From a1b88bdd5f8317e59d909f3e1174342d1ff93bd2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 22 Nov 2015 12:55:23 -0500 Subject: [PATCH] reverting #769 --- PropertySheets/Platform.props | 2 +- Source/3rd Party/wx/art/wxwin16x16.xpm | 161 - Source/3rd Party/wx/art/wxwin32x32.xpm | 442 - Source/3rd Party/wx/include/msvc/wx/setup.h | 461 +- Source/3rd Party/wx/include/wx/aboutdlg.h | 169 - Source/3rd Party/wx/include/wx/accel.h | 30 +- Source/3rd Party/wx/include/wx/access.h | 376 - .../3rd Party/wx/include/wx/affinematrix2d.h | 51 - .../wx/include/wx/affinematrix2dbase.h | 127 - Source/3rd Party/wx/include/wx/afterstd.h | 39 +- Source/3rd Party/wx/include/wx/anidecod.h | 17 +- Source/3rd Party/wx/include/wx/animate.h | 125 - Source/3rd Party/wx/include/wx/animdecod.h | 50 +- Source/3rd Party/wx/include/wx/any.h | 1113 -- Source/3rd Party/wx/include/wx/anybutton.h | 199 - Source/3rd Party/wx/include/wx/anystr.h | 139 - Source/3rd Party/wx/include/wx/app.h | 561 +- Source/3rd Party/wx/include/wx/apptrait.h | 144 +- Source/3rd Party/wx/include/wx/archive.h | 7 +- Source/3rd Party/wx/include/wx/arrimpl.cpp | 13 +- Source/3rd Party/wx/include/wx/arrstr.h | 267 +- Source/3rd Party/wx/include/wx/artprov.h | 89 +- Source/3rd Party/wx/include/wx/atomic.h | 159 - Source/3rd Party/wx/include/wx/bannerwindow.h | 144 - Source/3rd Party/wx/include/wx/base64.h | 121 - Source/3rd Party/wx/include/wx/beforestd.h | 48 +- Source/3rd Party/wx/include/wx/bitmap.h | 152 +- Source/3rd Party/wx/include/wx/bmpbuttn.h | 114 +- Source/3rd Party/wx/include/wx/bmpcbox.h | 125 - Source/3rd Party/wx/include/wx/bookctrl.h | 144 +- Source/3rd Party/wx/include/wx/brush.h | 104 +- Source/3rd Party/wx/include/wx/buffer.h | 570 +- Source/3rd Party/wx/include/wx/build.h | 66 +- Source/3rd Party/wx/include/wx/busyinfo.h | 1 + Source/3rd Party/wx/include/wx/button.h | 67 +- Source/3rd Party/wx/include/wx/calctrl.h | 396 - Source/3rd Party/wx/include/wx/caret.h | 17 +- Source/3rd Party/wx/include/wx/chartype.h | 304 - Source/3rd Party/wx/include/wx/checkbox.h | 78 +- .../3rd Party/wx/include/wx/checkeddelete.h | 44 - Source/3rd Party/wx/include/wx/checklst.h | 11 +- Source/3rd Party/wx/include/wx/chkconf.h | 916 +- Source/3rd Party/wx/include/wx/choicdlg.h | 8 +- Source/3rd Party/wx/include/wx/choice.h | 19 +- Source/3rd Party/wx/include/wx/choicebk.h | 80 +- Source/3rd Party/wx/include/wx/clipbrd.h | 89 +- Source/3rd Party/wx/include/wx/clntdata.h | 111 + Source/3rd Party/wx/include/wx/clrpicker.h | 33 +- Source/3rd Party/wx/include/wx/cmdargs.h | 151 - Source/3rd Party/wx/include/wx/cmdline.h | 88 +- Source/3rd Party/wx/include/wx/cmdproc.h | 12 +- Source/3rd Party/wx/include/wx/cmndata.h | 183 +- Source/3rd Party/wx/include/wx/collpane.h | 20 +- Source/3rd Party/wx/include/wx/colordlg.h | 16 +- Source/3rd Party/wx/include/wx/colour.h | 150 +- Source/3rd Party/wx/include/wx/colourdata.h | 51 - Source/3rd Party/wx/include/wx/combo.h | 217 +- Source/3rd Party/wx/include/wx/combobox.h | 71 +- .../wx/include/wx/commandlinkbutton.h | 169 - Source/3rd Party/wx/include/wx/compiler.h | 144 - Source/3rd Party/wx/include/wx/compositewin.h | 229 - Source/3rd Party/wx/include/wx/confbase.h | 171 +- Source/3rd Party/wx/include/wx/config.h | 28 +- Source/3rd Party/wx/include/wx/containr.h | 434 +- Source/3rd Party/wx/include/wx/control.h | 153 +- Source/3rd Party/wx/include/wx/convauto.h | 115 +- Source/3rd Party/wx/include/wx/cpp.h | 136 +- Source/3rd Party/wx/include/wx/cppunit.h | 301 - Source/3rd Party/wx/include/wx/crt.h | 22 - Source/3rd Party/wx/include/wx/cshelp.h | 17 +- Source/3rd Party/wx/include/wx/ctrlsub.h | 399 +- Source/3rd Party/wx/include/wx/cursor.h | 42 +- Source/3rd Party/wx/include/wx/custombgwin.h | 52 - Source/3rd Party/wx/include/wx/dataobj.h | 121 +- Source/3rd Party/wx/include/wx/dataview.h | 1356 --- Source/3rd Party/wx/include/wx/datectrl.h | 113 - Source/3rd Party/wx/include/wx/dateevt.h | 64 - Source/3rd Party/wx/include/wx/datetime.h | 459 +- Source/3rd Party/wx/include/wx/datetimectrl.h | 47 - Source/3rd Party/wx/include/wx/datstrm.h | 96 +- Source/3rd Party/wx/include/wx/dc.h | 1818 ++-- Source/3rd Party/wx/include/wx/dcbuffer.h | 64 +- Source/3rd Party/wx/include/wx/dcclient.h | 78 +- Source/3rd Party/wx/include/wx/dcgraph.h | 138 +- Source/3rd Party/wx/include/wx/dcmemory.h | 66 +- Source/3rd Party/wx/include/wx/dcmirror.h | 98 +- Source/3rd Party/wx/include/wx/dcprint.h | 37 +- Source/3rd Party/wx/include/wx/dcps.h | 17 - Source/3rd Party/wx/include/wx/dcscreen.h | 41 +- Source/3rd Party/wx/include/wx/dcsvg.h | 227 - Source/3rd Party/wx/include/wx/dde.h | 5 +- Source/3rd Party/wx/include/wx/debug.h | 632 +- Source/3rd Party/wx/include/wx/debugrpt.h | 247 - Source/3rd Party/wx/include/wx/defs.h | 2057 ++-- Source/3rd Party/wx/include/wx/dialog.h | 324 +- Source/3rd Party/wx/include/wx/dialup.h | 19 +- Source/3rd Party/wx/include/wx/dir.h | 49 +- Source/3rd Party/wx/include/wx/dirctrl.h | 17 - Source/3rd Party/wx/include/wx/dirdlg.h | 19 +- Source/3rd Party/wx/include/wx/display.h | 9 +- Source/3rd Party/wx/include/wx/display_impl.h | 11 +- Source/3rd Party/wx/include/wx/dlimpexp.h | 179 +- Source/3rd Party/wx/include/wx/dlist.h | 850 -- Source/3rd Party/wx/include/wx/dnd.h | 27 +- Source/3rd Party/wx/include/wx/docmdi.h | 133 +- Source/3rd Party/wx/include/wx/docview.h | 802 +- Source/3rd Party/wx/include/wx/dragimag.h | 53 - Source/3rd Party/wx/include/wx/dvrenderers.h | 445 - Source/3rd Party/wx/include/wx/dynarray.h | 182 +- Source/3rd Party/wx/include/wx/dynlib.h | 100 +- Source/3rd Party/wx/include/wx/dynload.h | 14 +- Source/3rd Party/wx/include/wx/editlbox.h | 99 - Source/3rd Party/wx/include/wx/effects.h | 33 +- Source/3rd Party/wx/include/wx/encconv.h | 20 +- Source/3rd Party/wx/include/wx/encinfo.h | 14 +- Source/3rd Party/wx/include/wx/event.h | 3026 ++---- Source/3rd Party/wx/include/wx/eventfilter.h | 71 - Source/3rd Party/wx/include/wx/evtloop.h | 314 +- Source/3rd Party/wx/include/wx/evtloopsrc.h | 103 - Source/3rd Party/wx/include/wx/except.h | 22 +- Source/3rd Party/wx/include/wx/fdrepdlg.h | 50 +- Source/3rd Party/wx/include/wx/features.h | 66 +- Source/3rd Party/wx/include/wx/ffile.h | 14 +- Source/3rd Party/wx/include/wx/file.h | 79 +- Source/3rd Party/wx/include/wx/fileconf.h | 33 +- Source/3rd Party/wx/include/wx/filectrl.h | 145 - Source/3rd Party/wx/include/wx/filedlg.h | 134 +- Source/3rd Party/wx/include/wx/filefn.h | 482 +- Source/3rd Party/wx/include/wx/filehistory.h | 113 - Source/3rd Party/wx/include/wx/filename.h | 190 +- Source/3rd Party/wx/include/wx/filepicker.h | 216 +- Source/3rd Party/wx/include/wx/filesys.h | 48 +- Source/3rd Party/wx/include/wx/flags.h | 17 +- Source/3rd Party/wx/include/wx/fmappriv.h | 3 +- Source/3rd Party/wx/include/wx/font.h | 421 +- Source/3rd Party/wx/include/wx/fontdata.h | 70 - Source/3rd Party/wx/include/wx/fontdlg.h | 19 +- Source/3rd Party/wx/include/wx/fontenc.h | 18 +- Source/3rd Party/wx/include/wx/fontenum.h | 16 +- Source/3rd Party/wx/include/wx/fontmap.h | 9 +- Source/3rd Party/wx/include/wx/fontpicker.h | 34 +- Source/3rd Party/wx/include/wx/fontutil.h | 91 +- Source/3rd Party/wx/include/wx/frame.h | 83 +- Source/3rd Party/wx/include/wx/fs_arc.h | 3 +- Source/3rd Party/wx/include/wx/fs_filter.h | 3 +- Source/3rd Party/wx/include/wx/fs_inet.h | 33 - Source/3rd Party/wx/include/wx/fs_mem.h | 35 +- Source/3rd Party/wx/include/wx/fs_zip.h | 22 - Source/3rd Party/wx/include/wx/fswatcher.h | 411 - Source/3rd Party/wx/include/wx/gauge.h | 16 +- Source/3rd Party/wx/include/wx/gbsizer.h | 94 +- Source/3rd Party/wx/include/wx/gdicmn.h | 614 +- Source/3rd Party/wx/include/wx/gdiobj.h | 55 +- .../wx/include/wx/generic/aboutdlgg.h | 102 - .../3rd Party/wx/include/wx/generic/accel.h | 49 - .../3rd Party/wx/include/wx/generic/animate.h | 177 - .../3rd Party/wx/include/wx/generic/bmpcbox.h | 136 - .../wx/include/wx/generic/busyinfo.h | 15 +- .../wx/include/wx/generic/buttonbar.h | 123 - .../wx/include/wx/generic/calctrlg.h | 316 - .../3rd Party/wx/include/wx/generic/caret.h | 94 - .../wx/include/wx/generic/choicdgg.h | 202 +- .../wx/include/wx/generic/clrpickerg.h | 24 +- .../wx/include/wx/generic/collpaneg.h | 31 +- .../3rd Party/wx/include/wx/generic/colour.h | 71 - .../wx/include/wx/generic/colrdlgg.h | 116 - .../3rd Party/wx/include/wx/generic/combo.h | 40 +- .../3rd Party/wx/include/wx/generic/ctrlsub.h | 122 - .../wx/include/wx/generic/custombgwin.h | 95 - .../wx/include/wx/generic/dataview.h | 292 - .../wx/include/wx/generic/datectrl.h | 96 - .../3rd Party/wx/include/wx/generic/dcpsg.h | 159 - .../wx/include/wx/generic/dirctrlg.h | 71 +- .../3rd Party/wx/include/wx/generic/dirdlgg.h | 88 - .../wx/include/wx/generic/dragimgg.h | 18 +- .../wx/include/wx/generic/dvrenderer.h | 67 - .../wx/include/wx/generic/dvrenderers.h | 183 - .../wx/include/wx/generic/fdrepdlg.h | 70 - .../wx/include/wx/generic/filectrlg.h | 303 - .../wx/include/wx/generic/filedlgg.h | 160 - .../wx/include/wx/generic/filepickerg.h | 74 +- .../wx/include/wx/generic/fontdlgg.h | 109 - .../wx/include/wx/generic/fontpickerg.h | 17 +- .../wx/include/wx/generic/fswatcher.h | 25 - Source/3rd Party/wx/include/wx/generic/grid.h | 2723 ----- .../wx/include/wx/generic/gridctrl.h | 276 - .../wx/include/wx/generic/grideditors.h | 378 - .../3rd Party/wx/include/wx/generic/gridsel.h | 115 - .../wx/include/wx/generic/headerctrlg.h | 181 - .../3rd Party/wx/include/wx/generic/helpext.h | 105 - .../wx/include/wx/generic/hyperlink.h | 144 - Source/3rd Party/wx/include/wx/generic/icon.h | 62 - .../wx/include/wx/generic/imaglist.h | 79 - .../3rd Party/wx/include/wx/generic/infobar.h | 137 - .../3rd Party/wx/include/wx/generic/laywin.h | 227 - .../wx/include/wx/generic/listctrl.h | 283 - Source/3rd Party/wx/include/wx/generic/logg.h | 55 +- Source/3rd Party/wx/include/wx/generic/mask.h | 53 - Source/3rd Party/wx/include/wx/generic/mdig.h | 260 - .../3rd Party/wx/include/wx/generic/msgdlgg.h | 53 +- .../wx/include/wx/generic/notebook.h | 21 +- .../wx/include/wx/generic/notifmsg.h | 60 - .../3rd Party/wx/include/wx/generic/numdlgg.h | 23 +- .../wx/include/wx/generic/paletteg.h | 50 - .../3rd Party/wx/include/wx/generic/panelg.h | 83 +- .../3rd Party/wx/include/wx/generic/printps.h | 67 - .../wx/include/wx/generic/private/grid.h | 948 -- .../wx/include/wx/generic/private/listctrl.h | 869 -- .../include/wx/generic/private/markuptext.h | 77 - .../include/wx/generic/private/richtooltip.h | 64 - .../include/wx/generic/private/textmeasure.h | 39 - .../wx/include/wx/generic/prntdlgg.h | 16 +- .../wx/include/wx/generic/progdlgg.h | 295 +- .../3rd Party/wx/include/wx/generic/propdlg.h | 168 - .../3rd Party/wx/include/wx/generic/region.h | 81 - .../wx/include/wx/generic/richmsgdlgg.h | 48 - .../3rd Party/wx/include/wx/generic/sashwin.h | 267 - .../wx/include/wx/generic/scrolwin.h | 50 +- .../wx/include/wx/generic/spinctlg.h | 447 +- .../3rd Party/wx/include/wx/generic/splash.h | 97 - .../wx/include/wx/generic/splitter.h | 79 +- .../wx/include/wx/generic/srchctlg.h | 23 +- .../wx/include/wx/generic/statbmpg.h | 75 - .../wx/include/wx/generic/statline.h | 5 +- .../wx/include/wx/generic/stattextg.h | 90 - .../wx/include/wx/generic/statusbr.h | 70 +- Source/3rd Party/wx/include/wx/generic/tabg.h | 358 - .../wx/include/wx/generic/textdlgg.h | 85 +- .../wx/include/wx/generic/timectrl.h | 69 - .../include/wx/generic/{private => }/timer.h | 24 +- .../wx/include/wx/generic/treectlg.h | 64 +- .../3rd Party/wx/include/wx/generic/wizard.h | 168 - Source/3rd Party/wx/include/wx/geometry.h | 84 +- Source/3rd Party/wx/include/wx/gifdecod.h | 21 +- Source/3rd Party/wx/include/wx/glcanvas.h | 248 - Source/3rd Party/wx/include/wx/graphics.h | 727 +- Source/3rd Party/wx/include/wx/grid.h | 21 - Source/3rd Party/wx/include/wx/gsocket.h | 184 + Source/3rd Party/wx/include/wx/hash.h | 360 +- Source/3rd Party/wx/include/wx/hashmap.h | 221 +- Source/3rd Party/wx/include/wx/hashset.h | 99 +- Source/3rd Party/wx/include/wx/headercol.h | 288 - Source/3rd Party/wx/include/wx/headerctrl.h | 488 - Source/3rd Party/wx/include/wx/help.h | 7 +- Source/3rd Party/wx/include/wx/helpbase.h | 7 +- Source/3rd Party/wx/include/wx/helphtml.h | 19 - Source/3rd Party/wx/include/wx/helpwin.h | 21 - Source/3rd Party/wx/include/wx/htmllbox.h | 321 - Source/3rd Party/wx/include/wx/hyperlink.h | 173 - Source/3rd Party/wx/include/wx/icon.h | 39 +- Source/3rd Party/wx/include/wx/iconbndl.h | 121 +- Source/3rd Party/wx/include/wx/iconloc.h | 7 +- Source/3rd Party/wx/include/wx/imagbmp.h | 22 +- Source/3rd Party/wx/include/wx/image.h | 313 +- Source/3rd Party/wx/include/wx/imaggif.h | 67 +- Source/3rd Party/wx/include/wx/imagiff.h | 7 +- Source/3rd Party/wx/include/wx/imagjpeg.h | 10 +- Source/3rd Party/wx/include/wx/imaglist.h | 9 +- Source/3rd Party/wx/include/wx/imagpcx.h | 5 +- Source/3rd Party/wx/include/wx/imagpng.h | 16 +- Source/3rd Party/wx/include/wx/imagpnm.h | 8 +- Source/3rd Party/wx/include/wx/imagtga.h | 4 +- Source/3rd Party/wx/include/wx/imagtiff.h | 26 +- Source/3rd Party/wx/include/wx/imagxpm.h | 11 +- Source/3rd Party/wx/include/wx/infobar.h | 67 - Source/3rd Party/wx/include/wx/init.h | 25 +- Source/3rd Party/wx/include/wx/intl.h | 476 +- Source/3rd Party/wx/include/wx/iosfwrap.h | 3 +- Source/3rd Party/wx/include/wx/ioswrap.h | 7 +- Source/3rd Party/wx/include/wx/ipc.h | 44 - Source/3rd Party/wx/include/wx/ipcbase.h | 232 +- Source/3rd Party/wx/include/wx/itemid.h | 61 - Source/3rd Party/wx/include/wx/joystick.h | 37 - Source/3rd Party/wx/include/wx/kbdstate.h | 121 - Source/3rd Party/wx/include/wx/language.h | 282 - Source/3rd Party/wx/include/wx/layout.h | 5 +- Source/3rd Party/wx/include/wx/laywin.h | 17 - Source/3rd Party/wx/include/wx/link.h | 31 - Source/3rd Party/wx/include/wx/list.h | 277 +- Source/3rd Party/wx/include/wx/listbase.h | 238 +- Source/3rd Party/wx/include/wx/listbook.h | 75 +- Source/3rd Party/wx/include/wx/listbox.h | 83 +- Source/3rd Party/wx/include/wx/listctrl.h | 11 +- Source/3rd Party/wx/include/wx/listimpl.cpp | 20 +- Source/3rd Party/wx/include/wx/log.h | 1504 +-- Source/3rd Party/wx/include/wx/longlong.h | 78 +- Source/3rd Party/wx/include/wx/math.h | 121 +- Source/3rd Party/wx/include/wx/matrix.h | 3 +- Source/3rd Party/wx/include/wx/mdi.h | 393 +- Source/3rd Party/wx/include/wx/mediactrl.h | 403 - Source/3rd Party/wx/include/wx/memconf.h | 3 +- Source/3rd Party/wx/include/wx/memory.h | 61 +- Source/3rd Party/wx/include/wx/memtext.h | 4 +- Source/3rd Party/wx/include/wx/menu.h | 149 +- Source/3rd Party/wx/include/wx/menuitem.h | 100 +- .../wx/include/wx/meta/convertible.h | 38 - Source/3rd Party/wx/include/wx/meta/if.h | 72 - .../wx/include/wx/meta/implicitconversion.h | 112 - .../3rd Party/wx/include/wx/meta/int2type.h | 16 - Source/3rd Party/wx/include/wx/meta/movable.h | 44 - Source/3rd Party/wx/include/wx/meta/pod.h | 87 - .../3rd Party/wx/include/wx/meta/removeref.h | 36 - Source/3rd Party/wx/include/wx/metafile.h | 15 +- Source/3rd Party/wx/include/wx/mimetype.h | 145 +- Source/3rd Party/wx/include/wx/minifram.h | 7 +- Source/3rd Party/wx/include/wx/modalhook.h | 104 - Source/3rd Party/wx/include/wx/module.h | 22 +- Source/3rd Party/wx/include/wx/mousemanager.h | 153 - Source/3rd Party/wx/include/wx/mousestate.h | 149 - Source/3rd Party/wx/include/wx/msgdlg.h | 302 +- Source/3rd Party/wx/include/wx/msgout.h | 132 +- Source/3rd Party/wx/include/wx/msgqueue.h | 168 - Source/3rd Party/wx/include/wx/mstream.h | 25 +- Source/3rd Party/wx/include/wx/msw/accel.h | 3 +- .../3rd Party/wx/include/wx/msw/anybutton.h | 80 - Source/3rd Party/wx/include/wx/msw/app.h | 122 +- Source/3rd Party/wx/include/wx/msw/apptbase.h | 34 +- Source/3rd Party/wx/include/wx/msw/apptrait.h | 65 +- Source/3rd Party/wx/include/wx/msw/bitmap.h | 138 +- Source/3rd Party/wx/include/wx/msw/bmpbuttn.h | 28 +- Source/3rd Party/wx/include/wx/msw/bmpcbox.h | 135 - Source/3rd Party/wx/include/wx/msw/brush.h | 31 +- Source/3rd Party/wx/include/wx/msw/button.h | 41 +- Source/3rd Party/wx/include/wx/msw/calctrl.h | 98 - Source/3rd Party/wx/include/wx/msw/caret.h | 7 +- Source/3rd Party/wx/include/wx/msw/checkbox.h | 19 +- Source/3rd Party/wx/include/wx/msw/checklst.h | 94 +- Source/3rd Party/wx/include/wx/msw/chkconf.h | 289 +- Source/3rd Party/wx/include/wx/msw/choice.h | 75 +- Source/3rd Party/wx/include/wx/msw/clipbrd.h | 39 +- Source/3rd Party/wx/include/wx/msw/colordlg.h | 41 +- Source/3rd Party/wx/include/wx/msw/colour.h | 26 +- Source/3rd Party/wx/include/wx/msw/combo.h | 18 +- Source/3rd Party/wx/include/wx/msw/combobox.h | 104 +- .../wx/include/wx/msw/commandlinkbutton.h | 73 - Source/3rd Party/wx/include/wx/msw/control.h | 12 +- Source/3rd Party/wx/include/wx/msw/crashrpt.h | 5 +- Source/3rd Party/wx/include/wx/msw/ctrlsub.h | 42 - Source/3rd Party/wx/include/wx/msw/cursor.h | 15 +- .../3rd Party/wx/include/wx/msw/custombgwin.h | 57 - Source/3rd Party/wx/include/wx/msw/datectrl.h | 66 - .../wx/include/wx/msw/datetimectrl.h | 88 - Source/3rd Party/wx/include/wx/msw/dc.h | 112 +- Source/3rd Party/wx/include/wx/msw/dcclient.h | 76 +- Source/3rd Party/wx/include/wx/msw/dcmemory.h | 21 +- Source/3rd Party/wx/include/wx/msw/dcprint.h | 44 +- Source/3rd Party/wx/include/wx/msw/dcscreen.h | 19 +- Source/3rd Party/wx/include/wx/msw/dde.h | 115 +- Source/3rd Party/wx/include/wx/msw/debughlp.h | 85 +- Source/3rd Party/wx/include/wx/msw/dialog.h | 60 +- Source/3rd Party/wx/include/wx/msw/dib.h | 44 +- Source/3rd Party/wx/include/wx/msw/dirdlg.h | 8 +- Source/3rd Party/wx/include/wx/msw/dragimag.h | 56 +- Source/3rd Party/wx/include/wx/msw/enhmeta.h | 41 +- Source/3rd Party/wx/include/wx/msw/evtloop.h | 35 +- .../wx/include/wx/msw/evtloopconsole.h | 51 - Source/3rd Party/wx/include/wx/msw/fdrepdlg.h | 5 +- Source/3rd Party/wx/include/wx/msw/filedlg.h | 24 +- Source/3rd Party/wx/include/wx/msw/font.h | 98 +- Source/3rd Party/wx/include/wx/msw/fontdlg.h | 3 +- Source/3rd Party/wx/include/wx/msw/frame.h | 30 +- .../3rd Party/wx/include/wx/msw/fswatcher.h | 37 - .../wx/include/wx/msw/{gauge.h => gauge95.h} | 55 +- Source/3rd Party/wx/include/wx/msw/gccpriv.h | 55 +- Source/3rd Party/wx/include/wx/msw/gdiimage.h | 120 +- .../3rd Party/wx/include/wx/msw/genrcdefs.h | 11 +- Source/3rd Party/wx/include/wx/msw/glcanvas.h | 158 - Source/3rd Party/wx/include/wx/msw/gsockmsw.h | 145 + .../3rd Party/wx/include/wx/msw/headerctrl.h | 136 - Source/3rd Party/wx/include/wx/msw/helpbest.h | 128 - Source/3rd Party/wx/include/wx/msw/helpchm.h | 51 +- Source/3rd Party/wx/include/wx/msw/helpwin.h | 7 +- Source/3rd Party/wx/include/wx/msw/htmlhelp.h | 4 +- .../3rd Party/wx/include/wx/msw/hyperlink.h | 64 - Source/3rd Party/wx/include/wx/msw/icon.h | 21 +- Source/3rd Party/wx/include/wx/msw/imaglist.h | 5 +- Source/3rd Party/wx/include/wx/msw/iniconf.h | 20 +- Source/3rd Party/wx/include/wx/msw/init.h | 90 - Source/3rd Party/wx/include/wx/msw/joystick.h | 91 - .../3rd Party/wx/include/wx/msw/libraries.h | 1 + Source/3rd Party/wx/include/wx/msw/listbox.h | 80 +- Source/3rd Party/wx/include/wx/msw/listctrl.h | 126 +- Source/3rd Party/wx/include/wx/msw/mdi.h | 139 +- Source/3rd Party/wx/include/wx/msw/menu.h | 141 +- Source/3rd Party/wx/include/wx/msw/menuitem.h | 122 +- Source/3rd Party/wx/include/wx/msw/metafile.h | 189 - Source/3rd Party/wx/include/wx/msw/microwin.h | 234 - Source/3rd Party/wx/include/wx/msw/mimetype.h | 9 +- Source/3rd Party/wx/include/wx/msw/minifram.h | 3 +- Source/3rd Party/wx/include/wx/msw/missing.h | 273 +- Source/3rd Party/wx/include/wx/msw/msgdlg.h | 76 +- Source/3rd Party/wx/include/wx/msw/mslu.h | 1 + Source/3rd Party/wx/include/wx/msw/msvcrt.h | 22 +- .../3rd Party/wx/include/wx/msw/nonownedwnd.h | 38 - Source/3rd Party/wx/include/wx/msw/notebook.h | 65 +- Source/3rd Party/wx/include/wx/msw/notifmsg.h | 74 - .../3rd Party/wx/include/wx/msw/ole/access.h | 67 - .../3rd Party/wx/include/wx/msw/ole/activex.h | 210 +- .../3rd Party/wx/include/wx/msw/ole/automtn.h | 65 +- .../wx/include/wx/msw/ole/dataform.h | 28 +- .../3rd Party/wx/include/wx/msw/ole/dataobj.h | 9 +- .../wx/include/wx/msw/ole/dataobj2.h | 17 +- .../3rd Party/wx/include/wx/msw/ole/dropsrc.h | 9 +- .../3rd Party/wx/include/wx/msw/ole/droptgt.h | 35 +- .../wx/include/wx/msw/ole/oleutils.h | 190 +- .../wx/include/wx/msw/ole/safearray.h | 394 - Source/3rd Party/wx/include/wx/msw/ole/uuid.h | 11 +- Source/3rd Party/wx/include/wx/msw/ownerdrw.h | 28 - Source/3rd Party/wx/include/wx/msw/palette.h | 52 +- Source/3rd Party/wx/include/wx/msw/panel.h | 56 - Source/3rd Party/wx/include/wx/msw/pen.h | 130 +- Source/3rd Party/wx/include/wx/msw/popupwin.h | 5 +- Source/3rd Party/wx/include/wx/msw/printdlg.h | 33 +- Source/3rd Party/wx/include/wx/msw/printwin.h | 18 +- Source/3rd Party/wx/include/wx/msw/private.h | 295 +- .../wx/include/wx/msw/private/button.h | 76 - .../wx/include/wx/msw/private/comptr.h | 129 - .../wx/include/wx/msw/private/datecontrols.h | 30 - .../3rd Party/wx/include/wx/msw/private/dc.h | 147 - .../wx/include/wx/msw/private/fswatcher.h | 335 - .../wx/include/wx/msw/private/hiddenwin.h | 30 - .../wx/include/wx/msw/private/keyboard.h | 41 - .../wx/include/wx/msw/private/metrics.h | 48 - .../wx/include/wx/msw/private/msgdlg.h | 93 - .../wx/include/wx/msw/private/pipestream.h | 50 - .../wx/include/wx/msw/private/sockmsw.h | 66 - .../wx/include/wx/msw/private/textmeasure.h | 63 - .../wx/include/wx/msw/private/timer.h | 36 - Source/3rd Party/wx/include/wx/msw/progdlg.h | 73 - Source/3rd Party/wx/include/wx/msw/radiobox.h | 34 +- Source/3rd Party/wx/include/wx/msw/radiobut.h | 6 +- Source/3rd Party/wx/include/wx/msw/rcdefs.h | 41 - Source/3rd Party/wx/include/wx/msw/regconf.h | 28 +- Source/3rd Party/wx/include/wx/msw/region.h | 11 +- Source/3rd Party/wx/include/wx/msw/registry.h | 98 +- .../3rd Party/wx/include/wx/msw/richmsgdlg.h | 30 - Source/3rd Party/wx/include/wx/msw/scrolbar.h | 8 +- Source/3rd Party/wx/include/wx/msw/seh.h | 7 +- Source/3rd Party/wx/include/wx/msw/setup.h | 734 +- .../3rd Party/wx/include/wx/msw/setup_inc.h | 164 - .../include/wx/msw/{slider.h => slider95.h} | 34 +- Source/3rd Party/wx/include/wx/msw/sound.h | 51 - Source/3rd Party/wx/include/wx/msw/spinbutt.h | 8 +- Source/3rd Party/wx/include/wx/msw/spinctrl.h | 63 +- .../3rd Party/wx/include/wx/msw/stackwalk.h | 15 +- Source/3rd Party/wx/include/wx/msw/statbmp.h | 24 +- Source/3rd Party/wx/include/wx/msw/statbox.h | 9 +- Source/3rd Party/wx/include/wx/msw/statbr95.h | 76 + Source/3rd Party/wx/include/wx/msw/statline.h | 7 +- Source/3rd Party/wx/include/wx/msw/stattext.h | 9 +- .../3rd Party/wx/include/wx/msw/statusbar.h | 111 - Source/3rd Party/wx/include/wx/msw/stdpaths.h | 46 +- Source/3rd Party/wx/include/wx/msw/subwin.h | 57 +- Source/3rd Party/wx/include/wx/msw/taskbar.h | 70 - .../wx/include/wx/msw/{toolbar.h => tbar95.h} | 69 +- Source/3rd Party/wx/include/wx/msw/textctrl.h | 148 +- .../3rd Party/wx/include/wx/msw/textentry.h | 102 - Source/3rd Party/wx/include/wx/msw/tglbtn.h | 66 +- Source/3rd Party/wx/include/wx/msw/timectrl.h | 62 - Source/3rd Party/wx/include/wx/msw/timer.h | 40 + Source/3rd Party/wx/include/wx/msw/tls.h | 116 - Source/3rd Party/wx/include/wx/msw/tooltip.h | 54 +- Source/3rd Party/wx/include/wx/msw/toplevel.h | 95 +- Source/3rd Party/wx/include/wx/msw/treectrl.h | 117 +- Source/3rd Party/wx/include/wx/msw/uxtheme.h | 83 +- Source/3rd Party/wx/include/wx/msw/uxthemep.h | 4 +- .../3rd Party/wx/include/wx/msw/webview_ie.h | 356 - .../wx/include/wx/msw/webview_missing.h | 947 -- .../wx/include/wx/msw/webviewhistoryitem_ie.h | 30 - Source/3rd Party/wx/include/wx/msw/window.h | 346 +- Source/3rd Party/wx/include/wx/msw/winundef.h | 29 +- Source/3rd Party/wx/include/wx/msw/wrapcctl.h | 36 +- Source/3rd Party/wx/include/wx/msw/wrapcdlg.h | 1 + Source/3rd Party/wx/include/wx/msw/wrapgdip.h | 31 - Source/3rd Party/wx/include/wx/msw/wrapshl.h | 10 +- Source/3rd Party/wx/include/wx/msw/wrapwin.h | 33 +- Source/3rd Party/wx/include/wx/nativewin.h | 173 - Source/3rd Party/wx/include/wx/nonownedwnd.h | 113 - Source/3rd Party/wx/include/wx/notebook.h | 120 +- Source/3rd Party/wx/include/wx/notifmsg.h | 159 - Source/3rd Party/wx/include/wx/numdlg.h | 1 + Source/3rd Party/wx/include/wx/numformatter.h | 78 - Source/3rd Party/wx/include/wx/object.h | 550 +- Source/3rd Party/wx/include/wx/odcombo.h | 399 - Source/3rd Party/wx/include/wx/overlay.h | 29 +- Source/3rd Party/wx/include/wx/ownerdrw.h | 202 +- Source/3rd Party/wx/include/wx/palette.h | 27 +- Source/3rd Party/wx/include/wx/panel.h | 60 +- Source/3rd Party/wx/include/wx/paper.h | 9 +- Source/3rd Party/wx/include/wx/pen.h | 156 +- Source/3rd Party/wx/include/wx/persist.h | 263 - Source/3rd Party/wx/include/wx/pickerbase.h | 19 +- Source/3rd Party/wx/include/wx/platform.h | 899 +- Source/3rd Party/wx/include/wx/platinfo.h | 80 +- Source/3rd Party/wx/include/wx/popupwin.h | 35 +- Source/3rd Party/wx/include/wx/position.h | 59 - Source/3rd Party/wx/include/wx/power.h | 23 +- Source/3rd Party/wx/include/wx/preferences.h | 145 - Source/3rd Party/wx/include/wx/print.h | 3 +- Source/3rd Party/wx/include/wx/printdlg.h | 27 +- .../wx/include/wx/private/browserhack28.h | 20 + .../wx/private/eventloopsourcesmanager.h | 25 - Source/3rd Party/wx/include/wx/private/fd.h | 53 - .../wx/include/wx/private/fdiodispatcher.h | 118 - .../wx/private/fdioeventloopsourcehandler.h | 38 - .../wx/include/wx/private/fdiohandler.h | 53 - .../wx/include/wx/private/fdiomanager.h | 42 - .../wx/include/wx/private/fileback.h | 5 +- .../wx/include/wx/private/filename.h | 3 +- .../wx/include/wx/private/flagscheck.h | 116 - .../3rd Party/wx/include/wx/private/fontmgr.h | 247 - .../wx/include/wx/private/fswatcher.h | 115 - .../wx/include/wx/private/graphics.h | 168 - .../wx/include/wx/private/markupparser.h | 176 - .../wx/include/wx/private/markupparserattr.h | 231 - .../3rd Party/wx/include/wx/private/overlay.h | 18 +- .../wx/include/wx/private/pipestream.h | 29 - .../wx/include/wx/private/preferences.h | 40 - .../wx/include/wx/private/richtooltip.h | 44 - .../3rd Party/wx/include/wx/private/sckaddr.h | 323 - .../wx/include/wx/private/selectdispatcher.h | 126 - .../3rd Party/wx/include/wx/private/socket.h | 373 - .../wx/include/wx/private/textmeasure.h | 174 - .../wx/include/wx/private/threadinfo.h | 69 - .../3rd Party/wx/include/wx/private/timer.h | 72 - .../3rd Party/wx/include/wx/private/window.h | 38 - .../wx/include/wx/private/wxprintf.h | 934 -- Source/3rd Party/wx/include/wx/prntbase.h | 213 +- Source/3rd Party/wx/include/wx/process.h | 31 +- Source/3rd Party/wx/include/wx/progdlg.h | 29 +- Source/3rd Party/wx/include/wx/propdlg.h | 18 - Source/3rd Party/wx/include/wx/ptr_scpd.h | 229 +- Source/3rd Party/wx/include/wx/ptr_shrd.h | 11 - Source/3rd Party/wx/include/wx/quantize.h | 3 +- Source/3rd Party/wx/include/wx/radiobox.h | 21 +- Source/3rd Party/wx/include/wx/radiobut.h | 7 +- Source/3rd Party/wx/include/wx/range.h | 28 - Source/3rd Party/wx/include/wx/rawbmp.h | 93 +- .../3rd Party/wx/include/wx/rearrangectrl.h | 232 - Source/3rd Party/wx/include/wx/recguard.h | 1 + Source/3rd Party/wx/include/wx/regex.h | 14 +- Source/3rd Party/wx/include/wx/region.h | 23 +- Source/3rd Party/wx/include/wx/renderer.h | 177 +- Source/3rd Party/wx/include/wx/richmsgdlg.h | 88 - Source/3rd Party/wx/include/wx/richtooltip.h | 103 - Source/3rd Party/wx/include/wx/rtti.h | 319 - Source/3rd Party/wx/include/wx/sashwin.h | 17 - Source/3rd Party/wx/include/wx/sckaddr.h | 222 - Source/3rd Party/wx/include/wx/sckipc.h | 159 - Source/3rd Party/wx/include/wx/sckstrm.h | 74 - Source/3rd Party/wx/include/wx/scopedarray.h | 119 - Source/3rd Party/wx/include/wx/scopedptr.h | 214 - Source/3rd Party/wx/include/wx/scopeguard.h | 223 +- Source/3rd Party/wx/include/wx/scrolbar.h | 20 +- Source/3rd Party/wx/include/wx/scrolwin.h | 332 +- Source/3rd Party/wx/include/wx/selstore.h | 34 +- Source/3rd Party/wx/include/wx/settings.h | 45 +- Source/3rd Party/wx/include/wx/setup_inc.h | 1499 --- .../3rd Party/wx/include/wx/setup_redirect.h | 17 - Source/3rd Party/wx/include/wx/sharedptr.h | 169 - Source/3rd Party/wx/include/wx/simplebook.h | 222 - Source/3rd Party/wx/include/wx/sizer.h | 553 +- Source/3rd Party/wx/include/wx/slider.h | 31 +- Source/3rd Party/wx/include/wx/snglinst.h | 43 +- Source/3rd Party/wx/include/wx/socket.h | 435 - Source/3rd Party/wx/include/wx/sound.h | 81 - Source/3rd Party/wx/include/wx/spinbutt.h | 35 +- Source/3rd Party/wx/include/wx/spinctrl.h | 134 +- Source/3rd Party/wx/include/wx/splash.h | 17 - Source/3rd Party/wx/include/wx/splitter.h | 17 +- Source/3rd Party/wx/include/wx/srchctrl.h | 39 +- Source/3rd Party/wx/include/wx/sstream.h | 40 +- Source/3rd Party/wx/include/wx/stack.h | 65 +- Source/3rd Party/wx/include/wx/stackwalk.h | 17 +- Source/3rd Party/wx/include/wx/statbmp.h | 14 +- Source/3rd Party/wx/include/wx/statbox.h | 22 +- Source/3rd Party/wx/include/wx/statline.h | 14 +- Source/3rd Party/wx/include/wx/stattext.h | 75 +- Source/3rd Party/wx/include/wx/statusbr.h | 184 +- Source/3rd Party/wx/include/wx/stdpaths.h | 98 +- Source/3rd Party/wx/include/wx/stdstream.h | 122 - Source/3rd Party/wx/include/wx/stockitem.h | 27 +- Source/3rd Party/wx/include/wx/stopwatch.h | 70 +- Source/3rd Party/wx/include/wx/strconv.h | 294 +- Source/3rd Party/wx/include/wx/stream.h | 161 +- Source/3rd Party/wx/include/wx/string.h | 4772 ++------- Source/3rd Party/wx/include/wx/stringimpl.h | 564 - Source/3rd Party/wx/include/wx/stringops.h | 172 - Source/3rd Party/wx/include/wx/strvararg.h | 1227 --- Source/3rd Party/wx/include/wx/sysopt.h | 9 +- Source/3rd Party/wx/include/wx/tarstrm.h | 9 +- Source/3rd Party/wx/include/wx/taskbar.h | 154 - Source/3rd Party/wx/include/wx/tbarbase.h | 262 +- Source/3rd Party/wx/include/wx/testing.h | 351 - Source/3rd Party/wx/include/wx/textbuf.h | 10 +- .../3rd Party/wx/include/wx/textcompleter.h | 86 - Source/3rd Party/wx/include/wx/textctrl.h | 765 +- Source/3rd Party/wx/include/wx/textdlg.h | 8 +- Source/3rd Party/wx/include/wx/textentry.h | 332 - Source/3rd Party/wx/include/wx/textfile.h | 3 +- Source/3rd Party/wx/include/wx/textwrapper.h | 128 - Source/3rd Party/wx/include/wx/tglbtn.h | 70 +- Source/3rd Party/wx/include/wx/thread.h | 217 +- Source/3rd Party/wx/include/wx/thrimpl.cpp | 35 +- Source/3rd Party/wx/include/wx/time.h | 76 - Source/3rd Party/wx/include/wx/timectrl.h | 124 - Source/3rd Party/wx/include/wx/timer.h | 125 +- Source/3rd Party/wx/include/wx/tipdlg.h | 85 - Source/3rd Party/wx/include/wx/tipwin.h | 5 +- Source/3rd Party/wx/include/wx/tls.h | 145 - Source/3rd Party/wx/include/wx/tokenzr.h | 25 +- Source/3rd Party/wx/include/wx/toolbar.h | 15 +- Source/3rd Party/wx/include/wx/toolbook.h | 67 +- Source/3rd Party/wx/include/wx/tooltip.h | 5 +- Source/3rd Party/wx/include/wx/toplevel.h | 165 +- Source/3rd Party/wx/include/wx/tracker.h | 91 - Source/3rd Party/wx/include/wx/translation.h | 323 - Source/3rd Party/wx/include/wx/treebase.h | 179 +- Source/3rd Party/wx/include/wx/treebook.h | 76 +- Source/3rd Party/wx/include/wx/treectrl.h | 78 +- Source/3rd Party/wx/include/wx/treelist.h | 576 - Source/3rd Party/wx/include/wx/txtstrm.h | 12 +- Source/3rd Party/wx/include/wx/typeinfo.h | 147 - Source/3rd Party/wx/include/wx/types.h | 92 - Source/3rd Party/wx/include/wx/uiaction.h | 90 - Source/3rd Party/wx/include/wx/unichar.h | 308 - Source/3rd Party/wx/include/wx/uri.h | 158 +- Source/3rd Party/wx/include/wx/url.h | 116 - Source/3rd Party/wx/include/wx/ustring.h | 749 -- Source/3rd Party/wx/include/wx/utils.h | 549 +- Source/3rd Party/wx/include/wx/valgen.h | 103 +- Source/3rd Party/wx/include/wx/validate.h | 38 +- Source/3rd Party/wx/include/wx/valnum.h | 463 - Source/3rd Party/wx/include/wx/valtext.h | 114 +- Source/3rd Party/wx/include/wx/variant.h | 311 +- Source/3rd Party/wx/include/wx/variantbase.h | 278 - Source/3rd Party/wx/include/wx/vector.h | 658 +- Source/3rd Party/wx/include/wx/version.h | 9 +- Source/3rd Party/wx/include/wx/versioninfo.h | 77 - Source/3rd Party/wx/include/wx/vidmode.h | 4 +- Source/3rd Party/wx/include/wx/vlbox.h | 37 +- Source/3rd Party/wx/include/wx/vms_x_fix.h | 1213 --- Source/3rd Party/wx/include/wx/volume.h | 5 +- Source/3rd Party/wx/include/wx/vscroll.h | 976 +- Source/3rd Party/wx/include/wx/weakref.h | 352 - Source/3rd Party/wx/include/wx/webview.h | 304 - .../wx/include/wx/webviewarchivehandler.h | 36 - .../wx/include/wx/webviewfshandler.h | 37 - Source/3rd Party/wx/include/wx/wfstream.h | 87 +- Source/3rd Party/wx/include/wx/window.h | 806 +- Source/3rd Party/wx/include/wx/windowid.h | 189 - Source/3rd Party/wx/include/wx/windowptr.h | 63 - Source/3rd Party/wx/include/wx/withimages.h | 96 - Source/3rd Party/wx/include/wx/wizard.h | 337 - Source/3rd Party/wx/include/wx/wrapsizer.h | 99 - Source/3rd Party/wx/include/wx/wupdlock.h | 3 +- Source/3rd Party/wx/include/wx/wx.h | 15 +- Source/3rd Party/wx/include/wx/wxchar.h | 1419 ++- Source/3rd Party/wx/include/wx/wxcrt.h | 986 -- Source/3rd Party/wx/include/wx/wxcrtbase.h | 690 -- Source/3rd Party/wx/include/wx/wxcrtvararg.h | 496 - Source/3rd Party/wx/include/wx/wxhtml.h | 21 - Source/3rd Party/wx/include/wx/wxprec.h | 24 +- Source/3rd Party/wx/include/wx/xlocale.h | 340 - Source/3rd Party/wx/include/wx/xpmdecod.h | 10 +- Source/3rd Party/wx/include/wx/xpmhand.h | 24 - Source/3rd Party/wx/include/wx/xti.h | 2173 +++- Source/3rd Party/wx/include/wx/xti2.h | 293 - Source/3rd Party/wx/include/wx/xtictor.h | 509 - Source/3rd Party/wx/include/wx/xtihandler.h | 112 - Source/3rd Party/wx/include/wx/xtiprop.h | 560 - Source/3rd Party/wx/include/wx/xtistrm.h | 408 - Source/3rd Party/wx/include/wx/xtitypes.h | 532 - Source/3rd Party/wx/include/wx/xtixml.h | 119 - Source/3rd Party/wx/include/wx/zipstrm.h | 6 +- Source/3rd Party/wx/include/wx/zstream.h | 28 +- Source/3rd Party/wx/src/common/accelcmn.cpp | 385 - Source/3rd Party/wx/src/common/accesscmn.cpp | 3 +- .../wx/src/common/affinematrix2d.cpp | 186 - Source/3rd Party/wx/src/common/anidecod.cpp | 53 +- Source/3rd Party/wx/src/common/animatecmn.cpp | 106 - Source/3rd Party/wx/src/common/any.cpp | 539 - Source/3rd Party/wx/src/common/appbase.cpp | 970 +- Source/3rd Party/wx/src/common/appcmn.cpp | 412 +- Source/3rd Party/wx/src/common/arcall.cpp | 1 + Source/3rd Party/wx/src/common/arcfind.cpp | 3 +- Source/3rd Party/wx/src/common/archive.cpp | 1 + Source/3rd Party/wx/src/common/arrstr.cpp | 576 - Source/3rd Party/wx/src/common/artprov.cpp | 268 +- Source/3rd Party/wx/src/common/artstd.cpp | 111 +- Source/3rd Party/wx/src/common/arttango.cpp | 327 - Source/3rd Party/wx/src/common/base64.cpp | 240 - Source/3rd Party/wx/src/common/bmpbase.cpp | 62 +- Source/3rd Party/wx/src/common/bmpbtncmn.cpp | 158 - Source/3rd Party/wx/src/common/bmpcboxcmn.cpp | 243 - Source/3rd Party/wx/src/common/bookctrl.cpp | 166 +- Source/3rd Party/wx/src/common/btncmn.cpp | 121 - Source/3rd Party/wx/src/common/cairo.cpp | 440 - Source/3rd Party/wx/src/common/calctrlcmn.cpp | 199 - .../3rd Party/wx/src/common/checkboxcmn.cpp | 90 - .../3rd Party/wx/src/common/checklstcmn.cpp | 119 - Source/3rd Party/wx/src/common/choiccmn.cpp | 83 +- Source/3rd Party/wx/src/common/clipcmn.cpp | 50 +- Source/3rd Party/wx/src/common/clntdata.cpp | 3 +- .../3rd Party/wx/src/common/clrpickercmn.cpp | 28 +- Source/3rd Party/wx/src/common/cmdline.cpp | 744 +- Source/3rd Party/wx/src/common/cmdproc.cpp | 58 +- Source/3rd Party/wx/src/common/cmndata.cpp | 299 +- Source/3rd Party/wx/src/common/colourcmn.cpp | 308 +- Source/3rd Party/wx/src/common/colourdata.cpp | 167 - Source/3rd Party/wx/src/common/combocmn.cpp | 1297 +-- Source/3rd Party/wx/src/common/config.cpp | 209 +- Source/3rd Party/wx/src/common/containr.cpp | 368 +- Source/3rd Party/wx/src/common/convauto.cpp | 292 +- Source/3rd Party/wx/src/common/cshelp.cpp | 13 +- Source/3rd Party/wx/src/common/ctrlcmn.cpp | 447 +- Source/3rd Party/wx/src/common/ctrlsub.cpp | 176 +- Source/3rd Party/wx/src/common/datacmn.cpp | 83 + Source/3rd Party/wx/src/common/datavcmn.cpp | 2559 ----- Source/3rd Party/wx/src/common/datetime.cpp | 3030 +++++- .../3rd Party/wx/src/common/datetimefmt.cpp | 2417 ----- Source/3rd Party/wx/src/common/datstrm.cpp | 216 +- Source/3rd Party/wx/src/common/dcbase.cpp | 1411 +-- Source/3rd Party/wx/src/common/dcbufcmn.cpp | 73 +- Source/3rd Party/wx/src/common/dcgraph.cpp | 905 +- Source/3rd Party/wx/src/common/dcsvg.cpp | 741 -- Source/3rd Party/wx/src/common/debugrpt.cpp | 751 -- Source/3rd Party/wx/src/common/dircmn.cpp | 89 +- Source/3rd Party/wx/src/common/dirctrlcmn.cpp | 88 - Source/3rd Party/wx/src/common/dlgcmn.cpp | 911 +- Source/3rd Party/wx/src/common/dndcmn.cpp | 3 +- Source/3rd Party/wx/src/common/dobjcmn.cpp | 335 +- Source/3rd Party/wx/src/common/docmdi.cpp | 190 +- Source/3rd Party/wx/src/common/docview.cpp | 1960 ++-- Source/3rd Party/wx/src/common/dpycmn.cpp | 33 +- Source/3rd Party/wx/src/common/dseldlg.cpp | 3 +- Source/3rd Party/wx/src/common/dummy.cpp | 2 +- Source/3rd Party/wx/src/common/dynarray.cpp | 125 +- Source/3rd Party/wx/src/common/dynlib.cpp | 130 +- Source/3rd Party/wx/src/common/dynload.cpp | 98 +- Source/3rd Party/wx/src/common/effects.cpp | 30 +- Source/3rd Party/wx/src/common/emptydmy.cpp | 3 - Source/3rd Party/wx/src/common/encconv.cpp | 87 +- Source/3rd Party/wx/src/common/event.cpp | 1442 +-- Source/3rd Party/wx/src/common/evtloopcmn.cpp | 227 +- .../common/execcmn.cpp} | 146 +- Source/3rd Party/wx/src/common/extended.c | 17 +- Source/3rd Party/wx/src/common/fddlgcmn.cpp | 23 +- .../wx/src/common/fdiodispatcher.cpp | 145 - Source/3rd Party/wx/src/common/ffile.cpp | 64 +- Source/3rd Party/wx/src/common/file.cpp | 237 +- Source/3rd Party/wx/src/common/fileback.cpp | 15 +- Source/3rd Party/wx/src/common/fileconf.cpp | 740 +- .../3rd Party/wx/src/common/filectrlcmn.cpp | 102 - Source/3rd Party/wx/src/common/filefn.cpp | 780 +- .../wx/src/common/filehistorycmn.cpp | 278 - Source/3rd Party/wx/src/common/filename.cpp | 1142 +- .../3rd Party/wx/src/common/filepickercmn.cpp | 104 +- Source/3rd Party/wx/src/common/filesys.cpp | 195 +- Source/3rd Party/wx/src/common/filtall.cpp | 1 + Source/3rd Party/wx/src/common/filtfind.cpp | 3 +- Source/3rd Party/wx/src/common/fldlgcmn.cpp | 211 +- Source/3rd Party/wx/src/common/fmapbase.cpp | 283 +- Source/3rd Party/wx/src/common/fontcmn.cpp | 742 +- Source/3rd Party/wx/src/common/fontdata.cpp | 94 - .../3rd Party/wx/src/common/fontenumcmn.cpp | 15 +- Source/3rd Party/wx/src/common/fontmap.cpp | 129 +- Source/3rd Party/wx/src/common/fontmgrcmn.cpp | 337 - .../3rd Party/wx/src/common/fontpickercmn.cpp | 26 +- .../3rd Party/wx/src/common/fontutilcmn.cpp | 65 - Source/3rd Party/wx/src/common/framecmn.cpp | 349 +- Source/3rd Party/wx/src/common/fs_arc.cpp | 42 +- Source/3rd Party/wx/src/common/fs_filter.cpp | 5 +- Source/3rd Party/wx/src/common/fs_inet.cpp | 165 - Source/3rd Party/wx/src/common/fs_mem.cpp | 259 +- .../3rd Party/wx/src/common/fswatchercmn.cpp | 333 - Source/3rd Party/wx/src/common/ftp.cpp | 1027 -- Source/3rd Party/wx/src/common/gaugecmn.cpp | 68 +- Source/3rd Party/wx/src/common/gbsizer.cpp | 89 +- Source/3rd Party/wx/src/common/gdicmn.cpp | 206 +- Source/3rd Party/wx/src/common/geometry.cpp | 48 +- Source/3rd Party/wx/src/common/gifdecod.cpp | 476 +- Source/3rd Party/wx/src/common/glcmn.cpp | 378 - Source/3rd Party/wx/src/common/graphcmn.cpp | 337 +- Source/3rd Party/wx/src/common/gridcmn.cpp | 88 - Source/3rd Party/wx/src/common/hash.cpp | 725 +- Source/3rd Party/wx/src/common/hashmap.cpp | 35 +- .../3rd Party/wx/src/common/headercolcmn.cpp | 93 - .../3rd Party/wx/src/common/headerctrlcmn.cpp | 516 - Source/3rd Party/wx/src/common/helpbase.cpp | 1 + Source/3rd Party/wx/src/common/http.cpp | 551 - .../3rd Party/wx/src/common/hyperlnkcmn.cpp | 141 - Source/3rd Party/wx/src/common/iconbndl.cpp | 321 +- Source/3rd Party/wx/src/common/imagall.cpp | 1 + Source/3rd Party/wx/src/common/imagbmp.cpp | 527 +- Source/3rd Party/wx/src/common/image.cpp | 1569 +-- Source/3rd Party/wx/src/common/imagfill.cpp | 11 +- Source/3rd Party/wx/src/common/imaggif.cpp | 746 +- Source/3rd Party/wx/src/common/imagiff.cpp | 140 +- Source/3rd Party/wx/src/common/imagjpeg.cpp | 132 +- Source/3rd Party/wx/src/common/imagpcx.cpp | 9 +- Source/3rd Party/wx/src/common/imagpng.cpp | 405 +- Source/3rd Party/wx/src/common/imagpnm.cpp | 24 +- Source/3rd Party/wx/src/common/imagtga.cpp | 225 +- Source/3rd Party/wx/src/common/imagtiff.cpp | 583 +- Source/3rd Party/wx/src/common/imagxpm.cpp | 48 +- Source/3rd Party/wx/src/common/init.cpp | 142 +- Source/3rd Party/wx/src/common/intl.cpp | 4090 ++++++-- Source/3rd Party/wx/src/common/ipcbase.cpp | 87 +- .../3rd Party/wx/src/common/languageinfo.cpp | 798 -- Source/3rd Party/wx/src/common/layout.cpp | 5 +- Source/3rd Party/wx/src/common/lboxcmn.cpp | 238 +- Source/3rd Party/wx/src/common/list.cpp | 78 +- .../3rd Party/wx/src/common/listctrlcmn.cpp | 248 +- Source/3rd Party/wx/src/common/log.cpp | 1032 +- Source/3rd Party/wx/src/common/longlong.cpp | 31 +- .../3rd Party/wx/src/common/markupparser.cpp | 483 - Source/3rd Party/wx/src/common/matrix.cpp | 1 + .../3rd Party/wx/src/common/mediactrlcmn.cpp | 553 - Source/3rd Party/wx/src/common/memory.cpp | 123 +- Source/3rd Party/wx/src/common/menucmn.cpp | 759 +- Source/3rd Party/wx/src/common/mimecmn.cpp | 141 +- Source/3rd Party/wx/src/common/modalhook.cpp | 119 - Source/3rd Party/wx/src/common/module.cpp | 52 +- .../3rd Party/wx/src/common/mousemanager.cpp | 187 - Source/3rd Party/wx/src/common/msgout.cpp | 172 +- Source/3rd Party/wx/src/common/mstream.cpp | 40 +- Source/3rd Party/wx/src/common/nbkbase.cpp | 126 +- .../3rd Party/wx/src/common/numformatter.cpp | 305 - Source/3rd Party/wx/src/common/object.cpp | 117 +- Source/3rd Party/wx/src/common/odcombocmn.cpp | 54 - Source/3rd Party/wx/src/common/overlaycmn.cpp | 43 +- .../3rd Party/wx/src/common/ownerdrwcmn.cpp | 104 - Source/3rd Party/wx/src/common/paper.cpp | 23 +- Source/3rd Party/wx/src/common/persist.cpp | 174 - Source/3rd Party/wx/src/common/pickerbase.cpp | 40 +- Source/3rd Party/wx/src/common/platinfo.cpp | 119 +- Source/3rd Party/wx/src/common/popupcmn.cpp | 142 +- Source/3rd Party/wx/src/common/powercmn.cpp | 15 +- .../wx/src/common/preferencescmn.cpp | 72 - Source/3rd Party/wx/src/common/prntbase.cpp | 1102 +- Source/3rd Party/wx/src/common/process.cpp | 23 +- Source/3rd Party/wx/src/common/protocol.cpp | 218 - Source/3rd Party/wx/src/common/quantize.cpp | 51 +- .../3rd Party/wx/src/common/radiobtncmn.cpp | 95 - Source/3rd Party/wx/src/common/radiocmn.cpp | 124 +- .../3rd Party/wx/src/common/rearrangectrl.cpp | 339 - Source/3rd Party/wx/src/common/regex.cpp | 109 +- Source/3rd Party/wx/src/common/rendcmn.cpp | 10 +- Source/3rd Party/wx/src/common/rgncmn.cpp | 9 +- .../wx/src/common/richtooltipcmn.cpp | 87 - Source/3rd Party/wx/src/common/sckaddr.cpp | 1013 -- Source/3rd Party/wx/src/common/sckfile.cpp | 59 - Source/3rd Party/wx/src/common/sckipc.cpp | 931 -- Source/3rd Party/wx/src/common/sckstrm.cpp | 87 - .../3rd Party/wx/src/common/scrolbarcmn.cpp | 91 - .../wx/src/common/selectdispatcher.cpp | 264 - Source/3rd Party/wx/src/common/settcmn.cpp | 20 + Source/3rd Party/wx/src/common/sizer.cpp | 1872 ++-- Source/3rd Party/wx/src/common/slidercmn.cpp | 109 - Source/3rd Party/wx/src/common/socket.cpp | 2164 ---- .../wx/src/common/socketiohandler.cpp | 130 - Source/3rd Party/wx/src/common/spinbtncmn.cpp | 98 - .../3rd Party/wx/src/common/spinctrlcmn.cpp | 118 - Source/3rd Party/wx/src/common/srchcmn.cpp | 7 +- Source/3rd Party/wx/src/common/sstream.cpp | 76 +- Source/3rd Party/wx/src/common/statbar.cpp | 380 +- Source/3rd Party/wx/src/common/statbmpcmn.cpp | 86 - Source/3rd Party/wx/src/common/statboxcmn.cpp | 89 - .../3rd Party/wx/src/common/statlinecmn.cpp | 81 - .../3rd Party/wx/src/common/stattextcmn.cpp | 262 - Source/3rd Party/wx/src/common/stdpbase.cpp | 118 +- Source/3rd Party/wx/src/common/stdstream.cpp | 292 - Source/3rd Party/wx/src/common/stockitem.cpp | 221 +- Source/3rd Party/wx/src/common/stopwatch.cpp | 399 +- Source/3rd Party/wx/src/common/strconv.cpp | 2412 +++-- Source/3rd Party/wx/src/common/stream.cpp | 432 +- Source/3rd Party/wx/src/common/string.cpp | 3340 +++--- Source/3rd Party/wx/src/common/stringimpl.cpp | 798 -- Source/3rd Party/wx/src/common/stringops.cpp | 315 - Source/3rd Party/wx/src/common/strvararg.cpp | 737 -- Source/3rd Party/wx/src/common/sysopt.cpp | 12 +- Source/3rd Party/wx/src/common/tarstrm.cpp | 122 +- Source/3rd Party/wx/src/common/taskbarcmn.cpp | 63 - Source/3rd Party/wx/src/common/tbarbase.cpp | 387 +- Source/3rd Party/wx/src/common/textbuf.cpp | 28 +- Source/3rd Party/wx/src/common/textcmn.cpp | 1034 +- .../3rd Party/wx/src/common/textentrycmn.cpp | 416 - Source/3rd Party/wx/src/common/textfile.cpp | 207 +- .../wx/src/common/textmeasurecmn.cpp | 280 - Source/3rd Party/wx/src/common/threadinfo.cpp | 103 - Source/3rd Party/wx/src/common/time.cpp | 361 - Source/3rd Party/wx/src/common/timercmn.cpp | 110 +- Source/3rd Party/wx/src/common/timerimpl.cpp | 83 - Source/3rd Party/wx/src/common/tokenzr.cpp | 114 +- Source/3rd Party/wx/src/common/toplvcmn.cpp | 149 +- .../3rd Party/wx/src/common/translation.cpp | 2064 ---- Source/3rd Party/wx/src/common/treebase.cpp | 192 +- Source/3rd Party/wx/src/common/txtstrm.cpp | 85 +- .../3rd Party/wx/src/common/uiactioncmn.cpp | 148 - Source/3rd Party/wx/src/common/unichar.cpp | 183 - Source/3rd Party/wx/src/common/unictabl.inc | 27 +- Source/3rd Party/wx/src/common/uri.cpp | 994 +- Source/3rd Party/wx/src/common/url.cpp | 495 - Source/3rd Party/wx/src/common/ustring.cpp | 537 - Source/3rd Party/wx/src/common/utilscmn.cpp | 1119 +- Source/3rd Party/wx/src/common/valgen.cpp | 200 +- Source/3rd Party/wx/src/common/validate.cpp | 3 +- Source/3rd Party/wx/src/common/valnum.cpp | 299 - Source/3rd Party/wx/src/common/valtext.cpp | 415 +- Source/3rd Party/wx/src/common/variant.cpp | 1372 +-- Source/3rd Party/wx/src/common/webview.cpp | 111 - .../wx/src/common/webviewarchivehandler.cpp | 117 - .../wx/src/common/webviewfshandler.cpp | 37 - Source/3rd Party/wx/src/common/wfstream.cpp | 34 +- Source/3rd Party/wx/src/common/wincmn.cpp | 1750 +--- Source/3rd Party/wx/src/common/windowid.cpp | 300 - Source/3rd Party/wx/src/common/wrapsizer.cpp | 589 -- Source/3rd Party/wx/src/common/wxchar.cpp | 2293 ++++ Source/3rd Party/wx/src/common/wxcrt.cpp | 1296 --- Source/3rd Party/wx/src/common/wxprintf.cpp | 248 - Source/3rd Party/wx/src/common/xlocale.cpp | 370 - Source/3rd Party/wx/src/common/xpmdecod.cpp | 89 +- Source/3rd Party/wx/src/common/xti.cpp | 718 +- Source/3rd Party/wx/src/common/xtistrm.cpp | 745 +- Source/3rd Party/wx/src/common/xtixml.cpp | 552 - Source/3rd Party/wx/src/common/zipstrm.cpp | 81 +- Source/3rd Party/wx/src/common/zstream.cpp | 81 +- Source/3rd Party/wx/src/generic/aboutdlgg.cpp | 330 - Source/3rd Party/wx/src/generic/accel.cpp | 219 - Source/3rd Party/wx/src/generic/animateg.cpp | 696 -- .../3rd Party/wx/src/generic/bannerwindow.cpp | 343 - Source/3rd Party/wx/src/generic/bmpcboxg.cpp | 358 - Source/3rd Party/wx/src/generic/busyinfo.cpp | 18 +- Source/3rd Party/wx/src/generic/buttonbar.cpp | 29 +- Source/3rd Party/wx/src/generic/calctrlg.cpp | 1724 --- Source/3rd Party/wx/src/generic/caret.cpp | 298 - Source/3rd Party/wx/src/generic/choicbkg.cpp | 121 +- Source/3rd Party/wx/src/generic/choicdgg.cpp | 235 +- .../3rd Party/wx/src/generic/clrpickerg.cpp | 108 +- Source/3rd Party/wx/src/generic/collpaneg.cpp | 140 +- Source/3rd Party/wx/src/generic/colour.cpp | 56 - Source/3rd Party/wx/src/generic/colrdlgg.cpp | 578 - Source/3rd Party/wx/src/generic/combog.cpp | 139 +- .../wx/src/generic/commandlinkbuttong.cpp | 116 - Source/3rd Party/wx/src/generic/datavgen.cpp | 5330 ---------- Source/3rd Party/wx/src/generic/datectlg.cpp | 484 - Source/3rd Party/wx/src/generic/dbgrptg.cpp | 537 - Source/3rd Party/wx/src/generic/dcpsg.cpp | 1256 +-- Source/3rd Party/wx/src/generic/dirctrlg.cpp | 593 +- Source/3rd Party/wx/src/generic/dirdlgg.cpp | 371 - Source/3rd Party/wx/src/generic/dragimgg.cpp | 60 +- Source/3rd Party/wx/src/generic/editlbox.cpp | 402 - Source/3rd Party/wx/src/generic/fdrepdlg.cpp | 292 - Source/3rd Party/wx/src/generic/filectrlg.cpp | 1479 --- Source/3rd Party/wx/src/generic/filedlgg.cpp | 406 - .../3rd Party/wx/src/generic/filepickerg.cpp | 93 +- Source/3rd Party/wx/src/generic/fontdlgg.cpp | 626 -- .../3rd Party/wx/src/generic/fontpickerg.cpp | 28 +- .../3rd Party/wx/src/generic/fswatcherg.cpp | 21 - Source/3rd Party/wx/src/generic/graphicc.cpp | 1942 +--- Source/3rd Party/wx/src/generic/grid.cpp | 9333 ----------------- Source/3rd Party/wx/src/generic/gridctrl.cpp | 952 -- .../3rd Party/wx/src/generic/grideditors.cpp | 1714 --- Source/3rd Party/wx/src/generic/gridsel.cpp | 1238 --- .../3rd Party/wx/src/generic/headerctrlg.cpp | 720 -- Source/3rd Party/wx/src/generic/helpext.cpp | 487 - Source/3rd Party/wx/src/generic/htmllbox.cpp | 723 -- .../3rd Party/wx/src/generic/hyperlinkg.cpp | 296 - Source/3rd Party/wx/src/generic/icon.cpp | 46 - Source/3rd Party/wx/src/generic/imaglist.cpp | 273 - Source/3rd Party/wx/src/generic/infobar.cpp | 330 - Source/3rd Party/wx/src/generic/laywin.cpp | 346 - Source/3rd Party/wx/src/generic/listbkg.cpp | 205 +- Source/3rd Party/wx/src/generic/listctrl.cpp | 5503 ---------- Source/3rd Party/wx/src/generic/logg.cpp | 919 +- .../3rd Party/wx/src/generic/markuptext.cpp | 253 - Source/3rd Party/wx/src/generic/mask.cpp | 75 - Source/3rd Party/wx/src/generic/mdig.cpp | 642 -- Source/3rd Party/wx/src/generic/msgdlgg.cpp | 203 +- Source/3rd Party/wx/src/generic/notebook.cpp | 755 -- Source/3rd Party/wx/src/generic/notifmsgg.cpp | 244 - Source/3rd Party/wx/src/generic/numdlgg.cpp | 6 +- Source/3rd Party/wx/src/generic/odcombo.cpp | 1208 --- Source/3rd Party/wx/src/generic/paletteg.cpp | 157 - .../panelcmn.cpp => generic/panelg.cpp} | 104 +- .../3rd Party/wx/src/generic/preferencesg.cpp | 265 - Source/3rd Party/wx/src/generic/printps.cpp | 37 +- Source/3rd Party/wx/src/generic/prntdlgg.cpp | 50 +- Source/3rd Party/wx/src/generic/progdlgg.cpp | 623 +- Source/3rd Party/wx/src/generic/propdlg.cpp | 233 - Source/3rd Party/wx/src/generic/regiong.cpp | 1933 ---- Source/3rd Party/wx/src/generic/renderg.cpp | 313 +- .../3rd Party/wx/src/generic/richmsgdlgg.cpp | 89 - .../3rd Party/wx/src/generic/richtooltipg.cpp | 711 -- Source/3rd Party/wx/src/generic/sashwin.cpp | 707 -- Source/3rd Party/wx/src/generic/scrlwing.cpp | 1120 +- Source/3rd Party/wx/src/generic/selstore.cpp | 37 +- Source/3rd Party/wx/src/generic/spinctlg.cpp | 738 +- Source/3rd Party/wx/src/generic/splash.cpp | 212 - Source/3rd Party/wx/src/generic/splitter.cpp | 335 +- Source/3rd Party/wx/src/generic/srchctlg.cpp | 357 +- Source/3rd Party/wx/src/generic/statbmpg.cpp | 48 - Source/3rd Party/wx/src/generic/statline.cpp | 85 - Source/3rd Party/wx/src/generic/stattextg.cpp | 168 - Source/3rd Party/wx/src/generic/statusbr.cpp | 539 +- Source/3rd Party/wx/src/generic/tabg.cpp | 1288 --- Source/3rd Party/wx/src/generic/textdlgg.cpp | 69 +- .../3rd Party/wx/src/generic/textmeasure.cpp | 68 - Source/3rd Party/wx/src/generic/timectrlg.cpp | 679 -- Source/3rd Party/wx/src/generic/timer.cpp | 109 +- Source/3rd Party/wx/src/generic/tipdlg.cpp | 351 - Source/3rd Party/wx/src/generic/tipwin.cpp | 19 +- Source/3rd Party/wx/src/generic/toolbkg.cpp | 109 +- Source/3rd Party/wx/src/generic/treebkg.cpp | 52 +- Source/3rd Party/wx/src/generic/treectlg.cpp | 1224 +-- Source/3rd Party/wx/src/generic/treelist.cpp | 1680 --- Source/3rd Party/wx/src/generic/vlbox.cpp | 211 +- Source/3rd Party/wx/src/generic/vscroll.cpp | 1040 +- Source/3rd Party/wx/src/generic/wizard.cpp | 1009 -- Source/3rd Party/wx/src/msw/aboutdlg.cpp | 73 - Source/3rd Party/wx/src/msw/accel.cpp | 26 +- Source/3rd Party/wx/src/msw/anybutton.cpp | 1378 --- Source/3rd Party/wx/src/msw/app.cpp | 911 +- Source/3rd Party/wx/src/msw/artmsw.cpp | 301 - Source/3rd Party/wx/src/msw/basemsw.cpp | 65 +- Source/3rd Party/wx/src/msw/bitmap.cpp | 625 +- Source/3rd Party/wx/src/msw/bmpbuttn.cpp | 583 +- Source/3rd Party/wx/src/msw/bmpcbox.cpp | 462 - Source/3rd Party/wx/src/msw/brush.cpp | 64 +- Source/3rd Party/wx/src/msw/button.cpp | 645 +- Source/3rd Party/wx/src/msw/calctrl.cpp | 524 - Source/3rd Party/wx/src/msw/caret.cpp | 11 +- Source/3rd Party/wx/src/msw/checkbox.cpp | 258 +- Source/3rd Party/wx/src/msw/checklst.cpp | 420 +- Source/3rd Party/wx/src/msw/choice.cpp | 687 +- Source/3rd Party/wx/src/msw/clipbrd.cpp | 54 +- Source/3rd Party/wx/src/msw/colordlg.cpp | 172 +- Source/3rd Party/wx/src/msw/colour.cpp | 41 + Source/3rd Party/wx/src/msw/combo.cpp | 167 +- Source/3rd Party/wx/src/msw/combobox.cpp | 650 +- .../wx/src/msw/commandlinkbutton.cpp | 202 - Source/3rd Party/wx/src/msw/control.cpp | 204 +- Source/3rd Party/wx/src/msw/crashrpt.cpp | 42 +- Source/3rd Party/wx/src/msw/cursor.cpp | 130 +- Source/3rd Party/wx/src/msw/data.cpp | 3 +- Source/3rd Party/wx/src/msw/datecontrols.cpp | 90 - Source/3rd Party/wx/src/msw/datectrl.cpp | 227 - Source/3rd Party/wx/src/msw/datetimectrl.cpp | 159 - Source/3rd Party/wx/src/msw/dc.cpp | 1542 ++- Source/3rd Party/wx/src/msw/dcclient.cpp | 373 +- Source/3rd Party/wx/src/msw/dcmemory.cpp | 70 +- Source/3rd Party/wx/src/msw/dcprint.cpp | 94 +- Source/3rd Party/wx/src/msw/dcscreen.cpp | 9 +- Source/3rd Party/wx/src/msw/dde.cpp | 229 +- Source/3rd Party/wx/src/msw/debughlp.cpp | 272 +- Source/3rd Party/wx/src/msw/dialog.cpp | 360 +- Source/3rd Party/wx/src/msw/dialup.cpp | 73 +- Source/3rd Party/wx/src/msw/dib.cpp | 204 +- Source/3rd Party/wx/src/msw/dir.cpp | 192 +- Source/3rd Party/wx/src/msw/dirdlg.cpp | 314 +- Source/3rd Party/wx/src/msw/display.cpp | 941 +- Source/3rd Party/wx/src/msw/dlmsw.cpp | 146 +- Source/3rd Party/wx/src/msw/dragimag.cpp | 78 +- Source/3rd Party/wx/src/msw/enhmeta.cpp | 237 +- Source/3rd Party/wx/src/msw/evtloop.cpp | 328 +- .../3rd Party/wx/src/msw/evtloopconsole.cpp | 165 - Source/3rd Party/wx/src/msw/fdrepdlg.cpp | 243 +- Source/3rd Party/wx/src/msw/filedlg.cpp | 520 +- Source/3rd Party/wx/src/msw/font.cpp | 740 +- Source/3rd Party/wx/src/msw/fontdlg.cpp | 16 +- Source/3rd Party/wx/src/msw/fontenum.cpp | 32 +- Source/3rd Party/wx/src/msw/fontutil.cpp | 35 +- Source/3rd Party/wx/src/msw/frame.cpp | 376 +- Source/3rd Party/wx/src/msw/fswatcher.cpp | 484 - Source/3rd Party/wx/src/msw/gauge.cpp | 227 - Source/3rd Party/wx/src/msw/gdiimage.cpp | 227 +- Source/3rd Party/wx/src/msw/gdiobj.cpp | 3 +- Source/3rd Party/wx/src/msw/gdiplus.cpp | 922 -- Source/3rd Party/wx/src/msw/glcanvas.cpp | 899 -- Source/3rd Party/wx/src/msw/graphics.cpp | 1372 +-- Source/3rd Party/wx/src/msw/gsockmsw.cpp | 487 + Source/3rd Party/wx/src/msw/headerctrl.cpp | 720 -- Source/3rd Party/wx/src/msw/helpbest.cpp | 107 - Source/3rd Party/wx/src/msw/helpchm.cpp | 133 +- Source/3rd Party/wx/src/msw/helpwin.cpp | 16 +- Source/3rd Party/wx/src/msw/hyperlink.cpp | 184 - Source/3rd Party/wx/src/msw/icon.cpp | 24 +- Source/3rd Party/wx/src/msw/imaglist.cpp | 214 +- Source/3rd Party/wx/src/msw/iniconf.cpp | 94 +- Source/3rd Party/wx/src/msw/joystick.cpp | 660 -- Source/3rd Party/wx/src/msw/listbox.cpp | 593 +- Source/3rd Party/wx/src/msw/listctrl.cpp | 1312 ++- Source/3rd Party/wx/src/msw/main.cpp | 177 +- Source/3rd Party/wx/src/msw/mdi.cpp | 754 +- Source/3rd Party/wx/src/msw/mediactrl_am.cpp | 2274 ---- Source/3rd Party/wx/src/msw/mediactrl_qt.cpp | 1288 --- .../3rd Party/wx/src/msw/mediactrl_wmp10.cpp | 1524 --- Source/3rd Party/wx/src/msw/menu.cpp | 1012 +- Source/3rd Party/wx/src/msw/menuitem.cpp | 1291 +-- Source/3rd Party/wx/src/msw/metafile.cpp | 100 +- Source/3rd Party/wx/src/msw/microwin.c | 364 - Source/3rd Party/wx/src/msw/mimetype.cpp | 185 +- Source/3rd Party/wx/src/msw/minifram.cpp | 3 +- Source/3rd Party/wx/src/msw/msgdlg.cpp | 817 +- Source/3rd Party/wx/src/msw/mslu.cpp | 84 +- Source/3rd Party/wx/src/msw/nativdlg.cpp | 13 +- Source/3rd Party/wx/src/msw/nativewin.cpp | 88 - Source/3rd Party/wx/src/msw/nonownedwnd.cpp | 183 - Source/3rd Party/wx/src/msw/notebook.cpp | 405 +- Source/3rd Party/wx/src/msw/notifmsg.cpp | 484 - Source/3rd Party/wx/src/msw/ole/access.cpp | 5 +- Source/3rd Party/wx/src/msw/ole/activex.cpp | 316 +- Source/3rd Party/wx/src/msw/ole/automtn.cpp | 674 +- Source/3rd Party/wx/src/msw/ole/dataobj.cpp | 417 +- Source/3rd Party/wx/src/msw/ole/dropsrc.cpp | 5 +- Source/3rd Party/wx/src/msw/ole/droptgt.cpp | 204 +- Source/3rd Party/wx/src/msw/ole/oleutils.cpp | 543 +- Source/3rd Party/wx/src/msw/ole/safearray.cpp | 135 - Source/3rd Party/wx/src/msw/ole/uuid.cpp | 10 +- Source/3rd Party/wx/src/msw/ownerdrw.cpp | 522 +- Source/3rd Party/wx/src/msw/palette.cpp | 228 +- Source/3rd Party/wx/src/msw/panel.cpp | 46 - Source/3rd Party/wx/src/msw/pen.cpp | 749 +- Source/3rd Party/wx/src/msw/penwin.cpp | 113 - Source/3rd Party/wx/src/msw/popupwin.cpp | 21 +- Source/3rd Party/wx/src/msw/power.cpp | 5 +- Source/3rd Party/wx/src/msw/printdlg.cpp | 588 +- Source/3rd Party/wx/src/msw/printwin.cpp | 142 +- Source/3rd Party/wx/src/msw/progdlg.cpp | 956 -- Source/3rd Party/wx/src/msw/radiobox.cpp | 211 +- Source/3rd Party/wx/src/msw/radiobut.cpp | 116 +- Source/3rd Party/wx/src/msw/regconf.cpp | 77 +- Source/3rd Party/wx/src/msw/region.cpp | 36 +- Source/3rd Party/wx/src/msw/registry.cpp | 369 +- Source/3rd Party/wx/src/msw/renderer.cpp | 775 +- Source/3rd Party/wx/src/msw/richmsgdlg.cpp | 95 - Source/3rd Party/wx/src/msw/richtooltip.cpp | 201 - Source/3rd Party/wx/src/msw/scrolbar.cpp | 144 +- Source/3rd Party/wx/src/msw/settings.cpp | 73 +- .../wx/src/msw/{slider.cpp => slider95.cpp} | 356 +- Source/3rd Party/wx/src/msw/snglinst.cpp | 25 +- Source/3rd Party/wx/src/msw/sockmsw.cpp | 487 - Source/3rd Party/wx/src/msw/sound.cpp | 204 - Source/3rd Party/wx/src/msw/spinbutt.cpp | 75 +- Source/3rd Party/wx/src/msw/spinctrl.cpp | 405 +- Source/3rd Party/wx/src/msw/stackwalk.cpp | 80 +- Source/3rd Party/wx/src/msw/statbmp.cpp | 170 +- Source/3rd Party/wx/src/msw/statbox.cpp | 274 +- Source/3rd Party/wx/src/msw/statbr95.cpp | 417 + Source/3rd Party/wx/src/msw/statline.cpp | 59 +- Source/3rd Party/wx/src/msw/stattext.cpp | 209 +- Source/3rd Party/wx/src/msw/statusbar.cpp | 681 -- Source/3rd Party/wx/src/msw/stdpaths.cpp | 124 +- Source/3rd Party/wx/src/msw/taskbar.cpp | 436 - .../wx/src/msw/{toolbar.cpp => tbar95.cpp} | 1204 +-- Source/3rd Party/wx/src/msw/textctrl.cpp | 1266 +-- Source/3rd Party/wx/src/msw/textentry.cpp | 1023 -- Source/3rd Party/wx/src/msw/textmeasure.cpp | 189 - Source/3rd Party/wx/src/msw/tglbtn.cpp | 176 +- Source/3rd Party/wx/src/msw/thread.cpp | 286 +- Source/3rd Party/wx/src/msw/timectrl.cpp | 64 - Source/3rd Party/wx/src/msw/timer.cpp | 85 +- Source/3rd Party/wx/src/msw/tooltip.cpp | 360 +- Source/3rd Party/wx/src/msw/toplevel.cpp | 844 +- Source/3rd Party/wx/src/msw/treectrl.cpp | 2128 ++-- Source/3rd Party/wx/src/msw/uiaction.cpp | 101 - Source/3rd Party/wx/src/msw/urlmsw.cpp | 248 - Source/3rd Party/wx/src/msw/utils.cpp | 777 +- Source/3rd Party/wx/src/msw/utilsexc.cpp | 434 +- Source/3rd Party/wx/src/msw/utilsgui.cpp | 215 +- Source/3rd Party/wx/src/msw/utilswin.cpp | 138 - Source/3rd Party/wx/src/msw/uxtheme.cpp | 7 +- Source/3rd Party/wx/src/msw/volume.cpp | 59 +- Source/3rd Party/wx/src/msw/webview_ie.cpp | 1689 --- Source/3rd Party/wx/src/msw/window.cpp | 2998 +++--- Source/3rd Party/wx/src/msw/winestub.c | 44 - Source/3rd Party/wx/src/png/CHANGES | 3839 +------ Source/3rd Party/wx/src/png/README | 144 +- Source/3rd Party/wx/src/png/TODO | 13 +- Source/3rd Party/wx/src/png/ansi2knr.c | 695 ++ Source/3rd Party/wx/src/png/png.c | 4680 ++------- Source/3rd Party/wx/src/png/png.h | 4516 ++++---- Source/3rd Party/wx/src/png/pngasmrd.h | 11 + Source/3rd Party/wx/src/png/pngconf.h | 1852 +++- Source/3rd Party/wx/src/png/pngdebug.h | 157 - Source/3rd Party/wx/src/png/pngerror.c | 913 +- Source/3rd Party/wx/src/png/pnggccrd.c | 5408 ++++++++++ Source/3rd Party/wx/src/png/pngget.c | 1239 +-- Source/3rd Party/wx/src/png/pnginfo.h | 260 - Source/3rd Party/wx/src/png/pnglibconf.h | 453 - Source/3rd Party/wx/src/png/pngmem.c | 722 +- Source/3rd Party/wx/src/png/pngpread.c | 1370 ++- Source/3rd Party/wx/src/png/pngprefix.h | 188 - Source/3rd Party/wx/src/png/pngpriv.h | 1912 ---- Source/3rd Party/wx/src/png/pngread.c | 4407 ++------ Source/3rd Party/wx/src/png/pngrio.c | 155 +- Source/3rd Party/wx/src/png/pngrtran.c | 4598 ++++---- Source/3rd Party/wx/src/png/pngrutil.c | 4924 ++++----- Source/3rd Party/wx/src/png/pngset.c | 2051 ++-- Source/3rd Party/wx/src/png/pngstruct.h | 489 - Source/3rd Party/wx/src/png/pngtest.c | 1631 ++- Source/3rd Party/wx/src/png/pngtrans.c | 701 +- Source/3rd Party/wx/src/png/pngvcrd.c | 3903 +++++++ Source/3rd Party/wx/src/png/pngwio.c | 242 +- Source/3rd Party/wx/src/png/pngwrite.c | 2557 ++--- Source/3rd Party/wx/src/png/pngwtran.c | 300 +- Source/3rd Party/wx/src/png/pngwutil.c | 2869 +++-- Source/3rd Party/wx/src/tiff/libtiff/tiff.h | 192 +- .../3rd Party/wx/src/tiff/libtiff/tiffconf.h | 66 +- Source/3rd Party/wx/src/tiff/libtiff/tiffio.h | 663 +- .../3rd Party/wx/src/tiff/libtiff/tiffvers.h | 4 +- Source/3rd Party/wx/src/xrc/descrip.mms | 164 - Source/3rd Party/wx/src/xrc/xh_animatctrl.cpp | 59 - Source/3rd Party/wx/src/xrc/xh_auinotbk.cpp | 118 - .../3rd Party/wx/src/xrc/xh_bannerwindow.cpp | 87 - Source/3rd Party/wx/src/xrc/xh_bmp.cpp | 59 - Source/3rd Party/wx/src/xrc/xh_bmpbt.cpp | 71 - Source/3rd Party/wx/src/xrc/xh_bmpcbox.cpp | 109 - Source/3rd Party/wx/src/xrc/xh_bttn.cpp | 69 - Source/3rd Party/wx/src/xrc/xh_cald.cpp | 66 - Source/3rd Party/wx/src/xrc/xh_chckb.cpp | 60 - Source/3rd Party/wx/src/xrc/xh_chckl.cpp | 111 - Source/3rd Party/wx/src/xrc/xh_choic.cpp | 88 - Source/3rd Party/wx/src/xrc/xh_choicbk.cpp | 143 - Source/3rd Party/wx/src/xrc/xh_clrpicker.cpp | 54 - Source/3rd Party/wx/src/xrc/xh_cmdlinkbn.cpp | 59 - Source/3rd Party/wx/src/xrc/xh_collpane.cpp | 100 - Source/3rd Party/wx/src/xrc/xh_combo.cpp | 95 - Source/3rd Party/wx/src/xrc/xh_comboctrl.cpp | 68 - Source/3rd Party/wx/src/xrc/xh_datectrl.cpp | 56 - Source/3rd Party/wx/src/xrc/xh_dirpicker.cpp | 57 - Source/3rd Party/wx/src/xrc/xh_dlg.cpp | 92 - Source/3rd Party/wx/src/xrc/xh_editlbox.cpp | 123 - Source/3rd Party/wx/src/xrc/xh_filectrl.cpp | 58 - Source/3rd Party/wx/src/xrc/xh_filepicker.cpp | 60 - Source/3rd Party/wx/src/xrc/xh_fontpicker.cpp | 59 - Source/3rd Party/wx/src/xrc/xh_frame.cpp | 98 - Source/3rd Party/wx/src/xrc/xh_gauge.cpp | 76 - Source/3rd Party/wx/src/xrc/xh_gdctl.cpp | 64 - Source/3rd Party/wx/src/xrc/xh_grid.cpp | 50 - Source/3rd Party/wx/src/xrc/xh_html.cpp | 80 - Source/3rd Party/wx/src/xrc/xh_htmllbox.cpp | 87 - Source/3rd Party/wx/src/xrc/xh_hyperlink.cpp | 87 - Source/3rd Party/wx/src/xrc/xh_listb.cpp | 95 - Source/3rd Party/wx/src/xrc/xh_listbk.cpp | 143 - Source/3rd Party/wx/src/xrc/xh_listc.cpp | 265 - Source/3rd Party/wx/src/xrc/xh_mdi.cpp | 138 - Source/3rd Party/wx/src/xrc/xh_menu.cpp | 180 - Source/3rd Party/wx/src/xrc/xh_notbk.cpp | 150 - Source/3rd Party/wx/src/xrc/xh_odcombo.cpp | 118 - Source/3rd Party/wx/src/xrc/xh_panel.cpp | 60 - Source/3rd Party/wx/src/xrc/xh_propdlg.cpp | 152 - Source/3rd Party/wx/src/xrc/xh_radbt.cpp | 65 - Source/3rd Party/wx/src/xrc/xh_radbx.cpp | 149 - Source/3rd Party/wx/src/xrc/xh_ribbon.cpp | 335 - Source/3rd Party/wx/src/xrc/xh_richtext.cpp | 61 - Source/3rd Party/wx/src/xrc/xh_scrol.cpp | 62 - Source/3rd Party/wx/src/xrc/xh_scwin.cpp | 71 - Source/3rd Party/wx/src/xrc/xh_simplebook.cpp | 101 - Source/3rd Party/wx/src/xrc/xh_sizer.cpp | 637 -- Source/3rd Party/wx/src/xrc/xh_slidr.cpp | 98 - Source/3rd Party/wx/src/xrc/xh_spin.cpp | 114 - Source/3rd Party/wx/src/xrc/xh_split.cpp | 114 - Source/3rd Party/wx/src/xrc/xh_srchctrl.cpp | 60 - Source/3rd Party/wx/src/xrc/xh_statbar.cpp | 128 - Source/3rd Party/wx/src/xrc/xh_stbmp.cpp | 54 - Source/3rd Party/wx/src/xrc/xh_stbox.cpp | 54 - Source/3rd Party/wx/src/xrc/xh_stlin.cpp | 52 - Source/3rd Party/wx/src/xrc/xh_sttxt.cpp | 63 - Source/3rd Party/wx/src/xrc/xh_text.cpp | 86 - Source/3rd Party/wx/src/xrc/xh_tglbtn.cpp | 100 - Source/3rd Party/wx/src/xrc/xh_timectrl.cpp | 52 - Source/3rd Party/wx/src/xrc/xh_toolb.cpp | 264 - Source/3rd Party/wx/src/xrc/xh_toolbk.cpp | 143 - Source/3rd Party/wx/src/xrc/xh_tree.cpp | 71 - Source/3rd Party/wx/src/xrc/xh_treebk.cpp | 181 - Source/3rd Party/wx/src/xrc/xh_unkwn.cpp | 118 - Source/3rd Party/wx/src/xrc/xh_wizrd.cpp | 103 - Source/3rd Party/wx/src/xrc/xmladv.cpp | 81 - Source/3rd Party/wx/src/xrc/xmlres.cpp | 2904 ----- Source/3rd Party/wx/src/xrc/xmlreshandler.cpp | 69 - Source/3rd Party/wx/src/xrc/xmlrsall.cpp | 210 - Source/3rd Party/wx/src/zlib/ChangeLog | 2 +- Source/3rd Party/wx/wx_base.vcproj | 12 +- Source/3rd Party/wx/wx_base.vcxproj | 80 +- Source/3rd Party/wx/wx_base.vcxproj.filters | 126 +- Source/3rd Party/wx/wx_core.vcproj | 40 +- Source/3rd Party/wx/wx_core.vcxproj | 603 +- Source/3rd Party/wx/wx_core.vcxproj.filters | 1688 +-- 1290 files changed, 98382 insertions(+), 304844 deletions(-) delete mode 100644 Source/3rd Party/wx/art/wxwin16x16.xpm delete mode 100644 Source/3rd Party/wx/art/wxwin32x32.xpm delete mode 100644 Source/3rd Party/wx/include/wx/aboutdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/access.h delete mode 100644 Source/3rd Party/wx/include/wx/affinematrix2d.h delete mode 100644 Source/3rd Party/wx/include/wx/affinematrix2dbase.h delete mode 100644 Source/3rd Party/wx/include/wx/animate.h delete mode 100644 Source/3rd Party/wx/include/wx/any.h delete mode 100644 Source/3rd Party/wx/include/wx/anybutton.h delete mode 100644 Source/3rd Party/wx/include/wx/anystr.h delete mode 100644 Source/3rd Party/wx/include/wx/atomic.h delete mode 100644 Source/3rd Party/wx/include/wx/bannerwindow.h delete mode 100644 Source/3rd Party/wx/include/wx/base64.h delete mode 100644 Source/3rd Party/wx/include/wx/bmpcbox.h delete mode 100644 Source/3rd Party/wx/include/wx/calctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/chartype.h delete mode 100644 Source/3rd Party/wx/include/wx/checkeddelete.h delete mode 100644 Source/3rd Party/wx/include/wx/cmdargs.h delete mode 100644 Source/3rd Party/wx/include/wx/colourdata.h delete mode 100644 Source/3rd Party/wx/include/wx/commandlinkbutton.h delete mode 100644 Source/3rd Party/wx/include/wx/compiler.h delete mode 100644 Source/3rd Party/wx/include/wx/compositewin.h delete mode 100644 Source/3rd Party/wx/include/wx/cppunit.h delete mode 100644 Source/3rd Party/wx/include/wx/crt.h delete mode 100644 Source/3rd Party/wx/include/wx/custombgwin.h delete mode 100644 Source/3rd Party/wx/include/wx/dataview.h delete mode 100644 Source/3rd Party/wx/include/wx/datectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/dateevt.h delete mode 100644 Source/3rd Party/wx/include/wx/datetimectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/dcps.h delete mode 100644 Source/3rd Party/wx/include/wx/dcsvg.h delete mode 100644 Source/3rd Party/wx/include/wx/debugrpt.h delete mode 100644 Source/3rd Party/wx/include/wx/dirctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/dlist.h delete mode 100644 Source/3rd Party/wx/include/wx/dragimag.h delete mode 100644 Source/3rd Party/wx/include/wx/dvrenderers.h delete mode 100644 Source/3rd Party/wx/include/wx/editlbox.h delete mode 100644 Source/3rd Party/wx/include/wx/eventfilter.h delete mode 100644 Source/3rd Party/wx/include/wx/evtloopsrc.h delete mode 100644 Source/3rd Party/wx/include/wx/filectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/filehistory.h delete mode 100644 Source/3rd Party/wx/include/wx/fontdata.h delete mode 100644 Source/3rd Party/wx/include/wx/fs_inet.h delete mode 100644 Source/3rd Party/wx/include/wx/fs_zip.h delete mode 100644 Source/3rd Party/wx/include/wx/fswatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/aboutdlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/accel.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/animate.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/bmpcbox.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/buttonbar.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/calctrlg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/caret.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/colour.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/colrdlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/ctrlsub.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/custombgwin.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/dataview.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/datectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/dcpsg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/dirdlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/dvrenderer.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/dvrenderers.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/fdrepdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/filectrlg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/filedlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/fontdlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/fswatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/grid.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/gridctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/grideditors.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/gridsel.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/headerctrlg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/helpext.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/hyperlink.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/icon.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/imaglist.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/infobar.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/laywin.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/listctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/mask.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/mdig.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/notifmsg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/paletteg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/printps.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/private/grid.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/private/listctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/private/markuptext.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/private/richtooltip.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/private/textmeasure.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/propdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/region.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/richmsgdlgg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/sashwin.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/splash.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/statbmpg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/stattextg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/tabg.h delete mode 100644 Source/3rd Party/wx/include/wx/generic/timectrl.h rename Source/3rd Party/wx/include/wx/generic/{private => }/timer.h (66%) delete mode 100644 Source/3rd Party/wx/include/wx/generic/wizard.h delete mode 100644 Source/3rd Party/wx/include/wx/glcanvas.h delete mode 100644 Source/3rd Party/wx/include/wx/grid.h create mode 100644 Source/3rd Party/wx/include/wx/gsocket.h delete mode 100644 Source/3rd Party/wx/include/wx/headercol.h delete mode 100644 Source/3rd Party/wx/include/wx/headerctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/helphtml.h delete mode 100644 Source/3rd Party/wx/include/wx/helpwin.h delete mode 100644 Source/3rd Party/wx/include/wx/htmllbox.h delete mode 100644 Source/3rd Party/wx/include/wx/hyperlink.h delete mode 100644 Source/3rd Party/wx/include/wx/infobar.h delete mode 100644 Source/3rd Party/wx/include/wx/ipc.h delete mode 100644 Source/3rd Party/wx/include/wx/itemid.h delete mode 100644 Source/3rd Party/wx/include/wx/joystick.h delete mode 100644 Source/3rd Party/wx/include/wx/kbdstate.h delete mode 100644 Source/3rd Party/wx/include/wx/language.h delete mode 100644 Source/3rd Party/wx/include/wx/laywin.h delete mode 100644 Source/3rd Party/wx/include/wx/link.h delete mode 100644 Source/3rd Party/wx/include/wx/mediactrl.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/convertible.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/if.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/implicitconversion.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/int2type.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/movable.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/pod.h delete mode 100644 Source/3rd Party/wx/include/wx/meta/removeref.h delete mode 100644 Source/3rd Party/wx/include/wx/modalhook.h delete mode 100644 Source/3rd Party/wx/include/wx/mousemanager.h delete mode 100644 Source/3rd Party/wx/include/wx/mousestate.h delete mode 100644 Source/3rd Party/wx/include/wx/msgqueue.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/anybutton.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/bmpcbox.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/calctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/commandlinkbutton.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/ctrlsub.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/custombgwin.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/datectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/datetimectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/evtloopconsole.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/fswatcher.h rename Source/3rd Party/wx/include/wx/msw/{gauge.h => gauge95.h} (53%) delete mode 100644 Source/3rd Party/wx/include/wx/msw/glcanvas.h create mode 100644 Source/3rd Party/wx/include/wx/msw/gsockmsw.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/headerctrl.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/helpbest.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/hyperlink.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/init.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/joystick.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/metafile.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/microwin.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/nonownedwnd.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/notifmsg.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/ole/access.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/ole/safearray.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/ownerdrw.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/panel.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/button.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/comptr.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/datecontrols.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/dc.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/fswatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/hiddenwin.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/keyboard.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/metrics.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/msgdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/pipestream.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/sockmsw.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/textmeasure.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/private/timer.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/progdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/rcdefs.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/richmsgdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/setup_inc.h rename Source/3rd Party/wx/include/wx/msw/{slider.h => slider95.h} (79%) delete mode 100644 Source/3rd Party/wx/include/wx/msw/sound.h create mode 100644 Source/3rd Party/wx/include/wx/msw/statbr95.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/statusbar.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/taskbar.h rename Source/3rd Party/wx/include/wx/msw/{toolbar.h => tbar95.h} (70%) delete mode 100644 Source/3rd Party/wx/include/wx/msw/textentry.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/timectrl.h create mode 100644 Source/3rd Party/wx/include/wx/msw/timer.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/tls.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/webview_ie.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/webview_missing.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/webviewhistoryitem_ie.h delete mode 100644 Source/3rd Party/wx/include/wx/msw/wrapgdip.h delete mode 100644 Source/3rd Party/wx/include/wx/nativewin.h delete mode 100644 Source/3rd Party/wx/include/wx/nonownedwnd.h delete mode 100644 Source/3rd Party/wx/include/wx/notifmsg.h delete mode 100644 Source/3rd Party/wx/include/wx/numformatter.h delete mode 100644 Source/3rd Party/wx/include/wx/odcombo.h delete mode 100644 Source/3rd Party/wx/include/wx/persist.h delete mode 100644 Source/3rd Party/wx/include/wx/position.h delete mode 100644 Source/3rd Party/wx/include/wx/preferences.h create mode 100644 Source/3rd Party/wx/include/wx/private/browserhack28.h delete mode 100644 Source/3rd Party/wx/include/wx/private/eventloopsourcesmanager.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fd.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fdiodispatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fdioeventloopsourcehandler.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fdiohandler.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fdiomanager.h delete mode 100644 Source/3rd Party/wx/include/wx/private/flagscheck.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fontmgr.h delete mode 100644 Source/3rd Party/wx/include/wx/private/fswatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/private/graphics.h delete mode 100644 Source/3rd Party/wx/include/wx/private/markupparser.h delete mode 100644 Source/3rd Party/wx/include/wx/private/markupparserattr.h delete mode 100644 Source/3rd Party/wx/include/wx/private/pipestream.h delete mode 100644 Source/3rd Party/wx/include/wx/private/preferences.h delete mode 100644 Source/3rd Party/wx/include/wx/private/richtooltip.h delete mode 100644 Source/3rd Party/wx/include/wx/private/sckaddr.h delete mode 100644 Source/3rd Party/wx/include/wx/private/selectdispatcher.h delete mode 100644 Source/3rd Party/wx/include/wx/private/socket.h delete mode 100644 Source/3rd Party/wx/include/wx/private/textmeasure.h delete mode 100644 Source/3rd Party/wx/include/wx/private/threadinfo.h delete mode 100644 Source/3rd Party/wx/include/wx/private/timer.h delete mode 100644 Source/3rd Party/wx/include/wx/private/window.h delete mode 100644 Source/3rd Party/wx/include/wx/private/wxprintf.h delete mode 100644 Source/3rd Party/wx/include/wx/propdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/ptr_shrd.h delete mode 100644 Source/3rd Party/wx/include/wx/range.h delete mode 100644 Source/3rd Party/wx/include/wx/rearrangectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/richmsgdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/richtooltip.h delete mode 100644 Source/3rd Party/wx/include/wx/rtti.h delete mode 100644 Source/3rd Party/wx/include/wx/sashwin.h delete mode 100644 Source/3rd Party/wx/include/wx/sckaddr.h delete mode 100644 Source/3rd Party/wx/include/wx/sckipc.h delete mode 100644 Source/3rd Party/wx/include/wx/sckstrm.h delete mode 100644 Source/3rd Party/wx/include/wx/scopedarray.h delete mode 100644 Source/3rd Party/wx/include/wx/scopedptr.h delete mode 100644 Source/3rd Party/wx/include/wx/setup_inc.h delete mode 100644 Source/3rd Party/wx/include/wx/setup_redirect.h delete mode 100644 Source/3rd Party/wx/include/wx/sharedptr.h delete mode 100644 Source/3rd Party/wx/include/wx/simplebook.h delete mode 100644 Source/3rd Party/wx/include/wx/socket.h delete mode 100644 Source/3rd Party/wx/include/wx/sound.h delete mode 100644 Source/3rd Party/wx/include/wx/splash.h delete mode 100644 Source/3rd Party/wx/include/wx/stdstream.h delete mode 100644 Source/3rd Party/wx/include/wx/stringimpl.h delete mode 100644 Source/3rd Party/wx/include/wx/stringops.h delete mode 100644 Source/3rd Party/wx/include/wx/strvararg.h delete mode 100644 Source/3rd Party/wx/include/wx/taskbar.h delete mode 100644 Source/3rd Party/wx/include/wx/testing.h delete mode 100644 Source/3rd Party/wx/include/wx/textcompleter.h delete mode 100644 Source/3rd Party/wx/include/wx/textentry.h delete mode 100644 Source/3rd Party/wx/include/wx/textwrapper.h delete mode 100644 Source/3rd Party/wx/include/wx/time.h delete mode 100644 Source/3rd Party/wx/include/wx/timectrl.h delete mode 100644 Source/3rd Party/wx/include/wx/tipdlg.h delete mode 100644 Source/3rd Party/wx/include/wx/tls.h delete mode 100644 Source/3rd Party/wx/include/wx/tracker.h delete mode 100644 Source/3rd Party/wx/include/wx/translation.h delete mode 100644 Source/3rd Party/wx/include/wx/treelist.h delete mode 100644 Source/3rd Party/wx/include/wx/typeinfo.h delete mode 100644 Source/3rd Party/wx/include/wx/types.h delete mode 100644 Source/3rd Party/wx/include/wx/uiaction.h delete mode 100644 Source/3rd Party/wx/include/wx/unichar.h delete mode 100644 Source/3rd Party/wx/include/wx/url.h delete mode 100644 Source/3rd Party/wx/include/wx/ustring.h delete mode 100644 Source/3rd Party/wx/include/wx/valnum.h delete mode 100644 Source/3rd Party/wx/include/wx/variantbase.h delete mode 100644 Source/3rd Party/wx/include/wx/versioninfo.h delete mode 100644 Source/3rd Party/wx/include/wx/vms_x_fix.h delete mode 100644 Source/3rd Party/wx/include/wx/weakref.h delete mode 100644 Source/3rd Party/wx/include/wx/webview.h delete mode 100644 Source/3rd Party/wx/include/wx/webviewarchivehandler.h delete mode 100644 Source/3rd Party/wx/include/wx/webviewfshandler.h delete mode 100644 Source/3rd Party/wx/include/wx/windowid.h delete mode 100644 Source/3rd Party/wx/include/wx/windowptr.h delete mode 100644 Source/3rd Party/wx/include/wx/withimages.h delete mode 100644 Source/3rd Party/wx/include/wx/wizard.h delete mode 100644 Source/3rd Party/wx/include/wx/wrapsizer.h delete mode 100644 Source/3rd Party/wx/include/wx/wxcrt.h delete mode 100644 Source/3rd Party/wx/include/wx/wxcrtbase.h delete mode 100644 Source/3rd Party/wx/include/wx/wxcrtvararg.h delete mode 100644 Source/3rd Party/wx/include/wx/wxhtml.h delete mode 100644 Source/3rd Party/wx/include/wx/xlocale.h delete mode 100644 Source/3rd Party/wx/include/wx/xpmhand.h delete mode 100644 Source/3rd Party/wx/include/wx/xti2.h delete mode 100644 Source/3rd Party/wx/include/wx/xtictor.h delete mode 100644 Source/3rd Party/wx/include/wx/xtihandler.h delete mode 100644 Source/3rd Party/wx/include/wx/xtiprop.h delete mode 100644 Source/3rd Party/wx/include/wx/xtistrm.h delete mode 100644 Source/3rd Party/wx/include/wx/xtitypes.h delete mode 100644 Source/3rd Party/wx/include/wx/xtixml.h delete mode 100644 Source/3rd Party/wx/src/common/accelcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/affinematrix2d.cpp delete mode 100644 Source/3rd Party/wx/src/common/animatecmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/any.cpp delete mode 100644 Source/3rd Party/wx/src/common/arrstr.cpp delete mode 100644 Source/3rd Party/wx/src/common/arttango.cpp delete mode 100644 Source/3rd Party/wx/src/common/base64.cpp delete mode 100644 Source/3rd Party/wx/src/common/bmpbtncmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/bmpcboxcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/btncmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/cairo.cpp delete mode 100644 Source/3rd Party/wx/src/common/calctrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/checkboxcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/checklstcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/colourdata.cpp create mode 100644 Source/3rd Party/wx/src/common/datacmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/datavcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/datetimefmt.cpp delete mode 100644 Source/3rd Party/wx/src/common/dcsvg.cpp delete mode 100644 Source/3rd Party/wx/src/common/debugrpt.cpp delete mode 100644 Source/3rd Party/wx/src/common/dirctrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/emptydmy.cpp rename Source/3rd Party/wx/{include/wx/private/streamtempinput.h => src/common/execcmn.cpp} (59%) delete mode 100644 Source/3rd Party/wx/src/common/fdiodispatcher.cpp delete mode 100644 Source/3rd Party/wx/src/common/filectrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/filehistorycmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/fontdata.cpp delete mode 100644 Source/3rd Party/wx/src/common/fontmgrcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/fontutilcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/fs_inet.cpp delete mode 100644 Source/3rd Party/wx/src/common/fswatchercmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/ftp.cpp delete mode 100644 Source/3rd Party/wx/src/common/glcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/gridcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/headercolcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/headerctrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/http.cpp delete mode 100644 Source/3rd Party/wx/src/common/hyperlnkcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/languageinfo.cpp delete mode 100644 Source/3rd Party/wx/src/common/markupparser.cpp delete mode 100644 Source/3rd Party/wx/src/common/mediactrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/modalhook.cpp delete mode 100644 Source/3rd Party/wx/src/common/mousemanager.cpp delete mode 100644 Source/3rd Party/wx/src/common/numformatter.cpp delete mode 100644 Source/3rd Party/wx/src/common/odcombocmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/ownerdrwcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/persist.cpp delete mode 100644 Source/3rd Party/wx/src/common/preferencescmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/protocol.cpp delete mode 100644 Source/3rd Party/wx/src/common/radiobtncmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/rearrangectrl.cpp delete mode 100644 Source/3rd Party/wx/src/common/richtooltipcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/sckaddr.cpp delete mode 100644 Source/3rd Party/wx/src/common/sckfile.cpp delete mode 100644 Source/3rd Party/wx/src/common/sckipc.cpp delete mode 100644 Source/3rd Party/wx/src/common/sckstrm.cpp delete mode 100644 Source/3rd Party/wx/src/common/scrolbarcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/selectdispatcher.cpp delete mode 100644 Source/3rd Party/wx/src/common/slidercmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/socket.cpp delete mode 100644 Source/3rd Party/wx/src/common/socketiohandler.cpp delete mode 100644 Source/3rd Party/wx/src/common/spinbtncmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/spinctrlcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/statbmpcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/statboxcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/statlinecmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/stattextcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/stdstream.cpp delete mode 100644 Source/3rd Party/wx/src/common/stringimpl.cpp delete mode 100644 Source/3rd Party/wx/src/common/stringops.cpp delete mode 100644 Source/3rd Party/wx/src/common/strvararg.cpp delete mode 100644 Source/3rd Party/wx/src/common/taskbarcmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/textentrycmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/textmeasurecmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/threadinfo.cpp delete mode 100644 Source/3rd Party/wx/src/common/time.cpp delete mode 100644 Source/3rd Party/wx/src/common/timerimpl.cpp delete mode 100644 Source/3rd Party/wx/src/common/translation.cpp delete mode 100644 Source/3rd Party/wx/src/common/uiactioncmn.cpp delete mode 100644 Source/3rd Party/wx/src/common/unichar.cpp delete mode 100644 Source/3rd Party/wx/src/common/url.cpp delete mode 100644 Source/3rd Party/wx/src/common/ustring.cpp delete mode 100644 Source/3rd Party/wx/src/common/valnum.cpp delete mode 100644 Source/3rd Party/wx/src/common/webview.cpp delete mode 100644 Source/3rd Party/wx/src/common/webviewarchivehandler.cpp delete mode 100644 Source/3rd Party/wx/src/common/webviewfshandler.cpp delete mode 100644 Source/3rd Party/wx/src/common/windowid.cpp delete mode 100644 Source/3rd Party/wx/src/common/wrapsizer.cpp create mode 100644 Source/3rd Party/wx/src/common/wxchar.cpp delete mode 100644 Source/3rd Party/wx/src/common/wxcrt.cpp delete mode 100644 Source/3rd Party/wx/src/common/wxprintf.cpp delete mode 100644 Source/3rd Party/wx/src/common/xlocale.cpp delete mode 100644 Source/3rd Party/wx/src/common/xtixml.cpp delete mode 100644 Source/3rd Party/wx/src/generic/aboutdlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/accel.cpp delete mode 100644 Source/3rd Party/wx/src/generic/animateg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/bannerwindow.cpp delete mode 100644 Source/3rd Party/wx/src/generic/bmpcboxg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/calctrlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/caret.cpp delete mode 100644 Source/3rd Party/wx/src/generic/colour.cpp delete mode 100644 Source/3rd Party/wx/src/generic/colrdlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/commandlinkbuttong.cpp delete mode 100644 Source/3rd Party/wx/src/generic/datavgen.cpp delete mode 100644 Source/3rd Party/wx/src/generic/datectlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/dbgrptg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/dirdlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/editlbox.cpp delete mode 100644 Source/3rd Party/wx/src/generic/fdrepdlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/filectrlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/filedlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/fontdlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/fswatcherg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/grid.cpp delete mode 100644 Source/3rd Party/wx/src/generic/gridctrl.cpp delete mode 100644 Source/3rd Party/wx/src/generic/grideditors.cpp delete mode 100644 Source/3rd Party/wx/src/generic/gridsel.cpp delete mode 100644 Source/3rd Party/wx/src/generic/headerctrlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/helpext.cpp delete mode 100644 Source/3rd Party/wx/src/generic/htmllbox.cpp delete mode 100644 Source/3rd Party/wx/src/generic/hyperlinkg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/icon.cpp delete mode 100644 Source/3rd Party/wx/src/generic/imaglist.cpp delete mode 100644 Source/3rd Party/wx/src/generic/infobar.cpp delete mode 100644 Source/3rd Party/wx/src/generic/laywin.cpp delete mode 100644 Source/3rd Party/wx/src/generic/listctrl.cpp delete mode 100644 Source/3rd Party/wx/src/generic/markuptext.cpp delete mode 100644 Source/3rd Party/wx/src/generic/mask.cpp delete mode 100644 Source/3rd Party/wx/src/generic/mdig.cpp delete mode 100644 Source/3rd Party/wx/src/generic/notebook.cpp delete mode 100644 Source/3rd Party/wx/src/generic/notifmsgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/odcombo.cpp delete mode 100644 Source/3rd Party/wx/src/generic/paletteg.cpp rename Source/3rd Party/wx/src/{common/panelcmn.cpp => generic/panelg.cpp} (56%) delete mode 100644 Source/3rd Party/wx/src/generic/preferencesg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/propdlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/regiong.cpp delete mode 100644 Source/3rd Party/wx/src/generic/richmsgdlgg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/richtooltipg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/sashwin.cpp delete mode 100644 Source/3rd Party/wx/src/generic/splash.cpp delete mode 100644 Source/3rd Party/wx/src/generic/statbmpg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/statline.cpp delete mode 100644 Source/3rd Party/wx/src/generic/stattextg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/tabg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/textmeasure.cpp delete mode 100644 Source/3rd Party/wx/src/generic/timectrlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/tipdlg.cpp delete mode 100644 Source/3rd Party/wx/src/generic/treelist.cpp delete mode 100644 Source/3rd Party/wx/src/generic/wizard.cpp delete mode 100644 Source/3rd Party/wx/src/msw/aboutdlg.cpp delete mode 100644 Source/3rd Party/wx/src/msw/anybutton.cpp delete mode 100644 Source/3rd Party/wx/src/msw/artmsw.cpp delete mode 100644 Source/3rd Party/wx/src/msw/bmpcbox.cpp delete mode 100644 Source/3rd Party/wx/src/msw/calctrl.cpp delete mode 100644 Source/3rd Party/wx/src/msw/commandlinkbutton.cpp delete mode 100644 Source/3rd Party/wx/src/msw/datecontrols.cpp delete mode 100644 Source/3rd Party/wx/src/msw/datectrl.cpp delete mode 100644 Source/3rd Party/wx/src/msw/datetimectrl.cpp delete mode 100644 Source/3rd Party/wx/src/msw/evtloopconsole.cpp delete mode 100644 Source/3rd Party/wx/src/msw/fswatcher.cpp delete mode 100644 Source/3rd Party/wx/src/msw/gauge.cpp delete mode 100644 Source/3rd Party/wx/src/msw/gdiplus.cpp delete mode 100644 Source/3rd Party/wx/src/msw/glcanvas.cpp create mode 100644 Source/3rd Party/wx/src/msw/gsockmsw.cpp delete mode 100644 Source/3rd Party/wx/src/msw/headerctrl.cpp delete mode 100644 Source/3rd Party/wx/src/msw/helpbest.cpp delete mode 100644 Source/3rd Party/wx/src/msw/hyperlink.cpp delete mode 100644 Source/3rd Party/wx/src/msw/joystick.cpp delete mode 100644 Source/3rd Party/wx/src/msw/mediactrl_am.cpp delete mode 100644 Source/3rd Party/wx/src/msw/mediactrl_qt.cpp delete mode 100644 Source/3rd Party/wx/src/msw/mediactrl_wmp10.cpp delete mode 100644 Source/3rd Party/wx/src/msw/microwin.c delete mode 100644 Source/3rd Party/wx/src/msw/nativewin.cpp delete mode 100644 Source/3rd Party/wx/src/msw/nonownedwnd.cpp delete mode 100644 Source/3rd Party/wx/src/msw/notifmsg.cpp delete mode 100644 Source/3rd Party/wx/src/msw/ole/safearray.cpp delete mode 100644 Source/3rd Party/wx/src/msw/panel.cpp delete mode 100644 Source/3rd Party/wx/src/msw/penwin.cpp delete mode 100644 Source/3rd Party/wx/src/msw/progdlg.cpp delete mode 100644 Source/3rd Party/wx/src/msw/richmsgdlg.cpp delete mode 100644 Source/3rd Party/wx/src/msw/richtooltip.cpp rename Source/3rd Party/wx/src/msw/{slider.cpp => slider95.cpp} (65%) delete mode 100644 Source/3rd Party/wx/src/msw/sockmsw.cpp delete mode 100644 Source/3rd Party/wx/src/msw/sound.cpp create mode 100644 Source/3rd Party/wx/src/msw/statbr95.cpp delete mode 100644 Source/3rd Party/wx/src/msw/statusbar.cpp delete mode 100644 Source/3rd Party/wx/src/msw/taskbar.cpp rename Source/3rd Party/wx/src/msw/{toolbar.cpp => tbar95.cpp} (60%) delete mode 100644 Source/3rd Party/wx/src/msw/textentry.cpp delete mode 100644 Source/3rd Party/wx/src/msw/textmeasure.cpp delete mode 100644 Source/3rd Party/wx/src/msw/timectrl.cpp delete mode 100644 Source/3rd Party/wx/src/msw/uiaction.cpp delete mode 100644 Source/3rd Party/wx/src/msw/urlmsw.cpp delete mode 100644 Source/3rd Party/wx/src/msw/utilswin.cpp delete mode 100644 Source/3rd Party/wx/src/msw/webview_ie.cpp delete mode 100644 Source/3rd Party/wx/src/msw/winestub.c create mode 100644 Source/3rd Party/wx/src/png/ansi2knr.c create mode 100644 Source/3rd Party/wx/src/png/pngasmrd.h delete mode 100644 Source/3rd Party/wx/src/png/pngdebug.h create mode 100644 Source/3rd Party/wx/src/png/pnggccrd.c delete mode 100644 Source/3rd Party/wx/src/png/pnginfo.h delete mode 100644 Source/3rd Party/wx/src/png/pnglibconf.h delete mode 100644 Source/3rd Party/wx/src/png/pngprefix.h delete mode 100644 Source/3rd Party/wx/src/png/pngpriv.h delete mode 100644 Source/3rd Party/wx/src/png/pngstruct.h create mode 100644 Source/3rd Party/wx/src/png/pngvcrd.c delete mode 100644 Source/3rd Party/wx/src/xrc/descrip.mms delete mode 100644 Source/3rd Party/wx/src/xrc/xh_animatctrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_auinotbk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_bannerwindow.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_bmp.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_bmpbt.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_bmpcbox.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_bttn.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_cald.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_chckb.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_chckl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_choic.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_choicbk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_clrpicker.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_cmdlinkbn.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_collpane.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_combo.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_comboctrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_datectrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_dirpicker.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_dlg.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_editlbox.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_filectrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_filepicker.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_fontpicker.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_frame.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_gauge.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_gdctl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_grid.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_html.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_htmllbox.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_hyperlink.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_listb.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_listbk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_listc.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_mdi.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_menu.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_notbk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_odcombo.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_panel.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_propdlg.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_radbt.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_radbx.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_ribbon.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_richtext.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_scrol.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_scwin.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_simplebook.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_sizer.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_slidr.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_spin.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_split.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_srchctrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_statbar.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_stbmp.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_stbox.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_stlin.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_sttxt.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_text.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_tglbtn.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_timectrl.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_toolb.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_toolbk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_tree.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_treebk.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_unkwn.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xh_wizrd.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xmladv.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xmlres.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xmlreshandler.cpp delete mode 100644 Source/3rd Party/wx/src/xrc/xmlrsall.cpp diff --git a/PropertySheets/Platform.props b/PropertySheets/Platform.props index d7da893e1..8e043f9db 100644 --- a/PropertySheets/Platform.props +++ b/PropertySheets/Platform.props @@ -25,7 +25,7 @@ - WIN32;_WIN32;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) diff --git a/Source/3rd Party/wx/art/wxwin16x16.xpm b/Source/3rd Party/wx/art/wxwin16x16.xpm deleted file mode 100644 index ed1848ea7..000000000 --- a/Source/3rd Party/wx/art/wxwin16x16.xpm +++ /dev/null @@ -1,161 +0,0 @@ -/* XPM */ -static const char *const wxwin16x16_xpm[] = { -"16 16 142 2", -" c None", -". c #7171C0", -"+ c #7D7DC7", -"@ c #8181CE", -"# c #7979CE", -"$ c #7171CE", -"% c #6868CD", -"& c #5050C0", -"* c #7C7CCB", -"= c #D3D3FC", -"- c #C0C0FF", -"; c #B1B1FF", -"> c #A4A4FF", -", c #9696FF", -"' c #6B6BE3", -") c #3E3EC0", -"! c #7B7BD3", -"~ c #CFCFFF", -"{ c #A7A7FF", -"] c #8989FF", -"^ c #7B7BFF", -"/ c #5E5EEB", -"( c #3333BF", -"_ c #6969D3", -": c #BEBEFF", -"< c #8E8EFF", -"[ c #5E5EFF", -"} c #4C4CFD", -"| c #6464C6", -"1 c #A4A478", -"2 c #BFBF63", -"3 c #BFBF5C", -"4 c #BFBF56", -"5 c #BFBF51", -"6 c #C17474", -"7 c #BF7070", -"8 c #BF6969", -"9 c #BF6363", -"0 c #544AC7", -"a c #A8A8FF", -"b c #7070FF", -"c c #5050FF", -"d c #3F3FFF", -"e c #8C8CBA", -"f c #F6F6C8", -"g c #FBFBBB", -"h c #FBFBAE", -"i c #FBFBA1", -"j c #F9F993", -"k c #D7D760", -"l c #D28D8D", -"m c #EEB8B8", -"n c #EFAAAA", -"o c #EF9E9E", -"p c #7C5ABC", -"q c #8D8DFF", -"r c #4747FF", -"s c #3535FF", -"t c #2B2BFF", -"u c #AAAAA7", -"v c #FFFFD2", -"w c #FFFFA9", -"x c #FFFF9A", -"y c #FFFF8D", -"z c #FFFF80", -"A c #E4E45B", -"B c #E39F9F", -"C c #FFCCCC", -"D c #FFA9A9", -"E c #FF9C9C", -"F c #B469A0", -"G c #3E3DE7", -"H c #2828EF", -"I c #1E1EEF", -"J c #1515EF", -"K c #A5A595", -"L c #FFFFC2", -"M c #FFFF8F", -"N c #F7F765", -"O c #F2F251", -"P c #DBDB3A", -"Q c #E48E8E", -"R c #FFBABA", -"S c #FF8E8E", -"T c #FF8181", -"U c #FF6868", -"V c #E54D60", -"W c #AC2E56", -"X c #0B0BBF", -"Y c #0606BF", -"Z c #C8C85D", -"` c #FEFEB1", -" . c #FEFE74", -".. c #F4F456", -"+. c #EFEF42", -"@. c #EFEF38", -"#. c #D7D725", -"$. c #E47676", -"%. c #FFA8A8", -"&. c #FF7373", -"*. c #FF5555", -"=. c #FF4343", -"-. c #FF3939", -";. c #DA2323", -">. c #CFCF3C", -",. c #F6F694", -"'. c #F0F047", -"). c #EFEF2E", -"!. c #EFEF24", -"~. c #D7D715", -"{. c #E45757", -"]. c #FF8888", -"^. c #FF4646", -"/. c #FF2F2F", -"(. c #FF2525", -"_. c #DA1414", -":. c #C3C328", -"<. c #EBEB55", -"[. c #ECEC2F", -"}. c #ECEC24", -"|. c #ECEC1A", -"1. c #EBEB10", -"2. c #CDCD06", -"3. c #DD3A3A", -"4. c #FF6060", -"5. c #FF1B1B", -"6. c #FE1111", -"7. c #D10707", -"8. c #B8B819", -"9. c #B7B715", -"0. c #B7B710", -"a. c #B7B70B", -"b. c #B7B706", -"c. c #B7B701", -"d. c #B7B700", -"e. c #BF1A1A", -"f. c #CC1919", -"g. c #CE1414", -"h. c #CE0E0E", -"i. c #CE0808", -"j. c #C90202", -"k. c #C00000", -" ", -" ", -" . + @ # $ % & ", -" * = - ; > , ' ) ", -" ! ~ { , ] ^ / ( ", -" _ : < ^ [ } | 1 2 3 4 5 ", -"6 7 8 9 0 a b c d e f g h i j k ", -"l m n o p q r s t u v w x y z A ", -"B C D E F G H I J K L M z N O P ", -"Q R S T U V W X Y Z ` ...+.@.#.", -"$.%.&.*.=.-.;. >.,.'.@.).!.~.", -"{.].^.-./.(._. :.<.[.}.|.1.2.", -"3.4./.(.5.6.7. 8.9.0.a.b.c.d.", -"e.f.g.h.i.j.k. ", -" ", -" "}; diff --git a/Source/3rd Party/wx/art/wxwin32x32.xpm b/Source/3rd Party/wx/art/wxwin32x32.xpm deleted file mode 100644 index 25aed5e59..000000000 --- a/Source/3rd Party/wx/art/wxwin32x32.xpm +++ /dev/null @@ -1,442 +0,0 @@ -/* XPM */ -static const char *const wxwin32x32_xpm[] = { -"32 32 407 2", -" c None", -". c #7373C1", -"+ c #6E6EBF", -"@ c #6B6BBF", -"# c #6868BF", -"$ c #6464BF", -"% c #6161BF", -"& c #5E5EBF", -"* c #5A5ABF", -"= c #5959C0", -"- c #7171C0", -"; c #7272C1", -"> c #8686CE", -", c #8686D0", -"' c #8282D0", -") c #7D7DD0", -"! c #7979D0", -"~ c #7575D0", -"{ c #7171D0", -"] c #6D6DD0", -"^ c #6666CD", -"/ c #5151C1", -"( c #4C4CBF", -"_ c #7171C1", -": c #7272C2", -"< c #C1C1F2", -"[ c #D7D7FF", -"} c #C9C9FF", -"| c #C2C2FF", -"1 c #BBBBFF", -"2 c #B4B4FF", -"3 c #AEAEFF", -"4 c #A7A7FF", -"5 c #A0A0FF", -"6 c #9A9AFF", -"7 c #8484F2", -"8 c #4949C2", -"9 c #4444C1", -"0 c #6A6AC0", -"a c #8989D4", -"b c #DADAFF", -"c c #C0C0FF", -"d c #9393FF", -"e c #8C8CFF", -"f c #8686FF", -"g c #5454D4", -"h c #3E3EC0", -"i c #6363BF", -"j c #8686D8", -"k c #D4D4FF", -"l c #D2D2FF", -"m c #7F7FFF", -"n c #7878FF", -"o c #4F4FD7", -"p c #3737BF", -"q c #5C5CBF", -"r c #7D7DD8", -"s c #CCCCFF", -"t c #CACAFF", -"u c #A8A8FF", -"v c #7070FF", -"w c #6B6BFF", -"x c #4545D7", -"y c #3030BF", -"z c #5555BF", -"A c #7373D8", -"B c #C3C3FF", -"C c #9C9CFF", -"D c #8D8DFF", -"E c #7777FF", -"F c #6262FF", -"G c #5252FF", -"H c #4B4BFF", -"I c #4848FF", -"J c #3232D7", -"K c #2626BF", -"L c #4E4EBF", -"M c #6A6AD8", -"N c #B9B9FF", -"O c #9090FF", -"P c #6F6FFF", -"Q c #5555FF", -"R c #4646FF", -"S c #4B4BF5", -"T c #8282B4", -"U c #93938E", -"V c #B1B173", -"W c #BFBF68", -"X c #BFBF65", -"Y c #BFBF62", -"Z c #BFBF5E", -"` c #BFBF5B", -" . c #BFBF57", -".. c #BFBF54", -"+. c #BFBF51", -"@. c #5858D8", -"#. c #B2B2FF", -"$. c #B1B1FF", -"%. c #8484FF", -"&. c #7272FF", -"*. c #6767FF", -"=. c #4F4FFF", -"-. c #4747FF", -";. c #4242FF", -">. c #4141FA", -",. c #ABAB8A", -"'. c #E4E4AA", -"). c #F5F5C3", -"!. c #F6F6BE", -"~. c #F6F6B7", -"{. c #F6F6B1", -"]. c #F6F6AB", -"^. c #F6F6A5", -"/. c #F6F69E", -"(. c #F6F698", -"_. c #F1F18C", -":. c #D0D05F", -"<. c #BFBF48", -"[. c #C17474", -"}. c #C07171", -"|. c #BF6E6E", -"1. c #BF6B6B", -"2. c #BF6868", -"3. c #BF6464", -"4. c #BF6161", -"5. c #7C498C", -"6. c #4242D8", -"7. c #A4A4FF", -"8. c #5959FF", -"9. c #3D3DFF", -"0. c #3838FF", -"a. c #6666CA", -"b. c #DCDC98", -"c. c #FFFFDD", -"d. c #FFFFD7", -"e. c #FFFFC0", -"f. c #FFFFB8", -"g. c #FFFFB2", -"h. c #FFFFAB", -"i. c #FFFFA4", -"j. c #FFFF9D", -"k. c #FFFF97", -"l. c #FFFF90", -"m. c #FBFB85", -"n. c #C2C244", -"o. c #C37676", -"p. c #DA9B9B", -"q. c #DF9F9F", -"r. c #DF9A9A", -"s. c #DF9494", -"t. c #DF8F8F", -"u. c #DF8A8A", -"v. c #B47094", -"w. c #3B3BD8", -"x. c #9292FF", -"y. c #5656FF", -"z. c #3333FF", -"A. c #2E2EFF", -"B. c #7070B6", -"C. c #E7E79F", -"D. c #FFFFDE", -"E. c #FFFFCF", -"F. c #FFFFB5", -"G. c #FFFF9E", -"H. c #FFFF8A", -"I. c #FFFF83", -"J. c #FFFF7C", -"K. c #C8C843", -"L. c #C06D6D", -"M. c #F1BEBE", -"N. c #FFDBDB", -"O. c #FFCBCB", -"P. c #FFC0C0", -"Q. c #FFBABA", -"R. c #FFB3B3", -"S. c #FFACAC", -"T. c #CE89AC", -"U. c #3333D7", -"V. c #8787FF", -"W. c #4D4DFF", -"X. c #2929FF", -"Y. c #2424FF", -"Z. c #6B6BB3", -"`. c #E7E795", -" + c #FFFFC6", -".+ c #FFFFA8", -"++ c #FFFF76", -"@+ c #FFFF6F", -"#+ c #C8C83C", -"$+ c #C77474", -"%+ c #FFD3D3", -"&+ c #FFDEDE", -"*+ c #FFC4C4", -"=+ c #FFA6A6", -"-+ c #FF9F9F", -";+ c #F3929A", -">+ c #2F29C3", -",+ c #4C4CFB", -"'+ c #6868FF", -")+ c #3939FF", -"!+ c #1F1FFF", -"~+ c #1A1AFF", -"{+ c #6666B0", -"]+ c #E7E78A", -"^+ c #FFFFD0", -"/+ c #FFFFBD", -"(+ c #FFFF9B", -"_+ c #FFFF91", -":+ c #FAFA6E", -"<+ c #F5F55F", -"[+ c #F5F558", -"}+ c #F7F756", -"|+ c #C7C732", -"1+ c #C86E6E", -"2+ c #FFC9C9", -"3+ c #FFD7D7", -"4+ c #FFB8B8", -"5+ c #FF9898", -"6+ c #FF9292", -"7+ c #FF8B8B", -"8+ c #B16098", -"9+ c #2420C6", -"0+ c #2222DD", -"a+ c #1F1FDF", -"b+ c #1B1BDF", -"c+ c #1818DF", -"d+ c #1414DF", -"e+ c #1010DF", -"f+ c #0C0CDF", -"g+ c #5F5F9C", -"h+ c #E7E77F", -"i+ c #FFFFC9", -"j+ c #FFFFB4", -"k+ c #FFFF8E", -"l+ c #FFFF7D", -"m+ c #FEFE75", -"n+ c #F4F45D", -"o+ c #EFEF4F", -"p+ c #EFEF4A", -"q+ c #EFEF44", -"r+ c #EFEF3F", -"s+ c #BFBF22", -"t+ c #C86666", -"u+ c #FFBFBF", -"v+ c #FFD0D0", -"w+ c #FFADAD", -"x+ c #FF8484", -"y+ c #FF7E7E", -"z+ c #FF7373", -"A+ c #E75F70", -"B+ c #B0457F", -"C+ c #9A3776", -"D+ c #5F1D7C", -"E+ c #0C0CBF", -"F+ c #0909BF", -"G+ c #0707BF", -"H+ c #0404BF", -"I+ c #878766", -"J+ c #E6E674", -"K+ c #FFFFC2", -"L+ c #FFFF82", -"M+ c #FEFE6E", -"N+ c #F3F355", -"O+ c #EFEF45", -"P+ c #EFEF40", -"Q+ c #EFEF3B", -"R+ c #EFEF36", -"S+ c #BFBF1C", -"T+ c #C85F5F", -"U+ c #FFB4B4", -"V+ c #FFA2A2", -"W+ c #FF7575", -"X+ c #FF5E5E", -"Y+ c #FF5050", -"Z+ c #FF4A4A", -"`+ c #FF4545", -" @ c #E73535", -".@ c #BF2121", -"+@ c #B7B733", -"@@ c #DCDC55", -"#@ c #FDFDB7", -"$@ c #FFFFA2", -"%@ c #FFFF75", -"&@ c #FCFC64", -"*@ c #F2F24E", -"=@ c #EFEF31", -"-@ c #EFEF2C", -";@ c #BFBF16", -">@ c #C85656", -",@ c #FFAAAA", -"'@ c #FFC2C2", -")@ c #FF9797", -"!@ c #FF7777", -"~@ c #FF6E6E", -"{@ c #FF5454", -"]@ c #FF4040", -"^@ c #FF3B3B", -"/@ c #E72C2C", -"(@ c #BF1919", -"_@ c #B7B72E", -":@ c #DADA48", -"<@ c #F7F7A6", -"[@ c #F6F689", -"}@ c #F2F254", -"|@ c #EFEF27", -"1@ c #EFEF22", -"2@ c #BFBF10", -"3@ c #C84040", -"4@ c #FF9A9A", -"5@ c #FFBBBB", -"6@ c #FF7171", -"7@ c #FF6666", -"8@ c #FF4E4E", -"9@ c #FF4646", -"0@ c #FF4141", -"a@ c #FF3C3C", -"b@ c #FF3737", -"c@ c #FF3232", -"d@ c #E72424", -"e@ c #BF1414", -"f@ c #B7B729", -"g@ c #DADA3F", -"h@ c #F7F7A1", -"i@ c #F4F480", -"j@ c #F0F047", -"k@ c #EFEF1D", -"l@ c #EFEF18", -"m@ c #BFBF0B", -"n@ c #C83636", -"o@ c #FFABAB", -"p@ c #FF7676", -"q@ c #FF2D2D", -"r@ c #FF2828", -"s@ c #E71C1C", -"t@ c #BF0F0F", -"u@ c #B7B724", -"v@ c #D1D132", -"w@ c #F4F478", -"x@ c #EFEF13", -"y@ c #ECEC0E", -"z@ c #BABA05", -"A@ c #C83030", -"B@ c #FF6161", -"C@ c #FF2323", -"D@ c #FF1E1E", -"E@ c #E71414", -"F@ c #BF0A0A", -"G@ c #B8B820", -"H@ c #B9B91F", -"I@ c #DADA2C", -"J@ c #E9E931", -"K@ c #EAEA2A", -"L@ c #EAEA25", -"M@ c #EAEA20", -"N@ c #EAEA1C", -"O@ c #EAEA17", -"P@ c #EAEA12", -"Q@ c #EAEA0D", -"R@ c #E5E508", -"S@ c #C7C703", -"T@ c #B7B701", -"U@ c #C52929", -"V@ c #FF5858", -"W@ c #FF1919", -"X@ c #FF1414", -"Y@ c #E30C0C", -"Z@ c #BF0606", -"`@ c #B8B819", -" # c #B7B717", -".# c #B7B714", -"+# c #B7B711", -"@# c #B7B70F", -"## c #B7B70C", -"$# c #B7B70A", -"%# c #B7B707", -"&# c #B7B705", -"*# c #B7B702", -"=# c #B7B700", -"-# c #BF2020", -";# c #E63131", -"># c #FF5555", -",# c #FF3A3A", -"'# c #FF0F0F", -")# c #FA0A0A", -"!# c #C90303", -"~# c #C00202", -"{# c #C01C1C", -"]# c #CB1B1B", -"^# c #D01A1A", -"/# c #D01616", -"(# c #D01313", -"_# c #D01010", -":# c #D00D0D", -"<# c #D00A0A", -"[# c #D00707", -"}# c #CF0303", -"|# c #C30101", -"1# c #C00000", -"2# c #C21414", -"3# c #BF1111", -"4# c #BF0E0E", -"5# c #BF0C0C", -"6# c #BF0909", -"7# c #BF0707", -"8# c #BF0404", -"9# c #BF0202", -"0# c #C50000", -" ", -" ", -" ", -" ", -" . + @ # $ % & * = ", -" - ; > , ' ) ! ~ { ] ^ / ( ", -" _ : < [ } | 1 2 3 4 5 6 7 8 9 ", -" 0 a b b c 2 3 4 5 6 d e f g h ", -" i j k l 2 4 5 6 d e f m n o p ", -" q r s t u 6 d e f m n v w x y ", -" z A B | C D f m E F G H I J K ", -" L M 1 N O m n P Q H R S T U V W X Y Z ` ...+. ", -" p @.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.", -" [.}.|.1.2.3.4.5.6.6 7.&.8.I ;.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.", -"}.o.p.q.r.s.t.u.v.w.O x.y.;.9.0.z.A.B.C.D.E.F.h.i.G.k.l.H.I.J.K.", -"L.M.N.O.P.Q.R.S.T.U.V.e W.0.z.A.X.Y.Z.`.d. +.+G.k.l.H.I.J.++@+#+", -"$+%+&+*+R.S.=+-+;+>+,+'+)+A.X.Y.!+~+{+]+^+/+(+_+H.I.J.:+<+[+}+|+", -"1+2+3+4+=+-+5+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+k+I.l+m+n+o+p+q+r+s+", -"t+u+v+w+5+6+7+x+y+z+A+B+C+D+E+F+G+H+I+J+K+h.L+++M+N+p+O+P+Q+R+S+", -"T+U+2+V+7+x+y+W+X+Y+Z+`+ @.@ +@@@#@$@%@&@*@O+P+Q+R+=@-@;@", -">@,@'@)@y+!@~@{@Z+`+]@^@/@(@ _@:@<@[@}@O+P+Q+R+=@-@|@1@2@", -"3@4@5@7+6@7@8@9@0@a@b@c@d@e@ f@g@h@i@j@Q+R+=@-@|@1@k@l@m@", -"n@y+o@p@{@9@0@a@b@c@q@r@s@t@ u@v@i@w@Q+=@-@|@1@k@l@x@y@z@", -"A@p@-+B@0@a@b@c@q@r@C@D@E@F@ G@H@I@J@K@L@M@N@O@P@Q@R@S@T@", -"U@7@4@V@b@c@q@r@C@D@W@X@Y@Z@ `@ #.#+#@###$#%#&#*#=#=# ", -"-#;#>#,#q@r@C@D@W@X@'#)#!#~# ", -"{#(@]#^#/#(#_#:#<#[#}#|#1# ", -" 2#3#4#5#6#7#8#9#1#0# ", -" ", -" ", -" ", -" "}; diff --git a/Source/3rd Party/wx/include/msvc/wx/setup.h b/Source/3rd Party/wx/include/msvc/wx/setup.h index 97e3193f8..f00b8ec37 100644 --- a/Source/3rd Party/wx/include/msvc/wx/setup.h +++ b/Source/3rd Party/wx/include/msvc/wx/setup.h @@ -1,256 +1,241 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msvc/wx/setup.h +// Name: msvc/wx/msw/setup.h // Purpose: wrapper around the real wx/setup.h for Visual C++ // Author: Vadim Zeitlin // Modified by: // Created: 2004-12-12 +// RCS-ID: $Id: setup.h 43687 2006-11-27 15:03:59Z VZ $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _MSC_VER - #error "This file should only be included when using Microsoft Visual C++" -#endif - // VC++ IDE predefines _DEBUG and _UNICODE for the new projects itself, but // the other symbols (WXUSINGDLL, __WXUNIVERSAL__, ...) should be defined // explicitly! -#include "wx/version.h" -#include "wx/cpp.h" - -// notice that wxSUFFIX_DEBUG is a string but wxSUFFIX itself must be an -// identifier as string concatenation is not done inside #include where we -// need it -#ifdef _DEBUG - #define wxSUFFIX_DEBUG "d" +#ifdef _MSC_VER #ifdef _UNICODE - #define wxSUFFIX ud - #else // !_UNICODE - #define wxSUFFIX d - #endif // _UNICODE/!_UNICODE -#else - #define wxSUFFIX_DEBUG "" - #ifdef _UNICODE - #define wxSUFFIX u - #else // !_UNICODE - // don't define wxSUFFIX at all as preprocessor operations don't work - // with empty values so we need to check for this case specially below - #endif // _UNICODE/!_UNICODE -#endif - -// compiler-specific prefix: by default it's always just "vc" for compatibility -// reasons but if you use multiple MSVC versions you probably build them with -// COMPILER_PREFIX=vcXX and in this case you may want to either predefine -// wxMSVC_VERSION as "XX" or define wxMSVC_VERSION_AUTO to use the appropriate -// version depending on the compiler used -#ifdef wxMSVC_VERSION - #define wxCOMPILER_PREFIX wxCONCAT(vc, wxMSVC_VERSION) -#elif defined(wxMSVC_VERSION_AUTO) - #if _MSC_VER == 1200 - #define wxCOMPILER_PREFIX vc60 - #elif _MSC_VER == 1300 - #define wxCOMPILER_PREFIX vc70 - #elif _MSC_VER == 1310 - #define wxCOMPILER_PREFIX vc71 - #elif _MSC_VER == 1400 - #define wxCOMPILER_PREFIX vc80 - #elif _MSC_VER == 1500 - #define wxCOMPILER_PREFIX vc90 - #elif _MSC_VER == 1600 - #define wxCOMPILER_PREFIX vc100 - #elif _MSC_VER == 1700 - #define wxCOMPILER_PREFIX vc110 - #elif _MSC_VER == 1800 - #define wxCOMPILER_PREFIX vc120 - #else - #error "Unknown MSVC compiler version, please report to wx-dev." - #endif -#else - #define wxCOMPILER_PREFIX vc -#endif - -// architecture-specific part: not used (again, for compatibility), for x86 -#if defined(_M_X64) - #define wxARCH_SUFFIX// _x64//Project64: Disable arch suffix. -#elif defined(_M_IA64) - #define wxARCH_SUFFIX// _ia64//Project64: Disable arch suffix. -#else // assume _M_IX86 - #define wxARCH_SUFFIX -#endif - -// Ensure the library configuration is defined -#ifndef wxCFG - #define wxCFG -#endif - -// Construct the path for the subdirectory under /lib/ that the included setup.h -// will be used from -#ifdef WXUSINGDLL - #define wxLIB_SUBDIR \ - wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _dll, wxCFG) -#else // !DLL - #define wxLIB_SUBDIR \ - wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _lib, wxCFG) -#endif // DLL/!DLL - -// The user can predefine a different prefix if not using the default MSW port -// with MSVC. -#ifndef wxTOOLKIT_PREFIX - #if defined(__WXGTK__) - #define wxTOOLKIT_PREFIX gtk2 - #else - #define wxTOOLKIT_PREFIX msw - #endif -#endif // wxTOOLKIT_PREFIX - -// the real setup.h header file we need is in the build-specific directory, -// construct the path to it -#ifdef wxSUFFIX - #define wxSETUPH_PATH \ - wxCONCAT6(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, wxSUFFIX, /wx/setup.h) -#else // suffix is empty - #define wxSETUPH_PATH \ - wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h) -#endif - -#define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH) - -#include wxSETUPH_PATH_STR - - -// the library names depend on the build, these macro builds the correct -// library name for the given base name -#ifdef wxSUFFIX - #define wxSUFFIX_STR wxSTRINGIZE(wxSUFFIX) -#else // suffix is empty - #define wxSUFFIX_STR "" -#endif -#define wxSHORT_VERSION_STRING \ - wxSTRINGIZE(wxMAJOR_VERSION) wxSTRINGIZE(wxMINOR_VERSION) - -#define wxWX_LIB_NAME(name, subname) \ - "wx" name wxSHORT_VERSION_STRING wxSUFFIX_STR subname - -#define wxBASE_LIB_NAME(name) wxWX_LIB_NAME("base", "_" name) -#define wxTOOLKIT_LIB_NAME(name) wxWX_LIB_NAME(wxSTRINGIZE(wxTOOLKIT_PREFIX), "_" name) - -// This one is for 3rd party libraries: they don't have the version number -// in their names and usually exist in ANSI version only (except for regex) -// -// 3rd party libraries are also are not linked in when using DLLs as they're -// embedded inside our own DLLs and don't need to be linked with the user code. -#define wx3RD_PARTY_LIB_NAME(name) "wx" name wxSUFFIX_DEBUG - -// special version for regex as it does have a Unicode version -#define wx3RD_PARTY_LIB_NAME_U(name) "wx" name wxSUFFIX_STR - -#pragma comment(lib, wxWX_LIB_NAME("base", "")) - -#ifndef wxNO_NET_LIB - #ifndef WXUSINGDLL - #pragma comment(lib, "wsock32") - #endif - #pragma comment(lib, wxBASE_LIB_NAME("net")) -#endif -#if wxUSE_XML && !defined(wxNO_XML_LIB) - #pragma comment(lib, wxBASE_LIB_NAME("xml")) -#endif -#if wxUSE_REGEX && !defined(wxNO_REGEX_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME_U("regex")) -#endif - -#if wxUSE_GUI - #if wxUSE_XML && !defined(wxNO_EXPAT_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) - #endif - #if wxUSE_LIBJPEG && !defined(wxNO_JPEG_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("jpeg")) - #endif - #if wxUSE_LIBPNG && !defined(wxNO_PNG_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("png")) - #endif - #if wxUSE_LIBTIFF && !defined(wxNO_TIFF_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff")) - #endif - #if wxUSE_ZLIB && !defined(wxNO_ZLIB_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("zlib")) - #endif - - #pragma comment(lib, wxTOOLKIT_LIB_NAME("core")) - - #ifndef wxNO_ADV_LIB - #pragma comment(lib, wxTOOLKIT_LIB_NAME("adv")) - #endif - - #if wxUSE_HTML && !defined(wxNO_HTML_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("html")) - #endif - #if wxUSE_GLCANVAS && !defined(wxNO_GL_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("gl")) - #endif - #if wxUSE_DEBUGREPORT && !defined(wxNO_QA_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("qa")) - #endif - #if wxUSE_XRC && !defined(wxNO_XRC_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("xrc")) - #endif - #if wxUSE_AUI && !defined(wxNO_AUI_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("aui")) - #endif - #if wxUSE_PROPGRID && !defined(wxNO_PROPGRID_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("propgrid")) - #endif - #if wxUSE_RIBBON && !defined(wxNO_RIBBON_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("ribbon")) - #endif - #if wxUSE_RICHTEXT && !defined(wxNO_RICHTEXT_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("richtext")) - #endif - #if wxUSE_MEDIACTRL && !defined(wxNO_MEDIA_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("media")) - #endif - #if wxUSE_STC && !defined(wxNO_STC_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("stc")) - #ifndef WXUSINGDLL - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla")) + #ifdef WXUSINGDLL + #ifdef _DEBUG + #include "../../../lib/vc_dll/mswud/wx/setup.h" + #else + #include "../../../lib/vc_dll/mswu/wx/setup.h" + #endif + #else + #ifdef _DEBUG + #include "../../../lib/vc_lib/mswud/wx/setup.h" + #else + #include "../../../lib/vc_lib/mswu/wx/setup.h" + #endif #endif - #endif - #if wxUSE_WEBVIEW && !defined(wxNO_WEBVIEW_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("webview")) - #endif -#endif // wxUSE_GUI + #ifdef _DEBUG + #pragma comment(lib,"wxbase28ud") + #pragma comment(lib,"wxbase28ud_net") + #pragma comment(lib,"wxbase28ud_xml") + #if wxUSE_REGEX + #pragma comment(lib,"wxregexud") + #endif -#ifndef WXUSINGDLL - // Make sure all required system libraries are added to the linker too when - // using static libraries. - #pragma comment(lib, "kernel32") - #pragma comment(lib, "user32") - #pragma comment(lib, "gdi32") - #pragma comment(lib, "comdlg32") - #pragma comment(lib, "winspool") - #pragma comment(lib, "winmm") - #pragma comment(lib, "shell32") - #pragma comment(lib, "comctl32") - #pragma comment(lib, "ole32") - #pragma comment(lib, "oleaut32") - #pragma comment(lib, "uuid") - #pragma comment(lib, "rpcrt4") - #pragma comment(lib, "advapi32") - #if wxUSE_URL_NATIVE - #pragma comment(lib, "wininet") - #endif + #if wxUSE_GUI + #if wxUSE_XML + #pragma comment(lib,"wxexpatd") + #endif + #if wxUSE_LIBJPEG + #pragma comment(lib,"wxjpegd") + #endif + #if wxUSE_LIBPNG + #pragma comment(lib,"wxpngd") + #endif + #if wxUSE_LIBTIFF + #pragma comment(lib,"wxtiffd") + #endif + #if wxUSE_ZLIB + #pragma comment(lib,"wxzlibd") + #endif + #pragma comment(lib,"wxmsw28ud_adv") + #pragma comment(lib,"wxmsw28ud_core") + #pragma comment(lib,"wxmsw28ud_html") + #if wxUSE_GLCANVAS + #pragma comment(lib,"wxmsw28ud_gl") + #endif + #if wxUSE_DEBUGREPORT + #pragma comment(lib,"wxmsw28ud_qa") + #endif + #if wxUSE_XRC + #pragma comment(lib,"wxmsw28ud_xrc") + #endif + #if wxUSE_AUI + #pragma comment(lib,"wxmsw28ud_aui") + #endif + #if wxUSE_RICHTEXT + #pragma comment(lib,"wxmsw28ud_richtext") + #endif + #if wxUSE_MEDIACTRL + #pragma comment(lib,"wxmsw28ud_media") + #endif + #if wxUSE_ODBC + #pragma comment(lib,"wxbase28ud_odbc") + #endif + #endif // wxUSE_GUI + #else // release + #pragma comment(lib,"wxbase28u") + #pragma comment(lib,"wxbase28u_net") + #pragma comment(lib,"wxbase28u_xml") + #if wxUSE_REGEX + #pragma comment(lib,"wxregexu") + #endif + + #if wxUSE_GUI + #if wxUSE_XML + #pragma comment(lib,"wxexpat") + #endif + #if wxUSE_LIBJPEG + #pragma comment(lib,"wxjpeg") + #endif + #if wxUSE_LIBPNG + #pragma comment(lib,"wxpng") + #endif + #if wxUSE_LIBTIFF + #pragma comment(lib,"wxtiff") + #endif + #if wxUSE_ZLIB + #pragma comment(lib,"wxzlib") + #endif + #pragma comment(lib,"wxmsw28u_adv") + #pragma comment(lib,"wxmsw28u_core") + #pragma comment(lib,"wxmsw28u_html") + #if wxUSE_GLCANVAS + #pragma comment(lib,"wxmsw28u_gl") + #endif + #if wxUSE_DEBUGREPORT + #pragma comment(lib,"wxmsw28u_qa") + #endif + #if wxUSE_XRC + #pragma comment(lib,"wxmsw28u_xrc") + #endif + #if wxUSE_AUI + #pragma comment(lib,"wxmsw28u_aui") + #endif + #if wxUSE_RICHTEXT + #pragma comment(lib,"wxmsw28u_richtext") + #endif + #if wxUSE_MEDIACTRL + #pragma comment(lib,"wxmsw28u_media") + #endif + #if wxUSE_ODBC + #pragma comment(lib,"wxbase28u_odbc") + #endif + #endif // wxUSE_GUI + #endif // debug/release + #else // !_UNICODE + #ifdef WXUSINGDLL + #ifdef _DEBUG + #include "../../../lib/vc_dll/mswd/wx/setup.h" + #else + #include "../../../lib/vc_dll/msw/wx/setup.h" + #endif + #else // static lib + #ifdef _DEBUG + #include "../../../lib/vc_lib/mswd/wx/setup.h" + #else + #include "../../../lib/vc_lib/msw/wx/setup.h" + #endif + #endif // shared/static + + #ifdef _DEBUG + #pragma comment(lib,"wxbase28d") + #if wxUSE_REGEX + #pragma comment(lib,"wxregexd") + #endif + + #if wxUSE_GUI + #if wxUSE_XML + #pragma comment(lib,"wxexpatd") + #endif + #if wxUSE_LIBJPEG + #pragma comment(lib,"wxjpegd") + #endif + #if wxUSE_LIBPNG + #pragma comment(lib,"wxpngd") + #endif + #if wxUSE_LIBTIFF + #pragma comment(lib,"wxtiffd") + #endif + #if wxUSE_ZLIB + #pragma comment(lib,"wxzlibd") + #endif + #pragma comment(lib,"wxmsw28d_core") + #if wxUSE_GLCANVAS + #pragma comment(lib,"wxmsw28d_gl") + #endif + #if wxUSE_DEBUGREPORT + #pragma comment(lib,"wxmsw28d_qa") + #endif + #if wxUSE_XRC + #pragma comment(lib,"wxmsw28d_xrc") + #endif + #if wxUSE_AUI + #pragma comment(lib,"wxmsw28d_aui") + #endif + #if wxUSE_RICHTEXT + #pragma comment(lib,"wxmsw28d_richtext") + #endif + #if wxUSE_MEDIACTRL + #pragma comment(lib,"wxmsw28d_media") + #endif + #if wxUSE_ODBC + #pragma comment(lib,"wxbase28d_odbc") + #endif + #endif // wxUSE_GUI + #else // release + #pragma comment(lib,"wxbase28") + #if wxUSE_REGEX + #pragma comment(lib,"wxregex") + #endif + + #if wxUSE_GUI + #if wxUSE_XML + #pragma comment(lib,"wxexpat") + #endif + #if wxUSE_LIBJPEG + #pragma comment(lib,"wxjpeg") + #endif + #if wxUSE_LIBPNG + #pragma comment(lib,"wxpng") + #endif + #if wxUSE_LIBTIFF + #pragma comment(lib,"wxtiff") + #endif + #if wxUSE_ZLIB + #pragma comment(lib,"wxzlib") + #endif + #pragma comment(lib,"wxmsw28_core") + #if wxUSE_GLCANVAS + #pragma comment(lib,"wxmsw28_gl") + #endif + #if wxUSE_DEBUGREPORT + #pragma comment(lib,"wxmsw28_qa") + #endif + #if wxUSE_XRC + #pragma comment(lib,"wxmsw28_xrc") + #endif + #if wxUSE_AUI + #pragma comment(lib,"wxmsw28_aui") + #endif + #if wxUSE_RICHTEXT + #pragma comment(lib,"wxmsw28_richtext") + #endif + #if wxUSE_MEDIACTRL + #pragma comment(lib,"wxmsw28_media") + #endif + #if wxUSE_ODBC + #pragma comment(lib,"wxbase28_odbc") + #endif + #endif // wxUSE_GUI + #endif // debug/release + #endif // _UNICODE/!_UNICODE +#else + #error "This file should only be included when using Microsoft Visual C++" +#endif - #ifdef __WXGTK__ - #pragma comment(lib, "gtk-win32-2.0.lib") - #pragma comment(lib, "gdk-win32-2.0.lib") - #pragma comment(lib, "pangocairo-1.0.lib") - #pragma comment(lib, "gdk_pixbuf-2.0.lib") - #pragma comment(lib, "cairo.lib") - #pragma comment(lib, "pango-1.0.lib") - #pragma comment(lib, "gobject-2.0.lib") - #pragma comment(lib, "gthread-2.0.lib") - #pragma comment(lib, "glib-2.0.lib") - #endif -#endif // !WXUSINGDLL diff --git a/Source/3rd Party/wx/include/wx/aboutdlg.h b/Source/3rd Party/wx/include/wx/aboutdlg.h deleted file mode 100644 index 975b5def2..000000000 --- a/Source/3rd Party/wx/include/wx/aboutdlg.h +++ /dev/null @@ -1,169 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/aboutdlg.h -// Purpose: declaration of wxAboutDialog class -// Author: Vadim Zeitlin -// Created: 2006-10-07 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ABOUTDLG_H_ -#define _WX_ABOUTDLG_H_ - -#include "wx/defs.h" - -#if wxUSE_ABOUTDLG - -#include "wx/app.h" -#include "wx/icon.h" - -// ---------------------------------------------------------------------------- -// wxAboutDialogInfo: information shown by the standard "About" dialog -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxAboutDialogInfo -{ -public: - // all fields are initially uninitialized - wxAboutDialogInfo() { } - - // accessors for various simply fields - // ----------------------------------- - - // name of the program, if not used defaults to wxApp::GetAppDisplayName() - void SetName(const wxString& name) { m_name = name; } - wxString GetName() const - { return m_name.empty() ? wxTheApp->GetAppDisplayName() : m_name; } - - // version should contain program version without "version" word (e.g., - // "1.2" or "RC2") while longVersion may contain the full version including - // "version" word (e.g., "Version 1.2" or "Release Candidate 2") - // - // if longVersion is empty, it is automatically constructed from version - // - // generic and gtk native: use short version only, as a suffix to the - // program name msw and osx native: use long version - void SetVersion(const wxString& version, - const wxString& longVersion = wxString()); - - bool HasVersion() const { return !m_version.empty(); } - const wxString& GetVersion() const { return m_version; } - const wxString& GetLongVersion() const { return m_longVersion; } - - // brief, but possibly multiline, description of the program - void SetDescription(const wxString& desc) { m_description = desc; } - bool HasDescription() const { return !m_description.empty(); } - const wxString& GetDescription() const { return m_description; } - - // short string containing the program copyright information - void SetCopyright(const wxString& copyright) { m_copyright = copyright; } - bool HasCopyright() const { return !m_copyright.empty(); } - const wxString& GetCopyright() const { return m_copyright; } - - // long, multiline string containing the text of the program licence - void SetLicence(const wxString& licence) { m_licence = licence; } - void SetLicense(const wxString& licence) { m_licence = licence; } - bool HasLicence() const { return !m_licence.empty(); } - const wxString& GetLicence() const { return m_licence; } - - // icon to be shown in the dialog, defaults to the main frame icon - void SetIcon(const wxIcon& icon) { m_icon = icon; } - bool HasIcon() const { return m_icon.IsOk(); } - wxIcon GetIcon() const; - - // web site for the program and its description (defaults to URL itself if - // empty) - void SetWebSite(const wxString& url, const wxString& desc = wxEmptyString) - { - m_url = url; - m_urlDesc = desc.empty() ? url : desc; - } - - bool HasWebSite() const { return !m_url.empty(); } - - const wxString& GetWebSiteURL() const { return m_url; } - const wxString& GetWebSiteDescription() const { return m_urlDesc; } - - // accessors for the arrays - // ------------------------ - - // the list of developers of the program - void SetDevelopers(const wxArrayString& developers) - { m_developers = developers; } - void AddDeveloper(const wxString& developer) - { m_developers.push_back(developer); } - - bool HasDevelopers() const { return !m_developers.empty(); } - const wxArrayString& GetDevelopers() const { return m_developers; } - - // the list of documentation writers - void SetDocWriters(const wxArrayString& docwriters) - { m_docwriters = docwriters; } - void AddDocWriter(const wxString& docwriter) - { m_docwriters.push_back(docwriter); } - - bool HasDocWriters() const { return !m_docwriters.empty(); } - const wxArrayString& GetDocWriters() const { return m_docwriters; } - - // the list of artists for the program art - void SetArtists(const wxArrayString& artists) - { m_artists = artists; } - void AddArtist(const wxString& artist) - { m_artists.push_back(artist); } - - bool HasArtists() const { return !m_artists.empty(); } - const wxArrayString& GetArtists() const { return m_artists; } - - // the list of translators - void SetTranslators(const wxArrayString& translators) - { m_translators = translators; } - void AddTranslator(const wxString& translator) - { m_translators.push_back(translator); } - - bool HasTranslators() const { return !m_translators.empty(); } - const wxArrayString& GetTranslators() const { return m_translators; } - - - // implementation only - // ------------------- - - // "simple" about dialog shows only textual information (with possibly - // default icon but without hyperlink nor any long texts such as the - // licence text) - bool IsSimple() const - { return !HasWebSite() && !HasIcon() && !HasLicence(); } - - // get the description and credits (i.e. all of developers, doc writers, - // artists and translators) as a one long multiline string - wxString GetDescriptionAndCredits() const; - - // returns the copyright with the (C) string substituted by the Unicode - // character U+00A9 - wxString GetCopyrightToDisplay() const; - -private: - wxString m_name, - m_version, - m_longVersion, - m_description, - m_copyright, - m_licence; - - wxIcon m_icon; - - wxString m_url, - m_urlDesc; - - wxArrayString m_developers, - m_docwriters, - m_artists, - m_translators; -}; - -// functions to show the about dialog box -WXDLLIMPEXP_ADV void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); - -#endif // wxUSE_ABOUTDLG - -#endif // _WX_ABOUTDLG_H_ - diff --git a/Source/3rd Party/wx/include/wx/accel.h b/Source/3rd Party/wx/include/wx/accel.h index a162db3a5..49d14ec2a 100644 --- a/Source/3rd Party/wx/include/wx/accel.h +++ b/Source/3rd Party/wx/include/wx/accel.h @@ -4,6 +4,7 @@ // Author: Julian Smart, Robert Roebling, Vadim Zeitlin // Modified by: // Created: 31.05.01 (extracted from other files) +// RCS-ID: $Id: accel.h 66927 2011-02-16 23:27:30Z JS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -26,25 +27,24 @@ class WXDLLIMPEXP_FWD_CORE wxKeyEvent; // ---------------------------------------------------------------------------- // wxAcceleratorEntry flags -enum wxAcceleratorEntryFlags +enum { wxACCEL_NORMAL = 0x0000, // no modifiers wxACCEL_ALT = 0x0001, // hold Alt key down wxACCEL_CTRL = 0x0002, // hold Ctrl key down wxACCEL_SHIFT = 0x0004, // hold Shift key down #if defined(__WXMAC__) || defined(__WXCOCOA__) - wxACCEL_RAW_CTRL= 0x0008, // + wxACCEL_CMD = 0x0008 // Command key on OS X #else - wxACCEL_RAW_CTRL= wxACCEL_CTRL, + wxACCEL_CMD = wxACCEL_CTRL #endif - wxACCEL_CMD = wxACCEL_CTRL }; // ---------------------------------------------------------------------------- // an entry in wxAcceleratorTable corresponds to one accelerator // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxAcceleratorEntry +class WXDLLEXPORT wxAcceleratorEntry { public: wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0, @@ -68,8 +68,7 @@ public: wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry) { - if (&entry != this) - Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item); + Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item); return *this; } @@ -107,7 +106,7 @@ public: bool IsOk() const { - return m_keyCode != 0; + return m_keyCode != 0; } @@ -116,13 +115,8 @@ public: // returns a wxString for the this accelerator. // this function formats it using the - format - // where maybe a hyphen-separated list of "shift|alt|ctrl" - wxString ToString() const { return AsPossiblyLocalizedString(true); } - - // same as above but without translating, useful if the string is meant to - // be stored in a file or otherwise stored, instead of being shown to the - // user - wxString ToRawString() const { return AsPossiblyLocalizedString(false); } + // where maybe a hyphen-separed list of "shift|alt|ctrl" + wxString ToString() const; // returns true if the given string correctly initialized this object // (i.e. if IsOk() returns true after this call) @@ -130,8 +124,6 @@ public: private: - wxString AsPossiblyLocalizedString(bool localized) const; - // common part of Create() and FromString() static bool ParseAccel(const wxString& str, int *flags, int *keycode); @@ -163,14 +155,14 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/accel.h" #elif defined(__WXMAC__) - #include "wx/osx/accel.h" + #include "wx/mac/accel.h" #elif defined(__WXCOCOA__) #include "wx/generic/accel.h" #elif defined(__WXPM__) #include "wx/os2/accel.h" #endif -extern WXDLLIMPEXP_DATA_CORE(wxAcceleratorTable) wxNullAcceleratorTable; +extern WXDLLEXPORT_DATA(wxAcceleratorTable) wxNullAcceleratorTable; #endif // wxUSE_ACCEL diff --git a/Source/3rd Party/wx/include/wx/access.h b/Source/3rd Party/wx/include/wx/access.h deleted file mode 100644 index 70cbaf138..000000000 --- a/Source/3rd Party/wx/include/wx/access.h +++ /dev/null @@ -1,376 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/access.h -// Purpose: Accessibility classes -// Author: Julian Smart -// Modified by: -// Created: 2003-02-12 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ACCESSBASE_H_ -#define _WX_ACCESSBASE_H_ - -// ---------------------------------------------------------------------------- -// headers we have to include here -// ---------------------------------------------------------------------------- - -#include "wx/defs.h" - -#if wxUSE_ACCESSIBILITY - -#include "wx/variant.h" - -typedef enum -{ - wxACC_FAIL, - wxACC_FALSE, - wxACC_OK, - wxACC_NOT_IMPLEMENTED, - wxACC_NOT_SUPPORTED -} wxAccStatus; - -// Child ids are integer identifiers from 1 up. -// So zero represents 'this' object. -#define wxACC_SELF 0 - -// Navigation constants - -typedef enum -{ - wxNAVDIR_DOWN, - wxNAVDIR_FIRSTCHILD, - wxNAVDIR_LASTCHILD, - wxNAVDIR_LEFT, - wxNAVDIR_NEXT, - wxNAVDIR_PREVIOUS, - wxNAVDIR_RIGHT, - wxNAVDIR_UP -} wxNavDir; - -// Role constants - -typedef enum { - wxROLE_NONE, - wxROLE_SYSTEM_ALERT, - wxROLE_SYSTEM_ANIMATION, - wxROLE_SYSTEM_APPLICATION, - wxROLE_SYSTEM_BORDER, - wxROLE_SYSTEM_BUTTONDROPDOWN, - wxROLE_SYSTEM_BUTTONDROPDOWNGRID, - wxROLE_SYSTEM_BUTTONMENU, - wxROLE_SYSTEM_CARET, - wxROLE_SYSTEM_CELL, - wxROLE_SYSTEM_CHARACTER, - wxROLE_SYSTEM_CHART, - wxROLE_SYSTEM_CHECKBUTTON, - wxROLE_SYSTEM_CLIENT, - wxROLE_SYSTEM_CLOCK, - wxROLE_SYSTEM_COLUMN, - wxROLE_SYSTEM_COLUMNHEADER, - wxROLE_SYSTEM_COMBOBOX, - wxROLE_SYSTEM_CURSOR, - wxROLE_SYSTEM_DIAGRAM, - wxROLE_SYSTEM_DIAL, - wxROLE_SYSTEM_DIALOG, - wxROLE_SYSTEM_DOCUMENT, - wxROLE_SYSTEM_DROPLIST, - wxROLE_SYSTEM_EQUATION, - wxROLE_SYSTEM_GRAPHIC, - wxROLE_SYSTEM_GRIP, - wxROLE_SYSTEM_GROUPING, - wxROLE_SYSTEM_HELPBALLOON, - wxROLE_SYSTEM_HOTKEYFIELD, - wxROLE_SYSTEM_INDICATOR, - wxROLE_SYSTEM_LINK, - wxROLE_SYSTEM_LIST, - wxROLE_SYSTEM_LISTITEM, - wxROLE_SYSTEM_MENUBAR, - wxROLE_SYSTEM_MENUITEM, - wxROLE_SYSTEM_MENUPOPUP, - wxROLE_SYSTEM_OUTLINE, - wxROLE_SYSTEM_OUTLINEITEM, - wxROLE_SYSTEM_PAGETAB, - wxROLE_SYSTEM_PAGETABLIST, - wxROLE_SYSTEM_PANE, - wxROLE_SYSTEM_PROGRESSBAR, - wxROLE_SYSTEM_PROPERTYPAGE, - wxROLE_SYSTEM_PUSHBUTTON, - wxROLE_SYSTEM_RADIOBUTTON, - wxROLE_SYSTEM_ROW, - wxROLE_SYSTEM_ROWHEADER, - wxROLE_SYSTEM_SCROLLBAR, - wxROLE_SYSTEM_SEPARATOR, - wxROLE_SYSTEM_SLIDER, - wxROLE_SYSTEM_SOUND, - wxROLE_SYSTEM_SPINBUTTON, - wxROLE_SYSTEM_STATICTEXT, - wxROLE_SYSTEM_STATUSBAR, - wxROLE_SYSTEM_TABLE, - wxROLE_SYSTEM_TEXT, - wxROLE_SYSTEM_TITLEBAR, - wxROLE_SYSTEM_TOOLBAR, - wxROLE_SYSTEM_TOOLTIP, - wxROLE_SYSTEM_WHITESPACE, - wxROLE_SYSTEM_WINDOW -} wxAccRole; - -// Object types - -typedef enum { - wxOBJID_WINDOW = 0x00000000, - wxOBJID_SYSMENU = 0xFFFFFFFF, - wxOBJID_TITLEBAR = 0xFFFFFFFE, - wxOBJID_MENU = 0xFFFFFFFD, - wxOBJID_CLIENT = 0xFFFFFFFC, - wxOBJID_VSCROLL = 0xFFFFFFFB, - wxOBJID_HSCROLL = 0xFFFFFFFA, - wxOBJID_SIZEGRIP = 0xFFFFFFF9, - wxOBJID_CARET = 0xFFFFFFF8, - wxOBJID_CURSOR = 0xFFFFFFF7, - wxOBJID_ALERT = 0xFFFFFFF6, - wxOBJID_SOUND = 0xFFFFFFF5 -} wxAccObject; - -// Accessible states - -#define wxACC_STATE_SYSTEM_ALERT_HIGH 0x00000001 -#define wxACC_STATE_SYSTEM_ALERT_MEDIUM 0x00000002 -#define wxACC_STATE_SYSTEM_ALERT_LOW 0x00000004 -#define wxACC_STATE_SYSTEM_ANIMATED 0x00000008 -#define wxACC_STATE_SYSTEM_BUSY 0x00000010 -#define wxACC_STATE_SYSTEM_CHECKED 0x00000020 -#define wxACC_STATE_SYSTEM_COLLAPSED 0x00000040 -#define wxACC_STATE_SYSTEM_DEFAULT 0x00000080 -#define wxACC_STATE_SYSTEM_EXPANDED 0x00000100 -#define wxACC_STATE_SYSTEM_EXTSELECTABLE 0x00000200 -#define wxACC_STATE_SYSTEM_FLOATING 0x00000400 -#define wxACC_STATE_SYSTEM_FOCUSABLE 0x00000800 -#define wxACC_STATE_SYSTEM_FOCUSED 0x00001000 -#define wxACC_STATE_SYSTEM_HOTTRACKED 0x00002000 -#define wxACC_STATE_SYSTEM_INVISIBLE 0x00004000 -#define wxACC_STATE_SYSTEM_MARQUEED 0x00008000 -#define wxACC_STATE_SYSTEM_MIXED 0x00010000 -#define wxACC_STATE_SYSTEM_MULTISELECTABLE 0x00020000 -#define wxACC_STATE_SYSTEM_OFFSCREEN 0x00040000 -#define wxACC_STATE_SYSTEM_PRESSED 0x00080000 -#define wxACC_STATE_SYSTEM_PROTECTED 0x00100000 -#define wxACC_STATE_SYSTEM_READONLY 0x00200000 -#define wxACC_STATE_SYSTEM_SELECTABLE 0x00400000 -#define wxACC_STATE_SYSTEM_SELECTED 0x00800000 -#define wxACC_STATE_SYSTEM_SELFVOICING 0x01000000 -#define wxACC_STATE_SYSTEM_UNAVAILABLE 0x02000000 - -// Selection flag - -typedef enum -{ - wxACC_SEL_NONE = 0, - wxACC_SEL_TAKEFOCUS = 1, - wxACC_SEL_TAKESELECTION = 2, - wxACC_SEL_EXTENDSELECTION = 4, - wxACC_SEL_ADDSELECTION = 8, - wxACC_SEL_REMOVESELECTION = 16 -} wxAccSelectionFlags; - -// Accessibility event identifiers - -#define wxACC_EVENT_SYSTEM_SOUND 0x0001 -#define wxACC_EVENT_SYSTEM_ALERT 0x0002 -#define wxACC_EVENT_SYSTEM_FOREGROUND 0x0003 -#define wxACC_EVENT_SYSTEM_MENUSTART 0x0004 -#define wxACC_EVENT_SYSTEM_MENUEND 0x0005 -#define wxACC_EVENT_SYSTEM_MENUPOPUPSTART 0x0006 -#define wxACC_EVENT_SYSTEM_MENUPOPUPEND 0x0007 -#define wxACC_EVENT_SYSTEM_CAPTURESTART 0x0008 -#define wxACC_EVENT_SYSTEM_CAPTUREEND 0x0009 -#define wxACC_EVENT_SYSTEM_MOVESIZESTART 0x000A -#define wxACC_EVENT_SYSTEM_MOVESIZEEND 0x000B -#define wxACC_EVENT_SYSTEM_CONTEXTHELPSTART 0x000C -#define wxACC_EVENT_SYSTEM_CONTEXTHELPEND 0x000D -#define wxACC_EVENT_SYSTEM_DRAGDROPSTART 0x000E -#define wxACC_EVENT_SYSTEM_DRAGDROPEND 0x000F -#define wxACC_EVENT_SYSTEM_DIALOGSTART 0x0010 -#define wxACC_EVENT_SYSTEM_DIALOGEND 0x0011 -#define wxACC_EVENT_SYSTEM_SCROLLINGSTART 0x0012 -#define wxACC_EVENT_SYSTEM_SCROLLINGEND 0x0013 -#define wxACC_EVENT_SYSTEM_SWITCHSTART 0x0014 -#define wxACC_EVENT_SYSTEM_SWITCHEND 0x0015 -#define wxACC_EVENT_SYSTEM_MINIMIZESTART 0x0016 -#define wxACC_EVENT_SYSTEM_MINIMIZEEND 0x0017 -#define wxACC_EVENT_OBJECT_CREATE 0x8000 -#define wxACC_EVENT_OBJECT_DESTROY 0x8001 -#define wxACC_EVENT_OBJECT_SHOW 0x8002 -#define wxACC_EVENT_OBJECT_HIDE 0x8003 -#define wxACC_EVENT_OBJECT_REORDER 0x8004 -#define wxACC_EVENT_OBJECT_FOCUS 0x8005 -#define wxACC_EVENT_OBJECT_SELECTION 0x8006 -#define wxACC_EVENT_OBJECT_SELECTIONADD 0x8007 -#define wxACC_EVENT_OBJECT_SELECTIONREMOVE 0x8008 -#define wxACC_EVENT_OBJECT_SELECTIONWITHIN 0x8009 -#define wxACC_EVENT_OBJECT_STATECHANGE 0x800A -#define wxACC_EVENT_OBJECT_LOCATIONCHANGE 0x800B -#define wxACC_EVENT_OBJECT_NAMECHANGE 0x800C -#define wxACC_EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D -#define wxACC_EVENT_OBJECT_VALUECHANGE 0x800E -#define wxACC_EVENT_OBJECT_PARENTCHANGE 0x800F -#define wxACC_EVENT_OBJECT_HELPCHANGE 0x8010 -#define wxACC_EVENT_OBJECT_DEFACTIONCHANGE 0x8011 -#define wxACC_EVENT_OBJECT_ACCELERATORCHANGE 0x8012 - -// ---------------------------------------------------------------------------- -// wxAccessible -// All functions return an indication of success, failure, or not implemented. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxAccessible; -class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLIMPEXP_FWD_CORE wxPoint; -class WXDLLIMPEXP_FWD_CORE wxRect; -class WXDLLIMPEXP_CORE wxAccessibleBase : public wxObject -{ - wxDECLARE_NO_COPY_CLASS(wxAccessibleBase); - -public: - wxAccessibleBase(wxWindow* win): m_window(win) {} - virtual ~wxAccessibleBase() {} - -// Overridables - - // Can return either a child object, or an integer - // representing the child element, starting from 1. - // pt is in screen coordinates. - virtual wxAccStatus HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns the rectangle for this object (id = 0) or a child element (id > 0). - // rect is in screen coordinates. - virtual wxAccStatus GetLocation(wxRect& WXUNUSED(rect), int WXUNUSED(elementId)) - { return wxACC_NOT_IMPLEMENTED; } - - // Navigates from fromId to toId/toObject. - virtual wxAccStatus Navigate(wxNavDir WXUNUSED(navDir), int WXUNUSED(fromId), - int* WXUNUSED(toId), wxAccessible** WXUNUSED(toObject)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the name of the specified object. - virtual wxAccStatus GetName(int WXUNUSED(childId), wxString* WXUNUSED(name)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the number of children. - virtual wxAccStatus GetChildCount(int* WXUNUSED(childCount)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the specified child (starting from 1). - // If *child is NULL and return value is wxACC_OK, - // this means that the child is a simple element and - // not an accessible object. - virtual wxAccStatus GetChild(int WXUNUSED(childId), wxAccessible** WXUNUSED(child)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the parent, or NULL. - virtual wxAccStatus GetParent(wxAccessible** WXUNUSED(parent)) - { return wxACC_NOT_IMPLEMENTED; } - - // Performs the default action. childId is 0 (the action for this object) - // or > 0 (the action for a child). - // Return wxACC_NOT_SUPPORTED if there is no default action for this - // window (e.g. an edit control). - virtual wxAccStatus DoDefaultAction(int WXUNUSED(childId)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the default action for this object (0) or > 0 (the action for a child). - // Return wxACC_OK even if there is no action. actionName is the action, or the empty - // string if there is no action. - // The retrieved string describes the action that is performed on an object, - // not what the object does as a result. For example, a toolbar button that prints - // a document has a default action of "Press" rather than "Prints the current document." - virtual wxAccStatus GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns the description for this object or a child. - virtual wxAccStatus GetDescription(int WXUNUSED(childId), wxString* WXUNUSED(description)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns help text for this object or a child, similar to tooltip text. - virtual wxAccStatus GetHelpText(int WXUNUSED(childId), wxString* WXUNUSED(helpText)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns the keyboard shortcut for this object or child. - // Return e.g. ALT+K - virtual wxAccStatus GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns a role constant. - virtual wxAccStatus GetRole(int WXUNUSED(childId), wxAccRole* WXUNUSED(role)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns a state constant. - virtual wxAccStatus GetState(int WXUNUSED(childId), long* WXUNUSED(state)) - { return wxACC_NOT_IMPLEMENTED; } - - // Returns a localized string representing the value for the object - // or child. - virtual wxAccStatus GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue)) - { return wxACC_NOT_IMPLEMENTED; } - - // Selects the object or child. - virtual wxAccStatus Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags)) - { return wxACC_NOT_IMPLEMENTED; } - - // Gets the window with the keyboard focus. - // If childId is 0 and child is NULL, no object in - // this subhierarchy has the focus. - // If this object has the focus, child should be 'this'. - virtual wxAccStatus GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child)) - { return wxACC_NOT_IMPLEMENTED; } - -#if wxUSE_VARIANT - // Gets a variant representing the selected children - // of this object. - // Acceptable values: - // - a null variant (IsNull() returns TRUE) - // - a list variant (GetType() == wxT("list")) - // - an integer representing the selected child element, - // or 0 if this object is selected (GetType() == wxT("long")) - // - a "void*" pointer to a wxAccessible child object - virtual wxAccStatus GetSelections(wxVariant* WXUNUSED(selections)) - { return wxACC_NOT_IMPLEMENTED; } -#endif // wxUSE_VARIANT - -// Accessors - - // Returns the window associated with this object. - - wxWindow* GetWindow() { return m_window; } - - // Sets the window associated with this object. - - void SetWindow(wxWindow* window) { m_window = window; } - -// Operations - - // Each platform's implementation must define this - // static void NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType, - // int objectId); - -private: - -// Data members - - wxWindow* m_window; -}; - - -// ---------------------------------------------------------------------------- -// now include the declaration of the real class -// ---------------------------------------------------------------------------- - -#if defined(__WXMSW__) - #include "wx/msw/ole/access.h" -#endif - -#endif // wxUSE_ACCESSIBILITY - -#endif // _WX_ACCESSBASE_H_ - diff --git a/Source/3rd Party/wx/include/wx/affinematrix2d.h b/Source/3rd Party/wx/include/wx/affinematrix2d.h deleted file mode 100644 index 28055f8d3..000000000 --- a/Source/3rd Party/wx/include/wx/affinematrix2d.h +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/affinematrix2d.h -// Purpose: wxAffineMatrix2D class. -// Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart -// Created: 2011-04-05 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_AFFINEMATRIX2D_H_ -#define _WX_AFFINEMATRIX2D_H_ - -#include "wx/defs.h" - -#if wxUSE_GEOMETRY - -#include "wx/affinematrix2dbase.h" - -// A simple implementation of wxAffineMatrix2DBase interface done entirely in -// wxWidgets. -class WXDLLIMPEXP_CORE wxAffineMatrix2D : public wxAffineMatrix2DBase -{ -public: - wxAffineMatrix2D() : m_11(1), m_12(0), - m_21(0), m_22(1), - m_tx(0), m_ty(0) - { - } - - // Implement base class pure virtual methods. - virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr); - virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const; - virtual void Concat(const wxAffineMatrix2DBase& t); - virtual bool Invert(); - virtual bool IsIdentity() const; - virtual bool IsEqual(const wxAffineMatrix2DBase& t) const; - virtual void Translate(wxDouble dx, wxDouble dy); - virtual void Scale(wxDouble xScale, wxDouble yScale); - virtual void Rotate(wxDouble cRadians); - -protected: - virtual wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const; - virtual wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const; - -private: - wxDouble m_11, m_12, m_21, m_22, m_tx, m_ty; -}; - -#endif // wxUSE_GEOMETRY - -#endif // _WX_AFFINEMATRIX2D_H_ diff --git a/Source/3rd Party/wx/include/wx/affinematrix2dbase.h b/Source/3rd Party/wx/include/wx/affinematrix2dbase.h deleted file mode 100644 index 94b1955aa..000000000 --- a/Source/3rd Party/wx/include/wx/affinematrix2dbase.h +++ /dev/null @@ -1,127 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/affinematrix2dbase.h -// Purpose: Common interface for 2D transformation matrices. -// Author: Catalin Raceanu -// Created: 2011-04-06 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_AFFINEMATRIX2DBASE_H_ -#define _WX_AFFINEMATRIX2DBASE_H_ - -#include "wx/defs.h" - -#if wxUSE_GEOMETRY - -#include "wx/geometry.h" - -struct wxMatrix2D -{ - wxMatrix2D(wxDouble v11 = 1, - wxDouble v12 = 0, - wxDouble v21 = 0, - wxDouble v22 = 1) - { - m_11 = v11; m_12 = v12; - m_21 = v21; m_22 = v22; - } - - wxDouble m_11, m_12, m_21, m_22; -}; - -// A 2x3 matrix representing an affine 2D transformation. -// -// This is an abstract base class implemented by wxAffineMatrix2D only so far, -// but in the future we also plan to derive wxGraphicsMatrix from it (it should -// also be documented then as currently only wxAffineMatrix2D itself is). -class WXDLLIMPEXP_CORE wxAffineMatrix2DBase -{ -public: - wxAffineMatrix2DBase() {} - virtual ~wxAffineMatrix2DBase() {} - - // sets the matrix to the respective values - virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0; - - // gets the component valuess of the matrix - virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const = 0; - - // concatenates the matrix - virtual void Concat(const wxAffineMatrix2DBase& t) = 0; - - // makes this the inverse matrix - virtual bool Invert() = 0; - - // return true if this is the identity matrix - virtual bool IsIdentity() const = 0; - - // returns true if the elements of the transformation matrix are equal ? - virtual bool IsEqual(const wxAffineMatrix2DBase& t) const = 0; - bool operator==(const wxAffineMatrix2DBase& t) const { return IsEqual(t); } - bool operator!=(const wxAffineMatrix2DBase& t) const { return !IsEqual(t); } - - - // - // transformations - // - - // add the translation to this matrix - virtual void Translate(wxDouble dx, wxDouble dy) = 0; - - // add the scale to this matrix - virtual void Scale(wxDouble xScale, wxDouble yScale) = 0; - - // add the rotation to this matrix (counter clockwise, radians) - virtual void Rotate(wxDouble ccRadians) = 0; - - // add mirroring to this matrix - void Mirror(int direction = wxHORIZONTAL) - { - wxDouble x = (direction & wxHORIZONTAL) ? -1 : 1; - wxDouble y = (direction & wxVERTICAL) ? -1 : 1; - Scale(x, y); - } - - - // applies that matrix to the point - wxPoint2DDouble TransformPoint(const wxPoint2DDouble& src) const - { - return DoTransformPoint(src); - } - - void TransformPoint(wxDouble* x, wxDouble* y) const - { - wxCHECK_RET( x && y, "Can't be NULL" ); - - const wxPoint2DDouble dst = DoTransformPoint(wxPoint2DDouble(*x, *y)); - *x = dst.m_x; - *y = dst.m_y; - } - - // applies the matrix except for translations - wxPoint2DDouble TransformDistance(const wxPoint2DDouble& src) const - { - return DoTransformDistance(src); - } - - void TransformDistance(wxDouble* dx, wxDouble* dy) const - { - wxCHECK_RET( dx && dy, "Can't be NULL" ); - - const wxPoint2DDouble - dst = DoTransformDistance(wxPoint2DDouble(*dx, *dy)); - *dx = dst.m_x; - *dy = dst.m_y; - } - -protected: - virtual - wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const = 0; - virtual - wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const = 0; -}; - -#endif // wxUSE_GEOMETRY - -#endif // _WX_AFFINEMATRIX2DBASE_H_ diff --git a/Source/3rd Party/wx/include/wx/afterstd.h b/Source/3rd Party/wx/include/wx/afterstd.h index 48b767652..78d3a7009 100644 --- a/Source/3rd Party/wx/include/wx/afterstd.h +++ b/Source/3rd Party/wx/include/wx/afterstd.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/afterstd.h +// Name: include/wx/afterstd.h // Purpose: #include after STL headers // Author: Vadim Zeitlin // Modified by: // Created: 07/07/03 +// RCS-ID: $Id: afterstd.h 61871 2009-09-09 22:29:51Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ See the comments in beforestd.h. */ -#if defined(__WINDOWS__) +#if defined(__WXMSW__) #include "wx/msw/winundef.h" #endif @@ -20,6 +21,13 @@ #if defined(__VISUALC__) && __VISUALC__ <= 1201 // MSVC 5 does not have this #if _MSC_VER > 1100 + // don't restore this one for VC6, it gives it in each try/catch which is a + // bit annoying to say the least + #if _MSC_VER >= 0x1300 + // unreachable code + #pragma warning(default:4702) + #endif // VC++ >= 7 + #pragma warning(pop) #else // 'expression' : signed/unsigned mismatch @@ -38,7 +46,26 @@ #endif #endif -// see beforestd.h for explanation -#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) - #pragma GCC visibility pop -#endif +/* + Redefine _T if we undefined it in wx/beforestd.h (see comment there about + why do we do it) and if we need it (we always do when building wx itself + and might also need when compiling the user code but this must be indicated + by the special wxNEEDS__T macro) + */ +#if defined(__SUNPRO_CC) || defined(__SUNPRO_C) + #if defined(WXBUILDING) || defined(wxNEEDS_T) + /* + Undefine _T in case it was defined in the standard header. + */ + #undef _T + + /* + And define it again in the same way as it's done in wx/wxchar.h. + */ + #if wxUSE_UNICODE + #define _T(x) wxCONCAT_HELPER(L, x) + #else /* !Unicode */ + #define _T(x) x + #endif /* Unicode/!Unicode */ + #endif /* we need _T() to be defined */ +#endif /* defined(__SUNPRO_CC) || defined(__SUNPRO_C) */ diff --git a/Source/3rd Party/wx/include/wx/anidecod.h b/Source/3rd Party/wx/include/wx/anidecod.h index f5eb6fbf0..6e3847614 100644 --- a/Source/3rd Party/wx/include/wx/anidecod.h +++ b/Source/3rd Party/wx/include/wx/anidecod.h @@ -2,6 +2,7 @@ // Name: wx/anidecod.h // Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation // Author: Francesco Montorsi +// CVS-ID: $Id: anidecod.h 45563 2007-04-21 18:17:50Z VZ $ // Copyright: (c) 2006 Francesco Montorsi // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #include "wx/defs.h" -#if wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF) +#if wxUSE_STREAMS && wxUSE_ICO_CUR #include "wx/stream.h" #include "wx/image.h" @@ -19,7 +20,7 @@ #include "wx/dynarray.h" -class /*WXDLLIMPEXP_CORE*/ wxANIFrameInfo; // private implementation detail +class /*WXDLLEXPORT*/ wxANIFrameInfo; WX_DECLARE_EXPORTED_OBJARRAY(wxANIFrameInfo, wxANIFrameInfoArray); WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray); @@ -28,7 +29,7 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray); // wxANIDecoder class // -------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxANIDecoder : public wxAnimationDecoder +class WXDLLEXPORT wxANIDecoder : public wxAnimationDecoder { public: // constructor, destructor, etc. @@ -43,7 +44,7 @@ public: virtual wxColour GetTransparentColour(unsigned int frame) const; // implementation of wxAnimationDecoder's pure virtuals - + virtual bool CanRead( wxInputStream& stream ) const; virtual bool Load( wxInputStream& stream ); bool ConvertToImage(unsigned int frame, wxImage *image) const; @@ -54,10 +55,6 @@ public: { return wxANIMATION_TYPE_ANI; } private: - // wxAnimationDecoder pure virtual: - virtual bool DoCanRead( wxInputStream& stream ) const; - // modifies current stream position (see wxAnimationDecoder::CanRead) - // frames stored as wxImage(s): ANI files are meant to be used mostly for animated // cursors and thus they do not use any optimization to encode differences between // two frames: they are just a list of images to display sequentially. @@ -71,10 +68,10 @@ private: static wxCURHandler sm_handler; - wxDECLARE_NO_COPY_CLASS(wxANIDecoder); + DECLARE_NO_COPY_CLASS(wxANIDecoder) }; -#endif // wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF) +#endif // wxUSE_STREAM && wxUSE_ICO_CUR #endif // _WX_ANIDECOD_H diff --git a/Source/3rd Party/wx/include/wx/animate.h b/Source/3rd Party/wx/include/wx/animate.h deleted file mode 100644 index 6243fb456..000000000 --- a/Source/3rd Party/wx/include/wx/animate.h +++ /dev/null @@ -1,125 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/animate.h -// Purpose: wxAnimation and wxAnimationCtrl -// Author: Julian Smart and Guillermo Rodriguez Garcia -// Modified by: Francesco Montorsi -// Created: 13/8/99 -// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ANIMATE_H_ -#define _WX_ANIMATE_H_ - -#include "wx/defs.h" - -#if wxUSE_ANIMATIONCTRL - -#include "wx/animdecod.h" -#include "wx/control.h" -#include "wx/timer.h" -#include "wx/bitmap.h" - -class WXDLLIMPEXP_FWD_ADV wxAnimation; - -extern WXDLLIMPEXP_DATA_ADV(wxAnimation) wxNullAnimation; -extern WXDLLIMPEXP_DATA_ADV(const char) wxAnimationCtrlNameStr[]; - - -// ---------------------------------------------------------------------------- -// wxAnimationBase -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxAnimationBase : public wxObject -{ -public: - wxAnimationBase() {} - - virtual bool IsOk() const = 0; - - // can be -1 - virtual int GetDelay(unsigned int frame) const = 0; - - virtual unsigned int GetFrameCount() const = 0; - virtual wxImage GetFrame(unsigned int frame) const = 0; - virtual wxSize GetSize() const = 0; - - virtual bool LoadFile(const wxString& name, - wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; - virtual bool Load(wxInputStream& stream, - wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; - -protected: - DECLARE_ABSTRACT_CLASS(wxAnimationBase) -}; - - - -// ---------------------------------------------------------------------------- -// wxAnimationCtrlBase -// ---------------------------------------------------------------------------- - -// do not autoresize to the animation's size when SetAnimation() is called -#define wxAC_NO_AUTORESIZE (0x0010) - -// default style does not include wxAC_NO_AUTORESIZE, that is, the control -// auto-resizes by default to fit the new animation when SetAnimation() is called -#define wxAC_DEFAULT_STYLE (wxBORDER_NONE) - -class WXDLLIMPEXP_ADV wxAnimationCtrlBase : public wxControl -{ -public: - wxAnimationCtrlBase() { } - - // public API - virtual bool LoadFile(const wxString& filename, - wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; - virtual bool Load(wxInputStream& stream, - wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; - - virtual void SetAnimation(const wxAnimation &anim) = 0; - virtual wxAnimation GetAnimation() const = 0; - - virtual bool Play() = 0; - virtual void Stop() = 0; - - virtual bool IsPlaying() const = 0; - - virtual void SetInactiveBitmap(const wxBitmap &bmp); - - // always return the original bitmap set in this control - wxBitmap GetInactiveBitmap() const - { return m_bmpStatic; } - -protected: - // the inactive bitmap as it was set by the user - wxBitmap m_bmpStatic; - - // the inactive bitmap currently shown in the control - // (may differ in the size from m_bmpStatic) - wxBitmap m_bmpStaticReal; - - // updates m_bmpStaticReal from m_bmpStatic if needed - virtual void UpdateStaticImage(); - - // called by SetInactiveBitmap - virtual void DisplayStaticImage() = 0; - -private: - DECLARE_ABSTRACT_CLASS(wxAnimationCtrlBase) -}; - - -// ---------------------------------------------------------------------------- -// include the platform-specific version of the wxAnimationCtrl class -// ---------------------------------------------------------------------------- - -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) - #include "wx/gtk/animate.h" -#else - #include "wx/generic/animate.h" -#endif - -#endif // wxUSE_ANIMATIONCTRL - -#endif // _WX_ANIMATE_H_ diff --git a/Source/3rd Party/wx/include/wx/animdecod.h b/Source/3rd Party/wx/include/wx/animdecod.h index 39c31d323..a1cb15eaa 100644 --- a/Source/3rd Party/wx/include/wx/animdecod.h +++ b/Source/3rd Party/wx/include/wx/animdecod.h @@ -2,6 +2,7 @@ // Name: wx/animdecod.h // Purpose: wxAnimationDecoder // Author: Francesco Montorsi +// CVS-ID: $Id: animdecod.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 2006 Francesco Montorsi // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,9 +16,8 @@ #include "wx/colour.h" #include "wx/gdicmn.h" -#include "wx/log.h" -#include "wx/stream.h" +class WXDLLIMPEXP_FWD_BASE wxInputStream; class WXDLLIMPEXP_FWD_CORE wxImage; /* @@ -30,15 +30,15 @@ class WXDLLIMPEXP_FWD_CORE wxImage; wxAnimationDecoders always load an input stream using some optimized format to store it which is format-depedent. This allows to store a (possibly big) animation using a format which is a good compromise between required memory - and time required to blit it on the screen. + and time required to blit in on the screen. - 2) wxAnimationDecoders contain the animation data in some internal variable. + 2) wxAnimationDecoders contain the animation data in some internal var. That's why they derive from wxObjectRefData: they are data which can be shared. 3) wxAnimationDecoders can be used by a wxImageHandler to retrieve a frame in wxImage format; the viceversa cannot be done. - 4) wxAnimationDecoders are decoders only, thus they do not support save features. + 4) wxAnimationDecoders are decoders only, thus do not support save features. 5) wxAnimationDecoders are directly used by wxAnimation (generic implementation) as wxObjectRefData while they need to be 'wrapped' by a wxImageHandler for @@ -61,11 +61,11 @@ enum wxAnimationDisposal // Do not dispose. The graphic is to be left in place. wxANIM_DONOTREMOVE = 0, - // Restore to background color. The area used by the graphic must be + // Restore to background color. The area used by the graphic must be // restored to the background color. wxANIM_TOBACKGROUND = 1, - // Restore to previous. The decoder is required to restore the area + // Restore to previous. The decoder is required to restore the area // overwritten by the graphic with what was there prior to rendering the graphic. wxANIM_TOPREVIOUS = 2 }; @@ -84,37 +84,19 @@ enum wxAnimationType // wxAnimationDecoder class // -------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxAnimationDecoder : public wxObjectRefData +class WXDLLEXPORT wxAnimationDecoder : public wxObjectRefData { public: wxAnimationDecoder() { + m_background = wxNullColour; m_nFrames = 0; } + virtual ~wxAnimationDecoder() { } + virtual bool Load( wxInputStream& stream ) = 0; - - bool CanRead( wxInputStream& stream ) const - { - // NOTE: this code is the same of wxImageHandler::CallDoCanRead - - if ( !stream.IsSeekable() ) - return false; // can't test unseekable stream - - wxFileOffset posOld = stream.TellI(); - bool ok = DoCanRead(stream); - - // restore the old position to be able to test other formats and so on - if ( stream.SeekI(posOld) == wxInvalidOffset ) - { - wxLogDebug(wxT("Failed to rewind the stream in wxAnimationDecoder!")); - - // reading would fail anyhow as we're not at the right position - return false; - } - - return ok; - } + virtual bool CanRead( wxInputStream& stream ) const = 0; virtual wxAnimationDecoder *Clone() const = 0; virtual wxAnimationType GetType() const = 0; @@ -150,12 +132,6 @@ public: unsigned int GetFrameCount() const { return m_nFrames; } protected: - // checks the signature of the data in the given stream and returns true if it - // appears to be a valid animation format recognized by the animation decoder; - // this function should modify the stream current position without taking care - // of restoring it since CanRead() will do it. - virtual bool DoCanRead(wxInputStream& stream) const = 0; - wxSize m_szAnimation; unsigned int m_nFrames; @@ -164,7 +140,7 @@ protected: wxColour m_background; }; -#endif // wxUSE_STREAMS +#endif // wxUSE_STREAM #endif // _WX_ANIMDECOD_H diff --git a/Source/3rd Party/wx/include/wx/any.h b/Source/3rd Party/wx/include/wx/any.h deleted file mode 100644 index c2cd7a79f..000000000 --- a/Source/3rd Party/wx/include/wx/any.h +++ /dev/null @@ -1,1113 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/any.h -// Purpose: wxAny class -// Author: Jaakko Salli -// Modified by: -// Created: 07/05/2009 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ANY_H_ -#define _WX_ANY_H_ - -#include "wx/defs.h" - -#if wxUSE_ANY - -#include // for placement new -#include "wx/string.h" -#include "wx/meta/if.h" -#include "wx/typeinfo.h" -#include "wx/list.h" - -// Size of the wxAny value buffer. -enum -{ - WX_ANY_VALUE_BUFFER_SIZE = 16 -}; - -union wxAnyValueBuffer -{ - union Alignment - { - #if wxHAS_INT64 - wxInt64 m_int64; - #endif - long double m_longDouble; - void ( *m_funcPtr )(void); - void ( wxAnyValueBuffer::*m_mFuncPtr )(void); - } m_alignment; - - void* m_ptr; - wxByte m_buffer[WX_ANY_VALUE_BUFFER_SIZE]; -}; - -// -// wxAnyValueType is base class for value type functionality for C++ data -// types used with wxAny. Usually the default template (wxAnyValueTypeImpl<>) -// will create a satisfactory wxAnyValueType implementation for a data type. -// -class WXDLLIMPEXP_BASE wxAnyValueType -{ - WX_DECLARE_ABSTRACT_TYPEINFO(wxAnyValueType) -public: - /** - Default constructor. - */ - wxAnyValueType() - { - } - - /** - Destructor. - */ - virtual ~wxAnyValueType() - { - } - - /** - This function is used for internal type matching. - */ - virtual bool IsSameType(const wxAnyValueType* otherType) const = 0; - - /** - This function is called every time the data in wxAny - buffer needs to be freed. - */ - virtual void DeleteValue(wxAnyValueBuffer& buf) const = 0; - - /** - Implement this for buffer-to-buffer copy. - - @param src - This is the source data buffer. - - @param dst - This is the destination data buffer that is in either - uninitialized or freed state. - */ - virtual void CopyBuffer(const wxAnyValueBuffer& src, - wxAnyValueBuffer& dst) const = 0; - - /** - Convert value into buffer of different type. Return false if - not possible. - */ - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const = 0; - - /** - Use this template function for checking if wxAnyValueType represents - a specific C++ data type. - - @remarks This template function does not work on some older compilers - (such as Visual C++ 6.0). For full compiler compatibility - please use wxANY_VALUE_TYPE_CHECK_TYPE(valueTypePtr, T) macro - instead. - - @see wxAny::CheckType() - */ - // FIXME-VC6: remove this hack when VC6 is no longer supported - template - bool CheckType(T* reserved = NULL) const; - -#if wxUSE_EXTENDED_RTTI - virtual const wxTypeInfo* GetTypeInfo() const = 0; -#endif -private: -}; - - -// -// We need to allocate wxAnyValueType instances in heap, and need to use -// scoped ptr to properly deallocate them in dynamic library use cases. -// Here we have a minimal specialized scoped ptr implementation to deal -// with various compiler-specific problems with template class' static -// member variable of template type with explicit constructor which -// is initialized in global scope. -// -class wxAnyValueTypeScopedPtr -{ -public: - wxAnyValueTypeScopedPtr(wxAnyValueType* ptr) : m_ptr(ptr) { } - ~wxAnyValueTypeScopedPtr() { delete m_ptr; } - wxAnyValueType* get() const { return m_ptr; } -private: - wxAnyValueType* m_ptr; -}; - - -// -// This method of checking the type is compatible with VC6 -#define wxANY_VALUE_TYPE_CHECK_TYPE(valueTypePtr, T) \ - wxAnyValueTypeImpl::IsSameClass(valueTypePtr) - - -/** - Helper macro for defining user value types. - - Even though C++ RTTI would be fully available to use, we'd have to to - facilitate sub-type system which allows, for instance, wxAny with - signed short '15' to be treated equal to wxAny with signed long long '15'. - Having sm_instance is important here. - - NB: We really need to have wxAnyValueType instances allocated - in heap. They are stored as static template member variables, - and with them we just can't be too careful (eg. not allocating - them in heap broke the type identification in GCC). -*/ -#define WX_DECLARE_ANY_VALUE_TYPE(CLS) \ - friend class wxAny; \ - WX_DECLARE_TYPEINFO_INLINE(CLS) \ -public: \ - static bool IsSameClass(const wxAnyValueType* otherType) \ - { \ - return wxTypeId(*sm_instance.get()) == wxTypeId(*otherType); \ - } \ - virtual bool IsSameType(const wxAnyValueType* otherType) const \ - { \ - return IsSameClass(otherType); \ - } \ -private: \ - static wxAnyValueTypeScopedPtr sm_instance; \ -public: \ - static wxAnyValueType* GetInstance() \ - { \ - return sm_instance.get(); \ - } - - -#define WX_IMPLEMENT_ANY_VALUE_TYPE(CLS) \ -wxAnyValueTypeScopedPtr CLS::sm_instance(new CLS()); - - -#ifdef __VISUALC6__ - // "non dll-interface class 'xxx' used as base interface - #pragma warning (push) - #pragma warning (disable:4275) -#endif - -/** - Following are helper classes for the wxAnyValueTypeImplBase. -*/ -namespace wxPrivate -{ - -template -class wxAnyValueTypeOpsInplace -{ -public: - static void DeleteValue(wxAnyValueBuffer& buf) - { - T* value = reinterpret_cast(&buf.m_buffer[0]); - value->~T(); - - // Some compiler may given 'unused variable' warnings without this - wxUnusedVar(value); - } - - static void SetValue(const T& value, - wxAnyValueBuffer& buf) - { - // Use placement new - void* const place = buf.m_buffer; - ::new(place) T(value); - } - - static const T& GetValue(const wxAnyValueBuffer& buf) - { - // Breaking this code into two lines should suppress - // GCC's 'type-punned pointer will break strict-aliasing rules' - // warning. - const T* value = reinterpret_cast(&buf.m_buffer[0]); - return *value; - } -}; - - -template -class wxAnyValueTypeOpsGeneric -{ -public: - template - class DataHolder - { - public: - DataHolder(const T2& value) - { - m_value = value; - } - virtual ~DataHolder() { } - - T2 m_value; - private: - wxDECLARE_NO_COPY_CLASS(DataHolder); - }; - - static void DeleteValue(wxAnyValueBuffer& buf) - { - DataHolder* holder = static_cast*>(buf.m_ptr); - delete holder; - } - - static void SetValue(const T& value, - wxAnyValueBuffer& buf) - { - DataHolder* holder = new DataHolder(value); - buf.m_ptr = holder; - } - - static const T& GetValue(const wxAnyValueBuffer& buf) - { - DataHolder* holder = static_cast*>(buf.m_ptr); - return holder->m_value; - } -}; - -} // namespace wxPrivate - - -/** - Intermediate template for the generic value type implementation. - We can derive from this same value type for multiple actual types - (for instance, we can have wxAnyValueTypeImplInt for all signed - integer types), and also easily implement specialized templates - with specific dynamic type conversion. -*/ -template -class wxAnyValueTypeImplBase : public wxAnyValueType -{ - typedef typename wxIf< sizeof(T) <= WX_ANY_VALUE_BUFFER_SIZE, - wxPrivate::wxAnyValueTypeOpsInplace, - wxPrivate::wxAnyValueTypeOpsGeneric >::value - Ops; - -public: - wxAnyValueTypeImplBase() : wxAnyValueType() { } - virtual ~wxAnyValueTypeImplBase() { } - - virtual void DeleteValue(wxAnyValueBuffer& buf) const - { - Ops::DeleteValue(buf); - } - - virtual void CopyBuffer(const wxAnyValueBuffer& src, - wxAnyValueBuffer& dst) const - { - Ops::SetValue(Ops::GetValue(src), dst); - } - - /** - It is important to reimplement this in any specialized template - classes that inherit from wxAnyValueTypeImplBase. - */ - static void SetValue(const T& value, - wxAnyValueBuffer& buf) - { - Ops::SetValue(value, buf); - } - - /** - It is important to reimplement this in any specialized template - classes that inherit from wxAnyValueTypeImplBase. - */ - static const T& GetValue(const wxAnyValueBuffer& buf) - { - return Ops::GetValue(buf); - } -#if wxUSE_EXTENDED_RTTI - virtual const wxTypeInfo* GetTypeInfo() const - { - return wxGetTypeInfo((T*)NULL); - } -#endif -}; - - -/* - Generic value type template. Note that bulk of the implementation - resides in wxAnyValueTypeImplBase. -*/ -template -class wxAnyValueTypeImpl : public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -public: - wxAnyValueTypeImpl() : wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImpl() { } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const - { - wxUnusedVar(src); - wxUnusedVar(dstType); - wxUnusedVar(dst); - return false; - } -}; - -template -wxAnyValueTypeScopedPtr wxAnyValueTypeImpl::sm_instance = new wxAnyValueTypeImpl(); - - -// -// Helper macro for using same base value type implementation for multiple -// actual C++ data types. -// -#define _WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ -template<> \ -class wxAnyValueTypeImpl : public wxAnyValueTypeImpl##CLSTYPE \ -{ \ - typedef wxAnyBase##CLSTYPE##Type UseDataType; \ -public: \ - wxAnyValueTypeImpl() : wxAnyValueTypeImpl##CLSTYPE() { } \ - virtual ~wxAnyValueTypeImpl() { } \ - static void SetValue(const T& value, wxAnyValueBuffer& buf) \ - { \ - void* voidPtr = reinterpret_cast(&buf.m_buffer[0]); \ - UseDataType* dptr = reinterpret_cast(voidPtr); \ - *dptr = static_cast(value); \ - } \ - static T GetValue(const wxAnyValueBuffer& buf) \ - { \ - const void* voidPtr = \ - reinterpret_cast(&buf.m_buffer[0]); \ - const UseDataType* sptr = \ - reinterpret_cast(voidPtr); \ - return static_cast(*sptr); \ - } - -#if wxUSE_EXTENDED_RTTI -#define WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ -_WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE)\ - virtual const wxTypeInfo* GetTypeInfo() const \ - { \ - return wxGetTypeInfo((T*)NULL); \ - } \ -}; -#else -#define WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ -_WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE)\ -}; -#endif - -// -// Integer value types -// - -#ifdef wxLongLong_t - typedef wxLongLong_t wxAnyBaseIntType; - typedef wxULongLong_t wxAnyBaseUintType; -#else - typedef long wxAnyBaseIntType; - typedef unsigned long wxAnyBaseUintType; -#endif - - -class WXDLLIMPEXP_BASE wxAnyValueTypeImplInt : - public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImplInt) -public: - wxAnyValueTypeImplInt() : - wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImplInt() { } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const; -}; - - -class WXDLLIMPEXP_BASE wxAnyValueTypeImplUint : - public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImplUint) -public: - wxAnyValueTypeImplUint() : - wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImplUint() { } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const; -}; - - -WX_ANY_DEFINE_SUB_TYPE(signed long, Int) -WX_ANY_DEFINE_SUB_TYPE(signed int, Int) -WX_ANY_DEFINE_SUB_TYPE(signed short, Int) -WX_ANY_DEFINE_SUB_TYPE(signed char, Int) -#ifdef wxLongLong_t -WX_ANY_DEFINE_SUB_TYPE(wxLongLong_t, Int) -#endif - -WX_ANY_DEFINE_SUB_TYPE(unsigned long, Uint) -WX_ANY_DEFINE_SUB_TYPE(unsigned int, Uint) -WX_ANY_DEFINE_SUB_TYPE(unsigned short, Uint) -WX_ANY_DEFINE_SUB_TYPE(unsigned char, Uint) -#ifdef wxLongLong_t -WX_ANY_DEFINE_SUB_TYPE(wxULongLong_t, Uint) -#endif - - -// -// This macro is used in header, but then in source file we must have: -// WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl##TYPENAME) -// -#define _WX_ANY_DEFINE_CONVERTIBLE_TYPE(T, TYPENAME, CONVFUNC, GV) \ -class WXDLLIMPEXP_BASE wxAnyValueTypeImpl##TYPENAME : \ - public wxAnyValueTypeImplBase \ -{ \ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl##TYPENAME) \ -public: \ - wxAnyValueTypeImpl##TYPENAME() : \ - wxAnyValueTypeImplBase() { } \ - virtual ~wxAnyValueTypeImpl##TYPENAME() { } \ - virtual bool ConvertValue(const wxAnyValueBuffer& src, \ - wxAnyValueType* dstType, \ - wxAnyValueBuffer& dst) const \ - { \ - GV value = GetValue(src); \ - return CONVFUNC(value, dstType, dst); \ - } \ -}; \ -template<> \ -class wxAnyValueTypeImpl : public wxAnyValueTypeImpl##TYPENAME \ -{ \ -public: \ - wxAnyValueTypeImpl() : wxAnyValueTypeImpl##TYPENAME() { } \ - virtual ~wxAnyValueTypeImpl() { } \ -}; - -#define WX_ANY_DEFINE_CONVERTIBLE_TYPE(T, TYPENAME, CONVFUNC, BT) \ -_WX_ANY_DEFINE_CONVERTIBLE_TYPE(T, TYPENAME, CONVFUNC, BT) \ - -#define WX_ANY_DEFINE_CONVERTIBLE_TYPE_BASE(T, TYPENAME, CONVFUNC) \ -_WX_ANY_DEFINE_CONVERTIBLE_TYPE(T, TYPENAME, \ - CONVFUNC, const T&) \ - -// -// String value type -// - -// Convert wxString to destination wxAny value type -extern WXDLLIMPEXP_BASE bool wxAnyConvertString(const wxString& value, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst); - -WX_ANY_DEFINE_CONVERTIBLE_TYPE_BASE(wxString, wxString, wxAnyConvertString) -WX_ANY_DEFINE_CONVERTIBLE_TYPE(const char*, ConstCharPtr, - wxAnyConvertString, wxString) -WX_ANY_DEFINE_CONVERTIBLE_TYPE(const wchar_t*, ConstWchar_tPtr, - wxAnyConvertString, wxString) - -// -// Bool value type -// -template<> -class WXDLLIMPEXP_BASE wxAnyValueTypeImpl : - public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -public: - wxAnyValueTypeImpl() : - wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImpl() { } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const; -}; - -// -// Floating point value type -// -class WXDLLIMPEXP_BASE wxAnyValueTypeImplDouble : - public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble) -public: - wxAnyValueTypeImplDouble() : - wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImplDouble() { } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const; -}; - -// WX_ANY_DEFINE_SUB_TYPE requires this -typedef double wxAnyBaseDoubleType; - -WX_ANY_DEFINE_SUB_TYPE(float, Double) -WX_ANY_DEFINE_SUB_TYPE(double, Double) - - -// -// Defines a dummy wxAnyValueTypeImpl<> with given export -// declaration. This is needed if a class is used with -// wxAny in both user shared library and application. -// -#define wxDECLARE_ANY_TYPE(CLS, DECL) \ -template<> \ -class DECL wxAnyValueTypeImpl : \ - public wxAnyValueTypeImplBase \ -{ \ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl) \ -public: \ - wxAnyValueTypeImpl() : \ - wxAnyValueTypeImplBase() { } \ - virtual ~wxAnyValueTypeImpl() { } \ - \ - virtual bool ConvertValue(const wxAnyValueBuffer& src, \ - wxAnyValueType* dstType, \ - wxAnyValueBuffer& dst) const \ - { \ - wxUnusedVar(src); \ - wxUnusedVar(dstType); \ - wxUnusedVar(dst); \ - return false; \ - } \ -}; - - -// Make sure some of wx's own types get the right wxAnyValueType export -// (this is needed only for types that are referred to from wxBase. -// currently we may not use any of these types from there, but let's -// use the macro on at least one to make sure it compiles since we can't -// really test it properly in unit tests since a separate DLL would -// be needed). -#if wxUSE_DATETIME - #include "wx/datetime.h" - wxDECLARE_ANY_TYPE(wxDateTime, WXDLLIMPEXP_BASE) -#endif - -//#include "wx/object.h" -//wxDECLARE_ANY_TYPE(wxObject*, WXDLLIMPEXP_BASE) - -//#include "wx/arrstr.h" -//wxDECLARE_ANY_TYPE(wxArrayString, WXDLLIMPEXP_BASE) - - -#if wxUSE_VARIANT - -class WXDLLIMPEXP_FWD_BASE wxAnyToVariantRegistration; - -// Because of header inter-dependencies, cannot include this earlier -#include "wx/variant.h" - -// -// wxVariantData* data type implementation. For cases when appropriate -// wxAny<->wxVariant conversion code is missing. -// - -class WXDLLIMPEXP_BASE wxAnyValueTypeImplVariantData : - public wxAnyValueTypeImplBase -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImplVariantData) -public: - wxAnyValueTypeImplVariantData() : - wxAnyValueTypeImplBase() { } - virtual ~wxAnyValueTypeImplVariantData() { } - - virtual void DeleteValue(wxAnyValueBuffer& buf) const - { - wxVariantData* data = static_cast(buf.m_ptr); - if ( data ) - data->DecRef(); - } - - virtual void CopyBuffer(const wxAnyValueBuffer& src, - wxAnyValueBuffer& dst) const - { - wxVariantData* data = static_cast(src.m_ptr); - if ( data ) - data->IncRef(); - dst.m_ptr = data; - } - - static void SetValue(wxVariantData* value, - wxAnyValueBuffer& buf) - { - value->IncRef(); - buf.m_ptr = value; - } - - static wxVariantData* GetValue(const wxAnyValueBuffer& buf) - { - return static_cast(buf.m_ptr); - } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const - { - wxUnusedVar(src); - wxUnusedVar(dstType); - wxUnusedVar(dst); - return false; - } -}; - -template<> -class wxAnyValueTypeImpl : - public wxAnyValueTypeImplVariantData -{ -public: - wxAnyValueTypeImpl() : wxAnyValueTypeImplVariantData() { } - virtual ~wxAnyValueTypeImpl() { } -}; - -#endif // wxUSE_VARIANT - -#ifdef __VISUALC6__ - // Re-enable useless VC6 warnings - #pragma warning (pop) -#endif - - -/* - Let's define a discrete Null value so we don't have to really - ever check if wxAny.m_type pointer is NULL or not. This is an - optimization, mostly. Implementation of this value type is - "hidden" in the source file. -*/ -extern WXDLLIMPEXP_DATA_BASE(wxAnyValueType*) wxAnyNullValueType; - - -// -// We need to implement custom signed/unsigned int equals operators -// for signed/unsigned (eg. wxAny(128UL) == 128L) comparisons to work. -#define WXANY_IMPLEMENT_INT_EQ_OP(TS, TUS) \ -bool operator==(TS value) const \ -{ \ - if ( wxAnyValueTypeImpl::IsSameClass(m_type) ) \ - return (value == static_cast \ - (wxAnyValueTypeImpl::GetValue(m_buffer))); \ - if ( wxAnyValueTypeImpl::IsSameClass(m_type) ) \ - return (value == static_cast \ - (wxAnyValueTypeImpl::GetValue(m_buffer))); \ - return false; \ -} \ -bool operator==(TUS value) const \ -{ \ - if ( wxAnyValueTypeImpl::IsSameClass(m_type) ) \ - return (value == static_cast \ - (wxAnyValueTypeImpl::GetValue(m_buffer))); \ - if ( wxAnyValueTypeImpl::IsSameClass(m_type) ) \ - return (value == static_cast \ - (wxAnyValueTypeImpl::GetValue(m_buffer))); \ - return false; \ -} - - -#if wxUSE_VARIANT - -// Note that the following functions are implemented outside wxAny class -// so that it can reside entirely in header and lack the export declaration. - -// Helper function used to associate wxAnyValueType with a wxVariantData. -extern WXDLLIMPEXP_BASE void -wxPreRegisterAnyToVariant(wxAnyToVariantRegistration* reg); - -// This function performs main wxAny to wxVariant conversion duties. -extern WXDLLIMPEXP_BASE bool -wxConvertAnyToVariant(const wxAny& any, wxVariant* variant); - -#endif // wxUSE_VARIANT - - -// -// The wxAny class represents a container for any type. A variant's value -// can be changed at run time, possibly to a different type of value. -// -// As standard, wxAny can store value of almost any type, in a fairly -// optimal manner even. -// -class wxAny -{ -public: - /** - Default constructor. - */ - wxAny() - { - m_type = wxAnyNullValueType; - } - - /** - Destructor. - */ - ~wxAny() - { - m_type->DeleteValue(m_buffer); - } - - //@{ - /** - Various constructors. - */ - template - wxAny(const T& value) - { - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(value, m_buffer); - } - - // These two constructors are needed to deal with string literals - wxAny(const char* value) - { - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(value, m_buffer); - } - wxAny(const wchar_t* value) - { - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(value, m_buffer); - } - - wxAny(const wxAny& any) - { - m_type = wxAnyNullValueType; - AssignAny(any); - } - -#if wxUSE_VARIANT - wxAny(const wxVariant& variant) - { - m_type = wxAnyNullValueType; - AssignVariant(variant); - } -#endif - - //@} - - /** - Use this template function for checking if this wxAny holds - a specific C++ data type. - - @remarks This template function does not work on some older compilers - (such as Visual C++ 6.0). For full compiler ccompatibility - please use wxANY_CHECK_TYPE(any, T) macro instead. - - @see wxAnyValueType::CheckType() - */ - // FIXME-VC6: remove this hack when VC6 is no longer supported - template - bool CheckType(T* = NULL) const - { - return m_type->CheckType(); - } - - /** - Returns the value type as wxAnyValueType instance. - - @remarks You cannot reliably test whether two wxAnys are of - same value type by simply comparing return values - of wxAny::GetType(). Instead, use wxAny::HasSameType(). - - @see HasSameType() - */ - const wxAnyValueType* GetType() const - { - return m_type; - } - - /** - Returns @true if this and another wxAny have the same - value type. - */ - bool HasSameType(const wxAny& other) const - { - return GetType()->IsSameType(other.GetType()); - } - - /** - Tests if wxAny is null (that is, whether there is no data). - */ - bool IsNull() const - { - return (m_type == wxAnyNullValueType); - } - - /** - Makes wxAny null (that is, clears it). - */ - void MakeNull() - { - m_type->DeleteValue(m_buffer); - m_type = wxAnyNullValueType; - } - - //@{ - /** - Assignment operators. - */ - template - wxAny& operator=(const T &value) - { - m_type->DeleteValue(m_buffer); - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(value, m_buffer); - return *this; - } - - wxAny& operator=(const wxAny &any) - { - if (this != &any) - AssignAny(any); - return *this; - } - -#if wxUSE_VARIANT - wxAny& operator=(const wxVariant &variant) - { - AssignVariant(variant); - return *this; - } -#endif - - // These two operators are needed to deal with string literals - wxAny& operator=(const char* value) - { - Assign(value); - return *this; - } - wxAny& operator=(const wchar_t* value) - { - Assign(value); - return *this; - } - - //@{ - /** - Equality operators. - */ - bool operator==(const wxString& value) const - { - wxString value2; - if ( !GetAs(&value2) ) - return false; - return value == value2; - } - - bool operator==(const char* value) const - { return (*this) == wxString(value); } - bool operator==(const wchar_t* value) const - { return (*this) == wxString(value); } - - // - // We need to implement custom signed/unsigned int equals operators - // for signed/unsigned (eg. wxAny(128UL) == 128L) comparisons to work. - WXANY_IMPLEMENT_INT_EQ_OP(signed char, unsigned char) - WXANY_IMPLEMENT_INT_EQ_OP(signed short, unsigned short) - WXANY_IMPLEMENT_INT_EQ_OP(signed int, unsigned int) - WXANY_IMPLEMENT_INT_EQ_OP(signed long, unsigned long) -#ifdef wxLongLong_t - WXANY_IMPLEMENT_INT_EQ_OP(wxLongLong_t, wxULongLong_t) -#endif - - wxGCC_WARNING_SUPPRESS(float-equal) - - bool operator==(float value) const - { - if ( !wxAnyValueTypeImpl::IsSameClass(m_type) ) - return false; - - return value == - static_cast - (wxAnyValueTypeImpl::GetValue(m_buffer)); - } - - bool operator==(double value) const - { - if ( !wxAnyValueTypeImpl::IsSameClass(m_type) ) - return false; - - return value == - static_cast - (wxAnyValueTypeImpl::GetValue(m_buffer)); - } - - wxGCC_WARNING_RESTORE(float-equal) - - bool operator==(bool value) const - { - if ( !wxAnyValueTypeImpl::IsSameClass(m_type) ) - return false; - - return value == (wxAnyValueTypeImpl::GetValue(m_buffer)); - } - - //@} - - //@{ - /** - Inequality operators (implement as template). - */ - template - bool operator!=(const T& value) const - { return !((*this) == value); } - //@} - - /** - This template function converts wxAny into given type. In most cases - no type conversion is performed, so if the type is incorrect an - assertion failure will occur. - - @remarks For convenience, conversion is done when T is wxString. This - is useful when a string literal (which are treated as - const char* and const wchar_t*) has been assigned to wxAny. - - This template function may not work properly with Visual C++ - 6. For full compiler compatibility, please use - wxANY_AS(any, T) macro instead. - */ - // FIXME-VC6: remove this hack when VC6 is no longer supported - template - T As(T* = NULL) const - { - if ( !wxAnyValueTypeImpl::IsSameClass(m_type) ) - { - wxFAIL_MSG("Incorrect or non-convertible data type"); - } - - return static_cast(wxAnyValueTypeImpl::GetValue(m_buffer)); - } - - // Allow easy conversion from 'const char *' etc. to wxString - // FIXME-VC6: remove this hack when VC6 is no longer supported - //template<> - wxString As(wxString*) const - { - wxString value; - if ( !GetAs(&value) ) - { - wxFAIL_MSG("Incorrect or non-convertible data type"); - } - return value; - } - -#if wxUSE_EXTENDED_RTTI - const wxTypeInfo* GetTypeInfo() const - { - return m_type->GetTypeInfo(); - } -#endif - /** - Template function that retrieves and converts the value of this - variant to the type that T* value is. - - @return Returns @true if conversion was successful. - */ - template - bool GetAs(T* value) const - { - if ( !wxAnyValueTypeImpl::IsSameClass(m_type) ) - { - wxAnyValueType* otherType = - wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueBuffer temp_buf; - - if ( !m_type->ConvertValue(m_buffer, otherType, temp_buf) ) - return false; - - *value = - static_cast(wxAnyValueTypeImpl::GetValue(temp_buf)); - otherType->DeleteValue(temp_buf); - - return true; - } - *value = static_cast(wxAnyValueTypeImpl::GetValue(m_buffer)); - return true; - } - -#if wxUSE_VARIANT - // GetAs() wxVariant specialization - bool GetAs(wxVariant* value) const - { - return wxConvertAnyToVariant(*this, value); - } -#endif - -private: - // Assignment functions - void AssignAny(const wxAny& any) - { - // Must delete value - CopyBuffer() never does that - m_type->DeleteValue(m_buffer); - - wxAnyValueType* newType = any.m_type; - - if ( !newType->IsSameType(m_type) ) - m_type = newType; - - newType->CopyBuffer(any.m_buffer, m_buffer); - } - -#if wxUSE_VARIANT - void AssignVariant(const wxVariant& variant) - { - wxVariantData* data = variant.GetData(); - - if ( data && data->GetAsAny(this) ) - return; - - m_type->DeleteValue(m_buffer); - - if ( variant.IsNull() ) - { - // Init as Null - m_type = wxAnyNullValueType; - } - else - { - // If everything else fails, wrap the whole wxVariantData - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(data, m_buffer); - } - } -#endif - - template - void Assign(const T &value) - { - m_type->DeleteValue(m_buffer); - m_type = wxAnyValueTypeImpl::sm_instance.get(); - wxAnyValueTypeImpl::SetValue(value, m_buffer); - } - - // Data - wxAnyValueBuffer m_buffer; - wxAnyValueType* m_type; -}; - - -// -// This method of checking the type is compatible with VC6 -#define wxANY_CHECK_TYPE(any, T) \ - wxANY_VALUE_TYPE_CHECK_TYPE((any).GetType(), T) - - -// -// This method of getting the value is compatible with VC6 -#define wxANY_AS(any, T) \ - (any).As(static_cast(NULL)) - - -template -inline bool wxAnyValueType::CheckType(T* reserved) const -{ - wxUnusedVar(reserved); - return wxAnyValueTypeImpl::IsSameClass(this); -} - -WX_DECLARE_LIST_WITH_DECL(wxAny, wxAnyList, class WXDLLIMPEXP_BASE); - -#endif // wxUSE_ANY - -#endif // _WX_ANY_H_ diff --git a/Source/3rd Party/wx/include/wx/anybutton.h b/Source/3rd Party/wx/include/wx/anybutton.h deleted file mode 100644 index ebeac3b55..000000000 --- a/Source/3rd Party/wx/include/wx/anybutton.h +++ /dev/null @@ -1,199 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/anybutton.h -// Purpose: wxAnyButtonBase class -// Author: Vadim Zetlin -// Created: 2000-08-15 (extracted from button.h) -// Copyright: (c) Vadim Zetlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ANYBUTTON_H_BASE_ -#define _WX_ANYBUTTON_H_BASE_ - -#include "wx/defs.h" - -#ifdef wxHAS_ANY_BUTTON - -// ---------------------------------------------------------------------------- -// wxAnyButton specific flags -// ---------------------------------------------------------------------------- - -// These flags affect label alignment -#define wxBU_LEFT 0x0040 -#define wxBU_TOP 0x0080 -#define wxBU_RIGHT 0x0100 -#define wxBU_BOTTOM 0x0200 -#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM ) - -// These two flags are obsolete -#define wxBU_NOAUTODRAW 0x0000 -#define wxBU_AUTODRAW 0x0004 - -// by default, the buttons will be created with some (system dependent) -// minimal size to make them look nicer, giving this style will make them as -// small as possible -#define wxBU_EXACTFIT 0x0001 - -// this flag can be used to disable using the text label in the button: it is -// mostly useful when creating buttons showing bitmap and having stock id as -// without it both the standard label corresponding to the stock id and the -// bitmap would be shown -#define wxBU_NOTEXT 0x0002 - - -#include "wx/bitmap.h" -#include "wx/control.h" - -// ---------------------------------------------------------------------------- -// wxAnyButton: common button functionality -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxAnyButtonBase : public wxControl -{ -public: - wxAnyButtonBase() { } - - // show the image in the button in addition to the label: this method is - // supported on all (major) platforms - void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT) - { - SetBitmapLabel(bitmap); - SetBitmapPosition(dir); - } - - wxBitmap GetBitmap() const { return DoGetBitmap(State_Normal); } - - // Methods for setting individual images for different states: normal, - // selected (meaning pushed or pressed), focused (meaning normal state for - // a focused button), disabled or hover (a.k.a. hot or current). - // - // Remember that SetBitmap() itself must be called before any other - // SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym - // for it anyhow) and that all bitmaps passed to these functions should be - // of the same size. - void SetBitmapLabel(const wxBitmap& bitmap) - { DoSetBitmap(bitmap, State_Normal); } - void SetBitmapPressed(const wxBitmap& bitmap) - { DoSetBitmap(bitmap, State_Pressed); } - void SetBitmapDisabled(const wxBitmap& bitmap) - { DoSetBitmap(bitmap, State_Disabled); } - void SetBitmapCurrent(const wxBitmap& bitmap) - { DoSetBitmap(bitmap, State_Current); } - void SetBitmapFocus(const wxBitmap& bitmap) - { DoSetBitmap(bitmap, State_Focused); } - - wxBitmap GetBitmapLabel() const { return DoGetBitmap(State_Normal); } - wxBitmap GetBitmapPressed() const { return DoGetBitmap(State_Pressed); } - wxBitmap GetBitmapDisabled() const { return DoGetBitmap(State_Disabled); } - wxBitmap GetBitmapCurrent() const { return DoGetBitmap(State_Current); } - wxBitmap GetBitmapFocus() const { return DoGetBitmap(State_Focused); } - - - // set the margins around the image - void SetBitmapMargins(wxCoord x, wxCoord y) { DoSetBitmapMargins(x, y); } - void SetBitmapMargins(const wxSize& sz) { DoSetBitmapMargins(sz.x, sz.y); } - wxSize GetBitmapMargins() { return DoGetBitmapMargins(); } - - // set the image position relative to the text, i.e. wxLEFT means that the - // image is to the left of the text (this is the default) - void SetBitmapPosition(wxDirection dir); - - - // Buttons on MSW can look bad if they are not native colours, because - // then they become owner-drawn and not theme-drawn. Disable it here - // in wxAnyButtonBase to make it consistent. - virtual bool ShouldInheritColours() const { return false; } - - // wxUniv-compatible and deprecated equivalents to SetBitmapXXX() -#if WXWIN_COMPATIBILITY_2_8 - void SetImageLabel(const wxBitmap& bitmap) { SetBitmap(bitmap); } - void SetImageMargins(wxCoord x, wxCoord y) { SetBitmapMargins(x, y); } -#endif // WXWIN_COMPATIBILITY_2_8 - - // backwards compatible names for pressed/current bitmaps: they're not - // deprecated as there is nothing really wrong with using them and no real - // advantage to using the new names but the new names are still preferred - wxBitmap GetBitmapSelected() const { return GetBitmapPressed(); } - wxBitmap GetBitmapHover() const { return GetBitmapCurrent(); } - - void SetBitmapSelected(const wxBitmap& bitmap) { SetBitmapPressed(bitmap); } - void SetBitmapHover(const wxBitmap& bitmap) { SetBitmapCurrent(bitmap); } - - - // this enum is not part of wx public API, it is public because it is used - // in non wxAnyButton-derived classes internally - // - // also notice that MSW code relies on the values of the enum elements, do - // not change them without revising src/msw/button.cpp - enum State - { - State_Normal, - State_Current, // a.k.a. hot or "hovering" - State_Pressed, // a.k.a. "selected" in public API for some reason - State_Disabled, - State_Focused, - State_Max - }; - - // return true if this button shouldn't show the text label, either because - // it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT - bool DontShowLabel() const - { - return HasFlag(wxBU_NOTEXT) || GetLabel().empty(); - } - - // return true if we do show the label - bool ShowsLabel() const - { - return !DontShowLabel(); - } - -protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const - { return wxBitmap(); } - virtual void DoSetBitmap(const wxBitmap& WXUNUSED(bitmap), - State WXUNUSED(which)) - { } - - virtual wxSize DoGetBitmapMargins() const - { return wxSize(0, 0); } - - virtual void DoSetBitmapMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) - { } - - virtual void DoSetBitmapPosition(wxDirection WXUNUSED(dir)) - { } - - virtual bool DoGetAuthNeeded() const { return false; } - virtual void DoSetAuthNeeded(bool WXUNUSED(show)) { } - - - wxDECLARE_NO_COPY_CLASS(wxAnyButtonBase); -}; - -#if defined(__WXUNIVERSAL__) - #include "wx/univ/anybutton.h" -#elif defined(__WXMSW__) - #include "wx/msw/anybutton.h" -//#elif defined(__WXMOTIF__) -// #include "wx/motif/anybutton.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/anybutton.h" -//#elif defined(__WXGTK__) -// #include "wx/gtk1/anybutton.h" -#elif defined(__WXMAC__) - #include "wx/osx/anybutton.h" -//#elif defined(__WXCOCOA__) -// #include "wx/cocoa/anybutton.h" -//#elif defined(__WXPM__) -// #include "wx/os2/anybutton.h" -#else - typedef wxAnyButtonBase wxAnyButton; -#endif - -#endif // wxHAS_ANY_BUTTON - -#endif // _WX_ANYBUTTON_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/anystr.h b/Source/3rd Party/wx/include/wx/anystr.h deleted file mode 100644 index 8eebaf9b0..000000000 --- a/Source/3rd Party/wx/include/wx/anystr.h +++ /dev/null @@ -1,139 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/anystr.h -// Purpose: wxAnyStrPtr class declaration -// Author: Vadim Zeitlin -// Created: 2009-03-23 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ANYSTR_H_ -#define _WX_ANYSTR_H_ - -#include "wx/string.h" - -// ---------------------------------------------------------------------------- -// wxAnyStrPtr -// -// Notice that this is an internal and intentionally not documented class. It -// is only used by wxWidgets itself to ensure compatibility with previous -// versions and shouldn't be used by user code. When you see a function -// returning it you should just know that you can treat it as a string pointer. -// ---------------------------------------------------------------------------- - -// This is a helper class convertible to either narrow or wide string pointer. -// It is similar to wxCStrData but, unlike it, can be NULL which is required to -// represent the return value of wxDateTime::ParseXXX() methods for example. -// -// NB: this class is fully inline and so doesn't need to be DLL-exported -class wxAnyStrPtr -{ -public: - // ctors: this class must be created from the associated string or using - // its default ctor for an invalid NULL-like object; notice that it is - // immutable after creation. - - // ctor for invalid pointer - wxAnyStrPtr() - : m_str(NULL) - { - } - - // ctor for valid pointer into the given string (whose lifetime must be - // greater than ours and which should remain constant while we're used) - wxAnyStrPtr(const wxString& str, const wxString::const_iterator& iter) - : m_str(&str), - m_iter(iter) - { - } - - // default copy ctor is ok and so is default dtor, in particular we do not - // free the string - - - // various operators meant to make this class look like a superposition of - // char* and wchar_t* - - // this one is needed to allow boolean expressions involving these objects, - // e.g. "if ( FuncReturningAnyStrPtr() && ... )" (unfortunately using - // unspecified_bool_type here wouldn't help with ambiguity between all the - // different conversions to pointers) - operator bool() const { return m_str != NULL; } - - // at least VC6 and VC7 also need this one or they complain about ambiguity - // for !anystr expressions - bool operator!() const { return !((bool)*this); } - - - // and these are the conversions operator which allow to assign the result - // of FuncReturningAnyStrPtr() to either char* or wxChar* (i.e. wchar_t*) - operator const char *() const - { - if ( !m_str ) - return NULL; - - // check if the string is convertible to char at all - // - // notice that this pointer points into wxString internal buffer - // containing its char* representation and so it can be kept for as - // long as wxString is not modified -- which is long enough for our - // needs - const char *p = m_str->c_str().AsChar(); - if ( *p ) - { - // find the offset of the character corresponding to this iterator - // position in bytes: we don't have any direct way to do it so we - // need to redo the conversion again for the part of the string - // before the iterator to find its length in bytes in current - // locale - // - // NB: conversion won't fail as it succeeded for the entire string - p += strlen(wxString(m_str->begin(), m_iter).mb_str()); - } - //else: conversion failed, return "" as we can't do anything else - - return p; - } - - operator const wchar_t *() const - { - if ( !m_str ) - return NULL; - - // no complications with wide strings (as long as we discount - // surrogates as we do for now) - // - // just remember that this works as long as wxString keeps an internal - // buffer with its wide wide char representation, just as with AsChar() - // above - return m_str->c_str().AsWChar() + (m_iter - m_str->begin()); - } - - // Because the objects of this class are only used as return type for - // functions which can return NULL we can skip providing dereferencing - // operators: the code using this class must test it for NULL first and if - // it does anything else with it it has to assign it to either char* or - // wchar_t* itself, before dereferencing. - // - // IOW this - // - // if ( *FuncReturningAnyStrPtr() ) - // - // is invalid because it could crash. And this - // - // const char *p = FuncReturningAnyStrPtr(); - // if ( p && *p ) - // - // already works fine. - -private: - // the original string and the position in it we correspond to, if the - // string is NULL this object is NULL pointer-like - const wxString * const m_str; - const wxString::const_iterator m_iter; - - wxDECLARE_NO_ASSIGN_CLASS(wxAnyStrPtr); -}; - -#endif // _WX_ANYSTR_H_ - diff --git a/Source/3rd Party/wx/include/wx/app.h b/Source/3rd Party/wx/include/wx/app.h index 55bdb4063..b7d500b12 100644 --- a/Source/3rd Party/wx/include/wx/app.h +++ b/Source/3rd Party/wx/include/wx/app.h @@ -5,6 +5,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: app.h 51592 2008-02-08 08:17:41Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,29 +18,21 @@ // ---------------------------------------------------------------------------- #include "wx/event.h" // for the base class -#include "wx/eventfilter.h" // (and another one) #include "wx/build.h" -#include "wx/cmdargs.h" // for wxCmdLineArgsArray used by wxApp::argv #include "wx/init.h" // we must declare wxEntry() #include "wx/intl.h" // for wxLayoutDirection -#include "wx/log.h" // for wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD() class WXDLLIMPEXP_FWD_BASE wxAppConsole; class WXDLLIMPEXP_FWD_BASE wxAppTraits; class WXDLLIMPEXP_FWD_BASE wxCmdLineParser; -class WXDLLIMPEXP_FWD_BASE wxEventLoopBase; +class WXDLLIMPEXP_FWD_BASE wxLog; class WXDLLIMPEXP_FWD_BASE wxMessageOutput; #if wxUSE_GUI + class WXDLLIMPEXP_FWD_BASE wxEventLoop; struct WXDLLIMPEXP_FWD_CORE wxVideoMode; - class WXDLLIMPEXP_FWD_CORE wxWindow; #endif -// this macro should be used in any main() or equivalent functions defined in wx -#define wxDISABLE_DEBUG_SUPPORT() \ - wxDISABLE_ASSERTS_IN_RELEASE_BUILD(); \ - wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD() - // ---------------------------------------------------------------------------- // typedefs // ---------------------------------------------------------------------------- @@ -58,25 +51,15 @@ enum }; // ---------------------------------------------------------------------------- -// global variables +// wxAppConsole: wxApp for non-GUI applications // ---------------------------------------------------------------------------- -// use of this list is strongly deprecated, use wxApp ScheduleForDestruction() -// and IsScheduledForDestruction() methods instead of this list directly, it -// is here for compatibility purposes only -extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; - -// ---------------------------------------------------------------------------- -// wxAppConsoleBase: wxApp for non-GUI applications -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxAppConsoleBase : public wxEvtHandler, - public wxEventFilter +class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler { public: // ctor and dtor - wxAppConsoleBase(); - virtual ~wxAppConsoleBase(); + wxAppConsole(); + virtual ~wxAppConsole(); // the virtual functions which may/must be overridden in the derived class @@ -98,28 +81,17 @@ public: // class OnInit() to do it. virtual bool OnInit(); + // this is here only temporary hopefully (FIXME) + virtual bool OnInitGui() { return true; } + // This is the replacement for the normal main(): all program work should // be done here. When OnRun() returns, the programs starts shutting down. - virtual int OnRun(); - - // Called before the first events are handled, called from within MainLoop() - virtual void OnLaunched(); - - // This is called by wxEventLoopBase::SetActive(): you should put the code - // which needs an active event loop here. - // Note that this function is called whenever an event loop is activated; - // you may want to use wxEventLoopBase::IsMain() to perform initialization - // specific for the app's main event loop. - virtual void OnEventLoopEnter(wxEventLoopBase* WXUNUSED(loop)) {} + virtual int OnRun() = 0; // This is only called if OnInit() returned true so it's a good place to do // any cleanup matching the initializations done there. virtual int OnExit(); - // This is called by wxEventLoopBase::OnExit() for each event loop which - // is exited. - virtual void OnEventLoopExit(wxEventLoopBase* WXUNUSED(loop)) {} - // This is the very last function called on wxApp object before it is // destroyed. If you override it (instead of overriding OnExit() as usual) // do not forget to call the base class version! @@ -145,20 +117,12 @@ public: // be argv[0] // set/get the application name - wxString GetAppName() const; + wxString GetAppName() const + { + return m_appName.empty() ? m_className : m_appName; + } void SetAppName(const wxString& name) { m_appName = name; } - // set/get the application display name: the display name is the name - // shown to the user in titles, reports, etc while the app name is - // used for paths, config, and other places the user doesn't see - // - // by default the display name is the same as app name or a capitalized - // version of the program if app name was not set neither but it's - // usually better to set it explicitly to something nicer - wxString GetAppDisplayName() const; - - void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; } - // set/get the app class name wxString GetClassName() const { return m_className; } void SetClassName(const wxString& name) { m_className = name; } @@ -167,19 +131,6 @@ public: const wxString& GetVendorName() const { return m_vendorName; } void SetVendorName(const wxString& name) { m_vendorName = name; } - // set/get the vendor display name: the display name is shown - // in titles/reports/dialogs to the user, while the vendor name - // is used in some areas such as wxConfig, wxStandardPaths, etc - const wxString& GetVendorDisplayName() const - { - return m_vendorDisplayName.empty() ? GetVendorName() - : m_vendorDisplayName; - } - void SetVendorDisplayName(const wxString& name) - { - m_vendorDisplayName = name; - } - // cmd line parsing stuff // ---------------------- @@ -219,68 +170,40 @@ public: // either should be configurable by the user (then he can change the // default behaviour simply by overriding CreateTraits() and returning his // own traits object) or which is GUI/console dependent as then wxAppTraits - // allows us to abstract the differences behind the common facade + // allows us to abstract the differences behind the common façade wxAppTraits *GetTraits(); - // this function provides safer access to traits object than - // wxTheApp->GetTraits() during startup or termination when the global - // application object itself may be unavailable - // - // of course, it still returns NULL in this case and the caller must check - // for it - static wxAppTraits *GetTraitsIfExists(); + // the functions below shouldn't be used now that we have wxAppTraits +#if WXWIN_COMPATIBILITY_2_4 - // Return some valid traits object. - // - // This method checks if we have wxTheApp and returns its traits if it does - // exist and the traits are non-NULL, similarly to GetTraitsIfExists(), but - // falls back to wxConsoleAppTraits to ensure that it always returns - // something valid. - static wxAppTraits& GetValidTraits(); +#if wxUSE_LOG + // override this function to create default log target of arbitrary + // user-defined class (default implementation creates a wxLogGui + // object) -- this log object is used by default by all wxLogXXX() + // functions. + wxDEPRECATED( virtual wxLog *CreateLogTarget() ); +#endif // wxUSE_LOG - // returns the main event loop instance, i.e. the event loop which is started - // by OnRun() and which dispatches all events sent from the native toolkit - // to the application (except when new event loops are temporarily set-up). - // The returned value maybe NULL. Put initialization code which needs a - // non-NULL main event loop into OnEventLoopEnter(). - wxEventLoopBase* GetMainLoop() const - { return m_mainLoop; } + // similar to CreateLogTarget() but for the global wxMessageOutput + // object + wxDEPRECATED( virtual wxMessageOutput *CreateMessageOutput() ); - // This function sets the C locale to the default locale for the current - // environment. It is advised to call this to ensure that the underlying - // toolkit uses the locale in which the numbers and monetary amounts are - // shown in the format expected by user and so on. - // - // Notice that this does _not_ change the global C++ locale, you need to do - // it explicitly if you want. - // - // Finally, notice that while this function is virtual, it is not supposed - // to be overridden outside of the library itself. - virtual void SetCLocale(); +#endif // WXWIN_COMPATIBILITY_2_4 // event processing functions // -------------------------- - // Implement the inherited wxEventFilter method but just return -1 from it - // to indicate that default processing should take place. + // this method allows to filter all the events processed by the program, so + // you should try to return quickly from it to avoid slowing down the + // program to the crawl + // + // return value should be -1 to continue with the normal event processing, + // or TRUE or FALSE to stop further processing and pretend that the event + // had been already processed or won't be processed at all, respectively virtual int FilterEvent(wxEvent& event); - // return true if we're running event loop, i.e. if the events can - // (already) be dispatched - static bool IsMainLoopRunning(); - #if wxUSE_EXCEPTIONS - // execute the functor to handle the given event - // - // this is a generalization of HandleEvent() below and the base class - // implementation of CallEventHandler() still calls HandleEvent() for - // compatibility for functors which are just wxEventFunctions (i.e. methods - // of wxEvtHandler) - virtual void CallEventHandler(wxEvtHandler *handler, - wxEventFunctor& functor, - wxEvent& event) const; - // call the specified handler on the given object with the given event // // this method only exists to allow catching the exceptions thrown by any @@ -291,112 +214,33 @@ public: wxEvent& event) const; // Called when an unhandled C++ exception occurs inside OnRun(): note that - // the main event loop has already terminated by now and the program will - // exit, if you need to really handle the exceptions you need to override - // OnExceptionInMainLoop() - virtual void OnUnhandledException(); - - // Function called if an uncaught exception is caught inside the main - // event loop: it may return true to continue running the event loop or - // false to stop it (in the latter case it may rethrow the exception as - // well) - virtual bool OnExceptionInMainLoop(); - + // the exception type is lost by now, so if you really want to handle the + // exception you should override OnRun() and put a try/catch around + // MainLoop() call there or use OnExceptionInMainLoop() + virtual void OnUnhandledException() { } #endif // wxUSE_EXCEPTIONS - - // pending events - // -------------- - - // IMPORTANT: all these methods conceptually belong to wxEventLoopBase - // but for many reasons we need to allow queuing of events - // even when there's no event loop (e.g. in wxApp::OnInit); - // this feature is used e.g. to queue events on secondary threads - // or in wxPython to use wx.CallAfter before the GUI is initialized - - // process all events in the m_handlersWithPendingEvents list -- it is necessary - // to call this function to process posted events. This happens during each + // process all events in the wxPendingEvents list -- it is necessary to + // call this function to process posted events. This happens during each // event loop iteration in GUI mode but if there is no main loop, it may be // also called directly. virtual void ProcessPendingEvents(); - // check if there are pending events on global pending event list - bool HasPendingEvents() const; + // doesn't do anything in this class, just a hook for GUI wxApp + virtual bool Yield(bool WXUNUSED(onlyIfNeeded) = false) { return true; } - // temporary suspends processing of the pending events - void SuspendProcessingOfPendingEvents(); + // make sure that idle events are sent again + virtual void WakeUpIdle() { } - // resume processing of the pending events previously stopped because of a - // call to SuspendProcessingOfPendingEvents() - void ResumeProcessingOfPendingEvents(); - - // called by ~wxEvtHandler to (eventually) remove the handler from the list of - // the handlers with pending events - void RemovePendingEventHandler(wxEvtHandler* toRemove); - - // adds an event handler to the list of the handlers with pending events - void AppendPendingEventHandler(wxEvtHandler* toAppend); - - // moves the event handler from the list of the handlers with pending events - //to the list of the handlers with _delayed_ pending events - void DelayPendingEventHandler(wxEvtHandler* toDelay); - - // deletes the current pending events - void DeletePendingEvents(); - - - // delayed destruction - // ------------------- - - // If an object may have pending events for it, it shouldn't be deleted - // immediately as this would result in a crash when trying to handle these - // events: instead, it should be scheduled for destruction and really - // destroyed only after processing all pending events. - // - // Notice that this is only possible if we have a running event loop, - // otherwise the object is just deleted directly by ScheduleForDestruction() - // and IsScheduledForDestruction() always returns false. - - // schedule the object for destruction in the near future - void ScheduleForDestruction(wxObject *object); - - // return true if the object is scheduled for destruction - bool IsScheduledForDestruction(wxObject *object) const; - - - // wxEventLoop-related methods - // --------------------------- - - // all these functions are forwarded to the corresponding methods of the - // currently active event loop -- and do nothing if there is none - virtual bool Pending(); - virtual bool Dispatch(); - - virtual int MainLoop(); - virtual void ExitMainLoop(); - - bool Yield(bool onlyIfNeeded = false); - - virtual void WakeUpIdle(); - - // this method is called by the active event loop when there are no events - // to process - // - // by default it generates the idle events and if you override it in your - // derived class you should call the base class version to ensure that idle - // events are still sent out - virtual bool ProcessIdle(); - - // this virtual function is overridden in GUI wxApp to always return true - // as GUI applications always have an event loop -- but console ones may - // have it or not, so it simply returns true if already have an event loop - // running but false otherwise - virtual bool UsesEventLoop() const; + // this is just a convenience: by providing its implementation here we + // avoid #ifdefs in the code using it + static bool IsMainLoopRunning() { return false; } // debugging support // ----------------- +#ifdef __WXDEBUG__ // this function is called when an assert failure occurs, the base class // version does the normal processing (i.e. shows the usual assert failure // dialog box) @@ -416,12 +260,16 @@ public: int line, const wxChar *cond, const wxChar *msg); +#endif // __WXDEBUG__ // check that the wxBuildOptions object (constructed in the application - // itself, usually the one from wxIMPLEMENT_APP() macro) matches the build + // itself, usually the one from IMPLEMENT_APP() macro) matches the build // options of the library and abort if it doesn't static bool CheckBuildOptions(const char *optionsSignature, const char *componentName); +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( static bool CheckBuildOptions(const wxBuildOptions& buildOptions) ); +#endif // implementation only from now on // ------------------------------- @@ -441,88 +289,37 @@ public: // command line arguments (public for backwards compatibility) - int argc; - - // this object is implicitly convertible to either "char**" (traditional - // type of argv parameter of main()) or to "wchar_t **" (for compatibility - // with Unicode build in previous wx versions and because the command line - // can, in pr -#if wxUSE_UNICODE - wxCmdLineArgsArray argv; -#else - char **argv; -#endif + int argc; + wxChar **argv; protected: - // delete all objects in wxPendingDelete list - // - // called from ProcessPendingEvents() - void DeletePendingObjects(); - // the function which creates the traits object when GetTraits() needs it // for the first time virtual wxAppTraits *CreateTraits(); + // function used for dynamic wxApp creation static wxAppInitializerFunction ms_appInitFn; // the one and only global application object static wxAppConsole *ms_appInstance; - // create main loop from AppTraits or return NULL if - // there is no main loop implementation - wxEventLoopBase *CreateMainLoop(); // application info (must be set from the user code) - wxString m_vendorName, // vendor name ("acme") - m_vendorDisplayName, // vendor display name (e.g. "ACME Inc") - m_appName, // app name ("myapp") - m_appDisplayName, // app display name ("My Application") - m_className; // class name + wxString m_vendorName, // vendor name (ACME Inc) + m_appName, // app name + m_className; // class name // the class defining the application behaviour, NULL initially and created // by GetTraits() when first needed wxAppTraits *m_traits; - // the main event loop of the application (may be NULL if the loop hasn't - // been started yet or has already terminated) - wxEventLoopBase *m_mainLoop; - - - // pending events management vars: - - // the array of the handlers with pending events which needs to be processed - // inside ProcessPendingEvents() - wxEvtHandlerArray m_handlersWithPendingEvents; - - // helper array used by ProcessPendingEvents() to store the event handlers - // which have pending events but of these events none can be processed right now - // (because of a call to wxEventLoop::YieldFor() which asked to selectively process - // pending events) - wxEvtHandlerArray m_handlersWithPendingDelayedEvents; - -#if wxUSE_THREADS - // this critical section protects both the lists above - wxCriticalSection m_handlersWithPendingEventsLocker; -#endif - - // flag modified by Suspend/ResumeProcessingOfPendingEvents() - bool m_bDoPendingEventProcessing; - - friend class WXDLLIMPEXP_FWD_BASE wxEvtHandler; // the application object is a singleton anyhow, there is no sense in // copying it - wxDECLARE_NO_COPY_CLASS(wxAppConsoleBase); + DECLARE_NO_COPY_CLASS(wxAppConsole) }; -#if defined(__UNIX__) && !defined(__WINDOWS__) - #include "wx/unix/app.h" -#else - // this has to be a class and not a typedef as we forward declare it - class wxAppConsole : public wxAppConsoleBase { }; -#endif - // ---------------------------------------------------------------------------- // wxAppBase: the common part of wxApp implementations for all platforms // ---------------------------------------------------------------------------- @@ -570,9 +367,43 @@ public: // the worker functions - usually not used directly by the user code // ----------------------------------------------------------------- - // safer alternatives to Yield(), using wxWindowDisabler - virtual bool SafeYield(wxWindow *win, bool onlyIfNeeded); - virtual bool SafeYieldFor(wxWindow *win, long eventsToProcess); + // return true if we're running main loop, i.e. if the events can + // (already) be dispatched + static bool IsMainLoopRunning() + { + wxAppBase *app = wx_static_cast(wxAppBase *, GetInstance()); + return app && app->m_mainLoop != NULL; + } + + // execute the main GUI loop, the function returns when the loop ends + virtual int MainLoop(); + + // exit the main loop thus terminating the application + virtual void Exit(); + + // exit the main GUI loop during the next iteration (i.e. it does not + // stop the program immediately!) + virtual void ExitMainLoop(); + + // returns true if there are unprocessed events in the event queue + virtual bool Pending(); + + // process the first event in the event queue (blocks until an event + // appears if there are none currently, use Pending() if this is not + // wanted), returns false if the event loop should stop and true + // otherwise + virtual bool Dispatch(); + + // process all currently pending events right now + // + // it is an error to call Yield() recursively unless the value of + // onlyIfNeeded is true + // + // WARNING: this function is dangerous as it can lead to unexpected + // reentrancies (i.e. when called from an event handler it + // may result in calling the same event handler again), use + // with _extreme_ care or, better, don't use at all! + virtual bool Yield(bool onlyIfNeeded = false) = 0; // this virtual function is called in the GUI mode when the application // becomes idle and normally just sends wxIdleEvent to all interested @@ -581,8 +412,18 @@ public: // it should return true if more idle events are needed, false if not virtual bool ProcessIdle(); - // override base class version: GUI apps always use an event loop - virtual bool UsesEventLoop() const { return true; } + // Send idle event to window and all subwindows + // Returns true if more idle time is requested. + virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event); + + +#if wxUSE_EXCEPTIONS + // Function called if an uncaught exception is caught inside the main + // event loop: it may return true to continue running the event loop or + // false to stop it (in the latter case it may rethrow the exception as + // well) + virtual bool OnExceptionInMainLoop(); +#endif // wxUSE_EXCEPTIONS // top level window functions @@ -614,15 +455,15 @@ public: // ------------------------------------------------------------------------ // Get display mode that is used use. This is only used in framebuffer - // wxWin ports such as wxDFB. + // wxWin ports (such as wxMGL or wxDFB). virtual wxVideoMode GetDisplayMode() const; // Set display mode to use. This is only used in framebuffer wxWin - // ports such as wxDFB. This method should be called from + // ports (such as wxMGL or wxDFB). This method should be called from // wxApp::OnInitGui virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; } // set use of best visual flag (see below) - void SetUseBestVisual( bool flag, bool forceTrueColour = false ) + void SetUseBestVisual( bool flag, bool forceTrueColour = false ) { m_useBestVisual = flag; m_forceTrueColour = forceTrueColour; } bool GetUseBestVisual() const { return m_useBestVisual; } @@ -637,9 +478,6 @@ public: // if it's unknown virtual wxLayoutDirection GetLayoutDirection() const; - // Change the theme used by the application, return true on success. - virtual bool SetNativeTheme(const wxString& WXUNUSED(theme)) { return false; } - // command line parsing (GUI-specific) // ------------------------------------------------------------------------ @@ -658,16 +496,28 @@ public: virtual void SetActive(bool isActive, wxWindow *lastFocus); #if WXWIN_COMPATIBILITY_2_6 + // OBSOLETE: don't use, always returns true + // // returns true if the program is successfully initialized - wxDEPRECATED_MSG("always returns true now, don't call") - bool Initialized(); + wxDEPRECATED( bool Initialized() ); #endif // WXWIN_COMPATIBILITY_2_6 + // perform standard OnIdle behaviour, ensure that this is always called + void OnIdle(wxIdleEvent& event); + + protected: + // delete all objects in wxPendingDelete list + void DeletePendingObjects(); + // override base class method to use GUI traits virtual wxAppTraits *CreateTraits(); + // the main event loop of the application (may be NULL if the loop hasn't + // been started yet or has already terminated) + wxEventLoop *m_mainLoop; + // the main top level window (may be NULL) wxWindow *m_topWindow; @@ -691,43 +541,47 @@ protected: // does any of our windows have focus? bool m_isActive; - wxDECLARE_NO_COPY_CLASS(wxAppBase); + + DECLARE_NO_COPY_CLASS(wxAppBase) }; #if WXWIN_COMPATIBILITY_2_6 inline bool wxAppBase::Initialized() { return true; } #endif // WXWIN_COMPATIBILITY_2_6 +#endif // wxUSE_GUI + // ---------------------------------------------------------------------------- // now include the declaration of the real class // ---------------------------------------------------------------------------- -#if defined(__WXMSW__) - #include "wx/msw/app.h" -#elif defined(__WXMOTIF__) - #include "wx/motif/app.h" -#elif defined(__WXDFB__) - #include "wx/dfb/app.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/app.h" -#elif defined(__WXGTK__) - #include "wx/gtk1/app.h" -#elif defined(__WXX11__) - #include "wx/x11/app.h" -#elif defined(__WXMAC__) - #include "wx/osx/app.h" -#elif defined(__WXCOCOA__) - #include "wx/cocoa/app.h" -#elif defined(__WXPM__) - #include "wx/os2/app.h" -#endif - +#if wxUSE_GUI + #if defined(__WXPALMOS__) + #include "wx/palmos/app.h" + #elif defined(__WXMSW__) + #include "wx/msw/app.h" + #elif defined(__WXMOTIF__) + #include "wx/motif/app.h" + #elif defined(__WXMGL__) + #include "wx/mgl/app.h" + #elif defined(__WXDFB__) + #include "wx/dfb/app.h" + #elif defined(__WXGTK20__) + #include "wx/gtk/app.h" + #elif defined(__WXGTK__) + #include "wx/gtk1/app.h" + #elif defined(__WXX11__) + #include "wx/x11/app.h" + #elif defined(__WXMAC__) + #include "wx/mac/app.h" + #elif defined(__WXCOCOA__) + #include "wx/cocoa/app.h" + #elif defined(__WXPM__) + #include "wx/os2/app.h" + #endif #else // !GUI - -// wxApp is defined in core and we cannot define another one in wxBase, -// so use the preprocessor to allow using wxApp in console programs too -#define wxApp wxAppConsole - + // allow using just wxApp (instead of wxAppConsole) in console programs + typedef wxAppConsole wxApp; #endif // GUI/!GUI // ---------------------------------------------------------------------------- @@ -738,12 +592,12 @@ protected: // object of type wxApp // // note that instead of using of wxTheApp in application code you should -// consider using wxDECLARE_APP() after which you may call wxGetApp() which will +// consider using DECLARE_APP() after which you may call wxGetApp() which will // return the object of the correct type (i.e. MyApp and not wxApp) // // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in // console mode it does nothing at all -#define wxTheApp static_cast(wxApp::GetInstance()) +#define wxTheApp wx_static_cast(wxApp*, wxApp::GetInstance()) // ---------------------------------------------------------------------------- // global functions @@ -753,20 +607,20 @@ protected: // ------------------------------------------------------ // Force an exit from main loop -WXDLLIMPEXP_BASE void wxExit(); +extern void WXDLLIMPEXP_BASE wxExit(); -// avoid redeclaring this function here if it had been already declared by +// avoid redeclaring this function here if it had been already declated by // wx/utils.h, this results in warnings from g++ with -Wredundant-decls #ifndef wx_YIELD_DECLARED #define wx_YIELD_DECLARED // Yield to other apps/messages -WXDLLIMPEXP_CORE bool wxYield(); +extern bool WXDLLIMPEXP_BASE wxYield(); #endif // wx_YIELD_DECLARED // Yield to other apps/messages -WXDLLIMPEXP_BASE void wxWakeUpIdle(); +extern void WXDLLIMPEXP_BASE wxWakeUpIdle(); // ---------------------------------------------------------------------------- // macros for dynamic creation of the application object @@ -783,53 +637,34 @@ public: { wxApp::SetInitializerFunction(fn); } }; -// the code below defines a wxIMPLEMENT_WXWIN_MAIN macro which you can use if +// the code below defines a IMPLEMENT_WXWIN_MAIN macro which you can use if // your compiler really, really wants main() to be in your main program (e.g. -// hello.cpp). Now wxIMPLEMENT_APP should add this code if required. +// hello.cpp). Now IMPLEMENT_APP should add this code if required. -// For compilers that support it, prefer to use wmain() as this ensures any -// Unicode strings can be passed as command line parameters and not just those -// representable in the current locale. -#if wxUSE_UNICODE && defined(__VISUALC__) - #define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ - int wmain(int argc, wchar_t **argv) \ - { \ - wxDISABLE_DEBUG_SUPPORT(); \ - \ - return wxEntry(argc, argv); \ - } -#else // Use standard main() - #define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ - int main(int argc, char **argv) \ - { \ - wxDISABLE_DEBUG_SUPPORT(); \ - \ - return wxEntry(argc, argv); \ - } -#endif +#define IMPLEMENT_WXWIN_MAIN_CONSOLE \ + int main(int argc, char **argv) { return wxEntry(argc, argv); } // port-specific header could have defined it already in some special way -#ifndef wxIMPLEMENT_WXWIN_MAIN - #define wxIMPLEMENT_WXWIN_MAIN wxIMPLEMENT_WXWIN_MAIN_CONSOLE -#endif // defined(wxIMPLEMENT_WXWIN_MAIN) +#ifndef IMPLEMENT_WXWIN_MAIN + #define IMPLEMENT_WXWIN_MAIN IMPLEMENT_WXWIN_MAIN_CONSOLE +#endif // defined(IMPLEMENT_WXWIN_MAIN) #ifdef __WXUNIVERSAL__ #include "wx/univ/theme.h" #ifdef wxUNIV_DEFAULT_THEME - #define wxIMPLEMENT_WX_THEME_SUPPORT \ + #define IMPLEMENT_WX_THEME_SUPPORT \ WX_USE_THEME(wxUNIV_DEFAULT_THEME); #else - #define wxIMPLEMENT_WX_THEME_SUPPORT + #define IMPLEMENT_WX_THEME_SUPPORT #endif #else - #define wxIMPLEMENT_WX_THEME_SUPPORT + #define IMPLEMENT_WX_THEME_SUPPORT #endif // Use this macro if you want to define your own main() or WinMain() function // and call wxEntry() from there. -#define wxIMPLEMENT_APP_NO_MAIN(appname) \ - appname& wxGetApp() { return *static_cast(wxApp::GetInstance()); } \ +#define IMPLEMENT_APP_NO_MAIN(appname) \ wxAppConsole *wxCreateApp() \ { \ wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \ @@ -837,53 +672,37 @@ public: return new appname; \ } \ wxAppInitializer \ - wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp) + wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ + DECLARE_APP(appname) \ + appname& wxGetApp() { return *wx_static_cast(appname*, wxApp::GetInstance()); } -// Same as wxIMPLEMENT_APP() normally but doesn't include themes support in +// Same as IMPLEMENT_APP() normally but doesn't include themes support in // wxUniversal builds -#define wxIMPLEMENT_APP_NO_THEMES(appname) \ - wxIMPLEMENT_WXWIN_MAIN \ - wxIMPLEMENT_APP_NO_MAIN(appname) +#define IMPLEMENT_APP_NO_THEMES(appname) \ + IMPLEMENT_APP_NO_MAIN(appname) \ + IMPLEMENT_WXWIN_MAIN // Use this macro exactly once, the argument is the name of the wxApp-derived // class which is the class of your application. -#define wxIMPLEMENT_APP(appname) \ - wxIMPLEMENT_WX_THEME_SUPPORT \ - wxIMPLEMENT_APP_NO_THEMES(appname) +#define IMPLEMENT_APP(appname) \ + IMPLEMENT_APP_NO_THEMES(appname) \ + IMPLEMENT_WX_THEME_SUPPORT // Same as IMPLEMENT_APP(), but for console applications. -#define wxIMPLEMENT_APP_CONSOLE(appname) \ - wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ - wxIMPLEMENT_APP_NO_MAIN(appname) +#define IMPLEMENT_APP_CONSOLE(appname) \ + IMPLEMENT_APP_NO_MAIN(appname) \ + IMPLEMENT_WXWIN_MAIN_CONSOLE // this macro can be used multiple times and just allows you to use wxGetApp() // function -#define wxDECLARE_APP(appname) \ - extern appname& wxGetApp() +#define DECLARE_APP(appname) extern appname& wxGetApp(); -// declare the stuff defined by wxIMPLEMENT_APP() macro, it's not really needed +// declare the stuff defined by IMPLEMENT_APP() macro, it's not really needed // anywhere else but at the very least it suppresses icc warnings about // defining extern symbols without prior declaration, and it shouldn't do any // harm extern wxAppConsole *wxCreateApp(); extern wxAppInitializer wxTheAppInitializer; -// ---------------------------------------------------------------------------- -// Compatibility macro aliases -// ---------------------------------------------------------------------------- - -// deprecated variants _not_ requiring a semicolon after them -// (note that also some wx-prefixed macro do _not_ require a semicolon because -// it's not always possible to force the compire to require it) - -#define IMPLEMENT_WXWIN_MAIN_CONSOLE wxIMPLEMENT_WXWIN_MAIN_CONSOLE -#define IMPLEMENT_WXWIN_MAIN wxIMPLEMENT_WXWIN_MAIN -#define IMPLEMENT_WX_THEME_SUPPORT wxIMPLEMENT_WX_THEME_SUPPORT -#define IMPLEMENT_APP_NO_MAIN(app) wxIMPLEMENT_APP_NO_MAIN(app); -#define IMPLEMENT_APP_NO_THEMES(app) wxIMPLEMENT_APP_NO_THEMES(app); -#define IMPLEMENT_APP(app) wxIMPLEMENT_APP(app); -#define IMPLEMENT_APP_CONSOLE(app) wxIMPLEMENT_APP_CONSOLE(app); -#define DECLARE_APP(app) wxDECLARE_APP(app); - #endif // _WX_APP_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/apptrait.h b/Source/3rd Party/wx/include/wx/apptrait.h index f488dfa7a..56f36dfea 100644 --- a/Source/3rd Party/wx/include/wx/apptrait.h +++ b/Source/3rd Party/wx/include/wx/apptrait.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.06.2003 +// RCS-ID: $Id: apptrait.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,44 +15,34 @@ #include "wx/string.h" #include "wx/platinfo.h" -class WXDLLIMPEXP_FWD_BASE wxArrayString; -class WXDLLIMPEXP_FWD_BASE wxConfigBase; -class WXDLLIMPEXP_FWD_BASE wxEventLoopBase; +class WXDLLIMPEXP_FWD_BASE wxObject; +class WXDLLIMPEXP_FWD_BASE wxAppTraits; #if wxUSE_FONTMAP class WXDLLIMPEXP_FWD_CORE wxFontMapper; #endif // wxUSE_FONTMAP class WXDLLIMPEXP_FWD_BASE wxLog; class WXDLLIMPEXP_FWD_BASE wxMessageOutput; -class WXDLLIMPEXP_FWD_BASE wxObject; class WXDLLIMPEXP_FWD_CORE wxRendererNative; -class WXDLLIMPEXP_FWD_BASE wxStandardPaths; class WXDLLIMPEXP_FWD_BASE wxString; -class WXDLLIMPEXP_FWD_BASE wxTimer; -class WXDLLIMPEXP_FWD_BASE wxTimerImpl; -class wxSocketManager; +class GSocketGUIFunctionsTable; // ---------------------------------------------------------------------------- // wxAppTraits: this class defines various configurable aspects of wxApp // ---------------------------------------------------------------------------- +class WXDLLIMPEXP_FWD_BASE wxStandardPathsBase; + class WXDLLIMPEXP_BASE wxAppTraitsBase { public: // needed since this class declares virtual members virtual ~wxAppTraitsBase() { } - // hooks for working with the global objects, may be overridden by the user + // hooks for creating the global objects, may be overridden by the user // ------------------------------------------------------------------------ -#if wxUSE_CONFIG - // create the default configuration object (base class version is - // implemented in config.cpp and creates wxRegConfig for wxMSW and - // wxFileConfig for all the other platforms) - virtual wxConfigBase *CreateConfig(); -#endif // wxUSE_CONFIG - #if wxUSE_LOG // create the default log target virtual wxLog *CreateLogTarget() = 0; @@ -72,14 +63,16 @@ public: // NB: returned pointer will be deleted by the caller virtual wxRendererNative *CreateRenderer() = 0; +#if wxUSE_STDPATHS // wxStandardPaths object is normally the same for wxBase and wxGUI // except in the case of wxMac and wxCocoa - virtual wxStandardPaths& GetStandardPaths(); - + virtual wxStandardPathsBase& GetStandardPaths(); +#endif // wxUSE_STDPATHS // functions abstracting differences between GUI and console modes // ------------------------------------------------------------------------ +#ifdef __WXDEBUG__ // show the assert dialog with the specified message in GUI or just print // the string to stderr in console mode // @@ -88,79 +81,53 @@ public: // // return true to suppress subsequent asserts, false to continue as before virtual bool ShowAssertDialog(const wxString& msg) = 0; +#endif // __WXDEBUG__ // return true if fprintf(stderr) goes somewhere, false otherwise virtual bool HasStderr() = 0; + // managing "pending delete" list: in GUI mode we can't immediately delete + // some objects because there may be unprocessed events for them and so we + // only do it during the next idle loop iteration while this is, of course, + // unnecessary in wxBase, so we have a few functions to abstract these + // operations + + // add the object to the pending delete list in GUI, delete it immediately + // in wxBase + virtual void ScheduleForDestroy(wxObject *object) = 0; + + // remove this object from the pending delete list in GUI, do nothing in + // wxBase + virtual void RemoveFromPendingDelete(wxObject *object) = 0; + #if wxUSE_SOCKETS - // this function is used by wxNet library to set the default socket manager - // to use: doing it like this allows us to keep all socket-related code in - // wxNet instead of having to pull it in wxBase itself as we'd have to do - // if we really implemented wxSocketManager here - // - // we don't take ownership of this pointer, it should have a lifetime - // greater than that of any socket (e.g. be a pointer to a static object) - static void SetDefaultSocketManager(wxSocketManager *manager) - { - ms_manager = manager; - } - - // return socket manager: this is usually different for console and GUI - // applications (although some ports use the same implementation for both) - virtual wxSocketManager *GetSocketManager() { return ms_manager; } + // return table of GUI callbacks for GSocket code or NULL in wxBase. This + // is needed because networking classes are in their own library and so + // they can't directly call GUI functions (the same net library can be + // used in both GUI and base apps). To complicate it further, GUI library + // ("wxCore") doesn't depend on networking library and so only a functions + // table can be passed around + virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0; #endif - // create a new, port specific, instance of the event loop used by wxApp - virtual wxEventLoopBase *CreateEventLoop() = 0; - -#if wxUSE_TIMER - // return platform and toolkit dependent wxTimer implementation - virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0; -#endif - -#if wxUSE_THREADS - virtual void MutexGuiEnter(); - virtual void MutexGuiLeave(); -#endif - - // functions returning port-specific information - // ------------------------------------------------------------------------ - // return information about the (native) toolkit currently used and its // runtime (not compile-time) version. // returns wxPORT_BASE for console applications and one of the remaining // wxPORT_* values for GUI applications. - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const = 0; + virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0; // return true if the port is using wxUniversal for the GUI, false if not virtual bool IsUsingUniversalWidgets() const = 0; // return the name of the Desktop Environment such as // "KDE" or "GNOME". May return an empty string. - virtual wxString GetDesktopEnvironment() const = 0; - - // returns a short string to identify the block of the standard command - // line options parsed automatically by current port: if this string is - // empty, there are no such options, otherwise the function also fills - // passed arrays with the names and the descriptions of those options. - virtual wxString GetStandardCmdLineOptions(wxArrayString& names, - wxArrayString& desc) const - { - wxUnusedVar(names); - wxUnusedVar(desc); - - return wxEmptyString; - } - + virtual wxString GetDesktopEnvironment() const { return wxEmptyString; } protected: -#if wxUSE_STACKWALKER +#if wxUSE_STACKWALKER && defined( __WXDEBUG__ ) // utility function: returns the stack frame as a plain wxString virtual wxString GetAssertStackTrace(); #endif - -private: - static wxSocketManager *ms_manager; }; // ---------------------------------------------------------------------------- @@ -170,10 +137,14 @@ private: // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the // Unix code (and otherwise __UNIX__ wouldn't be defined) // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port -#if defined(__WIN32__) +#if defined(__WXPALMOS__) + #include "wx/palmos/apptbase.h" +#elif defined(__WIN32__) #include "wx/msw/apptbase.h" #elif defined(__UNIX__) && !defined(__EMX__) #include "wx/unix/apptbase.h" +#elif defined(__WXMAC__) + #include "wx/mac/apptbase.h" #elif defined(__OS2__) #include "wx/os2/apptbase.h" #else // no platform-specific methods to add to wxAppTraits @@ -194,10 +165,6 @@ private: class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits { public: -#if !wxUSE_CONSOLE_EVENTLOOP - virtual wxEventLoopBase *CreateEventLoop() { return NULL; } -#endif // !wxUSE_CONSOLE_EVENTLOOP - #if wxUSE_LOG virtual wxLog *CreateLogTarget(); #endif // wxUSE_LOG @@ -206,12 +173,20 @@ public: virtual wxFontMapper *CreateFontMapper(); #endif // wxUSE_FONTMAP virtual wxRendererNative *CreateRenderer(); +#if wxUSE_SOCKETS + virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable(); +#endif +#ifdef __WXDEBUG__ virtual bool ShowAssertDialog(const wxString& msg); +#endif // __WXDEBUG__ virtual bool HasStderr(); + virtual void ScheduleForDestroy(wxObject *object); + virtual void RemoveFromPendingDelete(wxObject *object); + // the GetToolkitVersion for console application is always the same - virtual wxPortId GetToolkitVersion(int *verMaj = NULL, int *verMin = NULL) const + virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const { // no toolkits (wxBase is for console applications without GUI support) // NB: zero means "no toolkit", -1 means "not initialized yet" @@ -222,7 +197,6 @@ public: } virtual bool IsUsingUniversalWidgets() const { return false; } - virtual wxString GetDesktopEnvironment() const { return wxEmptyString; } }; // ---------------------------------------------------------------------------- @@ -231,7 +205,7 @@ public: #if wxUSE_GUI -class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits +class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits { public: #if wxUSE_LOG @@ -242,10 +216,18 @@ public: virtual wxFontMapper *CreateFontMapper(); #endif // wxUSE_FONTMAP virtual wxRendererNative *CreateRenderer(); +#if wxUSE_SOCKETS + virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable(); +#endif +#ifdef __WXDEBUG__ virtual bool ShowAssertDialog(const wxString& msg); +#endif // __WXDEBUG__ virtual bool HasStderr(); + virtual void ScheduleForDestroy(wxObject *object); + virtual void RemoveFromPendingDelete(wxObject *object); + virtual bool IsUsingUniversalWidgets() const { #ifdef __WXUNIVERSAL__ @@ -254,8 +236,6 @@ public: return false; #endif } - - virtual wxString GetDesktopEnvironment() const { return wxEmptyString; } }; #endif // wxUSE_GUI @@ -265,12 +245,16 @@ public: // ---------------------------------------------------------------------------- // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port -#if defined(__WIN32__) +#if defined(__WXPALMOS__) + #include "wx/palmos/apptrait.h" +#elif defined(__WIN32__) #include "wx/msw/apptrait.h" #elif defined(__OS2__) #include "wx/os2/apptrait.h" #elif defined(__UNIX__) #include "wx/unix/apptrait.h" +#elif defined(__WXMAC__) + #include "wx/mac/apptrait.h" #elif defined(__DOS__) #include "wx/msdos/apptrait.h" #else diff --git a/Source/3rd Party/wx/include/wx/archive.h b/Source/3rd Party/wx/include/wx/archive.h index 137149deb..dbf26c25c 100644 --- a/Source/3rd Party/wx/include/wx/archive.h +++ b/Source/3rd Party/wx/include/wx/archive.h @@ -2,6 +2,7 @@ // Name: wx/archive.h // Purpose: Streams for archive formats // Author: Mike Wetherell +// RCS-ID: $Id: archive.h 43445 2006-11-16 14:30:20Z MW $ // Copyright: (c) 2004 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -224,7 +225,7 @@ public: if (it.m_rep) it.m_rep.AddRef(); if (m_rep) - this->m_rep.UnRef(); + m_rep.UnRef(); m_rep = it.m_rep; return *this; } @@ -340,13 +341,11 @@ public: const wxString& name, wxPathFormat format = wxPATH_NATIVE) const = 0; - // FIXME-UTF8: remove these from this file, they are used for ANSI - // build only void SetConv(wxMBConv& conv) { m_pConv = &conv; } wxMBConv& GetConv() const { if (m_pConv) return *m_pConv; else return wxConvLocal; } - static const wxArchiveClassFactory *Find(const wxString& protocol, + static const wxArchiveClassFactory *Find(const wxChar *protocol, wxStreamProtocolType type = wxSTREAM_PROTOCOL); diff --git a/Source/3rd Party/wx/include/wx/arrimpl.cpp b/Source/3rd Party/wx/include/wx/arrimpl.cpp index 5d81a0d7a..37b26314a 100644 --- a/Source/3rd Party/wx/include/wx/arrimpl.cpp +++ b/Source/3rd Party/wx/include/wx/arrimpl.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 16.10.97 +// RCS-ID: $Id: arrimpl.cpp 34241 2005-05-22 12:10:55Z JS $ // Copyright: (c) 1997 Vadim Zeitlin -// Licence: wxWindows licence +// Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// /***************************************************************************** @@ -90,14 +91,14 @@ void name::Insert(const T& item, size_t uiIndex, size_t nInsert) \ base_array::operator[](uiIndex + i) = new T(item); \ } \ \ -int name::Index(const T& item, bool bFromEnd) const \ +int name::Index(const T& Item, bool bFromEnd) const \ { \ if ( bFromEnd ) { \ if ( size() > 0 ) { \ size_t ui = size() - 1; \ do { \ - if ( (T*)base_array::operator[](ui) == &item ) \ - return static_cast(ui); \ + if ( (T*)base_array::operator[](ui) == &Item ) \ + return wx_static_cast(int, ui); \ ui--; \ } \ while ( ui != 0 ); \ @@ -105,8 +106,8 @@ int name::Index(const T& item, bool bFromEnd) const \ } \ else { \ for( size_t ui = 0; ui < size(); ui++ ) { \ - if( (T*)base_array::operator[](ui) == &item ) \ - return static_cast(ui); \ + if( (T*)base_array::operator[](ui) == &Item ) \ + return wx_static_cast(int, ui); \ } \ } \ \ diff --git a/Source/3rd Party/wx/include/wx/arrstr.h b/Source/3rd Party/wx/include/wx/arrstr.h index 47d42fee9..299cd00f5 100644 --- a/Source/3rd Party/wx/include/wx/arrstr.h +++ b/Source/3rd Party/wx/include/wx/arrstr.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/arrstr.h +// Name: include/wx/arrstr.h // Purpose: wxArrayString class // Author: Mattia Barbon and Vadim Zeitlin // Modified by: // Created: 07/07/03 +// RCS-ID: $Id: arrstr.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,20 +15,10 @@ #include "wx/defs.h" #include "wx/string.h" -// these functions are only used in STL build now but we define them in any -// case for compatibility with the existing code outside of the library which -// could be using them -inline int wxCMPFUNC_CONV wxStringSortAscending(wxString* s1, wxString* s2) -{ - return s1->Cmp(*s2); -} +WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortAscending(wxString*, wxString*); +WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortDescending(wxString*, wxString*); -inline int wxCMPFUNC_CONV wxStringSortDescending(wxString* s1, wxString* s2) -{ - return wxStringSortAscending(s2, s1); -} - -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #include "wx/dynarray.h" @@ -51,11 +42,10 @@ public: wxArrayString() { } wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { } - wxArrayString(size_t sz, const char** a); - wxArrayString(size_t sz, const wchar_t** a); + wxArrayString(size_t sz, const wxChar** a); wxArrayString(size_t sz, const wxString* a); - int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const; + int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const; void Sort(bool reverseOrder = false); void Sort(CompareFunction function); @@ -85,37 +75,25 @@ public: Add(src[n]); } - int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const; - -private: - void Insert() - { - wxFAIL_MSG( "wxSortedArrayString::Insert() is not to be used" ); - } - - void Sort() - { - wxFAIL_MSG( "wxSortedArrayString::Sort() is not to be used" ); - } + int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const; }; -#else // if !wxUSE_STD_CONTAINERS +#else // if !wxUSE_STL -// this shouldn't be defined for compilers not supporting template methods or -// without std::distance() +// ---------------------------------------------------------------------------- +// The string array uses it's knowledge of internal structure of the wxString +// class to optimize string storage. Normally, we would store pointers to +// string, but as wxString is, in fact, itself a pointer (sizeof(wxString) is +// sizeof(char *)) we store these pointers instead. The cast to "wxString *" is +// really all we need to turn such pointer into a string! // -// FIXME-VC6: currently it's only not defined for VC6 in DLL build as it -// doesn't export template methods from DLL correctly so even though -// it compiles them fine, we get link errors when using wxArrayString -#if !defined(__VISUALC6__) || !(defined(WXMAKINGDLL) || defined(WXUSINGDLL)) - #define wxHAS_VECTOR_TEMPLATE_ASSIGN -#endif - -#ifdef wxHAS_VECTOR_TEMPLATE_ASSIGN - #include "wx/beforestd.h" - #include - #include "wx/afterstd.h" -#endif // wxHAS_VECTOR_TEMPLATE_ASSIGN +// Of course, it can be called a dirty hack, but we use twice less memory and +// this approach is also more speed efficient, so it's probably worth it. +// +// Usage notes: when a string is added/inserted, a new copy of it is created, +// so the original string may be safely deleted. When a string is retrieved +// from the array (operator[] or Item() method), a reference is returned. +// ---------------------------------------------------------------------------- class WXDLLIMPEXP_BASE wxArrayString { @@ -135,14 +113,13 @@ public: // // NB: the reason for using int and not bool is that like this we can avoid // using this ctor for implicit conversions from "const char *" (which - // we'd like to be implicitly converted to wxString instead!). This - // wouldn't be needed if the 'explicit' keyword was supported by all - // compilers, or if this was protected ctor for wxSortedArrayString, - // but we're stuck with it now. - wxEXPLICIT wxArrayString(int autoSort) { Init(autoSort != 0); } + // we'd like to be implicitly converted to wxString instead!) + // + // of course, using explicit would be even better - if all compilers + // supported it... + wxArrayString(int autoSort) { Init(autoSort != 0); } // C string array ctor - wxArrayString(size_t sz, const char** a); - wxArrayString(size_t sz, const wchar_t** a); + wxArrayString(size_t sz, const wxChar** a); // wxString string array ctor wxArrayString(size_t sz, const wxString* a); // copy ctor @@ -172,34 +149,38 @@ public: // items access (range checking is done in debug version) // get item at position uiIndex - wxString& Item(size_t nIndex) + wxString& Item(size_t nIndex) const { wxASSERT_MSG( nIndex < m_nCount, wxT("wxArrayString: index out of bounds") ); - return m_pItems[nIndex]; + return *(wxString *)&(m_pItems[nIndex]); } - const wxString& Item(size_t nIndex) const { return const_cast(this)->Item(nIndex); } // same as Item() - wxString& operator[](size_t nIndex) { return Item(nIndex); } - const wxString& operator[](size_t nIndex) const { return Item(nIndex); } + wxString& operator[](size_t nIndex) const { return Item(nIndex); } // get last item - wxString& Last() + wxString& Last() const { wxASSERT_MSG( !IsEmpty(), wxT("wxArrayString: index out of bounds") ); - return Item(GetCount() - 1); + return Item(Count() - 1); } - const wxString& Last() const { return const_cast(this)->Last(); } + // return a wxString[], useful for the controls which + // take one in their ctor. You must delete[] it yourself + // once you are done with it. Will return NULL if the + // ArrayString was empty. +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( wxString* GetStringArray() const ); +#endif // item management // Search the element in the array, starting from the beginning if // bFromEnd is false or from end otherwise. If bCase, comparison is case // sensitive (default). Returns index of the first item matched or // wxNOT_FOUND - int Index (const wxString& str, bool bCase = true, bool bFromEnd = false) const; + int Index (const wxChar *sz, bool bCase = true, bool bFromEnd = false) const; // add new element at the end (if the array is not sorted), return its // index size_t Add(const wxString& str, size_t nInsert = 1); @@ -208,15 +189,18 @@ public: // expand the array to have count elements void SetCount(size_t count); // remove first item matching this value - void Remove(const wxString& sz); + void Remove(const wxChar *sz); // remove item by index +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( void Remove(size_t nIndex, size_t nRemove = 1) ); +#endif void RemoveAt(size_t nIndex, size_t nRemove = 1); // sorting // sort array elements in alphabetical order (or reversed alphabetical // order if reverseOrder parameter is true) void Sort(bool reverseOrder = false); - // sort array elements using specified comparison function + // sort array elements using specified comparaison function void Sort(CompareFunction compareFunction); void Sort(CompareFunction2 compareFunction); @@ -251,7 +235,7 @@ public: public: pointer m_ptr; reverse_iterator() : m_ptr(NULL) { } - wxEXPLICIT reverse_iterator(pointer ptr) : m_ptr(ptr) { } + reverse_iterator(pointer ptr) : m_ptr(ptr) { } reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } reference operator*() const { return *m_ptr; } pointer operator->() const { return m_ptr; } @@ -277,7 +261,7 @@ public: public: pointer m_ptr; const_reverse_iterator() : m_ptr(NULL) { } - wxEXPLICIT const_reverse_iterator(pointer ptr) : m_ptr(ptr) { } + const_reverse_iterator(pointer ptr) : m_ptr(ptr) { } const_reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { } reference operator*() const { return *m_ptr; } @@ -294,32 +278,13 @@ public: wxArrayString(const_iterator first, const_iterator last) { Init(false); assign(first, last); } wxArrayString(size_type n, const_reference v) { Init(false); assign(n, v); } - -#ifdef wxHAS_VECTOR_TEMPLATE_ASSIGN - template - void assign(Iterator first, Iterator last) - { - clear(); - reserve(std::distance(first, last)); - for(; first != last; ++first) - push_back(*first); - } -#else // !wxHAS_VECTOR_TEMPLATE_ASSIGN - void assign(const_iterator first, const_iterator last) - { - clear(); - reserve(last - first); - for(; first != last; ++first) - push_back(*first); - } -#endif // wxHAS_VECTOR_TEMPLATE_ASSIGN/!wxHAS_VECTOR_TEMPLATE_ASSIGN - + void assign(const_iterator first, const_iterator last); void assign(size_type n, const_reference v) { clear(); Add(v, n); } reference back() { return *(end() - 1); } const_reference back() const { return *(end() - 1); } - iterator begin() { return m_pItems; } - const_iterator begin() const { return m_pItems; } + iterator begin() { return (wxString *)&(m_pItems[0]); } + const_iterator begin() const { return (wxString *)&(m_pItems[0]); } size_type capacity() const { return m_nSize; } void clear() { Clear(); } bool empty() const { return IsEmpty(); } @@ -343,36 +308,27 @@ public: void pop_back() { RemoveAt(GetCount() - 1); } void push_back(const_reference v) { Add(v); } reverse_iterator rbegin() { return reverse_iterator(end() - 1); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(end() - 1); } + const_reverse_iterator rbegin() const; reverse_iterator rend() { return reverse_iterator(begin() - 1); } - const_reverse_iterator rend() const - { return const_reverse_iterator(begin() - 1); } + const_reverse_iterator rend() const; void reserve(size_type n) /* base::reserve*/; void resize(size_type n, value_type v = value_type()); size_type size() const { return GetCount(); } - void swap(wxArrayString& other) - { - wxSwap(m_nSize, other.m_nSize); - wxSwap(m_nCount, other.m_nCount); - wxSwap(m_pItems, other.m_pItems); - wxSwap(m_autoSort, other.m_autoSort); - } protected: void Init(bool autoSort); // common part of all ctors void Copy(const wxArrayString& src); // copies the contents of another array private: - // Allocate the new buffer big enough to hold m_nCount + nIncrement items and - // return the pointer to the old buffer, which must be deleted by the caller - // (if the old buffer is big enough, just return NULL). - wxString *Grow(size_t nIncrement); + void Grow(size_t nIncrement = 0); // makes array bigger if needed + void Free(); // free all the strings stored + + void DoSort(); // common part of all Sort() variants size_t m_nSize, // current size of the array m_nCount; // current number of elements - wxString *m_pItems; // pointer to data + wxChar **m_pItems; // pointer to data bool m_autoSort; // if true, keep the array always sorted }; @@ -386,7 +342,7 @@ public: { Copy(array); } }; -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL // this class provides a temporary wxString* from a // wxArrayString @@ -409,110 +365,13 @@ public: return m_strings; } - wxString* Release() - { - wxString *r = GetStrings(); - m_strings = NULL; - return r; - } +#if wxABI_VERSION >= 20810 + wxString* Release(); +#endif // wxABI_VERSION >= 20810 private: const wxArrayString& m_array; wxString* m_strings; }; - -// ---------------------------------------------------------------------------- -// helper functions for working with arrays -// ---------------------------------------------------------------------------- - -// by default, these functions use the escape character to escape the -// separators occurring inside the string to be joined, this can be disabled by -// passing '\0' as escape - -WXDLLIMPEXP_BASE wxString wxJoin(const wxArrayString& arr, - const wxChar sep, - const wxChar escape = wxT('\\')); - -WXDLLIMPEXP_BASE wxArrayString wxSplit(const wxString& str, - const wxChar sep, - const wxChar escape = wxT('\\')); - - -// ---------------------------------------------------------------------------- -// This helper class allows to pass both C array of wxStrings or wxArrayString -// using the same interface. -// -// Use it when you have two methods taking wxArrayString or (int, wxString[]), -// that do the same thing. This class lets you iterate over input data in the -// same way whether it is a raw array of strings or wxArrayString. -// -// The object does not take ownership of the data -- internally it keeps -// pointers to the data, therefore the data must be disposed of by user -// and only after this object is destroyed. Usually it is not a problem as -// only temporary objects of this class are used. -// ---------------------------------------------------------------------------- - -class wxArrayStringsAdapter -{ -public: - // construct an adapter from a wxArrayString - wxArrayStringsAdapter(const wxArrayString& strings) - : m_type(wxSTRING_ARRAY), m_size(strings.size()) - { - m_data.array = &strings; - } - - // construct an adapter from a wxString[] - wxArrayStringsAdapter(unsigned int n, const wxString *strings) - : m_type(wxSTRING_POINTER), m_size(n) - { - m_data.ptr = strings; - } - - // construct an adapter from a single wxString - wxArrayStringsAdapter(const wxString& s) - : m_type(wxSTRING_POINTER), m_size(1) - { - m_data.ptr = &s; - } - - // default copy constructor is ok - - // iteration interface - size_t GetCount() const { return m_size; } - bool IsEmpty() const { return GetCount() == 0; } - const wxString& operator[] (unsigned int i) const - { - wxASSERT_MSG( i < GetCount(), wxT("index out of bounds") ); - if(m_type == wxSTRING_POINTER) - return m_data.ptr[i]; - return m_data.array->Item(i); - } - wxArrayString AsArrayString() const - { - if(m_type == wxSTRING_ARRAY) - return *m_data.array; - return wxArrayString(GetCount(), m_data.ptr); - } - -private: - // type of the data being held - enum wxStringContainerType - { - wxSTRING_ARRAY, // wxArrayString - wxSTRING_POINTER // wxString[] - }; - - wxStringContainerType m_type; - size_t m_size; - union - { - const wxString * ptr; - const wxArrayString * array; - } m_data; - - wxDECLARE_NO_ASSIGN_CLASS(wxArrayStringsAdapter); -}; - -#endif // _WX_ARRSTR_H +#endif diff --git a/Source/3rd Party/wx/include/wx/artprov.h b/Source/3rd Party/wx/include/wx/artprov.h index 32548eb84..31f3bd44e 100644 --- a/Source/3rd Party/wx/include/wx/artprov.h +++ b/Source/3rd Party/wx/include/wx/artprov.h @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 18/03/2002 +// RCS-ID: $Id: artprov.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,7 +15,6 @@ #include "wx/string.h" #include "wx/bitmap.h" #include "wx/icon.h" -#include "wx/iconbndl.h" class WXDLLIMPEXP_FWD_CORE wxArtProvidersList; class WXDLLIMPEXP_FWD_CORE wxArtProviderCache; @@ -27,10 +27,10 @@ class wxArtProviderModule; typedef wxString wxArtClient; typedef wxString wxArtID; -#define wxART_MAKE_CLIENT_ID_FROM_STR(id) ((id) + "_C") -#define wxART_MAKE_CLIENT_ID(id) (#id "_C") +#define wxART_MAKE_CLIENT_ID_FROM_STR(id) (id + wxT("_C")) +#define wxART_MAKE_CLIENT_ID(id) wxT(#id) wxT("_C") #define wxART_MAKE_ART_ID_FROM_STR(id) (id) -#define wxART_MAKE_ART_ID(id) (#id) +#define wxART_MAKE_ART_ID(id) wxT(#id) // ---------------------------------------------------------------------------- // Art clients @@ -44,7 +44,6 @@ typedef wxString wxArtID; #define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER) #define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX) #define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON) -#define wxART_LIST wxART_MAKE_CLIENT_ID(wxART_LIST) #define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER) @@ -65,8 +64,6 @@ typedef wxString wxArtID; #define wxART_GO_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN) #define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT) #define wxART_GO_HOME wxART_MAKE_ART_ID(wxART_GO_HOME) -#define wxART_GOTO_FIRST wxART_MAKE_ART_ID(wxART_GOTO_FIRST) -#define wxART_GOTO_LAST wxART_MAKE_ART_ID(wxART_GOTO_LAST) #define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN) #define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE) #define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS) @@ -102,10 +99,6 @@ typedef wxString wxArtID; #define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO) #define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO) -#define wxART_PLUS wxART_MAKE_ART_ID(wxART_PLUS) -#define wxART_MINUS wxART_MAKE_ART_ID(wxART_MINUS) - -#define wxART_CLOSE wxART_MAKE_ART_ID(wxART_CLOSE) #define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT) #define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND) @@ -116,14 +109,12 @@ typedef wxString wxArtID; // wxArtProvider class // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxArtProvider : public wxObject +class WXDLLEXPORT wxArtProvider : public wxObject { public: // Dtor removes the provider from providers stack if it's still on it virtual ~wxArtProvider(); - // Does this platform implement native icons theme? - static bool HasNativeProvider(); // Add new provider to the top of providers stack (i.e. the provider will // be queried first of all). @@ -131,12 +122,11 @@ public: // Add new provider to the bottom of providers stack (i.e. the provider // will be queried as the last one). +#if wxABI_VERSION >= 20810 static void PushBack(wxArtProvider *provider); - -#if WXWIN_COMPATIBILITY_2_8 - // use PushBack(), it's the same thing - static wxDEPRECATED( void Insert(wxArtProvider *provider) ); #endif + // same as PushBack() + static void Insert(wxArtProvider *provider); // Remove latest added provider and delete it. static bool Pop(); @@ -160,54 +150,26 @@ public: const wxArtClient& client = wxART_OTHER, const wxSize& size = wxDefaultSize); - // Helper used by GetMessageBoxIcon(): return the art id corresponding to - // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one - // can be set) - static wxArtID GetMessageBoxIconId(int flags); - - // Helper used by several generic classes: return the icon corresponding to - // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one - // can be set) - static wxIcon GetMessageBoxIcon(int flags) - { - return GetIcon(GetMessageBoxIconId(flags), wxART_MESSAGE_BOX); - } - - // Query the providers for iconbundle with given ID and return it. Return - // wxNullIconBundle if no provider provides it. - static wxIconBundle GetIconBundle(const wxArtID& id, - const wxArtClient& client = wxART_OTHER); - - // Gets native size for given 'client' or wxDefaultSize if it doesn't - // have native equivalent - static wxSize GetNativeSizeHint(const wxArtClient& client); - // Get the size hint of an icon from a specific wxArtClient, queries // the topmost provider if platform_dependent = false static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false); #if WXWIN_COMPATIBILITY_2_6 // use the corresponding methods without redundant "Provider" suffix - static wxDEPRECATED( void PushProvider(wxArtProvider *provider) ); - static wxDEPRECATED( void InsertProvider(wxArtProvider *provider) ); - static wxDEPRECATED( bool PopProvider() ); + wxDEPRECATED( static void PushProvider(wxArtProvider *provider) ); + wxDEPRECATED( static void InsertProvider(wxArtProvider *provider) ); + wxDEPRECATED( static bool PopProvider() ); // use Delete() if this is what you really need, or just delete the // provider pointer, do not use Remove() as it does not delete the pointer // unlike RemoveProvider() which does - static wxDEPRECATED( bool RemoveProvider(wxArtProvider *provider) ); + wxDEPRECATED( static bool RemoveProvider(wxArtProvider *provider) ); #endif // WXWIN_COMPATIBILITY_2_6 protected: friend class wxArtProviderModule; -#if wxUSE_ARTPROVIDER_STD // Initializes default provider static void InitStdProvider(); -#endif // wxUSE_ARTPROVIDER_STD - // Initializes Tango-based icon provider -#if wxUSE_ARTPROVIDER_TANGO - static void InitTangoProvider(); -#endif // wxUSE_ARTPROVIDER_TANGO // Initializes platform's native provider, if available (e.g. GTK2) static void InitNativeProvider(); // Destroy caches & all providers @@ -219,26 +181,15 @@ protected: return GetSizeHint(client, true); } - // Derived classes must override CreateBitmap or CreateIconBundle - // (or both) to create requested art resource. This method is called - // only once per instance's lifetime for each requested wxArtID. + // Derived classes must override this method to create requested + // art resource. This method is called only once per instance's + // lifetime for each requested wxArtID. virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id), const wxArtClient& WXUNUSED(client), - const wxSize& WXUNUSED(size)) - { - return wxNullBitmap; - } - - virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id), - const wxArtClient& WXUNUSED(client)) - { - return wxNullIconBundle; - } + const wxSize& WXUNUSED(size)) = 0; private: static void CommonAddingProvider(); - static wxIconBundle DoGetIconBundle(const wxArtID& id, - const wxArtClient& client); private: // list of providers: @@ -250,12 +201,4 @@ private: }; -#if !defined(__WXUNIVERSAL__) && \ - ((defined(__WXGTK__) && defined(__WXGTK20__)) || defined(__WXMSW__) || \ - defined(__WXMAC__)) - // *some* (partial) native implementation of wxArtProvider exists; this is - // not the same as wxArtProvider::HasNativeProvider()! - #define wxHAS_NATIVE_ART_PROVIDER_IMPL -#endif - #endif // _WX_ARTPROV_H_ diff --git a/Source/3rd Party/wx/include/wx/atomic.h b/Source/3rd Party/wx/include/wx/atomic.h deleted file mode 100644 index 1439d2948..000000000 --- a/Source/3rd Party/wx/include/wx/atomic.h +++ /dev/null @@ -1,159 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/atomic.h -// Purpose: functions to manipulate atomically integers and pointers -// Author: Armel Asselin -// Created: 12/13/2006 -// Copyright: (c) Armel Asselin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ATOMIC_H_ -#define _WX_ATOMIC_H_ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// get the value of wxUSE_THREADS configuration flag -#include "wx/defs.h" - -// constraints on the various functions: -// - wxAtomicDec must return a zero value if the value is zero once -// decremented else it must return any non-zero value (the true value is OK -// but not necessary). - -#if wxUSE_THREADS - -#if defined(HAVE_GCC_ATOMIC_BUILTINS) - -// NB: we intentionally don't use Linux's asm/atomic.h header, because it's -// an internal kernel header that doesn't always work in userspace: -// http://bugs.mysql.com/bug.php?id=28456 -// http://golubenco.org/blog/atomic-operations/ - -inline void wxAtomicInc (wxUint32 &value) -{ - __sync_fetch_and_add(&value, 1); -} - -inline wxUint32 wxAtomicDec (wxUint32 &value) -{ - return __sync_sub_and_fetch(&value, 1); -} - - -#elif defined(__WINDOWS__) - -// include standard Windows headers -#include "wx/msw/wrapwin.h" - -inline void wxAtomicInc (wxUint32 &value) -{ - InterlockedIncrement ((LONG*)&value); -} - -inline wxUint32 wxAtomicDec (wxUint32 &value) -{ - return InterlockedDecrement ((LONG*)&value); -} - -#elif defined(__WXMAC__) || defined(__DARWIN__) - -#include "libkern/OSAtomic.h" -inline void wxAtomicInc (wxUint32 &value) -{ - OSAtomicIncrement32 ((int32_t*)&value); -} - -inline wxUint32 wxAtomicDec (wxUint32 &value) -{ - return OSAtomicDecrement32 ((int32_t*)&value); -} - -#elif defined (__SOLARIS__) - -#include - -inline void wxAtomicInc (wxUint32 &value) -{ - atomic_add_32 ((uint32_t*)&value, 1); -} - -inline wxUint32 wxAtomicDec (wxUint32 &value) -{ - return atomic_add_32_nv ((uint32_t*)&value, (uint32_t)-1); -} - -#else // unknown platform - -// it will result in inclusion if the generic implementation code a bit later in this page -#define wxNEEDS_GENERIC_ATOMIC_OPS - -#endif // unknown platform - -#else // else of wxUSE_THREADS -// if no threads are used we can safely use simple ++/-- - -inline void wxAtomicInc (wxUint32 &value) { ++value; } -inline wxUint32 wxAtomicDec (wxUint32 &value) { return --value; } - -#endif // !wxUSE_THREADS - -// ---------------------------------------------------------------------------- -// proxies to actual implementations, but for various other types with same -// behaviour -// ---------------------------------------------------------------------------- - -#ifdef wxNEEDS_GENERIC_ATOMIC_OPS - -#include "wx/thread.h" // for wxCriticalSection - -class wxAtomicInt32 -{ -public: - wxAtomicInt32() { } // non initialized for consistency with basic int type - wxAtomicInt32(wxInt32 v) : m_value(v) { } - wxAtomicInt32(const wxAtomicInt32& a) : m_value(a.m_value) {} - - operator wxInt32() const { return m_value; } - operator volatile wxInt32&() { return m_value; } - - wxAtomicInt32& operator=(wxInt32 v) { m_value = v; return *this; } - - void Inc() - { - wxCriticalSectionLocker lock(m_locker); - ++m_value; - } - - wxInt32 Dec() - { - wxCriticalSectionLocker lock(m_locker); - return --m_value; - } - -private: - volatile wxInt32 m_value; - wxCriticalSection m_locker; -}; - -inline void wxAtomicInc(wxAtomicInt32 &value) { value.Inc(); } -inline wxInt32 wxAtomicDec(wxAtomicInt32 &value) { return value.Dec(); } - -#else // !wxNEEDS_GENERIC_ATOMIC_OPS - -#define wxHAS_ATOMIC_OPS - -inline void wxAtomicInc(wxInt32 &value) { wxAtomicInc((wxUint32&)value); } -inline wxInt32 wxAtomicDec(wxInt32 &value) { return wxAtomicDec((wxUint32&)value); } - -typedef wxInt32 wxAtomicInt32; - -#endif // wxNEEDS_GENERIC_ATOMIC_OPS - -// all the native implementations use 32 bits currently -// for a 64 bits implementation we could use (a future) wxAtomicInt64 as -// default type -typedef wxAtomicInt32 wxAtomicInt; - -#endif // _WX_ATOMIC_H_ diff --git a/Source/3rd Party/wx/include/wx/bannerwindow.h b/Source/3rd Party/wx/include/wx/bannerwindow.h deleted file mode 100644 index 1f1fb2461..000000000 --- a/Source/3rd Party/wx/include/wx/bannerwindow.h +++ /dev/null @@ -1,144 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/bannerwindow.h -// Purpose: wxBannerWindow class declaration -// Author: Vadim Zeitlin -// Created: 2011-08-16 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_BANNERWINDOW_H_ -#define _WX_BANNERWINDOW_H_ - -#include "wx/defs.h" - -#if wxUSE_BANNERWINDOW - -#include "wx/bitmap.h" -#include "wx/event.h" -#include "wx/window.h" - -class WXDLLIMPEXP_FWD_CORE wxBitmap; -class WXDLLIMPEXP_FWD_CORE wxColour; -class WXDLLIMPEXP_FWD_CORE wxDC; - -extern WXDLLIMPEXP_DATA_ADV(const char) wxBannerWindowNameStr[]; - -// ---------------------------------------------------------------------------- -// A simple banner window showing either a bitmap or text. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxBannerWindow : public wxWindow -{ -public: - // Default constructor, use Create() later. - wxBannerWindow() { Init(); } - - // Convenient constructor that should be used in the majority of cases. - // - // The banner orientation changes how the text in it is displayed and also - // defines where is the bitmap truncated if it's too big to fit but doesn't - // do anything for the banner position, this is supposed to be taken care - // of in the usual way, e.g. using sizers. - wxBannerWindow(wxWindow* parent, wxDirection dir = wxLEFT) - { - Init(); - - Create(parent, wxID_ANY, dir); - } - - // Full constructor provided for consistency with the other classes only. - wxBannerWindow(wxWindow* parent, - wxWindowID winid, - wxDirection dir = wxLEFT, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxBannerWindowNameStr) - { - Init(); - - Create(parent, winid, dir, pos, size, style, name); - } - - // Can be only called on objects created with the default constructor. - bool Create(wxWindow* parent, - wxWindowID winid, - wxDirection dir = wxLEFT, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxBannerWindowNameStr); - - - // Provide an existing bitmap to show. For wxLEFT orientation the bitmap is - // truncated from the top, for wxTOP and wxBOTTOM -- from the right and for - // wxRIGHT -- from the bottom, so put the most important part of the bitmap - // information in the opposite direction. - void SetBitmap(const wxBitmap& bmp); - - // Set the text to display. This is mutually exclusive with SetBitmap(). - // Title is rendered in bold and should be single line, message can have - // multiple lines but is not wrapped automatically. - void SetText(const wxString& title, const wxString& message); - - // Set the colours between which the gradient runs. This can be combined - // with SetText() but not SetBitmap(). - void SetGradient(const wxColour& start, const wxColour& end); - -protected: - virtual wxSize DoGetBestClientSize() const; - -private: - // Common part of all constructors. - void Init(); - - // Fully invalidates the window. - void OnSize(wxSizeEvent& event); - - // Redraws the window using either m_bitmap or m_title/m_message. - void OnPaint(wxPaintEvent& event); - - // Helper of OnPaint(): draw the bitmap at the correct position depending - // on our orientation. - void DrawBitmapBackground(wxDC& dc); - - // Helper of OnPaint(): draw the text in the appropriate direction. - void DrawBannerTextLine(wxDC& dc, const wxString& str, const wxPoint& pos); - - // Return the font to use for the title. Currently this is hardcoded as a - // larger bold version of the standard window font but could be made - // configurable in the future. - wxFont GetTitleFont() const; - - // Return the colour to use for extending the bitmap. Non-const as it - // updates m_colBitmapBg if needed. - wxColour GetBitmapBg(); - - - // The window side along which the banner is laid out. - wxDirection m_direction; - - // If valid, this bitmap is drawn as is. - wxBitmap m_bitmap; - - // If bitmap is valid, this is the colour we use to extend it if the bitmap - // is smaller than this window. It is computed on demand by GetBitmapBg(). - wxColour m_colBitmapBg; - - // The title and main message to draw, used if m_bitmap is invalid. - wxString m_title, - m_message; - - // Start and stop gradient colours, only used when drawing text. - wxColour m_colStart, - m_colEnd; - - wxDECLARE_EVENT_TABLE(); - - wxDECLARE_NO_COPY_CLASS(wxBannerWindow); -}; - -#endif // wxUSE_BANNERWINDOW - -#endif // _WX_BANNERWINDOW_H_ diff --git a/Source/3rd Party/wx/include/wx/base64.h b/Source/3rd Party/wx/include/wx/base64.h deleted file mode 100644 index 96c6dd80e..000000000 --- a/Source/3rd Party/wx/include/wx/base64.h +++ /dev/null @@ -1,121 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/base64.h -// Purpose: declaration of BASE64 encoding/decoding functionality -// Author: Charles Reimers, Vadim Zeitlin -// Created: 2007-06-18 -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_BASE64_H_ -#define _WX_BASE64_H_ - -#if wxUSE_BASE64 - -#include "wx/string.h" -#include "wx/buffer.h" - -// ---------------------------------------------------------------------------- -// encoding functions -// ---------------------------------------------------------------------------- - -// return the size needed for the buffer containing the encoded representation -// of a buffer of given length -inline size_t wxBase64EncodedSize(size_t len) { return 4*((len+2)/3); } - -// raw base64 encoding function which encodes the contents of a buffer of the -// specified length into the buffer of the specified size -// -// returns the length of the encoded data or wxCONV_FAILED if the buffer is not -// large enough; to determine the needed size you can either allocate a buffer -// of wxBase64EncodedSize(srcLen) size or call the function with NULL buffer in -// which case the required size will be returned -WXDLLIMPEXP_BASE size_t -wxBase64Encode(char *dst, size_t dstLen, const void *src, size_t srcLen); - -// encode the contents of the given buffer using base64 and return as string -// (there is no error return) -inline wxString wxBase64Encode(const void *src, size_t srcLen) -{ - const size_t dstLen = wxBase64EncodedSize(srcLen); - wxCharBuffer dst(dstLen); - wxBase64Encode(dst.data(), dstLen, src, srcLen); - - return dst; -} - -inline wxString wxBase64Encode(const wxMemoryBuffer& buf) -{ - return wxBase64Encode(buf.GetData(), buf.GetDataLen()); -} - -// ---------------------------------------------------------------------------- -// decoding functions -// ---------------------------------------------------------------------------- - -// elements of this enum specify the possible behaviours of wxBase64Decode() -// when an invalid character is encountered -enum wxBase64DecodeMode -{ - // normal behaviour: stop at any invalid characters - wxBase64DecodeMode_Strict, - - // skip whitespace characters - wxBase64DecodeMode_SkipWS, - - // the most lenient behaviour: simply ignore all invalid characters - wxBase64DecodeMode_Relaxed -}; - -// return the buffer size necessary for decoding a base64 string of the given -// length -inline size_t wxBase64DecodedSize(size_t srcLen) { return 3*srcLen/4; } - -// raw decoding function which decodes the contents of the string of specified -// length (or NUL-terminated by default) into the provided buffer of the given -// size -// -// the function normally stops at any character invalid inside a base64-encoded -// string (i.e. not alphanumeric nor '+' nor '/') but can be made to skip the -// whitespace or all invalid characters using its mode argument -// -// returns the length of the decoded data or wxCONV_FAILED if an error occurs -// such as the buffer is too small or the encoded string is invalid; in the -// latter case the posErr is filled with the position where the decoding -// stopped if it is not NULL -WXDLLIMPEXP_BASE size_t -wxBase64Decode(void *dst, size_t dstLen, - const char *src, size_t srcLen = wxNO_LEN, - wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t *posErr = NULL); - -inline size_t -wxBase64Decode(void *dst, size_t dstLen, - const wxString& src, - wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t *posErr = NULL) -{ - // don't use str.length() here as the ASCII buffer is shorter than it for - // strings with embedded NULs - return wxBase64Decode(dst, dstLen, src.ToAscii(), wxNO_LEN, mode, posErr); -} - -// decode the contents of the given string; the returned buffer is empty if an -// error occurs during decoding -WXDLLIMPEXP_BASE wxMemoryBuffer -wxBase64Decode(const char *src, size_t srcLen = wxNO_LEN, - wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t *posErr = NULL); - -inline wxMemoryBuffer -wxBase64Decode(const wxString& src, - wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t *posErr = NULL) -{ - // don't use str.length() here as the ASCII buffer is shorter than it for - // strings with embedded NULs - return wxBase64Decode(src.ToAscii(), wxNO_LEN, mode, posErr); -} - -#endif // wxUSE_BASE64 - -#endif // _WX_BASE64_H_ diff --git a/Source/3rd Party/wx/include/wx/beforestd.h b/Source/3rd Party/wx/include/wx/beforestd.h index 62ba0ac8d..7261de803 100644 --- a/Source/3rd Party/wx/include/wx/beforestd.h +++ b/Source/3rd Party/wx/include/wx/beforestd.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/beforestd.h +// Name: include/wx/beforestd.h // Purpose: #include before STL headers // Author: Vadim Zeitlin // Modified by: // Created: 07/07/03 +// RCS-ID: $Id: beforestd.h 61871 2009-09-09 22:29:51Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -22,20 +23,6 @@ // VC 7.x isn't as bad as VC6 and doesn't give these warnings but eVC (which // defines _MSC_VER as 1201) does need to be included as it's VC6-like #if defined(__VISUALC__) && __VISUALC__ <= 1201 - // these warning have to be disabled and not just temporarily disabled - // because they will be given at the end of the compilation of the - // current source and there is absolutely nothing we can do about them so - // disable them before warning(push) below - - // 'foo': unreferenced inline function has been removed - #pragma warning(disable:4514) - - // 'function' : function not inlined - #pragma warning(disable:4710) - - // 'id': identifier was truncated to 'num' characters in the debug info - #pragma warning(disable:4786) - // MSVC 5 does not have this #if __VISUALC__ > 1100 // we have to disable (and reenable in afterstd.h) this one because, @@ -61,15 +48,28 @@ // 'identifier' use the following syntax #pragma warning(disable:4663) #endif + + // these warning have to be disabled and not just temporarily disabled + // because they will be given at the end of the compilation of the + // current source and there is absolutely nothing we can do about them + + // 'foo': unreferenced inline function has been removed + #pragma warning(disable:4514) + + // 'function' : function not inlined + #pragma warning(disable:4710) + + // 'id': identifier was truncated to 'num' characters in the debug info + #pragma warning(disable:4786) #endif // VC++ < 7 -/** - GCC's visibility support is broken for libstdc++ in some older versions - (namely Debian/Ubuntu's GCC 4.1, see - https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/109262). We fix it - here by mimicking newer versions' behaviour of using default visibility - for libstdc++ code. +/* + Recent versions of Sun C++ compiler use _T in their standard headers and + our definition of it in wx/wxchar.h conflicts with them and breaks + compilation, so undefine _T before including them and redefine it back in + wx/afterstd.h if needed. */ -#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) - #pragma GCC visibility push(default) -#endif +#if defined(__SUNPRO_CC) || defined(__SUNPRO_C) + #undef _T +#endif /* SUNCC */ + diff --git a/Source/3rd Party/wx/include/wx/bitmap.h b/Source/3rd Party/wx/include/wx/bitmap.h index 2ca45f673..bcee14373 100644 --- a/Source/3rd Party/wx/include/wx/bitmap.h +++ b/Source/3rd Party/wx/include/wx/bitmap.h @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 22.04.01 +// RCS-ID: $Id: bitmap.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -18,14 +19,13 @@ #include "wx/string.h" #include "wx/gdicmn.h" // for wxBitmapType #include "wx/colour.h" -#include "wx/image.h" class WXDLLIMPEXP_FWD_CORE wxBitmap; class WXDLLIMPEXP_FWD_CORE wxBitmapHandler; class WXDLLIMPEXP_FWD_CORE wxIcon; +class WXDLLIMPEXP_FWD_CORE wxImage; class WXDLLIMPEXP_FWD_CORE wxMask; class WXDLLIMPEXP_FWD_CORE wxPalette; -class WXDLLIMPEXP_FWD_CORE wxDC; // ---------------------------------------------------------------------------- // wxVariant support @@ -33,16 +33,14 @@ class WXDLLIMPEXP_FWD_CORE wxDC; #if wxUSE_VARIANT #include "wx/variant.h" -DECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLIMPEXP_CORE) +DECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLEXPORT) #endif // ---------------------------------------------------------------------------- // wxMask represents the transparent area of the bitmap // ---------------------------------------------------------------------------- -// TODO: all implementation of wxMask, except the generic one, -// do not derive from wxMaskBase,,, they should -class WXDLLIMPEXP_CORE wxMaskBase : public wxObject +class WXDLLEXPORT wxMaskBase : public wxObject { public: // create the mask from bitmap pixels of the given colour @@ -68,7 +66,8 @@ protected: virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0; }; -#if defined(__WXDFB__) || \ +#if defined(__WXMGL__) || \ + defined(__WXDFB__) || \ defined(__WXMAC__) || \ defined(__WXGTK__) || \ defined(__WXCOCOA__) || \ @@ -79,30 +78,8 @@ protected: #define wxUSE_BITMAP_BASE 0 #endif -// a more readable way to tell -#define wxBITMAP_SCREEN_DEPTH (-1) - - -// ---------------------------------------------------------------------------- -// wxBitmapHelpers: container for various bitmap methods common to all ports. -// ---------------------------------------------------------------------------- - -// Unfortunately, currently wxBitmap does not inherit from wxBitmapBase on all -// platforms and this is not easy to fix. So we extract at least some common -// methods into this class from which both wxBitmapBase (and hence wxBitmap on -// all platforms where it does inherit from it) and wxBitmap in wxMSW and other -// exceptional ports (only wxPM and old wxCocoa) inherit. -class WXDLLIMPEXP_CORE wxBitmapHelpers -{ -public: - // Create a new wxBitmap from the PNG data in the given buffer. - static wxBitmap NewFromPNGData(const void* data, size_t size); -}; - - -// All ports except wxMSW and wxOS2 use wxBitmapHandler and wxBitmapBase as -// base class for wxBitmapHandler; wxMSW and wxOS2 use wxGDIImageHandler as -// base class since it allows some code reuse there. +// Only used by some ports +// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes #if wxUSE_BITMAP_BASE // ---------------------------------------------------------------------------- @@ -110,29 +87,18 @@ public: // different formats // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapHandler : public wxObject +class WXDLLEXPORT wxBitmapHandlerBase : public wxObject { public: - wxBitmapHandler() { m_type = wxBITMAP_TYPE_INVALID; } - virtual ~wxBitmapHandler() { } + wxBitmapHandlerBase() { m_type = wxBITMAP_TYPE_INVALID; } + virtual ~wxBitmapHandlerBase() { } - // NOTE: the following functions should be pure virtuals, but they aren't - // because otherwise almost all ports would have to implement - // them as "return false"... - - virtual bool Create(wxBitmap *WXUNUSED(bitmap), const void* WXUNUSED(data), - wxBitmapType WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height), - int WXUNUSED(depth) = 1) - { return false; } - - virtual bool LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), - wxBitmapType WXUNUSED(type), int WXUNUSED(desiredWidth), - int WXUNUSED(desiredHeight)) - { return false; } - - virtual bool SaveFile(const wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), - wxBitmapType WXUNUSED(type), const wxPalette *WXUNUSED(palette) = NULL) const - { return false; } + virtual bool Create(wxBitmap *bitmap, const void* data, long flags, + int width, int height, int depth = 1); + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, + int type, const wxPalette *palette = NULL); void SetName(const wxString& name) { m_name = name; } void SetExtension(const wxString& ext) { m_extension = ext; } @@ -146,65 +112,43 @@ private: wxString m_extension; wxBitmapType m_type; - DECLARE_ABSTRACT_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase) }; -// ---------------------------------------------------------------------------- -// wxBitmap: class which represents platform-dependent bitmap (unlike wxImage) -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxBitmapBase : public wxGDIObject, - public wxBitmapHelpers +class WXDLLEXPORT wxBitmapBase : public wxGDIObject { public: /* Derived class must implement these: wxBitmap(); - wxBitmap(const wxBitmap& bmp); + wxBitmap(int width, int height, int depth = -1); wxBitmap(const char bits[], int width, int height, int depth = 1); - wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); - wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH); wxBitmap(const char* const* bits); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM); - wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH); + wxBitmap(const wxImage& image, int depth = -1); + + bool Create(int width, int height, int depth = -1); static void InitStandardHandlers(); */ - virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0; - virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0; - virtual bool CreateScaled(int w, int h, int d, double logicalScale) - { return Create(w*logicalScale,h*logicalScale,d); } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const = 0; virtual int GetHeight() const = 0; virtual int GetWidth() const = 0; virtual int GetDepth() const = 0; - wxSize GetSize() const - { return wxSize(GetWidth(), GetHeight()); } - - // support for scaled bitmaps - virtual double GetScaleFactor() const { return 1.0; } - virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); } - virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); } - virtual wxSize GetScaledSize() const - { return wxSize(GetScaledWidth(), GetScaledHeight()); } - -#if wxUSE_IMAGE virtual wxImage ConvertToImage() const = 0; - // Convert to disabled (dimmed) bitmap. - wxBitmap ConvertToDisabled(unsigned char brightness = 255) const; -#endif // wxUSE_IMAGE - virtual wxMask *GetMask() const = 0; virtual void SetMask(wxMask *mask) = 0; virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0; virtual bool SaveFile(const wxString &name, wxBitmapType type, - const wxPalette *palette = NULL) const = 0; + const wxPalette *palette = (wxPalette *)NULL) const = 0; virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0; /* @@ -230,8 +174,8 @@ public: // Format handling static inline wxList& GetHandlers() { return sm_handlers; } - static void AddHandler(wxBitmapHandler *handler); - static void InsertHandler(wxBitmapHandler *handler); + static void AddHandler(wxBitmapHandlerBase *handler); + static void InsertHandler(wxBitmapHandlerBase *handler); static bool RemoveHandler(const wxString& name); static wxBitmapHandler *FindHandler(const wxString& name); static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType); @@ -259,58 +203,32 @@ protected: #endif // wxUSE_BITMAP_BASE - -// the wxBITMAP_DEFAULT_TYPE constant defines the default argument value -// for wxBitmap's ctor and wxBitmap::LoadFile() functions. -#if defined(__WXMSW__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE +#if defined(__WXPALMOS__) + #include "wx/palmos/bitmap.h" +#elif defined(__WXMSW__) #include "wx/msw/bitmap.h" #elif defined(__WXMOTIF__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/x11/bitmap.h" #elif defined(__WXGTK20__) - #ifdef __WINDOWS__ - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE - #else - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM - #endif #include "wx/gtk/bitmap.h" #elif defined(__WXGTK__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/gtk1/bitmap.h" #elif defined(__WXX11__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/x11/bitmap.h" +#elif defined(__WXMGL__) + #include "wx/mgl/bitmap.h" #elif defined(__WXDFB__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE #include "wx/dfb/bitmap.h" #elif defined(__WXMAC__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_PICT_RESOURCE - #include "wx/osx/bitmap.h" + #include "wx/mac/bitmap.h" #elif defined(__WXCOCOA__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE #include "wx/cocoa/bitmap.h" #elif defined(__WXPM__) - #define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE #include "wx/os2/bitmap.h" #endif -#if wxUSE_IMAGE -inline -wxBitmap -#if wxUSE_BITMAP_BASE -wxBitmapBase:: -#else -wxBitmap:: -#endif -ConvertToDisabled(unsigned char brightness) const -{ - return ConvertToImage().ConvertToDisabled(brightness); -} -#endif // wxUSE_IMAGE - // we must include generic mask.h after wxBitmap definition -#if defined(__WXDFB__) +#if defined(__WXMGL__) || defined(__WXDFB__) #define wxUSE_GENERIC_MASK 1 #else #define wxUSE_GENERIC_MASK 0 diff --git a/Source/3rd Party/wx/include/wx/bmpbuttn.h b/Source/3rd Party/wx/include/wx/bmpbuttn.h index 97e5f410d..f7b96b662 100644 --- a/Source/3rd Party/wx/include/wx/bmpbuttn.h +++ b/Source/3rd Party/wx/include/wx/bmpbuttn.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/bmpbuttn.h +// Name: wx/bmpbutton.h // Purpose: wxBitmapButton class interface // Author: Vadim Zeitlin // Modified by: // Created: 25.08.00 +// RCS-ID: $Id: bmpbuttn.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,75 +16,57 @@ #if wxUSE_BMPBUTTON +#include "wx/bitmap.h" #include "wx/button.h" -// FIXME: right now only wxMSW, wxGTK and wxOSX implement bitmap support in wxButton -// itself, this shouldn't be used for the other platforms neither -// when all of them do it -#if (defined(__WXMSW__) || defined(__WXGTK20__) || defined(__WXOSX__)) && !defined(__WXUNIVERSAL__) - #define wxHAS_BUTTON_BITMAP -#endif - -class WXDLLIMPEXP_FWD_CORE wxBitmapButton; +extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[]; // ---------------------------------------------------------------------------- // wxBitmapButton: a button which shows bitmaps instead of the usual string. // It has different bitmaps for different states (focused/disabled/pressed) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton +class WXDLLEXPORT wxBitmapButtonBase : public wxButton { public: wxBitmapButtonBase() { -#ifndef wxHAS_BUTTON_BITMAP m_marginX = m_marginY = 0; -#endif // wxHAS_BUTTON_BITMAP } - bool Create(wxWindow *parent, - wxWindowID winid, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) - { - // We use wxBU_NOTEXT to let the base class Create() know that we are - // not going to show the label: this is a hack needed for wxGTK where - // we can show both label and bitmap only with GTK 2.6+ but we always - // can show just one of them and this style allows us to choose which - // one we need. - // - // And we also use wxBU_EXACTFIT to avoid being resized up to the - // standard button size as this doesn't make sense for bitmap buttons - // which are not standard anyhow and should fit their bitmap size. - return wxButton::Create(parent, winid, "", - pos, size, - style | wxBU_NOTEXT | wxBU_EXACTFIT, - validator, name); - } - - // Special creation function for a standard "Close" bitmap. It allows to - // simply create a close button with the image appropriate for the common - // platform. - static wxBitmapButton* NewCloseButton(wxWindow* parent, wxWindowID winid); + // set the bitmaps + void SetBitmapLabel(const wxBitmap& bitmap) + { m_bmpNormal = bitmap; OnSetBitmap(); } + void SetBitmapSelected(const wxBitmap& sel) + { m_bmpSelected = sel; OnSetBitmap(); } + void SetBitmapFocus(const wxBitmap& focus) + { m_bmpFocus = focus; OnSetBitmap(); } + void SetBitmapDisabled(const wxBitmap& disabled) + { m_bmpDisabled = disabled; OnSetBitmap(); } + void SetBitmapHover(const wxBitmap& hover) + { m_bmpHover = hover; OnSetBitmap(); } + // retrieve the bitmaps + const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; } + const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; } + const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; } + const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } + const wxBitmap& GetBitmapHover() const { return m_bmpHover; } + wxBitmap& GetBitmapLabel() { return m_bmpNormal; } + wxBitmap& GetBitmapSelected() { return m_bmpSelected; } + wxBitmap& GetBitmapFocus() { return m_bmpFocus; } + wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; } + wxBitmap& GetBitmapHover() { return m_bmpHover; } // set/get the margins around the button - virtual void SetMargins(int x, int y) - { - DoSetBitmapMargins(x, y); - } - - int GetMarginX() const { return DoGetBitmapMargins().x; } - int GetMarginY() const { return DoGetBitmapMargins().y; } + virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } + int GetMarginX() const { return m_marginX; } + int GetMarginY() const { return m_marginY; } // deprecated synonym for SetBitmapLabel() #if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap), - SetBitmapLabel(bitmap); ) + wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) ); // prevent virtual function hiding virtual void SetLabel(const wxString& label) @@ -91,36 +74,31 @@ public: #endif // WXWIN_COMPATIBILITY_2_6 protected: -#ifndef wxHAS_BUTTON_BITMAP // function called when any of the bitmaps changes virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); } - virtual wxBitmap DoGetBitmap(State which) const { return m_bitmaps[which]; } - virtual void DoSetBitmap(const wxBitmap& bitmap, State which) - { m_bitmaps[which] = bitmap; OnSetBitmap(); } - - virtual wxSize DoGetBitmapMargins() const - { - return wxSize(m_marginX, m_marginY); - } - - virtual void DoSetBitmapMargins(int x, int y) - { - m_marginX = x; - m_marginY = y; - } - // the bitmaps for various states - wxBitmap m_bitmaps[State_Max]; + wxBitmap m_bmpNormal, + m_bmpSelected, + m_bmpFocus, + m_bmpDisabled, + m_bmpHover; // the margins around the bitmap int m_marginX, m_marginY; -#endif // !wxHAS_BUTTON_BITMAP - wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase); + + DECLARE_NO_COPY_CLASS(wxBitmapButtonBase) }; +#if WXWIN_COMPATIBILITY_2_6 +inline void wxBitmapButtonBase::SetLabel(const wxBitmap& bitmap) +{ + SetBitmapLabel(bitmap); +} +#endif // WXWIN_COMPATIBILITY_2_6 + #if defined(__WXUNIVERSAL__) #include "wx/univ/bmpbuttn.h" #elif defined(__WXMSW__) @@ -132,7 +110,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/bmpbuttn.h" #elif defined(__WXMAC__) - #include "wx/osx/bmpbuttn.h" + #include "wx/mac/bmpbuttn.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/bmpbuttn.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/bmpcbox.h b/Source/3rd Party/wx/include/wx/bmpcbox.h deleted file mode 100644 index a5b9beeed..000000000 --- a/Source/3rd Party/wx/include/wx/bmpcbox.h +++ /dev/null @@ -1,125 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/bmpcbox.h -// Purpose: wxBitmapComboBox base header -// Author: Jaakko Salli -// Modified by: -// Created: Aug-31-2006 -// Copyright: (c) Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_BMPCBOX_H_BASE_ -#define _WX_BMPCBOX_H_BASE_ - - -#include "wx/defs.h" - -#if wxUSE_BITMAPCOMBOBOX - -#include "wx/bitmap.h" -#include "wx/dynarray.h" - -class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLIMPEXP_FWD_CORE wxItemContainer; - -// Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which -// wxBitmapComboBox implementation utilizes ownerdrawn combobox -// (either native or generic). -#if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__) - #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED - -class WXDLLIMPEXP_FWD_CORE wxDC; -#endif - -extern WXDLLIMPEXP_DATA_ADV(const char) wxBitmapComboBoxNameStr[]; - - -class WXDLLIMPEXP_ADV wxBitmapComboBoxBase -{ -public: - // ctors and such - wxBitmapComboBoxBase() { Init(); } - - virtual ~wxBitmapComboBoxBase() { } - - // Sets the image for the given item. - virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0; - -#if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED) - - // Returns the image of the item with the given index. - virtual wxBitmap GetItemBitmap(unsigned int n) const = 0; - - // Returns size of the image used in list - virtual wxSize GetBitmapSize() const = 0; - -private: - void Init() {} - -#else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED - - // Returns the image of the item with the given index. - virtual wxBitmap GetItemBitmap(unsigned int n) const; - - // Returns size of the image used in list - virtual wxSize GetBitmapSize() const - { - return m_usedImgSize; - } - -protected: - - // Returns pointer to the combobox item container - virtual wxItemContainer* GetItemContainer() = 0; - - // Return pointer to the owner-drawn combobox control - virtual wxWindow* GetControl() = 0; - - // wxItemContainer functions - void BCBDoClear(); - void BCBDoDeleteOneItem(unsigned int n); - - void DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap); - - void DrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const; - void DrawItem(wxDC& dc, const wxRect& rect, int item, const wxString& text, - int flags) const; - wxCoord MeasureItem(size_t item) const; - - // Returns true if image size was affected - virtual bool OnAddBitmap(const wxBitmap& bitmap); - - // Recalculates amount of empty space needed in front of text - // in control itself. Returns number that can be passed to - // wxOwnerDrawnComboBox::SetCustomPaintWidth() and similar - // functions. - virtual int DetermineIndent(); - - void UpdateInternals(); - - wxArrayPtrVoid m_bitmaps; // Images associated with items - wxSize m_usedImgSize; // Size of bitmaps - - int m_imgAreaWidth; // Width and height of area next to text field - int m_fontHeight; - int m_indent; - -private: - void Init(); -#endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED -}; - - -#if defined(__WXUNIVERSAL__) - #include "wx/generic/bmpcbox.h" -#elif defined(__WXMSW__) - #include "wx/msw/bmpcbox.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/bmpcbox.h" -#else - #include "wx/generic/bmpcbox.h" -#endif - -#endif // wxUSE_BITMAPCOMBOBOX - -#endif // _WX_BMPCBOX_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/bookctrl.h b/Source/3rd Party/wx/include/wx/bookctrl.h index 55b7e9946..98a95dc6e 100644 --- a/Source/3rd Party/wx/include/wx/bookctrl.h +++ b/Source/3rd Party/wx/include/wx/bookctrl.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.08.03 +// RCS-ID: $Id: bookctrl.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -21,12 +22,11 @@ #include "wx/control.h" #include "wx/dynarray.h" -#include "wx/withimages.h" WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages); class WXDLLIMPEXP_FWD_CORE wxImageList; -class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent; +class WXDLLIMPEXP_FWD_CORE wxBookCtrlBaseEvent; // ---------------------------------------------------------------------------- // constants @@ -54,8 +54,7 @@ enum // wxBookCtrlBase // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBookCtrlBase : public wxControl, - public wxWithImages +class WXDLLEXPORT wxBookCtrlBase : public wxControl { public: // construction @@ -86,6 +85,9 @@ public: long style = 0, const wxString& name = wxEmptyString); + // dtor + virtual ~wxBookCtrlBase(); + // accessors // --------- @@ -94,7 +96,8 @@ public: virtual size_t GetPageCount() const { return m_pages.size(); } // get the panel which represents the given page - virtual wxWindow *GetPage(size_t n) const { return m_pages[n]; } + wxWindow *GetPage(size_t n) { return m_pages[n]; } + wxWindow *GetPage(size_t n) const { return m_pages[n]; } // get the current page or NULL if none wxWindow *GetCurrentPage() const @@ -104,7 +107,7 @@ public: } // get the currently selected page or wxNOT_FOUND if none - virtual int GetSelection() const { return m_selection; } + virtual int GetSelection() const = 0; // set/get the title of a page virtual bool SetPageText(size_t n, const wxString& strText) = 0; @@ -115,6 +118,15 @@ public: // images belong to the same image list) // --------------------------------------------------------------------- + // sets the image list to use, it is *not* deleted by the control + virtual void SetImageList(wxImageList *imageList); + + // as SetImageList() but we will delete the image list ourselves + void AssignImageList(wxImageList *imageList); + + // get pointer (may be NULL) to the associated image list + wxImageList* GetImageList() const { return m_imageList; } + // sets/returns item's image index in the current image list virtual int GetPageImage(size_t n) const = 0; virtual bool SetPageImage(size_t n, int imageId) = 0; @@ -126,14 +138,8 @@ public: // resize the notebook so that all pages will have the specified size virtual void SetPageSize(const wxSize& size); - // return the size of the area needed to accommodate the controller - wxSize GetControllerSize() const; - // calculate the size of the control from the size of its page - // - // by default this simply returns size enough to fit both the page and the - // controller - virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0; // get/set size of area between book control area and page area unsigned int GetInternalBorder() const { return m_internalBorder; } @@ -153,7 +159,6 @@ public: // returns the sizer containing the control, if any wxSizer* GetControlSizer() const { return m_controlSizer; } - // operations // ---------- @@ -170,7 +175,6 @@ public: // remove all pages and delete them virtual bool DeleteAllPages() { - m_selection = wxNOT_FOUND; DoInvalidateBestSize(); WX_CLEAR_ARRAY(m_pages); return true; @@ -180,7 +184,7 @@ public: virtual bool AddPage(wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE) + int imageId = -1) { DoInvalidateBestSize(); return InsertPage(GetPageCount(), page, text, bSelect, imageId); @@ -191,10 +195,10 @@ public: wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE) = 0; + int imageId = -1) = 0; // set the currently selected page, return the index of the previously - // selected one (or wxNOT_FOUND on error) + // selected one (or -1 on error) // // NB: this function will generate PAGE_CHANGING/ED events virtual int SetSelection(size_t n) = 0; @@ -207,16 +211,13 @@ public: void AdvanceSelection(bool forward = true) { int nPage = GetNextPage(forward); - if ( nPage != wxNOT_FOUND ) + if ( nPage != -1 ) { // cast is safe because of the check above SetSelection((size_t)nPage); } } - // return the index of the given page or wxNOT_FOUND - int FindPage(const wxWindow* page) const; - // hit test: returns which page is hit and, optionally, where (icon, label) virtual int HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(flags) = NULL) const @@ -228,11 +229,6 @@ public: // we do have multiple pages virtual bool HasMultiplePages() const { return true; } - // we don't want focus for ourselves - virtual bool AcceptsFocus() const { return false; } - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } protected: // flags for DoSetSelection() @@ -241,24 +237,6 @@ protected: SetSelection_SendEvent = 1 }; - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - // After the insertion of the page in the method InsertPage, calling this - // method sets the selection to the given page or the first one if there is - // still no selection. The "selection changed" event is sent only if - // bSelect is true, so when it is false, no event is sent even if the - // selection changed from wxNOT_FOUND to 0 when inserting the first page. - // - // Returns true if the selection was set to the specified page (explicitly - // because of bSelect == true or implicitly because it's the first page) or - // false otherwise. - bool DoSetSelectionAfterInsertion(size_t n, bool bSelect); - - // Update the selection after removing the page at the given index, - // typically called from the derived class overridden DoRemovePage(). - void DoSetSelectionAfterRemoval(size_t n); - // set the selection to the given page, sending the events (which can // possibly prevent the page change from taking place) if SendEvent flag is // included @@ -274,20 +252,15 @@ protected: { wxFAIL_MSG(wxT("Override this function!")); } // create a new "page changing" event - virtual wxBookCtrlEvent* CreatePageChangingEvent() const + virtual wxBookCtrlBaseEvent* CreatePageChangingEvent() const { wxFAIL_MSG(wxT("Override this function!")); return NULL; } // modify the event created by CreatePageChangingEvent() to "page changed" // event, usually by just calling SetEventType() on it - virtual void MakeChangedEvent(wxBookCtrlEvent& WXUNUSED(event)) + virtual void MakeChangedEvent(wxBookCtrlBaseEvent& WXUNUSED(event)) { wxFAIL_MSG(wxT("Override this function!")); } - // The derived class also may override the following method, also called - // from DoSetSelection(), to show/hide pages differently. - virtual void DoShowPage(wxWindow* page, bool show) { page->Show(show); } - - // Should we accept NULL page pointers in Add/InsertPage()? // // Default is no but derived classes may override it if they can treat NULL @@ -295,11 +268,7 @@ protected: // having nodes without any associated page) virtual bool AllowNullPage() const { return false; } - // Remove the page and return a pointer to it. - // - // It also needs to update the current selection if necessary, i.e. if the - // page being removed comes before the selected one and the helper method - // DoSetSelectionAfterRemoval() can be used for this. + // remove the page and return a pointer to it virtual wxWindow *DoRemovePage(size_t page) = 0; // our best size is the size which fits all our pages @@ -309,7 +278,7 @@ protected: int GetNextPage(bool forward) const; // Lay out controls - virtual void DoSize(); + void DoSize(); // This method also invalidates the size of the controller and should be // called instead of just InvalidateBestSize() whenever pages are added or @@ -325,10 +294,17 @@ protected: // the array of all pages of this control wxArrayPages m_pages; + // the associated image list or NULL + wxImageList *m_imageList; + + // true if we must delete m_imageList + bool m_ownsImageList; + // get the page area - virtual wxRect GetPageRect() const; + wxRect GetPageRect() const; // event handlers + virtual wxSize GetControllerSize() const; void OnSize(wxSizeEvent& event); // controller buddy if available, NULL otherwise (usually for native book controls like wxNotebook) @@ -343,11 +319,6 @@ protected: // the margin around the choice control int m_controlMargin; - // The currently selected page (in range 0..m_pages.size()-1 inclusive) or - // wxNOT_FOUND if none (this can normally only be the case for an empty - // control without any pages). - int m_selection; - private: // common part of all ctors @@ -357,81 +328,68 @@ private: unsigned int m_internalBorder; DECLARE_ABSTRACT_CLASS(wxBookCtrlBase) - wxDECLARE_NO_COPY_CLASS(wxBookCtrlBase); - + DECLARE_NO_COPY_CLASS(wxBookCtrlBase) DECLARE_EVENT_TABLE() }; // ---------------------------------------------------------------------------- -// wxBookCtrlEvent: page changing events generated by book classes +// wxBookCtrlBaseEvent: page changing events generated by derived classes // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBookCtrlEvent : public wxNotifyEvent +class WXDLLEXPORT wxBookCtrlBaseEvent : public wxNotifyEvent { public: - wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, - int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) + wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, + int nSel = -1, int nOldSel = -1) : wxNotifyEvent(commandType, winid) { m_nSel = nSel; m_nOldSel = nOldSel; } - wxBookCtrlEvent(const wxBookCtrlEvent& event) + wxBookCtrlBaseEvent(const wxBookCtrlBaseEvent& event) : wxNotifyEvent(event) { m_nSel = event.m_nSel; m_nOldSel = event.m_nOldSel; } - virtual wxEvent *Clone() const { return new wxBookCtrlEvent(*this); } - // accessors - // the currently selected page (wxNOT_FOUND if none) + // the currently selected page (-1 if none) int GetSelection() const { return m_nSel; } void SetSelection(int nSel) { m_nSel = nSel; } - // the page that was selected before the change (wxNOT_FOUND if none) + // the page that was selected before the change (-1 if none) int GetOldSelection() const { return m_nOldSel; } void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; } private: int m_nSel, // currently selected page m_nOldSel; // previously selected page - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxBookCtrlEvent) }; -typedef void (wxEvtHandler::*wxBookCtrlEventFunction)(wxBookCtrlEvent&); - -#define wxBookCtrlEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxBookCtrlEventFunction, func) - -// obsolete name, defined for compatibility only -#define wxBookCtrlBaseEvent wxBookCtrlEvent - // make a default book control for given platform #if wxUSE_NOTEBOOK // dedicated to majority of desktops #include "wx/notebook.h" #define wxBookCtrl wxNotebook - #define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED - #define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING + #define wxBookCtrlEvent wxNotebookEvent + #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED + #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING #define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_NOTEBOOK_PAGE_CHANGED(id, fn) #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_NOTEBOOK_PAGE_CHANGING(id, fn) + #define wxBookctrlEventHandler(func) wxNotebookEventHandler(func) #else // dedicated to Smartphones #include "wx/choicebk.h" #define wxBookCtrl wxChoicebook - #define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED - #define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING + #define wxBookCtrlEvent wxChoicebookEvent + #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED + #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING #define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_CHOICEBOOK_PAGE_CHANGED(id, fn) #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_CHOICEBOOK_PAGE_CHANGING(id, fn) + #define wxBookctrlEventHandler(func) wxChoicebookEventHandler(func) #endif -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_BOOKCTRL_PAGE_CHANGED -#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_BOOKCTRL_PAGE_CHANGING - #if WXWIN_COMPATIBILITY_2_6 #define wxBC_TOP wxBK_TOP #define wxBC_BOTTOM wxBK_BOTTOM diff --git a/Source/3rd Party/wx/include/wx/brush.h b/Source/3rd Party/wx/include/wx/brush.h index d26339f77..cf963ab2d 100644 --- a/Source/3rd Party/wx/include/wx/brush.h +++ b/Source/3rd Party/wx/include/wx/brush.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: brush.h 40865 2006-08-27 09:42:42Z VS $ // Copyright: Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -14,62 +15,22 @@ #include "wx/defs.h" #include "wx/object.h" #include "wx/gdiobj.h" -#include "wx/gdicmn.h" // for wxGDIObjListBase - -// NOTE: these values cannot be combined together! -enum wxBrushStyle -{ - wxBRUSHSTYLE_INVALID = -1, - - wxBRUSHSTYLE_SOLID = wxSOLID, - wxBRUSHSTYLE_TRANSPARENT = wxTRANSPARENT, - wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE, - wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK, - wxBRUSHSTYLE_STIPPLE = wxSTIPPLE, - wxBRUSHSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL, - wxBRUSHSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG, - wxBRUSHSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL, - wxBRUSHSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS, - wxBRUSHSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL, - wxBRUSHSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL, - wxBRUSHSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST, - wxBRUSHSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST -}; - // wxBrushBase -class WXDLLIMPEXP_CORE wxBrushBase: public wxGDIObject +class WXDLLEXPORT wxBrushBase: public wxGDIObject { public: virtual ~wxBrushBase() { } - virtual void SetColour(const wxColour& col) = 0; - virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0; - virtual void SetStyle(wxBrushStyle style) = 0; - virtual void SetStipple(const wxBitmap& stipple) = 0; - - virtual wxColour GetColour() const = 0; - virtual wxBrushStyle GetStyle() const = 0; - virtual wxBitmap *GetStipple() const = 0; + virtual int GetStyle() const = 0; virtual bool IsHatch() const - { return (GetStyle()>=wxBRUSHSTYLE_FIRST_HATCH) && (GetStyle()<=wxBRUSHSTYLE_LAST_HATCH); } - - // Convenient helpers for testing whether the brush is a transparent one: - // unlike GetStyle() == wxBRUSHSTYLE_TRANSPARENT, they work correctly even - // if the brush is invalid (they both return false in this case). - bool IsTransparent() const - { - return IsOk() && GetStyle() == wxBRUSHSTYLE_TRANSPARENT; - } - - bool IsNonTransparent() const - { - return IsOk() && GetStyle() != wxBRUSHSTYLE_TRANSPARENT; - } + { return (GetStyle()>=wxFIRST_HATCH) && (GetStyle()<=wxLAST_HATCH); } }; -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/palmos/brush.h" +#elif defined(__WXMSW__) #include "wx/msw/brush.h" #elif defined(__WXMOTIF__) || defined(__WXX11__) #include "wx/x11/brush.h" @@ -77,60 +38,17 @@ public: #include "wx/gtk/brush.h" #elif defined(__WXGTK__) #include "wx/gtk1/brush.h" +#elif defined(__WXMGL__) + #include "wx/mgl/brush.h" #elif defined(__WXDFB__) #include "wx/dfb/brush.h" #elif defined(__WXMAC__) - #include "wx/osx/brush.h" + #include "wx/mac/brush.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/brush.h" #elif defined(__WXPM__) #include "wx/os2/brush.h" #endif -class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase -{ -public: - wxBrush *FindOrCreateBrush(const wxColour& colour, - wxBrushStyle style = wxBRUSHSTYLE_SOLID); - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxBrush *FindOrCreateBrush(const wxColour& colour, int style) - { return FindOrCreateBrush(colour, (wxBrushStyle)style); } #endif - -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( void AddBrush(wxBrush*) ); - wxDEPRECATED( void RemoveBrush(wxBrush*) ); -#endif -}; - -extern WXDLLIMPEXP_DATA_CORE(wxBrushList*) wxTheBrushList; - -// provide comparison operators to allow code such as -// -// if ( brush.GetStyle() == wxTRANSPARENT ) -// -// to compile without warnings which it would otherwise provoke from some -// compilers as it compares elements of different enums -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - -// Unfortunately some compilers have ambiguity issues when enum comparisons are -// overloaded so we have to disable the overloads in this case, see -// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details. -#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM - -inline bool operator==(wxBrushStyle s, wxDeprecatedGUIConstants t) -{ - return static_cast(s) == static_cast(t); -} - -inline bool operator!=(wxBrushStyle s, wxDeprecatedGUIConstants t) -{ - return !(s == t); -} - -#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM - -#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 - -#endif // _WX_BRUSH_H_BASE_ + // _WX_BRUSH_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/buffer.h b/Source/3rd Party/wx/include/wx/buffer.h index 6df8030c0..f1ef1a23f 100644 --- a/Source/3rd Party/wx/include/wx/buffer.h +++ b/Source/3rd Party/wx/include/wx/buffer.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 12.04.99 +// RCS-ID: $Id: buffer.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,426 +12,144 @@ #ifndef _WX_BUFFER_H #define _WX_BUFFER_H -#include "wx/chartype.h" -#include "wx/wxcrtbase.h" +#include "wx/wxchar.h" #include // malloc() and free() -class WXDLLIMPEXP_FWD_BASE wxCStrData; - // ---------------------------------------------------------------------------- // Special classes for (wide) character strings: they use malloc/free instead // of new/delete // ---------------------------------------------------------------------------- -// helpers used by wxCharTypeBuffer -namespace wxPrivate -{ - -struct UntypedBufferData -{ - enum Kind - { - Owned, - NonOwned - }; - - UntypedBufferData(void *str, size_t len, Kind kind = Owned) - : m_str(str), m_length(len), m_ref(1), m_owned(kind == Owned) {} - - ~UntypedBufferData() - { - if ( m_owned ) - free(m_str); - } - - void *m_str; - size_t m_length; - - // "short" to have sizeof(Data)=12 on 32bit archs - unsigned short m_ref; - - bool m_owned; -}; - -// NB: this is defined in string.cpp and not the (non-existent) buffer.cpp -WXDLLIMPEXP_BASE UntypedBufferData * GetUntypedNullData(); - -} // namespace wxPrivate - - -// Reference-counted character buffer for storing string data. The buffer -// is only valid for as long as the "parent" object that provided the data -// is valid; see wxCharTypeBuffer for persistent variant. -template -class wxScopedCharTypeBuffer -{ -public: - typedef T CharType; - - wxScopedCharTypeBuffer() - { - m_data = GetNullData(); - } - - // Creates "non-owned" buffer, i.e. 'str' is not owned by the buffer - // and doesn't get freed by dtor. Used e.g. to point to wxString's internal - // storage. - static - const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str, - size_t len = wxNO_LEN) - { - if ( len == wxNO_LEN ) - len = wxStrlen(str); - - wxScopedCharTypeBuffer buf; - if ( str ) - buf.m_data = new Data(const_cast(str), len, Data::NonOwned); - return buf; - } - - // Creates "owned" buffer, i.e. takes over ownership of 'str' and frees it - // in dtor (if ref.count reaches 0). - static - const wxScopedCharTypeBuffer CreateOwned(CharType *str, - size_t len = wxNO_LEN ) - { - if ( len == wxNO_LEN ) - len = wxStrlen(str); - - wxScopedCharTypeBuffer buf; - if ( str ) - buf.m_data = new Data(str, len); - return buf; - } - - wxScopedCharTypeBuffer(const wxScopedCharTypeBuffer& src) - { - m_data = src.m_data; - IncRef(); - } - - wxScopedCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src) - { - if ( &src == this ) - return *this; - - DecRef(); - m_data = src.m_data; - IncRef(); - - return *this; - } - - ~wxScopedCharTypeBuffer() - { - DecRef(); - } - - // NB: this method is only const for backward compatibility. It used to - // be needed for auto_ptr-like semantics of the copy ctor, but now - // that ref-counting is used, it's not really needed. - CharType *release() const - { - if ( m_data == GetNullData() ) - return NULL; - - wxASSERT_MSG( m_data->m_owned, wxT("can't release non-owned buffer") ); - wxASSERT_MSG( m_data->m_ref == 1, wxT("can't release shared buffer") ); - - CharType * const p = m_data->Get(); - - wxScopedCharTypeBuffer *self = const_cast(this); - self->m_data->Set(NULL, 0); - self->DecRef(); - - return p; - } - - void reset() - { - DecRef(); - } - - CharType *data() { return m_data->Get(); } - const CharType *data() const { return m_data->Get(); } - operator const CharType *() const { return data(); } - CharType operator[](size_t n) const { return data()[n]; } - - size_t length() const { return m_data->m_length; } - -protected: - // reference-counted data - struct Data : public wxPrivate::UntypedBufferData - { - Data(CharType *str, size_t len, Kind kind = Owned) - : wxPrivate::UntypedBufferData(str, len, kind) - { - } - - CharType *Get() const { return static_cast(m_str); } - void Set(CharType *str, size_t len) - { - m_str = str; - m_length = len; - } - }; - - // placeholder for NULL string, to simplify this code - static Data *GetNullData() - { - return static_cast(wxPrivate::GetUntypedNullData()); - } - - void IncRef() - { - if ( m_data == GetNullData() ) // exception, not ref-counted - return; - m_data->m_ref++; - } - - void DecRef() - { - if ( m_data == GetNullData() ) // exception, not ref-counted - return; - if ( --m_data->m_ref == 0 ) - delete m_data; - m_data = GetNullData(); - } - - // sets this object to a be copy of 'other'; if 'src' is non-owned, - // a deep copy is made and 'this' will contain new instance of the data - void MakeOwnedCopyOf(const wxScopedCharTypeBuffer& src) - { - this->DecRef(); - - if ( src.m_data == this->GetNullData() ) - { - this->m_data = this->GetNullData(); - } - else if ( src.m_data->m_owned ) - { - this->m_data = src.m_data; - this->IncRef(); - } - else - { - // if the scoped buffer had non-owned data, we have to make - // a copy here, because src.m_data->m_str is valid only for as long - // as 'src' exists - this->m_data = new Data - ( - StrCopy(src.data(), src.length()), - src.length() - ); - } - } - - static CharType *StrCopy(const CharType *src, size_t len) - { - CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1)); - if ( dst ) - memcpy(dst, src, sizeof(CharType) * (len + 1)); - return dst; - } - -protected: - Data *m_data; -}; - -typedef wxScopedCharTypeBuffer wxScopedCharBuffer; -typedef wxScopedCharTypeBuffer wxScopedWCharBuffer; - - -// this buffer class always stores data in "owned" (persistent) manner -template -class wxCharTypeBuffer : public wxScopedCharTypeBuffer -{ -protected: - typedef typename wxScopedCharTypeBuffer::Data Data; - -public: - typedef T CharType; - - wxCharTypeBuffer(const CharType *str = NULL, size_t len = wxNO_LEN) - { - if ( str ) - { - if ( len == wxNO_LEN ) - len = wxStrlen(str); - this->m_data = new Data(this->StrCopy(str, len), len); - } - else - { - this->m_data = this->GetNullData(); - } - } - - wxCharTypeBuffer(size_t len) - { - CharType* const str = (CharType *)malloc((len + 1)*sizeof(CharType)); - if ( str ) - { - str[len] = (CharType)0; - - // There is a potential memory leak here if new throws because it - // fails to allocate Data, we ought to use new(nothrow) here, but - // this might fail to compile under some platforms so until this - // can be fully tested, just live with this (rather unlikely, as - // Data is a small object) potential leak. - this->m_data = new Data(str, len); - } - else - { - this->m_data = this->GetNullData(); - } - } - - wxCharTypeBuffer(const wxCharTypeBuffer& src) - : wxScopedCharTypeBuffer(src) {} - - wxCharTypeBuffer& operator=(const CharType *str) - { - this->DecRef(); - - if ( str ) - this->m_data = new Data(wxStrdup(str), wxStrlen(str)); - return *this; - } - - wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src) - { - wxScopedCharTypeBuffer::operator=(src); - return *this; - } - - wxCharTypeBuffer(const wxScopedCharTypeBuffer& src) - { - this->MakeOwnedCopyOf(src); - } - - wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src) - { - MakeOwnedCopyOf(src); - return *this; - } - - bool extend(size_t len) - { - wxASSERT_MSG( this->m_data->m_owned, "cannot extend non-owned buffer" ); - wxASSERT_MSG( this->m_data->m_ref == 1, "can't extend shared buffer" ); - - CharType *str = - (CharType *)realloc(this->data(), (len + 1) * sizeof(CharType)); - if ( !str ) - return false; - - // For consistency with the ctor taking just the length, NUL-terminate - // the buffer. - str[len] = (CharType)0; - - if ( this->m_data == this->GetNullData() ) - { - this->m_data = new Data(str, len); - } - else - { - this->m_data->Set(str, len); - this->m_data->m_owned = true; - } - - return true; - } - - void shrink(size_t len) - { - wxASSERT_MSG( this->m_data->m_owned, "cannot shrink non-owned buffer" ); - wxASSERT_MSG( this->m_data->m_ref == 1, "can't shrink shared buffer" ); - - wxASSERT( len <= this->length() ); - - this->m_data->m_length = len; - this->data()[len] = 0; - } -}; - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer ) -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) - -class wxCharBuffer : public wxCharTypeBuffer -{ -public: - typedef wxCharTypeBuffer wxCharTypeBufferBase; - typedef wxScopedCharTypeBuffer wxScopedCharTypeBufferBase; - - wxCharBuffer(const wxCharTypeBufferBase& buf) - : wxCharTypeBufferBase(buf) {} - wxCharBuffer(const wxScopedCharTypeBufferBase& buf) - : wxCharTypeBufferBase(buf) {} - - wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {} - wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {} - - wxCharBuffer(const wxCStrData& cstr); -}; - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer ) -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) - -class wxWCharBuffer : public wxCharTypeBuffer -{ -public: - typedef wxCharTypeBuffer wxCharTypeBufferBase; - typedef wxScopedCharTypeBuffer wxScopedCharTypeBufferBase; - - wxWCharBuffer(const wxCharTypeBufferBase& buf) - : wxCharTypeBufferBase(buf) {} - wxWCharBuffer(const wxScopedCharTypeBufferBase& buf) - : wxCharTypeBufferBase(buf) {} - - wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {} - wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {} - - wxWCharBuffer(const wxCStrData& cstr); -}; - -// wxCharTypeBuffer implicitly convertible to T* -template -class wxWritableCharTypeBuffer : public wxCharTypeBuffer -{ -public: - typedef typename wxScopedCharTypeBuffer::CharType CharType; - - wxWritableCharTypeBuffer(const wxScopedCharTypeBuffer& src) - : wxCharTypeBuffer(src) {} - // FIXME-UTF8: this won't be needed after converting mb_str()/wc_str() to - // always return a buffer - // + we should derive this class from wxScopedCharTypeBuffer - // then - wxWritableCharTypeBuffer(const CharType *str = NULL) - : wxCharTypeBuffer(str) {} - - operator CharType*() { return this->data(); } -}; - -typedef wxWritableCharTypeBuffer wxWritableCharBuffer; -typedef wxWritableCharTypeBuffer wxWritableWCharBuffer; - +#define DEFINE_BUFFER(classname, chartype, strdupfunc) \ +class WXDLLIMPEXP_BASE classname \ +{ \ +public: \ + classname(const chartype *str = NULL) \ + : m_str(str ? strdupfunc(str) : NULL) \ + { \ + } \ + \ + classname(size_t len) \ + : m_str((chartype *)malloc((len + 1)*sizeof(chartype))) \ + { \ + m_str[len] = (chartype)0; \ + } \ + \ + /* no need to check for NULL, free() does it */ \ + ~classname() { free(m_str); } \ + \ + /* \ + WARNING: \ + \ + the copy ctor and assignment operators change the passed in object \ + even although it is declared as "const", so: \ + \ + a) it shouldn't be really const \ + b) you shouldn't use it afterwards (or know that it was reset) \ + \ + This is very ugly but is unfortunately needed to make the normal use\ + of classname buffer objects possible and is very similar to what \ + std::auto_ptr<> does (as if it were an excuse...) \ + */ \ + \ + /* \ + because of the remark above, release() is declared const even if it \ + isn't really const \ + */ \ + chartype *release() const \ + { \ + chartype *p = m_str; \ + ((classname *)this)->m_str = NULL; \ + return p; \ + } \ + \ + void reset() \ + { \ + free(m_str); \ + m_str = NULL; \ + } \ + \ + classname(const classname& src) \ + : m_str(src.release()) \ + { \ + } \ + \ + classname& operator=(const chartype *str) \ + { \ + free(m_str); \ + m_str = str ? strdupfunc(str) : NULL; \ + return *this; \ + } \ + \ + classname& operator=(const classname& src) \ + { \ + free(m_str); \ + m_str = src.release(); \ + \ + return *this; \ + } \ + \ + bool extend(size_t len) \ + { \ + chartype * \ + str = (chartype *)realloc(m_str, (len + 1)*sizeof(chartype)); \ + if ( !str ) \ + return false; \ + \ + m_str = str; \ + \ + return true; \ + } \ + \ + chartype *data() { return m_str; } \ + const chartype *data() const { return m_str; } \ + operator const chartype *() const { return m_str; } \ + chartype operator[](size_t n) const { return m_str[n]; } \ + \ +private: \ + chartype *m_str; \ +} + +#if wxABI_VERSION >= 20804 +// needed for wxString::char_str() and wchar_str() +#define DEFINE_WRITABLE_BUFFER(classname, baseclass, chartype) \ +class WXDLLIMPEXP_BASE classname : public baseclass \ +{ \ +public: \ + classname(const baseclass& src) : baseclass(src) {} \ + classname(const chartype *str = NULL) : baseclass(str) {} \ + \ + operator chartype*() { return this->data(); } \ +} +#endif // wxABI_VERSION >= 20804 + +DEFINE_BUFFER(wxCharBuffer, char, wxStrdupA); +#if wxABI_VERSION >= 20804 +DEFINE_WRITABLE_BUFFER(wxWritableCharBuffer, wxCharBuffer, char); +#endif + +#if wxUSE_WCHAR_T + +DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW); +#if wxABI_VERSION >= 20804 +DEFINE_WRITABLE_BUFFER(wxWritableWCharBuffer, wxWCharBuffer, wchar_t); +#endif + +#endif // wxUSE_WCHAR_T + +#undef DEFINE_BUFFER +#undef DEFINE_WRITABLE_BUFFER #if wxUSE_UNICODE - #define wxWxCharBuffer wxWCharBuffer + typedef wxWCharBuffer wxWxCharBuffer; #define wxMB2WXbuf wxWCharBuffer #define wxWX2MBbuf wxCharBuffer - #if wxUSE_UNICODE_WCHAR - #define wxWC2WXbuf wxChar* - #define wxWX2WCbuf wxChar* - #elif wxUSE_UNICODE_UTF8 - #define wxWC2WXbuf wxWCharBuffer - #define wxWX2WCbuf wxWCharBuffer - #endif + #define wxWC2WXbuf wxChar* + #define wxWX2WCbuf wxChar* #else // ANSI - #define wxWxCharBuffer wxCharBuffer + typedef wxCharBuffer wxWxCharBuffer; #define wxMB2WXbuf wxChar* #define wxWX2MBbuf wxChar* @@ -451,7 +170,7 @@ public: friend class wxMemoryBuffer; - // everything is private as it can only be used by wxMemoryBuffer + // everyting is private as it can only be used by wxMemoryBuffer private: wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize) : m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0) @@ -483,21 +202,6 @@ private: delete this; } - void *release() - { - if ( m_data == NULL ) - return NULL; - - wxASSERT_MSG( m_ref == 1, "can't release shared buffer" ); - - void *p = m_data; - m_data = NULL; - m_len = - m_size = 0; - - return p; - } - // the buffer containing the data void *m_data; @@ -511,7 +215,7 @@ private: // the reference count size_t m_ref; - wxDECLARE_NO_COPY_CLASS(wxMemoryBufferData); + DECLARE_NO_COPY_CLASS(wxMemoryBufferData) }; @@ -537,12 +241,9 @@ public: wxMemoryBuffer& operator=(const wxMemoryBuffer& src) { - if (&src != this) - { - m_bufdata->DecRef(); - m_bufdata = src.m_bufdata; - m_bufdata->IncRef(); - } + m_bufdata->DecRef(); + m_bufdata = src.m_bufdata; + m_bufdata->IncRef(); return *this; } @@ -552,8 +253,6 @@ public: size_t GetBufSize() const { return m_bufdata->m_size; } size_t GetDataLen() const { return m_bufdata->m_len; } - bool IsEmpty() const { return GetDataLen() == 0; } - void SetBufSize(size_t size) { m_bufdata->ResizeIfNeeded(size); } void SetDataLen(size_t len) { @@ -561,8 +260,6 @@ public: m_bufdata->m_len = len; } - void Clear() { SetDataLen(0); } - // Ensure the buffer is big enough and return a pointer to it void *GetWriteBuf(size_t sizeNeeded) { @@ -604,13 +301,6 @@ public: operator const char *() const { return (const char*)GetData(); } - // gives up ownership of data, returns the pointer; after this call, - // data isn't freed by the buffer and its content is resent to empty - void *release() - { - return m_bufdata->release(); - } - private: wxMemoryBufferData* m_bufdata; }; diff --git a/Source/3rd Party/wx/include/wx/build.h b/Source/3rd Party/wx/include/wx/build.h index 79237d2b7..f6f5b0e22 100644 --- a/Source/3rd Party/wx/include/wx/build.h +++ b/Source/3rd Party/wx/include/wx/build.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin, Vaclav Slavik // Modified by: // Created: 07.05.02 +// RCS-ID: $Id: build.h 35858 2005-10-09 15:48:42Z MBN $ // Copyright: (c) 2002 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,7 +15,7 @@ #include "wx/version.h" // NB: This file contains macros for checking binary compatibility of libraries -// in multilib builds, plugins and user components. +// in multilib buildm, plugins and user components. // The WX_BUILD_OPTIONS_SIGNATURE macro expands into string that should // uniquely identify binary compatible builds: i.e. if two builds of the // library are binary compatible, their signature string should be the @@ -41,10 +42,14 @@ __WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y) "." __WX_BO_STRINGIZE(z) #endif -#if wxUSE_UNICODE_UTF8 - #define __WX_BO_UNICODE "UTF-8" -#elif wxUSE_UNICODE_WCHAR - #define __WX_BO_UNICODE "wchar_t" +#ifdef __WXDEBUG__ + #define __WX_BO_DEBUG "debug" +#else + #define __WX_BO_DEBUG "no debug" +#endif + +#if wxUSE_UNICODE + #define __WX_BO_UNICODE "Unicode" #else #define __WX_BO_UNICODE "ANSI" #endif @@ -54,16 +59,13 @@ #if defined(__GXX_ABI_VERSION) #define __WX_BO_COMPILER \ ",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION) +#elif defined(__INTEL_COMPILER) + #define __WX_BO_COMPILER ",Intel C++" #elif defined(__GNUG__) #define __WX_BO_COMPILER ",GCC " \ __WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__) #elif defined(__VISUALC__) - #define __WX_BO_COMPILER ",Visual C++ " __WX_BO_STRINGIZE(_MSC_VER) -#elif defined(__INTEL_COMPILER) - // Notice that this must come after MSVC check as ICC under Windows is - // ABI-compatible with the corresponding version of the MSVC and we want to - // allow using it compile the application code using MSVC-built DLLs. - #define __WX_BO_COMPILER ",Intel C++" + #define __WX_BO_COMPILER ",Visual C++" #elif defined(__BORLANDC__) #define __WX_BO_COMPILER ",Borland C++" #elif defined(__DIGITALMARS__) @@ -75,19 +77,19 @@ #endif // WXWIN_COMPATIBILITY macros affect presence of virtual functions +#if WXWIN_COMPATIBILITY_2_4 + #define __WX_BO_WXWIN_COMPAT_2_4 ",compatible with 2.4" +#else + #define __WX_BO_WXWIN_COMPAT_2_4 +#endif #if WXWIN_COMPATIBILITY_2_6 #define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6" #else #define __WX_BO_WXWIN_COMPAT_2_6 #endif -#if WXWIN_COMPATIBILITY_2_8 - #define __WX_BO_WXWIN_COMPAT_2_8 ",compatible with 2.8" -#else - #define __WX_BO_WXWIN_COMPAT_2_8 -#endif // deriving wxWin containers from STL ones changes them completely: -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #define __WX_BO_STL ",STL containers" #else #define __WX_BO_STL ",wx containers" @@ -96,10 +98,10 @@ // This macro is passed as argument to wxConsoleApp::CheckBuildOptions() #define WX_BUILD_OPTIONS_SIGNATURE \ __WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \ - " (" __WX_BO_UNICODE \ + " (" __WX_BO_DEBUG "," __WX_BO_UNICODE \ __WX_BO_COMPILER \ __WX_BO_STL \ - __WX_BO_WXWIN_COMPAT_2_6 __WX_BO_WXWIN_COMPAT_2_8 \ + __WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 \ ")" @@ -108,7 +110,7 @@ // ---------------------------------------------------------------------------- // Use this macro to check build options. Adding it to a file in DLL will -// ensure that the DLL checks build options in same way wxIMPLEMENT_APP() does. +// ensure that the DLL checks build options in same way IMPLEMENT_APP() does. #define WX_CHECK_BUILD_OPTIONS(libName) \ static struct wxBuildOptionsChecker \ { \ @@ -120,4 +122,28 @@ } gs_buildOptionsCheck; +#if WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// wxBuildOptions +// ---------------------------------------------------------------------------- + +// NB: Don't use this class in new code, it relies on the ctor being always +// inlined. WX_BUILD_OPTIONS_SIGNATURE always works. +class wxBuildOptions +{ +public: + // the ctor must be inline to get the compilation settings of the code + // which included this header + wxBuildOptions() : m_signature(WX_BUILD_OPTIONS_SIGNATURE) {} + +private: + const char *m_signature; + + // actually only CheckBuildOptions() should be our friend but well... + friend class wxAppConsole; +}; + +#endif // WXWIN_COMPATIBILITY_2_4 + #endif // _WX_BUILD_H_ diff --git a/Source/3rd Party/wx/include/wx/busyinfo.h b/Source/3rd Party/wx/include/wx/busyinfo.h index 5d3b6edf9..d13d3b68c 100644 --- a/Source/3rd Party/wx/include/wx/busyinfo.h +++ b/Source/3rd Party/wx/include/wx/busyinfo.h @@ -3,6 +3,7 @@ // Purpose: Information window (when app is busy) // Author: Vaclav Slavik // Copyright: (c) 1999 Vaclav Slavik +// RCS-ID: $Id: busyinfo.h 37158 2006-01-26 15:40:46Z ABX $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/button.h b/Source/3rd Party/wx/include/wx/button.h index 87a35f9f8..4ca2305ae 100644 --- a/Source/3rd Party/wx/include/wx/button.h +++ b/Source/3rd Party/wx/include/wx/button.h @@ -4,6 +4,7 @@ // Author: Vadim Zetlin // Modified by: // Created: 15.08.00 +// RCS-ID: $Id: button.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Vadim Zetlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,37 +14,70 @@ #include "wx/defs.h" +// ---------------------------------------------------------------------------- +// wxButton flags shared with other classes +// ---------------------------------------------------------------------------- + +#if wxUSE_TOGGLEBTN || wxUSE_BUTTON + +// These flags affect label alignment +#define wxBU_LEFT 0x0040 +#define wxBU_TOP 0x0080 +#define wxBU_RIGHT 0x0100 +#define wxBU_BOTTOM 0x0200 +#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM ) +#endif + #if wxUSE_BUTTON -#include "wx/anybutton.h" +// ---------------------------------------------------------------------------- +// wxButton specific flags +// ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; +// These two flags are obsolete +#define wxBU_NOAUTODRAW 0x0000 +#define wxBU_AUTODRAW 0x0004 + +// by default, the buttons will be created with some (system dependent) +// minimal size to make them look nicer, giving this style will make them as +// small as possible +#define wxBU_EXACTFIT 0x0001 + +#include "wx/control.h" + +class WXDLLIMPEXP_FWD_CORE wxBitmap; + +extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[]; // ---------------------------------------------------------------------------- // wxButton: a push button // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxButtonBase : public wxAnyButton +class WXDLLEXPORT wxButtonBase : public wxControl { public: wxButtonBase() { } - // show the authentication needed symbol on the button: this is currently - // only implemented on Windows Vista and newer (on which it shows the UAC - // shield symbol) - void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); } - bool GetAuthNeeded() const { return DoGetAuthNeeded(); } + // show the image in the button in addition to the label + virtual void SetImageLabel(const wxBitmap& WXUNUSED(bitmap)) { } - // make this button the default button in its top level window - // - // returns the old default item (possibly NULL) - virtual wxWindow *SetDefault(); + // set the margins around the image + virtual void SetImageMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { } + + // this wxButton method is called when the button becomes the default one + // on its panel + virtual void SetDefault() { } + + // Buttons on MSW can look bad if they are not native colours, because + // then they become owner-drawn and not theme-drawn. Disable it here + // in wxButtonBase to make it consistent. + virtual bool ShouldInheritColours() const { return false; } // returns the default button size for this platform static wxSize GetDefaultSize(); protected: - wxDECLARE_NO_COPY_CLASS(wxButtonBase); + DECLARE_NO_COPY_CLASS(wxButtonBase) }; #if defined(__WXUNIVERSAL__) @@ -57,13 +91,16 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/button.h" #elif defined(__WXMAC__) - #include "wx/osx/button.h" + #include "wx/mac/button.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/button.h" #elif defined(__WXPM__) #include "wx/os2/button.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/button.h" #endif #endif // wxUSE_BUTTON -#endif // _WX_BUTTON_H_BASE_ +#endif + // _WX_BUTTON_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/calctrl.h b/Source/3rd Party/wx/include/wx/calctrl.h deleted file mode 100644 index 16a84748d..000000000 --- a/Source/3rd Party/wx/include/wx/calctrl.h +++ /dev/null @@ -1,396 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/calctrl.h -// Purpose: date-picker control -// Author: Vadim Zeitlin -// Modified by: -// Created: 29.12.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CALCTRL_H_ -#define _WX_CALCTRL_H_ - -#include "wx/defs.h" - -#if wxUSE_CALENDARCTRL - -#include "wx/dateevt.h" -#include "wx/colour.h" -#include "wx/font.h" -#include "wx/control.h" - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl flags -// ---------------------------------------------------------------------------- - -enum -{ - // show Sunday as the first day of the week (default) - wxCAL_SUNDAY_FIRST = 0x0000, - - // show Monday as the first day of the week - wxCAL_MONDAY_FIRST = 0x0001, - - // highlight holidays - wxCAL_SHOW_HOLIDAYS = 0x0002, - - // disable the year change control, show only the month change one - // deprecated - wxCAL_NO_YEAR_CHANGE = 0x0004, - - // don't allow changing neither month nor year (implies - // wxCAL_NO_YEAR_CHANGE) - wxCAL_NO_MONTH_CHANGE = 0x000c, - - // use MS-style month-selection instead of combo-spin combination - wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010, - - // show the neighbouring weeks in the previous and next month - wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020, - - // show week numbers on the left side of the calendar. - wxCAL_SHOW_WEEK_NUMBERS = 0x0040 -}; - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// return values for the HitTest() method -enum wxCalendarHitTestResult -{ - wxCAL_HITTEST_NOWHERE, // outside of anything - wxCAL_HITTEST_HEADER, // on the header (weekdays) - wxCAL_HITTEST_DAY, // on a day in the calendar - wxCAL_HITTEST_INCMONTH, - wxCAL_HITTEST_DECMONTH, - wxCAL_HITTEST_SURROUNDING_WEEK, - wxCAL_HITTEST_WEEK -}; - -// border types for a date -enum wxCalendarDateBorder -{ - wxCAL_BORDER_NONE, // no border (default) - wxCAL_BORDER_SQUARE, // a rectangular border - wxCAL_BORDER_ROUND // a round border -}; - -// ---------------------------------------------------------------------------- -// wxCalendarDateAttr: custom attributes for a calendar date -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxCalendarDateAttr -{ -public: - // ctors - wxCalendarDateAttr(const wxColour& colText = wxNullColour, - const wxColour& colBack = wxNullColour, - const wxColour& colBorder = wxNullColour, - const wxFont& font = wxNullFont, - wxCalendarDateBorder border = wxCAL_BORDER_NONE) - : m_colText(colText), m_colBack(colBack), - m_colBorder(colBorder), m_font(font) - { - Init(border); - } - wxCalendarDateAttr(wxCalendarDateBorder border, - const wxColour& colBorder = wxNullColour) - : m_colBorder(colBorder) - { - Init(border); - } - - // setters - void SetTextColour(const wxColour& colText) { m_colText = colText; } - void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } - void SetBorderColour(const wxColour& col) { m_colBorder = col; } - void SetFont(const wxFont& font) { m_font = font; } - void SetBorder(wxCalendarDateBorder border) { m_border = border; } - void SetHoliday(bool holiday) { m_holiday = holiday; } - - // accessors - bool HasTextColour() const { return m_colText.IsOk(); } - bool HasBackgroundColour() const { return m_colBack.IsOk(); } - bool HasBorderColour() const { return m_colBorder.IsOk(); } - bool HasFont() const { return m_font.IsOk(); } - bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; } - - bool IsHoliday() const { return m_holiday; } - - const wxColour& GetTextColour() const { return m_colText; } - const wxColour& GetBackgroundColour() const { return m_colBack; } - const wxColour& GetBorderColour() const { return m_colBorder; } - const wxFont& GetFont() const { return m_font; } - wxCalendarDateBorder GetBorder() const { return m_border; } - - // get or change the "mark" attribute, i.e. the one used for the items - // marked with wxCalendarCtrl::Mark() - static const wxCalendarDateAttr& GetMark() { return m_mark; } - static void SetMark(wxCalendarDateAttr const& m) { m_mark = m; } - -protected: - void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) - { - m_border = border; - m_holiday = false; - } - -private: - static wxCalendarDateAttr m_mark; - - wxColour m_colText, - m_colBack, - m_colBorder; - wxFont m_font; - wxCalendarDateBorder m_border; - bool m_holiday; -}; - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl events -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_ADV wxCalendarCtrl; - -class WXDLLIMPEXP_ADV wxCalendarEvent : public wxDateEvent -{ -public: - wxCalendarEvent() : m_wday(wxDateTime::Inv_WeekDay) { } - wxCalendarEvent(wxWindow *win, const wxDateTime& dt, wxEventType type) - : wxDateEvent(win, dt, type), - m_wday(wxDateTime::Inv_WeekDay) { } - wxCalendarEvent(const wxCalendarEvent& event) - : wxDateEvent(event), m_wday(event.m_wday) { } - - void SetWeekDay(const wxDateTime::WeekDay wd) { m_wday = wd; } - wxDateTime::WeekDay GetWeekDay() const { return m_wday; } - - virtual wxEvent *Clone() const { return new wxCalendarEvent(*this); } - -private: - wxDateTime::WeekDay m_wday; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalendarEvent) -}; - -// ---------------------------------------------------------------------------- -// wxCalendarCtrlBase -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxCalendarCtrlBase : public wxControl -{ -public: - // do we allow changing the month/year? - bool AllowMonthChange() const { return !HasFlag(wxCAL_NO_MONTH_CHANGE); } - - // get/set the current date - virtual wxDateTime GetDate() const = 0; - virtual bool SetDate(const wxDateTime& date) = 0; - - - // restricting the dates shown by the control to the specified range: only - // implemented in the generic and MSW versions for now - - // if either date is set, the corresponding limit will be enforced and true - // returned; if none are set, the existing restrictions are removed and - // false is returned - virtual bool - SetDateRange(const wxDateTime& WXUNUSED(lowerdate) = wxDefaultDateTime, - const wxDateTime& WXUNUSED(upperdate) = wxDefaultDateTime) - { - return false; - } - - // retrieves the limits currently in use (wxDefaultDateTime if none) in the - // provided pointers (which may be NULL) and returns true if there are any - // limits or false if none - virtual bool - GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const - { - if ( lowerdate ) - *lowerdate = wxDefaultDateTime; - if ( upperdate ) - *upperdate = wxDefaultDateTime; - return false; - } - - // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd - // with the corresponding value (none for NOWHERE, the date for DAY and wd - // for HEADER) - // - // notice that this is not implemented in all versions - virtual wxCalendarHitTestResult - HitTest(const wxPoint& WXUNUSED(pos), - wxDateTime* WXUNUSED(date) = NULL, - wxDateTime::WeekDay* WXUNUSED(wd) = NULL) - { - return wxCAL_HITTEST_NOWHERE; - } - - // allow or disable changing the current month (and year), return true if - // the value of this option really changed or false if it was already set - // to the required value - // - // NB: we provide implementation for this pure virtual function, derived - // classes should call it - virtual bool EnableMonthChange(bool enable = true) = 0; - - - // an item without custom attributes is drawn with the default colours and - // font and without border, setting custom attributes allows to modify this - // - // the day parameter should be in 1..31 range, for days 29, 30, 31 the - // corresponding attribute is just unused if there is no such day in the - // current month - // - // notice that currently arbitrary attributes are supported only in the - // generic version, the native controls only support Mark() which assigns - // some special appearance (which can be customized using SetMark() for the - // generic version) to the given day - - virtual void Mark(size_t day, bool mark) = 0; - - virtual wxCalendarDateAttr *GetAttr(size_t WXUNUSED(day)) const - { return NULL; } - virtual void SetAttr(size_t WXUNUSED(day), wxCalendarDateAttr *attr) - { delete attr; } - virtual void ResetAttr(size_t WXUNUSED(day)) { } - - - // holidays support - // - // currently only the generic version implements all functions in this - // section; wxMSW implements simple support for holidays (they can be - // just enabled or disabled) and wxGTK doesn't support them at all - - // equivalent to changing wxCAL_SHOW_HOLIDAYS flag but should be called - // instead of just changing it - virtual void EnableHolidayDisplay(bool display = true); - - // set/get the colours to use for holidays (if they're enabled) - virtual void SetHolidayColours(const wxColour& WXUNUSED(colFg), - const wxColour& WXUNUSED(colBg)) { } - - virtual const wxColour& GetHolidayColourFg() const { return wxNullColour; } - virtual const wxColour& GetHolidayColourBg() const { return wxNullColour; } - - // mark the given day of the current month as being a holiday - virtual void SetHoliday(size_t WXUNUSED(day)) { } - - - // customizing the colours of the controls - // - // most of the methods in this section are only implemented by the native - // version of the control and do nothing in the native ones - - // set/get the colours to use for the display of the week day names at the - // top of the controls - virtual void SetHeaderColours(const wxColour& WXUNUSED(colFg), - const wxColour& WXUNUSED(colBg)) { } - - virtual const wxColour& GetHeaderColourFg() const { return wxNullColour; } - virtual const wxColour& GetHeaderColourBg() const { return wxNullColour; } - - // set/get the colours used for the currently selected date - virtual void SetHighlightColours(const wxColour& WXUNUSED(colFg), - const wxColour& WXUNUSED(colBg)) { } - - virtual const wxColour& GetHighlightColourFg() const { return wxNullColour; } - virtual const wxColour& GetHighlightColourBg() const { return wxNullColour; } - - - // implementation only from now on - - // generate the given calendar event, return true if it was processed - // - // NB: this is public because it's used from GTK+ callbacks - bool GenerateEvent(wxEventType type) - { - wxCalendarEvent event(this, GetDate(), type); - return HandleWindowEvent(event); - } - -protected: - // generate all the events for the selection change from dateOld to current - // date: SEL_CHANGED, PAGE_CHANGED if necessary and also one of (deprecated) - // YEAR/MONTH/DAY_CHANGED ones - // - // returns true if page changed event was generated, false if the new date - // is still in the same month as before - bool GenerateAllChangeEvents(const wxDateTime& dateOld); - - // call SetHoliday() for all holidays in the current month - // - // should be called on month change, does nothing if wxCAL_SHOW_HOLIDAYS is - // not set and returns false in this case, true if we do show them - bool SetHolidayAttrs(); - - // called by SetHolidayAttrs() to forget the previously set holidays - virtual void ResetHolidayAttrs() { } - - // called by EnableHolidayDisplay() - virtual void RefreshHolidays() { } -}; - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl -// ---------------------------------------------------------------------------- - -#define wxCalendarNameStr "CalendarCtrl" - -#ifndef __WXUNIVERSAL__ - #if defined(__WXGTK20__) - #define wxHAS_NATIVE_CALENDARCTRL - #include "wx/gtk/calctrl.h" - #define wxCalendarCtrl wxGtkCalendarCtrl - #elif defined(__WXMSW__) - #define wxHAS_NATIVE_CALENDARCTRL - #include "wx/msw/calctrl.h" - #endif -#endif // !__WXUNIVERSAL__ - -#ifndef wxHAS_NATIVE_CALENDARCTRL - #include "wx/generic/calctrlg.h" - #define wxCalendarCtrl wxGenericCalendarCtrl -#endif - -// ---------------------------------------------------------------------------- -// calendar event types and macros for handling them -// ---------------------------------------------------------------------------- - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_SEL_CHANGED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_PAGE_CHANGED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DOUBLECLICKED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_WEEKDAY_CLICKED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_WEEK_CLICKED, wxCalendarEvent ); - -// deprecated events -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DAY_CHANGED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_MONTH_CHANGED, wxCalendarEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALENDAR_YEAR_CHANGED, wxCalendarEvent ); - -typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&); - -#define wxCalendarEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxCalendarEventFunction, func) - -#define wx__DECLARE_CALEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_CALENDAR_ ## evt, id, wxCalendarEventHandler(fn)) - -#define EVT_CALENDAR(id, fn) wx__DECLARE_CALEVT(DOUBLECLICKED, id, fn) -#define EVT_CALENDAR_SEL_CHANGED(id, fn) wx__DECLARE_CALEVT(SEL_CHANGED, id, fn) -#define EVT_CALENDAR_PAGE_CHANGED(id, fn) wx__DECLARE_CALEVT(PAGE_CHANGED, id, fn) -#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEKDAY_CLICKED, id, fn) -#define EVT_CALENDAR_WEEK_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEK_CLICKED, id, fn) - -// deprecated events -#define EVT_CALENDAR_DAY(id, fn) wx__DECLARE_CALEVT(DAY_CHANGED, id, fn) -#define EVT_CALENDAR_MONTH(id, fn) wx__DECLARE_CALEVT(MONTH_CHANGED, id, fn) -#define EVT_CALENDAR_YEAR(id, fn) wx__DECLARE_CALEVT(YEAR_CHANGED, id, fn) - -#endif // wxUSE_CALENDARCTRL - -#endif // _WX_CALCTRL_H_ - diff --git a/Source/3rd Party/wx/include/wx/caret.h b/Source/3rd Party/wx/include/wx/caret.h index 63802cf31..848fdcf73 100644 --- a/Source/3rd Party/wx/include/wx/caret.h +++ b/Source/3rd Party/wx/include/wx/caret.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 23.05.99 +// RCS-ID: $Id: caret.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -33,7 +34,7 @@ class WXDLLIMPEXP_FWD_CORE wxWindowBase; // appear. It can be either a solid block or a custom bitmap (TODO) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCaretBase +class WXDLLEXPORT wxCaretBase { public: // ctors @@ -146,7 +147,7 @@ public: virtual void OnKillFocus() { } protected: - // these functions may be overridden in the derived classes, but they + // these functions may be overriden in the derived classes, but they // should call the base class version first virtual bool DoCreate(wxWindowBase *window, int width, int height) { @@ -166,7 +167,7 @@ protected: // the common initialization void Init() { - m_window = NULL; + m_window = (wxWindowBase *)NULL; m_x = m_y = 0; m_width = m_height = 0; m_countVisible = 0; @@ -185,7 +186,7 @@ protected: int m_countVisible; private: - wxDECLARE_NO_COPY_CLASS(wxCaretBase); + DECLARE_NO_COPY_CLASS(wxCaretBase) }; // --------------------------------------------------------------------------- @@ -207,17 +208,17 @@ private: #ifdef wxHAS_CARET_USING_OVERLAYS // we don't need to hide the caret if it's rendered using overlays -class WXDLLIMPEXP_CORE wxCaretSuspend +class WXDLLEXPORT wxCaretSuspend { public: wxCaretSuspend(wxWindow *WXUNUSED(win)) {} - wxDECLARE_NO_COPY_CLASS(wxCaretSuspend); + DECLARE_NO_COPY_CLASS(wxCaretSuspend) }; #else // !wxHAS_CARET_USING_OVERLAYS -class WXDLLIMPEXP_CORE wxCaretSuspend +class WXDLLEXPORT wxCaretSuspend { public: wxCaretSuspend(wxWindow *win) @@ -241,7 +242,7 @@ private: wxCaret *m_caret; bool m_show; - wxDECLARE_NO_COPY_CLASS(wxCaretSuspend); + DECLARE_NO_COPY_CLASS(wxCaretSuspend) }; #endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS diff --git a/Source/3rd Party/wx/include/wx/chartype.h b/Source/3rd Party/wx/include/wx/chartype.h deleted file mode 100644 index 5217258d1..000000000 --- a/Source/3rd Party/wx/include/wx/chartype.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Name: wx/chartype.h - * Purpose: Declarations of wxChar and related types - * Author: Joel Farley, Ove KÃ¥ven - * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee - * Created: 1998/06/12 - * Copyright: (c) 1998-2006 wxWidgets dev team - * Licence: wxWindows licence - */ - -/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ - -#ifndef _WX_WXCHARTYPE_H_ -#define _WX_WXCHARTYPE_H_ - -/* defs.h indirectly includes this file, so don't include it here */ -#include "wx/platform.h" - -/* check whether we have wchar_t and which size it is if we do */ -#if !defined(wxUSE_WCHAR_T) - #if defined(__UNIX__) - #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__) - #define wxUSE_WCHAR_T 1 - #else - #define wxUSE_WCHAR_T 0 - #endif - #elif defined(__GNUWIN32__) && !defined(__MINGW32__) - #define wxUSE_WCHAR_T 0 - #elif defined(__WATCOMC__) - #define wxUSE_WCHAR_T 0 - #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400) - #define wxUSE_WCHAR_T 0 - #else - /* add additional compiler checks if this fails */ - #define wxUSE_WCHAR_T 1 - #endif -#endif /* !defined(wxUSE_WCHAR_T) */ - -/* Unicode support requires wchar_t */ -#if !wxUSE_WCHAR_T - #error "wchar_t must be available" -#endif /* Unicode */ - -/* - non Unix compilers which do have wchar.h (but not tchar.h which is included - below and which includes wchar.h anyhow). - - Actually MinGW has tchar.h, but it does not include wchar.h - */ -#if defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__) - #ifndef HAVE_WCHAR_H - #define HAVE_WCHAR_H - #endif -#endif - -#ifdef HAVE_WCHAR_H - /* the current (as of Nov 2002) version of cygwin has a bug in its */ - /* wchar.h -- there is no extern "C" around the declarations in it */ - /* and this results in linking errors later; also, at least on some */ - /* Cygwin versions, wchar.h requires sys/types.h */ - #ifdef __CYGWIN__ - #include - #ifdef __cplusplus - extern "C" { - #endif - #endif /* Cygwin */ - - #include - - #if defined(__CYGWIN__) && defined(__cplusplus) - } - #endif /* Cygwin and C++ */ - -#elif defined(HAVE_WCSTR_H) - /* old compilers have relevant declarations here */ - #include -#elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__) - /* include stdlib.h for wchar_t */ - #include -#endif /* HAVE_WCHAR_H */ - -#ifdef HAVE_WIDEC_H - #include -#endif - -/* -------------------------------------------------------------------------- */ -/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */ -/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and */ -/* have the function mapping _tfoo() -> foo() or wfoo() */ -/* -------------------------------------------------------------------------- */ - -/* VC++ and BC++ starting with 5.2 have TCHAR support */ -#ifdef __VISUALC__ - #define wxHAVE_TCHAR_SUPPORT -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520) - #define wxHAVE_TCHAR_SUPPORT - #include -#elif defined(__WATCOMC__) - #define wxHAVE_TCHAR_SUPPORT -#elif defined(__DMC__) - #define wxHAVE_TCHAR_SUPPORT -#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 ) - #define wxHAVE_TCHAR_SUPPORT - #include - #include - #include -#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400) - /* VZ: the old VisualAge definitions were completely wrong and had no */ - /* chance at all to work in Unicode build anyhow so let's pretend */ - /* that VisualAge does _not_ support TCHAR for the moment (as */ - /* indicated by "0 &&" above) until someone really has time to delve */ - /* into Unicode issues under OS/2 */ - - /* VisualAge 4.0+ supports TCHAR */ - #define wxHAVE_TCHAR_SUPPORT -#endif /* compilers with (good) TCHAR support */ - -#ifdef wxHAVE_TCHAR_SUPPORT - /* get TCHAR definition if we've got it */ - #include - - /* we surely do have wchar_t if we have TCHAR */ - #ifndef wxUSE_WCHAR_T - #define wxUSE_WCHAR_T 1 - #endif /* !defined(wxUSE_WCHAR_T) */ -#endif /* wxHAVE_TCHAR_SUPPORT */ - -/* ------------------------------------------------------------------------- */ -/* define wxChar type */ -/* ------------------------------------------------------------------------- */ - -/* TODO: define wxCharInt to be equal to either int or wint_t? */ - -#if !wxUSE_UNICODE - typedef char wxChar; - typedef signed char wxSChar; - typedef unsigned char wxUChar; -#else - /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */ - /* signed/unsigned version of it which (a) makes sense to me (unlike */ - /* char wchar_t is always unsigned) and (b) was how the previous */ - /* definitions worked so keep it like this */ - - /* Sun's SunPro compiler supports the wchar_t type and wide character */ - /* functions, but does not define __WCHAR_TYPE__. Define it here to */ - /* allow unicode enabled builds. */ - #if (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && !defined(__WCHAR_TYPE__) - #define __WCHAR_TYPE__ wxchar_t - #endif - - /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */ - /* comment below */ - #if !defined(__WCHAR_TYPE__) || \ - (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96)) - /* standard case */ - typedef wchar_t wxChar; - typedef wchar_t wxSChar; - typedef wchar_t wxUChar; - #else /* __WCHAR_TYPE__ and gcc < 2.96 */ - /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. */ - /* However, this doesn't work with new GCC 3.x compilers because */ - /* wchar_t is C++'s builtin type in the new standard. OTOH, old */ - /* compilers (GCC 2.x) won't accept new definition of */ - /* wx{S,U}CharType, so we have to define wxChar */ - /* conditionally depending on detected compiler & compiler */ - /* version. */ - - /* with old definition of wxChar. */ - #define wchar_t __WCHAR_TYPE__ - typedef __WCHAR_TYPE__ wxChar; - typedef __WCHAR_TYPE__ wxSChar; - typedef __WCHAR_TYPE__ wxUChar; - #endif /* __WCHAR_TYPE__ */ -#endif /* ASCII/Unicode */ - -/* ------------------------------------------------------------------------- */ -/* define wxStringCharType */ -/* ------------------------------------------------------------------------- */ - -/* depending on the platform, Unicode build can either store wxStrings as - wchar_t* or UTF-8 encoded char*: */ -#if wxUSE_UNICODE - /* FIXME-UTF8: what would be better place for this? */ - #if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8) - #error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8" - #endif - #ifndef wxUSE_UTF8_LOCALE_ONLY - #define wxUSE_UTF8_LOCALE_ONLY 0 - #endif - - #ifndef wxUSE_UNICODE_UTF8 - #define wxUSE_UNICODE_UTF8 0 - #endif - - #if wxUSE_UNICODE_UTF8 - #define wxUSE_UNICODE_WCHAR 0 - #else - #define wxUSE_UNICODE_WCHAR 1 - #endif -#else - #define wxUSE_UNICODE_WCHAR 0 - #define wxUSE_UNICODE_UTF8 0 - #define wxUSE_UTF8_LOCALE_ONLY 0 -#endif - -/* define char type used by wxString internal representation: */ -#if wxUSE_UNICODE_WCHAR - typedef wchar_t wxStringCharType; -#else /* wxUSE_UNICODE_UTF8 || ANSI */ - typedef char wxStringCharType; -#endif - - -/* ------------------------------------------------------------------------- */ -/* define wxT() and related macros */ -/* ------------------------------------------------------------------------- */ - -/* BSD systems define _T() to be something different in ctype.h, override it */ -#if defined(__FreeBSD__) || defined(__DARWIN__) - #include - #undef _T -#endif - -/* - wxT ("wx text") macro turns a literal string constant into a wide char - constant. It is mostly unnecessary with wx 2.9 but defined for - compatibility. - */ -#ifndef wxT - #if !wxUSE_UNICODE - #define wxT(x) x - #else /* Unicode */ - /* - Notice that we use an intermediate macro to allow x to be expanded - if it's a macro itself. - */ - #ifndef wxCOMPILER_BROKEN_CONCAT_OPER - #define wxT(x) wxCONCAT_HELPER(L, x) - #else - #define wxT(x) wxPREPEND_L(x) - #endif - #endif /* ASCII/Unicode */ -#endif /* !defined(wxT) */ - -/* - wxT_2 exists only for compatibility with wx 2.x and is the same as wxT() in - that version but nothing in the newer ones. - */ -#define wxT_2(x) x - -/* - wxS ("wx string") macro can be used to create literals using the same - representation as wxString does internally, i.e. wchar_t in Unicode build - under Windows or char in UTF-8-based Unicode builds and (deprecated) ANSI - builds everywhere (see wxStringCharType definition above). - */ -#if wxUSE_UNICODE_WCHAR - /* - As above with wxT(), wxS() argument is expanded if it's a macro. - */ - #ifndef wxCOMPILER_BROKEN_CONCAT_OPER - #define wxS(x) wxCONCAT_HELPER(L, x) - #else - #define wxS(x) wxPREPEND_L(x) - #endif -#else /* wxUSE_UNICODE_UTF8 || ANSI */ - #define wxS(x) x -#endif - -/* - _T() is a synonym for wxT() familiar to Windows programmers. As this macro - has even higher risk of conflicting with system headers, its use is - discouraged and you may predefine wxNO__T to disable it. Additionally, we - do it ourselves for Sun CC which is known to use it in its standard headers - (see #10660). - */ -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) - #ifndef wxNO__T - #define wxNO__T - #endif -#endif - -#if !defined(_T) && !defined(wxNO__T) - #define _T(x) wxT(x) -#endif - -/* a helper macro allowing to make another macro Unicode-friendly, see below */ -#define wxAPPLY_T(x) wxT(x) - -/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */ -#ifndef __TFILE__ - #define __TFILE__ wxAPPLY_T(__FILE__) -#endif - -#ifndef __TDATE__ - #define __TDATE__ wxAPPLY_T(__DATE__) -#endif - -#ifndef __TTIME__ - #define __TTIME__ wxAPPLY_T(__TIME__) -#endif - -#endif /* _WX_WXCHARTYPE_H_ */ - diff --git a/Source/3rd Party/wx/include/wx/checkbox.h b/Source/3rd Party/wx/include/wx/checkbox.h index 6bbb22a3f..4760475ab 100644 --- a/Source/3rd Party/wx/include/wx/checkbox.h +++ b/Source/3rd Party/wx/include/wx/checkbox.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 07.09.00 +// RCS-ID: $Id: checkbox.h 39901 2006-06-30 10:51:44Z VS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -24,12 +25,8 @@ * Determine whether to use a 3-state or 2-state * checkbox. 3-state enables to differentiate * between 'unchecked', 'checked' and 'undetermined'. - * - * In addition to the styles here it is also possible to specify just 0 which - * is treated the same as wxCHK_2STATE for compatibility (but using explicit - * flag is preferred). */ -#define wxCHK_2STATE 0x4000 +#define wxCHK_2STATE 0x0000 #define wxCHK_3STATE 0x1000 /* @@ -40,13 +37,25 @@ */ #define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000 -extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[]; +/* + * The possible states of a 3-state checkbox (Compatible + * with the 2-state checkbox). + */ +enum wxCheckBoxState +{ + wxCHK_UNCHECKED, + wxCHK_CHECKED, + wxCHK_UNDETERMINED /* 3-state checkbox only */ +}; + + +extern WXDLLEXPORT_DATA(const wxChar) wxCheckBoxNameStr[]; // ---------------------------------------------------------------------------- // wxCheckBox: a control which shows a label and a box which may be checked // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCheckBoxBase : public wxControl +class WXDLLEXPORT wxCheckBoxBase : public wxControl { public: wxCheckBoxBase() { } @@ -109,9 +118,6 @@ public: } protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; } virtual wxCheckBoxState DoGet3StateValue() const @@ -120,51 +126,10 @@ protected: return wxCHK_UNCHECKED; } - // Helper function to be called from derived classes Create() - // implementations: it checks that the style doesn't contain any - // incompatible bits and modifies it to be sane if it does. - static void WXValidateStyle(long *stylePtr) - { - long& style = *stylePtr; - - if ( !(style & (wxCHK_2STATE | wxCHK_3STATE)) ) - { - // For compatibility we use absence of style flags as wxCHK_2STATE - // because wxCHK_2STATE used to have the value of 0 and some - // existing code uses 0 instead of it. Moreover, some code even - // uses some non-0 style, e.g. wxBORDER_XXX, but doesn't specify - // neither wxCHK_2STATE nor wxCHK_3STATE -- to avoid breaking it, - // assume (much more common) 2 state checkbox by default. - style |= wxCHK_2STATE; - } - - if ( style & wxCHK_3STATE ) - { - if ( style & wxCHK_2STATE ) - { - wxFAIL_MSG( "wxCHK_2STATE and wxCHK_3STATE can't be used " - "together" ); - style &= ~wxCHK_3STATE; - } - } - else // No wxCHK_3STATE - { - if ( style & wxCHK_ALLOW_3RD_STATE_FOR_USER ) - { - wxFAIL_MSG( "wxCHK_ALLOW_3RD_STATE_FOR_USER doesn't make sense " - "without wxCHK_3STATE" ); - style &= ~wxCHK_ALLOW_3RD_STATE_FOR_USER; - } - } - } - private: - wxDECLARE_NO_COPY_CLASS(wxCheckBoxBase); + DECLARE_NO_COPY_CLASS(wxCheckBoxBase) }; -// Most ports support 3 state checkboxes so define this by default. -#define wxHAS_3STATE_CHECKBOX - #if defined(__WXUNIVERSAL__) #include "wx/univ/checkbox.h" #elif defined(__WXMSW__) @@ -174,17 +139,18 @@ private: #elif defined(__WXGTK20__) #include "wx/gtk/checkbox.h" #elif defined(__WXGTK__) - #undef wxHAS_3STATE_CHECKBOX #include "wx/gtk1/checkbox.h" #elif defined(__WXMAC__) - #include "wx/osx/checkbox.h" + #include "wx/mac/checkbox.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/checkbox.h" #elif defined(__WXPM__) - #undef wxHAS_3STATE_CHECKBOX #include "wx/os2/checkbox.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/checkbox.h" #endif #endif // wxUSE_CHECKBOX -#endif // _WX_CHECKBOX_H_BASE_ +#endif + // _WX_CHECKBOX_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/checkeddelete.h b/Source/3rd Party/wx/include/wx/checkeddelete.h deleted file mode 100644 index fd295faf8..000000000 --- a/Source/3rd Party/wx/include/wx/checkeddelete.h +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/checkeddelete.h -// Purpose: wxCHECKED_DELETE() macro -// Author: Vadim Zeitlin -// Created: 2009-02-03 -// Copyright: (c) 2002-2009 wxWidgets dev team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CHECKEDDELETE_H_ -#define _WX_CHECKEDDELETE_H_ - -#include "wx/cpp.h" - -// TODO: provide wxCheckedDelete[Array]() template functions too - -// ---------------------------------------------------------------------------- -// wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros -// ---------------------------------------------------------------------------- - -/* - checked deleters are used to make sure that the type being deleted is really - a complete type.: otherwise sizeof() would result in a compile-time error - - do { ... } while ( 0 ) construct is used to have an anonymous scope - (otherwise we could have name clashes between different "complete"s) but - still force a semicolon after the macro -*/ - -#define wxCHECKED_DELETE(ptr) \ - wxSTATEMENT_MACRO_BEGIN \ - typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \ - delete ptr; \ - wxSTATEMENT_MACRO_END - -#define wxCHECKED_DELETE_ARRAY(ptr) \ - wxSTATEMENT_MACRO_BEGIN \ - typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \ - delete [] ptr; \ - wxSTATEMENT_MACRO_END - - -#endif // _WX_CHECKEDDELETE_H_ - diff --git a/Source/3rd Party/wx/include/wx/checklst.h b/Source/3rd Party/wx/include/wx/checklst.h index 0ed9d3cb1..c8857fd08 100644 --- a/Source/3rd Party/wx/include/wx/checklst.h +++ b/Source/3rd Party/wx/include/wx/checklst.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 12.09.00 +// RCS-ID: $Id: checklst.h 38319 2006-03-23 22:05:23Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,8 +12,6 @@ #ifndef _WX_CHECKLST_H_BASE_ #define _WX_CHECKLST_H_BASE_ -#include "wx/defs.h" - #if wxUSE_CHECKLISTBOX #include "wx/listbox.h" @@ -21,7 +20,7 @@ // wxCheckListBox: a listbox whose items may be checked // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCheckListBoxBase : public +class WXDLLEXPORT wxCheckListBoxBase : public #ifdef __WXWINCE__ // keep virtuals synchronised wxListBoxBase @@ -36,9 +35,7 @@ public: virtual bool IsChecked(unsigned int item) const = 0; virtual void Check(unsigned int item, bool check = true) = 0; - virtual unsigned int GetCheckedItems(wxArrayInt& checkedItems) const; - - wxDECLARE_NO_COPY_CLASS(wxCheckListBoxBase); + DECLARE_NO_COPY_CLASS(wxCheckListBoxBase) }; #if defined(__WXUNIVERSAL__) @@ -54,7 +51,7 @@ public: #elif defined(__WXGTK__) #include "wx/gtk1/checklst.h" #elif defined(__WXMAC__) - #include "wx/osx/checklst.h" + #include "wx/mac/checklst.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/checklst.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/chkconf.h b/Source/3rd Party/wx/include/wx/chkconf.h index 5b4ef5cc5..811e0c304 100644 --- a/Source/3rd Party/wx/include/wx/chkconf.h +++ b/Source/3rd Party/wx/include/wx/chkconf.h @@ -4,51 +4,46 @@ * Author: Vadim Zeitlin * Modified by: * Created: 09.08.00 + * RCS-ID: $Id: chkconf.h 48113 2007-08-15 17:43:50Z DE $ * Copyright: (c) 2000 Vadim Zeitlin * Licence: wxWindows licence */ /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ -#ifndef _WX_CHKCONF_H_ -#define _WX_CHKCONF_H_ /* - ************************************************** - PLEASE READ THIS IF YOU GET AN ERROR IN THIS FILE! - ************************************************** - - If you get an error saying "wxUSE_FOO must be defined", it means that you - are not using the correct up-to-date version of setup.h. This happens most - often when using svn or daily snapshots and a new symbol was added to - setup0.h and you haven't updated your local setup.h to reflect it. If - this is the case, you need to propagate the changes from setup0.h to your - setup.h and, if using makefiles under MSW, also remove setup.h under the - build directory (lib/$(COMPILER)_{lib,dll}/msw[u][d][dll]/wx) so that - the new setup.h is copied there. - - If you get an error of the form "wxFoo requires wxBar", then the settings - in your setup.h are inconsistent. You have the choice between correcting - them manually or commenting out #define wxABORT_ON_CONFIG_ERROR below to - try to correct the problems automatically (not really recommended but - might work). + Platform-specific checking. */ -/* - This file has the following sections: - 1. checks that all wxUSE_XXX symbols we use are defined - a) first the non-GUI ones - b) then the GUI-only ones - 2. platform-specific checks done in the platform headers - 3. generic consistency checks - a) first the non-GUI ones - b) then the GUI-only ones - */ +#if defined(__WXPALMOS__) +# include "wx/palmos/chkconf.h" +#elif defined(__WXWINCE__) +# include "wx/msw/wince/chkconf.h" +#elif defined(__WXMSW__) +# include "wx/msw/chkconf.h" +#elif defined(__WXMAC__) +# include "wx/mac/chkconf.h" +#elif defined(__OS2__) +# include "wx/os2/chkconf.h" +#elif defined(__WXMGL__) +# include "wx/mgl/chkconf.h" +#elif defined(__WXDFB__) +# include "wx/dfb/chkconf.h" +#elif defined(__WXMOTIF__) +# include "wx/motif/chkconf.h" +#elif defined(__WXX11__) +# include "wx/x11/chkconf.h" +#endif + +#ifdef __WXUNIVERSAL__ +# include "wx/univ/chkconf.h" +#endif /* this global setting determines what should we do if the setting FOO requires BAR and BAR is not set: we can either silently unset FOO as well (do this if you're trying to build the smallest possible library) or give an - error and abort (default as leads to least surprising behaviour) + error and abort (default as leads to least surprizing behaviour) */ #define wxABORT_ON_CONFIG_ERROR @@ -56,6 +51,16 @@ global features */ +/* GUI build by default */ +#if !defined(wxUSE_GUI) +# define wxUSE_GUI 1 +#endif /* !defined(wxUSE_GUI) */ + +/* Turn off wxUSE_ABI_INCOMPATIBLE_FEATURES if not specified. */ +#if !defined(wxUSE_ABI_INCOMPATIBLE_FEATURES) +# define wxUSE_ABI_INCOMPATIBLE_FEATURES 0 +#endif /* !defined(wxUSE_ABI_INCOMPATIBLE_FEATURES) */ + /* If we're compiling without support for threads/exceptions we have to disable the corresponding features. @@ -78,38 +83,24 @@ /* - Section 1a: tests for non GUI features. + tests for non GUI features please keep the options in alphabetical order! */ -#ifndef wxUSE_ANY -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ANY must be defined, please read comment near the top of this file." +#ifndef wxUSE_CRASHREPORT + /* this one is special: as currently it is Windows-only, don't force it + to be defined on other platforms */ +# if defined(wxABORT_ON_CONFIG_ERROR) && defined(__WXMSW__) +# error "wxUSE_CRASHREPORT must be defined." # else -# define wxUSE_ANY 0 +# define wxUSE_CRASHREPORT 0 # endif -#endif /* wxUSE_ANY */ - -#ifndef wxUSE_COMPILER_TLS -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COMPILER_TLS must be defined, please read comment near the top of this file." -# else -# define wxUSE_COMPILER_TLS 0 -# endif -#endif /* !defined(wxUSE_COMPILER_TLS) */ - -#ifndef wxUSE_CONSOLE_EVENTLOOP -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CONSOLE_EVENTLOOP must be defined, please read comment near the top of this file." -# else -# define wxUSE_CONSOLE_EVENTLOOP 0 -# endif -#endif /* !defined(wxUSE_CONSOLE_EVENTLOOP) */ +#endif /* !defined(wxUSE_CRASHREPORT) */ #ifndef wxUSE_DYNLIB_CLASS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DYNLIB_CLASS must be defined, please read comment near the top of this file." +# error "wxUSE_DYNLIB_CLASS must be defined." # else # define wxUSE_DYNLIB_CLASS 0 # endif @@ -117,23 +108,15 @@ #ifndef wxUSE_EXCEPTIONS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_EXCEPTIONS must be defined, please read comment near the top of this file." +# error "wxUSE_EXCEPTIONS must be defined." # else # define wxUSE_EXCEPTIONS 0 # endif #endif /* !defined(wxUSE_EXCEPTIONS) */ -#ifndef wxUSE_FILE_HISTORY -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FILE_HISTORY must be defined, please read comment near the top of this file." -# else -# define wxUSE_FILE_HISTORY 0 -# endif -#endif /* !defined(wxUSE_FILE_HISTORY) */ - #ifndef wxUSE_FILESYSTEM # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FILESYSTEM must be defined, please read comment near the top of this file." +# error "wxUSE_FILESYSTEM must be defined." # else # define wxUSE_FILESYSTEM 0 # endif @@ -141,55 +124,28 @@ #ifndef wxUSE_FS_ARCHIVE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FS_ARCHIVE must be defined, please read comment near the top of this file." +# error "wxUSE_FS_ARCHIVE must be defined." # else # define wxUSE_FS_ARCHIVE 0 # endif #endif /* !defined(wxUSE_FS_ARCHIVE) */ +/* don't give an error about this one yet, it's not fully implemented */ #ifndef wxUSE_FSVOLUME -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FSVOLUME must be defined, please read comment near the top of this file." -# else -# define wxUSE_FSVOLUME 0 -# endif +# define wxUSE_FSVOLUME 0 #endif /* !defined(wxUSE_FSVOLUME) */ -#ifndef wxUSE_FSWATCHER -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FSWATCHER must be defined, please read comment near the top of this file." -# else -# define wxUSE_FSWATCHER 0 -# endif -#endif /* !defined(wxUSE_FSWATCHER) */ - #ifndef wxUSE_DYNAMIC_LOADER # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DYNAMIC_LOADER must be defined, please read comment near the top of this file." +# error "wxUSE_DYNAMIC_LOADER must be defined." # else # define wxUSE_DYNAMIC_LOADER 0 # endif #endif /* !defined(wxUSE_DYNAMIC_LOADER) */ -#ifndef wxUSE_INTL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_INTL must be defined, please read comment near the top of this file." -# else -# define wxUSE_INTL 0 -# endif -#endif /* !defined(wxUSE_INTL) */ - -#ifndef wxUSE_IPV6 -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_IPV6 must be defined, please read comment near the top of this file." -# else -# define wxUSE_IPV6 0 -# endif -#endif /* !defined(wxUSE_IPV6) */ - #ifndef wxUSE_LOG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LOG must be defined, please read comment near the top of this file." +# error "wxUSE_LOG must be defined." # else # define wxUSE_LOG 0 # endif @@ -197,7 +153,7 @@ #ifndef wxUSE_LONGLONG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LONGLONG must be defined, please read comment near the top of this file." +# error "wxUSE_LONGLONG must be defined." # else # define wxUSE_LONGLONG 0 # endif @@ -205,7 +161,7 @@ #ifndef wxUSE_MIMETYPE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MIMETYPE must be defined, please read comment near the top of this file." +# error "wxUSE_MIMETYPE must be defined." # else # define wxUSE_MIMETYPE 0 # endif @@ -213,7 +169,7 @@ #ifndef wxUSE_ON_FATAL_EXCEPTION # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ON_FATAL_EXCEPTION must be defined, please read comment near the top of this file." +# error "wxUSE_ON_FATAL_EXCEPTION must be defined." # else # define wxUSE_ON_FATAL_EXCEPTION 0 # endif @@ -221,7 +177,7 @@ #ifndef wxUSE_PRINTF_POS_PARAMS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PRINTF_POS_PARAMS must be defined, please read comment near the top of this file." +# error "wxUSE_PRINTF_POS_PARAMS must be defined." # else # define wxUSE_PRINTF_POS_PARAMS 0 # endif @@ -229,7 +185,7 @@ #ifndef wxUSE_PROTOCOL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PROTOCOL must be defined, please read comment near the top of this file." +# error "wxUSE_PROTOCOL must be defined." # else # define wxUSE_PROTOCOL 0 # endif @@ -247,7 +203,7 @@ #ifndef wxUSE_PROTOCOL_HTTP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PROTOCOL_HTTP must be defined, please read comment near the top of this file." +# error "wxUSE_PROTOCOL_HTTP must be defined." # else # define wxUSE_PROTOCOL_HTTP 0 # endif @@ -255,7 +211,7 @@ #ifndef wxUSE_PROTOCOL_FTP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PROTOCOL_FTP must be defined, please read comment near the top of this file." +# error "wxUSE_PROTOCOL_FTP must be defined." # else # define wxUSE_PROTOCOL_FTP 0 # endif @@ -263,7 +219,7 @@ #ifndef wxUSE_PROTOCOL_FILE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PROTOCOL_FILE must be defined, please read comment near the top of this file." +# error "wxUSE_PROTOCOL_FILE must be defined." # else # define wxUSE_PROTOCOL_FILE 0 # endif @@ -271,7 +227,7 @@ #ifndef wxUSE_REGEX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_REGEX must be defined, please read comment near the top of this file." +# error "wxUSE_REGEX must be defined." # else # define wxUSE_REGEX 0 # endif @@ -279,7 +235,7 @@ #ifndef wxUSE_STDPATHS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STDPATHS must be defined, please read comment near the top of this file." +# error "wxUSE_STDPATHS must be defined." # else # define wxUSE_STDPATHS 1 # endif @@ -287,7 +243,7 @@ #ifndef wxUSE_XML # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_XML must be defined, please read comment near the top of this file." +# error "wxUSE_XML must be defined." # else # define wxUSE_XML 0 # endif @@ -295,31 +251,15 @@ #ifndef wxUSE_SOCKETS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SOCKETS must be defined, please read comment near the top of this file." +# error "wxUSE_SOCKETS must be defined." # else # define wxUSE_SOCKETS 0 # endif #endif /* !defined(wxUSE_SOCKETS) */ -#ifndef wxUSE_STD_CONTAINERS -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STD_CONTAINERS must be defined, please read comment near the top of this file." -# else -# define wxUSE_STD_CONTAINERS 0 -# endif -#endif /* !defined(wxUSE_STD_CONTAINERS) */ - -#ifndef wxUSE_STD_STRING_CONV_IN_WXSTRING -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STD_STRING_CONV_IN_WXSTRING must be defined, please read comment near the top of this file." -# else -# define wxUSE_STD_STRING_CONV_IN_WXSTRING 0 -# endif -#endif /* !defined(wxUSE_STD_STRING_CONV_IN_WXSTRING) */ - #ifndef wxUSE_STREAMS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STREAMS must be defined, please read comment near the top of this file." +# error "wxUSE_STREAMS must be defined." # else # define wxUSE_STREAMS 0 # endif @@ -327,7 +267,7 @@ #ifndef wxUSE_STOPWATCH # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STOPWATCH must be defined, please read comment near the top of this file." +# error "wxUSE_STOPWATCH must be defined." # else # define wxUSE_STOPWATCH 0 # endif @@ -335,7 +275,7 @@ #ifndef wxUSE_TEXTBUFFER # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TEXTBUFFER must be defined, please read comment near the top of this file." +# error "wxUSE_TEXTBUFFER must be defined." # else # define wxUSE_TEXTBUFFER 0 # endif @@ -343,7 +283,7 @@ #ifndef wxUSE_TEXTFILE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TEXTFILE must be defined, please read comment near the top of this file." +# error "wxUSE_TEXTFILE must be defined." # else # define wxUSE_TEXTFILE 0 # endif @@ -351,7 +291,7 @@ #ifndef wxUSE_UNICODE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_UNICODE must be defined, please read comment near the top of this file." +# error "wxUSE_UNICODE must be defined." # else # define wxUSE_UNICODE 0 # endif @@ -359,7 +299,7 @@ #ifndef wxUSE_URL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_URL must be defined, please read comment near the top of this file." +# error "wxUSE_URL must be defined." # else # define wxUSE_URL 0 # endif @@ -367,22 +307,14 @@ #ifndef wxUSE_VARIANT # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_VARIANT must be defined, please read comment near the top of this file." +# error "wxUSE_VARIANT must be defined." # else # define wxUSE_VARIANT 0 # endif #endif /* wxUSE_VARIANT */ -#ifndef wxUSE_XLOCALE -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_XLOCALE must be defined, please read comment near the top of this file." -# else -# define wxUSE_XLOCALE 0 -# endif -#endif /* !defined(wxUSE_XLOCALE) */ - /* - Section 1b: all these tests are for GUI only. + all these tests are for GUI only please keep the options in alphabetical order! */ @@ -395,7 +327,7 @@ #ifndef wxUSE_ABOUTDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ABOUTDLG must be defined, please read comment near the top of this file." +# error "wxUSE_ABOUTDLG must be defined." # else # define wxUSE_ABOUTDLG 0 # endif @@ -403,55 +335,23 @@ #ifndef wxUSE_ACCEL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ACCEL must be defined, please read comment near the top of this file." +# error "wxUSE_ACCEL must be defined." # else # define wxUSE_ACCEL 0 # endif #endif /* !defined(wxUSE_ACCEL) */ -#ifndef wxUSE_ACCESSIBILITY -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ACCESSIBILITY must be defined, please read comment near the top of this file." -# else -# define wxUSE_ACCESSIBILITY 0 -# endif -#endif /* !defined(wxUSE_ACCESSIBILITY) */ - #ifndef wxUSE_ANIMATIONCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ANIMATIONCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_ANIMATIONCTRL must be defined." # else # define wxUSE_ANIMATIONCTRL 0 # endif #endif /* !defined(wxUSE_ANIMATIONCTRL) */ -#ifndef wxUSE_ARTPROVIDER_STD -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ARTPROVIDER_STD must be defined, please read comment near the top of this file." -# else -# define wxUSE_ARTPROVIDER_STD 0 -# endif -#endif /* !defined(wxUSE_ARTPROVIDER_STD) */ - -#ifndef wxUSE_ARTPROVIDER_TANGO -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ARTPROVIDER_TANGO must be defined, please read comment near the top of this file." -# else -# define wxUSE_ARTPROVIDER_TANGO 0 -# endif -#endif /* !defined(wxUSE_ARTPROVIDER_TANGO) */ - -#ifndef wxUSE_AUTOID_MANAGEMENT -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_AUTOID_MANAGEMENT must be defined, please read comment near the top of this file." -# else -# define wxUSE_AUTOID_MANAGEMENT 0 -# endif -#endif /* !defined(wxUSE_AUTOID_MANAGEMENT) */ - #ifndef wxUSE_BITMAPCOMBOBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_BITMAPCOMBOBOX must be defined, please read comment near the top of this file." +# error "wxUSE_BITMAPCOMBOBOX must be defined." # else # define wxUSE_BITMAPCOMBOBOX 0 # endif @@ -459,7 +359,7 @@ #ifndef wxUSE_BMPBUTTON # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_BMPBUTTON must be defined, please read comment near the top of this file." +# error "wxUSE_BMPBUTTON must be defined." # else # define wxUSE_BMPBUTTON 0 # endif @@ -467,23 +367,15 @@ #ifndef wxUSE_BUTTON # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_BUTTON must be defined, please read comment near the top of this file." +# error "wxUSE_BUTTON must be defined." # else # define wxUSE_BUTTON 0 # endif #endif /* !defined(wxUSE_BUTTON) */ -#ifndef wxUSE_CAIRO -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CAIRO must be defined, please read comment near the top of this file." -# else -# define wxUSE_CAIRO 0 -# endif -#endif /* !defined(wxUSE_CAIRO) */ - #ifndef wxUSE_CALENDARCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CALENDARCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_CALENDARCTRL must be defined." # else # define wxUSE_CALENDARCTRL 0 # endif @@ -491,7 +383,7 @@ #ifndef wxUSE_CARET # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CARET must be defined, please read comment near the top of this file." +# error "wxUSE_CARET must be defined." # else # define wxUSE_CARET 0 # endif @@ -499,7 +391,7 @@ #ifndef wxUSE_CHECKBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CHECKBOX must be defined, please read comment near the top of this file." +# error "wxUSE_CHECKBOX must be defined." # else # define wxUSE_CHECKBOX 0 # endif @@ -507,7 +399,7 @@ #ifndef wxUSE_CHECKLISTBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CHECKLISTBOX must be defined, please read comment near the top of this file." +# error "wxUSE_CHECKLISTBOX must be defined." # else # define wxUSE_CHECKLISTBOX 0 # endif @@ -515,7 +407,7 @@ #ifndef wxUSE_CHOICE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CHOICE must be defined, please read comment near the top of this file." +# error "wxUSE_CHOICE must be defined." # else # define wxUSE_CHOICE 0 # endif @@ -523,7 +415,7 @@ #ifndef wxUSE_CHOICEBOOK # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CHOICEBOOK must be defined, please read comment near the top of this file." +# error "wxUSE_CHOICEBOOK must be defined." # else # define wxUSE_CHOICEBOOK 0 # endif @@ -531,7 +423,7 @@ #ifndef wxUSE_CHOICEDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CHOICEDLG must be defined, please read comment near the top of this file." +# error "wxUSE_CHOICEDLG must be defined." # else # define wxUSE_CHOICEDLG 0 # endif @@ -539,7 +431,7 @@ #ifndef wxUSE_CLIPBOARD # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CLIPBOARD must be defined, please read comment near the top of this file." +# error "wxUSE_CLIPBOARD must be defined." # else # define wxUSE_CLIPBOARD 0 # endif @@ -547,7 +439,7 @@ #ifndef wxUSE_COLLPANE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COLLPANE must be defined, please read comment near the top of this file." +# error "wxUSE_COLLPANE must be defined." # else # define wxUSE_COLLPANE 0 # endif @@ -555,7 +447,7 @@ #ifndef wxUSE_COLOURDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COLOURDLG must be defined, please read comment near the top of this file." +# error "wxUSE_COLOURDLG must be defined." # else # define wxUSE_COLOURDLG 0 # endif @@ -563,7 +455,7 @@ #ifndef wxUSE_COLOURPICKERCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COLOURPICKERCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_COLOURPICKERCTRL must be defined." # else # define wxUSE_COLOURPICKERCTRL 0 # endif @@ -571,23 +463,15 @@ #ifndef wxUSE_COMBOBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COMBOBOX must be defined, please read comment near the top of this file." +# error "wxUSE_COMBOBOX must be defined." # else # define wxUSE_COMBOBOX 0 # endif #endif /* !defined(wxUSE_COMBOBOX) */ -#ifndef wxUSE_COMMANDLINKBUTTON -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COMMANDLINKBUTTON must be defined, please read comment near the top of this file." -# else -# define wxUSE_COMMANDLINKBUTTON 0 -# endif -#endif /* !defined(wxUSE_COMMANDLINKBUTTON) */ - #ifndef wxUSE_COMBOCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COMBOCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_COMBOCTRL must be defined." # else # define wxUSE_COMBOCTRL 0 # endif @@ -595,7 +479,7 @@ #ifndef wxUSE_DATAOBJ # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DATAOBJ must be defined, please read comment near the top of this file." +# error "wxUSE_DATAOBJ must be defined." # else # define wxUSE_DATAOBJ 0 # endif @@ -603,7 +487,7 @@ #ifndef wxUSE_DATAVIEWCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DATAVIEWCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_DATAVIEWCTRL must be defined." # else # define wxUSE_DATAVIEWCTRL 0 # endif @@ -611,23 +495,15 @@ #ifndef wxUSE_DATEPICKCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DATEPICKCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_DATEPICKCTRL must be defined." # else # define wxUSE_DATEPICKCTRL 0 # endif #endif /* !defined(wxUSE_DATEPICKCTRL) */ -#ifndef wxUSE_DC_TRANSFORM_MATRIX -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DC_TRANSFORM_MATRIX must be defined, please read comment near the top of this file." -# else -# define wxUSE_DC_TRANSFORM_MATRIX 1 -# endif -#endif /* wxUSE_DC_TRANSFORM_MATRIX */ - #ifndef wxUSE_DIRPICKERCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DIRPICKERCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_DIRPICKERCTRL must be defined." # else # define wxUSE_DIRPICKERCTRL 0 # endif @@ -635,7 +511,7 @@ #ifndef wxUSE_DISPLAY # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DISPLAY must be defined, please read comment near the top of this file." +# error "wxUSE_DISPLAY must be defined." # else # define wxUSE_DISPLAY 0 # endif @@ -643,23 +519,15 @@ #ifndef wxUSE_DOC_VIEW_ARCHITECTURE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DOC_VIEW_ARCHITECTURE must be defined, please read comment near the top of this file." +# error "wxUSE_DOC_VIEW_ARCHITECTURE must be defined." # else # define wxUSE_DOC_VIEW_ARCHITECTURE 0 # endif #endif /* !defined(wxUSE_DOC_VIEW_ARCHITECTURE) */ -#ifndef wxUSE_FILECTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FILECTRL must be defined, please read comment near the top of this file." -# else -# define wxUSE_FILECTRL 0 -# endif -#endif /* !defined(wxUSE_FILECTRL) */ - #ifndef wxUSE_FILEDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FILEDLG must be defined, please read comment near the top of this file." +# error "wxUSE_FILEDLG must be defined." # else # define wxUSE_FILEDLG 0 # endif @@ -667,7 +535,7 @@ #ifndef wxUSE_FILEPICKERCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FILEPICKERCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_FILEPICKERCTRL must be defined." # else # define wxUSE_FILEPICKERCTRL 0 # endif @@ -675,7 +543,7 @@ #ifndef wxUSE_FONTDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FONTDLG must be defined, please read comment near the top of this file." +# error "wxUSE_FONTDLG must be defined." # else # define wxUSE_FONTDLG 0 # endif @@ -683,7 +551,7 @@ #ifndef wxUSE_FONTMAP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FONTMAP must be defined, please read comment near the top of this file." +# error "wxUSE_FONTMAP must be defined." # else # define wxUSE_FONTMAP 0 # endif @@ -691,7 +559,7 @@ #ifndef wxUSE_FONTPICKERCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_FONTPICKERCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_FONTPICKERCTRL must be defined." # else # define wxUSE_FONTPICKERCTRL 0 # endif @@ -699,7 +567,7 @@ #ifndef wxUSE_GAUGE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_GAUGE must be defined, please read comment near the top of this file." +# error "wxUSE_GAUGE must be defined." # else # define wxUSE_GAUGE 0 # endif @@ -707,7 +575,7 @@ #ifndef wxUSE_GRAPHICS_CONTEXT # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_GRAPHICS_CONTEXT must be defined, please read comment near the top of this file." +# error "wxUSE_GRAPHICS_CONTEXT must be defined." # else # define wxUSE_GRAPHICS_CONTEXT 0 # endif @@ -716,23 +584,15 @@ #ifndef wxUSE_GRID # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_GRID must be defined, please read comment near the top of this file." +# error "wxUSE_GRID must be defined." # else # define wxUSE_GRID 0 # endif #endif /* !defined(wxUSE_GRID) */ -#ifndef wxUSE_HEADERCTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_HEADERCTRL must be defined, please read comment near the top of this file." -# else -# define wxUSE_HEADERCTRL 0 -# endif -#endif /* !defined(wxUSE_HEADERCTRL) */ - #ifndef wxUSE_HELP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_HELP must be defined, please read comment near the top of this file." +# error "wxUSE_HELP must be defined." # else # define wxUSE_HELP 0 # endif @@ -740,7 +600,7 @@ #ifndef wxUSE_HYPERLINKCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_HYPERLINKCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_HYPERLINKCTRL must be defined." # else # define wxUSE_HYPERLINKCTRL 0 # endif @@ -748,19 +608,19 @@ #ifndef wxUSE_HTML # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_HTML must be defined, please read comment near the top of this file." +# error "wxUSE_HTML must be defined." # else # define wxUSE_HTML 0 # endif #endif /* !defined(wxUSE_HTML) */ #ifndef wxUSE_LIBMSPACK -# if !defined(__UNIX__) +# ifndef __UNIX__ /* set to 0 on platforms that don't have libmspack */ # define wxUSE_LIBMSPACK 0 # else # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LIBMSPACK must be defined, please read comment near the top of this file." +# error "wxUSE_LIBMSPACK must be defined." # else # define wxUSE_LIBMSPACK 0 # endif @@ -769,7 +629,7 @@ #ifndef wxUSE_ICO_CUR # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ICO_CUR must be defined, please read comment near the top of this file." +# error "wxUSE_ICO_CUR must be defined." # else # define wxUSE_ICO_CUR 0 # endif @@ -777,7 +637,7 @@ #ifndef wxUSE_IFF # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_IFF must be defined, please read comment near the top of this file." +# error "wxUSE_IFF must be defined." # else # define wxUSE_IFF 0 # endif @@ -785,23 +645,15 @@ #ifndef wxUSE_IMAGLIST # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_IMAGLIST must be defined, please read comment near the top of this file." +# error "wxUSE_IMAGLIST must be defined." # else # define wxUSE_IMAGLIST 0 # endif #endif /* !defined(wxUSE_IMAGLIST) */ -#ifndef wxUSE_INFOBAR -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_INFOBAR must be defined, please read comment near the top of this file." -# else -# define wxUSE_INFOBAR 0 -# endif -#endif /* !defined(wxUSE_INFOBAR) */ - #ifndef wxUSE_JOYSTICK # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_JOYSTICK must be defined, please read comment near the top of this file." +# error "wxUSE_JOYSTICK must be defined." # else # define wxUSE_JOYSTICK 0 # endif @@ -809,7 +661,7 @@ #ifndef wxUSE_LISTBOOK # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LISTBOOK must be defined, please read comment near the top of this file." +# error "wxUSE_LISTBOOK must be defined." # else # define wxUSE_LISTBOOK 0 # endif @@ -817,7 +669,7 @@ #ifndef wxUSE_LISTBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LISTBOX must be defined, please read comment near the top of this file." +# error "wxUSE_LISTBOX must be defined." # else # define wxUSE_LISTBOX 0 # endif @@ -825,7 +677,7 @@ #ifndef wxUSE_LISTCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LISTCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_LISTCTRL must be defined." # else # define wxUSE_LISTCTRL 0 # endif @@ -833,7 +685,7 @@ #ifndef wxUSE_LOGGUI # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LOGGUI must be defined, please read comment near the top of this file." +# error "wxUSE_LOGGUI must be defined." # else # define wxUSE_LOGGUI 0 # endif @@ -841,7 +693,7 @@ #ifndef wxUSE_LOGWINDOW # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LOGWINDOW must be defined, please read comment near the top of this file." +# error "wxUSE_LOGWINDOW must be defined." # else # define wxUSE_LOGWINDOW 0 # endif @@ -849,23 +701,15 @@ #ifndef wxUSE_LOG_DIALOG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_LOG_DIALOG must be defined, please read comment near the top of this file." +# error "wxUSE_LOG_DIALOG must be defined." # else # define wxUSE_LOG_DIALOG 0 # endif #endif /* !defined(wxUSE_LOG_DIALOG) */ -#ifndef wxUSE_MARKUP -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MARKUP must be defined, please read comment near the top of this file." -# else -# define wxUSE_MARKUP 0 -# endif -#endif /* !defined(wxUSE_MARKUP) */ - #ifndef wxUSE_MDI # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MDI must be defined, please read comment near the top of this file." +# error "wxUSE_MDI must be defined." # else # define wxUSE_MDI 0 # endif @@ -873,7 +717,7 @@ #ifndef wxUSE_MDI_ARCHITECTURE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MDI_ARCHITECTURE must be defined, please read comment near the top of this file." +# error "wxUSE_MDI_ARCHITECTURE must be defined." # else # define wxUSE_MDI_ARCHITECTURE 0 # endif @@ -881,7 +725,7 @@ #ifndef wxUSE_MENUS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MENUS must be defined, please read comment near the top of this file." +# error "wxUSE_MENUS must be defined." # else # define wxUSE_MENUS 0 # endif @@ -889,7 +733,7 @@ #ifndef wxUSE_MSGDLG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MSGDLG must be defined, please read comment near the top of this file." +# error "wxUSE_MSGDLG must be defined." # else # define wxUSE_MSGDLG 0 # endif @@ -897,23 +741,15 @@ #ifndef wxUSE_NOTEBOOK # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_NOTEBOOK must be defined, please read comment near the top of this file." +# error "wxUSE_NOTEBOOK must be defined." # else # define wxUSE_NOTEBOOK 0 # endif #endif /* !defined(wxUSE_NOTEBOOK) */ -#ifndef wxUSE_NOTIFICATION_MESSAGE -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_NOTIFICATION_MESSAGE must be defined, please read comment near the top of this file." -# else -# define wxUSE_NOTIFICATION_MESSAGE 0 -# endif -#endif /* !defined(wxUSE_NOTIFICATION_MESSAGE) */ - #ifndef wxUSE_ODCOMBOBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ODCOMBOBOX must be defined, please read comment near the top of this file." +# error "wxUSE_ODCOMBOBOX must be defined." # else # define wxUSE_ODCOMBOBOX 0 # endif @@ -921,7 +757,7 @@ #ifndef wxUSE_PALETTE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PALETTE must be defined, please read comment near the top of this file." +# error "wxUSE_PALETTE must be defined." # else # define wxUSE_PALETTE 0 # endif @@ -929,23 +765,15 @@ #ifndef wxUSE_POPUPWIN # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_POPUPWIN must be defined, please read comment near the top of this file." +# error "wxUSE_POPUPWIN must be defined." # else # define wxUSE_POPUPWIN 0 # endif #endif /* !defined(wxUSE_POPUPWIN) */ -#ifndef wxUSE_PREFERENCES_EDITOR -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PREFERENCES_EDITOR must be defined, please read comment near the top of this file." -# else -# define wxUSE_PREFERENCES_EDITOR 0 -# endif -#endif /* !defined(wxUSE_PREFERENCES_EDITOR) */ - #ifndef wxUSE_PRINTING_ARCHITECTURE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PRINTING_ARCHITECTURE must be defined, please read comment near the top of this file." +# error "wxUSE_PRINTING_ARCHITECTURE must be defined." # else # define wxUSE_PRINTING_ARCHITECTURE 0 # endif @@ -953,7 +781,7 @@ #ifndef wxUSE_RADIOBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RADIOBOX must be defined, please read comment near the top of this file." +# error "wxUSE_RADIOBOX must be defined." # else # define wxUSE_RADIOBOX 0 # endif @@ -961,47 +789,15 @@ #ifndef wxUSE_RADIOBTN # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RADIOBTN must be defined, please read comment near the top of this file." +# error "wxUSE_RADIOBTN must be defined." # else # define wxUSE_RADIOBTN 0 # endif #endif /* !defined(wxUSE_RADIOBTN) */ -#ifndef wxUSE_REARRANGECTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_REARRANGECTRL must be defined, please read comment near the top of this file." -# else -# define wxUSE_REARRANGECTRL 0 -# endif -#endif /* !defined(wxUSE_REARRANGECTRL) */ - -#ifndef wxUSE_RIBBON -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RIBBON must be defined, please read comment near the top of this file." -# else -# define wxUSE_RIBBON 0 -# endif -#endif /* !defined(wxUSE_RIBBON) */ - -#ifndef wxUSE_RICHMSGDLG -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RICHMSGDLG must be defined, please read comment near the top of this file." -# else -# define wxUSE_RICHMSGDLG 0 -# endif -#endif /* !defined(wxUSE_RICHMSGDLG) */ - -#ifndef wxUSE_RICHTOOLTIP -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RICHTOOLTIP must be defined, please read comment near the top of this file." -# else -# define wxUSE_RICHTOOLTIP 0 -# endif -#endif /* !defined(wxUSE_RICHTOOLTIP) */ - #ifndef wxUSE_SASH # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SASH must be defined, please read comment near the top of this file." +# error "wxUSE_SASH must be defined." # else # define wxUSE_SASH 0 # endif @@ -1009,7 +805,7 @@ #ifndef wxUSE_SCROLLBAR # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SCROLLBAR must be defined, please read comment near the top of this file." +# error "wxUSE_SCROLLBAR must be defined." # else # define wxUSE_SCROLLBAR 0 # endif @@ -1017,7 +813,7 @@ #ifndef wxUSE_SLIDER # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SLIDER must be defined, please read comment near the top of this file." +# error "wxUSE_SLIDER must be defined." # else # define wxUSE_SLIDER 0 # endif @@ -1025,7 +821,7 @@ #ifndef wxUSE_SOUND # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SOUND must be defined, please read comment near the top of this file." +# error "wxUSE_SOUND must be defined." # else # define wxUSE_SOUND 0 # endif @@ -1033,7 +829,7 @@ #ifndef wxUSE_SPINBTN # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SPINBTN must be defined, please read comment near the top of this file." +# error "wxUSE_SPINBTN must be defined." # else # define wxUSE_SPINBTN 0 # endif @@ -1041,7 +837,7 @@ #ifndef wxUSE_SPINCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SPINCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_SPINCTRL must be defined." # else # define wxUSE_SPINCTRL 0 # endif @@ -1049,7 +845,7 @@ #ifndef wxUSE_SPLASH # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SPLASH must be defined, please read comment near the top of this file." +# error "wxUSE_SPLASH must be defined." # else # define wxUSE_SPLASH 0 # endif @@ -1057,7 +853,7 @@ #ifndef wxUSE_SPLITTER # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SPLITTER must be defined, please read comment near the top of this file." +# error "wxUSE_SPLITTER must be defined." # else # define wxUSE_SPLITTER 0 # endif @@ -1065,7 +861,7 @@ #ifndef wxUSE_STATBMP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STATBMP must be defined, please read comment near the top of this file." +# error "wxUSE_STATBMP must be defined." # else # define wxUSE_STATBMP 0 # endif @@ -1073,7 +869,7 @@ #ifndef wxUSE_STATBOX # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STATBOX must be defined, please read comment near the top of this file." +# error "wxUSE_STATBOX must be defined." # else # define wxUSE_STATBOX 0 # endif @@ -1081,7 +877,7 @@ #ifndef wxUSE_STATLINE # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STATLINE must be defined, please read comment near the top of this file." +# error "wxUSE_STATLINE must be defined." # else # define wxUSE_STATLINE 0 # endif @@ -1089,7 +885,7 @@ #ifndef wxUSE_STATTEXT # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STATTEXT must be defined, please read comment near the top of this file." +# error "wxUSE_STATTEXT must be defined." # else # define wxUSE_STATTEXT 0 # endif @@ -1097,39 +893,31 @@ #ifndef wxUSE_STATUSBAR # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_STATUSBAR must be defined, please read comment near the top of this file." +# error "wxUSE_STATUSBAR must be defined." # else # define wxUSE_STATUSBAR 0 # endif #endif /* !defined(wxUSE_STATUSBAR) */ -#ifndef wxUSE_TASKBARICON +#ifndef wxUSE_TAB_DIALOG # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TASKBARICON must be defined, please read comment near the top of this file." +# error "wxUSE_TAB_DIALOG must be defined." # else -# define wxUSE_TASKBARICON 0 +# define wxUSE_TAB_DIALOG 0 # endif -#endif /* !defined(wxUSE_TASKBARICON) */ +#endif /* !defined(wxUSE_TAB_DIALOG) */ #ifndef wxUSE_TEXTCTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TEXTCTRL must be defined, please read comment near the top of this file." +# error "wxUSE_TEXTCTRL must be defined." # else # define wxUSE_TEXTCTRL 0 # endif #endif /* !defined(wxUSE_TEXTCTRL) */ -#ifndef wxUSE_TIMEPICKCTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TIMEPICKCTRL must be defined, please read comment near the top of this file." -# else -# define wxUSE_TIMEPICKCTRL 0 -# endif -#endif /* !defined(wxUSE_TIMEPICKCTRL) */ - #ifndef wxUSE_TIPWINDOW # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TIPWINDOW must be defined, please read comment near the top of this file." +# error "wxUSE_TIPWINDOW must be defined." # else # define wxUSE_TIPWINDOW 0 # endif @@ -1137,7 +925,7 @@ #ifndef wxUSE_TOOLBAR # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TOOLBAR must be defined, please read comment near the top of this file." +# error "wxUSE_TOOLBAR must be defined." # else # define wxUSE_TOOLBAR 0 # endif @@ -1145,7 +933,7 @@ #ifndef wxUSE_TOOLTIPS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TOOLTIPS must be defined, please read comment near the top of this file." +# error "wxUSE_TOOLTIPS must be defined." # else # define wxUSE_TOOLTIPS 0 # endif @@ -1153,47 +941,23 @@ #ifndef wxUSE_TREECTRL # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TREECTRL must be defined, please read comment near the top of this file." +# error "wxUSE_TREECTRL must be defined." # else # define wxUSE_TREECTRL 0 # endif #endif /* !defined(wxUSE_TREECTRL) */ -#ifndef wxUSE_TREELISTCTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TREELISTCTRL must be defined, please read comment near the top of this file." -# else -# define wxUSE_TREELISTCTRL 0 -# endif -#endif /* !defined(wxUSE_TREELISTCTRL) */ - -#ifndef wxUSE_UIACTIONSIMULATOR -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_UIACTIONSIMULATOR must be defined, please read comment near the top of this file." -# else -# define wxUSE_UIACTIONSIMULATOR 0 -# endif -#endif /* !defined(wxUSE_UIACTIONSIMULATOR) */ - #ifndef wxUSE_VALIDATORS # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_VALIDATORS must be defined, please read comment near the top of this file." +# error "wxUSE_VALIDATORS must be defined." # else # define wxUSE_VALIDATORS 0 # endif #endif /* !defined(wxUSE_VALIDATORS) */ -#ifndef wxUSE_WEBVIEW -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_WEBVIEW must be defined, please read comment near the top of this file." -# else -# define wxUSE_WEBVIEW 0 -# endif -#endif /* !defined(wxUSE_WEBVIEW) */ - #ifndef wxUSE_WXHTML_HELP # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_WXHTML_HELP must be defined, please read comment near the top of this file." +# error "wxUSE_WXHTML_HELP must be defined." # else # define wxUSE_WXHTML_HELP 0 # endif @@ -1201,7 +965,7 @@ #ifndef wxUSE_XRC # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_XRC must be defined, please read comment near the top of this file." +# error "wxUSE_XRC must be defined." # else # define wxUSE_XRC 0 # endif @@ -1210,63 +974,19 @@ #endif /* wxUSE_GUI */ /* - Section 2: platform-specific checks. - - This must be done after checking that everything is defined as the platform - checks use wxUSE_XXX symbols in #if tests. + check consistency of the settings */ -#if defined(__WXWINCE__) -# include "wx/msw/wince/chkconf.h" -#elif defined(__WINDOWS__) -# include "wx/msw/chkconf.h" -# if defined(__WXGTK__) -# include "wx/gtk/chkconf.h" -# endif -#elif defined(__WXGTK__) -# include "wx/gtk/chkconf.h" -#elif defined(__WXCOCOA__) -# include "wx/cocoa/chkconf.h" -#elif defined(__WXMAC__) -# include "wx/osx/chkconf.h" -#elif defined(__OS2__) -# include "wx/os2/chkconf.h" -#elif defined(__WXDFB__) -# include "wx/dfb/chkconf.h" -#elif defined(__WXMOTIF__) -# include "wx/motif/chkconf.h" -#elif defined(__WXX11__) -# include "wx/x11/chkconf.h" -#elif defined(__WXANDROID__) -# include "wx/android/chkconf.h" -#endif - -/* - __UNIX__ is also defined under Cygwin but we shouldn't perform these checks - there if we're building Windows ports. - */ -#if defined(__UNIX__) && !defined(__WINDOWS__) -# include "wx/unix/chkconf.h" -#endif - -#ifdef __WXUNIVERSAL__ -# include "wx/univ/chkconf.h" -#endif - -/* - Section 3a: check consistency of the non-GUI settings. - */ - -#if WXWIN_COMPATIBILITY_2_6 -# if !WXWIN_COMPATIBILITY_2_8 +#if WXWIN_COMPATIBILITY_2_4 +# if !WXWIN_COMPATIBILITY_2_6 # ifdef wxABORT_ON_CONFIG_ERROR -# error "2.6.X compatibility requires 2.8.X compatibility" +# error "2.4.X compatibility requires 2.6.X compatibility" # else -# undef WXWIN_COMPATIBILITY_2_8 -# define WXWIN_COMPATIBILITY_2_8 1 +# undef WXWIN_COMPATIBILITY_2_6 +# define WXWIN_COMPATIBILITY_2_6 1 # endif # endif -#endif /* WXWIN_COMPATIBILITY_2_6 */ +#endif /* WXWIN_COMPATIBILITY_2_4 */ #if wxUSE_ARCHIVE_STREAMS # if !wxUSE_DATETIME @@ -1279,6 +999,15 @@ # endif #endif /* wxUSE_ARCHIVE_STREAMS */ +#if wxUSE_CRASHREPORT && !wxUSE_ON_FATAL_EXCEPTION +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_CRASHREPORT requires wxUSE_ON_FATAL_EXCEPTION" +# else +# undef wxUSE_CRASHREPORT +# define wxUSE_CRASHREPORT 0 +# endif +#endif /* wxUSE_CRASHREPORT */ + #if wxUSE_PROTOCOL_FILE || wxUSE_PROTOCOL_FTP || wxUSE_PROTOCOL_HTTP # if !wxUSE_PROTOCOL # ifdef wxABORT_ON_CONFIG_ERROR @@ -1406,6 +1135,17 @@ # endif #endif /* wxUSE_MIMETYPE */ +#if wxUSE_ODBC +# if !wxUSE_DATETIME +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxODBC requires wxUSE_DATETIME" +# else +# undef wxUSE_ODBC +# define wxUSE_ODBC 0 +# endif +# endif +#endif /* wxUSE_ODBC */ + #if wxUSE_TEXTFILE && !wxUSE_TEXTBUFFER # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_TEXTFILE requires wxUSE_TEXTBUFFER" @@ -1424,6 +1164,15 @@ # endif #endif /* wxUSE_TEXTFILE */ +#if wxUSE_XML && !wxUSE_WCHAR_T +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_XML requires wxUSE_WCHAR_T" +# else +# undef wxUSE_XML +# define wxUSE_XML 0 +# endif +#endif /* wxUSE_XML */ + #if !wxUSE_DYNLIB_CLASS # if wxUSE_DYNAMIC_LOADER # ifdef wxABORT_ON_CONFIG_ERROR @@ -1453,6 +1202,18 @@ # endif #endif /* wxUSE_ZIPSTREAM */ +#if wxUSE_TARSTREAM + /* wxTar doesn't currently compile without wchar_t */ +# if !wxUSE_WCHAR_T +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxTar requires wchar_t" +# else +# undef wxUSE_TARSTREAM +# define wxUSE_TARSTREAM 0 +# endif +# endif +#endif /* wxUSE_TARSTREAM */ + #if wxUSE_TARSTREAM # if !wxUSE_ARCHIVE_STREAMS # ifdef wxABORT_ON_CONFIG_ERROR @@ -1464,20 +1225,9 @@ # endif #endif /* wxUSE_TARSTREAM */ -/* - Section 3b: the tests for the GUI settings only. - */ +/* the rest of the tests is for the GUI settings only */ #if wxUSE_GUI -#if wxUSE_ACCESSIBILITY && !defined(__WXMSW__) -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ACCESSIBILITY is currently only supported under wxMSW" -# else -# undef wxUSE_ACCESSIBILITY -# define wxUSE_ACCESSIBILITY 0 -# endif -#endif /* wxUSE_ACCESSIBILITY */ - #if wxUSE_BUTTON || \ wxUSE_CALENDARCTRL || \ wxUSE_CARET || \ @@ -1488,13 +1238,11 @@ wxUSE_CHOICE || \ wxUSE_GAUGE || \ wxUSE_GRID || \ - wxUSE_HEADERCTRL || \ wxUSE_LISTBOX || \ wxUSE_LISTCTRL || \ wxUSE_NOTEBOOK || \ wxUSE_RADIOBOX || \ wxUSE_RADIOBTN || \ - wxUSE_REARRANGECTRL || \ wxUSE_SCROLLBAR || \ wxUSE_SLIDER || \ wxUSE_SPINBTN || \ @@ -1506,8 +1254,7 @@ wxUSE_STATUSBAR || \ wxUSE_TEXTCTRL || \ wxUSE_TOOLBAR || \ - wxUSE_TREECTRL || \ - wxUSE_TREELISTCTRL + wxUSE_TREECTRL # if !wxUSE_CONTROLS # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_CONTROLS unset but some controls used" @@ -1529,17 +1276,6 @@ # endif #endif /* wxUSE_BMPBUTTON */ -#if wxUSE_COMMANDLINKBUTTON -# if !wxUSE_BUTTON -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_COMMANDLINKBUTTON requires wxUSE_BUTTON" -# else -# undef wxUSE_BUTTON -# define wxUSE_BUTTON 1 -# endif -# endif -#endif /* wxUSE_COMMANDLINKBUTTON */ - /* wxUSE_BOOKCTRL should be only used if any of the controls deriving from it are used @@ -1604,53 +1340,20 @@ #if !wxUSE_ODCOMBOBOX # if wxUSE_BITMAPCOMBOBOX -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxBitmapComboBox requires wxOwnerDrawnComboBox" -# else -# undef wxUSE_BITMAPCOMBOBOX -# define wxUSE_BITMAPCOMBOBOX 0 -# endif +# error "wxBitmapComboBox requires wxOwnerDrawnComboBox" +# else +# undef wxUSE_BITMAPCOMBOBOX +# define wxUSE_BITMAPCOMBOBOX 0 # endif #endif /* !wxUSE_ODCOMBOBOX */ -#if !wxUSE_HEADERCTRL -# if wxUSE_DATAVIEWCTRL || wxUSE_GRID -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxDataViewCtrl and wxGrid require wxHeaderCtrl" -# else -# undef wxUSE_HEADERCTRL -# define wxUSE_HEADERCTRL 1 -# endif -# endif -#endif /* !wxUSE_HEADERCTRL */ - -#if wxUSE_REARRANGECTRL -# if !wxUSE_CHECKLISTBOX -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxRearrangeCtrl requires wxCheckListBox" -# else -# undef wxUSE_REARRANGECTRL -# define wxUSE_REARRANGECTRL 0 -# endif -# endif -#endif /* wxUSE_REARRANGECTRL */ - -#if wxUSE_RICHMSGDLG -# if !wxUSE_MSGDLG -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_RICHMSGDLG requires wxUSE_MSGDLG" -# else -# undef wxUSE_MSGDLG -# define wxUSE_MSGDLG 1 -# endif -# endif -#endif /* wxUSE_RICHMSGDLG */ - /* don't attempt to use native status bar on the platforms not having it */ #ifndef wxUSE_NATIVE_STATUSBAR # define wxUSE_NATIVE_STATUSBAR 0 #elif wxUSE_NATIVE_STATUSBAR -# if defined(__WXUNIVERSAL__) || !(defined(__WXMSW__) || defined(__WXMAC__)) +# if defined(__WXUNIVERSAL__) || !( defined(__WXMSW__) || \ + defined(__WXMAC__) || \ + defined(__WXPALMOS__) ) # undef wxUSE_NATIVE_STATUSBAR # define wxUSE_NATIVE_STATUSBAR 0 # endif @@ -1666,6 +1369,40 @@ #endif /* wxUSE_GRAPHICS_CONTEXT */ +/* wxGTK-specific dependencies */ +#ifdef __WXGTK__ +# ifndef __WXUNIVERSAL__ +# if wxUSE_MDI_ARCHITECTURE && !wxUSE_MENUS +# ifdef wxABORT_ON_CONFIG_ERROR +# error "MDI requires wxUSE_MENUS in wxGTK" +# else +# undef wxUSE_MENUS +# define wxUSE_MENUS 1 +# endif +# endif +# endif /* !__WXUNIVERSAL__ */ + +# if wxUSE_JOYSTICK +# if !wxUSE_THREADS +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxJoystick requires threads in wxGTK" +# else +# undef wxUSE_JOYSTICK +# define wxUSE_JOYSTICK 0 +# endif +# endif +# endif +#endif /* wxGTK && !wxUniv */ + +/* Hopefully we can emulate these dialogs in due course */ +#if defined(__SMARTPHONE__) && defined(__WXWINCE__) +# ifdef wxUSE_COLOURDLG +# undef wxUSE_COLOURDLG +# define wxUSE_COLOURDLG 0 +# endif +#endif /* __SMARTPHONE__ && __WXWINCE__ */ + + /* generic controls dependencies */ #if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) # if wxUSE_FONTDLG || wxUSE_FILEDLG || wxUSE_CHOICEDLG @@ -1693,29 +1430,7 @@ # endif #endif /* !wxMSW || wxUniv */ -/* generic file dialog depends on (generic) file control */ -#if wxUSE_FILEDLG && !wxUSE_FILECTRL && \ - (defined(__WXUNIVERSAL__) || defined(__WXGTK__)) -# ifdef wxABORT_ON_CONFIG_ERROR -# error "Generic wxFileDialog requires wxFileCtrl" -# else -# undef wxUSE_FILECTRL -# define wxUSE_FILECTRL 1 -# endif -#endif /* wxUSE_FILEDLG */ - /* common dependencies */ -#if wxUSE_ARTPROVIDER_TANGO -# if !(wxUSE_STREAMS && wxUSE_IMAGE && wxUSE_LIBPNG) -# ifdef wxABORT_ON_CONFIG_ERROR -# error "Tango art provider requires wxImage with streams and PNG support" -# else -# undef wxUSE_ARTPROVIDER_TANGO -# define wxUSE_ARTPROVIDER_TANGO 0 -# endif -# endif -#endif /* wxUSE_ARTPROVIDER_TANGO */ - #if wxUSE_CALENDARCTRL # if !(wxUSE_SPINBTN && wxUSE_COMBOBOX) # ifdef wxABORT_ON_CONFIG_ERROR @@ -1738,16 +1453,16 @@ # endif #endif /* wxUSE_CALENDARCTRL */ -#if wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL +#if wxUSE_DATEPICKCTRL # if !wxUSE_DATETIME # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxDatePickerCtrl and wxTimePickerCtrl requires wxUSE_DATETIME" +# error "wxDatePickerCtrl requires wxUSE_DATETIME" # else # undef wxUSE_DATETIME # define wxUSE_DATETIME 1 # endif # endif -#endif /* wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL */ +#endif /* wxUSE_DATEPICKCTRL */ #if wxUSE_CHECKLISTBOX # if !wxUSE_LISTBOX @@ -1771,17 +1486,6 @@ # endif #endif /* wxUSE_CHOICEDLG */ -#if wxUSE_FILECTRL -# if !wxUSE_DATETIME -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxFileCtrl requires wxDateTime" -# else -# undef wxUSE_DATETIME -# define wxUSE_DATETIME 1 -# endif -# endif -#endif /* wxUSE_FILECTRL */ - #if wxUSE_HELP # if !wxUSE_BMPBUTTON # ifdef wxABORT_ON_CONFIG_ERROR @@ -1958,15 +1662,6 @@ # define wxUSE_STREAMS 1 # endif # endif - -# if !wxUSE_FILE_HISTORY -# ifdef wxABORT_ON_CONFIG_ERROR -# error "DocView requires wxUSE_FILE_HISTORY" -# else -# undef wxUSE_FILE_HISTORY -# define wxUSE_FILE_HISTORY 1 -# endif -# endif #endif /* wxUSE_DOC_VIEW_ARCHITECTURE */ #if wxUSE_PRINTING_ARCHITECTURE @@ -2012,7 +1707,7 @@ #endif /* wxUSE_FILEDLG */ #if !wxUSE_GAUGE || !wxUSE_BUTTON -# if wxUSE_PROGRESSDLG +# if wxUSE_PROGRESSDLG && !defined(__WXPALMOS__) # ifdef wxABORT_ON_CONFIG_ERROR # error "Generic progress dialog requires wxUSE_GAUGE and wxUSE_BUTTON" # else @@ -2054,7 +1749,7 @@ #endif #if !wxUSE_IMAGLIST -# if wxUSE_TREECTRL || wxUSE_NOTEBOOK || wxUSE_LISTCTRL || wxUSE_TREELISTCTRL +# if wxUSE_TREECTRL || wxUSE_NOTEBOOK || wxUSE_LISTCTRL # ifdef wxABORT_ON_CONFIG_ERROR # error "wxImageList must be compiled as well" # else @@ -2064,6 +1759,16 @@ # endif #endif /* !wxUSE_IMAGLIST */ +#if !wxUSE_MSGDLG +# ifdef wxABORT_ON_CONFIG_ERROR + /* FIXME: should compile without it, of course, but doesn't */ +# error "wxMessageBox is always needed" +# else +# undef wxUSE_MSGDLG +# define wxUSE_MSGDLG 1 +# endif +#endif + #if wxUSE_RADIOBOX # if !wxUSE_RADIOBTN # ifdef wxABORT_ON_CONFIG_ERROR @@ -2073,7 +1778,7 @@ # define wxUSE_RADIOBTN 1 # endif # endif -# if !wxUSE_STATBOX +# if !wxUSE_STATBOX && !defined(__WXPALMOS__) # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_RADIOBOX requires wxUSE_STATBOX" # else @@ -2116,6 +1821,15 @@ # endif #endif /* wxUSE_CLIPBOARD */ +#if wxUSE_WX_RESOURCES && !wxUSE_PROLOGIO +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxr resources require PrologIO" +# else +# undef wxUSE_PROLOGIO +# define wxUSE_PROLOGIO 1 +# endif +#endif /* wxUSE_WX_RESOURCES */ + #if wxUSE_XRC && !wxUSE_XML # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_XRC requires wxUSE_XML" @@ -2134,42 +1848,6 @@ # endif #endif /* wxUSE_SOCKETS */ -#if wxUSE_SVG && !wxUSE_STREAMS -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SVG requires wxUSE_STREAMS" -# else -# undef wxUSE_SVG -# define wxUSE_SVG 0 -# endif -#endif /* wxUSE_SVG */ - -#if wxUSE_SVG && !wxUSE_IMAGE -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SVG requires wxUSE_IMAGE" -# else -# undef wxUSE_SVG -# define wxUSE_SVG 0 -# endif -#endif /* wxUSE_SVG */ - -#if wxUSE_SVG && !wxUSE_LIBPNG -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_SVG requires wxUSE_LIBPNG" -# else -# undef wxUSE_SVG -# define wxUSE_SVG 0 -# endif -#endif /* wxUSE_SVG */ - -#if wxUSE_TASKBARICON && !wxUSE_MENUS -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TASKBARICON requires wxUSE_MENUS" -# else -# undef wxUSE_TASKBARICON -# define wxUSE_TASKBARICON 0 -# endif -#endif /* wxUSE_TASKBARICON */ - #if !wxUSE_VARIANT # if wxUSE_DATAVIEWCTRL # ifdef wxABORT_ON_CONFIG_ERROR @@ -2179,53 +1857,15 @@ # define wxUSE_DATAVIEWCTRL 0 # endif # endif -#endif /* wxUSE_VARIANT */ -#if wxUSE_TREELISTCTRL && !wxUSE_DATAVIEWCTRL -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TREELISTCTRL requires wxDataViewCtrl" -# else -# undef wxUSE_TREELISTCTRL -# define wxUSE_TREELISTCTRL 0 -# endif -#endif /* wxUSE_TREELISTCTRL */ - -#if wxUSE_WEBVIEW && !(wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_IE) -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_WEBVIEW requires at least one backend" -# else -# undef wxUSE_WEBVIEW -# define wxUSE_WEBVIEW 0 -# endif -#endif /* wxUSE_WEBVIEW && !any web view backend */ - -#if wxUSE_PREFERENCES_EDITOR - /* - We can use either a generic implementation, using wxNotebook, or a - native one under wxOSX/Cocoa but then we must be using the native - toolbar. - */ -# if !wxUSE_NOTEBOOK -# ifdef __WXOSX_COCOA__ -# if !wxUSE_TOOLBAR || !wxOSX_USE_NATIVE_TOOLBAR -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PREFERENCES_EDITOR requires native toolbar in wxOSX" -# else -# undef wxUSE_PREFERENCES_EDITOR -# define wxUSE_PREFERENCES_EDITOR 0 -# endif -# endif +# if wxUSE_ODBC +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_ODBC requires wxVariant" # else -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_PREFERENCES_EDITOR requires wxNotebook" -# else -# undef wxUSE_PREFERENCES_EDITOR -# define wxUSE_PREFERENCES_EDITOR 0 -# endif +# undef wxUSE_ODBC +# define wxUSE_ODBC 0 # endif # endif -#endif /* wxUSE_PREFERENCES_EDITOR */ +#endif /* wxUSE_VARIANT */ #endif /* wxUSE_GUI */ - -#endif /* _WX_CHKCONF_H_ */ diff --git a/Source/3rd Party/wx/include/wx/choicdlg.h b/Source/3rd Party/wx/include/wx/choicdlg.h index e2a15a0b8..76867ec67 100644 --- a/Source/3rd Party/wx/include/wx/choicdlg.h +++ b/Source/3rd Party/wx/include/wx/choicdlg.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/choicdlg.h +// Name: wx/choicdgg.h // Purpose: Includes generic choice dialog file // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: choicdlg.h 33948 2005-05-04 18:57:50Z JS $ // Copyright: Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,12 +12,11 @@ #ifndef _WX_CHOICDLG_H_BASE_ #define _WX_CHOICDLG_H_BASE_ -#include "wx/defs.h" - #if wxUSE_CHOICEDLG #include "wx/generic/choicdgg.h" #endif -#endif // _WX_CHOICDLG_H_BASE_ +#endif + // _WX_CHOICDLG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/choice.h b/Source/3rd Party/wx/include/wx/choice.h index f1b9ee886..fe2a9fa76 100644 --- a/Source/3rd Party/wx/include/wx/choice.h +++ b/Source/3rd Party/wx/include/wx/choice.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.07.99 +// RCS-ID: $Id: choice.h 42727 2006-10-30 16:04:27Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -25,13 +26,13 @@ // global data // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxChoiceNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxChoiceNameStr[]; // ---------------------------------------------------------------------------- // wxChoice allows to select one of a non-modifiable list of strings // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxChoiceBase : public wxControlWithItems +class WXDLLEXPORT wxChoiceBase : public wxControlWithItems { public: wxChoiceBase() { } @@ -54,18 +55,8 @@ public: // emulate selecting the item event.GetInt() void Command(wxCommandEvent& event); - // override wxItemContainer::IsSorted - virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } - -protected: - // The generic implementation doesn't determine the height correctly and - // doesn't account for the width of the arrow but does take into account - // the string widths, so the derived classes should override it and set the - // height and add the arrow width to the size returned by this version. - virtual wxSize DoGetBestSize() const; - private: - wxDECLARE_NO_COPY_CLASS(wxChoiceBase); + DECLARE_NO_COPY_CLASS(wxChoiceBase) }; // ---------------------------------------------------------------------------- @@ -85,7 +76,7 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/choice.h" #elif defined(__WXMAC__) - #include "wx/osx/choice.h" + #include "wx/mac/choice.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/choice.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/choicebk.h b/Source/3rd Party/wx/include/wx/choicebk.h index 60ff2a1e6..2f35c0a01 100644 --- a/Source/3rd Party/wx/include/wx/choicebk.h +++ b/Source/3rd Party/wx/include/wx/choicebk.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h // Created: 15.09.04 +// RCS-ID: $Id: choicebk.h 59616 2009-03-18 21:58:15Z VZ $ // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,12 +18,11 @@ #include "wx/bookctrl.h" #include "wx/choice.h" -#include "wx/containr.h" class WXDLLIMPEXP_FWD_CORE wxChoice; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; // wxChoicebook flags #define wxCHB_DEFAULT wxBK_DEFAULT @@ -36,10 +36,13 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBo // wxChoicebook // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxChoicebook : public wxNavigationEnabled +class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase { public: - wxChoicebook() { } + wxChoicebook() + { + Init(); + } wxChoicebook(wxWindow *parent, wxWindowID id, @@ -48,6 +51,8 @@ public: long style = 0, const wxString& name = wxEmptyString) { + Init(); + (void)Create(parent, id, pos, size, style, name); } @@ -60,17 +65,18 @@ public: const wxString& name = wxEmptyString); + virtual int GetSelection() const; virtual bool SetPageText(size_t n, const wxString& strText); virtual wxString GetPageText(size_t n) const; virtual int GetPageImage(size_t n) const; virtual bool SetPageImage(size_t n, int imageId); + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; virtual bool InsertPage(size_t n, wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); - virtual int SetSelection(size_t n) - { return DoSetSelection(n, SetSelection_SendEvent); } + int imageId = -1); + virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual void SetImageList(wxImageList *imageList); @@ -79,29 +85,31 @@ public: // returns the choice control wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; } - // Override this to return true because the part of parent window - // background between our controlling wxChoice and the page area should - // show through. - virtual bool HasTransparentBackground() { return true; } - protected: - virtual void DoSetWindowVariant(wxWindowVariant variant); - virtual wxWindow *DoRemovePage(size_t page); + // get the size which the choice control should have + virtual wxSize GetControllerSize() const; + void UpdateSelectedPage(size_t newsel) { - m_selection = static_cast(newsel); + m_selection = wx_static_cast(int, newsel); GetChoiceCtrl()->Select(m_selection); } - wxBookCtrlEvent* CreatePageChangingEvent() const; - void MakeChangedEvent(wxBookCtrlEvent &event); + wxBookCtrlBaseEvent* CreatePageChangingEvent() const; + void MakeChangedEvent(wxBookCtrlBaseEvent &event); // event handlers void OnChoiceSelected(wxCommandEvent& event); + // the currently selected page or wxNOT_FOUND if none + int m_selection; + private: + // common part of all constructors + void Init(); + DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) }; @@ -110,20 +118,36 @@ private: // choicebook event class and related stuff // ---------------------------------------------------------------------------- -// wxChoicebookEvent is obsolete and defined for compatibility only -#define wxChoicebookEvent wxBookCtrlEvent -typedef wxBookCtrlEventFunction wxChoicebookEventFunction; -#define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func) +class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent +{ +public: + wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + int nSel = -1, int nOldSel = -1) + : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) + { + } + + wxChoicebookEvent(const wxChoicebookEvent& event) + : wxBookCtrlBaseEvent(event) + { + } + + virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent) +}; + +typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&); + +#define wxChoicebookEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func) #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn)) #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED -#define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING + wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn)) #endif // wxUSE_CHOICEBOOK diff --git a/Source/3rd Party/wx/include/wx/clipbrd.h b/Source/3rd Party/wx/include/wx/clipbrd.h index 2ae8eef8c..11976bec9 100644 --- a/Source/3rd Party/wx/include/wx/clipbrd.h +++ b/Source/3rd Party/wx/include/wx/clipbrd.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.10.99 +// RCS-ID: $Id: clipbrd.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets Team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,11 +17,11 @@ #if wxUSE_CLIPBOARD -#include "wx/event.h" -#include "wx/chartype.h" -#include "wx/dataobj.h" // for wxDataFormat -#include "wx/vector.h" +#include "wx/object.h" +#include "wx/wxchar.h" +class WXDLLIMPEXP_FWD_CORE wxDataFormat; +class WXDLLIMPEXP_FWD_CORE wxDataObject; class WXDLLIMPEXP_FWD_CORE wxClipboard; // ---------------------------------------------------------------------------- @@ -31,10 +32,10 @@ class WXDLLIMPEXP_FWD_CORE wxClipboard; // with wxDataObject. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxClipboardBase : public wxObject +class WXDLLEXPORT wxClipboardBase : public wxObject { public: - wxClipboardBase() { m_usePrimary = false; } + wxClipboardBase() {} // open the clipboard before Add/SetData() and GetData() virtual bool Open() = 0; @@ -58,9 +59,6 @@ public: // ask if data in correct format is available virtual bool IsSupported( const wxDataFormat& format ) = 0; - // ask if data in correct format is available - virtual bool IsSupportedAsync( wxEvtHandler *sink ); - // fill data with data on the clipboard (if available) virtual bool GetData( wxDataObject& data ) = 0; @@ -72,72 +70,13 @@ public: // eating memory), otherwise the clipboard will be emptied on exit virtual bool Flush() { return false; } - // this allows to choose whether we work with CLIPBOARD (default) or - // PRIMARY selection on X11-based systems - // - // on the other ones, working with primary selection does nothing: this - // allows to write code which sets the primary selection when something is - // selected without any ill effects (i.e. without overwriting the - // clipboard which would be wrong on the platforms without X11 PRIMARY) - virtual void UsePrimarySelection(bool usePrimary = false) - { - m_usePrimary = usePrimary; - } - - // return true if we're using primary selection - bool IsUsingPrimarySelection() const { return m_usePrimary; } + // X11 has two clipboards which get selected by this call. Empty on MSW. + virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { } // Returns global instance (wxTheClipboard) of the object: static wxClipboard *Get(); - - - // don't use this directly, it is public for compatibility with some ports - // (wxX11, wxMotif, ...) only - bool m_usePrimary; }; -// ---------------------------------------------------------------------------- -// asynchronous clipboard event -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxClipboardEvent : public wxEvent -{ -public: - wxClipboardEvent(wxEventType evtType = wxEVT_NULL) - : wxEvent(0, evtType) - { - } - - wxClipboardEvent(const wxClipboardEvent& event) - : wxEvent(event), - m_formats(event.m_formats) - { - } - - bool SupportsFormat(const wxDataFormat& format) const; - void AddFormat(const wxDataFormat& format); - - virtual wxEvent *Clone() const - { - return new wxClipboardEvent(*this); - } - - -protected: - wxVector m_formats; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardEvent) -}; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent ); - -typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&); - -#define wxClipboardEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxClipboardEventFunction, func) - -#define EVT_CLIPBOARD_CHANGED(func) wx__DECLARE_EVT0(wxEVT_CLIPBOARD_CHANGED, wxClipboardEventHandler(func)) - // ---------------------------------------------------------------------------- // globals // ---------------------------------------------------------------------------- @@ -159,8 +98,10 @@ typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&); #include "wx/gtk1/clipbrd.h" #elif defined(__WXX11__) #include "wx/x11/clipbrd.h" +#elif defined(__WXMGL__) + #include "wx/mgl/clipbrd.h" #elif defined(__WXMAC__) - #include "wx/osx/clipbrd.h" + #include "wx/mac/clipbrd.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/clipbrd.h" #elif defined(__WXPM__) @@ -171,10 +112,10 @@ typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&); // helpful class for opening the clipboard and automatically closing it // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxClipboardLocker +class WXDLLEXPORT wxClipboardLocker { public: - wxClipboardLocker(wxClipboard *clipboard = NULL) + wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL) { m_clipboard = clipboard ? clipboard : wxTheClipboard; if ( m_clipboard ) @@ -196,7 +137,7 @@ public: private: wxClipboard *m_clipboard; - wxDECLARE_NO_COPY_CLASS(wxClipboardLocker); + DECLARE_NO_COPY_CLASS(wxClipboardLocker) }; #endif // wxUSE_CLIPBOARD diff --git a/Source/3rd Party/wx/include/wx/clntdata.h b/Source/3rd Party/wx/include/wx/clntdata.h index 09148f719..f9704a7d0 100644 --- a/Source/3rd Party/wx/include/wx/clntdata.h +++ b/Source/3rd Party/wx/include/wx/clntdata.h @@ -4,6 +4,7 @@ // Author: Robin Dunn // Modified by: // Created: 9-Oct-2001 +// RCS-ID: $Id: clntdata.h 36973 2006-01-18 16:45:41Z JS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -158,5 +159,115 @@ protected: }; +#include "wx/vector.h" + +struct WXDLLIMPEXP_BASE wxClientDataDictionaryPair +{ + wxClientDataDictionaryPair( size_t idx ) : index( idx ), data( 0 ) { } + + size_t index; + wxClientData* data; +}; + +_WX_DECLARE_VECTOR( + wxClientDataDictionaryPair, + wxClientDataDictionaryPairVector, + WXDLLIMPEXP_BASE +); + +// this class is used internally to maintain the association between items +// of (some subclasses of) wxControlWithItems and their client data +// NOTE: this class does not keep track of whether it contains +// wxClientData or void*. The client must ensure that +// it does not contain a mix of the two, and that +// DestroyData is called if it contains wxClientData +class WXDLLIMPEXP_BASE wxClientDataDictionary +{ +public: + wxClientDataDictionary() {} + + // deletes all the data + void DestroyData() + { + for( size_t i = 0, end = m_vec.size(); i != end; ++i ) + delete m_vec[i].data; + m_vec.clear(); + } + + // if data for the given index is not present, add it, + // if it is present, delete the old data and replace it with + // the new one + void Set( size_t index, wxClientData* data, bool doDelete ) + { + size_t ptr = Find( index ); + + if( !data ) + { + if( ptr == m_vec.size() ) return; + if( doDelete ) + delete m_vec[ptr].data; + m_vec.erase( ptr ); + } + else + { + if( ptr == m_vec.size() ) + { + m_vec.push_back( wxClientDataDictionaryPair( index ) ); + ptr = m_vec.size() - 1; + } + + if( doDelete ) + delete m_vec[ptr].data; + m_vec[ptr].data = data; + } + } + + // get the data associated with the given index, + // return 0 if not found + wxClientData* Get( size_t index ) const + { + size_t it = Find( index ); + if( it == m_vec.size() ) return 0; + return (wxClientData*)m_vec[it].data; // const cast + } + + // delete the data associated with the given index + // it also decreases by one the indices of all the elements + // with an index greater than the given index + void Delete( size_t index, bool doDelete ) + { + size_t todel = m_vec.size(); + + for( size_t i = 0, end = m_vec.size(); i != end; ++i ) + { + if( m_vec[i].index == index ) + todel = i; + else if( m_vec[i].index > index ) + --(m_vec[i].index); + } + + if( todel != m_vec.size() ) + { + if( doDelete ) + delete m_vec[todel].data; + m_vec.erase( todel ); + } + } +private: + // returns MyVec.size() if not found + size_t Find( size_t index ) const + { + for( size_t i = 0, end = m_vec.size(); i != end; ++i ) + { + if( m_vec[i].index == index ) + return i; + } + + return m_vec.size(); + } + + wxClientDataDictionaryPairVector m_vec; +}; + #endif // _WX_CLNTDATAH__ diff --git a/Source/3rd Party/wx/include/wx/clrpicker.h b/Source/3rd Party/wx/include/wx/clrpicker.h index 0d83898ed..f6a436fc3 100644 --- a/Source/3rd Party/wx/include/wx/clrpicker.h +++ b/Source/3rd Party/wx/include/wx/clrpicker.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Vadim Zeitlin, Francesco Montorsi +// RCS-ID: $Id: clrpicker.h 53135 2008-04-12 02:31:04Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -21,15 +22,8 @@ class WXDLLIMPEXP_FWD_CORE wxColourPickerEvent; -extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerWidgetNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerCtrlNameStr[]; - -// show the colour in HTML form (#AABBCC) as colour button label -#define wxCLRBTN_SHOW_LABEL 100 - -// the default style -#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL) - +extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerWidgetNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerCtrlNameStr[]; // ---------------------------------------------------------------------------- @@ -76,7 +70,7 @@ protected: // same prototype for their contructor (and also explains why we use // define instead of a typedef) // since GTK > 2.4, there is GtkColorButton -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/clrpicker.h" #define wxColourPickerWidget wxColourButton #else @@ -97,7 +91,7 @@ protected: class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase { public: - wxColourPickerCtrl() {} + wxColourPickerCtrl() : m_bIgnoreNextTextCtrlUpdate(false) {} virtual ~wxColourPickerCtrl() {} @@ -106,6 +100,7 @@ public: const wxSize& size = wxDefaultSize, long style = wxCLRP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxColourPickerCtrlNameStr) + : m_bIgnoreNextTextCtrlUpdate(false) { Create(parent, id, col, pos, size, style, validator, name); } bool Create(wxWindow *parent, wxWindowID id, @@ -146,6 +141,9 @@ protected: virtual long GetPickerStyle(long style) const { return (style & wxCLRP_SHOW_LABEL); } + // true if the next UpdateTextCtrl() call is to ignore + bool m_bIgnoreNextTextCtrlUpdate; + private: DECLARE_DYNAMIC_CLASS(wxColourPickerCtrl) }; @@ -155,14 +153,16 @@ private: // wxColourPickerEvent: used by wxColourPickerCtrl only // ---------------------------------------------------------------------------- -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_CHANGED, wxColourPickerEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLOURPICKER_CHANGED, 1102) +END_DECLARE_EVENT_TYPES() class WXDLLIMPEXP_CORE wxColourPickerEvent : public wxCommandEvent { public: wxColourPickerEvent() {} wxColourPickerEvent(wxObject *generator, int id, const wxColour &col) - : wxCommandEvent(wxEVT_COLOURPICKER_CHANGED, id), + : wxCommandEvent(wxEVT_COMMAND_COLOURPICKER_CHANGED, id), m_colour(col) { SetEventObject(generator); @@ -188,15 +188,12 @@ private: typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&); #define wxColourPickerEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxColourPickerEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxColourPickerEventFunction, &func) #define EVT_COLOURPICKER_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_COLOURPICKER_CHANGED, id, wxColourPickerEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_COLOURPICKER_CHANGED, id, wxColourPickerEventHandler(fn)) -// old wxEVT_COMMAND_* constant -#define wxEVT_COMMAND_COLOURPICKER_CHANGED wxEVT_COLOURPICKER_CHANGED - #endif // wxUSE_COLOURPICKERCTRL #endif // _WX_CLRPICKER_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/cmdargs.h b/Source/3rd Party/wx/include/wx/cmdargs.h deleted file mode 100644 index e4167f0fd..000000000 --- a/Source/3rd Party/wx/include/wx/cmdargs.h +++ /dev/null @@ -1,151 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/cmdargs.h -// Purpose: declaration of wxCmdLineArgsArray helper class -// Author: Vadim Zeitlin -// Created: 2007-11-12 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CMDARGS_H_ -#define _WX_CMDARGS_H_ - -#include "wx/arrstr.h" - -// ---------------------------------------------------------------------------- -// wxCmdLineArgsArray: helper class used by wxApp::argv -// ---------------------------------------------------------------------------- - -#if wxUSE_UNICODE - -// this class is used instead of either "char **" or "wchar_t **" (neither of -// which would be backwards compatible with all the existing code) for argv -// field of wxApp -// -// as it's used for compatibility, it tries to look as much as traditional -// (char **) argv as possible, in particular it provides implicit conversions -// to "char **" and also array-like operator[] -class WXDLLIMPEXP_BASE wxCmdLineArgsArray -{ -public: - wxCmdLineArgsArray() { m_argsA = NULL; m_argsW = NULL; } - - template - wxCmdLineArgsArray& operator=(T **argv) - { - FreeArgs(); - - m_args.clear(); - - if ( argv ) - { - while ( *argv ) - m_args.push_back(*argv++); - } - - return *this; - } - - operator char**() const - { - if ( !m_argsA ) - { - const size_t count = m_args.size(); - m_argsA = new char *[count]; - for ( size_t n = 0; n < count; n++ ) - m_argsA[n] = wxStrdup(m_args[n].ToAscii()); - } - - return m_argsA; - } - - operator wchar_t**() const - { - if ( !m_argsW ) - { - const size_t count = m_args.size(); - m_argsW = new wchar_t *[count]; - for ( size_t n = 0; n < count; n++ ) - m_argsW[n] = wxStrdup(m_args[n].wc_str()); - } - - return m_argsW; - } - - // existing code does checks like "if ( argv )" and we want it to continue - // to compile, so provide this conversion even if it is pretty dangerous - operator bool() const - { - return !m_args.empty(); - } - - // and the same for "if ( !argv )" checks - bool operator!() const - { - return m_args.empty(); - } - - wxString operator[](size_t n) const - { - return m_args[n]; - } - - // we must provide this overload for g++ 3.4 which can't choose between - // our operator[](size_t) and ::operator[](char**, int) otherwise - wxString operator[](int n) const - { - return m_args[n]; - } - - - // convenience methods, i.e. not existing only for backwards compatibility - - // do we have any arguments at all? - bool IsEmpty() const { return m_args.empty(); } - - // access the arguments as a convenient array of wxStrings - const wxArrayString& GetArguments() const { return m_args; } - - ~wxCmdLineArgsArray() - { - FreeArgs(); - } - -private: - template - void Free(T **args) - { - if ( !args ) - return; - - const size_t count = m_args.size(); - for ( size_t n = 0; n < count; n++ ) - free(args[n]); - - delete [] args; - } - - void FreeArgs() - { - Free(m_argsA); - Free(m_argsW); - } - - wxArrayString m_args; - mutable char **m_argsA; - mutable wchar_t **m_argsW; - - wxDECLARE_NO_COPY_CLASS(wxCmdLineArgsArray); -}; - -// provide global operator overload for compatibility with the existing code -// doing things like "if ( condition && argv )" -inline bool operator&&(bool cond, const wxCmdLineArgsArray& array) -{ - return cond && !array.IsEmpty(); -} - -#endif // wxUSE_UNICODE - -#endif // _WX_CMDARGS_H_ - diff --git a/Source/3rd Party/wx/include/wx/cmdline.h b/Source/3rd Party/wx/include/wx/cmdline.h index 5f12bfe47..9f6e6080b 100644 --- a/Source/3rd Party/wx/include/wx/cmdline.h +++ b/Source/3rd Party/wx/include/wx/cmdline.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 04.01.00 +// RCS-ID: $Id: cmdline.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,14 +17,6 @@ #include "wx/string.h" #include "wx/arrstr.h" -#include "wx/cmdargs.h" - -// determines ConvertStringToArgs() behaviour -enum wxCmdLineSplitType -{ - wxCMD_LINE_SPLIT_DOS, - wxCMD_LINE_SPLIT_UNIX -}; #if wxUSE_CMDLINE_PARSER @@ -35,14 +28,13 @@ class WXDLLIMPEXP_FWD_BASE wxDateTime; // by default, options are optional (sic) and each call to AddParam() allows // one more parameter - this may be changed by giving non-default flags to it -enum wxCmdLineEntryFlags +enum { wxCMD_LINE_OPTION_MANDATORY = 0x01, // this option must be given wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request - wxCMD_LINE_NEEDS_SEPARATOR = 0x10, // must have sep before the value - wxCMD_LINE_SWITCH_NEGATABLE = 0x20 // this switch can be negated (e.g. /S-) + wxCMD_LINE_NEEDS_SEPARATOR = 0x10 // must have sep before the value }; // an option value or parameter may be a string (the most common case), a @@ -52,7 +44,6 @@ enum wxCmdLineParamType wxCMD_LINE_VAL_STRING, // should be 0 (default) wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_VAL_DATE, - wxCMD_LINE_VAL_DOUBLE, wxCMD_LINE_VAL_NONE }; @@ -62,18 +53,9 @@ enum wxCmdLineEntryType wxCMD_LINE_SWITCH, wxCMD_LINE_OPTION, wxCMD_LINE_PARAM, - wxCMD_LINE_USAGE_TEXT, wxCMD_LINE_NONE // to terminate the list }; -// Possible return values of wxCmdLineParser::FoundSwitch() -enum wxCmdLineSwitchState -{ - wxCMD_SWITCH_OFF = -1, // Found but turned off/negated. - wxCMD_SWITCH_NOT_FOUND, // Not found at all. - wxCMD_SWITCH_ON // Found in normal state. -}; - // ---------------------------------------------------------------------------- // wxCmdLineEntryDesc is a description of one command line // switch/option/parameter @@ -82,17 +64,13 @@ enum wxCmdLineSwitchState struct wxCmdLineEntryDesc { wxCmdLineEntryType kind; - const char *shortName; - const char *longName; - const char *description; + const wxChar *shortName; + const wxChar *longName; + const wxChar *description; wxCmdLineParamType type; int flags; }; -// the list of wxCmdLineEntryDesc objects should be terminated with this one -#define wxCMD_LINE_DESC_END \ - { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0x0 } - // ---------------------------------------------------------------------------- // wxCmdLineParser is a class for parsing command line. // @@ -122,8 +100,6 @@ public: wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); } #if wxUSE_UNICODE wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); } - wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv) - { Init(); SetCmdLine(argc, argv); } #endif // wxUSE_UNICODE wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); } @@ -136,10 +112,6 @@ public: #if wxUSE_UNICODE wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); SetDesc(desc); } - wxCmdLineParser(const wxCmdLineEntryDesc *desc, - int argc, - const wxCmdLineArgsArray& argv) - { Init(); SetCmdLine(argc, argv); SetDesc(desc); } #endif // wxUSE_UNICODE wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline) { Init(); SetCmdLine(cmdline); SetDesc(desc); } @@ -148,7 +120,6 @@ public: void SetCmdLine(int argc, char **argv); #if wxUSE_UNICODE void SetCmdLine(int argc, wxChar **argv); - void SetCmdLine(int argc, const wxCmdLineArgsArray& argv); #endif // wxUSE_UNICODE void SetCmdLine(const wxString& cmdline); @@ -167,7 +138,7 @@ public: void EnableLongOptions(bool enable = true); void DisableLongOptions() { EnableLongOptions(false); } - bool AreLongOptionsEnabled() const; + bool AreLongOptionsEnabled(); // extra text may be shown by Usage() method if set by this function void SetLogo(const wxString& logo); @@ -182,34 +153,18 @@ public: void AddSwitch(const wxString& name, const wxString& lng = wxEmptyString, const wxString& desc = wxEmptyString, int flags = 0); - void AddLongSwitch(const wxString& lng, - const wxString& desc = wxEmptyString, - int flags = 0) - { - AddSwitch(wxString(), lng, desc, flags); - } // an option taking a value of the given type void AddOption(const wxString& name, const wxString& lng = wxEmptyString, const wxString& desc = wxEmptyString, wxCmdLineParamType type = wxCMD_LINE_VAL_STRING, int flags = 0); - void AddLongOption(const wxString& lng, - const wxString& desc = wxEmptyString, - wxCmdLineParamType type = wxCMD_LINE_VAL_STRING, - int flags = 0) - { - AddOption(wxString(), lng, desc, type, flags); - } // a parameter void AddParam(const wxString& desc = wxEmptyString, wxCmdLineParamType type = wxCMD_LINE_VAL_STRING, int flags = 0); - // add an explanatory text to be shown to the user in help - void AddUsageText(const wxString& text); - // actions // ------- @@ -222,10 +177,7 @@ public: int Parse(bool showUsage = true); // give the usage message describing all program options - void Usage() const; - - // return the usage string, call Usage() to directly show it to the user - wxString GetUsageString() const; + void Usage(); // get the command line arguments // ------------------------------ @@ -233,12 +185,6 @@ public: // returns true if the given switch was found bool Found(const wxString& name) const; - // Returns wxCMD_SWITCH_NOT_FOUND if the switch was not found at all, - // wxCMD_SWITCH_ON if it was found in normal state and wxCMD_SWITCH_OFF if - // it was found but negated (i.e. followed by "-", this can only happen for - // the switches with wxCMD_LINE_SWITCH_NEGATABLE flag). - wxCmdLineSwitchState FoundSwitch(const wxString& name) const; - // returns true if an option taking a string value was found and stores the // value in the provided pointer bool Found(const wxString& name, wxString *value) const; @@ -247,10 +193,6 @@ public: // the value in the provided pointer bool Found(const wxString& name, long *value) const; - // returns true if an option taking a double value was found and stores - // the value in the provided pointer - bool Found(const wxString& name, double *value) const; - #if wxUSE_DATETIME // returns true if an option taking a date value was found and stores the // value in the provided pointer @@ -267,17 +209,18 @@ public: void Reset(); // break down the command line in arguments - static wxArrayString - ConvertStringToArgs(const wxString& cmdline, - wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS); + static wxArrayString ConvertStringToArgs(const wxChar *cmdline); private: + // get usage string + wxString GetUsageString(); + // common part of all ctors void Init(); struct wxCmdLineParserData *m_data; - wxDECLARE_NO_COPY_CLASS(wxCmdLineParser); + DECLARE_NO_COPY_CLASS(wxCmdLineParser) }; #else // !wxUSE_CMDLINE_PARSER @@ -287,11 +230,10 @@ private: class WXDLLIMPEXP_BASE wxCmdLineParser { public: - static wxArrayString - ConvertStringToArgs(const wxString& cmdline, - wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS); + static wxArrayString ConvertStringToArgs(const wxChar *cmdline); }; #endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER #endif // _WX_CMDLINE_H_ + diff --git a/Source/3rd Party/wx/include/wx/cmdproc.h b/Source/3rd Party/wx/include/wx/cmdproc.h index 24b0b597f..930cad753 100644 --- a/Source/3rd Party/wx/include/wx/cmdproc.h +++ b/Source/3rd Party/wx/include/wx/cmdproc.h @@ -4,6 +4,7 @@ // Author: Julian Smart (extracted from docview.h by VZ) // Modified by: // Created: 05.11.00 +// RCS-ID: $Id: cmdproc.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ class WXDLLIMPEXP_FWD_CORE wxMenu; // wxCommand: a single command capable of performing itself // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCommand : public wxObject +class WXDLLEXPORT wxCommand : public wxObject { public: wxCommand(bool canUndoIt = false, const wxString& name = wxEmptyString); @@ -48,7 +49,7 @@ private: // wxCommandProcessor: wxCommand manager // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCommandProcessor : public wxObject +class WXDLLEXPORT wxCommandProcessor : public wxObject { public: // if max number of commands is -1, it is unlimited @@ -96,7 +97,10 @@ public: virtual void ClearCommands(); // Has the current project been changed? - virtual bool IsDirty() const; + virtual bool IsDirty() const + { + return m_currentCommand && (m_lastSavedCommand != m_currentCommand); + } // Mark the current command as the one where the last save took place void MarkAsSaved() @@ -133,7 +137,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxCommandProcessor) - wxDECLARE_NO_COPY_CLASS(wxCommandProcessor); + DECLARE_NO_COPY_CLASS(wxCommandProcessor) }; #endif // _WX_CMDPROC_H_ diff --git a/Source/3rd Party/wx/include/wx/cmndata.h b/Source/3rd Party/wx/include/wx/cmndata.h index 1b9204a51..a96c4ff72 100644 --- a/Source/3rd Party/wx/include/wx/cmndata.h +++ b/Source/3rd Party/wx/include/wx/cmndata.h @@ -4,6 +4,7 @@ // Author: Julian Smart and others // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: cmndata.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,18 +12,134 @@ #ifndef _WX_CMNDATA_H_BASE_ #define _WX_CMNDATA_H_BASE_ -#include "wx/defs.h" - -#if wxUSE_PRINTING_ARCHITECTURE - +#include "wx/window.h" +#include "wx/font.h" +#include "wx/encinfo.h" +#include "wx/colour.h" #include "wx/gdicmn.h" #if wxUSE_STREAMS #include "wx/stream.h" #endif + class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase; + +class WXDLLEXPORT wxColourData: public wxObject +{ +public: + wxColourData(); + wxColourData(const wxColourData& data); + virtual ~wxColourData(); + + void SetChooseFull(bool flag) { m_chooseFull = flag; } + bool GetChooseFull() const { return m_chooseFull; } + void SetColour(const wxColour& colour) { m_dataColour = colour; } + const wxColour& GetColour() const { return m_dataColour; } + wxColour& GetColour() { return m_dataColour; } + + // Array of 16 custom colours + void SetCustomColour(int i, const wxColour& colour); + wxColour GetCustomColour(int i); + + void operator=(const wxColourData& data); + +public: + wxColour m_dataColour; + wxColour m_custColours[16]; + bool m_chooseFull; + +private: + DECLARE_DYNAMIC_CLASS(wxColourData) +}; + +class WXDLLEXPORT wxFontData : public wxObject +{ +public: + wxFontData(); + virtual ~wxFontData(); + + wxFontData(const wxFontData& data) + : wxObject(), + m_fontColour(data.m_fontColour), + m_showHelp(data.m_showHelp), + m_allowSymbols(data.m_allowSymbols), + m_enableEffects(data.m_enableEffects), + m_initialFont(data.m_initialFont), + m_chosenFont(data.m_chosenFont), + m_minSize(data.m_minSize), + m_maxSize(data.m_maxSize), + m_encoding(data.m_encoding), + m_encodingInfo(data.m_encodingInfo) + { + } + + wxFontData& operator=(const wxFontData& data) + { + wxObject::operator=(data); + m_fontColour = data.m_fontColour; + m_showHelp = data.m_showHelp; + m_allowSymbols = data.m_allowSymbols; + m_enableEffects = data.m_enableEffects; + m_initialFont = data.m_initialFont; + m_chosenFont = data.m_chosenFont; + m_minSize = data.m_minSize; + m_maxSize = data.m_maxSize; + m_encoding = data.m_encoding; + m_encodingInfo = data.m_encodingInfo; + return *this; + } + + void SetAllowSymbols(bool flag) { m_allowSymbols = flag; } + bool GetAllowSymbols() const { return m_allowSymbols; } + + void SetColour(const wxColour& colour) { m_fontColour = colour; } + const wxColour& GetColour() const { return m_fontColour; } + + void SetShowHelp(bool flag) { m_showHelp = flag; } + bool GetShowHelp() const { return m_showHelp; } + + void EnableEffects(bool flag) { m_enableEffects = flag; } + bool GetEnableEffects() const { return m_enableEffects; } + + void SetInitialFont(const wxFont& font) { m_initialFont = font; } + wxFont GetInitialFont() const { return m_initialFont; } + + void SetChosenFont(const wxFont& font) { m_chosenFont = font; } + wxFont GetChosenFont() const { return m_chosenFont; } + + void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; } + + // encoding info is split into 2 parts: the logical wxWin encoding + // (wxFontEncoding) and a structure containing the native parameters for + // it (wxNativeEncodingInfo) + wxFontEncoding GetEncoding() const { return m_encoding; } + void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; } + + wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; } + + + // public for backwards compatibility only: don't use directly +public: + wxColour m_fontColour; + bool m_showHelp; + bool m_allowSymbols; + bool m_enableEffects; + wxFont m_initialFont; + wxFont m_chosenFont; + int m_minSize; + int m_maxSize; + +private: + wxFontEncoding m_encoding; + wxNativeEncodingInfo m_encodingInfo; + +private: + DECLARE_DYNAMIC_CLASS(wxFontData) +}; + +#if wxUSE_PRINTING_ARCHITECTURE /* * wxPrintData * Encapsulates printer information (not printer dialog information) @@ -51,7 +168,7 @@ enum wxPrintBin const int wxPRINTMEDIA_DEFAULT = 0; -class WXDLLIMPEXP_CORE wxPrintData: public wxObject +class WXDLLEXPORT wxPrintData: public wxObject { public: wxPrintData(); @@ -60,7 +177,7 @@ public: int GetNoCopies() const { return m_printNoCopies; } bool GetCollate() const { return m_printCollate; } - wxPrintOrientation GetOrientation() const { return m_printOrientation; } + int GetOrientation() const { return m_printOrientation; } bool IsOrientationReversed() const { return m_printOrientationReversed; } // Is this data OK for showing the print dialog? @@ -80,11 +197,7 @@ public: void SetNoCopies(int v) { m_printNoCopies = v; } void SetCollate(bool flag) { m_printCollate = flag; } - - // Please use the overloaded method below - wxDEPRECATED_INLINE(void SetOrientation(int orient), - m_printOrientation = (wxPrintOrientation)orient; ) - void SetOrientation(wxPrintOrientation orient) { m_printOrientation = orient; } + void SetOrientation(int orient) { m_printOrientation = orient; } void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; } void SetPrinterName(const wxString& name) { m_printerName = name; } @@ -100,13 +213,36 @@ public: wxString GetFilename() const { return m_filename; } void SetFilename( const wxString &filename ) { m_filename = filename; } - wxPrintData& operator=(const wxPrintData& data); + void operator=(const wxPrintData& data); char* GetPrivData() const { return m_privData; } int GetPrivDataLen() const { return m_privDataLen; } void SetPrivData( char *privData, int len ); +#if WXWIN_COMPATIBILITY_2_4 + // PostScript-specific data + wxString GetPrinterCommand() const; + wxString GetPrinterOptions() const; + wxString GetPreviewCommand() const; + wxString GetFontMetricPath() const; + double GetPrinterScaleX() const; + double GetPrinterScaleY() const; + long GetPrinterTranslateX() const; + long GetPrinterTranslateY() const; + + void SetPrinterCommand(const wxString& command); + void SetPrinterOptions(const wxString& options); + void SetPreviewCommand(const wxString& command); + void SetFontMetricPath(const wxString& path); + void SetPrinterScaleX(double x); + void SetPrinterScaleY(double y); + void SetPrinterScaling(double x, double y); + void SetPrinterTranslateX(long x); + void SetPrinterTranslateY(long y); + void SetPrinterTranslation(long x, long y); +#endif + // Convert between wxPrintData and native data void ConvertToNative(); void ConvertFromNative(); @@ -119,7 +255,7 @@ private: wxPrintMode m_printMode; int m_printNoCopies; - wxPrintOrientation m_printOrientation; + int m_printOrientation; bool m_printOrientationReversed; bool m_printCollate; @@ -148,7 +284,7 @@ private: * from the dialog. */ -class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject +class WXDLLEXPORT wxPrintDialogData: public wxObject { public: wxPrintDialogData(); @@ -165,7 +301,9 @@ public: bool GetSelection() const { return m_printSelection; } bool GetCollate() const { return m_printCollate; } bool GetPrintToFile() const { return m_printToFile; } - +#if WXWIN_COMPATIBILITY_2_4 + bool GetSetupDialog() const { return m_printSetupDialog; } +#endif void SetFromPage(int v) { m_printFromPage = v; } void SetToPage(int v) { m_printToPage = v; } void SetMinPage(int v) { m_printMinPage = v; } @@ -175,7 +313,9 @@ public: void SetSelection(bool flag) { m_printSelection = flag; } void SetCollate(bool flag) { m_printCollate = flag; } void SetPrintToFile(bool flag) { m_printToFile = flag; } - +#if WXWIN_COMPATIBILITY_2_4 + void SetSetupDialog(bool flag) { m_printSetupDialog = flag; } +#endif void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; } void EnableSelection(bool flag) { m_printEnableSelection = flag; } void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; } @@ -188,7 +328,7 @@ public: // Is this data OK for showing the print dialog? bool Ok() const { return IsOk(); } - bool IsOk() const { return m_printData.IsOk() ; } + bool IsOk() const { return m_printData.Ok() ; } wxPrintData& GetPrintData() { return m_printData; } void SetPrintData(const wxPrintData& printData) { m_printData = printData; } @@ -210,6 +350,9 @@ private: bool m_printEnablePageNumbers; bool m_printEnableHelp; bool m_printEnablePrintToFile; +#if WXWIN_COMPATIBILITY_2_4 + bool m_printSetupDialog; +#endif wxPrintData m_printData; private: @@ -223,7 +366,7 @@ private: // Compatibility with old name #define wxPageSetupData wxPageSetupDialogData -class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject +class WXDLLEXPORT wxPageSetupDialogData: public wxObject { public: wxPageSetupDialogData(); @@ -248,7 +391,7 @@ public: // Is this data OK for showing the page setup dialog? bool Ok() const { return IsOk(); } - bool IsOk() const { return m_printData.IsOk() ; } + bool IsOk() const { return m_printData.Ok() ; } // If a corresponding paper type is found in the paper database, will set the m_printData // paper size id member as well. @@ -279,7 +422,7 @@ public: // Use paper id in wxPrintData to set this object's paper size void CalculatePaperSizeFromId(); - wxPageSetupDialogData& operator=(const wxPageSetupDialogData& data); + wxPageSetupDialogData& operator=(const wxPageSetupData& data); wxPageSetupDialogData& operator=(const wxPrintData& data); wxPrintData& GetPrintData() { return m_printData; } diff --git a/Source/3rd Party/wx/include/wx/collpane.h b/Source/3rd Party/wx/include/wx/collpane.h index b83ff2974..483d33b26 100644 --- a/Source/3rd Party/wx/include/wx/collpane.h +++ b/Source/3rd Party/wx/include/wx/collpane.h @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 8/10/2006 +// RCS-ID: $Id: collpane.h 43300 2006-11-11 07:32:08Z RD $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -18,8 +19,6 @@ #include "wx/control.h" -// class name -extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsiblePaneNameStr[]; // ---------------------------------------------------------------------------- // wxCollapsiblePaneBase: interface for wxCollapsiblePane @@ -50,16 +49,16 @@ public: // event types and macros // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLLPANE_CHANGED, 1102) +END_DECLARE_EVENT_TYPES() class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent { public: wxCollapsiblePaneEvent() {} wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed) - : wxCommandEvent(wxEVT_COLLAPSIBLEPANE_CHANGED, id), + : wxCommandEvent(wxEVT_COMMAND_COLLPANE_CHANGED, id), m_bCollapsed(collapsed) { SetEventObject(generator); @@ -85,13 +84,13 @@ private: typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&); #define wxCollapsiblePaneEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxCollapsiblePaneEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCollapsiblePaneEventFunction, &func) #define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_COLLAPSIBLEPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_COLLPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn)) -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/collpane.h" #else #include "wx/generic/collpaneg.h" @@ -100,9 +99,6 @@ typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEv #define wxCollapsiblePane wxGenericCollapsiblePane #endif -// old wxEVT_COMMAND_* constant -#define wxEVT_COMMAND_COLLPANE_CHANGED wxEVT_COLLAPSIBLEPANE_CHANGED - #endif // wxUSE_COLLPANE #endif // _WX_COLLAPSABLE_PANE_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/colordlg.h b/Source/3rd Party/wx/include/wx/colordlg.h index ab5b645b4..f17192078 100644 --- a/Source/3rd Party/wx/include/wx/colordlg.h +++ b/Source/3rd Party/wx/include/wx/colordlg.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/colordlg.h +// Name: wx/colrdlgg.h // Purpose: wxColourDialog // Author: Vadim Zeitiln // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: colordlg.h 36623 2006-01-02 14:26:36Z JS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,14 +16,14 @@ #if wxUSE_COLOURDLG -#include "wx/colourdata.h" - #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #include "wx/msw/colordlg.h" #elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__) - #include "wx/osx/colordlg.h" + #include "wx/mac/colordlg.h" #elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/colordlg.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/colordlg.h" #else #include "wx/generic/colrdlgg.h" @@ -30,10 +31,9 @@ #endif // get the colour from user and return it -WXDLLIMPEXP_CORE wxColour wxGetColourFromUser(wxWindow *parent = NULL, - const wxColour& colInit = wxNullColour, - const wxString& caption = wxEmptyString, - wxColourData *data = NULL); +wxColour WXDLLEXPORT +wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL, + const wxColour& colInit = wxNullColour, const wxString& caption = wxEmptyString); #endif // wxUSE_COLOURDLG diff --git a/Source/3rd Party/wx/include/wx/colour.h b/Source/3rd Party/wx/include/wx/colour.h index 13878927a..66c45e772 100644 --- a/Source/3rd Party/wx/include/wx/colour.h +++ b/Source/3rd Party/wx/include/wx/colour.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Francesco Montorsi // Created: +// RCS-ID: $Id: colour.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,46 +15,38 @@ #include "wx/defs.h" #include "wx/gdiobj.h" + class WXDLLIMPEXP_FWD_CORE wxColour; -// A macro to define the standard wxColour constructors: -// -// It avoids the need to repeat these lines across all colour.h files, since -// Set() is a virtual function and thus cannot be called by wxColourBase ctors +// the standard wxColour constructors; +// this macro avoids to repeat these lines across all colour.h files, since +// Set() is a virtual function and thus cannot be called by wxColourBase +// constructors #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ - wxColour() { Init(); } \ - wxColour(ChannelType red, \ - ChannelType green, \ - ChannelType blue, \ - ChannelType alpha = wxALPHA_OPAQUE) \ - { Init(); Set(red, green, blue, alpha); } \ - wxColour(unsigned long colRGB) { Init(); Set(colRGB ); } \ - wxColour(const wxString& colourName) { Init(); Set(colourName); } \ - wxColour(const char *colourName) { Init(); Set(colourName); } \ - wxColour(const wchar_t *colourName) { Init(); Set(colourName); } + wxColour( ChannelType red, ChannelType green, ChannelType blue, \ + ChannelType alpha = wxALPHA_OPAQUE ) \ + { Set(red, green, blue, alpha); } \ + wxColour( unsigned long colRGB ) { Set(colRGB); } \ + wxColour(const wxString &colourName) { Set(colourName); } \ + wxColour(const wxChar *colourName) { Set(colourName); } // flags for wxColour -> wxString conversion (see wxColour::GetAsString) -enum { - wxC2S_NAME = 1, // return colour name, when possible - wxC2S_CSS_SYNTAX = 2, // return colour in rgb(r,g,b) syntax - wxC2S_HTML_SYNTAX = 4 // return colour in #rrggbb syntax -}; +#define wxC2S_NAME 1 // return colour name, when possible +#define wxC2S_CSS_SYNTAX 2 // return colour in rgb(r,g,b) syntax +#define wxC2S_HTML_SYNTAX 4 // return colour in #rrggbb syntax + const unsigned char wxALPHA_TRANSPARENT = 0; const unsigned char wxALPHA_OPAQUE = 0xff; -// a valid but fully transparent colour -#define wxTransparentColour wxColour(0, 0, 0, wxALPHA_TRANSPARENT) -#define wxTransparentColor wxTransparentColour - // ---------------------------------------------------------------------------- // wxVariant support // ---------------------------------------------------------------------------- #if wxUSE_VARIANT #include "wx/variant.h" -DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLIMPEXP_CORE) +DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT) #endif //----------------------------------------------------------------------------- @@ -61,22 +54,7 @@ DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLIMPEXP_CORE) // code redundancy in all native wxColour implementations //----------------------------------------------------------------------------- -/* Transition from wxGDIObject to wxObject is incomplete. If your port does - not need the wxGDIObject machinery to handle colors, please add it to the - list of ports which do not need it. - */ -#if defined( __WXMAC__ ) || defined( __WXMSW__ ) || defined( __WXPM__ ) || defined( __WXCOCOA__ ) -#define wxCOLOUR_IS_GDIOBJECT 0 -#else -#define wxCOLOUR_IS_GDIOBJECT 1 -#endif - -class WXDLLIMPEXP_CORE wxColourBase : public -#if wxCOLOUR_IS_GDIOBJECT - wxGDIObject -#else - wxObject -#endif +class WXDLLEXPORT wxColourBase : public wxGDIObject { public: // type of a single colour component @@ -93,9 +71,12 @@ public: ChannelType green, ChannelType blue, ChannelType alpha = wxALPHA_OPAQUE) - { InitRGBA(red, green, blue, alpha); } + { InitRGBA(red,green,blue, alpha); } // implemented in colourcmn.cpp + bool Set(const wxChar *str) + { return FromString(str); } + bool Set(const wxString &str) { return FromString(str); } @@ -113,6 +94,9 @@ public: // accessors // --------- + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const = 0; + virtual ChannelType Red() const = 0; virtual ChannelType Green() const = 0; virtual ChannelType Blue() const = 0; @@ -122,98 +106,28 @@ public: // implemented in colourcmn.cpp virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const; - void SetRGB(wxUint32 colRGB) - { - Set((ChannelType)(0xFF & colRGB), - (ChannelType)(0xFF & (colRGB >> 8)), - (ChannelType)(0xFF & (colRGB >> 16))); - } - void SetRGBA(wxUint32 colRGBA) - { - Set((ChannelType)(0xFF & colRGBA), - (ChannelType)(0xFF & (colRGBA >> 8)), - (ChannelType)(0xFF & (colRGBA >> 16)), - (ChannelType)(0xFF & (colRGBA >> 24))); - } - - wxUint32 GetRGB() const - { return Red() | (Green() << 8) | (Blue() << 16); } - - wxUint32 GetRGBA() const - { return Red() | (Green() << 8) | (Blue() << 16) | (Alpha() << 24); } - -#if !wxCOLOUR_IS_GDIOBJECT - virtual bool IsOk() const= 0; - - // older version, for backwards compatibility only (but not deprecated - // because it's still widely used) - bool Ok() const { return IsOk(); } -#endif - - // manipulation - // ------------ - - // These methods are static because they are mostly used - // within tight loops (where we don't want to instantiate wxColour's) - - static void MakeMono (unsigned char* r, unsigned char* g, unsigned char* b, bool on); - static void MakeDisabled(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char brightness = 255); - static void MakeGrey (unsigned char* r, unsigned char* g, unsigned char* b); // integer version - static void MakeGrey (unsigned char* r, unsigned char* g, unsigned char* b, - double weight_r, double weight_g, double weight_b); // floating point version - static unsigned char AlphaBlend (unsigned char fg, unsigned char bg, double alpha); - static void ChangeLightness(unsigned char* r, unsigned char* g, unsigned char* b, int ialpha); - - wxColour ChangeLightness(int ialpha) const; - wxColour& MakeDisabled(unsigned char brightness = 255); // old, deprecated // --------------- #if WXWIN_COMPATIBILITY_2_6 - static wxDEPRECATED( wxColour CreateByName(const wxString& name) ); + wxDEPRECATED( static wxColour CreateByName(const wxString& name) ); wxDEPRECATED( void InitFromName(const wxString& col) ); #endif protected: - // Some ports need Init() and while we don't, provide a stub so that the - // ports which don't need it are not forced to define it - void Init() { } - virtual void InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0; - virtual bool FromString(const wxString& s); - -#if wxCOLOUR_IS_GDIOBJECT - // wxColour doesn't use reference counted data (at least not in all ports) - // so provide stubs for the functions which need to be defined if we do use - // them - virtual wxGDIRefData *CreateGDIRefData() const - { - wxFAIL_MSG( "must be overridden if used" ); - - return NULL; - } - - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const - { - wxFAIL_MSG( "must be overridden if used" ); - - return NULL; - } -#endif + virtual bool FromString(const wxChar *s); }; -// wxColour <-> wxString utilities, used by wxConfig, defined in colourcmn.cpp -WXDLLIMPEXP_CORE wxString wxToString(const wxColourBase& col); -WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxColourBase* col); - - -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/generic/colour.h" +#elif defined(__WXMSW__) #include "wx/msw/colour.h" #elif defined(__WXMOTIF__) #include "wx/motif/colour.h" @@ -221,12 +135,14 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxColourBase* col); #include "wx/gtk/colour.h" #elif defined(__WXGTK__) #include "wx/gtk1/colour.h" +#elif defined(__WXMGL__) + #include "wx/generic/colour.h" #elif defined(__WXDFB__) #include "wx/generic/colour.h" #elif defined(__WXX11__) #include "wx/x11/colour.h" #elif defined(__WXMAC__) - #include "wx/osx/colour.h" + #include "wx/mac/colour.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/colour.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/colourdata.h b/Source/3rd Party/wx/include/wx/colourdata.h deleted file mode 100644 index 5a755ae07..000000000 --- a/Source/3rd Party/wx/include/wx/colourdata.h +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/colourdata.h -// Author: Julian Smart -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_COLOURDATA_H_ -#define _WX_COLOURDATA_H_ - -#include "wx/colour.h" - -class WXDLLIMPEXP_CORE wxColourData : public wxObject -{ -public: - // number of custom colours we store - enum - { - NUM_CUSTOM = 16 - }; - - wxColourData(); - wxColourData(const wxColourData& data); - wxColourData& operator=(const wxColourData& data); - virtual ~wxColourData(); - - void SetChooseFull(bool flag) { m_chooseFull = flag; } - bool GetChooseFull() const { return m_chooseFull; } - void SetColour(const wxColour& colour) { m_dataColour = colour; } - const wxColour& GetColour() const { return m_dataColour; } - wxColour& GetColour() { return m_dataColour; } - - // SetCustomColour() modifies colours in an internal array of NUM_CUSTOM - // custom colours; - void SetCustomColour(int i, const wxColour& colour); - wxColour GetCustomColour(int i) const; - - // Serialize the object to a string and restore it from it - wxString ToString() const; - bool FromString(const wxString& str); - - - // public for backwards compatibility only: don't use directly - wxColour m_dataColour; - wxColour m_custColours[NUM_CUSTOM]; - bool m_chooseFull; - - DECLARE_DYNAMIC_CLASS(wxColourData) -}; - -#endif // _WX_COLOURDATA_H_ diff --git a/Source/3rd Party/wx/include/wx/combo.h b/Source/3rd Party/wx/include/wx/combo.h index 5b3d5868b..2e5593d72 100644 --- a/Source/3rd Party/wx/include/wx/combo.h +++ b/Source/3rd Party/wx/include/wx/combo.h @@ -4,6 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 +// RCS-ID: $Id: combo.h 64412 2010-05-27 15:11:58Z JMS $ // Copyright: (c) Jaakko Salli // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -44,7 +45,6 @@ #include "wx/control.h" #include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags #include "wx/bitmap.h" // wxBitmap used by-value -#include "wx/textentry.h" class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class WXDLLIMPEXP_FWD_CORE wxComboPopup; @@ -86,8 +86,8 @@ enum wxCC_IFLAG_CREATED = 0x0100, // Internal use: really put button outside wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200, - // Internal use: SetMargins has been successfully called - wxCC_IFLAG_LEFT_MARGIN_SET = 0x0400, + // Internal use: SetTextIndent has been called + wxCC_IFLAG_INDENT_SET = 0x0400, // Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800, // Internal use: Secondary popup window type should be used (if available). @@ -119,8 +119,7 @@ struct wxComboCtrlFeatures BitmapButton = 0x0002, // Button may be replaced with bitmap ButtonSpacing = 0x0004, // Button can have spacing from the edge // of the control - TextIndent = 0x0008, // SetMargins can be used to control - // left margin. + TextIndent = 0x0008, // SetTextIndent can be used PaintControl = 0x0010, // Combo control itself can be custom painted PaintWritable = 0x0020, // A variable-width area in front of writable // combo control's textctrl can be custom @@ -139,14 +138,12 @@ struct wxComboCtrlFeatures }; -class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxControl, - public wxTextEntry +class WXDLLEXPORT wxComboCtrlBase : public wxControl { friend class wxComboPopup; - friend class wxComboPopupEvtHandler; public: // ctors and such - wxComboCtrlBase() : wxControl(), wxTextEntry() { Init(); } + wxComboCtrlBase() : wxControl() { Init(); } bool Create(wxWindow *parent, wxWindowID id, @@ -159,19 +156,9 @@ public: virtual ~wxComboCtrlBase(); - // Show/hide popup window (wxComboBox-compatible methods) - virtual void Popup(); - virtual void Dismiss() - { - HidePopup(true); - } - - // Show/hide popup window. - // TODO: Maybe deprecate in favor of Popup()/Dismiss(). - // However, these functions are still called internally - // so it is not straightforward. + // show/hide popup window virtual void ShowPopup(); - virtual void HidePopup(bool generateEvent=false); + virtual void HidePopup(); // Override for totally custom combo action virtual void OnButtonClick(); @@ -207,56 +194,26 @@ public: virtual bool Enable(bool enable = true); virtual bool Show(bool show = true); virtual bool SetFont(const wxFont& font); +#if wxUSE_VALIDATORS + virtual void SetValidator(const wxValidator &validator); + virtual wxValidator *GetValidator(); +#endif // wxUSE_VALIDATORS - // - // wxTextEntry methods - // - // NB: We basically need to override all of them because there is - // no guarantee how platform-specific wxTextEntry is implemented. - // - virtual void SetValue(const wxString& value) - { wxTextEntryBase::SetValue(value); } - virtual void ChangeValue(const wxString& value) - { wxTextEntryBase::ChangeValue(value); } - - virtual void WriteText(const wxString& text); - virtual void AppendText(const wxString& text) - { wxTextEntryBase::AppendText(text); } - - virtual wxString GetValue() const - { return wxTextEntryBase::GetValue(); } - - virtual wxString GetRange(long from, long to) const - { return wxTextEntryBase::GetRange(from, to); } - - // Replace() and DoSetValue() need to be fully re-implemented since - // EventSuppressor utility class does not work with the way - // wxComboCtrl is implemented. - virtual void Replace(long from, long to, const wxString& value); - - virtual void Remove(long from, long to); - + // wxTextCtrl methods - for readonly combo they should return + // without errors. + virtual wxString GetValue() const; + virtual void SetValue(const wxString& value); virtual void Copy(); virtual void Cut(); virtual void Paste(); - - virtual void Undo(); - virtual void Redo(); - virtual bool CanUndo() const; - virtual bool CanRedo() const; - virtual void SetInsertionPoint(long pos); + virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; virtual long GetLastPosition() const; - + virtual void Replace(long from, long to, const wxString& value); + virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); - virtual void GetSelection(long *from, long *to) const; - - virtual bool IsEditable() const; - virtual void SetEditable(bool editable); - - virtual bool SetHint(const wxString& hint); - virtual wxString GetHint() const; + virtual void Undo(); // This method sets the text without affecting list selection // (ie. wxComboPopup::SetStringValue doesn't get called). @@ -264,13 +221,7 @@ public: // This method sets value and also optionally sends EVT_TEXT // (needed by combo popups) - wxDEPRECATED( void SetValueWithEvent(const wxString& value, - bool withEvent = true) ); - - // Changes value of the control as if user had done it by selecting an - // item from a combo box drop-down list. Needs to be public so that - // derived popup classes can call it. - void SetValueByUser(const wxString& value); + void SetValueWithEvent(const wxString& value, bool withEvent = true); // // Popup customization methods @@ -352,18 +303,19 @@ public: const wxBitmap& bmpHover = wxNullBitmap, const wxBitmap& bmpDisabled = wxNullBitmap ); -#if WXWIN_COMPATIBILITY_2_8 // // This will set the space in pixels between left edge of the control and the // text, regardless whether control is read-only (ie. no wxTextCtrl) or not. // Platform-specific default can be set with value-1. // Remarks // * This method may do nothing on some native implementations. - wxDEPRECATED( void SetTextIndent( int indent ) ); + void SetTextIndent( int indent ); // Returns actual indentation in pixels. - wxDEPRECATED( wxCoord GetTextIndent() const ); -#endif + wxCoord GetTextIndent() const + { + return m_absIndent; + } // Returns area covered by the text field. const wxRect& GetTextRect() const @@ -434,21 +386,14 @@ public: const wxBitmap& GetBitmapHover() const { return m_bmpHover; } const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } - // Set custom style flags for embedded wxTextCtrl. Usually must be used - // with two-step creation, before Create() call. - void SetTextCtrlStyle( int style ); - // Return internal flags wxUint32 GetInternalFlags() const { return m_iFlags; } // Return true if Create has finished bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; } - // Need to override to return text area background colour - wxColour GetBackgroundColour() const; - // common code to be called on popup hide/dismiss - void OnPopupDismiss(bool generateEvent); + void OnPopupDismiss(); // PopupShown states enum @@ -466,26 +411,8 @@ public: // Set value returned by GetMainWindowOfCompositeControl void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; } - // This is public so we can access it from wxComboCtrlTextCtrl - virtual wxWindow *GetMainWindowOfCompositeControl() - { return m_mainCtrlWnd; } - - // also set the embedded wxTextCtrl colours - virtual bool SetForegroundColour(const wxColour& colour); - virtual bool SetBackgroundColour(const wxColour& colour); - protected: - // Returns true if hint text should be drawn in the control - bool ShouldUseHintText(int flags = 0) const - { - return ( !m_text && - !(flags & wxCONTROL_ISSUBMENU) && - !m_valueString.length() && - m_hintText.length() && - !ShouldDrawFocus() ); - } - // // Override these for customization purposes // @@ -493,8 +420,7 @@ protected: // called from wxSizeEvent handler virtual void OnResize() = 0; - // Return native text identation - // (i.e. text margin, for pure text, not textctrl) + // Return native text identation (for pure text, not textctrl) virtual wxCoord GetNativeTextIndent() const; // Called in syscolourchanged handler and base create @@ -502,25 +428,20 @@ protected: // Creates wxTextCtrl. // extraStyle: Extra style parameters - void CreateTextCtrl( int extraStyle ); - - // Called when text was changed programmatically - // (e.g. from WriteText()) - void OnSetValue(const wxString& value); + void CreateTextCtrl( int extraStyle, const wxValidator& validator ); // Installs standard input handler to combo (and optionally to the textctrl) void InstallInputHandlers(); - // Flags for DrawButton + // flags for DrawButton() enum { - Button_PaintBackground = 0x0001, // Paints control background below the button - Button_BitmapOnly = 0x0002 // Only paints the bitmap + Draw_PaintBg = 1, + Draw_BitmapOnly = 2 }; // Draws dropbutton. Using wxRenderer or bitmaps, as appropriate. - // Flags are defined above. - virtual void DrawButton( wxDC& dc, const wxRect& rect, int flags = Button_PaintBackground ); + void DrawButton( wxDC& dc, const wxRect& rect, int flags = Draw_PaintBg ); // Call if cursor is on button area or mouse is captured for the button. //bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside ); @@ -544,10 +465,7 @@ protected: void DestroyPopup(); // override the base class virtuals involved in geometry calculations - // The common version only sets a default width, so the derived classes - // should override it and set the height and change the width as needed. virtual wxSize DoGetBestSize() const; - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; // NULL popup can be used to indicate default in a derived class virtual void DoSetPopupControl(wxComboPopup* popup); @@ -560,10 +478,9 @@ protected: // just recalculate. void CalculateAreas( int btnWidth = 0 ); - // Standard textctrl positioning routine. Just give it platform-dependent + // Standard textctrl positioning routine. Just give it platform-dependant // textctrl coordinate adjustment. - virtual void PositionTextCtrl( int textCtrlXAdjust = 0, - int textCtrlYAdjust = 0); + void PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust ); // event handlers void OnSizeEvent( wxSizeEvent& event ); @@ -572,7 +489,6 @@ protected: void OnTextCtrlEvent(wxCommandEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event); void OnKeyEvent(wxKeyEvent& event); - void OnCharEvent(wxKeyEvent& event); // Set customization flags (directs how wxComboCtrlBase helpers behave) void Customize( wxUint32 flags ) { m_iFlags |= flags; } @@ -601,21 +517,12 @@ protected: virtual void DoSetToolTip( wxToolTip *tip ); #endif - // protected wxTextEntry methods - virtual void DoSetValue(const wxString& value, int flags); - virtual wxString DoGetValue() const; - virtual wxWindow *GetEditableWindow() { return this; } - - // margins functions - virtual bool DoSetMargins(const wxPoint& pt); - virtual wxPoint DoGetMargins() const; + virtual wxWindow *GetMainWindowOfCompositeControl() + { return m_mainCtrlWnd; } // This is used when m_text is hidden (readonly). wxString m_valueString; - // This is used when control is unfocused and m_valueString is empty - wxString m_hintText; - // the text control and button we show all the time wxTextCtrl* m_text; wxWindow* m_btn; @@ -636,7 +543,7 @@ protected: wxEvtHandler* m_toplevEvtHandler; // this is for the control in popup - wxEvtHandler* m_popupEvtHandler; + wxEvtHandler* m_popupExtraHandler; // this is for the popup window wxEvtHandler* m_popupWinEvtHandler; @@ -644,7 +551,7 @@ protected: // main (ie. topmost) window of a composite control (default = this) wxWindow* m_mainCtrlWnd; - // used to prevent immediate re-popupping in case closed popup + // used to prevent immediate re-popupping incase closed popup // by clicking on the combo control (needed because of inconsistent // transient implementation across platforms). wxLongLong m_timeCanAcceptClick; @@ -664,8 +571,8 @@ protected: // selection indicator. wxCoord m_widthCustomPaint; - // left margin, in pixels - wxCoord m_marginLeft; + // absolute text indentation, in pixels + wxCoord m_absIndent; // side on which the popup is aligned int m_anchorSide; @@ -677,9 +584,6 @@ protected: wxRect m_tcArea; wxRect m_btnArea; - // Colour of the text area, in case m_text is NULL - wxColour m_tcBgCol; - // current button state (uses renderer flags) int m_btnState; @@ -701,12 +605,9 @@ protected: // area used by the button wxSize m_btnSize; - // platform-dependent customization and other flags + // platform-dependant customization and other flags wxUint32 m_iFlags; - // custom style for m_text - int m_textCtrlStyle; - // draw blank button background under bitmap? bool m_blankButtonBg; @@ -715,10 +616,7 @@ protected: // should the focus be reset to the textctrl in idle time? bool m_resetFocus; - - // is the text-area background colour overridden? - bool m_hasTcBgCol; - + private: void Init(); @@ -745,16 +643,14 @@ enum wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called }; -class WXDLLIMPEXP_FWD_CORE wxComboCtrl; - -class WXDLLIMPEXP_CORE wxComboPopup +class WXDLLEXPORT wxComboPopup { friend class wxComboCtrlBase; public: wxComboPopup() { - m_combo = NULL; + m_combo = (wxComboCtrlBase*) NULL; m_iFlags = 0; } @@ -770,13 +666,6 @@ public: // Return true for success. virtual bool Create(wxWindow* parent) = 0; - // Calls Destroy() for the popup control (i.e. one returned by - // GetControl()) and makes sure that 'this' is deleted at the end. - // Default implementation works for both cases where popup control - // class is multiple inherited or created on heap as a separate - // object. - virtual void DestroyPopup(); - // We must have an associated control which is subclassed by the combobox. virtual wxWindow *GetControl() = 0; @@ -793,25 +682,14 @@ public: // Gets displayed string representation of the value. virtual wxString GetStringValue() const = 0; - // Called to check if the popup - when an item container - actually - // has matching item. Case-sensitivity checking etc. is up to the - // implementation. If the found item matched the string, but is - // different, it should be written back to pItem. Default implementation - // always return true and does not alter trueItem. - virtual bool FindItem(const wxString& item, wxString* trueItem=NULL); - // This is called to custom paint in the combo control itself (ie. not the popup). // Default implementation draws value as string. virtual void PaintComboControl( wxDC& dc, const wxRect& rect ); - // Receives wxEVT_KEY_DOWN key events from the parent wxComboCtrl. + // Receives key events from the parent wxComboCtrl. // Events not handled should be skipped, as usual. virtual void OnComboKeyEvent( wxKeyEvent& event ); - // Receives wxEVT_CHAR key events from the parent wxComboCtrl. - // Events not handled should be skipped, as usual. - virtual void OnComboCharEvent( wxKeyEvent& event ); - // Implement if you need to support special action when user // double-clicks on the parent wxComboCtrl. virtual void OnComboDoubleClick(); @@ -842,9 +720,6 @@ public: return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false; } - // Returns pointer to the associated parent wxComboCtrl. - wxComboCtrl* GetComboCtrl() const; - // Default PaintComboControl behaviour static void DefaultPaintComboControl( wxComboCtrlBase* combo, wxDC& dc, diff --git a/Source/3rd Party/wx/include/wx/combobox.h b/Source/3rd Party/wx/include/wx/combobox.h index fe51743fd..af84fb668 100644 --- a/Source/3rd Party/wx/include/wx/combobox.h +++ b/Source/3rd Party/wx/include/wx/combobox.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 24.12.00 +// RCS-ID: $Id: combobox.h 42727 2006-10-30 16:04:27Z VZ $ // Copyright: (c) 1996-2000 wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,54 +16,57 @@ #if wxUSE_COMBOBOX -// For compatibility with 2.8 include this header to allow using wxTE_XXX -// styles with wxComboBox without explicitly including it in the user code. -#include "wx/textctrl.h" - -extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[]; // ---------------------------------------------------------------------------- // wxComboBoxBase: this interface defines the methods wxComboBox must implement // ---------------------------------------------------------------------------- +#include "wx/textctrl.h" #include "wx/ctrlsub.h" -#include "wx/textentry.h" -class WXDLLIMPEXP_CORE wxComboBoxBase : public wxItemContainer, - public wxTextEntry +class WXDLLEXPORT wxComboBoxBase : public wxItemContainer { public: - // override these methods to disambiguate between two base classes versions - virtual void Clear() - { - wxTextEntry::Clear(); - wxItemContainer::Clear(); - } + // wxTextCtrl-like methods wxComboBox must implement + virtual wxString GetValue() const = 0; + virtual void SetValue(const wxString& value) = 0; - // IsEmpty() is ambiguous because we inherit it from both wxItemContainer - // and wxTextEntry, and even if defined it here to help the compiler with - // choosing one of them, it would still be confusing for the human users of - // this class. So instead define the clearly named methods below and leave - // IsEmpty() ambiguous to trigger a compilation error if it's used. - bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } - bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } + virtual void Copy() = 0; + virtual void Cut() = 0; + virtual void Paste() = 0; + virtual void SetInsertionPoint(long pos) = 0; + virtual long GetInsertionPoint() const = 0; + virtual wxTextPos GetLastPosition() const = 0; + virtual void Replace(long from, long to, const wxString& value) = 0; + virtual void SetSelection(long from, long to) = 0; + virtual void SetEditable(bool editable) = 0; - // also bring in GetSelection() versions of both base classes in scope - // - // NB: GetSelection(from, to) could be already implemented in wxTextEntry - // but still make it pure virtual because for some platforms it's not - // implemented there and also because the derived class has to override - // it anyhow to avoid ambiguity with the other GetSelection() - virtual int GetSelection() const = 0; - virtual void GetSelection(long *from, long *to) const = 0; + virtual void SetInsertionPointEnd() + { SetInsertionPoint(GetLastPosition()); } + virtual void Remove(long from, long to) + { Replace(from, to, wxEmptyString); } - virtual void Popup() { wxFAIL_MSG( wxT("Not implemented") ); } - virtual void Dismiss() { wxFAIL_MSG( wxT("Not implemented") ); } + virtual bool IsEditable() const = 0; + + virtual void Undo() = 0; + virtual void Redo() = 0; + virtual void SelectAll() = 0; + + virtual bool CanCopy() const = 0; + virtual bool CanCut() const = 0; + virtual bool CanPaste() const = 0; + virtual bool CanUndo() const = 0; + virtual bool CanRedo() const = 0; // may return value different from GetSelection() when the combobox // dropdown is shown and the user selected, but not yet accepted, a value // different from the old one in it virtual int GetCurrentSelection() const { return GetSelection(); } + + // redeclare inherited SetSelection() overload here as well to avoid + // virtual function hiding + virtual void SetSelection(int n) = 0; }; // ---------------------------------------------------------------------------- @@ -80,7 +84,7 @@ public: #elif defined(__WXGTK__) #include "wx/gtk1/combobox.h" #elif defined(__WXMAC__) - #include "wx/osx/combobox.h" + #include "wx/mac/combobox.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/combobox.h" #elif defined(__WXPM__) @@ -89,4 +93,5 @@ public: #endif // wxUSE_COMBOBOX -#endif // _WX_COMBOBOX_H_BASE_ +#endif + // _WX_COMBOBOX_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/commandlinkbutton.h b/Source/3rd Party/wx/include/wx/commandlinkbutton.h deleted file mode 100644 index 0aaa0ec65..000000000 --- a/Source/3rd Party/wx/include/wx/commandlinkbutton.h +++ /dev/null @@ -1,169 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/commandlinkbutton.h -// Purpose: wxCommandLinkButtonBase and wxGenericCommandLinkButton classes -// Author: Rickard Westerlund -// Created: 2010-06-11 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_COMMANDLINKBUTTON_H_ -#define _WX_COMMANDLINKBUTTON_H_ - -#include "wx/defs.h" - -#if wxUSE_COMMANDLINKBUTTON - -#include "wx/button.h" - -// ---------------------------------------------------------------------------- -// Command link button common base class -// ---------------------------------------------------------------------------- - -// This class has separate "main label" (title-like string) and (possibly -// multiline) "note" which can be set and queried separately but can also be -// set both at once by joining them with a new line and setting them as a -// label and queried by breaking the label into the parts before the first new -// line and after it. - -class WXDLLIMPEXP_ADV wxCommandLinkButtonBase : public wxButton -{ -public: - wxCommandLinkButtonBase() : wxButton() { } - - wxCommandLinkButtonBase(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = - wxDefaultValidator, - const wxString& name = wxButtonNameStr) - : wxButton(parent, - id, - mainLabel + '\n' + note, - pos, - size, - style, - validator, - name) - { } - - virtual void SetMainLabelAndNote(const wxString& mainLabel, - const wxString& note) = 0; - - virtual void SetMainLabel(const wxString& mainLabel) - { - SetMainLabelAndNote(mainLabel, GetNote()); - } - - virtual void SetNote(const wxString& note) - { - SetMainLabelAndNote(GetMainLabel(), note); - } - - virtual wxString GetMainLabel() const - { - return GetLabel().BeforeFirst('\n'); - } - - virtual wxString GetNote() const - { - return GetLabel().AfterFirst('\n'); - } - -protected: - virtual bool HasNativeBitmap() const { return false; } - -private: - wxDECLARE_NO_COPY_CLASS(wxCommandLinkButtonBase); -}; - -// ---------------------------------------------------------------------------- -// Generic command link button -// ---------------------------------------------------------------------------- - -// Trivial generic implementation simply using a multiline label to show both -// the main label and the note. - -class WXDLLIMPEXP_ADV wxGenericCommandLinkButton - : public wxCommandLinkButtonBase -{ -public: - wxGenericCommandLinkButton() : wxCommandLinkButtonBase() { } - - - wxGenericCommandLinkButton(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - : wxCommandLinkButtonBase() - { - Create(parent, id, mainLabel, note, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - - virtual void SetMainLabelAndNote(const wxString& mainLabel, - const wxString& note) - { - wxButton::SetLabel(mainLabel + '\n' + note); - } - -private: - void SetDefaultBitmap(); - - wxDECLARE_NO_COPY_CLASS(wxGenericCommandLinkButton); -}; - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/commandlinkbutton.h" -#else - class WXDLLIMPEXP_ADV wxCommandLinkButton : public wxGenericCommandLinkButton - { - public: - wxCommandLinkButton() : wxGenericCommandLinkButton() { } - - wxCommandLinkButton(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - : wxGenericCommandLinkButton(parent, - id, - mainLabel, - note, - pos, - size, - style, - validator, - name) - { } - - private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton); - }; -#endif // __WXMSW__/!__WXMSW__ - -#endif // wxUSE_COMMANDLINKBUTTON - -#endif // _WX_COMMANDLINKBUTTON_H_ diff --git a/Source/3rd Party/wx/include/wx/compiler.h b/Source/3rd Party/wx/include/wx/compiler.h deleted file mode 100644 index c6723a33b..000000000 --- a/Source/3rd Party/wx/include/wx/compiler.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Name: wx/compiler.h - * Purpose: Compiler-specific macro definitions. - * Author: Vadim Zeitlin - * Created: 2013-07-13 (extracted from wx/platform.h) - * Copyright: (c) 1997-2013 Vadim Zeitlin - * Licence: wxWindows licence - */ - -/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ - -#ifndef _WX_COMPILER_H_ -#define _WX_COMPILER_H_ - -/* - Compiler detection and related helpers. - */ - -/* - Notice that Intel compiler can be used as Microsoft Visual C++ add-on and - so we should define both __INTELC__ and __VISUALC__ for it. -*/ -#ifdef __INTEL_COMPILER -# define __INTELC__ -#endif - -#if defined(_MSC_VER) - /* - define another standard symbol for Microsoft Visual C++: the standard - one (_MSC_VER) is also defined by some other compilers. - */ -# define __VISUALC__ _MSC_VER - - /* - define special symbols for different VC version instead of writing tests - for magic numbers such as 1200, 1300 &c repeatedly - */ -#if __VISUALC__ < 1100 -# error "This Visual C++ version is too old and not supported any longer." -#elif __VISUALC__ < 1200 -# define __VISUALC5__ -#elif __VISUALC__ < 1300 -# define __VISUALC6__ -#elif __VISUALC__ < 1400 -# define __VISUALC7__ -#elif __VISUALC__ < 1500 -# define __VISUALC8__ -#elif __VISUALC__ < 1600 -# define __VISUALC9__ -#elif __VISUALC__ < 1700 -# define __VISUALC10__ -#elif __VISUALC__ < 1800 -# define __VISUALC11__ -#elif __VISUALC__ < 1900 -# define __VISUALC12__ -#elif __VISUAL__C < 2000 -# define __VISUALC14__ -#else -# pragma message("Please update wx/compiler.h to recognize this VC++ version") -#endif - -#elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) -# define __BORLANDC__ -#elif defined(__WATCOMC__) -#elif defined(__SC__) -# define __SYMANTECC__ -#elif defined(__SUNPRO_CC) -# ifndef __SUNCC__ -# define __SUNCC__ __SUNPRO_CC -# endif /* Sun CC */ -#elif defined(__SC__) -# ifdef __DMC__ -# define __DIGITALMARS__ -# else -# define __SYMANTEC__ -# endif -#endif /* compiler */ - -/* - Macros for checking compiler version. -*/ - -/* - This macro can be used to test the gcc version and can be used like this: - -# if wxCHECK_GCC_VERSION(3, 1) - ... we have gcc 3.1 or later ... -# else - ... no gcc at all or gcc < 3.1 ... -# endif -*/ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) - #define wxCHECK_GCC_VERSION( major, minor ) \ - ( ( __GNUC__ > (major) ) \ - || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) -#else - #define wxCHECK_GCC_VERSION( major, minor ) 0 -#endif - -/* - This macro can be used to test the Visual C++ version. -*/ -#ifndef __VISUALC__ -# define wxVISUALC_VERSION(major) 0 -# define wxCHECK_VISUALC_VERSION(major) 0 -#else -# define wxVISUALC_VERSION(major) ( (6 + major) * 100 ) -# define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) ) -#endif - -/** - This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler. - */ -#ifdef __SUNCC__ - /* - __SUNCC__ is 0xVRP where V is major version, R release and P patch level - */ - #define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4))) -#else - #define wxCHECK_SUNCC_VERSION(maj, min) (0) -#endif - -#ifndef __WATCOMC__ -# define wxWATCOM_VERSION(major,minor) 0 -# define wxCHECK_WATCOM_VERSION(major,minor) 0 -# define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0 -# define WX_WATCOM_ONLY_CODE( x ) -#else -# if __WATCOMC__ < 1200 -# error "Only Open Watcom is supported in this release" -# endif - -# define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 ) -# define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) ) -# define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) ) -# define WX_WATCOM_ONLY_CODE( x ) x -#endif - -/* - wxCHECK_MINGW32_VERSION() is defined in wx/msw/gccpriv.h which is included - later, see comments there. - */ - -#endif // _WX_COMPILER_H_ diff --git a/Source/3rd Party/wx/include/wx/compositewin.h b/Source/3rd Party/wx/include/wx/compositewin.h deleted file mode 100644 index a46c25770..000000000 --- a/Source/3rd Party/wx/include/wx/compositewin.h +++ /dev/null @@ -1,229 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/compositewin.h -// Purpose: wxCompositeWindow<> declaration -// Author: Vadim Zeitlin -// Created: 2011-01-02 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_COMPOSITEWIN_H_ -#define _WX_COMPOSITEWIN_H_ - -#include "wx/window.h" -#include "wx/containr.h" - -class WXDLLIMPEXP_FWD_CORE wxToolTip; - -// NB: This is an experimental and, as for now, undocumented class used only by -// wxWidgets itself internally. Don't use it in your code until its API is -// officially stabilized unless you are ready to change it with the next -// wxWidgets release. - -// ---------------------------------------------------------------------------- -// wxCompositeWindow is a helper for implementing composite windows: to define -// a class using subwindows, simply inherit from it specialized with the real -// base class name and implement GetCompositeWindowParts() pure virtual method. -// ---------------------------------------------------------------------------- - -// The template parameter W must be a wxWindow-derived class. -template -class wxCompositeWindow : public W -{ -public: - typedef W BaseWindowClass; - - // Default ctor doesn't do anything. - wxCompositeWindow() - { - this->Connect - ( - wxEVT_CREATE, - wxWindowCreateEventHandler(wxCompositeWindow::OnWindowCreate) - ); - - } - -#ifndef __VISUALC6__ - // FIXME-VC6: This compiler can't compile DoSetForAllParts() template function, - // it can't determine whether the deduced type should be "T" or "const T&". And - // without this function wxCompositeWindow is pretty useless so simply disable - // this code for it, this does mean that setting colours/fonts/... for - // composite controls won't work in the library compiled with it but so far - // this only affects the generic wxDatePickerCtrl which is not used by default - // under MSW anyhow so it doesn't seem to be worth it to spend time and uglify - // the code to fix it. - - // Override all wxWindow methods which must be forwarded to the composite - // window parts. - - // Attribute setters group. - // - // NB: Unfortunately we can't factor out the call for the setter itself - // into DoSetForAllParts() because we can't call the function passed to - // it non-virtually and we need to do this to avoid infinite recursion, - // so we work around this by calling the method of this object itself - // manually in each function. - virtual bool SetForegroundColour(const wxColour& colour) - { - if ( !BaseWindowClass::SetForegroundColour(colour) ) - return false; - - SetForAllParts(&wxWindowBase::SetForegroundColour, colour); - - return true; - } - - virtual bool SetBackgroundColour(const wxColour& colour) - { - if ( !BaseWindowClass::SetBackgroundColour(colour) ) - return false; - - SetForAllParts(&wxWindowBase::SetBackgroundColour, colour); - - return true; - } - - virtual bool SetFont(const wxFont& font) - { - if ( !BaseWindowClass::SetFont(font) ) - return false; - - SetForAllParts(&wxWindowBase::SetFont, font); - - return true; - } - - virtual bool SetCursor(const wxCursor& cursor) - { - if ( !BaseWindowClass::SetCursor(cursor) ) - return false; - - SetForAllParts(&wxWindowBase::SetCursor, cursor); - - return true; - } - -#if wxUSE_TOOLTIPS - virtual void DoSetToolTip(wxToolTip *tip) - { - BaseWindowClass::DoSetToolTip(tip); - - SetForAllParts(&wxWindowBase::CopyToolTip, tip); - } -#endif // wxUSE_TOOLTIPS - -#endif // !__VISUALC6__ - - virtual void SetFocus() - { - wxSetFocusToChild(this, NULL); - } - -private: - // Must be implemented by the derived class to return all children to which - // the public methods we override should forward to. - virtual wxWindowList GetCompositeWindowParts() const = 0; - - void OnWindowCreate(wxWindowCreateEvent& event) - { - event.Skip(); - - // Attach a few event handlers to all parts of the composite window. - // This makes the composite window behave more like a simple control - // and allows other code (such as wxDataViewCtrl's inline editing - // support) to hook into its event processing. - - wxWindow *child = event.GetWindow(); - if ( child == this ) - return; // not a child, we don't want to Connect() to ourselves - - // Always capture wxEVT_KILL_FOCUS: - child->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(wxCompositeWindow::OnKillFocus), - NULL, this); - - // Some events should be only handled for non-toplevel children. For - // example, we want to close the control in wxDataViewCtrl when Enter - // is pressed in the inline editor, but not when it's pressed in a - // popup dialog it opens. - wxWindow *win = child; - while ( win && win != this ) - { - if ( win->IsTopLevel() ) - return; - win = win->GetParent(); - } - - child->Connect(wxEVT_CHAR, - wxKeyEventHandler(wxCompositeWindow::OnChar), - NULL, this); - } - - void OnChar(wxKeyEvent& event) - { - if ( !this->ProcessWindowEvent(event) ) - event.Skip(); - } - - void OnKillFocus(wxFocusEvent& event) - { - // Ignore focus changes within the composite control: - wxWindow *win = event.GetWindow(); - while ( win ) - { - if ( win == this ) - { - event.Skip(); - return; - } - - // Note that we don't use IsTopLevel() check here, because we do - // want to ignore focus changes going to toplevel window that have - // the composite control as its parent; these would typically be - // some kind of control's popup window. - win = win->GetParent(); - } - - // The event shouldn't be ignored, forward it to the main control: - if ( !this->ProcessWindowEvent(event) ) - event.Skip(); - } - -#ifndef __VISUALC6__ - template - void SetForAllParts(bool (wxWindowBase::*func)(const T&), const T& arg) - { - DoSetForAllParts(func, arg); - } - - template - void SetForAllParts(bool (wxWindowBase::*func)(T*), T* arg) - { - DoSetForAllParts(func, arg); - } - - template - void DoSetForAllParts(bool (wxWindowBase::*func)(T), T arg) - { - // Simply call the setters for all parts of this composite window. - const wxWindowList parts = GetCompositeWindowParts(); - for ( wxWindowList::const_iterator i = parts.begin(); - i != parts.end(); - ++i ) - { - wxWindow * const child = *i; - - // Allow NULL elements in the list, this makes the code of derived - // composite controls which may have optionally shown children - // simpler and it doesn't cost us much here. - if ( child ) - (child->*func)(arg); - } - } -#endif // !__VISUALC6__ - - wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCompositeWindow, W); -}; - -#endif // _WX_COMPOSITEWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/confbase.h b/Source/3rd Party/wx/include/wx/confbase.h index c7153b1c8..2e0197dce 100644 --- a/Source/3rd Party/wx/include/wx/confbase.h +++ b/Source/3rd Party/wx/include/wx/confbase.h @@ -1,22 +1,21 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/confbase.h +// Name: confbase.h // Purpose: declaration of the base class of all config implementations // (see also: fileconf.h and msw/regconf.h and iniconf.h) // Author: Karsten Ballueder & Vadim Zeitlin // Modified by: // Created: 07.04.98 (adapted from appconf.h) +// RCS-ID: $Id: confbase.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net // Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _WX_CONFBASE_H_ -#define _WX_CONFBASE_H_ +#ifndef _WX_CONFBASE_H_ +#define _WX_CONFBASE_H_ #include "wx/defs.h" #include "wx/string.h" -#include "wx/object.h" -#include "wx/base64.h" class WXDLLIMPEXP_FWD_BASE wxArrayString; @@ -42,6 +41,8 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; #if wxUSE_CONFIG +#include "wx/string.h" + /// should we use registry instead of configuration files under Windows? // (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's // false) or wxRegConfig (if it's true and we're under Win32)) @@ -49,15 +50,6 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; #define wxUSE_CONFIG_NATIVE 1 #endif -// not all compilers can deal with template Read/Write() methods, define this -// symbol if the template functions are available -#if (!defined(__VISUALC__) || __VISUALC__ > 1200) && \ - !defined( __VMS ) && \ - !(defined(__HP_aCC) && defined(__hppa)) && \ - !defined (__DMC__) - #define wxHAS_CONFIG_TEMPLATE_RW -#endif - // Style flags for constructor style parameter enum { @@ -72,7 +64,7 @@ enum // abstract base class wxConfigBase which defines the interface for derived // classes // -// wxConfig organizes the items in a tree-like structure (modelled after the +// wxConfig organizes the items in a tree-like structure (modeled after the // Unix/Dos filesystem). There are groups (directories) and keys (files). // There is always one current group given by the current path. // @@ -80,7 +72,7 @@ enum // (long) type (TODO doubles and other types such as wxDate coming soon). // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxConfigBase : public wxObject +class WXDLLIMPEXP_BASE wxConfigBase { public: // constants @@ -172,7 +164,7 @@ public: bool Read(const wxString& key, long *pl) const; bool Read(const wxString& key, long *pl, long defVal) const; - // read an int (wrapper around `long' version) + // read an int bool Read(const wxString& key, int *pi) const; bool Read(const wxString& key, int *pi, int defVal) const; @@ -180,138 +172,39 @@ public: bool Read(const wxString& key, double* val) const; bool Read(const wxString& key, double* val, double defVal) const; - // read a float - bool Read(const wxString& key, float* val) const; - bool Read(const wxString& key, float* val, float defVal) const; - // read a bool bool Read(const wxString& key, bool* val) const; bool Read(const wxString& key, bool* val, bool defVal) const; -#if wxUSE_BASE64 - // read a binary data block - bool Read(const wxString& key, wxMemoryBuffer* data) const - { return DoReadBinary(key, data); } - // no default version since it does not make sense for binary data -#endif // wxUSE_BASE64 - -#ifdef wxHAS_CONFIG_TEMPLATE_RW - // read other types, for which wxFromString is defined - template - bool Read(const wxString& key, T* value) const - { - wxString s; - if ( !Read(key, &s) ) - return false; - return wxFromString(s, value); - } - - template - bool Read(const wxString& key, T* value, const T& defVal) const - { - const bool found = Read(key, value); - if ( !found ) - { - if (IsRecordingDefaults()) - ((wxConfigBase *)this)->Write(key, defVal); - *value = defVal; - } - return found; - } -#endif // wxHAS_CONFIG_TEMPLATE_RW - - // convenience functions returning directly the value + // convenience functions returning directly the value (we don't have them for + // int/double/bool as there would be ambiguities with the long one then) wxString Read(const wxString& key, const wxString& defVal = wxEmptyString) const { wxString s; (void)Read(key, &s, defVal); return s; } - // we have to provide a separate version for C strings as otherwise the - // template Read() would be used - wxString Read(const wxString& key, const char* defVal) const - { return Read(key, wxString(defVal)); } - wxString Read(const wxString& key, const wchar_t* defVal) const - { return Read(key, wxString(defVal)); } - - long ReadLong(const wxString& key, long defVal) const + long Read(const wxString& key, long defVal) const { long l; (void)Read(key, &l, defVal); return l; } - double ReadDouble(const wxString& key, double defVal) const - { double d; (void)Read(key, &d, defVal); return d; } - - bool ReadBool(const wxString& key, bool defVal) const - { bool b; (void)Read(key, &b, defVal); return b; } - - template - T ReadObject(const wxString& key, T const& defVal) const - { T t; (void)Read(key, &t, defVal); return t; } - - // for compatibility with wx 2.8 - long Read(const wxString& key, long defVal) const - { return ReadLong(key, defVal); } - - - // write the value (return true on success) + // write the value (return true on success) bool Write(const wxString& key, const wxString& value) { return DoWriteString(key, value); } bool Write(const wxString& key, long value) { return DoWriteLong(key, value); } + bool Write(const wxString& key, int value) + { return DoWriteInt(key, value); } + bool Write(const wxString& key, double value) { return DoWriteDouble(key, value); } bool Write(const wxString& key, bool value) { return DoWriteBool(key, value); } -#if wxUSE_BASE64 - bool Write(const wxString& key, const wxMemoryBuffer& buf) - { return DoWriteBinary(key, buf); } -#endif // wxUSE_BASE64 - // we have to provide a separate version for C strings as otherwise they // would be converted to bool and not to wxString as expected! - bool Write(const wxString& key, const char *value) + bool Write(const wxString& key, const wxChar *value) { return Write(key, wxString(value)); } - bool Write(const wxString& key, const unsigned char *value) - { return Write(key, wxString(value)); } - bool Write(const wxString& key, const wchar_t *value) - { return Write(key, wxString(value)); } - - - // we also have to provide specializations for other types which we want to - // handle using the specialized DoWriteXXX() instead of the generic template - // version below - bool Write(const wxString& key, char value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, unsigned char value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, short value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, unsigned short value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, unsigned int value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, int value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, unsigned long value) - { return DoWriteLong(key, value); } - - bool Write(const wxString& key, float value) - { return DoWriteDouble(key, value); } - - // Causes ambiguities in VC++ 6 and OpenVMS (at least) -#if ( (!defined(__VISUALC__) || __VISUALC__ > 1200) && !defined( __VMS ) && !defined (__DMC__)) - // for other types, use wxToString() - template - bool Write(const wxString& key, T const& value) - { return Write(key, wxToString(value)); } -#endif // permanently writes all changes virtual bool Flush(bool bCurrentOnly = false) = 0; @@ -372,19 +265,15 @@ protected: // do read/write the values of different types virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0; virtual bool DoReadLong(const wxString& key, long *pl) const = 0; + virtual bool DoReadInt(const wxString& key, int *pi) const; virtual bool DoReadDouble(const wxString& key, double* val) const; virtual bool DoReadBool(const wxString& key, bool* val) const; -#if wxUSE_BASE64 - virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const = 0; -#endif // wxUSE_BASE64 virtual bool DoWriteString(const wxString& key, const wxString& value) = 0; virtual bool DoWriteLong(const wxString& key, long value) = 0; + virtual bool DoWriteInt(const wxString& key, int value); virtual bool DoWriteDouble(const wxString& key, double value); virtual bool DoWriteBool(const wxString& key, bool value); -#if wxUSE_BASE64 - virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) = 0; -#endif // wxUSE_BASE64 private: // are we doing automatic environment variable expansion? @@ -402,8 +291,6 @@ private: // Style flag long m_style; - - DECLARE_ABSTRACT_CLASS(wxConfigBase) }; // a handy little class which changes current path to the path of given entry @@ -435,10 +322,22 @@ private: m_strOldPath; // saved path bool m_bChanged; // was the path changed? - wxDECLARE_NO_COPY_CLASS(wxConfigPathChanger); + DECLARE_NO_COPY_CLASS(wxConfigPathChanger) }; +// ---------------------------------------------------------------------------- +// the native wxConfigBase implementation +// ---------------------------------------------------------------------------- + +// under Windows we prefer to use the native implementation +// wxIniConfig isn't native anywhere after droping win16 in wxWidgets 2.6 +#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE + #define wxConfig wxRegConfig +#else // either we're under Unix or wish to use files even under Windows + #define wxConfig wxFileConfig +#endif + #endif // wxUSE_CONFIG /* @@ -452,7 +351,9 @@ WXDLLIMPEXP_BASE wxString wxExpandEnvVars(const wxString &sz); /* Split path into parts removing '..' in progress */ -WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxString& path); +WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxChar *sz); -#endif // _WX_CONFBASE_H_ + +#endif + // _WX_CONFIG_H_ diff --git a/Source/3rd Party/wx/include/wx/config.h b/Source/3rd Party/wx/include/wx/config.h index 59d6f5ba6..92d036f93 100644 --- a/Source/3rd Party/wx/include/wx/config.h +++ b/Source/3rd Party/wx/include/wx/config.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/config.h +// Name: config.h // Purpose: wxConfig base header // Author: Julian Smart // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: config.h 60524 2009-05-05 22:51:44Z PC $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,21 +16,16 @@ #if wxUSE_CONFIG -// ---------------------------------------------------------------------------- -// define the native wxConfigBase implementation -// ---------------------------------------------------------------------------- - -// under Windows we prefer to use the native implementation but can be forced -// to use the file-based one -#if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE - #include "wx/msw/regconf.h" - #define wxConfig wxRegConfig -#elif defined(__WXOS2__) && wxUSE_CONFIG_NATIVE - #include "wx/os2/iniconf.h" - #define wxConfig wxIniConfig -#else // either we're under Unix or wish to always use config files - #include "wx/fileconf.h" - #define wxConfig wxFileConfig +#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE +# ifdef __WIN32__ +# include "wx/msw/regconf.h" +# else +# include "wx/msw/iniconf.h" +# endif +#elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE +# include "wx/palmos/prefconf.h" +#else +# include "wx/fileconf.h" #endif #endif // wxUSE_CONFIG diff --git a/Source/3rd Party/wx/include/wx/containr.h b/Source/3rd Party/wx/include/wx/containr.h index a1f53ed5d..0cf322c2e 100644 --- a/Source/3rd Party/wx/include/wx/containr.h +++ b/Source/3rd Party/wx/include/wx/containr.h @@ -1,105 +1,62 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/containr.h -// Purpose: wxControlContainer and wxNavigationEnabled declarations +// Purpose: wxControlContainer class declration: a "mix-in" class which +// implements the TAB navigation between the controls // Author: Vadim Zeitlin // Modified by: // Created: 06.08.01 -// Copyright: (c) 2001, 2011 Vadim Zeitlin +// RCS-ID: $Id: containr.h 50863 2007-12-20 18:32:55Z VS $ +// Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_CONTAINR_H_ #define _WX_CONTAINR_H_ -#include "wx/defs.h" - -#ifndef wxHAS_NATIVE_TAB_TRAVERSAL - // We need wxEVT_XXX declarations in this case. - #include "wx/event.h" -#endif - +class WXDLLIMPEXP_FWD_CORE wxFocusEvent; +class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; class WXDLLIMPEXP_FWD_CORE wxWindow; class WXDLLIMPEXP_FWD_CORE wxWindowBase; /* - This header declares wxControlContainer class however it's not a real - container of controls but rather just a helper used to implement TAB - navigation among the window children. You should rarely need to use it - directly, derive from the documented public wxNavigationEnabled<> class to - implement TAB navigation in a custom composite window. + Implementation note: wxControlContainer is not a real mix-in but rather + a class meant to be agregated with (and not inherited from). Although + logically it should be a mix-in, doing it like this has no advantage from + the point of view of the existing code but does have some problems (we'd + need to play tricks with event handlers which may be difficult to do + safely). The price we pay for this simplicity is the ugly macros below. */ // ---------------------------------------------------------------------------- -// wxControlContainerBase: common part used in both native and generic cases +// wxControlContainer // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxControlContainerBase +class WXDLLEXPORT wxControlContainer { public: - // default ctor, SetContainerWindow() must be called later - wxControlContainerBase() - { - m_winParent = NULL; + // ctors and such + wxControlContainer(wxWindow *winParent = NULL); + void SetContainerWindow(wxWindow *winParent) { m_winParent = winParent; } - // By default, we accept focus ourselves. - m_acceptsFocusSelf = true; - - // But we don't have any children accepting it yet. - m_acceptsFocusChildren = false; - - m_inSetFocus = false; - m_winLastFocused = NULL; - } - virtual ~wxControlContainerBase() {} - - void SetContainerWindow(wxWindow *winParent) - { - wxASSERT_MSG( !m_winParent, wxT("shouldn't be called twice") ); - - m_winParent = winParent; - } - - // This can be called by the window to indicate that it never wants to have - // the focus for itself. - void DisableSelfFocus() - { m_acceptsFocusSelf = false; UpdateParentCanFocus(); } - - // This can be called to undo the effect of a previous DisableSelfFocus() - // (otherwise calling it is not necessary as the window does accept focus - // by default). - void EnableSelfFocus() - { m_acceptsFocusSelf = true; UpdateParentCanFocus(); } + // the methods to be called from the window event handlers + void HandleOnNavigationKey(wxNavigationKeyEvent& event); + void HandleOnFocus(wxFocusEvent& event); + void HandleOnWindowDestroy(wxWindowBase *child); // should be called from SetFocus(), returns false if we did nothing with // the focus and the default processing should take place bool DoSetFocus(); - // returns whether we should accept focus ourselves or not + // can our child get the focus? bool AcceptsFocus() const; - // Returns whether we or one of our children accepts focus. - bool AcceptsFocusRecursively() const - { return AcceptsFocus() || - (m_acceptsFocusChildren && HasAnyChildrenAcceptingFocus()); } - - // We accept focus from keyboard if we accept it at all. - bool AcceptsFocusFromKeyboard() const { return AcceptsFocusRecursively(); } - - // Call this when the number of children of the window changes. - // - // Returns true if we have any focusable children, false otherwise. - bool UpdateCanFocusChildren(); + // called from OnChildFocus() handler, i.e. when one of our (grand) + // children gets the focus + void SetLastFocus(wxWindow *win); protected: // set the focus to the child which had it the last time - virtual bool SetFocusToChild(); - - // return true if we have any children accepting focus - bool HasAnyFocusableChildren() const; - - // return true if we have any children that do accept focus right now - bool HasAnyChildrenAcceptingFocus() const; - + bool SetFocusToChild(); // the parent window we manage the children for wxWindow *m_winParent; @@ -107,265 +64,33 @@ protected: // the child which had the focus last time this panel was activated wxWindow *m_winLastFocused; -private: - // Update the window status to reflect whether it is getting focus or not. - void UpdateParentCanFocus(); - - // Indicates whether the associated window can ever have focus itself. - // - // Usually this is the case, e.g. a wxPanel can be used either as a - // container for its children or just as a normal window which can be - // focused. But sometimes, e.g. for wxStaticBox, we can never have focus - // ourselves and can only get it if we have any focusable children. - bool m_acceptsFocusSelf; - - // Cached value remembering whether we have any children accepting focus. - bool m_acceptsFocusChildren; - // a guard against infinite recursion bool m_inSetFocus; + + DECLARE_NO_COPY_CLASS(wxControlContainer) }; -#ifdef wxHAS_NATIVE_TAB_TRAVERSAL - -// ---------------------------------------------------------------------------- -// wxControlContainer for native TAB navigation -// ---------------------------------------------------------------------------- - -// this must be a real class as we forward-declare it elsewhere -class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase -{ -protected: - // set the focus to the child which had it the last time - virtual bool SetFocusToChild(); -}; - -#else // !wxHAS_NATIVE_TAB_TRAVERSAL - -// ---------------------------------------------------------------------------- -// wxControlContainer for TAB navigation implemented in wx itself -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase -{ -public: - // default ctor, SetContainerWindow() must be called later - wxControlContainer(); - - // the methods to be called from the window event handlers - void HandleOnNavigationKey(wxNavigationKeyEvent& event); - void HandleOnFocus(wxFocusEvent& event); - void HandleOnWindowDestroy(wxWindowBase *child); - - // called from OnChildFocus() handler, i.e. when one of our (grand) - // children gets the focus - void SetLastFocus(wxWindow *win); - -protected: - - wxDECLARE_NO_COPY_CLASS(wxControlContainer); -}; - -#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL - // this function is for wxWidgets internal use only -extern WXDLLIMPEXP_CORE bool wxSetFocusToChild(wxWindow *win, wxWindow **child); +extern bool wxSetFocusToChild(wxWindow *win, wxWindow **child); // ---------------------------------------------------------------------------- -// wxNavigationEnabled: Derive from this class to support keyboard navigation -// among window children in a wxWindow-derived class. The details of this class -// don't matter, you just need to derive from it to make navigation work. +// macros which may be used by the classes wishing to implement TAB navigation +// among their children // ---------------------------------------------------------------------------- -// The template parameter W must be a wxWindow-derived class. -template -class wxNavigationEnabled : public W -{ -public: - typedef W BaseWindowClass; - - wxNavigationEnabled() - { - m_container.SetContainerWindow(this); - -#ifndef wxHAS_NATIVE_TAB_TRAVERSAL - BaseWindowClass::Connect(wxEVT_NAVIGATION_KEY, - wxNavigationKeyEventHandler(wxNavigationEnabled::OnNavigationKey)); - - BaseWindowClass::Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(wxNavigationEnabled::OnFocus)); - - BaseWindowClass::Connect(wxEVT_CHILD_FOCUS, - wxChildFocusEventHandler(wxNavigationEnabled::OnChildFocus)); -#endif // !wxHAS_NATIVE_TAB_TRAVERSAL - } - - WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocus() const - { - return m_container.AcceptsFocus(); - } - - WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocusRecursively() const - { - return m_container.AcceptsFocusRecursively(); - } - - WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocusFromKeyboard() const - { - return m_container.AcceptsFocusFromKeyboard(); - } - - WXDLLIMPEXP_INLINE_CORE virtual void AddChild(wxWindowBase *child) - { - BaseWindowClass::AddChild(child); - - if ( m_container.UpdateCanFocusChildren() ) - { - // Under MSW we must have wxTAB_TRAVERSAL style for TAB navigation - // to work. - if ( !BaseWindowClass::HasFlag(wxTAB_TRAVERSAL) ) - BaseWindowClass::ToggleWindowStyle(wxTAB_TRAVERSAL); - } - } - - WXDLLIMPEXP_INLINE_CORE virtual void RemoveChild(wxWindowBase *child) - { -#ifndef wxHAS_NATIVE_TAB_TRAVERSAL - m_container.HandleOnWindowDestroy(child); -#endif // !wxHAS_NATIVE_TAB_TRAVERSAL - - BaseWindowClass::RemoveChild(child); - - // We could reset wxTAB_TRAVERSAL here but it doesn't seem to do any - // harm to keep it. - m_container.UpdateCanFocusChildren(); - } - - WXDLLIMPEXP_INLINE_CORE virtual void SetFocus() - { - if ( !m_container.DoSetFocus() ) - BaseWindowClass::SetFocus(); - } - - void SetFocusIgnoringChildren() - { - BaseWindowClass::SetFocus(); - } - -protected: -#ifndef wxHAS_NATIVE_TAB_TRAVERSAL - void OnNavigationKey(wxNavigationKeyEvent& event) - { - m_container.HandleOnNavigationKey(event); - } - - void OnFocus(wxFocusEvent& event) - { - m_container.HandleOnFocus(event); - } - - void OnChildFocus(wxChildFocusEvent& event) - { - m_container.SetLastFocus(event.GetWindow()); - event.Skip(); - } -#endif // !wxHAS_NATIVE_TAB_TRAVERSAL - - wxControlContainer m_container; - - - wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxNavigationEnabled, W); -}; - -// ---------------------------------------------------------------------------- -// Compatibility macros from now on, do NOT use them and preferably do not even -// look at them. -// ---------------------------------------------------------------------------- - -#if WXWIN_COMPATIBILITY_2_8 - -// common part of WX_DECLARE_CONTROL_CONTAINER in the native and generic cases, -// it should be used in the wxWindow-derived class declaration -#define WX_DECLARE_CONTROL_CONTAINER_BASE() \ -public: \ - virtual bool AcceptsFocus() const; \ - virtual bool AcceptsFocusRecursively() const; \ - virtual bool AcceptsFocusFromKeyboard() const; \ - virtual void AddChild(wxWindowBase *child); \ - virtual void RemoveChild(wxWindowBase *child); \ - virtual void SetFocus(); \ - void SetFocusIgnoringChildren(); \ - \ -protected: \ - wxControlContainer m_container - -// this macro must be used in the derived class ctor -#define WX_INIT_CONTROL_CONTAINER() \ - m_container.SetContainerWindow(this) - -// common part of WX_DELEGATE_TO_CONTROL_CONTAINER in the native and generic -// cases, must be used in the wxWindow-derived class implementation -#define WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \ - void classname::AddChild(wxWindowBase *child) \ - { \ - basename::AddChild(child); \ - \ - m_container.UpdateCanFocusChildren(); \ - } \ - \ - bool classname::AcceptsFocusRecursively() const \ - { \ - return m_container.AcceptsFocusRecursively(); \ - } \ - \ - void classname::SetFocus() \ - { \ - if ( !m_container.DoSetFocus() ) \ - basename::SetFocus(); \ - } \ - \ - bool classname::AcceptsFocus() const \ - { \ - return m_container.AcceptsFocus(); \ - } \ - \ - bool classname::AcceptsFocusFromKeyboard() const \ - { \ - return m_container.AcceptsFocusFromKeyboard(); \ - } - - -#ifdef wxHAS_NATIVE_TAB_TRAVERSAL - -#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) - -#define WX_DECLARE_CONTROL_CONTAINER WX_DECLARE_CONTROL_CONTAINER_BASE - -#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \ - WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \ - \ - void classname::RemoveChild(wxWindowBase *child) \ - { \ - basename::RemoveChild(child); \ - \ - m_container.UpdateCanFocusChildren(); \ - } \ - \ - void classname::SetFocusIgnoringChildren() \ - { \ - basename::SetFocus(); \ - } - -#else // !wxHAS_NATIVE_TAB_TRAVERSAL - // declare the methods to be forwarded -#define WX_DECLARE_CONTROL_CONTAINER() \ - WX_DECLARE_CONTROL_CONTAINER_BASE(); \ - \ -public: \ - void OnNavigationKey(wxNavigationKeyEvent& event); \ - void OnFocus(wxFocusEvent& event); \ - virtual void OnChildFocus(wxChildFocusEvent& event) +#define WX_DECLARE_CONTROL_CONTAINER() \ +public: \ + void OnNavigationKey(wxNavigationKeyEvent& event); \ + void OnFocus(wxFocusEvent& event); \ + virtual void OnChildFocus(wxChildFocusEvent& event); \ + virtual void SetFocus(); \ + virtual void SetFocusIgnoringChildren(); \ + virtual void RemoveChild(wxWindowBase *child); \ + virtual bool AcceptsFocus() const; \ +\ +protected: \ + wxControlContainer m_container // implement the event table entries for wxControlContainer #define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \ @@ -374,41 +99,44 @@ public: \ EVT_NAVIGATION_KEY(classname::OnNavigationKey) // implement the methods forwarding to the wxControlContainer -#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \ - WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \ - \ - void classname::RemoveChild(wxWindowBase *child) \ - { \ - m_container.HandleOnWindowDestroy(child); \ - \ - basename::RemoveChild(child); \ - \ - m_container.UpdateCanFocusChildren(); \ - } \ - \ - void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \ - { \ - m_container.HandleOnNavigationKey(event); \ - } \ - \ - void classname::SetFocusIgnoringChildren() \ - { \ - basename::SetFocus(); \ - } \ - \ - void classname::OnChildFocus(wxChildFocusEvent& event) \ - { \ - m_container.SetLastFocus(event.GetWindow()); \ - event.Skip(); \ - } \ - \ - void classname::OnFocus(wxFocusEvent& event) \ - { \ - m_container.HandleOnFocus(event); \ - } +#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \ +void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \ +{ \ + m_container.HandleOnNavigationKey(event); \ +} \ + \ +void classname::RemoveChild(wxWindowBase *child) \ +{ \ + m_container.HandleOnWindowDestroy(child); \ + \ + basename::RemoveChild(child); \ +} \ + \ +void classname::SetFocus() \ +{ \ + if ( !m_container.DoSetFocus() ) \ + basename::SetFocus(); \ +} \ + \ +void classname::SetFocusIgnoringChildren() \ +{ \ + basename::SetFocus(); \ +} \ + \ +void classname::OnChildFocus(wxChildFocusEvent& event) \ +{ \ + m_container.SetLastFocus(event.GetWindow()); \ + event.Skip(); \ +} \ + \ +void classname::OnFocus(wxFocusEvent& event) \ +{ \ + m_container.HandleOnFocus(event); \ +} \ +bool classname::AcceptsFocus() const \ +{ \ + return m_container.AcceptsFocus(); \ +} -#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL - -#endif // WXWIN_COMPATIBILITY_2_8 #endif // _WX_CONTAINR_H_ diff --git a/Source/3rd Party/wx/include/wx/control.h b/Source/3rd Party/wx/include/wx/control.h index 6fdc05c84..ff11a93cf 100644 --- a/Source/3rd Party/wx/include/wx/control.h +++ b/Source/3rd Party/wx/include/wx/control.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.07.99 +// RCS-ID: $Id: control.h 42816 2006-10-31 08:50:17Z RD $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,38 +22,13 @@ #include "wx/window.h" // base class -extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[]; - - -// ---------------------------------------------------------------------------- -// Ellipsize() constants -// ---------------------------------------------------------------------------- - -enum wxEllipsizeFlags -{ - wxELLIPSIZE_FLAGS_NONE = 0, - wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS = 1, - wxELLIPSIZE_FLAGS_EXPAND_TABS = 2, - - wxELLIPSIZE_FLAGS_DEFAULT = wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS | - wxELLIPSIZE_FLAGS_EXPAND_TABS -}; - -// NB: Don't change the order of these values, they're the same as in -// PangoEllipsizeMode enum. -enum wxEllipsizeMode -{ - wxELLIPSIZE_NONE, - wxELLIPSIZE_START, - wxELLIPSIZE_MIDDLE, - wxELLIPSIZE_END -}; +extern WXDLLEXPORT_DATA(const wxChar) wxControlNameStr[]; // ---------------------------------------------------------------------------- // wxControl is the base class for all controls // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxControlBase : public wxWindow +class WXDLLEXPORT wxControlBase : public wxWindow { public: wxControlBase() { } @@ -70,51 +46,11 @@ public: // get the control alignment (left/right/centre, top/bottom/centre) int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; } - // set label with mnemonics - virtual void SetLabel(const wxString& label) - { - m_labelOrig = label; - - InvalidateBestSize(); - - wxWindow::SetLabel(label); - } - - // return the original string, as it was passed to SetLabel() - // (i.e. with wx-style mnemonics) - virtual wxString GetLabel() const { return m_labelOrig; } - - // set label text (mnemonics will be escaped) - virtual void SetLabelText(const wxString& text) - { - SetLabel(EscapeMnemonics(text)); - } + // get the string without mnemonic characters ('&') + static wxString GetLabelText(const wxString& label); // get just the text of the label, without mnemonic characters ('&') - virtual wxString GetLabelText() const { return GetLabelText(GetLabel()); } - - -#if wxUSE_MARKUP - // Set the label with markup (and mnemonics). Markup is a simple subset of - // HTML with tags such as , and . By default it is not - // supported i.e. all the markup is simply stripped and SetLabel() is - // called but some controls in some ports do support this already and in - // the future most of them should. - // - // Notice that, being HTML-like, markup also supports XML entities so '<' - // should be encoded as "<" and so on, a bare '<' in the input will - // likely result in an error. As an exception, a bare '&' is allowed and - // indicates that the next character is a mnemonic. To insert a literal '&' - // in the control you need to use "&" in the input string. - // - // Returns true if the label was set, even if the markup in it was ignored. - // False is only returned if we failed to parse the label. - bool SetLabelMarkup(const wxString& markup) - { - return DoSetLabelMarkup(markup); - } -#endif // wxUSE_MARKUP - + wxString GetLabelText() const { return GetLabelText(GetLabel()); } // controls by default inherit the colours of their parents, if a // particular control class doesn't want to do it, it can override @@ -128,56 +64,13 @@ public: // if the button was clicked) virtual void Command(wxCommandEvent &event); + virtual void SetLabel( const wxString &label ); virtual bool SetFont(const wxFont& font); // wxControl-specific processing after processing the update event virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); - wxSize GetSizeFromTextSize(int xlen, int ylen = -1) const - { return DoGetSizeFromTextSize(xlen, ylen); } - wxSize GetSizeFromTextSize(const wxSize& tsize) const - { return DoGetSizeFromTextSize(tsize.x, tsize.y); } - - - // static utilities for mnemonics char (&) handling - // ------------------------------------------------ - - // returns the given string without mnemonic characters ('&') - static wxString GetLabelText(const wxString& label); - - // returns the given string without mnemonic characters ('&') - // this function is identic to GetLabelText() and is provided for clarity - // and for symmetry with the wxStaticText::RemoveMarkup() function. - static wxString RemoveMnemonics(const wxString& str); - - // escapes (by doubling them) the mnemonics - static wxString EscapeMnemonics(const wxString& str); - - - // miscellaneous static utilities - // ------------------------------ - - // replaces parts of the given (multiline) string with an ellipsis if needed - static wxString Ellipsize(const wxString& label, const wxDC& dc, - wxEllipsizeMode mode, int maxWidth, - int flags = wxELLIPSIZE_FLAGS_DEFAULT); - - // return the accel index in the string or -1 if none and puts the modified - // string into second parameter if non NULL - static int FindAccelIndex(const wxString& label, - wxString *labelOnly = NULL); - - // this is a helper for the derived class GetClassDefaultAttributes() - // implementation: it returns the right colours for the classes which - // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of - // being simple controls (such as wxButton, wxCheckBox, ...) - static wxVisualAttributes - GetCompositeControlsDefaultAttributes(wxWindowVariant variant); - protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const; - // creates the control (calls wxWindowBase::CreateBase inside) and adds it // to the list of parents children bool CreateControl(wxWindowBase *parent, @@ -188,36 +81,10 @@ protected: const wxValidator& validator, const wxString& name); -#if wxUSE_MARKUP - // This function may be overridden in the derived classes to implement - // support for labels with markup. The base class version simply strips the - // markup and calls SetLabel() with the remaining text. - virtual bool DoSetLabelMarkup(const wxString& markup); -#endif // wxUSE_MARKUP - - // override this to return the total control's size from a string size - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; - // initialize the common fields of wxCommandEvent void InitCommandEvent(wxCommandEvent& event) const; - // Ellipsize() helper: - static wxString DoEllipsizeSingleLine(const wxString& label, const wxDC& dc, - wxEllipsizeMode mode, int maxWidth, - int replacementWidth); - -#if wxUSE_MARKUP - // Remove markup from the given string, returns empty string on error i.e. - // if markup was syntactically invalid. - static wxString RemoveMarkup(const wxString& markup); -#endif // wxUSE_MARKUP - - - // this field contains the label in wx format, i.e. with '&' mnemonics, - // as it was passed to the last SetLabel() call - wxString m_labelOrig; - - wxDECLARE_NO_COPY_CLASS(wxControlBase); + DECLARE_NO_COPY_CLASS(wxControlBase) }; // ---------------------------------------------------------------------------- @@ -226,6 +93,8 @@ protected: #if defined(__WXUNIVERSAL__) #include "wx/univ/control.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/control.h" #elif defined(__WXMSW__) #include "wx/msw/control.h" #elif defined(__WXMOTIF__) @@ -235,7 +104,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/control.h" #elif defined(__WXMAC__) - #include "wx/osx/control.h" + #include "wx/mac/control.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/control.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/convauto.h b/Source/3rd Party/wx/include/wx/convauto.h index 46db14342..ced911950 100644 --- a/Source/3rd Party/wx/include/wx/convauto.h +++ b/Source/3rd Party/wx/include/wx/convauto.h @@ -3,6 +3,7 @@ // Purpose: wxConvAuto class declaration // Author: Vadim Zeitlin // Created: 2006-04-03 +// RCS-ID: $Id: convauto.h 45893 2007-05-08 20:05:16Z VZ $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,63 +12,24 @@ #define _WX_CONVAUTO_H_ #include "wx/strconv.h" -#include "wx/fontenc.h" + +#if wxUSE_WCHAR_T // ---------------------------------------------------------------------------- // wxConvAuto: uses BOM to automatically detect input encoding // ---------------------------------------------------------------------------- -// All currently recognized BOM values. -enum wxBOM -{ - wxBOM_Unknown = -1, - wxBOM_None, - wxBOM_UTF32BE, - wxBOM_UTF32LE, - wxBOM_UTF16BE, - wxBOM_UTF16LE, - wxBOM_UTF8 -}; - class WXDLLIMPEXP_BASE wxConvAuto : public wxMBConv { public: // default ctor, the real conversion will be created on demand - wxConvAuto(wxFontEncoding enc = wxFONTENCODING_DEFAULT) - { - Init(); - - m_encDefault = enc; - } + wxConvAuto() { m_conv = NULL; /* the rest will be initialized later */ } // copy ctor doesn't initialize anything neither as conversion can only be // deduced on first use - wxConvAuto(const wxConvAuto& other) : wxMBConv() - { - Init(); - - m_encDefault = other.m_encDefault; - } - - virtual ~wxConvAuto() - { - if ( m_ownsConv ) - delete m_conv; - } - - // get/set the fall-back encoding used when the input text doesn't have BOM - // and isn't UTF-8 - // - // special values are wxFONTENCODING_MAX meaning not to use any fall back - // at all (but just fail to convert in this case) and wxFONTENCODING_SYSTEM - // meaning to use the encoding of the system locale - static wxFontEncoding GetFallbackEncoding() { return ms_defaultMBEncoding; } - static void SetFallbackEncoding(wxFontEncoding enc); - static void DisableFallbackEncoding() - { - SetFallbackEncoding(wxFONTENCODING_MAX); - } + wxConvAuto(const wxConvAuto& WXUNUSED(other)) : wxMBConv() { m_conv = NULL; } + virtual ~wxConvAuto() { if ( m_conv && m_ownsConv ) delete m_conv; } // override the base class virtual function(s) to use our m_conv virtual size_t ToWChar(wchar_t *dst, size_t dstLen, @@ -80,64 +42,46 @@ public: virtual wxMBConv *Clone() const { return new wxConvAuto(*this); } - // return the BOM type of this buffer - static wxBOM DetectBOM(const char *src, size_t srcLen); - - // return the characters composing the given BOM. - static const char* GetBOMChars(wxBOM bomType, size_t* count); - - wxBOM GetBOM() const - { - return m_bomType; - } - private: - // common part of all ctors - void Init() + // all currently recognized BOM values + enum BOMType { - // We don't initialize m_encDefault here as different ctors do it - // differently. - m_conv = NULL; - m_bomType = wxBOM_Unknown; - m_ownsConv = false; - m_consumedBOM = false; - } + BOM_None, + BOM_UTF32BE, + BOM_UTF32LE, + BOM_UTF16BE, + BOM_UTF16LE, + BOM_UTF8 + }; - // initialize m_conv with the UTF-8 conversion - void InitWithUTF8() + // return the BOM type of this buffer + static BOMType DetectBOM(const char *src, size_t srcLen); + + // initialize m_conv with the conversion to use by default (UTF-8) + void InitWithDefault() { m_conv = &wxConvUTF8; m_ownsConv = false; } // create the correct conversion object for the given BOM type - void InitFromBOM(wxBOM bomType); + void InitFromBOM(BOMType bomType); // create the correct conversion object for the BOM present in the - // beginning of the buffer - // - // return false if the buffer is too short to allow us to determine if we - // have BOM or not - bool InitFromInput(const char *src, size_t len); + // beginning of the buffer; adjust the buffer to skip the BOM if found + void InitFromInput(const char **src, size_t *len); // adjust src and len to skip over the BOM (identified by m_bomType) at the // start of the buffer void SkipBOM(const char **src, size_t *len) const; - // fall-back multibyte encoding to use, may be wxFONTENCODING_SYSTEM or - // wxFONTENCODING_MAX but not wxFONTENCODING_DEFAULT - static wxFontEncoding ms_defaultMBEncoding; - // conversion object which we really use, NULL until the first call to // either ToWChar() or FromWChar() wxMBConv *m_conv; - // the multibyte encoding to use by default if input isn't Unicode - wxFontEncoding m_encDefault; - // our BOM type - wxBOM m_bomType; + BOMType m_bomType; // true if we allocated m_conv ourselves, false if we just use an existing // global conversion @@ -148,8 +92,17 @@ private: bool m_consumedBOM; - wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto); + DECLARE_NO_ASSIGN_CLASS(wxConvAuto) }; +#else // !wxUSE_WCHAR_T + +// it doesn't matter how we define it in this case as it's unused anyhow, but +// do define it to allow the code using wxConvAuto() as default argument (this +// is done in many places) to compile +typedef wxMBConv wxConvAuto; + +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T + #endif // _WX_CONVAUTO_H_ diff --git a/Source/3rd Party/wx/include/wx/cpp.h b/Source/3rd Party/wx/include/wx/cpp.h index e4b09b61f..8d7a646d7 100644 --- a/Source/3rd Party/wx/include/wx/cpp.h +++ b/Source/3rd Party/wx/include/wx/cpp.h @@ -3,6 +3,7 @@ * Purpose: Various preprocessor helpers * Author: Vadim Zeitlin * Created: 2006-09-30 + * RCS-ID: $Id: cpp.h 42993 2006-11-03 21:06:57Z VZ $ * Copyright: (c) 2006 Vadim Zeitlin * Licence: wxWindows licence */ @@ -12,27 +13,9 @@ #ifndef _WX_CPP_H_ #define _WX_CPP_H_ -#include "wx/compiler.h" /* wxCHECK_XXX_VERSION() macros */ - /* wxCONCAT works like preprocessor ## operator but also works with macros */ #define wxCONCAT_HELPER(text, line) text ## line - -#define wxCONCAT(x1, x2) \ - wxCONCAT_HELPER(x1, x2) -#define wxCONCAT3(x1, x2, x3) \ - wxCONCAT(wxCONCAT(x1, x2), x3) -#define wxCONCAT4(x1, x2, x3, x4) \ - wxCONCAT(wxCONCAT3(x1, x2, x3), x4) -#define wxCONCAT5(x1, x2, x3, x4, x5) \ - wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5) -#define wxCONCAT6(x1, x2, x3, x4, x5, x6) \ - wxCONCAT(wxCONCAT5(x1, x2, x3, x4, x5), x6) -#define wxCONCAT7(x1, x2, x3, x4, x5, x6, x7) \ - wxCONCAT(wxCONCAT6(x1, x2, x3, x4, x5, x6), x7) -#define wxCONCAT8(x1, x2, x3, x4, x5, x6, x7, x8) \ - wxCONCAT(wxCONCAT7(x1, x2, x3, x4, x5, x6, x7), x8) -#define wxCONCAT9(x1, x2, x3, x4, x5, x6, x7, x8, x9) \ - wxCONCAT(wxCONCAT8(x1, x2, x3, x4, x5, x6, x7, x8), x9) +#define wxCONCAT(text, line) wxCONCAT_HELPER(text, line) /* wxSTRINGIZE works as the preprocessor # operator but also works with macros */ #define wxSTRINGIZE_HELPER(x) #x @@ -41,16 +24,6 @@ /* a Unicode-friendly version of wxSTRINGIZE_T */ #define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x)) -/* - Special workarounds for compilers with broken "##" operator. For all the - other ones we can just use it directly. - */ -#ifdef wxCOMPILER_BROKEN_CONCAT_OPER - #define wxPREPEND_L(x) L ## x - #define wxAPPEND_i64(x) x ## i64 - #define wxAPPEND_ui64(x) x ## ui64 -#endif /* wxCOMPILER_BROKEN_CONCAT_OPER */ - /* Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the current line number to the given identifier to reduce the probability of the @@ -80,108 +53,5 @@ */ #define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */ -/* - Helpers for defining macros that expand into a single statement. - - The standatd solution is to use "do { ... } while (0)" statement but MSVC - generates a C4127 "condition expression is constant" warning for it so we - use something which is just complicated enough to not be recognized as a - constant but still simple enough to be optimized away. - - Another solution would be to use __pragma() to temporarily disable C4127. - - Notice that wxASSERT_ARG_TYPE in wx/strvargarg.h relies on these macros - creating some kind of a loop because it uses "break". - */ -#ifdef __WATCOMC__ - #define wxFOR_ONCE(name) for(int name=0; name<1; name++) - #define wxSTATEMENT_MACRO_BEGIN wxFOR_ONCE(wxMAKE_UNIQUE_NAME(wxmacro)) { - #define wxSTATEMENT_MACRO_END } -#else - #define wxSTATEMENT_MACRO_BEGIN do { - #define wxSTATEMENT_MACRO_END } while ( (void)0, 0 ) -#endif - -/* - Define __WXFUNCTION__ which is like standard __FUNCTION__ but defined as - NULL for the compilers which don't support the latter. - */ -#ifndef __WXFUNCTION__ - /* TODO: add more compilers supporting __FUNCTION__ */ - #if defined(__DMC__) - /* - __FUNCTION__ happens to be not defined within class members - http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485 - */ - #define __WXFUNCTION__ (NULL) - #elif defined(__GNUC__) || \ - (defined(_MSC_VER) && _MSC_VER >= 1300) || \ - defined(__FUNCTION__) - #define __WXFUNCTION__ __FUNCTION__ - #else - /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */ - #define __WXFUNCTION__ (NULL) - #endif -#endif /* __WXFUNCTION__ already defined */ - - -/* Auto-detect variadic macros support unless explicitly disabled. */ -#if !defined(HAVE_VARIADIC_MACROS) && !defined(wxNO_VARIADIC_MACROS) - /* Any C99 or C++11 compiler should have them. */ - #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - (defined(__cplusplus) && __cplusplus >= 201103L) - #define HAVE_VARIADIC_MACROS - #elif wxCHECK_GCC_VERSION(3,0) - #define HAVE_VARIADIC_MACROS - #elif wxCHECK_VISUALC_VERSION(8) - #define HAVE_VARIADIC_MACROS - #elif wxCHECK_WATCOM_VERSION(1,2) - #define HAVE_VARIADIC_MACROS - #endif -#endif /* !HAVE_VARIADIC_MACROS */ - - - -#ifdef HAVE_VARIADIC_MACROS -/* - wxCALL_FOR_EACH(what, ...) calls the macro from its first argument, what(pos, x), - for every remaining argument 'x', with 'pos' being its 1-based index in - *reverse* order (with the last argument being numbered 1). - - For example, wxCALL_FOR_EACH(test, a, b, c) expands into this: - - test(3, a) \ - test(2, b) \ - test(1, c) - - Up to eight arguments are supported. - - (With thanks to https://groups.google.com/d/topic/comp.std.c/d-6Mj5Lko_s/discussion - and http://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros) -*/ -#define wxCALL_FOR_EACH_NARG(...) wxCALL_FOR_EACH_NARG_((__VA_ARGS__, wxCALL_FOR_EACH_RSEQ_N())) -#define wxCALL_FOR_EACH_NARG_(args) wxCALL_FOR_EACH_ARG_N args -#define wxCALL_FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N -#define wxCALL_FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0 - -#define wxCALL_FOR_EACH_1(what, x) what(1, x) -#define wxCALL_FOR_EACH_2(what, x, ...) what(2, x) wxCALL_FOR_EACH_1(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_3(what, x, ...) what(3, x) wxCALL_FOR_EACH_2(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_4(what, x, ...) what(4, x) wxCALL_FOR_EACH_3(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_5(what, x, ...) what(5, x) wxCALL_FOR_EACH_4(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_6(what, x, ...) what(6, x) wxCALL_FOR_EACH_5(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_7(what, x, ...) what(7, x) wxCALL_FOR_EACH_6(what, __VA_ARGS__) -#define wxCALL_FOR_EACH_8(what, x, ...) what(8, x) wxCALL_FOR_EACH_7(what, __VA_ARGS__) - -#define wxCALL_FOR_EACH_(N, args) \ - wxCONCAT(wxCALL_FOR_EACH_, N) args - -#define wxCALL_FOR_EACH(what, ...) \ - wxCALL_FOR_EACH_(wxCALL_FOR_EACH_NARG(__VA_ARGS__), (what, __VA_ARGS__)) - -#else - #define wxCALL_FOR_EACH Error_wx_CALL_FOR_EACH_requires_variadic_macros_support -#endif /* HAVE_VARIADIC_MACROS */ - -#endif /* _WX_CPP_H_ */ +#endif // _WX_CPP_H_ diff --git a/Source/3rd Party/wx/include/wx/cppunit.h b/Source/3rd Party/wx/include/wx/cppunit.h deleted file mode 100644 index 89edd9165..000000000 --- a/Source/3rd Party/wx/include/wx/cppunit.h +++ /dev/null @@ -1,301 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/cppunit.h -// Purpose: wrapper header for CppUnit headers -// Author: Vadim Zeitlin -// Created: 15.02.04 -// Copyright: (c) 2004 Vadim Zeitlin -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CPPUNIT_H_ -#define _WX_CPPUNIT_H_ - -/////////////////////////////////////////////////////////////////////////////// -// using CPPUNIT_TEST() macro results in this warning, disable it as there is -// no other way to get rid of it and it's not very useful anyhow -#ifdef __VISUALC__ - // typedef-name 'foo' used as synonym for class-name 'bar' - #pragma warning(disable:4097) - - // unreachable code: we don't care about warnings in CppUnit headers - #pragma warning(disable:4702) - - // 'id': identifier was truncated to 'num' characters in the debug info - #pragma warning(disable:4786) -#endif // __VISUALC__ - -#ifdef __BORLANDC__ - #pragma warn -8022 -#endif - -#ifndef CPPUNIT_STD_NEED_ALLOCATOR - #define CPPUNIT_STD_NEED_ALLOCATOR 0 -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Set the default format for the errors, which can be used by an IDE to jump -// to the error location. This default gets overridden by the cppunit headers -// for some compilers (e.g. VC++). - -#ifndef CPPUNIT_COMPILER_LOCATION_FORMAT - #define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:" -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// Include all needed cppunit headers. -// - -#include "wx/beforestd.h" -#ifdef __VISUALC__ - #pragma warning(push) - - // with cppunit 1.12 we get many bogus warnings 4701 (local variable may be - // used without having been initialized) in TestAssert.h - #pragma warning(disable:4701) - - // and also 4100 (unreferenced formal parameter) in extensions/ - // ExceptionTestCaseDecorator.h - #pragma warning(disable:4100) -#endif - -#include -#include -#include -#include -#include - -#ifdef __VISUALC__ - #pragma warning(pop) -#endif -#include "wx/afterstd.h" - -#include "wx/string.h" - - -/////////////////////////////////////////////////////////////////////////////// -// Set of helpful test macros. -// - -// Base macro for wrapping CPPUNIT_TEST macros and so making them conditional -// tests, meaning that the test only get registered and thus run when a given -// runtime condition is true. -// In case the condition is evaluated as false a skip message is logged -// (the message will only be shown in verbose mode). -#define WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, anyTest) \ - if (Condition) \ - { anyTest; } \ - else \ - wxLogInfo(wxString::Format(wxT("skipping: %s.%s\n reason: %s equals false\n"), \ - wxString(suiteName, wxConvUTF8).c_str(), \ - wxString(#testMethod, wxConvUTF8).c_str(), \ - wxString(#Condition, wxConvUTF8).c_str())) - -// Conditional CPPUNIT_TEST macro. -#define WXTEST_WITH_CONDITION(suiteName, Condition, testMethod) \ - WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST(testMethod)) -// Conditional CPPUNIT_TEST_FAIL macro. -#define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \ - WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod)) - -CPPUNIT_NS_BEGIN - -// provide an overload of cppunit assertEquals(T, T) which can be used to -// compare wxStrings directly with C strings -inline void -assertEquals(const char *expected, - const char *actual, - CppUnit::SourceLine sourceLine, - const std::string& message) -{ - assertEquals(wxString(expected), wxString(actual), sourceLine, message); -} - -inline void -assertEquals(const char *expected, - const wxString& actual, - CppUnit::SourceLine sourceLine, - const std::string& message) -{ - assertEquals(wxString(expected), actual, sourceLine, message); -} - -inline void -assertEquals(const wxString& expected, - const char *actual, - CppUnit::SourceLine sourceLine, - const std::string& message) -{ - assertEquals(expected, wxString(actual), sourceLine, message); -} - -inline void -assertEquals(const wchar_t *expected, - const wxString& actual, - CppUnit::SourceLine sourceLine, - const std::string& message) -{ - assertEquals(wxString(expected), actual, sourceLine, message); -} - -inline void -assertEquals(const wxString& expected, - const wchar_t *actual, - CppUnit::SourceLine sourceLine, - const std::string& message) -{ - assertEquals(expected, wxString(actual), sourceLine, message); -} - -CPPUNIT_NS_END - -// define an assertEquals() overload for the given types, this is a helper and -// shouldn't be used directly because of VC6 complications, see below -#define WX_CPPUNIT_ASSERT_EQUALS(T1, T2) \ - inline void \ - assertEquals(T1 expected, \ - T2 actual, \ - CppUnit::SourceLine sourceLine, \ - const std::string& message) \ - { \ - if ( !assertion_traits::equal(expected,actual) ) \ - { \ - Asserter::failNotEqual( assertion_traits::toString(expected), \ - assertion_traits::toString(actual), \ - sourceLine, \ - message ); \ - } \ - } - -// this macro allows us to specify (usually literal) ints as expected values -// for functions returning integral types different from "int" -// -// FIXME-VC6: due to incorrect resolution of overloaded/template functions in -// this compiler (it basically doesn't use the template version at -// all if any overloaded function matches partially even if none of -// them matches fully) we also need to provide extra overloads - -#ifdef __VISUALC6__ - #define WX_CPPUNIT_ALLOW_EQUALS_TO_INT(T) \ - CPPUNIT_NS_BEGIN \ - WX_CPPUNIT_ASSERT_EQUALS(int, T) \ - WX_CPPUNIT_ASSERT_EQUALS(T, int) \ - WX_CPPUNIT_ASSERT_EQUALS(T, T) \ - CPPUNIT_NS_END - - CPPUNIT_NS_BEGIN - WX_CPPUNIT_ASSERT_EQUALS(int, int) - CPPUNIT_NS_END -#else // !VC6 - #define WX_CPPUNIT_ALLOW_EQUALS_TO_INT(T) \ - CPPUNIT_NS_BEGIN \ - WX_CPPUNIT_ASSERT_EQUALS(int, T) \ - WX_CPPUNIT_ASSERT_EQUALS(T, int) \ - CPPUNIT_NS_END -#endif // VC6/!VC6 - -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(long) -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(short) -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(unsigned) -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(unsigned long) - -#if defined( __VMS ) && defined( __ia64 ) -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(std::basic_streambuf::pos_type); -#endif - -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxLongLong_t) -WX_CPPUNIT_ALLOW_EQUALS_TO_INT(unsigned wxLongLong_t) -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - -// Use this macro to compare a wxArrayString with the pipe-separated elements -// of the given string -// -// NB: it's a macro and not a function to have the correct line numbers in the -// test failure messages -#define WX_ASSERT_STRARRAY_EQUAL(s, a) \ - { \ - wxArrayString expected(wxSplit(s, '|', '\0')); \ - \ - CPPUNIT_ASSERT_EQUAL( expected.size(), a.size() ); \ - \ - for ( size_t n = 0; n < a.size(); n++ ) \ - { \ - CPPUNIT_ASSERT_EQUAL( expected[n], a[n] ); \ - } \ - } - -// Use this macro to assert with the given formatted message (it should contain -// the format string and arguments in a separate pair of parentheses) -#define WX_ASSERT_MESSAGE(msg, cond) \ - CPPUNIT_ASSERT_MESSAGE(std::string(wxString::Format msg .mb_str()), (cond)) - -#define WX_ASSERT_EQUAL_MESSAGE(msg, expected, actual) \ - CPPUNIT_ASSERT_EQUAL_MESSAGE(std::string(wxString::Format msg .mb_str()), \ - (expected), (actual)) - -/////////////////////////////////////////////////////////////////////////////// -// define stream inserter for wxString if it's not defined in the main library, -// we need it to output the test failures involving wxString -#if !wxUSE_STD_IOSTREAM - -#include "wx/string.h" - -#include - -inline std::ostream& operator<<(std::ostream& o, const wxString& s) -{ -#if wxUSE_UNICODE - return o << (const char *)wxSafeConvertWX2MB(s.wc_str()); -#else - return o << s.c_str(); -#endif -} - -#endif // !wxUSE_STD_IOSTREAM - -// VC6 doesn't provide overloads for operator<<(__int64) in its stream classes -// so do it ourselves -#if defined(__VISUALC6__) && defined(wxLongLong_t) - -#include "wx/longlong.h" - -inline std::ostream& operator<<(std::ostream& ostr, wxLongLong_t ll) -{ - ostr << wxLongLong(ll).ToString(); - - return ostr; -} - -inline std::ostream& operator<<(std::ostream& ostr, unsigned wxLongLong_t llu) -{ - ostr << wxULongLong(llu).ToString(); - - return ostr; -} - -#endif // VC6 && wxLongLong_t - -/////////////////////////////////////////////////////////////////////////////// -// Some more compiler warning tweaking and auto linking. -// - -#ifdef __BORLANDC__ - #pragma warn .8022 -#endif - -#ifdef _MSC_VER - #pragma warning(default:4702) -#endif // _MSC_VER - -// for VC++ automatically link in cppunit library -#ifdef __VISUALC__ - #ifdef NDEBUG - #pragma comment(lib, "cppunit.lib") - #else // Debug - #pragma comment(lib, "cppunitd.lib") - #endif // Release/Debug -#endif - -#endif // _WX_CPPUNIT_H_ - diff --git a/Source/3rd Party/wx/include/wx/crt.h b/Source/3rd Party/wx/include/wx/crt.h deleted file mode 100644 index 9b939fd0f..000000000 --- a/Source/3rd Party/wx/include/wx/crt.h +++ /dev/null @@ -1,22 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Name: wx/crt.h -// Purpose: Header to include all headers with wrappers for CRT functions -// Author: Robert Roebling -// Created: 2007-05-30 -// Copyright: (c) 2007 wxWidgets dev team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CRT_H_ -#define _WX_CRT_H_ - -#include "wx/defs.h" - -// include wxChar type definition: -#include "wx/chartype.h" - -// and wrappers for CRT functions: -#include "wx/wxcrt.h" -#include "wx/wxcrtvararg.h" - -#endif // _WX_CRT_H_ diff --git a/Source/3rd Party/wx/include/wx/cshelp.h b/Source/3rd Party/wx/include/wx/cshelp.h index 50258f758..53e13c389 100644 --- a/Source/3rd Party/wx/include/wx/cshelp.h +++ b/Source/3rd Party/wx/include/wx/cshelp.h @@ -4,6 +4,7 @@ // Author: Julian Smart, Vadim Zeitlin // Modified by: // Created: 08/09/2000 +// RCS-ID: $Id: cshelp.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2000 Julian Smart, Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,7 +36,7 @@ * window for the application to display help for. */ -class WXDLLIMPEXP_CORE wxContextHelp : public wxObject +class WXDLLEXPORT wxContextHelp : public wxObject { public: wxContextHelp(wxWindow* win = NULL, bool beginHelp = true); @@ -64,7 +65,7 @@ private: * to put the application into context help mode. */ -class WXDLLIMPEXP_CORE wxContextHelpButton : public wxBitmapButton +class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton { public: wxContextHelpButton(wxWindow* parent, @@ -105,7 +106,7 @@ private: // and overriding ShowHelp() but calling the base class version wouldn't work // any more, which forces us to use a rather ugly hack and pass the extra // parameters of ShowHelpAtPoint() to ShowHelp() via member variables. -class WXDLLIMPEXP_CORE wxHelpProvider +class WXDLLEXPORT wxHelpProvider { public: // get/set the current (application-global) help provider (Set() returns @@ -187,7 +188,7 @@ WX_DECLARE_EXPORTED_HASH_MAP( wxUIntPtr, wxString, wxIntegerHash, // wxSimpleHelpProvider is an implementation of wxHelpProvider which supports // only plain text help strings and shows the string associated with the // control (if any) in a tooltip -class WXDLLIMPEXP_CORE wxSimpleHelpProvider : public wxHelpProvider +class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider { public: // implement wxHelpProvider methods @@ -211,12 +212,12 @@ protected: // both context identifiers and plain text help strings. If the help text is an integer, // it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string // in a tooltip as per wxSimpleHelpProvider. -class WXDLLIMPEXP_CORE wxHelpControllerHelpProvider : public wxSimpleHelpProvider +class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider { public: // Note that it doesn't own the help controller. The help controller // should be deleted separately. - wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL); + wxHelpControllerHelpProvider(wxHelpControllerBase* hc = (wxHelpControllerBase*) NULL); // implement wxHelpProvider methods @@ -231,11 +232,11 @@ public: protected: wxHelpControllerBase* m_helpController; - wxDECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider); + DECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider) }; // Convenience function for turning context id into wxString -WXDLLIMPEXP_CORE wxString wxContextId(int id); +WXDLLEXPORT wxString wxContextId(int id); #endif // wxUSE_HELP diff --git a/Source/3rd Party/wx/include/wx/ctrlsub.h b/Source/3rd Party/wx/include/wx/ctrlsub.h index d757e80f1..dc29fe63f 100644 --- a/Source/3rd Party/wx/include/wx/ctrlsub.h +++ b/Source/3rd Party/wx/include/wx/ctrlsub.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 22.10.99 +// RCS-ID: $Id: ctrlsub.h 42816 2006-10-31 08:50:17Z RD $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,6 @@ #if wxUSE_CONTROLS -#include "wx/arrstr.h" #include "wx/control.h" // base class // ---------------------------------------------------------------------------- @@ -29,7 +29,7 @@ // implements an extended interface deriving from this one) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxItemContainerImmutable +class WXDLLEXPORT wxItemContainerImmutable { public: wxItemContainerImmutable() { } @@ -72,7 +72,7 @@ public: bool SetStringSelection(const wxString& s); // return the selected string or empty string if none - virtual wxString GetStringSelection() const; + wxString GetStringSelection() const; // this is the same as SetSelection( for single-selection controls but // reads better for multi-selection ones @@ -80,109 +80,14 @@ public: protected: + // check that the index is valid - bool IsValid(unsigned int n) const { return n < GetCount(); } - bool IsValidInsert(unsigned int n) const { return n <= GetCount(); } + inline bool IsValid(unsigned int n) const { return n < GetCount(); } + inline bool IsValidInsert(unsigned int n) const { return n <= GetCount(); } }; -// ---------------------------------------------------------------------------- -// wxItemContainer extends wxItemContainerImmutable interface with methods -// for adding/removing items. -// -// Classes deriving from this one must override DoInsertItems() to implement -// adding items to the control. This can often be implemented more efficiently -// than simply looping over the elements and inserting them but if this is not -// the case, the generic DoInsertItemsInLoop can be used in implementation, but -// in this case DoInsertItem() needs to be overridden. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxItemContainer : public wxItemContainerImmutable +class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable { -private: - // AppendItems() and InsertItems() helpers just call DoAppend/InsertItems() - // after doing some checks - // - // NB: they're defined here so that they're inlined when used in public part - int AppendItems(const wxArrayStringsAdapter& items, - void **clientData, - wxClientDataType type) - { - if ( items.IsEmpty() ) - return wxNOT_FOUND; - - return DoAppendItems(items, clientData, type); - } - - int AppendItems(const wxArrayStringsAdapter& items) - { - return AppendItems(items, NULL, wxClientData_None); - } - - int AppendItems(const wxArrayStringsAdapter& items, void **clientData) - { - wxASSERT_MSG( GetClientDataType() != wxClientData_Object, - wxT("can't mix different types of client data") ); - - return AppendItems(items, clientData, wxClientData_Void); - } - - int AppendItems(const wxArrayStringsAdapter& items, - wxClientData **clientData) - { - wxASSERT_MSG( GetClientDataType() != wxClientData_Void, - wxT("can't mix different types of client data") ); - - return AppendItems(items, reinterpret_cast(clientData), - wxClientData_Object); - } - - int InsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) - { - wxASSERT_MSG( !IsSorted(), wxT("can't insert items in sorted control") ); - - wxCHECK_MSG( pos <= GetCount(), wxNOT_FOUND, - wxT("position out of range") ); - - // not all derived classes handle empty arrays correctly in - // DoInsertItems() and besides it really doesn't make much sense to do - // this (for append it could correspond to creating an initially empty - // control but why would anybody need to insert 0 items?) - wxCHECK_MSG( !items.IsEmpty(), wxNOT_FOUND, - wxT("need something to insert") ); - - return DoInsertItems(items, pos, clientData, type); - } - - int InsertItems(const wxArrayStringsAdapter& items, unsigned int pos) - { - return InsertItems(items, pos, NULL, wxClientData_None); - } - - int InsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData) - { - wxASSERT_MSG( GetClientDataType() != wxClientData_Object, - wxT("can't mix different types of client data") ); - - return InsertItems(items, pos, clientData, wxClientData_Void); - } - - int InsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - wxClientData **clientData) - { - wxASSERT_MSG( GetClientDataType() != wxClientData_Void, - wxT("can't mix different types of client data") ); - - return InsertItems(items, pos, - reinterpret_cast(clientData), - wxClientData_Object); - } - public: wxItemContainer() { m_clientDataItemsType = wxClientData_None; } virtual ~wxItemContainer(); @@ -190,262 +95,99 @@ public: // adding items // ------------ - // append single item, return its position in the control (which can be - // different from the last one if the control is sorted) int Append(const wxString& item) - { return AppendItems(item); } + { return DoAppend(item); } int Append(const wxString& item, void *clientData) - { return AppendItems(item, &clientData); } + { int n = DoAppend(item); SetClientData(n, clientData); return n; } int Append(const wxString& item, wxClientData *clientData) - { return AppendItems(item, &clientData); } + { int n = DoAppend(item); SetClientObject(n, clientData); return n; } - // append several items at once to the control, return the position of the - // last item appended - int Append(const wxArrayString& items) - { return AppendItems(items); } - int Append(const wxArrayString& items, void **clientData) - { return AppendItems(items, clientData); } - int Append(const wxArrayString& items, wxClientData **clientData) - { return AppendItems(items, clientData); } - int Append(unsigned int n, const wxString *items) - { return AppendItems(wxArrayStringsAdapter(n, items)); } - int Append(unsigned int n, const wxString *items, void **clientData) - { return AppendItems(wxArrayStringsAdapter(n, items), clientData); } - int Append(unsigned int n, - const wxString *items, - wxClientData **clientData) - { return AppendItems(wxArrayStringsAdapter(n, items), clientData); } + // only for rtti needs (separate name) + void AppendString( const wxString& item) + { Append( item ); } - // only for RTTI needs (separate name) - void AppendString(const wxString& item) - { Append(item); } + // append several items at once to the control + void Append(const wxArrayString& strings); - - // inserting items: not for sorted controls! - // ----------------------------------------- - - // insert single item at the given position, return its effective position int Insert(const wxString& item, unsigned int pos) - { return InsertItems(item, pos); } - int Insert(const wxString& item, unsigned int pos, void *clientData) - { return InsertItems(item, pos, &clientData); } - int Insert(const wxString& item, unsigned int pos, wxClientData *clientData) - { return InsertItems(item, pos, &clientData); } - - // insert several items at once into the control, return the index of the - // last item inserted - int Insert(const wxArrayString& items, unsigned int pos) - { return InsertItems(items, pos); } - int Insert(const wxArrayString& items, unsigned int pos, void **clientData) - { return InsertItems(items, pos, clientData); } - int Insert(const wxArrayString& items, - unsigned int pos, - wxClientData **clientData) - { return InsertItems(items, pos, clientData); } - int Insert(unsigned int n, const wxString *items, unsigned int pos) - { return InsertItems(wxArrayStringsAdapter(n, items), pos); } - int Insert(unsigned int n, - const wxString *items, - unsigned int pos, - void **clientData) - { return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); } - int Insert(unsigned int n, - const wxString *items, - unsigned int pos, - wxClientData **clientData) - { return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); } - - - // replacing items - // --------------- - - void Set(const wxArrayString& items) - { Clear(); Append(items); } - void Set(const wxArrayString& items, void **clientData) - { Clear(); Append(items, clientData); } - void Set(const wxArrayString& items, wxClientData **clientData) - { Clear(); Append(items, clientData); } - void Set(unsigned int n, const wxString *items) - { Clear(); Append(n, items); } - void Set(unsigned int n, const wxString *items, void **clientData) - { Clear(); Append(n, items, clientData); } - void Set(unsigned int n, const wxString *items, wxClientData **clientData) - { Clear(); Append(n, items, clientData); } + { return DoInsert(item, pos); } + int Insert(const wxString& item, unsigned int pos, void *clientData); + int Insert(const wxString& item, unsigned int pos, wxClientData *clientData); // deleting items // -------------- - void Clear(); - void Delete(unsigned int pos); - - - // various accessors - // ----------------- - - // The control may maintain its items in a sorted order in which case - // items are automatically inserted at the right position when they are - // inserted or appended. Derived classes have to override this method if - // they implement sorting, typically by returning HasFlag(wxXX_SORT) - virtual bool IsSorted() const { return false; } + virtual void Clear() = 0; + virtual void Delete(unsigned int n) = 0; + // misc + // ---- // client data stuff - // ----------------- - void SetClientData(unsigned int n, void* clientData); void* GetClientData(unsigned int n) const; - // SetClientObject() takes ownership of the pointer, GetClientObject() - // returns it but keeps the ownership while DetachClientObject() expects - // the caller to delete the pointer and also resets the internally stored - // one to NULL for this item void SetClientObject(unsigned int n, wxClientData* clientData); wxClientData* GetClientObject(unsigned int n) const; - wxClientData* DetachClientObject(unsigned int n); - // return the type of client data stored in this control: usually it just - // returns m_clientDataItemsType but must be overridden in the controls - // which delegate their client data storage to another one (e.g. wxChoice - // in wxUniv which stores data in wxListBox which it uses anyhow); don't - // forget to override SetClientDataType() if you override this one - // - // NB: for this to work no code should ever access m_clientDataItemsType - // directly but only via this function! - virtual wxClientDataType GetClientDataType() const - { return m_clientDataItemsType; } - - bool HasClientData() const - { return GetClientDataType() != wxClientData_None; } bool HasClientObjectData() const - { return GetClientDataType() == wxClientData_Object; } + { return m_clientDataItemsType == wxClientData_Object; } bool HasClientUntypedData() const - { return GetClientDataType() == wxClientData_Void; } + { return m_clientDataItemsType == wxClientData_Void; } protected: - // there is usually no need to override this method but you can do it if it - // is more convenient to only do "real" insertions in DoInsertItems() and - // to implement items appending here (in which case DoInsertItems() should - // call this method if pos == GetCount() as it can still be called in this - // case if public Insert() is called with such position) - virtual int DoAppendItems(const wxArrayStringsAdapter& items, - void **clientData, - wxClientDataType type) - { - return DoInsertItems(items, GetCount(), clientData, type); - } + virtual int DoAppend(const wxString& item) = 0; + virtual int DoInsert(const wxString& item, unsigned int pos) = 0; - // this method must be implemented to insert the items into the control at - // position pos which can be GetCount() meaning that the items should be - // appended; for the sorted controls the position can be ignored - // - // the derived classes typically use AssignNewItemClientData() to - // associate the data with the items as they're being inserted - // - // the method should return the index of the position the last item was - // inserted into or wxNOT_FOUND if an error occurred - virtual int DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, - wxClientDataType type) = 0; - - // before the client data is set for the first time for the control which - // hadn't had it before, DoInitItemClientData() is called which gives the - // derived class the possibility to initialize its client data storage only - // when client data is really used - virtual void DoInitItemClientData() { } - virtual void DoSetItemClientData(unsigned int n, void *clientData) = 0; - virtual void *DoGetItemClientData(unsigned int n) const = 0; - - virtual void DoClear() = 0; - virtual void DoDeleteOneItem(unsigned int pos) = 0; + virtual void DoSetItemClientData(unsigned int n, void* clientData) = 0; + virtual void* DoGetItemClientData(unsigned int n) const = 0; + virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData) = 0; + virtual wxClientData* DoGetItemClientObject(unsigned int n) const = 0; - // methods useful for the derived classes which don't have any better way - // of adding multiple items to the control than doing it one by one: such - // classes should call DoInsertItemsInLoop() from their DoInsert() and - // override DoInsertOneItem() to perform the real insertion - virtual int DoInsertOneItem(const wxString& item, unsigned int pos); - int DoInsertItemsInLoop(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type); - - - // helper for DoInsertItems(): n is the index into clientData, pos is the - // position of the item in the control - void AssignNewItemClientData(unsigned int pos, - void **clientData, - unsigned int n, - wxClientDataType type); - - // free the client object associated with the item at given position and - // set it to NULL (must only be called if HasClientObjectData()) - void ResetItemClientObject(unsigned int n); - - // set the type of the client data stored in this control: override this if - // you override GetClientDataType() - virtual void SetClientDataType(wxClientDataType clientDataItemsType) - { - m_clientDataItemsType = clientDataItemsType; - } - -private: // the type of the client data for the items wxClientDataType m_clientDataItemsType; }; -// Inheriting directly from a wxWindow-derived class and wxItemContainer -// unfortunately introduces an ambiguity for all GetClientXXX() methods as they -// are inherited twice: the "global" versions from wxWindow and the per-item -// versions taking the index from wxItemContainer. -// -// So we need to explicitly resolve them and this helper template class is -// provided to do it. To use it, simply inherit from wxWindowWithItems instead of Window and Container interface directly. -template -class wxWindowWithItems : public W, public C -{ -public: - typedef W BaseWindowClass; - typedef C BaseContainerInterface; - - wxWindowWithItems() { } - - void SetClientData(void *data) - { BaseWindowClass::SetClientData(data); } - void *GetClientData() const - { return BaseWindowClass::GetClientData(); } - void SetClientObject(wxClientData *data) - { BaseWindowClass::SetClientObject(data); } - wxClientData *GetClientObject() const - { return BaseWindowClass::GetClientObject(); } - - void SetClientData(unsigned int n, void* clientData) - { wxItemContainer::SetClientData(n, clientData); } - void* GetClientData(unsigned int n) const - { return wxItemContainer::GetClientData(n); } - void SetClientObject(unsigned int n, wxClientData* clientData) - { wxItemContainer::SetClientObject(n, clientData); } - wxClientData* GetClientObject(unsigned int n) const +// this macro must (unfortunately) be used in any class deriving from both +// wxItemContainer and wxControl because otherwise there is ambiguity when +// calling GetClientXXX() functions -- the compiler can't choose between the +// two versions +#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \ + void SetClientData(void *data) \ + { wxEvtHandler::SetClientData(data); } \ + void *GetClientData() const \ + { return wxEvtHandler::GetClientData(); } \ + void SetClientObject(wxClientData *data) \ + { wxEvtHandler::SetClientObject(data); } \ + wxClientData *GetClientObject() const \ + { return wxEvtHandler::GetClientObject(); } \ + void SetClientData(unsigned int n, void* clientData) \ + { wxItemContainer::SetClientData(n, clientData); } \ + void* GetClientData(unsigned int n) const \ + { return wxItemContainer::GetClientData(n); } \ + void SetClientObject(unsigned int n, wxClientData* clientData) \ + { wxItemContainer::SetClientObject(n, clientData); } \ + wxClientData* GetClientObject(unsigned int n) const \ { return wxItemContainer::GetClientObject(n); } -}; -class WXDLLIMPEXP_CORE wxControlWithItemsBase : - public wxWindowWithItems +class WXDLLEXPORT wxControlWithItems : public wxControl, public wxItemContainer { public: - wxControlWithItemsBase() { } + wxControlWithItems() { } + virtual ~wxControlWithItems(); + + // we have to redefine these functions here to avoid ambiguities in classes + // deriving from us which would arise otherwise because both base classses + // have the methods with the same names - hopefully, a smart compiler can + // optimize away these simple inline wrappers so we don't suffer much from + // this + wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST // usually the controls like list/combo boxes have their own background // colour virtual bool ShouldInheritColours() const { return false; } - - // Implementation only from now on. - - // Generate an event of the given type for the selection change. - void SendSelectionChangedEvent(wxEventType eventType); - protected: // fill in the client object or data field of the event as appropriate // @@ -454,25 +196,14 @@ protected: void InitCommandEventWithItems(wxCommandEvent& event, int n); private: - wxDECLARE_NO_COPY_CLASS(wxControlWithItemsBase); + DECLARE_ABSTRACT_CLASS(wxControlWithItems) + DECLARE_NO_COPY_CLASS(wxControlWithItems) }; -// define the platform-specific wxControlWithItems class -#if defined(__WXMSW__) - #include "wx/msw/ctrlsub.h" -#elif defined(__WXMOTIF__) - #include "wx/motif/ctrlsub.h" -#else - class WXDLLIMPEXP_CORE wxControlWithItems : public wxControlWithItemsBase - { - public: - wxControlWithItems() { } - private: - DECLARE_ABSTRACT_CLASS(wxControlWithItems) - wxDECLARE_NO_COPY_CLASS(wxControlWithItems); - }; -#endif +// ---------------------------------------------------------------------------- +// inline functions +// ---------------------------------------------------------------------------- #endif // wxUSE_CONTROLS diff --git a/Source/3rd Party/wx/include/wx/cursor.h b/Source/3rd Party/wx/include/wx/cursor.h index ef1413294..d072ff56a 100644 --- a/Source/3rd Party/wx/include/wx/cursor.h +++ b/Source/3rd Party/wx/include/wx/cursor.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: cursor.h 40865 2006-08-27 09:42:42Z VS $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -13,56 +14,27 @@ #include "wx/defs.h" -/* - wxCursor classes should have the following public API: - -class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject -{ -public: - wxCursor(); - wxCursor(const wxImage& image); - wxCursor(const wxString& name, - wxBitmapType type = wxCURSOR_DEFAULT_TYPE, - int hotSpotX = 0, int hotSpotY = 0); - wxCursor(wxStockCursor id) { InitFromStock(id); } -#if WXWIN_COMPATIBILITY_2_8 - wxCursor(int id) { InitFromStock((wxStockCursor)id); } -#endif - virtual ~wxCursor(); -}; - -*/ - -#if defined(__WXMSW__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE +#if defined(__WXPALMOS__) + #include "wx/palmos/cursor.h" +#elif defined(__WXMSW__) #include "wx/msw/cursor.h" #elif defined(__WXMOTIF__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XBM #include "wx/motif/cursor.h" #elif defined(__WXGTK20__) - #ifdef __WINDOWS__ - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE - #else - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM - #endif #include "wx/gtk/cursor.h" #elif defined(__WXGTK__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/gtk1/cursor.h" #elif defined(__WXX11__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/x11/cursor.h" +#elif defined(__WXMGL__) + #include "wx/mgl/cursor.h" #elif defined(__WXDFB__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE #include "wx/dfb/cursor.h" #elif defined(__WXMAC__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE - #include "wx/osx/cursor.h" + #include "wx/mac/cursor.h" #elif defined(__WXCOCOA__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE #include "wx/cocoa/cursor.h" #elif defined(__WXPM__) - #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE #include "wx/os2/cursor.h" #endif diff --git a/Source/3rd Party/wx/include/wx/custombgwin.h b/Source/3rd Party/wx/include/wx/custombgwin.h deleted file mode 100644 index 73890a465..000000000 --- a/Source/3rd Party/wx/include/wx/custombgwin.h +++ /dev/null @@ -1,52 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/custombgwin.h -// Purpose: Class adding support for custom window backgrounds. -// Author: Vadim Zeitlin -// Created: 2011-10-10 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CUSTOMBGWIN_H_ -#define _WX_CUSTOMBGWIN_H_ - -// ---------------------------------------------------------------------------- -// wxCustomBackgroundWindow: Adds support for custom backgrounds to any -// wxWindow-derived class. -// ---------------------------------------------------------------------------- - -class wxCustomBackgroundWindowBase -{ -public: - // Trivial default ctor. - wxCustomBackgroundWindowBase() { } - - // Also a trivial but virtual -- to suppress g++ warnings -- dtor. - virtual ~wxCustomBackgroundWindowBase() { } - - // Use the given bitmap to tile the background of this window. This bitmap - // will show through any transparent children. - // - // Notice that you must not prevent the base class EVT_ERASE_BACKGROUND - // handler from running (i.e. not to handle this event yourself) for this - // to work. - void SetBackgroundBitmap(const wxBitmap& bmp) - { - DoSetBackgroundBitmap(bmp); - } - -protected: - virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) = 0; - - wxDECLARE_NO_COPY_CLASS(wxCustomBackgroundWindowBase); -}; - -#if defined(__WXUNIVERSAL__) - #include "wx/univ/custombgwin.h" -#elif defined(__WXMSW__) - #include "wx/msw/custombgwin.h" -#else - #include "wx/generic/custombgwin.h" -#endif - -#endif // _WX_CUSTOMBGWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/dataobj.h b/Source/3rd Party/wx/include/wx/dataobj.h index d93e01e9f..31a756e23 100644 --- a/Source/3rd Party/wx/include/wx/dataobj.h +++ b/Source/3rd Party/wx/include/wx/dataobj.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin, Robert Roebling // Modified by: // Created: 26.05.99 +// RCS-ID: $Id: dataobj.h 40772 2006-08-23 13:38:45Z VZ $ // Copyright: (c) wxWidgets Team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ public: typedef NativeFormat; wxDataFormat(NativeFormat format = wxDF_INVALID); - wxDataFormat(const wxString& format); + wxDataFormat(const wxChar *format); wxDataFormat& operator=(NativeFormat format); wxDataFormat& operator=(const wxDataFormat& format); @@ -66,7 +67,7 @@ public: NativeFormat GetType() const; wxString GetId() const; - void SetId(const wxString& format); + void SetId(const wxChar *format); }; */ @@ -82,7 +83,7 @@ public: #elif defined(__WXX11__) #include "wx/x11/dataform.h" #elif defined(__WXMAC__) - #include "wx/osx/dataform.h" + #include "wx/mac/dataform.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/dataform.h" #elif defined(__WXPM__) @@ -91,7 +92,7 @@ public: // the value for default argument to some functions (corresponds to // wxDF_INVALID) -extern WXDLLIMPEXP_CORE const wxDataFormat& wxFormatInvalid; +extern WXDLLEXPORT const wxDataFormat& wxFormatInvalid; // ---------------------------------------------------------------------------- // wxDataObject represents a piece of data which knows which formats it @@ -113,7 +114,7 @@ extern WXDLLIMPEXP_CORE const wxDataFormat& wxFormatInvalid; // to be supported by SetData() or GetDataHere(). // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDataObjectBase +class WXDLLEXPORT wxDataObjectBase { public: enum Direction @@ -170,7 +171,7 @@ public: #elif defined(__WXGTK__) #include "wx/gtk1/dataobj.h" #elif defined(__WXMAC__) - #include "wx/osx/dataobj.h" + #include "wx/mac/dataobj.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/dataobj.h" #elif defined(__WXPM__) @@ -193,7 +194,7 @@ public: // Otherwise, you should use wxDataObjectComposite or wxDataObject directly. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDataObjectSimple : public wxDataObject +class WXDLLEXPORT wxDataObjectSimple : public wxDataObject { public: // ctor takes the format we support, but it can also be set later with @@ -245,7 +246,7 @@ private: // the one and only format we support wxDataFormat m_format; - wxDECLARE_NO_COPY_CLASS(wxDataObjectSimple); + DECLARE_NO_COPY_CLASS(wxDataObjectSimple) }; // ---------------------------------------------------------------------------- @@ -260,7 +261,7 @@ private: WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList); -class WXDLLIMPEXP_CORE wxDataObjectComposite : public wxDataObject +class WXDLLEXPORT wxDataObjectComposite : public wxDataObject { public: // ctor @@ -273,17 +274,11 @@ public: void Add(wxDataObjectSimple *dataObject, bool preferred = false); // Report the format passed to the SetData method. This should be the - // format of the data object within the composite that received data from + // format of the data object within the composite that recieved data from // the clipboard or the DnD operation. You can use this method to find - // out what kind of data object was received. + // out what kind of data object was recieved. wxDataFormat GetReceivedFormat() const; - // Returns the pointer to the object which supports this format or NULL. - // The returned pointer is owned by wxDataObjectComposite and must - // therefore not be destroyed by the caller. - wxDataObjectSimple *GetObject(const wxDataFormat& format, - wxDataObjectBase::Direction dir = Get) const; - // implement base class pure virtuals // ---------------------------------- virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const; @@ -300,6 +295,10 @@ public: virtual size_t GetBufferOffset( const wxDataFormat& format ); #endif +protected: + // returns the pointer to the object which supports this format or NULL + wxDataObjectSimple *GetObject(const wxDataFormat& format) const; + private: // the list of all (simple) data objects whose formats we support wxSimpleDataObjectList m_dataObjects; @@ -310,7 +309,7 @@ private: wxDataFormat m_receivedFormat; - wxDECLARE_NO_COPY_CLASS(wxDataObjectComposite); + DECLARE_NO_COPY_CLASS(wxDataObjectComposite) }; // ============================================================================ @@ -325,54 +324,7 @@ private: // wxTextDataObject contains text data // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - #if defined(__WXGTK20__) - #define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ - #elif defined(__WXMAC__) - #define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ - #endif -#endif // wxUSE_UNICODE - -class WXDLLIMPEXP_CORE wxHTMLDataObject : public wxDataObjectSimple -{ -public: - // ctor: you can specify the text here or in SetText(), or override - // GetText() - wxHTMLDataObject(const wxString& html = wxEmptyString) - : wxDataObjectSimple(wxDF_HTML), - m_html(html) - { - } - - // virtual functions which you may override if you want to provide text on - // demand only - otherwise, the trivial default versions will be used - virtual size_t GetLength() const { return m_html.Len() + 1; } - virtual wxString GetHTML() const { return m_html; } - virtual void SetHTML(const wxString& html) { m_html = html; } - - virtual size_t GetDataSize() const; - virtual bool GetDataHere(void *buf) const; - virtual bool SetData(size_t len, const void *buf); - - // Must provide overloads to avoid hiding them (and warnings about it) - virtual size_t GetDataSize(const wxDataFormat&) const - { - return GetDataSize(); - } - virtual bool GetDataHere(const wxDataFormat&, void *buf) const - { - return GetDataHere(buf); - } - virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) - { - return SetData(len, buf); - } - -private: - wxString m_html; -}; - -class WXDLLIMPEXP_CORE wxTextDataObject : public wxDataObjectSimple +class WXDLLEXPORT wxTextDataObject : public wxDataObjectSimple { public: // ctor: you can specify the text here or in SetText(), or override @@ -399,7 +351,7 @@ public: // ---------------------------------- // some platforms have 2 and not 1 format for text data -#if defined(wxNEEDS_UTF8_FOR_TEXT_DATAOBJ) || defined(wxNEEDS_UTF16_FOR_TEXT_DATAOBJ) +#if wxUSE_UNICODE && (defined(__WXGTK20__) || defined(__WXMAC__)) virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; } virtual void GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir) = Get) const; @@ -411,7 +363,7 @@ public: size_t GetDataSize(const wxDataFormat& format) const; bool GetDataHere(const wxDataFormat& format, void *pBuf) const; bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf); -#else // !wxNEEDS_UTF{8,16}_FOR_TEXT_DATAOBJ +#else virtual size_t GetDataSize() const; virtual bool GetDataHere(void *buf) const; virtual bool SetData(size_t len, const void *buf); @@ -428,19 +380,19 @@ public: { return SetData(len, buf); } -#endif // different wxTextDataObject implementations +#endif private: wxString m_text; - wxDECLARE_NO_COPY_CLASS(wxTextDataObject); + DECLARE_NO_COPY_CLASS(wxTextDataObject) }; // ---------------------------------------------------------------------------- // wxBitmapDataObject contains a bitmap // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapDataObjectBase : public wxDataObjectSimple +class WXDLLEXPORT wxBitmapDataObjectBase : public wxDataObjectSimple { public: // ctor: you can specify the bitmap here or in SetBitmap(), or override @@ -458,7 +410,7 @@ public: protected: wxBitmap m_bitmap; - wxDECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase); + DECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase) }; // ---------------------------------------------------------------------------- @@ -468,7 +420,7 @@ protected: // data from drag and drop operation. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFileDataObjectBase : public wxDataObjectSimple +class WXDLLEXPORT wxFileDataObjectBase : public wxDataObjectSimple { public: // ctor: use AddFile() later to fill the array @@ -480,7 +432,7 @@ public: protected: wxArrayString m_filenames; - wxDECLARE_NO_COPY_CLASS(wxFileDataObjectBase); + DECLARE_NO_COPY_CLASS(wxFileDataObjectBase) }; // ---------------------------------------------------------------------------- @@ -489,7 +441,7 @@ protected: // It is understood that this data can be copied bitwise. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCustomDataObject : public wxDataObjectSimple +class WXDLLEXPORT wxCustomDataObject : public wxDataObjectSimple { public: // if you don't specify the format in the ctor, you can still use @@ -541,7 +493,7 @@ private: size_t m_size; void *m_data; - wxDECLARE_NO_COPY_CLASS(wxCustomDataObject); + DECLARE_NO_COPY_CLASS(wxCustomDataObject) }; // ---------------------------------------------------------------------------- @@ -550,20 +502,19 @@ private: #if defined(__WXMSW__) #include "wx/msw/ole/dataobj2.h" - // wxURLDataObject defined in msw/ole/dataobj2.h -#elif defined(__WXGTK20__) - #include "wx/gtk/dataobj2.h" - // wxURLDataObject defined in msw/ole/dataobj2.h -#else - #if defined(__WXGTK__) + // wxURLDataObject defined in msw/ole/dataobj2.h +#else // !__WXMSW__ + #if defined(__WXGTK20__) + #include "wx/gtk/dataobj2.h" + #elif defined(__WXGTK__) #include "wx/gtk1/dataobj2.h" #elif defined(__WXX11__) #include "wx/x11/dataobj2.h" #elif defined(__WXMOTIF__) #include "wx/motif/dataobj2.h" #elif defined(__WXMAC__) - #include "wx/osx/dataobj2.h" + #include "wx/mac/dataobj2.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/dataobj2.h" #elif defined(__WXPM__) @@ -571,7 +522,7 @@ private: #endif // wxURLDataObject is simply wxTextDataObject with a different name - class WXDLLIMPEXP_CORE wxURLDataObject : public wxTextDataObject + class WXDLLEXPORT wxURLDataObject : public wxTextDataObject { public: wxURLDataObject(const wxString& url = wxEmptyString) @@ -582,7 +533,7 @@ private: wxString GetURL() const { return GetText(); } void SetURL(const wxString& url) { SetText(url); } }; -#endif +#endif // __WXMSW__/!__WXMSW__ #endif // wxUSE_DATAOBJ diff --git a/Source/3rd Party/wx/include/wx/dataview.h b/Source/3rd Party/wx/include/wx/dataview.h deleted file mode 100644 index ba0cafa3b..000000000 --- a/Source/3rd Party/wx/include/wx/dataview.h +++ /dev/null @@ -1,1356 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/dataview.h -// Purpose: wxDataViewCtrl base classes -// Author: Robert Roebling -// Modified by: Bo Yang -// Created: 08.01.06 -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DATAVIEW_H_BASE_ -#define _WX_DATAVIEW_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_DATAVIEWCTRL - -#include "wx/textctrl.h" -#include "wx/headercol.h" -#include "wx/variant.h" -#include "wx/dnd.h" // For wxDragResult declaration only. -#include "wx/dynarray.h" -#include "wx/icon.h" -#include "wx/itemid.h" -#include "wx/weakref.h" -#include "wx/vector.h" -#include "wx/dataobj.h" -#include "wx/withimages.h" - -class WXDLLIMPEXP_FWD_CORE wxImageList; - -#if !(defined(__WXGTK20__) || defined(__WXOSX__)) || defined(__WXUNIVERSAL__) -// #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__) - #define wxHAS_GENERIC_DATAVIEWCTRL -#endif - -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - // this symbol doesn't follow the convention for wxUSE_XXX symbols which - // are normally always defined as either 0 or 1, so its use is deprecated - // and it only exists for backwards compatibility, don't use it any more - // and use wxHAS_GENERIC_DATAVIEWCTRL instead - #define wxUSE_GENERICDATAVIEWCTRL -#endif - -// ---------------------------------------------------------------------------- -// wxDataViewCtrl globals -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_ADV wxDataViewModel; -class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; -class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; -class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; -class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; - -extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[]; - -// ---------------------------------------------------------------------------- -// wxDataViewCtrl flags -// ---------------------------------------------------------------------------- - -// size of a wxDataViewRenderer without contents: -#define wxDVC_DEFAULT_RENDERER_SIZE 20 - -// the default width of new (text) columns: -#define wxDVC_DEFAULT_WIDTH 80 - -// the default width of new toggle columns: -#define wxDVC_TOGGLE_DEFAULT_WIDTH 30 - -// the default minimal width of the columns: -#define wxDVC_DEFAULT_MINWIDTH 30 - -// The default alignment of wxDataViewRenderers is to take -// the alignment from the column it owns. -#define wxDVR_DEFAULT_ALIGNMENT -1 - - -// --------------------------------------------------------- -// wxDataViewItem -// --------------------------------------------------------- - -// Make it a class and not a typedef to allow forward declaring it. -class wxDataViewItem : public wxItemId -{ -public: - wxDataViewItem() : wxItemId() { } - wxEXPLICIT wxDataViewItem(void* pItem) : wxItemId(pItem) { } -}; - -WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); - -// --------------------------------------------------------- -// wxDataViewModelNotifier -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewModelNotifier -{ -public: - wxDataViewModelNotifier() { m_owner = NULL; } - virtual ~wxDataViewModelNotifier() { m_owner = NULL; } - - virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; - virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; - virtual bool ItemChanged( const wxDataViewItem &item ) = 0; - virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); - virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); - virtual bool ItemsChanged( const wxDataViewItemArray &items ); - virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; - virtual bool Cleared() = 0; - - // some platforms, such as GTK+, may need a two step procedure for ::Reset() - virtual bool BeforeReset() { return true; } - virtual bool AfterReset() { return Cleared(); } - - virtual void Resort() = 0; - - void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } - wxDataViewModel *GetOwner() const { return m_owner; } - -private: - wxDataViewModel *m_owner; -}; - - - -// ---------------------------------------------------------------------------- -// wxDataViewItemAttr: a structure containing the visual attributes of an item -// ---------------------------------------------------------------------------- - -// TODO: this should be renamed to wxItemAttr or something general like this - -class WXDLLIMPEXP_ADV wxDataViewItemAttr -{ -public: - // ctors - wxDataViewItemAttr() - { - m_bold = false; - m_italic = false; - } - - // setters - void SetColour(const wxColour& colour) { m_colour = colour; } - void SetBold( bool set ) { m_bold = set; } - void SetItalic( bool set ) { m_italic = set; } - void SetBackgroundColour(const wxColour& colour) { m_bgColour = colour; } - - // accessors - bool HasColour() const { return m_colour.IsOk(); } - const wxColour& GetColour() const { return m_colour; } - - bool HasFont() const { return m_bold || m_italic; } - bool GetBold() const { return m_bold; } - bool GetItalic() const { return m_italic; } - - bool HasBackgroundColour() const { return m_bgColour.IsOk(); } - const wxColour& GetBackgroundColour() const { return m_bgColour; } - - bool IsDefault() const { return !(HasColour() || HasFont() || HasBackgroundColour()); } - - // Return the font based on the given one with this attribute applied to it. - wxFont GetEffectiveFont(const wxFont& font) const; - -private: - wxColour m_colour; - bool m_bold; - bool m_italic; - wxColour m_bgColour; -}; - - -// --------------------------------------------------------- -// wxDataViewModel -// --------------------------------------------------------- - -WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers, - class WXDLLIMPEXP_ADV); - -class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter -{ -public: - wxDataViewModel(); - - virtual unsigned int GetColumnCount() const = 0; - - // return type as reported by wxVariant - virtual wxString GetColumnType( unsigned int col ) const = 0; - - // get value into a wxVariant - virtual void GetValue( wxVariant &variant, - const wxDataViewItem &item, unsigned int col ) const = 0; - - // return true if the given item has a value to display in the given - // column: this is always true except for container items which by default - // only show their label in the first column (but see HasContainerColumns()) - bool HasValue(const wxDataViewItem& item, unsigned col) const - { - return col == 0 || !IsContainer(item) || HasContainerColumns(item); - } - - // usually ValueChanged() should be called after changing the value in the - // model to update the control, ChangeValue() does it on its own while - // SetValue() does not -- so while you will override SetValue(), you should - // be usually calling ChangeValue() - virtual bool SetValue(const wxVariant &variant, - const wxDataViewItem &item, - unsigned int col) = 0; - - bool ChangeValue(const wxVariant& variant, - const wxDataViewItem& item, - unsigned int col) - { - return SetValue(variant, item, col) && ValueChanged(item, col); - } - - // Get text attribute, return false of default attributes should be used - virtual bool GetAttr(const wxDataViewItem &WXUNUSED(item), - unsigned int WXUNUSED(col), - wxDataViewItemAttr &WXUNUSED(attr)) const - { - return false; - } - - // Override this if you want to disable specific items - virtual bool IsEnabled(const wxDataViewItem &WXUNUSED(item), - unsigned int WXUNUSED(col)) const - { - return true; - } - - // define hierarchy - virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; - virtual bool IsContainer( const wxDataViewItem &item ) const = 0; - // Is the container just a header or an item with all columns - virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const - { return false; } - virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; - - // delegated notifiers - bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); - bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); - bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); - bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); - bool ItemChanged( const wxDataViewItem &item ); - bool ItemsChanged( const wxDataViewItemArray &items ); - bool ValueChanged( const wxDataViewItem &item, unsigned int col ); - bool Cleared(); - - // some platforms, such as GTK+, may need a two step procedure for ::Reset() - bool BeforeReset(); - bool AfterReset(); - - - // delegated action - virtual void Resort(); - - void AddNotifier( wxDataViewModelNotifier *notifier ); - void RemoveNotifier( wxDataViewModelNotifier *notifier ); - - // default compare function - virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ) const; - virtual bool HasDefaultCompare() const { return false; } - - // internal - virtual bool IsListModel() const { return false; } - virtual bool IsVirtualListModel() const { return false; } - -protected: - // the user should not delete this class directly: he should use DecRef() instead! - virtual ~wxDataViewModel() { } - - wxDataViewModelNotifiers m_notifiers; -}; - -// ---------------------------------------------------------------------------- -// wxDataViewListModel: a model of a list, i.e. flat data structure without any -// branches/containers, used as base class by wxDataViewIndexListModel and -// wxDataViewVirtualListModel -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewListModel : public wxDataViewModel -{ -public: - // derived classes should override these methods instead of - // {Get,Set}Value() and GetAttr() inherited from the base class - - virtual void GetValueByRow(wxVariant &variant, - unsigned row, unsigned col) const = 0; - - virtual bool SetValueByRow(const wxVariant &variant, - unsigned row, unsigned col) = 0; - - virtual bool - GetAttrByRow(unsigned WXUNUSED(row), unsigned WXUNUSED(col), - wxDataViewItemAttr &WXUNUSED(attr)) const - { - return false; - } - - virtual bool IsEnabledByRow(unsigned int WXUNUSED(row), - unsigned int WXUNUSED(col)) const - { - return true; - } - - - // helper methods provided by list models only - virtual unsigned GetRow( const wxDataViewItem &item ) const = 0; - - // returns the number of rows - virtual unsigned int GetCount() const = 0; - - // implement some base class pure virtual directly - virtual wxDataViewItem - GetParent( const wxDataViewItem & WXUNUSED(item) ) const - { - // items never have valid parent in this model - return wxDataViewItem(); - } - - virtual bool IsContainer( const wxDataViewItem &item ) const - { - // only the invisible (and invalid) root item has children - return !item.IsOk(); - } - - // and implement some others by forwarding them to our own ones - virtual void GetValue( wxVariant &variant, - const wxDataViewItem &item, unsigned int col ) const - { - GetValueByRow(variant, GetRow(item), col); - } - - virtual bool SetValue( const wxVariant &variant, - const wxDataViewItem &item, unsigned int col ) - { - return SetValueByRow( variant, GetRow(item), col ); - } - - virtual bool GetAttr(const wxDataViewItem &item, unsigned int col, - wxDataViewItemAttr &attr) const - { - return GetAttrByRow( GetRow(item), col, attr ); - } - - virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const - { - return IsEnabledByRow( GetRow(item), col ); - } - - - virtual bool IsListModel() const { return true; } -}; - -// --------------------------------------------------------- -// wxDataViewIndexListModel -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewListModel -{ -public: - wxDataViewIndexListModel( unsigned int initial_size = 0 ); - - void RowPrepended(); - void RowInserted( unsigned int before ); - void RowAppended(); - void RowDeleted( unsigned int row ); - void RowsDeleted( const wxArrayInt &rows ); - void RowChanged( unsigned int row ); - void RowValueChanged( unsigned int row, unsigned int col ); - void Reset( unsigned int new_size ); - - // convert to/from row/wxDataViewItem - - virtual unsigned GetRow( const wxDataViewItem &item ) const; - wxDataViewItem GetItem( unsigned int row ) const; - - // implement base methods - virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; - - unsigned int GetCount() const { return m_hash.GetCount(); } - -private: - wxDataViewItemArray m_hash; - unsigned int m_nextFreeID; - bool m_ordered; -}; - -// --------------------------------------------------------- -// wxDataViewVirtualListModel -// --------------------------------------------------------- - -#ifdef __WXMAC__ -// better than nothing -typedef wxDataViewIndexListModel wxDataViewVirtualListModel; -#else - -class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewListModel -{ -public: - wxDataViewVirtualListModel( unsigned int initial_size = 0 ); - - void RowPrepended(); - void RowInserted( unsigned int before ); - void RowAppended(); - void RowDeleted( unsigned int row ); - void RowsDeleted( const wxArrayInt &rows ); - void RowChanged( unsigned int row ); - void RowValueChanged( unsigned int row, unsigned int col ); - void Reset( unsigned int new_size ); - - // convert to/from row/wxDataViewItem - - virtual unsigned GetRow( const wxDataViewItem &item ) const; - wxDataViewItem GetItem( unsigned int row ) const; - - // compare based on index - - virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ) const; - virtual bool HasDefaultCompare() const; - - // implement base methods - virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; - - unsigned int GetCount() const { return m_size; } - - // internal - virtual bool IsVirtualListModel() const { return true; } - -private: - unsigned int m_size; -}; -#endif - -// ---------------------------------------------------------------------------- -// wxDataViewRenderer and related classes -// ---------------------------------------------------------------------------- - -#include "wx/dvrenderers.h" - -// --------------------------------------------------------- -// wxDataViewColumnBase -// --------------------------------------------------------- - -// for compatibility only, do not use -enum wxDataViewColumnFlags -{ - wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE, - wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE, - wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE, - wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN -}; - -class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn -{ -public: - // ctor for the text columns: takes ownership of renderer - wxDataViewColumnBase(wxDataViewRenderer *renderer, - unsigned int model_column) - { - Init(renderer, model_column); - } - - // ctor for the bitmap columns - wxDataViewColumnBase(const wxBitmap& bitmap, - wxDataViewRenderer *renderer, - unsigned int model_column) - : m_bitmap(bitmap) - { - Init(renderer, model_column); - } - - virtual ~wxDataViewColumnBase(); - - // setters: - virtual void SetOwner( wxDataViewCtrl *owner ) - { m_owner = owner; } - - // getters: - unsigned int GetModelColumn() const { return static_cast(m_model_column); } - wxDataViewCtrl *GetOwner() const { return m_owner; } - wxDataViewRenderer* GetRenderer() const { return m_renderer; } - - // implement some of base class pure virtuals (the rest is port-dependent - // and done differently in generic and native versions) - virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } - virtual wxBitmap GetBitmap() const { return m_bitmap; } - -protected: - wxDataViewRenderer *m_renderer; - int m_model_column; - wxBitmap m_bitmap; - wxDataViewCtrl *m_owner; - -private: - // common part of all ctors - void Init(wxDataViewRenderer *renderer, unsigned int model_column); -}; - -// --------------------------------------------------------- -// wxDataViewCtrlBase -// --------------------------------------------------------- - -#define wxDV_SINGLE 0x0000 // for convenience -#define wxDV_MULTIPLE 0x0001 // can select multiple items - -#define wxDV_NO_HEADER 0x0002 // column titles not visible -#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows -#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns - -#define wxDV_ROW_LINES 0x0010 // alternating colour in rows -#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height - -class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl -{ -public: - wxDataViewCtrlBase(); - virtual ~wxDataViewCtrlBase(); - - // model - // ----- - - virtual bool AssociateModel( wxDataViewModel *model ); - wxDataViewModel* GetModel(); - const wxDataViewModel* GetModel() const; - - - // column management - // ----------------- - - wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - - wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, - wxAlignment align = wxALIGN_NOT, - int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE ); - - virtual bool PrependColumn( wxDataViewColumn *col ); - virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); - virtual bool AppendColumn( wxDataViewColumn *col ); - - virtual unsigned int GetColumnCount() const = 0; - virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; - virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; - - virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; - virtual bool ClearColumns() = 0; - - void SetExpanderColumn( wxDataViewColumn *col ) - { m_expander_column = col ; DoSetExpanderColumn(); } - wxDataViewColumn *GetExpanderColumn() const - { return m_expander_column; } - - virtual wxDataViewColumn *GetSortingColumn() const = 0; - - - // items management - // ---------------- - - void SetIndent( int indent ) - { m_indent = indent ; DoSetIndent(); } - int GetIndent() const - { return m_indent; } - - // Current item is the one used by the keyboard navigation, it is the same - // as the (unique) selected item in single selection mode so these - // functions are mostly useful for controls with wxDV_MULTIPLE style. - wxDataViewItem GetCurrentItem() const; - void SetCurrentItem(const wxDataViewItem& item); - - // Currently focused column of the current item or NULL if no column has focus - virtual wxDataViewColumn *GetCurrentColumn() const = 0; - - // Selection: both GetSelection() and GetSelections() can be used for the - // controls both with and without wxDV_MULTIPLE style. For single selection - // controls GetSelections() is not very useful however. And for multi - // selection controls GetSelection() returns an invalid item if more than - // one item is selected. Use GetSelectedItemsCount() or HasSelection() to - // check if any items are selected at all. - virtual int GetSelectedItemsCount() const = 0; - bool HasSelection() const { return GetSelectedItemsCount() != 0; } - wxDataViewItem GetSelection() const; - virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; - virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; - virtual void Select( const wxDataViewItem & item ) = 0; - virtual void Unselect( const wxDataViewItem & item ) = 0; - virtual bool IsSelected( const wxDataViewItem & item ) const = 0; - - virtual void SelectAll() = 0; - virtual void UnselectAll() = 0; - - virtual void Expand( const wxDataViewItem & item ) = 0; - virtual void ExpandAncestors( const wxDataViewItem & item ); - virtual void Collapse( const wxDataViewItem & item ) = 0; - virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; - - virtual void EnsureVisible( const wxDataViewItem & item, - const wxDataViewColumn *column = NULL ) = 0; - virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; - virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; - - virtual bool SetRowHeight( int WXUNUSED(rowHeight) ) { return false; } - - virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) = 0; - - // Use EditItem() instead - wxDEPRECATED( void StartEditor(const wxDataViewItem& item, unsigned int column) ); - -#if wxUSE_DRAG_AND_DROP - virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format)) - { return false; } - virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format)) - { return false; } -#endif // wxUSE_DRAG_AND_DROP - - // define control visual attributes - // -------------------------------- - - virtual wxVisualAttributes GetDefaultAttributes() const - { - return GetClassDefaultAttributes(GetWindowVariant()); - } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) - { - return wxControl::GetCompositeControlsDefaultAttributes(variant); - } - -protected: - virtual void DoSetExpanderColumn() = 0 ; - virtual void DoSetIndent() = 0; - -private: - // Implementation of the public Set/GetCurrentItem() methods which are only - // called in multi selection case (for single selection controls their - // implementation is trivial and is done in the base class itself). - virtual wxDataViewItem DoGetCurrentItem() const = 0; - virtual void DoSetCurrentItem(const wxDataViewItem& item) = 0; - - wxDataViewModel *m_model; - wxDataViewColumn *m_expander_column; - int m_indent ; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) -}; - -// ---------------------------------------------------------------------------- -// wxDataViewEvent - the event class for the wxDataViewCtrl notifications -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent -{ -public: - wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) - : wxNotifyEvent(commandType, winid), - m_item(0), - m_col(-1), - m_model(NULL), - m_value(wxNullVariant), - m_column(NULL), - m_pos(-1,-1), - m_cacheFrom(0), - m_cacheTo(0), - m_editCancelled(false) -#if wxUSE_DRAG_AND_DROP - , m_dataObject(NULL), - m_dataBuffer(NULL), - m_dataSize(0), - m_dragFlags(0), - m_dropEffect(wxDragNone) -#endif - { } - - wxDataViewEvent(const wxDataViewEvent& event) - : wxNotifyEvent(event), - m_item(event.m_item), - m_col(event.m_col), - m_model(event.m_model), - m_value(event.m_value), - m_column(event.m_column), - m_pos(event.m_pos), - m_cacheFrom(event.m_cacheFrom), - m_cacheTo(event.m_cacheTo), - m_editCancelled(event.m_editCancelled) -#if wxUSE_DRAG_AND_DROP - , m_dataObject(event.m_dataObject), - m_dataFormat(event.m_dataFormat), - m_dataBuffer(event.m_dataBuffer), - m_dataSize(event.m_dataSize), - m_dragFlags(event.m_dragFlags), - m_dropEffect(event.m_dropEffect) -#endif - { } - - wxDataViewItem GetItem() const { return m_item; } - void SetItem( const wxDataViewItem &item ) { m_item = item; } - - int GetColumn() const { return m_col; } - void SetColumn( int col ) { m_col = col; } - - wxDataViewModel* GetModel() const { return m_model; } - void SetModel( wxDataViewModel *model ) { m_model = model; } - - const wxVariant &GetValue() const { return m_value; } - void SetValue( const wxVariant &value ) { m_value = value; } - - // for wxEVT_DATAVIEW_ITEM_EDITING_DONE only - bool IsEditCancelled() const { return m_editCancelled; } - void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } - - // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only - void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } - wxDataViewColumn *GetDataViewColumn() const { return m_column; } - - // for wxEVT_DATAVIEW_CONTEXT_MENU only - wxPoint GetPosition() const { return m_pos; } - void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } - - // For wxEVT_DATAVIEW_CACHE_HINT - int GetCacheFrom() const { return m_cacheFrom; } - int GetCacheTo() const { return m_cacheTo; } - void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; } - - -#if wxUSE_DRAG_AND_DROP - // For drag operations - void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } - wxDataObject *GetDataObject() const { return m_dataObject; } - - // For drop operations - void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } - wxDataFormat GetDataFormat() const { return m_dataFormat; } - void SetDataSize( size_t size ) { m_dataSize = size; } - size_t GetDataSize() const { return m_dataSize; } - void SetDataBuffer( void* buf ) { m_dataBuffer = buf;} - void *GetDataBuffer() const { return m_dataBuffer; } - void SetDragFlags( int flags ) { m_dragFlags = flags; } - int GetDragFlags() const { return m_dragFlags; } - void SetDropEffect( wxDragResult effect ) { m_dropEffect = effect; } - wxDragResult GetDropEffect() const { return m_dropEffect; } -#endif // wxUSE_DRAG_AND_DROP - - virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } - -protected: - wxDataViewItem m_item; - int m_col; - wxDataViewModel *m_model; - wxVariant m_value; - wxDataViewColumn *m_column; - wxPoint m_pos; - int m_cacheFrom; - int m_cacheTo; - bool m_editCancelled; - -#if wxUSE_DRAG_AND_DROP - wxDataObject *m_dataObject; - - wxDataFormat m_dataFormat; - void* m_dataBuffer; - size_t m_dataSize; - - int m_dragFlags; - wxDragResult m_dropEffect; -#endif // wxUSE_DRAG_AND_DROP - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) -}; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_CACHE_HINT, wxDataViewEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent ); - -typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); - -#define wxDataViewEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func) - -#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) - -#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) - -#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) -#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) -#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) -#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) -#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) -#define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn) -#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) -#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) -#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) - -#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) - -#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) -#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) -#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) -#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) -#define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn) - -#define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) -#define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) -#define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn) - -// Old and not documented synonym, don't use. -#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn) - -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - #include "wx/generic/dataview.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/dataview.h" -#elif defined(__WXMAC__) - #include "wx/osx/dataview.h" -#else - #error "unknown native wxDataViewCtrl implementation" -#endif - -//----------------------------------------------------------------------------- -// wxDataViewListStore -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewListStoreLine -{ -public: - wxDataViewListStoreLine( wxUIntPtr data = 0 ) - { - m_data = data; - } - - void SetData( wxUIntPtr data ) - { m_data = data; } - wxUIntPtr GetData() const - { return m_data; } - - wxVector m_values; - -private: - wxUIntPtr m_data; -}; - - -class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel -{ -public: - wxDataViewListStore(); - ~wxDataViewListStore(); - - void PrependColumn( const wxString &varianttype ); - void InsertColumn( unsigned int pos, const wxString &varianttype ); - void AppendColumn( const wxString &varianttype ); - - void AppendItem( const wxVector &values, wxUIntPtr data = 0 ); - void PrependItem( const wxVector &values, wxUIntPtr data = 0 ); - void InsertItem( unsigned int row, const wxVector &values, wxUIntPtr data = 0 ); - void DeleteItem( unsigned int pos ); - void DeleteAllItems(); -#if wxABI_VERSION >= 30001 - void ClearColumns(); -#endif - - unsigned int GetItemCount() const; - - void SetItemData( const wxDataViewItem& item, wxUIntPtr data ); - wxUIntPtr GetItemData( const wxDataViewItem& item ) const; - - // override base virtuals - - virtual unsigned int GetColumnCount() const; - - virtual wxString GetColumnType( unsigned int col ) const; - - virtual void GetValueByRow( wxVariant &value, - unsigned int row, unsigned int col ) const; - - virtual bool SetValueByRow( const wxVariant &value, - unsigned int row, unsigned int col ); - - -public: - wxVector m_data; - wxArrayString m_cols; -}; - -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl -{ -public: - wxDataViewListCtrl(); - wxDataViewListCtrl( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, - const wxValidator& validator = wxDefaultValidator ); - ~wxDataViewListCtrl(); - - bool Create( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, - const wxValidator& validator = wxDefaultValidator ); - - wxDataViewListStore *GetStore() - { return (wxDataViewListStore*) GetModel(); } - const wxDataViewListStore *GetStore() const - { return (const wxDataViewListStore*) GetModel(); } - - int ItemToRow(const wxDataViewItem &item) const - { return item.IsOk() ? (int)GetStore()->GetRow(item) : wxNOT_FOUND; } - wxDataViewItem RowToItem(int row) const - { return row == wxNOT_FOUND ? wxDataViewItem() : GetStore()->GetItem(row); } - - int GetSelectedRow() const - { return ItemToRow(GetSelection()); } - void SelectRow(unsigned row) - { Select(RowToItem(row)); } - void UnselectRow(unsigned row) - { Unselect(RowToItem(row)); } - bool IsRowSelected(unsigned row) const - { return IsSelected(RowToItem(row)); } - - bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); - bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); - bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); - - // overridden from base class - virtual bool PrependColumn( wxDataViewColumn *col ); - virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); - virtual bool AppendColumn( wxDataViewColumn *col ); -#if wxABI_VERSION >= 30001 - virtual bool ClearColumns(); -#endif - - wxDataViewColumn *AppendTextColumn( const wxString &label, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendToggleColumn( const wxString &label, - wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, - int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendProgressColumn( const wxString &label, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); - wxDataViewColumn *AppendIconTextColumn( const wxString &label, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); - - void AppendItem( const wxVector &values, wxUIntPtr data = 0 ) - { GetStore()->AppendItem( values, data ); } - void PrependItem( const wxVector &values, wxUIntPtr data = 0 ) - { GetStore()->PrependItem( values, data ); } - void InsertItem( unsigned int row, const wxVector &values, wxUIntPtr data = 0 ) - { GetStore()->InsertItem( row, values, data ); } - void DeleteItem( unsigned row ) - { GetStore()->DeleteItem( row ); } - void DeleteAllItems() - { GetStore()->DeleteAllItems(); } - - void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); - GetStore()->RowValueChanged( row, col); } - void GetValue( wxVariant &value, unsigned int row, unsigned int col ) - { GetStore()->GetValueByRow( value, row, col ); } - - void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); - GetStore()->RowValueChanged( row, col); } - wxString GetTextValue( unsigned int row, unsigned int col ) const - { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } - - void SetToggleValue( bool value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); - GetStore()->RowValueChanged( row, col); } - bool GetToggleValue( unsigned int row, unsigned int col ) const - { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } - - void SetItemData( const wxDataViewItem& item, wxUIntPtr data ) - { GetStore()->SetItemData( item, data ); } - wxUIntPtr GetItemData( const wxDataViewItem& item ) const - { return GetStore()->GetItemData( item ); } - - int GetItemCount() const - { return GetStore()->GetItemCount(); } - - void OnSize( wxSizeEvent &event ); - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl) -}; - -//----------------------------------------------------------------------------- -// wxDataViewTreeStore -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode -{ -public: - wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, - const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); - virtual ~wxDataViewTreeStoreNode(); - - void SetText( const wxString &text ) - { m_text = text; } - wxString GetText() const - { return m_text; } - void SetIcon( const wxIcon &icon ) - { m_icon = icon; } - const wxIcon &GetIcon() const - { return m_icon; } - void SetData( wxClientData *data ) - { if (m_data) delete m_data; m_data = data; } - wxClientData *GetData() const - { return m_data; } - - wxDataViewItem GetItem() const - { return wxDataViewItem( (void*) this ); } - - virtual bool IsContainer() - { return false; } - - wxDataViewTreeStoreNode *GetParent() - { return m_parent; } - -private: - wxDataViewTreeStoreNode *m_parent; - wxString m_text; - wxIcon m_icon; - wxClientData *m_data; -}; - -WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, - class WXDLLIMPEXP_ADV); - -class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode -{ -public: - wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, - const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, - wxClientData *data = NULL ); - virtual ~wxDataViewTreeStoreContainerNode(); - - const wxDataViewTreeStoreNodeList &GetChildren() const - { return m_children; } - wxDataViewTreeStoreNodeList &GetChildren() - { return m_children; } - - void SetExpandedIcon( const wxIcon &icon ) - { m_iconExpanded = icon; } - const wxIcon &GetExpandedIcon() const - { return m_iconExpanded; } - - void SetExpanded( bool expanded = true ) - { m_isExpanded = expanded; } - bool IsExpanded() const - { return m_isExpanded; } - - virtual bool IsContainer() - { return true; } - -private: - wxDataViewTreeStoreNodeList m_children; - wxIcon m_iconExpanded; - bool m_isExpanded; -}; - -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel -{ -public: - wxDataViewTreeStore(); - ~wxDataViewTreeStore(); - - wxDataViewItem AppendItem( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); - wxDataViewItem PrependItem( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); - wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); - - wxDataViewItem PrependContainer( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, - wxClientData *data = NULL ); - wxDataViewItem AppendContainer( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, - wxClientData *data = NULL ); - wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, - wxClientData *data = NULL ); - - wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; - int GetChildCount( const wxDataViewItem& parent ) const; - - void SetItemText( const wxDataViewItem& item, const wxString &text ); - wxString GetItemText( const wxDataViewItem& item ) const; - void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); - const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; - void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); - const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; - void SetItemData( const wxDataViewItem& item, wxClientData *data ); - wxClientData *GetItemData( const wxDataViewItem& item ) const; - - void DeleteItem( const wxDataViewItem& item ); - void DeleteChildren( const wxDataViewItem& item ); - void DeleteAllItems(); - - // implement base methods - - virtual void GetValue( wxVariant &variant, - const wxDataViewItem &item, unsigned int col ) const; - virtual bool SetValue( const wxVariant &variant, - const wxDataViewItem &item, unsigned int col ); - virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; - virtual bool IsContainer( const wxDataViewItem &item ) const; - virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; - - virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ) const; - - virtual bool HasDefaultCompare() const - { return true; } - virtual unsigned int GetColumnCount() const - { return 1; } - virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const - { return wxT("wxDataViewIconText"); } - - wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; - wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; - wxDataViewTreeStoreNode *GetRoot() const { return m_root; } - -public: - wxDataViewTreeStoreNode *m_root; -}; - -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl, - public wxWithImages -{ -public: - wxDataViewTreeCtrl() { } - wxDataViewTreeCtrl(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDV_NO_HEADER | wxDV_ROW_LINES, - const wxValidator& validator = wxDefaultValidator) - { - Create(parent, id, pos, size, style, validator); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDV_NO_HEADER | wxDV_ROW_LINES, - const wxValidator& validator = wxDefaultValidator); - - wxDataViewTreeStore *GetStore() - { return (wxDataViewTreeStore*) GetModel(); } - const wxDataViewTreeStore *GetStore() const - { return (const wxDataViewTreeStore*) GetModel(); } - - bool IsContainer( const wxDataViewItem& item ) const - { return GetStore()->IsContainer(item); } - - wxDataViewItem AppendItem( const wxDataViewItem& parent, - const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); - wxDataViewItem PrependItem( const wxDataViewItem& parent, - const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); - wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); - - wxDataViewItem PrependContainer( const wxDataViewItem& parent, - const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, - wxClientData *data = NULL ); - wxDataViewItem AppendContainer( const wxDataViewItem& parent, - const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, - wxClientData *data = NULL ); - wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, - wxClientData *data = NULL ); - - wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const - { return GetStore()->GetNthChild(parent, pos); } - int GetChildCount( const wxDataViewItem& parent ) const - { return GetStore()->GetChildCount(parent); } - - void SetItemText( const wxDataViewItem& item, const wxString &text ); - wxString GetItemText( const wxDataViewItem& item ) const - { return GetStore()->GetItemText(item); } - void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); - const wxIcon &GetItemIcon( const wxDataViewItem& item ) const - { return GetStore()->GetItemIcon(item); } - void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); - const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const - { return GetStore()->GetItemExpandedIcon(item); } - void SetItemData( const wxDataViewItem& item, wxClientData *data ) - { GetStore()->SetItemData(item,data); } - wxClientData *GetItemData( const wxDataViewItem& item ) const - { return GetStore()->GetItemData(item); } - - void DeleteItem( const wxDataViewItem& item ); - void DeleteChildren( const wxDataViewItem& item ); - void DeleteAllItems(); - - void OnExpanded( wxDataViewEvent &event ); - void OnCollapsed( wxDataViewEvent &event ); - void OnSize( wxSizeEvent &event ); - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) -}; - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED wxEVT_DATAVIEW_SELECTION_CHANGED -#define wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED wxEVT_DATAVIEW_ITEM_ACTIVATED -#define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED wxEVT_DATAVIEW_ITEM_COLLAPSED -#define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED wxEVT_DATAVIEW_ITEM_EXPANDED -#define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING wxEVT_DATAVIEW_ITEM_COLLAPSING -#define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING wxEVT_DATAVIEW_ITEM_EXPANDING -#define wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING wxEVT_DATAVIEW_ITEM_START_EDITING -#define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED wxEVT_DATAVIEW_ITEM_EDITING_STARTED -#define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE wxEVT_DATAVIEW_ITEM_EDITING_DONE -#define wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED wxEVT_DATAVIEW_ITEM_VALUE_CHANGED -#define wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU wxEVT_DATAVIEW_ITEM_CONTEXT_MENU -#define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_CLICK -#define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK -#define wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED wxEVT_DATAVIEW_COLUMN_SORTED -#define wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED wxEVT_DATAVIEW_COLUMN_REORDERED -#define wxEVT_COMMAND_DATAVIEW_CACHE_HINT wxEVT_DATAVIEW_CACHE_HINT -#define wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG wxEVT_DATAVIEW_ITEM_BEGIN_DRAG -#define wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE -#define wxEVT_COMMAND_DATAVIEW_ITEM_DROP wxEVT_DATAVIEW_ITEM_DROP - -#endif // wxUSE_DATAVIEWCTRL - -#endif - // _WX_DATAVIEW_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/datectrl.h b/Source/3rd Party/wx/include/wx/datectrl.h deleted file mode 100644 index 6fa4367c0..000000000 --- a/Source/3rd Party/wx/include/wx/datectrl.h +++ /dev/null @@ -1,113 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/datectrl.h -// Purpose: implements wxDatePickerCtrl -// Author: Vadim Zeitlin -// Modified by: -// Created: 2005-01-09 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DATECTRL_H_ -#define _WX_DATECTRL_H_ - -#include "wx/defs.h" - -#if wxUSE_DATEPICKCTRL - -#include "wx/datetimectrl.h" // the base class - -#define wxDatePickerCtrlNameStr wxT("datectrl") - -// wxDatePickerCtrl styles -enum -{ - // default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN - wxDP_DEFAULT = 0, - - // a spin control-like date picker (not supported in generic version) - wxDP_SPIN = 1, - - // a combobox-like date picker (not supported in mac version) - wxDP_DROPDOWN = 2, - - // always show century in the default date display (otherwise it depends on - // the system date format which may include the century or not) - wxDP_SHOWCENTURY = 4, - - // allow not having any valid date in the control (by default it always has - // some date, today initially if no valid date specified in ctor) - wxDP_ALLOWNONE = 8 -}; - -// ---------------------------------------------------------------------------- -// wxDatePickerCtrl: allow the user to enter the date -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxDateTimePickerCtrl -{ -public: - /* - The derived classes should implement ctor and Create() method with the - following signature: - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr); - */ - - /* - We inherit the methods to set/get the date from the base class. - - virtual void SetValue(const wxDateTime& dt) = 0; - virtual wxDateTime GetValue() const = 0; - */ - - // And add methods to set/get the allowed valid range for the dates. If - // either/both of them are invalid, there is no corresponding limit and if - // neither is set, GetRange() returns false. - virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0; - virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0; -}; - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/datectrl.h" - - #define wxHAS_NATIVE_DATEPICKCTRL -#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__) - #include "wx/osx/datectrl.h" - - #define wxHAS_NATIVE_DATEPICKCTRL -#else - #include "wx/generic/datectrl.h" - - class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlGeneric - { - public: - wxDatePickerCtrl() { } - wxDatePickerCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr) - : wxDatePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name) - { - } - - private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl) - }; -#endif - -#endif // wxUSE_DATEPICKCTRL - -#endif // _WX_DATECTRL_H_ - diff --git a/Source/3rd Party/wx/include/wx/dateevt.h b/Source/3rd Party/wx/include/wx/dateevt.h deleted file mode 100644 index 4131ab383..000000000 --- a/Source/3rd Party/wx/include/wx/dateevt.h +++ /dev/null @@ -1,64 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/dateevt.h -// Purpose: declares wxDateEvent class -// Author: Vadim Zeitlin -// Modified by: -// Created: 2005-01-10 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DATEEVT_H_ -#define _WX_DATEEVT_H_ - -#include "wx/event.h" -#include "wx/datetime.h" -#include "wx/window.h" - -// ---------------------------------------------------------------------------- -// wxDateEvent: used by wxCalendarCtrl, wxDatePickerCtrl and wxTimePickerCtrl. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDateEvent : public wxCommandEvent -{ -public: - wxDateEvent() { } - wxDateEvent(wxWindow *win, const wxDateTime& dt, wxEventType type) - : wxCommandEvent(type, win->GetId()), - m_date(dt) - { - SetEventObject(win); - } - - const wxDateTime& GetDate() const { return m_date; } - void SetDate(const wxDateTime &date) { m_date = date; } - - // default copy ctor, assignment operator and dtor are ok - virtual wxEvent *Clone() const { return new wxDateEvent(*this); } - -private: - wxDateTime m_date; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDateEvent) -}; - -// ---------------------------------------------------------------------------- -// event types and macros for handling them -// ---------------------------------------------------------------------------- - -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_DATE_CHANGED, wxDateEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_TIME_CHANGED, wxDateEvent); - -typedef void (wxEvtHandler::*wxDateEventFunction)(wxDateEvent&); - -#define wxDateEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxDateEventFunction, func) - -#define EVT_DATE_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_DATE_CHANGED, id, wxDateEventHandler(fn)) - -#define EVT_TIME_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_TIME_CHANGED, id, wxDateEventHandler(fn)) - -#endif // _WX_DATEEVT_H_ - diff --git a/Source/3rd Party/wx/include/wx/datetime.h b/Source/3rd Party/wx/include/wx/datetime.h index 12a41e632..f527b9d42 100644 --- a/Source/3rd Party/wx/include/wx/datetime.h +++ b/Source/3rd Party/wx/include/wx/datetime.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 10.02.99 +// RCS-ID: $Id: datetime.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,23 +17,19 @@ #if wxUSE_DATETIME -#ifdef __WXWINCE__ - #include "wx/msw/wince/time.h" +#ifndef __WXWINCE__ +#include #else - #include -#endif // OS +#include "wx/msw/wince/time.h" +#endif #include // for INT_MIN #include "wx/longlong.h" -#include "wx/anystr.h" class WXDLLIMPEXP_FWD_BASE wxDateTime; class WXDLLIMPEXP_FWD_BASE wxTimeSpan; class WXDLLIMPEXP_FWD_BASE wxDateSpan; -#ifdef __WINDOWS__ -struct _SYSTEMTIME; -#endif #include "wx/dynarray.h" @@ -40,8 +37,11 @@ struct _SYSTEMTIME; // set this to the corresponding value in seconds 1/1/1970 has on your // systems c-runtime -#define WX_TIME_BASE_OFFSET 0 - +#if defined(__WXMAC__) && !defined(__DARWIN__) && __MSL__ < 0x6000 + #define WX_TIME_BASE_OFFSET ( 2082844800L + 126144000L ) +#else + #define WX_TIME_BASE_OFFSET 0 +#endif /* * TODO * @@ -52,6 +52,27 @@ struct _SYSTEMTIME; * 5. wxDateTimeHolidayAuthority for Easter and other christian feasts */ +/* Two wrapper functions for thread safety */ +#ifdef HAVE_LOCALTIME_R +#define wxLocaltime_r localtime_r +#else +WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*); +#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__) + // On Windows, localtime _is_ threadsafe! +#warning using pseudo thread-safe wrapper for localtime to emulate localtime_r +#endif +#endif + +#ifdef HAVE_GMTIME_R +#define wxGmtime_r gmtime_r +#else +WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*); +#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__) + // On Windows, gmtime _is_ threadsafe! +#warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r +#endif +#endif + /* The three (main) classes declared in this header represent: @@ -106,25 +127,12 @@ struct _SYSTEMTIME; // wxInvalidDateTime) class WXDLLIMPEXP_FWD_BASE wxDateTime; -extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultDateTimeFormat[]; -extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultTimeSpanFormat[]; +extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat; +extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat; extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime; #define wxInvalidDateTime wxDefaultDateTime - -// ---------------------------------------------------------------------------- -// conditional compilation -// ---------------------------------------------------------------------------- - -// if configure detected strftime(), we have it too -#ifdef HAVE_STRFTIME - #define wxHAS_STRFTIME -// suppose everyone else has strftime except Win CE unless VC8 is used -#elif !defined(__WXWINCE__) || defined(__VISUALC8__) - #define wxHAS_STRFTIME -#endif - // ---------------------------------------------------------------------------- // wxDateTime represents an absolute moment in the time // ---------------------------------------------------------------------------- @@ -151,7 +159,7 @@ public: // the time in the current time zone Local, - // zones from GMT (= Greenwich Mean Time): they're guaranteed to be + // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be // consequent numbers, so writing something like `GMT0 + offset' is // safe if abs(offset) <= 12 @@ -221,6 +229,124 @@ public: // TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?) }; + // these values only are used to identify the different dates of + // adoption of the Gregorian calendar (see IsGregorian()) + // + // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)" + // by Claus Tøndering, http://www.pip.dknet.dk/~c-t/calendar.html + // except for the comments "we take". + // + // Symbol "->" should be read as "was followed by" in the comments + // which follow. + enum GregorianAdoption + { + Gr_Unknown, // no data for this country or it's too uncertain to use + Gr_Standard, // on the day 0 of Gregorian calendar: 15 Oct 1582 + + Gr_Alaska, // Oct 1867 when Alaska became part of the USA + Gr_Albania, // Dec 1912 + + Gr_Austria = Gr_Unknown, // Different regions on different dates + Gr_Austria_Brixen, // 5 Oct 1583 -> 16 Oct 1583 + Gr_Austria_Salzburg = Gr_Austria_Brixen, + Gr_Austria_Tyrol = Gr_Austria_Brixen, + Gr_Austria_Carinthia, // 14 Dec 1583 -> 25 Dec 1583 + Gr_Austria_Styria = Gr_Austria_Carinthia, + + Gr_Belgium, // Then part of the Netherlands + + Gr_Bulgaria = Gr_Unknown, // Unknown precisely (from 1915 to 1920) + Gr_Bulgaria_1, // 18 Mar 1916 -> 1 Apr 1916 + Gr_Bulgaria_2, // 31 Mar 1916 -> 14 Apr 1916 + Gr_Bulgaria_3, // 3 Sep 1920 -> 17 Sep 1920 + + Gr_Canada = Gr_Unknown, // Different regions followed the changes in + // Great Britain or France + + Gr_China = Gr_Unknown, // Different authorities say: + Gr_China_1, // 18 Dec 1911 -> 1 Jan 1912 + Gr_China_2, // 18 Dec 1928 -> 1 Jan 1929 + + Gr_Czechoslovakia, // (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584 + Gr_Denmark, // (including Norway) 18 Feb 1700 -> 1 Mar 1700 + Gr_Egypt, // 1875 + Gr_Estonia, // 1918 + Gr_Finland, // Then part of Sweden + + Gr_France, // 9 Dec 1582 -> 20 Dec 1582 + Gr_France_Alsace, // 4 Feb 1682 -> 16 Feb 1682 + Gr_France_Lorraine, // 16 Feb 1760 -> 28 Feb 1760 + Gr_France_Strasbourg, // February 1682 + + Gr_Germany = Gr_Unknown, // Different states on different dates: + Gr_Germany_Catholic, // 1583-1585 (we take 1584) + Gr_Germany_Prussia, // 22 Aug 1610 -> 2 Sep 1610 + Gr_Germany_Protestant, // 18 Feb 1700 -> 1 Mar 1700 + + Gr_GreatBritain, // 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)') + + Gr_Greece, // 9 Mar 1924 -> 23 Mar 1924 + Gr_Hungary, // 21 Oct 1587 -> 1 Nov 1587 + Gr_Ireland = Gr_GreatBritain, + Gr_Italy = Gr_Standard, + + Gr_Japan = Gr_Unknown, // Different authorities say: + Gr_Japan_1, // 19 Dec 1872 -> 1 Jan 1873 + Gr_Japan_2, // 19 Dec 1892 -> 1 Jan 1893 + Gr_Japan_3, // 18 Dec 1918 -> 1 Jan 1919 + + Gr_Latvia, // 1915-1918 (we take 1915) + Gr_Lithuania, // 1915 + Gr_Luxemburg, // 14 Dec 1582 -> 25 Dec 1582 + Gr_Netherlands = Gr_Belgium, // (including Belgium) 1 Jan 1583 + + // this is too weird to take into account: the Gregorian calendar was + // introduced twice in Groningen, first time 28 Feb 1583 was followed + // by 11 Mar 1583, then it has gone back to Julian in the summer of + // 1584 and then 13 Dec 1700 -> 12 Jan 1701 - which is + // the date we take here + Gr_Netherlands_Groningen, // 13 Dec 1700 -> 12 Jan 1701 + Gr_Netherlands_Gelderland, // 30 Jun 1700 -> 12 Jul 1700 + Gr_Netherlands_Utrecht, // (and Overijssel) 30 Nov 1700->12 Dec 1700 + Gr_Netherlands_Friesland, // (and Drenthe) 31 Dec 1700 -> 12 Jan 1701 + + Gr_Norway = Gr_Denmark, // Then part of Denmark + Gr_Poland = Gr_Standard, + Gr_Portugal = Gr_Standard, + Gr_Romania, // 31 Mar 1919 -> 14 Apr 1919 + Gr_Russia, // 31 Jan 1918 -> 14 Feb 1918 + Gr_Scotland = Gr_GreatBritain, + Gr_Spain = Gr_Standard, + + // Sweden has a curious history. Sweden decided to make a gradual + // change from the Julian to the Gregorian calendar. By dropping every + // leap year from 1700 through 1740 the eleven superfluous days would + // be omitted and from 1 Mar 1740 they would be in sync with the + // Gregorian calendar. (But in the meantime they would be in sync with + // nobody!) + // + // So 1700 (which should have been a leap year in the Julian calendar) + // was not a leap year in Sweden. However, by mistake 1704 and 1708 + // became leap years. This left Sweden out of synchronisation with + // both the Julian and the Gregorian world, so they decided to go back + // to the Julian calendar. In order to do this, they inserted an extra + // day in 1712, making that year a double leap year! So in 1712, + // February had 30 days in Sweden. + // + // Later, in 1753, Sweden changed to the Gregorian calendar by + // dropping 11 days like everyone else. + Gr_Sweden = Gr_Finland, // 17 Feb 1753 -> 1 Mar 1753 + + Gr_Switzerland = Gr_Unknown,// Different cantons used different dates + Gr_Switzerland_Catholic, // 1583, 1584 or 1597 (we take 1584) + Gr_Switzerland_Protestant, // 31 Dec 1700 -> 12 Jan 1701 + + Gr_Turkey, // 1 Jan 1927 + Gr_USA = Gr_GreatBritain, + Gr_Wales = Gr_GreatBritain, + Gr_Yugoslavia // 1919 + }; + // the country parameter is used so far for calculating the start and // the end of DST period and for deciding whether the date is a work // day or not @@ -289,22 +415,26 @@ public: // helper classes // ------------------------------------------------------------------------ - // a class representing a time zone: basically, this is just an offset + // a class representing a time zone: basicly, this is just an offset // (in seconds) from GMT class WXDLLIMPEXP_BASE TimeZone { public: TimeZone(TZ tz); - // create time zone object with the given offset - TimeZone(long offset = 0) { m_offset = offset; } + // don't use this ctor, it doesn't work for negative offsets (but can't + // be removed or changed to avoid breaking ABI in 2.8) + TimeZone(wxDateTime_t offset = 0) { m_offset = offset; } +#if wxABI_VERSION >= 20808 + // create time zone object with the given offset static TimeZone Make(long offset) { TimeZone tz; tz.m_offset = offset; return tz; } +#endif // wxABI 2.8.8+ long GetOffset() const { return m_offset; } @@ -322,9 +452,7 @@ public: // instead of modifying the member fields directly! struct WXDLLIMPEXP_BASE Tm { - wxDateTime_t msec, sec, min, hour, - mday, // Day of the month in 1..31 range. - yday; // Day of the year in 0..365 range. + wxDateTime_t msec, sec, min, hour, mday; Month mon; int year; @@ -359,10 +487,9 @@ public: // the timezone we correspond to TimeZone m_tz; - // This value can only be accessed via GetWeekDay() and not directly - // because it's not always computed when creating this object and may - // need to be calculated on demand. - wxDateTime_t wday; + // these values can't be accessed directly because they're not always + // computed and we calculate them on demand + wxDateTime_t wday, yday; }; // static methods @@ -405,25 +532,16 @@ public: int year = Inv_Year, Calendar cal = Gregorian); - // get the full (default) or abbreviated month name in the current // locale, returns empty string on error static wxString GetMonthName(Month month, NameFlags flags = Name_Full); - // get the standard English full (default) or abbreviated month name - static wxString GetEnglishMonthName(Month month, - NameFlags flags = Name_Full); - // get the full (default) or abbreviated weekday name in the current // locale, returns empty string on error static wxString GetWeekDayName(WeekDay weekday, NameFlags flags = Name_Full); - // get the standard English full (default) or abbreviated weekday name - static wxString GetEnglishWeekDayName(WeekDay weekday, - NameFlags flags = Name_Full); - // get the AM and PM strings in the current locale (may be empty) static void GetAmPmStrings(wxString *am, wxString *pm); @@ -459,7 +577,7 @@ public: // ------------------------------------------------------------------------ // default ctor does not initialize the object, use Set()! - wxDateTime() { m_time = wxLongLong(wxINT32_MIN, 0); } + wxDateTime() { m_time = wxLongLong((wxInt32)UINT_MAX, UINT_MAX); } // from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970) #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) @@ -487,12 +605,6 @@ public: wxDateTime_t minute = 0, wxDateTime_t second = 0, wxDateTime_t millisec = 0); -#ifdef __WINDOWS__ - wxDateTime(const struct _SYSTEMTIME& st) - { - SetFromMSWSysTime(st); - } -#endif // default copy ctor ok @@ -540,9 +652,11 @@ public: // resets time to 00:00:00, doesn't change the date wxDateTime& ResetTime(); +#if wxABI_VERSION >= 20802 // get the date part of this object only, i.e. the object which has the // same date as this one but time of 00:00:00 wxDateTime GetDateOnly() const; +#endif // wxABI 2.8.1+ // the following functions don't change the values of the other // fields, i.e. SetMinute() won't change either hour or seconds value @@ -574,7 +688,7 @@ public: // default assignment operator is ok // calendar calculations (functions which set the date only leave the time - // unchanged, e.g. don't explicitly zero it): SetXXX() functions modify the + // unchanged, e.g. don't explictly zero it): SetXXX() functions modify the // object itself, GetXXX() ones return a new object. // ------------------------------------------------------------------------ @@ -592,7 +706,7 @@ public: wxDateTime& SetToPrevWeekDay(WeekDay weekday); inline wxDateTime GetPrevWeekDay(WeekDay weekday) const; - // set to Nth occurrence of given weekday in the given month of the + // set to Nth occurence of given weekday in the given month of the // given year (time is set to 0), return true on success and false on // failure. n may be positive (1..5) or negative to count from the end // of the month (see helper function SetToLastWeekDay()) @@ -790,6 +904,14 @@ public: // because the holidays are different in different countries bool IsWorkDay(Country country = Country_Default) const; + // is this date later than Gregorian calendar introduction for the + // given country (see enum GregorianAdoption)? + // + // NB: this function shouldn't be considered as absolute authority in + // the matter. Besides, for some countries the exact date of + // adoption of the Gregorian calendar is simply unknown. + bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const; + // dos date and time format // ------------------------------------------------------------------------ @@ -799,20 +921,6 @@ public: // pack the date in DOS format unsigned long GetAsDOS() const; - // SYSTEMTIME format - // ------------------------------------------------------------------------ -#ifdef __WINDOWS__ - // convert SYSTEMTIME to wxDateTime - wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME& st); - - // convert wxDateTime to SYSTEMTIME - void GetAsMSWSysTime(struct _SYSTEMTIME* st) const; - - // same as above but only take date part into account, time is always zero - wxDateTime& SetFromMSWSysDate(const struct _SYSTEMTIME& st); - void GetAsMSWSysDate(struct _SYSTEMTIME* st) const; -#endif // __WINDOWS__ - // comparison (see also functions below for operator versions) // ------------------------------------------------------------------------ @@ -936,195 +1044,46 @@ public: inline wxTimeSpan Subtract(const wxDateTime& dt) const; inline wxTimeSpan operator-(const wxDateTime& dt2) const; - wxDateSpan DiffAsDateSpan(const wxDateTime& dt) const; - - // conversion to/from text + // conversion to/from text: all conversions from text return the pointer to + // the next character following the date specification (i.e. the one where + // the scan had to stop) or NULL on failure. // ------------------------------------------------------------------------ - // all conversions functions return true to indicate whether parsing - // succeeded or failed and fill in the provided end iterator, which must - // not be NULL, with the location of the character where the parsing - // stopped (this will be end() of the passed string if everything was - // parsed) - // parse a string in RFC 822 format (found e.g. in mail headers and // having the form "Wed, 10 Feb 1999 19:07:07 +0100") - bool ParseRfc822Date(const wxString& date, - wxString::const_iterator *end); - + const wxChar *ParseRfc822Date(const wxChar* date); // parse a date/time in the given format (see strptime(3)), fill in // the missing (in the string) fields with the values of dateDef (by // default, they will not change if they had valid values or will // default to Today() otherwise) - bool ParseFormat(const wxString& date, - const wxString& format, - const wxDateTime& dateDef, - wxString::const_iterator *end); - - bool ParseFormat(const wxString& date, - const wxString& format, - wxString::const_iterator *end) - { - return ParseFormat(date, format, wxDefaultDateTime, end); - } - - bool ParseFormat(const wxString& date, - wxString::const_iterator *end) - { - return ParseFormat(date, wxDefaultDateTimeFormat, wxDefaultDateTime, end); - } - - // parse a string containing date, time or both in ISO 8601 format - // - // notice that these functions are new in wx 3.0 and so we don't - // provide compatibility overloads for them - bool ParseISODate(const wxString& date) - { - wxString::const_iterator end; - return ParseFormat(date, wxS("%Y-%m-%d"), &end) && end == date.end(); - } - - bool ParseISOTime(const wxString& time) - { - wxString::const_iterator end; - return ParseFormat(time, wxS("%H:%M:%S"), &end) && end == time.end(); - } - - bool ParseISOCombined(const wxString& datetime, char sep = 'T') - { - wxString::const_iterator end; - const wxString fmt = wxS("%Y-%m-%d") + wxString(sep) + wxS("%H:%M:%S"); - return ParseFormat(datetime, fmt, &end) && end == datetime.end(); - } - + const wxChar *ParseFormat(const wxChar *date, + const wxChar *format = wxDefaultDateTimeFormat, + const wxDateTime& dateDef = wxDefaultDateTime); // parse a string containing the date/time in "free" format, this // function will try to make an educated guess at the string contents - bool ParseDateTime(const wxString& datetime, - wxString::const_iterator *end); - + const wxChar *ParseDateTime(const wxChar *datetime); // parse a string containing the date only in "free" format (less // flexible than ParseDateTime) - bool ParseDate(const wxString& date, - wxString::const_iterator *end); - + const wxChar *ParseDate(const wxChar *date); // parse a string containing the time only in "free" format - bool ParseTime(const wxString& time, - wxString::const_iterator *end); - + const wxChar *ParseTime(const wxChar *time); // this function accepts strftime()-like format string (default // argument corresponds to the preferred date and time representation // for the current locale) and returns the string containing the // resulting text representation - wxString Format(const wxString& format = wxDefaultDateTimeFormat, + wxString Format(const wxChar *format = wxDefaultDateTimeFormat, const TimeZone& tz = Local) const; // preferred date representation for the current locale - wxString FormatDate() const { return Format(wxS("%x")); } + wxString FormatDate() const { return Format(wxT("%x")); } // preferred time representation for the current locale - wxString FormatTime() const { return Format(wxS("%X")); } + wxString FormatTime() const { return Format(wxT("%X")); } // returns the string representing the date in ISO 8601 format // (YYYY-MM-DD) - wxString FormatISODate() const { return Format(wxS("%Y-%m-%d")); } + wxString FormatISODate() const { return Format(wxT("%Y-%m-%d")); } // returns the string representing the time in ISO 8601 format // (HH:MM:SS) - wxString FormatISOTime() const { return Format(wxS("%H:%M:%S")); } - // return the combined date time representation in ISO 8601 format; the - // separator character should be 'T' according to the standard but it - // can also be useful to set it to ' ' - wxString FormatISOCombined(char sep = 'T') const - { return FormatISODate() + sep + FormatISOTime(); } - - - // backwards compatible versions of the parsing functions: they return an - // object representing the next character following the date specification - // (i.e. the one where the scan had to stop) or a special NULL-like object - // on failure - // - // they're not deprecated because a lot of existing code uses them and - // there is no particular harm in keeping them but you should still prefer - // the versions above in the new code - wxAnyStrPtr ParseRfc822Date(const wxString& date) - { - wxString::const_iterator end; - return ParseRfc822Date(date, &end) ? wxAnyStrPtr(date, end) - : wxAnyStrPtr(); - } - - wxAnyStrPtr ParseFormat(const wxString& date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime) - { - wxString::const_iterator end; - return ParseFormat(date, format, dateDef, &end) ? wxAnyStrPtr(date, end) - : wxAnyStrPtr(); - } - - wxAnyStrPtr ParseDateTime(const wxString& datetime) - { - wxString::const_iterator end; - return ParseDateTime(datetime, &end) ? wxAnyStrPtr(datetime, end) - : wxAnyStrPtr(); - } - - wxAnyStrPtr ParseDate(const wxString& date) - { - wxString::const_iterator end; - return ParseDate(date, &end) ? wxAnyStrPtr(date, end) - : wxAnyStrPtr(); - } - - wxAnyStrPtr ParseTime(const wxString& time) - { - wxString::const_iterator end; - return ParseTime(time, &end) ? wxAnyStrPtr(time, end) - : wxAnyStrPtr(); - } - - // In addition to wxAnyStrPtr versions above we also must provide the - // overloads for C strings as we must return a pointer into the original - // string and not inside a temporary wxString which would have been created - // if the overloads above were used. - // - // And then we also have to provide the overloads for wxCStrData, as usual. - // Unfortunately those ones can't return anything as we don't have any - // sufficiently long-lived wxAnyStrPtr to return from them: any temporary - // strings it would point to would be destroyed when this function returns - // making it impossible to dereference the return value. So we just don't - // return anything from here which at least allows to keep compatibility - // with the code not testing the return value. Other uses of this method - // need to be converted to use one of the new bool-returning overloads - // above. - void ParseRfc822Date(const wxCStrData& date) - { ParseRfc822Date(wxString(date)); } - const char* ParseRfc822Date(const char* date); - const wchar_t* ParseRfc822Date(const wchar_t* date); - - void ParseFormat(const wxCStrData& date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime) - { ParseFormat(wxString(date), format, dateDef); } - const char* ParseFormat(const char* date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime); - const wchar_t* ParseFormat(const wchar_t* date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime); - - void ParseDateTime(const wxCStrData& datetime) - { ParseDateTime(wxString(datetime)); } - const char* ParseDateTime(const char* datetime); - const wchar_t* ParseDateTime(const wchar_t* datetime); - - void ParseDate(const wxCStrData& date) - { ParseDate(wxString(date)); } - const char* ParseDate(const char* date); - const wchar_t* ParseDate(const wchar_t* date); - - void ParseTime(const wxCStrData& time) - { ParseTime(wxString(time)); } - const char* ParseTime(const char* time); - const wchar_t* ParseTime(const wchar_t* time); - + wxString FormatISOTime() const { return Format(wxT("%H:%M:%S")); } // implementation // ------------------------------------------------------------------------ @@ -1136,7 +1095,7 @@ public: inline wxLongLong GetValue() const; // a helper function to get the current time_t - static time_t GetTimeNow() { return time(NULL); } + static time_t GetTimeNow() { return time((time_t *)NULL); } // another one to get the current time broken down static struct tm *GetTmNow() @@ -1293,7 +1252,7 @@ public: // compare two timestamps: works with the absolute values, i.e. 1 // hour is shorter than -2 hours. Also, it will return false if the // timespans are equal in absolute value. - bool IsShorterThan(const wxTimeSpan& t) const; + bool IsShorterThan(const wxTimeSpan& t) const { return !IsLongerThan(t); } inline bool operator<(const wxTimeSpan &ts) const { @@ -1350,7 +1309,7 @@ public: // resulting text representation. Notice that only some of format // specifiers valid for wxDateTime are valid for wxTimeSpan: hours, // minutes and seconds make sense, but not "PM/AM" string for example. - wxString Format(const wxString& format = wxDefaultTimeSpanFormat) const; + wxString Format(const wxChar *format = wxDefaultTimeSpanFormat) const; // implementation // ------------------------------------------------------------------------ @@ -1452,8 +1411,6 @@ public: int GetYears() const { return m_years; } // get number of months int GetMonths() const { return m_months; } - // returns 12*GetYears() + GetMonths() - int GetTotalMonths() const { return 12*m_years + m_months; } // get number of weeks int GetWeeks() const { return m_weeks; } // get number of days @@ -1630,9 +1587,7 @@ protected: inline bool wxDateTime::IsInStdRange() const { - // currently we don't know what is the real type of time_t so prefer to err - // on the safe side and limit it to 32 bit values which is safe everywhere - return m_time >= 0l && (m_time / TIME_T_FACTOR) < wxINT32_MAX; + return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX; } /* static */ @@ -1654,16 +1609,9 @@ inline wxDateTime wxDateTime::Today() #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) inline wxDateTime& wxDateTime::Set(time_t timet) { - if ( timet == (time_t)-1 ) - { - m_time = wxInvalidDateTime.m_time; - } - else - { - // assign first to avoid long multiplication overflow! - m_time = timet - WX_TIME_BASE_OFFSET; - m_time *= TIME_T_FACTOR; - } + // assign first to avoid long multiplication overflow! + m_time = timet - WX_TIME_BASE_OFFSET ; + m_time *= TIME_T_FACTOR; return *this; } @@ -1999,9 +1947,9 @@ inline wxLongLong wxTimeSpan::GetSeconds() const inline int wxTimeSpan::GetMinutes() const { - // For compatibility, this method (and the other accessors) return int, - // even though GetLo() actually returns unsigned long with greater range. - return static_cast((GetSeconds() / 60l).GetLo()); + // explicit cast to int suppresses a warning with CodeWarrior and possibly + // others (changing the return type to long from int is impossible in 2.8) + return (int)((GetSeconds() / 60l).GetLo()); } inline int wxTimeSpan::GetHours() const @@ -2074,11 +2022,6 @@ inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const return GetValue().Abs() > ts.GetValue().Abs(); } -inline bool wxTimeSpan::IsShorterThan(const wxTimeSpan& ts) const -{ - return GetValue().Abs() < ts.GetValue().Abs(); -} - // ---------------------------------------------------------------------------- // wxDateSpan // ---------------------------------------------------------------------------- diff --git a/Source/3rd Party/wx/include/wx/datetimectrl.h b/Source/3rd Party/wx/include/wx/datetimectrl.h deleted file mode 100644 index 30f23dfff..000000000 --- a/Source/3rd Party/wx/include/wx/datetimectrl.h +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/timectrl.h -// Purpose: Declaration of wxDateTimePickerCtrl class. -// Author: Vadim Zeitlin -// Created: 2011-09-22 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DATETIME_CTRL_H_ -#define _WX_DATETIME_CTRL_H_ - -#include "wx/defs.h" - -#if wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL - -#define wxNEEDS_DATETIMEPICKCTRL - -#include "wx/control.h" // the base class - -#include "wx/datetime.h" - -// ---------------------------------------------------------------------------- -// wxDateTimePickerCtrl: Private common base class of wx{Date,Time}PickerCtrl. -// ---------------------------------------------------------------------------- - -// This class is an implementation detail and should not be used directly, only -// use the documented API of wxDateTimePickerCtrl and wxTimePickerCtrl. -class WXDLLIMPEXP_ADV wxDateTimePickerCtrlBase : public wxControl -{ -public: - // Set/get the date or time (in the latter case, time part is ignored). - virtual void SetValue(const wxDateTime& dt) = 0; - virtual wxDateTime GetValue() const = 0; -}; - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/datetimectrl.h" -#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__) - #include "wx/osx/datetimectrl.h" -#else - typedef wxDateTimePickerCtrlBase wxDateTimePickerCtrl; -#endif - -#endif // wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL - -#endif // _WX_DATETIME_CTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/datstrm.h b/Source/3rd Party/wx/include/wx/datstrm.h index e96134deb..b6d00e43e 100644 --- a/Source/3rd Party/wx/include/wx/datstrm.h +++ b/Source/3rd Party/wx/include/wx/datstrm.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/datstrm.h +// Name: datstrm.h // Purpose: Data stream classes // Author: Guilhem Lavaux // Modified by: Mickael Gilabert // Created: 28/06/1998 +// RCS-ID: $Id: datstrm.h 38576 2006-04-05 16:10:08Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,64 +18,15 @@ #if wxUSE_STREAMS -// Common wxDataInputStream and wxDataOutputStream parameters. -class WXDLLIMPEXP_BASE wxDataStreamBase +class WXDLLIMPEXP_BASE wxDataInputStream { public: - void BigEndianOrdered(bool be_order) { m_be_order = be_order; } - - // By default we use extended precision (80 bit) format for both float and - // doubles. Call this function to switch to alternative representation in - // which IEEE 754 single precision (32 bits) is used for floats and double - // precision (64 bits) is used for doubles. - void UseBasicPrecisions() - { -#if wxUSE_APPLE_IEEE - m_useExtendedPrecision = false; -#endif // wxUSE_APPLE_IEEE - } - - // UseExtendedPrecision() is not very useful as it corresponds to the - // default value, only call it in your code if you want the compilation - // fail with the error when using wxWidgets library compiled without - // extended precision support. -#if wxUSE_APPLE_IEEE - void UseExtendedPrecision() - { - m_useExtendedPrecision = true; - } -#endif // wxUSE_APPLE_IEEE - #if wxUSE_UNICODE - void SetConv( const wxMBConv &conv ); - wxMBConv *GetConv() const { return m_conv; } + wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvAuto()); +#else + wxDataInputStream(wxInputStream& s); #endif - -protected: - // Ctor and dtor are both protected, this class is never used directly but - // only by its derived classes. - wxDataStreamBase(const wxMBConv& conv); - ~wxDataStreamBase(); - - - bool m_be_order; - -#if wxUSE_APPLE_IEEE - bool m_useExtendedPrecision; -#endif // wxUSE_APPLE_IEEE - -#if wxUSE_UNICODE - wxMBConv *m_conv; -#endif - - wxDECLARE_NO_COPY_CLASS(wxDataStreamBase); -}; - - -class WXDLLIMPEXP_BASE wxDataInputStream : public wxDataStreamBase -{ -public: - wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8); + ~wxDataInputStream(); bool IsOk() { return m_input->IsOk(); } @@ -88,7 +40,6 @@ public: wxUint16 Read16(); wxUint8 Read8(); double ReadDouble(); - float ReadFloat(); wxString ReadString(); #if wxHAS_INT64 @@ -107,7 +58,6 @@ public: void Read16(wxUint16 *buffer, size_t size); void Read8(wxUint8 *buffer, size_t size); void ReadDouble(double *buffer, size_t size); - void ReadFloat(float *buffer, size_t size); wxDataInputStream& operator>>(wxString& s); wxDataInputStream& operator>>(wxInt8& c); @@ -124,19 +74,30 @@ public: wxDataInputStream& operator>>(wxULongLong& i); wxDataInputStream& operator>>(wxLongLong& i); #endif - wxDataInputStream& operator>>(double& d); + wxDataInputStream& operator>>(double& i); wxDataInputStream& operator>>(float& f); + void BigEndianOrdered(bool be_order) { m_be_order = be_order; } + protected: wxInputStream *m_input; + bool m_be_order; +#if wxUSE_UNICODE + wxMBConv *m_conv; +#endif - wxDECLARE_NO_COPY_CLASS(wxDataInputStream); + DECLARE_NO_COPY_CLASS(wxDataInputStream) }; -class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase +class WXDLLIMPEXP_BASE wxDataOutputStream { public: - wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8); +#if wxUSE_UNICODE + wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvAuto()); +#else + wxDataOutputStream(wxOutputStream& s); +#endif + ~wxDataOutputStream(); bool IsOk() { return m_output->IsOk(); } @@ -152,7 +113,6 @@ public: void Write16(wxUint16 i); void Write8(wxUint8 i); void WriteDouble(double d); - void WriteFloat(float f); void WriteString(const wxString& string); #if wxHAS_INT64 @@ -171,8 +131,8 @@ public: void Write16(const wxUint16 *buffer, size_t size); void Write8(const wxUint8 *buffer, size_t size); void WriteDouble(const double *buffer, size_t size); - void WriteFloat(const float *buffer, size_t size); + wxDataOutputStream& operator<<(const wxChar *string); wxDataOutputStream& operator<<(const wxString& string); wxDataOutputStream& operator<<(wxInt8 c); wxDataOutputStream& operator<<(wxInt16 i); @@ -188,13 +148,19 @@ public: wxDataOutputStream& operator<<(const wxULongLong &i); wxDataOutputStream& operator<<(const wxLongLong &i); #endif - wxDataOutputStream& operator<<(double d); + wxDataOutputStream& operator<<(double f); wxDataOutputStream& operator<<(float f); + void BigEndianOrdered(bool be_order) { m_be_order = be_order; } + protected: wxOutputStream *m_output; + bool m_be_order; +#if wxUSE_UNICODE + wxMBConv *m_conv; +#endif - wxDECLARE_NO_COPY_CLASS(wxDataOutputStream); + DECLARE_NO_COPY_CLASS(wxDataOutputStream) }; #endif diff --git a/Source/3rd Party/wx/include/wx/dc.h b/Source/3rd Party/wx/include/wx/dc.h index 5806f0dfc..8448d8005 100644 --- a/Source/3rd Party/wx/include/wx/dc.h +++ b/Source/3rd Party/wx/include/wx/dc.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05/25/99 +// RCS-ID: $Id: dc.h 59768 2009-03-23 12:35:12Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -25,137 +26,25 @@ #include "wx/brush.h" #include "wx/pen.h" #include "wx/palette.h" +#include "wx/list.h" // we use wxList in inline functions #include "wx/dynarray.h" #include "wx/math.h" -#include "wx/image.h" -#include "wx/region.h" -#include "wx/affinematrix2d.h" - -#define wxUSE_NEW_DC 1 class WXDLLIMPEXP_FWD_CORE wxDC; -class WXDLLIMPEXP_FWD_CORE wxClientDC; -class WXDLLIMPEXP_FWD_CORE wxPaintDC; -class WXDLLIMPEXP_FWD_CORE wxWindowDC; -class WXDLLIMPEXP_FWD_CORE wxScreenDC; -class WXDLLIMPEXP_FWD_CORE wxMemoryDC; -class WXDLLIMPEXP_FWD_CORE wxPrinterDC; -class WXDLLIMPEXP_FWD_CORE wxPrintData; +class WXDLLIMPEXP_FWD_CORE wxDCBase; -#if wxUSE_GRAPHICS_CONTEXT -class WXDLLIMPEXP_FWD_CORE wxGraphicsContext; -#endif - -// Logical ops -enum wxRasterOperationMode -{ - wxCLEAR, // 0 - wxXOR, // src XOR dst - wxINVERT, // NOT dst - wxOR_REVERSE, // src OR (NOT dst) - wxAND_REVERSE, // src AND (NOT dst) - wxCOPY, // src - wxAND, // src AND dst - wxAND_INVERT, // (NOT src) AND dst - wxNO_OP, // dst - wxNOR, // (NOT src) AND (NOT dst) - wxEQUIV, // (NOT src) XOR dst - wxSRC_INVERT, // (NOT src) - wxOR_INVERT, // (NOT src) OR dst - wxNAND, // (NOT src) OR (NOT dst) - wxOR, // src OR dst - wxSET // 1 -#if WXWIN_COMPATIBILITY_2_8 - ,wxROP_BLACK = wxCLEAR, - wxBLIT_BLACKNESS = wxCLEAR, - wxROP_XORPEN = wxXOR, - wxBLIT_SRCINVERT = wxXOR, - wxROP_NOT = wxINVERT, - wxBLIT_DSTINVERT = wxINVERT, - wxROP_MERGEPENNOT = wxOR_REVERSE, - wxBLIT_00DD0228 = wxOR_REVERSE, - wxROP_MASKPENNOT = wxAND_REVERSE, - wxBLIT_SRCERASE = wxAND_REVERSE, - wxROP_COPYPEN = wxCOPY, - wxBLIT_SRCCOPY = wxCOPY, - wxROP_MASKPEN = wxAND, - wxBLIT_SRCAND = wxAND, - wxROP_MASKNOTPEN = wxAND_INVERT, - wxBLIT_00220326 = wxAND_INVERT, - wxROP_NOP = wxNO_OP, - wxBLIT_00AA0029 = wxNO_OP, - wxROP_NOTMERGEPEN = wxNOR, - wxBLIT_NOTSRCERASE = wxNOR, - wxROP_NOTXORPEN = wxEQUIV, - wxBLIT_00990066 = wxEQUIV, - wxROP_NOTCOPYPEN = wxSRC_INVERT, - wxBLIT_NOTSCRCOPY = wxSRC_INVERT, - wxROP_MERGENOTPEN = wxOR_INVERT, - wxBLIT_MERGEPAINT = wxOR_INVERT, - wxROP_NOTMASKPEN = wxNAND, - wxBLIT_007700E6 = wxNAND, - wxROP_MERGEPEN = wxOR, - wxBLIT_SRCPAINT = wxOR, - wxROP_WHITE = wxSET, - wxBLIT_WHITENESS = wxSET -#endif //WXWIN_COMPATIBILITY_2_8 -}; - -// Flood styles -enum wxFloodFillStyle -{ - wxFLOOD_SURFACE = 1, - wxFLOOD_BORDER -}; - -// Mapping modes -enum wxMappingMode -{ - wxMM_TEXT = 1, - wxMM_METRIC, - wxMM_LOMETRIC, - wxMM_TWIPS, - wxMM_POINTS -}; - -// Description of text characteristics. -struct wxFontMetrics -{ - wxFontMetrics() - { - height = - ascent = - descent = - internalLeading = - externalLeading = - averageWidth = 0; - } - - int height, // Total character height. - ascent, // Part of the height above the baseline. - descent, // Part of the height below the baseline. - internalLeading, // Intra-line spacing. - externalLeading, // Inter-line spacing. - averageWidth; // Average font width, a.k.a. "x-width". -}; - -#if WXWIN_COMPATIBILITY_2_8 - -//----------------------------------------------------------------------------- -// wxDrawObject helper class -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxDrawObject +class WXDLLEXPORT wxDrawObject { public: - wxDEPRECATED_CONSTRUCTOR(wxDrawObject)() + + wxDrawObject() : m_isBBoxValid(false) , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) { } virtual ~wxDrawObject() { } - virtual void Draw(wxDC&) const { } + virtual void Draw(wxDCBase&) const { } virtual void CalcBoundingBox(wxCoord x, wxCoord y) { @@ -201,116 +90,297 @@ protected: wxCoord m_minX, m_minY, m_maxX, m_maxY; }; -#endif // WXWIN_COMPATIBILITY_2_8 +// --------------------------------------------------------------------------- +// global variables +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// wxDC is the device context - object on which any drawing is done +// --------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// wxDCFactory -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxDCImpl; - -class WXDLLIMPEXP_CORE wxDCFactory +class WXDLLEXPORT wxDCBase : public wxObject { public: - wxDCFactory() {} - virtual ~wxDCFactory() {} - - virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; - virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; - virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0; - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; - virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0; -#if wxUSE_PRINTING_ARCHITECTURE - virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; -#endif - - static void Set(wxDCFactory *factory); - static wxDCFactory *Get(); - -private: - static wxDCFactory *m_factory; -}; - -//----------------------------------------------------------------------------- -// wxNativeDCFactory -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory -{ -public: - wxNativeDCFactory() {} - - virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); - virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ); - virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ); - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); - virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); - virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ); -#if wxUSE_PRINTING_ARCHITECTURE - virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); -#endif -}; - -//----------------------------------------------------------------------------- -// wxDCImpl -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxDCImpl: public wxObject -{ -public: - wxDCImpl( wxDC *owner ); - virtual ~wxDCImpl(); - - wxDC *GetOwner() const { return m_owner; } - - wxWindow* GetWindow() const { return m_window; } - - virtual bool IsOk() const { return m_ok; } - - // query capabilities - - virtual bool CanDrawBitmap() const = 0; - virtual bool CanGetTextExtent() const = 0; - - // get Cairo context - virtual void* GetCairoContext() const + wxDCBase() + : m_colour(wxColourDisplay()) + , m_ok(true) + , m_clipping(false) + , m_isInteractive(0) + , m_isBBoxValid(false) + , m_logicalOriginX(0), m_logicalOriginY(0) + , m_deviceOriginX(0), m_deviceOriginY(0) + , m_logicalScaleX(1.0), m_logicalScaleY(1.0) + , m_userScaleX(1.0), m_userScaleY(1.0) + , m_scaleX(1.0), m_scaleY(1.0) + , m_signX(1), m_signY(1) + , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) + , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0) + , m_logicalFunction(wxCOPY) + , m_backgroundMode(wxTRANSPARENT) + , m_mappingMode(wxMM_TEXT) + , m_pen() + , m_brush() + , m_backgroundBrush(*wxTRANSPARENT_BRUSH) + , m_textForegroundColour(*wxBLACK) + , m_textBackgroundColour(*wxWHITE) + , m_font() +#if wxUSE_PALETTE + , m_palette() + , m_hasCustomPalette(false) +#endif // wxUSE_PALETTE { - return NULL; + ResetBoundingBox(); + ResetClipping(); } - virtual void* GetHandle() const { return NULL; } + virtual ~wxDCBase() { } + + // graphic primitives + // ------------------ + + virtual void DrawObject(wxDrawObject* drawobject) + { + drawobject->Draw(*this); + CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); + CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); + } + + bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, + int style = wxFLOOD_SURFACE) + { return DoFloodFill(x, y, col, style); } + bool FloodFill(const wxPoint& pt, const wxColour& col, + int style = wxFLOOD_SURFACE) + { return DoFloodFill(pt.x, pt.y, col, style); } + + // fill the area specified by rect with a radial gradient, starting from + // initialColour in the centre of the cercle and fading to destColour. + void GradientFillConcentric(const wxRect& rect, + const wxColour& initialColour, + const wxColour& destColour) + { GradientFillConcentric(rect, initialColour, destColour, + wxPoint(rect.GetWidth() / 2, + rect.GetHeight() / 2)); } + + void GradientFillConcentric(const wxRect& rect, + const wxColour& initialColour, + const wxColour& destColour, + const wxPoint& circleCenter) + { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } + + // fill the area specified by rect with a linear gradient + void GradientFillLinear(const wxRect& rect, + const wxColour& initialColour, + const wxColour& destColour, + wxDirection nDirection = wxEAST) + { DoGradientFillLinear(rect, initialColour, destColour, nDirection); } + + bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const + { return DoGetPixel(x, y, col); } + bool GetPixel(const wxPoint& pt, wxColour *col) const + { return DoGetPixel(pt.x, pt.y, col); } + + void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) + { DoDrawLine(x1, y1, x2, y2); } + void DrawLine(const wxPoint& pt1, const wxPoint& pt2) + { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } + + void CrossHair(wxCoord x, wxCoord y) + { DoCrossHair(x, y); } + void CrossHair(const wxPoint& pt) + { DoCrossHair(pt.x, pt.y); } + + void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc) + { DoDrawArc(x1, y1, x2, y2, xc, yc); } + void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) + { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } + + void DrawCheckMark(wxCoord x, wxCoord y, + wxCoord width, wxCoord height) + { DoDrawCheckMark(x, y, width, height); } + void DrawCheckMark(const wxRect& rect) + { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } + + void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, + double sa, double ea) + { DoDrawEllipticArc(x, y, w, h, sa, ea); } + void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, + double sa, double ea) + { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } + + void DrawPoint(wxCoord x, wxCoord y) + { DoDrawPoint(x, y); } + void DrawPoint(const wxPoint& pt) + { DoDrawPoint(pt.x, pt.y); } + + void DrawLines(int n, wxPoint points[], + wxCoord xoffset = 0, wxCoord yoffset = 0) + { DoDrawLines(n, points, xoffset, yoffset); } + void DrawLines(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0); + + void DrawPolygon(int n, wxPoint points[], + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE) + { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } + + void DrawPolygon(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE); + + void DrawPolyPolygon(int n, int count[], wxPoint points[], + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE) + { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } + + void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) + { DoDrawRectangle(x, y, width, height); } + void DrawRectangle(const wxPoint& pt, const wxSize& sz) + { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } + void DrawRectangle(const wxRect& rect) + { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } + + void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, + double radius) + { DoDrawRoundedRectangle(x, y, width, height, radius); } + void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, + double radius) + { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } + void DrawRoundedRectangle(const wxRect& r, double radius) + { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } + + void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) + { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } + void DrawCircle(const wxPoint& pt, wxCoord radius) + { DrawCircle(pt.x, pt.y, radius); } + + void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) + { DoDrawEllipse(x, y, width, height); } + void DrawEllipse(const wxPoint& pt, const wxSize& sz) + { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } + void DrawEllipse(const wxRect& rect) + { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } + + void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) + { DoDrawIcon(icon, x, y); } + void DrawIcon(const wxIcon& icon, const wxPoint& pt) + { DoDrawIcon(icon, pt.x, pt.y); } + + void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, + bool useMask = false) + { DoDrawBitmap(bmp, x, y, useMask); } + void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, + bool useMask = false) + { DoDrawBitmap(bmp, pt.x, pt.y, useMask); } + + void DrawText(const wxString& text, wxCoord x, wxCoord y) + { DoDrawText(text, x, y); } + void DrawText(const wxString& text, const wxPoint& pt) + { DoDrawText(text, pt.x, pt.y); } + + void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) + { DoDrawRotatedText(text, x, y, angle); } + void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) + { DoDrawRotatedText(text, pt.x, pt.y, angle); } + + // this version puts both optional bitmap and the text into the given + // rectangle and aligns is as specified by alignment parameter; it also + // will emphasize the character with the given index if it is != -1 and + // return the bounding rectangle if required + virtual void DrawLabel(const wxString& text, + const wxBitmap& image, + const wxRect& rect, + int alignment = wxALIGN_LEFT | wxALIGN_TOP, + int indexAccel = -1, + wxRect *rectBounding = NULL); + + void DrawLabel(const wxString& text, const wxRect& rect, + int alignment = wxALIGN_LEFT | wxALIGN_TOP, + int indexAccel = -1) + { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } + + bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) + { + return DoBlit(xdest, ydest, width, height, + source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); + } + bool Blit(const wxPoint& destPt, const wxSize& sz, + wxDC *source, const wxPoint& srcPt, + int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) + { + return DoBlit(destPt.x, destPt.y, sz.x, sz.y, + source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); + } - // query dimension, colour deps, resolution - - virtual void DoGetSize(int *width, int *height) const = 0; - void GetSize(int *width, int *height) const + wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const { - DoGetSize(width, height); - return ; + return DoGetAsBitmap(subrect); } - wxSize GetSize() const - { - int w, h; - DoGetSize(&w, &h); - return wxSize(w, h); - } +#if wxUSE_SPLINES + // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) + void DrawSpline(wxCoord x1, wxCoord y1, + wxCoord x2, wxCoord y2, + wxCoord x3, wxCoord y3); + void DrawSpline(int n, wxPoint points[]); - virtual void DoGetSizeMM(int* width, int* height) const = 0; + void DrawSpline(wxList *points) { DoDrawSpline(points); } +#endif // wxUSE_SPLINES - virtual int GetDepth() const = 0; - virtual wxSize GetPPI() const = 0; + // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE +#ifdef __WXWINCE__ + //! Generic method to draw ellipses, circles and arcs with current pen and brush. + /*! \param x Upper left corner of bounding box. + * \param y Upper left corner of bounding box. + * \param w Width of bounding box. + * \param h Height of bounding box. + * \param sa Starting angle of arc + * (counterclockwise, start at 3 o'clock, 360 is full circle). + * \param ea Ending angle of arc. + * \param angle Rotation angle, the Arc will be rotated after + * calculating begin and end. + */ + void DrawEllipticArcRot( wxCoord x, wxCoord y, + wxCoord width, wxCoord height, + double sa = 0, double ea = 0, double angle = 0 ) + { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } - // Right-To-Left (RTL) modes + void DrawEllipticArcRot( const wxPoint& pt, + const wxSize& sz, + double sa = 0, double ea = 0, double angle = 0 ) + { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } - virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } - virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; } + void DrawEllipticArcRot( const wxRect& rect, + double sa = 0, double ea = 0, double angle = 0 ) + { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } - // page and document + virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, + wxCoord w, wxCoord h, + double sa = 0, double ea = 0, double angle = 0 ); + + //! Rotates points around center. + /*! This is a quite straight method, it calculates in pixels + * and so it produces rounding errors. + * \param points The points inside will be rotated. + * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). + * \param center Center of rotation. + */ + void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) ); + + // used by DrawEllipticArcRot + // Careful: wxList gets filled with points you have to delete later. + void CalculateEllipticPoints( wxList* points, + wxCoord xStart, wxCoord yStart, + wxCoord w, wxCoord h, + double sa, double ea ); +#endif + + // global DC operations + // -------------------- + + virtual void Clear() = 0; virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } virtual void EndDoc() { } @@ -318,10 +388,206 @@ public: virtual void StartPage() { } virtual void EndPage() { } - // flushing the content of this dc immediately eg onto screen - virtual void Flush() { } +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( void BeginDrawing() ); + wxDEPRECATED( void EndDrawing() ); +#endif // WXWIN_COMPATIBILITY_2_6 + + + // set objects to use for drawing + // ------------------------------ + + virtual void SetFont(const wxFont& font) = 0; + virtual void SetPen(const wxPen& pen) = 0; + virtual void SetBrush(const wxBrush& brush) = 0; + virtual void SetBackground(const wxBrush& brush) = 0; + virtual void SetBackgroundMode(int mode) = 0; +#if wxUSE_PALETTE + virtual void SetPalette(const wxPalette& palette) = 0; +#endif // wxUSE_PALETTE + + // clipping region + // --------------- + + void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) + { DoSetClippingRegion(x, y, width, height); } + void SetClippingRegion(const wxPoint& pt, const wxSize& sz) + { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } + void SetClippingRegion(const wxRect& rect) + { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } + void SetClippingRegion(const wxRegion& region) + { DoSetClippingRegionAsRegion(region); } + +#if wxABI_VERSION >= 20811 + void SetDeviceClippingRegion(const wxRegion& region) + { DoSetClippingRegionAsRegion(region); } +#endif + + virtual void DestroyClippingRegion() { ResetClipping(); } + + void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const + { DoGetClippingBox(x, y, w, h); } + void GetClippingBox(wxRect& rect) const + { + DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); + } + + // text extent + // ----------- + + virtual wxCoord GetCharHeight() const = 0; + virtual wxCoord GetCharWidth() const = 0; + + // only works for single line strings + void GetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + wxFont *theFont = NULL) const + { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } + + wxSize GetTextExtent(const wxString& string) const + { + wxCoord w, h; + DoGetTextExtent(string, &w, &h); + return wxSize(w, h); + } + + // works for single as well as multi-line strings + virtual void GetMultiLineTextExtent(const wxString& string, + wxCoord *width, + wxCoord *height, + wxCoord *heightLine = NULL, + wxFont *font = NULL) const; + + wxSize GetMultiLineTextExtent(const wxString& string) const + { + wxCoord w, h; + GetMultiLineTextExtent(string, &w, &h); + return wxSize(w, h); + } + + // Measure cumulative width of text after each character + bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const + { return DoGetPartialTextExtents(text, widths); } + + // size and resolution + // ------------------- + + // in device units + void GetSize(int *width, int *height) const + { DoGetSize(width, height); } + wxSize GetSize() const + { + int w, h; + DoGetSize(&w, &h); + + return wxSize(w, h); + } + + // in mm + void GetSizeMM(int* width, int* height) const + { DoGetSizeMM(width, height); } + wxSize GetSizeMM() const + { + int w, h; + DoGetSizeMM(&w, &h); + + return wxSize(w, h); + } + + // coordinates conversions + // ----------------------- + + // This group of functions does actual conversion of the input, as you'd + // expect. + wxCoord DeviceToLogicalX(wxCoord x) const; + wxCoord DeviceToLogicalY(wxCoord y) const; + wxCoord DeviceToLogicalXRel(wxCoord x) const; + wxCoord DeviceToLogicalYRel(wxCoord y) const; + wxCoord LogicalToDeviceX(wxCoord x) const; + wxCoord LogicalToDeviceY(wxCoord y) const; + wxCoord LogicalToDeviceXRel(wxCoord x) const; + wxCoord LogicalToDeviceYRel(wxCoord y) const; + + // query DC capabilities + // --------------------- + + virtual bool CanDrawBitmap() const = 0; + virtual bool CanGetTextExtent() const = 0; + + // colour depth + virtual int GetDepth() const = 0; + + // Resolution in Pixels per inch + virtual wxSize GetPPI() const = 0; + + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const { return m_ok; } + + // accessors and setters + // --------------------- + + virtual int GetBackgroundMode() const { return m_backgroundMode; } + virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } + virtual const wxBrush& GetBrush() const { return m_brush; } + virtual const wxFont& GetFont() const { return m_font; } + virtual const wxPen& GetPen() const { return m_pen; } + + virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } + virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } + virtual void SetTextForeground(const wxColour& colour) + { m_textForegroundColour = colour; } + virtual void SetTextBackground(const wxColour& colour) + { m_textBackgroundColour = colour; } + + virtual int GetMapMode() const { return m_mappingMode; } + virtual void SetMapMode(int mode) = 0; + + virtual void GetUserScale(double *x, double *y) const + { + if ( x ) *x = m_userScaleX; + if ( y ) *y = m_userScaleY; + } + virtual void SetUserScale(double x, double y) = 0; + + virtual void GetLogicalScale(double *x, double *y) + { + if ( x ) *x = m_logicalScaleX; + if ( y ) *y = m_logicalScaleY; + } + virtual void SetLogicalScale(double x, double y) + { + m_logicalScaleX = x; + m_logicalScaleY = y; + } + + void GetLogicalOrigin(wxCoord *x, wxCoord *y) const + { DoGetLogicalOrigin(x, y); } + wxPoint GetLogicalOrigin() const + { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } + virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0; + + void GetDeviceOrigin(wxCoord *x, wxCoord *y) const + { DoGetDeviceOrigin(x, y); } + wxPoint GetDeviceOrigin() const + { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } + virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0; + + virtual void ComputeScaleAndOrigin() {} + + virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0; + + virtual int GetLogicalFunction() const { return m_logicalFunction; } + virtual void SetLogicalFunction(int function) = 0; + +#if WXWIN_COMPATIBILITY_2_4 + virtual void SetOptimization(bool WXUNUSED(opt)) { } + virtual bool GetOptimization() { return false; } +#endif // bounding box + // ------------ virtual void CalcBoundingBox(wxCoord x, wxCoord y) { @@ -342,6 +608,7 @@ public: m_maxY = y; } } + void ResetBoundingBox() { m_isBBoxValid = false; @@ -349,198 +616,79 @@ public: m_minX = m_maxX = m_minY = m_maxY = 0; } + // Get the final bounding box of the PostScript or Metafile picture. wxCoord MinX() const { return m_minX; } wxCoord MaxX() const { return m_maxX; } wxCoord MinY() const { return m_minY; } wxCoord MaxY() const { return m_maxY; } - // setters and getters + // misc old functions + // ------------------ - virtual void SetFont(const wxFont& font) = 0; - virtual const wxFont& GetFont() const { return m_font; } - - virtual void SetPen(const wxPen& pen) = 0; - virtual const wxPen& GetPen() const { return m_pen; } - - virtual void SetBrush(const wxBrush& brush) = 0; - virtual const wxBrush& GetBrush() const { return m_brush; } - - virtual void SetBackground(const wxBrush& brush) = 0; - virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } - - virtual void SetBackgroundMode(int mode) = 0; - virtual int GetBackgroundMode() const { return m_backgroundMode; } - - virtual void SetTextForeground(const wxColour& colour) - { m_textForegroundColour = colour; } - virtual const wxColour& GetTextForeground() const - { return m_textForegroundColour; } - - virtual void SetTextBackground(const wxColour& colour) - { m_textBackgroundColour = colour; } - virtual const wxColour& GetTextBackground() const - { return m_textBackgroundColour; } - -#if wxUSE_PALETTE - virtual void SetPalette(const wxPalette& palette) = 0; -#endif // wxUSE_PALETTE - - // inherit the DC attributes (font and colours) from the given window - // - // this is called automatically when a window, client or paint DC is - // created - virtual void InheritAttributes(wxWindow *win); - - - // logical functions - - virtual void SetLogicalFunction(wxRasterOperationMode function) = 0; - virtual wxRasterOperationMode GetLogicalFunction() const - { return m_logicalFunction; } - - // text measurement - - virtual wxCoord GetCharHeight() const = 0; - virtual wxCoord GetCharWidth() const = 0; - - // The derived classes should really override DoGetFontMetrics() to return - // the correct values in the future but for now provide a default - // implementation in terms of DoGetTextExtent() to avoid breaking the - // compilation of all other ports as wxMSW is the only one to implement it. - virtual void DoGetFontMetrics(int *height, - int *ascent, - int *descent, - int *internalLeading, - int *externalLeading, - int *averageWidth) const; - - virtual void DoGetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const = 0; - virtual void GetMultiLineTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *heightLine = NULL, - const wxFont *font = NULL) const; - virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; - - // clearing - - virtual void Clear() = 0; - - // clipping - - // Note that this pure virtual method has an implementation that updates - // the values returned by DoGetClippingBox() and so can be called from the - // derived class overridden version if it makes sense (i.e. if the clipping - // box coordinates are not already updated in some other way). - virtual void DoSetClippingRegion(wxCoord x, wxCoord y, - wxCoord w, wxCoord h) = 0; - - // NB: this function works with device coordinates, not the logical ones! - virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0; - - virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, - wxCoord *w, wxCoord *h) const + // for compatibility with the old code when wxCoord was long everywhere + void GetTextExtent(const wxString& string, + long *x, long *y, + long *descent = NULL, + long *externalLeading = NULL, + wxFont *theFont = NULL) const { + wxCoord x2, y2, descent2, externalLeading2; + DoGetTextExtent(string, &x2, &y2, + &descent2, &externalLeading2, + theFont); if ( x ) - *x = m_clipX1; + *x = x2; if ( y ) - *y = m_clipY1; - if ( w ) - *w = m_clipX2 - m_clipX1; - if ( h ) - *h = m_clipY2 - m_clipY1; + *y = y2; + if ( descent ) + *descent = descent2; + if ( externalLeading ) + *externalLeading = externalLeading2; } - virtual void DestroyClippingRegion() { ResetClipping(); } - - - // coordinates conversions and transforms - - virtual wxCoord DeviceToLogicalX(wxCoord x) const; - virtual wxCoord DeviceToLogicalY(wxCoord y) const; - virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; - virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; - virtual wxCoord LogicalToDeviceX(wxCoord x) const; - virtual wxCoord LogicalToDeviceY(wxCoord y) const; - virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; - virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; - - virtual void SetMapMode(wxMappingMode mode); - virtual wxMappingMode GetMapMode() const { return m_mappingMode; } - - virtual void SetUserScale(double x, double y); - virtual void GetUserScale(double *x, double *y) const + void GetLogicalOrigin(long *x, long *y) const { - if ( x ) *x = m_userScaleX; - if ( y ) *y = m_userScaleY; + wxCoord x2, y2; + DoGetLogicalOrigin(&x2, &y2); + if ( x ) + *x = x2; + if ( y ) + *y = y2; } - virtual void SetLogicalScale(double x, double y); - virtual void GetLogicalScale(double *x, double *y) const + void GetDeviceOrigin(long *x, long *y) const { - if ( x ) *x = m_logicalScaleX; - if ( y ) *y = m_logicalScaleY; + wxCoord x2, y2; + DoGetDeviceOrigin(&x2, &y2); + if ( x ) + *x = x2; + if ( y ) + *y = y2; } - - virtual void SetLogicalOrigin(wxCoord x, wxCoord y); - virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const + void GetClippingBox(long *x, long *y, long *w, long *h) const { - if ( x ) *x = m_logicalOriginX; - if ( y ) *y = m_logicalOriginY; + wxCoord xx,yy,ww,hh; + DoGetClippingBox(&xx, &yy, &ww, &hh); + if (x) *x = xx; + if (y) *y = yy; + if (w) *w = ww; + if (h) *h = hh; } - virtual void SetDeviceOrigin(wxCoord x, wxCoord y); - virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const - { - if ( x ) *x = m_deviceOriginX; - if ( y ) *y = m_deviceOriginY; - } + // RTL related functions + // --------------------- -#if wxUSE_DC_TRANSFORM_MATRIX - // Transform matrix support is not available in most ports right now - // (currently only wxMSW provides it) so do nothing in these methods by - // default. - virtual bool CanUseTransformMatrix() const - { return false; } - virtual bool SetTransformMatrix(const wxAffineMatrix2D& WXUNUSED(matrix)) - { return false; } - virtual wxAffineMatrix2D GetTransformMatrix() const - { return wxAffineMatrix2D(); } - virtual void ResetTransformMatrix() + // get or change the layout direction (LTR or RTL) for this dc, + // wxLayout_Default is returned if layout direction is not supported + virtual wxLayoutDirection GetLayoutDirection() const + { return wxLayout_Default; } + virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } -#endif // wxUSE_DC_TRANSFORM_MATRIX - - virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); - - virtual void ComputeScaleAndOrigin(); - - // this needs to overidden if the axis is inverted - virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); - - virtual double GetContentScaleFactor() const { return m_contentScaleFactor; } - -#ifdef __WXMSW__ - // Native Windows functions using the underlying HDC don't honour GDI+ - // transformations which may be applied to it. Using this function we can - // transform the coordinates manually before passing them to such functions - // (as in e.g. wxRendererMSW code). It doesn't do anything if this is not a - // wxGCDC. - virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const - { - return r; - } -#endif // __WXMSW__ - - - // --------------------------------------------------------- - // the actual drawing API +protected: + // the pure virtual functions which should be implemented by wxDC virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE) = 0; + int style = wxFLOOD_SURFACE) = 0; virtual void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, @@ -584,83 +732,78 @@ public: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, - bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, - wxCoord ysrcMask = wxDefaultCoord) = 0; + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) = 0; - virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode rop = wxCOPY, - bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, - wxCoord ysrcMask = wxDefaultCoord); + virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const { return wxNullBitmap; } - virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const - { return wxNullBitmap; } + virtual void DoGetSize(int *width, int *height) const = 0; + virtual void DoGetSizeMM(int* width, int* height) const = 0; - - virtual void DoDrawLines(int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset ) = 0; - virtual void DrawLines(const wxPointList *list, - wxCoord xoffset, wxCoord yoffset ); - - virtual void DoDrawPolygon(int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0; - virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], + virtual void DoDrawLines(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset) = 0; + virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle); - void DrawPolygon(const wxPointList *list, - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle ); + int fillStyle = wxODDEVEN_RULE) = 0; + virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle); + virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; + virtual void DoSetClippingRegion(wxCoord x, wxCoord y, + wxCoord width, wxCoord height) = 0; + +#if WXWIN_COMPATIBILITY_2_4 + // this was only for confusing people, use DoGetClippingBox only + virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, + wxCoord *w, wxCoord *h) + { DoGetClippingBox(x, y, w, h); } +#endif + + virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, + wxCoord *w, wxCoord *h) const + { + if ( x ) + *x = m_clipX1; + if ( y ) + *y = m_clipY1; + if ( w ) + *w = m_clipX2 - m_clipX1; + if ( h ) + *h = m_clipY2 - m_clipY1; + } + + virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const + { + if ( x ) *x = m_logicalOriginX; + if ( y ) *y = m_logicalOriginY; + } + + virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const + { + if ( x ) *x = m_deviceOriginX; + if ( y ) *y = m_deviceOriginY; + } + + virtual void DoGetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + wxFont *theFont = NULL) const = 0; + + virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; #if wxUSE_SPLINES - void DrawSpline(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord x3, wxCoord y3); - void DrawSpline(int n, const wxPoint points[]); - void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } - - virtual void DoDrawSpline(const wxPointList *points); + virtual void DoDrawSpline(wxList *points); #endif - // --------------------------------------------------------- - // wxMemoryDC Impl API - - virtual void DoSelect(const wxBitmap& WXUNUSED(bmp)) - { } - - virtual const wxBitmap& GetSelectedBitmap() const - { return wxNullBitmap; } - virtual wxBitmap& GetSelectedBitmap() - { return wxNullBitmap; } - - // --------------------------------------------------------- - // wxPrinterDC Impl API - - virtual wxRect GetPaperRect() const - { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); } - - virtual int GetResolution() const - { return -1; } - -#if wxUSE_GRAPHICS_CONTEXT - virtual wxGraphicsContext* GetGraphicsContext() const - { return NULL; } - virtual void SetGraphicsContext( wxGraphicsContext* WXUNUSED(ctx) ) - {} +#if wxABI_VERSION >= 20810 + // returns adjustment factor for converting wxFont "point size"; in wx + // it is point size on screen and needs to be multiplied by this value + // for rendering on higher-resolution DCs such as printer ones + static float GetFontPointSizeAdjustment(float dpi); #endif -private: - wxDC *m_owner; - protected: // unset clipping variables (after clipping region was destroyed) void ResetClipping() @@ -670,61 +813,6 @@ protected: m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; } -#ifdef __WXWINCE__ - //! Generic method to draw ellipses, circles and arcs with current pen and brush. - /*! \param x Upper left corner of bounding box. - * \param y Upper left corner of bounding box. - * \param w Width of bounding box. - * \param h Height of bounding box. - * \param sa Starting angle of arc - * (counterclockwise, start at 3 o'clock, 360 is full circle). - * \param ea Ending angle of arc. - * \param angle Rotation angle, the Arc will be rotated after - * calculating begin and end. - */ - void DrawEllipticArcRot( wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } - - void DrawEllipticArcRot( const wxPoint& pt, - const wxSize& sz, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } - - void DrawEllipticArcRot( const wxRect& rect, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } - - virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, - wxCoord w, wxCoord h, - double sa = 0, double ea = 0, double angle = 0 ); - - //! Rotates points around center. - /*! This is a quite straight method, it calculates in pixels - * and so it produces rounding errors. - * \param points The points inside will be rotated. - * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). - * \param center Center of rotation. - */ - void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) ); - - // used by DrawEllipticArcRot - // Careful: wxList gets filled with points you have to delete later. - void CalculateEllipticPoints( wxPointList* points, - wxCoord xStart, wxCoord yStart, - wxCoord w, wxCoord h, - double sa, double ea ); -#endif // __WXWINCE__ - - // returns adjustment factor for converting wxFont "point size"; in wx - // it is point size on screen and needs to be multiplied by this value - // for rendering on higher-resolution DCs such as printer ones - static float GetFontPointSizeAdjustment(float dpi); - - // window on which the DC draws or NULL - wxWindow *m_window; - // flags bool m_colour:1; bool m_ok:1; @@ -734,35 +822,27 @@ protected: // coordinate system variables - wxCoord m_logicalOriginX, m_logicalOriginY; - wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user + // TODO short descriptions of what exactly they are would be nice... + + wxCoord m_logicalOriginX, m_logicalOriginY; + wxCoord m_deviceOriginX, m_deviceOriginY; - wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner - // is not at 0,0. This was the case under - // Mac's GrafPorts (coordinate system - // used toplevel window's origin) and - // e.g. for Postscript, where the native - // origin in the bottom left corner. double m_logicalScaleX, m_logicalScaleY; double m_userScaleX, m_userScaleY; - double m_scaleX, m_scaleY; // calculated from logical scale and user scale + double m_scaleX, m_scaleY; - int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes - - double m_contentScaleFactor; // used by high resolution displays (retina) - - // what is a mm on a screen you don't know the size of? - double m_mm_to_pix_x, - m_mm_to_pix_y; + // Used by SetAxisOrientation() to invert the axes + int m_signX, m_signY; // bounding and clipping boxes wxCoord m_minX, m_minY, m_maxX, m_maxY; wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; - wxRasterOperationMode m_logicalFunction; + int m_logicalFunction; int m_backgroundMode; - wxMappingMode m_mappingMode; + int m_mappingMode; + // GDI objects wxPen m_pen; wxBrush m_brush; wxBrush m_backgroundBrush; @@ -776,613 +856,48 @@ protected: #endif // wxUSE_PALETTE private: - DECLARE_ABSTRACT_CLASS(wxDCImpl) + DECLARE_NO_COPY_CLASS(wxDCBase) + DECLARE_ABSTRACT_CLASS(wxDCBase) }; - -class WXDLLIMPEXP_CORE wxDC : public wxObject -{ -public: - // copy attributes (font, colours and writing direction) from another DC - void CopyAttributes(const wxDC& dc); - - virtual ~wxDC() { delete m_pimpl; } - - wxDCImpl *GetImpl() - { return m_pimpl; } - const wxDCImpl *GetImpl() const - { return m_pimpl; } - - wxWindow *GetWindow() const - { return m_pimpl->GetWindow(); } - - void *GetHandle() const - { return m_pimpl->GetHandle(); } - - bool IsOk() const - { return m_pimpl && m_pimpl->IsOk(); } - - // query capabilities - - bool CanDrawBitmap() const - { return m_pimpl->CanDrawBitmap(); } - bool CanGetTextExtent() const - { return m_pimpl->CanGetTextExtent(); } - - // query dimension, colour deps, resolution - - void GetSize(int *width, int *height) const - { m_pimpl->DoGetSize(width, height); } - wxSize GetSize() const - { return m_pimpl->GetSize(); } - - void GetSizeMM(int* width, int* height) const - { m_pimpl->DoGetSizeMM(width, height); } - wxSize GetSizeMM() const - { - int w, h; - m_pimpl->DoGetSizeMM(&w, &h); - return wxSize(w, h); - } - - int GetDepth() const - { return m_pimpl->GetDepth(); } - wxSize GetPPI() const - { return m_pimpl->GetPPI(); } - - virtual int GetResolution() const - { return m_pimpl->GetResolution(); } - - double GetContentScaleFactor() const - { return m_pimpl->GetContentScaleFactor(); } - - // Right-To-Left (RTL) modes - - void SetLayoutDirection(wxLayoutDirection dir) - { m_pimpl->SetLayoutDirection( dir ); } - wxLayoutDirection GetLayoutDirection() const - { return m_pimpl->GetLayoutDirection(); } - - // page and document - - bool StartDoc(const wxString& message) - { return m_pimpl->StartDoc(message); } - void EndDoc() - { m_pimpl->EndDoc(); } - - void StartPage() - { m_pimpl->StartPage(); } - void EndPage() - { m_pimpl->EndPage(); } - - // bounding box - - void CalcBoundingBox(wxCoord x, wxCoord y) - { m_pimpl->CalcBoundingBox(x,y); } - void ResetBoundingBox() - { m_pimpl->ResetBoundingBox(); } - - wxCoord MinX() const - { return m_pimpl->MinX(); } - wxCoord MaxX() const - { return m_pimpl->MaxX(); } - wxCoord MinY() const - { return m_pimpl->MinY(); } - wxCoord MaxY() const - { return m_pimpl->MaxY(); } - - // setters and getters - - void SetFont(const wxFont& font) - { m_pimpl->SetFont( font ); } - const wxFont& GetFont() const - { return m_pimpl->GetFont(); } - - void SetPen(const wxPen& pen) - { m_pimpl->SetPen( pen ); } - const wxPen& GetPen() const - { return m_pimpl->GetPen(); } - - void SetBrush(const wxBrush& brush) - { m_pimpl->SetBrush( brush ); } - const wxBrush& GetBrush() const - { return m_pimpl->GetBrush(); } - - void SetBackground(const wxBrush& brush) - { m_pimpl->SetBackground( brush ); } - const wxBrush& GetBackground() const - { return m_pimpl->GetBackground(); } - - void SetBackgroundMode(int mode) - { m_pimpl->SetBackgroundMode( mode ); } - int GetBackgroundMode() const - { return m_pimpl->GetBackgroundMode(); } - - void SetTextForeground(const wxColour& colour) - { m_pimpl->SetTextForeground(colour); } - const wxColour& GetTextForeground() const - { return m_pimpl->GetTextForeground(); } - - void SetTextBackground(const wxColour& colour) - { m_pimpl->SetTextBackground(colour); } - const wxColour& GetTextBackground() const - { return m_pimpl->GetTextBackground(); } - -#if wxUSE_PALETTE - void SetPalette(const wxPalette& palette) - { m_pimpl->SetPalette(palette); } -#endif // wxUSE_PALETTE - - // logical functions - - void SetLogicalFunction(wxRasterOperationMode function) - { m_pimpl->SetLogicalFunction(function); } - wxRasterOperationMode GetLogicalFunction() const - { return m_pimpl->GetLogicalFunction(); } - - // text measurement - - wxCoord GetCharHeight() const - { return m_pimpl->GetCharHeight(); } - wxCoord GetCharWidth() const - { return m_pimpl->GetCharWidth(); } - - wxFontMetrics GetFontMetrics() const - { - wxFontMetrics fm; - m_pimpl->DoGetFontMetrics(&fm.height, &fm.ascent, &fm.descent, - &fm.internalLeading, &fm.externalLeading, - &fm.averageWidth); - return fm; - } - - void GetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const - { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } - - wxSize GetTextExtent(const wxString& string) const - { - wxCoord w, h; - m_pimpl->DoGetTextExtent(string, &w, &h); - return wxSize(w, h); - } - - void GetMultiLineTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *heightLine = NULL, - const wxFont *font = NULL) const - { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); } - - wxSize GetMultiLineTextExtent(const wxString& string) const - { - wxCoord w, h; - m_pimpl->GetMultiLineTextExtent(string, &w, &h); - return wxSize(w, h); - } - - bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const - { return m_pimpl->DoGetPartialTextExtents(text, widths); } - - // clearing - - void Clear() - { m_pimpl->Clear(); } - - // clipping - - void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { m_pimpl->DoSetClippingRegion(x, y, width, height); } - void SetClippingRegion(const wxPoint& pt, const wxSize& sz) - { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } - void SetClippingRegion(const wxRect& rect) - { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } - - // unlike the functions above, the coordinates of the region used in this - // one are in device coordinates, not the logical ones - void SetDeviceClippingRegion(const wxRegion& region) - { m_pimpl->DoSetDeviceClippingRegion(region); } - - // this function is deprecated because its name is confusing: you may - // expect it to work with logical coordinates but, in fact, it does exactly - // the same thing as SetDeviceClippingRegion() - // - // please review the code using it and either replace it with calls to - // SetDeviceClippingRegion() or correct it if it was [wrongly] passing - // logical coordinates to this function - wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region), - SetDeviceClippingRegion(region); ) - - void DestroyClippingRegion() - { m_pimpl->DestroyClippingRegion(); } - - void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const - { m_pimpl->DoGetClippingBox(x, y, w, h); } - void GetClippingBox(wxRect& rect) const - { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); } - - // coordinates conversions and transforms - - wxCoord DeviceToLogicalX(wxCoord x) const - { return m_pimpl->DeviceToLogicalX(x); } - wxCoord DeviceToLogicalY(wxCoord y) const - { return m_pimpl->DeviceToLogicalY(y); } - wxCoord DeviceToLogicalXRel(wxCoord x) const - { return m_pimpl->DeviceToLogicalXRel(x); } - wxCoord DeviceToLogicalYRel(wxCoord y) const - { return m_pimpl->DeviceToLogicalYRel(y); } - wxCoord LogicalToDeviceX(wxCoord x) const - { return m_pimpl->LogicalToDeviceX(x); } - wxCoord LogicalToDeviceY(wxCoord y) const - { return m_pimpl->LogicalToDeviceY(y); } - wxCoord LogicalToDeviceXRel(wxCoord x) const - { return m_pimpl->LogicalToDeviceXRel(x); } - wxCoord LogicalToDeviceYRel(wxCoord y) const - { return m_pimpl->LogicalToDeviceYRel(y); } - - void SetMapMode(wxMappingMode mode) - { m_pimpl->SetMapMode(mode); } - wxMappingMode GetMapMode() const - { return m_pimpl->GetMapMode(); } - - void SetUserScale(double x, double y) - { m_pimpl->SetUserScale(x,y); } - void GetUserScale(double *x, double *y) const - { m_pimpl->GetUserScale( x, y ); } - - void SetLogicalScale(double x, double y) - { m_pimpl->SetLogicalScale( x, y ); } - void GetLogicalScale(double *x, double *y) const - { m_pimpl->GetLogicalScale( x, y ); } - - void SetLogicalOrigin(wxCoord x, wxCoord y) - { m_pimpl->SetLogicalOrigin(x,y); } - void GetLogicalOrigin(wxCoord *x, wxCoord *y) const - { m_pimpl->DoGetLogicalOrigin(x, y); } - wxPoint GetLogicalOrigin() const - { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } - - void SetDeviceOrigin(wxCoord x, wxCoord y) - { m_pimpl->SetDeviceOrigin( x, y); } - void GetDeviceOrigin(wxCoord *x, wxCoord *y) const - { m_pimpl->DoGetDeviceOrigin(x, y); } - wxPoint GetDeviceOrigin() const - { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } - - void SetAxisOrientation(bool xLeftRight, bool yBottomUp) - { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); } - -#if wxUSE_DC_TRANSFORM_MATRIX - bool CanUseTransformMatrix() const - { return m_pimpl->CanUseTransformMatrix(); } - - bool SetTransformMatrix(const wxAffineMatrix2D &matrix) - { return m_pimpl->SetTransformMatrix(matrix); } - - wxAffineMatrix2D GetTransformMatrix() const - { return m_pimpl->GetTransformMatrix(); } - - void ResetTransformMatrix() - { m_pimpl->ResetTransformMatrix(); } -#endif // wxUSE_DC_TRANSFORM_MATRIX - - // mostly internal - void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) - { m_pimpl->SetDeviceLocalOrigin( x, y ); } - - - // ----------------------------------------------- - // the actual drawing API - - bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE) - { return m_pimpl->DoFloodFill(x, y, col, style); } - bool FloodFill(const wxPoint& pt, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE) - { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); } - - // fill the area specified by rect with a radial gradient, starting from - // initialColour in the centre of the cercle and fading to destColour. - void GradientFillConcentric(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour) - { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour, - wxPoint(rect.GetWidth() / 2, - rect.GetHeight() / 2)); } - - void GradientFillConcentric(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - const wxPoint& circleCenter) - { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } - - // fill the area specified by rect with a linear gradient - void GradientFillLinear(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - wxDirection nDirection = wxEAST) - { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); } - - bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const - { return m_pimpl->DoGetPixel(x, y, col); } - bool GetPixel(const wxPoint& pt, wxColour *col) const - { return m_pimpl->DoGetPixel(pt.x, pt.y, col); } - - void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) - { m_pimpl->DoDrawLine(x1, y1, x2, y2); } - void DrawLine(const wxPoint& pt1, const wxPoint& pt2) - { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } - - void CrossHair(wxCoord x, wxCoord y) - { m_pimpl->DoCrossHair(x, y); } - void CrossHair(const wxPoint& pt) - { m_pimpl->DoCrossHair(pt.x, pt.y); } - - void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc) - { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); } - void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) - { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } - - void DrawCheckMark(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) - { m_pimpl->DoDrawCheckMark(x, y, width, height); } - void DrawCheckMark(const wxRect& rect) - { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } - - void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea) - { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); } - void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, - double sa, double ea) - { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } - - void DrawPoint(wxCoord x, wxCoord y) - { m_pimpl->DoDrawPoint(x, y); } - void DrawPoint(const wxPoint& pt) - { m_pimpl->DoDrawPoint(pt.x, pt.y); } - - void DrawLines(int n, const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0) - { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } - void DrawLines(const wxPointList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0) - { m_pimpl->DrawLines( list, xoffset, yoffset ); } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void DrawLines(const wxList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0) ); -#endif // WXWIN_COMPATIBILITY_2_8 - - void DrawPolygon(int n, const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) - { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } - void DrawPolygon(const wxPointList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) - { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } - void DrawPolyPolygon(int n, const int count[], const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) - { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void DrawPolygon(const wxList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) ); -#endif // WXWIN_COMPATIBILITY_2_8 - - void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { m_pimpl->DoDrawRectangle(x, y, width, height); } - void DrawRectangle(const wxPoint& pt, const wxSize& sz) - { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } - void DrawRectangle(const wxRect& rect) - { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } - - void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, - double radius) - { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); } - void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, - double radius) - { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } - void DrawRoundedRectangle(const wxRect& r, double radius) - { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } - - void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) - { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } - void DrawCircle(const wxPoint& pt, wxCoord radius) - { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); } - - void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { m_pimpl->DoDrawEllipse(x, y, width, height); } - void DrawEllipse(const wxPoint& pt, const wxSize& sz) - { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } - void DrawEllipse(const wxRect& rect) - { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } - - void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) - { m_pimpl->DoDrawIcon(icon, x, y); } - void DrawIcon(const wxIcon& icon, const wxPoint& pt) - { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); } - - void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = false) - { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); } - void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, - bool useMask = false) - { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); } - - void DrawText(const wxString& text, wxCoord x, wxCoord y) - { m_pimpl->DoDrawText(text, x, y); } - void DrawText(const wxString& text, const wxPoint& pt) - { m_pimpl->DoDrawText(text, pt.x, pt.y); } - - void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) - { m_pimpl->DoDrawRotatedText(text, x, y, angle); } - void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) - { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); } - - // this version puts both optional bitmap and the text into the given - // rectangle and aligns is as specified by alignment parameter; it also - // will emphasize the character with the given index if it is != -1 and - // return the bounding rectangle if required - void DrawLabel(const wxString& text, - const wxBitmap& image, - const wxRect& rect, - int alignment = wxALIGN_LEFT | wxALIGN_TOP, - int indexAccel = -1, - wxRect *rectBounding = NULL); - - void DrawLabel(const wxString& text, const wxRect& rect, - int alignment = wxALIGN_LEFT | wxALIGN_TOP, - int indexAccel = -1) - { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } - - bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) - { - return m_pimpl->DoBlit(xdest, ydest, width, height, - source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); - } - bool Blit(const wxPoint& destPt, const wxSize& sz, - wxDC *source, const wxPoint& srcPt, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - const wxPoint& srcPtMask = wxDefaultPosition) - { - return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y, - source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); - } - - bool StretchBlit(wxCoord dstX, wxCoord dstY, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord srcX, wxCoord srcY, - wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) - { - return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight, - source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); - } - bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, - wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - const wxPoint& srcMaskPt = wxDefaultPosition) - { - return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, - source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); - } - - wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const - { - return m_pimpl->DoGetAsBitmap(subrect); - } - -#if wxUSE_SPLINES - void DrawSpline(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord x3, wxCoord y3) - { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } - void DrawSpline(int n, const wxPoint points[]) - { m_pimpl->DrawSpline(n,points); } - void DrawSpline(const wxPointList *points) - { m_pimpl->DrawSpline(points); } -#endif // wxUSE_SPLINES - - -#if WXWIN_COMPATIBILITY_2_8 - // for compatibility with the old code when wxCoord was long everywhere - wxDEPRECATED( void GetTextExtent(const wxString& string, - long *x, long *y, - long *descent = NULL, - long *externalLeading = NULL, - const wxFont *theFont = NULL) const ); - wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); - wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); - wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); - - wxDEPRECATED( void DrawObject(wxDrawObject* drawobject) ); -#endif // WXWIN_COMPATIBILITY_2_8 - -#ifdef __WXMSW__ - // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only - // works if this wxDC is GDI-based and fails for GDI+ contexts (and - // anything else without HDC, e.g. wxPostScriptDC) - WXHDC GetHDC() const; - - // don't use these methods manually, use GetTempHDC() instead - virtual WXHDC AcquireHDC() { return GetHDC(); } - virtual void ReleaseHDC(WXHDC WXUNUSED(hdc)) { } - - // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like - // semantics, i.e. it is moved when copied - class TempHDC - { - public: - TempHDC(wxDC& dc) - : m_dc(dc), - m_hdc(dc.AcquireHDC()) - { - } - - TempHDC(const TempHDC& thdc) - : m_dc(thdc.m_dc), - m_hdc(thdc.m_hdc) - { - const_cast(thdc).m_hdc = 0; - } - - ~TempHDC() - { - if ( m_hdc ) - m_dc.ReleaseHDC(m_hdc); - } - - WXHDC GetHDC() const { return m_hdc; } - - private: - wxDC& m_dc; - WXHDC m_hdc; - - wxDECLARE_NO_ASSIGN_CLASS(TempHDC); - }; - - // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c) - TempHDC GetTempHDC() { return TempHDC(*this); } -#endif // __WXMSW__ - -#if wxUSE_GRAPHICS_CONTEXT - virtual wxGraphicsContext* GetGraphicsContext() const - { - return m_pimpl->GetGraphicsContext(); - } - virtual void SetGraphicsContext( wxGraphicsContext* ctx ) - { - m_pimpl->SetGraphicsContext(ctx); - } +// ---------------------------------------------------------------------------- +// now include the declaration of wxDC class +// ---------------------------------------------------------------------------- + +#if defined(__WXPALMOS__) + #include "wx/palmos/dc.h" +#elif defined(__WXMSW__) + #include "wx/msw/dc.h" +#elif defined(__WXMOTIF__) + #include "wx/motif/dc.h" +#elif defined(__WXGTK20__) + #include "wx/gtk/dc.h" +#elif defined(__WXGTK__) + #include "wx/gtk1/dc.h" +#elif defined(__WXX11__) + #include "wx/x11/dc.h" +#elif defined(__WXMGL__) + #include "wx/mgl/dc.h" +#elif defined(__WXDFB__) + #include "wx/dfb/dc.h" +#elif defined(__WXMAC__) + #include "wx/mac/dc.h" +#elif defined(__WXCOCOA__) + #include "wx/cocoa/dc.h" +#elif defined(__WXPM__) + #include "wx/os2/dc.h" #endif -protected: - // ctor takes ownership of the pointer - wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { } - - wxDCImpl * const m_pimpl; - -private: - DECLARE_ABSTRACT_CLASS(wxDC) - wxDECLARE_NO_COPY_CLASS(wxDC); -}; +#if wxUSE_GRAPHICS_CONTEXT + #include "wx/dcgraph.h" +#endif // ---------------------------------------------------------------------------- // helper class: you can use it to temporarily change the DC text colour and // restore it automatically when the object goes out of scope // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDCTextColourChanger +class WXDLLEXPORT wxDCTextColourChanger { public: wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { } @@ -1394,13 +909,13 @@ public: ~wxDCTextColourChanger() { - if ( m_colFgOld.IsOk() ) + if ( m_colFgOld.Ok() ) m_dc.SetTextForeground(m_colFgOld); } void Set(const wxColour& col) { - if ( !m_colFgOld.IsOk() ) + if ( !m_colFgOld.Ok() ) m_colFgOld = m_dc.GetTextForeground(); m_dc.SetTextForeground(col); } @@ -1410,7 +925,7 @@ private: wxColour m_colFgOld; - wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger); + DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) }; // ---------------------------------------------------------------------------- @@ -1418,7 +933,7 @@ private: // restore it automatically when the object goes out of scope // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDCPenChanger +class WXDLLEXPORT wxDCPenChanger { public: wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) @@ -1428,7 +943,7 @@ public: ~wxDCPenChanger() { - if ( m_penOld.IsOk() ) + if ( m_penOld.Ok() ) m_dc.SetPen(m_penOld); } @@ -1437,7 +952,7 @@ private: wxPen m_penOld; - wxDECLARE_NO_COPY_CLASS(wxDCPenChanger); + DECLARE_NO_COPY_CLASS(wxDCPenChanger) }; // ---------------------------------------------------------------------------- @@ -1445,7 +960,7 @@ private: // restore it automatically when the object goes out of scope // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDCBrushChanger +class WXDLLEXPORT wxDCBrushChanger { public: wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) @@ -1455,7 +970,7 @@ public: ~wxDCBrushChanger() { - if ( m_brushOld.IsOk() ) + if ( m_brushOld.Ok() ) m_dc.SetBrush(m_brushOld); } @@ -1464,7 +979,7 @@ private: wxBrush m_brushOld; - wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger); + DECLARE_NO_COPY_CLASS(wxDCBrushChanger) }; // ---------------------------------------------------------------------------- @@ -1472,11 +987,11 @@ private: // destroys it in the dtor // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDCClipper +class WXDLLEXPORT wxDCClipper { public: wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) - { dc.SetClippingRegion(r.GetBox()); } + { dc.SetClippingRegion(r); } wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) { dc.SetClippingRegion(r.x, r.y, r.width, r.height); } wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) @@ -1487,48 +1002,7 @@ public: private: wxDC& m_dc; - wxDECLARE_NO_COPY_CLASS(wxDCClipper); + DECLARE_NO_COPY_CLASS(wxDCClipper) }; -// ---------------------------------------------------------------------------- -// helper class: you can use it to temporarily change the DC font and -// restore it automatically when the object goes out of scope -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxDCFontChanger -{ -public: - wxDCFontChanger(wxDC& dc) - : m_dc(dc), m_fontOld() - { - } - - wxDCFontChanger(wxDC& dc, const wxFont& font) - : m_dc(dc), m_fontOld(dc.GetFont()) - { - m_dc.SetFont(font); - } - - void Set(const wxFont& font) - { - if ( !m_fontOld.IsOk() ) - m_fontOld = m_dc.GetFont(); - m_dc.SetFont(font); - } - - ~wxDCFontChanger() - { - if ( m_fontOld.IsOk() ) - m_dc.SetFont(m_fontOld); - } - -private: - wxDC& m_dc; - - wxFont m_fontOld; - - wxDECLARE_NO_COPY_CLASS(wxDCFontChanger); -}; - - #endif // _WX_DC_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dcbuffer.h b/Source/3rd Party/wx/include/wx/dcbuffer.h index c869f72a7..6769dbc85 100644 --- a/Source/3rd Party/wx/include/wx/dcbuffer.h +++ b/Source/3rd Party/wx/include/wx/dcbuffer.h @@ -4,6 +4,7 @@ // Author: Ron Lee // Modified by: Vadim Zeitlin (refactored, added bg preservation) // Created: 16/03/02 +// RCS-ID: $Id: dcbuffer.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Ron Lee // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,11 +37,7 @@ // does not prepare the window DC #define wxBUFFER_CLIENT_AREA 0x02 -// Set when not using specific buffer bitmap. Note that this -// is private style and not returned by GetStyle. -#define wxBUFFER_USES_SHARED_BUFFER 0x04 - -class WXDLLIMPEXP_CORE wxBufferedDC : public wxMemoryDC +class WXDLLEXPORT wxBufferedDC : public wxMemoryDC { public: // Default ctor, must subsequently call Init for two stage construction. @@ -101,11 +98,25 @@ public: // Usually called in the dtor or by the dtor of derived classes if the // BufferedDC must blit before the derived class (which may own the dc it's // blitting to) is destroyed. - void UnMask(); + void UnMask() + { + wxCHECK_RET( m_dc, wxT("no underlying wxDC?") ); + wxASSERT_MSG( m_buffer && m_buffer->IsOk(), wxT("invalid backing store") ); + + wxCoord x = 0, + y = 0; + + if ( m_style & wxBUFFER_CLIENT_AREA ) + GetDeviceOrigin(&x, &y); + + m_dc->Blit(0, 0, m_buffer->GetWidth(), m_buffer->GetHeight(), + this, -x, -y ); + m_dc = NULL; + } // Set and get the style void SetStyle(int style) { m_style = style; } - int GetStyle() const { return m_style & ~wxBUFFER_USES_SHARED_BUFFER; } + int GetStyle() const { return m_style; } private: // common part of Init()s @@ -115,6 +126,10 @@ private: m_dc = dc; m_style = style; + + // inherit the same layout direction as the original DC + if (dc && dc->IsOk()) + SetLayoutDirection(dc->GetLayoutDirection()); } // check that the bitmap is valid and use it @@ -133,10 +148,8 @@ private: // the buffering style int m_style; - wxSize m_area; - DECLARE_DYNAMIC_CLASS(wxBufferedDC) - wxDECLARE_NO_COPY_CLASS(wxBufferedDC); + DECLARE_NO_COPY_CLASS(wxBufferedDC) }; @@ -146,7 +159,7 @@ private: // Creates a double buffered wxPaintDC, optionally allowing the // user to specify their own buffer to use. -class WXDLLIMPEXP_CORE wxBufferedPaintDC : public wxBufferedDC +class WXDLLEXPORT wxBufferedPaintDC : public wxBufferedDC { public: // If no bitmap is supplied by the user, a temporary one will be created. @@ -196,7 +209,7 @@ private: wxPaintDC m_paintdc; DECLARE_ABSTRACT_CLASS(wxBufferedPaintDC) - wxDECLARE_NO_COPY_CLASS(wxBufferedPaintDC); + DECLARE_NO_COPY_CLASS(wxBufferedPaintDC) }; @@ -213,25 +226,40 @@ private: #define wxAutoBufferedPaintDCBase wxBufferedPaintDC #endif -class WXDLLIMPEXP_CORE wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase + +#ifdef __WXDEBUG__ + +class wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase { public: wxAutoBufferedPaintDC(wxWindow* win) : wxAutoBufferedPaintDCBase(win) { - wxASSERT_MSG( win->GetBackgroundStyle() == wxBG_STYLE_PAINT, - "You need to call SetBackgroundStyle(wxBG_STYLE_PAINT) in ctor, " - "and also, if needed, paint the background in wxEVT_PAINT handler." - ); + TestWinStyle(win); } virtual ~wxAutoBufferedPaintDC() { } private: - wxDECLARE_NO_COPY_CLASS(wxAutoBufferedPaintDC); + + void TestWinStyle(wxWindow* win) + { + // Help the user to get the double-buffering working properly. + wxASSERT_MSG( win->GetBackgroundStyle() == wxBG_STYLE_CUSTOM, + wxT("In constructor, you need to call SetBackgroundStyle(wxBG_STYLE_CUSTOM), ") + wxT("and also, if needed, paint the background manually in the paint event handler.")); + } + + DECLARE_NO_COPY_CLASS(wxAutoBufferedPaintDC) }; +#else // !__WXDEBUG__ + +// In release builds, just use typedef +typedef wxAutoBufferedPaintDCBase wxAutoBufferedPaintDC; + +#endif // Check if the window is natively double buffered and will return a wxPaintDC diff --git a/Source/3rd Party/wx/include/wx/dcclient.h b/Source/3rd Party/wx/include/wx/dcclient.h index f6c9c3f7b..c770f6a2f 100644 --- a/Source/3rd Party/wx/include/wx/dcclient.h +++ b/Source/3rd Party/wx/include/wx/dcclient.h @@ -2,61 +2,41 @@ // Name: wx/dcclient.h // Purpose: wxClientDC base header // Author: Julian Smart +// Modified by: +// Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: dcclient.h 40865 2006-08-27 09:42:42Z VS $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DCCLIENT_H_BASE_ #define _WX_DCCLIENT_H_BASE_ -#include "wx/dc.h" +#include "wx/defs.h" -//----------------------------------------------------------------------------- -// wxWindowDC -//----------------------------------------------------------------------------- +#if defined(__WXPALMOS__) +#include "wx/palmos/dcclient.h" +#elif defined(__WXMSW__) +#include "wx/msw/dcclient.h" +#elif defined(__WXMOTIF__) +#include "wx/motif/dcclient.h" +#elif defined(__WXGTK20__) +#include "wx/gtk/dcclient.h" +#elif defined(__WXGTK__) +#include "wx/gtk1/dcclient.h" +#elif defined(__WXX11__) +#include "wx/x11/dcclient.h" +#elif defined(__WXMGL__) +#include "wx/mgl/dcclient.h" +#elif defined(__WXDFB__) +#include "wx/dfb/dcclient.h" +#elif defined(__WXMAC__) +#include "wx/mac/dcclient.h" +#elif defined(__WXCOCOA__) +#include "wx/cocoa/dcclient.h" +#elif defined(__WXPM__) +#include "wx/os2/dcclient.h" +#endif -class WXDLLIMPEXP_CORE wxWindowDC : public wxDC -{ -public: - wxWindowDC(wxWindow *win); - -protected: - wxWindowDC(wxDCImpl *impl) : wxDC(impl) { } - -private: - DECLARE_ABSTRACT_CLASS(wxWindowDC) -}; - -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC -{ -public: - wxClientDC(wxWindow *win); - -protected: - wxClientDC(wxDCImpl *impl) : wxWindowDC(impl) { } - -private: - DECLARE_ABSTRACT_CLASS(wxClientDC) -}; - -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC -{ -public: - wxPaintDC(wxWindow *win); - -protected: - wxPaintDC(wxDCImpl *impl) : wxClientDC(impl) { } - -private: - DECLARE_ABSTRACT_CLASS(wxPaintDC) -}; - -#endif // _WX_DCCLIENT_H_BASE_ +#endif + // _WX_DCCLIENT_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dcgraph.h b/Source/3rd Party/wx/include/wx/dcgraph.h index 0181f552a..8245f8145 100644 --- a/Source/3rd Party/wx/include/wx/dcgraph.h +++ b/Source/3rd Party/wx/include/wx/dcgraph.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/dcgraph.h +// Name: wx/graphdc.h // Purpose: graphics context device bridge header // Author: Stefan Csomor // Modified by: // Created: // Copyright: (c) Stefan Csomor +// RCS-ID: $Id: dcgraph.h 53390 2008-04-28 04:19:15Z KO $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,59 +14,36 @@ #if wxUSE_GRAPHICS_CONTEXT -#include "wx/dc.h" #include "wx/geometry.h" +#include "wx/dynarray.h" #include "wx/graphics.h" -class WXDLLIMPEXP_FWD_CORE wxWindowDC; +class WXDLLEXPORT wxWindowDC; +#ifdef __WXMAC__ +#define wxGCDC wxDC +#endif -class WXDLLIMPEXP_CORE wxGCDC: public wxDC +class WXDLLEXPORT wxGCDC: +#ifdef __WXMAC__ + public wxDCBase +#else + public wxDC +#endif { + DECLARE_DYNAMIC_CLASS(wxGCDC) + DECLARE_NO_COPY_CLASS(wxGCDC) + public: - wxGCDC( const wxWindowDC& dc ); - wxGCDC( const wxMemoryDC& dc ); -#if wxUSE_PRINTING_ARCHITECTURE - wxGCDC( const wxPrinterDC& dc ); -#endif -#if defined(__WXMSW__) && wxUSE_ENH_METAFILE - wxGCDC( const wxEnhMetaFileDC& dc ); -#endif - wxGCDC(wxGraphicsContext* context); - + wxGCDC(const wxWindowDC& dc); +#ifdef __WXMSW__ + wxGCDC( const wxMemoryDC& dc); +#endif wxGCDC(); virtual ~wxGCDC(); - wxGraphicsContext* GetGraphicsContext() const; - void SetGraphicsContext( wxGraphicsContext* ctx ); + void Init(); -#ifdef __WXMSW__ - // override wxDC virtual functions to provide access to HDC associated with - // this Graphics object (implemented in src/msw/graphics.cpp) - virtual WXHDC AcquireHDC(); - virtual void ReleaseHDC(WXHDC hdc); -#endif // __WXMSW__ - -private: - DECLARE_DYNAMIC_CLASS(wxGCDC) - wxDECLARE_NO_COPY_CLASS(wxGCDC); -}; - - -class WXDLLIMPEXP_CORE wxGCDCImpl: public wxDCImpl -{ -public: - wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ); - wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ); -#if wxUSE_PRINTING_ARCHITECTURE - wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ); -#endif -#if defined(__WXMSW__) && wxUSE_ENH_METAFILE - wxGCDCImpl( wxDC *owner, const wxEnhMetaFileDC& dc ); -#endif - wxGCDCImpl( wxDC *owner ); - - virtual ~wxGCDCImpl(); // implement base class pure virtuals // ---------------------------------- @@ -77,9 +55,10 @@ public: virtual void StartPage(); virtual void EndPage(); - + + // to be virtualized on next major // flushing the content of this dc immediately onto screen - virtual void Flush(); + void Flush(); virtual void SetFont(const wxFont& font); virtual void SetPen(const wxPen& pen); @@ -98,21 +77,27 @@ public: virtual int GetDepth() const; virtual wxSize GetPPI() const; - virtual void SetLogicalFunction(wxRasterOperationMode function); + virtual void SetMapMode(int mode); + virtual void SetUserScale(double x, double y); + + virtual void SetLogicalScale(double x, double y); + virtual void SetLogicalOrigin(wxCoord x, wxCoord y); + virtual void SetDeviceOrigin(wxCoord x, wxCoord y); + virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); + virtual void SetLogicalFunction(int function); virtual void SetTextForeground(const wxColour& colour); virtual void SetTextBackground(const wxColour& colour); virtual void ComputeScaleAndOrigin(); - wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; } + wxGraphicsContext* GetGraphicsContext() { return m_graphicContext; } virtual void SetGraphicsContext( wxGraphicsContext* ctx ); - - virtual void* GetHandle() const; - + +protected: // the true implementations virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE); + int style = wxFLOOD_SURFACE); virtual void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, @@ -129,7 +114,7 @@ public: virtual void DoDrawPoint(wxCoord x, wxCoord y); #if wxUSE_SPLINES - virtual void DoDrawSpline(const wxPointList *points); + virtual void DoDrawSpline(wxList *points); #endif virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); @@ -161,31 +146,22 @@ public: double angle); virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); - - virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); virtual void DoGetSize(int *,int *) const; virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, const wxPoint points[], + virtual void DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle); + virtual void DoDrawPolygon(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle = wxODDEVEN_RULE); + virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle); - virtual void DoSetDeviceClippingRegion(const wxRegion& region); + virtual void DoSetClippingRegionAsRegion(const wxRegion& region); virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); @@ -193,34 +169,22 @@ public: wxCoord *x, wxCoord *y, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const; + wxFont *theFont = NULL) const; virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; -#ifdef __WXMSW__ - virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const; -#endif // __WXMSW__ - protected: - // unused int parameter distinguishes this version, which does not create a - // wxGraphicsContext, in the expectation that the derived class will do it - wxGCDCImpl(wxDC* owner, int); - // scaling variables bool m_logicalFunctionSupported; + double m_mm_to_pix_x, m_mm_to_pix_y; wxGraphicsMatrix m_matrixOriginal; wxGraphicsMatrix m_matrixCurrent; double m_formerScaleX, m_formerScaleY; wxGraphicsContext* m_graphicContext; - -private: - void Init(wxGraphicsContext*); - - DECLARE_CLASS(wxGCDCImpl) - wxDECLARE_NO_COPY_CLASS(wxGCDCImpl); }; -#endif // wxUSE_GRAPHICS_CONTEXT +#endif + #endif // _WX_GRAPHICS_DC_H_ diff --git a/Source/3rd Party/wx/include/wx/dcmemory.h b/Source/3rd Party/wx/include/wx/dcmemory.h index 84ae9adef..cd7bb0c9d 100644 --- a/Source/3rd Party/wx/include/wx/dcmemory.h +++ b/Source/3rd Party/wx/include/wx/dcmemory.h @@ -5,40 +5,72 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: dcmemory.h 43843 2006-12-07 05:44:44Z PC $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DCMEMORY_H_BASE_ #define _WX_DCMEMORY_H_BASE_ -#include "wx/dc.h" #include "wx/bitmap.h" -//----------------------------------------------------------------------------- -// wxMemoryDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMemoryDC: public wxDC +// NOTE: different native implementations of wxMemoryDC will derive from +// different wxDC classes (wxPaintDC, wxWindowDC, etc), so that +// we cannot derive wxMemoryDCBase from wxDC and then use it as the +// only base class for native impl of wxMemoryDC... +class WXDLLEXPORT wxMemoryDCBase { public: - wxMemoryDC(); - wxMemoryDC( wxBitmap& bitmap ); - wxMemoryDC( wxDC *dc ); + wxMemoryDCBase() { } + + // avoid warnings about having virtual functions but non virtual dtor + virtual ~wxMemoryDCBase() { } // select the given bitmap to draw on it - void SelectObject(wxBitmap& bmp); + void SelectObject(wxBitmap& bmp) + { + // make sure that the given wxBitmap is not sharing its data with other + // wxBitmap instances as its contents will be modified by any drawing + // operation done on this DC + if (bmp.IsOk()) + bmp.UnShare(); + + DoSelect(bmp); + } // select the given bitmap for read-only - void SelectObjectAsSource(const wxBitmap& bmp); + virtual void SelectObjectAsSource(const wxBitmap& bmp) + { + DoSelect(bmp); + } - // get selected bitmap - const wxBitmap& GetSelectedBitmap() const; - wxBitmap& GetSelectedBitmap(); - -private: - DECLARE_DYNAMIC_CLASS(wxMemoryDC) +protected: + virtual void DoSelect(const wxBitmap& bmp) = 0; }; +#if defined(__WXPALMOS__) +#include "wx/palmos/dcmemory.h" +#elif defined(__WXMSW__) +#include "wx/msw/dcmemory.h" +#elif defined(__WXMOTIF__) +#include "wx/motif/dcmemory.h" +#elif defined(__WXGTK20__) +#include "wx/gtk/dcmemory.h" +#elif defined(__WXGTK__) +#include "wx/gtk1/dcmemory.h" +#elif defined(__WXX11__) +#include "wx/x11/dcmemory.h" +#elif defined(__WXMGL__) +#include "wx/mgl/dcmemory.h" +#elif defined(__WXDFB__) +#include "wx/dfb/dcmemory.h" +#elif defined(__WXMAC__) +#include "wx/mac/dcmemory.h" +#elif defined(__WXCOCOA__) +#include "wx/cocoa/dcmemory.h" +#elif defined(__WXPM__) +#include "wx/os2/dcmemory.h" +#endif #endif // _WX_DCMEMORY_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dcmirror.h b/Source/3rd Party/wx/include/wx/dcmirror.h index 2978ac43d..89bf12575 100644 --- a/Source/3rd Party/wx/include/wx/dcmirror.h +++ b/Source/3rd Party/wx/include/wx/dcmirror.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 21.07.2003 +// RCS-ID: $Id: dcmirror.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ // wxMirrorDC allows to write the same code for horz/vertical layout // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMirrorDCImpl : public wxDCImpl +class WXDLLEXPORT wxMirrorDC : public wxDC { public: // constructs a mirror DC associated with the given real DC @@ -25,12 +26,13 @@ public: // if mirror parameter is true, all vertical and horizontal coordinates are // exchanged, otherwise this class behaves in exactly the same way as a // plain DC - wxMirrorDCImpl(wxDC *owner, wxDCImpl& dc, bool mirror) - : wxDCImpl(owner), - m_dc(dc) - { - m_mirror = mirror; - } + // + // the cast to wxMirrorDC is a dirty hack done to allow us to call the + // protected methods of wxDCBase directly in our code below, without it it + // would be impossible (this is correct from C++ point of view but doesn't + // make any sense in this particular situation) + wxMirrorDC(wxDC& dc, bool mirror) : m_dc((wxMirrorDC&)dc) + { m_mirror = mirror; } // wxDCBase operations virtual void Clear() { m_dc.Clear(); } @@ -51,8 +53,9 @@ public: virtual bool CanGetTextExtent() const { return m_dc.CanGetTextExtent(); } virtual int GetDepth() const { return m_dc.GetDepth(); } virtual wxSize GetPPI() const { return m_dc.GetPPI(); } - virtual bool IsOk() const { return m_dc.IsOk(); } - virtual void SetMapMode(wxMappingMode mode) { m_dc.SetMapMode(mode); } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const { return m_dc.Ok(); } + virtual void SetMapMode(int mode) { m_dc.SetMapMode(mode); } virtual void SetUserScale(double x, double y) { m_dc.SetUserScale(GetX(x, y), GetY(x, y)); } virtual void SetLogicalOrigin(wxCoord x, wxCoord y) @@ -62,11 +65,14 @@ public: virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) { m_dc.SetAxisOrientation(GetX(xLeftRight, yBottomUp), GetY(xLeftRight, yBottomUp)); } - virtual void SetLogicalFunction(wxRasterOperationMode function) + virtual void SetLogicalFunction(int function) { m_dc.SetLogicalFunction(function); } - virtual void* GetHandle() const - { return m_dc.GetHandle(); } + // helper functions which may be useful for the users of this class + wxSize Reflect(const wxSize& sizeOrig) + { + return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig; + } protected: // returns x and y if not mirroring or y and x if mirroring @@ -81,26 +87,30 @@ protected: wxCoord *GetX(wxCoord *x, wxCoord *y) const { return m_mirror ? y : x; } wxCoord *GetY(wxCoord *x, wxCoord *y) const { return m_mirror ? x : y; } - // exchange x and y components of all points in the array if necessary - wxPoint* Mirror(int n, const wxPoint*& points) const + // exchange x and y unconditionally + static void Swap(wxCoord& x, wxCoord& y) + { + wxCoord t = x; + x = y; + y = t; + } + + // exchange x and y components of all points in the array if necessary + void Mirror(int n, wxPoint points[]) const { - wxPoint* points_alloc = NULL; if ( m_mirror ) { - points_alloc = new wxPoint[n]; for ( int i = 0; i < n; i++ ) { - points_alloc[i].x = points[i].y; - points_alloc[i].y = points[i].x; + Swap(points[i].x, points[i].y); } - points = points_alloc; } - return points_alloc; } + // wxDCBase functions virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE) + int style = wxFLOOD_SURFACE) { return m_dc.DoFloodFill(GetX(x, y), GetY(x, y), col, style); } @@ -200,8 +210,7 @@ protected: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord w, wxCoord h, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, - bool useMask = false, + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) { return m_dc.DoBlit(GetX(xdest, ydest), GetY(xdest, ydest), @@ -221,31 +230,31 @@ protected: m_dc.DoGetSizeMM(GetX(w, h), GetY(w, h)); } - virtual void DoDrawLines(int n, const wxPoint points[], + virtual void DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { - wxPoint* points_alloc = Mirror(n, points); + Mirror(n, points); m_dc.DoDrawLines(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset)); - delete[] points_alloc; + Mirror(n, points); } - virtual void DoDrawPolygon(int n, const wxPoint points[], + virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE) + int fillStyle = wxODDEVEN_RULE) { - wxPoint* points_alloc = Mirror(n, points); + Mirror(n, points); m_dc.DoDrawPolygon(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset), fillStyle); - delete[] points_alloc; + Mirror(n, points); } - virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region)) + virtual void DoSetClippingRegionAsRegion(const wxRegion& WXUNUSED(region)) { wxFAIL_MSG( wxT("not implemented") ); } @@ -260,39 +269,18 @@ protected: wxCoord *x, wxCoord *y, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const + wxFont *theFont = NULL) const { // never mirrored m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } private: - wxDCImpl& m_dc; + wxMirrorDC& m_dc; bool m_mirror; - wxDECLARE_NO_COPY_CLASS(wxMirrorDCImpl); -}; - -class WXDLLIMPEXP_CORE wxMirrorDC : public wxDC -{ -public: - wxMirrorDC(wxDC& dc, bool mirror) - : wxDC(new wxMirrorDCImpl(this, *dc.GetImpl(), mirror)) - { - m_mirror = mirror; - } - - // helper functions which may be useful for the users of this class - wxSize Reflect(const wxSize& sizeOrig) - { - return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig; - } - -private: - bool m_mirror; - - wxDECLARE_NO_COPY_CLASS(wxMirrorDC); + DECLARE_NO_COPY_CLASS(wxMirrorDC) }; #endif // _WX_DCMIRROR_H_ diff --git a/Source/3rd Party/wx/include/wx/dcprint.h b/Source/3rd Party/wx/include/wx/dcprint.h index 87f33eb6d..b22394b08 100644 --- a/Source/3rd Party/wx/include/wx/dcprint.h +++ b/Source/3rd Party/wx/include/wx/dcprint.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: dcprint.h 41240 2006-09-15 16:45:48Z PC $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -15,28 +16,18 @@ #if wxUSE_PRINTING_ARCHITECTURE -#include "wx/dc.h" - -//----------------------------------------------------------------------------- -// wxPrinterDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPrinterDC : public wxDC -{ -public: - wxPrinterDC(); - wxPrinterDC(const wxPrintData& data); - - wxRect GetPaperRect() const; - int GetResolution() const; - -protected: - wxPrinterDC(wxDCImpl *impl) : wxDC(impl) { } - -private: - DECLARE_DYNAMIC_CLASS(wxPrinterDC) -}; +#if defined(__WXPALMOS__) +#include "wx/palmos/dcprint.h" +#elif defined(__WXMSW__) +#include "wx/msw/dcprint.h" +#endif +#if defined(__WXPM__) +#include "wx/os2/dcprint.h" +#endif +#if defined(__WXMAC__) +#include "wx/mac/dcprint.h" +#endif #endif // wxUSE_PRINTING_ARCHITECTURE - -#endif // _WX_DCPRINT_H_BASE_ +#endif + // _WX_DCPRINT_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dcps.h b/Source/3rd Party/wx/include/wx/dcps.h deleted file mode 100644 index 659eb595f..000000000 --- a/Source/3rd Party/wx/include/wx/dcps.h +++ /dev/null @@ -1,17 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/dcps.h -// Purpose: wxPostScriptDC base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DCPS_H_BASE_ -#define _WX_DCPS_H_BASE_ - -#include "wx/generic/dcpsg.h" - -#endif - diff --git a/Source/3rd Party/wx/include/wx/dcscreen.h b/Source/3rd Party/wx/include/wx/dcscreen.h index fc5c49f71..8b52dd959 100644 --- a/Source/3rd Party/wx/include/wx/dcscreen.h +++ b/Source/3rd Party/wx/include/wx/dcscreen.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: dcscreen.h 40865 2006-08-27 09:42:42Z VS $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -12,24 +13,30 @@ #define _WX_DCSCREEN_H_BASE_ #include "wx/defs.h" -#include "wx/dc.h" - -class WXDLLIMPEXP_CORE wxScreenDC : public wxDC -{ -public: - wxScreenDC(); - - static bool StartDrawingOnTop(wxWindow * WXUNUSED(window)) - { return true; } - static bool StartDrawingOnTop(wxRect * WXUNUSED(rect) = NULL) - { return true; } - static bool EndDrawingOnTop() - { return true; } - -private: - DECLARE_DYNAMIC_CLASS(wxScreenDC) -}; +#if defined(__WXPALMOS__) +#include "wx/palmos/dcscreen.h" +#elif defined(__WXMSW__) +#include "wx/msw/dcscreen.h" +#elif defined(__WXMOTIF__) +#include "wx/motif/dcscreen.h" +#elif defined(__WXGTK20__) +#include "wx/gtk/dcscreen.h" +#elif defined(__WXGTK__) +#include "wx/gtk1/dcscreen.h" +#elif defined(__WXX11__) +#include "wx/x11/dcscreen.h" +#elif defined(__WXMGL__) +#include "wx/mgl/dcscreen.h" +#elif defined(__WXDFB__) +#include "wx/dfb/dcscreen.h" +#elif defined(__WXMAC__) +#include "wx/mac/dcscreen.h" +#elif defined(__WXCOCOA__) +#include "wx/cocoa/dcscreen.h" +#elif defined(__WXPM__) +#include "wx/os2/dcscreen.h" +#endif #endif // _WX_DCSCREEN_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dcsvg.h b/Source/3rd Party/wx/include/wx/dcsvg.h deleted file mode 100644 index c6485ff13..000000000 --- a/Source/3rd Party/wx/include/wx/dcsvg.h +++ /dev/null @@ -1,227 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/dcsvg.h -// Purpose: wxSVGFileDC -// Author: Chris Elliott -// Modified by: -// Created: -// Copyright: (c) Chris Elliott -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DCSVG_H_ -#define _WX_DCSVG_H_ - -#include "wx/string.h" -#include "wx/dc.h" - -#if wxUSE_SVG - -#define wxSVGVersion wxT("v0100") - -#ifdef __BORLANDC__ -#pragma warn -8008 -#pragma warn -8066 -#endif - -class WXDLLIMPEXP_FWD_BASE wxFileOutputStream; - - - -class WXDLLIMPEXP_FWD_CORE wxSVGFileDC; - -class WXDLLIMPEXP_CORE wxSVGFileDCImpl : public wxDCImpl -{ -public: - wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename, - int width=320, int height=240, double dpi=72.0 ); - - virtual ~wxSVGFileDCImpl(); - - bool IsOk() const { return m_OK; } - - virtual bool CanDrawBitmap() const { return true; } - virtual bool CanGetTextExtent() const { return true; } - - virtual int GetDepth() const - { - wxFAIL_MSG(wxT("wxSVGFILEDC::GetDepth Call not implemented")); - return -1; - } - - virtual void Clear() - { - wxFAIL_MSG(wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); - } - - virtual void DestroyClippingRegion(); - - virtual wxCoord GetCharHeight() const; - virtual wxCoord GetCharWidth() const; - - virtual void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), - wxCoord WXUNUSED(w), wxCoord WXUNUSED(h)) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::SetClippingRegion not implemented")); - } - - virtual void SetPalette(const wxPalette& WXUNUSED(palette)) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::SetPalette not implemented")); - } - - virtual void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), - wxCoord *WXUNUSED(w), wxCoord *WXUNUSED(h)) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::GetClippingBox not implemented")); - } - - virtual void SetLogicalFunction(wxRasterOperationMode WXUNUSED(function)) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); - } - - virtual wxRasterOperationMode GetLogicalFunction() const - { - wxFAIL_MSG(wxT("wxSVGFILEDC::GetLogicalFunction() not implemented")); - return wxCOPY; - } - - virtual void SetBackground( const wxBrush &brush ); - virtual void SetBackgroundMode( int mode ); - virtual void SetBrush(const wxBrush& brush); - virtual void SetFont(const wxFont& font); - virtual void SetPen(const wxPen& pen); - - virtual void* GetHandle() const { return NULL; } - -private: - virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const - { - wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); - return true; - } - - virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, wxDC *, - wxCoord, wxCoord, wxRasterOperationMode = wxCOPY, - bool = 0, int = -1, int = -1); - - virtual void DoCrossHair(wxCoord, wxCoord) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented")); - } - - virtual void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord); - - virtual void DoDrawBitmap(const wxBitmap &, wxCoord, wxCoord, bool = false); - - virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord w, wxCoord h); - - virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h); - - virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea); - - virtual void DoDrawIcon(const wxIcon &, wxCoord, wxCoord); - - virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); - - virtual void DoDrawLines(int n, const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0); - - virtual void DoDrawPoint(wxCoord, wxCoord); - - virtual void DoDrawPolygon(int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle); - - virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h); - - virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, - double angle); - - virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, - wxCoord w, wxCoord h, - double radius = 20) ; - - virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); - - virtual bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), - const wxColour& WXUNUSED(col), - wxFloodFillStyle WXUNUSED(style) = wxFLOOD_SURFACE) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); - return false; - } - - virtual void DoGetSize(int * x, int *y) const - { - if ( x ) - *x = m_width; - if ( y ) - *y = m_height; - } - - virtual void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *font = NULL) const; - - virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region)) - { - wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetDeviceClippingRegion not yet implemented")); - } - - virtual void DoSetClippingRegion(int x, int y, int width, int height); - - virtual void DoGetSizeMM( int *width, int *height ) const; - - virtual wxSize GetPPI() const; - - void Init (const wxString &filename, int width, int height, double dpi); - - void write( const wxString &s ); - -private: - // If m_graphics_changed is true, close the current element and start a - // new one for the last pen/brush change. - void NewGraphicsIfNeeded(); - - // Open a new graphics group setting up all the attributes according to - // their current values in wxDC. - void DoStartNewGraphics(); - - wxFileOutputStream *m_outfile; - wxString m_filename; - int m_sub_images; // number of png format images we have - bool m_OK; - bool m_graphics_changed; // set by Set{Brush,Pen}() - int m_width, m_height; - double m_dpi; - - // The clipping nesting level is incremented by every call to - // SetClippingRegion() and reset when DestroyClippingRegion() is called. - size_t m_clipNestingLevel; - - // Unique ID for every clipping graphics group: this is simply always - // incremented in each SetClippingRegion() call. - size_t m_clipUniqueId; - - DECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl) -}; - - -class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC -{ -public: - wxSVGFileDC(const wxString& filename, - int width = 320, - int height = 240, - double dpi = 72.0) - : wxDC(new wxSVGFileDCImpl(this, filename, width, height, dpi)) - { - } -}; - -#endif // wxUSE_SVG - -#endif // _WX_DCSVG_H_ diff --git a/Source/3rd Party/wx/include/wx/dde.h b/Source/3rd Party/wx/include/wx/dde.h index d7cf290cd..495e9e27a 100644 --- a/Source/3rd Party/wx/include/wx/dde.h +++ b/Source/3rd Party/wx/include/wx/dde.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: dde.h 53135 2008-04-12 02:31:04Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -21,10 +22,10 @@ WX_DECLARE_USER_EXPORTED_LIST(wxDDEClient, wxDDEClientList, WXDLLIMPEXP_BASE); WX_DECLARE_USER_EXPORTED_LIST(wxDDEServer, wxDDEServerList, WXDLLIMPEXP_BASE); WX_DECLARE_USER_EXPORTED_LIST(wxDDEConnection, wxDDEConnectionList, WXDLLIMPEXP_BASE); -#if defined(__WINDOWS__) +#if defined(__WXMSW__) #include "wx/msw/dde.h" #else - #error DDE is only supported under Windows + #error DDE is only supported on MSW #endif #endif diff --git a/Source/3rd Party/wx/include/wx/debug.h b/Source/3rd Party/wx/include/wx/debug.h index 143f23956..fd42bdbfd 100644 --- a/Source/3rd Party/wx/include/wx/debug.h +++ b/Source/3rd Party/wx/include/wx/debug.h @@ -1,388 +1,247 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/debug.h -// Purpose: Misc debug functions and macros -// Author: Vadim Zeitlin -// Created: 29/01/98 -// Copyright: (c) 1998-2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// +/** +* Name: wx/debug.h +* Purpose: Misc debug functions and macros +* Author: Vadim Zeitlin +* Modified by: Ryan Norton (Converted to C) +* Created: 29/01/98 +* RCS-ID: $Id: debug.h 61872 2009-09-09 22:37:05Z VZ $ +* Copyright: (c) 1998 Vadim Zeitlin +* Licence: wxWindows licence +*/ -#ifndef _WX_DEBUG_H_ -#define _WX_DEBUG_H_ +/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ -#if !defined(__WXWINCE__) - #include -#endif // systems without assert.h +#ifndef _WX_DEBUG_H_ +#define _WX_DEBUG_H_ -#include // for CHAR_BIT used below +#ifndef __WXWINCE__ +#include +#endif +#include /* for CHAR_BIT used below */ -#include "wx/chartype.h" // for __TFILE__ and wxChar -#include "wx/cpp.h" // for __WXFUNCTION__ -#include "wx/dlimpexp.h" // for WXDLLIMPEXP_FWD_BASE +#include "wx/wxchar.h" /* for __TFILE__ and wxChar */ -class WXDLLIMPEXP_FWD_BASE wxString; -class WXDLLIMPEXP_FWD_BASE wxCStrData; +/* ---------------------------------------------------------------------------- */ +/* Defines controlling the debugging macros */ +/* ---------------------------------------------------------------------------- */ -// ---------------------------------------------------------------------------- -// Defines controlling the debugging macros -// ---------------------------------------------------------------------------- - -/* - wxWidgets can be built with several different levels of debug support - specified by the value of wxDEBUG_LEVEL constant: - - 0: No assertion macros at all, this should only be used when optimizing - for resource-constrained systems (typically embedded ones). - 1: Default level, most of the assertions are enabled. - 2: Maximal (at least for now): asserts which are "expensive" - (performance-wise) or only make sense for finding errors in wxWidgets - itself, as opposed to bugs in applications using it, are also enabled. - */ - -// unless wxDEBUG_LEVEL is predefined (by configure or via wx/setup.h under -// Windows), use the default -#if !defined(wxDEBUG_LEVEL) - #define wxDEBUG_LEVEL 1 -#endif // !defined(wxDEBUG_LEVEL) - -/* - __WXDEBUG__ is defined when wxDEBUG_LEVEL != 0. This is done mostly for - compatibility but it also provides a simpler way to check if asserts and - debug logging is enabled at all. - */ -#if wxDEBUG_LEVEL > 0 +/* if _DEBUG is defined (MS VC++ and others use it in debug builds), define */ +/* __WXDEBUG__ too */ +#ifdef _DEBUG #ifndef __WXDEBUG__ #define __WXDEBUG__ - #endif -#else - #undef __WXDEBUG__ -#endif + #endif /* !__WXDEBUG__ */ +#endif /* _DEBUG */ -// Finally there is also a very old WXDEBUG macro not used anywhere at all, it -// is only defined for compatibility. +/* if NDEBUG is defined ( uses it), undef __WXDEBUG__ and WXDEBUG */ +#ifdef NDEBUG + #undef __WXDEBUG__ + #undef WXDEBUG +#endif /* NDEBUG */ + +/* if __WXDEBUG__ is defined, make sure that WXDEBUG is defined and >= 1 */ #ifdef __WXDEBUG__ #if !defined(WXDEBUG) || !WXDEBUG #undef WXDEBUG #define WXDEBUG 1 - #endif // !WXDEBUG -#endif // __WXDEBUG__ + #endif /* !WXDEBUG */ +#endif /* __WXDEBUG__ */ -// ---------------------------------------------------------------------------- -// Handling assertion failures -// ---------------------------------------------------------------------------- - -/* - Type for the function called in case of assert failure, see - wxSetAssertHandler(). - */ -typedef void (*wxAssertHandler_t)(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg); - -#if wxDEBUG_LEVEL - -// the global assert handler function, if it is NULL asserts don't check their -// conditions -extern WXDLLIMPEXP_DATA_BASE(wxAssertHandler_t) wxTheAssertHandler; - -/* - Sets the function to be called in case of assertion failure. - - The default assert handler forwards to wxApp::OnAssertFailure() whose - default behaviour is, in turn, to show the standard assertion failure - dialog if a wxApp object exists or shows the same dialog itself directly - otherwise. - - While usually it is enough -- and more convenient -- to just override - OnAssertFailure(), to handle all assertion failures, including those - occurring even before wxApp object creation or after its destruction you - need to provide your assertion handler function. - - This function also provides a simple way to disable all asserts: simply - pass NULL pointer to it. Doing this will result in not even evaluating - assert conditions at all, avoiding almost all run-time cost of asserts. - - Notice that this function is not MT-safe, so you should call it before - starting any other threads. - - The return value of this function is the previous assertion handler. It can - be called after any pre-processing by your handler and can also be restored - later if you uninstall your handler. - */ -inline wxAssertHandler_t wxSetAssertHandler(wxAssertHandler_t handler) -{ - const wxAssertHandler_t old = wxTheAssertHandler; - wxTheAssertHandler = handler; - return old; -} - -/* - Reset the default assert handler. - - This may be used to enable asserts, which are disabled by default in this - case, for programs built in release build (NDEBUG defined). - */ -extern void WXDLLIMPEXP_BASE wxSetDefaultAssertHandler(); - -#else // !wxDEBUG_LEVEL - -// provide empty stubs in case assertions are completely disabled -// -// NB: can't use WXUNUSED() here as we're included from wx/defs.h before it is -// defined -inline wxAssertHandler_t wxSetAssertHandler(wxAssertHandler_t /* handler */) -{ - return NULL; -} - -inline void wxSetDefaultAssertHandler() { } - -#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL - -// simply a synonym for wxSetAssertHandler(NULL) -inline void wxDisableAsserts() { wxSetAssertHandler(NULL); } - -/* - A macro which disables asserts for applications compiled in release build. - - By default, wxIMPLEMENT_APP (or rather wxIMPLEMENT_WXWIN_MAIN) disable the - asserts in the applications compiled in the release build by calling this. - It does nothing if NDEBUG is not defined. - */ -#ifdef NDEBUG - #define wxDISABLE_ASSERTS_IN_RELEASE_BUILD() wxDisableAsserts() -#else - #define wxDISABLE_ASSERTS_IN_RELEASE_BUILD() -#endif - -#if wxDEBUG_LEVEL - -/* - wxOnAssert() is used by the debugging macros defined below. Different - overloads are needed because these macros can be used with or without wxT(). - - All of them are implemented in src/common/appcmn.cpp and unconditionally - call wxTheAssertHandler so the caller must check that it is non-NULL - (assert macros do it). - */ - -#if wxUSE_UNICODE - -// these overloads are the ones typically used by debugging macros: we have to -// provide wxChar* msg version because it's common to use wxT() in the macros -// and finally, we can't use const wx(char)* msg = NULL, because that would -// be ambiguous -// -// also notice that these functions can't be inline as wxString is not defined -// yet (and can't be as wxString code itself may use assertions) -extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond); - -extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const char *msg); - -extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxChar *msg) ; -#endif /* wxUSE_UNICODE */ - -// this version is for compatibility with wx 2.8 Unicode build only, we don't -// use it ourselves any more except in ANSI-only build in which case it is all -// we need -extern WXDLLIMPEXP_BASE void wxOnAssert(const wxChar *file, - int line, - const char *func, - const wxChar *cond, - const wxChar *msg = NULL); - -// these overloads work when msg passed to debug macro is a string and we -// also have to provide wxCStrData overload to resolve ambiguity which would -// otherwise arise from wxASSERT( s.c_str() ) -extern WXDLLIMPEXP_BASE void wxOnAssert(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg); - -extern WXDLLIMPEXP_BASE void wxOnAssert(const wxString& file, - int line, - const wxString& func, - const wxString& cond); - -extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxCStrData& msg); - -extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxString& msg); - -#endif // wxDEBUG_LEVEL - - -// ---------------------------------------------------------------------------- -// Debugging macros -// ---------------------------------------------------------------------------- - -/* - Assertion macros: check if the condition is true and call assert handler - (which will by default notify the user about failure) if it isn't. - - wxASSERT and wxFAIL macros as well as wxTrap() function do nothing at all - if wxDEBUG_LEVEL is 0 however they do check their conditions at default - debug level 1, unlike the previous wxWidgets versions. - - wxASSERT_LEVEL_2 is meant to be used for "expensive" asserts which should - normally be disabled because they have a big impact on performance and so - this macro only does anything if wxDEBUG_LEVEL >= 2. - */ -#if wxDEBUG_LEVEL - // wxTrap() can be used to break into the debugger unconditionally - // (assuming the program is running under debugger, of course). - // - // If possible, we prefer to define it as a macro rather than as a function - // to open the debugger at the position where we trapped and not inside the - // trap function itself which is not very useful. - #if wxCHECK_VISUALC_VERSION(7) - #define wxTrap() __debugbreak() +#ifndef __WXFUNCTION__ + /* TODO: add more compilers supporting __FUNCTION__ */ + #if defined(__DMC__) + /* + __FUNCTION__ happens to be not defined within class members + http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485 + */ + #define __WXFUNCTION__ (NULL) + #elif defined(__GNUC__) || \ + (defined(_MSC_VER) && _MSC_VER >= 1300) || \ + defined(__FUNCTION__) + #define __WXFUNCTION__ __FUNCTION__ #else - extern WXDLLIMPEXP_BASE void wxTrap(); - #endif // Win VisualC + /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */ + #define __WXFUNCTION__ (NULL) + #endif +#endif /* __WXFUNCTION__ already defined */ - // Global flag used to indicate that assert macros should call wxTrap(): it - // is set by the default assert handler if the user answers yes to the - // question of whether to trap. - extern WXDLLIMPEXP_DATA_BASE(bool) wxTrapInAssert; +/* ---------------------------------------------------------------------------- */ +/* Debugging macros */ +/* */ +/* All debugging macros rely on ASSERT() which in turn calls the user-defined */ +/* OnAssert() function. To keep things simple, it's called even when the */ +/* expression is true (i.e. everything is ok) and by default does nothing: just */ +/* returns the same value back. But if you redefine it to do something more sexy */ +/* (popping up a message box in your favourite GUI, sending you e-mail or */ +/* whatever) it will affect all ASSERTs, FAILs and CHECKs in your code. */ +/* */ +/* Warning: if you don't like advice on programming style, don't read */ +/* further! ;-) */ +/* */ +/* Extensive use of these macros is recommended! Remember that ASSERTs are */ +/* disabled in final build (without __WXDEBUG__ defined), so they add strictly */ +/* nothing to your program's code. On the other hand, CHECK macros do stay */ +/* even in release builds, but in general are not much of a burden, while */ +/* a judicious use of them might increase your program's stability. */ +/* ---------------------------------------------------------------------------- */ - // This macro checks if the condition is true and calls the assert handler - // with the provided message if it isn't and finally traps if the special - // flag indicating that it should do it was set by the handler. - // - // Notice that we don't use the handler return value for compatibility - // reasons (if we changed its return type, we'd need to change wxApp:: - // OnAssertFailure() too which would break user code overriding it), hence - // the need for the ugly global flag. +/* Macros which are completely disabled in 'release' mode */ +/* */ +/* NB: these functions are implemented in src/common/appcmn.cpp */ +#if defined(__cplusplus) && defined(__WXDEBUG__) + /* + This function is called whenever one of debugging macros fails (i.e. + condition is false in an assertion). To customize its behaviour, override + wxApp::OnAssert(). + + Parameters: + szFile and nLine - file name and line number of the ASSERT + szFunc - function name of the ASSERT, may be NULL (NB: ASCII) + szCond - text form of the condition which failed + szMsg - optional message explaining the reason + */ + extern void WXDLLIMPEXP_BASE wxOnAssert(const wxChar *szFile, + int nLine, + const char *szFunc, + const wxChar *szCond, + const wxChar *szMsg = NULL); + + /* call this function to break into the debugger unconditionally (assuming */ + /* the program is running under debugger, of course) */ + extern void WXDLLIMPEXP_BASE wxTrap(); + + /* generic assert macro */ + #define wxASSERT(cond) wxASSERT_MSG(cond, NULL) + + + /* assert with additional message explaining its cause */ + + /* compilers can give a warning (such as "possible unwanted ;") when using */ + /* the default definition of wxASSERT_MSG so we provide an alternative */ + #if defined(__MWERKS__) #define wxASSERT_MSG(cond, msg) \ - wxSTATEMENT_MACRO_BEGIN \ - if ( wxTheAssertHandler && !(cond) && \ - (wxOnAssert(__FILE__, __LINE__, __WXFUNCTION__, \ - #cond, msg), wxTrapInAssert) ) \ - { \ - wxTrapInAssert = false; \ - wxTrap(); \ - } \ - wxSTATEMENT_MACRO_END + if ( cond ) \ + {} \ + else \ + wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, wxT(#cond), msg) + #else + #define wxASSERT_MSG(cond, msg) \ + if ( cond ) \ + ; \ + else \ + wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, wxT(#cond), msg) + #endif - // a version without any additional message, don't use unless condition - // itself is fully self-explanatory - #define wxASSERT(cond) wxASSERT_MSG(cond, (const char*)NULL) + /* special form of assert: always triggers it (in debug mode) */ + #define wxFAIL wxFAIL_MSG(NULL) - // wxFAIL is a special form of assert: it always triggers (and so is - // usually used in normally unreachable code) - #define wxFAIL_COND_MSG(cond, msg) \ - wxSTATEMENT_MACRO_BEGIN \ - if ( wxTheAssertHandler && \ - (wxOnAssert(__FILE__, __LINE__, __WXFUNCTION__, \ - cond, msg), wxTrapInAssert) ) \ - { \ - wxTrapInAssert = false; \ - wxTrap(); \ - } \ - wxSTATEMENT_MACRO_END + /* FAIL with some message */ + #define wxFAIL_MSG(msg) wxFAIL_COND_MSG("wxAssertFailure", msg) - #define wxFAIL_MSG(msg) wxFAIL_COND_MSG("Assert failure", msg) - #define wxFAIL wxFAIL_MSG((const char*)NULL) -#else // !wxDEBUG_LEVEL - #define wxTrap() + /* FAIL with some message and a condition */ + #define wxFAIL_COND_MSG(cond, msg) \ + wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, wxT(cond), msg) - #define wxASSERT(cond) - #define wxASSERT_MSG(cond, msg) - #define wxFAIL - #define wxFAIL_MSG(msg) - #define wxFAIL_COND_MSG(cond, msg) -#endif // wxDEBUG_LEVEL + /* An assert helper used to avoid warning when testing constant expressions, */ + /* i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about */ + /* expression being always true, but not using */ + /* wxASSERT( wxAssertIsEqual(sizeof(int), 4) ) */ + /* */ + /* NB: this is made obsolete by wxCOMPILE_TIME_ASSERT() and should no */ + /* longer be used. */ + extern bool WXDLLIMPEXP_BASE wxAssertIsEqual(int x, int y); +#else + #define wxTrap() -#if wxDEBUG_LEVEL >= 2 - #define wxASSERT_LEVEL_2_MSG(cond, msg) wxASSERT_MSG(cond, msg) - #define wxASSERT_LEVEL_2(cond) wxASSERT(cond) -#else // wxDEBUG_LEVEL < 2 - #define wxASSERT_LEVEL_2_MSG(cond, msg) - #define wxASSERT_LEVEL_2(cond) + /* nothing to do in release mode (hopefully at this moment there are */ + /* no more bugs ;-) */ + #define wxASSERT(cond) + #define wxASSERT_MSG(cond, msg) + #define wxFAIL + #define wxFAIL_MSG(msg) + #define wxFAIL_COND_MSG(cond, msg) +#endif /* __WXDEBUG__ */ + +#ifdef __cplusplus + /* Use of wxFalse instead of false suppresses compiler warnings about testing */ + /* constant expression */ + extern WXDLLIMPEXP_DATA_BASE(const bool) wxFalse; #endif -// This is simply a wrapper for the standard abort() which is not available -// under all platforms. -// -// It isn't really debug-related but there doesn't seem to be any better place -// for it, so declare it here and define it in appbase.cpp, together with -// wxTrap(). -extern void WXDLLIMPEXP_BASE wxAbort(); +#define wxAssertFailure wxFalse + +/* NB: the following macros also work in release mode! */ /* - wxCHECK macros always check their conditions, setting debug level to 0 only - makes them silent in case of failure, otherwise -- including at default - debug level 1 -- they call the assert handler if the condition is false - - They are supposed to be used only in invalid situation: for example, an - invalid parameter (e.g. a NULL pointer) is passed to a function. Instead of - dereferencing it and causing core dump the function might use - - wxCHECK_RET( p != NULL, "pointer can't be NULL" ) + These macros must be used only in invalid situation: for example, an + invalid parameter (e.g. a NULL pointer) is passed to a function. Instead of + dereferencing it and causing core dump the function might try using + CHECK( p != NULL ) or CHECK( p != NULL, return LogError("p is NULL!!") ) */ -// the generic macro: takes the condition to check, the statement to be executed -// in case the condition is false and the message to pass to the assert handler -#define wxCHECK2_MSG(cond, op, msg) \ - if ( cond ) \ - {} \ - else \ - { \ - wxFAIL_COND_MSG(#cond, msg); \ - op; \ - } \ - struct wxDummyCheckStruct /* just to force a semicolon */ +/* check that expression is true, "return" if not (also FAILs in debug mode) */ +#define wxCHECK(cond, rc) wxCHECK_MSG(cond, rc, NULL) -// check which returns with the specified return code if the condition fails +/* as wxCHECK but with a message explaining why we fail */ #define wxCHECK_MSG(cond, rc, msg) wxCHECK2_MSG(cond, return rc, msg) -// check that expression is true, "return" if not (also FAILs in debug mode) -#define wxCHECK(cond, rc) wxCHECK_MSG(cond, rc, (const char*)NULL) +/* check that expression is true, perform op if not */ +#define wxCHECK2(cond, op) wxCHECK2_MSG(cond, op, NULL) -// check that expression is true, perform op if not -#define wxCHECK2(cond, op) wxCHECK2_MSG(cond, op, (const char*)NULL) +/* as wxCHECK2 but with a message explaining why we fail */ -// special form of wxCHECK2: as wxCHECK, but for use in void functions -// -// NB: there is only one form (with msg parameter) and it's intentional: -// there is no other way to tell the caller what exactly went wrong -// from the void function (of course, the function shouldn't be void -// to begin with...) +#ifdef __GNUC__ + #define wxFORCE_SEMICOLON typedef int wxDummyCheckInt + /* Note: old gcc versions (e.g. 2.8) give an internal compiler error */ + /* on a simple forward declaration, when used in a template */ + /* function, so rather use a dummy typedef which does work... */ +#else + #define wxFORCE_SEMICOLON struct wxDummyCheckStruct + /* Note2: however, some other compilers (notably Digital Mars */ + /* don't like multiple typedefs (even though the standard */ + /* does allow them), so use a forward declaration for non-gcc. */ +#endif +/* see comment near the definition of wxASSERT_MSG for the # if/else reason */ +#if defined(__MWERKS__) + #define wxCHECK2_MSG(cond, op, msg) \ + if ( cond ) \ + {} \ + else \ + { \ + wxFAIL_COND_MSG(#cond, msg); \ + op; \ + } \ + struct wxDummyCheckStruct /* just to force a semicolon */ +#else + #define wxCHECK2_MSG(cond, op, msg) \ + if ( cond ) \ + ; \ + else \ + { \ + wxFAIL_COND_MSG(#cond, msg); \ + op; \ + } \ + wxFORCE_SEMICOLON /* just to force a semicolon */ +#endif + +/* special form of wxCHECK2: as wxCHECK, but for use in void functions */ +/* */ +/* NB: there is only one form (with msg parameter) and it's intentional: */ +/* there is no other way to tell the caller what exactly went wrong */ +/* from the void function (of course, the function shouldn't be void */ +/* to begin with...) */ #define wxCHECK_RET(cond, msg) wxCHECK2_MSG(cond, return, msg) - -// ---------------------------------------------------------------------------- -// Compile time asserts -// -// Unlike the normal assert and related macros above which are checked during -// the program run-time the macros below will result in a compilation error if -// the condition they check is false. This is usually used to check the -// expressions containing sizeof()s which cannot be tested with the -// preprocessor. If you can use the #if's, do use them as you can give a more -// detailed error message then. -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- */ +/* Compile time asserts */ +/* */ +/* Unlike the normal assert and related macros above which are checked during */ +/* the program tun-time the macros below will result in a compilation error if */ +/* the condition they check is false. This is usually used to check the */ +/* expressions containing sizeof()s which cannot be tested with the */ +/* preprocessor. If you can use the #if's, do use them as you can give a more */ +/* detailed error message then. */ +/* ---------------------------------------------------------------------------- */ /* How this works (you don't have to understand it to be able to use the @@ -404,31 +263,13 @@ extern void WXDLLIMPEXP_BASE wxAbort(); It may be used both within a function and in the global scope. */ -#if defined(__WATCOMC__) +#if defined(__WATCOMC__) && defined(__cplusplus) /* avoid "unused symbol" warning */ #define wxCOMPILE_TIME_ASSERT(expr, msg) \ class wxMAKE_UNIQUE_ASSERT_NAME { \ unsigned int msg: expr; \ wxMAKE_UNIQUE_ASSERT_NAME() { wxUnusedVar(msg); } \ } -#elif defined( __VMS ) -namespace wxdebug{ - -// HP aCC cannot deal with missing names for template value parameters -template struct STATIC_ASSERTION_FAILURE; - -template <> struct STATIC_ASSERTION_FAILURE { enum { value = 1 }; }; - -// HP aCC cannot deal with missing names for template value parameters -template struct static_assert_test{}; - -} - #define WX_JOIN( X, Y ) X##Y - #define WX_STATIC_ASSERT_BOOL_CAST(x) (bool)(x) - #define wxCOMPILE_TIME_ASSERT(expr, msg) \ - typedef ::wxdebug::static_assert_test<\ - sizeof(::wxdebug::STATIC_ASSERTION_FAILURE< WX_STATIC_ASSERT_BOOL_CAST( expr ) >)>\ - WX_JOIN(wx_static_assert_typedef_, __LINE__) #else #define wxCOMPILE_TIME_ASSERT(expr, msg) \ struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; } @@ -444,53 +285,32 @@ template struct static_assert_test{}; #define wxCOMPILE_TIME_ASSERT2(expr, msg, text) \ struct wxMAKE_UNIQUE_ASSERT_NAME2(text) { unsigned int msg: expr; } -// helpers for wxCOMPILE_TIME_ASSERT below, for private use only +/* helpers for wxCOMPILE_TIME_ASSERT below, for private use only */ #define wxMAKE_BITSIZE_MSG(type, size) type ## SmallerThan ## size ## Bits -// a special case of compile time assert: check that the size of the given type -// is at least the given number of bits +/* a special case of compile time assert: check that the size of the given type */ +/* is at least the given number of bits */ #define wxASSERT_MIN_BITSIZE(type, size) \ wxCOMPILE_TIME_ASSERT(sizeof(type) * CHAR_BIT >= size, \ wxMAKE_BITSIZE_MSG(type, size)) - -// ---------------------------------------------------------------------------- -// other miscellaneous debugger-related functions -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- */ +/* other miscellaneous debugger-related functions */ +/* ---------------------------------------------------------------------------- */ /* Return true if we're running under debugger. - Currently only really works under Win32 and just returns false elsewhere. + Currently this only really works under Win32 and Mac in CodeWarrior builds, + it always returns false in other cases. */ -#if defined(__WIN32__) - extern bool WXDLLIMPEXP_BASE wxIsDebuggerRunning(); -#else // !Mac - inline bool wxIsDebuggerRunning() { return false; } -#endif // Mac/!Mac +#ifdef __cplusplus + /* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */ + #if defined(__WXMAC__) || defined(__WIN32__) + extern bool WXDLLIMPEXP_BASE wxIsDebuggerRunning(); + #else /* !Mac */ + inline bool wxIsDebuggerRunning() { return false; } + #endif /* Mac/!Mac */ +#endif /* __cplusplus */ -// An assert helper used to avoid warning when testing constant expressions, -// i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about -// expression being always true, but not using -// wxASSERT( wxAssertIsEqual(sizeof(int), 4) ) -// -// NB: this is made obsolete by wxCOMPILE_TIME_ASSERT() and should no -// longer be used. -extern bool WXDLLIMPEXP_BASE wxAssertIsEqual(int x, int y); - -// Use of wxFalse instead of false suppresses compiler warnings about testing -// constant expression -extern WXDLLIMPEXP_DATA_BASE(const bool) wxFalse; - -#define wxAssertFailure wxFalse - -// This is similar to WXUNUSED() and useful for parameters which are only used -// in assertions. -#if wxDEBUG_LEVEL - #define WXUNUSED_UNLESS_DEBUG(param) param -#else - #define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param) -#endif - - -#endif // _WX_DEBUG_H_ +#endif /* _WX_DEBUG_H_ */ diff --git a/Source/3rd Party/wx/include/wx/debugrpt.h b/Source/3rd Party/wx/include/wx/debugrpt.h deleted file mode 100644 index 421bede97..000000000 --- a/Source/3rd Party/wx/include/wx/debugrpt.h +++ /dev/null @@ -1,247 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/debugrpt.h -// Purpose: declaration of wxDebugReport class -// Author: Vadim Zeitlin -// Created: 2005-01-17 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DEBUGRPT_H_ -#define _WX_DEBUGRPT_H_ - -#include "wx/defs.h" - -#if wxUSE_DEBUGREPORT && wxUSE_XML - -#include "wx/string.h" -#include "wx/arrstr.h" - -class WXDLLIMPEXP_FWD_XML wxXmlNode; - -// ---------------------------------------------------------------------------- -// wxDebugReport: generate a debug report, processing is done in derived class -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_QA wxDebugReport -{ -public: - // this is used for the functions which may report either the current state - // or the state during the last (fatal) exception - enum Context { Context_Current, Context_Exception }; - - - // ctor creates a temporary directory where we create the files which will - // be included in the report, use IsOk() to check for errors - wxDebugReport(); - - // dtor normally destroys the temporary directory created in the ctor (with - // all the files it contains), call Reset() to prevent this from happening - virtual ~wxDebugReport(); - - // return the name of the directory used for this report - const wxString& GetDirectory() const { return m_dir; } - - // return true if the object was successfully initialized - bool IsOk() const { return !GetDirectory().empty(); } - - // reset the directory name we use, the object can't be used any more after - // this as it becomes invalid/uninitialized - void Reset() { m_dir.clear(); } - - - // add another file to the report: the file must already exist, its name - // can be either absolute in which case it is copied to the debug report - // directory or relative to GetDirectory() - // - // description is shown to the user in the report summary - virtual void AddFile(const wxString& filename, const wxString& description); - - // convenience function: write the given text to a file with the given name - // and then add it to the report (the difference with AddFile() is that the - // file will be created by this function and doesn't have to already exist) - bool AddText(const wxString& filename, - const wxString& text, - const wxString& description); - -#if wxUSE_STACKWALKER - // add an XML file containing the current or exception context and the - // stack trace - bool AddCurrentContext() { return AddContext(Context_Current); } - bool AddExceptionContext() { return AddContext(Context_Exception); } - virtual bool AddContext(Context ctx); -#endif - -#if wxUSE_CRASHREPORT - // add a file with crash report - bool AddCurrentDump() { return AddDump(Context_Current); } - bool AddExceptionDump() { return AddDump(Context_Exception); } - virtual bool AddDump(Context ctx); -#endif // wxUSE_CRASHREPORT - - // add all available information to the report - void AddAll(Context context = Context_Exception); - - - // process this report: the base class simply notifies the user that the - // report has been generated, this is usually not enough -- instead you - // should override this method to do something more useful to you - bool Process(); - - // get the name used as base name for various files, by default - // wxApp::GetName() - virtual wxString GetReportName() const; - - // get the files in this report - size_t GetFilesCount() const { return m_files.GetCount(); } - bool GetFile(size_t n, wxString *name, wxString *desc) const; - - // remove the file from report: this is used by wxDebugReportPreview to - // allow the user to remove files potentially containing private - // information from the report - void RemoveFile(const wxString& name); - -protected: -#if wxUSE_STACKWALKER - // used by AddContext() - virtual bool DoAddSystemInfo(wxXmlNode *nodeSystemInfo); - virtual bool DoAddLoadedModules(wxXmlNode *nodeModules); - virtual bool DoAddExceptionInfo(wxXmlNode *nodeContext); - virtual void DoAddCustomContext(wxXmlNode * WXUNUSED(nodeRoot)) { } -#endif - - // used by Process() - virtual bool DoProcess(); - -private: - // name of the report directory - wxString m_dir; - - // the arrays of files in this report and their descriptions - wxArrayString m_files, - m_descriptions; -}; - -#if wxUSE_ZIPSTREAM - -// ---------------------------------------------------------------------------- -// wxDebugReportCompress: compress all files of this debug report in a .ZIP -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_QA wxDebugReportCompress : public wxDebugReport -{ -public: - wxDebugReportCompress() { } - - // you can optionally specify the directory and/or name of the file where - // the debug report should be generated, a default location under the - // directory containing temporary files will be used if you don't - // - // both of these functions should be called before Process()ing the report - // if they're called at all - void SetCompressedFileDirectory(const wxString& dir); - void SetCompressedFileBaseName(const wxString& name); - - // returns the full path of the compressed file (empty if creation failed) - const wxString& GetCompressedFileName() const { return m_zipfile; } - -protected: - virtual bool DoProcess(); - -private: - // user-specified file directory/base name, use defaults if empty - wxString m_zipDir, - m_zipName; - - // full path to the ZIP file we created - wxString m_zipfile; -}; - -// ---------------------------------------------------------------------------- -// wxDebugReportUploader: uploads compressed file using HTTP POST request -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_QA wxDebugReportUpload : public wxDebugReportCompress -{ -public: - // this class will upload the compressed file created by its base class to - // an HTML multipart/form-data form at the specified address - // - // the URL is the base address, input is the name of the "type=file" - // control on the form used for the file name and action is the value of - // the form action field - wxDebugReportUpload(const wxString& url, - const wxString& input, - const wxString& action, - const wxString& curl = wxT("curl")); - -protected: - virtual bool DoProcess(); - - // this function may be overridden in a derived class to show the output - // from curl: this may be an HTML page or anything else that the server - // returned - // - // return value becomes the return value of Process() - virtual bool OnServerReply(const wxArrayString& WXUNUSED(reply)) - { - return true; - } - -private: - // the full URL to use with HTTP POST request - wxString m_uploadURL; - - // the name of the input field containing the file name in the form at - // above URL - wxString m_inputField; - - // the curl command (by default it is just "curl" but could be full path to - // curl or a wrapper script with curl-compatible syntax) - wxString m_curlCmd; -}; - -#endif // wxUSE_ZIPSTREAM - - -// ---------------------------------------------------------------------------- -// wxDebugReportPreview: presents the debug report to the user and allows him -// to veto report entirely or remove some parts of it -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_QA wxDebugReportPreview -{ -public: - // ctor is trivial - wxDebugReportPreview() { } - - // present the report to the user and allow him to modify it by removing - // some or all of the files and, potentially, adding some notes - // - // return true if the report should be processed or false if the user chose - // to cancel report generation or removed all files from it - virtual bool Show(wxDebugReport& dbgrpt) const = 0; - - // dtor is trivial as well but should be virtual for a base class - virtual ~wxDebugReportPreview() { } -}; - -#if wxUSE_GUI - -// ---------------------------------------------------------------------------- -// wxDebugReportPreviewStd: standard debug report preview window -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_QA wxDebugReportPreviewStd : public wxDebugReportPreview -{ -public: - wxDebugReportPreviewStd() { } - - virtual bool Show(wxDebugReport& dbgrpt) const; -}; - -#endif // wxUSE_GUI - -#endif // wxUSE_DEBUGREPORT && wxUSE_XML - -#endif // _WX_DEBUGRPT_H_ diff --git a/Source/3rd Party/wx/include/wx/defs.h b/Source/3rd Party/wx/include/wx/defs.h index 7bb9fec52..6e3fd8765 100644 --- a/Source/3rd Party/wx/include/wx/defs.h +++ b/Source/3rd Party/wx/include/wx/defs.h @@ -4,6 +4,7 @@ * Author: Julian Smart and others * Modified by: Ryan Norton (Converted to C) * Created: 01/02/97 + * RCS-ID: $Id: defs.h 66923 2011-02-16 22:37:48Z JS $ * Copyright: (c) Julian Smart * Licence: wxWindows licence */ @@ -13,13 +14,6 @@ #ifndef _WX_DEFS_H_ #define _WX_DEFS_H_ -/* - NOTE: this symbol will be replaced with "WXWIN_COMPATIBILITY_3_0" as soon - as the development branch for 3.1 is created - */ -#define FUTURE_WXWIN_COMPATIBILITY_3_0 1 -#define wxDEPRECATED_FUTURE( x ) x - /* ---------------------------------------------------------------------------- */ /* compiler and OS identification */ /* ---------------------------------------------------------------------------- */ @@ -29,16 +23,18 @@ #ifdef __cplusplus /* Make sure the environment is set correctly */ # if defined(__WXMSW__) && defined(__X__) -# error "Target can't be both X and MSW" +# error "Target can't be both X and Windows" +# elif defined(__WXMSW__) && defined(__PALMOS__) +# error "Target can't be both PalmOS and Windows" # elif !defined(__WXMOTIF__) && \ !defined(__WXMSW__) && \ + !defined(__WXPALMOS__)&& \ !defined(__WXGTK__) && \ !defined(__WXPM__) && \ - !defined(__WXOSX_CARBON__) && \ - !defined(__WXOSX_COCOA__) && \ - !defined(__WXOSX_IPHONE__) && \ + !defined(__WXMAC__) && \ !defined(__WXCOCOA__) && \ !defined(__X__) && \ + !defined(__WXMGL__) && \ !defined(__WXDFB__) && \ !defined(__WXX11__) && \ wxUSE_GUI @@ -63,6 +59,9 @@ #define __WXBASE__ #endif +/* include the feature test macros */ +#include "wx/features.h" + /* suppress some Visual C++ warnings */ #ifdef __VISUALC__ /* the only "real" warning here is 4244 but there are just too many of them */ @@ -73,89 +72,43 @@ # pragma warning(disable:4355) /* 'this' used in base member initializer list */ # pragma warning(disable:4511) /* copy ctor couldn't be generated */ # pragma warning(disable:4512) /* operator=() couldn't be generated */ -# pragma warning(disable:4514) /* unreferenced inline func has been removed */ # pragma warning(disable:4710) /* function not inlined */ - /* - TODO: this warning should really be enabled as it can be genuinely - useful, check where does it occur in wxWidgets - */ - #pragma warning(disable: 4127) /* conditional expression is constant */ - - /* There are too many false positivies for this one, particularly when - using templates like wxVector */ - /* class 'foo' needs to have dll-interface to be used by clients of - class 'bar'" */ -# pragma warning(disable:4251) - - /* - This is a similar warning which occurs when deriving from standard - containers. MSDN even mentions that it can be ignored in this case - (albeit only in debug build while the warning is the same in release - too and seems equally harmless). - */ -#if wxUSE_STD_CONTAINERS -# pragma warning(disable:4275) -#endif /* wxUSE_STD_CONTAINERS */ - -# ifdef __VISUALC5__ /* For VC++ 5.0 for release mode, the warning 'C4702: unreachable code */ /* is buggy, and occurs for code that does actually get executed */ -# ifndef __WXDEBUG__ +# if !defined __WXDEBUG__ && __VISUALC__ <= 1100 # pragma warning(disable:4702) /* unreachable code */ # endif - /* The VC++ 5.0 warning 'C4003: not enough actual parameters for macro' * is incompatible with the wxWidgets headers since it is given when * parameters are empty but not missing. */ +# if __VISUALC__ <= 1100 # pragma warning(disable:4003) /* not enough actual parameters for macro */ # endif - /* - VC6 insists on complaining about - - return type for 'wxVector::reverse_iterator::operator ->' is 'T **' - (ie; not a UDT or reference to a UDT. Will produce errors if applied - using infix notation) - - which is perfectly fine because template classes do routinely define - operators which don't make sense for all template parameter values - (besides this warning was removed in subsequent versions). - */ - #ifdef __VISUALC6__ - #pragma warning(disable: 4284) - #endif /* VC6 */ - - /* - When compiling with VC++ 7 /Wp64 option we get thousands of warnings for - conversion from size_t to int or long. Some precious few of them might - be worth looking into but unfortunately it seems infeasible to fix all - the other, harmless ones (e.g. inserting static_cast(s.length()) - everywhere this method is used though we are quite sure that using >4GB - strings is a bad idea anyhow) so just disable it globally for now. - */ - #if wxCHECK_VISUALC_VERSION(7) - /* conversion from 'size_t' to 'unsigned long', possible loss of data */ - #pragma warning(disable:4267) - #endif /* VC++ 7 or later */ - /* VC++ 8 gives a warning when using standard functions such as sprintf, localtime, ... -- stop this madness, unless the user had already done it */ - #if wxCHECK_VISUALC_VERSION(8) + #if __VISUALC__ >= 1400 #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif #ifndef _CRT_NON_CONFORMING_SWPRINTFS #define _CRT_NON_CONFORMING_SWPRINTFS 1 #endif - #ifndef _SCL_SECURE_NO_WARNINGS - #define _SCL_SECURE_NO_WARNINGS 1 - #endif #endif /* VC++ 8 */ #endif /* __VISUALC__ */ +/* suppress some Salford C++ warnings */ +#ifdef __SALFORDC__ +# pragma suppress 353 /* Possible nested comments */ +# pragma suppress 593 /* Define not used */ +# pragma suppress 61 /* enum has no name (doesn't suppress!) */ +# pragma suppress 106 /* unnamed, unused parameter */ +# pragma suppress 571 /* Virtual function hiding */ +#endif /* __SALFORDC__ */ + /* suppress some Borland C++ warnings */ #ifdef __BORLANDC__ # pragma warn -inl /* Functions containing reserved words and certain constructs are not expanded inline */ @@ -174,18 +127,6 @@ # define wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING(name) #endif -/* - Clang Support - */ - -#ifndef WX_HAS_CLANG_FEATURE -# ifndef __has_feature -# define WX_HAS_CLANG_FEATURE(x) 0 -# else -# define WX_HAS_CLANG_FEATURE(x) __has_feature(x) -# endif -#endif - /* ---------------------------------------------------------------------------- */ /* wxWidgets version and compatibility defines */ /* ---------------------------------------------------------------------------- */ @@ -214,16 +155,73 @@ #define va_list __gnuc_va_list #endif /* HP-UX */ -/* Prevents conflicts between sys/types.h and winsock.h with Cygwin, */ -/* when using Windows sockets. */ -#if defined(__CYGWIN__) && defined(__WINDOWS__) -#define __USE_W32_SOCKETS -#endif - /* ---------------------------------------------------------------------------- */ /* check for native bool type and TRUE/FALSE constants */ /* ---------------------------------------------------------------------------- */ +/* Add more tests here for Windows compilers that already define bool */ +/* (under Unix, configure tests for this) */ +#ifndef HAVE_BOOL + #if defined( __MWERKS__ ) + #if (__MWERKS__ >= 0x1000) && __option(bool) + #define HAVE_BOOL + #endif + #elif defined(__APPLE__) && defined(__APPLE_CC__) + /* Apple bundled gcc supports bool */ + #define HAVE_BOOL + #elif defined(__VISUALC__) && (__VISUALC__ == 1020) + /* in VC++ 4.2 the bool keyword is reserved (hence can't be typedefed) */ + /* but not implemented, so we must #define it */ + #define bool unsigned int + #elif defined(__VISUALC__) && (__VISUALC__ == 1010) + /* For VisualC++ 4.1, we need to define */ + /* bool as something between 4.0 & 5.0... */ + typedef unsigned int wxbool; + #define bool wxbool + #define HAVE_BOOL + #elif defined(__VISUALC__) && (__VISUALC__ > 1020) + /* VC++ supports bool since 4.2 */ + #define HAVE_BOOL + #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x500) + /* Borland 5.0+ supports bool */ + #define HAVE_BOOL + #elif wxCHECK_WATCOM_VERSION(1,0) + /* Watcom 11+ supports bool */ + #define HAVE_BOOL + #elif defined(__DIGITALMARS__) + /* DigitalMars supports bool */ + #define HAVE_BOOL + #elif defined(__GNUWIN32__) || defined(__MINGW32__) || defined(__CYGWIN__) + /* Cygwin supports bool */ + #define HAVE_BOOL + #elif defined(__VISAGECPP__) + #if __IBMCPP__ < 400 + typedef unsigned long bool; + #define true ((bool)1) + #define false ((bool)0) + #endif + #define HAVE_BOOL + #endif /* compilers */ +#endif /* HAVE_BOOL */ + +#if !defined(__MWERKS__) || !defined(true) +#if !defined(HAVE_BOOL) && !defined(bool) && !defined(VMS) + /* NB: of course, this doesn't replace the standard type, because, for */ + /* example, overloading based on bool/int parameter doesn't work and */ + /* so should be avoided in portable programs */ + typedef unsigned int bool; +#endif /* bool */ + +/* deal with TRUE/true stuff: we assume that if the compiler supports bool, it */ +/* supports true/false as well and that, OTOH, if it does _not_ support bool, */ +/* it doesn't support these keywords (this is less sure, in particular VC++ */ +/* 4.x could be a problem here) */ +#ifndef HAVE_BOOL + #define true ((bool)1) + #define false ((bool)0) +#endif +#endif + /* for backwards compatibility, also define TRUE and FALSE */ /* */ /* note that these definitions should work both in C++ and C code, so don't */ @@ -238,6 +236,12 @@ typedef short int WXTYPE; +/* special care should be taken with this type under Windows where the real */ +/* window id is unsigned, so we must always do the cast before comparing them */ +/* (or else they would be always different!). Using wxGetWindowId() which does */ +/* the cast itself is recommended. Note that this type can't be unsigned */ +/* because wxID_ANY == -1 is a valid (and largely used) value for window id. */ +typedef int wxWindowID; /* ---------------------------------------------------------------------------- */ /* other feature tests */ @@ -263,9 +267,10 @@ typedef short int WXTYPE; #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520) /* BC++ 4.52 doesn't support explicit, CBuilder 1 does */ #define HAVE_EXPLICIT - #elif defined(__DIGITALMARS__) + #elif defined(__MWERKS__) && (__MWERKS__ >= 0x2400) + /* Metrowerks CW6 or higher has explicit */ #define HAVE_EXPLICIT - #elif defined(__WATCOMC__) + #elif defined(__DIGITALMARS__) #define HAVE_EXPLICIT #endif #endif /* !HAVE_EXPLICIT */ @@ -276,10 +281,51 @@ typedef short int WXTYPE; #define wxEXPLICIT #endif /* HAVE_EXPLICIT/!HAVE_EXPLICIT */ -/* these macros are obsolete, use the standard C++ casts directly now */ -#define wx_static_cast(t, x) static_cast(x) -#define wx_const_cast(t, x) const_cast(x) -#define wx_reinterpret_cast(t, x) reinterpret_cast(x) +/* check for static/const_cast<>() (we don't use the other ones for now) */ +#ifndef HAVE_CXX_CASTS + #if defined(__VISUALC__) && (__VISUALC__ >= 1100) + /* VC++ 6.0 and 5.0 have C++ casts (what about earlier versions?) */ + #define HAVE_CXX_CASTS + #elif defined(__MINGW32__) || defined(__CYGWIN32__) + #if wxCHECK_GCC_VERSION(2, 95) + /* GCC 2.95 has C++ casts, what about earlier versions? */ + #define HAVE_CXX_CASTS + #endif + #endif +#endif /* !HAVE_CXX_CASTS */ + +#ifdef HAVE_CXX_CASTS + #ifndef HAVE_CONST_CAST + #define HAVE_CONST_CAST + #endif + #ifndef HAVE_REINTERPRET_CAST + #define HAVE_REINTERPRET_CAST + #endif + #ifndef HAVE_STATIC_CAST + #define HAVE_STATIC_CAST + #endif + #ifndef HAVE_DYNAMIC_CAST + #define HAVE_DYNAMIC_CAST + #endif +#endif /* HAVE_CXX_CASTS */ + +#ifdef HAVE_STATIC_CAST + #define wx_static_cast(t, x) static_cast(x) +#else + #define wx_static_cast(t, x) ((t)(x)) +#endif + +#ifdef HAVE_CONST_CAST + #define wx_const_cast(t, x) const_cast(x) +#else + #define wx_const_cast(t, x) ((t)(x)) +#endif + +#ifdef HAVE_REINTERPRET_CAST + #define wx_reinterpret_cast(t, x) reinterpret_cast(x) +#else + #define wx_reinterpret_cast(t, x) ((t)(x)) +#endif /* This one is a wx invention: like static cast but used when we intentionally @@ -295,8 +341,6 @@ typedef short int WXTYPE; #pragma warning(disable: 1682) /* conversion from "X" to "T" may lose significant bits */ #pragma warning(disable: 810) - /* non-pointer conversion from "foo" to "bar" may lose significant bits */ - #pragma warning(disable: 2259) return x; @@ -310,10 +354,8 @@ typedef short int WXTYPE; inline T wx_truncate_cast_impl(X x) { #pragma warning(push) - /* conversion from 'size_t' to 'type', possible loss of data */ + /* conversion from 'X' to 'T', possible loss of data */ #pragma warning(disable: 4267) - /* conversion from 'type1' to 'type2', possible loss of data */ - #pragma warning(disable: 4242) return x; @@ -332,7 +374,8 @@ typedef short int WXTYPE; #if defined(__VISUALC__) && (__VISUALC__ >= 1100) /* VC++ 6.0 and 5.0 have std::wstring (what about earlier versions?) */ #define HAVE_STD_WSTRING - #elif defined(__MINGW32__) && wxCHECK_GCC_VERSION(3, 3) + #elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \ + && wxCHECK_GCC_VERSION(3, 3) /* GCC 3.1 has std::wstring; 3.0 never was in MinGW, 2.95 hasn't it */ #define HAVE_STD_WSTRING #endif @@ -351,45 +394,6 @@ typedef short int WXTYPE; #endif #endif -#ifndef HAVE_TR1_TYPE_TRAITS - #if defined(__VISUALC__) && (_MSC_FULL_VER >= 150030729) - #define HAVE_TR1_TYPE_TRAITS - #endif -#endif - -#if defined(__has_include) - /* - Notice that we trust our configure tests more than __has_include(), - notably the latter can return true even if the header exists but isn't - actually usable, as it happens with in non C++11 mode. - So if configure already detected at least one working alternative, - just use it. - */ - #if !defined(HAVE_TYPE_TRAITS) && !defined(HAVE_TR1_TYPE_TRAITS) - #if __has_include() - #define HAVE_TYPE_TRAITS - #elif __has_include() - #define HAVE_TR1_TYPE_TRAITS - #endif - #endif - - #if !defined(HAVE_STD_UNORDERED_MAP) && !defined(HAVE_TR1_UNORDERED_MAP) - #if __has_include() - #define HAVE_STD_UNORDERED_MAP - #elif __has_include() - #define HAVE_TR1_UNORDERED_MAP - #endif - #endif - - #if !defined(HAVE_STD_UNORDERED_SET) && !defined(HAVE_TR1_UNORDERED_SET) - #if __has_include() - #define HAVE_STD_UNORDERED_SET - #elif __has_include() - #define HAVE_TR1_UNORDERED_SET - #endif - #endif -#endif /* defined(__has_include) */ - /* provide replacement for C99 va_copy() if the compiler doesn't have it */ /* could be already defined by configure or the user */ @@ -433,51 +437,6 @@ typedef short int WXTYPE; #endif /* va_copy/!va_copy */ #endif /* wxVaCopy */ -#ifndef HAVE_WOSTREAM - /* - Mingw <= 3.4 and all versions of Cygwin don't have std::wostream - */ - #if (defined(__MINGW32__) && !wxCHECK_GCC_VERSION(4, 0)) || \ - defined(__CYGWIN__) - #define wxNO_WOSTREAM - #endif - - /* VC++ doesn't have it in the old iostream library */ - #if defined(__VISUALC__) && wxUSE_IOSTREAMH - #define wxNO_WOSTREAM - #endif - - #ifndef wxNO_WOSTREAM - #define HAVE_WOSTREAM - #endif - - #undef wxNO_WOSTREAM -#endif /* HAVE_WOSTREAM */ - -/* ---------------------------------------------------------------------------- */ -/* other C++ features */ -/* ---------------------------------------------------------------------------- */ - -#ifndef HAVE_PARTIAL_SPECIALIZATION - /* be optimistic by default */ - #define HAVE_PARTIAL_SPECIALIZATION -#endif - -#ifdef __VISUALC__ - #if __VISUALC__ < 1310 - #undef HAVE_PARTIAL_SPECIALIZATION - #endif -#endif /* __VISUALC__ */ - - -#ifndef HAVE_TEMPLATE_OVERLOAD_RESOLUTION - /* assume the compiler can use type or const expressions as template - arguments if it supports partial specialization -- except if it's a - Borland one which can't */ - #if defined(HAVE_PARTIAL_SPECIALIZATION) && !defined(__BORLANDC__) - #define HAVE_TEMPLATE_OVERLOAD_RESOLUTION - #endif /* (HAVE_PARTIAL_SPECIALIZATION) && !defined(__BORLANDC__) */ -#endif /* !defined(HAVE_TEMPLATE_OVERLOAD_RESOLUTION) */ /* ---------------------------------------------------------------------------- */ /* portable calling conventions macros */ @@ -497,7 +456,7 @@ typedef short int WXTYPE; #define wxSTDCALL #endif /* platform */ -/* LINKAGEMODE mode is empty for everything except OS/2 */ +/* LINKAGEMODE mode is empty for everyting except OS/2 */ #ifndef LINKAGEMODE #define LINKAGEMODE #endif /* LINKAGEMODE */ @@ -535,200 +494,48 @@ typedef short int WXTYPE; /* ---------------------------------------------------------------------------- */ /* Printf-like attribute definitions to obtain warnings with GNU C/C++ */ -#ifndef WX_ATTRIBUTE_PRINTF +#ifndef ATTRIBUTE_PRINTF # if defined(__GNUC__) && !wxUSE_UNICODE -# define WX_ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) +# define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) # else -# define WX_ATTRIBUTE_PRINTF(m, n) +# define ATTRIBUTE_PRINTF(m, n) # endif -# define WX_ATTRIBUTE_PRINTF_1 WX_ATTRIBUTE_PRINTF(1, 2) -# define WX_ATTRIBUTE_PRINTF_2 WX_ATTRIBUTE_PRINTF(2, 3) -# define WX_ATTRIBUTE_PRINTF_3 WX_ATTRIBUTE_PRINTF(3, 4) -# define WX_ATTRIBUTE_PRINTF_4 WX_ATTRIBUTE_PRINTF(4, 5) -# define WX_ATTRIBUTE_PRINTF_5 WX_ATTRIBUTE_PRINTF(5, 6) -#endif /* !defined(WX_ATTRIBUTE_PRINTF) */ +# define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2) +# define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3) +# define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4) +# define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5) +# define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6) +#endif /* !defined(ATTRIBUTE_PRINTF) */ -#ifndef WX_ATTRIBUTE_NORETURN -# if WX_HAS_CLANG_FEATURE(attribute_analyzer_noreturn) -# define WX_ATTRIBUTE_NORETURN __attribute__((analyzer_noreturn)) -# elif defined( __GNUC__ ) -# define WX_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) -# elif wxCHECK_VISUALC_VERSION(7) -# define WX_ATTRIBUTE_NORETURN __declspec(noreturn) -# else -# define WX_ATTRIBUTE_NORETURN -# endif -#endif - -#if defined(__GNUC__) - #define WX_ATTRIBUTE_UNUSED __attribute__ ((unused)) -#else - #define WX_ATTRIBUTE_UNUSED -#endif - -/* - Macros for marking functions as being deprecated. - - The preferred macro in the new code is wxDEPRECATED_MSG() which allows to - explain why is the function deprecated. Almost all the existing code uses - the older wxDEPRECATED() or its variants currently, but this will hopefully - change in the future. - */ - -/* The basic compiler-specific construct to generate a deprecation warning. */ -#ifdef __clang__ - #define wxDEPRECATED_DECL __attribute__((deprecated)) -#elif wxCHECK_GCC_VERSION(3, 1) - #define wxDEPRECATED_DECL __attribute__((deprecated)) +/* Macro to issue warning when using deprecated functions with gcc3 or MSVC7: */ +#if wxCHECK_GCC_VERSION(3, 1) + #define wxDEPRECATED(x) x __attribute__ ((deprecated)) #elif defined(__VISUALC__) && (__VISUALC__ >= 1300) - #define wxDEPRECATED_DECL __declspec(deprecated) + #define wxDEPRECATED(x) __declspec(deprecated) x #else - #define wxDEPRECATED_DECL + #define wxDEPRECATED(x) x #endif -/* - Macro taking the deprecation message. It applies to the next declaration. - - If the compiler doesn't support showing the message, this degrades to a - simple wxDEPRECATED(), i.e. at least gives a warning, if possible. - */ -#if defined(__clang__) && defined(__has_extension) - #if __has_extension(attribute_deprecated_with_message) - #define wxDEPRECATED_MSG(msg) __attribute__((deprecated(msg))) - #else - #define wxDEPRECATED_MSG(msg) __attribute__((deprecated)) - #endif -#elif wxCHECK_GCC_VERSION(4, 5) - #define wxDEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -#elif wxCHECK_VISUALC_VERSION(8) - #define wxDEPRECATED_MSG(msg) __declspec(deprecated("deprecated: " msg)) -#else - #define wxDEPRECATED_MSG(msg) wxDEPRECATED_DECL -#endif - -/* - Macro taking the declaration that it deprecates. Prefer to use - wxDEPRECATED_MSG() instead as it's simpler (wrapping the entire declaration - makes the code unclear) and allows to specify the explanation. - */ -#define wxDEPRECATED(x) wxDEPRECATED_DECL x - -#if defined(__GNUC__) && !wxCHECK_GCC_VERSION(3, 4) - /* - We need to add dummy "inline" to allow gcc < 3.4 to handle the - deprecation attribute on the constructors. - */ - #define wxDEPRECATED_CONSTRUCTOR(x) wxDEPRECATED( inline x) -#else - #define wxDEPRECATED_CONSTRUCTOR(x) wxDEPRECATED(x) -#endif - -/* - Macro which marks the function as being deprecated but also defines it - inline. - - Currently it's defined in the same trivial way in all cases but it could - need a special definition with some other compilers in the future which - explains why do we have it. - */ -#define wxDEPRECATED_INLINE(func, body) wxDEPRECATED(func) { body } - -/* - A macro to define a simple deprecated accessor. - */ -#define wxDEPRECATED_ACCESSOR(func, what) wxDEPRECATED_INLINE(func, return what;) - -/* - Special variant of the macro above which should be used for the functions - which are deprecated but called by wx itself: this often happens with - deprecated virtual functions which are called by the library. - */ -#ifdef WXBUILDING -# define wxDEPRECATED_BUT_USED_INTERNALLY(x) x -#else -# define wxDEPRECATED_BUT_USED_INTERNALLY(x) wxDEPRECATED(x) -#endif - -/* - Macros to suppress and restore gcc warnings, requires g++ >= 4.6 and don't - do anything otherwise. - - Example of use: - - wxGCC_WARNING_SUPPRESS(float-equal) - inline bool wxIsSameDouble(double x, double y) { return x == y; } - wxGCC_WARNING_RESTORE(float-equal) - */ -#if wxCHECK_GCC_VERSION(4, 6) -# define wxGCC_WARNING_SUPPRESS(x) \ - _Pragma (wxSTRINGIZE(GCC diagnostic push)) \ - _Pragma (wxSTRINGIZE(GCC diagnostic ignored wxSTRINGIZE(wxCONCAT(-W,x)))) -# define wxGCC_WARNING_RESTORE(x) \ - _Pragma (wxSTRINGIZE(GCC diagnostic pop)) -#else /* gcc < 4.6 or not gcc at all */ -# define wxGCC_WARNING_SUPPRESS(x) -# define wxGCC_WARNING_RESTORE(x) -#endif - -/* - Combination of the two variants above: should be used for deprecated - functions which are defined inline and are used by wxWidgets itself. - */ -#ifdef WXBUILDING -# define wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(func, body) func { body } -#else -# define wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(func, body) \ - wxDEPRECATED(func) { body } -#endif +/* everybody gets the assert and other debug macros */ +#include "wx/debug.h" /* NULL declaration: it must be defined as 0 for C++ programs (in particular, */ /* it must not be defined as "(void *)0" which is standard for C but completely */ /* breaks C++ code) */ -#if !defined(__HANDHELDPC__) +#ifndef __HANDHELDPC__ #include #endif -#ifdef __cplusplus +/* delete pointer if it is not NULL and NULL it afterwards */ +/* (checking that it's !NULL before passing it to delete is just a */ +/* a question of style, because delete will do it itself anyhow, but it might */ +/* be considered as an error by some overzealous debugging implementations of */ +/* the library, so we do it ourselves) */ +#define wxDELETE(p) if ( (p) != NULL ) { delete p; p = NULL; } -// everybody gets the assert and other debug macros -#include "wx/debug.h" - - // delete pointer if it is not NULL and NULL it afterwards - template - inline void wxDELETE(T*& ptr) - { - typedef char TypeIsCompleteCheck[sizeof(T)] WX_ATTRIBUTE_UNUSED; - - if ( ptr != NULL ) - { - delete ptr; - ptr = NULL; - } - } - - // delete an array and NULL it (see comments above) - template - inline void wxDELETEA(T*& ptr) - { - typedef char TypeIsCompleteCheck[sizeof(T)] WX_ATTRIBUTE_UNUSED; - - if ( ptr != NULL ) - { - delete [] ptr; - ptr = NULL; - } - } - - // trivial implementation of std::swap() for primitive types - template - inline void wxSwap(T& first, T& second) - { - T tmp(first); - first = second; - second = tmp; - } -#endif /*__cplusplus*/ +/* delete an array and NULL it (see comments above) */ +#define wxDELETEA(p) if ( (p) ) { delete [] (p); p = NULL; } /* size of statically declared array */ #define WXSIZEOF(array) (sizeof(array)/sizeof(array[0])) @@ -737,79 +544,6 @@ typedef short int WXTYPE; /* integer on success as failure indicator */ #define wxNOT_FOUND (-1) -/* the default value for some length parameters meaning that the string is */ -/* NUL-terminated */ -#define wxNO_LEN ((size_t)-1) - -/* ---------------------------------------------------------------------------- */ -/* macros dealing with comparison operators */ -/* ---------------------------------------------------------------------------- */ - -/* - Expands into m(op, args...) for each op in the set { ==, !=, <, <=, >, >= }. - */ -#define wxFOR_ALL_COMPARISONS(m) \ - m(==) m(!=) m(>=) m(<=) m(>) m(<) - -#define wxFOR_ALL_COMPARISONS_1(m, x) \ - m(==,x) m(!=,x) m(>=,x) m(<=,x) m(>,x) m(<,x) - -#define wxFOR_ALL_COMPARISONS_2(m, x, y) \ - m(==,x,y) m(!=,x,y) m(>=,x,y) m(<=,x,y) m(>,x,y) m(<,x,y) - -#define wxFOR_ALL_COMPARISONS_3(m, x, y, z) \ - m(==,x,y,z) m(!=,x,y,z) m(>=,x,y,z) m(<=,x,y,z) m(>,x,y,z) m(<,x,y,z) - -/* - These are only used with wxDEFINE_COMPARISON_[BY_]REV: they pass both the - normal and the reversed comparison operators to the macro. - */ -#define wxFOR_ALL_COMPARISONS_2_REV(m, x, y) \ - m(==,x,y,==) m(!=,x,y,!=) m(>=,x,y,<=) \ - m(<=,x,y,>=) m(>,x,y,<) m(<,x,y,>) - -#define wxFOR_ALL_COMPARISONS_3_REV(m, x, y, z) \ - m(==,x,y,z,==) m(!=,x,y,z,!=) m(>=,x,y,z,<=) \ - m(<=,x,y,z,>=) m(>,x,y,z,<) m(<,x,y,z,>) - - -#define wxDEFINE_COMPARISON(op, T1, T2, cmp) \ - inline bool operator op(T1 x, T2 y) { return cmp(x, y, op); } - -#define wxDEFINE_COMPARISON_REV(op, T1, T2, cmp, oprev) \ - inline bool operator op(T2 y, T1 x) { return cmp(x, y, oprev); } - -#define wxDEFINE_COMPARISON_BY_REV(op, T1, T2, oprev) \ - inline bool operator op(T1 x, T2 y) { return y oprev x; } - -/* - Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given - types in the specified order. The implementation is provided by the cmp - macro. Normally wxDEFINE_ALL_COMPARISONS should be used as comparison - operators are usually symmetric. - */ -#define wxDEFINE_COMPARISONS(T1, T2, cmp) \ - wxFOR_ALL_COMPARISONS_3(wxDEFINE_COMPARISON, T1, T2, cmp) - -/* - Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given - types in the specified order, implemented in terms of existing operators - for the reverse order. - */ -#define wxDEFINE_COMPARISONS_BY_REV(T1, T2) \ - wxFOR_ALL_COMPARISONS_2_REV(wxDEFINE_COMPARISON_BY_REV, T1, T2) - -/* - This macro allows to define all 12 comparison operators (6 operators for - both orders of arguments) for the given types using the provided "cmp" - macro to implement the actual comparison: the macro is called with the 2 - arguments names, the first of type T1 and the second of type T2, and the - comparison operator being implemented. - */ -#define wxDEFINE_ALL_COMPARISONS(T1, T2, cmp) \ - wxFOR_ALL_COMPARISONS_3(wxDEFINE_COMPARISON, T1, T2, cmp) \ - wxFOR_ALL_COMPARISONS_3_REV(wxDEFINE_COMPARISON_REV, T1, T2, cmp) - /* ---------------------------------------------------------------------------- */ /* macros to avoid compiler warnings */ /* ---------------------------------------------------------------------------- */ @@ -821,6 +555,13 @@ typedef short int WXTYPE; #define WXUNUSED(identifier) identifier #endif +/* some arguments are only used in debug mode, but unused in release one */ +#ifdef __WXDEBUG__ + #define WXUNUSED_UNLESS_DEBUG(param) param +#else + #define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param) +#endif + /* some arguments are not used in unicode mode */ #if wxUSE_UNICODE #define WXUNUSED_IN_UNICODE(param) WXUNUSED(param) @@ -867,6 +608,25 @@ typedef short int WXTYPE; /* compiler specific settings */ /* ---------------------------------------------------------------------------- */ +/* to allow compiling with warning level 4 under Microsoft Visual C++ some */ +/* warnings just must be disabled */ +#ifdef __VISUALC__ + #pragma warning(disable: 4514) /* unreferenced inline func has been removed */ +/* + you might be tempted to disable this one also: triggered by CHECK and FAIL + macros in debug.h, but it's, overall, a rather useful one, so I leave it and + will try to find some way to disable this warning just for CHECK/FAIL. Anyone? +*/ + #pragma warning(disable: 4127) /* conditional expression is constant */ +#endif /* VC++ */ + +#if defined(__MWERKS__) + #undef try + #undef except + #undef finally + #define except(x) catch(...) +#endif /* Metrowerks */ + #if wxONLY_WATCOM_EARLIER_THAN(1,4) typedef short mode_t; #endif @@ -874,10 +634,13 @@ typedef short int WXTYPE; /* where should i put this? we need to make sure of this as it breaks */ /* the code. */ #if !wxUSE_IOSTREAMH && defined(__WXDEBUG__) +# ifndef __MWERKS__ +/* #undef __WXDEBUG__ */ # ifdef wxUSE_DEBUG_NEW_ALWAYS # undef wxUSE_DEBUG_NEW_ALWAYS # define wxUSE_DEBUG_NEW_ALWAYS 0 # endif +# endif #endif /* ---------------------------------------------------------------------------- */ @@ -893,7 +656,7 @@ enum { wxDefaultCoord = -1 }; /* define fixed length types */ /* ---------------------------------------------------------------------------- */ -#if defined(__MINGW32__) +#if defined(__WXPALMOS__) || defined(__MINGW32__) #include #endif @@ -901,6 +664,9 @@ enum { wxDefaultCoord = -1 }; /* practice) */ /* 8bit */ +#ifndef SIZEOF_CHAR + #define SIZEOF_CHAR 1 +#endif typedef signed char wxInt8; typedef unsigned char wxUint8; typedef wxUint8 wxByte; @@ -932,7 +698,7 @@ typedef wxUint16 wxWord; |short | 16 16 16 16 16 | |int | 32 64 32 32 16 | |long | 64 64 32 32 32 | - |long long | 64 64 64 -- -- | + |long long | 64 | |void * | 64 64 64 32 32 | +-----------+----------------------------+ @@ -943,35 +709,32 @@ typedef wxUint16 wxWord; */ /* 32bit */ -#if defined(__WINDOWS__) +#ifdef __PALMOS__ + typedef int wxInt32; + typedef unsigned int wxUint32; + #define SIZEOF_INT 4 + #define SIZEOF_LONG 4 + #define SIZEOF_WCHAR_T 2 + #define SIZEOF_SIZE_T 4 + #define wxSIZE_T_IS_UINT + #define SIZEOF_VOID_P 4 + #define SIZEOF_SIZE_T 4 +#elif defined(__WINDOWS__) + /* Win64 uses LLP64 model and so ints and longs have the same size as in */ + /* Win32 */ #if defined(__WIN32__) typedef int wxInt32; typedef unsigned int wxUint32; - /* - Win64 uses LLP64 model and so ints and longs have the same size as - in Win32. - */ + /* Assume that if SIZEOF_INT is defined that all the other ones except + SIZEOF_SIZE_T, are too. See next #if below. */ #ifndef SIZEOF_INT #define SIZEOF_INT 4 - #endif - - #ifndef SIZEOF_LONG #define SIZEOF_LONG 4 - #endif - - #ifndef SIZEOF_LONG_LONG - #define SIZEOF_LONG_LONG 8 - #endif - - #ifndef SIZEOF_WCHAR_T - /* Windows uses UTF-16 */ #define SIZEOF_WCHAR_T 2 - #endif - #ifndef SIZEOF_SIZE_T /* - Under Win64 sizeof(size_t) == 8 and so it is neither unsigned + under Win64 sizeof(size_t) == 8 and so it is neither unsigned int nor unsigned long! */ #ifdef __WIN64__ @@ -984,14 +747,25 @@ typedef wxUint16 wxWord; #define wxSIZE_T_IS_UINT #endif #undef wxSIZE_T_IS_ULONG - #endif - #ifndef SIZEOF_VOID_P #ifdef __WIN64__ #define SIZEOF_VOID_P 8 #else /* Win32 */ #define SIZEOF_VOID_P 4 #endif /* Win64/32 */ + #endif /* !defined(SIZEOF_INT) */ + + /* + If Python.h was included first, it defines all of the SIZEOF's above + except for SIZEOF_SIZE_T, so we need to do it here to avoid + triggering the #error in the ssize_t typedefs below... + */ + #ifndef SIZEOF_SIZE_T + #ifdef __WIN64__ + #define SIZEOF_SIZE_T 8 + #else /* Win32 */ + #define SIZEOF_SIZE_T 4 + #endif #endif #else #error "Unsupported Windows version" @@ -1034,7 +808,7 @@ typedef wxUint16 wxWord; #if defined(__MACH__) && !defined(SIZEOF_WCHAR_T) #define SIZEOF_WCHAR_T 4 #endif - #if !defined(SIZEOF_WCHAR_T) + #if wxUSE_WCHAR_T && !defined(SIZEOF_WCHAR_T) /* also assume that sizeof(wchar_t) == 2 (under Unix the most */ /* common case is 4 but there configure would have defined */ /* SIZEOF_WCHAR_T for us) */ @@ -1043,224 +817,23 @@ typedef wxUint16 wxWord; Wchar_tMustBeExactly2Bytes); #define SIZEOF_WCHAR_T 2 - #endif /* !defined(SIZEOF_WCHAR_T) */ + #endif /* wxUSE_WCHAR_T */ #endif #endif /* Win/!Win */ -#ifndef SIZEOF_WCHAR_T - #error "SIZEOF_WCHAR_T must be defined, but isn't" -#endif - -/* also define C99-like sized MIN/MAX constants */ -#define wxINT8_MIN CHAR_MIN -#define wxINT8_MAX CHAR_MAX -#define wxUINT8_MAX UCHAR_MAX - -#define wxINT16_MIN SHRT_MIN -#define wxINT16_MAX SHRT_MAX -#define wxUINT16_MAX USHRT_MAX - -#if SIZEOF_INT == 4 - #define wxINT32_MIN INT_MIN - #define wxINT32_MAX INT_MAX - #define wxUINT32_MAX UINT_MAX -#elif SIZEOF_LONG == 4 - #define wxINT32_MIN LONG_MIN - #define wxINT32_MAX LONG_MAX - #define wxUINT32_MAX ULONG_MAX -#else - #error "Unknown 32 bit type" -#endif - typedef wxUint32 wxDword; -#ifdef LLONG_MAX - #define wxINT64_MIN LLONG_MIN - #define wxINT64_MAX LLONG_MAX - #define wxUINT64_MAX ULLONG_MAX -#else - #define wxINT64_MIN (wxLL(-9223372036854775807)-1) - #define wxINT64_MAX wxLL(9223372036854775807) - #define wxUINT64_MAX wxULL(0xFFFFFFFFFFFFFFFF) -#endif - -/* 64 bit */ - -/* NB: we #define and not typedef wxLongLong_t because we use "#ifdef */ -/* wxLongLong_t" in wx/longlong.h */ - -/* wxULongLong_t is set later (usually to unsigned wxLongLong_t) */ - -/* to avoid compilation problems on 64bit machines with ambiguous method calls */ -/* we will need to define this */ -#undef wxLongLongIsLong - /* - First check for specific compilers which have known 64 bit integer types, - this avoids clashes with SIZEOF_LONG[_LONG] being defined incorrectly for - e.g. MSVC builds (Python.h defines it as 8 even for MSVC). - - Also notice that we check for "long long" before checking for 64 bit long as - we still want to use "long long" and not "long" for wxLongLong_t on 64 bit - architectures to be able to pass wxLongLong_t to the standard functions - prototyped as taking "long long" such as strtoll(). + Define an integral type big enough to contain all of long, size_t and void *. */ -#if (defined(__VISUALC__) || defined(__INTELC__)) && defined(__WIN32__) - #define wxLongLong_t __int64 - #define wxLongLongSuffix i64 - #define wxLongLongFmtSpec "I64" -#elif defined(__BORLANDC__) && defined(__WIN32__) && (__BORLANDC__ >= 0x520) - #define wxLongLong_t __int64 - #define wxLongLongSuffix i64 - #define wxLongLongFmtSpec "L" -#elif (defined(__WATCOMC__) && (defined(__WIN32__) || defined(__DOS__) || defined(__OS2__))) - #define wxLongLong_t __int64 - #define wxLongLongSuffix i64 - #define wxLongLongFmtSpec "L" -#elif defined(__DIGITALMARS__) - #define wxLongLong_t __int64 - #define wxLongLongSuffix LL - #define wxLongLongFmtSpec "ll" -#elif defined(__MINGW32__) - #define wxLongLong_t long long - #define wxLongLongSuffix ll - #define wxLongLongFmtSpec "I64" -#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400 - #define wxLongLong_t long long -#elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8) || \ - defined(__GNUC__) || \ - defined(__CYGWIN__) || \ - defined(__WXMICROWIN__) || \ - (defined(__DJGPP__) && __DJGPP__ >= 2) - #define wxLongLong_t long long - #define wxLongLongSuffix ll - #define wxLongLongFmtSpec "ll" -#elif defined(SIZEOF_LONG) && (SIZEOF_LONG == 8) - #define wxLongLong_t long - #define wxLongLongSuffix l - #define wxLongLongFmtSpec "l" - #define wxLongLongIsLong -#endif - - -#ifdef wxLongLong_t - #define wxULongLong_t unsigned wxLongLong_t - - /* - wxLL() and wxULL() macros allow to define 64 bit constants in a - portable way. - */ - #ifndef wxCOMPILER_BROKEN_CONCAT_OPER - #define wxLL(x) wxCONCAT(x, wxLongLongSuffix) - #define wxULL(x) wxCONCAT(x, wxCONCAT(u, wxLongLongSuffix)) - #else - /* - Currently only Borland compiler has broken concatenation operator - and this compiler is known to use [u]i64 suffix. - */ - #define wxLL(x) wxAPPEND_i64(x) - #define wxULL(x) wxAPPEND_ui64(x) - #endif - - typedef wxLongLong_t wxInt64; - typedef wxULongLong_t wxUint64; - - #define wxHAS_INT64 1 - - #ifndef wxLongLongIsLong - #define wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - #endif -#elif wxUSE_LONGLONG - /* these macros allow to define 64 bit constants in a portable way */ - #define wxLL(x) wxLongLong(x) - #define wxULL(x) wxULongLong(x) - - #define wxInt64 wxLongLong - #define wxUint64 wxULongLong - - #define wxHAS_INT64 1 - -#else /* !wxUSE_LONGLONG */ - - #define wxHAS_INT64 0 - -#endif - -/* - Helper macro for conditionally compiling some code only if wxLongLong_t is - available and is a type different from the other integer types (i.e. not - long). - */ -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - #define wxIF_LONG_LONG_TYPE(x) x -#else - #define wxIF_LONG_LONG_TYPE(x) -#endif - - -/* Make sure ssize_t is defined (a signed type the same size as size_t). */ -/* (HAVE_SSIZE_T is not already defined by configure) */ -#ifndef HAVE_SSIZE_T -#ifdef __MINGW32__ - #if defined(_SSIZE_T_) || defined(_SSIZE_T_DEFINED) - #define HAVE_SSIZE_T - #endif -#elif wxCHECK_WATCOM_VERSION(1,4) - #define HAVE_SSIZE_T -#endif -#endif /* !HAVE_SSIZE_T */ - -/* If we really don't have ssize_t, provide our own version. */ -#ifdef HAVE_SSIZE_T - #ifdef __UNIX__ - #include - #endif -#else /* !HAVE_SSIZE_T */ - #if SIZEOF_SIZE_T == 4 - typedef wxInt32 ssize_t; - #elif SIZEOF_SIZE_T == 8 - typedef wxInt64 ssize_t; - #else - #error "error defining ssize_t, size_t is not 4 or 8 bytes" - #endif - - /* prevent ssize_t redefinitions in other libraries */ - #define HAVE_SSIZE_T -#endif - -/* - We can't rely on Windows _W64 being defined as windows.h may not be - included so define our own equivalent: this should be used with types - like WXLPARAM or WXWPARAM which are 64 bit under Win64 to avoid warnings - each time we cast it to a pointer or a handle (which results in hundreds - of warnings as Win32 API often passes pointers in them) - */ -#if wxCHECK_VISUALC_VERSION(7) - #define wxW64 __w64 -#else - #define wxW64 -#endif - -/* - Define signed and unsigned integral types big enough to contain all of long, - size_t and void *. - */ -#if SIZEOF_LONG >= SIZEOF_VOID_P - /* - Normal case when long is the largest integral type. - */ - typedef long wxIntPtr; +#if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T + /* normal case */ typedef unsigned long wxUIntPtr; + typedef long wxIntPtr; #elif SIZEOF_SIZE_T >= SIZEOF_VOID_P - /* - Win64 case: size_t is the only integral type big enough for "void *". - - Notice that we must use __w64 to avoid warnings about casting pointers - to wxIntPtr (which we do often as this is what it is defined for) in 32 - bit build with MSVC. - */ - typedef wxW64 ssize_t wxIntPtr; + /* Win64 case */ typedef size_t wxUIntPtr; + #define wxIntPtr ssize_t #else /* This should never happen for the current architectures but if you're @@ -1320,16 +893,152 @@ inline void *wxUIntToPtr(wxUIntPtr p) #endif /*__cplusplus*/ +/* 64 bit */ + +/* NB: we #define and not typedef wxLongLong_t because we use "#ifdef */ +/* wxLongLong_t" in wx/longlong.h */ + +/* wxULongLong_t is set later (usually to unsigned wxLongLong_t) */ + +/* to avoid compilation problems on 64bit machines with ambiguous method calls */ +/* we will need to define this */ +#undef wxLongLongIsLong + +/* + First check for specific compilers which have known 64 bit integer types, + this avoids clashes with SIZEOF_LONG[_LONG] being defined incorrectly for + e.g. MSVC builds (Python.h defines it as 8 even for MSVC). + + Also notice that we check for "long long" before checking for 64 bit long as + we still want to use "long long" and not "long" for wxLongLong_t on 64 bit + architectures to be able to pass wxLongLong_t to the standard functions + prototyped as taking "long long" such as strtoll(). + */ +#if (defined(__VISUALC__) && defined(__WIN32__)) + #define wxLongLong_t __int64 + #define wxLongLongSuffix i64 + #define wxLongLongFmtSpec wxT("I64") +#elif defined(__BORLANDC__) && defined(__WIN32__) && (__BORLANDC__ >= 0x520) + #define wxLongLong_t __int64 + #define wxLongLongSuffix i64 + #define wxLongLongFmtSpec wxT("L") +#elif (defined(__WATCOMC__) && (defined(__WIN32__) || defined(__DOS__) || defined(__OS2__))) + #define wxLongLong_t __int64 + #define wxLongLongSuffix i64 + #define wxLongLongFmtSpec wxT("L") +#elif defined(__DIGITALMARS__) + #define wxLongLong_t __int64 + #define wxLongLongSuffix LL + #define wxLongLongFmtSpec wxT("ll") +#elif defined(__MINGW32__) + #define wxLongLong_t long long + #define wxLongLongSuffix ll + #define wxLongLongFmtSpec wxT("I64") +#elif defined(__MWERKS__) + #if __option(longlong) + #define wxLongLong_t long long + #define wxLongLongSuffix ll + #define wxLongLongFmtSpec wxT("ll") + #else + #error "The 64 bit integer support in CodeWarrior has been disabled." + #error "See the documentation on the 'longlong' pragma." + #endif +#elif defined(__WXPALMOS__) + #define wxLongLong_t int64_t + #define wxLongLongSuffix ll + #define wxLongLongFmtSpec wxT("ll") +#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400 + #define wxLongLong_t long long +#elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8) || \ + defined(__GNUC__) || \ + defined(__CYGWIN__) || \ + defined(__WXMICROWIN__) || \ + (defined(__DJGPP__) && __DJGPP__ >= 2) + #define wxLongLong_t long long + #define wxLongLongSuffix ll + #define wxLongLongFmtSpec wxT("ll") +#elif defined(SIZEOF_LONG) && (SIZEOF_LONG == 8) + #define wxLongLong_t long + #define wxLongLongSuffix l + #define wxLongLongFmtSpec wxT("l") + #define wxLongLongIsLong +#endif + + +#ifdef wxLongLong_t + + #ifdef __WXPALMOS__ + #define wxULongLong_t uint64_t + #else + #define wxULongLong_t unsigned wxLongLong_t + #endif + + /* these macros allow to define 64 bit constants in a portable way */ + #define wxLL(x) wxCONCAT(x, wxLongLongSuffix) + #define wxULL(x) wxCONCAT(x, wxCONCAT(u, wxLongLongSuffix)) + + typedef wxLongLong_t wxInt64; + typedef wxULongLong_t wxUint64; + + #define wxHAS_INT64 1 + +#elif wxUSE_LONGLONG + /* these macros allow to define 64 bit constants in a portable way */ + #define wxLL(x) wxLongLong(x) + #define wxULL(x) wxULongLong(x) + + #define wxInt64 wxLongLong + #define wxUint64 wxULongLong + + #define wxHAS_INT64 1 + +#else /* !wxUSE_LONGLONG */ + + #define wxHAS_INT64 0 + +#endif + + +/* Make sure ssize_t is defined (a signed type the same size as size_t) */ +/* HAVE_SSIZE_T should be defined for compiliers that already have it */ +#ifdef __MINGW32__ + #if defined(_SSIZE_T_) && !defined(HAVE_SSIZE_T) + #define HAVE_SSIZE_T + #endif +#endif +#if defined(__PALMOS__) && !defined(HAVE_SSIZE_T) + #define HAVE_SSIZE_T +#endif +#if wxCHECK_WATCOM_VERSION(1,4) + #define HAVE_SSIZE_T +#endif +#ifndef HAVE_SSIZE_T + #if SIZEOF_SIZE_T == 4 + typedef wxInt32 ssize_t; + #elif SIZEOF_SIZE_T == 8 + typedef wxInt64 ssize_t; + #else + #error "error defining ssize_t, size_t is not 4 or 8 bytes" + #endif + + /* prevent ssize_t redefinitions in other libraries */ + #define HAVE_SSIZE_T +#endif + /* base floating point types */ -/* wxFloat32: 32 bit IEEE float ( 1 sign, 8 exponent bits, 23 fraction bits ) */ -/* wxFloat64: 64 bit IEEE float ( 1 sign, 11 exponent bits, 52 fraction bits ) */ +/* wxFloat32: 32 bit IEEE float ( 1 sign, 8 exponent bits, 23 fraction bits */ +/* wxFloat64: 64 bit IEEE float ( 1 sign, 11 exponent bits, 52 fraction bits */ /* wxDouble: native fastest representation that has at least wxFloat64 */ /* precision, so use the IEEE types for storage, and this for */ /* calculations */ typedef float wxFloat32; -typedef double wxFloat64; +#if (defined( __WXMAC__ ) || defined(__WXCOCOA__)) && defined (__MWERKS__) + typedef short double wxFloat64; +#else + typedef double wxFloat64; +#endif typedef double wxDouble; @@ -1338,113 +1047,18 @@ typedef double wxDouble; of treating it as a real fundamental type, set wxWCHAR_T_IS_REAL_TYPE to 0 for them and to 1 for all the others. */ -#ifndef wxWCHAR_T_IS_REAL_TYPE +#if wxUSE_WCHAR_T /* - VC++ typedefs wchar_t as unsigned short by default until VC8, that is - unless /Za or /Zc:wchar_t option is used in which case _WCHAR_T_DEFINED - is defined. + VC++ typedefs wchar_t as unsigned short by default, that is unless + /Za or /Zc:wchar_t option is used in which case _WCHAR_T_DEFINED is + defined. */ # if defined(__VISUALC__) && !defined(_NATIVE_WCHAR_T_DEFINED) # define wxWCHAR_T_IS_REAL_TYPE 0 # else /* compiler having standard-conforming wchar_t */ # define wxWCHAR_T_IS_REAL_TYPE 1 # endif -#endif /* !defined(wxWCHAR_T_IS_REAL_TYPE) */ - -/* Helper macro for doing something dependent on whether wchar_t is or isn't a - typedef inside another macro. */ -#if wxWCHAR_T_IS_REAL_TYPE - #define wxIF_WCHAR_T_TYPE(x) x -#else /* !wxWCHAR_T_IS_REAL_TYPE */ - #define wxIF_WCHAR_T_TYPE(x) -#endif /* wxWCHAR_T_IS_REAL_TYPE/!wxWCHAR_T_IS_REAL_TYPE */ - -/* - This constant should be used instead of NULL in vararg functions taking - wxChar* arguments: passing NULL (which is the same as 0, unless the compiler - defines it specially, e.g. like gcc does with its __null built-in) doesn't - work in this case as va_arg() wouldn't interpret the integer 0 correctly - when trying to convert it to a pointer on architectures where sizeof(int) is - strictly less than sizeof(void *). - - Examples of places where this must be used include wxFileTypeInfo ctor. - */ -#define wxNullPtr ((void *)NULL) - - -/* Define wxChar16 and wxChar32 */ - -#if SIZEOF_WCHAR_T == 2 - #define wxWCHAR_T_IS_WXCHAR16 - typedef wchar_t wxChar16; -#else - typedef wxUint16 wxChar16; -#endif - -#if SIZEOF_WCHAR_T == 4 - #define wxWCHAR_T_IS_WXCHAR32 - typedef wchar_t wxChar32; -#else - typedef wxUint32 wxChar32; -#endif - - -/* - Helper macro expanding into the given "m" macro invoked with each of the - integer types as parameter (notice that this does not include char/unsigned - char and bool but does include wchar_t). - */ -#define wxDO_FOR_INT_TYPES(m) \ - m(short) \ - m(unsigned short) \ - m(int) \ - m(unsigned int) \ - m(long) \ - m(unsigned long) \ - wxIF_LONG_LONG_TYPE( m(wxLongLong_t) ) \ - wxIF_LONG_LONG_TYPE( m(wxULongLong_t) ) \ - wxIF_WCHAR_T_TYPE( m(wchar_t) ) - -/* - Same as wxDO_FOR_INT_TYPES() but does include char and unsigned char. - - Notice that we use "char" and "unsigned char" here but not "signed char" - which would be more correct as "char" could be unsigned by default. But - wxWidgets code currently supposes that char is signed and we'd need to - clean up assumptions about it, notably in wx/unichar.h, to be able to use - "signed char" here. - */ -#define wxDO_FOR_CHAR_INT_TYPES(m) \ - m(char) \ - m(unsigned char) \ - wxDO_FOR_INT_TYPES(m) - -/* - Same as wxDO_FOR_INT_TYPES() above except that m macro takes the - type as the first argument and some extra argument, passed from this macro - itself, as the second one. - */ -#define wxDO_FOR_INT_TYPES_1(m, arg) \ - m(short, arg) \ - m(unsigned short, arg) \ - m(int, arg) \ - m(unsigned int, arg) \ - m(long, arg) \ - m(unsigned long, arg) \ - wxIF_LONG_LONG_TYPE( m(wxLongLong_t, arg) ) \ - wxIF_LONG_LONG_TYPE( m(wxULongLong_t, arg) ) \ - wxIF_WCHAR_T_TYPE( m(wchar_t, arg) ) - -/* - Combination of wxDO_FOR_CHAR_INT_TYPES() and wxDO_FOR_INT_TYPES_1(): - invokes the given macro with the specified argument as its second parameter - for all char and int types. - */ -#define wxDO_FOR_CHAR_INT_TYPES_1(m, arg) \ - m(char, arg) \ - m(unsigned char, arg) \ - wxDO_FOR_INT_TYPES_1(m, arg) - +#endif /* wxUSE_WCHAR_T */ /* ---------------------------------------------------------------------------- */ /* byte ordering related definition and macros */ @@ -1464,6 +1078,36 @@ typedef double wxDouble; /* byte swapping */ +#if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh ) +/* assembler versions for these */ +#ifdef __POWERPC__ + inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i ) + {return (__lhbrx( &i , 0 ) );} + inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i ) + {return (__lhbrx( &i , 0 ) );} + inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i ) + {return (__lwbrx( &i , 0 ) );} + inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i ) + {return (__lwbrx( &i , 0 ) );} +#else + #pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0) + pascal wxUint16 wxUINT16_SWAP_ALWAYS(wxUint16 value) + = { 0xE158 }; + + #pragma parameter __D0 wxINT16_SWAP_ALWAYS(__D0) + pascal wxInt16 wxINT16_SWAP_ALWAYS(wxInt16 value) + = { 0xE158 }; + + #pragma parameter __D0 wxUINT32_SWAP_ALWAYS (__D0) + pascal wxUint32 wxUINT32_SWAP_ALWAYS(wxUint32 value) + = { 0xE158, 0x4840, 0xE158 }; + + #pragma parameter __D0 wxINT32_SWAP_ALWAYS (__D0) + pascal wxInt32 wxINT32_SWAP_ALWAYS(wxInt32 value) + = { 0xE158, 0x4840, 0xE158 }; + +#endif +#else /* !MWERKS */ #define wxUINT16_SWAP_ALWAYS(val) \ ((wxUint16) ( \ (((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \ @@ -1487,6 +1131,7 @@ typedef double wxDouble; (((wxUint32) (val) & (wxUint32) 0x0000ff00U) << 8) | \ (((wxUint32) (val) & (wxUint32) 0x00ff0000U) >> 8) | \ (((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24))) +#endif /* machine specific byte swapping */ #ifdef wxLongLong_t @@ -1547,8 +1192,6 @@ typedef double wxDouble; #if wxHAS_INT64 #define wxUINT64_SWAP_ON_BE(val) wxUINT64_SWAP_ALWAYS(val) #define wxUINT64_SWAP_ON_LE(val) (val) - #define wxINT64_SWAP_ON_BE(val) wxINT64_SWAP_ALWAYS(val) - #define wxINT64_SWAP_ON_LE(val) (val) #endif #else #define wxUINT16_SWAP_ON_LE(val) wxUINT16_SWAP_ALWAYS(val) @@ -1562,50 +1205,9 @@ typedef double wxDouble; #if wxHAS_INT64 #define wxUINT64_SWAP_ON_LE(val) wxUINT64_SWAP_ALWAYS(val) #define wxUINT64_SWAP_ON_BE(val) (val) - #define wxINT64_SWAP_ON_LE(val) wxINT64_SWAP_ALWAYS(val) - #define wxINT64_SWAP_ON_BE(val) (val) #endif #endif -/* ---------------------------------------------------------------------------- */ -/* template workarounds for buggy compilers */ -/* ---------------------------------------------------------------------------- */ - -#if defined(__GNUC__) && !wxCHECK_GCC_VERSION( 3, 4 ) - /* GCC <= 3.4 has buggy template support */ -# define wxUSE_MEMBER_TEMPLATES 0 -#endif - -#if defined(_MSC_VER) && _MSC_VER <= 1200 - /* MSVC <= 6.0 has buggy template support */ -# define wxUSE_MEMBER_TEMPLATES 0 -# define wxUSE_FUNC_TEMPLATE_POINTER 0 -#endif - -#ifndef wxUSE_MEMBER_TEMPLATES -# define wxUSE_MEMBER_TEMPLATES 1 -#endif - -#ifndef wxUSE_FUNC_TEMPLATE_POINTER -# define wxUSE_FUNC_TEMPLATE_POINTER 1 -#endif - -#if wxUSE_MEMBER_TEMPLATES -# define wxTEMPLATED_MEMBER_CALL( method, type ) method() -# define wxTEMPLATED_MEMBER_FIX( type ) -#else -# define wxTEMPLATED_MEMBER_CALL( method, type ) method((type*)NULL) -# define wxTEMPLATED_MEMBER_FIX( type ) type* =NULL -#endif - -#if defined(_MSC_VER) && _MSC_VER <= 1200 -# define wxTEMPLATED_FUNCTION_FIX( type ), wxTEMPLATED_MEMBER_FIX(type) -# define wxINFUNC_CLASS_TYPE_FIX( type ) typedef type type; -#else -# define wxTEMPLATED_FUNCTION_FIX( type ) -# define wxINFUNC_CLASS_TYPE_FIX( type ) -#endif - /* ---------------------------------------------------------------------------- */ /* Geometric flags */ /* ---------------------------------------------------------------------------- */ @@ -1628,10 +1230,7 @@ enum wxOrientation wxHORIZONTAL = 0x0004, wxVERTICAL = 0x0008, - wxBOTH = wxVERTICAL | wxHORIZONTAL, - - /* a mask to extract orientation from the combination of flags */ - wxORIENTATION_MASK = wxBOTH + wxBOTH = wxVERTICAL | wxHORIZONTAL }; enum wxDirection @@ -1649,21 +1248,11 @@ enum wxDirection wxWEST = wxLEFT, wxEAST = wxRIGHT, - wxALL = (wxUP | wxDOWN | wxRIGHT | wxLEFT), - - /* a mask to extract direction from the combination of flags */ - wxDIRECTION_MASK = wxALL + wxALL = (wxUP | wxDOWN | wxRIGHT | wxLEFT) }; enum wxAlignment { - /* - 0 is a valid wxAlignment value (both wxALIGN_LEFT and wxALIGN_TOP - use it) so define a symbolic name for an invalid alignment value - which can be assumed to be different from anything else - */ - wxALIGN_INVALID = -1, - wxALIGN_NOT = 0x0000, wxALIGN_CENTER_HORIZONTAL = 0x0100, wxALIGN_CENTRE_HORIZONTAL = wxALIGN_CENTER_HORIZONTAL, @@ -1681,25 +1270,6 @@ enum wxAlignment wxALIGN_MASK = 0x0f00 }; -/* misc. flags for wxSizer items */ -enum wxSizerFlagBits -{ - /* - wxADJUST_MINSIZE doesn't do anything any more but we still define - it for compatibility. Notice that it may be also predefined (as 0, - hopefully) in the user code in order to use it even in - !WXWIN_COMPATIBILITY_2_8 builds so don't redefine it in such case. - */ -#if WXWIN_COMPATIBILITY_2_8 && !defined(wxADJUST_MINSIZE) - wxADJUST_MINSIZE = 0, -#endif - wxFIXED_MINSIZE = 0x8000, - wxRESERVE_SPACE_EVEN_IF_HIDDEN = 0x0002, - - /* a mask to extract wxSizerFlagBits from combination of flags */ - wxSIZER_FLAG_BITS_MASK = 0x8002 -}; - enum wxStretch { wxSTRETCH_NOT = 0x0000, @@ -1707,10 +1277,18 @@ enum wxStretch wxGROW = 0x2000, wxEXPAND = wxGROW, wxSHAPED = 0x4000, - wxTILE = wxSHAPED | wxFIXED_MINSIZE, + wxFIXED_MINSIZE = 0x8000, +#if wxABI_VERSION >= 20808 + wxRESERVE_SPACE_EVEN_IF_HIDDEN = 0x0002, +#endif + wxTILE = 0xc000, - /* a mask to extract stretch from the combination of flags */ - wxSTRETCH_MASK = 0x7000 /* sans wxTILE */ + /* for compatibility only, default now, don't use explicitly any more */ +#if WXWIN_COMPATIBILITY_2_4 + wxADJUST_MINSIZE = 0x00100000 +#else + wxADJUST_MINSIZE = 0 +#endif }; /* border flags: the values are chosen for backwards compatibility */ @@ -1726,7 +1304,7 @@ enum wxBorder wxBORDER_RAISED = 0x04000000, wxBORDER_SUNKEN = 0x08000000, wxBORDER_DOUBLE = 0x10000000, /* deprecated */ - wxBORDER_THEME = wxBORDER_DOUBLE, + wxBORDER_THEME = 0x10000000, /* a mask to extract border style from the combination of flags */ wxBORDER_MASK = 0x1f200000 @@ -1748,40 +1326,12 @@ enum wxBorder * Some styles are used across more than one group, * so the values mustn't clash with others in the group. * Otherwise, numbers can be reused across groups. - */ - -/* - Summary of the bits used by various styles. - - High word, containing styles which can be used with many windows: - - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16| - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - | | | | | | | | | | | | | | | | - | | | | | | | | | | | | | | | \_ wxFULL_REPAINT_ON_RESIZE - | | | | | | | | | | | | | | \____ wxPOPUP_WINDOW - | | | | | | | | | | | | | \_______ wxWANTS_CHARS - | | | | | | | | | | | | \__________ wxTAB_TRAVERSAL - | | | | | | | | | | | \_____________ wxTRANSPARENT_WINDOW - | | | | | | | | | | \________________ wxBORDER_NONE - | | | | | | | | | \___________________ wxCLIP_CHILDREN - | | | | | | | | \______________________ wxALWAYS_SHOW_SB - | | | | | | | \_________________________ wxBORDER_STATIC - | | | | | | \____________________________ wxBORDER_SIMPLE - | | | | | \_______________________________ wxBORDER_RAISED - | | | | \__________________________________ wxBORDER_SUNKEN - | | | \_____________________________________ wxBORDER_{DOUBLE,THEME} - | | \________________________________________ wxCAPTION/wxCLIP_SIBLINGS - | \___________________________________________ wxHSCROLL - \______________________________________________ wxVSCROLL - - - Low word style bits is class-specific meaning that the same bit can have - different meanings for different controls (e.g. 0x10 is wxCB_READONLY - meaning that the control can't be modified for wxComboBox but wxLB_SORT - meaning that the control should be kept sorted for wxListBox, while - wxLB_SORT has a different value -- and this is just fine). + * + * From version 1.66: + * Window (cross-group) styles now take up the first half + * of the flag, and control-specific styles the + * second half. + * */ /* @@ -1940,10 +1490,9 @@ enum wxBorder #define wxLB_MULTIPLE 0x0040 #define wxLB_EXTENDED 0x0080 /* wxLB_OWNERDRAW is Windows-only */ -#define wxLB_NEEDED_SB 0x0000 #define wxLB_OWNERDRAW 0x0100 -#define wxLB_ALWAYS_SB 0x0200 -#define wxLB_NO_SB 0x0400 +#define wxLB_NEEDED_SB 0x0200 +#define wxLB_ALWAYS_SB 0x0400 #define wxLB_HSCROLL wxHSCROLL /* always show an entire number of rows */ #define wxLB_INT_HEIGHT 0x0800 @@ -1977,12 +1526,14 @@ enum wxBorder /* Old names for compatibility */ #define wxRA_HORIZONTAL wxHORIZONTAL #define wxRA_VERTICAL wxVERTICAL +#define wxRA_USE_CHECKBOX 0x0010 /* alternative native subcontrols (wxPalmOS) */ /* * wxRadioButton style flag */ #define wxRB_GROUP 0x0004 #define wxRB_SINGLE 0x0008 +#define wxRB_USE_CHECKBOX 0x0010 /* alternative native control (wxPalmOS) */ /* * wxScrollBar flags @@ -1992,15 +1543,14 @@ enum wxBorder /* * wxSpinButton flags. - * Note that a wxSpinCtrl is sometimes defined as a wxTextCtrl, and so the - * flags shouldn't overlap with wxTextCtrl flags that can be used for a single - * line controls (currently we reuse wxTE_CHARWRAP and wxTE_RICH2 neither of - * which makes sense for them). + * Note that a wxSpinCtrl is sometimes defined as + * a wxTextCtrl, and so the flags must be different + * from wxTextCtrl's. */ #define wxSP_HORIZONTAL wxHORIZONTAL /* 4 */ #define wxSP_VERTICAL wxVERTICAL /* 8 */ -#define wxSP_ARROW_KEYS 0x4000 -#define wxSP_WRAP 0x8000 +#define wxSP_ARROW_KEYS 0x1000 +#define wxSP_WRAP 0x2000 /* * wxTabCtrl flags @@ -2014,6 +1564,18 @@ enum wxBorder #define wxTC_MULTILINE 0x0200 /* == wxNB_MULTILINE */ #define wxTC_OWNERDRAW 0x0400 +/* + * wxStatusBar95 flags + */ +#define wxST_SIZEGRIP 0x0010 + +/* + * wxStaticText flags + */ +#define wxST_NO_AUTORESIZE 0x0001 +#define wxST_DOTS_MIDDLE 0x0002 +#define wxST_DOTS_END 0x0004 + /* * wxStaticBitmap flags */ @@ -2039,13 +1601,9 @@ enum wxBorder #define wxNO 0x00000008 #define wxYES_NO (wxYES | wxNO) #define wxCANCEL 0x00000010 -#define wxAPPLY 0x00000020 -#define wxCLOSE 0x00000040 -#define wxOK_DEFAULT 0x00000000 /* has no effect (default) */ -#define wxYES_DEFAULT 0x00000000 /* has no effect (default) */ -#define wxNO_DEFAULT 0x00000080 /* only valid with wxYES_NO */ -#define wxCANCEL_DEFAULT 0x80000000 /* only valid with wxCANCEL */ +#define wxYES_DEFAULT 0x00000000 /* has no effect (default) */ +#define wxNO_DEFAULT 0x00000080 #define wxICON_EXCLAMATION 0x00000100 #define wxICON_HAND 0x00000200 @@ -2055,68 +1613,24 @@ enum wxBorder #define wxICON_INFORMATION 0x00000800 #define wxICON_STOP wxICON_HAND #define wxICON_ASTERISK wxICON_INFORMATION +#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800) -#define wxHELP 0x00001000 -#define wxFORWARD 0x00002000 -#define wxBACKWARD 0x00004000 -#define wxRESET 0x00008000 -#define wxMORE 0x00010000 -#define wxSETUP 0x00020000 -#define wxICON_NONE 0x00040000 -#define wxICON_AUTH_NEEDED 0x00080000 - -#define wxICON_MASK \ - (wxICON_EXCLAMATION|wxICON_HAND|wxICON_QUESTION|wxICON_INFORMATION|wxICON_NONE|wxICON_AUTH_NEEDED) +#define wxFORWARD 0x00001000 +#define wxBACKWARD 0x00002000 +#define wxRESET 0x00004000 +#define wxHELP 0x00008000 +#define wxMORE 0x00010000 +#define wxSETUP 0x00020000 /* * Background styles. See wxWindow::SetBackgroundStyle */ + enum wxBackgroundStyle { - /* - background is erased in the EVT_ERASE_BACKGROUND handler or using - the system default background if no such handler is defined (this - is the default style) - */ - wxBG_STYLE_ERASE, - - /* - background is erased by the system, no EVT_ERASE_BACKGROUND event - is generated at all - */ - wxBG_STYLE_SYSTEM, - - /* - background is erased in EVT_PAINT handler and not erased at all - before it, this should be used if the paint handler paints over - the entire window to avoid flicker - */ - wxBG_STYLE_PAINT, - - /* - Indicates that the window background is not erased, letting the parent - window show through. - */ - wxBG_STYLE_TRANSPARENT, - - /* this style is deprecated and doesn't do anything, don't use */ - wxBG_STYLE_COLOUR, - - /* - this style is deprecated and is synonymous with - wxBG_STYLE_PAINT, use the new name - */ - wxBG_STYLE_CUSTOM = wxBG_STYLE_PAINT -}; - -/* - * Key types used by (old style) lists and hashes. - */ -enum wxKeyType -{ - wxKEY_NONE, - wxKEY_INTEGER, - wxKEY_STRING + wxBG_STYLE_SYSTEM, + wxBG_STYLE_COLOUR, + wxBG_STYLE_CUSTOM }; /* ---------------------------------------------------------------------------- */ @@ -2124,26 +1638,8 @@ enum wxKeyType /* ---------------------------------------------------------------------------- */ /* Standard menu IDs */ -enum wxStandardID +enum { - /* - These ids delimit the range used by automatically-generated ids - (i.e. those used when wxID_ANY is specified during construction). - */ -#if defined(__WXMSW__) || wxUSE_AUTOID_MANAGEMENT - /* - On MSW the range is always restricted no matter if id management - is used or not because the native window ids are limited to short - range. On other platforms the range is only restricted if id - management is used so the reference count buffer won't be so big. - */ - wxID_AUTO_LOWEST = -32000, - wxID_AUTO_HIGHEST = -2000, -#else - wxID_AUTO_LOWEST = -1000000, - wxID_AUTO_HIGHEST = -2000, -#endif - /* no id matches this one when compared to it */ wxID_NONE = -3, @@ -2259,24 +1755,6 @@ enum wxStandardID wxID_ZOOM_OUT, wxID_UNDELETE, wxID_REVERT_TO_SAVED, - wxID_CDROM, - wxID_CONVERT, - wxID_EXECUTE, - wxID_FLOPPY, - wxID_HARDDISK, - wxID_BOTTOM, - wxID_FIRST, - wxID_LAST, - wxID_TOP, - wxID_INFO, - wxID_JUMP_TO, - wxID_NETWORK, - wxID_SELECT_COLOR, - wxID_SELECT_FONT, - wxID_SORT_ASCENDING, - wxID_SORT_DESCENDING, - wxID_SPELL_CHECK, - wxID_STRIKETHROUGH, /* System menu IDs (used by wxUniv): */ wxID_SYSTEM_MENU = 5200, @@ -2287,50 +1765,12 @@ enum wxStandardID wxID_ICONIZE_FRAME, wxID_RESTORE_FRAME, - /* MDI window menu ids */ - wxID_MDI_WINDOW_FIRST = 5230, - wxID_MDI_WINDOW_CASCADE = wxID_MDI_WINDOW_FIRST, - wxID_MDI_WINDOW_TILE_HORZ, - wxID_MDI_WINDOW_TILE_VERT, - wxID_MDI_WINDOW_ARRANGE_ICONS, - wxID_MDI_WINDOW_PREV, - wxID_MDI_WINDOW_NEXT, - wxID_MDI_WINDOW_LAST = wxID_MDI_WINDOW_NEXT, - - /* OS X system menu ids */ - wxID_OSX_MENU_FIRST = 5250, - wxID_OSX_HIDE = wxID_OSX_MENU_FIRST, - wxID_OSX_HIDEOTHERS, - wxID_OSX_SHOWALL, -#if wxABI_VERSION >= 30001 - wxID_OSX_SERVICES, - wxID_OSX_MENU_LAST = wxID_OSX_SERVICES, -#else - wxID_OSX_MENU_LAST = wxID_OSX_SHOWALL, -#endif - /* IDs used by generic file dialog (13 consecutive starting from this value) */ wxID_FILEDLGG = 5900, - /* IDs used by generic file ctrl (4 consecutive starting from this value) */ - wxID_FILECTRL = 5950, - wxID_HIGHEST = 5999 }; -/* ---------------------------------------------------------------------------- */ -/* wxWindowID type (after wxID_XYZ enum, platform detection, and dlimpexp.h) */ -/* ---------------------------------------------------------------------------- */ - -/* special care should be taken with this type under Windows where the real */ -/* window id is unsigned, so we must always do the cast before comparing them */ -/* (or else they would be always different!). Using wxGetWindowId() which does */ -/* the cast itself is recommended. Note that this type can't be unsigned */ -/* because wxID_ANY == -1 is a valid (and largely used) value for window id. */ -#if defined(__cplusplus) && wxUSE_GUI - #include "wx/windowid.h" -#endif - /* ---------------------------------------------------------------------------- */ /* other constants */ /* ---------------------------------------------------------------------------- */ @@ -2342,22 +1782,9 @@ enum wxItemKind wxITEM_NORMAL, wxITEM_CHECK, wxITEM_RADIO, - wxITEM_DROPDOWN, wxITEM_MAX }; -/* - * The possible states of a 3-state checkbox (Compatible - * with the 2-state checkbox). - */ -enum wxCheckBoxState -{ - wxCHK_UNCHECKED, - wxCHK_CHECKED, - wxCHK_UNDETERMINED /* 3-state checkbox only */ -}; - - /* hit test results */ enum wxHitTest { @@ -2403,45 +1830,12 @@ enum wxHitTest #define wxSIZE_NO_ADJUSTMENTS 0x0008 /* Change the window position even if it seems to be already correct */ #define wxSIZE_FORCE 0x0010 -/* Emit size event even if size didn't change */ -#define wxSIZE_FORCE_EVENT 0x0020 /* ---------------------------------------------------------------------------- */ /* GDI descriptions */ /* ---------------------------------------------------------------------------- */ -// Hatch styles used by both pen and brush styles. -// -// NB: Do not use these constants directly, they're for internal use only, use -// wxBRUSHSTYLE_XXX_HATCH and wxPENSTYLE_XXX_HATCH instead. -enum wxHatchStyle -{ - wxHATCHSTYLE_INVALID = -1, - - /* - The value of the first style is chosen to fit with - wxDeprecatedGUIConstants values below, don't change it. - */ - wxHATCHSTYLE_FIRST = 111, - wxHATCHSTYLE_BDIAGONAL = wxHATCHSTYLE_FIRST, - wxHATCHSTYLE_CROSSDIAG, - wxHATCHSTYLE_FDIAGONAL, - wxHATCHSTYLE_CROSS, - wxHATCHSTYLE_HORIZONTAL, - wxHATCHSTYLE_VERTICAL, - wxHATCHSTYLE_LAST = wxHATCHSTYLE_VERTICAL -}; - -/* - WARNING: the following styles are deprecated; use the - wxFontFamily, wxFontStyle, wxFontWeight, wxBrushStyle, - wxPenStyle, wxPenCap, wxPenJoin enum values instead! -*/ - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - -/* don't use any elements of this enum in the new code */ -enum wxDeprecatedGUIConstants +enum { /* Text font families */ wxDEFAULT = 70, @@ -2474,23 +1868,71 @@ enum wxDeprecatedGUIConstants wxTRANSPARENT, /* Brush & Pen Stippling. Note that a stippled pen cannot be dashed!! */ - /* Note also that stippling a Pen IS meaningful, because a Line is */ + /* Note also that stippling a Pen IS meaningfull, because a Line is */ wxSTIPPLE_MASK_OPAQUE, /* mask is used for blitting monochrome using text fore and back ground colors */ wxSTIPPLE_MASK, /* mask is used for masking areas in the stipple bitmap (TO DO) */ /* drawn with a Pen, and without any Brush -- and it can be stippled. */ wxSTIPPLE = 110, - wxBDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL, - wxCROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG, - wxFDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL, - wxCROSS_HATCH = wxHATCHSTYLE_CROSS, - wxHORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL, - wxVERTICAL_HATCH = wxHATCHSTYLE_VERTICAL, - wxFIRST_HATCH = wxHATCHSTYLE_FIRST, - wxLAST_HATCH = wxHATCHSTYLE_LAST + wxBDIAGONAL_HATCH, /* In wxWidgets < 2.6 use WX_HATCH macro */ + wxCROSSDIAG_HATCH, /* to verify these wx*_HATCH are in style */ + wxFDIAGONAL_HATCH, /* of wxBrush. In wxWidgets >= 2.6 use */ + wxCROSS_HATCH, /* wxBrush::IsHatch() instead. */ + wxHORIZONTAL_HATCH, + wxVERTICAL_HATCH, + wxFIRST_HATCH = wxBDIAGONAL_HATCH, + wxLAST_HATCH = wxVERTICAL_HATCH, + + wxJOIN_BEVEL = 120, + wxJOIN_MITER, + wxJOIN_ROUND, + + wxCAP_ROUND = 130, + wxCAP_PROJECTING, + wxCAP_BUTT }; + +#if WXWIN_COMPATIBILITY_2_4 + #define IS_HATCH(s) ((s)>=wxFIRST_HATCH && (s)<=wxLAST_HATCH) +#else + /* use wxBrush::IsHatch() instead thought wxMotif still uses it in src/motif/dcclient.cpp */ #endif +/* Logical ops */ +typedef enum +{ + wxCLEAR, wxROP_BLACK = wxCLEAR, wxBLIT_BLACKNESS = wxCLEAR, /* 0 */ + wxXOR, wxROP_XORPEN = wxXOR, wxBLIT_SRCINVERT = wxXOR, /* src XOR dst */ + wxINVERT, wxROP_NOT = wxINVERT, wxBLIT_DSTINVERT = wxINVERT, /* NOT dst */ + wxOR_REVERSE, wxROP_MERGEPENNOT = wxOR_REVERSE, wxBLIT_00DD0228 = wxOR_REVERSE, /* src OR (NOT dst) */ + wxAND_REVERSE, wxROP_MASKPENNOT = wxAND_REVERSE, wxBLIT_SRCERASE = wxAND_REVERSE, /* src AND (NOT dst) */ + wxCOPY, wxROP_COPYPEN = wxCOPY, wxBLIT_SRCCOPY = wxCOPY, /* src */ + wxAND, wxROP_MASKPEN = wxAND, wxBLIT_SRCAND = wxAND, /* src AND dst */ + wxAND_INVERT, wxROP_MASKNOTPEN = wxAND_INVERT, wxBLIT_00220326 = wxAND_INVERT, /* (NOT src) AND dst */ + wxNO_OP, wxROP_NOP = wxNO_OP, wxBLIT_00AA0029 = wxNO_OP, /* dst */ + wxNOR, wxROP_NOTMERGEPEN = wxNOR, wxBLIT_NOTSRCERASE = wxNOR, /* (NOT src) AND (NOT dst) */ + wxEQUIV, wxROP_NOTXORPEN = wxEQUIV, wxBLIT_00990066 = wxEQUIV, /* (NOT src) XOR dst */ + wxSRC_INVERT, wxROP_NOTCOPYPEN = wxSRC_INVERT, wxBLIT_NOTSCRCOPY = wxSRC_INVERT, /* (NOT src) */ + wxOR_INVERT, wxROP_MERGENOTPEN = wxOR_INVERT, wxBLIT_MERGEPAINT = wxOR_INVERT, /* (NOT src) OR dst */ + wxNAND, wxROP_NOTMASKPEN = wxNAND, wxBLIT_007700E6 = wxNAND, /* (NOT src) OR (NOT dst) */ + wxOR, wxROP_MERGEPEN = wxOR, wxBLIT_SRCPAINT = wxOR, /* src OR dst */ + wxSET, wxROP_WHITE = wxSET, wxBLIT_WHITENESS = wxSET /* 1 */ +} form_ops_t; + +/* Flood styles */ +enum +{ + wxFLOOD_SURFACE = 1, + wxFLOOD_BORDER +}; + +/* Polygon filling mode */ +enum +{ + wxODDEVEN_RULE = 1, + wxWINDING_RULE +}; + /* ToolPanel in wxFrame (VZ: unused?) */ enum { @@ -2526,55 +1968,19 @@ enum wxDataFormatId wxDF_MAX }; -/* Key codes */ +/* Virtual keycodes */ enum wxKeyCode { - WXK_NONE = 0, - - WXK_CONTROL_A = 1, - WXK_CONTROL_B, - WXK_CONTROL_C, - WXK_CONTROL_D, - WXK_CONTROL_E, - WXK_CONTROL_F, - WXK_CONTROL_G, - WXK_CONTROL_H, - WXK_CONTROL_I, - WXK_CONTROL_J, - WXK_CONTROL_K, - WXK_CONTROL_L, - WXK_CONTROL_M, - WXK_CONTROL_N, - WXK_CONTROL_O, - WXK_CONTROL_P, - WXK_CONTROL_Q, - WXK_CONTROL_R, - WXK_CONTROL_S, - WXK_CONTROL_T, - WXK_CONTROL_U, - WXK_CONTROL_V, - WXK_CONTROL_W, - WXK_CONTROL_X, - WXK_CONTROL_Y, - WXK_CONTROL_Z, - - WXK_BACK = 8, /* backspace */ + WXK_BACK = 8, WXK_TAB = 9, WXK_RETURN = 13, WXK_ESCAPE = 27, - - /* values from 33 to 126 are reserved for the standard ASCII characters */ - WXK_SPACE = 32, WXK_DELETE = 127, - /* values from 128 to 255 are reserved for ASCII extended characters - (note that there isn't a single fixed standard for the meaning - of these values; avoid them in portable apps!) */ - - /* These are not compatible with unicode characters. + /* These are, by design, not compatible with unicode characters. If you want to get a unicode character from a key event, use - wxKeyEvent::GetUnicodeKey */ + wxKeyEvent::GetUnicodeKey instead. */ WXK_START = 300, WXK_LBUTTON, WXK_RBUTTON, @@ -2681,12 +2087,7 @@ enum wxKeyCode WXK_WINDOWS_LEFT, WXK_WINDOWS_RIGHT, WXK_WINDOWS_MENU , -#ifdef __WXOSX__ - WXK_RAW_CONTROL, -#else - WXK_RAW_CONTROL = WXK_CONTROL, -#endif - WXK_COMMAND = WXK_CONTROL, + WXK_COMMAND, /* Hardware-specific buttons */ WXK_SPECIAL1 = 193, @@ -2722,14 +2123,28 @@ enum wxKeyModifier wxMOD_META = 0x0008, wxMOD_WIN = wxMOD_META, #if defined(__WXMAC__) || defined(__WXCOCOA__) - wxMOD_RAW_CONTROL = 0x0010, + wxMOD_CMD = wxMOD_META, #else - wxMOD_RAW_CONTROL = wxMOD_CONTROL, -#endif wxMOD_CMD = wxMOD_CONTROL, +#endif wxMOD_ALL = 0xffff }; +/* Mapping modes (same values as used by Windows, don't change) */ +enum +{ + wxMM_TEXT = 1, + wxMM_LOMETRIC, + wxMM_HIMETRIC, + wxMM_LOENGLISH, + wxMM_HIENGLISH, + wxMM_TWIPS, + wxMM_ISOTROPIC, + wxMM_ANISOTROPIC, + wxMM_POINTS, + wxMM_METRIC +}; + /* Shortcut for easier dialog-unit-to-pixel conversion */ #define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt) @@ -2854,17 +2269,14 @@ typedef enum wxPAPER_PENV_7_ROTATED, /* PRC Envelope #7 Rotated 230 x 160 mm */ wxPAPER_PENV_8_ROTATED, /* PRC Envelope #8 Rotated 309 x 120 mm */ wxPAPER_PENV_9_ROTATED, /* PRC Envelope #9 Rotated 324 x 229 mm */ - wxPAPER_PENV_10_ROTATED, /* PRC Envelope #10 Rotated 458 x 324 m */ - wxPAPER_A0, /* A0 Sheet 841 x 1189 mm */ - wxPAPER_A1 /* A1 Sheet 594 x 841 mm */ + wxPAPER_PENV_10_ROTATED /* PRC Envelope #10 Rotated 458 x 324 m */ } wxPaperSize; /* Printing orientation */ -enum wxPrintOrientation -{ - wxPORTRAIT = 1, - wxLANDSCAPE -}; +#ifndef wxPORTRAIT +#define wxPORTRAIT 1 +#define wxLANDSCAPE 2 +#endif /* Duplex printing modes */ @@ -2909,20 +2321,16 @@ enum wxUpdateUI wxUPDATE_UI_FROMIDLE = 0x0002 /* Invoked from On(Internal)Idle */ }; +/* ---------------------------------------------------------------------------- */ +/* Notification Event flags - used for dock icon bouncing, etc. */ +/* ---------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------------- */ -/* wxList types */ -/* ---------------------------------------------------------------------------- */ - -/* type of compare function for list sort operation (as in 'qsort'): it should - return a negative value, 0 or positive value if the first element is less - than, equal or greater than the second */ - -typedef int (* LINKAGEMODE wxSortCompareFunction)(const void *elem1, const void *elem2); - -/* wxList iterator function */ -typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); - +enum wxNotificationOptions +{ + wxNOTIFY_NONE = 0x0000, + wxNOTIFY_ONCE = 0x0001, + wxNOTIFY_REPEAT = 0x0002 +}; /* ---------------------------------------------------------------------------- */ /* miscellaneous */ @@ -2943,7 +2351,7 @@ typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); #endif #if defined(__CYGWIN__) && defined(__WXMSW__) -# if wxUSE_STD_CONTAINERS || defined(wxUSE_STD_STRING) +# if wxUSE_STL || defined(wxUSE_STD_STRING) /* NASTY HACK because the gethostname in sys/unistd.h which the gnu stl includes and wx builds with by default clash with each other @@ -2958,21 +2366,19 @@ typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); /* --------------------------------------------------------------------------- */ /* macros that enable wxWidgets apps to be compiled in absence of the */ -/* system headers, although some platform specific types are used in the */ +/* sytem headers, although some platform specific types are used in the */ /* platform specific (implementation) parts of the headers */ /* --------------------------------------------------------------------------- */ -#ifdef __DARWIN__ -#define DECLARE_WXOSX_OPAQUE_CFREF( name ) typedef struct __##name* name##Ref; -#define DECLARE_WXOSX_OPAQUE_CONST_CFREF( name ) typedef const struct __##name* name##Ref; -#endif - #ifdef __WXMAC__ #define WX_OPAQUE_TYPE( name ) struct wxOpaque##name +typedef unsigned char WXCOLORREF[6]; +typedef void* WXCGIMAGEREF; typedef void* WXHBITMAP; typedef void* WXHCURSOR; +typedef void* WXHRGN; typedef void* WXRECTPTR; typedef void* WXPOINTPTR; typedef void* WXHWND; @@ -2980,69 +2386,54 @@ typedef void* WXEVENTREF; typedef void* WXEVENTHANDLERREF; typedef void* WXEVENTHANDLERCALLREF; typedef void* WXAPPLEEVENTREF; - +typedef void* WXHDC; +typedef void* WXHMENU; typedef unsigned int WXUINT; typedef unsigned long WXDWORD; typedef unsigned short WXWORD; +typedef WX_OPAQUE_TYPE(CIconHandle ) * WXHICON ; typedef WX_OPAQUE_TYPE(PicHandle ) * WXHMETAFILE ; -#if wxOSX_USE_CARBON -typedef struct OpaqueControlRef* WXWidget ; -typedef struct OpaqueWindowPtr* WXWindow ; -typedef struct __AGLPixelFormatRec *WXGLPixelFormat; -typedef struct __AGLContextRec *WXGLContext; -#endif + +/* typedef void* WXWidget; */ +/* typedef void* WXWindow; */ +typedef WX_OPAQUE_TYPE(ControlRef ) * WXWidget ; +typedef WX_OPAQUE_TYPE(WindowRef) * WXWindow ; typedef void* WXDisplay; -/* - * core frameworks - */ +/* typedef WindowPtr WXHWND; */ +/* typedef Handle WXHANDLE; */ +/* typedef CIconHandle WXHICON; */ +/* typedef unsigned long WXHFONT; */ +/* typedef MenuHandle WXHMENU; */ +/* typedef unsigned long WXHPEN; */ +/* typedef unsigned long WXHBRUSH; */ +/* typedef unsigned long WXHPALETTE; */ +/* typedef CursHandle WXHCURSOR; */ +/* typedef RgnHandle WXHRGN; */ +/* typedef unsigned long WXHACCEL; */ +/* typedef unsigned long WXHINSTANCE; */ +/* typedef unsigned long WXHIMAGELIST; */ +/* typedef unsigned long WXHGLOBAL; */ +/* typedef GrafPtr WXHDC; */ +/* typedef unsigned int WXWPARAM; */ +/* typedef long WXLPARAM; */ +/* typedef void * WXRGNDATA; */ +/* typedef void * WXMSG; */ +/* typedef unsigned long WXHCONV; */ +/* typedef unsigned long WXHKEY; */ +/* typedef void * WXDRAWITEMSTRUCT; */ +/* typedef void * WXMEASUREITEMSTRUCT; */ +/* typedef void * WXLPCREATESTRUCT; */ +/* typedef int (*WXFARPROC)(); */ -typedef const void * CFTypeRef; - -/* typedef const struct __CFString * CFStringRef; */ - -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CFString ) -typedef struct __CFString * CFMutableStringRef; - -DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopSource ) -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CTFont ) -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CTFontDescriptor ) - -#define DECLARE_WXOSX_OPAQUE_CGREF( name ) typedef struct name* name##Ref; - -DECLARE_WXOSX_OPAQUE_CGREF( CGColor ) -DECLARE_WXOSX_OPAQUE_CGREF( CGImage ) -DECLARE_WXOSX_OPAQUE_CGREF( CGContext ) -DECLARE_WXOSX_OPAQUE_CGREF( CGFont ) - -typedef CGColorRef WXCOLORREF; -typedef CGImageRef WXCGIMAGEREF; -typedef CGContextRef WXHDC; - -/* - * carbon - */ - -typedef const struct __HIShape * HIShapeRef; -typedef struct __HIShape * HIMutableShapeRef; - -#define DECLARE_WXMAC_OPAQUE_REF( name ) typedef struct Opaque##name* name; - -DECLARE_WXMAC_OPAQUE_REF( PasteboardRef ) -DECLARE_WXMAC_OPAQUE_REF( IconRef ) -DECLARE_WXMAC_OPAQUE_REF( MenuRef ) - -typedef IconRef WXHICON ; -typedef HIShapeRef WXHRGN; -#if wxOSX_USE_CARBON -typedef MenuRef WXHMENU; -#endif +/* typedef WindowPtr WXWindow; */ +/* typedef ControlHandle WXWidget; */ #endif -#if defined( __WXCOCOA__ ) || defined(__WXMAC__) +#if defined( __WXCOCOA__ ) || ( defined(__WXMAC__) && defined(__DARWIN__) ) /* Definitions of 32-bit/64-bit types * These are typedef'd exactly the same way in newer OS X headers so @@ -3075,7 +2466,7 @@ typedef unsigned int NSUInteger; */ /* NOTE: This ought to work with other compilers too, but I'm being cautious */ -#if (defined(__GNUC__) && defined(__APPLE__)) +#if (defined(__GNUC__) && defined(__APPLE__)) || defined(__MWERKS__) /* It's desirable to have type safety for Objective-C(++) code as it does at least catch typos of method names among other things. However, it is not possible to declare an Objective-C class from plain old C or C++ @@ -3095,7 +2486,7 @@ typedef klass *WX_##klass typedef struct klass *WX_##klass #endif /* defined(__OBJC__) */ -#else /* not Apple's gcc */ +#else /* not Apple's GNU or CodeWarrior */ #warning "Objective-C types will not be checked by the compiler." /* NOTE: typedef struct objc_object *id; */ /* IOW, we're declaring these using the id type without using that name, */ @@ -3105,7 +2496,7 @@ typedef struct klass *WX_##klass #define DECLARE_WXCOCOA_OBJC_CLASS(klass) \ typedef struct objc_object *WX_##klass -#endif /* (defined(__GNUC__) && defined(__APPLE__)) */ +#endif /* (defined(__GNUC__) && defined(__APPLE__)) || defined(__MWERKS__) */ DECLARE_WXCOCOA_OBJC_CLASS(NSApplication); DECLARE_WXCOCOA_OBJC_CLASS(NSBitmapImageRep); @@ -3116,8 +2507,6 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSColorPanel); DECLARE_WXCOCOA_OBJC_CLASS(NSControl); DECLARE_WXCOCOA_OBJC_CLASS(NSCursor); DECLARE_WXCOCOA_OBJC_CLASS(NSEvent); -DECLARE_WXCOCOA_OBJC_CLASS(NSFont); -DECLARE_WXCOCOA_OBJC_CLASS(NSFontDescriptor); DECLARE_WXCOCOA_OBJC_CLASS(NSFontPanel); DECLARE_WXCOCOA_OBJC_CLASS(NSImage); DECLARE_WXCOCOA_OBJC_CLASS(NSLayoutManager); @@ -3128,7 +2517,6 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSMutableArray); DECLARE_WXCOCOA_OBJC_CLASS(NSNotification); DECLARE_WXCOCOA_OBJC_CLASS(NSObject); DECLARE_WXCOCOA_OBJC_CLASS(NSPanel); -DECLARE_WXCOCOA_OBJC_CLASS(NSResponder); DECLARE_WXCOCOA_OBJC_CLASS(NSScrollView); DECLARE_WXCOCOA_OBJC_CLASS(NSSound); DECLARE_WXCOCOA_OBJC_CLASS(NSStatusItem); @@ -3140,77 +2528,76 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSTextStorage); DECLARE_WXCOCOA_OBJC_CLASS(NSThread); DECLARE_WXCOCOA_OBJC_CLASS(NSWindow); DECLARE_WXCOCOA_OBJC_CLASS(NSView); -DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext); -DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLPixelFormat); -DECLARE_WXCOCOA_OBJC_CLASS( NSPrintInfo ); -#ifndef __WXMAC__ +#ifdef __WXMAC__ +// things added for __WXMAC__ +DECLARE_WXCOCOA_OBJC_CLASS(NSString); +#else +// things only for __WXCOCOA__ typedef WX_NSView WXWidget; /* wxWidgets BASE definition */ #endif #endif /* __WXCOCOA__ || ( __WXMAC__ &__DARWIN__)*/ -#ifdef __WXMAC__ +#if defined(__WXPALMOS__) -DECLARE_WXCOCOA_OBJC_CLASS(NSString); +typedef void * WXHWND; +typedef void * WXHANDLE; +typedef void * WXHICON; +typedef void * WXHFONT; +typedef void * WXHMENU; +typedef void * WXHPEN; +typedef void * WXHBRUSH; +typedef void * WXHPALETTE; +typedef void * WXHCURSOR; +typedef void * WXHRGN; +typedef void * WXHACCEL; +typedef void * WXHINSTANCE; +typedef void * WXHBITMAP; +typedef void * WXHIMAGELIST; +typedef void * WXHGLOBAL; +typedef void * WXHDC; +typedef unsigned int WXUINT; +typedef unsigned long WXDWORD; +typedef unsigned short WXWORD; -#if wxOSX_USE_COCOA +typedef unsigned long WXCOLORREF; +typedef struct tagMSG WXMSG; -typedef WX_NSWindow WXWindow; -typedef WX_NSView WXWidget; -typedef WX_NSMenu WXHMENU; -typedef WX_NSOpenGLPixelFormat WXGLPixelFormat; -typedef WX_NSOpenGLContext WXGLContext; +typedef WXHWND WXWINHANDLE; /* WinHandle of PalmOS */ +typedef WXWINHANDLE WXWidget; -#elif wxOSX_USE_IPHONE +typedef void * WXFORMPTR; +typedef void * WXEVENTPTR; +typedef void * WXRECTANGLEPTR; -DECLARE_WXCOCOA_OBJC_CLASS(UIWindow); -DECLARE_WXCOCOA_OBJC_CLASS(UIView); -DECLARE_WXCOCOA_OBJC_CLASS(UIFont); -DECLARE_WXCOCOA_OBJC_CLASS(UIImage); -DECLARE_WXCOCOA_OBJC_CLASS(UIEvent); -DECLARE_WXCOCOA_OBJC_CLASS(NSSet); -DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext); +#endif /* __WXPALMOS__ */ -typedef WX_UIWindow WXWindow; -typedef WX_UIView WXWidget; -typedef WX_EAGLContext WXGLContext; -typedef WX_NSString* WXGLPixelFormat; - -#endif - -#endif /* __WXMAC__ */ /* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */ #if defined(__WIN32__) -/* Stand-ins for Windows types to avoid #including all of windows.h */ - -#ifndef NO_STRICT - #define WX_MSW_DECLARE_HANDLE(type) typedef struct type##__ * WX##type -#else - #define WX_MSW_DECLARE_HANDLE(type) typedef void * WX##type +/* the keywords needed for WinMain() declaration */ +#ifndef WXFAR +# define WXFAR #endif -typedef void* WXHANDLE; -WX_MSW_DECLARE_HANDLE(HWND); -WX_MSW_DECLARE_HANDLE(HICON); -WX_MSW_DECLARE_HANDLE(HFONT); -WX_MSW_DECLARE_HANDLE(HMENU); -WX_MSW_DECLARE_HANDLE(HPEN); -WX_MSW_DECLARE_HANDLE(HBRUSH); -WX_MSW_DECLARE_HANDLE(HPALETTE); -WX_MSW_DECLARE_HANDLE(HCURSOR); -WX_MSW_DECLARE_HANDLE(HRGN); -WX_MSW_DECLARE_HANDLE(RECTPTR); -WX_MSW_DECLARE_HANDLE(HACCEL); -WX_MSW_DECLARE_HANDLE(HINSTANCE); -WX_MSW_DECLARE_HANDLE(HBITMAP); -WX_MSW_DECLARE_HANDLE(HIMAGELIST); -WX_MSW_DECLARE_HANDLE(HGLOBAL); -WX_MSW_DECLARE_HANDLE(HDC); -typedef WXHINSTANCE WXHMODULE; - -#undef WX_MSW_DECLARE_HANDLE - +/* Stand-ins for Windows types to avoid #including all of windows.h */ +typedef void * WXHWND; +typedef void * WXHANDLE; +typedef void * WXHICON; +typedef void * WXHFONT; +typedef void * WXHMENU; +typedef void * WXHPEN; +typedef void * WXHBRUSH; +typedef void * WXHPALETTE; +typedef void * WXHCURSOR; +typedef void * WXHRGN; +typedef void * WXRECTPTR; +typedef void * WXHACCEL; +typedef void WXFAR * WXHINSTANCE; +typedef void * WXHBITMAP; +typedef void * WXHIMAGELIST; +typedef void * WXHGLOBAL; +typedef void * WXHDC; typedef unsigned int WXUINT; typedef unsigned long WXDWORD; typedef unsigned short WXWORD; @@ -3226,18 +2613,16 @@ typedef void * WXDRAWITEMSTRUCT; typedef void * WXMEASUREITEMSTRUCT; typedef void * WXLPCREATESTRUCT; -#ifdef __WXMSW__ typedef WXHWND WXWidget; -#endif #ifdef __WIN64__ -typedef wxUint64 WXWPARAM; -typedef wxInt64 WXLPARAM; -typedef wxInt64 WXLRESULT; +typedef unsigned __int64 WXWPARAM; +typedef __int64 WXLPARAM; +typedef __int64 WXLRESULT; #else -typedef wxW64 unsigned int WXWPARAM; -typedef wxW64 long WXLPARAM; -typedef wxW64 long WXLRESULT; +typedef unsigned int WXWPARAM; +typedef long WXLPARAM; +typedef long WXLRESULT; #endif #if defined(__GNUWIN32__) || defined(__WXMICROWIN__) @@ -3267,8 +2652,6 @@ typedef unsigned long WXHPALETTE; typedef unsigned long WXHCURSOR; typedef unsigned long WXHRGN; typedef unsigned long WXHACCEL; -typedef unsigned long WXHINSTANCE; -typedef unsigned long WXHMODULE; typedef unsigned long WXHBITMAP; typedef unsigned long WXHDC; typedef unsigned int WXUINT; @@ -3388,49 +2771,56 @@ typedef long WXPixel; /* safety catch in src/motif/colour.cpp */ #ifdef __WXGTK__ /* Stand-ins for GLIB types */ +typedef char gchar; +typedef signed char gint8; +typedef int gint; +typedef unsigned guint; +typedef unsigned long gulong; +typedef void* gpointer; typedef struct _GSList GSList; /* Stand-ins for GDK types */ typedef struct _GdkColor GdkColor; +typedef struct _GdkColormap GdkColormap; +typedef struct _GdkFont GdkFont; +typedef struct _GdkGC GdkGC; +typedef struct _GdkVisual GdkVisual; + +#ifdef __WXGTK20__ +typedef struct _GdkAtom *GdkAtom; +typedef struct _GdkDrawable GdkWindow; +typedef struct _GdkDrawable GdkBitmap; +typedef struct _GdkDrawable GdkPixmap; +#else /* GTK+ 1.2 */ +typedef gulong GdkAtom; +typedef struct _GdkWindow GdkWindow; +typedef struct _GdkWindow GdkBitmap; +typedef struct _GdkWindow GdkPixmap; +#endif /* GTK+ 1.2/2.0 */ + typedef struct _GdkCursor GdkCursor; +typedef struct _GdkRegion GdkRegion; typedef struct _GdkDragContext GdkDragContext; -#if defined(__WXGTK20__) - typedef struct _GdkAtom* GdkAtom; -#else - typedef unsigned long GdkAtom; -#endif - -#if !defined(__WXGTK3__) - typedef struct _GdkColormap GdkColormap; - typedef struct _GdkFont GdkFont; - typedef struct _GdkGC GdkGC; - typedef struct _GdkRegion GdkRegion; -#endif - -#if defined(__WXGTK3__) - typedef struct _GdkWindow GdkWindow; -#elif defined(__WXGTK20__) - typedef struct _GdkDrawable GdkWindow; - typedef struct _GdkDrawable GdkPixmap; -#else - typedef struct _GdkWindow GdkWindow; - typedef struct _GdkWindow GdkBitmap; - typedef struct _GdkWindow GdkPixmap; +#ifdef HAVE_XIM +typedef struct _GdkIC GdkIC; +typedef struct _GdkICAttr GdkICAttr; #endif /* Stand-ins for GTK types */ typedef struct _GtkWidget GtkWidget; typedef struct _GtkRcStyle GtkRcStyle; typedef struct _GtkAdjustment GtkAdjustment; +typedef struct _GtkList GtkList; typedef struct _GtkToolbar GtkToolbar; +typedef struct _GtkTooltips GtkTooltips; typedef struct _GtkNotebook GtkNotebook; typedef struct _GtkNotebookPage GtkNotebookPage; typedef struct _GtkAccelGroup GtkAccelGroup; +typedef struct _GtkItemFactory GtkItemFactory; typedef struct _GtkSelectionData GtkSelectionData; typedef struct _GtkTextBuffer GtkTextBuffer; typedef struct _GtkRange GtkRange; -typedef struct _GtkCellRenderer GtkCellRenderer; typedef GtkWidget *WXWidget; @@ -3454,6 +2844,10 @@ typedef struct _PangoLayout PangoLayout; typedef struct _PangoFontDescription PangoFontDescription; #endif +#ifdef __WXMGL__ +typedef struct window_t *WXWidget; +#endif /* MGL */ + #ifdef __WXDFB__ /* DirectFB doesn't have the concept of non-TLW window, so use something arbitrary */ @@ -3464,59 +2858,36 @@ typedef const void* WXWidget; /* included before or after wxWidgets classes, and therefore must be */ /* disabled here before any significant wxWidgets headers are included. */ #ifdef __cplusplus -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include "wx/msw/winundef.h" -#endif /* __WINDOWS__ */ +#endif /* __WXMSW__ */ #endif /* __cplusplus */ - -/* include the feature test macros */ -#include "wx/features.h" - /* --------------------------------------------------------------------------- */ -/* macros to define a class without copy ctor nor assignment operator */ +/* macro to define a class without copy ctor nor assignment operator */ /* --------------------------------------------------------------------------- */ -#define wxDECLARE_NO_COPY_CLASS(classname) \ +#define DECLARE_NO_COPY_CLASS(classname) \ private: \ classname(const classname&); \ - classname& operator=(const classname&) + classname& operator=(const classname&); -#define wxDECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg) \ - private: \ - classname(const classname&); \ - classname& operator=(const classname&) - -#define wxDECLARE_NO_COPY_TEMPLATE_CLASS_2(classname, arg1, arg2) \ - private: \ - classname(const classname&); \ - classname& operator=(const classname&) - -#define wxDECLARE_NO_ASSIGN_CLASS(classname) \ +#define DECLARE_NO_ASSIGN_CLASS(classname) \ private: \ - classname& operator=(const classname&) - -/* deprecated variants _not_ requiring a semicolon after them */ -#define DECLARE_NO_COPY_CLASS(classname) \ - wxDECLARE_NO_COPY_CLASS(classname); -#define DECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg) \ - wxDECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg); -#define DECLARE_NO_ASSIGN_CLASS(classname) \ - wxDECLARE_NO_ASSIGN_CLASS(classname); + classname& operator=(const classname&); /* --------------------------------------------------------------------------- */ /* If a manifest is being automatically generated, add common controls 6 to it */ /* --------------------------------------------------------------------------- */ -#if wxUSE_GUI && \ - (!defined wxUSE_NO_MANIFEST || wxUSE_NO_MANIFEST == 0 ) && \ +#if (!defined wxUSE_NO_MANIFEST || wxUSE_NO_MANIFEST == 0 ) && \ ( defined _MSC_FULL_VER && _MSC_FULL_VER >= 140040130 ) #define WX_CC_MANIFEST(cpu) \ "/manifestdependency:\"type='win32' \ name='Microsoft.Windows.Common-Controls' \ version='6.0.0.0' \ - processorArchitecture='" cpu "' \ + processorArchitecture='"cpu"' \ publicKeyToken='6595b64144ccf1df' \ language='*'\"" @@ -3532,13 +2903,5 @@ typedef const void* WXWidget; #endif /* !wxUSE_NO_MANIFEST && _MSC_FULL_VER >= 140040130 */ -/* wxThread and wxProcess priorities */ -enum -{ - wxPRIORITY_MIN = 0u, /* lowest possible priority */ - wxPRIORITY_DEFAULT = 50u, /* normal priority */ - wxPRIORITY_MAX = 100u /* highest possible priority */ -}; - #endif /* _WX_DEFS_H_ */ diff --git a/Source/3rd Party/wx/include/wx/dialog.h b/Source/3rd Party/wx/include/wx/dialog.h index 9a6391aae..cf9dbf6c9 100644 --- a/Source/3rd Party/wx/include/wx/dialog.h +++ b/Source/3rd Party/wx/include/wx/dialog.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29.06.99 +// RCS-ID: $Id: dialog.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,22 +12,14 @@ #ifndef _WX_DIALOG_H_BASE_ #define _WX_DIALOG_H_BASE_ -#include "wx/toplevel.h" +#include "wx/defs.h" #include "wx/containr.h" -#include "wx/sharedptr.h" +#include "wx/toplevel.h" class WXDLLIMPEXP_FWD_CORE wxSizer; class WXDLLIMPEXP_FWD_CORE wxStdDialogButtonSizer; -class WXDLLIMPEXP_FWD_CORE wxBoxSizer; -class WXDLLIMPEXP_FWD_CORE wxDialogLayoutAdapter; -class WXDLLIMPEXP_FWD_CORE wxDialog; -class WXDLLIMPEXP_FWD_CORE wxButton; -class WXDLLIMPEXP_FWD_CORE wxScrolledWindow; -class wxTextSizerWrapper; -// Also see the bit summary table in wx/toplevel.h. - -#define wxDIALOG_NO_PARENT 0x00000020 // Don't make owned by apps top window +#define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window #ifdef __WXWINCE__ #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER) @@ -34,56 +27,25 @@ class wxTextSizerWrapper; #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX) #endif -// Layout adaptation levels, for SetLayoutAdaptationLevel +extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[]; -// Don't do any layout adaptation -#define wxDIALOG_ADAPTATION_NONE 0 - -// Only look for wxStdDialogButtonSizer for non-scrolling part -#define wxDIALOG_ADAPTATION_STANDARD_SIZER 1 - -// Also look for any suitable sizer for non-scrolling part -#define wxDIALOG_ADAPTATION_ANY_SIZER 2 - -// Also look for 'loose' standard buttons for non-scrolling part -#define wxDIALOG_ADAPTATION_LOOSE_BUTTONS 3 - -// Layout adaptation mode, for SetLayoutAdaptationMode -enum wxDialogLayoutAdaptationMode -{ - wxDIALOG_ADAPTATION_MODE_DEFAULT = 0, // use global adaptation enabled status - wxDIALOG_ADAPTATION_MODE_ENABLED = 1, // enable this dialog overriding global status - wxDIALOG_ADAPTATION_MODE_DISABLED = 2 // disable this dialog overriding global status -}; - -enum wxDialogModality -{ - wxDIALOG_MODALITY_NONE = 0, - wxDIALOG_MODALITY_WINDOW_MODAL = 1, - wxDIALOG_MODALITY_APP_MODAL = 2 -}; - -extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[]; - -class WXDLLIMPEXP_CORE wxDialogBase : public wxNavigationEnabled +class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow { public: - wxDialogBase(); + enum + { + // all flags allowed in wxDialogBase::CreateButtonSizer() + ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT + }; + + wxDialogBase() { Init(); } virtual ~wxDialogBase() { } // define public wxDialog methods to be implemented by the derived classes virtual int ShowModal() = 0; virtual void EndModal(int retCode) = 0; virtual bool IsModal() const = 0; - // show the dialog frame-modally (needs a parent), using app-modal - // dialogs on platforms that don't support it - virtual void ShowWindowModal () ; - virtual void SendWindowModalDialogEvent ( wxEventType type ); -#ifdef wxHAS_EVENT_BIND - template - void ShowWindowModalThenDo(const Functor& onEndModal); -#endif // wxHAS_EVENT_BIND // Modal dialogs have a return code - usually the id of the last // pressed button @@ -102,33 +64,10 @@ public: void SetEscapeId(int escapeId); int GetEscapeId() const { return m_escapeId; } - // Find the parent to use for modal dialog: try to use the specified parent - // but fall back to the current active window or main application window as - // last resort if it is unsuitable. - // - // As this function is often called from the ctor, the window style may be - // not set yet and hence must be passed explicitly to it so that we could - // check whether it contains wxDIALOG_NO_PARENT bit. - // - // This function always returns a valid top level window or NULL. - wxWindow *GetParentForModalDialog(wxWindow *parent, long style) const; - - // This overload can only be used for already initialized windows, i.e. not - // from the ctor. It uses the current window parent and style. - wxWindow *GetParentForModalDialog() const - { - return GetParentForModalDialog(GetParent(), GetWindowStyle()); - } - #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL - // splits text up at newlines and places the lines into a vertical - // wxBoxSizer - wxSizer *CreateTextSizer( const wxString& message ); - - // same as above but uses a customized wxTextSizerWrapper to create - // non-standard controls for the lines - wxSizer *CreateTextSizer( const wxString& message, - wxTextSizerWrapper& wrapper ); + // splits text up at newlines and places the + // lines into a vertical wxBoxSizer + wxSizer *CreateTextSizer( const wxString &message ); #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL // returns a horizontal wxBoxSizer containing the given buttons @@ -138,64 +77,15 @@ public: // platforms which have hardware buttons replacing OK/Cancel and such) wxSizer *CreateButtonSizer(long flags); - // returns a sizer containing the given one and a static line separating it - // from the preceding elements if it's appropriate for the current platform - wxSizer *CreateSeparatedSizer(wxSizer *sizer); - // returns the sizer containing CreateButtonSizer() below a separating // static line for the platforms which use static lines for items // separation (i.e. not Mac) - // - // this is just a combination of CreateButtonSizer() and - // CreateSeparatedSizer() wxSizer *CreateSeparatedButtonSizer(long flags); #if wxUSE_BUTTON wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags ); #endif // wxUSE_BUTTON - // Do layout adaptation - virtual bool DoLayoutAdaptation(); - - // Can we do layout adaptation? - virtual bool CanDoLayoutAdaptation(); - - // Returns a content window if there is one. This can be used by the layout adapter, for - // example to make the pages of a book control into scrolling windows - virtual wxWindow* GetContentWindow() const { return NULL; } - - // Add an id to the list of main button identifiers that should be in the button sizer - void AddMainButtonId(wxWindowID id) { m_mainButtonIds.Add((int) id); } - wxArrayInt& GetMainButtonIds() { return m_mainButtonIds; } - - // Is this id in the main button id array? - bool IsMainButtonId(wxWindowID id) const { return (m_mainButtonIds.Index((int) id) != wxNOT_FOUND); } - - // Level of adaptation, from none (Level 0) to full (Level 3). To disable adaptation, - // set level 0, for example in your dialog constructor. You might - // do this if you know that you are displaying on a large screen and you don't want the - // dialog changed. - void SetLayoutAdaptationLevel(int level) { m_layoutAdaptationLevel = level; } - int GetLayoutAdaptationLevel() const { return m_layoutAdaptationLevel; } - - /// Override global adaptation enabled/disabled status - void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode) { m_layoutAdaptationMode = mode; } - wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const { return m_layoutAdaptationMode; } - - // Returns true if the adaptation has been done - void SetLayoutAdaptationDone(bool adaptationDone) { m_layoutAdaptationDone = adaptationDone; } - bool GetLayoutAdaptationDone() const { return m_layoutAdaptationDone; } - - // Set layout adapter class, returning old adapter - static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter); - static wxDialogLayoutAdapter* GetLayoutAdapter() { return sm_layoutAdapter; } - - // Global switch for layout adaptation - static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; } - static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; } - - // modality kind - virtual wxDialogModality GetModality() const; protected: // emulate click of a button with the given id if it's present in the dialog // @@ -218,6 +108,7 @@ protected: // wxID_OK return code void AcceptAndClose(); + // The return code from modal dialog int m_returnCode; @@ -227,36 +118,9 @@ protected: // The identifier for cancel button (usually wxID_CANCEL) int m_escapeId; - // Flags whether layout adaptation has been done for this dialog - bool m_layoutAdaptationDone; - - // Extra button identifiers to be taken as 'main' button identifiers - // to be placed in the non-scrolling area - wxArrayInt m_mainButtonIds; - - // Adaptation level - int m_layoutAdaptationLevel; - - // Local override for global adaptation enabled status - wxDialogLayoutAdaptationMode m_layoutAdaptationMode; - - // Global layout adapter - static wxDialogLayoutAdapter* sm_layoutAdapter; - - // Global adaptation switch - static bool sm_layoutAdaptation; - private: - // helper of GetParentForModalDialog(): returns the passed in window if it - // can be used as our parent or NULL if it can't - wxWindow *CheckIfCanBeUsedAsParent(wxWindow *parent) const; - - // Helper of OnCharHook() and OnCloseWindow(): find the appropriate button - // for closing the dialog and send a click event for it. - // - // Return true if we found a button to close the dialog and "clicked" it or - // false otherwise. - bool SendCloseButtonClickEvent(); + // common part of all ctors + void Init(); // handle Esc key presses void OnCharHook(wxKeyEvent& event); @@ -271,88 +135,18 @@ private: void OnSysColourChanged(wxSysColourChangedEvent& event); - wxDECLARE_NO_COPY_CLASS(wxDialogBase); + DECLARE_NO_COPY_CLASS(wxDialogBase) DECLARE_EVENT_TABLE() + WX_DECLARE_CONTROL_CONTAINER(); }; -/*! - * Base class for layout adapters - code that, for example, turns a dialog into a - * scrolling dialog if there isn't enough screen space. You can derive further - * adapter classes to do any other kind of adaptation, such as applying a watermark, or adding - * a help mechanism. - */ - -class WXDLLIMPEXP_CORE wxDialogLayoutAdapter: public wxObject -{ - DECLARE_CLASS(wxDialogLayoutAdapter) -public: - wxDialogLayoutAdapter() {} - - // Override this function to indicate that adaptation should be done - virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0; - - // Override this function to do the adaptation - virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0; -}; - -/*! - * Standard adapter. Does scrolling adaptation for paged and regular dialogs. - * - */ - -class WXDLLIMPEXP_CORE wxStandardDialogLayoutAdapter: public wxDialogLayoutAdapter -{ - DECLARE_CLASS(wxStandardDialogLayoutAdapter) -public: - wxStandardDialogLayoutAdapter() {} - -// Overrides - - // Indicate that adaptation should be done - virtual bool CanDoLayoutAdaptation(wxDialog* dialog); - - // Do layout adaptation - virtual bool DoLayoutAdaptation(wxDialog* dialog); - -// Implementation - - // Create the scrolled window - virtual wxScrolledWindow* CreateScrolledWindow(wxWindow* parent); - -#if wxUSE_BUTTON - // Find a standard or horizontal box sizer - virtual wxSizer* FindButtonSizer(bool stdButtonSizer, wxDialog* dialog, wxSizer* sizer, int& retBorder, int accumlatedBorder = 0); - - // Check if this sizer contains standard buttons, and so can be repositioned in the dialog - virtual bool IsOrdinaryButtonSizer(wxDialog* dialog, wxBoxSizer* sizer); - - // Check if this is a standard button - virtual bool IsStandardButton(wxDialog* dialog, wxButton* button); - - // Find 'loose' main buttons in the existing layout and add them to the standard dialog sizer - virtual bool FindLooseButtons(wxDialog* dialog, wxStdDialogButtonSizer* buttonSizer, wxSizer* sizer, int& count); -#endif // wxUSE_BUTTON - - // Reparent the controls to the scrolled window, except those in buttonSizer - virtual void ReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL); - static void DoReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL); - - // A function to fit the dialog around its contents, and then adjust for screen size. - // If scrolled windows are passed, scrolling is enabled in the required orientation(s). - virtual bool FitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow); - virtual bool FitWithScrolling(wxDialog* dialog, wxWindowList& windows); - static bool DoFitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow); - static bool DoFitWithScrolling(wxDialog* dialog, wxWindowList& windows); - - // Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both - virtual int MustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize); - static int DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize); -}; #if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__) #include "wx/univ/dialog.h" #else - #if defined(__WXMSW__) + #if defined(__WXPALMOS__) + #include "wx/palmos/dialog.h" + #elif defined(__WXMSW__) #include "wx/msw/dialog.h" #elif defined(__WXMOTIF__) #include "wx/motif/dialog.h" @@ -361,7 +155,7 @@ public: #elif defined(__WXGTK__) #include "wx/gtk1/dialog.h" #elif defined(__WXMAC__) - #include "wx/osx/dialog.h" + #include "wx/mac/dialog.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/dialog.h" #elif defined(__WXPM__) @@ -369,73 +163,5 @@ public: #endif #endif -class WXDLLIMPEXP_CORE wxWindowModalDialogEvent : public wxCommandEvent -{ -public: - wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0) - : wxCommandEvent(commandType, id) { } - - wxDialog *GetDialog() const - { return wxStaticCast(GetEventObject(), wxDialog); } - - int GetReturnCode() const - { return GetDialog()->GetReturnCode(); } - - virtual wxEvent *Clone() const { return new wxWindowModalDialogEvent (*this); } - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowModalDialogEvent ) -}; - -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent ); - -typedef void (wxEvtHandler::*wxWindowModalDialogEventFunction)(wxWindowModalDialogEvent &); - -#define wxWindowModalDialogEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxWindowModalDialogEventFunction, func) - -#define EVT_WINDOW_MODAL_DIALOG_CLOSED(winid, func) \ - wx__DECLARE_EVT1(wxEVT_WINDOW_MODAL_DIALOG_CLOSED, winid, wxWindowModalDialogEventHandler(func)) - -#ifdef wxHAS_EVENT_BIND -template -class wxWindowModalDialogEventFunctor -{ -public: - wxWindowModalDialogEventFunctor(const Functor& f) - : m_f(new Functor(f)) - {} - - void operator()(wxWindowModalDialogEvent& event) - { - if ( m_f ) - { - // We only want to call this handler once. Also, by deleting - // the functor here, its data (such as wxWindowPtr pointing to - // the dialog) are freed immediately after exiting this operator(). - wxSharedPtr functor(m_f); - m_f.reset(); - - (*functor)(event.GetReturnCode()); - } - else // was already called once - { - event.Skip(); - } - } - -private: - wxSharedPtr m_f; -}; - -template -void wxDialogBase::ShowWindowModalThenDo(const Functor& onEndModal) -{ - Bind(wxEVT_WINDOW_MODAL_DIALOG_CLOSED, - wxWindowModalDialogEventFunctor(onEndModal)); - ShowWindowModal(); -} -#endif // wxHAS_EVENT_BIND - #endif // _WX_DIALOG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dialup.h b/Source/3rd Party/wx/include/wx/dialup.h index 6c1786605..b86e70cba 100644 --- a/Source/3rd Party/wx/include/wx/dialup.h +++ b/Source/3rd Party/wx/include/wx/dialup.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 07.07.99 +// RCS-ID: $Id: dialup.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -42,7 +43,7 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; * main thread? */ -class WXDLLIMPEXP_CORE wxDialUpManager +class WXDLLEXPORT wxDialUpManager { public: // this function should create and return the object of the @@ -151,13 +152,13 @@ public: // wxDialUpManager events // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_CORE wxDialUpEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIALUP_CONNECTED, wxDialUpEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIALUP_DISCONNECTED, wxDialUpEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED, 450) + DECLARE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED, 451) +END_DECLARE_EVENT_TYPES() // the event class for the dialup events -class WXDLLIMPEXP_CORE wxDialUpEvent : public wxEvent +class WXDLLEXPORT wxDialUpEvent : public wxEvent { public: wxDialUpEvent(bool isConnected, bool isOwnEvent) : wxEvent(isOwnEvent) @@ -170,7 +171,7 @@ public: bool IsConnectedEvent() const { return GetEventType() == wxEVT_DIALUP_CONNECTED; } - // does this event come from wxDialUpManager::Dial() or from some external + // does this event come from wxDialUpManager::Dial() or from some extrenal // process (i.e. does it result from our own attempt to establish the // connection)? bool IsOwnEvent() const { return m_id != 0; } @@ -179,14 +180,14 @@ public: virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); } private: - wxDECLARE_NO_ASSIGN_CLASS(wxDialUpEvent); + DECLARE_NO_ASSIGN_CLASS(wxDialUpEvent) }; // the type of dialup event handler function typedef void (wxEvtHandler::*wxDialUpEventFunction)(wxDialUpEvent&); #define wxDialUpEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxDialUpEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDialUpEventFunction, &func) // macros to catch dialup events #define EVT_DIALUP_CONNECTED(func) \ diff --git a/Source/3rd Party/wx/include/wx/dir.h b/Source/3rd Party/wx/include/wx/dir.h index 914e74f93..90cee0225 100644 --- a/Source/3rd Party/wx/include/wx/dir.h +++ b/Source/3rd Party/wx/include/wx/dir.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 08.12.99 +// RCS-ID: $Id: dir.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 1999 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,7 +14,6 @@ #include "wx/longlong.h" #include "wx/string.h" -#include "wx/filefn.h" // for wxS_DIR_DEFAULT class WXDLLIMPEXP_FWD_BASE wxArrayString; @@ -21,17 +21,14 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; // constants // ---------------------------------------------------------------------------- -// These flags affect the behaviour of GetFirst/GetNext() and Traverse(). -// They define what types are included in the list of items they produce. -// Note that wxDIR_NO_FOLLOW is relevant only on Unix and ignored under systems -// not supporting symbolic links. -enum wxDirFlags +// these flags define what kind of filenames is included in the list of files +// enumerated by GetFirst/GetNext +enum { wxDIR_FILES = 0x0001, // include files wxDIR_DIRS = 0x0002, // include directories wxDIR_HIDDEN = 0x0004, // include hidden files wxDIR_DOTDOT = 0x0008, // include '.' and '..' - wxDIR_NO_FOLLOW = 0x0010, // don't dereference any symlink // by default, enumerate everything except '.' and '..' wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN @@ -66,7 +63,7 @@ public: virtual wxDirTraverseResult OnDir(const wxString& dirname) = 0; // called for each directory which we couldn't open during our traversal - // of the directory tree + // of the directory tyree // // this method can also return either wxDIR_STOP, wxDIR_IGNORE or // wxDIR_CONTINUE but the latter is treated specially: it means to retry @@ -86,6 +83,8 @@ class WXDLLIMPEXP_FWD_BASE wxDirData; class WXDLLIMPEXP_BASE wxDir { public: + // test for existence of a directory with the given name + static bool Exists(const wxString& dir); // ctors // ----- @@ -96,26 +95,18 @@ public: // opens the directory for enumeration, use IsOpened() to test success wxDir(const wxString& dir); - // dtor calls Close() automatically - ~wxDir() { Close(); } + // dtor cleans up the associated ressources + ~wxDir(); // open the directory for enumerating bool Open(const wxString& dir); - // close the directory, Open() can be called again later - void Close(); - // returns true if the directory was successfully opened bool IsOpened() const; // get the full name of the directory (without '/' at the end) wxString GetName() const; - // Same as GetName() but does include the trailing separator, unless the - // string is empty (only for invalid directories). - wxString GetNameWithSep() const; - - // file enumeration routines // ------------------------- @@ -129,10 +120,10 @@ public: bool GetNext(wxString *filename) const; // return true if this directory has any files in it - bool HasFiles(const wxString& spec = wxEmptyString) const; + bool HasFiles(const wxString& spec = wxEmptyString); // return true if this directory has any subdirectories - bool HasSubDirs(const wxString& spec = wxEmptyString) const; + bool HasSubDirs(const wxString& spec = wxEmptyString); // enumerate all files in this directory and its subdirectories // @@ -155,31 +146,15 @@ public: const wxString& filespec, int flags = wxDIR_DEFAULT); -#if wxUSE_LONGLONG // returns the size of all directories recursively found in given path static wxULongLong GetTotalSize(const wxString &dir, wxArrayString *filesSkipped = NULL); -#endif // wxUSE_LONGLONG - - - // static utilities for directory management - // (alias to wxFileName's functions for dirs) - // ----------------------------------------- - - // test for existence of a directory with the given name - static bool Exists(const wxString& dir); - - static bool Make(const wxString &dir, int perm = wxS_DIR_DEFAULT, - int flags = 0); - - static bool Remove(const wxString &dir, int flags = 0); - private: friend class wxDirData; wxDirData *m_data; - wxDECLARE_NO_COPY_CLASS(wxDir); + DECLARE_NO_COPY_CLASS(wxDir) }; #endif // _WX_DIR_H_ diff --git a/Source/3rd Party/wx/include/wx/dirctrl.h b/Source/3rd Party/wx/include/wx/dirctrl.h deleted file mode 100644 index 1d9d1ba18..000000000 --- a/Source/3rd Party/wx/include/wx/dirctrl.h +++ /dev/null @@ -1,17 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/dirctrl.h -// Purpose: Directory control base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DIRCTRL_H_BASE_ -#define _WX_DIRCTRL_H_BASE_ - -#include "wx/generic/dirctrlg.h" - -#endif - // _WX_DIRCTRL_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dirdlg.h b/Source/3rd Party/wx/include/wx/dirdlg.h index bbe393816..8c6d2f8fe 100644 --- a/Source/3rd Party/wx/include/wx/dirdlg.h +++ b/Source/3rd Party/wx/include/wx/dirdlg.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Robert Roebling +// RCS-ID: $Id: dirdlg.h 44027 2006-12-21 19:26:48Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -19,9 +20,9 @@ // constants // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogDefaultFolderStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogDefaultFolderStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[]; #define wxDD_CHANGE_DIR 0x0100 #define wxDD_DIR_MUST_EXIST 0x0200 @@ -39,7 +40,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; // wxDirDialogBase //------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDirDialogBase : public wxDialog +class WXDLLEXPORT wxDirDialogBase : public wxDialog { public: wxDirDialogBase() {} @@ -95,7 +96,8 @@ protected: #if defined(__WXUNIVERSAL__) #include "wx/generic/dirdlgg.h" #define wxDirDialog wxGenericDirDialog -#elif defined(__WXMSW__) && (!wxUSE_OLE || \ +#elif defined(__WXMSW__) && (defined(__SALFORDC__) || \ + !wxUSE_OLE || \ (defined (__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)) #include "wx/generic/dirdlgg.h" #define wxDirDialog wxGenericDirDialog @@ -104,17 +106,18 @@ protected: #define wxDirDialog wxGenericDirDialog #elif defined(__WXMSW__) #include "wx/msw/dirdlg.h" // Native MSW -#elif defined(__WXGTK20__) +#elif defined(__WXGTK24__) #include "wx/gtk/dirdlg.h" // Native GTK for gtk2.4 #elif defined(__WXGTK__) #include "wx/generic/dirdlgg.h" #define wxDirDialog wxGenericDirDialog #elif defined(__WXMAC__) - #include "wx/osx/dirdlg.h" // Native Mac + #include "wx/mac/dirdlg.h" // Native Mac #elif defined(__WXCOCOA__) #include "wx/cocoa/dirdlg.h" // Native Cocoa #elif defined(__WXMOTIF__) || \ defined(__WXX11__) || \ + defined(__WXMGL__) || \ defined(__WXCOCOA__) || \ defined(__WXPM__) #include "wx/generic/dirdlgg.h" // Other ports use generic implementation @@ -125,7 +128,7 @@ protected: // common ::wxDirSelector() function // ---------------------------------------------------------------------------- -WXDLLIMPEXP_CORE wxString +WXDLLEXPORT wxString wxDirSelector(const wxString& message = wxDirSelectorPromptStr, const wxString& defaultPath = wxEmptyString, long style = wxDD_DEFAULT_STYLE, diff --git a/Source/3rd Party/wx/include/wx/display.h b/Source/3rd Party/wx/include/wx/display.h index 95ed21767..98a52ec30 100644 --- a/Source/3rd Party/wx/include/wx/display.h +++ b/Source/3rd Party/wx/include/wx/display.h @@ -3,6 +3,7 @@ // Purpose: wxDisplay class // Author: Royce Mitchell III, Vadim Zeitlin // Created: 06/21/02 +// RCS-ID: $Id: display.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 2002-2006 wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes); // default, uninitialized, video mode object - extern WXDLLIMPEXP_DATA_CORE(const wxVideoMode) wxDefaultVideoMode; + extern WXDLLEXPORT_DATA(const wxVideoMode) wxDefaultVideoMode; #endif // wxUSE_DISPLAY class WXDLLIMPEXP_FWD_CORE wxWindow; @@ -36,7 +37,7 @@ class WXDLLIMPEXP_FWD_CORE wxDisplayImpl; // wxDisplay: represents a display/monitor attached to the system // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDisplay +class WXDLLEXPORT wxDisplay { public: // initialize the object containing all information about the given @@ -61,7 +62,7 @@ public: // find the display where the given window lies, return wxNOT_FOUND if it // is not shown at all - static int GetFromWindow(const wxWindow *window); + static int GetFromWindow(wxWindow *window); // return true if the object was initialized successfully @@ -121,7 +122,7 @@ private: wxDisplayImpl *m_impl; - wxDECLARE_NO_COPY_CLASS(wxDisplay); + DECLARE_NO_COPY_CLASS(wxDisplay) }; #endif // _WX_DISPLAY_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/display_impl.h b/Source/3rd Party/wx/include/wx/display_impl.h index 15b361ceb..8c38f6522 100644 --- a/Source/3rd Party/wx/include/wx/display_impl.h +++ b/Source/3rd Party/wx/include/wx/display_impl.h @@ -3,6 +3,7 @@ // Purpose: wxDisplayImpl class declaration // Author: Vadim Zeitlin // Created: 2006-03-15 +// RCS-ID: $Id: display_impl.h 41548 2006-10-02 05:38:05Z PC $ // Copyright: (c) 2002-2006 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,7 @@ // wxDisplayFactory: allows to create wxDisplay objects // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDisplayFactory +class WXDLLEXPORT wxDisplayFactory { public: wxDisplayFactory() { } @@ -36,14 +37,14 @@ public: // return the display for the given window or wxNOT_FOUND // // the window pointer must not be NULL (i.e. caller should check it) - virtual int GetFromWindow(const wxWindow *window); + virtual int GetFromWindow(wxWindow *window); }; // ---------------------------------------------------------------------------- // wxDisplayImpl: base class for all wxDisplay implementations // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDisplayImpl +class WXDLLEXPORT wxDisplayImpl { public: // virtual dtor for this base class @@ -88,7 +89,7 @@ protected: friend class wxDisplayFactory; - wxDECLARE_NO_COPY_CLASS(wxDisplayImpl); + DECLARE_NO_COPY_CLASS(wxDisplayImpl) }; // ---------------------------------------------------------------------------- @@ -97,7 +98,7 @@ protected: // this is a stub implementation using single/main display only, it is // available even if wxUSE_DISPLAY == 0 -class WXDLLIMPEXP_CORE wxDisplayFactorySingle : public wxDisplayFactory +class WXDLLEXPORT wxDisplayFactorySingle : public wxDisplayFactory { public: virtual wxDisplayImpl *CreateDisplay(unsigned n); diff --git a/Source/3rd Party/wx/include/wx/dlimpexp.h b/Source/3rd Party/wx/include/wx/dlimpexp.h index 0e0ca8906..743785e04 100644 --- a/Source/3rd Party/wx/include/wx/dlimpexp.h +++ b/Source/3rd Party/wx/include/wx/dlimpexp.h @@ -4,6 +4,7 @@ * Author: Vadim Zeitlin * Modified by: * Created: 16.10.2003 (extracted from wx/defs.h) + * RCS-ID: $Id: dlimpexp.h 49563 2007-10-31 20:46:21Z VZ $ * Copyright: (c) 2003 Vadim Zeitlin * Licence: wxWindows licence */ @@ -15,31 +16,17 @@ #ifndef _WX_DLIMPEXP_H_ #define _WX_DLIMPEXP_H_ -#if defined(HAVE_VISIBILITY) -# define WXEXPORT __attribute__ ((visibility("default"))) -# define WXIMPORT __attribute__ ((visibility("default"))) -#elif defined(__WINDOWS__) +#if defined(__WXMSW__) /* __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well - as VC++. + as VC++ and gcc */ -# if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) +# if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__) # define WXEXPORT __declspec(dllexport) # define WXIMPORT __declspec(dllimport) - /* - While gcc also supports __declspec(dllexport), it creates unusably huge - DLL files since gcc 4.5 (while taking horribly long amounts of time), - see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601. Because of this - we rely on binutils auto export/import support which seems to work - quite well for 4.5+. - */ -# elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5) - /* - __declspec could be used here too but let's use the native - __attribute__ instead for clarity. - */ -# define WXEXPORT __attribute__((dllexport)) -# define WXIMPORT __attribute__((dllimport)) +# else /* compiler doesn't support __declspec() */ +# define WXEXPORT +# define WXIMPORT # endif #elif defined(__WXPM__) # if defined (__WATCOMC__) @@ -56,6 +43,11 @@ # define WXEXPORT _Export # define WXIMPORT _Export # endif +#elif defined(__WXMAC__) || defined(__WXCOCOA__) +# ifdef __MWERKS__ +# define WXEXPORT __declspec(export) +# define WXIMPORT __declspec(import) +# endif #elif defined(__CYGWIN__) # define WXEXPORT __declspec(dllexport) # define WXIMPORT __declspec(dllimport) @@ -72,7 +64,7 @@ support arbitrary combinations of libs/DLLs: either we build all of them as DLLs (in which case WXMAKINGDLL is defined) or none (it isn't). - However we have a problem because we need separate WXDLLIMPEXP versions for + However we have a problem because we need separate WXDLLEXPORT versions for different libraries as, for example, wxString class should be dllexported when compiled in wxBase and dllimported otherwise, so we do define separate WXMAKING/USINGDLL_XYZ constants for each component XYZ. @@ -86,43 +78,30 @@ # define WXMAKINGDLL_CORE # define WXMAKINGDLL_ADV # define WXMAKINGDLL_QA +# define WXMAKINGDLL_ODBC +# define WXMAKINGDLL_DBGRID # define WXMAKINGDLL_HTML # define WXMAKINGDLL_GL # define WXMAKINGDLL_XML # define WXMAKINGDLL_XRC # define WXMAKINGDLL_AUI -# define WXMAKINGDLL_PROPGRID -# define WXMAKINGDLL_RIBBON # define WXMAKINGDLL_RICHTEXT # define WXMAKINGDLL_MEDIA -# define WXMAKINGDLL_STC -# define WXMAKINGDLL_WEBVIEW #endif /* WXMAKINGDLL */ /* - WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import + WXDLLEXPORT maps to export declaration when building the DLL, to import declaration if using it or to nothing at all if we don't use wxWin as DLL */ #ifdef WXMAKINGDLL_BASE # define WXDLLIMPEXP_BASE WXEXPORT # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type -# if defined(HAVE_VISIBILITY) -# define WXDLLIMPEXP_INLINE_BASE WXEXPORT -# else -# define WXDLLIMPEXP_INLINE_BASE -# endif #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_BASE WXIMPORT # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type -# if defined(HAVE_VISIBILITY) -# define WXDLLIMPEXP_INLINE_BASE WXIMPORT -# else -# define WXDLLIMPEXP_INLINE_BASE -# endif #else /* not making nor using DLL */ # define WXDLLIMPEXP_BASE # define WXDLLIMPEXP_DATA_BASE(type) type -# define WXDLLIMPEXP_INLINE_BASE #endif #ifdef WXMAKINGDLL_NET @@ -139,23 +118,12 @@ #ifdef WXMAKINGDLL_CORE # define WXDLLIMPEXP_CORE WXEXPORT # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type -# if defined(HAVE_VISIBILITY) -# define WXDLLIMPEXP_INLINE_CORE WXEXPORT -# else -# define WXDLLIMPEXP_INLINE_CORE -# endif #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_CORE WXIMPORT # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type -# if defined(HAVE_VISIBILITY) -# define WXDLLIMPEXP_INLINE_CORE WXIMPORT -# else -# define WXDLLIMPEXP_INLINE_CORE -# endif #else /* not making nor using DLL */ # define WXDLLIMPEXP_CORE # define WXDLLIMPEXP_DATA_CORE(type) type -# define WXDLLIMPEXP_INLINE_CORE #endif #ifdef WXMAKINGDLL_ADV @@ -169,6 +137,17 @@ # define WXDLLIMPEXP_DATA_ADV(type) type #endif +#ifdef WXMAKINGDLL_ODBC +# define WXDLLIMPEXP_ODBC WXEXPORT +# define WXDLLIMPEXP_DATA_ODBC(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_ODBC WXIMPORT +# define WXDLLIMPEXP_DATA_ODBC(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_ODBC +# define WXDLLIMPEXP_DATA_ODBC(type) type +#endif + #ifdef WXMAKINGDLL_QA # define WXDLLIMPEXP_QA WXEXPORT # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type @@ -180,6 +159,17 @@ # define WXDLLIMPEXP_DATA_QA(type) type #endif +#ifdef WXMAKINGDLL_DBGRID +# define WXDLLIMPEXP_DBGRID WXEXPORT +# define WXDLLIMPEXP_DATA_DBGRID(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_DBGRID WXIMPORT +# define WXDLLIMPEXP_DATA_DBGRID(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_DBGRID +# define WXDLLIMPEXP_DATA_DBGRID(type) type +#endif + #ifdef WXMAKINGDLL_HTML # define WXDLLIMPEXP_HTML WXEXPORT # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type @@ -223,25 +213,6 @@ # define WXDLLIMPEXP_AUI #endif -#ifdef WXMAKINGDLL_PROPGRID -# define WXDLLIMPEXP_PROPGRID WXEXPORT -# define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type -#elif defined(WXUSINGDLL) -# define WXDLLIMPEXP_PROPGRID WXIMPORT -# define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type -#else /* not making nor using DLL */ -# define WXDLLIMPEXP_PROPGRID -# define WXDLLIMPEXP_DATA_PROPGRID(type) type -#endif - -#ifdef WXMAKINGDLL_RIBBON -# define WXDLLIMPEXP_RIBBON WXEXPORT -#elif defined(WXUSINGDLL) -# define WXDLLIMPEXP_RIBBON WXIMPORT -#else /* not making nor using DLL */ -# define WXDLLIMPEXP_RIBBON -#endif - #ifdef WXMAKINGDLL_RICHTEXT # define WXDLLIMPEXP_RICHTEXT WXEXPORT #elif defined(WXUSINGDLL) @@ -258,35 +229,19 @@ # define WXDLLIMPEXP_MEDIA #endif -#ifdef WXMAKINGDLL_STC -# define WXDLLIMPEXP_STC WXEXPORT -# define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type -#elif defined(WXUSINGDLL) -# define WXDLLIMPEXP_STC WXIMPORT -# define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type -#else /* not making nor using DLL */ -# define WXDLLIMPEXP_STC -# define WXDLLIMPEXP_DATA_STC(type) type -#endif +/* for backwards compatibility, define suffix-less versions too */ +#define WXDLLEXPORT WXDLLIMPEXP_CORE +#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE -#ifdef WXMAKINGDLL_WEBVIEW -# define WXDLLIMPEXP_WEBVIEW WXEXPORT -# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type -#elif defined(WXUSINGDLL) -# define WXDLLIMPEXP_WEBVIEW WXIMPORT -# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type -#else /* not making nor using DLL */ -# define WXDLLIMPEXP_WEBVIEW -# define WXDLLIMPEXP_DATA_WEBVIEW(type) type -#endif - -/* +/* wx-2.9 introduces new macros for forward declarations, include them + * here for forward compatibility: + GCC warns about using __attribute__ (and also __declspec in mingw32 case) on forward declarations while MSVC complains about forward declarations without __declspec for the classes later declared with it, so we need a separate set of macros for forward declarations to hide this difference: */ -#if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__)) +#if defined(__WINDOWS__) && defined(__GNUC__) #define WXDLLIMPEXP_FWD_BASE #define WXDLLIMPEXP_FWD_NET #define WXDLLIMPEXP_FWD_CORE @@ -297,12 +252,9 @@ #define WXDLLIMPEXP_FWD_XML #define WXDLLIMPEXP_FWD_XRC #define WXDLLIMPEXP_FWD_AUI - #define WXDLLIMPEXP_FWD_PROPGRID - #define WXDLLIMPEXP_FWD_RIBBON #define WXDLLIMPEXP_FWD_RICHTEXT #define WXDLLIMPEXP_FWD_MEDIA #define WXDLLIMPEXP_FWD_STC - #define WXDLLIMPEXP_FWD_WEBVIEW #else #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET @@ -314,51 +266,10 @@ #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI - #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID - #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC - #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW #endif -/* for backwards compatibility, define suffix-less versions too */ -#define WXDLLEXPORT WXDLLIMPEXP_CORE -#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE - -/* - MSVC up to 6.0 needs to be explicitly told to export template instantiations - used by the DLL clients, use this macro to do it like this: - - template class Foo { ... }; - WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo ) - - (notice that currently we only need this for wxBase and wxCore libraries) - */ -#if defined(__VISUALC__) && (__VISUALC__ <= 1200) - #ifdef WXMAKINGDLL_BASE - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ - template class WXDLLIMPEXP_BASE decl; - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ - template class WXDLLIMPEXP_CORE decl; - #else - /* - We need to disable this warning when using this macro, as - recommended by Microsoft itself: - - http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958 - */ - #pragma warning(disable:4231) - - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ - extern template class WXDLLIMPEXP_BASE decl; - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ - extern template class WXDLLIMPEXP_CORE decl; - #endif -#else /* not VC <= 6 */ - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) - #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) -#endif /* VC6/others */ - #endif /* _WX_DLIMPEXP_H_ */ diff --git a/Source/3rd Party/wx/include/wx/dlist.h b/Source/3rd Party/wx/include/wx/dlist.h deleted file mode 100644 index b69f617d9..000000000 --- a/Source/3rd Party/wx/include/wx/dlist.h +++ /dev/null @@ -1,850 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/dlist.h -// Purpose: wxDList which is a template version of wxList -// Author: Robert Roebling -// Created: 18.09.2008 -// Copyright: (c) 2008 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DLIST_H_ -#define _WX_DLIST_H_ - -#include "wx/defs.h" -#include "wx/utils.h" - -#if wxUSE_STD_CONTAINERS - -#include "wx/beforestd.h" -#include -#include -#include -#include "wx/afterstd.h" - -template -class wxDList: public std::list -{ -private: - bool m_destroy; - typedef std::list BaseListType; - typedef wxDList ListType; - -public: - typedef typename BaseListType::iterator iterator; - - class compatibility_iterator - { - private: - /* Workaround for broken VC6 nested class name resolution */ - typedef typename BaseListType::iterator iterator; - friend class wxDList; - - iterator m_iter; - ListType *m_list; - - public: - compatibility_iterator() - : m_iter(), m_list( NULL ) {} - compatibility_iterator( ListType* li, iterator i ) - : m_iter( i ), m_list( li ) {} - compatibility_iterator( const ListType* li, iterator i ) - : m_iter( i ), m_list( const_cast(li) ) {} - - compatibility_iterator* operator->() { return this; } - const compatibility_iterator* operator->() const { return this; } - - bool operator==(const compatibility_iterator& i) const - { - wxASSERT_MSG( m_list && i.m_list, - "comparing invalid iterators is illegal" ); - return (m_list == i.m_list) && (m_iter == i.m_iter); - } - bool operator!=(const compatibility_iterator& i) const - { return !( operator==( i ) ); } - operator bool() const - { return m_list ? m_iter != m_list->end() : false; } - bool operator !() const - { return !( operator bool() ); } - - T* GetData() const { return *m_iter; } - void SetData( T* e ) { *m_iter = e; } - - compatibility_iterator GetNext() const - { - iterator i = m_iter; - return compatibility_iterator( m_list, ++i ); - } - - compatibility_iterator GetPrevious() const - { - if ( m_iter == m_list->begin() ) - return compatibility_iterator(); - - iterator i = m_iter; - return compatibility_iterator( m_list, --i ); - } - - int IndexOf() const - { - return *this ? std::distance( m_list->begin(), m_iter ) - : wxNOT_FOUND; - } - }; - -public: - wxDList() : m_destroy( false ) {} - - ~wxDList() { Clear(); } - - compatibility_iterator Find( const T* e ) const - { - return compatibility_iterator( this, - std::find( const_cast(this)->begin(), - const_cast(this)->end(), e ) ); - } - - bool IsEmpty() const - { return this->empty(); } - size_t GetCount() const - { return this->size(); } - - compatibility_iterator Item( size_t idx ) const - { - iterator i = const_cast(this)->begin(); - std::advance( i, idx ); - return compatibility_iterator( this, i ); - } - - T* operator[](size_t idx) const - { - return Item(idx).GetData(); - } - - compatibility_iterator GetFirst() const - { - return compatibility_iterator( this, const_cast(this)->begin() ); - } - compatibility_iterator GetLast() const - { - iterator i = const_cast(this)->end(); - return compatibility_iterator( this, !(this->empty()) ? --i : i ); - } - compatibility_iterator Member( T* e ) const - { return Find( e ); } - compatibility_iterator Nth( int n ) const - { return Item( n ); } - int IndexOf( T* e ) const - { return Find( e ).IndexOf(); } - - compatibility_iterator Append( T* e ) - { - this->push_back( e ); - return GetLast(); - } - - compatibility_iterator Insert( T* e ) - { - this->push_front( e ); - return compatibility_iterator( this, this->begin() ); - } - - compatibility_iterator Insert( compatibility_iterator & i, T* e ) - { - return compatibility_iterator( this, this->insert( i.m_iter, e ) ); - } - - compatibility_iterator Insert( size_t idx, T* e ) - { - return compatibility_iterator( this, - this->insert( Item( idx ).m_iter, e ) ); - } - - void DeleteContents( bool destroy ) - { m_destroy = destroy; } - - bool GetDeleteContents() const - { return m_destroy; } - - void Erase( const compatibility_iterator& i ) - { - if ( m_destroy ) - delete i->GetData(); - this->erase( i.m_iter ); - } - - bool DeleteNode( const compatibility_iterator& i ) - { - if( i ) - { - Erase( i ); - return true; - } - return false; - } - - bool DeleteObject( T* e ) - { - return DeleteNode( Find( e ) ); - } - - void Clear() - { - if ( m_destroy ) - { - iterator it, en; - for ( it = this->begin(), en = this->end(); it != en; ++it ) - delete *it; - } - this->clear(); - } -}; - -#else // !wxUSE_STD_CONTAINERS - -template -class wxDList -{ -public: - class Node - { - public: - Node(wxDList *list = NULL, - Node *previous = NULL, - Node *next = NULL, - T *data = NULL) - { - m_list = list; - m_previous = previous; - m_next = next; - m_data = data; - if (previous) - previous->m_next = this; - if (next) - next->m_previous = this; - } - - ~Node() - { - // handle the case when we're being deleted from the list by - // the user (i.e. not by the list itself from DeleteNode) - - // we must do it for compatibility with old code - if (m_list != NULL) - m_list->DetachNode(this); - } - - void DeleteData() - { - delete m_data; - } - - Node *GetNext() const { return m_next; } - Node *GetPrevious() const { return m_previous; } - T *GetData() const { return m_data; } - T **GetDataPtr() const { return &(wx_const_cast(nodetype*,this)->m_data); } - void SetData( T *data ) { m_data = data; } - - int IndexOf() const - { - wxCHECK_MSG( m_list, wxNOT_FOUND, - "node doesn't belong to a list in IndexOf" ); - - int i; - Node *prev = m_previous; - for( i = 0; prev; i++ ) - prev = prev->m_previous; - return i; - } - - private: - T *m_data; // user data - Node *m_next, // next and previous nodes in the list - *m_previous; - wxDList *m_list; // list we belong to - - friend class wxDList; - }; - - typedef Node nodetype; - - class compatibility_iterator - { - public: - compatibility_iterator(nodetype *ptr = NULL) : m_ptr(ptr) { } - nodetype *operator->() const { return m_ptr; } - operator nodetype *() const { return m_ptr; } - - private: - nodetype *m_ptr; - }; - -private: - void Init() - { - m_nodeFirst = - m_nodeLast = NULL; - m_count = 0; - m_destroy = false; - } - - void DoDeleteNode( nodetype *node ) - { - if ( m_destroy ) - node->DeleteData(); - // so that the node knows that it's being deleted by the list - node->m_list = NULL; - delete node; - } - - size_t m_count; // number of elements in the list - bool m_destroy; // destroy user data when deleting list items? - nodetype *m_nodeFirst, // pointers to the head and tail of the list - *m_nodeLast; - -public: - wxDList() - { - Init(); - } - - wxDList( const wxDList& list ) - { - Init(); - Assign(list); - } - - wxDList( size_t count, T *elements[] ) - { - Init(); - size_t n; - for (n = 0; n < count; n++) - Append( elements[n] ); - } - - wxDList& operator=( const wxDList& list ) - { - if (&list != this) - Assign(list); - return *this; - } - - ~wxDList() - { - nodetype *each = m_nodeFirst; - while ( each != NULL ) - { - nodetype *next = each->GetNext(); - DoDeleteNode(each); - each = next; - } - } - - void Assign(const wxDList &list) - { - wxASSERT_MSG( !list.m_destroy, - "copying list which owns it's elements is a bad idea" ); - Clear(); - m_destroy = list.m_destroy; - m_nodeFirst = NULL; - m_nodeLast = NULL; - nodetype* node; - for (node = list.GetFirst(); node; node = node->GetNext() ) - Append(node->GetData()); - wxASSERT_MSG( m_count == list.m_count, "logic error in Assign()" ); - } - - nodetype *Append( T *object ) - { - nodetype *node = new nodetype( this, m_nodeLast, NULL, object ); - - if ( !m_nodeFirst ) - { - m_nodeFirst = node; - m_nodeLast = m_nodeFirst; - } - else - { - m_nodeLast->m_next = node; - m_nodeLast = node; - } - m_count++; - return node; - } - - nodetype *Insert( T* object ) - { - return Insert( NULL, object ); - } - - nodetype *Insert( size_t pos, T* object ) - { - if (pos == m_count) - return Append( object ); - else - return Insert( Item(pos), object ); - } - - nodetype *Insert( nodetype *position, T* object ) - { - wxCHECK_MSG( !position || position->m_list == this, NULL, - "can't insert before a node from another list" ); - - // previous and next node for the node being inserted - nodetype *prev, *next; - if ( position ) - { - prev = position->GetPrevious(); - next = position; - } - else - { - // inserting in the beginning of the list - prev = NULL; - next = m_nodeFirst; - } - nodetype *node = new nodetype( this, prev, next, object ); - if ( !m_nodeFirst ) - m_nodeLast = node; - if ( prev == NULL ) - m_nodeFirst = node; - m_count++; - return node; - } - - nodetype *GetFirst() const { return m_nodeFirst; } - nodetype *GetLast() const { return m_nodeLast; } - size_t GetCount() const { return m_count; } - bool IsEmpty() const { return m_count == 0; } - - void DeleteContents(bool destroy) { m_destroy = destroy; } - bool GetDeleteContents() const { return m_destroy; } - - nodetype *Item(size_t index) const - { - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - { - if ( index-- == 0 ) - return current; - } - wxFAIL_MSG( "invalid index in Item()" ); - return NULL; - } - - T *operator[](size_t index) const - { - nodetype *node = Item(index); - return node ? node->GetData() : NULL; - } - - nodetype *DetachNode( nodetype *node ) - { - wxCHECK_MSG( node, NULL, "detaching NULL wxNodeBase" ); - wxCHECK_MSG( node->m_list == this, NULL, - "detaching node which is not from this list" ); - // update the list - nodetype **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next - : &m_nodeFirst; - nodetype **nextPrev = node->GetNext() ? &node->GetNext()->m_previous - : &m_nodeLast; - *prevNext = node->GetNext(); - *nextPrev = node->GetPrevious(); - m_count--; - // mark the node as not belonging to this list any more - node->m_list = NULL; - return node; - } - - void Erase( nodetype *node ) - { - DeleteNode(node); - } - - bool DeleteNode( nodetype *node ) - { - if ( !DetachNode(node) ) - return false; - DoDeleteNode(node); - return true; - } - - bool DeleteObject( T *object ) - { - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - { - if ( current->GetData() == object ) - { - DeleteNode(current); - return true; - } - } - // not found - return false; - } - - nodetype *Find(const T *object) const - { - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - { - if ( current->GetData() == object ) - return current; - } - // not found - return NULL; - } - - int IndexOf(const T *object) const - { - int n = 0; - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - { - if ( current->GetData() == object ) - return n; - n++; - } - return wxNOT_FOUND; - } - - void Clear() - { - nodetype *current = m_nodeFirst; - while ( current ) - { - nodetype *next = current->GetNext(); - DoDeleteNode(current); - current = next; - } - m_nodeFirst = - m_nodeLast = NULL; - m_count = 0; - } - - void Reverse() - { - nodetype * node = m_nodeFirst; - nodetype* tmp; - while (node) - { - // swap prev and next pointers - tmp = node->m_next; - node->m_next = node->m_previous; - node->m_previous = tmp; - // this is the node that was next before swapping - node = tmp; - } - // swap first and last node - tmp = m_nodeFirst; m_nodeFirst = m_nodeLast; m_nodeLast = tmp; - } - - void DeleteNodes(nodetype* first, nodetype* last) - { - nodetype * node = first; - while (node != last) - { - nodetype* next = node->GetNext(); - DeleteNode(node); - node = next; - } - } - - void ForEach(wxListIterateFunction F) - { - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - (*F)(current->GetData()); - } - - T *FirstThat(wxListIterateFunction F) - { - for ( nodetype *current = GetFirst(); current; current = current->GetNext() ) - { - if ( (*F)(current->GetData()) ) - return current->GetData(); - } - return NULL; - } - - T *LastThat(wxListIterateFunction F) - { - for ( nodetype *current = GetLast(); current; current = current->GetPrevious() ) - { - if ( (*F)(current->GetData()) ) - return current->GetData(); - } - return NULL; - } - - /* STL interface */ -public: - typedef size_t size_type; - typedef int difference_type; - typedef T* value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - - class iterator - { - public: - typedef nodetype Node; - typedef iterator itor; - typedef T* value_type; - typedef value_type* ptr_type; - typedef value_type& reference; - - Node* m_node; - Node* m_init; - public: - typedef reference reference_type; - typedef ptr_type pointer_type; - - iterator(Node* node, Node* init) : m_node(node), m_init(init) {} - iterator() : m_node(NULL), m_init(NULL) { } - reference_type operator*() const - { return *m_node->GetDataPtr(); } - // ptrop - itor& operator++() { m_node = m_node->GetNext(); return *this; } - const itor operator++(int) - { itor tmp = *this; m_node = m_node->GetNext(); return tmp; } - itor& operator--() - { - m_node = m_node ? m_node->GetPrevious() : m_init; - return *this; - } - const itor operator--(int) - { - itor tmp = *this; - m_node = m_node ? m_node->GetPrevious() : m_init; - return tmp; - } - bool operator!=(const itor& it) const - { return it.m_node != m_node; } - bool operator==(const itor& it) const - { return it.m_node == m_node; } - }; - class const_iterator - { - public: - typedef nodetype Node; - typedef T* value_type; - typedef const value_type& const_reference; - typedef const_iterator itor; - typedef value_type* ptr_type; - - Node* m_node; - Node* m_init; - public: - typedef const_reference reference_type; - typedef const ptr_type pointer_type; - - const_iterator(Node* node, Node* init) - : m_node(node), m_init(init) { } - const_iterator() : m_node(NULL), m_init(NULL) { } - const_iterator(const iterator& it) - : m_node(it.m_node), m_init(it.m_init) { } - reference_type operator*() const - { return *m_node->GetDataPtr(); } - // ptrop - itor& operator++() { m_node = m_node->GetNext(); return *this; } - const itor operator++(int) - { itor tmp = *this; m_node = m_node->GetNext(); return tmp; } - itor& operator--() - { - m_node = m_node ? m_node->GetPrevious() : m_init; - return *this; - } - const itor operator--(int) - { - itor tmp = *this; - m_node = m_node ? m_node->GetPrevious() : m_init; - return tmp; - } - bool operator!=(const itor& it) const - { return it.m_node != m_node; } - bool operator==(const itor& it) const - { return it.m_node == m_node; } - }; - - class reverse_iterator - { - public: - typedef nodetype Node; - typedef T* value_type; - typedef reverse_iterator itor; - typedef value_type* ptr_type; - typedef value_type& reference; - - Node* m_node; - Node* m_init; - public: - typedef reference reference_type; - typedef ptr_type pointer_type; - - reverse_iterator(Node* node, Node* init) - : m_node(node), m_init(init) { } - reverse_iterator() : m_node(NULL), m_init(NULL) { } - reference_type operator*() const - { return *m_node->GetDataPtr(); } - // ptrop - itor& operator++() - { m_node = m_node->GetPrevious(); return *this; } - const itor operator++(int) - { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; } - itor& operator--() - { m_node = m_node ? m_node->GetNext() : m_init; return *this; } - const itor operator--(int) - { - itor tmp = *this; - m_node = m_node ? m_node->GetNext() : m_init; - return tmp; - } - bool operator!=(const itor& it) const - { return it.m_node != m_node; } - bool operator==(const itor& it) const - { return it.m_node == m_node; } - }; - - class const_reverse_iterator - { - public: - typedef nodetype Node; - typedef T* value_type; - typedef const_reverse_iterator itor; - typedef value_type* ptr_type; - typedef const value_type& const_reference; - - Node* m_node; - Node* m_init; - public: - typedef const_reference reference_type; - typedef const ptr_type pointer_type; - - const_reverse_iterator(Node* node, Node* init) - : m_node(node), m_init(init) { } - const_reverse_iterator() : m_node(NULL), m_init(NULL) { } - const_reverse_iterator(const reverse_iterator& it) - : m_node(it.m_node), m_init(it.m_init) { } - reference_type operator*() const - { return *m_node->GetDataPtr(); } - // ptrop - itor& operator++() - { m_node = m_node->GetPrevious(); return *this; } - const itor operator++(int) - { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; } - itor& operator--() - { m_node = m_node ? m_node->GetNext() : m_init; return *this;} - const itor operator--(int) - { - itor tmp = *this; - m_node = m_node ? m_node->GetNext() : m_init; - return tmp; - } - bool operator!=(const itor& it) const - { return it.m_node != m_node; } - bool operator==(const itor& it) const - { return it.m_node == m_node; } - }; - - wxEXPLICIT wxDList(size_type n, const_reference v = value_type()) - { assign(n, v); } - wxDList(const const_iterator& first, const const_iterator& last) - { assign(first, last); } - iterator begin() { return iterator(GetFirst(), GetLast()); } - const_iterator begin() const - { return const_iterator(GetFirst(), GetLast()); } - iterator end() { return iterator(NULL, GetLast()); } - const_iterator end() const { return const_iterator(NULL, GetLast()); } - reverse_iterator rbegin() - { return reverse_iterator(GetLast(), GetFirst()); } - const_reverse_iterator rbegin() const - { return const_reverse_iterator(GetLast(), GetFirst()); } - reverse_iterator rend() { return reverse_iterator(NULL, GetFirst()); } - const_reverse_iterator rend() const - { return const_reverse_iterator(NULL, GetFirst()); } - void resize(size_type n, value_type v = value_type()) - { - while (n < size()) - pop_back(); - while (n > size()) - push_back(v); - } - size_type size() const { return GetCount(); } - size_type max_size() const { return INT_MAX; } - bool empty() const { return IsEmpty(); } - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - reference back() { iterator tmp = end(); return *--tmp; } - const_reference back() const { const_iterator tmp = end(); return *--tmp; } - void push_front(const_reference v = value_type()) - { Insert(GetFirst(), v); } - void pop_front() { DeleteNode(GetFirst()); } - void push_back(const_reference v = value_type()) - { Append( v ); } - void pop_back() { DeleteNode(GetLast()); } - void assign(const_iterator first, const const_iterator& last) - { - clear(); - for(; first != last; ++first) - Append(*first); - } - void assign(size_type n, const_reference v = value_type()) - { - clear(); - for(size_type i = 0; i < n; ++i) - Append(v); - } - iterator insert(const iterator& it, const_reference v) - { - if (it == end()) - Append( v ); - else - Insert(it.m_node,v); - iterator itprev(it); - return itprev--; - } - void insert(const iterator& it, size_type n, const_reference v) - { - for(size_type i = 0; i < n; ++i) - Insert(it.m_node, v); - } - void insert(const iterator& it, const_iterator first, const const_iterator& last) - { - for(; first != last; ++first) - Insert(it.m_node, *first); - } - iterator erase(const iterator& it) - { - iterator next = iterator(it.m_node->GetNext(), GetLast()); - DeleteNode(it.m_node); return next; - } - iterator erase(const iterator& first, const iterator& last) - { - iterator next = last; ++next; - DeleteNodes(first.m_node, last.m_node); - return next; - } - void clear() { Clear(); } - void splice(const iterator& it, wxDList& l, const iterator& first, const iterator& last) - { insert(it, first, last); l.erase(first, last); } - void splice(const iterator& it, wxDList& l) - { splice(it, l, l.begin(), l.end() ); } - void splice(const iterator& it, wxDList& l, const iterator& first) - { - iterator tmp = first; ++tmp; - if(it == first || it == tmp) return; - insert(it, *first); - l.erase(first); - } - void remove(const_reference v) - { DeleteObject(v); } - void reverse() - { Reverse(); } - /* void swap(list& l) - { - { size_t t = m_count; m_count = l.m_count; l.m_count = t; } - { bool t = m_destroy; m_destroy = l.m_destroy; l.m_destroy = t; } - { wxNodeBase* t = m_nodeFirst; m_nodeFirst = l.m_nodeFirst; l.m_nodeFirst = t; } - { wxNodeBase* t = m_nodeLast; m_nodeLast = l.m_nodeLast; l.m_nodeLast = t; } - { wxKeyType t = m_keyType; m_keyType = l.m_keyType; l.m_keyType = t; } - } */ -}; - -#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS - -#endif // _WX_DLIST_H_ diff --git a/Source/3rd Party/wx/include/wx/dnd.h b/Source/3rd Party/wx/include/wx/dnd.h index 5463d4364..62dbac117 100644 --- a/Source/3rd Party/wx/include/wx/dnd.h +++ b/Source/3rd Party/wx/include/wx/dnd.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin, Robert Roebling // Modified by: // Created: 26.05.99 +// RCS-ID: $Id: dnd.h 43636 2006-11-25 14:08:27Z VZ $ // Copyright: (c) wxWidgets Team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -46,14 +47,14 @@ enum wxDragResult // return true if res indicates that something was done during a dnd operation, // i.e. is neither error nor none nor cancel -WXDLLIMPEXP_CORE bool wxIsDragResultOk(wxDragResult res); +WXDLLEXPORT bool wxIsDragResultOk(wxDragResult res); // ---------------------------------------------------------------------------- // wxDropSource is the object you need to create (and call DoDragDrop on it) // to initiate a drag-and-drop operation // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDropSourceBase +class WXDLLEXPORT wxDropSourceBase { public: wxDropSourceBase(const wxCursor &cursorCopy = wxNullCursor, @@ -62,10 +63,10 @@ public: : m_cursorCopy(cursorCopy), m_cursorMove(cursorMove), m_cursorStop(cursorStop) - { m_data = NULL; } + { m_data = (wxDataObject *)NULL; } virtual ~wxDropSourceBase() { } - // set the data which is transferred by drag and drop + // set the data which is transfered by drag and drop void SetData(wxDataObject& data) { m_data = &data; } @@ -114,7 +115,7 @@ protected: m_cursorMove, m_cursorStop; - wxDECLARE_NO_COPY_CLASS(wxDropSourceBase); + DECLARE_NO_COPY_CLASS(wxDropSourceBase) }; // ---------------------------------------------------------------------------- @@ -128,13 +129,13 @@ protected: // OnData() is called) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDropTargetBase +class WXDLLEXPORT wxDropTargetBase { public: // ctor takes a pointer to heap-allocated wxDataObject which will be owned // by wxDropTarget and deleted by it automatically. If you don't give it // here, you can use SetDataObject() later. - wxDropTargetBase(wxDataObject *dataObject = NULL) + wxDropTargetBase(wxDataObject *dataObject = (wxDataObject*)NULL) { m_dataObject = dataObject; m_defaultAction = wxDragNone; } // dtor deletes our data object virtual ~wxDropTargetBase() @@ -202,7 +203,7 @@ protected: wxDataObject *m_dataObject; wxDragResult m_defaultAction; - wxDECLARE_NO_COPY_CLASS(wxDropTargetBase); + DECLARE_NO_COPY_CLASS(wxDropTargetBase) }; // ---------------------------------------------------------------------------- @@ -221,7 +222,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/dnd.h" #elif defined(__WXMAC__) - #include "wx/osx/dnd.h" + #include "wx/mac/dnd.h" #elif defined(__WXPM__) #include "wx/os2/dnd.h" #endif @@ -232,7 +233,7 @@ protected: // A simple wxDropTarget derived class for text data: you only need to // override OnDropText() to get something working -class WXDLLIMPEXP_CORE wxTextDropTarget : public wxDropTarget +class WXDLLEXPORT wxTextDropTarget : public wxDropTarget { public: wxTextDropTarget(); @@ -242,11 +243,11 @@ public: virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); private: - wxDECLARE_NO_COPY_CLASS(wxTextDropTarget); + DECLARE_NO_COPY_CLASS(wxTextDropTarget) }; // A drop target which accepts files (dragged from File Manager or Explorer) -class WXDLLIMPEXP_CORE wxFileDropTarget : public wxDropTarget +class WXDLLEXPORT wxFileDropTarget : public wxDropTarget { public: wxFileDropTarget(); @@ -258,7 +259,7 @@ public: virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); private: - wxDECLARE_NO_COPY_CLASS(wxFileDropTarget); + DECLARE_NO_COPY_CLASS(wxFileDropTarget) }; #endif // wxUSE_DRAG_AND_DROP diff --git a/Source/3rd Party/wx/include/wx/docmdi.h b/Source/3rd Party/wx/include/wx/docmdi.h index 217230868..d4d7fcfed 100644 --- a/Source/3rd Party/wx/include/wx/docmdi.h +++ b/Source/3rd Party/wx/include/wx/docmdi.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/docmdi.h +// Name: docmdi.h // Purpose: Frame classes for MDI document/view applications // Author: Julian Smart +// Modified by: // Created: 01/02/97 -// Copyright: (c) 1997 Julian Smart -// (c) 2010 Vadim Zeitlin +// RCS-ID: $Id: docmdi.h 41020 2006-09-05 20:47:48Z VZ $ +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,83 +19,89 @@ #include "wx/docview.h" #include "wx/mdi.h" -#ifdef __VISUALC6__ - // "non dll-interface class 'wxDocXXXFrameAny<>' used as base interface for - // dll-interface class 'wxDocMDIXXXFrame'" -- this is bogus as the template - // will be DLL-exported but only once it is used as base class here! - #pragma warning (push) - #pragma warning (disable:4275) -#endif +/* + * Use this instead of wxMDIParentFrame + */ -// Define MDI versions of the doc-view frame classes. Note that we need to -// define them as classes for wxRTTI, otherwise we could simply define them as -// typedefs. - -// ---------------------------------------------------------------------------- -// An MDI document parent frame -// ---------------------------------------------------------------------------- - -typedef - wxDocParentFrameAny wxDocMDIParentFrameBase; - -class WXDLLIMPEXP_CORE wxDocMDIParentFrame : public wxDocMDIParentFrameBase +class WXDLLEXPORT wxDocMDIParentFrame: public wxMDIParentFrame { public: - wxDocMDIParentFrame() : wxDocMDIParentFrameBase() { } + wxDocMDIParentFrame(); + wxDocMDIParentFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, + const wxString& title, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame")); - wxDocMDIParentFrame(wxDocManager *manager, - wxFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxDocMDIParentFrameBase(manager, - parent, id, title, pos, size, style, name) - { - } + bool Create(wxDocManager *manager, wxFrame *parent, wxWindowID id, + const wxString& title, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame")); + + // Extend event processing to search the document manager's event table + virtual bool ProcessEvent(wxEvent& event); + + wxDocManager *GetDocumentManager(void) const { return m_docManager; } + + void OnExit(wxCommandEvent& event); + void OnMRUFile(wxCommandEvent& event); + void OnCloseWindow(wxCloseEvent& event); + +protected: + void Init(); + wxDocManager *m_docManager; private: DECLARE_CLASS(wxDocMDIParentFrame) - wxDECLARE_NO_COPY_CLASS(wxDocMDIParentFrame); + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxDocMDIParentFrame) }; -// ---------------------------------------------------------------------------- -// An MDI document child frame -// ---------------------------------------------------------------------------- +/* + * Use this instead of wxMDIChildFrame + */ -typedef - wxDocChildFrameAny wxDocMDIChildFrameBase; - -class WXDLLIMPEXP_CORE wxDocMDIChildFrame : public wxDocMDIChildFrameBase +class WXDLLEXPORT wxDocMDIChildFrame: public wxMDIChildFrame { public: - wxDocMDIChildFrame() { } + wxDocMDIChildFrame(); + wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id, + const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long type = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame")); + virtual ~wxDocMDIChildFrame(); - wxDocMDIChildFrame(wxDocument *doc, - wxView *view, - wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxDocMDIChildFrameBase(doc, view, - parent, id, title, pos, size, style, name) - { - } + bool Create(wxDocument *doc, + wxView *view, + wxMDIParentFrame *frame, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long type = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + // Extend event processing to search the view's event table + virtual bool ProcessEvent(wxEvent& event); + + void OnActivate(wxActivateEvent& event); + void OnCloseWindow(wxCloseEvent& event); + + inline wxDocument *GetDocument() const { return m_childDocument; } + inline wxView *GetView(void) const { return m_childView; } + inline void SetDocument(wxDocument *doc) { m_childDocument = doc; } + inline void SetView(wxView *view) { m_childView = view; } + bool Destroy() { m_childView = (wxView *)NULL; return wxMDIChildFrame::Destroy(); } + +protected: + void Init(); + wxDocument* m_childDocument; + wxView* m_childView; private: + DECLARE_EVENT_TABLE() DECLARE_CLASS(wxDocMDIChildFrame) - wxDECLARE_NO_COPY_CLASS(wxDocMDIChildFrame); + DECLARE_NO_COPY_CLASS(wxDocMDIChildFrame) }; -#ifdef __VISUALC6__ - #pragma warning (pop) #endif + // wxUSE_MDI_ARCHITECTURE -#endif // wxUSE_MDI_ARCHITECTURE - -#endif // _WX_DOCMDI_H_ +#endif + // _WX_DOCMDI_H_ diff --git a/Source/3rd Party/wx/include/wx/docview.h b/Source/3rd Party/wx/include/wx/docview.h index 55635ed6c..c19bae19d 100644 --- a/Source/3rd Party/wx/include/wx/docview.h +++ b/Source/3rd Party/wx/include/wx/docview.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: docview.h 53546 2008-05-10 21:02:36Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,11 +17,8 @@ #if wxUSE_DOC_VIEW_ARCHITECTURE #include "wx/list.h" -#include "wx/dlist.h" #include "wx/string.h" #include "wx/frame.h" -#include "wx/filehistory.h" -#include "wx/vector.h" #if wxUSE_PRINTING_ARCHITECTURE #include "wx/print.h" @@ -33,41 +31,39 @@ class WXDLLIMPEXP_FWD_CORE wxDocTemplate; class WXDLLIMPEXP_FWD_CORE wxDocManager; class WXDLLIMPEXP_FWD_CORE wxPrintInfo; class WXDLLIMPEXP_FWD_CORE wxCommandProcessor; +class WXDLLIMPEXP_FWD_CORE wxFileHistory; class WXDLLIMPEXP_FWD_BASE wxConfigBase; -class wxDocChildFrameAnyBase; - #if wxUSE_STD_IOSTREAM #include "wx/iosfwrap.h" #else #include "wx/stream.h" #endif -// Flags for wxDocManager (can be combined). +// Document manager flags enum { - wxDOC_NEW = 1, - wxDOC_SILENT = 2 + wxDOC_SDI = 1, + wxDOC_MDI, + wxDOC_NEW, + wxDOC_SILENT, + wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI }; // Document template flags enum { wxTEMPLATE_VISIBLE = 1, - wxTEMPLATE_INVISIBLE = 2, + wxTEMPLATE_INVISIBLE, wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE }; #define wxMAX_FILE_HISTORY 9 -typedef wxVector wxDocVector; -typedef wxVector wxViewVector; -typedef wxVector wxDocTemplateVector; - -class WXDLLIMPEXP_CORE wxDocument : public wxEvtHandler +class WXDLLEXPORT wxDocument : public wxEvtHandler { public: - wxDocument(wxDocument *parent = NULL); + wxDocument(wxDocument *parent = (wxDocument *) NULL); virtual ~wxDocument(); // accessors @@ -80,19 +76,9 @@ public: void SetDocumentName(const wxString& name) { m_documentTypeName = name; } wxString GetDocumentName() const { return m_documentTypeName; } - // access the flag indicating whether this document had been already saved, - // SetDocumentSaved() is only used internally, don't call it bool GetDocumentSaved() const { return m_savedYet; } void SetDocumentSaved(bool saved = true) { m_savedYet = saved; } - // activate the first view of the document if any - void Activate(); - - // return true if the document hasn't been modified since the last time it - // was saved (implying that it returns false if it was never saved, even if - // the document is not modified) - bool AlreadySaved() const { return !IsModified() && GetDocumentSaved(); } - virtual bool Close(); virtual bool Save(); virtual bool SaveAs(); @@ -117,10 +103,6 @@ public: // modified to false) virtual bool OnSaveModified(); - // if you override, remember to call the default - // implementation (wxDocument::OnChangeFilename) - virtual void OnChangeFilename(bool notifyViews); - // Called by framework if created automatically by the default document // manager: gives document a chance to initialise and (usually) create a // view @@ -128,36 +110,26 @@ public: // By default, creates a base wxCommandProcessor. virtual wxCommandProcessor *OnCreateCommandProcessor(); - virtual wxCommandProcessor *GetCommandProcessor() const - { return m_commandProcessor; } - virtual void SetCommandProcessor(wxCommandProcessor *proc) - { m_commandProcessor = proc; } + virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; } + virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; } // Called after a view is added or removed. The default implementation // deletes the document if this is there are no more views. virtual void OnChangedViewList(); - // Called from OnCloseDocument(), does nothing by default but may be - // overridden. Return value is ignored. virtual bool DeleteContents(); virtual bool Draw(wxDC&); virtual bool IsModified() const { return m_documentModified; } - virtual void Modify(bool mod); + virtual void Modify(bool mod) { m_documentModified = mod; } virtual bool AddView(wxView *view); virtual bool RemoveView(wxView *view); - -#ifndef __VISUALC6__ - wxViewVector GetViewsVector() const; -#endif // !__VISUALC6__ - wxList& GetViews() { return m_documentViews; } const wxList& GetViews() const { return m_documentViews; } - wxView *GetFirstView() const; - virtual void UpdateAllViews(wxView *sender = NULL, wxObject *hint = NULL); + virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL); virtual void NotifyClosing(); // Remove all views (because we're closing the document) @@ -165,31 +137,30 @@ public: // Other stuff virtual wxDocManager *GetDocumentManager() const; - virtual wxDocTemplate *GetDocumentTemplate() const - { return m_documentTemplate; } - virtual void SetDocumentTemplate(wxDocTemplate *temp) - { m_documentTemplate = temp; } + virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; } + virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; } - // Get the document name to be shown to the user: the title if there is - // any, otherwise the filename if the document was saved and, finally, - // "unnamed" otherwise - virtual wxString GetUserReadableName() const; + // Get title, or filename if no title, else [unnamed] + // + // NB: this method will be deprecated in wxWidgets 3.0, you still need to + // override it if you need to modify the existing behaviour in this + // version but use GetUserReadableName() below if you just need to call + // it + virtual bool GetPrintableName(wxString& buf) const; -#if WXWIN_COMPATIBILITY_2_8 - // use GetUserReadableName() instead - wxDEPRECATED_BUT_USED_INTERNALLY( - virtual bool GetPrintableName(wxString& buf) const - ); -#endif // WXWIN_COMPATIBILITY_2_8 +#if wxABI_VERSION >= 20805 + wxString GetUserReadableName() const + { + wxString s; + GetPrintableName(s); + return s; + } +#endif // wxABI 2.8.5+ // Returns a window that can be used as a parent for document-related // dialogs. Override if necessary. virtual wxWindow *GetDocumentWindow() const; - // Returns true if this document is a child document corresponding to a - // part of the parent document and not a disk file as usual. - bool IsChildDocument() const { return m_documentParent != NULL; } - protected: wxList m_documentViews; wxString m_documentFile; @@ -197,36 +168,25 @@ protected: wxString m_documentTypeName; wxDocTemplate* m_documentTemplate; bool m_documentModified; - - // if the document parent is non-NULL, it's a pseudo-document corresponding - // to a part of the parent document which can't be saved or loaded - // independently of its parent and is always closed when its parent is wxDocument* m_documentParent; - wxCommandProcessor* m_commandProcessor; bool m_savedYet; // Called by OnSaveDocument and OnOpenDocument to implement standard - // Save/Load behaviour. Re-implement in derived class for custom - // behaviour. + // Save/Load behavior. Re-implement in derived class for custom + // behavior. virtual bool DoSaveDocument(const wxString& file); virtual bool DoOpenDocument(const wxString& file); - // the default implementation of GetUserReadableName() - wxString DoGetUserReadableName() const; - private: - // list of all documents whose m_documentParent is this one - typedef wxDList DocsList; - DocsList m_childDocuments; - DECLARE_ABSTRACT_CLASS(wxDocument) - wxDECLARE_NO_COPY_CLASS(wxDocument); + DECLARE_NO_COPY_CLASS(wxDocument) }; -class WXDLLIMPEXP_CORE wxView: public wxEvtHandler +class WXDLLEXPORT wxView: public wxEvtHandler { public: + // wxView(wxDocument *doc = (wxDocument *) NULL); wxView(); virtual ~wxView(); @@ -239,19 +199,16 @@ public: wxWindow *GetFrame() const { return m_viewFrame ; } void SetFrame(wxWindow *frame) { m_viewFrame = frame; } - virtual void OnActivateView(bool activate, - wxView *activeView, - wxView *deactiveView); + virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView); virtual void OnDraw(wxDC *dc) = 0; virtual void OnPrint(wxDC *dc, wxObject *info); - virtual void OnUpdate(wxView *sender, wxObject *hint = NULL); + virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL); virtual void OnClosingDocument() {} virtual void OnChangeFilename(); // Called by framework if created automatically by the default document // manager class: gives view a chance to initialise - virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) - { return true; } + virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return true; } // Checks if the view is the last one for the document; if so, asks user // to confirm save data (if modified). If ok, deletes itself and returns @@ -261,6 +218,9 @@ public: // Override to do cleanup/veto close virtual bool OnClose(bool deleteWindow); + // Extend event processing to search the document's event table + virtual bool ProcessEvent(wxEvent& event); + // A view's window can call this to notify the view it is (in)active. // The function then notifies the document manager. virtual void Activate(bool activate); @@ -272,33 +232,18 @@ public: virtual wxPrintout *OnCreatePrintout(); #endif - // implementation only - // ------------------- - - // set the associated frame, it is used to reset its view when we're - // destroyed - void SetDocChildFrame(wxDocChildFrameAnyBase *docChildFrame); - - // get the associated frame, may be NULL during destruction - wxDocChildFrameAnyBase* GetDocChildFrame() const { return m_docChildFrame; } - protected: - // hook the document into event handlers chain here - virtual bool TryBefore(wxEvent& event); - wxDocument* m_viewDocument; wxString m_viewTypeName; wxWindow* m_viewFrame; - wxDocChildFrameAnyBase *m_docChildFrame; - private: DECLARE_ABSTRACT_CLASS(wxView) - wxDECLARE_NO_COPY_CLASS(wxView); + DECLARE_NO_COPY_CLASS(wxView) }; // Represents user interface (and other) properties of documents and views -class WXDLLIMPEXP_CORE wxDocTemplate: public wxObject +class WXDLLEXPORT wxDocTemplate: public wxObject { friend class WXDLLIMPEXP_FWD_CORE wxDocManager; @@ -313,8 +258,8 @@ public: const wxString& ext, const wxString& docTypeName, const wxString& viewTypeName, - wxClassInfo *docClassInfo = NULL, - wxClassInfo *viewClassInfo = NULL, + wxClassInfo *docClassInfo = (wxClassInfo *) NULL, + wxClassInfo *viewClassInfo = (wxClassInfo *)NULL, long flags = wxDEFAULT_TEMPLATE_FLAGS); virtual ~wxDocTemplate(); @@ -327,16 +272,13 @@ public: // Helper method for CreateDocument; also allows you to do your own document // creation - virtual bool InitDocument(wxDocument* doc, - const wxString& path, - long flags = 0); + virtual bool InitDocument(wxDocument* doc, const wxString& path, long flags = 0); wxString GetDefaultExtension() const { return m_defaultExt; } wxString GetDescription() const { return m_description; } wxString GetDirectory() const { return m_directory; } wxDocManager *GetDocumentManager() const { return m_documentManager; } - void SetDocumentManager(wxDocManager *manager) - { m_documentManager = manager; } + void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; } wxString GetFileFilter() const { return m_fileFilter; } long GetFlags() const { return m_flags; } virtual wxString GetViewName() const { return m_viewTypeName; } @@ -348,7 +290,7 @@ public: void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; } void SetFlags(long flags) { m_flags = flags; } - bool IsVisible() const { return (m_flags & wxTEMPLATE_VISIBLE) != 0; } + bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); } wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; } wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; } @@ -369,26 +311,23 @@ protected: wxClassInfo* m_docClassInfo; wxClassInfo* m_viewClassInfo; - // Called by CreateDocument and CreateView to create the actual - // document/view object. - // - // By default uses the ClassInfo provided to the constructor. Override - // these functions to provide a different method of creation. + // Called by CreateDocument and CreateView to create the actual document/view object. + // By default uses the ClassInfo provided to the constructor. Override these functions + // to provide a different method of creation. virtual wxDocument *DoCreateDocument(); virtual wxView *DoCreateView(); private: DECLARE_CLASS(wxDocTemplate) - wxDECLARE_NO_COPY_CLASS(wxDocTemplate); + DECLARE_NO_COPY_CLASS(wxDocTemplate) }; // One object of this class may be created in an application, to manage all // the templates and documents. -class WXDLLIMPEXP_CORE wxDocManager: public wxEvtHandler +class WXDLLEXPORT wxDocManager: public wxEvtHandler { public: - // NB: flags are unused, don't pass wxDOC_XXX to this ctor - wxDocManager(long flags = 0, bool initialize = true); + wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true); virtual ~wxDocManager(); virtual bool Initialize(); @@ -401,18 +340,14 @@ public: void OnFileRevert(wxCommandEvent& event); void OnFileSave(wxCommandEvent& event); void OnFileSaveAs(wxCommandEvent& event); - void OnMRUFile(wxCommandEvent& event); -#if wxUSE_PRINTING_ARCHITECTURE void OnPrint(wxCommandEvent& event); void OnPreview(wxCommandEvent& event); - void OnPageSetup(wxCommandEvent& event); -#endif // wxUSE_PRINTING_ARCHITECTURE void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); // Handlers for UI update commands void OnUpdateFileOpen(wxUpdateUIEvent& event); - void OnUpdateDisableIfNoDoc(wxUpdateUIEvent& event); + void OnUpdateFileClose(wxUpdateUIEvent& event); void OnUpdateFileRevert(wxUpdateUIEvent& event); void OnUpdateFileNew(wxUpdateUIEvent& event); void OnUpdateFileSave(wxUpdateUIEvent& event); @@ -420,16 +355,17 @@ public: void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); + void OnUpdatePrint(wxUpdateUIEvent& event); + void OnUpdatePreview(wxUpdateUIEvent& event); + + // Extend event processing to search the view's event table + virtual bool ProcessEvent(wxEvent& event); + // called when file format detection didn't work, can be overridden to do // something in this case virtual void OnOpenFileFailure() { } virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); - - // wrapper around CreateDocument() with a more clear name - wxDocument *CreateNewDocument() - { return CreateDocument(wxString(), wxDOC_NEW); } - virtual wxView *CreateView(wxDocument *doc, long flags = 0); virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0); virtual bool FlushDoc(wxDocument *doc); @@ -445,12 +381,6 @@ public: void AssociateTemplate(wxDocTemplate *temp); void DisassociateTemplate(wxDocTemplate *temp); - // Find template from document class info, may return NULL. - wxDocTemplate* FindTemplate(const wxClassInfo* documentClassInfo); - - // Find document from file name, may return NULL. - wxDocument* FindDocumentByPath(const wxString& path) const; - wxDocument *GetCurrentDocument() const; void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; } @@ -472,25 +402,27 @@ public: // Views or windows should inform the document manager // when a view is going in or out of focus virtual void ActivateView(wxView *view, bool activate = true); - virtual wxView *GetCurrentView() const { return m_currentView; } - - // This method tries to find an active view harder than GetCurrentView(): - // if the latter is NULL, it also checks if we don't have just a single - // view and returns it then. - wxView *GetAnyUsableView() const; - - -#ifndef __VISUALC6__ - wxDocVector GetDocumentsVector() const; - wxDocTemplateVector GetTemplatesVector() const; -#endif // !__VISUALC6__ + virtual wxView *GetCurrentView() const; wxList& GetDocuments() { return m_docs; } wxList& GetTemplates() { return m_templates; } - // Return the default name for a new document (by default returns strings - // in the form "unnamed " but can be overridden) - virtual wxString MakeNewDocumentName(); + // Make a default document name + // + // NB: this method is renamed to MakeNewDocumentName() in wx 3.0, you still + // need to override it if your code needs to customize the default name + // generation but if you just use it from your code, prefer the version + // below which is forward-compatible with wx 3.0 + virtual bool MakeDefaultName(wxString& buf); + +#if wxABI_VERSION >= 20808 + wxString MakeNewDocumentName() const + { + wxString s; + wx_const_cast(wxDocManager *, this)->MakeDefaultName(s); + return s; + } +#endif // wx ABI >= 2.8.8 // Make a frame title (override this to do something different) virtual wxString MakeFrameTitle(wxDocument* doc); @@ -506,59 +438,26 @@ public: virtual void FileHistoryUseMenu(wxMenu *menu); virtual void FileHistoryRemoveMenu(wxMenu *menu); #if wxUSE_CONFIG - virtual void FileHistoryLoad(const wxConfigBase& config); + virtual void FileHistoryLoad(wxConfigBase& config); virtual void FileHistorySave(wxConfigBase& config); #endif // wxUSE_CONFIG virtual void FileHistoryAddFilesToMenu(); virtual void FileHistoryAddFilesToMenu(wxMenu* menu); - wxString GetLastDirectory() const; + wxString GetLastDirectory() const { return m_lastDirectory; } void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } // Get the current document manager static wxDocManager* GetDocumentManager() { return sm_docManager; } -#if wxUSE_PRINTING_ARCHITECTURE - wxPageSetupDialogData& GetPageSetupDialogData() - { return m_pageSetupDialogData; } - const wxPageSetupDialogData& GetPageSetupDialogData() const - { return m_pageSetupDialogData; } -#endif // wxUSE_PRINTING_ARCHITECTURE - -#if WXWIN_COMPATIBILITY_2_8 - // deprecated, override GetDefaultName() instead - wxDEPRECATED_BUT_USED_INTERNALLY( - virtual bool MakeDefaultName(wxString& buf) - ); -#endif - #if WXWIN_COMPATIBILITY_2_6 // deprecated, use GetHistoryFilesCount() instead wxDEPRECATED( size_t GetNoHistoryFiles() const ); #endif // WXWIN_COMPATIBILITY_2_6 - protected: - // Called when a file selected from the MRU list doesn't exist any more. - // The default behaviour is to remove the file from the MRU and notify the - // user about it but this method can be overridden to customize it. - virtual void OnMRUFileNotExist(unsigned n, const wxString& filename); - - // Open the MRU file with the given index in our associated file history. - void DoOpenMRUFile(unsigned n); -#if wxUSE_PRINTING_ARCHITECTURE - virtual wxPreviewFrame* CreatePreviewFrame(wxPrintPreviewBase* preview, - wxWindow *parent, - const wxString& title); -#endif // wxUSE_PRINTING_ARCHITECTURE - - // hook the currently active view into event handlers chain here - virtual bool TryBefore(wxEvent& event); - - // return the command processor for the current document, if any - wxCommandProcessor *GetCurrentCommandProcessor() const; - + long m_flags; int m_defaultDocumentNameCounter; int m_maxDocsOpen; wxList m_docs; @@ -568,13 +467,9 @@ protected: wxString m_lastDirectory; static wxDocManager* sm_docManager; -#if wxUSE_PRINTING_ARCHITECTURE - wxPageSetupDialogData m_pageSetupDialogData; -#endif // wxUSE_PRINTING_ARCHITECTURE - DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxDocManager) - wxDECLARE_NO_COPY_CLASS(wxDocManager); + DECLARE_NO_COPY_CLASS(wxDocManager) }; #if WXWIN_COMPATIBILITY_2_6 @@ -585,304 +480,61 @@ inline size_t wxDocManager::GetNoHistoryFiles() const #endif // WXWIN_COMPATIBILITY_2_6 // ---------------------------------------------------------------------------- -// Base class for child frames -- this is what wxView renders itself into -// -// Notice that this is a mix-in class so it doesn't derive from wxWindow, only -// wxDocChildFrameAny does +// A default child frame // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase +class WXDLLEXPORT wxDocChildFrame : public wxFrame { public: - // default ctor, use Create() after it - wxDocChildFrameAnyBase() - { - m_childDocument = NULL; - m_childView = NULL; - m_win = NULL; - m_lastEvent = NULL; - } + wxDocChildFrame(wxDocument *doc, + wxView *view, + wxFrame *frame, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long type = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxT("frame")); + virtual ~wxDocChildFrame(){} - // full ctor equivalent to using the default one and Create() - wxDocChildFrameAnyBase(wxDocument *doc, wxView *view, wxWindow *win) - { - Create(doc, view, win); - } + // Extend event processing to search the view's event table + virtual bool ProcessEvent(wxEvent& event); - // method which must be called for an object created using the default ctor - // - // note that it returns bool just for consistency with Create() methods in - // other classes, we never return false from here - bool Create(wxDocument *doc, wxView *view, wxWindow *win) - { - m_childDocument = doc; - m_childView = view; - m_win = win; - - if ( view ) - view->SetDocChildFrame(this); - - return true; - } - - // dtor doesn't need to be virtual, an object should never be destroyed via - // a pointer to this class - ~wxDocChildFrameAnyBase() - { - // prevent the view from deleting us if we're being deleted directly - // (and not via Close() + Destroy()) - if ( m_childView ) - m_childView->SetDocChildFrame(NULL); - } + void OnActivate(wxActivateEvent& event); + void OnCloseWindow(wxCloseEvent& event); wxDocument *GetDocument() const { return m_childDocument; } wxView *GetView() const { return m_childView; } void SetDocument(wxDocument *doc) { m_childDocument = doc; } void SetView(wxView *view) { m_childView = view; } - - wxWindow *GetWindow() const { return m_win; } - - // implementation only - - // Check if this event had been just processed in this frame. - bool HasAlreadyProcessed(wxEvent& event) const - { - return m_lastEvent == &event; - } + bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); } protected: - // we're not a wxEvtHandler but we provide this wxEvtHandler-like function - // which is called from TryBefore() of the derived classes to give our view - // a chance to process the message before the frame event handlers are used - bool TryProcessEvent(wxEvent& event); - - // called from EVT_CLOSE handler in the frame: check if we can close and do - // cleanup if so; veto the event otherwise - bool CloseView(wxCloseEvent& event); - - wxDocument* m_childDocument; wxView* m_childView; - // the associated window: having it here is not terribly elegant but it - // allows us to avoid having any virtual functions in this class - wxWindow* m_win; - -private: - // Pointer to the last processed event used to avoid sending the same event - // twice to wxDocManager, from here and from wxDocParentFrameAnyBase. - wxEvent* m_lastEvent; - - wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase); -}; - -// ---------------------------------------------------------------------------- -// Template implementing child frame concept using the given wxFrame-like class -// -// This is used to define wxDocChildFrame and wxDocMDIChildFrame: ChildFrame is -// a wxFrame or wxMDIChildFrame (although in theory it could be any wxWindow- -// derived class as long as it provided a ctor with the same signature as -// wxFrame and OnActivate() method) and ParentFrame is either wxFrame or -// wxMDIParentFrame. -// ---------------------------------------------------------------------------- - -template -class WXDLLIMPEXP_CORE wxDocChildFrameAny : public ChildFrame, - public wxDocChildFrameAnyBase -{ -public: - typedef ChildFrame BaseClass; - - // default ctor, use Create after it - wxDocChildFrameAny() { } - - // ctor for a frame showing the given view of the specified document - wxDocChildFrameAny(wxDocument *doc, - wxView *view, - ParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - Create(doc, view, parent, id, title, pos, size, style, name); - } - - bool Create(wxDocument *doc, - wxView *view, - ParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - if ( !wxDocChildFrameAnyBase::Create(doc, view, this) ) - return false; - - if ( !BaseClass::Create(parent, id, title, pos, size, style, name) ) - return false; - - this->Connect(wxEVT_ACTIVATE, - wxActivateEventHandler(wxDocChildFrameAny::OnActivate)); - this->Connect(wxEVT_CLOSE_WINDOW, - wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow)); - - return true; - } - - virtual bool Destroy() - { - // FIXME: why exactly do we do this? to avoid activation events during - // destructions maybe? - m_childView = NULL; - return BaseClass::Destroy(); - } - -protected: - // hook the child view into event handlers chain here - virtual bool TryBefore(wxEvent& event) - { - return TryProcessEvent(event) || BaseClass::TryBefore(event); - } - -private: - void OnActivate(wxActivateEvent& event) - { - BaseClass::OnActivate(event); - - if ( m_childView ) - m_childView->Activate(event.GetActive()); - } - - void OnCloseWindow(wxCloseEvent& event) - { - if ( CloseView(event) ) - Destroy(); - //else: vetoed - } - - wxDECLARE_NO_COPY_TEMPLATE_CLASS_2(wxDocChildFrameAny, - ChildFrame, ParentFrame); -}; - -// ---------------------------------------------------------------------------- -// A default child frame: we need to define it as a class just for wxRTTI, -// otherwise we could simply typedef it -// ---------------------------------------------------------------------------- - -#ifdef __VISUALC6__ - // "non dll-interface class 'wxDocChildFrameAny<>' used as base interface - // for dll-interface class 'wxDocChildFrame'" -- this is bogus as the - // template will be DLL-exported but only once it is used as base class - // here! - #pragma warning (push) - #pragma warning (disable:4275) -#endif - -typedef wxDocChildFrameAny wxDocChildFrameBase; - -class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase -{ -public: - wxDocChildFrame() - { - } - - wxDocChildFrame(wxDocument *doc, - wxView *view, - wxFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxDocChildFrameBase(doc, view, - parent, id, title, pos, size, style, name) - { - } - - bool Create(wxDocument *doc, - wxView *view, - wxFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - return wxDocChildFrameBase::Create - ( - doc, view, - parent, id, title, pos, size, style, name - ); - } - private: DECLARE_CLASS(wxDocChildFrame) - wxDECLARE_NO_COPY_CLASS(wxDocChildFrame); + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxDocChildFrame) }; // ---------------------------------------------------------------------------- -// wxDocParentFrame and related classes. -// -// As with wxDocChildFrame we define a template base class used by both normal -// and MDI versions +// A default parent frame // ---------------------------------------------------------------------------- -// Base class containing type-independent code of wxDocParentFrameAny -// -// Similarly to wxDocChildFrameAnyBase, this class is a mix-in and doesn't -// derive from wxWindow. -class WXDLLIMPEXP_CORE wxDocParentFrameAnyBase +class WXDLLEXPORT wxDocParentFrame : public wxFrame { public: - wxDocParentFrameAnyBase(wxWindow* frame) - : m_frame(frame) - { - m_docManager = NULL; - } - - wxDocManager *GetDocumentManager() const { return m_docManager; } - -protected: - // This is similar to wxDocChildFrameAnyBase method with the same name: - // while we're not an event handler ourselves and so can't override - // TryBefore(), we provide a helper that the derived template class can use - // from its TryBefore() implementation. - bool TryProcessEvent(wxEvent& event); - - wxWindow* const m_frame; - wxDocManager *m_docManager; - - wxDECLARE_NO_COPY_CLASS(wxDocParentFrameAnyBase); -}; - -// This is similar to wxDocChildFrameAny and is used to provide common -// implementation for both wxDocParentFrame and wxDocMDIParentFrame -template -class WXDLLIMPEXP_CORE wxDocParentFrameAny : public BaseFrame, - public wxDocParentFrameAnyBase -{ -public: - wxDocParentFrameAny() : wxDocParentFrameAnyBase(this) { } - wxDocParentFrameAny(wxDocManager *manager, - wxFrame *frame, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxDocParentFrameAnyBase(this) - { - Create(manager, frame, id, title, pos, size, style, name); - } + wxDocParentFrame(); + wxDocParentFrame(wxDocManager *manager, + wxFrame *frame, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); bool Create(wxDocManager *manager, wxFrame *frame, @@ -891,116 +543,40 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - m_docManager = manager; + const wxString& name = wxFrameNameStr); - if ( !BaseFrame::Create(frame, id, title, pos, size, style, name) ) - return false; + // Extend event processing to search the document manager's event table + virtual bool ProcessEvent(wxEvent& event); - this->Connect(wxID_EXIT, wxEVT_MENU, - wxCommandEventHandler(wxDocParentFrameAny::OnExit)); - this->Connect(wxEVT_CLOSE_WINDOW, - wxCloseEventHandler(wxDocParentFrameAny::OnCloseWindow)); + wxDocManager *GetDocumentManager() const { return m_docManager; } - return true; - } + void OnExit(wxCommandEvent& event); + void OnMRUFile(wxCommandEvent& event); + void OnCloseWindow(wxCloseEvent& event); protected: - // hook the document manager into event handling chain here - virtual bool TryBefore(wxEvent& event) - { - // It is important to send the event to the base class first as - // wxMDIParentFrame overrides its TryBefore() to send the menu events - // to the currently active child frame and the child must get them - // before our own TryProcessEvent() is executed, not afterwards. - return BaseFrame::TryBefore(event) || TryProcessEvent(event); - } - -private: - void OnExit(wxCommandEvent& WXUNUSED(event)) - { - this->Close(); - } - - void OnCloseWindow(wxCloseEvent& event) - { - if ( m_docManager && !m_docManager->Clear(!event.CanVeto()) ) - { - // The user decided not to close finally, abort. - event.Veto(); - } - else - { - // Just skip the event, base class handler will destroy the window. - event.Skip(); - } - } - - - wxDECLARE_NO_COPY_CLASS(wxDocParentFrameAny); -}; - -typedef wxDocParentFrameAny wxDocParentFrameBase; - -class WXDLLIMPEXP_CORE wxDocParentFrame : public wxDocParentFrameBase -{ -public: - wxDocParentFrame() : wxDocParentFrameBase() { } - - wxDocParentFrame(wxDocManager *manager, - wxFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxDocParentFrameBase(manager, - parent, id, title, pos, size, style, name) - { - } - - bool Create(wxDocManager *manager, - wxFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - return wxDocParentFrameBase::Create(manager, - parent, id, title, - pos, size, style, name); - } + wxDocManager *m_docManager; private: + typedef wxFrame base_type; DECLARE_CLASS(wxDocParentFrame) - wxDECLARE_NO_COPY_CLASS(wxDocParentFrame); + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxDocParentFrame) }; -#ifdef __VISUALC6__ - // reenable warning 4275 - #pragma warning (pop) -#endif - // ---------------------------------------------------------------------------- // Provide simple default printing facilities // ---------------------------------------------------------------------------- #if wxUSE_PRINTING_ARCHITECTURE -class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout +class WXDLLEXPORT wxDocPrintout : public wxPrintout { public: - wxDocPrintout(wxView *view = NULL, const wxString& title = wxString()); - - // implement wxPrintout methods - virtual bool OnPrintPage(int page); - virtual bool HasPage(int page); - virtual bool OnBeginDocument(int startPage, int endPage); - virtual void GetPageInfo(int *minPage, int *maxPage, - int *selPageFrom, int *selPageTo); + wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout")); + bool OnPrintPage(int page); + bool HasPage(int page); + bool OnBeginDocument(int startPage, int endPage); + void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); virtual wxView *GetView() { return m_printoutView; } @@ -1009,53 +585,91 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxDocPrintout) - wxDECLARE_NO_COPY_CLASS(wxDocPrintout); + DECLARE_NO_COPY_CLASS(wxDocPrintout) }; #endif // wxUSE_PRINTING_ARCHITECTURE +// ---------------------------------------------------------------------------- +// File history management +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFileHistory : public wxObject +{ +public: + wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1); + virtual ~wxFileHistory(); + + // Operations + virtual void AddFileToHistory(const wxString& file); + virtual void RemoveFileFromHistory(size_t i); + virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; } + virtual void UseMenu(wxMenu *menu); + + // Remove menu from the list (MDI child may be closing) + virtual void RemoveMenu(wxMenu *menu); + +#if wxUSE_CONFIG + virtual void Load(wxConfigBase& config); + virtual void Save(wxConfigBase& config); +#endif // wxUSE_CONFIG + + virtual void AddFilesToMenu(); + virtual void AddFilesToMenu(wxMenu* menu); // Single menu + + // Accessors + virtual wxString GetHistoryFile(size_t i) const; + virtual size_t GetCount() const { return m_fileHistoryN; } + + const wxList& GetMenus() const { return m_fileMenus; } + +#if wxABI_VERSION >= 20802 + // Set/get base id + void SetBaseId(wxWindowID baseId) { m_idBase = baseId; } + wxWindowID GetBaseId() const { return m_idBase; } +#endif // wxABI 2.8.2+ + +#if WXWIN_COMPATIBILITY_2_6 + // deprecated, use GetCount() instead + wxDEPRECATED( size_t GetNoHistoryFiles() const ); +#endif // WXWIN_COMPATIBILITY_2_6 + +protected: + // Last n files + wxChar** m_fileHistory; + // Number of files saved + size_t m_fileHistoryN; + // Menus to maintain (may need several for an MDI app) + wxList m_fileMenus; + // Max files to maintain + size_t m_fileMaxFiles; + +private: + // The ID of the first history menu item (Doesn't have to be wxID_FILE1) + wxWindowID m_idBase; + + DECLARE_DYNAMIC_CLASS(wxFileHistory) + DECLARE_NO_COPY_CLASS(wxFileHistory) +}; + +#if WXWIN_COMPATIBILITY_2_6 +inline size_t wxFileHistory::GetNoHistoryFiles() const +{ + return m_fileHistoryN; +} +#endif // WXWIN_COMPATIBILITY_2_6 + +#if wxUSE_STD_IOSTREAM // For compatibility with existing file formats: // converts from/to a stream to/from a temporary file. -#if wxUSE_STD_IOSTREAM -bool WXDLLIMPEXP_CORE -wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); -bool WXDLLIMPEXP_CORE -wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); +bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); +bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); #else -bool WXDLLIMPEXP_CORE -wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); -bool WXDLLIMPEXP_CORE -wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); +// For compatibility with existing file formats: +// converts from/to a stream to/from a temporary file. +bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); +bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); #endif // wxUSE_STD_IOSTREAM - -// these flags are not used anywhere by wxWidgets and kept only for an unlikely -// case of existing user code using them for its own purposes -#if WXWIN_COMPATIBILITY_2_8 -enum -{ - wxDOC_SDI = 1, - wxDOC_MDI, - wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI -}; -#endif // WXWIN_COMPATIBILITY_2_8 - -#ifndef __VISUALC6__ -inline wxViewVector wxDocument::GetViewsVector() const -{ - return m_documentViews.AsVector(); -} - -inline wxDocVector wxDocManager::GetDocumentsVector() const -{ - return m_docs.AsVector(); -} - -inline wxDocTemplateVector wxDocManager::GetTemplatesVector() const -{ - return m_templates.AsVector(); -} -#endif // !__VISUALC6__ - #endif // wxUSE_DOC_VIEW_ARCHITECTURE #endif // _WX_DOCH__ diff --git a/Source/3rd Party/wx/include/wx/dragimag.h b/Source/3rd Party/wx/include/wx/dragimag.h deleted file mode 100644 index 4143ca889..000000000 --- a/Source/3rd Party/wx/include/wx/dragimag.h +++ /dev/null @@ -1,53 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/dragimag.h -// Purpose: wxDragImage base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DRAGIMAG_H_BASE_ -#define _WX_DRAGIMAG_H_BASE_ - -#if wxUSE_DRAGIMAGE - -class WXDLLIMPEXP_FWD_CORE wxRect; -class WXDLLIMPEXP_FWD_CORE wxMemoryDC; -class WXDLLIMPEXP_FWD_CORE wxDC; - -#if defined(__WXMSW__) -# if defined(__WXUNIVERSAL__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage -# else -# include "wx/msw/dragimag.h" -# endif - -#elif defined(__WXMOTIF__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage - -#elif defined(__WXGTK__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage - -#elif defined(__WXX11__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage - -#elif defined(__WXMAC__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage - -#elif defined(__WXPM__) -# include "wx/generic/dragimgg.h" -# define wxDragImage wxGenericDragImage - -#endif - -#endif // wxUSE_DRAGIMAGE - -#endif - // _WX_DRAGIMAG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/dvrenderers.h b/Source/3rd Party/wx/include/wx/dvrenderers.h deleted file mode 100644 index 3f623cf6a..000000000 --- a/Source/3rd Party/wx/include/wx/dvrenderers.h +++ /dev/null @@ -1,445 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/dvrenderers.h -// Purpose: Declare all wxDataViewCtrl classes -// Author: Robert Roebling, Vadim Zeitlin -// Created: 2009-11-08 (extracted from wx/dataview.h) -// Copyright: (c) 2006 Robert Roebling -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DVRENDERERS_H_ -#define _WX_DVRENDERERS_H_ - -/* - Note about the structure of various headers: they're organized in a more - complicated way than usual because of the various dependencies which are - different for different ports. In any case the only public header, i.e. the - one which can be included directly is wx/dataview.h. It, in turn, includes - this one to define all the renderer classes. - - We define the base wxDataViewRendererBase class first and then include a - port-dependent wx/xxx/dvrenderer.h which defines wxDataViewRenderer itself. - After this we can define wxDataViewRendererCustomBase (and maybe in the - future base classes for other renderers if the need arises, i.e. if there - is any non-trivial code or API which it makes sense to keep in common code) - and include wx/xxx/dvrenderers.h (notice the plural) which defines all the - rest of the renderer classes. - */ - -class WXDLLIMPEXP_FWD_ADV wxDataViewCustomRenderer; - -// ---------------------------------------------------------------------------- -// wxDataViewIconText: helper class used by wxDataViewIconTextRenderer -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewIconText : public wxObject -{ -public: - wxDataViewIconText( const wxString &text = wxEmptyString, - const wxIcon& icon = wxNullIcon ) - : m_text(text), - m_icon(icon) - { } - - wxDataViewIconText( const wxDataViewIconText &other ) - : wxObject(), - m_text(other.m_text), - m_icon(other.m_icon) - { } - - void SetText( const wxString &text ) { m_text = text; } - wxString GetText() const { return m_text; } - void SetIcon( const wxIcon &icon ) { m_icon = icon; } - const wxIcon &GetIcon() const { return m_icon; } - - bool IsSameAs(const wxDataViewIconText& other) const - { - return m_text == other.m_text && m_icon.IsSameAs(other.m_icon); - } - - bool operator==(const wxDataViewIconText& other) const - { - return IsSameAs(other); - } - - bool operator!=(const wxDataViewIconText& other) const - { - return !IsSameAs(other); - } - -private: - wxString m_text; - wxIcon m_icon; - - DECLARE_DYNAMIC_CLASS(wxDataViewIconText) -}; - -DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) - -// ---------------------------------------------------------------------------- -// wxDataViewRendererBase -// ---------------------------------------------------------------------------- - -enum wxDataViewCellMode -{ - wxDATAVIEW_CELL_INERT, - wxDATAVIEW_CELL_ACTIVATABLE, - wxDATAVIEW_CELL_EDITABLE -}; - -enum wxDataViewCellRenderState -{ - wxDATAVIEW_CELL_SELECTED = 1, - wxDATAVIEW_CELL_PRELIT = 2, - wxDATAVIEW_CELL_INSENSITIVE = 4, - wxDATAVIEW_CELL_FOCUSED = 8 -}; - -class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject -{ -public: - wxDataViewRendererBase( const wxString &varianttype, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int alignment = wxDVR_DEFAULT_ALIGNMENT ); - virtual ~wxDataViewRendererBase(); - - virtual bool Validate( wxVariant& WXUNUSED(value) ) - { return true; } - - void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } - wxDataViewColumn* GetOwner() const { return m_owner; } - - // renderer value and attributes: SetValue() and SetAttr() are called - // before a cell is rendered using this renderer - virtual bool SetValue(const wxVariant& value) = 0; - virtual bool GetValue(wxVariant& value) const = 0; - - virtual void SetAttr(const wxDataViewItemAttr& WXUNUSED(attr)) { } - - virtual void SetEnabled(bool WXUNUSED(enabled)) { } - - wxString GetVariantType() const { return m_variantType; } - - // helper that calls SetValue and SetAttr: - void PrepareForItem(const wxDataViewModel *model, - const wxDataViewItem& item, unsigned column); - - // renderer properties: - virtual void SetMode( wxDataViewCellMode mode ) = 0; - virtual wxDataViewCellMode GetMode() const = 0; - - // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but - // rather an "int"; that's because for rendering cells it's allowed - // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) - virtual void SetAlignment( int align ) = 0; - virtual int GetAlignment() const = 0; - - // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of - // the item text (hence this only makes sense for renderers showing - // text...) with ellipsis in order to make it fit the column width - virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0; - void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); } - - virtual wxEllipsizeMode GetEllipsizeMode() const = 0; - - // in-place editing - virtual bool HasEditorCtrl() const - { return false; } - virtual wxWindow* CreateEditorCtrl(wxWindow * WXUNUSED(parent), - wxRect WXUNUSED(labelRect), - const wxVariant& WXUNUSED(value)) - { return NULL; } - virtual bool GetValueFromEditorCtrl(wxWindow * WXUNUSED(editor), - wxVariant& WXUNUSED(value)) - { return false; } - - virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); - virtual void CancelEditing(); - virtual bool FinishEditing(); - - wxWindow *GetEditorCtrl() { return m_editorCtrl; } - - virtual bool IsCustomRenderer() const { return false; } - - -protected: - // Called from {Cancel,Finish}Editing() to cleanup m_editorCtrl - void DestroyEditControl(); - - // Return the alignment of this renderer if it's specified (i.e. has value - // different from the default wxDVR_DEFAULT_ALIGNMENT) or the alignment of - // the column it is used for otherwise. - // - // Unlike GetAlignment(), this always returns a valid combination of - // wxALIGN_XXX flags (although possibly wxALIGN_NOT) and never returns - // wxDVR_DEFAULT_ALIGNMENT. - int GetEffectiveAlignment() const; - - wxString m_variantType; - wxDataViewColumn *m_owner; - wxWeakRef m_editorCtrl; - wxDataViewItem m_item; // for m_editorCtrl - - // internal utility, may be used anywhere the window associated with the - // renderer is required - wxDataViewCtrl* GetView() const; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) -}; - -// include the real wxDataViewRenderer declaration for the native ports -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - // in the generic implementation there is no real wxDataViewRenderer, all - // renderers are custom so it's the same as wxDataViewCustomRenderer and - // wxDataViewCustomRendererBase derives from wxDataViewRendererBase directly - // - // this is a rather ugly hack but unfortunately it just doesn't seem to be - // possible to have the same class hierarchy in all ports and avoid - // duplicating the entire wxDataViewCustomRendererBase in the generic - // wxDataViewRenderer class (well, we could use a mix-in but this would - // make classes hierarchy non linear and arguably even more complex) - #define wxDataViewCustomRendererRealBase wxDataViewRendererBase -#else - #if defined(__WXGTK20__) - #include "wx/gtk/dvrenderer.h" - #elif defined(__WXMAC__) - #include "wx/osx/dvrenderer.h" - #else - #error "unknown native wxDataViewCtrl implementation" - #endif - #define wxDataViewCustomRendererRealBase wxDataViewRenderer -#endif - -// ---------------------------------------------------------------------------- -// wxDataViewCustomRendererBase -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewCustomRendererBase - : public wxDataViewCustomRendererRealBase -{ -public: - // Constructor must specify the usual renderer parameters which we simply - // pass to the base class - wxDataViewCustomRendererBase(const wxString& varianttype = "string", - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT) - : wxDataViewCustomRendererRealBase(varianttype, mode, align) - { - } - - - // Render the item using the current value (returned by GetValue()). - virtual bool Render(wxRect cell, wxDC *dc, int state) = 0; - - // Return the size of the item appropriate to its current value. - virtual wxSize GetSize() const = 0; - - // Define virtual function which are called when a key is pressed on the - // item, clicked or the user starts to drag it: by default they all simply - // return false indicating that the events are not handled - - virtual bool ActivateCell(const wxRect& cell, - wxDataViewModel *model, - const wxDataViewItem & item, - unsigned int col, - const wxMouseEvent* mouseEvent); - - // Deprecated, use (and override) ActivateCell() instead - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual bool Activate(wxRect WXUNUSED(cell), - wxDataViewModel *WXUNUSED(model), - const wxDataViewItem & WXUNUSED(item), - unsigned int WXUNUSED(col)), - return false; ) - - // Deprecated, use (and override) ActivateCell() instead - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual bool LeftClick(wxPoint WXUNUSED(cursor), - wxRect WXUNUSED(cell), - wxDataViewModel *WXUNUSED(model), - const wxDataViewItem & WXUNUSED(item), - unsigned int WXUNUSED(col)), - return false; ) - - virtual bool StartDrag(const wxPoint& WXUNUSED(cursor), - const wxRect& WXUNUSED(cell), - wxDataViewModel *WXUNUSED(model), - const wxDataViewItem & WXUNUSED(item), - unsigned int WXUNUSED(col) ) - { return false; } - - - // Helper which can be used by Render() implementation in the derived - // classes: it will draw the text in the same manner as the standard - // renderers do. - virtual void RenderText(const wxString& text, - int xoffset, - wxRect cell, - wxDC *dc, - int state); - - - // Override the base class virtual method to simply store the attribute so - // that it can be accessed using GetAttr() from Render() if needed. - virtual void SetAttr(const wxDataViewItemAttr& attr) { m_attr = attr; } - const wxDataViewItemAttr& GetAttr() const { return m_attr; } - - // Store the enabled state of the item so that it can be accessed from - // Render() via GetEnabled() if needed. - virtual void SetEnabled(bool enabled) { m_enabled = enabled; } - bool GetEnabled() const { return m_enabled; } - - - // Implementation only from now on - - // Retrieve the DC to use for drawing. This is implemented in derived - // platform-specific classes. - virtual wxDC *GetDC() = 0; - - // To draw background use the background colour in wxDataViewItemAttr - virtual void RenderBackground(wxDC* dc, const wxRect& rect); - - // Prepare DC to use attributes and call Render(). - void WXCallRender(wxRect rect, wxDC *dc, int state); - - virtual bool IsCustomRenderer() const { return true; } - -protected: - // helper for GetSize() implementations, respects attributes - wxSize GetTextExtent(const wxString& str) const; - -private: - wxDataViewItemAttr m_attr; - bool m_enabled; - - wxDECLARE_NO_COPY_CLASS(wxDataViewCustomRendererBase); -}; - -// include the declaration of all the other renderers to get the real -// wxDataViewCustomRenderer from which we need to inherit below -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - // because of the different renderer classes hierarchy in the generic - // version, as explained above, we can include the header defining - // wxDataViewRenderer only here and not before wxDataViewCustomRendererBase - // declaration as for the native ports - #include "wx/generic/dvrenderer.h" - #include "wx/generic/dvrenderers.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/dvrenderers.h" -#elif defined(__WXMAC__) - #include "wx/osx/dvrenderers.h" -#else - #error "unknown native wxDataViewCtrl implementation" -#endif - -// ---------------------------------------------------------------------------- -// wxDataViewSpinRenderer -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer -{ -public: - wxDataViewSpinRenderer( int min, int max, - wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, - int alignment = wxDVR_DEFAULT_ALIGNMENT ); - virtual bool HasEditorCtrl() const { return true; } - virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ); - virtual bool Render( wxRect rect, wxDC *dc, int state ); - virtual wxSize GetSize() const; - virtual bool SetValue( const wxVariant &value ); - virtual bool GetValue( wxVariant &value ) const; - -private: - long m_data; - long m_min,m_max; -}; - -#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__) - -// ---------------------------------------------------------------------------- -// wxDataViewChoiceRenderer -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer -{ -public: - wxDataViewChoiceRenderer( const wxArrayString &choices, - wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, - int alignment = wxDVR_DEFAULT_ALIGNMENT ); - virtual bool HasEditorCtrl() const { return true; } - virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ); - virtual bool Render( wxRect rect, wxDC *dc, int state ); - virtual wxSize GetSize() const; - virtual bool SetValue( const wxVariant &value ); - virtual bool GetValue( wxVariant &value ) const; - - wxString GetChoice(size_t index) const { return m_choices[index]; } - const wxArrayString& GetChoices() const { return m_choices; } - -private: - wxArrayString m_choices; - wxString m_data; -}; - -// ---------------------------------------------------------------------------- -// wxDataViewChoiceByIndexRenderer -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewChoiceByIndexRenderer: public wxDataViewChoiceRenderer -{ -public: - wxDataViewChoiceByIndexRenderer( const wxArrayString &choices, - wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, - int alignment = wxDVR_DEFAULT_ALIGNMENT ); - - virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ); - - virtual bool SetValue( const wxVariant &value ); - virtual bool GetValue( wxVariant &value ) const; -}; - - -#endif // generic or Carbon versions - -#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__) - -// ---------------------------------------------------------------------------- -// wxDataViewDateRenderer -// ---------------------------------------------------------------------------- - -#if wxUSE_DATEPICKCTRL -class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer -{ -public: - wxDataViewDateRenderer(const wxString &varianttype = wxT("datetime"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, - int align = wxDVR_DEFAULT_ALIGNMENT); - - virtual bool HasEditorCtrl() const { return true; } - virtual wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant &value); - virtual bool GetValueFromEditorCtrl(wxWindow* editor, wxVariant &value); - virtual bool SetValue(const wxVariant &value); - virtual bool GetValue(wxVariant& value) const; - virtual bool Render( wxRect cell, wxDC *dc, int state ); - virtual wxSize GetSize() const; - -private: - wxDateTime m_date; -}; -#else // !wxUSE_DATEPICKCTRL -typedef wxDataViewTextRenderer wxDataViewDateRenderer; -#endif - -#endif // generic or GTK+ versions - -// this class is obsolete, its functionality was merged in -// wxDataViewTextRenderer itself now, don't use it any more -#define wxDataViewTextRendererAttr wxDataViewTextRenderer - -#endif // _WX_DVRENDERERS_H_ - diff --git a/Source/3rd Party/wx/include/wx/dynarray.h b/Source/3rd Party/wx/include/wx/dynarray.h index dabeb3e33..3cde91ae7 100644 --- a/Source/3rd Party/wx/include/wx/dynarray.h +++ b/Source/3rd Party/wx/include/wx/dynarray.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 12.09.97 +// RCS-ID: $Id: dynarray.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -13,7 +14,7 @@ #include "wx/defs.h" -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #include "wx/beforestd.h" #include #include @@ -53,8 +54,6 @@ */ #define WX_ARRAY_DEFAULT_INITIAL_SIZE (16) -#define _WX_ERROR_REMOVE "removing inexistent element in wxArray::Remove" - // ---------------------------------------------------------------------------- // types // ---------------------------------------------------------------------------- @@ -80,10 +79,10 @@ typedef int (wxCMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2); // you cast "SomeArray *" as "BaseArray *" and then delete it) // ---------------------------------------------------------------------------- -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL template -class wxArray_SortFunction +class WXDLLIMPEXP_BASE wxArray_SortFunction { public: typedef int (wxCMPFUNC_CONV *CMPFUNC)(T* pItem1, T* pItem2); @@ -96,7 +95,7 @@ private: }; template -class wxSortedArray_SortFunction +class WXDLLIMPEXP_BASE wxSortedArray_SortFunction { public: typedef F CMPFUNC; @@ -120,80 +119,32 @@ classexp name : public std::vector \ typedef predicate::CMPFUNC SCMPFUNC; \ public: \ typedef wxArray_SortFunction::CMPFUNC CMPFUNC; \ - \ public: \ - typedef T base_type; \ - \ - name() : std::vector() { } \ - name(size_type n) : std::vector(n) { } \ - name(size_type n, const_reference v) : std::vector(n, v) { } \ - template \ - name(InputIterator first, InputIterator last) : std::vector(first, last) { } \ - \ void Empty() { clear(); } \ void Clear() { clear(); } \ void Alloc(size_t uiSize) { reserve(uiSize); } \ - void Shrink() { name tmp(*this); swap(tmp); } \ + void Shrink(); \ \ size_t GetCount() const { return size(); } \ void SetCount(size_t n, T v = T()) { resize(n, v); } \ bool IsEmpty() const { return empty(); } \ size_t Count() const { return size(); } \ \ + typedef T base_type; \ + \ +protected: \ T& Item(size_t uiIndex) const \ { wxASSERT( uiIndex < size() ); return (T&)operator[](uiIndex); } \ - T& Last() const { return Item(size() - 1); } \ \ - int Index(T item, bool bFromEnd = false) const \ - { \ - if ( bFromEnd ) \ - { \ - const const_reverse_iterator b = rbegin(), \ - e = rend(); \ - for ( const_reverse_iterator i = b; i != e; ++i ) \ - if ( *i == item ) \ - return (int)(e - i - 1); \ - } \ - else \ - { \ - const const_iterator b = begin(), \ - e = end(); \ - for ( const_iterator i = b; i != e; ++i ) \ - if ( *i == item ) \ - return (int)(i - b); \ - } \ - \ - return wxNOT_FOUND; \ - } \ - int Index(T lItem, CMPFUNC fnCompare) const \ - { \ - Predicate p((SCMPFUNC)fnCompare); \ - const_iterator i = std::lower_bound(begin(), end(), lItem, p);\ - return i != end() && !p(lItem, *i) ? (int)(i - begin()) \ - : wxNOT_FOUND; \ - } \ - size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const \ - { \ - Predicate p((SCMPFUNC)fnCompare); \ - const_iterator i = std::lower_bound(begin(), end(), lItem, p);\ - return i - begin(); \ - } \ + int Index(T e, bool bFromEnd = false) const; \ + int Index(T lItem, CMPFUNC fnCompare) const; \ + size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const; \ void Add(T lItem, size_t nInsert = 1) \ { insert(end(), nInsert, lItem); } \ - size_t Add(T lItem, CMPFUNC fnCompare) \ - { \ - size_t n = IndexForInsert(lItem, fnCompare); \ - Insert(lItem, n); \ - return n; \ - } \ + size_t Add(T lItem, CMPFUNC fnCompare); \ void Insert(T lItem, size_t uiIndex, size_t nInsert = 1) \ { insert(begin() + uiIndex, nInsert, lItem); } \ - void Remove(T lItem) \ - { \ - int n = Index(lItem); \ - wxCHECK_RET( n != wxNOT_FOUND, _WX_ERROR_REMOVE ); \ - RemoveAt((size_t)n); \ - } \ + void Remove(T lItem); \ void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ { erase(begin() + uiIndex, begin() + uiIndex + nRemove); } \ \ @@ -204,12 +155,12 @@ public: \ } \ } -#else // if !wxUSE_STD_CONTAINERS +#else // if !wxUSE_STL #define _WX_DECLARE_BASEARRAY(T, name, classexp) \ classexp name \ { \ - typedef CMPFUNC SCMPFUNC; /* for compatibility wuth wxUSE_STD_CONTAINERS */ \ + typedef CMPFUNC SCMPFUNC; /* for compatibility wuth wxUSE_STL */ \ public: \ name(); \ name(const name& array); \ @@ -250,7 +201,7 @@ protected: \ typedef const value_type* const_iterator; \ typedef value_type& reference; \ typedef const value_type& const_reference; \ - typedef ptrdiff_t difference_type; \ + typedef int difference_type; \ typedef size_t size_type; \ \ void assign(const_iterator first, const_iterator last); \ @@ -275,26 +226,14 @@ protected: \ void pop_back() { RemoveAt(size() - 1); } \ void push_back(const value_type& v) { Add(v); } \ void reserve(size_type n) { Alloc(n); } \ - void resize(size_type count, value_type defval = value_type()) \ - { \ - if ( count < m_nCount ) \ - m_nCount = count; \ - else \ - SetCount(count, defval); \ - } \ + void resize(size_type n, value_type v = value_type()) \ + { SetCount(n, v); } \ \ iterator begin() { return m_pItems; } \ iterator end() { return m_pItems + m_nCount; } \ const_iterator begin() const { return m_pItems; } \ const_iterator end() const { return m_pItems + m_nCount; } \ \ - void swap(name& other) \ - { \ - wxSwap(m_nSize, other.m_nSize); \ - wxSwap(m_nCount, other.m_nCount); \ - wxSwap(m_pItems, other.m_pItems); \ - } \ - \ /* the following functions may be made directly public because */ \ /* they don't use the type of the elements at all */ \ public: \ @@ -313,7 +252,7 @@ private: \ T *m_pItems; \ } -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL // ============================================================================ // The private helper macros containing the core of the array classes @@ -326,22 +265,53 @@ private: \ // so using a temporary variable instead. // // The classes need a (even trivial) ~name() to link under Mac X +// +// _WX_ERROR_REMOVE is needed to resolve the name conflict between the wxT() +// macro and T typedef: we can't use wxT() inside WX_DEFINE_ARRAY! + +#define _WX_ERROR_REMOVE wxT("removing inexisting element in wxArray::Remove") // ---------------------------------------------------------------------------- // _WX_DEFINE_TYPEARRAY: array for simple types // ---------------------------------------------------------------------------- -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL -// in STL case we don't need the entire base arrays hack as standard container -// don't suffer from alignment/storage problems as our home-grown do #define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \ - _WX_DECLARE_BASEARRAY(T, name, classexp) +typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \ +classexp name : public base \ +{ \ +public: \ + T& operator[](size_t uiIndex) const \ + { return (T&)(base::operator[](uiIndex)); } \ + T& Item(size_t uiIndex) const \ + { return (T&)/*const cast*/base::operator[](uiIndex); } \ + T& Last() const \ + { return Item(Count() - 1); } \ + \ + int Index(T e, bool bFromEnd = false) const \ + { return base::Index(e, bFromEnd); } \ + \ + void Add(T lItem, size_t nInsert = 1) \ + { insert(end(), nInsert, lItem); } \ + void Insert(T lItem, size_t uiIndex, size_t nInsert = 1) \ + { insert(begin() + uiIndex, nInsert, lItem); } \ + \ + void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ + { base::RemoveAt(uiIndex, nRemove); } \ + void Remove(T lItem) \ + { int iIndex = Index(lItem); \ + wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \ + _WX_ERROR_REMOVE); \ + RemoveAt((size_t)iIndex); } \ + \ + void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC)fCmp); } \ +} #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ _WX_DEFINE_TYPEARRAY(T, name, base, classexp) -#else // if !wxUSE_STD_CONTAINERS +#else // if !wxUSE_STL // common declaration used by both _WX_DEFINE_TYPEARRAY and // _WX_DEFINE_TYPEARRAY_PTR @@ -356,12 +326,17 @@ public: \ name() { } \ ~name() { } \ \ + name& operator=(const name& src) \ + { base* temp = (base*) this; \ + (*temp) = ((const base&)src); \ + return *this; } \ + \ T& operator[](size_t uiIndex) const \ { return (T&)(base::operator[](uiIndex)); } \ T& Item(size_t uiIndex) const \ { return (T&)(base::operator[](uiIndex)); } \ T& Last() const \ - { return (T&)(base::operator[](GetCount() - 1)); } \ + { return (T&)(base::operator[](Count() - 1)); } \ \ int Index(T lItem, bool bFromEnd = false) const \ { return base::Index((base_type)lItem, bFromEnd); } \ @@ -375,7 +350,8 @@ public: \ { base::RemoveAt(uiIndex, nRemove); } \ void Remove(T lItem) \ { int iIndex = Index(lItem); \ - wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE); \ + wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \ + _WX_ERROR_REMOVE); \ base::RemoveAt((size_t)iIndex); } \ \ void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC)fCmp); } \ @@ -462,7 +438,6 @@ public: \ bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }\ }; \ \ - name(size_type n) { assign(n, value_type()); } \ name(size_type n, const_reference v) { assign(n, v); } \ name(const_iterator first, const_iterator last) \ { assign(first, last); } \ @@ -500,7 +475,6 @@ public: \ void reserve(size_type n) { base::reserve(n); } \ void resize(size_type n, value_type v = value_type()) \ { base::resize(n, v); } \ - void swap(name& other) { base::swap(other); } \ } #define _WX_PTROP pointer operator->() const { return m_ptr; } @@ -511,7 +485,7 @@ public: \ #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, _WX_PTROP_NONE) -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL // ---------------------------------------------------------------------------- // _WX_DEFINE_SORTED_TYPEARRAY: sorted array for simple data types @@ -552,14 +526,13 @@ public: \ \ size_t Add(T lItem) \ { return base::Add(lItem, (CMPFUNC)m_fnCompare); } \ - void push_back(T lItem) \ - { Add(lItem); } \ \ void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ { base::erase(begin() + uiIndex, begin() + uiIndex + nRemove); } \ void Remove(T lItem) \ { int iIndex = Index(lItem); \ - wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE ); \ + wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \ + _WX_ERROR_REMOVE ); \ base::erase(begin() + iIndex); } \ \ private: \ @@ -584,8 +557,7 @@ public: \ \ ~name(); \ \ - void Alloc(size_t count) { base::reserve(count); } \ - void reserve(size_t count) { base::reserve(count); } \ + void Alloc(size_t count) { reserve(count); } \ size_t GetCount() const { return base_array::size(); } \ size_t size() const { return base_array::size(); } \ bool IsEmpty() const { return base_array::empty(); } \ @@ -644,7 +616,7 @@ private: \ // that wants to export a wxArray daubed with your own import/export goo. // // Finally, you can define the macro below as something special to modify the -// arrays defined by a simple WX_FOO_ARRAY as well. By default is empty. +// arrays defined by a simple WX_FOO_ARRAY as well. By default is is empty. #define wxARRAY_DEFAULT_EXPORT // ---------------------------------------------------------------------------- @@ -656,7 +628,7 @@ private: \ WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, wxARRAY_DEFAULT_EXPORT) #define WX_DECLARE_EXPORTED_BASEARRAY(T, name) \ - WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, WXDLLIMPEXP_CORE) + WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, WXDLLEXPORT) #define WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, expmode) \ typedef T _wxArray##name; \ @@ -677,10 +649,10 @@ private: \ WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class wxARRAY_DEFAULT_EXPORT) #define WX_DEFINE_EXPORTED_TYPEARRAY(T, name, base) \ - WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class WXDLLIMPEXP_CORE) + WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class WXDLLEXPORT) #define WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, base) \ - WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class WXDLLIMPEXP_CORE) + WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class WXDLLEXPORT) #define WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, expdecl) \ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class expdecl) @@ -733,7 +705,7 @@ private: \ wxARRAY_DEFAULT_EXPORT) #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, base) \ - WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLIMPEXP_CORE) + WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLEXPORT) #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, expmode) \ typedef T _wxArray##name; \ @@ -759,7 +731,7 @@ private: \ #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ - WXDLLIMPEXP_CORE) + WXDLLEXPORT) #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ expmode) \ @@ -812,7 +784,7 @@ private: \ WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, wxARRAY_DEFAULT_EXPORT) #define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \ - WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLIMPEXP_CORE) + WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLEXPORT) #define WX_DECLARE_OBJARRAY_WITH_DECL(T, name, decl) \ typedef T _wxObjArray##name; \ @@ -1034,7 +1006,7 @@ WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE #define WX_PREPEND_ARRAY(array, other) \ { \ size_t wxAAcnt = (other).size(); \ - (array).reserve(wxAAcnt); \ + (array).Alloc(wxAAcnt); \ for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ { \ (array).Insert((other)[wxAAn], wxAAn); \ @@ -1045,7 +1017,7 @@ WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE #define WX_APPEND_ARRAY(array, other) \ { \ size_t wxAAcnt = (other).size(); \ - (array).reserve(wxAAcnt); \ + (array).Alloc(wxAAcnt); \ for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ { \ (array).push_back((other)[wxAAn]); \ diff --git a/Source/3rd Party/wx/include/wx/dynlib.h b/Source/3rd Party/wx/include/wx/dynlib.h index e02e08388..5903a7b5b 100644 --- a/Source/3rd Party/wx/include/wx/dynlib.h +++ b/Source/3rd Party/wx/include/wx/dynlib.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux, Vadim Zeitlin, Vaclav Slavik // Modified by: // Created: 20/07/98 +// RCS-ID: $Id: dynlib.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,6 +19,14 @@ #include "wx/string.h" #include "wx/dynarray.h" +#if defined(__OS2__) || defined(__EMX__) +#include "wx/os2/private.h" +#endif + +#ifdef __WXMSW__ +#include "wx/msw/private.h" +#endif + // note that we have our own dlerror() implementation under Darwin #if (defined(HAVE_DLERROR) && !defined(__EMX__)) || defined(__DARWIN__) #define wxHAVE_DYNLIB_ERROR @@ -32,7 +41,7 @@ class WXDLLIMPEXP_FWD_BASE wxDynamicLibraryDetailsCreator; // Note: __OS2__/EMX has to be tested first, since we want to use // native version, even if configure detected presence of DLOPEN. #if defined(__OS2__) || defined(__EMX__) || defined(__WINDOWS__) - typedef WXHMODULE wxDllType; + typedef HMODULE wxDllType; #elif defined(__DARWIN__) // Don't include dlfcn.h on Darwin, we may be using our own replacements. typedef void *wxDllType; @@ -64,13 +73,12 @@ enum wxDLFlags wxDL_VERBATIM = 0x00000008, // attempt to load the supplied library // name without appending the usual dll // filename extension. - - // this flag is obsolete, don't use wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded // (only for wxPluginManager) wxDL_QUIET = 0x00000020, // don't log an error if failed to load +#if wxABI_VERSION >= 20810 // this flag is dangerous, for internal use of wxMSW only, don't use at all // and especially don't use directly, use wxLoadedDLL instead if you really // do need it @@ -78,6 +86,7 @@ enum wxDLFlags // loaded DLL or NULL otherwise; Unload() // should not be called so don't forget to // Detach() if you use this function +#endif // wx 2.8.10+ wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32 }; @@ -109,63 +118,6 @@ enum wxPluginCategory #define wxDYNLIB_FUNCTION(type, name, dynlib) \ type pfn ## name = (type)(dynlib).GetSymbol(wxT(#name)) - -// a more convenient function replacing wxDYNLIB_FUNCTION above -// -// it uses the convention that the type of the function is its name suffixed -// with "_t" but it doesn't define a variable but just assigns the loaded value -// to it and also allows to pass it the prefix to be used instead of hardcoding -// "pfn" (the prefix can be "m_" or "gs_pfn" or whatever) -// -// notice that this function doesn't generate error messages if the symbol -// couldn't be loaded, the caller should generate the appropriate message -#define wxDL_INIT_FUNC(pfx, name, dynlib) \ - pfx ## name = (name ## _t)(dynlib).RawGetSymbol(#name) - -#ifdef __WINDOWS__ - -// same as wxDL_INIT_FUNC() but appends 'A' or 'W' to the function name, see -// wxDynamicLibrary::GetSymbolAorW() -#define wxDL_INIT_FUNC_AW(pfx, name, dynlib) \ - pfx ## name = (name ## _t)(dynlib).GetSymbolAorW(#name) - -#endif // __WINDOWS__ - -// the following macros can be used to redirect a whole library to a class and -// check at run-time if the library is present and contains all required -// methods -// -// notice that they are supposed to be used inside a class which has "m_ok" -// member variable indicating if the library had been successfully loaded - -// helper macros constructing the name of the variable storing the function -// pointer and the name of its type from the function name -#define wxDL_METHOD_NAME(name) m_pfn ## name -#define wxDL_METHOD_TYPE(name) name ## _t - -// parameters are: -// - rettype: return type of the function, e.g. "int" -// - name: name of the function, e.g. "foo" -// - args: function signature in parentheses, e.g. "(int x, int y)" -// - argnames: the names of the parameters in parentheses, e.g. "(x, y)" -// - defret: the value to return if the library wasn't successfully loaded -#define wxDL_METHOD_DEFINE( rettype, name, args, argnames, defret ) \ - typedef rettype (* wxDL_METHOD_TYPE(name)) args ; \ - wxDL_METHOD_TYPE(name) wxDL_METHOD_NAME(name); \ - rettype name args \ - { return m_ok ? wxDL_METHOD_NAME(name) argnames : defret; } - -#define wxDL_VOIDMETHOD_DEFINE( name, args, argnames ) \ - typedef void (* wxDL_METHOD_TYPE(name)) args ; \ - wxDL_METHOD_TYPE(name) wxDL_METHOD_NAME(name); \ - void name args \ - { if ( m_ok ) wxDL_METHOD_NAME(name) argnames ; } - -#define wxDL_METHOD_LOAD(lib, name) \ - wxDL_METHOD_NAME(name) = \ - (wxDL_METHOD_TYPE(name)) lib.GetSymbol(#name, &m_ok); \ - if ( !m_ok ) return false - // ---------------------------------------------------------------------------- // wxDynamicLibraryDetails: contains details about a loaded wxDynamicLibrary // ---------------------------------------------------------------------------- @@ -231,7 +183,7 @@ public: static wxDllType GetProgramHandle(); // return the platform standard DLL extension (with leading dot) - static wxString GetDllExt(wxDynamicLibraryCategory cat = wxDL_LIBRARY); + static const wxChar *GetDllExt() { return ms_dllext; } wxDynamicLibrary() : m_handle(0) { } wxDynamicLibrary(const wxString& libname, int flags = wxDL_DEFAULT) @@ -303,7 +255,7 @@ public: #endif } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // this function is useful for loading functions from the standard Windows // DLLs: such functions have an 'A' (in ANSI build) or 'W' (in Unicode, or // wide character build) suffix if they take string parameters @@ -325,7 +277,7 @@ public: { return RawGetSymbolAorW(m_handle, name); } -#endif // __WINDOWS__ +#endif // __WXMSW__ // return all modules/shared libraries in the address space of this process // @@ -348,19 +300,6 @@ public: static wxString GetPluginsDirectory(); -#ifdef __WINDOWS__ - // return the handle (HMODULE/HINSTANCE) of the DLL with the given name - // and/or containing the specified address: for XP and later systems only - // the address is used and the name is ignored but for the previous systems - // only the name (which may be either a full path to the DLL or just its - // base name, possibly even without extension) is used - // - // the returned handle reference count is not incremented so it doesn't - // need to be freed using FreeLibrary() but it also means that it can - // become invalid if the DLL is unloaded - static WXHMODULE MSWGetModuleHandle(const wxString& name, void *addr); -#endif // __WINDOWS__ - protected: // common part of GetSymbol() and HasSymbol() void *DoGetSymbol(const wxString& name, bool *success = 0) const; @@ -371,15 +310,18 @@ protected: #endif // wxHAVE_DYNLIB_ERROR + // platform specific shared lib suffix. + static const wxChar *ms_dllext; + // the handle to DLL or NULL wxDllType m_handle; // no copy ctor/assignment operators (or we'd try to unload the library // twice) - wxDECLARE_NO_COPY_CLASS(wxDynamicLibrary); + DECLARE_NO_COPY_CLASS(wxDynamicLibrary) }; -#ifdef __WINDOWS__ +#if defined(__WXMSW__) && wxABI_VERSION >= 20810 // ---------------------------------------------------------------------------- // wxLoadedDLL is a MSW-only internal helper class allowing to dynamically bind @@ -400,7 +342,7 @@ public: } }; -#endif // __WINDOWS__ +#endif // __WXMSW__ // ---------------------------------------------------------------------------- // Interesting defines diff --git a/Source/3rd Party/wx/include/wx/dynload.h b/Source/3rd Party/wx/include/wx/dynload.h index 939a1184a..76b377c07 100644 --- a/Source/3rd Party/wx/include/wx/dynload.h +++ b/Source/3rd Party/wx/include/wx/dynload.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/dynload.h +// Name: dynload.h // Purpose: Dynamic loading framework // Author: Ron Lee, David Falkinder, Vadim Zeitlin and a cast of 1000's // (derived in part from dynlib.cpp (c) 1998 Guilhem Lavaux) // Modified by: // Created: 03/12/01 +// RCS-ID: $Id: dynload.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2001 Ron Lee // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -81,11 +82,8 @@ public: private: - // These pointers may be NULL but if they are not, then m_ourLast follows - // m_ourFirst in the linked list, i.e. can be found by calling GetNext() a - // sufficient number of times. - const wxClassInfo *m_ourFirst; // first class info in this plugin - const wxClassInfo *m_ourLast; // ..and the last one + wxClassInfo *m_before; // sm_first before loading this lib + wxClassInfo *m_after; // ..and after. size_t m_linkcount; // Ref count of library link calls size_t m_objcount; // ..and (pluggable) object instantiations. @@ -96,7 +94,7 @@ private: void RegisterModules(); // Init any wxModules in the lib. void UnregisterModules(); // Cleanup any wxModules we installed. - wxDECLARE_NO_COPY_CLASS(wxPluginLibrary); + DECLARE_NO_COPY_CLASS(wxPluginLibrary) }; @@ -146,7 +144,7 @@ private: // We could allow this class to be copied if we really // wanted to, but not without modification. - wxDECLARE_NO_COPY_CLASS(wxPluginManager); + DECLARE_NO_COPY_CLASS(wxPluginManager) }; diff --git a/Source/3rd Party/wx/include/wx/editlbox.h b/Source/3rd Party/wx/include/wx/editlbox.h deleted file mode 100644 index 7aad2ac20..000000000 --- a/Source/3rd Party/wx/include/wx/editlbox.h +++ /dev/null @@ -1,99 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/editlbox.h -// Purpose: ListBox with editable items -// Author: Vaclav Slavik -// Copyright: (c) Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __WX_EDITLBOX_H__ -#define __WX_EDITLBOX_H__ - -#include "wx/defs.h" - -#if wxUSE_EDITABLELISTBOX - -#include "wx/panel.h" - -class WXDLLIMPEXP_FWD_CORE wxBitmapButton; -class WXDLLIMPEXP_FWD_CORE wxListCtrl; -class WXDLLIMPEXP_FWD_CORE wxListEvent; - -#define wxEL_ALLOW_NEW 0x0100 -#define wxEL_ALLOW_EDIT 0x0200 -#define wxEL_ALLOW_DELETE 0x0400 -#define wxEL_NO_REORDER 0x0800 -#define wxEL_DEFAULT_STYLE (wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE) - -extern WXDLLIMPEXP_DATA_ADV(const char) wxEditableListBoxNameStr[]; - -// This class provides a composite control that lets the -// user easily enter list of strings - -class WXDLLIMPEXP_ADV wxEditableListBox : public wxPanel -{ -public: - wxEditableListBox() { Init(); } - - wxEditableListBox(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxEL_DEFAULT_STYLE, - const wxString& name = wxEditableListBoxNameStr) - { - Init(); - Create(parent, id, label, pos, size, style, name); - } - - bool Create(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxEL_DEFAULT_STYLE, - const wxString& name = wxEditableListBoxNameStr); - - void SetStrings(const wxArrayString& strings); - void GetStrings(wxArrayString& strings) const; - - wxListCtrl* GetListCtrl() { return m_listCtrl; } - wxBitmapButton* GetDelButton() { return m_bDel; } - wxBitmapButton* GetNewButton() { return m_bNew; } - wxBitmapButton* GetUpButton() { return m_bUp; } - wxBitmapButton* GetDownButton() { return m_bDown; } - wxBitmapButton* GetEditButton() { return m_bEdit; } - -protected: - wxBitmapButton *m_bDel, *m_bNew, *m_bUp, *m_bDown, *m_bEdit; - wxListCtrl *m_listCtrl; - int m_selection; - long m_style; - - void Init() - { - m_style = 0; - m_selection = 0; - m_bEdit = m_bNew = m_bDel = m_bUp = m_bDown = NULL; - m_listCtrl = NULL; - } - - void OnItemSelected(wxListEvent& event); - void OnEndLabelEdit(wxListEvent& event); - void OnNewItem(wxCommandEvent& event); - void OnDelItem(wxCommandEvent& event); - void OnEditItem(wxCommandEvent& event); - void OnUpItem(wxCommandEvent& event); - void OnDownItem(wxCommandEvent& event); - - DECLARE_CLASS(wxEditableListBox) - DECLARE_EVENT_TABLE() - -private: - void SwapItems(long i1, long i2); - -}; - -#endif // wxUSE_EDITABLELISTBOX - -#endif // __WX_EDITLBOX_H__ diff --git a/Source/3rd Party/wx/include/wx/effects.h b/Source/3rd Party/wx/include/wx/effects.h index ecda16342..987ddf51a 100644 --- a/Source/3rd Party/wx/include/wx/effects.h +++ b/Source/3rd Party/wx/include/wx/effects.h @@ -5,6 +5,7 @@ // Author: Julian Smart et al // Modified by: // Created: 25/4/2000 +// RCS-ID: $Id: effects.h 39109 2006-05-08 11:31:03Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,12 +13,6 @@ #ifndef _WX_EFFECTS_H_ #define _WX_EFFECTS_H_ -// this class is deprecated and will be removed in the next wx version -// -// please use wxRenderer::DrawBorder() instead of DrawSunkenEdge(); there is no -// replacement for TileBitmap() but it doesn't seem to be very useful anyhow -#if WXWIN_COMPATIBILITY_2_8 - /* * wxEffects: various 3D effects */ @@ -27,15 +22,17 @@ #include "wx/gdicmn.h" #include "wx/dc.h" -class WXDLLIMPEXP_CORE wxEffectsImpl: public wxObject +class WXDLLEXPORT wxEffects: public wxObject { +DECLARE_CLASS(wxEffects) + public: // Assume system colours - wxEffectsImpl() ; + wxEffects() ; // Going from lightest to darkest - wxEffectsImpl(const wxColour& highlightColour, const wxColour& lightShadow, - const wxColour& faceColour, const wxColour& mediumShadow, - const wxColour& darkShadow) ; + wxEffects(const wxColour& highlightColour, const wxColour& lightShadow, + const wxColour& faceColour, const wxColour& mediumShadow, + const wxColour& darkShadow) ; // Accessors wxColour GetHighlightColour() const { return m_highlightColour; } @@ -73,18 +70,6 @@ protected: wxColour m_faceColour; // Usually grey wxColour m_mediumShadow; // Usually dark grey wxColour m_darkShadow; // Usually black - - DECLARE_CLASS(wxEffectsImpl) }; -// current versions of g++ don't generate deprecation warnings for classes -// declared deprecated, so define wxEffects as a typedef instead: this does -// generate warnings with both g++ and VC (which also has no troubles with -// directly deprecating the classes...) -// -// note that this g++ bug (16370) is supposed to be fixed in g++ 4.3.0 -typedef wxEffectsImpl wxDEPRECATED(wxEffects); - -#endif // WXWIN_COMPATIBILITY_2_8 - -#endif // _WX_EFFECTS_H_ +#endif diff --git a/Source/3rd Party/wx/include/wx/encconv.h b/Source/3rd Party/wx/include/wx/encconv.h index d4b0ba101..f57d8ea9d 100644 --- a/Source/3rd Party/wx/include/wx/encconv.h +++ b/Source/3rd Party/wx/include/wx/encconv.h @@ -57,7 +57,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject virtual ~wxEncodingConverter() { if (m_Table) delete[] m_Table; } // Initialize conversion. Both output or input encoding may - // be wxFONTENCODING_UNICODE. + // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. // // All subsequent calls to Convert() will interpret it's argument // as a string in input_enc encoding and will output string in @@ -76,7 +76,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject // try some (lossy) substitutions - e.g. replace // unconvertable latin capitals with acute by ordinary // capitals, replace en-dash or em-dash by '-' etc. - // both modes guarantee that output string will have same length + // both modes gurantee that output string will have same length // as input string // // Returns false if given conversion is impossible, true otherwise @@ -91,11 +91,12 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject bool Convert(char* str) const { return Convert(str, str); } wxString Convert(const wxString& input) const; +#if wxUSE_WCHAR_T bool Convert(const char* input, wchar_t* output) const; bool Convert(const wchar_t* input, char* output) const; bool Convert(const wchar_t* input, wchar_t* output) const; bool Convert(wchar_t* str) const { return Convert(str, str); } - +#endif // Return equivalent(s) for given font that are used // under given platform. wxPLATFORM_CURRENT means the plaform // this binary was compiled for @@ -109,9 +110,9 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject // // Equivalence is defined in terms of convertibility: // 2 encodings are equivalent if you can convert text between - // then without losing information (it may - and will - happen - // that you lose special chars like quotation marks or em-dashes - // but you shouldn't lose any diacritics and language-specific + // then without loosing information (it may - and will - happen + // that you loose special chars like quotation marks or em-dashes + // but you shouldn't loose any diacritics and language-specific // characters when converting between equivalent encodings). // // Convert() method is not limited to converting between @@ -143,11 +144,16 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject } private: + +#if wxUSE_WCHAR_T wchar_t *m_Table; +#else + char *m_Table; +#endif bool m_UnicodeInput, m_UnicodeOutput; bool m_JustCopy; - wxDECLARE_NO_COPY_CLASS(wxEncodingConverter); + DECLARE_NO_COPY_CLASS(wxEncodingConverter) }; #endif // _WX_ENCCONV_H_ diff --git a/Source/3rd Party/wx/include/wx/encinfo.h b/Source/3rd Party/wx/include/wx/encinfo.h index 4f436be1c..fb3d9214f 100644 --- a/Source/3rd Party/wx/include/wx/encinfo.h +++ b/Source/3rd Party/wx/include/wx/encinfo.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.09.2003 (extracted from wx/fontenc.h) +// RCS-ID: $Id: encinfo.h 40865 2006-08-27 09:42:42Z VS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -31,9 +32,10 @@ // to create a font of non-standard encoding (like KOI8) under Windows - the // facename specifies the encoding then) -struct WXDLLIMPEXP_CORE wxNativeEncodingInfo +struct WXDLLEXPORT wxNativeEncodingInfo { wxString facename; // may be empty meaning "any" +#ifndef __WXPALMOS__ wxFontEncoding encoding; // so that we know what this struct represents #if defined(__WXMSW__) || \ @@ -51,11 +53,17 @@ struct WXDLLIMPEXP_CORE wxNativeEncodingInfo #elif defined(_WX_X_FONTLIKE) wxString xregistry, xencoding; -#elif defined(wxHAS_UTF8_FONTS) - // ports using UTF-8 for text don't need encoding information for fonts +#elif defined(__WXGTK20__) + // No way to specify this in Pango as this + // seems to be handled internally. +#elif defined(__WXMGL__) + int mglEncoding; +#elif defined(__WXDFB__) + // DirectFB uses UTF-8 internally, doesn't use font encodings #else #error "Unsupported toolkit" #endif +#endif // !__WXPALMOS__ // this struct is saved in config by wxFontMapper, so it should know to // serialise itself (implemented in platform-specific code) bool FromString(const wxString& s); diff --git a/Source/3rd Party/wx/include/wx/event.h b/Source/3rd Party/wx/include/wx/event.h index f45170da3..599b588d2 100644 --- a/Source/3rd Party/wx/include/wx/event.h +++ b/Source/3rd Party/wx/include/wx/event.h @@ -4,12 +4,13 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: event.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_EVENT_H_ -#define _WX_EVENT_H_ +#ifndef _WX_EVENT_H__ +#define _WX_EVENT_H__ #include "wx/defs.h" #include "wx/cpp.h" @@ -19,34 +20,18 @@ #if wxUSE_GUI #include "wx/gdicmn.h" #include "wx/cursor.h" - #include "wx/mousestate.h" #endif +#include "wx/thread.h" + #include "wx/dynarray.h" -#include "wx/thread.h" -#include "wx/tracker.h" -#include "wx/typeinfo.h" -#include "wx/any.h" - -#ifdef wxHAS_EVENT_BIND - #include "wx/meta/convertible.h" -#endif - -// Currently VC6 and VC7 are known to not be able to compile CallAfter() code, -// so disable it for them. -#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(8) - #include "wx/meta/removeref.h" - - #define wxHAS_CALL_AFTER -#endif // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- class WXDLLIMPEXP_FWD_BASE wxList; -class WXDLLIMPEXP_FWD_BASE wxEvent; -class WXDLLIMPEXP_FWD_BASE wxEventFilter; + #if wxUSE_GUI class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxMenu; @@ -54,25 +39,7 @@ class WXDLLIMPEXP_FWD_BASE wxEventFilter; class WXDLLIMPEXP_FWD_CORE wxWindowBase; #endif // wxUSE_GUI -// We operate with pointer to members of wxEvtHandler (such functions are used -// as event handlers in the event tables or as arguments to Connect()) but by -// default MSVC uses a restricted (but more efficient) representation of -// pointers to members which can't deal with multiple base classes. To avoid -// mysterious (as the compiler is not good enough to detect this and give a -// sensible error message) errors in the user code as soon as it defines -// classes inheriting from both wxEvtHandler (possibly indirectly, e.g. via -// wxWindow) and something else (including our own wxTrackable but not limited -// to it), we use the special MSVC keyword telling the compiler to use a more -// general pointer to member representation for the classes inheriting from -// wxEvtHandler. -#ifdef __VISUALC__ - #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance -#else - #define wxMSVC_FWD_MULTIPLE_BASES -#endif - -class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler; -class wxEventConnectionRef; +class WXDLLIMPEXP_FWD_BASE wxEvtHandler; // ---------------------------------------------------------------------------- // Event types @@ -80,756 +47,249 @@ class wxEventConnectionRef; typedef int wxEventType; -#define wxEVT_ANY ((wxEventType)-1) - // this is used to make the event table entry type safe, so that for an event -// handler only a function with proper parameter list can be given. See also -// the wxEVENT_HANDLER_CAST-macro. -#define wxStaticCastEvent(type, val) static_cast(val) +// handler only a function with proper parameter list can be given. +#define wxStaticCastEvent(type, val) wx_static_cast(type, val) -#define wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ - wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj) +// in previous versions of wxWidgets the event types used to be constants +// which created difficulties with custom/user event types definition +// +// starting from wxWidgets 2.4 the event types are now dynamically assigned +// using wxNewEventType() which solves this problem, however at price of +// several incompatibilities: +// +// a) event table macros declaration changed, it now uses wxEventTableEntry +// ctor instead of initialisation from an agregate - the macro +// DECLARE_EVENT_TABLE_ENTRY may be used to write code which can compile +// with all versions of wxWidgets +// +// b) event types can't be used as switch() cases as they're not really +// constant any more - there is no magic solution here, you just have to +// change the switch()es to if()s +// +// if these are real problems for you, define WXWIN_COMPATIBILITY_EVENT_TYPES +// as 1 to get 100% old behaviour, however you won't be able to use the +// libraries using the new dynamic event type allocation in such case, so avoid +// it if possible. +#ifndef WXWIN_COMPATIBILITY_EVENT_TYPES + #define WXWIN_COMPATIBILITY_EVENT_TYPES 0 +#endif -#define wxDECLARE_EVENT_TABLE_TERMINATOR() \ - wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) +#if WXWIN_COMPATIBILITY_EVENT_TYPES + +#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ + { type, winid, idLast, fn, obj } + +#define BEGIN_DECLARE_EVENT_TYPES() enum { +#define END_DECLARE_EVENT_TYPES() }; +#define DECLARE_EVENT_TYPE(name, value) name = wxEVT_FIRST + value, +#define DECLARE_LOCAL_EVENT_TYPE(name, value) name = wxEVT_USER_FIRST + value, +#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ + DECLARE_LOCAL_EVENT_TYPE(name, value) +#define DEFINE_EVENT_TYPE(name) +#define DEFINE_LOCAL_EVENT_TYPE(name) + + +#else // !WXWIN_COMPATIBILITY_EVENT_TYPES + +#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ + wxEventTableEntry(type, winid, idLast, fn, obj) + +#define BEGIN_DECLARE_EVENT_TYPES() +#define END_DECLARE_EVENT_TYPES() +#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ + extern expdecl const wxEventType name; +#define DECLARE_EVENT_TYPE(name, value) \ + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) +#define DECLARE_LOCAL_EVENT_TYPE(name, value) \ + DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) +#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); +#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) // generate a new unique event type extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); -// define macros to create new event types: -#ifdef wxHAS_EVENT_BIND - // events are represented by an instance of wxEventTypeTag and the - // corresponding type must be specified for type-safety checks - - // define a new custom event type, can be used alone or after event - // declaration in the header using one of the macros below - #define wxDEFINE_EVENT( name, type ) \ - const wxEventTypeTag< type > name( wxNewEventType() ) - - // the general version allowing exporting the event type from DLL, used by - // wxWidgets itself - #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ - extern const expdecl wxEventTypeTag< type > name - - // this is the version which will normally be used in the user code - #define wxDECLARE_EVENT( name, type ) \ - wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) - - - // these macros are only used internally for backwards compatibility and - // allow to define an alias for an existing event type (this is used by - // wxEVT_SPIN_XXX) - #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ - const wxEventTypeTag< type > name( value ) - - #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ - extern const expdecl wxEventTypeTag< type > name -#else // !wxHAS_EVENT_BIND - // the macros are the same ones as above but defined differently as we only - // use the integer event type values to identify events in this case - - #define wxDEFINE_EVENT( name, type ) \ - const wxEventType name( wxNewEventType() ) - - #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \ - extern const expdecl wxEventType name - #define wxDECLARE_EVENT( name, type ) \ - wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) - - #define wxDEFINE_EVENT_ALIAS( name, type, value ) \ - const wxEventType name = value - #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \ - extern const expdecl wxEventType name -#endif // wxHAS_EVENT_BIND/!wxHAS_EVENT_BIND - -// Try to cast the given event handler to the correct handler type: - -#define wxEVENT_HANDLER_CAST( functype, func ) \ - ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func ) - - -#ifdef wxHAS_EVENT_BIND - -// The tag is a type associated to the event type (which is an integer itself, -// in spite of its name) value. It exists in order to be used as a template -// parameter and provide a mapping between the event type values and their -// corresponding wxEvent-derived classes. -template -class wxEventTypeTag -{ -public: - // The class of wxEvent-derived class carried by the events of this type. - typedef T EventClass; - - wxEventTypeTag(wxEventType type) { m_type = type; } - - // Return a wxEventType reference for the initialization of the static - // event tables. See wxEventTableEntry::m_eventType for a more thorough - // explanation. - operator const wxEventType&() const { return m_type; } - -private: - wxEventType m_type; -}; - -#endif // wxHAS_EVENT_BIND - -// These are needed for the functor definitions -typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); - -// We had some trouble (specifically with eVC for ARM WinCE build) with using -// wxEventFunction in the past so we had introduced wxObjectEventFunction which -// used to be a typedef for a member of wxObject and not wxEvtHandler to work -// around this but as eVC is not really supported any longer we now only keep -// this for backwards compatibility and, despite its name, this is a typedef -// for wxEvtHandler member now -- but if we have the same problem with another -// compiler we can restore its old definition for it. -typedef wxEventFunction wxObjectEventFunction; - -// The event functor which is stored in the static and dynamic event tables: -class WXDLLIMPEXP_BASE wxEventFunctor -{ -public: - virtual ~wxEventFunctor(); - - // Invoke the actual event handler: - virtual void operator()(wxEvtHandler *, wxEvent&) = 0; - - // this function tests whether this functor is matched, for the purpose of - // finding it in an event table in Unbind(), by the given functor: - virtual bool IsMatching(const wxEventFunctor& functor) const = 0; - - // If the functor holds an wxEvtHandler, then get access to it and track - // its lifetime with wxEventConnectionRef: - virtual wxEvtHandler *GetEvtHandler() const - { return NULL; } - - // This is only used to maintain backward compatibility in - // wxAppConsoleBase::CallEventHandler and ensures that an overwritten - // wxAppConsoleBase::HandleEvent is still called for functors which hold an - // wxEventFunction: - virtual wxEventFunction GetEvtMethod() const - { return NULL; } - -private: - WX_DECLARE_ABSTRACT_TYPEINFO(wxEventFunctor) -}; - -// A plain method functor for the untyped legacy event types: -class WXDLLIMPEXP_BASE wxObjectEventFunctor : public wxEventFunctor -{ -public: - wxObjectEventFunctor(wxObjectEventFunction method, wxEvtHandler *handler) - : m_handler( handler ), m_method( method ) - { } - - virtual void operator()(wxEvtHandler *handler, wxEvent& event); - - virtual bool IsMatching(const wxEventFunctor& functor) const - { - if ( wxTypeId(functor) == wxTypeId(*this) ) - { - const wxObjectEventFunctor &other = - static_cast< const wxObjectEventFunctor & >( functor ); - - // FIXME-VC6: amazing but true: replacing "m_method == 0" here - // with "!m_method" makes VC6 crash with an ICE in DLL build (only!) - // Also notice that using "NULL" instead of "0" results in warnings - // about "using NULL in arithmetics" from arm-linux-androideabi-g++ - // 4.4.3 used for wxAndroid build. - - return ( m_method == other.m_method || other.m_method == 0 ) && - ( m_handler == other.m_handler || other.m_handler == NULL ); - } - else - return false; - } - - virtual wxEvtHandler *GetEvtHandler() const - { return m_handler; } - - virtual wxEventFunction GetEvtMethod() const - { return m_method; } - -private: - wxEvtHandler *m_handler; - wxEventFunction m_method; - - // Provide a dummy default ctor for type info purposes - wxObjectEventFunctor() { } - - WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor) -}; - -// Create a functor for the legacy events: used by Connect() -inline wxObjectEventFunctor * -wxNewEventFunctor(const wxEventType& WXUNUSED(evtType), - wxObjectEventFunction method, - wxEvtHandler *handler) -{ - return new wxObjectEventFunctor(method, handler); -} - -// This version is used by wxDECLARE_EVENT_TABLE_ENTRY() -inline wxObjectEventFunctor * -wxNewEventTableFunctor(const wxEventType& WXUNUSED(evtType), - wxObjectEventFunction method) -{ - return new wxObjectEventFunctor(method, NULL); -} - -inline wxObjectEventFunctor -wxMakeEventFunctor(const wxEventType& WXUNUSED(evtType), - wxObjectEventFunction method, - wxEvtHandler *handler) -{ - return wxObjectEventFunctor(method, handler); -} - -#ifdef wxHAS_EVENT_BIND - -namespace wxPrivate -{ - -// helper template defining nested "type" typedef as the event class -// corresponding to the given event type -template struct EventClassOf; - -// the typed events provide the information about the class of the events they -// carry themselves: -template -struct EventClassOf< wxEventTypeTag > -{ - typedef typename wxEventTypeTag::EventClass type; -}; - -// for the old untyped events we don't have information about the exact event -// class carried by them -template <> -struct EventClassOf -{ - typedef wxEvent type; -}; - - -// helper class defining operations different for method functors using an -// object of wxEvtHandler-derived class as handler and the others -template struct HandlerImpl; - -// specialization for handlers deriving from wxEvtHandler -template -struct HandlerImpl -{ - static bool IsEvtHandler() - { return true; } - static T *ConvertFromEvtHandler(wxEvtHandler *p) - { return static_cast(p); } - static wxEvtHandler *ConvertToEvtHandler(T *p) - { return p; } - static wxEventFunction ConvertToEvtMethod(void (T::*f)(A&)) - { return static_cast( - reinterpret_cast(f)); } -}; - -// specialization for handlers not deriving from wxEvtHandler -template -struct HandlerImpl -{ - static bool IsEvtHandler() - { return false; } - static T *ConvertFromEvtHandler(wxEvtHandler *) - { return NULL; } - static wxEvtHandler *ConvertToEvtHandler(T *) - { return NULL; } - static wxEventFunction ConvertToEvtMethod(void (T::*)(A&)) - { return NULL; } -}; - -} // namespace wxPrivate - -// functor forwarding the event to a method of the given object -// -// notice that the object class may be different from the class in which the -// method is defined but it must be convertible to this class -// -// also, the type of the handler parameter doesn't need to be exactly the same -// as EventTag::EventClass but it must be its base class -- this is explicitly -// allowed to handle different events in the same handler taking wxEvent&, for -// example -template - -class wxEventFunctorMethod - : public wxEventFunctor, - private wxPrivate::HandlerImpl - < - Class, - EventArg, - wxConvertibleTo::value != 0 - > -{ -private: - static void CheckHandlerArgument(EventArg *) { } - -public: - // the event class associated with the given event tag - typedef typename wxPrivate::EventClassOf::type EventClass; - - - wxEventFunctorMethod(void (Class::*method)(EventArg&), EventHandler *handler) - : m_handler( handler ), m_method( method ) - { - wxASSERT_MSG( handler || this->IsEvtHandler(), - "handlers defined in non-wxEvtHandler-derived classes " - "must be connected with a valid sink object" ); - - // if you get an error here it means that the signature of the handler - // you're trying to use is not compatible with (i.e. is not the same as - // or a base class of) the real event class used for this event type - CheckHandlerArgument(static_cast(NULL)); - } - - virtual void operator()(wxEvtHandler *handler, wxEvent& event) - { - Class * realHandler = m_handler; - if ( !realHandler ) - { - realHandler = this->ConvertFromEvtHandler(handler); - - // this is not supposed to happen but check for it nevertheless - wxCHECK_RET( realHandler, "invalid event handler" ); - } - - // the real (run-time) type of event is EventClass and we checked in - // the ctor that EventClass can be converted to EventArg, so this cast - // is always valid - (realHandler->*m_method)(static_cast(event)); - } - - virtual bool IsMatching(const wxEventFunctor& functor) const - { - if ( wxTypeId(functor) != wxTypeId(*this) ) - return false; - - typedef wxEventFunctorMethod - ThisFunctor; - - // the cast is valid because wxTypeId()s matched above - const ThisFunctor& other = static_cast(functor); - - return (m_method == other.m_method || other.m_method == NULL) && - (m_handler == other.m_handler || other.m_handler == NULL); - } - - virtual wxEvtHandler *GetEvtHandler() const - { return this->ConvertToEvtHandler(m_handler); } - - virtual wxEventFunction GetEvtMethod() const - { return this->ConvertToEvtMethod(m_method); } - -private: - EventHandler *m_handler; - void (Class::*m_method)(EventArg&); - - // Provide a dummy default ctor for type info purposes - wxEventFunctorMethod() { } - - typedef wxEventFunctorMethod thisClass; - WX_DECLARE_TYPEINFO_INLINE(thisClass) -}; - - -// functor forwarding the event to function (function, static method) -template -class wxEventFunctorFunction : public wxEventFunctor -{ -private: - static void CheckHandlerArgument(EventArg *) { } - -public: - // the event class associated with the given event tag - typedef typename wxPrivate::EventClassOf::type EventClass; - - wxEventFunctorFunction( void ( *handler )( EventArg & )) - : m_handler( handler ) - { - // if you get an error here it means that the signature of the handler - // you're trying to use is not compatible with (i.e. is not the same as - // or a base class of) the real event class used for this event type - CheckHandlerArgument(static_cast(NULL)); - } - - virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event) - { - // If you get an error here like "must use .* or ->* to call - // pointer-to-member function" then you probably tried to call - // Bind/Unbind with a method pointer but without a handler pointer or - // NULL as a handler e.g.: - // Unbind( wxEVT_XXX, &EventHandler::method ); - // or - // Unbind( wxEVT_XXX, &EventHandler::method, NULL ) - m_handler(static_cast(event)); - } - - virtual bool IsMatching(const wxEventFunctor &functor) const - { - if ( wxTypeId(functor) != wxTypeId(*this) ) - return false; - - typedef wxEventFunctorFunction ThisFunctor; - - const ThisFunctor& other = static_cast( functor ); - - return m_handler == other.m_handler; - } - -private: - void (*m_handler)(EventArg&); - - // Provide a dummy default ctor for type info purposes - wxEventFunctorFunction() { } - - typedef wxEventFunctorFunction thisClass; - WX_DECLARE_TYPEINFO_INLINE(thisClass) -}; - - -template -class wxEventFunctorFunctor : public wxEventFunctor -{ -public: - typedef typename EventTag::EventClass EventArg; - - wxEventFunctorFunctor(const Functor& handler) - : m_handler(handler), m_handlerAddr(&handler) - { } - - virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event) - { - // If you get an error here like "must use '.*' or '->*' to call - // pointer-to-member function" then you probably tried to call - // Bind/Unbind with a method pointer but without a handler pointer or - // NULL as a handler e.g.: - // Unbind( wxEVT_XXX, &EventHandler::method ); - // or - // Unbind( wxEVT_XXX, &EventHandler::method, NULL ) - m_handler(static_cast(event)); - } - - virtual bool IsMatching(const wxEventFunctor &functor) const - { - if ( wxTypeId(functor) != wxTypeId(*this) ) - return false; - - typedef wxEventFunctorFunctor FunctorThis; - - const FunctorThis& other = static_cast(functor); - - // The only reliable/portable way to compare two functors is by - // identity: - return m_handlerAddr == other.m_handlerAddr; - } - -private: - // Store a copy of the functor to prevent using/calling an already - // destroyed instance: - Functor m_handler; - - // Use the address of the original functor for comparison in IsMatching: - const void *m_handlerAddr; - - // Provide a dummy default ctor for type info purposes - wxEventFunctorFunctor() { } - - typedef wxEventFunctorFunctor thisClass; - WX_DECLARE_TYPEINFO_INLINE(thisClass) -}; - -// Create functors for the templatized events, either allocated on the heap for -// wxNewXXX() variants (this is needed in wxEvtHandler::Bind<>() to store them -// in dynamic event table) or just by returning them as temporary objects (this -// is enough for Unbind<>() and we avoid unnecessary heap allocation like this). - - -// Create functors wrapping functions: -template -inline wxEventFunctorFunction * -wxNewEventFunctor(const EventTag&, void (*func)(EventArg &)) -{ - return new wxEventFunctorFunction(func); -} - -template -inline wxEventFunctorFunction -wxMakeEventFunctor(const EventTag&, void (*func)(EventArg &)) -{ - return wxEventFunctorFunction(func); -} - -// Create functors wrapping other functors: -template -inline wxEventFunctorFunctor * -wxNewEventFunctor(const EventTag&, const Functor &func) -{ - return new wxEventFunctorFunctor(func); -} - -template -inline wxEventFunctorFunctor -wxMakeEventFunctor(const EventTag&, const Functor &func) -{ - return wxEventFunctorFunctor(func); -} - -// Create functors wrapping methods: -template - -inline wxEventFunctorMethod * -wxNewEventFunctor(const EventTag&, - void (Class::*method)(EventArg&), - EventHandler *handler) -{ - return new wxEventFunctorMethod( - method, handler); -} - -template - -inline wxEventFunctorMethod -wxMakeEventFunctor(const EventTag&, - void (Class::*method)(EventArg&), - EventHandler *handler) -{ - return wxEventFunctorMethod( - method, handler); -} - -// Create an event functor for the event table via wxDECLARE_EVENT_TABLE_ENTRY: -// in this case we don't have the handler (as it's always the same as the -// object which generated the event) so we must use Class as its type -template -inline wxEventFunctorMethod * -wxNewEventTableFunctor(const EventTag&, void (Class::*method)(EventArg&)) -{ - return new wxEventFunctorMethod( - method, NULL); -} - -#endif // wxHAS_EVENT_BIND - - -// many, but not all, standard event types - - // some generic events -extern WXDLLIMPEXP_BASE const wxEventType wxEVT_NULL; -extern WXDLLIMPEXP_BASE const wxEventType wxEVT_FIRST; -extern WXDLLIMPEXP_BASE const wxEventType wxEVT_USER_FIRST; - - // Need events declared to do this -class WXDLLIMPEXP_FWD_BASE wxIdleEvent; -class WXDLLIMPEXP_FWD_BASE wxThreadEvent; -class WXDLLIMPEXP_FWD_BASE wxAsyncMethodCallEvent; -class WXDLLIMPEXP_FWD_CORE wxCommandEvent; -class WXDLLIMPEXP_FWD_CORE wxMouseEvent; -class WXDLLIMPEXP_FWD_CORE wxFocusEvent; -class WXDLLIMPEXP_FWD_CORE wxChildFocusEvent; -class WXDLLIMPEXP_FWD_CORE wxKeyEvent; -class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; -class WXDLLIMPEXP_FWD_CORE wxSetCursorEvent; -class WXDLLIMPEXP_FWD_CORE wxScrollEvent; -class WXDLLIMPEXP_FWD_CORE wxSpinEvent; -class WXDLLIMPEXP_FWD_CORE wxScrollWinEvent; -class WXDLLIMPEXP_FWD_CORE wxSizeEvent; -class WXDLLIMPEXP_FWD_CORE wxMoveEvent; -class WXDLLIMPEXP_FWD_CORE wxCloseEvent; -class WXDLLIMPEXP_FWD_CORE wxActivateEvent; -class WXDLLIMPEXP_FWD_CORE wxWindowCreateEvent; -class WXDLLIMPEXP_FWD_CORE wxWindowDestroyEvent; -class WXDLLIMPEXP_FWD_CORE wxShowEvent; -class WXDLLIMPEXP_FWD_CORE wxIconizeEvent; -class WXDLLIMPEXP_FWD_CORE wxMaximizeEvent; -class WXDLLIMPEXP_FWD_CORE wxMouseCaptureChangedEvent; -class WXDLLIMPEXP_FWD_CORE wxMouseCaptureLostEvent; -class WXDLLIMPEXP_FWD_CORE wxPaintEvent; -class WXDLLIMPEXP_FWD_CORE wxEraseEvent; -class WXDLLIMPEXP_FWD_CORE wxNcPaintEvent; -class WXDLLIMPEXP_FWD_CORE wxMenuEvent; -class WXDLLIMPEXP_FWD_CORE wxContextMenuEvent; -class WXDLLIMPEXP_FWD_CORE wxSysColourChangedEvent; -class WXDLLIMPEXP_FWD_CORE wxDisplayChangedEvent; -class WXDLLIMPEXP_FWD_CORE wxQueryNewPaletteEvent; -class WXDLLIMPEXP_FWD_CORE wxPaletteChangedEvent; -class WXDLLIMPEXP_FWD_CORE wxJoystickEvent; -class WXDLLIMPEXP_FWD_CORE wxDropFilesEvent; -class WXDLLIMPEXP_FWD_CORE wxInitDialogEvent; -class WXDLLIMPEXP_FWD_CORE wxUpdateUIEvent; -class WXDLLIMPEXP_FWD_CORE wxClipboardTextEvent; -class WXDLLIMPEXP_FWD_CORE wxHelpEvent; - - - // Command events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_BUTTON, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHOICE, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX_DCLICK, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKLISTBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SLIDER, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBUTTON, wxCommandEvent); - -// wxEVT_SCROLLBAR is deprecated, use wxEVT_SCROLL... events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLBAR, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_VLBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_RCLICKED, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_DROPDOWN, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_ENTER, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent); - - // Thread and asynchronous method call events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_THREAD, wxThreadEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_ASYNC_METHOD_CALL, wxAsyncMethodCallEvent); - - // Mouse event types -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent); - - // Character input event type -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent); +#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES + +BEGIN_DECLARE_EVENT_TYPES() + +#if WXWIN_COMPATIBILITY_EVENT_TYPES + wxEVT_NULL = 0, + wxEVT_FIRST = 10000, + wxEVT_USER_FIRST = wxEVT_FIRST + 2000, +#else // !WXWIN_COMPATIBILITY_EVENT_TYPES + // it is important to still have these as constants to avoid + // initialization order related problems + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_NULL, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_FIRST, 10000) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_USER_FIRST, wxEVT_FIRST + 2000) +#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES + + DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED, 2) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHOICE_SELECTED, 3) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED, 4) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 5) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 6) + // now they are in wx/textctrl.h +#if WXWIN_COMPATIBILITY_EVENT_TYPES + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14) +#endif // WXWIN_COMPATIBILITY_EVENT_TYPES + DECLARE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED, 9) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED, 10) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED, 11) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBUTTON_SELECTED, 12) + + // wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use + // wxEVT_SCROLL... events + + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SCROLLBAR_UPDATED, 13) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_VLBOX_SELECTED, 14) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED, 15) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED, 16) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER, 17) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED, 18) + + // Sockets and timers send events, too + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_SOCKET, 50) + DECLARE_EVENT_TYPE(wxEVT_TIMER , 80) + + // Mouse event types + DECLARE_EVENT_TYPE(wxEVT_LEFT_DOWN, 100) + DECLARE_EVENT_TYPE(wxEVT_LEFT_UP, 101) + DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DOWN, 102) + DECLARE_EVENT_TYPE(wxEVT_MIDDLE_UP, 103) + DECLARE_EVENT_TYPE(wxEVT_RIGHT_DOWN, 104) + DECLARE_EVENT_TYPE(wxEVT_RIGHT_UP, 105) + DECLARE_EVENT_TYPE(wxEVT_MOTION, 106) + DECLARE_EVENT_TYPE(wxEVT_ENTER_WINDOW, 107) + DECLARE_EVENT_TYPE(wxEVT_LEAVE_WINDOW, 108) + DECLARE_EVENT_TYPE(wxEVT_LEFT_DCLICK, 109) + DECLARE_EVENT_TYPE(wxEVT_MIDDLE_DCLICK, 110) + DECLARE_EVENT_TYPE(wxEVT_RIGHT_DCLICK, 111) + DECLARE_EVENT_TYPE(wxEVT_SET_FOCUS, 112) + DECLARE_EVENT_TYPE(wxEVT_KILL_FOCUS, 113) + DECLARE_EVENT_TYPE(wxEVT_CHILD_FOCUS, 114) + DECLARE_EVENT_TYPE(wxEVT_MOUSEWHEEL, 115) + + // Non-client mouse events + DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN, 200) + DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_UP, 201) + DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DOWN, 202) + DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_UP, 203) + DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DOWN, 204) + DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_UP, 205) + DECLARE_EVENT_TYPE(wxEVT_NC_MOTION, 206) + DECLARE_EVENT_TYPE(wxEVT_NC_ENTER_WINDOW, 207) + DECLARE_EVENT_TYPE(wxEVT_NC_LEAVE_WINDOW, 208) + DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DCLICK, 209) + DECLARE_EVENT_TYPE(wxEVT_NC_MIDDLE_DCLICK, 210) + DECLARE_EVENT_TYPE(wxEVT_NC_RIGHT_DCLICK, 211) + + // Character input event type + DECLARE_EVENT_TYPE(wxEVT_CHAR, 212) + DECLARE_EVENT_TYPE(wxEVT_CHAR_HOOK, 213) + DECLARE_EVENT_TYPE(wxEVT_NAVIGATION_KEY, 214) + DECLARE_EVENT_TYPE(wxEVT_KEY_DOWN, 215) + DECLARE_EVENT_TYPE(wxEVT_KEY_UP, 216) #if wxUSE_HOTKEY -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent); + DECLARE_EVENT_TYPE(wxEVT_HOTKEY, 217) #endif -// This is a private event used by wxMSW code only and subject to change or -// disappear in the future. Don't use. -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AFTER_CHAR, wxKeyEvent); + // Set cursor event + DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR, 230) - // Set cursor event -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent); + // wxScrollBar and wxSlider event identifiers + DECLARE_EVENT_TYPE(wxEVT_SCROLL_TOP, 300) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_BOTTOM, 301) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEUP, 302) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_LINEDOWN, 303) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP, 304) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN, 305) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK, 306) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE, 307) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_CHANGED, 308) - // wxScrollBar and wxSlider event identifiers -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent); + // Scroll events from wxWindow + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP, 320) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM, 321) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEUP, 322) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEDOWN, 323) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEUP, 324) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEDOWN, 325) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBTRACK, 326) + DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE, 327) -// Due to a bug in older wx versions, wxSpinEvents were being sent with type of -// wxEVT_SCROLL_LINEUP, wxEVT_SCROLL_LINEDOWN and wxEVT_SCROLL_THUMBTRACK. But -// with the type-safe events in place, these event types are associated with -// wxScrollEvent. To allow handling of spin events, new event types have been -// defined in spinbutt.h/spinnbuttcmn.cpp. To maintain backward compatibility -// the spin event types are being initialized with the scroll event types. + // System events + DECLARE_EVENT_TYPE(wxEVT_SIZE, 400) + DECLARE_EVENT_TYPE(wxEVT_MOVE, 401) + DECLARE_EVENT_TYPE(wxEVT_CLOSE_WINDOW, 402) + DECLARE_EVENT_TYPE(wxEVT_END_SESSION, 403) + DECLARE_EVENT_TYPE(wxEVT_QUERY_END_SESSION, 404) + DECLARE_EVENT_TYPE(wxEVT_ACTIVATE_APP, 405) + // 406..408 are power events + DECLARE_EVENT_TYPE(wxEVT_ACTIVATE, 409) + DECLARE_EVENT_TYPE(wxEVT_CREATE, 410) + DECLARE_EVENT_TYPE(wxEVT_DESTROY, 411) + DECLARE_EVENT_TYPE(wxEVT_SHOW, 412) + DECLARE_EVENT_TYPE(wxEVT_ICONIZE, 413) + DECLARE_EVENT_TYPE(wxEVT_MAXIMIZE, 414) + DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED, 415) + DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_LOST, 416) + DECLARE_EVENT_TYPE(wxEVT_PAINT, 417) + DECLARE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND, 418) + DECLARE_EVENT_TYPE(wxEVT_NC_PAINT, 419) + DECLARE_EVENT_TYPE(wxEVT_PAINT_ICON, 420) + DECLARE_EVENT_TYPE(wxEVT_MENU_OPEN, 421) + DECLARE_EVENT_TYPE(wxEVT_MENU_CLOSE, 422) + DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 423) + DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424) + DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425) + DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426) + DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 427) + DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 428) + DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 429) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 430) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 431) + DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 432) + DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 433) + DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 434) + DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 435) + DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436) + DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437) + DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_IDLE, 439) + DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440) + DECLARE_EVENT_TYPE(wxEVT_SIZING, 441) + DECLARE_EVENT_TYPE(wxEVT_MOVING, 442) + DECLARE_EVENT_TYPE(wxEVT_HIBERNATE, 443) + // more power events follow -- see wx/power.h -#if wxUSE_SPINBTN + // Clipboard events + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY, 444) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT, 445) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE, 446) -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent ); -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent ); -wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent ); + // Generic command events + // Note: a click is a higher-level event than button down/up + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK, 500) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LEFT_DCLICK, 501) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_CLICK, 502) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_DCLICK, 503) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SET_FOCUS, 504) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_KILL_FOCUS, 505) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_ENTER, 506) -#endif + // Help events + DECLARE_EVENT_TYPE(wxEVT_HELP, 1050) + DECLARE_EVENT_TYPE(wxEVT_DETAILED_HELP, 1051) - // Scroll events from wxWindow -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent); - - // System events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent); - - // Clipboard events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_COPY, wxClipboardTextEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_CUT, wxClipboardTextEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_PASTE, wxClipboardTextEvent); - - // Generic command events - // Note: a click is a higher-level event than button down/up -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent); - - // Help events -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent); +END_DECLARE_EVENT_TYPES() // these 2 events are the same -#define wxEVT_TOOL wxEVT_MENU +#define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED // ---------------------------------------------------------------------------- // Compatibility @@ -839,16 +299,13 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent); // wx/textctrl.h in all ports [yet], so declare it here as well // // still, any new code using it should include wx/textctrl.h explicitly -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT, wxCommandEvent); - - -// ---------------------------------------------------------------------------- -// wxEvent(-derived) classes -// ---------------------------------------------------------------------------- +#if !WXWIN_COMPATIBILITY_EVENT_TYPES + extern const wxEventType WXDLLIMPEXP_CORE wxEVT_COMMAND_TEXT_UPDATED; +#endif // the predefined constants for the number of times we propagate event // upwards window child-parent chain -enum wxEventPropagation +enum Propagation_state { // don't propagate it at all wxEVENT_PROPAGATE_NONE = 0, @@ -857,59 +314,6 @@ enum wxEventPropagation wxEVENT_PROPAGATE_MAX = INT_MAX }; -// The different categories for a wxEvent; see wxEvent::GetEventCategory. -// NOTE: they are used as OR-combinable flags by wxEventLoopBase::YieldFor -enum wxEventCategory -{ - // this is the category for those events which are generated to update - // the appearance of the GUI but which (usually) do not comport data - // processing, i.e. which do not provide input or output data - // (e.g. size events, scroll events, etc). - // They are events NOT directly generated by the user's input devices. - wxEVT_CATEGORY_UI = 1, - - // this category groups those events which are generated directly from the - // user through input devices like mouse and keyboard and usually result in - // data to be processed from the application. - // (e.g. mouse clicks, key presses, etc) - wxEVT_CATEGORY_USER_INPUT = 2, - - // this category is for wxSocketEvent - wxEVT_CATEGORY_SOCKET = 4, - - // this category is for wxTimerEvent - wxEVT_CATEGORY_TIMER = 8, - - // this category is for any event used to send notifications from the - // secondary threads to the main one or in general for notifications among - // different threads (which may or may not be user-generated) - wxEVT_CATEGORY_THREAD = 16, - - - // implementation only - - // used in the implementations of wxEventLoopBase::YieldFor - wxEVT_CATEGORY_UNKNOWN = 32, - - // a special category used as an argument to wxEventLoopBase::YieldFor to indicate that - // Yield() should leave all wxEvents on the queue while emptying the native event queue - // (native events will be processed but the wxEvents they generate will be queued) - wxEVT_CATEGORY_CLIPBOARD = 64, - - - // shortcut masks - - // this category groups those events which are emitted in response to - // events of the native toolkit and which typically are not-"delayable". - wxEVT_CATEGORY_NATIVE_EVENTS = wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT, - - // used in wxEventLoopBase::YieldFor to specify all event categories should be processed: - wxEVT_CATEGORY_ALL = - wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \ - wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD|wxEVT_CATEGORY_UNKNOWN| \ - wxEVT_CATEGORY_CLIPBOARD -}; - /* * wxWidgets events, covering all interesting things that might happen * (button clicking, resizing, setting text in widgets, etc.). @@ -924,25 +328,24 @@ enum wxEventCategory class WXDLLIMPEXP_BASE wxEvent : public wxObject { +private: + wxEvent& operator=(const wxEvent&); + +protected: + wxEvent(const wxEvent&); // for implementing Clone() + public: wxEvent(int winid = 0, wxEventType commandType = wxEVT_NULL ); void SetEventType(wxEventType typ) { m_eventType = typ; } wxEventType GetEventType() const { return m_eventType; } - wxObject *GetEventObject() const { return m_eventObject; } void SetEventObject(wxObject *obj) { m_eventObject = obj; } - long GetTimestamp() const { return m_timeStamp; } void SetTimestamp(long ts = 0) { m_timeStamp = ts; } - int GetId() const { return m_id; } void SetId(int Id) { m_id = Id; } - // Returns the user data optionally associated with the event handler when - // using Connect() or Bind(). - wxObject *GetEventUserData() const { return m_callbackUserData; } - // Can instruct event processor that we wish to ignore this event // (treat as if the event table entry had not been found): this must be done // to allow the event processing by the base classes (calling event.Skip() @@ -950,17 +353,11 @@ public: void Skip(bool skip = true) { m_skipped = skip; } bool GetSkipped() const { return m_skipped; } - // This function is used to create a copy of the event polymorphically and + // this function is used to create a copy of the event polymorphically and // all derived classes must implement it because otherwise wxPostEvent() // for them wouldn't work (it needs to do a copy of the event) virtual wxEvent *Clone() const = 0; - // this function is used to selectively process events in wxEventLoopBase::YieldFor - // NOTE: by default it returns wxEVT_CATEGORY_UI just because the major - // part of wxWidgets events belong to that category. - virtual wxEventCategory GetEventCategory() const - { return wxEVT_CATEGORY_UI; } - // Implementation only: this test is explicitly anti OO and this function // exists only for optimization purposes. bool IsCommandEvent() const { return m_isCommandEvent; } @@ -985,61 +382,11 @@ public: m_propagationLevel = propagationLevel; } - // This method is for internal use only and allows to get the object that - // is propagating this event upwards the window hierarchy, if any. - wxEvtHandler* GetPropagatedFrom() const { return m_propagatedFrom; } - - // This is for internal use only and is only called by - // wxEvtHandler::ProcessEvent() to check whether it's the first time this - // event is being processed - bool WasProcessed() - { - if ( m_wasProcessed ) - return true; - - m_wasProcessed = true; - - return false; - } - - // This is for internal use only and is used for setting, testing and - // resetting of m_willBeProcessedAgain flag. - void SetWillBeProcessedAgain() - { - m_willBeProcessedAgain = true; - } - - bool WillBeProcessedAgain() - { - if ( m_willBeProcessedAgain ) - { - m_willBeProcessedAgain = false; - return true; - } - - return false; - } - - // This is also used only internally by ProcessEvent() to check if it - // should process the event normally or only restrict the search for the - // event handler to this object itself. - bool ShouldProcessOnlyIn(wxEvtHandler *h) const - { - return h == m_handlerToProcessOnlyIn; - } - - // Called to indicate that the result of ShouldProcessOnlyIn() wasn't taken - // into account. The existence of this function may seem counterintuitive - // but unfortunately it's needed by wxScrollHelperEvtHandler, see comments - // there. Don't even think of using this in your own code, this is a gross - // hack and is only needed because of wx complicated history and should - // never be used anywhere else. - void DidntHonourProcessOnlyIn() - { - m_handlerToProcessOnlyIn = NULL; - } - +#if WXWIN_COMPATIBILITY_2_4 +public: +#else protected: +#endif wxObject* m_eventObject; wxEventType m_eventType; long m_timeStamp; @@ -1049,45 +396,26 @@ public: // m_callbackUserData is for internal usage only wxObject* m_callbackUserData; -private: - // If this handler - wxEvtHandler *m_handlerToProcessOnlyIn; - protected: // the propagation level: while it is positive, we propagate the event to // the parent window (if any) + // + // this one doesn't have to be public, we don't have to worry about + // backwards compatibility as it is new int m_propagationLevel; - // The object that the event is being propagated from, initially NULL and - // only set by wxPropagateOnce. - wxEvtHandler* m_propagatedFrom; - +#if WXWIN_COMPATIBILITY_2_4 +public: +#else +protected: +#endif bool m_skipped; bool m_isCommandEvent; - // initially false but becomes true as soon as WasProcessed() is called for - // the first time, as this is done only by ProcessEvent() it explains the - // variable name: it becomes true after ProcessEvent() was called at least - // once for this event - bool m_wasProcessed; - - // This one is initially false too, but can be set to true to indicate that - // the event will be passed to another handler if it's not processed in - // this one. - bool m_willBeProcessedAgain; - -protected: - wxEvent(const wxEvent&); // for implementing Clone() - wxEvent& operator=(const wxEvent&); // for derived classes operator=() - private: - // It needs to access our m_propagationLevel and m_propagatedFrom fields. + // it needs to access our m_propagationLevel friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce; - // and this one needs to access our m_handlerToProcessOnlyIn - friend class WXDLLIMPEXP_FWD_BASE wxEventProcessInHandlerOnly; - - DECLARE_ABSTRACT_CLASS(wxEvent) }; @@ -1111,439 +439,92 @@ private: wxEvent& m_event; int m_propagationLevelOld; - wxDECLARE_NO_COPY_CLASS(wxPropagationDisabler); + DECLARE_NO_COPY_CLASS(wxPropagationDisabler) }; /* - * Helper used to indicate that an event is propagated upwards the window - * hierarchy by the given window. + * Another one to temporarily lower propagation level. */ class WXDLLIMPEXP_BASE wxPropagateOnce { public: - // The handler argument should normally be non-NULL to allow the parent - // event handler to know that it's being used to process an event coming - // from the child, it's only NULL by default for backwards compatibility. - wxPropagateOnce(wxEvent& event, wxEvtHandler* handler = NULL) - : m_event(event), - m_propagatedFromOld(event.m_propagatedFrom) + wxPropagateOnce(wxEvent& event) : m_event(event) { wxASSERT_MSG( m_event.m_propagationLevel > 0, wxT("shouldn't be used unless ShouldPropagate()!") ); m_event.m_propagationLevel--; - m_event.m_propagatedFrom = handler; } ~wxPropagateOnce() { - m_event.m_propagatedFrom = m_propagatedFromOld; m_event.m_propagationLevel++; } private: wxEvent& m_event; - wxEvtHandler* const m_propagatedFromOld; - wxDECLARE_NO_COPY_CLASS(wxPropagateOnce); + DECLARE_NO_COPY_CLASS(wxPropagateOnce) }; -// A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn() -// return true for the handler passed to its ctor. -class wxEventProcessInHandlerOnly -{ -public: - wxEventProcessInHandlerOnly(wxEvent& event, wxEvtHandler *handler) - : m_event(event), - m_handlerToProcessOnlyInOld(event.m_handlerToProcessOnlyIn) - { - m_event.m_handlerToProcessOnlyIn = handler; - } - - ~wxEventProcessInHandlerOnly() - { - m_event.m_handlerToProcessOnlyIn = m_handlerToProcessOnlyInOld; - } - -private: - wxEvent& m_event; - wxEvtHandler * const m_handlerToProcessOnlyInOld; - - wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly); -}; - - -class WXDLLIMPEXP_BASE wxEventBasicPayloadMixin -{ -public: - wxEventBasicPayloadMixin() - : m_commandInt(0), - m_extraLong(0) - { - } - - void SetString(const wxString& s) { m_cmdString = s; } - const wxString& GetString() const { return m_cmdString; } - - void SetInt(int i) { m_commandInt = i; } - int GetInt() const { return m_commandInt; } - - void SetExtraLong(long extraLong) { m_extraLong = extraLong; } - long GetExtraLong() const { return m_extraLong; } - -protected: - // Note: these variables have "cmd" or "command" in their name for backward compatibility: - // they used to be part of wxCommandEvent, not this mixin. - wxString m_cmdString; // String event argument - int m_commandInt; - long m_extraLong; // Additional information (e.g. select/deselect) - - wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin); -}; - -class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin : public wxEventBasicPayloadMixin -{ -public: - wxEventAnyPayloadMixin() : wxEventBasicPayloadMixin() {} - -#if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) - template - void SetPayload(const T& payload) - { - m_payload = payload; - } - - template - T GetPayload() const - { - return m_payload.As(); - } - -protected: - wxAny m_payload; -#endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) - - wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin); -}; - - -// Idle event -/* - wxEVT_IDLE - */ - -// Whether to always send idle events to windows, or -// to only send update events to those with the -// wxWS_EX_PROCESS_IDLE style. - -enum wxIdleMode -{ - // Send idle events to all windows - wxIDLE_PROCESS_ALL, - - // Send idle events to windows that have - // the wxWS_EX_PROCESS_IDLE flag specified - wxIDLE_PROCESS_SPECIFIED -}; - -class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent -{ -public: - wxIdleEvent() - : wxEvent(0, wxEVT_IDLE), - m_requestMore(false) - { } - wxIdleEvent(const wxIdleEvent& event) - : wxEvent(event), - m_requestMore(event.m_requestMore) - { } - - void RequestMore(bool needMore = true) { m_requestMore = needMore; } - bool MoreRequested() const { return m_requestMore; } - - virtual wxEvent *Clone() const { return new wxIdleEvent(*this); } - - // Specify how wxWidgets will send idle events: to - // all windows, or only to those which specify that they - // will process the events. - static void SetMode(wxIdleMode mode) { sm_idleMode = mode; } - - // Returns the idle event mode - static wxIdleMode GetMode() { return sm_idleMode; } - -protected: - bool m_requestMore; - static wxIdleMode sm_idleMode; - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent) -}; - - -// Thread event - -class WXDLLIMPEXP_BASE wxThreadEvent : public wxEvent, - public wxEventAnyPayloadMixin -{ -public: - wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY) - : wxEvent(id, eventType) - { } - - wxThreadEvent(const wxThreadEvent& event) - : wxEvent(event), - wxEventAnyPayloadMixin(event) - { - // make sure our string member (which uses COW, aka refcounting) is not - // shared by other wxString instances: - SetString(GetString().Clone()); - } - - virtual wxEvent *Clone() const - { - return new wxThreadEvent(*this); - } - - // this is important to avoid that calling wxEventLoopBase::YieldFor thread events - // gets processed when this is unwanted: - virtual wxEventCategory GetEventCategory() const - { return wxEVT_CATEGORY_THREAD; } - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThreadEvent) -}; - - -// Asynchronous method call events: these event are processed by wxEvtHandler -// itself and result in a call to its Execute() method which simply calls the -// specified method. The difference with a simple method call is that this is -// done asynchronously, i.e. at some later time, instead of immediately when -// the event object is constructed. - -#ifdef wxHAS_CALL_AFTER - -// This is a base class used to process all method calls. -class wxAsyncMethodCallEvent : public wxEvent -{ -public: - wxAsyncMethodCallEvent(wxObject* object) - : wxEvent(wxID_ANY, wxEVT_ASYNC_METHOD_CALL) - { - SetEventObject(object); - } - - wxAsyncMethodCallEvent(const wxAsyncMethodCallEvent& other) - : wxEvent(other) - { - } - - virtual void Execute() = 0; -}; - -// This is a version for calling methods without parameters. -template -class wxAsyncMethodCallEvent0 : public wxAsyncMethodCallEvent -{ -public: - typedef T ObjectType; - typedef void (ObjectType::*MethodType)(); - - wxAsyncMethodCallEvent0(ObjectType* object, - MethodType method) - : wxAsyncMethodCallEvent(object), - m_object(object), - m_method(method) - { - } - - wxAsyncMethodCallEvent0(const wxAsyncMethodCallEvent0& other) - : wxAsyncMethodCallEvent(other), - m_object(other.m_object), - m_method(other.m_method) - { - } - - virtual wxEvent *Clone() const - { - return new wxAsyncMethodCallEvent0(*this); - } - - virtual void Execute() - { - (m_object->*m_method)(); - } - -private: - ObjectType* const m_object; - const MethodType m_method; -}; - -// This is a version for calling methods with a single parameter. -template -class wxAsyncMethodCallEvent1 : public wxAsyncMethodCallEvent -{ -public: - typedef T ObjectType; - typedef void (ObjectType::*MethodType)(T1 x1); - typedef typename wxRemoveRef::type ParamType1; - - wxAsyncMethodCallEvent1(ObjectType* object, - MethodType method, - const ParamType1& x1) - : wxAsyncMethodCallEvent(object), - m_object(object), - m_method(method), - m_param1(x1) - { - } - - wxAsyncMethodCallEvent1(const wxAsyncMethodCallEvent1& other) - : wxAsyncMethodCallEvent(other), - m_object(other.m_object), - m_method(other.m_method), - m_param1(other.m_param1) - { - } - - virtual wxEvent *Clone() const - { - return new wxAsyncMethodCallEvent1(*this); - } - - virtual void Execute() - { - (m_object->*m_method)(m_param1); - } - -private: - ObjectType* const m_object; - const MethodType m_method; - const ParamType1 m_param1; -}; - -// This is a version for calling methods with two parameters. -template -class wxAsyncMethodCallEvent2 : public wxAsyncMethodCallEvent -{ -public: - typedef T ObjectType; - typedef void (ObjectType::*MethodType)(T1 x1, T2 x2); - typedef typename wxRemoveRef::type ParamType1; - typedef typename wxRemoveRef::type ParamType2; - - wxAsyncMethodCallEvent2(ObjectType* object, - MethodType method, - const ParamType1& x1, - const ParamType2& x2) - : wxAsyncMethodCallEvent(object), - m_object(object), - m_method(method), - m_param1(x1), - m_param2(x2) - { - } - - wxAsyncMethodCallEvent2(const wxAsyncMethodCallEvent2& other) - : wxAsyncMethodCallEvent(other), - m_object(other.m_object), - m_method(other.m_method), - m_param1(other.m_param1), - m_param2(other.m_param2) - { - } - - virtual wxEvent *Clone() const - { - return new wxAsyncMethodCallEvent2(*this); - } - - virtual void Execute() - { - (m_object->*m_method)(m_param1, m_param2); - } - -private: - ObjectType* const m_object; - const MethodType m_method; - const ParamType1 m_param1; - const ParamType2 m_param2; -}; - -// This is a version for calling any functors -template -class wxAsyncMethodCallEventFunctor : public wxAsyncMethodCallEvent -{ -public: - typedef T FunctorType; - - wxAsyncMethodCallEventFunctor(wxObject *object, const FunctorType& fn) - : wxAsyncMethodCallEvent(object), - m_fn(fn) - { - } - - wxAsyncMethodCallEventFunctor(const wxAsyncMethodCallEventFunctor& other) - : wxAsyncMethodCallEvent(other), - m_fn(other.m_fn) - { - } - - virtual wxEvent *Clone() const - { - return new wxAsyncMethodCallEventFunctor(*this); - } - - virtual void Execute() - { - m_fn(); - } - -private: - FunctorType m_fn; -}; - -#endif // wxHAS_CALL_AFTER - - #if wxUSE_GUI // Item or menu event class /* - wxEVT_BUTTON - wxEVT_CHECKBOX - wxEVT_CHOICE - wxEVT_LISTBOX - wxEVT_LISTBOX_DCLICK - wxEVT_TEXT - wxEVT_TEXT_ENTER - wxEVT_MENU - wxEVT_SLIDER - wxEVT_RADIOBOX - wxEVT_RADIOBUTTON - wxEVT_SCROLLBAR - wxEVT_VLBOX - wxEVT_COMBOBOX - wxEVT_TOGGLEBUTTON + wxEVT_COMMAND_BUTTON_CLICKED + wxEVT_COMMAND_CHECKBOX_CLICKED + wxEVT_COMMAND_CHOICE_SELECTED + wxEVT_COMMAND_LISTBOX_SELECTED + wxEVT_COMMAND_LISTBOX_DOUBLECLICKED + wxEVT_COMMAND_TEXT_UPDATED + wxEVT_COMMAND_TEXT_ENTER + wxEVT_COMMAND_MENU_SELECTED + wxEVT_COMMAND_SLIDER_UPDATED + wxEVT_COMMAND_RADIOBOX_SELECTED + wxEVT_COMMAND_RADIOBUTTON_SELECTED + wxEVT_COMMAND_SCROLLBAR_UPDATED + wxEVT_COMMAND_VLBOX_SELECTED + wxEVT_COMMAND_COMBOBOX_SELECTED + wxEVT_COMMAND_TOGGLEBUTTON_CLICKED */ -class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent, - public wxEventBasicPayloadMixin +#if WXWIN_COMPATIBILITY_2_4 +// Backwards compatibility for wxCommandEvent::m_commandString, will lead to compilation errors in some cases of usage +class WXDLLIMPEXP_CORE wxCommandEvent; + +class WXDLLIMPEXP_CORE wxCommandEventStringHelper +{ +public: + wxCommandEventStringHelper(wxCommandEvent * evt) + : m_evt(evt) + { } + + void operator=(const wxString &str); + operator wxString(); + const wxChar* c_str() const; + +private: + wxCommandEvent* m_evt; +}; +#endif + +class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent { public: wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); wxCommandEvent(const wxCommandEvent& event) : wxEvent(event), - wxEventBasicPayloadMixin(event), +#if WXWIN_COMPATIBILITY_2_4 + m_commandString(this), +#endif + m_cmdString(event.m_cmdString), + m_commandInt(event.m_commandInt), + m_extraLong(event.m_extraLong), m_clientData(event.m_clientData), m_clientObject(event.m_clientObject) - { - // Because GetString() can retrieve the string text only on demand, we - // need to copy it explicitly. - if ( m_cmdString.empty() ) - m_cmdString = event.GetString(); - } + { } // Set/Get client data from controls void SetClientData(void* clientData) { m_clientData = clientData; } @@ -1553,23 +534,36 @@ public: void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } wxClientData *GetClientObject() const { return m_clientObject; } - // Note: this shadows wxEventBasicPayloadMixin::GetString(), because it does some - // GUI-specific hacks - wxString GetString() const; - // Get listbox selection if single-choice int GetSelection() const { return m_commandInt; } + // Set/Get listbox/choice selection string + void SetString(const wxString& s) { m_cmdString = s; } + wxString GetString() const; + // Get checkbox value bool IsChecked() const { return m_commandInt != 0; } // true if the listbox event was a selection. bool IsSelection() const { return (m_extraLong != 0); } - virtual wxEvent *Clone() const { return new wxCommandEvent(*this); } - virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } + void SetExtraLong(long extraLong) { m_extraLong = extraLong; } + long GetExtraLong() const { return m_extraLong; } + void SetInt(int i) { m_commandInt = i; } + int GetInt() const { return m_commandInt; } + + virtual wxEvent *Clone() const { return new wxCommandEvent(*this); } + +#if WXWIN_COMPATIBILITY_2_4 +public: + wxCommandEventStringHelper m_commandString; +#else protected: +#endif + wxString m_cmdString; // String event argument + int m_commandInt; + long m_extraLong; // Additional information (e.g. select/deselect) void* m_clientData; // Arbitrary client data wxClientData* m_clientObject; // Arbitrary client object @@ -1577,6 +571,23 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) }; +#if WXWIN_COMPATIBILITY_2_4 +inline void wxCommandEventStringHelper::operator=(const wxString &str) +{ + m_evt->SetString(str); +} + +inline wxCommandEventStringHelper::operator wxString() +{ + return m_evt->GetString(); +} + +inline const wxChar* wxCommandEventStringHelper::c_str() const +{ + return m_evt->GetString().c_str(); +} +#endif + // this class adds a possibility to react (from the user) code to a control // notification: allow or veto the operation being reported. class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent @@ -1608,7 +619,6 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent) }; - // Scroll event class, derived form wxCommandEvent. wxScrollEvents are // sent by wxSlider and wxScrollBar. /* @@ -1658,7 +668,7 @@ class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent public: wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, int pos = 0, int orient = 0); - wxScrollWinEvent(const wxScrollWinEvent& event) : wxEvent(event) + wxScrollWinEvent(const wxScrollWinEvent & event) : wxEvent(event) { m_commandInt = event.m_commandInt; m_extraLong = event.m_extraLong; } @@ -1669,7 +679,11 @@ public: virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); } +#if WXWIN_COMPATIBILITY_2_4 +public: +#else protected: +#endif int m_commandInt; long m_extraLong; @@ -1677,8 +691,6 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent) }; - - // Mouse event class /* @@ -1694,25 +706,36 @@ private: wxEVT_LEFT_DCLICK wxEVT_MIDDLE_DCLICK wxEVT_RIGHT_DCLICK + wxEVT_NC_LEFT_DOWN + wxEVT_NC_LEFT_UP, + wxEVT_NC_MIDDLE_DOWN, + wxEVT_NC_MIDDLE_UP, + wxEVT_NC_RIGHT_DOWN, + wxEVT_NC_RIGHT_UP, + wxEVT_NC_MOTION, + wxEVT_NC_ENTER_WINDOW, + wxEVT_NC_LEAVE_WINDOW, + wxEVT_NC_LEFT_DCLICK, + wxEVT_NC_MIDDLE_DCLICK, + wxEVT_NC_RIGHT_DCLICK, */ -enum wxMouseWheelAxis +// the symbolic names for the mouse buttons +enum { - wxMOUSE_WHEEL_VERTICAL, - wxMOUSE_WHEEL_HORIZONTAL + wxMOUSE_BTN_ANY = -1, + wxMOUSE_BTN_NONE = 0, + wxMOUSE_BTN_LEFT = 1, + wxMOUSE_BTN_MIDDLE = 2, + wxMOUSE_BTN_RIGHT = 3 }; -class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent, - public wxMouseState +class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent { public: wxMouseEvent(wxEventType mouseType = wxEVT_NULL); - wxMouseEvent(const wxMouseEvent& event) - : wxEvent(event), - wxMouseState(event) - { - Assign(event); - } + wxMouseEvent(const wxMouseEvent& event) : wxEvent(event) + { Assign(event); } // Was it a button event? (*doesn't* mean: is any button *down*?) bool IsButton() const { return Button(wxMOUSE_BTN_ANY); } @@ -1726,30 +749,47 @@ public: // Was it a up event from this (or any) button? bool ButtonUp(int but = wxMOUSE_BTN_ANY) const; - // Was this event generated by the given button? + // Was the given button? bool Button(int but) const; + // Was the given button in Down state? + bool ButtonIsDown(int but) const; + // Get the button which is changing state (wxMOUSE_BTN_NONE if none) int GetButton() const; + // Find state of shift/control keys + bool ControlDown() const { return m_controlDown; } + bool MetaDown() const { return m_metaDown; } + bool AltDown() const { return m_altDown; } + bool ShiftDown() const { return m_shiftDown; } + bool CmdDown() const + { +#if defined(__WXMAC__) || defined(__WXCOCOA__) + return MetaDown(); +#else + return ControlDown(); +#endif + } + // Find which event was just generated bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); } bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); } bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); } - bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); } - bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); } bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); } bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); } bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); } - bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); } - bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); } bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); } bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); } bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); } - bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); } - bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); } + + // Find the current state of the mouse buttons (regardless + // of current event type) + bool LeftIsDown() const { return m_leftDown; } + bool MiddleIsDown() const { return m_middleDown; } + bool RightIsDown() const { return m_rightDown; } // True if a button is down and the mouse is moving bool Dragging() const @@ -1769,12 +809,35 @@ public: // True if the mouse is just leaving the window bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); } - // Returns the number of mouse clicks associated with this event. - int GetClickCount() const { return m_clickCount; } + // Find the position of the event + void GetPosition(wxCoord *xpos, wxCoord *ypos) const + { + if (xpos) + *xpos = m_x; + if (ypos) + *ypos = m_y; + } + + void GetPosition(long *xpos, long *ypos) const + { + if (xpos) + *xpos = (long)m_x; + if (ypos) + *ypos = (long)m_y; + } + + // Find the position of the event + wxPoint GetPosition() const { return wxPoint(m_x, m_y); } // Find the logical position of the event given the DC wxPoint GetLogicalPosition(const wxDC& dc) const; + // Get X position + wxCoord GetX() const { return m_x; } + + // Get Y position + wxCoord GetY() const { return m_y; } + // Get wheel rotation, positive or negative indicates direction of // rotation. Current devices all send an event when rotation is equal to // +/-WheelDelta, but this allows for finer resolution devices to be @@ -1789,40 +852,32 @@ public: // should occur for each delta. int GetWheelDelta() const { return m_wheelDelta; } - // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL - // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling - // using e.g. a trackpad). - wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; } - // Returns the configured number of lines (or whatever) to be scrolled per - // wheel action. Defaults to three. + // wheel action. Defaults to one. int GetLinesPerAction() const { return m_linesPerAction; } - // Returns the configured number of columns (or whatever) to be scrolled per - // wheel action. Defaults to three. - int GetColumnsPerAction() const { return m_columnsPerAction; } - // Is the system set to do page scrolling? bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); } virtual wxEvent *Clone() const { return new wxMouseEvent(*this); } - virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } - wxMouseEvent& operator=(const wxMouseEvent& event) - { - if (&event != this) - Assign(event); - return *this; - } + wxMouseEvent& operator=(const wxMouseEvent& event) { Assign(event); return *this; } public: - int m_clickCount; + wxCoord m_x, m_y; + + bool m_leftDown; + bool m_middleDown; + bool m_rightDown; + + bool m_controlDown; + bool m_shiftDown; + bool m_altDown; + bool m_metaDown; - wxMouseWheelAxis m_wheelAxis; int m_wheelRotation; int m_wheelDelta; int m_linesPerAction; - int m_columnsPerAction; protected: void Assign(const wxMouseEvent& evt); @@ -1845,7 +900,7 @@ public: m_x(x), m_y(y), m_cursor() { } - wxSetCursorEvent(const wxSetCursorEvent& event) + wxSetCursorEvent(const wxSetCursorEvent & event) : wxEvent(event), m_x(event.m_x), m_y(event.m_y), @@ -1857,7 +912,7 @@ public: void SetCursor(const wxCursor& cursor) { m_cursor = cursor; } const wxCursor& GetCursor() const { return m_cursor; } - bool HasCursor() const { return m_cursor.IsOk(); } + bool HasCursor() const { return m_cursor.Ok(); } virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); } @@ -1879,51 +934,51 @@ private: wxEVT_HOTKEY */ -// key categories: the bit flags for IsKeyInCategory() function -// -// the enum values used may change in future version of wx -// use the named constants only, or bitwise combinations thereof -enum wxKeyCategoryFlags -{ - // arrow keys, on and off numeric keypads - WXK_CATEGORY_ARROW = 1, - - // page up and page down keys, on and off numeric keypads - WXK_CATEGORY_PAGING = 2, - - // home and end keys, on and off numeric keypads - WXK_CATEGORY_JUMP = 4, - - // tab key, on and off numeric keypads - WXK_CATEGORY_TAB = 8, - - // backspace and delete keys, on and off numeric keypads - WXK_CATEGORY_CUT = 16, - - // all keys usually used for navigation - WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW | - WXK_CATEGORY_PAGING | - WXK_CATEGORY_JUMP -}; - -class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent, - public wxKeyboardState +class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent { public: wxKeyEvent(wxEventType keyType = wxEVT_NULL); - - // Normal copy ctor and a ctor creating a new event for the same key as the - // given one but a different event type (this is used in implementation - // code only, do not use outside of the library). wxKeyEvent(const wxKeyEvent& evt); - wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt); + + // can be used check if the key event has exactly the given modifiers: + // "GetModifiers() = wxMOD_CONTROL" is easier to write than "ControlDown() + // && !MetaDown() && !AltDown() && !ShiftDown()" + int GetModifiers() const + { + return (m_controlDown ? wxMOD_CONTROL : 0) | + (m_shiftDown ? wxMOD_SHIFT : 0) | + (m_metaDown ? wxMOD_META : 0) | + (m_altDown ? wxMOD_ALT : 0); + } + + // Find state of shift/control keys + bool ControlDown() const { return m_controlDown; } + bool ShiftDown() const { return m_shiftDown; } + bool MetaDown() const { return m_metaDown; } + bool AltDown() const { return m_altDown; } + + // "Cmd" is a pseudo key which is Control for PC and Unix platforms but + // Apple ("Command") key under Macs: it makes often sense to use it instead + // of, say, ControlDown() because Cmd key is used for the same thing under + // Mac as Ctrl elsewhere (but Ctrl still exists, just not used for this + // purpose under Mac) + bool CmdDown() const + { +#if defined(__WXMAC__) || defined(__WXCOCOA__) + return MetaDown(); +#else + return ControlDown(); +#endif + } + + // exclude MetaDown() from HasModifiers() because NumLock under X is often + // configured as mod2 modifier, yet the key events even when it is pressed + // should be processed normally, not like Ctrl- or Alt-key + bool HasModifiers() const { return ControlDown() || AltDown(); } // get the key code: an ASCII7 char or an element of wxKeyCode enum int GetKeyCode() const { return (int)m_keyCode; } - // returns true iff this event's key code is of a certain type - bool IsKeyInCategory(int category) const; - #if wxUSE_UNICODE // get the Unicode character corresponding to this key wxChar GetUnicodeKey() const { return m_uniChar; } @@ -1938,66 +993,69 @@ public: // Find the position of the event void GetPosition(wxCoord *xpos, wxCoord *ypos) const { - if (xpos) - *xpos = GetX(); - if (ypos) - *ypos = GetY(); + if (xpos) *xpos = m_x; + if (ypos) *ypos = m_y; } - // This version if provided only for backwards compatiblity, don't use. void GetPosition(long *xpos, long *ypos) const { - if (xpos) - *xpos = GetX(); - if (ypos) - *ypos = GetY(); + if (xpos) *xpos = (long)m_x; + if (ypos) *ypos = (long)m_y; } wxPoint GetPosition() const - { return wxPoint(GetX(), GetY()); } + { return wxPoint(m_x, m_y); } // Get X position - wxCoord GetX() const; + wxCoord GetX() const { return m_x; } // Get Y position - wxCoord GetY() const; - - // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal - // key events even though the event had been handled (by default they would - // not be generated in this case). - void DoAllowNextEvent() { m_allowNext = true; } - - // Return the value of the "allow next" flag, for internal use only. - bool IsNextEventAllowed() const { return m_allowNext; } + wxCoord GetY() const { return m_y; } +#if WXWIN_COMPATIBILITY_2_6 + // deprecated, Use GetKeyCode instead. + wxDEPRECATED( long KeyCode() const ); +#endif // WXWIN_COMPATIBILITY_2_6 virtual wxEvent *Clone() const { return new wxKeyEvent(*this); } - virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; } // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for // example) wxKeyEvent& operator=(const wxKeyEvent& evt) { - if ( &evt != this ) - { - wxEvent::operator=(evt); + m_x = evt.m_x; + m_y = evt.m_y; - // Borland C++ 5.82 doesn't compile an explicit call to an - // implicitly defined operator=() so need to do it this way: - *static_cast(this) = evt; + m_keyCode = evt.m_keyCode; + + m_controlDown = evt.m_controlDown; + m_shiftDown = evt.m_shiftDown; + m_altDown = evt.m_altDown; + m_metaDown = evt.m_metaDown; + m_scanCode = evt.m_scanCode; + m_rawCode = evt.m_rawCode; + m_rawFlags = evt.m_rawFlags; +#if wxUSE_UNICODE + m_uniChar = evt.m_uniChar; +#endif - DoAssignMembers(evt); - } return *this; } public: - // Do not use these fields directly, they are initialized on demand, so - // call GetX() and GetY() or GetPosition() instead. wxCoord m_x, m_y; long m_keyCode; + // TODO: replace those with a single m_modifiers bitmask of wxMOD_XXX? + bool m_controlDown; + bool m_shiftDown; + bool m_altDown; + bool m_metaDown; + + // FIXME: what is this for? relation to m_rawXXX? + bool m_scanCode; + #if wxUSE_UNICODE // This contains the full Unicode character // in a character events in Unicode mode @@ -2010,46 +1068,6 @@ public: wxUint32 m_rawFlags; private: - // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK - // type. This is used by all ctors. - void InitPropagation() - { - if ( m_eventType == wxEVT_CHAR_HOOK ) - m_propagationLevel = wxEVENT_PROPAGATE_MAX; - - m_allowNext = false; - } - - // Copy only the event data present in this class, this is used by - // AssignKeyData() and copy ctor. - void DoAssignMembers(const wxKeyEvent& evt) - { - m_x = evt.m_x; - m_y = evt.m_y; - m_hasPosition = evt.m_hasPosition; - - m_keyCode = evt.m_keyCode; - - m_rawCode = evt.m_rawCode; - m_rawFlags = evt.m_rawFlags; -#if wxUSE_UNICODE - m_uniChar = evt.m_uniChar; -#endif - } - - // Initialize m_x and m_y using the current mouse cursor position if - // necessary. - void InitPositionIfNecessary() const; - - // If this flag is true, the normal key events should still be generated - // even if wxEVT_CHAR_HOOK had been handled. By default it is false as - // handling wxEVT_CHAR_HOOK suppresses all the subsequent events. - bool m_allowNext; - - // If true, m_x and m_y were already initialized. If false, try to get them - // when they're requested. - bool m_hasPosition; - DECLARE_DYNAMIC_CLASS(wxKeyEvent) }; @@ -2067,7 +1085,7 @@ public: : wxEvent(winid, wxEVT_SIZE), m_size(sz) { } - wxSizeEvent(const wxSizeEvent& event) + wxSizeEvent(const wxSizeEvent & event) : wxEvent(event), m_size(event.m_size), m_rect(event.m_rect) { } @@ -2076,7 +1094,6 @@ public: { m_eventType = wxEVT_SIZING; m_id = id; } wxSize GetSize() const { return m_size; } - void SetSize(wxSize size) { m_size = size; } wxRect GetRect() const { return m_rect; } void SetRect(const wxRect& rect) { m_rect = rect; } @@ -2122,7 +1139,11 @@ public: virtual wxEvent *Clone() const { return new wxMoveEvent(*this); } +#if WXWIN_COMPATIBILITY_2_4 +public: +#else protected: +#endif wxPoint m_pos; wxRect m_rect; @@ -2134,11 +1155,10 @@ private: /* wxEVT_PAINT wxEVT_NC_PAINT + wxEVT_PAINT_ICON */ -#if wxDEBUG_LEVEL && (defined(__WXMSW__) || defined(__WXPM__)) - #define wxHAS_PAINT_DEBUG - +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined extern WXDLLIMPEXP_CORE int g_isPainting; #endif // debug @@ -2149,15 +1169,15 @@ public: wxPaintEvent(int Id = 0) : wxEvent(Id, wxEVT_PAINT) { -#ifdef wxHAS_PAINT_DEBUG - // set the internal flag for the duration of redrawing +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) + // set the internal flag for the duration of processing of WM_PAINT g_isPainting++; #endif // debug } // default copy ctor and dtor are normally fine, we only need them to keep // g_isPainting updated in debug build -#ifdef wxHAS_PAINT_DEBUG +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) wxPaintEvent(const wxPaintEvent& event) : wxEvent(event) { @@ -2197,7 +1217,7 @@ private: class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent { public: - wxEraseEvent(int Id = 0, wxDC *dc = NULL) + wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL) : wxEvent(Id, wxEVT_ERASE_BACKGROUND), m_dc(dc) { } @@ -2211,7 +1231,11 @@ public: virtual wxEvent *Clone() const { return new wxEraseEvent(*this); } +#if WXWIN_COMPATIBILITY_2_4 +public: +#else protected: +#endif wxDC *m_dc; private: @@ -2275,36 +1299,19 @@ private: class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent { public: - // Type of activation. For now we can only detect if it was by mouse or by - // some other method and even this is only available under wxMSW. - enum Reason - { - Reason_Mouse, - Reason_Unknown - }; - - wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, - int Id = 0, Reason activationReason = Reason_Unknown) - : wxEvent(Id, type), - m_activationReason(activationReason) - { - m_active = active; - } + wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0) + : wxEvent(Id, type) + { m_active = active; } wxActivateEvent(const wxActivateEvent& event) : wxEvent(event) - { - m_active = event.m_active; - m_activationReason = event.m_activationReason; - } + { m_active = event.m_active; } bool GetActive() const { return m_active; } - Reason GetActivationReason() const { return m_activationReason;} virtual wxEvent *Clone() const { return new wxActivateEvent(*this); } private: bool m_active; - Reason m_activationReason; private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent) @@ -2341,7 +1348,7 @@ public: wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL) : wxEvent(winid, type) { m_menuId = winid; m_menu = menu; } - wxMenuEvent(const wxMenuEvent& event) + wxMenuEvent(const wxMenuEvent & event) : wxEvent(event) { m_menuId = event.m_menuId; m_menu = event.m_menu; } @@ -2379,7 +1386,7 @@ public: m_veto(false), // should be false by default m_canVeto(true) {} - wxCloseEvent(const wxCloseEvent& event) + wxCloseEvent(const wxCloseEvent & event) : wxEvent(event), m_loggingOff(event.m_loggingOff), m_veto(event.m_veto), @@ -2429,17 +1436,14 @@ public: wxShowEvent(int winid = 0, bool show = false) : wxEvent(winid, wxEVT_SHOW) { m_show = show; } - wxShowEvent(const wxShowEvent& event) + wxShowEvent(const wxShowEvent & event) : wxEvent(event) { m_show = event.m_show; } void SetShow(bool show) { m_show = show; } - - // return true if the window was shown, false if hidden - bool IsShown() const { return m_show; } - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( bool GetShow() const { return IsShown(); } ) + bool GetShow() const { return m_show; } +#if wxABI_VERSION >= 20811 + bool IsShown() const { return GetShow(); } #endif virtual wxEvent *Clone() const { return new wxShowEvent(*this); } @@ -2461,16 +1465,15 @@ public: wxIconizeEvent(int winid = 0, bool iconized = true) : wxEvent(winid, wxEVT_ICONIZE) { m_iconized = iconized; } - wxIconizeEvent(const wxIconizeEvent& event) + wxIconizeEvent(const wxIconizeEvent & event) : wxEvent(event) { m_iconized = event.m_iconized; } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( bool Iconized() const { return IsIconized(); } ) -#endif // return true if the frame was iconized, false if restored - bool IsIconized() const { return m_iconized; } - + bool Iconized() const { return m_iconized; } +#if wxABI_VERSION >= 20811 + bool IsIconized() const { return Iconized(); } +#endif virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); } protected: @@ -2523,7 +1526,11 @@ enum class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent { +#if WXWIN_COMPATIBILITY_2_4 +public: +#else protected: +#endif wxPoint m_pos; int m_zPosition; int m_buttonChange; // Which button changed? @@ -2543,7 +1550,7 @@ public: m_joyStick(joystick) { } - wxJoystickEvent(const wxJoystickEvent& event) + wxJoystickEvent(const wxJoystickEvent & event) : wxEvent(event), m_pos(event.m_pos), m_zPosition(event.m_zPosition), @@ -2609,7 +1616,7 @@ public: wxDropFilesEvent(wxEventType type = wxEVT_NULL, int noFiles = 0, - wxString *files = NULL) + wxString *files = (wxString *) NULL) : wxEvent(0, type), m_noFiles(noFiles), m_pos(), @@ -2678,7 +1685,7 @@ public: m_setText = m_setChecked = false; } - wxUpdateUIEvent(const wxUpdateUIEvent& event) + wxUpdateUIEvent(const wxUpdateUIEvent & event) : wxCommandEvent(event), m_checked(event.m_checked), m_enabled(event.m_enabled), @@ -2842,7 +1849,7 @@ class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent public: wxPaletteChangedEvent(wxWindowID winid = 0) : wxEvent(winid, wxEVT_PALETTE_CHANGED), - m_changedWindow(NULL) + m_changedWindow((wxWindow *) NULL) { } wxPaletteChangedEvent(const wxPaletteChangedEvent& event) @@ -2874,7 +1881,7 @@ public: : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE), m_paletteRealized(false) { } - wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent& event) + wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent & event) : wxEvent(event), m_paletteRealized(event.m_paletteRealized) { } @@ -2903,7 +1910,7 @@ public: wxNavigationKeyEvent() : wxEvent(0, wxEVT_NAVIGATION_KEY), m_flags(IsForward | FromTab), // defaults are for TAB - m_focus(NULL) + m_focus((wxWindow *)NULL) { m_propagationLevel = wxEVENT_PROPAGATE_NONE; } @@ -2944,7 +1951,7 @@ public: virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); } - enum wxNavigationKeyEventFlags + enum { IsBackward = 0x0000, IsForward = 0x0001, @@ -3020,7 +2027,7 @@ public: m_pos(pt), m_origin(GuessOrigin(origin)) { } - wxHelpEvent(const wxHelpEvent& event) + wxHelpEvent(const wxHelpEvent & event) : wxCommandEvent(event), m_pos(event.m_pos), m_target(event.m_target), @@ -3066,9 +2073,9 @@ private: // NOTE : under windows these events are *NOT* generated automatically // for a Rich Edit text control. /* -wxEVT_TEXT_COPY -wxEVT_TEXT_CUT -wxEVT_TEXT_PASTE +wxEVT_COMMAND_TEXT_COPY +wxEVT_COMMAND_TEXT_CUT +wxEVT_COMMAND_TEXT_PASTE */ class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent @@ -3078,7 +2085,7 @@ public: wxWindowID winid = 0) : wxCommandEvent(type, winid) { } - wxClipboardTextEvent(const wxClipboardTextEvent& event) + wxClipboardTextEvent(const wxClipboardTextEvent & event) : wxCommandEvent(event) { } @@ -3105,7 +2112,7 @@ public: : wxCommandEvent(type, winid), m_pos(pt) { } - wxContextMenuEvent(const wxContextMenuEvent& event) + wxContextMenuEvent(const wxContextMenuEvent & event) : wxCommandEvent(event), m_pos(event.m_pos) { } @@ -3123,6 +2130,62 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent) }; +// Idle event +/* + wxEVT_IDLE + */ + +// Whether to always send idle events to windows, or +// to only send update events to those with the +// wxWS_EX_PROCESS_IDLE style. + +enum wxIdleMode +{ + // Send idle events to all windows + wxIDLE_PROCESS_ALL, + + // Send idle events to windows that have + // the wxWS_EX_PROCESS_IDLE flag specified + wxIDLE_PROCESS_SPECIFIED +}; + +class WXDLLIMPEXP_CORE wxIdleEvent : public wxEvent +{ +public: + wxIdleEvent() + : wxEvent(0, wxEVT_IDLE), + m_requestMore(false) + { } + wxIdleEvent(const wxIdleEvent & event) + : wxEvent(event), + m_requestMore(event.m_requestMore) + { } + + void RequestMore(bool needMore = true) { m_requestMore = needMore; } + bool MoreRequested() const { return m_requestMore; } + + virtual wxEvent *Clone() const { return new wxIdleEvent(*this); } + + // Specify how wxWidgets will send idle events: to + // all windows, or only to those which specify that they + // will process the events. + static void SetMode(wxIdleMode mode) { sm_idleMode = mode; } + + // Returns the idle event mode + static wxIdleMode GetMode() { return sm_idleMode; } + + // Can we send an idle event? + static bool CanSend(wxWindow* win); + +protected: + bool m_requestMore; + static wxIdleMode sm_idleMode; + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent) +}; + +#endif // wxUSE_GUI /* TODO wxEVT_MOUSE_CAPTURE_CHANGED, @@ -3134,69 +2197,75 @@ private: wxEVT_COMPARE_ITEM */ -#endif // wxUSE_GUI - // ============================================================================ // event handler and related classes // ============================================================================ +// for backwards compatibility and to prevent eVC 4 for ARM from crashing with +// internal compiler error when compiling wx, we define wxObjectEventFunction +// as a wxObject method even though it can only be a wxEvtHandler one +typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); + +// we can't have ctors nor base struct in backwards compatibility mode or +// otherwise we won't be able to initialize the objects with an agregate, so +// we have to keep both versions +#if WXWIN_COMPATIBILITY_EVENT_TYPES + +struct WXDLLIMPEXP_BASE wxEventTableEntry +{ + // For some reason, this can't be wxEventType, or VC++ complains. + int m_eventType; // main event type + int m_id; // control/menu/toolbar id + int m_lastId; // used for ranges of ids + wxObjectEventFunction m_fn; // function to call: not wxEventFunction, + // because of dependency problems + + wxObject* m_callbackUserData; +}; + +#else // !WXWIN_COMPATIBILITY_EVENT_TYPES // struct containing the members common to static and dynamic event tables // entries struct WXDLLIMPEXP_BASE wxEventTableEntryBase { +private: + wxEventTableEntryBase& operator=(const wxEventTableEntryBase& event); + +public: wxEventTableEntryBase(int winid, int idLast, - wxEventFunctor* fn, wxObject *data) + wxObjectEventFunction fn, wxObject *data) : m_id(winid), m_lastId(idLast), m_fn(fn), m_callbackUserData(data) - { - wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast, - "invalid IDs range: lower bound > upper bound" ); - } + { } - wxEventTableEntryBase( const wxEventTableEntryBase &entry ) - : m_id( entry.m_id ), - m_lastId( entry.m_lastId ), - m_fn( entry.m_fn ), - m_callbackUserData( entry.m_callbackUserData ) - { - // This is a 'hack' to ensure that only one instance tries to delete - // the functor pointer. It is safe as long as the only place where the - // copy constructor is being called is when the static event tables are - // being initialized (a temporary instance is created and then this - // constructor is called). - - const_cast( entry ).m_fn = NULL; - } - - ~wxEventTableEntryBase() - { - delete m_fn; - } + wxEventTableEntryBase(const wxEventTableEntryBase& event) + : m_id(event.m_id), + m_lastId(event.m_lastId), + m_fn(event.m_fn), + m_callbackUserData(event.m_callbackUserData) + { } // the range of ids for this entry: if m_lastId == wxID_ANY, the range // consists only of m_id, otherwise it is m_id..m_lastId inclusive int m_id, m_lastId; - // function/method/functor to call - wxEventFunctor* m_fn; + // function to call: not wxEventFunction, because of dependency problems + wxObjectEventFunction m_fn; - // arbitrary user data associated with the callback + // arbitrary user data asosciated with the callback wxObject* m_callbackUserData; - -private: - wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase); }; // an entry from a static event table struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase { wxEventTableEntry(const int& evType, int winid, int idLast, - wxEventFunctor* fn, wxObject *data) + wxObjectEventFunction fn, wxObject *data) : wxEventTableEntryBase(winid, idLast, fn, data), m_eventType(evType) { } @@ -3210,16 +2279,17 @@ struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase const int& m_eventType; private: - wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry); + wxEventTableEntry& operator=(const wxEventTableEntry&); }; // an entry used in dynamic event table managed by wxEvtHandler::Connect() struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase { wxDynamicEventTableEntry(int evType, int winid, int idLast, - wxEventFunctor* fn, wxObject *data) + wxObjectEventFunction fn, wxObject *data, wxEvtHandler* eventSink) : wxEventTableEntryBase(winid, idLast, fn, data), - m_eventType(evType) + m_eventType(evType), + m_eventSink(eventSink) { } // not a reference here as we can't keep a reference to a temporary int @@ -3227,10 +2297,16 @@ struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase // do we need it int m_eventType; -private: - wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry); + // Pointer to object whose function is fn - so we don't assume the + // EventFunction is always a member of the EventHandler receiving the + // message + wxEvtHandler* m_eventSink; + + DECLARE_NO_COPY_CLASS(wxDynamicEventTableEntry) }; +#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES + // ---------------------------------------------------------------------------- // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0} // ---------------------------------------------------------------------------- @@ -3269,21 +2345,20 @@ public: // Handle the given event, in other words search the event table hash // and call self->ProcessEvent() if a match was found. - bool HandleEvent(wxEvent& event, wxEvtHandler *self); + bool HandleEvent(wxEvent &event, wxEvtHandler *self); // Clear table void Clear(); -#if wxUSE_MEMORY_TRACING - // Clear all tables: only used to work around problems in memory tracing - // code + // Clear all tables static void ClearAll(); -#endif // wxUSE_MEMORY_TRACING + // Rebuild all tables + static void ReconstructAll(); protected: // Init the hash table with the entries of the static event table. void InitHashTable(); - // Helper function of InitHashTable() to insert 1 entry into the hash table. + // Helper funtion of InitHashTable() to insert 1 entry into the hash table. void AddEntry(const wxEventTableEntry &entry); // Allocate and init with null pointers the base hash table. void AllocEventTypeTable(size_t size); @@ -3302,7 +2377,7 @@ protected: wxEventHashTable* m_previous; wxEventHashTable* m_next; - wxDECLARE_NO_COPY_CLASS(wxEventHashTable); + DECLARE_NO_COPY_CLASS(wxEventHashTable) }; // ---------------------------------------------------------------------------- @@ -3310,298 +2385,75 @@ protected: // ---------------------------------------------------------------------------- class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject - , public wxTrackable { public: wxEvtHandler(); virtual ~wxEvtHandler(); - - // Event handler chain - // ------------------- - wxEvtHandler *GetNextHandler() const { return m_nextHandler; } wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; } - virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } - virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } + void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } + void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; } bool GetEvtHandlerEnabled() const { return m_enabled; } - void Unlink(); - bool IsUnlinked() const; - - - // Global event filters - // -------------------- - - // Add an event filter whose FilterEvent() method will be called for each - // and every event processed by wxWidgets. The filters are called in LIFO - // order and wxApp is registered as an event filter by default. The pointer - // must remain valid until it's removed with RemoveFilter() and is not - // deleted by wxEvtHandler. - static void AddFilter(wxEventFilter* filter); - - // Remove a filter previously installed with AddFilter(). - static void RemoveFilter(wxEventFilter* filter); - - - // Event queuing and processing - // ---------------------------- - - // Process an event right now: this can only be called from the main - // thread, use QueueEvent() for scheduling the events for - // processing from other threads. + // process an event right now virtual bool ProcessEvent(wxEvent& event); - // Process an event by calling ProcessEvent and handling any exceptions - // thrown by event handlers. It's mostly useful when processing wx events - // when called from C code (e.g. in GTK+ callback) when the exception - // wouldn't correctly propagate to wxEventLoop. - bool SafelyProcessEvent(wxEvent& event); - // NOTE: uses ProcessEvent() - - // This method tries to process the event in this event handler, including - // any preprocessing done by TryBefore() and all the handlers chained to - // it, but excluding the post-processing done in TryAfter(). - // - // It is meant to be called from ProcessEvent() only and is not virtual, - // additional event handlers can be hooked into the normal event processing - // logic using TryBefore() and TryAfter() hooks. - // - // You can also call it yourself to forward an event to another handler but - // without propagating it upwards if it's unhandled (this is usually - // unwanted when forwarding as the original handler would already do it if - // needed normally). - bool ProcessEventLocally(wxEvent& event); - - // Schedule the given event to be processed later. It takes ownership of - // the event pointer, i.e. it will be deleted later. This is safe to call - // from multiple threads although you still need to ensure that wxString - // fields of the event object are deep copies and not use the same string - // buffer as other wxString objects in this thread. - virtual void QueueEvent(wxEvent *event); - - // Add an event to be processed later: notice that this function is not - // safe to call from threads other than main, use QueueEvent() - virtual void AddPendingEvent(const wxEvent& event) - { - // notice that the thread-safety problem comes from the fact that - // Clone() doesn't make deep copies of wxString fields of wxEvent - // object and so the same wxString could be used from both threads when - // the event object is destroyed in this one -- QueueEvent() avoids - // this problem as the event pointer is not used any more in this - // thread at all after it is called. - QueueEvent(event.Clone()); - } + // add an event to be processed later + void AddPendingEvent(wxEvent& event); void ProcessPendingEvents(); - // NOTE: uses ProcessEvent() - - void DeletePendingEvents(); #if wxUSE_THREADS - bool ProcessThreadEvent(const wxEvent& event); - // NOTE: uses AddPendingEvent(); call only from secondary threads + bool ProcessThreadEvent(wxEvent& event); #endif -#ifdef wxHAS_CALL_AFTER - // Asynchronous method calls: these methods schedule the given method - // pointer for a later call (during the next idle event loop iteration). - // - // Notice that the method is called on this object itself, so the object - // CallAfter() is called on must have the correct dynamic type. - // - // These method can be used from another thread. - - template - void CallAfter(void (T::*method)()) - { - QueueEvent( - new wxAsyncMethodCallEvent0(static_cast(this), method) - ); - } - - // Notice that we use P1 and not T1 for the parameter to allow passing - // parameters that are convertible to the type taken by the method - // instead of being exactly the same, to be closer to the usual method call - // semantics. - template - void CallAfter(void (T::*method)(T1 x1), P1 x1) - { - QueueEvent( - new wxAsyncMethodCallEvent1( - static_cast(this), method, x1) - ); - } - - template - void CallAfter(void (T::*method)(T1 x1, T2 x2), P1 x1, P2 x2) - { - QueueEvent( - new wxAsyncMethodCallEvent2( - static_cast(this), method, x1, x2) - ); - } - - template - void CallAfter(const T& fn) - { - QueueEvent(new wxAsyncMethodCallEventFunctor(this, fn)); - } -#endif // wxHAS_CALL_AFTER - - - // Connecting and disconnecting - // ---------------------------- - - // These functions are used for old, untyped, event handlers and don't - // check that the type of the function passed to them actually matches the - // type of the event. They also only allow connecting events to methods of - // wxEvtHandler-derived classes. - // - // The template Connect() methods below are safer and allow connecting - // events to arbitrary functions or functors -- but require compiler - // support for templates. - // Dynamic association of a member function handler with the event handler, // winid and event type void Connect(int winid, int lastId, - wxEventType eventType, + int eventType, wxObjectEventFunction func, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) - { - DoBind(winid, lastId, eventType, - wxNewEventFunctor(eventType, func, eventSink), - userData); - } + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL); // Convenience function: take just one id void Connect(int winid, - wxEventType eventType, + int eventType, wxObjectEventFunction func, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL) { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); } // Even more convenient: without id (same as using id of wxID_ANY) - void Connect(wxEventType eventType, + void Connect(int eventType, wxObjectEventFunction func, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL) { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); } bool Disconnect(int winid, int lastId, wxEventType eventType, wxObjectEventFunction func = NULL, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) - { - return DoUnbind(winid, lastId, eventType, - wxMakeEventFunctor(eventType, func, eventSink), - userData ); - } + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL); bool Disconnect(int winid = wxID_ANY, wxEventType eventType = wxEVT_NULL, wxObjectEventFunction func = NULL, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL) { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); } bool Disconnect(wxEventType eventType, wxObjectEventFunction func, - wxObject *userData = NULL, - wxEvtHandler *eventSink = NULL) + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL) { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } -#ifdef wxHAS_EVENT_BIND - // Bind functions to an event: - template - void Bind(const EventTag& eventType, - void (*function)(EventArg &), - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL) - { - DoBind(winid, lastId, eventType, - wxNewEventFunctor(eventType, function), - userData); - } - - - template - bool Unbind(const EventTag& eventType, - void (*function)(EventArg &), - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL) - { - return DoUnbind(winid, lastId, eventType, - wxMakeEventFunctor(eventType, function), - userData); - } - - // Bind functors to an event: - template - void Bind(const EventTag& eventType, - const Functor &functor, - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL) - { - DoBind(winid, lastId, eventType, - wxNewEventFunctor(eventType, functor), - userData); - } - - - template - bool Unbind(const EventTag& eventType, - const Functor &functor, - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL) - { - return DoUnbind(winid, lastId, eventType, - wxMakeEventFunctor(eventType, functor), - userData); - } - - - // Bind a method of a class (called on the specified handler which must - // be convertible to this class) object to an event: - - template - void Bind(const EventTag &eventType, - void (Class::*method)(EventArg &), - EventHandler *handler, - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL) - { - DoBind(winid, lastId, eventType, - wxNewEventFunctor(eventType, method, handler), - userData); - } - - template - bool Unbind(const EventTag &eventType, - void (Class::*method)(EventArg&), - EventHandler *handler, - int winid = wxID_ANY, - int lastId = wxID_ANY, - wxObject *userData = NULL ) - { - return DoUnbind(winid, lastId, eventType, - wxMakeEventFunctor(eventType, method, handler), - userData); - } -#endif // wxHAS_EVENT_BIND - wxList* GetDynamicEventTable() const { return m_dynamicEvents ; } // User data can be associated with each wxEvtHandler @@ -3611,80 +2463,48 @@ public: void SetClientData( void *data ) { DoSetClientData(data); } void *GetClientData() const { return DoGetClientData(); } - - // implementation from now on - // -------------------------- - - // check if the given event table entry matches this event by id (the check - // for the event type should be done by caller) and call the handler if it - // does + // check if the given event table entry matches this event and call the + // handler if it does // // return true if the event was processed, false otherwise (no match or the // handler decided to skip the event) - static bool ProcessEventIfMatchesId(const wxEventTableEntryBase& tableEntry, - wxEvtHandler *handler, - wxEvent& event); + static bool ProcessEventIfMatches(const wxEventTableEntryBase& tableEntry, + wxEvtHandler *handler, + wxEvent& event); + // implementation from now on virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); bool SearchDynamicEventTable( wxEvent& event ); +#if wxUSE_THREADS + void ClearEventLocker(); +#endif // wxUSE_THREADS + // Avoid problems at exit by cleaning up static hash table gracefully void ClearEventHashTable() { GetEventHashTable().Clear(); } - void OnSinkDestroyed( wxEvtHandler *sink ); - private: - void DoBind(int winid, - int lastId, - wxEventType eventType, - wxEventFunctor *func, - wxObject* userData = NULL); - - bool DoUnbind(int winid, - int lastId, - wxEventType eventType, - const wxEventFunctor& func, - wxObject *userData = NULL); - static const wxEventTableEntry sm_eventTableEntries[]; protected: // hooks for wxWindow used by ProcessEvent() // ----------------------------------------- - // this one is called before trying our own event table to allow plugging - // in the event handlers overriding the default logic, this is used by e.g. - // validators. - virtual bool TryBefore(wxEvent& event); - - // This one is not a hook but just a helper which looks up the handler in - // this object itself. + // This one is called before trying our own event table to allow plugging + // in the validators. // - // It is called from ProcessEventLocally() and normally shouldn't be called - // directly as doing it would ignore any chained event handlers - bool TryHereOnly(wxEvent& event); - - // Another helper which simply calls pre-processing hook and then tries to - // handle the event at this handler level. - bool TryBeforeAndHere(wxEvent& event) - { - return TryBefore(event) || TryHereOnly(event); - } + // NB: This method is intentionally *not* inside wxUSE_VALIDATORS! + // It is part of wxBase which doesn't use validators and the code + // is compiled out when building wxBase w/o GUI classes, which affects + // binary compatibility and wxBase library can't be used by GUI + // ports. + virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; } // this one is called after failing to find the event handle in our own // table to give a chance to the other windows to process it // // base class implementation passes the event to wxTheApp - virtual bool TryAfter(wxEvent& event); - -#if WXWIN_COMPATIBILITY_2_8 - // deprecated method: override TryBefore() instead of this one - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual bool TryValidator(wxEvent& WXUNUSED(event)), return false; ) - - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual bool TryParent(wxEvent& event), return DoTryApp(event); ) -#endif // WXWIN_COMPATIBILITY_2_8 + virtual bool TryParent(wxEvent& event); static const wxEventTable sm_eventTable; @@ -3699,9 +2519,18 @@ protected: wxList* m_pendingEvents; #if wxUSE_THREADS - // critical section protecting m_pendingEvents - wxCriticalSection m_pendingEventsLock; -#endif // wxUSE_THREADS +#if defined (__VISAGECPP__) + const wxCriticalSection& Lock() const { return m_eventsLocker; } + wxCriticalSection& Lock() { return m_eventsLocker; } + + wxCriticalSection m_eventsLocker; +# else + const wxCriticalSection& Lock() const { return *m_eventsLocker; } + wxCriticalSection& Lock() { return *m_eventsLocker; } + + wxCriticalSection* m_eventsLocker; +# endif +#endif // Is event handler enabled? bool m_enabled; @@ -3728,142 +2557,26 @@ protected: virtual void DoSetClientData( void *data ); virtual void *DoGetClientData() const; - // Search tracker objects for event connection with this sink - wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *handler); - private: - // pass the event to wxTheApp instance, called from TryAfter() - bool DoTryApp(wxEvent& event); - - // try to process events in all handlers chained to this one - bool DoTryChain(wxEvent& event); - - // Head of the event filter linked list. - static wxEventFilter* ms_filterList; - DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler) }; -WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE); - - -// Define an inline method of wxObjectEventFunctor which couldn't be defined -// before wxEvtHandler declaration: at least Sun CC refuses to compile function -// calls through pointer to member for forward-declared classes (see #12452). -inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event) +// Post a message to the given eventhandler which will be processed during the +// next event loop iteration +inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event) { - wxEvtHandler * const realHandler = m_handler ? m_handler : handler; - - (realHandler->*m_method)(event); -} - -// ---------------------------------------------------------------------------- -// wxEventConnectionRef represents all connections between two event handlers -// and enables automatic disconnect when an event handler sink goes out of -// scope. Each connection/disconnect increases/decreases ref count, and -// when it reaches zero the node goes out of scope. -// ---------------------------------------------------------------------------- - -class wxEventConnectionRef : public wxTrackerNode -{ -public: - wxEventConnectionRef() : m_src(NULL), m_sink(NULL), m_refCount(0) { } - wxEventConnectionRef(wxEvtHandler *src, wxEvtHandler *sink) - : m_src(src), m_sink(sink), m_refCount(1) - { - m_sink->AddNode(this); - } - - // The sink is being destroyed - virtual void OnObjectDestroy( ) - { - if ( m_src ) - m_src->OnSinkDestroyed( m_sink ); - delete this; - } - - virtual wxEventConnectionRef *ToEventConnection() { return this; } - - void IncRef() { m_refCount++; } - void DecRef() - { - if ( !--m_refCount ) - { - // The sink holds the only external pointer to this object - if ( m_sink ) - m_sink->RemoveNode(this); - delete this; - } - } - -private: - wxEvtHandler *m_src, - *m_sink; - int m_refCount; - - friend class wxEvtHandler; - - wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef); -}; - -// Post a message to the given event handler which will be processed during the -// next event loop iteration. -// -// Notice that this one is not thread-safe, use wxQueueEvent() -inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event) -{ - wxCHECK_RET( dest, "need an object to post event to" ); + wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") ); dest->AddPendingEvent(event); } -// Wrapper around wxEvtHandler::QueueEvent(): adds an event for later -// processing, unlike wxPostEvent it is safe to use from different thread even -// for events with wxString members -inline void wxQueueEvent(wxEvtHandler *dest, wxEvent *event) -{ - wxCHECK_RET( dest, "need an object to queue event for" ); - - dest->QueueEvent(event); -} - typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); -typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); -typedef void (wxEvtHandler::*wxThreadEventFunction)(wxThreadEvent&); #define wxEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxEventFunction, func) -#define wxIdleEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxIdleEventFunction, func) -#define wxThreadEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxThreadEventFunction, func) + (wxObjectEventFunction)wxStaticCastEvent(wxEventFunction, &func) #if wxUSE_GUI -// ---------------------------------------------------------------------------- -// wxEventBlocker: helper class to temporarily disable event handling for a window -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler -{ -public: - wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY); - virtual ~wxEventBlocker(); - - void Block(wxEventType type) - { - m_eventsToBlock.push_back(type); - } - - virtual bool ProcessEvent(wxEvent& event); - -protected: - wxArrayInt m_eventsToBlock; - wxWindow *m_window; - - wxDECLARE_NO_COPY_CLASS(wxEventBlocker); -}; - typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&); typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&); @@ -3884,6 +2597,7 @@ typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&); typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&); typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); +typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&); typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&); typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&); @@ -3901,100 +2615,109 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&); typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&); +// these typedefs don't have the same name structure as the others, keep for +// backwards compatibility only +#if WXWIN_COMPATIBILITY_2_4 + typedef wxSysColourChangedEventFunction wxSysColourChangedFunction; + typedef wxDisplayChangedEventFunction wxDisplayChangedFunction; +#endif // WXWIN_COMPATIBILITY_2_4 + #define wxCommandEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxCommandEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCommandEventFunction, &func) #define wxScrollEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxScrollEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollEventFunction, &func) #define wxScrollWinEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollWinEventFunction, &func) #define wxSizeEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSizeEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSizeEventFunction, &func) #define wxMoveEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMoveEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMoveEventFunction, &func) #define wxPaintEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxPaintEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaintEventFunction, &func) #define wxNcPaintEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNcPaintEventFunction, &func) #define wxEraseEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxEraseEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxEraseEventFunction, &func) #define wxMouseEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMouseEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseEventFunction, &func) #define wxCharEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxCharEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCharEventFunction, &func) #define wxKeyEventHandler(func) wxCharEventHandler(func) #define wxFocusEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxFocusEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFocusEventFunction, &func) #define wxChildFocusEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChildFocusEventFunction, &func) #define wxActivateEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxActivateEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActivateEventFunction, &func) #define wxMenuEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMenuEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMenuEventFunction, &func) #define wxJoystickEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxJoystickEventFunction, &func) #define wxDropFilesEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDropFilesEventFunction, &func) #define wxInitDialogEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxInitDialogEventFunction, &func) #define wxSysColourChangedEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSysColourChangedEventFunction, &func) #define wxDisplayChangedEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDisplayChangedEventFunction, &func) #define wxUpdateUIEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxUpdateUIEventFunction, &func) +#define wxIdleEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func) #define wxCloseEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxCloseEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCloseEventFunction, &func) #define wxShowEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxShowEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxShowEventFunction, &func) #define wxIconizeEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIconizeEventFunction, &func) #define wxMaximizeEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMaximizeEventFunction, &func) #define wxNavigationKeyEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNavigationKeyEventFunction, &func) #define wxPaletteChangedEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaletteChangedEventFunction, &func) #define wxQueryNewPaletteEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxQueryNewPaletteEventFunction, &func) #define wxWindowCreateEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowCreateEventFunction, &func) #define wxWindowDestroyEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowDestroyEventFunction, &func) #define wxSetCursorEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSetCursorEventFunction, &func) #define wxNotifyEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNotifyEventFunction, &func) #define wxHelpEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxHelpEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHelpEventFunction, &func) #define wxContextMenuEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxContextMenuEventFunction, &func) #define wxMouseCaptureChangedEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureChangedEventFunction, &func) #define wxMouseCaptureLostEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureLostEventFunction, &func) #define wxClipboardTextEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxClipboardTextEventFunction, &func) #endif // wxUSE_GUI // N.B. In GNU-WIN32, you *have* to take the address of a member function // (use &) or the compiler crashes... -#define wxDECLARE_EVENT_TABLE() \ - private: \ - static const wxEventTableEntry sm_eventTableEntries[]; \ - protected: \ - static const wxEventTable sm_eventTable; \ - virtual const wxEventTable* GetEventTable() const; \ - static wxEventHashTable sm_eventHashTable; \ - virtual wxEventHashTable& GetEventHashTable() const +#define DECLARE_EVENT_TABLE() \ + private: \ + static const wxEventTableEntry sm_eventTableEntries[]; \ + protected: \ + static const wxEventTable sm_eventTable; \ + virtual const wxEventTable* GetEventTable() const; \ + static wxEventHashTable sm_eventHashTable; \ + virtual wxEventHashTable& GetEventHashTable() const; // N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize // sm_eventTable before using it in GetEventTable() or the compiler gives // E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews) -#define wxBEGIN_EVENT_TABLE(theClass, baseClass) \ +#define BEGIN_EVENT_TABLE(theClass, baseClass) \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ const wxEventTable *theClass::GetEventTable() const \ @@ -4004,7 +2727,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& { return theClass::sm_eventHashTable; } \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ +#define BEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4019,7 +2742,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ +#define BEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4034,7 +2757,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ +#define BEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4049,7 +2772,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ +#define BEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4064,7 +2787,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ +#define BEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4079,7 +2802,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ +#define BEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4094,7 +2817,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ +#define BEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -4109,8 +2832,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define wxEND_EVENT_TABLE() \ - wxDECLARE_EVENT_TABLE_TERMINATOR() }; +#define END_EVENT_TABLE() DECLARE_EVENT_TABLE_ENTRY( wxEVT_NULL, 0, 0, 0, 0 ) }; /* * Event table macros @@ -4124,7 +2846,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& // - id1, id2 ids of the first/last id // - fn the function (should be cast to the right type) #define wx__DECLARE_EVT2(evt, id1, id2, fn) \ - wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), + DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), #define wx__DECLARE_EVT1(evt, id, fn) \ wx__DECLARE_EVT2(evt, id, wxID_ANY, fn) #define wx__DECLARE_EVT0(evt, fn) \ @@ -4140,13 +2862,11 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& // EVT_COMMAND #define EVT_COMMAND(winid, event, func) \ wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func)) - #define EVT_COMMAND_RANGE(id1, id2, event, func) \ wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func)) #define EVT_NOTIFY(event, winid, func) \ wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func)) - #define EVT_NOTIFY_RANGE(event, id1, id2, func) \ wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func)) @@ -4155,8 +2875,6 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func)) #define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func)) #define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func)) -#define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func)) -#define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func)) #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func)) #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func)) #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func)) @@ -4212,31 +2930,19 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func)) #define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func)) #define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func)) -#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func)) // All mouse events #define EVT_MOUSE_EVENTS(func) \ EVT_LEFT_DOWN(func) \ EVT_LEFT_UP(func) \ - EVT_LEFT_DCLICK(func) \ EVT_MIDDLE_DOWN(func) \ EVT_MIDDLE_UP(func) \ - EVT_MIDDLE_DCLICK(func) \ EVT_RIGHT_DOWN(func) \ EVT_RIGHT_UP(func) \ - EVT_RIGHT_DCLICK(func) \ - EVT_MOUSE_AUX1_DOWN(func) \ - EVT_MOUSE_AUX1_UP(func) \ - EVT_MOUSE_AUX1_DCLICK(func) \ - EVT_MOUSE_AUX2_DOWN(func) \ - EVT_MOUSE_AUX2_UP(func) \ - EVT_MOUSE_AUX2_DCLICK(func) \ EVT_MOTION(func) \ + EVT_LEFT_DCLICK(func) \ + EVT_MIDDLE_DCLICK(func) \ + EVT_RIGHT_DCLICK(func) \ EVT_LEAVE_WINDOW(func) \ EVT_ENTER_WINDOW(func) \ EVT_MOUSEWHEEL(func) @@ -4313,33 +3019,30 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #endif // WXWIN_COMPATIBILITY_2_6 // Convenience macros for commonly-used commands -#define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKBOX, winid, wxCommandEventHandler(func)) -#define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_CHOICE, winid, wxCommandEventHandler(func)) -#define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX, winid, wxCommandEventHandler(func)) -#define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX_DCLICK, winid, wxCommandEventHandler(func)) -#define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_MENU, winid, wxCommandEventHandler(func)) -#define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_MENU, id1, id2, wxCommandEventHandler(func)) +#define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKBOX_CLICKED, winid, wxCommandEventHandler(func)) +#define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICE_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOX_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, winid, wxCommandEventHandler(func)) +#define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_MENU_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_MENU_SELECTED, id1, id2, wxCommandEventHandler(func)) #if defined(__SMARTPHONE__) # define EVT_BUTTON(winid, func) EVT_MENU(winid, func) #else -# define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_BUTTON, winid, wxCommandEventHandler(func)) +# define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_BUTTON_CLICKED, winid, wxCommandEventHandler(func)) #endif -#define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_SLIDER, winid, wxCommandEventHandler(func)) -#define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBOX, winid, wxCommandEventHandler(func)) -#define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBUTTON, winid, wxCommandEventHandler(func)) +#define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SLIDER_UPDATED, winid, wxCommandEventHandler(func)) +#define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RADIOBOX_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RADIOBUTTON_SELECTED, winid, wxCommandEventHandler(func)) // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events -#define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLLBAR, winid, wxCommandEventHandler(func)) -#define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_VLBOX, winid, wxCommandEventHandler(func)) -#define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX, winid, wxCommandEventHandler(func)) -#define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL, winid, wxCommandEventHandler(func)) -#define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_DROPDOWN, winid, wxCommandEventHandler(func)) -#define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL, id1, id2, wxCommandEventHandler(func)) -#define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func)) -#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) -#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func)) -#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func)) -#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func)) -#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func)) +#define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SCROLLBAR_UPDATED, winid, wxCommandEventHandler(func)) +#define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_VLBOX_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_SELECTED, winid, wxCommandEventHandler(func)) +#define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_CLICKED, winid, wxCommandEventHandler(func)) +#define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_CLICKED, id1, id2, wxCommandEventHandler(func)) +#define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_RCLICKED, winid, wxCommandEventHandler(func)) +#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) +#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_ENTER, winid, wxCommandEventHandler(func)) +#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, winid, wxCommandEventHandler(func)) // Generic command events #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func)) @@ -4357,6 +3060,12 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func)) #define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func)) +// These are obsolete, see _BUTTON_ events +#if WXWIN_COMPATIBILITY_2_4 + #define EVT_JOY_DOWN(func) EVT_JOY_BUTTON_DOWN(func) + #define EVT_JOY_UP(func) EVT_JOY_BUTTON_UP(func) +#endif // WXWIN_COMPATIBILITY_2_4 + // All joystick events #define EVT_JOYSTICK_EVENTS(func) \ EVT_JOY_BUTTON_DOWN(func) \ @@ -4382,52 +3091,25 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func)) // Clipboard text Events -#define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_CUT, winid, wxClipboardTextEventHandler(func)) -#define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_COPY, winid, wxClipboardTextEventHandler(func)) -#define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_PASTE, winid, wxClipboardTextEventHandler(func)) +#define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_CUT, winid, wxClipboardTextEventHandler(func)) +#define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_COPY, winid, wxClipboardTextEventHandler(func)) +#define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_PASTE, winid, wxClipboardTextEventHandler(func)) -// Thread events -#define EVT_THREAD(id, func) wx__DECLARE_EVT1(wxEVT_THREAD, id, wxThreadEventHandler(func)) +// ---------------------------------------------------------------------------- +// Global data +// ---------------------------------------------------------------------------- + +// for pending event processing - notice that there is intentionally no +// WXDLLEXPORT here +extern WXDLLIMPEXP_BASE wxList *wxPendingEvents; +#if wxUSE_THREADS + extern WXDLLIMPEXP_BASE wxCriticalSection *wxPendingEventsLocker; +#endif // ---------------------------------------------------------------------------- // Helper functions // ---------------------------------------------------------------------------- -// This is an ugly hack to allow the use of Bind() instead of Connect() inside -// the library code if the library was built with support for it, here is how -// it is used: -// -// class SomeEventHandlingClass : wxBIND_OR_CONNECT_HACK_BASE_CLASS -// public SomeBaseClass -// { -// public: -// SomeEventHandlingClass(wxWindow *win) -// { -// // connect to the event for the given window -// wxBIND_OR_CONNECT_HACK(win, wxEVT_SOMETHING, wxSomeEventHandler, -// SomeEventHandlingClass::OnSomeEvent, this); -// } -// -// private: -// void OnSomeEvent(wxSomeEvent&) { ... } -// }; -// -// This is *not* meant to be used by library users, it is only defined here -// (and not in a private header) because the base class must be visible from -// other public headers, please do NOT use this in your code, it will be -// removed from future wx versions without warning. -#ifdef wxHAS_EVENT_BIND - #define wxBIND_OR_CONNECT_HACK_BASE_CLASS - #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS - #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ - win->Bind(evt, &func, obj) -#else // wxHAS_EVENT_BIND - #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler, - #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler - #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ - win->Connect(evt, handler(func), NULL, obj) -#endif // wxHAS_EVENT_BIND - #if wxUSE_GUI // Find a window with the focus, that is also a descendant of the given window. @@ -4436,66 +3118,4 @@ WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor); #endif // wxUSE_GUI - -// ---------------------------------------------------------------------------- -// Compatibility macro aliases -// ---------------------------------------------------------------------------- - -// deprecated variants _not_ requiring a semicolon after them and without wx prefix -// (note that also some wx-prefixed macro do _not_ require a semicolon because -// it's not always possible to force the compire to require it) - -#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ - wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) -#define DECLARE_EVENT_TABLE_TERMINATOR() wxDECLARE_EVENT_TABLE_TERMINATOR() -#define DECLARE_EVENT_TABLE() wxDECLARE_EVENT_TABLE(); -#define BEGIN_EVENT_TABLE(a,b) wxBEGIN_EVENT_TABLE(a,b) -#define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) -#define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) wxBEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) -#define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) wxBEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) -#define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) wxBEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) -#define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) wxBEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) -#define BEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) wxBEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) -#define END_EVENT_TABLE() wxEND_EVENT_TABLE() - -// other obsolete event declaration/definition macros; we don't need them any longer -// but we keep them for compatibility as it doesn't cost us anything anyhow -#define BEGIN_DECLARE_EVENT_TYPES() -#define END_DECLARE_EVENT_TYPES() -#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ - extern expdecl const wxEventType name; -#define DECLARE_EVENT_TYPE(name, value) \ - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) -#define DECLARE_LOCAL_EVENT_TYPE(name, value) \ - DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) -#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); -#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) - -// alias for backward compatibility with 2.9.0: -#define wxEVT_COMMAND_THREAD wxEVT_THREAD -// other old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_BUTTON_CLICKED wxEVT_BUTTON -#define wxEVT_COMMAND_CHECKBOX_CLICKED wxEVT_CHECKBOX -#define wxEVT_COMMAND_CHOICE_SELECTED wxEVT_CHOICE -#define wxEVT_COMMAND_LISTBOX_SELECTED wxEVT_LISTBOX -#define wxEVT_COMMAND_LISTBOX_DOUBLECLICKED wxEVT_LISTBOX_DCLICK -#define wxEVT_COMMAND_CHECKLISTBOX_TOGGLED wxEVT_CHECKLISTBOX -#define wxEVT_COMMAND_MENU_SELECTED wxEVT_MENU -#define wxEVT_COMMAND_TOOL_CLICKED wxEVT_TOOL -#define wxEVT_COMMAND_SLIDER_UPDATED wxEVT_SLIDER -#define wxEVT_COMMAND_RADIOBOX_SELECTED wxEVT_RADIOBOX -#define wxEVT_COMMAND_RADIOBUTTON_SELECTED wxEVT_RADIOBUTTON -#define wxEVT_COMMAND_SCROLLBAR_UPDATED wxEVT_SCROLLBAR -#define wxEVT_COMMAND_VLBOX_SELECTED wxEVT_VLBOX -#define wxEVT_COMMAND_COMBOBOX_SELECTED wxEVT_COMBOBOX -#define wxEVT_COMMAND_TOOL_RCLICKED wxEVT_TOOL_RCLICKED -#define wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED wxEVT_TOOL_DROPDOWN -#define wxEVT_COMMAND_TOOL_ENTER wxEVT_TOOL_ENTER -#define wxEVT_COMMAND_COMBOBOX_DROPDOWN wxEVT_COMBOBOX_DROPDOWN -#define wxEVT_COMMAND_COMBOBOX_CLOSEUP wxEVT_COMBOBOX_CLOSEUP -#define wxEVT_COMMAND_TEXT_COPY wxEVT_TEXT_COPY -#define wxEVT_COMMAND_TEXT_CUT wxEVT_TEXT_CUT -#define wxEVT_COMMAND_TEXT_PASTE wxEVT_TEXT_PASTE -#define wxEVT_COMMAND_TEXT_UPDATED wxEVT_TEXT - -#endif // _WX_EVENT_H_ +#endif // _WX_EVENT_H__ diff --git a/Source/3rd Party/wx/include/wx/eventfilter.h b/Source/3rd Party/wx/include/wx/eventfilter.h deleted file mode 100644 index 30eac4d36..000000000 --- a/Source/3rd Party/wx/include/wx/eventfilter.h +++ /dev/null @@ -1,71 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/eventfilter.h -// Purpose: wxEventFilter class declaration. -// Author: Vadim Zeitlin -// Created: 2011-11-21 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_EVENTFILTER_H_ -#define _WX_EVENTFILTER_H_ - -#include "wx/defs.h" - -class WXDLLIMPEXP_FWD_BASE wxEvent; -class WXDLLIMPEXP_FWD_BASE wxEvtHandler; - -// ---------------------------------------------------------------------------- -// wxEventFilter is used with wxEvtHandler::AddFilter() and ProcessEvent(). -// ---------------------------------------------------------------------------- - -class wxEventFilter -{ -public: - // Possible return values for FilterEvent(). - // - // Notice that the values of these enum elements are fixed due to backwards - // compatibility constraints. - enum - { - // Process event as usual. - Event_Skip = -1, - - // Don't process the event normally at all. - Event_Ignore = 0, - - // Event was already handled, don't process it normally. - Event_Processed = 1 - }; - - wxEventFilter() - { - m_next = NULL; - } - - virtual ~wxEventFilter() - { - wxASSERT_MSG( !m_next, "Forgot to call wxEvtHandler::RemoveFilter()?" ); - } - - // This method allows to filter all the events processed by the program, so - // you should try to return quickly from it to avoid slowing down the - // program to a crawl. - // - // Return value should be -1 to continue with the normal event processing, - // or true or false to stop further processing and pretend that the event - // had been already processed or won't be processed at all, respectively. - virtual int FilterEvent(wxEvent& event) = 0; - -private: - // Objects of this class are made to be stored in a linked list in - // wxEvtHandler so put the next node ponter directly in the class itself. - wxEventFilter* m_next; - - // And provide access to it for wxEvtHandler [only]. - friend class wxEvtHandler; - - wxDECLARE_NO_COPY_CLASS(wxEventFilter); -}; - -#endif // _WX_EVENTFILTER_H_ diff --git a/Source/3rd Party/wx/include/wx/evtloop.h b/Source/3rd Party/wx/include/wx/evtloop.h index 6ef6d2522..3f44e8688 100644 --- a/Source/3rd Party/wx/include/wx/evtloop.h +++ b/Source/3rd Party/wx/include/wx/evtloop.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 01.06.01 +// RCS-ID: $Id: evtloop.h 53607 2008-05-16 15:21:40Z SN $ // Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,103 +12,28 @@ #ifndef _WX_EVTLOOP_H_ #define _WX_EVTLOOP_H_ -#include "wx/event.h" #include "wx/utils.h" -// TODO: implement wxEventLoopSource for MSW (it should wrap a HANDLE and be -// monitored using MsgWaitForMultipleObjects()) -#if defined(__WXOSX__) || (defined(__UNIX__) && !defined(__WINDOWS__)) - #define wxUSE_EVENTLOOP_SOURCE 1 -#else - #define wxUSE_EVENTLOOP_SOURCE 0 -#endif - -#if wxUSE_EVENTLOOP_SOURCE - class wxEventLoopSource; - class wxEventLoopSourceHandler; -#endif - -/* - NOTE ABOUT wxEventLoopBase::YieldFor LOGIC - ------------------------------------------ - - The YieldFor() function helps to avoid re-entrancy problems and problems - caused by out-of-order event processing - (see "wxYield-like problems" and "wxProgressDialog+threading BUG" wx-dev threads). - - The logic behind YieldFor() is simple: it analyzes the queue of the native - events generated by the underlying GUI toolkit and picks out and processes - only those matching the given mask. - - It's important to note that YieldFor() is used to selectively process the - events generated by the NATIVE toolkit. - Events syntethized by wxWidgets code or by user code are instead selectively - processed thanks to the logic built into wxEvtHandler::ProcessPendingEvents(). - In fact, when wxEvtHandler::ProcessPendingEvents gets called from inside a - YieldFor() call, wxEventLoopBase::IsEventAllowedInsideYield is used to decide - if the pending events for that event handler can be processed. - If all the pending events associated with that event handler result as "not processable", - the event handler "delays" itself calling wxEventLoopBase::DelayPendingEventHandler - (so it's moved: m_handlersWithPendingEvents => m_handlersWithPendingDelayedEvents). - Last, wxEventLoopBase::ProcessPendingEvents() before exiting moves the delayed - event handlers back into the list of handlers with pending events - (m_handlersWithPendingDelayedEvents => m_handlersWithPendingEvents) so that - a later call to ProcessPendingEvents() (possibly outside the YieldFor() call) - will process all pending events as usual. -*/ +class WXDLLIMPEXP_FWD_CORE wxEventLoop; // ---------------------------------------------------------------------------- -// wxEventLoopBase: interface for wxEventLoop +// wxEventLoop: a GUI event loop // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxEventLoopBase +class WXDLLEXPORT wxEventLoopBase { public: // trivial, but needed (because of wxEventLoopBase) ctor - wxEventLoopBase(); + wxEventLoopBase() { } // dtor virtual ~wxEventLoopBase() { } - // use this to check whether the event loop was successfully created before - // using it - virtual bool IsOk() const { return true; } - - // returns true if this is the main loop - bool IsMain() const; - -#if wxUSE_EVENTLOOP_SOURCE - // create a new event loop source wrapping the given file descriptor and - // monitor it for events occurring on this descriptor in all event loops - static wxEventLoopSource * - AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags); -#endif // wxUSE_EVENTLOOP_SOURCE - - // dispatch&processing - // ------------------- - // start the event loop, return the exit code when it is finished - // - // notice that wx ports should override DoRun(), this method is virtual - // only to allow overriding it in the user code for custom event loops - virtual int Run(); - - // is this event loop running now? - // - // notice that even if this event loop hasn't terminated yet but has just - // spawned a nested (e.g. modal) event loop, this would return false - bool IsRunning() const; + virtual int Run() = 0; // exit from the loop with the given exit code - // - // this can be only used to exit the currently running loop, use - // ScheduleExit() if this might not be the case - virtual void Exit(int rc = 0); - - // ask the event loop to exit with the given exit code, can be used even if - // this loop is not running right now but the loop must have been started, - // i.e. Run() should have been already called - virtual void ScheduleExit(int rc = 0) = 0; + virtual void Exit(int rc = 0) = 0; // return true if any events are available virtual bool Pending() const = 0; @@ -115,120 +41,54 @@ public: // dispatch a single event, return false if we should exit from the loop virtual bool Dispatch() = 0; - // same as Dispatch() but doesn't wait for longer than the specified (in - // ms) timeout, return true if an event was processed, false if we should - // exit the loop or -1 if timeout expired - virtual int DispatchTimeout(unsigned long timeout) = 0; - - // implement this to wake up the loop: usually done by posting a dummy event - // to it (can be called from non main thread) - virtual void WakeUp() = 0; - - - // idle handling - // ------------- - - // make sure that idle events are sent again - virtual void WakeUpIdle(); - - // this virtual function is called when the application - // becomes idle and by default it forwards to wxApp::ProcessIdle() and - // while it can be overridden in a custom event loop, you must call the - // base class version to ensure that idle events are still generated - // - // it should return true if more idle events are needed, false if not - virtual bool ProcessIdle(); - - - // Yield-related hooks - // ------------------- - - // process all currently pending events right now - // - // it is an error to call Yield() recursively unless the value of - // onlyIfNeeded is true - // - // WARNING: this function is dangerous as it can lead to unexpected - // reentrancies (i.e. when called from an event handler it - // may result in calling the same event handler again), use - // with _extreme_ care or, better, don't use at all! - bool Yield(bool onlyIfNeeded = false); - virtual bool YieldFor(long eventsToProcess) = 0; - - // returns true if the main thread is inside a Yield() call - virtual bool IsYielding() const - { return m_isInsideYield; } - - // returns true if events of the given event category should be immediately - // processed inside a wxApp::Yield() call or rather should be queued for - // later processing by the main event loop - virtual bool IsEventAllowedInsideYield(wxEventCategory cat) const - { return (m_eventsToProcessInsideYield & cat) != 0; } - - // no SafeYield hooks since it uses wxWindow which is not available when wxUSE_GUI=0 - - - // active loop - // ----------- - // return currently active (running) event loop, may be NULL - static wxEventLoopBase *GetActive() { return ms_activeLoop; } + static wxEventLoop *GetActive() { return ms_activeLoop; } // set currently active (running) event loop - static void SetActive(wxEventLoopBase* loop); + static void SetActive(wxEventLoop* loop) { ms_activeLoop = loop; } + // is this event loop running now? + // + // notice that even if this event loop hasn't terminated yet but has just + // spawned a nested (e.g. modal) event loop, this would return false + bool IsRunning() const; protected: - // real implementation of Run() - virtual int DoRun() = 0; - // this function should be called before the event loop terminates, whether // this happens normally (because of Exit() call) or abnormally (because of // an exception thrown from inside the loop) - virtual void OnExit(); - - // Return true if we're currently inside our Run(), even if another nested - // event loop is currently running, unlike IsRunning() (which should have - // been really called IsActive() but it's too late to change this now). - bool IsInsideRun() const { return m_isInsideRun; } + virtual void OnExit() { } // the pointer to currently active loop - static wxEventLoopBase *ms_activeLoop; + static wxEventLoop *ms_activeLoop; - // should we exit the loop? - bool m_shouldExit; - - // YieldFor() helpers: - bool m_isInsideYield; - long m_eventsToProcessInsideYield; - -private: - // this flag is set on entry into Run() and reset before leaving it - bool m_isInsideRun; - - wxDECLARE_NO_COPY_CLASS(wxEventLoopBase); + DECLARE_NO_COPY_CLASS(wxEventLoopBase) }; -#if defined(__WINDOWS__) || defined(__WXMAC__) || defined(__WXDFB__) || (defined(__UNIX__) && !defined(__WXOSX__)) +#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__) // this class can be used to implement a standard event loop logic using // Pending() and Dispatch() // // it also handles idle processing automatically -class WXDLLIMPEXP_BASE wxEventLoopManual : public wxEventLoopBase +class WXDLLEXPORT wxEventLoopManual : public wxEventLoopBase { public: wxEventLoopManual(); - // sets the "should exit" flag and wakes up the loop so that it terminates - // soon - virtual void ScheduleExit(int rc = 0); - -protected: // enters a loop calling OnNextIteration(), Pending() and Dispatch() and // terminating when Exit() is called - virtual int DoRun(); + virtual int Run(); + + // sets the "should exit" flag and wakes up the loop so that it terminates + // soon + virtual void Exit(int rc = 0); + +protected: + // implement this to wake up the loop: usually done by posting a dummy event + // to it (called from Exit()) + virtual void WakeUp() = 0; // may be overridden to perform some action at the start of each new event // loop iteration @@ -238,14 +98,8 @@ protected: // the loop exit code int m_exitcode; -private: - // process all already pending events and dispatch a new one (blocking - // until it appears in the event queue if necessary) - // - // returns the return value of Dispatch() - bool ProcessEvents(); - - wxDECLARE_NO_COPY_CLASS(wxEventLoopManual); + // should we exit the loop? + bool m_shouldExit; }; #endif // platforms using "manual" loop @@ -253,98 +107,42 @@ private: // we're moving away from old m_impl wxEventLoop model as otherwise the user // code doesn't have access to platform-specific wxEventLoop methods and this // can sometimes be very useful (e.g. under MSW this is necessary for -// integration with MFC) but currently this is not done for all ports yet (e.g. -// wxX11) so fall back to the old wxGUIEventLoop definition below for them - -#if defined(__DARWIN__) - // CoreFoundation-based event loop is currently in wxBase so include it in - // any case too (although maybe it actually shouldn't be there at all) - #include "wx/osx/core/evtloop.h" -#endif - -// include the header defining wxConsoleEventLoop -#if defined(__UNIX__) && !defined(__WINDOWS__) - #include "wx/unix/evtloop.h" -#elif defined(__WINDOWS__) - #include "wx/msw/evtloopconsole.h" -#endif - -#if wxUSE_GUI - -// include the appropriate header defining wxGUIEventLoop - -#if defined(__WXMSW__) +// integration with MFC) but currently this is done for MSW only, other ports +// should follow a.s.a.p. +#if defined(__WXPALMOS__) + #include "wx/palmos/evtloop.h" +#elif defined(__WXMSW__) #include "wx/msw/evtloop.h" -#elif defined(__WXCOCOA__) - #include "wx/cocoa/evtloop.h" -#elif defined(__WXOSX__) - #include "wx/osx/evtloop.h" +#elif defined(__WXMAC__) + #include "wx/mac/evtloop.h" #elif defined(__WXDFB__) #include "wx/dfb/evtloop.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/evtloop.h" #else // other platform -#include "wx/stopwatch.h" // for wxMilliClock_t +class WXDLLEXPORT wxEventLoopImpl; -class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl; - -class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxEventLoopBase +class WXDLLEXPORT wxEventLoop : public wxEventLoopBase { public: - wxGUIEventLoop() { m_impl = NULL; } - virtual ~wxGUIEventLoop(); + wxEventLoop() { m_impl = NULL; } + virtual ~wxEventLoop(); - virtual void ScheduleExit(int rc = 0); + virtual int Run(); + virtual void Exit(int rc = 0); virtual bool Pending() const; virtual bool Dispatch(); - virtual int DispatchTimeout(unsigned long timeout) - { - // TODO: this is, of course, horribly inefficient and a proper wait with - // timeout should be implemented for all ports natively... - const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout; - for ( ;; ) - { - if ( Pending() ) - return Dispatch(); - - if ( wxGetLocalTimeMillis() >= timeEnd ) - return -1; - } - } - virtual void WakeUp() { } - virtual bool YieldFor(long eventsToProcess); protected: - virtual int DoRun(); - // the pointer to the port specific implementation class wxEventLoopImpl *m_impl; - wxDECLARE_NO_COPY_CLASS(wxGUIEventLoop); + DECLARE_NO_COPY_CLASS(wxEventLoop) }; #endif // platforms -#endif // wxUSE_GUI - -#if wxUSE_GUI - // we use a class rather than a typedef because wxEventLoop is - // forward-declared in many places - class wxEventLoop : public wxGUIEventLoop { }; -#else // !wxUSE_GUI - // we can't define wxEventLoop differently in GUI and base libraries so use - // a #define to still allow writing wxEventLoop in the user code - #if wxUSE_CONSOLE_EVENTLOOP && (defined(__WINDOWS__) || defined(__UNIX__)) - #define wxEventLoop wxConsoleEventLoop - #else // we still must define it somehow for the code below... - #define wxEventLoop wxEventLoopBase - #endif -#endif - inline bool wxEventLoopBase::IsRunning() const { return GetActive() == this; } -#if wxUSE_GUI && !defined(__WXOSX__) // ---------------------------------------------------------------------------- // wxModalEventLoop // ---------------------------------------------------------------------------- @@ -353,7 +151,7 @@ inline bool wxEventLoopBase::IsRunning() const { return GetActive() == this; } // implement modality, we will surely need platform-specific implementations // too, this generic implementation is here only temporarily to see how it // works -class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop +class WXDLLEXPORT wxModalEventLoop : public wxEventLoop { public: wxModalEventLoop(wxWindow *winModal) @@ -367,15 +165,13 @@ protected: delete m_windowDisabler; m_windowDisabler = NULL; - wxGUIEventLoop::OnExit(); + wxEventLoop::OnExit(); } private: wxWindowDisabler *m_windowDisabler; }; -#endif //wxUSE_GUI - // ---------------------------------------------------------------------------- // wxEventLoopActivator: helper class for wxEventLoop implementations // ---------------------------------------------------------------------------- @@ -386,24 +182,23 @@ private: class wxEventLoopActivator { public: - wxEventLoopActivator(wxEventLoopBase *evtLoop) + wxEventLoopActivator(wxEventLoop *evtLoop) { - m_evtLoopOld = wxEventLoopBase::GetActive(); - wxEventLoopBase::SetActive(evtLoop); + m_evtLoopOld = wxEventLoop::GetActive(); + wxEventLoop::SetActive(evtLoop); } ~wxEventLoopActivator() { // restore the previously active event loop - wxEventLoopBase::SetActive(m_evtLoopOld); + wxEventLoop::SetActive(m_evtLoopOld); } private: - wxEventLoopBase *m_evtLoopOld; + wxEventLoop *m_evtLoopOld; }; -#if wxUSE_GUI || wxUSE_CONSOLE_EVENTLOOP - +#if wxABI_VERSION >= 20808 class wxEventLoopGuarantor { public: @@ -429,7 +224,6 @@ public: private: wxEventLoop *m_evtLoopNew; }; - -#endif // wxUSE_GUI || wxUSE_CONSOLE_EVENTLOOP +#endif // wxABI_VERSION >= 20805 #endif // _WX_EVTLOOP_H_ diff --git a/Source/3rd Party/wx/include/wx/evtloopsrc.h b/Source/3rd Party/wx/include/wx/evtloopsrc.h deleted file mode 100644 index cb3e5c6a9..000000000 --- a/Source/3rd Party/wx/include/wx/evtloopsrc.h +++ /dev/null @@ -1,103 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/evtloopsrc.h -// Purpose: declaration of wxEventLoopSource class -// Author: Vadim Zeitlin -// Created: 2009-10-21 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_EVTLOOPSRC_H_ -#define _WX_EVTLOOPSRC_H_ - -// Include the header to get wxUSE_EVENTLOOP_SOURCE definition from it. -#include "wx/evtloop.h" - -// ---------------------------------------------------------------------------- -// wxEventLoopSource: a source of events which may be added to wxEventLoop -// ---------------------------------------------------------------------------- - -// TODO: refactor wxSocket under Unix to reuse wxEventLoopSource instead of -// duplicating much of its logic -// -// TODO: freeze the API and document it - -#if wxUSE_EVENTLOOP_SOURCE - -#define wxTRACE_EVT_SOURCE "EventSource" - -// handler used to process events on event loop sources -class wxEventLoopSourceHandler -{ -public: - // called when descriptor is available for non-blocking read - virtual void OnReadWaiting() = 0; - - // called when descriptor is available for non-blocking write - virtual void OnWriteWaiting() = 0; - - // called when there is exception on descriptor - virtual void OnExceptionWaiting() = 0; - - // virtual dtor for the base class - virtual ~wxEventLoopSourceHandler() { } -}; - -// flags describing which kind of IO events we're interested in -enum -{ - wxEVENT_SOURCE_INPUT = 0x01, - wxEVENT_SOURCE_OUTPUT = 0x02, - wxEVENT_SOURCE_EXCEPTION = 0x04, - wxEVENT_SOURCE_ALL = wxEVENT_SOURCE_INPUT | - wxEVENT_SOURCE_OUTPUT | - wxEVENT_SOURCE_EXCEPTION -}; - -// wxEventLoopSource itself is an ABC and can't be created directly, currently -// the only way to create it is by using wxEventLoop::AddSourceForFD(). -class wxEventLoopSource -{ -public: - // dtor is pure virtual because it must be overridden to remove the source - // from the event loop monitoring it - virtual ~wxEventLoopSource() = 0; - - void SetHandler(wxEventLoopSourceHandler* handler) { m_handler = handler; } - wxEventLoopSourceHandler* GetHandler() const { return m_handler; } - - void SetFlags(int flags) { m_flags = flags; } - int GetFlags() const { return m_flags; } - -protected: - // ctor is only used by the derived classes - wxEventLoopSource(wxEventLoopSourceHandler *handler, int flags) - : m_handler(handler), - m_flags(flags) - { - } - - wxEventLoopSourceHandler* m_handler; - int m_flags; - - wxDECLARE_NO_COPY_CLASS(wxEventLoopSource); -}; - -inline wxEventLoopSource::~wxEventLoopSource() { } - -#if defined(__UNIX__) - #include "wx/unix/evtloopsrc.h" -#endif // __UNIX__ - -#if defined(__WXGTK20__) - #include "wx/gtk/evtloopsrc.h" -#endif - -#if defined(__DARWIN__) - #include "wx/osx/evtloopsrc.h" -#endif - -#endif // wxUSE_EVENTLOOP_SOURCE - -#endif // _WX_EVTLOOPSRC_H_ - diff --git a/Source/3rd Party/wx/include/wx/except.h b/Source/3rd Party/wx/include/wx/except.h index 02dac3d4b..f6310a57f 100644 --- a/Source/3rd Party/wx/include/wx/except.h +++ b/Source/3rd Party/wx/include/wx/except.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 17.09.2003 +// RCS-ID: $Id: except.h 27408 2004-05-23 20:53:33Z JS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,24 +18,13 @@ // macros working whether wxUSE_EXCEPTIONS is 0 or 1 // ---------------------------------------------------------------------------- -// even if the library itself was compiled with exceptions support, the user -// code using it might be compiling with a compiler switch disabling them in -// which cases we shouldn't use try/catch in the headers -- this results in -// compilation errors in e.g. wx/scopeguard.h with at least g++ 4 -#if !wxUSE_EXCEPTIONS || \ - (defined(__GNUG__) && !defined(__EXCEPTIONS)) - #ifndef wxNO_EXCEPTIONS - #define wxNO_EXCEPTIONS - #endif -#endif - -#ifdef wxNO_EXCEPTIONS - #define wxTRY - #define wxCATCH_ALL(code) -#else // do use exceptions +#if wxUSE_EXCEPTIONS #define wxTRY try #define wxCATCH_ALL(code) catch ( ... ) { code } -#endif // wxNO_EXCEPTIONS/!wxNO_EXCEPTIONS +#else // !wxUSE_EXCEPTIONS + #define wxTRY + #define wxCATCH_ALL(code) +#endif // wxUSE_EXCEPTIONS/!wxUSE_EXCEPTIONS #endif // _WX_EXCEPT_H_ diff --git a/Source/3rd Party/wx/include/wx/fdrepdlg.h b/Source/3rd Party/wx/include/wx/fdrepdlg.h index 05b80b9e8..87d154497 100644 --- a/Source/3rd Party/wx/include/wx/fdrepdlg.h +++ b/Source/3rd Party/wx/include/wx/fdrepdlg.h @@ -4,6 +4,7 @@ // Author: Markus Greither and Vadim Zeitlin // Modified by: // Created: 23/03/2001 +// RCS-ID: // Copyright: (c) Markus Greither // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -59,15 +60,15 @@ enum wxFindReplaceDialogStyles // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFindReplaceData : public wxObject +class WXDLLEXPORT wxFindReplaceData : public wxObject { public: wxFindReplaceData() { Init(); } wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); } // accessors - const wxString& GetFindString() const { return m_FindWhat; } - const wxString& GetReplaceString() const { return m_ReplaceWith; } + const wxString& GetFindString() { return m_FindWhat; } + const wxString& GetReplaceString() { return m_ReplaceWith; } int GetFlags() const { return m_Flags; } @@ -92,7 +93,7 @@ private: // wxFindReplaceDialogBase // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFindReplaceDialogBase : public wxDialog +class WXDLLEXPORT wxFindReplaceDialogBase : public wxDialog { public: // ctors and such @@ -120,7 +121,7 @@ protected: // the last string we searched for wxString m_lastSearch; - wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase); + DECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase) }; // include wxFindReplaceDialog declaration @@ -136,13 +137,11 @@ protected: // wxFindReplaceDialog events // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFindDialogEvent : public wxCommandEvent +class WXDLLEXPORT wxFindDialogEvent : public wxCommandEvent { public: wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0) : wxCommandEvent(commandType, id) { } - wxFindDialogEvent(const wxFindDialogEvent& event) - : wxCommandEvent(event), m_strReplace(event.m_strReplace) { } int GetFlags() const { return GetInt(); } wxString GetFindString() const { return GetString(); } @@ -156,46 +155,39 @@ public: void SetFindString(const wxString& str) { SetString(str); } void SetReplaceString(const wxString& str) { m_strReplace = str; } - virtual wxEvent *Clone() const { return new wxFindDialogEvent(*this); } - private: wxString m_strReplace; - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFindDialogEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxFindDialogEvent) }; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND, wxFindDialogEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_NEXT, wxFindDialogEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE, wxFindDialogEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE_ALL, wxFindDialogEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_CLOSE, wxFindDialogEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND, 510) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT, 511) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE, 512) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL, 513) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE, 514) +END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&); #define wxFindDialogEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxFindDialogEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFindDialogEventFunction, &func) #define EVT_FIND(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FIND, id, wxFindDialogEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_FIND, id, wxFindDialogEventHandler(fn)) #define EVT_FIND_NEXT(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FIND_NEXT, id, wxFindDialogEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_NEXT, id, wxFindDialogEventHandler(fn)) #define EVT_FIND_REPLACE(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FIND_REPLACE, id, wxFindDialogEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_REPLACE, id, wxFindDialogEventHandler(fn)) #define EVT_FIND_REPLACE_ALL(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn)) #define EVT_FIND_CLOSE(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FIND_CLOSE, id, wxFindDialogEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_FIND wxEVT_FIND -#define wxEVT_COMMAND_FIND_NEXT wxEVT_FIND_NEXT -#define wxEVT_COMMAND_FIND_REPLACE wxEVT_FIND_REPLACE -#define wxEVT_COMMAND_FIND_REPLACE_ALL wxEVT_FIND_REPLACE_ALL -#define wxEVT_COMMAND_FIND_CLOSE wxEVT_FIND_CLOSE + wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_CLOSE, id, wxFindDialogEventHandler(fn)) #endif // wxUSE_FINDREPLDLG diff --git a/Source/3rd Party/wx/include/wx/features.h b/Source/3rd Party/wx/include/wx/features.h index 8fa9fe302..953940a87 100644 --- a/Source/3rd Party/wx/include/wx/features.h +++ b/Source/3rd Party/wx/include/wx/features.h @@ -5,6 +5,7 @@ * Author: Vadim Zeitlin * Modified by: Ryan Norton (Converted to C) * Created: 18.03.02 +* RCS-ID: $Id: features.h 40865 2006-08-27 09:42:42Z VS $ * Copyright: (c) 2002 Vadim Zeitlin * Licence: wxWindows licence */ @@ -34,11 +35,9 @@ /* taskbar is implemented in the major ports */ #if defined(__WXMSW__) || defined(__WXCOCOA__) \ || defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__) \ - || defined(__WXOSX_MAC__) || defined(__WXCOCOA__) + || defined(__WXMAC_OSX__) || defined(__WXCOCOA__) #define wxHAS_TASK_BAR_ICON #else - #undef wxUSE_TASKBARICON - #define wxUSE_TASKBARICON 0 #undef wxHAS_TASK_BAR_ICON #endif @@ -61,66 +60,5 @@ #undef wxHAS_REGEX_ADVANCED #endif -/* Pango-based ports and wxDFB use UTF-8 for text and font encodings - * internally and so their fonts can handle any encodings: */ -#if wxUSE_PANGO || defined(__WXDFB__) - #define wxHAS_UTF8_FONTS -#endif - -/* This is defined when the underlying toolkit handles tab traversal natively. - Otherwise we implement it ourselves in wxControlContainer. */ -#ifdef __WXGTK20__ - #define wxHAS_NATIVE_TAB_TRAVERSAL -#endif - -/* This is defined when the compiler provides some type of extended locale - functions. Otherwise, we implement them ourselves to only support the - 'C' locale */ -#if defined(HAVE_LOCALE_T) || \ - (wxCHECK_VISUALC_VERSION(8) && !defined(__WXWINCE__)) - #define wxHAS_XLOCALE_SUPPORT -#else - #undef wxHAS_XLOCALE_SUPPORT -#endif - -/* Direct access to bitmap data is not implemented in all ports yet */ -#if defined(__WXGTK20__) || defined(__WXMAC__) || defined(__WXDFB__) || \ - defined(__WXMSW__) - - /* - These compilers can't deal with templates in wx/rawbmp.h: - - HP aCC for PA-RISC - - Watcom < 1.8 - */ - #if !wxONLY_WATCOM_EARLIER_THAN(1, 8) && \ - !(defined(__HP_aCC) && defined(__hppa)) - #define wxHAS_RAW_BITMAP - #endif -#endif - -/* also define deprecated synonym which exists for compatibility only */ -#ifdef wxHAS_RAW_BITMAP - #define wxHAVE_RAW_BITMAP -#endif - -/* - If this is defined, wxEvtHandler::Bind<>() is available (not all compilers - have the required template support for this and in particular under Windows - where only g++ and MSVC >= 7 currently support it. - - Recent Sun CC versions support this but perhaps older ones can compile this - code too, adjust the version check if this is the case (unfortunately we - can't easily test for the things used in wx/event.h in configure so we have - to maintain these checks manually). The same applies to xlC 7: perhaps - earlier versions can compile this code too but they were not tested. - */ -#if wxCHECK_GCC_VERSION(3, 2) || wxCHECK_VISUALC_VERSION(7) \ - || (defined(__SUNCC__) && __SUNCC__ >= 0x5100) \ - || (defined(__xlC__) && __xlC__ >= 0x700) \ - || defined(__INTELC__) - #define wxHAS_EVENT_BIND -#endif - - #endif /* _WX_FEATURES_H_ */ diff --git a/Source/3rd Party/wx/include/wx/ffile.h b/Source/3rd Party/wx/include/wx/ffile.h index c6b128342..26f1b4e3e 100644 --- a/Source/3rd Party/wx/include/wx/ffile.h +++ b/Source/3rd Party/wx/include/wx/ffile.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 14.07.99 +// RCS-ID: $Id: ffile.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,20 +37,20 @@ public: // def ctor wxFFile() { m_fp = NULL; } // open specified file (may fail, use IsOpened()) - wxFFile(const wxString& filename, const wxString& mode = wxT("r")); + wxFFile(const wxChar *filename, const wxChar *mode = wxT("r")); // attach to (already opened) file wxFFile(FILE *lfp) { m_fp = lfp; } // open/close // open a file (existing or not - the mode controls what happens) - bool Open(const wxString& filename, const wxString& mode = wxT("r")); + bool Open(const wxChar *filename, const wxChar *mode = wxT("r")); // closes the opened file (this is a NOP if not opened) bool Close(); // assign an existing file descriptor and get it back from wxFFile object void Attach(FILE *lfp, const wxString& name = wxEmptyString) { Close(); m_fp = lfp; m_name = name; } - FILE* Detach() { FILE* fpOld = m_fp; m_fp = NULL; return fpOld; } + void Detach() { m_fp = NULL; } FILE *fp() const { return m_fp; } // read/write (unbuffered) @@ -61,7 +62,12 @@ public: // returns the number of bytes written size_t Write(const void *pBuf, size_t nCount); // returns true on success - bool Write(const wxString& s, const wxMBConv& conv = wxConvAuto()); + bool Write(const wxString& s, const wxMBConv& conv = wxConvAuto()) + { + const wxWX2MBbuf buf = s.mb_str(conv); + size_t size = strlen(buf); + return Write((const char *)buf, size) == size; + } // flush data not yet written bool Flush(); diff --git a/Source/3rd Party/wx/include/wx/file.h b/Source/3rd Party/wx/include/wx/file.h index b1ae3cff1..a2ccd4223 100644 --- a/Source/3rd Party/wx/include/wx/file.h +++ b/Source/3rd Party/wx/include/wx/file.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/file.h +// Name: file.h // Purpose: wxFile - encapsulates low-level "file descriptor" // wxTempFile - safely replace the old file // Author: Vadim Zeitlin // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: file.h 46331 2007-06-05 13:16:11Z JS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,7 +19,29 @@ #include "wx/string.h" #include "wx/filefn.h" -#include "wx/convauto.h" +#include "wx/strconv.h" + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// we redefine these constants here because S_IREAD &c are _not_ standard +// however, we do assume that the values correspond to the Unix umask bits +#define wxS_IRUSR 00400 +#define wxS_IWUSR 00200 +#define wxS_IXUSR 00100 + +#define wxS_IRGRP 00040 +#define wxS_IWGRP 00020 +#define wxS_IXGRP 00010 + +#define wxS_IROTH 00004 +#define wxS_IWOTH 00002 +#define wxS_IXOTH 00001 + +// default mode for the new files: corresponds to umask 022 +#define wxS_DEFAULT (wxS_IRUSR | wxS_IWUSR | wxS_IRGRP | wxS_IWGRP |\ + wxS_IROTH | wxS_IWOTH) // ---------------------------------------------------------------------------- // class wxFile: raw file IO @@ -40,43 +63,48 @@ public: // static functions // ---------------- // check whether a regular file by this name exists - static bool Exists(const wxString& name); + static bool Exists(const wxChar *name); // check whether we can access the given file in given mode // (only read and write make sense here) - static bool Access(const wxString& name, OpenMode mode); + static bool Access(const wxChar *name, OpenMode mode); // ctors // ----- // def ctor - wxFile() { m_fd = fd_invalid; m_lasterror = 0; } + wxFile() { m_fd = fd_invalid; m_error = false; } // open specified file (may fail, use IsOpened()) - wxFile(const wxString& fileName, OpenMode mode = read); + wxFile(const wxChar *szFileName, OpenMode mode = read); // attach to (already opened) file - wxFile(int lfd) { m_fd = lfd; m_lasterror = 0; } + wxFile(int lfd) { m_fd = lfd; m_error = false; } // open/close // create a new file (with the default value of bOverwrite, it will fail if // the file already exists, otherwise it will overwrite it and succeed) - bool Create(const wxString& fileName, bool bOverwrite = false, + bool Create(const wxChar *szFileName, bool bOverwrite = false, int access = wxS_DEFAULT); - bool Open(const wxString& fileName, OpenMode mode = read, + bool Open(const wxChar *szFileName, OpenMode mode = read, int access = wxS_DEFAULT); bool Close(); // Close is a NOP if not opened // assign an existing file descriptor and get it back from wxFile object - void Attach(int lfd) { Close(); m_fd = lfd; m_lasterror = 0; } - int Detach() { int fdOld = m_fd; m_fd = fd_invalid; return fdOld; } + void Attach(int lfd) { Close(); m_fd = lfd; m_error = false; } + void Detach() { m_fd = fd_invalid; } int fd() const { return m_fd; } // read/write (unbuffered) - // read all data from the file into a string (useful for text files) - bool ReadAll(wxString *str, const wxMBConv& conv = wxConvAuto()); // returns number of bytes read or wxInvalidOffset on error ssize_t Read(void *pBuf, size_t nCount); // returns the number of bytes written size_t Write(const void *pBuf, size_t nCount); // returns true on success - bool Write(const wxString& s, const wxMBConv& conv = wxConvAuto()); + bool Write(const wxString& s, const wxMBConv& conv = wxConvUTF8) + { + const wxWX2MBbuf buf = s.mb_str(conv); + if (!buf) + return false; + size_t size = strlen(buf); + return Write((const char *) buf, size) == size; + } // flush data not yet written bool Flush(); @@ -96,15 +124,10 @@ public: // is end of file reached? bool Eof() const; // has an error occurred? - bool Error() const { return m_lasterror != 0; } - // get last errno - int GetLastError() const { return m_lasterror; } - // reset error state - void ClearLastError() { m_lasterror = 0; } + bool Error() const { return m_error; } // type such as disk or pipe wxFileKind GetKind() const { return wxGetFileKind(m_fd); } - // dtor closes the file if opened ~wxFile() { Close(); } @@ -115,16 +138,8 @@ private: wxFile(const wxFile&); wxFile& operator=(const wxFile&); - // Copy the value of errno into m_lasterror if rc == -1 and return true in - // this case (indicating that we've got an error). Otherwise return false. - // - // Notice that we use the possibly 64 bit wxFileOffset instead of int here so - // that it works for checking the result of functions such as tell() too. - bool CheckForError(wxFileOffset rc) const; - - int m_fd; // file descriptor or INVALID_FD if not opened - int m_lasterror; // errno value of last error + bool m_error; // error memory }; // ---------------------------------------------------------------------------- @@ -159,13 +174,9 @@ public: // I/O (both functions return true on success, false on failure) bool Write(const void *p, size_t n) { return m_file.Write(p, n) == n; } - bool Write(const wxString& str, const wxMBConv& conv = wxMBConvUTF8()) + bool Write(const wxString& str, const wxMBConv& conv = wxConvUTF8) { return m_file.Write(str, conv); } - // flush data: can be called before closing file to ensure that data was - // correctly written out - bool Flush() { return m_file.Flush(); } - // different ways to close the file // validate changes and delete the old file of name m_strName bool Commit(); diff --git a/Source/3rd Party/wx/include/wx/fileconf.h b/Source/3rd Party/wx/include/wx/fileconf.h index bfda4494f..47c483f26 100644 --- a/Source/3rd Party/wx/include/wx/fileconf.h +++ b/Source/3rd Party/wx/include/wx/fileconf.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 07.04.98 (adapted from appconf.cpp) +// RCS-ID: $Id: fileconf.h 50711 2007-12-15 02:57:58Z VZ $ // Copyright: (c) 1997 Karsten Ballueder & Vadim Zeitlin // Ballueder@usa.net // Licence: wxWindows licence @@ -19,7 +20,6 @@ #include "wx/textfile.h" #include "wx/string.h" #include "wx/confbase.h" -#include "wx/filename.h" // ---------------------------------------------------------------------------- // wxFileConfig @@ -111,18 +111,8 @@ public: // // where file is the basename of szFile, ext is its extension // or .conf (Unix) or .ini (Win) if it has none - static wxFileName GetGlobalFile(const wxString& szFile); - static wxFileName GetLocalFile(const wxString& szFile, int style = 0); - - static wxString GetGlobalFileName(const wxString& szFile) - { - return GetGlobalFile(szFile).GetFullPath(); - } - - static wxString GetLocalFileName(const wxString& szFile, int style = 0) - { - return GetLocalFile(szFile, style).GetFullPath(); - } + static wxString GetGlobalFileName(const wxChar *szFile); + static wxString GetLocalFileName(const wxChar *szFile); // ctor & dtor // New constructor: one size fits all. Specify wxCONFIG_USE_LOCAL_FILE or @@ -152,7 +142,7 @@ public: // implement inherited pure virtual functions virtual void SetPath(const wxString& strPath); - virtual const wxString& GetPath() const; + virtual const wxString& GetPath() const { return m_strPath; } virtual bool GetFirstGroup(wxString& str, long& lIndex) const; virtual bool GetNextGroup (wxString& str, long& lIndex) const; @@ -193,20 +183,14 @@ public: protected: virtual bool DoReadString(const wxString& key, wxString *pStr) const; virtual bool DoReadLong(const wxString& key, long *pl) const; -#if wxUSE_BASE64 - virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const; -#endif // wxUSE_BASE64 virtual bool DoWriteString(const wxString& key, const wxString& szValue); virtual bool DoWriteLong(const wxString& key, long lValue); -#if wxUSE_BASE64 - virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf); -#endif // wxUSE_BASE64 private: // GetXXXFileName helpers: return ('/' terminated) directory names static wxString GetGlobalDir(); - static wxString GetLocalDir(int style = 0); + static wxString GetLocalDir(); // common part of all ctors (assumes that m_str{Local|Global}File are already // initialized @@ -236,8 +220,8 @@ private: wxFileConfigLineList *m_linesHead, // head of the linked list *m_linesTail; // tail - wxFileName m_fnLocalFile, // local file name passed to ctor - m_fnGlobalFile; // global + wxString m_strLocalFile, // local file name passed to ctor + m_strGlobalFile; // global wxString m_strPath; // current path (not '/' terminated) wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group @@ -251,8 +235,7 @@ private: bool m_isDirty; // if true, we have unsaved changes - wxDECLARE_NO_COPY_CLASS(wxFileConfig); - DECLARE_ABSTRACT_CLASS(wxFileConfig) + DECLARE_NO_COPY_CLASS(wxFileConfig) }; #endif diff --git a/Source/3rd Party/wx/include/wx/filectrl.h b/Source/3rd Party/wx/include/wx/filectrl.h deleted file mode 100644 index e4c302f7d..000000000 --- a/Source/3rd Party/wx/include/wx/filectrl.h +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/filectrl.h -// Purpose: Header for wxFileCtrlBase and other common functions used by -// platform-specific wxFileCtrl's -// Author: Diaa M. Sami -// Modified by: -// Created: Jul-07-2007 -// Copyright: (c) Diaa M. Sami -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FILECTRL_H_BASE_ -#define _WX_FILECTRL_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_FILECTRL - -#include "wx/string.h" -#include "wx/event.h" - -enum -{ - wxFC_OPEN = 0x0001, - wxFC_SAVE = 0x0002, - wxFC_MULTIPLE = 0x0004, - wxFC_NOSHOWHIDDEN = 0x0008 -}; - -#define wxFC_DEFAULT_STYLE wxFC_OPEN -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileCtrlNameStr[]; // in filectrlcmn.cpp - -class WXDLLIMPEXP_CORE wxFileCtrlBase -{ -public: - virtual ~wxFileCtrlBase() {} - - virtual void SetWildcard( const wxString& wildCard ) = 0; - virtual void SetFilterIndex( int filterindex ) = 0; - virtual bool SetDirectory( const wxString& dir ) = 0; - - // Selects a certain file. - // In case the filename specified isn't found/couldn't be shown with - // currently selected filter, false is returned and nothing happens - virtual bool SetFilename( const wxString& name ) = 0; - - // chdirs to a certain directory and selects a certain file. - // In case the filename specified isn't found/couldn't be shown with - // currently selected filter, false is returned and if directory exists - // it's chdir'ed to - virtual bool SetPath( const wxString& path ) = 0; - - virtual wxString GetFilename() const = 0; - virtual wxString GetDirectory() const = 0; - virtual wxString GetWildcard() const = 0; - virtual wxString GetPath() const = 0; - virtual void GetPaths( wxArrayString& paths ) const = 0; - virtual void GetFilenames( wxArrayString& files ) const = 0; - virtual int GetFilterIndex() const = 0; - - virtual bool HasMultipleFileSelection() const = 0; - virtual void ShowHidden(bool show) = 0; -}; - -void GenerateFilterChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd ); -void GenerateFolderChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd ); -void GenerateSelectionChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd ); -void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const wxString filename = wxEmptyString ); - -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) - #define wxFileCtrl wxGtkFileCtrl - #include "wx/gtk/filectrl.h" -#else - #define wxFileCtrl wxGenericFileCtrl - #include "wx/generic/filectrlg.h" -#endif - -// Some documentation -// On wxEVT_FILECTRL_FILTERCHANGED, only the value returned by GetFilterIndex is -// valid and it represents the (new) current filter index for the wxFileCtrl. -// On wxEVT_FILECTRL_FOLDERCHANGED, only the value returned by GetDirectory is -// valid and it represents the (new) current directory for the wxFileCtrl. -// On wxEVT_FILECTRL_FILEACTIVATED, GetDirectory returns the current directory -// for the wxFileCtrl and GetFiles returns the names of the file(s) activated. -// On wxEVT_FILECTRL_SELECTIONCHANGED, GetDirectory returns the current directory -// for the wxFileCtrl and GetFiles returns the names of the currently selected -// file(s). -// In wxGTK, after each wxEVT_FILECTRL_FOLDERCHANGED, wxEVT_FILECTRL_SELECTIONCHANGED -// is fired automatically once or more with 0 files. -class WXDLLIMPEXP_CORE wxFileCtrlEvent : public wxCommandEvent -{ -public: - wxFileCtrlEvent() {} - wxFileCtrlEvent( wxEventType type, wxObject *evtObject, int id ) - : wxCommandEvent( type, id ) - { - SetEventObject( evtObject ); - } - - // no need for the copy constructor as the default one will be fine. - virtual wxEvent *Clone() const { return new wxFileCtrlEvent( *this ); } - - void SetFiles( const wxArrayString &files ) { m_files = files; } - void SetDirectory( const wxString &directory ) { m_directory = directory; } - void SetFilterIndex( int filterIndex ) { m_filterIndex = filterIndex; } - - wxArrayString GetFiles() const { return m_files; } - wxString GetDirectory() const { return m_directory; } - int GetFilterIndex() const { return m_filterIndex; } - - wxString GetFile() const; - -protected: - int m_filterIndex; - wxString m_directory; - wxArrayString m_files; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent ) -}; - -typedef void ( wxEvtHandler::*wxFileCtrlEventFunction )( wxFileCtrlEvent& ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_SELECTIONCHANGED, wxFileCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILEACTIVATED, wxFileCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FOLDERCHANGED, wxFileCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILTERCHANGED, wxFileCtrlEvent ); - -#define wxFileCtrlEventHandler(func) \ - wxEVENT_HANDLER_CAST( wxFileCtrlEventFunction, func ) - -#define EVT_FILECTRL_FILEACTIVATED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FILECTRL_FILEACTIVATED, id, wxFileCtrlEventHandler(fn)) - -#define EVT_FILECTRL_SELECTIONCHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FILECTRL_SELECTIONCHANGED, id, wxFileCtrlEventHandler(fn)) - -#define EVT_FILECTRL_FOLDERCHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn)) - -#define EVT_FILECTRL_FILTERCHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FILECTRL_FILTERCHANGED, id, wxFileCtrlEventHandler(fn)) - -#endif // wxUSE_FILECTRL - -#endif // _WX_FILECTRL_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/filedlg.h b/Source/3rd Party/wx/include/wx/filedlg.h index 8bed418e9..0e247b358 100644 --- a/Source/3rd Party/wx/include/wx/filedlg.h +++ b/Source/3rd Party/wx/include/wx/filedlg.h @@ -5,6 +5,7 @@ // Modified by: // Created: 8/17/99 // Copyright: (c) Robert Roebling +// RCS-ID: $Id: filedlg.h 44027 2006-12-21 19:26:48Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,12 +19,6 @@ #include "wx/dialog.h" #include "wx/arrstr.h" -// this symbol is defined for the platforms which support multiple -// ('|'-separated) filters in the file dialog -#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXMAC__) - #define wxHAS_MULTIPLE_FILEDLG_FILTERS -#endif - //---------------------------------------------------------------------------- // wxFileDialog data //---------------------------------------------------------------------------- @@ -55,6 +50,9 @@ enum wxOPEN = wxFD_OPEN, wxSAVE = wxFD_SAVE, wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT, +#if WXWIN_COMPATIBILITY_2_4 + wxHIDE_READONLY = 0x0008, +#endif wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST, wxMULTIPLE = wxFD_MULTIPLE, wxCHANGE_DIR = wxFD_CHANGE_DIR @@ -63,15 +61,15 @@ enum #define wxFD_DEFAULT_STYLE wxFD_OPEN -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileDialogNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorPromptStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[]; //---------------------------------------------------------------------------- // wxFileDialogBase //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFileDialogBase: public wxDialog +class WXDLLEXPORT wxFileDialogBase: public wxDialog { public: wxFileDialogBase () { Init(); } @@ -90,9 +88,6 @@ public: Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name); } - virtual ~wxFileDialogBase() {} - - bool Create(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, const wxString& defaultDir = wxEmptyString, @@ -106,9 +101,9 @@ public: bool HasFdFlag(int flag) const { return HasFlag(flag); } virtual void SetMessage(const wxString& message) { m_message = message; } - virtual void SetPath(const wxString& path); - virtual void SetDirectory(const wxString& dir); - virtual void SetFilename(const wxString& name); + virtual void SetPath(const wxString& path) { m_path = path; } + virtual void SetDirectory(const wxString& dir) { m_dir = dir; } + virtual void SetFilename(const wxString& name) { m_fileName = name; } virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } @@ -121,20 +116,19 @@ public: virtual wxString GetWildcard() const { return m_wildCard; } virtual int GetFilterIndex() const { return m_filterIndex; } - virtual wxString GetCurrentlySelectedFilename() const - { return m_currentlySelectedFilename; } - - // this function is called with wxFileDialog as parameter and should - // create the window containing the extra controls we want to show in it - typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*); - - virtual bool SupportsExtraControl() const { return false; } - - bool SetExtraControlCreator(ExtraControlCreatorFunction creator); - wxWindow *GetExtraControl() const { return m_extraControl; } - // Utility functions +#if WXWIN_COMPATIBILITY_2_4 + // Parses the wildCard, returning the number of filters. + // Returns 0 if none or if there's a problem, + // The arrays will contain an equal number of items found before the error. + // wildCard is in the form: + // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png" + wxDEPRECATED( static int ParseWildcard(const wxString& wildCard, + wxArrayString& descriptions, + wxArrayString& filters) ); +#endif // WXWIN_COMPATIBILITY_2_4 + #if WXWIN_COMPATIBILITY_2_6 wxDEPRECATED( long GetStyle() const ); @@ -158,89 +152,73 @@ protected: wxString m_wildCard; int m_filterIndex; - // Currently selected, but not yet necessarily accepted by the user, file. - // This should be updated whenever the selection in the control changes by - // the platform-specific code to provide a useful implementation of - // GetCurrentlySelectedFilename(). - wxString m_currentlySelectedFilename; - - wxWindow* m_extraControl; - - // returns true if control is created (if it already exists returns false) - bool CreateExtraControl(); - // return true if SetExtraControlCreator() was called - bool HasExtraControlCreator() const - { return m_extraControlCreator != NULL; } - // get the size of the extra control by creating and deleting it - wxSize GetExtraControlSize(); - private: - ExtraControlCreatorFunction m_extraControlCreator; - void Init(); DECLARE_DYNAMIC_CLASS(wxFileDialogBase) - wxDECLARE_NO_COPY_CLASS(wxFileDialogBase); + DECLARE_NO_COPY_CLASS(wxFileDialogBase) }; - //---------------------------------------------------------------------------- // wxFileDialog convenience functions //---------------------------------------------------------------------------- // File selector - backward compatibility -WXDLLIMPEXP_CORE wxString -wxFileSelector(const wxString& message = wxFileSelectorPromptStr, - const wxString& default_path = wxEmptyString, - const wxString& default_filename = wxEmptyString, - const wxString& default_extension = wxEmptyString, - const wxString& wildcard = wxFileSelectorDefaultWildcardStr, +WXDLLEXPORT wxString +wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, + const wxChar *default_path = NULL, + const wxChar *default_filename = NULL, + const wxChar *default_extension = NULL, + const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, wxWindow *parent = NULL, int x = wxDefaultCoord, int y = wxDefaultCoord); // An extended version of wxFileSelector -WXDLLIMPEXP_CORE wxString -wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr, - const wxString& default_path = wxEmptyString, - const wxString& default_filename = wxEmptyString, +WXDLLEXPORT wxString +wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, + const wxChar *default_path = NULL, + const wxChar *default_filename = NULL, int *indexDefaultExtension = NULL, - const wxString& wildcard = wxFileSelectorDefaultWildcardStr, + const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, wxWindow *parent = NULL, int x = wxDefaultCoord, int y = wxDefaultCoord); // Ask for filename to load -WXDLLIMPEXP_CORE wxString -wxLoadFileSelector(const wxString& what, - const wxString& extension, - const wxString& default_name = wxEmptyString, - wxWindow *parent = NULL); +WXDLLEXPORT wxString +wxLoadFileSelector(const wxChar *what, + const wxChar *extension, + const wxChar *default_name = (const wxChar *)NULL, + wxWindow *parent = (wxWindow *) NULL); // Ask for filename to save -WXDLLIMPEXP_CORE wxString -wxSaveFileSelector(const wxString& what, - const wxString& extension, - const wxString& default_name = wxEmptyString, - wxWindow *parent = NULL); +WXDLLEXPORT wxString +wxSaveFileSelector(const wxChar *what, + const wxChar *extension, + const wxChar *default_name = (const wxChar *) NULL, + wxWindow *parent = (wxWindow *) NULL); #if defined (__WXUNIVERSAL__) - #define wxHAS_GENERIC_FILEDIALOG - #include "wx/generic/filedlgg.h" +#define wxUSE_GENERIC_FILEDIALOG +#include "wx/generic/filedlgg.h" #elif defined(__WXMSW__) - #include "wx/msw/filedlg.h" +#include "wx/msw/filedlg.h" #elif defined(__WXMOTIF__) - #include "wx/motif/filedlg.h" +#include "wx/motif/filedlg.h" +#elif defined(__WXGTK24__) +#include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version #elif defined(__WXGTK20__) - #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version +#define wxUSE_GENERIC_FILEDIALOG +#include "wx/generic/filedlgg.h" #elif defined(__WXGTK__) - #include "wx/gtk1/filedlg.h" +#include "wx/gtk1/filedlg.h" #elif defined(__WXMAC__) - #include "wx/osx/filedlg.h" +#include "wx/mac/filedlg.h" #elif defined(__WXCOCOA__) - #include "wx/cocoa/filedlg.h" +#include "wx/cocoa/filedlg.h" #elif defined(__WXPM__) - #include "wx/os2/filedlg.h" +#include "wx/os2/filedlg.h" #endif #endif // wxUSE_FILEDLG diff --git a/Source/3rd Party/wx/include/wx/filefn.h b/Source/3rd Party/wx/include/wx/filefn.h index 221028053..84bb515a7 100644 --- a/Source/3rd Party/wx/include/wx/filefn.h +++ b/Source/3rd Party/wx/include/wx/filefn.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: filefn.h 63300 2010-01-28 21:36:09Z MW $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,9 +22,22 @@ #include #endif -#ifndef __WXWINCE__ +#ifdef __WXWINCE__ +// Nothing +#elif !defined(__MWERKS__) #include #include +#else + #ifdef __MACH__ + #include + #include + #include + #include + #else + #include + #include + #include + #endif #endif #ifdef __OS2__ @@ -44,7 +58,7 @@ #endif #if defined(__WINDOWS__) && !defined(__WXMICROWIN__) -#if !defined( __GNUWIN32__ ) && !defined(__WXWINCE__) && !defined(__CYGWIN__) +#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !defined(__WXWINCE__) && !defined(__CYGWIN__) #include #include #include @@ -69,18 +83,18 @@ #include #endif +#ifdef __SALFORDC__ + #include + #include +#endif + #ifndef __WXWINCE__ #include // O_RDONLY &c #endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- -#if defined(__VISUALC__) || defined(__DIGITALMARS__) - typedef int mode_t; -#endif - #ifdef __WXWINCE__ typedef long off_t; #else @@ -92,10 +106,12 @@ #endif #endif -#if defined(__VISUALC__) && !defined(__WXWINCE__) +#if (defined(__VISUALC__) && !defined(__WXWINCE__)) || ( defined(__MWERKS__) && defined( __INTEL__) ) typedef _off_t off_t; #elif defined(__SYMANTEC__) typedef long off_t; +#elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__) + typedef long off_t; #endif enum wxSeekMode @@ -113,51 +129,6 @@ enum wxFileKind wxFILE_KIND_PIPE // a pipe }; -// we redefine these constants here because S_IREAD &c are _not_ standard -// however, we do assume that the values correspond to the Unix umask bits -enum wxPosixPermissions -{ - // standard Posix names for these permission flags: - wxS_IRUSR = 00400, - wxS_IWUSR = 00200, - wxS_IXUSR = 00100, - - wxS_IRGRP = 00040, - wxS_IWGRP = 00020, - wxS_IXGRP = 00010, - - wxS_IROTH = 00004, - wxS_IWOTH = 00002, - wxS_IXOTH = 00001, - - // longer but more readable synonyms for the constants above: - wxPOSIX_USER_READ = wxS_IRUSR, - wxPOSIX_USER_WRITE = wxS_IWUSR, - wxPOSIX_USER_EXECUTE = wxS_IXUSR, - - wxPOSIX_GROUP_READ = wxS_IRGRP, - wxPOSIX_GROUP_WRITE = wxS_IWGRP, - wxPOSIX_GROUP_EXECUTE = wxS_IXGRP, - - wxPOSIX_OTHERS_READ = wxS_IROTH, - wxPOSIX_OTHERS_WRITE = wxS_IWOTH, - wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH, - - // default mode for the new files: allow reading/writing them to everybody but - // the effective file mode will be set after anding this value with umask and - // so won't include wxS_IW{GRP,OTH} for the default 022 umask value - wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \ - wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \ - wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE), - - // default mode for the new directories (see wxFileName::Mkdir): allow - // reading/writing/executing them to everybody, but just like wxS_DEFAULT - // the effective directory mode will be set after anding this value with umask - wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \ - wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \ - wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE) -}; - // ---------------------------------------------------------------------------- // declare our versions of low level file functions: some compilers prepend // underscores to the usual names, some also have Unicode versions of them @@ -167,30 +138,29 @@ enum wxPosixPermissions // Implemented in filefnwce.cpp #if defined( __WXWINCE__) typedef __int64 wxFileOffset; - #define wxFileOffsetFmtSpec wxT("I64") - WXDLLIMPEXP_BASE int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode)); - WXDLLIMPEXP_BASE int wxCRT_Access(const wxChar *name, int WXUNUSED(how)); - WXDLLIMPEXP_BASE int wxCRT_Chmod(const wxChar *name, int WXUNUSED(how)); - WXDLLIMPEXP_BASE int wxClose(int fd); - WXDLLIMPEXP_BASE int wxFsync(int WXUNUSED(fd)); - WXDLLIMPEXP_BASE int wxRead(int fd, void *buf, unsigned int count); - WXDLLIMPEXP_BASE int wxWrite(int fd, const void *buf, unsigned int count); - WXDLLIMPEXP_BASE int wxEof(int fd); - WXDLLIMPEXP_BASE wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin); + #define wxFileOffsetFmtSpec _("I64") + int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode)); + int wxAccess(const wxChar *name, int WXUNUSED(how)); + int wxClose(int fd); + int wxFsync(int WXUNUSED(fd)); + int wxRead(int fd, void *buf, unsigned int count); + int wxWrite(int fd, const void *buf, unsigned int count); + int wxEof(int fd); + wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin); #define wxLSeek wxSeek - WXDLLIMPEXP_BASE wxFileOffset wxTell(int fd); + wxFileOffset wxTell(int fd); // always Unicode under WinCE - #define wxCRT_MkDir _wmkdir - #define wxCRT_RmDir _wrmdir - #define wxCRT_Stat _wstat + #define wxMkDir _wmkdir + #define wxRmDir _wrmdir + #define wxStat _wstat #define wxStructStat struct _stat -#elif (defined(__WINDOWS__) || defined(__OS2__)) && \ +#elif (defined(__WXMSW__) || defined(__OS2__)) && !defined(__WXPALMOS__) && \ ( \ defined(__VISUALC__) || \ - defined(__MINGW64_TOOLCHAIN__) || \ (defined(__MINGW32__) && !defined(__WINE__) && \ wxCHECK_W32API_VERSION(0, 5)) || \ + defined(__MWERKS__) || \ defined(__DMC__) || \ defined(__WATCOMC__) || \ defined(__BORLANDC__) \ @@ -210,7 +180,7 @@ enum wxPosixPermissions #endif // detect compilers which have support for huge stdio files - #if wxCHECK_VISUALC_VERSION(8) + #if defined __VISUALC__ && __VISUALC__ >= 1400 #define wxHAS_HUGE_STDIO_FILES #define wxFseek _fseeki64 #define wxFtell _ftelli64 @@ -220,10 +190,9 @@ enum wxPosixPermissions #define wxFtell ftello64 #endif - // other Windows compilers (DMC, Watcom, and Borland) don't have huge file - // support (or at least not all functions needed for it by wx) currently - - // types + // other Windows compilers (DMC, Watcom, Metrowerks and Borland) don't have + // huge file support (or at least not all functions needed for it by wx) + // currently #ifdef wxHAS_HUGE_FILES typedef wxLongLong_t wxFileOffset; @@ -232,46 +201,6 @@ enum wxPosixPermissions typedef off_t wxFileOffset; #endif - // at least Borland 5.5 doesn't like "struct ::stat" so don't use the scope - // resolution operator present in wxPOSIX_IDENT for it - #ifdef __BORLANDC__ - #define wxPOSIX_STRUCT(s) struct s - #else - #define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s) - #endif - - // Notice that Watcom is the only compiler to have a wide char - // version of struct stat as well as a wide char stat function variant. - // This was dropped since OW 1.4 "for consistency across platforms". - // - // Borland is also special in that it uses _stat with Unicode functions - // (for MSVC compatibility?) but stat with ANSI ones - #ifdef __BORLANDC__ - #if wxHAS_HUGE_FILES - #define wxStructStat struct stati64 - #else - #if wxUSE_UNICODE - #define wxStructStat struct _stat - #else - #define wxStructStat struct stat - #endif - #endif - #else // !__BORLANDC__ - #ifdef wxHAS_HUGE_FILES - #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) - #define wxStructStat struct _wstati64 - #else - #define wxStructStat struct _stati64 - #endif - #else - #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) - #define wxStructStat struct _wstat - #else - #define wxStructStat struct _stat - #endif - #endif - #endif // __BORLANDC__/!__BORLANDC__ - // functions @@ -281,22 +210,42 @@ enum wxPosixPermissions // to avoid using them as they're not present in earlier versions and // always using the native functions spelling is easier than testing for // the versions - #if defined(__BORLANDC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__MINGW64_TOOLCHAIN__) + #if defined(__BORLANDC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__MINGW64__) #define wxPOSIX_IDENT(func) ::func #else // by default assume MSVC-compatible names #define wxPOSIX_IDENT(func) _ ## func #define wxHAS_UNDERSCORES_IN_POSIX_IDENTS #endif + // at least Borland 5.5 doesn't like "struct ::stat" so don't use the scope + // resolution operator present in wxPOSIX_IDENT for it + #ifdef __BORLANDC__ + #define wxPOSIX_STRUCT(s) struct s + #else + #define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s) + #endif + // first functions not working with strings, i.e. without ANSI/Unicode // complications #define wxClose wxPOSIX_IDENT(close) - #define wxRead wxPOSIX_IDENT(read) - #define wxWrite wxPOSIX_IDENT(write) + #if defined(__MWERKS__) + #if __MSL__ >= 0x6000 + #define wxRead(fd, buf, nCount) _read(fd, (void *)buf, nCount) + #define wxWrite(fd, buf, nCount) _write(fd, (void *)buf, nCount) + #else + #define wxRead(fd, buf, nCount)\ + _read(fd, (const char *)buf, nCount) + #define wxWrite(fd, buf, nCount)\ + _write(fd, (const char *)buf, nCount) + #endif + #else // __MWERKS__ + #define wxRead wxPOSIX_IDENT(read) + #define wxWrite wxPOSIX_IDENT(write) + #endif #ifdef wxHAS_HUGE_FILES - #ifndef __MINGW64_TOOLCHAIN__ + #ifndef __MINGW64__ #define wxSeek wxPOSIX_IDENT(lseeki64) #define wxLseek wxPOSIX_IDENT(lseeki64) #define wxTell wxPOSIX_IDENT(telli64) @@ -327,93 +276,104 @@ enum wxPosixPermissions #define wxEof wxPOSIX_IDENT(eof) // then the functions taking strings - - // first the ANSI versions - #define wxCRT_OpenA wxPOSIX_IDENT(open) - #define wxCRT_AccessA wxPOSIX_IDENT(access) - #define wxCRT_ChmodA wxPOSIX_IDENT(chmod) - #define wxCRT_MkDirA wxPOSIX_IDENT(mkdir) - #define wxCRT_RmDirA wxPOSIX_IDENT(rmdir) - #ifdef wxHAS_HUGE_FILES - // MinGW-64 provides underscore-less versions of all file functions - // except for this one. - #ifdef __MINGW64_TOOLCHAIN__ - #define wxCRT_StatA _stati64 - #else - #define wxCRT_StatA wxPOSIX_IDENT(stati64) - #endif - #else - // Unfortunately Watcom is not consistent - #if defined(__OS2__) && defined(__WATCOMC__) - #define wxCRT_StatA _stat - #else - #define wxCRT_StatA wxPOSIX_IDENT(stat) - #endif - #endif - - // then wide char ones #if wxUSE_UNICODE - // special workaround for buggy wopen() in bcc 5.5 - #if defined(__BORLANDC__) && \ - (__BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551) - WXDLLIMPEXP_BASE int wxCRT_OpenW(const wxChar *pathname, - int flags, mode_t mode); - #else - #define wxCRT_OpenW _wopen - #endif - - #define wxCRT_AccessW _waccess - #define wxCRT_ChmodW _wchmod - #define wxCRT_MkDirW _wmkdir - #define wxCRT_RmDirW _wrmdir - #ifdef wxHAS_HUGE_FILES - #define wxCRT_StatW _wstati64 - #else - #define wxCRT_StatW _wstat - #endif - #endif // wxUSE_UNICODE - - - // finally the default char-type versions - #if wxUSE_UNICODE - #if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__) + #if wxUSE_UNICODE_MSLU // implement the missing file functions in Win9x ourselves - WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, - int flags, int mode); - WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name, - int mode); - WXDLLIMPEXP_BASE int wxMSLU__wchmod(const wxChar *name, - int mode); - WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name); - WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name); + #if defined( __VISUALC__ ) \ + || ( defined(__MINGW32__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \ + || ( defined(__MWERKS__) && defined(__WXMSW__) ) \ + || ( defined(__BORLANDC__) && (__BORLANDC__ > 0x460) ) \ + || defined(__DMC__) - WXDLLIMPEXP_BASE int - wxMSLU__wstat(const wxChar *name, wxStructStat *buffer); + WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, + int flags, int mode); + WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name, + int mode); + WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name); + WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name); - #define wxCRT_Open wxMSLU__wopen + WXDLLIMPEXP_BASE int + wxMSLU__wstat(const wxChar *name, wxPOSIX_STRUCT(stat) *buffer); + WXDLLIMPEXP_BASE int + wxMSLU__wstati64(const wxChar *name, + wxPOSIX_STRUCT(stati64) *buffer); + #endif // Windows compilers with MSLU support - #define wxCRT_Access wxMSLU__waccess - #define wxCRT_Chmod wxMSLU__wchmod - #define wxCRT_MkDir wxMSLU__wmkdir - #define wxCRT_RmDir wxMSLU__wrmdir - #define wxCRT_Stat wxMSLU__wstat + #define wxOpen wxMSLU__wopen + + #define wxAccess wxMSLU__waccess + #define wxMkDir wxMSLU__wmkdir + #define wxRmDir wxMSLU__wrmdir + #ifdef wxHAS_HUGE_FILES + #define wxStat wxMSLU__wstati64 + #else + #define wxStat wxMSLU__wstat + #endif #else // !wxUSE_UNICODE_MSLU - #define wxCRT_Open wxCRT_OpenW - #define wxCRT_Access wxCRT_AccessW - #define wxCRT_Chmod wxCRT_ChmodW - #define wxCRT_MkDir wxCRT_MkDirW - #define wxCRT_RmDir wxCRT_RmDirW - #define wxCRT_Stat wxCRT_StatW + #ifdef __BORLANDC__ + #if __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551 + WXDLLIMPEXP_BASE int wxOpen(const wxChar *pathname, + int flags, mode_t mode); + #else + #define wxOpen _wopen + #endif + #define wxAccess _waccess + #define wxMkDir _wmkdir + #define wxRmDir _wrmdir + #ifdef wxHAS_HUGE_FILES + #define wxStat _wstati64 + #else + #define wxStat _wstat + #endif + #else + #define wxOpen _wopen + #define wxAccess _waccess + #define wxMkDir _wmkdir + #define wxRmDir _wrmdir + #ifdef wxHAS_HUGE_FILES + #define wxStat _wstati64 + #else + #define wxStat _wstat + #endif + #endif #endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU #else // !wxUSE_UNICODE - #define wxCRT_Open wxCRT_OpenA - #define wxCRT_Access wxCRT_AccessA - #define wxCRT_Chmod wxCRT_ChmodA - #define wxCRT_MkDir wxCRT_MkDirA - #define wxCRT_RmDir wxCRT_RmDirA - #define wxCRT_Stat wxCRT_StatA + #define wxOpen wxPOSIX_IDENT(open) + #define wxAccess wxPOSIX_IDENT(access) + #define wxMkDir wxPOSIX_IDENT(mkdir) + #define wxRmDir wxPOSIX_IDENT(rmdir) + #ifdef wxHAS_HUGE_FILES + #define wxStat wxPOSIX_IDENT(stati64) + #else + // Unfortunately Watcom is not consistent, so:- + #if defined(__OS2__) && defined(__WATCOMC__) + #define wxStat _stat + #else + #if defined (__BORLANDC__) + #define wxStat _stat //wxPOSIX_IDENT(stat) + #else + #define wxStat wxPOSIX_IDENT(stat) + #endif // !borland + #endif // !watcom + #endif #endif // wxUSE_UNICODE/!wxUSE_UNICODE + // Types: Notice that Watcom is the only compiler to have a wide char + // version of struct stat as well as a wide char stat function variant. + // This was droped since OW 1.4 "for consistency across platforms". + #ifdef wxHAS_HUGE_FILES + #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) + #define wxStructStat struct _wstati64 + #else + #define wxStructStat struct _stati64 + #endif + #else + #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) + #define wxStructStat struct _wstat + #else + #define wxStructStat struct _stat + #endif + #endif // constants (unless already defined by the user code) #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS @@ -449,16 +409,16 @@ enum wxPosixPermissions #undef wxHAS_HUGE_STDIO_FILES #else // Unix or Windows using unknown compiler, assume POSIX supported typedef off_t wxFileOffset; - #ifdef HAVE_LARGEFILE_SUPPORT + #ifdef _LARGE_FILES #define wxFileOffsetFmtSpec wxLongLongFmtSpec wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t), BadFileSizeType ); // wxFile is present and supports large files - #if wxUSE_FILE + #ifdef wxUSE_FILE #define wxHAS_LARGE_FILES #endif // wxFFile is present and supports large files - #if wxUSE_FFILE && (SIZEOF_LONG == 8 || defined HAVE_FSEEKO) + #if SIZEOF_LONG == 8 || defined HAVE_FSEEKO #define wxHAS_LARGE_FFILES #endif #ifdef HAVE_FSEEKO @@ -476,28 +436,33 @@ enum wxPosixPermissions #define wxSeek lseek #define wxFsync fsync #define wxEof eof - #define wxCRT_MkDir mkdir - #define wxCRT_RmDir rmdir + + #define wxMkDir mkdir + #define wxRmDir rmdir #define wxTell(fd) lseek(fd, 0, SEEK_CUR) #define wxStructStat struct stat - #define wxCRT_Open open - #define wxCRT_Stat stat - #define wxCRT_Lstat lstat - #define wxCRT_Access access - #define wxCRT_Chmod chmod + #if wxUSE_UNICODE + #define wxNEED_WX_UNISTD_H + #if defined(__DMC__) + typedef unsigned long mode_t; + #endif + WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf ); + WXDLLIMPEXP_BASE int wxLstat( const wxChar *file_name, wxStructStat *buf ); + WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode ); + WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode ); + #else + #define wxOpen open + #define wxStat stat + #define wxLstat lstat + #define wxAccess access + #endif #define wxHAS_NATIVE_LSTAT #endif // platforms -// if the platform doesn't have symlinks, define wxCRT_Lstat to be the same as -// wxCRT_Stat to avoid #ifdefs in the code using it -#ifndef wxHAS_NATIVE_LSTAT - #define wxCRT_Lstat wxCRT_Stat -#endif - // define wxFseek/wxFtell to large file versions if available (done above) or // to fseek/ftell if not, to save ifdefs in using code #ifndef wxFseek @@ -507,37 +472,18 @@ enum wxPosixPermissions #define wxFtell ftell #endif -inline int wxAccess(const wxString& path, mode_t mode) - { return wxCRT_Access(path.fn_str(), mode); } -inline int wxChmod(const wxString& path, mode_t mode) - { return wxCRT_Chmod(path.fn_str(), mode); } -inline int wxOpen(const wxString& path, int flags, mode_t mode) - { return wxCRT_Open(path.fn_str(), flags, mode); } - -// FIXME-CE: provide our own implementations of the missing CRT functions -#ifndef __WXWINCE__ -inline int wxStat(const wxString& path, wxStructStat *buf) - { return wxCRT_Stat(path.fn_str(), buf); } -inline int wxLstat(const wxString& path, wxStructStat *buf) - { return wxCRT_Lstat(path.fn_str(), buf); } -inline int wxRmDir(const wxString& path) - { return wxCRT_RmDir(path.fn_str()); } -#if (defined(__WINDOWS__) && !defined(__CYGWIN__)) \ - || (defined(__OS2__) && defined(__WATCOMC__)) -inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0) - { return wxCRT_MkDir(path.fn_str()); } -#else -inline int wxMkDir(const wxString& path, mode_t mode) - { return wxCRT_MkDir(path.fn_str(), mode); } -#endif -#endif // !__WXWINCE__ - #ifdef O_BINARY #define wxO_BINARY O_BINARY #else #define wxO_BINARY 0 #endif +// if the platform doesn't have symlinks, define wxLstat to be the same as +// wxStat to avoid #ifdefs in the code using it +#ifndef wxHAS_NATIVE_LSTAT + #define wxLstat wxStat +#endif + #if defined(__VISAGECPP__) && __IBMCPP__ >= 400 // // VisualAge C++ V4.0 cannot have any external linkage const decs @@ -554,7 +500,7 @@ const int wxInvalidOffset = -1; WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename); // does the path exist? (may have or not '/' or '\\' at the end) -WXDLLIMPEXP_BASE bool wxDirExists(const wxString& pathName); +WXDLLIMPEXP_BASE bool wxDirExists(const wxChar *pszPathName); WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename); @@ -565,58 +511,43 @@ WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path); // Get directory WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path); -// all deprecated functions below are deprecated in favour of wxFileName's methods -#if WXWIN_COMPATIBILITY_2_8 +// wxString version +WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path); -wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(char *s) ); -wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(wchar_t *s) ); +WXDLLIMPEXP_BASE void wxDos2UnixFilename(wxChar *s); -wxDEPRECATED_BUT_USED_INTERNALLY( - WXDLLIMPEXP_BASE void wxUnix2DosFilename(char *s) ); -wxDEPRECATED_BUT_USED_INTERNALLY( - WXDLLIMPEXP_BASE void wxUnix2DosFilename(wchar_t *s) ); +WXDLLIMPEXP_BASE void wxUnix2DosFilename(wxChar *s); // Strip the extension, in situ -// Deprecated in favour of wxFileName::StripExtension() but notice that their -// behaviour is slightly different, see the manual -wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(char *buffer) ); -wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wchar_t *buffer) ); -wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer) ); +WXDLLIMPEXP_BASE void wxStripExtension(wxChar *buffer); +WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer); // Get a temporary filename -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = NULL) ); -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf) ); +WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL); +WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf); // Expand file name (~/ and ${OPENWINHOME}/ stuff) -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxExpandPath(char *dest, const wxString& path) ); -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxExpandPath(wchar_t *dest, const wxString& path) ); - // DEPRECATED: use wxFileName::Normalize(wxPATH_NORM_ENV_VARS) +WXDLLIMPEXP_BASE wxChar* wxExpandPath(wxChar *dest, const wxChar *path); +WXDLLIMPEXP_BASE bool wxExpandPath(wxString& dest, const wxChar *path); // Contract w.r.t environment ( -> ${OPENWINHOME}/lib) // and make (if under the home tree) relative to home // [caller must copy-- volatile] -wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename, const wxString& envname = wxEmptyString, - const wxString& user = wxEmptyString) ); - // DEPRECATED: use wxFileName::ReplaceEnvVariable and wxFileName::ReplaceHomeDir + const wxString& user = wxEmptyString); // Destructive removal of /./ and /../ stuff -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxRealPath(char *path) ); -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxRealPath(wchar_t *path) ); -wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path) ); - // DEPRECATED: use wxFileName::Normalize instead +WXDLLIMPEXP_BASE wxChar* wxRealPath(wxChar *path); // Allocate a copy of the full absolute path -wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path) ); - // DEPRECATED: use wxFileName::MakeAbsolute instead -#endif +WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path); // Get first file name matching given wild card. // Flags are reserved for future use. #define wxFILE 1 #define wxDIR 2 -WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxString& spec, int flags = wxFILE); +WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE); WXDLLIMPEXP_BASE wxString wxFindNextFile(); // Does the pattern contain wildcards? @@ -646,7 +577,7 @@ WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2, // copies into buf. // IMPORTANT NOTE getcwd is know not to work under some releases // of Win32s 1.3, according to MS release notes! -wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = NULL, int sz = 1000) ); +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000) ); // new and preferred version of wxGetWorkingDirectory // NB: can't have the same name because of overloading ambiguity #endif // WXWIN_COMPATIBILITY_2_6 @@ -656,7 +587,7 @@ WXDLLIMPEXP_BASE wxString wxGetCwd(); WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d); // Make directory -WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT); +WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777); // Remove directory. Flags reserved for future use. WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0); @@ -736,20 +667,17 @@ inline bool wxIsPathSeparator(wxChar c) } // does the string ends with path separator? -WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxString& filename); +WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxChar *pszFileName); -#if WXWIN_COMPATIBILITY_2_8 // split the full path into path (including drive for DOS), name and extension // (understands both '/' and '\\') -// Deprecated in favour of wxFileName::SplitPath -wxDEPRECATED( WXDLLIMPEXP_BASE void wxSplitPath(const wxString& fileName, - wxString *pstrPath, - wxString *pstrName, - wxString *pstrExt) ); -#endif +WXDLLIMPEXP_BASE void wxSplitPath(const wxChar *pszFileName, + wxString *pstrPath, + wxString *pstrName, + wxString *pstrExt); // find a file in a list of directories, returns false if not found -WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile); +WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile); // Get the OS directory if appropriate (such as the Windows directory). // On non-Windows platform, probably just return the empty string. diff --git a/Source/3rd Party/wx/include/wx/filehistory.h b/Source/3rd Party/wx/include/wx/filehistory.h deleted file mode 100644 index b6cb1cb50..000000000 --- a/Source/3rd Party/wx/include/wx/filehistory.h +++ /dev/null @@ -1,113 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/filehistory.h -// Purpose: wxFileHistory class -// Author: Julian Smart, Vaclav Slavik -// Created: 2010-05-03 -// Copyright: (c) Julian Smart, Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FILEHISTORY_H_ -#define _WX_FILEHISTORY_H_ - -#include "wx/defs.h" - -#if wxUSE_FILE_HISTORY - -#include "wx/windowid.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/string.h" -#include "wx/arrstr.h" - -class WXDLLIMPEXP_FWD_CORE wxMenu; -class WXDLLIMPEXP_FWD_BASE wxConfigBase; -class WXDLLIMPEXP_FWD_BASE wxFileName; - -// ---------------------------------------------------------------------------- -// File history management -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxFileHistoryBase : public wxObject -{ -public: - wxFileHistoryBase(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1); - - // Operations - virtual void AddFileToHistory(const wxString& file); - virtual void RemoveFileFromHistory(size_t i); - virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; } - virtual void UseMenu(wxMenu *menu); - - // Remove menu from the list (MDI child may be closing) - virtual void RemoveMenu(wxMenu *menu); - -#if wxUSE_CONFIG - virtual void Load(const wxConfigBase& config); - virtual void Save(wxConfigBase& config); -#endif // wxUSE_CONFIG - - virtual void AddFilesToMenu(); - virtual void AddFilesToMenu(wxMenu* menu); // Single menu - - // Accessors - virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; } - virtual size_t GetCount() const { return m_fileHistory.GetCount(); } - - const wxList& GetMenus() const { return m_fileMenus; } - - // Set/get base id - void SetBaseId(wxWindowID baseId) { m_idBase = baseId; } - wxWindowID GetBaseId() const { return m_idBase; } - -#if WXWIN_COMPATIBILITY_2_6 - // deprecated, use GetCount() instead - wxDEPRECATED( size_t GetNoHistoryFiles() const ); -#endif // WXWIN_COMPATIBILITY_2_6 - -protected: - // Last n files - wxArrayString m_fileHistory; - - // Menus to maintain (may need several for an MDI app) - wxList m_fileMenus; - - // Max files to maintain - size_t m_fileMaxFiles; - -private: - // The ID of the first history menu item (Doesn't have to be wxID_FILE1) - wxWindowID m_idBase; - - // Normalize a file name to canonical form. We have a special function for - // this to ensure the same normalization is used everywhere. - static wxString NormalizeFileName(const wxFileName& filename); - - wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase); -}; - -#if WXWIN_COMPATIBILITY_2_6 -inline size_t wxFileHistoryBase::GetNoHistoryFiles() const -{ - return m_fileHistory.GetCount(); -} -#endif // WXWIN_COMPATIBILITY_2_6 - - -#if defined(__WXGTK20__) - #include "wx/gtk/filehistory.h" -#else - // no platform-specific implementation of wxFileHistory yet - class WXDLLIMPEXP_CORE wxFileHistory : public wxFileHistoryBase - { - public: - wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1) - : wxFileHistoryBase(maxFiles, idBase) {} - - DECLARE_DYNAMIC_CLASS(wxFileHistory) - }; -#endif - -#endif // wxUSE_FILE_HISTORY - -#endif // _WX_FILEHISTORY_H_ diff --git a/Source/3rd Party/wx/include/wx/filename.h b/Source/3rd Party/wx/include/wx/filename.h index f0f70a3d7..e9228787d 100644 --- a/Source/3rd Party/wx/include/wx/filename.h +++ b/Source/3rd Party/wx/include/wx/filename.h @@ -4,6 +4,7 @@ // Author: Robert Roebling, Vadim Zeitlin // Modified by: // Created: 28.12.00 +// RCS-ID: $Id: filename.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2000 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,12 +12,21 @@ #ifndef _WX_FILENAME_H_ #define _WX_FILENAME_H_ +/* + TODO: + + 1. support for drives under Windows + 2. more file operations: + a) chmod() + b) [acm]time() - get and set + c) rename()? + 3. SameFileAs() function to compare inodes under Unix + */ + #include "wx/arrstr.h" #include "wx/filefn.h" #include "wx/datetime.h" #include "wx/intl.h" -#include "wx/longlong.h" -#include "wx/file.h" #if wxUSE_FILE class WXDLLIMPEXP_FWD_BASE wxFile; @@ -26,12 +36,6 @@ class WXDLLIMPEXP_FWD_BASE wxFile; class WXDLLIMPEXP_FWD_BASE wxFFile; #endif -// this symbol is defined for the platforms where file systems use volumes in -// paths -#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__) - #define wxHAS_FILESYSTEM_VOLUMES -#endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -53,20 +57,12 @@ enum wxPathFormat wxPATH_MAX // Not a valid value for specifying path format }; -// different conventions that may be used with GetHumanReadableSize() -enum wxSizeConvention -{ - wxSIZE_CONV_TRADITIONAL, // 1024 bytes = 1 KB - wxSIZE_CONV_IEC, // 1024 bytes = 1 KiB - wxSIZE_CONV_SI // 1000 bytes = 1 KB -}; - // the kind of normalization to do with the file name: these values can be // or'd together to perform several operations at once enum wxPathNormalize { wxPATH_NORM_ENV_VARS = 0x0001, // replace env vars with their values - wxPATH_NORM_DOTS = 0x0002, // squeeze all .. and . + wxPATH_NORM_DOTS = 0x0002, // squeeze all .. and . and prepend cwd wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user wxPATH_NORM_CASE = 0x0008, // if case insensitive => tolower wxPATH_NORM_ABSOLUTE = 0x0010, // make the path absolute @@ -78,44 +74,18 @@ enum wxPathNormalize // what exactly should GetPath() return? enum { - wxPATH_NO_SEPARATOR = 0x0000, // for symmetry with wxPATH_GET_SEPARATOR wxPATH_GET_VOLUME = 0x0001, // include the volume if applicable wxPATH_GET_SEPARATOR = 0x0002 // terminate the path with the separator }; -// Mkdir flags +// MkDir flags enum { wxPATH_MKDIR_FULL = 0x0001 // create directories recursively }; -// Rmdir flags -enum -{ - wxPATH_RMDIR_FULL = 0x0001, // delete with subdirectories if empty - wxPATH_RMDIR_RECURSIVE = 0x0002 // delete all recursively (dangerous!) -}; - -// FileExists flags -enum -{ - wxFILE_EXISTS_REGULAR = 0x0001, // check for existence of a regular file - wxFILE_EXISTS_DIR = 0x0002, // check for existence of a directory - wxFILE_EXISTS_SYMLINK = 0x1004, // check for existence of a symbolic link; - // also sets wxFILE_EXISTS_NO_FOLLOW as - // it would never be satisfied otherwise - wxFILE_EXISTS_DEVICE = 0x0008, // check for existence of a device - wxFILE_EXISTS_FIFO = 0x0016, // check for existence of a FIFO - wxFILE_EXISTS_SOCKET = 0x0032, // check for existence of a socket - // gap for future types - wxFILE_EXISTS_NO_FOLLOW = 0x1000, // don't dereference a contained symlink - wxFILE_EXISTS_ANY = 0x1FFF // check for existence of anything -}; - -#if wxUSE_LONGLONG // error code of wxFileName::GetSize() -extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize; -#endif // wxUSE_LONGLONG +extern WXDLLIMPEXP_DATA_BASE(wxULongLong) wxInvalidSize; @@ -136,13 +106,13 @@ public: // is contructed (the name will be empty), otherwise a file name and // extension are extracted from it wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE ) - { Assign( fullpath, format ); m_dontFollowLinks = false; } + { Assign( fullpath, format ); } // from a directory name and a file name wxFileName(const wxString& path, const wxString& name, wxPathFormat format = wxPATH_NATIVE) - { Assign(path, name, format); m_dontFollowLinks = false; } + { Assign(path, name, format); } // from a volume, directory name, file base name and extension wxFileName(const wxString& volume, @@ -150,14 +120,14 @@ public: const wxString& name, const wxString& ext, wxPathFormat format = wxPATH_NATIVE) - { Assign(volume, path, name, ext, format); m_dontFollowLinks = false; } + { Assign(volume, path, name, ext, format); } // from a directory name, file base name and extension wxFileName(const wxString& path, const wxString& name, const wxString& ext, wxPathFormat format = wxPATH_NATIVE) - { Assign(path, name, ext, format); m_dontFollowLinks = false; } + { Assign(path, name, ext, format); } // the same for delayed initialization @@ -194,7 +164,7 @@ public: // assorted assignment operators wxFileName& operator=(const wxFileName& filename) - { if (this != &filename) Assign(filename); return *this; } + { Assign(filename); return *this; } wxFileName& operator=(const wxString& filename) { Assign(filename); return *this; } @@ -218,20 +188,14 @@ public: !m_ext.empty() || m_hasExt; } - // does the file with this name exist? + // does the file with this name exists? bool FileExists() const; static bool FileExists( const wxString &file ); - // does the directory with this name exist? + // does the directory with this name exists? bool DirExists() const; static bool DirExists( const wxString &dir ); - // does anything at all with this name (i.e. file, directory or some - // other file system object such as a device, socket, ...) exist? - bool Exists(int flags = wxFILE_EXISTS_ANY) const; - static bool Exists(const wxString& path, int flags = wxFILE_EXISTS_ANY); - - // checks on most common flags for files/directories; // more platform-specific features (like e.g. Unix permissions) are not // available in wxFileName @@ -254,10 +218,6 @@ public: bool IsFileExecutable() const { return wxIsExecutable(GetFullPath()); } static bool IsFileExecutable(const wxString &path) { return wxFileExists(path) && wxIsExecutable(path); } - // set the file permissions to a combination of wxPosixPermissions enum - // values - bool SetPermissions(int permissions); - // time functions #if wxUSE_DATETIME @@ -265,10 +225,10 @@ public: // (any of the pointers may be NULL) bool SetTimes(const wxDateTime *dtAccess, const wxDateTime *dtMod, - const wxDateTime *dtCreate) const; + const wxDateTime *dtCreate); // set the access and modification times to the current moment - bool Touch() const; + bool Touch(); // return the last access, last modification and create times // (any of the pointers may be NULL) @@ -285,9 +245,9 @@ public: } #endif // wxUSE_DATETIME -#if defined( __WXOSX_MAC__ ) && wxOSX_USE_CARBON +#ifdef __WXMAC__ bool MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) ; - bool MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) const; + bool MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) ; // gets the 'common' type and creator for a certain extension static bool MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator ) ; // registers application defined extensions and their default type and creator @@ -303,7 +263,7 @@ public: static wxString GetCwd(const wxString& volume = wxEmptyString); // change the current working directory - bool SetCwd() const; + bool SetCwd(); static bool SetCwd( const wxString &cwd ); // get the value of user home (Unix only mainly) @@ -338,12 +298,11 @@ public: #endif // wxUSE_FFILE // directory creation and removal. - bool Mkdir(int perm = wxS_DIR_DEFAULT, int flags = 0) const; - static bool Mkdir(const wxString &dir, int perm = wxS_DIR_DEFAULT, - int flags = 0); + bool Mkdir( int perm = 0777, int flags = 0); + static bool Mkdir( const wxString &dir, int perm = 0777, int flags = 0 ); - bool Rmdir(int flags = 0) const; - static bool Rmdir(const wxString &dir, int flags = 0); + bool Rmdir(); + static bool Rmdir( const wxString &dir ); // operations on the path @@ -375,53 +334,14 @@ public: { return Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_TILDE, cwd, format); } - - // If the path is a symbolic link (Unix-only), indicate that all - // filesystem operations on this path should be performed on the link - // itself and not on the file it points to, as is the case by default. - // - // No effect if this is not a symbolic link. - void DontFollowLink() - { - m_dontFollowLinks = true; - } - - // If the path is a symbolic link (Unix-only), returns whether various - // file operations should act on the link itself, or on its target. - // - // This does not test if the path is really a symlink or not. - bool ShouldFollowLink() const - { - return !m_dontFollowLinks; - } - #if defined(__WIN32__) && !defined(__WXWINCE__) && wxUSE_OLE // if the path is a shortcut, return the target and optionally, // the arguments bool GetShortcutTarget(const wxString& shortcutPath, wxString& targetFilename, - wxString* arguments = NULL) const; + wxString* arguments = NULL); #endif -#ifndef __WXWINCE__ - // if the path contains the value of the environment variable named envname - // then this function replaces it with the string obtained from - // wxString::Format(replacementFmtString, value_of_envname_variable) - // - // Example: - // wxFileName fn("/usr/openwin/lib/someFile"); - // fn.ReplaceEnvVariable("OPENWINHOME"); - // // now fn.GetFullPath() == "$OPENWINHOME/lib/someFile" - bool ReplaceEnvVariable(const wxString& envname, - const wxString& replacementFmtString = "$%s", - wxPathFormat format = wxPATH_NATIVE); -#endif - - // replaces, if present in the path, the home directory for the given user - // (see wxGetHomeDir) with a tilde - bool ReplaceHomeDir(wxPathFormat format = wxPATH_NATIVE); - - // Comparison // compares with the rules of the given platforms format @@ -469,29 +389,24 @@ public: static wxString GetPathTerminators(wxPathFormat format = wxPATH_NATIVE); // get the canonical path separator for this format - static wxUniChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE) + static wxChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE) { return GetPathSeparators(format)[0u]; } // is the char a path separator for this format? static bool IsPathSeparator(wxChar ch, wxPathFormat format = wxPATH_NATIVE); - // is this is a DOS path which beings with a windows unique volume name - // ('\\?\Volume{guid}\')? - static bool IsMSWUniqueVolumeNamePath(const wxString& path, - wxPathFormat format = wxPATH_NATIVE); - // Dir accessors size_t GetDirCount() const { return m_dirs.size(); } - bool AppendDir(const wxString& dir); + void AppendDir(const wxString& dir); void PrependDir(const wxString& dir); - bool InsertDir(size_t before, const wxString& dir); + void InsertDir(size_t before, const wxString& dir); void RemoveDir(size_t pos); void RemoveLastDir() { RemoveDir(GetDirCount() - 1); } // Other accessors void SetExt( const wxString &ext ) { m_ext = ext; m_hasExt = !m_ext.empty(); } - void ClearExt() { m_ext.clear(); m_hasExt = false; } - void SetEmptyExt() { m_ext.clear(); m_hasExt = true; } + void ClearExt() { m_ext = wxEmptyString; m_hasExt = false; } + void SetEmptyExt() { m_ext = wxT(""); m_hasExt = true; } wxString GetExt() const { return m_ext; } bool HasExt() const { return m_hasExt; } @@ -566,32 +481,24 @@ public: wxString *path, wxPathFormat format = wxPATH_NATIVE); - // strip the file extension: "foo.bar" => "foo" (but ".baz" => ".baz") +#if wxABI_VERSION >= 20811 + // strip the file extension static wxString StripExtension(const wxString& fullpath); +#endif // wxABI_VERSION >= 20811 -#ifdef wxHAS_FILESYSTEM_VOLUMES - // return the string representing a file system volume, or drive - static wxString GetVolumeString(char drive, int flags = wxPATH_GET_SEPARATOR); -#endif // wxHAS_FILESYSTEM_VOLUMES - // File size + // Filesize -#if wxUSE_LONGLONG // returns the size of the given filename wxULongLong GetSize() const; static wxULongLong GetSize(const wxString &file); // returns the size in a human readable form - wxString - GetHumanReadableSize(const wxString& nullsize = wxGetTranslation("Not available"), - int precision = 1, - wxSizeConvention conv = wxSIZE_CONV_TRADITIONAL) const; - static wxString - GetHumanReadableSize(const wxULongLong& sz, - const wxString& nullsize = wxGetTranslation("Not available"), - int precision = 1, - wxSizeConvention conv = wxSIZE_CONV_TRADITIONAL); -#endif // wxUSE_LONGLONG + wxString GetHumanReadableSize(const wxString &nullsize = wxGetTranslation(wxT("Not available")), + int precision = 1) const; + static wxString GetHumanReadableSize(const wxULongLong &sz, + const wxString &nullsize = wxGetTranslation(wxT("Not available")), + int precision = 1); // deprecated methods, don't use any more @@ -634,11 +541,6 @@ private: // the difference is important as file with name "foo" and without // extension has full name "foo" while with empty extension it is "foo." bool m_hasExt; - - // by default, symlinks are dereferenced but this flag can be set with - // DontFollowLink() to change this and make different operations work on - // this file path itself instead of the target of the symlink - bool m_dontFollowLinks; }; #endif // _WX_FILENAME_H_ diff --git a/Source/3rd Party/wx/include/wx/filepicker.h b/Source/3rd Party/wx/include/wx/filepicker.h index 9b6e9f786..ce08f8569 100644 --- a/Source/3rd Party/wx/include/wx/filepicker.h +++ b/Source/3rd Party/wx/include/wx/filepicker.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Francesco Montorsi +// RCS-ID: $Id: filepicker.h 49804 2007-11-10 01:09:42Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -16,64 +17,20 @@ #if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL #include "wx/pickerbase.h" -#include "wx/filename.h" class WXDLLIMPEXP_FWD_CORE wxDialog; class WXDLLIMPEXP_FWD_CORE wxFileDirPickerEvent; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFilePickerWidgetLabel[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFilePickerWidgetNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFilePickerCtrlNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFilePickerWidgetLabel[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFilePickerWidgetNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFilePickerCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirPickerWidgetLabel[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirPickerWidgetNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirPickerCtrlNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirPickerWidgetLabel[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirPickerWidgetNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirPickerCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[]; -// ---------------------------------------------------------------------------- -// wxFileDirPickerEvent: used by wxFilePickerCtrl and wxDirPickerCtrl only -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxFileDirPickerEvent : public wxCommandEvent -{ -public: - wxFileDirPickerEvent() {} - wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path) - : wxCommandEvent(type, id), - m_path(path) - { - SetEventObject(generator); - } - - wxString GetPath() const { return m_path; } - void SetPath(const wxString &p) { m_path = p; } - - // default copy ctor, assignment operator and dtor are ok - virtual wxEvent *Clone() const { return new wxFileDirPickerEvent(*this); } - -private: - wxString m_path; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileDirPickerEvent) -}; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILEPICKER_CHANGED, wxFileDirPickerEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRPICKER_CHANGED, wxFileDirPickerEvent ); - -// ---------------------------------------------------------------------------- -// event types and macros -// ---------------------------------------------------------------------------- - -typedef void (wxEvtHandler::*wxFileDirPickerEventFunction)(wxFileDirPickerEvent&); - -#define wxFileDirPickerEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxFileDirPickerEventFunction, func) - -#define EVT_FILEPICKER_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FILEPICKER_CHANGED, id, wxFileDirPickerEventHandler(fn)) -#define EVT_DIRPICKER_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_DIRPICKER_CHANGED, id, wxFileDirPickerEventHandler(fn)) // ---------------------------------------------------------------------------- // wxFileDirPickerWidgetBase: a generic abstract interface which must be @@ -86,13 +43,9 @@ public: wxFileDirPickerWidgetBase() { } virtual ~wxFileDirPickerWidgetBase() { } - // Path here is the name of the selected file or directory. wxString GetPath() const { return m_path; } virtual void SetPath(const wxString &str) { m_path=str; } - // Set the directory to open the file browse dialog at initially. - virtual void SetInitialDirectory(const wxString& dir) = 0; - // returns the picker widget cast to wxControl virtual wxControl *AsControl() = 0; @@ -112,14 +65,12 @@ protected: #define wxFLP_OVERWRITE_PROMPT 0x1000 #define wxFLP_FILE_MUST_EXIST 0x2000 #define wxFLP_CHANGE_DIR 0x4000 -#define wxFLP_SMALL wxPB_SMALL // NOTE: wxMULTIPLE is not supported ! #define wxDIRP_DIR_MUST_EXIST 0x0008 #define wxDIRP_CHANGE_DIR 0x0010 -#define wxDIRP_SMALL wxPB_SMALL // map platform-dependent controls which implement the wxFileDirPickerWidgetBase @@ -128,7 +79,7 @@ protected: // requires that all classes being mapped as wx{File|Dir}PickerWidget have the // same prototype for the contructor... // since GTK >= 2.6, there is GtkFileButton -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +#if defined(__WXGTK26__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/filepicker.h" #define wxFilePickerWidget wxFileButton #define wxDirPickerWidget wxDirButton @@ -147,7 +98,7 @@ protected: class WXDLLIMPEXP_CORE wxFileDirPickerCtrlBase : public wxPickerBase { public: - wxFileDirPickerCtrlBase() {} + wxFileDirPickerCtrlBase() : m_bIgnoreNextTextCtrlUpdate(false) {} protected: // NB: no default values since this function will never be used @@ -168,12 +119,6 @@ public: // public API wxString GetPath() const; void SetPath(const wxString &str); - // Set the directory to open the file browse dialog at initially. - void SetInitialDirectory(const wxString& dir) - { - m_pickerIface->SetInitialDirectory(dir); - } - public: // internal functions void UpdatePickerFromTextCtrl(); @@ -182,14 +127,17 @@ public: // internal functions // event handler for our picker void OnFileDirChange(wxFileDirPickerEvent &); + // Returns TRUE if the current path is a valid one + // (i.e. a valid file for a wxFilePickerWidget or a valid + // folder for a wxDirPickerWidget). + virtual bool CheckPath(const wxString &str) const = 0; + // TRUE if any textctrl change should update the current working directory virtual bool IsCwdToUpdate() const = 0; // Returns the event type sent by this picker virtual wxEventType GetEventType() const = 0; - virtual void DoConnect( wxControl *sender, wxFileDirPickerCtrlBase *eventSink ) = 0; - // Returns the filtered value currently placed in the text control (if present). virtual wxString GetTextCtrlValue() const = 0; @@ -203,6 +151,9 @@ protected: protected: + // true if the next UpdateTextCtrl() call is to ignore + bool m_bIgnoreNextTextCtrlUpdate; + // m_picker object as wxFileDirPickerWidgetBase interface wxFileDirPickerWidgetBase *m_pickerIface; }; @@ -256,16 +207,20 @@ public: const wxSize& size = wxDefaultSize, long style = wxFLP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxFilePickerCtrlNameStr); + const wxString& name = wxFilePickerCtrlNameStr) + { + return wxFileDirPickerCtrlBase::CreateBase(parent, id, path, + message, wildcard, + pos, size, style, + validator, name); + } - void SetFileName(const wxFileName &filename) - { SetPath(filename.GetFullPath()); } - - wxFileName GetFileName() const - { return wxFileName(GetPath()); } public: // overrides + // return true if the given path is valid for this control + bool CheckPath(const wxString& path) const; + // return the text control value in canonical form wxString GetTextCtrlValue() const; @@ -273,25 +228,16 @@ public: // overrides { return HasFlag(wxFLP_CHANGE_DIR); } wxEventType GetEventType() const - { return wxEVT_FILEPICKER_CHANGED; } - - virtual void DoConnect( wxControl *sender, wxFileDirPickerCtrlBase *eventSink ) - { - sender->Connect( wxEVT_FILEPICKER_CHANGED, - wxFileDirPickerEventHandler( wxFileDirPickerCtrlBase::OnFileDirChange ), - NULL, eventSink ); - } - + { return wxEVT_COMMAND_FILEPICKER_CHANGED; } protected: - virtual wxFileDirPickerWidgetBase *CreatePicker(wxWindow *parent, const wxString& path, const wxString& message, const wxString& wildcard) { return new wxFilePickerWidget(parent, wxID_ANY, - wxGetTranslation(wxFilePickerWidgetLabel), + wxFilePickerWidgetLabel, path, message, wildcard, wxDefaultPosition, wxDefaultSize, GetPickerStyle(GetWindowStyle())); @@ -300,13 +246,8 @@ protected: // extracts the style for our picker from wxFileDirPickerCtrlBase's style long GetPickerStyle(long style) const { - return style & (wxFLP_OPEN | - wxFLP_SAVE | - wxFLP_OVERWRITE_PROMPT | - wxFLP_FILE_MUST_EXIST | - wxFLP_CHANGE_DIR | - wxFLP_USE_TEXTCTRL | - wxFLP_SMALL); + return (style & (wxFLP_OPEN|wxFLP_SAVE|wxFLP_OVERWRITE_PROMPT| + wxFLP_FILE_MUST_EXIST|wxFLP_CHANGE_DIR)); } private: @@ -357,41 +298,35 @@ public: const wxSize& size = wxDefaultSize, long style = wxDIRP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDirPickerCtrlNameStr); + const wxString& name = wxDirPickerCtrlNameStr) + { + return wxFileDirPickerCtrlBase::CreateBase + ( + parent, id, path, message, wxEmptyString, + pos, size, style, validator, name + ); + } - void SetDirName(const wxFileName &dirname) - { SetPath(dirname.GetPath()); } - - wxFileName GetDirName() const - { return wxFileName::DirName(GetPath()); } public: // overrides + bool CheckPath(const wxString &path) const; + wxString GetTextCtrlValue() const; bool IsCwdToUpdate() const { return HasFlag(wxDIRP_CHANGE_DIR); } wxEventType GetEventType() const - { return wxEVT_DIRPICKER_CHANGED; } - - virtual void DoConnect( wxControl *sender, wxFileDirPickerCtrlBase *eventSink ) - { - sender->Connect( wxEVT_DIRPICKER_CHANGED, - wxFileDirPickerEventHandler( wxFileDirPickerCtrlBase::OnFileDirChange ), - NULL, eventSink ); - } - + { return wxEVT_COMMAND_DIRPICKER_CHANGED; } protected: - virtual wxFileDirPickerWidgetBase *CreatePicker(wxWindow *parent, const wxString& path, const wxString& message, const wxString& WXUNUSED(wildcard)) { - return new wxDirPickerWidget(parent, wxID_ANY, - wxGetTranslation(wxDirPickerWidgetLabel), + return new wxDirPickerWidget(parent, wxID_ANY, wxDirPickerWidgetLabel, path, message, wxDefaultPosition, wxDefaultSize, GetPickerStyle(GetWindowStyle())); @@ -399,12 +334,7 @@ protected: // extracts the style for our picker from wxFileDirPickerCtrlBase's style long GetPickerStyle(long style) const - { - return style & (wxDIRP_DIR_MUST_EXIST | - wxDIRP_CHANGE_DIR | - wxDIRP_USE_TEXTCTRL | - wxDIRP_SMALL); - } + { return (style & (wxDIRP_DIR_MUST_EXIST|wxDIRP_CHANGE_DIR)); } private: DECLARE_DYNAMIC_CLASS(wxDirPickerCtrl) @@ -412,9 +342,57 @@ private: #endif // wxUSE_DIRPICKERCTRL -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_FILEPICKER_CHANGED wxEVT_FILEPICKER_CHANGED -#define wxEVT_COMMAND_DIRPICKER_CHANGED wxEVT_DIRPICKER_CHANGED + +#if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL + +// ---------------------------------------------------------------------------- +// wxFileDirPickerEvent: used by wxFilePickerCtrl and wxDirPickerCtrl only +// ---------------------------------------------------------------------------- + +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_FILEPICKER_CHANGED, 1102) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_DIRPICKER_CHANGED, 1103) +END_DECLARE_EVENT_TYPES() + +class WXDLLIMPEXP_CORE wxFileDirPickerEvent : public wxCommandEvent +{ +public: + wxFileDirPickerEvent() {} + wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path) + : wxCommandEvent(type, id), + m_path(path) + { + SetEventObject(generator); + } + + wxString GetPath() const { return m_path; } + void SetPath(const wxString &p) { m_path = p; } + + // default copy ctor, assignment operator and dtor are ok + virtual wxEvent *Clone() const { return new wxFileDirPickerEvent(*this); } + +private: + wxString m_path; + + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileDirPickerEvent) +}; + +// ---------------------------------------------------------------------------- +// event types and macros +// ---------------------------------------------------------------------------- + +typedef void (wxEvtHandler::*wxFileDirPickerEventFunction)(wxFileDirPickerEvent&); + +#define wxFileDirPickerEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFileDirPickerEventFunction, &func) + +#define EVT_FILEPICKER_CHANGED(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_FILEPICKER_CHANGED, id, wxFileDirPickerEventHandler(fn)) +#define EVT_DIRPICKER_CHANGED(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_DIRPICKER_CHANGED, id, wxFileDirPickerEventHandler(fn)) + + +#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL #endif // _WX_FILEDIRPICKER_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/filesys.h b/Source/3rd Party/wx/include/wx/filesys.h index e4cbe45d4..3d40f1104 100644 --- a/Source/3rd Party/wx/include/wx/filesys.h +++ b/Source/3rd Party/wx/include/wx/filesys.h @@ -3,6 +3,7 @@ // Purpose: class for opening files - virtual file system // Author: Vaclav Slavik // Copyright: (c) 1999 Vaclav Slavik +// RCS-ID: $Id: filesys.h 53135 2008-04-12 02:31:04Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,8 +12,6 @@ #include "wx/defs.h" -#if wxUSE_FILESYSTEM - #if !wxUSE_STREAMS #error You cannot compile virtual file systems without wxUSE_STREAMS #endif @@ -21,6 +20,8 @@ #error You cannot compile wxHTML without virtual file systems #endif +#if wxUSE_FILESYSTEM + #include "wx/stream.h" #include "wx/datetime.h" #include "wx/filename.h" @@ -49,7 +50,7 @@ public: { m_Stream = stream; m_Location = loc; - m_MimeType = mimetype.Lower(); + m_MimeType = mimetype; m_MimeType.MakeLower(); m_Anchor = anchor; #if wxUSE_DATETIME m_Modif = modif; @@ -77,7 +78,7 @@ public: } // returns file's mime type - const wxString& GetMimeType() const; + const wxString& GetMimeType() const { return m_MimeType; } // returns the original location (aka filename) of the file const wxString& GetLocation() const { return m_Location; } @@ -98,7 +99,7 @@ private: #endif // wxUSE_DATETIME DECLARE_ABSTRACT_CLASS(wxFSFile) - wxDECLARE_NO_COPY_CLASS(wxFSFile); + DECLARE_NO_COPY_CLASS(wxFSFile) }; @@ -131,28 +132,28 @@ public: virtual wxString FindFirst(const wxString& spec, int flags = 0); virtual wxString FindNext(); - // Returns MIME type of the file - w/o need to open it - // (default behaviour is that it returns type based on extension) - static wxString GetMimeTypeFromExt(const wxString& location); - protected: // returns protocol ("file", "http", "tar" etc.) The last (most right) // protocol is used: // {it returns "tar" for "file:subdir/archive.tar.gz#tar:/README.txt"} - static wxString GetProtocol(const wxString& location); + wxString GetProtocol(const wxString& location) const; // returns left part of address: // {it returns "file:subdir/archive.tar.gz" for "file:subdir/archive.tar.gz#tar:/README.txt"} - static wxString GetLeftLocation(const wxString& location); + wxString GetLeftLocation(const wxString& location) const; // returns anchor part of address: // {it returns "anchor" for "file:subdir/archive.tar.gz#tar:/README.txt#anchor"} // NOTE: anchor is NOT a part of GetLeftLocation()'s return value - static wxString GetAnchor(const wxString& location); + wxString GetAnchor(const wxString& location) const; // returns right part of address: // {it returns "/README.txt" for "file:subdir/archive.tar.gz#tar:/README.txt"} - static wxString GetRightLocation(const wxString& location); + wxString GetRightLocation(const wxString& location) const; + + // Returns MIME type of the file - w/o need to open it + // (default behaviour is that it returns type based on extension) + wxString GetMimeTypeFromExt(const wxString& location); DECLARE_ABSTRACT_CLASS(wxFileSystemHandler) }; @@ -167,8 +168,7 @@ protected: //-------------------------------------------------------------------------------- // Open Bit Flags -enum wxFileSystemOpenFlags -{ +enum { wxFS_READ = 1, // Open for reading wxFS_SEEKABLE = 4 // Returned stream will be seekable }; @@ -205,8 +205,7 @@ public: wxString FindNext(); // find a file in a list of directories, returns false if not found - bool FindFileInPath(wxString *pStr, - const wxString& path, const wxString& file); + bool FindFileInPath(wxString *pStr, const wxChar *path, const wxChar *file); // Adds FS handler. // In fact, this class is only front-end to the FS handlers :-) @@ -246,7 +245,7 @@ protected: // Handlers local to this instance DECLARE_DYNAMIC_CLASS(wxFileSystem) - wxDECLARE_NO_COPY_CLASS(wxFileSystem); + DECLARE_NO_COPY_CLASS(wxFileSystem) }; @@ -292,20 +291,7 @@ protected: static wxString ms_root; }; -// Stream reading data from wxFSFile: this allows to use virtual files with any -// wx functions accepting streams. -class WXDLLIMPEXP_BASE wxFSInputStream : public wxWrapperInputStream -{ -public: - // Notice that wxFS_READ is implied in flags. - wxFSInputStream(const wxString& filename, int flags = 0); - virtual ~wxFSInputStream(); -private: - wxFSFile* m_file; - - wxDECLARE_NO_COPY_CLASS(wxFSInputStream); -}; #endif // wxUSE_FILESYSTEM diff --git a/Source/3rd Party/wx/include/wx/flags.h b/Source/3rd Party/wx/include/wx/flags.h index 7958b51bc..803205fdf 100644 --- a/Source/3rd Party/wx/include/wx/flags.h +++ b/Source/3rd Party/wx/include/wx/flags.h @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 27/07/03 +// RCS-ID: $Id: flags.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) 2003 Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -152,10 +153,8 @@ private : unsigned long m_data; }; -#if wxUSE_EXTENDED_RTTI - -#define wxDEFINE_FLAGS( flags ) \ - class WXDLLIMPEXP_BASE flags \ +#define WX_DEFINE_FLAGS( flags ) \ + class WXDLLEXPORT flags \ {\ public : \ flags(long data=0) :m_data(data) {} \ @@ -163,14 +162,4 @@ private : bool operator ==(const flags &rhs) const { return m_data == rhs.m_data; }\ } ; -#else - -#define wxDEFINE_FLAGS( flags ) - -#endif - -#if WXWIN_COMPATIBILITY_2_8 - #define WX_DEFINE_FLAGS wxDEFINE_FLAGS -#endif - #endif diff --git a/Source/3rd Party/wx/include/wx/fmappriv.h b/Source/3rd Party/wx/include/wx/fmappriv.h index 5c6abefe6..95df28c90 100644 --- a/Source/3rd Party/wx/include/wx/fmappriv.h +++ b/Source/3rd Party/wx/include/wx/fmappriv.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 21.06.2003 (extracted from common/fontmap.cpp) +// RCS-ID: $Id: fmappriv.h 27454 2004-05-26 10:49:43Z JS $ // Copyright: (c) 1999-2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -64,7 +65,7 @@ private: bool m_ok; - wxDECLARE_NO_COPY_CLASS(wxFontMapperPathChanger); + DECLARE_NO_COPY_CLASS(wxFontMapperPathChanger) }; #endif // wxUSE_CONFIG diff --git a/Source/3rd Party/wx/include/wx/font.h b/Source/3rd Party/wx/include/wx/font.h index 27c836d20..751262626 100644 --- a/Source/3rd Party/wx/include/wx/font.h +++ b/Source/3rd Party/wx/include/wx/font.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.09.99 +// RCS-ID: $Id: font.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,13 +19,15 @@ #include "wx/defs.h" // for wxDEFAULT &c #include "wx/fontenc.h" // the font encoding constants #include "wx/gdiobj.h" // the base class -#include "wx/gdicmn.h" // for wxGDIObjListBase // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- +class WXDLLIMPEXP_FWD_CORE wxFontData; +class WXDLLIMPEXP_FWD_CORE wxFontBase; class WXDLLIMPEXP_FWD_CORE wxFont; +class WXDLLIMPEXP_FWD_CORE wxSize; // ---------------------------------------------------------------------------- // font constants @@ -65,20 +68,8 @@ enum wxFontWeight wxFONTWEIGHT_MAX }; -// Symbolic font sizes as defined in CSS specification. -enum wxFontSymbolicSize -{ - wxFONTSIZE_XX_SMALL = -3, - wxFONTSIZE_X_SMALL, - wxFONTSIZE_SMALL, - wxFONTSIZE_MEDIUM, - wxFONTSIZE_LARGE, - wxFONTSIZE_X_LARGE, - wxFONTSIZE_XX_LARGE -}; - // the font flag bits for the new font ctor accepting one combined flags word -enum wxFontFlag +enum { // no special flags: font with default weight/slant/anti-aliasing wxFONTFLAG_DEFAULT = 0, @@ -110,182 +101,18 @@ enum wxFontFlag wxFONTFLAG_STRIKETHROUGH }; -// ---------------------------------------------------------------------------- -// wxFontInfo describes a wxFont -// ---------------------------------------------------------------------------- - -class wxFontInfo -{ -public: - // Default ctor uses the default font size appropriate for the current - // platform. - wxFontInfo() - { InitPointSize(-1); } - - // These ctors specify the font size, either in points or in pixels. - wxEXPLICIT wxFontInfo(int pointSize) - { InitPointSize(pointSize); } - wxEXPLICIT wxFontInfo(const wxSize& pixelSize) : m_pixelSize(pixelSize) - { Init(); } - - // Setters for the various attributes. All of them return the object itself - // so that the calls to them could be chained. - wxFontInfo& Family(wxFontFamily family) - { m_family = family; return *this; } - wxFontInfo& FaceName(const wxString& faceName) - { m_faceName = faceName; return *this; } - - wxFontInfo& Bold(bool bold = true) - { SetFlag(wxFONTFLAG_BOLD, bold); return *this; } - wxFontInfo& Light(bool light = true) - { SetFlag(wxFONTFLAG_LIGHT, light); return *this; } - - wxFontInfo& Italic(bool italic = true) - { SetFlag(wxFONTFLAG_ITALIC, italic); return *this; } - wxFontInfo& Slant(bool slant = true) - { SetFlag(wxFONTFLAG_SLANT, slant); return *this; } - - wxFontInfo& AntiAliased(bool antiAliased = true) - { SetFlag(wxFONTFLAG_ANTIALIASED, antiAliased); return *this; } - wxFontInfo& Underlined(bool underlined = true) - { SetFlag(wxFONTFLAG_UNDERLINED, underlined); return *this; } - wxFontInfo& Strikethrough(bool strikethrough = true) - { SetFlag(wxFONTFLAG_STRIKETHROUGH, strikethrough); return *this; } - - wxFontInfo& Encoding(wxFontEncoding encoding) - { m_encoding = encoding; return *this; } - - - // Set all flags at once. - wxFontInfo& AllFlags(int flags) - { m_flags = flags; return *this; } - - - // Accessors are mostly meant to be used by wxFont itself to extract the - // various pieces of the font description. - - bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; } - int GetPointSize() const { return m_pointSize; } - wxSize GetPixelSize() const { return m_pixelSize; } - wxFontFamily GetFamily() const { return m_family; } - const wxString& GetFaceName() const { return m_faceName; } - - wxFontStyle GetStyle() const - { - return m_flags & wxFONTFLAG_ITALIC - ? wxFONTSTYLE_ITALIC - : m_flags & wxFONTFLAG_SLANT - ? wxFONTSTYLE_SLANT - : wxFONTSTYLE_NORMAL; - } - - wxFontWeight GetWeight() const - { - return m_flags & wxFONTFLAG_LIGHT - ? wxFONTWEIGHT_LIGHT - : m_flags & wxFONTFLAG_BOLD - ? wxFONTWEIGHT_BOLD - : wxFONTWEIGHT_NORMAL; - } - - bool IsAntiAliased() const - { - return (m_flags & wxFONTFLAG_ANTIALIASED) != 0; - } - - bool IsUnderlined() const - { - return (m_flags & wxFONTFLAG_UNDERLINED) != 0; - } - - bool IsStrikethrough() const - { - return (m_flags & wxFONTFLAG_STRIKETHROUGH) != 0; - } - - wxFontEncoding GetEncoding() const { return m_encoding; } - - - // Default copy ctor, assignment operator and dtor are OK. - -private: - // Common part of all ctor, initializing everything except the size (which - // is initialized by the ctors themselves). - void Init() - { - m_family = wxFONTFAMILY_DEFAULT; - m_flags = wxFONTFLAG_DEFAULT; - m_encoding = wxFONTENCODING_DEFAULT; - } - - void InitPointSize(int pointSize) - { - Init(); - - m_pointSize = pointSize; - m_pixelSize = wxDefaultSize; - } - - // Turn on or off the given bit in m_flags depending on the value of the - // boolean argument. - void SetFlag(int flag, bool on) - { - if ( on ) - m_flags |= flag; - else - m_flags &= ~flag; - } - - // The size information: if m_pixelSize is valid (!= wxDefaultSize), then - // it is used. Otherwise m_pointSize is used, taking into account that if - // it is == -1, it means that the platform dependent font size should be - // used. - int m_pointSize; - wxSize m_pixelSize; - - wxFontFamily m_family; - wxString m_faceName; - int m_flags; - wxFontEncoding m_encoding; -}; - // ---------------------------------------------------------------------------- // wxFontBase represents a font object // ---------------------------------------------------------------------------- class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo; -class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject +class WXDLLEXPORT wxFontBase : public wxGDIObject { public: - /* - derived classes should provide the following ctors: - - wxFont(); - wxFont(const wxFontInfo& info); - wxFont(const wxString& nativeFontInfoString); - wxFont(const wxNativeFontInfo& info); - wxFont(int size, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - wxFont(const wxSize& pixelSize, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - */ - // creator function virtual ~wxFontBase(); - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 // from the font components static wxFont *New( int pointSize, // size of the font in points @@ -294,41 +121,6 @@ public: int weight, // see wxFontWeight enum bool underlined = false, // not underlined by default const wxString& face = wxEmptyString, // facename - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ... - { return New(pointSize, (wxFontFamily)family, (wxFontStyle)style, - (wxFontWeight)weight, underlined, face, encoding); } - - // from the font components - static wxFont *New( - const wxSize& pixelSize, // size of the font in pixels - int family, // see wxFontFamily enum - int style, // see wxFontStyle enum - int weight, // see wxFontWeight enum - bool underlined = false, // not underlined by default - const wxString& face = wxEmptyString, // facename - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ... - { return New(pixelSize, (wxFontFamily)family, (wxFontStyle)style, - (wxFontWeight)weight, underlined, face, encoding); } -#endif - - // from the font components - static wxFont *New( - int pointSize, // size of the font in points - wxFontFamily family, // see wxFontFamily enum - wxFontStyle style, // see wxFontStyle enum - wxFontWeight weight, // see wxFontWeight enum - bool underlined = false, // not underlined by default - const wxString& face = wxEmptyString, // facename - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... - - // from the font components - static wxFont *New( - const wxSize& pixelSize, // size of the font in pixels - wxFontFamily family, // see wxFontFamily enum - wxFontStyle style, // see wxFontStyle enum - wxFontWeight weight, // see wxFontWeight enum - bool underlined = false, // not underlined by default - const wxString& face = wxEmptyString, // facename wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... // from the font components but using the font flags instead of separate @@ -339,6 +131,15 @@ public: const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + // from the font components + static wxFont *New( + const wxSize& pixelSize, // size of the font in pixels + int family, // see wxFontFamily enum + int style, // see wxFontStyle enum + int weight, // see wxFontWeight enum + bool underlined = false, // not underlined by default + const wxString& face = wxEmptyString, // facename + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... // from the font components but using the font flags instead of separate // parameters for each flag @@ -354,19 +155,22 @@ public: // from the string representation of wxNativeFontInfo static wxFont *New(const wxString& strNativeFontDesc); + // was the font successfully created? + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_refData != NULL; } + // comparison - bool operator==(const wxFont& font) const; - bool operator!=(const wxFont& font) const { return !(*this == font); } + bool operator == (const wxFont& font) const; + bool operator != (const wxFont& font) const; // accessors: get the font characteristics virtual int GetPointSize() const = 0; virtual wxSize GetPixelSize() const; virtual bool IsUsingSizeInPixels() const; - wxFontFamily GetFamily() const; - virtual wxFontStyle GetStyle() const = 0; - virtual wxFontWeight GetWeight() const = 0; + virtual int GetFamily() const = 0; + virtual int GetStyle() const = 0; + virtual int GetWeight() const = 0; virtual bool GetUnderlined() const = 0; - virtual bool GetStrikethrough() const { return false; } virtual wxString GetFaceName() const = 0; virtual wxFontEncoding GetEncoding() const = 0; virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0; @@ -379,12 +183,10 @@ public: // change the font characteristics virtual void SetPointSize( int pointSize ) = 0; virtual void SetPixelSize( const wxSize& pixelSize ); - virtual void SetFamily( wxFontFamily family ) = 0; - virtual void SetStyle( wxFontStyle style ) = 0; - virtual void SetWeight( wxFontWeight weight ) = 0; - + virtual void SetFamily( int family ) = 0; + virtual void SetStyle( int style ) = 0; + virtual void SetWeight( int weight ) = 0; virtual void SetUnderlined( bool underlined ) = 0; - virtual void SetStrikethrough( bool WXUNUSED(strikethrough) ) {} virtual void SetEncoding(wxFontEncoding encoding) = 0; virtual bool SetFaceName( const wxString& faceName ); void SetNativeFontInfo(const wxNativeFontInfo& info) @@ -393,75 +195,25 @@ public: bool SetNativeFontInfo(const wxString& info); bool SetNativeFontInfoUserDesc(const wxString& info); - // Symbolic font sizes support: set the font size to "large" or "very - // small" either absolutely (i.e. compared to the default font size) or - // relatively to the given font size. - void SetSymbolicSize(wxFontSymbolicSize size); - void SetSymbolicSizeRelativeTo(wxFontSymbolicSize size, int base) - { - SetPointSize(AdjustToSymbolicSize(size, base)); - } - - // Adjust the base size in points according to symbolic size. - static int AdjustToSymbolicSize(wxFontSymbolicSize size, int base); - - // translate the fonts into human-readable string (i.e. GetStyleString() // will return "wxITALIC" for an italic font, ...) wxString GetFamilyString() const; wxString GetStyleString() const; wxString GetWeightString() const; + // Unofficial API, don't use + virtual void SetNoAntiAliasing( bool WXUNUSED(no) = true ) { } + virtual bool GetNoAntiAliasing() const { return false; } + // the default encoding is used for creating all fonts with default // encoding parameter static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } static void SetDefaultEncoding(wxFontEncoding encoding); - // this doesn't do anything and is kept for compatibility only -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_INLINE(void SetNoAntiAliasing(bool no = true), wxUnusedVar(no);) - wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;) -#endif // WXWIN_COMPATIBILITY_2_8 - protected: // the function called by both overloads of SetNativeFontInfo() virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); - // The function called by public GetFamily(): it can return - // wxFONTFAMILY_UNKNOWN unlike the public method (see comment there). - virtual wxFontFamily DoGetFamily() const = 0; - - - // Helper functions to recover wxFONTSTYLE/wxFONTWEIGHT and underlined flag - // values from flags containing a combination of wxFONTFLAG_XXX. - static wxFontStyle GetStyleFromFlags(int flags) - { - return flags & wxFONTFLAG_ITALIC - ? wxFONTSTYLE_ITALIC - : flags & wxFONTFLAG_SLANT - ? wxFONTSTYLE_SLANT - : wxFONTSTYLE_NORMAL; - } - - static wxFontWeight GetWeightFromFlags(int flags) - { - return flags & wxFONTFLAG_LIGHT - ? wxFONTWEIGHT_LIGHT - : flags & wxFONTFLAG_BOLD - ? wxFONTWEIGHT_BOLD - : wxFONTWEIGHT_NORMAL; - } - - static bool GetUnderlinedFromFlags(int flags) - { - return (flags & wxFONTFLAG_UNDERLINED) != 0; - } - - static bool GetStrikethroughFromFlags(int flags) - { - return (flags & wxFONTFLAG_STRIKETHROUGH) != 0; - } - private: // the currently default encoding: by default, it's the default system // encoding, but may be changed by the application using @@ -470,52 +222,10 @@ private: static wxFontEncoding ms_encodingDefault; }; -// wxFontBase <-> wxString utilities, used by wxConfig -WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font); -WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font); - - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 -#define wxDECLARE_FONT_COMPAT_SETTER \ - wxDEPRECATED_FUTURE( void SetFamily(int family) ) \ - { SetFamily((wxFontFamily)family); } \ - wxDEPRECATED_FUTURE( void SetStyle(int style) ) \ - { SetStyle((wxFontStyle)style); } \ - wxDEPRECATED_FUTURE( void SetWeight(int weight) ) \ - { SetWeight((wxFontWeight)weight); } \ - wxDEPRECATED_FUTURE( void SetFamily(wxDeprecatedGUIConstants family) ) \ - { SetFamily((wxFontFamily)family); } \ - wxDEPRECATED_FUTURE( void SetStyle(wxDeprecatedGUIConstants style) ) \ - { SetStyle((wxFontStyle)style); } \ - wxDEPRECATED_FUTURE( void SetWeight(wxDeprecatedGUIConstants weight) ) \ - { SetWeight((wxFontWeight)weight); } -#else -#define wxDECLARE_FONT_COMPAT_SETTER /*empty*/ -#endif - -// this macro must be used in all derived wxFont classes declarations -#define wxDECLARE_COMMON_FONT_METHODS() \ - wxDECLARE_FONT_COMPAT_SETTER \ - \ - /* functions for modifying font in place */ \ - wxFont& MakeBold(); \ - wxFont& MakeItalic(); \ - wxFont& MakeUnderlined(); \ - wxFont& MakeStrikethrough(); \ - wxFont& MakeLarger() { return Scale(1.2f); } \ - wxFont& MakeSmaller() { return Scale(1/1.2f); } \ - wxFont& Scale(float x); \ - /* functions for creating fonts based on this one */ \ - wxFont Bold() const; \ - wxFont Italic() const; \ - wxFont Underlined() const; \ - wxFont Strikethrough() const; \ - wxFont Larger() const { return Scaled(1.2f); } \ - wxFont Smaller() const { return Scaled(1/1.2f); } \ - wxFont Scaled(float x) const - // include the real class declaration -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/palmos/font.h" +#elif defined(__WXMSW__) #include "wx/msw/font.h" #elif defined(__WXMOTIF__) #include "wx/motif/font.h" @@ -525,74 +235,17 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font); #include "wx/gtk1/font.h" #elif defined(__WXX11__) #include "wx/x11/font.h" +#elif defined(__WXMGL__) + #include "wx/mgl/font.h" #elif defined(__WXDFB__) #include "wx/dfb/font.h" #elif defined(__WXMAC__) - #include "wx/osx/font.h" + #include "wx/mac/font.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/font.h" #elif defined(__WXPM__) #include "wx/os2/font.h" #endif -class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase -{ -public: - wxFont *FindOrCreateFont(int pointSize, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underline = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight, - bool underline = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style, - (wxFontWeight)weight, underline, face, encoding); } -#endif - -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( void AddFont(wxFont*) ); - wxDEPRECATED( void RemoveFont(wxFont*) ); -#endif -}; - -extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList; - - -// provide comparison operators to allow code such as -// -// if ( font.GetStyle() == wxFONTSTYLE_SLANT ) -// -// to compile without warnings which it would otherwise provoke from some -// compilers as it compares elements of different enums -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - -// Unfortunately some compilers have ambiguity issues when enum comparisons are -// overloaded so we have to disable the overloads in this case, see -// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details. -#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM - -inline bool operator==(wxFontFamily s, wxDeprecatedGUIConstants t) -{ return static_cast(s) == static_cast(t); } -inline bool operator!=(wxFontFamily s, wxDeprecatedGUIConstants t) -{ return !(s == t); } -inline bool operator==(wxFontStyle s, wxDeprecatedGUIConstants t) -{ return static_cast(s) == static_cast(t); } -inline bool operator!=(wxFontStyle s, wxDeprecatedGUIConstants t) -{ return !(s == t); } -inline bool operator==(wxFontWeight s, wxDeprecatedGUIConstants t) -{ return static_cast(s) == static_cast(t); } -inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t) -{ return !(s == t); } - -#endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM - -#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 - #endif // _WX_FONT_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/fontdata.h b/Source/3rd Party/wx/include/wx/fontdata.h deleted file mode 100644 index 87571ce94..000000000 --- a/Source/3rd Party/wx/include/wx/fontdata.h +++ /dev/null @@ -1,70 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/fontdata.h -// Author: Julian Smart -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FONTDATA_H_ -#define _WX_FONTDATA_H_ - -#include "wx/font.h" -#include "wx/colour.h" -#include "wx/encinfo.h" - -class WXDLLIMPEXP_CORE wxFontData : public wxObject -{ -public: - wxFontData(); - virtual ~wxFontData(); - - wxFontData(const wxFontData& data); - wxFontData& operator=(const wxFontData& data); - - void SetAllowSymbols(bool flag) { m_allowSymbols = flag; } - bool GetAllowSymbols() const { return m_allowSymbols; } - - void SetColour(const wxColour& colour) { m_fontColour = colour; } - const wxColour& GetColour() const { return m_fontColour; } - - void SetShowHelp(bool flag) { m_showHelp = flag; } - bool GetShowHelp() const { return m_showHelp; } - - void EnableEffects(bool flag) { m_enableEffects = flag; } - bool GetEnableEffects() const { return m_enableEffects; } - - void SetInitialFont(const wxFont& font) { m_initialFont = font; } - wxFont GetInitialFont() const { return m_initialFont; } - - void SetChosenFont(const wxFont& font) { m_chosenFont = font; } - wxFont GetChosenFont() const { return m_chosenFont; } - - void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; } - - // encoding info is split into 2 parts: the logical wxWin encoding - // (wxFontEncoding) and a structure containing the native parameters for - // it (wxNativeEncodingInfo) - wxFontEncoding GetEncoding() const { return m_encoding; } - void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; } - - wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; } - - - // public for backwards compatibility only: don't use directly - wxColour m_fontColour; - bool m_showHelp; - bool m_allowSymbols; - bool m_enableEffects; - wxFont m_initialFont; - wxFont m_chosenFont; - int m_minSize; - int m_maxSize; - -private: - wxFontEncoding m_encoding; - wxNativeEncodingInfo m_encodingInfo; - - DECLARE_DYNAMIC_CLASS(wxFontData) -}; - -#endif // _WX_FONTDATA_H_ diff --git a/Source/3rd Party/wx/include/wx/fontdlg.h b/Source/3rd Party/wx/include/wx/fontdlg.h index 2bbb9e827..f93bba49e 100644 --- a/Source/3rd Party/wx/include/wx/fontdlg.h +++ b/Source/3rd Party/wx/include/wx/fontdlg.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 12.05.02 +// RCS-ID: $Id: fontdlg.h 41846 2006-10-09 22:56:48Z VZ $ // Copyright: (c) 1997-2002 wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,13 +17,13 @@ #if wxUSE_FONTDLG #include "wx/dialog.h" // the base class -#include "wx/fontdata.h" +#include "wx/cmndata.h" // wxFontData // ---------------------------------------------------------------------------- // wxFontDialog interface // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFontDialogBase : public wxDialog +class WXDLLEXPORT wxFontDialogBase : public wxDialog { public: // create the font dialog @@ -36,6 +37,8 @@ public: bool Create(wxWindow *parent, const wxFontData& data) { InitFontData(&data); return Create(parent); } + virtual ~wxFontDialogBase(); + // retrieve the font data const wxFontData& GetFontData() const { return m_fontData; } wxFontData& GetFontData() { return m_fontData; } @@ -55,7 +58,7 @@ protected: wxFontData m_fontData; - wxDECLARE_NO_COPY_CLASS(wxFontDialogBase); + DECLARE_NO_COPY_CLASS(wxFontDialogBase) }; #if WXWIN_COMPATIBILITY_2_6 @@ -71,7 +74,7 @@ inline bool wxFontDialogBase::Create(wxWindow *parent, const wxFontData *data) // platform-specific wxFontDialog implementation // ---------------------------------------------------------------------------- -#if defined( __WXOSX_MAC__ ) +#if defined( __WXMAC_OSX__ ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 ) //set to 1 to use native mac font and color dialogs #define USE_NATIVE_FONT_DIALOG_FOR_MACOSX 1 #else @@ -96,7 +99,7 @@ inline bool wxFontDialogBase::Create(wxWindow *parent, const wxFontData *data) #elif defined(__WXPM__) #include "wx/os2/fontdlg.h" #elif defined(__WXMAC__) - #include "wx/osx/fontdlg.h" + #include "wx/mac/fontdlg.h" #endif // ---------------------------------------------------------------------------- @@ -105,9 +108,9 @@ inline bool wxFontDialogBase::Create(wxWindow *parent, const wxFontData *data) // get the font from user and return it, returns wxNullFont if the dialog was // cancelled -WXDLLIMPEXP_CORE wxFont wxGetFontFromUser(wxWindow *parent = NULL, - const wxFont& fontInit = wxNullFont, - const wxString& caption = wxEmptyString); +wxFont WXDLLEXPORT +wxGetFontFromUser(wxWindow *parent = (wxWindow *)NULL, + const wxFont& fontInit = wxNullFont, const wxString& caption = wxEmptyString); #endif // wxUSE_FONTDLG diff --git a/Source/3rd Party/wx/include/wx/fontenc.h b/Source/3rd Party/wx/include/wx/fontenc.h index 25cfec12e..b80acafff 100644 --- a/Source/3rd Party/wx/include/wx/fontenc.h +++ b/Source/3rd Party/wx/include/wx/fontenc.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29.03.00 +// RCS-ID: $Id: fontenc.h 29139 2004-09-14 12:08:28Z ABX $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ enum wxFontEncoding wxFONTENCODING_CP874, // WinThai wxFONTENCODING_CP932, // Japanese (shift-JIS) wxFONTENCODING_CP936, // Chinese simplified (GB) - wxFONTENCODING_CP949, // Korean (Hangul charset, a.k.a. EUC-KR) + wxFONTENCODING_CP949, // Korean (Hangul charset) wxFONTENCODING_CP950, // Chinese (traditional - Big5) wxFONTENCODING_CP1250, // WinLatin2 wxFONTENCODING_CP1251, // WinCyrillic @@ -64,8 +65,6 @@ enum wxFontEncoding wxFONTENCODING_CP1255, // WinHebrew wxFONTENCODING_CP1256, // WinArabic wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) - wxFONTENCODING_CP1258, // WinVietnamese - wxFONTENCODING_CP1361, // Johab Korean character set. wxFONTENCODING_CP12_MAX, wxFONTENCODING_UTF7, // UTF-7 Unicode encoding @@ -117,10 +116,6 @@ enum wxFontEncoding wxFONTENCODING_MACGAELIC, wxFONTENCODING_MACKEYBOARD, - // more CJK encodings (for historical reasons some are already declared - // above) - wxFONTENCODING_ISO2022_JP, // ISO-2022-JP JIS encoding - wxFONTENCODING_MAX, // highest enumerated encoding value wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN , @@ -149,14 +144,7 @@ enum wxFontEncoding wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html) - wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, // Shift JIS - - // Korean (CP 949 not actually the same but close enough) - wxFONTENCODING_EUC_KR = wxFONTENCODING_CP949, - wxFONTENCODING_JOHAB = wxFONTENCODING_CP1361, - - // Vietnamese - wxFONTENCODING_VIETNAMESE = wxFONTENCODING_CP1258 + wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 // Shift JIS }; #endif // _WX_FONTENC_H_ diff --git a/Source/3rd Party/wx/include/wx/fontenum.h b/Source/3rd Party/wx/include/wx/fontenum.h index 96cbb00fe..8ea5a23c9 100644 --- a/Source/3rd Party/wx/include/wx/fontenum.h +++ b/Source/3rd Party/wx/include/wx/fontenum.h @@ -5,6 +5,7 @@ // Modified by: extended to enumerate more than just font facenames and works // not only on Windows now (VZ) // Created: 04/01/98 +// RCS-ID: $Id: fontenum.h 43727 2006-12-01 10:14:28Z VS $ // Copyright: (c) Julian Smart, Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,19 +13,20 @@ #ifndef _WX_FONTENUM_H_ #define _WX_FONTENUM_H_ -#include "wx/defs.h" - -#if wxUSE_FONTENUM - #include "wx/fontenc.h" #include "wx/arrstr.h" +#if wxUSE_PANGO || defined(__WXDFB__) + // defined if the port uses only UTF-8 font encodings internally + #define wxHAS_UTF8_FONTS +#endif + // ---------------------------------------------------------------------------- // wxFontEnumerator enumerates all available fonts on the system or only the // fonts with given attributes // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFontEnumerator +class WXDLLEXPORT wxFontEnumerator { public: wxFontEnumerator() {} @@ -80,9 +82,7 @@ private: bool EnumerateEncodingsUTF8(const wxString& facename); #endif - wxDECLARE_NO_COPY_CLASS(wxFontEnumerator); + DECLARE_NO_COPY_CLASS(wxFontEnumerator) }; -#endif // wxUSE_FONTENUM - #endif // _WX_FONTENUM_H_ diff --git a/Source/3rd Party/wx/include/wx/fontmap.h b/Source/3rd Party/wx/include/wx/fontmap.h index 2bbc46296..c30511328 100644 --- a/Source/3rd Party/wx/include/wx/fontmap.h +++ b/Source/3rd Party/wx/include/wx/fontmap.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 04.11.99 +// RCS-ID: $Id: fontmap.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -49,7 +50,7 @@ class WXDLLIMPEXP_FWD_CORE wxFontMapper; class WXDLLIMPEXP_BASE wxFontMapperBase { public: - // constructor and such + // constructtor and such // --------------------- // default ctor @@ -121,7 +122,7 @@ public: void SetConfigPath(const wxString& prefix); // return default config path - static const wxString& GetDefaultConfigPath(); + static const wxChar *GetDefaultConfigPath(); #endif // wxUSE_CONFIG @@ -169,7 +170,7 @@ private: friend class wxFontMapperPathChanger; - wxDECLARE_NO_COPY_CLASS(wxFontMapperBase); + DECLARE_NO_COPY_CLASS(wxFontMapperBase) }; // ---------------------------------------------------------------------------- @@ -263,7 +264,7 @@ protected: wxWindow *m_windowParent; private: - wxDECLARE_NO_COPY_CLASS(wxFontMapper); + DECLARE_NO_COPY_CLASS(wxFontMapper) }; #endif // wxUSE_GUI diff --git a/Source/3rd Party/wx/include/wx/fontpicker.h b/Source/3rd Party/wx/include/wx/fontpicker.h index a5cc0f187..d13d0b22f 100644 --- a/Source/3rd Party/wx/include/wx/fontpicker.h +++ b/Source/3rd Party/wx/include/wx/fontpicker.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Francesco Montorsi +// RCS-ID: $Id: fontpicker.h 53135 2008-04-12 02:31:04Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -21,8 +22,8 @@ class WXDLLIMPEXP_FWD_CORE wxFontPickerEvent; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFontPickerWidgetNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxFontPickerCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFontPickerWidgetNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFontPickerCtrlNameStr[]; // ---------------------------------------------------------------------------- @@ -65,11 +66,8 @@ protected: // uses the currently selected font to draw the label of the button #define wxFNTP_USEFONT_FOR_LABEL 0x0010 -#define wxFONTBTN_DEFAULT_STYLE \ - (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL) - -// native version currently only exists in wxGTK2 -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +// since GTK > 2.4, there is GtkFontButton +#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/fontpicker.h" #define wxFontPickerWidget wxFontButton #else @@ -99,7 +97,8 @@ class WXDLLIMPEXP_CORE wxFontPickerCtrl : public wxPickerBase { public: wxFontPickerCtrl() - : m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) + : m_bIgnoreNextTextCtrlUpdate(false), + m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) { } @@ -114,7 +113,8 @@ public: long style = wxFNTP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxFontPickerCtrlNameStr) - : m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) + : m_bIgnoreNextTextCtrlUpdate(false), + m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) { Create(parent, id, initial, pos, size, style, validator, name); } @@ -162,6 +162,9 @@ protected: long GetPickerStyle(long style) const { return (style & (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)); } + // true if the next UpdateTextCtrl() call is to ignore + bool m_bIgnoreNextTextCtrlUpdate; + // the maximum pointsize allowed to the user unsigned int m_nMaxPointSize; @@ -174,14 +177,16 @@ private: // wxFontPickerEvent: used by wxFontPickerCtrl only // ---------------------------------------------------------------------------- -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FONTPICKER_CHANGED, wxFontPickerEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_FONTPICKER_CHANGED, 1102) +END_DECLARE_EVENT_TYPES() class WXDLLIMPEXP_CORE wxFontPickerEvent : public wxCommandEvent { public: wxFontPickerEvent() {} wxFontPickerEvent(wxObject *generator, int id, const wxFont &f) - : wxCommandEvent(wxEVT_FONTPICKER_CHANGED, id), + : wxCommandEvent(wxEVT_COMMAND_FONTPICKER_CHANGED, id), m_font(f) { SetEventObject(generator); @@ -206,13 +211,10 @@ private: typedef void (wxEvtHandler::*wxFontPickerEventFunction)(wxFontPickerEvent&); #define wxFontPickerEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxFontPickerEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFontPickerEventFunction, &func) #define EVT_FONTPICKER_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_FONTPICKER_CHANGED, id, wxFontPickerEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_FONTPICKER_CHANGED wxEVT_FONTPICKER_CHANGED + wx__DECLARE_EVT1(wxEVT_COMMAND_FONTPICKER_CHANGED, id, wxFontPickerEventHandler(fn)) #endif // wxUSE_FONTPICKERCTRL diff --git a/Source/3rd Party/wx/include/wx/fontutil.h b/Source/3rd Party/wx/include/wx/fontutil.h index 05592bf26..c0c46e458 100644 --- a/Source/3rd Party/wx/include/wx/fontutil.h +++ b/Source/3rd Party/wx/include/wx/fontutil.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05.11.99 +// RCS-ID: $Id: fontutil.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -64,17 +65,11 @@ enum wxXLFDField // functions, the user code can only get the objects of this type from // somewhere and pass it somewhere else (possibly save them somewhere using // ToString() and restore them using FromString()) - -class WXDLLIMPEXP_CORE wxNativeFontInfo +class WXDLLEXPORT wxNativeFontInfo { public: #if wxUSE_PANGO PangoFontDescription *description; - - // Pango font description doesn't have these attributes, so we store them - // separately and handle them ourselves in {To,From}String() methods. - bool m_underlined; - bool m_strikethrough; #elif defined(_WX_X_FONTLIKE) // the members can't be accessed directly as we only parse the // xFontName on demand @@ -110,77 +105,12 @@ public: // set the XFLD void SetXFontName(const wxString& xFontName); #elif defined(__WXMSW__) - wxNativeFontInfo(const LOGFONT& lf_) : lf(lf_) { } - LOGFONT lf; #elif defined(__WXPM__) // OS/2 native structures that define a font FATTRS fa; FONTMETRICS fm; FACENAMEDESC fn; -#elif defined(__WXOSX__) -public: - wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); } - wxNativeFontInfo( int size, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined, - const wxString& faceName, - wxFontEncoding encoding) - { Init(size,family,style,weight,underlined,faceName,encoding); } - - ~wxNativeFontInfo() { Free(); } - - wxNativeFontInfo& operator=(const wxNativeFontInfo& info) - { - if (this != &info) - { - Free(); - Init(info); - } - return *this; - } - - void Init(CTFontDescriptorRef descr); - void Init(const wxNativeFontInfo& info); - void Init(int size, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined, - const wxString& faceName , - wxFontEncoding encoding); - - void Free(); - void EnsureValid(); - - static void UpdateNamesMap(const wxString& familyname, CTFontDescriptorRef descr); - static void UpdateNamesMap(const wxString& familyname, CTFontRef font); - - bool m_descriptorValid; - -#if wxOSX_USE_ATSU_TEXT - bool m_atsuFontValid; - // the atsu font ID - wxUint32 m_atsuFontID; - // the qd styles that are not intrinsic to the font above - wxInt16 m_atsuAdditionalQDStyles; -#if wxOSX_USE_CARBON - wxInt16 m_qdFontFamily; - wxInt16 m_qdFontStyle; -#endif -#endif - - int m_pointSize; - wxFontFamily m_family; - wxFontStyle m_style; - wxFontWeight m_weight; - bool m_underlined; - bool m_strikethrough; - wxString m_faceName; - wxFontEncoding m_encoding; -public : #else // other platforms // // This is a generic implementation that should work on all ports @@ -193,7 +123,6 @@ public : wxFontStyle style; wxFontWeight weight; bool underlined; - bool strikethrough; wxString faceName; wxFontEncoding encoding; #endif // platforms @@ -212,11 +141,8 @@ public: wxNativeFontInfo& operator=(const wxNativeFontInfo& info) { - if (this != &info) - { - Free(); - Init(info); - } + Free(); + Init(info); return *this; } #endif // wxUSE_PANGO @@ -231,7 +157,6 @@ public: SetStyle((wxFontStyle)font.GetStyle()); SetWeight((wxFontWeight)font.GetWeight()); SetUnderlined(font.GetUnderlined()); - SetStrikethrough(font.GetStrikethrough()); #if defined(__WXMSW__) if ( font.IsUsingSizeInPixels() ) SetPixelSize(font.GetPixelSize()); @@ -260,7 +185,6 @@ public: wxFontStyle GetStyle() const; wxFontWeight GetWeight() const; bool GetUnderlined() const; - bool GetStrikethrough() const; wxString GetFaceName() const; wxFontFamily GetFamily() const; wxFontEncoding GetEncoding() const; @@ -270,7 +194,6 @@ public: void SetStyle(wxFontStyle style); void SetWeight(wxFontWeight weight); void SetUnderlined(bool underlined); - void SetStrikethrough(bool strikethrough); bool SetFaceName(const wxString& facename); void SetFamily(wxFontFamily family); void SetEncoding(wxFontEncoding encoding); @@ -301,12 +224,12 @@ public: // translate a wxFontEncoding into native encoding parameter (defined above), // returning true if an (exact) macth could be found, false otherwise (without // attempting any substitutions) -WXDLLIMPEXP_CORE bool wxGetNativeFontEncoding(wxFontEncoding encoding, - wxNativeEncodingInfo *info); +extern bool wxGetNativeFontEncoding(wxFontEncoding encoding, + wxNativeEncodingInfo *info); // test for the existence of the font described by this facename/encoding, // return true if such font(s) exist, false otherwise -WXDLLIMPEXP_CORE bool wxTestFontEncoding(const wxNativeEncodingInfo& info); +extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info); // ---------------------------------------------------------------------------- // font-related functions (X and GTK) diff --git a/Source/3rd Party/wx/include/wx/frame.h b/Source/3rd Party/wx/include/wx/frame.h index 67aab11eb..a1a8036fc 100644 --- a/Source/3rd Party/wx/include/wx/frame.h +++ b/Source/3rd Party/wx/include/wx/frame.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 15.11.99 +// RCS-ID: $Id: frame.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,15 +17,13 @@ // ---------------------------------------------------------------------------- #include "wx/toplevel.h" // the base class -#include "wx/statusbr.h" // the default names for various classs -extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[]; class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxMenuBar; -class WXDLLIMPEXP_FWD_CORE wxMenuItem; class WXDLLIMPEXP_FWD_CORE wxStatusBar; class WXDLLIMPEXP_FWD_CORE wxToolBar; @@ -33,11 +32,10 @@ class WXDLLIMPEXP_FWD_CORE wxToolBar; // ---------------------------------------------------------------------------- // wxFrame-specific (i.e. not for wxDialog) styles -// -// Also see the bit summary table in wx/toplevel.h. #define wxFRAME_NO_TASKBAR 0x0002 // No taskbar button (MSW only) #define wxFRAME_TOOL_WINDOW 0x0004 // No taskbar button, no system menu #define wxFRAME_FLOAT_ON_PARENT 0x0008 // Always above its parent +#define wxFRAME_SHAPED 0x0010 // Create a window that is able to be shaped // ---------------------------------------------------------------------------- // wxFrame is a top-level window with optional menubar, statusbar and toolbar @@ -51,7 +49,7 @@ class WXDLLIMPEXP_FWD_CORE wxToolBar; // CreateXXXBar() is called. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFrameBase : public wxTopLevelWindow +class WXDLLEXPORT wxFrameBase : public wxTopLevelWindow { public: // construction @@ -73,6 +71,9 @@ public: // if the frame has a toolbar) in client coordinates virtual wxPoint GetClientAreaOrigin() const; + // sends a size event to the window using its current size -- this has an + // effect of refreshing the window layout + virtual void SendSizeEvent(); // menu bar functions // ------------------ @@ -80,33 +81,20 @@ public: #if wxUSE_MENUS virtual void SetMenuBar(wxMenuBar *menubar); virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; } - - // find the item by id in the frame menu bar: this is an internal function - // and exists mainly in order to be overridden in the MDI parent frame - // which also looks at its active child menu bar - virtual wxMenuItem *FindItemInMenuBar(int menuId) const; - - // generate menu command corresponding to the given menu item - // - // returns true if processed - bool ProcessCommand(wxMenuItem *item); - - // generate menu command corresponding to the given menu command id - // - // returns true if processed - bool ProcessCommand(int winid); -#else - bool ProcessCommand(int WXUNUSED(winid)) { return false; } #endif // wxUSE_MENUS + // process menu command: returns true if processed + bool ProcessCommand(int winid); + // status bar functions // -------------------- #if wxUSE_STATUSBAR // create the main status bar by calling OnCreateStatusBar() virtual wxStatusBar* CreateStatusBar(int number = 1, - long style = wxSTB_DEFAULT_STYLE, + long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE, wxWindowID winid = 0, - const wxString& name = wxStatusLineNameStr); + const wxString& name = + wxStatusLineNameStr); // return a new status bar virtual wxStatusBar *OnCreateStatusBar(int number, long style, @@ -169,18 +157,23 @@ public: // Implement internal behaviour (menu updating on some platforms) virtual void OnInternalIdle(); + // if there is no real wxTopLevelWindow on this platform we have to define + // some wxTopLevelWindowBase pure virtual functions here to avoid breaking + // old ports (wxMotif) which don't define them in wxFrame +#ifndef wxTopLevelWindowNative + virtual bool ShowFullScreen(bool WXUNUSED(show), + long WXUNUSED(style) = wxFULLSCREEN_ALL) + { return false; } + virtual bool IsFullScreen() const + { return false; } +#endif // no wxTopLevelWindowNative + #if wxUSE_MENUS || wxUSE_TOOLBAR - // show help text for the currently selected menu or toolbar item - // (typically in the status bar) or hide it and restore the status bar text - // originally shown before the menu was opened if show == false + // show help text (typically in the statusbar); show is false + // if you are hiding the help, true otherwise virtual void DoGiveHelp(const wxString& text, bool show); #endif - virtual bool IsClientAreaChild(const wxWindow *child) const - { - return !IsOneOfBars(child) && wxTopLevelWindow::IsClientAreaChild(child); - } - protected: // the frame main menu/status/tool bars // ------------------------------------ @@ -204,19 +197,12 @@ protected: // frame virtual void AttachMenuBar(wxMenuBar *menubar); - // Return true if we should update the menu item state from idle event - // handler or false if we should delay it until the menu is opened. - static bool ShouldUpdateMenuFromIdle(); - wxMenuBar *m_frameMenuBar; #endif // wxUSE_MENUS #if wxUSE_STATUSBAR && (wxUSE_MENUS || wxUSE_TOOLBAR) // the saved status bar text overwritten by DoGiveHelp() wxString m_oldStatusText; - - // the last help string we have shown in the status bar - wxString m_lastHelpShown; #endif #if wxUSE_STATUSBAR @@ -224,10 +210,9 @@ protected: // something changes virtual void PositionStatusBar() { } - // show the help string for the given menu item using DoGiveHelp() if the - // given item does have a help string (as determined by FindInMenuBar()), - // return false if there is no help for such item - bool ShowMenuHelp(int helpid); + // show the help string for this menu item in the given status bar: the + // status bar pointer can be NULL; return true if help was shown + bool ShowMenuHelp(wxStatusBar *statbar, int helpid); wxStatusBar *m_frameStatusBar; #endif // wxUSE_STATUSBAR @@ -247,14 +232,16 @@ protected: DECLARE_EVENT_TABLE() #endif // wxUSE_MENUS && wxUSE_STATUSBAR - wxDECLARE_NO_COPY_CLASS(wxFrameBase); + DECLARE_NO_COPY_CLASS(wxFrameBase) }; // include the real class declaration #if defined(__WXUNIVERSAL__) // && !defined(__WXMICROWIN__) #include "wx/univ/frame.h" #else // !__WXUNIVERSAL__ - #if defined(__WXMSW__) + #if defined(__WXPALMOS__) + #include "wx/palmos/frame.h" + #elif defined(__WXMSW__) #include "wx/msw/frame.h" #elif defined(__WXGTK20__) #include "wx/gtk/frame.h" @@ -263,7 +250,7 @@ protected: #elif defined(__WXMOTIF__) #include "wx/motif/frame.h" #elif defined(__WXMAC__) - #include "wx/osx/frame.h" + #include "wx/mac/frame.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/frame.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/fs_arc.h b/Source/3rd Party/wx/include/wx/fs_arc.h index 04e8c5bd4..02afd0746 100644 --- a/Source/3rd Party/wx/include/wx/fs_arc.h +++ b/Source/3rd Party/wx/include/wx/fs_arc.h @@ -3,6 +3,7 @@ // Purpose: Archive file system // Author: Vaclav Slavik, Mike Wetherell // Copyright: (c) 1999 Vaclav Slavik, (c) 2006 Mike Wetherell +// CVS-ID: $Id: fs_arc.h 42713 2006-10-30 11:56:12Z ABX $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -46,7 +47,7 @@ private: wxString DoFind(); - wxDECLARE_NO_COPY_CLASS(wxArchiveFSHandler); + DECLARE_NO_COPY_CLASS(wxArchiveFSHandler) DECLARE_DYNAMIC_CLASS(wxArchiveFSHandler) }; diff --git a/Source/3rd Party/wx/include/wx/fs_filter.h b/Source/3rd Party/wx/include/wx/fs_filter.h index ae309145e..1eb014510 100644 --- a/Source/3rd Party/wx/include/wx/fs_filter.h +++ b/Source/3rd Party/wx/include/wx/fs_filter.h @@ -3,6 +3,7 @@ // Purpose: Filter file system handler // Author: Mike Wetherell // Copyright: (c) 2006 Mike Wetherell +// CVS-ID: $Id: fs_filter.h 42713 2006-10-30 11:56:12Z ABX $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,7 +33,7 @@ public: virtual wxString FindNext(); private: - wxDECLARE_NO_COPY_CLASS(wxFilterFSHandler); + DECLARE_NO_COPY_CLASS(wxFilterFSHandler) }; #endif // wxUSE_FILESYSTEM diff --git a/Source/3rd Party/wx/include/wx/fs_inet.h b/Source/3rd Party/wx/include/wx/fs_inet.h deleted file mode 100644 index bde0c6954..000000000 --- a/Source/3rd Party/wx/include/wx/fs_inet.h +++ /dev/null @@ -1,33 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/fs_inet.h -// Purpose: HTTP and FTP file system -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FS_INET_H_ -#define _WX_FS_INET_H_ - -#include "wx/defs.h" - -#if wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS - -#include "wx/filesys.h" - -// ---------------------------------------------------------------------------- -// wxInternetFSHandler -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_NET wxInternetFSHandler : public wxFileSystemHandler -{ - public: - virtual bool CanOpen(const wxString& location); - virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location); -}; - -#endif - // wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS - -#endif // _WX_FS_INET_H_ - diff --git a/Source/3rd Party/wx/include/wx/fs_mem.h b/Source/3rd Party/wx/include/wx/fs_mem.h index facb6c5e0..e4d6737d7 100644 --- a/Source/3rd Party/wx/include/wx/fs_mem.h +++ b/Source/3rd Party/wx/include/wx/fs_mem.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/fs_mem.h +// Name: fs_mem.h // Purpose: in-memory file system // Author: Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik @@ -15,13 +15,9 @@ #include "wx/filesys.h" -#include "wx/hashmap.h" - -class wxMemoryFSFile; -WX_DECLARE_STRING_HASH_MAP(wxMemoryFSFile *, wxMemoryFSHash); - #if wxUSE_GUI - #include "wx/bitmap.h" + class WXDLLIMPEXP_FWD_CORE wxBitmap; + class WXDLLIMPEXP_FWD_CORE wxImage; #endif // wxUSE_GUI // ---------------------------------------------------------------------------- @@ -39,12 +35,14 @@ public: // name "memory:" + filename static void AddFile(const wxString& filename, const wxString& textdata); static void AddFile(const wxString& filename, const void *binarydata, size_t size); +#if wxABI_VERSION >= 20805 static void AddFileWithMimeType(const wxString& filename, const wxString& textdata, const wxString& mimetype); static void AddFileWithMimeType(const wxString& filename, const void *binarydata, size_t size, const wxString& mimetype); +#endif // wxABI_VERSION >= 20805 // Remove file from memory FS and free occupied memory static void RemoveFile(const wxString& filename); @@ -55,21 +53,8 @@ public: virtual wxString FindNext(); protected: - // check that the given file is not already present in m_Hash; logs an - // error and returns false if it does exist - static bool CheckDoesntExist(const wxString& filename); - - // the hash map indexed by the names of the files stored in the memory FS - static wxMemoryFSHash m_Hash; - - // the file name currently being searched for, i.e. the argument of the - // last FindFirst() call or empty string if FindFirst() hasn't been called - // yet or FindNext() didn't find anything - wxString m_findArgument; - - // iterator into m_Hash used by FindFirst/Next(), possibly m_Hash.end() or - // even invalid (can only be used when m_findArgument is not empty) - wxMemoryFSHash::const_iterator m_findIter; + static bool CheckHash(const wxString& filename); + static wxHashTable *m_Hash; }; // ---------------------------------------------------------------------------- @@ -96,6 +81,7 @@ public: { wxMemoryFSHandlerBase::AddFile(filename, binarydata, size); } +#if wxABI_VERSION >= 20805 static void AddFileWithMimeType(const wxString& filename, const wxString& textdata, const wxString& mimetype) @@ -112,15 +98,16 @@ public: binarydata, size, mimetype); } +#endif // wxABI_VERSION >= 20805 #if wxUSE_IMAGE static void AddFile(const wxString& filename, const wxImage& image, - wxBitmapType type); + long type); static void AddFile(const wxString& filename, const wxBitmap& bitmap, - wxBitmapType type); + long type); #endif // wxUSE_IMAGE }; diff --git a/Source/3rd Party/wx/include/wx/fs_zip.h b/Source/3rd Party/wx/include/wx/fs_zip.h deleted file mode 100644 index 197a46a5e..000000000 --- a/Source/3rd Party/wx/include/wx/fs_zip.h +++ /dev/null @@ -1,22 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/fs_zip.h -// Purpose: wxZipFSHandler typedef for compatibility -// Author: Mike Wetherell -// Copyright: (c) 2006 Mike Wetherell -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FS_ZIP_H_ -#define _WX_FS_ZIP_H_ - -#include "wx/defs.h" - -#if wxUSE_FS_ZIP - -#include "wx/fs_arc.h" - -typedef wxArchiveFSHandler wxZipFSHandler; - -#endif // wxUSE_FS_ZIP - -#endif // _WX_FS_ZIP_H_ diff --git a/Source/3rd Party/wx/include/wx/fswatcher.h b/Source/3rd Party/wx/include/wx/fswatcher.h deleted file mode 100644 index 056780d34..000000000 --- a/Source/3rd Party/wx/include/wx/fswatcher.h +++ /dev/null @@ -1,411 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/fswatcher.h -// Purpose: wxFileSystemWatcherBase -// Author: Bartosz Bekier -// Created: 2009-05-23 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FSWATCHER_BASE_H_ -#define _WX_FSWATCHER_BASE_H_ - -#include "wx/defs.h" - -#if wxUSE_FSWATCHER - -#include "wx/log.h" -#include "wx/event.h" -#include "wx/evtloop.h" -#include "wx/filename.h" -#include "wx/dir.h" -#include "wx/hashmap.h" - -#define wxTRACE_FSWATCHER "fswatcher" - -// ---------------------------------------------------------------------------- -// wxFileSystemWatcherEventType & wxFileSystemWatcherEvent -// ---------------------------------------------------------------------------- - -/** - * Possible types of file system events. - * This is a subset that will work fine an all platforms (actually, we will - * see how it works on Mac). - * - * We got 2 types of error events: - * - warning: these are not fatal and further events can still be generated - * - error: indicates fatal error and causes that no more events will happen - */ -enum -{ - wxFSW_EVENT_CREATE = 0x01, - wxFSW_EVENT_DELETE = 0x02, - wxFSW_EVENT_RENAME = 0x04, - wxFSW_EVENT_MODIFY = 0x08, - wxFSW_EVENT_ACCESS = 0x10, - wxFSW_EVENT_ATTRIB = 0x20, // Currently this is wxGTK-only - - // error events - wxFSW_EVENT_WARNING = 0x40, - wxFSW_EVENT_ERROR = 0x80, - wxFSW_EVENT_ALL = wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE | - wxFSW_EVENT_RENAME | wxFSW_EVENT_MODIFY | - wxFSW_EVENT_ACCESS | wxFSW_EVENT_ATTRIB | - wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR -#ifdef wxHAS_INOTIFY - ,wxFSW_EVENT_UNMOUNT = 0x2000 -#endif -}; - -// Type of the path watched, used only internally for now. -enum wxFSWPathType -{ - wxFSWPath_None, // Invalid value for an initialized watch. - wxFSWPath_File, // Plain file. - wxFSWPath_Dir, // Watch a directory and the files in it. - wxFSWPath_Tree // Watch a directory and all its children recursively. -}; - -// Type of the warning for the events notifying about them. -enum wxFSWWarningType -{ - wxFSW_WARNING_NONE, - wxFSW_WARNING_GENERAL, - wxFSW_WARNING_OVERFLOW -}; - -/** - * Event containing information about file system change. - */ -class WXDLLIMPEXP_FWD_BASE wxFileSystemWatcherEvent; -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_FSWATCHER, - wxFileSystemWatcherEvent); - -class WXDLLIMPEXP_BASE wxFileSystemWatcherEvent: public wxEvent -{ -public: - // Constructor for any kind of events, also used as default ctor. - wxFileSystemWatcherEvent(int changeType = 0, int watchid = wxID_ANY) : - wxEvent(watchid, wxEVT_FSWATCHER), - m_changeType(changeType), - m_warningType(wxFSW_WARNING_NONE) - { - } - - // Constructor for the error or warning events. - wxFileSystemWatcherEvent(int changeType, - wxFSWWarningType warningType, - const wxString& errorMsg = wxString(), - int watchid = wxID_ANY) : - wxEvent(watchid, wxEVT_FSWATCHER), - m_changeType(changeType), - m_warningType(warningType), - m_errorMsg(errorMsg) - { - } - - // Constructor for the normal events carrying information about the changes. - wxFileSystemWatcherEvent(int changeType, - const wxFileName& path, const wxFileName& newPath, - int watchid = wxID_ANY) : - wxEvent(watchid, wxEVT_FSWATCHER), - m_changeType(changeType), - m_warningType(wxFSW_WARNING_NONE), - m_path(path), - m_newPath(newPath) - - { - } - - /** - * Returns the path at which the event occurred. - */ - const wxFileName& GetPath() const - { - return m_path; - } - - /** - * Sets the path at which the event occurred - */ - void SetPath(const wxFileName& path) - { - m_path = path; - } - - /** - * In case of rename(move?) events, returns the new path related to the - * event. The "new" means newer in the sense of time. In case of other - * events it returns the same path as GetPath(). - */ - const wxFileName& GetNewPath() const - { - return m_newPath; - } - - /** - * Sets the new path related to the event. See above. - */ - void SetNewPath(const wxFileName& path) - { - m_newPath = path; - } - - /** - * Returns the type of file system event that occurred. - */ - int GetChangeType() const - { - return m_changeType; - } - - virtual wxEvent* Clone() const - { - wxFileSystemWatcherEvent* evt = new wxFileSystemWatcherEvent(*this); - evt->m_errorMsg = m_errorMsg.Clone(); - evt->m_path = wxFileName(m_path.GetFullPath().Clone()); - evt->m_newPath = wxFileName(m_newPath.GetFullPath().Clone()); - evt->m_warningType = m_warningType; - return evt; - } - - virtual wxEventCategory GetEventCategory() const - { - // TODO this has to be merged with "similar" categories and changed - return wxEVT_CATEGORY_UNKNOWN; - } - - /** - * Returns if this error is an error event - */ - bool IsError() const - { - return (m_changeType & (wxFSW_EVENT_ERROR | wxFSW_EVENT_WARNING)) != 0; - } - - wxString GetErrorDescription() const - { - return m_errorMsg; - } - - wxFSWWarningType GetWarningType() const - { - return m_warningType; - } - - /** - * Returns a wxString describing an event useful for debugging or testing - */ - wxString ToString() const; - -protected: - int m_changeType; - wxFSWWarningType m_warningType; - wxFileName m_path; - wxFileName m_newPath; - wxString m_errorMsg; -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileSystemWatcherEvent) -}; - -typedef void (wxEvtHandler::*wxFileSystemWatcherEventFunction) - (wxFileSystemWatcherEvent&); - -#define wxFileSystemWatcherEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxFileSystemWatcherEventFunction, func) - -#define EVT_FSWATCHER(winid, func) \ - wx__DECLARE_EVT1(wxEVT_FSWATCHER, winid, wxFileSystemWatcherEventHandler(func)) - -// ---------------------------------------------------------------------------- -// wxFileSystemWatcherBase: interface for wxFileSystemWatcher -// ---------------------------------------------------------------------------- - -// Simple container to store information about one watched path. -class wxFSWatchInfo -{ -public: - wxFSWatchInfo() : - m_events(-1), m_type(wxFSWPath_None), m_refcount(-1) - { - } - - wxFSWatchInfo(const wxString& path, - int events, - wxFSWPathType type, - const wxString& filespec = wxString()) : - m_path(path), m_filespec(filespec), m_events(events), m_type(type), - m_refcount(1) - { - } - - const wxString& GetPath() const - { - return m_path; - } - - const wxString& GetFilespec() const { return m_filespec; } - - int GetFlags() const - { - return m_events; - } - - wxFSWPathType GetType() const - { - return m_type; - } - - // Reference counting of watch entries is used to avoid watching the same - // file system path multiple times (this can happen even accidentally, e.g. - // when you have a recursive watch and then decide to watch some file or - // directory under it separately). - int IncRef() - { - return ++m_refcount; - } - - int DecRef() - { - wxASSERT_MSG( m_refcount > 0, wxS("Trying to decrement a zero count") ); - return --m_refcount; - } - -protected: - wxString m_path; - wxString m_filespec; // For tree watches, holds any filespec to apply - int m_events; - wxFSWPathType m_type; - int m_refcount; -}; - -WX_DECLARE_STRING_HASH_MAP(wxFSWatchInfo, wxFSWatchInfoMap); - -/** - * Encapsulation of platform-specific file system event mechanism - */ -class wxFSWatcherImpl; - -/** - * Main entry point for clients interested in file system events. - * Defines interface that can be used to receive that kind of events. - */ -class WXDLLIMPEXP_BASE wxFileSystemWatcherBase: public wxEvtHandler -{ -public: - wxFileSystemWatcherBase(); - - virtual ~wxFileSystemWatcherBase(); - - /** - * Adds path to currently watched files. Any events concerning this - * particular path will be sent to handler. Optionally a filter can be - * specified to receive only events of particular type. - * - * Please note that when adding a dir, immediate children will be watched - * as well. - */ - virtual bool Add(const wxFileName& path, int events = wxFSW_EVENT_ALL); - - /** - * Like above, but recursively adds every file/dir in the tree rooted in - * path. Additionally a file mask can be specified to include only files - * of particular type. - */ - virtual bool AddTree(const wxFileName& path, int events = wxFSW_EVENT_ALL, - const wxString& filespec = wxEmptyString); - - /** - * Removes path from the list of watched paths. - */ - virtual bool Remove(const wxFileName& path); - - /** - * Same as above, but also removes every file belonging to the tree rooted - * at path. - */ - virtual bool RemoveTree(const wxFileName& path); - - /** - * Clears the list of currently watched paths. - */ - virtual bool RemoveAll(); - - /** - * Returns the number of watched paths - */ - int GetWatchedPathsCount() const; - - /** - * Retrevies all watched paths and places them in wxArrayString. Returns - * the number of paths. - * - * TODO think about API here: we need to return more information (like is - * the path watched recursively) - */ - int GetWatchedPaths(wxArrayString* paths) const; - - wxEvtHandler* GetOwner() const - { - return m_owner; - } - - void SetOwner(wxEvtHandler* handler) - { - if (!handler) - m_owner = this; - else - m_owner = handler; - } - - - // This is a semi-private function used by wxWidgets itself only. - // - // Delegates the real work of adding the path to wxFSWatcherImpl::Add() and - // updates m_watches if the new path was successfully added. - bool AddAny(const wxFileName& path, int events, wxFSWPathType type, - const wxString& filespec = wxString()); - -protected: - - static wxString GetCanonicalPath(const wxFileName& path) - { - wxFileName path_copy = wxFileName(path); - if ( !path_copy.Normalize() ) - { - wxFAIL_MSG(wxString::Format("Unable to normalize path '%s'", - path.GetFullPath())); - return wxEmptyString; - } - - return path_copy.GetFullPath(); - } - - - wxFSWatchInfoMap m_watches; // path=>wxFSWatchInfo map - wxFSWatcherImpl* m_service; // file system events service - wxEvtHandler* m_owner; // handler for file system events - - friend class wxFSWatcherImpl; -}; - -// include the platform specific file defining wxFileSystemWatcher -// inheriting from wxFileSystemWatcherBase - -#ifdef wxHAS_INOTIFY - #include "wx/unix/fswatcher_inotify.h" - #define wxFileSystemWatcher wxInotifyFileSystemWatcher -#elif defined(wxHAS_KQUEUE) - #include "wx/unix/fswatcher_kqueue.h" - #define wxFileSystemWatcher wxKqueueFileSystemWatcher -#elif defined(__WINDOWS__) - #include "wx/msw/fswatcher.h" - #define wxFileSystemWatcher wxMSWFileSystemWatcher -#else - #include "wx/generic/fswatcher.h" - #define wxFileSystemWatcher wxPollingFileSystemWatcher -#endif - -#endif // wxUSE_FSWATCHER - -#endif /* _WX_FSWATCHER_BASE_H_ */ diff --git a/Source/3rd Party/wx/include/wx/gauge.h b/Source/3rd Party/wx/include/wx/gauge.h index 9e0955c55..a6246ca42 100644 --- a/Source/3rd Party/wx/include/wx/gauge.h +++ b/Source/3rd Party/wx/include/wx/gauge.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.02.01 +// RCS-ID: $Id: gauge.h 41089 2006-09-09 13:36:54Z RR $ // Copyright: (c) 1996-2001 wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -40,13 +41,13 @@ #define wxGAUGE_EMULATE_INDETERMINATE_MODE 0 #endif -extern WXDLLIMPEXP_DATA_CORE(const char) wxGaugeNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxGaugeNameStr[]; // ---------------------------------------------------------------------------- // wxGauge: a progress bar // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGaugeBase : public wxControl +class WXDLLEXPORT wxGaugeBase : public wxControl { public: wxGaugeBase() { m_rangeMax = m_gaugePos = 0; } @@ -83,12 +84,10 @@ public: virtual void SetBezelFace(int w); virtual int GetBezelFace() const; - // overridden base class virtuals + // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - // the max position int m_rangeMax; @@ -99,13 +98,14 @@ protected: int m_nDirection; // can be wxRIGHT or wxLEFT #endif - wxDECLARE_NO_COPY_CLASS(wxGaugeBase); + DECLARE_NO_COPY_CLASS(wxGaugeBase) }; #if defined(__WXUNIVERSAL__) #include "wx/univ/gauge.h" #elif defined(__WXMSW__) - #include "wx/msw/gauge.h" + #include "wx/msw/gauge95.h" + #define wxGauge wxGauge95 #elif defined(__WXMOTIF__) #include "wx/motif/gauge.h" #elif defined(__WXGTK20__) @@ -113,7 +113,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/gauge.h" #elif defined(__WXMAC__) - #include "wx/osx/gauge.h" + #include "wx/mac/gauge.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/gauge.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/gbsizer.h b/Source/3rd Party/wx/include/wx/gbsizer.h index e5cd22266..dd2f31bec 100644 --- a/Source/3rd Party/wx/include/wx/gbsizer.h +++ b/Source/3rd Party/wx/include/wx/gbsizer.h @@ -1,11 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/gbsizer.h +// Name: gbsizer.h // Purpose: wxGridBagSizer: A sizer that can lay out items in a grid, // with items at specified cells, and with the option of row // and/or column spanning // // Author: Robin Dunn // Created: 03-Nov-2003 +// RCS-ID: $Id: gbsizer.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Robin Dunn // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,7 +28,7 @@ // is used for this and also for wxGridCellCoords. //--------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGBPosition +class WXDLLEXPORT wxGBPosition { public: wxGBPosition() : m_row(0), m_col(0) {} @@ -49,70 +50,29 @@ private: }; -class WXDLLIMPEXP_CORE wxGBSpan +class WXDLLEXPORT wxGBSpan { public: - wxGBSpan() { Init(); } - wxGBSpan(int rowspan, int colspan) - { - // Initialize the members to valid values as not doing it may result in - // infinite loop in wxGBSizer code if the user passed 0 for any of - // them, see #12934. - Init(); - - SetRowspan(rowspan); - SetColspan(colspan); - } + wxGBSpan() : m_rowspan(1), m_colspan(1) {} + wxGBSpan(int rowspan, int colspan) : m_rowspan(rowspan), m_colspan(colspan) {} // default copy ctor and assignment operator are okay. - // Factor constructor creating an invalid wxGBSpan: this is mostly supposed - // to be used as return value for functions returning wxGBSpan in case of - // errors. - static wxGBSpan Invalid() - { - return wxGBSpan(NULL); - } - int GetRowspan() const { return m_rowspan; } int GetColspan() const { return m_colspan; } - void SetRowspan(int rowspan) - { - wxCHECK_RET( rowspan > 0, "Row span should be strictly positive" ); - - m_rowspan = rowspan; - } - - void SetColspan(int colspan) - { - wxCHECK_RET( colspan > 0, "Column span should be strictly positive" ); - - m_colspan = colspan; - } + void SetRowspan(int rowspan) { m_rowspan = rowspan; } + void SetColspan(int colspan) { m_colspan = colspan; } bool operator==(const wxGBSpan& o) const { return m_rowspan == o.m_rowspan && m_colspan == o.m_colspan; } bool operator!=(const wxGBSpan& o) const { return !(*this == o); } private: - // This private ctor is used by Invalid() only. - wxGBSpan(struct InvalidCtorTag*) - { - m_rowspan = - m_colspan = -1; - } - - void Init() - { - m_rowspan = - m_colspan = 1; - } - int m_rowspan; int m_colspan; }; -extern WXDLLIMPEXP_DATA_CORE(const wxGBSpan) wxDefaultSpan; +extern WXDLLEXPORT_DATA(const wxGBSpan) wxDefaultSpan; //--------------------------------------------------------------------------- @@ -122,33 +82,33 @@ extern WXDLLIMPEXP_DATA_CORE(const wxGBSpan) wxDefaultSpan; class WXDLLIMPEXP_FWD_CORE wxGridBagSizer; -class WXDLLIMPEXP_CORE wxGBSizerItem : public wxSizerItem +class WXDLLEXPORT wxGBSizerItem : public wxSizerItem { public: // spacer wxGBSizerItem( int width, int height, const wxGBPosition& pos, - const wxGBSpan& span=wxDefaultSpan, - int flag=0, - int border=0, - wxObject* userData=NULL); + const wxGBSpan& span, + int flag, + int border, + wxObject* userData); // window wxGBSizerItem( wxWindow *window, const wxGBPosition& pos, - const wxGBSpan& span=wxDefaultSpan, - int flag=0, - int border=0, - wxObject* userData=NULL ); + const wxGBSpan& span, + int flag, + int border, + wxObject* userData ); // subsizer wxGBSizerItem( wxSizer *sizer, const wxGBPosition& pos, - const wxGBSpan& span=wxDefaultSpan, - int flag=0, - int border=0, - wxObject* userData=NULL ); + const wxGBSpan& span, + int flag, + int border, + wxObject* userData ); // default ctor wxGBSizerItem(); @@ -174,7 +134,7 @@ public: // is successful and after the next Layout the item will be resized. bool SetSpan( const wxGBSpan& span ); - // Returns true if this item and the other item intersect + // Returns true if this item and the other item instersect bool Intersects(const wxGBSizerItem& other); // Returns true if the given pos/span would intersect with this item. @@ -196,7 +156,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxGBSizerItem) - wxDECLARE_NO_COPY_CLASS(wxGBSizerItem); + DECLARE_NO_COPY_CLASS(wxGBSizerItem) }; @@ -205,7 +165,7 @@ private: //--------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGridBagSizer : public wxFlexGridSizer +class WXDLLEXPORT wxGridBagSizer : public wxFlexGridSizer { public: wxGridBagSizer(int vgap = 0, int hgap = 0 ); @@ -326,7 +286,9 @@ public: protected: wxGBPosition FindEmptyCell(); +#if wxABI_VERSION >= 20808 void AdjustForOverflow(); +#endif wxSize m_emptyCellSize; @@ -334,7 +296,7 @@ protected: private: DECLARE_CLASS(wxGridBagSizer) - wxDECLARE_NO_COPY_CLASS(wxGridBagSizer); + DECLARE_NO_COPY_CLASS(wxGridBagSizer) }; //--------------------------------------------------------------------------- diff --git a/Source/3rd Party/wx/include/wx/gdicmn.h b/Source/3rd Party/wx/include/wx/gdicmn.h index 38d28259e..2b9e71b05 100644 --- a/Source/3rd Party/wx/include/wx/gdicmn.h +++ b/Source/3rd Party/wx/include/wx/gdicmn.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: gdicmn.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,8 +37,6 @@ class WXDLLIMPEXP_FWD_CORE wxPalette; class WXDLLIMPEXP_FWD_CORE wxPen; class WXDLLIMPEXP_FWD_CORE wxRegion; class WXDLLIMPEXP_FWD_BASE wxString; -class WXDLLIMPEXP_FWD_CORE wxIconBundle; -class WXDLLIMPEXP_FWD_CORE wxPoint; // --------------------------------------------------------------------------- // constants @@ -58,10 +57,8 @@ enum wxBitmapType wxBITMAP_TYPE_XBM_DATA, wxBITMAP_TYPE_XPM, wxBITMAP_TYPE_XPM_DATA, - wxBITMAP_TYPE_TIFF, - wxBITMAP_TYPE_TIF = wxBITMAP_TYPE_TIFF, - wxBITMAP_TYPE_TIFF_RESOURCE, - wxBITMAP_TYPE_TIF_RESOURCE = wxBITMAP_TYPE_TIFF_RESOURCE, + wxBITMAP_TYPE_TIF, + wxBITMAP_TYPE_TIF_RESOURCE, wxBITMAP_TYPE_GIF, wxBITMAP_TYPE_GIF_RESOURCE, wxBITMAP_TYPE_PNG, @@ -81,18 +78,9 @@ enum wxBitmapType wxBITMAP_TYPE_TGA, wxBITMAP_TYPE_MACCURSOR, wxBITMAP_TYPE_MACCURSOR_RESOURCE, - - wxBITMAP_TYPE_MAX, wxBITMAP_TYPE_ANY = 50 }; -// Polygon filling mode -enum wxPolygonFillMode -{ - wxODDEVEN_RULE = 1, - wxWINDING_RULE -}; - // Standard cursors enum wxStockCursor { @@ -136,58 +124,48 @@ enum wxStockCursor wxCURSOR_BASED_ARROW_UP, wxCURSOR_BASED_ARROW_DOWN, #endif // X11 + wxCURSOR_ARROWWAIT, -#ifdef __WXMAC__ - wxCURSOR_OPEN_HAND, - wxCURSOR_CLOSED_HAND, -#endif wxCURSOR_MAX }; #ifndef __WXGTK__ - #define wxCURSOR_DEFAULT wxCURSOR_ARROW -#endif - -#ifndef __WXMAC__ - // TODO CS supply openhand and closedhand cursors - #define wxCURSOR_OPEN_HAND wxCURSOR_HAND - #define wxCURSOR_CLOSED_HAND wxCURSOR_HAND + #define wxCURSOR_DEFAULT wxCURSOR_ARROW #endif // --------------------------------------------------------------------------- // macros // --------------------------------------------------------------------------- -#if defined(__WINDOWS__) || defined(__WXPM__) - #define wxHAS_IMAGES_IN_RESOURCES -#endif - /* Useful macro for creating icons portably, for example: - wxIcon *icon = new wxICON(sample); + wxIcon *icon = new wxICON(mondrian); expands into: - wxIcon *icon = new wxIcon("sample"); // On Windows - wxIcon *icon = new wxIcon(sample_xpm); // On wxGTK/Linux + wxIcon *icon = new wxIcon("mondrian"); // On wxMSW + wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK */ -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Load from a resource #define wxICON(X) wxIcon(wxT(#X)) #elif defined(__WXPM__) // Load from a resource #define wxICON(X) wxIcon(wxT(#X)) +#elif defined(__WXMGL__) + // Initialize from an included XPM + #define wxICON(X) wxIcon( (const char**) X##_xpm ) #elif defined(__WXDFB__) // Initialize from an included XPM - #define wxICON(X) wxIcon( X##_xpm ) + #define wxICON(X) wxIcon( (const char**) X##_xpm ) #elif defined(__WXGTK__) // Initialize from an included XPM - #define wxICON(X) wxIcon( X##_xpm ) + #define wxICON(X) wxIcon( (const char**) X##_xpm ) #elif defined(__WXMAC__) // Initialize from an included XPM - #define wxICON(X) wxIcon( X##_xpm ) + #define wxICON(X) wxIcon( (const char**) X##_xpm ) #elif defined(__WXMOTIF__) // Initialize from an included XPM #define wxICON(X) wxIcon( X##_xpm ) @@ -203,42 +181,21 @@ enum wxStockCursor under Unix bitmaps live in XPMs and under Windows they're in ressources. */ -#if defined(__WINDOWS__) || defined(__WXPM__) - #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_BMP_RESOURCE) +#if defined(__WXMSW__) || defined(__WXPM__) + #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE) #elif defined(__WXGTK__) || \ defined(__WXMOTIF__) || \ defined(__WXX11__) || \ defined(__WXMAC__) || \ + defined(__WXMGL__) || \ defined(__WXDFB__) || \ defined(__WXCOCOA__) // Initialize from an included XPM - #define wxBITMAP(name) wxBitmap(name##_xpm) + #define wxBITMAP(name) wxBitmap( (const char**) name##_xpm ) #else // other platforms #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM) #endif // platform -// Macro for creating wxBitmap from in-memory PNG data. -// -// It reads PNG data from name_png static byte arrays that can be created using -// e.g. misc/scripts/png2c.py. -// -// This macro exists mostly as a helper for wxBITMAP_PNG() below but also -// because it's slightly more convenient to use than NewFromPNGData() directly. -#define wxBITMAP_PNG_FROM_DATA(name) \ - wxBitmap::NewFromPNGData(name##_png, WXSIZEOF(name##_png)) - -// Similar to wxBITMAP but used for the bitmaps in PNG format. -// -// Under Windows they should be embedded into the resource file using RT_RCDATA -// resource type and under OS X the PNG file with the specified name must be -// available in the resource subdirectory of the bundle. Elsewhere, this is -// exactly the same thing as wxBITMAP_PNG_FROM_DATA() described above. -#if defined(__WINDOWS__) || defined(__WXOSX__) - #define wxBITMAP_PNG(name) wxBitmap(wxS(#name), wxBITMAP_TYPE_PNG_RESOURCE) -#else - #define wxBITMAP_PNG(name) wxBITMAP_PNG_FROM_DATA(name) -#endif - // =========================================================================== // classes // =========================================================================== @@ -247,7 +204,7 @@ enum wxStockCursor // wxSize // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSize +class WXDLLEXPORT wxSize { public: // members are public for compatibility, don't use them directly. @@ -259,38 +216,29 @@ public: // no copy ctor or assignment operator - the defaults are ok + bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; } + bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; } + + wxSize operator+(const wxSize& sz) const { return wxSize(x + sz.x, y + sz.y); } + wxSize operator-(const wxSize& sz) const { return wxSize(x - sz.x, y - sz.y); } + wxSize operator/(int i) const { return wxSize(x / i, y / i); } + wxSize operator*(int i) const { return wxSize(x * i, y * i); } + wxSize& operator+=(const wxSize& sz) { x += sz.x; y += sz.y; return *this; } wxSize& operator-=(const wxSize& sz) { x -= sz.x; y -= sz.y; return *this; } - wxSize& operator/=(int i) { x /= i; y /= i; return *this; } - wxSize& operator*=(int i) { x *= i; y *= i; return *this; } - wxSize& operator/=(unsigned int i) { x /= i; y /= i; return *this; } - wxSize& operator*=(unsigned int i) { x *= i; y *= i; return *this; } - wxSize& operator/=(long i) { x /= i; y /= i; return *this; } - wxSize& operator*=(long i) { x *= i; y *= i; return *this; } - wxSize& operator/=(unsigned long i) { x /= i; y /= i; return *this; } - wxSize& operator*=(unsigned long i) { x *= i; y *= i; return *this; } - wxSize& operator/=(double i) { x = int(x/i); y = int(y/i); return *this; } - wxSize& operator*=(double i) { x = int(x*i); y = int(y*i); return *this; } + wxSize& operator/=(const int i) { x /= i; y /= i; return *this; } + wxSize& operator*=(const int i) { x *= i; y *= i; return *this; } void IncTo(const wxSize& sz) { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; } void DecTo(const wxSize& sz) { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; } - void DecToIfSpecified(const wxSize& sz) - { - if ( sz.x != wxDefaultCoord && sz.x < x ) - x = sz.x; - if ( sz.y != wxDefaultCoord && sz.y < y ) - y = sz.y; - } void IncBy(int dx, int dy) { x += dx; y += dy; } - void IncBy(const wxPoint& pt); void IncBy(const wxSize& sz) { IncBy(sz.x, sz.y); } void IncBy(int d) { IncBy(d, d); } void DecBy(int dx, int dy) { IncBy(-dx, -dy); } - void DecBy(const wxPoint& pt); void DecBy(const wxSize& sz) { DecBy(sz.x, sz.y); } void DecBy(int d) { DecBy(d, d); } @@ -323,103 +271,11 @@ public: int GetY() const { return y; } }; -inline bool operator==(const wxSize& s1, const wxSize& s2) -{ - return s1.x == s2.x && s1.y == s2.y; -} - -inline bool operator!=(const wxSize& s1, const wxSize& s2) -{ - return s1.x != s2.x || s1.y != s2.y; -} - -inline wxSize operator+(const wxSize& s1, const wxSize& s2) -{ - return wxSize(s1.x + s2.x, s1.y + s2.y); -} - -inline wxSize operator-(const wxSize& s1, const wxSize& s2) -{ - return wxSize(s1.x - s2.x, s1.y - s2.y); -} - -inline wxSize operator/(const wxSize& s, int i) -{ - return wxSize(s.x / i, s.y / i); -} - -inline wxSize operator*(const wxSize& s, int i) -{ - return wxSize(s.x * i, s.y * i); -} - -inline wxSize operator*(int i, const wxSize& s) -{ - return wxSize(s.x * i, s.y * i); -} - -inline wxSize operator/(const wxSize& s, unsigned int i) -{ - return wxSize(s.x / i, s.y / i); -} - -inline wxSize operator*(const wxSize& s, unsigned int i) -{ - return wxSize(s.x * i, s.y * i); -} - -inline wxSize operator*(unsigned int i, const wxSize& s) -{ - return wxSize(s.x * i, s.y * i); -} - -inline wxSize operator/(const wxSize& s, long i) -{ - return wxSize(s.x / i, s.y / i); -} - -inline wxSize operator*(const wxSize& s, long i) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - -inline wxSize operator*(long i, const wxSize& s) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - -inline wxSize operator/(const wxSize& s, unsigned long i) -{ - return wxSize(int(s.x / i), int(s.y / i)); -} - -inline wxSize operator*(const wxSize& s, unsigned long i) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - -inline wxSize operator*(unsigned long i, const wxSize& s) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - -inline wxSize operator*(const wxSize& s, double i) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - -inline wxSize operator*(double i, const wxSize& s) -{ - return wxSize(int(s.x * i), int(s.y * i)); -} - - - // --------------------------------------------------------------------------- // Point classes: with real or integer coordinates // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRealPoint +class WXDLLEXPORT wxRealPoint { public: double x; @@ -427,273 +283,53 @@ public: wxRealPoint() : x(0.0), y(0.0) { } wxRealPoint(double xx, double yy) : x(xx), y(yy) { } - wxRealPoint(const wxPoint& pt); - // no copy ctor or assignment operator - the defaults are ok + wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); } + wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); } - //assignment operators - wxRealPoint& operator+=(const wxRealPoint& p) { x += p.x; y += p.y; return *this; } - wxRealPoint& operator-=(const wxRealPoint& p) { x -= p.x; y -= p.y; return *this; } - - wxRealPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } - wxRealPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } + bool operator==(const wxRealPoint& pt) const + { + return wxIsSameDouble(x, pt.x) && wxIsSameDouble(y, pt.y); + } + bool operator!=(const wxRealPoint& pt) const { return !(*this == pt); } }; -inline bool operator==(const wxRealPoint& p1, const wxRealPoint& p2) -{ - return wxIsSameDouble(p1.x, p2.x) && wxIsSameDouble(p1.y, p2.y); -} - -inline bool operator!=(const wxRealPoint& p1, const wxRealPoint& p2) -{ - return !(p1 == p2); -} - -inline wxRealPoint operator+(const wxRealPoint& p1, const wxRealPoint& p2) -{ - return wxRealPoint(p1.x + p2.x, p1.y + p2.y); -} - - -inline wxRealPoint operator-(const wxRealPoint& p1, const wxRealPoint& p2) -{ - return wxRealPoint(p1.x - p2.x, p1.y - p2.y); -} - - -inline wxRealPoint operator/(const wxRealPoint& s, int i) -{ - return wxRealPoint(s.x / i, s.y / i); -} - -inline wxRealPoint operator*(const wxRealPoint& s, int i) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator*(int i, const wxRealPoint& s) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator/(const wxRealPoint& s, unsigned int i) -{ - return wxRealPoint(s.x / i, s.y / i); -} - -inline wxRealPoint operator*(const wxRealPoint& s, unsigned int i) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator*(unsigned int i, const wxRealPoint& s) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator/(const wxRealPoint& s, long i) -{ - return wxRealPoint(s.x / i, s.y / i); -} - -inline wxRealPoint operator*(const wxRealPoint& s, long i) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator*(long i, const wxRealPoint& s) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator/(const wxRealPoint& s, unsigned long i) -{ - return wxRealPoint(s.x / i, s.y / i); -} - -inline wxRealPoint operator*(const wxRealPoint& s, unsigned long i) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator*(unsigned long i, const wxRealPoint& s) -{ - return wxRealPoint(s.x * i, s.y * i); -} - -inline wxRealPoint operator*(const wxRealPoint& s, double i) -{ - return wxRealPoint(int(s.x * i), int(s.y * i)); -} - -inline wxRealPoint operator*(double i, const wxRealPoint& s) -{ - return wxRealPoint(int(s.x * i), int(s.y * i)); -} - - -// ---------------------------------------------------------------------------- -// wxPoint: 2D point with integer coordinates -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPoint +class WXDLLEXPORT wxPoint { public: int x, y; wxPoint() : x(0), y(0) { } wxPoint(int xx, int yy) : x(xx), y(yy) { } - wxPoint(const wxRealPoint& pt) : x(int(pt.x)), y(int(pt.y)) { } // no copy ctor or assignment operator - the defaults are ok - //assignment operators + // comparison + bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; } + bool operator!=(const wxPoint& p) const { return !(*this == p); } + + // arithmetic operations (component wise) + wxPoint operator+(const wxPoint& p) const { return wxPoint(x + p.x, y + p.y); } + wxPoint operator-(const wxPoint& p) const { return wxPoint(x - p.x, y - p.y); } + wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; } wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; } wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } - // check if both components are set/initialized - bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; } + wxPoint operator+(const wxSize& s) const { return wxPoint(x + s.GetWidth(), y + s.GetHeight()); } + wxPoint operator-(const wxSize& s) const { return wxPoint(x - s.GetWidth(), y - s.GetHeight()); } - // fill in the unset components with the values from the other point - void SetDefaults(const wxPoint& pt) - { - if ( x == wxDefaultCoord ) - x = pt.x; - if ( y == wxDefaultCoord ) - y = pt.y; - } + wxPoint operator-() const { return wxPoint(-x, -y); } }; - -// comparison -inline bool operator==(const wxPoint& p1, const wxPoint& p2) -{ - return p1.x == p2.x && p1.y == p2.y; -} - -inline bool operator!=(const wxPoint& p1, const wxPoint& p2) -{ - return !(p1 == p2); -} - - -// arithmetic operations (component wise) -inline wxPoint operator+(const wxPoint& p1, const wxPoint& p2) -{ - return wxPoint(p1.x + p2.x, p1.y + p2.y); -} - -inline wxPoint operator-(const wxPoint& p1, const wxPoint& p2) -{ - return wxPoint(p1.x - p2.x, p1.y - p2.y); -} - -inline wxPoint operator+(const wxPoint& p, const wxSize& s) -{ - return wxPoint(p.x + s.x, p.y + s.y); -} - -inline wxPoint operator-(const wxPoint& p, const wxSize& s) -{ - return wxPoint(p.x - s.x, p.y - s.y); -} - -inline wxPoint operator+(const wxSize& s, const wxPoint& p) -{ - return wxPoint(p.x + s.x, p.y + s.y); -} - -inline wxPoint operator-(const wxSize& s, const wxPoint& p) -{ - return wxPoint(s.x - p.x, s.y - p.y); -} - -inline wxPoint operator-(const wxPoint& p) -{ - return wxPoint(-p.x, -p.y); -} - -inline wxPoint operator/(const wxPoint& s, int i) -{ - return wxPoint(s.x / i, s.y / i); -} - -inline wxPoint operator*(const wxPoint& s, int i) -{ - return wxPoint(s.x * i, s.y * i); -} - -inline wxPoint operator*(int i, const wxPoint& s) -{ - return wxPoint(s.x * i, s.y * i); -} - -inline wxPoint operator/(const wxPoint& s, unsigned int i) -{ - return wxPoint(s.x / i, s.y / i); -} - -inline wxPoint operator*(const wxPoint& s, unsigned int i) -{ - return wxPoint(s.x * i, s.y * i); -} - -inline wxPoint operator*(unsigned int i, const wxPoint& s) -{ - return wxPoint(s.x * i, s.y * i); -} - -inline wxPoint operator/(const wxPoint& s, long i) -{ - return wxPoint(s.x / i, s.y / i); -} - -inline wxPoint operator*(const wxPoint& s, long i) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -inline wxPoint operator*(long i, const wxPoint& s) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -inline wxPoint operator/(const wxPoint& s, unsigned long i) -{ - return wxPoint(s.x / i, s.y / i); -} - -inline wxPoint operator*(const wxPoint& s, unsigned long i) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -inline wxPoint operator*(unsigned long i, const wxPoint& s) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -inline wxPoint operator*(const wxPoint& s, double i) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -inline wxPoint operator*(double i, const wxPoint& s) -{ - return wxPoint(int(s.x * i), int(s.y * i)); -} - -WX_DECLARE_LIST_WITH_DECL(wxPoint, wxPointList, class WXDLLIMPEXP_CORE); - // --------------------------------------------------------------------------- // wxRect // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRect +class WXDLLEXPORT wxRect { public: wxRect() @@ -755,7 +391,7 @@ public: wxPoint GetTopRight() const { return wxPoint(GetRight(), GetTop()); } wxPoint GetRightTop() const { return GetTopRight(); } void SetTopRight(const wxPoint &p) { SetRight(p.x); SetTop(p.y); } - void SetRightTop(const wxPoint &p) { SetTopRight(p); } + void SetRightTop(const wxPoint &p) { SetTopLeft(p); } wxPoint GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); } wxPoint GetLeftBottom() const { return GetBottomLeft(); } @@ -802,10 +438,14 @@ public: return r; } + // compare rectangles + bool operator==(const wxRect& rect) const; + bool operator!=(const wxRect& rect) const { return !(*this == rect); } + // return true if the point is (not strcitly) inside the rect bool Contains(int x, int y) const; bool Contains(const wxPoint& pt) const { return Contains(pt.x, pt.y); } - // return true if the rectangle 'rect' is (not strictly) inside this rect + // return true if the rectangle is (not strcitly) inside the rect bool Contains(const wxRect& rect) const; #if WXWIN_COMPATIBILITY_2_6 @@ -818,11 +458,15 @@ public: // return true if the rectangles have a non empty intersection bool Intersects(const wxRect& rect) const; - // like Union() but don't ignore empty rectangles - wxRect& operator+=(const wxRect& rect); - // intersections of two rectrangles not testing for empty rectangles - wxRect& operator*=(const wxRect& rect); + // these are like Union() but don't ignore empty rectangles + wxRect operator+(const wxRect& rect) const; + wxRect& operator+=(const wxRect& rect) + { + *this = *this + rect; + return *this; + } + // centre this rectangle in the given (usually, but not necessarily, // larger) one @@ -842,28 +486,6 @@ public: int x, y, width, height; }; - -// compare rectangles -inline bool operator==(const wxRect& r1, const wxRect& r2) -{ - return (r1.x == r2.x) && (r1.y == r2.y) && - (r1.width == r2.width) && (r1.height == r2.height); -} - -inline bool operator!=(const wxRect& r1, const wxRect& r2) -{ - return !(r1 == r2); -} - -// like Union() but don't treat empty rectangles specially -WXDLLIMPEXP_CORE wxRect operator+(const wxRect& r1, const wxRect& r2); - -// intersections of two rectangles -WXDLLIMPEXP_CORE wxRect operator*(const wxRect& r1, const wxRect& r2); - - - - #if WXWIN_COMPATIBILITY_2_6 inline bool wxRect::Inside(int cx, int cy) const { return Contains(cx, cy); } inline bool wxRect::Inside(const wxPoint& pt) const { return Contains(pt); } @@ -871,11 +493,6 @@ inline bool wxRect::Inside(const wxRect& rect) const { return Contains(rect); } #endif // WXWIN_COMPATIBILITY_2_6 -// define functions which couldn't be defined above because of declarations -// order -inline void wxSize::IncBy(const wxPoint& pt) { IncBy(pt.x, pt.y); } -inline void wxSize::DecBy(const wxPoint& pt) { DecBy(pt.x, pt.y); } - // --------------------------------------------------------------------------- // Management of pens, brushes and fonts // --------------------------------------------------------------------------- @@ -891,9 +508,42 @@ protected: wxList list; }; +class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase +{ +public: + wxPen *FindOrCreatePen(const wxColour& colour, int width, int style); +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( void AddPen(wxPen*) ); + wxDEPRECATED( void RemovePen(wxPen*) ); +#endif +}; + +class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase +{ +public: + wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID); +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( void AddBrush(wxBrush*) ); + wxDEPRECATED( void RemoveBrush(wxBrush*) ); +#endif +}; + +class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase +{ +public: + wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight, + bool underline = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( void AddFont(wxFont*) ); + wxDEPRECATED( void RemoveFont(wxFont*) ); +#endif +}; + WX_DECLARE_STRING_HASH_MAP(wxColour*, wxStringToColourHashMap); -class WXDLLIMPEXP_CORE wxColourDatabase +class WXDLLEXPORT wxColourDatabase { public: wxColourDatabase(); @@ -926,11 +576,11 @@ private: wxStringToColourHashMap *m_map; }; -class WXDLLIMPEXP_CORE wxResourceCache: public wxList +class WXDLLEXPORT wxResourceCache: public wxList { public: wxResourceCache() { } -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL wxResourceCache(const unsigned int keyType) : wxList(keyType) { } #endif virtual ~wxResourceCache(); @@ -940,6 +590,10 @@ public: // global variables // --------------------------------------------------------------------------- +// Lists of GDI objects +extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList; +extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList; +extern WXDLLEXPORT_DATA(wxFontList*) wxTheFontList; /* Stock objects @@ -959,7 +613,6 @@ public: BRUSH_BLUE, BRUSH_CYAN, BRUSH_GREEN, - BRUSH_YELLOW, BRUSH_GREY, BRUSH_LIGHTGREY, BRUSH_MEDIUMGREY, @@ -970,7 +623,6 @@ public: COLOUR_BLUE, COLOUR_CYAN, COLOUR_GREEN, - COLOUR_YELLOW, COLOUR_LIGHTGREY, COLOUR_RED, COLOUR_WHITE, @@ -983,10 +635,8 @@ public: FONT_SWISS, PEN_BLACK, PEN_BLACKDASHED, - PEN_BLUE, PEN_CYAN, PEN_GREEN, - PEN_YELLOW, PEN_GREY, PEN_LIGHTGREY, PEN_MEDIUMGREY, @@ -1014,7 +664,7 @@ protected: static wxObject* ms_stockObject[ITEMCOUNT]; - wxDECLARE_NO_COPY_CLASS(wxStockGDI); + DECLARE_NO_COPY_CLASS(wxStockGDI) }; #define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC) @@ -1024,10 +674,8 @@ protected: #define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED) #define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK) -#define wxBLUE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLUE) #define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN) #define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN) -#define wxYELLOW_PEN wxStockGDI::GetPen(wxStockGDI::PEN_YELLOW) #define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY) #define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY) #define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY) @@ -1039,7 +687,6 @@ protected: #define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE) #define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN) #define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN) -#define wxYELLOW_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_YELLOW) #define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY) #define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY) #define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY) @@ -1051,7 +698,6 @@ protected: #define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE) #define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN) #define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN) -#define wxYELLOW wxStockGDI::GetColour(wxStockGDI::COLOUR_YELLOW) #define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY) #define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED) #define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE) @@ -1061,51 +707,49 @@ protected: #define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD) // 'Null' objects -extern WXDLLIMPEXP_DATA_CORE(wxBitmap) wxNullBitmap; -extern WXDLLIMPEXP_DATA_CORE(wxIcon) wxNullIcon; -extern WXDLLIMPEXP_DATA_CORE(wxCursor) wxNullCursor; -extern WXDLLIMPEXP_DATA_CORE(wxPen) wxNullPen; -extern WXDLLIMPEXP_DATA_CORE(wxBrush) wxNullBrush; -extern WXDLLIMPEXP_DATA_CORE(wxPalette) wxNullPalette; -extern WXDLLIMPEXP_DATA_CORE(wxFont) wxNullFont; -extern WXDLLIMPEXP_DATA_CORE(wxColour) wxNullColour; -extern WXDLLIMPEXP_DATA_CORE(wxIconBundle) wxNullIconBundle; +extern WXDLLEXPORT_DATA(wxBitmap) wxNullBitmap; +extern WXDLLEXPORT_DATA(wxIcon) wxNullIcon; +extern WXDLLEXPORT_DATA(wxCursor) wxNullCursor; +extern WXDLLEXPORT_DATA(wxPen) wxNullPen; +extern WXDLLEXPORT_DATA(wxBrush) wxNullBrush; +extern WXDLLEXPORT_DATA(wxPalette) wxNullPalette; +extern WXDLLEXPORT_DATA(wxFont) wxNullFont; +extern WXDLLEXPORT_DATA(wxColour) wxNullColour; -extern WXDLLIMPEXP_DATA_CORE(wxColourDatabase*) wxTheColourDatabase; +extern WXDLLEXPORT_DATA(wxColourDatabase*) wxTheColourDatabase; -extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const wxSize) wxDefaultSize; -extern WXDLLIMPEXP_DATA_CORE(const wxPoint) wxDefaultPosition; +extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize; +extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition; // --------------------------------------------------------------------------- // global functions // --------------------------------------------------------------------------- // resource management -extern void WXDLLIMPEXP_CORE wxInitializeStockLists(); -extern void WXDLLIMPEXP_CORE wxDeleteStockLists(); +extern void WXDLLEXPORT wxInitializeStockLists(); +extern void WXDLLEXPORT wxDeleteStockLists(); // is the display colour (or monochrome)? -extern bool WXDLLIMPEXP_CORE wxColourDisplay(); +extern bool WXDLLEXPORT wxColourDisplay(); // Returns depth of screen -extern int WXDLLIMPEXP_CORE wxDisplayDepth(); +extern int WXDLLEXPORT wxDisplayDepth(); #define wxGetDisplayDepth wxDisplayDepth // get the display size -extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height); -extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize(); -extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height); -extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM(); -extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI(); +extern void WXDLLEXPORT wxDisplaySize(int *width, int *height); +extern wxSize WXDLLEXPORT wxGetDisplaySize(); +extern void WXDLLEXPORT wxDisplaySizeMM(int *width, int *height); +extern wxSize WXDLLEXPORT wxGetDisplaySizeMM(); // Get position and size of the display workarea -extern void WXDLLIMPEXP_CORE wxClientDisplayRect(int *x, int *y, int *width, int *height); -extern wxRect WXDLLIMPEXP_CORE wxGetClientDisplayRect(); +extern void WXDLLEXPORT wxClientDisplayRect(int *x, int *y, int *width, int *height); +extern wxRect WXDLLEXPORT wxGetClientDisplayRect(); // set global cursor -extern void WXDLLIMPEXP_CORE wxSetCursor(const wxCursor& cursor); +extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor); #endif // _WX_GDICMNH__ diff --git a/Source/3rd Party/wx/include/wx/gdiobj.h b/Source/3rd Party/wx/include/wx/gdiobj.h index b1dbc04a7..b4dab2774 100644 --- a/Source/3rd Party/wx/include/wx/gdiobj.h +++ b/Source/3rd Party/wx/include/wx/gdiobj.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: gdiobj.h 42211 2006-10-21 17:19:11Z SN $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -19,44 +20,18 @@ // the same native GDI object // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGDIRefData : public wxObjectRefData -{ -public: - // Default ctor which needs to be defined just because we use - // wxDECLARE_NO_COPY_CLASS() below. - wxGDIRefData() { } - - // override this in the derived classes to check if this data object is - // really fully initialized - virtual bool IsOk() const { return true; } - -private: - wxDECLARE_NO_COPY_CLASS(wxGDIRefData); -}; +class WXDLLIMPEXP_CORE wxGDIRefData: public wxObjectRefData { }; // ---------------------------------------------------------------------------- -// wxGDIObject: base class for bitmaps, pens, brushes, ... +// wxGDIObject // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGDIObject : public wxObject +class WXDLLIMPEXP_CORE wxGDIObject: public wxObject { public: - // checks if the object can be used - virtual bool IsOk() const - { - // the cast here is safe because the derived classes always create - // wxGDIRefData objects - return m_refData && static_cast(m_refData)->IsOk(); - } - - // don't use in the new code, use IsOk() instead bool IsNull() const { return m_refData == NULL; } - // older version, for backwards compatibility only (but not deprecated - // because it's still widely used) - bool Ok() const { return IsOk(); } - -#if defined(__WXMSW__) || defined(__WXPM__) +#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__) // Creates the resource virtual bool RealizeResource() { return false; } @@ -69,24 +44,8 @@ public: virtual WXHANDLE GetResourceHandle() const { return 0; } #endif // defined(__WXMSW__) || defined(__WXPM__) -protected: - // replace base class functions using wxObjectRefData with our own which - // use wxGDIRefData to ensure that we always work with data objects of the - // correct type (i.e. derived from wxGDIRefData) - virtual wxObjectRefData *CreateRefData() const - { - return CreateGDIRefData(); - } - - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const - { - return CloneGDIRefData(static_cast(data)); - } - - virtual wxGDIRefData *CreateGDIRefData() const = 0; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const = 0; - DECLARE_DYNAMIC_CLASS(wxGDIObject) }; -#endif // _WX_GDIOBJ_H_BASE_ +#endif + // _WX_GDIOBJ_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/generic/aboutdlgg.h b/Source/3rd Party/wx/include/wx/generic/aboutdlgg.h deleted file mode 100644 index 36e0cad43..000000000 --- a/Source/3rd Party/wx/include/wx/generic/aboutdlgg.h +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/aboutdlgg.h -// Purpose: generic wxAboutBox() implementation -// Author: Vadim Zeitlin -// Created: 2006-10-07 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_ABOUTDLGG_H_ -#define _WX_GENERIC_ABOUTDLGG_H_ - -#include "wx/defs.h" - -#if wxUSE_ABOUTDLG - -#include "wx/dialog.h" - -class WXDLLIMPEXP_FWD_ADV wxAboutDialogInfo; -class WXDLLIMPEXP_FWD_CORE wxSizer; -class WXDLLIMPEXP_FWD_CORE wxSizerFlags; - -// Under GTK and OS X "About" dialogs are not supposed to be modal, unlike MSW -// and, presumably, all the other platforms. -#ifndef wxUSE_MODAL_ABOUT_DIALOG - #if defined(__WXGTK__) || defined(__WXMAC__) - #define wxUSE_MODAL_ABOUT_DIALOG 0 - #else - #define wxUSE_MODAL_ABOUT_DIALOG 1 - #endif -#endif // wxUSE_MODAL_ABOUT_DIALOG not defined - -// ---------------------------------------------------------------------------- -// wxGenericAboutDialog: generic "About" dialog implementation -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGenericAboutDialog : public wxDialog -{ -public: - // constructors and Create() method - // -------------------------------- - - // default ctor, you must use Create() to really initialize the dialog - wxGenericAboutDialog() { Init(); } - - // ctor which fully initializes the object - wxGenericAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent = NULL) - { - Init(); - - (void)Create(info, parent); - } - - // this method must be called if and only if the default ctor was used - bool Create(const wxAboutDialogInfo& info, wxWindow* parent = NULL); - -protected: - // this virtual method may be overridden to add some more controls to the - // dialog - // - // notice that for this to work you must call Create() from the derived - // class ctor and not use the base class ctor directly as otherwise the - // virtual function of the derived class wouldn't be called - virtual void DoAddCustomControls() { } - - // add arbitrary control to the text sizer contents with the specified - // flags - void AddControl(wxWindow *win, const wxSizerFlags& flags); - - // add arbitrary control to the text sizer contents and center it - void AddControl(wxWindow *win); - - // add the text, if it's not empty, to the text sizer contents - void AddText(const wxString& text); - -#if wxUSE_COLLPANE - // add a wxCollapsiblePane containing the given text - void AddCollapsiblePane(const wxString& title, const wxString& text); -#endif // wxUSE_COLLPANE - -private: - // common part of all ctors - void Init() { m_sizerText = NULL; } - -#if !wxUSE_MODAL_ABOUT_DIALOG - // An explicit handler for deleting the dialog when it's closed is needed - // when we show it non-modally. - void OnCloseWindow(wxCloseEvent& event); - void OnOK(wxCommandEvent& event); -#endif // !wxUSE_MODAL_ABOUT_DIALOG - - wxSizer *m_sizerText; -}; - -// unlike wxAboutBox which can show either the native or generic about dialog, -// this function always shows the generic one -WXDLLIMPEXP_ADV void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); - -#endif // wxUSE_ABOUTDLG - -#endif // _WX_GENERIC_ABOUTDLGG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/accel.h b/Source/3rd Party/wx/include/wx/generic/accel.h deleted file mode 100644 index 44f8e07e8..000000000 --- a/Source/3rd Party/wx/include/wx/generic/accel.h +++ /dev/null @@ -1,49 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/accel.h -// Purpose: wxAcceleratorTable class -// Author: Robert Roebling -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_ACCEL_H_ -#define _WX_GENERIC_ACCEL_H_ - -class WXDLLIMPEXP_FWD_CORE wxKeyEvent; - -// ---------------------------------------------------------------------------- -// wxAcceleratorTable -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxAcceleratorTable : public wxObject -{ -public: - wxAcceleratorTable(); - wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); - virtual ~wxAcceleratorTable(); - - bool Ok() const { return IsOk(); } - bool IsOk() const; - - void Add(const wxAcceleratorEntry& entry); - void Remove(const wxAcceleratorEntry& entry); - - // implementation - // -------------- - - wxMenuItem *GetMenuItem(const wxKeyEvent& event) const; - int GetCommand(const wxKeyEvent& event) const; - - const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const; - -protected: - // ref counting code - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - -private: - DECLARE_DYNAMIC_CLASS(wxAcceleratorTable) -}; - -#endif // _WX_GENERIC_ACCEL_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/animate.h b/Source/3rd Party/wx/include/wx/generic/animate.h deleted file mode 100644 index 818daf890..000000000 --- a/Source/3rd Party/wx/include/wx/generic/animate.h +++ /dev/null @@ -1,177 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/animate.h -// Purpose: wxAnimation and wxAnimationCtrl -// Author: Julian Smart and Guillermo Rodriguez Garcia -// Modified by: Francesco Montorsi -// Created: 13/8/99 -// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_ANIMATEH__ -#define _WX_GENERIC_ANIMATEH__ - -#include "wx/bitmap.h" - -// ---------------------------------------------------------------------------- -// wxAnimation -// ---------------------------------------------------------------------------- - -WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV); - -class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase -{ -public: - wxAnimation() {} - wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY) - { LoadFile(name, type); } - - virtual bool IsOk() const - { return m_refData != NULL; } - - virtual unsigned int GetFrameCount() const; - virtual int GetDelay(unsigned int i) const; - virtual wxImage GetFrame(unsigned int i) const; - virtual wxSize GetSize() const; - - virtual bool LoadFile(const wxString& filename, - wxAnimationType type = wxANIMATION_TYPE_ANY); - virtual bool Load(wxInputStream& stream, - wxAnimationType type = wxANIMATION_TYPE_ANY); - - // extended interface used by the generic implementation of wxAnimationCtrl - wxPoint GetFramePosition(unsigned int frame) const; - wxSize GetFrameSize(unsigned int frame) const; - wxAnimationDisposal GetDisposalMethod(unsigned int frame) const; - wxColour GetTransparentColour(unsigned int frame) const; - wxColour GetBackgroundColour() const; - -protected: - static wxAnimationDecoderList sm_handlers; - -public: - static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; } - static void AddHandler(wxAnimationDecoder *handler); - static void InsertHandler(wxAnimationDecoder *handler); - static const wxAnimationDecoder *FindHandler( wxAnimationType animType ); - - static void CleanUpHandlers(); - static void InitStandardHandlers(); - - DECLARE_DYNAMIC_CLASS(wxAnimation) -}; - - -// ---------------------------------------------------------------------------- -// wxAnimationCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase -{ -public: - wxAnimationCtrl() { Init(); } - wxAnimationCtrl(wxWindow *parent, - wxWindowID id, - const wxAnimation& anim = wxNullAnimation, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxAC_DEFAULT_STYLE, - const wxString& name = wxAnimationCtrlNameStr) - { - Init(); - - Create(parent, id, anim, pos, size, style, name); - } - - void Init(); - - bool Create(wxWindow *parent, wxWindowID id, - const wxAnimation& anim = wxNullAnimation, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxAC_DEFAULT_STYLE, - const wxString& name = wxAnimationCtrlNameStr); - - ~wxAnimationCtrl(); - -public: - virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY); - virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY); - - virtual void Stop(); - virtual bool Play() - { return Play(true /* looped */); } - virtual bool IsPlaying() const - { return m_isPlaying; } - - void SetAnimation(const wxAnimation &animation); - wxAnimation GetAnimation() const - { return m_animation; } - - virtual void SetInactiveBitmap(const wxBitmap &bmp); - - // override base class method - virtual bool SetBackgroundColour(const wxColour& col); - -public: // event handlers - - void OnPaint(wxPaintEvent& event); - void OnTimer(wxTimerEvent& event); - void OnSize(wxSizeEvent& event); - -public: // extended API specific to this implementation of wxAnimateCtrl - - // Specify whether the animation's background colour is to be shown (the default), - // or whether the window background should show through - void SetUseWindowBackgroundColour(bool useWinBackground = true) - { m_useWinBackgroundColour = useWinBackground; } - bool IsUsingWindowBackgroundColour() const - { return m_useWinBackgroundColour; } - - // This overload of Play() lets you specify if the animation must loop or not - bool Play(bool looped); - - // Draw the current frame of the animation into given DC. - // This is fast as current frame is always cached. - void DrawCurrentFrame(wxDC& dc); - - // Returns a wxBitmap with the current frame drawn in it - wxBitmap& GetBackingStore() - { return m_backingStore; } - -protected: // internal utilities - - // resize this control to fit m_animation - void FitToAnimation(); - - // Draw the background; use this when e.g. previous frame had wxANIM_TOBACKGROUND disposal. - void DisposeToBackground(); - void DisposeToBackground(wxDC& dc); - void DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz); - - void IncrementalUpdateBackingStore(); - bool RebuildBackingStoreUpToFrame(unsigned int); - void DrawFrame(wxDC &dc, unsigned int); - - virtual void DisplayStaticImage(); - virtual wxSize DoGetBestSize() const; - -protected: - unsigned int m_currentFrame; // Current frame - bool m_looped; // Looped, or not - wxTimer m_timer; // The timer - wxAnimation m_animation; // The animation - - bool m_isPlaying; // Is the animation playing? - bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour? - - wxBitmap m_backingStore; // The frames are drawn here and then blitted - // on the screen - -private: - typedef wxAnimationCtrlBase base_type; - DECLARE_DYNAMIC_CLASS(wxAnimationCtrl) - DECLARE_EVENT_TABLE() -}; - -#endif // _WX_GENERIC_ANIMATEH__ diff --git a/Source/3rd Party/wx/include/wx/generic/bmpcbox.h b/Source/3rd Party/wx/include/wx/generic/bmpcbox.h deleted file mode 100644 index d5e5cbb16..000000000 --- a/Source/3rd Party/wx/include/wx/generic/bmpcbox.h +++ /dev/null @@ -1,136 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/bmpcbox.h -// Purpose: wxBitmapComboBox -// Author: Jaakko Salli -// Modified by: -// Created: Aug-30-2006 -// Copyright: (c) Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_BMPCBOX_H_ -#define _WX_GENERIC_BMPCBOX_H_ - - -#define wxGENERIC_BITMAPCOMBOBOX 1 - -#include "wx/odcombo.h" - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox: a wxComboBox that allows images to be shown -// in front of string items. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxOwnerDrawnComboBox, - public wxBitmapComboBoxBase -{ -public: - - // ctors and such - wxBitmapComboBox() : wxOwnerDrawnComboBox(), wxBitmapComboBoxBase() - { - Init(); - } - - wxBitmapComboBox(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr) - : wxOwnerDrawnComboBox(), - wxBitmapComboBoxBase() - { - Init(); - - (void)Create(parent, id, value, pos, size, n, - choices, style, validator, name); - } - - wxBitmapComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - virtual ~wxBitmapComboBox(); - - // Adds item with image to the end of the combo box. - int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap); - int Append(const wxString& item, const wxBitmap& bitmap, void *clientData); - int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData); - - // Inserts item with image into the list before pos. Not valid for wxCB_SORT - // styles, use Append instead. - int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos); - int Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, void *clientData); - int Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, wxClientData *clientData); - - // Sets the image for the given item. - virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap); - virtual bool SetFont(const wxFont& font); - -protected: - - virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const; - virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const; - virtual wxCoord OnMeasureItem(size_t item) const; - virtual wxCoord OnMeasureItemWidth(size_t item) const; - - // Event handlers - void OnSize(wxSizeEvent& event); - - virtual wxSize DoGetBestSize() const; - - virtual wxItemContainer* GetItemContainer() { return this; } - virtual wxWindow* GetControl() { return this; } - - // wxItemContainer implementation - virtual int DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type); - virtual void DoClear(); - virtual void DoDeleteOneItem(unsigned int n); - -private: - bool m_inResize; - - void Init(); - - DECLARE_EVENT_TABLE() - - DECLARE_DYNAMIC_CLASS(wxBitmapComboBox) -}; - -#endif // _WX_GENERIC_BMPCBOX_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/busyinfo.h b/Source/3rd Party/wx/include/wx/generic/busyinfo.h index df8ad8642..b8fdd4866 100644 --- a/Source/3rd Party/wx/include/wx/generic/busyinfo.h +++ b/Source/3rd Party/wx/include/wx/generic/busyinfo.h @@ -3,18 +3,17 @@ // Purpose: Information window (when app is busy) // Author: Vaclav Slavik // Copyright: (c) 1999 Vaclav Slavik +// RCS-ID: $Id: busyinfo.h 49804 2007-11-10 01:09:42Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_BUSYINFO_H_ -#define _WX_BUSYINFO_H_ +#ifndef __BUSYINFO_H__ +#define __BUSYINFO_H__ #include "wx/defs.h" #if wxUSE_BUSYINFO -#include "wx/object.h" - class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxWindow; @@ -24,7 +23,7 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; // Can be used in exactly same way as wxBusyCursor //-------------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBusyInfo : public wxObject +class WXDLLEXPORT wxBusyInfo : public wxObject { public: wxBusyInfo(const wxString& message, wxWindow *parent = NULL); @@ -34,8 +33,10 @@ public: private: wxFrame *m_InfoFrame; - wxDECLARE_NO_COPY_CLASS(wxBusyInfo); + DECLARE_NO_COPY_CLASS(wxBusyInfo) }; + #endif // wxUSE_BUSYINFO -#endif // _WX_BUSYINFO_H_ + +#endif // __BUSYINFO_H__ diff --git a/Source/3rd Party/wx/include/wx/generic/buttonbar.h b/Source/3rd Party/wx/include/wx/generic/buttonbar.h deleted file mode 100644 index e933a3ca2..000000000 --- a/Source/3rd Party/wx/include/wx/generic/buttonbar.h +++ /dev/null @@ -1,123 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/buttonbar.h -// Purpose: wxButtonToolBar declaration -// Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech -// Modified by: -// Created: 2006-04-13 -// Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin, -// SciTech Software, Inc. -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_BUTTONBAR_H_ -#define _WX_BUTTONBAR_H_ - -#include "wx/bmpbuttn.h" -#include "wx/toolbar.h" - -class WXDLLIMPEXP_FWD_CORE wxButtonToolBarTool; - -// ---------------------------------------------------------------------------- -// wxButtonToolBar -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxButtonToolBar : public wxToolBarBase -{ -public: - // construction/destruction - wxButtonToolBar() { Init(); } - wxButtonToolBar(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxToolBarNameStr) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create( wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxToolBarNameStr ); - - virtual ~wxButtonToolBar(); - - virtual bool Realize(); - - virtual void SetToolShortHelp(int id, const wxString& helpString); - virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; - -protected: - // common part of all ctors - void Init(); - - // implement base class pure virtuals - virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); - virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); - - virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); - virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); - virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); - - virtual wxToolBarToolBase *CreateTool(int id, - const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, - wxItemKind kind, - wxObject *clientData, - const wxString& shortHelp, - const wxString& longHelp); - virtual wxToolBarToolBase *CreateTool(wxControl *control, - const wxString& label); - - virtual wxSize DoGetBestClientSize() const; - - // calculate layout - void DoLayout(); - - // get the bounding rect for the given tool - wxRect GetToolRect(wxToolBarToolBase *tool) const; - - // get the rect limits depending on the orientation: top/bottom for a - // vertical toolbar, left/right for a horizontal one - void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const; - - // receives button commands - void OnCommand(wxCommandEvent& event); - - // paints a border - void OnPaint(wxPaintEvent& event); - - // detects mouse clicks outside buttons - void OnLeftUp(wxMouseEvent& event); - -private: - // have we calculated the positions of our tools? - bool m_needsLayout; - - // the width of a separator - wxCoord m_widthSeparator; - - // the total size of all toolbar elements - wxCoord m_maxWidth, - m_maxHeight; - - // the height of a label - int m_labelHeight; - - // the space above the label - int m_labelMargin; - -private: - DECLARE_DYNAMIC_CLASS(wxButtonToolBar) - DECLARE_EVENT_TABLE() -}; - -#endif - // _WX_BUTTONBAR_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/calctrlg.h b/Source/3rd Party/wx/include/wx/generic/calctrlg.h deleted file mode 100644 index 8e430b623..000000000 --- a/Source/3rd Party/wx/include/wx/generic/calctrlg.h +++ /dev/null @@ -1,316 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/calctrlg.h -// Purpose: generic implementation of date-picker control -// Author: Vadim Zeitlin -// Modified by: -// Created: 29.12.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_CALCTRLG_H -#define _WX_GENERIC_CALCTRLG_H - -#include "wx/control.h" // the base class -#include "wx/dcclient.h" // for wxPaintDC - -class WXDLLIMPEXP_FWD_CORE wxComboBox; -class WXDLLIMPEXP_FWD_CORE wxStaticText; -class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; -class WXDLLIMPEXP_FWD_CORE wxSpinEvent; - -// ---------------------------------------------------------------------------- -// wxGenericCalendarCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGenericCalendarCtrl : public wxCalendarCtrlBase -{ -public: - // construction - wxGenericCalendarCtrl() { Init(); } - wxGenericCalendarCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS, - const wxString& name = wxCalendarNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS, - const wxString& name = wxCalendarNameStr); - - virtual ~wxGenericCalendarCtrl(); - - virtual bool Destroy(); - - // set/get the current date - // ------------------------ - - virtual bool SetDate(const wxDateTime& date); - virtual wxDateTime GetDate() const { return m_date; } - - - // set/get the range in which selection can occur - // --------------------------------------------- - - virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, - const wxDateTime& upperdate = wxDefaultDateTime); - - virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const; - - // these functions are for generic version only, don't use them but use the - // Set/GetDateRange() above instead - bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime); - const wxDateTime& GetLowerDateLimit() const { return m_lowdate; } - bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime); - const wxDateTime& GetUpperDateLimit() const { return m_highdate; } - - - // calendar mode - // ------------- - - // some calendar styles can't be changed after the control creation by - // just using SetWindowStyle() and Refresh() and the functions below - // should be used instead for them - - // corresponds to wxCAL_NO_MONTH_CHANGE bit - virtual bool EnableMonthChange(bool enable = true); - - // corresponds to wxCAL_NO_YEAR_CHANGE bit, deprecated, generic only - void EnableYearChange(bool enable = true); - - - // customization - // ------------- - - virtual void Mark(size_t day, bool mark); - - // all other functions in this section are for generic version only - - // header colours are used for painting the weekdays at the top - virtual void SetHeaderColours(const wxColour& colFg, const wxColour& colBg) - { - m_colHeaderFg = colFg; - m_colHeaderBg = colBg; - } - - virtual const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; } - virtual const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; } - - // highlight colour is used for the currently selected date - virtual void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) - { - m_colHighlightFg = colFg; - m_colHighlightBg = colBg; - } - - virtual const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; } - virtual const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; } - - // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) - virtual void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) - { - m_colHolidayFg = colFg; - m_colHolidayBg = colBg; - } - - virtual const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; } - virtual const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; } - - virtual wxCalendarDateAttr *GetAttr(size_t day) const - { - wxCHECK_MSG( day > 0 && day < 32, NULL, wxT("invalid day") ); - - return m_attrs[day - 1]; - } - - virtual void SetAttr(size_t day, wxCalendarDateAttr *attr) - { - wxCHECK_RET( day > 0 && day < 32, wxT("invalid day") ); - - delete m_attrs[day - 1]; - m_attrs[day - 1] = attr; - } - - virtual void ResetAttr(size_t day) { SetAttr(day, NULL); } - - virtual void SetHoliday(size_t day); - - virtual wxCalendarHitTestResult HitTest(const wxPoint& pos, - wxDateTime *date = NULL, - wxDateTime::WeekDay *wd = NULL); - - // implementation only from now on - // ------------------------------- - - // forward these functions to all subcontrols - virtual bool Enable(bool enable = true); - virtual bool Show(bool show = true); - - virtual void SetWindowStyleFlag(long style); - - virtual wxVisualAttributes GetDefaultAttributes() const - { return GetClassDefaultAttributes(GetWindowVariant()); } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - - void OnSysColourChanged(wxSysColourChangedEvent& event); - -protected: - // override some base class virtuals - virtual wxSize DoGetBestSize() const; - virtual void DoMoveWindow(int x, int y, int width, int height); - virtual void DoGetSize(int *width, int *height) const; - -private: - // common part of all ctors - void Init(); - - // startup colours and reinitialization after colour changes in system - void InitColours(); - - // event handlers - void OnPaint(wxPaintEvent& event); - void OnClick(wxMouseEvent& event); - void OnDClick(wxMouseEvent& event); - void OnChar(wxKeyEvent& event); - void OnMonthChange(wxCommandEvent& event); - - void HandleYearChange(wxCommandEvent& event); - void OnYearChange(wxSpinEvent& event); - void OnYearTextChange(wxCommandEvent& event); - - // (re)calc m_widthCol and m_heightRow - void RecalcGeometry(); - - // set the date and send the notification - void SetDateAndNotify(const wxDateTime& date); - - // get the week (row, in range 1..6) for the given date - size_t GetWeek(const wxDateTime& date) const; - - // get the date from which we start drawing days - wxDateTime GetStartDate() const; - - // get the first/last days of the week corresponding to the current style - wxDateTime::WeekDay GetWeekStart() const - { - return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Mon - : wxDateTime::Sun; - } - - wxDateTime::WeekDay GetWeekEnd() const - { - return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Sun - : wxDateTime::Sat; - } - - - // is this date shown? - bool IsDateShown(const wxDateTime& date) const; - - // is this date in the currently allowed range? - bool IsDateInRange(const wxDateTime& date) const; - - // adjust the date to the currently allowed range, return true if it was - // changed - bool AdjustDateToRange(wxDateTime *date) const; - - // redraw the given date - void RefreshDate(const wxDateTime& date); - - // change the date inside the same month/year - void ChangeDay(const wxDateTime& date); - - // deprecated - bool AllowYearChange() const - { - return !(GetWindowStyle() & wxCAL_NO_YEAR_CHANGE); - } - - // show the correct controls - void ShowCurrentControls(); - - // create the month combo and year spin controls - void CreateMonthComboBox(); - void CreateYearSpinCtrl(); - -public: - // get the currently shown control for month/year - wxControl *GetMonthControl() const; - wxControl *GetYearControl() const; - -private: - virtual void ResetHolidayAttrs(); - virtual void RefreshHolidays() { Refresh(); } - - // OnPaint helper-methods - - // Highlight the [fromdate : todate] range using pen and brush - void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pen, const wxBrush* brush); - - // Get the "coordinates" for the date relative to the month currently displayed. - // using (day, week): upper left coord is (1, 1), lower right coord is (7, 6) - // if the date isn't visible (-1, -1) is put in (day, week) and false is returned - bool GetDateCoord(const wxDateTime& date, int *day, int *week) const; - - // Set the flag for SetDate(): otherwise it would overwrite the year - // typed in by the user - void SetUserChangedYear() { m_userChangedYear = true; } - - - // the subcontrols - wxStaticText *m_staticMonth; - wxComboBox *m_comboMonth; - - wxStaticText *m_staticYear; - wxSpinCtrl *m_spinYear; - - // the current selection - wxDateTime m_date; - - // the date-range - wxDateTime m_lowdate; - wxDateTime m_highdate; - - // default attributes - wxColour m_colHighlightFg, - m_colHighlightBg, - m_colHolidayFg, - m_colHolidayBg, - m_colHeaderFg, - m_colHeaderBg, - m_colBackground, - m_colSurrounding; - - // the attributes for each of the month days - wxCalendarDateAttr *m_attrs[31]; - - // the width and height of one column/row in the calendar - wxCoord m_widthCol, - m_heightRow, - m_rowOffset, - m_calendarWeekWidth; - - wxRect m_leftArrowRect, - m_rightArrowRect; - - // the week day names - wxString m_weekdays[7]; - - // true if SetDate() is being called as the result of changing the year in - // the year control - bool m_userChangedYear; - - DECLARE_DYNAMIC_CLASS(wxGenericCalendarCtrl) - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGenericCalendarCtrl); -}; - -#endif // _WX_GENERIC_CALCTRLG_H diff --git a/Source/3rd Party/wx/include/wx/generic/caret.h b/Source/3rd Party/wx/include/wx/generic/caret.h deleted file mode 100644 index 67041cf20..000000000 --- a/Source/3rd Party/wx/include/wx/generic/caret.h +++ /dev/null @@ -1,94 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/caret.h -// Purpose: generic wxCaret class -// Author: Vadim Zeitlin (original code by Robert Roebling) -// Modified by: -// Created: 25.05.99 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_CARET_H_ -#define _WX_CARET_H_ - -#include "wx/timer.h" -#include "wx/dc.h" -#include "wx/overlay.h" - -#ifdef wxHAS_NATIVE_OVERLAY - #define wxHAS_CARET_USING_OVERLAYS -#endif - -class WXDLLIMPEXP_FWD_CORE wxCaret; - -class WXDLLIMPEXP_CORE wxCaretTimer : public wxTimer -{ -public: - wxCaretTimer(wxCaret *caret); - virtual void Notify(); - -private: - wxCaret *m_caret; -}; - -class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase -{ -public: - // ctors - // ----- - // default - use Create() - wxCaret() : m_timer(this) { InitGeneric(); } - // creates a block caret associated with the given window - wxCaret(wxWindowBase *window, int width, int height) - : wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); } - wxCaret(wxWindowBase *window, const wxSize& size) - : wxCaretBase(window, size), m_timer(this) { InitGeneric(); } - - virtual ~wxCaret(); - - // implementation - // -------------- - - // called by wxWindow (not using the event tables) - virtual void OnSetFocus(); - virtual void OnKillFocus(); - - // called by wxCaretTimer - void OnTimer(); - -protected: - virtual void DoShow(); - virtual void DoHide(); - virtual void DoMove(); - virtual void DoSize(); - - // blink the caret once - void Blink(); - - // refresh the caret - void Refresh(); - - // draw the caret on the given DC - void DoDraw(wxDC *dc, wxWindow* win); - -private: - // GTK specific initialization - void InitGeneric(); - -#ifdef wxHAS_CARET_USING_OVERLAYS - // the overlay for displaying the caret - wxOverlay m_overlay; -#else - // the bitmap holding the part of window hidden by the caret when it was - // at (m_xOld, m_yOld) - wxBitmap m_bmpUnderCaret; - int m_xOld, - m_yOld; -#endif - - wxCaretTimer m_timer; - bool m_blinkedOut, // true => caret hidden right now - m_hasFocus; // true => our window has focus -}; - -#endif // _WX_CARET_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/choicdgg.h b/Source/3rd Party/wx/include/wx/generic/choicdgg.h index e0cf1ed69..ebefcd81b 100644 --- a/Source/3rd Party/wx/include/wx/generic/choicdgg.h +++ b/Source/3rd Party/wx/include/wx/generic/choicdgg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions // Created: 01/02/97 +// RCS-ID: $Id: choicdgg.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,7 +36,7 @@ class WXDLLIMPEXP_FWD_CORE wxListBoxBase; // wxAnyChoiceDialog: a base class for dialogs containing a listbox // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxAnyChoiceDialog : public wxDialog +class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog { public: wxAnyChoiceDialog() { } @@ -85,14 +86,14 @@ protected: const wxString *choices, long styleLbox); - wxDECLARE_NO_COPY_CLASS(wxAnyChoiceDialog); + DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog) }; // ---------------------------------------------------------------------------- // wxSingleChoiceDialog: a dialog with single selection listbox // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSingleChoiceDialog : public wxAnyChoiceDialog +class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog { public: wxSingleChoiceDialog() @@ -105,112 +106,39 @@ public: const wxString& caption, int n, const wxString *choices, - void **clientData = NULL, + char **clientData = (char **)NULL, long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition) - { - Create(parent, message, caption, n, choices, clientData, style, pos); - } - + const wxPoint& pos = wxDefaultPosition); wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, const wxArrayString& choices, - void **clientData = NULL, + char **clientData = (char **)NULL, long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition) - { - Create(parent, message, caption, choices, clientData, style, pos); - } + const wxPoint& pos = wxDefaultPosition); bool Create(wxWindow *parent, const wxString& message, const wxString& caption, int n, const wxString *choices, - void **clientData = NULL, + char **clientData = (char **)NULL, long style = wxCHOICEDLG_STYLE, const wxPoint& pos = wxDefaultPosition); bool Create(wxWindow *parent, const wxString& message, const wxString& caption, const wxArrayString& choices, - void **clientData = NULL, + char **clientData = (char **)NULL, long style = wxCHOICEDLG_STYLE, const wxPoint& pos = wxDefaultPosition); void SetSelection(int sel); int GetSelection() const { return m_selection; } wxString GetStringSelection() const { return m_stringSelection; } - void* GetSelectionData() const { return m_clientData; } -#if WXWIN_COMPATIBILITY_2_8 - // Deprecated overloads taking "char**" client data. - wxDEPRECATED_CONSTRUCTOR - ( - wxSingleChoiceDialog(wxWindow *parent, - const wxString& message, - const wxString& caption, - int n, - const wxString *choices, - char **clientData, - long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition) - ) - { - Create(parent, message, caption, n, choices, - (void**)clientData, style, pos); - } - - wxDEPRECATED_CONSTRUCTOR - ( - wxSingleChoiceDialog(wxWindow *parent, - const wxString& message, - const wxString& caption, - const wxArrayString& choices, - char **clientData, - long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition) - ) - { - Create(parent, message, caption, choices, - (void**)clientData, style, pos); - } - - wxDEPRECATED_INLINE - ( - bool Create(wxWindow *parent, - const wxString& message, - const wxString& caption, - int n, - const wxString *choices, - char **clientData, - long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition), - return Create(parent, message, caption, n, choices, - (void**)clientData, style, pos); - ) - - wxDEPRECATED_INLINE - ( - bool Create(wxWindow *parent, - const wxString& message, - const wxString& caption, - const wxArrayString& choices, - char **clientData, - long style = wxCHOICEDLG_STYLE, - const wxPoint& pos = wxDefaultPosition), - return Create(parent, message, caption, choices, - (void**)clientData, style, pos); - ) - - // NB: no need to make it return wxChar, it's untyped - wxDEPRECATED_ACCESSOR - ( - char* GetSelectionClientData() const, - (char*)GetSelectionData() - ) -#endif // WXWIN_COMPATIBILITY_2_8 + // obsolete function (NB: no need to make it return wxChar, it's untyped) + char *GetSelectionClientData() const { return (char *)m_clientData; } // implementation from now on void OnOK(wxCommandEvent& event); @@ -236,7 +164,7 @@ private: // wxMultiChoiceDialog: a dialog with multi selection listbox // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMultiChoiceDialog : public wxAnyChoiceDialog +class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog { public: wxMultiChoiceDialog() { } @@ -299,7 +227,7 @@ private: // ---------------------------------------------------------------------------- // get the user selection as a string -WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, +WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, const wxArrayString& choices, wxWindow *parent = NULL, @@ -307,10 +235,9 @@ WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); + int height = wxCHOICE_HEIGHT); -WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, +WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, int n, const wxString *choices, wxWindow *parent = NULL, @@ -318,24 +245,11 @@ WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); - -WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, - const wxString& caption, - const wxArrayString& choices, - int initialSelection, - wxWindow *parent = NULL); - -WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message, - const wxString& caption, - int n, const wxString *choices, - int initialSelection, - wxWindow *parent = NULL); + int height = wxCHOICE_HEIGHT); // Same as above but gets position in list of strings, instead of string, // or -1 if no selection -WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, +WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, const wxArrayString& choices, wxWindow *parent = NULL, @@ -343,10 +257,9 @@ WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); + int height = wxCHOICE_HEIGHT); -WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, +WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, int n, const wxString *choices, wxWindow *parent = NULL, @@ -354,23 +267,10 @@ WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); + int height = wxCHOICE_HEIGHT); -WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, - const wxString& caption, - const wxArrayString& choices, - int initialSelection, - wxWindow *parent = NULL); - -WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message, - const wxString& caption, - int n, const wxString *choices, - int initialSelection, - wxWindow *parent = NULL); - -// Return client data instead or NULL if canceled -WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, +// Return client data instead or NULL if cancelled +WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message, const wxString& caption, const wxArrayString& choices, void **client_data, @@ -379,10 +279,9 @@ WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); + int height = wxCHOICE_HEIGHT); -WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, +WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message, const wxString& caption, int n, const wxString *choices, void **client_data, @@ -391,54 +290,12 @@ WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT, - int initialSelection = 0); - -WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, - const wxString& caption, - const wxArrayString& choices, - void **client_data, - int initialSelection, - wxWindow *parent = NULL); - - -WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message, - const wxString& caption, - int n, const wxString *choices, - void **client_data, - int initialSelection, - wxWindow *parent = NULL); - -// fill the array with the indices of the chosen items, it will be empty -// if no items were selected or Cancel was pressed - return the number of -// selections or -1 if cancelled -WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections, - const wxString& message, - const wxString& caption, - int n, const wxString *choices, - wxWindow *parent = NULL, - int x = wxDefaultCoord, - int y = wxDefaultCoord, - bool centre = true, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); -WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections, - const wxString& message, - const wxString& caption, - const wxArrayString& choices, - wxWindow *parent = NULL, - int x = wxDefaultCoord, - int y = wxDefaultCoord, - bool centre = true, - int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT); - -#if WXWIN_COMPATIBILITY_2_8 // fill the array with the indices of the chosen items, it will be empty // if no items were selected or Cancel was pressed - return the number of // selections -wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections, +WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections, const wxString& message, const wxString& caption, int n, const wxString *choices, @@ -447,9 +304,9 @@ wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selection int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT) ); + int height = wxCHOICE_HEIGHT); -wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections, +WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections, const wxString& message, const wxString& caption, const wxArrayString& choices, @@ -458,7 +315,6 @@ wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selection int y = wxDefaultCoord, bool centre = true, int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT)); -#endif // WXWIN_COMPATIBILITY_2_8 + int height = wxCHOICE_HEIGHT); #endif // _WX_GENERIC_CHOICDGG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/clrpickerg.h b/Source/3rd Party/wx/include/wx/generic/clrpickerg.h index 723c8795f..3a54f1e6f 100644 --- a/Source/3rd Party/wx/include/wx/generic/clrpickerg.h +++ b/Source/3rd Party/wx/include/wx/generic/clrpickerg.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Vadim Zeitlin, Francesco Montorsi +// RCS-ID: $Id: clrpickerg.h 58967 2009-02-17 13:31:28Z SC $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -12,14 +13,30 @@ #define _WX_CLRPICKER_H_ #include "wx/button.h" -#include "wx/bmpbuttn.h" -#include "wx/colourdata.h" +#include "wx/cmndata.h" //----------------------------------------------------------------------------- // wxGenericColourButton: a button which brings up a wxColourDialog //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGenericColourButton : public wxBitmapButton, +// show the colour in HTML form (#AABBCC) as colour button label +#define wxCLRBTN_SHOW_LABEL 100 + +// the default style +#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL) + +#ifndef wxCLRBTN_USES_BMP_BUTTON + #define wxCLRBTN_USES_BMP_BUTTON 0 +#endif + +#if wxCLRBTN_USES_BMP_BUTTON + #include "wx/bmpbutton.h" + #define wxCLRBTN_BASE_CLASS wxBitmapButton +#else + #define wxCLRBTN_BASE_CLASS wxButton +#endif + +class WXDLLIMPEXP_CORE wxGenericColourButton : public wxCLRBTN_BASE_CLASS, public wxColourPickerWidgetBase { public: @@ -63,7 +80,6 @@ public: protected: - wxBitmap m_bitmap; wxSize DoGetBestSize() const; diff --git a/Source/3rd Party/wx/include/wx/generic/collpaneg.h b/Source/3rd Party/wx/include/wx/generic/collpaneg.h index e7c05eee2..b16b65948 100644 --- a/Source/3rd Party/wx/include/wx/generic/collpaneg.h +++ b/Source/3rd Party/wx/include/wx/generic/collpaneg.h @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 8/10/2006 +// RCS-ID: $Id: collpaneg.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -14,18 +15,15 @@ // forward declared class WXDLLIMPEXP_FWD_CORE wxButton; class WXDLLIMPEXP_FWD_CORE wxStaticLine; -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) -class WXDLLIMPEXP_FWD_CORE wxDisclosureTriangle; -#endif -#include "wx/containr.h" +// class name +extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxCollapsiblePaneNameStr[]; // ---------------------------------------------------------------------------- // wxGenericCollapsiblePane // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : - public wxNavigationEnabled +class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : public wxCollapsiblePaneBase { public: wxGenericCollapsiblePane() { Init(); } @@ -44,7 +42,15 @@ public: Create(parent, winid, label, pos, size, style, val, name); } - virtual ~wxGenericCollapsiblePane(); + void Init() + { + m_pButton = NULL; + m_pPane = NULL; + m_pStaticLine = NULL; + m_sz = NULL; + } + + ~wxGenericCollapsiblePane(); bool Create(wxWindow *parent, wxWindowID winid, @@ -68,11 +74,6 @@ public: virtual bool Layout(); - - // for the generic collapsible pane only: - wxControl* GetControlWidget() const - { return (wxControl*)m_pButton; } - // implementation only, don't use void OnStateChange(const wxSize& sizeNew); @@ -84,11 +85,7 @@ protected: int GetBorder() const; // child controls -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) - wxDisclosureTriangle *m_pButton; -#else wxButton *m_pButton; -#endif wxStaticLine *m_pStaticLine; wxWindow *m_pPane; wxSizer *m_sz; @@ -97,8 +94,6 @@ protected: wxString m_strLabel; private: - void Init(); - // event handlers void OnButton(wxCommandEvent &ev); void OnSize(wxSizeEvent &ev); diff --git a/Source/3rd Party/wx/include/wx/generic/colour.h b/Source/3rd Party/wx/include/wx/generic/colour.h deleted file mode 100644 index 5db020cac..000000000 --- a/Source/3rd Party/wx/include/wx/generic/colour.h +++ /dev/null @@ -1,71 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/colour.h -// Purpose: wxColour class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_COLOUR_H_ -#define _WX_GENERIC_COLOUR_H_ - -#include "wx/object.h" - -// Colour -class WXDLLIMPEXP_CORE wxColour: public wxColourBase -{ -public: - // constructors - // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS - - // copy ctors and assignment operators - wxColour(const wxColour& col) - { - *this = col; - } - - wxColour& operator=(const wxColour& col); - - // accessors - virtual bool IsOk() const { return m_isInit; } - - unsigned char Red() const { return m_red; } - unsigned char Green() const { return m_green; } - unsigned char Blue() const { return m_blue; } - unsigned char Alpha() const { return m_alpha; } - - // comparison - bool operator==(const wxColour& colour) const - { - return (m_red == colour.m_red && - m_green == colour.m_green && - m_blue == colour.m_blue && - m_alpha == colour.m_alpha && - m_isInit == colour.m_isInit); - } - - bool operator!=(const wxColour& colour) const { return !(*this == colour); } - -protected: - - // Helper function - void Init(); - - virtual void - InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); - -private: - bool m_isInit; - unsigned char m_red; - unsigned char m_blue; - unsigned char m_green; - unsigned char m_alpha; - -private: - DECLARE_DYNAMIC_CLASS(wxColour) -}; - -#endif // _WX_GENERIC_COLOUR_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/colrdlgg.h b/Source/3rd Party/wx/include/wx/generic/colrdlgg.h deleted file mode 100644 index a83abd8ce..000000000 --- a/Source/3rd Party/wx/include/wx/generic/colrdlgg.h +++ /dev/null @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/colrdlgg.h -// Purpose: wxGenericColourDialog -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_COLORDLGG_H_ -#define _WX_COLORDLGG_H_ - -#include "wx/gdicmn.h" -#include "wx/dialog.h" - -#define wxID_ADD_CUSTOM 3000 - -#if wxUSE_SLIDER - - #define wxID_RED_SLIDER 3001 - #define wxID_GREEN_SLIDER 3002 - #define wxID_BLUE_SLIDER 3003 - - class WXDLLIMPEXP_FWD_CORE wxSlider; - -#endif // wxUSE_SLIDER - -class WXDLLIMPEXP_CORE wxGenericColourDialog : public wxDialog -{ -public: - wxGenericColourDialog(); - wxGenericColourDialog(wxWindow *parent, - wxColourData *data = NULL); - virtual ~wxGenericColourDialog(); - - bool Create(wxWindow *parent, wxColourData *data = NULL); - - wxColourData &GetColourData() { return m_colourData; } - - virtual int ShowModal(); - - // Internal functions - void OnMouseEvent(wxMouseEvent& event); - void OnPaint(wxPaintEvent& event); - - virtual void CalculateMeasurements(); - virtual void CreateWidgets(); - virtual void InitializeColours(); - - virtual void PaintBasicColours(wxDC& dc); - virtual void PaintCustomColours(wxDC& dc); - virtual void PaintCustomColour(wxDC& dc); - virtual void PaintHighlight(wxDC& dc, bool draw); - - virtual void OnBasicColourClick(int which); - virtual void OnCustomColourClick(int which); - - void OnAddCustom(wxCommandEvent& event); - -#if wxUSE_SLIDER - void OnRedSlider(wxCommandEvent& event); - void OnGreenSlider(wxCommandEvent& event); - void OnBlueSlider(wxCommandEvent& event); -#endif // wxUSE_SLIDER - - void OnCloseWindow(wxCloseEvent& event); - -protected: - wxColourData m_colourData; - - // Area reserved for grids of colours - wxRect m_standardColoursRect; - wxRect m_customColoursRect; - wxRect m_singleCustomColourRect; - - // Size of each colour rectangle - wxPoint m_smallRectangleSize; - - // For single customizable colour - wxPoint m_customRectangleSize; - - // Grid spacing (between rectangles) - int m_gridSpacing; - - // Section spacing (between left and right halves of dialog box) - int m_sectionSpacing; - - // 48 'standard' colours - wxColour m_standardColours[48]; - - // 16 'custom' colours - wxColour m_customColours[16]; - - // Which colour is selected? An index into one of the two areas. - int m_colourSelection; - int m_whichKind; // 1 for standard colours, 2 for custom colours, - -#if wxUSE_SLIDER - wxSlider *m_redSlider; - wxSlider *m_greenSlider; - wxSlider *m_blueSlider; -#endif // wxUSE_SLIDER - - int m_buttonY; - - int m_okButtonX; - int m_customButtonX; - - // static bool colourDialogCancelled; - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericColourDialog) -}; - -#endif // _WX_COLORDLGG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/combo.h b/Source/3rd Party/wx/include/wx/generic/combo.h index af1c7533a..1c0ccee5c 100644 --- a/Source/3rd Party/wx/include/wx/generic/combo.h +++ b/Source/3rd Party/wx/include/wx/generic/combo.h @@ -4,6 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 +// RCS-ID: $Id: combo.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Jaakko Salli // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,11 +31,9 @@ #endif -#include "wx/dcbuffer.h" +extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxComboBoxNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[]; - -class WXDLLIMPEXP_CORE wxGenericComboCtrl : public wxComboCtrlBase +class WXDLLEXPORT wxGenericComboCtrl : public wxComboCtrlBase { public: // ctors and such @@ -81,37 +80,6 @@ public: protected: - // Dummies for platform-specific wxTextEntry implementations -#if defined(__WXUNIVERSAL__) - // Looks like there's nothing we need to override here -#elif defined(__WXMOTIF__) - virtual WXWidget GetTextWidget() const { return NULL; } -#elif defined(__WXGTK__) -#if defined(__WXGTK20__) - virtual GtkEditable *GetEditable() const { return NULL; } - virtual GtkEntry *GetEntry() const { return NULL; } -#endif -#elif defined(__WXMAC__) - // Looks like there's nothing we need to override here -#elif defined(__WXPM__) - virtual WXHWND GetEditHWND() const { return NULL; } -#endif - - // For better transparent background rendering - virtual bool HasTransparentBackground() - { - #if wxALWAYS_NATIVE_DOUBLE_BUFFER - #ifdef __WXGTK__ - // Sanity check for GTK+ - return IsDoubleBuffered(); - #else - return true; - #endif - #else - return false; - #endif - } - // Mandatory virtuals virtual void OnResize(); @@ -133,7 +101,7 @@ private: // If native wxComboCtrl was not defined, then prepare a simple // front-end so that wxRTTI works as expected. -class WXDLLIMPEXP_CORE wxComboCtrl : public wxGenericComboCtrl +class WXDLLEXPORT wxComboCtrl : public wxGenericComboCtrl { public: wxComboCtrl() : wxGenericComboCtrl() {} diff --git a/Source/3rd Party/wx/include/wx/generic/ctrlsub.h b/Source/3rd Party/wx/include/wx/generic/ctrlsub.h deleted file mode 100644 index 0dd113dcf..000000000 --- a/Source/3rd Party/wx/include/wx/generic/ctrlsub.h +++ /dev/null @@ -1,122 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/ctrlsub.h -// Purpose: common functionality of wxItemContainer-derived controls -// Author: Vadim Zeitlin -// Created: 2007-07-25 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_CTRLSUB_H_ -#define _WX_GENERIC_CTRLSUB_H_ - -#include "wx/dynarray.h" - -// ---------------------------------------------------------------------------- -// wxControlWithItemsGeneric: generic implementation of item client data -// ---------------------------------------------------------------------------- - -class wxControlWithItemsGeneric : public wxControlWithItemsBase -{ -public: - wxControlWithItemsGeneric() { } - - virtual void DoInitItemClientData() - { - m_itemsClientData.resize(GetCount(), NULL); - } - - virtual void DoSetItemClientData(unsigned int n, void *clientData) - { - m_itemsClientData[n] = clientData; - } - - virtual void *DoGetItemClientData(unsigned int n) const - { - return m_itemsClientData[n]; - } - - virtual void DoClear() { m_itemsClientData.clear(); } - virtual void DoDeleteOneItem(unsigned int pos) - { - if ( HasClientData() ) - m_itemsClientData.RemoveAt(pos); - } - -protected: - // preallocate memory for numItems new items: this should be called from - // the derived classes DoInsertItems() to speed up appending big numbers of - // items with client data; it is safe to call even if we don't use client - // data at all and does nothing in this case - void AllocClientData(unsigned int numItems) - { - if ( HasClientData() ) - m_itemsClientData.reserve(m_itemsClientData.size() + numItems); - } - - // this must be called by derived classes when a new item is added to the - // control to add storage for the corresponding client data pointer (before - // inserting many items, call AllocClientData()) - void InsertNewItemClientData(unsigned int pos, - void **clientData, - unsigned int n, - wxClientDataType type) - { - if ( InitClientDataIfNeeded(type) ) - m_itemsClientData.Insert(clientData[n], pos); - } - - // the same as InsertNewItemClientData() but for numItems consecutive items - // (this can only be used if the control doesn't support sorting as - // otherwise the items positions wouldn't be consecutive any more) - void InsertNewItemsClientData(unsigned int pos, - unsigned int numItems, - void **clientData, - wxClientDataType type) - { - if ( InitClientDataIfNeeded(type) ) - { - // it's more efficient to insert everything at once and then update - // for big number of items to avoid moving the array contents - // around (which would result in O(N^2) algorithm) - m_itemsClientData.Insert(NULL, pos, numItems); - - for ( unsigned int n = 0; n < numItems; ++n, ++pos ) - m_itemsClientData[pos] = clientData[n]; - } - } - - - // vector containing the client data pointers: it is either empty (if - // client data is not used) or has the same number of elements as the - // control - wxArrayPtrVoid m_itemsClientData; - -private: - // initialize client data if needed, return false if we don't have any - // client data and true otherwise - bool InitClientDataIfNeeded(wxClientDataType type) - { - if ( !HasClientData() ) - { - if ( type == wxClientData_None ) - { - // we didn't have the client data before and are not asked to - // store it now neither - return false; - } - - // this is the first time client data is used with this control - DoInitItemClientData(); - SetClientDataType(type); - } - //else: we already have client data - - return true; - } - - wxDECLARE_NO_COPY_CLASS(wxControlWithItemsGeneric); -}; - -#endif // _WX_GENERIC_CTRLSUB_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/custombgwin.h b/Source/3rd Party/wx/include/wx/generic/custombgwin.h deleted file mode 100644 index 800419549..000000000 --- a/Source/3rd Party/wx/include/wx/generic/custombgwin.h +++ /dev/null @@ -1,95 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/custombgwin.h -// Purpose: Generic implementation of wxCustomBackgroundWindow. -// Author: Vadim Zeitlin -// Created: 2011-10-10 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_CUSTOMBGWIN_H_ -#define _WX_GENERIC_CUSTOMBGWIN_H_ - -#include "wx/bitmap.h" - -// A helper to avoid template bloat: this class contains all type-independent -// code of wxCustomBackgroundWindow<> below. -class wxCustomBackgroundWindowGenericBase : public wxCustomBackgroundWindowBase -{ -public: - wxCustomBackgroundWindowGenericBase() { } - -protected: - void DoEraseBackground(wxEraseEvent& event, wxWindow* win) - { - wxDC& dc = *event.GetDC(); - - const wxSize clientSize = win->GetClientSize(); - const wxSize bitmapSize = m_bitmapBg.GetSize(); - - for ( int x = 0; x < clientSize.x; x += bitmapSize.x ) - { - for ( int y = 0; y < clientSize.y; y += bitmapSize.y ) - { - dc.DrawBitmap(m_bitmapBg, x, y); - } - } - } - - - // The bitmap used for painting the background if valid. - wxBitmap m_bitmapBg; - - - wxDECLARE_NO_COPY_CLASS(wxCustomBackgroundWindowGenericBase); -}; - -// ---------------------------------------------------------------------------- -// wxCustomBackgroundWindow -// ---------------------------------------------------------------------------- - -template -class wxCustomBackgroundWindow : public W, - public wxCustomBackgroundWindowGenericBase -{ -public: - typedef W BaseWindowClass; - - wxCustomBackgroundWindow() { } - -protected: - virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) - { - m_bitmapBg = bmp; - - if ( m_bitmapBg.IsOk() ) - { - BaseWindowClass::Connect - ( - wxEVT_ERASE_BACKGROUND, - wxEraseEventHandler(wxCustomBackgroundWindow::OnEraseBackground) - ); - } - else - { - BaseWindowClass::Disconnect - ( - wxEVT_ERASE_BACKGROUND, - wxEraseEventHandler(wxCustomBackgroundWindow::OnEraseBackground) - ); - } - } - -private: - // Event handler for erasing the background which is only used when we have - // a valid background bitmap. - void OnEraseBackground(wxEraseEvent& event) - { - DoEraseBackground(event, this); - } - - - wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCustomBackgroundWindow, W); -}; - -#endif // _WX_GENERIC_CUSTOMBGWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/dataview.h b/Source/3rd Party/wx/include/wx/generic/dataview.h deleted file mode 100644 index f3ac8ee59..000000000 --- a/Source/3rd Party/wx/include/wx/generic/dataview.h +++ /dev/null @@ -1,292 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dataview.h -// Purpose: wxDataViewCtrl generic implementation header -// Author: Robert Roebling -// Modified By: Bo Yang -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GENERICDATAVIEWCTRLH__ -#define __GENERICDATAVIEWCTRLH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" -#include "wx/scrolwin.h" -#include "wx/icon.h" -#include "wx/vector.h" - -class WXDLLIMPEXP_FWD_ADV wxDataViewMainWindow; -class WXDLLIMPEXP_FWD_ADV wxDataViewHeaderWindow; - -// --------------------------------------------------------- -// wxDataViewColumn -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewColumn : public wxDataViewColumnBase -{ -public: - wxDataViewColumn(const wxString& title, - wxDataViewRenderer *renderer, - unsigned int model_column, - int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE) - : wxDataViewColumnBase(renderer, model_column), - m_title(title) - { - Init(width, align, flags); - } - - wxDataViewColumn(const wxBitmap& bitmap, - wxDataViewRenderer *renderer, - unsigned int model_column, - int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxDATAVIEW_COL_RESIZABLE) - : wxDataViewColumnBase(bitmap, renderer, model_column) - { - Init(width, align, flags); - } - - // implement wxHeaderColumnBase methods - virtual void SetTitle(const wxString& title) { m_title = title; UpdateDisplay(); } - virtual wxString GetTitle() const { return m_title; } - - virtual void SetWidth(int width) { m_width = width; UpdateDisplay(); } - virtual int GetWidth() const; - - virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; UpdateDisplay(); } - virtual int GetMinWidth() const { return m_minWidth; } - - virtual void SetAlignment(wxAlignment align) { m_align = align; UpdateDisplay(); } - virtual wxAlignment GetAlignment() const { return m_align; } - - virtual void SetFlags(int flags) { m_flags = flags; UpdateDisplay(); } - virtual int GetFlags() const { return m_flags; } - - virtual bool IsSortKey() const { return m_sort; } - - virtual void UnsetAsSortKey(); - - virtual void SetSortOrder(bool ascending); - - virtual bool IsSortOrderAscending() const { return m_sortAscending; } - - virtual void SetBitmap( const wxBitmap& bitmap ) { wxDataViewColumnBase::SetBitmap(bitmap); UpdateDisplay(); } - - -private: - // common part of all ctors - void Init(int width, wxAlignment align, int flags); - - void UpdateDisplay(); - - wxString m_title; - int m_width, - m_minWidth; - wxAlignment m_align; - int m_flags; - bool m_sort, - m_sortAscending; - - friend class wxDataViewHeaderWindowBase; - friend class wxDataViewHeaderWindow; - friend class wxDataViewHeaderWindowMSW; -}; - -// --------------------------------------------------------- -// wxDataViewCtrl -// --------------------------------------------------------- - -WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, - class WXDLLIMPEXP_ADV); - -class WXDLLIMPEXP_ADV wxDataViewCtrl : public wxDataViewCtrlBase, - public wxScrollHelper -{ - friend class wxDataViewMainWindow; - friend class wxDataViewHeaderWindowBase; - friend class wxDataViewHeaderWindow; - friend class wxDataViewHeaderWindowMSW; - friend class wxDataViewColumn; - -public: - wxDataViewCtrl() : wxScrollHelper(this) - { - Init(); - } - - wxDataViewCtrl( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDataViewCtrlNameStr ) - : wxScrollHelper(this) - { - Create(parent, id, pos, size, style, validator, name); - } - - virtual ~wxDataViewCtrl(); - - void Init(); - - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDataViewCtrlNameStr); - - virtual bool AssociateModel( wxDataViewModel *model ); - - virtual bool AppendColumn( wxDataViewColumn *col ); - virtual bool PrependColumn( wxDataViewColumn *col ); - virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); - - virtual void DoSetExpanderColumn(); - virtual void DoSetIndent(); - - virtual unsigned int GetColumnCount() const; - virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; - virtual bool DeleteColumn( wxDataViewColumn *column ); - virtual bool ClearColumns(); - virtual int GetColumnPosition( const wxDataViewColumn *column ) const; - - virtual wxDataViewColumn *GetSortingColumn() const; - - virtual int GetSelectedItemsCount() const; - virtual int GetSelections( wxDataViewItemArray & sel ) const; - virtual void SetSelections( const wxDataViewItemArray & sel ); - virtual void Select( const wxDataViewItem & item ); - virtual void Unselect( const wxDataViewItem & item ); - virtual bool IsSelected( const wxDataViewItem & item ) const; - - virtual void SelectAll(); - virtual void UnselectAll(); - - virtual void EnsureVisible( const wxDataViewItem & item, - const wxDataViewColumn *column = NULL ); - virtual void HitTest( const wxPoint & point, wxDataViewItem & item, - wxDataViewColumn* &column ) const; - virtual wxRect GetItemRect( const wxDataViewItem & item, - const wxDataViewColumn *column = NULL ) const; - - virtual bool SetRowHeight( int rowHeight ); - - virtual void Expand( const wxDataViewItem & item ); - virtual void Collapse( const wxDataViewItem & item ); - virtual bool IsExpanded( const wxDataViewItem & item ) const; - - virtual void SetFocus(); - - virtual bool SetFont(const wxFont & font); - -#if wxUSE_DRAG_AND_DROP - virtual bool EnableDragSource( const wxDataFormat &format ); - virtual bool EnableDropTarget( const wxDataFormat &format ); -#endif // wxUSE_DRAG_AND_DROP - - virtual wxBorder GetDefaultBorder() const; - - virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column); - - // These methods are specific to generic wxDataViewCtrl implementation and - // should not be used in portable code. - wxColour GetAlternateRowColour() const { return m_alternateRowColour; } - void SetAlternateRowColour(const wxColour& colour); - -protected: - virtual void EnsureVisible( int row, int column ); - - // Notice that row here may be invalid (i.e. >= GetRowCount()), this is not - // an error and this function simply returns an invalid item in this case. - virtual wxDataViewItem GetItemByRow( unsigned int row ) const; - virtual int GetRowByItem( const wxDataViewItem & item ) const; - - int GetSortingColumnIndex() const { return m_sortingColumnIdx; } - void SetSortingColumnIndex(int idx) { m_sortingColumnIdx = idx; } - -public: // utility functions not part of the API - - // returns the "best" width for the idx-th column - unsigned int GetBestColumnWidth(int idx) const; - - // called by header window after reorder - void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos ); - - // update the display after a change to an individual column - void OnColumnChange(unsigned int idx); - - // update after a change to the number of columns - void OnColumnsCountChanged(); - - wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; } - - // return the index of the given column in m_cols - int GetColumnIndex(const wxDataViewColumn *column) const; - - // Return the index of the column having the given model index. - int GetModelColumnIndex(unsigned int model_column) const; - - // return the column displayed at the given position in the control - wxDataViewColumn *GetColumnAt(unsigned int pos) const; - - virtual wxDataViewColumn *GetCurrentColumn() const; - - virtual void OnInternalIdle(); - -private: - virtual wxDataViewItem DoGetCurrentItem() const; - virtual void DoSetCurrentItem(const wxDataViewItem& item); - - void InvalidateColBestWidths(); - void InvalidateColBestWidth(int idx); - void UpdateColWidths(); - - wxDataViewColumnList m_cols; - // cached column best widths information, values are for - // respective columns from m_cols and the arrays have same size - struct CachedColWidthInfo - { - CachedColWidthInfo() : width(0), dirty(true) {} - int width; // cached width or 0 if not computed - bool dirty; // column was invalidated, header needs updating - }; - wxVector m_colsBestWidths; - // This indicates that at least one entry in m_colsBestWidths has 'dirty' - // flag set. It's cheaper to check one flag in OnInternalIdle() than to - // iterate over m_colsBestWidths to check if anything needs to be done. - bool m_colsDirty; - - wxDataViewModelNotifier *m_notifier; - wxDataViewMainWindow *m_clientArea; - wxDataViewHeaderWindow *m_headerArea; - - // user defined color to draw row lines, may be invalid - wxColour m_alternateRowColour; - - // the index of the column currently used for sorting or -1 - int m_sortingColumnIdx; - -private: - void OnSize( wxSizeEvent &event ); - virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); - - // we need to return a special WM_GETDLGCODE value to process just the - // arrows but let the other navigation characters through -#ifdef __WXMSW__ - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); -#endif // __WXMSW__ - - WX_FORWARD_TO_SCROLL_HELPER() - -private: - DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) - wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl); - DECLARE_EVENT_TABLE() -}; - - -#endif // __GENERICDATAVIEWCTRLH__ diff --git a/Source/3rd Party/wx/include/wx/generic/datectrl.h b/Source/3rd Party/wx/include/wx/generic/datectrl.h deleted file mode 100644 index 47e656634..000000000 --- a/Source/3rd Party/wx/include/wx/generic/datectrl.h +++ /dev/null @@ -1,96 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/datectrl.h -// Purpose: generic wxDatePickerCtrl implementation -// Author: Andreas Pflug -// Modified by: -// Created: 2005-01-19 -// Copyright: (c) 2005 Andreas Pflug -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_DATECTRL_H_ -#define _WX_GENERIC_DATECTRL_H_ - -#include "wx/compositewin.h" - -class WXDLLIMPEXP_FWD_CORE wxComboCtrl; - -class WXDLLIMPEXP_FWD_ADV wxCalendarCtrl; -class WXDLLIMPEXP_FWD_ADV wxCalendarComboPopup; - -class WXDLLIMPEXP_ADV wxDatePickerCtrlGeneric - : public wxCompositeWindow -{ -public: - // creating the control - wxDatePickerCtrlGeneric() { Init(); } - virtual ~wxDatePickerCtrlGeneric(); - wxDatePickerCtrlGeneric(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr) - { - Init(); - - (void)Create(parent, id, date, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr); - - // wxDatePickerCtrl methods - void SetValue(const wxDateTime& date); - wxDateTime GetValue() const; - - bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const; - void SetRange(const wxDateTime &dt1, const wxDateTime &dt2); - - bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, - const wxDateTime& upperdate = wxDefaultDateTime); - - // extra methods available only in this (generic) implementation - wxCalendarCtrl *GetCalendar() const; - - - // implementation only from now on - // ------------------------------- - - // overridden base class methods - virtual bool Destroy(); - -protected: - virtual wxSize DoGetBestSize() const; - -private: - void Init(); - - // return the list of the windows composing this one - virtual wxWindowList GetCompositeWindowParts() const; - - void OnText(wxCommandEvent &event); - void OnSize(wxSizeEvent& event); - void OnFocus(wxFocusEvent& event); - -#ifdef __WXOSX_COCOA__ - virtual void OSXGenerateEvent(const wxDateTime& WXUNUSED(dt)) { } -#endif - - wxComboCtrl* m_combo; - wxCalendarComboPopup* m_popup; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxDatePickerCtrlGeneric); -}; - -#endif // _WX_GENERIC_DATECTRL_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/dcpsg.h b/Source/3rd Party/wx/include/wx/generic/dcpsg.h deleted file mode 100644 index ea423475d..000000000 --- a/Source/3rd Party/wx/include/wx/generic/dcpsg.h +++ /dev/null @@ -1,159 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dcpsg.h -// Purpose: wxPostScriptDC class -// Author: Julian Smart and others -// Modified by: -// Copyright: (c) Julian Smart and Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DCPSG_H_ -#define _WX_DCPSG_H_ - -#include "wx/defs.h" - -#if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT - -#include "wx/dc.h" -#include "wx/dcprint.h" -#include "wx/dialog.h" -#include "wx/module.h" -#include "wx/cmndata.h" -#include "wx/strvararg.h" - -//----------------------------------------------------------------------------- -// wxPostScriptDC -//----------------------------------------------------------------------------- - - -class WXDLLIMPEXP_CORE wxPostScriptDC : public wxDC -{ -public: - wxPostScriptDC(); - - // Recommended constructor - wxPostScriptDC(const wxPrintData& printData); - -private: - DECLARE_DYNAMIC_CLASS(wxPostScriptDC) -}; - -class WXDLLIMPEXP_CORE wxPostScriptDCImpl : public wxDCImpl -{ -public: - wxPostScriptDCImpl( wxPrinterDC *owner ); - wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data ); - wxPostScriptDCImpl( wxPostScriptDC *owner ); - wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data ); - - void Init(); - - virtual ~wxPostScriptDCImpl(); - - virtual bool Ok() const { return IsOk(); } - virtual bool IsOk() const; - - bool CanDrawBitmap() const { return true; } - - void Clear(); - void SetFont( const wxFont& font ); - void SetPen( const wxPen& pen ); - void SetBrush( const wxBrush& brush ); - void SetLogicalFunction( wxRasterOperationMode function ); - void SetBackground( const wxBrush& brush ); - - void DestroyClippingRegion(); - - bool StartDoc(const wxString& message); - void EndDoc(); - void StartPage(); - void EndPage(); - - wxCoord GetCharHeight() const; - wxCoord GetCharWidth() const; - bool CanGetTextExtent() const { return true; } - - // Resolution in pixels per logical inch - wxSize GetPPI() const; - - virtual void ComputeScaleAndOrigin(); - - void SetBackgroundMode(int WXUNUSED(mode)) { } - void SetPalette(const wxPalette& WXUNUSED(palette)) { } - - void SetPrintData(const wxPrintData& data); - wxPrintData& GetPrintData() { return m_printData; } - - virtual int GetDepth() const { return 24; } - - void PsPrint( const wxString& psdata ); - - // Overrridden for wxPrinterDC Impl - - virtual int GetResolution() const; - virtual wxRect GetPaperRect() const; - - virtual void* GetHandle() const { return NULL; } - -protected: - bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, - wxFloodFillStyle style = wxFLOOD_SURFACE); - bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; - void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); - void DoCrossHair(wxCoord x, wxCoord y) ; - void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); - void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); - void DoDrawPoint(wxCoord x, wxCoord y); - void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); - void DoDrawPolygon(int n, const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20); - void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); -#if wxUSE_SPLINES - void DoDrawSpline(const wxPointList *points); -#endif - bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); - void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); - void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false); - void DoDrawText(const wxString& text, wxCoord x, wxCoord y); - void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); - void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip)) - { - wxFAIL_MSG( "not implemented" ); - } - void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const; - void DoGetSize(int* width, int* height) const; - void DoGetSizeMM(int *width, int *height) const; - - FILE* m_pstream; // PostScript output stream - unsigned char m_currentRed; - unsigned char m_currentGreen; - unsigned char m_currentBlue; - int m_pageNumber; - bool m_clipping; - double m_underlinePosition; - double m_underlineThickness; - wxPrintData m_printData; - double m_pageHeight; - -private: - DECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl) -}; - -#endif - // wxUSE_POSTSCRIPT && wxUSE_PRINTING_ARCHITECTURE - -#endif - // _WX_DCPSG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/dirctrlg.h b/Source/3rd Party/wx/include/wx/generic/dirctrlg.h index e14aeb7ca..b4cea43b5 100644 --- a/Source/3rd Party/wx/include/wx/generic/dirctrlg.h +++ b/Source/3rd Party/wx/include/wx/generic/dirctrlg.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dirctrlg.h +// Name: dirctrlg.h // Purpose: wxGenericDirCtrl class // Builds on wxDirCtrl class written by Robert Roebling for the // wxFile application, modified by Harm van der Heijden. @@ -7,6 +7,7 @@ // Author: Robert Roebling, Harm van der Heijden, Julian Smart et al // Modified by: // Created: 21/3/2000 +// RCS-ID: $Id: dirctrlg.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Robert Roebling, Harm van der Heijden, Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,6 +15,10 @@ #ifndef _WX_DIRCTRL_H_ #define _WX_DIRCTRL_H_ +#if wxUSE_DIRDLG || wxUSE_FILEDLG + #include "wx/imaglist.h" +#endif + #if wxUSE_DIRDLG #include "wx/treectrl.h" @@ -26,6 +31,7 @@ //----------------------------------------------------------------------------- class WXDLLIMPEXP_FWD_CORE wxTextCtrl; +class WXDLLIMPEXP_FWD_CORE wxImageList; class WXDLLIMPEXP_FWD_BASE wxHashTable; //----------------------------------------------------------------------------- @@ -43,16 +49,14 @@ enum // Use 3D borders on internal controls wxDIRCTRL_3D_INTERNAL = 0x0080, // Editable labels - wxDIRCTRL_EDIT_LABELS = 0x0100, - // Allow multiple selection - wxDIRCTRL_MULTIPLE = 0x0200 + wxDIRCTRL_EDIT_LABELS = 0x0100 }; //----------------------------------------------------------------------------- // wxDirItemData //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDirItemData : public wxTreeItemData +class WXDLLEXPORT wxDirItemData : public wxTreeItemData { public: wxDirItemData(const wxString& path, const wxString& name, bool isDir); @@ -74,7 +78,7 @@ public: class WXDLLIMPEXP_FWD_CORE wxDirFilterListCtrl; -class WXDLLIMPEXP_CORE wxGenericDirCtrl: public wxControl +class WXDLLEXPORT wxGenericDirCtrl: public wxControl { public: wxGenericDirCtrl(); @@ -82,7 +86,7 @@ public: const wxString &dir = wxDirDialogDefaultFolderStr, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDIRCTRL_3D_INTERNAL, + long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, const wxString& filter = wxEmptyString, int defaultFilter = 0, const wxString& name = wxTreeCtrlNameStr ) @@ -95,7 +99,7 @@ public: const wxString &dir = wxDirDialogDefaultFolderStr, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDIRCTRL_3D_INTERNAL, + long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, const wxString& filter = wxEmptyString, int defaultFilter = 0, const wxString& name = wxTreeCtrlNameStr ); @@ -108,8 +112,6 @@ public: void OnCollapseItem(wxTreeEvent &event ); void OnBeginEditItem(wxTreeEvent &event ); void OnEndEditItem(wxTreeEvent &event ); - void OnTreeSelChange(wxTreeEvent &event); - void OnItemActivated(wxTreeEvent &event); void OnSize(wxSizeEvent &event ); // Try to expand as much of the given path as possible. @@ -124,17 +126,12 @@ public: // Get dir or filename virtual wxString GetPath() const; - virtual void GetPaths(wxArrayString& paths) const; // Get selected filename path only (else empty string). // I.e. don't count a directory as a selection virtual wxString GetFilePath() const; - virtual void GetFilePaths(wxArrayString& paths) const; virtual void SetPath(const wxString& path); - virtual void SelectPath(const wxString& path, bool select = true); - virtual void SelectPaths(const wxArrayString& paths); - virtual void ShowHidden( bool show ); virtual bool GetShowHidden() { return m_showHidden; } @@ -149,19 +146,20 @@ public: virtual wxTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; } virtual wxDirFilterListCtrl* GetFilterListCtrl() const { return m_filterListCtrl; } - virtual void UnselectAll(); - // Helper virtual void SetupSections(); +#if WXWIN_COMPATIBILITY_2_4 + // Parse the filter into an array of filters and an array of descriptions + virtual int ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions); +#endif // WXWIN_COMPATIBILITY_2_4 + // Find the child that matches the first part of 'path'. // E.g. if a child path is "/usr" and 'path' is "/usr/include" // then the child for /usr is returned. // If the path string has been used (we're at the leaf), done is set to true virtual wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done); - wxString GetPath(wxTreeItemId itemId) const; - // Resize the components of the control virtual void DoResize(); @@ -171,9 +169,6 @@ public: // Collapse the entire tree virtual void CollapseTree(); - // overridden base class methods - virtual void SetFocus(); - protected: virtual void ExpandRoot(); virtual void ExpandDir(wxTreeItemId parentId); @@ -190,9 +185,6 @@ protected: bool ExtractWildcard(const wxString& filterStr, int n, wxString& filter, wxString& description); private: - void PopulateNode(wxTreeItemId node); - wxDirItemData* GetItemData(wxTreeItemId itemId); - bool m_showHidden; wxTreeItemId m_rootId; wxString m_defaultPath; // Starting path @@ -206,23 +198,14 @@ private: private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxGenericDirCtrl) - wxDECLARE_NO_COPY_CLASS(wxGenericDirCtrl); + DECLARE_NO_COPY_CLASS(wxGenericDirCtrl) }; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent ); - -#define wx__DECLARE_DIRCTRL_EVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_DIRCTRL_ ## evt, id, wxTreeEventHandler(fn)) - -#define EVT_DIRCTRL_SELECTIONCHANGED(id, fn) wx__DECLARE_DIRCTRL_EVT(SELECTIONCHANGED, id, fn) -#define EVT_DIRCTRL_FILEACTIVATED(id, fn) wx__DECLARE_DIRCTRL_EVT(FILEACTIVATED, id, fn) - //----------------------------------------------------------------------------- // wxDirFilterListCtrl //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDirFilterListCtrl: public wxChoice +class WXDLLEXPORT wxDirFilterListCtrl: public wxChoice { public: wxDirFilterListCtrl() { Init(); } @@ -255,7 +238,7 @@ protected: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxDirFilterListCtrl) - wxDECLARE_NO_COPY_CLASS(wxDirFilterListCtrl); + DECLARE_NO_COPY_CLASS(wxDirFilterListCtrl) }; #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXPM__) @@ -272,11 +255,9 @@ protected: // wxFileIconsTable - use wxTheFileIconsTable which is created as necessary //------------------------------------------------------------------------- -#if wxUSE_DIRDLG || wxUSE_FILEDLG || wxUSE_FILECTRL +#if wxUSE_DIRDLG || wxUSE_FILEDLG -class WXDLLIMPEXP_FWD_CORE wxImageList; - -class WXDLLIMPEXP_CORE wxFileIconsTable +class WXDLLEXPORT wxFileIconsTable { public: wxFileIconsTable(); @@ -306,13 +287,9 @@ protected: }; // The global fileicons table -extern WXDLLIMPEXP_DATA_CORE(wxFileIconsTable *) wxTheFileIconsTable; +extern WXDLLEXPORT_DATA(wxFileIconsTable *) wxTheFileIconsTable; -#endif // wxUSE_DIRDLG || wxUSE_FILEDLG || wxUSE_FILECTRL - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_DIRCTRL_SELECTIONCHANGED wxEVT_DIRCTRL_SELECTIONCHANGED -#define wxEVT_COMMAND_DIRCTRL_FILEACTIVATED wxEVT_DIRCTRL_FILEACTIVATED +#endif // wxUSE_DIRDLG || wxUSE_FILEDLG #endif // _WX_DIRCTRLG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/dirdlgg.h b/Source/3rd Party/wx/include/wx/generic/dirdlgg.h deleted file mode 100644 index cc8b5a874..000000000 --- a/Source/3rd Party/wx/include/wx/generic/dirdlgg.h +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dirdlgg.h -// Purpose: wxGenericDirCtrl class -// Builds on wxDirCtrl class written by Robert Roebling for the -// wxFile application, modified by Harm van der Heijden. -// Further modified for Windows. -// Author: Robert Roebling, Harm van der Heijden, Julian Smart et al -// Modified by: -// Created: 21/3/2000 -// Copyright: (c) Robert Roebling, Harm van der Heijden, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_DIRDLGG_H_ -#define _WX_DIRDLGG_H_ - -class WXDLLIMPEXP_FWD_CORE wxGenericDirCtrl; -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; -class WXDLLIMPEXP_FWD_CORE wxTreeEvent; - -// we may be included directly as well as from wx/dirdlg.h (FIXME) -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; - -#ifndef wxDD_DEFAULT_STYLE -#ifdef __WXWINCE__ - #define wxDD_DEFAULT_STYLE wxDEFAULT_DIALOG_STYLE -#else - #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) -#endif -#endif - -#include "wx/dialog.h" - -//----------------------------------------------------------------------------- -// wxGenericDirDialog -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericDirDialog : public wxDirDialogBase -{ -public: - wxGenericDirDialog() : wxDirDialogBase() { } - - wxGenericDirDialog(wxWindow* parent, - const wxString& title = wxDirSelectorPromptStr, - const wxString& defaultPath = wxEmptyString, - long style = wxDD_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize,//Size(450, 550), - const wxString& name = wxDirDialogNameStr); - - bool Create(wxWindow* parent, - const wxString& title = wxDirSelectorPromptStr, - const wxString& defaultPath = wxEmptyString, - long style = wxDD_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize,//Size(450, 550), - const wxString& name = wxDirDialogNameStr); - - //// Accessors - void SetPath(const wxString& path); - wxString GetPath() const; - - //// Overrides - virtual int ShowModal(); - virtual void EndModal(int retCode); - - // this one is specific to wxGenericDirDialog - wxTextCtrl* GetInputCtrl() const { return m_input; } - -protected: - //// Event handlers - void OnCloseWindow(wxCloseEvent& event); - void OnOK(wxCommandEvent& event); - void OnTreeSelected(wxTreeEvent &event); - void OnTreeKeyDown(wxTreeEvent &event); - void OnNew(wxCommandEvent& event); - void OnGoHome(wxCommandEvent& event); - void OnShowHidden(wxCommandEvent& event); - - wxGenericDirCtrl* m_dirCtrl; - wxTextCtrl* m_input; - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericDirDialog) -}; - -#endif // _WX_DIRDLGG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/dragimgg.h b/Source/3rd Party/wx/include/wx/generic/dragimgg.h index 5cab078a1..79f2785ba 100644 --- a/Source/3rd Party/wx/include/wx/generic/dragimgg.h +++ b/Source/3rd Party/wx/include/wx/generic/dragimgg.h @@ -5,6 +5,7 @@ // Author: Julian Smart // Modified by: // Created: 29/2/2000 +// RCS-ID: $Id: dragimgg.h 42397 2006-10-25 12:12:56Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -87,7 +88,7 @@ * wxGenericDragImage */ -class WXDLLIMPEXP_CORE wxGenericDragImage: public wxObject +class WXDLLEXPORT wxGenericDragImage: public wxObject { public: @@ -156,14 +157,13 @@ public: // Attributes //////////////////////////////////////////////////////////////////////////// -#ifdef wxHAS_NATIVE_OVERLAY - // backing store is not used when native overlays are - void SetBackingBitmap(wxBitmap* WXUNUSED(bitmap)) { } -#else // For efficiency, tell wxGenericDragImage to use a bitmap that's already // created (e.g. from last drag) - void SetBackingBitmap(wxBitmap* bitmap) { m_pBackingBitmap = bitmap; } -#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY + void SetBackingBitmap(wxBitmap* bitmap) { +#ifndef wxHAS_NATIVE_OVERLAY + m_pBackingBitmap = bitmap; +#endif + } // Operations //////////////////////////////////////////////////////////////////////////// @@ -192,7 +192,7 @@ public: // Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. - bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = false, wxRect* rect = NULL); + bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = false, wxRect* rect = (wxRect*) NULL); // Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. This is full screen only. fullScreenRect gives the @@ -264,7 +264,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxGenericDragImage) - wxDECLARE_NO_COPY_CLASS(wxGenericDragImage); + DECLARE_NO_COPY_CLASS(wxGenericDragImage) }; #endif diff --git a/Source/3rd Party/wx/include/wx/generic/dvrenderer.h b/Source/3rd Party/wx/include/wx/generic/dvrenderer.h deleted file mode 100644 index 75889a810..000000000 --- a/Source/3rd Party/wx/include/wx/generic/dvrenderer.h +++ /dev/null @@ -1,67 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dvrenderer.h -// Purpose: wxDataViewRenderer for generic wxDataViewCtrl implementation -// Author: Robert Roebling, Vadim Zeitlin -// Created: 2009-11-07 (extracted from wx/generic/dataview.h) -// Copyright: (c) 2006 Robert Roebling -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_DVRENDERER_H_ -#define _WX_GENERIC_DVRENDERER_H_ - -// ---------------------------------------------------------------------------- -// wxDataViewRenderer -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewCustomRendererBase -{ -public: - wxDataViewRenderer( const wxString &varianttype, - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - virtual ~wxDataViewRenderer(); - - virtual wxDC *GetDC(); - - virtual void SetAlignment( int align ); - virtual int GetAlignment() const; - - virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) - { m_ellipsizeMode = mode; } - virtual wxEllipsizeMode GetEllipsizeMode() const - { return m_ellipsizeMode; } - - virtual void SetMode( wxDataViewCellMode mode ) - { m_mode = mode; } - virtual wxDataViewCellMode GetMode() const - { return m_mode; } - - // implementation - - // This callback is used by generic implementation of wxDVC itself. It's - // different from the corresponding ActivateCell() method which should only - // be overridable for the custom renderers while the generic implementation - // uses this one for all of them, including the standard ones. - - virtual bool WXActivateCell(const wxRect& WXUNUSED(cell), - wxDataViewModel *WXUNUSED(model), - const wxDataViewItem & WXUNUSED(item), - unsigned int WXUNUSED(col), - const wxMouseEvent* WXUNUSED(mouseEvent)) - { return false; } - -private: - int m_align; - wxDataViewCellMode m_mode; - - wxEllipsizeMode m_ellipsizeMode; - - wxDC *m_dc; - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) -}; - -#endif // _WX_GENERIC_DVRENDERER_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/dvrenderers.h b/Source/3rd Party/wx/include/wx/generic/dvrenderers.h deleted file mode 100644 index 6f80c773a..000000000 --- a/Source/3rd Party/wx/include/wx/generic/dvrenderers.h +++ /dev/null @@ -1,183 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/dvrenderers.h -// Purpose: All generic wxDataViewCtrl renderer classes -// Author: Robert Roebling, Vadim Zeitlin -// Created: 2009-11-07 (extracted from wx/generic/dataview.h) -// Copyright: (c) 2006 Robert Roebling -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_DVRENDERERS_H_ -#define _WX_GENERIC_DVRENDERERS_H_ - -// --------------------------------------------------------- -// wxDataViewCustomRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer -{ -public: - wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - - // see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h - - virtual bool WXActivateCell(const wxRect& cell, - wxDataViewModel *model, - const wxDataViewItem& item, - unsigned int col, - const wxMouseEvent *mouseEvent) - { - return ActivateCell(cell, model, item, col, mouseEvent); - } - -private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) -}; - - -// --------------------------------------------------------- -// wxDataViewTextRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer -{ -public: - wxDataViewTextRenderer( const wxString &varianttype = wxT("string"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant &value ) const; - - virtual bool Render(wxRect cell, wxDC *dc, int state); - virtual wxSize GetSize() const; - - // in-place editing - virtual bool HasEditorCtrl() const; - virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, - const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ); - -protected: - wxString m_text; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) -}; - -// --------------------------------------------------------- -// wxDataViewBitmapRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer -{ -public: - wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant &value ) const; - - bool Render( wxRect cell, wxDC *dc, int state ); - wxSize GetSize() const; - -private: - wxIcon m_icon; - wxBitmap m_bitmap; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) -}; - -// --------------------------------------------------------- -// wxDataViewToggleRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer -{ -public: - wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant &value ) const; - - bool Render( wxRect cell, wxDC *dc, int state ); - wxSize GetSize() const; - - // Implementation only, don't use nor override - virtual bool WXActivateCell(const wxRect& cell, - wxDataViewModel *model, - const wxDataViewItem& item, - unsigned int col, - const wxMouseEvent *mouseEvent); -private: - bool m_toggle; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) -}; - -// --------------------------------------------------------- -// wxDataViewProgressRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer -{ -public: - wxDataViewProgressRenderer( const wxString &label = wxEmptyString, - const wxString &varianttype = wxT("long"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant& value ) const; - - virtual bool Render(wxRect cell, wxDC *dc, int state); - virtual wxSize GetSize() const; - -private: - wxString m_label; - int m_value; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) -}; - -// --------------------------------------------------------- -// wxDataViewIconTextRenderer -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer -{ -public: - wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant &value ) const; - - virtual bool Render(wxRect cell, wxDC *dc, int state); - virtual wxSize GetSize() const; - - virtual bool HasEditorCtrl() const { return true; } - virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, - const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ); - -private: - wxDataViewIconText m_value; - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) -}; - -#endif // _WX_GENERIC_DVRENDERERS_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/fdrepdlg.h b/Source/3rd Party/wx/include/wx/generic/fdrepdlg.h deleted file mode 100644 index d1ad8d1b8..000000000 --- a/Source/3rd Party/wx/include/wx/generic/fdrepdlg.h +++ /dev/null @@ -1,70 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/fdrepdlg.h -// Purpose: wxGenericFindReplaceDialog class -// Author: Markus Greither -// Modified by: -// Created: 25/05/2001 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_FDREPDLG_H_ -#define _WX_GENERIC_FDREPDLG_H_ - -class WXDLLIMPEXP_FWD_CORE wxCheckBox; -class WXDLLIMPEXP_FWD_CORE wxRadioBox; -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; - -// ---------------------------------------------------------------------------- -// wxGenericFindReplaceDialog: dialog for searching / replacing text -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericFindReplaceDialog : public wxFindReplaceDialogBase -{ -public: - wxGenericFindReplaceDialog() { Init(); } - - wxGenericFindReplaceDialog(wxWindow *parent, - wxFindReplaceData *data, - const wxString& title, - int style = 0) - { - Init(); - - (void)Create(parent, data, title, style); - } - - bool Create(wxWindow *parent, - wxFindReplaceData *data, - const wxString& title, - int style = 0); - -protected: - void Init(); - - void SendEvent(const wxEventType& evtType); - - void OnFind(wxCommandEvent& event); - void OnReplace(wxCommandEvent& event); - void OnReplaceAll(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - - void OnUpdateFindUI(wxUpdateUIEvent& event); - - void OnCloseWindow(wxCloseEvent& event); - - wxCheckBox *m_chkCase, - *m_chkWord; - - wxRadioBox *m_radioDir; - - wxTextCtrl *m_textFind, - *m_textRepl; - -private: - DECLARE_DYNAMIC_CLASS(wxGenericFindReplaceDialog) - - DECLARE_EVENT_TABLE() -}; - -#endif // _WX_GENERIC_FDREPDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/filectrlg.h b/Source/3rd Party/wx/include/wx/generic/filectrlg.h deleted file mode 100644 index ba26118d7..000000000 --- a/Source/3rd Party/wx/include/wx/generic/filectrlg.h +++ /dev/null @@ -1,303 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/filectrlg.h -// Purpose: wxGenericFileCtrl Header -// Author: Diaa M. Sami -// Modified by: -// Created: Jul-07-2007 -// Copyright: (c) Diaa M. Sami -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_FILECTRL_H_ -#define _WX_GENERIC_FILECTRL_H_ - -#if wxUSE_FILECTRL - -#include "wx/containr.h" -#include "wx/listctrl.h" -#include "wx/filectrl.h" -#include "wx/filename.h" - -class WXDLLIMPEXP_FWD_CORE wxCheckBox; -class WXDLLIMPEXP_FWD_CORE wxChoice; -class WXDLLIMPEXP_FWD_CORE wxStaticText; -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; - -extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[]; - -//----------------------------------------------------------------------------- -// wxFileData - a class to hold the file info for the wxFileListCtrl -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxFileData -{ -public: - enum fileType - { - is_file = 0x0000, - is_dir = 0x0001, - is_link = 0x0002, - is_exe = 0x0004, - is_drive = 0x0008 - }; - - wxFileData() { Init(); } - // Full copy constructor - wxFileData( const wxFileData& fileData ) { Copy(fileData); } - // Create a filedata from this information - wxFileData( const wxString &filePath, const wxString &fileName, - fileType type, int image_id ); - - // make a full copy of the other wxFileData - void Copy( const wxFileData &other ); - - // (re)read the extra data about the file from the system - void ReadData(); - - // get the name of the file, dir, drive - wxString GetFileName() const { return m_fileName; } - // get the full path + name of the file, dir, path - wxString GetFilePath() const { return m_filePath; } - // Set the path + name and name of the item - void SetNewName( const wxString &filePath, const wxString &fileName ); - - // Get the size of the file in bytes - wxFileOffset GetSize() const { return m_size; } - // Get the type of file, either file extension or , , - wxString GetFileType() const; - // get the last modification time - wxDateTime GetDateTime() const { return m_dateTime; } - // Get the time as a formatted string - wxString GetModificationTime() const; - // in UNIX get rwx for file, in MSW get attributes ARHS - wxString GetPermissions() const { return m_permissions; } - // Get the id of the image used in a wxImageList - int GetImageId() const { return m_image; } - - bool IsFile() const { return !IsDir() && !IsLink() && !IsDrive(); } - bool IsDir() const { return (m_type & is_dir ) != 0; } - bool IsLink() const { return (m_type & is_link ) != 0; } - bool IsExe() const { return (m_type & is_exe ) != 0; } - bool IsDrive() const { return (m_type & is_drive) != 0; } - - // Get/Set the type of file, file/dir/drive/link - int GetType() const { return m_type; } - - // the wxFileListCtrl fields in report view - enum fileListFieldType - { - FileList_Name, - FileList_Size, - FileList_Type, - FileList_Time, -#if defined(__UNIX__) || defined(__WIN32__) - FileList_Perm, -#endif // defined(__UNIX__) || defined(__WIN32__) - FileList_Max - }; - - // Get the entry for report view of wxFileListCtrl - wxString GetEntry( fileListFieldType num ) const; - - // Get a string representation of the file info - wxString GetHint() const; - // initialize a wxListItem attributes - void MakeItem( wxListItem &item ); - - // operators - wxFileData& operator = (const wxFileData& fd) { Copy(fd); return *this; } - -protected: - wxString m_fileName; - wxString m_filePath; - wxFileOffset m_size; - wxDateTime m_dateTime; - wxString m_permissions; - int m_type; - int m_image; - -private: - void Init(); -}; - -//----------------------------------------------------------------------------- -// wxFileListCtrl -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxFileListCtrl : public wxListCtrl -{ -public: - wxFileListCtrl(); - wxFileListCtrl( wxWindow *win, - wxWindowID id, - const wxString &wild, - bool showHidden, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxLC_LIST, - const wxValidator &validator = wxDefaultValidator, - const wxString &name = wxT("filelist") ); - virtual ~wxFileListCtrl(); - - virtual void ChangeToListMode(); - virtual void ChangeToReportMode(); - virtual void ChangeToSmallIconMode(); - virtual void ShowHidden( bool show = true ); - bool GetShowHidden() const { return m_showHidden; } - - virtual long Add( wxFileData *fd, wxListItem &item ); - virtual void UpdateItem(const wxListItem &item); - virtual void UpdateFiles(); - virtual void MakeDir(); - virtual void GoToParentDir(); - virtual void GoToHomeDir(); - virtual void GoToDir( const wxString &dir ); - virtual void SetWild( const wxString &wild ); - wxString GetWild() const { return m_wild; } - wxString GetDir() const { return m_dirName; } - - void OnListDeleteItem( wxListEvent &event ); - void OnListDeleteAllItems( wxListEvent &event ); - void OnListEndLabelEdit( wxListEvent &event ); - void OnListColClick( wxListEvent &event ); - - virtual void SortItems(wxFileData::fileListFieldType field, bool forward); - bool GetSortDirection() const { return m_sort_forward; } - wxFileData::fileListFieldType GetSortField() const { return m_sort_field; } - -protected: - void FreeItemData(wxListItem& item); - void FreeAllItemsData(); - - wxString m_dirName; - bool m_showHidden; - wxString m_wild; - - bool m_sort_forward; - wxFileData::fileListFieldType m_sort_field; - -private: - DECLARE_DYNAMIC_CLASS(wxFileListCtrl) - DECLARE_EVENT_TABLE() -}; - -class WXDLLIMPEXP_CORE wxGenericFileCtrl : public wxNavigationEnabled, - public wxFileCtrlBase -{ -public: - wxGenericFileCtrl() - { - m_ignoreChanges = false; - } - - wxGenericFileCtrl ( wxWindow *parent, - wxWindowID id, - const wxString& defaultDirectory = wxEmptyString, - const wxString& defaultFilename = wxEmptyString, - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = wxFC_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const wxString& name = wxFileCtrlNameStr ) - { - m_ignoreChanges = false; - Create(parent, id, defaultDirectory, defaultFilename, wildCard, - style, pos, size, name ); - } - - virtual ~wxGenericFileCtrl() {} - - bool Create( wxWindow *parent, - wxWindowID id, - const wxString& defaultDirectory = wxEmptyString, - const wxString& defaultFileName = wxEmptyString, - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = wxFC_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const wxString& name = wxFileCtrlNameStr ); - - virtual void SetWildcard( const wxString& wildCard ); - virtual void SetFilterIndex( int filterindex ); - virtual bool SetDirectory( const wxString& dir ); - - // Selects a certain file. - // In case the filename specified isn't found/couldn't be shown with - // currently selected filter, false is returned and nothing happens - virtual bool SetFilename( const wxString& name ); - - // Changes to a certain directory and selects a certain file. - // In case the filename specified isn't found/couldn't be shown with - // currently selected filter, false is returned and if directory exists - // it's chdir'ed to - virtual bool SetPath( const wxString& path ); - - virtual wxString GetFilename() const; - virtual wxString GetDirectory() const; - virtual wxString GetWildcard() const { return this->m_wildCard; } - virtual wxString GetPath() const; - virtual void GetPaths( wxArrayString& paths ) const; - virtual void GetFilenames( wxArrayString& files ) const; - virtual int GetFilterIndex() const { return m_filterIndex; } - - virtual bool HasMultipleFileSelection() const - { return HasFlag(wxFC_MULTIPLE); } - virtual void ShowHidden(bool show) { m_list->ShowHidden( show ); } - - void GoToParentDir(); - void GoToHomeDir(); - - // get the directory currently shown in the control: this can be different - // from GetDirectory() if the user entered a full path (with a path other - // than the one currently shown in the control) in the text control - // manually - wxString GetShownDirectory() const { return m_list->GetDir(); } - - wxFileListCtrl *GetFileList() { return m_list; } - - void ChangeToReportMode() { m_list->ChangeToReportMode(); } - void ChangeToListMode() { m_list->ChangeToListMode(); } - - -private: - void OnChoiceFilter( wxCommandEvent &event ); - void OnCheck( wxCommandEvent &event ); - void OnActivated( wxListEvent &event ); - void OnTextEnter( wxCommandEvent &WXUNUSED( event ) ); - void OnTextChange( wxCommandEvent &WXUNUSED( event ) ); - void OnSelected( wxListEvent &event ); - void HandleAction( const wxString &fn ); - - void DoSetFilterIndex( int filterindex ); - void UpdateControls(); - - // the first of these methods can only be used for the controls with single - // selection (i.e. without wxFC_MULTIPLE style), the second one in any case - wxFileName DoGetFileName() const; - void DoGetFilenames( wxArrayString& filenames, bool fullPath ) const; - - int m_style; - - wxString m_filterExtension; - wxChoice *m_choice; - wxTextCtrl *m_text; - wxFileListCtrl *m_list; - wxCheckBox *m_check; - wxStaticText *m_static; - - wxString m_dir; - wxString m_fileName; - wxString m_wildCard; // wild card in one string as we got it - - int m_filterIndex; - bool m_inSelected; - bool m_ignoreChanges; - bool m_noSelChgEvent; // suppress selection changed events. - - DECLARE_DYNAMIC_CLASS( wxGenericFileCtrl ) - DECLARE_EVENT_TABLE() -}; - -#endif // wxUSE_FILECTRL - -#endif // _WX_GENERIC_FILECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/filedlgg.h b/Source/3rd Party/wx/include/wx/generic/filedlgg.h deleted file mode 100644 index 7d14e523f..000000000 --- a/Source/3rd Party/wx/include/wx/generic/filedlgg.h +++ /dev/null @@ -1,160 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/filedlgg.h -// Purpose: wxGenericFileDialog -// Author: Robert Roebling -// Modified by: -// Created: 8/17/99 -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FILEDLGG_H_ -#define _WX_FILEDLGG_H_ - -#include "wx/listctrl.h" -#include "wx/datetime.h" -#include "wx/filefn.h" -#include "wx/artprov.h" -#include "wx/filedlg.h" -#include "wx/generic/filectrlg.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxBitmapButton; -class WXDLLIMPEXP_FWD_CORE wxGenericFileCtrl; -class WXDLLIMPEXP_FWD_CORE wxGenericFileDialog; -class WXDLLIMPEXP_FWD_CORE wxFileCtrlEvent; - -//------------------------------------------------------------------------- -// wxGenericFileDialog -//------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericFileDialog: public wxFileDialogBase -{ -public: - wxGenericFileDialog() : wxFileDialogBase() { Init(); } - - wxGenericFileDialog(wxWindow *parent, - const wxString& message = wxFileSelectorPromptStr, - const wxString& defaultDir = wxEmptyString, - const wxString& defaultFile = wxEmptyString, - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = wxFD_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize, - const wxString& name = wxFileDialogNameStr, - bool bypassGenericImpl = false ); - - bool Create( wxWindow *parent, - const wxString& message = wxFileSelectorPromptStr, - const wxString& defaultDir = wxEmptyString, - const wxString& defaultFile = wxEmptyString, - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = wxFD_DEFAULT_STYLE, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize, - const wxString& name = wxFileDialogNameStr, - bool bypassGenericImpl = false ); - - virtual ~wxGenericFileDialog(); - - virtual void SetDirectory(const wxString& dir) - { m_filectrl->SetDirectory(dir); } - virtual void SetFilename(const wxString& name) - { m_filectrl->SetFilename(name); } - virtual void SetMessage(const wxString& message) { SetTitle(message); } - virtual void SetPath(const wxString& path) - { m_filectrl->SetPath(path); } - virtual void SetFilterIndex(int filterIndex) - { m_filectrl->SetFilterIndex(filterIndex); } - virtual void SetWildcard(const wxString& wildCard) - { m_filectrl->SetWildcard(wildCard); } - - virtual wxString GetPath() const - { return m_filectrl->GetPath(); } - virtual void GetPaths(wxArrayString& paths) const - { m_filectrl->GetPaths(paths); } - virtual wxString GetDirectory() const - { return m_filectrl->GetDirectory(); } - virtual wxString GetFilename() const - { return m_filectrl->GetFilename(); } - virtual void GetFilenames(wxArrayString& files) const - { m_filectrl->GetFilenames(files); } - virtual wxString GetWildcard() const - { return m_filectrl->GetWildcard(); } - virtual int GetFilterIndex() const - { return m_filectrl->GetFilterIndex(); } - virtual bool SupportsExtraControl() const { return true; } - - // implementation only from now on - // ------------------------------- - - virtual int ShowModal(); - virtual bool Show( bool show = true ); - - void OnList( wxCommandEvent &event ); - void OnReport( wxCommandEvent &event ); - void OnUp( wxCommandEvent &event ); - void OnHome( wxCommandEvent &event ); - void OnOk( wxCommandEvent &event ); - void OnNew( wxCommandEvent &event ); - void OnFileActivated( wxFileCtrlEvent &event); - -private: - // if true, don't use this implementation at all - bool m_bypassGenericImpl; - -protected: - // update the state of m_upDirButton and m_newDirButton depending on the - // currently selected directory - void OnUpdateButtonsUI(wxUpdateUIEvent& event); - - wxString m_filterExtension; - wxGenericFileCtrl *m_filectrl; - wxBitmapButton *m_upDirButton; - wxBitmapButton *m_newDirButton; - -private: - void Init(); - wxBitmapButton* AddBitmapButton( wxWindowID winId, const wxArtID& artId, - const wxString& tip, wxSizer *sizer ); - - DECLARE_DYNAMIC_CLASS(wxGenericFileDialog) - DECLARE_EVENT_TABLE() - - // these variables are preserved between wxGenericFileDialog calls - static long ms_lastViewStyle; // list or report? - static bool ms_lastShowHidden; // did we show hidden files? -}; - -#ifdef wxHAS_GENERIC_FILEDIALOG - -class WXDLLIMPEXP_CORE wxFileDialog: public wxGenericFileDialog -{ -public: - wxFileDialog() {} - - wxFileDialog(wxWindow *parent, - const wxString& message = wxFileSelectorPromptStr, - const wxString& defaultDir = wxEmptyString, - const wxString& defaultFile = wxEmptyString, - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = 0, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize) - :wxGenericFileDialog(parent, message, - defaultDir, defaultFile, wildCard, - style, - pos, size) - { - } - -private: - DECLARE_DYNAMIC_CLASS(wxFileDialog) -}; - -#endif // wxHAS_GENERIC_FILEDIALOG - -#endif // _WX_FILEDLGG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/filepickerg.h b/Source/3rd Party/wx/include/wx/generic/filepickerg.h index a10de927c..769d20b4a 100644 --- a/Source/3rd Party/wx/include/wx/generic/filepickerg.h +++ b/Source/3rd Party/wx/include/wx/generic/filepickerg.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Francesco Montorsi +// RCS-ID: $Id: filepickerg.h 40100 2006-07-15 15:13:04Z VS $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -16,8 +17,8 @@ #include "wx/dirdlg.h" -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRPICKER_CHANGED, wxFileDirPickerEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILEPICKER_CHANGED, wxFileDirPickerEvent ); +extern WXDLLEXPORT_DATA(const wxEventType) wxEVT_COMMAND_DIRPICKER_CHANGED; +extern WXDLLEXPORT_DATA(const wxEventType) wxEVT_COMMAND_FILEPICKER_CHANGED; //----------------------------------------------------------------------------- @@ -28,7 +29,7 @@ class WXDLLIMPEXP_CORE wxGenericFileDirButton : public wxButton, public wxFileDirPickerWidgetBase { public: - wxGenericFileDirButton() { Init(); } + wxGenericFileDirButton() { } wxGenericFileDirButton(wxWindow *parent, wxWindowID id, const wxString& label = wxFilePickerWidgetLabel, @@ -41,14 +42,15 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxFilePickerWidgetNameStr) { - Init(); Create(parent, id, label, path, message, wildcard, pos, size, style, validator, name); } + virtual ~wxGenericFileDirButton() {} + virtual wxControl *AsControl() { return this; } -public: // overridable +public: // overrideable virtual wxDialog *CreateDialog() = 0; @@ -57,8 +59,6 @@ public: // overridable virtual wxEventType GetEventType() const = 0; - virtual void SetInitialDirectory(const wxString& dir); - public: bool Create(wxWindow *parent, wxWindowID id, @@ -77,18 +77,6 @@ public: protected: wxString m_message, m_wildcard; - - // we just store the style passed to the ctor here instead of passing it to - // wxButton as some of our bits can conflict with wxButton styles and it - // just doesn't make sense to use picker styles for wxButton anyhow - long m_pickerStyle; - - // Initial directory set by SetInitialDirectory() call or empty. - wxString m_initialDir; - -private: - // common part of all ctors - void Init() { m_pickerStyle = -1; } }; @@ -118,36 +106,39 @@ public: pos, size, style, validator, name); } -public: // overridable +public: // overrideable virtual long GetDialogStyle() const { - // the derived class must initialize it if it doesn't use the - // non-default wxGenericFileDirButton ctor - wxASSERT_MSG( m_pickerStyle != -1, - "forgot to initialize m_pickerStyle?" ); - - long filedlgstyle = 0; - if ( m_pickerStyle & wxFLP_OPEN ) + if (this->HasFlag(wxFLP_OPEN)) filedlgstyle |= wxFD_OPEN; - if ( m_pickerStyle & wxFLP_SAVE ) + if (this->HasFlag(wxFLP_SAVE)) filedlgstyle |= wxFD_SAVE; - if ( m_pickerStyle & wxFLP_OVERWRITE_PROMPT ) + if (this->HasFlag(wxFLP_OVERWRITE_PROMPT)) filedlgstyle |= wxFD_OVERWRITE_PROMPT; - if ( m_pickerStyle & wxFLP_FILE_MUST_EXIST ) + if (this->HasFlag(wxFLP_FILE_MUST_EXIST)) filedlgstyle |= wxFD_FILE_MUST_EXIST; - if ( m_pickerStyle & wxFLP_CHANGE_DIR ) + if (this->HasFlag(wxFLP_CHANGE_DIR)) filedlgstyle |= wxFD_CHANGE_DIR; return filedlgstyle; } - virtual wxDialog *CreateDialog(); + virtual wxDialog *CreateDialog() + { + wxFileDialog *p = new wxFileDialog(GetDialogParent(), m_message, + wxEmptyString, wxEmptyString, + m_wildcard, GetDialogStyle()); + + // this sets both the default folder and the default file of the dialog + p->SetPath(m_path); + return p; + } wxEventType GetEventType() const - { return wxEVT_FILEPICKER_CHANGED; } + { return wxEVT_COMMAND_FILEPICKER_CHANGED; } protected: void UpdateDialogPath(wxDialog *p) @@ -185,24 +176,28 @@ public: pos, size, style, validator, name); } -public: // overridable +public: // overrideable virtual long GetDialogStyle() const { long dirdlgstyle = wxDD_DEFAULT_STYLE; - if ( m_pickerStyle & wxDIRP_DIR_MUST_EXIST ) + if (this->HasFlag(wxDIRP_DIR_MUST_EXIST)) dirdlgstyle |= wxDD_DIR_MUST_EXIST; - if ( m_pickerStyle & wxDIRP_CHANGE_DIR ) + if (this->HasFlag(wxDIRP_CHANGE_DIR)) dirdlgstyle |= wxDD_CHANGE_DIR; return dirdlgstyle; } - virtual wxDialog *CreateDialog(); + virtual wxDialog *CreateDialog() + { + return new wxDirDialog(GetDialogParent(), m_message, m_path, + GetDialogStyle()); + } wxEventType GetEventType() const - { return wxEVT_DIRPICKER_CHANGED; } + { return wxEVT_COMMAND_DIRPICKER_CHANGED; } protected: void UpdateDialogPath(wxDialog *p) @@ -214,8 +209,5 @@ private: DECLARE_DYNAMIC_CLASS(wxGenericDirButton) }; -// old wxEVT_COMMAND_* constants -//#define wxEVT_COMMAND_DIRPICKER_CHANGED wxEVT_DIRPICKER_CHANGED -//#define wxEVT_COMMAND_FILEPICKER_CHANGED wxEVT_FILEPICKER_CHANGED #endif // _WX_FILEDIRPICKER_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/fontdlgg.h b/Source/3rd Party/wx/include/wx/generic/fontdlgg.h deleted file mode 100644 index a16fa6e2e..000000000 --- a/Source/3rd Party/wx/include/wx/generic/fontdlgg.h +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/fontdlgg.h -// Purpose: wxGenericFontDialog -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_FONTDLGG_H -#define _WX_GENERIC_FONTDLGG_H - -#include "wx/gdicmn.h" -#include "wx/font.h" - -#ifdef __WXWINCE__ -#define USE_SPINCTRL_FOR_POINT_SIZE 1 -class WXDLLIMPEXP_FWD_CORE wxSpinEvent; -#else -#define USE_SPINCTRL_FOR_POINT_SIZE 0 -#endif - -/* - * FONT DIALOG - */ - -class WXDLLIMPEXP_FWD_CORE wxChoice; -class WXDLLIMPEXP_FWD_CORE wxText; -class WXDLLIMPEXP_FWD_CORE wxCheckBox; -class WXDLLIMPEXP_FWD_CORE wxFontPreviewer; - -enum -{ - wxID_FONT_UNDERLINE = 3000, - wxID_FONT_STYLE, - wxID_FONT_WEIGHT, - wxID_FONT_FAMILY, - wxID_FONT_COLOUR, - wxID_FONT_SIZE -}; - -class WXDLLIMPEXP_CORE wxGenericFontDialog : public wxFontDialogBase -{ -public: - wxGenericFontDialog() { Init(); } - wxGenericFontDialog(wxWindow *parent) - : wxFontDialogBase(parent) { Init(); } - wxGenericFontDialog(wxWindow *parent, const wxFontData& data) - : wxFontDialogBase(parent, data) { Init(); } - virtual ~wxGenericFontDialog(); - - virtual int ShowModal(); - -#if WXWIN_COMPATIBILITY_2_6 - // deprecated, for backwards compatibility only - wxDEPRECATED( wxGenericFontDialog(wxWindow *parent, const wxFontData *data) ); -#endif // WXWIN_COMPATIBILITY_2_6 - - // Internal functions - void OnCloseWindow(wxCloseEvent& event); - - virtual void CreateWidgets(); - virtual void InitializeFont(); - - void OnChangeFont(wxCommandEvent& event); - -#if USE_SPINCTRL_FOR_POINT_SIZE - void OnChangeSize(wxSpinEvent& event); -#endif - -protected: - - virtual bool DoCreate(wxWindow *parent); - -private: - - // common part of all ctors - void Init(); - - void DoChangeFont(); - - wxFont m_dialogFont; - - wxChoice *m_familyChoice; - wxChoice *m_styleChoice; - wxChoice *m_weightChoice; - wxChoice *m_colourChoice; - wxCheckBox *m_underLineCheckBox; - -#if !USE_SPINCTRL_FOR_POINT_SIZE - wxChoice *m_pointSizeChoice; -#endif - - wxFontPreviewer *m_previewer; - bool m_useEvents; - - // static bool fontDialogCancelled; - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericFontDialog) -}; - -#if WXWIN_COMPATIBILITY_2_6 - // deprecated, for backwards compatibility only -inline wxGenericFontDialog::wxGenericFontDialog(wxWindow *parent, const wxFontData *data) - :wxFontDialogBase(parent) { Init(); InitFontData(data); Create(parent); } -#endif // WXWIN_COMPATIBILITY_2_6 - -#endif // _WX_GENERIC_FONTDLGG_H diff --git a/Source/3rd Party/wx/include/wx/generic/fontpickerg.h b/Source/3rd Party/wx/include/wx/generic/fontpickerg.h index 2490b7159..cfa612aa9 100644 --- a/Source/3rd Party/wx/include/wx/generic/fontpickerg.h +++ b/Source/3rd Party/wx/include/wx/generic/fontpickerg.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Francesco Montorsi +// RCS-ID: $Id: fontpickerg.h 42999 2006-11-03 21:54:13Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -12,12 +13,15 @@ #define _WX_FONTPICKER_H_ #include "wx/button.h" -#include "wx/fontdata.h" +#include "wx/cmndata.h" //----------------------------------------------------------------------------- -// wxGenericFontButton: a button which brings up a wxFontDialog +// wxGenericFontButton: a button which brings up a wxColourDialog //----------------------------------------------------------------------------- +#define wxFONTBTN_DEFAULT_STYLE \ + (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL) + class WXDLLIMPEXP_CORE wxGenericFontButton : public wxButton, public wxFontPickerWidgetBase { @@ -43,8 +47,8 @@ public: // API extensions specific for wxGenericFontButton // user can override this to init font data in a different way virtual void InitFontData(); - // returns the font data shown in wxFontDialog - wxFontData *GetFontData() { return &m_data; } + // returns the font data shown in wxColourDialog + wxFontData *GetFontData() { return &ms_data; } public: @@ -65,7 +69,10 @@ protected: void UpdateFont(); - wxFontData m_data; + // the colour data shown in wxColourPickerCtrlGeneric + // controls. This member is static so that all colour pickers + // in the program share the same set of custom colours. + static wxFontData ms_data; private: DECLARE_DYNAMIC_CLASS(wxGenericFontButton) diff --git a/Source/3rd Party/wx/include/wx/generic/fswatcher.h b/Source/3rd Party/wx/include/wx/generic/fswatcher.h deleted file mode 100644 index efd7631b4..000000000 --- a/Source/3rd Party/wx/include/wx/generic/fswatcher.h +++ /dev/null @@ -1,25 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/fswatcher.h -// Purpose: wxPollingFileSystemWatcher -// Author: Bartosz Bekier -// Created: 2009-05-26 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FSWATCHER_GENERIC_H_ -#define _WX_FSWATCHER_GENERIC_H_ - -#include "wx/defs.h" - -#if wxUSE_FSWATCHER - -class WXDLLIMPEXP_BASE wxPollingFileSystemWatcher : public wxFileSystemWatcherBase -{ -public: - -}; - -#endif // wxUSE_FSWATCHER - -#endif /* _WX_FSWATCHER_GENERIC_H_ */ diff --git a/Source/3rd Party/wx/include/wx/generic/grid.h b/Source/3rd Party/wx/include/wx/generic/grid.h deleted file mode 100644 index c58cec374..000000000 --- a/Source/3rd Party/wx/include/wx/generic/grid.h +++ /dev/null @@ -1,2723 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/grid.h -// Purpose: wxGrid and related classes -// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) -// Modified by: Santiago Palacios -// Created: 1/08/1999 -// Copyright: (c) Michael Bedward -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_GRID_H_ -#define _WX_GENERIC_GRID_H_ - -#include "wx/defs.h" - -#if wxUSE_GRID - -#include "wx/hashmap.h" - -#include "wx/scrolwin.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -extern WXDLLIMPEXP_DATA_ADV(const char) wxGridNameStr[]; - -// Default parameters for wxGrid -// -#define WXGRID_DEFAULT_NUMBER_ROWS 10 -#define WXGRID_DEFAULT_NUMBER_COLS 10 -#if defined(__WXMSW__) || defined(__WXGTK20__) -#define WXGRID_DEFAULT_ROW_HEIGHT 25 -#else -#define WXGRID_DEFAULT_ROW_HEIGHT 30 -#endif // __WXMSW__ -#define WXGRID_DEFAULT_COL_WIDTH 80 -#define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32 -#define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82 -#define WXGRID_LABEL_EDGE_ZONE 2 -#define WXGRID_MIN_ROW_HEIGHT 15 -#define WXGRID_MIN_COL_WIDTH 15 -#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16 - -// type names for grid table values -#define wxGRID_VALUE_STRING wxT("string") -#define wxGRID_VALUE_BOOL wxT("bool") -#define wxGRID_VALUE_NUMBER wxT("long") -#define wxGRID_VALUE_FLOAT wxT("double") -#define wxGRID_VALUE_CHOICE wxT("choice") - -#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING -#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER - -// magic constant which tells (to some functions) to automatically calculate -// the appropriate size -#define wxGRID_AUTOSIZE (-1) - -// many wxGrid methods work either with columns or rows, this enum is used for -// the parameter indicating which one should it be -enum wxGridDirection -{ - wxGRID_COLUMN, - wxGRID_ROW -}; - -// Flags used with wxGrid::Render() to select parts of the grid to draw. -enum wxGridRenderStyle -{ - wxGRID_DRAW_ROWS_HEADER = 0x001, - wxGRID_DRAW_COLS_HEADER = 0x002, - wxGRID_DRAW_CELL_LINES = 0x004, - wxGRID_DRAW_BOX_RECT = 0x008, - wxGRID_DRAW_SELECTION = 0x010, - wxGRID_DRAW_DEFAULT = wxGRID_DRAW_ROWS_HEADER | - wxGRID_DRAW_COLS_HEADER | - wxGRID_DRAW_CELL_LINES | - wxGRID_DRAW_BOX_RECT -}; - -// ---------------------------------------------------------------------------- -// forward declarations -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_ADV wxGrid; -class WXDLLIMPEXP_FWD_ADV wxGridCellAttr; -class WXDLLIMPEXP_FWD_ADV wxGridCellAttrProviderData; -class WXDLLIMPEXP_FWD_ADV wxGridColLabelWindow; -class WXDLLIMPEXP_FWD_ADV wxGridCornerLabelWindow; -class WXDLLIMPEXP_FWD_ADV wxGridRowLabelWindow; -class WXDLLIMPEXP_FWD_ADV wxGridWindow; -class WXDLLIMPEXP_FWD_ADV wxGridTypeRegistry; -class WXDLLIMPEXP_FWD_ADV wxGridSelection; - -class WXDLLIMPEXP_FWD_CORE wxHeaderCtrl; -class WXDLLIMPEXP_FWD_CORE wxCheckBox; -class WXDLLIMPEXP_FWD_CORE wxComboBox; -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; -#if wxUSE_SPINCTRL -class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; -#endif - -class wxGridFixedIndicesSet; - -class wxGridOperations; -class wxGridRowOperations; -class wxGridColumnOperations; -class wxGridDirectionOperations; - - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -#define wxSafeIncRef(p) if ( p ) (p)->IncRef() -#define wxSafeDecRef(p) if ( p ) (p)->DecRef() - -// ---------------------------------------------------------------------------- -// wxGridCellWorker: common base class for wxGridCellRenderer and -// wxGridCellEditor -// -// NB: this is more an implementation convenience than a design issue, so this -// class is not documented and is not public at all -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer, public wxRefCounter -{ -public: - wxGridCellWorker() { } - - // interpret renderer parameters: arbitrary string whose interpretation is - // left to the derived classes - virtual void SetParameters(const wxString& params); - -protected: - // virtual dtor for any base class - private because only DecRef() can - // delete us - virtual ~wxGridCellWorker(); - -private: - // suppress the stupid gcc warning about the class having private dtor and - // no friends - friend class wxGridCellWorkerDummyFriend; -}; - -// ---------------------------------------------------------------------------- -// wxGridCellRenderer: this class is responsible for actually drawing the cell -// in the grid. You may pass it to the wxGridCellAttr (below) to change the -// format of one given cell or to wxGrid::SetDefaultRenderer() to change the -// view of all cells. This is an ABC, you will normally use one of the -// predefined derived classes or derive your own class from it. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridCellRenderer : public wxGridCellWorker -{ -public: - // draw the given cell on the provided DC inside the given rectangle - // using the style specified by the attribute and the default or selected - // state corresponding to the isSelected value. - // - // this pure virtual function has a default implementation which will - // prepare the DC using the given attribute: it will draw the rectangle - // with the bg colour from attr and set the text colour and font - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected) = 0; - - // get the preferred size of the cell for its contents - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) = 0; - - // create a new object which is the copy of this one - virtual wxGridCellRenderer *Clone() const = 0; -}; - -// ---------------------------------------------------------------------------- -// wxGridCellEditor: This class is responsible for providing and manipulating -// the in-place edit controls for the grid. Instances of wxGridCellEditor -// (actually, instances of derived classes since it is an ABC) can be -// associated with the cell attributes for individual cells, rows, columns, or -// even for the entire grid. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridCellEditor : public wxGridCellWorker -{ -public: - wxGridCellEditor(); - - bool IsCreated() const { return m_control != NULL; } - wxControl* GetControl() const { return m_control; } - void SetControl(wxControl* control) { m_control = control; } - - wxGridCellAttr* GetCellAttr() const { return m_attr; } - void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; } - - // Creates the actual edit control - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) = 0; - - // Size and position the edit control - virtual void SetSize(const wxRect& rect); - - // Show or hide the edit control, use the specified attributes to set - // colours/fonts for it - virtual void Show(bool show, wxGridCellAttr *attr = NULL); - - // Draws the part of the cell not occupied by the control: the base class - // version just fills it with background colour from the attribute - virtual void PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr); - - - // The methods called by wxGrid when a cell is edited: first BeginEdit() is - // called, then EndEdit() is and if it returns true and if the change is - // not vetoed by a user-defined event handler, finally ApplyEdit() is called - - // Fetch the value from the table and prepare the edit control - // to begin editing. Set the focus to the edit control. - virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; - - // Returns false if nothing changed, otherwise returns true and return the - // new value in its string form in the newval output parameter. - // - // This should also store the new value in its real type internally so that - // it could be used by ApplyEdit() but it must not modify the grid as the - // change could still be vetoed. - virtual bool EndEdit(int row, int col, const wxGrid *grid, - const wxString& oldval, wxString *newval) = 0; - - // Complete the editing of the current cell by storing the value saved by - // the previous call to EndEdit() in the grid - virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; - - - // Reset the value in the control back to its starting value - virtual void Reset() = 0; - - // return true to allow the given key to start editing: the base class - // version only checks that the event has no modifiers. The derived - // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in - // their IsAcceptedKey() implementation, although, of course, it is not a - // mandatory requirment. - // - // NB: if the key is F2 (special), editing will always start and this - // method will not be called at all (but StartingKey() will) - virtual bool IsAcceptedKey(wxKeyEvent& event); - - // If the editor is enabled by pressing keys on the grid, this will be - // called to let the editor do something about that first key if desired - virtual void StartingKey(wxKeyEvent& event); - - // if the editor is enabled by clicking on the cell, this method will be - // called - virtual void StartingClick(); - - // Some types of controls on some platforms may need some help - // with the Return key. - virtual void HandleReturn(wxKeyEvent& event); - - // Final cleanup - virtual void Destroy(); - - // create a new object which is the copy of this one - virtual wxGridCellEditor *Clone() const = 0; - - // added GetValue so we can get the value which is in the control - virtual wxString GetValue() const = 0; - -protected: - // the dtor is private because only DecRef() can delete us - virtual ~wxGridCellEditor(); - - // the control we show on screen - wxControl* m_control; - - // a temporary pointer to the attribute being edited - wxGridCellAttr* m_attr; - - // if we change the colours/font of the control from the default ones, we - // must restore the default later and we save them here between calls to - // Show(true) and Show(false) - wxColour m_colFgOld, - m_colBgOld; - wxFont m_fontOld; - - // suppress the stupid gcc warning about the class having private dtor and - // no friends - friend class wxGridCellEditorDummyFriend; - - wxDECLARE_NO_COPY_CLASS(wxGridCellEditor); -}; - -// ---------------------------------------------------------------------------- -// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers -// ---------------------------------------------------------------------------- - -// Base class for corner window renderer: it is the simplest of all renderers -// and only has a single function -class WXDLLIMPEXP_ADV wxGridCornerHeaderRenderer -{ -public: - // Draw the border around the corner window. - virtual void DrawBorder(const wxGrid& grid, - wxDC& dc, - wxRect& rect) const = 0; - - // make the dtor of a class with virtual functions virtual to avoid g++ - // warnings, even though this class is not supposed to be used - // polymorphically - virtual ~wxGridCornerHeaderRenderer() { } -}; - - -// Base class for the row/column header cells renderers -class WXDLLIMPEXP_ADV wxGridHeaderLabelsRenderer - : public wxGridCornerHeaderRenderer -{ -public: - // Draw header cell label - virtual void DrawLabel(const wxGrid& grid, - wxDC& dc, - const wxString& value, - const wxRect& rect, - int horizAlign, - int vertAlign, - int textOrientation) const; -}; - -// Currently the row/column/corner renders don't need any methods other than -// those already in wxGridHeaderLabelsRenderer but still define separate classes -// for them for future extensions and also for better type safety (i.e. to -// avoid inadvertently using a column header renderer for the row headers) -class WXDLLIMPEXP_ADV wxGridRowHeaderRenderer - : public wxGridHeaderLabelsRenderer -{ -}; - -class WXDLLIMPEXP_ADV wxGridColumnHeaderRenderer - : public wxGridHeaderLabelsRenderer -{ -}; - -// Also define the default renderers which are used by wxGridCellAttrProvider -// by default -class WXDLLIMPEXP_ADV wxGridRowHeaderRendererDefault - : public wxGridRowHeaderRenderer -{ -public: - virtual void DrawBorder(const wxGrid& grid, - wxDC& dc, - wxRect& rect) const; -}; - -// Column header cells renderers -class WXDLLIMPEXP_ADV wxGridColumnHeaderRendererDefault - : public wxGridColumnHeaderRenderer -{ -public: - virtual void DrawBorder(const wxGrid& grid, - wxDC& dc, - wxRect& rect) const; -}; - -// Header corner renderer -class WXDLLIMPEXP_ADV wxGridCornerHeaderRendererDefault - : public wxGridCornerHeaderRenderer -{ -public: - virtual void DrawBorder(const wxGrid& grid, - wxDC& dc, - wxRect& rect) const; -}; - - -// ---------------------------------------------------------------------------- -// wxGridCellAttr: this class can be used to alter the cells appearance in -// the grid by changing their colour/font/... from default. An object of this -// class may be returned by wxGridTable::GetAttr(). -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer, public wxRefCounter -{ -public: - enum wxAttrKind - { - Any, - Default, - Cell, - Row, - Col, - Merged - }; - - // ctors - wxGridCellAttr(wxGridCellAttr *attrDefault = NULL) - { - Init(attrDefault); - - SetAlignment(wxALIGN_INVALID, wxALIGN_INVALID); - } - - // VZ: considering the number of members wxGridCellAttr has now, this ctor - // seems to be pretty useless... may be we should just remove it? - wxGridCellAttr(const wxColour& colText, - const wxColour& colBack, - const wxFont& font, - int hAlign, - int vAlign) - : m_colText(colText), m_colBack(colBack), m_font(font) - { - Init(); - SetAlignment(hAlign, vAlign); - } - - // creates a new copy of this object - wxGridCellAttr *Clone() const; - void MergeWith(wxGridCellAttr *mergefrom); - - // setters - void SetTextColour(const wxColour& colText) { m_colText = colText; } - void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } - void SetFont(const wxFont& font) { m_font = font; } - void SetAlignment(int hAlign, int vAlign) - { - m_hAlign = hAlign; - m_vAlign = vAlign; - } - void SetSize(int num_rows, int num_cols); - void SetOverflow(bool allow = true) - { m_overflow = allow ? Overflow : SingleCell; } - void SetReadOnly(bool isReadOnly = true) - { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; } - - // takes ownership of the pointer - void SetRenderer(wxGridCellRenderer *renderer) - { wxSafeDecRef(m_renderer); m_renderer = renderer; } - void SetEditor(wxGridCellEditor* editor) - { wxSafeDecRef(m_editor); m_editor = editor; } - - void SetKind(wxAttrKind kind) { m_attrkind = kind; } - - // accessors - bool HasTextColour() const { return m_colText.IsOk(); } - bool HasBackgroundColour() const { return m_colBack.IsOk(); } - bool HasFont() const { return m_font.IsOk(); } - bool HasAlignment() const - { - return m_hAlign != wxALIGN_INVALID || m_vAlign != wxALIGN_INVALID; - } - bool HasRenderer() const { return m_renderer != NULL; } - bool HasEditor() const { return m_editor != NULL; } - bool HasReadWriteMode() const { return m_isReadOnly != Unset; } - bool HasOverflowMode() const { return m_overflow != UnsetOverflow; } - bool HasSize() const { return m_sizeRows != 1 || m_sizeCols != 1; } - - const wxColour& GetTextColour() const; - const wxColour& GetBackgroundColour() const; - const wxFont& GetFont() const; - void GetAlignment(int *hAlign, int *vAlign) const; - - // unlike GetAlignment() which always overwrites its output arguments with - // the alignment values to use, falling back on default alignment if this - // attribute doesn't have any, this function will preserve the values of - // parameters on entry if the corresponding alignment is not set in this - // attribute meaning that they can be initialized to default alignment (and - // also that they must be initialized, unlike with GetAlignment()) - void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; - - void GetSize(int *num_rows, int *num_cols) const; - bool GetOverflow() const - { return m_overflow != SingleCell; } - wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const; - wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const; - - bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; } - - wxAttrKind GetKind() { return m_attrkind; } - - void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; } - -protected: - // the dtor is private because only DecRef() can delete us - virtual ~wxGridCellAttr() - { - wxSafeDecRef(m_renderer); - wxSafeDecRef(m_editor); - } - -private: - enum wxAttrReadMode - { - Unset = -1, - ReadWrite, - ReadOnly - }; - - enum wxAttrOverflowMode - { - UnsetOverflow = -1, - Overflow, - SingleCell - }; - - // the common part of all ctors - void Init(wxGridCellAttr *attrDefault = NULL); - - - wxColour m_colText, - m_colBack; - wxFont m_font; - int m_hAlign, - m_vAlign; - int m_sizeRows, - m_sizeCols; - - wxAttrOverflowMode m_overflow; - - wxGridCellRenderer* m_renderer; - wxGridCellEditor* m_editor; - wxGridCellAttr* m_defGridAttr; - - wxAttrReadMode m_isReadOnly; - - wxAttrKind m_attrkind; - - // use Clone() instead - wxDECLARE_NO_COPY_CLASS(wxGridCellAttr); - - // suppress the stupid gcc warning about the class having private dtor and - // no friends - friend class wxGridCellAttrDummyFriend; -}; - -// ---------------------------------------------------------------------------- -// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the -// cell attributes. -// ---------------------------------------------------------------------------- - -// implementation note: we separate it from wxGridTableBase because we wish to -// avoid deriving a new table class if possible, and sometimes it will be -// enough to just derive another wxGridCellAttrProvider instead -// -// the default implementation is reasonably efficient for the generic case, -// but you might still wish to implement your own for some specific situations -// if you have performance problems with the stock one -class WXDLLIMPEXP_ADV wxGridCellAttrProvider : public wxClientDataContainer -{ -public: - wxGridCellAttrProvider(); - virtual ~wxGridCellAttrProvider(); - - // DecRef() must be called on the returned pointer - virtual wxGridCellAttr *GetAttr(int row, int col, - wxGridCellAttr::wxAttrKind kind ) const; - - // all these functions take ownership of the pointer, don't call DecRef() - // on it - virtual void SetAttr(wxGridCellAttr *attr, int row, int col); - virtual void SetRowAttr(wxGridCellAttr *attr, int row); - virtual void SetColAttr(wxGridCellAttr *attr, int col); - - // these functions must be called whenever some rows/cols are deleted - // because the internal data must be updated then - void UpdateAttrRows( size_t pos, int numRows ); - void UpdateAttrCols( size_t pos, int numCols ); - - - // get renderers for the given row/column header label and the corner - // window: unlike cell renderers, these objects are not reference counted - // and are never NULL so they are returned by reference - virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); - virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); - virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); - -private: - void InitData(); - - wxGridCellAttrProviderData *m_data; - - wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider); -}; - -// ---------------------------------------------------------------------------- -// wxGridCellCoords: location of a cell in the grid -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridCellCoords -{ -public: - wxGridCellCoords() { m_row = m_col = -1; } - wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; } - - // default copy ctor is ok - - int GetRow() const { return m_row; } - void SetRow( int n ) { m_row = n; } - int GetCol() const { return m_col; } - void SetCol( int n ) { m_col = n; } - void Set( int row, int col ) { m_row = row; m_col = col; } - - wxGridCellCoords& operator=( const wxGridCellCoords& other ) - { - if ( &other != this ) - { - m_row=other.m_row; - m_col=other.m_col; - } - return *this; - } - - bool operator==( const wxGridCellCoords& other ) const - { - return (m_row == other.m_row && m_col == other.m_col); - } - - bool operator!=( const wxGridCellCoords& other ) const - { - return (m_row != other.m_row || m_col != other.m_col); - } - - bool operator!() const - { - return (m_row == -1 && m_col == -1 ); - } - -private: - int m_row; - int m_col; -}; - - -// For comparisons... -// -extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords; -extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect; - -// An array of cell coords... -// -WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords, wxGridCellCoordsArray, - class WXDLLIMPEXP_ADV); - -// ---------------------------------------------------------------------------- -// Grid table classes -// ---------------------------------------------------------------------------- - -// the abstract base class -class WXDLLIMPEXP_ADV wxGridTableBase : public wxObject, - public wxClientDataContainer -{ -public: - wxGridTableBase(); - virtual ~wxGridTableBase(); - - // You must override these functions in a derived table class - // - - // return the number of rows and columns in this table - virtual int GetNumberRows() = 0; - virtual int GetNumberCols() = 0; - - // the methods above are unfortunately non-const even though they should - // have been const -- but changing it now is not possible any longer as it - // would break the existing code overriding them, so instead we provide - // these const synonyms which can be used from const-correct code - int GetRowsCount() const - { return const_cast(this)->GetNumberRows(); } - int GetColsCount() const - { return const_cast(this)->GetNumberCols(); } - - - virtual bool IsEmptyCell( int row, int col ) - { - return GetValue(row, col).empty(); - } - - bool IsEmpty(const wxGridCellCoords& coord) - { - return IsEmptyCell(coord.GetRow(), coord.GetCol()); - } - - virtual wxString GetValue( int row, int col ) = 0; - virtual void SetValue( int row, int col, const wxString& value ) = 0; - - // Data type determination and value access - virtual wxString GetTypeName( int row, int col ); - virtual bool CanGetValueAs( int row, int col, const wxString& typeName ); - virtual bool CanSetValueAs( int row, int col, const wxString& typeName ); - - virtual long GetValueAsLong( int row, int col ); - virtual double GetValueAsDouble( int row, int col ); - virtual bool GetValueAsBool( int row, int col ); - - virtual void SetValueAsLong( int row, int col, long value ); - virtual void SetValueAsDouble( int row, int col, double value ); - virtual void SetValueAsBool( int row, int col, bool value ); - - // For user defined types - virtual void* GetValueAsCustom( int row, int col, const wxString& typeName ); - virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value ); - - - // Overriding these is optional - // - virtual void SetView( wxGrid *grid ) { m_view = grid; } - virtual wxGrid * GetView() const { return m_view; } - - virtual void Clear() {} - virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 ); - virtual bool AppendRows( size_t numRows = 1 ); - virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); - virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 ); - virtual bool AppendCols( size_t numCols = 1 ); - virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); - - virtual wxString GetRowLabelValue( int row ); - virtual wxString GetColLabelValue( int col ); - virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {} - virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {} - - // Attribute handling - // - - // give us the attr provider to use - we take ownership of the pointer - void SetAttrProvider(wxGridCellAttrProvider *attrProvider); - - // get the currently used attr provider (may be NULL) - wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; } - - // Does this table allow attributes? Default implementation creates - // a wxGridCellAttrProvider if necessary. - virtual bool CanHaveAttributes(); - - // by default forwarded to wxGridCellAttrProvider if any. May be - // overridden to handle attributes directly in the table. - virtual wxGridCellAttr *GetAttr( int row, int col, - wxGridCellAttr::wxAttrKind kind ); - - - // these functions take ownership of the pointer - virtual void SetAttr(wxGridCellAttr* attr, int row, int col); - virtual void SetRowAttr(wxGridCellAttr *attr, int row); - virtual void SetColAttr(wxGridCellAttr *attr, int col); - -private: - wxGrid * m_view; - wxGridCellAttrProvider *m_attrProvider; - - DECLARE_ABSTRACT_CLASS(wxGridTableBase) - wxDECLARE_NO_COPY_CLASS(wxGridTableBase); -}; - - -// ---------------------------------------------------------------------------- -// wxGridTableMessage -// ---------------------------------------------------------------------------- - -// IDs for messages sent from grid table to view -// -enum wxGridTableRequest -{ - wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, - wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, - wxGRIDTABLE_NOTIFY_ROWS_INSERTED, - wxGRIDTABLE_NOTIFY_ROWS_APPENDED, - wxGRIDTABLE_NOTIFY_ROWS_DELETED, - wxGRIDTABLE_NOTIFY_COLS_INSERTED, - wxGRIDTABLE_NOTIFY_COLS_APPENDED, - wxGRIDTABLE_NOTIFY_COLS_DELETED -}; - -class WXDLLIMPEXP_ADV wxGridTableMessage -{ -public: - wxGridTableMessage(); - wxGridTableMessage( wxGridTableBase *table, int id, - int comInt1 = -1, - int comInt2 = -1 ); - - void SetTableObject( wxGridTableBase *table ) { m_table = table; } - wxGridTableBase * GetTableObject() const { return m_table; } - void SetId( int id ) { m_id = id; } - int GetId() { return m_id; } - void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; } - int GetCommandInt() { return m_comInt1; } - void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; } - int GetCommandInt2() { return m_comInt2; } - -private: - wxGridTableBase *m_table; - int m_id; - int m_comInt1; - int m_comInt2; - - wxDECLARE_NO_COPY_CLASS(wxGridTableMessage); -}; - - - -// ------ wxGridStringArray -// A 2-dimensional array of strings for data values -// - -WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString, wxGridStringArray, - class WXDLLIMPEXP_ADV); - - - -// ------ wxGridStringTable -// -// Simplest type of data table for a grid for small tables of strings -// that are stored in memory -// - -class WXDLLIMPEXP_ADV wxGridStringTable : public wxGridTableBase -{ -public: - wxGridStringTable(); - wxGridStringTable( int numRows, int numCols ); - - // these are pure virtual in wxGridTableBase - // - virtual int GetNumberRows() { return static_cast(m_data.size()); } - virtual int GetNumberCols() { return m_numCols; } - virtual wxString GetValue( int row, int col ); - virtual void SetValue( int row, int col, const wxString& s ); - - // overridden functions from wxGridTableBase - // - void Clear(); - bool InsertRows( size_t pos = 0, size_t numRows = 1 ); - bool AppendRows( size_t numRows = 1 ); - bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); - bool InsertCols( size_t pos = 0, size_t numCols = 1 ); - bool AppendCols( size_t numCols = 1 ); - bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); - - void SetRowLabelValue( int row, const wxString& ); - void SetColLabelValue( int col, const wxString& ); - wxString GetRowLabelValue( int row ); - wxString GetColLabelValue( int col ); - -private: - wxGridStringArray m_data; - - // notice that while we don't need to store the number of our rows as it's - // always equal to the size of m_data array, we do need to store the number - // of our columns as we can't retrieve it from m_data when the number of - // rows is 0 (see #10818) - int m_numCols; - - // These only get used if you set your own labels, otherwise the - // GetRow/ColLabelValue functions return wxGridTableBase defaults - // - wxArrayString m_rowLabels; - wxArrayString m_colLabels; - - DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable ) -}; - - - -// ============================================================================ -// Grid view classes -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxGridSizesInfo stores information about sizes of the rows or columns. -// -// It assumes that most of the columns or rows have default size and so stores -// the default size separately and uses a hash to map column or row numbers to -// their non default size for those which don't have the default size. -// ---------------------------------------------------------------------------- - -// hash map to store positions as the keys and sizes as the values -WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash, wxIntegerEqual, - wxUnsignedToIntHashMap, class WXDLLIMPEXP_ADV ); - -struct WXDLLIMPEXP_ADV wxGridSizesInfo -{ - // default ctor, initialize m_sizeDefault and m_customSizes later - wxGridSizesInfo() { } - - // ctor used by wxGrid::Get{Col,Row}Sizes() - wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); - - // default copy ctor, assignment operator and dtor are ok - - // Get the size of the element with the given index - int GetSize(unsigned pos) const; - - - // default size - int m_sizeDefault; - - // position -> size map containing all elements with non-default size - wxUnsignedToIntHashMap m_customSizes; -}; - -// ---------------------------------------------------------------------------- -// wxGrid -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGrid : public wxScrolledWindow -{ -public: - // possible selection modes - enum wxGridSelectionModes - { - wxGridSelectCells = 0, // allow selecting anything - wxGridSelectRows = 1, // allow selecting only entire rows - wxGridSelectColumns = 2, // allow selecting only entire columns - wxGridSelectRowsOrColumns = wxGridSelectRows | wxGridSelectColumns - }; - - // Different behaviour of the TAB key when the end (or the beginning, for - // Shift-TAB) of the current row is reached: - enum TabBehaviour - { - Tab_Stop, // Do nothing, this is default. - Tab_Wrap, // Move to the next (or previous) row. - Tab_Leave // Move to the next (or previous) control. - }; - - // creation and destruction - // ------------------------ - - // ctor and Create() create the grid window, as with the other controls - wxGrid() { Init(); } - - wxGrid(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxWANTS_CHARS, - const wxString& name = wxGridNameStr) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxWANTS_CHARS, - const wxString& name = wxGridNameStr); - - virtual ~wxGrid(); - - // however to initialize grid data either CreateGrid() or SetTable() must - // be also called - - // this is basically equivalent to - // - // SetTable(new wxGridStringTable(numRows, numCols), true, selmode) - // - bool CreateGrid( int numRows, int numCols, - wxGridSelectionModes selmode = wxGridSelectCells ); - - bool SetTable( wxGridTableBase *table, - bool takeOwnership = false, - wxGridSelectionModes selmode = wxGridSelectCells ); - - bool ProcessTableMessage(wxGridTableMessage&); - - wxGridTableBase *GetTable() const { return m_table; } - - - void SetSelectionMode(wxGridSelectionModes selmode); - wxGridSelectionModes GetSelectionMode() const; - - // ------ grid dimensions - // - int GetNumberRows() const { return m_numRows; } - int GetNumberCols() const { return m_numCols; } - - - // ------ display update functions - // - wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ) const; - - wxArrayInt CalcColLabelsExposed( const wxRegion& reg ) const; - wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ) const; - - - void ClearGrid(); - bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true) - { - return DoModifyLines(&wxGridTableBase::InsertRows, - pos, numRows, updateLabels); - } - bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true) - { - return DoModifyLines(&wxGridTableBase::InsertCols, - pos, numCols, updateLabels); - } - - bool AppendRows(int numRows = 1, bool updateLabels = true) - { - return DoAppendLines(&wxGridTableBase::AppendRows, numRows, updateLabels); - } - bool AppendCols(int numCols = 1, bool updateLabels = true) - { - return DoAppendLines(&wxGridTableBase::AppendCols, numCols, updateLabels); - } - - bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true) - { - return DoModifyLines(&wxGridTableBase::DeleteRows, - pos, numRows, updateLabels); - } - bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true) - { - return DoModifyLines(&wxGridTableBase::DeleteCols, - pos, numCols, updateLabels); - } - - void DrawGridCellArea( wxDC& dc , const wxGridCellCoordsArray& cells ); - void DrawGridSpace( wxDC& dc ); - void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); - void DrawAllGridLines( wxDC& dc, const wxRegion & reg ); - void DrawCell( wxDC& dc, const wxGridCellCoords& ); - void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells); - - // this function is called when the current cell highlight must be redrawn - // and may be overridden by the user - virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); - - virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); - virtual void DrawRowLabel( wxDC& dc, int row ); - - virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols ); - virtual void DrawColLabel( wxDC& dc, int col ); - - virtual void DrawCornerLabel(wxDC& dc); - - // ------ Cell text drawing functions - // - void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, - int horizontalAlignment = wxALIGN_LEFT, - int verticalAlignment = wxALIGN_TOP, - int textOrientation = wxHORIZONTAL ) const; - - void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&, - int horizontalAlignment = wxALIGN_LEFT, - int verticalAlignment = wxALIGN_TOP, - int textOrientation = wxHORIZONTAL ) const; - - // ------ grid render function for printing - // - void Render( wxDC& dc, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const wxGridCellCoords& topLeft = wxGridCellCoords(-1, -1), - const wxGridCellCoords& bottomRight = wxGridCellCoords(-1, -1), - int style = wxGRID_DRAW_DEFAULT ); - - // Split a string containing newline characters into an array of - // strings and return the number of lines - // - void StringToLines( const wxString& value, wxArrayString& lines ) const; - - void GetTextBoxSize( const wxDC& dc, - const wxArrayString& lines, - long *width, long *height ) const; - - - // ------ - // Code that does a lot of grid modification can be enclosed - // between BeginBatch() and EndBatch() calls to avoid screen - // flicker - // - void BeginBatch() { m_batchCount++; } - void EndBatch(); - - int GetBatchCount() { return m_batchCount; } - - virtual void Refresh(bool eraseb = true, const wxRect* rect = NULL); - - // Use this, rather than wxWindow::Refresh(), to force an - // immediate repainting of the grid. Has no effect if you are - // already inside a BeginBatch / EndBatch block. - // - // This function is necessary because wxGrid has a minimal OnPaint() - // handler to reduce screen flicker. - // - void ForceRefresh(); - - - // ------ edit control functions - // - bool IsEditable() const { return m_editable; } - void EnableEditing( bool edit ); - - void EnableCellEditControl( bool enable = true ); - void DisableCellEditControl() { EnableCellEditControl(false); } - bool CanEnableCellControl() const; - bool IsCellEditControlEnabled() const; - bool IsCellEditControlShown() const; - - bool IsCurrentCellReadOnly() const; - - void ShowCellEditControl(); - void HideCellEditControl(); - void SaveEditControlValue(); - - - // ------ grid location functions - // Note that all of these functions work with the logical coordinates of - // grid cells and labels so you will need to convert from device - // coordinates for mouse events etc. - // - wxGridCellCoords XYToCell(int x, int y) const; - void XYToCell(int x, int y, wxGridCellCoords& coords) const - { coords = XYToCell(x, y); } - wxGridCellCoords XYToCell(const wxPoint& pos) const - { return XYToCell(pos.x, pos.y); } - - // these functions return the index of the row/columns corresponding to the - // given logical position in pixels - // - // if clipToMinMax is false (default, wxNOT_FOUND is returned if the - // position is outside any row/column, otherwise the first/last element is - // returned in this case - int YToRow( int y, bool clipToMinMax = false ) const; - int XToCol( int x, bool clipToMinMax = false ) const; - - int YToEdgeOfRow( int y ) const; - int XToEdgeOfCol( int x ) const; - - wxRect CellToRect( int row, int col ) const; - wxRect CellToRect( const wxGridCellCoords& coords ) const - { return CellToRect( coords.GetRow(), coords.GetCol() ); } - - int GetGridCursorRow() const { return m_currentCellCoords.GetRow(); } - int GetGridCursorCol() const { return m_currentCellCoords.GetCol(); } - - // check to see if a cell is either wholly visible (the default arg) or - // at least partially visible in the grid window - // - bool IsVisible( int row, int col, bool wholeCellVisible = true ) const; - bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true ) const - { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); } - void MakeCellVisible( int row, int col ); - void MakeCellVisible( const wxGridCellCoords& coords ) - { MakeCellVisible( coords.GetRow(), coords.GetCol() ); } - - - // ------ grid cursor movement functions - // - void SetGridCursor(int row, int col) { SetCurrentCell(row, col); } - void SetGridCursor(const wxGridCellCoords& c) { SetCurrentCell(c); } - - void GoToCell(int row, int col) - { - if ( SetCurrentCell(row, col) ) - MakeCellVisible(row, col); - } - - void GoToCell(const wxGridCellCoords& coords) - { - if ( SetCurrentCell(coords) ) - MakeCellVisible(coords); - } - - bool MoveCursorUp( bool expandSelection ); - bool MoveCursorDown( bool expandSelection ); - bool MoveCursorLeft( bool expandSelection ); - bool MoveCursorRight( bool expandSelection ); - bool MovePageDown(); - bool MovePageUp(); - bool MoveCursorUpBlock( bool expandSelection ); - bool MoveCursorDownBlock( bool expandSelection ); - bool MoveCursorLeftBlock( bool expandSelection ); - bool MoveCursorRightBlock( bool expandSelection ); - - void SetTabBehaviour(TabBehaviour behaviour) { m_tabBehaviour = behaviour; } - - - // ------ label and gridline formatting - // - int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; } - int GetRowLabelSize() const { return m_rowLabelWidth; } - int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; } - int GetColLabelSize() const { return m_colLabelHeight; } - wxColour GetLabelBackgroundColour() const { return m_labelBackgroundColour; } - wxColour GetLabelTextColour() const { return m_labelTextColour; } - wxFont GetLabelFont() const { return m_labelFont; } - void GetRowLabelAlignment( int *horiz, int *vert ) const; - void GetColLabelAlignment( int *horiz, int *vert ) const; - int GetColLabelTextOrientation() const; - wxString GetRowLabelValue( int row ) const; - wxString GetColLabelValue( int col ) const; - - wxColour GetCellHighlightColour() const { return m_cellHighlightColour; } - int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth; } - int GetCellHighlightROPenWidth() const { return m_cellHighlightROPenWidth; } - - // this one will use wxHeaderCtrl for the column labels - void UseNativeColHeader(bool native = true); - - // this one will still draw them manually but using the native renderer - // instead of using the same appearance as for the row labels - void SetUseNativeColLabels( bool native = true ); - - void SetRowLabelSize( int width ); - void SetColLabelSize( int height ); - void HideRowLabels() { SetRowLabelSize( 0 ); } - void HideColLabels() { SetColLabelSize( 0 ); } - void SetLabelBackgroundColour( const wxColour& ); - void SetLabelTextColour( const wxColour& ); - void SetLabelFont( const wxFont& ); - void SetRowLabelAlignment( int horiz, int vert ); - void SetColLabelAlignment( int horiz, int vert ); - void SetColLabelTextOrientation( int textOrientation ); - void SetRowLabelValue( int row, const wxString& ); - void SetColLabelValue( int col, const wxString& ); - void SetCellHighlightColour( const wxColour& ); - void SetCellHighlightPenWidth(int width); - void SetCellHighlightROPenWidth(int width); - - - // interactive grid mouse operations control - // ----------------------------------------- - - // functions globally enabling row/column interactive resizing (enabled by - // default) - void EnableDragRowSize( bool enable = true ); - void DisableDragRowSize() { EnableDragRowSize( false ); } - - void EnableDragColSize( bool enable = true ); - void DisableDragColSize() { EnableDragColSize( false ); } - - // if interactive resizing is enabled, some rows/columns can still have - // fixed size - void DisableRowResize(int row) { DoDisableLineResize(row, m_setFixedRows); } - void DisableColResize(int col) { DoDisableLineResize(col, m_setFixedCols); } - - // these functions return whether the given row/column can be - // effectively resized: for this interactive resizing must be enabled - // and this index must not have been passed to DisableRow/ColResize() - bool CanDragRowSize(int row) const - { return m_canDragRowSize && DoCanResizeLine(row, m_setFixedRows); } - bool CanDragColSize(int col) const - { return m_canDragColSize && DoCanResizeLine(col, m_setFixedCols); } - - // interactive column reordering (disabled by default) - void EnableDragColMove( bool enable = true ); - void DisableDragColMove() { EnableDragColMove( false ); } - bool CanDragColMove() const { return m_canDragColMove; } - - // interactive resizing of grid cells (enabled by default) - void EnableDragGridSize(bool enable = true); - void DisableDragGridSize() { EnableDragGridSize(false); } - bool CanDragGridSize() const { return m_canDragGridSize; } - - // interactive dragging of cells (disabled by default) - void EnableDragCell( bool enable = true ); - void DisableDragCell() { EnableDragCell( false ); } - bool CanDragCell() const { return m_canDragCell; } - - - // grid lines - // ---------- - - // enable or disable drawing of the lines - void EnableGridLines(bool enable = true); - bool GridLinesEnabled() const { return m_gridLinesEnabled; } - - // by default grid lines stop at last column/row, but this may be changed - void ClipHorzGridLines(bool clip) - { DoClipGridLines(m_gridLinesClipHorz, clip); } - void ClipVertGridLines(bool clip) - { DoClipGridLines(m_gridLinesClipVert, clip); } - bool AreHorzGridLinesClipped() const { return m_gridLinesClipHorz; } - bool AreVertGridLinesClipped() const { return m_gridLinesClipVert; } - - // this can be used to change the global grid lines colour - void SetGridLineColour(const wxColour& col); - wxColour GetGridLineColour() const { return m_gridLineColour; } - - // these methods may be overridden to customize individual grid lines - // appearance - virtual wxPen GetDefaultGridLinePen(); - virtual wxPen GetRowGridLinePen(int row); - virtual wxPen GetColGridLinePen(int col); - - - // attributes - // ---------- - - // this sets the specified attribute for this cell or in this row/col - void SetAttr(int row, int col, wxGridCellAttr *attr); - void SetRowAttr(int row, wxGridCellAttr *attr); - void SetColAttr(int col, wxGridCellAttr *attr); - - // the grid can cache attributes for the recently used cells (currently it - // only caches one attribute for the most recently used one) and might - // notice that its value in the attribute provider has changed -- if this - // happens, call this function to force it - void RefreshAttr(int row, int col); - - // returns the attribute we may modify in place: a new one if this cell - // doesn't have any yet or the existing one if it does - // - // DecRef() must be called on the returned pointer, as usual - wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; - - - // shortcuts for setting the column parameters - - // set the format for the data in the column: default is string - void SetColFormatBool(int col); - void SetColFormatNumber(int col); - void SetColFormatFloat(int col, int width = -1, int precision = -1); - void SetColFormatCustom(int col, const wxString& typeName); - - // ------ row and col formatting - // - int GetDefaultRowSize() const; - int GetRowSize( int row ) const; - bool IsRowShown(int row) const { return GetRowSize(row) != 0; } - int GetDefaultColSize() const; - int GetColSize( int col ) const; - bool IsColShown(int col) const { return GetColSize(col) != 0; } - wxColour GetDefaultCellBackgroundColour() const; - wxColour GetCellBackgroundColour( int row, int col ) const; - wxColour GetDefaultCellTextColour() const; - wxColour GetCellTextColour( int row, int col ) const; - wxFont GetDefaultCellFont() const; - wxFont GetCellFont( int row, int col ) const; - void GetDefaultCellAlignment( int *horiz, int *vert ) const; - void GetCellAlignment( int row, int col, int *horiz, int *vert ) const; - bool GetDefaultCellOverflow() const; - bool GetCellOverflow( int row, int col ) const; - - // this function returns 1 in num_rows and num_cols for normal cells, - // positive numbers for a cell spanning multiple columns/rows (as set with - // SetCellSize()) and _negative_ numbers corresponding to the offset of the - // top left cell of the span from this one for the other cells covered by - // this cell - // - // the return value is CellSpan_None, CellSpan_Main or CellSpan_Inside for - // each of these cases respectively - enum CellSpan - { - CellSpan_Inside = -1, - CellSpan_None = 0, - CellSpan_Main - }; - - CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; - - wxSize GetCellSize(const wxGridCellCoords& coords) - { - wxSize s; - GetCellSize(coords.GetRow(), coords.GetCol(), &s.x, &s.y); - return s; - } - - // ------ row and col sizes - void SetDefaultRowSize( int height, bool resizeExistingRows = false ); - void SetRowSize( int row, int height ); - void HideRow(int row) { DoSetRowSize(row, 0); } - void ShowRow(int row) { DoSetRowSize(row, -1); } - - void SetDefaultColSize( int width, bool resizeExistingCols = false ); - void SetColSize( int col, int width ); - void HideCol(int col) { DoSetColSize(col, 0); } - void ShowCol(int col) { DoSetColSize(col, -1); } - - // the row and column sizes can be also set all at once using - // wxGridSizesInfo which holds all of them at once - - wxGridSizesInfo GetColSizes() const - { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths); } - wxGridSizesInfo GetRowSizes() const - { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights); } - - void SetColSizes(const wxGridSizesInfo& sizeInfo); - void SetRowSizes(const wxGridSizesInfo& sizeInfo); - - - // ------- columns (only, for now) reordering - - // columns index <-> positions mapping: by default, the position of the - // column is the same as its index, but the columns can also be reordered - // (either by calling SetColPos() explicitly or by the user dragging the - // columns around) in which case their indices don't correspond to their - // positions on display any longer - // - // internally we always work with indices except for the functions which - // have "Pos" in their names (and which work with columns, not pixels) and - // only the display and hit testing code really cares about display - // positions at all - - // set the positions of all columns at once (this method uses the same - // conventions as wxHeaderCtrl::SetColumnsOrder() for the order array) - void SetColumnsOrder(const wxArrayInt& order); - - // return the column index corresponding to the given (valid) position - int GetColAt(int pos) const - { - return m_colAt.empty() ? pos : m_colAt[pos]; - } - - // reorder the columns so that the column with the given index is now shown - // as the position pos - void SetColPos(int idx, int pos); - - // return the position at which the column with the given index is - // displayed: notice that this is a slow operation as we don't maintain the - // reverse mapping currently - int GetColPos(int idx) const - { - if ( m_colAt.IsEmpty() ) - return idx; - - for ( int i = 0; i < m_numCols; i++ ) - { - if ( m_colAt[i] == idx ) - return i; - } - - wxFAIL_MSG( "invalid column index" ); - - return wxNOT_FOUND; - } - - // reset the columns positions to the default order - void ResetColPos(); - - - // automatically size the column or row to fit to its contents, if - // setAsMin is true, this optimal width will also be set as minimal width - // for this column - void AutoSizeColumn( int col, bool setAsMin = true ) - { AutoSizeColOrRow(col, setAsMin, wxGRID_COLUMN); } - void AutoSizeRow( int row, bool setAsMin = true ) - { AutoSizeColOrRow(row, setAsMin, wxGRID_ROW); } - - // auto size all columns (very ineffective for big grids!) - void AutoSizeColumns( bool setAsMin = true ) - { (void)SetOrCalcColumnSizes(false, setAsMin); } - - void AutoSizeRows( bool setAsMin = true ) - { (void)SetOrCalcRowSizes(false, setAsMin); } - - // auto size the grid, that is make the columns/rows of the "right" size - // and also set the grid size to just fit its contents - void AutoSize(); - - // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize: - // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column - // instead of data column. Note that this operation may be slow for large - // tables. - // autosize row height depending on label text - void AutoSizeRowLabelSize( int row ); - - // autosize column width depending on label text - void AutoSizeColLabelSize( int col ); - - // column won't be resized to be lesser width - this must be called during - // the grid creation because it won't resize the column if it's already - // narrower than the minimal width - void SetColMinimalWidth( int col, int width ); - void SetRowMinimalHeight( int row, int width ); - - /* These members can be used to query and modify the minimal - * acceptable size of grid rows and columns. Call this function in - * your code which creates the grid if you want to display cells - * with a size smaller than the default acceptable minimum size. - * Like the members SetColMinimalWidth and SetRowMinimalWidth, - * the existing rows or columns will not be checked/resized. - */ - void SetColMinimalAcceptableWidth( int width ); - void SetRowMinimalAcceptableHeight( int width ); - int GetColMinimalAcceptableWidth() const; - int GetRowMinimalAcceptableHeight() const; - - void SetDefaultCellBackgroundColour( const wxColour& ); - void SetCellBackgroundColour( int row, int col, const wxColour& ); - void SetDefaultCellTextColour( const wxColour& ); - - void SetCellTextColour( int row, int col, const wxColour& ); - void SetDefaultCellFont( const wxFont& ); - void SetCellFont( int row, int col, const wxFont& ); - void SetDefaultCellAlignment( int horiz, int vert ); - void SetCellAlignment( int row, int col, int horiz, int vert ); - void SetDefaultCellOverflow( bool allow ); - void SetCellOverflow( int row, int col, bool allow ); - void SetCellSize( int row, int col, int num_rows, int num_cols ); - - // takes ownership of the pointer - void SetDefaultRenderer(wxGridCellRenderer *renderer); - void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer); - wxGridCellRenderer *GetDefaultRenderer() const; - wxGridCellRenderer* GetCellRenderer(int row, int col) const; - - // takes ownership of the pointer - void SetDefaultEditor(wxGridCellEditor *editor); - void SetCellEditor(int row, int col, wxGridCellEditor *editor); - wxGridCellEditor *GetDefaultEditor() const; - wxGridCellEditor* GetCellEditor(int row, int col) const; - - - - // ------ cell value accessors - // - wxString GetCellValue( int row, int col ) const - { - if ( m_table ) - { - return m_table->GetValue( row, col ); - } - else - { - return wxEmptyString; - } - } - - wxString GetCellValue( const wxGridCellCoords& coords ) const - { return GetCellValue( coords.GetRow(), coords.GetCol() ); } - - void SetCellValue( int row, int col, const wxString& s ); - void SetCellValue( const wxGridCellCoords& coords, const wxString& s ) - { SetCellValue( coords.GetRow(), coords.GetCol(), s ); } - - // returns true if the cell can't be edited - bool IsReadOnly(int row, int col) const; - - // make the cell editable/readonly - void SetReadOnly(int row, int col, bool isReadOnly = true); - - // ------ select blocks of cells - // - void SelectRow( int row, bool addToSelected = false ); - void SelectCol( int col, bool addToSelected = false ); - - void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol, - bool addToSelected = false ); - - void SelectBlock( const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - bool addToSelected = false ) - { SelectBlock( topLeft.GetRow(), topLeft.GetCol(), - bottomRight.GetRow(), bottomRight.GetCol(), - addToSelected ); } - - void SelectAll(); - - bool IsSelection() const; - - // ------ deselect blocks or cells - // - void DeselectRow( int row ); - void DeselectCol( int col ); - void DeselectCell( int row, int col ); - - void ClearSelection(); - - bool IsInSelection( int row, int col ) const; - - bool IsInSelection( const wxGridCellCoords& coords ) const - { return IsInSelection( coords.GetRow(), coords.GetCol() ); } - - wxGridCellCoordsArray GetSelectedCells() const; - wxGridCellCoordsArray GetSelectionBlockTopLeft() const; - wxGridCellCoordsArray GetSelectionBlockBottomRight() const; - wxArrayInt GetSelectedRows() const; - wxArrayInt GetSelectedCols() const; - - // This function returns the rectangle that encloses the block of cells - // limited by TopLeft and BottomRight cell in device coords and clipped - // to the client size of the grid window. - // - wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft, - const wxGridCellCoords & bottomRight ) const; - - // Access or update the selection fore/back colours - wxColour GetSelectionBackground() const - { return m_selectionBackground; } - wxColour GetSelectionForeground() const - { return m_selectionForeground; } - - void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; } - void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; } - - - // Methods for a registry for mapping data types to Renderers/Editors - void RegisterDataType(const wxString& typeName, - wxGridCellRenderer* renderer, - wxGridCellEditor* editor); - // DJC MAPTEK - virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; - wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const - { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); } - virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; - virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; - virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; - - // grid may occupy more space than needed for its rows/columns, this - // function allows to set how big this extra space is - void SetMargins(int extraWidth, int extraHeight) - { - m_extraWidth = extraWidth; - m_extraHeight = extraHeight; - - CalcDimensions(); - } - - // Accessors for component windows - wxWindow* GetGridWindow() const { return (wxWindow*)m_gridWin; } - wxWindow* GetGridRowLabelWindow() const { return (wxWindow*)m_rowLabelWin; } - wxWindow* GetGridColLabelWindow() const { return m_colWindow; } - wxWindow* GetGridCornerLabelWindow() const { return (wxWindow*)m_cornerLabelWin; } - - // This one can only be called if we are using the native header window - wxHeaderCtrl *GetGridColHeader() const - { - wxASSERT_MSG( m_useNativeHeader, "no column header window" ); - - // static_cast<> doesn't work without the full class declaration in - // view and we prefer to avoid adding more compile-time dependencies - // even at the cost of using reinterpret_cast<> - return reinterpret_cast(m_colWindow); - } - - // Allow adjustment of scroll increment. The default is (15, 15). - void SetScrollLineX(int x) { m_xScrollPixelsPerLine = x; } - void SetScrollLineY(int y) { m_yScrollPixelsPerLine = y; } - int GetScrollLineX() const { return m_xScrollPixelsPerLine; } - int GetScrollLineY() const { return m_yScrollPixelsPerLine; } - - // ------- drag and drop -#if wxUSE_DRAG_AND_DROP - virtual void SetDropTarget(wxDropTarget *dropTarget); -#endif // wxUSE_DRAG_AND_DROP - - - // ------- sorting support - - // wxGrid doesn't support sorting on its own but it can indicate the sort - // order in the column header (currently only if native header control is - // used though) - - // return the column currently displaying the sort indicator or wxNOT_FOUND - // if none - int GetSortingColumn() const { return m_sortCol; } - - // return true if this column is currently used for sorting - bool IsSortingBy(int col) const { return GetSortingColumn() == col; } - - // return the current sorting order (on GetSortingColumn()): true for - // ascending sort and false for descending; it doesn't make sense to call - // it if GetSortingColumn() returns wxNOT_FOUND - bool IsSortOrderAscending() const { return m_sortIsAscending; } - - // set the sorting column (or unsets any existing one if wxNOT_FOUND) and - // the order in which to sort - void SetSortingColumn(int col, bool ascending = true); - - // unset any existing sorting column - void UnsetSortingColumn() { SetSortingColumn(wxNOT_FOUND); } - -#if WXWIN_COMPATIBILITY_2_8 - // ------ For compatibility with previous wxGrid only... - // - // ************************************************ - // ** Don't use these in new code because they ** - // ** are liable to disappear in a future ** - // ** revision ** - // ************************************************ - // - - wxGrid( wxWindow *parent, - int x, int y, int w = wxDefaultCoord, int h = wxDefaultCoord, - long style = wxWANTS_CHARS, - const wxString& name = wxPanelNameStr ) - { - Init(); - Create(parent, wxID_ANY, wxPoint(x, y), wxSize(w, h), style, name); - } - - void SetCellValue( const wxString& val, int row, int col ) - { SetCellValue( row, col, val ); } - - void UpdateDimensions() - { CalcDimensions(); } - - int GetRows() const { return GetNumberRows(); } - int GetCols() const { return GetNumberCols(); } - int GetCursorRow() const { return GetGridCursorRow(); } - int GetCursorColumn() const { return GetGridCursorCol(); } - - int GetScrollPosX() const { return 0; } - int GetScrollPosY() const { return 0; } - - void SetScrollX( int WXUNUSED(x) ) { } - void SetScrollY( int WXUNUSED(y) ) { } - - void SetColumnWidth( int col, int width ) - { SetColSize( col, width ); } - - int GetColumnWidth( int col ) const - { return GetColSize( col ); } - - void SetRowHeight( int row, int height ) - { SetRowSize( row, height ); } - - // GetRowHeight() is below - - int GetViewHeight() const // returned num whole rows visible - { return 0; } - - int GetViewWidth() const // returned num whole cols visible - { return 0; } - - void SetLabelSize( int orientation, int sz ) - { - if ( orientation == wxHORIZONTAL ) - SetColLabelSize( sz ); - else - SetRowLabelSize( sz ); - } - - int GetLabelSize( int orientation ) const - { - if ( orientation == wxHORIZONTAL ) - return GetColLabelSize(); - else - return GetRowLabelSize(); - } - - void SetLabelAlignment( int orientation, int align ) - { - if ( orientation == wxHORIZONTAL ) - SetColLabelAlignment( align, wxALIGN_INVALID ); - else - SetRowLabelAlignment( align, wxALIGN_INVALID ); - } - - int GetLabelAlignment( int orientation, int WXUNUSED(align) ) const - { - int h, v; - if ( orientation == wxHORIZONTAL ) - { - GetColLabelAlignment( &h, &v ); - return h; - } - else - { - GetRowLabelAlignment( &h, &v ); - return h; - } - } - - void SetLabelValue( int orientation, const wxString& val, int pos ) - { - if ( orientation == wxHORIZONTAL ) - SetColLabelValue( pos, val ); - else - SetRowLabelValue( pos, val ); - } - - wxString GetLabelValue( int orientation, int pos) const - { - if ( orientation == wxHORIZONTAL ) - return GetColLabelValue( pos ); - else - return GetRowLabelValue( pos ); - } - - wxFont GetCellTextFont() const - { return m_defaultCellAttr->GetFont(); } - - wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const - { return m_defaultCellAttr->GetFont(); } - - void SetCellTextFont(const wxFont& fnt) - { SetDefaultCellFont( fnt ); } - - void SetCellTextFont(const wxFont& fnt, int row, int col) - { SetCellFont( row, col, fnt ); } - - void SetCellTextColour(const wxColour& val, int row, int col) - { SetCellTextColour( row, col, val ); } - - void SetCellTextColour(const wxColour& col) - { SetDefaultCellTextColour( col ); } - - void SetCellBackgroundColour(const wxColour& col) - { SetDefaultCellBackgroundColour( col ); } - - void SetCellBackgroundColour(const wxColour& colour, int row, int col) - { SetCellBackgroundColour( row, col, colour ); } - - bool GetEditable() const { return IsEditable(); } - void SetEditable( bool edit = true ) { EnableEditing( edit ); } - bool GetEditInPlace() const { return IsCellEditControlEnabled(); } - - void SetEditInPlace(bool WXUNUSED(edit) = true) { } - - void SetCellAlignment( int align, int row, int col) - { SetCellAlignment(row, col, align, wxALIGN_CENTER); } - void SetCellAlignment( int WXUNUSED(align) ) {} - void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col)) - { } - void SetDividerPen(const wxPen& WXUNUSED(pen)) { } - wxPen& GetDividerPen() const; - void OnActivate(bool WXUNUSED(active)) {} - - // ******** End of compatibility functions ********** - - - - // ------ control IDs - enum { wxGRID_CELLCTRL = 2000, - wxGRID_TOPCTRL }; - - // ------ control types - enum { wxGRID_TEXTCTRL = 2100, - wxGRID_CHECKBOX, - wxGRID_CHOICE, - wxGRID_COMBOBOX }; - - wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize; ) - wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize; ) -#endif // WXWIN_COMPATIBILITY_2_8 - - - // override some base class functions - virtual bool Enable(bool enable = true); - virtual wxWindow *GetMainWindowOfCompositeControl() - { return (wxWindow*)m_gridWin; } - virtual void Fit(); - - // implementation only - void CancelMouseCapture(); - -protected: - virtual wxSize DoGetBestSize() const; - - bool m_created; - - wxGridWindow *m_gridWin; - wxGridCornerLabelWindow *m_cornerLabelWin; - wxGridRowLabelWindow *m_rowLabelWin; - - // the real type of the column window depends on m_useNativeHeader value: - // if it is true, its dynamic type is wxHeaderCtrl, otherwise it is - // wxGridColLabelWindow, use accessors below when the real type matters - wxWindow *m_colWindow; - - wxGridColLabelWindow *GetColLabelWindow() const - { - wxASSERT_MSG( !m_useNativeHeader, "no column label window" ); - - return reinterpret_cast(m_colWindow); - } - - wxGridTableBase *m_table; - bool m_ownTable; - - int m_numRows; - int m_numCols; - - wxGridCellCoords m_currentCellCoords; - - // the corners of the block being currently selected or wxGridNoCellCoords - wxGridCellCoords m_selectedBlockTopLeft; - wxGridCellCoords m_selectedBlockBottomRight; - - // when selecting blocks of cells (either from the keyboard using Shift - // with cursor keys, or by dragging the mouse), the selection is anchored - // at m_currentCellCoords which defines one of the corners of the rectangle - // being selected -- and this variable defines the other corner, i.e. it's - // either m_selectedBlockTopLeft or m_selectedBlockBottomRight depending on - // which of them is not m_currentCellCoords - // - // if no block selection is in process, it is set to wxGridNoCellCoords - wxGridCellCoords m_selectedBlockCorner; - - wxGridSelection *m_selection; - - wxColour m_selectionBackground; - wxColour m_selectionForeground; - - // NB: *never* access m_row/col arrays directly because they are created - // on demand, *always* use accessor functions instead! - - // init the m_rowHeights/Bottoms arrays with default values - void InitRowHeights(); - - int m_defaultRowHeight; - int m_minAcceptableRowHeight; - wxArrayInt m_rowHeights; - wxArrayInt m_rowBottoms; - - // init the m_colWidths/Rights arrays - void InitColWidths(); - - int m_defaultColWidth; - int m_minAcceptableColWidth; - wxArrayInt m_colWidths; - wxArrayInt m_colRights; - - int m_sortCol; - bool m_sortIsAscending; - - bool m_useNativeHeader, - m_nativeColumnLabels; - - // get the col/row coords - int GetColWidth(int col) const; - int GetColLeft(int col) const; - int GetColRight(int col) const; - - // this function must be public for compatibility... -public: - int GetRowHeight(int row) const; -protected: - - int GetRowTop(int row) const; - int GetRowBottom(int row) const; - - int m_rowLabelWidth; - int m_colLabelHeight; - - // the size of the margin left to the right and bottom of the cell area - int m_extraWidth, - m_extraHeight; - - wxColour m_labelBackgroundColour; - wxColour m_labelTextColour; - wxFont m_labelFont; - - int m_rowLabelHorizAlign; - int m_rowLabelVertAlign; - int m_colLabelHorizAlign; - int m_colLabelVertAlign; - int m_colLabelTextOrientation; - - bool m_defaultRowLabelValues; - bool m_defaultColLabelValues; - - wxColour m_gridLineColour; - bool m_gridLinesEnabled; - bool m_gridLinesClipHorz, - m_gridLinesClipVert; - wxColour m_cellHighlightColour; - int m_cellHighlightPenWidth; - int m_cellHighlightROPenWidth; - - - // common part of AutoSizeColumn/Row() and GetBestSize() - int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = true); - int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true); - - // common part of AutoSizeColumn/Row() - void AutoSizeColOrRow(int n, bool setAsMin, wxGridDirection direction); - - // Calculate the minimum acceptable size for labels area - wxCoord CalcColOrRowLabelAreaMinSize(wxGridDirection direction); - - // if a column has a minimal width, it will be the value for it in this - // hash table - wxLongToLongHashMap m_colMinWidths, - m_rowMinHeights; - - // get the minimal width of the given column/row - int GetColMinimalWidth(int col) const; - int GetRowMinimalHeight(int col) const; - - // do we have some place to store attributes in? - bool CanHaveAttributes() const; - - // cell attribute cache (currently we only cache 1, may be will do - // more/better later) - struct CachedAttr - { - int row, col; - wxGridCellAttr *attr; - } m_attrCache; - - // invalidates the attribute cache - void ClearAttrCache(); - - // adds an attribute to cache - void CacheAttr(int row, int col, wxGridCellAttr *attr) const; - - // looks for an attr in cache, returns true if found - bool LookupAttr(int row, int col, wxGridCellAttr **attr) const; - - // looks for the attr in cache, if not found asks the table and caches the - // result - wxGridCellAttr *GetCellAttr(int row, int col) const; - wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords ) const - { return GetCellAttr( coords.GetRow(), coords.GetCol() ); } - - // the default cell attr object for cells that don't have their own - wxGridCellAttr* m_defaultCellAttr; - - - bool m_inOnKeyDown; - int m_batchCount; - - - wxGridTypeRegistry* m_typeRegistry; - - enum CursorMode - { - WXGRID_CURSOR_SELECT_CELL, - WXGRID_CURSOR_RESIZE_ROW, - WXGRID_CURSOR_RESIZE_COL, - WXGRID_CURSOR_SELECT_ROW, - WXGRID_CURSOR_SELECT_COL, - WXGRID_CURSOR_MOVE_COL - }; - - // this method not only sets m_cursorMode but also sets the correct cursor - // for the given mode and, if captureMouse is not false releases the mouse - // if it was captured and captures it if it must be captured - // - // for this to work, you should always use it and not set m_cursorMode - // directly! - void ChangeCursorMode(CursorMode mode, - wxWindow *win = NULL, - bool captureMouse = true); - - wxWindow *m_winCapture; // the window which captured the mouse - - // this variable is used not for finding the correct current cursor but - // mainly for finding out what is going to happen if the mouse starts being - // dragged right now - // - // by default it is WXGRID_CURSOR_SELECT_CELL meaning that nothing else is - // going on, and it is set to one of RESIZE/SELECT/MOVE values while the - // corresponding operation will be started if the user starts dragging the - // mouse from the current position - CursorMode m_cursorMode; - - - //Column positions - wxArrayInt m_colAt; - - bool m_canDragRowSize; - bool m_canDragColSize; - bool m_canDragColMove; - bool m_canDragGridSize; - bool m_canDragCell; - - // the last position (horizontal or vertical depending on whether the user - // is resizing a column or a row) where a row or column separator line was - // dragged by the user or -1 of there is no drag operation in progress - int m_dragLastPos; - int m_dragRowOrCol; - - // true if a drag operation is in progress; when this is true, - // m_startDragPos is valid, i.e. not wxDefaultPosition - bool m_isDragging; - - // the position (in physical coordinates) where the user started dragging - // the mouse or wxDefaultPosition if mouse isn't being dragged - // - // notice that this can be != wxDefaultPosition while m_isDragging is still - // false because we wait until the mouse is moved some distance away before - // setting m_isDragging to true - wxPoint m_startDragPos; - - bool m_waitForSlowClick; - - wxGridCellCoords m_selectionStart; - - wxCursor m_rowResizeCursor; - wxCursor m_colResizeCursor; - - bool m_editable; // applies to whole grid - bool m_cellEditCtrlEnabled; // is in-place edit currently shown? - - TabBehaviour m_tabBehaviour; // determines how the TAB key behaves - - void Init(); // common part of all ctors - void Create(); - void CreateColumnWindow(); - void CalcDimensions(); - void CalcWindowSizes(); - bool Redimension( wxGridTableMessage& ); - - - // generate the appropriate grid event and return -1 if it was vetoed, 1 if - // it was processed (but not vetoed) and 0 if it wasn't processed - int SendEvent(const wxEventType evtType, - int row, int col, - const wxMouseEvent& e); - int SendEvent(const wxEventType evtType, - const wxGridCellCoords& coords, - const wxMouseEvent& e) - { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); } - int SendEvent(const wxEventType evtType, - int row, int col, - const wxString& s = wxString()); - int SendEvent(const wxEventType evtType, - const wxGridCellCoords& coords, - const wxString& s = wxString()) - { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), s); } - int SendEvent(const wxEventType evtType, const wxString& s = wxString()) - { return SendEvent(evtType, m_currentCellCoords, s); } - - // send wxEVT_GRID_{ROW,COL}_SIZE or wxEVT_GRID_COL_AUTO_SIZE, return true - // if the event was processed, false otherwise - bool SendGridSizeEvent(wxEventType type, - int row, int col, - const wxMouseEvent& mouseEv); - - void OnPaint( wxPaintEvent& ); - void OnSize( wxSizeEvent& ); - void OnKeyDown( wxKeyEvent& ); - void OnKeyUp( wxKeyEvent& ); - void OnChar( wxKeyEvent& ); - void OnEraseBackground( wxEraseEvent& ); - void OnHideEditor( wxCommandEvent& ); - - - bool SetCurrentCell( const wxGridCellCoords& coords ); - bool SetCurrentCell( int row, int col ) - { return SetCurrentCell( wxGridCellCoords(row, col) ); } - - - // this function is called to extend the block being currently selected - // from mouse and keyboard event handlers - void UpdateBlockBeingSelected(int topRow, int leftCol, - int bottomRow, int rightCol); - - void UpdateBlockBeingSelected(const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight) - { UpdateBlockBeingSelected(topLeft.GetRow(), topLeft.GetCol(), - bottomRight.GetRow(), bottomRight.GetCol()); } - - // ------ functions to get/send data (see also public functions) - // - bool GetModelValues(); - bool SetModelValues(); - - friend class WXDLLIMPEXP_FWD_ADV wxGridSelection; - friend class wxGridRowOperations; - friend class wxGridColumnOperations; - - // they call our private Process{{Corner,Col,Row}Label,GridCell}MouseEvent() - friend class wxGridCornerLabelWindow; - friend class wxGridColLabelWindow; - friend class wxGridRowLabelWindow; - friend class wxGridWindow; - friend class wxGridHeaderRenderer; - - friend class wxGridHeaderCtrl; - -private: - - // implement wxScrolledWindow method to return m_gridWin size - virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); - - // redraw the grid lines, should be called after changing their attributes - void RedrawGridLines(); - - // draw all grid lines in the given cell region (unlike the public - // DrawAllGridLines() which just draws all of them) - void DrawRangeGridLines(wxDC& dc, const wxRegion& reg, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight); - - // draw all lines from top to bottom row and left to right column in the - // rectangle determined by (top, left)-(bottom, right) -- but notice that - // the caller must have set up the clipping correctly, this rectangle is - // only used here for optimization - void DoDrawGridLines(wxDC& dc, - int top, int left, - int bottom, int right, - int topRow, int leftCol, - int bottomRight, int rightCol); - - // common part of Clip{Horz,Vert}GridLines - void DoClipGridLines(bool& var, bool clip); - - // update the sorting indicator shown in the specified column (whose index - // must be valid) - // - // this will use GetSortingColumn() and IsSortOrderAscending() to determine - // the sorting indicator to effectively show - void UpdateColumnSortingIndicator(int col); - - // update the grid after changing the columns order (common part of - // SetColPos() and ResetColPos()) - void RefreshAfterColPosChange(); - - - // return the position (not index) of the column at the given logical pixel - // position - // - // this always returns a valid position, even if the coordinate is out of - // bounds (in which case first/last column is returned) - int XToPos(int x) const; - - - // event handlers and their helpers - // -------------------------------- - - // process mouse drag event in WXGRID_CURSOR_SELECT_CELL mode - bool DoGridCellDrag(wxMouseEvent& event, - const wxGridCellCoords& coords, - bool isFirstDrag); - - // process row/column resizing drag event - void DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper); - - // process mouse drag event in the grid window - void DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords); - - // process different clicks on grid cells - void DoGridCellLeftDown(wxMouseEvent& event, - const wxGridCellCoords& coords, - const wxPoint& pos); - void DoGridCellLeftDClick(wxMouseEvent& event, - const wxGridCellCoords& coords, - const wxPoint& pos); - void DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords); - - // process movement (but not dragging) event in the grid cell area - void DoGridMouseMoveEvent(wxMouseEvent& event, - const wxGridCellCoords& coords, - const wxPoint& pos); - - // process mouse events in the grid window - void ProcessGridCellMouseEvent(wxMouseEvent& event); - - // process mouse events in the row/column labels/corner windows - void ProcessRowLabelMouseEvent(wxMouseEvent& event); - void ProcessColLabelMouseEvent(wxMouseEvent& event); - void ProcessCornerLabelMouseEvent(wxMouseEvent& event); - - void DoColHeaderClick(int col); - - void DoStartResizeCol(int col); - void DoUpdateResizeCol(int x); - void DoUpdateResizeColWidth(int w); - void DoStartMoveCol(int col); - - void DoEndDragResizeRow(const wxMouseEvent& event); - void DoEndDragResizeCol(const wxMouseEvent& event); - void DoEndMoveCol(int pos); - - // process a TAB keypress - void DoGridProcessTab(wxKeyboardState& kbdState); - - // common implementations of methods defined for both rows and columns - void DeselectLine(int line, const wxGridOperations& oper); - bool DoEndDragResizeLine(const wxGridOperations& oper); - int PosToLinePos(int pos, bool clipToMinMax, - const wxGridOperations& oper) const; - int PosToLine(int pos, bool clipToMinMax, - const wxGridOperations& oper) const; - int PosToEdgeOfLine(int pos, const wxGridOperations& oper) const; - - bool DoMoveCursor(bool expandSelection, - const wxGridDirectionOperations& diroper); - bool DoMoveCursorByPage(const wxGridDirectionOperations& diroper); - bool DoMoveCursorByBlock(bool expandSelection, - const wxGridDirectionOperations& diroper); - void AdvanceToNextNonEmpty(wxGridCellCoords& coords, - const wxGridDirectionOperations& diroper); - - // common part of {Insert,Delete}{Rows,Cols} - bool DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t), - int pos, int num, bool updateLabels); - // Append{Rows,Cols} is a bit different because of one less parameter - bool DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t), - int num, bool updateLabels); - - // common part of Set{Col,Row}Sizes - void DoSetSizes(const wxGridSizesInfo& sizeInfo, - const wxGridOperations& oper); - - // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size - void DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed); - bool DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const; - - // Helper of Render(): get grid size, origin offset and fill cell arrays - void GetRenderSizes( const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - wxPoint& pointOffSet, wxSize& sizeGrid, - wxGridCellCoordsArray& renderCells, - wxArrayInt& arrayCols, wxArrayInt& arrayRows ); - - // Helper of Render(): set the scale to draw the cells at the right size. - void SetRenderScale( wxDC& dc, const wxPoint& pos, const wxSize& size, - const wxSize& sizeGrid ); - - // Helper of Render(): get render start position from passed parameter - wxPoint GetRenderPosition( wxDC& dc, const wxPoint& position ); - - // Helper of Render(): draws a box around the rendered area - void DoRenderBox( wxDC& dc, const int& style, - const wxPoint& pointOffSet, - const wxSize& sizeCellArea, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight ); - - // Implementation of public Set{Row,Col}Size() and {Hide,Show}{Row,Col}(). - // They interpret their height or width parameter slightly different from - // the public methods where -1 in it means "auto fit to the label" for the - // compatibility reasons. Here it means "show a previously hidden row or - // column" while 0 means "hide it" just as in the public methods. And any - // positive values are handled naturally, i.e. they just specify the size. - void DoSetRowSize( int row, int height ); - void DoSetColSize( int col, int width ); - - - // these sets contain the indices of fixed, i.e. non-resizable - // interactively, grid rows or columns and are NULL if there are no fixed - // elements (which is the default) - wxGridFixedIndicesSet *m_setFixedRows, - *m_setFixedCols; - - DECLARE_DYNAMIC_CLASS( wxGrid ) - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGrid); -}; - -// ---------------------------------------------------------------------------- -// wxGridUpdateLocker prevents updates to a grid during its lifetime -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridUpdateLocker -{ -public: - // if the pointer is NULL, Create() can be called later - wxGridUpdateLocker(wxGrid *grid = NULL) - { - Init(grid); - } - - // can be called if ctor was used with a NULL pointer, must not be called - // more than once - void Create(wxGrid *grid) - { - wxASSERT_MSG( !m_grid, wxT("shouldn't be called more than once") ); - - Init(grid); - } - - ~wxGridUpdateLocker() - { - if ( m_grid ) - m_grid->EndBatch(); - } - -private: - void Init(wxGrid *grid) - { - m_grid = grid; - if ( m_grid ) - m_grid->BeginBatch(); - } - - wxGrid *m_grid; - - wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker); -}; - -// ---------------------------------------------------------------------------- -// Grid event class and event types -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent, - public wxKeyboardState -{ -public: - wxGridEvent() - : wxNotifyEvent() - { - Init(-1, -1, -1, -1, false); - } - - wxGridEvent(int id, - wxEventType type, - wxObject* obj, - int row = -1, int col = -1, - int x = -1, int y = -1, - bool sel = true, - const wxKeyboardState& kbd = wxKeyboardState()) - : wxNotifyEvent(type, id), - wxKeyboardState(kbd) - { - Init(row, col, x, y, sel); - SetEventObject(obj); - } - - // explicitly specifying inline allows gcc < 3.4 to - // handle the deprecation attribute even in the constructor. - wxDEPRECATED_CONSTRUCTOR( - wxGridEvent(int id, - wxEventType type, - wxObject* obj, - int row, int col, - int x, int y, - bool sel, - bool control, - bool shift = false, bool alt = false, bool meta = false)); - - virtual int GetRow() { return m_row; } - virtual int GetCol() { return m_col; } - wxPoint GetPosition() { return wxPoint( m_x, m_y ); } - bool Selecting() { return m_selecting; } - - virtual wxEvent *Clone() const { return new wxGridEvent(*this); } - -protected: - int m_row; - int m_col; - int m_x; - int m_y; - bool m_selecting; - -private: - void Init(int row, int col, int x, int y, bool sel) - { - m_row = row; - m_col = col; - m_x = x; - m_y = y; - m_selecting = sel; - } - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent) -}; - -class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent, - public wxKeyboardState -{ -public: - wxGridSizeEvent() - : wxNotifyEvent() - { - Init(-1, -1, -1); - } - - wxGridSizeEvent(int id, - wxEventType type, - wxObject* obj, - int rowOrCol = -1, - int x = -1, int y = -1, - const wxKeyboardState& kbd = wxKeyboardState()) - : wxNotifyEvent(type, id), - wxKeyboardState(kbd) - { - Init(rowOrCol, x, y); - - SetEventObject(obj); - } - - wxDEPRECATED_CONSTRUCTOR( - wxGridSizeEvent(int id, - wxEventType type, - wxObject* obj, - int rowOrCol, - int x, int y, - bool control, - bool shift = false, - bool alt = false, - bool meta = false) ); - - int GetRowOrCol() { return m_rowOrCol; } - wxPoint GetPosition() { return wxPoint( m_x, m_y ); } - - virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); } - -protected: - int m_rowOrCol; - int m_x; - int m_y; - -private: - void Init(int rowOrCol, int x, int y) - { - m_rowOrCol = rowOrCol; - m_x = x; - m_y = y; - } - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent) -}; - - -class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent, - public wxKeyboardState -{ -public: - wxGridRangeSelectEvent() - : wxNotifyEvent() - { - Init(wxGridNoCellCoords, wxGridNoCellCoords, false); - } - - wxGridRangeSelectEvent(int id, - wxEventType type, - wxObject* obj, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - bool sel = true, - const wxKeyboardState& kbd = wxKeyboardState()) - : wxNotifyEvent(type, id), - wxKeyboardState(kbd) - { - Init(topLeft, bottomRight, sel); - - SetEventObject(obj); - } - - wxDEPRECATED_CONSTRUCTOR( - wxGridRangeSelectEvent(int id, - wxEventType type, - wxObject* obj, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - bool sel, - bool control, - bool shift = false, - bool alt = false, - bool meta = false) ); - - wxGridCellCoords GetTopLeftCoords() { return m_topLeft; } - wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; } - int GetTopRow() { return m_topLeft.GetRow(); } - int GetBottomRow() { return m_bottomRight.GetRow(); } - int GetLeftCol() { return m_topLeft.GetCol(); } - int GetRightCol() { return m_bottomRight.GetCol(); } - bool Selecting() { return m_selecting; } - - virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); } - -protected: - void Init(const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - bool selecting) - { - m_topLeft = topLeft; - m_bottomRight = bottomRight; - m_selecting = selecting; - } - - wxGridCellCoords m_topLeft; - wxGridCellCoords m_bottomRight; - bool m_selecting; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent) -}; - - -class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent -{ -public: - wxGridEditorCreatedEvent() - : wxCommandEvent() - { - m_row = 0; - m_col = 0; - m_ctrl = NULL; - } - - wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, - int row, int col, wxControl* ctrl); - - int GetRow() { return m_row; } - int GetCol() { return m_col; } - wxControl* GetControl() { return m_ctrl; } - void SetRow(int row) { m_row = row; } - void SetCol(int col) { m_col = col; } - void SetControl(wxControl* ctrl) { m_ctrl = ctrl; } - - virtual wxEvent *Clone() const { return new wxGridEditorCreatedEvent(*this); } - -private: - int m_row; - int m_col; - wxControl* m_ctrl; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent) -}; - - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SIZE, wxGridSizeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGING, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGED, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_SELECT_CELL, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_SHOWN, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_MOVE, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SORT, wxGridEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_TABBING, wxGridEvent ); - -typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); -typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); -typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); -typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&); - -#define wxGridEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxGridEventFunction, func) - -#define wxGridSizeEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func) - -#define wxGridRangeSelectEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func) - -#define wxGridEditorCreatedEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func) - -#define wx__DECLARE_GRIDEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn)) - -#define wx__DECLARE_GRIDSIZEEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridSizeEventHandler(fn)) - -#define wx__DECLARE_GRIDRANGESELEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridRangeSelectEventHandler(fn)) - -#define wx__DECLARE_GRIDEDITOREVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEditorCreatedEventHandler(fn)) - -#define EVT_GRID_CMD_CELL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_CLICK, id, fn) -#define EVT_GRID_CMD_CELL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_CLICK, id, fn) -#define EVT_GRID_CMD_CELL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_DCLICK, id, fn) -#define EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_DCLICK, id, fn) -#define EVT_GRID_CMD_LABEL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_CLICK, id, fn) -#define EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_CLICK, id, fn) -#define EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_DCLICK, id, fn) -#define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn) -#define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn) -#define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn) -#define EVT_GRID_CMD_COL_AUTO_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_AUTO_SIZE, id, fn) -#define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn) -#define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn) -#define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn) -#define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn) -#define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn) -#define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn) -#define EVT_GRID_CMD_EDITOR_SHOWN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_SHOWN, id, fn) -#define EVT_GRID_CMD_EDITOR_HIDDEN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_HIDDEN, id, fn) -#define EVT_GRID_CMD_EDITOR_CREATED(id, fn) wx__DECLARE_GRIDEDITOREVT(EDITOR_CREATED, id, fn) -#define EVT_GRID_CMD_CELL_BEGIN_DRAG(id, fn) wx__DECLARE_GRIDEVT(CELL_BEGIN_DRAG, id, fn) -#define EVT_GRID_CMD_TABBING(id, fn) wx__DECLARE_GRIDEVT(TABBING, id, fn) - -// same as above but for any id (exists mainly for backwards compatibility but -// then it's also true that you rarely have multiple grid in the same window) -#define EVT_GRID_CELL_LEFT_CLICK(fn) EVT_GRID_CMD_CELL_LEFT_CLICK(wxID_ANY, fn) -#define EVT_GRID_CELL_RIGHT_CLICK(fn) EVT_GRID_CMD_CELL_RIGHT_CLICK(wxID_ANY, fn) -#define EVT_GRID_CELL_LEFT_DCLICK(fn) EVT_GRID_CMD_CELL_LEFT_DCLICK(wxID_ANY, fn) -#define EVT_GRID_CELL_RIGHT_DCLICK(fn) EVT_GRID_CMD_CELL_RIGHT_DCLICK(wxID_ANY, fn) -#define EVT_GRID_LABEL_LEFT_CLICK(fn) EVT_GRID_CMD_LABEL_LEFT_CLICK(wxID_ANY, fn) -#define EVT_GRID_LABEL_RIGHT_CLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_CLICK(wxID_ANY, fn) -#define EVT_GRID_LABEL_LEFT_DCLICK(fn) EVT_GRID_CMD_LABEL_LEFT_DCLICK(wxID_ANY, fn) -#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn) -#define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn) -#define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn) -#define EVT_GRID_COL_AUTO_SIZE(fn) EVT_GRID_CMD_COL_AUTO_SIZE(wxID_ANY, fn) -#define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn) -#define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn) -#define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn) -#define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn) -#define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn) -#define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn) -#define EVT_GRID_EDITOR_SHOWN(fn) EVT_GRID_CMD_EDITOR_SHOWN(wxID_ANY, fn) -#define EVT_GRID_EDITOR_HIDDEN(fn) EVT_GRID_CMD_EDITOR_HIDDEN(wxID_ANY, fn) -#define EVT_GRID_EDITOR_CREATED(fn) EVT_GRID_CMD_EDITOR_CREATED(wxID_ANY, fn) -#define EVT_GRID_CELL_BEGIN_DRAG(fn) EVT_GRID_CMD_CELL_BEGIN_DRAG(wxID_ANY, fn) -#define EVT_GRID_TABBING(fn) EVT_GRID_CMD_TABBING(wxID_ANY, fn) - -// we used to have a single wxEVT_GRID_CELL_CHANGE event but it was split into -// wxEVT_GRID_CELL_CHANGING and CHANGED ones in wx 2.9.0, however the CHANGED -// is basically the same as the old CHANGE event so we keep the name for -// compatibility -#if WXWIN_COMPATIBILITY_2_8 - #define wxEVT_GRID_CELL_CHANGE wxEVT_GRID_CELL_CHANGED - - #define EVT_GRID_CMD_CELL_CHANGE EVT_GRID_CMD_CELL_CHANGED - #define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED -#endif // WXWIN_COMPATIBILITY_2_8 - -#if 0 // TODO: implement these ? others ? - -extern const int wxEVT_GRID_CREATE_CELL; -extern const int wxEVT_GRID_CHANGE_LABELS; -extern const int wxEVT_GRID_CHANGE_SEL_LABEL; - -#define EVT_GRID_CREATE_CELL(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), -#define EVT_GRID_CHANGE_LABELS(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), -#define EVT_GRID_CHANGE_SEL_LABEL(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), - -#endif - -#endif // wxUSE_GRID -#endif // _WX_GENERIC_GRID_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/gridctrl.h b/Source/3rd Party/wx/include/wx/generic/gridctrl.h deleted file mode 100644 index efcb233c8..000000000 --- a/Source/3rd Party/wx/include/wx/generic/gridctrl.h +++ /dev/null @@ -1,276 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/gridctrl.h -// Purpose: wxGrid controls -// Author: Paul Gammans, Roger Gammans -// Modified by: -// Created: 11/04/2001 -// Copyright: (c) The Computer Surgery (paul@compsurg.co.uk) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_GRIDCTRL_H_ -#define _WX_GENERIC_GRIDCTRL_H_ - -#include "wx/grid.h" - -#if wxUSE_GRID - -#define wxGRID_VALUE_CHOICEINT wxT("choiceint") -#define wxGRID_VALUE_DATETIME wxT("datetime") - - -// the default renderer for the cells containing string data -class WXDLLIMPEXP_ADV wxGridCellStringRenderer : public wxGridCellRenderer -{ -public: - // draw the string - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - // return the string extent - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const - { return new wxGridCellStringRenderer; } - -protected: - // set the text colours before drawing - void SetTextColoursAndFont(const wxGrid& grid, - const wxGridCellAttr& attr, - wxDC& dc, - bool isSelected); - - // calc the string extent for given string/font - wxSize DoGetBestSize(const wxGridCellAttr& attr, - wxDC& dc, - const wxString& text); -}; - -// the default renderer for the cells containing numeric (long) data -class WXDLLIMPEXP_ADV wxGridCellNumberRenderer : public wxGridCellStringRenderer -{ -public: - // draw the string right aligned - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const - { return new wxGridCellNumberRenderer; } - -protected: - wxString GetString(const wxGrid& grid, int row, int col); -}; - -class WXDLLIMPEXP_ADV wxGridCellFloatRenderer : public wxGridCellStringRenderer -{ -public: - wxGridCellFloatRenderer(int width = -1, - int precision = -1, - int format = wxGRID_FLOAT_FORMAT_DEFAULT); - - // get/change formatting parameters - int GetWidth() const { return m_width; } - void SetWidth(int width) { m_width = width; m_format.clear(); } - int GetPrecision() const { return m_precision; } - void SetPrecision(int precision) { m_precision = precision; m_format.clear(); } - int GetFormat() const { return m_style; } - void SetFormat(int format) { m_style = format; m_format.clear(); } - - // draw the string right aligned with given width/precision - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - // parameters string format is "width[,precision[,format]]" - // with format being one of f|e|g|E|F|G - virtual void SetParameters(const wxString& params); - - virtual wxGridCellRenderer *Clone() const; - -protected: - wxString GetString(const wxGrid& grid, int row, int col); - -private: - // formatting parameters - int m_width, - m_precision; - - int m_style; - wxString m_format; -}; - -// renderer for boolean fields -class WXDLLIMPEXP_ADV wxGridCellBoolRenderer : public wxGridCellRenderer -{ -public: - // draw a check mark or nothing - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - // return the checkmark size - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const - { return new wxGridCellBoolRenderer; } - -private: - static wxSize ms_sizeCheckMark; -}; - - -#if wxUSE_DATETIME - -#include "wx/datetime.h" - -// the default renderer for the cells containing times and dates -class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer -{ -public: - wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, - const wxString& informat = wxDefaultDateTimeFormat); - - // draw the string right aligned - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const; - - // output strptime()-like format string - virtual void SetParameters(const wxString& params); - -protected: - wxString GetString(const wxGrid& grid, int row, int col); - - wxString m_iformat; - wxString m_oformat; - wxDateTime m_dateDef; - wxDateTime::TimeZone m_tz; -}; - -#endif // wxUSE_DATETIME - -// renders a number using the corresponding text string -class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellStringRenderer -{ -public: - wxGridCellEnumRenderer( const wxString& choices = wxEmptyString ); - - // draw the string right aligned - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const; - - // parameters string format is "item1[,item2[...,itemN]]" where itemN will - // be used if the cell value is N-1 - virtual void SetParameters(const wxString& params); - -protected: - wxString GetString(const wxGrid& grid, int row, int col); - - wxArrayString m_choices; -}; - - -class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer -{ -public: - wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { } - - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected); - - virtual wxSize GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col); - - virtual wxGridCellRenderer *Clone() const - { return new wxGridCellAutoWrapStringRenderer; } - -private: - wxArrayString GetTextLines( wxGrid& grid, - wxDC& dc, - const wxGridCellAttr& attr, - const wxRect& rect, - int row, int col); - - // Helper methods of GetTextLines() - - // Break a single logical line of text into several physical lines, all of - // which are added to the lines array. The lines are broken at maxWidth and - // the dc is used for measuring text extent only. - void BreakLine(wxDC& dc, - const wxString& logicalLine, - wxCoord maxWidth, - wxArrayString& lines); - - // Break a word, which is supposed to be wider than maxWidth, into several - // lines, which are added to lines array and the last, incomplete, of which - // is returned in line output parameter. - // - // Returns the width of the last line. - wxCoord BreakWord(wxDC& dc, - const wxString& word, - wxCoord maxWidth, - wxArrayString& lines, - wxString& line); - - -}; - -#endif // wxUSE_GRID -#endif // _WX_GENERIC_GRIDCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/grideditors.h b/Source/3rd Party/wx/include/wx/generic/grideditors.h deleted file mode 100644 index b5986e422..000000000 --- a/Source/3rd Party/wx/include/wx/generic/grideditors.h +++ /dev/null @@ -1,378 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/grideditors.h -// Purpose: wxGridCellEditorEvtHandler and wxGrid editors -// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) -// Modified by: Santiago Palacios -// Created: 1/08/1999 -// Copyright: (c) Michael Bedward -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_GRID_EDITORS_H_ -#define _WX_GENERIC_GRID_EDITORS_H_ - -#include "wx/defs.h" - -#if wxUSE_GRID - -#include "wx/scopedptr.h" - -class wxGridCellEditorEvtHandler : public wxEvtHandler -{ -public: - wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor) - : m_grid(grid), - m_editor(editor), - m_inSetFocus(false) - { - } - - void OnKillFocus(wxFocusEvent& event); - void OnKeyDown(wxKeyEvent& event); - void OnChar(wxKeyEvent& event); - - void SetInSetFocus(bool inSetFocus) { m_inSetFocus = inSetFocus; } - -private: - wxGrid *m_grid; - wxGridCellEditor *m_editor; - - // Work around the fact that a focus kill event can be sent to - // a combobox within a set focus event. - bool m_inSetFocus; - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler) - wxDECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler); -}; - - -#if wxUSE_TEXTCTRL - -// the editor for string/text data -class WXDLLIMPEXP_ADV wxGridCellTextEditor : public wxGridCellEditor -{ -public: - wxEXPLICIT wxGridCellTextEditor(size_t maxChars = 0); - - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - virtual void SetSize(const wxRect& rect); - - virtual void PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr); - - virtual bool IsAcceptedKey(wxKeyEvent& event); - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - - virtual void Reset(); - virtual void StartingKey(wxKeyEvent& event); - virtual void HandleReturn(wxKeyEvent& event); - - // parameters string format is "max_width" - virtual void SetParameters(const wxString& params); -#if wxUSE_VALIDATORS - virtual void SetValidator(const wxValidator& validator); -#endif - - virtual wxGridCellEditor *Clone() const; - - // added GetValue so we can get the value which is in the control - virtual wxString GetValue() const; - -protected: - wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; } - - // parts of our virtual functions reused by the derived classes - void DoCreate(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler, - long style = 0); - void DoBeginEdit(const wxString& startValue); - void DoReset(const wxString& startValue); - -private: - size_t m_maxChars; // max number of chars allowed -#if wxUSE_VALIDATORS - wxScopedPtr m_validator; -#endif - wxString m_value; - - wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor); -}; - -// the editor for numeric (long) data -class WXDLLIMPEXP_ADV wxGridCellNumberEditor : public wxGridCellTextEditor -{ -public: - // allows to specify the range - if min == max == -1, no range checking is - // done - wxGridCellNumberEditor(int min = -1, int max = -1); - - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - - virtual bool IsAcceptedKey(wxKeyEvent& event); - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - - virtual void Reset(); - virtual void StartingKey(wxKeyEvent& event); - - // parameters string format is "min,max" - virtual void SetParameters(const wxString& params); - - virtual wxGridCellEditor *Clone() const - { return new wxGridCellNumberEditor(m_min, m_max); } - - // added GetValue so we can get the value which is in the control - virtual wxString GetValue() const; - -protected: -#if wxUSE_SPINCTRL - wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; } -#endif - - // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl - bool HasRange() const - { -#if wxUSE_SPINCTRL - return m_min != m_max; -#else - return false; -#endif - } - - // string representation of our value - wxString GetString() const - { return wxString::Format(wxT("%ld"), m_value); } - -private: - int m_min, - m_max; - - long m_value; - - wxDECLARE_NO_COPY_CLASS(wxGridCellNumberEditor); -}; - - -enum wxGridCellFloatFormat -{ - // Decimal floating point (%f) - wxGRID_FLOAT_FORMAT_FIXED = 0x0010, - - // Scientific notation (mantise/exponent) using e character (%e) - wxGRID_FLOAT_FORMAT_SCIENTIFIC = 0x0020, - - // Use the shorter of %e or %f (%g) - wxGRID_FLOAT_FORMAT_COMPACT = 0x0040, - - // To use in combination with one of the above formats (%F/%E/%G) - wxGRID_FLOAT_FORMAT_UPPER = 0x0080, - - // Format used by default. - wxGRID_FLOAT_FORMAT_DEFAULT = wxGRID_FLOAT_FORMAT_FIXED, - - // A mask to extract format from the combination of flags. - wxGRID_FLOAT_FORMAT_MASK = wxGRID_FLOAT_FORMAT_FIXED | - wxGRID_FLOAT_FORMAT_SCIENTIFIC | - wxGRID_FLOAT_FORMAT_COMPACT | - wxGRID_FLOAT_FORMAT_UPPER -}; - -// the editor for floating point numbers (double) data -class WXDLLIMPEXP_ADV wxGridCellFloatEditor : public wxGridCellTextEditor -{ -public: - wxGridCellFloatEditor(int width = -1, - int precision = -1, - int format = wxGRID_FLOAT_FORMAT_DEFAULT); - - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - - virtual bool IsAcceptedKey(wxKeyEvent& event); - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - - virtual void Reset(); - virtual void StartingKey(wxKeyEvent& event); - - virtual wxGridCellEditor *Clone() const - { return new wxGridCellFloatEditor(m_width, m_precision); } - - // parameters string format is "width[,precision[,format]]" - // format to choose beween f|e|g|E|G (f is used by default) - virtual void SetParameters(const wxString& params); - -protected: - // string representation of our value - wxString GetString(); - -private: - int m_width, - m_precision; - double m_value; - - int m_style; - wxString m_format; - - wxDECLARE_NO_COPY_CLASS(wxGridCellFloatEditor); -}; - -#endif // wxUSE_TEXTCTRL - -#if wxUSE_CHECKBOX - -// the editor for boolean data -class WXDLLIMPEXP_ADV wxGridCellBoolEditor : public wxGridCellEditor -{ -public: - wxGridCellBoolEditor() { } - - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - - virtual void SetSize(const wxRect& rect); - virtual void Show(bool show, wxGridCellAttr *attr = NULL); - - virtual bool IsAcceptedKey(wxKeyEvent& event); - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - - virtual void Reset(); - virtual void StartingClick(); - virtual void StartingKey(wxKeyEvent& event); - - virtual wxGridCellEditor *Clone() const - { return new wxGridCellBoolEditor; } - - // added GetValue so we can get the value which is in the control, see - // also UseStringValues() - virtual wxString GetValue() const; - - // set the string values returned by GetValue() for the true and false - // states, respectively - static void UseStringValues(const wxString& valueTrue = wxT("1"), - const wxString& valueFalse = wxEmptyString); - - // return true if the given string is equal to the string representation of - // true value which we currently use - static bool IsTrueValue(const wxString& value); - -protected: - wxCheckBox *CBox() const { return (wxCheckBox *)m_control; } - -private: - bool m_value; - - static wxString ms_stringValues[2]; - - wxDECLARE_NO_COPY_CLASS(wxGridCellBoolEditor); -}; - -#endif // wxUSE_CHECKBOX - -#if wxUSE_COMBOBOX - -// the editor for string data allowing to choose from the list of strings -class WXDLLIMPEXP_ADV wxGridCellChoiceEditor : public wxGridCellEditor -{ -public: - // if !allowOthers, user can't type a string not in choices array - wxGridCellChoiceEditor(size_t count = 0, - const wxString choices[] = NULL, - bool allowOthers = false); - wxGridCellChoiceEditor(const wxArrayString& choices, - bool allowOthers = false); - - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - - virtual void SetSize(const wxRect& rect); - - virtual void PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr); - - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - - virtual void Reset(); - - // parameters string format is "item1[,item2[...,itemN]]" - virtual void SetParameters(const wxString& params); - - virtual wxGridCellEditor *Clone() const; - - // added GetValue so we can get the value which is in the control - virtual wxString GetValue() const; - -protected: - wxComboBox *Combo() const { return (wxComboBox *)m_control; } - - wxString m_value; - wxArrayString m_choices; - bool m_allowOthers; - - wxDECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor); -}; - -#endif // wxUSE_COMBOBOX - -#if wxUSE_COMBOBOX - -class WXDLLIMPEXP_ADV wxGridCellEnumEditor : public wxGridCellChoiceEditor -{ -public: - wxGridCellEnumEditor( const wxString& choices = wxEmptyString ); - virtual ~wxGridCellEnumEditor() {} - - virtual wxGridCellEditor* Clone() const; - - virtual void BeginEdit(int row, int col, wxGrid* grid); - virtual bool EndEdit(int row, int col, const wxGrid* grid, - const wxString& oldval, wxString *newval); - virtual void ApplyEdit(int row, int col, wxGrid* grid); - -private: - long m_index; - - wxDECLARE_NO_COPY_CLASS(wxGridCellEnumEditor); -}; - -#endif // wxUSE_COMBOBOX - -class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor -{ -public: - wxGridCellAutoWrapStringEditor() : wxGridCellTextEditor() { } - virtual void Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler); - - virtual wxGridCellEditor *Clone() const - { return new wxGridCellAutoWrapStringEditor; } - - wxDECLARE_NO_COPY_CLASS(wxGridCellAutoWrapStringEditor); -}; - -#endif // wxUSE_GRID - -#endif // _WX_GENERIC_GRID_EDITORS_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/gridsel.h b/Source/3rd Party/wx/include/wx/generic/gridsel.h deleted file mode 100644 index 76135532c..000000000 --- a/Source/3rd Party/wx/include/wx/generic/gridsel.h +++ /dev/null @@ -1,115 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/gridsel.h -// Purpose: wxGridSelection -// Author: Stefan Neis -// Modified by: -// Created: 20/02/2000 -// Copyright: (c) Stefan Neis -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_GRIDSEL_H_ -#define _WX_GENERIC_GRIDSEL_H_ - -#include "wx/defs.h" - -#if wxUSE_GRID - -#include "wx/grid.h" - -class WXDLLIMPEXP_ADV wxGridSelection -{ -public: - wxGridSelection(wxGrid *grid, - wxGrid::wxGridSelectionModes sel = wxGrid::wxGridSelectCells); - - bool IsSelection(); - bool IsInSelection(int row, int col); - bool IsInSelection(const wxGridCellCoords& coords) - { - return IsInSelection(coords.GetRow(), coords.GetCol()); - } - - void SetSelectionMode(wxGrid::wxGridSelectionModes selmode); - wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; } - void SelectRow(int row, const wxKeyboardState& kbd = wxKeyboardState()); - void SelectCol(int col, const wxKeyboardState& kbd = wxKeyboardState()); - void SelectBlock(int topRow, int leftCol, - int bottomRow, int rightCol, - const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true ); - void SelectBlock(const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true ) - { - SelectBlock(topLeft.GetRow(), topLeft.GetCol(), - bottomRight.GetRow(), bottomRight.GetCol(), - kbd, sendEvent); - } - - void SelectCell(int row, int col, - const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true); - void SelectCell(const wxGridCellCoords& coords, - const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true) - { - SelectCell(coords.GetRow(), coords.GetCol(), kbd, sendEvent); - } - - void ToggleCellSelection(int row, int col, - const wxKeyboardState& kbd = wxKeyboardState()); - void ToggleCellSelection(const wxGridCellCoords& coords, - const wxKeyboardState& kbd = wxKeyboardState()) - { - ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd); - } - - void ClearSelection(); - - void UpdateRows( size_t pos, int numRows ); - void UpdateCols( size_t pos, int numCols ); - -private: - int BlockContain( int topRow1, int leftCol1, - int bottomRow1, int rightCol1, - int topRow2, int leftCol2, - int bottomRow2, int rightCol2 ); - // returns 1, if Block1 contains Block2, - // -1, if Block2 contains Block1, - // 0, otherwise - - int BlockContainsCell( int topRow, int leftCol, - int bottomRow, int rightCol, - int row, int col ) - // returns 1, if Block contains Cell, - // 0, otherwise - { - return ( topRow <= row && row <= bottomRow && - leftCol <= col && col <= rightCol ); - } - - void SelectBlockNoEvent(int topRow, int leftCol, - int bottomRow, int rightCol) - { - SelectBlock(topRow, leftCol, bottomRow, rightCol, - wxKeyboardState(), false); - } - - wxGridCellCoordsArray m_cellSelection; - wxGridCellCoordsArray m_blockSelectionTopLeft; - wxGridCellCoordsArray m_blockSelectionBottomRight; - wxArrayInt m_rowSelection; - wxArrayInt m_colSelection; - - wxGrid *m_grid; - wxGrid::wxGridSelectionModes m_selectionMode; - - friend class WXDLLIMPEXP_FWD_ADV wxGrid; - - wxDECLARE_NO_COPY_CLASS(wxGridSelection); -}; - -#endif // wxUSE_GRID -#endif // _WX_GENERIC_GRIDSEL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/headerctrlg.h b/Source/3rd Party/wx/include/wx/generic/headerctrlg.h deleted file mode 100644 index d2eceb2bf..000000000 --- a/Source/3rd Party/wx/include/wx/generic/headerctrlg.h +++ /dev/null @@ -1,181 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/headerctrlg.h -// Purpose: Generic wxHeaderCtrl implementation -// Author: Vadim Zeitlin -// Created: 2008-12-01 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_HEADERCTRLG_H_ -#define _WX_GENERIC_HEADERCTRLG_H_ - -#include "wx/event.h" -#include "wx/vector.h" -#include "wx/overlay.h" - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase -{ -public: - wxHeaderCtrl() - { - Init(); - } - - wxHeaderCtrl(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr); - - virtual ~wxHeaderCtrl(); - -protected: - virtual wxSize DoGetBestSize() const; - - -private: - // implement base class pure virtuals - virtual void DoSetCount(unsigned int count); - virtual unsigned int DoGetCount() const; - virtual void DoUpdate(unsigned int idx); - - virtual void DoScrollHorz(int dx); - - virtual void DoSetColumnsOrder(const wxArrayInt& order); - virtual wxArrayInt DoGetColumnsOrder() const; - - // common part of all ctors - void Init(); - - // event handlers - void OnPaint(wxPaintEvent& event); - void OnMouse(wxMouseEvent& event); - void OnKeyDown(wxKeyEvent& event); - void OnCaptureLost(wxMouseCaptureLostEvent& event); - - // move the column with given idx at given position (this doesn't generate - // any events but does refresh the display) - void DoMoveCol(unsigned int idx, unsigned int pos); - - // return the horizontal start position of the given column in physical - // coordinates - int GetColStart(unsigned int idx) const; - - // and the end position - int GetColEnd(unsigned int idx) const; - - // refresh the given column [only]; idx must be valid - void RefreshCol(unsigned int idx); - - // refresh the given column if idx is valid - void RefreshColIfNotNone(unsigned int idx); - - // refresh all the controls starting from (and including) the given one - void RefreshColsAfter(unsigned int idx); - - // return the column at the given position or -1 if it is beyond the - // rightmost column and put true into onSeparator output parameter if the - // position is near the divider at the right end of this column (notice - // that this means that we return column 0 even if the position is over - // column 1 but close enough to the divider separating it from column 0) - unsigned int FindColumnAtPoint(int x, bool *onSeparator = NULL) const; - - // return true if a drag resizing operation is currently in progress - bool IsResizing() const; - - // return true if a drag reordering operation is currently in progress - bool IsReordering() const; - - // return true if any drag operation is currently in progress - bool IsDragging() const { return IsResizing() || IsReordering(); } - - // end any drag operation currently in progress (resizing or reordering) - void EndDragging(); - - // cancel the drag operation currently in progress and generate an event - // about it - void CancelDragging(); - - // start (if m_colBeingResized is -1) or continue resizing the column - // - // this generates wxEVT_HEADER_BEGIN_RESIZE/RESIZING events and can - // cancel the operation if the user handler decides so - void StartOrContinueResizing(unsigned int col, int xPhysical); - - // end the resizing operation currently in progress and generate an event - // about it with its cancelled flag set if xPhysical is -1 - void EndResizing(int xPhysical); - - // same functions as above but for column moving/reordering instead of - // resizing - void StartReordering(unsigned int col, int xPhysical); - - // returns true if we did drag the column somewhere else or false if we - // didn't really move it -- in this case we consider that no reordering - // took place and that a normal column click event should be generated - bool EndReordering(int xPhysical); - - // constrain the given position to be larger than the start position of the - // given column plus its minimal width and return the effective width - int ConstrainByMinWidth(unsigned int col, int& xPhysical); - - // update the information displayed while a column is being moved around - void UpdateReorderingMarker(int xPhysical); - - // clear any overlaid markers - void ClearMarkers(); - - - // number of columns in the control currently - unsigned int m_numColumns; - - // index of the column under mouse or -1 if none - unsigned int m_hover; - - // the column being resized or -1 if there is no resizing operation in - // progress - unsigned int m_colBeingResized; - - // the column being moved or -1 if there is no reordering operation in - // progress - unsigned int m_colBeingReordered; - - // the distance from the start of m_colBeingReordered and the mouse - // position when the user started to drag it - int m_dragOffset; - - // the horizontal scroll offset - int m_scrollOffset; - - // the overlay display used during the dragging operations - wxOverlay m_overlay; - - // the indices of the column appearing at the given position on the display - // (its size is always m_numColumns) - wxArrayInt m_colIndices; - - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl); -}; - -#endif // _WX_GENERIC_HEADERCTRLG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/helpext.h b/Source/3rd Party/wx/include/wx/generic/helpext.h deleted file mode 100644 index fe0c3e7eb..000000000 --- a/Source/3rd Party/wx/include/wx/generic/helpext.h +++ /dev/null @@ -1,105 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/helpext.h -// Purpose: an external help controller for wxWidgets -// Author: Karsten Ballueder (Ballueder@usa.net) -// Modified by: -// Copyright: (c) Karsten Ballueder 1998 -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __WX_HELPEXT_H_ -#define __WX_HELPEXT_H_ - -#if wxUSE_HELP - - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/helpbase.h" - - -// ---------------------------------------------------------------------------- -// wxExtHelpController -// ---------------------------------------------------------------------------- - -// This class implements help via an external browser. -class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase -{ -public: - wxExtHelpController(wxWindow* parentWindow = NULL); - virtual ~wxExtHelpController(); - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED(void SetBrowser(const wxString& browsername = wxEmptyString, bool isNetscape = false) ); -#endif - - // Set viewer: new name for SetBrowser - virtual void SetViewer(const wxString& viewer = wxEmptyString, - long flags = wxHELP_NETSCAPE); - - virtual bool Initialize(const wxString& dir, int WXUNUSED(server)) - { return Initialize(dir); } - - virtual bool Initialize(const wxString& dir); - virtual bool LoadFile(const wxString& file = wxEmptyString); - virtual bool DisplayContents(void); - virtual bool DisplaySection(int sectionNo); - virtual bool DisplaySection(const wxString& section); - virtual bool DisplayBlock(long blockNo); - virtual bool KeywordSearch(const wxString& k, - wxHelpSearchMode mode = wxHELP_SEARCH_ALL); - - virtual bool Quit(void); - virtual void OnQuit(void); - - virtual bool DisplayHelp(const wxString &) ; - - virtual void SetFrameParameters(const wxString& WXUNUSED(title), - const wxSize& WXUNUSED(size), - const wxPoint& WXUNUSED(pos) = wxDefaultPosition, - bool WXUNUSED(newFrameEachTime) = false) - { - // does nothing by default - } - - virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = NULL, - wxPoint *WXUNUSED(pos) = NULL, - bool *WXUNUSED(newFrameEachTime) = NULL) - { - return NULL; // does nothing by default - } - -protected: - // Filename of currently active map file. - wxString m_helpDir; - - // How many entries do we have in the map file? - int m_NumOfEntries; - - // A list containing all id,url,documentation triples. - wxList *m_MapList; - -private: - // parse a single line of the map file (called by LoadFile()) - // - // return true if the line was valid or false otherwise - bool ParseMapFileLine(const wxString& line); - - // Deletes the list and all objects. - void DeleteList(void); - - - // How to call the html viewer. - wxString m_BrowserName; - - // Is the viewer a variant of netscape? - bool m_BrowserIsNetscape; - - DECLARE_CLASS(wxExtHelpController) -}; - -#endif // wxUSE_HELP - -#endif // __WX_HELPEXT_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/hyperlink.h b/Source/3rd Party/wx/include/wx/generic/hyperlink.h deleted file mode 100644 index eb7338886..000000000 --- a/Source/3rd Party/wx/include/wx/generic/hyperlink.h +++ /dev/null @@ -1,144 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/hyperlink.h -// Purpose: Hyperlink control -// Author: David Norris , Otto Wyss -// Modified by: Ryan Norton, Francesco Montorsi -// Created: 04/02/2005 -// Copyright: (c) 2005 David Norris -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERICHYPERLINKCTRL_H_ -#define _WX_GENERICHYPERLINKCTRL_H_ - -// ---------------------------------------------------------------------------- -// wxGenericHyperlinkCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGenericHyperlinkCtrl : public wxHyperlinkCtrlBase -{ -public: - // Default constructor (for two-step construction). - wxGenericHyperlinkCtrl() { Init(); } - - // Constructor. - wxGenericHyperlinkCtrl(wxWindow *parent, - wxWindowID id, - const wxString& label, const wxString& url, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHL_DEFAULT_STYLE, - const wxString& name = wxHyperlinkCtrlNameStr) - { - Init(); - (void) Create(parent, id, label, url, pos, size, style, name); - } - - // Creation function (for two-step construction). - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& label, const wxString& url, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHL_DEFAULT_STYLE, - const wxString& name = wxHyperlinkCtrlNameStr); - - - // get/set - wxColour GetHoverColour() const { return m_hoverColour; } - void SetHoverColour(const wxColour &colour) { m_hoverColour = colour; } - - wxColour GetNormalColour() const { return m_normalColour; } - void SetNormalColour(const wxColour &colour); - - wxColour GetVisitedColour() const { return m_visitedColour; } - void SetVisitedColour(const wxColour &colour); - - wxString GetURL() const { return m_url; } - void SetURL (const wxString &url) { m_url=url; } - - void SetVisited(bool visited = true) { m_visited=visited; } - bool GetVisited() const { return m_visited; } - - // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour, - // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important ! - - -protected: - // Helper used by this class itself and native MSW implementation that - // connects OnRightUp() and OnPopUpCopy() handlers. - void ConnectMenuHandlers(); - - // event handlers - - // Renders the hyperlink. - void OnPaint(wxPaintEvent& event); - - // Handle set/kill focus events (invalidate for painting focus rect) - void OnFocus(wxFocusEvent& event); - - // Fire a HyperlinkEvent on space - void OnChar(wxKeyEvent& event); - - // Returns the wxRect of the label of this hyperlink. - // This is different from the clientsize's rectangle when - // clientsize != bestsize and this rectangle is influenced - // by the alignment of the label (wxHL_ALIGN_*). - wxRect GetLabelRect() const; - - // If the click originates inside the bounding box of the label, - // a flag is set so that an event will be fired when the left - // button is released. - void OnLeftDown(wxMouseEvent& event); - - // If the click both originated and finished inside the bounding box - // of the label, a HyperlinkEvent is fired. - void OnLeftUp(wxMouseEvent& event); - void OnRightUp(wxMouseEvent& event); - - // Changes the cursor to a hand, if the mouse is inside the label's - // bounding box. - void OnMotion(wxMouseEvent& event); - - // Changes the cursor back to the default, if necessary. - void OnLeaveWindow(wxMouseEvent& event); - - // handles "Copy URL" menuitem - void OnPopUpCopy(wxCommandEvent& event); - - // overridden base class virtuals - - // Returns the best size for the window, which is the size needed - // to display the text label. - virtual wxSize DoGetBestClientSize() const; - - // creates a context menu with "Copy URL" menuitem - virtual void DoContextMenu(const wxPoint &); - -private: - // Common part of all ctors. - void Init(); - - // URL associated with the link. This is transmitted inside - // the HyperlinkEvent fired when the user clicks on the label. - wxString m_url; - - // Foreground colours for various link types. - // NOTE: wxWindow::m_backgroundColour is used for background, - // wxWindow::m_foregroundColour is used to render non-visited links - wxColour m_hoverColour; - wxColour m_normalColour; - wxColour m_visitedColour; - - // True if the mouse cursor is inside the label's bounding box. - bool m_rollover; - - // True if the link has been clicked before. - bool m_visited; - - // True if a click is in progress (left button down) and the click - // originated inside the label's bounding box. - bool m_clicking; -}; - -#endif // _WX_GENERICHYPERLINKCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/icon.h b/Source/3rd Party/wx/include/wx/generic/icon.h deleted file mode 100644 index 7a336d37c..000000000 --- a/Source/3rd Party/wx/include/wx/generic/icon.h +++ /dev/null @@ -1,62 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/icon.h -// Purpose: wxIcon implementation for ports where it's same as wxBitmap -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_ICON_H_ -#define _WX_GENERIC_ICON_H_ - -#include "wx/bitmap.h" - -//----------------------------------------------------------------------------- -// wxIcon -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxIcon: public wxBitmap -{ -public: - wxIcon(); - - wxIcon(const char* const* bits); -#ifdef wxNEEDS_CHARPP - wxIcon(char **bits); -#endif - - // For compatibility with wxMSW where desired size is sometimes required to - // distinguish between multiple icons in a resource. - wxIcon( const wxString& filename, - wxBitmapType type = wxICON_DEFAULT_TYPE, - int WXUNUSED(desiredWidth)=-1, int WXUNUSED(desiredHeight)=-1 ) : - wxBitmap(filename, type) - { - } - - wxIcon(const wxIconLocation& loc) - : wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_ANY) - { - } - - bool LoadFile(const wxString& name, wxBitmapType flags, - int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) - { return wxBitmap::LoadFile(name, flags); } - - // unhide the base class version - virtual bool LoadFile(const wxString& name, - wxBitmapType flags = wxICON_DEFAULT_TYPE) - { return wxBitmap::LoadFile(name, flags); } - - // create from bitmap (which should have a mask unless it's monochrome): - // there shouldn't be any implicit bitmap -> icon conversion (i.e. no - // ctors, assignment operators...), but it's ok to have such function - void CopyFromBitmap(const wxBitmap& bmp); - -private: - DECLARE_DYNAMIC_CLASS(wxIcon) -}; - -#endif // _WX_GENERIC_ICON_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/imaglist.h b/Source/3rd Party/wx/include/wx/generic/imaglist.h deleted file mode 100644 index 8fc145e03..000000000 --- a/Source/3rd Party/wx/include/wx/generic/imaglist.h +++ /dev/null @@ -1,79 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/imaglist.h -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Copyright: (c) 1998 Robert Roebling and Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_IMAGLISTG_H_ -#define _WX_IMAGLISTG_H_ - -#include "wx/list.h" - -class WXDLLIMPEXP_FWD_CORE wxDC; -class WXDLLIMPEXP_FWD_CORE wxBitmap; -class WXDLLIMPEXP_FWD_CORE wxIcon; -class WXDLLIMPEXP_FWD_CORE wxColour; - - -class WXDLLIMPEXP_CORE wxGenericImageList: public wxObject -{ -public: - wxGenericImageList() { m_width = m_height = 0; } - wxGenericImageList( int width, int height, bool mask = true, int initialCount = 1 ); - virtual ~wxGenericImageList(); - bool Create( int width, int height, bool mask = true, int initialCount = 1 ); - bool Create(); - - virtual int GetImageCount() const; - virtual bool GetSize( int index, int &width, int &height ) const; - - int Add( const wxBitmap& bitmap ); - int Add( const wxBitmap& bitmap, const wxBitmap& mask ); - int Add( const wxBitmap& bitmap, const wxColour& maskColour ); - wxBitmap GetBitmap(int index) const; - wxIcon GetIcon(int index) const; - bool Replace( int index, const wxBitmap &bitmap ); - bool Replace( int index, const wxBitmap &bitmap, const wxBitmap& mask ); - bool Remove( int index ); - bool RemoveAll(); - - virtual bool Draw(int index, wxDC& dc, int x, int y, - int flags = wxIMAGELIST_DRAW_NORMAL, - bool solidBackground = false); - - // Internal use only - const wxBitmap *GetBitmapPtr(int index) const; -private: - wxObjectList m_images; - - int m_width; - int m_height; - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericImageList) -}; - -#ifndef wxHAS_NATIVE_IMAGELIST - -/* - * wxImageList has to be a real class or we have problems with - * the run-time information. - */ - -class WXDLLIMPEXP_CORE wxImageList: public wxGenericImageList -{ - DECLARE_DYNAMIC_CLASS(wxImageList) - -public: - wxImageList() {} - - wxImageList( int width, int height, bool mask = true, int initialCount = 1 ) - : wxGenericImageList(width, height, mask, initialCount) - { - } -}; -#endif // !wxHAS_NATIVE_IMAGELIST - -#endif // _WX_IMAGLISTG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/infobar.h b/Source/3rd Party/wx/include/wx/generic/infobar.h deleted file mode 100644 index cd751b1e9..000000000 --- a/Source/3rd Party/wx/include/wx/generic/infobar.h +++ /dev/null @@ -1,137 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/infobar.h -// Purpose: generic wxInfoBar class declaration -// Author: Vadim Zeitlin -// Created: 2009-07-28 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_INFOBAR_H_ -#define _WX_GENERIC_INFOBAR_H_ - -class WXDLLIMPEXP_FWD_CORE wxBitmapButton; -class WXDLLIMPEXP_FWD_CORE wxStaticBitmap; -class WXDLLIMPEXP_FWD_CORE wxStaticText; - -// ---------------------------------------------------------------------------- -// wxInfoBar -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxInfoBarGeneric : public wxInfoBarBase -{ -public: - // the usual ctors and Create() but remember that info bar is created - // hidden - wxInfoBarGeneric() { Init(); } - - wxInfoBarGeneric(wxWindow *parent, wxWindowID winid = wxID_ANY) - { - Init(); - Create(parent, winid); - } - - bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY); - - - // implement base class methods - // ---------------------------- - - virtual void ShowMessage(const wxString& msg, - int flags = wxICON_INFORMATION); - - virtual void Dismiss(); - - virtual void AddButton(wxWindowID btnid, const wxString& label = wxString()); - - virtual void RemoveButton(wxWindowID btnid); - - // methods specific to this version - // -------------------------------- - - // set the effect(s) to use when showing/hiding the bar, may be - // wxSHOW_EFFECT_NONE to disable any effects entirely - // - // by default, slide to bottom/top is used when it's positioned on the top - // of the window for showing/hiding it and top/bottom when it's positioned - // at the bottom - void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect) - { - m_showEffect = showEffect; - m_hideEffect = hideEffect; - } - - // get effect used when showing/hiding the window - wxShowEffect GetShowEffect() const; - wxShowEffect GetHideEffect() const; - - // set the duration of animation used when showing/hiding the bar, in ms - void SetEffectDuration(int duration) { m_effectDuration = duration; } - - // get the currently used effect animation duration - int GetEffectDuration() const { return m_effectDuration; } - - - // overridden base class methods - // ----------------------------- - - // setting the font of this window sets it for the text control inside it - // (default font is a larger and bold version of the normal one) - virtual bool SetFont(const wxFont& font); - -#if wxABI_VERSION >= 30001 - // same thing with the colour: this affects the text colour - virtual bool SetForegroundColour(const wxColor& colour); -#endif // 3.0.1+ - -protected: - // info bar shouldn't have any border by default, the colour difference - // between it and the main window separates it well enough - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - - // update the parent to take our new or changed size into account (notably - // should be called when we're shown or hidden) - void UpdateParent(); - -private: - // common part of all ctors - void Init(); - - // handler for the close button - void OnButton(wxCommandEvent& event); - - // show/hide the bar - void DoShow(); - void DoHide(); - - // determine the placement of the bar from its position in the containing - // sizer - enum BarPlacement - { - BarPlacement_Top, - BarPlacement_Bottom, - BarPlacement_Unknown - }; - - BarPlacement GetBarPlacement() const; - - - // different controls making up the bar - wxStaticBitmap *m_icon; - wxStaticText *m_text; - wxBitmapButton *m_button; - - // the effects to use when showing/hiding and duration for them: by default - // the effect is determined by the info bar automatically depending on its - // position and the default duration is used - wxShowEffect m_showEffect, - m_hideEffect; - int m_effectDuration; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric); -}; - -#endif // _WX_GENERIC_INFOBAR_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/laywin.h b/Source/3rd Party/wx/include/wx/generic/laywin.h deleted file mode 100644 index a38fd97fc..000000000 --- a/Source/3rd Party/wx/include/wx/generic/laywin.h +++ /dev/null @@ -1,227 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/laywin.h -// Purpose: Implements a simple layout algorithm, plus -// wxSashLayoutWindow which is an example of a window with -// layout-awareness (via event handlers). This is suited to -// IDE-style window layout. -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_LAYWIN_H_G_ -#define _WX_LAYWIN_H_G_ - -#if wxUSE_SASH - #include "wx/sashwin.h" -#endif // wxUSE_SASH - -#include "wx/event.h" - -class WXDLLIMPEXP_FWD_ADV wxQueryLayoutInfoEvent; -class WXDLLIMPEXP_FWD_ADV wxCalculateLayoutEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_QUERY_LAYOUT_INFO, wxQueryLayoutInfoEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_CALCULATE_LAYOUT, wxCalculateLayoutEvent ); - -enum wxLayoutOrientation -{ - wxLAYOUT_HORIZONTAL, - wxLAYOUT_VERTICAL -}; - -enum wxLayoutAlignment -{ - wxLAYOUT_NONE, - wxLAYOUT_TOP, - wxLAYOUT_LEFT, - wxLAYOUT_RIGHT, - wxLAYOUT_BOTTOM -}; - -// Not sure this is necessary -// Tell window which dimension we're sizing on -#define wxLAYOUT_LENGTH_Y 0x0008 -#define wxLAYOUT_LENGTH_X 0x0000 - -// Use most recently used length -#define wxLAYOUT_MRU_LENGTH 0x0010 - -// Only a query, so don't actually move it. -#define wxLAYOUT_QUERY 0x0100 - -/* - * This event is used to get information about window alignment, - * orientation and size. - */ - -class WXDLLIMPEXP_ADV wxQueryLayoutInfoEvent: public wxEvent -{ -public: - wxQueryLayoutInfoEvent(wxWindowID id = 0) - { - SetEventType(wxEVT_QUERY_LAYOUT_INFO); - m_requestedLength = 0; - m_flags = 0; - m_id = id; - m_alignment = wxLAYOUT_TOP; - m_orientation = wxLAYOUT_HORIZONTAL; - } - - // Read by the app - void SetRequestedLength(int length) { m_requestedLength = length; } - int GetRequestedLength() const { return m_requestedLength; } - - void SetFlags(int flags) { m_flags = flags; } - int GetFlags() const { return m_flags; } - - // Set by the app - void SetSize(const wxSize& size) { m_size = size; } - wxSize GetSize() const { return m_size; } - - void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; } - wxLayoutOrientation GetOrientation() const { return m_orientation; } - - void SetAlignment(wxLayoutAlignment align) { m_alignment = align; } - wxLayoutAlignment GetAlignment() const { return m_alignment; } - - virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); } - -protected: - int m_flags; - int m_requestedLength; - wxSize m_size; - wxLayoutOrientation m_orientation; - wxLayoutAlignment m_alignment; - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryLayoutInfoEvent) -}; - -typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&); - -#define wxQueryLayoutInfoEventHandler( func ) \ - wxEVENT_HANDLER_CAST( wxQueryLayoutInfoEventFunction, func ) - -#define EVT_QUERY_LAYOUT_INFO(func) \ - wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, wxID_ANY, wxID_ANY, wxQueryLayoutInfoEventHandler( func ), NULL ), - -/* - * This event is used to take a bite out of the available client area. - */ - -class WXDLLIMPEXP_ADV wxCalculateLayoutEvent: public wxEvent -{ -public: - wxCalculateLayoutEvent(wxWindowID id = 0) - { - SetEventType(wxEVT_CALCULATE_LAYOUT); - m_flags = 0; - m_id = id; - } - - // Read by the app - void SetFlags(int flags) { m_flags = flags; } - int GetFlags() const { return m_flags; } - - // Set by the app - void SetRect(const wxRect& rect) { m_rect = rect; } - wxRect GetRect() const { return m_rect; } - - virtual wxEvent *Clone() const { return new wxCalculateLayoutEvent(*this); } - -protected: - int m_flags; - wxRect m_rect; - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalculateLayoutEvent) -}; - -typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&); - -#define wxCalculateLayoutEventHandler( func ) wxEVENT_HANDLER_CAST(wxCalculateLayoutEventFunction, func) - -#define EVT_CALCULATE_LAYOUT(func) \ - wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, wxID_ANY, wxID_ANY, wxCalculateLayoutEventHandler( func ), NULL ), - -#if wxUSE_SASH - -// This is window that can remember alignment/orientation, does its own layout, -// and can provide sashes too. Useful for implementing docked windows with sashes in -// an IDE-style interface. -class WXDLLIMPEXP_ADV wxSashLayoutWindow: public wxSashWindow -{ -public: - wxSashLayoutWindow() - { - Init(); - } - - wxSashLayoutWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow")) - { - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow")); - -// Accessors - inline wxLayoutAlignment GetAlignment() const { return m_alignment; } - inline wxLayoutOrientation GetOrientation() const { return m_orientation; } - - inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; } - inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; } - - // Give the window default dimensions - inline void SetDefaultSize(const wxSize& size) { m_defaultSize = size; } - -// Event handlers - // Called by layout algorithm to allow window to take a bit out of the - // client rectangle, and size itself if not in wxLAYOUT_QUERY mode. - void OnCalculateLayout(wxCalculateLayoutEvent& event); - - // Called by layout algorithm to retrieve information about the window. - void OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event); - -private: - void Init(); - - wxLayoutAlignment m_alignment; - wxLayoutOrientation m_orientation; - wxSize m_defaultSize; - -private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxSashLayoutWindow) - DECLARE_EVENT_TABLE() -}; - -#endif // wxUSE_SASH - -class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame; -class WXDLLIMPEXP_FWD_CORE wxFrame; - -// This class implements the layout algorithm -class WXDLLIMPEXP_ADV wxLayoutAlgorithm: public wxObject -{ -public: - wxLayoutAlgorithm() {} - -#if wxUSE_MDI_ARCHITECTURE - // The MDI client window is sized to whatever's left over. - bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = NULL); -#endif // wxUSE_MDI_ARCHITECTURE - - // mainWindow is sized to whatever's left over. This function for backward - // compatibility; use LayoutWindow. - bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = NULL); - - // mainWindow is sized to whatever's left over. - bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = NULL); -}; - -#endif - // _WX_LAYWIN_H_G_ diff --git a/Source/3rd Party/wx/include/wx/generic/listctrl.h b/Source/3rd Party/wx/include/wx/generic/listctrl.h deleted file mode 100644 index a7bdebf6e..000000000 --- a/Source/3rd Party/wx/include/wx/generic/listctrl.h +++ /dev/null @@ -1,283 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/listctrl.h -// Purpose: Generic list control -// Author: Robert Roebling -// Created: 01/02/97 -// Copyright: (c) 1998 Robert Roebling and Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_LISTCTRL_H_ -#define _WX_GENERIC_LISTCTRL_H_ - -#include "wx/containr.h" -#include "wx/scrolwin.h" -#include "wx/textctrl.h" - -#if wxUSE_DRAG_AND_DROP -class WXDLLIMPEXP_FWD_CORE wxDropTarget; -#endif - -//----------------------------------------------------------------------------- -// internal classes -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxListHeaderWindow; -class WXDLLIMPEXP_FWD_CORE wxListMainWindow; - -//----------------------------------------------------------------------------- -// wxListCtrl -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericListCtrl: public wxNavigationEnabled, - public wxScrollHelper -{ -public: - - wxGenericListCtrl() : wxScrollHelper(this) - { - Init(); - } - - wxGenericListCtrl( wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxLC_ICON, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr) - : wxScrollHelper(this) - { - Create(parent, winid, pos, size, style, validator, name); - } - - virtual ~wxGenericListCtrl(); - - void Init(); - - bool Create( wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxLC_ICON, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr); - - bool GetColumn( int col, wxListItem& item ) const; - bool SetColumn( int col, const wxListItem& item ); - int GetColumnWidth( int col ) const; - bool SetColumnWidth( int col, int width); - int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think - wxRect GetViewRect() const; - - bool GetItem( wxListItem& info ) const; - bool SetItem( wxListItem& info ) ; - long SetItem( long index, int col, const wxString& label, int imageId = -1 ); - int GetItemState( long item, long stateMask ) const; - bool SetItemState( long item, long state, long stateMask); - bool SetItemImage( long item, int image, int selImage = -1 ); - bool SetItemColumnImage( long item, long column, int image ); - wxString GetItemText( long item, int col = 0 ) const; - void SetItemText( long item, const wxString& str ); - wxUIntPtr GetItemData( long item ) const; - bool SetItemPtrData(long item, wxUIntPtr data); - bool SetItemData(long item, long data) { return SetItemPtrData(item, data); } - bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const; - bool GetSubItemRect( long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const; - bool GetItemPosition( long item, wxPoint& pos ) const; - bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC - int GetItemCount() const; - int GetColumnCount() const; - void SetItemSpacing( int spacing, bool isSmall = false ); - wxSize GetItemSpacing() const; - void SetItemTextColour( long item, const wxColour& col); - wxColour GetItemTextColour( long item ) const; - void SetItemBackgroundColour( long item, const wxColour &col); - wxColour GetItemBackgroundColour( long item ) const; - void SetItemFont( long item, const wxFont &f); - wxFont GetItemFont( long item ) const; - int GetSelectedItemCount() const; - wxColour GetTextColour() const; - void SetTextColour(const wxColour& col); - long GetTopItem() const; - - void SetSingleStyle( long style, bool add = true ) ; - void SetWindowStyleFlag( long style ); - void RecreateWindow() {} - long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const; - wxImageList *GetImageList( int which ) const; - void SetImageList( wxImageList *imageList, int which ); - void AssignImageList( wxImageList *imageList, int which ); - bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC - - void ClearAll(); - bool DeleteItem( long item ); - bool DeleteAllItems(); - bool DeleteAllColumns(); - bool DeleteColumn( int col ); - - void SetItemCount(long count); - - wxTextCtrl *EditLabel(long item, - wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); - - // End label editing, optionally cancelling the edit -#if wxABI_VERSION >= 30002 - bool EndEditLabel(bool cancel); -#endif - - wxTextCtrl* GetEditControl() const; - void Edit( long item ) { EditLabel(item); } - - bool EnsureVisible( long item ); - long FindItem( long start, const wxString& str, bool partial = false ); - long FindItem( long start, wxUIntPtr data ); - long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC - long HitTest( const wxPoint& point, int& flags, long *pSubItem = NULL ) const; - long InsertItem(wxListItem& info); - long InsertItem( long index, const wxString& label ); - long InsertItem( long index, int imageIndex ); - long InsertItem( long index, const wxString& label, int imageIndex ); - bool ScrollList( int dx, int dy ); - bool SortItems( wxListCtrlCompare fn, wxIntPtr data ); - - // do we have a header window? - bool HasHeader() const - { return InReportView() && !HasFlag(wxLC_NO_HEADER); } - - // refresh items selectively (only useful for virtual list controls) - void RefreshItem(long item); - void RefreshItems(long itemFrom, long itemTo); - - virtual void EnableBellOnNoMatch(bool on = true); - -#if WXWIN_COMPATIBILITY_2_6 - // obsolete, don't use - wxDEPRECATED( int GetItemSpacing( bool isSmall ) const ); -#endif // WXWIN_COMPATIBILITY_2_6 - - - // overridden base class virtuals - // ------------------------------ - - virtual wxVisualAttributes GetDefaultAttributes() const - { - return GetClassDefaultAttributes(GetWindowVariant()); - } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - - virtual void Update(); - - - // implementation only from now on - // ------------------------------- - - // generic version extension, don't use in portable code - bool Update( long item ); - - void OnInternalIdle( ); - - // We have to hand down a few functions - virtual void Refresh(bool eraseBackground = true, - const wxRect *rect = NULL); - - virtual bool SetBackgroundColour( const wxColour &colour ); - virtual bool SetForegroundColour( const wxColour &colour ); - virtual wxColour GetBackgroundColour() const; - virtual wxColour GetForegroundColour() const; - virtual bool SetFont( const wxFont &font ); - virtual bool SetCursor( const wxCursor &cursor ); - -#if wxUSE_DRAG_AND_DROP - virtual void SetDropTarget( wxDropTarget *dropTarget ); - virtual wxDropTarget *GetDropTarget() const; -#endif - - virtual bool ShouldInheritColours() const { return false; } - - // implementation - // -------------- - - wxImageList *m_imageListNormal; - wxImageList *m_imageListSmall; - wxImageList *m_imageListState; // what's that ? - bool m_ownsImageListNormal, - m_ownsImageListSmall, - m_ownsImageListState; - wxListHeaderWindow *m_headerWin; - wxListMainWindow *m_mainWin; - -protected: - // Implement base class pure virtual methods. - long DoInsertColumn(long col, const wxListItem& info); - - - virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); - - virtual wxSize DoGetBestClientSize() const; - - // return the text for the given column of the given item - virtual wxString OnGetItemText(long item, long column) const; - - // return the icon for the given item. In report view, OnGetItemImage will - // only be called for the first column. See OnGetItemColumnImage for - // details. - virtual int OnGetItemImage(long item) const; - - // return the icon for the given item and column. - virtual int OnGetItemColumnImage(long item, long column) const; - - // it calls our OnGetXXX() functions - friend class WXDLLIMPEXP_FWD_CORE wxListMainWindow; - - virtual wxBorder GetDefaultBorder() const; - - virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); - -private: - void CreateOrDestroyHeaderWindowAsNeeded(); - void OnScroll( wxScrollWinEvent& event ); - void OnSize( wxSizeEvent &event ); - - // we need to return a special WM_GETDLGCODE value to process just the - // arrows but let the other navigation characters through -#if defined(__WXMSW__) && !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__) - virtual WXLRESULT - MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); -#endif // __WXMSW__ - - WX_FORWARD_TO_SCROLL_HELPER() - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericListCtrl) -}; - -#if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && (!(defined(__WXMAC__) && wxOSX_USE_CARBON) || defined(__WXUNIVERSAL__ )) -/* - * wxListCtrl has to be a real class or we have problems with - * the run-time information. - */ - -class WXDLLIMPEXP_CORE wxListCtrl: public wxGenericListCtrl -{ - DECLARE_DYNAMIC_CLASS(wxListCtrl) - -public: - wxListCtrl() {} - - wxListCtrl(wxWindow *parent, wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxLC_ICON, - const wxValidator &validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr) - : wxGenericListCtrl(parent, winid, pos, size, style, validator, name) - { - } - -}; -#endif // !__WXMSW__ || __WXUNIVERSAL__ - -#endif // _WX_GENERIC_LISTCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/logg.h b/Source/3rd Party/wx/include/wx/generic/logg.h index e96c34568..240b30fbd 100644 --- a/Source/3rd Party/wx/include/wx/generic/logg.h +++ b/Source/3rd Party/wx/include/wx/generic/logg.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: logg.h 41020 2006-09-05 20:47:48Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,10 +14,6 @@ #if wxUSE_GUI -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; -class WXDLLIMPEXP_FWD_CORE wxLogFrame; -class WXDLLIMPEXP_FWD_CORE wxWindow; - // ---------------------------------------------------------------------------- // the following log targets are only compiled in if the we're compiling the // GUI part (andnot just the base one) of the library, they're implemented in @@ -26,20 +23,20 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; #if wxUSE_TEXTCTRL // log everything to a text window (GUI only of course) -class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog +class WXDLLEXPORT wxLogTextCtrl : public wxLog { public: wxLogTextCtrl(wxTextCtrl *pTextCtrl); protected: // implement sink function - virtual void DoLogText(const wxString& msg); + virtual void DoLogString(const wxChar *szString, time_t t); private: // the control we use wxTextCtrl *m_pTextCtrl; - wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl); + DECLARE_NO_COPY_CLASS(wxLogTextCtrl) }; #endif // wxUSE_TEXTCTRL @@ -50,7 +47,7 @@ private: #if wxUSE_LOGGUI -class WXDLLIMPEXP_CORE wxLogGui : public wxLog +class WXDLLEXPORT wxLogGui : public wxLog { public: // ctor @@ -60,22 +57,11 @@ public: virtual void Flush(); protected: - virtual void DoLogRecord(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info); - - // return the title to be used for the log dialog, depending on m_bErrors - // and m_bWarnings values - wxString GetTitle() const; - - // return the icon (one of wxICON_XXX constants) to be used for the dialog - // depending on m_bErrors/m_bWarnings - int GetSeverityIcon() const; + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t); // empty everything void Clear(); - wxArrayString m_aMessages; // the log message texts wxArrayInt m_aSeverity; // one of wxLOG_XXX values wxArrayLong m_aTimes; // the time of each message @@ -83,19 +69,6 @@ protected: m_bWarnings, // any warnings? m_bHasMessages; // any messages at all? -private: - // this method is called to show a single log message, it uses - // wxMessageBox() by default - virtual void DoShowSingleLogMessage(const wxString& message, - const wxString& title, - int style); - - // this method is called to show multiple log messages, it uses wxLogDialog - virtual void DoShowMultipleLogMessages(const wxArrayString& messages, - const wxArrayInt& severities, - const wxArrayLong& times, - const wxString& title, - int style); }; #endif // wxUSE_LOGGUI @@ -103,17 +76,17 @@ private: // ---------------------------------------------------------------------------- // (background) log window: this class forwards all log messages to the log // target which was active when it was instantiated, but also collects them -// to the log window. This window has its own menu which allows the user to +// to the log window. This window has it's own menu which allows the user to // close it, clear the log contents or save it to the file. // ---------------------------------------------------------------------------- #if wxUSE_LOGWINDOW -class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough +class WXDLLEXPORT wxLogWindow : public wxLogPassThrough { public: - wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL) - const wxString& szTitle, // the title of the frame + wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL) + const wxChar *szTitle, // the title of the frame bool bShow = true, // show window immediately? bool bPassToOld = true); // pass messages to the old target? @@ -126,6 +99,9 @@ public: wxFrame *GetFrame() const; // overridables + // called immediately after the log frame creation allowing for + // any extra initializations + virtual void OnFrameCreate(wxFrame *frame); // called if the user closes the window interactively, will not be // called if it is destroyed for another reason (such as when program // exits) - return true from here to allow the frame to close, false @@ -136,12 +112,13 @@ public: virtual void OnFrameDelete(wxFrame *frame); protected: - virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg); + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t); + virtual void DoLogString(const wxChar *szString, time_t t); private: wxLogFrame *m_pLogFrame; // the log frame - wxDECLARE_NO_COPY_CLASS(wxLogWindow); + DECLARE_NO_COPY_CLASS(wxLogWindow) }; #endif // wxUSE_LOGWINDOW diff --git a/Source/3rd Party/wx/include/wx/generic/mask.h b/Source/3rd Party/wx/include/wx/generic/mask.h deleted file mode 100644 index f6aad1a86..000000000 --- a/Source/3rd Party/wx/include/wx/generic/mask.h +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/mask.h -// Purpose: generic implementation of wxMask -// Author: Vadim Zeitlin -// Created: 2006-09-28 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_MASKG_H_ -#define _WX_GENERIC_MASKG_H_ - -// ---------------------------------------------------------------------------- -// generic wxMask implementation -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMask : public wxMaskBase -{ -public: - wxMask() { } - wxMask(const wxBitmap& bitmap, const wxColour& colour) - { - InitFromColour(bitmap, colour); - } - -#if wxUSE_PALETTE - wxMask(const wxBitmap& bitmap, int paletteIndex) - { - Create(bitmap, paletteIndex); - } -#endif // wxUSE_PALETTE - - wxMask(const wxBitmap& bitmap) - { - InitFromMonoBitmap(bitmap); - } - - // implementation-only from now on - wxBitmap GetBitmap() const { return m_bitmap; } - -private: - // implement wxMaskBase pure virtuals - virtual void FreeData(); - virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour); - virtual bool InitFromMonoBitmap(const wxBitmap& bitmap); - - wxBitmap m_bitmap; - - DECLARE_DYNAMIC_CLASS(wxMask) -}; - -#endif // _WX_GENERIC_MASKG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/mdig.h b/Source/3rd Party/wx/include/wx/generic/mdig.h deleted file mode 100644 index 7c433edc4..000000000 --- a/Source/3rd Party/wx/include/wx/generic/mdig.h +++ /dev/null @@ -1,260 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/mdig.h -// Purpose: Generic MDI (Multiple Document Interface) classes -// Author: Hans Van Leemputten -// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes -// Created: 29/07/2002 -// Copyright: (c) 2002 Hans Van Leemputten -// (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_MDIG_H_ -#define _WX_GENERIC_MDIG_H_ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/panel.h" - -class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase; -class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent; -class WXDLLIMPEXP_FWD_CORE wxIcon; -class WXDLLIMPEXP_FWD_CORE wxIconBundle; -class WXDLLIMPEXP_FWD_CORE wxNotebook; - -#if wxUSE_GENERIC_MDI_AS_NATIVE - #define wxGenericMDIParentFrame wxMDIParentFrame - #define wxGenericMDIChildFrame wxMDIChildFrame - #define wxGenericMDIClientWindow wxMDIClientWindow -#else // !wxUSE_GENERIC_MDI_AS_NATIVE - class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame; - class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame; - class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow; -#endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE - -// ---------------------------------------------------------------------------- -// wxGenericMDIParentFrame -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericMDIParentFrame : public wxMDIParentFrameBase -{ -public: - wxGenericMDIParentFrame() { Init(); } - wxGenericMDIParentFrame(wxWindow *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr) - { - Init(); - - Create(parent, winid, title, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr); - - virtual ~wxGenericMDIParentFrame(); - - // implement base class pure virtuals - static bool IsTDI() { return true; } - - virtual void ActivateNext() { AdvanceActive(true); } - virtual void ActivatePrevious() { AdvanceActive(false); } - -#if wxUSE_MENUS - virtual void SetWindowMenu(wxMenu* pMenu); - - virtual void SetMenuBar(wxMenuBar *pMenuBar); -#endif // wxUSE_MENUS - - virtual wxGenericMDIClientWindow *OnCreateGenericClient(); - - - // implementation only from now on - void WXSetChildMenuBar(wxGenericMDIChildFrame *child); - void WXUpdateChildTitle(wxGenericMDIChildFrame *child); - void WXActivateChild(wxGenericMDIChildFrame *child); - void WXRemoveChild(wxGenericMDIChildFrame *child); - bool WXIsActiveChild(wxGenericMDIChildFrame *child) const; - bool WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const; - - // return the book control used by the client window to manage the pages - wxBookCtrlBase *GetBookCtrl() const; - -protected: -#if wxUSE_MENUS - wxMenuBar *m_pMyMenuBar; -#endif // wxUSE_MENUS - - // advance the activation forward or backwards - void AdvanceActive(bool forward); - -private: - void Init(); - -#if wxUSE_MENUS - void RemoveWindowMenu(wxMenuBar *pMenuBar); - void AddWindowMenu(wxMenuBar *pMenuBar); - - void OnWindowMenu(wxCommandEvent& event); -#endif // wxUSE_MENUS - - virtual bool ProcessEvent(wxEvent& event); - - void OnClose(wxCloseEvent& event); - - // return the client window, may be NULL if we hadn't been created yet - wxGenericMDIClientWindow *GetGenericClientWindow() const; - - // close all children, return false if any of them vetoed it - bool CloseAll(); - - - // this pointer is non-NULL if we're currently inside our ProcessEvent() - // and we forwarded the event to this child (as we do with menu events) - wxMDIChildFrameBase *m_childHandler; - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame) -}; - -// ---------------------------------------------------------------------------- -// wxGenericMDIChildFrame -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericMDIChildFrame : public wxTDIChildFrame -{ -public: - wxGenericMDIChildFrame() { Init(); } - wxGenericMDIChildFrame(wxGenericMDIParentFrame *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - Init(); - - Create(parent, winid, title, pos, size, style, name); - } - - bool Create(wxGenericMDIParentFrame *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - - virtual ~wxGenericMDIChildFrame(); - - // implement MDI operations - virtual void Activate(); - - -#if wxUSE_MENUS - virtual void SetMenuBar( wxMenuBar *menu_bar ); - virtual wxMenuBar *GetMenuBar() const; -#endif // wxUSE_MENUS - - virtual wxString GetTitle() const { return m_title; } - virtual void SetTitle(const wxString& title); - - virtual bool TryAfter(wxEvent& event); - - // implementation only from now on - - wxGenericMDIParentFrame* GetGenericMDIParent() const - { -#if wxUSE_GENERIC_MDI_AS_NATIVE - return GetMDIParent(); -#else // generic != native - return m_mdiParentGeneric; -#endif - } - -protected: - wxString m_title; - -#if wxUSE_MENUS - wxMenuBar *m_pMenuBar; -#endif // wxUSE_MENUS - -#if !wxUSE_GENERIC_MDI_AS_NATIVE - wxGenericMDIParentFrame *m_mdiParentGeneric; -#endif - -protected: - void Init(); - -private: - void OnMenuHighlight(wxMenuEvent& event); - void OnClose(wxCloseEvent& event); - - DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame) - DECLARE_EVENT_TABLE() - - friend class wxGenericMDIClientWindow; -}; - -// ---------------------------------------------------------------------------- -// wxGenericMDIClientWindow -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericMDIClientWindow : public wxMDIClientWindowBase -{ -public: - wxGenericMDIClientWindow() { } - - // unfortunately we need to provide our own version of CreateClient() - // because of the difference in the type of the first parameter and - // implement the base class pure virtual method in terms of it - // (CreateGenericClient() is virtual itself to allow customizing the client - // window creation by overriding it in the derived classes) - virtual bool CreateGenericClient(wxWindow *parent); - virtual bool CreateClient(wxMDIParentFrame *parent, - long WXUNUSED(style) = wxVSCROLL | wxHSCROLL) - { - return CreateGenericClient(parent); - } - - // implementation only - wxBookCtrlBase *GetBookCtrl() const; - wxGenericMDIChildFrame *GetChild(size_t pos) const; - int FindChild(wxGenericMDIChildFrame *child) const; - -private: - void PageChanged(int OldSelection, int newSelection); - - void OnPageChanged(wxBookCtrlEvent& event); - void OnSize(wxSizeEvent& event); - - // the notebook containing all MDI children as its pages - wxNotebook *m_notebook; - - DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow) -}; - -// ---------------------------------------------------------------------------- -// inline functions implementation -// ---------------------------------------------------------------------------- - -inline bool -wxGenericMDIParentFrame:: -WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const -{ - return child == m_childHandler; -} - -#endif // _WX_GENERIC_MDIG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/msgdlgg.h b/Source/3rd Party/wx/include/wx/generic/msgdlgg.h index 5792ec8d4..4776b106a 100644 --- a/Source/3rd Party/wx/include/wx/generic/msgdlgg.h +++ b/Source/3rd Party/wx/include/wx/generic/msgdlgg.h @@ -4,52 +4,41 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: msgdlgg.h 49765 2007-11-09 18:32:38Z DE $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_GENERIC_MSGDLGG_H_ -#define _WX_GENERIC_MSGDLGG_H_ +#ifndef __MSGDLGH_G__ +#define __MSGDLGH_G__ -class WXDLLIMPEXP_FWD_CORE wxSizer; +#include "wx/defs.h" +#include "wx/dialog.h" -class WXDLLIMPEXP_CORE wxGenericMessageDialog : public wxMessageDialogBase +// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO +// Returns wxYES/NO/OK/CANCEL + +extern WXDLLEXPORT_DATA(const wxChar) wxMessageBoxCaptionStr[]; + +class WXDLLEXPORT wxGenericMessageDialog: public wxDialog, public wxMessageDialogBase { +DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog) + public: - wxGenericMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, - const wxPoint& pos = wxDefaultPosition); - - virtual int ShowModal(); - -protected: - // Creates a message dialog taking any options that have been set after - // object creation into account such as custom labels. - void DoCreateMsgdialog(); + wxGenericMessageDialog(wxWindow *parent, const wxString& message, + const wxString& caption = wxMessageBoxCaptionStr, + long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition); void OnYes(wxCommandEvent& event); void OnNo(wxCommandEvent& event); - void OnHelp(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); - // can be overridden to provide more contents to the dialog - virtual void AddMessageDialogCheckBox(wxSizer *WXUNUSED(sizer)) { } - virtual void AddMessageDialogDetails(wxSizer *WXUNUSED(sizer)) { } - private: - // Creates and returns a standard button sizer using the style of this - // dialog and the custom labels, if any. - // - // May return NULL on smart phone platforms not using buttons at all. - wxSizer *CreateMsgDlgButtonSizer(); - - wxPoint m_pos; - bool m_created; - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog) }; -#endif // _WX_GENERIC_MSGDLGG_H_ +#if (!defined( __WXMSW__ ) && !defined( __WXMAC__) && !defined(__WXPM__) && !defined(__WXCOCOA__)) || defined(__WXUNIVERSAL__) +#define wxMessageDialog wxGenericMessageDialog +#endif + +#endif // __MSGDLGH_G__ diff --git a/Source/3rd Party/wx/include/wx/generic/notebook.h b/Source/3rd Party/wx/include/wx/generic/notebook.h index 964585cf8..5b96a204b 100644 --- a/Source/3rd Party/wx/include/wx/generic/notebook.h +++ b/Source/3rd Party/wx/include/wx/generic/notebook.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/notebook.h +// Name: notebook.h // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog) // Author: Julian Smart // Modified by: +// RCS-ID: $Id: notebook.h 41738 2006-10-08 17:37:23Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,9 +22,9 @@ // ---------------------------------------------------------------------------- // fwd declarations -class WXDLLIMPEXP_FWD_CORE wxImageList; -class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLIMPEXP_FWD_CORE wxTabView; +class WXDLLEXPORT wxImageList; +class WXDLLEXPORT wxWindow; +class WXDLLEXPORT wxTabView; // ---------------------------------------------------------------------------- // wxNotebook @@ -55,15 +56,17 @@ public: // accessors // --------- - // Find the position of the wxNotebookPage, wxNOT_FOUND if not found. + // Find the position of the wxNotebookPage, -1 if not found. int FindPagePosition(wxNotebookPage* page) const; // set the currently selected page, return the index of the previously - // selected one (or wxNOT_FOUND on error) + // selected one (or -1 on error) // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events int SetSelection(size_t nPage); // cycle thru the tabs // void AdvanceSelection(bool bForward = true); + // get the currently selected page + int GetSelection() const { return m_nSelection; } // changes selected page without sending events int ChangeSelection(size_t nPage); @@ -106,13 +109,13 @@ public: wxNotebookPage *pPage, const wxString& strText, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = -1); // callbacks // --------- void OnSize(wxSizeEvent& event); void OnInternalIdle(); - void OnSelChange(wxBookCtrlEvent& event); + void OnSelChange(wxNotebookEvent& event); void OnSetFocus(wxFocusEvent& event); void OnNavigationKey(wxNavigationKeyEvent& event); @@ -146,6 +149,8 @@ protected: // helper functions void ChangePage(int nOldSel, int nSel); // change pages + int m_nSelection; // the current selection (-1 if none) + wxTabView* m_tabView; DECLARE_DYNAMIC_CLASS(wxNotebook) diff --git a/Source/3rd Party/wx/include/wx/generic/notifmsg.h b/Source/3rd Party/wx/include/wx/generic/notifmsg.h deleted file mode 100644 index 1cd74ba7f..000000000 --- a/Source/3rd Party/wx/include/wx/generic/notifmsg.h +++ /dev/null @@ -1,60 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/notifmsg.h -// Purpose: generic implementation of wxGenericNotificationMessage -// Author: Vadim Zeitlin -// Created: 2007-11-24 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_NOTIFMSG_H_ -#define _WX_GENERIC_NOTIFMSG_H_ - -class wxNotificationMessageDialog; - -// ---------------------------------------------------------------------------- -// wxGenericNotificationMessage -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxGenericNotificationMessage : public wxNotificationMessageBase -{ -public: - wxGenericNotificationMessage() { Init(); } - wxGenericNotificationMessage(const wxString& title, - const wxString& message = wxString(), - wxWindow *parent = NULL, - int flags = wxICON_INFORMATION) - : wxNotificationMessageBase(title, message, parent, flags) - { - Init(); - } - - virtual ~wxGenericNotificationMessage(); - - - virtual bool Show(int timeout = Timeout_Auto); - virtual bool Close(); - - // generic implementation-specific methods - - // get/set the default timeout (used if Timeout_Auto is specified) - static int GetDefaultTimeout() { return ms_timeout; } - static void SetDefaultTimeout(int timeout); - -private: - void Init(); - - - // default timeout - static int ms_timeout; - - // notification message is represented by a modeless dialog in this - // implementation - wxNotificationMessageDialog *m_dialog; - - - wxDECLARE_NO_COPY_CLASS(wxGenericNotificationMessage); -}; - -#endif // _WX_GENERIC_NOTIFMSG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/numdlgg.h b/Source/3rd Party/wx/include/wx/generic/numdlgg.h index 34309462c..cbebd0918 100644 --- a/Source/3rd Party/wx/include/wx/generic/numdlgg.h +++ b/Source/3rd Party/wx/include/wx/generic/numdlgg.h @@ -4,6 +4,7 @@ // Author: John Labenski // Modified by: // Created: 07.02.04 (extracted from textdlgg.cpp) +// RCS-ID: $Id: numdlgg.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,7 +28,7 @@ // wxNumberEntryDialog: a dialog with spin control, [ok] and [cancel] buttons // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxNumberEntryDialog : public wxDialog +class WXDLLEXPORT wxNumberEntryDialog : public wxDialog { public: wxNumberEntryDialog(wxWindow *parent, @@ -56,22 +57,22 @@ protected: private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxNumberEntryDialog) - wxDECLARE_NO_COPY_CLASS(wxNumberEntryDialog); + DECLARE_NO_COPY_CLASS(wxNumberEntryDialog) }; // ---------------------------------------------------------------------------- // function to get a number from user // ---------------------------------------------------------------------------- -WXDLLIMPEXP_CORE long - wxGetNumberFromUser(const wxString& message, - const wxString& prompt, - const wxString& caption, - long value = 0, - long min = 0, - long max = 100, - wxWindow *parent = NULL, - const wxPoint& pos = wxDefaultPosition); +long WXDLLEXPORT +wxGetNumberFromUser(const wxString& message, + const wxString& prompt, + const wxString& caption, + long value = 0, + long min = 0, + long max = 100, + wxWindow *parent = (wxWindow *)NULL, + const wxPoint& pos = wxDefaultPosition); #endif // wxUSE_NUMBERDLG diff --git a/Source/3rd Party/wx/include/wx/generic/paletteg.h b/Source/3rd Party/wx/include/wx/generic/paletteg.h deleted file mode 100644 index 0f6f5a491..000000000 --- a/Source/3rd Party/wx/include/wx/generic/paletteg.h +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/paletteg.h -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Copyright: (c) 1998 Robert Roebling and Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __WX_PALETTEG_H__ -#define __WX_PALETTEG_H__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/gdiobj.h" -#include "wx/gdicmn.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxPalette; - -//----------------------------------------------------------------------------- -// wxPalette -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPalette: public wxPaletteBase -{ -public: - wxPalette(); - wxPalette( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue ); - virtual ~wxPalette(); - - bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); - int GetPixel( unsigned char red, unsigned char green, unsigned char blue ) const; - bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const; - - virtual int GetColoursCount() const; - -protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - -private: - DECLARE_DYNAMIC_CLASS(wxPalette) -}; - -#endif // __WX_PALETTEG_H__ diff --git a/Source/3rd Party/wx/include/wx/generic/panelg.h b/Source/3rd Party/wx/include/wx/generic/panelg.h index 5c02cb35d..f211a995c 100644 --- a/Source/3rd Party/wx/include/wx/generic/panelg.h +++ b/Source/3rd Party/wx/include/wx/generic/panelg.h @@ -4,19 +4,45 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: panelg.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_GENERIC_PANELG_H_ -#define _WX_GENERIC_PANELG_H_ +#ifndef _WX_GENERIC_PANEL_H_ +#define _WX_GENERIC_PANEL_H_ -#include "wx/bitmap.h" +// ---------------------------------------------------------------------------- +// headers and forward declarations +// ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPanel : public wxPanelBase +#include "wx/window.h" +#include "wx/containr.h" + +class WXDLLIMPEXP_FWD_CORE wxControlContainer; + +extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[]; + +// ---------------------------------------------------------------------------- +// wxPanel contains other controls and implements TAB traversal between them +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxPanel : public wxWindow { public: - wxPanel() { } + wxPanel() { Init(); } + + // Old-style constructor (no default values for coordinates to avoid + // ambiguity with the new one) + wxPanel(wxWindow *parent, + int x, int y, int width, int height, + long style = wxTAB_TRAVERSAL | wxNO_BORDER, + const wxString& name = wxPanelNameStr) + { + Init(); + + Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name); + } // Constructor wxPanel(wxWindow *parent, @@ -26,23 +52,44 @@ public: long style = wxTAB_TRAVERSAL | wxNO_BORDER, const wxString& name = wxPanelNameStr) { + Init(); + Create(parent, winid, pos, size, style, name); } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_CONSTRUCTOR( - wxPanel(wxWindow *parent, - int x, int y, int width, int height, - long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxPanelNameStr) - { - Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name); - } - ) -#endif // WXWIN_COMPATIBILITY_2_8 + // Pseudo ctor + bool Create(wxWindow *parent, + wxWindowID winid = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL | wxNO_BORDER, + const wxString& name = wxPanelNameStr); + + virtual ~wxPanel(); + + // implementation from now on + // -------------------------- + + // calls layout for layout constraints and sizers + void OnSize(wxSizeEvent& event); + + virtual void InitDialog(); + +#ifdef __WXUNIVERSAL__ + virtual bool IsCanvasWindow() const { return true; } +#endif + + + WX_DECLARE_CONTROL_CONTAINER(); + +protected: + // common part of all ctors + void Init(); private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel) + DECLARE_EVENT_TABLE() }; -#endif // _WX_GENERIC_PANELG_H_ +#endif + // _WX_GENERIC_PANEL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/printps.h b/Source/3rd Party/wx/include/wx/generic/printps.h deleted file mode 100644 index 388307297..000000000 --- a/Source/3rd Party/wx/include/wx/generic/printps.h +++ /dev/null @@ -1,67 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/printps.h -// Purpose: wxPostScriptPrinter, wxPostScriptPrintPreview -// wxGenericPageSetupDialog -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __PRINTPSH__ -#define __PRINTPSH__ - -#include "wx/prntbase.h" - -#if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT - -// ---------------------------------------------------------------------------- -// Represents the printer: manages printing a wxPrintout object -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPostScriptPrinter : public wxPrinterBase -{ -public: - wxPostScriptPrinter(wxPrintDialogData *data = NULL); - virtual ~wxPostScriptPrinter(); - - virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true); - virtual wxDC* PrintDialog(wxWindow *parent); - virtual bool Setup(wxWindow *parent); - -private: - DECLARE_DYNAMIC_CLASS(wxPostScriptPrinter) -}; - -// ---------------------------------------------------------------------------- -// wxPrintPreview: programmer creates an object of this class to preview a -// wxPrintout. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPostScriptPrintPreview : public wxPrintPreviewBase -{ -public: - wxPostScriptPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting = NULL, - wxPrintDialogData *data = NULL); - wxPostScriptPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting, - wxPrintData *data); - - virtual ~wxPostScriptPrintPreview(); - - virtual bool Print(bool interactive); - virtual void DetermineScaling(); - -private: - void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); - -private: - DECLARE_CLASS(wxPostScriptPrintPreview) -}; - -#endif - -#endif -// __PRINTPSH__ diff --git a/Source/3rd Party/wx/include/wx/generic/private/grid.h b/Source/3rd Party/wx/include/wx/generic/private/grid.h deleted file mode 100644 index 7ef99700c..000000000 --- a/Source/3rd Party/wx/include/wx/generic/private/grid.h +++ /dev/null @@ -1,948 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/grid.h -// Purpose: Private wxGrid structures -// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) -// Modified by: Santiago Palacios -// Created: 1/08/1999 -// Copyright: (c) Michael Bedward -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_GRID_PRIVATE_H_ -#define _WX_GENERIC_GRID_PRIVATE_H_ - -#include "wx/defs.h" - -#if wxUSE_GRID - -// Internally used (and hence intentionally not exported) event telling wxGrid -// to hide the currently shown editor. -wxDECLARE_EVENT( wxEVT_GRID_HIDE_EDITOR, wxCommandEvent ); - -// ---------------------------------------------------------------------------- -// array classes -// ---------------------------------------------------------------------------- - -WX_DEFINE_ARRAY_WITH_DECL_PTR(wxGridCellAttr *, wxArrayAttrs, - class WXDLLIMPEXP_ADV); - -struct wxGridCellWithAttr -{ - wxGridCellWithAttr(int row, int col, wxGridCellAttr *attr_) - : coords(row, col), attr(attr_) - { - wxASSERT( attr ); - } - - wxGridCellWithAttr(const wxGridCellWithAttr& other) - : coords(other.coords), - attr(other.attr) - { - attr->IncRef(); - } - - wxGridCellWithAttr& operator=(const wxGridCellWithAttr& other) - { - coords = other.coords; - if (attr != other.attr) - { - attr->DecRef(); - attr = other.attr; - attr->IncRef(); - } - return *this; - } - - void ChangeAttr(wxGridCellAttr* new_attr) - { - if (attr != new_attr) - { - // "Delete" (i.e. DecRef) the old attribute. - attr->DecRef(); - attr = new_attr; - // Take ownership of the new attribute, i.e. no IncRef. - } - } - - ~wxGridCellWithAttr() - { - attr->DecRef(); - } - - wxGridCellCoords coords; - wxGridCellAttr *attr; -}; - -WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellWithAttr, wxGridCellWithAttrArray, - class WXDLLIMPEXP_ADV); - - -// ---------------------------------------------------------------------------- -// private classes -// ---------------------------------------------------------------------------- - -// header column providing access to the column information stored in wxGrid -// via wxHeaderColumn interface -class wxGridHeaderColumn : public wxHeaderColumn -{ -public: - wxGridHeaderColumn(wxGrid *grid, int col) - : m_grid(grid), - m_col(col) - { - } - - virtual wxString GetTitle() const { return m_grid->GetColLabelValue(m_col); } - virtual wxBitmap GetBitmap() const { return wxNullBitmap; } - virtual int GetWidth() const { return m_grid->GetColSize(m_col); } - virtual int GetMinWidth() const { return 0; } - virtual wxAlignment GetAlignment() const - { - int horz, - vert; - m_grid->GetColLabelAlignment(&horz, &vert); - - return static_cast(horz); - } - - virtual int GetFlags() const - { - // we can't know in advance whether we can sort by this column or not - // with wxGrid API so suppose we can by default - int flags = wxCOL_SORTABLE; - if ( m_grid->CanDragColSize(m_col) ) - flags |= wxCOL_RESIZABLE; - if ( m_grid->CanDragColMove() ) - flags |= wxCOL_REORDERABLE; - if ( GetWidth() == 0 ) - flags |= wxCOL_HIDDEN; - - return flags; - } - - virtual bool IsSortKey() const - { - return m_grid->IsSortingBy(m_col); - } - - virtual bool IsSortOrderAscending() const - { - return m_grid->IsSortOrderAscending(); - } - -private: - // these really should be const but are not because the column needs to be - // assignable to be used in a wxVector (in STL build, in non-STL build we - // avoid the need for this) - wxGrid *m_grid; - int m_col; -}; - -// header control retreiving column information from the grid -class wxGridHeaderCtrl : public wxHeaderCtrl -{ -public: - wxGridHeaderCtrl(wxGrid *owner) - : wxHeaderCtrl(owner, - wxID_ANY, - wxDefaultPosition, - wxDefaultSize, - wxHD_ALLOW_HIDE | - (owner->CanDragColMove() ? wxHD_ALLOW_REORDER : 0)) - { - } - -protected: - virtual const wxHeaderColumn& GetColumn(unsigned int idx) const - { - return m_columns[idx]; - } - -private: - wxGrid *GetOwner() const { return static_cast(GetParent()); } - - static wxMouseEvent GetDummyMouseEvent() - { - // make up a dummy event for the grid event to use -- unfortunately we - // can't do anything else here - wxMouseEvent e; - e.SetState(wxGetMouseState()); - return e; - } - - // override the base class method to update our m_columns array - virtual void OnColumnCountChanging(unsigned int count) - { - const unsigned countOld = m_columns.size(); - if ( count < countOld ) - { - // just discard the columns which don't exist any more (notice that - // we can't use resize() here as it would require the vector - // value_type, i.e. wxGridHeaderColumn to be default constructible, - // which it is not) - m_columns.erase(m_columns.begin() + count, m_columns.end()); - } - else // new columns added - { - // add columns for the new elements - for ( unsigned n = countOld; n < count; n++ ) - m_columns.push_back(wxGridHeaderColumn(GetOwner(), n)); - } - } - - // override to implement column auto sizing - virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle) - { - // TODO: currently grid doesn't support computing the column best width - // from its contents so we just use the best label width as is - GetOwner()->SetColSize(idx, widthTitle); - - return true; - } - - // overridden to react to the actions using the columns popup menu - virtual void UpdateColumnVisibility(unsigned int idx, bool show) - { - GetOwner()->SetColSize(idx, show ? wxGRID_AUTOSIZE : 0); - - // as this is done by the user we should notify the main program about - // it - GetOwner()->SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, idx, - GetDummyMouseEvent()); - } - - // overridden to react to the columns order changes in the customization - // dialog - virtual void UpdateColumnsOrder(const wxArrayInt& order) - { - GetOwner()->SetColumnsOrder(order); - } - - - // event handlers forwarding wxHeaderCtrl events to wxGrid - void OnClick(wxHeaderCtrlEvent& event) - { - GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_CLICK, - -1, event.GetColumn(), - GetDummyMouseEvent()); - - GetOwner()->DoColHeaderClick(event.GetColumn()); - } - - void OnDoubleClick(wxHeaderCtrlEvent& event) - { - if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_DCLICK, - -1, event.GetColumn(), - GetDummyMouseEvent()) ) - { - event.Skip(); - } - } - - void OnRightClick(wxHeaderCtrlEvent& event) - { - if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_RIGHT_CLICK, - -1, event.GetColumn(), - GetDummyMouseEvent()) ) - { - event.Skip(); - } - } - - void OnBeginResize(wxHeaderCtrlEvent& event) - { - GetOwner()->DoStartResizeCol(event.GetColumn()); - - event.Skip(); - } - - void OnResizing(wxHeaderCtrlEvent& event) - { - GetOwner()->DoUpdateResizeColWidth(event.GetWidth()); - } - - void OnEndResize(wxHeaderCtrlEvent& event) - { - // we again need to pass a mouse event to be used for the grid event - // generation but we don't have it here so use a dummy one as in - // UpdateColumnVisibility() - wxMouseEvent e; - e.SetState(wxGetMouseState()); - GetOwner()->DoEndDragResizeCol(e); - - event.Skip(); - } - - void OnBeginReorder(wxHeaderCtrlEvent& event) - { - GetOwner()->DoStartMoveCol(event.GetColumn()); - } - - void OnEndReorder(wxHeaderCtrlEvent& event) - { - GetOwner()->DoEndMoveCol(event.GetNewOrder()); - } - - wxVector m_columns; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridHeaderCtrl); -}; - -// common base class for various grid subwindows -class WXDLLIMPEXP_ADV wxGridSubwindow : public wxWindow -{ -public: - wxGridSubwindow(wxGrid *owner, - int additionalStyle = 0, - const wxString& name = wxPanelNameStr) - : wxWindow(owner, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - wxBORDER_NONE | additionalStyle, - name) - { - m_owner = owner; - } - - virtual wxWindow *GetMainWindowOfCompositeControl() { return m_owner; } - - virtual bool AcceptsFocus() const { return false; } - - wxGrid *GetOwner() { return m_owner; } - -protected: - void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); - - wxGrid *m_owner; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridSubwindow); -}; - -class WXDLLIMPEXP_ADV wxGridRowLabelWindow : public wxGridSubwindow -{ -public: - wxGridRowLabelWindow(wxGrid *parent) - : wxGridSubwindow(parent) - { - } - - -private: - void OnPaint( wxPaintEvent& event ); - void OnMouseEvent( wxMouseEvent& event ); - void OnMouseWheel( wxMouseEvent& event ); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridRowLabelWindow); -}; - - -class WXDLLIMPEXP_ADV wxGridColLabelWindow : public wxGridSubwindow -{ -public: - wxGridColLabelWindow(wxGrid *parent) - : wxGridSubwindow(parent) - { - } - - -private: - void OnPaint( wxPaintEvent& event ); - void OnMouseEvent( wxMouseEvent& event ); - void OnMouseWheel( wxMouseEvent& event ); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridColLabelWindow); -}; - - -class WXDLLIMPEXP_ADV wxGridCornerLabelWindow : public wxGridSubwindow -{ -public: - wxGridCornerLabelWindow(wxGrid *parent) - : wxGridSubwindow(parent) - { - } - -private: - void OnMouseEvent( wxMouseEvent& event ); - void OnMouseWheel( wxMouseEvent& event ); - void OnPaint( wxPaintEvent& event ); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridCornerLabelWindow); -}; - -class WXDLLIMPEXP_ADV wxGridWindow : public wxGridSubwindow -{ -public: - wxGridWindow(wxGrid *parent) - : wxGridSubwindow(parent, - wxWANTS_CHARS | wxCLIP_CHILDREN, - "GridWindow") - { - } - - - virtual void ScrollWindow( int dx, int dy, const wxRect *rect ); - - virtual bool AcceptsFocus() const { return true; } - -private: - void OnPaint( wxPaintEvent &event ); - void OnMouseWheel( wxMouseEvent& event ); - void OnMouseEvent( wxMouseEvent& event ); - void OnKeyDown( wxKeyEvent& ); - void OnKeyUp( wxKeyEvent& ); - void OnChar( wxKeyEvent& ); - void OnEraseBackground( wxEraseEvent& ); - void OnFocus( wxFocusEvent& ); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGridWindow); -}; - -// ---------------------------------------------------------------------------- -// the internal data representation used by wxGridCellAttrProvider -// ---------------------------------------------------------------------------- - -// this class stores attributes set for cells -class WXDLLIMPEXP_ADV wxGridCellAttrData -{ -public: - void SetAttr(wxGridCellAttr *attr, int row, int col); - wxGridCellAttr *GetAttr(int row, int col) const; - void UpdateAttrRows( size_t pos, int numRows ); - void UpdateAttrCols( size_t pos, int numCols ); - -private: - // searches for the attr for given cell, returns wxNOT_FOUND if not found - int FindIndex(int row, int col) const; - - wxGridCellWithAttrArray m_attrs; -}; - -// this class stores attributes set for rows or columns -class WXDLLIMPEXP_ADV wxGridRowOrColAttrData -{ -public: - // empty ctor to suppress warnings - wxGridRowOrColAttrData() {} - ~wxGridRowOrColAttrData(); - - void SetAttr(wxGridCellAttr *attr, int rowOrCol); - wxGridCellAttr *GetAttr(int rowOrCol) const; - void UpdateAttrRowsOrCols( size_t pos, int numRowsOrCols ); - -private: - wxArrayInt m_rowsOrCols; - wxArrayAttrs m_attrs; -}; - -// NB: this is just a wrapper around 3 objects: one which stores cell -// attributes, and 2 others for row/col ones -class WXDLLIMPEXP_ADV wxGridCellAttrProviderData -{ -public: - wxGridCellAttrData m_cellAttrs; - wxGridRowOrColAttrData m_rowAttrs, - m_colAttrs; -}; - -// ---------------------------------------------------------------------------- -// operations classes abstracting the difference between operating on rows and -// columns -// ---------------------------------------------------------------------------- - -// This class allows to write a function only once because by using its methods -// it will apply to both columns and rows. -// -// This is an abstract interface definition, the two concrete implementations -// below should be used when working with rows and columns respectively. -class wxGridOperations -{ -public: - // Returns the operations in the other direction, i.e. wxGridRowOperations - // if this object is a wxGridColumnOperations and vice versa. - virtual wxGridOperations& Dual() const = 0; - - // Return the number of rows or columns. - virtual int GetNumberOfLines(const wxGrid *grid) const = 0; - - // Return the selection mode which allows selecting rows or columns. - virtual wxGrid::wxGridSelectionModes GetSelectionMode() const = 0; - - // Make a wxGridCellCoords from the given components: thisDir is row or - // column and otherDir is column or row - virtual wxGridCellCoords MakeCoords(int thisDir, int otherDir) const = 0; - - // Calculate the scrolled position of the given abscissa or ordinate. - virtual int CalcScrolledPosition(wxGrid *grid, int pos) const = 0; - - // Selects the horizontal or vertical component from the given object. - virtual int Select(const wxGridCellCoords& coords) const = 0; - virtual int Select(const wxPoint& pt) const = 0; - virtual int Select(const wxSize& sz) const = 0; - virtual int Select(const wxRect& r) const = 0; - virtual int& Select(wxRect& r) const = 0; - - // Returns width or height of the rectangle - virtual int& SelectSize(wxRect& r) const = 0; - - // Make a wxSize such that Select() applied to it returns first component - virtual wxSize MakeSize(int first, int second) const = 0; - - // Sets the row or column component of the given cell coordinates - virtual void Set(wxGridCellCoords& coords, int line) const = 0; - - - // Draws a line parallel to the row or column, i.e. horizontal or vertical: - // pos is the horizontal or vertical position of the line and start and end - // are the coordinates of the line extremities in the other direction - virtual void - DrawParallelLine(wxDC& dc, int start, int end, int pos) const = 0; - - // Draw a horizontal or vertical line across the given rectangle - // (this is implemented in terms of above and uses Select() to extract - // start and end from the given rectangle) - void DrawParallelLineInRect(wxDC& dc, const wxRect& rect, int pos) const - { - const int posStart = Select(rect.GetPosition()); - DrawParallelLine(dc, posStart, posStart + Select(rect.GetSize()), pos); - } - - - // Return the index of the row or column at the given pixel coordinate. - virtual int - PosToLine(const wxGrid *grid, int pos, bool clip = false) const = 0; - - // Get the top/left position, in pixels, of the given row or column - virtual int GetLineStartPos(const wxGrid *grid, int line) const = 0; - - // Get the bottom/right position, in pixels, of the given row or column - virtual int GetLineEndPos(const wxGrid *grid, int line) const = 0; - - // Get the height/width of the given row/column - virtual int GetLineSize(const wxGrid *grid, int line) const = 0; - - // Get wxGrid::m_rowBottoms/m_colRights array - virtual const wxArrayInt& GetLineEnds(const wxGrid *grid) const = 0; - - // Get default height row height or column width - virtual int GetDefaultLineSize(const wxGrid *grid) const = 0; - - // Return the minimal acceptable row height or column width - virtual int GetMinimalAcceptableLineSize(const wxGrid *grid) const = 0; - - // Return the minimal row height or column width - virtual int GetMinimalLineSize(const wxGrid *grid, int line) const = 0; - - // Set the row height or column width - virtual void SetLineSize(wxGrid *grid, int line, int size) const = 0; - - // Set the row default height or column default width - virtual void SetDefaultLineSize(wxGrid *grid, int size, bool resizeExisting) const = 0; - - - // Return the index of the line at the given position - // - // NB: currently this is always identity for the rows as reordering is only - // implemented for the lines - virtual int GetLineAt(const wxGrid *grid, int pos) const = 0; - - // Return the display position of the line with the given index. - // - // NB: As GetLineAt(), currently this is always identity for rows. - virtual int GetLinePos(const wxGrid *grid, int line) const = 0; - - // Return the index of the line just before the given one or wxNOT_FOUND. - virtual int GetLineBefore(const wxGrid* grid, int line) const = 0; - - // Get the row or column label window - virtual wxWindow *GetHeaderWindow(wxGrid *grid) const = 0; - - // Get the width or height of the row or column label window - virtual int GetHeaderWindowSize(wxGrid *grid) const = 0; - - - // This class is never used polymorphically but give it a virtual dtor - // anyhow to suppress g++ complaints about it - virtual ~wxGridOperations() { } -}; - -class wxGridRowOperations : public wxGridOperations -{ -public: - virtual wxGridOperations& Dual() const; - - virtual int GetNumberOfLines(const wxGrid *grid) const - { return grid->GetNumberRows(); } - - virtual wxGrid::wxGridSelectionModes GetSelectionMode() const - { return wxGrid::wxGridSelectRows; } - - virtual wxGridCellCoords MakeCoords(int thisDir, int otherDir) const - { return wxGridCellCoords(thisDir, otherDir); } - - virtual int CalcScrolledPosition(wxGrid *grid, int pos) const - { return grid->CalcScrolledPosition(wxPoint(pos, 0)).x; } - - virtual int Select(const wxGridCellCoords& c) const { return c.GetRow(); } - virtual int Select(const wxPoint& pt) const { return pt.x; } - virtual int Select(const wxSize& sz) const { return sz.x; } - virtual int Select(const wxRect& r) const { return r.x; } - virtual int& Select(wxRect& r) const { return r.x; } - virtual int& SelectSize(wxRect& r) const { return r.width; } - virtual wxSize MakeSize(int first, int second) const - { return wxSize(first, second); } - virtual void Set(wxGridCellCoords& coords, int line) const - { coords.SetRow(line); } - - virtual void DrawParallelLine(wxDC& dc, int start, int end, int pos) const - { dc.DrawLine(start, pos, end, pos); } - - virtual int PosToLine(const wxGrid *grid, int pos, bool clip = false) const - { return grid->YToRow(pos, clip); } - virtual int GetLineStartPos(const wxGrid *grid, int line) const - { return grid->GetRowTop(line); } - virtual int GetLineEndPos(const wxGrid *grid, int line) const - { return grid->GetRowBottom(line); } - virtual int GetLineSize(const wxGrid *grid, int line) const - { return grid->GetRowHeight(line); } - virtual const wxArrayInt& GetLineEnds(const wxGrid *grid) const - { return grid->m_rowBottoms; } - virtual int GetDefaultLineSize(const wxGrid *grid) const - { return grid->GetDefaultRowSize(); } - virtual int GetMinimalAcceptableLineSize(const wxGrid *grid) const - { return grid->GetRowMinimalAcceptableHeight(); } - virtual int GetMinimalLineSize(const wxGrid *grid, int line) const - { return grid->GetRowMinimalHeight(line); } - virtual void SetLineSize(wxGrid *grid, int line, int size) const - { grid->SetRowSize(line, size); } - virtual void SetDefaultLineSize(wxGrid *grid, int size, bool resizeExisting) const - { grid->SetDefaultRowSize(size, resizeExisting); } - - virtual int GetLineAt(const wxGrid * WXUNUSED(grid), int pos) const - { return pos; } // TODO: implement row reordering - virtual int GetLinePos(const wxGrid * WXUNUSED(grid), int line) const - { return line; } // TODO: implement row reordering - - virtual int GetLineBefore(const wxGrid* WXUNUSED(grid), int line) const - { return line - 1; } - - virtual wxWindow *GetHeaderWindow(wxGrid *grid) const - { return grid->GetGridRowLabelWindow(); } - virtual int GetHeaderWindowSize(wxGrid *grid) const - { return grid->GetRowLabelSize(); } -}; - -class wxGridColumnOperations : public wxGridOperations -{ -public: - virtual wxGridOperations& Dual() const; - - virtual int GetNumberOfLines(const wxGrid *grid) const - { return grid->GetNumberCols(); } - - virtual wxGrid::wxGridSelectionModes GetSelectionMode() const - { return wxGrid::wxGridSelectColumns; } - - virtual wxGridCellCoords MakeCoords(int thisDir, int otherDir) const - { return wxGridCellCoords(otherDir, thisDir); } - - virtual int CalcScrolledPosition(wxGrid *grid, int pos) const - { return grid->CalcScrolledPosition(wxPoint(0, pos)).y; } - - virtual int Select(const wxGridCellCoords& c) const { return c.GetCol(); } - virtual int Select(const wxPoint& pt) const { return pt.y; } - virtual int Select(const wxSize& sz) const { return sz.y; } - virtual int Select(const wxRect& r) const { return r.y; } - virtual int& Select(wxRect& r) const { return r.y; } - virtual int& SelectSize(wxRect& r) const { return r.height; } - virtual wxSize MakeSize(int first, int second) const - { return wxSize(second, first); } - virtual void Set(wxGridCellCoords& coords, int line) const - { coords.SetCol(line); } - - virtual void DrawParallelLine(wxDC& dc, int start, int end, int pos) const - { dc.DrawLine(pos, start, pos, end); } - - virtual int PosToLine(const wxGrid *grid, int pos, bool clip = false) const - { return grid->XToCol(pos, clip); } - virtual int GetLineStartPos(const wxGrid *grid, int line) const - { return grid->GetColLeft(line); } - virtual int GetLineEndPos(const wxGrid *grid, int line) const - { return grid->GetColRight(line); } - virtual int GetLineSize(const wxGrid *grid, int line) const - { return grid->GetColWidth(line); } - virtual const wxArrayInt& GetLineEnds(const wxGrid *grid) const - { return grid->m_colRights; } - virtual int GetDefaultLineSize(const wxGrid *grid) const - { return grid->GetDefaultColSize(); } - virtual int GetMinimalAcceptableLineSize(const wxGrid *grid) const - { return grid->GetColMinimalAcceptableWidth(); } - virtual int GetMinimalLineSize(const wxGrid *grid, int line) const - { return grid->GetColMinimalWidth(line); } - virtual void SetLineSize(wxGrid *grid, int line, int size) const - { grid->SetColSize(line, size); } - virtual void SetDefaultLineSize(wxGrid *grid, int size, bool resizeExisting) const - { grid->SetDefaultColSize(size, resizeExisting); } - - virtual int GetLineAt(const wxGrid *grid, int pos) const - { return grid->GetColAt(pos); } - virtual int GetLinePos(const wxGrid *grid, int line) const - { return grid->GetColPos(line); } - - virtual int GetLineBefore(const wxGrid* grid, int line) const - { - int posBefore = grid->GetColPos(line) - 1; - return posBefore >= 0 ? grid->GetColAt(posBefore) : wxNOT_FOUND; - } - - virtual wxWindow *GetHeaderWindow(wxGrid *grid) const - { return grid->GetGridColLabelWindow(); } - virtual int GetHeaderWindowSize(wxGrid *grid) const - { return grid->GetColLabelSize(); } -}; - -// This class abstracts the difference between operations going forward -// (down/right) and backward (up/left) and allows to use the same code for -// functions which differ only in the direction of grid traversal. -// -// Notice that all operations in this class work with display positions and not -// internal indices which can be different if the columns were reordered. -// -// Like wxGridOperations it's an ABC with two concrete subclasses below. Unlike -// it, this is a normal object and not just a function dispatch table and has a -// non-default ctor. -// -// Note: the explanation of this discrepancy is the existence of (very useful) -// Dual() method in wxGridOperations which forces us to make wxGridOperations a -// function dispatcher only. -class wxGridDirectionOperations -{ -public: - // The oper parameter to ctor selects whether we work with rows or columns - wxGridDirectionOperations(wxGrid *grid, const wxGridOperations& oper) - : m_grid(grid), - m_oper(oper) - { - } - - // Check if the component of this point in our direction is at the - // boundary, i.e. is the first/last row/column - virtual bool IsAtBoundary(const wxGridCellCoords& coords) const = 0; - - // Increment the component of this point in our direction - virtual void Advance(wxGridCellCoords& coords) const = 0; - - // Find the line at the given distance, in pixels, away from this one - // (this uses clipping, i.e. anything after the last line is counted as the - // last one and anything before the first one as 0) - // - // TODO: Implementation of this method currently doesn't support column - // reordering as it mixes up indices and positions. But this doesn't - // really matter as it's only called for rows (Page Up/Down only work - // vertically) and row reordering is not currently supported. We'd - // need to fix it if this ever changes however. - virtual int MoveByPixelDistance(int line, int distance) const = 0; - - // This class is never used polymorphically but give it a virtual dtor - // anyhow to suppress g++ complaints about it - virtual ~wxGridDirectionOperations() { } - -protected: - // Get the position of the row or column from the given coordinates pair. - // - // This is just a shortcut to avoid repeating m_oper and m_grid multiple - // times in the derived classes code. - int GetLinePos(const wxGridCellCoords& coords) const - { - return m_oper.GetLinePos(m_grid, m_oper.Select(coords)); - } - - // Get the index of the row or column from the position. - int GetLineAt(int pos) const - { - return m_oper.GetLineAt(m_grid, pos); - } - - // Check if the given line is visible, i.e. has non 0 size. - bool IsLineVisible(int line) const - { - return m_oper.GetLineSize(m_grid, line) != 0; - } - - - wxGrid * const m_grid; - const wxGridOperations& m_oper; -}; - -class wxGridBackwardOperations : public wxGridDirectionOperations -{ -public: - wxGridBackwardOperations(wxGrid *grid, const wxGridOperations& oper) - : wxGridDirectionOperations(grid, oper) - { - } - - virtual bool IsAtBoundary(const wxGridCellCoords& coords) const - { - wxASSERT_MSG( m_oper.Select(coords) >= 0, "invalid row/column" ); - - int pos = GetLinePos(coords); - while ( pos ) - { - // Check the previous line. - int line = GetLineAt(--pos); - if ( IsLineVisible(line) ) - { - // There is another visible line before this one, hence it's - // not at boundary. - return false; - } - } - - // We reached the boundary without finding any visible lines. - return true; - } - - virtual void Advance(wxGridCellCoords& coords) const - { - int pos = GetLinePos(coords); - for ( ;; ) - { - // This is not supposed to happen if IsAtBoundary() returned false. - wxCHECK_RET( pos, "can't advance when already at boundary" ); - - int line = GetLineAt(--pos); - if ( IsLineVisible(line) ) - { - m_oper.Set(coords, line); - break; - } - } - } - - virtual int MoveByPixelDistance(int line, int distance) const - { - int pos = m_oper.GetLineStartPos(m_grid, line); - return m_oper.PosToLine(m_grid, pos - distance + 1, true); - } -}; - -// Please refer to the comments above when reading this class code, it's -// absolutely symmetrical to wxGridBackwardOperations. -class wxGridForwardOperations : public wxGridDirectionOperations -{ -public: - wxGridForwardOperations(wxGrid *grid, const wxGridOperations& oper) - : wxGridDirectionOperations(grid, oper), - m_numLines(oper.GetNumberOfLines(grid)) - { - } - - virtual bool IsAtBoundary(const wxGridCellCoords& coords) const - { - wxASSERT_MSG( m_oper.Select(coords) < m_numLines, "invalid row/column" ); - - int pos = GetLinePos(coords); - while ( pos < m_numLines - 1 ) - { - int line = GetLineAt(++pos); - if ( IsLineVisible(line) ) - return false; - } - - return true; - } - - virtual void Advance(wxGridCellCoords& coords) const - { - int pos = GetLinePos(coords); - for ( ;; ) - { - wxCHECK_RET( pos < m_numLines - 1, - "can't advance when already at boundary" ); - - int line = GetLineAt(++pos); - if ( IsLineVisible(line) ) - { - m_oper.Set(coords, line); - break; - } - } - } - - virtual int MoveByPixelDistance(int line, int distance) const - { - int pos = m_oper.GetLineStartPos(m_grid, line); - return m_oper.PosToLine(m_grid, pos + distance, true); - } - -private: - const int m_numLines; -}; - -// ---------------------------------------------------------------------------- -// data structures used for the data type registry -// ---------------------------------------------------------------------------- - -struct wxGridDataTypeInfo -{ - wxGridDataTypeInfo(const wxString& typeName, - wxGridCellRenderer* renderer, - wxGridCellEditor* editor) - : m_typeName(typeName), m_renderer(renderer), m_editor(editor) - {} - - ~wxGridDataTypeInfo() - { - wxSafeDecRef(m_renderer); - wxSafeDecRef(m_editor); - } - - wxString m_typeName; - wxGridCellRenderer* m_renderer; - wxGridCellEditor* m_editor; - - wxDECLARE_NO_COPY_CLASS(wxGridDataTypeInfo); -}; - - -WX_DEFINE_ARRAY_WITH_DECL_PTR(wxGridDataTypeInfo*, wxGridDataTypeInfoArray, - class WXDLLIMPEXP_ADV); - - -class WXDLLIMPEXP_ADV wxGridTypeRegistry -{ -public: - wxGridTypeRegistry() {} - ~wxGridTypeRegistry(); - - void RegisterDataType(const wxString& typeName, - wxGridCellRenderer* renderer, - wxGridCellEditor* editor); - - // find one of already registered data types - int FindRegisteredDataType(const wxString& typeName); - - // try to FindRegisteredDataType(), if this fails and typeName is one of - // standard typenames, register it and return its index - int FindDataType(const wxString& typeName); - - // try to FindDataType(), if it fails see if it is not one of already - // registered data types with some params in which case clone the - // registered data type and set params for it - int FindOrCloneDataType(const wxString& typeName); - - wxGridCellRenderer* GetRenderer(int index); - wxGridCellEditor* GetEditor(int index); - -private: - wxGridDataTypeInfoArray m_typeinfo; -}; - -#endif // wxUSE_GRID -#endif // _WX_GENERIC_GRID_PRIVATE_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/private/listctrl.h b/Source/3rd Party/wx/include/wx/generic/private/listctrl.h deleted file mode 100644 index 5cd210f48..000000000 --- a/Source/3rd Party/wx/include/wx/generic/private/listctrl.h +++ /dev/null @@ -1,869 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/listctrl.h -// Purpose: private definitions of wxListCtrl helpers -// Author: Robert Roebling -// Vadim Zeitlin (virtual list control support) -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_LISTCTRL_PRIVATE_H_ -#define _WX_GENERIC_LISTCTRL_PRIVATE_H_ - -#include "wx/defs.h" - -#if wxUSE_LISTCTRL - -#include "wx/listctrl.h" -#include "wx/selstore.h" -#include "wx/timer.h" -#include "wx/settings.h" - -// ============================================================================ -// private classes -// ============================================================================ - -//----------------------------------------------------------------------------- -// wxColWidthInfo (internal) -//----------------------------------------------------------------------------- - -struct wxColWidthInfo -{ - int nMaxWidth; - bool bNeedsUpdate; // only set to true when an item whose - // width == nMaxWidth is removed - - wxColWidthInfo(int w = 0, bool needsUpdate = false) - { - nMaxWidth = w; - bNeedsUpdate = needsUpdate; - } -}; - -WX_DEFINE_ARRAY_PTR(wxColWidthInfo *, ColWidthArray); - -//----------------------------------------------------------------------------- -// wxListItemData (internal) -//----------------------------------------------------------------------------- - -class wxListItemData -{ -public: - wxListItemData(wxListMainWindow *owner); - ~wxListItemData(); - - void SetItem( const wxListItem &info ); - void SetImage( int image ) { m_image = image; } - void SetData( wxUIntPtr data ) { m_data = data; } - void SetPosition( int x, int y ); - void SetSize( int width, int height ); - - bool HasText() const { return !m_text.empty(); } - const wxString& GetText() const { return m_text; } - void SetText(const wxString& text) { m_text = text; } - - // we can't use empty string for measuring the string width/height, so - // always return something - wxString GetTextForMeasuring() const - { - wxString s = GetText(); - if ( s.empty() ) - s = wxT('H'); - - return s; - } - - bool IsHit( int x, int y ) const; - - int GetX() const; - int GetY() const; - int GetWidth() const; - int GetHeight() const; - - int GetImage() const { return m_image; } - bool HasImage() const { return GetImage() != -1; } - - void GetItem( wxListItem &info ) const; - - void SetAttr(wxListItemAttr *attr) { m_attr = attr; } - wxListItemAttr *GetAttr() const { return m_attr; } - -public: - // the item image or -1 - int m_image; - - // user data associated with the item - wxUIntPtr m_data; - - // the item coordinates are not used in report mode; instead this pointer is - // NULL and the owner window is used to retrieve the item position and size - wxRect *m_rect; - - // the list ctrl we are in - wxListMainWindow *m_owner; - - // custom attributes or NULL - wxListItemAttr *m_attr; - -protected: - // common part of all ctors - void Init(); - - wxString m_text; -}; - -//----------------------------------------------------------------------------- -// wxListHeaderData (internal) -//----------------------------------------------------------------------------- - -class wxListHeaderData : public wxObject -{ -public: - wxListHeaderData(); - wxListHeaderData( const wxListItem &info ); - void SetItem( const wxListItem &item ); - void SetPosition( int x, int y ); - void SetWidth( int w ); - void SetState( int state ); - void SetFormat( int format ); - void SetHeight( int h ); - bool HasImage() const; - - bool HasText() const { return !m_text.empty(); } - const wxString& GetText() const { return m_text; } - void SetText(const wxString& text) { m_text = text; } - - void GetItem( wxListItem &item ); - - bool IsHit( int x, int y ) const; - int GetImage() const; - int GetWidth() const; - int GetFormat() const; - int GetState() const; - -protected: - long m_mask; - int m_image; - wxString m_text; - int m_format; - int m_width; - int m_xpos, - m_ypos; - int m_height; - int m_state; - -private: - void Init(); -}; - -//----------------------------------------------------------------------------- -// wxListLineData (internal) -//----------------------------------------------------------------------------- - -WX_DECLARE_LIST(wxListItemData, wxListItemDataList); - -class wxListLineData -{ -public: - // the list of subitems: only may have more than one item in report mode - wxListItemDataList m_items; - - // this is not used in report view - struct GeometryInfo - { - // total item rect - wxRect m_rectAll; - - // label only - wxRect m_rectLabel; - - // icon only - wxRect m_rectIcon; - - // the part to be highlighted - wxRect m_rectHighlight; - - // extend all our rects to be centered inside the one of given width - void ExtendWidth(wxCoord w) - { - wxASSERT_MSG( m_rectAll.width <= w, - wxT("width can only be increased") ); - - m_rectAll.width = w; - m_rectLabel.x = m_rectAll.x + (w - m_rectLabel.width) / 2; - m_rectIcon.x = m_rectAll.x + (w - m_rectIcon.width) / 2; - m_rectHighlight.x = m_rectAll.x + (w - m_rectHighlight.width) / 2; - } - } - *m_gi; - - // is this item selected? [NB: not used in virtual mode] - bool m_highlighted; - - // back pointer to the list ctrl - wxListMainWindow *m_owner; - -public: - wxListLineData(wxListMainWindow *owner); - - ~wxListLineData() - { - WX_CLEAR_LIST(wxListItemDataList, m_items); - delete m_gi; - } - - // called by the owner when it toggles report view - void SetReportView(bool inReportView) - { - // we only need m_gi when we're not in report view so update as needed - if ( inReportView ) - { - delete m_gi; - m_gi = NULL; - } - else - { - m_gi = new GeometryInfo; - } - } - - // are we in report mode? - inline bool InReportView() const; - - // are we in virtual report mode? - inline bool IsVirtual() const; - - // these 2 methods shouldn't be called for report view controls, in that - // case we determine our position/size ourselves - - // calculate the size of the line - void CalculateSize( wxDC *dc, int spacing ); - - // remember the position this line appears at - void SetPosition( int x, int y, int spacing ); - - // wxListCtrl API - - void SetImage( int image ) { SetImage(0, image); } - int GetImage() const { return GetImage(0); } - void SetImage( int index, int image ); - int GetImage( int index ) const; - - bool HasImage() const { return GetImage() != -1; } - bool HasText() const { return !GetText(0).empty(); } - - void SetItem( int index, const wxListItem &info ); - void GetItem( int index, wxListItem &info ); - - wxString GetText(int index) const; - void SetText( int index, const wxString& s ); - - wxListItemAttr *GetAttr() const; - void SetAttr(wxListItemAttr *attr); - - // return true if the highlighting really changed - bool Highlight( bool on ); - - void ReverseHighlight(); - - bool IsHighlighted() const - { - wxASSERT_MSG( !IsVirtual(), wxT("unexpected call to IsHighlighted") ); - - return m_highlighted; - } - - // draw the line on the given DC in icon/list mode - void Draw( wxDC *dc, bool current ); - - // the same in report mode: it needs more parameters as we don't store - // everything in the item in report mode - void DrawInReportMode( wxDC *dc, - const wxRect& rect, - const wxRect& rectHL, - bool highlighted, - bool current ); - -private: - // set the line to contain num items (only can be > 1 in report mode) - void InitItems( int num ); - - // get the mode (i.e. style) of the list control - inline int GetMode() const; - - // Apply this item attributes to the given DC: set the text font and colour - // and also erase the background appropriately. - void ApplyAttributes(wxDC *dc, - const wxRect& rectHL, - bool highlighted, - bool current); - - // draw the text on the DC with the correct justification; also add an - // ellipsis if the text is too large to fit in the current width - void DrawTextFormatted(wxDC *dc, - const wxString &text, - int col, - int x, - int yMid, // this is middle, not top, of the text - int width); -}; - -WX_DECLARE_OBJARRAY(wxListLineData, wxListLineDataArray); - -//----------------------------------------------------------------------------- -// wxListHeaderWindow (internal) -//----------------------------------------------------------------------------- - -class wxListHeaderWindow : public wxWindow -{ -protected: - wxListMainWindow *m_owner; - const wxCursor *m_currentCursor; - wxCursor *m_resizeCursor; - bool m_isDragging; - - // column being resized or -1 - int m_column; - - // divider line position in logical (unscrolled) coords - int m_currentX; - - // minimal position beyond which the divider line - // can't be dragged in logical coords - int m_minX; - -public: - wxListHeaderWindow(); - - // We provide only Create(), not the ctor, because we need to create the - // C++ object before creating the window, see the explanations in - // CreateOrDestroyHeaderWindowAsNeeded() - bool Create( wxWindow *win, - wxWindowID id, - wxListMainWindow *owner, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxString &name = wxT("wxlistctrlcolumntitles") ); - - virtual ~wxListHeaderWindow(); - - // We never need focus as we don't have any keyboard interface. - virtual bool AcceptsFocus() const { return false; } - - void DrawCurrent(); - void AdjustDC( wxDC& dc ); - - void OnPaint( wxPaintEvent &event ); - void OnMouse( wxMouseEvent &event ); - - // needs refresh - bool m_dirty; - - // Update main window's column later - bool m_sendSetColumnWidth; - int m_colToSend; - int m_widthToSend; - - virtual void OnInternalIdle(); - -private: - // common part of all ctors - void Init(); - - // generate and process the list event of the given type, return true if - // it wasn't vetoed, i.e. if we should proceed - bool SendListEvent(wxEventType type, const wxPoint& pos); - - DECLARE_EVENT_TABLE() -}; - -//----------------------------------------------------------------------------- -// wxListRenameTimer (internal) -//----------------------------------------------------------------------------- - -class wxListRenameTimer: public wxTimer -{ -private: - wxListMainWindow *m_owner; - -public: - wxListRenameTimer( wxListMainWindow *owner ); - void Notify(); -}; - -//----------------------------------------------------------------------------- -// wxListFindTimer (internal) -//----------------------------------------------------------------------------- - -class wxListFindTimer: public wxTimer -{ -public: - // reset the current prefix after half a second of inactivity - enum { DELAY = 500 }; - - wxListFindTimer( wxListMainWindow *owner ) - : m_owner(owner) - { - } - - virtual void Notify(); - -private: - wxListMainWindow *m_owner; -}; - -//----------------------------------------------------------------------------- -// wxListTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing -//----------------------------------------------------------------------------- - -class wxListTextCtrlWrapper : public wxEvtHandler -{ -public: - // NB: text must be a valid object but not Create()d yet - wxListTextCtrlWrapper(wxListMainWindow *owner, - wxTextCtrl *text, - size_t itemEdit); - - wxTextCtrl *GetText() const { return m_text; } - - // Check if the given key event should stop editing and return true if it - // does or false otherwise. - bool CheckForEndEditKey(const wxKeyEvent& event); - - // Different reasons for calling EndEdit(): - // - // It was called because: - enum EndReason - { - End_Accept, // user has accepted the changes. - End_Discard, // user has cancelled editing. - End_Destroy // the entire control is being destroyed. - }; - - void EndEdit(EndReason reason); - -protected: - void OnChar( wxKeyEvent &event ); - void OnKeyUp( wxKeyEvent &event ); - void OnKillFocus( wxFocusEvent &event ); - - bool AcceptChanges(); - void Finish( bool setfocus ); - -private: - wxListMainWindow *m_owner; - wxTextCtrl *m_text; - wxString m_startValue; - size_t m_itemEdited; - bool m_aboutToFinish; - - DECLARE_EVENT_TABLE() -}; - -//----------------------------------------------------------------------------- -// wxListMainWindow (internal) -//----------------------------------------------------------------------------- - -WX_DECLARE_LIST(wxListHeaderData, wxListHeaderDataList); - -class wxListMainWindow : public wxWindow -{ -public: - wxListMainWindow(); - wxListMainWindow( wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size ); - - virtual ~wxListMainWindow(); - - // called by the main control when its mode changes - void SetReportView(bool inReportView); - - // helper to simplify testing for wxLC_XXX flags - bool HasFlag(int flag) const { return m_parent->HasFlag(flag); } - - // return true if this is a virtual list control - bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); } - - // return true if the control is in report mode - bool InReportView() const { return HasFlag(wxLC_REPORT); } - - // return true if we are in single selection mode, false if multi sel - bool IsSingleSel() const { return HasFlag(wxLC_SINGLE_SEL); } - - // do we have a header window? - bool HasHeader() const - { return InReportView() && !HasFlag(wxLC_NO_HEADER); } - - void HighlightAll( bool on ); - - // all these functions only do something if the line is currently visible - - // change the line "selected" state, return true if it really changed - bool HighlightLine( size_t line, bool highlight = true); - - // as HighlightLine() but do it for the range of lines: this is incredibly - // more efficient for virtual list controls! - // - // NB: unlike HighlightLine() this one does refresh the lines on screen - void HighlightLines( size_t lineFrom, size_t lineTo, bool on = true ); - - // toggle the line state and refresh it - void ReverseHighlight( size_t line ) - { HighlightLine(line, !IsHighlighted(line)); RefreshLine(line); } - - // return true if the line is highlighted - bool IsHighlighted(size_t line) const; - - // refresh one or several lines at once - void RefreshLine( size_t line ); - void RefreshLines( size_t lineFrom, size_t lineTo ); - - // refresh all selected items - void RefreshSelected(); - - // refresh all lines below the given one: the difference with - // RefreshLines() is that the index here might not be a valid one (happens - // when the last line is deleted) - void RefreshAfter( size_t lineFrom ); - - // the methods which are forwarded to wxListLineData itself in list/icon - // modes but are here because the lines don't store their positions in the - // report mode - - // get the bound rect for the entire line - wxRect GetLineRect(size_t line) const; - - // get the bound rect of the label - wxRect GetLineLabelRect(size_t line) const; - - // get the bound rect of the items icon (only may be called if we do have - // an icon!) - wxRect GetLineIconRect(size_t line) const; - - // get the rect to be highlighted when the item has focus - wxRect GetLineHighlightRect(size_t line) const; - - // get the size of the total line rect - wxSize GetLineSize(size_t line) const - { return GetLineRect(line).GetSize(); } - - // return the hit code for the corresponding position (in this line) - long HitTestLine(size_t line, int x, int y) const; - - // bring the selected item into view, scrolling to it if necessary - void MoveToItem(size_t item); - - bool ScrollList( int WXUNUSED(dx), int dy ); - - // bring the current item into view - void MoveToFocus() { MoveToItem(m_current); } - - // start editing the label of the given item - wxTextCtrl *EditLabel(long item, - wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); - - bool EndEditLabel(bool cancel); - - wxTextCtrl *GetEditControl() const - { - return m_textctrlWrapper ? m_textctrlWrapper->GetText() : NULL; - } - - void ResetTextControl(wxTextCtrl *text) - { - delete text; - m_textctrlWrapper = NULL; - } - - void OnRenameTimer(); - bool OnRenameAccept(size_t itemEdit, const wxString& value); - void OnRenameCancelled(size_t itemEdit); - - void OnFindTimer(); - // set whether or not to ring the find bell - // (does nothing on MSW - bell is always rung) - void EnableBellOnNoMatch( bool on ); - - void OnMouse( wxMouseEvent &event ); - - // called to switch the selection from the current item to newCurrent, - void OnArrowChar( size_t newCurrent, const wxKeyEvent& event ); - - void OnCharHook( wxKeyEvent &event ); - void OnChar( wxKeyEvent &event ); - void OnKeyDown( wxKeyEvent &event ); - void OnKeyUp( wxKeyEvent &event ); - void OnSetFocus( wxFocusEvent &event ); - void OnKillFocus( wxFocusEvent &event ); - void OnScroll( wxScrollWinEvent& event ); - - void OnPaint( wxPaintEvent &event ); - - void OnChildFocus(wxChildFocusEvent& event); - - void DrawImage( int index, wxDC *dc, int x, int y ); - void GetImageSize( int index, int &width, int &height ) const; - - void SetImageList( wxImageList *imageList, int which ); - void SetItemSpacing( int spacing, bool isSmall = false ); - int GetItemSpacing( bool isSmall = false ); - - void SetColumn( int col, const wxListItem &item ); - void SetColumnWidth( int col, int width ); - void GetColumn( int col, wxListItem &item ) const; - int GetColumnWidth( int col ) const; - int GetColumnCount() const { return m_columns.GetCount(); } - - // returns the sum of the heights of all columns - int GetHeaderWidth() const; - - int GetCountPerPage() const; - - void SetItem( wxListItem &item ); - void GetItem( wxListItem &item ) const; - void SetItemState( long item, long state, long stateMask ); - void SetItemStateAll( long state, long stateMask ); - int GetItemState( long item, long stateMask ) const; - bool GetItemRect( long item, wxRect &rect ) const - { - return GetSubItemRect(item, wxLIST_GETSUBITEMRECT_WHOLEITEM, rect); - } - bool GetSubItemRect( long item, long subItem, wxRect& rect ) const; - wxRect GetViewRect() const; - bool GetItemPosition( long item, wxPoint& pos ) const; - int GetSelectedItemCount() const; - - wxString GetItemText(long item, int col = 0) const - { - wxListItem info; - info.m_mask = wxLIST_MASK_TEXT; - info.m_itemId = item; - info.m_col = col; - GetItem( info ); - return info.m_text; - } - - void SetItemText(long item, const wxString& value) - { - wxListItem info; - info.m_mask = wxLIST_MASK_TEXT; - info.m_itemId = item; - info.m_text = value; - SetItem( info ); - } - - wxImageList* GetSmallImageList() const - { return m_small_image_list; } - - // set the scrollbars and update the positions of the items - void RecalculatePositions(bool noRefresh = false); - - // refresh the window and the header - void RefreshAll(); - - long GetNextItem( long item, int geometry, int state ) const; - void DeleteItem( long index ); - void DeleteAllItems(); - void DeleteColumn( int col ); - void DeleteEverything(); - void EnsureVisible( long index ); - long FindItem( long start, const wxString& str, bool partial = false ); - long FindItem( long start, wxUIntPtr data); - long FindItem( const wxPoint& pt ); - long HitTest( int x, int y, int &flags ) const; - void InsertItem( wxListItem &item ); - long InsertColumn( long col, const wxListItem &item ); - int GetItemWidthWithImage(wxListItem * item); - void SortItems( wxListCtrlCompare fn, wxIntPtr data ); - - size_t GetItemCount() const; - bool IsEmpty() const { return GetItemCount() == 0; } - void SetItemCount(long count); - - // change the current (== focused) item, send a notification event - void ChangeCurrent(size_t current); - void ResetCurrent() { ChangeCurrent((size_t)-1); } - bool HasCurrent() const { return m_current != (size_t)-1; } - - // send out a wxListEvent - void SendNotify( size_t line, - wxEventType command, - const wxPoint& point = wxDefaultPosition ); - - // override base class virtual to reset m_lineHeight when the font changes - virtual bool SetFont(const wxFont& font) - { - if ( !wxWindow::SetFont(font) ) - return false; - - m_lineHeight = 0; - - return true; - } - - // these are for wxListLineData usage only - - // get the backpointer to the list ctrl - wxGenericListCtrl *GetListCtrl() const - { - return wxStaticCast(GetParent(), wxGenericListCtrl); - } - - // get the height of all lines (assuming they all do have the same height) - wxCoord GetLineHeight() const; - - // get the y position of the given line (only for report view) - wxCoord GetLineY(size_t line) const; - - // get the brush to use for the item highlighting - wxBrush *GetHighlightBrush() const - { - return m_hasFocus ? m_highlightBrush : m_highlightUnfocusedBrush; - } - - bool HasFocus() const - { - return m_hasFocus; - } - -protected: - // the array of all line objects for a non virtual list control (for the - // virtual list control we only ever use m_lines[0]) - wxListLineDataArray m_lines; - - // the list of column objects - wxListHeaderDataList m_columns; - - // currently focused item or -1 - size_t m_current; - - // the number of lines per page - int m_linesPerPage; - - // this flag is set when something which should result in the window - // redrawing happens (i.e. an item was added or deleted, or its appearance - // changed) and OnPaint() doesn't redraw the window while it is set which - // allows to minimize the number of repaintings when a lot of items are - // being added. The real repainting occurs only after the next OnIdle() - // call - bool m_dirty; - - wxColour *m_highlightColour; - wxImageList *m_small_image_list; - wxImageList *m_normal_image_list; - int m_small_spacing; - int m_normal_spacing; - bool m_hasFocus; - - bool m_lastOnSame; - wxTimer *m_renameTimer; - - // incremental search data - wxString m_findPrefix; - wxTimer *m_findTimer; - // This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1 - // if it is globally enabled but has been temporarily disabled because we - // had already beeped for this particular search. - int m_findBell; - - bool m_isCreated; - int m_dragCount; - wxPoint m_dragStart; - ColWidthArray m_aColWidths; - - // for double click logic - size_t m_lineLastClicked, - m_lineBeforeLastClicked, - m_lineSelectSingleOnUp; - -protected: - wxWindow *GetMainWindowOfCompositeControl() { return GetParent(); } - - // the total count of items in a virtual list control - size_t m_countVirt; - - // the object maintaining the items selection state, only used in virtual - // controls - wxSelectionStore m_selStore; - - // common part of all ctors - void Init(); - - // get the line data for the given index - wxListLineData *GetLine(size_t n) const - { - wxASSERT_MSG( n != (size_t)-1, wxT("invalid line index") ); - - if ( IsVirtual() ) - { - wxConstCast(this, wxListMainWindow)->CacheLineData(n); - n = 0; - } - - return &m_lines[n]; - } - - // get a dummy line which can be used for geometry calculations and such: - // you must use GetLine() if you want to really draw the line - wxListLineData *GetDummyLine() const; - - // cache the line data of the n-th line in m_lines[0] - void CacheLineData(size_t line); - - // get the range of visible lines - void GetVisibleLinesRange(size_t *from, size_t *to); - - // force us to recalculate the range of visible lines - void ResetVisibleLinesRange() { m_lineFrom = (size_t)-1; } - - // find the first item starting with the given prefix after the given item - size_t PrefixFindItem(size_t item, const wxString& prefix) const; - - // get the colour to be used for drawing the rules - wxColour GetRuleColour() const - { - return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); - } - -private: - // initialize the current item if needed - void UpdateCurrent(); - - // delete all items but don't refresh: called from dtor - void DoDeleteAllItems(); - - // Compute the minimal width needed to fully display the column header. - int ComputeMinHeaderWidth(const wxListHeaderData* header) const; - - - // the height of one line using the current font - wxCoord m_lineHeight; - - // the total header width or 0 if not calculated yet - wxCoord m_headerWidth; - - // the first and last lines being shown on screen right now (inclusive), - // both may be -1 if they must be calculated so never access them directly: - // use GetVisibleLinesRange() above instead - size_t m_lineFrom, - m_lineTo; - - // the brushes to use for item highlighting when we do/don't have focus - wxBrush *m_highlightBrush, - *m_highlightUnfocusedBrush; - - // wrapper around the text control currently used for in place editing or - // NULL if no item is being edited - wxListTextCtrlWrapper *m_textctrlWrapper; - - - DECLARE_EVENT_TABLE() - - friend class wxGenericListCtrl; -}; - -#endif // wxUSE_LISTCTRL -#endif // _WX_GENERIC_LISTCTRL_PRIVATE_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/private/markuptext.h b/Source/3rd Party/wx/include/wx/generic/private/markuptext.h deleted file mode 100644 index 1d9569229..000000000 --- a/Source/3rd Party/wx/include/wx/generic/private/markuptext.h +++ /dev/null @@ -1,77 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/markuptext.h -// Purpose: Generic wxMarkupText class for managing text with markup. -// Author: Vadim Zeitlin -// Created: 2011-02-21 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_PRIVATE_MARKUPTEXT_H_ -#define _WX_GENERIC_PRIVATE_MARKUPTEXT_H_ - -#include "wx/defs.h" - -class WXDLLIMPEXP_FWD_CORE wxDC; -class WXDLLIMPEXP_FWD_CORE wxRect; - -// ---------------------------------------------------------------------------- -// wxMarkupText: allows to measure and draw the text containing markup. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMarkupText -{ -public: - // Constants for Render() flags. - enum - { - Render_Default = 0, // Don't show mnemonics visually. - Render_ShowAccels = 1 // Underline mnemonics. - }; - - - // Initialize with the given string containing markup (which is supposed to - // be valid, the caller must check for it before constructing this object). - // - // Notice that the usual rules for mnemonics apply to the markup text: if - // it contains any '&' characters they must be escaped by doubling them, - // otherwise they indicate that the next character is the mnemonic for this - // field. - // - // TODO-MULTILINE-MARKUP: Currently only single line labels are supported, - // search for other occurrences of this comment to find the places which - // need to be updated to support multiline labels with markup. - wxMarkupText(const wxString& markup) - : m_markup(markup) - { - } - - // Default copy ctor, assignment operator and dtor are ok. - - // Update the markup string. - // - // The same rules for mnemonics as in the ctor apply to this string. - void SetMarkup(const wxString& markup) { m_markup = markup; } - - - // Return the width and height required by the given string and optionally - // the height of the visible part above the baseline (i.e. ascent minus - // internal leading). - // - // The font currently selected into the DC is used for measuring (notice - // that it is changed by this function but normally -- i.e. if markup is - // valid -- restored to its original value when it returns). - wxSize Measure(wxDC& dc, int *visibleHeight = NULL) const; - - // Render the markup string into the given DC in the specified rectangle. - // - // Notice that while the function uses the provided rectangle for alignment - // (it centers the text in it), no clipping is done by it so use Measure() - // and set the clipping region before rendering if necessary. - void Render(wxDC& dc, const wxRect& rect, int flags); - -private: - wxString m_markup; -}; - -#endif // _WX_GENERIC_PRIVATE_MARKUPTEXT_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/private/richtooltip.h b/Source/3rd Party/wx/include/wx/generic/private/richtooltip.h deleted file mode 100644 index ad356f51f..000000000 --- a/Source/3rd Party/wx/include/wx/generic/private/richtooltip.h +++ /dev/null @@ -1,64 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/richtooltip.h -// Purpose: wxRichToolTipGenericImpl declaration. -// Author: Vadim Zeitlin -// Created: 2011-10-18 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_ -#define _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_ - -#include "wx/icon.h" -#include "wx/colour.h" - -// ---------------------------------------------------------------------------- -// wxRichToolTipGenericImpl: defines generic wxRichToolTip implementation. -// ---------------------------------------------------------------------------- - -class wxRichToolTipGenericImpl : public wxRichToolTipImpl -{ -public: - wxRichToolTipGenericImpl(const wxString& title, const wxString& message) : - m_title(title), - m_message(message) - { - m_tipKind = wxTipKind_Auto; - - // This is pretty arbitrary, we could follow MSW and use some multiple - // of double-click time here. - m_timeout = 5000; - m_delay = 0; - } - - virtual void SetBackgroundColour(const wxColour& col, - const wxColour& colEnd); - virtual void SetCustomIcon(const wxIcon& icon); - virtual void SetStandardIcon(int icon); - virtual void SetTimeout(unsigned milliseconds, - unsigned millisecondsDelay = 0); - virtual void SetTipKind(wxTipKind tipKind); - virtual void SetTitleFont(const wxFont& font); - - virtual void ShowFor(wxWindow* win, const wxRect* rect = NULL); - -protected: - wxString m_title, - m_message; - -private: - wxIcon m_icon; - - wxColour m_colStart, - m_colEnd; - - unsigned m_timeout, - m_delay; - - wxTipKind m_tipKind; - - wxFont m_titleFont; -}; - -#endif // _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/private/textmeasure.h b/Source/3rd Party/wx/include/wx/generic/private/textmeasure.h deleted file mode 100644 index 2b31d0283..000000000 --- a/Source/3rd Party/wx/include/wx/generic/private/textmeasure.h +++ /dev/null @@ -1,39 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/textmeasure.h -// Purpose: Generic wxTextMeasure declaration. -// Author: Vadim Zeitlin -// Created: 2012-10-17 -// Copyright: (c) 1997-2012 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_PRIVATE_TEXTMEASURE_H_ -#define _WX_GENERIC_PRIVATE_TEXTMEASURE_H_ - -// ---------------------------------------------------------------------------- -// wxTextMeasure for the platforms without native support. -// ---------------------------------------------------------------------------- - -class wxTextMeasure : public wxTextMeasureBase -{ -public: - wxEXPLICIT wxTextMeasure(const wxDC *dc, const wxFont *font = NULL) - : wxTextMeasureBase(dc, font) {} - wxEXPLICIT wxTextMeasure(const wxWindow *win, const wxFont *font = NULL) - : wxTextMeasureBase(win, font) {} - -protected: - virtual void DoGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL); - - virtual bool DoGetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX); - - wxDECLARE_NO_COPY_CLASS(wxTextMeasure); -}; - -#endif // _WX_GENERIC_PRIVATE_TEXTMEASURE_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/prntdlgg.h b/Source/3rd Party/wx/include/wx/generic/prntdlgg.h index 0374595ce..ef57d47cc 100644 --- a/Source/3rd Party/wx/include/wx/generic/prntdlgg.h +++ b/Source/3rd Party/wx/include/wx/generic/prntdlgg.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/prntdlgg.h +// Name: prntdlgg.h // Purpose: wxGenericPrintDialog, wxGenericPrintSetupDialog, // wxGenericPageSetupDialog // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: prntdlgg.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,7 +23,6 @@ #include "wx/printdlg.h" #include "wx/listctrl.h" -#include "wx/dc.h" #if wxUSE_POSTSCRIPT #include "wx/dcps.h" #endif @@ -33,7 +33,7 @@ class WXDLLIMPEXP_FWD_CORE wxCheckBox; class WXDLLIMPEXP_FWD_CORE wxComboBox; class WXDLLIMPEXP_FWD_CORE wxStaticText; class WXDLLIMPEXP_FWD_CORE wxRadioBox; -class WXDLLIMPEXP_FWD_CORE wxPageSetupDialogData; +class WXDLLIMPEXP_FWD_CORE wxPageSetupData; // ---------------------------------------------------------------------------- // constants @@ -77,7 +77,7 @@ enum // wxPostScriptNativeData //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPostScriptPrintNativeData: public wxPrintNativeDataBase +class WXDLLEXPORT wxPostScriptPrintNativeData: public wxPrintNativeDataBase { public: wxPostScriptPrintNativeData(); @@ -136,11 +136,11 @@ private: // Windows using PostScript print/preview) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGenericPrintDialog : public wxPrintDialogBase +class WXDLLEXPORT wxGenericPrintDialog : public wxPrintDialogBase { public: wxGenericPrintDialog(wxWindow *parent, - wxPrintDialogData* data = NULL); + wxPrintDialogData* data = (wxPrintDialogData*)NULL); wxGenericPrintDialog(wxWindow *parent, wxPrintData* data); virtual ~wxGenericPrintDialog(); @@ -181,7 +181,7 @@ private: DECLARE_DYNAMIC_CLASS(wxGenericPrintDialog) }; -class WXDLLIMPEXP_CORE wxGenericPrintSetupDialog : public wxDialog +class WXDLLEXPORT wxGenericPrintSetupDialog : public wxDialog { public: // There are no configuration options for the dialog, so we @@ -219,7 +219,7 @@ private: #endif // wxUSE_POSTSCRIPT -class WXDLLIMPEXP_CORE wxGenericPageSetupDialog : public wxPageSetupDialogBase +class WXDLLEXPORT wxGenericPageSetupDialog : public wxPageSetupDialogBase { public: wxGenericPageSetupDialog(wxWindow *parent = NULL, diff --git a/Source/3rd Party/wx/include/wx/generic/progdlgg.h b/Source/3rd Party/wx/include/wx/generic/progdlgg.h index 477e4d670..6382d1fc8 100644 --- a/Source/3rd Party/wx/include/wx/generic/progdlgg.h +++ b/Source/3rd Party/wx/include/wx/generic/progdlgg.h @@ -1,196 +1,132 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/progdlgg.h -// Purpose: wxGenericProgressDialog class +//////////////////////////////////////////////////// +// Name: progdlgg.h +// Purpose: wxProgressDialog class // Author: Karsten Ballueder -// Modified by: Francesco Montorsi +// Modified by: // Created: 09.05.1999 +// RCS-ID: $Id: progdlgg.h 50711 2007-12-15 02:57:58Z VZ $ // Copyright: (c) Karsten Ballueder // Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////// #ifndef __PROGDLGH_G__ #define __PROGDLGH_G__ +#include "wx/defs.h" +#include "wx/progdlg.h" + +#if wxUSE_PROGRESSDLG + #include "wx/dialog.h" class WXDLLIMPEXP_FWD_CORE wxButton; -class WXDLLIMPEXP_FWD_CORE wxEventLoop; class WXDLLIMPEXP_FWD_CORE wxGauge; class WXDLLIMPEXP_FWD_CORE wxStaticText; -class WXDLLIMPEXP_FWD_CORE wxWindowDisabler; -/* - Progress dialog which shows a moving progress bar. - Taken from the Mahogany project. -*/ -class WXDLLIMPEXP_CORE wxGenericProgressDialog : public wxDialog +/* Progress dialog which shows a moving progress bar. + Taken from the Mahogany project.*/ + +class WXDLLEXPORT wxProgressDialog : public wxDialog { +DECLARE_DYNAMIC_CLASS(wxProgressDialog) public: - wxGenericProgressDialog(); - wxGenericProgressDialog(const wxString& title, const wxString& message, - int maximum = 100, - wxWindow *parent = NULL, - int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE); + /* Creates and displays dialog, disables event handling for other + frames or parent frame to avoid recursion problems. + @param title title for window + @param message message to display in window + @param maximum value for status bar, if <= 0, no bar is shown + @param parent window or NULL + @param style is the bit mask of wxPD_XXX constants from wx/defs.h + */ + wxProgressDialog(const wxString &title, wxString const &message, + int maximum = 100, + wxWindow *parent = NULL, + int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE); + /* Destructor. + Re-enables event handling for other windows. + */ + virtual ~wxProgressDialog(); - virtual ~wxGenericProgressDialog(); + /* Update the status bar to the new value. + @param value new value + @param newmsg if used, new message to display + @returns true if ABORT button has not been pressed + */ + virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL); - bool Create(const wxString& title, - const wxString& message, - int maximum = 100, - wxWindow *parent = NULL, - int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE); - - virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL); + /* Switches the dialog to use a gauge in indeterminate mode and calls + wxGauge::Pulse() to show to the user a bit of progress */ virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL); - void Resume(); - - int GetValue() const; - int GetRange() const; - wxString GetMessage() const; - - void SetRange(int maximum); - - // Return whether "Cancel" or "Skip" button was pressed, always return - // false if the corresponding button is not shown. - bool WasCancelled() const; - bool WasSkipped() const; - // Must provide overload to avoid hiding it (and warnings about it) virtual void Update() { wxDialog::Update(); } - virtual bool Show( bool show = true ); + /* Can be called to continue after the cancel button has been pressed, but + the program decided to continue the operation (e.g., user didn't + confirm it) + */ + void Resume(); - // This enum is an implementation detail and should not be used - // by user code. - enum State + virtual bool Show( bool show = true ); + +protected: + // callback for optional abort button + void OnCancel(wxCommandEvent& event); + + // callback for optional skip button + void OnSkip(wxCommandEvent& event); + + // callback to disable "hard" window closing + void OnClose(wxCloseEvent& event); + + // must be called to reenable the other windows temporarily disabled while + // the dialog was shown + void ReenableOtherWindows(); + +private: + // create the label with given text and another one to show the time nearby + // as the next windows in the sizer, returns the created control + wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer); + + // updates the label message + void UpdateMessage(const wxString &newmsg); + + // common part of Update() and Pulse(), returns true if not cancelled + bool DoAfterUpdate(bool *skip); + + // shortcuts for enabling buttons + void EnableClose(); + void EnableSkip(bool enable=true); + void EnableAbort(bool enable=true); + inline void DisableSkip() { EnableSkip(false); } + inline void DisableAbort() { EnableAbort(false); } + + // the status bar + wxGauge *m_gauge; + // the message displayed + wxStaticText *m_msg; + // displayed elapsed, estimated, remaining time + class wxStaticText *m_elapsed, + *m_estimated, + *m_remaining; + // time when the dialog was created + unsigned long m_timeStart; + // time when the dialog was closed or cancelled + unsigned long m_timeStop; + // time between the moment the dialog was closed/cancelled and resume + unsigned long m_break; + + // parent top level window (may be NULL) + wxWindow *m_parentTop; + + // continue processing or not (return value for Update()) + enum { Uncancelable = -1, // dialog can't be canceled Canceled, // can be cancelled and, in fact, was Continue, // can be cancelled but wasn't - Finished, // finished, waiting to be removed from screen - Dismissed // was closed by user after finishing - }; - -protected: - // Update just the m_maximum field, this is used by public SetRange() but, - // unlike it, doesn't update the controls state. This makes it useful for - // both this class and its derived classes that don't use m_gauge to - // display progress. - void SetMaximum(int maximum); - - // Return the labels to use for showing the elapsed/estimated/remaining - // times respectively. - static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); } - static wxString GetEstimatedLabel() { return wxGetTranslation("Estimated time:"); } - static wxString GetRemainingLabel() { return wxGetTranslation("Remaining time:"); } - - - // Similar to wxWindow::HasFlag() but tests for a presence of a wxPD_XXX - // flag in our (separate) flags instead of using m_windowStyle. - bool HasPDFlag(int flag) const { return (m_pdStyle & flag) != 0; } - - // Return the progress dialog style. Prefer to use HasPDFlag() if possible. - int GetPDStyle() const { return m_pdStyle; } - void SetPDStyle(int pdStyle) { m_pdStyle = pdStyle; } - - // Updates estimated times from a given progress bar value and stores the - // results in provided arguments. - void UpdateTimeEstimates(int value, - unsigned long &elapsedTime, - unsigned long &estimatedTime, - unsigned long &remainingTime); - - // Converts seconds to HH:mm:ss format. - static wxString GetFormattedTime(unsigned long timeInSec); - - // callback for optional abort button - void OnCancel(wxCommandEvent&); - - // callback for optional skip button - void OnSkip(wxCommandEvent&); - - // callback to disable "hard" window closing - void OnClose(wxCloseEvent&); - - // called to disable the other windows while this dialog is shown - void DisableOtherWindows(); - - // must be called to reenable the other windows temporarily disabled while - // the dialog was shown - void ReenableOtherWindows(); - - // Set the top level parent we store from the parent window provided when - // creating the dialog. - void SetTopParent(wxWindow* parent); - - // return the top level parent window of this dialog (may be NULL) - wxWindow *GetTopParent() const { return m_parentTop; } - - - // continue processing or not (return value for Update()) - State m_state; - - // the maximum value - int m_maximum; - -#if defined(__WXMSW__ ) || defined(__WXPM__) - // the factor we use to always keep the value in 16 bit range as the native - // control only supports ranges from 0 to 65,535 - size_t m_factor; -#endif // __WXMSW__ - - // time when the dialog was created - unsigned long m_timeStart; - // time when the dialog was closed or cancelled - unsigned long m_timeStop; - // time between the moment the dialog was closed/cancelled and resume - unsigned long m_break; - -private: - // update the label to show the given time (in seconds) - static void SetTimeLabel(unsigned long val, wxStaticText *label); - - // common part of all ctors - void Init(); - - // create the label with given text and another one to show the time nearby - // as the next windows in the sizer, returns the created control - wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer); - - // updates the label message - void UpdateMessage(const wxString &newmsg); - - // common part of Update() and Pulse(), returns true if not cancelled - bool DoBeforeUpdate(bool *skip); - - // common part of Update() and Pulse() - void DoAfterUpdate(); - - // shortcuts for enabling buttons - void EnableClose(); - void EnableSkip(bool enable = true); - void EnableAbort(bool enable = true); - void DisableSkip() { EnableSkip(false); } - void DisableAbort() { EnableAbort(false); } - - // the widget displaying current status (may be NULL) - wxGauge *m_gauge; - // the message displayed - wxStaticText *m_msg; - // displayed elapsed, estimated, remaining time - wxStaticText *m_elapsed, - *m_estimated, - *m_remaining; - - // parent top level window (may be NULL) - wxWindow *m_parentTop; - - // Progress dialog styles: this is not the same as m_windowStyle because - // wxPD_XXX constants clash with the existing TLW styles so to be sure we - // don't have any conflicts we just use a separate variable for storing - // them. - int m_pdStyle; + Finished // finished, waiting to be removed from screen + } m_state; // skip some portion bool m_skip; @@ -201,29 +137,36 @@ private: wxButton *m_btnSkip; #endif + // the maximum value + int m_maximum; + // saves the time when elapsed time was updated so there is only one // update per second unsigned long m_last_timeupdate; - // tells how often a change of the estimated time has to be confirmed - // before it is actually displayed - this reduces the frequency of updates + // before it is actually displayed - this reduces the frequence of updates // of estimated and remaining time - int m_delay; - + const int m_delay; // counts the confirmations int m_ctdelay; unsigned long m_display_estimated; + bool m_hasAbortButton, + m_hasSkipButton; + +#if defined(__WXMSW__ ) || defined(__WXPM__) + // the factor we use to always keep the value in 16 bit range as the native + // control only supports ranges from 0 to 65,535 + size_t m_factor; +#endif // __WXMSW__ + // for wxPD_APP_MODAL case - wxWindowDisabler *m_winDisabler; - - // Temporary event loop created by the dialog itself if there is no - // currently active loop when it is created. - wxEventLoop *m_tempEventLoop; - + class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxGenericProgressDialog); + DECLARE_NO_COPY_CLASS(wxProgressDialog) }; +#endif // wxUSE_PROGRESSDLG + #endif // __PROGDLGH_G__ diff --git a/Source/3rd Party/wx/include/wx/generic/propdlg.h b/Source/3rd Party/wx/include/wx/generic/propdlg.h deleted file mode 100644 index 6cb63efad..000000000 --- a/Source/3rd Party/wx/include/wx/generic/propdlg.h +++ /dev/null @@ -1,168 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/propdlg.h -// Purpose: wxPropertySheetDialog -// Author: Julian Smart -// Modified by: -// Created: 2005-03-12 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PROPDLG_H_ -#define _WX_PROPDLG_H_ - -#include "wx/defs.h" - -#if wxUSE_BOOKCTRL - -#include "wx/dialog.h" - -class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase; - -//----------------------------------------------------------------------------- -// wxPropertySheetDialog -// A platform-independent properties dialog. -// -// * on PocketPC, a flat-look 'property sheet' notebook will be used, with -// no OK/Cancel/Help buttons -// * on other platforms, a normal notebook will be used, with standard buttons -// -// To use this class, call Create from your derived class. -// Then create pages and add to the book control. Finally call CreateButtons and -// LayoutDialog. -// -// For example: -// -// MyPropertySheetDialog::Create(...) -// { -// wxPropertySheetDialog::Create(...); -// -// // Add page -// wxPanel* panel = new wxPanel(GetBookCtrl(), ...); -// GetBookCtrl()->AddPage(panel, wxT("General")); -// -// CreateButtons(); -// LayoutDialog(); -// } -// -// Override CreateBookCtrl and AddBookCtrl to create and add a different -// kind of book control. -//----------------------------------------------------------------------------- - -enum wxPropertySheetDialogFlags -{ - // Use the platform default - wxPROPSHEET_DEFAULT = 0x0001, - - // Use a notebook - wxPROPSHEET_NOTEBOOK = 0x0002, - - // Use a toolbook - wxPROPSHEET_TOOLBOOK = 0x0004, - - // Use a choicebook - wxPROPSHEET_CHOICEBOOK = 0x0008, - - // Use a listbook - wxPROPSHEET_LISTBOOK = 0x0010, - - // Use a wxButtonToolBar toolbook - wxPROPSHEET_BUTTONTOOLBOOK = 0x0020, - - // Use a treebook - wxPROPSHEET_TREEBOOK = 0x0040, - - // Shrink dialog to fit current page - wxPROPSHEET_SHRINKTOFIT = 0x0100 -}; - -class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog -{ -public: - wxPropertySheetDialog() : wxDialog() { Init(); } - - wxPropertySheetDialog(wxWindow* parent, wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr) - { - Init(); - Create(parent, id, title, pos, sz, style, name); - } - - bool Create(wxWindow* parent, wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& sz = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr); - -//// Accessors - - // Set and get the notebook - void SetBookCtrl(wxBookCtrlBase* book) { m_bookCtrl = book; } - wxBookCtrlBase* GetBookCtrl() const { return m_bookCtrl; } - - // Override function in base - virtual wxWindow* GetContentWindow() const; - - // Set and get the inner sizer - void SetInnerSize(wxSizer* sizer) { m_innerSizer = sizer; } - wxSizer* GetInnerSizer() const { return m_innerSizer ; } - - // Set and get the book style - void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; } - long GetSheetStyle() const { return m_sheetStyle ; } - - // Set and get the border around the whole dialog - void SetSheetOuterBorder(int border) { m_sheetOuterBorder = border; } - int GetSheetOuterBorder() const { return m_sheetOuterBorder ; } - - // Set and get the border around the book control only - void SetSheetInnerBorder(int border) { m_sheetInnerBorder = border; } - int GetSheetInnerBorder() const { return m_sheetInnerBorder ; } - -/// Operations - - // Creates the buttons (none on PocketPC) - virtual void CreateButtons(int flags = wxOK|wxCANCEL); - - // Lay out the dialog, to be called after pages have been created - virtual void LayoutDialog(int centreFlags = wxBOTH); - -/// Implementation - - // Creates the book control. If you want to use a different kind of - // control, override. - virtual wxBookCtrlBase* CreateBookCtrl(); - - // Adds the book control to the inner sizer. - virtual void AddBookCtrl(wxSizer* sizer); - - // Set the focus - void OnActivate(wxActivateEvent& event); - - // Resize dialog if necessary - void OnIdle(wxIdleEvent& event); - -private: - void Init(); - -protected: - wxBookCtrlBase* m_bookCtrl; - wxSizer* m_innerSizer; // sizer for extra space - long m_sheetStyle; - int m_sheetOuterBorder; - int m_sheetInnerBorder; - int m_selectedPage; - - DECLARE_DYNAMIC_CLASS(wxPropertySheetDialog) - DECLARE_EVENT_TABLE() -}; - -#endif // wxUSE_BOOKCTRL - -#endif // _WX_PROPDLG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/region.h b/Source/3rd Party/wx/include/wx/generic/region.h deleted file mode 100644 index 1c5048dbf..000000000 --- a/Source/3rd Party/wx/include/wx/generic/region.h +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/region.h -// Purpose: generic wxRegion class -// Author: David Elliott -// Modified by: -// Created: 2004/04/12 -// Copyright: (c) 2004 David Elliott -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_REGION_H__ -#define _WX_GENERIC_REGION_H__ - -class WXDLLIMPEXP_CORE wxRegionGeneric : public wxRegionBase -{ -public: - wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h); - wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight); - wxRegionGeneric(const wxRect& rect); - wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - wxRegionGeneric(const wxBitmap& bmp); - wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0); - wxRegionGeneric(); - virtual ~wxRegionGeneric(); - - // wxRegionBase pure virtuals - virtual void Clear(); - virtual bool IsEmpty() const; - -protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - - // wxRegionBase pure virtuals - virtual bool DoIsEqual(const wxRegion& region) const; - virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const; - virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const; - virtual wxRegionContain DoContainsRect(const wxRect& rect) const; - - virtual bool DoOffset(wxCoord x, wxCoord y); - virtual bool DoUnionWithRect(const wxRect& rect); - virtual bool DoUnionWithRegion(const wxRegion& region); - virtual bool DoIntersect(const wxRegion& region); - virtual bool DoSubtract(const wxRegion& region); - virtual bool DoXor(const wxRegion& region); - - friend class WXDLLIMPEXP_FWD_CORE wxRegionIteratorGeneric; -}; - -class WXDLLIMPEXP_CORE wxRegionIteratorGeneric : public wxObject -{ -public: - wxRegionIteratorGeneric(); - wxRegionIteratorGeneric(const wxRegionGeneric& region); - wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator); - virtual ~wxRegionIteratorGeneric(); - - wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator); - - void Reset() { m_current = 0; } - void Reset(const wxRegionGeneric& region); - - operator bool () const { return HaveRects(); } - bool HaveRects() const; - - wxRegionIteratorGeneric& operator++(); - wxRegionIteratorGeneric operator++(int); - - long GetX() const; - long GetY() const; - long GetW() const; - long GetWidth() const { return GetW(); } - long GetH() const; - long GetHeight() const { return GetH(); } - wxRect GetRect() const; -private: - long m_current; - wxRegionGeneric m_region; -}; - -#endif // _WX_GENERIC_REGION_H__ diff --git a/Source/3rd Party/wx/include/wx/generic/richmsgdlgg.h b/Source/3rd Party/wx/include/wx/generic/richmsgdlgg.h deleted file mode 100644 index 9384dbb88..000000000 --- a/Source/3rd Party/wx/include/wx/generic/richmsgdlgg.h +++ /dev/null @@ -1,48 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/richmsgdlgg.h -// Purpose: wxGenericRichMessageDialog -// Author: Rickard Westerlund -// Created: 2010-07-04 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_RICHMSGDLGG_H_ -#define _WX_GENERIC_RICHMSGDLGG_H_ - -class WXDLLIMPEXP_FWD_CORE wxCheckBox; -class WXDLLIMPEXP_FWD_CORE wxCollapsiblePane; -class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent; - -class WXDLLIMPEXP_CORE wxGenericRichMessageDialog - : public wxRichMessageDialogBase -{ -public: - wxGenericRichMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK | wxCENTRE) - : wxRichMessageDialogBase( parent, message, caption, style ), - m_checkBox(NULL), - m_detailsPane(NULL) - { } - - virtual bool IsCheckBoxChecked() const; - -protected: - wxCheckBox *m_checkBox; - wxCollapsiblePane *m_detailsPane; - - // overrides methods in the base class - virtual void AddMessageDialogCheckBox(wxSizer *sizer); - virtual void AddMessageDialogDetails(wxSizer *sizer); - -private: - void OnPaneChanged(wxCollapsiblePaneEvent& event); - - DECLARE_EVENT_TABLE() - - wxDECLARE_NO_COPY_CLASS(wxGenericRichMessageDialog); -}; - -#endif // _WX_GENERIC_RICHMSGDLGG_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/sashwin.h b/Source/3rd Party/wx/include/wx/generic/sashwin.h deleted file mode 100644 index e4f34d829..000000000 --- a/Source/3rd Party/wx/include/wx/generic/sashwin.h +++ /dev/null @@ -1,267 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/sashwin.h -// Purpose: wxSashWindow implementation. A sash window has an optional -// sash on each edge, allowing it to be dragged. An event -// is generated when the sash is released. -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SASHWIN_H_G_ -#define _WX_SASHWIN_H_G_ - -#if wxUSE_SASH - -#include "wx/defs.h" -#include "wx/window.h" -#include "wx/string.h" - -#define wxSASH_DRAG_NONE 0 -#define wxSASH_DRAG_DRAGGING 1 -#define wxSASH_DRAG_LEFT_DOWN 2 - -enum wxSashEdgePosition { - wxSASH_TOP = 0, - wxSASH_RIGHT, - wxSASH_BOTTOM, - wxSASH_LEFT, - wxSASH_NONE = 100 -}; - -/* - * wxSashEdge represents one of the four edges of a window. - */ - -class WXDLLIMPEXP_ADV wxSashEdge -{ -public: - wxSashEdge() - { m_show = false; -#if WXWIN_COMPATIBILITY_2_6 - m_border = false; -#endif - m_margin = 0; } - - bool m_show; // Is the sash showing? -#if WXWIN_COMPATIBILITY_2_6 - bool m_border; // Do we draw a border? -#endif - int m_margin; // The margin size -}; - -/* - * wxSashWindow flags - */ - -#define wxSW_NOBORDER 0x0000 -//#define wxSW_3D 0x0010 -#define wxSW_BORDER 0x0020 -#define wxSW_3DSASH 0x0040 -#define wxSW_3DBORDER 0x0080 -#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER) - -/* - * wxSashWindow allows any of its edges to have a sash which can be dragged - * to resize the window. The actual content window will be created as a child - * of wxSashWindow. - */ - -class WXDLLIMPEXP_ADV wxSashWindow: public wxWindow -{ -public: - // Default constructor - wxSashWindow() - { - Init(); - } - - // Normal constructor - wxSashWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow")) - { - Init(); - Create(parent, id, pos, size, style, name); - } - - virtual ~wxSashWindow(); - - bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow")); - - // Set whether there's a sash in this position - void SetSashVisible(wxSashEdgePosition edge, bool sash); - - // Get whether there's a sash in this position - bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; } - -#if WXWIN_COMPATIBILITY_2_6 - // Set whether there's a border in this position - // This value is unused in wxSashWindow. - void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; } - - // Get whether there's a border in this position - // This value is unused in wxSashWindow. - bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; } -#endif - - // Get border size - int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; } - - // Sets the default sash border size - void SetDefaultBorderSize(int width) { m_borderSize = width; } - - // Gets the default sash border size - int GetDefaultBorderSize() const { return m_borderSize; } - - // Sets the addition border size between child and sash window - void SetExtraBorderSize(int width) { m_extraBorderSize = width; } - - // Gets the addition border size between child and sash window - int GetExtraBorderSize() const { return m_extraBorderSize; } - - virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; } - virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; } - virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; } - virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; } - - virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; } - virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; } - virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; } - virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; } - -//////////////////////////////////////////////////////////////////////////// -// Implementation - - // Paints the border and sash - void OnPaint(wxPaintEvent& event); - - // Handles mouse events - void OnMouseEvent(wxMouseEvent& ev); - - // Adjusts the panes - void OnSize(wxSizeEvent& event); - -#if defined(__WXMSW__) || defined(__WXMAC__) - // Handle cursor correctly - void OnSetCursor(wxSetCursorEvent& event); -#endif // wxMSW - - // Draws borders - void DrawBorders(wxDC& dc); - - // Draws the sashes - void DrawSash(wxSashEdgePosition edge, wxDC& dc); - - // Draws the sashes - void DrawSashes(wxDC& dc); - - // Draws the sash tracker (for whilst moving the sash) - void DrawSashTracker(wxSashEdgePosition edge, int x, int y); - - // Tests for x, y over sash - wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2); - - // Resizes subwindows - void SizeWindows(); - - // Initialize colours - void InitColours(); - -private: - void Init(); - - wxSashEdge m_sashes[4]; - int m_dragMode; - wxSashEdgePosition m_draggingEdge; - int m_oldX; - int m_oldY; - int m_borderSize; - int m_extraBorderSize; - int m_firstX; - int m_firstY; - int m_minimumPaneSizeX; - int m_minimumPaneSizeY; - int m_maximumPaneSizeX; - int m_maximumPaneSizeY; - wxCursor* m_sashCursorWE; - wxCursor* m_sashCursorNS; - wxColour m_lightShadowColour; - wxColour m_mediumShadowColour; - wxColour m_darkShadowColour; - wxColour m_hilightColour; - wxColour m_faceColour; - bool m_mouseCaptured; - wxCursor* m_currentCursor; - -private: - DECLARE_DYNAMIC_CLASS(wxSashWindow) - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxSashWindow); -}; - -class WXDLLIMPEXP_FWD_ADV wxSashEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_SASH_DRAGGED, wxSashEvent ); - -enum wxSashDragStatus -{ - wxSASH_STATUS_OK, - wxSASH_STATUS_OUT_OF_RANGE -}; - -class WXDLLIMPEXP_ADV wxSashEvent: public wxCommandEvent -{ -public: - wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE) - { - m_eventType = (wxEventType) wxEVT_SASH_DRAGGED; - m_id = id; - m_edge = edge; - } - - wxSashEvent(const wxSashEvent& event) - : wxCommandEvent(event), - m_edge(event.m_edge), - m_dragRect(event.m_dragRect), - m_dragStatus(event.m_dragStatus) { } - - void SetEdge(wxSashEdgePosition edge) { m_edge = edge; } - wxSashEdgePosition GetEdge() const { return m_edge; } - - //// The rectangle formed by the drag operation - void SetDragRect(const wxRect& rect) { m_dragRect = rect; } - wxRect GetDragRect() const { return m_dragRect; } - - //// Whether the drag caused the rectangle to be reversed (e.g. - //// dragging the top below the bottom) - void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; } - wxSashDragStatus GetDragStatus() const { return m_dragStatus; } - - virtual wxEvent *Clone() const { return new wxSashEvent(*this); } - -private: - wxSashEdgePosition m_edge; - wxRect m_dragRect; - wxSashDragStatus m_dragStatus; - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSashEvent) -}; - -typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&); - -#define wxSashEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSashEventFunction, func) - -#define EVT_SASH_DRAGGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SASH_DRAGGED, id, wxSashEventHandler(fn)) -#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \ - wx__DECLARE_EVT2(wxEVT_SASH_DRAGGED, id1, id2, wxSashEventHandler(fn)) - -#endif // wxUSE_SASH - -#endif - // _WX_SASHWIN_H_G_ diff --git a/Source/3rd Party/wx/include/wx/generic/scrolwin.h b/Source/3rd Party/wx/include/wx/generic/scrolwin.h index 92e9e7c36..b1cea5de7 100644 --- a/Source/3rd Party/wx/include/wx/generic/scrolwin.h +++ b/Source/3rd Party/wx/include/wx/generic/scrolwin.h @@ -1,9 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/scrolwin.h -// Purpose: generic wxScrollHelper -// Author: Vadim Zeitlin -// Created: 2008-12-24 (replacing old file with the same name) -// Copyright: (c) 2008 Vadim Zeitlin +// Purpose: wxGenericScrolledWindow class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id: scrolwin.h 35875 2005-10-10 18:24:27Z VZ $ +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,43 +13,15 @@ #define _WX_GENERIC_SCROLLWIN_H_ // ---------------------------------------------------------------------------- -// generic wxScrollHelper implementation +// headers and constants // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxScrollHelper : public wxScrollHelperBase -{ -public: - wxScrollHelper(wxWindow *winToScroll); +#include "wx/window.h" +#include "wx/panel.h" - // implement base class pure virtuals - virtual void AdjustScrollbars(); - virtual bool IsScrollbarShown(int orient) const; - -protected: - virtual void DoScroll(int x, int y); - virtual void DoShowScrollbars(wxScrollbarVisibility horz, - wxScrollbarVisibility vert); - -private: - // helper of AdjustScrollbars(): does the work for the single scrollbar - // - // notice that the parameters passed by non-const references are modified - // by this function - void DoAdjustScrollbar(int orient, - int clientSize, - int virtSize, - int pixelsPerUnit, - int& scrollUnits, - int& scrollPosition, - int& scrollLinesPerPage, - wxScrollbarVisibility visibility); - - - wxScrollbarVisibility m_xVisibility, - m_yVisibility; - - wxDECLARE_NO_COPY_CLASS(wxScrollHelper); -}; +// ---------------------------------------------------------------------------- +// wxGenericScrolledWindow +// ---------------------------------------------------------------------------- #endif // _WX_GENERIC_SCROLLWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/spinctlg.h b/Source/3rd Party/wx/include/wx/generic/spinctlg.h index 256c47b31..59a62d6a4 100644 --- a/Source/3rd Party/wx/include/wx/generic/spinctlg.h +++ b/Source/3rd Party/wx/include/wx/generic/spinctlg.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 28.10.99 +// RCS-ID: $Id: spinctlg.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,282 +22,28 @@ #if wxUSE_SPINBTN -#include "wx/compositewin.h" - -class WXDLLIMPEXP_FWD_CORE wxSpinButton; -class WXDLLIMPEXP_FWD_CORE wxTextCtrl; - -class wxSpinCtrlTextGeneric; // wxTextCtrl used for the wxSpinCtrlGenericBase - -// The !wxUSE_SPINBTN version's GetValue() function conflicts with the -// wxTextCtrl's GetValue() and so you have to input a dummy int value. -#define wxSPINCTRL_GETVALUE_FIX +class WXDLLEXPORT wxSpinButton; +class WXDLLEXPORT wxTextCtrl; // ---------------------------------------------------------------------------- -// wxSpinCtrlGeneric is a combination of wxTextCtrl and wxSpinButton -// -// This class manages a double valued generic spinctrl through the DoGet/SetXXX -// functions that are made public as Get/SetXXX functions for int or double -// for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid -// function ambiguity. +// wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase - : public wxNavigationEnabled > -{ -public: - wxSpinCtrlGenericBase() { Init(); } - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, - double min = 0, double max = 100, double initial = 0, - double inc = 1, - const wxString& name = wxT("wxSpinCtrl")); - - virtual ~wxSpinCtrlGenericBase(); - - // accessors - // T GetValue() const - // T GetMin() const - // T GetMax() const - // T GetIncrement() const - virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } - // unsigned GetDigits() const - wxSpinCtrlDouble only - - // operations - virtual void SetValue(const wxString& text); - // void SetValue(T val) - // void SetRange(T minVal, T maxVal) - // void SetIncrement(T inc) - virtual void SetSnapToTicks(bool snap_to_ticks); - // void SetDigits(unsigned digits) - wxSpinCtrlDouble only - - // Select text in the textctrl - void SetSelection(long from, long to); - - // implementation from now on - - // forward these functions to all subcontrols - virtual bool Enable(bool enable = true); - virtual bool Show(bool show = true); -#if wxUSE_TOOLTIPS - virtual void DoSetToolTip(wxToolTip *tip); -#endif // wxUSE_TOOLTIPS - - virtual bool SetBackgroundColour(const wxColour& colour); - - // get the subcontrols - wxTextCtrl *GetText() const { return m_textCtrl; } - wxSpinButton *GetSpinButton() const { return m_spinButton; } - - // forwarded events from children windows - void OnSpinButton(wxSpinEvent& event); - void OnTextLostFocus(wxFocusEvent& event); - void OnTextChar(wxKeyEvent& event); - - // this window itself is used only as a container for its sub windows so it - // shouldn't accept the focus at all and any attempts to explicitly set - // focus to it should give focus to its text constol part - virtual bool AcceptsFocus() const { return false; } - virtual void SetFocus(); - - friend class wxSpinCtrlTextGeneric; - -protected: - // override the base class virtuals involved into geometry calculations - virtual wxSize DoGetBestSize() const; - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; - virtual void DoMoveWindow(int x, int y, int width, int height); - -#ifdef __WXMSW__ - // and, for MSW, enabling this window itself - virtual void DoEnable(bool enable); -#endif // __WXMSW__ - - enum SendEvent - { - SendEvent_None, - SendEvent_Text - }; - - // generic double valued functions - double DoGetValue() const { return m_value; } - bool DoSetValue(double val, SendEvent sendEvent); - void DoSetRange(double min_val, double max_val); - void DoSetIncrement(double inc); - - // update our value to reflect the text control contents (if it has been - // modified by user, do nothing otherwise) - // - // can also change the text control if its value is invalid - // - // return true if our value has changed - bool SyncSpinToText(SendEvent sendEvent); - - // Send the correct event type - virtual void DoSendEvent() = 0; - - // Convert the text to/from the corresponding value. - virtual bool DoTextToValue(const wxString& text, double *val) = 0; - virtual wxString DoValueToText(double val) = 0; - - // check if the value is in range - bool InRange(double n) const { return (n >= m_min) && (n <= m_max); } - - // ensure that the value is in range wrapping it round if necessary - double AdjustToFitInRange(double value) const; - - - double m_value; - double m_min; - double m_max; - double m_increment; - bool m_snap_to_ticks; - - int m_spin_value; - - // the subcontrols - wxTextCtrl *m_textCtrl; - wxSpinButton *m_spinButton; - -private: - // common part of all ctors - void Init(); - - // Implement pure virtual function inherited from wxCompositeWindow. - virtual wxWindowList GetCompositeWindowParts() const; - - DECLARE_EVENT_TABLE() -}; - -#else // !wxUSE_SPINBTN - -#define wxSPINCTRL_GETVALUE_FIX int = 1 - -// ---------------------------------------------------------------------------- -// wxSpinCtrl is just a text control -// ---------------------------------------------------------------------------- - -#include "wx/textctrl.h" - -class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl -{ -public: - wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100), - m_increment(1), m_snap_to_ticks(false), - m_format(wxT("%g")) { } - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, - double min = 0, double max = 100, double initial = 0, - double inc = 1, - const wxString& name = wxT("wxSpinCtrl")) - { - m_min = min; - m_max = max; - m_value = initial; - m_increment = inc; - - bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style, - wxDefaultValidator, name); - DoSetValue(initial, SendEvent_None); - - return ok; - } - - // accessors - // T GetValue() const - // T GetMin() const - // T GetMax() const - // T GetIncrement() const - virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } - // unsigned GetDigits() const - wxSpinCtrlDouble only - - // operations - virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); } - // void SetValue(T val) - // void SetRange(T minVal, T maxVal) - // void SetIncrement(T inc) - virtual void SetSnapToTicks(bool snap_to_ticks) - { m_snap_to_ticks = snap_to_ticks; } - // void SetDigits(unsigned digits) - wxSpinCtrlDouble only - - // Select text in the textctrl - //void SetSelection(long from, long to); - -protected: - // generic double valued - double DoGetValue() const - { - double n; - if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) ) - n = INT_MIN; - - return n; - } - - bool DoSetValue(double val, SendEvent sendEvent) - { - wxString str(wxString::Format(m_format, val)); - switch ( sendEvent ) - { - case SendEvent_None: - wxTextCtrl::ChangeValue(str); - break; - - case SendEvent_Text: - wxTextCtrl::SetValue(str); - break; - } - - return true; - } - void DoSetRange(double min_val, double max_val) - { - m_min = min_val; - m_max = max_val; - } - void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused - - double m_value; - double m_min; - double m_max; - double m_increment; - bool m_snap_to_ticks; - wxString m_format; -}; - -#endif // wxUSE_SPINBTN/!wxUSE_SPINBTN - -#if !defined(wxHAS_NATIVE_SPINCTRL) - -//----------------------------------------------------------------------------- -// wxSpinCtrl -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase +class WXDLLEXPORT wxSpinCtrl : public wxControl { public: wxSpinCtrl() { Init(); } + wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + long style = wxSP_ARROW_KEYS, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { Init(); - Create(parent, id, value, pos, size, style, min, max, initial, name); } @@ -305,72 +52,82 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + long style = wxSP_ARROW_KEYS, int min = 0, int max = 100, int initial = 0, - const wxString& name = wxT("wxSpinCtrl")) - { - return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, - style, min, max, initial, 1, name); - } + const wxString& name = wxT("wxSpinCtrl")); - // accessors - int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); } - int GetMin() const { return int(m_min); } - int GetMax() const { return int(m_max); } - int GetIncrement() const { return int(m_increment); } + virtual ~wxSpinCtrl(); // operations - void SetValue(const wxString& value) - { wxSpinCtrlGenericBase::SetValue(value); } - void SetValue( int value ) { DoSetValue(value, SendEvent_None); } - void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } - void SetIncrement(int inc) { DoSetIncrement(inc); } + void SetValue(int val); + void SetValue(const wxString& text); + void SetRange(int min, int max); + void SetSelection(long from, long to); - virtual int GetBase() const { return m_base; } - virtual bool SetBase(int base); + // accessors + int GetValue() const; + int GetMin() const; + int GetMax() const; + + // implementation from now on + + // forward these functions to all subcontrols + virtual bool Enable(bool enable = true); + virtual bool Show(bool show = true); + virtual bool Reparent(wxWindow *newParent); + + // get the subcontrols + wxTextCtrl *GetText() const { return m_text; } + wxSpinButton *GetSpinButton() const { return m_btn; } + + // set the value of the text (only) + void SetTextValue(int val); + + // put the numeric value of the string in the text ctrl into val and return + // true or return false if the text ctrl doesn't contain a number or if the + // number is out of range + bool GetTextValue(int *val) const; protected: - virtual void DoSendEvent(); + // override the base class virtuals involved into geometry calculations + virtual wxSize DoGetBestSize() const; + virtual void DoMoveWindow(int x, int y, int width, int height); - virtual bool DoTextToValue(const wxString& text, double *val); - virtual wxString DoValueToText(double val); + // common part of all ctors + void Init(); private: - // Common part of all ctors. - void Init() - { - m_base = 10; - } - - int m_base; + // the subcontrols + wxTextCtrl *m_text; + wxSpinButton *m_btn; +private: DECLARE_DYNAMIC_CLASS(wxSpinCtrl) }; -#endif // wxHAS_NATIVE_SPINCTRL +#else // !wxUSE_SPINBTN -//----------------------------------------------------------------------------- -// wxSpinCtrlDouble -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// wxSpinCtrl is just a text control +// ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase +#include "wx/textctrl.h" + +class WXDLLEXPORT wxSpinCtrl : public wxTextCtrl { public: - wxSpinCtrlDouble() { Init(); } - wxSpinCtrlDouble(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, - double min = 0, double max = 100, double initial = 0, - double inc = 1, - const wxString& name = wxT("wxSpinCtrlDouble")) - { - Init(); + wxSpinCtrl() { Init(); } - Create(parent, id, value, pos, size, style, - min, max, initial, inc, name); + wxSpinCtrl(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSP_ARROW_KEYS, + int min = 0, int max = 100, int initial = 0, + const wxString& name = wxT("wxSpinCtrl")) + { + Create(parent, id, value, pos, size, style, min, max, initial, name); } bool Create(wxWindow *parent, @@ -378,55 +135,49 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, - double min = 0, double max = 100, double initial = 0, - double inc = 1, - const wxString& name = wxT("wxSpinCtrlDouble")) + long style = wxSP_ARROW_KEYS, + int min = 0, int max = 100, int initial = 0, + const wxString& name = wxT("wxSpinCtrl")) { - return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, - style, min, max, initial, - inc, name); + SetRange(min, max); + + bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style, + wxDefaultValidator, name); + SetValue(initial); + + return ok; } // accessors - double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); } - double GetMin() const { return m_min; } - double GetMax() const { return m_max; } - double GetIncrement() const { return m_increment; } - unsigned GetDigits() const { return m_digits; } - - // operations - void SetValue(const wxString& value) - { wxSpinCtrlGenericBase::SetValue(value); } - void SetValue(double value) { DoSetValue(value, SendEvent_None); } - void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } - void SetIncrement(double inc) { DoSetIncrement(inc); } - void SetDigits(unsigned digits); - - // We don't implement bases support for floating point numbers, this is not - // very useful in practice. - virtual int GetBase() const { return 10; } - virtual bool SetBase(int WXUNUSED(base)) { return 0; } - -protected: - virtual void DoSendEvent(); - - virtual bool DoTextToValue(const wxString& text, double *val); - virtual wxString DoValueToText(double val); - - unsigned m_digits; - -private: - // Common part of all ctors. - void Init() + int GetValue(int WXUNUSED(dummy) = 1) const { - m_digits = 0; - m_format = wxS("%g"); + int n; + if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n) != 1) ) + n = INT_MIN; + + return n; } - wxString m_format; + int GetMin() const { return m_min; } + int GetMax() const { return m_max; } - DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble) + // operations + void SetValue(const wxString& value) { wxTextCtrl::SetValue(value); } + void SetValue(int val) { wxString s; s << val; wxTextCtrl::SetValue(s); } + void SetRange(int min, int max) { m_min = min; m_max = max; } + +protected: + // initialize m_min/max with the default values + void Init() { SetRange(0, 100); } + + int m_min; + int m_max; + +private: + DECLARE_DYNAMIC_CLASS(wxSpinCtrl) }; +#endif // wxUSE_SPINBTN/!wxUSE_SPINBTN + #endif // _WX_GENERIC_SPINCTRL_H_ + diff --git a/Source/3rd Party/wx/include/wx/generic/splash.h b/Source/3rd Party/wx/include/wx/generic/splash.h deleted file mode 100644 index 24ad733d5..000000000 --- a/Source/3rd Party/wx/include/wx/generic/splash.h +++ /dev/null @@ -1,97 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/splash.h -// Purpose: Splash screen class -// Author: Julian Smart -// Modified by: -// Created: 28/6/2000 -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SPLASH_H_ -#define _WX_SPLASH_H_ - -#include "wx/bitmap.h" -#include "wx/eventfilter.h" -#include "wx/frame.h" -#include "wx/timer.h" - - -/* - * A window for displaying a splash screen - */ - -#define wxSPLASH_CENTRE_ON_PARENT 0x01 -#define wxSPLASH_CENTRE_ON_SCREEN 0x02 -#define wxSPLASH_NO_CENTRE 0x00 -#define wxSPLASH_TIMEOUT 0x04 -#define wxSPLASH_NO_TIMEOUT 0x00 - -class WXDLLIMPEXP_FWD_ADV wxSplashScreenWindow; - -/* - * wxSplashScreen - */ - -class WXDLLIMPEXP_ADV wxSplashScreen: public wxFrame, - public wxEventFilter -{ -public: - // for RTTI macros only - wxSplashScreen() { Init(); } - wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, - wxWindow* parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP); - virtual ~wxSplashScreen(); - - void OnCloseWindow(wxCloseEvent& event); - void OnNotify(wxTimerEvent& event); - - long GetSplashStyle() const { return m_splashStyle; } - wxSplashScreenWindow* GetSplashWindow() const { return m_window; } - int GetTimeout() const { return m_milliseconds; } - - // Override wxEventFilter method to hide splash screen on any user input. - virtual int FilterEvent(wxEvent& event); - -protected: - // Common part of all ctors. - void Init(); - - wxSplashScreenWindow* m_window; - long m_splashStyle; - int m_milliseconds; - wxTimer m_timer; - - DECLARE_DYNAMIC_CLASS(wxSplashScreen) - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxSplashScreen); -}; - -/* - * wxSplashScreenWindow - */ - -class WXDLLIMPEXP_ADV wxSplashScreenWindow: public wxWindow -{ -public: - wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER); - - void OnPaint(wxPaintEvent& event); - void OnEraseBackground(wxEraseEvent& event); - - void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } - wxBitmap& GetBitmap() { return m_bitmap; } - -protected: - wxBitmap m_bitmap; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxSplashScreenWindow); -}; - - -#endif - // _WX_SPLASH_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/splitter.h b/Source/3rd Party/wx/include/wx/generic/splitter.h index a6afbfbab..14012b1b8 100644 --- a/Source/3rd Party/wx/include/wx/generic/splitter.h +++ b/Source/3rd Party/wx/include/wx/generic/splitter.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/splitter.h +// Name: wx/splitter.h // Purpose: wxSplitterWindow class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: splitter.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -48,7 +49,7 @@ enum // to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be // standard). -class WXDLLIMPEXP_CORE wxSplitterWindow: public wxNavigationEnabled +class WXDLLEXPORT wxSplitterWindow: public wxWindow { public: @@ -118,7 +119,7 @@ public: // Removes the specified (or second) window from the view // Doesn't actually delete the window. - bool Unsplit(wxWindow *toRemove = NULL); + bool Unsplit(wxWindow *toRemove = (wxWindow *) NULL); // Replaces one of the windows with another one (neither old nor new // parameter should be NULL) @@ -132,17 +133,14 @@ public: // Is the window split? bool IsSplit() const { return (m_windowTwo != NULL); } + // Sets the sash size + void SetSashSize(int width) { m_sashSize = width; } + // Sets the border size void SetBorderSize(int WXUNUSED(width)) { } - // Hide or show the sash and test whether it's currently hidden. - void SetSashInvisible(bool invisible = true); - bool IsSashInvisible() const { return HasFlag(wxSP_NOSASH); } - - // Gets the current sash size which may be 0 if it's hidden and the default - // sash size. + // Gets the sash size int GetSashSize() const; - int GetDefaultSashSize() const; // Gets the border size int GetBorderSize() const; @@ -195,9 +193,6 @@ public: // Handles mouse events void OnMouseEvent(wxMouseEvent& ev); - // Aborts dragging mode - void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); - // Adjusts the panes void OnSize(wxSizeEvent& event); @@ -211,19 +206,18 @@ public: virtual void DrawSashTracker(int x, int y); // Tests for x, y over sash - virtual bool SashHitTest(int x, int y); + virtual bool SashHitTest(int x, int y, int tolerance = 5); // Resizes subwindows virtual void SizeWindows(); + void SetNeedUpdating(bool needUpdating) { m_needUpdating = needUpdating; } + bool GetNeedUpdating() const { return m_needUpdating ; } + #ifdef __WXMAC__ virtual bool MacClipGrandChildren() const { return true ; } #endif - // Sets the sash size: this doesn't do anything and shouldn't be used at - // all any more. - wxDEPRECATED_INLINE( void SetSashSize(int WXUNUSED(width)), return; ) - protected: // event handlers #if defined(__WXMSW__) || defined(__WXMAC__) @@ -281,15 +275,16 @@ protected: wxWindow* m_windowOne; wxWindow* m_windowTwo; int m_dragMode; - int m_oldX; // current tracker position if not live mode - int m_oldY; // current tracker position if not live mode + int m_oldX; + int m_oldY; int m_sashPosition; // Number of pixels from left or top double m_sashGravity; + int m_sashSize; wxSize m_lastSize; int m_requestedSashPosition; int m_sashPositionCurrent; // while dragging - wxPoint m_ptStart; // mouse position when dragging started - int m_sashStart; // sash position when dragging started + int m_firstX; + int m_firstY; int m_minimumPaneSize; wxCursor m_sashCursorWE; wxCursor m_sashCursorNS; @@ -299,11 +294,14 @@ protected: bool m_needUpdating:1; bool m_permitUnsplitAlways:1; bool m_isHot:1; + bool m_checkRequestedSashPosition:1; private: + WX_DECLARE_CONTROL_CONTAINER(); + DECLARE_DYNAMIC_CLASS(wxSplitterWindow) DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxSplitterWindow); + DECLARE_NO_COPY_CLASS(wxSplitterWindow) }; // ---------------------------------------------------------------------------- @@ -314,18 +312,16 @@ private: // usual wxWin convention, but the three event types have different kind of // data associated with them, so the accessors can be only used if the real // event type matches with the one for which the accessors make sense -class WXDLLIMPEXP_CORE wxSplitterEvent : public wxNotifyEvent +class WXDLLEXPORT wxSplitterEvent : public wxNotifyEvent { public: wxSplitterEvent(wxEventType type = wxEVT_NULL, - wxSplitterWindow *splitter = NULL) + wxSplitterWindow *splitter = (wxSplitterWindow *)NULL) : wxNotifyEvent(type) { SetEventObject(splitter); if (splitter) m_id = splitter->GetId(); } - wxSplitterEvent(const wxSplitterEvent& event) - : wxNotifyEvent(event), m_data(event.m_data) { } // SASH_POS_CHANGED methods @@ -333,16 +329,16 @@ public: // all void SetSashPosition(int pos) { - wxASSERT( GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGED - || GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING); + wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED + || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING); m_data.pos = pos; } int GetSashPosition() const { - wxASSERT( GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGED - || GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING); + wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED + || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING); return m_data.pos; } @@ -350,7 +346,7 @@ public: // UNSPLIT event methods wxWindow *GetWindowBeingRemoved() const { - wxASSERT( GetEventType() == wxEVT_SPLITTER_UNSPLIT ); + wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_UNSPLIT ); return m_data.win; } @@ -358,20 +354,18 @@ public: // DCLICK event methods int GetX() const { - wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED ); + wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED ); return m_data.pt.x; } int GetY() const { - wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED ); + wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED ); return m_data.pt.y; } - virtual wxEvent *Clone() const { return new wxSplitterEvent(*this); } - private: friend class WXDLLIMPEXP_FWD_CORE wxSplitterWindow; @@ -386,16 +380,16 @@ private: } pt; // position of double click for DCLICK event } m_data; - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSplitterEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxSplitterEvent) }; typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&); #define wxSplitterEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSplitterEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSplitterEventFunction, &func) #define wx__DECLARE_SPLITTEREVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_SPLITTER_ ## evt, id, wxSplitterEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_SPLITTER_ ## evt, id, wxSplitterEventHandler(fn)) #define EVT_SPLITTER_SASH_POS_CHANGED(id, fn) \ wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGED, id, fn) @@ -409,11 +403,4 @@ typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&); #define EVT_SPLITTER_UNSPLIT(id, fn) \ wx__DECLARE_SPLITTEREVT(UNSPLIT, id, fn) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED wxEVT_SPLITTER_SASH_POS_CHANGED -#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING wxEVT_SPLITTER_SASH_POS_CHANGING -#define wxEVT_COMMAND_SPLITTER_DOUBLECLICKED wxEVT_SPLITTER_DOUBLECLICKED -#define wxEVT_COMMAND_SPLITTER_UNSPLIT wxEVT_SPLITTER_UNSPLIT - #endif // _WX_GENERIC_SPLITTER_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/srchctlg.h b/Source/3rd Party/wx/include/wx/generic/srchctlg.h index 2613b9a52..8f7a42e52 100644 --- a/Source/3rd Party/wx/include/wx/generic/srchctlg.h +++ b/Source/3rd Party/wx/include/wx/generic/srchctlg.h @@ -3,6 +3,7 @@ // Purpose: generic wxSearchCtrl class // Author: Vince Harron // Created: 2006-02-19 +// RCS-ID: $Id: srchctlg.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: Vince Harron // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ class WXDLLIMPEXP_FWD_CORE wxSearchTextCtrl; // wxSearchCtrl is a combination of wxTextCtrl and wxSearchButton // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase +class WXDLLEXPORT wxSearchCtrl : public wxSearchCtrlBase { public: // creation @@ -61,13 +62,18 @@ public: virtual void ShowCancelButton( bool show ); virtual bool IsCancelButtonVisible() const; +#if wxABI_VERSION >= 20802 // TODO: In 2.9 these should probably be virtual, and declared in the base class... void SetDescriptiveText(const wxString& text); wxString GetDescriptiveText() const; +#endif // accessors // --------- + virtual wxString GetValue() const; + virtual void SetValue(const wxString& value); + virtual wxString GetRange(long from, long to) const; virtual int GetLineLength(long lineNo) const; @@ -190,7 +196,6 @@ public: // wxWindow overrides virtual bool SetFont(const wxFont& font); - virtual bool SetBackgroundColour(const wxColour& colour); // search control generic only void SetSearchBitmap( const wxBitmap& bitmap ); @@ -200,11 +205,7 @@ public: #endif // wxUSE_MENUS protected: - virtual void DoSetValue(const wxString& value, int flags); - virtual wxString DoGetValue() const; - - virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file, int fileType); + virtual void DoSetValue(const wxString& value, int flags = 0); // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestSize() const; @@ -218,7 +219,7 @@ protected: virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop ); virtual wxBitmap RenderCancelBitmap( int x, int y ); - void OnCancelButton( wxCommandEvent& event ); + virtual void OnSearchButton( wxCommandEvent& event ); void OnSetFocus( wxFocusEvent& event ); void OnSize( wxSizeEvent& event ); @@ -235,12 +236,6 @@ protected: private: friend class wxSearchButton; - // Implement pure virtual function inherited from wxCompositeWindow. - virtual wxWindowList GetCompositeWindowParts() const; - - // Position the child controls using the current window size. - void DoLayoutControls(); - #if wxUSE_MENUS void PopupSearchMenu(); #endif // wxUSE_MENUS diff --git a/Source/3rd Party/wx/include/wx/generic/statbmpg.h b/Source/3rd Party/wx/include/wx/generic/statbmpg.h deleted file mode 100644 index f3d198df4..000000000 --- a/Source/3rd Party/wx/include/wx/generic/statbmpg.h +++ /dev/null @@ -1,75 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/statbmpg.h -// Purpose: wxGenericStaticBitmap header -// Author: Marcin Wojdyr, Stefan Csomor -// Created: 2008-06-16 -// Copyright: wxWidgets developers -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_STATBMP_H_ -#define _WX_GENERIC_STATBMP_H_ - -#include "wx/statbmp.h" - -class WXDLLIMPEXP_CORE wxGenericStaticBitmap : public wxStaticBitmapBase -{ -public: - wxGenericStaticBitmap() {} - wxGenericStaticBitmap(wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr) - { - Create(parent, id, bitmap, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr); - - virtual void SetBitmap(const wxBitmap& bitmap) - { - m_bitmap = bitmap; - SetInitialSize(GetBitmapSize()); - Refresh(); - } - - virtual wxBitmap GetBitmap() const { return m_bitmap; } - - virtual void SetIcon(const wxIcon& icon) - { - m_bitmap.CopyFromIcon(icon); - SetInitialSize(GetBitmapSize()); - Refresh(); - } - -#if defined(__WXGTK20__) || defined(__WXMAC__) - // icons and bitmaps are really the same thing in wxGTK and wxMac - wxIcon GetIcon() const { return (const wxIcon &)m_bitmap; } -#endif - - -private: - wxSize GetBitmapSize() - { - return m_bitmap.IsOk() ? m_bitmap.GetScaledSize() - : wxSize(16, 16); // this is completely arbitrary - } - - void OnPaint(wxPaintEvent& event); - - wxBitmap m_bitmap; - - DECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap) -}; - - -#endif //_WX_GENERIC_STATBMP_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/statline.h b/Source/3rd Party/wx/include/wx/generic/statline.h index e151e8b14..4ad6f17fd 100644 --- a/Source/3rd Party/wx/include/wx/generic/statline.h +++ b/Source/3rd Party/wx/include/wx/generic/statline.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/statline.h +// Name: generic/statline.h // Purpose: a generic wxStaticLine class // Author: Vadim Zeitlin // Created: 28.06.99 +// Version: $Id: statline.h 43874 2006-12-09 14:52:59Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,7 @@ class wxStaticBox; // wxStaticLine // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStaticLine : public wxStaticLineBase +class WXDLLEXPORT wxStaticLine : public wxStaticLineBase { DECLARE_DYNAMIC_CLASS(wxStaticLine) diff --git a/Source/3rd Party/wx/include/wx/generic/stattextg.h b/Source/3rd Party/wx/include/wx/generic/stattextg.h deleted file mode 100644 index 918a4f4eb..000000000 --- a/Source/3rd Party/wx/include/wx/generic/stattextg.h +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/stattextg.h -// Purpose: wxGenericStaticText header -// Author: Marcin Wojdyr -// Created: 2008-06-26 -// Copyright: Marcin Wojdyr -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_STATTEXTG_H_ -#define _WX_GENERIC_STATTEXTG_H_ - -// prevent it from including the platform-specific wxStaticText declaration as -// this is not going to compile if it derives from wxGenericStaticText defined -// below (currently this is only the case in wxUniv but it could also happen -// with other ports) -#define wxNO_PORT_STATTEXT_INCLUDE -#include "wx/stattext.h" -#undef wxNO_PORT_STATTEXT_INCLUDE - -class WXDLLIMPEXP_CORE wxGenericStaticText : public wxStaticTextBase -{ -public: - wxGenericStaticText() { Init(); } - - wxGenericStaticText(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticTextNameStr) - { - Init(); - - Create(parent, id, label, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticTextNameStr); - - virtual ~wxGenericStaticText(); - - - // overridden base class virtual methods - virtual void SetLabel(const wxString& label); - virtual bool SetFont(const wxFont &font); - -protected: - virtual wxSize DoGetBestClientSize() const; - - virtual wxString DoGetLabel() const { return m_label; } - virtual void DoSetLabel(const wxString& label); - - void DoSetSize(int x, int y, int width, int height, int sizeFlags); - -#if wxUSE_MARKUP - virtual bool DoSetLabelMarkup(const wxString& markup); -#endif // wxUSE_MARKUP - -private: - void Init() - { -#if wxUSE_MARKUP - m_markupText = NULL; -#endif // wxUSE_MARKUP - } - - void OnPaint(wxPaintEvent& event); - - void DoDrawLabel(wxDC& dc, const wxRect& rect); - - // These fields are only used if m_markupText == NULL. - wxString m_label; - int m_mnemonic; - -#if wxUSE_MARKUP - class wxMarkupText *m_markupText; -#endif // wxUSE_MARKUP - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericStaticText) -}; - -#endif // _WX_GENERIC_STATTEXTG_H_ - diff --git a/Source/3rd Party/wx/include/wx/generic/statusbr.h b/Source/3rd Party/wx/include/wx/generic/statusbr.h index f0827fdc8..5934a9472 100644 --- a/Source/3rd Party/wx/include/wx/generic/statusbr.h +++ b/Source/3rd Party/wx/include/wx/generic/statusbr.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: VZ at 05.02.00 to derive from wxStatusBarBase // Created: 01/02/97 +// RCS-ID: $Id: statusbr.h 41200 2006-09-13 19:10:31Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,18 +19,13 @@ #include "wx/pen.h" #include "wx/arrstr.h" - -// ---------------------------------------------------------------------------- -// wxStatusBarGeneric -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxStatusBarGeneric : public wxStatusBarBase +class WXDLLEXPORT wxStatusBarGeneric : public wxStatusBarBase { public: wxStatusBarGeneric() { Init(); } wxStatusBarGeneric(wxWindow *parent, wxWindowID winid = wxID_ANY, - long style = wxSTB_DEFAULT_STYLE, + long style = wxST_SIZEGRIP, const wxString& name = wxStatusBarNameStr) { Init(); @@ -40,75 +36,67 @@ public: virtual ~wxStatusBarGeneric(); bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY, - long style = wxSTB_DEFAULT_STYLE, + long style = wxST_SIZEGRIP, const wxString& name = wxStatusBarNameStr); - // implement base class methods + // Create status line + virtual void SetFieldsCount(int number = 1, + const int *widths = (const int *) NULL); + + // Set status line text + virtual void SetStatusText(const wxString& text, int number = 0); + virtual wxString GetStatusText(int number = 0) const; + + // Set status line widths virtual void SetStatusWidths(int n, const int widths_field[]); + + // Get the position and size of the field's internal bounding rectangle virtual bool GetFieldRect(int i, wxRect& rect) const; + + // sets the minimal vertical size of the status bar virtual void SetMinHeight(int height); virtual int GetBorderX() const { return m_borderX; } virtual int GetBorderY() const { return m_borderY; } + //////////////////////////////////////////////////////////////////////// + // Implementation - // implementation only (not part of wxStatusBar public API): + virtual void DrawFieldText(wxDC& dc, int i); + virtual void DrawField(wxDC& dc, int i); - int GetFieldFromPoint(const wxPoint& point) const; + void SetBorderX(int x); + void SetBorderY(int y); -protected: - virtual void DoUpdateStatusText(int number); - - // event handlers void OnPaint(wxPaintEvent& event); - void OnSize(wxSizeEvent& event); void OnLeftDown(wxMouseEvent& event); void OnRightDown(wxMouseEvent& event); + virtual void InitColours(); + // Responds to colour changes void OnSysColourChanged(wxSysColourChangedEvent& event); protected: - - virtual void DrawFieldText(wxDC& dc, const wxRect& rc, int i, int textHeight); - virtual void DrawField(wxDC& dc, int i, int textHeight); - - void SetBorderX(int x); - void SetBorderY(int y); - - virtual void InitColours(); - - // true if the status bar shows the size grip: for this it must have - // wxSTB_SIZEGRIP style and the window it is attached to must be resizable - // and not maximized - bool ShowsSizeGrip() const; - - // returns the position and the size of the size grip - wxRect GetSizeGripRect() const; - // common part of all ctors void Init(); - // the last known size, fields widths must be updated whenever it's out of - // date - wxSize m_lastClientSize; + wxArrayString m_statusStrings; - // the absolute widths of the status bar panes in pixels + // the last known width of the client rect (used to rebuild cache) + int m_lastClientWidth; + // the widths of the status bar panes in pixels wxArrayInt m_widthsAbs; int m_borderX; int m_borderY; - wxPen m_mediumShadowPen; wxPen m_hilightPen; virtual wxSize DoGetBestSize() const; private: - // Update m_lastClientSize and m_widthsAbs from the current size. - void DoUpdateFieldWidths(); - DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBarGeneric) }; diff --git a/Source/3rd Party/wx/include/wx/generic/tabg.h b/Source/3rd Party/wx/include/wx/generic/tabg.h deleted file mode 100644 index d376b3b51..000000000 --- a/Source/3rd Party/wx/include/wx/generic/tabg.h +++ /dev/null @@ -1,358 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/tabg.h -// Purpose: Generic tabbed dialogs; used by wxMotif's wxNotebook -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __TABGH_G__ -#define __TABGH_G__ - -#define WXTAB_VERSION 1.1 - -#include "wx/hashmap.h" -#include "wx/string.h" -#include "wx/dialog.h" -#include "wx/panel.h" -#include "wx/list.h" - -class WXDLLIMPEXP_FWD_CORE wxTabView; - -/* - * A wxTabControl is the internal and visual representation - * of the tab. - */ - -class WXDLLIMPEXP_CORE wxTabControl: public wxObject -{ -DECLARE_DYNAMIC_CLASS(wxTabControl) -public: - wxTabControl(wxTabView *v = NULL); - virtual ~wxTabControl(void); - - virtual void OnDraw(wxDC& dc, bool lastInRow); - void SetLabel(const wxString& str) { m_controlLabel = str; } - wxString GetLabel(void) const { return m_controlLabel; } - - void SetFont(const wxFont& f) { m_labelFont = f; } - wxFont *GetFont(void) const { return (wxFont*) & m_labelFont; } - - void SetSelected(bool sel) { m_isSelected = sel; } - bool IsSelected(void) const { return m_isSelected; } - - void SetPosition(int x, int y) { m_offsetX = x; m_offsetY = y; } - void SetSize(int x, int y) { m_width = x; m_height = y; } - - void SetRowPosition(int r) { m_rowPosition = r; } - int GetRowPosition() const { return m_rowPosition; } - void SetColPosition(int c) { m_colPosition = c; } - int GetColPosition() const { return m_colPosition; } - - int GetX(void) const { return m_offsetX; } - int GetY(void) const { return m_offsetY; } - int GetWidth(void) const { return m_width; } - int GetHeight(void) const { return m_height; } - - int GetId(void) const { return m_id; } - void SetId(int i) { m_id = i; } - - virtual bool HitTest(int x, int y) const ; - -protected: - wxTabView* m_view; - wxString m_controlLabel; - bool m_isSelected; - wxFont m_labelFont; - int m_offsetX; // Offsets from top-left of tab view area (the area below the tabs) - int m_offsetY; - int m_width; - int m_height; - int m_id; - int m_rowPosition; // Position in row from 0 - int m_colPosition; // Position in col from 0 -}; - -/* - * Each wxTabLayer is a list of tabs. E.g. there - * are 3 layers in the MS Word Options dialog. - */ - -class WXDLLIMPEXP_CORE wxTabLayer: public wxList -{ -}; - -/* - * The wxTabView controls and draws the tabbed object - */ - -WX_DECLARE_LIST(wxTabLayer, wxTabLayerList); - -#define wxTAB_STYLE_DRAW_BOX 1 // Draws 3D boxes round tab layers -#define wxTAB_STYLE_COLOUR_INTERIOR 2 // Colours interior of tabs, otherwise draws outline - -class WXDLLIMPEXP_CORE wxTabView: public wxObject -{ -DECLARE_DYNAMIC_CLASS(wxTabView) -public: - wxTabView(long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); - virtual ~wxTabView(); - - inline int GetNumberOfLayers() const { return m_layers.GetCount(); } - inline wxTabLayerList& GetLayers() { return m_layers; } - - inline void SetWindow(wxWindow* wnd) { m_window = wnd; } - inline wxWindow* GetWindow(void) const { return m_window; } - - // Automatically positions tabs - wxTabControl *AddTab(int id, const wxString& label, wxTabControl *existingTab = NULL); - - // Remove the tab without deleting the window - bool RemoveTab(int id); - - void ClearTabs(bool deleteTabs = true); - - bool SetTabText(int id, const wxString& label); - wxString GetTabText(int id) const; - - // Layout tabs (optional, e.g. if resizing window) - void LayoutTabs(); - - // Draw all tabs - virtual void Draw(wxDC& dc); - - // Process mouse event, return false if we didn't process it - virtual bool OnEvent(wxMouseEvent& event); - - // Called when a tab is activated - virtual void OnTabActivate(int activateId, int deactivateId); - // Allows vetoing - virtual bool OnTabPreActivate(int WXUNUSED(activateId), int WXUNUSED(deactivateId) ) { return true; } - - // Allows use of application-supplied wxTabControl classes. - virtual wxTabControl *OnCreateTabControl(void) { return new wxTabControl(this); } - - void SetHighlightColour(const wxColour& col); - void SetShadowColour(const wxColour& col); - void SetBackgroundColour(const wxColour& col); - inline void SetTextColour(const wxColour& col) { m_textColour = col; } - - inline wxColour GetHighlightColour(void) const { return m_highlightColour; } - inline wxColour GetShadowColour(void) const { return m_shadowColour; } - inline wxColour GetBackgroundColour(void) const { return m_backgroundColour; } - inline wxColour GetTextColour(void) const { return m_textColour; } - inline const wxPen *GetHighlightPen(void) const { return m_highlightPen; } - inline const wxPen *GetShadowPen(void) const { return m_shadowPen; } - inline const wxPen *GetBackgroundPen(void) const { return m_backgroundPen; } - inline const wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; } - - inline void SetViewRect(const wxRect& rect) { m_tabViewRect = rect; } - inline wxRect GetViewRect(void) const { return m_tabViewRect; } - - // Calculate tab width to fit to view, and optionally adjust the view - // to fit the tabs exactly. - int CalculateTabWidth(int noTabs, bool adjustView = false); - - inline void SetTabStyle(long style) { m_tabStyle = style; } - inline long GetTabStyle(void) const { return m_tabStyle; } - - inline void SetTabSize(int w, int h) { m_tabWidth = w; m_tabHeight = h; } - inline int GetTabWidth(void) const { return m_tabWidth; } - inline int GetTabHeight(void) const { return m_tabHeight; } - inline void SetTabSelectionHeight(int h) { m_tabSelectionHeight = h; } - inline int GetTabSelectionHeight(void) const { return m_tabSelectionHeight; } - - // Returns the total height of the tabs component -- this may be several - // times the height of a tab, if there are several tab layers (rows). - int GetTotalTabHeight(); - - inline int GetTopMargin(void) const { return m_topMargin; } - inline void SetTopMargin(int margin) { m_topMargin = margin; } - - void SetTabSelection(int sel, bool activateTool = true); - inline int GetTabSelection() const { return m_tabSelection; } - - // Find tab control for id - wxTabControl *FindTabControlForId(int id) const ; - - // Find tab control for layer, position (starting from zero) - wxTabControl *FindTabControlForPosition(int layer, int position) const ; - - inline int GetHorizontalTabOffset() const { return m_tabHorizontalOffset; } - inline int GetHorizontalTabSpacing() const { return m_tabHorizontalSpacing; } - inline void SetHorizontalTabOffset(int sp) { m_tabHorizontalOffset = sp; } - inline void SetHorizontalTabSpacing(int sp) { m_tabHorizontalSpacing = sp; } - - inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; } - inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; } - - inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; } - inline void SetTabFont(const wxFont& f) { m_tabFont = f; } - - inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; } - inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; } - // Find the node and the column at which this control is positioned. - wxList::compatibility_iterator FindTabNodeAndColumn(wxTabControl *control, int *col) const ; - - // Do the necessary to change to this tab - virtual bool ChangeTab(wxTabControl *control); - - // Move the selected tab to the bottom layer, if necessary, - // without calling app activation code - bool MoveSelectionTab(wxTabControl *control); - - inline int GetNumberOfTabs() const { return m_noTabs; } - -protected: - // List of layers, from front to back. - wxTabLayerList m_layers; - - // Selected tab - int m_tabSelection; - - // Usual tab height - int m_tabHeight; - - // The height of the selected tab - int m_tabSelectionHeight; - - // Usual tab width - int m_tabWidth; - - // Space between tabs - int m_tabHorizontalSpacing; - - // Space between top of normal tab and text - int m_tabVerticalTextSpacing; - - // Horizontal offset of each tab row above the first - int m_tabHorizontalOffset; - - // The distance between the bottom of the first tab row - // and the top of the client area (i.e. the margin) - int m_topMargin; - - // The position and size of the view above which the tabs are placed. - // I.e., the internal client area of the sheet. - wxRect m_tabViewRect; - - // Bitlist of styles - long m_tabStyle; - - // Colours - wxColour m_highlightColour; - wxColour m_shadowColour; - wxColour m_backgroundColour; - wxColour m_textColour; - - // Pen and brush cache - const wxPen* m_highlightPen; - const wxPen* m_shadowPen; - const wxPen* m_backgroundPen; - const wxBrush* m_backgroundBrush; - - wxFont m_tabFont; - wxFont m_tabSelectedFont; - - int m_noTabs; - - wxWindow* m_window; -}; - -/* - * A dialog box class that is tab-friendly - */ - -class WXDLLIMPEXP_CORE wxTabbedDialog : public wxDialog -{ - DECLARE_DYNAMIC_CLASS(wxTabbedDialog) - -public: - wxTabbedDialog(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long windowStyle = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr); - virtual ~wxTabbedDialog(); - - wxTabView *GetTabView() const { return m_tabView; } - void SetTabView(wxTabView *v) { m_tabView = v; } - - void OnCloseWindow(wxCloseEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnPaint(wxPaintEvent& event); - -protected: - wxTabView* m_tabView; - -private: - DECLARE_EVENT_TABLE() -}; - -/* - * A panel class that is tab-friendly - */ - -class WXDLLIMPEXP_CORE wxTabbedPanel : public wxPanel -{ - DECLARE_DYNAMIC_CLASS(wxTabbedPanel) - -public: - wxTabbedPanel(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long windowStyle = 0, - const wxString& name = wxPanelNameStr); - virtual ~wxTabbedPanel(); - - wxTabView *GetTabView() const { return m_tabView; } - void SetTabView(wxTabView *v) { m_tabView = v; } - - void OnMouseEvent(wxMouseEvent& event); - void OnPaint(wxPaintEvent& event); - -protected: - wxTabView* m_tabView; - -private: - DECLARE_EVENT_TABLE() -}; - -WX_DECLARE_HASH_MAP(int, wxWindow*, wxIntegerHash, wxIntegerEqual, - wxIntToWindowHashMap); - -class WXDLLIMPEXP_CORE wxPanelTabView : public wxTabView -{ - DECLARE_DYNAMIC_CLASS(wxPanelTabView) - -public: - wxPanelTabView(wxPanel *pan, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); - virtual ~wxPanelTabView(void); - - // Called when a tab is activated - virtual void OnTabActivate(int activateId, int deactivateId); - - // Specific to this class - void AddTabWindow(int id, wxWindow *window); - wxWindow *GetTabWindow(int id) const ; - void ClearWindows(bool deleteWindows = true); - wxWindow *GetCurrentWindow() const { return m_currentWindow; } - - void ShowWindowForTab(int id); - // wxList& GetWindows() const { return (wxList&) m_tabWindows; } - -protected: - // List of panels, one for each tab. Indexed - // by tab ID. - wxIntToWindowHashMap m_tabWindows; - wxWindow* m_currentWindow; - wxPanel* m_panel; -}; - -#endif - diff --git a/Source/3rd Party/wx/include/wx/generic/textdlgg.h b/Source/3rd Party/wx/include/wx/generic/textdlgg.h index 02a64227e..fab9a1012 100644 --- a/Source/3rd Party/wx/include/wx/generic/textdlgg.h +++ b/Source/3rd Party/wx/include/wx/generic/textdlgg.h @@ -1,15 +1,16 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/textdlgg.h +// Name: textdlgg.h // Purpose: wxTextEntryDialog class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: textdlgg.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_TEXTDLGG_H_ -#define _WX_TEXTDLGG_H_ +#ifndef __TEXTDLGH_G__ +#define __TEXTDLGH_G__ #include "wx/defs.h" @@ -19,13 +20,12 @@ #if wxUSE_VALIDATORS #include "wx/valtext.h" -#include "wx/textctrl.h" #endif class WXDLLIMPEXP_FWD_CORE wxTextCtrl; -extern WXDLLIMPEXP_DATA_CORE(const char) wxGetTextFromUserPromptStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxGetTextFromUserPromptStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxGetPasswordFromUserPromptStr[]; #define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY) @@ -33,47 +33,25 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[]; // wxTextEntryDialog: a dialog with text control, [ok] and [cancel] buttons // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTextEntryDialog : public wxDialog +class WXDLLEXPORT wxTextEntryDialog : public wxDialog { public: - wxTextEntryDialog() - { - m_textctrl = NULL; - } - wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr, const wxString& value = wxEmptyString, long style = wxTextEntryDialogStyle, - const wxPoint& pos = wxDefaultPosition) - { - Create(parent, message, caption, value, style, pos); - } - - bool Create(wxWindow *parent, - const wxString& message, - const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& value = wxEmptyString, - long style = wxTextEntryDialogStyle, - const wxPoint& pos = wxDefaultPosition); + const wxPoint& pos = wxDefaultPosition); void SetValue(const wxString& val); wxString GetValue() const { return m_value; } - void SetMaxLength(unsigned long len); - #if wxUSE_VALIDATORS void SetTextValidator( const wxTextValidator& validator ); -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void SetTextValidator( long style ) ); -#endif - void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE ); + void SetTextValidator( long style = wxFILTER_NONE ); wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); } -#endif // wxUSE_VALIDATORS - - virtual bool TransferDataToWindow(); - virtual bool TransferDataFromWindow(); +#endif + // wxUSE_VALIDATORS // implementation only void OnOK(wxCommandEvent& event); @@ -86,14 +64,14 @@ protected: private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxTextEntryDialog) - wxDECLARE_NO_COPY_CLASS(wxTextEntryDialog); + DECLARE_NO_COPY_CLASS(wxTextEntryDialog) }; // ---------------------------------------------------------------------------- // wxPasswordEntryDialog: dialog with password control, [ok] and [cancel] // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPasswordEntryDialog : public wxTextEntryDialog +class WXDLLEXPORT wxPasswordEntryDialog : public wxTextEntryDialog { public: wxPasswordEntryDialog(wxWindow *parent, @@ -104,31 +82,32 @@ public: const wxPoint& pos = wxDefaultPosition); private: DECLARE_DYNAMIC_CLASS(wxPasswordEntryDialog) - wxDECLARE_NO_COPY_CLASS(wxPasswordEntryDialog); + DECLARE_NO_COPY_CLASS(wxPasswordEntryDialog) }; // ---------------------------------------------------------------------------- // function to get a string from user // ---------------------------------------------------------------------------- -WXDLLIMPEXP_CORE wxString - wxGetTextFromUser(const wxString& message, - const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& default_value = wxEmptyString, - wxWindow *parent = NULL, - wxCoord x = wxDefaultCoord, - wxCoord y = wxDefaultCoord, - bool centre = true); +wxString WXDLLEXPORT +wxGetTextFromUser(const wxString& message, + const wxString& caption = wxGetTextFromUserPromptStr, + const wxString& default_value = wxEmptyString, + wxWindow *parent = (wxWindow *) NULL, + wxCoord x = wxDefaultCoord, + wxCoord y = wxDefaultCoord, + bool centre = true); -WXDLLIMPEXP_CORE wxString - wxGetPasswordFromUser(const wxString& message, - const wxString& caption = wxGetPasswordFromUserPromptStr, - const wxString& default_value = wxEmptyString, - wxWindow *parent = NULL, - wxCoord x = wxDefaultCoord, - wxCoord y = wxDefaultCoord, - bool centre = true); +wxString WXDLLEXPORT +wxGetPasswordFromUser(const wxString& message, + const wxString& caption = wxGetPasswordFromUserPromptStr, + const wxString& default_value = wxEmptyString, + wxWindow *parent = (wxWindow *) NULL, + wxCoord x = wxDefaultCoord, + wxCoord y = wxDefaultCoord, + bool centre = true); #endif // wxUSE_TEXTDLG -#endif // _WX_TEXTDLGG_H_ +#endif + // __TEXTDLGH_G__ diff --git a/Source/3rd Party/wx/include/wx/generic/timectrl.h b/Source/3rd Party/wx/include/wx/generic/timectrl.h deleted file mode 100644 index 20b02498b..000000000 --- a/Source/3rd Party/wx/include/wx/generic/timectrl.h +++ /dev/null @@ -1,69 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/timectrl.h -// Purpose: Generic implementation of wxTimePickerCtrl. -// Author: Paul Breen, Vadim Zeitlin -// Created: 2011-09-22 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_TIMECTRL_H_ -#define _WX_GENERIC_TIMECTRL_H_ - -#include "wx/containr.h" -#include "wx/compositewin.h" - -class WXDLLIMPEXP_ADV wxTimePickerCtrlGeneric - : public wxCompositeWindow< wxNavigationEnabled > -{ -public: - typedef wxCompositeWindow< wxNavigationEnabled > Base; - - // Creating the control. - wxTimePickerCtrlGeneric() { Init(); } - virtual ~wxTimePickerCtrlGeneric(); - wxTimePickerCtrlGeneric(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr) - { - Init(); - - (void)Create(parent, id, date, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr); - - // Implement pure virtual wxTimePickerCtrlBase methods. - virtual void SetValue(const wxDateTime& date); - virtual wxDateTime GetValue() const; - -protected: - virtual wxSize DoGetBestSize() const; - - virtual void DoMoveWindow(int x, int y, int width, int height); - -private: - void Init(); - - // Return the list of the windows composing this one. - virtual wxWindowList GetCompositeWindowParts() const; - - // Implementation data. - class wxTimePickerGenericImpl* m_impl; - - wxDECLARE_NO_COPY_CLASS(wxTimePickerCtrlGeneric); -}; - -#endif // _WX_GENERIC_TIMECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/generic/private/timer.h b/Source/3rd Party/wx/include/wx/generic/timer.h similarity index 66% rename from Source/3rd Party/wx/include/wx/generic/private/timer.h rename to Source/3rd Party/wx/include/wx/generic/timer.h index 6d96389ce..0f52c1b4a 100644 --- a/Source/3rd Party/wx/include/wx/generic/private/timer.h +++ b/Source/3rd Party/wx/include/wx/generic/timer.h @@ -1,17 +1,15 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/private/timer.h +// Name: timer.h // Purpose: Generic implementation of wxTimer class // Author: Vaclav Slavik +// Id: $Id: timer.h 41020 2006-09-05 20:47:48Z VZ $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_GENERIC_PRIVATE_TIMER_H_ -#define _WX_GENERIC_PRIVATE_TIMER_H_ -#if wxUSE_TIMER - -#include "wx/private/timer.h" +#ifndef __WX_TIMER_H__ +#define __WX_TIMER_H__ //----------------------------------------------------------------------------- // wxTimer @@ -19,11 +17,13 @@ class wxTimerDesc; -class WXDLLIMPEXP_BASE wxGenericTimerImpl : public wxTimerImpl +class WXDLLEXPORT wxTimer : public wxTimerBase { public: - wxGenericTimerImpl(wxTimer* timer) : wxTimerImpl(timer) { Init(); } - virtual ~wxGenericTimerImpl(); + wxTimer() { Init(); } + wxTimer(wxEvtHandler *owner, int timerid = -1) : wxTimerBase(owner, timerid) + { Init(); } + virtual ~wxTimer(); virtual bool Start(int millisecs = -1, bool oneShot = false); virtual void Stop(); @@ -38,8 +38,8 @@ protected: private: wxTimerDesc *m_desc; + + DECLARE_ABSTRACT_CLASS(wxTimer) }; -#endif // wxUSE_TIMER - -#endif // _WX_GENERIC_PRIVATE_TIMER_H_ +#endif // __WX_TIMER_H__ diff --git a/Source/3rd Party/wx/include/wx/generic/treectlg.h b/Source/3rd Party/wx/include/wx/generic/treectlg.h index 39b473397..818c8a31c 100644 --- a/Source/3rd Party/wx/include/wx/generic/treectlg.h +++ b/Source/3rd Party/wx/include/wx/generic/treectlg.h @@ -4,6 +4,7 @@ // Author: Robert Roebling // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: treectlg.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 1997,1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -33,7 +34,7 @@ class WXDLLIMPEXP_FWD_CORE wxTextCtrl; // wxGenericTreeCtrl - the tree control // ----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGenericTreeCtrl : public wxTreeCtrlBase, +class WXDLLEXPORT wxGenericTreeCtrl : public wxTreeCtrlBase, public wxScrollHelper { public: @@ -64,6 +65,7 @@ public: const wxValidator &validator = wxDefaultValidator, const wxString& name = wxTreeCtrlNameStr); + // implement base class pure virtuals // ---------------------------------- @@ -110,18 +112,8 @@ public: // ---------- virtual wxTreeItemId GetRootItem() const { return m_anchor; } - virtual wxTreeItemId GetSelection() const - { - wxASSERT_MSG( !HasFlag(wxTR_MULTIPLE), - wxT("must use GetSelections() with this control") ); - - return m_current; - } + virtual wxTreeItemId GetSelection() const { return m_current; } virtual size_t GetSelections(wxArrayTreeItemIds&) const; - virtual wxTreeItemId GetFocusedItem() const { return m_current; } - - virtual void ClearFocusedItem(); - virtual void SetFocusedItem(const wxTreeItemId& item); virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const; virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item, @@ -156,19 +148,16 @@ public: virtual void Unselect(); virtual void UnselectAll(); virtual void SelectItem(const wxTreeItemId& item, bool select = true); - virtual void SelectChildren(const wxTreeItemId& parent); virtual void EnsureVisible(const wxTreeItemId& item); virtual void ScrollTo(const wxTreeItemId& item); virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, - wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)); + wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)); virtual wxTextCtrl *GetEditControl() const; virtual void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false); - virtual void EnableBellOnNoMatch(bool on = true); - virtual void SortChildren(const wxTreeItemId& item); // items geometry @@ -196,12 +185,29 @@ public: void Edit( const wxTreeItemId& item ) { EditLabel(item); } #endif // WXWIN_COMPATIBILITY_2_6 +#if WXWIN_COMPATIBILITY_2_4 + // deprecated functions: use Set/GetItemImage directly + wxDEPRECATED( int GetItemSelectedImage(const wxTreeItemId& item) const ); + wxDEPRECATED( void SetItemSelectedImage(const wxTreeItemId& item, int image) ); + + // use the versions taking wxTreeItemIdValue cookies (note that + // GetNextChild() is not inside wxDEPRECATED on purpose, as otherwise we + // get twice as many warnings without any added benefit: it is always used + // with GetFirstChild() anyhow) + wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, + long& cookie) const ); + wxTreeItemId GetNextChild(const wxTreeItemId& item, + long& cookie) const; +#endif // WXWIN_COMPATIBILITY_2_4 + // implementation only from now on // overridden base class virtuals virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); + virtual void Freeze(); + virtual void Thaw(); virtual void Refresh(bool eraseBackground = true, const wxRect *rect = NULL); virtual bool SetFont( const wxFont &font ); @@ -211,7 +217,6 @@ public: void OnPaint( wxPaintEvent &event ); void OnSetFocus( wxFocusEvent &event ); void OnKillFocus( wxFocusEvent &event ); - void OnKeyDown( wxKeyEvent &event ); void OnChar( wxKeyEvent &event ); void OnMouse( wxMouseEvent &event ); void OnGetToolTip( wxTreeEvent &event ); @@ -257,37 +262,26 @@ protected: bool m_lastOnSame; // last click on the same item as prev wxImageList *m_imageListButtons; + int m_freezeCount; int m_dragCount; wxPoint m_dragStart; wxGenericTreeItem *m_dropTarget; wxCursor m_oldCursor; // cursor is changed while dragging wxGenericTreeItem *m_oldSelection; wxGenericTreeItem *m_underMouse; // for visual effects - - enum { NoEffect, BorderEffect, AboveEffect, BelowEffect } m_dndEffect; - wxGenericTreeItem *m_dndEffectItem; - wxTreeTextCtrl *m_textCtrl; - wxTimer *m_renameTimer; // incremental search data wxString m_findPrefix; wxTimer *m_findTimer; - // This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1 - // if it is globally enabled but has been temporarily disabled because we - // had already beeped for this particular search. - int m_findBell; bool m_dropEffectAboveItem; // the common part of all ctors void Init(); - // overridden wxWindow methods - virtual void DoThaw(); - // misc helpers void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted); @@ -299,9 +293,6 @@ protected: bool unselect_others = true, bool extended_select = false); - virtual int DoGetItemState(const wxTreeItemId& item) const; - virtual void DoSetItemState(const wxTreeItemId& item, int state); - virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent, size_t previous, const wxString& text, @@ -330,6 +321,7 @@ protected: void CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ); void CalculatePositions(); + void CalculateSize( wxGenericTreeItem *item, wxDC &dc ); void RefreshSubtree( wxGenericTreeItem *item ); void RefreshLine( wxGenericTreeItem *item ); @@ -356,13 +348,9 @@ protected: virtual wxSize DoGetBestSize() const; private: - // Reset the state of the last find (i.e. keyboard incremental search) - // operation. - void ResetFindState(); - DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl) - wxDECLARE_NO_COPY_CLASS(wxGenericTreeCtrl); + DECLARE_NO_COPY_CLASS(wxGenericTreeCtrl) }; #if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) @@ -371,7 +359,7 @@ private: * the run-time information. */ -class WXDLLIMPEXP_CORE wxTreeCtrl: public wxGenericTreeCtrl +class WXDLLEXPORT wxTreeCtrl: public wxGenericTreeCtrl { DECLARE_DYNAMIC_CLASS(wxTreeCtrl) diff --git a/Source/3rd Party/wx/include/wx/generic/wizard.h b/Source/3rd Party/wx/include/wx/generic/wizard.h deleted file mode 100644 index 216187007..000000000 --- a/Source/3rd Party/wx/include/wx/generic/wizard.h +++ /dev/null @@ -1,168 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/generic/wizard.h -// Purpose: declaration of generic wxWizard class -// Author: Vadim Zeitlin -// Modified by: Robert Vazan (sizers) -// Created: 28.09.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_WIZARD_H_ -#define _WX_GENERIC_WIZARD_H_ - -// ---------------------------------------------------------------------------- -// wxWizard -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxButton; -class WXDLLIMPEXP_FWD_CORE wxStaticBitmap; -class WXDLLIMPEXP_FWD_ADV wxWizardEvent; -class WXDLLIMPEXP_FWD_CORE wxBoxSizer; -class WXDLLIMPEXP_FWD_ADV wxWizardSizer; - -class WXDLLIMPEXP_ADV wxWizard : public wxWizardBase -{ -public: - // ctor - wxWizard() { Init(); } - wxWizard(wxWindow *parent, - int id = wxID_ANY, - const wxString& title = wxEmptyString, - const wxBitmap& bitmap = wxNullBitmap, - const wxPoint& pos = wxDefaultPosition, - long style = wxDEFAULT_DIALOG_STYLE) - { - Init(); - Create(parent, id, title, bitmap, pos, style); - } - bool Create(wxWindow *parent, - int id = wxID_ANY, - const wxString& title = wxEmptyString, - const wxBitmap& bitmap = wxNullBitmap, - const wxPoint& pos = wxDefaultPosition, - long style = wxDEFAULT_DIALOG_STYLE); - void Init(); - virtual ~wxWizard(); - - // implement base class pure virtuals - virtual bool RunWizard(wxWizardPage *firstPage); - virtual wxWizardPage *GetCurrentPage() const; - virtual void SetPageSize(const wxSize& size); - virtual wxSize GetPageSize() const; - virtual void FitToPage(const wxWizardPage *firstPage); - virtual wxSizer *GetPageAreaSizer() const; - virtual void SetBorder(int border); - - /// set/get bitmap - const wxBitmap& GetBitmap() const { return m_bitmap; } - void SetBitmap(const wxBitmap& bitmap); - - // implementation only from now on - // ------------------------------- - - // is the wizard running? - bool IsRunning() const { return m_page != NULL; } - - // show the prev/next page, but call TransferDataFromWindow on the current - // page first and return false without changing the page if - // TransferDataFromWindow() returns false - otherwise, returns true - virtual bool ShowPage(wxWizardPage *page, bool goingForward = true); - - // do fill the dialog with controls - // this is app-overridable to, for example, set help and tooltip text - virtual void DoCreateControls(); - - // Do the adaptation - virtual bool DoLayoutAdaptation(); - - // Set/get bitmap background colour - void SetBitmapBackgroundColour(const wxColour& colour) { m_bitmapBackgroundColour = colour; } - const wxColour& GetBitmapBackgroundColour() const { return m_bitmapBackgroundColour; } - - // Set/get bitmap placement (centred, tiled etc.) - void SetBitmapPlacement(int placement) { m_bitmapPlacement = placement; } - int GetBitmapPlacement() const { return m_bitmapPlacement; } - - // Set/get minimum bitmap width - void SetMinimumBitmapWidth(int w) { m_bitmapMinimumWidth = w; } - int GetMinimumBitmapWidth() const { return m_bitmapMinimumWidth; } - - // Tile bitmap - static bool TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap); - -protected: - // for compatibility only, doesn't do anything any more - void FinishLayout() { } - - // Do fit, and adjust to screen size if necessary - virtual void DoWizardLayout(); - - // Resize bitmap if necessary - virtual bool ResizeBitmap(wxBitmap& bmp); - - // was the dialog really created? - bool WasCreated() const { return m_btnPrev != NULL; } - - // event handlers - void OnCancel(wxCommandEvent& event); - void OnBackOrNext(wxCommandEvent& event); - void OnHelp(wxCommandEvent& event); - - void OnWizEvent(wxWizardEvent& event); - - void AddBitmapRow(wxBoxSizer *mainColumn); - void AddStaticLine(wxBoxSizer *mainColumn); - void AddBackNextPair(wxBoxSizer *buttonRow); - void AddButtonRow(wxBoxSizer *mainColumn); - - // the page size requested by user - wxSize m_sizePage; - - // the dialog position from the ctor - wxPoint m_posWizard; - - // wizard state - wxWizardPage *m_page; // the current page or NULL - wxBitmap m_bitmap; // the default bitmap to show - - // wizard controls - wxButton *m_btnPrev, // the "" or "Finish" button - wxStaticBitmap *m_statbmp; // the control for the bitmap - - // Border around page area sizer requested using SetBorder() - int m_border; - - // Whether RunWizard() was called - bool m_started; - - // Whether was modal (modeless has to be destroyed on finish or cancel) - bool m_wasModal; - - // True if pages are laid out using the sizer - bool m_usingSizer; - - // Page area sizer will be inserted here with padding - wxBoxSizer *m_sizerBmpAndPage; - - // Actual position and size of pages - wxWizardSizer *m_sizerPage; - - // Bitmap background colour if resizing bitmap - wxColour m_bitmapBackgroundColour; - - // Bitmap placement flags - int m_bitmapPlacement; - - // Minimum bitmap width - int m_bitmapMinimumWidth; - - friend class wxWizardSizer; - - DECLARE_DYNAMIC_CLASS(wxWizard) - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxWizard); -}; - -#endif // _WX_GENERIC_WIZARD_H_ diff --git a/Source/3rd Party/wx/include/wx/geometry.h b/Source/3rd Party/wx/include/wx/geometry.h index ec31fc1c6..c4e67817f 100644 --- a/Source/3rd Party/wx/include/wx/geometry.h +++ b/Source/3rd Party/wx/include/wx/geometry.h @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 08/05/99 +// RCS-ID: $Id: geometry.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 1999 Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -33,7 +34,7 @@ enum wxOutCode wxOutBottom = 0x04 }; -class WXDLLIMPEXP_CORE wxPoint2DInt +class WXDLLEXPORT wxPoint2DInt { public : inline wxPoint2DInt(); @@ -87,12 +88,12 @@ inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt); -inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt); +inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt); +inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n); inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n); -inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n); inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n); -inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n); +inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n); inline wxPoint2DInt::wxPoint2DInt() { @@ -156,7 +157,7 @@ inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const { - return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ); + return ( (wxDouble)(pt.m_x-m_x)*(pt.m_x-m_x) + (wxDouble)(pt.m_y-m_y)*(pt.m_y-m_y) ); } inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const @@ -181,11 +182,8 @@ inline wxPoint2DInt wxPoint2DInt::operator-() inline wxPoint2DInt& wxPoint2DInt::operator=(const wxPoint2DInt& pt) { - if (this != &pt) - { - m_x = pt.m_x; - m_y = pt.m_y; - } + m_x = pt.m_x; + m_y = pt.m_y; return *this; } @@ -205,15 +203,15 @@ inline wxPoint2DInt& wxPoint2DInt::operator-=(const wxPoint2DInt& pt) inline wxPoint2DInt& wxPoint2DInt::operator*=(const wxPoint2DInt& pt) { - m_x = m_x * pt.m_x; - m_y = m_y * pt.m_y; + m_x = m_x + pt.m_x; + m_y = m_y + pt.m_y; return *this; } inline wxPoint2DInt& wxPoint2DInt::operator/=(const wxPoint2DInt& pt) { - m_x = m_x / pt.m_x; - m_y = m_y / pt.m_y; + m_x = m_x - pt.m_x; + m_y = m_y - pt.m_y; return *this; } @@ -250,8 +248,7 @@ inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt) inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt) { - return wxPoint2DInt( static_cast(pt.m_x * n) , - static_cast(pt.m_y * n) ); + return wxPoint2DInt( (int) (pt.m_x * n) , (int) (pt.m_y * n) ); } inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) @@ -261,8 +258,7 @@ inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n) { - return wxPoint2DInt( static_cast(pt.m_x * n) , - static_cast(pt.m_y * n) ); + return wxPoint2DInt( (int) (pt.m_x * n) , (int) (pt.m_y * n) ); } inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) @@ -277,13 +273,12 @@ inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n) inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n) { - return wxPoint2DInt( static_cast(pt.m_x / n) , - static_cast(pt.m_y / n) ); + return wxPoint2DInt( (int) (pt.m_x / n) , (int) (pt.m_y / n) ); } // wxPoint2Ds represent a point or a vector in a 2d coordinate system -class WXDLLIMPEXP_CORE wxPoint2DDouble +class WXDLLEXPORT wxPoint2DDouble { public : inline wxPoint2DDouble(); @@ -416,11 +411,8 @@ inline wxPoint2DDouble wxPoint2DDouble::operator-() inline wxPoint2DDouble& wxPoint2DDouble::operator=(const wxPoint2DDouble& pt) { - if (this != &pt) - { - m_x = pt.m_x; - m_y = pt.m_y; - } + m_x = pt.m_x; + m_y = pt.m_y; return *this; } @@ -517,7 +509,7 @@ inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n) // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if // left <= x < right and top <= m_y < bottom , thus it is a half open interval. -class WXDLLIMPEXP_CORE wxRect2DDouble +class WXDLLEXPORT wxRect2DDouble { public: wxRect2DDouble() @@ -531,13 +523,13 @@ public: */ // single attribute accessors - wxPoint2DDouble GetPosition() const + inline wxPoint2DDouble GetPosition() { return wxPoint2DDouble(m_x, m_y); } - wxSize GetSize() const + inline wxSize GetSize() { return wxSize((int) m_width, (int) m_height); } - // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their - // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately + // for the edge and corner accessors there are two setters conterparts, the Set.. functions keep the other corners at their + // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners apropriately inline wxDouble GetLeft() const { return m_x; } inline void SetLeft( wxDouble n ) { m_width += m_x - n; m_x = n; } @@ -648,7 +640,7 @@ public: // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if // left <= x < right and top <= m_y < bottom , thus it is a half open interval. -class WXDLLIMPEXP_CORE wxRect2DInt +class WXDLLEXPORT wxRect2DInt { public: wxRect2DInt() { m_x = m_y = m_width = m_height = 0; } @@ -660,11 +652,11 @@ public: // single attribute accessors - wxPoint2DInt GetPosition() const { return wxPoint2DInt(m_x, m_y); } - wxSize GetSize() const { return wxSize(m_width, m_height); } + inline wxPoint2DInt GetPosition() { return wxPoint2DInt(m_x, m_y); } + inline wxSize GetSize() { return wxSize(m_width, m_height); } - // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their - // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately + // for the edge and corner accessors there are two setters conterparts, the Set.. functions keep the other corners at their + // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners apropriately inline wxInt32 GetLeft() const { return m_x; } inline void SetLeft( wxInt32 n ) { m_width += m_x - n; m_x = n; } @@ -783,7 +775,7 @@ inline bool wxRect2DInt::operator != (const wxRect2DInt& rect) const return !(*this == rect); } -class WXDLLIMPEXP_CORE wxTransform2D +class wxTransform2D { public : virtual ~wxTransform2D() { } @@ -798,6 +790,24 @@ public : virtual wxRect2DInt InverseTransform( const wxRect2DInt &r ) const ; }; +inline void wxTransform2D::Transform( wxRect2DInt* r ) const + { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom(); Transform( &a ); Transform( &b ); *r = wxRect2DInt( a , b ); } + +inline wxPoint2DInt wxTransform2D::Transform( const wxPoint2DInt &pt ) const + { wxPoint2DInt res = pt; Transform( &res ); return res; } + +inline wxRect2DInt wxTransform2D::Transform( const wxRect2DInt &r ) const + { wxRect2DInt res = r; Transform( &res ); return res; } + +inline void wxTransform2D::InverseTransform( wxRect2DInt* r ) const + { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom(); InverseTransform( &a ); InverseTransform( &b ); *r = wxRect2DInt( a , b ); } + +inline wxPoint2DInt wxTransform2D::InverseTransform( const wxPoint2DInt &pt ) const + { wxPoint2DInt res = pt; InverseTransform( &res ); return res; } + +inline wxRect2DInt wxTransform2D::InverseTransform( const wxRect2DInt &r ) const + { wxRect2DInt res = r; InverseTransform( &res ); return res; } + #endif // wxUSE_GEOMETRY diff --git a/Source/3rd Party/wx/include/wx/gifdecod.h b/Source/3rd Party/wx/include/wx/gifdecod.h index b32e05319..3ada1a19d 100644 --- a/Source/3rd Party/wx/include/wx/gifdecod.h +++ b/Source/3rd Party/wx/include/wx/gifdecod.h @@ -3,6 +3,7 @@ // Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation // Author: Guillermo Rodriguez Garcia // Version: 3.02 +// CVS-ID: $Id: gifdecod.h 45563 2007-04-21 18:17:50Z VZ $ // Copyright: (c) 1999 Guillermo Rodriguez Garcia // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -45,7 +46,7 @@ enum wxGIFErrorCode // wxGIFDecoder class // -------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGIFDecoder : public wxAnimationDecoder +class WXDLLEXPORT wxGIFDecoder : public wxAnimationDecoder { public: // constructor, destructor, etc. @@ -75,6 +76,7 @@ public: void Destroy(); // implementation of wxAnimationDecoder's pure virtuals + virtual bool CanRead( wxInputStream& stream ) const; virtual bool Load( wxInputStream& stream ) { return LoadGIF(stream) == wxGIF_OK; } @@ -86,15 +88,6 @@ public: { return wxANIMATION_TYPE_GIF; } private: - // wxAnimationDecoder pure virtual - virtual bool DoCanRead( wxInputStream& stream ) const; - // modifies current stream position (see wxAnimationDecoder::CanRead) - - int getcode(wxInputStream& stream, int bits, int abfin); - wxGIFErrorCode dgif(wxInputStream& stream, - GIFImage *img, int interl, int bits); - - // array of all frames wxArrayPtrVoid m_frames; @@ -105,9 +98,13 @@ private: unsigned char m_buffer[256]; // buffer for reading unsigned char *m_bufp; // pointer to next byte in buffer - wxDECLARE_NO_COPY_CLASS(wxGIFDecoder); + int getcode(wxInputStream& stream, int bits, int abfin); + wxGIFErrorCode dgif(wxInputStream& stream, + GIFImage *img, int interl, int bits); + + DECLARE_NO_COPY_CLASS(wxGIFDecoder) }; -#endif // wxUSE_STREAMS && wxUSE_GIF +#endif // wxUSE_STREAM && wxUSE_GIF #endif // _WX_GIFDECOD_H_ diff --git a/Source/3rd Party/wx/include/wx/glcanvas.h b/Source/3rd Party/wx/include/wx/glcanvas.h deleted file mode 100644 index 688d4788b..000000000 --- a/Source/3rd Party/wx/include/wx/glcanvas.h +++ /dev/null @@ -1,248 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/glcanvas.h -// Purpose: wxGLCanvas base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GLCANVAS_H_BASE_ -#define _WX_GLCANVAS_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_GLCANVAS - -#include "wx/app.h" -#include "wx/palette.h" -#include "wx/window.h" - -class WXDLLIMPEXP_FWD_GL wxGLCanvas; -class WXDLLIMPEXP_FWD_GL wxGLContext; - -// ---------------------------------------------------------------------------- -// Constants for attributes list -// ---------------------------------------------------------------------------- - -// Notice that not all implementation support options such as stereo, auxiliary -// buffers, alpha channel, and accumulator buffer, use IsDisplaySupported() to -// check for individual attributes support. -enum -{ - WX_GL_RGBA = 1, // use true color palette (on if no attrs specified) - WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA - WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay - WX_GL_DOUBLEBUFFER, // use double buffering (on if no attrs specified) - WX_GL_STEREO, // use stereoscopic display - WX_GL_AUX_BUFFERS, // number of auxiliary buffers - WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits) - WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits) - WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits) - WX_GL_MIN_ALPHA, // use alpha buffer with most bits (> MIN_ALPHA bits) - WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32) - WX_GL_STENCIL_SIZE, // bits for stencil buffer - WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits) - WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits) - WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) - WX_GL_MIN_ACCUM_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits) - WX_GL_SAMPLE_BUFFERS, // 1 for multisampling support (antialiasing) - WX_GL_SAMPLES // 4 for 2x2 antialiasing supersampling on most graphics cards -}; - -#define wxGLCanvasName wxT("GLCanvas") - -// ---------------------------------------------------------------------------- -// wxGLContextBase: OpenGL rendering context -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_GL wxGLContextBase : public wxObject -{ -public: - /* - The derived class should provide a ctor with this signature: - - wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL); - */ - - // set this context as the current one - virtual bool SetCurrent(const wxGLCanvas& win) const = 0; -}; - -// ---------------------------------------------------------------------------- -// wxGLCanvasBase: window which can be used for OpenGL rendering -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_GL wxGLCanvasBase : public wxWindow -{ -public: - // default ctor doesn't initialize the window, use Create() later - wxGLCanvasBase(); - - virtual ~wxGLCanvasBase(); - - - /* - The derived class should provide a ctor with this signature: - - wxGLCanvas(wxWindow *parent, - wxWindowID id = wxID_ANY, - int* attribList = 0, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const wxPalette& palette = wxNullPalette); - */ - - // operations - // ---------- - - // set the given context associated with this window as the current one - bool SetCurrent(const wxGLContext& context) const; - - // flush the back buffer (if we have it) - virtual bool SwapBuffers() = 0; - - - // accessors - // --------- - - // check if the given attributes are supported without creating a canvas - static bool IsDisplaySupported(const int *attribList); - -#if wxUSE_PALETTE - const wxPalette *GetPalette() const { return &m_palette; } -#endif // wxUSE_PALETTE - - // miscellaneous helper functions - // ------------------------------ - - // call glcolor() for the colour with the given name, return false if - // colour not found - bool SetColour(const wxString& colour); - - // return true if the extension with given name is supported - // - // notice that while this function is implemented for all of GLX, WGL and - // AGL the extensions names are usually not the same for different - // platforms and so the code using it still usually uses conditional - // compilation - static bool IsExtensionSupported(const char *extension); - - // deprecated methods using the implicit wxGLContext -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( wxGLContext* GetContext() const ); - - wxDEPRECATED( void SetCurrent() ); - - wxDEPRECATED( void OnSize(wxSizeEvent& event) ); -#endif // WXWIN_COMPATIBILITY_2_8 - -#ifdef __WXUNIVERSAL__ - // resolve the conflict with wxWindowUniv::SetCurrent() - virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); } -#endif - -protected: - // override this to implement SetColour() in GL_INDEX_MODE - // (currently only implemented in wxX11 and wxMotif ports) - virtual int GetColourIndex(const wxColour& WXUNUSED(col)) { return -1; } - - // check if the given extension name is present in the space-separated list - // of extensions supported by the current implementation such as returned - // by glXQueryExtensionsString() or glGetString(GL_EXTENSIONS) - static bool IsExtensionInList(const char *list, const char *extension); - -#if wxUSE_PALETTE - // create default palette if we're not using RGBA mode - // (not supported in most ports) - virtual wxPalette CreateDefaultPalette() { return wxNullPalette; } - - wxPalette m_palette; -#endif // wxUSE_PALETTE - -#if WXWIN_COMPATIBILITY_2_8 - wxGLContext *m_glContext; -#endif // WXWIN_COMPATIBILITY_2_8 -}; - -// ---------------------------------------------------------------------------- -// wxGLApp: a special wxApp subclass for OpenGL applications which must be used -// to select a visual compatible with the given attributes -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_GL wxGLAppBase : public wxApp -{ -public: - wxGLAppBase() : wxApp() { } - - // use this in the constructor of the user-derived wxGLApp class to - // determine if an OpenGL rendering context with these attributes - // is available - returns true if so, false if not. - virtual bool InitGLVisual(const int *attribList) = 0; -}; - -#if defined(__WXMSW__) - #include "wx/msw/glcanvas.h" -#elif defined(__WXMOTIF__) || defined(__WXX11__) - #include "wx/x11/glcanvas.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/glcanvas.h" -#elif defined(__WXGTK__) - #include "wx/gtk1/glcanvas.h" -#elif defined(__WXMAC__) - #include "wx/osx/glcanvas.h" -#elif defined(__WXCOCOA__) - #include "wx/cocoa/glcanvas.h" -#else - #error "wxGLCanvas not supported in this wxWidgets port" -#endif - -// wxMac and wxMSW don't need anything extra in wxGLAppBase, so declare it here -#ifndef wxGL_APP_DEFINED - -class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase -{ -public: - wxGLApp() : wxGLAppBase() { } - - virtual bool InitGLVisual(const int *attribList); - -private: - DECLARE_DYNAMIC_CLASS(wxGLApp) -}; - -#endif // !wxGL_APP_DEFINED - -// ---------------------------------------------------------------------------- -// wxGLAPI: an API wrapper that allows the use of 'old' APIs even on OpenGL -// platforms that don't support it natively anymore, if the APIs are available -// it's a mere redirect -// ---------------------------------------------------------------------------- - -#ifndef wxUSE_OPENGL_EMULATION - #define wxUSE_OPENGL_EMULATION 0 -#endif - -class WXDLLIMPEXP_GL wxGLAPI : public wxObject -{ -public: - wxGLAPI(); - ~wxGLAPI(); - - static void glFrustum(GLfloat left, GLfloat right, GLfloat bottom, - GLfloat top, GLfloat zNear, GLfloat zFar); - static void glBegin(GLenum mode); - static void glTexCoord2f(GLfloat s, GLfloat t); - static void glVertex3f(GLfloat x, GLfloat y, GLfloat z); - static void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); - static void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - static void glColor3f(GLfloat r, GLfloat g, GLfloat b); - static void glEnd(); -}; - -#endif // wxUSE_GLCANVAS - -#endif // _WX_GLCANVAS_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/graphics.h b/Source/3rd Party/wx/include/wx/graphics.h index 5fdcd7541..6d4333bd2 100644 --- a/Source/3rd Party/wx/include/wx/graphics.h +++ b/Source/3rd Party/wx/include/wx/graphics.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Stefan Csomor +// RCS-ID: $Id: graphics.h 60190 2009-04-16 00:57:35Z KO $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,76 +18,18 @@ #include "wx/geometry.h" #include "wx/dynarray.h" -#include "wx/dc.h" -#include "wx/image.h" -#include "wx/vector.h" -enum wxAntialiasMode -{ - wxANTIALIAS_NONE, // should be 0 - wxANTIALIAS_DEFAULT -}; - -enum wxInterpolationQuality -{ - // default interpolation - wxINTERPOLATION_DEFAULT, - // no interpolation - wxINTERPOLATION_NONE, - // fast interpolation, suited for interactivity - wxINTERPOLATION_FAST, - // better quality - wxINTERPOLATION_GOOD, - // best quality, not suited for interactivity - wxINTERPOLATION_BEST -}; - -enum wxCompositionMode -{ - // R = Result, S = Source, D = Destination, premultiplied with alpha - // Ra, Sa, Da their alpha components - - // classic Porter-Duff compositions - // http://keithp.com/~keithp/porterduff/p253-porter.pdf - - wxCOMPOSITION_INVALID = -1, /* indicates invalid/unsupported mode */ - wxCOMPOSITION_CLEAR, /* R = 0 */ - wxCOMPOSITION_SOURCE, /* R = S */ - wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */ - wxCOMPOSITION_IN, /* R = S*Da */ - wxCOMPOSITION_OUT, /* R = S*(1 - Da) */ - wxCOMPOSITION_ATOP, /* R = S*Da + D*(1 - Sa) */ - - wxCOMPOSITION_DEST, /* R = D, essentially a noop */ - wxCOMPOSITION_DEST_OVER, /* R = S*(1 - Da) + D */ - wxCOMPOSITION_DEST_IN, /* R = D*Sa */ - wxCOMPOSITION_DEST_OUT, /* R = D*(1 - Sa) */ - wxCOMPOSITION_DEST_ATOP, /* R = S*(1 - Da) + D*Sa */ - wxCOMPOSITION_XOR, /* R = S*(1 - Da) + D*(1 - Sa) */ - - // mathematical compositions - wxCOMPOSITION_ADD /* R = S + D */ -}; - -class WXDLLIMPEXP_FWD_CORE wxWindowDC; -class WXDLLIMPEXP_FWD_CORE wxMemoryDC; -#if wxUSE_PRINTING_ARCHITECTURE -class WXDLLIMPEXP_FWD_CORE wxPrinterDC; -#endif -#ifdef __WXMSW__ -#if wxUSE_ENH_METAFILE -class WXDLLIMPEXP_FWD_CORE wxEnhMetaFileDC; -#endif -#endif -class WXDLLIMPEXP_FWD_CORE wxGraphicsContext; -class WXDLLIMPEXP_FWD_CORE wxGraphicsPath; -class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix; -class WXDLLIMPEXP_FWD_CORE wxGraphicsFigure; -class WXDLLIMPEXP_FWD_CORE wxGraphicsRenderer; -class WXDLLIMPEXP_FWD_CORE wxGraphicsPen; -class WXDLLIMPEXP_FWD_CORE wxGraphicsBrush; -class WXDLLIMPEXP_FWD_CORE wxGraphicsFont; -class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmap; +class WXDLLIMPEXP_CORE wxWindowDC; +class WXDLLIMPEXP_CORE wxMemoryDC; +class WXDLLIMPEXP_CORE wxGraphicsContext; +class WXDLLIMPEXP_CORE wxGraphicsPath; +class WXDLLIMPEXP_CORE wxGraphicsMatrix; +class WXDLLIMPEXP_CORE wxGraphicsFigure; +class WXDLLIMPEXP_CORE wxGraphicsRenderer; +class WXDLLIMPEXP_CORE wxGraphicsPen; +class WXDLLIMPEXP_CORE wxGraphicsBrush; +class WXDLLIMPEXP_CORE wxGraphicsFont; +class WXDLLIMPEXP_CORE wxGraphicsBitmap; /* * notes about the graphics context apis @@ -105,93 +48,164 @@ class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmap; // instance from the other instances that were shared - using copy on write semantics // -class WXDLLIMPEXP_FWD_CORE wxGraphicsObjectRefData; -class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmapData; -class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrixData; -class WXDLLIMPEXP_FWD_CORE wxGraphicsPathData; +class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData +{ +public : + wxGraphicsObjectRefData( wxGraphicsRenderer* renderer ); + wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data ); + wxGraphicsRenderer* GetRenderer() const ; + virtual wxGraphicsObjectRefData* Clone() const ; + +protected : + wxGraphicsRenderer* m_renderer; +} ; class WXDLLIMPEXP_CORE wxGraphicsObject : public wxObject { -public: - wxGraphicsObject(); - wxGraphicsObject( wxGraphicsRenderer* renderer ); - virtual ~wxGraphicsObject(); +public : + wxGraphicsObject() ; +#if wxABI_VERSION >= 20810 + wxGraphicsObject( const wxGraphicsObject& other) : wxObject( other ) {} + wxGraphicsObject& operator= (const wxGraphicsObject & other) { Ref(other); return *this;} +#endif + wxGraphicsObject( wxGraphicsRenderer* renderer ) ; + virtual ~wxGraphicsObject() ; - bool IsNull() const; + bool IsNull() const ; // returns the renderer that was used to create this instance, or NULL if it has not been initialized yet - wxGraphicsRenderer* GetRenderer() const; - wxGraphicsObjectRefData* GetGraphicsData() const; -protected: + wxGraphicsRenderer* GetRenderer() const ; + wxGraphicsObjectRefData* GetGraphicsData() const ; +protected : virtual wxObjectRefData* CreateRefData() const; virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; DECLARE_DYNAMIC_CLASS(wxGraphicsObject) -}; +} ; class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject { -public: +public : wxGraphicsPen() {} +#if wxABI_VERSION >= 20810 + wxGraphicsPen( const wxGraphicsPen& other) : wxGraphicsObject( other ) {} + wxGraphicsPen& operator= (const wxGraphicsPen & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsPen() {} -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsPen) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPen) wxNullGraphicsPen; +extern WXDLLEXPORT_DATA(wxGraphicsPen) wxNullGraphicsPen; class WXDLLIMPEXP_CORE wxGraphicsBrush : public wxGraphicsObject { -public: +public : wxGraphicsBrush() {} +#if wxABI_VERSION >= 20810 + wxGraphicsBrush( const wxGraphicsBrush& other) : wxGraphicsObject( other ) {} + wxGraphicsBrush& operator= (const wxGraphicsBrush & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsBrush() {} -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsBrush) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush) wxNullGraphicsBrush; +extern WXDLLEXPORT_DATA(wxGraphicsBrush) wxNullGraphicsBrush; class WXDLLIMPEXP_CORE wxGraphicsFont : public wxGraphicsObject { -public: +public : wxGraphicsFont() {} +#if wxABI_VERSION >= 20810 + wxGraphicsFont( const wxGraphicsFont& other) : wxGraphicsObject( other ) {} + wxGraphicsFont& operator= (const wxGraphicsFont & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsFont() {} -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsFont) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsFont) wxNullGraphicsFont; +extern WXDLLEXPORT_DATA(wxGraphicsFont) wxNullGraphicsFont; class WXDLLIMPEXP_CORE wxGraphicsBitmap : public wxGraphicsObject { -public: +public : wxGraphicsBitmap() {} +#if wxABI_VERSION >= 20810 + wxGraphicsBitmap( const wxGraphicsBitmap& other) : wxGraphicsObject( other ) {} + wxGraphicsBitmap& operator= (const wxGraphicsBitmap & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsBitmap() {} - - // Convert bitmap to wxImage: this is more efficient than converting to - // wxBitmap first and then to wxImage and also works without X server - // connection under Unix that wxBitmap requires. -#if wxUSE_IMAGE - wxImage ConvertToImage() const; -#endif // wxUSE_IMAGE - - void* GetNativeBitmap() const; - - const wxGraphicsBitmapData* GetBitmapData() const - { return (const wxGraphicsBitmapData*) GetRefData(); } - wxGraphicsBitmapData* GetBitmapData() - { return (wxGraphicsBitmapData*) GetRefData(); } - -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsBitmap) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap) wxNullGraphicsBitmap; +extern WXDLLEXPORT_DATA(wxGraphicsBitmap) wxNullGraphicsBitmap; + +class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData +{ +public : + wxGraphicsMatrixData( wxGraphicsRenderer* renderer) : + wxGraphicsObjectRefData(renderer) {} + + virtual ~wxGraphicsMatrixData() {} + + // concatenates the matrix + virtual void Concat( const wxGraphicsMatrixData *t ) = 0; + + // sets the matrix to the respective values + virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, + wxDouble tx=0.0, wxDouble ty=0.0) = 0; + + // gets the component valuess of the matrix + virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL, + wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const = 0; + + // makes this the inverse matrix + virtual void Invert() = 0; + + // returns true if the elements of the transformation matrix are equal ? + virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0; + + // return true if this is the identity matrix + virtual bool IsIdentity() const = 0; + + // + // transformation + // + + // add the translation to this matrix + virtual void Translate( wxDouble dx , wxDouble dy ) = 0; + + // add the scale to this matrix + virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0; + + // add the rotation to this matrix (radians) + virtual void Rotate( wxDouble angle ) = 0; + + // + // apply the transforms + // + + // applies that matrix to the point + virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0; + + // applies the matrix except for translations + virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0; + + // returns the native representation + virtual void * GetNativeMatrix() const = 0; +} ; class WXDLLIMPEXP_CORE wxGraphicsMatrix : public wxGraphicsObject { -public: +public : wxGraphicsMatrix() {} +#if wxABI_VERSION >= 20810 + wxGraphicsMatrix( const wxGraphicsMatrix& other) : wxGraphicsObject( other ) {} + wxGraphicsMatrix& operator= (const wxGraphicsMatrix & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsMatrix() {} @@ -248,16 +262,89 @@ public: wxGraphicsMatrixData* GetMatrixData() { return (wxGraphicsMatrixData*) GetRefData(); } -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix) wxNullGraphicsMatrix; +extern WXDLLEXPORT_DATA(wxGraphicsMatrix) wxNullGraphicsMatrix; + +class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData +{ +public : + wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {} + virtual ~wxGraphicsPathData() {} + + // + // These are the path primitives from which everything else can be constructed + // + + // begins a new subpath at (x,y) + virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0; + + // adds a straight line from the current point to (x,y) + virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0; + + // adds a cubic Bezier curve from the current point, using two control points and an end point + virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0; + + // adds another path + virtual void AddPath( const wxGraphicsPathData* path ) =0; + + // closes the current sub-path + virtual void CloseSubpath() = 0; + + // gets the last point of the current path, (0,0) if not yet set + virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0; + + // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle + virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0; + + // + // These are convenience functions which - if not available natively will be assembled + // using the primitives from above + // + + // adds a quadratic Bezier curve from the current point, using a control point and an end point + virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ); + + // appends a rectangle as a new closed subpath + virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + + // appends an ellipsis as a new closed subpath fitting the passed rectangle + virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r ); + + // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1) + virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ; + + // appends an ellipse + virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); + + // appends a rounded rectangle + virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); + + // returns the native path + virtual void * GetNativePath() const = 0; + + // give the native path returned by GetNativePath() back (there might be some deallocations necessary) + virtual void UnGetNativePath(void *p) const= 0; + + // transforms each point of this path by the matrix + virtual void Transform( const wxGraphicsMatrixData* matrix ) =0; + + // gets the bounding box enclosing all points (possibly including control points) + virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0; + + virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const=0; +}; class WXDLLIMPEXP_CORE wxGraphicsPath : public wxGraphicsObject { -public: +public : wxGraphicsPath() {} +#if wxABI_VERSION >= 20810 + wxGraphicsPath( const wxGraphicsPath& other) : wxGraphicsObject( other ) {} + wxGraphicsPath& operator= (const wxGraphicsPath & other) { Ref(other); return *this;} +#endif virtual ~wxGraphicsPath() {} // @@ -273,21 +360,21 @@ public: void AddLineToPoint( const wxPoint2DDouble& p); // adds a cubic Bezier curve from the current point, using two control points and an end point - virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ); + virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) ; void AddCurveToPoint( const wxPoint2DDouble& c1, const wxPoint2DDouble& c2, const wxPoint2DDouble& e); // adds another path virtual void AddPath( const wxGraphicsPath& path ); // closes the current sub-path - virtual void CloseSubpath(); + virtual void CloseSubpath() ; // gets the last point of the current path, (0,0) if not yet set virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const; wxPoint2DDouble GetCurrentPoint() const; // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle - virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ); + virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) ; void AddArc( const wxPoint2DDouble& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise); // @@ -305,7 +392,7 @@ public: virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r ); // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1) - virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ); + virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ; // appends an ellipse virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); @@ -326,97 +413,21 @@ public: virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h)const; wxRect2DDouble GetBox()const; - virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; - bool Contains( const wxPoint2DDouble& c, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; + virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE)const; + bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE)const; const wxGraphicsPathData* GetPathData() const { return (const wxGraphicsPathData*) GetRefData(); } wxGraphicsPathData* GetPathData() { return (wxGraphicsPathData*) GetRefData(); } -private: +private : DECLARE_DYNAMIC_CLASS(wxGraphicsPath) -}; +} ; -extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPath) wxNullGraphicsPath; +extern WXDLLEXPORT_DATA(wxGraphicsPath) wxNullGraphicsPath; -// Describes a single gradient stop. -class wxGraphicsGradientStop -{ -public: - wxGraphicsGradientStop(wxColour col = wxTransparentColour, - float pos = 0.) - : m_col(col), - m_pos(pos) - { - } - - // default copy ctor, assignment operator and dtor are ok - - const wxColour& GetColour() const { return m_col; } - void SetColour(const wxColour& col) { m_col = col; } - - float GetPosition() const { return m_pos; } - void SetPosition(float pos) - { - wxASSERT_MSG( pos >= 0 && pos <= 1, "invalid gradient stop position" ); - - m_pos = pos; - } - -private: - // The colour of this gradient band. - wxColour m_col; - - // Its starting position: 0 is the beginning and 1 is the end. - float m_pos; -}; - -// A collection of gradient stops ordered by their positions (from lowest to -// highest). The first stop (index 0, position 0.0) is always the starting -// colour and the last one (index GetCount() - 1, position 1.0) is the end -// colour. -class WXDLLIMPEXP_CORE wxGraphicsGradientStops -{ -public: - wxGraphicsGradientStops(wxColour startCol = wxTransparentColour, - wxColour endCol = wxTransparentColour) - { - // we can't use Add() here as it relies on having start/end stops as - // first/last array elements so do it manually - m_stops.push_back(wxGraphicsGradientStop(startCol, 0.f)); - m_stops.push_back(wxGraphicsGradientStop(endCol, 1.f)); - } - - // default copy ctor, assignment operator and dtor are ok for this class - - - // Add a stop in correct order. - void Add(const wxGraphicsGradientStop& stop); - void Add(wxColour col, float pos) { Add(wxGraphicsGradientStop(col, pos)); } - - // Get the number of stops. - size_t GetCount() const { return m_stops.size(); } - - // Return the stop at the given index (which must be valid). - wxGraphicsGradientStop Item(unsigned n) const { return m_stops.at(n); } - - // Get/set start and end colours. - void SetStartColour(wxColour col) - { m_stops[0].SetColour(col); } - wxColour GetStartColour() const - { return m_stops[0].GetColour(); } - void SetEndColour(wxColour col) - { m_stops[m_stops.size() - 1].SetColour(col); } - wxColour GetEndColour() const - { return m_stops[m_stops.size() - 1].GetColour(); } - -private: - // All the stops stored in ascending order of positions. - wxVector m_stops; -}; - class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject { public: @@ -424,109 +435,49 @@ public: virtual ~wxGraphicsContext(); - static wxGraphicsContext* Create( const wxWindowDC& dc); - static wxGraphicsContext * Create( const wxMemoryDC& dc); -#if wxUSE_PRINTING_ARCHITECTURE - static wxGraphicsContext * Create( const wxPrinterDC& dc); -#endif + static wxGraphicsContext* Create( const wxWindowDC& dc) ; + #ifdef __WXMSW__ -#if wxUSE_ENH_METAFILE - static wxGraphicsContext * Create( const wxEnhMetaFileDC& dc); -#endif + static wxGraphicsContext * Create( const wxMemoryDC& dc) ; #endif - static wxGraphicsContext* CreateFromNative( void * context ); + static wxGraphicsContext* CreateFromNative( void * context ) ; - static wxGraphicsContext* CreateFromNativeWindow( void * window ); + static wxGraphicsContext* CreateFromNativeWindow( void * window ) ; - static wxGraphicsContext* Create( wxWindow* window ); - -#if wxUSE_IMAGE - // Create a context for drawing onto a wxImage. The image life time must be - // greater than that of the context itself as when the context is destroyed - // it will copy its contents to the specified image. - static wxGraphicsContext* Create(wxImage& image); -#endif // wxUSE_IMAGE + static wxGraphicsContext* Create( wxWindow* window ) ; // create a context that can be used for measuring texts only, no drawing allowed static wxGraphicsContext * Create(); - // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown - virtual bool StartDoc( const wxString& message ); - - // done with that document (relevant only for printing / pdf etc) - virtual void EndDoc(); - - // opens a new page (relevant only for printing / pdf etc) with the given size in points - // (if both are null the default page size will be used) - virtual void StartPage( wxDouble width = 0, wxDouble height = 0 ); - - // ends the current page (relevant only for printing / pdf etc) - virtual void EndPage(); - - // make sure that the current content of this context is immediately visible - virtual void Flush(); - wxGraphicsPath CreatePath() const; virtual wxGraphicsPen CreatePen(const wxPen& pen) const; virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const; - // sets the brush to a linear gradient, starting at (x1,y1) and ending at - // (x2,y2) with the given boundary colours or the specified stops - wxGraphicsBrush - CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxColour& c1, const wxColour& c2) const; - wxGraphicsBrush - CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops) const; + // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 + virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2) const; - // sets the brush to a radial gradient originating at (xo,yc) and ending - // on a circle around (xc,yc) with the given radius; the colours may be - // specified by just the two extremes or the full array of gradient stops - wxGraphicsBrush - CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, wxDouble radius, - const wxColour& oColor, const wxColour& cColor) const; + // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) + // with radius r and color cColor + virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor) const; - wxGraphicsBrush - CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, wxDouble radius, - const wxGraphicsGradientStops& stops) const; - - // creates a font + // sets the font virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) const; - virtual wxGraphicsFont CreateFont(double sizeInPixels, - const wxString& facename, - int flags = wxFONTFLAG_DEFAULT, - const wxColour& col = *wxBLACK) const; + +#if wxABI_VERSION >= 20809 + wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) const; +#endif - // create a native bitmap representation - virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) const; -#if wxUSE_IMAGE - wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) const; -#endif // wxUSE_IMAGE - - // create a native bitmap representation - virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) const; + //virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) const; // create a 'native' matrix corresponding to these values virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, wxDouble tx=0.0, wxDouble ty=0.0) const; - wxGraphicsMatrix CreateMatrix( const wxAffineMatrix2DBase& mat ) const - { - wxMatrix2D mat2D; - wxPoint2DDouble tr; - mat.Get(&mat2D, &tr); - - return CreateMatrix(mat2D.m_11, mat2D.m_12, mat2D.m_21, mat2D.m_22, - tr.m_x, tr.m_y); - } - // push the current state of the context, ie the transformation matrix on a stack virtual void PushState() = 0; @@ -540,55 +491,16 @@ public: virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; // resets the clipping to original extent - virtual void ResetClip() = 0; + virtual void ResetClip() = 0 ; // returns the native context virtual void * GetNativeContext() = 0; - // returns the current shape antialiasing mode - virtual wxAntialiasMode GetAntialiasMode() const { return m_antialias; } + // returns the current logical function + virtual int GetLogicalFunction() const { return m_logicalFunction; } - // sets the antialiasing mode, returns true if it supported - virtual bool SetAntialiasMode(wxAntialiasMode antialias) = 0; - - // returns the current interpolation quality - virtual wxInterpolationQuality GetInterpolationQuality() const { return m_interpolation; } - - // sets the interpolation quality, returns true if it supported - virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) = 0; - - // returns the current compositing operator - virtual wxCompositionMode GetCompositionMode() const { return m_composition; } - - // sets the compositing operator, returns true if it supported - virtual bool SetCompositionMode(wxCompositionMode op) = 0; - - // returns the size of the graphics context in device coordinates - void GetSize(wxDouble* width, wxDouble* height) const - { - if ( width ) - *width = m_width; - if ( height ) - *height = m_height; - } - - // returns the resolution of the graphics context in device points per inch - virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY); - -#if 0 - // sets the current alpha on this context - virtual void SetAlpha( wxDouble alpha ); - - // returns the alpha on this context - virtual wxDouble GetAlpha() const; -#endif - - // all rendering is done into a fully transparent temporary context - virtual void BeginLayer(wxDouble opacity) = 0; - - // composites back the drawings into the context with the opacity given at - // the BeginLayer call - virtual void EndLayer() = 0; + // sets the current logical function, returns true if it supported + virtual bool SetLogicalFunction(int function) ; // // transformation : changes the current transformation matrix CTM of the context @@ -635,41 +547,35 @@ public: virtual void StrokePath( const wxGraphicsPath& path ) = 0; // fills a path with the current brush - virtual void FillPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ) = 0; + virtual void FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ) = 0; // draws a path by first filling and then stroking - virtual void DrawPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); + virtual void DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ); // // text // - void DrawText( const wxString &str, wxDouble x, wxDouble y ) - { DoDrawText(str, x, y); } + virtual void DrawText( const wxString &str, wxDouble x, wxDouble y ) = 0; - void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ) - { DoDrawRotatedText(str, x, y, angle); } + virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ); - void DrawText( const wxString &str, wxDouble x, wxDouble y, - const wxGraphicsBrush& backgroundBrush ) - { DoDrawFilledText(str, x, y, backgroundBrush); } - - void DrawText( const wxString &str, wxDouble x, wxDouble y, - wxDouble angle, const wxGraphicsBrush& backgroundBrush ) - { DoDrawRotatedFilledText(str, x, y, angle, backgroundBrush); } + virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, const wxGraphicsBrush& backgroundBrush ) ; + virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle, const wxGraphicsBrush& backgroundBrush ); virtual void GetTextExtent( const wxString &text, wxDouble *width, wxDouble *height, - wxDouble *descent = NULL, wxDouble *externalLeading = NULL ) const = 0; + wxDouble *descent, wxDouble *externalLeading ) const = 0; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const = 0; // // image support // - - virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; - +#if wxABI_VERSION >= 20809 + void DrawGraphicsBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); +#endif + virtual void DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; @@ -688,9 +594,9 @@ public: virtual void StrokeLines( size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints); // draws a polygon - virtual void DrawLines( size_t n, const wxPoint2DDouble *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); + virtual void DrawLines( size_t n, const wxPoint2DDouble *points, int fillStyle = wxODDEVEN_RULE ); - // draws a rectangle + // draws a polygon virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h); // draws an ellipse @@ -703,42 +609,16 @@ public: // helper to determine if a 0.5 offset should be applied for the drawing operation virtual bool ShouldOffset() const { return false; } - - // indicates whether the context should try to offset for pixel boundaries, this only makes sense on - // bitmap devices like screen, by default this is turned off - virtual void EnableOffset(bool enable = true); - - void DisableOffset() { EnableOffset(false); } - bool OffsetEnabled() { return m_enableOffset; } - -protected: - // These fields must be initialized in the derived class ctors. - wxDouble m_width, - m_height; + +protected : wxGraphicsPen m_pen; wxGraphicsBrush m_brush; wxGraphicsFont m_font; - wxAntialiasMode m_antialias; - wxCompositionMode m_composition; - wxInterpolationQuality m_interpolation; - bool m_enableOffset; + int m_logicalFunction; -protected: - // implementations of overloaded public functions: we use different names - // for them to avoid the virtual function hiding problems in the derived - // classes - virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0; - virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y, - wxDouble angle); - virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y, - const wxGraphicsBrush& backgroundBrush); - virtual void DoDrawRotatedFilledText(const wxString& str, - wxDouble x, wxDouble y, - wxDouble angle, - const wxGraphicsBrush& backgroundBrush); - - wxDECLARE_NO_COPY_CLASS(wxGraphicsContext); +private : + DECLARE_NO_COPY_CLASS(wxGraphicsContext) DECLARE_ABSTRACT_CLASS(wxGraphicsContext) }; @@ -750,10 +630,14 @@ protected: class WXDLLIMPEXP_CORE wxGraphicsFigure : public wxGraphicsObject { -public: - wxGraphicsFigure(wxGraphicsRenderer* renderer); +public : + wxGraphicsFigure(wxGraphicsRenderer* renderer) ; +#if wxABI_VERSION >= 20810 + wxGraphicsFigure( const wxGraphicsFigure& other) : wxGraphicsObject( other ) {} + wxGraphicsFigure& operator= (const wxGraphicsFigure & other) { Ref(other); return *this;} +#endif - virtual ~wxGraphicsFigure(); + virtual ~wxGraphicsFigure() ; void SetPath( wxGraphicsMatrix* matrix ); @@ -768,12 +652,12 @@ public: // returns the transformation matrix of this object, may be null if there is no transformation necessary wxGraphicsMatrix* GetMatrix() { return m_matrix; } -private: +private : wxGraphicsMatrix* m_matrix; wxGraphicsPath* m_path; DECLARE_DYNAMIC_CLASS(wxGraphicsFigure) -}; +} ; #endif @@ -785,37 +669,28 @@ private: class WXDLLIMPEXP_CORE wxGraphicsRenderer : public wxObject { -public: +public : wxGraphicsRenderer() {} virtual ~wxGraphicsRenderer() {} static wxGraphicsRenderer* GetDefaultRenderer(); +#if wxABI_VERSION >= 20811 static wxGraphicsRenderer* GetCairoRenderer(); +#endif // Context - virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0; - virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0; -#if wxUSE_PRINTING_ARCHITECTURE - virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0; -#endif + virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ; #ifdef __WXMSW__ -#if wxUSE_ENH_METAFILE - virtual wxGraphicsContext * CreateContext( const wxEnhMetaFileDC& dc) = 0; + virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ; #endif -#endif - virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0; virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0; virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0; -#if wxUSE_IMAGE - virtual wxGraphicsContext * CreateContextFromImage(wxImage& image) = 0; -#endif // wxUSE_IMAGE - // create a context that can be used for measuring texts only, no drawing allowed virtual wxGraphicsContext * CreateMeasuringContext() = 0; @@ -830,59 +705,31 @@ public: // Paints - virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0; + virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0 ; - virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0; + virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0 ; - // Gradient brush creation functions may not honour all the stops specified - // stops and use just its boundary colours (this is currently the case - // under OS X) - virtual wxGraphicsBrush - CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops) = 0; + // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 + virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2) = 0; - virtual wxGraphicsBrush - CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, - wxDouble radius, - const wxGraphicsGradientStops& stops) = 0; + // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) + // with radius r and color cColor + virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor) = 0; - // sets the font + // sets the font virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0; - virtual wxGraphicsFont CreateFont(double sizeInPixels, - const wxString& facename, - int flags = wxFONTFLAG_DEFAULT, - const wxColour& col = *wxBLACK) = 0; - // create a native bitmap representation - virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0; -#if wxUSE_IMAGE - virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) = 0; - virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp) = 0; -#endif // wxUSE_IMAGE +#if wxABI_VERSION >= 20809 + wxGraphicsBitmap CreateBitmap( const wxBitmap &bmp ); +#endif - // create a graphics bitmap from a native bitmap - virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap ) = 0; - - // create a subimage from a native image representation - virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; - -private: - wxDECLARE_NO_COPY_CLASS(wxGraphicsRenderer); +private : + DECLARE_NO_COPY_CLASS(wxGraphicsRenderer) DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer) -}; +} ; - -#if wxUSE_IMAGE -inline -wxImage wxGraphicsBitmap::ConvertToImage() const -{ - wxGraphicsRenderer* renderer = GetRenderer(); - return renderer ? renderer->CreateImageFromBitmap(*this) : wxNullImage; -} -#endif // wxUSE_IMAGE - -#endif // wxUSE_GRAPHICS_CONTEXT +#endif #endif // _WX_GRAPHICS_H_ diff --git a/Source/3rd Party/wx/include/wx/grid.h b/Source/3rd Party/wx/include/wx/grid.h deleted file mode 100644 index 02055658e..000000000 --- a/Source/3rd Party/wx/include/wx/grid.h +++ /dev/null @@ -1,21 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/grid.h -// Purpose: wxGrid base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GRID_H_BASE_ -#define _WX_GRID_H_BASE_ - -#include "wx/generic/grid.h" - -// these headers used to be included from the above header but isn't any more, -// still do it from here for compatibility -#include "wx/generic/grideditors.h" -#include "wx/generic/gridctrl.h" - -#endif // _WX_GRID_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/gsocket.h b/Source/3rd Party/wx/include/wx/gsocket.h new file mode 100644 index 000000000..83d8ee49b --- /dev/null +++ b/Source/3rd Party/wx/include/wx/gsocket.h @@ -0,0 +1,184 @@ +/* ------------------------------------------------------------------------- + * Project: GSocket (Generic Socket) + * Name: gsocket.h + * Author: Guilhem Lavaux + * Guillermo Rodriguez Garcia (maintainer) + * Copyright: (c) Guilhem Lavaux + * Licence: wxWindows Licence + * Purpose: GSocket include file (system independent) + * CVSID: $Id: gsocket.h 33948 2005-05-04 18:57:50Z JS $ + * ------------------------------------------------------------------------- + */ + +#ifndef __GSOCKET_H +#define __GSOCKET_H + +#ifndef __GSOCKET_STANDALONE__ +#include "wx/defs.h" + +#include "wx/dlimpexp.h" /* for WXDLLIMPEXP_NET */ + +#endif + +#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) + +#include + +/* + Including sys/types.h under cygwin results in the warnings about "fd_set + having been defined in sys/types.h" when winsock.h is included later and + doesn't seem to be necessary anyhow. It's not needed under Mac neither. + */ +#if !defined(__WXMAC__) && !defined(__CYGWIN__) && !defined(__WXWINCE__) +#include +#endif + +#ifdef __WXWINCE__ +#include +#endif + +class GSocket; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _GAddress GAddress; + +typedef enum { + GSOCK_NOFAMILY = 0, + GSOCK_INET, + GSOCK_INET6, + GSOCK_UNIX +} GAddressType; + +typedef enum { + GSOCK_STREAMED, + GSOCK_UNSTREAMED +} GSocketStream; + +typedef enum { + GSOCK_NOERROR = 0, + GSOCK_INVOP, + GSOCK_IOERR, + GSOCK_INVADDR, + GSOCK_INVSOCK, + GSOCK_NOHOST, + GSOCK_INVPORT, + GSOCK_WOULDBLOCK, + GSOCK_TIMEDOUT, + GSOCK_MEMERR, + GSOCK_OPTERR +} GSocketError; + +/* See below for an explanation on how events work. + */ +typedef enum { + GSOCK_INPUT = 0, + GSOCK_OUTPUT = 1, + GSOCK_CONNECTION = 2, + GSOCK_LOST = 3, + GSOCK_MAX_EVENT = 4 +} GSocketEvent; + +enum { + GSOCK_INPUT_FLAG = 1 << GSOCK_INPUT, + GSOCK_OUTPUT_FLAG = 1 << GSOCK_OUTPUT, + GSOCK_CONNECTION_FLAG = 1 << GSOCK_CONNECTION, + GSOCK_LOST_FLAG = 1 << GSOCK_LOST +}; + +typedef int GSocketEventFlags; + +typedef void (*GSocketCallback)(GSocket *socket, GSocketEvent event, + char *cdata); + + +/* Functions tables for internal use by GSocket code: */ + +/* Actually this is a misnomer now, but reusing this name means I don't + have to ifdef app traits or common socket code */ +class GSocketGUIFunctionsTable +{ +public: + // needed since this class declares virtual members + virtual ~GSocketGUIFunctionsTable() { } + virtual bool OnInit() = 0; + virtual void OnExit() = 0; + virtual bool CanUseEventLoop() = 0; + virtual bool Init_Socket(GSocket *socket) = 0; + virtual void Destroy_Socket(GSocket *socket) = 0; +#ifndef __WINDOWS__ + virtual void Install_Callback(GSocket *socket, GSocketEvent event) = 0; + virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event) = 0; +#endif + virtual void Enable_Events(GSocket *socket) = 0; + virtual void Disable_Events(GSocket *socket) = 0; +}; + + +/* Global initializers */ + +/* Sets GUI functions callbacks. Must be called *before* GSocket_Init + if the app uses async sockets. */ +void GSocket_SetGUIFunctions(GSocketGUIFunctionsTable *guifunc); + +/* GSocket_Init() must be called at the beginning */ +int GSocket_Init(void); + +/* GSocket_Cleanup() must be called at the end */ +void GSocket_Cleanup(void); + + +/* Constructors / Destructors */ + +GSocket *GSocket_new(void); + + +/* GAddress */ + +GAddress *GAddress_new(void); +GAddress *GAddress_copy(GAddress *address); +void GAddress_destroy(GAddress *address); + +void GAddress_SetFamily(GAddress *address, GAddressType type); +GAddressType GAddress_GetFamily(GAddress *address); + +/* The use of any of the next functions will set the address family to + * the specific one. For example if you use GAddress_INET_SetHostName, + * address family will be implicitly set to AF_INET. + */ + +GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname); +GSocketError GAddress_INET_SetAnyAddress(GAddress *address); +GSocketError GAddress_INET_SetHostAddress(GAddress *address, + unsigned long hostaddr); +GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port, + const char *protocol); +GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port); + +GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, + size_t sbuf); +unsigned long GAddress_INET_GetHostAddress(GAddress *address); +unsigned short GAddress_INET_GetPort(GAddress *address); + +/* TODO: Define specific parts (INET6, UNIX) */ + +GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path); +GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +# if defined(__WINDOWS__) +# include "wx/msw/gsockmsw.h" +# elif defined(__WXMAC__) && !defined(__DARWIN__) +# include "wx/mac/gsockmac.h" +# else +# include "wx/unix/gsockunx.h" +# endif + +#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */ + +#endif /* __GSOCKET_H */ diff --git a/Source/3rd Party/wx/include/wx/hash.h b/Source/3rd Party/wx/include/wx/hash.h index b992658a2..9937bbe4e 100644 --- a/Source/3rd Party/wx/include/wx/hash.h +++ b/Source/3rd Party/wx/include/wx/hash.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: VZ at 25.02.00: type safe hashes with WX_DECLARE_HASH() // Created: 01/02/97 +// RCS-ID: $Id: hash.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,12 +13,23 @@ #define _WX_HASH_H__ #include "wx/defs.h" -#include "wx/string.h" -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL && WXWIN_COMPATIBILITY_2_4 + #define wxUSE_OLD_HASH_TABLE 1 +#else + #define wxUSE_OLD_HASH_TABLE 0 +#endif + +#if !wxUSE_STL #include "wx/object.h" #else - class WXDLLIMPEXP_FWD_BASE wxObject; + class WXDLLIMPEXP_BASE wxObject; +#endif +#if wxUSE_OLD_HASH_TABLE + #include "wx/list.h" +#endif +#if WXWIN_COMPATIBILITY_2_4 + #include "wx/dynarray.h" #endif // the default size of the hash @@ -30,10 +42,69 @@ * the list to find the desired item. */ +// ---------------------------------------------------------------------------- +// this is the base class for object hashes: hash tables which contain +// pointers to objects +// ---------------------------------------------------------------------------- + +#if wxUSE_OLD_HASH_TABLE + +class WXDLLIMPEXP_BASE wxHashTableBase : public wxObject +{ +public: + wxHashTableBase(); + + void Create(wxKeyType keyType = wxKEY_INTEGER, + size_t size = wxHASH_SIZE_DEFAULT); + void Destroy(); + + size_t GetSize() const { return m_hashSize; } + size_t GetCount() const { return m_count; } + + void DeleteContents(bool flag); + +protected: + // find the node for (key, value) + wxNodeBase *GetNode(long key, long value) const; + + // the array of lists in which we store the values for given key hash + wxListBase **m_hashTable; + + // the size of m_lists array + size_t m_hashSize; + + // the type of indexing we use + wxKeyType m_keyType; + + // the total number of elements in the hash + size_t m_count; + + // should we delete our data? + bool m_deleteContents; + +private: + // no copy ctor/assignment operator (yet) + DECLARE_NO_COPY_CLASS(wxHashTableBase) +}; + +#else // if !wxUSE_OLD_HASH_TABLE + +#if !defined(wxENUM_KEY_TYPE_DEFINED) +#define wxENUM_KEY_TYPE_DEFINED + +enum wxKeyType +{ + wxKEY_NONE, + wxKEY_INTEGER, + wxKEY_STRING +}; + +#endif + union wxHashKeyValue { long integer; - wxString *string; + wxChar *string; }; // for some compilers (AIX xlC), defining it as friend inside the class is not @@ -47,12 +118,12 @@ class WXDLLIMPEXP_BASE wxHashTableBase_Node public: wxHashTableBase_Node( long key, void* value, wxHashTableBase* table ); - wxHashTableBase_Node( const wxString& key, void* value, + wxHashTableBase_Node( const wxChar* key, void* value, wxHashTableBase* table ); ~wxHashTableBase_Node(); long GetKeyInteger() const { return m_key.integer; } - const wxString& GetKeyString() const { return *m_key.string; } + const wxChar* GetKeyString() const { return m_key.string; } void* GetData() const { return m_value; } void SetData( void* data ) { m_value = data; } @@ -79,7 +150,7 @@ protected: }; class WXDLLIMPEXP_BASE wxHashTableBase -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL : public wxObject #endif { @@ -100,15 +171,15 @@ public: void DeleteContents( bool flag ) { m_deleteContents = flag; } - static long MakeKey(const wxString& string); + static long MakeKey(const wxChar *string); protected: void DoPut( long key, long hash, void* data ); - void DoPut( const wxString& key, long hash, void* data ); + void DoPut( const wxChar* key, long hash, void* data ); void* DoGet( long key, long hash ) const; - void* DoGet( const wxString& key, long hash ) const; + void* DoGet( const wxChar* key, long hash ) const; void* DoDelete( long key, long hash ); - void* DoDelete( const wxString& key, long hash ); + void* DoDelete( const wxChar* key, long hash ); private: // Remove the node from the hash, *only called from @@ -149,13 +220,96 @@ protected: bool m_deleteContents; private: - wxDECLARE_NO_COPY_CLASS(wxHashTableBase); + DECLARE_NO_COPY_CLASS(wxHashTableBase) }; +#endif // wxUSE_OLD_HASH_TABLE + +#if !wxUSE_STL + +#if WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// a hash table which stores longs +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxHashTableLong : public wxObject +{ +public: + wxHashTableLong(size_t size = wxHASH_SIZE_DEFAULT) + { Init(size); } + virtual ~wxHashTableLong(); + + void Create(size_t size = wxHASH_SIZE_DEFAULT); + void Destroy(); + + size_t GetSize() const { return m_hashSize; } + size_t GetCount() const { return m_count; } + + void Put(long key, long value); + long Get(long key) const; + long Delete(long key); + +protected: + void Init(size_t size); + +private: + wxArrayLong **m_values, + **m_keys; + + // the size of array above + size_t m_hashSize; + + // the total number of elements in the hash + size_t m_count; + + // not implemented yet + DECLARE_NO_COPY_CLASS(wxHashTableLong) +}; + +// ---------------------------------------------------------------------------- +// wxStringHashTable: a hash table which indexes strings with longs +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxStringHashTable : public wxObject +{ +public: + wxStringHashTable(size_t sizeTable = wxHASH_SIZE_DEFAULT); + virtual ~wxStringHashTable(); + + // add a string associated with this key to the table + void Put(long key, const wxString& value); + + // get the string from the key: if not found, an empty string is returned + // and the wasFound is set to false if not NULL + wxString Get(long key, bool *wasFound = NULL) const; + + // remove the item, returning true if the item was found and deleted + bool Delete(long key) const; + + // clean up + void Destroy(); + +private: + wxArrayLong **m_keys; + wxArrayString **m_values; + + // the size of array above + size_t m_hashSize; + + DECLARE_NO_COPY_CLASS(wxStringHashTable) +}; + +#endif // WXWIN_COMPATIBILITY_2_4 + +#endif // !wxUSE_STL + // ---------------------------------------------------------------------------- // for compatibility only // ---------------------------------------------------------------------------- +#if !wxUSE_OLD_HASH_TABLE + class WXDLLIMPEXP_BASE wxHashTable_Node : public wxHashTableBase_Node { friend class WXDLLIMPEXP_FWD_BASE wxHashTable; @@ -163,7 +317,7 @@ public: wxHashTable_Node( long key, void* value, wxHashTableBase* table ) : wxHashTableBase_Node( key, value, table ) { } - wxHashTable_Node( const wxString& key, void* value, + wxHashTable_Node( const wxChar* key, void* value, wxHashTableBase* table ) : wxHashTableBase_Node( key, value, table ) { } @@ -199,9 +353,9 @@ public: { DoPut( value, value, object ); } void Put(long lhash, long value, wxObject *object) { DoPut( value, lhash, object ); } - void Put(const wxString& value, wxObject *object) + void Put(const wxChar *value, wxObject *object) { DoPut( value, MakeKey( value ), object ); } - void Put(long lhash, const wxString& value, wxObject *object) + void Put(long lhash, const wxChar *value, wxObject *object) { DoPut( value, lhash, object ); } // key and value are the same @@ -209,9 +363,9 @@ public: { return (wxObject*)DoGet( value, value ); } wxObject *Get(long lhash, long value) const { return (wxObject*)DoGet( value, lhash ); } - wxObject *Get(const wxString& value) const + wxObject *Get(const wxChar *value) const { return (wxObject*)DoGet( value, MakeKey( value ) ); } - wxObject *Get(long lhash, const wxString& value) const + wxObject *Get(long lhash, const wxChar *value) const { return (wxObject*)DoGet( value, lhash ); } // Deletes entry and returns data if found @@ -219,11 +373,16 @@ public: { return (wxObject*)DoDelete( key, key ); } wxObject *Delete(long lhash, long key) { return (wxObject*)DoDelete( key, lhash ); } - wxObject *Delete(const wxString& key) + wxObject *Delete(const wxChar *key) { return (wxObject*)DoDelete( key, MakeKey( key ) ); } - wxObject *Delete(long lhash, const wxString& key) + wxObject *Delete(long lhash, const wxChar *key) { return (wxObject*)DoDelete( key, lhash ); } + // Construct your own integer key from a string, e.g. in case + // you need to combine it with something + long MakeKey(const wxChar *string) const + { return wxHashTableBase::MakeKey(string); } + // Way of iterating through whole hash table (e.g. to delete everything) // Not necessary, of course, if you're only storing pointers to // objects maintained separately @@ -250,6 +409,101 @@ private: size_t m_currBucket; }; +#else // if wxUSE_OLD_HASH_TABLE + +class WXDLLIMPEXP_BASE wxHashTable : public wxObject +{ +public: + typedef wxNode Node; + typedef wxNode* compatibility_iterator; + + int n; + int current_position; + wxNode *current_node; + + unsigned int key_type; + wxList **hash_table; + + wxHashTable(int the_key_type = wxKEY_INTEGER, + int size = wxHASH_SIZE_DEFAULT); + virtual ~wxHashTable(); + + // copy ctor and assignment operator + wxHashTable(const wxHashTable& table) : wxObject() + { DoCopy(table); } + wxHashTable& operator=(const wxHashTable& table) + { Clear(); DoCopy(table); return *this; } + + void DoCopy(const wxHashTable& table); + + void Destroy(); + + bool Create(int the_key_type = wxKEY_INTEGER, + int size = wxHASH_SIZE_DEFAULT); + + // Note that there are 2 forms of Put, Get. + // With a key and a value, the *value* will be checked + // when a collision is detected. Otherwise, if there are + // 2 items with a different value but the same key, + // we'll retrieve the WRONG ONE. So where possible, + // supply the required value along with the key. + // In fact, the value-only versions make a key, and still store + // the value. The use of an explicit key might be required + // e.g. when combining several values into one key. + // When doing that, it's highly likely we'll get a collision, + // e.g. 1 + 2 = 3, 2 + 1 = 3. + + // key and value are NOT necessarily the same + void Put(long key, long value, wxObject *object); + void Put(long key, const wxChar *value, wxObject *object); + + // key and value are the same + void Put(long value, wxObject *object); + void Put(const wxChar *value, wxObject *object); + + // key and value not the same + wxObject *Get(long key, long value) const; + wxObject *Get(long key, const wxChar *value) const; + + // key and value are the same + wxObject *Get(long value) const; + wxObject *Get(const wxChar *value) const; + + // Deletes entry and returns data if found + wxObject *Delete(long key); + wxObject *Delete(const wxChar *key); + + wxObject *Delete(long key, int value); + wxObject *Delete(long key, const wxChar *value); + + // Construct your own integer key from a string, e.g. in case + // you need to combine it with something + long MakeKey(const wxChar *string) const; + + // Way of iterating through whole hash table (e.g. to delete everything) + // Not necessary, of course, if you're only storing pointers to + // objects maintained separately + + void BeginFind(); + Node* Next(); + + void DeleteContents(bool flag); + void Clear(); + + // Returns number of nodes + size_t GetCount() const { return m_count; } + +private: + size_t m_count; // number of elements in the hashtable + bool m_deleteContents; + + DECLARE_DYNAMIC_CLASS(wxHashTable) +}; + +#endif // wxUSE_OLD_HASH_TABLE + +#if !wxUSE_OLD_HASH_TABLE + // defines a new type safe hash table which stores the elements of type eltype // in lists of class listclass #define _WX_DECLARE_HASH(eltype, dummy, hashclass, classexp) \ @@ -278,6 +532,69 @@ private: DECLARE_NO_COPY_CLASS(hashclass) \ } +#else // if wxUSE_OLD_HASH_TABLE + +#define _WX_DECLARE_HASH(eltype, listclass, hashclass, classexp) \ + classexp hashclass : public wxHashTableBase \ + { \ + public: \ + hashclass(wxKeyType keyType = wxKEY_INTEGER, \ + size_t size = wxHASH_SIZE_DEFAULT) \ + { Create(keyType, size); } \ + \ + virtual ~hashclass() { Destroy(); } \ + \ + void Put(long key, long val, eltype *data) { DoPut(key, val, data); } \ + void Put(long key, eltype *data) { DoPut(key, key, data); } \ + \ + eltype *Get(long key, long value) const \ + { \ + wxNodeBase *node = GetNode(key, value); \ + return node ? ((listclass::Node *)node)->GetData() : (eltype *)0; \ + } \ + eltype *Get(long key) const { return Get(key, key); } \ + \ + eltype *Delete(long key, long value) \ + { \ + eltype *data; \ + \ + wxNodeBase *node = GetNode(key, value); \ + if ( node ) \ + { \ + data = ((listclass::Node *)node)->GetData(); \ + \ + delete node; \ + m_count--; \ + } \ + else \ + { \ + data = (eltype *)0; \ + } \ + \ + return data; \ + } \ + eltype *Delete(long key) { return Delete(key, key); } \ + \ + protected: \ + void DoPut(long key, long value, eltype *data) \ + { \ + size_t slot = (size_t)abs((int)(key % (long)m_hashSize)); \ + \ + if ( !m_hashTable[slot] ) \ + { \ + m_hashTable[slot] = new listclass(m_keyType); \ + if ( m_deleteContents ) \ + m_hashTable[slot]->DeleteContents(true); \ + } \ + \ + ((listclass *)m_hashTable[slot])->Append(value, data); \ + m_count++; \ + } \ + \ + DECLARE_NO_COPY_CLASS(hashclass) \ + } + +#endif // wxUSE_OLD_HASH_TABLE // this macro is to be used in the user code #define WX_DECLARE_HASH(el, list, hash) \ @@ -286,7 +603,7 @@ private: // and this one does exactly the same thing but should be used inside the // library #define WX_DECLARE_EXPORTED_HASH(el, list, hash) \ - _WX_DECLARE_HASH(el, list, hash, class WXDLLIMPEXP_CORE) + _WX_DECLARE_HASH(el, list, hash, class WXDLLEXPORT) #define WX_DECLARE_USER_EXPORTED_HASH(el, list, hash, usergoo) \ _WX_DECLARE_HASH(el, list, hash, class usergoo) @@ -309,4 +626,5 @@ private: (hash).Clear(); \ } -#endif // _WX_HASH_H__ +#endif + // _WX_HASH_H__ diff --git a/Source/3rd Party/wx/include/wx/hashmap.h b/Source/3rd Party/wx/include/wx/hashmap.h index 40e049c19..44b081fb3 100644 --- a/Source/3rd Party/wx/include/wx/hashmap.h +++ b/Source/3rd Party/wx/include/wx/hashmap.h @@ -4,6 +4,7 @@ // Author: Mattia Barbon // Modified by: // Created: 29/01/2002 +// RCS-ID: $Id: hashmap.h 57388 2008-12-17 09:34:48Z VZ $ // Copyright: (c) Mattia Barbon // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,11 +13,10 @@ #define _WX_HASHMAP_H_ #include "wx/string.h" -#include "wx/wxcrt.h" -// In wxUSE_STD_CONTAINERS build we prefer to use the standard hash map class -// but it can be either in non-standard hash_map header (old g++ and some other -// STL implementations) or in C++0x standard unordered_map which can in turn be +// In wxUSE_STL build we prefer to use the standard hash map class but it can +// be either in non-standard hash_map header (old g++ and some other STL +// implementations) or in C++0x standard unordered_map which can in turn be // available either in std::tr1 or std namespace itself // // To summarize: if std::unordered_map is available use it, otherwise use tr1 @@ -27,7 +27,7 @@ #define HAVE_STL_HASH_MAP #endif -#if wxUSE_STD_CONTAINERS && \ +#if wxUSE_STL && \ (defined(HAVE_STD_UNORDERED_MAP) || defined(HAVE_TR1_UNORDERED_MAP)) #if defined(HAVE_STD_UNORDERED_MAP) @@ -41,7 +41,7 @@ #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ typedef WX_HASH_MAP_NAMESPACE::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME -#elif wxUSE_STD_CONTAINERS && defined(HAVE_STL_HASH_MAP) +#elif wxUSE_STL && defined(HAVE_STL_HASH_MAP) #if defined(HAVE_EXT_HASH_MAP) #include @@ -58,7 +58,7 @@ #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME -#else // !wxUSE_STD_CONTAINERS || no std::{hash,unordered}_map class available +#else // !wxUSE_STL || no std::{hash,unordered}_map class available #define wxNEEDS_WX_HASH_MAP @@ -71,12 +71,12 @@ typedef int ptrdiff_t; // private struct WXDLLIMPEXP_BASE _wxHashTable_NodeBase { - _wxHashTable_NodeBase() : m_next(NULL) {} + _wxHashTable_NodeBase() : m_nxt(0) {} - _wxHashTable_NodeBase* m_next; + _wxHashTable_NodeBase* m_nxt; // Cannot do this: -// wxDECLARE_NO_COPY_CLASS(_wxHashTable_NodeBase); +// DECLARE_NO_COPY_CLASS(_wxHashTable_NodeBase) // without rewriting the macros, which require a public copy constructor. }; @@ -97,7 +97,7 @@ protected: for( size_t i = 0; i < buckets; ++i ) if( table[i] ) return table[i]; - return NULL; + return 0; } // as static const unsigned prime_count = 31 but works with all compilers @@ -126,9 +126,7 @@ protected: } }; -#define _WX_DECLARE_HASHTABLE( VALUE_T, KEY_T, HASH_T, KEY_EX_T, KEY_EQ_T,\ - PTROPERATOR, CLASSNAME, CLASSEXP, \ - SHOULD_GROW, SHOULD_SHRINK ) \ +#define _WX_DECLARE_HASHTABLE( VALUE_T, KEY_T, HASH_T, KEY_EX_T, KEY_EQ_T, CLASSNAME, CLASSEXP, SHOULD_GROW, SHOULD_SHRINK ) \ CLASSEXP CLASSNAME : protected _wxHashTableBase2 \ { \ public: \ @@ -147,10 +145,11 @@ public: \ typedef const KEY_T const_key_type; \ typedef const VALUE_T const_mapped_type; \ public: \ + struct Node; \ typedef KEY_EX_T key_extractor; \ typedef CLASSNAME Self; \ protected: \ - _wxHashTable_NodeBase** m_table; \ + Node** m_table; \ size_t m_tableBuckets; \ size_t m_items; \ hasher m_hasher; \ @@ -162,15 +161,17 @@ public: \ public: \ Node( const value_type& value ) \ : m_value( value ) {} \ - Node* next() { return static_cast(m_next); } \ + Node* m_next() { return (Node*)this->m_nxt; } \ \ value_type m_value; \ }; \ \ + CLASSEXP Iterator; \ + friend CLASSEXP Iterator; \ protected: \ static void DeleteNode( _wxHashTable_NodeBase* node ) \ { \ - delete static_cast(node); \ + delete (Node*)node; \ } \ public: \ /* */ \ @@ -182,9 +183,9 @@ public: \ Node* m_node; \ Self* m_ht; \ \ - Iterator() : m_node(NULL), m_ht(NULL) {} \ + Iterator() : m_node(0), m_ht(0) {} \ Iterator( Node* node, const Self* ht ) \ - : m_node(node), m_ht(const_cast(ht)) {} \ + : m_node(node), m_ht((Self*)ht) {} \ bool operator ==( const Iterator& it ) const \ { return m_node == it.m_node; } \ bool operator !=( const Iterator& it ) const \ @@ -196,18 +197,17 @@ public: \ for( size_type i = bucket + 1; i < m_ht->m_tableBuckets; ++i ) \ { \ if( m_ht->m_table[i] ) \ - return static_cast(m_ht->m_table[i]); \ + return m_ht->m_table[i]; \ } \ - return NULL; \ + return 0; \ } \ \ void PlusPlus() \ { \ - Node* next = m_node->next(); \ + Node* next = m_node->m_next(); \ m_node = next ? next : GetNextNode(); \ } \ }; \ - friend class Iterator; \ \ public: \ CLASSEXP iterator : public Iterator \ @@ -218,7 +218,7 @@ public: \ iterator& operator++() { PlusPlus(); return *this; } \ iterator operator++(int) { iterator it=*this;PlusPlus();return it; } \ reference operator *() const { return m_node->m_value; } \ - PTROPERATOR(pointer) \ + pointer operator ->() const { return &(m_node->m_value); } \ }; \ \ CLASSEXP const_iterator : public Iterator \ @@ -227,11 +227,11 @@ public: \ const_iterator() : Iterator() {} \ const_iterator(iterator i) : Iterator(i) {} \ const_iterator( Node* node, const Self* ht ) \ - : Iterator(node, const_cast(ht)) {} \ + : Iterator( node, (Self*)ht ) {} \ const_iterator& operator++() { PlusPlus();return *this; } \ const_iterator operator++(int) { const_iterator it=*this;PlusPlus();return it; } \ const_reference operator *() const { return m_node->m_value; } \ - PTROPERATOR(const_pointer) \ + const_pointer operator ->() const { return &(m_node->m_value); } \ }; \ \ CLASSNAME( size_type sz = 10, const hasher& hfun = hasher(), \ @@ -243,11 +243,11 @@ public: \ m_equals( k_eq ), \ m_getKey( k_ex ) \ { \ - m_table = (_wxHashTable_NodeBase**)AllocTable(m_tableBuckets); \ + m_table = (Node**)AllocTable( m_tableBuckets ); \ } \ \ CLASSNAME( const Self& ht ) \ - : m_table(NULL), \ + : m_table( 0 ), \ m_tableBuckets( 0 ), \ m_items( ht.m_items ), \ m_hasher( ht.m_hasher ), \ @@ -259,15 +259,12 @@ public: \ \ const Self& operator=( const Self& ht ) \ { \ - if (&ht != this) \ - { \ - clear(); \ - m_hasher = ht.m_hasher; \ - m_equals = ht.m_equals; \ - m_getKey = ht.m_getKey; \ - m_items = ht.m_items; \ - HashCopy( ht ); \ - } \ + clear(); \ + m_hasher = ht.m_hasher; \ + m_equals = ht.m_equals; \ + m_getKey = ht.m_getKey; \ + m_items = ht.m_items; \ + HashCopy( ht ); \ return *this; \ } \ \ @@ -285,7 +282,8 @@ public: \ /* shrink it ( perhaps it should ) */ \ void clear() \ { \ - DeleteNodes(m_tableBuckets, m_table, DeleteNode); \ + DeleteNodes( m_tableBuckets, (_wxHashTable_NodeBase**)m_table, \ + DeleteNode ); \ m_items = 0; \ } \ \ @@ -293,23 +291,23 @@ public: \ size_type max_size() const { return size_type(-1); } \ bool empty() const { return size() == 0; } \ \ - const_iterator end() const { return const_iterator(NULL, this); } \ - iterator end() { return iterator(NULL, this); } \ + const_iterator end() const { return const_iterator( 0, this ); } \ + iterator end() { return iterator( 0, this ); } \ const_iterator begin() const \ - { return const_iterator(static_cast(GetFirstNode(m_tableBuckets, m_table)), this); } \ + { return const_iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); } \ iterator begin() \ - { return iterator(static_cast(GetFirstNode(m_tableBuckets, m_table)), this); } \ + { return iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); } \ \ size_type erase( const const_key_type& key ) \ { \ - _wxHashTable_NodeBase** node = GetNodePtr(key); \ + Node** node = GetNodePtr( key ); \ \ if( !node ) \ return 0; \ \ --m_items; \ - _wxHashTable_NodeBase* temp = (*node)->m_next; \ - delete static_cast(*node); \ + Node* temp = (*node)->m_next(); \ + delete *node; \ (*node) = temp; \ if( SHOULD_SHRINK( m_tableBuckets, m_items ) ) \ ResizeTable( GetPreviousPrime( (unsigned long) m_tableBuckets ) - 1 ); \ @@ -328,7 +326,7 @@ protected: \ { \ const const_key_type& key = m_getKey( value ); \ size_t bucket = m_hasher( key ) % m_tableBuckets; \ - Node* node = static_cast(m_table[bucket]); \ + Node* node = m_table[bucket]; \ \ while( node ) \ { \ @@ -337,7 +335,7 @@ protected: \ created = false; \ return node; \ } \ - node = node->next(); \ + node = node->m_next(); \ } \ created = true; \ return CreateNode( value, bucket); \ @@ -345,7 +343,7 @@ protected: \ Node * CreateNode( const value_type& value, size_t bucket ) \ {\ Node* node = new Node( value ); \ - node->m_next = m_table[bucket]; \ + node->m_nxt = m_table[bucket]; \ m_table[bucket] = node; \ \ /* must be after the node is inserted */ \ @@ -361,16 +359,17 @@ protected: \ }\ \ /* returns NULL if not found */ \ - _wxHashTable_NodeBase** GetNodePtr(const const_key_type& key) const \ + Node** GetNodePtr( const const_key_type& key ) const \ { \ size_t bucket = m_hasher( key ) % m_tableBuckets; \ - _wxHashTable_NodeBase** node = &m_table[bucket]; \ + Node** node = &m_table[bucket]; \ \ while( *node ) \ { \ - if (m_equals(m_getKey(static_cast(*node)->m_value), key)) \ + if( m_equals( m_getKey( (*node)->m_value ), key ) ) \ return node; \ - node = &(*node)->m_next; \ + /* Tell the compiler to not do any strict-aliasing assumptions with a void cast? Can we make such a runtime guarantee? */ \ + node = (Node**)&(*node)->m_nxt; \ } \ \ return NULL; \ @@ -381,28 +380,28 @@ protected: \ Node* GetNode( const const_key_type& key ) const \ { \ size_t bucket = m_hasher( key ) % m_tableBuckets; \ - Node* node = static_cast(m_table[bucket]); \ + Node* node = m_table[bucket]; \ \ while( node ) \ { \ if( m_equals( m_getKey( node->m_value ), key ) ) \ return node; \ - node = node->next(); \ + node = node->m_next(); \ } \ \ - return NULL; \ + return 0; \ } \ \ void ResizeTable( size_t newSize ) \ { \ newSize = GetNextPrime( (unsigned long)newSize ); \ - _wxHashTable_NodeBase** srcTable = m_table; \ + Node** srcTable = m_table; \ size_t srcBuckets = m_tableBuckets; \ - m_table = (_wxHashTable_NodeBase**)AllocTable( newSize ); \ + m_table = (Node**)AllocTable( newSize ); \ m_tableBuckets = newSize; \ \ - CopyHashTable( srcTable, srcBuckets, \ - this, m_table, \ + CopyHashTable( (_wxHashTable_NodeBase**)srcTable, srcBuckets, \ + this, (_wxHashTable_NodeBase**)m_table, \ (BucketFromNode)GetBucketForNode,\ (ProcessNode)&DummyProcessNode ); \ FreeTable(srcTable); \ @@ -412,9 +411,9 @@ protected: \ void HashCopy( const Self& ht ) \ { \ ResizeTable( ht.size() ); \ - CopyHashTable( ht.m_table, ht.m_tableBuckets, \ + CopyHashTable( (_wxHashTable_NodeBase**)ht.m_table, ht.m_tableBuckets,\ (_wxHashTableBase2*)this, \ - m_table, \ + (_wxHashTable_NodeBase**)m_table, \ (BucketFromNode)GetBucketForNode, \ (ProcessNode)CopyNode ); \ } \ @@ -426,15 +425,12 @@ protected: \ CLASSEXP CLASSNAME \ { \ public: \ - typedef KEY_T first_type; \ - typedef VALUE_T second_type; \ typedef KEY_T t1; \ typedef VALUE_T t2; \ typedef const KEY_T const_t1; \ typedef const VALUE_T const_t2; \ \ - CLASSNAME(const const_t1& f, const const_t2& s) \ - : first(const_cast(f)), second(const_cast(s)) {} \ + CLASSNAME( const const_t1& f, const const_t2& s ):first(t1(f)),second(t2(s)) {} \ \ t1 first; \ t2 second; \ @@ -466,7 +462,7 @@ inline bool never_grow( size_t, size_t ) { return false; } inline bool never_shrink( size_t, size_t ) { return false; } inline bool grow_lf70( size_t buckets, size_t items ) { - return float(items)/float(buckets) >= 0.85f; + return float(items)/float(buckets) >= 0.85; } #endif // various hash map implementations @@ -482,9 +478,8 @@ inline bool grow_lf70( size_t buckets, size_t items ) #ifndef wxNEEDS_WX_HASH_MAP // integer types -struct WXDLLIMPEXP_BASE wxIntegerHash +class WXDLLIMPEXP_BASE wxIntegerHash { -private: WX_HASH_MAP_NAMESPACE::hash longHash; WX_HASH_MAP_NAMESPACE::hash ulongHash; WX_HASH_MAP_NAMESPACE::hash intHash; @@ -492,7 +487,7 @@ private: WX_HASH_MAP_NAMESPACE::hash shortHash; WX_HASH_MAP_NAMESPACE::hash ushortHash; -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#if defined wxLongLong_t && !defined wxLongLongIsLong // hash ought to work but doesn't on some compilers #if (!defined SIZEOF_LONG_LONG && SIZEOF_LONG == 4) \ || (defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG * 2) @@ -506,7 +501,7 @@ private: #else WX_HASH_MAP_NAMESPACE::hash longlongHash; #endif -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#endif public: wxIntegerHash() { } @@ -516,10 +511,10 @@ public: size_t operator()( unsigned int x ) const { return uintHash( x ); } size_t operator()( short x ) const { return shortHash( x ); } size_t operator()( unsigned short x ) const { return ushortHash( x ); } -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#if defined wxLongLong_t && !defined wxLongLongIsLong size_t operator()( wxLongLong_t x ) const { return longlongHash(x); } size_t operator()( wxULongLong_t x ) const { return longlongHash(x); } -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#endif wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } }; @@ -527,8 +522,9 @@ public: #else // wxNEEDS_WX_HASH_MAP // integer types -struct WXDLLIMPEXP_BASE wxIntegerHash +class WXDLLIMPEXP_BASE wxIntegerHash { +public: wxIntegerHash() { } unsigned long operator()( long x ) const { return (unsigned long)x; } unsigned long operator()( unsigned long x ) const { return x; } @@ -536,18 +532,19 @@ struct WXDLLIMPEXP_BASE wxIntegerHash unsigned long operator()( unsigned int x ) const { return x; } unsigned long operator()( short x ) const { return (unsigned long)x; } unsigned long operator()( unsigned short x ) const { return x; } -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - wxULongLong_t operator()( wxLongLong_t x ) const { return static_cast(x); } +#if defined wxLongLong_t && !defined wxLongLongIsLong + wxULongLong_t operator()( wxLongLong_t x ) const { return wx_static_cast(wxULongLong_t, x); } wxULongLong_t operator()( wxULongLong_t x ) const { return x; } -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#endif wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } }; #endif // !wxNEEDS_WX_HASH_MAP/wxNEEDS_WX_HASH_MAP -struct WXDLLIMPEXP_BASE wxIntegerEqual +class WXDLLIMPEXP_BASE wxIntegerEqual { +public: wxIntegerEqual() { } bool operator()( long a, long b ) const { return a == b; } bool operator()( unsigned long a, unsigned long b ) const { return a == b; } @@ -555,64 +552,60 @@ struct WXDLLIMPEXP_BASE wxIntegerEqual bool operator()( unsigned int a, unsigned int b ) const { return a == b; } bool operator()( short a, short b ) const { return a == b; } bool operator()( unsigned short a, unsigned short b ) const { return a == b; } -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#if defined wxLongLong_t && !defined wxLongLongIsLong bool operator()( wxLongLong_t a, wxLongLong_t b ) const { return a == b; } bool operator()( wxULongLong_t a, wxULongLong_t b ) const { return a == b; } -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#endif wxIntegerEqual& operator=(const wxIntegerEqual&) { return *this; } }; // pointers -struct WXDLLIMPEXP_BASE wxPointerHash +class WXDLLIMPEXP_BASE wxPointerHash { +public: wxPointerHash() { } #ifdef wxNEEDS_WX_HASH_MAP wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); } #else - size_t operator()( const void* k ) const { return (size_t)k; } + wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); } #endif wxPointerHash& operator=(const wxPointerHash&) { return *this; } }; -struct WXDLLIMPEXP_BASE wxPointerEqual +class WXDLLIMPEXP_BASE wxPointerEqual { +public: wxPointerEqual() { } bool operator()( const void* a, const void* b ) const { return a == b; } wxPointerEqual& operator=(const wxPointerEqual&) { return *this; } }; -// wxString, char*, wchar_t* -struct WXDLLIMPEXP_BASE wxStringHash +// wxString, char*, wxChar* +class WXDLLIMPEXP_BASE wxStringHash { +public: wxStringHash() {} unsigned long operator()( const wxString& x ) const - { return stringHash( x.wx_str() ); } - unsigned long operator()( const wchar_t* x ) const - { return stringHash( x ); } + { return wxCharStringHash( x.c_str() ); } + unsigned long operator()( const wxChar* x ) const + { return wxCharStringHash( x ); } + static unsigned long wxCharStringHash( const wxChar* ); +#if wxUSE_UNICODE unsigned long operator()( const char* x ) const - { return stringHash( x ); } - -#if WXWIN_COMPATIBILITY_2_8 - static unsigned long wxCharStringHash( const wxChar* x ) - { return stringHash(x); } - #if wxUSE_UNICODE - static unsigned long charStringHash( const char* x ) - { return stringHash(x); } - #endif -#endif // WXWIN_COMPATIBILITY_2_8 - - static unsigned long stringHash( const wchar_t* ); - static unsigned long stringHash( const char* ); + { return charStringHash( x ); } + static unsigned long charStringHash( const char* ); +#endif // wxUSE_UNICODE wxStringHash& operator=(const wxStringHash&) { return *this; } }; -struct WXDLLIMPEXP_BASE wxStringEqual +class WXDLLIMPEXP_BASE wxStringEqual { +public: wxStringEqual() {} bool operator()( const wxString& a, const wxString& b ) const { return a == b; } @@ -628,16 +621,10 @@ struct WXDLLIMPEXP_BASE wxStringEqual #ifdef wxNEEDS_WX_HASH_MAP -#define wxPTROP_NORMAL(pointer) \ - pointer operator ->() const { return &(m_node->m_value); } -#define wxPTROP_NOP(pointer) - #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ _WX_DECLARE_PAIR( KEY_T, VALUE_T, CLASSNAME##_wxImplementation_Pair, CLASSEXP ) \ _WX_DECLARE_HASH_MAP_KEY_EX( KEY_T, CLASSNAME##_wxImplementation_Pair, CLASSNAME##_wxImplementation_KeyEx, CLASSEXP ) \ -_WX_DECLARE_HASHTABLE( CLASSNAME##_wxImplementation_Pair, KEY_T, HASH_T, \ - CLASSNAME##_wxImplementation_KeyEx, KEY_EQ_T, wxPTROP_NORMAL, \ - CLASSNAME##_wxImplementation_HashTable, CLASSEXP, grow_lf70, never_shrink ) \ +_WX_DECLARE_HASHTABLE( CLASSNAME##_wxImplementation_Pair, KEY_T, HASH_T, CLASSNAME##_wxImplementation_KeyEx, KEY_EQ_T, CLASSNAME##_wxImplementation_HashTable, CLASSEXP, grow_lf70, never_shrink ) \ CLASSEXP CLASSNAME:public CLASSNAME##_wxImplementation_HashTable \ { \ public: \ @@ -678,12 +665,14 @@ public: \ \ size_type erase( const key_type& k ) \ { return CLASSNAME##_wxImplementation_HashTable::erase( k ); } \ - void erase( const iterator& it ) { erase( (*it).first ); } \ + void erase( const iterator& it ) { erase( it->first ); } \ + void erase( const const_iterator& it ) { erase( it->first ); } \ \ /* count() == 0 | 1 */ \ size_type count( const const_key_type& key ) \ { \ - return GetNode( key ) ? 1u : 0u; \ + /* explicit cast needed to suppress CodeWarrior warnings */ \ + return (size_type)(GetNode( key ) ? 1 : 0); \ } \ } @@ -708,7 +697,7 @@ public: \ #define WX_DECLARE_EXPORTED_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME) \ WX_DECLARE_HASH_MAP_WITH_DECL( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, \ - CLASSNAME, class WXDLLIMPEXP_CORE ) + CLASSNAME, class WXDLLEXPORT ) #define WX_DECLARE_STRING_HASH_MAP_WITH_DECL( VALUE_T, CLASSNAME, DECL ) \ _WX_DECLARE_HASH_MAP( wxString, VALUE_T, wxStringHash, wxStringEqual, \ @@ -716,7 +705,7 @@ public: \ #define WX_DECLARE_EXPORTED_STRING_HASH_MAP( VALUE_T, CLASSNAME ) \ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( VALUE_T, CLASSNAME, \ - class WXDLLIMPEXP_CORE ) + class WXDLLEXPORT ) #define WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL( VALUE_T, CLASSNAME, DECL ) \ _WX_DECLARE_HASH_MAP( void*, VALUE_T, wxPointerHash, wxPointerEqual, \ @@ -724,7 +713,7 @@ public: \ #define WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP( VALUE_T, CLASSNAME ) \ WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL( VALUE_T, CLASSNAME, \ - class WXDLLIMPEXP_CORE ) + class WXDLLEXPORT ) // delete all hash elements // @@ -746,11 +735,5 @@ public: \ WX_DECLARE_HASH_MAP_WITH_DECL( long, long, wxIntegerHash, wxIntegerEqual, wxLongToLongHashMap, class WXDLLIMPEXP_BASE ); -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxString, wxStringToStringHashMap, - class WXDLLIMPEXP_BASE ); - -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxUIntPtr, wxStringToNumHashMap, - class WXDLLIMPEXP_BASE ); - #endif // _WX_HASHMAP_H_ diff --git a/Source/3rd Party/wx/include/wx/hashset.h b/Source/3rd Party/wx/include/wx/hashset.h index 251cdafe2..b5e7892ff 100644 --- a/Source/3rd Party/wx/include/wx/hashset.h +++ b/Source/3rd Party/wx/include/wx/hashset.h @@ -4,6 +4,7 @@ // Author: Mattia Barbon // Modified by: // Created: 11/08/2003 +// RCS-ID: $Id: hashset.h 55215 2008-08-23 18:54:04Z VZ $ // Copyright: (c) Mattia Barbon // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,20 +17,22 @@ // see comment in wx/hashmap.h which also applies to different standard hash // set classes -#if wxUSE_STD_CONTAINERS && \ +#if wxUSE_STL && \ (defined(HAVE_STD_UNORDERED_SET) || defined(HAVE_TR1_UNORDERED_SET)) #if defined(HAVE_STD_UNORDERED_SET) #include - #define WX_HASH_SET_BASE_TEMPLATE std::unordered_set + #define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\ + typedef std::unordered_set< KEY_T, HASH_T, KEY_EQ_T > CLASSNAME #elif defined(HAVE_TR1_UNORDERED_SET) #include - #define WX_HASH_SET_BASE_TEMPLATE std::tr1::unordered_set + #define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\ + typedef std::tr1::unordered_set< KEY_T, HASH_T, KEY_EQ_T > CLASSNAME #else - #error Update this code: unordered_set is available, but I do not know where. +#error Update this code: unordered_set is available, but I do not know where. #endif -#elif wxUSE_STD_CONTAINERS && defined(HAVE_STL_HASH_MAP) +#elif wxUSE_STL && defined(HAVE_STL_HASH_MAP) #if defined(HAVE_EXT_HASH_MAP) #include @@ -37,63 +40,10 @@ #include #endif -#define WX_HASH_SET_BASE_TEMPLATE WX_HASH_MAP_NAMESPACE::hash_set +#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\ + typedef WX_HASH_MAP_NAMESPACE::hash_set< KEY_T, HASH_T, KEY_EQ_T > CLASSNAME -#endif // different hash_set/unordered_set possibilities - -#ifdef WX_HASH_SET_BASE_TEMPLATE - -// we need to define the class declared by _WX_DECLARE_HASH_SET as a class and -// not a typedef to allow forward declaring it -#define _WX_DECLARE_HASH_SET_IMPL( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP ) \ -CLASSEXP CLASSNAME \ - : public WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T > \ -{ \ -public: \ - explicit CLASSNAME(size_type n = 3, \ - const hasher& h = hasher(), \ - const key_equal& ke = key_equal(), \ - const allocator_type& a = allocator_type()) \ - : WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(n, h, ke, a) \ - {} \ - template \ - CLASSNAME(InputIterator f, InputIterator l, \ - const hasher& h = hasher(), \ - const key_equal& ke = key_equal(), \ - const allocator_type& a = allocator_type()) \ - : WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(f, l, h, ke, a)\ - {} \ - CLASSNAME(const WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >& s) \ - : WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(s) \ - {} \ -} - -// In some standard library implementations (in particular, the libstdc++ that -// ships with g++ 4.7), std::unordered_set inherits privately from its hasher -// and comparator template arguments for purposes of empty base optimization. -// As a result, in the declaration of a class deriving from std::unordered_set -// the names of the hasher and comparator classes are interpreted as naming -// the base class which is inaccessible. -// The workaround is to prefix the class names with 'struct'; however, don't -// do this on MSVC because it causes a warning there if the class was -// declared as a 'class' rather than a 'struct' (and MSVC's std::unordered_set -// implementation does not suffer from the access problem). -#ifdef _MSC_VER -#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) STRUCTNAME -#else -#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) struct STRUCTNAME -#endif - -#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP ) \ - _WX_DECLARE_HASH_SET_IMPL( \ - KEY_T, \ - WX_MAYBE_PREFIX_WITH_STRUCT(HASH_T), \ - WX_MAYBE_PREFIX_WITH_STRUCT(KEY_EQ_T), \ - PTROP, \ - CLASSNAME, \ - CLASSEXP) - -#else // no appropriate STL class, use our own implementation +#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) // this is a complex way of defining an easily inlineable identity function... #define _WX_DECLARE_HASH_SET_KEY_EX( KEY_T, CLASSNAME, CLASSEXP ) \ @@ -113,11 +63,9 @@ public: \ CLASSNAME& operator=(const CLASSNAME&) { return *this; } \ }; -#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP )\ +#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\ _WX_DECLARE_HASH_SET_KEY_EX( KEY_T, CLASSNAME##_wxImplementation_KeyEx, CLASSEXP ) \ -_WX_DECLARE_HASHTABLE( KEY_T, KEY_T, HASH_T, \ - CLASSNAME##_wxImplementation_KeyEx, KEY_EQ_T, PTROP, \ - CLASSNAME##_wxImplementation_HashTable, CLASSEXP, grow_lf70, never_shrink ) \ +_WX_DECLARE_HASHTABLE( KEY_T, KEY_T, HASH_T, CLASSNAME##_wxImplementation_KeyEx, KEY_EQ_T, CLASSNAME##_wxImplementation_HashTable, CLASSEXP, grow_lf70, never_shrink ) \ CLASSEXP CLASSNAME:public CLASSNAME##_wxImplementation_HashTable \ { \ public: \ @@ -151,35 +99,24 @@ public: \ void erase( const const_iterator& it ) { erase( *it ); } \ \ /* count() == 0 | 1 */ \ - size_type count( const const_key_type& key ) const \ + size_type count( const const_key_type& key ) \ { return GetNode( key ) ? 1 : 0; } \ } -#endif // STL/wx implementations - +#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) // these macros are to be used in the user code #define WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME) \ - _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, wxPTROP_NORMAL, CLASSNAME, class ) + _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, class ) // and these do exactly the same thing but should be used inside the // library #define WX_DECLARE_HASH_SET_WITH_DECL( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, DECL) \ - _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, wxPTROP_NORMAL, CLASSNAME, DECL ) + _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, DECL ) #define WX_DECLARE_EXPORTED_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME) \ WX_DECLARE_HASH_SET_WITH_DECL( KEY_T, HASH_T, KEY_EQ_T, \ - CLASSNAME, class WXDLLIMPEXP_CORE ) - -// Finally these versions allow to define hash sets of non-objects (including -// pointers, hence the confusing but wxArray-compatible name) without -// operator->() which can't be used for them. This is mostly used inside the -// library itself to avoid warnings when using such hash sets with some less -// common compilers (notably Sun CC). -#define WX_DECLARE_HASH_SET_PTR( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME) \ - _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, wxPTROP_NOP, CLASSNAME, class ) -#define WX_DECLARE_HASH_SET_WITH_DECL_PTR( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, DECL) \ - _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, wxPTROP_NOP, CLASSNAME, DECL ) + CLASSNAME, class WXDLLEXPORT ) // delete all hash elements // diff --git a/Source/3rd Party/wx/include/wx/headercol.h b/Source/3rd Party/wx/include/wx/headercol.h deleted file mode 100644 index 1002c0f56..000000000 --- a/Source/3rd Party/wx/include/wx/headercol.h +++ /dev/null @@ -1,288 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/headercol.h -// Purpose: declaration of wxHeaderColumn class -// Author: Vadim Zeitlin -// Created: 2008-12-02 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HEADERCOL_H_ -#define _WX_HEADERCOL_H_ - -#include "wx/bitmap.h" - -#if wxUSE_HEADERCTRL - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -enum -{ - // special value for column width meaning unspecified/default - wxCOL_WIDTH_DEFAULT = -1, - - // size the column automatically to fit all values - wxCOL_WIDTH_AUTOSIZE = -2 -}; - -// bit masks for the various column attributes -enum -{ - // column can be resized (included in default flags) - wxCOL_RESIZABLE = 1, - - // column can be clicked to toggle the sort order by its contents - wxCOL_SORTABLE = 2, - - // column can be dragged to change its order (included in default) - wxCOL_REORDERABLE = 4, - - // column is not shown at all - wxCOL_HIDDEN = 8, - - // default flags for wxHeaderColumn ctor - wxCOL_DEFAULT_FLAGS = wxCOL_RESIZABLE | wxCOL_REORDERABLE -}; - -// ---------------------------------------------------------------------------- -// wxHeaderColumn: interface for a column in a header of controls such as -// wxListCtrl, wxDataViewCtrl or wxGrid -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderColumn -{ -public: - // ctors and dtor - // -------------- - - /* - Derived classes must provide ctors with the following signatures - (notice that they shouldn't be explicit to allow passing strings/bitmaps - directly to methods such wxHeaderCtrl::AppendColumn()): - wxHeaderColumn(const wxString& title, - int width = wxCOL_WIDTH_DEFAULT, - wxAlignment align = wxALIGN_NOT, - int flags = wxCOL_DEFAULT_FLAGS); - wxHeaderColumn(const wxBitmap &bitmap, - int width = wxDVC_DEFAULT_WIDTH, - wxAlignment align = wxALIGN_CENTER, - int flags = wxCOL_DEFAULT_FLAGS); - */ - - // virtual dtor for the base class to avoid gcc warnings even though we - // don't normally delete the objects of this class via a pointer to - // wxHeaderColumn so it's not necessary, strictly speaking - virtual ~wxHeaderColumn() { } - - // getters for various attributes - // ------------------------------ - - // notice that wxHeaderColumn only provides getters as this is all the - // wxHeaderCtrl needs, various derived class must also provide some way to - // change these attributes but this can be done either at the column level - // (in which case they should inherit from wxSettableHeaderColumn) or via - // the methods of the main control in which case you don't need setters in - // the column class at all - - // title is the string shown for this column - virtual wxString GetTitle() const = 0; - - // bitmap shown (instead of text) in the column header - virtual wxBitmap GetBitmap() const = 0; \ - - // width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning - // unspecified/default - virtual int GetWidth() const = 0; - - // minimal width can be set for resizable columns to forbid resizing them - // below the specified size (set to 0 to remove) - virtual int GetMinWidth() const = 0; - - // alignment of the text: wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT - virtual wxAlignment GetAlignment() const = 0; - - - // flags manipulations: - // -------------------- - - // notice that while we make GetFlags() pure virtual here and implement the - // individual flags access in terms of it, for some derived classes it is - // more natural to implement access to each flag individually, in which - // case they can use our GetFromIndividualFlags() helper below to implement - // GetFlags() - - // retrieve all column flags at once: combination of wxCOL_XXX values above - virtual int GetFlags() const = 0; - - bool HasFlag(int flag) const { return (GetFlags() & flag) != 0; } - - - // wxCOL_RESIZABLE - virtual bool IsResizeable() const - { return HasFlag(wxCOL_RESIZABLE); } - - // wxCOL_SORTABLE - virtual bool IsSortable() const - { return HasFlag(wxCOL_SORTABLE); } - - // wxCOL_REORDERABLE - virtual bool IsReorderable() const - { return HasFlag(wxCOL_REORDERABLE); } - - // wxCOL_HIDDEN - virtual bool IsHidden() const - { return HasFlag(wxCOL_HIDDEN); } - bool IsShown() const - { return !IsHidden(); } - - - // sorting - // ------- - - // return true if the column is the one currently used for sorting - virtual bool IsSortKey() const = 0; - - // for sortable columns indicate whether we should sort in ascending or - // descending order (this should only be taken into account if IsSortKey()) - virtual bool IsSortOrderAscending() const = 0; - -protected: - // helper for the class overriding IsXXX() - int GetFromIndividualFlags() const; -}; - -// ---------------------------------------------------------------------------- -// wxSettableHeaderColumn: column which allows to change its fields too -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxSettableHeaderColumn : public wxHeaderColumn -{ -public: - virtual void SetTitle(const wxString& title) = 0; - virtual void SetBitmap(const wxBitmap& bitmap) = 0; - virtual void SetWidth(int width) = 0; - virtual void SetMinWidth(int minWidth) = 0; - virtual void SetAlignment(wxAlignment align) = 0; - - // see comment for wxHeaderColumn::GetFlags() about the relationship - // between SetFlags() and Set{Sortable,Reorderable,...} - - // change, set, clear, toggle or test for any individual flag - virtual void SetFlags(int flags) = 0; - void ChangeFlag(int flag, bool set); - void SetFlag(int flag); - void ClearFlag(int flag); - void ToggleFlag(int flag); - - virtual void SetResizeable(bool resizable) - { ChangeFlag(wxCOL_RESIZABLE, resizable); } - virtual void SetSortable(bool sortable) - { ChangeFlag(wxCOL_SORTABLE, sortable); } - virtual void SetReorderable(bool reorderable) - { ChangeFlag(wxCOL_REORDERABLE, reorderable); } - virtual void SetHidden(bool hidden) - { ChangeFlag(wxCOL_HIDDEN, hidden); } - - // This function can be called to indicate that this column is not used for - // sorting any more. Under some platforms it's not necessary to do anything - // in this case as just setting another column as a sort key takes care of - // everything but under MSW we currently need to call this explicitly to - // reset the sort indicator displayed on the column. - virtual void UnsetAsSortKey() { } - - virtual void SetSortOrder(bool ascending) = 0; - void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); } - -protected: - // helper for the class overriding individual SetXXX() methods instead of - // overriding SetFlags() - void SetIndividualFlags(int flags); -}; - -// ---------------------------------------------------------------------------- -// wxHeaderColumnSimple: trivial generic implementation of wxHeaderColumn -// ---------------------------------------------------------------------------- - -class wxHeaderColumnSimple : public wxSettableHeaderColumn -{ -public: - // ctors and dtor - wxHeaderColumnSimple(const wxString& title, - int width = wxCOL_WIDTH_DEFAULT, - wxAlignment align = wxALIGN_NOT, - int flags = wxCOL_DEFAULT_FLAGS) - : m_title(title), - m_width(width), - m_align(align), - m_flags(flags) - { - Init(); - } - - wxHeaderColumnSimple(const wxBitmap& bitmap, - int width = wxCOL_WIDTH_DEFAULT, - wxAlignment align = wxALIGN_CENTER, - int flags = wxCOL_DEFAULT_FLAGS) - : m_bitmap(bitmap), - m_width(width), - m_align(align), - m_flags(flags) - { - Init(); - } - - // implement base class pure virtuals - virtual void SetTitle(const wxString& title) { m_title = title; } - virtual wxString GetTitle() const { return m_title; } - - virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } - wxBitmap GetBitmap() const { return m_bitmap; } - - virtual void SetWidth(int width) { m_width = width; } - virtual int GetWidth() const { return m_width; } - - virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; } - virtual int GetMinWidth() const { return m_minWidth; } - - virtual void SetAlignment(wxAlignment align) { m_align = align; } - virtual wxAlignment GetAlignment() const { return m_align; } - - virtual void SetFlags(int flags) { m_flags = flags; } - virtual int GetFlags() const { return m_flags; } - - virtual bool IsSortKey() const { return m_sort; } - virtual void UnsetAsSortKey() { m_sort = false; } - - virtual void SetSortOrder(bool ascending) - { - m_sort = true; - m_sortAscending = ascending; - } - - virtual bool IsSortOrderAscending() const { return m_sortAscending; } - -private: - // common part of all ctors - void Init() - { - m_minWidth = 0; - m_sort = false; - m_sortAscending = true; - } - - wxString m_title; - wxBitmap m_bitmap; - int m_width, - m_minWidth; - wxAlignment m_align; - int m_flags; - bool m_sort, - m_sortAscending; -}; - -#endif // wxUSE_HEADERCTRL - -#endif // _WX_HEADERCOL_H_ - diff --git a/Source/3rd Party/wx/include/wx/headerctrl.h b/Source/3rd Party/wx/include/wx/headerctrl.h deleted file mode 100644 index 78d7117b9..000000000 --- a/Source/3rd Party/wx/include/wx/headerctrl.h +++ /dev/null @@ -1,488 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/headerctrl.h -// Purpose: wxHeaderCtrlBase class: interface of wxHeaderCtrl -// Author: Vadim Zeitlin -// Created: 2008-12-01 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HEADERCTRL_H_ -#define _WX_HEADERCTRL_H_ - -#include "wx/control.h" - -#if wxUSE_HEADERCTRL - -#include "wx/dynarray.h" -#include "wx/vector.h" - -#include "wx/headercol.h" - -// notice that the classes in this header are defined in the core library even -// although currently they're only used by wxGrid which is in wxAdv because we -// plan to use it in wxListCtrl which is in core too in the future -class WXDLLIMPEXP_FWD_CORE wxHeaderCtrlEvent; - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -enum -{ - // allow column drag and drop - wxHD_ALLOW_REORDER = 0x0001, - - // allow hiding (and showing back) the columns using the menu shown by - // right clicking the header - wxHD_ALLOW_HIDE = 0x0002, - - // style used by default when creating the control - wxHD_DEFAULT_STYLE = wxHD_ALLOW_REORDER -}; - -extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[]; - -// ---------------------------------------------------------------------------- -// wxHeaderCtrlBase defines the interface of a header control -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderCtrlBase : public wxControl -{ -public: - /* - Derived classes must provide default ctor as well as a ctor and - Create() function with the following signatures: - - wxHeaderCtrl(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr); - - bool Create(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr); - */ - - // column-related methods - // ---------------------- - - // set the number of columns in the control - // - // this also calls UpdateColumn() for all columns - void SetColumnCount(unsigned int count); - - // return the number of columns in the control as set by SetColumnCount() - unsigned int GetColumnCount() const { return DoGetCount(); } - - // return whether the control has any columns - bool IsEmpty() const { return DoGetCount() == 0; } - - // update the column with the given index - void UpdateColumn(unsigned int idx) - { - wxCHECK_RET( idx < GetColumnCount(), "invalid column index" ); - - DoUpdate(idx); - } - - - // columns order - // ------------- - - // set the columns order: the array defines the column index which appears - // the given position, it must have GetColumnCount() elements and contain - // all indices exactly once - void SetColumnsOrder(const wxArrayInt& order); - wxArrayInt GetColumnsOrder() const; - - // get the index of the column at the given display position - unsigned int GetColumnAt(unsigned int pos) const; - - // get the position at which this column is currently displayed - unsigned int GetColumnPos(unsigned int idx) const; - - // reset the columns order to the natural one - void ResetColumnsOrder(); - - // helper function used by the generic version of this control and also - // wxGrid: reshuffles the array of column indices indexed by positions - // (i.e. using the same convention as for SetColumnsOrder()) so that the - // column with the given index is found at the specified position - static void MoveColumnInOrderArray(wxArrayInt& order, - unsigned int idx, - unsigned int pos); - - - // UI helpers - // ---------- - -#if wxUSE_MENUS - // show the popup menu containing all columns with check marks for the ones - // which are currently shown and return true if something was done using it - // (in this case UpdateColumnVisibility() will have been called) or false - // if the menu was cancelled - // - // this is called from the default right click handler for the controls - // with wxHD_ALLOW_HIDE style - bool ShowColumnsMenu(const wxPoint& pt, const wxString& title = wxString()); - - // append the entries for all our columns to the given menu, with the - // currently visible columns being checked - // - // this is used by ShowColumnsMenu() but can also be used if you use your - // own custom columns menu but nevertheless want to show all the columns in - // it - // - // the ids of the items corresponding to the columns are consecutive and - // start from idColumnsBase - void AddColumnsItems(wxMenu& menu, int idColumnsBase = 0); -#endif // wxUSE_MENUS - - // show the columns customization dialog and return true if something was - // changed using it (in which case UpdateColumnVisibility() and/or - // UpdateColumnsOrder() will have been called) - // - // this is called by the control itself from ShowColumnsMenu() (which in - // turn is only called by the control if wxHD_ALLOW_HIDE style was - // specified) and if the control has wxHD_ALLOW_REORDER style as well - bool ShowCustomizeDialog(); - - // compute column title width - int GetColumnTitleWidth(const wxHeaderColumn& col); - - // implementation only from now on - // ------------------------------- - - // the user doesn't need to TAB to this control - virtual bool AcceptsFocusFromKeyboard() const { return false; } - - // this method is only overridden in order to synchronize the control with - // the main window when it is scrolled, the derived class must implement - // DoScrollHorz() - virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); - -protected: - // this method must be implemented by the derived classes to return the - // information for the given column - virtual const wxHeaderColumn& GetColumn(unsigned int idx) const = 0; - - // this method is called from the default EVT_HEADER_SEPARATOR_DCLICK - // handler to update the fitting column width of the given column, it - // should return true if the width was really updated - virtual bool UpdateColumnWidthToFit(unsigned int WXUNUSED(idx), - int WXUNUSED(widthTitle)) - { - return false; - } - - // this method is called from ShowColumnsMenu() and must be overridden to - // update the internal column visibility (there is no need to call - // UpdateColumn() from here, this will be done internally) - virtual void UpdateColumnVisibility(unsigned int WXUNUSED(idx), - bool WXUNUSED(show)) - { - wxFAIL_MSG( "must be overridden if called" ); - } - - // this method is called from ShowCustomizeDialog() to reorder all columns - // at once and should be implemented for controls using wxHD_ALLOW_REORDER - // style (there is no need to call SetColumnsOrder() from here, this is - // done by the control itself) - virtual void UpdateColumnsOrder(const wxArrayInt& WXUNUSED(order)) - { - wxFAIL_MSG( "must be overridden if called" ); - } - - // this method can be overridden in the derived classes to do something - // (e.g. update/resize some internal data structures) before the number of - // columns in the control changes - virtual void OnColumnCountChanging(unsigned int WXUNUSED(count)) { } - - - // helper function for the derived classes: update the array of column - // indices after the number of columns changed - void DoResizeColumnIndices(wxArrayInt& colIndices, unsigned int count); - -protected: - // this window doesn't look nice with the border so don't use it by default - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - -private: - // methods implementing our public API and defined in platform-specific - // implementations - virtual void DoSetCount(unsigned int count) = 0; - virtual unsigned int DoGetCount() const = 0; - virtual void DoUpdate(unsigned int idx) = 0; - - virtual void DoScrollHorz(int dx) = 0; - - virtual void DoSetColumnsOrder(const wxArrayInt& order) = 0; - virtual wxArrayInt DoGetColumnsOrder() const = 0; - - - // event handlers - void OnSeparatorDClick(wxHeaderCtrlEvent& event); -#if wxUSE_MENUS - void OnRClick(wxHeaderCtrlEvent& event); -#endif // wxUSE_MENUS - - DECLARE_EVENT_TABLE() -}; - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl: port-specific header control implementation, notice that this -// is still an ABC which is meant to be used as part of another -// control, see wxHeaderCtrlSimple for a standalone version -// ---------------------------------------------------------------------------- - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/headerctrl.h" -#else - #define wxHAS_GENERIC_HEADERCTRL - #include "wx/generic/headerctrlg.h" -#endif // platform - -// ---------------------------------------------------------------------------- -// wxHeaderCtrlSimple: concrete header control which can be used standalone -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderCtrlSimple : public wxHeaderCtrl -{ -public: - // control creation - // ---------------- - - wxHeaderCtrlSimple() { Init(); } - wxHeaderCtrlSimple(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr) - { - Init(); - - Create(parent, winid, pos, size, style, name); - } - - // managing the columns - // -------------------- - - // insert the column at the given position, using GetColumnCount() as - // position appends it at the end - void InsertColumn(const wxHeaderColumnSimple& col, unsigned int idx) - { - wxCHECK_RET( idx <= GetColumnCount(), "invalid column index" ); - - DoInsert(col, idx); - } - - // append the column to the end of the control - void AppendColumn(const wxHeaderColumnSimple& col) - { - DoInsert(col, GetColumnCount()); - } - - // delete the column at the given index - void DeleteColumn(unsigned int idx) - { - wxCHECK_RET( idx < GetColumnCount(), "invalid column index" ); - - DoDelete(idx); - } - - // delete all the existing columns - void DeleteAllColumns(); - - - // modifying columns - // ----------------- - - // show or hide the column, notice that even when a column is hidden we - // still account for it when using indices - void ShowColumn(unsigned int idx, bool show = true) - { - wxCHECK_RET( idx < GetColumnCount(), "invalid column index" ); - - DoShowColumn(idx, show); - } - - void HideColumn(unsigned int idx) - { - ShowColumn(idx, false); - } - - // indicate that the column is used for sorting - void ShowSortIndicator(unsigned int idx, bool ascending = true) - { - wxCHECK_RET( idx < GetColumnCount(), "invalid column index" ); - - DoShowSortIndicator(idx, ascending); - } - - // remove the sort indicator completely - void RemoveSortIndicator(); - -protected: - // implement/override base class methods - virtual const wxHeaderColumn& GetColumn(unsigned int idx) const; - virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle); - - // and define another one to be overridden in the derived classes: it - // should return the best width for the given column contents or -1 if not - // implemented, we use it to implement UpdateColumnWidthToFit() - virtual int GetBestFittingWidth(unsigned int WXUNUSED(idx)) const - { - return -1; - } - -private: - // functions implementing our public API - void DoInsert(const wxHeaderColumnSimple& col, unsigned int idx); - void DoDelete(unsigned int idx); - void DoShowColumn(unsigned int idx, bool show); - void DoShowSortIndicator(unsigned int idx, bool ascending); - - // common part of all ctors - void Init(); - - // bring the column count in sync with the number of columns we store - void UpdateColumnCount() - { - SetColumnCount(static_cast(m_cols.size())); - } - - - // all our current columns - typedef wxVector Columns; - Columns m_cols; - - // the column currently used for sorting or -1 if none - unsigned int m_sortKey; - - - wxDECLARE_NO_COPY_CLASS(wxHeaderCtrlSimple); -}; - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl events -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderCtrlEvent : public wxNotifyEvent -{ -public: - wxHeaderCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) - : wxNotifyEvent(commandType, winid), - m_col(-1), - m_width(0), - m_order(static_cast(-1)) - { - } - - wxHeaderCtrlEvent(const wxHeaderCtrlEvent& event) - : wxNotifyEvent(event), - m_col(event.m_col), - m_width(event.m_width), - m_order(event.m_order) - { - } - - // the column which this event pertains to: valid for all header events - int GetColumn() const { return m_col; } - void SetColumn(int col) { m_col = col; } - - // the width of the column: valid for column resizing/dragging events only - int GetWidth() const { return m_width; } - void SetWidth(int width) { m_width = width; } - - // the new position of the column: for end reorder events only - unsigned int GetNewOrder() const { return m_order; } - void SetNewOrder(unsigned int order) { m_order = order; } - - virtual wxEvent *Clone() const { return new wxHeaderCtrlEvent(*this); } - -protected: - // the column affected by the event - int m_col; - - // the current width for the dragging events - int m_width; - - // the new column position for end reorder event - unsigned int m_order; - -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHeaderCtrlEvent) -}; - - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_CLICK, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_RIGHT_CLICK, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_MIDDLE_CLICK, wxHeaderCtrlEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_DCLICK, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_RIGHT_DCLICK, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_MIDDLE_DCLICK, wxHeaderCtrlEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_SEPARATOR_DCLICK, wxHeaderCtrlEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_BEGIN_RESIZE, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_RESIZING, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_END_RESIZE, wxHeaderCtrlEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_BEGIN_REORDER, wxHeaderCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_END_REORDER, wxHeaderCtrlEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HEADER_DRAGGING_CANCELLED, wxHeaderCtrlEvent ); - -typedef void (wxEvtHandler::*wxHeaderCtrlEventFunction)(wxHeaderCtrlEvent&); - -#define wxHeaderCtrlEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxHeaderCtrlEventFunction, func) - -#define wx__DECLARE_HEADER_EVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_HEADER_ ## evt, id, wxHeaderCtrlEventHandler(fn)) - -#define EVT_HEADER_CLICK(id, fn) wx__DECLARE_HEADER_EVT(CLICK, id, fn) -#define EVT_HEADER_RIGHT_CLICK(id, fn) wx__DECLARE_HEADER_EVT(RIGHT_CLICK, id, fn) -#define EVT_HEADER_MIDDLE_CLICK(id, fn) wx__DECLARE_HEADER_EVT(MIDDLE_CLICK, id, fn) - -#define EVT_HEADER_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(DCLICK, id, fn) -#define EVT_HEADER_RIGHT_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(RIGHT_DCLICK, id, fn) -#define EVT_HEADER_MIDDLE_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(MIDDLE_DCLICK, id, fn) - -#define EVT_HEADER_SEPARATOR_DCLICK(id, fn) wx__DECLARE_HEADER_EVT(SEPARATOR_DCLICK, id, fn) - -#define EVT_HEADER_BEGIN_RESIZE(id, fn) wx__DECLARE_HEADER_EVT(BEGIN_RESIZE, id, fn) -#define EVT_HEADER_RESIZING(id, fn) wx__DECLARE_HEADER_EVT(RESIZING, id, fn) -#define EVT_HEADER_END_RESIZE(id, fn) wx__DECLARE_HEADER_EVT(END_RESIZE, id, fn) - -#define EVT_HEADER_BEGIN_REORDER(id, fn) wx__DECLARE_HEADER_EVT(BEGIN_REORDER, id, fn) -#define EVT_HEADER_END_REORDER(id, fn) wx__DECLARE_HEADER_EVT(END_REORDER, id, fn) - -#define EVT_HEADER_DRAGGING_CANCELLED(id, fn) wx__DECLARE_HEADER_EVT(DRAGGING_CANCELLED, id, fn) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_HEADER_CLICK wxEVT_HEADER_CLICK -#define wxEVT_COMMAND_HEADER_RIGHT_CLICK wxEVT_HEADER_RIGHT_CLICK -#define wxEVT_COMMAND_HEADER_MIDDLE_CLICK wxEVT_HEADER_MIDDLE_CLICK -#define wxEVT_COMMAND_HEADER_DCLICK wxEVT_HEADER_DCLICK -#define wxEVT_COMMAND_HEADER_RIGHT_DCLICK wxEVT_HEADER_RIGHT_DCLICK -#define wxEVT_COMMAND_HEADER_MIDDLE_DCLICK wxEVT_HEADER_MIDDLE_DCLICK -#define wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK wxEVT_HEADER_SEPARATOR_DCLICK -#define wxEVT_COMMAND_HEADER_BEGIN_RESIZE wxEVT_HEADER_BEGIN_RESIZE -#define wxEVT_COMMAND_HEADER_RESIZING wxEVT_HEADER_RESIZING -#define wxEVT_COMMAND_HEADER_END_RESIZE wxEVT_HEADER_END_RESIZE -#define wxEVT_COMMAND_HEADER_BEGIN_REORDER wxEVT_HEADER_BEGIN_REORDER -#define wxEVT_COMMAND_HEADER_END_REORDER wxEVT_HEADER_END_REORDER -#define wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED wxEVT_HEADER_DRAGGING_CANCELLED - -#endif // wxUSE_HEADERCTRL - -#endif // _WX_HEADERCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/help.h b/Source/3rd Party/wx/include/wx/help.h index 665c6b9ed..1cc09d42c 100644 --- a/Source/3rd Party/wx/include/wx/help.h +++ b/Source/3rd Party/wx/include/wx/help.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/help.h +// Name: help.h // Purpose: wxHelpController base header // Author: wxWidgets Team // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: help.h 33948 2005-05-04 18:57:50Z JS $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,6 +22,10 @@ #include "wx/msw/wince/helpwce.h" #define wxHelpController wxWinceHelpController +#elif defined(__WXPALMOS__) + #include "wx/palmos/help.h" + + #define wxHelpController wxPalmHelpController #elif defined(__WXMSW__) #include "wx/msw/helpchm.h" diff --git a/Source/3rd Party/wx/include/wx/helpbase.h b/Source/3rd Party/wx/include/wx/helpbase.h index 82e99f729..0ab778205 100644 --- a/Source/3rd Party/wx/include/wx/helpbase.h +++ b/Source/3rd Party/wx/include/wx/helpbase.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/helpbase.h +// Name: helpbase.h // Purpose: Help system base classes // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: helpbase.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,7 +32,7 @@ enum wxHelpSearchMode }; // Defines the API for help controllers -class WXDLLIMPEXP_CORE wxHelpControllerBase: public wxObject +class WXDLLEXPORT wxHelpControllerBase: public wxObject { public: inline wxHelpControllerBase(wxWindow* parentWindow = NULL) { m_parentWindow = parentWindow; } @@ -81,7 +82,7 @@ public: wxPoint *WXUNUSED(pos) = NULL, bool *WXUNUSED(newFrameEachTime) = NULL) { - return NULL; // does nothing by default + return (wxFrame*) NULL; // does nothing by default } virtual bool Quit() = 0; diff --git a/Source/3rd Party/wx/include/wx/helphtml.h b/Source/3rd Party/wx/include/wx/helphtml.h deleted file mode 100644 index 87bc81dfb..000000000 --- a/Source/3rd Party/wx/include/wx/helphtml.h +++ /dev/null @@ -1,19 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/helphtml.h -// Purpose: Includes wx/html/helpctrl.h, for wxHtmlHelpController. -// Author: Julian Smart -// Modified by: -// Created: 2003-05-24 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __WX_HELPHTML_H_ -#define __WX_HELPHTML_H_ - -#if wxUSE_WXHTML_HELP -#include "wx/html/helpctrl.h" -#endif - -#endif // __WX_HELPHTML_H_ - diff --git a/Source/3rd Party/wx/include/wx/helpwin.h b/Source/3rd Party/wx/include/wx/helpwin.h deleted file mode 100644 index b73a62eba..000000000 --- a/Source/3rd Party/wx/include/wx/helpwin.h +++ /dev/null @@ -1,21 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/helpwin.h -// Purpose: Includes Windows or OS/2 help -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HELPWIN_H_BASE_ -#define _WX_HELPWIN_H_BASE_ - -#if defined(__WXMSW__) -#include "wx/msw/helpwin.h" -#elif defined(__WXPM__) -#include "wx/os2/helpwin.h" -#endif - -#endif - // _WX_HELPWIN_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/htmllbox.h b/Source/3rd Party/wx/include/wx/htmllbox.h deleted file mode 100644 index 27c3a36c3..000000000 --- a/Source/3rd Party/wx/include/wx/htmllbox.h +++ /dev/null @@ -1,321 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/htmllbox.h -// Purpose: wxHtmlListBox is a listbox whose items are wxHtmlCells -// Author: Vadim Zeitlin -// Modified by: -// Created: 31.05.03 -// Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HTMLLBOX_H_ -#define _WX_HTMLLBOX_H_ - -#include "wx/vlbox.h" // base class -#include "wx/html/htmlwin.h" -#include "wx/ctrlsub.h" - -#if wxUSE_FILESYSTEM - #include "wx/filesys.h" -#endif // wxUSE_FILESYSTEM - -class WXDLLIMPEXP_FWD_HTML wxHtmlCell; -class WXDLLIMPEXP_FWD_HTML wxHtmlWinParser; -class WXDLLIMPEXP_FWD_HTML wxHtmlListBoxCache; -class WXDLLIMPEXP_FWD_HTML wxHtmlListBoxStyle; - -extern WXDLLIMPEXP_DATA_HTML(const char) wxHtmlListBoxNameStr[]; -extern WXDLLIMPEXP_DATA_HTML(const char) wxSimpleHtmlListBoxNameStr[]; - -// ---------------------------------------------------------------------------- -// wxHtmlListBox -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_HTML wxHtmlListBox : public wxVListBox, - public wxHtmlWindowInterface, - public wxHtmlWindowMouseHelper -{ - DECLARE_ABSTRACT_CLASS(wxHtmlListBox) -public: - // constructors and such - // --------------------- - - // default constructor, you must call Create() later - wxHtmlListBox(); - - // normal constructor which calls Create() internally - wxHtmlListBox(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxHtmlListBoxNameStr); - - // really creates the control and sets the initial number of items in it - // (which may be changed later with SetItemCount()) - // - // the only special style which may be specified here is wxLB_MULTIPLE - // - // returns true on success or false if the control couldn't be created - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxHtmlListBoxNameStr); - - // destructor cleans up whatever resources we use - virtual ~wxHtmlListBox(); - - // override some base class virtuals - virtual void RefreshRow(size_t line); - virtual void RefreshRows(size_t from, size_t to); - virtual void RefreshAll(); - virtual void SetItemCount(size_t count); - -#if wxUSE_FILESYSTEM - // retrieve the file system used by the wxHtmlWinParser: if you use - // relative paths in your HTML, you should use its ChangePathTo() method - wxFileSystem& GetFileSystem() { return m_filesystem; } - const wxFileSystem& GetFileSystem() const { return m_filesystem; } -#endif // wxUSE_FILESYSTEM - - virtual void OnInternalIdle(); - -protected: - // this method must be implemented in the derived class and should return - // the body (i.e. without ) of the HTML for the given item - virtual wxString OnGetItem(size_t n) const = 0; - - // this function may be overridden to decorate HTML returned by OnGetItem() - virtual wxString OnGetItemMarkup(size_t n) const; - - - // this method allows to customize the selection appearance: it may be used - // to specify the colour of the text which normally has the given colour - // colFg when it is inside the selection - // - // by default, the original colour is not used at all and all text has the - // same (default for this system) colour inside selection - virtual wxColour GetSelectedTextColour(const wxColour& colFg) const; - - // this is the same as GetSelectedTextColour() but allows to customize the - // background colour -- this is even more rarely used as you can change it - // globally using SetSelectionBackground() - virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const; - - - // we implement both of these functions in terms of OnGetItem(), they are - // not supposed to be overridden by our descendants - virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const; - virtual wxCoord OnMeasureItem(size_t n) const; - - // override this one to draw custom background for selected items correctly - virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; - - // this method may be overridden to handle clicking on a link in the - // listbox (by default, clicks on links are simply ignored) - virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link); - - // event handlers - void OnSize(wxSizeEvent& event); - void OnMouseMove(wxMouseEvent& event); - void OnLeftDown(wxMouseEvent& event); - - - // common part of all ctors - void Init(); - - // ensure that the given item is cached - void CacheItem(size_t n) const; - -private: - // wxHtmlWindowInterface methods: - virtual void SetHTMLWindowTitle(const wxString& title); - virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link); - virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type, - const wxString& url, - wxString *redirect) const; - virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell, - const wxPoint& pos) const; - virtual wxWindow* GetHTMLWindow(); - virtual wxColour GetHTMLBackgroundColour() const; - virtual void SetHTMLBackgroundColour(const wxColour& clr); - virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg); - virtual void SetHTMLStatusText(const wxString& text); - virtual wxCursor GetHTMLCursor(HTMLCursor type) const; - - // returns index of item that contains given HTML cell - size_t GetItemForCell(const wxHtmlCell *cell) const; - - // return physical coordinates of root wxHtmlCell of n-th item - wxPoint GetRootCellCoords(size_t n) const; - - // Converts physical coordinates stored in @a pos into coordinates - // relative to the root cell of the item under mouse cursor, if any. If no - // cell is found under the cursor, returns false. Otherwise stores the new - // coordinates back into @a pos and pointer to the cell under cursor into - // @a cell and returns true. - bool PhysicalCoordsToCell(wxPoint& pos, wxHtmlCell*& cell) const; - - // The opposite of PhysicalCoordsToCell: converts coordinates relative to - // given cell to physical coordinates in the window - wxPoint CellCoordsToPhysical(const wxPoint& pos, wxHtmlCell *cell) const; - -private: - // this class caches the pre-parsed HTML to speed up display - wxHtmlListBoxCache *m_cache; - - // HTML parser we use - wxHtmlWinParser *m_htmlParser; - -#if wxUSE_FILESYSTEM - // file system used by m_htmlParser - wxFileSystem m_filesystem; -#endif // wxUSE_FILESYSTEM - - // rendering style for the parser which allows us to customize our colours - wxHtmlListBoxStyle *m_htmlRendStyle; - - - // it calls our GetSelectedTextColour() and GetSelectedTextBgColour() - friend class wxHtmlListBoxStyle; - friend class wxHtmlListBoxWinInterface; - - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxHtmlListBox); -}; - - -// ---------------------------------------------------------------------------- -// wxSimpleHtmlListBox -// ---------------------------------------------------------------------------- - -#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN -#define wxHLB_MULTIPLE wxLB_MULTIPLE - -class WXDLLIMPEXP_HTML wxSimpleHtmlListBox : - public wxWindowWithItems -{ - DECLARE_ABSTRACT_CLASS(wxSimpleHtmlListBox) -public: - // wxListbox-compatible constructors - // --------------------------------- - - wxSimpleHtmlListBox() { } - - wxSimpleHtmlListBox(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = wxHLB_DEFAULT_STYLE, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSimpleHtmlListBoxNameStr) - { - Create(parent, id, pos, size, n, choices, style, validator, name); - } - - wxSimpleHtmlListBox(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = wxHLB_DEFAULT_STYLE, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSimpleHtmlListBoxNameStr) - { - Create(parent, id, pos, size, choices, style, validator, name); - } - - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = wxHLB_DEFAULT_STYLE, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSimpleHtmlListBoxNameStr); - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = wxHLB_DEFAULT_STYLE, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSimpleHtmlListBoxNameStr); - - virtual ~wxSimpleHtmlListBox(); - - // these must be overloaded otherwise the compiler will complain - // about wxItemContainerImmutable::[G|S]etSelection being pure virtuals... - void SetSelection(int n) - { wxVListBox::SetSelection(n); } - int GetSelection() const - { return wxVListBox::GetSelection(); } - - - // accessing strings - // ----------------- - - virtual unsigned int GetCount() const - { return m_items.GetCount(); } - - virtual wxString GetString(unsigned int n) const; - - // override default unoptimized wxItemContainer::GetStrings() function - wxArrayString GetStrings() const - { return m_items; } - - virtual void SetString(unsigned int n, const wxString& s); - - // resolve ambiguity between wxItemContainer and wxVListBox versions - void Clear(); - -protected: - virtual int DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type); - - virtual void DoSetItemClientData(unsigned int n, void *clientData) - { m_HTMLclientData[n] = clientData; } - - virtual void *DoGetItemClientData(unsigned int n) const - { return m_HTMLclientData[n]; } - - // wxItemContainer methods - virtual void DoClear(); - virtual void DoDeleteOneItem(unsigned int n); - - // calls wxHtmlListBox::SetItemCount() and RefreshAll() - void UpdateCount(); - - // override these functions just to change their visibility: users of - // wxSimpleHtmlListBox shouldn't be allowed to call them directly! - virtual void SetItemCount(size_t count) - { wxHtmlListBox::SetItemCount(count); } - virtual void SetRowCount(size_t count) - { wxHtmlListBox::SetRowCount(count); } - - virtual wxString OnGetItem(size_t n) const - { return m_items[n]; } - - virtual void InitEvent(wxCommandEvent& event, int n) - { - // we're not a virtual control and we can include the string - // of the item which was clicked: - event.SetString(m_items[n]); - wxVListBox::InitEvent(event, n); - } - - wxArrayString m_items; - wxArrayPtrVoid m_HTMLclientData; - - // Note: For the benefit of old compilers (like gcc-2.8) this should - // not be named m_clientdata as that clashes with the name of an - // anonymous struct member in wxEvtHandler, which we derive from. - - wxDECLARE_NO_COPY_CLASS(wxSimpleHtmlListBox); -}; - -#endif // _WX_HTMLLBOX_H_ - diff --git a/Source/3rd Party/wx/include/wx/hyperlink.h b/Source/3rd Party/wx/include/wx/hyperlink.h deleted file mode 100644 index db183d5a2..000000000 --- a/Source/3rd Party/wx/include/wx/hyperlink.h +++ /dev/null @@ -1,173 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/hyperlink.h -// Purpose: Hyperlink control -// Author: David Norris , Otto Wyss -// Modified by: Ryan Norton, Francesco Montorsi -// Created: 04/02/2005 -// Copyright: (c) 2005 David Norris -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HYPERLINK_H_ -#define _WX_HYPERLINK_H_ - -#include "wx/defs.h" - -#if wxUSE_HYPERLINKCTRL - -#include "wx/control.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -#define wxHL_CONTEXTMENU 0x0001 -#define wxHL_ALIGN_LEFT 0x0002 -#define wxHL_ALIGN_RIGHT 0x0004 -#define wxHL_ALIGN_CENTRE 0x0008 -#define wxHL_DEFAULT_STYLE (wxHL_CONTEXTMENU|wxNO_BORDER|wxHL_ALIGN_CENTRE) - -extern WXDLLIMPEXP_DATA_ADV(const char) wxHyperlinkCtrlNameStr[]; - - -// ---------------------------------------------------------------------------- -// wxHyperlinkCtrl -// ---------------------------------------------------------------------------- - -// A static text control that emulates a hyperlink. The link is displayed -// in an appropriate text style, derived from the control's normal font. -// When the mouse rolls over the link, the cursor changes to a hand and the -// link's color changes to the active color. -// -// Clicking on the link does not launch a web browser; instead, a -// HyperlinkEvent is fired. The event propagates upward until it is caught, -// just like a wxCommandEvent. -// -// Use the EVT_HYPERLINK() to catch link events. -class WXDLLIMPEXP_ADV wxHyperlinkCtrlBase : public wxControl -{ -public: - - // get/set - virtual wxColour GetHoverColour() const = 0; - virtual void SetHoverColour(const wxColour &colour) = 0; - - virtual wxColour GetNormalColour() const = 0; - virtual void SetNormalColour(const wxColour &colour) = 0; - - virtual wxColour GetVisitedColour() const = 0; - virtual void SetVisitedColour(const wxColour &colour) = 0; - - virtual wxString GetURL() const = 0; - virtual void SetURL (const wxString &url) = 0; - - virtual void SetVisited(bool visited = true) = 0; - virtual bool GetVisited() const = 0; - - // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour, - // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important ! - - virtual bool HasTransparentBackground() { return true; } - -protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - // checks for validity some of the ctor/Create() function parameters - void CheckParams(const wxString& label, const wxString& url, long style); - -public: - // not part of the public API but needs to be public as used by - // GTK+ callbacks: - void SendEvent(); -}; - -// ---------------------------------------------------------------------------- -// wxHyperlinkEvent -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_ADV wxHyperlinkEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_HYPERLINK, wxHyperlinkEvent ); - -// -// An event fired when the user clicks on the label in a hyperlink control. -// See HyperlinkControl for details. -// -class WXDLLIMPEXP_ADV wxHyperlinkEvent : public wxCommandEvent -{ -public: - wxHyperlinkEvent() {} - wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url) - : wxCommandEvent(wxEVT_HYPERLINK, id), - m_url(url) - { - SetEventObject(generator); - } - - // Returns the URL associated with the hyperlink control - // that the user clicked on. - wxString GetURL() const { return m_url; } - void SetURL(const wxString &url) { m_url=url; } - - // default copy ctor, assignment operator and dtor are ok - virtual wxEvent *Clone() const { return new wxHyperlinkEvent(*this); } - -private: - - // URL associated with the hyperlink control that the used clicked on. - wxString m_url; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHyperlinkEvent) -}; - - -// ---------------------------------------------------------------------------- -// event types and macros -// ---------------------------------------------------------------------------- - -typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&); - -#define wxHyperlinkEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxHyperlinkEventFunction, func) - -#define EVT_HYPERLINK(id, fn) \ - wx__DECLARE_EVT1(wxEVT_HYPERLINK, id, wxHyperlinkEventHandler(fn)) - - -#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__) - #include "wx/gtk/hyperlink.h" -// Note that the native control is only available in Unicode version under MSW. -#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__) - #include "wx/msw/hyperlink.h" -#else - #include "wx/generic/hyperlink.h" - - class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxGenericHyperlinkCtrl - { - public: - wxHyperlinkCtrl() { } - - wxHyperlinkCtrl(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxString& url, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHL_DEFAULT_STYLE, - const wxString& name = wxHyperlinkCtrlNameStr) - : wxGenericHyperlinkCtrl(parent, id, label, url, pos, size, - style, name) - { - } - - private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxHyperlinkCtrl ); - }; -#endif - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_HYPERLINK wxEVT_HYPERLINK - -#endif // wxUSE_HYPERLINKCTRL - -#endif // _WX_HYPERLINK_H_ diff --git a/Source/3rd Party/wx/include/wx/icon.h b/Source/3rd Party/wx/include/wx/icon.h index 5f3676423..8a73884ca 100644 --- a/Source/3rd Party/wx/include/wx/icon.h +++ b/Source/3rd Party/wx/include/wx/icon.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: icon.h 41538 2006-09-30 20:45:15Z RR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,50 +14,28 @@ #include "wx/iconloc.h" - -// a more readable way to tell -#define wxICON_SCREEN_DEPTH (-1) - - -// the wxICON_DEFAULT_TYPE (the wxIcon equivalent of wxBITMAP_DEFAULT_TYPE) -// constant defines the default argument value for wxIcon ctor and wxIcon::LoadFile() -// functions. - -#if defined(__WXMSW__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_ICO_RESOURCE +#if defined(__WXPALMOS__) + #include "wx/generic/icon.h" +#elif defined(__WXMSW__) #include "wx/msw/icon.h" #elif defined(__WXMOTIF__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/motif/icon.h" #elif defined(__WXGTK20__) - #ifdef __WINDOWS__ - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_ICO_RESOURCE - #else - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_XPM - #endif #include "wx/generic/icon.h" #elif defined(__WXGTK__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/generic/icon.h" #elif defined(__WXX11__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_XPM + #include "wx/generic/icon.h" +#elif defined(__WXMGL__) + #define wxICON_DEFAULT_BITMAP_TYPE wxBITMAP_TYPE_ICO_RESOURCE #include "wx/generic/icon.h" #elif defined(__WXDFB__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_XPM #include "wx/generic/icon.h" #elif defined(__WXMAC__) -#if wxOSX_USE_COCOA_OR_CARBON - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_ICON_RESOURCE - #include "wx/osx/icon.h" -#else - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_PNG_RESOURCE - #include "wx/generic/icon.h" -#endif + #include "wx/mac/icon.h" #elif defined(__WXCOCOA__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_ICON_RESOURCE #include "wx/cocoa/icon.h" #elif defined(__WXPM__) - #define wxICON_DEFAULT_TYPE wxBITMAP_TYPE_ICO_RESOURCE #include "wx/os2/icon.h" #endif @@ -66,7 +45,7 @@ #if wxUSE_VARIANT #include "wx/variant.h" -DECLARE_VARIANT_OBJECT_EXPORTED(wxIcon,WXDLLIMPEXP_CORE) +DECLARE_VARIANT_OBJECT_EXPORTED(wxIcon,WXDLLEXPORT) #endif diff --git a/Source/3rd Party/wx/include/wx/iconbndl.h b/Source/3rd Party/wx/include/wx/iconbndl.h index b12234cdb..ced8dbba6 100644 --- a/Source/3rd Party/wx/include/wx/iconbndl.h +++ b/Source/3rd Party/wx/include/wx/iconbndl.h @@ -4,6 +4,7 @@ // Author: Mattia barbon // Modified by: // Created: 23.03.02 +// RCS-ID: $Id: iconbndl.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Mattia Barbon // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,122 +12,58 @@ #ifndef _WX_ICONBNDL_H_ #define _WX_ICONBNDL_H_ -#include "wx/gdiobj.h" -#include "wx/gdicmn.h" // for wxSize -#include "wx/icon.h" - #include "wx/dynarray.h" +// for wxSize +#include "wx/gdicmn.h" -class WXDLLIMPEXP_FWD_BASE wxInputStream; +class WXDLLIMPEXP_FWD_CORE wxIcon; +class WXDLLIMPEXP_FWD_BASE wxString; -WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray); +WX_DECLARE_EXPORTED_OBJARRAY( wxIcon, wxIconArray ); // this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE, // if you need them, you have to load them manually and call // wxIconCollection::AddIcon -class WXDLLIMPEXP_CORE wxIconBundle : public wxGDIObject +class WXDLLEXPORT wxIconBundle { public: - // Flags that determine what happens if GetIcon() doesn't find the icon of - // exactly the requested size. - enum - { - // Return invalid icon if exact size is not found. - FALLBACK_NONE = 0, - - // Return the icon of the system icon size if exact size is not found. - // May be combined with other non-NONE enum elements to determine what - // happens if the system icon size is not found neither. - FALLBACK_SYSTEM = 1, - - // Return the icon of closest larger size or, if there is no icon of - // larger size in the bundle, the closest icon of smaller size. - FALLBACK_NEAREST_LARGER = 2 - }; - // default constructor - wxIconBundle(); - + wxIconBundle() : m_icons() {} // initializes the bundle with the icon(s) found in the file -#if wxUSE_STREAMS && wxUSE_IMAGE -#if wxUSE_FFILE || wxUSE_FILE - wxIconBundle(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY); -#endif // wxUSE_FFILE || wxUSE_FILE - wxIconBundle(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY); -#endif // wxUSE_STREAMS && wxUSE_IMAGE - + wxIconBundle( const wxString& file, long type ) : m_icons() + { AddIcon( file, type ); } // initializes the bundle with a single icon - wxIconBundle(const wxIcon& icon); + wxIconBundle( const wxIcon& icon ) : m_icons() + { AddIcon( icon ); } - // default copy ctor and assignment operator are OK + const wxIconBundle& operator =( const wxIconBundle& ic ); + wxIconBundle( const wxIconBundle& ic ) : m_icons() + { *this = ic; } + + ~wxIconBundle() { DeleteIcons(); } // adds all the icons contained in the file to the collection, // if the collection already contains icons with the same // width and height, they are replaced -#if wxUSE_STREAMS && wxUSE_IMAGE -#if wxUSE_FFILE || wxUSE_FILE - void AddIcon(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY); -#endif // wxUSE_FFILE || wxUSE_FILE - void AddIcon(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY); -#endif // wxUSE_STREAMS && wxUSE_IMAGE - + void AddIcon( const wxString& file, long type ); // adds the icon to the collection, if the collection already // contains an icon with the same width and height, it is // replaced - void AddIcon(const wxIcon& icon); + void AddIcon( const wxIcon& icon ); // returns the icon with the given size; if no such icon exists, - // behavior is specified by the flags. - wxIcon GetIcon(const wxSize& size, int flags = FALLBACK_SYSTEM) const; - - // equivalent to GetIcon(wxSize(size, size)) - wxIcon GetIcon(wxCoord size = wxDefaultCoord, - int flags = FALLBACK_SYSTEM) const - { return GetIcon(wxSize(size, size), flags); } - - // returns the icon exactly of the specified size or wxNullIcon if no icon - // of exactly given size are available - wxIcon GetIconOfExactSize(const wxSize& size) const; - wxIcon GetIconOfExactSize(wxCoord size) const - { return GetIconOfExactSize(wxSize(size, size)); } - - // enumerate all icons in the bundle: don't use these functions if ti can - // be avoided, using GetIcon() directly is better - - // return the number of available icons - size_t GetIconCount() const; - - // return the icon at index (must be < GetIconCount()) - wxIcon GetIconByIndex(size_t n) const; - - // check if we have any icons at all - bool IsEmpty() const { return GetIconCount() == 0; } - -#if WXWIN_COMPATIBILITY_2_8 -#if wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE) - wxDEPRECATED( void AddIcon(const wxString& file, long type) - { - AddIcon(file, (wxBitmapType)type); - } - ) - - wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString& file, long type) - { - AddIcon(file, (wxBitmapType)type); - } - ) -#endif // wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE) -#endif // WXWIN_COMPATIBILITY_2_8 - -protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - + // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists, + // returns the first icon in the bundle + const wxIcon& GetIcon( const wxSize& size ) const; + // equivalent to GetIcon( wxSize( size, size ) ) + const wxIcon& GetIcon( wxCoord size = wxDefaultCoord ) const + { return GetIcon( wxSize( size, size ) ); } private: // delete all icons void DeleteIcons(); - - DECLARE_DYNAMIC_CLASS(wxIconBundle) +public: + wxIconArray m_icons; }; -#endif // _WX_ICONBNDL_H_ +#endif + // _WX_ICONBNDL_H_ diff --git a/Source/3rd Party/wx/include/wx/iconloc.h b/Source/3rd Party/wx/include/wx/iconloc.h index cc17f6811..e89d45d4e 100644 --- a/Source/3rd Party/wx/include/wx/iconloc.h +++ b/Source/3rd Party/wx/include/wx/iconloc.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 21.06.2003 +// RCS-ID: $Id: iconloc.h 27408 2004-05-23 20:53:33Z JS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -38,9 +39,9 @@ private: wxString m_filename; }; -// under Windows the same file may contain several icons so we also store the +// under MSW the same file may contain several icons so we also store the // index of the icon -#if defined(__WINDOWS__) +#if defined(__WXMSW__) class WXDLLIMPEXP_BASE wxIconLocation : public wxIconLocationBase { @@ -64,7 +65,7 @@ wxIconLocation::wxIconLocation(const wxString& file, int num) SetIndex(num); } -#else // !__WINDOWS__ +#else // !MSW // must be a class because we forward declare it as class class WXDLLIMPEXP_BASE wxIconLocation : public wxIconLocationBase diff --git a/Source/3rd Party/wx/include/wx/imagbmp.h b/Source/3rd Party/wx/include/wx/imagbmp.h index 231753079..e32fc509b 100644 --- a/Source/3rd Party/wx/include/wx/imagbmp.h +++ b/Source/3rd Party/wx/include/wx/imagbmp.h @@ -2,6 +2,7 @@ // Name: wx/imagbmp.h // Purpose: wxImage BMP, ICO, CUR and ANI handlers // Author: Robert Roebling, Chris Elliott +// RCS-ID: $Id: imagbmp.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Robert Roebling, Chris Elliott // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -20,6 +21,13 @@ #define wxIMAGE_OPTION_CUR_HOTSPOT_X wxT("HotSpotX") #define wxIMAGE_OPTION_CUR_HOTSPOT_Y wxT("HotSpotY") +#if WXWIN_COMPATIBILITY_2_4 + // Do not use these macros, they are deprecated + #define wxBMP_FORMAT wxIMAGE_OPTION_BMP_FORMAT + #define wxCUR_HOTSPOT_X wxIMAGE_OPTION_CUR_HOTSPOT_X + #define wxCUR_HOTSPOT_Y wxIMAGE_OPTION_CUR_HOTSPOT_Y +#endif + enum { @@ -39,7 +47,7 @@ enum // wxBMPHandler // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBMPHandler : public wxImageHandler +class WXDLLEXPORT wxBMPHandler : public wxImageHandler { public: wxBMPHandler() @@ -73,7 +81,7 @@ private: // wxICOHandler // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxICOHandler : public wxBMPHandler +class WXDLLEXPORT wxICOHandler : public wxBMPHandler { public: wxICOHandler() @@ -88,9 +96,8 @@ public: virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); virtual bool DoLoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index ); - + virtual int GetImageCount( wxInputStream& stream ); protected: - virtual int DoGetImageCount( wxInputStream& stream ); virtual bool DoCanRead( wxInputStream& stream ); #endif // wxUSE_STREAMS @@ -103,7 +110,7 @@ private: // wxCURHandler // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxCURHandler : public wxICOHandler +class WXDLLEXPORT wxCURHandler : public wxICOHandler { public: wxCURHandler() @@ -130,7 +137,7 @@ private: // wxANIHandler // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxANIHandler : public wxCURHandler +class WXDLLEXPORT wxANIHandler : public wxCURHandler { public: wxANIHandler() @@ -145,9 +152,8 @@ public: #if wxUSE_STREAMS virtual bool SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose=true) ){return false ;} virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); - + virtual int GetImageCount( wxInputStream& stream ); protected: - virtual int DoGetImageCount( wxInputStream& stream ); virtual bool DoCanRead( wxInputStream& stream ); #endif // wxUSE_STREAMS diff --git a/Source/3rd Party/wx/include/wx/image.h b/Source/3rd Party/wx/include/wx/image.h index 9739c53db..8dc2d8500 100644 --- a/Source/3rd Party/wx/include/wx/image.h +++ b/Source/3rd Party/wx/include/wx/image.h @@ -2,6 +2,7 @@ // Name: wx/image.h // Purpose: wxImage class // Author: Robert Roebling +// RCS-ID: $Id: image.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,6 @@ #include "wx/string.h" #include "wx/gdicmn.h" #include "wx/hashmap.h" -#include "wx/arrstr.h" #if wxUSE_STREAMS # include "wx/stream.h" @@ -27,50 +27,27 @@ // which breaks the compilation below #undef index -#define wxIMAGE_OPTION_QUALITY wxString(wxS("quality")) -#define wxIMAGE_OPTION_FILENAME wxString(wxS("FileName")) +#define wxIMAGE_OPTION_QUALITY wxString(wxT("quality")) +#define wxIMAGE_OPTION_FILENAME wxString(wxT("FileName")) -#define wxIMAGE_OPTION_RESOLUTION wxString(wxS("Resolution")) -#define wxIMAGE_OPTION_RESOLUTIONX wxString(wxS("ResolutionX")) -#define wxIMAGE_OPTION_RESOLUTIONY wxString(wxS("ResolutionY")) +#define wxIMAGE_OPTION_RESOLUTION wxString(wxT("Resolution")) +#define wxIMAGE_OPTION_RESOLUTIONX wxString(wxT("ResolutionX")) +#define wxIMAGE_OPTION_RESOLUTIONY wxString(wxT("ResolutionY")) -#define wxIMAGE_OPTION_RESOLUTIONUNIT wxString(wxS("ResolutionUnit")) - -#define wxIMAGE_OPTION_MAX_WIDTH wxString(wxS("MaxWidth")) -#define wxIMAGE_OPTION_MAX_HEIGHT wxString(wxS("MaxHeight")) - -#define wxIMAGE_OPTION_ORIGINAL_WIDTH wxString(wxS("OriginalWidth")) -#define wxIMAGE_OPTION_ORIGINAL_HEIGHT wxString(wxS("OriginalHeight")) +#define wxIMAGE_OPTION_RESOLUTIONUNIT wxString(wxT("ResolutionUnit")) // constants used with wxIMAGE_OPTION_RESOLUTIONUNIT -// -// NB: don't change these values, they correspond to libjpeg constants -enum wxImageResolution +enum { - // Resolution not specified - wxIMAGE_RESOLUTION_NONE = 0, - - // Resolution specified in inches wxIMAGE_RESOLUTION_INCHES = 1, - - // Resolution specified in centimeters wxIMAGE_RESOLUTION_CM = 2 }; // Constants for wxImage::Scale() for determining the level of quality -enum wxImageResizeQuality +enum { - // different image resizing algorithms used by Scale() and Rescale() - wxIMAGE_QUALITY_NEAREST = 0, - wxIMAGE_QUALITY_BILINEAR = 1, - wxIMAGE_QUALITY_BICUBIC = 2, - wxIMAGE_QUALITY_BOX_AVERAGE = 3, - - // default quality is low (but fast) - wxIMAGE_QUALITY_NORMAL = wxIMAGE_QUALITY_NEAREST, - - // highest (but best) quality - wxIMAGE_QUALITY_HIGH = 4 + wxIMAGE_QUALITY_NORMAL = 0, + wxIMAGE_QUALITY_HIGH = 1 }; // alpha channel values: fully transparent, default threshold separating @@ -94,32 +71,25 @@ class WXDLLIMPEXP_FWD_CORE wxPalette; #if wxUSE_VARIANT #include "wx/variant.h" -DECLARE_VARIANT_OBJECT_EXPORTED(wxImage,WXDLLIMPEXP_CORE) +DECLARE_VARIANT_OBJECT_EXPORTED(wxImage,WXDLLEXPORT) #endif //----------------------------------------------------------------------------- // wxImageHandler //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxImageHandler: public wxObject +class WXDLLEXPORT wxImageHandler: public wxObject { public: wxImageHandler() - : m_name(wxEmptyString), m_extension(wxEmptyString), m_mime(), m_type(wxBITMAP_TYPE_INVALID) + : m_name(wxEmptyString), m_extension(wxEmptyString), m_mime(), m_type(0) { } #if wxUSE_STREAMS - // NOTE: LoadFile and SaveFile are not pure virtuals to allow derived classes - // to implement only one of the two - virtual bool LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), - bool WXUNUSED(verbose)=true, int WXUNUSED(index)=-1 ) - { return false; } - virtual bool SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), - bool WXUNUSED(verbose)=true ) - { return false; } + virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); + virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); - int GetImageCount( wxInputStream& stream ); - // save the stream position, call DoGetImageCount() and restore the position + virtual int GetImageCount( wxInputStream& stream ); bool CanRead( wxInputStream& stream ) { return CallDoCanRead(stream); } bool CanRead( const wxString& name ); @@ -127,48 +97,25 @@ public: void SetName(const wxString& name) { m_name = name; } void SetExtension(const wxString& ext) { m_extension = ext; } - void SetAltExtensions(const wxArrayString& exts) { m_altExtensions = exts; } - void SetType(wxBitmapType type) { m_type = type; } + void SetType(long type) { m_type = type; } void SetMimeType(const wxString& type) { m_mime = type; } const wxString& GetName() const { return m_name; } const wxString& GetExtension() const { return m_extension; } - const wxArrayString& GetAltExtensions() const { return m_altExtensions; } - wxBitmapType GetType() const { return m_type; } + long GetType() const { return m_type; } const wxString& GetMimeType() const { return m_mime; } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( - void SetType(long type) { SetType((wxBitmapType)type); } - ) -#endif // WXWIN_COMPATIBILITY_2_8 - protected: #if wxUSE_STREAMS - // NOTE: this function is allowed to change the current stream position - // since GetImageCount() will take care of restoring it later - virtual int DoGetImageCount( wxInputStream& WXUNUSED(stream) ) - { return 1; } // default return value is 1 image - - // NOTE: this function is allowed to change the current stream position - // since CallDoCanRead() will take care of restoring it later virtual bool DoCanRead( wxInputStream& stream ) = 0; // save the stream position, call DoCanRead() and restore the position bool CallDoCanRead(wxInputStream& stream); #endif // wxUSE_STREAMS - // helper for the derived classes SaveFile() implementations: returns the - // values of x- and y-resolution options specified as the image options if - // any - static wxImageResolution - GetResolutionFromOptions(const wxImage& image, int *x, int *y); - - wxString m_name; wxString m_extension; - wxArrayString m_altExtensions; wxString m_mime; - wxBitmapType m_type; + long m_type; private: DECLARE_CLASS(wxImageHandler) @@ -178,7 +125,7 @@ private: // wxImageHistogram //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxImageHistogramEntry +class WXDLLEXPORT wxImageHistogramEntry { public: wxImageHistogramEntry() { index = value = 0; } @@ -190,7 +137,7 @@ WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry, wxIntegerHash, wxIntegerEqual, wxImageHistogramBase); -class WXDLLIMPEXP_CORE wxImageHistogram : public wxImageHistogramBase +class WXDLLEXPORT wxImageHistogram : public wxImageHistogramBase { public: wxImageHistogram() : wxImageHistogramBase(256) { } @@ -220,7 +167,7 @@ public: // wxImage //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxImage: public wxObject +class WXDLLEXPORT wxImage: public wxObject { public: // red, green and blue are 8 bit unsigned integers in the range of 0..255 @@ -246,60 +193,30 @@ public: double value; }; - wxImage() {} - wxImage( int width, int height, bool clear = true ) - { Create( width, height, clear ); } - wxImage( int width, int height, unsigned char* data, bool static_data = false ) - { Create( width, height, data, static_data ); } - wxImage( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false ) - { Create( width, height, data, alpha, static_data ); } - - // ctor variants using wxSize: - wxImage( const wxSize& sz, bool clear = true ) - { Create( sz, clear ); } - wxImage( const wxSize& sz, unsigned char* data, bool static_data = false ) - { Create( sz, data, static_data ); } - wxImage( const wxSize& sz, unsigned char* data, unsigned char* alpha, bool static_data = false ) - { Create( sz, data, alpha, static_data ); } - - wxImage( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 ) - { LoadFile( name, type, index ); } - wxImage( const wxString& name, const wxString& mimetype, int index = -1 ) - { LoadFile( name, mimetype, index ); } - wxImage( const char* const* xpmData ) - { Create(xpmData); } + wxImage(){} + wxImage( int width, int height, bool clear = true ); + wxImage( int width, int height, unsigned char* data, bool static_data = false ); + wxImage( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false ); + wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); + wxImage( const wxString& name, const wxString& mimetype, int index = -1 ); + wxImage( const char* const* xpmData ); #if wxUSE_STREAMS - wxImage( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 ) - { LoadFile( stream, type, index ); } - wxImage( wxInputStream& stream, const wxString& mimetype, int index = -1 ) - { LoadFile( stream, mimetype, index ); } + wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ); + wxImage( wxInputStream& stream, const wxString& mimetype, int index = -1 ); #endif // wxUSE_STREAMS - bool Create( const char* const* xpmData ); -#ifdef __BORLANDC__ - // needed for Borland 5.5 - wxImage( char** xpmData ) { Create(const_cast(xpmData)); } - bool Create( char** xpmData ) { return Create(const_cast(xpmData)); } -#endif - bool Create( int width, int height, bool clear = true ); bool Create( int width, int height, unsigned char* data, bool static_data = false ); bool Create( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false ); - - // Create() variants using wxSize: - bool Create( const wxSize& sz, bool clear = true ) - { return Create(sz.GetWidth(), sz.GetHeight(), clear); } - bool Create( const wxSize& sz, unsigned char* data, bool static_data = false ) - { return Create(sz.GetWidth(), sz.GetHeight(), data, static_data); } - bool Create( const wxSize& sz, unsigned char* data, unsigned char* alpha, bool static_data = false ) - { return Create(sz.GetWidth(), sz.GetHeight(), data, alpha, static_data); } - + bool Create( const char* const* xpmData ); +#ifdef __BORLANDC__ + // needed for Borland 5.5 + wxImage( char** xpmData ) { Create(wx_const_cast(const char* const*, xpmData)); } + bool Create( char** xpmData ) { return Create(wx_const_cast(const char* const*, xpmData)); } +#endif void Destroy(); - // initialize the image data with zeroes - void Clear(unsigned char value = 0); - // creates an identical copy of the image (the = operator // just raises the ref count) wxImage Copy() const; @@ -319,26 +236,21 @@ public: void Paste( const wxImage &image, int x, int y ); // return the new image with size width*height - wxImage Scale( int width, int height, - wxImageResizeQuality quality = wxIMAGE_QUALITY_NORMAL ) const; + wxImage Scale( int width, int height, int quality = wxIMAGE_QUALITY_NORMAL ) const; // box averager and bicubic filters for up/down sampling - wxImage ResampleNearest(int width, int height) const; wxImage ResampleBox(int width, int height) const; - wxImage ResampleBilinear(int width, int height) const; wxImage ResampleBicubic(int width, int height) const; // blur the image according to the specified pixel radius - wxImage Blur(int radius) const; - wxImage BlurHorizontal(int radius) const; - wxImage BlurVertical(int radius) const; + wxImage Blur(int radius); + wxImage BlurHorizontal(int radius); + wxImage BlurVertical(int radius); wxImage ShrinkBy( int xFactor , int yFactor ) const ; // rescales the image in place - wxImage& Rescale( int width, int height, - wxImageResizeQuality quality = wxIMAGE_QUALITY_NORMAL ) - { return *this = Scale(width, height, quality); } + wxImage& Rescale( int width, int height, int quality = wxIMAGE_QUALITY_NORMAL ) { return *this = Scale(width, height, quality); } // resizes the image in place wxImage& Resize( const wxSize& size, const wxPoint& pos, @@ -347,10 +259,9 @@ public: // Rotates the image about the given point, 'angle' radians. // Returns the rotated image, leaving this image intact. wxImage Rotate(double angle, const wxPoint & centre_of_rotation, - bool interpolating = true, wxPoint * offset_after_rotation = NULL) const; + bool interpolating = true, wxPoint * offset_after_rotation = (wxPoint*) NULL) const; wxImage Rotate90( bool clockwise = true ) const; - wxImage Rotate180() const; wxImage Mirror( bool horizontally = true ) const; // replace one colour with another @@ -358,17 +269,13 @@ public: unsigned char r2, unsigned char g2, unsigned char b2 ); // Convert to greyscale image. Uses the luminance component (Y) of the image. - // The luma value (YUV) is calculated using (R * weight_r) + (G * weight_g) + (B * weight_b), defaults to ITU-T BT.601 - wxImage ConvertToGreyscale(double weight_r, double weight_g, double weight_b) const; - wxImage ConvertToGreyscale(void) const; + // The luma value (YUV) is calculated using (R * lr) + (G * lg) + (B * lb), defaults to ITU-T BT.601 + wxImage ConvertToGreyscale( double lr = 0.299, double lg = 0.587, double lb = 0.114 ) const; // convert to monochrome image ( will be replaced by white, // everything else by black) wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const; - // Convert to disabled (dimmed) image. - wxImage ConvertToDisabled(unsigned char brightness = 255) const; - // these routines are slow but safe void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); void SetRGB( const wxRect& rect, unsigned char r, unsigned char g, unsigned char b ); @@ -388,13 +295,9 @@ public: bool SetMaskFromImage(const wxImage & mask, unsigned char mr, unsigned char mg, unsigned char mb); - // converts image's alpha channel to mask (choosing mask colour - // automatically or using the specified colour for the mask), if it has - // any, does nothing otherwise: + // converts image's alpha channel to mask, if it has any, does nothing + // otherwise: bool ConvertAlphaToMask(unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD); - bool ConvertAlphaToMask(unsigned char mr, unsigned char mg, unsigned char mb, - unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD); - // This method converts an image where the original alpha // information is only available as a shades of a colour @@ -409,23 +312,23 @@ public: bool ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b ); static bool CanRead( const wxString& name ); - static int GetImageCount( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY ); - virtual bool LoadFile( const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 ); + static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY ); + virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); virtual bool LoadFile( const wxString& name, const wxString& mimetype, int index = -1 ); #if wxUSE_STREAMS static bool CanRead( wxInputStream& stream ); - static int GetImageCount( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY ); - virtual bool LoadFile( wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1 ); + static int GetImageCount( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY ); + virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ); virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 ); #endif virtual bool SaveFile( const wxString& name ) const; - virtual bool SaveFile( const wxString& name, wxBitmapType type ) const; + virtual bool SaveFile( const wxString& name, int type ) const; virtual bool SaveFile( const wxString& name, const wxString& mimetype ) const; #if wxUSE_STREAMS - virtual bool SaveFile( wxOutputStream& stream, wxBitmapType type ) const; + virtual bool SaveFile( wxOutputStream& stream, int type ) const; virtual bool SaveFile( wxOutputStream& stream, const wxString& mimetype ) const; #endif @@ -434,17 +337,6 @@ public: int GetWidth() const; int GetHeight() const; - wxSize GetSize() const - { return wxSize(GetWidth(), GetHeight()); } - - // Gets the type of image found by LoadFile or specified with SaveFile - wxBitmapType GetType() const; - - // Set the image type, this is normally only called if the image is being - // created from data in the given format but not using LoadFile() (e.g. - // wxGIFDecoder uses this) - void SetType(wxBitmapType type); - // these functions provide fastest access to wxImage data but should be // used carefully as no checks are done unsigned char *GetData() const; @@ -455,7 +347,6 @@ public: bool HasAlpha() const { return GetAlpha() != NULL; } void SetAlpha(unsigned char *alpha = NULL, bool static_data=false); void InitAlpha(); - void ClearAlpha(); // return true if this pixel is masked or has alpha less than specified // threshold @@ -506,9 +397,8 @@ public: static void InsertHandler( wxImageHandler *handler ); static bool RemoveHandler( const wxString& name ); static wxImageHandler *FindHandler( const wxString& name ); - static wxImageHandler *FindHandler( const wxString& extension, wxBitmapType imageType ); - static wxImageHandler *FindHandler( wxBitmapType imageType ); - + static wxImageHandler *FindHandler( const wxString& extension, long imageType ); + static wxImageHandler *FindHandler( long imageType ); static wxImageHandler *FindHandlerMime( const wxString& mimetype ); static wxString GetImageExtWildcard(); @@ -519,65 +409,6 @@ public: static HSVValue RGBtoHSV(const RGBValue& rgb); static RGBValue HSVtoRGB(const HSVValue& hsv); -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_CONSTRUCTOR( - wxImage(const wxString& name, long type, int index = -1) - { - LoadFile(name, (wxBitmapType)type, index); - } - ) - -#if wxUSE_STREAMS - wxDEPRECATED_CONSTRUCTOR( - wxImage(wxInputStream& stream, long type, int index = -1) - { - LoadFile(stream, (wxBitmapType)type, index); - } - ) - - wxDEPRECATED( - bool LoadFile(wxInputStream& stream, long type, int index = -1) - { - return LoadFile(stream, (wxBitmapType)type, index); - } - ) - - wxDEPRECATED( - bool SaveFile(wxOutputStream& stream, long type) const - { - return SaveFile(stream, (wxBitmapType)type); - } - ) -#endif // wxUSE_STREAMS - - wxDEPRECATED( - bool LoadFile(const wxString& name, long type, int index = -1) - { - return LoadFile(name, (wxBitmapType)type, index); - } - ) - - wxDEPRECATED( - bool SaveFile(const wxString& name, long type) const - { - return SaveFile(name, (wxBitmapType)type); - } - ) - - static wxDEPRECATED( - wxImageHandler *FindHandler(const wxString& ext, long type) - { - return FindHandler(ext, (wxBitmapType)type); - } - ) - - static wxDEPRECATED( - wxImageHandler *FindHandler(long imageType) - { - return FindHandler((wxBitmapType)imageType); - } - ) -#endif // WXWIN_COMPATIBILITY_2_8 protected: static wxList sm_handlers; @@ -594,41 +425,13 @@ protected: private: friend class WXDLLIMPEXP_FWD_CORE wxImageHandler; - // Possible values for MakeEmptyClone() flags. - enum - { - // Create an image with the same orientation as this one. This is the - // default and only exists for symmetry with SwapOrientation. - Clone_SameOrientation = 0, - - // Create an image with the same height as this image width and the - // same width as this image height. - Clone_SwapOrientation = 1 - }; - - // Returns a new blank image with the same dimensions (or with width and - // height swapped if Clone_SwapOrientation flag is given), alpha, and mask - // as this image itself. This is used by several functions creating - // modified versions of this image. - wxImage MakeEmptyClone(int flags = Clone_SameOrientation) const; - -#if wxUSE_STREAMS - // read the image from the specified stream updating image type if - // successful - bool DoLoad(wxImageHandler& handler, wxInputStream& stream, int index); - - // write the image to the specified stream and also update the image type - // if successful - bool DoSave(wxImageHandler& handler, wxOutputStream& stream) const; -#endif // wxUSE_STREAMS - DECLARE_DYNAMIC_CLASS(wxImage) }; -extern void WXDLLIMPEXP_CORE wxInitAllImageHandlers(); +extern void WXDLLEXPORT wxInitAllImageHandlers(); -extern WXDLLIMPEXP_DATA_CORE(wxImage) wxNullImage; +extern WXDLLEXPORT_DATA(wxImage) wxNullImage; //----------------------------------------------------------------------------- // wxImage handlers diff --git a/Source/3rd Party/wx/include/wx/imaggif.h b/Source/3rd Party/wx/include/wx/imaggif.h index f3f087cc0..21b58e618 100644 --- a/Source/3rd Party/wx/include/wx/imaggif.h +++ b/Source/3rd Party/wx/include/wx/imaggif.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imaggif.h +// Name: imaggif.h // Purpose: wxImage GIF handler -// Author: Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K -// Copyright: (c) 1999-2011 Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K +// Author: Vaclav Slavik & Guillermo Rodriguez Garcia +// RCS-ID: $Id: imaggif.h 37393 2006-02-08 21:47:09Z VZ $ +// Copyright: (c) Guillermo Rodriguez Garcia // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,13 +19,7 @@ #if wxUSE_GIF -#define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment") - -struct wxRGB; -struct GifHashTableType; -class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h - -class WXDLLIMPEXP_CORE wxGIFHandler : public wxImageHandler +class WXDLLEXPORT wxGIFHandler : public wxImageHandler { public: inline wxGIFHandler() @@ -33,61 +28,21 @@ public: m_extension = wxT("gif"); m_type = wxBITMAP_TYPE_GIF; m_mime = wxT("image/gif"); - m_hashTable = NULL; } #if wxUSE_STREAMS - virtual bool LoadFile(wxImage *image, wxInputStream& stream, - bool verbose = true, int index = -1); - virtual bool SaveFile(wxImage *image, wxOutputStream& stream, - bool verbose=true); - - // Save animated gif - bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream, - bool verbose = true, int delayMilliSecs = 1000); - + virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); + virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); protected: - virtual int DoGetImageCount(wxInputStream& stream); - virtual bool DoCanRead(wxInputStream& stream); - - bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose, - bool first, int delayMilliSecs, bool loop, - const wxRGB *pal, int palCount, - int mask_index); -#endif // wxUSE_STREAMS -protected: - - // Declarations for saving - - unsigned long m_crntShiftDWord; /* For bytes decomposition into codes. */ - int m_pixelCount; - struct GifHashTableType *m_hashTable; - wxInt16 - m_EOFCode, /* The EOF LZ code. */ - m_clearCode, /* The CLEAR LZ code. */ - m_runningCode, /* The next code algorithm can generate. */ - m_runningBits, /* The number of bits required to represent RunningCode. */ - m_maxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ - m_crntCode, /* Current algorithm code. */ - m_crntShiftState; /* Number of bits in CrntShiftDWord. */ - wxUint8 m_LZBuf[256]; /* Compressed input is buffered here. */ - - bool InitHashTable(); - void ClearHashTable(); - void InsertHashTable(unsigned long key, int code); - int ExistsHashTable(unsigned long key); - -#if wxUSE_STREAMS - bool CompressOutput(wxOutputStream *, int code); - bool SetupCompress(wxOutputStream *, int bpp); - bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen); + virtual bool DoCanRead( wxInputStream& stream ); #endif private: DECLARE_DYNAMIC_CLASS(wxGIFHandler) }; +#endif -#endif // wxUSE_GIF -#endif // _WX_IMAGGIF_H_ +#endif + // _WX_IMAGGIF_H_ diff --git a/Source/3rd Party/wx/include/wx/imagiff.h b/Source/3rd Party/wx/include/wx/imagiff.h index fb0bb052a..6b47da735 100644 --- a/Source/3rd Party/wx/include/wx/imagiff.h +++ b/Source/3rd Party/wx/include/wx/imagiff.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagiff.h +// Name: imagiff.h // Purpose: wxImage handler for Amiga IFF images // Author: Steffen Gutmann +// RCS-ID: $Id: imagiff.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) Steffen Gutmann, 2002 // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ #if wxUSE_IMAGE && wxUSE_IFF -class WXDLLIMPEXP_CORE wxIFFHandler : public wxImageHandler +class WXDLLEXPORT wxIFFHandler : public wxImageHandler { public: wxIFFHandler() @@ -31,10 +32,10 @@ public: #if wxUSE_STREAMS virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1); virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true); -protected: virtual bool DoCanRead(wxInputStream& stream); #endif +private: DECLARE_DYNAMIC_CLASS(wxIFFHandler) }; diff --git a/Source/3rd Party/wx/include/wx/imagjpeg.h b/Source/3rd Party/wx/include/wx/imagjpeg.h index 666522428..410b7cc93 100644 --- a/Source/3rd Party/wx/include/wx/imagjpeg.h +++ b/Source/3rd Party/wx/include/wx/imagjpeg.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagjpeg.h +// Name: imagjpeg.h // Purpose: wxImage JPEG handler // Author: Vaclav Slavik +// RCS-ID: $Id: imagjpeg.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,23 +19,18 @@ #if wxUSE_LIBJPEG #include "wx/image.h" -#include "wx/versioninfo.h" -class WXDLLIMPEXP_CORE wxJPEGHandler: public wxImageHandler +class WXDLLEXPORT wxJPEGHandler: public wxImageHandler { public: inline wxJPEGHandler() { m_name = wxT("JPEG file"); m_extension = wxT("jpg"); - m_altExtensions.Add(wxT("jpeg")); - m_altExtensions.Add(wxT("jpe")); m_type = wxBITMAP_TYPE_JPEG; m_mime = wxT("image/jpeg"); } - static wxVersionInfo GetLibraryVersionInfo(); - #if wxUSE_STREAMS virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); diff --git a/Source/3rd Party/wx/include/wx/imaglist.h b/Source/3rd Party/wx/include/wx/imaglist.h index 1559d3f6f..91cf8eac6 100644 --- a/Source/3rd Party/wx/include/wx/imaglist.h +++ b/Source/3rd Party/wx/include/wx/imaglist.h @@ -5,14 +5,13 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: imaglist.h 41288 2006-09-18 23:06:35Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_IMAGLIST_H_BASE_ #define _WX_IMAGLIST_H_BASE_ -#include "wx/defs.h" - /* * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to * images for their items by an index into an image list. @@ -41,7 +40,7 @@ enum #define wxIMAGELIST_DRAW_SELECTED 0x0004 #define wxIMAGELIST_DRAW_FOCUSED 0x0008 -#if defined(__WXMSW__) || defined(__WXMAC__) +#if defined(__WXMSW__) || defined(__WXMAC_CARBON__) #define wxHAS_NATIVE_IMAGELIST #endif @@ -49,8 +48,8 @@ enum #include "wx/generic/imaglist.h" #elif defined(__WXMSW__) #include "wx/msw/imaglist.h" -#elif defined(__WXMAC__) - #include "wx/osx/imaglist.h" +#elif defined(__WXMAC_CARBON__) + #include "wx/mac/imaglist.h" #endif #endif // _WX_IMAGLIST_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/imagpcx.h b/Source/3rd Party/wx/include/wx/imagpcx.h index 1bdd9c276..f56048f84 100644 --- a/Source/3rd Party/wx/include/wx/imagpcx.h +++ b/Source/3rd Party/wx/include/wx/imagpcx.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagpcx.h +// Name: imagpcx.h // Purpose: wxImage PCX handler // Author: Guillermo Rodriguez Garcia +// RCS-ID: $Id: imagpcx.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) 1999 Guillermo Rodriguez Garcia // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ //----------------------------------------------------------------------------- #if wxUSE_PCX -class WXDLLIMPEXP_CORE wxPCXHandler : public wxImageHandler +class WXDLLEXPORT wxPCXHandler : public wxImageHandler { public: inline wxPCXHandler() diff --git a/Source/3rd Party/wx/include/wx/imagpng.h b/Source/3rd Party/wx/include/wx/imagpng.h index 30567638c..daea3a26f 100644 --- a/Source/3rd Party/wx/include/wx/imagpng.h +++ b/Source/3rd Party/wx/include/wx/imagpng.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagpng.h +// Name: imagpng.h // Purpose: wxImage PNG handler // Author: Robert Roebling +// RCS-ID: $Id: imagpng.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,25 +19,18 @@ #if wxUSE_LIBPNG #include "wx/image.h" -#include "wx/versioninfo.h" #define wxIMAGE_OPTION_PNG_FORMAT wxT("PngFormat") #define wxIMAGE_OPTION_PNG_BITDEPTH wxT("PngBitDepth") -#define wxIMAGE_OPTION_PNG_FILTER wxT("PngF") -#define wxIMAGE_OPTION_PNG_COMPRESSION_LEVEL wxT("PngZL") -#define wxIMAGE_OPTION_PNG_COMPRESSION_MEM_LEVEL wxT("PngZM") -#define wxIMAGE_OPTION_PNG_COMPRESSION_STRATEGY wxT("PngZS") -#define wxIMAGE_OPTION_PNG_COMPRESSION_BUFFER_SIZE wxT("PngZB") enum { wxPNG_TYPE_COLOUR = 0, wxPNG_TYPE_GREY = 2, - wxPNG_TYPE_GREY_RED = 3, - wxPNG_TYPE_PALETTE = 4 + wxPNG_TYPE_GREY_RED = 3 }; -class WXDLLIMPEXP_CORE wxPNGHandler: public wxImageHandler +class WXDLLEXPORT wxPNGHandler: public wxImageHandler { public: inline wxPNGHandler() @@ -47,8 +41,6 @@ public: m_mime = wxT("image/png"); } - static wxVersionInfo GetLibraryVersionInfo(); - #if wxUSE_STREAMS virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); diff --git a/Source/3rd Party/wx/include/wx/imagpnm.h b/Source/3rd Party/wx/include/wx/imagpnm.h index 3597ad840..68b95efd9 100644 --- a/Source/3rd Party/wx/include/wx/imagpnm.h +++ b/Source/3rd Party/wx/include/wx/imagpnm.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagpnm.h +// Name: imagpnm.h // Purpose: wxImage PNM handler // Author: Sylvain Bougnoux +// RCS-ID: $Id: imagpnm.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Sylvain Bougnoux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,16 +17,13 @@ //----------------------------------------------------------------------------- #if wxUSE_PNM -class WXDLLIMPEXP_CORE wxPNMHandler : public wxImageHandler +class WXDLLEXPORT wxPNMHandler : public wxImageHandler { public: inline wxPNMHandler() { m_name = wxT("PNM file"); m_extension = wxT("pnm"); - m_altExtensions.Add(wxT("ppm")); - m_altExtensions.Add(wxT("pgm")); - m_altExtensions.Add(wxT("pbm")); m_type = wxBITMAP_TYPE_PNM; m_mime = wxT("image/pnm"); } diff --git a/Source/3rd Party/wx/include/wx/imagtga.h b/Source/3rd Party/wx/include/wx/imagtga.h index 3fdb2207f..9b0a84187 100644 --- a/Source/3rd Party/wx/include/wx/imagtga.h +++ b/Source/3rd Party/wx/include/wx/imagtga.h @@ -2,6 +2,7 @@ // Name: wx/imagtga.h // Purpose: wxImage TGA handler // Author: Seth Jackson +// RCS-ID: $Id: imagtga.h 43843 2006-12-07 05:44:44Z PC $ // Copyright: (c) 2005 Seth Jackson // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,14 +18,13 @@ #if wxUSE_TGA -class WXDLLIMPEXP_CORE wxTGAHandler : public wxImageHandler +class WXDLLEXPORT wxTGAHandler : public wxImageHandler { public: wxTGAHandler() { m_name = wxT("TGA file"); m_extension = wxT("tga"); - m_altExtensions.Add(wxT("tpic")); m_type = wxBITMAP_TYPE_TGA; m_mime = wxT("image/tga"); } diff --git a/Source/3rd Party/wx/include/wx/imagtiff.h b/Source/3rd Party/wx/include/wx/imagtiff.h index 0e2b9aca6..53df633a3 100644 --- a/Source/3rd Party/wx/include/wx/imagtiff.h +++ b/Source/3rd Party/wx/include/wx/imagtiff.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagtiff.h +// Name: imagtiff.h // Purpose: wxImage TIFF handler // Author: Robert Roebling +// RCS-ID: $Id: imagtiff.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,34 +19,23 @@ #if wxUSE_LIBTIFF #include "wx/image.h" -#include "wx/versioninfo.h" // defines for wxImage::SetOption -#define wxIMAGE_OPTION_TIFF_BITSPERSAMPLE wxString(wxT("BitsPerSample")) -#define wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL wxString(wxT("SamplesPerPixel")) -#define wxIMAGE_OPTION_TIFF_COMPRESSION wxString(wxT("Compression")) -#define wxIMAGE_OPTION_TIFF_PHOTOMETRIC wxString(wxT("Photometric")) -#define wxIMAGE_OPTION_TIFF_IMAGEDESCRIPTOR wxString(wxT("ImageDescriptor")) +#define wxIMAGE_OPTION_BITSPERSAMPLE wxString(wxT("BitsPerSample")) +#define wxIMAGE_OPTION_SAMPLESPERPIXEL wxString(wxT("SamplesPerPixel")) +#define wxIMAGE_OPTION_COMPRESSION wxString(wxT("Compression")) +#define wxIMAGE_OPTION_IMAGEDESCRIPTOR wxString(wxT("ImageDescriptor")) -// for backwards compatibility -#define wxIMAGE_OPTION_BITSPERSAMPLE wxIMAGE_OPTION_TIFF_BITSPERSAMPLE -#define wxIMAGE_OPTION_SAMPLESPERPIXEL wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL -#define wxIMAGE_OPTION_COMPRESSION wxIMAGE_OPTION_TIFF_COMPRESSION -#define wxIMAGE_OPTION_IMAGEDESCRIPTOR wxIMAGE_OPTION_TIFF_IMAGEDESCRIPTOR - -class WXDLLIMPEXP_CORE wxTIFFHandler: public wxImageHandler +class WXDLLEXPORT wxTIFFHandler: public wxImageHandler { public: wxTIFFHandler(); - static wxVersionInfo GetLibraryVersionInfo(); - #if wxUSE_STREAMS virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ); virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ); - + virtual int GetImageCount( wxInputStream& stream ); protected: - virtual int DoGetImageCount( wxInputStream& stream ); virtual bool DoCanRead( wxInputStream& stream ); #endif diff --git a/Source/3rd Party/wx/include/wx/imagxpm.h b/Source/3rd Party/wx/include/wx/imagxpm.h index 608e7fc14..4bff4894f 100644 --- a/Source/3rd Party/wx/include/wx/imagxpm.h +++ b/Source/3rd Party/wx/include/wx/imagxpm.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/imagxpm.h +// Name: imaggif.h // Purpose: wxImage XPM handler // Author: Vaclav Slavik +// RCS-ID: $Id: imagxpm.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) 2001 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,13 +12,12 @@ #include "wx/image.h" -#if wxUSE_XPM //----------------------------------------------------------------------------- // wxXPMHandler //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxXPMHandler : public wxImageHandler +class WXDLLEXPORT wxXPMHandler : public wxImageHandler { public: inline wxXPMHandler() @@ -39,6 +39,7 @@ private: DECLARE_DYNAMIC_CLASS(wxXPMHandler) }; -#endif // wxUSE_XPM -#endif // _WX_IMAGXPM_H_ +#endif + // _WX_IMAGXPM_H_ + diff --git a/Source/3rd Party/wx/include/wx/infobar.h b/Source/3rd Party/wx/include/wx/infobar.h deleted file mode 100644 index be390a856..000000000 --- a/Source/3rd Party/wx/include/wx/infobar.h +++ /dev/null @@ -1,67 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/infobar.h -// Purpose: declaration of wxInfoBarBase defining common API of wxInfoBar -// Author: Vadim Zeitlin -// Created: 2009-07-28 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_INFOBAR_H_ -#define _WX_INFOBAR_H_ - -#include "wx/defs.h" - -#if wxUSE_INFOBAR - -#include "wx/control.h" - -// ---------------------------------------------------------------------------- -// wxInfoBar shows non-critical but important information to the user -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxInfoBarBase : public wxControl -{ -public: - // real ctors are provided by the derived classes, just notice that unlike - // most of the other windows, info bar is created hidden and must be - // explicitly shown when it is needed (this is done because it is supposed - // to be shown only intermittently and hiding it after creating it from the - // user code would result in flicker) - wxInfoBarBase() { } - - - // show the info bar with the given message and optionally an icon - virtual void ShowMessage(const wxString& msg, - int flags = wxICON_INFORMATION) = 0; - - // hide the info bar - virtual void Dismiss() = 0; - - // add an extra button to the bar, near the message (replacing the default - // close button which is only shown if no extra buttons are used) - virtual void AddButton(wxWindowID btnid, - const wxString& label = wxString()) = 0; - - // remove a button previously added by AddButton() - virtual void RemoveButton(wxWindowID btnid) = 0; - -private: - wxDECLARE_NO_COPY_CLASS(wxInfoBarBase); -}; - -// currently only GTK+ has a native implementation -#if defined(__WXGTK218__) && !defined(__WXUNIVERSAL__) - #include "wx/gtk/infobar.h" - #define wxHAS_NATIVE_INFOBAR -#endif // wxGTK2 - -// if the generic version is the only one we have, use it -#ifndef wxHAS_NATIVE_INFOBAR - #include "wx/generic/infobar.h" - #define wxInfoBar wxInfoBarGeneric -#endif - -#endif // wxUSE_INFOBAR - -#endif // _WX_INFOBAR_H_ diff --git a/Source/3rd Party/wx/include/wx/init.h b/Source/3rd Party/wx/include/wx/init.h index fc480ce1a..d07112ff5 100644 --- a/Source/3rd Party/wx/include/wx/init.h +++ b/Source/3rd Party/wx/include/wx/init.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29.06.2003 +// RCS-ID: $Id: init.h 61558 2009-07-30 10:14:36Z VS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ #define _WX_INIT_H_ #include "wx/defs.h" -#include "wx/chartype.h" +#include "wx/wxchar.h" // ---------------------------------------------------------------------------- // wxEntry helper functions which allow to have more fine grained control @@ -52,23 +53,16 @@ extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv); #endif// wxUSE_UNICODE -// Under Windows we define additional wxEntry() overloads with signature -// compatible with WinMain() and not the traditional main(). -#if wxUSE_GUI && defined(__WINDOWS__) - #include "wx/msw/init.h" -#endif - // ---------------------------------------------------------------------------- // Using the library without (explicit) application object: you may avoid using -// wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at +// DECLARE_APP and IMPLEMENT_APP macros and call the functions below instead at // the program startup and termination // ---------------------------------------------------------------------------- // initialize the library (may be called as many times as needed, but each // call to wxInitialize() must be matched by wxUninitialize()) -extern bool WXDLLIMPEXP_BASE wxInitialize(); -extern bool WXDLLIMPEXP_BASE wxInitialize(int argc, wxChar **argv); -#if wxUSE_UNICODE +extern bool WXDLLIMPEXP_BASE wxInitialize(int argc = 0, wxChar **argv = NULL); +#if wxUSE_UNICODE && wxABI_VERSION >= 20811 extern bool WXDLLIMPEXP_BASE wxInitialize(int argc, char **argv); #endif @@ -82,17 +76,12 @@ class WXDLLIMPEXP_BASE wxInitializer { public: // initialize the library - wxInitializer() - { - m_ok = wxInitialize(); - } - - wxInitializer(int argc, wxChar **argv) + wxInitializer(int argc = 0, wxChar **argv = NULL) { m_ok = wxInitialize(argc, argv); } -#if wxUSE_UNICODE +#if wxUSE_UNICODE && wxABI_VERSION >= 20811 wxInitializer(int argc, char **argv) { m_ok = wxInitialize(argc, argv); diff --git a/Source/3rd Party/wx/include/wx/intl.h b/Source/3rd Party/wx/include/wx/intl.h index cd76ff116..ed5631a83 100644 --- a/Source/3rd Party/wx/include/wx/intl.h +++ b/Source/3rd Party/wx/include/wx/intl.h @@ -5,16 +5,19 @@ // Modified by: Michael N. Filippov // (2003/09/30 - plural forms support) // Created: 29/01/98 +// RCS-ID: $Id: intl.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// WARNING: Parts of this file are generated. See misc/languages/README for +// details. + #ifndef _WX_INTL_H_ #define _WX_INTL_H_ #include "wx/defs.h" #include "wx/string.h" -#include "wx/translation.h" // Make wxLayoutDirection enum available without need for wxUSE_INTL so wxWindow, wxApp // and other classes are not distrubed by wxUSE_INTL @@ -29,7 +32,6 @@ enum wxLayoutDirection #if wxUSE_INTL #include "wx/fontenc.h" -#include "wx/language.h" // ============================================================================ // global decls @@ -39,17 +41,290 @@ enum wxLayoutDirection // macros // ---------------------------------------------------------------------------- +// gettext() style macros (notice that xgettext should be invoked with +// --keyword="_" --keyword="wxPLURAL:1,2" options +// to extract the strings from the sources) +#ifndef WXINTL_NO_GETTEXT_MACRO + #define _(s) wxGetTranslation(wxT(s)) + #define wxPLURAL(sing, plur, n) wxGetTranslation(wxT(sing), wxT(plur), n) +#endif + +// another one which just marks the strings for extraction, but doesn't +// perform the translation (use -kwxTRANSLATE with xgettext!) +#define wxTRANSLATE(str) wxT(str) + // ---------------------------------------------------------------------------- // forward decls // ---------------------------------------------------------------------------- class WXDLLIMPEXP_FWD_BASE wxLocale; class WXDLLIMPEXP_FWD_BASE wxLanguageInfoArray; +class wxMsgCatalog; // ============================================================================ // locale support // ============================================================================ +// ---------------------------------------------------------------------------- +// wxLanguage: defines all supported languages +// ---------------------------------------------------------------------------- + +// --- --- --- generated code begins here --- --- --- + +// This enum is generated by misc/languages/genlang.py +// When making changes, please put them into misc/languages/langtabl.txt +enum wxLanguage +{ + // user's default/preffered language as got from OS: + wxLANGUAGE_DEFAULT, + // unknown language, if wxLocale::GetSystemLanguage fails: + wxLANGUAGE_UNKNOWN, + + wxLANGUAGE_ABKHAZIAN, + wxLANGUAGE_AFAR, + wxLANGUAGE_AFRIKAANS, + wxLANGUAGE_ALBANIAN, + wxLANGUAGE_AMHARIC, + wxLANGUAGE_ARABIC, + wxLANGUAGE_ARABIC_ALGERIA, + wxLANGUAGE_ARABIC_BAHRAIN, + wxLANGUAGE_ARABIC_EGYPT, + wxLANGUAGE_ARABIC_IRAQ, + wxLANGUAGE_ARABIC_JORDAN, + wxLANGUAGE_ARABIC_KUWAIT, + wxLANGUAGE_ARABIC_LEBANON, + wxLANGUAGE_ARABIC_LIBYA, + wxLANGUAGE_ARABIC_MOROCCO, + wxLANGUAGE_ARABIC_OMAN, + wxLANGUAGE_ARABIC_QATAR, + wxLANGUAGE_ARABIC_SAUDI_ARABIA, + wxLANGUAGE_ARABIC_SUDAN, + wxLANGUAGE_ARABIC_SYRIA, + wxLANGUAGE_ARABIC_TUNISIA, + wxLANGUAGE_ARABIC_UAE, + wxLANGUAGE_ARABIC_YEMEN, + wxLANGUAGE_ARMENIAN, + wxLANGUAGE_ASSAMESE, + wxLANGUAGE_AYMARA, + wxLANGUAGE_AZERI, + wxLANGUAGE_AZERI_CYRILLIC, + wxLANGUAGE_AZERI_LATIN, + wxLANGUAGE_BASHKIR, + wxLANGUAGE_BASQUE, + wxLANGUAGE_BELARUSIAN, + wxLANGUAGE_BENGALI, + wxLANGUAGE_BHUTANI, + wxLANGUAGE_BIHARI, + wxLANGUAGE_BISLAMA, + wxLANGUAGE_BRETON, + wxLANGUAGE_BULGARIAN, + wxLANGUAGE_BURMESE, + wxLANGUAGE_CAMBODIAN, + wxLANGUAGE_CATALAN, + wxLANGUAGE_CHINESE, + wxLANGUAGE_CHINESE_SIMPLIFIED, + wxLANGUAGE_CHINESE_TRADITIONAL, + wxLANGUAGE_CHINESE_HONGKONG, + wxLANGUAGE_CHINESE_MACAU, + wxLANGUAGE_CHINESE_SINGAPORE, + wxLANGUAGE_CHINESE_TAIWAN, + wxLANGUAGE_CORSICAN, + wxLANGUAGE_CROATIAN, + wxLANGUAGE_CZECH, + wxLANGUAGE_DANISH, + wxLANGUAGE_DUTCH, + wxLANGUAGE_DUTCH_BELGIAN, + wxLANGUAGE_ENGLISH, + wxLANGUAGE_ENGLISH_UK, + wxLANGUAGE_ENGLISH_US, + wxLANGUAGE_ENGLISH_AUSTRALIA, + wxLANGUAGE_ENGLISH_BELIZE, + wxLANGUAGE_ENGLISH_BOTSWANA, + wxLANGUAGE_ENGLISH_CANADA, + wxLANGUAGE_ENGLISH_CARIBBEAN, + wxLANGUAGE_ENGLISH_DENMARK, + wxLANGUAGE_ENGLISH_EIRE, + wxLANGUAGE_ENGLISH_JAMAICA, + wxLANGUAGE_ENGLISH_NEW_ZEALAND, + wxLANGUAGE_ENGLISH_PHILIPPINES, + wxLANGUAGE_ENGLISH_SOUTH_AFRICA, + wxLANGUAGE_ENGLISH_TRINIDAD, + wxLANGUAGE_ENGLISH_ZIMBABWE, + wxLANGUAGE_ESPERANTO, + wxLANGUAGE_ESTONIAN, + wxLANGUAGE_FAEROESE, + wxLANGUAGE_FARSI, + wxLANGUAGE_FIJI, + wxLANGUAGE_FINNISH, + wxLANGUAGE_FRENCH, + wxLANGUAGE_FRENCH_BELGIAN, + wxLANGUAGE_FRENCH_CANADIAN, + wxLANGUAGE_FRENCH_LUXEMBOURG, + wxLANGUAGE_FRENCH_MONACO, + wxLANGUAGE_FRENCH_SWISS, + wxLANGUAGE_FRISIAN, + wxLANGUAGE_GALICIAN, + wxLANGUAGE_GEORGIAN, + wxLANGUAGE_GERMAN, + wxLANGUAGE_GERMAN_AUSTRIAN, + wxLANGUAGE_GERMAN_BELGIUM, + wxLANGUAGE_GERMAN_LIECHTENSTEIN, + wxLANGUAGE_GERMAN_LUXEMBOURG, + wxLANGUAGE_GERMAN_SWISS, + wxLANGUAGE_GREEK, + wxLANGUAGE_GREENLANDIC, + wxLANGUAGE_GUARANI, + wxLANGUAGE_GUJARATI, + wxLANGUAGE_HAUSA, + wxLANGUAGE_HEBREW, + wxLANGUAGE_HINDI, + wxLANGUAGE_HUNGARIAN, + wxLANGUAGE_ICELANDIC, + wxLANGUAGE_INDONESIAN, + wxLANGUAGE_INTERLINGUA, + wxLANGUAGE_INTERLINGUE, + wxLANGUAGE_INUKTITUT, + wxLANGUAGE_INUPIAK, + wxLANGUAGE_IRISH, + wxLANGUAGE_ITALIAN, + wxLANGUAGE_ITALIAN_SWISS, + wxLANGUAGE_JAPANESE, + wxLANGUAGE_JAVANESE, + wxLANGUAGE_KANNADA, + wxLANGUAGE_KASHMIRI, + wxLANGUAGE_KASHMIRI_INDIA, + wxLANGUAGE_KAZAKH, + wxLANGUAGE_KERNEWEK, + wxLANGUAGE_KINYARWANDA, + wxLANGUAGE_KIRGHIZ, + wxLANGUAGE_KIRUNDI, + wxLANGUAGE_KONKANI, + wxLANGUAGE_KOREAN, + wxLANGUAGE_KURDISH, + wxLANGUAGE_LAOTHIAN, + wxLANGUAGE_LATIN, + wxLANGUAGE_LATVIAN, + wxLANGUAGE_LINGALA, + wxLANGUAGE_LITHUANIAN, + wxLANGUAGE_MACEDONIAN, + wxLANGUAGE_MALAGASY, + wxLANGUAGE_MALAY, + wxLANGUAGE_MALAYALAM, + wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, + wxLANGUAGE_MALAY_MALAYSIA, + wxLANGUAGE_MALTESE, + wxLANGUAGE_MANIPURI, + wxLANGUAGE_MAORI, + wxLANGUAGE_MARATHI, + wxLANGUAGE_MOLDAVIAN, + wxLANGUAGE_MONGOLIAN, + wxLANGUAGE_NAURU, + wxLANGUAGE_NEPALI, + wxLANGUAGE_NEPALI_INDIA, + wxLANGUAGE_NORWEGIAN_BOKMAL, + wxLANGUAGE_NORWEGIAN_NYNORSK, + wxLANGUAGE_OCCITAN, + wxLANGUAGE_ORIYA, + wxLANGUAGE_OROMO, + wxLANGUAGE_PASHTO, + wxLANGUAGE_POLISH, + wxLANGUAGE_PORTUGUESE, + wxLANGUAGE_PORTUGUESE_BRAZILIAN, + wxLANGUAGE_PUNJABI, + wxLANGUAGE_QUECHUA, + wxLANGUAGE_RHAETO_ROMANCE, + wxLANGUAGE_ROMANIAN, + wxLANGUAGE_RUSSIAN, + wxLANGUAGE_RUSSIAN_UKRAINE, + wxLANGUAGE_SAMOAN, + wxLANGUAGE_SANGHO, + wxLANGUAGE_SANSKRIT, + wxLANGUAGE_SCOTS_GAELIC, + wxLANGUAGE_SERBIAN, + wxLANGUAGE_SERBIAN_CYRILLIC, + wxLANGUAGE_SERBIAN_LATIN, + wxLANGUAGE_SERBO_CROATIAN, + wxLANGUAGE_SESOTHO, + wxLANGUAGE_SETSWANA, + wxLANGUAGE_SHONA, + wxLANGUAGE_SINDHI, + wxLANGUAGE_SINHALESE, + wxLANGUAGE_SISWATI, + wxLANGUAGE_SLOVAK, + wxLANGUAGE_SLOVENIAN, + wxLANGUAGE_SOMALI, + wxLANGUAGE_SPANISH, + wxLANGUAGE_SPANISH_ARGENTINA, + wxLANGUAGE_SPANISH_BOLIVIA, + wxLANGUAGE_SPANISH_CHILE, + wxLANGUAGE_SPANISH_COLOMBIA, + wxLANGUAGE_SPANISH_COSTA_RICA, + wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, + wxLANGUAGE_SPANISH_ECUADOR, + wxLANGUAGE_SPANISH_EL_SALVADOR, + wxLANGUAGE_SPANISH_GUATEMALA, + wxLANGUAGE_SPANISH_HONDURAS, + wxLANGUAGE_SPANISH_MEXICAN, + wxLANGUAGE_SPANISH_MODERN, + wxLANGUAGE_SPANISH_NICARAGUA, + wxLANGUAGE_SPANISH_PANAMA, + wxLANGUAGE_SPANISH_PARAGUAY, + wxLANGUAGE_SPANISH_PERU, + wxLANGUAGE_SPANISH_PUERTO_RICO, + wxLANGUAGE_SPANISH_URUGUAY, + wxLANGUAGE_SPANISH_US, + wxLANGUAGE_SPANISH_VENEZUELA, + wxLANGUAGE_SUNDANESE, + wxLANGUAGE_SWAHILI, + wxLANGUAGE_SWEDISH, + wxLANGUAGE_SWEDISH_FINLAND, + wxLANGUAGE_TAGALOG, + wxLANGUAGE_TAJIK, + wxLANGUAGE_TAMIL, + wxLANGUAGE_TATAR, + wxLANGUAGE_TELUGU, + wxLANGUAGE_THAI, + wxLANGUAGE_TIBETAN, + wxLANGUAGE_TIGRINYA, + wxLANGUAGE_TONGA, + wxLANGUAGE_TSONGA, + wxLANGUAGE_TURKISH, + wxLANGUAGE_TURKMEN, + wxLANGUAGE_TWI, + wxLANGUAGE_UIGHUR, + wxLANGUAGE_UKRAINIAN, + wxLANGUAGE_URDU, + wxLANGUAGE_URDU_INDIA, + wxLANGUAGE_URDU_PAKISTAN, + wxLANGUAGE_UZBEK, + wxLANGUAGE_UZBEK_CYRILLIC, + wxLANGUAGE_UZBEK_LATIN, + wxLANGUAGE_VIETNAMESE, + wxLANGUAGE_VOLAPUK, + wxLANGUAGE_WELSH, + wxLANGUAGE_WOLOF, + wxLANGUAGE_XHOSA, + wxLANGUAGE_YIDDISH, + wxLANGUAGE_YORUBA, + wxLANGUAGE_ZHUANG, + wxLANGUAGE_ZULU, + + // for custom, user-defined languages: + wxLANGUAGE_USER_DEFINED + + +#if wxABI_VERSION >= 20808 + // For binary compatibility, we can't put new items in their normal + // position in the enum, because it would change other values. We have to + // put it somewhere well outside normal range -- the particular value used + // is arbitrary: + , wxLANGUAGE_VALENCIAN = 0x1fffffff, + wxLANGUAGE_SAMI +#endif +}; + +// --- --- --- generated code ends here --- --- --- + // ---------------------------------------------------------------------------- // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc. // translation information @@ -59,30 +334,14 @@ struct WXDLLIMPEXP_BASE wxLanguageInfo { int Language; // wxLanguage id wxString CanonicalName; // Canonical name, e.g. fr_FR -#ifdef __WINDOWS__ +#ifdef __WIN32__ wxUint32 WinLang, // Win32 language identifiers WinSublang; -#endif // __WINDOWS__ +#endif // __WIN32__ wxString Description; // human-readable name of the language wxLayoutDirection LayoutDirection; - -#ifdef __WINDOWS__ - // return the LCID corresponding to this language - wxUint32 GetLCID() const; -#endif // __WINDOWS__ - - // return the locale name corresponding to this language usable with - // setlocale() on the current system - wxString GetLocaleName() const; }; -// for Unix systems GetLocaleName() is trivial so implement it inline here, for -// MSW it's implemented in intl.cpp -#ifndef __WINDOWS__ -inline wxString wxLanguageInfo::GetLocaleName() const { return CanonicalName; } -#endif // !__WINDOWS__ - - // ---------------------------------------------------------------------------- // wxLocaleCategory: the category of locale settings // ---------------------------------------------------------------------------- @@ -98,10 +357,6 @@ enum wxLocaleCategory // monetary value wxLOCALE_CAT_MONEY, - // default category for wxLocaleInfo values which only apply to a single - // category (e.g. wxLOCALE_SHORT_DATE_FMT) - wxLOCALE_CAT_DEFAULT, - wxLOCALE_CAT_MAX }; @@ -111,21 +366,11 @@ enum wxLocaleCategory enum wxLocaleInfo { - // the thousands separator (for wxLOCALE_CAT_NUMBER or MONEY) + // the thounsands separator wxLOCALE_THOUSANDS_SEP, - // the character used as decimal point (for wxLOCALE_CAT_NUMBER or MONEY) - wxLOCALE_DECIMAL_POINT, - - // the stftime()-formats used for short/long date and time representations - // (under some platforms short and long date formats are the same) - // - // NB: these elements should appear in this order, code in GetInfo() relies - // on it - wxLOCALE_SHORT_DATE_FMT, - wxLOCALE_LONG_DATE_FMT, - wxLOCALE_DATE_TIME_FMT, - wxLOCALE_TIME_FMT + // the character used as decimal point + wxLOCALE_DECIMAL_POINT }; @@ -136,12 +381,8 @@ enum wxLocaleInfo enum wxLocaleInitFlags { - wxLOCALE_DONT_LOAD_DEFAULT = 0x0000, // don't load wxwin.mo - wxLOCALE_LOAD_DEFAULT = 0x0001 // load wxwin.mo? -#if WXWIN_COMPATIBILITY_2_8 - ,wxLOCALE_CONV_ENCODING = 0x0002 // no longer used, simply remove - // it from the existing code -#endif + wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo? + wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly? }; class WXDLLIMPEXP_BASE wxLocale @@ -154,26 +395,19 @@ public: wxLocale() { DoCommonInit(); } // the ctor has a side effect of changing current locale - wxLocale(const wxString& name, // name (for messages) - const wxString& shortName = wxEmptyString, // dir prefix (for msg files) - const wxString& locale = wxEmptyString, // locale (for setlocale) - bool bLoadDefault = true // preload wxstd.mo? -#if WXWIN_COMPATIBILITY_2_8 - ,bool bConvertEncoding = true // convert Win<->Unix if necessary? -#endif - ) + wxLocale(const wxChar *szName, // name (for messages) + const wxChar *szShort = (const wxChar *) NULL, // dir prefix (for msg files) + const wxChar *szLocale = (const wxChar *) NULL, // locale (for setlocale) + bool bLoadDefault = true, // preload wxstd.mo? + bool bConvertEncoding = false) // convert Win<->Unix if necessary? { DoCommonInit(); -#if WXWIN_COMPATIBILITY_2_8 - Init(name, shortName, locale, bLoadDefault, bConvertEncoding); -#else - Init(name, shortName, locale, bLoadDefault); -#endif + Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding); } wxLocale(int language, // wxLanguage id or custom language - int flags = wxLOCALE_LOAD_DEFAULT) + int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) { DoCommonInit(); @@ -181,18 +415,15 @@ public: } // the same as a function (returns true on success) - bool Init(const wxString& name, - const wxString& shortName = wxEmptyString, - const wxString& locale = wxEmptyString, - bool bLoadDefault = true -#if WXWIN_COMPATIBILITY_2_8 - ,bool bConvertEncoding = true -#endif - ); + bool Init(const wxChar *szName, + const wxChar *szShort = (const wxChar *) NULL, + const wxChar *szLocale = (const wxChar *) NULL, + bool bLoadDefault = true, + bool bConvertEncoding = false); // same as second ctor (returns true on success) bool Init(int language = wxLANGUAGE_DEFAULT, - int flags = wxLOCALE_LOAD_DEFAULT); + int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); // restores old locale virtual ~wxLocale(); @@ -211,14 +442,13 @@ public: // get the values of the given locale-dependent datum: the current locale // is used, the US default value is returned if everything else fails - static wxString GetInfo(wxLocaleInfo index, - wxLocaleCategory cat = wxLOCALE_CAT_DEFAULT); + static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat); // return true if the locale was set successfully bool IsOk() const { return m_pszOldLocale != NULL; } // returns locale name - const wxString& GetLocale() const { return m_strLocale; } + const wxChar *GetLocale() const { return m_strLocale; } // return current locale wxLanguage value int GetLanguage() const { return m_language; } @@ -236,8 +466,7 @@ public: // (in this order). // // This only applies to subsequent invocations of AddCatalog()! - static void AddCatalogLookupPathPrefix(const wxString& prefix) - { wxFileTranslationsLoader::AddCatalogLookupPathPrefix(prefix); } + static void AddCatalogLookupPathPrefix(const wxString& prefix); // add a catalog: it's searched for in standard places (current directory // first, system one after), but the you may prepend additional directories to @@ -246,16 +475,15 @@ public: // The loaded catalog will be used for message lookup by GetString(). // // Returns 'true' if it was successfully loaded - bool AddCatalog(const wxString& domain); - bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage); - bool AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage, const wxString& msgIdCharset); + bool AddCatalog(const wxChar *szDomain); + bool AddCatalog(const wxChar *szDomain, + wxLanguage msgIdLanguage, const wxChar *msgIdCharset); // check if the given locale is provided by OS and C run time static bool IsAvailable(int lang); // check if the given catalog is loaded - bool IsLoaded(const wxString& domain) const; + bool IsLoaded(const wxChar *szDomain) const; // Retrieve the language info struct for the given language // @@ -266,10 +494,6 @@ public: // is not in database static wxString GetLanguageName(int lang); - // Returns ISO code ("canonical name") of language or empty string if the - // language is not in database - static wxString GetLanguageCanonicalName(int lang); - // Find the language for the given locale string which may be either a // canonical ISO 2 letter language code ("xx"), a language code followed by // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") @@ -293,26 +517,20 @@ public: // // domains are searched in the last to first order, i.e. catalogs // added later override those added before. - const wxString& GetString(const wxString& origString, - const wxString& domain = wxEmptyString) const - { - return wxGetTranslation(origString, domain); - } + virtual const wxChar *GetString(const wxChar *szOrigString, + const wxChar *szDomain = NULL) const; // plural form version of the same: - const wxString& GetString(const wxString& origString, - const wxString& origString2, - unsigned n, - const wxString& domain = wxEmptyString) const - { - return wxGetTranslation(origString, origString2, n, domain); - } + virtual const wxChar *GetString(const wxChar *szOrigString, + const wxChar *szOrigString2, + size_t n, + const wxChar *szDomain = NULL) const; // Returns the current short name for the locale const wxString& GetName() const { return m_strShort; } // return the contents of .po file header - wxString GetHeaderValue(const wxString& header, - const wxString& domain = wxEmptyString) const; + wxString GetHeaderValue( const wxChar* szHeader, + const wxChar* szDomain = NULL ) const; // These two methods are for internal use only. First one creates // ms_languagesDB if it doesn't already exist, second one destroys @@ -321,9 +539,8 @@ public: static void DestroyLanguagesDB(); private: - bool DoInit(const wxString& name, - const wxString& shortName, - const wxString& locale); + // find catalog by name in a linked list, return NULL if !found + wxMsgCatalog *FindCatalog(const wxChar *szDomain) const; // copy default table of languages from global static array to // m_langugagesInfo, called by InitLanguagesDB @@ -336,16 +553,18 @@ private: m_strShort; // short name for the locale int m_language; // this locale wxLanguage value - const char *m_pszOldLocale; // previous locale from setlocale() + const wxChar *m_pszOldLocale; // previous locale from setlocale() wxLocale *m_pOldLocale; // previous wxLocale + wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs + + bool m_bConvertEncoding; + bool m_initialized; - wxTranslations m_translations; - static wxLanguageInfoArray *ms_languagesDB; - wxDECLARE_NO_COPY_CLASS(wxLocale); + DECLARE_NO_COPY_CLASS(wxLocale) }; // ---------------------------------------------------------------------------- @@ -355,6 +574,59 @@ private: // get the current locale object (note that it may be NULL!) extern WXDLLIMPEXP_BASE wxLocale* wxGetLocale(); -#endif // wxUSE_INTL +// get the translation of the string in the current locale +inline const wxChar * +wxGetTranslation(const wxChar *sz, const wxChar* domain = NULL) +{ + wxLocale *pLoc = wxGetLocale(); + if (pLoc) + return pLoc->GetString(sz, domain); + else + return sz; +} + +inline const wxChar * +wxGetTranslation(const wxChar *sz1, const wxChar *sz2, + size_t n, + const wxChar *domain = NULL) +{ + wxLocale *pLoc = wxGetLocale(); + if (pLoc) + return pLoc->GetString(sz1, sz2, n, domain); + else + return n == 1 ? sz1 : sz2; +} + +#else // !wxUSE_INTL + +// the macros should still be defined - otherwise compilation would fail + +#if !defined(WXINTL_NO_GETTEXT_MACRO) + #if !defined(_) + #define _(s) (wxT(s)) + #endif + #define wxPLURAL(sing, plur, n) ((n) == 1 ? wxT(sing) : wxT(plur)) +#endif + +#define wxTRANSLATE(str) wxT(str) + +inline const wxChar * +wxGetTranslation(const wxChar *sz, const wxChar * WXUNUSED(domain) = NULL) +{ + return sz; +} + +#endif // wxUSE_INTL/!wxUSE_INTL + +// define this one just in case it occurs somewhere (instead of preferred +// wxTRANSLATE) too +#if !defined(WXINTL_NO_GETTEXT_MACRO) + #if !defined(gettext_noop) + #define gettext_noop(str) wxT(str) + #endif + #if !defined(N_) + #define N_(s) wxT(s) + #endif +#endif #endif // _WX_INTL_H_ diff --git a/Source/3rd Party/wx/include/wx/iosfwrap.h b/Source/3rd Party/wx/include/wx/iosfwrap.h index 8dce36de0..0a68afcc2 100644 --- a/Source/3rd Party/wx/include/wx/iosfwrap.h +++ b/Source/3rd Party/wx/include/wx/iosfwrap.h @@ -4,6 +4,7 @@ // Author: Jan van Dijk // Modified by: // Created: 18.12.2002 +// RCS-ID: $Id: iosfwrap.h 33555 2005-04-12 21:06:03Z ABX $ // Copyright: wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ # include #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ # include "wx/msw/winundef.h" #endif diff --git a/Source/3rd Party/wx/include/wx/ioswrap.h b/Source/3rd Party/wx/include/wx/ioswrap.h index 10817d28b..19292af5d 100644 --- a/Source/3rd Party/wx/include/wx/ioswrap.h +++ b/Source/3rd Party/wx/include/wx/ioswrap.h @@ -4,23 +4,20 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.02.99 +// RCS-ID: $Id: ioswrap.h 33555 2005-04-12 21:06:03Z ABX $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #if wxUSE_STD_IOSTREAM -#include "wx/beforestd.h" - #if wxUSE_IOSTREAMH # include #else # include #endif -#include "wx/afterstd.h" - -#ifdef __WINDOWS__ +#ifdef __WXMSW__ # include "wx/msw/winundef.h" #endif diff --git a/Source/3rd Party/wx/include/wx/ipc.h b/Source/3rd Party/wx/include/wx/ipc.h deleted file mode 100644 index 36542e5f0..000000000 --- a/Source/3rd Party/wx/include/wx/ipc.h +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/ipc.h -// Purpose: wrapper around different wxIPC classes implementations -// Author: Vadim Zeitlin -// Modified by: -// Created: 15.04.02 -// Copyright: (c) 2002 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_IPC_H_ -#define _WX_IPC_H_ - -// Set wxUSE_DDE_FOR_IPC to 1 to use DDE for IPC under Windows. If it is set to -// 0, or if the platform is not Windows, use TCP/IP for IPC implementation - -#if !defined(wxUSE_DDE_FOR_IPC) - #ifdef __WINDOWS__ - #define wxUSE_DDE_FOR_IPC 1 - #else - #define wxUSE_DDE_FOR_IPC 0 - #endif -#endif // !defined(wxUSE_DDE_FOR_IPC) - -#if !defined(__WINDOWS__) - #undef wxUSE_DDE_FOR_IPC - #define wxUSE_DDE_FOR_IPC 0 -#endif - -#if wxUSE_DDE_FOR_IPC - #define wxConnection wxDDEConnection - #define wxServer wxDDEServer - #define wxClient wxDDEClient - - #include "wx/dde.h" -#else // !wxUSE_DDE_FOR_IPC - #define wxConnection wxTCPConnection - #define wxServer wxTCPServer - #define wxClient wxTCPClient - - #include "wx/sckipc.h" -#endif // wxUSE_DDE_FOR_IPC/!wxUSE_DDE_FOR_IPC - -#endif // _WX_IPC_H_ diff --git a/Source/3rd Party/wx/include/wx/ipcbase.h b/Source/3rd Party/wx/include/wx/ipcbase.h index 226ad6dbc..d2a48f621 100644 --- a/Source/3rd Party/wx/include/wx/ipcbase.h +++ b/Source/3rd Party/wx/include/wx/ipcbase.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/ipcbase.h +// Name: ipcbase.h // Purpose: Base classes for IPC // Author: Julian Smart // Modified by: // Created: 4/1/98 +// RCS-ID: $Id: ipcbase.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,19 +31,10 @@ enum wxIPCFormat wxIPC_PENDATA = 10, wxIPC_RIFF = 11, wxIPC_WAVE = 12, - wxIPC_UTF16TEXT = 13, /* CF_UNICODE */ + wxIPC_UNICODETEXT = 13, wxIPC_ENHMETAFILE = 14, wxIPC_FILENAME = 15, /* CF_HDROP */ wxIPC_LOCALE = 16, - wxIPC_UTF8TEXT = 17, - wxIPC_UTF32TEXT = 18, -#if SIZEOF_WCHAR_T == 2 - wxIPC_UNICODETEXT = wxIPC_UTF16TEXT, -#elif SIZEOF_WCHAR_T == 4 - wxIPC_UNICODETEXT = wxIPC_UTF32TEXT, -#else -# error "Unknown wchar_t size" -#endif wxIPC_PRIVATE = 20 }; @@ -51,201 +43,110 @@ class WXDLLIMPEXP_FWD_BASE wxClientBase; class WXDLLIMPEXP_BASE wxConnectionBase: public wxObject { + DECLARE_CLASS(wxConnectionBase) + public: - wxConnectionBase(void *buffer, size_t size); // use external buffer + wxConnectionBase(wxChar *buffer, int size); // use external buffer wxConnectionBase(); // use internal, adaptive buffer wxConnectionBase(const wxConnectionBase& copy); - virtual ~wxConnectionBase(); + virtual ~wxConnectionBase(void); void SetConnected( bool c ) { m_connected = c; } bool GetConnected() { return m_connected; } // Calls that CLIENT can make - bool Execute(const void *data, size_t size, wxIPCFormat fmt = wxIPC_PRIVATE) - { return DoExecute(data, size, fmt); } - bool Execute(const char *s, size_t size = wxNO_LEN) - { return DoExecute(s, size == wxNO_LEN ? strlen(s) + 1 - : size, wxIPC_TEXT); } - bool Execute(const wchar_t *ws, size_t size = wxNO_LEN) - { return DoExecute(ws, size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t) - : size, wxIPC_UNICODETEXT); } - bool Execute(const wxString& s) - { - const wxScopedCharBuffer buf = s.utf8_str(); - return DoExecute(buf, strlen(buf) + 1, wxIPC_UTF8TEXT); - } - bool Execute(const wxCStrData& cs) - { return Execute(cs.AsString()); } - - virtual const void *Request(const wxString& item, - size_t *size = NULL, - wxIPCFormat format = wxIPC_TEXT) = 0; - - bool Poke(const wxString& item, const void *data, size_t size, - wxIPCFormat fmt = wxIPC_PRIVATE) - { return DoPoke(item, data, size, fmt); } - bool Poke(const wxString& item, const char *s, size_t size = wxNO_LEN) - { return DoPoke(item, s, size == wxNO_LEN ? strlen(s) + 1 - : size, wxIPC_TEXT); } - bool Poke(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN) - { return DoPoke(item, ws, - size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t) - : size, wxIPC_UNICODETEXT); } - bool Poke(const wxString& item, const wxString s) - { - const wxScopedCharBuffer buf = s.utf8_str(); - return DoPoke(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT); - } - bool Poke(const wxString& item, const wxCStrData& cs) - { return Poke(item, cs.AsString()); } - + virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0; + virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); } + virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0; + virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0; virtual bool StartAdvise(const wxString& item) = 0; virtual bool StopAdvise(const wxString& item) = 0; // Calls that SERVER can make - bool Advise(const wxString& item, const void *data, size_t size, - wxIPCFormat fmt = wxIPC_PRIVATE) - { return DoAdvise(item, data, size, fmt); } - bool Advise(const wxString& item, const char *s, size_t size = wxNO_LEN) - { return DoAdvise(item, s, size == wxNO_LEN ? strlen(s) + 1 - : size, wxIPC_TEXT); } - bool Advise(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN) - { return DoAdvise(item, ws, - size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t) - : size, wxIPC_UNICODETEXT); } - bool Advise(const wxString& item, const wxString s) - { - const wxScopedCharBuffer buf = s.utf8_str(); - return DoAdvise(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT); - } - bool Advise(const wxString& item, const wxCStrData& cs) - { return Advise(item, cs.AsString()); } + virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0; // Calls that both can make - virtual bool Disconnect() = 0; - + virtual bool Disconnect(void) = 0; // Callbacks to SERVER - override at will - virtual bool OnExec(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(data)) - { - wxFAIL_MSG( "This method shouldn't be called, if it is, it probably " - "means that you didn't update your old code overriding " - "OnExecute() to use the new parameter types (\"const void *\" " - "instead of \"wxChar *\" and \"size_t\" instead of \"int\"), " - "you must do it or your code wouldn't be executed at all!" ); - return false; - } + virtual bool OnExecute ( const wxString& WXUNUSED(topic), + wxChar *WXUNUSED(data), + int WXUNUSED(size), + wxIPCFormat WXUNUSED(format) ) + { return false; } - // deprecated function kept for backwards compatibility: usually you will - // want to override OnExec() above instead which receives its data in a more - // convenient format - virtual bool OnExecute(const wxString& topic, - const void *data, - size_t size, - wxIPCFormat format) - { return OnExec(topic, GetTextFromData(data, size, format)); } + virtual wxChar *OnRequest ( const wxString& WXUNUSED(topic), + const wxString& WXUNUSED(item), + int *WXUNUSED(size), + wxIPCFormat WXUNUSED(format) ) + { return (wxChar *) NULL; } - virtual const void *OnRequest(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(item), - size_t *size, - wxIPCFormat WXUNUSED(format)) - { *size = 0; return NULL; } + virtual bool OnPoke ( const wxString& WXUNUSED(topic), + const wxString& WXUNUSED(item), + wxChar *WXUNUSED(data), + int WXUNUSED(size), + wxIPCFormat WXUNUSED(format) ) + { return false; } - virtual bool OnPoke(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(item), - const void *WXUNUSED(data), - size_t WXUNUSED(size), - wxIPCFormat WXUNUSED(format)) - { return false; } + virtual bool OnStartAdvise ( const wxString& WXUNUSED(topic), + const wxString& WXUNUSED(item) ) + { return false; } - virtual bool OnStartAdvise(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(item)) - { return false; } - - virtual bool OnStopAdvise(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(item)) - { return false; } + virtual bool OnStopAdvise ( const wxString& WXUNUSED(topic), + const wxString& WXUNUSED(item) ) + { return false; } // Callbacks to CLIENT - override at will - virtual bool OnAdvise(const wxString& WXUNUSED(topic), - const wxString& WXUNUSED(item), - const void *WXUNUSED(data), - size_t WXUNUSED(size), - wxIPCFormat WXUNUSED(format)) - { return false; } - - // Callbacks to BOTH - virtual bool OnDisconnect() { delete this; return true; } - - - // return true if this is one of the formats used for textual data - // transmission - static bool IsTextFormat(wxIPCFormat format) - { - return format == wxIPC_TEXT || - format == wxIPC_UTF8TEXT || - format == wxIPC_UTF16TEXT || - format == wxIPC_UTF32TEXT; - } - - // converts from the data and format into a wxString automatically - // - // this function accepts data in all of wxIPC_TEXT, wxIPC_UNICODETEXT, and - // wxIPC_UTF8TEXT formats but asserts if the format is anything else (i.e. - // such that IsTextFormat(format) doesn't return true) - // - // notice that the size parameter here contains the total size of the data, - // including the terminating '\0' or L'\0' - static - wxString GetTextFromData(const void *data, size_t size, wxIPCFormat format); + virtual bool OnAdvise ( const wxString& WXUNUSED(topic), + const wxString& WXUNUSED(item), + wxChar *WXUNUSED(data), + int WXUNUSED(size), + wxIPCFormat WXUNUSED(format) ) + { return false; } + // Callbacks to BOTH - override at will + // Default behaviour is to delete connection and return true + virtual bool OnDisconnect(void) = 0; // return a buffer at least this size, reallocating buffer if needed - // returns NULL if using an inadequate user buffer which can't be resized - void *GetBufferAtLeast(size_t bytes); - -protected: - virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format) = 0; - virtual bool DoPoke(const wxString& item, const void *data, size_t size, - wxIPCFormat format) = 0; - virtual bool DoAdvise(const wxString& item, const void *data, size_t size, - wxIPCFormat format) = 0; - - -private: - char *m_buffer; - size_t m_buffersize; - bool m_deletebufferwhendone; + // returns NULL if using an inadequate user buffer - it can't be resized + wxChar * GetBufferAtLeast( size_t bytes ); protected: bool m_connected; +private: + wxChar * m_buffer; + size_t m_buffersize; + bool m_deletebufferwhendone; - wxDECLARE_NO_ASSIGN_CLASS(wxConnectionBase); - DECLARE_CLASS(wxConnectionBase) + // can't use DECLARE_NO_COPY_CLASS(wxConnectionBase) because we already + // have copy ctor but still forbid the default assignment operator + wxConnectionBase& operator=(const wxConnectionBase&); }; -class WXDLLIMPEXP_BASE wxServerBase : public wxObject +class WXDLLIMPEXP_BASE wxServerBase: public wxObject { + DECLARE_CLASS(wxServerBase) + public: - wxServerBase() { } - virtual ~wxServerBase() { } + inline wxServerBase(void) {} + inline ~wxServerBase(void) {} // Returns false on error (e.g. port number is already in use) virtual bool Create(const wxString& serverName) = 0; // Callbacks to SERVER - override at will virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) = 0; - - DECLARE_CLASS(wxServerBase) }; -class WXDLLIMPEXP_BASE wxClientBase : public wxObject +class WXDLLIMPEXP_BASE wxClientBase: public wxObject { + DECLARE_CLASS(wxClientBase) + public: - wxClientBase() { } - virtual ~wxClientBase() { } + inline wxClientBase(void) {} + inline ~wxClientBase(void) {} virtual bool ValidHost(const wxString& host) = 0; @@ -255,9 +156,8 @@ public: const wxString& topic) = 0; // Callbacks to CLIENT - override at will - virtual wxConnectionBase *OnMakeConnection() = 0; - - DECLARE_CLASS(wxClientBase) + virtual wxConnectionBase *OnMakeConnection(void) = 0; }; -#endif // _WX_IPCBASEH__ +#endif + // _WX_IPCBASEH__ diff --git a/Source/3rd Party/wx/include/wx/itemid.h b/Source/3rd Party/wx/include/wx/itemid.h deleted file mode 100644 index 99897e9c1..000000000 --- a/Source/3rd Party/wx/include/wx/itemid.h +++ /dev/null @@ -1,61 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/itemid.h -// Purpose: wxItemId class declaration. -// Author: Vadim Zeitlin -// Created: 2011-08-17 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ITEMID_H_ -#define _WX_ITEMID_H_ - -// ---------------------------------------------------------------------------- -// wxItemId: an opaque item identifier used with wx{Tree,TreeList,DataView}Ctrl. -// ---------------------------------------------------------------------------- - -// The template argument T is typically a pointer to some opaque type. While -// wxTreeItemId and wxDataViewItem use a pointer to void, this is dangerous and -// not recommended for the new item id classes. -template -class wxItemId -{ -public: - typedef T Type; - - // This ctor is implicit which is fine for non-void* types, but if you use - // this class with void* you're strongly advised to make the derived class - // ctor explicit as implicitly converting from any pointer is simply too - // dangerous. - wxItemId(Type item = NULL) : m_pItem(item) { } - - // Default copy ctor, assignment operator and dtor are ok. - - bool IsOk() const { return m_pItem != NULL; } - Type GetID() const { return m_pItem; } - operator const Type() const { return m_pItem; } - - // This is used for implementation purposes only. - Type operator->() const { return m_pItem; } - - void Unset() { m_pItem = NULL; } - - // This field is public *only* for compatibility with the old wxTreeItemId - // implementation and must not be used in any new code. -//private: - Type m_pItem; -}; - -template -bool operator==(const wxItemId& left, const wxItemId& right) -{ - return left.GetID() == right.GetID(); -} - -template -bool operator!=(const wxItemId& left, const wxItemId& right) -{ - return !(left == right); -} - -#endif // _WX_ITEMID_H_ diff --git a/Source/3rd Party/wx/include/wx/joystick.h b/Source/3rd Party/wx/include/wx/joystick.h deleted file mode 100644 index 733ad7de8..000000000 --- a/Source/3rd Party/wx/include/wx/joystick.h +++ /dev/null @@ -1,37 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/joystick.h -// Purpose: wxJoystick base header -// Author: wxWidgets Team -// Modified by: -// Created: -// Copyright: (c) wxWidgets Team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_JOYSTICK_H_BASE_ -#define _WX_JOYSTICK_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_JOYSTICK - -#if defined(__WINDOWS__) -#include "wx/msw/joystick.h" -#elif defined(__WXMOTIF__) -#include "wx/unix/joystick.h" -#elif defined(__WXGTK__) -#include "wx/unix/joystick.h" -#elif defined(__WXX11__) -#include "wx/unix/joystick.h" -#elif defined(__DARWIN__) -#include "wx/osx/core/joystick.h" -#elif defined(__WXMAC__) -#include "wx/osx/joystick.h" -#elif defined(__WXPM__) -#include "wx/os2/joystick.h" -#endif - -#endif // wxUSE_JOYSTICK - -#endif - // _WX_JOYSTICK_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/kbdstate.h b/Source/3rd Party/wx/include/wx/kbdstate.h deleted file mode 100644 index ab0df32d1..000000000 --- a/Source/3rd Party/wx/include/wx/kbdstate.h +++ /dev/null @@ -1,121 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/kbdstate.h -// Purpose: Declaration of wxKeyboardState class -// Author: Vadim Zeitlin -// Created: 2008-09-19 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_KBDSTATE_H_ -#define _WX_KBDSTATE_H_ - -#include "wx/defs.h" - -// ---------------------------------------------------------------------------- -// wxKeyboardState stores the state of the keyboard modifier keys -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxKeyboardState -{ -public: - wxKeyboardState(bool controlDown = false, - bool shiftDown = false, - bool altDown = false, - bool metaDown = false) - : m_controlDown(controlDown), - m_shiftDown(shiftDown), - m_altDown(altDown), - m_metaDown(metaDown) -#ifdef __WXOSX__ - ,m_rawControlDown(false) -#endif - { - } - - // default copy ctor, assignment operator and dtor are ok - - - // accessors for the various modifier keys - // --------------------------------------- - - // should be used check if the key event has exactly the given modifiers: - // "GetModifiers() = wxMOD_CONTROL" is easier to write than "ControlDown() - // && !MetaDown() && !AltDown() && !ShiftDown()" - int GetModifiers() const - { - return (m_controlDown ? wxMOD_CONTROL : 0) | - (m_shiftDown ? wxMOD_SHIFT : 0) | - (m_metaDown ? wxMOD_META : 0) | -#ifdef __WXOSX__ - (m_rawControlDown ? wxMOD_RAW_CONTROL : 0) | -#endif - (m_altDown ? wxMOD_ALT : 0); - } - - // returns true if any modifiers at all are pressed - bool HasAnyModifiers() const { return GetModifiers() != wxMOD_NONE; } - - // returns true if any modifiers changing the usual key interpretation are - // pressed, notably excluding Shift - bool HasModifiers() const - { - return ControlDown() || RawControlDown() || AltDown(); - } - - // accessors for individual modifier keys - bool ControlDown() const { return m_controlDown; } - bool RawControlDown() const - { -#ifdef __WXOSX__ - return m_rawControlDown; -#else - return m_controlDown; -#endif - } - bool ShiftDown() const { return m_shiftDown; } - bool MetaDown() const { return m_metaDown; } - bool AltDown() const { return m_altDown; } - - // "Cmd" is a pseudo key which is Control for PC and Unix platforms but - // Apple ("Command") key under Macs: it makes often sense to use it instead - // of, say, ControlDown() because Cmd key is used for the same thing under - // Mac as Ctrl elsewhere (but Ctrl still exists, just not used for this - // purpose under Mac) - bool CmdDown() const - { - return ControlDown(); - } - - // these functions are mostly used by wxWidgets itself - // --------------------------------------------------- - - void SetControlDown(bool down) { m_controlDown = down; } - void SetRawControlDown(bool down) - { -#ifdef __WXOSX__ - m_rawControlDown = down; -#else - m_controlDown = down; -#endif - } - void SetShiftDown(bool down) { m_shiftDown = down; } - void SetAltDown(bool down) { m_altDown = down; } - void SetMetaDown(bool down) { m_metaDown = down; } - - - // for backwards compatibility with the existing code accessing these - // members of wxKeyEvent directly, these variables are public, however you - // should not use them in any new code, please use the accessors instead -public: - bool m_controlDown : 1; - bool m_shiftDown : 1; - bool m_altDown : 1; - bool m_metaDown : 1; -#ifdef __WXOSX__ - bool m_rawControlDown : 1; -#endif -}; - -#endif // _WX_KBDSTATE_H_ - diff --git a/Source/3rd Party/wx/include/wx/language.h b/Source/3rd Party/wx/include/wx/language.h deleted file mode 100644 index bb8a13e52..000000000 --- a/Source/3rd Party/wx/include/wx/language.h +++ /dev/null @@ -1,282 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/language.h -// Purpose: wxLanguage enum -// Author: Vadim Zeitlin -// Created: 2010-04-23 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// WARNING: Parts of this file are generated. See misc/languages/README for -// details. - -#ifndef _WX_LANGUAGE_H_ -#define _WX_LANGUAGE_H_ - -#include "wx/defs.h" - -#if wxUSE_INTL - -// ---------------------------------------------------------------------------- -// wxLanguage: defines all supported languages -// ---------------------------------------------------------------------------- - -// --- --- --- generated code begins here --- --- --- - -/** - The languages supported by wxLocale. - - This enum is generated by misc/languages/genlang.py - When making changes, please put them into misc/languages/langtabl.txt -*/ -enum wxLanguage -{ - /// User's default/preffered language as got from OS. - wxLANGUAGE_DEFAULT, - - /// Unknown language, returned if wxLocale::GetSystemLanguage fails. - wxLANGUAGE_UNKNOWN, - - wxLANGUAGE_ABKHAZIAN, - wxLANGUAGE_AFAR, - wxLANGUAGE_AFRIKAANS, - wxLANGUAGE_ALBANIAN, - wxLANGUAGE_AMHARIC, - wxLANGUAGE_ARABIC, - wxLANGUAGE_ARABIC_ALGERIA, - wxLANGUAGE_ARABIC_BAHRAIN, - wxLANGUAGE_ARABIC_EGYPT, - wxLANGUAGE_ARABIC_IRAQ, - wxLANGUAGE_ARABIC_JORDAN, - wxLANGUAGE_ARABIC_KUWAIT, - wxLANGUAGE_ARABIC_LEBANON, - wxLANGUAGE_ARABIC_LIBYA, - wxLANGUAGE_ARABIC_MOROCCO, - wxLANGUAGE_ARABIC_OMAN, - wxLANGUAGE_ARABIC_QATAR, - wxLANGUAGE_ARABIC_SAUDI_ARABIA, - wxLANGUAGE_ARABIC_SUDAN, - wxLANGUAGE_ARABIC_SYRIA, - wxLANGUAGE_ARABIC_TUNISIA, - wxLANGUAGE_ARABIC_UAE, - wxLANGUAGE_ARABIC_YEMEN, - wxLANGUAGE_ARMENIAN, - wxLANGUAGE_ASSAMESE, - wxLANGUAGE_ASTURIAN, - wxLANGUAGE_AYMARA, - wxLANGUAGE_AZERI, - wxLANGUAGE_AZERI_CYRILLIC, - wxLANGUAGE_AZERI_LATIN, - wxLANGUAGE_BASHKIR, - wxLANGUAGE_BASQUE, - wxLANGUAGE_BELARUSIAN, - wxLANGUAGE_BENGALI, - wxLANGUAGE_BHUTANI, - wxLANGUAGE_BIHARI, - wxLANGUAGE_BISLAMA, - wxLANGUAGE_BOSNIAN, - wxLANGUAGE_BRETON, - wxLANGUAGE_BULGARIAN, - wxLANGUAGE_BURMESE, - wxLANGUAGE_CAMBODIAN, - wxLANGUAGE_CATALAN, - wxLANGUAGE_CHINESE, - wxLANGUAGE_CHINESE_SIMPLIFIED, - wxLANGUAGE_CHINESE_TRADITIONAL, - wxLANGUAGE_CHINESE_HONGKONG, - wxLANGUAGE_CHINESE_MACAU, - wxLANGUAGE_CHINESE_SINGAPORE, - wxLANGUAGE_CHINESE_TAIWAN, - wxLANGUAGE_CORSICAN, - wxLANGUAGE_CROATIAN, - wxLANGUAGE_CZECH, - wxLANGUAGE_DANISH, - wxLANGUAGE_DUTCH, - wxLANGUAGE_DUTCH_BELGIAN, - wxLANGUAGE_ENGLISH, - wxLANGUAGE_ENGLISH_UK, - wxLANGUAGE_ENGLISH_US, - wxLANGUAGE_ENGLISH_AUSTRALIA, - wxLANGUAGE_ENGLISH_BELIZE, - wxLANGUAGE_ENGLISH_BOTSWANA, - wxLANGUAGE_ENGLISH_CANADA, - wxLANGUAGE_ENGLISH_CARIBBEAN, - wxLANGUAGE_ENGLISH_DENMARK, - wxLANGUAGE_ENGLISH_EIRE, - wxLANGUAGE_ENGLISH_JAMAICA, - wxLANGUAGE_ENGLISH_NEW_ZEALAND, - wxLANGUAGE_ENGLISH_PHILIPPINES, - wxLANGUAGE_ENGLISH_SOUTH_AFRICA, - wxLANGUAGE_ENGLISH_TRINIDAD, - wxLANGUAGE_ENGLISH_ZIMBABWE, - wxLANGUAGE_ESPERANTO, - wxLANGUAGE_ESTONIAN, - wxLANGUAGE_FAEROESE, - wxLANGUAGE_FARSI, - wxLANGUAGE_FIJI, - wxLANGUAGE_FINNISH, - wxLANGUAGE_FRENCH, - wxLANGUAGE_FRENCH_BELGIAN, - wxLANGUAGE_FRENCH_CANADIAN, - wxLANGUAGE_FRENCH_LUXEMBOURG, - wxLANGUAGE_FRENCH_MONACO, - wxLANGUAGE_FRENCH_SWISS, - wxLANGUAGE_FRISIAN, - wxLANGUAGE_GALICIAN, - wxLANGUAGE_GEORGIAN, - wxLANGUAGE_GERMAN, - wxLANGUAGE_GERMAN_AUSTRIAN, - wxLANGUAGE_GERMAN_BELGIUM, - wxLANGUAGE_GERMAN_LIECHTENSTEIN, - wxLANGUAGE_GERMAN_LUXEMBOURG, - wxLANGUAGE_GERMAN_SWISS, - wxLANGUAGE_GREEK, - wxLANGUAGE_GREENLANDIC, - wxLANGUAGE_GUARANI, - wxLANGUAGE_GUJARATI, - wxLANGUAGE_HAUSA, - wxLANGUAGE_HEBREW, - wxLANGUAGE_HINDI, - wxLANGUAGE_HUNGARIAN, - wxLANGUAGE_ICELANDIC, - wxLANGUAGE_INDONESIAN, - wxLANGUAGE_INTERLINGUA, - wxLANGUAGE_INTERLINGUE, - wxLANGUAGE_INUKTITUT, - wxLANGUAGE_INUPIAK, - wxLANGUAGE_IRISH, - wxLANGUAGE_ITALIAN, - wxLANGUAGE_ITALIAN_SWISS, - wxLANGUAGE_JAPANESE, - wxLANGUAGE_JAVANESE, - wxLANGUAGE_KANNADA, - wxLANGUAGE_KASHMIRI, - wxLANGUAGE_KASHMIRI_INDIA, - wxLANGUAGE_KAZAKH, - wxLANGUAGE_KERNEWEK, - wxLANGUAGE_KINYARWANDA, - wxLANGUAGE_KIRGHIZ, - wxLANGUAGE_KIRUNDI, - wxLANGUAGE_KONKANI, - wxLANGUAGE_KOREAN, - wxLANGUAGE_KURDISH, - wxLANGUAGE_LAOTHIAN, - wxLANGUAGE_LATIN, - wxLANGUAGE_LATVIAN, - wxLANGUAGE_LINGALA, - wxLANGUAGE_LITHUANIAN, - wxLANGUAGE_MACEDONIAN, - wxLANGUAGE_MALAGASY, - wxLANGUAGE_MALAY, - wxLANGUAGE_MALAYALAM, - wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, - wxLANGUAGE_MALAY_MALAYSIA, - wxLANGUAGE_MALTESE, - wxLANGUAGE_MANIPURI, - wxLANGUAGE_MAORI, - wxLANGUAGE_MARATHI, - wxLANGUAGE_MOLDAVIAN, - wxLANGUAGE_MONGOLIAN, - wxLANGUAGE_NAURU, - wxLANGUAGE_NEPALI, - wxLANGUAGE_NEPALI_INDIA, - wxLANGUAGE_NORWEGIAN_BOKMAL, - wxLANGUAGE_NORWEGIAN_NYNORSK, - wxLANGUAGE_OCCITAN, - wxLANGUAGE_ORIYA, - wxLANGUAGE_OROMO, - wxLANGUAGE_PASHTO, - wxLANGUAGE_POLISH, - wxLANGUAGE_PORTUGUESE, - wxLANGUAGE_PORTUGUESE_BRAZILIAN, - wxLANGUAGE_PUNJABI, - wxLANGUAGE_QUECHUA, - wxLANGUAGE_RHAETO_ROMANCE, - wxLANGUAGE_ROMANIAN, - wxLANGUAGE_RUSSIAN, - wxLANGUAGE_RUSSIAN_UKRAINE, - wxLANGUAGE_SAMI, - wxLANGUAGE_SAMOAN, - wxLANGUAGE_SANGHO, - wxLANGUAGE_SANSKRIT, - wxLANGUAGE_SCOTS_GAELIC, - wxLANGUAGE_SERBIAN, - wxLANGUAGE_SERBIAN_CYRILLIC, - wxLANGUAGE_SERBIAN_LATIN, - wxLANGUAGE_SERBO_CROATIAN, - wxLANGUAGE_SESOTHO, - wxLANGUAGE_SETSWANA, - wxLANGUAGE_SHONA, - wxLANGUAGE_SINDHI, - wxLANGUAGE_SINHALESE, - wxLANGUAGE_SISWATI, - wxLANGUAGE_SLOVAK, - wxLANGUAGE_SLOVENIAN, - wxLANGUAGE_SOMALI, - wxLANGUAGE_SPANISH, - wxLANGUAGE_SPANISH_ARGENTINA, - wxLANGUAGE_SPANISH_BOLIVIA, - wxLANGUAGE_SPANISH_CHILE, - wxLANGUAGE_SPANISH_COLOMBIA, - wxLANGUAGE_SPANISH_COSTA_RICA, - wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, - wxLANGUAGE_SPANISH_ECUADOR, - wxLANGUAGE_SPANISH_EL_SALVADOR, - wxLANGUAGE_SPANISH_GUATEMALA, - wxLANGUAGE_SPANISH_HONDURAS, - wxLANGUAGE_SPANISH_MEXICAN, - wxLANGUAGE_SPANISH_MODERN, - wxLANGUAGE_SPANISH_NICARAGUA, - wxLANGUAGE_SPANISH_PANAMA, - wxLANGUAGE_SPANISH_PARAGUAY, - wxLANGUAGE_SPANISH_PERU, - wxLANGUAGE_SPANISH_PUERTO_RICO, - wxLANGUAGE_SPANISH_URUGUAY, - wxLANGUAGE_SPANISH_US, - wxLANGUAGE_SPANISH_VENEZUELA, - wxLANGUAGE_SUNDANESE, - wxLANGUAGE_SWAHILI, - wxLANGUAGE_SWEDISH, - wxLANGUAGE_SWEDISH_FINLAND, - wxLANGUAGE_TAGALOG, - wxLANGUAGE_TAJIK, - wxLANGUAGE_TAMIL, - wxLANGUAGE_TATAR, - wxLANGUAGE_TELUGU, - wxLANGUAGE_THAI, - wxLANGUAGE_TIBETAN, - wxLANGUAGE_TIGRINYA, - wxLANGUAGE_TONGA, - wxLANGUAGE_TSONGA, - wxLANGUAGE_TURKISH, - wxLANGUAGE_TURKMEN, - wxLANGUAGE_TWI, - wxLANGUAGE_UIGHUR, - wxLANGUAGE_UKRAINIAN, - wxLANGUAGE_URDU, - wxLANGUAGE_URDU_INDIA, - wxLANGUAGE_URDU_PAKISTAN, - wxLANGUAGE_UZBEK, - wxLANGUAGE_UZBEK_CYRILLIC, - wxLANGUAGE_UZBEK_LATIN, - wxLANGUAGE_VALENCIAN, - wxLANGUAGE_VIETNAMESE, - wxLANGUAGE_VOLAPUK, - wxLANGUAGE_WELSH, - wxLANGUAGE_WOLOF, - wxLANGUAGE_XHOSA, - wxLANGUAGE_YIDDISH, - wxLANGUAGE_YORUBA, - wxLANGUAGE_ZHUANG, - wxLANGUAGE_ZULU, - wxLANGUAGE_KABYLE, - - /// For custom, user-defined languages. - wxLANGUAGE_USER_DEFINED -}; - -// --- --- --- generated code ends here --- --- --- - -#endif // wxUSE_INTL - -#endif // _WX_LANGUAGE_H_ diff --git a/Source/3rd Party/wx/include/wx/layout.h b/Source/3rd Party/wx/include/wx/layout.h index 94e56257c..4a6d82d7b 100644 --- a/Source/3rd Party/wx/include/wx/layout.h +++ b/Source/3rd Party/wx/include/wx/layout.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: layout.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -63,7 +64,7 @@ enum wxRelationship // wxIndividualLayoutConstraint: a constraint on window position // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxIndividualLayoutConstraint : public wxObject +class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject { public: wxIndividualLayoutConstraint(); @@ -154,7 +155,7 @@ protected: // wxLayoutConstraints: the complete set of constraints for a window // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxLayoutConstraints : public wxObject +class WXDLLEXPORT wxLayoutConstraints : public wxObject { public: // Edge constraints diff --git a/Source/3rd Party/wx/include/wx/laywin.h b/Source/3rd Party/wx/include/wx/laywin.h deleted file mode 100644 index e3f6b6eee..000000000 --- a/Source/3rd Party/wx/include/wx/laywin.h +++ /dev/null @@ -1,17 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/laywin.h -// Purpose: wxSashLayoutWindow base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_LAYWIN_H_BASE_ -#define _WX_LAYWIN_H_BASE_ - -#include "wx/generic/laywin.h" - -#endif - // _WX_LAYWIN_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/link.h b/Source/3rd Party/wx/include/wx/link.h deleted file mode 100644 index c422fc17a..000000000 --- a/Source/3rd Party/wx/include/wx/link.h +++ /dev/null @@ -1,31 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/link.h -// Purpose: macros to force linking modules which might otherwise be -// discarded by the linker -// Author: Vaclav Slavik -// Copyright: (c) Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_LINK_H_ -#define _WX_LINK_H_ - -// This must be part of the module you want to force: -#define wxFORCE_LINK_THIS_MODULE(module_name) \ - extern void _wx_link_dummy_func_##module_name (); \ - void _wx_link_dummy_func_##module_name () { } - - -// And this must be somewhere where it certainly will be linked: -#define wxFORCE_LINK_MODULE(module_name) \ - extern void _wx_link_dummy_func_##module_name (); \ - static struct wxForceLink##module_name \ - { \ - wxForceLink##module_name() \ - { \ - _wx_link_dummy_func_##module_name (); \ - } \ - } _wx_link_dummy_var_##module_name; - - -#endif // _WX_LINK_H_ diff --git a/Source/3rd Party/wx/include/wx/list.h b/Source/3rd Party/wx/include/wx/list.h index 366479b09..1d3a69af3 100644 --- a/Source/3rd Party/wx/include/wx/list.h +++ b/Source/3rd Party/wx/include/wx/list.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: VZ at 16/11/98: WX_DECLARE_LIST() and typesafe lists added // Created: 29/01/98 +// RCS-ID: $Id: list.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,8 +22,8 @@ like the old class. */ -#ifndef _WX_LIST_H_ -#define _WX_LIST_H_ +#ifndef _WX_LISTH__ +#define _WX_LISTH__ // ----------------------------------------------------------------------------- // headers @@ -31,9 +32,8 @@ #include "wx/defs.h" #include "wx/object.h" #include "wx/string.h" -#include "wx/vector.h" -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #include "wx/beforestd.h" #include #include @@ -45,10 +45,38 @@ // types // ---------------------------------------------------------------------------- +// type of compare function for list sort operation (as in 'qsort'): it should +// return a negative value, 0 or positive value if the first element is less +// than, equal or greater than the second + +extern "C" +{ +typedef int (* LINKAGEMODE wxSortCompareFunction)(const void *elem1, const void *elem2); +} + class WXDLLIMPEXP_FWD_BASE wxObjectListNode; typedef wxObjectListNode wxNode; -#if wxUSE_STD_CONTAINERS +// +typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +#if !defined(wxENUM_KEY_TYPE_DEFINED) +#define wxENUM_KEY_TYPE_DEFINED + +enum wxKeyType +{ + wxKEY_NONE, + wxKEY_INTEGER, + wxKEY_STRING +}; + +#endif + +#if wxUSE_STL #define wxLIST_COMPATIBILITY @@ -65,10 +93,10 @@ typedef wxObjectListNode wxNode; #define WX_DECLARE_LIST_WITH_DECL(elT, liT, decl) \ WX_DECLARE_LIST_XO(elT*, liT, decl) -#if !defined(__VISUALC__) || __VISUALC__ >= 1300 // == !VC6 +#if !defined( __VISUALC__ ) template -class wxList_SortFunction +class WXDLLIMPEXP_BASE wxList_SortFunction { public: wxList_SortFunction(wxSortCompareFunction f) : m_f(f) { } @@ -79,12 +107,12 @@ private: }; #define WX_LIST_SORTFUNCTION( elT, f ) wxList_SortFunction(f) -#define WX_LIST_VC6_WORKAROUND(elT, liT, decl) +#define VC6_WORKAROUND(elT, liT, decl) -#else // if defined( __VISUALC__ ) && __VISUALC__ < 1300 // == VC6 +#else // if defined( __VISUALC__ ) #define WX_LIST_SORTFUNCTION( elT, f ) std::greater( f ) -#define WX_LIST_VC6_WORKAROUND(elT, liT, decl) \ +#define VC6_WORKAROUND(elT, liT, decl) \ decl liT; \ \ /* Workaround for broken VC6 STL incorrectly requires a std::greater<> */ \ @@ -100,26 +128,19 @@ private: bool operator()(const elT X, const elT Y) const \ { \ return m_CompFunc ? \ - ( m_CompFunc( wxListCastElementToVoidPtr(X), \ - wxListCastElementToVoidPtr(Y) ) < 0 ) : \ + ( m_CompFunc( X, Y ) < 0 ) : \ ( X > Y ); \ } \ }; -// helper for std::greater above: -template -inline const void *wxListCastElementToVoidPtr(const T* ptr) { return ptr; } -inline const void *wxListCastElementToVoidPtr(const wxString& str) - { return (const char*)str; } - -#endif // VC6/!VC6 +#endif // defined( __VISUALC__ ) /* Note 1: the outer helper class _WX_LIST_HELPER_##liT below is a workaround for mingw 3.2.3 compiler bug that prevents a static function of liT class from being exported into dll. A minimal code snippet reproducing the bug: - struct WXDLLIMPEXP_CORE Foo + struct WXDLLEXPORT Foo { static void Bar(); struct SomeInnerClass @@ -148,22 +169,21 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) decl _WX_LIST_HELPER_##liT \ { \ typedef elT _WX_LIST_ITEM_TYPE_##liT; \ - typedef std::list BaseListType; \ public: \ - static BaseListType EmptyList; \ static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X ); \ }; \ \ - WX_LIST_VC6_WORKAROUND(elT, liT, decl) \ - class liT : public std::list \ + VC6_WORKAROUND(elT, liT, decl) \ + decl liT : public std::list \ { \ private: \ typedef std::list BaseListType; \ + static BaseListType EmptyList; \ \ bool m_destroy; \ \ public: \ - class compatibility_iterator \ + decl compatibility_iterator \ { \ private: \ /* Workaround for broken VC6 nested class name resolution */ \ @@ -175,7 +195,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) \ public: \ compatibility_iterator() \ - : m_iter(_WX_LIST_HELPER_##liT::EmptyList.end()), m_list( NULL ) {} \ + : m_iter(EmptyList.end()), m_list( NULL ) {} \ compatibility_iterator( liT* li, iterator i ) \ : m_iter( i ), m_list( li ) {} \ compatibility_iterator( const liT* li, iterator i ) \ @@ -217,7 +237,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) } \ int IndexOf() const \ { \ - return *this ? (int)std::distance( m_list->begin(), m_iter ) \ + return *this ? std::distance( m_list->begin(), m_iter ) \ : wxNOT_FOUND; \ } \ }; \ @@ -259,7 +279,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) iterator i = const_cast< liT* >(this)->end(); \ return compatibility_iterator( this, !empty() ? --i : i ); \ } \ - bool Member( elT e ) const \ + compatibility_iterator Member( elT e ) const \ { return Find( e ); } \ compatibility_iterator Nth( int n ) const \ { return Item( n ); } \ @@ -276,7 +296,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) push_front( e ); \ return compatibility_iterator( this, begin() ); \ } \ - compatibility_iterator Insert(const compatibility_iterator & i, elT e)\ + compatibility_iterator Insert(const compatibility_iterator &i, elT e) \ { \ return compatibility_iterator( this, insert( i.m_iter, e ) ); \ } \ @@ -322,7 +342,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) ~liT() { Clear(); } \ \ /* It needs access to our EmptyList */ \ - friend class compatibility_iterator; \ + friend decl compatibility_iterator; \ } #define WX_DECLARE_LIST(elementtype, listname) \ @@ -331,7 +351,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) WX_DECLARE_LIST(elementtype, listname) #define WX_DECLARE_EXPORTED_LIST(elementtype, listname) \ - WX_DECLARE_LIST_WITH_DECL(elementtype, listname, class WXDLLIMPEXP_CORE) + WX_DECLARE_LIST_WITH_DECL(elementtype, listname, class WXDLLEXPORT) #define WX_DECLARE_EXPORTED_LIST_PTR(elementtype, listname) \ WX_DECLARE_EXPORTED_LIST(elementtype, listname) @@ -347,8 +367,13 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) #define WX_DEFINE_EXPORTED_LIST(name) WX_DEFINE_LIST(name) #define WX_DEFINE_USER_EXPORTED_LIST(name) WX_DEFINE_LIST(name) -#else // if !wxUSE_STD_CONTAINERS +#else // if !wxUSE_STL +// due to circular header dependencies this function has to be declared here +// (normally it's found in utils.h which includes itself list.h...) +#if WXWIN_COMPATIBILITY_2_4 +extern WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s); +#endif // undef it to get rid of old, deprecated functions #define wxLIST_COMPATIBILITY @@ -360,7 +385,7 @@ inline const void *wxListCastElementToVoidPtr(const wxString& str) union wxListKeyValue { long integer; - wxString *string; + wxChar *string; }; // a struct which may contain both types of keys @@ -377,17 +402,15 @@ public: { } wxListKey(long i) : m_keyType(wxKEY_INTEGER) { m_key.integer = i; } + wxListKey(const wxChar *s) : m_keyType(wxKEY_STRING) + { m_key.string = wxStrdup(s); } wxListKey(const wxString& s) : m_keyType(wxKEY_STRING) - { m_key.string = new wxString(s); } - wxListKey(const char *s) : m_keyType(wxKEY_STRING) - { m_key.string = new wxString(s); } - wxListKey(const wchar_t *s) : m_keyType(wxKEY_STRING) - { m_key.string = new wxString(s); } + { m_key.string = wxStrdup(s.c_str()); } // accessors wxKeyType GetKeyType() const { return m_keyType; } - const wxString GetString() const - { wxASSERT( m_keyType == wxKEY_STRING ); return *m_key.string; } + const wxChar *GetString() const + { wxASSERT( m_keyType == wxKEY_STRING ); return m_key.string; } long GetNumber() const { wxASSERT( m_keyType == wxKEY_INTEGER ); return m_key.integer; } @@ -400,7 +423,7 @@ public: ~wxListKey() { if ( m_keyType == wxKEY_STRING ) - delete m_key.string; + free(m_key.string); } private: @@ -421,20 +444,20 @@ class WXDLLIMPEXP_BASE wxNodeBase friend class wxListBase; public: // ctor - wxNodeBase(wxListBase *list = NULL, - wxNodeBase *previous = NULL, - wxNodeBase *next = NULL, + wxNodeBase(wxListBase *list = (wxListBase *)NULL, + wxNodeBase *previous = (wxNodeBase *)NULL, + wxNodeBase *next = (wxNodeBase *)NULL, void *data = NULL, const wxListKey& key = wxDefaultListKey); virtual ~wxNodeBase(); // FIXME no check is done that the list is really keyed on strings - wxString GetKeyString() const { return *m_key.string; } + const wxChar *GetKeyString() const { return m_key.string; } long GetKeyInteger() const { return m_key.integer; } // Necessary for some existing code - void SetKeyString(const wxString& s) { m_key.string = new wxString(s); } + void SetKeyString(wxChar* s) { m_key.string = s; } void SetKeyInteger(long i) { m_key.integer = i; } #ifdef wxLIST_COMPATIBILITY @@ -458,7 +481,7 @@ protected: virtual void DeleteData() { } public: // for wxList::iterator - void** GetDataPtr() const { return &(const_cast(this)->m_data); } + void** GetDataPtr() const { return &(((wxNodeBase*)this)->m_data); } private: // optional key stuff wxListKeyValue m_key; @@ -469,7 +492,7 @@ private: wxListBase *m_list; // list we belong to - wxDECLARE_NO_COPY_CLASS(wxNodeBase); + DECLARE_NO_COPY_CLASS(wxNodeBase) }; // ----------------------------------------------------------------------------- @@ -478,9 +501,9 @@ private: class WXDLLIMPEXP_FWD_BASE wxList; -class WXDLLIMPEXP_BASE wxListBase +class WXDLLIMPEXP_BASE wxListBase : public wxObject { -friend class wxNodeBase; // should be able to call DetachNode() +friend class WXDLLIMPEXP_FWD_BASE wxNodeBase; // should be able to call DetachNode() friend class wxHashTableBase; // should be able to call untyped Find() public: @@ -537,6 +560,10 @@ protected: void *data, const wxListKey& key = wxDefaultListKey) = 0; +// Can't access these from derived classes otherwise (bug in Salford C++?) +#ifdef __SALFORDC__ +public: +#endif // ctors // from an array @@ -560,7 +587,7 @@ protected: { wxNodeBase *node = Item(n); - return node ? node->GetData() : NULL; + return node ? node->GetData() : (wxNodeBase *)NULL; } // operations @@ -570,8 +597,7 @@ protected: // append to beginning of list wxNodeBase *Append(void *object); // insert a new item at the beginning of the list - wxNodeBase *Insert(void *object) - { return Insert(static_cast(NULL), object); } + wxNodeBase *Insert(void *object) { return Insert( (wxNodeBase*)NULL, object); } // insert a new item at the given position wxNodeBase *Insert(size_t pos, void *object) { return pos == GetCount() ? Append(object) @@ -581,7 +607,7 @@ protected: // keyed append wxNodeBase *Append(long key, void *object); - wxNodeBase *Append(const wxString& key, void *object); + wxNodeBase *Append(const wxChar *key, void *object); // removes node from the list but doesn't delete it (returns pointer // to the node or NULL if it wasn't found in the list) @@ -675,10 +701,10 @@ private: classexp nodetype : public wxNodeBase \ { \ public: \ - nodetype(wxListBase *list = NULL, \ - nodetype *previous = NULL, \ - nodetype *next = NULL, \ - T *data = NULL, \ + nodetype(wxListBase *list = (wxListBase *)NULL, \ + nodetype *previous = (nodetype *)NULL, \ + nodetype *next = (nodetype *)NULL, \ + T *data = (T *)NULL, \ const wxListKey& key = wxDefaultListKey) \ : wxNodeBase(list, previous, next, data, key) { } \ \ @@ -722,7 +748,7 @@ private: : wxListBase(count, (void **)elements) { } \ \ name& operator=(const name& list) \ - { if (&list != this) Assign(list); return *this; } \ + { Assign(list); return *this; } \ \ nodetype *GetFirst() const \ { return (nodetype *)wxListBase::GetFirst(); } \ @@ -735,14 +761,13 @@ private: T *operator[](size_t index) const \ { \ nodetype *node = Item(index); \ - return node ? (T*)(node->GetData()) : NULL; \ + return node ? (T*)(node->GetData()) : (T*)NULL; \ } \ \ nodetype *Append(Tbase *object) \ { return (nodetype *)wxListBase::Append(object); } \ nodetype *Insert(Tbase *object) \ - { return (nodetype *)Insert(static_cast(NULL), \ - object); } \ + { return (nodetype *)Insert((nodetype*)NULL, object); } \ nodetype *Insert(size_t pos, Tbase *object) \ { return (nodetype *)wxListBase::Insert(pos, object); } \ nodetype *Insert(nodetype *prev, Tbase *object) \ @@ -768,9 +793,6 @@ private: virtual nodetype *Find(const wxListKey& key) const \ { return (nodetype *)wxListBase::Find(key); } \ \ - bool Member(const Tbase *object) const \ - { return Find(object) != NULL; } \ - \ int IndexOf(Tbase *object) const \ { return wxListBase::IndexOf(object); } \ \ @@ -820,19 +842,9 @@ private: reference_type operator*() const \ { return *(pointer_type)m_node->GetDataPtr(); } \ ptrop \ - itor& operator++() \ - { \ - wxASSERT_MSG( m_node, wxT("uninitialized iterator") ); \ - m_node = m_node->GetNext(); \ - return *this; \ - } \ + itor& operator++() { m_node = m_node->GetNext(); return *this; }\ const itor operator++(int) \ - { \ - itor tmp = *this; \ - wxASSERT_MSG( m_node, wxT("uninitialized iterator") ); \ - m_node = m_node->GetNext(); \ - return tmp; \ - } \ + { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }\ itor& operator--() \ { \ m_node = m_node ? m_node->GetPrevious() : m_init; \ @@ -873,19 +885,9 @@ private: reference_type operator*() const \ { return *(pointer_type)m_node->GetDataPtr(); } \ ptrop \ - itor& operator++() \ - { \ - wxASSERT_MSG( m_node, wxT("uninitialized iterator") ); \ - m_node = m_node->GetNext(); \ - return *this; \ - } \ + itor& operator++() { m_node = m_node->GetNext(); return *this; }\ const itor operator++(int) \ - { \ - itor tmp = *this; \ - wxASSERT_MSG( m_node, wxT("uninitialized iterator") ); \ - m_node = m_node->GetNext(); \ - return tmp; \ - } \ + { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }\ itor& operator--() \ { \ m_node = m_node ? m_node->GetPrevious() : m_init; \ @@ -1031,33 +1033,21 @@ private: for(size_type i = 0; i < n; ++i) \ Append((const_base_reference)v); \ } \ - iterator insert(const iterator& it, const_reference v) \ + iterator insert(const iterator& it, const_reference v = value_type())\ { \ if ( it == end() ) \ - { \ Append((const_base_reference)v); \ - /* \ - note that this is the new end(), the old one was \ - invalidated by the Append() call, and this is why we \ - can't use the same code as in the normal case below \ - */ \ - iterator itins(end()); \ - return --itins; \ - } \ else \ - { \ Insert(it.m_node, (const_base_reference)v); \ - iterator itins(it); \ - return --itins; \ - } \ + iterator itprev(it); \ + return itprev--; \ } \ - void insert(const iterator& it, size_type n, const_reference v) \ + void insert(const iterator& it, size_type n, const_reference v = value_type())\ { \ for(size_type i = 0; i < n; ++i) \ insert(it, v); \ } \ - void insert(const iterator& it, \ - const_iterator first, const const_iterator& last) \ + void insert(const iterator& it, const_iterator first, const const_iterator& last)\ { \ for(; first != last; ++first) \ insert(it, *first); \ @@ -1129,11 +1119,11 @@ private: WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node, decl) #define WX_DECLARE_EXPORTED_LIST(elementtype, listname) \ - WX_DECLARE_LIST_WITH_DECL(elementtype, listname, class WXDLLIMPEXP_CORE) + WX_DECLARE_LIST_WITH_DECL(elementtype, listname, class WXDLLEXPORT) #define WX_DECLARE_EXPORTED_LIST_PTR(elementtype, listname) \ typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \ - WX_DECLARE_LIST_PTR_2(elementtype, listname, wx##listname##Node, class WXDLLIMPEXP_CORE) + WX_DECLARE_LIST_PTR_2(elementtype, listname, wx##listname##Node, class WXDLLEXPORT) #define WX_DECLARE_USER_EXPORTED_LIST(elementtype, listname, usergoo) \ typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \ @@ -1149,7 +1139,7 @@ private: #define WX_DEFINE_EXPORTED_LIST(name) WX_DEFINE_LIST(name) #define WX_DEFINE_USER_EXPORTED_LIST(name) WX_DEFINE_LIST(name) -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL // ============================================================================ // now we can define classes 100% compatible with the old ones @@ -1163,7 +1153,7 @@ private: // inline compatibility functions -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL // ---------------------------------------------------------------------------- // wxNodeBase deprecated methods @@ -1198,43 +1188,36 @@ WX_DECLARE_LIST_2(wxObject, wxObjectList, wxObjectListNode, class WXDLLIMPEXP_BASE wxList : public wxObjectList { public: -#if defined(wxWARN_COMPAT_LIST_USE) && !wxUSE_STD_CONTAINERS - wxList() { } +#if defined(wxWARN_COMPAT_LIST_USE) && !wxUSE_STL + wxList() { }; wxDEPRECATED( wxList(int key_type) ); -#elif !wxUSE_STD_CONTAINERS +#elif !wxUSE_STL wxList(int key_type = wxKEY_NONE); #endif // this destructor is required for Darwin ~wxList() { } -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL wxList& operator=(const wxList& list) - { if (&list != this) Assign(list); return *this; } + { (void) wxListBase::operator=(list); return *this; } // compatibility methods void Sort(wxSortCompareFunction compfunc) { wxListBase::Sort(compfunc); } -#endif // !wxUSE_STD_CONTAINERS +#endif -#ifndef __VISUALC6__ - template - wxVector AsVector() const - { - wxVector vector(size()); - size_t i = 0; - - for ( const_iterator it = begin(); it != end(); ++it ) - { - vector[i++] = static_cast(*it); - } - - return vector; - } -#endif // !__VISUALC6__ +#if wxUSE_STL +#else + wxNode *Member(wxObject *object) const { return (wxNode *)Find(object); } +#endif +private: +#if !wxUSE_STL + DECLARE_DYNAMIC_CLASS(wxList) +#endif }; -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL // ----------------------------------------------------------------------------- // wxStringList class for compatibility with the old code @@ -1248,24 +1231,17 @@ public: // default #ifdef wxWARN_COMPAT_LIST_USE wxStringList(); - wxDEPRECATED( wxStringList(const wxChar *first ...) ); // FIXME-UTF8 + wxDEPRECATED( wxStringList(const wxChar *first ...) ); #else wxStringList(); - wxStringList(const wxChar *first ...); // FIXME-UTF8 + wxStringList(const wxChar *first ...); #endif // copying the string list: the strings are copied, too (extremely // inefficient!) wxStringList(const wxStringList& other) : wxStringListBase() { DeleteContents(true); DoCopy(other); } wxStringList& operator=(const wxStringList& other) - { - if (&other != this) - { - Clear(); - DoCopy(other); - } - return *this; - } + { Clear(); DoCopy(other); return *this; } // operations // makes a copy of the string @@ -1284,9 +1260,11 @@ public: private: void DoCopy(const wxStringList&); // common part of copy ctor and operator= + + DECLARE_DYNAMIC_CLASS(wxStringList) }; -#else // if wxUSE_STD_CONTAINERS +#else // if wxUSE_STL WX_DECLARE_LIST_XO(wxString, wxStringListBase, class WXDLLIMPEXP_BASE); @@ -1309,7 +1287,7 @@ public: { push_front(s); return GetFirst(); } }; -#endif // wxUSE_STD_CONTAINERS +#endif // wxUSE_STL #endif // wxLIST_COMPATIBILITY @@ -1327,15 +1305,4 @@ public: (list).clear(); \ } -// append all element of one list to another one -#define WX_APPEND_LIST(list, other) \ - { \ - wxList::compatibility_iterator node = other->GetFirst(); \ - while ( node ) \ - { \ - (list)->push_back(node->GetData()); \ - node = node->GetNext(); \ - } \ - } - #endif // _WX_LISTH__ diff --git a/Source/3rd Party/wx/include/wx/listbase.h b/Source/3rd Party/wx/include/wx/listbase.h index f74f967c2..152864786 100644 --- a/Source/3rd Party/wx/include/wx/listbase.h +++ b/Source/3rd Party/wx/include/wx/listbase.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 04.12.99 +// RCS-ID: $Id: listbase.h 46313 2007-06-03 22:38:28Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,17 +16,13 @@ #include "wx/font.h" #include "wx/gdicmn.h" #include "wx/event.h" -#include "wx/control.h" - -class WXDLLIMPEXP_FWD_CORE wxImageList; // ---------------------------------------------------------------------------- // types // ---------------------------------------------------------------------------- // type of compare function for wxListCtrl sort operation -typedef -int (wxCALLBACK *wxListCtrlCompare)(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData); +typedef int (wxCALLBACK *wxListCtrlCompare)(long item1, long item2, long sortData); // ---------------------------------------------------------------------------- // wxListCtrl constants @@ -164,7 +161,7 @@ enum // TODO: this should be renamed to wxItemAttr or something general like this // and used as base class for wxTextAttr which duplicates this class // entirely currently -class WXDLLIMPEXP_CORE wxListItemAttr +class WXDLLEXPORT wxListItemAttr { public: // ctors @@ -185,9 +182,9 @@ public: void SetFont(const wxFont& font) { m_font = font; } // accessors - bool HasTextColour() const { return m_colText.IsOk(); } - bool HasBackgroundColour() const { return m_colBack.IsOk(); } - bool HasFont() const { return m_font.IsOk(); } + bool HasTextColour() const { return m_colText.Ok(); } + bool HasBackgroundColour() const { return m_colBack.Ok(); } + bool HasFont() const { return m_font.Ok(); } const wxColour& GetTextColour() const { return m_colText; } const wxColour& GetBackgroundColour() const { return m_colBack; } @@ -216,7 +213,7 @@ private: // wxListItem: the item or column info, used to exchange data with wxListCtrl // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListItem : public wxObject +class WXDLLEXPORT wxListItem : public wxObject { public: wxListItem() { Init(); m_attr = NULL; } @@ -238,27 +235,6 @@ public: if ( item.HasAttributes() ) m_attr = new wxListItemAttr(*item.GetAttributes()); } - - wxListItem& operator=(const wxListItem& item) - { - if ( &item != this ) - { - m_mask = item.m_mask; - m_itemId = item.m_itemId; - m_col = item.m_col; - m_state = item.m_state; - m_stateMask = item.m_stateMask; - m_text = item.m_text; - m_image = item.m_image; - m_data = item.m_data; - m_format = item.m_format; - m_width = item.m_width; - m_attr = item.m_attr ? new wxListItemAttr(*item.m_attr) : NULL; - } - - return *this; - } - virtual ~wxListItem() { delete m_attr; } // resetting @@ -356,7 +332,7 @@ protected: void Init() { m_mask = 0; - m_itemId = -1; + m_itemId = 0; m_col = 0; m_state = 0; m_stateMask = 0; @@ -370,123 +346,25 @@ protected: wxListItemAttr *m_attr; // optional pointer to the items style private: + // VZ: this is strange, we have a copy ctor but not operator=(), why? + wxListItem& operator=(const wxListItem& item); + DECLARE_DYNAMIC_CLASS(wxListItem) }; -// ---------------------------------------------------------------------------- -// wxListCtrlBase: the base class for the main control itself. -// ---------------------------------------------------------------------------- - -// Unlike other base classes, this class doesn't currently define the API of -// the real control class but is just used for implementation convenience. We -// should define the public class functions as pure virtual here in the future -// however. -class WXDLLIMPEXP_CORE wxListCtrlBase : public wxControl -{ -public: - wxListCtrlBase() { } - - // Image list methods. - // ------------------- - - // Associate the given (possibly NULL to indicate that no images will be - // used) image list with the control. The ownership of the image list - // passes to the control, i.e. it will be deleted when the control itself - // is destroyed. - // - // The value of "which" must be one of wxIMAGE_LIST_{NORMAL,SMALL,STATE}. - virtual void AssignImageList(wxImageList* imageList, int which) = 0; - - // Same as AssignImageList() but the control does not delete the image list - // so it can be shared among several controls. - virtual void SetImageList(wxImageList* imageList, int which) = 0; - - // Return the currently used image list, may be NULL. - virtual wxImageList* GetImageList(int which) const = 0; - - - // Column-related methods. - // ----------------------- - - // All these methods can only be used in report view mode. - - // Appends a new column. - // - // Returns the index of the newly inserted column or -1 on error. - long AppendColumn(const wxString& heading, - wxListColumnFormat format = wxLIST_FORMAT_LEFT, - int width = -1); - - // Add a new column to the control at the position "col". - // - // Returns the index of the newly inserted column or -1 on error. - long InsertColumn(long col, const wxListItem& info); - long InsertColumn(long col, - const wxString& heading, - int format = wxLIST_FORMAT_LEFT, - int width = wxLIST_AUTOSIZE); - - // Delete the given or all columns. - virtual bool DeleteColumn(int col) = 0; - virtual bool DeleteAllColumns() = 0; - - // Return the current number of columns. - virtual int GetColumnCount() const = 0; - - // Get or update information about the given column. Set item mask to - // indicate the fields to retrieve or change. - // - // Returns false on error, e.g. if the column index is invalid. - virtual bool GetColumn(int col, wxListItem& item) const = 0; - virtual bool SetColumn(int col, const wxListItem& item) = 0; - - // Convenient wrappers for the above methods which get or update just the - // column width. - virtual int GetColumnWidth(int col) const = 0; - virtual bool SetColumnWidth(int col, int width) = 0; - - // return the attribute for the item (may return NULL if none) - virtual wxListItemAttr *OnGetItemAttr(long item) const; - - // Other miscellaneous accessors. - // ------------------------------ - - // Convenient functions for testing the list control mode: - bool InReportView() const { return HasFlag(wxLC_REPORT); } - bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); } - - // Enable or disable beep when incremental match doesn't find any item. - // Only implemented in the generic version currently. - virtual void EnableBellOnNoMatch(bool WXUNUSED(on) = true) { } - - void EnableAlternateRowColours(bool enable = true); - void SetAlternateRowColour(const wxColour& colour); - -protected: - // Real implementations methods to which our public forwards. - virtual long DoInsertColumn(long col, const wxListItem& info) = 0; - - // Overridden methods of the base class. - virtual wxSize DoGetBestClientSize() const; - -private: - // user defined color to draw row lines, may be invalid - wxListItemAttr m_alternateRowColour; -}; - // ---------------------------------------------------------------------------- // wxListEvent - the event class for the wxListCtrl notifications // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListEvent : public wxNotifyEvent +class WXDLLEXPORT wxListEvent : public wxNotifyEvent { public: wxListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) : wxNotifyEvent(commandType, winid) - , m_code(-1) - , m_oldItemIndex(-1) - , m_itemIndex(-1) - , m_col(-1) + , m_code(0) + , m_oldItemIndex(0) + , m_itemIndex(0) + , m_col(0) , m_pointDrag() , m_item() , m_editCancelled(false) @@ -510,15 +388,15 @@ public: const wxString& GetLabel() const { return m_item.m_text; } const wxString& GetText() const { return m_item.m_text; } int GetImage() const { return m_item.m_image; } - wxUIntPtr GetData() const { return m_item.m_data; } + long GetData() const { return wx_static_cast(long, m_item.m_data); } long GetMask() const { return m_item.m_mask; } const wxListItem& GetItem() const { return m_item; } - // for wxEVT_LIST_CACHE_HINT only + // for wxEVT_COMMAND_LIST_CACHE_HINT only long GetCacheFrom() const { return m_oldItemIndex; } long GetCacheTo() const { return m_itemIndex; } - // was label editing canceled? (for wxEVT_LIST_END_LABEL_EDIT only) + // was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only) bool IsEditCancelled() const { return m_editCancelled; } void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } @@ -526,7 +404,7 @@ public: //protected: -- not for backwards compatibility int m_code; - long m_oldItemIndex; // only for wxEVT_LIST_CACHE_HINT + long m_oldItemIndex; // only for wxEVT_COMMAND_LIST_CACHE_HINT long m_itemIndex; int m_col; wxPoint m_pointDrag; @@ -544,35 +422,40 @@ private: // wxListCtrl event macros // ---------------------------------------------------------------------------- -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_DRAG, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_RDRAG, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_LABEL_EDIT, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_END_LABEL_EDIT, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_DELETE_ITEM, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_DELETE_ALL_ITEMS, wxListEvent ); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_SELECTED, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_DESELECTED, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_KEY_DOWN, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_INSERT_ITEM, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_CLICK, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_RIGHT_CLICK, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_MIDDLE_CLICK, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_ACTIVATED, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_CACHE_HINT, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_RIGHT_CLICK, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_BEGIN_DRAG, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_DRAGGING, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_END_DRAG, wxListEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_FOCUSED, wxListEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG, 700) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG, 701) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, 702) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT, 703) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM, 704) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, 705) +#if WXWIN_COMPATIBILITY_2_4 + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO, 706) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO, 707) +#endif + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED, 708) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED, 709) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN, 710) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM, 711) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK, 712) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, 713) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 714) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, 715) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT, 716) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK, 717) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, 718) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING, 719) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG, 720) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED, 721) +END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); #define wxListEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxListEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListEventFunction, &func) #define wx__DECLARE_LISTEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_LIST_ ## evt, id, wxListEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_LIST_ ## evt, id, wxListEventHandler(fn)) #define EVT_LIST_BEGIN_DRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_DRAG, id, fn) #define EVT_LIST_BEGIN_RDRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_RDRAG, id, fn) @@ -598,28 +481,11 @@ typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); #define EVT_LIST_CACHE_HINT(id, fn) wx__DECLARE_LISTEVT(CACHE_HINT, id, fn) -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_LIST_BEGIN_DRAG wxEVT_LIST_BEGIN_DRAG -#define wxEVT_COMMAND_LIST_BEGIN_RDRAG wxEVT_LIST_BEGIN_RDRAG -#define wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT wxEVT_LIST_BEGIN_LABEL_EDIT -#define wxEVT_COMMAND_LIST_END_LABEL_EDIT wxEVT_LIST_END_LABEL_EDIT -#define wxEVT_COMMAND_LIST_DELETE_ITEM wxEVT_LIST_DELETE_ITEM -#define wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS wxEVT_LIST_DELETE_ALL_ITEMS -#define wxEVT_COMMAND_LIST_ITEM_SELECTED wxEVT_LIST_ITEM_SELECTED -#define wxEVT_COMMAND_LIST_ITEM_DESELECTED wxEVT_LIST_ITEM_DESELECTED -#define wxEVT_COMMAND_LIST_KEY_DOWN wxEVT_LIST_KEY_DOWN -#define wxEVT_COMMAND_LIST_INSERT_ITEM wxEVT_LIST_INSERT_ITEM -#define wxEVT_COMMAND_LIST_COL_CLICK wxEVT_LIST_COL_CLICK -#define wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK wxEVT_LIST_ITEM_RIGHT_CLICK -#define wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK wxEVT_LIST_ITEM_MIDDLE_CLICK -#define wxEVT_COMMAND_LIST_ITEM_ACTIVATED wxEVT_LIST_ITEM_ACTIVATED -#define wxEVT_COMMAND_LIST_CACHE_HINT wxEVT_LIST_CACHE_HINT -#define wxEVT_COMMAND_LIST_COL_RIGHT_CLICK wxEVT_LIST_COL_RIGHT_CLICK -#define wxEVT_COMMAND_LIST_COL_BEGIN_DRAG wxEVT_LIST_COL_BEGIN_DRAG -#define wxEVT_COMMAND_LIST_COL_DRAGGING wxEVT_LIST_COL_DRAGGING -#define wxEVT_COMMAND_LIST_COL_END_DRAG wxEVT_LIST_COL_END_DRAG -#define wxEVT_COMMAND_LIST_ITEM_FOCUSED wxEVT_LIST_ITEM_FOCUSED +#if WXWIN_COMPATIBILITY_2_4 +#define EVT_LIST_GET_INFO(id, fn) wx__DECLARE_LISTEVT(GET_INFO, id, fn) +#define EVT_LIST_SET_INFO(id, fn) wx__DECLARE_LISTEVT(SET_INFO, id, fn) +#endif #endif // _WX_LISTCTRL_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/listbook.h b/Source/3rd Party/wx/include/wx/listbook.h index d074e167b..b14ee4cdb 100644 --- a/Source/3rd Party/wx/include/wx/listbook.h +++ b/Source/3rd Party/wx/include/wx/listbook.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.08.03 +// RCS-ID: $Id: listbook.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,13 +17,12 @@ #if wxUSE_LISTBOOK #include "wx/bookctrl.h" -#include "wx/containr.h" class WXDLLIMPEXP_FWD_CORE wxListView; class WXDLLIMPEXP_FWD_CORE wxListEvent; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LISTBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LISTBOOK_PAGE_CHANGING, wxBookCtrlEvent ); +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; // wxListbook flags #define wxLB_DEFAULT wxBK_DEFAULT @@ -36,10 +36,13 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LISTBOOK_PAGE_CHANGING, wxBook // wxListbook // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListbook : public wxNavigationEnabled +class WXDLLEXPORT wxListbook : public wxBookCtrlBase { public: - wxListbook() { } + wxListbook() + { + Init(); + } wxListbook(wxWindow *parent, wxWindowID id, @@ -48,6 +51,8 @@ public: long style = 0, const wxString& name = wxEmptyString) { + Init(); + (void)Create(parent, id, pos, size, style, name); } @@ -61,15 +66,17 @@ public: // overridden base class methods + virtual int GetSelection() const; virtual bool SetPageText(size_t n, const wxString& strText); virtual wxString GetPageText(size_t n) const; virtual int GetPageImage(size_t n) const; virtual bool SetPageImage(size_t n, int imageId); + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; virtual bool InsertPage(size_t n, wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = -1); virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; @@ -82,22 +89,24 @@ public: protected: virtual wxWindow *DoRemovePage(size_t page); + // get the size which the list control should have + virtual wxSize GetControllerSize() const; + void UpdateSelectedPage(size_t newsel); - wxBookCtrlEvent* CreatePageChangingEvent() const; - void MakeChangedEvent(wxBookCtrlEvent &event); - - // Get the correct wxListCtrl flags to use depending on our own flags. - long GetListCtrlFlags() const; + wxBookCtrlBaseEvent* CreatePageChangingEvent() const; + void MakeChangedEvent(wxBookCtrlBaseEvent &event); // event handlers void OnListSelected(wxListEvent& event); void OnSize(wxSizeEvent& event); -private: - // this should be called when we need to be relaid out - void UpdateSize(); + // the currently selected page or wxNOT_FOUND if none + int m_selection; +private: + // common part of all constructors + void Init(); DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook) @@ -107,22 +116,36 @@ private: // listbook event class and related stuff // ---------------------------------------------------------------------------- -// wxListbookEvent is obsolete and defined for compatibility only (notice that -// we use #define and not typedef to also keep compatibility with the existing -// code which forward declares it) -#define wxListbookEvent wxBookCtrlEvent -typedef wxBookCtrlEventFunction wxListbookEventFunction; -#define wxListbookEventHandler(func) wxBookCtrlEventHandler(func) +class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent +{ +public: + wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) + : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) + { + } + + wxListbookEvent(const wxListbookEvent& event) + : wxBookCtrlBaseEvent(event) + { + } + + virtual wxEvent *Clone() const { return new wxListbookEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent) +}; + +typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&); + +#define wxListbookEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func) #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_LISTBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn)) #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_LISTBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED wxEVT_LISTBOOK_PAGE_CHANGED -#define wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING wxEVT_LISTBOOK_PAGE_CHANGING + wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn)) #endif // wxUSE_LISTBOOK diff --git a/Source/3rd Party/wx/include/wx/listbox.h b/Source/3rd Party/wx/include/wx/listbox.h index 9b115bcc5..a3b98fc48 100644 --- a/Source/3rd Party/wx/include/wx/listbox.h +++ b/Source/3rd Party/wx/include/wx/listbox.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 22.10.99 +// RCS-ID: $Id: listbox.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -29,26 +30,38 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; // global data // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxListBoxNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxListBoxNameStr[]; // ---------------------------------------------------------------------------- // wxListBox interface is defined by the class wxListBoxBase // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListBoxBase : public wxControlWithItems +class WXDLLEXPORT wxListBoxBase : public wxControlWithItems { public: wxListBoxBase() { } virtual ~wxListBoxBase(); - void InsertItems(unsigned int nItems, const wxString *items, unsigned int pos) - { Insert(nItems, items, pos); } + // all generic methods are in wxControlWithItems, except for the following + // ones which are not yet implemented by wxChoice/wxComboBox + void Insert(const wxString& item, unsigned int pos) + { /* return*/ wxControlWithItems::Insert(item,pos); } + void Insert(const wxString& item, unsigned int pos, void *clientData) + { /* return*/ wxControlWithItems::Insert(item,pos,clientData); } + void Insert(const wxString& item, unsigned int pos, wxClientData *clientData) + { /* return*/ wxControlWithItems::Insert(item,pos,clientData); } + + void InsertItems(unsigned int nItems, const wxString *items, unsigned int pos); void InsertItems(const wxArrayString& items, unsigned int pos) - { Insert(items, pos); } + { DoInsertItems(items, pos); } + + void Set(int n, const wxString* items, void **clientData = NULL); + void Set(const wxArrayString& items, void **clientData = NULL) + { DoSetItems(items, clientData); } // multiple selection logic virtual bool IsSelected(int n) const = 0; - virtual void SetSelection(int n); + virtual void SetSelection(int n) { DoSetSelection(n, true); } void SetSelection(int n, bool select) { DoSetSelection(n, select); } void Deselect(int n) { DoSetSelection(n, false); } void DeselectAll(int itemToLeaveSelected = -1); @@ -83,19 +96,32 @@ public: (m_windowStyle & wxLB_EXTENDED); } - // override wxItemContainer::IsSorted - virtual bool IsSorted() const { return HasFlag( wxLB_SORT ); } + // return true if this listbox is sorted + bool IsSorted() const { return (m_windowStyle & wxLB_SORT) != 0; } // emulate selecting or deselecting the item event.GetInt() (depending on // event.GetExtraLong()) void Command(wxCommandEvent& event); - // return the index of the item at this position or wxNOT_FOUND + // returns the item number at a point or wxNOT_FOUND int HitTest(const wxPoint& point) const { return DoListHitTest(point); } - int HitTest(int x, int y) const { return DoListHitTest(wxPoint(x, y)); } +#if WXWIN_COMPATIBILITY_2_6 + // compatibility - these functions are deprecated, use the new ones + // instead + wxDEPRECATED( bool Selected(int n) const ); +#endif // WXWIN_COMPATIBILITY_2_6 protected: + // NB: due to wxGTK implementation details, DoInsert() is implemented + // using DoInsertItems() and not the other way round + virtual int DoInsert(const wxString& item, unsigned int pos) + { InsertItems(1, &item, pos); return pos; } + + // to be implemented in derived classes + virtual void DoInsertItems(const wxArrayString& items, unsigned int pos) = 0; + virtual void DoSetItems(const wxArrayString& items, void **clientData) = 0; + virtual void DoSetFirstItem(int n) = 0; virtual void DoSetSelection(int n, bool select) = 0; @@ -104,39 +130,14 @@ protected: virtual int DoListHitTest(const wxPoint& WXUNUSED(point)) const { return wxNOT_FOUND; } - // Helper for the code generating events in single selection mode: updates - // m_oldSelections and return true if the selection really changed. - // Otherwise just returns false. - bool DoChangeSingleSelection(int item); - // Helper for generating events in multiple and extended mode: compare the - // current selections with the previously recorded ones (in - // m_oldSelections) and send the appropriate event if they differ, - // otherwise just return false. - bool CalcAndSendEvent(); - - // Send a listbox (de)selection or double click event. - // - // Returns true if the event was processed. - bool SendEvent(wxEventType evtType, int item, bool selected); - - // Array storing the indices of all selected items that we already notified - // the user code about for multi selection list boxes. - // - // For single selection list boxes, we reuse this array to store the single - // currently selected item, this is used by DoChangeSingleSelection(). - // - // TODO-OPT: wxSelectionStore would be more efficient for big list boxes. - wxArrayInt m_oldSelections; - - // Update m_oldSelections with currently selected items (does nothing in - // single selection mode on platforms other than MSW). - void UpdateOldSelections(); - -private: - wxDECLARE_NO_COPY_CLASS(wxListBoxBase); + DECLARE_NO_COPY_CLASS(wxListBoxBase) }; +#if WXWIN_COMPATIBILITY_2_6 + inline bool wxListBoxBase::Selected(int n) const { return IsSelected(n); } +#endif // WXWIN_COMPATIBILITY_2_6 + // ---------------------------------------------------------------------------- // include the platform-specific class declaration // ---------------------------------------------------------------------------- @@ -152,7 +153,7 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/listbox.h" #elif defined(__WXMAC__) - #include "wx/osx/listbox.h" + #include "wx/mac/listbox.h" #elif defined(__WXPM__) #include "wx/os2/listbox.h" #elif defined(__WXCOCOA__) diff --git a/Source/3rd Party/wx/include/wx/listctrl.h b/Source/3rd Party/wx/include/wx/listctrl.h index f12d10c0e..efccc7300 100644 --- a/Source/3rd Party/wx/include/wx/listctrl.h +++ b/Source/3rd Party/wx/include/wx/listctrl.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 04.12.99 +// RCS-ID: $Id: listctrl.h 46432 2007-06-13 03:46:20Z SC $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -21,16 +22,16 @@ // constants // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxListCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxListCtrlNameStr[]; // ---------------------------------------------------------------------------- // include the wxListCtrl class declaration // ---------------------------------------------------------------------------- -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) +#if defined(__WIN32__) && !defined(__WXUNIVERSAL__) #include "wx/msw/listctrl.h" -#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON - #include "wx/osx/listctrl.h" +#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__) + #include "wx/mac/carbon/listctrl.h" #else #include "wx/generic/listctrl.h" #endif @@ -39,7 +40,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxListCtrlNameStr[]; // wxListView: a class which provides a better API for list control // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListView : public wxListCtrl +class WXDLLEXPORT wxListView : public wxListCtrl { public: wxListView() { } diff --git a/Source/3rd Party/wx/include/wx/listimpl.cpp b/Source/3rd Party/wx/include/wx/listimpl.cpp index 3d673a47e..d05fda13e 100644 --- a/Source/3rd Party/wx/include/wx/listimpl.cpp +++ b/Source/3rd Party/wx/include/wx/listimpl.cpp @@ -1,14 +1,15 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/listimpl.cpp +// Name: listimpl.cpp // Purpose: second-part of macro based implementation of template lists // Author: Vadim Zeitlin // Modified by: // Created: 16/11/98 +// RCS-ID: $Id: listimpl.cpp 38893 2006-04-24 17:59:10Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #undef WX_DEFINE_LIST #define WX_DEFINE_LIST(name) \ @@ -16,11 +17,11 @@ { \ delete X; \ } \ - _WX_LIST_HELPER_##name::BaseListType _WX_LIST_HELPER_##name::EmptyList; + name::BaseListType name::EmptyList; -#else // !wxUSE_STD_CONTAINERS - #undef WX_DEFINE_LIST_2 - #define WX_DEFINE_LIST_2(T, name) \ +#else // !wxUSE_STL + + #define _DEFINE_LIST(T, name) \ void wx##name##Node::DeleteData() \ { \ delete (T *)GetData(); \ @@ -29,7 +30,10 @@ // redefine the macro so that now it will generate the class implementation // old value would provoke a compile-time error if this file is not included #undef WX_DEFINE_LIST - #define WX_DEFINE_LIST(name) WX_DEFINE_LIST_2(_WX_LIST_ITEM_TYPE_##name, name) + #define WX_DEFINE_LIST(name) _DEFINE_LIST(_WX_LIST_ITEM_TYPE_##name, name) -#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS + // don't pollute preprocessor's name space + //#undef _DEFINE_LIST + +#endif // wxUSE_STL/!wxUSE_STL diff --git a/Source/3rd Party/wx/include/wx/log.h b/Source/3rd Party/wx/include/wx/log.h index 900a4cbe2..5e23bcf92 100644 --- a/Source/3rd Party/wx/include/wx/log.h +++ b/Source/3rd Party/wx/include/wx/log.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: log.h 50993 2008-01-02 21:18:15Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,46 +13,38 @@ #define _WX_LOG_H_ #include "wx/defs.h" -#include "wx/cpp.h" + +// ---------------------------------------------------------------------------- +// common constants for use in wxUSE_LOG/!wxUSE_LOG +// ---------------------------------------------------------------------------- + +// the trace masks have been superceded by symbolic trace constants, they're +// for compatibility only andwill be removed soon - do NOT use them + +// meaning of different bits of the trace mask (which allows selectively +// enable/disable some trace messages) +#define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete) +#define wxTraceMessages 0x0002 // trace window messages/X callbacks +#define wxTraceResAlloc 0x0004 // trace GDI resource allocation +#define wxTraceRefCount 0x0008 // trace various ref counting operations + +#ifdef __WXMSW__ + #define wxTraceOleCalls 0x0100 // OLE interface calls +#endif // ---------------------------------------------------------------------------- // types // ---------------------------------------------------------------------------- -// NB: this is needed even if wxUSE_LOG == 0 +// NB: these types are needed even if wxUSE_LOG == 0 +typedef unsigned long wxTraceMask; typedef unsigned long wxLogLevel; -// the trace masks have been superseded by symbolic trace constants, they're -// for compatibility only and will be removed soon - do NOT use them -#if WXWIN_COMPATIBILITY_2_8 - #define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete) - #define wxTraceMessages 0x0002 // trace window messages/X callbacks - #define wxTraceResAlloc 0x0004 // trace GDI resource allocation - #define wxTraceRefCount 0x0008 // trace various ref counting operations - - #ifdef __WINDOWS__ - #define wxTraceOleCalls 0x0100 // OLE interface calls - #endif - - typedef unsigned long wxTraceMask; -#endif // WXWIN_COMPATIBILITY_2_8 - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- #include "wx/string.h" -#include "wx/strvararg.h" - -// ---------------------------------------------------------------------------- -// forward declarations -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_BASE wxObject; - -#if wxUSE_GUI - class WXDLLIMPEXP_FWD_CORE wxFrame; -#endif // wxUSE_GUI #if wxUSE_LOG @@ -62,49 +55,32 @@ class WXDLLIMPEXP_FWD_BASE wxObject; #endif #include "wx/dynarray.h" -#include "wx/hashmap.h" -#if wxUSE_THREADS - #include "wx/thread.h" -#endif // wxUSE_THREADS - -// wxUSE_LOG_DEBUG enables the debug log messages #ifndef wxUSE_LOG_DEBUG - #if wxDEBUG_LEVEL - #define wxUSE_LOG_DEBUG 1 - #else // !wxDEBUG_LEVEL - #define wxUSE_LOG_DEBUG 0 - #endif +# ifdef __WXDEBUG__ +# define wxUSE_LOG_DEBUG 1 +# else // !__WXDEBUG__ +# define wxUSE_LOG_DEBUG 0 +# endif #endif -// wxUSE_LOG_TRACE enables the trace messages, they are disabled by default -#ifndef wxUSE_LOG_TRACE - #if wxDEBUG_LEVEL - #define wxUSE_LOG_TRACE 1 - #else // !wxDEBUG_LEVEL - #define wxUSE_LOG_TRACE 0 - #endif -#endif // wxUSE_LOG_TRACE +// ---------------------------------------------------------------------------- +// forward declarations +// ---------------------------------------------------------------------------- -// wxLOG_COMPONENT identifies the component which generated the log record and -// can be #define'd to a user-defined value when compiling the user code to use -// component-based filtering (see wxLog::SetComponentLevel()) -#ifndef wxLOG_COMPONENT - // this is a variable and not a macro in order to allow the user code to - // just #define wxLOG_COMPONENT without #undef'ining it first - extern WXDLLIMPEXP_DATA_BASE(const char *) wxLOG_COMPONENT; - - #ifdef WXBUILDING - #define wxLOG_COMPONENT "wx" - #endif -#endif +#if wxUSE_GUI + class WXDLLIMPEXP_FWD_CORE wxTextCtrl; + class WXDLLIMPEXP_FWD_CORE wxLogFrame; + class WXDLLIMPEXP_FWD_CORE wxFrame; + class WXDLLIMPEXP_FWD_CORE wxWindow; +#endif // wxUSE_GUI // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- // different standard log levels (you may also define your own) -enum wxLogLevelValues +enum { wxLOG_FatalError, // program can't continue, abort immediately wxLOG_Error, // a serious error, user must be informed about it @@ -128,213 +104,12 @@ enum wxLogLevelValues #define wxTRACE_ResAlloc wxT("resalloc") // trace GDI resource allocation #define wxTRACE_RefCount wxT("refcount") // trace various ref counting operations -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #define wxTRACE_OleCalls wxT("ole") // OLE interface calls #endif #include "wx/iosfwrap.h" -// ---------------------------------------------------------------------------- -// information about a log record, i.e. unit of log output -// ---------------------------------------------------------------------------- - -class wxLogRecordInfo -{ -public: - // default ctor creates an uninitialized object - wxLogRecordInfo() - { - memset(this, 0, sizeof(*this)); - } - - // normal ctor, used by wxLogger specifies the location of the log - // statement; its time stamp and thread id are set up here - wxLogRecordInfo(const char *filename_, - int line_, - const char *func_, - const char *component_) - { - filename = filename_; - func = func_; - line = line_; - component = component_; - - timestamp = time(NULL); - -#if wxUSE_THREADS - threadId = wxThread::GetCurrentId(); -#endif // wxUSE_THREADS - - m_data = NULL; - } - - // we need to define copy ctor and assignment operator because of m_data - wxLogRecordInfo(const wxLogRecordInfo& other) - { - Copy(other); - } - - wxLogRecordInfo& operator=(const wxLogRecordInfo& other) - { - if ( &other != this ) - { - delete m_data; - Copy(other); - } - - return *this; - } - - // dtor is non-virtual, this class is not meant to be derived from - ~wxLogRecordInfo() - { - delete m_data; - } - - - // the file name and line number of the file where the log record was - // generated, if available or NULL and 0 otherwise - const char *filename; - int line; - - // the name of the function where the log record was generated (may be NULL - // if the compiler doesn't support __FUNCTION__) - const char *func; - - // the name of the component which generated this message, may be NULL if - // not set (i.e. wxLOG_COMPONENT not defined) - const char *component; - - // time of record generation - time_t timestamp; - -#if wxUSE_THREADS - // id of the thread which logged this record - wxThreadIdType threadId; -#endif // wxUSE_THREADS - - - // store an arbitrary value in this record context - // - // wxWidgets always uses keys starting with "wx.", e.g. "wx.sys_error" - void StoreValue(const wxString& key, wxUIntPtr val) - { - if ( !m_data ) - m_data = new ExtraData; - - m_data->numValues[key] = val; - } - - void StoreValue(const wxString& key, const wxString& val) - { - if ( !m_data ) - m_data = new ExtraData; - - m_data->strValues[key] = val; - } - - - // these functions retrieve the value of either numeric or string key, - // return false if not found - bool GetNumValue(const wxString& key, wxUIntPtr *val) const - { - if ( !m_data ) - return false; - - wxStringToNumHashMap::const_iterator it = m_data->numValues.find(key); - if ( it == m_data->numValues.end() ) - return false; - - *val = it->second; - - return true; - } - - bool GetStrValue(const wxString& key, wxString *val) const - { - if ( !m_data ) - return false; - - wxStringToStringHashMap::const_iterator it = m_data->strValues.find(key); - if ( it == m_data->strValues.end() ) - return false; - - *val = it->second; - - return true; - } - -private: - void Copy(const wxLogRecordInfo& other) - { - memcpy(this, &other, sizeof(*this)); - if ( other.m_data ) - m_data = new ExtraData(*other.m_data); - } - - // extra data associated with the log record: this is completely optional - // and can be used to pass information from the log function to the log - // sink (e.g. wxLogSysError() uses this to pass the error code) - struct ExtraData - { - wxStringToNumHashMap numValues; - wxStringToStringHashMap strValues; - }; - - // NULL if not used - ExtraData *m_data; -}; - -#define wxLOG_KEY_TRACE_MASK "wx.trace_mask" - -// ---------------------------------------------------------------------------- -// log record: a unit of log output -// ---------------------------------------------------------------------------- - -struct wxLogRecord -{ - wxLogRecord(wxLogLevel level_, - const wxString& msg_, - const wxLogRecordInfo& info_) - : level(level_), - msg(msg_), - info(info_) - { - } - - wxLogLevel level; - wxString msg; - wxLogRecordInfo info; -}; - -// ---------------------------------------------------------------------------- -// Derive from this class to customize format of log messages. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxLogFormatter -{ -public: - // Default constructor. - wxLogFormatter() { } - - // Trivial but virtual destructor for the base class. - virtual ~wxLogFormatter() { } - - - // Override this method to implement custom formatting of the given log - // record. The default implementation simply prepends a level-dependent - // prefix to the message and optionally adds a time stamp. - virtual wxString Format(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info) const; - -protected: - // Override this method to change just the time stamp formatting. It is - // called by default Format() implementation. - virtual wxString FormatTime(time_t t) const; -}; - - // ---------------------------------------------------------------------------- // derive from this class to redirect (or suppress, or ...) log messages // normally, only a single instance of this class exists but it's not enforced @@ -344,106 +119,46 @@ class WXDLLIMPEXP_BASE wxLog { public: // ctor - wxLog() : m_formatter(new wxLogFormatter) { } + wxLog(){} - // make dtor virtual for all derived classes - virtual ~wxLog(); + // these functions allow to completely disable all log messages - - // log messages selection - // ---------------------- - - // these functions allow to completely disable all log messages or disable - // log messages at level less important than specified for the current - // thread - - // is logging enabled at all now? - static bool IsEnabled() - { -#if wxUSE_THREADS - if ( !wxThread::IsMain() ) - return IsThreadLoggingEnabled(); -#endif // wxUSE_THREADS - - return ms_doLog; - } + // is logging disabled now? + static bool IsEnabled() { return ms_doLog; } // change the flag state, return the previous one - static bool EnableLogging(bool enable = true) - { -#if wxUSE_THREADS - if ( !wxThread::IsMain() ) - return EnableThreadLogging(enable); -#endif // wxUSE_THREADS - - bool doLogOld = ms_doLog; - ms_doLog = enable; - return doLogOld; - } - - // return the current global log level - static wxLogLevel GetLogLevel() { return ms_logLevel; } - - // set global log level: messages with level > logLevel will not be logged - static void SetLogLevel(wxLogLevel logLevel) { ms_logLevel = logLevel; } - - // set the log level for the given component - static void SetComponentLevel(const wxString& component, wxLogLevel level); - - // return the effective log level for this component, falling back to - // parent component and to the default global log level if necessary - // - // NB: component argument is passed by value and not const reference in an - // attempt to encourage compiler to avoid an extra copy: as we modify - // the component internally, we'd create one anyhow and like this it - // can be avoided if the string is a temporary anyhow - static wxLogLevel GetComponentLevel(wxString component); - - - // is logging of messages from this component enabled at this level? - // - // usually always called with wxLOG_COMPONENT as second argument - static bool IsLevelEnabled(wxLogLevel level, wxString component) - { - return IsEnabled() && level <= GetComponentLevel(component); - } - - - // enable/disable messages at wxLOG_Verbose level (only relevant if the - // current log level is greater or equal to it) - // - // notice that verbose mode can be activated by the standard command-line - // '--verbose' option - static void SetVerbose(bool bVerbose = true) { ms_bVerbose = bVerbose; } - - // check if verbose messages are enabled - static bool GetVerbose() { return ms_bVerbose; } + static bool EnableLogging(bool doIt = true) + { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; } + // static sink function - see DoLog() for function to overload in the + // derived classes + static void OnLog(wxLogLevel level, const wxChar *szString, time_t t); // message buffering - // ----------------- // flush shows all messages if they're not logged immediately (FILE - // and iostream logs don't need it, but wxLogGui does to avoid showing + // and iostream logs don't need it, but wxGuiLog does to avoid showing // 17 modal dialogs one after another) virtual void Flush(); - // flush the active target if any and also output any pending messages from - // background threads - static void FlushActive(); + // flush the active target if any + static void FlushActive() + { + if ( !ms_suspendCount ) + { + wxLog *log = GetActiveTarget(); + if ( log ) + log->Flush(); + } + } - // only one sink is active at each moment get current log target, will call - // wxAppTraits::CreateLogTarget() to create one if none exists + // only one sink is active at each moment + // get current log target, will call wxApp::CreateLogTarget() to + // create one if none exists static wxLog *GetActiveTarget(); - // change log target, logger may be NULL - static wxLog *SetActiveTarget(wxLog *logger); - -#if wxUSE_THREADS - // change log target for the current thread only, shouldn't be called from - // the main thread as it doesn't use thread-specific log target - static wxLog *SetThreadActiveTarget(wxLog *logger); -#endif // wxUSE_THREADS + // change log target, pLogger may be NULL + static wxLog *SetActiveTarget(wxLog *pLogger); // suspend the message flushing of the main target until the next call // to Resume() - this is mainly for internal use (to prevent wxYield() @@ -453,9 +168,19 @@ public: // must be called for each Suspend()! static void Resume() { ms_suspendCount--; } + // functions controlling the default wxLog behaviour + // verbose mode is activated by standard command-line '-verbose' + // option + static void SetVerbose(bool bVerbose = true) { ms_bVerbose = bVerbose; } + + // Set log level. Log messages with level > logLevel will not be logged. + static void SetLogLevel(wxLogLevel logLevel) { ms_logLevel = logLevel; } + +#if wxABI_VERSION >= 20805 /* 2.8.5+ only */ // should GetActiveTarget() try to create a new log object if the // current is NULL? static void DontCreateOnDemand(); +#endif // Make GetActiveTarget() create a new log object again. static void DoCreateOnDemand(); @@ -468,8 +193,12 @@ public: // gets duplicate counting status static bool GetRepetitionCounting() { return ms_bRepetCounting; } + // trace mask (see wxTraceXXX constants for details) + static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; } + // add string trace mask - static void AddTraceMask(const wxString& str); + static void AddTraceMask(const wxString& str) + { ms_aTraceMasks.push_back(str); } // add string trace mask static void RemoveTraceMask(const wxString& str); @@ -477,88 +206,41 @@ public: // remove all string trace masks static void ClearTraceMasks(); - // get string trace masks: note that this is MT-unsafe if other threads can - // call AddTraceMask() concurrently - static const wxArrayString& GetTraceMasks(); + // get string trace masks + static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; } + + // sets the timestamp string: this is used as strftime() format string + // for the log targets which add time stamps to the messages - set it + // to NULL to disable time stamping completely. + static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; } + + + // accessors + + // gets the verbose status + static bool GetVerbose() { return ms_bVerbose; } + + // get trace mask + static wxTraceMask GetTraceMask() { return ms_ulTraceMask; } // is this trace mask in the list? - static bool IsAllowedTraceMask(const wxString& mask); + static bool IsAllowedTraceMask(const wxChar *mask); + + // return the current loglevel limit + static wxLogLevel GetLogLevel() { return ms_logLevel; } + + // get the current timestamp format string (may be NULL) + static const wxChar *GetTimestamp() { return ms_timestamp; } - // log formatting - // ----------------- + // helpers - // Change wxLogFormatter object used by wxLog to format the log messages. - // - // wxLog takes ownership of the pointer passed in but the caller is - // responsible for deleting the returned pointer. - wxLogFormatter* SetFormatter(wxLogFormatter* formatter); - - - // All the time stamp related functions below only work when the default - // wxLogFormatter is being used. Defining a custom formatter overrides them - // as it could use its own time stamp format or format messages without - // using time stamp at all. - - - // sets the time stamp string format: this is used as strftime() format - // string for the log targets which add time stamps to the messages; set - // it to empty string to disable time stamping completely. - static void SetTimestamp(const wxString& ts) { ms_timestamp = ts; } - - // disable time stamping of log messages - static void DisableTimestamp() { SetTimestamp(wxEmptyString); } - - - // get the current timestamp format string (maybe empty) - static const wxString& GetTimestamp() { return ms_timestamp; } - - - - // helpers: all functions in this section are mostly for internal use only, - // don't call them from your code even if they are not formally deprecated - - // put the time stamp into the string if ms_timestamp is not empty (don't - // change it otherwise); the first overload uses the current time. + // put the time stamp into the string if ms_timestamp != NULL (don't + // change it otherwise) static void TimeStamp(wxString *str); - static void TimeStamp(wxString *str, time_t t); - // these methods should only be called from derived classes DoLogRecord(), - // DoLogTextAtLevel() and DoLogText() implementations respectively and - // shouldn't be called directly, use logging functions instead - void LogRecord(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info) - { - DoLogRecord(level, msg, info); - } - - void LogTextAtLevel(wxLogLevel level, const wxString& msg) - { - DoLogTextAtLevel(level, msg); - } - - void LogText(const wxString& msg) - { - DoLogText(msg); - } - - // this is a helper used by wxLogXXX() functions, don't call it directly - // and see DoLog() for function to overload in the derived classes - static void OnLog(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info); - - // version called when no information about the location of the log record - // generation is available (but the time stamp is), it mainly exists for - // backwards compatibility, don't use it in new code - static void OnLog(wxLogLevel level, const wxString& msg, time_t t); - - // a helper calling the above overload with current time - static void OnLog(wxLogLevel level, const wxString& msg) - { - OnLog(level, msg, time(NULL)); - } + // make dtor virtual for all derived classes + virtual ~wxLog(); // this method exists for backwards compatibility only, don't use @@ -566,117 +248,35 @@ public: #if WXWIN_COMPATIBILITY_2_6 // this function doesn't do anything any more, don't call it - static wxDEPRECATED_INLINE( - wxChar *SetLogBuffer(wxChar *, size_t = 0), return NULL; - ); -#endif // WXWIN_COMPATIBILITY_2_6 - - // don't use integer masks any more, use string trace masks instead -#if WXWIN_COMPATIBILITY_2_8 - static wxDEPRECATED_INLINE( void SetTraceMask(wxTraceMask ulMask), - ms_ulTraceMask = ulMask; ) - - // this one can't be marked deprecated as it's used in our own wxLogger - // below but it still is deprecated and shouldn't be used - static wxTraceMask GetTraceMask() { return ms_ulTraceMask; } -#endif // WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( static wxChar *SetLogBuffer(wxChar *buf, size_t size = 0) ); +#endif protected: - // the logging functions that can be overridden: DoLogRecord() is called - // for every "record", i.e. a unit of log output, to be logged and by - // default formats the message and passes it to DoLogTextAtLevel() which in - // turn passes it to DoLogText() by default + // the logging functions that can be overriden - // override this method if you want to change message formatting or do - // dynamic filtering - virtual void DoLogRecord(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info); + // default DoLog() prepends the time stamp and a prefix corresponding + // to the message to szString and then passes it to DoLogString() + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t); - // override this method to redirect output to different channels depending - // on its level only; if even the level doesn't matter, override - // DoLogText() instead - virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg); + // default DoLogString does nothing but is not pure virtual because if + // you override DoLog() you might not need it at all + virtual void DoLogString(const wxChar *szString, time_t t); - // this function is not pure virtual as it might not be needed if you do - // the logging in overridden DoLogRecord() or DoLogTextAtLevel() directly - // but if you do not override them in your derived class you must override - // this one as the default implementation of it simply asserts - virtual void DoLogText(const wxString& msg); - - - // the rest of the functions are for backwards compatibility only, don't - // use them in new code; if you're updating your existing code you need to - // switch to overriding DoLogRecord/Text() above (although as long as these - // functions exist, log classes using them will continue to work) -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_BUT_USED_INTERNALLY( - virtual void DoLog(wxLogLevel level, const char *szString, time_t t) - ); - - wxDEPRECATED_BUT_USED_INTERNALLY( - virtual void DoLog(wxLogLevel level, const wchar_t *wzString, time_t t) - ); - - // these shouldn't be used by new code - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual void DoLogString(const char *WXUNUSED(szString), - time_t WXUNUSED(t)), - wxEMPTY_PARAMETER_VALUE - ) - - wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( - virtual void DoLogString(const wchar_t *WXUNUSED(wzString), - time_t WXUNUSED(t)), - wxEMPTY_PARAMETER_VALUE - ) -#endif // WXWIN_COMPATIBILITY_2_8 - - - // log a message indicating the number of times the previous message was - // repeated if previous repetition counter is strictly positive, does - // nothing otherwise; return the old value of repetition counter - unsigned LogLastRepeatIfNeeded(); + // log a line containing the number of times the previous message was + // repeated and returns this number (which can be 0) + static unsigned DoLogNumberOfRepeats(); private: -#if wxUSE_THREADS - // called from FlushActive() to really log any buffered messages logged - // from the other threads - void FlushThreadMessages(); - - // these functions are called for non-main thread only by IsEnabled() and - // EnableLogging() respectively - static bool IsThreadLoggingEnabled(); - static bool EnableThreadLogging(bool enable = true); -#endif // wxUSE_THREADS - - // get the active log target for the main thread, auto-creating it if - // necessary - // - // this is called from GetActiveTarget() and OnLog() when they're called - // from the main thread - static wxLog *GetMainThreadActiveTarget(); - - // called from OnLog() if it's called from the main thread or if we have a - // (presumably MT-safe) thread-specific logger and by FlushThreadMessages() - // when it plays back the buffered messages logged from the other threads - void CallDoLogNow(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info); - - - // variables - // ---------------- - - wxLogFormatter *m_formatter; // We own this pointer. - - // static variables // ---------------- - // if true, don't log the same message multiple times, only log it once - // with the number of times it was repeated + // traditional behaviour or counting repetitions static bool ms_bRepetCounting; + static wxString ms_prevString; // previous message that was logged + // how many times the previous message was logged + static unsigned ms_prevCounter; + static time_t ms_prevTimeStamp;// timestamp of the previous message + static wxLogLevel ms_prevLevel; // level of the previous message static wxLog *ms_pLogger; // currently active log sink static bool ms_doLog; // false => all logging disabled @@ -687,21 +287,28 @@ private: static size_t ms_suspendCount; // if positive, logs are not flushed - // format string for strftime(), if empty, time stamping log messages is + // format string for strftime(), if NULL, time stamping log messages is // disabled - static wxString ms_timestamp; + static const wxChar *ms_timestamp; -#if WXWIN_COMPATIBILITY_2_8 static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour -#endif // WXWIN_COMPATIBILITY_2_8 + static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace + + + // this is the replacement of DoLogNumberOfRepeats() (which has to be kept + // to avoid breaking ABI in this version) + unsigned LogLastRepeatIfNeeded(); + + // implementation of the function above which supposes that the caller had + // already locked gs_prevCS + unsigned LogLastRepeatIfNeededUnlocked(); }; // ---------------------------------------------------------------------------- // "trivial" derivations of wxLog // ---------------------------------------------------------------------------- -// log everything except for the debug/trace messages (which are passed to -// wxMessageOutputDebug) to a buffer +// log everything to a buffer class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog { public: @@ -715,12 +322,13 @@ public: virtual void Flush(); protected: - virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg); + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t); + virtual void DoLogString(const wxChar *szString, time_t t); private: wxString m_str; - wxDECLARE_NO_COPY_CLASS(wxLogBuffer); + DECLARE_NO_COPY_CLASS(wxLogBuffer) }; @@ -729,15 +337,15 @@ class WXDLLIMPEXP_BASE wxLogStderr : public wxLog { public: // redirect log output to a FILE - wxLogStderr(FILE *fp = NULL); + wxLogStderr(FILE *fp = (FILE *) NULL); protected: // implement sink function - virtual void DoLogText(const wxString& msg); + virtual void DoLogString(const wxChar *szString, time_t t); FILE *m_fp; - wxDECLARE_NO_COPY_CLASS(wxLogStderr); + DECLARE_NO_COPY_CLASS(wxLogStderr) }; #if wxUSE_STD_IOSTREAM @@ -751,7 +359,7 @@ public: protected: // implement sink function - virtual void DoLogText(const wxString& msg); + virtual void DoLogString(const wxChar *szString, time_t t); // using ptr here to avoid including from this file wxSTD ostream *m_ostr; @@ -821,13 +429,13 @@ public: virtual void Flush(); // call to avoid destroying the old log target +#if wxABI_VERSION >= 20805 /* 2.8.5+ only */ void DetachOldLog() { m_logOld = NULL; } +#endif protected: - // pass the record to the old logger if needed - virtual void DoLogRecord(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info); + // pass the chain to the old logger if needed + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t); private: // the current log target @@ -839,32 +447,17 @@ private: // do we pass the messages to the old logger? bool m_bPassMessages; - wxDECLARE_NO_COPY_CLASS(wxLogChain); + DECLARE_NO_COPY_CLASS(wxLogChain) }; // a chain log target which uses itself as the new logger - -#define wxLogPassThrough wxLogInterposer - -class WXDLLIMPEXP_BASE wxLogInterposer : public wxLogChain +class WXDLLIMPEXP_BASE wxLogPassThrough : public wxLogChain { public: - wxLogInterposer(); + wxLogPassThrough(); private: - wxDECLARE_NO_COPY_CLASS(wxLogInterposer); -}; - -// a temporary interposer which doesn't destroy the old log target -// (calls DetachOldLog) - -class WXDLLIMPEXP_BASE wxLogInterposerTemp : public wxLogChain -{ -public: - wxLogInterposerTemp(); - -private: - wxDECLARE_NO_COPY_CLASS(wxLogInterposerTemp); + DECLARE_NO_COPY_CLASS(wxLogPassThrough) }; #if wxUSE_GUI @@ -872,404 +465,15 @@ private: #include "wx/generic/logg.h" #endif // wxUSE_GUI -// ---------------------------------------------------------------------------- -// wxLogger -// ---------------------------------------------------------------------------- - -// wxLogger is a helper class used by wxLogXXX() functions implementation, -// don't use it directly as it's experimental and subject to change (OTOH it -// might become public in the future if it's deemed to be useful enough) - -// contains information about the context from which a log message originates -// and provides Log() vararg method which forwards to wxLog::OnLog() and passes -// this context to it -class wxLogger -{ -public: - // ctor takes the basic information about the log record - wxLogger(wxLogLevel level, - const char *filename, - int line, - const char *func, - const char *component) - : m_level(level), - m_info(filename, line, func, component) - { - } - - // store extra data in our log record and return this object itself (so - // that further calls to its functions could be chained) - template - wxLogger& Store(const wxString& key, T val) - { - m_info.StoreValue(key, val); - return *this; - } - - // hack for "overloaded" wxLogXXX() functions: calling this method - // indicates that we may have an extra first argument preceding the format - // string and that if we do have it, we should store it in m_info using the - // given key (while by default 0 value will be used) - wxLogger& MaybeStore(const wxString& key, wxUIntPtr value = 0) - { - wxASSERT_MSG( m_optKey.empty(), "can only have one optional value" ); - m_optKey = key; - - m_info.StoreValue(key, value); - return *this; - } - - - // non-vararg function used by wxVLogXXX(): - - // log the message at the level specified in the ctor if this log message - // is enabled - void LogV(const wxString& format, va_list argptr) - { - // remember that fatal errors can't be disabled - if ( m_level == wxLOG_FatalError || - wxLog::IsLevelEnabled(m_level, m_info.component) ) - DoCallOnLog(format, argptr); - } - - // overloads used by functions with optional leading arguments (whose - // values are stored in the key passed to MaybeStore()) - void LogV(long num, const wxString& format, va_list argptr) - { - Store(m_optKey, num); - - LogV(format, argptr); - } - - void LogV(void *ptr, const wxString& format, va_list argptr) - { - Store(m_optKey, wxPtrToUInt(ptr)); - - LogV(format, argptr); - } - - void LogVTrace(const wxString& mask, const wxString& format, va_list argptr) - { - if ( !wxLog::IsAllowedTraceMask(mask) ) - return; - - Store(wxLOG_KEY_TRACE_MASK, mask); - - LogV(format, argptr); - } - - - // vararg functions used by wxLogXXX(): - - // will log the message at the level specified in the ctor - // - // notice that this function supposes that the caller already checked that - // the level was enabled and does no checks itself - WX_DEFINE_VARARG_FUNC_VOID - ( - Log, - 1, (const wxFormatString&), - DoLog, DoLogUtf8 - ) - - // same as Log() but with an extra numeric or pointer parameters: this is - // used to pass an optional value by storing it in m_info under the name - // passed to MaybeStore() and is required to support "overloaded" versions - // of wxLogStatus() and wxLogSysError() - WX_DEFINE_VARARG_FUNC_VOID - ( - Log, - 2, (long, const wxFormatString&), - DoLogWithNum, DoLogWithNumUtf8 - ) - - // unfortunately we can't use "void *" here as we get overload ambiguities - // with Log(wxFormatString, ...) when the first argument is a "char *" or - // "wchar_t *" then -- so we only allow passing wxObject here, which is - // ugly but fine in practice as this overload is only used by wxLogStatus() - // whose first argument is a wxFrame - WX_DEFINE_VARARG_FUNC_VOID - ( - Log, - 2, (wxObject *, const wxFormatString&), - DoLogWithPtr, DoLogWithPtrUtf8 - ) - - // log the message at the level specified as its first argument - // - // as the macros don't have access to the level argument in this case, this - // function does check that the level is enabled itself - WX_DEFINE_VARARG_FUNC_VOID - ( - LogAtLevel, - 2, (wxLogLevel, const wxFormatString&), - DoLogAtLevel, DoLogAtLevelUtf8 - ) - - // special versions for wxLogTrace() which is passed either string or - // integer mask as first argument determining whether the message should be - // logged or not - WX_DEFINE_VARARG_FUNC_VOID - ( - LogTrace, - 2, (const wxString&, const wxFormatString&), - DoLogTrace, DoLogTraceUtf8 - ) - -#if WXWIN_COMPATIBILITY_2_8 - WX_DEFINE_VARARG_FUNC_VOID - ( - LogTrace, - 2, (wxTraceMask, const wxFormatString&), - DoLogTraceMask, DoLogTraceMaskUtf8 - ) -#endif // WXWIN_COMPATIBILITY_2_8 - -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 1, (const wxString&), - (wxFormatString(f1))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 1, (const wxCStrData&), - (wxFormatString(f1))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 1, (const char*), - (wxFormatString(f1))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 1, (const wchar_t*), - (wxFormatString(f1))) - - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (long, const wxString&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (long, const wxCStrData&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (long, const char *), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (long, const wchar_t *), - (f1, wxFormatString(f2))) - - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (wxObject *, const wxString&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (wxObject *, const wxCStrData&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (wxObject *, const char *), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, Log, - 2, (wxObject *, const wchar_t *), - (f1, wxFormatString(f2))) - - WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel, - 2, (wxLogLevel, const wxString&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel, - 2, (wxLogLevel, const wxCStrData&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel, - 2, (wxLogLevel, const char *), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel, - 2, (wxLogLevel, const wchar_t *), - (f1, wxFormatString(f2))) - - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (const wxString&, const wxString&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (const wxString&, const wxCStrData&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (const wxString&, const char *), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (const wxString&, const wchar_t *), - (f1, wxFormatString(f2))) - -#if WXWIN_COMPATIBILITY_2_8 - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (wxTraceMask, wxTraceMask), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (wxTraceMask, const wxCStrData&), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (wxTraceMask, const char *), - (f1, wxFormatString(f2))) - WX_VARARG_WATCOM_WORKAROUND(void, LogTrace, - 2, (wxTraceMask, const wchar_t *), - (f1, wxFormatString(f2))) -#endif // WXWIN_COMPATIBILITY_2_8 -#endif // __WATCOMC__ - -private: -#if !wxUSE_UTF8_LOCALE_ONLY - void DoLog(const wxChar *format, ...) - { - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogWithNum(long num, const wxChar *format, ...) - { - Store(m_optKey, num); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogWithPtr(void *ptr, const wxChar *format, ...) - { - Store(m_optKey, wxPtrToUInt(ptr)); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogAtLevel(wxLogLevel level, const wxChar *format, ...) - { - if ( !wxLog::IsLevelEnabled(level, m_info.component) ) - return; - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(level, format, argptr); - va_end(argptr); - } - - void DoLogTrace(const wxString& mask, const wxChar *format, ...) - { - if ( !wxLog::IsAllowedTraceMask(mask) ) - return; - - Store(wxLOG_KEY_TRACE_MASK, mask); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - -#if WXWIN_COMPATIBILITY_2_8 - void DoLogTraceMask(wxTraceMask mask, const wxChar *format, ...) - { - if ( (wxLog::GetTraceMask() & mask) != mask ) - return; - - Store(wxLOG_KEY_TRACE_MASK, mask); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } -#endif // WXWIN_COMPATIBILITY_2_8 -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 - void DoLogUtf8(const char *format, ...) - { - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogWithNumUtf8(long num, const char *format, ...) - { - Store(m_optKey, num); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogWithPtrUtf8(void *ptr, const char *format, ...) - { - Store(m_optKey, wxPtrToUInt(ptr)); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - - void DoLogAtLevelUtf8(wxLogLevel level, const char *format, ...) - { - if ( !wxLog::IsLevelEnabled(level, m_info.component) ) - return; - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(level, format, argptr); - va_end(argptr); - } - - void DoLogTraceUtf8(const wxString& mask, const char *format, ...) - { - if ( !wxLog::IsAllowedTraceMask(mask) ) - return; - - Store(wxLOG_KEY_TRACE_MASK, mask); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } - -#if WXWIN_COMPATIBILITY_2_8 - void DoLogTraceMaskUtf8(wxTraceMask mask, const char *format, ...) - { - if ( (wxLog::GetTraceMask() & mask) != mask ) - return; - - Store(wxLOG_KEY_TRACE_MASK, mask); - - va_list argptr; - va_start(argptr, format); - DoCallOnLog(format, argptr); - va_end(argptr); - } -#endif // WXWIN_COMPATIBILITY_2_8 -#endif // wxUSE_UNICODE_UTF8 - - void DoCallOnLog(wxLogLevel level, const wxString& format, va_list argptr) - { - wxLog::OnLog(level, wxString::FormatV(format, argptr), m_info); - } - - void DoCallOnLog(const wxString& format, va_list argptr) - { - DoCallOnLog(m_level, format, argptr); - } - - - const wxLogLevel m_level; - wxLogRecordInfo m_info; - - wxString m_optKey; - - wxDECLARE_NO_COPY_CLASS(wxLogger); -}; - // ============================================================================ // global functions // ============================================================================ +// ---------------------------------------------------------------------------- +// Log functions should be used by application instead of stdio, iostream &c +// for log messages for easy redirection +// ---------------------------------------------------------------------------- + // ---------------------------------------------------------------------------- // get error code/error message from system in a portable way // ---------------------------------------------------------------------------- @@ -1281,236 +485,36 @@ WXDLLIMPEXP_BASE unsigned long wxSysErrorCode(); WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0); // ---------------------------------------------------------------------------- -// define wxLog() functions which can be used by application instead of -// stdio, iostream &c for log messages for easy redirection +// define wxLog // ---------------------------------------------------------------------------- -/* - The code below is unreadable because it (unfortunately unavoidably) - contains a lot of macro magic but all it does is to define wxLogXXX() such - that you can call them as vararg functions to log a message at the - corresponding level. - - More precisely, it defines: - - - wxLog{FatalError,Error,Warning,Message,Verbose,Debug}() functions - taking the format string and additional vararg arguments if needed. - - wxLogGeneric(wxLogLevel level, const wxString& format, ...) which - takes the log level explicitly. - - wxLogSysError(const wxString& format, ...) and wxLogSysError(long - err, const wxString& format, ...) which log a wxLOG_Error severity - message with the error message corresponding to the system error code - err or the last error. - - wxLogStatus(const wxString& format, ...) which logs the message into - the status bar of the main application window and its overload - wxLogStatus(wxFrame *frame, const wxString& format, ...) which logs it - into the status bar of the specified frame. - - wxLogTrace(Mask mask, const wxString& format, ...) which only logs - the message is the specified mask is enabled. This comes in two kinds: - Mask can be a wxString or a long. Both are deprecated. - - In addition, wxVLogXXX() versions of all the functions above are also - defined. They take a va_list argument instead of "...". - */ - -// creates wxLogger object for the current location -#define wxMAKE_LOGGER(level) \ - wxLogger(wxLOG_##level, __FILE__, __LINE__, __WXFUNCTION__, wxLOG_COMPONENT) - -// this macro generates the expression which logs whatever follows it in -// parentheses at the level specified as argument -#define wxDO_LOG(level) wxMAKE_LOGGER(level).Log - -// this is the non-vararg equivalent -#define wxDO_LOGV(level, format, argptr) \ - wxMAKE_LOGGER(level).LogV(format, argptr) - -// this macro declares wxLog() macro which logs whatever follows it if -// logging at specified level is enabled (notice that if it is false, the -// following arguments are not even evaluated which is good as it avoids -// unnecessary overhead) -// -// Note: the strange (because executing at most once) for() loop because we -// must arrange for wxDO_LOG() to be at the end of the macro and using a -// more natural "if (IsLevelEnabled()) wxDO_LOG()" would result in wrong -// behaviour for the following code ("else" would bind to the wrong "if"): -// -// if ( cond ) -// wxLogError("!!!"); -// else -// ... -// -// See also #11829 for the problems with other simpler approaches, -// notably the need for two macros due to buggy __LINE__ in MSVC. -// -// Note 2: Unfortunately we can't use the same solution for all compilers -// because the loop-based one results in problems with MSVC6 due to its -// wrong (pre-C++98) rules for the scope of the variables declared -// inside the loop, as this prevents us from using wxLogXXX() in switch -// statement clauses ("initialization of loopvar skipped by case"). So -// for now, i.e. while we still support VC6, use the previous solution -// for it (FIXME-VC6). -#ifdef __VISUALC6__ -#define wxDO_LOG_IF_ENABLED(level) \ - if ( !wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxDO_LOG(level) -#else -#define wxDO_LOG_IF_ENABLED_HELPER(level, loopvar) \ - for ( bool loopvar = false; \ - !loopvar && wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT); \ - loopvar = true ) \ - wxDO_LOG(level) - -#define wxDO_LOG_IF_ENABLED(level) \ - wxDO_LOG_IF_ENABLED_HELPER(level, wxMAKE_UNIQUE_NAME(wxlogcheck)) -#endif - -// wxLogFatalError() is special as it can't be disabled -#define wxLogFatalError wxDO_LOG(FatalError) -#define wxVLogFatalError(format, argptr) wxDO_LOGV(FatalError, format, argptr) - -#define wxLogError wxDO_LOG_IF_ENABLED(Error) -#define wxVLogError(format, argptr) wxDO_LOGV(Error, format, argptr) - -#define wxLogWarning wxDO_LOG_IF_ENABLED(Warning) -#define wxVLogWarning(format, argptr) wxDO_LOGV(Warning, format, argptr) - -#define wxLogMessage wxDO_LOG_IF_ENABLED(Message) -#define wxVLogMessage(format, argptr) wxDO_LOGV(Message, format, argptr) - -// this one is special as it only logs if we're in verbose mode -#define wxLogVerbose \ - if ( !(wxLog::IsLevelEnabled(wxLOG_Info, wxLOG_COMPONENT) && \ - wxLog::GetVerbose()) ) \ - {} \ - else \ - wxDO_LOG(Info) -#define wxVLogVerbose(format, argptr) \ - if ( !(wxLog::IsLevelEnabled(wxLOG_Info, wxLOG_COMPONENT) && \ - wxLog::GetVerbose()) ) \ - {} \ - else \ - wxDO_LOGV(Info, format, argptr) - -// deprecated synonyms for wxLogVerbose() and wxVLogVerbose() -#define wxLogInfo wxLogVerbose -#define wxVLogInfo wxVLogVerbose - - -// another special case: the level is passed as first argument of the function -// and so is not available to the macro -// -// notice that because of this, arguments of wxLogGeneric() are currently -// always evaluated, unlike for the other log functions -#define wxLogGeneric wxMAKE_LOGGER(Max).LogAtLevel -#define wxVLogGeneric(level, format, argptr) \ - if ( !wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxDO_LOGV(level, format, argptr) - - -// wxLogSysError() needs to stash the error code value in the log record info -// so it needs special handling too; additional complications arise because the -// error code may or not be present as the first argument -// -// notice that we unfortunately can't avoid the call to wxSysErrorCode() even -// though it may be unneeded if an explicit error code is passed to us because -// the message might not be logged immediately (e.g. it could be queued for -// logging from the main thread later) and so we can't to wait until it is -// logged to determine whether we have last error or not as it will be too late -// and it will have changed already by then (in fact it even changes when -// wxString::Format() is called because of vsnprintf() inside it so it can -// change even much sooner) -#define wxLOG_KEY_SYS_ERROR_CODE "wx.sys_error" - -#define wxLogSysError \ - if ( !wxLog::IsLevelEnabled(wxLOG_Error, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxMAKE_LOGGER(Error).MaybeStore(wxLOG_KEY_SYS_ERROR_CODE, \ - wxSysErrorCode()).Log - -// unfortunately we can't have overloaded macros so we can't define versions -// both with and without error code argument and have to rely on LogV() -// overloads in wxLogger to select between them -#define wxVLogSysError \ - wxMAKE_LOGGER(Error).MaybeStore(wxLOG_KEY_SYS_ERROR_CODE, \ - wxSysErrorCode()).LogV - -#if wxUSE_GUI - // wxLogStatus() is similar to wxLogSysError() as it allows to optionally - // specify the frame to which the message should go - #define wxLOG_KEY_FRAME "wx.frame" - - #define wxLogStatus \ - if ( !wxLog::IsLevelEnabled(wxLOG_Status, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxMAKE_LOGGER(Status).MaybeStore(wxLOG_KEY_FRAME).Log - - #define wxVLogStatus \ - wxMAKE_LOGGER(Status).MaybeStore(wxLOG_KEY_FRAME).LogV -#endif // wxUSE_GUI - - +#define DECLARE_LOG_FUNCTION(level) \ +extern void WXDLLIMPEXP_BASE wxVLog##level(const wxChar *szFormat, \ + va_list argptr); \ +extern void WXDLLIMPEXP_BASE wxLog##level(const wxChar *szFormat, \ + ...) ATTRIBUTE_PRINTF_1 +#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \ +extern void expdecl wxVLog##level(argclass arg, \ + const wxChar *szFormat, \ + va_list argptr); \ +extern void expdecl wxLog##level(argclass arg, \ + const wxChar *szFormat, \ + ...) ATTRIBUTE_PRINTF_2 #else // !wxUSE_LOG -#undef wxUSE_LOG_DEBUG -#define wxUSE_LOG_DEBUG 0 - -#undef wxUSE_LOG_TRACE -#define wxUSE_LOG_TRACE 0 - -#if defined(__WATCOMC__) || defined(__MINGW32__) - // Mingw has similar problem with wxLogSysError: - #define WX_WATCOM_OR_MINGW_ONLY_CODE( x ) x -#else - #define WX_WATCOM_OR_MINGW_ONLY_CODE( x ) -#endif - -// define macros for defining log functions which do nothing at all -// -// WX_WATCOM_ONLY_CODE is needed to work around -// http://bugzilla.openwatcom.org/show_bug.cgi?id=351 -#define wxDEFINE_EMPTY_LOG_FUNCTION(level) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxFormatString&)) \ - WX_WATCOM_ONLY_CODE( \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const char*)) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wchar_t*)) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxCStrData&)) \ - ) \ - inline void wxVLog##level(const wxFormatString& WXUNUSED(format), \ - va_list WXUNUSED(argptr)) { } \ - -#define wxDEFINE_EMPTY_LOG_FUNCTION2(level, argclass) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxFormatString&)) \ - WX_WATCOM_OR_MINGW_ONLY_CODE( \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const char*)) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wchar_t*)) \ - WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \ - ) \ - inline void wxVLog##level(argclass WXUNUSED(arg), \ - const wxFormatString& WXUNUSED(format), \ - va_list WXUNUSED(argptr)) {} - -wxDEFINE_EMPTY_LOG_FUNCTION(FatalError); -wxDEFINE_EMPTY_LOG_FUNCTION(Error); -wxDEFINE_EMPTY_LOG_FUNCTION(SysError); -wxDEFINE_EMPTY_LOG_FUNCTION2(SysError, long); -wxDEFINE_EMPTY_LOG_FUNCTION(Warning); -wxDEFINE_EMPTY_LOG_FUNCTION(Message); -wxDEFINE_EMPTY_LOG_FUNCTION(Info); -wxDEFINE_EMPTY_LOG_FUNCTION(Verbose); - -wxDEFINE_EMPTY_LOG_FUNCTION2(Generic, wxLogLevel); - -#if wxUSE_GUI - wxDEFINE_EMPTY_LOG_FUNCTION(Status); - wxDEFINE_EMPTY_LOG_FUNCTION2(Status, wxFrame *); -#endif // wxUSE_GUI +// log functions do nothing at all +#define DECLARE_LOG_FUNCTION(level) \ +inline void wxVLog##level(const wxChar *WXUNUSED(szFormat), \ + va_list WXUNUSED(argptr)) { } \ +inline void wxLog##level(const wxChar *WXUNUSED(szFormat), \ + ...) { } +#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \ +inline void wxVLog##level(argclass WXUNUSED(arg), \ + const wxChar *WXUNUSED(szFormat), \ + va_list WXUNUSED(argptr)) {} \ +inline void wxLog##level(argclass WXUNUSED(arg), \ + const wxChar *WXUNUSED(szFormat), \ + ...) { } // Empty Class to fake wxLogNull class WXDLLIMPEXP_BASE wxLogNull @@ -1528,70 +532,85 @@ public: #endif // wxUSE_LOG/!wxUSE_LOG +#define DECLARE_LOG_FUNCTION2(level, argclass, arg) \ + DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, WXDLLIMPEXP_BASE) -// debug functions can be completely disabled in optimized builds -// if these log functions are disabled, we prefer to define them as (empty) -// variadic macros as this completely removes them and their argument -// evaluation from the object code but if this is not supported by compiler we -// use empty inline functions instead (defining them as nothing would result in -// compiler warnings) -// -// note that making wxVLogDebug/Trace() themselves (empty inline) functions is -// a bad idea as some compilers are stupid enough to not inline even empty -// functions if their parameters are complicated enough, but by defining them -// as an empty inline function we ensure that even dumbest compilers optimise -// them away -#ifdef __BORLANDC__ - // but Borland gives "W8019: Code has no effect" for wxLogNop() so we need - // to define it differently for it to avoid these warnings (same problem as - // with wxUnusedVar()) - #define wxLogNop() { } -#else +// a generic function for all levels (level is passes as parameter) +DECLARE_LOG_FUNCTION2(Generic, wxLogLevel, level); + +// one function per each level +DECLARE_LOG_FUNCTION(FatalError); +DECLARE_LOG_FUNCTION(Error); +DECLARE_LOG_FUNCTION(Warning); +DECLARE_LOG_FUNCTION(Message); +DECLARE_LOG_FUNCTION(Info); +DECLARE_LOG_FUNCTION(Verbose); + +// this function sends the log message to the status line of the top level +// application frame, if any +DECLARE_LOG_FUNCTION(Status); + +#if wxUSE_GUI + // this one is the same as previous except that it allows to explicitly + class WXDLLIMPEXP_FWD_CORE wxFrame; + // specify the frame to which the output should go + DECLARE_LOG_FUNCTION2_EXP(Status, wxFrame *, pFrame, WXDLLIMPEXP_CORE); +#endif // wxUSE_GUI + +// additional one: as wxLogError, but also logs last system call error code +// and the corresponding error message if available +DECLARE_LOG_FUNCTION(SysError); + +// and another one which also takes the error code (for those broken APIs +// that don't set the errno (like registry APIs in Win32)) +DECLARE_LOG_FUNCTION2(SysError, long, lErrCode); + +// debug functions do nothing in release mode +#if wxUSE_LOG && wxUSE_LOG_DEBUG + DECLARE_LOG_FUNCTION(Debug); + + // there is no more unconditional LogTrace: it is not different from + // LogDebug and it creates overload ambiguities + //DECLARE_LOG_FUNCTION(Trace); + + // this version only logs the message if the mask had been added to the + // list of masks with AddTraceMask() + DECLARE_LOG_FUNCTION2(Trace, const wxChar *, mask); + + // and this one does nothing if all of level bits are not set in + // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of + // string identifiers + DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask); +#else //!debug || !wxUSE_LOG + // these functions do nothing in release builds, but don't define them as + // nothing as it could result in different code structure in debug and + // release and this could result in trouble when these macros are used + // inside if/else + // + // note that making wxVLogDebug/Trace() themselves (empty inline) functions + // is a bad idea as some compilers are stupid enough to not inline even + // empty functions if their parameters are complicated enough, but by + // defining them as an empty inline function we ensure that even dumbest + // compilers optimise them away inline void wxLogNop() { } -#endif -#if wxUSE_LOG_DEBUG - #define wxLogDebug wxDO_LOG_IF_ENABLED(Debug) - #define wxVLogDebug(format, argptr) wxDO_LOGV(Debug, format, argptr) -#else // !wxUSE_LOG_DEBUG #define wxVLogDebug(fmt, valist) wxLogNop() - - #ifdef HAVE_VARIADIC_MACROS - #define wxLogDebug(fmt, ...) wxLogNop() - #else // !HAVE_VARIADIC_MACROS - WX_DEFINE_VARARG_FUNC_NOP(wxLogDebug, 1, (const wxFormatString&)) - #endif -#endif // wxUSE_LOG_DEBUG/!wxUSE_LOG_DEBUG - -#if wxUSE_LOG_TRACE - #define wxLogTrace \ - if ( !wxLog::IsLevelEnabled(wxLOG_Trace, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxMAKE_LOGGER(Trace).LogTrace - #define wxVLogTrace \ - if ( !wxLog::IsLevelEnabled(wxLOG_Trace, wxLOG_COMPONENT) ) \ - {} \ - else \ - wxMAKE_LOGGER(Trace).LogVTrace -#else // !wxUSE_LOG_TRACE #define wxVLogTrace(mask, fmt, valist) wxLogNop() #ifdef HAVE_VARIADIC_MACROS + // unlike the inline functions below, this completely removes the + // wxLogXXX calls from the object file: + #define wxLogDebug(fmt, ...) wxLogNop() #define wxLogTrace(mask, fmt, ...) wxLogNop() #else // !HAVE_VARIADIC_MACROS - #if WXWIN_COMPATIBILITY_2_8 - WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (wxTraceMask, const wxFormatString&)) - #endif - WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wxString&, const wxFormatString&)) - #ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const char*, const char*)) - WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wchar_t*, const wchar_t*)) - #endif + // note that leaving out "fmt" in the vararg functions provokes a warning + // from SGI CC: "the last argument of the varargs function is unnamed" + inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } + inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS -#endif // wxUSE_LOG_TRACE/!wxUSE_LOG_TRACE +#endif // debug/!debug // wxLogFatalError helper: show the (fatal) error to the user in a safe way, // i.e. without using wxMessageBox() for example because it could crash @@ -1602,46 +621,33 @@ wxSafeShowMessage(const wxString& title, const wxString& text); // debug only logging functions: use them with API name and error code // ---------------------------------------------------------------------------- -#if wxUSE_LOG_DEBUG +#ifdef __WXDEBUG__ // make life easier for people using VC++ IDE: clicking on the message // will take us immediately to the place of the failed API #ifdef __VISUALC__ #define wxLogApiError(api, rc) \ wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."), \ - __FILE__, __LINE__, api, \ + __TFILE__, __LINE__, api, \ (long)rc, wxSysErrorMsg(rc)) #else // !VC++ #define wxLogApiError(api, rc) \ wxLogDebug(wxT("In file %s at line %d: '%s' failed with ") \ wxT("error 0x%08lx (%s)."), \ - __FILE__, __LINE__, api, \ + __TFILE__, __LINE__, api, \ (long)rc, wxSysErrorMsg(rc)) #endif // VC++/!VC++ #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode()) -#else // !wxUSE_LOG_DEBUG +#else //!debug #define wxLogApiError(api, err) wxLogNop() #define wxLogLastError(api) wxLogNop() -#endif // wxUSE_LOG_DEBUG/!wxUSE_LOG_DEBUG +#endif //debug/!debug // wxCocoa has additiional trace masks #if defined(__WXCOCOA__) #include "wx/cocoa/log.h" #endif -#ifdef WX_WATCOM_ONLY_CODE - #undef WX_WATCOM_ONLY_CODE -#endif - -// macro which disables debug logging in release builds: this is done by -// default by wxIMPLEMENT_APP() so usually it doesn't need to be used explicitly -#if defined(NDEBUG) && wxUSE_LOG_DEBUG - #define wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD() \ - wxLog::SetLogLevel(wxLOG_Info) -#else // !NDEBUG - #define wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD() -#endif // NDEBUG/!NDEBUG - #endif // _WX_LOG_H_ diff --git a/Source/3rd Party/wx/include/wx/longlong.h b/Source/3rd Party/wx/include/wx/longlong.h index d389c0733..304001d8d 100644 --- a/Source/3rd Party/wx/include/wx/longlong.h +++ b/Source/3rd Party/wx/include/wx/longlong.h @@ -5,6 +5,7 @@ // Author: Jeffrey C. Ollie , Vadim Zeitlin // Modified by: // Created: 10.02.99 +// RCS-ID: $Id: longlong.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -66,8 +67,8 @@ #define wxUSE_LONGLONG_NATIVE 0 #endif - class WXDLLIMPEXP_FWD_BASE wxLongLongWx; - class WXDLLIMPEXP_FWD_BASE wxULongLongWx; + class WXDLLIMPEXP_BASE wxLongLongWx; + class WXDLLIMPEXP_BASE wxULongLongWx; #if defined(__VISUALC__) && !defined(__WIN32__) #define wxLongLong wxLongLongWx #define wxULongLong wxULongLongWx @@ -403,20 +404,15 @@ public: // convert to ulong with range checking in debug mode (only!) unsigned long ToULong() const { - wxASSERT_MSG( m_ll <= ULONG_MAX, + wxASSERT_MSG( m_ll <= LONG_MAX, wxT("wxULongLong to long conversion loss of precision") ); return wx_truncate_cast(unsigned long, m_ll); } // convert to double - // - // For some completely obscure reasons compiling the cast below with - // VC6 in DLL builds only (!) results in "error C2520: conversion from - // unsigned __int64 to double not implemented, use signed __int64" so - // we must use a different version for that compiler. -#ifdef __VISUALC6__ - double ToDouble() const; +#ifdef _MSC_VER + double ToDouble() const { return wx_truncate_cast(double, (__int64) m_ll); } #else double ToDouble() const { return wx_truncate_cast(double, m_ll); } #endif @@ -1066,7 +1062,7 @@ inline wxULongLong operator+(unsigned long l, const wxULongLong& ull) { return u inline wxLongLong operator-(unsigned long l, const wxULongLong& ull) { wxULongLong ret = wxULongLong(l) - ull; - return wxLongLong((wxInt32)ret.GetHi(),ret.GetLo()); + return wxLongLong((long)ret.GetHi(),ret.GetLo()); } #if wxUSE_LONGLONG_NATIVE && wxUSE_STREAMS @@ -1079,66 +1075,6 @@ WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &st #endif -// ---------------------------------------------------------------------------- -// Specialize numeric_limits<> for our long long wrapper classes. -// ---------------------------------------------------------------------------- - -#if wxUSE_LONGLONG_NATIVE - -// VC6 is known to not have __int64 specializations of numeric_limits<> in its -// anyhow so don't bother including it, especially as it results in -// tons of warnings because the standard header itself uses obsolete template -// specialization syntax. -#ifndef __VISUALC6__ - -#include - -namespace std -{ - -#ifdef __clang__ - // libstdc++ (used by Clang) uses struct for numeric_limits; unlike gcc, clang - // warns about this - template<> struct numeric_limits : public numeric_limits {}; - template<> struct numeric_limits : public numeric_limits {}; -#else - template<> class numeric_limits : public numeric_limits {}; - template<> class numeric_limits : public numeric_limits {}; -#endif - -} // namespace std - -#endif // !VC6 - -#endif // wxUSE_LONGLONG_NATIVE - -// ---------------------------------------------------------------------------- -// Specialize wxArgNormalizer to allow using wxLongLong directly with wx pseudo -// vararg functions. -// ---------------------------------------------------------------------------- - -// Notice that this must be done here and not in wx/strvararg.h itself because -// we can't include wx/longlong.h from there as this header itself includes -// wx/string.h which includes wx/strvararg.h too, so to avoid the circular -// dependencies we can only do it here (or add another header just for this but -// it doesn't seem necessary). -#include "wx/strvararg.h" - -template<> -struct WXDLLIMPEXP_BASE wxArgNormalizer -{ - wxArgNormalizer(wxLongLong value, - const wxFormatString *fmt, unsigned index) - : m_value(value) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_LongLongInt ); - } - - wxLongLong_t get() const { return m_value.GetValue(); } - - wxLongLong m_value; -}; - #endif // wxUSE_LONGLONG #endif // _WX_LONGLONG_H diff --git a/Source/3rd Party/wx/include/wx/math.h b/Source/3rd Party/wx/include/wx/math.h index 272800eaa..5ac102151 100644 --- a/Source/3rd Party/wx/include/wx/math.h +++ b/Source/3rd Party/wx/include/wx/math.h @@ -4,6 +4,7 @@ * Author: John Labenski and others * Modified by: * Created: 02/02/03 +* RCS-ID: $Id: math.h 62541 2009-11-03 14:10:46Z VZ $ * Copyright: (c) John Labenski * Licence: wxWindows licence */ @@ -21,9 +22,9 @@ #define M_PI 3.1415926535897932384626433832795 #endif -/* Scaling factors for various unit conversions: 1 inch = 2.54 cm */ +/* Scaling factors for various unit conversions */ #ifndef METRIC_CONVERSION_CONSTANT - #define METRIC_CONVERSION_CONSTANT (1/25.4) + #define METRIC_CONVERSION_CONSTANT 0.0393700787 #endif #ifndef mm2inches @@ -51,32 +52,14 @@ #endif -#ifdef __cplusplus +/* unknown __VISAGECC__, __SYMANTECCC__ */ -/* Any C++11 compiler should provide isfinite() */ -#if __cplusplus >= 201103 - #include - #define wxFinite(x) std::isfinite(x) -#elif defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) +#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) #include #define wxFinite(x) _finite(x) -#elif defined(__MINGW64_TOOLCHAIN__) || defined(__clang__) - /* - add more compilers with C99 support here: using C99 isfinite() is - preferable to using BSD-ish finite() - */ - #if defined(_GLIBCXX_CMATH) || defined(_LIBCPP_CMATH) - // these headers #undef isfinite - #define wxFinite(x) std::isfinite(x) - #else - #define wxFinite(x) isfinite(x) - #endif -#elif ( defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \ +#elif defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \ defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \ - defined(__HPUX__) ) && ( !defined(wxOSX_USE_IPHONE) || wxOSX_USE_IPHONE == 0 ) -#ifdef __SOLARIS__ -#include -#endif + defined(__HPUX__)||defined(__MWERKS__) #define wxFinite(x) finite(x) #else #define wxFinite(x) ((x) == (x)) @@ -87,59 +70,58 @@ #define wxIsNaN(x) _isnan(x) #elif defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \ defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \ - defined(__HPUX__) + defined(__HPUX__)||defined(__MWERKS__) #define wxIsNaN(x) isnan(x) #else #define wxIsNaN(x) ((x) != (x)) #endif -#ifdef __INTELC__ +#ifdef __cplusplus - inline bool wxIsSameDouble(double x, double y) + #ifdef __INTELC__ + + inline bool wxIsSameDouble(double x, double y) + { + // VZ: this warning, given for operators==() and !=() is not wrong, as == + // shouldn't be used with doubles, but we get too many of them and + // removing these operators is probably not a good idea + // + // Maybe we should alway compare doubles up to some "epsilon" precision + #pragma warning(push) + + // floating-point equality and inequality comparisons are unreliable + #pragma warning(disable: 1572) + + return x == y; + + #pragma warning(pop) + } + + #else /* !__INTELC__ */ + + inline bool wxIsSameDouble(double x, double y) { return x == y; } + + #endif /* __INTELC__/!__INTELC__ */ + + inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); } + + inline int wxRound(double x) { - // VZ: this warning, given for operators==() and !=() is not wrong, as == - // shouldn't be used with doubles, but we get too many of them and - // removing these operators is probably not a good idea - // - // Maybe we should always compare doubles up to some "epsilon" precision - #pragma warning(push) - - // floating-point equality and inequality comparisons are unreliable - #pragma warning(disable: 1572) - - return x == y; - - #pragma warning(pop) + #if defined(HAVE_ROUND) + return int(round(x)); + #else + return (int)(x < 0 ? x - 0.5 : x + 0.5); + #endif } - -#else /* !__INTELC__ */ - wxGCC_WARNING_SUPPRESS(float-equal) - inline bool wxIsSameDouble(double x, double y) { return x == y; } - wxGCC_WARNING_RESTORE(float-equal) - -#endif /* __INTELC__/!__INTELC__ */ - -inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); } - -inline int wxRound(double x) -{ - wxASSERT_MSG( x > INT_MIN - 0.5 && x < INT_MAX + 0.5, - wxT("argument out of supported range") ); - - #if defined(HAVE_ROUND) - return int(round(x)); - #else - return (int)(x < 0 ? x - 0.5 : x + 0.5); - #endif -} - #endif /* __cplusplus */ -#if defined(__WINDOWS__) && !defined(__WXWINCE__) +#if defined(__WXMSW__) && !defined(__WXWINCE__) #define wxMulDivInt32( a , b , c ) ::MulDiv( a , b , c ) +#elif defined( __WXMAC__ ) + #define wxMulDivInt32( a , b , c ) ( (wxInt32) ( ( (wxInt64)(a) * (wxInt64)(b) ) / (wxInt64)(c) ) ) #else - #define wxMulDivInt32( a , b , c ) (wxRound((a)*(((wxDouble)b)/((wxDouble)c)))) + #define wxMulDivInt32( a , b , c ) ((wxInt32)((a)*(((wxDouble)b)/((wxDouble)c)))) #endif #if wxUSE_APPLE_IEEE @@ -147,15 +129,8 @@ inline int wxRound(double x) extern "C" { #endif /* functions from common/extended.c */ - WXDLLIMPEXP_BASE wxFloat64 wxConvertFromIeeeExtended(const wxInt8 *bytes); - WXDLLIMPEXP_BASE void wxConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes); - - /* use wxConvertFromIeeeExtended() and wxConvertToIeeeExtended() instead */ -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( WXDLLIMPEXP_BASE wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes) ); - wxDEPRECATED( WXDLLIMPEXP_BASE void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes) ); -#endif - + WXDLLEXPORT wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes); + WXDLLEXPORT void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes); #ifdef __cplusplus } #endif diff --git a/Source/3rd Party/wx/include/wx/matrix.h b/Source/3rd Party/wx/include/wx/matrix.h index a10e42bf7..11c688ba4 100644 --- a/Source/3rd Party/wx/include/wx/matrix.h +++ b/Source/3rd Party/wx/include/wx/matrix.h @@ -4,6 +4,7 @@ // Author: Chris Breeze, Julian Smart // Modified by: Klaas Holwerda // Created: 01/02/97 +// RCS-ID: $Id: matrix.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) Julian Smart, Chris Breeze // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,7 +32,7 @@ // at a certain coordinate and angle within another parent picture. // At all times m_isIdentity is set if the matrix itself is an Identity matrix. // It is used where possible to optimize calculations. -class WXDLLIMPEXP_CORE wxTransformMatrix: public wxObject +class WXDLLEXPORT wxTransformMatrix: public wxObject { public: wxTransformMatrix(void); diff --git a/Source/3rd Party/wx/include/wx/mdi.h b/Source/3rd Party/wx/include/wx/mdi.h index dda4aacf5..7a9eeca59 100644 --- a/Source/3rd Party/wx/include/wx/mdi.h +++ b/Source/3rd Party/wx/include/wx/mdi.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/mdi.h // Purpose: wxMDI base header -// Author: Julian Smart (original) -// Vadim Zeitlin (base MDI classes refactoring) -// Copyright: (c) 1998 Julian Smart -// (c) 2008 Vadim Zeitlin +// Author: Julian Smart +// Modified by: +// Created: +// Copyright: (c) Julian Smart +// RCS-ID: $Id: mdi.h 37066 2006-01-23 03:27:34Z MR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,393 +16,25 @@ #if wxUSE_MDI -#include "wx/frame.h" -#include "wx/menu.h" - -// forward declarations -class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame; -class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; -class WXDLLIMPEXP_FWD_CORE wxMDIClientWindowBase; -class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow; - -// ---------------------------------------------------------------------------- -// wxMDIParentFrameBase: base class for parent frame for MDI children -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMDIParentFrameBase : public wxFrame -{ -public: - wxMDIParentFrameBase() - { - m_clientWindow = NULL; - m_currentChild = NULL; -#if wxUSE_MENUS - m_windowMenu = NULL; -#endif // wxUSE_MENUS - } - - /* - Derived classes should provide ctor and Create() with the following - declaration: - - bool Create(wxWindow *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr); - */ - -#if wxUSE_MENUS - virtual ~wxMDIParentFrameBase() - { - delete m_windowMenu; - } -#endif // wxUSE_MENUS - - // accessors - // --------- - - // Get or change the active MDI child window - virtual wxMDIChildFrame *GetActiveChild() const - { return m_currentChild; } - virtual void SetActiveChild(wxMDIChildFrame *child) - { m_currentChild = child; } - - - // Get the client window - wxMDIClientWindowBase *GetClientWindow() const { return m_clientWindow; } - - - // MDI windows menu functions - // -------------------------- - -#if wxUSE_MENUS - // return the pointer to the current window menu or NULL if we don't have - // because of wxFRAME_NO_WINDOW_MENU style - wxMenu* GetWindowMenu() const { return m_windowMenu; } - - // use the given menu instead of the default window menu - // - // menu can be NULL to disable the window menu completely - virtual void SetWindowMenu(wxMenu *menu) - { - if ( menu != m_windowMenu ) - { - delete m_windowMenu; - m_windowMenu = menu; - } - } -#endif // wxUSE_MENUS - - - // standard MDI window management functions - // ---------------------------------------- - - virtual void Cascade() { } - virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { } - virtual void ArrangeIcons() { } - virtual void ActivateNext() = 0; - virtual void ActivatePrevious() = 0; - - /* - Derived classes must provide the following function: - - static bool IsTDI(); - */ - - // Create the client window class (don't Create() the window here, just - // return a new object of a wxMDIClientWindow-derived class) - // - // Notice that if you override this method you should use the default - // constructor and Create() and not the constructor creating the window - // when creating the frame or your overridden version is not going to be - // called (as the call to a virtual function from ctor will be dispatched - // to this class version) - virtual wxMDIClientWindow *OnCreateClient(); - -protected: - // Override to pass menu/toolbar events to the active child first. - virtual bool TryBefore(wxEvent& event); - - - // This is wxMDIClientWindow for all the native implementations but not for - // the generic MDI version which has its own wxGenericMDIClientWindow and - // so we store it as just a base class pointer because we don't need its - // exact type anyhow - wxMDIClientWindowBase *m_clientWindow; - wxMDIChildFrame *m_currentChild; - -#if wxUSE_MENUS - // the current window menu or NULL if we are not using it - wxMenu *m_windowMenu; -#endif // wxUSE_MENUS -}; - -// ---------------------------------------------------------------------------- -// wxMDIChildFrameBase: child frame managed by wxMDIParentFrame -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMDIChildFrameBase : public wxFrame -{ -public: - wxMDIChildFrameBase() { m_mdiParent = NULL; } - - /* - Derived classes should provide Create() with the following signature: - - bool Create(wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - - And setting m_mdiParent to parent parameter. - */ - - // MDI children specific methods - virtual void Activate() = 0; - - // Return the MDI parent frame: notice that it may not be the same as - // GetParent() (our parent may be the client window or even its subwindow - // in some implementations) - wxMDIParentFrame *GetMDIParent() const { return m_mdiParent; } - - // Synonym for GetMDIParent(), was used in some other ports - wxMDIParentFrame *GetMDIParentFrame() const { return GetMDIParent(); } - - - // in most ports MDI children frames are not really top-level, the only - // exception are the Mac ports in which MDI children are just normal top - // level windows too - virtual bool IsTopLevel() const { return false; } - - // In all ports keyboard navigation must stop at MDI child frame level and - // can't cross its boundary. Indicate this by overriding this function to - // return true. - virtual bool IsTopNavigationDomain() const { return true; } - - // Raising any frame is supposed to show it but wxFrame Raise() - // implementation doesn't work for MDI child frames in most forms so - // forward this to Activate() which serves the same purpose by default. - virtual void Raise() { Activate(); } - -protected: - wxMDIParentFrame *m_mdiParent; -}; - -// ---------------------------------------------------------------------------- -// wxTDIChildFrame: child frame used by TDI implementations -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTDIChildFrame : public wxMDIChildFrameBase -{ -public: - // override wxFrame methods for this non top-level window - -#if wxUSE_STATUSBAR - // no status bars - // - // TODO: MDI children should have their own status bars, why not? - virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1, - long WXUNUSED(style) = 1, - wxWindowID WXUNUSED(id) = 1, - const wxString& WXUNUSED(name) - = wxEmptyString) - { return NULL; } - - virtual wxStatusBar *GetStatusBar() const - { return NULL; } - virtual void SetStatusText(const wxString &WXUNUSED(text), - int WXUNUSED(number)=0) - { } - virtual void SetStatusWidths(int WXUNUSED(n), - const int WXUNUSED(widths)[]) - { } -#endif // wxUSE_STATUSBAR - -#if wxUSE_TOOLBAR - // no toolbar - // - // TODO: again, it should be possible to have tool bars - virtual wxToolBar *CreateToolBar(long WXUNUSED(style), - wxWindowID WXUNUSED(id), - const wxString& WXUNUSED(name)) - { return NULL; } - virtual wxToolBar *GetToolBar() const { return NULL; } -#endif // wxUSE_TOOLBAR - - // no icon - virtual void SetIcons(const wxIconBundle& WXUNUSED(icons)) { } - - // title is used as the tab label - virtual wxString GetTitle() const { return m_title; } - virtual void SetTitle(const wxString& title) = 0; - - // no maximize etc - virtual void Maximize(bool WXUNUSED(maximize) = true) { } - virtual bool IsMaximized() const { return true; } - virtual bool IsAlwaysMaximized() const { return true; } - virtual void Iconize(bool WXUNUSED(iconize) = true) { } - virtual bool IsIconized() const { return false; } - virtual void Restore() { } - - virtual bool ShowFullScreen(bool WXUNUSED(show), - long WXUNUSED(style)) { return false; } - virtual bool IsFullScreen() const { return false; } - - - // we need to override these functions to ensure that a child window is - // created even though we derive from wxFrame -- basically we make it - // behave as just a wxWindow by short-circuiting wxTLW changes to the base - // class behaviour - - virtual void AddChild(wxWindowBase *child) { wxWindow::AddChild(child); } - - virtual bool Destroy() { return wxWindow::Destroy(); } - - // extra platform-specific hacks -#ifdef __WXMSW__ - virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const - { - return wxWindow::MSWGetStyle(flags, exstyle); - } - - virtual WXHWND MSWGetParent() const - { - return wxWindow::MSWGetParent(); - } - - WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) - { - return wxWindow::MSWWindowProc(message, wParam, lParam); - } -#endif // __WXMSW__ - -protected: - virtual void DoGetSize(int *width, int *height) const - { - wxWindow::DoGetSize(width, height); - } - - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags) - { - wxWindow::DoSetSize(x, y, width, height, sizeFlags); - } - - virtual void DoGetClientSize(int *width, int *height) const - { - wxWindow::DoGetClientSize(width, height); - } - - virtual void DoSetClientSize(int width, int height) - { - wxWindow::DoSetClientSize(width, height); - } - - virtual void DoMoveWindow(int x, int y, int width, int height) - { - wxWindow::DoMoveWindow(x, y, width, height); - } - - // no size hints - virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), - int WXUNUSED(maxW), int WXUNUSED(maxH), - int WXUNUSED(incW), int WXUNUSED(incH)) { } - - wxString m_title; -}; - -// ---------------------------------------------------------------------------- -// wxMDIClientWindowBase: child of parent frame, parent of children frames -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMDIClientWindowBase : public wxWindow -{ -public: - /* - The derived class must provide the default ctor only (CreateClient() - will be called later). - */ - - // Can be overridden in the derived classes but the base class version must - // be usually called first to really create the client window. - virtual bool CreateClient(wxMDIParentFrame *parent, - long style = wxVSCROLL | wxHSCROLL) = 0; -}; - -// ---------------------------------------------------------------------------- -// Include the port-specific implementation of the base classes defined above -// ---------------------------------------------------------------------------- - -// wxUSE_GENERIC_MDI_AS_NATIVE may be predefined to force the generic MDI -// implementation use even on the platforms which usually don't use it -// -// notice that generic MDI can still be used without this, but you would need -// to explicitly use wxGenericMDIXXX classes in your code (and currently also -// add src/generic/mdig.cpp to your build as it's not compiled in if generic -// MDI is not used by default -- but this may change later...) -#ifndef wxUSE_GENERIC_MDI_AS_NATIVE - // wxUniv always uses the generic MDI implementation and so do the ports - // without native version (although wxCocoa seems to have one -- but it's - // probably not functional?) - #if defined(__WXCOCOA__) || \ - defined(__WXMOTIF__) || \ - defined(__WXPM__) || \ - defined(__WXUNIVERSAL__) - #define wxUSE_GENERIC_MDI_AS_NATIVE 1 - #else - #define wxUSE_GENERIC_MDI_AS_NATIVE 0 - #endif -#endif // wxUSE_GENERIC_MDI_AS_NATIVE - -#if wxUSE_GENERIC_MDI_AS_NATIVE +#if defined(__WXUNIVERSAL__) #include "wx/generic/mdig.h" #elif defined(__WXMSW__) #include "wx/msw/mdi.h" +#elif defined(__WXMOTIF__) + #include "wx/motif/mdi.h" #elif defined(__WXGTK20__) #include "wx/gtk/mdi.h" #elif defined(__WXGTK__) #include "wx/gtk1/mdi.h" #elif defined(__WXMAC__) - #include "wx/osx/mdi.h" + #include "wx/mac/mdi.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/mdi.h" +#elif defined(__WXPM__) + #include "wx/generic/mdig.h" #endif -inline wxMDIClientWindow *wxMDIParentFrameBase::OnCreateClient() -{ - return new wxMDIClientWindow; -} - -inline bool wxMDIParentFrameBase::TryBefore(wxEvent& event) -{ - // Menu (and toolbar) events should be sent to the active child frame - // first, if any. - if ( event.GetEventType() == wxEVT_MENU || - event.GetEventType() == wxEVT_UPDATE_UI ) - { - wxMDIChildFrame * const child = GetActiveChild(); - if ( child ) - { - // However avoid sending the event back to the child if it's - // currently being propagated to us from it. - wxWindow* const - from = static_cast(event.GetPropagatedFrom()); - if ( !from || !from->IsDescendant(child) ) - { - if ( child->ProcessWindowEventLocally(event) ) - return true; - } - } - } - - return wxFrame::TryBefore(event); -} - #endif // wxUSE_MDI -#endif // _WX_MDI_H_BASE_ +#endif + // _WX_MDI_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/mediactrl.h b/Source/3rd Party/wx/include/wx/mediactrl.h deleted file mode 100644 index 4d0fd7b0f..000000000 --- a/Source/3rd Party/wx/include/wx/mediactrl.h +++ /dev/null @@ -1,403 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/mediactrl.h -// Purpose: wxMediaCtrl class -// Author: Ryan Norton -// Modified by: -// Created: 11/07/04 -// Copyright: (c) Ryan Norton -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// Definitions -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Header guard -// ---------------------------------------------------------------------------- -#ifndef _WX_MEDIACTRL_H_ -#define _WX_MEDIACTRL_H_ - -// ---------------------------------------------------------------------------- -// Pre-compiled header stuff -// ---------------------------------------------------------------------------- - -#include "wx/defs.h" - -// ---------------------------------------------------------------------------- -// Compilation guard -// ---------------------------------------------------------------------------- - -#if wxUSE_MEDIACTRL - -// ---------------------------------------------------------------------------- -// Includes -// ---------------------------------------------------------------------------- - -#include "wx/control.h" -#include "wx/uri.h" - -// ============================================================================ -// Declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// -// Enumerations -// -// ---------------------------------------------------------------------------- - -enum wxMediaState -{ - wxMEDIASTATE_STOPPED, - wxMEDIASTATE_PAUSED, - wxMEDIASTATE_PLAYING -}; - -enum wxMediaCtrlPlayerControls -{ - wxMEDIACTRLPLAYERCONTROLS_NONE = 0, - //Step controls like fastforward, step one frame etc. - wxMEDIACTRLPLAYERCONTROLS_STEP = 1 << 0, - //Volume controls like the speaker icon, volume slider, etc. - wxMEDIACTRLPLAYERCONTROLS_VOLUME = 1 << 1, - wxMEDIACTRLPLAYERCONTROLS_DEFAULT = - wxMEDIACTRLPLAYERCONTROLS_STEP | - wxMEDIACTRLPLAYERCONTROLS_VOLUME -}; - -#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend") -#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend") -#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend") -#define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend") -#define wxMEDIABACKEND_REALPLAYER wxT("wxRealPlayerMediaBackend") -#define wxMEDIABACKEND_WMP10 wxT("wxWMP10MediaBackend") - -// ---------------------------------------------------------------------------- -// -// wxMediaEvent -// -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent -{ -public: - // ------------------------------------------------------------------------ - // wxMediaEvent Constructor - // - // Normal constructor, much the same as wxNotifyEvent - // ------------------------------------------------------------------------ - wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) - : wxNotifyEvent(commandType, winid) - { } - - // ------------------------------------------------------------------------ - // wxMediaEvent Copy Constructor - // - // Normal copy constructor, much the same as wxNotifyEvent - // ------------------------------------------------------------------------ - wxMediaEvent(const wxMediaEvent &clone) - : wxNotifyEvent(clone) - { } - - // ------------------------------------------------------------------------ - // wxMediaEvent::Clone - // - // Allocates a copy of this object. - // Required for wxEvtHandler::AddPendingEvent - // ------------------------------------------------------------------------ - virtual wxEvent *Clone() const - { return new wxMediaEvent(*this); } - - - // Put this class on wxWidget's RTTI table - DECLARE_DYNAMIC_CLASS(wxMediaEvent) -}; - -// ---------------------------------------------------------------------------- -// -// wxMediaCtrl -// -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl -{ -public: - wxMediaCtrl() : m_imp(NULL), m_bLoaded(false) - { } - - wxMediaCtrl(wxWindow* parent, wxWindowID winid, - const wxString& fileName = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& szBackend = wxEmptyString, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxT("mediaCtrl")) - : m_imp(NULL), m_bLoaded(false) - { Create(parent, winid, fileName, pos, size, style, - szBackend, validator, name); } - - wxMediaCtrl(wxWindow* parent, wxWindowID winid, - const wxURI& location, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& szBackend = wxEmptyString, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxT("mediaCtrl")) - : m_imp(NULL), m_bLoaded(false) - { Create(parent, winid, location, pos, size, style, - szBackend, validator, name); } - - virtual ~wxMediaCtrl(); - - bool Create(wxWindow* parent, wxWindowID winid, - const wxString& fileName = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& szBackend = wxEmptyString, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxT("mediaCtrl")); - - bool Create(wxWindow* parent, wxWindowID winid, - const wxURI& location, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& szBackend = wxEmptyString, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxT("mediaCtrl")); - - bool DoCreate(const wxClassInfo* instance, - wxWindow* parent, wxWindowID winid, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxT("mediaCtrl")); - - bool Play(); - bool Pause(); - bool Stop(); - - bool Load(const wxString& fileName); - - wxMediaState GetState(); - - wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart); - wxFileOffset Tell(); //FIXME: This should be const - wxFileOffset Length(); //FIXME: This should be const - - double GetPlaybackRate(); //All but MCI & GStreamer - bool SetPlaybackRate(double dRate); //All but MCI & GStreamer - - bool Load(const wxURI& location); - bool Load(const wxURI& location, const wxURI& proxy); - - wxFileOffset GetDownloadProgress(); // DirectShow only - wxFileOffset GetDownloadTotal(); // DirectShow only - - double GetVolume(); - bool SetVolume(double dVolume); - - bool ShowPlayerControls( - wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT); - - //helpers for the wxPython people - bool LoadURI(const wxString& fileName) - { return Load(wxURI(fileName)); } - bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy) - { return Load(wxURI(fileName), wxURI(proxy)); } - -protected: - static const wxClassInfo* NextBackend(wxClassInfo::const_iterator* it); - - void OnMediaFinished(wxMediaEvent& evt); - virtual void DoMoveWindow(int x, int y, int w, int h); - wxSize DoGetBestSize() const; - - //FIXME: This is nasty... find a better way to work around - //inheritance issues -#if defined(__WXOSX_CARBON__) - virtual void MacVisibilityChanged(); -#endif -#if defined(__WXOSX_CARBON__) || defined(__WXCOCOA__) - friend class wxQTMediaBackend; -#endif - class wxMediaBackend* m_imp; - bool m_bLoaded; - - DECLARE_DYNAMIC_CLASS(wxMediaCtrl) -}; - -// ---------------------------------------------------------------------------- -// -// wxMediaBackend -// -// Derive from this and use standard wxWidgets RTTI -// (DECLARE_DYNAMIC_CLASS and IMPLEMENT_CLASS) to make a backend -// for wxMediaCtrl. Backends are searched alphabetically - -// the one with the earliest letter is tried first. -// -// Note that this is currently not API or ABI compatible - -// so statically link or make the client compile on-site. -// -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject -{ -public: - wxMediaBackend() - { } - - virtual ~wxMediaBackend(); - - virtual bool CreateControl(wxControl* WXUNUSED(ctrl), - wxWindow* WXUNUSED(parent), - wxWindowID WXUNUSED(winid), - const wxPoint& WXUNUSED(pos), - const wxSize& WXUNUSED(size), - long WXUNUSED(style), - const wxValidator& WXUNUSED(validator), - const wxString& WXUNUSED(name)) - { return false; } - - virtual bool Play() - { return false; } - virtual bool Pause() - { return false; } - virtual bool Stop() - { return false; } - - virtual bool Load(const wxString& WXUNUSED(fileName)) - { return false; } - virtual bool Load(const wxURI& WXUNUSED(location)) - { return false; } - - virtual bool SetPosition(wxLongLong WXUNUSED(where)) - { return 0; } - virtual wxLongLong GetPosition() - { return 0; } - virtual wxLongLong GetDuration() - { return 0; } - - virtual void Move(int WXUNUSED(x), int WXUNUSED(y), - int WXUNUSED(w), int WXUNUSED(h)) - { } - virtual wxSize GetVideoSize() const - { return wxSize(0,0); } - - virtual double GetPlaybackRate() - { return 0.0; } - virtual bool SetPlaybackRate(double WXUNUSED(dRate)) - { return false; } - - virtual wxMediaState GetState() - { return wxMEDIASTATE_STOPPED; } - - virtual double GetVolume() - { return 0.0; } - virtual bool SetVolume(double WXUNUSED(dVolume)) - { return false; } - - virtual bool Load(const wxURI& WXUNUSED(location), - const wxURI& WXUNUSED(proxy)) - { return false; } - - virtual bool ShowPlayerControls( - wxMediaCtrlPlayerControls WXUNUSED(flags)) - { return false; } - virtual bool IsInterfaceShown() - { return false; } - - virtual wxLongLong GetDownloadProgress() - { return 0; } - virtual wxLongLong GetDownloadTotal() - { return 0; } - - virtual void MacVisibilityChanged() - { } - virtual void RESERVED9() {} - - DECLARE_DYNAMIC_CLASS(wxMediaBackend) -}; - - -//Our events -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMediaEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMediaEvent ); - -//Function type(s) our events need -typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&); - -#define wxMediaEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxMediaEventFunction, func) - -//Macro for usage with message maps -#define EVT_MEDIA_FINISHED(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), -#define EVT_MEDIA_STOP(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_LOADED, wxMediaEvent ); -#define EVT_MEDIA_LOADED(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_LOADED, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STATECHANGED, wxMediaEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_PLAY, wxMediaEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_PAUSE, wxMediaEvent ); -#define EVT_MEDIA_STATECHANGED(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STATECHANGED, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), -#define EVT_MEDIA_PLAY(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_PLAY, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), -#define EVT_MEDIA_PAUSE(winid, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_PAUSE, winid, wxID_ANY, wxMediaEventHandler(fn), NULL ), - -// ---------------------------------------------------------------------------- -// common backend base class used by many other backends -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_MEDIA wxMediaBackendCommonBase : public wxMediaBackend -{ -public: - // add a pending wxMediaEvent of the given type - void QueueEvent(wxEventType evtType); - - // notify that the movie playback is finished - void QueueFinishEvent() - { - QueueEvent(wxEVT_MEDIA_STATECHANGED); - QueueEvent(wxEVT_MEDIA_FINISHED); - } - - // send the stop event and return true if it hasn't been vetoed - bool SendStopEvent(); - - // Queue pause event - void QueuePlayEvent(); - - // Queue pause event - void QueuePauseEvent(); - - // Queue stop event (no veto) - void QueueStopEvent(); - -protected: - // call this when the movie size has changed but not because it has just - // been loaded (in this case, call NotifyMovieLoaded() below) - void NotifyMovieSizeChanged(); - - // call this when the movie is fully loaded - void NotifyMovieLoaded(); - - - wxMediaCtrl *m_ctrl; // parent control -}; - -// ---------------------------------------------------------------------------- -// End compilation guard -// ---------------------------------------------------------------------------- -#endif // wxUSE_MEDIACTRL - -// ---------------------------------------------------------------------------- -// End header guard and header itself -// ---------------------------------------------------------------------------- -#endif // _WX_MEDIACTRL_H_ - - diff --git a/Source/3rd Party/wx/include/wx/memconf.h b/Source/3rd Party/wx/include/wx/memconf.h index d1fcc24d2..9508b1fef 100644 --- a/Source/3rd Party/wx/include/wx/memconf.h +++ b/Source/3rd Party/wx/include/wx/memconf.h @@ -6,6 +6,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 22.01.00 +// RCS-ID: $Id: memconf.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -45,7 +46,7 @@ public: { } - wxDECLARE_NO_COPY_CLASS(wxMemoryConfig); + DECLARE_NO_COPY_CLASS(wxMemoryConfig) }; #endif // wxUSE_CONFIG diff --git a/Source/3rd Party/wx/include/wx/memory.h b/Source/3rd Party/wx/include/wx/memory.h index aef683e4d..e4594f66e 100644 --- a/Source/3rd Party/wx/include/wx/memory.h +++ b/Source/3rd Party/wx/include/wx/memory.h @@ -4,21 +4,29 @@ // Author: Arthur Seaton, Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: memory.h 39634 2006-06-08 12:51:01Z ABX $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MEMORY_H_ -#define _WX_MEMORY_H_ +#ifndef _WX_MEMORYH__ +#define _WX_MEMORYH__ #include "wx/defs.h" #include "wx/string.h" #include "wx/msgout.h" -#if wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT +/* + The macro which will be expanded to include the file and line number + info, or to be a straight call to the new operator. +*/ + +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #include +#ifdef __WXDEBUG__ + WXDLLIMPEXP_BASE void * wxDebugAlloc(size_t size, wxChar * fileName, int lineNum, bool isObject, bool isVect = false); WXDLLIMPEXP_BASE void wxDebugFree(void * buf, bool isVect = false); @@ -42,14 +50,14 @@ WXDLLIMPEXP_BASE void wxDebugFree(void * buf, bool isVect = false); #if defined(__SUNCC__) #define wxUSE_ARRAY_MEMORY_OPERATORS 0 -#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) +#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) || defined( __MWERKS__) #define wxUSE_ARRAY_MEMORY_OPERATORS 1 #elif defined (__SGI_CC_) // only supported by -n32 compilers #ifndef __EDG_ABI_COMPATIBILITY_VERSION #define wxUSE_ARRAY_MEMORY_OPERATORS 0 #endif -#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) +#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) || defined( __MWERKS__) #define wxUSE_ARRAY_MEMORY_OPERATORS 1 #else // ::operator new[] is a recent C++ feature, so assume it's not supported @@ -59,7 +67,7 @@ WXDLLIMPEXP_BASE void wxDebugFree(void * buf, bool isVect = false); // devik 2000-8-29: All new/delete ops are now inline because they can't // be marked as dllexport/dllimport. It then leads to weird bugs when // used on MSW as DLL -#if defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE)) +#if defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE)) inline void * operator new (size_t size, wxChar * fileName, int lineNum) { return wxDebugAlloc(size, fileName, lineNum, false, false); @@ -107,10 +115,10 @@ void * operator new[] (size_t size, wxChar * fileName, int lineNum); void operator delete[] (void * buf); #endif // wxUSE_ARRAY_MEMORY_OPERATORS -#endif // defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE)) +#endif // defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE)) -// VC++ 6.0 -#if ( defined(__VISUALC__) && (__VISUALC__ >= 1200) ) +// VC++ 6.0 and MWERKS +#if ( defined(__VISUALC__) && (__VISUALC__ >= 1200) ) || defined(__MWERKS__) inline void operator delete(void* pData, wxChar* /* fileName */, int /* lineNum */) { wxDebugFree(pData, false); @@ -121,6 +129,7 @@ inline void operator delete[](void* pData, wxChar* /* fileName */, int /* lineNu } #endif // __VISUALC__>=1200 #endif // wxUSE_GLOBAL_MEMORY_OPERATORS +#endif // __WXDEBUG__ //********************************************************************************** @@ -133,7 +142,7 @@ typedef unsigned int wxMarkerType; class WXDLLIMPEXP_BASE wxMemStruct { -friend class WXDLLIMPEXP_FWD_BASE wxDebugContext; // access to the m_next pointer for list traversal. +friend class WXDLLIMPEXP_BASE wxDebugContext; // access to the m_next pointer for list traversal. public: public: @@ -198,9 +207,6 @@ public: typedef void (wxMemStruct::*PmSFV) (); -// Type of the app function that can be installed and called at wxWidgets shutdown -// (after all other registered files with global destructors have been closed down). -typedef void (*wxShutdownNotifyFunction)(); /* Debugging class. This will only have a single instance, but it's @@ -301,8 +307,6 @@ public: // This function is used to output the dump static void OutputDumpLine(const wxChar *szFormat, ...); - static void SetShutdownNotifyFunction(wxShutdownNotifyFunction shutdownFn); - private: // Store these here to allow access to the list without // needing to have a wxMemStruct object. @@ -312,25 +316,23 @@ private: // Set to false if we're not checking all previous nodes when // we do a new. Set to true when we are. static bool m_checkPrevious; - - // Holds a pointer to an optional application function to call at shutdown. - static wxShutdownNotifyFunction sm_shutdownFn; - - // Have to access our shutdown hook - friend class wxDebugContextDumpDelayCounter; }; // Final cleanup (e.g. deleting the log object and doing memory leak checking) // will be delayed until all wxDebugContextDumpDelayCounter objects have been // destructed. Adding one wxDebugContextDumpDelayCounter per file will delay // memory leak checking until after destructing all global objects. - class WXDLLIMPEXP_BASE wxDebugContextDumpDelayCounter { public: - wxDebugContextDumpDelayCounter(); - ~wxDebugContextDumpDelayCounter(); + wxDebugContextDumpDelayCounter() { + sm_count++; + } + ~wxDebugContextDumpDelayCounter() { + sm_count--; + if(!sm_count) DoDump(); + } private: void DoDump(); static int sm_count; @@ -342,13 +344,13 @@ static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_File; static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_Extra; // Output a debug message, in a system dependent fashion. -void WXDLLIMPEXP_BASE wxTrace(const wxChar *fmt ...) WX_ATTRIBUTE_PRINTF_1; -void WXDLLIMPEXP_BASE wxTraceLevel(int level, const wxChar *fmt ...) WX_ATTRIBUTE_PRINTF_2; +void WXDLLIMPEXP_BASE wxTrace(const wxChar *fmt ...) ATTRIBUTE_PRINTF_1; +void WXDLLIMPEXP_BASE wxTraceLevel(int level, const wxChar *fmt ...) ATTRIBUTE_PRINTF_2; #define WXTRACE wxTrace #define WXTRACELEVEL wxTraceLevel -#else // wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#else // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #define WXDEBUG_DUMPDELAYCOUNTER @@ -365,6 +367,7 @@ void WXDLLIMPEXP_BASE wxTraceLevel(int level, const wxChar *fmt ...) WX_ATTRIBUT #define WXTRACE true ? (void)0 : wxTrace #define WXTRACELEVEL true ? (void)0 : wxTraceLevel -#endif // wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#endif // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT -#endif // _WX_MEMORY_H_ +#endif + // _WX_MEMORYH__ diff --git a/Source/3rd Party/wx/include/wx/memtext.h b/Source/3rd Party/wx/include/wx/memtext.h index 48d71911f..16706092a 100644 --- a/Source/3rd Party/wx/include/wx/memtext.h +++ b/Source/3rd Party/wx/include/wx/memtext.h @@ -41,11 +41,11 @@ protected: { return true; } virtual bool OnWrite(wxTextFileType WXUNUSED(typeNew), - const wxMBConv& WXUNUSED(conv) = wxMBConvUTF8()) + const wxMBConv& WXUNUSED(conv) = wxConvUTF8) { return true; } private: - wxDECLARE_NO_COPY_CLASS(wxMemoryText); + DECLARE_NO_COPY_CLASS(wxMemoryText) }; #endif // wxUSE_TEXTBUFFER diff --git a/Source/3rd Party/wx/include/wx/menu.h b/Source/3rd Party/wx/include/wx/menu.h index bdf28030f..dad76c795 100644 --- a/Source/3rd Party/wx/include/wx/menu.h +++ b/Source/3rd Party/wx/include/wx/menu.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.10.99 +// RCS-ID: $Id: menu.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -26,7 +27,6 @@ // included wx/menu.h #include "wx/menuitem.h" -class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxMenu; class WXDLLIMPEXP_FWD_CORE wxMenuBarBase; class WXDLLIMPEXP_FWD_CORE wxMenuBar; @@ -40,7 +40,7 @@ WX_DECLARE_EXPORTED_LIST(wxMenuItem, wxMenuItemList); // wxMenu // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenuBase : public wxEvtHandler +class WXDLLEXPORT wxMenuBase : public wxEvtHandler { public: // create a menu @@ -68,7 +68,7 @@ public: } // append a separator to the menu - wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR); } + wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR, wxEmptyString); } // append a check item wxMenuItem* AppendCheckItem(int itemid, @@ -237,9 +237,6 @@ public: void SetLabel(int itemid, const wxString& label); wxString GetLabel(int itemid) const; - // Returns the stripped label - wxString GetLabelText(int itemid) const { return wxMenuItem::GetLabelText(GetLabel(itemid)); } - virtual void SetHelpString(int itemid, const wxString& helpString); virtual wxString GetHelpString(int itemid) const; @@ -248,27 +245,16 @@ public: // the title virtual void SetTitle(const wxString& title) { m_title = title; } - const wxString& GetTitle() const { return m_title; } + const wxString GetTitle() const { return m_title; } // event handler void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } wxEvtHandler *GetEventHandler() const { return m_eventHandler; } - // Invoking window: this is set by wxWindow::PopupMenu() before showing a - // popup menu and reset after it's hidden. Notice that you probably want to - // use GetWindow() below instead of GetInvokingWindow() as the latter only - // returns non-NULL for the top level menus - // - // NB: avoid calling SetInvokingWindow() directly if possible, use - // wxMenuInvokingWindowSetter class below instead - void SetInvokingWindow(wxWindow *win); + // invoking window + void SetInvokingWindow(wxWindow *win) { m_invokingWindow = win; } wxWindow *GetInvokingWindow() const { return m_invokingWindow; } - // the window associated with this menu: this is the invoking window for - // popup menus or the top level window to which the menu bar is attached - // for menus which are part of a menu bar - wxWindow *GetWindow() const; - // style long GetStyle() const { return m_style; } @@ -278,7 +264,7 @@ public: // Updates the UI for a menu and all submenus recursively. source is the // object that has the update event handlers defined for it. If NULL, the // menu or associated window will be used. - void UpdateUI(wxEvtHandler* source = NULL); + void UpdateUI(wxEvtHandler* source = (wxEvtHandler*)NULL); // get the menu bar this menu is attached to (may be NULL, always NULL for // popup menus). Traverse up the menu hierarchy to find it. @@ -388,47 +374,22 @@ protected: static bool ms_locked; - wxDECLARE_NO_COPY_CLASS(wxMenuBase); -}; + DECLARE_NO_COPY_CLASS(wxMenuBase) -#if wxUSE_EXTENDED_RTTI - -// ---------------------------------------------------------------------------- -// XTI accessor -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxMenuInfoHelper : public wxObject -{ public: - wxMenuInfoHelper() { m_menu = NULL; } - virtual ~wxMenuInfoHelper() { } - - bool Create( wxMenu *menu, const wxString &title ) - { - m_menu = menu; - m_title = title; - return true; - } - - wxMenu* GetMenu() const { return m_menu; } - wxString GetTitle() const { return m_title; } - -private: - wxMenu *m_menu; - wxString m_title; - - DECLARE_DYNAMIC_CLASS(wxMenuInfoHelper) -}; - -WX_DECLARE_EXPORTED_LIST(wxMenuInfoHelper, wxMenuInfoHelperList ); +#if wxABI_VERSION >= 20805 + // Returns the stripped label + wxString GetLabelText(int itemid) const { return wxMenuItem::GetLabelFromText(GetLabel(itemid)); } #endif +}; + // ---------------------------------------------------------------------------- // wxMenuBar // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenuBarBase : public wxWindow +class WXDLLEXPORT wxMenuBarBase : public wxWindow { public: // default ctor @@ -471,11 +432,8 @@ public: virtual bool IsEnabledTop(size_t WXUNUSED(pos)) const { return true; } // get or change the label of the menu at given position - virtual void SetMenuLabel(size_t pos, const wxString& label) = 0; - virtual wxString GetMenuLabel(size_t pos) const = 0; - - // get the stripped label of the menu at given position - virtual wxString GetMenuLabelText(size_t pos) const { return wxMenuItem::GetLabelText(GetMenuLabel(pos)); } + virtual void SetLabelTop(size_t pos, const wxString& label) = 0; + virtual wxString GetLabelTop(size_t pos) const = 0; // item search // ----------- @@ -538,36 +496,29 @@ public: // update all menu item states in all menus virtual void UpdateMenus(); - virtual bool CanBeOutsideClientArea() const { return true; } - -#if wxUSE_EXTENDED_RTTI - // XTI helpers: - bool AppendMenuInfo( const wxMenuInfoHelper *info ) - { return Append( info->GetMenu(), info->GetTitle() ); } - const wxMenuInfoHelperList& GetMenuInfos() const; -#endif - -#if WXWIN_COMPATIBILITY_2_8 - // get or change the label of the menu at given position - // Deprecated in favour of SetMenuLabel - wxDEPRECATED( void SetLabelTop(size_t pos, const wxString& label) ); - // Deprecated in favour of GetMenuLabelText - wxDEPRECATED( wxString GetLabelTop(size_t pos) const ); -#endif - protected: // the list of all our menus wxMenuList m_menus; -#if wxUSE_EXTENDED_RTTI - // used by XTI - wxMenuInfoHelperList m_menuInfos; -#endif - // the frame we are attached to (may be NULL) wxFrame *m_menuBarFrame; - wxDECLARE_NO_COPY_CLASS(wxMenuBarBase); + DECLARE_NO_COPY_CLASS(wxMenuBarBase) + +public: + +#if wxABI_VERSION >= 20805 + // Replacement for SetLabelTop + void SetMenuLabel(size_t pos, const wxString& label) { SetLabelTop(pos, label); } + + // Gets the original label at the top-level of the menubar + // Implemented per port, since we can't have virtual functions in the stable branch. + // wxString GetMenuLabel(size_t pos) const; + + // Get the text only, from the label at the top-level of the menubar + wxString GetMenuLabelText(size_t pos) const; +#endif + }; // ---------------------------------------------------------------------------- @@ -579,6 +530,8 @@ protected: #else // !wxUSE_BASE_CLASSES_ONLY #if defined(__WXUNIVERSAL__) #include "wx/univ/menu.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/menu.h" #elif defined(__WXMSW__) #include "wx/msw/menu.h" #elif defined(__WXMOTIF__) @@ -588,7 +541,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/menu.h" #elif defined(__WXMAC__) - #include "wx/osx/menu.h" + #include "wx/mac/menu.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/menu.h" #elif defined(__WXPM__) @@ -596,35 +549,7 @@ protected: #endif #endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY -// ---------------------------------------------------------------------------- -// Helper class used in the implementation only: sets the invoking window of -// the given menu in its ctor and resets it in dtor. -// ---------------------------------------------------------------------------- - -class wxMenuInvokingWindowSetter -{ -public: - // Ctor sets the invoking window for the given menu. - // - // The menu lifetime must be greater than that of this class. - wxMenuInvokingWindowSetter(wxMenu& menu, wxWindow *win) - : m_menu(menu) - { - menu.SetInvokingWindow(win); - } - - // Dtor resets the invoking window. - ~wxMenuInvokingWindowSetter() - { - m_menu.SetInvokingWindow(NULL); - } - -private: - wxMenu& m_menu; - - wxDECLARE_NO_COPY_CLASS(wxMenuInvokingWindowSetter); -}; - #endif // wxUSE_MENUS -#endif // _WX_MENU_H_BASE_ +#endif + // _WX_MENU_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/menuitem.h b/Source/3rd Party/wx/include/wx/menuitem.h index 96f99831c..2a55e582b 100644 --- a/Source/3rd Party/wx/include/wx/menuitem.h +++ b/Source/3rd Party/wx/include/wx/menuitem.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 25.10.99 +// RCS-ID: $Id: menuitem.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1999 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,16 +35,16 @@ class WXDLLIMPEXP_FWD_CORE wxMenu; // menu or a separator // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenuItemBase : public wxObject +class WXDLLEXPORT wxMenuItemBase : public wxObject { public: // creation - static wxMenuItem *New(wxMenu *parentMenu = NULL, + static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL, int itemid = wxID_SEPARATOR, const wxString& text = wxEmptyString, const wxString& help = wxEmptyString, wxItemKind kind = wxITEM_NORMAL, - wxMenu *subMenu = NULL); + wxMenu *subMenu = (wxMenu *)NULL); // destruction: wxMenuItem will delete its submenu virtual ~wxMenuItemBase(); @@ -55,39 +56,27 @@ public: // get/set id void SetId(int itemid) { m_id = itemid; } int GetId() const { return m_id; } + bool IsSeparator() const { return m_id == wxID_SEPARATOR; } // the item's text (or name) // - // NB: the item's label includes the accelerators and mnemonics info (if + // NB: the item's text includes the accelerators and mnemonics info (if // any), i.e. it may contain '&' or '_' or "\t..." and thus is - // different from the item's text which only contains the text shown - // in the menu. This used to be called SetText. - virtual void SetItemLabel(const wxString& str); + // different from the item's label which only contains the text shown + // in the menu + virtual void SetText(const wxString& str); - // return the item label including any mnemonics and accelerators. - // This used to be called GetText. - virtual wxString GetItemLabel() const { return m_text; } + wxString GetLabel() const { return GetLabelFromText(m_text); } + const wxString& GetText() const { return m_text; } - // return just the text of the item label, without any mnemonics - // This used to be called GetLabel. - virtual wxString GetItemLabelText() const { return GetLabelText(m_text); } - - // return just the text part of the given label (implemented in platform-specific code) - // This used to be called GetLabelFromText. - static wxString GetLabelText(const wxString& label); + // get the label from text (implemented in platform-specific code) + static wxString GetLabelFromText(const wxString& text); // what kind of menu item we are wxItemKind GetKind() const { return m_kind; } void SetKind(wxItemKind kind) { m_kind = kind; } - bool IsSeparator() const { return m_kind == wxITEM_SEPARATOR; } - bool IsCheck() const { return m_kind == wxITEM_CHECK; } - bool IsRadio() const { return m_kind == wxITEM_RADIO; } - - virtual void SetCheckable(bool checkable) - { m_kind = checkable ? wxITEM_CHECK : wxITEM_NORMAL; } - - // Notice that this doesn't quite match SetCheckable(). + virtual void SetCheckable(bool checkable) { m_kind = checkable ? wxITEM_CHECK : wxITEM_NORMAL; } bool IsCheckable() const { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; } @@ -120,37 +109,23 @@ public: virtual void SetAccel(wxAcceleratorEntry *accel); #endif // wxUSE_ACCEL -#if WXWIN_COMPATIBILITY_2_8 // compatibility only, use new functions in the new code - wxDEPRECATED( void SetName(const wxString& str) ); - wxDEPRECATED( wxString GetName() const ); - - // Now use GetItemLabelText - wxDEPRECATED( wxString GetLabel() const ) ; - - // Now use GetItemLabel - wxDEPRECATED( const wxString& GetText() const ); - - // Now use GetLabelText to strip the accelerators - static wxDEPRECATED( wxString GetLabelFromText(const wxString& text) ); - - // Now use SetItemLabel - wxDEPRECATED( virtual void SetText(const wxString& str) ); -#endif // WXWIN_COMPATIBILITY_2_8 + void SetName(const wxString& str) { SetText(str); } + const wxString& GetName() const { return GetText(); } static wxMenuItem *New(wxMenu *parentMenu, int itemid, const wxString& text, const wxString& help, bool isCheckable, - wxMenu *subMenu = NULL) + wxMenu *subMenu = (wxMenu *)NULL) { return New(parentMenu, itemid, text, help, isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu); } protected: - wxWindowIDRef m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR + int m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR wxMenu *m_parentMenu, // the menu we belong to *m_subMenu; // our sub menu or NULL wxString m_text, // label of the item @@ -160,30 +135,39 @@ protected: bool m_isEnabled; // is enabled? // this ctor is for the derived classes only, we're never created directly - wxMenuItemBase(wxMenu *parentMenu = NULL, + wxMenuItemBase(wxMenu *parentMenu = (wxMenu *)NULL, int itemid = wxID_SEPARATOR, const wxString& text = wxEmptyString, const wxString& help = wxEmptyString, wxItemKind kind = wxITEM_NORMAL, - wxMenu *subMenu = NULL); + wxMenu *subMenu = (wxMenu *)NULL); private: // and, if we have one ctor, compiler won't generate a default copy one, so // declare them ourselves - but don't implement as they shouldn't be used wxMenuItemBase(const wxMenuItemBase& item); wxMenuItemBase& operator=(const wxMenuItemBase& item); -}; -#if WXWIN_COMPATIBILITY_2_8 -inline void wxMenuItemBase::SetName(const wxString &str) - { SetItemLabel(str); } -inline wxString wxMenuItemBase::GetName() const - { return GetItemLabel(); } -inline wxString wxMenuItemBase::GetLabel() const - { return GetLabelText(m_text); } -inline const wxString& wxMenuItemBase::GetText() const { return m_text; } -inline void wxMenuItemBase::SetText(const wxString& text) { SetItemLabel(text); } -#endif // WXWIN_COMPATIBILITY_2_8 +public: + +#if wxABI_VERSION >= 20805 + // Sets the label. This function replaces SetText. + void SetItemLabel(const wxString& str) { SetText(str); } + + // return the item label including any mnemonics and accelerators. + // This used to be called GetText. + // We can't implement this in the base class (no new virtuals in stable branch) + // wxString GetItemLabel() const; + + // return just the text of the item label, without any mnemonics + // This used to be called GetLabel. + wxString GetItemLabelText() const { return GetLabelText(m_text); } + + // return just the text part of the given label. In 2.9 and up, this is implemented in + // platform-specific code, but is now implemented in terms of GetLabelFromText. + static wxString GetLabelText(const wxString& label); +#endif +}; // ---------------------------------------------------------------------------- // include the real class declaration @@ -194,6 +178,8 @@ inline void wxMenuItemBase::SetText(const wxString& text) { SetItemLabel(text); #else // !wxUSE_BASE_CLASSES_ONLY #if defined(__WXUNIVERSAL__) #include "wx/univ/menuitem.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/menuitem.h" #elif defined(__WXMSW__) #include "wx/msw/menuitem.h" #elif defined(__WXMOTIF__) @@ -203,7 +189,7 @@ inline void wxMenuItemBase::SetText(const wxString& text) { SetItemLabel(text); #elif defined(__WXGTK__) #include "wx/gtk1/menuitem.h" #elif defined(__WXMAC__) - #include "wx/osx/menuitem.h" + #include "wx/mac/menuitem.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/menuitem.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/meta/convertible.h b/Source/3rd Party/wx/include/wx/meta/convertible.h deleted file mode 100644 index 459993782..000000000 --- a/Source/3rd Party/wx/include/wx/meta/convertible.h +++ /dev/null @@ -1,38 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/convertible.h -// Purpose: Test if types are convertible -// Author: Arne Steinarson -// Created: 2008-01-10 -// Copyright: (c) 2008 Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_CONVERTIBLE_H_ -#define _WX_META_CONVERTIBLE_H_ - -// -// Introduce an extra class to make this header compilable with g++3.2 -// -template -struct wxConvertibleTo_SizeHelper -{ - static char Match(B* pb); - static int Match(...); -}; - -// Helper to decide if an object of type D is convertible to type B (the test -// succeeds in particular when D derives from B) -template -struct wxConvertibleTo -{ - enum - { - value = - sizeof(wxConvertibleTo_SizeHelper::Match(static_cast(NULL))) - == - sizeof(char) - }; -}; - -#endif // _WX_META_CONVERTIBLE_H_ - diff --git a/Source/3rd Party/wx/include/wx/meta/if.h b/Source/3rd Party/wx/include/wx/meta/if.h deleted file mode 100644 index f6f3672fc..000000000 --- a/Source/3rd Party/wx/include/wx/meta/if.h +++ /dev/null @@ -1,72 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/if.h -// Purpose: declares wxIf<> metaprogramming construct -// Author: Vaclav Slavik -// Created: 2008-01-22 -// Copyright: (c) 2008 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_IF_H_ -#define _WX_META_IF_H_ - -#include "wx/defs.h" - -// NB: This code is intentionally written without partial templates -// specialization, because some older compilers (notably VC6) don't -// support it. - -namespace wxPrivate -{ - -template -struct wxIfImpl - -// broken VC6 needs not just an incomplete template class declaration but a -// "skeleton" declaration of the specialized versions below as it apparently -// tries to look up the types in the generic template definition at some moment -// even though it ends up by using the correct specialization in the end -- but -// without this skeleton it doesn't recognize Result as a class at all below -#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7) -{ - template struct Result {}; -} -#endif // VC++ <= 6 -; - -// specialization for true: -template <> -struct wxIfImpl -{ - template struct Result - { - typedef TTrue value; - }; -}; - -// specialization for false: -template<> -struct wxIfImpl -{ - template struct Result - { - typedef TFalse value; - }; -}; - -} // namespace wxPrivate - -// wxIf<> template defines nested type "value" which is the same as -// TTrue if the condition Cond (boolean compile-time constant) was met and -// TFalse if it wasn't. -// -// See wxVector in vector.h for usage example -template -struct wxIf -{ - typedef typename wxPrivate::wxIfImpl - ::template Result::value - value; -}; - -#endif // _WX_META_IF_H_ diff --git a/Source/3rd Party/wx/include/wx/meta/implicitconversion.h b/Source/3rd Party/wx/include/wx/meta/implicitconversion.h deleted file mode 100644 index d596a6b24..000000000 --- a/Source/3rd Party/wx/include/wx/meta/implicitconversion.h +++ /dev/null @@ -1,112 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/implicitconversion.h -// Purpose: Determine resulting type from implicit conversion -// Author: Vaclav Slavik -// Created: 2010-10-22 -// Copyright: (c) 2010 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_IMPLICITCONVERSION_H_ -#define _WX_META_IMPLICITCONVERSION_H_ - -#include "wx/defs.h" -#include "wx/meta/if.h" - -// C++ hierarchy of data types is: -// -// Long double (highest) -// Double -// Float -// Unsigned long int -// Long int -// Unsigned int -// Int (lowest) -// -// Types lower in the hierarchy are converted into ones higher up if both are -// involved e.g. in arithmetic expressions. - -namespace wxPrivate -{ - -// Helper macro to define a constant inside a template class: it's needed -// because MSVC6 doesn't support initializing static integer members but the -// usual workaround of using enums instead doesn't work for Borland (at least -// in template classes). -#ifdef __VISUALC6__ - #define wxDEFINE_CLASS_INT_CONST(name, value) enum { name = value } -#else - #define wxDEFINE_CLASS_INT_CONST(name, value) static const int name = value -#endif - -template -struct TypeHierarchy -{ - // consider unknown types (e.g. objects, pointers) to be of highest - // level, always convert to them if they occur - wxDEFINE_CLASS_INT_CONST( level, 9999 ); -}; - -#define WX_TYPE_HIERARCHY_LEVEL(level_num, type) \ - template<> struct TypeHierarchy \ - { \ - wxDEFINE_CLASS_INT_CONST( level, level_num ); \ - } - -WX_TYPE_HIERARCHY_LEVEL( 1, char); -WX_TYPE_HIERARCHY_LEVEL( 2, unsigned char); -WX_TYPE_HIERARCHY_LEVEL( 3, short); -WX_TYPE_HIERARCHY_LEVEL( 4, unsigned short); -WX_TYPE_HIERARCHY_LEVEL( 5, int); -WX_TYPE_HIERARCHY_LEVEL( 6, unsigned int); -WX_TYPE_HIERARCHY_LEVEL( 7, long); -WX_TYPE_HIERARCHY_LEVEL( 8, unsigned long); -#ifdef wxLongLong_t -WX_TYPE_HIERARCHY_LEVEL( 9, wxLongLong_t); -WX_TYPE_HIERARCHY_LEVEL(10, wxULongLong_t); -#endif -WX_TYPE_HIERARCHY_LEVEL(11, float); -WX_TYPE_HIERARCHY_LEVEL(12, double); -WX_TYPE_HIERARCHY_LEVEL(13, long double); - -#if wxWCHAR_T_IS_REAL_TYPE - #if SIZEOF_WCHAR_T == SIZEOF_SHORT - template<> struct TypeHierarchy : public TypeHierarchy {}; - #elif SIZEOF_WCHAR_T == SIZEOF_INT - template<> struct TypeHierarchy : public TypeHierarchy {}; - #elif SIZEOF_WCHAR_T == SIZEOF_LONG - template<> struct TypeHierarchy : public TypeHierarchy {}; - #else - #error "weird wchar_t size, please update this code" - #endif -#endif - -#undef WX_TYPE_HIERARCHY_LEVEL - -} // namespace wxPrivate - -// Helper to determine resulting type of implicit conversion in -// an expression with two arithmetic types. -template -struct wxImplicitConversionType -{ - typedef typename wxIf - < - // if T2 is "higher" type, convert to it - (int)(wxPrivate::TypeHierarchy::level) < (int)(wxPrivate::TypeHierarchy::level), - T2, - // otherwise use T1 - T1 - >::value - value; -}; - - -template -struct wxImplicitConversionType3 : public wxImplicitConversionType< - T1, - typename wxImplicitConversionType::value> -{ -}; - -#endif // _WX_META_IMPLICITCONVERSION_H_ diff --git a/Source/3rd Party/wx/include/wx/meta/int2type.h b/Source/3rd Party/wx/include/wx/meta/int2type.h deleted file mode 100644 index 7b8d5dc02..000000000 --- a/Source/3rd Party/wx/include/wx/meta/int2type.h +++ /dev/null @@ -1,16 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/int2type.h -// Purpose: Generate a unique type from a constant integer -// Author: Arne Steinarson -// Created: 2008-01-10 -// Copyright: (c) 2008 Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_INT2TYPE_H_ -#define _WX_META_INT2TYPE_H_ - -template -struct wxInt2Type { enum { value=N }; }; - -#endif // _WX_META_INT2TYPE_H_ diff --git a/Source/3rd Party/wx/include/wx/meta/movable.h b/Source/3rd Party/wx/include/wx/meta/movable.h deleted file mode 100644 index e3a9f9e96..000000000 --- a/Source/3rd Party/wx/include/wx/meta/movable.h +++ /dev/null @@ -1,44 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/movable.h -// Purpose: Test if a type is movable using memmove() etc. -// Author: Vaclav Slavik -// Created: 2008-01-21 -// Copyright: (c) 2008 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_MOVABLE_H_ -#define _WX_META_MOVABLE_H_ - -#include "wx/meta/pod.h" -#include "wx/string.h" // for wxIsMovable specialization - -// Helper to decide if an object of type T is "movable", i.e. if it can be -// copied to another memory location using memmove() or realloc() C functions. -// C++ only gurantees that POD types (including primitive types) are -// movable. -template -struct wxIsMovable -{ - wxDEFINE_TEMPLATE_BOOL_VALUE(wxIsPod::value); -}; - -// Macro to add wxIsMovable specialization for given type that marks it -// as movable: -#define WX_DECLARE_TYPE_MOVABLE(type) \ - template<> struct wxIsMovable \ - { \ - wxDEFINE_TEMPLATE_BOOL_VALUE(true); \ - }; - -// Our implementation of wxString is written in such way that it's safe to move -// it around (unless position cache is used which unfortunately breaks this). -// OTOH, we don't know anything about std::string. -// (NB: we don't put this into string.h and choose to include wx/string.h from -// here instead so that rarely-used wxIsMovable code isn't included by -// everything) -#if !wxUSE_STD_STRING && !wxUSE_STRING_POS_CACHE -WX_DECLARE_TYPE_MOVABLE(wxString) -#endif - -#endif // _WX_META_MOVABLE_H_ diff --git a/Source/3rd Party/wx/include/wx/meta/pod.h b/Source/3rd Party/wx/include/wx/meta/pod.h deleted file mode 100644 index b9dde13d6..000000000 --- a/Source/3rd Party/wx/include/wx/meta/pod.h +++ /dev/null @@ -1,87 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/pod.h -// Purpose: Test if a type is POD -// Author: Vaclav Slavik, Jaakko Salli -// Created: 2010-06-14 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_POD_H_ -#define _WX_META_POD_H_ - -#include "wx/defs.h" - -// -// TODO: Use TR1 is_pod<> implementation where available. VC9 SP1 has it -// in tr1 namespace, VC10 has it in std namespace. GCC 4.2 has it in -// , while GCC 4.3 and later have it in . -// - -// This macro declares something called "value" inside a class declaration. -// -// It has to be used because VC6 doesn't handle initialization of the static -// variables in the class declaration itself while BCC5.82 doesn't understand -// enums (it compiles the template fine but can't use it later) -#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7) - #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) enum { value = val } -#else - #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val -#endif - -// Helper to decide if an object of type T is POD (Plain Old Data) -template -struct wxIsPod -{ - wxDEFINE_TEMPLATE_BOOL_VALUE(false); -}; - -// Macro to add wxIsPod specialization for given type that marks it -// as Plain Old Data: -#define WX_DECLARE_TYPE_POD(type) \ - template<> struct wxIsPod \ - { \ - wxDEFINE_TEMPLATE_BOOL_VALUE(true); \ - }; - -WX_DECLARE_TYPE_POD(bool) -WX_DECLARE_TYPE_POD(unsigned char) -WX_DECLARE_TYPE_POD(signed char) -WX_DECLARE_TYPE_POD(unsigned int) -WX_DECLARE_TYPE_POD(signed int) -WX_DECLARE_TYPE_POD(unsigned short int) -WX_DECLARE_TYPE_POD(signed short int) -WX_DECLARE_TYPE_POD(signed long int) -WX_DECLARE_TYPE_POD(unsigned long int) -WX_DECLARE_TYPE_POD(float) -WX_DECLARE_TYPE_POD(double) -WX_DECLARE_TYPE_POD(long double) -#if wxWCHAR_T_IS_REAL_TYPE -WX_DECLARE_TYPE_POD(wchar_t) -#endif -#ifdef wxLongLong_t -WX_DECLARE_TYPE_POD(wxLongLong_t) -WX_DECLARE_TYPE_POD(wxULongLong_t) -#endif - -// Visual C++ 6.0 can't compile partial template specializations and as this is -// only an optimization, we can live with pointers not being recognized as -// POD types under VC6 -#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7) - -// pointers are Plain Old Data: -template -struct wxIsPod -{ - static const bool value = true; -}; - -template -struct wxIsPod -{ - static const bool value = true; -}; - -#endif // !VC++ < 7 - -#endif // _WX_META_POD_H_ diff --git a/Source/3rd Party/wx/include/wx/meta/removeref.h b/Source/3rd Party/wx/include/wx/meta/removeref.h deleted file mode 100644 index e199d033f..000000000 --- a/Source/3rd Party/wx/include/wx/meta/removeref.h +++ /dev/null @@ -1,36 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/meta/removeref.h -// Purpose: Allows to remove a reference from a type. -// Author: Vadim Zeitlin -// Created: 2012-10-21 -// Copyright: (c) 2012 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_META_REMOVEREF_H_ -#define _WX_META_REMOVEREF_H_ - -// wxRemoveRef<> is similar to C++11 std::remove_reference<> but works with all -// compilers (but, to compensate for this, doesn't work with rvalue references). - -// Except that it doesn't work with VC++ 6 as there doesn't seem to be any way -// to partially specialize a template for references with it. -#ifndef __VISUALC6__ - -template -struct wxRemoveRef -{ - typedef T type; -}; - -template -struct wxRemoveRef -{ - typedef T type; -}; - -#define wxHAS_REMOVEREF - -#endif // !__VISUALC6__ - -#endif // _WX_META_REMOVEREF_H_ diff --git a/Source/3rd Party/wx/include/wx/metafile.h b/Source/3rd Party/wx/include/wx/metafile.h index e368a2261..7d92ab0f3 100644 --- a/Source/3rd Party/wx/include/wx/metafile.h +++ b/Source/3rd Party/wx/include/wx/metafile.h @@ -4,6 +4,7 @@ // Author: wxWidgets team // Modified by: // Created: 13.01.00 +// RCS-ID: $Id: metafile.h 39841 2006-06-26 14:37:34Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -24,7 +25,11 @@ #if defined(__WXMSW__) #if wxUSE_ENH_METAFILE - #include "wx/msw/enhmeta.h" + #if defined(__WXPALMOS__) + #include "wx/palmos/enhmeta.h" + #else + #include "wx/msw/enhmeta.h" + #endif #if wxUSE_WIN_METAFILES_ALWAYS // use normal metafiles as well @@ -40,12 +45,16 @@ #define wxMETAFILE_IS_ENH #endif // wxUSE_WIN_METAFILES_ALWAYS #else // !wxUSE_ENH_METAFILE - #include "wx/msw/metafile.h" + #if defined(__WXPALMOS__) + #include "wx/palmos/metafile.h" + #else + #include "wx/msw/metafile.h" + #endif #endif #elif defined(__WXPM__) #include "wx/os2/metafile.h" #elif defined(__WXMAC__) - #include "wx/osx/metafile.h" + #include "wx/mac/metafile.h" #endif #endif // wxUSE_METAFILE diff --git a/Source/3rd Party/wx/include/wx/mimetype.h b/Source/3rd Party/wx/include/wx/mimetype.h index 2df28e50f..8baf854c1 100644 --- a/Source/3rd Party/wx/include/wx/mimetype.h +++ b/Source/3rd Party/wx/include/wx/mimetype.h @@ -5,6 +5,7 @@ // Modified by: // Chris Elliott (biol75@york.ac.uk) 5 Dec 00: write support for Win32 // Created: 23.09.98 +// RCS-ID: $Id: mimetype.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// @@ -25,8 +26,6 @@ #include "wx/dynarray.h" #include "wx/arrstr.h" -#include - // fwd decls class WXDLLIMPEXP_FWD_BASE wxIconLocation; class WXDLLIMPEXP_FWD_BASE wxFileTypeImpl; @@ -117,107 +116,16 @@ private: class WXDLLIMPEXP_BASE wxFileTypeInfo { -private: - void DoVarArgInit(const wxString& mimeType, - const wxString& openCmd, - const wxString& printCmd, - const wxString& desc, - va_list argptr); - - void VarArgInit(const wxString *mimeType, - const wxString *openCmd, - const wxString *printCmd, - const wxString *desc, - // the other parameters form a NULL terminated list of - // extensions - ...); - public: - // NB: This is a helper to get implicit conversion of variadic ctor's - // fixed arguments into something that can be passed to VarArgInit(). - // Do not use, it's used by the ctor only. - struct CtorString - { - CtorString(const char *str) : m_str(str) {} - CtorString(const wchar_t *str) : m_str(str) {} - CtorString(const wxString& str) : m_str(str) {} - CtorString(const wxCStrData& str) : m_str(str) {} - CtorString(const wxScopedCharBuffer& str) : m_str(str) {} - CtorString(const wxScopedWCharBuffer& str) : m_str(str) {} - - operator const wxString*() const { return &m_str; } - - wxString m_str; - }; - // ctors - - // Ctor specifying just the MIME type (which is mandatory), the other - // fields can be set later if needed. - wxFileTypeInfo(const wxString& mimeType) - : m_mimeType(mimeType) - { - } - - // Ctor allowing to specify the values of all fields at once: - // - // wxFileTypeInfo(const wxString& mimeType, - // const wxString& openCmd, - // const wxString& printCmd, - // const wxString& desc, - // // the other parameters form a list of extensions for this - // // file type and should be terminated with wxNullPtr (not - // // just NULL!) - // ...); - WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, - 4, (const CtorString&, - const CtorString&, - const CtorString&, - const CtorString&), - VarArgInit, VarArgInit) -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND_CTOR( - wxFileTypeInfo, - 4, (const wxString&, - const wxString&, - const wxString&, - const wxString&), - (CtorString(f1), - CtorString(f2), - CtorString(f3), - CtorString(f4))); - WX_VARARG_WATCOM_WORKAROUND_CTOR( - wxFileTypeInfo, - 4, (const wxCStrData&, - const wxCStrData&, - const wxCStrData&, - const wxCStrData&), - (CtorString(f1), - CtorString(f2), - CtorString(f3), - CtorString(f4))); - WX_VARARG_WATCOM_WORKAROUND_CTOR( - wxFileTypeInfo, - 4, (const char*, - const char*, - const char*, - const char*), - (CtorString(f1), - CtorString(f2), - CtorString(f3), - CtorString(f4))); - WX_VARARG_WATCOM_WORKAROUND_CTOR( - wxFileTypeInfo, - 4, (const wchar_t*, - const wchar_t*, - const wchar_t*, - const wchar_t*), - (CtorString(f1), - CtorString(f2), - CtorString(f3), - CtorString(f4))); -#endif + // a normal item + wxFileTypeInfo(const wxChar *mimeType, + const wxChar *openCmd, + const wxChar *printCmd, + const wxChar *desc, + // the other parameters form a NULL terminated list of + // extensions + ...); // the array elements correspond to the parameters of the ctor above in // the same order @@ -231,16 +139,6 @@ public: bool IsValid() const { return !m_mimeType.empty(); } // setters - // set the open/print commands - void SetOpenCommand(const wxString& command) { m_openCmd = command; } - void SetPrintCommand(const wxString& command) { m_printCmd = command; } - - // set the description - void SetDescription(const wxString& desc) { m_desc = desc; } - - // add another extension corresponding to this file type - void AddExtension(const wxString& ext) { m_exts.push_back(ext); } - // set the icon info void SetIcon(const wxString& iconFile, int iconIndex = 0) { @@ -388,7 +286,7 @@ public: // operations // expand a string in the format of GetOpenCommand (which may contain - // '%s' and '%t' format specifiers for the file name and mime type + // '%s' and '%t' format specificators for the file name and mime type // and %{param} constructions). static wxString ExpandCommand(const wxString& command, const MessageParameters& params); @@ -427,7 +325,7 @@ public: static void Set( wxMimeTypesManagerFactory *factory ); static wxMimeTypesManagerFactory *Get(); - + private: static wxMimeTypesManagerFactory *m_factory; }; @@ -478,13 +376,32 @@ public: // get file type from MIME type (in format /) wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); + // other operations: return true if there were no errors or false if there + // were some unrecognized entries (the good entries are always read anyhow) + // + // FIXME: These ought to be private ?? + + // read in additional file (the standard ones are read automatically) + // in mailcap format (see mimetype.cpp for description) + // + // 'fallback' parameter may be set to true to avoid overriding the + // settings from other, previously parsed, files by this one: normally, + // the files read most recently would override the older files, but with + // fallback == true this won't happen + + bool ReadMailcap(const wxString& filename, bool fallback = false); + // read in additional file in mime.types format + bool ReadMimeTypes(const wxString& filename); + // enumerate all known MIME types // // returns the number of retrieved file types size_t EnumAllFileTypes(wxArrayString& mimetypes); // these functions can be used to provide default values for some of the - // MIME types inside the program itself + // MIME types inside the program itself (you may also use + // ReadMailcap(filenameWithDefaultTypes, true /* use as fallback */) to + // achieve the same goal, but this requires having this info in a file). // // The filetypes array should be terminated by either NULL entry or an // invalid wxFileTypeInfo (i.e. the one created with default ctor) diff --git a/Source/3rd Party/wx/include/wx/minifram.h b/Source/3rd Party/wx/include/wx/minifram.h index 096e2785d..50df6006a 100644 --- a/Source/3rd Party/wx/include/wx/minifram.h +++ b/Source/3rd Party/wx/include/wx/minifram.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: minifram.h 49299 2007-10-21 18:07:29Z PC $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,9 @@ #if wxUSE_MINIFRAME -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) +#include "wx/palmos/minifram.h" +#elif defined(__WXMSW__) #include "wx/msw/minifram.h" #elif defined(__WXMOTIF__) #include "wx/motif/minifram.h" @@ -26,7 +29,7 @@ #elif defined(__WXX11__) #include "wx/x11/minifram.h" #elif defined(__WXMAC__) -#include "wx/osx/minifram.h" +#include "wx/mac/minifram.h" #elif defined(__WXPM__) #include "wx/os2/minifram.h" #else diff --git a/Source/3rd Party/wx/include/wx/modalhook.h b/Source/3rd Party/wx/include/wx/modalhook.h deleted file mode 100644 index 55341f9bd..000000000 --- a/Source/3rd Party/wx/include/wx/modalhook.h +++ /dev/null @@ -1,104 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/modalhook.h -// Purpose: Allows to hook into showing modal dialogs. -// Author: Vadim Zeitlin -// Created: 2013-05-19 -// Copyright: (c) 2013 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MODALHOOK_H_ -#define _WX_MODALHOOK_H_ - -#include "wx/vector.h" - -class WXDLLIMPEXP_FWD_CORE wxDialog; - -// ---------------------------------------------------------------------------- -// Class allowing to be notified about any modal dialog calls. -// ---------------------------------------------------------------------------- - -// To be notified about entering and exiting modal dialogs and possibly to -// replace them with something else (e.g. just return a predefined value for -// testing), define an object of this class, override its Enter() and -// possibly Exit() methods and call Register() on it. -class WXDLLIMPEXP_CORE wxModalDialogHook -{ -public: - // Default ctor doesn't do anything, call Register() to activate the hook. - wxModalDialogHook() { } - - // Dtor unregisters the hook if it had been registered. - virtual ~wxModalDialogHook() { DoUnregister(); } - - // Register this hook as being active, i.e. its Enter() and Exit() methods - // will be called. - // - // Notice that the order of registration matters: the last hook registered - // is called first, and if its Enter() returns something != wxID_NONE, the - // subsequent hooks are skipped. - void Register(); - - // Unregister this hook. Notice that is done automatically from the dtor. - void Unregister(); - - // Called from wxWidgets code before showing any modal dialogs and calls - // Enter() for every registered hook. - static int CallEnter(wxDialog* dialog); - - // Called from wxWidgets code after dismissing the dialog and calls Exit() - // for every registered hook. - static void CallExit(wxDialog* dialog); - -protected: - // Called by wxWidgets before showing any modal dialogs, override this to - // be notified about this and return anything but wxID_NONE to skip showing - // the modal dialog entirely and just return the specified result. - virtual int Enter(wxDialog* dialog) = 0; - - // Called by wxWidgets after dismissing the modal dialog. Notice that it - // won't be called if Enter() hadn't been. - virtual void Exit(wxDialog* WXUNUSED(dialog)) { } - -private: - // Unregister the given hook, return true if it was done or false if the - // hook wasn't found. - bool DoUnregister(); - - // All the hooks in reverse registration order (i.e. in call order). - typedef wxVector Hooks; - static Hooks ms_hooks; - - wxDECLARE_NO_COPY_CLASS(wxModalDialogHook); -}; - -// Helper object used by WX_MODAL_DIALOG_HOOK below to ensure that CallExit() -// is called on scope exit. -class wxModalDialogHookExitGuard -{ -public: - wxEXPLICIT wxModalDialogHookExitGuard(wxDialog* dialog) - : m_dialog(dialog) - { - } - - ~wxModalDialogHookExitGuard() - { - wxModalDialogHook::CallExit(m_dialog); - } - -private: - wxDialog* const m_dialog; - - wxDECLARE_NO_COPY_CLASS(wxModalDialogHookExitGuard); -}; - -// This macro needs to be used at the top of every implementation of -// ShowModal() in order for wxModalDialogHook to work. -#define WX_HOOK_MODAL_DIALOG() \ - const int modalDialogHookRC = wxModalDialogHook::CallEnter(this); \ - if ( modalDialogHookRC != wxID_NONE ) \ - return modalDialogHookRC; \ - wxModalDialogHookExitGuard modalDialogHookExit(this) - -#endif // _WX_MODALHOOK_H_ diff --git a/Source/3rd Party/wx/include/wx/module.h b/Source/3rd Party/wx/include/wx/module.h index 15f98e89b..7cee6f226 100644 --- a/Source/3rd Party/wx/include/wx/module.h +++ b/Source/3rd Party/wx/include/wx/module.h @@ -4,6 +4,7 @@ // Author: Wolfram Gloger/adapted by Guilhem Lavaux // Modified by: // Created: 04/11/98 +// RCS-ID: $Id: module.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Wolfram Gloger and Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,7 +14,6 @@ #include "wx/object.h" #include "wx/list.h" -#include "wx/arrstr.h" #include "wx/dynarray.h" // declare a linked list of modules @@ -73,14 +73,6 @@ protected: m_dependencies.Add(dep); } - // same as the version above except it will look up wxClassInfo by name on - // its own - void AddDependency(const char *className) - { - m_namedDependencies.Add(className); - } - - private: // initialize module and Append it to initializedModules list recursively // calling itself to satisfy module dependencies if needed @@ -92,19 +84,11 @@ private: // could be initialized) and also empty m_modules itself static void DoCleanUpModules(const wxModuleList& modules); - // resolve all named dependencies and add them to the normal m_dependencies - bool ResolveNamedDependencies(); - - // module dependencies: contains wxClassInfo pointers for all modules which - // must be initialized before this one + // module dependencies: contains wxArrayClassInfo m_dependencies; - // and the named dependencies: those will be resolved during run-time and - // added to m_dependencies - wxArrayString m_namedDependencies; - - // used internally while initializing/cleaning up modules + // used internally while initiliazing/cleaning up modules enum { State_Registered, // module registered but not initialized yet diff --git a/Source/3rd Party/wx/include/wx/mousemanager.h b/Source/3rd Party/wx/include/wx/mousemanager.h deleted file mode 100644 index caa2abeae..000000000 --- a/Source/3rd Party/wx/include/wx/mousemanager.h +++ /dev/null @@ -1,153 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/mousemanager.h -// Purpose: wxMouseEventsManager class declaration -// Author: Vadim Zeitlin -// Created: 2009-04-20 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MOUSEMANAGER_H_ -#define _WX_MOUSEMANAGER_H_ - -#include "wx/event.h" - -// ---------------------------------------------------------------------------- -// wxMouseEventsManager -// ---------------------------------------------------------------------------- - -/* - This class handles mouse events and synthesizes high-level notifications - such as clicks and drag events from low level mouse button presses and - mouse movement events. It is useful because handling the mouse events is - less obvious than might seem at a first glance: for example, clicks on an - object should only be generated if the mouse was both pressed and released - over it and not just released (so it requires storing the previous state) - and dragging shouldn't start before the mouse moves away far enough. - - This class encapsulates all these dull details for controls containing - multiple items which can be identified by a positive integer index and you - just need to implement its pure virtual functions to use it. - */ -class WXDLLIMPEXP_CORE wxMouseEventsManager : public wxEvtHandler -{ -public: - // a mouse event manager is always associated with a window and must be - // deleted by the window when it is destroyed so if it is created using the - // default ctor Create() must be called later - wxMouseEventsManager() { Init(); } - wxMouseEventsManager(wxWindow *win) { Init(); Create(win); } - bool Create(wxWindow *win); - - virtual ~wxMouseEventsManager(); - -protected: - // called to find the item at the given position: return wxNOT_FOUND (-1) - // if there is no item here - virtual int MouseHitTest(const wxPoint& pos) = 0; - - // called when the user clicked (i.e. pressed and released mouse over the - // same item), should normally generate a notification about this click and - // return true if it was handled or false otherwise, determining whether - // the original mouse event is skipped or not - virtual bool MouseClicked(int item) = 0; - - // called to start dragging the given item, should generate the appropriate - // BEGIN_DRAG event and return false if dragging this item was forbidden - virtual bool MouseDragBegin(int item, const wxPoint& pos) = 0; - - // called while the item is being dragged, should normally update the - // feedback on screen (usually using wxOverlay) - virtual void MouseDragging(int item, const wxPoint& pos) = 0; - - // called when the mouse is released after dragging the item - virtual void MouseDragEnd(int item, const wxPoint& pos) = 0; - - // called when mouse capture is lost while dragging the item, should remove - // the visual feedback drawn by MouseDragging() - virtual void MouseDragCancelled(int item) = 0; - - - // you don't need to override those but you will want to do if it your - // control renders pressed items differently - - // called when the item is becomes pressed, can be used to change its - // appearance - virtual void MouseClickBegin(int WXUNUSED(item)) { } - - // called if the mouse capture was lost while the item was pressed, can be - // used to restore the default item appearance if it was changed in - // MouseClickBegin() - virtual void MouseClickCancelled(int WXUNUSED(item)) { } - -private: - /* - Here is a small diagram explaining the switches between different - states: - - - /---------->NORMAL<--------------- Drag end - / / / | event - / / | | ^ - / / | | | - Click / N | | mouse | mouse up - event / | | down | - | / | | DRAGGING - | / | | ^ - Y|/ N \ v |Y - +-------------+ +--------+ N +-----------+ - |On same item?| |On item?| -----------|Begin drag?| - +-------------+ +--------+ / +-----------+ - ^ | / ^ - | | / | - \ mouse | / mouse moved | - \ up v v far enough / - \--------PRESSED-------------------/ - - - There are also transitions from PRESSED and DRAGGING to NORMAL in case - the mouse capture is lost or Escape key is pressed which are not shown. - */ - enum State - { - State_Normal, // initial, default state - State_Pressed, // mouse was pressed over an item - State_Dragging // the item is being dragged - }; - - // common part of both ctors - void Init(); - - // various event handlers - void OnCaptureLost(wxMouseCaptureLostEvent& event); - void OnLeftDown(wxMouseEvent& event); - void OnLeftUp(wxMouseEvent& event); - void OnMove(wxMouseEvent& event); - - - // the associated window, never NULL except between the calls to the - // default ctor and Create() - wxWindow *m_win; - - // the current state - State m_state; - - // the details of the operation currently in progress, only valid if - // m_state is not normal - - // the item being pressed or dragged (always valid, i.e. != wxNOT_FOUND if - // m_state != State_Normal) - int m_item; - - // the position of the last mouse event of interest: either mouse press in - // State_Pressed or last movement event in State_Dragging - wxPoint m_posLast; - - - DECLARE_EVENT_TABLE() - - wxDECLARE_NO_COPY_CLASS(wxMouseEventsManager); -}; - -#endif // _WX_MOUSEMANAGER_H_ - diff --git a/Source/3rd Party/wx/include/wx/mousestate.h b/Source/3rd Party/wx/include/wx/mousestate.h deleted file mode 100644 index 2ea1cc5bf..000000000 --- a/Source/3rd Party/wx/include/wx/mousestate.h +++ /dev/null @@ -1,149 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/mousestate.h -// Purpose: Declaration of wxMouseState class -// Author: Vadim Zeitlin -// Created: 2008-09-19 (extracted from wx/utils.h) -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MOUSESTATE_H_ -#define _WX_MOUSESTATE_H_ - -#include "wx/gdicmn.h" // for wxPoint -#include "wx/kbdstate.h" - -// the symbolic names for the mouse buttons -enum wxMouseButton -{ - wxMOUSE_BTN_ANY = -1, - wxMOUSE_BTN_NONE = 0, - wxMOUSE_BTN_LEFT = 1, - wxMOUSE_BTN_MIDDLE = 2, - wxMOUSE_BTN_RIGHT = 3, - wxMOUSE_BTN_AUX1 = 4, - wxMOUSE_BTN_AUX2 = 5, - wxMOUSE_BTN_MAX -}; - -// ---------------------------------------------------------------------------- -// wxMouseState contains the information about mouse position, buttons and also -// key modifiers -// ---------------------------------------------------------------------------- - -// wxMouseState is used to hold information about button and modifier state -// and is what is returned from wxGetMouseState. -class WXDLLIMPEXP_CORE wxMouseState : public wxKeyboardState -{ -public: - wxMouseState() - : m_leftDown(false), m_middleDown(false), m_rightDown(false), - m_aux1Down(false), m_aux2Down(false), - m_x(0), m_y(0) - { - } - - // default copy ctor, assignment operator and dtor are ok - - - // accessors for the mouse position - wxCoord GetX() const { return m_x; } - wxCoord GetY() const { return m_y; } - wxPoint GetPosition() const { return wxPoint(m_x, m_y); } - void GetPosition(wxCoord *x, wxCoord *y) const - { - if ( x ) - *x = m_x; - if ( y ) - *y = m_y; - } - - // this overload is for compatibility only - void GetPosition(long *x, long *y) const - { - if ( x ) - *x = m_x; - if ( y ) - *y = m_y; - } - - // accessors for the pressed buttons - bool LeftIsDown() const { return m_leftDown; } - bool MiddleIsDown() const { return m_middleDown; } - bool RightIsDown() const { return m_rightDown; } - bool Aux1IsDown() const { return m_aux1Down; } - bool Aux2IsDown() const { return m_aux2Down; } - - bool ButtonIsDown(wxMouseButton but) const - { - switch ( but ) - { - case wxMOUSE_BTN_ANY: - return LeftIsDown() || MiddleIsDown() || RightIsDown() || - Aux1IsDown() || Aux2IsDown(); - - case wxMOUSE_BTN_LEFT: - return LeftIsDown(); - - case wxMOUSE_BTN_MIDDLE: - return MiddleIsDown(); - - case wxMOUSE_BTN_RIGHT: - return RightIsDown(); - - case wxMOUSE_BTN_AUX1: - return Aux1IsDown(); - - case wxMOUSE_BTN_AUX2: - return Aux2IsDown(); - - case wxMOUSE_BTN_NONE: - case wxMOUSE_BTN_MAX: - break; - } - - wxFAIL_MSG(wxS("invalid parameter")); - return false; - } - - - // these functions are mostly used by wxWidgets itself - void SetX(wxCoord x) { m_x = x; } - void SetY(wxCoord y) { m_y = y; } - void SetPosition(wxPoint pos) { m_x = pos.x, m_y = pos.y; } - - void SetLeftDown(bool down) { m_leftDown = down; } - void SetMiddleDown(bool down) { m_middleDown = down; } - void SetRightDown(bool down) { m_rightDown = down; } - void SetAux1Down(bool down) { m_aux1Down = down; } - void SetAux2Down(bool down) { m_aux2Down = down; } - - // this mostly makes sense in the derived classes such as wxMouseEvent - void SetState(const wxMouseState& state) { *this = state; } - - // these functions are for compatibility only, they were used in 2.8 - // version of wxMouseState but their names are confusing as wxMouseEvent - // has methods with the same names which do something quite different so - // don't use them any more -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_INLINE(bool LeftDown() const, return LeftIsDown(); ) - wxDEPRECATED_INLINE(bool MiddleDown() const, return MiddleIsDown(); ) - wxDEPRECATED_INLINE(bool RightDown() const, return RightIsDown(); ) -#endif // WXWIN_COMPATIBILITY_2_8 - - // for compatibility reasons these variables are public as the code using - // wxMouseEvent often uses them directly -- however they should not be - // accessed directly in this class, use the accessors above instead -// private: - bool m_leftDown : 1; - bool m_middleDown : 1; - bool m_rightDown : 1; - bool m_aux1Down : 1; - bool m_aux2Down : 1; - - wxCoord m_x, - m_y; -}; - -#endif // _WX_MOUSESTATE_H_ - diff --git a/Source/3rd Party/wx/include/wx/msgdlg.h b/Source/3rd Party/wx/include/wx/msgdlg.h index 3b0ea9fde..dabea34f9 100644 --- a/Source/3rd Party/wx/include/wx/msgdlg.h +++ b/Source/3rd Party/wx/include/wx/msgdlg.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msgdlg.h +// Name: wx/msgdlgg.h // Purpose: common header and base class for wxMessageDialog // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: msgdlg.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,302 +16,58 @@ #if wxUSE_MSGDLG -#include "wx/dialog.h" -#include "wx/stockitem.h" - -extern WXDLLIMPEXP_DATA_CORE(const char) wxMessageBoxCaptionStr[]; - -// ---------------------------------------------------------------------------- -// wxMessageDialogBase: base class defining wxMessageDialog interface -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMessageDialogBase : public wxDialog +class WXDLLEXPORT wxMessageDialogBase { -public: - // helper class for SetXXXLabels() methods: it makes it possible to pass - // either a stock id (wxID_CLOSE) or a string ("&Close") to them - class ButtonLabel - { - public: - // ctors are not explicit, objects of this class can be implicitly - // constructed from either stock ids or strings - ButtonLabel(int stockId) - : m_stockId(stockId) - { - wxASSERT_MSG( wxIsStockID(stockId), "invalid stock id" ); - } - - ButtonLabel(const wxString& label) - : m_label(label), m_stockId(wxID_NONE) - { - } - - ButtonLabel(const char *label) - : m_label(label), m_stockId(wxID_NONE) - { - } - - ButtonLabel(const wchar_t *label) - : m_label(label), m_stockId(wxID_NONE) - { - } - - ButtonLabel(const wxCStrData& label) - : m_label(label), m_stockId(wxID_NONE) - { - } - - // default copy ctor and dtor are ok - - // get the string label, whether it was originally specified directly - // or as a stock id -- this is only useful for platforms without native - // stock items id support - wxString GetAsString() const - { - return m_stockId == wxID_NONE - ? m_label - : wxGetStockLabel(m_stockId, wxSTOCK_FOR_BUTTON); - } - - // return the stock id or wxID_NONE if this is not a stock label - int GetStockId() const { return m_stockId; } - - private: - // the label if explicitly given or empty if this is a stock item - const wxString m_label; - - // the stock item id or wxID_NONE if m_label should be used - const int m_stockId; - }; - - // ctors - wxMessageDialogBase() { m_dialogStyle = 0; } - wxMessageDialogBase(wxWindow *parent, - const wxString& message, - const wxString& caption, - long style) - : m_message(message), - m_caption(caption) - { - m_parent = parent; - SetMessageDialogStyle(style); - } - - // virtual dtor for the base class - virtual ~wxMessageDialogBase() { } - - wxString GetCaption() const { return m_caption; } - - virtual void SetMessage(const wxString& message) - { - m_message = message; - } - - wxString GetMessage() const { return m_message; } - - void SetExtendedMessage(const wxString& extendedMessage) - { - m_extendedMessage = extendedMessage; - } - - wxString GetExtendedMessage() const { return m_extendedMessage; } - - // change the dialog style flag +protected: + // common validation of wxMessageDialog style void SetMessageDialogStyle(long style) { - wxASSERT_MSG( ((style & wxYES_NO) == wxYES_NO) || !(style & wxYES_NO), - "wxYES and wxNO may only be used together" ); - - wxASSERT_MSG( !(style & wxYES) || !(style & wxOK), - "wxOK and wxYES/wxNO can't be used together" ); - - // It is common to specify just the icon, without wxOK, in the existing - // code, especially one written by Windows programmers as MB_OK is 0 - // and so they're used to omitting wxOK. Don't complain about it but - // just add wxOK implicitly for compatibility. - if ( !(style & wxYES) && !(style & wxOK) ) - style |= wxOK; + wxASSERT_MSG( ((style & wxYES_NO) == wxYES_NO) || ((style & wxYES_NO) == 0), + wxT("wxYES and wxNO may only be used together in wxMessageDialog") ); wxASSERT_MSG( (style & wxID_OK) != wxID_OK, - "wxMessageBox: Did you mean wxOK (and not wxID_OK)?" ); - - wxASSERT_MSG( !(style & wxNO_DEFAULT) || (style & wxNO), - "wxNO_DEFAULT is invalid without wxNO" ); - - wxASSERT_MSG( !(style & wxCANCEL_DEFAULT) || (style & wxCANCEL), - "wxCANCEL_DEFAULT is invalid without wxCANCEL" ); - - wxASSERT_MSG( !(style & wxCANCEL_DEFAULT) || !(style & wxNO_DEFAULT), - "only one default button can be specified" ); + wxT("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") ); m_dialogStyle = style; } - - long GetMessageDialogStyle() const { return m_dialogStyle; } - - // customization of the message box buttons - virtual bool SetYesNoLabels(const ButtonLabel& yes,const ButtonLabel& no) + inline long GetMessageDialogStyle() const { - DoSetCustomLabel(m_yes, yes); - DoSetCustomLabel(m_no, no); - return true; + return m_dialogStyle; } - virtual bool SetYesNoCancelLabels(const ButtonLabel& yes, - const ButtonLabel& no, - const ButtonLabel& cancel) - { - DoSetCustomLabel(m_yes, yes); - DoSetCustomLabel(m_no, no); - DoSetCustomLabel(m_cancel, cancel); - return true; - } - - virtual bool SetOKLabel(const ButtonLabel& ok) - { - DoSetCustomLabel(m_ok, ok); - return true; - } - - virtual bool SetOKCancelLabels(const ButtonLabel& ok, - const ButtonLabel& cancel) - { - DoSetCustomLabel(m_ok, ok); - DoSetCustomLabel(m_cancel, cancel); - return true; - } - - virtual bool SetHelpLabel(const ButtonLabel& help) - { - DoSetCustomLabel(m_help, help); - return true; - } - - // test if any custom labels were set - bool HasCustomLabels() const - { - return !(m_ok.empty() && m_cancel.empty() && m_help.empty() && - m_yes.empty() && m_no.empty()); - } - - // these functions return the label to be used for the button which is - // either a custom label explicitly set by the user or the default label, - // i.e. they always return a valid string - wxString GetYesLabel() const - { return m_yes.empty() ? GetDefaultYesLabel() : m_yes; } - wxString GetNoLabel() const - { return m_no.empty() ? GetDefaultNoLabel() : m_no; } - wxString GetOKLabel() const - { return m_ok.empty() ? GetDefaultOKLabel() : m_ok; } - wxString GetCancelLabel() const - { return m_cancel.empty() ? GetDefaultCancelLabel() : m_cancel; } - wxString GetHelpLabel() const - { return m_help.empty() ? GetDefaultHelpLabel() : m_help; } - - // based on message dialog style, returns exactly one of: wxICON_NONE, - // wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION, - // wxICON_AUTH_NEEDED - virtual long GetEffectiveIcon() const - { - if ( m_dialogStyle & wxICON_NONE ) - return wxICON_NONE; - else if ( m_dialogStyle & wxICON_ERROR ) - return wxICON_ERROR; - else if ( m_dialogStyle & wxICON_WARNING ) - return wxICON_WARNING; - else if ( m_dialogStyle & wxICON_QUESTION ) - return wxICON_QUESTION; - else if ( m_dialogStyle & wxICON_INFORMATION ) - return wxICON_INFORMATION; - else if ( m_dialogStyle & wxYES ) - return wxICON_QUESTION; - else - return wxICON_INFORMATION; - } - -protected: - // for the platforms not supporting separate main and extended messages - // this function should be used to combine both of them in a single string - wxString GetFullMessage() const - { - wxString msg = m_message; - if ( !m_extendedMessage.empty() ) - msg << "\n\n" << m_extendedMessage; - - return msg; - } - - wxString m_message, - m_extendedMessage, - m_caption; - long m_dialogStyle; - - // this function is called by our public SetXXXLabels() and should assign - // the value to var with possibly some transformation (e.g. Cocoa version - // currently uses this to remove any accelerators from the button strings - // while GTK+ one handles stock items specifically here) - virtual void DoSetCustomLabel(wxString& var, const ButtonLabel& label) - { - var = label.GetAsString(); - } - - // these functions return the custom label or empty string and should be - // used only in specific circumstances such as creating the buttons with - // these labels (in which case it makes sense to only use a custom label if - // it was really given and fall back on stock label otherwise), use the - // Get{Yes,No,OK,Cancel}Label() methods above otherwise - const wxString& GetCustomYesLabel() const { return m_yes; } - const wxString& GetCustomNoLabel() const { return m_no; } - const wxString& GetCustomOKLabel() const { return m_ok; } - const wxString& GetCustomHelpLabel() const { return m_help; } - const wxString& GetCustomCancelLabel() const { return m_cancel; } - private: - // these functions may be overridden to provide different defaults for the - // default button labels (this is used by wxGTK) - virtual wxString GetDefaultYesLabel() const { return wxGetTranslation("Yes"); } - virtual wxString GetDefaultNoLabel() const { return wxGetTranslation("No"); } - virtual wxString GetDefaultOKLabel() const { return wxGetTranslation("OK"); } - virtual wxString GetDefaultCancelLabel() const { return wxGetTranslation("Cancel"); } - virtual wxString GetDefaultHelpLabel() const { return wxGetTranslation("Help"); } - - // labels for the buttons, initially empty meaning that the defaults should - // be used, use GetYes/No/OK/CancelLabel() to access them - wxString m_yes, - m_no, - m_ok, - m_cancel, - m_help; - - wxDECLARE_NO_COPY_CLASS(wxMessageDialogBase); + long m_dialogStyle; }; +#if defined(__WX_COMPILING_MSGDLGG_CPP__) #include "wx/generic/msgdlgg.h" - -#if defined(__WX_COMPILING_MSGDLGG_CPP__) || \ - defined(__WXUNIVERSAL__) || defined(__WXGPE__) || \ - (defined(__WXGTK__) && !defined(__WXGTK20__)) - - #define wxMessageDialog wxGenericMessageDialog -#elif defined(__WXCOCOA__) - #include "wx/cocoa/msgdlg.h" +#elif defined(__WXUNIVERSAL__) || defined(__WXGPE__) +#include "wx/generic/msgdlgg.h" +#elif defined(__WXPALMOS__) +#include "wx/palmos/msgdlg.h" #elif defined(__WXMSW__) - #include "wx/msw/msgdlg.h" +#include "wx/msw/msgdlg.h" #elif defined(__WXMOTIF__) - #include "wx/motif/msgdlg.h" +#include "wx/motif/msgdlg.h" #elif defined(__WXGTK20__) - #include "wx/gtk/msgdlg.h" +#include "wx/gtk/msgdlg.h" +#elif defined(__WXGTK__) +#include "wx/generic/msgdlgg.h" +#elif defined(__WXGTK__) +#include "wx/generic/msgdlgg.h" #elif defined(__WXMAC__) - #include "wx/osx/msgdlg.h" +#include "wx/mac/msgdlg.h" +#elif defined(__WXCOCOA__) +#include "wx/cocoa/msgdlg.h" #elif defined(__WXPM__) - #include "wx/os2/msgdlg.h" +#include "wx/os2/msgdlg.h" #endif // ---------------------------------------------------------------------------- // wxMessageBox: the simplest way to use wxMessageDialog // ---------------------------------------------------------------------------- -int WXDLLIMPEXP_CORE wxMessageBox(const wxString& message, +int WXDLLEXPORT wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, long style = wxOK | wxCENTRE, wxWindow *parent = NULL, @@ -318,4 +75,5 @@ int WXDLLIMPEXP_CORE wxMessageBox(const wxString& message, #endif // wxUSE_MSGDLG -#endif // _WX_MSGDLG_H_BASE_ +#endif + // _WX_MSGDLG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/msgout.h b/Source/3rd Party/wx/include/wx/msgout.h index dac849272..63803bfa3 100644 --- a/Source/3rd Party/wx/include/wx/msgout.h +++ b/Source/3rd Party/wx/include/wx/msgout.h @@ -4,6 +4,7 @@ // Author: Mattia Barbon // Modified by: // Created: 17.07.02 +// RCS-ID: $Id: msgout.h 35690 2005-09-25 20:23:30Z VZ $ // Copyright: (c) Mattia Barbon // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,67 +17,21 @@ // ---------------------------------------------------------------------------- #include "wx/defs.h" -#include "wx/chartype.h" -#include "wx/strvararg.h" +#include "wx/wxchar.h" // ---------------------------------------------------------------------------- // wxMessageOutput is a class abstracting formatted output target, i.e. // something you can printf() to // ---------------------------------------------------------------------------- -// NB: VC6 has a bug that causes linker errors if you have template methods -// in a class using __declspec(dllimport). The solution is to split such -// class into two classes, one that contains the template methods and does -// *not* use WXDLLIMPEXP_BASE and another class that contains the rest -// (with DLL linkage). -class wxMessageOutputBase -{ -public: - virtual ~wxMessageOutputBase() { } - - // show a message to the user - // void Printf(const wxString& format, ...) = 0; - WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&), - DoPrintfWchar, DoPrintfUtf8) -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxCStrData&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wchar_t*), - (wxFormatString(f1))); -#endif - - // called by DoPrintf() to output formatted string but can also be called - // directly if no formatting is needed - virtual void Output(const wxString& str) = 0; - -protected: - // NB: this is pure virtual so that it can be implemented in dllexported - // wxMessagOutput class -#if !wxUSE_UTF8_LOCALE_ONLY - virtual void DoPrintfWchar(const wxChar *format, ...) = 0; -#endif -#if wxUSE_UNICODE_UTF8 - virtual void DoPrintfUtf8(const char *format, ...) = 0; -#endif -}; - -#ifdef __VISUALC__ - // "non dll-interface class 'wxStringPrintfMixin' used as base interface - // for dll-interface class 'wxString'" -- this is OK in our case - #pragma warning (push) - #pragma warning (disable:4275) -#endif - -class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase +class WXDLLIMPEXP_BASE wxMessageOutput { public: virtual ~wxMessageOutput() { } + // show a message to the user + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0; + // gets the current wxMessageOutput object (may be NULL during // initialization or shutdown) static wxMessageOutput* Get(); @@ -84,90 +39,62 @@ public: // sets the global wxMessageOutput instance; returns the previous one static wxMessageOutput* Set(wxMessageOutput* msgout); -protected: -#if !wxUSE_UTF8_LOCALE_ONLY - virtual void DoPrintfWchar(const wxChar *format, ...); -#endif -#if wxUSE_UNICODE_UTF8 - virtual void DoPrintfUtf8(const char *format, ...); -#endif - private: static wxMessageOutput* ms_msgOut; }; -#ifdef __VISUALC__ - #pragma warning (pop) -#endif +// ---------------------------------------------------------------------------- +// implementation showing the message to the user in "best" possible way: uses +// native message box if available (currently only under Windows) and stderr +// otherwise; unlike wxMessageOutputMessageBox this class is always safe to use +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput +{ +public: + wxMessageOutputBest() { } + + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; +}; // ---------------------------------------------------------------------------- -// implementation which sends output to stderr or specified file +// implementation which sends output to stderr // ---------------------------------------------------------------------------- class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput { public: - wxMessageOutputStderr(FILE *fp = stderr) : m_fp(fp) { } + wxMessageOutputStderr() { } - virtual void Output(const wxString& str); - -protected: - // return the string with "\n" appended if it doesn't already terminate - // with it (in which case it's returned unchanged) - wxString AppendLineFeedIfNeeded(const wxString& str); - - FILE *m_fp; -}; - -// ---------------------------------------------------------------------------- -// implementation showing the message to the user in "best" possible way: -// uses stderr or message box if available according to the flag given to ctor. -// ---------------------------------------------------------------------------- - -enum wxMessageOutputFlags -{ - wxMSGOUT_PREFER_STDERR = 0, // use stderr if available (this is the default) - wxMSGOUT_PREFER_MSGBOX = 1 // always use message box if available -}; - -class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutputStderr -{ -public: - wxMessageOutputBest(wxMessageOutputFlags flags = wxMSGOUT_PREFER_STDERR) - : m_flags(flags) { } - - virtual void Output(const wxString& str); - -private: - wxMessageOutputFlags m_flags; + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; }; // ---------------------------------------------------------------------------- // implementation which shows output in a message box // ---------------------------------------------------------------------------- -#if wxUSE_GUI && wxUSE_MSGDLG +#if wxUSE_GUI class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput { public: wxMessageOutputMessageBox() { } - virtual void Output(const wxString& str); + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; }; -#endif // wxUSE_GUI && wxUSE_MSGDLG +#endif // wxUSE_GUI // ---------------------------------------------------------------------------- // implementation using the native way of outputting debug messages // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutputStderr +class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput { public: wxMessageOutputDebug() { } - virtual void Output(const wxString& str); + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; }; // ---------------------------------------------------------------------------- @@ -179,7 +106,8 @@ class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput public: wxMessageOutputLog() { } - virtual void Output(const wxString& str); + virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; }; -#endif // _WX_MSGOUT_H_ +#endif + // _WX_MSGOUT_H_ diff --git a/Source/3rd Party/wx/include/wx/msgqueue.h b/Source/3rd Party/wx/include/wx/msgqueue.h deleted file mode 100644 index 8b8da87d1..000000000 --- a/Source/3rd Party/wx/include/wx/msgqueue.h +++ /dev/null @@ -1,168 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msqqueue.h -// Purpose: Message queues for inter-thread communication -// Author: Evgeniy Tarassov -// Created: 2007-10-31 -// Copyright: (C) 2007 TT-Solutions SARL -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSGQUEUE_H_ -#define _WX_MSGQUEUE_H_ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/thread.h" - -#if wxUSE_THREADS - -#include "wx/stopwatch.h" - -#include "wx/beforestd.h" -#include -#include "wx/afterstd.h" - -enum wxMessageQueueError -{ - wxMSGQUEUE_NO_ERROR = 0, // operation completed successfully - wxMSGQUEUE_TIMEOUT, // no messages received before timeout expired - wxMSGQUEUE_MISC_ERROR // some unexpected (and fatal) error has occurred -}; - -// --------------------------------------------------------------------------- -// Message queue allows passing message between threads. -// -// This class is typically used for communicating between the main and worker -// threads. The main thread calls Post() and the worker thread calls Receive(). -// -// For this class a message is an object of arbitrary type T. Notice that -// typically there must be some special message indicating that the thread -// should terminate as there is no other way to gracefully shutdown a thread -// waiting on the message queue. -// --------------------------------------------------------------------------- -template -class wxMessageQueue -{ -public: - // The type of the messages transported by this queue - typedef T Message; - - // Default ctor creates an initially empty queue - wxMessageQueue() - : m_conditionNotEmpty(m_mutex) - { - } - - // Add a message to this queue and signal the threads waiting for messages. - // - // This method is safe to call from multiple threads in parallel. - wxMessageQueueError Post(const Message& msg) - { - wxMutexLocker locker(m_mutex); - - wxCHECK( locker.IsOk(), wxMSGQUEUE_MISC_ERROR ); - - m_messages.push(msg); - - m_conditionNotEmpty.Signal(); - - return wxMSGQUEUE_NO_ERROR; - } - - // Remove all messages from the queue. - // - // This method is meant to be called from the same thread(s) that call - // Post() to discard any still pending requests if they became unnecessary. - wxMessageQueueError Clear() - { - wxCHECK( IsOk(), wxMSGQUEUE_MISC_ERROR ); - - wxMutexLocker locker(m_mutex); - - std::queue empty; - std::swap(m_messages, empty); - - return wxMSGQUEUE_NO_ERROR; - } - - // Wait no more than timeout milliseconds until a message becomes available. - // - // Setting timeout to 0 is equivalent to an infinite timeout. See Receive(). - wxMessageQueueError ReceiveTimeout(long timeout, T& msg) - { - wxCHECK( IsOk(), wxMSGQUEUE_MISC_ERROR ); - - wxMutexLocker locker(m_mutex); - - wxCHECK( locker.IsOk(), wxMSGQUEUE_MISC_ERROR ); - - const wxMilliClock_t waitUntil = wxGetLocalTimeMillis() + timeout; - while ( m_messages.empty() ) - { - wxCondError result = m_conditionNotEmpty.WaitTimeout(timeout); - - if ( result == wxCOND_NO_ERROR ) - continue; - - wxCHECK( result == wxCOND_TIMEOUT, wxMSGQUEUE_MISC_ERROR ); - - const wxMilliClock_t now = wxGetLocalTimeMillis(); - - if ( now >= waitUntil ) - return wxMSGQUEUE_TIMEOUT; - - timeout = (waitUntil - now).ToLong(); - wxASSERT(timeout > 0); - } - - msg = m_messages.front(); - m_messages.pop(); - - return wxMSGQUEUE_NO_ERROR; - } - - // Same as ReceiveTimeout() but waits for as long as it takes for a message - // to become available (so it can't return wxMSGQUEUE_TIMEOUT) - wxMessageQueueError Receive(T& msg) - { - wxCHECK( IsOk(), wxMSGQUEUE_MISC_ERROR ); - - wxMutexLocker locker(m_mutex); - - wxCHECK( locker.IsOk(), wxMSGQUEUE_MISC_ERROR ); - - while ( m_messages.empty() ) - { - wxCondError result = m_conditionNotEmpty.Wait(); - - wxCHECK( result == wxCOND_NO_ERROR, wxMSGQUEUE_MISC_ERROR ); - } - - msg = m_messages.front(); - m_messages.pop(); - - return wxMSGQUEUE_NO_ERROR; - } - - // Return false only if there was a fatal error in ctor - bool IsOk() const - { - return m_conditionNotEmpty.IsOk(); - } - -private: - // Disable copy ctor and assignment operator - wxMessageQueue(const wxMessageQueue& rhs); - wxMessageQueue& operator=(const wxMessageQueue& rhs); - - mutable wxMutex m_mutex; - wxCondition m_conditionNotEmpty; - - std::queue m_messages; -}; - -#endif // wxUSE_THREADS - -#endif // _WX_MSGQUEUE_H_ diff --git a/Source/3rd Party/wx/include/wx/mstream.h b/Source/3rd Party/wx/include/wx/mstream.h index 5a5e955b2..a81452284 100644 --- a/Source/3rd Party/wx/include/wx/mstream.h +++ b/Source/3rd Party/wx/include/wx/mstream.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: // Created: 11/07/98 +// RCS-ID: $Id: mstream.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,23 +25,11 @@ class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream public: wxMemoryInputStream(const void *data, size_t length); wxMemoryInputStream(const wxMemoryOutputStream& stream); - wxMemoryInputStream(wxInputStream& stream, - wxFileOffset lenFile = wxInvalidOffset) - { - InitFromStream(stream, lenFile); - } - wxMemoryInputStream(wxMemoryInputStream& stream) - : wxInputStream() - { - InitFromStream(stream, wxInvalidOffset); - } - virtual ~wxMemoryInputStream(); virtual wxFileOffset GetLength() const { return m_length; } virtual bool IsSeekable() const { return true; } - virtual char Peek(); - virtual bool CanRead() const; + char Peek(); wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; } @@ -57,14 +46,9 @@ protected: wxFileOffset OnSysTell() const; private: - // common part of ctors taking wxInputStream - void InitFromStream(wxInputStream& stream, wxFileOffset lenFile); - size_t m_length; - // copy ctor is implemented above: it copies the other stream in this one - DECLARE_ABSTRACT_CLASS(wxMemoryInputStream) - wxDECLARE_NO_ASSIGN_CLASS(wxMemoryInputStream); + DECLARE_NO_COPY_CLASS(wxMemoryInputStream) }; class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream @@ -93,8 +77,7 @@ protected: wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); wxFileOffset OnSysTell() const; - DECLARE_DYNAMIC_CLASS(wxMemoryOutputStream) - wxDECLARE_NO_COPY_CLASS(wxMemoryOutputStream); + DECLARE_NO_COPY_CLASS(wxMemoryOutputStream) }; #if WXWIN_COMPATIBILITY_2_6 diff --git a/Source/3rd Party/wx/include/wx/msw/accel.h b/Source/3rd Party/wx/include/wx/msw/accel.h index 1180ba2f1..705146894 100644 --- a/Source/3rd Party/wx/include/wx/msw/accel.h +++ b/Source/3rd Party/wx/include/wx/msw/accel.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 31/7/98 +// RCS-ID: $Id: accel.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; // the accel table has all accelerators for a given window or menu // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxAcceleratorTable : public wxObject +class WXDLLEXPORT wxAcceleratorTable : public wxObject { public: // default ctor diff --git a/Source/3rd Party/wx/include/wx/msw/anybutton.h b/Source/3rd Party/wx/include/wx/msw/anybutton.h deleted file mode 100644 index e8226d51c..000000000 --- a/Source/3rd Party/wx/include/wx/msw/anybutton.h +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/anybutton.h -// Purpose: wxAnyButton class -// Author: Julian Smart -// Created: 1997-02-01 (extracted from button.h) -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_ANYBUTTON_H_ -#define _WX_MSW_ANYBUTTON_H_ - -// ---------------------------------------------------------------------------- -// Common button functionality -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase -{ -public: - wxAnyButton() - { - m_imageData = NULL; -#if wxUSE_MARKUP - m_markupText = NULL; -#endif // wxUSE_MARKUP - } - - virtual ~wxAnyButton(); - - // overridden base class methods - virtual void SetLabel(const wxString& label); - virtual bool SetBackgroundColour(const wxColour &colour); - virtual bool SetForegroundColour(const wxColour &colour); - - // implementation from now on - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); - - virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); - virtual State GetNormalState() const { return State_Normal; } - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - -protected: - // usually overridden base class virtuals - virtual wxSize DoGetBestSize() const; - - virtual wxBitmap DoGetBitmap(State which) const; - virtual void DoSetBitmap(const wxBitmap& bitmap, State which); - virtual wxSize DoGetBitmapMargins() const; - virtual void DoSetBitmapMargins(wxCoord x, wxCoord y); - virtual void DoSetBitmapPosition(wxDirection dir); - -#if wxUSE_MARKUP - virtual bool DoSetLabelMarkup(const wxString& markup); -#endif // wxUSE_MARKUP - - // Increases the passed in size to account for the button image. - // - // Should only be called if we do have a button, i.e. if m_imageData is - // non-NULL. - void AdjustForBitmapSize(wxSize& size) const; - - class wxButtonImageData *m_imageData; - -#if wxUSE_MARKUP - class wxMarkupText *m_markupText; -#endif // wxUSE_MARKUP - - // Switches button into owner-drawn mode: this is used if we need to draw - // something not supported by the native control, such as using non default - // colours or a bitmap on pre-XP systems. - void MakeOwnerDrawn(); - bool IsOwnerDrawn() const; - -private: - wxDECLARE_NO_COPY_CLASS(wxAnyButton); -}; - -#endif // _WX_MSW_ANYBUTTON_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/app.h b/Source/3rd Party/wx/include/wx/msw/app.h index 469d5d47a..4989c9c7a 100644 --- a/Source/3rd Party/wx/include/wx/msw/app.h +++ b/Source/3rd Party/wx/include/wx/msw/app.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/app.h +// Name: app.h // Purpose: wxApp class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: app.h 53157 2008-04-13 12:17:37Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,8 +23,10 @@ class WXDLLIMPEXP_FWD_BASE wxLog; // Represents the application. Derive OnInit and declare // a new App object to start application -class WXDLLIMPEXP_CORE wxApp : public wxAppBase +class WXDLLEXPORT wxApp : public wxAppBase { + DECLARE_DYNAMIC_CLASS(wxApp) + public: wxApp(); virtual ~wxApp(); @@ -32,6 +35,7 @@ public: virtual bool Initialize(int& argc, wxChar **argv); virtual void CleanUp(); + virtual bool Yield(bool onlyIfNeeded = false); virtual void WakeUpIdle(); virtual void SetPrintMode(int mode) { m_printMode = mode; } @@ -46,40 +50,20 @@ public: virtual bool OnExceptionInMainLoop(); #endif // wxUSE_EXCEPTIONS - // MSW-specific from now on - // ------------------------ - - // this suffix should be appended to all our Win32 class names to obtain a - // variant registered without CS_[HV]REDRAW styles - static const wxChar *GetNoRedrawClassSuffix() { return wxT("NR"); } - - // get the name of the registered Win32 class with the given (unique) base - // name: this function constructs the unique class name using this name as - // prefix, checks if the class is already registered and registers it if it - // isn't and returns the name it was registered under (or NULL if it failed) - // - // the registered class will always have CS_[HV]REDRAW and CS_DBLCLKS - // styles as well as any additional styles specified as arguments here; and - // there will be also a companion registered class identical to this one - // but without CS_[HV]REDRAW whose name will be the same one but with - // GetNoRedrawClassSuffix() - // - // the background brush argument must be either a COLOR_XXX standard value - // or (default) -1 meaning that the class paints its background itself - static const wxChar *GetRegisteredClassName(const wxChar *name, - int bgBrushCol = -1, - int extraStyles = 0); - - // return true if this name corresponds to one of the classes we registered - // in the previous GetRegisteredClassName() calls - static bool IsRegisteredClassName(const wxString& name); + // deprecated functions, use wxEventLoop directly instead +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( void DoMessage(WXMSG *pMsg) ); + wxDEPRECATED( bool DoMessage() ); + wxDEPRECATED( bool ProcessMessage(WXMSG* pMsg) ); +#endif // WXWIN_COMPATIBILITY_2_4 protected: int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT public: - // unregister any window classes registered by GetRegisteredClassName() - static void UnregisterWindowClasses(); + // Implementation + static bool RegisterWindowClasses(); + static bool UnregisterWindowClasses(); #if wxUSE_RICHEDIT // initialize the richedit DLL of (at least) given version, return true if @@ -91,39 +75,73 @@ public: // wasn't found at all static int GetComCtl32Version(); - // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not - // currently detected) - static int GetShell32Version(); - // the SW_XXX value to be used for the frames opened by the application // (currently seems unused which is a bug -- TODO) static int m_nCmdShow; protected: DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxApp); - DECLARE_DYNAMIC_CLASS(wxApp) + DECLARE_NO_COPY_CLASS(wxApp) }; +// ---------------------------------------------------------------------------- +// MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition +// ---------------------------------------------------------------------------- + +// we need HINSTANCE declaration to define WinMain() +#include "wx/msw/wrapwin.h" + +#ifndef SW_SHOWNORMAL + #define SW_SHOWNORMAL 1 +#endif + +// WinMain() is always ANSI, even in Unicode build, under normal Windows +// but is always Unicode under CE #ifdef __WXWINCE__ + typedef wchar_t *wxCmdLineArgType; +#else + typedef char *wxCmdLineArgType; +#endif -// under CE provide a dummy implementation of GetComCtl32Version() returning -// the value passing all ">= 470" tests (which are the only ones used in our -// code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll -// functionality -inline int wxApp::GetComCtl32Version() -{ - return 471; -} +extern int WXDLLEXPORT +wxEntry(HINSTANCE hInstance, + HINSTANCE hPrevInstance = NULL, + wxCmdLineArgType pCmdLine = NULL, + int nCmdShow = SW_SHOWNORMAL); -// this is not currently used at all under CE so it's not really clear what do -// we need to return from here -inline int wxApp::GetShell32Version() -{ - return 0; -} +#if defined(__BORLANDC__) && wxUSE_UNICODE + // Borland C++ has the following nonstandard behaviour: when the -WU + // command line flag is used, the linker expects to find wWinMain instead + // of WinMain. This flag causes the compiler to define _UNICODE and + // UNICODE symbols and there's no way to detect its use, so we have to + // define both WinMain and wWinMain so that IMPLEMENT_WXWIN_MAIN works + // for both code compiled with and without -WU. + // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863 + // for more details. + #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \ + extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \ + HINSTANCE hPrevInstance, \ + wchar_t * WXUNUSED(lpCmdLine), \ + int nCmdShow) \ + { \ + /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \ + /* wchar_t*, but fortunately it's not used anywhere */ \ + /* and we can simply pass NULL in: */ \ + return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ + } +#else + #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD +#endif // defined(__BORLANDC__) && wxUSE_UNICODE -#endif // __WXWINCE__ +#define IMPLEMENT_WXWIN_MAIN \ + extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ + HINSTANCE hPrevInstance, \ + wxCmdLineArgType lpCmdLine, \ + int nCmdShow) \ + { \ + return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ + } \ + IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD #endif // _WX_APP_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/apptbase.h b/Source/3rd Party/wx/include/wx/msw/apptbase.h index 4dff054d3..efab1ed33 100644 --- a/Source/3rd Party/wx/include/wx/msw/apptbase.h +++ b/Source/3rd Party/wx/include/wx/msw/apptbase.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 22.06.2003 +// RCS-ID: $Id: apptbase.h 40599 2006-08-13 21:00:32Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -25,47 +26,20 @@ public: // some opaque data which will be passed later to AfterChildWaitLoop() virtual void *BeforeChildWaitLoop() = 0; + // process pending Windows messages, even in console app + virtual void AlwaysYield() = 0; + // called after starting to wait for the child termination, the parameter // is the return value of BeforeChildWaitLoop() virtual void AfterChildWaitLoop(void *data) = 0; -#if wxUSE_THREADS // wxThread helpers // ---------------- // process a message while waiting for a(nother) thread, should return // false if and only if we have to exit the application virtual bool DoMessageFromThreadWait() = 0; - - // wait for the handle to be signaled, return WAIT_OBJECT_0 if it is or, in - // the GUI code, WAIT_OBJECT_0 + 1 if a Windows message arrived - virtual WXDWORD WaitForThread(WXHANDLE hThread, int flags) = 0; -#endif // wxUSE_THREADS - - -#ifndef __WXWINCE__ - // console helpers - // --------------- - - // this method can be overridden by a derived class to always return true - // or false to force [not] using the console for output to stderr - // - // by default console applications always return true from here while the - // GUI ones only return true if they're being run from console and there is - // no other activity happening in this console - virtual bool CanUseStderr() = 0; - - // write text to the console, return true if ok or false on error - virtual bool WriteToStderr(const wxString& text) = 0; -#endif // !__WXWINCE__ - -protected: -#if wxUSE_THREADS - // implementation of WaitForThread() for the console applications which is - // also used by the GUI code if it doesn't [yet|already] dispatch events - WXDWORD DoSimpleWaitForThread(WXHANDLE hThread); -#endif // wxUSE_THREADS }; #endif // _WX_MSW_APPTBASE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/apptrait.h b/Source/3rd Party/wx/include/wx/msw/apptrait.h index 6089cd3fb..6b094ce29 100644 --- a/Source/3rd Party/wx/include/wx/msw/apptrait.h +++ b/Source/3rd Party/wx/include/wx/msw/apptrait.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 21.06.2003 +// RCS-ID: $Id: apptrait.h 40599 2006-08-13 21:00:32Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -18,79 +19,27 @@ class WXDLLIMPEXP_BASE wxConsoleAppTraits : public wxConsoleAppTraitsBase { public: - virtual wxEventLoopBase *CreateEventLoop(); virtual void *BeforeChildWaitLoop(); + virtual void AlwaysYield(); virtual void AfterChildWaitLoop(void *data); -#if wxUSE_TIMER - virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer); -#endif // wxUSE_TIMER -#if wxUSE_THREADS + virtual bool DoMessageFromThreadWait(); - virtual WXDWORD WaitForThread(WXHANDLE hThread, int flags); -#endif // wxUSE_THREADS -#ifndef __WXWINCE__ - virtual bool CanUseStderr() { return true; } - virtual bool WriteToStderr(const wxString& text); -#endif // !__WXWINCE__ }; #if wxUSE_GUI -#if defined(__WXMSW__) - class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase { public: - virtual wxEventLoopBase *CreateEventLoop(); virtual void *BeforeChildWaitLoop(); + virtual void AlwaysYield(); virtual void AfterChildWaitLoop(void *data); -#if wxUSE_TIMER - virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer); -#endif // wxUSE_TIMER -#if wxUSE_THREADS + virtual bool DoMessageFromThreadWait(); - virtual WXDWORD WaitForThread(WXHANDLE hThread, int flags); -#endif // wxUSE_THREADS - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const; - -#ifndef __WXWINCE__ - virtual bool CanUseStderr(); - virtual bool WriteToStderr(const wxString& text); -#endif // !__WXWINCE__ + virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const; }; -#elif defined(__WXGTK__) - -class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase -{ -public: - virtual wxEventLoopBase *CreateEventLoop(); - virtual void *BeforeChildWaitLoop() { return NULL; } - virtual void AfterChildWaitLoop(void *WXUNUSED(data)) { } -#if wxUSE_TIMER - virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer); -#endif - -#if wxUSE_THREADS && defined(__WXGTK20__) - virtual void MutexGuiEnter(); - virtual void MutexGuiLeave(); -#endif - -#if wxUSE_THREADS - virtual bool DoMessageFromThreadWait() { return true; } - virtual WXDWORD WaitForThread(WXHANDLE hThread, int WXUNUSED(flags)) - { return DoSimpleWaitForThread(hThread); } -#endif // wxUSE_THREADS - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const; - -#ifndef __WXWINCE__ - virtual bool CanUseStderr() { return false; } - virtual bool WriteToStderr(const wxString& WXUNUSED(text)) { return false; } -#endif // !__WXWINCE__ -}; - -#endif - #endif // wxUSE_GUI #endif // _WX_MSW_APPTRAIT_H_ + diff --git a/Source/3rd Party/wx/include/wx/msw/bitmap.h b/Source/3rd Party/wx/include/wx/msw/bitmap.h index 8cd49b0fc..4e71852a5 100644 --- a/Source/3rd Party/wx/include/wx/msw/bitmap.h +++ b/Source/3rd Party/wx/include/wx/msw/bitmap.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: bitmap.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,6 @@ #define _WX_BITMAP_H_ #include "wx/msw/gdiimage.h" -#include "wx/math.h" #include "wx/palette.h" class WXDLLIMPEXP_FWD_CORE wxBitmap; @@ -25,26 +25,16 @@ class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxDIB; #endif class WXDLLIMPEXP_FWD_CORE wxIcon; +class WXDLLIMPEXP_FWD_CORE wxImage; class WXDLLIMPEXP_FWD_CORE wxMask; class WXDLLIMPEXP_FWD_CORE wxPalette; class WXDLLIMPEXP_FWD_CORE wxPixelDataBase; -// What kind of transparency should a bitmap copied from an icon or cursor -// have? -enum wxBitmapTransparency -{ - wxBitmapTransparency_Auto, // default: copy alpha if the source has it - wxBitmapTransparency_None, // never create alpha - wxBitmapTransparency_Always // always use alpha -}; - // ---------------------------------------------------------------------------- // wxBitmap: a mono or colour bitmap -// NOTE: for wxMSW we don't use the wxBitmapBase base class declared in bitmap.h! // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmap : public wxGDIImage, - public wxBitmapHelpers +class WXDLLEXPORT wxBitmap : public wxGDIImage { public: // default ctor creates an invalid bitmap, you must Create() it later @@ -58,23 +48,22 @@ public: #ifdef wxNEEDS_CHARPP wxBitmap(char** data) { - *this = wxBitmap(const_cast(data)); + *this = wxBitmap(wx_const_cast(const char* const*, data)); } #endif // Load a file or resource - wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); + wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); // New constructor for generalised creation from data - wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1); + wxBitmap(const void* data, long type, int width, int height, int depth = 1); // Create a new, uninitialized bitmap of the given size and depth (if it // is omitted, will create a bitmap compatible with the display) // // NB: this ctor will create a DIB for 24 and 32bpp bitmaps, use ctor // taking a DC argument if you want to force using DDB in this case - wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); } - wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); } + wxBitmap(int width, int height, int depth = -1); // Create a bitmap compatible with the given DC wxBitmap(int width, int height, const wxDC& dc); @@ -91,11 +80,7 @@ public: // we must have this, otherwise icons are silently copied into bitmaps using // the copy ctor but the resulting bitmap is invalid! - wxBitmap(const wxIcon& icon, - wxBitmapTransparency transp = wxBitmapTransparency_Auto) - { - CopyFromIcon(icon, transp); - } + wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); } wxBitmap& operator=(const wxIcon& icon) { @@ -115,42 +100,31 @@ public: #if wxUSE_IMAGE wxImage ConvertToImage() const; - wxBitmap ConvertToDisabled(unsigned char brightness = 255) const; #endif // wxUSE_IMAGE // get the given part of bitmap wxBitmap GetSubBitmap( const wxRect& rect ) const; // NB: This should not be called from user code. It is for wx internal - // use only. + // use only. wxBitmap GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const; // copies the contents and mask of the given (colour) icon to the bitmap - bool CopyFromIcon(const wxIcon& icon, - wxBitmapTransparency transp = wxBitmapTransparency_Auto); + bool CopyFromIcon(const wxIcon& icon); // copies the contents and mask of the given cursor to the bitmap - bool CopyFromCursor(const wxCursor& cursor, - wxBitmapTransparency transp = wxBitmapTransparency_Auto); + bool CopyFromCursor(const wxCursor& cursor); #if wxUSE_WXDIB // copies from a device independent bitmap bool CopyFromDIB(const wxDIB& dib); - bool IsDIB() const; - bool ConvertToDIB(); #endif - virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); - virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) - { return Create(sz.GetWidth(), sz.GetHeight(), depth); } - + virtual bool Create(int width, int height, int depth = -1); virtual bool Create(int width, int height, const wxDC& dc); - virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); - virtual bool CreateScaled(int w, int h, int d, double logicalScale) - { return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); } - - virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); - virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; + virtual bool Create(const void* data, long type, int width, int height, int depth = 1); + virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); + virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); wxBitmapRefData *GetBitmapData() const { return (wxBitmapRefData *)m_refData; } @@ -165,38 +139,36 @@ public: #endif // wxUSE_PALETTE wxMask *GetMask() const; + wxBitmap GetMaskBitmap() const; void SetMask(wxMask *mask); // these functions are internal and shouldn't be used, they risk to // disappear in the future bool HasAlpha() const; void UseAlpha(); - void ResetAlpha(); - // support for scaled bitmaps - virtual double GetScaleFactor() const { return 1.0; } - virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); } - virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); } - virtual wxSize GetScaledSize() const - { return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); } +#if WXWIN_COMPATIBILITY_2_4 + // these functions do nothing and are only there for backwards + // compatibility + wxDEPRECATED( int GetQuality() const ); + wxDEPRECATED( void SetQuality(int quality) ); +#endif // WXWIN_COMPATIBILITY_2_4 // implementation only from now on // ------------------------------- - // Set alpha flag to true if this is a 32bpp bitmap which has any non-0 - // values in its alpha channel. - void MSWUpdateAlpha(); - public: void SetHBITMAP(WXHBITMAP bmp) { SetHandle((WXHANDLE)bmp); } WXHBITMAP GetHBITMAP() const { return (WXHBITMAP)GetHandle(); } +#ifdef __WXDEBUG__ void SetSelectedInto(wxDC *dc); wxDC *GetSelectedInto() const; +#endif // __WXDEBUG__ protected: virtual wxGDIImageRefData *CreateData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; // creates an uninitialized bitmap, called from Create()s above bool DoCreate(int w, int h, int depth, WXHDC hdc); @@ -214,9 +186,7 @@ protected: private: // common part of CopyFromIcon/CopyFromCursor for Win32 - bool - CopyFromIconOrCursor(const wxGDIImage& icon, - wxBitmapTransparency transp = wxBitmapTransparency_Auto); + bool CopyFromIconOrCursor(const wxGDIImage& icon); DECLARE_DYNAMIC_CLASS(wxBitmap) @@ -226,7 +196,7 @@ private: // wxMask: a mono bitmap used for drawing bitmaps transparently. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMask : public wxObject +class WXDLLEXPORT wxMask : public wxObject { public: wxMask(); @@ -254,8 +224,6 @@ public: bool Create(const wxBitmap& bitmap, int paletteIndex); bool Create(const wxBitmap& bitmap); - wxBitmap GetBitmap() const; - // Implementation WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; } void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; } @@ -266,49 +234,45 @@ protected: DECLARE_DYNAMIC_CLASS(wxMask) }; - // ---------------------------------------------------------------------------- // wxBitmapHandler is a class which knows how to load/save bitmaps to/from file -// NOTE: for wxMSW we don't use the wxBitmapHandler class declared in bitmap.h! // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapHandler : public wxGDIImageHandler +class WXDLLEXPORT wxBitmapHandler : public wxGDIImageHandler { public: wxBitmapHandler() { } - wxBitmapHandler(const wxString& name, const wxString& ext, wxBitmapType type) - : wxGDIImageHandler(name, ext, type) { } - - // implement wxGDIImageHandler's pure virtuals: - - virtual bool Create(wxGDIImage *image, - const void* data, - wxBitmapType type, - int width, int height, int depth = 1); - virtual bool Load(wxGDIImage *image, - const wxString& name, - wxBitmapType type, - int desiredWidth, int desiredHeight); - virtual bool Save(const wxGDIImage *image, - const wxString& name, - wxBitmapType type) const; - - - // make wxBitmapHandler compatible with the wxBitmapHandler interface - // declared in bitmap.h, even if it's derived from wxGDIImageHandler: + wxBitmapHandler(const wxString& name, const wxString& ext, long type) + : wxGDIImageHandler(name, ext, type) + { + } + // keep wxBitmapHandler derived from wxGDIImageHandler compatible with the + // old class which worked only with bitmaps virtual bool Create(wxBitmap *bitmap, const void* data, - wxBitmapType type, + long flags, int width, int height, int depth = 1); virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, - wxBitmapType type, + long flags, int desiredWidth, int desiredHeight); - virtual bool SaveFile(const wxBitmap *bitmap, + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, - wxBitmapType type, - const wxPalette *palette = NULL) const; + int type, + const wxPalette *palette = NULL); + + virtual bool Create(wxGDIImage *image, + const void* data, + long flags, + int width, int height, int depth = 1); + virtual bool Load(wxGDIImage *image, + const wxString& name, + long flags, + int desiredWidth, int desiredHeight); + virtual bool Save(wxGDIImage *image, + const wxString& name, + int type); private: DECLARE_DYNAMIC_CLASS(wxBitmapHandler) diff --git a/Source/3rd Party/wx/include/wx/msw/bmpbuttn.h b/Source/3rd Party/wx/include/wx/msw/bmpbuttn.h index d5e6c422f..a9173613b 100644 --- a/Source/3rd Party/wx/include/wx/msw/bmpbuttn.h +++ b/Source/3rd Party/wx/include/wx/msw/bmpbuttn.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: bmpbuttn.h 36078 2005-11-03 19:38:20Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,10 +16,10 @@ #include "wx/bitmap.h" #include "wx/brush.h" -class WXDLLIMPEXP_CORE wxBitmapButton : public wxBitmapButtonBase +class WXDLLEXPORT wxBitmapButton : public wxBitmapButtonBase { public: - wxBitmapButton() {} + wxBitmapButton() { } wxBitmapButton(wxWindow *parent, wxWindowID id, @@ -41,7 +42,30 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxButtonNameStr); + // Implementation + virtual bool SetBackgroundColour(const wxColour& colour); + virtual void SetDefault(); + virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); + virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel ); + virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ); + virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ); + protected: + // reimplement some base class virtuals + virtual wxSize DoGetBestSize() const; + virtual void OnSetBitmap(); + + // invalidate m_brushDisabled when system colours change + void OnSysColourChanged(wxSysColourChangedEvent& event); + + // change the currently bitmap if we have a hover one + void OnMouseEnterOrLeave(wxMouseEvent& event); + + + // the brush we use to draw disabled buttons + wxBrush m_brushDisabled; + + DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton) }; diff --git a/Source/3rd Party/wx/include/wx/msw/bmpcbox.h b/Source/3rd Party/wx/include/wx/msw/bmpcbox.h deleted file mode 100644 index 0462c4621..000000000 --- a/Source/3rd Party/wx/include/wx/msw/bmpcbox.h +++ /dev/null @@ -1,135 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/bmpcbox.h -// Purpose: wxBitmapComboBox -// Author: Jaakko Salli -// Created: 2008-04-06 -// Copyright: (c) 2008 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_BMPCBOX_H_ -#define _WX_MSW_BMPCBOX_H_ - - -#include "wx/combobox.h" - - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox: a wxComboBox that allows images to be shown -// in front of string items. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxComboBox, - public wxBitmapComboBoxBase -{ -public: - // ctors and such - wxBitmapComboBox() : wxComboBox(), wxBitmapComboBoxBase() - { - Init(); - } - - wxBitmapComboBox(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr) - : wxComboBox(), - wxBitmapComboBoxBase() - { - Init(); - - (void)Create(parent, id, value, pos, size, n, - choices, style, validator, name); - } - - wxBitmapComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapComboBoxNameStr); - - virtual ~wxBitmapComboBox(); - - // Sets the image for the given item. - virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap); - - virtual bool SetFont(const wxFont& font); - - // Adds item with image to the end of the combo box. - int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap); - int Append(const wxString& item, const wxBitmap& bitmap, void *clientData); - int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData); - - // Inserts item with image into the list before pos. Not valid for wxCB_SORT - // styles, use Append instead. - int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos); - int Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, void *clientData); - int Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, wxClientData *clientData); - -protected: - - WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); - virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); - - // Event handlers - void OnSize(wxSizeEvent& event); - - virtual wxItemContainer* GetItemContainer() { return this; } - virtual wxWindow* GetControl() { return this; } - - // wxItemContainer implementation - virtual int DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type); - virtual void DoClear(); - virtual void DoDeleteOneItem(unsigned int n); - - virtual bool OnAddBitmap(const wxBitmap& bitmap); - virtual wxSize DoGetBestSize() const; - void RecreateControl(); - -private: - void Init(); - - bool m_inResize; - - DECLARE_EVENT_TABLE() - - DECLARE_DYNAMIC_CLASS(wxBitmapComboBox) -}; - -#endif // _WX_MSW_BMPCBOX_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/brush.h b/Source/3rd Party/wx/include/wx/msw/brush.h index 1cccb07ce..37de6d77d 100644 --- a/Source/3rd Party/wx/include/wx/msw/brush.h +++ b/Source/3rd Party/wx/include/wx/msw/brush.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: brush.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,51 +12,49 @@ #ifndef _WX_BRUSH_H_ #define _WX_BRUSH_H_ +#include "wx/gdicmn.h" +#include "wx/gdiobj.h" +#include "wx/bitmap.h" + class WXDLLIMPEXP_FWD_CORE wxBrush; -class WXDLLIMPEXP_FWD_CORE wxColour; -class WXDLLIMPEXP_FWD_CORE wxBitmap; // ---------------------------------------------------------------------------- // wxBrush // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBrush : public wxBrushBase +class WXDLLEXPORT wxBrush : public wxBrushBase { public: wxBrush(); - wxBrush(const wxColour& col, wxBrushStyle style = wxBRUSHSTYLE_SOLID); -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxDEPRECATED_FUTURE( wxBrush(const wxColour& col, int style) ); -#endif + wxBrush(const wxColour& col, int style = wxSOLID); wxBrush(const wxBitmap& stipple); virtual ~wxBrush(); virtual void SetColour(const wxColour& col); virtual void SetColour(unsigned char r, unsigned char g, unsigned char b); - virtual void SetStyle(wxBrushStyle style); + virtual void SetStyle(int style); virtual void SetStipple(const wxBitmap& stipple); bool operator==(const wxBrush& brush) const; bool operator!=(const wxBrush& brush) const { return !(*this == brush); } wxColour GetColour() const; - wxBrushStyle GetStyle() const; + virtual int GetStyle() const; wxBitmap *GetStipple() const; -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxDEPRECATED_FUTURE( void SetStyle(int style) ) - { SetStyle((wxBrushStyle)style); } -#endif + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_refData != NULL; } // return the HBRUSH for this brush virtual WXHANDLE GetResourceHandle() const; protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; + virtual wxObjectRefData *CreateRefData() const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; private: DECLARE_DYNAMIC_CLASS(wxBrush) }; -#endif // _WX_BRUSH_H_ +#endif + // _WX_BRUSH_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/button.h b/Source/3rd Party/wx/include/wx/msw/button.h index 666f1916c..e36e44ff6 100644 --- a/Source/3rd Party/wx/include/wx/msw/button.h +++ b/Source/3rd Party/wx/include/wx/msw/button.h @@ -4,21 +4,22 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: button.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_BUTTON_H_ -#define _WX_MSW_BUTTON_H_ +#ifndef _WX_BUTTON_H_ +#define _WX_BUTTON_H_ // ---------------------------------------------------------------------------- // Pushbutton // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxButton : public wxButtonBase +class WXDLLEXPORT wxButton : public wxButtonBase { public: - wxButton() { Init(); } + wxButton() { } wxButton(wxWindow *parent, wxWindowID id, const wxString& label = wxEmptyString, @@ -28,8 +29,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxButtonNameStr) { - Init(); - Create(parent, id, label, pos, size, style, validator, name); } @@ -44,15 +43,23 @@ public: virtual ~wxButton(); - virtual wxWindow *SetDefault(); + virtual void SetDefault(); // implementation from now on virtual void Command(wxCommandEvent& event); virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual bool MSWCommand(WXUINT param, WXWORD id); + // coloured buttons support + virtual bool SetBackgroundColour(const wxColour &colour); + virtual bool SetForegroundColour(const wxColour &colour); + + virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; +private: + void MakeOwnerDrawn(); + protected: // send a notification event, return true if processed bool SendClickEvent(); @@ -64,22 +71,12 @@ protected: // set or unset BS_DEFPUSHBUTTON style static void SetDefaultStyle(wxButton *btn, bool on); - virtual bool DoGetAuthNeeded() const; - virtual void DoSetAuthNeeded(bool show); - - // true if the UAC symbol is shown - bool m_authNeeded; + // usually overridden base class virtuals + virtual wxSize DoGetBestSize() const; private: - void Init() - { - m_authNeeded = false; - } - - void OnCharHook(wxKeyEvent& event); - - wxDECLARE_EVENT_TABLE(); - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxButton); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxButton) }; -#endif // _WX_MSW_BUTTON_H_ +#endif + // _WX_BUTTON_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/calctrl.h b/Source/3rd Party/wx/include/wx/msw/calctrl.h deleted file mode 100644 index c5c51d9fd..000000000 --- a/Source/3rd Party/wx/include/wx/msw/calctrl.h +++ /dev/null @@ -1,98 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/calctrl.h -// Purpose: wxCalendarCtrl control implementation for MSW -// Author: Vadim Zeitlin -// Copyright: (C) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_CALCTRL_H_ -#define _WX_MSW_CALCTRL_H_ - -class WXDLLIMPEXP_ADV wxCalendarCtrl : public wxCalendarCtrlBase -{ -public: - wxCalendarCtrl() { Init(); } - wxCalendarCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS, - const wxString& name = wxCalendarNameStr) - { - Init(); - - Create(parent, id, date, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS, - const wxString& name = wxCalendarNameStr); - - virtual bool SetDate(const wxDateTime& date); - virtual wxDateTime GetDate() const; - - virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, - const wxDateTime& upperdate = wxDefaultDateTime); - virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const; - - virtual bool EnableMonthChange(bool enable = true); - - virtual void Mark(size_t day, bool mark); - virtual void SetHoliday(size_t day); - - virtual wxCalendarHitTestResult HitTest(const wxPoint& pos, - wxDateTime *date = NULL, - wxDateTime::WeekDay *wd = NULL); - - virtual void SetWindowStyleFlag(long style); - -protected: - virtual wxSize DoGetBestSize() const; - - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - - void MSWOnClick(wxMouseEvent& event); - void MSWOnDoubleClick(wxMouseEvent& event); - -private: - void Init(); - - // bring the control in sync with m_marks - void UpdateMarks(); - - // set first day of week in the control to correspond to our - // wxCAL_MONDAY_FIRST flag - void UpdateFirstDayOfWeek(); - - // reset holiday information - virtual void ResetHolidayAttrs() { m_holidays = 0; } - - // redisplay holidays - virtual void RefreshHolidays() { UpdateMarks(); } - - - // current date, we need to store it instead of simply retrieving it from - // the control as needed in order to be able to generate the correct events - // from MSWOnNotify() - wxDateTime m_date; - - // bit field containing the state (marked or not) of all days in the month - wxUint32 m_marks; - - // the same but indicating whether a day is a holiday or not - wxUint32 m_holidays; - - - DECLARE_DYNAMIC_CLASS(wxCalendarCtrl) - wxDECLARE_NO_COPY_CLASS(wxCalendarCtrl); -}; - -#endif // _WX_MSW_CALCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/caret.h b/Source/3rd Party/wx/include/wx/msw/caret.h index 89a8fe2e8..90b0d29cc 100644 --- a/Source/3rd Party/wx/include/wx/msw/caret.h +++ b/Source/3rd Party/wx/include/wx/msw/caret.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/caret.h +// Name: msw/caret.h // Purpose: wxCaret class - the MSW implementation of wxCaret // Author: Vadim Zeitlin // Modified by: // Created: 23.05.99 +// RCS-ID: $Id: caret.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_CARET_H_ #define _WX_CARET_H_ -class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase +class WXDLLEXPORT wxCaret : public wxCaretBase { public: wxCaret() { Init(); } @@ -55,7 +56,7 @@ protected: private: bool m_hasCaret; - wxDECLARE_NO_COPY_CLASS(wxCaret); + DECLARE_NO_COPY_CLASS(wxCaret) }; #endif // _WX_CARET_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/checkbox.h b/Source/3rd Party/wx/include/wx/msw/checkbox.h index ceaf2e91d..6f5605571 100644 --- a/Source/3rd Party/wx/include/wx/msw/checkbox.h +++ b/Source/3rd Party/wx/include/wx/msw/checkbox.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: checkbox.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ #define _WX_CHECKBOX_H_ // Checkbox item (single checkbox) -class WXDLLIMPEXP_CORE wxCheckBox : public wxCheckBoxBase +class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase { public: wxCheckBox() { } @@ -41,28 +42,20 @@ public: virtual bool GetValue() const; // override some base class virtuals - virtual void SetLabel(const wxString& label); - virtual bool MSWCommand(WXUINT param, WXWORD id); virtual void Command(wxCommandEvent& event); virtual bool SetForegroundColour(const wxColour& colour); virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - - // make the checkbox owner drawn or reset it to normal style - void MSWMakeOwnerDrawn(bool ownerDrawn); - - // implementation only from now on - virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; - protected: - virtual wxSize DoGetBestClientSize() const; + virtual wxSize DoGetBestSize() const; virtual void DoSet3StateValue(wxCheckBoxState value); virtual wxCheckBoxState DoGet3StateValue() const; + // make the checkbox owner drawn or reset it to normal style + void MakeOwnerDrawn(bool ownerDrawn); + // return true if this checkbox is owner drawn bool IsOwnerDrawn() const; diff --git a/Source/3rd Party/wx/include/wx/msw/checklst.h b/Source/3rd Party/wx/include/wx/msw/checklst.h index e4505e709..5f1272781 100644 --- a/Source/3rd Party/wx/include/wx/msw/checklst.h +++ b/Source/3rd Party/wx/include/wx/msw/checklst.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 16.11.97 +// RCS-ID: $Id: checklst.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -18,35 +19,35 @@ class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn; class WXDLLIMPEXP_FWD_CORE wxCheckListBoxItem; // fwd decl, defined in checklst.cpp -class WXDLLIMPEXP_CORE wxCheckListBox : public wxCheckListBoxBase +class WXDLLEXPORT wxCheckListBox : public wxCheckListBoxBase { public: - // ctors - wxCheckListBox(); - wxCheckListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int nStrings = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); - wxCheckListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); + // ctors + wxCheckListBox(); + wxCheckListBox(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int nStrings = 0, + const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr); + wxCheckListBox(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr); - bool Create(wxWindow *parent, wxWindowID id, + bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListBoxNameStr); - bool Create(wxWindow *parent, wxWindowID id, + bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const wxArrayString& choices, @@ -54,35 +55,42 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListBoxNameStr); - // items may be checked - virtual bool IsChecked(unsigned int uiIndex) const; - virtual void Check(unsigned int uiIndex, bool bCheck = true); - virtual void Toggle(unsigned int uiIndex); + // override base class virtuals + virtual void Delete(unsigned int n); - // we create our items ourselves and they have non-standard size, - // so we need to override these functions - virtual wxOwnerDrawn *CreateLboxItem(size_t n); - virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); + virtual bool SetFont( const wxFont &font ); + + // items may be checked + virtual bool IsChecked(unsigned int uiIndex) const; + virtual void Check(unsigned int uiIndex, bool bCheck = true); + + // return the index of the item at this position or wxNOT_FOUND + int HitTest(const wxPoint& pt) const { return DoHitTestItem(pt.x, pt.y); } + int HitTest(wxCoord x, wxCoord y) const { return DoHitTestItem(x, y); } + + // accessors + size_t GetItemHeight() const { return m_nItemHeight; } + + // we create our items ourselves and they have non-standard size, + // so we need to override these functions + virtual wxOwnerDrawn *CreateLboxItem(size_t n); + virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); protected: - // pressing space or clicking the check box toggles the item - void OnKeyDown(wxKeyEvent& event); - void OnLeftClick(wxMouseEvent& event); + // this can't be called DoHitTest() because wxWindow already has this method + int DoHitTestItem(wxCoord x, wxCoord y) const; - // send an "item checked" event - void SendEvent(unsigned int uiIndex) - { - wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId()); - event.SetInt(uiIndex); - event.SetEventObject(this); - event.SetString(GetString(uiIndex)); - ProcessCommand(event); - } + // pressing space or clicking the check box toggles the item + void OnKeyDown(wxKeyEvent& event); + void OnLeftClick(wxMouseEvent& event); - wxSize DoGetBestClientSize() const; + wxSize DoGetBestSize() const; - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox) +private: + size_t m_nItemHeight; // height of checklistbox items (the same for all) + + DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox) }; #endif //_CHECKLST_H diff --git a/Source/3rd Party/wx/include/wx/msw/chkconf.h b/Source/3rd Party/wx/include/wx/msw/chkconf.h index a476cd0e2..022ca20dd 100644 --- a/Source/3rd Party/wx/include/wx/msw/chkconf.h +++ b/Source/3rd Party/wx/include/wx/msw/chkconf.h @@ -4,6 +4,7 @@ * Author: Julian Smart * Modified by: * Created: 01/02/97 + * RCS-ID: $Id: chkconf.h 44436 2007-02-10 02:06:54Z RD $ * Copyright: (c) Julian Smart * Licence: wxWindows licence */ @@ -14,22 +15,6 @@ #define _WX_MSW_CHKCONF_H_ /* ensure that MSW-specific settings are defined */ -#ifndef wxUSE_ACTIVEX -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_ACTIVEX must be defined." -# else -# define wxUSE_ACTIVEX 0 -# endif -#endif /* !defined(wxUSE_ACTIVEX) */ - -#ifndef wxUSE_CRASHREPORT -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CRASHREPORT must be defined." -# else -# define wxUSE_CRASHREPORT 0 -# endif -#endif /* !defined(wxUSE_CRASHREPORT) */ - #ifndef wxUSE_DC_CACHEING # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_DC_CACHEING must be defined" @@ -38,69 +23,27 @@ # endif #endif /* wxUSE_DC_CACHEING */ -#ifndef wxUSE_DIALUP_MANAGER -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DIALUP_MANAGER must be defined." -# else -# define wxUSE_DIALUP_MANAGER 0 -# endif -#endif /* !defined(wxUSE_DIALUP_MANAGER) */ -#ifndef wxUSE_MS_HTML_HELP -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_MS_HTML_HELP must be defined." -# else -# define wxUSE_MS_HTML_HELP 0 -# endif -#endif /* !defined(wxUSE_MS_HTML_HELP) */ +/* + * disable the settings which don't work for some compilers + */ -#ifndef wxUSE_INICONF -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_INICONF must be defined." -# else -# define wxUSE_INICONF 0 -# endif -#endif /* !defined(wxUSE_INICONF) */ +/* + * If using PostScript-in-MSW in Univ, must enable PostScript + */ +#if defined(__WXUNIVERSAL__) && wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW && !wxUSE_POSTSCRIPT +# undef wxUSE_POSTSCRIPT +# define wxUSE_POSTSCRIPT 1 +#endif -#ifndef wxUSE_OLE -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_OLE must be defined." -# else -# define wxUSE_OLE 0 -# endif -#endif /* !defined(wxUSE_OLE) */ - -#ifndef wxUSE_OLE_AUTOMATION -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_OLE_AUTOMATION must be defined." -# else -# define wxUSE_OLE_AUTOMATION 0 -# endif -#endif /* !defined(wxUSE_OLE_AUTOMATION) */ - -#ifndef wxUSE_TASKBARICON_BALLOONS -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_TASKBARICON_BALLOONS must be defined." +#ifndef wxUSE_NORLANDER_HEADERS +# if ( wxCHECK_WATCOM_VERSION(1,0) || defined(__WINE__) ) || \ + ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) +# define wxUSE_NORLANDER_HEADERS 1 # else -# define wxUSE_TASKBARICON_BALLOONS 0 +# define wxUSE_NORLANDER_HEADERS 0 # endif -#endif /* wxUSE_TASKBARICON_BALLOONS */ - -#ifndef wxUSE_UNICODE_MSLU -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_UNICODE_MSLU must be defined." -# else -# define wxUSE_UNICODE_MSLU 0 -# endif -#endif /* wxUSE_UNICODE_MSLU */ - -#ifndef wxUSE_UXTHEME -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_UXTHEME must be defined." -# else -# define wxUSE_UXTHEME 0 -# endif -#endif /* wxUSE_UXTHEME */ +#endif /* * We don't want to give an error if wxUSE_UNICODE_MSLU is enabled but @@ -114,49 +57,13 @@ # define wxUSE_UNICODE_MSLU 0 #endif - /* - * Unfortunately we can't use compiler TLS support if the library can be used - * inside a dynamically loaded DLL under Windows XP, as this can result in hard - * to diagnose crashes due to the bugs in Windows TLS support, see #13116. - * - * So we disable it unless we can be certain that the code will never run under - * XP, as is the case if we're using a compiler which doesn't support XP such - * as MSVC 11+, unless it's used with the special "_xp" toolset, in which case - * _USING_V110_SDK71_ is defined. - * - * However defining wxUSE_COMPILER_TLS as 2 overrides this safety check, see - * the comments in wx/setup.h. - */ -#if wxUSE_COMPILER_TLS == 1 - #if !wxCHECK_VISUALC_VERSION(11) || defined(_USING_V110_SDK71_) - #undef wxUSE_COMPILER_TLS - #define wxUSE_COMPILER_TLS 0 - #endif -#endif - - -/* - * disable the settings which don't work for some compilers + * Don't use MSLU if compiling with Wine */ -#ifndef wxUSE_NORLANDER_HEADERS -# if ( wxCHECK_WATCOM_VERSION(1,0) || defined(__WINE__) ) || \ - ((defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))) -# define wxUSE_NORLANDER_HEADERS 1 -# else -# define wxUSE_NORLANDER_HEADERS 0 -# endif -#endif - -/* - * See WINVER definition in wx/msw/wrapwin.h for the explanation of this test - * logic. - */ -#if (defined(__VISUALC__) && (__VISUALC__ < 1300)) && \ - (!defined(WINVER) || WINVER < 0x0500) -# undef wxUSE_TASKBARICON_BALLOONS -# define wxUSE_TASKBARICON_BALLOONS 0 +#if wxUSE_UNICODE_MSLU && defined(__WINE__) +# undef wxUSE_UNICODE_MSLU +# define wxUSE_UNICODE_MSLU 0 #endif /* @@ -175,6 +82,12 @@ # define wxUSE_STACKWALKER 0 #endif /* compiler doesn't support SEH */ +/* wxUSE_DEBUG_NEW_ALWAYS doesn't work with CodeWarrior */ +#if defined(__MWERKS__) +# undef wxUSE_DEBUG_NEW_ALWAYS +# define wxUSE_DEBUG_NEW_ALWAYS 0 +#endif + #if defined(__GNUWIN32__) /* These don't work as expected for mingw32 and cygwin32 */ # undef wxUSE_MEMORY_TRACING @@ -238,6 +151,11 @@ */ #ifdef __WIN64__ # if wxUSE_STACKWALKER + /* this is not currently supported under Win64, volunteers needed to + make it work */ +# undef wxUSE_STACKWALKER +# define wxUSE_STACKWALKER 0 + # undef wxUSE_CRASHREPORT # define wxUSE_CRASHREPORT 0 # endif @@ -247,24 +165,18 @@ /* Compiler-specific checks. */ - -/* Borland */ -#ifdef __BORLANDC__ - -#if __BORLANDC__ < 0x500 +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) /* BC++ 4.0 can't compile JPEG library */ # undef wxUSE_LIBJPEG # define wxUSE_LIBJPEG 0 #endif /* wxUSE_DEBUG_NEW_ALWAYS = 1 not compatible with BC++ in DLL mode */ -#if defined(WXMAKINGDLL) || defined(WXUSINGDLL) +#if defined(__BORLANDC__) && (defined(WXMAKINGDLL) || defined(WXUSINGDLL)) # undef wxUSE_DEBUG_NEW_ALWAYS # define wxUSE_DEBUG_NEW_ALWAYS 0 #endif -#endif /* __BORLANDC__ */ - /* DMC++ doesn't have definitions for date picker control, so use generic control */ #ifdef __DMC__ @@ -277,34 +189,86 @@ #endif +/* check that MSW-specific options are defined too */ +#ifndef wxUSE_ACTIVEX +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_ACTIVEX must be defined." +# else +# define wxUSE_ACTIVEX 0 +# endif +#endif /* !defined(wxUSE_ACTIVEX) */ + +#ifndef wxUSE_DIALUP_MANAGER +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_DIALUP_MANAGER must be defined." +# else +# define wxUSE_DIALUP_MANAGER 0 +# endif +#endif /* !defined(wxUSE_DIALUP_MANAGER) */ + +#ifndef wxUSE_MS_HTML_HELP +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_MS_HTML_HELP must be defined." +# else +# define wxUSE_MS_HTML_HELP 0 +# endif +#endif /* !defined(wxUSE_MS_HTML_HELP) */ + +#ifndef wxUSE_OLE +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_OLE must be defined." +# else +# define wxUSE_OLE 0 +# endif +#endif /* !defined(wxUSE_OLE) */ + +#ifndef wxUSE_OLE_AUTOMATION +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_OLE_AUTOMATION must be defined." +# else +# define wxUSE_OLE_AUTOMATION 0 +# endif +#endif /* !defined(wxUSE_OLE_AUTOMATION) */ + +#ifndef wxUSE_UNICODE_MSLU +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_UNICODE_MSLU must be defined." +# else +# define wxUSE_UNICODE_MSLU 0 +# endif +#endif /* wxUSE_UNICODE_MSLU */ + +#ifndef wxUSE_UXTHEME +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_UXTHEME must be defined." +# else +# define wxUSE_UXTHEME 0 +# endif +#endif /* wxUSE_UXTHEME */ + +#ifndef wxUSE_UXTHEME_AUTO +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_UXTHEME_AUTO must be defined." +# else +# define wxUSE_UXTHEME_AUTO 0 +# endif +#endif /* wxUSE_UXTHEME_AUTO */ + /* un/redefine the options which we can't compile (after checking that they're defined */ #ifdef __WINE__ -# if wxUSE_ACTIVEX -# undef wxUSE_ACTIVEX -# define wxUSE_ACTIVEX 0 -# endif /* wxUSE_ACTIVEX */ - -# if wxUSE_UNICODE_MSLU -# undef wxUSE_UNICODE_MSLU -# define wxUSE_UNICODE_MSLU 0 -# endif /* wxUSE_UNICODE_MSLU */ -#endif /* __WINE__ */ + /* apparently it doesn't compile under Wine, remove it/when it does */ + #if wxUSE_ACTIVEX + #undef wxUSE_ACTIVEX + #define wxUSE_ACTIVEX 0 + #endif // wxUSE_ACTIVEX +#endif // __WINE__ /* check settings consistency for MSW-specific ones */ -#if wxUSE_CRASHREPORT && !wxUSE_ON_FATAL_EXCEPTION -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_CRASHREPORT requires wxUSE_ON_FATAL_EXCEPTION" -# else -# undef wxUSE_CRASHREPORT -# define wxUSE_CRASHREPORT 0 -# endif -#endif /* wxUSE_CRASHREPORT */ - #if !wxUSE_VARIANT # if wxUSE_ACTIVEX # ifdef wxABORT_ON_CONFIG_ERROR @@ -345,14 +309,6 @@ #endif /* !wxUSE_DYNAMIC_LOADER */ #if !wxUSE_DYNLIB_CLASS -# if wxUSE_DC_TRANSFORM_MATRIX -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DC_TRANSFORM_MATRIX requires wxUSE_DYNLIB_CLASS" -# else -# undef wxUSE_DC_TRANSFORM_MATRIX -# define wxUSE_DC_TRANSFORM_MATRIX 0 -# endif -# endif # if wxUSE_UXTHEME # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_UXTHEME requires wxUSE_DYNLIB_CLASS" @@ -417,42 +373,15 @@ # define wxUSE_MEDIACTRL 0 # endif # endif -# if wxUSE_WEB -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxWebView requires wxActiveXContainer under MSW" -# else -# undef wxUSE_WEB -# define wxUSE_WEB 0 -# endif -# endif #endif /* !wxUSE_ACTIVEX */ -#if !wxUSE_THREADS -# if wxUSE_FSWATCHER +#if defined(_MSC_VER) && _MSC_VER <= 1200 && wxUSE_GRAPHICS_CONTEXT # ifdef wxABORT_ON_CONFIG_ERROR -# error "wxFileSystemWatcher requires wxThread under MSW" +# error "wxGraphicsContext needs MSVC 7 or newer" # else -# undef wxUSE_FSWATCHER -# define wxUSE_FSWATCHER 0 +# undef wxUSE_GRAPHICS_CONTEXT +# define wxUSE_GRAPHICS_CONTEXT 0 # endif -# endif -#endif /* !wxUSE_THREADS */ - - -#if !wxUSE_OLE_AUTOMATION -# if wxUSE_WEB -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxWebView requires wxUSE_OLE_AUTOMATION under MSW" -# else -# undef wxUSE_WEB -# define wxUSE_WEB 0 -# endif -# endif -#endif /* !wxUSE_OLE_AUTOMATION */ - -#if defined(__WXUNIVERSAL__) && wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW && !wxUSE_POSTSCRIPT -# undef wxUSE_POSTSCRIPT -# define wxUSE_POSTSCRIPT 1 #endif #endif /* _WX_MSW_CHKCONF_H_ */ diff --git a/Source/3rd Party/wx/include/wx/msw/choice.h b/Source/3rd Party/wx/include/wx/msw/choice.h index 7027077ff..6dccdafa4 100644 --- a/Source/3rd Party/wx/include/wx/msw/choice.h +++ b/Source/3rd Party/wx/include/wx/msw/choice.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Vadim Zeitlin to derive from wxChoiceBase // Created: 01/02/97 +// RCS-ID: $Id: choice.h 51616 2008-02-09 15:22:15Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,13 +12,11 @@ #ifndef _WX_CHOICE_H_ #define _WX_CHOICE_H_ -struct tagCOMBOBOXINFO; - // ---------------------------------------------------------------------------- // Choice item // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase +class WXDLLEXPORT wxChoice : public wxChoiceBase { public: // ctors @@ -67,10 +66,11 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxChoiceNameStr); - virtual bool Show(bool show = true); - virtual void SetLabel(const wxString& label); + virtual void Delete(unsigned int n); + virtual void Clear(); + virtual unsigned int GetCount() const; virtual int GetSelection() const; virtual int GetCurrentSelection() const; @@ -80,14 +80,6 @@ public: virtual wxString GetString(unsigned int n) const; virtual void SetString(unsigned int n, const wxString& s); - virtual wxVisualAttributes GetDefaultAttributes() const - { - return GetClassDefaultAttributes(GetWindowVariant()); - } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - // MSW only virtual bool MSWCommand(WXUINT param, WXWORD id); WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); @@ -95,31 +87,17 @@ public: virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg); virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - // common part of all ctors - void Init() - { - m_lastAcceptedSelection = - m_pendingSelection = wxID_NONE; - m_heightOwn = wxDefaultCoord; - } - - virtual void DoDeleteOneItem(unsigned int n); - virtual void DoClear(); - - virtual int DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, wxClientDataType type); + void Init() { m_lastAcceptedSelection = wxID_NONE; } + virtual int DoAppend(const wxString& item); + virtual int DoInsert(const wxString& item, unsigned int pos); virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoSetItemClientData(unsigned int n, void* clientData); virtual void* DoGetItemClientData(unsigned int n) const; + virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); + virtual wxClientData* DoGetItemClientObject(unsigned int n) const; // MSW implementation virtual wxSize DoGetBestSize() const; @@ -127,21 +105,10 @@ protected: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; - - // Show or hide the popup part of the control. - void MSWDoPopupOrDismiss(bool show); // update the height of the drop down list to fit the number of items we // have (without changing the visible height) - void MSWUpdateDropDownHeight(); - - // set the height of the visible part of the control to m_heightOwn - void MSWUpdateVisibleHeight(); - - // Call GetComboBoxInfo() and return false if it's not supported by this - // system. Notice that the caller must initialize info.cbSize. - bool MSWGetComboBoxInfo(tagCOMBOBOXINFO* info) const; + void UpdateVisibleHeight(); // create and initialize the control bool CreateAndInit(wxWindow *parent, wxWindowID id, @@ -155,24 +122,12 @@ protected: // free all memory we have (used by Clear() and dtor) void Free(); - // set the height for simple combo box - int SetHeightSimpleComboBox(int nItems) const; -#if wxUSE_DEFERRED_SIZING - virtual void MSWEndDeferWindowPos(); -#endif // wxUSE_DEFERRED_SIZING + // last "completed" selection, i.e. not the transient one while the user is + // browsing the popup list: this is only used when != wxID_NONE which is + // the case while the drop down is opened + int m_lastAcceptedSelection; - // These variables are only used while the drop down is opened. - // - // The first one contains the item that had been originally selected before - // the drop down was opened and the second one the item we should select - // when the drop down is closed again. - int m_lastAcceptedSelection, - m_pendingSelection; - - // the height of the control itself if it was set explicitly or - // wxDefaultCoord if it hadn't - int m_heightOwn; DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice) }; diff --git a/Source/3rd Party/wx/include/wx/msw/clipbrd.h b/Source/3rd Party/wx/include/wx/msw/clipbrd.h index aafeb31ef..a8cf81c3c 100644 --- a/Source/3rd Party/wx/include/wx/msw/clipbrd.h +++ b/Source/3rd Party/wx/include/wx/msw/clipbrd.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: clipbrd.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,28 +14,32 @@ #if wxUSE_CLIPBOARD +#include "wx/list.h" +#include "wx/module.h" +#include "wx/dataobj.h" // for wxDataFormat + // These functions superceded by wxClipboard, but retained in order to // implement wxClipboard, and for compatibility. // open/close the clipboard -WXDLLIMPEXP_CORE bool wxOpenClipboard(); -WXDLLIMPEXP_CORE bool wxIsClipboardOpened(); +WXDLLEXPORT bool wxOpenClipboard(); +WXDLLEXPORT bool wxIsClipboardOpened(); #define wxClipboardOpen wxIsClipboardOpened -WXDLLIMPEXP_CORE bool wxCloseClipboard(); +WXDLLEXPORT bool wxCloseClipboard(); // get/set data -WXDLLIMPEXP_CORE bool wxEmptyClipboard(); -WXDLLIMPEXP_CORE bool wxSetClipboardData(wxDataFormat dataFormat, +WXDLLEXPORT bool wxEmptyClipboard(); +WXDLLEXPORT bool wxSetClipboardData(wxDataFormat dataFormat, const void *data, int width = 0, int height = 0); -WXDLLIMPEXP_CORE void* wxGetClipboardData(wxDataFormat dataFormat, +WXDLLEXPORT void* wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL); // clipboard formats -WXDLLIMPEXP_CORE bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat); -WXDLLIMPEXP_CORE wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat); -WXDLLIMPEXP_CORE int wxRegisterClipboardFormat(wxChar *formatName); -WXDLLIMPEXP_CORE bool wxGetClipboardFormatName(wxDataFormat dataFormat, +WXDLLEXPORT bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat); +WXDLLEXPORT wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat); +WXDLLEXPORT int wxRegisterClipboardFormat(wxChar *formatName); +WXDLLEXPORT bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int maxCount); @@ -42,8 +47,11 @@ WXDLLIMPEXP_CORE bool wxGetClipboardFormatName(wxDataFormat dataFormat, // wxClipboard //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxClipboard : public wxClipboardBase +class WXDLLIMPEXP_FWD_CORE wxDataObject; +class WXDLLEXPORT wxClipboard : public wxClipboardBase { + DECLARE_DYNAMIC_CLASS(wxClipboard) + public: wxClipboard(); virtual ~wxClipboard(); @@ -77,13 +85,14 @@ public: // eating memory), otherwise the clipboard will be emptied on exit virtual bool Flush(); + // X11 has two clipboards which get selected by this call. Empty on MSW. + void UsePrimarySelection( bool WXUNUSED(primary) = false ) { } + private: IDataObject *m_lastDataObject; bool m_isOpened; - - DECLARE_DYNAMIC_CLASS(wxClipboard) }; #endif // wxUSE_CLIPBOARD - -#endif // _WX_CLIPBRD_H_ +#endif + // _WX_CLIPBRD_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/colordlg.h b/Source/3rd Party/wx/include/wx/msw/colordlg.h index a76eb4b43..fa0913473 100644 --- a/Source/3rd Party/wx/include/wx/msw/colordlg.h +++ b/Source/3rd Party/wx/include/wx/msw/colordlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: colordlg.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,22 +12,19 @@ #ifndef _WX_COLORDLG_H_ #define _WX_COLORDLG_H_ +#include "wx/defs.h" #include "wx/dialog.h" +#include "wx/cmndata.h" // ---------------------------------------------------------------------------- // wxColourDialog: dialog for choosing a colours // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxColourDialog : public wxDialog +class WXDLLEXPORT wxColourDialog : public wxDialog { public: - wxColourDialog() { Init(); } - wxColourDialog(wxWindow *parent, wxColourData *data = NULL) - { - Init(); - - Create(parent, data); - } + wxColourDialog(); + wxColourDialog(wxWindow *parent, wxColourData *data = NULL); bool Create(wxWindow *parent, wxColourData *data = NULL); @@ -38,36 +36,21 @@ public: virtual int ShowModal(); - // wxMSW-specific implementation from now on - // ----------------------------------------- - - // called from the hook procedure on WM_INITDIALOG reception - virtual void MSWOnInitDone(WXHWND hDlg); - protected: - // common part of all ctors - void Init(); - -#if !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize(int *width, int *height) const; virtual void DoGetClientSize(int *width, int *height) const; - virtual void DoMoveWindow(int x, int y, int width, int height); - virtual void DoCentre(int dir); -#endif // !(__SMARTPHONE__ && __WXWINCE__) + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); wxColourData m_colourData; wxString m_title; - // indicates that the dialog should be centered in this direction if non 0 - // (set by DoCentre(), used by MSWOnInitDone()) - int m_centreDir; - - // true if DoMoveWindow() had been called - bool m_movedWindow; - + wxPoint m_pos; DECLARE_DYNAMIC_CLASS_NO_COPY(wxColourDialog) }; -#endif // _WX_COLORDLG_H_ +#endif + // _WX_COLORDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/colour.h b/Source/3rd Party/wx/include/wx/msw/colour.h index 8ca120f82..d66b838d7 100644 --- a/Source/3rd Party/wx/include/wx/msw/colour.h +++ b/Source/3rd Party/wx/include/wx/msw/colour.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: colour.h 51769 2008-02-13 22:36:43Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,17 +18,30 @@ // Colour // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxColour : public wxColourBase +class WXDLLEXPORT wxColour : public wxColourBase { public: // constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS + + wxColour() { Init(); } + wxColour( ChannelType red, ChannelType green, ChannelType blue, + ChannelType alpha = wxALPHA_OPAQUE ) + { Set(red, green, blue, alpha); } + wxColour( unsigned long colRGB ) { Set(colRGB); } + wxColour(const wxString& colourName) { Init(); Set(colourName); } + wxColour(const wxChar *colourName) { Init(); Set(colourName); } + + + // dtor + virtual ~wxColour(); + // accessors // --------- - virtual bool IsOk() const { return m_isInit; } + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_isInit; } unsigned char Red() const { return m_red; } unsigned char Green() const { return m_green; } @@ -44,10 +58,11 @@ public: && m_alpha == colour.m_alpha; } - bool operator!=(const wxColour& colour) const { return !(*this == colour); } + bool operator != (const wxColour& colour) const { return !(*this == colour); } WXCOLORREF GetPixel() const { return m_pixel; } + public: WXCOLORREF m_pixel; @@ -69,4 +84,5 @@ private: DECLARE_DYNAMIC_CLASS(wxColour) }; -#endif // _WX_COLOUR_H_ +#endif + // _WX_COLOUR_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/combo.h b/Source/3rd Party/wx/include/wx/msw/combo.h index a8955bf9f..0cd58b32d 100644 --- a/Source/3rd Party/wx/include/wx/msw/combo.h +++ b/Source/3rd Party/wx/include/wx/msw/combo.h @@ -4,6 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 +// RCS-ID: $Id: combo.h 43881 2006-12-09 19:48:21Z PC $ // Copyright: (c) Jaakko Salli // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,9 +33,9 @@ // Define this only if native implementation includes all features #define wxCOMBOCONTROL_FULLY_FEATURED -extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[]; +extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxComboBoxNameStr[]; -class WXDLLIMPEXP_CORE wxComboCtrl : public wxComboCtrlBase +class WXDLLEXPORT wxComboCtrl : public wxComboCtrlBase { public: // ctors and such @@ -72,29 +73,22 @@ public: static int GetFeatures() { return wxComboCtrlFeatures::All; } #if wxUSE_COMBOCTRL_POPUP_ANIMATION - void OnTimerEvent(wxTimerEvent& WXUNUSED(event)) { DoTimerEvent(); } - + void OnTimerEvent( wxTimerEvent& event ); protected: - void DoTimerEvent(); - virtual bool AnimateShow( const wxRect& rect, int flags ); -#endif // wxUSE_COMBOCTRL_POPUP_ANIMATION +#endif protected: - // Dummy method - we override all functions that call this - virtual WXHWND GetEditHWND() const { return NULL; } - // customization virtual void OnResize(); virtual wxCoord GetNativeTextIndent() const; + virtual void OnThemeChange(); // event handlers void OnPaintEvent( wxPaintEvent& event ); void OnMouseEvent( wxMouseEvent& event ); - virtual bool HasTransparentBackground() { return IsDoubleBuffered(); } - private: void Init(); diff --git a/Source/3rd Party/wx/include/wx/msw/combobox.h b/Source/3rd Party/wx/include/wx/msw/combobox.h index a42b8d834..5d4d7761f 100644 --- a/Source/3rd Party/wx/include/wx/msw/combobox.h +++ b/Source/3rd Party/wx/include/wx/msw/combobox.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: combobox.h 45818 2007-05-05 13:15:47Z RR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,6 @@ #define _WX_COMBOBOX_H_ #include "wx/choice.h" -#include "wx/textentry.h" #if wxUSE_COMBOBOX @@ -20,11 +20,10 @@ // Combobox control // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxComboBox : public wxChoice, - public wxTextEntry +class WXDLLEXPORT wxComboBox: public wxChoice { public: - wxComboBox() { Init(); } + wxComboBox() { } wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, @@ -35,11 +34,8 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) { - Init(); Create(parent, id, value, pos, size, n, choices, style, validator, name); - } - wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -49,8 +45,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) { - Init(); - Create(parent, id, value, pos, size, choices, style, validator, name); } @@ -74,33 +68,46 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr); - // See wxComboBoxBase discussion of IsEmpty(). - bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } - bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } + // List functions: see wxChoice - // resolve ambiguities among virtual functions inherited from both base - // classes - virtual void Clear(); + // Text field functions virtual wxString GetValue() const; virtual void SetValue(const wxString& value); - virtual wxString GetStringSelection() const - { return wxChoice::GetStringSelection(); } - virtual void Popup() { MSWDoPopupOrDismiss(true); } - virtual void Dismiss() { MSWDoPopupOrDismiss(false); } - virtual void SetSelection(int n) { wxChoice::SetSelection(n); } - virtual void SetSelection(long from, long to) - { wxTextEntry::SetSelection(from, to); } - virtual int GetSelection() const { return wxChoice::GetSelection(); } - virtual bool ContainsHWND(WXHWND hWnd) const; - virtual void GetSelection(long *from, long *to) const; + // Clipboard operations + virtual void Copy(); + virtual void Cut(); + virtual void Paste(); + virtual bool CanCopy() const; + virtual bool CanCut() const; + virtual bool CanPaste() const; + virtual void SetInsertionPoint(long pos); + virtual void SetInsertionPointEnd(); + virtual long GetInsertionPoint() const; + virtual wxTextPos GetLastPosition() const; + virtual void Replace(long from, long to, const wxString& value); + virtual void Remove(long from, long to); + virtual void SetSelection(int n) { wxChoice::SetSelection(n); } + virtual void SetSelection(long from, long to); + virtual int GetSelection() const { return wxChoice::GetSelection(); } + virtual void GetSelection(long* from, long* to) const; + virtual void SetEditable(bool editable); + + virtual void Undo(); + virtual void Redo(); + virtual bool CanUndo() const; + virtual bool CanRedo() const; + virtual void SelectAll(); virtual bool IsEditable() const; + virtual bool HasSelection() const; // implementation only from now on virtual bool MSWCommand(WXUINT param, WXWORD id); bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam); virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); bool MSWShouldPreProcessMessage(WXMSG *pMsg); + + WXHWND GetEditHWND() const; // Standard event handling void OnCut(wxCommandEvent& event); @@ -121,54 +128,11 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; -#if wxUSE_UXTHEME - // override wxTextEntry method to work around Windows bug - virtual bool SetHint(const wxString& hint); -#endif // wxUSE_UXTHEME - -protected: -#if wxUSE_TOOLTIPS - virtual void DoSetToolTip(wxToolTip *tip); -#endif - - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; - - // Override this one to avoid eating events from our popup listbox. - virtual wxWindow *MSWFindItem(long id, WXHWND hWnd) const; - - // this is the implementation of GetEditHWND() which can also be used when - // we don't have the edit control, it simply returns NULL then - // - // try not to use this function unless absolutely necessary (as in the - // message handling code where the edit control might not be created yet - // for the messages we receive during the control creation) as normally - // just testing for IsEditable() and using GetEditHWND() should be enough - WXHWND GetEditHWNDIfAvailable() const; - - virtual void EnableTextChangedEvents(bool enable) - { - m_allowTextEvents = enable; - } - private: - // there are the overridden wxTextEntry methods which should only be called - // when we do have an edit control so they assert if this is not the case - virtual wxWindow *GetEditableWindow(); - virtual WXHWND GetEditHWND() const; - - // common part of all ctors - void Init() - { - m_allowTextEvents = true; - } - - // normally true, false if text events are currently disabled - bool m_allowTextEvents; - DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) DECLARE_EVENT_TABLE() }; #endif // wxUSE_COMBOBOX - -#endif // _WX_COMBOBOX_H_ +#endif + // _WX_COMBOBOX_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/commandlinkbutton.h b/Source/3rd Party/wx/include/wx/msw/commandlinkbutton.h deleted file mode 100644 index bc4d4804d..000000000 --- a/Source/3rd Party/wx/include/wx/msw/commandlinkbutton.h +++ /dev/null @@ -1,73 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/commandlinkbutton.h -// Purpose: wxCommandLinkButton class -// Author: Rickard Westerlund -// Created: 2010-06-11 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_COMMANDLINKBUTTON_H_ -#define _WX_MSW_COMMANDLINKBUTTON_H_ - -// ---------------------------------------------------------------------------- -// Command link button for wxMSW -// ---------------------------------------------------------------------------- - -// Derive from the generic version to be able to fall back to it during -// run-time if the command link buttons are not supported by the system we're -// running under. - -class WXDLLIMPEXP_ADV wxCommandLinkButton : public wxGenericCommandLinkButton -{ -public: - wxCommandLinkButton () : wxGenericCommandLinkButton() { } - - wxCommandLinkButton(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - : wxGenericCommandLinkButton() - { - Create(parent, id, mainLabel, note, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel = wxEmptyString, - const wxString& note = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - - // overridden base class methods - // ----------------------------- - - // do the same thing as in the generic case here - virtual void SetLabel(const wxString& label) - { - SetMainLabelAndNote(label.BeforeFirst('\n'), label.AfterFirst('\n')); - } - - virtual void SetMainLabelAndNote(const wxString& mainLabel, - const wxString& note); - - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - -protected: - virtual wxSize DoGetBestSize() const; - - virtual bool HasNativeBitmap() const; - -private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton); -}; - -#endif // _WX_MSW_COMMANDLINKBUTTON_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/control.h b/Source/3rd Party/wx/include/wx/msw/control.h index 0db9a3ed3..c70454cbc 100644 --- a/Source/3rd Party/wx/include/wx/msw/control.h +++ b/Source/3rd Party/wx/include/wx/msw/control.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: control.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,7 +15,7 @@ #include "wx/dynarray.h" // General item class -class WXDLLIMPEXP_CORE wxControl : public wxControlBase +class WXDLLEXPORT wxControl : public wxControlBase { public: wxControl() { } @@ -34,6 +35,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr); + virtual ~wxControl(); // Simulates an event virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } @@ -121,8 +123,12 @@ protected: // one virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd); - // Look in our GetSubcontrols() for the windows with the given ID. - virtual wxWindow *MSWFindItem(long id, WXHWND hWnd) const; + // this is a helper for the derived class GetClassDefaultAttributes() + // implementation: it returns the right colours for the classes which + // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of + // being simple controls (such as wxButton, wxCheckBox, ...) + static wxVisualAttributes + GetCompositeControlsDefaultAttributes(wxWindowVariant variant); // for controls like radiobuttons which are really composite this array // holds the ids (not HWNDs!) of the sub controls diff --git a/Source/3rd Party/wx/include/wx/msw/crashrpt.h b/Source/3rd Party/wx/include/wx/msw/crashrpt.h index 81542bd80..3933a387d 100644 --- a/Source/3rd Party/wx/include/wx/msw/crashrpt.h +++ b/Source/3rd Party/wx/include/wx/msw/crashrpt.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 13.07.2003 +// RCS-ID: $Id: crashrpt.h 34436 2005-05-31 09:20:43Z JS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -93,10 +94,10 @@ struct WXDLLIMPEXP_BASE wxCrashReport { // set the name of the file to which the report is written, it is // constructed from the .exe name by default - static void SetFileName(const wxString& filename); + static void SetFileName(const wxChar *filename); // return the current file name - static wxString GetFileName(); + static const wxChar *GetFileName(); // write the exception report to the file, return true if it could be done // or false otherwise diff --git a/Source/3rd Party/wx/include/wx/msw/ctrlsub.h b/Source/3rd Party/wx/include/wx/msw/ctrlsub.h deleted file mode 100644 index 068be29e5..000000000 --- a/Source/3rd Party/wx/include/wx/msw/ctrlsub.h +++ /dev/null @@ -1,42 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ctrlsub.h -// Purpose: common functionality of wxItemContainer-derived controls -// Author: Vadim Zeitlin -// Created: 2007-07-25 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_CTRLSUB_H_ -#define _WX_MSW_CTRLSUB_H_ - -// ---------------------------------------------------------------------------- -// wxControlWithItems -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxControlWithItems : public wxControlWithItemsBase -{ -public: - wxControlWithItems() { } - -protected: - // preallocate memory for inserting the given new items into the control - // using the wm message (normally either LB_INITSTORAGE or CB_INITSTORAGE) - void MSWAllocStorage(const wxArrayStringsAdapter& items, unsigned wm); - - // insert or append a string to the controls using the given message - // (one of {CB,LB}_{ADD,INSERT}STRING, pos must be 0 when appending) - int MSWInsertOrAppendItem(unsigned pos, const wxString& item, unsigned wm); - - // normally the control containing the items is this window itself but if - // the derived control is composed of several windows, this method can be - // overridden to return the real list/combobox control - virtual WXHWND MSWGetItemsHWND() const { return GetHWND(); } - -private: - DECLARE_ABSTRACT_CLASS(wxControlWithItems) - wxDECLARE_NO_COPY_CLASS(wxControlWithItems); -}; - -#endif // _WX_MSW_CTRLSUB_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/cursor.h b/Source/3rd Party/wx/include/wx/msw/cursor.h index 678416e5f..3cf280d43 100644 --- a/Source/3rd Party/wx/include/wx/msw/cursor.h +++ b/Source/3rd Party/wx/include/wx/msw/cursor.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: cursor.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,19 +17,19 @@ class WXDLLIMPEXP_FWD_CORE wxImage; // Cursor -class WXDLLIMPEXP_CORE wxCursor : public wxGDIImage +class WXDLLEXPORT wxCursor : public wxGDIImage { public: // constructors wxCursor(); wxCursor(const wxImage& image); + wxCursor(const char bits[], int width, int height, + int hotSpotX = -1, int hotSpotY = -1, + const char maskBits[] = NULL); wxCursor(const wxString& name, - wxBitmapType type = wxCURSOR_DEFAULT_TYPE, + long flags = wxBITMAP_TYPE_CUR_RESOURCE, int hotSpotX = 0, int hotSpotY = 0); - wxCursor(wxStockCursor id) { InitFromStock(id); } -#if WXWIN_COMPATIBILITY_2_8 - wxCursor(int id) { InitFromStock((wxStockCursor)id); } -#endif + wxCursor(int idCursor); virtual ~wxCursor(); // implementation only @@ -36,8 +37,6 @@ public: WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); } protected: - void InitFromStock(wxStockCursor); - virtual wxGDIImageRefData *CreateData() const; private: diff --git a/Source/3rd Party/wx/include/wx/msw/custombgwin.h b/Source/3rd Party/wx/include/wx/msw/custombgwin.h deleted file mode 100644 index ca8d8bfc4..000000000 --- a/Source/3rd Party/wx/include/wx/msw/custombgwin.h +++ /dev/null @@ -1,57 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/custombgwin.h -// Purpose: wxMSW implementation of wxCustomBackgroundWindow -// Author: Vadim Zeitlin -// Created: 2011-10-10 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_CUSTOMBGWIN_H_ -#define _WX_MSW_CUSTOMBGWIN_H_ - -#include "wx/bitmap.h" -#include "wx/brush.h" - -// ---------------------------------------------------------------------------- -// wxCustomBackgroundWindow -// ---------------------------------------------------------------------------- - -template -class wxCustomBackgroundWindow : public W, - public wxCustomBackgroundWindowBase -{ -public: - typedef W BaseWindowClass; - - wxCustomBackgroundWindow() { m_backgroundBrush = NULL; } - - virtual ~wxCustomBackgroundWindow() { delete m_backgroundBrush; } - -protected: - virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) - { - delete m_backgroundBrush; - m_backgroundBrush = bmp.IsOk() ? new wxBrush(bmp) : NULL; - - // Our transparent children should use our background if we have it, - // otherwise try to restore m_inheritBgCol to some reasonable value: true - // if we also have non-default background colour or false otherwise. - BaseWindowClass::m_inheritBgCol = bmp.IsOk() - || BaseWindowClass::UseBgCol(); - } - - virtual WXHBRUSH MSWGetCustomBgBrush() - { - if ( m_backgroundBrush ) - return (WXHBRUSH)m_backgroundBrush->GetResourceHandle(); - - return BaseWindowClass::MSWGetCustomBgBrush(); - } - - wxBrush *m_backgroundBrush; - - wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCustomBackgroundWindow, W); -}; - -#endif // _WX_MSW_CUSTOMBGWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/datectrl.h b/Source/3rd Party/wx/include/wx/msw/datectrl.h deleted file mode 100644 index 7ec52f034..000000000 --- a/Source/3rd Party/wx/include/wx/msw/datectrl.h +++ /dev/null @@ -1,66 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/datectrl.h -// Purpose: wxDatePickerCtrl for Windows -// Author: Vadim Zeitlin -// Modified by: -// Created: 2005-01-09 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_DATECTRL_H_ -#define _WX_MSW_DATECTRL_H_ - -// ---------------------------------------------------------------------------- -// wxDatePickerCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlBase -{ -public: - // ctors - wxDatePickerCtrl() { } - - wxDatePickerCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr) - { - Create(parent, id, dt, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxDatePickerCtrlNameStr); - - // Override this one to add date-specific (and time-ignoring) checks. - virtual void SetValue(const wxDateTime& dt); - virtual wxDateTime GetValue() const; - - // Implement the base class pure virtuals. - virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2); - virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const; - - // Override MSW-specific functions used during control creation. - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - -protected: -#if wxUSE_INTL - virtual wxLocaleInfo MSWGetFormat() const; -#endif // wxUSE_INTL - virtual bool MSWAllowsNone() const { return HasFlag(wxDP_ALLOWNONE); } - virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch); - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl) -}; - -#endif // _WX_MSW_DATECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/datetimectrl.h b/Source/3rd Party/wx/include/wx/msw/datetimectrl.h deleted file mode 100644 index dcb4d4ee1..000000000 --- a/Source/3rd Party/wx/include/wx/msw/datetimectrl.h +++ /dev/null @@ -1,88 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/datetimectrl.h -// Purpose: wxDateTimePickerCtrl for Windows. -// Author: Vadim Zeitlin -// Created: 2011-09-22 (extracted from wx/msw/datectrl.h). -// Copyright: (c) 2005-2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_DATETIMECTRL_H_ -#define _WX_MSW_DATETIMECTRL_H_ - -#include "wx/intl.h" - -// Forward declare a struct from Platform SDK. -struct tagNMDATETIMECHANGE; - -// ---------------------------------------------------------------------------- -// wxDateTimePickerCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDateTimePickerCtrl : public wxDateTimePickerCtrlBase -{ -public: - // set/get the date - virtual void SetValue(const wxDateTime& dt); - virtual wxDateTime GetValue() const; - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - -protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - virtual wxSize DoGetBestSize() const; - - // Helper for the derived classes Create(): creates a native control with - // the specified attributes. - bool MSWCreateDateTimePicker(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name); - - // Notice that the methods below must be overridden in all native MSW - // classes inheriting from this one but they can't be pure virtual because - // the generic implementations, not needing nor able to implement them, is - // also derived from this class currently. The real problem is, of course, - // this wrong class structure because the generic classes also inherit the - // wrong implementations of Set/GetValue() and DoGetBestSize() but as they - // override these methods anyhow, it does work -- but is definitely ugly - // and need to be changed (but how?) in the future. - -#if wxUSE_INTL - // Override to return the date/time format used by this control. - virtual wxLocaleInfo MSWGetFormat() const /* = 0 */ - { - wxFAIL_MSG( "Unreachable" ); - return wxLOCALE_TIME_FMT; - } -#endif // wxUSE_INTL - - // Override to indicate whether we can have no date at all. - virtual bool MSWAllowsNone() const /* = 0 */ - { - wxFAIL_MSG( "Unreachable" ); - return false; - } - - // Override to update m_date and send the event when the control contents - // changes, return true if the event was handled. - virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch) /* = 0 */ - { - wxUnusedVar(dtch); - wxFAIL_MSG( "Unreachable" ); - return false; - } - - - // the date currently shown by the control, may be invalid - wxDateTime m_date; -}; - -#endif // _WX_MSW_DATETIMECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/dc.h b/Source/3rd Party/wx/include/wx/msw/dc.h index e5a153f89..97b1444fc 100644 --- a/Source/3rd Party/wx/include/wx/msw/dc.h +++ b/Source/3rd Party/wx/include/wx/msw/dc.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dc.h 42612 2006-10-29 10:46:49Z SC $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,6 @@ #define _WX_MSW_DC_H_ #include "wx/defs.h" -#include "wx/dc.h" // --------------------------------------------------------------------------- // macros @@ -42,11 +42,11 @@ public: // this is an ABC: use one of the derived classes to create a DC associated // with a window, screen, printer and so on -class WXDLLIMPEXP_CORE wxMSWDCImpl: public wxDCImpl +class WXDLLEXPORT wxDC : public wxDCBase { public: - wxMSWDCImpl(wxDC *owner, WXHDC hDC); - virtual ~wxMSWDCImpl(); + wxDC(WXHDC hDC) { Init(); m_hDC = hDC; } + virtual ~wxDC(); // implement base class pure virtuals // ---------------------------------- @@ -78,22 +78,14 @@ public: virtual int GetDepth() const; virtual wxSize GetPPI() const; - - virtual void SetMapMode(wxMappingMode mode); + virtual void SetMapMode(int mode); virtual void SetUserScale(double x, double y); + virtual void SetSystemScale(double x, double y); virtual void SetLogicalScale(double x, double y); virtual void SetLogicalOrigin(wxCoord x, wxCoord y); virtual void SetDeviceOrigin(wxCoord x, wxCoord y); virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); - -#if wxUSE_DC_TRANSFORM_MATRIX - virtual bool CanUseTransformMatrix() const; - virtual bool SetTransformMatrix(const wxAffineMatrix2D& matrix); - virtual wxAffineMatrix2D GetTransformMatrix() const; - virtual void ResetTransformMatrix(); -#endif // wxUSE_DC_TRANSFORM_MATRIX - - virtual void SetLogicalFunction(wxRasterOperationMode function); + virtual void SetLogicalFunction(int function); // implementation from now on // -------------------------- @@ -101,9 +93,10 @@ public: virtual void SetRop(WXHDC cdc); virtual void SelectOldObjects(WXHDC dc); + wxWindow *GetWindow() const { return m_canvas; } void SetWindow(wxWindow *win) { - m_window = win; + m_canvas = win; #if wxUSE_PALETTE // if we have palettes use the correct one for this window @@ -125,8 +118,6 @@ public: m_clipX2 = 0; } - void* GetHandle() const { return (void*)GetHDC(); } - const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; } wxBitmap& GetSelectedBitmap() { return m_selectedBitmap; } @@ -153,6 +144,7 @@ public: protected: void Init() { + m_canvas = NULL; m_bOwnsDC = false; m_hDC = NULL; @@ -168,26 +160,17 @@ protected: // create an uninitialized DC: this should be only used by the derived // classes - wxMSWDCImpl( wxDC *owner ) : wxDCImpl( owner ) { Init(); } + wxDC() { Init(); } - void RealizeScaleAndOrigin(); - -public: - virtual void DoGetFontMetrics(int *height, - int *ascent, - int *descent, - int *internalLeading, - int *externalLeading, - int *averageWidth) const; virtual void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const; + wxFont *theFont = NULL) const; virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - wxFloodFillStyle style = wxFLOOD_SURFACE); + int style = wxFLOOD_SURFACE); virtual void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, @@ -213,8 +196,8 @@ public: double radius); virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); -#if wxUSE_SPLINES && !defined(__WXWINCE__) - virtual void DoDrawSpline(const wxPointList *points); +#if wxUSE_SPLINES + virtual void DoDrawSpline(wxList *points); #endif virtual void DoCrossHair(wxCoord x, wxCoord y); @@ -229,38 +212,28 @@ public: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); - - virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); + // this is gnarly - we can't even call this function DoSetClippingRegion() + // because of virtual function hiding + virtual void DoSetClippingRegionAsRegion(const wxRegion& region); virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - virtual void DoSetDeviceClippingRegion(const wxRegion& region); virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const; virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, const wxPoint points[], + virtual void DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, const wxPoint points[], + virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], + int fillStyle = wxODDEVEN_RULE); + virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const - { - return subrect == NULL ? GetSelectedBitmap() - : GetSelectedBitmap().GetSubBitmap(*subrect); - } + int fillStyle = wxODDEVEN_RULE); + virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const + { return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); } #if wxUSE_PALETTE @@ -274,11 +247,10 @@ public: void InitializePalette(); #endif // wxUSE_PALETTE -protected: // common part of DoDrawText() and DoDrawRotatedText() void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); - // common part of DoSetClippingRegion() and DoSetDeviceClippingRegion() + // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion() void SetClippingHrgn(WXHRGN hrgn); // implementation of DoGetSize() for wxScreen/PrinterDC: this simply @@ -319,12 +291,12 @@ protected: #endif // wxUSE_PALETTE #if wxUSE_DC_CACHEING - static wxObjectList sm_bitmapCache; - static wxObjectList sm_dcCache; + static wxList sm_bitmapCache; + static wxList sm_dcCache; #endif - DECLARE_CLASS(wxMSWDCImpl) - wxDECLARE_NO_COPY_CLASS(wxMSWDCImpl); + DECLARE_DYNAMIC_CLASS(wxDC) + DECLARE_NO_COPY_CLASS(wxDC) }; // ---------------------------------------------------------------------------- @@ -332,27 +304,28 @@ protected: // only/mainly) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDCTempImpl : public wxMSWDCImpl +class WXDLLEXPORT wxDCTemp : public wxDC { public: // construct a temporary DC with the specified HDC and size (it should be // specified whenever we know it for this HDC) - wxDCTempImpl(wxDC *owner, WXHDC hdc, const wxSize& size ) - : wxMSWDCImpl( owner, hdc ), + wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize) + : wxDC(hdc), m_size(size) { } - virtual ~wxDCTempImpl() + virtual ~wxDCTemp() { // prevent base class dtor from freeing it SetHDC((WXHDC)NULL); } +protected: virtual void DoGetSize(int *w, int *h) const { wxASSERT_MSG( m_size.IsFullySpecified(), - wxT("size of this DC hadn't been set and is unknown") ); + _T("size of this DC hadn't been set and is unknown") ); if ( w ) *w = m_size.x; @@ -365,16 +338,7 @@ private: // find it ourselves const wxSize m_size; - wxDECLARE_NO_COPY_CLASS(wxDCTempImpl); -}; - -class WXDLLIMPEXP_CORE wxDCTemp : public wxDC -{ -public: - wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize) - : wxDC(new wxDCTempImpl(this, hdc, size)) - { - } + DECLARE_NO_COPY_CLASS(wxDCTemp) }; #endif // _WX_MSW_DC_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/dcclient.h b/Source/3rd Party/wx/include/wx/msw/dcclient.h index 3eebc4f70..e01171e3e 100644 --- a/Source/3rd Party/wx/include/wx/msw/dcclient.h +++ b/Source/3rd Party/wx/include/wx/msw/dcclient.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/dcclient.h +// Name: dcclient.h // Purpose: wxClientDC class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dcclient.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,77 +17,83 @@ // ---------------------------------------------------------------------------- #include "wx/dc.h" -#include "wx/msw/dc.h" -#include "wx/dcclient.h" +#include "wx/dynarray.h" -class wxPaintDCInfo; +// ---------------------------------------------------------------------------- +// array types +// ---------------------------------------------------------------------------- + +// this one if used by wxPaintDC only +struct WXDLLIMPEXP_FWD_CORE wxPaintDCInfo; + +WX_DECLARE_EXPORTED_OBJARRAY(wxPaintDCInfo, wxArrayDCInfo); // ---------------------------------------------------------------------------- // DC classes // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxMSWDCImpl +class WXDLLEXPORT wxWindowDC : public wxDC { public: // default ctor - wxWindowDCImpl( wxDC *owner ); + wxWindowDC(); // Create a DC corresponding to the whole window - wxWindowDCImpl( wxDC *owner, wxWindow *win ); - - virtual void DoGetSize(int *width, int *height) const; + wxWindowDC(wxWindow *win); protected: // initialize the newly created DC void InitDC(); - DECLARE_CLASS(wxWindowDCImpl) - wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl); + // override some base class virtuals + virtual void DoGetSize(int *width, int *height) const; + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxWindowDC) }; -class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl +class WXDLLEXPORT wxClientDC : public wxWindowDC { public: // default ctor - wxClientDCImpl( wxDC *owner ); + wxClientDC(); // Create a DC corresponding to the client area of the window - wxClientDCImpl( wxDC *owner, wxWindow *win ); + wxClientDC(wxWindow *win); - virtual ~wxClientDCImpl(); - - virtual void DoGetSize(int *width, int *height) const; + virtual ~wxClientDC(); protected: void InitDC(); - DECLARE_CLASS(wxClientDCImpl) - wxDECLARE_NO_COPY_CLASS(wxClientDCImpl); + // override some base class virtuals + virtual void DoGetSize(int *width, int *height) const; + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxClientDC) }; -class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl +class WXDLLEXPORT wxPaintDC : public wxClientDC { public: - wxPaintDCImpl( wxDC *owner ); + wxPaintDC(); // Create a DC corresponding for painting the window in OnPaint() - wxPaintDCImpl( wxDC *owner, wxWindow *win ); + wxPaintDC(wxWindow *win); - virtual ~wxPaintDCImpl(); + virtual ~wxPaintDC(); // find the entry for this DC in the cache (keyed by the window) static WXHDC FindDCInCache(wxWindow* win); - // This must be called by the code handling WM_PAINT to remove the DC - // cached for this window for the duration of this message processing. - static void EndPaint(wxWindow *win); - protected: - // Find the DC for this window in the cache, return NULL if not found. - static wxPaintDCInfo *FindInCache(wxWindow* win); + static wxArrayDCInfo ms_cache; - DECLARE_CLASS(wxPaintDCImpl) - wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl); + // find the entry for this DC in the cache (keyed by the window) + wxPaintDCInfo *FindInCache(size_t *index = NULL) const; + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxPaintDC) }; /* @@ -95,13 +102,16 @@ protected: * message. It is used in HandlePaint and need not be used by an application. */ -class WXDLLIMPEXP_CORE wxPaintDCEx : public wxPaintDC +class WXDLLEXPORT wxPaintDCEx : public wxPaintDC { public: wxPaintDCEx(wxWindow *canvas, WXHDC dc); + virtual ~wxPaintDCEx(); +private: + int saveState; DECLARE_CLASS(wxPaintDCEx) - wxDECLARE_NO_COPY_CLASS(wxPaintDCEx); + DECLARE_NO_COPY_CLASS(wxPaintDCEx) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/dcmemory.h b/Source/3rd Party/wx/include/wx/msw/dcmemory.h index b7d81f2eb..fced2bc4f 100644 --- a/Source/3rd Party/wx/include/wx/msw/dcmemory.h +++ b/Source/3rd Party/wx/include/wx/msw/dcmemory.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dcmemory.h 48236 2007-08-20 23:43:32Z KO $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,33 +12,33 @@ #ifndef _WX_DCMEMORY_H_ #define _WX_DCMEMORY_H_ -#include "wx/dcmemory.h" -#include "wx/msw/dc.h" +#include "wx/dcclient.h" -class WXDLLIMPEXP_CORE wxMemoryDCImpl: public wxMSWDCImpl +class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase { public: - wxMemoryDCImpl( wxMemoryDC *owner ); - wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ); - wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC + wxMemoryDC() { CreateCompatible(NULL); Init(); } + wxMemoryDC(wxBitmap& bitmap) { CreateCompatible(NULL); Init(); SelectObject(bitmap); } + wxMemoryDC(wxDC *dc); // Create compatible DC + +protected: // override some base class virtuals virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); virtual void DoGetSize(int* width, int* height) const; virtual void DoSelect(const wxBitmap& bitmap); - virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const + virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const { return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmapOfHDC(*subrect, GetHDC() );} -protected: // create DC compatible with the given one or screen if dc == NULL bool CreateCompatible(wxDC *dc); // initialize the newly created DC void Init(); - DECLARE_CLASS(wxMemoryDCImpl) - wxDECLARE_NO_COPY_CLASS(wxMemoryDCImpl); +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxMemoryDC) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/dcprint.h b/Source/3rd Party/wx/include/wx/msw/dcprint.h index 449ed7a0a..948b52e45 100644 --- a/Source/3rd Party/wx/include/wx/msw/dcprint.h +++ b/Source/3rd Party/wx/include/wx/msw/dcprint.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dcprint.h 42522 2006-10-27 13:07:40Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,20 +14,19 @@ #if wxUSE_PRINTING_ARCHITECTURE -#include "wx/dcprint.h" +#include "wx/dc.h" #include "wx/cmndata.h" -#include "wx/msw/dc.h" -// ------------------------------------------------------------------------ -// wxPrinterDCImpl -// - -class WXDLLIMPEXP_CORE wxPrinterDCImpl : public wxMSWDCImpl +class WXDLLEXPORT wxPrinterDC : public wxDC { public: + // Create a printer DC (obsolete function: use wxPrintData version now) + wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = true, int orientation = wxPORTRAIT); + // Create from print data - wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); - wxPrinterDCImpl( wxPrinterDC *owner, WXHDC theDC ); + wxPrinterDC(const wxPrintData& data); + + wxPrinterDC(WXHDC theDC); // override some base class virtuals virtual bool StartDoc(const wxString& message); @@ -34,7 +34,7 @@ public: virtual void StartPage(); virtual void EndPage(); - virtual wxRect GetPaperRect() const; + wxRect GetPaperRect(); protected: virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, @@ -42,8 +42,7 @@ protected: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); virtual void DoGetSize(int *w, int *h) const { GetDeviceSize(w, h); @@ -56,25 +55,14 @@ protected: wxPrintData m_printData; private: - DECLARE_CLASS(wxPrinterDCImpl) - wxDECLARE_NO_COPY_CLASS(wxPrinterDCImpl); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxPrinterDC) }; +// Gets an HDC for the default printer configuration +// WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation); + // Gets an HDC for the specified printer configuration -WXHDC WXDLLIMPEXP_CORE wxGetPrinterDC(const wxPrintData& data); - -// ------------------------------------------------------------------------ -// wxPrinterDCromHDC -// - -class WXDLLIMPEXP_CORE wxPrinterDCFromHDC: public wxPrinterDC -{ -public: - wxPrinterDCFromHDC( WXHDC theDC ) - : wxPrinterDC(new wxPrinterDCImpl(this, theDC)) - { - } -}; +WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& data); #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/Source/3rd Party/wx/include/wx/msw/dcscreen.h b/Source/3rd Party/wx/include/wx/msw/dcscreen.h index 4c072da49..89c83ae7f 100644 --- a/Source/3rd Party/wx/include/wx/msw/dcscreen.h +++ b/Source/3rd Party/wx/include/wx/msw/dcscreen.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dcscreen.h 36565 2005-12-25 12:52:53Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,22 +12,28 @@ #ifndef _WX_MSW_DCSCREEN_H_ #define _WX_MSW_DCSCREEN_H_ -#include "wx/dcscreen.h" -#include "wx/msw/dc.h" +#include "wx/dc.h" -class WXDLLIMPEXP_CORE wxScreenDCImpl : public wxMSWDCImpl +class WXDLLEXPORT wxScreenDC : public wxDC { public: // Create a DC representing the whole screen - wxScreenDCImpl( wxScreenDC *owner ); + wxScreenDC(); + // Compatibility with X's requirements for drawing on top of all windows: + // they don't do anything under MSW + static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return true; } + static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return true; } + static bool EndDrawingOnTop() { return true; } + +protected: virtual void DoGetSize(int *w, int *h) const { GetDeviceSize(w, h); } - DECLARE_CLASS(wxScreenDCImpl) - wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl); +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxScreenDC) }; #endif // _WX_MSW_DCSCREEN_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/dde.h b/Source/3rd Party/wx/include/wx/msw/dde.h index 70a6cf39b..fe8f23c2f 100644 --- a/Source/3rd Party/wx/include/wx/msw/dde.h +++ b/Source/3rd Party/wx/include/wx/msw/dde.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/dde.h +// Name: dde.h // Purpose: DDE class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dde.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -40,98 +41,104 @@ class WXDLLIMPEXP_FWD_BASE wxDDEServer; class WXDLLIMPEXP_FWD_BASE wxDDEClient; -class WXDLLIMPEXP_BASE wxDDEConnection : public wxConnectionBase +class WXDLLIMPEXP_BASE wxDDEConnection: public wxConnectionBase { + DECLARE_DYNAMIC_CLASS(wxDDEConnection) public: - wxDDEConnection(void *buffer, size_t size); // use external buffer + wxDDEConnection(wxChar *buffer, int size); // use external buffer wxDDEConnection(); // use internal buffer - virtual ~wxDDEConnection(); + virtual ~wxDDEConnection(void); - // implement base class pure virtual methods - virtual const void *Request(const wxString& item, - size_t *size = NULL, - wxIPCFormat format = wxIPC_TEXT); + // Calls that CLIENT can make + virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); + virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); } + virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT); + virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); virtual bool StartAdvise(const wxString& item); virtual bool StopAdvise(const wxString& item); - virtual bool Disconnect(); -protected: - virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format); - virtual bool DoPoke(const wxString& item, const void *data, size_t size, - wxIPCFormat format); - virtual bool DoAdvise(const wxString& item, const void *data, size_t size, - wxIPCFormat format); + // Calls that SERVER can make + virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); -public: + // Calls that both can make + virtual bool Disconnect(void); + + // Default behaviour is to delete connection and return true + virtual bool OnDisconnect(void); + + public: wxString m_topicName; wxDDEServer* m_server; wxDDEClient* m_client; WXHCONV m_hConv; - const void* m_sendingData; + wxChar* m_sendingData; int m_dataSize; - wxIPCFormat m_dataType; + wxIPCFormat m_dataType; - wxDECLARE_NO_COPY_CLASS(wxDDEConnection); - DECLARE_DYNAMIC_CLASS(wxDDEConnection) + DECLARE_NO_COPY_CLASS(wxDDEConnection) }; -class WXDLLIMPEXP_BASE wxDDEServer : public wxServerBase +class WXDLLIMPEXP_BASE wxDDEServer: public wxServerBase { -public: - wxDDEServer(); - bool Create(const wxString& server_name); - virtual ~wxDDEServer(); + DECLARE_DYNAMIC_CLASS(wxDDEServer) + public: - virtual wxConnectionBase *OnAcceptConnection(const wxString& topic); + wxDDEServer(void); + virtual ~wxDDEServer(void); + bool Create(const wxString& server_name); // Returns false if can't create server (e.g. port + // number is already in use) + virtual wxConnectionBase *OnAcceptConnection(const wxString& topic); - // Find/delete wxDDEConnection corresponding to the HCONV - wxDDEConnection *FindConnection(WXHCONV conv); - bool DeleteConnection(WXHCONV conv); - wxString& GetServiceName() const { return (wxString&) m_serviceName; } + //////////////////////////////////////////////////////////// + // Implementation - wxDDEConnectionList& GetConnections() const - { return (wxDDEConnectionList&) m_connections; } + // Find/delete wxDDEConnection corresponding to the HCONV + wxDDEConnection *FindConnection(WXHCONV conv); + bool DeleteConnection(WXHCONV conv); + inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; } + inline wxDDEConnectionList& GetConnections(void) const + { + return (wxDDEConnectionList&) m_connections; + } protected: int m_lastError; wxString m_serviceName; wxDDEConnectionList m_connections; - - DECLARE_DYNAMIC_CLASS(wxDDEServer) }; class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase { -public: - wxDDEClient(); - virtual ~wxDDEClient(); + DECLARE_DYNAMIC_CLASS(wxDDEClient) + public: + wxDDEClient(void); + virtual ~wxDDEClient(void); + bool ValidHost(const wxString& host); + virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic); + // Call this to make a connection. + // Returns NULL if cannot. + virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection. - bool ValidHost(const wxString& host); + //////////////////////////////////////////////////////////// + // Implementation - // Call this to make a connection. Returns NULL if cannot. - virtual wxConnectionBase *MakeConnection(const wxString& host, - const wxString& server, - const wxString& topic); + // Find/delete wxDDEConnection corresponding to the HCONV + wxDDEConnection *FindConnection(WXHCONV conv); + bool DeleteConnection(WXHCONV conv); - // Tailor this to return own connection. - virtual wxConnectionBase *OnMakeConnection(); - - // Find/delete wxDDEConnection corresponding to the HCONV - wxDDEConnection *FindConnection(WXHCONV conv); - bool DeleteConnection(WXHCONV conv); - - wxDDEConnectionList& GetConnections() const - { return (wxDDEConnectionList&) m_connections; } + inline wxDDEConnectionList& GetConnections(void) const + { + return (wxDDEConnectionList&) m_connections; + } protected: int m_lastError; wxDDEConnectionList m_connections; - - DECLARE_DYNAMIC_CLASS(wxDDEClient) }; void WXDLLIMPEXP_BASE wxDDEInitialize(); void WXDLLIMPEXP_BASE wxDDECleanUp(); -#endif // _WX_DDE_H_ +#endif + // _WX_DDE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/debughlp.h b/Source/3rd Party/wx/include/wx/msw/debughlp.h index 45651d469..65ca85d82 100644 --- a/Source/3rd Party/wx/include/wx/msw/debughlp.h +++ b/Source/3rd Party/wx/include/wx/msw/debughlp.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/debughlp.h +// Name: wx/msw/wrapdbgh.h // Purpose: wraps dbghelp.h standard file // Author: Vadim Zeitlin // Modified by: // Created: 2005-01-08 (extracted from msw/crashrpt.cpp) +// RCS-ID: $Id: debughlp.h 31443 2005-01-18 10:10:23Z ABX $ // Copyright: (c) 2003-2005 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -19,21 +20,18 @@ #endif // __WXWINCE__ #include "wx/msw/private.h" -// All known versions of imagehlp.h define API_VERSION_NUMBER but it's not -// documented, so deal with the possibility that it's not defined just in case. -#ifndef API_VERSION_NUMBER - #define API_VERSION_NUMBER 0 -#endif - -// wxUSE_DBGHELP is a bit special as it is not defined in wx/setup.h and we try -// to auto-detect whether we should be using debug help API or not ourselves -// below. However if the auto-detection fails, you can always predefine it as 0 -// to avoid even trying. +// we need to determine whether we have the declarations for the function in +// debughlp.dll version 5.81 (at least) and we check for DBHLPAPI to test this +// +// reasons: +// - VC6 version of imagehlp.h doesn't define it +// - VC7 one does +// - testing for compiler version doesn't work as you can install and use +// the new SDK headers with VC6 +// +// in any case, the user may override by defining wxUSE_DBGHELP himself #ifndef wxUSE_DBGHELP - // The version of imagehlp.h from VC6 (7) is too old and is missing some - // required symbols while the version from VC7 (9) is good enough. As we - // don't know anything about version 8, don't use it unless we can test it. - #if API_VERSION_NUMBER >= 9 + #ifdef DBHLPAPI #define wxUSE_DBGHELP 1 #else #define wxUSE_DBGHELP 0 @@ -148,9 +146,9 @@ public: PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE); typedef BOOL (WINAPI *SymFromAddr_t)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO); - typedef LPVOID (WINAPI *SymFunctionTableAccess_t)(HANDLE, DWORD_PTR); - typedef DWORD_PTR (WINAPI *SymGetModuleBase_t)(HANDLE, DWORD_PTR); - typedef BOOL (WINAPI *SymGetLineFromAddr_t)(HANDLE, DWORD_PTR, + typedef LPVOID (WINAPI *SymFunctionTableAccess_t)(HANDLE, DWORD); + typedef DWORD (WINAPI *SymGetModuleBase_t)(HANDLE, DWORD); + typedef BOOL (WINAPI *SymGetLineFromAddr_t)(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE); typedef BOOL (WINAPI *SymSetContext_t)(HANDLE, PIMAGEHLP_STACK_FRAME, PIMAGEHLP_CONTEXT); @@ -166,44 +164,23 @@ public: CONST PMINIDUMP_USER_STREAM_INFORMATION, CONST PMINIDUMP_CALLBACK_INFORMATION); - // The macro called by wxDO_FOR_ALL_SYM_FUNCS() below takes 2 arguments: - // the name of the function in the program code, which never has "64" - // suffix, and the name of the function in the DLL which can have "64" - // suffix in some cases. These 2 helper macros call the macro with the - // correct arguments in both cases. - #define wxSYM_CALL(what, name) what(name, name) -#if defined(_M_AMD64) - #define wxSYM_CALL_64(what, name) what(name, name ## 64) - - // Also undo all the "helpful" definitions done by imagehlp.h that map 32 - // bit functions to 64 bit ones, we don't need this as we do it ourselves. - #undef StackWalk - #undef SymFunctionTableAccess - #undef SymGetModuleBase - #undef SymGetLineFromAddr - #undef EnumerateLoadedModules -#else - #define wxSYM_CALL_64(what, name) what(name, name) -#endif - #define wxDO_FOR_ALL_SYM_FUNCS(what) \ - wxSYM_CALL_64(what, StackWalk); \ - wxSYM_CALL_64(what, SymFunctionTableAccess); \ - wxSYM_CALL_64(what, SymGetModuleBase); \ - wxSYM_CALL_64(what, SymGetLineFromAddr); \ - wxSYM_CALL_64(what, EnumerateLoadedModules); \ - \ - wxSYM_CALL(what, SymGetOptions); \ - wxSYM_CALL(what, SymSetOptions); \ - wxSYM_CALL(what, SymInitialize); \ - wxSYM_CALL(what, SymFromAddr); \ - wxSYM_CALL(what, SymSetContext); \ - wxSYM_CALL(what, SymEnumSymbols); \ - wxSYM_CALL(what, SymGetTypeInfo); \ - wxSYM_CALL(what, SymCleanup); \ - wxSYM_CALL(what, MiniDumpWriteDump) + what(SymGetOptions); \ + what(SymSetOptions); \ + what(SymInitialize); \ + what(StackWalk); \ + what(SymFromAddr); \ + what(SymFunctionTableAccess); \ + what(SymGetModuleBase); \ + what(SymGetLineFromAddr); \ + what(SymSetContext); \ + what(SymEnumSymbols); \ + what(SymGetTypeInfo); \ + what(SymCleanup); \ + what(EnumerateLoadedModules); \ + what(MiniDumpWriteDump) - #define wxDECLARE_SYM_FUNCTION(func, name) static func ## _t func + #define wxDECLARE_SYM_FUNCTION(func) static func ## _t func wxDO_FOR_ALL_SYM_FUNCS(wxDECLARE_SYM_FUNCTION); diff --git a/Source/3rd Party/wx/include/wx/msw/dialog.h b/Source/3rd Party/wx/include/wx/msw/dialog.h index 57b1bd548..15f8ba10f 100644 --- a/Source/3rd Party/wx/include/wx/msw/dialog.h +++ b/Source/3rd Party/wx/include/wx/msw/dialog.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dialog.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,26 +14,17 @@ #include "wx/panel.h" -// this option is always enabled (there doesn't seem to be any good reason to -// disable it) for desktop Windows versions but Windows CE dialogs are usually -// not resizable and never show resize gripper anyhow so don't use it there -#ifdef __WXWINCE__ - #define wxUSE_DIALOG_SIZEGRIP 0 -#else - #define wxUSE_DIALOG_SIZEGRIP 1 -#endif - -extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[]; class WXDLLIMPEXP_FWD_CORE wxDialogModalData; #if wxUSE_TOOLBAR && (defined(__SMARTPHONE__) || defined(__POCKETPC__)) class WXDLLIMPEXP_FWD_CORE wxToolBar; -extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[]; #endif // Dialog boxes -class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase +class WXDLLEXPORT wxDialog : public wxDialogBase { public: wxDialog() { Init(); } @@ -91,9 +83,7 @@ public: // override some base class virtuals virtual bool Show(bool show = true); -#if wxUSE_DIALOG_SIZEGRIP - virtual void SetWindowStyleFlag(long style); -#endif // wxUSE_DIALOG_SIZEGRIP + virtual void Raise(); #ifdef __POCKETPC__ // Responds to the OK button in a PocketPC titlebar. This @@ -106,26 +96,34 @@ public: // Windows callbacks WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); +#if WXWIN_COMPATIBILITY_2_6 + // use the other ctor + wxDEPRECATED( wxDialog(wxWindow *parent, + const wxString& title, bool modal, + int x = wxDefaultCoord, int y = wxDefaultCoord, int width = 500, int height = 500, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxDialogNameStr) ); + + // just call Show() or ShowModal() + wxDEPRECATED( void SetModal(bool flag) ); + + // use IsModal() + wxDEPRECATED( bool IsModalShowing() const ); +#endif // WXWIN_COMPATIBILITY_2_6 + protected: + // find the window to use as parent for this dialog if none has been + // specified explicitly by the user + // + // may return NULL + wxWindow *FindSuitableParent() const; + // common part of all ctors void Init(); private: -#if wxUSE_DIALOG_SIZEGRIP - // these functions deal with the gripper window shown in the corner of - // resizable dialogs - void CreateGripper(); - void DestroyGripper(); - void ShowGripper(bool show); - void ResizeGripper(); - - // this function is used to adjust Z-order of new children relative to the - // gripper if we have one - void OnWindowCreate(wxWindowCreateEvent& event); - - // gripper window for a resizable dialog, NULL if we're not resizable - WXHWND m_hGripper; -#endif // wxUSE_DIALOG_SIZEGRIP + wxWindow* m_oldFocus; + bool m_endModalCalled; // allow for closing within InitDialog #if wxUSE_TOOLBAR && defined(__POCKETPC__) wxToolBar* m_dialogToolBar; @@ -135,7 +133,7 @@ private: wxDialogModalData *m_modalData; DECLARE_DYNAMIC_CLASS(wxDialog) - wxDECLARE_NO_COPY_CLASS(wxDialog); + DECLARE_NO_COPY_CLASS(wxDialog) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/dib.h b/Source/3rd Party/wx/include/wx/msw/dib.h index cb8e8168f..71ae02bb7 100644 --- a/Source/3rd Party/wx/include/wx/msw/dib.h +++ b/Source/3rd Party/wx/include/wx/msw/dib.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.03.03 (replaces the old file with the same name) +// RCS-ID: $Id: dib.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 1997-2003 wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,21 +12,18 @@ #ifndef _WX_MSW_DIB_H_ #define _WX_MSW_DIB_H_ +class WXDLLIMPEXP_FWD_CORE wxBitmap; class WXDLLIMPEXP_FWD_CORE wxPalette; #include "wx/msw/private.h" #if wxUSE_WXDIB -#ifdef __WXMSW__ - #include "wx/bitmap.h" -#endif // __WXMSW__ - // ---------------------------------------------------------------------------- // wxDIB: represents a DIB section // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDIB +class WXDLLEXPORT wxDIB { public: // ctors and such @@ -39,11 +37,9 @@ public: wxDIB(int width, int height, int depth) { Init(); (void)Create(width, height, depth); } -#ifdef __WXMSW__ // create a DIB from the DDB wxDIB(const wxBitmap& bmp) { Init(); (void)Create(bmp); } -#endif // __WXMSW__ // create a DIB from the Windows DDB wxDIB(HBITMAP hbmp) @@ -57,9 +53,7 @@ public: // same as the corresponding ctors but with return value bool Create(int width, int height, int depth); -#ifdef __WXMSW__ - bool Create(const wxBitmap& bmp) { return Create(GetHbitmapOf(bmp)); } -#endif + bool Create(const wxBitmap& bmp); bool Create(HBITMAP hbmp); bool Load(const wxString& filename); @@ -144,28 +138,12 @@ public: // ------------------ #if wxUSE_IMAGE - // Possible formats for DIBs created by the functions below. - enum PixelFormat - { - PixelFormat_PreMultiplied = 0, - PixelFormat_NotPreMultiplied = 1 - }; - - // Create a DIB from the given image, the DIB will be either 24 or 32 (if - // the image has alpha channel) bpp. - // - // By default the DIB stores pixel data in pre-multiplied format so that it - // can be used with ::AlphaBlend() but it is also possible to disable - // pre-multiplication for the DIB to be usable with ImageList_Draw() which - // does pre-multiplication internally. - wxDIB(const wxImage& image, PixelFormat pf = PixelFormat_PreMultiplied) - { - Init(); - (void)Create(image, pf); - } + // create a DIB from the given image, the DIB will be either 24 or 32 (if + // the image has alpha channel) bpp + wxDIB(const wxImage& image) { Init(); (void)Create(image); } // same as the above ctor but with the return code - bool Create(const wxImage& image, PixelFormat pf = PixelFormat_PreMultiplied); + bool Create(const wxImage& image); // create wxImage having the same data as this DIB wxImage ConvertToImage() const; @@ -222,6 +200,11 @@ private: // the case bool m_ownsHandle; + // if true, we have alpha, if false we don't (note that we can still have + // m_depth == 32 but the last component is then simply padding and not + // alpha) + bool m_hasAlpha; + // DIBs can't be copied wxDIB(const wxDIB&); @@ -237,6 +220,7 @@ void wxDIB::Init() { m_handle = 0; m_ownsHandle = true; + m_hasAlpha = false; m_data = NULL; diff --git a/Source/3rd Party/wx/include/wx/msw/dirdlg.h b/Source/3rd Party/wx/include/wx/msw/dirdlg.h index 6e0e5a2b3..8e27d57e3 100644 --- a/Source/3rd Party/wx/include/wx/msw/dirdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/dirdlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: dirdlg.h 38956 2006-04-30 09:44:29Z RR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_DIRDLG_H_ #define _WX_DIRDLG_H_ -class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase +class WXDLLEXPORT wxDirDialog : public wxDirDialogBase { public: wxDirDialog(wxWindow *parent, @@ -27,11 +28,6 @@ public: virtual int ShowModal(); private: - // The real implementations of ShowModal(), used for Windows versions - // before and since Vista. - int ShowSHBrowseForFolder(WXHWND owner); - int ShowIFileDialog(WXHWND owner); - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDirDialog) }; diff --git a/Source/3rd Party/wx/include/wx/msw/dragimag.h b/Source/3rd Party/wx/include/wx/msw/dragimag.h index 9f3d67323..ce944200e 100644 --- a/Source/3rd Party/wx/include/wx/msw/dragimag.h +++ b/Source/3rd Party/wx/include/wx/msw/dragimag.h @@ -5,6 +5,7 @@ // Author: Julian Smart // Modified by: // Created: 08/04/99 +// RCS-ID: $Id: dragimag.h 45845 2007-05-05 19:00:35Z PC $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -98,7 +99,7 @@ * wxDragImage */ -class WXDLLIMPEXP_CORE wxDragImage: public wxObject +class WXDLLEXPORT wxDragImage: public wxObject { public: @@ -113,6 +114,14 @@ public: Create(image, cursor); } + // Deprecated form of the above + wxDragImage(const wxBitmap& image, const wxCursor& cursor, const wxPoint& cursorHotspot) + { + Init(); + + Create(image, cursor, cursorHotspot); + } + wxDragImage(const wxIcon& image, const wxCursor& cursor = wxNullCursor) { Init(); @@ -120,6 +129,14 @@ public: Create(image, cursor); } + // Deprecated form of the above + wxDragImage(const wxIcon& image, const wxCursor& cursor, const wxPoint& cursorHotspot) + { + Init(); + + Create(image, cursor, cursorHotspot); + } + wxDragImage(const wxString& str, const wxCursor& cursor = wxNullCursor) { Init(); @@ -127,6 +144,14 @@ public: Create(str, cursor); } + // Deprecated form of the above + wxDragImage(const wxString& str, const wxCursor& cursor, const wxPoint& cursorHotspot) + { + Init(); + + Create(str, cursor, cursorHotspot); + } + #if wxUSE_TREECTRL wxDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) { @@ -155,12 +180,27 @@ public: // Create a drag image from a bitmap and optional cursor bool Create(const wxBitmap& image, const wxCursor& cursor = wxNullCursor); + bool Create(const wxBitmap& image, const wxCursor& cursor, const wxPoint& WXUNUSED(cursorHotspot)) + { + wxLogDebug(wxT("wxDragImage::Create: use of a cursor hotspot is now deprecated. Please omit this argument.")); + return Create(image, cursor); + } // Create a drag image from an icon and optional cursor bool Create(const wxIcon& image, const wxCursor& cursor = wxNullCursor); + bool Create(const wxIcon& image, const wxCursor& cursor, const wxPoint& WXUNUSED(cursorHotspot)) + { + wxLogDebug(wxT("wxDragImage::Create: use of a cursor hotspot is now deprecated. Please omit this argument.")); + return Create(image, cursor); + } // Create a drag image from a string and optional cursor bool Create(const wxString& str, const wxCursor& cursor = wxNullCursor); + bool Create(const wxString& str, const wxCursor& cursor, const wxPoint& WXUNUSED(cursorHotspot)) + { + wxLogDebug(wxT("wxDragImage::Create: use of a cursor hotspot is now deprecated. Please omit this argument.")); + return Create(str, cursor); + } #if wxUSE_TREECTRL // Create a drag image for the given tree control item @@ -174,7 +214,7 @@ public: // Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. - bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = false, wxRect* rect = NULL); + bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = false, wxRect* rect = (wxRect*) NULL); // Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. This is full screen only. fullScreenRect gives the @@ -208,16 +248,6 @@ public: WXHIMAGELIST GetCursorHIMAGELIST() const { return m_hCursorImageList; } #endif - // don't use in new code, use versions without hot spot parameter -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_CONSTRUCTOR( wxDragImage(const wxBitmap& image, const wxCursor& cursor, const wxPoint& cursorHotspot) ); - wxDEPRECATED_CONSTRUCTOR( wxDragImage(const wxString& str, const wxCursor& cursor, const wxPoint& cursorHotspot) ); - wxDEPRECATED_CONSTRUCTOR( wxDragImage(const wxIcon& image, const wxCursor& cursor, const wxPoint& cursorHotspot) ); - wxDEPRECATED( bool Create(const wxBitmap& image, const wxCursor& cursor, const wxPoint& cursorHotspot) ); - wxDEPRECATED( bool Create(const wxIcon& image, const wxCursor& cursor, const wxPoint& cursorHotspot) ); - wxDEPRECATED( bool Create(const wxString& str, const wxCursor& cursor, const wxPoint& cursorHotspot) ); -#endif // WXWIN_COMPATIBILITY_2_8 - protected: WXHIMAGELIST m_hImageList; @@ -236,7 +266,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxDragImage) - wxDECLARE_NO_COPY_CLASS(wxDragImage); + DECLARE_NO_COPY_CLASS(wxDragImage) }; #endif // wxUSE_DRAGIMAGE diff --git a/Source/3rd Party/wx/include/wx/msw/enhmeta.h b/Source/3rd Party/wx/include/wx/msw/enhmeta.h index e7e19ca4a..59631b5af 100644 --- a/Source/3rd Party/wx/include/wx/msw/enhmeta.h +++ b/Source/3rd Party/wx/include/wx/msw/enhmeta.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 13.01.00 +// RCS-ID: $Id: enhmeta.h 60850 2009-06-01 10:16:13Z JS $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -12,22 +13,24 @@ #define _WX_MSW_ENHMETA_H_ #include "wx/dc.h" -#include "wx/gdiobj.h" #if wxUSE_DRAG_AND_DROP #include "wx/dataobj.h" #endif +// Change this to 1 if you set wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW to 1 in prntbase.cpp +#define wxUSE_ENH_METAFILE_FROM_DC 0 + // ---------------------------------------------------------------------------- // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxEnhMetaFile : public wxGDIObject +class WXDLLEXPORT wxEnhMetaFile : public wxObject { public: wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file) { Init(); } - wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxGDIObject() + wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxObject() { Init(); Assign(metafile); } wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile) { Free(); Assign(metafile); return *this; } @@ -36,10 +39,11 @@ public: { Free(); } // display the picture stored in the metafile on the given DC - bool Play(wxDC *dc, wxRect *rectBound = NULL); + bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL); // accessors - virtual bool IsOk() const { return m_hMF != 0; } + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_hMF != 0; } wxSize GetSize() const; int GetWidth() const { return GetSize().x; } @@ -61,11 +65,6 @@ protected: void Free(); void Assign(const wxEnhMetaFile& mf); - // we don't use these functions (but probably should) but have to implement - // them as they're pure virtual in the base class - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - private: wxString m_filename; WXHANDLE m_hMF; @@ -77,7 +76,7 @@ private: // wxEnhMetaFileDC: allows to create a wxEnhMetaFile // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxEnhMetaFileDC : public wxDC +class WXDLLEXPORT wxEnhMetaFileDC : public wxDC { public: // the ctor parameters specify the filename (empty for memory metafiles), @@ -86,18 +85,28 @@ public: int width = 0, int height = 0, const wxString& description = wxEmptyString); +#if wxUSE_ENH_METAFILE_FROM_DC // as above, but takes reference DC as first argument to take resolution, // size, font metrics etc. from - wxEXPLICIT wxEnhMetaFileDC(const wxDC& referenceDC, const wxString& filename = wxEmptyString, int width = 0, int height = 0, const wxString& description = wxEmptyString); +#endif + + virtual ~wxEnhMetaFileDC(); // obtain a pointer to the new metafile (caller should delete it) wxEnhMetaFile *Close(); +protected: + virtual void DoGetSize(int *width, int *height) const; + private: + // size passed to ctor and returned by DoGetSize() + int m_width, + m_height; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC) }; @@ -109,7 +118,7 @@ private: // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and // so we derive from wxDataObject and not from wxDataObjectSimple -class WXDLLIMPEXP_CORE wxEnhMetaFileDataObject : public wxDataObject +class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject { public: // ctors @@ -136,7 +145,7 @@ public: protected: wxEnhMetaFile m_metafile; - wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject); + DECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject) }; @@ -147,7 +156,7 @@ protected: // CF_ENHMETAFILE // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple +class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple { public: // ctors @@ -179,7 +188,7 @@ public: protected: wxEnhMetaFile m_metafile; - wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject); + DECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject) }; #endif // wxUSE_DRAG_AND_DROP diff --git a/Source/3rd Party/wx/include/wx/msw/evtloop.h b/Source/3rd Party/wx/include/wx/msw/evtloop.h index 68c1a0c9b..d6f4312ac 100644 --- a/Source/3rd Party/wx/include/wx/msw/evtloop.h +++ b/Source/3rd Party/wx/include/wx/msw/evtloop.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/msw/evtloop.h -// Purpose: wxEventLoop class for wxMSW port +// Purpose: wxEventLoop class for MSW // Author: Vadim Zeitlin // Modified by: // Created: 2004-07-31 +// RCS-ID: $Id: evtloop.h 36881 2006-01-15 10:13:40Z ABX $ // Copyright: (c) 2003-2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,30 +12,31 @@ #ifndef _WX_MSW_EVTLOOP_H_ #define _WX_MSW_EVTLOOP_H_ -#include "wx/dynarray.h" -#include "wx/msw/wrapwin.h" #include "wx/window.h" -#include "wx/msw/evtloopconsole.h" // for wxMSWEventLoopBase // ---------------------------------------------------------------------------- // wxEventLoop // ---------------------------------------------------------------------------- -WX_DECLARE_EXPORTED_OBJARRAY(MSG, wxMSGArray); - -class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase +class WXDLLEXPORT wxEventLoop : public wxEventLoopManual { public: - wxGUIEventLoop() { } + wxEventLoop(); - // process a single message: calls PreProcessMessage() before dispatching - // it - virtual void ProcessMessage(WXMSG *msg); + // implement base class pure virtuals + virtual bool Pending() const; + virtual bool Dispatch(); + + // MSW-specific methods + // -------------------- // preprocess a message, return true if processed (i.e. no further // dispatching required) virtual bool PreProcessMessage(WXMSG *msg); + // process a single message + virtual void ProcessMessage(WXMSG *msg); + // set the critical window: this is the window such that all the events // except those to this window (and its children) stop to be processed // (typical examples: assert or crash report dialog) @@ -50,22 +52,15 @@ public: return !ms_winCritical || IsChildOfCriticalWindow(win); } - // override/implement base class virtuals - virtual bool Dispatch(); - virtual int DispatchTimeout(unsigned long timeout); - virtual void WakeUp(); - virtual bool YieldFor(long eventsToProcess); - protected: + // override/implement base class virtuals + virtual void WakeUp(); virtual void OnNextIteration(); -private: // check if the given window is a child of ms_winCritical (which must be // non NULL) static bool IsChildOfCriticalWindow(wxWindowMSW *win); - // array of messages used for temporary storage by YieldFor() - wxMSGArray m_arrMSG; // critical window or NULL static wxWindowMSW *ms_winCritical; diff --git a/Source/3rd Party/wx/include/wx/msw/evtloopconsole.h b/Source/3rd Party/wx/include/wx/msw/evtloopconsole.h deleted file mode 100644 index 36da6f640..000000000 --- a/Source/3rd Party/wx/include/wx/msw/evtloopconsole.h +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/evtloopconsole.h -// Purpose: wxConsoleEventLoop class for Windows -// Author: Vadim Zeitlin -// Modified by: -// Created: 2004-07-31 -// Copyright: (c) 2003-2004 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_EVTLOOPCONSOLE_H_ -#define _WX_MSW_EVTLOOPCONSOLE_H_ - -class WXDLLIMPEXP_BASE wxMSWEventLoopBase : public wxEventLoopManual -{ -public: - wxMSWEventLoopBase(); - - // implement base class pure virtuals - virtual bool Pending() const; - -protected: - // get the next message from queue and return true or return false if we - // got WM_QUIT or an error occurred - bool GetNextMessage(WXMSG *msg); - - // same as above but with a timeout and return value can be -1 meaning that - // time out expired in addition to - int GetNextMessageTimeout(WXMSG *msg, unsigned long timeout); -}; - -#if wxUSE_CONSOLE_EVENTLOOP - -class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase -{ -public: - wxConsoleEventLoop() { } - - // override/implement base class virtuals - virtual bool Dispatch(); - virtual int DispatchTimeout(unsigned long timeout); - virtual void WakeUp(); - virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; } - - // Windows-specific function to process a single message - virtual void ProcessMessage(WXMSG *msg); -}; - -#endif // wxUSE_CONSOLE_EVENTLOOP - -#endif // _WX_MSW_EVTLOOPCONSOLE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/fdrepdlg.h b/Source/3rd Party/wx/include/wx/msw/fdrepdlg.h index 8bc582922..1e534ae85 100644 --- a/Source/3rd Party/wx/include/wx/msw/fdrepdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/fdrepdlg.h @@ -4,6 +4,7 @@ // Author: Markus Greither // Modified by: 31.07.01: VZ: integrated into wxWidgets // Created: 23/03/2001 +// RCS-ID: // Copyright: (c) Markus Greither // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxFindReplaceDialog: dialog for searching / replacing text // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFindReplaceDialog : public wxFindReplaceDialogBase +class WXDLLEXPORT wxFindReplaceDialog : public wxFindReplaceDialogBase { public: // ctors and such @@ -55,7 +56,7 @@ protected: wxFindReplaceDialogImpl *m_impl; DECLARE_DYNAMIC_CLASS(wxFindReplaceDialog) - wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialog); + DECLARE_NO_COPY_CLASS(wxFindReplaceDialog) }; #endif // _WX_MSW_FDREPDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/filedlg.h b/Source/3rd Party/wx/include/wx/msw/filedlg.h index c1eab6254..4608a2ed9 100644 --- a/Source/3rd Party/wx/include/wx/msw/filedlg.h +++ b/Source/3rd Party/wx/include/wx/msw/filedlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: filedlg.h 39402 2006-05-28 23:32:12Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxFileDialog //------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFileDialog: public wxFileDialogBase +class WXDLLEXPORT wxFileDialog: public wxFileDialogBase { public: wxFileDialog(wxWindow *parent, @@ -28,43 +29,26 @@ public: const wxSize& sz = wxDefaultSize, const wxString& name = wxFileDialogNameStr); + virtual void SetPath(const wxString& path); virtual void GetPaths(wxArrayString& paths) const; virtual void GetFilenames(wxArrayString& files) const; -#ifndef __WXWINCE__ - virtual bool SupportsExtraControl() const { return true; } - void MSWOnInitDialogHook(WXHWND hwnd); -#endif // __WXWINCE__ virtual int ShowModal(); - // wxMSW-specific implementation from now on - // ----------------------------------------- - - // called from the hook procedure on CDN_INITDONE reception - virtual void MSWOnInitDone(WXHWND hDlg); - - // called from the hook procedure on CDN_SELCHANGE. - void MSWOnSelChange(WXHWND hDlg); - protected: #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) virtual void DoMoveWindow(int x, int y, int width, int height); - virtual void DoCentre(int dir); virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetPosition( int *x, int *y ) const; #endif // !(__SMARTPHONE__ && __WXWINCE__) private: wxArrayString m_fileNames; - - // remember if our SetPosition() or Centre() (which requires special - // treatment) was called bool m_bMovedWindow; - int m_centreDir; // nothing to do if 0 DECLARE_DYNAMIC_CLASS(wxFileDialog) - wxDECLARE_NO_COPY_CLASS(wxFileDialog); + DECLARE_NO_COPY_CLASS(wxFileDialog) }; #endif // _WX_FILEDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/font.h b/Source/3rd Party/wx/include/wx/msw/font.h index 48d99cb20..925355dfb 100644 --- a/Source/3rd Party/wx/include/wx/msw/font.h +++ b/Source/3rd Party/wx/include/wx/msw/font.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: font.h 39411 2006-05-29 00:03:36Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,15 +18,12 @@ // wxFont // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFont : public wxFontBase +class WXDLLEXPORT wxFont : public wxFontBase { public: // ctors and such wxFont() { } - wxFont(const wxFontInfo& info); - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 wxFont(int size, int family, int style, @@ -34,34 +32,9 @@ public: const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { - (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); - } -#endif - - wxFont(int size, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { - Create(size, family, style, weight, underlined, face, encoding); + (void)Create(size, family, style, weight, underlined, face, encoding); } - bool Create(int size, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { - return DoCreate(size, wxDefaultSize, false, family, style, - weight, underlined, face, encoding); - } - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 wxFont(const wxSize& pixelSize, int family, int style, @@ -69,19 +42,6 @@ public: bool underlined = false, const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { - (void)Create(pixelSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, - underlined, face, encoding); - } -#endif - - wxFont(const wxSize& pixelSize, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, - bool underlined = false, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { (void)Create(pixelSize, family, style, weight, underlined, face, encoding); @@ -94,11 +54,22 @@ public: wxFont(const wxString& fontDesc); + bool Create(int size, + int family, + int style, + int weight, + bool underlined = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + return DoCreate(size, wxDefaultSize, false, family, style, + weight, underlined, face, encoding); + } bool Create(const wxSize& pixelSize, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, + int family, + int style, + int weight, bool underlined = false, const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT) @@ -111,30 +82,31 @@ public: virtual ~wxFont(); + // wxFontBase overridden functions + virtual wxString GetNativeFontInfoDesc() const; + virtual wxString GetNativeFontInfoUserDesc() const; + // implement base class pure virtuals virtual int GetPointSize() const; virtual wxSize GetPixelSize() const; virtual bool IsUsingSizeInPixels() const; - virtual wxFontStyle GetStyle() const; - virtual wxFontWeight GetWeight() const; + virtual int GetFamily() const; + virtual int GetStyle() const; + virtual int GetWeight() const; virtual bool GetUnderlined() const; - virtual bool GetStrikethrough() const; virtual wxString GetFaceName() const; virtual wxFontEncoding GetEncoding() const; virtual const wxNativeFontInfo *GetNativeFontInfo() const; virtual void SetPointSize(int pointSize); virtual void SetPixelSize(const wxSize& pixelSize); - virtual void SetFamily(wxFontFamily family); - virtual void SetStyle(wxFontStyle style); - virtual void SetWeight(wxFontWeight weight); + virtual void SetFamily(int family); + virtual void SetStyle(int style); + virtual void SetWeight(int weight); virtual bool SetFaceName(const wxString& faceName); virtual void SetUnderlined(bool underlined); - virtual void SetStrikethrough(bool strikethrough); virtual void SetEncoding(wxFontEncoding encoding); - wxDECLARE_COMMON_FONT_METHODS(); - virtual bool IsFixedWidth() const; // implementation only from now on @@ -148,24 +120,26 @@ public: // for consistency with other wxMSW classes WXHFONT GetHFONT() const; + /* + virtual bool UseResource(); + virtual bool ReleaseResource(); + */ + protected: // real font creation function, used in all cases bool DoCreate(int size, const wxSize& pixelSize, bool sizeUsingPixels, - wxFontFamily family, - wxFontStyle style, - wxFontWeight weight, + int family, + int style, + int weight, bool underlined = false, const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT); virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); - virtual wxFontFamily DoGetFamily() const; - // implement wxObject virtuals which are used by AllocExclusive() - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; + void Unshare(); private: DECLARE_DYNAMIC_CLASS(wxFont) diff --git a/Source/3rd Party/wx/include/wx/msw/fontdlg.h b/Source/3rd Party/wx/include/wx/msw/fontdlg.h index e5b49abc7..f3c3562d3 100644 --- a/Source/3rd Party/wx/include/wx/msw/fontdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/fontdlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: fontdlg.h 38448 2006-03-30 14:04:17Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxFontDialog // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFontDialog : public wxFontDialogBase +class WXDLLEXPORT wxFontDialog : public wxFontDialogBase { public: wxFontDialog() : wxFontDialogBase() { /* must be Create()d later */ } diff --git a/Source/3rd Party/wx/include/wx/msw/frame.h b/Source/3rd Party/wx/include/wx/msw/frame.h index 7fddcde1f..dc3a58be5 100644 --- a/Source/3rd Party/wx/include/wx/msw/frame.h +++ b/Source/3rd Party/wx/include/wx/msw/frame.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: frame.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_FRAME_H_ #define _WX_FRAME_H_ -class WXDLLIMPEXP_CORE wxFrame : public wxFrameBase +class WXDLLEXPORT wxFrame : public wxFrameBase { public: // construction @@ -41,6 +42,7 @@ public: // implement base class pure virtuals virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); + virtual void Raise(); // implementation only from now on // ------------------------------- @@ -58,7 +60,7 @@ public: // Status bar #if wxUSE_STATUSBAR virtual wxStatusBar* OnCreateStatusBar(int number = 1, - long style = wxSTB_DEFAULT_STYLE, + long style = wxST_SIZEGRIP, wxWindowID id = 0, const wxString& name = wxStatusLineNameStr); @@ -73,9 +75,16 @@ public: { return m_useNativeStatusBar; } #endif // wxUSE_STATUSBAR +#if wxUSE_MENUS + WXHMENU GetWinMenu() const { return m_hMenu; } +#endif // wxUSE_MENUS + // event handlers + bool HandlePaint(); bool HandleSize(int x, int y, WXUINT flag); bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); + bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu); + bool HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup); // tooltip management #if wxUSE_TOOLTIPS @@ -83,8 +92,9 @@ public: void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; } #endif // tooltips - // override the base class function to handle iconized/maximized frames - virtual void SendSizeEvent(int flags = 0); + // a MSW only function which sends a size event to the window using its + // current size - this has an effect of refreshing the window layout + virtual void SendSizeEvent(); virtual wxPoint GetClientAreaOrigin() const; @@ -99,15 +109,6 @@ public: WXWPARAM wParam, WXLPARAM lParam); -#if wxUSE_MENUS - // get the currently active menu: this is the same as the frame menu for - // normal frames but is overridden by wxMDIParentFrame - virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; } - - // Look up the menu in the menu bar. - virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu); -#endif // wxUSE_MENUS - protected: // common part of all ctors void Init(); @@ -132,6 +133,9 @@ protected: // wxMDIChildFrame bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg); + // handle WM_INITMENUPOPUP message to generate wxEVT_MENU_OPEN + bool HandleInitMenuPopup(WXHMENU hMenu); + virtual bool IsMDIChild() const { return false; } // get default (wxWidgets) icon for the frame diff --git a/Source/3rd Party/wx/include/wx/msw/fswatcher.h b/Source/3rd Party/wx/include/wx/msw/fswatcher.h deleted file mode 100644 index b73ee6618..000000000 --- a/Source/3rd Party/wx/include/wx/msw/fswatcher.h +++ /dev/null @@ -1,37 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/fswatcher.h -// Purpose: wxMSWFileSystemWatcher -// Author: Bartosz Bekier -// Created: 2009-05-26 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_FSWATCHER_MSW_H_ -#define _WX_FSWATCHER_MSW_H_ - -#include "wx/defs.h" - -#if wxUSE_FSWATCHER - -class WXDLLIMPEXP_BASE wxMSWFileSystemWatcher : public wxFileSystemWatcherBase -{ -public: - wxMSWFileSystemWatcher(); - - wxMSWFileSystemWatcher(const wxFileName& path, - int events = wxFSW_EVENT_ALL); - - // Override the base class function to provide a much more efficient - // implementation for it using the platform native support for watching the - // entire directory trees. - virtual bool AddTree(const wxFileName& path, int events = wxFSW_EVENT_ALL, - const wxString& filter = wxEmptyString); - -protected: - bool Init(); -}; - -#endif // wxUSE_FSWATCHER - -#endif /* _WX_FSWATCHER_MSW_H_ */ diff --git a/Source/3rd Party/wx/include/wx/msw/gauge.h b/Source/3rd Party/wx/include/wx/msw/gauge95.h similarity index 53% rename from Source/3rd Party/wx/include/wx/msw/gauge.h rename to Source/3rd Party/wx/include/wx/msw/gauge95.h index ac820e99b..c6c74df20 100644 --- a/Source/3rd Party/wx/include/wx/msw/gauge.h +++ b/Source/3rd Party/wx/include/wx/msw/gauge95.h @@ -1,34 +1,35 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/gauge.h -// Purpose: wxGauge implementation for MSW +// Name: gauge95.h +// Purpose: wxGauge95 class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: gauge95.h 43881 2006-12-09 19:48:21Z PC $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_GAUGE_H_ -#define _WX_MSW_GAUGE_H_ +#ifndef _GAUGE95_H_ +#define _GAUGE95_H_ #if wxUSE_GAUGE -extern WXDLLIMPEXP_DATA_CORE(const char) wxGaugeNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxGaugeNameStr[]; // Group box -class WXDLLIMPEXP_CORE wxGauge : public wxGaugeBase +class WXDLLEXPORT wxGauge95 : public wxGaugeBase { public: - wxGauge() { } + wxGauge95() { } - wxGauge(wxWindow *parent, - wxWindowID id, - int range, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxGA_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxGaugeNameStr) + wxGauge95(wxWindow *parent, + wxWindowID id, + int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxGA_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxGaugeNameStr) { (void)Create(parent, id, range, pos, size, style, validator, name); } @@ -46,32 +47,24 @@ public: virtual void SetRange(int range); virtual void SetValue(int pos); - // overridden base class virtuals + // overriden base class virtuals virtual bool SetForegroundColour(const wxColour& col); virtual bool SetBackgroundColour(const wxColour& col); - virtual void Pulse(); + + void SetIndeterminateMode(); + void SetDeterminateMode(); + void Pulse(); WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: virtual wxSize DoGetBestSize() const; -private: - // returns true if the control is currently in indeterminate (a.k.a. - // "marquee") mode - bool IsInIndeterminateMode() const; - - // switch to/from indeterminate mode - void SetIndeterminateMode(); - void SetDeterminateMode(); - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge95) }; #endif // wxUSE_GAUGE -#endif // _WX_MSW_GAUGE_H_ +#endif + // _GAUGEMSW_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/gccpriv.h b/Source/3rd Party/wx/include/wx/msw/gccpriv.h index c1962799a..db4c72a84 100644 --- a/Source/3rd Party/wx/include/wx/msw/gccpriv.h +++ b/Source/3rd Party/wx/include/wx/msw/gccpriv.h @@ -4,6 +4,7 @@ Author: Vadim Zeitlin Modified by: Created: + RCS-ID: $Id: gccpriv.h 36155 2005-11-10 16:16:05Z ABX $ Copyright: (c) Vadim Zeitlin Licence: wxWindows Licence */ @@ -17,51 +18,8 @@ #define __GNUWIN32__ #endif -#if defined(__MINGW32__) - /* - Include the header defining __MINGW32_{MAJ,MIN}OR_VERSION but check - that UNICODE or _UNICODE is already defined, as _mingw.h relies on them - being set and we'd get weird compilation errors later if it is included - without them being defined, better give a clearer error right now. - */ - #if !defined(UNICODE) - #ifndef wxUSE_UNICODE - #error "wxUSE_UNICODE must be defined before including this header." - #endif - #if wxUSE_UNICODE - #error "UNICODE must be defined before including this header." - #endif - #endif - +#if defined(__MINGW32__) && ( ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) ) ) #include <_mingw.h> - - /* - MinGW-w64 project provides compilers for both Win32 and Win64 but only - defines the same __MINGW32__ symbol for the former as MinGW32 toolchain - which is quite different (notably doesn't provide many SDK headers that - MinGW-w64 does include). So we define a separate symbol which, unlike - the predefined __MINGW64__, can be used to detect this toolchain in - both 32 and 64 bit builds. - - And define __MINGW32_TOOLCHAIN__ for consistency and also because it's - convenient as we often want to have some workarounds only for the (old) - MinGW32 but not (newer) MinGW-w64, which still predefines __MINGW32__. - */ - #ifdef __MINGW64_VERSION_MAJOR - #ifndef __MINGW64_TOOLCHAIN__ - #define __MINGW64_TOOLCHAIN__ - #endif - #else - #ifndef __MINGW32_TOOLCHAIN__ - #define __MINGW32_TOOLCHAIN__ - #endif - #endif - - #define wxCHECK_MINGW32_VERSION( major, minor ) \ - ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \ - || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) ) -#else - #define wxCHECK_MINGW32_VERSION( major, minor ) (0) #endif #if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H ) @@ -116,6 +74,15 @@ #define __CYGWIN10__ #endif +/* Check for Mingw runtime version: */ +#if defined(__MINGW32_MAJOR_VERSION) && defined(__MINGW32_MINOR_VERSION) + #define wxCHECK_MINGW32_VERSION( major, minor ) \ + ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \ + || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) ) +#else + #define wxCHECK_MINGW32_VERSION( major, minor ) (0) +#endif + /* Mingw runtime 1.0-20010604 has some missing _tXXXX functions, so let's define them ourselves: */ #if defined(__GNUWIN32__) && wxCHECK_W32API_VERSION( 1, 0 ) \ diff --git a/Source/3rd Party/wx/include/wx/msw/gdiimage.h b/Source/3rd Party/wx/include/wx/msw/gdiimage.h index 38520c9fa..d78f5b620 100644 --- a/Source/3rd Party/wx/include/wx/msw/gdiimage.h +++ b/Source/3rd Party/wx/include/wx/msw/gdiimage.h @@ -1,10 +1,11 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/gdiimage.h +// Name: include/wx/msw/gdiimage.h // Purpose: wxGDIImage class: base class for wxBitmap, wxIcon, wxCursor // under MSW // Author: Vadim Zeitlin // Modified by: // Created: 20.11.99 +// RCS-ID: $Id: gdiimage.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 1999 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ WX_DECLARE_EXPORTED_LIST(wxGDIImageHandler, wxGDIImageHandlerList); // wxGDIImageRefData: common data fields for all derived classes // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGDIImageRefData : public wxGDIRefData +class WXDLLEXPORT wxGDIImageRefData : public wxGDIRefData { public: wxGDIImageRefData() @@ -39,7 +40,7 @@ public: m_handle = 0; } - wxGDIImageRefData(const wxGDIImageRefData& data) : wxGDIRefData() + wxGDIImageRefData(const wxGDIImageRefData& data) : wxGDIRefData(data) { m_width = data.m_width; m_height = data.m_height; @@ -50,7 +51,7 @@ public: } // accessors - virtual bool IsOk() const { return m_handle != 0; } + bool IsOk() const { return m_handle != 0; } void SetSize(int w, int h) { m_width = w; m_height = h; } @@ -75,13 +76,58 @@ public: }; }; +// ---------------------------------------------------------------------------- +// wxGDIImageHandler: a class which knows how to load/save wxGDIImages. +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxGDIImageHandler : public wxObject +{ +public: + // ctor + wxGDIImageHandler() { m_type = wxBITMAP_TYPE_INVALID; } + wxGDIImageHandler(const wxString& name, + const wxString& ext, + long type) + : m_name(name), m_extension(ext) + { + m_type = type; + } + + // accessors + void SetName(const wxString& name) { m_name = name; } + void SetExtension(const wxString& ext) { m_extension = ext; } + void SetType(long type) { m_type = type; } + + const wxString& GetName() const { return m_name; } + const wxString& GetExtension() const { return m_extension; } + long GetType() const { return m_type; } + + // real handler operations: to implement in derived classes + virtual bool Create(wxGDIImage *image, + const void* data, + long flags, + int width, int height, int depth = 1) = 0; + virtual bool Load(wxGDIImage *image, + const wxString& name, + long flags, + int desiredWidth, int desiredHeight) = 0; + virtual bool Save(wxGDIImage *image, + const wxString& name, + int type) = 0; + +protected: + wxString m_name; + wxString m_extension; + long m_type; +}; + // ---------------------------------------------------------------------------- // wxGDIImage: this class supports GDI image handlers which may be registered // dynamically and will be used for loading/saving the images in the specified // format. It also falls back to wxImage if no appropriate image is found. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGDIImage : public wxGDIObject +class WXDLLEXPORT wxGDIImage : public wxGDIObject { public: // handlers list interface @@ -108,16 +154,13 @@ public: void SetHandle(WXHANDLE handle) { AllocExclusive(); GetGDIImageData()->m_handle = handle; } + bool Ok() const { return IsOk(); } + bool IsOk() const { return GetHandle() != 0; } + int GetWidth() const { return IsNull() ? 0 : GetGDIImageData()->m_width; } int GetHeight() const { return IsNull() ? 0 : GetGDIImageData()->m_height; } int GetDepth() const { return IsNull() ? 0 : GetGDIImageData()->m_depth; } - wxSize GetSize() const - { - return IsNull() ? wxSize(0,0) : - wxSize(GetGDIImageData()->m_width, GetGDIImageData()->m_height); - } - void SetWidth(int w) { AllocExclusive(); GetGDIImageData()->m_width = w; } void SetHeight(int h) { AllocExclusive(); GetGDIImageData()->m_height = h; } void SetDepth(int d) { AllocExclusive(); GetGDIImageData()->m_depth = d; } @@ -137,61 +180,10 @@ protected: // create the data for the derived class here virtual wxGDIImageRefData *CreateData() const = 0; - // implement the wxGDIObject method in terms of our, more specific, one - virtual wxGDIRefData *CreateGDIRefData() const { return CreateData(); } - - // we can't [efficiently] clone objects of this class - virtual wxGDIRefData * - CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const - { - wxFAIL_MSG( wxT("must be implemented if used") ); - - return NULL; - } + // implement the wxObject method in terms of our, more specific, one + virtual wxObjectRefData *CreateRefData() const { return CreateData(); } static wxGDIImageHandlerList ms_handlers; }; -// ---------------------------------------------------------------------------- -// wxGDIImageHandler: a class which knows how to load/save wxGDIImages. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGDIImageHandler : public wxObject -{ -public: - // ctor - wxGDIImageHandler() { m_type = wxBITMAP_TYPE_INVALID; } - wxGDIImageHandler(const wxString& name, - const wxString& ext, - wxBitmapType type) - : m_name(name), m_extension(ext), m_type(type) { } - - // accessors - void SetName(const wxString& name) { m_name = name; } - void SetExtension(const wxString& ext) { m_extension = ext; } - void SetType(wxBitmapType type) { m_type = type; } - - const wxString& GetName() const { return m_name; } - const wxString& GetExtension() const { return m_extension; } - wxBitmapType GetType() const { return m_type; } - - // real handler operations: to implement in derived classes - virtual bool Create(wxGDIImage *image, - const void* data, - wxBitmapType flags, - int width, int height, int depth = 1) = 0; - virtual bool Load(wxGDIImage *image, - const wxString& name, - wxBitmapType flags, - int desiredWidth, int desiredHeight) = 0; - virtual bool Save(const wxGDIImage *image, - const wxString& name, - wxBitmapType type) const = 0; - -protected: - wxString m_name; - wxString m_extension; - wxBitmapType m_type; -}; - #endif // _WX_MSW_GDIIMAGE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/genrcdefs.h b/Source/3rd Party/wx/include/wx/msw/genrcdefs.h index 3cdb012ed..d96634cfe 100644 --- a/Source/3rd Party/wx/include/wx/msw/genrcdefs.h +++ b/Source/3rd Party/wx/include/wx/msw/genrcdefs.h @@ -2,6 +2,7 @@ * Name: wx/msw/genrcdefs.h * Purpose: Emit preprocessor symbols into rcdefs.h for resource compiler * Author: Mike Wetherell + * RCS-ID: $Id: genrcdefs.h 36133 2005-11-08 22:49:46Z MW $ * Copyright: (c) 2005 Mike Wetherell * Licence: wxWindows licence */ @@ -12,14 +13,10 @@ EMIT(#ifndef _WX_RCDEFS_H) EMIT(#define _WX_RCDEFS_H) #ifdef _MSC_FULL_VER -#if _MSC_FULL_VER < 140040130 -EMIT(#define wxUSE_RC_MANIFEST 1) -#endif -#else -EMIT(#define wxUSE_RC_MANIFEST 1) +EMIT(#define WX_MSC_FULL_VER _MSC_FULL_VER) #endif -#if defined _M_AMD64 || defined __x86_64__ +#ifdef _M_AMD64 EMIT(#define WX_CPU_AMD64) #endif @@ -27,7 +24,7 @@ EMIT(#define WX_CPU_AMD64) EMIT(#define WX_CPU_ARM) #endif -#if defined _M_IA64 || defined __ia64__ +#ifdef _M_IA64 EMIT(#define WX_CPU_IA64) #endif diff --git a/Source/3rd Party/wx/include/wx/msw/glcanvas.h b/Source/3rd Party/wx/include/wx/msw/glcanvas.h deleted file mode 100644 index 52b82f42a..000000000 --- a/Source/3rd Party/wx/include/wx/msw/glcanvas.h +++ /dev/null @@ -1,158 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/glcanvas.h -// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GLCANVAS_H_ -#define _WX_GLCANVAS_H_ - -#include "wx/palette.h" - -#include "wx/msw/wrapwin.h" - -#include - -// ---------------------------------------------------------------------------- -// wxGLContext: OpenGL rendering context -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase -{ -public: - wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL); - virtual ~wxGLContext(); - - virtual bool SetCurrent(const wxGLCanvas& win) const; - - HGLRC GetGLRC() const { return m_glContext; } - -protected: - HGLRC m_glContext; - -private: - DECLARE_CLASS(wxGLContext) -}; - -// ---------------------------------------------------------------------------- -// wxGLCanvas: OpenGL output window -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase -{ -public: - wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas - wxGLCanvas(wxWindow *parent, - wxWindowID id = wxID_ANY, - const int *attribList = NULL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const wxPalette& palette = wxNullPalette); - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const int *attribList = NULL, - const wxPalette& palette = wxNullPalette); - - virtual ~wxGLCanvas(); - - // implement wxGLCanvasBase methods - virtual bool SwapBuffers(); - - - // MSW-specific helpers - // -------------------- - - // get the HDC used for OpenGL rendering - HDC GetHDC() const { return m_hDC; } - - // try to find pixel format matching the given attributes list for the - // specified HDC, return 0 on error, otherwise pfd is filled in with the - // information from attribList if non-NULL - static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList, - PIXELFORMATDESCRIPTOR *pfd = NULL); - -#if wxUSE_PALETTE - // palette stuff - bool SetupPalette(const wxPalette& palette); - virtual wxPalette CreateDefaultPalette(); - void OnQueryNewPalette(wxQueryNewPaletteEvent& event); - void OnPaletteChanged(wxPaletteChangedEvent& event); -#endif // wxUSE_PALETTE - - // deprecated methods using the implicit wxGLContext, associate the context - // explicitly with the window instead -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( - wxGLCanvas(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const int *attribList = NULL, - const wxPalette& palette = wxNullPalette) - ); - - wxDEPRECATED( - wxGLCanvas(wxWindow *parent, - const wxGLContext *shared, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const int *attribList = NULL, - const wxPalette& palette = wxNullPalette) - ); - - wxDEPRECATED( - wxGLCanvas(wxWindow *parent, - const wxGLCanvas *shared, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const int *attribList = NULL, - const wxPalette& palette = wxNullPalette) - ); -#endif // WXWIN_COMPATIBILITY_2_8 - -protected: - // common part of all ctors - void Init(); - - // the real window creation function, Create() may reuse it twice as we may - // need to create an OpenGL window to query the available extensions and - // then potentially delete and recreate it with another pixel format - bool CreateWindow(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName); - - // set up the pixel format using the given attributes and palette - int DoSetup(PIXELFORMATDESCRIPTOR &pfd, const int *attribList); - - - // HDC for this window, we keep it all the time - HDC m_hDC; - -private: - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxGLCanvas) -}; - -#endif // _WX_GLCANVAS_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/gsockmsw.h b/Source/3rd Party/wx/include/wx/msw/gsockmsw.h new file mode 100644 index 000000000..6e5486992 --- /dev/null +++ b/Source/3rd Party/wx/include/wx/msw/gsockmsw.h @@ -0,0 +1,145 @@ +/* ------------------------------------------------------------------------- + * Project: GSocket (Generic Socket) for WX + * Name: gsockmsw.h + * Copyright: (c) Guilhem Lavaux + * Licence: wxWindows Licence + * Purpose: GSocket MSW header + * CVSID: $Id: gsockmsw.h 33948 2005-05-04 18:57:50Z JS $ + * ------------------------------------------------------------------------- + */ + +#ifndef __GSOCK_MSW_H +#define __GSOCK_MSW_H + +#ifndef __GSOCKET_STANDALONE__ +#include "wx/setup.h" +#endif + +#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) + +#ifndef __GSOCKET_STANDALONE__ +#include "wx/gsocket.h" +#else +#include "gsocket.h" +#endif + +#include "wx/msw/wrapwin.h" + +#if defined(__CYGWIN__) + //CYGWIN gives annoying warning about runtime stuff if we don't do this +# define USE_SYS_TYPES_FD_SET +# include +#endif + +#if defined(__WXWINCE__) || defined(__CYGWIN__) || defined(__WXMSW__) +#include +#endif + +class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable +{ +public: + virtual bool OnInit(); + virtual void OnExit(); + virtual bool CanUseEventLoop(); + virtual bool Init_Socket(GSocket *socket); + virtual void Destroy_Socket(GSocket *socket); + virtual void Enable_Events(GSocket *socket); + virtual void Disable_Events(GSocket *socket); +}; + +/* Definition of GSocket */ +class GSocket +{ +public: + GSocket(); + ~GSocket(); + bool IsOk() { return m_ok; } + void Close(); + void Shutdown(); + GSocketError SetLocal(GAddress *address); + GSocketError SetPeer(GAddress *address); + GAddress *GetLocal(); + GAddress *GetPeer(); + GSocketError SetServer(); + GSocket *WaitConnection(); + bool SetReusable(); + GSocketError Connect(GSocketStream stream); + GSocketError SetNonOriented(); + int Read(char *buffer, int size); + int Write(const char *buffer, int size); + GSocketEventFlags Select(GSocketEventFlags flags); + void SetNonBlocking(bool non_block); + void SetTimeout(unsigned long millis); + GSocketError WXDLLIMPEXP_NET GetError(); + void SetCallback(GSocketEventFlags flags, + GSocketCallback callback, char *cdata); + void UnsetCallback(GSocketEventFlags flags); + GSocketError GetSockOpt(int level, int optname, + void *optval, int *optlen); + GSocketError SetSockOpt(int level, int optname, + const void *optval, int optlen); +protected: + GSocketError Input_Timeout(); + GSocketError Output_Timeout(); + GSocketError Connect_Timeout(); + int Recv_Stream(char *buffer, int size); + int Recv_Dgram(char *buffer, int size); + int Send_Stream(const char *buffer, int size); + int Send_Dgram(const char *buffer, int size); + bool m_ok; + +/* TODO: Make these protected */ +public: + SOCKET m_fd; + GAddress *m_local; + GAddress *m_peer; + GSocketError m_error; + + /* Attributes */ + bool m_non_blocking; + bool m_server; + bool m_stream; + bool m_establishing; + bool m_reusable; + struct timeval m_timeout; + + /* Callbacks */ + GSocketEventFlags m_detected; + GSocketCallback m_cbacks[GSOCK_MAX_EVENT]; + char *m_data[GSOCK_MAX_EVENT]; + int m_msgnumber; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Definition of GAddress */ +struct _GAddress +{ + struct sockaddr *m_addr; + size_t m_len; + + GAddressType m_family; + int m_realfamily; + + GSocketError m_error; +}; + + +/* GAddress */ + +GSocketError _GAddress_translate_from(GAddress *address, + struct sockaddr *addr, int len); +GSocketError _GAddress_translate_to (GAddress *address, + struct sockaddr **addr, int *len); +GSocketError _GAddress_Init_INET(GAddress *address); +GSocketError _GAddress_Init_UNIX(GAddress *address); + +#ifdef __cplusplus +} +#endif + +#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */ + +#endif /* __GSOCK_MSW_H */ diff --git a/Source/3rd Party/wx/include/wx/msw/headerctrl.h b/Source/3rd Party/wx/include/wx/msw/headerctrl.h deleted file mode 100644 index db702c5a1..000000000 --- a/Source/3rd Party/wx/include/wx/msw/headerctrl.h +++ /dev/null @@ -1,136 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/headerctrl.h -// Purpose: wxMSW native wxHeaderCtrl -// Author: Vadim Zeitlin -// Created: 2008-12-01 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_HEADERCTRL_H_ -#define _WX_MSW_HEADERCTRL_H_ - -class WXDLLIMPEXP_FWD_CORE wxImageList; - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase -{ -public: - wxHeaderCtrl() - { - Init(); - } - - wxHeaderCtrl(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHD_DEFAULT_STYLE, - const wxString& name = wxHeaderCtrlNameStr); - - virtual ~wxHeaderCtrl(); - - -protected: - // override wxWindow methods which must be implemented by a new control - virtual wxSize DoGetBestSize() const; - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - -private: - // implement base class pure virtuals - virtual void DoSetCount(unsigned int count); - virtual unsigned int DoGetCount() const; - virtual void DoUpdate(unsigned int idx); - - virtual void DoScrollHorz(int dx); - - virtual void DoSetColumnsOrder(const wxArrayInt& order); - virtual wxArrayInt DoGetColumnsOrder() const; - - // override MSW-specific methods needed for new control - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - - // common part of all ctors - void Init(); - - // wrapper around Header_InsertItem(): insert the item using information - // from the given column at the given index - void DoInsertItem(const wxHeaderColumn& col, unsigned int idx); - - // get the number of currently visible items: this is also the total number - // of items contained in the native control - int GetShownColumnsCount() const; - - // due to the discrepancy for the hidden columns which we know about but - // the native control does not, there can be a difference between the - // column indices we use and the ones used by the native control; these - // functions translate between them - // - // notice that MSWToNativeIdx() shouldn't be called for hidden columns and - // MSWFromNativeIdx() always returns an index of a visible column - int MSWToNativeIdx(int idx); - int MSWFromNativeIdx(int item); - - // this is the same as above but for order, not index - int MSWToNativeOrder(int order); - int MSWFromNativeOrder(int order); - - // get the event type corresponding to a click or double click event - // (depending on dblclk value) with the specified (using MSW convention) - // mouse button - wxEventType GetClickEventType(bool dblclk, int button); - - - // the number of columns in the control, including the hidden ones (not - // taken into account by the native control, see comment in DoGetCount()) - unsigned int m_numColumns; - - // this is a lookup table allowing us to check whether the column with the - // given index is currently shown in the native control, in which case the - // value of this array element with this index is 0, or hidden - // - // notice that this may be different from GetColumn(idx).IsHidden() and in - // fact we need this array precisely because it will be different from it - // in DoUpdate() when the column hidden flag gets toggled and we need it to - // handle this transition correctly - wxArrayInt m_isHidden; - - // the order of our columns: this array contains the index of the column - // shown at the position n as the n-th element - // - // this is necessary only to handle the hidden columns: the native control - // doesn't know about them and so we can't use Header_GetOrderArray() - wxArrayInt m_colIndices; - - // the image list: initially NULL, created on demand - wxImageList *m_imageList; - - // the offset of the window used to emulate scrolling it - int m_scrollOffset; - - // actual column we are dragging or -1 if not dragging anything - int m_colBeingDragged; - - wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl); -}; - -#endif // _WX_MSW_HEADERCTRL_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/helpbest.h b/Source/3rd Party/wx/include/wx/msw/helpbest.h deleted file mode 100644 index 4deffa4ad..000000000 --- a/Source/3rd Party/wx/include/wx/msw/helpbest.h +++ /dev/null @@ -1,128 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/helpbest.h -// Purpose: Tries to load MS HTML Help, falls back to wxHTML upon failure -// Author: Mattia Barbon -// Modified by: -// Created: 02/04/2001 -// Copyright: (c) Mattia Barbon -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HELPBEST_H_ -#define _WX_HELPBEST_H_ - -#if wxUSE_HELP && wxUSE_MS_HTML_HELP \ - && wxUSE_WXHTML_HELP && !defined(__WXUNIVERSAL__) - -#include "wx/helpbase.h" -#include "wx/html/helpfrm.h" // for wxHF_DEFAULT_STYLE - -class WXDLLIMPEXP_HTML wxBestHelpController: public wxHelpControllerBase -{ -public: - wxBestHelpController(wxWindow* parentWindow = NULL, - int style = wxHF_DEFAULT_STYLE) - : wxHelpControllerBase(parentWindow), - m_helpControllerType(wxUseNone), - m_helpController(NULL), - m_style(style) - { - } - - virtual ~wxBestHelpController() { delete m_helpController; } - - // Must call this to set the filename - virtual bool Initialize(const wxString& file); - virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize( file ); } - - // If file is "", reloads file given in Initialize - virtual bool LoadFile(const wxString& file = wxEmptyString) - { - return m_helpController->LoadFile( GetValidFilename( file ) ); - } - - virtual bool DisplayContents() - { - return m_helpController->DisplayContents(); - } - - virtual bool DisplaySection(int sectionNo) - { - return m_helpController->DisplaySection( sectionNo ); - } - - virtual bool DisplaySection(const wxString& section) - { - return m_helpController->DisplaySection( section ); - } - - virtual bool DisplayBlock(long blockNo) - { - return m_helpController->DisplayBlock( blockNo ); - } - - virtual bool DisplayContextPopup(int contextId) - { - return m_helpController->DisplayContextPopup( contextId ); - } - - virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos) - { - return m_helpController->DisplayTextPopup( text, pos ); - } - - virtual bool KeywordSearch(const wxString& k, - wxHelpSearchMode mode = wxHELP_SEARCH_ALL) - { - return m_helpController->KeywordSearch( k, mode ); - } - - virtual bool Quit() - { - return m_helpController->Quit(); - } - - // Allows one to override the default settings for the help frame. - virtual void SetFrameParameters(const wxString& title, - const wxSize& size, - const wxPoint& pos = wxDefaultPosition, - bool newFrameEachTime = false) - { - m_helpController->SetFrameParameters( title, size, pos, - newFrameEachTime ); - } - - // Obtains the latest settings used by the help frame and the help frame. - virtual wxFrame *GetFrameParameters(wxSize *size = NULL, - wxPoint *pos = NULL, - bool *newFrameEachTime = NULL) - { - return m_helpController->GetFrameParameters( size, pos, - newFrameEachTime ); - } - - /// Set the window that can optionally be used for the help window's parent. - virtual void SetParentWindow(wxWindow* win) { m_helpController->SetParentWindow(win); } - - /// Get the window that can optionally be used for the help window's parent. - virtual wxWindow* GetParentWindow() const { return m_helpController->GetParentWindow(); } - -protected: - // Append/change extension if necessary. - wxString GetValidFilename(const wxString& file) const; - -protected: - enum HelpControllerType { wxUseNone, wxUseHtmlHelp, wxUseChmHelp }; - - HelpControllerType m_helpControllerType; - wxHelpControllerBase* m_helpController; - int m_style; - - DECLARE_DYNAMIC_CLASS(wxBestHelpController) - wxDECLARE_NO_COPY_CLASS(wxBestHelpController); -}; - -#endif // wxUSE_HELP && wxUSE_MS_HTML_HELP && wxUSE_WXHTML_HELP - -#endif - // _WX_HELPBEST_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/helpchm.h b/Source/3rd Party/wx/include/wx/msw/helpchm.h index 29a338672..a6c3e8440 100644 --- a/Source/3rd Party/wx/include/wx/msw/helpchm.h +++ b/Source/3rd Party/wx/include/wx/msw/helpchm.h @@ -1,21 +1,22 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/helpchm.h +// Name: helpchm.h // Purpose: Help system: MS HTML Help implementation // Author: Julian Smart // Modified by: // Created: 16/04/2000 +// RCS-ID: $Id: helpchm.h 39725 2006-06-14 17:46:51Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_HELPCHM_H_ -#define _WX_MSW_HELPCHM_H_ +#ifndef _WX_HELPCHM_H_ +#define _WX_HELPCHM_H_ #if wxUSE_MS_HTML_HELP #include "wx/helpbase.h" -class WXDLLIMPEXP_CORE wxCHMHelpController : public wxHelpControllerBase +class WXDLLEXPORT wxCHMHelpController : public wxHelpControllerBase { public: wxCHMHelpController(wxWindow* parentWindow = NULL): wxHelpControllerBase(parentWindow) { } @@ -44,46 +45,16 @@ public: wxWindow *window); protected: - // get the name of the CHM file we use from our m_helpFile - wxString GetValidFilename() const; - - // Call HtmlHelp() with the provided parameters (both overloads do the same - // thing but allow to avoid casts in the calling code) and return false - // (but don't crash) if HTML help is unavailable - static bool CallHtmlHelp(wxWindow *win, const wxChar *str, - unsigned cmd, WXWPARAM param); - static bool CallHtmlHelp(wxWindow *win, const wxChar *str, - unsigned cmd, const void *param = NULL) - { - return CallHtmlHelp(win, str, cmd, reinterpret_cast(param)); - } - - // even simpler wrappers using GetParentWindow() and GetValidFilename() as - // the first 2 HtmlHelp() parameters - bool CallHtmlHelp(unsigned cmd, WXWPARAM param) - { - return CallHtmlHelp(GetParentWindow(), GetValidFilename().t_str(), - cmd, param); - } - - bool CallHtmlHelp(unsigned cmd, const void *param = NULL) - { - return CallHtmlHelp(cmd, reinterpret_cast(param)); - } - - // wrapper around CallHtmlHelp(HH_DISPLAY_TEXT_POPUP): only one of text and - // contextId parameters can be non-NULL/non-zero - static bool DoDisplayTextPopup(const wxChar *text, - const wxPoint& pos, - int contextId, - wxWindow *window); - + // Append extension if necessary. + wxString GetValidFilename(const wxString& file) const; +protected: wxString m_helpFile; - DECLARE_DYNAMIC_CLASS(wxCHMHelpController) + DECLARE_CLASS(wxCHMHelpController) }; #endif // wxUSE_MS_HTML_HELP -#endif // _WX_MSW_HELPCHM_H_ +#endif +// _WX_HELPCHM_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/helpwin.h b/Source/3rd Party/wx/include/wx/msw/helpwin.h index 8439fbe82..e563c8e9c 100644 --- a/Source/3rd Party/wx/include/wx/msw/helpwin.h +++ b/Source/3rd Party/wx/include/wx/msw/helpwin.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/helpwin.h +// Name: helpwin.h // Purpose: Help system: WinHelp implementation // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: helpwin.h 41020 2006-09-05 20:47:48Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,9 +18,9 @@ #include "wx/helpbase.h" -class WXDLLIMPEXP_CORE wxWinHelpController: public wxHelpControllerBase +class WXDLLEXPORT wxWinHelpController: public wxHelpControllerBase { - DECLARE_DYNAMIC_CLASS(wxWinHelpController) + DECLARE_CLASS(wxWinHelpController) public: wxWinHelpController(wxWindow* parentWindow = NULL): wxHelpControllerBase(parentWindow) {} diff --git a/Source/3rd Party/wx/include/wx/msw/htmlhelp.h b/Source/3rd Party/wx/include/wx/msw/htmlhelp.h index ff3622c65..960ee155c 100644 --- a/Source/3rd Party/wx/include/wx/msw/htmlhelp.h +++ b/Source/3rd Party/wx/include/wx/msw/htmlhelp.h @@ -3,9 +3,9 @@ * Copyright 2004 Jacek Caban * * Originally written for the Wine project, and issued under - * the wxWindows licence by kind permission of the author. + * the wxWindows License by kind permission of the author. * - * Licence: wxWindows licence + * License: wxWindows License */ #ifndef __HTMLHELP_H__ diff --git a/Source/3rd Party/wx/include/wx/msw/hyperlink.h b/Source/3rd Party/wx/include/wx/msw/hyperlink.h deleted file mode 100644 index 847695b27..000000000 --- a/Source/3rd Party/wx/include/wx/msw/hyperlink.h +++ /dev/null @@ -1,64 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/hyperlink.h -// Purpose: Hyperlink control -// Author: Rickard Westerlund -// Created: 2010-08-04 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_HYPERLINK_H_ -#define _WX_MSW_HYPERLINK_H_ - -#include "wx/generic/hyperlink.h" - -// ---------------------------------------------------------------------------- -// wxHyperlinkCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxGenericHyperlinkCtrl -{ -public: - // Default constructor (for two-step construction). - wxHyperlinkCtrl() { } - - // Constructor. - wxHyperlinkCtrl(wxWindow *parent, - wxWindowID id, - const wxString& label, const wxString& url, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHL_DEFAULT_STYLE, - const wxString& name = wxHyperlinkCtrlNameStr) - { - (void)Create(parent, id, label, url, pos, size, style, name); - } - - // Creation function (for two-step construction). - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& label, const wxString& url, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxHL_DEFAULT_STYLE, - const wxString& name = wxHyperlinkCtrlNameStr); - - - // overridden base class methods - // ----------------------------- - - virtual void SetURL(const wxString &url); - - virtual void SetLabel(const wxString &label); - -protected: - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - virtual wxSize DoGetBestClientSize() const; - -private: - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - - wxDECLARE_DYNAMIC_CLASS( wxHyperlinkCtrl ); -}; - -#endif // _WX_MSW_HYPERLINK_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/icon.h b/Source/3rd Party/wx/include/wx/msw/icon.h index 5a7c89c1b..d716a26a5 100644 --- a/Source/3rd Party/wx/include/wx/msw/icon.h +++ b/Source/3rd Party/wx/include/wx/msw/icon.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: icon.h 42752 2006-10-30 19:26:48Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,7 +24,7 @@ // notice that although wxIconRefData inherits from wxBitmapRefData, it is not // a valid wxBitmapRefData -class WXDLLIMPEXP_CORE wxIconRefData : public wxGDIImageRefData +class WXDLLEXPORT wxIconRefData : public wxGDIImageRefData { public: wxIconRefData() { } @@ -36,7 +37,7 @@ public: // Icon // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxIcon : public wxGDIImage +class WXDLLEXPORT wxIcon : public wxGDIImage { public: // ctors @@ -47,13 +48,13 @@ public: wxIcon(const char bits[], int width, int height); // from XPM data - wxIcon(const char* const* data) { CreateIconFromXpm(data); } -#ifdef wxNEEDS_CHARPP - wxIcon(char **data) { CreateIconFromXpm(const_cast(data)); } -#endif + wxIcon(const char **data) { CreateIconFromXpm(data); } + + wxIcon(char **data) { CreateIconFromXpm((const char **)data); } + // from resource/file wxIcon(const wxString& name, - wxBitmapType type = wxICON_DEFAULT_TYPE, + long type = wxBITMAP_TYPE_ICO_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); wxIcon(const wxIconLocation& loc); @@ -61,11 +62,9 @@ public: virtual ~wxIcon(); virtual bool LoadFile(const wxString& name, - wxBitmapType type = wxICON_DEFAULT_TYPE, + long type = wxBITMAP_TYPE_ICO_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); - bool CreateFromHICON(WXHICON icon); - // implementation only from now on wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; } @@ -86,7 +85,7 @@ protected: virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; // create from XPM data - void CreateIconFromXpm(const char* const* data); + void CreateIconFromXpm(const char **data); private: DECLARE_DYNAMIC_CLASS(wxIcon) diff --git a/Source/3rd Party/wx/include/wx/msw/imaglist.h b/Source/3rd Party/wx/include/wx/msw/imaglist.h index e37dbf915..b31c73539 100644 --- a/Source/3rd Party/wx/include/wx/msw/imaglist.h +++ b/Source/3rd Party/wx/include/wx/msw/imaglist.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: imaglist.h 41271 2006-09-18 04:41:09Z KO $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ // now, the app must take care of ownership issues. That is, the // image lists must be explicitly deleted after the control(s) that uses them // is (are) deleted, or when the app exits. -class WXDLLIMPEXP_CORE wxImageList : public wxObject +class WXDLLEXPORT wxImageList : public wxObject { public: /* @@ -198,7 +199,7 @@ public: protected: WXHIMAGELIST m_hImageList; - DECLARE_DYNAMIC_CLASS_NO_COPY(wxImageList) + DECLARE_DYNAMIC_CLASS(wxImageList) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/iniconf.h b/Source/3rd Party/wx/include/wx/msw/iniconf.h index 63ebd0014..61b9d0c8d 100644 --- a/Source/3rd Party/wx/include/wx/msw/iniconf.h +++ b/Source/3rd Party/wx/include/wx/msw/iniconf.h @@ -1,19 +1,20 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/iniconf.h +// Name: include/wx/msw/iniconf.h // Purpose: INI-file based wxConfigBase implementation // Author: Vadim Zeitlin // Modified by: // Created: 27.07.98 +// RCS-ID: $Id: iniconf.h 62185 2009-09-28 10:02:42Z JS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_INICONF_H_ -#define _WX_MSW_INICONF_H_ +#ifndef _INICONF_H +#define _INICONF_H #include "wx/defs.h" -#if wxUSE_CONFIG && wxUSE_INICONF +#if wxUSE_CONFIG // ---------------------------------------------------------------------------- // wxIniConfig is a wxConfig implementation which uses MS Windows INI files to @@ -39,7 +40,7 @@ // same as appname). The file name (strAppName parameter) may, in fact, // contain the full path to the file. If it doesn't, the file is searched for // in the Windows directory. -class WXDLLIMPEXP_CORE wxIniConfig : public wxConfigBase +class WXDLLEXPORT wxIniConfig : public wxConfigBase { public: // ctor & dtor @@ -81,11 +82,9 @@ protected: // read/write bool DoReadString(const wxString& key, wxString *pStr) const; bool DoReadLong(const wxString& key, long *plResult) const; - bool DoReadBinary(const wxString& key, wxMemoryBuffer *buf) const; bool DoWriteString(const wxString& key, const wxString& szValue); bool DoWriteLong(const wxString& key, long lValue); - bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf); private: // helpers @@ -95,11 +94,8 @@ private: wxString m_strLocalFilename; // name of the private INI file wxString m_strGroup, // current group in appname.ini file m_strPath; // the rest of the path (no trailing '_'!) - - wxDECLARE_NO_COPY_CLASS(wxIniConfig); - DECLARE_ABSTRACT_CLASS(wxIniConfig) }; -#endif // wxUSE_CONFIG && wxUSE_INICONF +#endif // wxUSE_CONFIG -#endif // _WX_MSW_INICONF_H_ +#endif // _INICONF_H diff --git a/Source/3rd Party/wx/include/wx/msw/init.h b/Source/3rd Party/wx/include/wx/msw/init.h deleted file mode 100644 index 014dedbd0..000000000 --- a/Source/3rd Party/wx/include/wx/msw/init.h +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/init.h -// Purpose: Windows-specific wxEntry() overload -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_INIT_H_ -#define _WX_MSW_INIT_H_ - -// ---------------------------------------------------------------------------- -// Windows-specific wxEntry() overload and wxIMPLEMENT_WXWIN_MAIN definition -// ---------------------------------------------------------------------------- - -// we need HINSTANCE declaration to define WinMain() -#include "wx/msw/wrapwin.h" - -#ifndef SW_SHOWNORMAL - #define SW_SHOWNORMAL 1 -#endif - -// WinMain() is always ANSI, even in Unicode build, under normal Windows -// but is always Unicode under CE -#ifdef __WXWINCE__ - typedef wchar_t *wxCmdLineArgType; -#else - typedef char *wxCmdLineArgType; -#endif - -// Windows-only overloads of wxEntry() and wxEntryStart() which take the -// parameters passed to WinMain() instead of those passed to main() -extern WXDLLIMPEXP_CORE bool - wxEntryStart(HINSTANCE hInstance, - HINSTANCE hPrevInstance = NULL, - wxCmdLineArgType pCmdLine = NULL, - int nCmdShow = SW_SHOWNORMAL); - -extern WXDLLIMPEXP_CORE int - wxEntry(HINSTANCE hInstance, - HINSTANCE hPrevInstance = NULL, - wxCmdLineArgType pCmdLine = NULL, - int nCmdShow = SW_SHOWNORMAL); - -#if defined(__BORLANDC__) && wxUSE_UNICODE - // Borland C++ has the following nonstandard behaviour: when the -WU - // command line flag is used, the linker expects to find wWinMain instead - // of WinMain. This flag causes the compiler to define _UNICODE and - // UNICODE symbols and there's no way to detect its use, so we have to - // define both WinMain and wWinMain so that wxIMPLEMENT_WXWIN_MAIN works - // for both code compiled with and without -WU. - // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863 - // for more details. - #define wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \ - extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \ - HINSTANCE hPrevInstance, \ - wchar_t * WXUNUSED(lpCmdLine), \ - int nCmdShow) \ - { \ - wxDISABLE_DEBUG_SUPPORT(); \ - \ - /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \ - /* wchar_t*, but fortunately it's not used anywhere */ \ - /* and we can simply pass NULL in: */ \ - return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ - } -#else - #define wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD -#endif // defined(__BORLANDC__) && wxUSE_UNICODE - -#define wxIMPLEMENT_WXWIN_MAIN \ - extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ - HINSTANCE hPrevInstance, \ - wxCmdLineArgType WXUNUSED(lpCmdLine), \ - int nCmdShow) \ - { \ - wxDISABLE_DEBUG_SUPPORT(); \ - \ - /* NB: We pass NULL in place of lpCmdLine to behave the same as */ \ - /* Borland-specific wWinMain() above. If it becomes needed */ \ - /* to pass lpCmdLine to wxEntry() here, you'll have to fix */ \ - /* wWinMain() above too. */ \ - return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ - } \ - wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD - - -#endif // _WX_MSW_INIT_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/joystick.h b/Source/3rd Party/wx/include/wx/msw/joystick.h deleted file mode 100644 index b3f5e5710..000000000 --- a/Source/3rd Party/wx/include/wx/msw/joystick.h +++ /dev/null @@ -1,91 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/joystick.h -// Purpose: wxJoystick class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_JOYSTICK_H_ -#define _WX_JOYSTICK_H_ - -#include "wx/event.h" - -class WXDLLIMPEXP_ADV wxJoystick: public wxObject -{ - DECLARE_DYNAMIC_CLASS(wxJoystick) - public: - /* - * Public interface - */ - - wxJoystick(int joystick = wxJOYSTICK1); - - // Attributes - //////////////////////////////////////////////////////////////////////////// - - wxPoint GetPosition(void) const; - int GetPosition(unsigned axis) const; - bool GetButtonState(unsigned button) const; - int GetZPosition(void) const; - int GetButtonState(void) const; - int GetPOVPosition(void) const; - int GetPOVCTSPosition(void) const; - int GetRudderPosition(void) const; - int GetUPosition(void) const; - int GetVPosition(void) const; - int GetMovementThreshold(void) const; - void SetMovementThreshold(int threshold) ; - - // Capabilities - //////////////////////////////////////////////////////////////////////////// - - static int GetNumberJoysticks(void); - - bool IsOk(void) const; // Checks that the joystick is functioning - int GetManufacturerId(void) const ; - int GetProductId(void) const ; - wxString GetProductName(void) const ; - int GetXMin(void) const; - int GetYMin(void) const; - int GetZMin(void) const; - int GetXMax(void) const; - int GetYMax(void) const; - int GetZMax(void) const; - int GetNumberButtons(void) const; - int GetNumberAxes(void) const; - int GetMaxButtons(void) const; - int GetMaxAxes(void) const; - int GetPollingMin(void) const; - int GetPollingMax(void) const; - int GetRudderMin(void) const; - int GetRudderMax(void) const; - int GetUMin(void) const; - int GetUMax(void) const; - int GetVMin(void) const; - int GetVMax(void) const; - - bool HasRudder(void) const; - bool HasZ(void) const; - bool HasU(void) const; - bool HasV(void) const; - bool HasPOV(void) const; - bool HasPOV4Dir(void) const; - bool HasPOVCTS(void) const; - - // Operations - //////////////////////////////////////////////////////////////////////////// - - // pollingFreq = 0 means that movement events are sent when above the threshold. - // If pollingFreq > 0, events are received every this many milliseconds. - bool SetCapture(wxWindow* win, int pollingFreq = 0); - bool ReleaseCapture(void); - -protected: - int m_joystick; -}; - -#endif - // _WX_JOYSTICK_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/libraries.h b/Source/3rd Party/wx/include/wx/msw/libraries.h index c2d4a6749..efd7389e0 100644 --- a/Source/3rd Party/wx/include/wx/msw/libraries.h +++ b/Source/3rd Party/wx/include/wx/msw/libraries.h @@ -3,6 +3,7 @@ * Purpose: Pragmas for linking libs conditionally * Author: Michael Wetherell * Modified by: + * RCS-ID: $Id: libraries.h 37045 2006-01-21 22:50:46Z MW $ * Copyright: (c) 2005 Michael Wetherell * Licence: wxWindows licence */ diff --git a/Source/3rd Party/wx/include/wx/msw/listbox.h b/Source/3rd Party/wx/include/wx/msw/listbox.h index c89aee9de..518b78303 100644 --- a/Source/3rd Party/wx/include/wx/msw/listbox.h +++ b/Source/3rd Party/wx/include/wx/msw/listbox.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: listbox.h 66941 2011-02-17 11:01:22Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,6 +14,10 @@ #if wxUSE_LISTBOX +// Fixing spurious selection events breaks binary compatibility, so this is normally 0. +// See ticket #12143 +#define wxUSE_LISTBOX_SELECTION_FIX 0 + // ---------------------------------------------------------------------------- // simple types // ---------------------------------------------------------------------------- @@ -33,11 +38,11 @@ class WXDLLIMPEXP_FWD_BASE wxArrayInt; // List box control // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase +class WXDLLEXPORT wxListBox : public wxListBoxBase { public: // ctors and such - wxListBox() { Init(); } + wxListBox(); wxListBox(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -46,8 +51,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListBoxNameStr) { - Init(); - Create(parent, id, pos, size, n, choices, style, validator, name); } wxListBox(wxWindow *parent, wxWindowID id, @@ -58,8 +61,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListBoxNameStr) { - Init(); - Create(parent, id, pos, size, choices, style, validator, name); } @@ -80,6 +81,10 @@ public: virtual ~wxListBox(); + // implement base class pure virtuals + virtual void Clear(); + virtual void Delete(unsigned int n); + virtual unsigned int GetCount() const; virtual wxString GetString(unsigned int n) const; virtual void SetString(unsigned int n, const wxString& s); @@ -89,15 +94,8 @@ public: virtual int GetSelection() const; virtual int GetSelections(wxArrayInt& aSelections) const; - // return the index of the item at this position or wxNOT_FOUND - int HitTest(const wxPoint& pt) const { return DoHitTestList(pt); } - int HitTest(wxCoord x, wxCoord y) const { return DoHitTestList(wxPoint(x, y)); } - - // ownerdrawn wxListBox and wxCheckListBox support + // wxCheckListBox support #if wxUSE_OWNER_DRAWN - // override base class virtuals - virtual bool SetFont(const wxFont &font); - bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); bool MSWOnDraw(WXDRAWITEMSTRUCT *item); @@ -109,12 +107,6 @@ public: // get the index of the given item int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } - - // get rect of the given item index - bool GetItemRect(size_t n, wxRect& rect) const; - - // redraw the given item - bool RefreshItem(size_t n); #endif // wxUSE_OWNER_DRAWN // Windows-specific code to update the horizontal extent of the listbox, if @@ -145,53 +137,43 @@ public: return GetCompositeControlsDefaultAttributes(variant); } - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - - virtual void OnInternalIdle(); +#if wxUSE_LISTBOX_SELECTION_FIX + virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); +#endif protected: - virtual wxSize DoGetBestClientSize() const; - - virtual void DoClear(); - virtual void DoDeleteOneItem(unsigned int n); - virtual void DoSetSelection(int n, bool select); - - virtual int DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, wxClientDataType type); - + virtual int DoAppend(const wxString& item); + virtual void DoInsertItems(const wxArrayString& items, unsigned int pos); + virtual void DoSetItems(const wxArrayString& items, void **clientData); virtual void DoSetFirstItem(int n); virtual void DoSetItemClientData(unsigned int n, void* clientData); virtual void* DoGetItemClientData(unsigned int n) const; - - // this can't be called DoHitTest() because wxWindow already has this method - virtual int DoHitTestList(const wxPoint& point) const; + virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); + virtual wxClientData* DoGetItemClientObject(unsigned int n) const; + virtual int DoListHitTest(const wxPoint& point) const; // free memory (common part of Clear() and dtor) void Free(); unsigned int m_noItems; + int m_selected; + + virtual wxSize DoGetBestSize() const; #if wxUSE_OWNER_DRAWN // control items wxListBoxItemsArray m_aItems; #endif +#if wxUSE_LISTBOX_SELECTION_FIX + // flag set to true when we get a keyboard event and reset to false when we + // get a mouse one: this is used to find the correct item for the selection + // event + bool m_selectedByKeyboard; +#endif + private: - // common part of all ctors - void Init(); - - // call this when items are added to or deleted from the listbox or an - // items text changes - void MSWOnItemsChanged(); - - // flag indicating whether the max horizontal extent should be updated, - // i.e. if we need to call SetHorizontalExtent() from OnInternalIdle() - bool m_updateHorizontalExtent; - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox) }; diff --git a/Source/3rd Party/wx/include/wx/msw/listctrl.h b/Source/3rd Party/wx/include/wx/msw/listctrl.h index 6904d6511..de4c7d839 100644 --- a/Source/3rd Party/wx/include/wx/msw/listctrl.h +++ b/Source/3rd Party/wx/include/wx/msw/listctrl.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Agron Selimaj // Created: 01/02/97 +// RCS-ID: $Id: listctrl.h 54419 2008-06-29 01:35:24Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,14 +13,8 @@ #define _WX_LISTCTRL_H_ #include "wx/textctrl.h" -#include "wx/dynarray.h" -#include "wx/vector.h" -class wxMSWListItemData; - -// define this symbol to indicate the availability of SetColumnsOrder() and -// related functions -#define wxHAS_LISTCTRL_COLUMN_ORDER +class WXDLLIMPEXP_FWD_CORE wxImageList; /* The wxListCtrl can show lists of items in four different modes: @@ -75,7 +70,7 @@ class wxMSWListItemData; */ -class WXDLLIMPEXP_CORE wxListCtrl: public wxListCtrlBase +class WXDLLEXPORT wxListCtrl: public wxControl { public: /* @@ -119,25 +114,13 @@ public: bool GetColumn(int col, wxListItem& item) const; // Sets information about this column - bool SetColumn(int col, const wxListItem& item); + bool SetColumn(int col, const wxListItem& item) ; // Gets the column width int GetColumnWidth(int col) const; // Sets the column width - bool SetColumnWidth(int col, int width); - - - // Gets the column order from its index or index from its order - int GetColumnOrder(int col) const; - int GetColumnIndexFromOrder(int order) const; - - // Gets the column order for all columns - wxArrayInt GetColumnsOrder() const; - - // Sets the column order for all columns - bool SetColumnsOrder(const wxArrayInt& orders); - + bool SetColumnWidth(int col, int width) ; // Gets the number of items that can fit vertically in the // visible area of the list control (list or report view) @@ -152,48 +135,50 @@ public: wxTextCtrl* GetEditControl() const; // Gets information about the item - bool GetItem(wxListItem& info) const; + bool GetItem(wxListItem& info) const ; // Sets information about the item - bool SetItem(wxListItem& info); + bool SetItem(wxListItem& info) ; // Sets a string field at a particular column long SetItem(long index, int col, const wxString& label, int imageId = -1); // Gets the item state - int GetItemState(long item, long stateMask) const; + int GetItemState(long item, long stateMask) const ; // Sets the item state - bool SetItemState(long item, long state, long stateMask); + bool SetItemState(long item, long state, long stateMask) ; // Sets the item image - bool SetItemImage(long item, int image, int selImage = -1); + bool SetItemImage(long item, int image, int selImage = -1) ; bool SetItemColumnImage(long item, long column, int image); // Gets the item text - wxString GetItemText(long item, int col = 0) const; + wxString GetItemText(long item) const ; // Sets the item text - void SetItemText(long item, const wxString& str); + void SetItemText(long item, const wxString& str) ; // Gets the item data - wxUIntPtr GetItemData(long item) const; + wxUIntPtr GetItemData(long item) const ; // Sets the item data +#if wxABI_VERSION >= 20804 bool SetItemPtrData(long item, wxUIntPtr data); - bool SetItemData(long item, long data) { return SetItemPtrData(item, data); } +#endif // wxABI 2.8.4+ + bool SetItemData(long item, long data); // Gets the item rectangle - bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const; + bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; // Gets the subitem rectangle in report mode - bool GetSubItemRect(long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const; + bool GetSubItemRect(long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; // Gets the item position - bool GetItemPosition(long item, wxPoint& pos) const; + bool GetItemPosition(long item, wxPoint& pos) const ; // Sets the item position - bool SetItemPosition(long item, const wxPoint& pos); + bool SetItemPosition(long item, const wxPoint& pos) ; // Gets the number of items in the list control int GetItemCount() const; @@ -227,22 +212,22 @@ public: // Gets the index of the topmost visible item when in // list or report view - long GetTopItem() const; + long GetTopItem() const ; // Add or remove a single window style - void SetSingleStyle(long style, bool add = true); + void SetSingleStyle(long style, bool add = true) ; // Set the whole window style - void SetWindowStyleFlag(long style); + void SetWindowStyleFlag(long style) ; // Searches for an item, starting from 'item'. // item can be -1 to find the first item that matches the // specified flags. // Returns the item or -1 if unsuccessful. - long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const; + long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; // Gets one of the three image lists - wxImageList *GetImageList(int which) const; + wxImageList *GetImageList(int which) const ; // Sets the image list // N.B. There's a quirk in the Win95 list view implementation. @@ -251,8 +236,14 @@ public: // haven't specified wxLIST_MASK_IMAGE when inserting. // So you have to set a NULL small-icon image list to be sure that // the wxLC_LIST mode works without icons. Of course, you may want icons... - void SetImageList(wxImageList *imageList, int which); - void AssignImageList(wxImageList *imageList, int which); + void SetImageList(wxImageList *imageList, int which) ; + void AssignImageList(wxImageList *imageList, int which) ; + + // are we in report mode? + bool InReportView() const { return HasFlag(wxLC_REPORT); } + + // are we in virtual report mode? + bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); } // refresh items selectively (only useful for virtual list controls) void RefreshItem(long item); @@ -268,7 +259,7 @@ public: bool DeleteItem(long item); // Deletes all items - bool DeleteAllItems(); + bool DeleteAllItems() ; // Deletes a column bool DeleteColumn(int col); @@ -280,13 +271,13 @@ public: void ClearAll(); // Edit the label - wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); + wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)); // End label editing, optionally cancelling the edit bool EndEditLabel(bool cancel); // Ensures this item is visible - bool EnsureVisible(long item); + bool EnsureVisible(long item) ; // Find an item whose label matches this string, starting from the item after 'start' // or the beginning if 'start' is -1. @@ -318,6 +309,14 @@ public: // Insert an image/string item long InsertItem(long index, const wxString& label, int imageIndex); + // For list view mode (only), inserts a column. + long InsertColumn(long col, const wxListItem& info); + + long InsertColumn(long col, + const wxString& heading, + int format = wxLIST_FORMAT_LEFT, + int width = -1); + // set the number of items in a virtual list control void SetItemCount(long count); @@ -339,7 +338,7 @@ public: // or zero if the two items are equivalent. // data is arbitrary data to be passed to the sort function. - bool SortItems(wxListCtrlCompare fn, wxIntPtr data); + bool SortItems(wxListCtrlCompare fn, long data); // IMPLEMENTATION virtual bool MSWCommand(WXUINT param, WXWORD id); @@ -383,26 +382,12 @@ protected: // common part of all ctors void Init(); - // Implement constrained best size calculation. - virtual int DoGetBestClientHeight(int width) const - { return MSWGetBestViewRect(width, -1).y; } - virtual int DoGetBestClientWidth(int height) const - { return MSWGetBestViewRect(-1, height).x; } - - wxSize MSWGetBestViewRect(int x, int y) const; - - // Implement base class pure virtual methods. - long DoInsertColumn(long col, const wxListItem& info); - // free memory taken by all internal data void FreeAllInternalData(); - // get the internal data object for this item (may return NULL) - wxMSWListItemData *MSWGetItemData(long item) const; - // get the item attribute, either by quering it for virtual control, or by // returning the one previously set using setter methods for a normal one - wxListItemAttr *DoGetItemColumnAttr(long item, long column) const; + wxListItemAttr *DoGetItemAttr(long item) const; wxTextCtrl* m_textCtrl; // The control used for editing a label @@ -417,9 +402,10 @@ protected: // keep track of inserted/deleted columns long m_count; // Keep track of item count to save calls to // ListView_GetItemCount + bool m_ignoreChangeMessages; - // all wxMSWListItemData objects we use - wxVector m_internalData; + // true if we have any internal data (user data & attributes) + bool m_AnyInternalData; // true if we have any items with custom attributes bool m_hasAnyAttr; @@ -438,11 +424,8 @@ protected: // return the icon for the given item and column. virtual int OnGetItemColumnImage(long item, long column) const; - // return the attribute for the given item and column (may return NULL if none) - virtual wxListItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const - { - return OnGetItemAttr(item); - } + // return the attribute for the item (may return NULL if none) + virtual wxListItemAttr *OnGetItemAttr(long item) const; private: // process NM_CUSTOMDRAW notification message @@ -458,14 +441,9 @@ private: // destroy m_textCtrl if it's currently valid and reset it to NULL void DeleteEditControl(); - // Intercept Escape and Enter keys to avoid them being stolen from our - // in-place editor control. - void OnCharHook(wxKeyEvent& event); - - DECLARE_DYNAMIC_CLASS(wxListCtrl) DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxListCtrl); + DECLARE_NO_COPY_CLASS(wxListCtrl) }; #endif // _WX_LISTCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/mdi.h b/Source/3rd Party/wx/include/wx/msw/mdi.h index 45b9304c3..46f7f1059 100644 --- a/Source/3rd Party/wx/include/wx/msw/mdi.h +++ b/Source/3rd Party/wx/include/wx/msw/mdi.h @@ -2,28 +2,31 @@ // Name: wx/msw/mdi.h // Purpose: MDI (Multiple Document Interface) classes // Author: Julian Smart -// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes +// Modified by: // Created: 01/02/97 -// Copyright: (c) 1997 Julian Smart -// (c) 2008 Vadim Zeitlin +// RCS-ID: $Id: mdi.h 53135 2008-04-12 02:31:04Z VZ $ +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_MDI_H_ -#define _WX_MSW_MDI_H_ +#ifndef _WX_MDI_H_ +#define _WX_MDI_H_ #include "wx/frame.h" -class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable; +extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; + +class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow; +class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; // --------------------------------------------------------------------------- // wxMDIParentFrame // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase +class WXDLLEXPORT wxMDIParentFrame : public wxFrame { public: - wxMDIParentFrame() { Init(); } + wxMDIParentFrame(); wxMDIParentFrame(wxWindow *parent, wxWindowID id, const wxString& title, @@ -32,8 +35,6 @@ public: long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, const wxString& name = wxFrameNameStr) { - Init(); - Create(parent, id, title, pos, size, style, name); } @@ -47,44 +48,32 @@ public: long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, const wxString& name = wxFrameNameStr); - // override/implement base class [pure] virtual methods - // ---------------------------------------------------- + // accessors + // --------- - static bool IsTDI() { return false; } + // Get the active MDI child window (Windows only) + wxMDIChildFrame *GetActiveChild() const; - // we don't store the active child in m_currentChild so override this - // function to find it dynamically - virtual wxMDIChildFrame *GetActiveChild() const; + // Get the client window + wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; } + // Create the client window class (don't Create the window, + // just return a new class) + virtual wxMDIClientWindow *OnCreateClient(void); + + // MDI windows menu + wxMenu* GetWindowMenu() const { return m_windowMenu; } + void SetWindowMenu(wxMenu* menu) ; + virtual void DoMenuUpdates(wxMenu* menu = NULL); + + // MDI operations + // -------------- virtual void Cascade(); virtual void Tile(wxOrientation orient = wxHORIZONTAL); virtual void ArrangeIcons(); virtual void ActivateNext(); virtual void ActivatePrevious(); -#if wxUSE_MENUS - virtual void SetWindowMenu(wxMenu* menu); - - virtual void DoMenuUpdates(wxMenu* menu = NULL); - - // return the active child menu, if any - virtual WXHMENU MSWGetActiveMenu() const; -#endif // wxUSE_MENUS - - - // implementation only from now on - - // MDI helpers - // ----------- - -#if wxUSE_MENUS - // called by wxMDIChildFrame after it was successfully created - virtual void AddMDIChild(wxMDIChildFrame *child); - - // called by wxMDIChildFrame just before it is destroyed - virtual void RemoveMDIChild(wxMDIChildFrame *child); -#endif // wxUSE_MENUS - // handlers // -------- @@ -95,6 +84,7 @@ public: void OnIconized(wxIconizeEvent& event); bool HandleActivate(int state, bool minimized, WXHWND activate); + bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); // override window proc for MDI-specific message processing virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); @@ -102,12 +92,6 @@ public: virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); virtual bool MSWTranslateMessage(WXMSG* msg); -#if wxUSE_MENUS - // override wxFrameBase function to also look in the active child menu bar - // and the "Window" menu - virtual wxMenuItem *FindItemInMenuBar(int menuId) const; -#endif // wxUSE_MENUS - protected: #if wxUSE_MENUS_NATIVE virtual void InternalSetMenuBar(); @@ -118,45 +102,27 @@ protected: // set the size of the MDI client window to match the frame size void UpdateClientSize(); + + wxMDIClientWindow * m_clientWindow; + wxMDIChildFrame * m_currentChild; + wxMenu* m_windowMenu; + + // true if MDI Frame is intercepting commands, not child + bool m_parentFrameActive; + private: - // common part of all ctors - void Init(); - -#if wxUSE_MENUS - // "Window" menu commands event handlers - void OnMDICommand(wxCommandEvent& event); - void OnMDIChild(wxCommandEvent& event); - - - // add/remove window menu if we have it (i.e. m_windowMenu != NULL) - void AddWindowMenu(); - void RemoveWindowMenu(); - - // update the window menu (if we have it) to enable or disable the commands - // which only make sense when we have more than one child - void UpdateWindowMenu(bool enable); - -#if wxUSE_ACCEL - wxAcceleratorTable *m_accelWindowMenu; -#endif // wxUSE_ACCEL -#endif // wxUSE_MENUS - - // return the number of child frames we currently have (maybe 0) - int GetChildFramesCount() const; - - friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) - wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame); + DECLARE_NO_COPY_CLASS(wxMDIParentFrame) }; // --------------------------------------------------------------------------- // wxMDIChildFrame // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase +class WXDLLEXPORT wxMDIChildFrame : public wxFrame { public: wxMDIChildFrame() { Init(); } @@ -173,6 +139,8 @@ public: Create(parent, id, title, pos, size, style, name); } + virtual ~wxMDIChildFrame(); + bool Create(wxMDIParentFrame *parent, wxWindowID id, const wxString& title, @@ -181,16 +149,12 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr); - virtual ~wxMDIChildFrame(); + virtual bool IsTopLevel() const { return false; } - // implement MDI operations - virtual void Activate(); - - // Override some frame operations too + // MDI operations virtual void Maximize(bool maximize = true); virtual void Restore(); - - virtual bool Show(bool show = true); + virtual void Activate(); // Implementation only from now on // ------------------------------- @@ -198,6 +162,7 @@ public: // Handlers bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); bool HandleWindowPosChanging(void *lpPos); + bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); bool HandleGetMinMaxInfo(void *mmInfo); virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); @@ -210,10 +175,11 @@ public: void OnIdle(wxIdleEvent& event); + virtual bool Show(bool show = true); + protected: virtual void DoGetScreenPosition(int *x, int *y) const; virtual void DoGetPosition(int *x, int *y) const; - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); virtual void DoSetClientSize(int width, int height); virtual void InternalSetMenuBar(); virtual bool IsMDIChild() const { return true; } @@ -236,10 +202,16 @@ private: // wxMDIClientWindow // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase +class WXDLLEXPORT wxMDIClientWindow : public wxWindow { public: wxMDIClientWindow() { Init(); } + wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) + { + Init(); + + CreateClient(parent, style); + } // Note: this is virtual, to allow overridden behaviour. virtual bool CreateClient(wxMDIParentFrame *parent, @@ -262,4 +234,5 @@ private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) }; -#endif // _WX_MSW_MDI_H_ +#endif + // _WX_MDI_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/menu.h b/Source/3rd Party/wx/include/wx/msw/menu.h index 5cdab1f66..b25f77d5d 100644 --- a/Source/3rd Party/wx/include/wx/msw/menu.h +++ b/Source/3rd Party/wx/include/wx/msw/menu.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Vadim Zeitlin (wxMenuItem is now in separate file) // Created: 01/02/97 +// RCS-ID: $Id: menu.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,7 +25,6 @@ class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxToolBar; #endif -class wxMenuRadioItemsData; // Not using a combined wxToolBar/wxMenuBar? then use // a commandbar in WinCE .NET to implement the @@ -45,7 +45,7 @@ class wxMenuRadioItemsData; // Menu // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase +class WXDLLEXPORT wxMenu : public wxMenuBase { public: // ctors & dtor @@ -60,36 +60,23 @@ public: virtual void SetTitle(const wxString& title); - // MSW-only methods - // ---------------- - - // Create a new menu from the given native HMENU. Takes ownership of the - // menu handle and will delete it when this object is destroyed. - static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); } - -#if wxABI_VERSION >= 30002 - // Detaches HMENU so that it isn't deleted when this object is destroyed. - // Don't use this object after calling this method. - WXHMENU MSWDetachHMENU() { WXHMENU m = m_hMenu; m_hMenu = NULL; return m; } -#endif - // implementation only from now on // ------------------------------- + virtual void Attach(wxMenuBarBase *menubar); + bool MSWCommand(WXUINT param, WXWORD id); - // get the native menu handle + // semi-private accessors + // get the window which contains this menu + wxWindow *GetWindow() const; + // get the menu handle WXHMENU GetHMenu() const { return m_hMenu; } - // Return the start and end position of the radio group to which the item - // at the given position belongs. Returns false if there is no radio group - // containing this position. - bool MSWGetRadioGroupRange(int pos, int *start, int *end) const; - #if wxUSE_ACCEL // called by wxMenuBar to build its accel table from the accels of all menus - bool HasAccels() const { return !m_accels.empty(); } - size_t GetAccelCount() const { return m_accels.size(); } + bool HasAccels() const { return !m_accels.IsEmpty(); } + size_t GetAccelCount() const { return m_accels.GetCount(); } size_t CopyAccels(wxAcceleratorEntry *accels) const; // called by wxMenuItem when its accels changes @@ -97,65 +84,29 @@ public: // helper used by wxMenu itself (returns the index in m_accels) int FindAccel(int id) const; - - // used only by wxMDIParentFrame currently but could be useful elsewhere: - // returns a new accelerator table with accelerators for just this menu - // (shouldn't be called if we don't have any accelerators) - wxAcceleratorTable *CreateAccelTable() const; #endif // wxUSE_ACCEL -#if wxUSE_OWNER_DRAWN - - int GetMaxAccelWidth() - { - if (m_maxAccelWidth == -1) - CalculateMaxAccelWidth(); - return m_maxAccelWidth; - } - - void ResetMaxAccelWidth() - { - m_maxAccelWidth = -1; - } - - // get the menu with given handle (recursively) - wxMenu* MSWGetMenu(WXHMENU hMenu); - -private: - void CalculateMaxAccelWidth(); - -#endif // wxUSE_OWNER_DRAWN - protected: virtual wxMenuItem* DoAppend(wxMenuItem *item); virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item); virtual wxMenuItem* DoRemove(wxMenuItem *item); private: - // This constructor is private, use MSWNewFromHMENU() to use it. - wxMenu(WXHMENU hMenu); - - // Common part of all ctors, it doesn't create a new HMENU. - void InitNoCreate(); - - // Common part of all ctors except of the one above taking a native menu - // handler: calls InitNoCreate() and also creates a new menu. + // common part of all ctors void Init(); // common part of Append/Insert (behaves as Append is pos == (size_t)-1) bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1); - - // This variable contains the description of the radio item groups and - // allows to find whether an item at the given position is part of the - // group and also where its group starts and ends. - // - // It is initially NULL and only allocated if we have any radio items. - wxMenuRadioItemsData *m_radioData; + // terminate the current radio group, if any + void EndRadioGroup(); // if true, insert a breal before appending the next item bool m_doBreak; + // the position of the first item in the current radio group or -1 + int m_startRadioGroup; + // the menu handle of this menu WXHMENU m_hMenu; @@ -164,17 +115,6 @@ private: wxAcceleratorArray m_accels; #endif // wxUSE_ACCEL -#if wxUSE_OWNER_DRAWN - // true if the menu has any ownerdrawn items - bool m_ownerDrawn; - - // the max width of menu items bitmaps - int m_maxBitmapWidth; - - // the max width of menu items accels - int m_maxAccelWidth; -#endif // wxUSE_OWNER_DRAWN - DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenu) }; @@ -182,7 +122,26 @@ private: // Menu Bar (a la Windows) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase +class WXDLLEXPORT wxMenuInfo : public wxObject +{ +public : + wxMenuInfo() { m_menu = NULL; } + virtual ~wxMenuInfo() { } + + void Create( wxMenu *menu , const wxString &title ) + { m_menu = menu; m_title = title; } + wxMenu* GetMenu() const { return m_menu; } + wxString GetTitle() const { return m_title; } +private : + wxMenu *m_menu; + wxString m_title; + + DECLARE_DYNAMIC_CLASS(wxMenuInfo) +}; + +WX_DECLARE_EXPORTED_LIST(wxMenuInfo, wxMenuInfoList ); + +class WXDLLEXPORT wxMenuBar : public wxMenuBarBase { public: // ctors & dtor @@ -195,15 +154,17 @@ public: virtual ~wxMenuBar(); // menubar construction + bool Append( wxMenuInfo *info ) { return Append( info->GetMenu() , info->GetTitle() ); } + const wxMenuInfoList& GetMenuInfos() const; + virtual bool Append( wxMenu *menu, const wxString &title ); virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title); virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); virtual wxMenu *Remove(size_t pos); virtual void EnableTop( size_t pos, bool flag ); - virtual bool IsEnabledTop(size_t pos) const; - virtual void SetMenuLabel( size_t pos, const wxString& label ); - virtual wxString GetMenuLabel( size_t pos ) const; + virtual void SetLabelTop( size_t pos, const wxString& label ); + virtual wxString GetLabelTop( size_t pos ) const; // implementation from now on WXHMENU Create(); @@ -222,6 +183,9 @@ public: #endif #if wxUSE_ACCEL + // get the accel table for all the menus + const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; } + // update the accel table (must be called after adding/deleting a menu) void RebuildAccelTable(); #endif // wxUSE_ACCEL @@ -237,18 +201,22 @@ public: void Refresh( bool eraseBackground, const wxRect *rect = (const wxRect *) NULL ) { wxWindow::Refresh(eraseBackground, rect); } - // get the menu with given handle (recursively) - wxMenu* MSWGetMenu(WXHMENU hMenu); - protected: // common part of all ctors void Init(); + wxArrayString m_titles; + wxMenuInfoList m_menuInfos; + WXHMENU m_hMenu; // Return the MSW position for a wxMenu which is sometimes different from // the wxWidgets position. int MSWPositionForWxMenu(wxMenu *menu, int wxpos); +#if wxUSE_ACCEL + // the accelerator table for all accelerators in all our menus + wxAcceleratorTable m_accelTable; +#endif // wxUSE_ACCEL #if defined(__WXWINCE__) && wxUSE_TOOLBAR wxToolBar* m_toolBar; @@ -261,6 +229,13 @@ protected: private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar) + +public: + +#if wxABI_VERSION >= 20805 + // Gets the original label at the top-level of the menubar + wxString GetMenuLabel(size_t pos) const; +#endif }; #endif // _WX_MENU_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/menuitem.h b/Source/3rd Party/wx/include/wx/msw/menuitem.h index 4cfd7ebff..641365848 100644 --- a/Source/3rd Party/wx/include/wx/msw/menuitem.h +++ b/Source/3rd Party/wx/include/wx/msw/menuitem.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/menuitem.h +// Name: menuitem.h // Purpose: wxMenuItem class // Author: Vadim Zeitlin // Modified by: // Created: 11.11.97 +// RCS-ID: $Id: menuitem.h 48053 2007-08-13 17:07:01Z JS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,33 +17,31 @@ // ---------------------------------------------------------------------------- #if wxUSE_OWNER_DRAWN - #include "wx/ownerdrw.h" - #include "wx/bitmap.h" - - struct tagRECT; + #include "wx/ownerdrw.h" // base class #endif // ---------------------------------------------------------------------------- // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase +class WXDLLEXPORT wxMenuItem : public wxMenuItemBase #if wxUSE_OWNER_DRAWN , public wxOwnerDrawn #endif { public: // ctor & dtor - wxMenuItem(wxMenu *parentMenu = NULL, + wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL, int id = wxID_SEPARATOR, const wxString& name = wxEmptyString, const wxString& help = wxEmptyString, wxItemKind kind = wxITEM_NORMAL, - wxMenu *subMenu = NULL); + wxMenu *subMenu = (wxMenu *)NULL); virtual ~wxMenuItem(); // override base class virtuals - virtual void SetItemLabel(const wxString& strName); + virtual void SetText(const wxString& strName); + virtual void SetCheckable(bool checkable); virtual void Enable(bool bDoEnable = true); virtual void Check(bool bDoCheck = true); @@ -54,99 +53,48 @@ public: // the id for a popup menu is really its menu handle (as required by // ::AppendMenu() API), so this function will return either the id or the - // menu handle depending on what we are - // - // notice that it also returns the id as an unsigned int, as required by - // Win32 API - WXWPARAM GetMSWId() const; + // menu handle depending on what we're + int GetRealId() const; + + // mark item as belonging to the given radio group + void SetAsRadioGroupStart(); + void SetRadioGroupStart(int start); + void SetRadioGroupEnd(int end); -#if WXWIN_COMPATIBILITY_2_8 // compatibility only, don't use in new code - wxDEPRECATED( wxMenuItem(wxMenu *parentMenu, int id, const wxString& text, const wxString& help, bool isCheckable, - wxMenu *subMenu = NULL) - ); -#endif - -#if wxUSE_OWNER_DRAWN - - void SetBitmaps(const wxBitmap& bmpChecked, - const wxBitmap& bmpUnchecked = wxNullBitmap) - { - m_bmpChecked = bmpChecked; - m_bmpUnchecked = bmpUnchecked; - SetOwnerDrawn(true); - } - - void SetBitmap(const wxBitmap& bmp, bool bChecked = true) - { - if ( bChecked ) - m_bmpChecked = bmp; - else - m_bmpUnchecked = bmp; - SetOwnerDrawn(true); - } - - void SetDisabledBitmap(const wxBitmap& bmpDisabled) - { - m_bmpDisabled = bmpDisabled; - SetOwnerDrawn(true); - } - - const wxBitmap& GetBitmap(bool bChecked = true) const - { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } - - const wxBitmap& GetDisabledBitmap() const - { return m_bmpDisabled; } - - int MeasureAccelWidth() const; - - // override wxOwnerDrawn base class virtuals - virtual wxString GetName() const; - virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight); - virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); - -protected: - virtual void GetFontToUse(wxFont& font) const; - virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const; - -private: - // helper function for draw std menu check mark - void DrawStdCheckMark(WXHDC hdc, const tagRECT* rc, wxODStatus stat); - -#else // !wxUSE_OWNER_DRAWN - // Provide stubs for the public functions above to ensure that the code - // still compiles without wxUSE_OWNER_DRAWN -- it makes sense to just drop - // the bitmaps then instead of failing compilation. - void SetBitmaps(const wxBitmap& WXUNUSED(bmpChecked), - const wxBitmap& WXUNUSED(bmpUnchecked) = wxNullBitmap) { } - void SetBitmap(const wxBitmap& WXUNUSED(bmp), - bool WXUNUSED(bChecked) = true) { } - const wxBitmap& GetBitmap() const { return wxNullBitmap; } -#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN + wxMenu *subMenu = (wxMenu *)NULL); private: // common part of all ctors void Init(); - // Return the item position in the menu containing it. - // - // Returns -1 if the item is not attached to a menu or if we can't find its - // position (which is not really supposed to ever happen). - int MSGetMenuItemPos() const; + // the positions of the first and last items of the radio group this item + // belongs to or -1: start is the radio group start and is valid for all + // but first radio group items (m_isRadioGroupStart == false), end is valid + // only for the first one + union + { + int start; + int end; + } m_radioGroup; -#if wxUSE_OWNER_DRAWN - // item bitmaps - wxBitmap m_bmpChecked, // bitmap to put near the item - m_bmpUnchecked, // (checked is used also for 'uncheckable' items) - m_bmpDisabled; -#endif // wxUSE_OWNER_DRAWN + // does this item start a radio group? + bool m_isRadioGroupStart; DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) + +public: + +#if wxABI_VERSION >= 20805 + // return the item label including any mnemonics and accelerators. + // This used to be called GetText. + wxString GetItemLabel() const { return GetText(); } +#endif }; #endif //_MENUITEM_H diff --git a/Source/3rd Party/wx/include/wx/msw/metafile.h b/Source/3rd Party/wx/include/wx/msw/metafile.h deleted file mode 100644 index 8991f58c9..000000000 --- a/Source/3rd Party/wx/include/wx/msw/metafile.h +++ /dev/null @@ -1,189 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/metafile.h -// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes -// Author: Julian Smart -// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_METAFIILE_H_ -#define _WX_METAFIILE_H_ - -#include "wx/dc.h" -#include "wx/gdiobj.h" - -#if wxUSE_DRAG_AND_DROP - #include "wx/dataobj.h" -#endif - -// ---------------------------------------------------------------------------- -// Metafile and metafile device context classes -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_CORE wxMetafile; - -class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData -{ -public: - wxMetafileRefData(); - virtual ~wxMetafileRefData(); - - virtual bool IsOk() const { return m_metafile != 0; } - -public: - WXHANDLE m_metafile; - int m_windowsMappingMode; - int m_width, m_height; - - friend class WXDLLIMPEXP_FWD_CORE wxMetafile; -}; - -#define M_METAFILEDATA ((wxMetafileRefData *)m_refData) - -class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject -{ -public: - wxMetafile(const wxString& file = wxEmptyString); - virtual ~wxMetafile(); - - // After this is called, the metafile cannot be used for anything - // since it is now owned by the clipboard. - virtual bool SetClipboard(int width = 0, int height = 0); - - virtual bool Play(wxDC *dc); - - // set/get the size of metafile for clipboard operations - wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); } - int GetWidth() const { return M_METAFILEDATA->m_width; } - int GetHeight() const { return M_METAFILEDATA->m_height; } - - void SetWidth(int width) { M_METAFILEDATA->m_width = width; } - void SetHeight(int height) { M_METAFILEDATA->m_height = height; } - - // Implementation - WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; } - void SetHMETAFILE(WXHANDLE mf) ; - int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; } - void SetWindowsMappingMode(int mm); - -protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - -private: - DECLARE_DYNAMIC_CLASS(wxMetafile) -}; - -class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxMSWDCImpl -{ -public: - wxMetafileDCImpl(wxDC *owner, const wxString& file = wxEmptyString); - wxMetafileDCImpl(wxDC *owner, const wxString& file, - int xext, int yext, int xorg, int yorg); - virtual ~wxMetafileDCImpl(); - - virtual wxMetafile *Close(); - virtual void SetMapMode(wxMappingMode mode); - virtual void DoGetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const; - - // Implementation - wxMetafile *GetMetaFile() const { return m_metaFile; } - void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } - int GetWindowsMappingMode() const { return m_windowsMappingMode; } - void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } - -protected: - virtual void DoGetSize(int *width, int *height) const; - - int m_windowsMappingMode; - wxMetafile* m_metaFile; - -private: - DECLARE_CLASS(wxMetafileDCImpl) - wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl); -}; - -class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC -{ -public: - // Don't supply origin and extent - // Supply them to wxMakeMetaFilePlaceable instead. - wxMetafileDC(const wxString& file) - : wxDC(new wxMetafileDCImpl( this, file )) - { } - - // Supply origin and extent (recommended). - // Then don't need to supply them to wxMakeMetaFilePlaceable. - wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg) - : wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg )) - { } - - wxMetafile *GetMetafile() const - { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); } - - wxMetafile *Close() - { return ((wxMetafileDCImpl*)m_pimpl)->Close(); } - -private: - DECLARE_CLASS(wxMetafileDC) - wxDECLARE_NO_COPY_CLASS(wxMetafileDC); -}; - - - - -/* - * Pass filename of existing non-placeable metafile, and bounding box. - * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. - * - */ - -// No origin or extent -bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); - -// Optional origin and extent -bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); - -// ---------------------------------------------------------------------------- -// wxMetafileDataObject is a specialization of wxDataObject for metafile data -// ---------------------------------------------------------------------------- - -#if wxUSE_DRAG_AND_DROP - -class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple -{ -public: - // ctors - wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE) - { } - wxMetafileDataObject(const wxMetafile& metafile) - : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { } - - // virtual functions which you may override if you want to provide data on - // demand only - otherwise, the trivial default versions will be used - virtual void SetMetafile(const wxMetafile& metafile) - { m_metafile = metafile; } - virtual wxMetafile GetMetafile() const - { return m_metafile; } - - // implement base class pure virtuals - virtual size_t GetDataSize() const; - virtual bool GetDataHere(void *buf) const; - virtual bool SetData(size_t len, const void *buf); - -protected: - wxMetafile m_metafile; -}; - -#endif // wxUSE_DRAG_AND_DROP - -#endif - // _WX_METAFIILE_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/microwin.h b/Source/3rd Party/wx/include/wx/msw/microwin.h deleted file mode 100644 index bb9861ab1..000000000 --- a/Source/3rd Party/wx/include/wx/msw/microwin.h +++ /dev/null @@ -1,234 +0,0 @@ -/* -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/microwin.h -// Purpose: Extra implementation for MicroWindows -// Author: Julian Smart -// Created: 2001-05-31 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// -*/ - -#ifndef _WX_MICROWIN_H_ -#define _WX_MICROWIN_H_ - -/* Implemented by microwin.cpp */ - -#ifdef __cplusplus -extern "C" { -#endif - -BOOL SetCursorPos(int x, int y); - -HCURSOR SetCursor(HCURSOR hCursor); - -/* Implemented with wrong number of args by MicroWindows */ -/* so we need to use a different name */ -int GetScrollPosWX (HWND hWnd, int iSBar); - -BOOL ScrollWindow(HWND, int xAmount, int yAmount, - CONST RECT* lpRect, CONST RECT* lpClipRect); - -HWND WindowFromPoint(POINT pt); -SHORT GetKeyState(int nVirtKey); -HWND SetParent(HWND hWndChild, HWND hWndNewParent); -VOID DragAcceptFiles(HWND, BOOL); -BOOL IsDialogMessage(HWND hWnd, MSG* msg); -DWORD GetMessagePos(VOID); -BOOL IsIconic(HWND hWnd); -int SetMapMode(HDC hDC, int mode); -int GetMapMode(HDC hDC); -HCURSOR LoadCursor(HINSTANCE hInst, int cursor); -DWORD GetModuleFileName(HINSTANCE hInst, LPSTR name, DWORD sz); -VOID DestroyIcon(HICON hIcon); -COLORREF GetTextColor(HDC hdc); -COLORREF GetBkColor(HDC hdc); -HPALETTE SelectPalette(HDC hdc, HPALETTE hPalette, BOOL b); -BOOL IntersectClipRect(HDC hdc, int x, int y, - int w, int h); -BOOL GetClipBox(HDC hdc, RECT* rect); -BOOL DrawIconEx(HDC hdc, int x, int y, HICON hIcon, int w, int h, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags); -BOOL SetViewportExtEx(HDC hdc, int x, int y, LPSIZE lpSize); -BOOL SetViewportOrgEx(HDC hdc, int x, int y, LPPOINT lpPoint); -BOOL SetWindowExtEx(HDC hdc, int x, int y, LPSIZE lpSize); -BOOL SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lpSize); -BOOL ExtFloodFill(HDC hdc, int x, int y, COLORREF col, UINT flags); -int SetPolyFillMode(HDC hdc, int mode); -BOOL RoundRect(HDC hdc, int left, int top, int right, int bottom, int r1, int r2); -BOOL MaskBlt(HDC hdc, int x, int y, int w, int h, - HDC hDCSource, int xSrc, int ySrc, HBITMAP hBitmapMask, int xMask, int yMask, DWORD rop); -UINT RealizePalette(HDC hDC); -BOOL SetBrushOrgEx(HDC hdc, int xOrigin, int yOrigin, LPPOINT lpPoint); -int GetObject(HGDIOBJ hObj, int sz, LPVOID logObj); - -/* For some reason these aren't defined in the headers */ -BOOL EnableScrollBar (HWND hWnd, int iSBar, BOOL bEnable) ; -BOOL GetScrollPos (HWND hWnd, int iSBar, int* pPos); -BOOL GetScrollRange (HWND hWnd, int iSBar, int* pMinPos, int* pMaxPos); -BOOL SetScrollPos (HWND hWnd, int iSBar, int iNewPos); -BOOL SetScrollRange (HWND hWnd, int iSBar, int iMinPos, int iMaxPos); -BOOL SetScrollInfo (HWND hWnd, int iSBar, - LPCSCROLLINFO lpsi, BOOL fRedraw); -BOOL GetScrollInfo(HWND hWnd, int iSBar, LPSCROLLINFO lpsi); -BOOL ShowScrollBar (HWND hWnd, int iSBar, BOOL bShow); -HBITMAP WINAPI -CreateBitmap( int width, int height, int nPlanes, int bPP, LPCVOID lpData); - -#ifdef __cplusplus -} -#endif - -/* - * Key State Masks for Mouse Messages - */ -#ifndef MK_LBUTTON -#define MK_LBUTTON 0x0001 -#define MK_RBUTTON 0x0002 -#define MK_SHIFT 0x0004 -#define MK_CONTROL 0x0008 -#define MK_MBUTTON 0x0010 -#endif - -/* - * DrawIcon flags - */ - -#ifndef DI_MASK -#define DI_MASK 0x0001 -#define DI_IMAGE 0x0002 -#define DI_NORMAL 0x0003 -#define DI_COMPAT 0x0004 -#define DI_DEFAULTSIZE 0x0008 -#endif - -/* TODO: May have to fake these message */ -#ifndef WM_INITDIALOG -#define WM_INITDIALOG 0x0110 -#endif -#ifndef WM_QUERYENDSESSION -#define WM_QUERYENDSESSION 0x0011 -#endif -#ifndef WM_ENDSESSION -#define WM_ENDSESSION 0x0016 -#endif -#ifndef WM_SETCURSOR -#define WM_SETCURSOR 0x0020 -#endif -#ifndef WM_GETMINMAXINFO -#define WM_GETMINMAXINFO 0x0024 -typedef struct tagMINMAXINFO { - POINT ptReserved; - POINT ptMaxSize; - POINT ptMaxPosition; - POINT ptMinTrackSize; - POINT ptMaxTrackSize; -} MINMAXINFO, *PMINMAXINFO, *LPMINMAXINFO; - -#endif -#ifndef WM_SYSCOMMAND -#define WM_SYSCOMMAND 0x0112 -#endif -#ifndef WM_SYSCOLORCHANGE -#define WM_SYSCOLORCHANGE 0x0015 -#endif -#ifndef WM_QUERYNEWPALETTE -#define WM_QUERYNEWPALETTE 0x030F -#endif -#ifndef WM_PALETTEISCHANGING -#define WM_PALETTEISCHANGING 0x0310 -#endif -#ifndef WM_PALETTECHANGED -#define WM_PALETTECHANGED 0x0311 -#endif -#ifndef WM_NOTIFY -#define WM_NOTIFY 0x004E -#endif -#ifndef WM_DROPFILES -#define WM_DROPFILES 0x0233 -#endif - -#ifndef PALETTERGB -#define PALETTERGB RGB -#endif - -#ifndef MM_TEXT -#define MM_TEXT 1 -#define MM_LOMETRIC 2 -#define MM_HIMETRIC 3 -#define MM_LOENGLISH 4 -#define MM_HIENGLISH 5 -#define MM_TWIPS 6 -#define MM_ISOTROPIC 7 -#define MM_ANISOTROPIC 8 -#endif - -#ifndef SC_MAXIMIZE -#define SC_MINIMIZE 0xF020 -#define SC_MAXIMIZE 0xF030 -#endif - -// TODO: all of them -#ifndef IDC_ARROW -#define IDC_ARROW 1 -#endif - -/* - * Standard Cursor IDs - */ -#ifndef MAKEINTRESOURCE -#define MAKEINTRESOURCE(r) r -#endif - -#ifndef IDC_ARROW -#define IDC_ARROW MAKEINTRESOURCE(32512) -#define IDC_IBEAM MAKEINTRESOURCE(32513) -#define IDC_WAIT MAKEINTRESOURCE(32514) -#define IDC_CROSS MAKEINTRESOURCE(32515) -#define IDC_UPARROW MAKEINTRESOURCE(32516) -#define IDC_SIZE MAKEINTRESOURCE(32640) /* OBSOLETE: use IDC_SIZEALL */ -#define IDC_ICON MAKEINTRESOURCE(32641) /* OBSOLETE: use IDC_ARROW */ -#define IDC_SIZENWSE MAKEINTRESOURCE(32642) -#define IDC_SIZENESW MAKEINTRESOURCE(32643) -#define IDC_SIZEWE MAKEINTRESOURCE(32644) -#define IDC_SIZENS MAKEINTRESOURCE(32645) -#define IDC_SIZEALL MAKEINTRESOURCE(32646) -#define IDC_NO MAKEINTRESOURCE(32648) /* not in win3.1 */ -#if(WINVER >= 0x0500) -#define IDC_HAND MAKEINTRESOURCE(32649) -#endif /* WINVER >= 0x0500 */ -#define IDC_APPSTARTING MAKEINTRESOURCE(32650) /* not in win3.1 */ -#if(WINVER >= 0x0400) -#define IDC_HELP MAKEINTRESOURCE(32651) -#endif /* WINVER >= 0x0400 */ -#endif - -/* ExtFloodFill style flags */ -#define FLOODFILLBORDER 0 -#define FLOODFILLSURFACE 1 - -/* PolyFill() Modes */ -#define ALTERNATE 1 -#define WINDING 2 -#define POLYFILL_LAST 2 - -/* Quaternary raster codes */ -#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore)) - -/* Device Parameters for GetDeviceCaps() */ -#define DRIVERVERSION 0 /* Device driver version */ -#define TECHNOLOGY 2 /* Device classification */ -#define HORZSIZE 4 /* Horizontal size in millimeters */ -#define VERTSIZE 6 /* Vertical size in millimeters */ - -/* Ternary raster operations */ -/* Now defined by MicroWindows */ -#if 0 -#define DSTINVERT (DWORD)0x00550009 /* dest = (NOT dest) */ -#define WHITENESS (DWORD)0x00FF0062 /* dest = WHITE */ -#define SRCERASE (DWORD)0x00440328 /* dest = source AND (NOT dest ) */ -#define MERGEPAINT (DWORD)0x00BB0226 /* dest = (NOT source) OR dest */ -#define SRCPAINT (DWORD)0x00EE0086 /* dest = source OR dest */ -#define NOTSRCCOPY (DWORD)0x00330008 /* dest = (NOT source) */ -#endif - -#endif /* _WX_MICROWIN_H_ */ diff --git a/Source/3rd Party/wx/include/wx/msw/mimetype.h b/Source/3rd Party/wx/include/wx/msw/mimetype.h index 11cf45e21..9052d07dc 100644 --- a/Source/3rd Party/wx/include/wx/msw/mimetype.h +++ b/Source/3rd Party/wx/include/wx/msw/mimetype.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 23.09.98 +// RCS-ID: $Id: mimetype.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// @@ -65,7 +66,7 @@ public: private: // helper function: reads the command corresponding to the specified verb // from the registry (returns an empty string if not found) - wxString GetCommand(const wxString& verb) const; + wxString GetCommand(const wxChar *verb) const; // get the registry path for the given verb wxString GetVerbPath(const wxString& verb) const; @@ -101,6 +102,12 @@ public: size_t EnumAllFileTypes(wxArrayString& mimetypes); + // this are NOPs under Windows + bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = true) + { return true; } + bool ReadMimeTypes(const wxString& WXUNUSED(filename)) + { return true; } + // create a new filetype association wxFileType *Associate(const wxFileTypeInfo& ftInfo); diff --git a/Source/3rd Party/wx/include/wx/msw/minifram.h b/Source/3rd Party/wx/include/wx/msw/minifram.h index 6f74ef490..d2e23d9cf 100644 --- a/Source/3rd Party/wx/include/wx/msw/minifram.h +++ b/Source/3rd Party/wx/include/wx/msw/minifram.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: minifram.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,7 +14,7 @@ #include "wx/frame.h" -class WXDLLIMPEXP_CORE wxMiniFrame : public wxFrame +class WXDLLEXPORT wxMiniFrame : public wxFrame { public: wxMiniFrame() { } diff --git a/Source/3rd Party/wx/include/wx/msw/missing.h b/Source/3rd Party/wx/include/wx/msw/missing.h index 039d3322c..c84134bdf 100644 --- a/Source/3rd Party/wx/include/wx/msw/missing.h +++ b/Source/3rd Party/wx/include/wx/msw/missing.h @@ -3,6 +3,7 @@ // Purpose: Declarations for parts of the Win32 SDK that are missing in // the versions that come with some compilers // Created: 2002/04/23 +// RCS-ID: $Id: missing.h 48436 2007-08-28 19:26:16Z JS $ // Copyright: (c) 2002 Mattia Barbon // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,30 +29,19 @@ #define WM_CONTEXTMENU 0x007B #endif -#ifndef WM_CHANGEUISTATE - #define WM_CHANGEUISTATE 0x0127 -#endif - +// Needed by toplevel.cpp #ifndef WM_UPDATEUISTATE #define WM_UPDATEUISTATE 0x0128 #endif -#ifndef WM_QUERYUISTATE - #define WM_QUERYUISTATE 0x0129 +#ifndef WM_CHANGEUISTATE + #define WM_CHANGEUISTATE 0x0127 #endif #ifndef WM_PRINTCLIENT #define WM_PRINTCLIENT 0x318 #endif -#ifndef DT_HIDEPREFIX - #define DT_HIDEPREFIX 0x00100000 -#endif - -#ifndef DSS_HIDEPREFIX - #define DSS_HIDEPREFIX 0x0200 -#endif - // Needed by toplevel.cpp #ifndef UIS_SET #define UIS_SET 1 @@ -80,18 +70,12 @@ #ifndef WM_MOUSEWHEEL #define WM_MOUSEWHEEL 0x020A #endif - #ifndef WM_MOUSEHWHEEL - #define WM_MOUSEHWHEEL 0x020E - #endif #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 #endif #ifndef SPI_GETWHEELSCROLLLINES #define SPI_GETWHEELSCROLLLINES 104 #endif - #ifndef SPI_GETWHEELSCROLLCHARS - #define SPI_GETWHEELSCROLLCHARS 108 - #endif #endif // wxUSE_MOUSEWHEEL // Needed by window.cpp @@ -103,7 +87,6 @@ #define VK_OEM_5 0xDC #define VK_OEM_6 0xDD #define VK_OEM_7 0xDE - #define VK_OEM_102 0xE2 #endif #ifndef VK_OEM_COMMA @@ -155,8 +138,38 @@ #define LWA_ALPHA 2 #endif -#ifndef QS_ALLPOSTMESSAGE -#define QS_ALLPOSTMESSAGE 0 +#if defined __VISUALC__ && __VISUALC__ <= 1200 && !defined MIIM_BITMAP +#define MIIM_STRING 0x00000040 +#define MIIM_BITMAP 0x00000080 +#define MIIM_FTYPE 0x00000100 +#define HBMMENU_CALLBACK ((HBITMAP) -1) +typedef struct tagMENUINFO +{ + DWORD cbSize; + DWORD fMask; + DWORD dwStyle; + UINT cyMax; + HBRUSH hbrBack; + DWORD dwContextHelpID; + DWORD dwMenuData; +} MENUINFO, FAR *LPMENUINFO; +struct wxMENUITEMINFO_ +{ + UINT cbSize; + UINT fMask; + UINT fType; + UINT fState; + UINT wID; + HMENU hSubMenu; + HBITMAP hbmpChecked; + HBITMAP hbmpUnchecked; + DWORD dwItemData; + LPTSTR dwTypeData; + UINT cch; + HBITMAP hbmpItem; +}; +#else +#define wxMENUITEMINFO_ MENUITEMINFO #endif /* @@ -228,42 +241,15 @@ typedef struct wxtagNMLVCUSTOMDRAW_ { #endif // defined __VISUALC__ && __VISUALC__ <= 1100 // ---------------------------------------------------------------------------- -// menu stuff +// ListView common control +// Needed by listctrl.cpp // ---------------------------------------------------------------------------- -#ifndef MIIM_BITMAP - #define MIIM_STRING 0x00000040 - #define MIIM_BITMAP 0x00000080 - #define MIIM_FTYPE 0x00000100 - #define HBMMENU_CALLBACK ((HBITMAP) -1) - - typedef struct tagMENUINFO - { - DWORD cbSize; - DWORD fMask; - DWORD dwStyle; - UINT cyMax; - HBRUSH hbrBack; - DWORD dwContextHelpID; - DWORD dwMenuData; - } MENUINFO, FAR *LPMENUINFO; -#endif // MIIM_BITMAP &c - -// ---------------------------------------------------------------------------- -// definitions related to ListView and Header common controls, needed by -// msw/listctrl.cpp and msw/headerctrl.cpp -// ---------------------------------------------------------------------------- - -#ifndef I_IMAGENONE - #define I_IMAGENONE (-2) -#endif - #ifndef LVS_EX_FULLROWSELECT #define LVS_EX_FULLROWSELECT 0x00000020 #endif -// LVS_EX_LABELTIP is not supported by Windows CE, don't define it there -#if !defined(LVS_EX_LABELTIP) && !defined(__WXWINCE__) +#ifndef LVS_EX_LABELTIP #define LVS_EX_LABELTIP 0x00004000 #endif @@ -275,18 +261,6 @@ typedef struct wxtagNMLVCUSTOMDRAW_ { #define HDN_GETDISPINFOW (HDN_FIRST-29) #endif -#ifndef HDS_HOTTRACK - #define HDS_HOTTRACK 4 -#endif -#ifndef HDS_FLAT - #define HDS_FLAT 0x0200 -#endif - -#ifndef HDF_SORTUP - #define HDF_SORTUP 0x0400 - #define HDF_SORTDOWN 0x0200 -#endif - /* * In addition to the above, the following are required for several compilers. */ @@ -342,7 +316,6 @@ typedef struct wxtagNMLVCUSTOMDRAW_ { #ifdef __DMC__ -#ifndef VER_NT_WORKSTATION typedef struct _OSVERSIONINFOEX { DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; @@ -356,7 +329,6 @@ typedef struct _OSVERSIONINFOEX { BYTE wProductType; BYTE wReserved; } OSVERSIONINFOEX; -#endif // !defined(VER_NT_WORKSTATION) #ifndef _TrackMouseEvent #define _TrackMouseEvent TrackMouseEvent @@ -395,34 +367,6 @@ typedef struct _OSVERSIONINFOEX { #define LVM_GETHEADER (LVM_FIRST+31) #endif -#ifndef HDLAYOUT - #define HDLAYOUT HD_LAYOUT -#endif - -#ifndef HDITEM - #define HDITEM HD_ITEM -#endif - -#ifndef NMHEADER - #define NMHEADER HD_NOTIFY -#endif - -#ifndef HDS_DRAGDROP - #define HDS_DRAGDROP 0x0040 -#endif -#ifndef HDS_FULLDRAG - #define HDS_FULLDRAG 0x0080 -#endif - - -#ifndef HDN_BEGINDRAG - #define HDN_BEGINDRAG (HDN_FIRST - 11) -#endif - -#ifndef HDN_ENDDRAG - #define HDN_ENDDRAG (HDN_FIRST - 10) -#endif - #ifndef LVSICF_NOSCROLL #define LVSICF_NOINVALIDATEALL 0x0001 #define LVSICF_NOSCROLL 0x0002 @@ -524,141 +468,6 @@ typedef struct #endif -#endif - -//Various defines that will be needed by mingw and possibly VC++6 -//Used by the webview library - -#ifndef DISPID_COMMANDSTATECHANGE -#define DISPID_COMMANDSTATECHANGE 105 -#endif - -#ifndef DISPID_NAVIGATECOMPLETE2 -#define DISPID_NAVIGATECOMPLETE2 252 -#endif - -#ifndef DISPID_NAVIGATEERROR -#define DISPID_NAVIGATEERROR 271 -#endif - -#ifndef DISPID_NEWWINDOW3 -#define DISPID_NEWWINDOW3 273 -#endif - -#ifndef INET_E_ERROR_FIRST -#define INET_E_ERROR_FIRST 0x800C0002L -#endif - -#ifndef INET_E_INVALID_URL -#define INET_E_INVALID_URL 0x800C0002L -#endif - -#ifndef INET_E_NO_SESSION -#define INET_E_NO_SESSION 0x800C0003L -#endif - -#ifndef INET_E_CANNOT_CONNECT -#define INET_E_CANNOT_CONNECT 0x800C0004L -#endif - -#ifndef INET_E_RESOURCE_NOT_FOUND -#define INET_E_RESOURCE_NOT_FOUND 0x800C0005L -#endif - -#ifndef INET_E_OBJECT_NOT_FOUND -#define INET_E_OBJECT_NOT_FOUND 0x800C0006L -#endif - -#ifndef INET_E_DATA_NOT_AVAILABLE -#define INET_E_DATA_NOT_AVAILABLE 0x800C0007L -#endif - -#ifndef INET_E_DOWNLOAD_FAILURE -#define INET_E_DOWNLOAD_FAILURE 0x800C0008L -#endif - -#ifndef INET_E_AUTHENTICATION_REQUIRED -#define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L -#endif - -#ifndef INET_E_NO_VALID_MEDIA -#define INET_E_NO_VALID_MEDIA 0x800C000AL -#endif - -#ifndef INET_E_CONNECTION_TIMEOUT -#define INET_E_CONNECTION_TIMEOUT 0x800C000BL -#endif - -#ifndef INET_E_INVALID_REQUEST -#define INET_E_INVALID_REQUEST 0x800C000CL -#endif - -#ifndef INET_E_UNKNOWN_PROTOCOL -#define INET_E_UNKNOWN_PROTOCOL 0x800C000DL -#endif - -#ifndef INET_E_SECURITY_PROBLEM -#define INET_E_SECURITY_PROBLEM 0x800C000EL -#endif - -#ifndef INET_E_CANNOT_LOAD_DATA -#define INET_E_CANNOT_LOAD_DATA 0x800C000FL -#endif - -#ifndef INET_E_CANNOT_INSTANTIATE_OBJECT -#define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L -#endif - -#ifndef INET_E_QUERYOPTION_UNKNOWN -#define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L -#endif - -#ifndef INET_E_REDIRECT_FAILED -#define INET_E_REDIRECT_FAILED 0x800C0014L -#endif - -#ifndef INET_E_REDIRECT_TO_DIR -#define INET_E_REDIRECT_TO_DIR 0x800C0015L -#endif - -#ifndef INET_E_CANNOT_LOCK_REQUEST -#define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L -#endif - -#ifndef INET_E_USE_EXTEND_BINDING -#define INET_E_USE_EXTEND_BINDING 0x800C0017L -#endif - -#ifndef INET_E_TERMINATED_BIND -#define INET_E_TERMINATED_BIND 0x800C0018L -#endif - -#ifndef INET_E_INVALID_CERTIFICATE -#define INET_E_INVALID_CERTIFICATE 0x800C0019L -#endif - -#ifndef INET_E_CODE_DOWNLOAD_DECLINED -#define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L -#endif - -#ifndef INET_E_RESULT_DISPATCHED -#define INET_E_RESULT_DISPATCHED 0x800C0200L -#endif - -#ifndef INET_E_CANNOT_REPLACE_SFP_FILE -#define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L -#endif - -#ifndef INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY -#define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L -#endif - -#ifndef INET_E_CODE_INSTALL_SUPPRESSED -#define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L -#endif - -#ifndef MUI_LANGUAGE_NAME -#define MUI_LANGUAGE_NAME 0x8 #endif /* @@ -682,9 +491,5 @@ typedef struct #endif #endif // defined __WINE__ -#ifndef INVALID_FILE_ATTRIBUTES - #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) -#endif - #endif // _WX_MISSING_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/msgdlg.h b/Source/3rd Party/wx/include/wx/msw/msgdlg.h index f83f99fee..690678b8d 100644 --- a/Source/3rd Party/wx/include/wx/msw/msgdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/msgdlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: msgdlg.h 37164 2006-01-26 17:20:50Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,64 +12,31 @@ #ifndef _WX_MSGBOXDLG_H_ #define _WX_MSGBOXDLG_H_ -class WXDLLIMPEXP_CORE wxMessageDialog : public wxMessageDialogBase +#include "wx/defs.h" +#include "wx/dialog.h" + +/* + * Message box dialog + */ + +extern WXDLLEXPORT_DATA(const wxChar) wxMessageBoxCaptionStr[]; + +class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase { -public: - wxMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, - const wxPoint& WXUNUSED(pos) = wxDefaultPosition) - : wxMessageDialogBase(parent, message, caption, style) - { - m_hook = NULL; - } - - virtual int ShowModal(); - - virtual long GetEffectiveIcon() const; - - // implementation-specific - - // return the font used for the text in the message box - static wxFont GetMessageFont(); - +DECLARE_DYNAMIC_CLASS(wxMessageDialog) protected: - // Override this as task dialogs are always centered on parent. - virtual void DoCentre(int dir); + wxString m_caption; + wxString m_message; + wxWindow * m_parent; +public: + wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, + long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition); -private: - // hook procedure used to adjust the message box beyond what the standard - // MessageBox() function can do for us - static WXLRESULT wxCALLBACK HookFunction(int code, WXWPARAM, WXLPARAM); + int ShowModal(void); - static const struct ButtonAccessors - { - int id; - wxString (wxMessageDialog::*getter)() const; - } ms_buttons[]; - - // replace the static text control with a text control in order to show - // scrollbar (and also, incidentally, allow text selection) - void ReplaceStaticWithEdit(); - - // adjust the button labels - // - // this is called from HookFunction() and our HWND is valid at this moment - void AdjustButtonLabels(); - - // offset all buttons starting from the first one given by dx to the right - void OffsetButtonsStartingFrom(int first, int dx); - - // used by ShowModal() to display a message box when task dialogs - // aren't available. - int ShowMessageBox(); - - - WXHANDLE m_hook; // HHOOK used to position the message box - - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxMessageDialog); + DECLARE_NO_COPY_CLASS(wxMessageDialog) }; -#endif // _WX_MSGBOXDLG_H_ +#endif + // _WX_MSGBOXDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/mslu.h b/Source/3rd Party/wx/include/wx/msw/mslu.h index a2117c2dc..83f4060d7 100644 --- a/Source/3rd Party/wx/include/wx/msw/mslu.h +++ b/Source/3rd Party/wx/include/wx/msw/mslu.h @@ -5,6 +5,7 @@ // Modified by: Vadim Zeitlin to move out various functions to other files // to fix header inter-dependencies // Created: 2002/02/17 +// RCS-ID: $Id: mslu.h 42462 2006-10-26 19:06:51Z VZ $ // Copyright: (c) 2002 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/msw/msvcrt.h b/Source/3rd Party/wx/include/wx/msw/msvcrt.h index 0c07cfa03..15c4dfbde 100644 --- a/Source/3rd Party/wx/include/wx/msw/msvcrt.h +++ b/Source/3rd Party/wx/include/wx/msw/msvcrt.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 31.01.1999 +// RCS-ID: $Id: msvcrt.h 42363 2006-10-24 23:19:12Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,8 +14,7 @@ // used like this: // wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); // to turn on memory leak checks for programs compiled with Microsoft Visual -// C++ (5.0+). The macro will not be defined under other compilers or if it -// can't be used with MSVC for whatever reason. +// C++ (5.0+). The macro will expand to nothing under other compilers. #ifndef _MSW_MSVCRT_H_ #define _MSW_MSVCRT_H_ @@ -22,7 +22,7 @@ // use debug CRT functions for memory leak detections in VC++ 5.0+ in debug // builds #undef wxUSE_VC_CRTDBG -#if defined(_DEBUG) && defined(__VISUALC__) && (__VISUALC__ >= 1000) \ +#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000) \ && !defined(UNDER_CE) // it doesn't combine well with wxWin own memory debugging methods #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !wxUSE_MEMORY_TRACING && !defined(__NO_VC_CRTDBG__) @@ -31,19 +31,19 @@ #endif #ifdef wxUSE_VC_CRTDBG + // VC++ uses this macro as debug/release mode indicator + #ifndef _DEBUG + #define _DEBUG + #endif + // Need to undef new if including crtdbg.h which may redefine new itself #ifdef new #undef new #endif #include - - // Defining _CRTBLD should never be necessary at all, but keep it for now - // as there is no time to retest all the compilers before 3.0 release. - // Definitely do not use it with MSVS 2013 as defining it results in errors - // if the standard is included afterwards. - #if !defined(_CRTBLD) && !wxCHECK_VISUALC_VERSION(12) - // Needed when building with pure MS SDK + #ifndef _CRTBLD + // Need when builded with pure MS SDK #define _CRTBLD #endif @@ -54,7 +54,7 @@ // this define works around a bug with inline declarations of new, see // - // http://support.microsoft.com/kb/q140858/ + // http://support.microsoft.com/support/kb/articles/Q140/8/58.asp // // for the details #define new WXDEBUG_NEW diff --git a/Source/3rd Party/wx/include/wx/msw/nonownedwnd.h b/Source/3rd Party/wx/include/wx/msw/nonownedwnd.h deleted file mode 100644 index 72e3e6b07..000000000 --- a/Source/3rd Party/wx/include/wx/msw/nonownedwnd.h +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/nonownedwnd.h -// Purpose: wxNonOwnedWindow declaration for wxMSW. -// Author: Vadim Zeitlin -// Created: 2011-10-09 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_NONOWNEDWND_H_ -#define _WX_MSW_NONOWNEDWND_H_ - -class wxNonOwnedWindowShapeImpl; - -// ---------------------------------------------------------------------------- -// wxNonOwnedWindow -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase -{ -public: - wxNonOwnedWindow(); - virtual ~wxNonOwnedWindow(); - -protected: - virtual bool DoClearShape(); - virtual bool DoSetRegionShape(const wxRegion& region); -#if wxUSE_GRAPHICS_CONTEXT - virtual bool DoSetPathShape(const wxGraphicsPath& path); - -private: - wxNonOwnedWindowShapeImpl* m_shapeImpl; -#endif // wxUSE_GRAPHICS_CONTEXT - - wxDECLARE_NO_COPY_CLASS(wxNonOwnedWindow); -}; - -#endif // _WX_MSW_NONOWNEDWND_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/notebook.h b/Source/3rd Party/wx/include/wx/msw/notebook.h index fc0c1edd8..5832c2d0e 100644 --- a/Source/3rd Party/wx/include/wx/msw/notebook.h +++ b/Source/3rd Party/wx/include/wx/msw/notebook.h @@ -3,6 +3,7 @@ // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet) // Author: Robert Roebling // Modified by: Vadim Zeitlin for Windows version +// RCS-ID: $Id: notebook.h 41797 2006-10-09 12:10:01Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,7 +23,41 @@ // wxNotebook // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase +class WXDLLEXPORT wxNotebookPageInfo : public wxObject +{ +public : + wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; } + virtual ~wxNotebookPageInfo() { } + + void Create(wxNotebookPage *page, + const wxString& text, + bool selected, + int imageId) + { + m_page = page; + m_text = text; + m_selected = selected; + m_imageId = imageId; + } + + wxNotebookPage* GetPage() const { return m_page; } + wxString GetText() const { return m_text; } + bool GetSelected() const { return m_selected; } + int GetImageId() const { return m_imageId; } + +private: + wxNotebookPage *m_page; + wxString m_text; + bool m_selected; + int m_imageId; + + DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo) +}; + + +WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); + +class WXDLLEXPORT wxNotebook : public wxNotebookBase { public: // ctors @@ -51,9 +86,11 @@ public: virtual size_t GetPageCount() const; // set the currently selected page, return the index of the previously - // selected one (or wxNOT_FOUND on error) + // selected one (or -1 on error) // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events int SetSelection(size_t nPage); + // get the currently selected page + int GetSelection() const { return m_nSelection; } // changes selected page without sending events int ChangeSelection(size_t nPage); @@ -95,7 +132,10 @@ public: wxNotebookPage *pPage, const wxString& strText, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = -1); + + void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ); } + const wxNotebookPageInfoList& GetPageInfos() const; // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH // style. @@ -110,6 +150,7 @@ public: // callbacks // --------- void OnSize(wxSizeEvent& event); + void OnSelChange(wxNotebookEvent& event); void OnNavigationKey(wxNavigationKeyEvent& event); // base class virtuals @@ -141,10 +182,11 @@ public: return true; } + // return the themed brush for painting our children + virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd); + // draw child background virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win); - - virtual bool MSWHasInheritableBackground() const { return true; } #endif // wxUSE_UXTHEME // translate wxWin styles to the Windows ones @@ -155,7 +197,7 @@ protected: void Init(); // hides the currently shown page and shows the given one (if not -1) and - // updates m_selection accordingly + // updates m_nSelection accordingly void UpdateSelection(int selNew); // remove one page from the notebook, without deleting @@ -170,9 +212,6 @@ protected: void AdjustPageSize(wxNotebookPage *page); #if wxUSE_UXTHEME - // return the themed brush for painting our children - virtual WXHBRUSH MSWGetCustomBgBrush() { return m_hbrBackground; } - // gets the bitmap of notebook background and returns a brush from it WXHBRUSH QueryBgBitmap(); @@ -193,11 +232,13 @@ protected: // true if we have already subclassed our updown control bool m_hasSubclassedUpdown; - - // true if we already refreshed the current page after showing the window - bool m_doneUpdateHack; #endif // __WXWINCE__ + // the current selection (-1 if none) + int m_nSelection; + + wxNotebookPageInfoList m_pageInfos; + #if wxUSE_UXTHEME // background brush used to paint the tab control WXHBRUSH m_hbrBackground; diff --git a/Source/3rd Party/wx/include/wx/msw/notifmsg.h b/Source/3rd Party/wx/include/wx/msw/notifmsg.h deleted file mode 100644 index b7e0e0e86..000000000 --- a/Source/3rd Party/wx/include/wx/msw/notifmsg.h +++ /dev/null @@ -1,74 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/notifmsg.h -// Purpose: implementation of wxNotificationMessage for Windows -// Author: Vadim Zeitlin -// Created: 2007-12-01 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_NOTIFMSG_H_ -#define _WX_MSW_NOTIFMSG_H_ - -class WXDLLIMPEXP_FWD_ADV wxTaskBarIcon; - -// ---------------------------------------------------------------------------- -// wxNotificationMessage -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxNotificationMessage : public wxNotificationMessageBase -{ -public: - wxNotificationMessage() { Init(); } - wxNotificationMessage(const wxString& title, - const wxString& message = wxString(), - wxWindow *parent = NULL, - int flags = wxICON_INFORMATION) - : wxNotificationMessageBase(title, message, parent, flags) - { - Init(); - } - - virtual ~wxNotificationMessage(); - - - virtual bool Show(int timeout = Timeout_Auto); - virtual bool Close(); - - // MSW implementation-specific methods - - // by default, wxNotificationMessage under MSW creates a temporary taskbar - // icon to which it attaches the notification, if there is an existing - // taskbar icon object in the application you may want to call this method - // to attach the notification to it instead (we won't take ownership of it - // and you can also pass NULL to not use the icon for notifications any - // more) - // - // returns the task bar icon which was used previously (may be NULL) - static wxTaskBarIcon *UseTaskBarIcon(wxTaskBarIcon *icon); - - // call this to always use the generic implementation, even if the system - // supports the balloon tooltips used by the native one - static void AlwaysUseGeneric(bool alwaysUseGeneric) - { - ms_alwaysUseGeneric = alwaysUseGeneric; - } - -private: - // common part of all ctors - void Init() { m_impl = NULL; } - - - // flag indicating whether we should always use generic implementation - static bool ms_alwaysUseGeneric; - - // the real implementation of this class (selected during run-time because - // the balloon task bar icons are not available in all Windows versions) - class wxNotifMsgImpl *m_impl; - - - wxDECLARE_NO_COPY_CLASS(wxNotificationMessage); -}; - -#endif // _WX_MSW_NOTIFMSG_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/ole/access.h b/Source/3rd Party/wx/include/wx/msw/ole/access.h deleted file mode 100644 index 980943edb..000000000 --- a/Source/3rd Party/wx/include/wx/msw/ole/access.h +++ /dev/null @@ -1,67 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/access.h -// Purpose: declaration of the wxAccessible class -// Author: Julian Smart -// Modified by: -// Created: 2003-02-12 -// Copyright: (c) 2003 Julian Smart -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ACCESS_H_ -#define _WX_ACCESS_H_ - -#if wxUSE_ACCESSIBILITY - -// ---------------------------------------------------------------------------- -// forward declarations -// ---------------------------------------------------------------------------- - -class wxIAccessible; -class WXDLLIMPEXP_FWD_CORE wxWindow; - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// wxAccessible implements accessibility behaviour. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxAccessible : public wxAccessibleBase -{ -public: - wxAccessible(wxWindow *win = NULL); - virtual ~wxAccessible(); - -// Overridables - -// Accessors - - // Returns the wxIAccessible pointer - wxIAccessible* GetIAccessible() { return m_pIAccessible; } - - // Returns the IAccessible standard interface pointer - void* GetIAccessibleStd() ; - -// Operations - - // Sends an event when something changes in an accessible object. - static void NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType, - int objectId); - -protected: - void Init(); - -private: - wxIAccessible * m_pIAccessible; // the pointer to COM interface - void* m_pIAccessibleStd; // the pointer to the standard COM interface, - // for default processing - - wxDECLARE_NO_COPY_CLASS(wxAccessible); -}; - -#endif //wxUSE_ACCESSIBILITY - -#endif //_WX_ACCESS_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/ole/activex.h b/Source/3rd Party/wx/include/wx/msw/ole/activex.h index e3ecd13cd..20de45c2d 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/activex.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/activex.h @@ -4,6 +4,7 @@ // Author: Ryan Norton // Modified by: // Created: 8/18/05 +// RCS-ID: $Id: activex.h 41793 2006-10-09 09:32:08Z ABX $ // Copyright: (c) Ryan Norton // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -26,8 +27,6 @@ #include "wx/window.h" #include "wx/variant.h" -class FrameSite; - //--------------------------------------------------------------------------- // MSW COM includes //--------------------------------------------------------------------------- @@ -70,94 +69,78 @@ class FrameSite; // //--------------------------------------------------------------------------- -template -class wxAutoOleInterface -{ -public: - typedef I Interface; - - explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) - {} - wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) - { QueryInterface(riid, pUnk); } - wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) - { QueryInterface(riid, pDispatch); } - wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL) - { CreateInstance(clsid, riid); } - wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL) - { operator=(ti); } - - wxAutoOleInterface& operator=(const wxAutoOleInterface& ti) - { - if ( ti.m_interface ) - ti.m_interface->AddRef(); - Free(); - m_interface = ti.m_interface; - return *this; - } - - wxAutoOleInterface& operator=(I*& ti) - { - Free(); - m_interface = ti; - return *this; - } - - ~wxAutoOleInterface() { Free(); } - - void Free() - { - if ( m_interface ) - m_interface->Release(); - m_interface = NULL; - } - - HRESULT QueryInterface(REFIID riid, IUnknown *pUnk) - { - Free(); - wxASSERT(pUnk != NULL); - return pUnk->QueryInterface(riid, (void **)&m_interface); - } - - HRESULT CreateInstance(REFCLSID clsid, REFIID riid) - { - Free(); - return CoCreateInstance - ( - clsid, - NULL, - CLSCTX_ALL, - riid, - (void **)&m_interface - ); - } - - operator I*() const {return m_interface; } - I* operator->() {return m_interface; } - I** GetRef() {return &m_interface; } - bool Ok() const { return IsOk(); } - bool IsOk() const { return m_interface != NULL; } - -protected: - I *m_interface; +#define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \ +class wxAutoOleInterface \ +{ \ + protected: \ + I *m_interface; \ +\ + public: \ + explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \ + wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \ + { QueryInterface(riid, pUnk); } \ + wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \ + { QueryInterface(riid, pDispatch); } \ + wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\ + { CreateInstance(clsid, riid); }\ + wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\ + { operator = (ti); }\ +\ + wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\ + {\ + if (ti.m_interface)\ + ti.m_interface->AddRef();\ + Free();\ + m_interface = ti.m_interface;\ + return *this;\ + }\ +\ + wxAutoOleInterface& operator = (I *&ti)\ + {\ + Free();\ + m_interface = ti;\ + return *this;\ + }\ +\ + ~wxAutoOleInterface() { Free(); }\ +\ + inline void Free()\ + {\ + if (m_interface)\ + m_interface->Release();\ + m_interface = NULL;\ + }\ +\ + HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\ + {\ + Free();\ + wxASSERT(pUnk != NULL);\ + return pUnk->QueryInterface(riid, (void **) &m_interface);\ + }\ +\ + HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\ + {\ + Free();\ + return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\ + }\ +\ + inline operator I *() const {return m_interface;}\ + inline I* operator ->() {return m_interface;}\ + inline I** GetRef() {return &m_interface;}\ + inline bool Ok() const { return IsOk(); }\ + inline bool IsOk() const {return m_interface != NULL;}\ }; -#if WXWIN_COMPATIBILITY_2_8 -// this macro is kept for compatibility with older wx versions -#define WX_DECLARE_AUTOOLE(wxAutoOleInterfaceType, I) \ - typedef wxAutoOleInterface wxAutoOleInterfaceType; -#endif // WXWIN_COMPATIBILITY_2_8 +WX_DECLARE_AUTOOLE(wxAutoIDispatch, IDispatch) +WX_DECLARE_AUTOOLE(wxAutoIOleClientSite, IOleClientSite) +WX_DECLARE_AUTOOLE(wxAutoIUnknown, IUnknown) +WX_DECLARE_AUTOOLE(wxAutoIOleObject, IOleObject) +WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject, IOleInPlaceObject) +WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject, IOleInPlaceActiveObject) +WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView, IOleDocumentView) +WX_DECLARE_AUTOOLE(wxAutoIViewObject, IViewObject) -typedef wxAutoOleInterface wxAutoIDispatch; -typedef wxAutoOleInterface wxAutoIOleClientSite; -typedef wxAutoOleInterface wxAutoIUnknown; -typedef wxAutoOleInterface wxAutoIOleObject; -typedef wxAutoOleInterface wxAutoIOleInPlaceObject; -typedef wxAutoOleInterface wxAutoIOleInPlaceActiveObject; -typedef wxAutoOleInterface wxAutoIOleDocumentView; -typedef wxAutoOleInterface wxAutoIViewObject; - -class WXDLLIMPEXP_CORE wxActiveXContainer : public wxWindow +class wxActiveXContainer : public wxWindow { public: wxActiveXContainer(wxWindow * parent, REFIID iid, IUnknown* pUnk); @@ -167,14 +150,11 @@ public: void OnPaint(wxPaintEvent&); void OnSetFocus(wxFocusEvent&); void OnKillFocus(wxFocusEvent&); - virtual bool MSWTranslateMessage(WXMSG* pMsg); - virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc); protected: friend class FrameSite; friend class wxActiveXEvents; - FrameSite *m_frameSite; wxAutoIDispatch m_Dispatch; wxAutoIOleClientSite m_clientSite; wxAutoIUnknown m_ActiveX; @@ -191,30 +171,9 @@ protected: void CreateActiveX(REFIID, IUnknown*); }; -///\brief Store native event parameters. -///\detail Store OLE 'Invoke' parameters for event handlers that need to access them. -/// These are the exact values for the event as they are passed to the wxActiveXContainer. -struct wxActiveXEventNativeMSW -{ - DISPID dispIdMember; - REFIID riid; - LCID lcid; - WORD wFlags; - DISPPARAMS *pDispParams; - VARIANT *pVarResult; - EXCEPINFO *pExcepInfo; - unsigned int *puArgErr; - - wxActiveXEventNativeMSW - (DISPID a_dispIdMember, REFIID a_riid, LCID a_lcid, WORD a_wFlags, DISPPARAMS *a_pDispParams, - VARIANT *a_pVarResult, EXCEPINFO *a_pExcepInfo, unsigned int *a_puArgErr) - :dispIdMember(a_dispIdMember), riid(a_riid), lcid(a_lcid), wFlags(a_wFlags), pDispParams(a_pDispParams), - pVarResult(a_pVarResult), pExcepInfo(a_pExcepInfo), puArgErr(a_puArgErr) - { } -}; // Events -class WXDLLIMPEXP_CORE wxActiveXEvent : public wxCommandEvent +class wxActiveXEvent : public wxCommandEvent { private: friend class wxActiveXEvents; @@ -225,38 +184,37 @@ public: virtual wxEvent *Clone() const { return new wxActiveXEvent(*this); } - size_t ParamCount() const; + size_t ParamCount() const + { return m_params.GetCount(); } wxString ParamType(size_t idx) const { - wxASSERT(idx < ParamCount()); + wxASSERT(idx < m_params.GetCount()); return m_params[idx].GetType(); } wxString ParamName(size_t idx) const { - wxASSERT(idx < ParamCount()); + wxASSERT(idx < m_params.GetCount()); return m_params[idx].GetName(); } - wxVariant& operator[] (size_t idx); + wxVariant& operator[] (size_t idx) + { + wxASSERT(idx < ParamCount()); + return m_params[idx]; + } DISPID GetDispatchId() const { return m_dispid; } - - wxActiveXEventNativeMSW *GetNativeParameters() const - { return (wxActiveXEventNativeMSW*)GetClientData(); } }; -// #define wxACTIVEX_ID 14001 -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_ACTIVEX, wxActiveXEvent ); - +#define wxACTIVEX_ID 14001 +DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_ACTIVEX, wxACTIVEX_ID) typedef void (wxEvtHandler::*wxActiveXEventFunction)(wxActiveXEvent&); - +#define EVT_ACTIVEX(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxActiveXEventFunction) & fn, (wxObject *) NULL ), #define wxActiveXEventHandler(func) \ - wxEVENT_HANDLER_CAST( wxActiveXEventFunction, func ) - -#define EVT_ACTIVEX(id, fn) wxDECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, wxActiveXEventHandler( fn ), NULL ), + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActiveXEventFunction, &func) #endif // wxUSE_ACTIVEX diff --git a/Source/3rd Party/wx/include/wx/msw/ole/automtn.h b/Source/3rd Party/wx/include/wx/msw/ole/automtn.h index dcf719ed5..9dd1e3763 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/automtn.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/automtn.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/automtn.h +// Name: automtn.h // Purpose: OLE automation utilities // Author: Julian Smart // Modified by: // Created: 11/6/98 +// RCS-ID: $Id: automtn.h 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) 1998, Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -20,49 +21,32 @@ typedef void WXIDISPATCH; typedef unsigned short* WXBSTR; -typedef unsigned long WXLCID; #ifdef GetObject #undef GetObject #endif -// Flags used with wxAutomationObject::GetInstance() -enum wxAutomationInstanceFlags -{ - // Only use the existing instance, never create a new one. - wxAutomationInstance_UseExistingOnly = 0, - - // Create a new instance if there are no existing ones. - wxAutomationInstance_CreateIfNeeded = 1, - - // Do not log errors if we failed to get the existing instance because none - // is available. - wxAutomationInstance_SilentIfNone = 2 -}; - /* * wxAutomationObject * Wraps up an IDispatch pointer and invocation; does variant conversion. */ -class WXDLLIMPEXP_CORE wxAutomationObject: public wxObject +class WXDLLEXPORT wxAutomationObject: public wxObject { public: wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL); virtual ~wxAutomationObject(); // Set/get dispatch pointer - void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; } - WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; } - bool IsOk() const { return m_dispatchPtr != NULL; } + inline void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; } + inline WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; } // Get a dispatch pointer from the current object associated - // with a ProgID, such as "Excel.Application" - bool GetInstance(const wxString& progId, - int flags = wxAutomationInstance_CreateIfNeeded) const; + // with a class id, such as "Excel.Application" + bool GetInstance(const wxString& classId) const; - // Get a dispatch pointer from a new instance of the class - bool CreateInstance(const wxString& progId) const; + // Get a dispatch pointer from a new instance of the the class + bool CreateInstance(const wxString& classId) const; // Low-level invocation function. Pass either an array of variants, // or an array of pointers to variants. @@ -80,7 +64,7 @@ public: const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant); // Get/Put property - wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const; + wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const; wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const; wxVariant GetProperty(const wxString& property, const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant, @@ -103,36 +87,13 @@ public: // A way of initialising another wxAutomationObject with a dispatch object, // without having to deal with nasty IDispatch pointers. - bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const; + bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const; bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const; - // Returns the locale identifier used in automation calls. The default is - // LOCALE_SYSTEM_DEFAULT. Objects obtained by GetObject() inherit the - // locale identifier from the one that created them. - WXLCID GetLCID() const; - - // Sets the locale identifier to be used in automation calls performed by - // this object. The default is LOCALE_SYSTEM_DEFAULT. - void SetLCID(WXLCID lcid); - - // Returns the flags used for conversions between wxVariant and OLE - // VARIANT, see wxOleConvertVariantFlags. The default value is - // wxOleConvertVariant_Default but all the objects obtained by GetObject() - // inherit the flags from the one that created them. - long GetConvertVariantFlags() const; - - // Sets the flags used for conversions between wxVariant and OLE VARIANT, - // see wxOleConvertVariantFlags (default is wxOleConvertVariant_Default. - void SetConvertVariantFlags(long flags); - -public: // public for compatibility only, don't use m_dispatchPtr directly. +public: WXIDISPATCH* m_dispatchPtr; -private: - WXLCID m_lcid; - long m_convertVariantFlags; - - wxDECLARE_NO_COPY_CLASS(wxAutomationObject); + DECLARE_NO_COPY_CLASS(wxAutomationObject) }; #endif // wxUSE_OLE_AUTOMATION diff --git a/Source/3rd Party/wx/include/wx/msw/ole/dataform.h b/Source/3rd Party/wx/include/wx/msw/ole/dataform.h index 4f90bdf09..f94c87f86 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/dataform.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/dataform.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/dataform.h +// Name: msw/ole/dataform.h // Purpose: declaration of the wxDataFormat class // Author: Vadim Zeitlin // Modified by: // Created: 19.10.99 (extracted from msw/ole/dataobj.h) +// RCS-ID: $Id: dataform.h 28812 2004-08-16 12:45:46Z ABX $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,21 +16,14 @@ // wxDataFormat identifies the single format of data // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDataFormat +class WXDLLEXPORT wxDataFormat { public: // the clipboard formats under Win32 are WORD's typedef unsigned short NativeFormat; wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; } - - // we need constructors from all string types as implicit conversions to - // wxString don't apply when we already rely on implicit conversion of a, - // for example, "char *" string to wxDataFormat, and existing code does it - wxDataFormat(const wxString& format) { SetId(format); } - wxDataFormat(const char *format) { SetId(format); } - wxDataFormat(const wchar_t *format) { SetId(format); } - wxDataFormat(const wxCStrData& format) { SetId(format); } + wxDataFormat(const wxChar *format) { SetId(format); } wxDataFormat& operator=(NativeFormat format) { m_format = format; return *this; } @@ -39,10 +33,14 @@ public: // default copy ctor/assignment operators ok // comparison (must have both versions) - bool operator==(wxDataFormatId format) const; - bool operator!=(wxDataFormatId format) const; - bool operator==(const wxDataFormat& format) const; - bool operator!=(const wxDataFormat& format) const; + bool operator==(wxDataFormatId format) const + { return m_format == (NativeFormat)format; } + bool operator!=(wxDataFormatId format) const + { return m_format != (NativeFormat)format; } + bool operator==(const wxDataFormat& format) const + { return m_format == format.m_format; } + bool operator!=(const wxDataFormat& format) const + { return m_format != format.m_format; } // explicit and implicit conversions to NativeFormat which is one of // standard data types (implicit conversion is useful for preserving the @@ -57,7 +55,7 @@ public: // string ids are used for custom types - this SetId() must be used for // application-specific formats wxString GetId() const; - void SetId(const wxString& format); + void SetId(const wxChar *format); // returns true if the format is one of those defined in wxDataFormatId bool IsStandard() const { return m_format > 0 && m_format < wxDF_PRIVATE; } diff --git a/Source/3rd Party/wx/include/wx/msw/ole/dataobj.h b/Source/3rd Party/wx/include/wx/msw/ole/dataobj.h index fb9d2a177..71cd44553 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/dataobj.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/dataobj.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/dataobj.h +// Name: msw/ole/dataobj.h // Purpose: declaration of the wxDataObject class // Author: Vadim Zeitlin // Modified by: // Created: 10.05.98 +// RCS-ID: $Id: dataobj.h 37406 2006-02-09 03:45:14Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ struct IDataObject; // wxDataObject is a "smart" and polymorphic piece of data. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDataObject : public wxDataObjectBase +class WXDLLEXPORT wxDataObject : public wxDataObjectBase { public: // ctor & dtor @@ -58,7 +59,7 @@ public: #define wxGetFormatName(format) wxDataObject::GetFormatName(format) #else // !Debug - #define wxGetFormatName(format) wxT("") + #define wxGetFormatName(format) _T("") #endif // Debug/!Debug // they need to be accessed from wxIDataObject, so made them public, // or wxIDataObject friend @@ -72,7 +73,7 @@ public: private: IDataObject *m_pIDataObject; // pointer to the COM interface - wxDECLARE_NO_COPY_CLASS(wxDataObject); + DECLARE_NO_COPY_CLASS(wxDataObject) }; #endif //_WX_MSW_OLE_DATAOBJ_H diff --git a/Source/3rd Party/wx/include/wx/msw/ole/dataobj2.h b/Source/3rd Party/wx/include/wx/msw/ole/dataobj2.h index cb76273c6..dc1954d0b 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/dataobj2.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/dataobj2.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 21.10.99 +// RCS-ID: $Id: dataobj2.h 40772 2006-08-23 13:38:45Z VZ $ // Copyright: (c) 1999 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -20,7 +21,7 @@ // rarely used). This is ugly, but I haven't found a solution for it yet. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapDataObject : public wxBitmapDataObjectBase +class WXDLLEXPORT wxBitmapDataObject : public wxBitmapDataObjectBase { public: // ctors @@ -50,7 +51,7 @@ private: // the DIB data void /* BITMAPINFO */ *m_data; - wxDECLARE_NO_COPY_CLASS(wxBitmapDataObject); + DECLARE_NO_COPY_CLASS(wxBitmapDataObject) }; // ---------------------------------------------------------------------------- @@ -59,7 +60,7 @@ private: // FIXME did I already mention it was ugly? // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapDataObject2 : public wxBitmapDataObjectBase +class WXDLLEXPORT wxBitmapDataObject2 : public wxBitmapDataObjectBase { public: // ctors @@ -83,14 +84,14 @@ public: { return SetData(len, buf); } private: - wxDECLARE_NO_COPY_CLASS(wxBitmapDataObject2); + DECLARE_NO_COPY_CLASS(wxBitmapDataObject2) }; // ---------------------------------------------------------------------------- // wxFileDataObject - data object for CF_HDROP // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxFileDataObject : public wxFileDataObjectBase +class WXDLLEXPORT wxFileDataObject : public wxFileDataObjectBase { public: wxFileDataObject() { } @@ -111,14 +112,14 @@ public: { return SetData(len, buf); } private: - wxDECLARE_NO_COPY_CLASS(wxFileDataObject); + DECLARE_NO_COPY_CLASS(wxFileDataObject) }; // ---------------------------------------------------------------------------- // wxURLDataObject: data object for URLs // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxURLDataObject : public wxDataObjectComposite +class WXDLLEXPORT wxURLDataObject : public wxDataObjectComposite { public: // initialize with URL in ctor or use SetURL later @@ -139,7 +140,7 @@ private: // last data object we got data in wxDataObjectSimple *m_dataObjectLast; - wxDECLARE_NO_COPY_CLASS(wxURLDataObject); + DECLARE_NO_COPY_CLASS(wxURLDataObject) }; #endif // _WX_MSW_OLE_DATAOBJ2_H diff --git a/Source/3rd Party/wx/include/wx/msw/ole/dropsrc.h b/Source/3rd Party/wx/include/wx/msw/ole/dropsrc.h index c137da1ce..8646558f9 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/dropsrc.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/dropsrc.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/dropsrc.h +// Name: ole/dropsrc.h // Purpose: declaration of the wxDropSource class // Author: Vadim Zeitlin // Modified by: // Created: 06.03.98 +// RCS-ID: $Id: dropsrc.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -29,14 +30,14 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; // the cursor 'name' from the resources under MSW, but will expand to // something else under GTK. If you don't use it, you will have to use #ifdef // in the application code. -#define wxDROP_ICON(name) wxCursor(wxT(#name)) +#define wxDROP_ICON(name) wxCursor(_T(#name)) // ---------------------------------------------------------------------------- // wxDropSource is used to start the drag-&-drop operation on associated // wxDataObject object. It's responsible for giving UI feedback while dragging. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDropSource : public wxDropSourceBase +class WXDLLEXPORT wxDropSource : public wxDropSourceBase { public: // ctors: if you use default ctor you must call SetData() later! @@ -70,7 +71,7 @@ protected: private: wxIDropSource *m_pIDropSource; // the pointer to COM interface - wxDECLARE_NO_COPY_CLASS(wxDropSource); + DECLARE_NO_COPY_CLASS(wxDropSource) }; #endif //wxUSE_DRAG_AND_DROP diff --git a/Source/3rd Party/wx/include/wx/msw/ole/droptgt.h b/Source/3rd Party/wx/include/wx/msw/ole/droptgt.h index f7cee12ee..a1d44a0ef 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/droptgt.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/droptgt.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/droptgt.h +// Name: ole/droptgt.h // Purpose: declaration of the wxDropTarget class // Author: Vadim Zeitlin // Modified by: // Created: 06.03.98 +// RCS-ID: $Id: droptgt.h 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -18,7 +19,6 @@ // ---------------------------------------------------------------------------- class wxIDropTarget; -struct wxIDropTargetHelper; struct IDataObject; // ---------------------------------------------------------------------------- @@ -31,7 +31,7 @@ struct IDataObject; // (all of them, including protected ones which are called by the class itself) // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDropTarget : public wxDropTargetBase +class WXDLLEXPORT wxDropTarget : public wxDropTargetBase { public: // ctor & dtor @@ -47,41 +47,24 @@ public: virtual bool OnDrop(wxCoord x, wxCoord y); virtual bool GetData(); - // Can only be called during OnXXX methods. - wxDataFormat GetMatchingPair(); - // implementation only from now on // ------------------------------- // do we accept this kind of data? - bool MSWIsAcceptedData(IDataObject *pIDataSource) const; + bool IsAcceptedData(IDataObject *pIDataSource) const; // give us the data source from IDropTarget::Drop() - this is later used by // GetData() when it's called from inside OnData() - void MSWSetDataSource(IDataObject *pIDataSource); - - // These functions take care of all things necessary to support native drag - // images. - // - // {Init,End}DragImageSupport() are called during Register/Revoke, - // UpdateDragImageOnXXX() functions are called on the corresponding drop - // target events. - void MSWInitDragImageSupport(); - void MSWEndDragImageSupport(); - void MSWUpdateDragImageOnData(wxCoord x, wxCoord y, wxDragResult res); - void MSWUpdateDragImageOnDragOver(wxCoord x, wxCoord y, wxDragResult res); - void MSWUpdateDragImageOnEnter(wxCoord x, wxCoord y, wxDragResult res); - void MSWUpdateDragImageOnLeave(); + void SetDataSource(IDataObject *pIDataSource); private: // helper used by IsAcceptedData() and GetData() - wxDataFormat MSWGetSupportedFormat(IDataObject *pIDataSource) const; + wxDataFormat GetSupportedFormat(IDataObject *pIDataSource) const; - wxIDropTarget *m_pIDropTarget; // the pointer to our COM interface - IDataObject *m_pIDataSource; // the pointer to the source data object - wxIDropTargetHelper *m_dropTargetHelper; // the drop target helper + wxIDropTarget *m_pIDropTarget; // the pointer to our COM interface + IDataObject *m_pIDataSource; // the pointer to the source data object - wxDECLARE_NO_COPY_CLASS(wxDropTarget); + DECLARE_NO_COPY_CLASS(wxDropTarget) }; #endif //wxUSE_DRAG_AND_DROP diff --git a/Source/3rd Party/wx/include/wx/msw/ole/oleutils.h b/Source/3rd Party/wx/include/wx/msw/ole/oleutils.h index 9b5ee2651..635c11b19 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/oleutils.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/oleutils.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/oleutils.h +// Name: oleutils.h // Purpose: OLE helper routines, OLE debugging support &c // Author: Vadim Zeitlin // Modified by: // Created: 19.02.1998 +// RCS-ID: $Id: oleutils.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,6 @@ #include #include "wx/intl.h" #include "wx/log.h" -#include "wx/variant.h" // ============================================================================ // General purpose functions and macros @@ -36,21 +36,14 @@ // return true if ok, false otherwise inline bool wxOleInitialize() { - HRESULT + // we need to initialize OLE library #ifdef __WXWINCE__ - hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + if ( FAILED(::CoInitializeEx(NULL, COINIT_MULTITHREADED)) ) #else - hr = ::OleInitialize(NULL); + if ( FAILED(::OleInitialize(NULL)) ) #endif - - // RPC_E_CHANGED_MODE indicates that OLE had been already initialized - // before, albeit with different mode. Don't consider it to be an error as - // we don't actually care ourselves about the mode used so this allows the - // main application to call OleInitialize() on its own before we do if it - // needs non-default mode. - if ( hr != RPC_E_CHANGED_MODE && FAILED(hr) ) { - wxLogError(wxGetTranslation("Cannot initialize OLE")); + wxLogError(_("Cannot initialize OLE")); return false; } @@ -82,7 +75,7 @@ inline void ReleaseInterface(IUnknown *pIUnk) #define RELEASE_AND_NULL(p) if ( (p) != NULL ) { p->Release(); p = NULL; }; // return true if the iid is in the array -extern WXDLLIMPEXP_CORE bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount); +extern bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount); // ============================================================================ // IUnknown implementation helpers @@ -140,10 +133,9 @@ private: wxAutoULong m_cRef // macros for declaring supported interfaces -// NB: ADD_IID prepends IID_I whereas ADD_RAW_IID does not +// NB: you should write ADD_INTERFACE(Foo) and not ADD_INTERFACE(IID_IFoo)! #define BEGIN_IID_TABLE(cname) const IID *cname::ms_aIids[] = { #define ADD_IID(iid) &IID_I##iid, -#define ADD_RAW_IID(iid) &iid, #define END_IID_TABLE } // implementation is as straightforward as possible @@ -151,7 +143,7 @@ private: #define IMPLEMENT_IUNKNOWN_METHODS(classname) \ STDMETHODIMP classname::QueryInterface(REFIID riid, void **ppv) \ { \ - wxLogQueryInterface(wxT(#classname), riid); \ + wxLogQueryInterface(_T(#classname), riid); \ \ if ( IsIidFromList(riid, ms_aIids, WXSIZEOF(ms_aIids)) ) { \ *ppv = this; \ @@ -168,14 +160,14 @@ private: \ STDMETHODIMP_(ULONG) classname::AddRef() \ { \ - wxLogAddRef(wxT(#classname), m_cRef); \ + wxLogAddRef(_T(#classname), m_cRef); \ \ return ++m_cRef; \ } \ \ STDMETHODIMP_(ULONG) classname::Release() \ { \ - wxLogRelease(wxT(#classname), m_cRef); \ + wxLogRelease(_T(#classname), m_cRef); \ \ if ( --m_cRef == wxAutoULong(0) ) { \ delete this; \ @@ -192,17 +184,17 @@ private: // VZ: I don't know it's not done for compilers other than VC++ but I leave it // as is. Please note, though, that tracing OLE interface calls may be // incredibly useful when debugging OLE programs. -#if defined(__WXDEBUG__) && (( defined(__VISUALC__) && (__VISUALC__ >= 1000) )) +#if defined(__WXDEBUG__) && ( ( defined(__VISUALC__) && (__VISUALC__ >= 1000) ) || defined(__MWERKS__) ) // ---------------------------------------------------------------------------- // All OLE specific log functions have DebugTrace level (as LogTrace) // ---------------------------------------------------------------------------- // tries to translate riid into a symbolic name, if possible -WXDLLIMPEXP_CORE void wxLogQueryInterface(const wxChar *szInterface, REFIID riid); +void wxLogQueryInterface(const wxChar *szInterface, REFIID riid); // these functions print out the new value of reference counter -WXDLLIMPEXP_CORE void wxLogAddRef (const wxChar *szInterface, ULONG cRef); -WXDLLIMPEXP_CORE void wxLogRelease(const wxChar *szInterface, ULONG cRef); +void wxLogAddRef (const wxChar *szInterface, ULONG cRef); +void wxLogRelease(const wxChar *szInterface, ULONG cRef); #else //!__WXDEBUG__ #define wxLogQueryInterface(szInterface, riid) @@ -212,137 +204,43 @@ WXDLLIMPEXP_CORE void wxLogRelease(const wxChar *szInterface, ULONG cRef); // wrapper around BSTR type (by Vadim Zeitlin) -class WXDLLIMPEXP_CORE wxBasicString +class WXDLLEXPORT wxBasicString { public: // ctors & dtor + wxBasicString(const char *sz); wxBasicString(const wxString& str); - wxBasicString(const wxBasicString& bstr); ~wxBasicString(); - wxBasicString& operator=(const wxBasicString& bstr); + void Init(const char* sz); // accessors - // just get the string - operator BSTR() const { return m_bstrBuf; } - // retrieve a copy of our string - caller must SysFreeString() it later! - BSTR Get() const { return SysAllocString(m_bstrBuf); } + // just get the string + operator BSTR() const { return m_wzBuf; } + // retrieve a copy of our string - caller must SysFreeString() it later! + BSTR Get() const { return SysAllocString(m_wzBuf); } private: - // actual string - BSTR m_bstrBuf; + // @@@ not implemented (but should be) + wxBasicString(const wxBasicString&); + wxBasicString& operator=(const wxBasicString&); + + OLECHAR *m_wzBuf; // actual string }; #if wxUSE_VARIANT // Convert variants class WXDLLIMPEXP_FWD_BASE wxVariant; -// wrapper for CURRENCY type used in VARIANT (VARIANT.vt == VT_CY) -class WXDLLIMPEXP_CORE wxVariantDataCurrency : public wxVariantData -{ -public: - wxVariantDataCurrency() { VarCyFromR8(0.0, &m_value); } - wxVariantDataCurrency(CURRENCY value) { m_value = value; } - - CURRENCY GetValue() const { return m_value; } - void SetValue(CURRENCY value) { m_value = value; } - - virtual bool Eq(wxVariantData& data) const; - -#if wxUSE_STD_IOSTREAM - virtual bool Write(wxSTD ostream& str) const; -#endif - virtual bool Write(wxString& str) const; - - wxVariantData* Clone() const { return new wxVariantDataCurrency(m_value); } - virtual wxString GetType() const { return wxS("currency"); } - - DECLARE_WXANY_CONVERSION() - -private: - CURRENCY m_value; -}; - - -// wrapper for SCODE type used in VARIANT (VARIANT.vt == VT_ERROR) -class WXDLLIMPEXP_CORE wxVariantDataErrorCode : public wxVariantData -{ -public: - wxVariantDataErrorCode(SCODE value = S_OK) { m_value = value; } - - SCODE GetValue() const { return m_value; } - void SetValue(SCODE value) { m_value = value; } - - virtual bool Eq(wxVariantData& data) const; - -#if wxUSE_STD_IOSTREAM - virtual bool Write(wxSTD ostream& str) const; -#endif - virtual bool Write(wxString& str) const; - - wxVariantData* Clone() const { return new wxVariantDataErrorCode(m_value); } - virtual wxString GetType() const { return wxS("errorcode"); } - - DECLARE_WXANY_CONVERSION() - -private: - SCODE m_value; -}; - -// wrapper for SAFEARRAY, used for passing multidimensional arrays in wxVariant -class WXDLLIMPEXP_CORE wxVariantDataSafeArray : public wxVariantData -{ -public: - wxEXPLICIT wxVariantDataSafeArray(SAFEARRAY* value = NULL) - { - m_value = value; - } - - SAFEARRAY* GetValue() const { return m_value; } - void SetValue(SAFEARRAY* value) { m_value = value; } - - virtual bool Eq(wxVariantData& data) const; - -#if wxUSE_STD_IOSTREAM - virtual bool Write(wxSTD ostream& str) const; -#endif - virtual bool Write(wxString& str) const; - - wxVariantData* Clone() const { return new wxVariantDataSafeArray(m_value); } - virtual wxString GetType() const { return wxS("safearray"); } - - DECLARE_WXANY_CONVERSION() - -private: - SAFEARRAY* m_value; -}; - -// Used by wxAutomationObject for its wxConvertOleToVariant() calls. -enum wxOleConvertVariantFlags -{ - wxOleConvertVariant_Default = 0, - - // If wxOleConvertVariant_ReturnSafeArrays flag is set, SAFEARRAYs - // contained in OLE VARIANTs will be returned as wxVariants - // with wxVariantDataSafeArray type instead of wxVariants - // with the list type containing the (flattened) SAFEARRAY's elements. - wxOleConvertVariant_ReturnSafeArrays = 1 -}; - -WXDLLIMPEXP_CORE -bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant); - -WXDLLIMPEXP_CORE -bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant, - long flags = wxOleConvertVariant_Default); - +WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant); +WXDLLEXPORT bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant); #endif // wxUSE_VARIANT // Convert string to Unicode -WXDLLIMPEXP_CORE BSTR wxConvertStringToOle(const wxString& str); +WXDLLEXPORT BSTR wxConvertStringToOle(const wxString& str); // Convert string from BSTR to wxString -WXDLLIMPEXP_CORE wxString wxConvertStringFromOle(BSTR bStr); +WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr); #else // !wxUSE_OLE @@ -355,30 +253,4 @@ inline void wxOleUninitialize() { } #endif // wxUSE_OLE/!wxUSE_OLE -// RAII class initializing OLE in its ctor and undoing it in its dtor. -class wxOleInitializer -{ -public: - wxOleInitializer() - : m_ok(wxOleInitialize()) - { - } - - bool IsOk() const - { - return m_ok; - } - - ~wxOleInitializer() - { - if ( m_ok ) - wxOleUninitialize(); - } - -private: - const bool m_ok; - - wxDECLARE_NO_COPY_CLASS(wxOleInitializer); -}; - #endif //_WX_OLEUTILS_H diff --git a/Source/3rd Party/wx/include/wx/msw/ole/safearray.h b/Source/3rd Party/wx/include/wx/msw/ole/safearray.h deleted file mode 100644 index fb5c70a39..000000000 --- a/Source/3rd Party/wx/include/wx/msw/ole/safearray.h +++ /dev/null @@ -1,394 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: msw/ole/safearray.h -// Purpose: Helpers for working with OLE SAFEARRAYs. -// Author: PB -// Created: 2012-09-23 -// Copyright: (c) 2012 wxWidgets development team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSW_OLE_SAFEARRAY_H_ -#define _MSW_OLE_SAFEARRAY_H_ - -#include "wx/msw/ole/oleutils.h" - -#if wxUSE_OLE && wxUSE_VARIANT - -/* - wxSafeArray is wxWidgets wrapper for working with MS Windows SAFEARRAYs. - It also has convenience functions for converting between SAFEARRAY - and wxVariant with list type or wxArrayString. -*/ - -// The base class with type-independent methods. It exists solely in order to -// reduce the template bloat. -class WXDLLIMPEXP_CORE wxSafeArrayBase -{ -public: - // If owns a SAFEARRAY, it's unlocked and destroyed. - virtual ~wxSafeArrayBase() { Destroy(); } - - // Unlocks and destroys the owned SAFEARRAY. - void Destroy(); - - // Unlocks the owned SAFEARRAY, returns it and gives up its ownership. - SAFEARRAY* Detach(); - - // Returns true if has a valid SAFEARRAY. - bool HasArray() const { return m_array != NULL; } - - // Returns the number of dimensions. - size_t GetDim() const; - - // Returns lower bound for dimension dim in bound. Dimensions start at 1. - bool GetLBound(size_t dim, long& bound) const; - - // Returns upper bound for dimension dim in bound. Dimensions start at 1. - bool GetUBound(size_t dim, long& bound) const; - - // Returns element count for dimension dim. Dimensions start at 1. - size_t GetCount(size_t dim) const; - -protected: - // Default constructor, protected so the class can't be used on its own, - // it's only used as a base class of wxSafeArray<>. - wxSafeArrayBase() - { - m_array = NULL; - } - - bool Lock(); - bool Unlock(); - - SAFEARRAY* m_array; -}; - -// wxSafeArrayConvertor<> must be specialized for the type in order to allow -// using it with wxSafeArray<>. -// -// We specialize it below for the standard types. -template -struct wxSafeArrayConvertor {}; - -/** - Macro for specializing wxSafeArrayConvertor for simple types. - - The template parameters are: - - externType: basic C data type, e.g. wxFloat64 or wxInt32 - - varType: corresponding VARIANT type constant, e.g. VT_R8 or VT_I4. -*/ -#define wxSPECIALIZE_WXSAFEARRAY_CONVERTOR_SIMPLE(externType, varType) \ -template <> \ -struct wxSafeArrayConvertor \ -{ \ - typedef externType externT; \ - typedef externT internT; \ - static bool ToArray(const externT& from, internT& to) \ - { \ - to = from; \ - return true; \ - } \ - static bool FromArray(const internT& from, externT& to) \ - { \ - to = from; \ - return true; \ - } \ -} - -wxSPECIALIZE_WXSAFEARRAY_CONVERTOR_SIMPLE(wxInt16, VT_I2); -wxSPECIALIZE_WXSAFEARRAY_CONVERTOR_SIMPLE(wxInt32, VT_I4); -wxSPECIALIZE_WXSAFEARRAY_CONVERTOR_SIMPLE(wxFloat32, VT_R4); -wxSPECIALIZE_WXSAFEARRAY_CONVERTOR_SIMPLE(wxFloat64, VT_R8); - -// Specialization for VT_BSTR using wxString. -template <> -struct wxSafeArrayConvertor -{ - typedef wxString externT; - typedef BSTR internT; - - static bool ToArray(const wxString& from, BSTR& to) - { - BSTR bstr = wxConvertStringToOle(from); - - if ( !bstr && !from.empty() ) - { - // BSTR can be NULL for empty strings but if the string was - // not empty, it means we failed to allocate memory for it. - return false; - } - to = bstr; - return true; - } - - static bool FromArray(const BSTR from, wxString& to) - { - to = wxConvertStringFromOle(from); - return true; - } -}; - -// Specialization for VT_VARIANT using wxVariant. -template <> -struct wxSafeArrayConvertor -{ - typedef wxVariant externT; - typedef VARIANT internT; - - static bool ToArray(const wxVariant& from, VARIANT& to) - { - return wxConvertVariantToOle(from, to); - } - - static bool FromArray(const VARIANT& from, wxVariant& to) - { - return wxConvertOleToVariant(from, to); - } -}; - - -template -class wxSafeArray : public wxSafeArrayBase -{ -public: - typedef wxSafeArrayConvertor Convertor; - typedef typename Convertor::internT internT; - typedef typename Convertor::externT externT; - - // Default constructor. - wxSafeArray() - { - m_array = NULL; - } - - // Creates and locks a zero-based one-dimensional SAFEARRAY with the given - // number of elements. - bool Create(size_t count) - { - SAFEARRAYBOUND bound; - - bound.lLbound = 0; - bound.cElements = count; - return Create(&bound, 1); - } - - // Creates and locks a SAFEARRAY. See SafeArrayCreate() in MSDN - // documentation for more information. - bool Create(SAFEARRAYBOUND* bound, size_t dimensions) - { - wxCHECK_MSG( !m_array, false, wxS("Can't be created twice") ); - - m_array = SafeArrayCreate(varType, dimensions, bound); - if ( !m_array ) - return false; - - return Lock(); - } - - /** - Creates a 0-based one-dimensional SAFEARRAY from wxVariant with the - list type. - - Can be called only for wxSafeArray. - */ - bool CreateFromListVariant(const wxVariant& variant) - { - wxCHECK(varType == VT_VARIANT, false); - wxCHECK(variant.GetType() == wxS("list"), false); - - if ( !Create(variant.GetCount()) ) - return false; - - VARIANT* data = static_cast(m_array->pvData); - - for ( size_t i = 0; i < variant.GetCount(); i++) - { - if ( !Convertor::ToArray(variant[i], data[i]) ) - return false; - } - return true; - } - - /** - Creates a 0-based one-dimensional SAFEARRAY from wxArrayString. - - Can be called only for wxSafeArray. - */ - bool CreateFromArrayString(const wxArrayString& strings) - { - wxCHECK(varType == VT_BSTR, false); - - if ( !Create(strings.size()) ) - return false; - - BSTR* data = static_cast(m_array->pvData); - - for ( size_t i = 0; i < strings.size(); i++ ) - { - if ( !Convertor::ToArray(strings[i], data[i]) ) - return false; - } - return true; - } - - /** - Attaches and locks an existing SAFEARRAY. - The array must have the same VARTYPE as this wxSafeArray was - instantiated with. - */ - bool Attach(SAFEARRAY* array) - { - wxCHECK_MSG(!m_array && array, false, - wxS("Can only attach a valid array to an uninitialized one") ); - - VARTYPE vt; - HRESULT hr = SafeArrayGetVartype(array, &vt); - if ( FAILED(hr) ) - { - wxLogApiError(wxS("SafeArrayGetVarType()"), hr); - return false; - } - - wxCHECK_MSG(vt == varType, false, - wxS("Attaching array of invalid type")); - - m_array = array; - return Lock(); - } - - /** - Indices have the same row-column order as rgIndices in - SafeArrayPutElement(), i.e. they follow BASIC rules, NOT C ones. - */ - bool SetElement(long* indices, const externT& element) - { - wxCHECK_MSG( m_array, false, wxS("Uninitialized array") ); - wxCHECK_MSG( indices, false, wxS("Invalid index") ); - - internT* data; - - if ( FAILED( SafeArrayPtrOfIndex(m_array, (LONG *)indices, (void**)&data) ) ) - return false; - - return Convertor::ToArray(element, *data); - } - - /** - Indices have the same row-column order as rgIndices in - SafeArrayPutElement(), i.e. they follow BASIC rules, NOT C ones. - */ - bool GetElement(long* indices, externT& element) const - { - wxCHECK_MSG( m_array, false, wxS("Uninitialized array") ); - wxCHECK_MSG( indices, false, wxS("Invalid index") ); - - internT* data; - - if ( FAILED( SafeArrayPtrOfIndex(m_array, (LONG *)indices, (void**)&data) ) ) - return false; - - return Convertor::FromArray(*data, element); - } - - /** - Converts the array to a wxVariant with the list type, regardless of the - underlying SAFEARRAY type. - - If the array is multidimensional, it is flattened using the alghoritm - originally employed in wxConvertOleToVariant(). - */ - bool ConvertToVariant(wxVariant& variant) const - { - wxCHECK_MSG( m_array, false, wxS("Uninitialized array") ); - - size_t dims = m_array->cDims; - size_t count = 1; - - for ( size_t i = 0; i < dims; i++ ) - count *= m_array->rgsabound[i].cElements; - - const internT* data = static_cast(m_array->pvData); - externT element; - - variant.ClearList(); - for ( size_t i1 = 0; i1 < count; i1++ ) - { - if ( !Convertor::FromArray(data[i1], element) ) - { - variant.ClearList(); - return false; - } - variant.Append(element); - } - return true; - } - - /** - Converts an array to an ArrayString. - - Can be called only for wxSafeArray. If the array is - multidimensional, it is flattened using the alghoritm originally - employed in wxConvertOleToVariant(). - */ - bool ConvertToArrayString(wxArrayString& strings) const - { - wxCHECK_MSG( m_array, false, wxS("Uninitialized array") ); - wxCHECK(varType == VT_BSTR, false); - - size_t dims = m_array->cDims; - size_t count = 1; - - for ( size_t i = 0; i < dims; i++ ) - count *= m_array->rgsabound[i].cElements; - - const BSTR* data = static_cast(m_array->pvData); - wxString element; - - strings.clear(); - strings.reserve(count); - for ( size_t i1 = 0; i1 < count; i1++ ) - { - if ( !Convertor::FromArray(data[i1], element) ) - { - strings.clear(); - return false; - } - strings.push_back(element); - } - return true; - } - - static bool ConvertToVariant(SAFEARRAY* psa, wxVariant& variant) - { - wxSafeArray sa; - bool result = false; - - if ( sa.Attach(psa) ) - result = sa.ConvertToVariant(variant); - - if ( sa.HasArray() ) - sa.Detach(); - - return result; - } - - static bool ConvertToArrayString(SAFEARRAY* psa, wxArrayString& strings) - { - wxSafeArray sa; - bool result = false; - - if ( sa.Attach(psa) ) - result = sa.ConvertToArrayString(strings); - - if ( sa.HasArray() ) - sa.Detach(); - - return result; - } - - wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxSafeArray, varType); -}; - -#endif // wxUSE_OLE && wxUSE_VARIANT - -#endif // _MSW_OLE_SAFEARRAY_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/ole/uuid.h b/Source/3rd Party/wx/include/wx/msw/ole/uuid.h index 80e7d8859..0609448ec 100644 --- a/Source/3rd Party/wx/include/wx/msw/ole/uuid.h +++ b/Source/3rd Party/wx/include/wx/msw/ole/uuid.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ole/uuid.h +// Name: ole/uuid.h // Purpose: encapsulates an UUID with some added helper functions // Author: Vadim Zeitlin // Modified by: // Created: 11.07.97 +// RCS-ID: $Id: uuid.h 55113 2008-08-18 11:30:10Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence // @@ -13,7 +14,7 @@ #ifndef _WX_OLEUUID_H #define _WX_OLEUUID_H -#include "wx/chartype.h" +#include "wx/wxchar.h" // ------------------------------------------------------------------ // UUID (Universally Unique IDentifier) definition // ------------------------------------------------------------------ @@ -43,7 +44,7 @@ typedef unsigned char uchar; // ------------------------------------------------------------------ // uses RPC functions to create/convert Universally Unique Identifiers -class WXDLLIMPEXP_CORE Uuid +class WXDLLEXPORT Uuid { private: UUID m_uuid; @@ -73,9 +74,11 @@ public: bool Set(const wxChar *pc); // from a string, returns true if ok void Set(const UUID& uuid); // from another UUID (never fails) +#if wxABI_VERSION >= 20809 // comparison operators bool operator==(const Uuid& uuid) const; - bool operator!=(const Uuid& uuid) const { return !(*this == uuid); } + bool operator!=(const Uuid& uuid) const; +#endif // wxABI_VERSION >= 2.8.9 // accessors operator const UUID*() const { return &m_uuid; } diff --git a/Source/3rd Party/wx/include/wx/msw/ownerdrw.h b/Source/3rd Party/wx/include/wx/msw/ownerdrw.h deleted file mode 100644 index 789a7f2d7..000000000 --- a/Source/3rd Party/wx/include/wx/msw/ownerdrw.h +++ /dev/null @@ -1,28 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/ownerdrw.h -// Purpose: wxOwnerDrawn class -// Author: Marcin Malich -// Modified by: -// Created: 2009-09-22 -// Copyright: (c) 2009 Marcin Malich -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_OWNERDRW_H_ -#define _WX_OWNERDRW_H_ - -#if wxUSE_OWNER_DRAWN - -class WXDLLIMPEXP_CORE wxOwnerDrawn : public wxOwnerDrawnBase -{ -public: - wxOwnerDrawn() {} - virtual ~wxOwnerDrawn() {} - - virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, - wxODAction act, wxODStatus stat); -}; - -#endif // wxUSE_OWNER_DRAWN - -#endif // _WX_OWNERDRW_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/palette.h b/Source/3rd Party/wx/include/wx/msw/palette.h index 19c604e08..87b59ec33 100644 --- a/Source/3rd Party/wx/include/wx/msw/palette.h +++ b/Source/3rd Party/wx/include/wx/msw/palette.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: palette.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,38 +14,45 @@ #include "wx/gdiobj.h" -class WXDLLIMPEXP_CORE wxPalette : public wxPaletteBase +class WXDLLIMPEXP_FWD_CORE wxPalette; + +class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData +{ + friend class WXDLLIMPEXP_FWD_CORE wxPalette; +public: + wxPaletteRefData(void); + virtual ~wxPaletteRefData(void); +protected: + WXHPALETTE m_hPalette; +}; + +#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) + +class WXDLLEXPORT wxPalette: public wxPaletteBase { public: - wxPalette() { } - wxPalette(int n, - const unsigned char *red, const unsigned char *green, const unsigned char *blue) - { - Create(n, red, green, blue); - } - - bool Create(int n, - const unsigned char *red, const unsigned char *green, const unsigned char *blue); + wxPalette(); + wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + virtual ~wxPalette(void); + bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + + int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const; + bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; virtual int GetColoursCount() const; - int - GetPixel(unsigned char red, unsigned char green, unsigned char blue) const; + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk(void) const { return (m_refData != NULL) ; } - bool - GetRGB(int pixel, - unsigned char *red, unsigned char *green, unsigned char *blue) const; + virtual bool FreeResource(bool force = false); // implemetation - WXHPALETTE GetHPALETTE() const; + inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); } void SetHPALETTE(WXHPALETTE pal); - -protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; - + private: DECLARE_DYNAMIC_CLASS(wxPalette) }; -#endif // _WX_PALETTE_H_ +#endif + // _WX_PALETTE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/panel.h b/Source/3rd Party/wx/include/wx/msw/panel.h deleted file mode 100644 index 4762bef19..000000000 --- a/Source/3rd Party/wx/include/wx/msw/panel.h +++ /dev/null @@ -1,56 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/panel.h -// Purpose: wxMSW-specific wxPanel class. -// Author: Vadim Zeitlin -// Created: 2011-03-18 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PANEL_H_ -#define _WX_MSW_PANEL_H_ - -class WXDLLIMPEXP_FWD_CORE wxBrush; - -// ---------------------------------------------------------------------------- -// wxPanel -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPanel : public wxPanelBase -{ -public: - wxPanel() { } - - wxPanel(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxPanelNameStr) - { - Create(parent, winid, pos, size, style, name); - } - - // This is overridden for MSW to return true for all panels that are child - // of a window with themed background (such as wxNotebook) which should - // show through the child panels. - virtual bool HasTransparentBackground(); - - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_CONSTRUCTOR( - wxPanel(wxWindow *parent, - int x, int y, int width, int height, - long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxPanelNameStr) - { - Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name); - } - ) -#endif // WXWIN_COMPATIBILITY_2_8 - -private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel); -}; - -#endif // _WX_MSW_PANEL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/pen.h b/Source/3rd Party/wx/include/wx/msw/pen.h index e05902183..caf378d33 100644 --- a/Source/3rd Party/wx/include/wx/msw/pen.h +++ b/Source/3rd Party/wx/include/wx/msw/pen.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Vadim Zeitlin: fixed operator=(), ==(), !=() // Created: 01/02/97 +// RCS-ID: $Id: pen.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,66 +13,119 @@ #define _WX_PEN_H_ #include "wx/gdiobj.h" -#include "wx/gdicmn.h" +#include "wx/bitmap.h" +#include "wx/colour.h" + +typedef WXDWORD wxMSWDash; + +class WXDLLIMPEXP_FWD_CORE wxPen; + +// VZ: this class should be made private +class WXDLLEXPORT wxPenRefData : public wxGDIRefData +{ +public: + wxPenRefData(); + wxPenRefData(const wxPenRefData& data); + virtual ~wxPenRefData(); + + bool operator==(const wxPenRefData& data) const + { + // we intentionally don't compare m_hPen fields here + return m_style == data.m_style && + m_width == data.m_width && + m_join == data.m_join && + m_cap == data.m_cap && + m_colour == data.m_colour && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && + (m_style != wxUSER_DASH || + (m_nbDash == data.m_nbDash && + memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); + } + +protected: + int m_width; + int m_style; + int m_join; + int m_cap; + wxBitmap m_stipple; + int m_nbDash; + wxDash * m_dash; + wxColour m_colour; + WXHPEN m_hPen; + +private: + friend class WXDLLIMPEXP_FWD_CORE wxPen; + + // Cannot use + // DECLARE_NO_COPY_CLASS(wxPenRefData) + // because copy constructor is explicitly declared above; + // but no copy assignment operator is defined, so declare + // it private to prevent the compiler from defining it: + wxPenRefData& operator=(const wxPenRefData&); +}; + +#define M_PENDATA ((wxPenRefData *)m_refData) +#define wxPENDATA(x) ((wxPenRefData *)(x).m_refData) // ---------------------------------------------------------------------------- // Pen // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPen : public wxPenBase +class WXDLLEXPORT wxPen : public wxGDIObject { public: - wxPen() { } - wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID); -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxDEPRECATED_FUTURE( wxPen(const wxColour& col, int width, int style) ); -#endif - + wxPen(); + wxPen(const wxColour& col, int width = 1, int style = wxSOLID); wxPen(const wxBitmap& stipple, int width); - virtual ~wxPen() { } + virtual ~wxPen(); + + bool operator==(const wxPen& pen) const + { + const wxPenRefData *penData = (wxPenRefData *)pen.m_refData; + + // an invalid pen is only equal to another invalid pen + return m_refData ? penData && *M_PENDATA == *penData : !penData; + } - bool operator==(const wxPen& pen) const; bool operator!=(const wxPen& pen) const { return !(*this == pen); } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const { return (m_refData != NULL); } + // Override in order to recreate the pen void SetColour(const wxColour& col); void SetColour(unsigned char r, unsigned char g, unsigned char b); void SetWidth(int width); - void SetStyle(wxPenStyle style); + void SetStyle(int style); void SetStipple(const wxBitmap& stipple); void SetDashes(int nb_dashes, const wxDash *dash); - void SetJoin(wxPenJoin join); - void SetCap(wxPenCap cap); + void SetJoin(int join); + void SetCap(int cap); - wxColour GetColour() const; - int GetWidth() const; - wxPenStyle GetStyle() const; - wxPenJoin GetJoin() const; - wxPenCap GetCap() const; - int GetDashes(wxDash** ptr) const; - wxDash* GetDash() const; - int GetDashCount() const; - wxBitmap* GetStipple() const; + wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); } + int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); } + int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); } + int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); } + int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); } + int GetDashes(wxDash **ptr) const + { + *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); + return (M_PENDATA ? M_PENDATA->m_nbDash : 0); + } + wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); } + inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); } -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxDEPRECATED_FUTURE( void SetStyle(int style) ) - { SetStyle((wxPenStyle)style); } -#endif + inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); } - // internal: wxGDIObject methods - virtual bool RealizeResource(); - virtual bool FreeResource(bool force = false); - virtual WXHANDLE GetResourceHandle() const; - virtual bool IsFree() const; - -protected: - virtual wxGDIRefData* CreateGDIRefData() const; - virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; - - // same as FreeResource() + RealizeResource() - bool Recreate(); + // Internal + bool RealizeResource(); + bool FreeResource(bool force = false); + WXHANDLE GetResourceHandle() const; + bool IsFree() const; + void Unshare(); +private: DECLARE_DYNAMIC_CLASS(wxPen) }; diff --git a/Source/3rd Party/wx/include/wx/msw/popupwin.h b/Source/3rd Party/wx/include/wx/msw/popupwin.h index 143f64e49..56f63fef4 100644 --- a/Source/3rd Party/wx/include/wx/msw/popupwin.h +++ b/Source/3rd Party/wx/include/wx/msw/popupwin.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 06.01.01 +// RCS-ID: $Id: popupwin.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxPopupWindow // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPopupWindow : public wxPopupWindowBase +class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase { public: wxPopupWindow() { } @@ -25,7 +26,6 @@ public: bool Create(wxWindow *parent, int flags = wxBORDER_NONE); - virtual void SetFocus(); virtual bool Show(bool show = true); // return the style to be used for the popup windows @@ -35,6 +35,7 @@ public: virtual WXHWND MSWGetParent() const; protected: + // popups handle the position like wxTopLevelWindow, not wxWindow virtual void DoGetPosition(int *x, int *y) const; DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow) diff --git a/Source/3rd Party/wx/include/wx/msw/printdlg.h b/Source/3rd Party/wx/include/wx/msw/printdlg.h index 3c9682ca0..25b21a50f 100644 --- a/Source/3rd Party/wx/include/wx/msw/printdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/printdlg.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/printdlg.h +// Name: printdlg.h // Purpose: wxPrintDialog, wxPageSetupDialog classes // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: printdlg.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,30 +20,28 @@ #include "wx/printdlg.h" class WXDLLIMPEXP_FWD_CORE wxDC; -class WinPrinter; //---------------------------------------------------------------------------- // wxWindowsPrintNativeData //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowsPrintNativeData: public wxPrintNativeDataBase +class WXDLLEXPORT wxWindowsPrintNativeData: public wxPrintNativeDataBase { public: wxWindowsPrintNativeData(); virtual ~wxWindowsPrintNativeData(); - + virtual bool TransferTo( wxPrintData &data ); virtual bool TransferFrom( const wxPrintData &data ); - + virtual bool Ok() const { return IsOk(); } virtual bool IsOk() const; - - void InitializeDevMode(const wxString &printerName = wxEmptyString, WinPrinter* printer = NULL); + void* GetDevMode() const { return m_devMode; } void SetDevMode(void* data) { m_devMode = data; } void* GetDevNames() const { return m_devNames; } void SetDevNames(void* data) { m_devNames = data; } - + private: void* m_devMode; void* m_devNames; @@ -52,12 +51,12 @@ private: private: DECLARE_DYNAMIC_CLASS(wxWindowsPrintNativeData) }; - + // --------------------------------------------------------------------------- // wxWindowsPrintDialog: the MSW dialog for printing // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowsPrintDialog : public wxPrintDialogBase +class WXDLLEXPORT wxWindowsPrintDialog : public wxPrintDialogBase { public: wxWindowsPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL); @@ -77,24 +76,24 @@ private: wxPrinterDC* m_printerDC; bool m_destroyDC; wxWindow* m_dialogParent; - + private: bool ConvertToNative( wxPrintDialogData &data ); bool ConvertFromNative( wxPrintDialogData &data ); - + // holds MSW handle void* m_printDlg; private: - wxDECLARE_NO_COPY_CLASS(wxWindowsPrintDialog); + DECLARE_NO_COPY_CLASS(wxWindowsPrintDialog) DECLARE_CLASS(wxWindowsPrintDialog) }; // --------------------------------------------------------------------------- -// wxWindowsPageSetupDialog: the MSW page setup dialog +// wxWindowsPageSetupDialog: the MSW page setup dialog // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowsPageSetupDialog: public wxPageSetupDialogBase +class WXDLLEXPORT wxWindowsPageSetupDialog: public wxPageSetupDialogBase { public: wxWindowsPageSetupDialog(); @@ -106,12 +105,12 @@ public: bool ConvertToNative( wxPageSetupDialogData &data ); bool ConvertFromNative( wxPageSetupDialogData &data ); - virtual wxPageSetupDialogData& GetPageSetupDialogData() { return m_pageSetupData; } + virtual wxPageSetupData& GetPageSetupDialogData() { return m_pageSetupData; } private: wxPageSetupDialogData m_pageSetupData; wxWindow* m_dialogParent; - + // holds MSW handle void* m_pageDlg; diff --git a/Source/3rd Party/wx/include/wx/msw/printwin.h b/Source/3rd Party/wx/include/wx/msw/printwin.h index eb7ad14df..4240682a6 100644 --- a/Source/3rd Party/wx/include/wx/msw/printwin.h +++ b/Source/3rd Party/wx/include/wx/msw/printwin.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/printwin.h +// Name: printwin.h // Purpose: wxWindowsPrinter, wxWindowsPrintPreview classes // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: printwin.h 42522 2006-10-27 13:07:40Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,12 +18,13 @@ // Represents the printer: manages printing a wxPrintout object // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowsPrinter : public wxPrinterBase +class WXDLLEXPORT wxWindowsPrinter : public wxPrinterBase { DECLARE_DYNAMIC_CLASS(wxWindowsPrinter) public: wxWindowsPrinter(wxPrintDialogData *data = NULL); + virtual ~wxWindowsPrinter(); virtual bool Print(wxWindow *parent, wxPrintout *printout, @@ -32,7 +34,9 @@ public: virtual bool Setup(wxWindow *parent); private: - wxDECLARE_NO_COPY_CLASS(wxWindowsPrinter); + WXFARPROC m_lpAbortProc; + + DECLARE_NO_COPY_CLASS(wxWindowsPrinter) }; // --------------------------------------------------------------------------- @@ -40,7 +44,7 @@ private: // wxPrintout. // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowsPrintPreview : public wxPrintPreviewBase +class WXDLLEXPORT wxWindowsPrintPreview : public wxPrintPreviewBase { public: wxWindowsPrintPreview(wxPrintout *printout, @@ -54,11 +58,7 @@ public: virtual bool Print(bool interactive); virtual void DetermineScaling(); -protected: -#if wxUSE_ENH_METAFILE - virtual bool RenderPageIntoBitmap(wxBitmap& bmp, int pageNum); -#endif - +private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxWindowsPrintPreview) }; diff --git a/Source/3rd Party/wx/include/wx/msw/private.h b/Source/3rd Party/wx/include/wx/msw/private.h index 272f5b247..c4d37c8c3 100644 --- a/Source/3rd Party/wx/include/wx/msw/private.h +++ b/Source/3rd Party/wx/include/wx/msw/private.h @@ -6,6 +6,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: private.h 62189 2009-09-28 16:02:08Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,10 +23,6 @@ #include "wx/log.h" -#if wxUSE_GUI - #include "wx/window.h" -#endif // wxUSE_GUI - class WXDLLIMPEXP_FWD_CORE wxFont; class WXDLLIMPEXP_FWD_CORE wxWindow; class WXDLLIMPEXP_FWD_CORE wxWindowBase; @@ -45,13 +42,13 @@ class WXDLLIMPEXP_FWD_CORE wxWindowBase; #if wxUSE_GUI -extern WXDLLIMPEXP_DATA_CORE(HICON) wxSTD_FRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HICON) wxSTD_MDIPARENTFRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HICON) wxSTD_MDICHILDFRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HICON) wxDEFAULT_FRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HICON) wxDEFAULT_MDIPARENTFRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HICON) wxDEFAULT_MDICHILDFRAME_ICON; -extern WXDLLIMPEXP_DATA_CORE(HFONT) wxSTATUS_LINE_FONT; +extern WXDLLEXPORT_DATA(HICON) wxSTD_FRAME_ICON; +extern WXDLLEXPORT_DATA(HICON) wxSTD_MDIPARENTFRAME_ICON; +extern WXDLLEXPORT_DATA(HICON) wxSTD_MDICHILDFRAME_ICON; +extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_FRAME_ICON; +extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_MDIPARENTFRAME_ICON; +extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_MDICHILDFRAME_ICON; +extern WXDLLEXPORT_DATA(HFONT) wxSTATUS_LINE_FONT; #endif // wxUSE_GUI @@ -61,13 +58,6 @@ extern WXDLLIMPEXP_DATA_CORE(HFONT) wxSTATUS_LINE_FONT; extern WXDLLIMPEXP_DATA_BASE(HINSTANCE) wxhInstance; -extern "C" -{ - WXDLLIMPEXP_BASE HINSTANCE wxGetInstance(); -} - -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - // --------------------------------------------------------------------------- // define things missing from some compilers' headers // --------------------------------------------------------------------------- @@ -168,9 +158,9 @@ extern LONG APIENTRY _EXPORT // This one is a macro so that it can be tested with #ifdef, it will be // undefined if it cannot be implemented for a given compiler. -// Vc++, bcc, dmc, ow, mingw akk have _get_osfhandle() and Cygwin has -// get_osfhandle. Others are currently unknown, e.g. Salford, Intel, Visual -// Age. +// Vc++, bcc, dmc, ow, mingw, codewarrior (and rsxnt) have _get_osfhandle. +// Cygwin has get_osfhandle. Others are currently unknown, e.g. Salford, +// Intel, Visual Age. #if defined(__WXWINCE__) #define wxGetOSFHandle(fd) ((HANDLE)fd) #define wxOpenOSFHandle(h, flags) ((int)wxPtrToUInt(h)) @@ -180,7 +170,8 @@ extern LONG APIENTRY _EXPORT || defined(__BORLANDC__) \ || defined(__DMC__) \ || defined(__WATCOMC__) \ - || defined(__MINGW32__) + || defined(__MINGW32__) \ + || (defined(__MWERKS__) && defined(__MSL__)) #define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd)) #define wxOpenOSFHandle(h, flags) (_open_osfhandle(wxPtrToUInt(h), flags)) #define wx_fdopen _fdopen @@ -217,21 +208,6 @@ struct WinStruct : public T }; -// Macros for converting wxString to the type expected by API functions. -// -// Normally it is enough to just use wxString::t_str() which is implicitly -// convertible to LPCTSTR, but in some cases an explicit conversion is required. -// -// In such cases wxMSW_CONV_LPCTSTR() should be used. But if an API function -// takes a non-const pointer, wxMSW_CONV_LPTSTR() which casts away the -// constness (but doesn't make it possible to really modify the returned -// pointer, of course) should be used. And if a string is passed as LPARAM, use -// wxMSW_CONV_LPARAM() which does the required ugly reinterpret_cast<> too. -#define wxMSW_CONV_LPCTSTR(s) static_cast((s).t_str()) -#define wxMSW_CONV_LPTSTR(s) const_cast(wxMSW_CONV_LPCTSTR(s)) -#define wxMSW_CONV_LPARAM(s) reinterpret_cast(wxMSW_CONV_LPCTSTR(s)) - - #if wxUSE_GUI #include "wx/gdicmn.h" @@ -275,7 +251,7 @@ enum wxSTD_COLOUR wxSTD_COL_MAX }; -struct WXDLLIMPEXP_CORE wxCOLORMAP +struct WXDLLEXPORT wxCOLORMAP { COLORREF from, to; }; @@ -309,9 +285,7 @@ inline void wxCopyRectToRECT(const wxRect& rect, RECT& rc) // translations between HIMETRIC units (which OLE likes) and pixels (which are // liked by all the others) - implemented in msw/utilsexc.cpp extern void HIMETRICToPixel(LONG *x, LONG *y); -extern void HIMETRICToPixel(LONG *x, LONG *y, HDC hdcRef); extern void PixelToHIMETRIC(LONG *x, LONG *y); -extern void PixelToHIMETRIC(LONG *x, LONG *y, HDC hdcRef); // Windows convention of the mask is opposed to the wxWidgets one, so we need // to invert the mask each time we pass one/get one to/from Windows @@ -328,22 +302,6 @@ extern HICON wxBitmapToHICON(const wxBitmap& bmp); extern HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY); - -#if wxUSE_OWNER_DRAWN - -// Draw the bitmap in specified state (this is used by owner drawn controls) -enum wxDSBStates -{ - wxDSB_NORMAL = 0, - wxDSB_SELECTED, - wxDSB_DISABLED -}; - -extern -BOOL wxDrawStateBitmap(HDC hDC, HBITMAP hBitmap, int x, int y, UINT uState); - -#endif // wxUSE_OWNER_DRAWN - // get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they // will fail on system with multiple monitors where the coords may be negative // @@ -353,32 +311,21 @@ BOOL wxDrawStateBitmap(HDC hDC, HBITMAP hBitmap, int x, int y, UINT uState); #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) #endif // GET_X_LPARAM -// get the current state of SHIFT/CTRL/ALT keys -inline bool wxIsModifierDown(int vk) -{ - // GetKeyState() returns different negative values on WinME and WinNT, - // so simply test for negative value. - return ::GetKeyState(vk) < 0; -} - +// get the current state of SHIFT/CTRL keys inline bool wxIsShiftDown() { - return wxIsModifierDown(VK_SHIFT); +// return (::GetKeyState(VK_SHIFT) & 0x100) != 0; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + return ::GetKeyState(VK_SHIFT) < 0; } inline bool wxIsCtrlDown() { - return wxIsModifierDown(VK_CONTROL); -} - -inline bool wxIsAltDown() -{ - return wxIsModifierDown(VK_MENU); -} - -inline bool wxIsAnyModifierDown() -{ - return wxIsShiftDown() || wxIsCtrlDown() || wxIsAltDown(); +// return (::GetKeyState(VK_CONTROL) & 0x100) != 0; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + return ::GetKeyState(VK_CONTROL) < 0; } // wrapper around GetWindowRect() and GetClientRect() APIs doing error checking @@ -388,9 +335,7 @@ inline RECT wxGetWindowRect(HWND hwnd) RECT rect; if ( !::GetWindowRect(hwnd, &rect) ) - { - wxLogLastError(wxT("GetWindowRect")); - } + wxLogLastError(_T("GetWindowRect")); return rect; } @@ -400,9 +345,7 @@ inline RECT wxGetClientRect(HWND hwnd) RECT rect; if ( !::GetClientRect(hwnd, &rect) ) - { - wxLogLastError(wxT("GetClientRect")); - } + wxLogLastError(_T("GetClientRect")); return rect; } @@ -424,16 +367,15 @@ public: private: HDC m_hdc; - wxDECLARE_NO_COPY_CLASS(ScreenHDC); + DECLARE_NO_COPY_CLASS(ScreenHDC) }; // the same as ScreenHDC but for window DCs class WindowHDC { public: - WindowHDC() : m_hwnd(NULL), m_hdc(NULL) { } WindowHDC(HWND hwnd) { m_hdc = ::GetDC(m_hwnd = hwnd); } - ~WindowHDC() { if ( m_hwnd && m_hdc ) { ::ReleaseDC(m_hwnd, m_hdc); } } + ~WindowHDC() { ::ReleaseDC(m_hwnd, m_hdc); } operator HDC() const { return m_hdc; } @@ -441,7 +383,7 @@ private: HWND m_hwnd; HDC m_hdc; - wxDECLARE_NO_COPY_CLASS(WindowHDC); + DECLARE_NO_COPY_CLASS(WindowHDC) }; // the same as ScreenHDC but for memory DCs: creates the HDC compatible with @@ -457,7 +399,7 @@ public: private: HDC m_hdc; - wxDECLARE_NO_COPY_CLASS(MemoryHDC); + DECLARE_NO_COPY_CLASS(MemoryHDC) }; // a class which selects a GDI object into a DC in its ctor and deselects in @@ -468,12 +410,12 @@ private: void DoInit(HGDIOBJ hgdiobj) { m_hgdiobj = ::SelectObject(m_hdc, hgdiobj); } public: - SelectInHDC() : m_hdc(NULL), m_hgdiobj(NULL) { } + SelectInHDC() : m_hdc(NULL) { } SelectInHDC(HDC hdc, HGDIOBJ hgdiobj) : m_hdc(hdc) { DoInit(hgdiobj); } void Init(HDC hdc, HGDIOBJ hgdiobj) { - wxASSERT_MSG( !m_hdc, wxT("initializing twice?") ); + wxASSERT_MSG( !m_hdc, _T("initializing twice?") ); m_hdc = hdc; @@ -489,7 +431,7 @@ private: HDC m_hdc; HGDIOBJ m_hgdiobj; - wxDECLARE_NO_COPY_CLASS(SelectInHDC); + DECLARE_NO_COPY_CLASS(SelectInHDC) }; // a class which cleans up any GDI object @@ -502,7 +444,7 @@ protected: void InitGdiobj(HGDIOBJ gdiobj) { - wxASSERT_MSG( !m_gdiobj, wxT("initializing twice?") ); + wxASSERT_MSG( !m_gdiobj, _T("initializing twice?") ); m_gdiobj = gdiobj; } @@ -555,13 +497,8 @@ public: class AutoHBITMAP : private AutoGDIObject { public: - AutoHBITMAP() - : AutoGDIObject() { } - AutoHBITMAP(HBITMAP hbmp) : AutoGDIObject(hbmp) { } - void Init(HBITMAP hbmp) { InitGdiobj(hbmp); } - operator HBITMAP() const { return (HBITMAP)GetObject(); } }; @@ -600,9 +537,7 @@ public: : m_hdc(hdc) { if ( !::SelectClipRgn(hdc, hrgn) ) - { - wxLogLastError(wxT("SelectClipRgn")); - } + wxLogLastError(_T("SelectClipRgn")); } ~HDCClipper() @@ -613,7 +548,7 @@ public: private: HDC m_hdc; - wxDECLARE_NO_COPY_CLASS(HDCClipper); + DECLARE_NO_COPY_CLASS(HDCClipper) }; // set the given map mode for the life time of this object @@ -631,9 +566,7 @@ private: { m_modeOld = ::SetMapMode(hdc, mm); if ( !m_modeOld ) - { - wxLogLastError(wxT("SelectClipRgn")); - } + wxLogLastError(_T("SelectClipRgn")); } ~HDCMapModeChanger() @@ -646,44 +579,29 @@ private: HDC m_hdc; int m_modeOld; - wxDECLARE_NO_COPY_CLASS(HDCMapModeChanger); + DECLARE_NO_COPY_CLASS(HDCMapModeChanger) }; #define wxCHANGE_HDC_MAP_MODE(hdc, mm) \ HDCMapModeChanger wxMAKE_UNIQUE_NAME(wxHDCMapModeChanger)(hdc, mm) #endif // __WXWINCE__/!__WXWINCE__ -// smart pointer using GlobalAlloc/GlobalFree() +// smart buffeer using GlobalAlloc/GlobalFree() class GlobalPtr { public: - // default ctor, call Init() later - GlobalPtr() - { - m_hGlobal = NULL; - } - // allocates a block of given size - void Init(size_t size, unsigned flags = GMEM_MOVEABLE) + GlobalPtr(size_t size, unsigned flags = GMEM_MOVEABLE) { m_hGlobal = ::GlobalAlloc(flags, size); if ( !m_hGlobal ) - { - wxLogLastError(wxT("GlobalAlloc")); - } - } - - GlobalPtr(size_t size, unsigned flags = GMEM_MOVEABLE) - { - Init(size, flags); + wxLogLastError(_T("GlobalAlloc")); } ~GlobalPtr() { if ( m_hGlobal && ::GlobalFree(m_hGlobal) ) - { - wxLogLastError(wxT("GlobalFree")); - } + wxLogLastError(_T("GlobalFree")); } // implicit conversion @@ -692,7 +610,7 @@ public: private: HGLOBAL m_hGlobal; - wxDECLARE_NO_COPY_CLASS(GlobalPtr); + DECLARE_NO_COPY_CLASS(GlobalPtr) }; // when working with global pointers (which is unfortunately still necessary @@ -701,56 +619,35 @@ private: class GlobalPtrLock { public: - // default ctor, use Init() later -- should only be used if the HGLOBAL can - // be NULL (in which case Init() shouldn't be called) - GlobalPtrLock() + GlobalPtrLock(HGLOBAL hGlobal) : m_hGlobal(hGlobal) { - m_hGlobal = NULL; - m_ptr = NULL; - } - - // initialize the object, may be only called if we were created using the - // default ctor; HGLOBAL must not be NULL - void Init(HGLOBAL hGlobal) - { - m_hGlobal = hGlobal; - - // NB: GlobalLock() is a macro, not a function, hence don't use the - // global scope operator with it (and neither with GlobalUnlock()) m_ptr = GlobalLock(hGlobal); if ( !m_ptr ) - { - wxLogLastError(wxT("GlobalLock")); - } - } - - // initialize the object, HGLOBAL must not be NULL - GlobalPtrLock(HGLOBAL hGlobal) - { - Init(hGlobal); + wxLogLastError(_T("GlobalLock")); } ~GlobalPtrLock() { - if ( m_hGlobal && !GlobalUnlock(m_hGlobal) ) + if ( !GlobalUnlock(m_hGlobal) ) { +#ifdef __WXDEBUG__ // this might happen simply because the block became unlocked DWORD dwLastError = ::GetLastError(); if ( dwLastError != NO_ERROR ) { - wxLogApiError(wxT("GlobalUnlock"), dwLastError); + wxLogApiError(_T("GlobalUnlock"), dwLastError); } +#endif // __WXDEBUG__ } } - void *Get() const { return m_ptr; } operator void *() const { return m_ptr; } private: HGLOBAL m_hGlobal; void *m_ptr; - wxDECLARE_NO_COPY_CLASS(GlobalPtrLock); + DECLARE_NO_COPY_CLASS(GlobalPtrLock) }; // register the class when it is first needed and unregister it in dtor @@ -771,12 +668,12 @@ public: { // we should only be called if we hadn't been initialized yet wxASSERT_MSG( m_registered == -1, - wxT("calling ClassRegistrar::Register() twice?") ); + _T("calling ClassRegistrar::Register() twice?") ); m_registered = ::RegisterClass(&wc) ? 1 : 0; if ( !IsRegistered() ) { - wxLogLastError(wxT("RegisterClassEx()")); + wxLogLastError(_T("RegisterClassEx()")); } else { @@ -795,9 +692,9 @@ public: { if ( IsRegistered() ) { - if ( !::UnregisterClass(m_clsname.t_str(), wxGetInstance()) ) + if ( !::UnregisterClass(m_clsname, wxhInstance) ) { - wxLogLastError(wxT("UnregisterClass")); + wxLogLastError(_T("UnregisterClass")); } } } @@ -839,7 +736,7 @@ private: #define GetHbrushOf(brush) ((HBRUSH)(brush).GetResourceHandle()) #define GetHmenu() ((HMENU)GetHMenu()) -#define GetHmenuOf(menu) ((HMENU)(menu)->GetHMenu()) +#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu()) #define GetHcursor() ((HCURSOR)GetHCURSOR()) #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR()) @@ -848,7 +745,7 @@ private: #define GetHfontOf(font) ((HFONT)(font).GetHFONT()) #define GetHimagelist() ((HIMAGELIST)GetHIMAGELIST()) -#define GetHimagelistOf(imgl) ((HIMAGELIST)(imgl)->GetHIMAGELIST()) +#define GetHimagelistOf(imgl) ((HIMAGELIST)imgl->GetHIMAGELIST()) #define GetHpalette() ((HPALETTE)GetHPALETTE()) #define GetHpaletteOf(pal) ((HPALETTE)(pal).GetHPALETTE()) @@ -865,6 +762,13 @@ private: // global functions // --------------------------------------------------------------------------- +extern "C" +{ + WXDLLIMPEXP_BASE HINSTANCE wxGetInstance(); +} + +WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); + // return the full path of the given module inline wxString wxGetFullModuleName(HMODULE hmod) { @@ -876,7 +780,7 @@ inline wxString wxGetFullModuleName(HMODULE hmod) MAX_PATH ) ) { - wxLogLastError(wxT("GetModuleFileName")); + wxLogLastError(_T("GetModuleFileName")); } return fullname; @@ -895,11 +799,9 @@ inline wxString wxGetFullModuleName() // 0x0400 Windows 95, NT4 // 0x0410 Windows 98 // 0x0500 Windows ME, 2000 -// 0x0501 Windows XP, 2003 -// 0x0502 Windows XP SP2, 2003 SP1 -// 0x0600 Windows Vista, 2008 -// 0x0601 Windows 7 -// 0x0602 Windows 8 (currently also returned for 8.1) +// 0x0501 Windows XP +// 0x0502 Windows 2003 +// 0x0600 Longhorn // // for the other Windows versions 0 is currently returned enum wxWinVersion @@ -919,54 +821,44 @@ enum wxWinVersion wxWinVersion_NT5 = wxWinVersion_5, wxWinVersion_2000 = wxWinVersion_5, wxWinVersion_XP = 0x0501, - wxWinVersion_2003 = 0x0501, - wxWinVersion_XP_SP2 = 0x0502, - wxWinVersion_2003_SP1 = 0x0502, + wxWinVersion_2003 = 0x0502, wxWinVersion_6 = 0x0600, - wxWinVersion_Vista = wxWinVersion_6, - wxWinVersion_NT6 = wxWinVersion_6, - - wxWinVersion_7 = 0x601, - - wxWinVersion_8 = 0x602 + wxWinVersion_NT6 = 0x0600 }; WXDLLIMPEXP_BASE wxWinVersion wxGetWinVersion(); -#if wxUSE_GUI && defined(__WXMSW__) +#if wxUSE_GUI // cursor stuff extern HCURSOR wxGetCurrentBusyCursor(); // from msw/utils.cpp extern const wxCursor *wxGetGlobalCursor(); // from msw/cursor.cpp -// GetCursorPos can fail without populating the POINT. This falls back to GetMessagePos. -WXDLLIMPEXP_CORE void wxGetCursorPosMSW(POINT* pt); +WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font); +WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font); +WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont); +WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int charset); -WXDLLIMPEXP_CORE void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font); -WXDLLIMPEXP_CORE void wxFillLogFont(LOGFONT *logFont, const wxFont *font); -WXDLLIMPEXP_CORE wxFont wxCreateFontFromLogFont(const LOGFONT *logFont); -WXDLLIMPEXP_CORE wxFontEncoding wxGetFontEncFromCharSet(int charset); - -WXDLLIMPEXP_CORE void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos); -WXDLLIMPEXP_CORE void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos); +WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos); +WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos); // Find maximum size of window/rectangle -extern WXDLLIMPEXP_CORE void wxFindMaxSize(WXHWND hwnd, RECT *rect); +extern WXDLLEXPORT void wxFindMaxSize(WXHWND hwnd, RECT *rect); // Safely get the window text (i.e. without using fixed size buffer) -extern WXDLLIMPEXP_CORE wxString wxGetWindowText(WXHWND hWnd); +extern WXDLLEXPORT wxString wxGetWindowText(WXHWND hWnd); // get the window class name -extern WXDLLIMPEXP_CORE wxString wxGetWindowClass(WXHWND hWnd); +extern WXDLLEXPORT wxString wxGetWindowClass(WXHWND hWnd); // get the window id (should be unsigned, hence this is not wxWindowID which // is, for mainly historical reasons, signed) -extern WXDLLIMPEXP_CORE int wxGetWindowId(WXHWND hWnd); +extern WXDLLEXPORT WXWORD wxGetWindowId(WXHWND hWnd); // check if hWnd's WNDPROC is wndProc. Return true if yes, false if they are // different -extern WXDLLIMPEXP_CORE bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc); +extern WXDLLEXPORT bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc); // Does this window style specify any border? inline bool wxStyleHasBorder(long style) @@ -975,41 +867,26 @@ inline bool wxStyleHasBorder(long style) wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; } -inline long wxGetWindowExStyle(const wxWindowMSW *win) -{ - return ::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE); -} - -inline bool wxHasWindowExStyle(const wxWindowMSW *win, long style) -{ - return (wxGetWindowExStyle(win) & style) != 0; -} - -inline long wxSetWindowExStyle(const wxWindowMSW *win, long style) -{ - return ::SetWindowLong(GetHwndOf(win), GWL_EXSTYLE, style); -} - // ---------------------------------------------------------------------------- // functions mapping HWND to wxWindow // ---------------------------------------------------------------------------- -// this function simply checks whether the given hwnd corresponds to a wxWindow +// this function simply checks whether the given hWnd corresponds to a wxWindow // and returns either that window if it does or NULL otherwise -extern WXDLLIMPEXP_CORE wxWindow* wxFindWinFromHandle(HWND hwnd); +extern WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd); // find the window for HWND which is part of some wxWindow, i.e. unlike // wxFindWinFromHandle() above it will also work for "sub controls" of a // wxWindow. // // returns the wxWindow corresponding to the given HWND or NULL. -extern WXDLLIMPEXP_CORE wxWindow *wxGetWindowFromHWND(WXHWND hwnd); +extern WXDLLEXPORT wxWindow *wxGetWindowFromHWND(WXHWND hwnd); // Get the size of an icon -extern WXDLLIMPEXP_CORE wxSize wxGetHiconSize(HICON hicon); +extern WXDLLEXPORT wxSize wxGetHiconSize(HICON hicon); // Lines are drawn differently for WinCE and regular WIN32 -WXDLLIMPEXP_CORE void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2); +WXDLLEXPORT void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2); // fill the client rect of the given window on the provided dc using this brush inline void wxFillRect(HWND hwnd, HDC hdc, HBRUSH hbr) @@ -1071,6 +948,6 @@ inline void *wxSetWindowUserData(HWND hwnd, void *data) #endif // __WIN64__/__WIN32__ -#endif // wxUSE_GUI && __WXMSW__ +#endif // wxUSE_GUI #endif // _WX_PRIVATE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/button.h b/Source/3rd Party/wx/include/wx/msw/private/button.h deleted file mode 100644 index 9f605c66a..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/button.h +++ /dev/null @@ -1,76 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/button.h -// Purpose: helper functions used with native BUTTON control -// Author: Vadim Zeitlin -// Created: 2008-06-07 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_BUTTON_H_ -#define _WX_MSW_PRIVATE_BUTTON_H_ - -// define some standard button constants which may be missing in the headers -#ifndef BS_PUSHLIKE - #define BS_PUSHLIKE 0x00001000L -#endif - -#ifndef BST_UNCHECKED - #define BST_UNCHECKED 0x0000 -#endif - -#ifndef BST_CHECKED - #define BST_CHECKED 0x0001 -#endif - -#ifndef BST_INDETERMINATE - #define BST_INDETERMINATE 0x0002 -#endif - -namespace wxMSWButton -{ - -// returns BS_MULTILINE if the label contains new lines or 0 otherwise -inline int GetMultilineStyle(const wxString& label) -{ - return label.find(wxT('\n')) == wxString::npos ? 0 : BS_MULTILINE; -} - -// update the style of the specified HWND to include or exclude BS_MULTILINE -// depending on whether the label contains the new lines -void UpdateMultilineStyle(HWND hwnd, const wxString& label); - -// flags for ComputeBestSize() and GetFittingSize() -enum -{ - Size_AuthNeeded = 1, - Size_ExactFit = 2 -}; - -// NB: All the functions below are implemented in src/msw/button.cpp - -// Compute the button size (as if wxBU_EXACTFIT were specified, i.e. without -// adjusting it to be of default size if it's smaller) for the given label size -WXDLLIMPEXP_CORE wxSize -GetFittingSize(wxWindow *win, const wxSize& sizeLabel, int flags = 0); - -// Compute the button size (as if wxBU_EXACTFIT were specified) by computing -// its label size and then calling GetFittingSize(). -wxSize ComputeBestFittingSize(wxControl *btn, int flags = 0); - -// Increase the size passed as parameter to be at least the standard button -// size if the control doesn't have wxBU_EXACTFIT style and also cache it as -// the best size and return its value -- this is used in DoGetBestSize() -// implementation. -wxSize IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size); - -// helper of wxToggleButton::DoGetBestSize() -inline wxSize ComputeBestSize(wxControl *btn, int flags = 0) -{ - return IncreaseToStdSizeAndCache(btn, ComputeBestFittingSize(btn, flags)); -} - -} // namespace wxMSWButton - -#endif // _WX_MSW_PRIVATE_BUTTON_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/private/comptr.h b/Source/3rd Party/wx/include/wx/msw/private/comptr.h deleted file mode 100644 index 194cf54f9..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/comptr.h +++ /dev/null @@ -1,129 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/comptr.h -// Purpose: Smart pointer for COM interfaces. -// Author: PB -// Created: 2012-04-16 -// Copyright: (c) 2012 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_COMPTR_H_ -#define _WX_MSW_PRIVATE_COMPTR_H_ - -// ---------------------------------------------------------------------------- -// wxCOMPtr: A minimalistic smart pointer for use with COM interfaces. -// ---------------------------------------------------------------------------- - -template -class wxCOMPtr -{ -public: - typedef T element_type; - - wxCOMPtr() - : m_ptr(NULL) - { - } - - wxEXPLICIT wxCOMPtr(T* ptr) - : m_ptr(ptr) - { - if ( m_ptr ) - m_ptr->AddRef(); - } - - wxCOMPtr(const wxCOMPtr& ptr) - : m_ptr(ptr.get()) - { - if ( m_ptr ) - m_ptr->AddRef(); - } - - ~wxCOMPtr() - { - if ( m_ptr ) - m_ptr->Release(); - } - - void reset(T* ptr = NULL) - { - if ( m_ptr != ptr) - { - if ( ptr ) - ptr->AddRef(); - if ( m_ptr ) - m_ptr->Release(); - m_ptr = ptr; - } - } - - wxCOMPtr& operator=(const wxCOMPtr& ptr) - { - reset(ptr.get()); - return *this; - } - - wxCOMPtr& operator=(T* ptr) - { - reset(ptr); - return *this; - } - - operator T*() const - { - return m_ptr; - } - - T& operator*() const - { - return *m_ptr; - } - - T* operator->() const - { - return m_ptr; - } - - // It would be better to forbid direct access completely but we do need - // for QueryInterface() and similar functions, so provide it but it can - // only be used to initialize the pointer, not to modify an existing one. - T** operator&() - { - wxASSERT_MSG(!m_ptr, - wxS("Can't get direct access to initialized pointer")); - - return &m_ptr; - } - - T* get() const - { - return m_ptr; - } - - bool operator<(T* ptr) const - { - return get() < ptr; - } - -private: - T* m_ptr; -}; - -// Define a helper for the macro below: we just need a function taking a -// pointer and not returning anything to avoid warnings about unused return -// value of the cast in the macro itself. -namespace wxPrivate { inline void PPV_ARGS_CHECK(void*) { } } - -// Takes the interface name and a pointer to a pointer of the interface type -// and expands into the IID of this interface and the same pointer but after a -// type-safety check. -// -// This is similar to the standard IID_PPV_ARGS macro but takes the pointer -// type instead of relying on the non-standard Microsoft __uuidof(). -#define wxIID_PPV_ARGS(IType, pType) \ - IID_##IType, \ - (wxPrivate::PPV_ARGS_CHECK(static_cast(*pType)), \ - reinterpret_cast(pType)) - -#endif // _WX_MSW_PRIVATE_COMPTR_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/private/datecontrols.h b/Source/3rd Party/wx/include/wx/msw/private/datecontrols.h deleted file mode 100644 index 9794cfae8..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/datecontrols.h +++ /dev/null @@ -1,30 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/datecontrols.h -// Purpose: implementation helpers for wxDatePickerCtrl and wxCalendarCtrl -// Author: Vadim Zeitlin -// Created: 2008-04-04 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSW_PRIVATE_DATECONTROLS_H_ -#define _MSW_PRIVATE_DATECONTROLS_H_ - -#include "wx/datetime.h" - -#include "wx/msw/wrapwin.h" - -// namespace for the helper functions related to the date controls -namespace wxMSWDateControls -{ - -// do the one time only initialization of date classes of comctl32.dll, return -// true if ok or log an error and return false if we failed (this can only -// happen with a very old version of common controls DLL, i.e. before 4.70) -extern bool CheckInitialization(); - -} // namespace wxMSWDateControls - -#endif // _MSW_PRIVATE_DATECONTROLS_H_ - - diff --git a/Source/3rd Party/wx/include/wx/msw/private/dc.h b/Source/3rd Party/wx/include/wx/msw/private/dc.h deleted file mode 100644 index 303cd19df..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/dc.h +++ /dev/null @@ -1,147 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/dc.h -// Purpose: private wxMSW helpers for working with HDCs -// Author: Vadim Zeitlin -// Created: 2009-06-16 (extracted from src/msw/dc.cpp) -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSW_PRIVATE_DC_H_ -#define _MSW_PRIVATE_DC_H_ - -#include "wx/msw/dc.h" -#include "wx/msw/wrapwin.h" - -namespace wxMSWImpl -{ - -// various classes to change some DC property temporarily - -// text background and foreground colours -class wxTextColoursChanger -{ -public: - wxTextColoursChanger(HDC hdc, const wxMSWDCImpl& dc) - : m_hdc(hdc) - { - Change(dc.GetTextForeground(), dc.GetTextBackground()); - } - - wxTextColoursChanger(HDC hdc, const wxColour& colFg, const wxColour& colBg) - : m_hdc(hdc) - { - Change(colFg, colBg); - } - - wxTextColoursChanger(HDC hdc, COLORREF colFg, COLORREF colBg) - : m_hdc(hdc) - { - Change(colFg, colBg); - } - - ~wxTextColoursChanger() - { - if ( m_oldColFg != CLR_INVALID ) - ::SetTextColor(m_hdc, m_oldColFg); - if ( m_oldColBg != CLR_INVALID ) - ::SetBkColor(m_hdc, m_oldColBg); - } - -protected: - // this ctor doesn't change mode immediately, call Change() later to do it - // only if needed - wxTextColoursChanger(HDC hdc) - : m_hdc(hdc) - { - m_oldColFg = - m_oldColBg = CLR_INVALID; - } - - void Change(const wxColour& colFg, const wxColour& colBg) - { - Change(colFg.IsOk() ? colFg.GetPixel() : CLR_INVALID, - colBg.IsOk() ? colBg.GetPixel() : CLR_INVALID); - } - - void Change(COLORREF colFg, COLORREF colBg) - { - if ( colFg != CLR_INVALID ) - { - m_oldColFg = ::SetTextColor(m_hdc, colFg); - if ( m_oldColFg == CLR_INVALID ) - { - wxLogLastError(wxT("SetTextColor")); - } - } - else - { - m_oldColFg = CLR_INVALID; - } - - if ( colBg != CLR_INVALID ) - { - m_oldColBg = ::SetBkColor(m_hdc, colBg); - if ( m_oldColBg == CLR_INVALID ) - { - wxLogLastError(wxT("SetBkColor")); - } - } - else - { - m_oldColBg = CLR_INVALID; - } - } - -private: - const HDC m_hdc; - COLORREF m_oldColFg, - m_oldColBg; - - wxDECLARE_NO_COPY_CLASS(wxTextColoursChanger); -}; - -// background mode -class wxBkModeChanger -{ -public: - // set background mode to opaque if mode != wxBRUSHSTYLE_TRANSPARENT - wxBkModeChanger(HDC hdc, int mode) - : m_hdc(hdc) - { - Change(mode); - } - - ~wxBkModeChanger() - { - if ( m_oldMode ) - ::SetBkMode(m_hdc, m_oldMode); - } - -protected: - // this ctor doesn't change mode immediately, call Change() later to do it - // only if needed - wxBkModeChanger(HDC hdc) : m_hdc(hdc) { m_oldMode = 0; } - - void Change(int mode) - { - m_oldMode = ::SetBkMode(m_hdc, mode == wxBRUSHSTYLE_TRANSPARENT - ? TRANSPARENT - : OPAQUE); - if ( !m_oldMode ) - { - wxLogLastError(wxT("SetBkMode")); - } - } - -private: - const HDC m_hdc; - int m_oldMode; - - wxDECLARE_NO_COPY_CLASS(wxBkModeChanger); -}; - -} // namespace wxMSWImpl - -#endif // _MSW_PRIVATE_DC_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/private/fswatcher.h b/Source/3rd Party/wx/include/wx/msw/private/fswatcher.h deleted file mode 100644 index 38e3b41ee..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/fswatcher.h +++ /dev/null @@ -1,335 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/fswatcher.h -// Purpose: File system watcher impl classes -// Author: Bartosz Bekier -// Created: 2009-05-26 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef WX_MSW_PRIVATE_FSWATCHER_H_ -#define WX_MSW_PRIVATE_FSWATCHER_H_ - -#include "wx/filename.h" -#include "wx/vector.h" -#include "wx/msw/private.h" - -// ============================================================================ -// wxFSWatcherEntry implementation & helper declarations -// ============================================================================ - -class wxFSWatcherImplMSW; - -class wxFSWatchEntryMSW : public wxFSWatchInfo -{ -public: - enum - { - BUFFER_SIZE = 4096 // TODO parametrize - }; - - wxFSWatchEntryMSW(const wxFSWatchInfo& winfo) : - wxFSWatchInfo(winfo) - { - // get handle for this path - m_handle = OpenDir(m_path); - m_overlapped = (OVERLAPPED*)calloc(1, sizeof(OVERLAPPED)); - wxZeroMemory(m_buffer); - } - - virtual ~wxFSWatchEntryMSW() - { - wxLogTrace(wxTRACE_FSWATCHER, "Deleting entry '%s'", m_path); - - if (m_handle != INVALID_HANDLE_VALUE) - { - if (!CloseHandle(m_handle)) - { - wxLogSysError(_("Unable to close the handle for '%s'"), - m_path); - } - } - free(m_overlapped); - } - - bool IsOk() const - { - return m_handle != INVALID_HANDLE_VALUE; - } - - HANDLE GetHandle() const - { - return m_handle; - } - - void* GetBuffer() - { - return m_buffer; - } - - OVERLAPPED* GetOverlapped() const - { - return m_overlapped; - } - -private: - // opens dir with all flags, attributes etc. necessary to be later - // asynchronous watched with ReadDirectoryChangesW - static HANDLE OpenDir(const wxString& path) - { - HANDLE handle = CreateFile(path.t_str(), - FILE_LIST_DIRECTORY, - FILE_SHARE_READ | - FILE_SHARE_WRITE | - FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OVERLAPPED, - NULL); - if (handle == INVALID_HANDLE_VALUE) - { - wxLogSysError(_("Failed to open directory \"%s\" for monitoring."), - path); - } - - return handle; - } - - HANDLE m_handle; // handle to opened directory - char m_buffer[BUFFER_SIZE]; // buffer for fs events - OVERLAPPED* m_overlapped; - - wxDECLARE_NO_COPY_CLASS(wxFSWatchEntryMSW); -}; - -// ============================================================================ -// wxFSWatcherImplMSW helper classes implementations -// ============================================================================ - -class wxIOCPService -{ -public: - wxIOCPService() : - m_iocp(INVALID_HANDLE_VALUE) - { - Init(); - } - - ~wxIOCPService() - { - if (m_iocp != INVALID_HANDLE_VALUE) - { - if (!CloseHandle(m_iocp)) - { - wxLogSysError(_("Unable to close I/O completion port handle")); - } - } - m_watches.clear(); - } - - // associates a wxFSWatchEntryMSW with completion port - bool Add(wxSharedPtr watch) - { - wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" ); - wxCHECK_MSG( watch->IsOk(), false, "Invalid watch" ); - - // associate with IOCP - HANDLE ret = CreateIoCompletionPort(watch->GetHandle(), m_iocp, - (ULONG_PTR)watch.get(), 0); - if (ret == NULL) - { - wxLogSysError(_("Unable to associate handle with " - "I/O completion port")); - return false; - } - else if (ret != m_iocp) - { - wxFAIL_MSG(_("Unexpectedly new I/O completion port was created")); - return false; - } - - // add to watch map - wxFSWatchEntries::value_type val(watch->GetPath(), watch); - return m_watches.insert(val).second; - } - - // Removes a watch we're currently using. Notice that this doesn't happen - // immediately, CompleteRemoval() must be called later when it's really - // safe to delete the watch, i.e. after completion of the IO operation - // using it. - bool ScheduleForRemoval(const wxSharedPtr& watch) - { - wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" ); - wxCHECK_MSG( watch->IsOk(), false, "Invalid watch" ); - - const wxString path = watch->GetPath(); - wxFSWatchEntries::iterator it = m_watches.find(path); - wxCHECK_MSG( it != m_watches.end(), false, - "Can't remove a watch we don't use" ); - - // We can't just delete the watch here as we can have pending events - // for it and if we destroyed it now, we could get a dangling (or, - // worse, reused to point to another object) pointer in ReadEvents() so - // just remember that this one should be removed when CompleteRemoval() - // is called later. - m_removedWatches.push_back(watch); - m_watches.erase(it); - - return true; - } - - // Really remove the watch previously passed to ScheduleForRemoval(). - // - // It's ok to call this for a watch that hadn't been removed before, in - // this case we'll just return false and do nothing. - bool CompleteRemoval(wxFSWatchEntryMSW* watch) - { - for ( Watches::iterator it = m_removedWatches.begin(); - it != m_removedWatches.end(); - ++it ) - { - if ( (*it).get() == watch ) - { - // Removing the object from here will result in deleting the - // watch itself as it's not referenced from anywhere else now. - m_removedWatches.erase(it); - return true; - } - } - - return false; - } - - // post completion packet - bool PostEmptyStatus() - { - wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" ); - - // The special values of 0 will make GetStatus() return Status_Exit. - int ret = PostQueuedCompletionStatus(m_iocp, 0, 0, NULL); - if (!ret) - { - wxLogSysError(_("Unable to post completion status")); - } - - return ret != 0; - } - - // Possible return values of GetStatus() - enum Status - { - // Status successfully retrieved into the provided arguments. - Status_OK, - - // Special status indicating that we should exit retrieved. - Status_Exit, - - // An error occurred because the watched directory was deleted. - Status_Deleted, - - // Some other error occurred. - Status_Error - }; - - // Wait for completion status to arrive. - // This function can block forever in it's wait for completion status. - // Use PostEmptyStatus() to wake it up (and end the worker thread) - Status - GetStatus(DWORD* count, wxFSWatchEntryMSW** watch, - OVERLAPPED** overlapped) - { - wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, Status_Error, - "Invalid IOCP object" ); - wxCHECK_MSG( count && watch && overlapped, Status_Error, - "Output parameters can't be NULL" ); - - int ret = GetQueuedCompletionStatus(m_iocp, count, (ULONG_PTR *)watch, - overlapped, INFINITE); - if ( ret != 0 ) - { - return *count || *watch || *overlapped ? Status_OK : Status_Exit; - } - - // An error is returned if the underlying directory has been deleted, - // but this is not really an unexpected failure, so handle it - // specially. - if ( wxSysErrorCode() == ERROR_ACCESS_DENIED && - *watch && !wxFileName::DirExists((*watch)->GetPath()) ) - return Status_Deleted; - - // Some other error, at least log it. - wxLogSysError(_("Unable to dequeue completion packet")); - - return Status_Error; - } - -protected: - bool Init() - { - m_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); - if (m_iocp == NULL) - { - wxLogSysError(_("Unable to create I/O completion port")); - } - return m_iocp != NULL; - } - - HANDLE m_iocp; - - // The hash containing all the wxFSWatchEntryMSW objects currently being - // watched keyed by their paths. - wxFSWatchEntries m_watches; - - // Contains the watches which had been removed but are still pending. - typedef wxVector< wxSharedPtr > Watches; - Watches m_removedWatches; -}; - - -class wxIOCPThread : public wxThread -{ -public: - wxIOCPThread(wxFSWatcherImplMSW* service, wxIOCPService* iocp); - - // finishes this thread - bool Finish(); - -protected: - // structure to hold information needed to process one native event - // this is just a dummy holder, so it doesn't take ownership of it's data - struct wxEventProcessingData - { - wxEventProcessingData(const FILE_NOTIFY_INFORMATION* ne, - const wxFSWatchEntryMSW* watch) : - nativeEvent(ne), watch(watch) - {} - - const FILE_NOTIFY_INFORMATION* nativeEvent; - const wxFSWatchEntryMSW* watch; - }; - - virtual ExitCode Entry(); - - // wait for events to occur, read them and send to interested parties - // returns false it empty status was read, which means we whould exit - // true otherwise - bool ReadEvents(); - - void ProcessNativeEvents(wxVector& events); - - void SendEvent(wxFileSystemWatcherEvent& evt); - - static int Native2WatcherFlags(int flags); - - static wxString FileNotifyInformationToString( - const FILE_NOTIFY_INFORMATION& e); - - static wxFileName GetEventPath(const wxFSWatchEntryMSW& watch, - const FILE_NOTIFY_INFORMATION& e); - - wxFSWatcherImplMSW* m_service; - wxIOCPService* m_iocp; -}; - -#endif /* WX_MSW_PRIVATE_FSWATCHER_H_ */ diff --git a/Source/3rd Party/wx/include/wx/msw/private/hiddenwin.h b/Source/3rd Party/wx/include/wx/msw/private/hiddenwin.h deleted file mode 100644 index 3b52b6098..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/hiddenwin.h +++ /dev/null @@ -1,30 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/hiddenwin.h -// Purpose: Helper for creating a hidden window used by wxMSW internally. -// Author: Vadim Zeitlin -// Created: 2011-09-16 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_HIDDENWIN_H_ -#define _WX_MSW_PRIVATE_HIDDENWIN_H_ - -#include "wx/msw/private.h" - -/* - Creates a hidden window with supplied window proc registering the class for - it if necessary (i.e. the first time only). Caller is responsible for - destroying the window and unregistering the class (note that this must be - done because wxWidgets may be used as a DLL and so may be loaded/unloaded - multiple times into/from the same process so we can't rely on automatic - Windows class unregistration). - - pclassname is a pointer to a caller stored classname, which must initially be - NULL. classname is the desired wndclass classname. If function successfully - registers the class, pclassname will be set to classname. - */ -extern "C" WXDLLIMPEXP_BASE HWND -wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc); - -#endif // _WX_MSW_PRIVATE_HIDDENWIN_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/keyboard.h b/Source/3rd Party/wx/include/wx/msw/private/keyboard.h deleted file mode 100644 index 002303e96..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/keyboard.h +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/keyboard.h -// Purpose: Helper keyboard-related functions. -// Author: Vadim Zeitlin -// Created: 2010-09-09 -// Copyright: (c) 2010 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_KEYBOARD_H_ -#define _WX_MSW_PRIVATE_KEYBOARD_H_ - -#include "wx/defs.h" - -namespace wxMSWKeyboard -{ - -// ---------------------------------------------------------------------------- -// Functions for translating between MSW virtual keys codes and wx key codes -// -// These functions are currently implemented in src/msw/window.cpp. -// ---------------------------------------------------------------------------- - -// Translate MSW virtual key code to wx key code. lParam is used to distinguish -// between numpad and extended version of the keys, extended is assumed by -// default if lParam == 0. -// -// Returns WXK_NONE if translation couldn't be done at all (this happens e.g. -// for dead keys and in this case uc will be WXK_NONE too) or if the key -// corresponds to a non-Latin-1 character in which case uc is filled with its -// Unicode value. -WXDLLIMPEXP_CORE int VKToWX(WXWORD vk, WXLPARAM lParam = 0, wchar_t *uc = NULL); - -// Translate wxKeyCode enum element (passed as int for compatibility reasons) -// to MSW virtual key code. isExtended is set to true if the key corresponds to -// a non-numpad version of a key that exists both on numpad and outside it. -WXDLLIMPEXP_CORE WXWORD WXToVK(int id, bool *isExtended = NULL); - -} // namespace wxMSWKeyboard - -#endif // _WX_MSW_PRIVATE_KEYBOARD_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/metrics.h b/Source/3rd Party/wx/include/wx/msw/private/metrics.h deleted file mode 100644 index 0e1b41deb..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/metrics.h +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/metrics.h -// Purpose: various helper functions to retrieve system metrics -// Author: Vadim Zeitlin -// Created: 2008-09-05 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_METRICS_H_ -#define _WX_MSW_PRIVATE_METRICS_H_ - -namespace wxMSWImpl -{ - -// return NONCLIENTMETRICS as retrieved by SystemParametersInfo() -// -// currently this is not cached as the values may change when system settings -// do and we don't react to this to invalidate the cache but it could be done -// in the future -// -// MT-safety: this function is only meant to be called from the main thread -inline const NONCLIENTMETRICS& GetNonClientMetrics() -{ - static WinStruct nm; - if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) ) - { -#if WINVER >= 0x0600 - // a new field has been added to NONCLIENTMETRICS under Vista, so - // the call to SystemParametersInfo() fails if we use the struct - // size incorporating this new value on an older system -- retry - // without it - nm.cbSize -= sizeof(int); - if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) ) -#endif // WINVER >= 0x0600 - { - // maybe we should initialize the struct with some defaults? - wxLogLastError(wxT("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)")); - } - } - - return nm; -} - -} // namespace wxMSWImpl - -#endif // _WX_MSW_PRIVATE_METRICS_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/private/msgdlg.h b/Source/3rd Party/wx/include/wx/msw/private/msgdlg.h deleted file mode 100644 index e8946503b..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/msgdlg.h +++ /dev/null @@ -1,93 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/msgdlg.h -// Purpose: helper functions used with native message dialog -// Author: Rickard Westerlund -// Created: 2010-07-12 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_MSGDLG_H_ -#define _WX_MSW_PRIVATE_MSGDLG_H_ - -#include "wx/msw/wrapcctl.h" -#include "wx/scopedarray.h" - -// Macro to help identify if task dialogs are available: we rely on -// TD_WARNING_ICON being defined in the headers for this as this symbol is used -// by the task dialogs only. Also notice that task dialogs are available for -// Unicode applications only. -#if defined(TD_WARNING_ICON) && wxUSE_UNICODE - #define wxHAS_MSW_TASKDIALOG -#endif - -// Provides methods for creating a task dialog. -namespace wxMSWMessageDialog -{ - -#ifdef wxHAS_MSW_TASKDIALOG - class wxMSWTaskDialogConfig - { - public: - enum { MAX_BUTTONS = 4 }; - - wxMSWTaskDialogConfig() - : buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]), - parent(NULL), - iconId(0), - style(0), - useCustomLabels(false) - { } - - // initializes the object from a message dialog. - wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg); - - wxScopedArray buttons; - wxWindow *parent; - wxString caption; - wxString message; - wxString extendedMessage; - long iconId; - long style; - bool useCustomLabels; - wxString btnYesLabel; - wxString btnNoLabel; - wxString btnOKLabel; - wxString btnCancelLabel; - wxString btnHelpLabel; - - // Will create a task dialog with it's paremeters for it's creation - // stored in the provided TASKDIALOGCONFIG parameter. - // NOTE: The wxMSWTaskDialogConfig object needs to remain accessible - // during the subsequent call to TaskDialogIndirect(). - void MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc); - - // Used by MSWCommonTaskDialogInit() to add a regular button or a - // button with a custom label if used. - void AddTaskDialogButton(TASKDIALOGCONFIG &tdc, - int btnCustomId, - int btnCommonId, - const wxString& customLabel); - }; // class wxMSWTaskDialogConfig - - - typedef HRESULT (WINAPI *TaskDialogIndirect_t)(const TASKDIALOGCONFIG *, - int *, int *, BOOL *); - - // Return the pointer to TaskDialogIndirect(). This should only be called - // if HasNativeTaskDialog() returned true and is normally guaranteed to - // succeed in this case. - TaskDialogIndirect_t GetTaskDialogIndirectFunc(); -#endif // wxHAS_MSW_TASKDIALOG - - - // Check if the task dialog is available: this simply checks the OS version - // as we know that it's only present in Vista and later. - bool HasNativeTaskDialog(); - - // Translates standard MSW button IDs like IDCANCEL into an equivalent - // wx constant such as wxCANCEL. - int MSWTranslateReturnCode(int msAns); -}; // namespace wxMSWMessageDialog - -#endif // _WX_MSW_PRIVATE_MSGDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/pipestream.h b/Source/3rd Party/wx/include/wx/msw/private/pipestream.h deleted file mode 100644 index ba6d032be..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/pipestream.h +++ /dev/null @@ -1,50 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/pipestream.h -// Purpose: MSW wxPipeInputStream and wxPipeOutputStream declarations -// Author: Vadim Zeitlin -// Created: 2013-06-08 (extracted from src/msw/utilsexc.cpp) -// Copyright: (c) 2013 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_PIPESTREAM_H_ -#define _WX_MSW_PRIVATE_PIPESTREAM_H_ - -class wxPipeInputStream : public wxInputStream -{ -public: - wxEXPLICIT wxPipeInputStream(HANDLE hInput); - virtual ~wxPipeInputStream(); - - // returns true if the pipe is still opened - bool IsOpened() const { return m_hInput != INVALID_HANDLE_VALUE; } - - // returns true if there is any data to be read from the pipe - virtual bool CanRead() const; - -protected: - virtual size_t OnSysRead(void *buffer, size_t len); - -protected: - HANDLE m_hInput; - - wxDECLARE_NO_COPY_CLASS(wxPipeInputStream); -}; - -class wxPipeOutputStream: public wxOutputStream -{ -public: - wxEXPLICIT wxPipeOutputStream(HANDLE hOutput); - virtual ~wxPipeOutputStream() { Close(); } - bool Close(); - -protected: - size_t OnSysWrite(const void *buffer, size_t len); - -protected: - HANDLE m_hOutput; - - wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream); -}; - -#endif // _WX_MSW_PRIVATE_PIPESTREAM_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/sockmsw.h b/Source/3rd Party/wx/include/wx/msw/private/sockmsw.h deleted file mode 100644 index e0f550d32..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/sockmsw.h +++ /dev/null @@ -1,66 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/gsockmsw.h -// Purpose: MSW-specific socket implementation -// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia, Vadim Zeitlin -// Created: April 1997 -// Copyright: (C) 1999-1997, Guilhem Lavaux -// (C) 1999-2000, Guillermo Rodriguez Garcia -// (C) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef _WX_MSW_GSOCKMSW_H_ -#define _WX_MSW_GSOCKMSW_H_ - -#include "wx/msw/wrapwin.h" - -#if defined(__CYGWIN__) - //CYGWIN gives annoying warning about runtime stuff if we don't do this -# define USE_SYS_TYPES_FD_SET -# include -#endif - -#if defined(__WXWINCE__) || defined(__CYGWIN__) - #include -#endif - -// ---------------------------------------------------------------------------- -// MSW-specific socket implementation -// ---------------------------------------------------------------------------- - -class wxSocketImplMSW : public wxSocketImpl -{ -public: - wxSocketImplMSW(wxSocketBase& wxsocket); - - virtual ~wxSocketImplMSW(); - - virtual wxSocketError GetLastError() const; - - virtual void ReenableEvents(wxSocketEventFlags WXUNUSED(flags)) - { - // notifications are never disabled in this implementation, there is no - // need for this as WSAAsyncSelect() only sends notification once when - // the new data becomes available anyhow, so there is no need to do - // anything here - } - -private: - virtual void DoClose(); - - virtual void UnblockAndRegisterWithEventLoop() - { - // no need to make the socket non-blocking, Install_Callback() will do - // it - wxSocketManager::Get()->Install_Callback(this); - } - - int m_msgnumber; - - friend class wxSocketMSWManager; - - wxDECLARE_NO_COPY_CLASS(wxSocketImplMSW); -}; - -#endif /* _WX_MSW_GSOCKMSW_H_ */ diff --git a/Source/3rd Party/wx/include/wx/msw/private/textmeasure.h b/Source/3rd Party/wx/include/wx/msw/private/textmeasure.h deleted file mode 100644 index ee14751a5..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/textmeasure.h +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/textmeasure.h -// Purpose: wxMSW-specific declaration of wxTextMeasure class -// Author: Manuel Martin -// Created: 2012-10-05 -// Copyright: (c) 1997-2012 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_TEXTMEASURE_H_ -#define _WX_MSW_PRIVATE_TEXTMEASURE_H_ - -#include "wx/msw/wrapwin.h" - -// ---------------------------------------------------------------------------- -// wxTextMeasure for MSW. -// ---------------------------------------------------------------------------- - -class wxTextMeasure : public wxTextMeasureBase -{ -public: - wxEXPLICIT wxTextMeasure(const wxDC *dc, const wxFont *font = NULL) - : wxTextMeasureBase(dc, font) - { - Init(); - } - - wxEXPLICIT wxTextMeasure(const wxWindow *win, const wxFont *font = NULL) - : wxTextMeasureBase(win, font) - { - Init(); - } - -protected: - void Init(); - - virtual void BeginMeasuring(); - virtual void EndMeasuring(); - - virtual void DoGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL); - - virtual bool DoGetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX); - - - - // We use either the HDC of the provided wxDC or an HDC created for our - // window. - HDC m_hdc; - - // If we change the font in BeginMeasuring(), we restore it to the old one - // in EndMeasuring(). - HFONT m_hfontOld; - - wxDECLARE_NO_COPY_CLASS(wxTextMeasure); -}; - -#endif // _WX_MSW_PRIVATE_TEXTMEASURE_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/private/timer.h b/Source/3rd Party/wx/include/wx/msw/private/timer.h deleted file mode 100644 index 71ce2ceec..000000000 --- a/Source/3rd Party/wx/include/wx/msw/private/timer.h +++ /dev/null @@ -1,36 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/private/timer.h -// Purpose: wxTimer class -// Author: Julian Smart -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_PRIVATE_TIMER_H_ -#define _WX_MSW_PRIVATE_TIMER_H_ - -#if wxUSE_TIMER - -#include "wx/private/timer.h" -#include "wx/msw/wrapwin.h" // for WPARAM - -class WXDLLIMPEXP_BASE wxMSWTimerImpl : public wxTimerImpl -{ -public: - wxMSWTimerImpl(wxTimer *timer) : wxTimerImpl(timer) { m_id = 0; } - - virtual bool Start(int milliseconds = -1, bool oneShot = false); - virtual void Stop(); - - virtual bool IsRunning() const { return m_id != 0; } - -protected: - // this must be 64 bit under Win64 as WPARAM (storing timer ids) is 64 bit - // there and so the ids may possibly not fit in 32 bits - WPARAM m_id; -}; - -#endif // wxUSE_TIMER - -#endif // _WX_TIMERH_ diff --git a/Source/3rd Party/wx/include/wx/msw/progdlg.h b/Source/3rd Party/wx/include/wx/msw/progdlg.h deleted file mode 100644 index c63a0b66f..000000000 --- a/Source/3rd Party/wx/include/wx/msw/progdlg.h +++ /dev/null @@ -1,73 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/progdlg.h -// Purpose: wxProgressDialog -// Author: Rickard Westerlund -// Created: 2010-07-22 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PROGDLG_H_ -#define _WX_PROGDLG_H_ - -class wxProgressDialogTaskRunner; -class wxProgressDialogSharedData; - -class WXDLLIMPEXP_CORE wxProgressDialog : public wxGenericProgressDialog -{ -public: - wxProgressDialog(const wxString& title, const wxString& message, - int maximum = 100, - wxWindow *parent = NULL, - int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE); - - virtual ~wxProgressDialog(); - - virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL); - virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL); - - void Resume(); - - int GetValue() const; - wxString GetMessage() const; - - void SetRange(int maximum); - - // Return whether "Cancel" or "Skip" button was pressed, always return - // false if the corresponding button is not shown. - bool WasSkipped() const; - bool WasCancelled() const; - - virtual void SetTitle(const wxString& title); - virtual wxString GetTitle() const; - - virtual bool Show( bool show = true ); - - // Must provide overload to avoid hiding it (and warnings about it) - virtual void Update() { wxGenericProgressDialog::Update(); } - - virtual WXWidget GetHandle() const; - -private: - // Performs common routines to Update() and Pulse(). Requires the - // shared object to have been entered. - bool DoNativeBeforeUpdate(bool *skip); - - // Updates the various timing informations for both determinate - // and indeterminate modes. Requires the shared object to have - // been entered. - void UpdateExpandedInformation(int value); - - wxProgressDialogTaskRunner *m_taskDialogRunner; - - wxProgressDialogSharedData *m_sharedData; - - // Store the message and title we currently use to be able to return it - // from Get{Message,Title}() - wxString m_message, - m_title; - - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxProgressDialog); -}; - -#endif // _WX_PROGDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/radiobox.h b/Source/3rd Party/wx/include/wx/msw/radiobox.h index 261d724d6..8012dd8b9 100644 --- a/Source/3rd Party/wx/include/wx/msw/radiobox.h +++ b/Source/3rd Party/wx/include/wx/msw/radiobox.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: radiobox.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,7 +20,7 @@ class WXDLLIMPEXP_FWD_CORE wxSubwindows; // wxRadioBox // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRadioBox : public wxStaticBox, public wxRadioBoxBase +class WXDLLEXPORT wxRadioBox : public wxStaticBox, public wxRadioBoxBase { public: wxRadioBox() { Init(); } @@ -31,7 +32,7 @@ public: const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDim = 0, - long style = wxRA_SPECIFY_COLS, + long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) { @@ -48,7 +49,7 @@ public: const wxSize& size, const wxArrayString& choices, int majorDim = 0, - long style = wxRA_SPECIFY_COLS, + long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) { @@ -67,7 +68,7 @@ public: const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDim = 0, - long style = wxRA_SPECIFY_COLS, + long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); bool Create(wxWindow *parent, @@ -77,7 +78,7 @@ public: const wxSize& size, const wxArrayString& choices, int majorDim = 0, - long style = wxRA_SPECIFY_COLS, + long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); @@ -96,7 +97,6 @@ public: // override some base class methods virtual bool Show(bool show = true); virtual bool Enable(bool enable = true); - virtual bool CanBeFocused() const; virtual void SetFocus(); virtual bool SetFont(const wxFont& font); virtual bool ContainsHWND(WXHWND hWnd) const; @@ -113,20 +113,16 @@ public: virtual bool Reparent(wxWindowBase *newParent); - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } + // we inherit a version always returning false from wxStaticBox, override + // it to behave normally + virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); } void SetLabelFont(const wxFont& WXUNUSED(font)) {} void SetButtonFont(const wxFont& font) { SetFont(font); } - // implementation only from now on // ------------------------------- - // This function can be used to check if the given radio button HWND - // belongs to one of our radio boxes. If it doesn't, NULL is returned. - static wxRadioBox *GetFromRadioButtonHWND(WXHWND hwnd); - virtual bool MSWCommand(WXUINT param, WXWORD id); void Command(wxCommandEvent& event); @@ -145,13 +141,9 @@ protected: // get the total size occupied by the radio box buttons wxSize GetTotalButtonSize(const wxSize& sizeBtn) const; - // Adjust all the buttons to the new window size. - void PositionAllButtons(int x, int y, int width, int height); - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual void DoMoveWindow(int x, int y, int width, int height); virtual wxSize DoGetBestSize() const; #if wxUSE_TOOLTIPS @@ -162,16 +154,10 @@ protected: virtual WXHRGN MSWGetRegionWithoutChildren(); #endif // __WXWINCE__ - // resolve ambiguity in base classes - virtual wxBorder GetDefaultBorder() const { return wxRadioBoxBase::GetDefaultBorder(); } // the buttons we contain wxSubwindows *m_radioButtons; - // and the special dummy button used only as a tab group boundary - WXHWND m_dummyHwnd; - wxWindowIDRef m_dummyId; - // array of widths and heights of the buttons, may be wxDefaultCoord if the // corresponding quantity should be computed int *m_radioWidth; @@ -182,7 +168,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxRadioBox) - wxDECLARE_NO_COPY_CLASS(wxRadioBox); + DECLARE_NO_COPY_CLASS(wxRadioBox) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/radiobut.h b/Source/3rd Party/wx/include/wx/msw/radiobut.h index b5a235b6d..6e48bf3f3 100644 --- a/Source/3rd Party/wx/include/wx/msw/radiobut.h +++ b/Source/3rd Party/wx/include/wx/msw/radiobut.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/radiobut.h +// Name: radiobut.h // Purpose: wxRadioButton class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: radiobut.h 41144 2006-09-10 23:08:13Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_RADIOBUT_H_ #define _WX_RADIOBUT_H_ -class WXDLLIMPEXP_CORE wxRadioButton: public wxControl +class WXDLLEXPORT wxRadioButton: public wxControl { public: // ctors and creation functions @@ -52,7 +53,6 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } virtual wxSize DoGetBestSize() const; private: diff --git a/Source/3rd Party/wx/include/wx/msw/rcdefs.h b/Source/3rd Party/wx/include/wx/msw/rcdefs.h deleted file mode 100644 index 8b9ac716f..000000000 --- a/Source/3rd Party/wx/include/wx/msw/rcdefs.h +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/rcdefs.h -// Purpose: Fallback for the generated rcdefs.h under the lib directory -// Author: Mike Wetherell -// Copyright: (c) 2005 Mike Wetherell -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_RCDEFS_H -#define _WX_RCDEFS_H - -#ifdef __GNUC__ - // We must be using windres which uses gcc as its preprocessor. We do need - // to generate the manifest then as gcc doesn't do it automatically and we - // can define the architecture macro on our own as all the usual symbols - // are available (unlike with Microsoft RC.EXE which doesn't predefine - // anything useful at all). - #ifndef wxUSE_RC_MANIFEST - #define wxUSE_RC_MANIFEST 1 - #endif - - #if defined __i386__ - #ifndef WX_CPU_X86 - #define WX_CPU_X86 - #endif - #elif defined __x86_64__ - #ifndef WX_CPU_AMD64 - #define WX_CPU_AMD64 - #endif - #elif defined __ia64__ - #ifndef WX_CPU_IA64 - #define WX_CPU_IA64 - #endif - #endif -#endif - -// Don't do anything here for the other compilers, in particular don't define -// WX_CPU_X86 here as we used to do. If people define wxUSE_RC_MANIFEST, they -// must also define the architecture constant correctly. - -#endif diff --git a/Source/3rd Party/wx/include/wx/msw/regconf.h b/Source/3rd Party/wx/include/wx/msw/regconf.h index 31b1b4aba..a256e98c8 100644 --- a/Source/3rd Party/wx/include/wx/msw/regconf.h +++ b/Source/3rd Party/wx/include/wx/msw/regconf.h @@ -1,24 +1,27 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/regconf.h +// Name: msw/regconf.h // Purpose: Registry based implementation of wxConfigBase // Author: Vadim Zeitlin // Modified by: // Created: 27.04.98 +// RCS-ID: $Id: regconf.h 62185 2009-09-28 10:02:42Z JS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _WX_MSW_REGCONF_H_ -#define _WX_MSW_REGCONF_H_ +#ifndef _REGCONF_H +#define _REGCONF_H #include "wx/defs.h" -#if wxUSE_CONFIG && wxUSE_REGKEY +#if wxUSE_CONFIG + +#ifndef _REGISTRY_H + #include "wx/msw/registry.h" +#endif -#include "wx/msw/registry.h" #include "wx/object.h" #include "wx/confbase.h" -#include "wx/buffer.h" // ---------------------------------------------------------------------------- // wxRegConfig @@ -91,24 +94,23 @@ protected: // implement read/write methods virtual bool DoReadString(const wxString& key, wxString *pStr) const; virtual bool DoReadLong(const wxString& key, long *plResult) const; - virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const; virtual bool DoWriteString(const wxString& key, const wxString& szValue); virtual bool DoWriteLong(const wxString& key, long lValue); - virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf); private: + // no copy ctor/assignment operator + wxRegConfig(const wxRegConfig&); + wxRegConfig& operator=(const wxRegConfig&); + // these keys are opened during all lifetime of wxRegConfig object wxRegKey m_keyLocalRoot, m_keyLocal, m_keyGlobalRoot, m_keyGlobal; // current path (not '/' terminated) wxString m_strPath; - - wxDECLARE_NO_COPY_CLASS(wxRegConfig); - DECLARE_ABSTRACT_CLASS(wxRegConfig) }; -#endif // wxUSE_CONFIG && wxUSE_REGKEY +#endif // wxUSE_CONFIG -#endif // _WX_MSW_REGCONF_H_ +#endif // _REGCONF_H diff --git a/Source/3rd Party/wx/include/wx/msw/region.h b/Source/3rd Party/wx/include/wx/msw/region.h index ae60875e2..881214c7e 100644 --- a/Source/3rd Party/wx/include/wx/msw/region.h +++ b/Source/3rd Party/wx/include/wx/msw/region.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: region.h 59602 2009-03-18 10:07:58Z VZ $ // Copyright: (c) 1997-2002 wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_MSW_REGION_H_ #define _WX_MSW_REGION_H_ -class WXDLLIMPEXP_CORE wxRegion : public wxRegionWithCombine +class WXDLLEXPORT wxRegion : public wxRegionWithCombine { public: wxRegion(); @@ -19,7 +20,7 @@ public: wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxRect& rect); wxRegion(WXHRGN hRegion); // Hangs on to this region - wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); + wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); #if wxUSE_IMAGE wxRegion( const wxBitmap& bmp) { @@ -42,8 +43,8 @@ public: WXHRGN GetHRGN() const; protected: - virtual wxGDIRefData *CreateGDIRefData() const; - virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; + virtual wxObjectRefData *CreateRefData() const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual bool DoIsEqual(const wxRegion& region) const; virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const; @@ -58,7 +59,7 @@ protected: DECLARE_DYNAMIC_CLASS(wxRegion) }; -class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject +class WXDLLEXPORT wxRegionIterator : public wxObject { public: wxRegionIterator() { Init(); } diff --git a/Source/3rd Party/wx/include/wx/msw/registry.h b/Source/3rd Party/wx/include/wx/msw/registry.h index 23453c94e..04758d280 100644 --- a/Source/3rd Party/wx/include/wx/msw/registry.h +++ b/Source/3rd Party/wx/include/wx/msw/registry.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.04.1998 +// RCS-ID: $Id: registry.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,10 +12,6 @@ #ifndef _WX_MSW_REGISTRY_H_ #define _WX_MSW_REGISTRY_H_ -#include "wx/defs.h" - -#if wxUSE_REGKEY - class WXDLLIMPEXP_FWD_BASE wxOutputStream; // ---------------------------------------------------------------------------- @@ -65,22 +62,6 @@ public: Write // read and write }; - // Different registry views supported under WOW64. - enum WOW64ViewMode - { - // 32 bit registry for 32 bit applications, 64 bit registry - // for 64 bit ones. - WOW64ViewMode_Default, - - // Can be used in 64 bit apps to access 32 bit registry, - // has no effect (i.e. treated as default) in 32 bit apps. - WOW64ViewMode_32, - - // Can be used in 32 bit apps to access 64 bit registry, - // has no effect (i.e. treated as default) in 64 bit apps. - WOW64ViewMode_64 - }; - // information about standard (predefined) registry keys // number of standard keys static const size_t nStdKeys; @@ -91,23 +72,17 @@ public: // get StdKey from root HKEY static StdKey GetStdKeyFromHkey(WXHKEY hkey); - // extracts the std key prefix from the string (return value) and + // extacts the std key prefix from the string (return value) and // leaves only the part after it (i.e. modifies the string passed!) static StdKey ExtractKeyName(wxString& str); // ctors // root key is set to HKCR (the only root key under Win16) - wxRegKey(WOW64ViewMode viewMode = WOW64ViewMode_Default); - + wxRegKey(); // strKey is the full name of the key (i.e. starting with HKEY_xxx...) - wxRegKey(const wxString& strKey, - WOW64ViewMode viewMode = WOW64ViewMode_Default); - + wxRegKey(const wxString& strKey); // strKey is the name of key under (standard key) keyParent - wxRegKey(StdKey keyParent, - const wxString& strKey, - WOW64ViewMode viewMode = WOW64ViewMode_Default); - + wxRegKey(StdKey keyParent, const wxString& strKey); // strKey is the name of key under (previously created) keyParent wxRegKey(const wxRegKey& keyParent, const wxString& strKey); // dtor closes the key @@ -126,8 +101,6 @@ public: // get infomation about the key // get the (full) key name. Abbreviate std root keys if bShortPrefix. wxString GetName(bool bShortPrefix = true) const; - // Retrieves the registry view used by this key. - WOW64ViewMode GetView() const { return m_viewMode; } // return true if the key exists bool Exists() const; // get the info about key (any number of these pointers may be NULL) @@ -147,16 +120,15 @@ public: // create the key: will fail if the key already exists and !bOkIfExists bool Create(bool bOkIfExists = true); // rename a value from old name to new one - bool RenameValue(const wxString& szValueOld, const wxString& szValueNew); + bool RenameValue(const wxChar *szValueOld, const wxChar *szValueNew); // rename the key - bool Rename(const wxString& szNewName); + bool Rename(const wxChar *szNewName); // copy value to another key possibly changing its name (by default it will // remain the same) - bool CopyValue(const wxString& szValue, wxRegKey& keyDst, - const wxString& szNewName = wxEmptyString); - + bool CopyValue(const wxChar *szValue, wxRegKey& keyDst, + const wxChar *szNewName = NULL); // copy the entire contents of the key recursively to another location - bool Copy(const wxString& szNewName); + bool Copy(const wxChar *szNewName); // same as Copy() but using a key and not the name bool Copy(wxRegKey& keyDst); // close the key (will be automatically done in dtor) @@ -166,19 +138,21 @@ public: // deletes this key and all of it's subkeys/values bool DeleteSelf(); // deletes the subkey with all of it's subkeys/values recursively - bool DeleteKey(const wxString& szKey); - // deletes the named value (may be empty string to remove the default value) - bool DeleteValue(const wxString& szValue); + bool DeleteKey(const wxChar *szKey); + // deletes the named value (may be NULL to remove the default value) + bool DeleteValue(const wxChar *szValue); // access to values and subkeys // get value type - ValueType GetValueType(const wxString& szValue) const; + ValueType GetValueType(const wxChar *szValue) const; // returns true if the value contains a number (else it's some string) - bool IsNumericValue(const wxString& szValue) const; + bool IsNumericValue(const wxChar *szValue) const; // assignment operators set the default value of the key wxRegKey& operator=(const wxString& strValue) - { SetValue(wxEmptyString, strValue); return *this; } + { SetValue(NULL, strValue); return *this; } + wxRegKey& operator=(long lValue) + { SetValue(NULL, lValue); return *this; } // query the default value of the key: implicitly or explicitly wxString QueryDefaultValue() const; @@ -187,30 +161,30 @@ public: // named values // set the string value - bool SetValue(const wxString& szValue, const wxString& strValue); + bool SetValue(const wxChar *szValue, const wxString& strValue); // retrieve the string value - bool QueryValue(const wxString& szValue, wxString& strValue) const + bool QueryValue(const wxChar *szValue, wxString& strValue) const { return QueryValue(szValue, strValue, false); } // retrieve raw string value - bool QueryRawValue(const wxString& szValue, wxString& strValue) const + bool QueryRawValue(const wxChar *szValue, wxString& strValue) const { return QueryValue(szValue, strValue, true); } // retrieve either raw or expanded string value - bool QueryValue(const wxString& szValue, wxString& strValue, bool raw) const; + bool QueryValue(const wxChar *szValue, wxString& strValue, bool raw) const; // set the numeric value - bool SetValue(const wxString& szValue, long lValue); + bool SetValue(const wxChar *szValue, long lValue); // return the numeric value - bool QueryValue(const wxString& szValue, long *plValue) const; + bool QueryValue(const wxChar *szValue, long *plValue) const; // set the binary value - bool SetValue(const wxString& szValue, const wxMemoryBuffer& buf); + bool SetValue(const wxChar *szValue, const wxMemoryBuffer& buf); // return the binary value - bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const; + bool QueryValue(const wxChar *szValue, wxMemoryBuffer& buf) const; // query existence of a key/value // return true if value exists - bool HasValue(const wxString& szKey) const; + bool HasValue(const wxChar *szKey) const; // return true if given subkey exists - bool HasSubKey(const wxString& szKey) const; + bool HasSubKey(const wxChar *szKey) const; // return true if any subkeys exist bool HasSubkeys() const; // return true if any values exist @@ -258,18 +232,16 @@ private: wxString FormatValue(const wxString& name) const; - WXHKEY m_hKey, // our handle - m_hRootKey; // handle of the top key (i.e. StdKey) - wxString m_strKey; // key name (relative to m_hRootKey) - WOW64ViewMode m_viewMode; // which view to select under WOW64 - AccessMode m_mode; // valid only if key is opened - long m_dwLastError; // last error (0 if none) + WXHKEY m_hKey, // our handle + m_hRootKey; // handle of the top key (i.e. StdKey) + wxString m_strKey; // key name (relative to m_hRootKey) + + AccessMode m_mode; // valid only if key is opened + long m_dwLastError; // last error (0 if none) - wxDECLARE_NO_COPY_CLASS(wxRegKey); + DECLARE_NO_COPY_CLASS(wxRegKey) }; -#endif // wxUSE_REGKEY - #endif // _WX_MSW_REGISTRY_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/richmsgdlg.h b/Source/3rd Party/wx/include/wx/msw/richmsgdlg.h deleted file mode 100644 index 51cdc6322..000000000 --- a/Source/3rd Party/wx/include/wx/msw/richmsgdlg.h +++ /dev/null @@ -1,30 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/richmsgdlg.h -// Purpose: wxRichMessageDialog -// Author: Rickard Westerlund -// Created: 2010-07-04 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_RICHMSGDLG_H_ -#define _WX_MSW_RICHMSGDLG_H_ - -class WXDLLIMPEXP_CORE wxRichMessageDialog : public wxGenericRichMessageDialog -{ -public: - wxRichMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK | wxCENTRE) - : wxGenericRichMessageDialog(parent, message, caption, style) - { } - - // overridden base class method showing the native task dialog if possible - virtual int ShowModal(); - -private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxRichMessageDialog); -}; - -#endif // _WX_MSW_RICHMSGDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/scrolbar.h b/Source/3rd Party/wx/include/wx/msw/scrolbar.h index 663549393..bfe86c6a8 100644 --- a/Source/3rd Party/wx/include/wx/msw/scrolbar.h +++ b/Source/3rd Party/wx/include/wx/msw/scrolbar.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/scrolbar.h +// Name: scrollbar.h // Purpose: wxScrollBar class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: scrolbar.h 41020 2006-09-05 20:47:48Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ #define _WX_SCROLBAR_H_ // Scrollbar item -class WXDLLIMPEXP_CORE wxScrollBar: public wxScrollBarBase +class WXDLLEXPORT wxScrollBar: public wxScrollBarBase { public: wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; } @@ -57,9 +58,6 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: virtual wxSize DoGetBestSize() const; diff --git a/Source/3rd Party/wx/include/wx/msw/seh.h b/Source/3rd Party/wx/include/wx/msw/seh.h index d3c7dccfe..23053fab0 100644 --- a/Source/3rd Party/wx/include/wx/msw/seh.h +++ b/Source/3rd Party/wx/include/wx/msw/seh.h @@ -3,6 +3,7 @@ // Purpose: declarations for SEH (structured exceptions handling) support // Author: Vadim Zeitlin // Created: 2006-04-26 +// RCS-ID: $Id: seh.h 44451 2007-02-11 02:17:28Z VZ $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -54,11 +55,11 @@ // as division by 0 or access violation) to C++ pseudo-exceptions extern void wxSETranslator(unsigned int code, EXCEPTION_POINTERS *ep); - // up to VC 12 this warning ("calling _set_se_translator() requires /EHa") + // up to VC 7.1 this warning ("calling _set_se_translator() requires /EHa") // is harmless and it's easier to suppress it than use different makefiles - // for VC5 and 6 (which don't support /EHa at all) and VC7+ (which does + // for VC5 and 6 (which don't support /EHa at all) and VC7 (which does // accept it but it seems to change nothing for it anyhow) - #if __VISUALC__ < 1900 + #if __VISUALC__ <= 1310 #pragma warning(disable: 4535) #endif diff --git a/Source/3rd Party/wx/include/wx/msw/setup.h b/Source/3rd Party/wx/include/wx/msw/setup.h index 58089ae97..36147b18f 100644 --- a/Source/3rd Party/wx/include/wx/msw/setup.h +++ b/Source/3rd Party/wx/include/wx/msw/setup.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: setup0.h 60190 2009-04-16 00:57:35Z KO $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -26,6 +27,14 @@ // compatibility settings // ---------------------------------------------------------------------------- +// This setting determines the compatibility with 2.4 API: set it to 1 to +// enable it but please consider updating your code instead. +// +// Default is 0 +// +// Recommended setting: 0 (please update your code) +#define WXWIN_COMPATIBILITY_2_4 0 + // This setting determines the compatibility with 2.6 API: set it to 0 to // flag all cases of using deprecated functions. // @@ -34,17 +43,7 @@ // in the version after it completely. // // Recommended setting: 0 (please update your code) -#define WXWIN_COMPATIBILITY_2_6 0 - -// This setting determines the compatibility with 2.8 API: set it to 0 to -// flag all cases of using deprecated functions. -// -// Default is 1 but please try building your code with 0 as the default will -// change to 0 in the next version and the deprecated functions will disappear -// in the version after it completely. -// -// Recommended setting: 0 (please update your code) -#define WXWIN_COMPATIBILITY_2_8 1 +#define WXWIN_COMPATIBILITY_2_6 1 // MSW-only: Set to 0 for accurate dialog units, else 1 for old behaviour when // default system font is used for wxWindow::GetCharWidth/Height() instead of @@ -59,50 +58,6 @@ // debugging settings // ---------------------------------------------------------------------------- -// wxDEBUG_LEVEL will be defined as 1 in wx/debug.h so normally there is no -// need to define it here. You may do it for two reasons: either completely -// disable/compile out the asserts in release version (then do it inside #ifdef -// NDEBUG) or, on the contrary, enable more asserts, including the usually -// disabled ones, in the debug build (then do it inside #ifndef NDEBUG) -// -// #ifdef NDEBUG -// #define wxDEBUG_LEVEL 0 -// #else -// #define wxDEBUG_LEVEL 2 -// #endif - -// wxHandleFatalExceptions() may be used to catch the program faults at run -// time and, instead of terminating the program with a usual GPF message box, -// call the user-defined wxApp::OnFatalException() function. If you set -// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work. -// -// This setting is for Win32 only and can only be enabled if your compiler -// supports Win32 structured exception handling (currently only VC++ does) -// -// Default is 1 -// -// Recommended setting: 1 if your compiler supports it. -#define wxUSE_ON_FATAL_EXCEPTION 1 - -// Set this to 1 to be able to generate a human-readable (unlike -// machine-readable minidump created by wxCrashReport::Generate()) stack back -// trace when your program crashes using wxStackWalker -// -// Default is 1 if supported by the compiler. -// -// Recommended setting: 1, set to 0 if your programs never crash -#define wxUSE_STACKWALKER 1 - -// Set this to 1 to compile in wxDebugReport class which allows you to create -// and optionally upload to your web site a debug report consisting of back -// trace of the crash (if wxUSE_STACKWALKER == 1) and other information. -// -// Default is 1 if supported by the compiler. -// -// Recommended setting: 1, it is compiled into a separate library so there -// is no overhead if you don't use it -#define wxUSE_DEBUGREPORT 1 - // Generic comment about debugging settings: they are very useful if you don't // use any other memory leak detection tools such as Purify/BoundsChecker, but // are probably redundant otherwise. Also, Visual C++ CRT has the same features @@ -110,13 +65,10 @@ // may prefer to use it instead of built in memory debugging code because it is // faster and more fool proof. // -// Using VC++ CRT memory debugging is enabled by default in debug build (_DEBUG -// is defined) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0) +// Using VC++ CRT memory debugging is enabled by default in debug mode +// (__WXDEBUG__) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0) // and if __NO_VC_CRTDBG__ is not defined. -// The rest of the options in this section are obsolete and not supported, -// enable them at your own risk. - // If 1, enables wxDebugContext, for writing error messages to file, etc. If // __WXDEBUG__ is not defined, will still use the normal memory operators. // @@ -150,27 +102,72 @@ // In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If // this causes problems (e.g. link errors), set this to 0. You may need to set // this to 0 if using templates (at least for VC++). This switch is currently -// ignored for MinGW/Cygwin. +// ignored for mingw / cygwin / CodeWarrior // // Default is 0 // // Recommended setting: 0 #define wxUSE_DEBUG_NEW_ALWAYS 0 +// wxHandleFatalExceptions() may be used to catch the program faults at run +// time and, instead of terminating the program with a usual GPF message box, +// call the user-defined wxApp::OnFatalException() function. If you set +// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work. +// +// This setting is for Win32 only and can only be enabled if your compiler +// supports Win32 structured exception handling (currently only VC++ does) +// +// Default is 1 +// +// Recommended setting: 1 if your compiler supports it. +#define wxUSE_ON_FATAL_EXCEPTION 1 + +// Set this to 1 to be able to generate a human-readable (unlike +// machine-readable minidump created by wxCrashReport::Generate()) stack back +// trace when your program crashes using wxStackWalker +// +// Default is 1 if supported by the compiler. +// +// Recommended setting: 1, set to 0 if your programs never crash +#define wxUSE_STACKWALKER 1 + +// Set this to 1 to compile in wxDebugReport class which allows you to create +// and optionally upload to your web site a debug report consisting of back +// trace of the crash (if wxUSE_STACKWALKER == 1) and other information. +// +// Default is 1 if supported by the compiler. +// +// Recommended setting: 1, it is compiled into a separate library so there +// is no overhead if you don't use it +#define wxUSE_DEBUGREPORT 0 // ---------------------------------------------------------------------------- // Unicode support // ---------------------------------------------------------------------------- -// These settings are obsolete: the library is always built in Unicode mode -// now, only set wxUSE_UNICODE to 0 to compile legacy code in ANSI mode if -// absolutely necessary -- updating it is strongly recommended as the ANSI mode -// will disappear completely in future wxWidgets releases. +// Set wxUSE_UNICODE to 1 to compile wxWidgets in Unicode mode: wxChar will be +// defined as wchar_t, wxString will use Unicode internally. If you set this +// to 1, you must use wxT() macro for all literal strings in the program. +// +// Unicode is currently only fully supported under Windows NT/2000/XP +// (Windows 9x doesn't support it and the programs compiled in Unicode mode +// will not run under 9x -- but see wxUSE_UNICODE_MSLU below). +// +// Default is 0 +// +// Recommended setting: 0 (unless you only plan to use Windows NT/2000/XP) #ifndef wxUSE_UNICODE - #define wxUSE_UNICODE 0//TODO:pj64 + #define wxUSE_UNICODE 0 #endif -// wxUSE_WCHAR_T is required by wxWidgets now, don't change. +// Setting wxUSE_WCHAR_T to 1 gives you some degree of Unicode support without +// compiling the program in Unicode mode. More precisely, it will be possible +// to construct wxString from a wide (Unicode) string and convert any wxString +// to Unicode. +// +// Default is 1 +// +// Recommended setting: 1 #define wxUSE_WCHAR_T 1 // ---------------------------------------------------------------------------- @@ -200,6 +197,15 @@ // Recommended setting: 0 (this is still work in progress...) #define wxUSE_EXTENDED_RTTI 0 +// Set wxUSE_STL to 1 to derive wxList(Foo) and wxArray(Foo) from +// std::list and std::vector, with a compatibility interface, +// and for wxHashMap to be implemented with templates. +// +// Default is 0 +// +// Recommended setting: YMMV +#define wxUSE_STL 0 + // Support for message/error logging. This includes wxLogXXX() functions and // wxLog and derived classes. Don't set this to 0 unless you really know what // you are doing. @@ -251,6 +257,37 @@ // Recommended setting: 1 as setting it to 0 disables many other things #define wxUSE_STREAMS 1 +// Use standard C++ streams if 1 instead of wx streams in some places. If +// disabled (default), wx streams are used everywhere and wxWidgets doesn't +// depend on the standard streams library. +// +// Notice that enabling this does not replace wx streams with std streams +// everywhere, in a lot of places wx streams are used no matter what. +// +// Default is 0 +// +// Recommended setting: 1 if you use the standard streams anyhow and so +// dependency on the standard streams library is not a +// problem +#define wxUSE_STD_IOSTREAM 0 + +// Enable conversion to standard C++ string if 1. +// +// Default is 1 for most compilers. +// +// Currently the Digital Mars and Watcom compilers come without standard C++ +// library headers by default, wxUSE_STD_STRING can be set to 1 if you do have +// them (e.g. from STLPort). +// +// VC++ 5.0 does include standard C++ library header, however they produce +// many warnings that can't be turned off when compiled at warning level 4. +#if defined(__DMC__) || defined(__WATCOMC__) \ + || (defined(_MSC_VER) && _MSC_VER < 1200) + #define wxUSE_STD_STRING 0 +#else + #define wxUSE_STD_STRING 1 +#endif + // Support for positional parameters (e.g. %1$d, %2$s ...) in wxVsnprintf. // Note that if the system's implementation does not support positional // parameters, setting this to 1 forces the use of the wxWidgets implementation @@ -266,125 +303,6 @@ // Recommended setting: 1 if you want to support multiple languages #define wxUSE_PRINTF_POS_PARAMS 1 -// Enable the use of compiler-specific thread local storage keyword, if any. -// This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but is -// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets -// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under -// XP as this triggers a bug in compiler TLS support that results in crashes -// when any TLS variables are used. -// -// If you're absolutely sure that your build of wxWidgets is never going to be -// used in such situation, either because it's not going to be linked from any -// kind of plugin or because you only target Vista or later systems, you can -// set this to 2 to force the use of compiler TLS even under MSW. -// -// Default is 1 meaning that compiler TLS is used only if it's 100% safe. -// -// Recommended setting: 2 if you want to have maximal performance and don't -// care about the scenario described above. -#define wxUSE_COMPILER_TLS 1 - -// ---------------------------------------------------------------------------- -// Interoperability with the standard library. -// ---------------------------------------------------------------------------- - -// Set wxUSE_STL to 1 to enable maximal interoperability with the standard -// library, even at the cost of backwards compatibility. -// -// Default is 0 -// -// Recommended setting: 0 as the options below already provide a relatively -// good level of interoperability and changing this option arguably isn't worth -// diverging from the official builds of the library. -#define wxUSE_STL 0 - -// This is not a real option but is used as the default value for -// wxUSE_STD_IOSTREAM, wxUSE_STD_STRING and wxUSE_STD_CONTAINERS. -// -// Currently the Digital Mars and Watcom compilers come without standard C++ -// library headers by default, wxUSE_STD_STRING can be set to 1 if you do have -// them (e.g. from STLPort). -// -// VC++ 5.0 does include standard C++ library headers, however they produce -// many warnings that can't be turned off when compiled at warning level 4. -#if defined(__DMC__) || defined(__WATCOMC__) \ - || (defined(_MSC_VER) && _MSC_VER < 1200) - #define wxUSE_STD_DEFAULT 0 -#else - #define wxUSE_STD_DEFAULT 1 -#endif - -// Use standard C++ containers to implement wxVector<>, wxStack<>, wxDList<> -// and wxHashXXX<> classes. If disabled, wxWidgets own (mostly compatible but -// usually more limited) implementations are used which allows to avoid the -// dependency on the C++ run-time library. -// -// Notice that the compilers mentioned in wxUSE_STD_DEFAULT comment above don't -// support using standard containers and that VC6 needs non-default options for -// such build to avoid getting "fatal error C1076: compiler limit : internal -// heap limit reached; use /Zm to specify a higher limit" in its own standard -// headers, so you need to ensure you do increase the heap size before enabling -// this option for this compiler. -// -// Default is 0 for compatibility reasons. -// -// Recommended setting: 1 unless compatibility with the official wxWidgets -// build and/or the existing code is a concern. -#define wxUSE_STD_CONTAINERS 0 - -// Use standard C++ streams if 1 instead of wx streams in some places. If -// disabled, wx streams are used everywhere and wxWidgets doesn't depend on the -// standard streams library. -// -// Notice that enabling this does not replace wx streams with std streams -// everywhere, in a lot of places wx streams are used no matter what. -// -// Default is 1 if compiler supports it. -// -// Recommended setting: 1 if you use the standard streams anyhow and so -// dependency on the standard streams library is not a -// problem -#define wxUSE_STD_IOSTREAM wxUSE_STD_DEFAULT - -// Enable minimal interoperability with the standard C++ string class if 1. -// "Minimal" means that wxString can be constructed from std::string or -// std::wstring but can't be implicitly converted to them. You need to enable -// the option below for the latter. -// -// Default is 1 for most compilers. -// -// Recommended setting: 1 unless you want to ensure your program doesn't use -// the standard C++ library at all. -#define wxUSE_STD_STRING wxUSE_STD_DEFAULT - -// Make wxString as much interchangeable with std::[w]string as possible, in -// particular allow implicit conversion of wxString to either of these classes. -// This comes at a price (or a benefit, depending on your point of view) of not -// allowing implicit conversion to "const char *" and "const wchar_t *". -// -// Because a lot of existing code relies on these conversions, this option is -// disabled by default but can be enabled for your build if you don't care -// about compatibility. -// -// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled. -// -// Recommended setting: 0 to remain compatible with the official builds of -// wxWidgets. -#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL - -// VC++ 4.2 and above allows and but you can't mix -// them. Set this option to 1 to use , 0 to use . -// -// Note that newer compilers (including VC++ 7.1 and later) don't support -// wxUSE_IOSTREAMH == 1 and so will be used anyhow. -// -// Default is 0. -// -// Recommended setting: 0, only set to 1 if you use a really old compiler -#define wxUSE_IOSTREAMH 0 - - // ---------------------------------------------------------------------------- // non GUI features selection // ---------------------------------------------------------------------------- @@ -402,24 +320,6 @@ // Recommended setting: 1 #define wxUSE_LONGLONG 1 -// Set wxUSE_BASE64 to 1, to compile in Base64 support. This is required for -// storing binary data in wxConfig on most platforms. -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_BASE64 1 - -// Set this to 1 to be able to use wxEventLoop even in console applications -// (i.e. using base library only, without GUI). This is mostly useful for -// processing socket events but is also necessary to use timers in console -// applications -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_CONSOLE_EVENTLOOP 1 - // Set wxUSE_(F)FILE to 1 to compile wx(F)File classes. wxFile uses low level // POSIX functions for file access, wxFFile uses ANSI C stdio.h functions. // @@ -455,21 +355,6 @@ // i18n support: _() macro, wxLocale class. Requires wxTextFile. #define wxUSE_INTL 1 -// Provide wxFoo_l() functions similar to standard foo() functions but taking -// an extra locale parameter. -// -// Notice that this is fully implemented only for the systems providing POSIX -// xlocale support or Microsoft Visual C++ >= 8 (which provides proprietary -// almost-equivalent of xlocale functions), otherwise wxFoo_l() functions will -// only work for the current user locale and "C" locale. You can use -// wxHAS_XLOCALE_SUPPORT to test whether the full support is available. -// -// Default is 1 -// -// Recommended setting: 1 but may be disabled if you are writing programs -// running only in C locale anyhow -#define wxUSE_XLOCALE 1 - // Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which // allow to manipulate dates, times and time intervals. wxDateTime replaces the // old wxTime and wxDate classes which are still provided for backwards @@ -501,13 +386,6 @@ // Recommended setting: 1 (needed by wxSocket) #define wxUSE_STOPWATCH 1 -// Set wxUSE_FSWATCHER to 1 if you want to enable wxFileSystemWatcher -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_FSWATCHER 1 - // Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes // which allow the application to store its settings in the persistent // storage. Setting this to 1 will also enable on-demand creation of the @@ -556,17 +434,6 @@ // Set to 1 to use socket classes #define wxUSE_SOCKETS 1 -// Set to 1 to use ipv6 socket classes (requires wxUSE_SOCKETS) -// -// Notice that currently setting this option under Windows will result in -// programs which can only run on recent OS versions (with ws2_32.dll -// installed) which is why it is disabled by default. -// -// Default is 1. -// -// Recommended setting: 1 if you need IPv6 support -#define wxUSE_IPV6 0 - // Set to 1 to enable virtual file systems (required by wxHTML) #define wxUSE_FILESYSTEM 1 @@ -604,9 +471,6 @@ // Joystick support class #define wxUSE_JOYSTICK 1 -// wxFontEnumerator class -#define wxUSE_FONTENUM 1 - // wxFontMapper class #define wxUSE_FONTMAP 1 @@ -648,14 +512,6 @@ // possible in which case setting this to 0 can gain up to 100KB. #define wxUSE_VARIANT 1 -// Support for wxAny class, the successor for wxVariant. -// -// Default is 1. -// -// Recommended setting: 1 unless you want to reduce the library size by a small amount, -// or your compiler cannot for some reason cope with complexity of templates used. -#define wxUSE_ANY 1 - // Support for regular expression matching via wxRegEx class: enable this to // use POSIX regular expressions in your code. You need to compile regex // library from src/regex to use it under Windows. @@ -664,7 +520,7 @@ // // Recommended setting: 1 if your compiler supports it, if it doesn't please // contribute us a makefile for src/regex for it -#define wxUSE_REGEX 0//TODO:pj64 +#define wxUSE_REGEX 0 // wxSystemOptions class #define wxUSE_SYSTEM_OPTIONS 1 @@ -677,14 +533,21 @@ // Default is 1. // // Recommended setting: 1 -#define wxUSE_MEDIACTRL 0//TODO:pj64 +#define wxUSE_MEDIACTRL 0 + +// Use GStreamer for Unix (req a lot of dependancies) +// +// Default is 0 +// +// Recommended setting: 1 (wxMediaCtrl won't work by default without it) +#define wxUSE_GSTREAMER 0 // Use wxWidget's XRC XML-based resource system. Recommended. // // Default is 1 // // Recommended setting: 1 (requires wxUSE_XML) -#define wxUSE_XRC 0//TODO:pj64 +#define wxUSE_XRC 0 // XML parsing classes. Note that their API will change in the future, so // using wxXmlDocument and wxXmlNode in your app is not recommended. @@ -699,107 +562,34 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_AUI 0//TODO:pj64 +#define wxUSE_AUI 0 -// Use wxWidget's Ribbon classes for interfaces -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_RIBBON 1 - -// Use wxPropertyGrid. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_PROPGRID 1 - -// Use wxStyledTextCtrl, a wxWidgets implementation of Scintilla. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_STC 1 - -// Use wxWidget's web viewing classes -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_WEBVIEW 0 - -// Use the IE wxWebView backend -// -// Default is 1 on MSW -// -// Recommended setting: 1 -#ifdef __WXMSW__ -#define wxUSE_WEBVIEW_IE 1 -#else -#define wxUSE_WEBVIEW_IE 0 -#endif - -// Use the WebKit wxWebView backend -// -// Default is 1 on GTK and OSX -// -// Recommended setting: 1 -#if defined(__WXGTK__) || defined(__WXOSX__) -#define wxUSE_WEBVIEW_WEBKIT 1 -#else -#define wxUSE_WEBVIEW_WEBKIT 0 -#endif // Enable the new wxGraphicsPath and wxGraphicsContext classes for an advanced // 2D drawing API. (Still somewhat experimental) // -// Please note that on Windows gdiplus.dll is loaded dynamically which means -// that nothing special needs to be done as long as you don't use -// wxGraphicsContext at all or only use it on XP and later systems but you -// still do need to distribute it yourself for an application using -// wxGraphicsContext to be runnable on pre-XP systems. -// -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC7+ is known to ship with gdiplus.h. For other compilers (e.g. -// mingw32) you may need to install the headers (and just the headers) -// yourself. If you do, change the setting below manually. -// -// Recommended setting: 1 if supported by the compilation environment - -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER -# if _MSC_VER >= 1310 - // MSVC7.1+ comes with new enough Platform SDK, enable - // wxGraphicsContext support for it -# define wxUSE_GRAPHICS_CONTEXT 1 -# else - // MSVC 6 didn't include GDI+ headers so disable by default, enable it - // here if you use MSVC 6 with a newer SDK -# define wxUSE_GRAPHICS_CONTEXT 0 -# endif -#else - // Disable support for other Windows compilers, enable it if your compiler - // comes with new enough SDK or you installed the headers manually. - // - // Notice that this will be set by configure under non-Windows platforms - // anyhow so the value there is not important. -# define wxUSE_GRAPHICS_CONTEXT 0 -#endif - -// Enable wxGraphicsContext implementation using Cairo library. -// -// This is not needed under Windows and detected automatically by configure -// under other systems, however you may set this to 1 manually if you installed -// Cairo under Windows yourself and prefer to use it instead the native GDI+ -// implementation. +// Please note that on Windows you will need to link with gdiplus.lib (use +// USE_GDIPLUS=1 for makefile builds) and distribute gdiplus.dll with your +// application if you want it to be runnable on pre-XP systems. // // Default is 0 // -// Recommended setting: 0 -#define wxUSE_CAIRO 0 +// Recommended setting: 1 +#ifndef wxUSE_GRAPHICS_CONTEXT +#define wxUSE_GRAPHICS_CONTEXT 0 +#endif +// Enable the new wxCairoContext classes for an advanced +// 2D drawing API. (Still somewhat experimental) +// +// Please note that you will need to link with Cairo for this to work. +// +// Default is 0 +// +// Recommended setting: 1 +#ifndef wxUSE_CAIRO +#define wxUSE_CAIRO 0 +#endif // ---------------------------------------------------------------------------- // Individual GUI controls @@ -813,15 +603,6 @@ // Recommended setting: 1 (don't change except for very special programs) #define wxUSE_CONTROLS 1 -// Support markup in control labels, i.e. provide wxControl::SetLabelMarkup(). -// Currently markup is supported only by a few controls and only some ports but -// their number will increase with time. -// -// Default is 1 -// -// Recommended setting: 1 (may be set to 0 if you want to save on code size) -#define wxUSE_MARKUP 1 - // wxPopupWindow class is a top level transient window. It is currently used // to implement wxTipWindow // @@ -848,7 +629,6 @@ // // Recommended setting: 1 #define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl -#define wxUSE_BANNERWINDOW 1 // wxBannerWindow #define wxUSE_BUTTON 1 // wxButton #define wxUSE_BMPBUTTON 1 // wxBitmapButton #define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl @@ -858,22 +638,17 @@ #define wxUSE_COLLPANE 1 // wxCollapsiblePane #define wxUSE_COLOURPICKERCTRL 1 // wxColourPickerCtrl #define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_COMMANDLINKBUTTON 1 // wxCommandLinkButton #define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl #define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl #define wxUSE_DIRPICKERCTRL 1 // wxDirPickerCtrl -#define wxUSE_EDITABLELISTBOX 1 // wxEditableListBox -#define wxUSE_FILECTRL 1 // wxFileCtrl #define wxUSE_FILEPICKERCTRL 1 // wxFilePickerCtrl #define wxUSE_FONTPICKERCTRL 1 // wxFontPickerCtrl #define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_HEADERCTRL 1 // wxHeaderCtrl #define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl #define wxUSE_LISTBOX 1 // wxListBox #define wxUSE_LISTCTRL 1 // wxListCtrl #define wxUSE_RADIOBOX 1 // wxRadioBox #define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_RICHMSGDLG 1 // wxRichMessageDialog #define wxUSE_SCROLLBAR 1 // wxScrollBar #define wxUSE_SEARCHCTRL 1 // wxSearchCtrl #define wxUSE_SLIDER 1 // wxSlider @@ -884,10 +659,8 @@ #define wxUSE_STATTEXT 1 // wxStaticText #define wxUSE_STATBMP 1 // wxStaticBitmap #define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TIMEPICKCTRL 1 // wxTimePickerCtrl #define wxUSE_TOGGLEBTN 1 // requires wxButton #define wxUSE_TREECTRL 1 // wxTreeCtrl -#define wxUSE_TREELISTCTRL 1 // wxTreeListCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. @@ -958,13 +731,13 @@ // Recommended setting: 1 #define wxUSE_TOOLBOOK 1 -// wxTaskBarIcon is a small notification icon shown in the system toolbar or -// dock. +// wxTabDialog is a generic version of wxNotebook but it is incompatible with +// the new class. It shouldn't be used in new code. // -// Default is 1. +// Default is 0. // -// Recommended setting: 1 (but can be set to 0 if you don't need it) -#define wxUSE_TASKBARICON 1 +// Recommended setting: 0 (use wxNotebook) +#define wxUSE_TAB_DIALOG 0 // wxGrid class // @@ -1007,15 +780,6 @@ // Recommended setting: 1 but can be safely set to 0 #define wxUSE_BITMAPCOMBOBOX 1 -// wxRearrangeCtrl is a wxCheckListBox with two buttons allowing to move items -// up and down in it. It is also used as part of wxRearrangeDialog. -// -// Default is 1. -// -// Recommended setting: 1 but can be safely set to 0 (currently used only by -// wxHeaderCtrl) -#define wxUSE_REARRANGECTRL 1 - // ---------------------------------------------------------------------------- // Miscellaneous GUI stuff // ---------------------------------------------------------------------------- @@ -1023,29 +787,6 @@ // wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar) #define wxUSE_ACCEL 1 -// Use the standard art provider. The icons returned by this provider are -// embedded into the library as XPMs so disabling it reduces the library size -// somewhat but this should only be done if you use your own custom art -// provider returning the icons or never use any icons not provided by the -// native art provider (which might not be implemented at all for some -// platforms) or by the Tango icons provider (if it's not itself disabled -// below). -// -// Default is 1. -// -// Recommended setting: 1 unless you use your own custom art provider. -#define wxUSE_ARTPROVIDER_STD 1 - -// Use art provider providing Tango icons: this art provider has higher quality -// icons than the default ones using smaller size XPM icons without -// transparency but the embedded PNG icons add to the library size. -// -// Default is 1 under non-GTK ports. Under wxGTK the native art provider using -// the GTK+ stock icons replaces it so it is normally not necessary. -// -// Recommended setting: 1 but can be turned off to reduce the library size. -#define wxUSE_ARTPROVIDER_TANGO 1 - // Hotkey support (currently Windows only) #define wxUSE_HOTKEY 1 @@ -1078,14 +819,6 @@ // enumerated above, then this class is mostly useless too) #define wxUSE_IMAGLIST 1 -// Use wxInfoBar class. -// -// Default is 1. -// -// Recommended setting: 1 (but can be disabled without problems as nothing -// depends on it) -#define wxUSE_INFOBAR 1 - // Use wxMenu, wxMenuBar, wxMenuItem. // // Default is 1. @@ -1093,35 +826,6 @@ // Recommended setting: 1 (can't be disabled under MSW) #define wxUSE_MENUS 1 -// Use wxNotificationMessage. -// -// wxNotificationMessage allows to show non-intrusive messages to the user -// using balloons, banners, popups or whatever is the appropriate method for -// the current platform. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_NOTIFICATION_MESSAGE 1 - -// wxPreferencesEditor provides a common API for different ways of presenting -// the standard "Preferences" or "Properties" dialog under different platforms -// (e.g. some use modal dialogs, some use modeless ones; some apply the changes -// immediately while others require an explicit "Apply" button). -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_PREFERENCES_EDITOR 1 - -// wxRichToolTip is a customizable tooltip class which has more functionality -// than the stock (but native, unlike this class) wxToolTip. -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely set to 0 if you don't need it) -#define wxUSE_RICHTOOLTIP 1 - // Use wxSashWindow class. // // Default is 1. @@ -1146,20 +850,6 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 -// Use reference counted ID management: this means that wxWidgets will track -// the automatically allocated ids (those used when you use wxID_ANY when -// creating a window, menu or toolbar item &c) instead of just supposing that -// the program never runs out of them. This is mostly useful only under wxMSW -// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where -// long-running programs can run into problems with ids reuse without this. On -// the other platforms, where the ids have the full int range, this shouldn't -// be necessary. -#ifdef __WXMSW__ -#define wxUSE_AUTOID_MANAGEMENT 1 -#else -#define wxUSE_AUTOID_MANAGEMENT 0 -#endif - // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- @@ -1250,13 +940,6 @@ // use this function #define wxUSE_ABOUTDLG 1 -// wxFileHistory class -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_FILE_HISTORY 1 - // ---------------------------------------------------------------------------- // Metafiles support // ---------------------------------------------------------------------------- @@ -1313,16 +996,14 @@ // Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL // headers and libraries to be able to compile the library with wxUSE_GLCANVAS -// set to 1 and, under Windows, also to add opengl32.lib and glu32.lib to the -// list of libraries used to link your application (although this is done -// implicitly for Microsoft Visual C++ users). +// set to 1. Note that for some compilers (notably Microsoft Visual C++) you +// will need to manually add opengl32.lib and glu32.lib to the list of +// libraries linked with your program if you use OpenGL. // -// Default is 1 unless the compiler is known to ship without the necessary -// headers (Digital Mars) or the platform doesn't support OpenGL (Windows CE). +// Default is 0. // -// Recommended setting: 1 if you intend to use OpenGL, can be safely set to 0 -// otherwise. -#define wxUSE_GLCANVAS 0//TODO:pj64 +// Recommended setting: 1 if you intend to use OpenGL, 0 otherwise +#define wxUSE_GLCANVAS 0 // wxRichTextCtrl allows editing of styled text. // @@ -1330,7 +1011,7 @@ // // Recommended setting: 1, set to 0 if you want compile a // smaller library. -#define wxUSE_RICHTEXT 0//TODO:pj64 +#define wxUSE_RICHTEXT 0 // ---------------------------------------------------------------------------- // Data transfer @@ -1401,6 +1082,8 @@ // Use wxHTML-based help controller? #define wxUSE_WXHTML_HELP 1 +#define wxUSE_RESOURCES 0 + // 0 for no wxGetResource/wxWriteResource #define wxUSE_CONSTRAINTS 1 // 0 for no window layout constraint system @@ -1410,11 +1093,8 @@ #define wxUSE_MOUSEWHEEL 1 // Include mouse wheel support -// Compile wxUIActionSimulator class? -#define wxUSE_UIACTIONSIMULATOR 1 - // ---------------------------------------------------------------------------- -// wxDC classes for various output formats +// postscript support settings // ---------------------------------------------------------------------------- // Set to 1 for PostScript device context. @@ -1423,19 +1103,50 @@ // Set to 1 to use font metric files in GetTextExtent #define wxUSE_AFM_FOR_POSTSCRIPT 1 -// Set to 1 to compile in support for wxSVGFileDC, a wxDC subclass which allows -// to create files in SVG (Scalable Vector Graphics) format. -#define wxUSE_SVG 1 +// ---------------------------------------------------------------------------- +// database classes +// ---------------------------------------------------------------------------- -// Should wxDC provide SetTransformMatrix() and related methods? +// Define 1 to use ODBC classes +#define wxUSE_ODBC 0 + +// For backward compatibility reasons, this parameter now only controls the +// default scrolling method used by cursors. This default behavior can be +// overriden by setting the second param of wxDB::wxDbGetConnection() or +// wxDb() constructor to indicate whether the connection (and any wxDbTable()s +// that use the connection) should support forward only scrolling of cursors, +// or both forward and backward support for backward scrolling cursors is +// dependent on the data source as well as the ODBC driver being used. +#define wxODBC_FWD_ONLY_CURSORS 1 + +// Default is 0. Set to 1 to use the deprecated classes, enum types, function, +// member variables. With a setting of 1, full backward compatibility with the +// 2.0.x release is possible. It is STRONGLY recommended that this be set to 0, +// as future development will be done only on the non-deprecated +// functions/classes/member variables/etc. +#define wxODBC_BACKWARD_COMPATABILITY 0 + +// ---------------------------------------------------------------------------- +// other compiler (mis)features +// ---------------------------------------------------------------------------- + +// Set this to 0 if your compiler can't cope with omission of prototype +// parameters. // -// Default is 1 but can be set to 0 if this functionality is not used. Notice -// that currently only wxMSW supports this so setting this to 0 doesn't change -// much for non-MSW platforms (although it will still save a few bytes -// probably). +// Default is 1. // -// Recommended setting: 1. -#define wxUSE_DC_TRANSFORM_MATRIX 1 +// Recommended setting: 1 (should never need to set this to 0) +#define REMOVE_UNUSED_ARG 1 + +// VC++ 4.2 and above allows and but you can't mix +// them. Set to 1 for , 0 for . Note that VC++ 7.1 +// and later doesn't support wxUSE_IOSTREAMH == 1 and so will be +// used anyhow. +// +// Default is 1. +// +// Recommended setting: whatever your compiler likes more +#define wxUSE_IOSTREAMH 1 // ---------------------------------------------------------------------------- // image format support @@ -1459,25 +1170,25 @@ #define wxUSE_LIBJPEG 1 // Set to 1 for TIFF format support (requires libtiff) -#define wxUSE_LIBTIFF 0//TODO:pj64 +#define wxUSE_LIBTIFF 0 // Set to 1 for TGA format support (loading only) -#define wxUSE_TGA 0//TODO:pj64 +#define wxUSE_TGA 0 // Set to 1 for GIF format support -#define wxUSE_GIF 0//TODO:pj64 +#define wxUSE_GIF 0 // Set to 1 for PNM format support -#define wxUSE_PNM 0//TODO:pj64 +#define wxUSE_PNM 0 // Set to 1 for PCX format support -#define wxUSE_PCX 0//TODO:pj64 +#define wxUSE_PCX 0 // Set to 1 for IFF format support (Amiga format) #define wxUSE_IFF 0 // Set to 1 for XPM format support -#define wxUSE_XPM 0//TODO:pj64 +#define wxUSE_XPM 0 // Set to 1 for MS Icons and Cursors format support #define wxUSE_ICO_CUR 1 @@ -1503,7 +1214,6 @@ /* --- end common options --- */ -/* --- start MSW options --- */ // ---------------------------------------------------------------------------- // Windows-only settings // ---------------------------------------------------------------------------- @@ -1559,11 +1269,15 @@ // Recommended setting: 1, required by wxMediaCtrl #define wxUSE_ACTIVEX 1 -// wxDC caching implementation +// wxDC cacheing implementation #define wxUSE_DC_CACHEING 1 +// Set this to 1 to enable the use of DIB's for wxBitmap to support +// bitmaps > 16MB on Win95/98/Me. Set to 0 to use DDB's only. +#define wxUSE_DIB_FOR_BITMAP 0 + // Set this to 1 to enable wxDIB class used internally for manipulating -// wxBitmap data. +// wxBitmao data. // // Default is 1, set it to 0 only if you don't use wxImage neither // @@ -1574,13 +1288,6 @@ // (just use Windows printing). #define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1 -// Set this to 1 to compile in wxRegKey class. -// -// Default is 1 -// -// Recommended setting: 1, this is used internally by wx in a few places -#define wxUSE_REGKEY 1 - // Set this to 1 to use RICHEDIT controls for wxTextCtrl with style wxTE_RICH // which allows to put more than ~32Kb of text in it even under Win9x (NT // doesn't have such limitation). @@ -1606,28 +1313,16 @@ // Recommended setting: 1, set to 0 for a small library size reduction #define wxUSE_OWNER_DRAWN 1 -// Set this to 1 to enable MSW-specific wxTaskBarIcon::ShowBalloon() method. It -// is required by native wxNotificationMessage implementation. -// -// Default is 1 but disabled in wx/msw/chkconf.h if SDK is too old to contain -// the necessary declarations. -// -// Recommended setting: 1, set to 0 for a tiny library size reduction -#define wxUSE_TASKBARICON_BALLOONS 1 - // Set to 1 to compile MS Windows XP theme engine support #define wxUSE_UXTHEME 1 +// Set to 1 to auto-adapt to MS Windows XP themes where possible +// (notably, wxNotebook pages) +#define wxUSE_UXTHEME_AUTO 1 + // Set to 1 to use InkEdit control (Tablet PC), if available #define wxUSE_INKEDIT 0 -// Set to 1 to enable .INI files based wxConfig implementation (wxIniConfig) -// -// Default is 0. -// -// Recommended setting: 0, nobody uses .INI files any more -#define wxUSE_INICONF 0 - // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- @@ -1640,14 +1335,6 @@ // Recommended setting: 0, this is mainly used for testing #define wxUSE_DATEPICKCTRL_GENERIC 0 -// Set this to 1 to be able to use wxTimePickerCtrlGeneric in addition to the -// native wxTimePickerCtrl for the platforms that have the latter (MSW). -// -// Default is 0. -// -// Recommended setting: 0, this is mainly used for testing -#define wxUSE_TIMEPICKCTRL_GENERIC 0 - // ---------------------------------------------------------------------------- // Crash debugging helpers // ---------------------------------------------------------------------------- @@ -1659,7 +1346,16 @@ // // Recommended setting: 1, set to 0 if your programs never crash #define wxUSE_CRASHREPORT 1 -/* --- end MSW options --- */ + +// ---------------------------------------------------------------------------- +// obsolete settings +// ---------------------------------------------------------------------------- + +// NB: all settings in this section are obsolete and should not be used/changed +// at all, they will disappear + +// Define 1 to use bitmap messages. +#define wxUSE_BITMAP_MESSAGE 1 #endif // _WX_SETUP_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/setup_inc.h b/Source/3rd Party/wx/include/wx/msw/setup_inc.h deleted file mode 100644 index 6905a7a8e..000000000 --- a/Source/3rd Party/wx/include/wx/msw/setup_inc.h +++ /dev/null @@ -1,164 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/setup_inc.h -// Purpose: MSW-specific setup.h options -// Author: Vadim Zeitlin -// Created: 2007-07-21 (extracted from wx/msw/setup0.h) -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// Windows-only settings -// ---------------------------------------------------------------------------- - -// Set wxUSE_UNICODE_MSLU to 1 if you're compiling wxWidgets in Unicode mode -// and want to run your programs under Windows 9x and not only NT/2000/XP. -// This setting enables use of unicows.dll from MSLU (MS Layer for Unicode, see -// http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx). Note -// that you will have to modify the makefiles to include unicows.lib import -// library as the first library (see installation instructions in install.txt -// to learn how to do it when building the library or samples). -// -// If your compiler doesn't have unicows.lib, you can get a version of it at -// http://libunicows.sourceforge.net -// -// Default is 0 -// -// Recommended setting: 0 (1 if you want to deploy Unicode apps on 9x systems) -#ifndef wxUSE_UNICODE_MSLU - #define wxUSE_UNICODE_MSLU 0 -#endif - -// Set this to 1 if you want to use wxWidgets and MFC in the same program. This -// will override some other settings (see below) -// -// Default is 0. -// -// Recommended setting: 0 unless you really have to use MFC -#define wxUSE_MFC 0 - -// Set this to 1 for generic OLE support: this is required for drag-and-drop, -// clipboard, OLE Automation. Only set it to 0 if your compiler is very old and -// can't compile/doesn't have the OLE headers. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_OLE 1 - -// Set this to 1 to enable wxAutomationObject class. -// -// Default is 1. -// -// Recommended setting: 1 if you need to control other applications via OLE -// Automation, can be safely set to 0 otherwise -#define wxUSE_OLE_AUTOMATION 1 - -// Set this to 1 to enable wxActiveXContainer class allowing to embed OLE -// controls in wx. -// -// Default is 1. -// -// Recommended setting: 1, required by wxMediaCtrl -#define wxUSE_ACTIVEX 1 - -// wxDC caching implementation -#define wxUSE_DC_CACHEING 1 - -// Set this to 1 to enable wxDIB class used internally for manipulating -// wxBitmap data. -// -// Default is 1, set it to 0 only if you don't use wxImage neither -// -// Recommended setting: 1 (without it conversion to/from wxImage won't work) -#define wxUSE_WXDIB 1 - -// Set to 0 to disable PostScript print/preview architecture code under Windows -// (just use Windows printing). -#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1 - -// Set this to 1 to compile in wxRegKey class. -// -// Default is 1 -// -// Recommended setting: 1, this is used internally by wx in a few places -#define wxUSE_REGKEY 1 - -// Set this to 1 to use RICHEDIT controls for wxTextCtrl with style wxTE_RICH -// which allows to put more than ~32Kb of text in it even under Win9x (NT -// doesn't have such limitation). -// -// Default is 1 for compilers which support it -// -// Recommended setting: 1, only set it to 0 if your compiler doesn't have -// or can't compile -#define wxUSE_RICHEDIT 1 - -// Set this to 1 to use extra features of richedit v2 and later controls -// -// Default is 1 for compilers which support it -// -// Recommended setting: 1 -#define wxUSE_RICHEDIT2 1 - -// Set this to 1 to enable support for the owner-drawn menu and listboxes. This -// is required by wxUSE_CHECKLISTBOX. -// -// Default is 1. -// -// Recommended setting: 1, set to 0 for a small library size reduction -#define wxUSE_OWNER_DRAWN 1 - -// Set this to 1 to enable MSW-specific wxTaskBarIcon::ShowBalloon() method. It -// is required by native wxNotificationMessage implementation. -// -// Default is 1 but disabled in wx/msw/chkconf.h if SDK is too old to contain -// the necessary declarations. -// -// Recommended setting: 1, set to 0 for a tiny library size reduction -#define wxUSE_TASKBARICON_BALLOONS 1 - -// Set to 1 to compile MS Windows XP theme engine support -#define wxUSE_UXTHEME 1 - -// Set to 1 to use InkEdit control (Tablet PC), if available -#define wxUSE_INKEDIT 0 - -// Set to 1 to enable .INI files based wxConfig implementation (wxIniConfig) -// -// Default is 0. -// -// Recommended setting: 0, nobody uses .INI files any more -#define wxUSE_INICONF 0 - -// ---------------------------------------------------------------------------- -// Generic versions of native controls -// ---------------------------------------------------------------------------- - -// Set this to 1 to be able to use wxDatePickerCtrlGeneric in addition to the -// native wxDatePickerCtrl -// -// Default is 0. -// -// Recommended setting: 0, this is mainly used for testing -#define wxUSE_DATEPICKCTRL_GENERIC 0 - -// Set this to 1 to be able to use wxTimePickerCtrlGeneric in addition to the -// native wxTimePickerCtrl for the platforms that have the latter (MSW). -// -// Default is 0. -// -// Recommended setting: 0, this is mainly used for testing -#define wxUSE_TIMEPICKCTRL_GENERIC 0 - -// ---------------------------------------------------------------------------- -// Crash debugging helpers -// ---------------------------------------------------------------------------- - -// Set this to 1 to be able to use wxCrashReport::Generate() to create mini -// dumps of your program when it crashes (or at any other moment) -// -// Default is 1 if supported by the compiler (VC++ and recent BC++ only). -// -// Recommended setting: 1, set to 0 if your programs never crash -#define wxUSE_CRASHREPORT 1 diff --git a/Source/3rd Party/wx/include/wx/msw/slider.h b/Source/3rd Party/wx/include/wx/msw/slider95.h similarity index 79% rename from Source/3rd Party/wx/include/wx/msw/slider.h rename to Source/3rd Party/wx/include/wx/msw/slider95.h index a16c5952e..55415c789 100644 --- a/Source/3rd Party/wx/include/wx/msw/slider.h +++ b/Source/3rd Party/wx/include/wx/msw/slider95.h @@ -1,20 +1,21 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/slider.h -// Purpose: wxSlider class implementation using trackbar control +// Name: wx/msw/slider95.h +// Purpose: wxSlider class, using the Win95 (and later) trackbar control // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: slider95.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_SLIDER_H_ -#define _WX_SLIDER_H_ +#ifndef _WX_SLIDER95_H_ +#define _WX_SLIDER95_H_ class WXDLLIMPEXP_FWD_CORE wxSubwindows; // Slider -class WXDLLIMPEXP_CORE wxSlider : public wxSliderBase +class WXDLLEXPORT wxSlider : public wxSliderBase { public: wxSlider() { Init(); } @@ -58,6 +59,7 @@ public: int GetMax() const { return m_rangeMax; } // Win32-specific slider methods + void SetTickFreq(int n, int pos); int GetTickFreq() const { return m_tickFreq; } void SetPageSize(int pageSize); int GetPageSize() const; @@ -81,8 +83,6 @@ public: // we should let background show through the slider (and its labels) virtual bool HasTransparentBackground() { return true; } - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } void Command(wxCommandEvent& event); virtual bool MSWOnScroll(int orientation, WXWORD wParam, @@ -99,17 +99,13 @@ protected: void Init(); // format an integer value as string - static wxString Format(int n) { return wxString::Format(wxT("%d"), n); } + static wxString Format(int n) { return wxString::Format(_T("%d"), n); } // get the boundig box for the slider and possible labels wxRect GetBoundingBox() const; - // Get the height and, if the pointers are non NULL, widths of both labels. - // - // Notice that the return value will be 0 if we don't have wxSL_LABELS - // style but we do fill widthMin and widthMax even if we don't have - // wxSL_MIN_MAX_LABELS style set so the caller should account for it. - int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const; + // get the height and, if the pointer is not NULL, width of our labels + int GetLabelsSize(int *width = NULL) const; // overridden base class virtuals @@ -118,8 +114,11 @@ protected: virtual void DoMoveWindow(int x, int y, int width, int height); virtual wxSize DoGetBestSize() const; + virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + + // the labels windows, if any - wxSubwindows *m_labels; + wxSubwindows *m_labels; int m_rangeMin; int m_rangeMax; @@ -131,11 +130,8 @@ protected: // of dragging the thumb or scrolling the mouse wheel bool m_isDragging; - // Platform-specific implementation of SetTickFreq - virtual void DoSetTickFreq(int freq); - DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider) }; -#endif // _WX_SLIDER_H_ +#endif // _WX_SLIDER95_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/sound.h b/Source/3rd Party/wx/include/wx/msw/sound.h deleted file mode 100644 index 9e7cc4969..000000000 --- a/Source/3rd Party/wx/include/wx/msw/sound.h +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/sound.h -// Purpose: wxSound class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SOUND_H_ -#define _WX_SOUND_H_ - -#if wxUSE_SOUND - -class WXDLLIMPEXP_ADV wxSound : public wxSoundBase -{ -public: - wxSound(); - wxSound(const wxString& fileName, bool isResource = false); - wxSound(size_t size, const void* data); - virtual ~wxSound(); - - // Create from resource or file - bool Create(const wxString& fileName, bool isResource = false); - - // Create from data - bool Create(size_t size, const void* data); - - bool IsOk() const { return m_data != NULL; } - - static void Stop(); - -protected: - void Init() { m_data = NULL; } - bool CheckCreatedOk(); - void Free(); - - virtual bool DoPlay(unsigned flags) const; - -private: - // data of this object - class wxSoundData *m_data; - - wxDECLARE_NO_COPY_CLASS(wxSound); -}; - -#endif // wxUSE_SOUND - -#endif // _WX_SOUND_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/spinbutt.h b/Source/3rd Party/wx/include/wx/msw/spinbutt.h index 0daef50c3..dcfb0a370 100644 --- a/Source/3rd Party/wx/include/wx/msw/spinbutt.h +++ b/Source/3rd Party/wx/include/wx/msw/spinbutt.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/spinbutt.h +// Name: wx/univ/spinbutt.h // Purpose: wxSpinButton class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: spinbutt.h 41316 2006-09-20 14:15:14Z RR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,7 @@ #if wxUSE_SPINBTN -class WXDLLIMPEXP_CORE wxSpinButton : public wxSpinButtonBase +class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase { public: // construction @@ -56,9 +57,6 @@ public: // a wxSpinButton can't do anything useful with focus, only wxSpinCtrl can virtual bool AcceptsFocus() const { return false; } - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: virtual wxSize DoGetBestSize() const; diff --git a/Source/3rd Party/wx/include/wx/msw/spinctrl.h b/Source/3rd Party/wx/include/wx/msw/spinctrl.h index 9623fe486..08b619450 100644 --- a/Source/3rd Party/wx/include/wx/msw/spinctrl.h +++ b/Source/3rd Party/wx/include/wx/msw/spinctrl.h @@ -1,9 +1,10 @@ //////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/spinctrl.h +// Name: msw/spinctrl.h // Purpose: wxSpinCtrl class declaration for Win32 // Author: Vadim Zeitlin // Modified by: // Created: 22.07.99 +// RCS-ID: $Id: spinctrl.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -26,22 +27,20 @@ WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins); // control is clicked. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton +class WXDLLEXPORT wxSpinCtrl : public wxSpinButton { public: - wxSpinCtrl() { Init(); } + wxSpinCtrl() { } wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + long style = wxSP_ARROW_KEYS, int min = 0, int max = 100, int initial = 0, - const wxString& name = wxT("wxSpinCtrl")) + const wxString& name = _T("wxSpinCtrl")) { - Init(); - Create(parent, id, value, pos, size, style, min, max, initial, name); } @@ -50,9 +49,9 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + long style = wxSP_ARROW_KEYS, int min = 0, int max = 100, int initial = 0, - const wxString& name = wxT("wxSpinCtrl")); + const wxString& name = _T("wxSpinCtrl")); // a wxTextCtrl-like method (but we can't have GetValue returning wxString // because the base class already has one returning int!) @@ -61,11 +60,6 @@ public: // another wxTextCtrl-like method void SetSelection(long from, long to); - // wxSpinCtrlBase methods - virtual int GetBase() const; - virtual bool SetBase(int base); - - // implementation only from now on // ------------------------------- @@ -73,7 +67,6 @@ public: virtual void SetValue(int val); virtual int GetValue() const; - virtual void SetRange(int minVal, int maxVal); virtual bool SetFont(const wxFont &font); virtual void SetFocus(); @@ -85,18 +78,6 @@ public: // wxSpinButton doesn't accept focus, but we do virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); } - // we're like wxTextCtrl and not (default) wxButton - virtual wxVisualAttributes GetDefaultAttributes() const - { - return GetClassDefaultAttributes(GetWindowVariant()); - } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) - { - return GetCompositeControlsDefaultAttributes(variant); - } - // for internal use only // get the subclassed window proc of the buddy text @@ -108,23 +89,21 @@ public: // process a WM_COMMAND generated by the buddy text control bool ProcessTextCommand(WXWORD cmd, WXWORD id); - // recognize buddy window as part of this control at wx level - virtual bool ContainsHWND(WXHWND hWnd) const { return hWnd == m_hwndBuddy; } - protected: virtual void DoGetPosition(int *x, int *y) const; virtual void DoMoveWindow(int x, int y, int width, int height); virtual wxSize DoGetBestSize() const; - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; virtual void DoGetSize(int *width, int *height) const; +#if wxABI_VERSION >= 20808 virtual void DoGetClientSize(int *x, int *y) const; +#endif + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - virtual bool MSWOnScroll(int orientation, WXWORD wParam, - WXWORD pos, WXHWND control); + // the handler for wxSpinButton events + void OnSpinChange(wxSpinEvent& event); // handle processing of special keys void OnChar(wxKeyEvent& event); @@ -146,22 +125,14 @@ protected: WXHWND m_hwndBuddy; WXFARPROC m_wndProcBuddy; - // Block text update event after SetValue() - bool m_blockEvent; + // all existing wxSpinCtrls - this allows to find the one corresponding to + // the given buddy window in GetSpinForTextCtrl() + static wxArraySpins ms_allSpins; private: - // Common part of all ctors. - void Init(); - - // Adjust the text control style depending on whether we need to enter only - // digits or may need to enter something else (e.g. "-" sign, "x" - // hexadecimal prefix, ...) in it. - void UpdateBuddyStyle(); - - DECLARE_DYNAMIC_CLASS(wxSpinCtrl) DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxSpinCtrl); + DECLARE_NO_COPY_CLASS(wxSpinCtrl) }; #endif // wxUSE_SPINCTRL diff --git a/Source/3rd Party/wx/include/wx/msw/stackwalk.h b/Source/3rd Party/wx/include/wx/msw/stackwalk.h index 131180501..2aeba90c5 100644 --- a/Source/3rd Party/wx/include/wx/msw/stackwalk.h +++ b/Source/3rd Party/wx/include/wx/msw/stackwalk.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2005-01-08 +// RCS-ID: $Id: stackwalk.h 43346 2006-11-12 14:33:03Z RR $ // Copyright: (c) 2005 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -28,7 +29,7 @@ class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase { private: wxStackFrame *ConstCast() const - { return const_cast(this); } + { return wx_const_cast(wxStackFrame *, this); } size_t DoGetParamCount() const { return m_paramTypes.GetCount(); } @@ -64,7 +65,7 @@ protected: // helper for debug API: it wants to have addresses as DWORDs size_t GetSymAddr() const { - return reinterpret_cast(m_address); + return wx_reinterpret_cast(size_t, m_address); } private: @@ -89,15 +90,13 @@ public: // only wxStackWalker(const char * WXUNUSED(argv0) = NULL) { } - virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH); -#if wxUSE_ON_FATAL_EXCEPTION - virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH); -#endif // wxUSE_ON_FATAL_EXCEPTION + virtual void Walk(size_t skip = 1, size_t maxDepth = 200); + virtual void WalkFromException(); // enumerate stack frames from the given context - void WalkFrom(const _CONTEXT *ctx, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH); - void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH); + void WalkFrom(const _CONTEXT *ctx, size_t skip = 1); + void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1); }; #endif // _WX_MSW_STACKWALK_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/statbmp.h b/Source/3rd Party/wx/include/wx/msw/statbmp.h index 9fb16ad87..99bc98595 100644 --- a/Source/3rd Party/wx/include/wx/msw/statbmp.h +++ b/Source/3rd Party/wx/include/wx/msw/statbmp.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: statbmp.h 51824 2008-02-16 01:59:21Z SN $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,10 +16,10 @@ #include "wx/icon.h" #include "wx/bitmap.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBitmapNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxStaticBitmapNameStr[]; // a control showing an icon or a bitmap -class WXDLLIMPEXP_CORE wxStaticBitmap : public wxStaticBitmapBase +class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase { public: wxStaticBitmap() { Init(); } @@ -53,11 +54,9 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: - virtual wxSize DoGetBestClientSize() const; + virtual wxBorder GetDefaultBorder() const; + virtual wxSize DoGetBestSize() const; // ctor/dtor helpers void Init() { m_isIcon = true; m_image = NULL; m_currentHandle = 0; } @@ -69,13 +68,11 @@ protected: void SetImage(const wxGDIImage* image); void SetImageNoCopy( wxGDIImage* image ); -#ifndef __WXWINCE__ +#if wxABI_VERSION >= 20808 // draw the bitmap ourselves here if the OS can't do it correctly (if it // can we leave it to it) void DoPaintManually(wxPaintEvent& event); -#endif // !__WXWINCE__ - - void WXHandleSize(wxSizeEvent& event); +#endif // we can have either an icon or a bitmap bool m_isIcon; @@ -85,13 +82,8 @@ protected: WXHANDLE m_currentHandle; private: - // Replace the image at the native control level with the given HBITMAP or - // HICON (which can be 0) and destroy the previous image if necessary. - void MSWReplaceImageHandle(WXLPARAM handle); - DECLARE_DYNAMIC_CLASS(wxStaticBitmap) - wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(wxStaticBitmap); + DECLARE_NO_COPY_CLASS(wxStaticBitmap) }; #endif diff --git a/Source/3rd Party/wx/include/wx/msw/statbox.h b/Source/3rd Party/wx/include/wx/msw/statbox.h index adbb9c9ae..99604516d 100644 --- a/Source/3rd Party/wx/include/wx/msw/statbox.h +++ b/Source/3rd Party/wx/include/wx/msw/statbox.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: statbox.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ #define _WX_MSW_STATBOX_H_ // Group box -class WXDLLIMPEXP_CORE wxStaticBox : public wxStaticBoxBase +class WXDLLEXPORT wxStaticBox : public wxStaticBoxBase { public: wxStaticBox() { } @@ -39,12 +40,12 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: virtual wxSize DoGetBestSize() const; + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const; + #ifndef __WXWINCE__ public: virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); diff --git a/Source/3rd Party/wx/include/wx/msw/statbr95.h b/Source/3rd Party/wx/include/wx/msw/statbr95.h new file mode 100644 index 000000000..1e3155ad0 --- /dev/null +++ b/Source/3rd Party/wx/include/wx/msw/statbr95.h @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: msw/statbr95.h +// Purpose: native implementation of wxStatusBar +// Author: Vadim Zeitlin +// Modified by: +// Created: 04.04.98 +// RCS-ID: $Id: statbr95.h 41035 2006-09-06 17:36:22Z PC $ +// Copyright: (c) 1998 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _STATBR95_H +#define _STATBR95_H + +#if wxUSE_NATIVE_STATUSBAR + +class WXDLLEXPORT wxStatusBar95 : public wxStatusBarBase +{ +public: + // ctors and such + wxStatusBar95(); + wxStatusBar95(wxWindow *parent, + wxWindowID id = wxID_ANY, + long style = wxST_SIZEGRIP, + const wxString& name = wxStatusBarNameStr) + { + (void)Create(parent, id, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id = wxID_ANY, + long style = wxST_SIZEGRIP, + const wxString& name = wxStatusBarNameStr); + + virtual ~wxStatusBar95(); + + // a status line can have several (<256) fields numbered from 0 + virtual void SetFieldsCount(int number = 1, const int *widths = NULL); + + // each field of status line has it's own text + virtual void SetStatusText(const wxString& text, int number = 0); + virtual wxString GetStatusText(int number = 0) const; + + // set status line fields' widths + virtual void SetStatusWidths(int n, const int widths_field[]); + + // set status line fields' styles + virtual void SetStatusStyles(int n, const int styles[]); + + // sets the minimal vertical size of the status bar + virtual void SetMinHeight(int height); + + // get the position and size of the field's internal bounding rectangle + virtual bool GetFieldRect(int i, wxRect& rect) const; + + // get the border size + virtual int GetBorderX() const; + virtual int GetBorderY() const; + + virtual WXLRESULT MSWWindowProc(WXUINT nMsg, + WXWPARAM wParam, + WXLPARAM lParam); +protected: + void CopyFieldsWidth(const int widths[]); + void SetFieldsWidth(); + + // override base class virtual + void DoMoveWindow(int x, int y, int width, int height); + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBar95) +}; + +#endif // wxUSE_NATIVE_STATUSBAR + +#endif diff --git a/Source/3rd Party/wx/include/wx/msw/statline.h b/Source/3rd Party/wx/include/wx/msw/statline.h index a08c3b6fb..7b7edf930 100644 --- a/Source/3rd Party/wx/include/wx/msw/statline.h +++ b/Source/3rd Party/wx/include/wx/msw/statline.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/statline.h +// Name: msw/statline.h // Purpose: MSW version of wxStaticLine class // Author: Vadim Zeitlin // Created: 28.06.99 +// Version: $Id: statline.h 43874 2006-12-09 14:52:59Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,7 +15,7 @@ // wxStaticLine // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStaticLine : public wxStaticLineBase +class WXDLLEXPORT wxStaticLine : public wxStaticLineBase { public: // constructors and pseudo-constructors @@ -37,7 +38,7 @@ public: long style = wxLI_HORIZONTAL, const wxString &name = wxStaticLineNameStr ); - // overridden base class virtuals + // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } // usually overridden base class virtuals diff --git a/Source/3rd Party/wx/include/wx/msw/stattext.h b/Source/3rd Party/wx/include/wx/msw/stattext.h index cce64efc9..2338315cb 100644 --- a/Source/3rd Party/wx/include/wx/msw/stattext.h +++ b/Source/3rd Party/wx/include/wx/msw/stattext.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: stattext.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_STATTEXT_H_ #define _WX_STATTEXT_H_ -class WXDLLIMPEXP_CORE wxStaticText : public wxStaticTextBase +class WXDLLEXPORT wxStaticText : public wxStaticTextBase { public: wxStaticText() { } @@ -43,12 +44,10 @@ public: protected: // implement/override some base class virtuals + virtual wxBorder GetDefaultBorder() const; virtual void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO); - virtual wxSize DoGetBestClientSize() const; - - virtual wxString DoGetLabel() const; - virtual void DoSetLabel(const wxString& str); + virtual wxSize DoGetBestSize() const; DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText) }; diff --git a/Source/3rd Party/wx/include/wx/msw/statusbar.h b/Source/3rd Party/wx/include/wx/msw/statusbar.h deleted file mode 100644 index b1d352a7c..000000000 --- a/Source/3rd Party/wx/include/wx/msw/statusbar.h +++ /dev/null @@ -1,111 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/statusbar.h -// Purpose: native implementation of wxStatusBar -// Author: Vadim Zeitlin -// Modified by: -// Created: 04.04.98 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_STATUSBAR_H_ -#define _WX_MSW_STATUSBAR_H_ - -#if wxUSE_NATIVE_STATUSBAR - -#include "wx/vector.h" -#include "wx/tooltip.h" - -class WXDLLIMPEXP_FWD_CORE wxClientDC; - -class WXDLLIMPEXP_CORE wxStatusBar : public wxStatusBarBase -{ -public: - // ctors and such - wxStatusBar(); - wxStatusBar(wxWindow *parent, - wxWindowID id = wxID_ANY, - long style = wxSTB_DEFAULT_STYLE, - const wxString& name = wxStatusBarNameStr) - { - m_pDC = NULL; - (void)Create(parent, id, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - long style = wxSTB_DEFAULT_STYLE, - const wxString& name = wxStatusBarNameStr); - - virtual ~wxStatusBar(); - - // implement base class methods - virtual void SetFieldsCount(int number = 1, const int *widths = NULL); - virtual void SetStatusWidths(int n, const int widths_field[]); - virtual void SetStatusStyles(int n, const int styles[]); - virtual void SetMinHeight(int height); - virtual bool GetFieldRect(int i, wxRect& rect) const; - - virtual int GetBorderX() const; - virtual int GetBorderY() const; - - // override some wxWindow virtual methods too - virtual bool SetFont(const wxFont& font); - - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, - WXWPARAM wParam, - WXLPARAM lParam); - -protected: - // implement base class pure virtual method - virtual void DoUpdateStatusText(int number); - - // override some base class virtuals - virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; - virtual wxSize DoGetBestSize() const; - virtual void DoMoveWindow(int x, int y, int width, int height); -#if wxUSE_TOOLTIPS - virtual bool MSWProcessMessage(WXMSG* pMsg); - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result); -#endif - - // implementation of the public SetStatusWidths() - void MSWUpdateFieldsWidths(); - - // used by DoUpdateStatusText() - wxClientDC *m_pDC; - -#if wxUSE_TOOLTIPS - // the tooltips used when wxSTB_SHOW_TIPS is given - wxVector m_tooltips; -#endif - -private: - struct MSWBorders - { - int horz, - vert, - between; - }; - - // retrieve all status bar borders using SB_GETBORDERS - MSWBorders MSWGetBorders() const; - - // return the size of the border between the fields - int MSWGetBorderWidth() const; - - struct MSWMetrics - { - int gripWidth, - textMargin; - }; - - // return the various status bar metrics - static const MSWMetrics& MSWGetMetrics(); - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBar) -}; - -#endif // wxUSE_NATIVE_STATUSBAR - -#endif // _WX_MSW_STATUSBAR_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/stdpaths.h b/Source/3rd Party/wx/include/wx/msw/stdpaths.h index a153ac7a5..55f8f2d98 100644 --- a/Source/3rd Party/wx/include/wx/msw/stdpaths.h +++ b/Source/3rd Party/wx/include/wx/msw/stdpaths.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2004-10-19 +// RCS-ID: $Id: stdpaths.h 43340 2006-11-12 12:58:10Z RR $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -28,55 +29,12 @@ public: virtual wxString GetPluginsDir() const; virtual wxString GetDocumentsDir() const; - - // MSW-specific methods - - // This class supposes that data, plugins &c files are located under the - // program directory which is the directory containing the application - // binary itself. But sometimes this binary may be in a subdirectory of the - // main program directory, e.g. this happens in at least the following - // common cases: - // 1. The program is in "bin" subdirectory of the installation directory. - // 2. The program is in "debug" subdirectory of the directory containing - // sources and data files during development - // - // By calling this function you instruct the class to remove the last - // component of the path if it matches its argument. Notice that it may be - // called more than once, e.g. you can call both IgnoreAppSubDir("bin") and - // IgnoreAppSubDir("debug") to take care of both production and development - // cases above but that each call will only remove the last path component. - // Finally note that the argument can contain wild cards so you can also - // call IgnoreAppSubDir("vc*msw*") to ignore all build directories at once - // when using wxWidgets-inspired output directories names. - void IgnoreAppSubDir(const wxString& subdirPattern); - - // This function is used to ignore all common build directories and is - // called from the ctor -- use DontIgnoreAppSubDir() to undo this. - void IgnoreAppBuildSubDirs(); - - // Undo the effects of all preceding IgnoreAppSubDir() calls. - void DontIgnoreAppSubDir(); - - - // Returns the directory corresponding to the specified Windows shell CSIDL - static wxString MSWGetShellDir(int csidl); - protected: - // Ctor is protected, use wxStandardPaths::Get() instead of instantiating - // objects of this class directly. - // - // It calls IgnoreAppBuildSubDirs() and also sets up the object to use - // both vendor and application name by default. - wxStandardPaths(); - // get the path corresponding to the given standard CSIDL_XXX constant static wxString DoGetDirectory(int csidl); // return the directory of the application itself - wxString GetAppDir() const; - - // directory returned by GetAppDir() - mutable wxString m_appDir; + static wxString GetAppDir(); }; // ---------------------------------------------------------------------------- diff --git a/Source/3rd Party/wx/include/wx/msw/subwin.h b/Source/3rd Party/wx/include/wx/msw/subwin.h index d1a893e01..75f8dad6d 100644 --- a/Source/3rd Party/wx/include/wx/msw/subwin.h +++ b/Source/3rd Party/wx/include/wx/msw/subwin.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2004-12-11 +// RCS-ID: $Id: subwin.h 30981 2004-12-13 01:02:32Z VZ $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ // wxSubwindows contains all HWNDs making part of a single wx control // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSubwindows +class WXDLLEXPORT wxSubwindows { public: // the number of subwindows can be specified either as parameter to ctor or @@ -27,11 +28,10 @@ public: // allocate enough space for the given number of windows void Create(size_t n) { - wxASSERT_MSG( !m_hwnds, wxT("Create() called twice?") ); + wxASSERT_MSG( !m_hwnds, _T("Create() called twice?") ); m_count = n; m_hwnds = (HWND *)calloc(n, sizeof(HWND)); - m_ids = new wxWindowIDRef[n]; } // non-virtual dtor, this class is not supposed to be used polymorphically @@ -39,12 +39,10 @@ public: { for ( size_t n = 0; n < m_count; n++ ) { - if ( m_hwnds[n] ) - ::DestroyWindow(m_hwnds[n]); + ::DestroyWindow(m_hwnds[n]); } free(m_hwnds); - delete [] m_ids; } // get the number of subwindows @@ -53,24 +51,15 @@ public: // access a given window HWND& Get(size_t n) { - wxASSERT_MSG( n < m_count, wxT("subwindow index out of range") ); + wxASSERT_MSG( n < m_count, _T("subwindow index out of range") ); return m_hwnds[n]; } + HWND& operator[](size_t n) { return Get(n); } HWND operator[](size_t n) const { - return const_cast(this)->Get(n); - } - - // initialize the given window: id will be stored in wxWindowIDRef ensuring - // that it is not reused while this object exists - void Set(size_t n, HWND hwnd, wxWindowID id) - { - wxASSERT_MSG( n < m_count, wxT("subwindow index out of range") ); - - m_hwnds[n] = hwnd; - m_ids[n] = id; + return wx_const_cast(wxSubwindows *, this)->Get(n); } // check if we have this window @@ -95,8 +84,7 @@ public: int sw = show ? SW_SHOW : SW_HIDE; for ( size_t n = 0; n < m_count; n++ ) { - if ( m_hwnds[n] ) - ::ShowWindow(m_hwnds[n], sw); + ::ShowWindow(m_hwnds[n], sw); } } @@ -105,8 +93,7 @@ public: { for ( size_t n = 0; n < m_count; n++ ) { - if ( m_hwnds[n] ) - ::EnableWindow(m_hwnds[n], enable); + ::EnableWindow(m_hwnds[n], enable); } } @@ -114,17 +101,14 @@ public: void SetFont(const wxFont& font) { HFONT hfont = GetHfontOf(font); - wxCHECK_RET( hfont, wxT("invalid font") ); + wxCHECK_RET( hfont, _T("invalid font") ); for ( size_t n = 0; n < m_count; n++ ) { - if ( m_hwnds[n] ) - { - ::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0); + ::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0); - // otherwise the window might not be redrawn correctly - ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); - } + // otherwise the window might not be redrawn correctly + ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); } } @@ -134,14 +118,10 @@ public: wxRect r; for ( size_t n = 0; n < m_count; n++ ) { - if ( m_hwnds[n] ) - { - RECT rc; + RECT rc; + ::GetWindowRect(m_hwnds[n], &rc); - ::GetWindowRect(m_hwnds[n], &rc); - - r.Union(wxRectFromRECT(rc)); - } + r.Union(wxRectFromRECT(rc)); } return r; @@ -160,11 +140,8 @@ private: // the HWNDs we contain HWND *m_hwnds; - // the IDs of the windows - wxWindowIDRef *m_ids; - - wxDECLARE_NO_COPY_CLASS(wxSubwindows); + DECLARE_NO_COPY_CLASS(wxSubwindows) }; // convenient macro to forward a few methods which are usually propagated to diff --git a/Source/3rd Party/wx/include/wx/msw/taskbar.h b/Source/3rd Party/wx/include/wx/msw/taskbar.h deleted file mode 100644 index c9a4a11ca..000000000 --- a/Source/3rd Party/wx/include/wx/msw/taskbar.h +++ /dev/null @@ -1,70 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// File: wx/msw/taskbar.h -// Purpose: Defines wxTaskBarIcon class for manipulating icons on the -// Windows task bar. -// Author: Julian Smart -// Modified by: Vaclav Slavik -// Created: 24/3/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TASKBAR_H_ -#define _WX_TASKBAR_H_ - -#include "wx/icon.h" - -// private helper class: -class WXDLLIMPEXP_FWD_ADV wxTaskBarIconWindow; - -class WXDLLIMPEXP_ADV wxTaskBarIcon : public wxTaskBarIconBase -{ -public: - wxTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE); - virtual ~wxTaskBarIcon(); - - // Accessors - bool IsOk() const { return true; } - bool IsIconInstalled() const { return m_iconAdded; } - - // Operations - bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString); - bool RemoveIcon(void); - bool PopupMenu(wxMenu *menu); - - // MSW-specific class methods - -#if wxUSE_TASKBARICON_BALLOONS - // show a balloon notification (the icon must have been already initialized - // using SetIcon) - // - // title and text are limited to 63 and 255 characters respectively, msec - // is the timeout, in milliseconds, before the balloon disappears (will be - // clamped down to the allowed 10-30s range by Windows if it's outside it) - // and flags can include wxICON_ERROR/INFO/WARNING to show a corresponding - // icon - // - // return true if balloon was shown, false on error (incorrect parameters - // or function unsupported by OS) - bool ShowBalloon(const wxString& title, - const wxString& text, - unsigned msec = 0, - int flags = 0); -#endif // wxUSE_TASKBARICON_BALLOONS - -protected: - friend class wxTaskBarIconWindow; - - long WindowProc(unsigned int msg, unsigned int wParam, long lParam); - void RegisterWindowMessages(); - - - wxTaskBarIconWindow *m_win; - bool m_iconAdded; - wxIcon m_icon; - wxString m_strTooltip; - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxTaskBarIcon) -}; - -#endif // _WX_TASKBAR_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/toolbar.h b/Source/3rd Party/wx/include/wx/msw/tbar95.h similarity index 70% rename from Source/3rd Party/wx/include/wx/msw/toolbar.h rename to Source/3rd Party/wx/include/wx/msw/tbar95.h index 0c6b7e9c9..4b1d4b66d 100644 --- a/Source/3rd Party/wx/include/wx/msw/toolbar.h +++ b/Source/3rd Party/wx/include/wx/msw/tbar95.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/toolbar.h +// Name: wx/msw/tbar95.h // Purpose: wxToolBar (Windows 95 toolbar) class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: tbar95.h 58446 2009-01-26 23:32:16Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,7 @@ #include "wx/dynarray.h" #include "wx/imaglist.h" -class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase +class WXDLLEXPORT wxToolBar : public wxToolBarBase { public: // ctors and dtor @@ -26,7 +27,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxTB_HORIZONTAL, + long style = wxNO_BORDER | wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr) { Init(); @@ -38,7 +39,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxTB_HORIZONTAL, + long style = wxNO_BORDER | wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr); virtual ~wxToolBar(); @@ -53,9 +54,12 @@ public: virtual void SetRows(int nRows); - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap); - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); - +#if wxABI_VERSION >= 20802 + // TODO: In 2.9 these should probably be virtual, and declared in the base class... + void SetToolNormalBitmap(int id, const wxBitmap& bitmap); + void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); +#endif + // implementation only from now on // ------------------------------- @@ -77,25 +81,6 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - -#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK - virtual bool MSWEraseBgHook(WXHDC hDC); - virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child); -#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK - - virtual wxToolBarToolBase *CreateTool(int id, - const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, - wxItemKind kind = wxITEM_NORMAL, - wxObject *clientData = NULL, - const wxString& shortHelp = wxEmptyString, - const wxString& longHelp = wxEmptyString); - - virtual wxToolBarToolBase *CreateTool(wxControl *control, - const wxString& label); protected: // common part of all ctors void Init(); @@ -114,14 +99,22 @@ protected: virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); + virtual wxToolBarToolBase *CreateTool(int id, + const wxString& label, + const wxBitmap& bmpNormal, + const wxBitmap& bmpDisabled, + wxItemKind kind, + wxObject *clientData, + const wxString& shortHelp, + const wxString& longHelp); + virtual wxToolBarToolBase *CreateTool(wxControl *control); + // return the appropriate size and flags for the toolbar control virtual wxSize DoGetBestSize() const; // handlers for various events bool HandleSize(WXWPARAM wParam, WXLPARAM lParam); -#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam); -#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam); // should be called whenever the toolbar size changes @@ -145,10 +138,6 @@ protected: // the total number of toolbar elements size_t m_nButtons; - // the sum of the sizes of the fixed items (i.e. excluding stretchable - // spaces) in the toolbar direction - int m_totalFixedSize; - // the tool the cursor is in wxToolBarToolBase *m_pInTool; @@ -156,23 +145,9 @@ private: // makes sure tool bitmap size is sufficient for all tools void AdjustToolBitmapSize(); - // update the sizes of stretchable spacers to consume all extra space we - // have - void UpdateStretchableSpacersSize(); - -#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK - // do erase the toolbar background, always do it for the entire control as - // the caller sets the clipping region correctly to exclude parts which - // should not be erased - void MSWDoEraseBackground(WXHDC hDC); - - // return the brush to use for erasing the toolbar background - WXHBRUSH MSWGetToolbarBgBrush(); -#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK - DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxToolBar) - wxDECLARE_NO_COPY_CLASS(wxToolBar); + DECLARE_NO_COPY_CLASS(wxToolBar) }; #endif // wxUSE_TOOLBAR diff --git a/Source/3rd Party/wx/include/wx/msw/textctrl.h b/Source/3rd Party/wx/include/wx/msw/textctrl.h index 42c3cc6d7..5790a7c93 100644 --- a/Source/3rd Party/wx/include/wx/msw/textctrl.h +++ b/Source/3rd Party/wx/include/wx/msw/textctrl.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: textctrl.h 52547 2008-03-15 12:33:04Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,7 +12,7 @@ #ifndef _WX_TEXTCTRL_H_ #define _WX_TEXTCTRL_H_ -class WXDLLIMPEXP_CORE wxTextCtrl : public wxTextCtrlBase +class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase { public: // creation @@ -40,40 +41,45 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); - // overridden wxTextEntry methods - // ------------------------------ + // implement base class pure virtuals + // ---------------------------------- virtual wxString GetValue() const; - virtual wxString GetRange(long from, long to) const; - virtual bool IsEmpty() const; - virtual void WriteText(const wxString& text); - virtual void AppendText(const wxString& text); - virtual void Clear(); + virtual wxString GetRange(long from, long to) const; virtual int GetLineLength(long lineNo) const; virtual wxString GetLineText(long lineNo) const; virtual int GetNumberOfLines() const; - virtual void SetMaxLength(unsigned long len); - - virtual void GetSelection(long *from, long *to) const; - - virtual void Redo(); - virtual bool CanRedo() const; - - virtual void SetInsertionPointEnd(); - virtual long GetInsertionPoint() const; - virtual wxTextPos GetLastPosition() const; - - // implement base class pure virtuals - // ---------------------------------- - virtual bool IsModified() const; + virtual bool IsEditable() const; + + virtual void GetSelection(long* from, long* to) const; + + // operations + // ---------- + + // editing + virtual void Clear(); + virtual void Replace(long from, long to, const wxString& value); + virtual void Remove(long from, long to); + + // load the control's contents from the file + virtual bool DoLoadFile(const wxString& file, int fileType); + + // clears the dirty flag virtual void MarkDirty(); virtual void DiscardEdits(); + virtual void SetMaxLength(unsigned long len); + + // writing text inserts it at the current position, appending always + // inserts it at the end + virtual void WriteText(const wxString& text); + virtual void AppendText(const wxString& text); + #ifdef __WIN32__ virtual bool EmulateKeyPress(const wxKeyEvent& event); #endif // __WIN32__ @@ -101,17 +107,39 @@ public: return wxTextCtrlBase::HitTest(pt, col, row); } + // Clipboard operations + virtual void Copy(); + virtual void Cut(); + virtual void Paste(); + + virtual bool CanCopy() const; + virtual bool CanCut() const; + virtual bool CanPaste() const; + + // Undo/redo + virtual void Undo(); + virtual void Redo(); + + virtual bool CanUndo() const; + virtual bool CanRedo() const; + + // Insertion point + virtual void SetInsertionPoint(long pos); + virtual void SetInsertionPointEnd(); + virtual long GetInsertionPoint() const; + virtual wxTextPos GetLastPosition() const; + + virtual void SetSelection(long from, long to); + virtual void SetEditable(bool editable); + // Caret handling (Windows only) + bool ShowNativeCaret(bool show = true); bool HideNativeCaret() { return ShowNativeCaret(false); } // Implementation from now on // -------------------------- -#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT - virtual void SetDropTarget(wxDropTarget *dropTarget); -#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT - virtual void SetWindowStyleFlag(long style); virtual void Command(wxCommandEvent& event); @@ -124,11 +152,10 @@ public: int GetRichVersion() const { return m_verRichEdit; } bool IsRich() const { return m_verRichEdit != 0; } - // rich edit controls are not compatible with normal ones and we must set - // the colours and font for them otherwise + // rich edit controls are not compatible with normal ones and wem ust set + // the colours for them otherwise virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); - virtual bool SetFont(const wxFont& font); #else bool IsRich() const { return false; } #endif // wxUSE_RICHEDIT @@ -141,10 +168,7 @@ public: virtual void AdoptAttributesFromHWND(); - virtual bool AcceptsFocusFromKeyboard() const; - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const; + virtual bool AcceptsFocus() const; // callbacks void OnDropFiles(wxDropFilesEvent& event); @@ -170,13 +194,6 @@ public: // EDIT control has one already) void OnContextMenu(wxContextMenuEvent& event); -#if wxABI_VERSION >= 30002 - // Create context menu for RICHEDIT controls. This may be called once during - // the control's lifetime or every time the menu is shown, depending on - // implementation. - wxMenu *MSWCreateContextMenu(); -#endif - // be sure the caret remains invisible if the user // called HideNativeCaret() before void OnSetFocus(wxFocusEvent& event); @@ -186,13 +203,12 @@ public: virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg); virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + virtual wxVisualAttributes GetDefaultAttributes() const; protected: // common part of all ctors void Init(); - virtual bool DoLoadFile(const wxString& file, int fileType); - // creates the control of appropriate class (plain or rich edit) with the // styles corresponding to m_windowStyle // @@ -204,17 +220,15 @@ protected: virtual void DoSetValue(const wxString &value, int flags = 0); - virtual wxPoint DoPositionToCoords(long pos) const; - // return true if this control has a user-set limit on amount of text (i.e. // the limit is due to a previous call to SetMaxLength() and not built in) bool HasSpaceLimit(unsigned int *len) const; - // Used by EN_MAXTEXT handler to increase the size limit (will do nothing - // if the current limit is big enough). Should never be called directly. + // call this to increase the size limit (will do nothing if the current + // limit is big enough) // - // Returns true if we increased the limit to allow entering more text, - // false if we hit the limit set by SetMaxLength() and so didn't change it. + // returns true if we increased the limit to allow entering more text, + // false if we hit the limit set by SetMaxLength() and so didn't change it bool AdjustSpaceLimit(); #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU) @@ -231,8 +245,11 @@ protected: void DoWriteText(const wxString& text, int flags = SetValue_SendEvent | SetValue_SelectionOnly); - // set the selection (possibly without scrolling the caret into view) - void DoSetSelection(long from, long to, int flags); + // set the selection possibly without scrolling the caret into view + void DoSetSelection(long from, long to, bool scrollCaret = true); + + // return true if there is a non empty selection in the control + bool HasSelection() const; // get the length of the line containing the character at the given // position @@ -242,26 +259,11 @@ protected: bool SendUpdateEvent(); virtual wxSize DoGetBestSize() const; - virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; #if wxUSE_RICHEDIT - // Apply the character-related parts of wxTextAttr to the given selection - // or the entire control if start == end == -1. - // - // This function is private and should only be called for rich edit - // controls and with (from, to) already in correct order, i.e. from <= to. - bool MSWSetCharFormat(const wxTextAttr& attr, long from = -1, long to = -1); - - // Same as above for paragraph-related parts of wxTextAttr. Note that this - // can only be applied to the selection as RichEdit doesn't support setting - // the paragraph styles globally. - bool MSWSetParaFormat(const wxTextAttr& attr, long from, long to); - - // we're using RICHEDIT (and not simple EDIT) control if this field is not - // 0, it also gives the version of the RICHEDIT control being used - // (although not directly: 1 is for 1.0, 2 is for either 2.0 or 3.0 as we - // can't nor really need to distinguish between them and 4 is for 4.1) + // 0, it also gives the version of the RICHEDIT control being used (1, 2 or + // 3 so far) int m_verRichEdit; #endif // wxUSE_RICHEDIT @@ -270,15 +272,6 @@ protected: int m_updatesCount; private: - virtual void EnableTextChangedEvents(bool enable) - { - m_updatesCount = enable ? -1 : -2; - } - - // implement wxTextEntry pure virtual: it implements all the operations for - // the simple EDIT controls - virtual WXHWND GetEditHWND() const { return m_hWnd; } - void OnKeyDown(wxKeyEvent& event); DECLARE_EVENT_TABLE() @@ -294,4 +287,5 @@ private: }; -#endif // _WX_TEXTCTRL_H_ +#endif + // _WX_TEXTCTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/textentry.h b/Source/3rd Party/wx/include/wx/msw/textentry.h deleted file mode 100644 index 80b9e2396..000000000 --- a/Source/3rd Party/wx/include/wx/msw/textentry.h +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/textentry.h -// Purpose: wxMSW-specific wxTextEntry implementation -// Author: Vadim Zeitlin -// Created: 2007-09-26 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_TEXTENTRY_H_ -#define _WX_MSW_TEXTENTRY_H_ - -class wxTextAutoCompleteData; // private class used only by wxTextEntry itself - -// ---------------------------------------------------------------------------- -// wxTextEntry: common part of wxComboBox and (single line) wxTextCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase -{ -public: - wxTextEntry(); - virtual ~wxTextEntry(); - - // implement wxTextEntryBase pure virtual methods - virtual void WriteText(const wxString& text); - virtual void Remove(long from, long to); - - virtual void Copy(); - virtual void Cut(); - virtual void Paste(); - - virtual void Undo(); - virtual void Redo(); - virtual bool CanUndo() const; - virtual bool CanRedo() const; - - virtual void SetInsertionPoint(long pos); - virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; - - virtual void SetSelection(long from, long to) - { DoSetSelection(from, to); } - virtual void GetSelection(long *from, long *to) const; - - virtual bool IsEditable() const; - virtual void SetEditable(bool editable); - - virtual void SetMaxLength(unsigned long len); - -#if wxUSE_UXTHEME - virtual bool SetHint(const wxString& hint); - virtual wxString GetHint() const; -#endif // wxUSE_UXTHEME - -protected: - virtual wxString DoGetValue() const; - - // this is really a hook for multiline text controls as the single line - // ones don't need to ever scroll to show the selection but having it here - // allows us to put Remove() in the base class - enum - { - SetSel_NoScroll = 0, // don't do anything special - SetSel_Scroll = 1 // default: scroll to make the selection visible - }; - virtual void DoSetSelection(long from, long to, int flags = SetSel_Scroll); - - // margins functions - virtual bool DoSetMargins(const wxPoint& pt); - virtual wxPoint DoGetMargins() const; - - // auto-completion uses COM under Windows so they won't work without - // wxUSE_OLE as OleInitialize() is not called then -#if wxUSE_OLE - virtual bool DoAutoCompleteStrings(const wxArrayString& choices); -#if wxUSE_DYNLIB_CLASS - virtual bool DoAutoCompleteFileNames(int flags); -#endif // wxUSE_DYNLIB_CLASS - virtual bool DoAutoCompleteCustom(wxTextCompleter *completer); -#endif // wxUSE_OLE - -private: - // implement this to return the HWND of the EDIT control - virtual WXHWND GetEditHWND() const = 0; - -#if wxUSE_OLE - // Get the auto-complete object creating it if necessary. Returns NULL if - // creating it failed. - wxTextAutoCompleteData *GetOrCreateCompleter(); - - // Various auto-completion-related stuff, only used if any of AutoComplete() - // methods are called. Use the function above to access it. - wxTextAutoCompleteData *m_autoCompleteData; - - // It needs to call our GetEditableWindow() and GetEditHWND() methods. - friend class wxTextAutoCompleteData; -#endif // wxUSE_OLE -}; - -#endif // _WX_MSW_TEXTENTRY_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/tglbtn.h b/Source/3rd Party/wx/include/wx/msw/tglbtn.h index 1b0e9c32d..ae45202c2 100644 --- a/Source/3rd Party/wx/include/wx/msw/tglbtn.h +++ b/Source/3rd Party/wx/include/wx/msw/tglbtn.h @@ -5,20 +5,21 @@ // Author: John Norris, minor changes by Axel Schlueter // Modified by: // Created: 08.02.01 +// RCS-ID: $Id: tglbtn.h 37393 2006-02-08 21:47:09Z VZ $ // Copyright: (c) 2000 Johnny C. Norris II -// Licence: wxWindows licence +// License: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TOGGLEBUTTON_H_ #define _WX_TOGGLEBUTTON_H_ -#include "wx/bitmap.h" +extern WXDLLEXPORT_DATA(const wxChar) wxCheckBoxNameStr[]; // Checkbox item (single checkbox) -class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase +class WXDLLEXPORT wxToggleButton : public wxControl { public: - wxToggleButton() { Init(); } + wxToggleButton() {} wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label, @@ -45,66 +46,15 @@ public: virtual bool MSWCommand(WXUINT param, WXWORD id); virtual void Command(wxCommandEvent& event); - - virtual State GetNormalState() const; - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - -protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; - void Init(); - - // current state of the button (when owner-drawn) - bool m_state; +protected: + virtual wxSize DoGetBestSize() const; + virtual wxBorder GetDefaultBorder() const; private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton) }; -//----------------------------------------------------------------------------- -// wxBitmapToggleButton -//----------------------------------------------------------------------------- - - -class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButton -{ -public: - // construction/destruction - wxBitmapToggleButton() {} - wxBitmapToggleButton(wxWindow *parent, - wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - - // Create the control - bool Create(wxWindow *parent, - wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr); - - // deprecated synonym for SetBitmapLabel() - wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap), - SetBitmapLabel(bitmap); ) - // prevent virtual function hiding - virtual void SetLabel(const wxString& label) { wxToggleButton::SetLabel(label); } - -private: - DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton) -}; - #endif // _WX_TOGGLEBUTTON_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/timectrl.h b/Source/3rd Party/wx/include/wx/msw/timectrl.h deleted file mode 100644 index c5bc83aec..000000000 --- a/Source/3rd Party/wx/include/wx/msw/timectrl.h +++ /dev/null @@ -1,62 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/timectrl.h -// Purpose: wxTimePickerCtrl for Windows. -// Author: Vadim Zeitlin -// Created: 2011-09-22 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_TIMECTRL_H_ -#define _WX_MSW_TIMECTRL_H_ - -// ---------------------------------------------------------------------------- -// wxTimePickerCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxTimePickerCtrl : public wxTimePickerCtrlBase -{ -public: - // ctors - wxTimePickerCtrl() { } - - wxTimePickerCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr) - { - Create(parent, id, dt, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr) - { - return MSWCreateDateTimePicker(parent, id, dt, - pos, size, style, - validator, name); - } - - // Override MSW-specific functions used during control creation. - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - -protected: -#if wxUSE_INTL - virtual wxLocaleInfo MSWGetFormat() const; -#endif // wxUSE_INTL - virtual bool MSWAllowsNone() const { return false; } - virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch); - - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTimePickerCtrl); -}; - -#endif // _WX_MSW_TIMECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/timer.h b/Source/3rd Party/wx/include/wx/msw/timer.h new file mode 100644 index 000000000..449543300 --- /dev/null +++ b/Source/3rd Party/wx/include/wx/msw/timer.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: timer.h +// Purpose: wxTimer class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id: timer.h 41020 2006-09-05 20:47:48Z VZ $ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TIMER_H_ +#define _WX_TIMER_H_ + +class WXDLLEXPORT wxTimer : public wxTimerBase +{ +friend void wxProcessTimer(wxTimer& timer); + +public: + wxTimer() { Init(); } + wxTimer(wxEvtHandler *owner, int id = wxID_ANY) : wxTimerBase(owner, id) + { Init(); } + virtual ~wxTimer(); + + virtual bool Start(int milliseconds = -1, bool oneShot = false); + virtual void Stop(); + + virtual bool IsRunning() const { return m_id != 0; } + +protected: + void Init(); + + unsigned long m_id; + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxTimer) +}; + +#endif + // _WX_TIMERH_ diff --git a/Source/3rd Party/wx/include/wx/msw/tls.h b/Source/3rd Party/wx/include/wx/msw/tls.h deleted file mode 100644 index 9d46cadf3..000000000 --- a/Source/3rd Party/wx/include/wx/msw/tls.h +++ /dev/null @@ -1,116 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/tls.h -// Purpose: Win32 implementation of wxTlsValue<> -// Author: Vadim Zeitlin -// Created: 2008-08-08 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_TLS_H_ -#define _WX_MSW_TLS_H_ - -#include "wx/msw/wrapwin.h" -#include "wx/thread.h" -#include "wx/vector.h" - -// ---------------------------------------------------------------------------- -// wxTlsKey is a helper class encapsulating a TLS slot -// ---------------------------------------------------------------------------- - -class wxTlsKey -{ -public: - // ctor allocates a new key - wxTlsKey(wxTlsDestructorFunction destructor) - { - m_destructor = destructor; - m_slot = ::TlsAlloc(); - } - - // return true if the key was successfully allocated - bool IsOk() const { return m_slot != TLS_OUT_OF_INDEXES; } - - // get the key value, there is no error return - void *Get() const - { - return ::TlsGetValue(m_slot); - } - - // change the key value, return true if ok - bool Set(void *value) - { - void *old = Get(); - - if ( ::TlsSetValue(m_slot, value) == 0 ) - return false; - - if ( old ) - m_destructor(old); - - // update m_allValues list of all values - remove old, add new - wxCriticalSectionLocker lock(m_csAllValues); - if ( old ) - { - for ( wxVector::iterator i = m_allValues.begin(); - i != m_allValues.end(); - ++i ) - { - if ( *i == old ) - { - if ( value ) - *i = value; - else - m_allValues.erase(i); - return true; - } - } - wxFAIL_MSG( "previous wxTlsKey value not recorded in m_allValues" ); - } - - if ( value ) - m_allValues.push_back(value); - - return true; - } - - // free the key - ~wxTlsKey() - { - if ( !IsOk() ) - return; - - // Win32 API doesn't have the equivalent of pthread's destructor, so we - // have to keep track of all allocated values and destroy them manually; - // ideally we'd do that at thread exit time, but since we could only - // do that with wxThread and not otherwise created threads, we do it - // here. - // - // TODO: We should still call destructors for wxTlsKey used in the - // thread from wxThread's thread shutdown code, *in addition* - // to doing it in ~wxTlsKey. - // - // NB: No need to lock m_csAllValues, by the time this code is called, - // no other thread can be using this key. - for ( wxVector::iterator i = m_allValues.begin(); - i != m_allValues.end(); - ++i ) - { - m_destructor(*i); - } - - ::TlsFree(m_slot); - } - -private: - wxTlsDestructorFunction m_destructor; - DWORD m_slot; - - wxVector m_allValues; - wxCriticalSection m_csAllValues; - - wxDECLARE_NO_COPY_CLASS(wxTlsKey); -}; - -#endif // _WX_MSW_TLS_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/tooltip.h b/Source/3rd Party/wx/include/wx/msw/tooltip.h index 7f10c7fa1..3e623a39a 100644 --- a/Source/3rd Party/wx/include/wx/msw/tooltip.h +++ b/Source/3rd Party/wx/include/wx/msw/tooltip.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 31.01.99 +// RCS-ID: $Id: tooltip.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -12,23 +13,16 @@ #define _WX_MSW_TOOLTIP_H_ #include "wx/object.h" -#include "wx/gdicmn.h" class WXDLLIMPEXP_FWD_CORE wxWindow; -class wxToolTipOtherWindows; -class WXDLLIMPEXP_CORE wxToolTip : public wxObject +class WXDLLEXPORT wxToolTip : public wxObject { public: // ctor & dtor wxToolTip(const wxString &tip); virtual ~wxToolTip(); - // ctor used by wxStatusBar to associate a tooltip to a portion of - // the status bar window: - wxToolTip(wxWindow* win, unsigned int id, - const wxString &tip, const wxRect& rc); - // accessors // tip text void SetTip(const wxString& tip); @@ -43,44 +37,20 @@ public: static void Enable(bool flag); // set the delay after which the tooltip appears static void SetDelay(long milliseconds); - // set the delay after which the tooltip disappears or how long the - // tooltip remains visible - static void SetAutoPop(long milliseconds); - // set the delay between subsequent tooltips to appear - static void SetReshow(long milliseconds); - // set maximum width for the new tooltips: -1 disables wrapping - // entirely, 0 restores the default behaviour - static void SetMaxWidth(int width); // implementation only from now on // ------------------------------- - // should be called in response to WM_MOUSEMOVE + // should be called in responde to WM_MOUSEMOVE static void RelayEvent(WXMSG *msg); // add a window to the tooltip control - void AddOtherWindow(WXHWND hwnd); + void Add(WXHWND hwnd); // remove any tooltip from the window - static void Remove(WXHWND hwnd, unsigned int id, const wxRect& rc); - - // Set the rectangle we're associated with. This rectangle is only used for - // the main window, not any sub-windows added with Add() so in general it - // makes sense to use it for tooltips associated with a single window only. - void SetRect(const wxRect& rc); + static void Remove(WXHWND hwnd); private: - // Adds a window other than our main m_window to this tooltip. - void DoAddHWND(WXHWND hWnd); - - // Perform the specified operation for the given window only. - void DoSetTip(WXHWND hWnd); - void DoRemove(WXHWND hWnd); - - // Call the given function for all windows we're associated with. - void DoForAllWindows(void (wxToolTip::*func)(WXHWND)); - - // the one and only one tooltip control we use - never access it directly // but use GetToolTipCtrl() which will create it when needed static WXHWND ms_hwndTT; @@ -88,24 +58,14 @@ private: // create the tooltip ctrl if it doesn't exist yet and return its HWND static WXHWND GetToolTipCtrl(); - // new tooltip maximum width, defaults to min(display width, 400) - static int ms_maxWidth; - // remove this tooltip from the tooltip control void Remove(); - // adjust tooltip max width based on current tooltip text - bool AdjustMaxWidth(); - wxString m_text; // tooltip text - wxWindow* m_window; // main window we're associated with - wxToolTipOtherWindows *m_others; // other windows associated with it or NULL - wxRect m_rect; // the rect of the window for which this tooltip is shown - // (or a rect with width/height == 0 to show it for the entire window) - unsigned int m_id; // the id of this tooltip (ignored when m_rect width/height is 0) + wxWindow *m_window; // window we're associated with DECLARE_ABSTRACT_CLASS(wxToolTip) - wxDECLARE_NO_COPY_CLASS(wxToolTip); + DECLARE_NO_COPY_CLASS(wxToolTip) }; #endif // _WX_MSW_TOOLTIP_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/toplevel.h b/Source/3rd Party/wx/include/wx/msw/toplevel.h index e598c2960..30ddeeda9 100644 --- a/Source/3rd Party/wx/include/wx/msw/toplevel.h +++ b/Source/3rd Party/wx/include/wx/msw/toplevel.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.09.01 +// RCS-ID: $Id: toplevel.h 50999 2008-01-03 01:13:44Z VZ $ // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxTopLevelWindowMSW // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTopLevelWindowMSW : public wxTopLevelWindowBase +class WXDLLEXPORT wxTopLevelWindowMSW : public wxTopLevelWindowBase { public: // constructors and such @@ -51,17 +52,19 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; + virtual void SetIcon(const wxIcon& icon); virtual void SetIcons(const wxIconBundle& icons ); virtual void Restore(); - + virtual void SetLayoutDirection(wxLayoutDirection dir); +#ifndef __WXWINCE__ + virtual bool SetShape(const wxRegion& region); +#endif // __WXWINCE__ virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO); virtual bool Show(bool show = true); - virtual void Raise(); - virtual void ShowWithoutActivating(); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool IsFullScreen() const { return m_fsIsShowing; } @@ -73,20 +76,7 @@ public: virtual bool SetTransparent(wxByte alpha); virtual bool CanSetTransparent(); - - // MSW-specific methods - // -------------------- - - // Return the menu representing the "system" menu of the window. You can - // call wxMenu::AppendWhatever() methods on it but removing items from it - // is in general not a good idea. - // - // The pointer returned by this method belongs to the window and will be - // deleted when the window itself is, do not delete it yourself. May return - // NULL if getting the system menu failed. - wxMenu *MSWGetSystemMenu() const; - - + // implementation from now on // -------------------------- @@ -118,25 +108,6 @@ public: // window proc for the frames WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - -#if wxUSE_MENUS - bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu); - - // handle WM_EXITMENULOOP message for Win95 only - bool HandleExitMenuLoop(WXWORD isPopup); - - // handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE - bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu); - - // Command part of HandleMenuPopup() and HandleExitMenuLoop(). - bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup); - - // Find the menu corresponding to the given handle. - virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu); -#endif // wxUSE_MENUS - protected: // common part of all ctors void Init(); @@ -156,30 +127,6 @@ protected: // common part of Iconize(), Maximize() and Restore() void DoShowWindow(int nShowCmd); - // override those to return the normal window coordinates even when the - // window is minimized -#ifndef __WXWINCE__ - virtual void DoGetPosition(int *x, int *y) const; - virtual void DoGetSize(int *width, int *height) const; -#endif // __WXWINCE__ - - // Top level windows have different freeze semantics on Windows - virtual void DoFreeze(); - virtual void DoThaw(); - - // helper of SetIcons(): calls gets the icon with the size specified by the - // given system metrics (SM_C{X|Y}[SM]ICON) from the bundle and sets it - // using WM_SETICON with the specified wParam (ICOM_SMALL or ICON_BIG); - // returns true if the icon was set - bool DoSelectAndSetIcon(const wxIconBundle& icons, int smX, int smY, int i); - - // override wxWindow virtual method to use CW_USEDEFAULT if necessary - virtual void MSWGetCreateWindowCoords(const wxPoint& pos, - const wxSize& size, - int& x, int& y, - int& w, int& h) const; - - // is the window currently iconized? bool m_iconized; @@ -194,16 +141,7 @@ protected: bool m_fsIsMaximized; bool m_fsIsShowing; - // Save the current focus to m_winLastFocused if we're not iconized (the - // focus is always NULL when we're iconized). - void DoSaveLastFocus(); - - // Restore focus to m_winLastFocused if possible and needed. - void DoRestoreLastFocus(); - - // The last focused child: we remember it when we're deactivated and - // restore focus to it when we're activated (this is done here) or restored - // from iconic state (done by wxFrame). + // the last focused child: we restore focus to it on activation wxWindow *m_winLastFocused; #if defined(__SMARTPHONE__) && defined(__WXWINCE__) @@ -242,21 +180,18 @@ protected: #endif // __SMARTPHONE__ && __WXWINCE__ private: + // helper of SetIcons(): calls gets the icon with the size specified by the + // given system metrics (SM_C{X|Y}[SM]ICON) from the bundle and sets it + // using WM_SETICON with the specified wParam (ICOM_SMALL or ICON_BIG) + void DoSelectAndSetIcon(const wxIconBundle& icons, int smX, int smY, int i); + #if defined(__SMARTPHONE__) || defined(__POCKETPC__) void* m_activateInfo; #endif - // The system menu: initially NULL but can be set (once) by - // MSWGetSystemMenu(). Owned by this window. - wxMenu *m_menuSystem; - - // The number of currently opened menus: 0 initially, 1 when a top level - // menu is opened, 2 when its submenu is opened and so on. - int m_menuDepth; - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW); + DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW) }; #endif // _WX_MSW_TOPLEVEL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/treectrl.h b/Source/3rd Party/wx/include/wx/msw/treectrl.h index cf18b36e7..d3a6a2e35 100644 --- a/Source/3rd Party/wx/include/wx/msw/treectrl.h +++ b/Source/3rd Party/wx/include/wx/msw/treectrl.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Vadim Zeitlin to be less MSW-specific on 10/10/98 // Created: 01/02/97 +// RCS-ID: $Id: treectrl.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -49,7 +50,7 @@ WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr); // wxTreeCtrl // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreeCtrl : public wxTreeCtrlBase +class WXDLLEXPORT wxTreeCtrl : public wxTreeCtrlBase { public: // creation @@ -126,11 +127,6 @@ public: virtual wxTreeItemId GetRootItem() const; virtual wxTreeItemId GetSelection() const; virtual size_t GetSelections(wxArrayTreeItemIds& selections) const; - virtual wxTreeItemId GetFocusedItem() const; - - virtual void ClearFocusedItem(); - virtual void SetFocusedItem(const wxTreeItemId& item); - virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const; virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item, @@ -165,13 +161,12 @@ public: virtual void Unselect(); virtual void UnselectAll(); virtual void SelectItem(const wxTreeItemId& item, bool select = true); - virtual void SelectChildren(const wxTreeItemId& parent); virtual void EnsureVisible(const wxTreeItemId& item); virtual void ScrollTo(const wxTreeItemId& item); virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, - wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)); + wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)); virtual wxTextCtrl *GetEditControl() const; virtual void EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges = false) @@ -185,6 +180,34 @@ public: wxRect& rect, bool textOnly = false) const; + // deprecated + // ---------- + +#if WXWIN_COMPATIBILITY_2_4 + // these methods are deprecated and will be removed in future versions of + // wxWidgets, they're here for compatibility only, don't use them in new + // code (the comments indicate why these methods are now useless and how to + // replace them) + + // use Expand, Collapse, CollapseAndReset or Toggle + wxDEPRECATED( void ExpandItem(const wxTreeItemId& item, int action) ); + + // use Set/GetImageList and Set/GetStateImageList + // Use base class GetImageList() + wxDEPRECATED( void SetImageList(wxImageList *imageList, int) ); + + // use Set/GetItemImage directly + wxDEPRECATED( int GetItemSelectedImage(const wxTreeItemId& item) const ); + wxDEPRECATED( void SetItemSelectedImage(const wxTreeItemId& item, int image) ); + + // use the versions taking wxTreeItemIdValue cookies + wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, + long& cookie) const ); + wxDEPRECATED( wxTreeItemId GetNextChild(const wxTreeItemId& item, + long& cookie) const ); +#endif // WXWIN_COMPATIBILITY_2_4 + + // implementation // -------------- @@ -207,18 +230,15 @@ public: virtual bool SetBackgroundColour(const wxColour &colour); virtual bool SetForegroundColour(const wxColour &colour); - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } + // get/set the check state for the item (only for wxTR_MULTIPLE) + bool IsItemChecked(const wxTreeItemId& item) const; + void SetItemCheck(const wxTreeItemId& item, bool check = true); + + // set/get the item state.image (state == -1 means cycle to the next one) + void SetState(const wxTreeItemId& node, int state); + int GetState(const wxTreeItemId& node); protected: - // Implement "update locking" in a custom way for this control. - virtual void DoFreeze(); - virtual void DoThaw(); - - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - // SetImageList helper void SetAnyImageList(wxImageList *imageList, int which); @@ -228,9 +248,6 @@ protected: // end edit label void DoEndEditLabel(bool discardChanges = false); - virtual int DoGetItemState(const wxTreeItemId& item) const; - virtual void DoSetItemState(const wxTreeItemId& item, int state); - virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent, size_t pos, const wxString& text, @@ -246,28 +263,6 @@ protected: // obtain the user data for the lParam member of TV_ITEM class wxTreeItemParam *GetItemParam(const wxTreeItemId& item) const; - // update the event to include the items client data and pass it to - // HandleWindowEvent(), return true if it processed it - bool HandleTreeEvent(wxTreeEvent& event) const; - - // pass the event to HandleTreeEvent() and return true if the event was - // either unprocessed or not vetoed - bool IsTreeEventAllowed(wxTreeEvent& event) const - { - return !HandleTreeEvent(event) || event.IsAllowed(); - } - - // generate a wxEVT_KEY_DOWN event from the specified WPARAM/LPARAM values - // having the same meaning as for WM_KEYDOWN, return true if it was - // processed - bool MSWHandleTreeKeyDownEvent(WXWPARAM wParam, WXLPARAM lParam); - - // handle a key event in a multi-selection control, should be only called - // for keys which can be used to change the selection - // - // return true if the key was processed, false otherwise - bool MSWHandleSelectionKey(unsigned vkey); - // data used only while editing the item label: wxTextCtrl *m_textCtrl; // text control in which it is edited @@ -283,13 +278,6 @@ private: void DoExpand(const wxTreeItemId& item, int flag); - void DoSelectItem(const wxTreeItemId& item, bool select = true); - void DoUnselectItem(const wxTreeItemId& item); - void DoToggleItemSelection(const wxTreeItemId& item); - - void DoUnselectAll(); - void DoSelectChildren(const wxTreeItemId& parent); - void DeleteTextCtrl(); // return true if the item is the hidden root one (i.e. it's the root item @@ -297,14 +285,6 @@ private: bool IsHiddenRoot(const wxTreeItemId& item) const; - // check if the given flags (taken from TV_HITTESTINFO structure) - // indicate a position "on item": this is less trivial than just checking - // for TVHT_ONITEM because we consider that points to the left and right of - // item text are also "on item" when wxTR_FULL_ROW_HIGHLIGHT is used as the - // item visually spans the entire breadth of the window then - bool MSWIsOnItem(unsigned flags) const; - - // the hash storing the items attributes (indexed by item ids) wxMapTreeAttr m_attrs; @@ -323,30 +303,11 @@ private: wxTreeItemId m_htSelStart, m_htClickedItem; wxPoint m_ptClick; - // whether dragging has started - bool m_dragStarted; - - // whether focus was lost between subsequent clicks of a single item - bool m_focusLost; - - // set when we are changing selection ourselves (only used in multi - // selection mode) - bool m_changingSelection; - - // whether we need to trigger a state image click event - bool m_triggerStateImageClick; - - // whether we need to deselect other items on mouse up - bool m_mouseUpDeselect; - - // The size to restore the control to when it is thawed, see DoThaw(). - wxSize m_thawnSize; - friend class wxTreeItemIndirectData; friend class wxTreeSortHelper; DECLARE_DYNAMIC_CLASS(wxTreeCtrl) - wxDECLARE_NO_COPY_CLASS(wxTreeCtrl); + DECLARE_NO_COPY_CLASS(wxTreeCtrl) }; #endif // wxUSE_TREECTRL diff --git a/Source/3rd Party/wx/include/wx/msw/uxtheme.h b/Source/3rd Party/wx/include/wx/msw/uxtheme.h index e0ce8fbbb..23e745fc9 100644 --- a/Source/3rd Party/wx/include/wx/msw/uxtheme.h +++ b/Source/3rd Party/wx/include/wx/msw/uxtheme.h @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/uxtheme.h +// Name: include/wx/msw/uxtheme.h // Purpose: wxUxThemeEngine class: support for XP themes // Author: John Platts, Vadim Zeitlin // Modified by: // Created: 2003 +// RCS-ID: $Id: uxtheme.h 42725 2006-10-30 15:37:42Z VZ $ // Copyright: (c) 2003 John Platts, Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_UXTHEME_H_ @@ -16,74 +17,6 @@ #include "wx/msw/private.h" // we use GetHwndOf() #include "wx/msw/uxthemep.h" -// Amazingly, GetThemeFont() and GetThemeSysFont() functions use LOGFONTA under -// XP but LOGFONTW (even in non-Unicode build) under later versions of Windows. -// If we declare them as taking LOGFONT below, the code would be able to -// silently pass LOGFONTA to them in ANSI build and would crash at run-time -// under Windows Vista/7 because of a buffer overrun (LOGFONTA being smaller -// than LOGFONTW expected by these functions). If we we declare them as taking -// LOGFONTW, the code wouldn't work correctly under XP. So we use a special -// wxUxThemeFont class to encapsulate this and intentionally change the LOGFONT -// output parameters of the theme functions to take it instead. - -class wxUxThemeFont -{ -public: - // Trivial default ctor. - wxUxThemeFont() { } - - // Just some unique type. - struct Ptr { }; - -#if wxUSE_UNICODE - // In Unicode build we always use LOGFONT anyhow so this class is - // completely trivial. - Ptr *GetPtr() { return reinterpret_cast(&m_lfW); } - const LOGFONTW& GetLOGFONT() { return m_lfW; } -#else // !wxUSE_UNICODE - // Return either LOGFONTA or LOGFONTW pointer as required by the current - // Windows version. - Ptr *GetPtr() - { - return UseLOGFONTW() ? reinterpret_cast(&m_lfW) - : reinterpret_cast(&m_lfA); - } - - // This method returns LOGFONT (i.e. LOGFONTA in ANSI build and LOGFONTW in - // Unicode one) which can be used with other, normal, Windows or wx - // functions. Internally it may need to transform LOGFONTW to LOGFONTA. - const LOGFONTA& GetLOGFONT() - { - if ( UseLOGFONTW() ) - { - // Most of the fields are the same in LOGFONTA and LOGFONTW so just - // copy everything by default. - memcpy(&m_lfA, &m_lfW, sizeof(m_lfA)); - - // But the face name must be converted from Unicode. - WideCharToMultiByte(CP_ACP, 0, m_lfW.lfFaceName, -1, - m_lfA.lfFaceName, sizeof(m_lfA.lfFaceName), - NULL, NULL); - } - - return m_lfA; - } - -private: - static bool UseLOGFONTW() - { - return wxGetWinVersion() >= wxWinVersion_Vista; - } - - LOGFONTA m_lfA; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE - -private: - LOGFONTW m_lfW; - - wxDECLARE_NO_COPY_CLASS(wxUxThemeFont); -}; - typedef HTHEME (__stdcall *PFNWXUOPENTHEMEDATA)(HWND, const wchar_t *); typedef HRESULT (__stdcall *PFNWXUCLOSETHEMEDATA)(HTHEME); typedef HRESULT (__stdcall *PFNWXUDRAWTHEMEBACKGROUND)(HTHEME, HDC, int, int, const RECT *, const RECT *); @@ -106,7 +39,7 @@ typedef HRESULT (__stdcall *PFNWXUGETTHEMEBOOL)(HTHEME, int, int, int, BOOL *); typedef HRESULT (__stdcall *PFNWXUGETTHEMEINT)(HTHEME, int, int, int, int *); typedef HRESULT (__stdcall *PFNWXUGETTHEMEENUMVALUE)(HTHEME, int, int, int, int *); typedef HRESULT (__stdcall *PFNWXUGETTHEMEPOSITION)(HTHEME, int, int, int, POINT *); -typedef HRESULT (__stdcall *PFNWXUGETTHEMEFONT)(HTHEME, HDC, int, int, int, wxUxThemeFont::Ptr *); +typedef HRESULT (__stdcall *PFNWXUGETTHEMEFONT)(HTHEME, HDC, int, int, int, LOGFONT *); typedef HRESULT (__stdcall *PFNWXUGETTHEMERECT)(HTHEME, int, int, int, RECT *); typedef HRESULT (__stdcall *PFNWXUGETTHEMEMARGINS)(HTHEME, HDC, int, int, int, RECT *, MARGINS *); typedef HRESULT (__stdcall *PFNWXUGETTHEMEINTLIST)(HTHEME, int, int, int, INTLIST*); @@ -117,7 +50,7 @@ typedef COLORREF(__stdcall *PFNWXUGETTHEMESYSCOLOR)(HTHEME, int); typedef HBRUSH (__stdcall *PFNWXUGETTHEMESYSCOLORBRUSH)(HTHEME, int); typedef BOOL (__stdcall *PFNWXUGETTHEMESYSBOOL)(HTHEME, int); typedef int (__stdcall *PFNWXUGETTHEMESYSSIZE)(HTHEME, int); -typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSFONT)(HTHEME, int, wxUxThemeFont::Ptr *); +typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSFONT)(HTHEME, int, LOGFONT *); typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSSTRING)(HTHEME, int, wchar_t *, int); typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSINT)(HTHEME, int, int *); typedef BOOL (__stdcall *PFNWXUISTHEMEACTIVE)(); @@ -146,7 +79,7 @@ typedef HRESULT (__stdcall *PFNWXUENABLETHEMING)(BOOL); #define wxUX_THEME_DECLARE(type, func) type func(...) { return 0; } #endif -class WXDLLIMPEXP_CORE wxUxThemeEngine +class WXDLLEXPORT wxUxThemeEngine { public: // get the theme engine or NULL if themes are not available @@ -235,7 +168,7 @@ private: friend class wxUxThemeModule; #endif // wxUSE_UXTHEME - wxDECLARE_NO_COPY_CLASS(wxUxThemeEngine); + DECLARE_NO_COPY_CLASS(wxUxThemeEngine) }; #if wxUSE_UXTHEME @@ -290,7 +223,7 @@ public: private: HTHEME m_hTheme; - wxDECLARE_NO_COPY_CLASS(wxUxThemeHandle); + DECLARE_NO_COPY_CLASS(wxUxThemeHandle) }; #endif // _WX_UXTHEME_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/uxthemep.h b/Source/3rd Party/wx/include/wx/msw/uxthemep.h index 6f52b694a..bc2fda91d 100644 --- a/Source/3rd Party/wx/include/wx/msw/uxthemep.h +++ b/Source/3rd Party/wx/include/wx/msw/uxthemep.h @@ -4,9 +4,9 @@ * Copyright (C) 2003 Kevin Koltzau * * Originally written for the Wine project, and issued under - * the wxWindows licence by kind permission of the author. + * the wxWindows License by kind permission of the author. * - * Licence: wxWindows licence + * License: wxWindows License */ #ifndef __WINE_UXTHEME_H diff --git a/Source/3rd Party/wx/include/wx/msw/webview_ie.h b/Source/3rd Party/wx/include/wx/msw/webview_ie.h deleted file mode 100644 index bc19ee85a..000000000 --- a/Source/3rd Party/wx/include/wx/msw/webview_ie.h +++ /dev/null @@ -1,356 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: include/wx/msw/webview_ie.h -// Purpose: wxMSW IE wxWebView backend -// Author: Marianne Gagnon -// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef wxWebViewIE_H -#define wxWebViewIE_H - -#include "wx/setup.h" - -#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) - -#include "wx/control.h" -#include "wx/webview.h" -#include "wx/msw/ole/automtn.h" -#include "wx/msw/ole/activex.h" -#include "wx/msw/ole/oleutils.h" -#include "wx/msw/private/comptr.h" -#include "wx/msw/wrapwin.h" -#include "wx/msw/missing.h" -#include "wx/msw/webview_missing.h" -#include "wx/sharedptr.h" -#include "wx/vector.h" - -struct IHTMLDocument2; -struct IHTMLElement; -struct IMarkupPointer; -class wxFSFile; -class ClassFactory; -class wxIEContainer; -class DocHostUIHandler; -class wxFindPointers; -class wxIInternetProtocol; - -class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView -{ -public: - - wxWebViewIE() {} - - wxWebViewIE(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxWebViewNameStr) - { - Create(parent, id, url, pos, size, style, name); - } - - ~wxWebViewIE(); - - bool Create(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxWebViewNameStr); - - virtual void LoadURL(const wxString& url); - virtual void LoadHistoryItem(wxSharedPtr item); - virtual wxVector > GetBackwardHistory(); - virtual wxVector > GetForwardHistory(); - - virtual bool CanGoForward() const; - virtual bool CanGoBack() const; - virtual void GoBack(); - virtual void GoForward(); - virtual void ClearHistory(); - virtual void EnableHistory(bool enable = true); - virtual void Stop(); - virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT); - - virtual wxString GetPageSource() const; - virtual wxString GetPageText() const; - - virtual bool IsBusy() const; - virtual wxString GetCurrentURL() const; - virtual wxString GetCurrentTitle() const; - - virtual void SetZoomType(wxWebViewZoomType); - virtual wxWebViewZoomType GetZoomType() const; - virtual bool CanSetZoomType(wxWebViewZoomType) const; - - virtual void Print(); - - virtual wxWebViewZoom GetZoom() const; - virtual void SetZoom(wxWebViewZoom zoom); - - //Clipboard functions - virtual bool CanCut() const; - virtual bool CanCopy() const; - virtual bool CanPaste() const; - virtual void Cut(); - virtual void Copy(); - virtual void Paste(); - - //Undo / redo functionality - virtual bool CanUndo() const; - virtual bool CanRedo() const; - virtual void Undo(); - virtual void Redo(); - - //Find function - virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT); - - //Editing functions - virtual void SetEditable(bool enable = true); - virtual bool IsEditable() const; - - //Selection - virtual void SelectAll(); - virtual bool HasSelection() const; - virtual void DeleteSelection(); - virtual wxString GetSelectedText() const; - virtual wxString GetSelectedSource() const; - virtual void ClearSelection(); - - virtual void RunScript(const wxString& javascript); - - //Virtual Filesystem Support - virtual void RegisterHandler(wxSharedPtr handler); - - virtual void* GetNativeBackend() const { return m_webBrowser; } - - // ---- IE-specific methods - - // FIXME: I seem to be able to access remote webpages even in offline mode... - bool IsOfflineMode(); - void SetOfflineMode(bool offline); - - wxWebViewZoom GetIETextZoom() const; - void SetIETextZoom(wxWebViewZoom level); - - wxWebViewZoom GetIEOpticalZoom() const; - void SetIEOpticalZoom(wxWebViewZoom level); - - void onActiveXEvent(wxActiveXEvent& evt); - void onEraseBg(wxEraseEvent&) {} - - DECLARE_EVENT_TABLE(); - -protected: - virtual void DoSetPage(const wxString& html, const wxString& baseUrl); - -private: - wxIEContainer* m_container; - wxAutomationObject m_ie; - IWebBrowser2* m_webBrowser; - DWORD m_dwCookie; - wxCOMPtr m_uiHandler; - - //We store the current zoom type; - wxWebViewZoomType m_zoomType; - - /** The "Busy" property of IWebBrowser2 does not always return busy when - * we'd want it to; this variable may be set to true in cases where the - * Busy property is false but should be true. - */ - bool m_isBusy; - //We manage our own history, the history list contains the history items - //which are added as documentcomplete events arrive, unless we are loading - //an item from the history. The position is stored as an int, and reflects - //where we are in the history list. - wxVector > m_historyList; - wxVector m_factories; - int m_historyPosition; - bool m_historyLoadingFromList; - bool m_historyEnabled; - - //We store find flag, results and position. - wxVector m_findPointers; - int m_findFlags; - wxString m_findText; - int m_findPosition; - - //Generic helper functions - bool CanExecCommand(wxString command) const; - void ExecCommand(wxString command); - wxCOMPtr GetDocument() const; - bool IsElementVisible(wxCOMPtr elm); - //Find helper functions. - void FindInternal(const wxString& text, int flags, int internal_flag); - long FindNext(int direction = 1); - void FindClear(); - //Toggles control features see INTERNETFEATURELIST for values. - bool EnableControlFeature(long flag, bool enable = true); - - wxDECLARE_DYNAMIC_CLASS(wxWebViewIE); -}; - -class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryIE : public wxWebViewFactory -{ -public: - virtual wxWebView* Create() { return new wxWebViewIE; } - virtual wxWebView* Create(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxWebViewNameStr) - { return new wxWebViewIE(parent, id, url, pos, size, style, name); } -}; - -class VirtualProtocol : public wxIInternetProtocol -{ -protected: - wxIInternetProtocolSink* m_protocolSink; - wxString m_html; - VOID * fileP; - - wxFSFile* m_file; - wxSharedPtr m_handler; - -public: - VirtualProtocol(wxSharedPtr handler); - virtual ~VirtualProtocol() {} - - //IUnknown - DECLARE_IUNKNOWN_METHODS; - - //IInternetProtocolRoot - HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason), - DWORD WXUNUSED(dwOptions)) - { return E_NOTIMPL; } - HRESULT STDMETHODCALLTYPE Continue(wxPROTOCOLDATA *WXUNUSED(pProtocolData)) - { return S_OK; } - HRESULT STDMETHODCALLTYPE Resume() { return S_OK; } - HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl, - wxIInternetProtocolSink *pOIProtSink, - wxIInternetBindInfo *pOIBindInfo, - DWORD grfPI, - HANDLE_PTR dwReserved); - HRESULT STDMETHODCALLTYPE Suspend() { return S_OK; } - HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) { return S_OK; } - - //IInternetProtocol - HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions)) - { return S_OK; } - HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead); - HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove), - DWORD WXUNUSED(dwOrigin), - ULARGE_INTEGER* WXUNUSED(plibNewPosition)) - { return E_FAIL; } - HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; } -}; - -class ClassFactory : public IClassFactory -{ -public: - ClassFactory(wxSharedPtr handler) : m_handler(handler) - { AddRef(); } - virtual ~ClassFactory() {} - - wxString GetName() { return m_handler->GetName(); } - - //IClassFactory - HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter, - REFIID riid, void** ppvObject); - HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock); - - //IUnknown - DECLARE_IUNKNOWN_METHODS; - -private: - wxSharedPtr m_handler; -}; - -class wxIEContainer : public wxActiveXContainer -{ -public: - wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL); - virtual ~wxIEContainer(); - virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc); -private: - DocHostUIHandler* m_uiHandler; -}; - -class DocHostUIHandler : public wxIDocHostUIHandler -{ -public: - DocHostUIHandler(wxWebView* browser) { m_browser = browser; } - virtual ~DocHostUIHandler() {} - - virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt, - IUnknown *pcmdtReserved, - IDispatch *pdispReserved); - - virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo); - - virtual HRESULT wxSTDCALL ShowUI(DWORD dwID, - IOleInPlaceActiveObject *pActiveObject, - IOleCommandTarget *pCommandTarget, - IOleInPlaceFrame *pFrame, - IOleInPlaceUIWindow *pDoc); - - virtual HRESULT wxSTDCALL HideUI(void); - - virtual HRESULT wxSTDCALL UpdateUI(void); - - virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable); - - virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate); - - virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate); - - virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder, - IOleInPlaceUIWindow *pUIWindow, - BOOL fRameWindow); - - virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg, - const GUID *pguidCmdGroup, - DWORD nCmdID); - - virtual HRESULT wxSTDCALL GetOptionKeyPath(LPOLESTR *pchKey, - DWORD dw); - - virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget, - IDropTarget **ppDropTarget); - - virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch); - - virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate, - OLECHAR *pchURLIn, - OLECHAR **ppchURLOut); - - virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO, - IDataObject **ppDORet); - //IUnknown - DECLARE_IUNKNOWN_METHODS; - -private: - wxWebView* m_browser; -}; - -class wxFindPointers -{ -public: - wxFindPointers(wxIMarkupPointer *ptrBegin, wxIMarkupPointer *ptrEnd) - { - begin = ptrBegin; - end = ptrEnd; - } - //The two markup pointers. - wxIMarkupPointer *begin, *end; -}; - -#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) - -#endif // wxWebViewIE_H diff --git a/Source/3rd Party/wx/include/wx/msw/webview_missing.h b/Source/3rd Party/wx/include/wx/msw/webview_missing.h deleted file mode 100644 index fc2b8bc04..000000000 --- a/Source/3rd Party/wx/include/wx/msw/webview_missing.h +++ /dev/null @@ -1,947 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: include/wx/msw/webview_missing.h -// Purpose: Defintions / classes commonly missing used by wxWebViewIE -// Author: Steven Lamerton -// Copyright: (c) 2012 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -/* - * Classes and definitions used by wxWebViewIE vary in their - * completeness between compilers and versions of compilers. - * We implement our own versions here which should work - * for all compilers. The definitions are taken from the - * mingw-w64 headers which are public domain. -*/ - -/* urlmon.h */ - -struct IHTMLElement; -struct IHTMLDocument2; - -#ifndef REFRESH_NORMAL -#define REFRESH_NORMAL 0 -#endif - -#ifndef REFRESH_COMPLETELY -#define REFRESH_COMPLETELY 3 -#endif - -typedef enum __wxMIDL_IBindStatusCallback_0006 -{ - wxBSCF_FIRSTDATANOTIFICATION = 0x1, - wxBSCF_INTERMEDIATEDATANOTIFICATION = 0x2, - wxBSCF_LASTDATANOTIFICATION = 0x4, - wxBSCF_DATAFULLYAVAILABLE = 0x8, - wxBSCF_AVAILABLEDATASIZEUNKNOWN = 0x10 -} wxBSCF; - -EXTERN_C const IID CLSID_FileProtocol; - -typedef struct _tagwxBINDINFO -{ - ULONG cbSize; - LPWSTR szExtraInfo; - STGMEDIUM stgmedData; - DWORD grfBindInfoF; - DWORD dwBindVerb; - LPWSTR szCustomVerb; - DWORD cbstgmedData; - DWORD dwOptions; - DWORD dwOptionsFlags; - DWORD dwCodePage; - SECURITY_ATTRIBUTES securityAttributes; - IID iid; - IUnknown *pUnk; - DWORD dwReserved; -} wxBINDINFO; - -typedef struct _tagwxPROTOCOLDATA -{ - DWORD grfFlags; - DWORD dwState; - LPVOID pData; - ULONG cbData; -} wxPROTOCOLDATA; - -class wxIInternetBindInfo : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL GetBindInfo(DWORD *grfBINDF, wxBINDINFO *pbindinfo) = 0; - virtual HRESULT wxSTDCALL GetBindString(ULONG ulStringType, LPOLESTR *ppwzStr, - ULONG cEl, ULONG *pcElFetched) = 0; -}; - -class wxIInternetProtocolSink : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL Switch(wxPROTOCOLDATA *pProtocolData) = 0; - virtual HRESULT wxSTDCALL ReportProgress(ULONG ulStatusCode, - LPCWSTR szStatusText) = 0; - virtual HRESULT wxSTDCALL ReportData(DWORD grfBSCF, ULONG ulProgress, - ULONG ulProgressMax) = 0; - virtual HRESULT wxSTDCALL ReportResult(HRESULT hrResult, DWORD dwError, - LPCWSTR szResult) = 0; -}; - -class wxIInternetProtocolRoot : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink, - wxIInternetBindInfo *pOIBindInfo, DWORD grfPI, - HANDLE_PTR dwReserved) = 0; - virtual HRESULT wxSTDCALL Continue(wxPROTOCOLDATA *pProtocolData) = 0; - virtual HRESULT wxSTDCALL Abort(HRESULT hrReason, DWORD dwOptions) = 0; - virtual HRESULT wxSTDCALL Terminate(DWORD dwOptions) = 0; - virtual HRESULT wxSTDCALL Suspend(void) = 0; - virtual HRESULT wxSTDCALL Resume(void) = 0; -}; - - -class wxIInternetProtocol : public wxIInternetProtocolRoot -{ -public: - virtual HRESULT wxSTDCALL Read(void *pv, ULONG cb, ULONG *pcbRead) = 0; - virtual HRESULT wxSTDCALL Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, - ULARGE_INTEGER *plibNewPosition) = 0; - virtual HRESULT wxSTDCALL LockRequest(DWORD dwOptions) = 0; - virtual HRESULT wxSTDCALL UnlockRequest(void) = 0; -}; - - -class wxIInternetSession : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL RegisterNameSpace(IClassFactory *pCF, REFCLSID rclsid, - LPCWSTR pwzProtocol, - ULONG cPatterns, - const LPCWSTR *ppwzPatterns, - DWORD dwReserved) = 0; - virtual HRESULT wxSTDCALL UnregisterNameSpace(IClassFactory *pCF, - LPCWSTR pszProtocol) = 0; - virtual HRESULT wxSTDCALL RegisterMimeFilter(IClassFactory *pCF, - REFCLSID rclsid, - LPCWSTR pwzType) = 0; - virtual HRESULT wxSTDCALL UnregisterMimeFilter(IClassFactory *pCF, - LPCWSTR pwzType) = 0; - virtual HRESULT wxSTDCALL CreateBinding(LPBC pBC, LPCWSTR szUrl, - IUnknown *pUnkOuter, IUnknown **ppUnk, - wxIInternetProtocol **ppOInetProt, - DWORD dwOption) = 0; - virtual HRESULT wxSTDCALL SetSessionOption(DWORD dwOption, LPVOID pBuffer, - DWORD dwBufferLength, - DWORD dwReserved) = 0; - virtual HRESULT wxSTDCALL GetSessionOption(DWORD dwOption, LPVOID pBuffer, - DWORD *pdwBufferLength, - DWORD dwReserved) = 0; -}; - -/* end of urlmon.h */ - -/* mshtmhst.h */ - -typedef enum _tagwxDOCHOSTUIFLAG -{ - DOCHOSTUIFLAG_DIALOG = 0x1, - DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2, - DOCHOSTUIFLAG_NO3DBORDER = 0x4, - DOCHOSTUIFLAG_SCROLL_NO = 0x8, - DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10, - DOCHOSTUIFLAG_OPENNEWWIN = 0x20, - DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40, - DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80, - DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100, - DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200, - DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400, - DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800, - DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000, - DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000, - DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000, - DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000, - DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000, - DOCHOSTUIFLAG_THEME = 0x40000, - DOCHOSTUIFLAG_NOTHEME = 0x80000, - DOCHOSTUIFLAG_NOPICS = 0x100000, - DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000, - DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000, - DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000, - DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000 -} DOCHOSTUIFLAG; - -typedef struct _tagwxDOCHOSTUIINFO -{ - ULONG cbSize; - DWORD dwFlags; - DWORD dwDoubleClick; - OLECHAR *pchHostCss; - OLECHAR *pchHostNS; -} DOCHOSTUIINFO; - -class wxIDocHostUIHandler : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt, - IUnknown *pcmdtReserved, - IDispatch *pdispReserved) = 0; - - virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) = 0; - - virtual HRESULT wxSTDCALL ShowUI(DWORD dwID, - IOleInPlaceActiveObject *pActiveObject, - IOleCommandTarget *pCommandTarget, - IOleInPlaceFrame *pFrame, - IOleInPlaceUIWindow *pDoc) = 0; - - virtual HRESULT wxSTDCALL HideUI(void) = 0; - - virtual HRESULT wxSTDCALL UpdateUI(void) = 0; - - virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) = 0; - - virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) = 0; - - virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) = 0; - - virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder, - IOleInPlaceUIWindow *pUIWindow, - BOOL fRameWindow) = 0; - - virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg, - const GUID *pguidCmdGroup, - DWORD nCmdID) = 0; - - virtual HRESULT wxSTDCALL GetOptionKeyPath(LPOLESTR *pchKey, - DWORD dw) = 0; - - virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget, - IDropTarget **ppDropTarget) = 0; - - virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) = 0; - - virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate, - OLECHAR *pchURLIn, - OLECHAR **ppchURLOut) = 0; - - virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO, - IDataObject **ppDORet) = 0; -}; - -/* end of mshtmhst.h */ - -/* mshtml.h */ - -typedef enum _tagwxPOINTER_GRAVITY -{ - wxPOINTER_GRAVITY_Left = 0, - wxPOINTER_GRAVITY_Right = 1, - wxPOINTER_GRAVITY_Max = 2147483647 -} wxPOINTER_GRAVITY; - -typedef enum _tagwxELEMENT_ADJACENCY -{ - wxELEM_ADJ_BeforeBegin = 0, - wxELEM_ADJ_AfterBegin = 1, - wxELEM_ADJ_BeforeEnd = 2, - wxELEM_ADJ_AfterEnd = 3, - wxELEMENT_ADJACENCY_Max = 2147483647 -} wxELEMENT_ADJACENCY; - -typedef enum _tagwxMARKUP_CONTEXT_TYPE -{ - wxCONTEXT_TYPE_None = 0, - wxCONTEXT_TYPE_Text = 1, - wxCONTEXT_TYPE_EnterScope = 2, - wxCONTEXT_TYPE_ExitScope = 3, - wxCONTEXT_TYPE_NoScope = 4, - wxMARKUP_CONTEXT_TYPE_Max = 2147483647 -} wxMARKUP_CONTEXT_TYPE; - -typedef enum _tagwxFINDTEXT_FLAGS -{ - wxFINDTEXT_BACKWARDS = 0x1, - wxFINDTEXT_WHOLEWORD = 0x2, - wxFINDTEXT_MATCHCASE = 0x4, - wxFINDTEXT_RAW = 0x20000, - wxFINDTEXT_MATCHDIAC = 0x20000000, - wxFINDTEXT_MATCHKASHIDA = 0x40000000, - wxFINDTEXT_MATCHALEFHAMZA = 0x80000000, - wxFINDTEXT_FLAGS_Max = 2147483647 -} wxFINDTEXT_FLAGS; - -typedef enum _tagwxMOVEUNIT_ACTION -{ - wxMOVEUNIT_PREVCHAR = 0, - wxMOVEUNIT_NEXTCHAR = 1, - wxMOVEUNIT_PREVCLUSTERBEGIN = 2, - wxMOVEUNIT_NEXTCLUSTERBEGIN = 3, - wxMOVEUNIT_PREVCLUSTEREND = 4, - wxMOVEUNIT_NEXTCLUSTEREND = 5, - wxMOVEUNIT_PREVWORDBEGIN = 6, - wxMOVEUNIT_NEXTWORDBEGIN = 7, - wxMOVEUNIT_PREVWORDEND = 8, - wxMOVEUNIT_NEXTWORDEND = 9, - wxMOVEUNIT_PREVPROOFWORD = 10, - wxMOVEUNIT_NEXTPROOFWORD = 11, - wxMOVEUNIT_NEXTURLBEGIN = 12, - wxMOVEUNIT_PREVURLBEGIN = 13, - wxMOVEUNIT_NEXTURLEND = 14, - wxMOVEUNIT_PREVURLEND = 15, - wxMOVEUNIT_PREVSENTENCE = 16, - wxMOVEUNIT_NEXTSENTENCE = 17, - wxMOVEUNIT_PREVBLOCK = 18, - wxMOVEUNIT_NEXTBLOCK = 19, - wxMOVEUNIT_ACTION_Max = 2147483647 -} wxMOVEUNIT_ACTION; - -typedef enum _tagwxELEMENT_TAG_ID -{ - wxTAGID_NULL = 0, wxTAGID_UNKNOWN = 1, wxTAGID_A = 2, wxTAGID_ACRONYM = 3, - wxTAGID_ADDRESS = 4, wxTAGID_APPLET = 5, wxTAGID_AREA = 6, wxTAGID_B = 7, - wxTAGID_BASE = 8, wxTAGID_BASEFONT = 9, wxTAGID_BDO = 10, - wxTAGID_BGSOUND = 11, wxTAGID_BIG = 12, wxTAGID_BLINK = 13, - wxTAGID_BLOCKQUOTE = 14, wxTAGID_BODY = 15, wxTAGID_BR = 16, - wxTAGID_BUTTON = 17, wxTAGID_CAPTION = 18, wxTAGID_CENTER = 19, - wxTAGID_CITE = 20, wxTAGID_CODE = 21, wxTAGID_COL = 22, - wxTAGID_COLGROUP = 23, wxTAGID_COMMENT = 24, wxTAGID_COMMENT_RAW = 25, - wxTAGID_DD = 26, wxTAGID_DEL = 27, wxTAGID_DFN = 28, wxTAGID_DIR = 29, - wxTAGID_DIV = 30, wxTAGID_DL = 31, wxTAGID_DT = 32, wxTAGID_EM = 33, - wxTAGID_EMBED = 34, wxTAGID_FIELDSET = 35, wxTAGID_FONT = 36, - wxTAGID_FORM = 37, wxTAGID_FRAME = 38, wxTAGID_FRAMESET = 39, - wxTAGID_GENERIC = 40, wxTAGID_H1 = 41, wxTAGID_H2 = 42, wxTAGID_H3 = 43, - wxTAGID_H4 = 44, wxTAGID_H5 = 45, wxTAGID_H6 = 46, wxTAGID_HEAD = 47, - wxTAGID_HR = 48, wxTAGID_HTML = 49, wxTAGID_I = 50, wxTAGID_IFRAME = 51, - wxTAGID_IMG = 52, wxTAGID_INPUT = 53, wxTAGID_INS = 54, wxTAGID_KBD = 55, - wxTAGID_LABEL = 56, wxTAGID_LEGEND = 57, wxTAGID_LI = 58, wxTAGID_LINK = 59, - wxTAGID_LISTING = 60, wxTAGID_MAP = 61, wxTAGID_MARQUEE = 62, - wxTAGID_MENU = 63, wxTAGID_META = 64, wxTAGID_NEXTID = 65, - wxTAGID_NOBR = 66, wxTAGID_NOEMBED = 67, wxTAGID_NOFRAMES = 68, - wxTAGID_NOSCRIPT = 69, wxTAGID_OBJECT = 70, wxTAGID_OL = 71, - wxTAGID_OPTION = 72, wxTAGID_P = 73, wxTAGID_PARAM = 74, - wxTAGID_PLAINTEXT = 75, wxTAGID_PRE = 76, wxTAGID_Q = 77, wxTAGID_RP = 78, - wxTAGID_RT = 79, wxTAGID_RUBY = 80, wxTAGID_S = 81, wxTAGID_SAMP = 82, - wxTAGID_SCRIPT = 83, wxTAGID_SELECT = 84, wxTAGID_SMALL = 85, - wxTAGID_SPAN = 86, wxTAGID_STRIKE = 87, wxTAGID_STRONG = 88, - wxTAGID_STYLE = 89, wxTAGID_SUB = 90, wxTAGID_SUP = 91, wxTAGID_TABLE = 92, - wxTAGID_TBODY = 93, wxTAGID_TC = 94, wxTAGID_TD = 95, wxTAGID_TEXTAREA = 96, - wxTAGID_TFOOT = 97, wxTAGID_TH = 98, wxTAGID_THEAD = 99, - wxTAGID_TITLE = 100, wxTAGID_TR = 101, wxTAGID_TT = 102, wxTAGID_U = 103, - wxTAGID_UL = 104, wxTAGID_VAR = 105, wxTAGID_WBR = 106, wxTAGID_XMP = 107, - wxTAGID_ROOT = 108, wxTAGID_OPTGROUP = 109, wxTAGID_COUNT = 110, - wxTAGID_LAST_PREDEFINED = 10000, wxELEMENT_TAG_ID_Max = 2147483647 -} wxELEMENT_TAG_ID; - -struct wxIHTMLStyle : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL put_fontFamily(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_fontFamily(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_fontStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_fontStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_fontVariant(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_fontVariant(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_fontWeight(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_fontWeight(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_fontSize(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_fontSize(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_font(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_font(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_color(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_color(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_background(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_background(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundColor(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_backgroundColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundImage(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_backgroundImage(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundRepeat(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_backgroundRepeat(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundAttachment(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_backgroundAttachment(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundPosition(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_backgroundPosition(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundPositionX(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_backgroundPositionX(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_backgroundPositionY(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_backgroundPositionY(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_wordSpacing(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_wordSpacing(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_letterSpacing(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_letterSpacing(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_textDecoration(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_textDecoration(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_textDecorationNone(VARIANT_BOOL v) = 0; - virtual HRESULT wxSTDCALL get_textDecorationNone(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL put_textDecorationUnderline(VARIANT_BOOL v) = 0; - virtual HRESULT wxSTDCALL get_textDecorationUnderline(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL put_textDecorationOverline(VARIANT_BOOL v) = 0; - virtual HRESULT wxSTDCALL get_textDecorationOverline(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL put_textDecorationLineThrough(VARIANT_BOOL v) = 0; - virtual HRESULT wxSTDCALL get_textDecorationLineThrough(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL put_textDecorationBlink(VARIANT_BOOL v) = 0; - virtual HRESULT wxSTDCALL get_textDecorationBlink(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL put_verticalAlign(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_verticalAlign(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_textTransform(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_textTransform(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_textAlign(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_textAlign(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_textIndent(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_textIndent(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_lineHeight(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_lineHeight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_marginTop(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_marginTop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_marginRight(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_marginRight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_marginBottom(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_marginBottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_marginLeft(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_marginLeft(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_margin(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_margin(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_paddingTop(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_paddingTop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_paddingRight(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_paddingRight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_paddingBottom(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_paddingBottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_paddingLeft(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_paddingLeft(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_padding(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_padding(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_border(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_border(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderTop(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderTop(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderRight(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderRight(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderBottom(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderBottom(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderLeft(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderLeft(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderColor(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderColor(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderTopColor(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderTopColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderRightColor(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderRightColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderBottomColor(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderBottomColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderLeftColor(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderLeftColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderWidth(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderWidth(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderTopWidth(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderTopWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderRightWidth(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderRightWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderBottomWidth(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderBottomWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderLeftWidth(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_borderLeftWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_borderStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderTopStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderTopStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderRightStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderRightStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderBottomStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderBottomStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_borderLeftStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_borderLeftStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_width(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_width(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_height(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_height(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_styleFloat(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_styleFloat(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_clear(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_clear(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_display(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_display(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_visibility(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_visibility(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_listStyleType(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_listStyleType(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_listStylePosition(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_listStylePosition(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_listStyleImage(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_listStyleImage(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_listStyle(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_listStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_whiteSpace(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_whiteSpace(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_top(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_top(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_left(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_left(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_position(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_zIndex(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_zIndex(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_overflow(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_overflow(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_pageBreakBefore(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_pageBreakBefore(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_pageBreakAfter(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_pageBreakAfter(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_cssText(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_cssText(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_pixelTop(long v) = 0; - virtual HRESULT wxSTDCALL get_pixelTop(long *p) = 0; - virtual HRESULT wxSTDCALL put_pixelLeft(long v) = 0; - virtual HRESULT wxSTDCALL get_pixelLeft(long *p) = 0; - virtual HRESULT wxSTDCALL put_pixelWidth(long v) = 0; - virtual HRESULT wxSTDCALL get_pixelWidth(long *p) = 0; - virtual HRESULT wxSTDCALL put_pixelHeight(long v) = 0; - virtual HRESULT wxSTDCALL get_pixelHeight(long *p) = 0; - virtual HRESULT wxSTDCALL put_posTop(float v) = 0; - virtual HRESULT wxSTDCALL get_posTop(float *p) = 0; - virtual HRESULT wxSTDCALL put_posLeft(float v) = 0; - virtual HRESULT wxSTDCALL get_posLeft(float *p) = 0; - virtual HRESULT wxSTDCALL put_posWidth(float v) = 0; - virtual HRESULT wxSTDCALL get_posWidth(float *p) = 0; - virtual HRESULT wxSTDCALL put_posHeight(float v) = 0; - virtual HRESULT wxSTDCALL get_posHeight(float *p) = 0; - virtual HRESULT wxSTDCALL put_cursor(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_cursor(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_clip(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_clip(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_filter(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_filter(BSTR *p) = 0; - virtual HRESULT wxSTDCALL setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags = 1) = 0; - virtual HRESULT wxSTDCALL getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT *AttributeValue) = 0; - virtual HRESULT wxSTDCALL removeAttribute(BSTR strAttributeName, LONG lFlags, VARIANT_BOOL *pfSuccess) = 0; - virtual HRESULT wxSTDCALL toString(BSTR *String) = 0; -}; - -struct wxIHTMLCurrentStyle : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL get_position(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_styleFloat(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_color(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_fontFamily(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_fontStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_fontVariant(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_fontWeight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_fontSize(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundImage(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundPositionX(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundPositionY(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundRepeat(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderLeftColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderTopColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderRightColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderBottomColor(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderTopStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderRightStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderBottomStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderLeftStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderTopWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderRightWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderBottomWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_borderLeftWidth(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_left(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_top(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_width(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_height(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_paddingLeft(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_paddingTop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_paddingRight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_paddingBottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_textAlign(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textDecoration(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_display(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_visibility(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_zIndex(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_letterSpacing(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_lineHeight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_textIndent(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_verticalAlign(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_backgroundAttachment(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_marginTop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_marginRight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_marginBottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_marginLeft(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_clear(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_listStyleType(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_listStylePosition(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_listStyleImage(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_clipTop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_clipRight(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_clipBottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_clipLeft(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_overflow(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_pageBreakBefore(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_pageBreakAfter(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_cursor(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_tableLayout(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderCollapse(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_direction(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_behavior(BSTR *p) = 0; - virtual HRESULT wxSTDCALL getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT *AttributeValue) = 0; - virtual HRESULT wxSTDCALL get_unicodeBidi(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_right(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_bottom(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_imeMode(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_rubyAlign(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_rubyPosition(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_rubyOverhang(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textAutospace(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_lineBreak(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_wordBreak(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textJustify(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textJustifyTrim(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textKashida(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_blockDirection(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_layoutGridChar(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_layoutGridLine(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_layoutGridMode(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_layoutGridType(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderStyle(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderColor(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_borderWidth(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_padding(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_margin(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_accelerator(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_overflowX(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_overflowY(BSTR *p) = 0; - virtual HRESULT wxSTDCALL get_textTransform(BSTR *p) = 0; -}; - - -struct wxIHTMLRect : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL put_left(long v) = 0; - virtual HRESULT wxSTDCALL get_left(long *p) = 0; - virtual HRESULT wxSTDCALL put_top(long v) = 0; - virtual HRESULT wxSTDCALL get_top(long *p) = 0; - virtual HRESULT wxSTDCALL put_right(long v) = 0; - virtual HRESULT wxSTDCALL get_right(long *p) = 0; - virtual HRESULT wxSTDCALL put_bottom(long v) = 0; - virtual HRESULT wxSTDCALL get_bottom(long *p) = 0; -}; - -struct wxIHTMLRectCollection : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL get_length(long *p) = 0; - virtual HRESULT wxSTDCALL get__newEnum(IUnknown **p) = 0; - virtual HRESULT wxSTDCALL item(VARIANT *pvarIndex, VARIANT *pvarResult) = 0; -}; - -struct wxIHTMLFiltersCollection : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL get_length(long *p) = 0; - virtual HRESULT wxSTDCALL get__newEnum(IUnknown **p) = 0; - virtual HRESULT wxSTDCALL item(VARIANT *pvarIndex, VARIANT *pvarResult) = 0; -}; - -struct wxIHTMLElementCollection : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL toString(BSTR *String) = 0; - virtual HRESULT wxSTDCALL put_length(long v) = 0; - virtual HRESULT wxSTDCALL get_length(long *p) = 0; - virtual HRESULT wxSTDCALL get__newEnum(IUnknown **p) = 0; - virtual HRESULT wxSTDCALL item(VARIANT name, VARIANT index, IDispatch **pdisp) = 0; - virtual HRESULT wxSTDCALL tags(VARIANT tagName, IDispatch **pdisp) = 0; -}; - -struct wxIHTMLElement2 : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL get_scopeName(BSTR *p) = 0; - virtual HRESULT wxSTDCALL setCapture(VARIANT_BOOL containerCapture = -1) = 0; - virtual HRESULT wxSTDCALL releaseCapture(void) = 0; - virtual HRESULT wxSTDCALL put_onlosecapture(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onlosecapture(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL componentFromPoint(long x, long y, BSTR *component) = 0; - virtual HRESULT wxSTDCALL doScroll(VARIANT component) = 0; - virtual HRESULT wxSTDCALL put_onscroll(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onscroll(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondrag(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondrag(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondragend(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondragend(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondragenter(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondragenter(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondragover(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondragover(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondragleave(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondragleave(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_ondrop(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_ondrop(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onbeforecut(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onbeforecut(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_oncut(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_oncut(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onbeforecopy(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onbeforecopy(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_oncopy(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_oncopy(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onbeforepaste(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onbeforepaste(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onpaste(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onpaste(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_currentStyle(wxIHTMLCurrentStyle **p) = 0; - virtual HRESULT wxSTDCALL put_onpropertychange(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onpropertychange(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL getClientRects(wxIHTMLRectCollection **pRectCol) = 0; - virtual HRESULT wxSTDCALL getBoundingClientRect(wxIHTMLRect **pRect) = 0; - virtual HRESULT wxSTDCALL setExpression(BSTR propname, BSTR expression, BSTR language = L"") = 0; - virtual HRESULT wxSTDCALL getExpression(BSTR propname, VARIANT *expression) = 0; - virtual HRESULT wxSTDCALL removeExpression(BSTR propname, VARIANT_BOOL *pfSuccess) = 0; - virtual HRESULT wxSTDCALL put_tabIndex(short v) = 0; - virtual HRESULT wxSTDCALL get_tabIndex(short *p) = 0; - virtual HRESULT wxSTDCALL focus(void) = 0; - virtual HRESULT wxSTDCALL put_accessKey(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_accessKey(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_onblur(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onblur(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onfocus(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onfocus(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onresize(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onresize(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL blur(void) = 0; - virtual HRESULT wxSTDCALL addFilter(IUnknown *pUnk) = 0; - virtual HRESULT wxSTDCALL removeFilter(IUnknown *pUnk) = 0; - virtual HRESULT wxSTDCALL get_clientHeight(long *p) = 0; - virtual HRESULT wxSTDCALL get_clientWidth(long *p) = 0; - virtual HRESULT wxSTDCALL get_clientTop(long *p) = 0; - virtual HRESULT wxSTDCALL get_clientLeft(long *p) = 0; - virtual HRESULT wxSTDCALL attachEvent(BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL detachEvent(BSTR event, IDispatch *pDisp) = 0; - virtual HRESULT wxSTDCALL get_readyState(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onreadystatechange(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onreadystatechange(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onrowsdelete(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onrowsdelete(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_onrowsinserted(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onrowsinserted(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_oncellchange(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_oncellchange(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL put_dir(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_dir(BSTR *p) = 0; - virtual HRESULT wxSTDCALL createControlRange(IDispatch **range) = 0; - virtual HRESULT wxSTDCALL get_scrollHeight(long *p) = 0; - virtual HRESULT wxSTDCALL get_scrollWidth(long *p) = 0; - virtual HRESULT wxSTDCALL put_scrollTop(long v) = 0; - virtual HRESULT wxSTDCALL get_scrollTop(long *p) = 0; - virtual HRESULT wxSTDCALL put_scrollLeft(long v) = 0; - virtual HRESULT wxSTDCALL get_scrollLeft(long *p) = 0; - virtual HRESULT wxSTDCALL clearAttributes(void) = 0; - virtual HRESULT wxSTDCALL mergeAttributes(IHTMLElement *mergeThis) = 0; - virtual HRESULT wxSTDCALL put_oncontextmenu(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_oncontextmenu(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL insertAdjacentElement(BSTR where, IHTMLElement *insertedElement, IHTMLElement **inserted) = 0; - virtual HRESULT wxSTDCALL applyElement(IHTMLElement *apply, BSTR where, IHTMLElement **applied) = 0; - virtual HRESULT wxSTDCALL getAdjacentText(BSTR where, BSTR *text) = 0; - virtual HRESULT wxSTDCALL replaceAdjacentText(BSTR where, BSTR newText, BSTR *oldText) = 0; - virtual HRESULT wxSTDCALL get_canHaveChildren(VARIANT_BOOL *p) = 0; - virtual HRESULT wxSTDCALL addBehavior(BSTR bstrUrl, VARIANT *pvarFactory, long *pCookie) = 0; - virtual HRESULT wxSTDCALL removeBehavior(long cookie, VARIANT_BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL get_runtimeStyle(wxIHTMLStyle **p) = 0; - virtual HRESULT wxSTDCALL get_behaviorUrns(IDispatch **p) = 0; - virtual HRESULT wxSTDCALL put_tagUrn(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_tagUrn(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_onbeforeeditfocus(VARIANT v) = 0; - virtual HRESULT wxSTDCALL get_onbeforeeditfocus(VARIANT *p) = 0; - virtual HRESULT wxSTDCALL get_readyStateValue(long *p) = 0; - virtual HRESULT wxSTDCALL getElementsByTagName(BSTR v, - wxIHTMLElementCollection **pelColl) = 0; -}; - -struct wxIHTMLTxtRange : public IDispatch -{ -public: - virtual HRESULT wxSTDCALL get_htmlText(BSTR *p) = 0; - virtual HRESULT wxSTDCALL put_text(BSTR v) = 0; - virtual HRESULT wxSTDCALL get_text(BSTR *p) = 0; - virtual HRESULT wxSTDCALL parentElement(IHTMLElement **parent) = 0; - virtual HRESULT wxSTDCALL duplicate(wxIHTMLTxtRange **Duplicate) = 0; - virtual HRESULT wxSTDCALL inRange(wxIHTMLTxtRange *Range, VARIANT_BOOL *InRange) = 0; - virtual HRESULT wxSTDCALL isEqual(wxIHTMLTxtRange *Range, VARIANT_BOOL *IsEqual) = 0; - virtual HRESULT wxSTDCALL scrollIntoView(VARIANT_BOOL fStart = -1) = 0; - virtual HRESULT wxSTDCALL collapse(VARIANT_BOOL Start = -1) = 0; - virtual HRESULT wxSTDCALL expand(BSTR Unit, VARIANT_BOOL *Success) = 0; - virtual HRESULT wxSTDCALL move(BSTR Unit, long Count, long *ActualCount) = 0; - virtual HRESULT wxSTDCALL moveStart(BSTR Unit, long Count, long *ActualCount) = 0; - virtual HRESULT wxSTDCALL moveEnd(BSTR Unit, long Count, long *ActualCount) = 0; - virtual HRESULT wxSTDCALL select(void) = 0; - virtual HRESULT wxSTDCALL pasteHTML(BSTR html) = 0; - virtual HRESULT wxSTDCALL moveToElementText(IHTMLElement *element) = 0; - virtual HRESULT wxSTDCALL setEndPoint(BSTR how, wxIHTMLTxtRange *SourceRange) = 0; - virtual HRESULT wxSTDCALL compareEndPoints(BSTR how, wxIHTMLTxtRange *SourceRange, long *ret) = 0; - virtual HRESULT wxSTDCALL findText(BSTR String, long count, long Flags, VARIANT_BOOL *Success) = 0; - virtual HRESULT wxSTDCALL moveToPoint(long x, long y) = 0; - virtual HRESULT wxSTDCALL getBookmark(BSTR *Boolmark) = 0; - virtual HRESULT wxSTDCALL moveToBookmark(BSTR Bookmark, VARIANT_BOOL *Success) = 0; - virtual HRESULT wxSTDCALL queryCommandSupported(BSTR cmdID, VARIANT_BOOL *pfRet) = 0; - virtual HRESULT wxSTDCALL queryCommandEnabled(BSTR cmdID, VARIANT_BOOL *pfRet) = 0; - virtual HRESULT wxSTDCALL queryCommandState(BSTR cmdID, VARIANT_BOOL *pfRet) = 0; - virtual HRESULT wxSTDCALL queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL *pfRet) = 0; - virtual HRESULT wxSTDCALL queryCommandText(BSTR cmdID, BSTR *pcmdText) = 0; - virtual HRESULT wxSTDCALL queryCommandValue(BSTR cmdID, VARIANT *pcmdValue) = 0; - virtual HRESULT wxSTDCALL execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet) = 0; - virtual HRESULT wxSTDCALL execCommandShowHelp(BSTR cmdID, VARIANT_BOOL *pfRet) = 0; -}; - -struct wxIMarkupContainer : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL OwningDoc(IHTMLDocument2 **ppDoc) = 0; -}; - -struct wxIMarkupPointer : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL OwningDoc(IHTMLDocument2 **ppDoc) = 0; - virtual HRESULT wxSTDCALL Gravity(wxPOINTER_GRAVITY *pGravity) = 0; - virtual HRESULT wxSTDCALL SetGravity(wxPOINTER_GRAVITY Gravity) = 0; - virtual HRESULT wxSTDCALL Cling(BOOL *pfCling) = 0; - virtual HRESULT wxSTDCALL SetCling(BOOL fCLing) = 0; - virtual HRESULT wxSTDCALL Unposition(void) = 0; - virtual HRESULT wxSTDCALL IsPositioned(BOOL *pfPositioned) = 0; - virtual HRESULT wxSTDCALL GetContainer(wxIMarkupContainer **ppContainer) = 0; - virtual HRESULT wxSTDCALL MoveAdjacentToElement(IHTMLElement *pElement, wxELEMENT_ADJACENCY eAdj) = 0; - virtual HRESULT wxSTDCALL MoveToPointer(wxIMarkupPointer *pPointer) = 0; - virtual HRESULT wxSTDCALL MoveToContainer(wxIMarkupContainer *pContainer, BOOL fAtStart) = 0; - virtual HRESULT wxSTDCALL Left(BOOL fMove, wxMARKUP_CONTEXT_TYPE *pContext, IHTMLElement **ppElement, long *pcch, OLECHAR *pchText) = 0; - virtual HRESULT wxSTDCALL Right(BOOL fMove, wxMARKUP_CONTEXT_TYPE *pContext, IHTMLElement **ppElement, long *pcch, OLECHAR *pchText) = 0; - virtual HRESULT wxSTDCALL CurrentScope(IHTMLElement **ppElemCurrent) = 0; - virtual HRESULT wxSTDCALL IsLeftOf(wxIMarkupPointer *pPointerThat, BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL IsLeftOfOrEqualTo(wxIMarkupPointer *pPointerThat, BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL IsRightOf(wxIMarkupPointer *pPointerThat, BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL IsRightOfOrEqualTo(wxIMarkupPointer *pPointerThat, BOOL *pfResult) = 0; - virtual HRESULT wxSTDCALL IsEqualTo(wxIMarkupPointer *pPointerThat, BOOL *pfAreEqual) = 0; - virtual HRESULT wxSTDCALL MoveUnit(wxMOVEUNIT_ACTION muAction) = 0; - virtual HRESULT wxSTDCALL FindText(OLECHAR *pchFindText, DWORD dwFlags, wxIMarkupPointer *pIEndMatch, wxIMarkupPointer *pIEndSearch) = 0; -}; - -struct wxIMarkupServices : public IUnknown -{ -public: - virtual HRESULT wxSTDCALL CreateMarkupPointer(wxIMarkupPointer **ppPointer) = 0; - virtual HRESULT wxSTDCALL CreateMarkupContainer(wxIMarkupContainer **ppMarkupContainer) = 0; - virtual HRESULT wxSTDCALL CreateElement(wxELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement) = 0; - virtual HRESULT wxSTDCALL CloneElement(IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone) = 0; - virtual HRESULT wxSTDCALL InsertElement(IHTMLElement *pElementInsert, wxIMarkupPointer *pPointerStart, wxIMarkupPointer *pPointerFinish) = 0; - virtual HRESULT wxSTDCALL RemoveElement(IHTMLElement *pElementRemove) = 0; - virtual HRESULT wxSTDCALL Remove(wxIMarkupPointer *pPointerStart, wxIMarkupPointer *pPointerFinish) = 0; - virtual HRESULT wxSTDCALL Copy(wxIMarkupPointer *pPointerSourceStart, wxIMarkupPointer *pPointerSourceFinish, wxIMarkupPointer *pPointerTarget) = 0; - virtual HRESULT wxSTDCALL Move(wxIMarkupPointer *pPointerSourceStart, wxIMarkupPointer *pPointerSourceFinish, wxIMarkupPointer *pPointerTarget) = 0; - virtual HRESULT wxSTDCALL InsertText(OLECHAR *pchText, long cch, wxIMarkupPointer *pPointerTarget) = 0; - virtual HRESULT wxSTDCALL ParseString(OLECHAR *pchHTML, DWORD dwFlags, wxIMarkupContainer **ppContainerResult, wxIMarkupPointer *ppPointerStart, wxIMarkupPointer *ppPointerFinish) = 0; - virtual HRESULT wxSTDCALL ParseGlobal(HGLOBAL hglobalHTML, DWORD dwFlags, wxIMarkupContainer **ppContainerResult, wxIMarkupPointer *pPointerStart, wxIMarkupPointer *pPointerFinish) = 0; - virtual HRESULT wxSTDCALL IsScopedElement(IHTMLElement *pElement, BOOL *pfScoped) = 0; - virtual HRESULT wxSTDCALL GetElementTagId(IHTMLElement *pElement, wxELEMENT_TAG_ID *ptagId) = 0; - virtual HRESULT wxSTDCALL GetTagIDForName(BSTR bstrName, wxELEMENT_TAG_ID *ptagId) = 0; - virtual HRESULT wxSTDCALL GetNameForTagID(wxELEMENT_TAG_ID tagId, BSTR *pbstrName) = 0; - virtual HRESULT wxSTDCALL MovePointersToRange(wxIHTMLTxtRange *pIRange, wxIMarkupPointer *pPointerStart, wxIMarkupPointer *pPointerFinish) = 0; - virtual HRESULT wxSTDCALL MoveRangeToPointers(wxIMarkupPointer *pPointerStart, wxIMarkupPointer *pPointerFinish, wxIHTMLTxtRange *pIRange) = 0; - virtual HRESULT wxSTDCALL BeginUndoUnit(OLECHAR *pchTitle) = 0; - virtual HRESULT wxSTDCALL EndUndoUnit(void) = 0; -}; - -/* end of mshtml.h */ - -/* WinInet.h */ - -#ifndef HTTP_STATUS_BAD_REQUEST -#define HTTP_STATUS_BAD_REQUEST 400 -#endif - -#ifndef HTTP_STATUS_DENIED -#define HTTP_STATUS_DENIED 401 -#endif - -#ifndef HTTP_STATUS_PAYMENT_REQ -#define HTTP_STATUS_PAYMENT_REQ 402 -#endif - -#ifndef HTTP_STATUS_FORBIDDEN -#define HTTP_STATUS_FORBIDDEN 403 -#endif - -#ifndef HTTP_STATUS_NOT_FOUND -#define HTTP_STATUS_NOT_FOUND 404 -#endif - -#ifndef HTTP_STATUS_BAD_METHOD -#define HTTP_STATUS_BAD_METHOD 405 -#endif - -#ifndef HTTP_STATUS_NONE_ACCEPTABLE -#define HTTP_STATUS_NONE_ACCEPTABLE 406 -#endif - -#ifndef HTTP_STATUS_PROXY_AUTH_REQ -#define HTTP_STATUS_PROXY_AUTH_REQ 407 -#endif - -#ifndef HTTP_STATUS_REQUEST_TIMEOUT -#define HTTP_STATUS_REQUEST_TIMEOUT 408 -#endif - -#ifndef HTTP_STATUS_CONFLICT -#define HTTP_STATUS_CONFLICT 409 -#endif - -#ifndef HTTP_STATUS_GONE -#define HTTP_STATUS_GONE 410 -#endif - -#ifndef HTTP_STATUS_LENGTH_REQUIRED -#define HTTP_STATUS_LENGTH_REQUIRED 411 -#endif - -#ifndef HTTP_STATUS_PRECOND_FAILED -#define HTTP_STATUS_PRECOND_FAILED 412 -#endif - -#ifndef HTTP_STATUS_REQUEST_TOO_LARGE -#define HTTP_STATUS_REQUEST_TOO_LARGE 413 -#endif - -#ifndef HTTP_STATUS_URI_TOO_LONG -#define HTTP_STATUS_URI_TOO_LONG 414 -#endif - -#ifndef HTTP_STATUS_UNSUPPORTED_MEDIA -#define HTTP_STATUS_UNSUPPORTED_MEDIA 415 -#endif - -#ifndef HTTP_STATUS_RETRY_WITH -#define HTTP_STATUS_RETRY_WITH 449 -#endif - -#ifndef HTTP_STATUS_SERVER_ERROR -#define HTTP_STATUS_SERVER_ERROR 500 -#endif - -#ifndef HTTP_STATUS_NOT_SUPPORTED -#define HTTP_STATUS_NOT_SUPPORTED 501 -#endif - -#ifndef HTTP_STATUS_BAD_GATEWAY -#define HTTP_STATUS_BAD_GATEWAY 502 -#endif - -#ifndef HTTP_STATUS_SERVICE_UNAVAIL -#define HTTP_STATUS_SERVICE_UNAVAIL 503 -#endif - -#ifndef HTTP_STATUS_GATEWAY_TIMEOUT -#define HTTP_STATUS_GATEWAY_TIMEOUT 504 -#endif - -#ifndef HTTP_STATUS_VERSION_NOT_SUP -#define HTTP_STATUS_VERSION_NOT_SUP 505 -#endif - -/* end of WinInet.h */ - diff --git a/Source/3rd Party/wx/include/wx/msw/webviewhistoryitem_ie.h b/Source/3rd Party/wx/include/wx/msw/webviewhistoryitem_ie.h deleted file mode 100644 index 6edfbb393..000000000 --- a/Source/3rd Party/wx/include/wx/msw/webviewhistoryitem_ie.h +++ /dev/null @@ -1,30 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: include/wx/msw/webviewhistoryitem.h -// Purpose: wxWebViewHistoryItem header for MSW -// Author: Steven Lamerton -// Copyright: (c) 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_WEBVIEWHISTORYITEM_H_ -#define _WX_MSW_WEBVIEWHISTORYITEM_H_ - -#include "wx/setup.h" - -#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) - -class WXDLLIMPEXP_WEBVIEW wxWebViewHistoryItem -{ -public: - wxWebViewHistoryItem(const wxString& url, const wxString& title) : - m_url(url), m_title(title) {} - wxString GetUrl() { return m_url; } - wxString GetTitle() { return m_title; } - -private: - wxString m_url, m_title; -}; - -#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) - -#endif // _WX_MSW_WEBVIEWHISTORYITEM_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/window.h b/Source/3rd Party/wx/include/wx/msw/window.h index 57325878c..b765ac1db 100644 --- a/Source/3rd Party/wx/include/wx/msw/window.h +++ b/Source/3rd Party/wx/include/wx/msw/window.h @@ -5,6 +5,7 @@ // Modified by: Vadim Zeitlin on 13.05.99: complete refont of message handling, // elimination of Default(), ... // Created: 01/02/97 +// RCS-ID: $Id: window.h 53929 2008-06-02 18:27:16Z RD $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,23 +13,24 @@ #ifndef _WX_WINDOW_H_ #define _WX_WINDOW_H_ -#include "wx/settings.h" // solely for wxSystemColour +// --------------------------------------------------------------------------- +// constants +// --------------------------------------------------------------------------- -// if this is set to 1, we use deferred window sizing to reduce flicker when -// resizing complicated window hierarchies, but this can in theory result in -// different behaviour than the old code so we keep the possibility to use it -// by setting this to 0 (in the future this should be removed completely) -#ifdef __WXWINCE__ - #define wxUSE_DEFERRED_SIZING 0 -#else - #define wxUSE_DEFERRED_SIZING 1 +#if WXWIN_COMPATIBILITY_2_4 +// they're unused by wxWidgets... +enum +{ + wxKEY_SHIFT = 1, + wxKEY_CTRL = 2 +}; #endif // --------------------------------------------------------------------------- // wxWindow declaration for MSW // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowMSW : public wxWindowBase +class WXDLLEXPORT wxWindowMSW : public wxWindowBase { friend class wxSpinCtrl; friend class wxSlider; @@ -66,20 +68,8 @@ public: virtual void Raise(); virtual void Lower(); - virtual bool BeginRepositioningChildren(); - virtual void EndRepositioningChildren(); - - virtual bool Show(bool show = true); - virtual bool ShowWithEffect(wxShowEffect effect, - unsigned timeout = 0) - { - return MSWShowWithEffect(true, effect, timeout); - } - virtual bool HideWithEffect(wxShowEffect effect, - unsigned timeout = 0) - { - return MSWShowWithEffect(false, effect, timeout); - } + virtual bool Show( bool show = true ); + virtual bool Enable( bool enable = true ); virtual void SetFocus(); virtual void SetFocusFromKbd(); @@ -91,6 +81,9 @@ public: virtual void Refresh( bool eraseBackground = true, const wxRect *rect = (const wxRect *) NULL ); virtual void Update(); + virtual void Freeze(); + virtual void Thaw(); + virtual bool IsFrozen() const { return m_frozenness > 0; } virtual void SetWindowStyleFlag(long style); virtual void SetExtraStyle(long exStyle); @@ -99,6 +92,12 @@ public: virtual int GetCharHeight() const; virtual int GetCharWidth() const; + virtual void GetTextExtent(const wxString& string, + int *x, int *y, + int *descent = (int *) NULL, + int *externalLeading = (int *) NULL, + const wxFont *theFont = (const wxFont *) NULL) + const; virtual void SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh = true ); @@ -107,7 +106,7 @@ public: virtual int GetScrollThumb( int orient ) const; virtual int GetScrollRange( int orient ) const; virtual void ScrollWindow( int dx, int dy, - const wxRect* rect = NULL ); + const wxRect* rect = (wxRect *) NULL ); virtual bool ScrollLines(int lines); virtual bool ScrollPages(int pages); @@ -125,6 +124,12 @@ public: // Accept files for dragging virtual void DragAcceptFiles(bool accept); +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( bool GetUseCtl3D() const ); + wxDEPRECATED( bool GetTransparentBackground() const ); + wxDEPRECATED( void SetTransparent(bool t = true) ); +#endif // WXWIN_COMPATIBILITY_2_4 + #ifndef __WXUNIVERSAL__ // Native resource loading (implemented in src/msw/nativdlg.cpp) // FIXME: should they really be all virtual? @@ -158,29 +163,6 @@ public: // does this window have deferred position and/or size? bool IsSizeDeferred() const; - // these functions allow to register a global handler for the given Windows - // message: it will be called from MSWWindowProc() of any window which gets - // this event if it's not processed before (i.e. unlike a hook procedure it - // does not override the normal processing) - // - // notice that if you want to process a message for a given window only you - // should override its MSWWindowProc() instead - - // type of the handler: it is called with the message parameters (except - // that the window object is passed instead of window handle) and should - // return true if it handled the message or false if it should be passed to - // DefWindowProc() - typedef bool (*MSWMessageHandler)(wxWindowMSW *win, - WXUINT nMsg, - WXWPARAM wParam, - WXLPARAM lParam); - - // install a handler, shouldn't be called more than one for the same message - static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler); - - // unregister a previously registered handler - static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler); - // implementation from now on // ========================== @@ -189,6 +171,7 @@ public: // -------------- void OnPaint(wxPaintEvent& event); + void OnEraseBackground(wxEraseEvent& event); #ifdef __WXWINCE__ void OnInitDialog(wxInitDialogEvent& event); #endif @@ -206,7 +189,7 @@ public: // to understand why does it work, look at SubclassWin() code and comments bool IsOfStandardClass() const { return m_oldWndProc != NULL; } - wxWindow *FindItem(long id, WXHWND hWnd = NULL) const; + wxWindow *FindItem(long id) const; wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const; // MSW only: true if this control is part of the main control @@ -236,12 +219,24 @@ public: // created yet) void MSWUpdateStyle(long flagsOld, long exflagsOld); +#if wxABI_VERSION >= 20805 + // Helper for getting an appropriate theme style for the application. Unnecessary in + // 2.9 and above. + wxBorder GetThemedBorderStyle() const; +#endif + + // translate wxWidgets coords into Windows ones suitable to be passed to + // ::CreateWindow() + // + // returns true if non default coords are returned, false otherwise + bool MSWGetCreateWindowCoords(const wxPoint& pos, + const wxSize& size, + int& x, int& y, + int& w, int& h) const; + // get the HWND to be used as parent of this window with CreateWindow() virtual WXHWND MSWGetParent() const; - // get the Win32 window class name used by all wxWindow objects by default - static const wxChar *MSWGetRegisteredClassName(); - // creates the window of specified Windows class with given style, extended // style, title and geometry (default values // @@ -320,8 +315,6 @@ public: bool HandleSize(int x, int y, WXUINT flag); bool HandleSizing(wxRect& rect); bool HandleGetMinMaxInfo(void *mmInfo); - bool HandleEnterSizeMove(); - bool HandleExitSizeMove(); bool HandleShow(bool show, int status); bool HandleActivate(int flag, bool minimized, WXHWND activate); @@ -347,13 +340,12 @@ public: bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags); bool HandleMouseMove(int x, int y, WXUINT flags); - bool HandleMouseWheel(wxMouseWheelAxis axis, - WXWPARAM wParam, WXLPARAM lParam); + bool HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam); - bool HandleChar(WXWPARAM wParam, WXLPARAM lParam); + bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = false); bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam); bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam); -#if wxUSE_HOTKEY +#if wxUSE_ACCEL bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam); #endif #ifdef __WIN32__ @@ -369,21 +361,7 @@ public: bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed); - // The main body of common window proc for all wxWindow objects. It tries - // to handle the given message and returns true if it was handled (the - // appropriate return value is then put in result, which must be non-NULL) - // or false if it wasn't. - // - // This function should be overridden in any new code instead of - // MSWWindowProc() even if currently most of the code overrides - // MSWWindowProc() as it had been written before this function was added. - virtual bool MSWHandleMessage(WXLRESULT *result, - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam); - - // Common Window procedure for all wxWindow objects: forwards to - // MSWHandleMessage() and MSWDefWindowProc() if the message wasn't handled. + // Window procedure virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); // Calls an appropriate default window procedure @@ -405,61 +383,21 @@ public: virtual void MSWDestroyWindow(); - // Functions dealing with painting the window background. The derived - // classes should normally only need to reimplement MSWGetBgBrush() if they - // need to use a non-solid brush for erasing their background. This - // function is called by MSWGetBgBrushForChild() which only exists for the - // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by - // MSWGetBgBrush() to actually find the right brush to use. - - // Adjust the origin for the brush returned by MSWGetBgBrushForChild(). - // - // This needs to be overridden for scrolled windows to ensure that the - // scrolling of their associated DC is taken into account. - // - // Both parameters must be non-NULL. - virtual void MSWAdjustBrushOrg(int* WXUNUSED(xOrg), - int* WXUNUSED(yOrg)) const - { - } - - // The brush returned from here must remain valid at least until the next - // event loop iteration. Returning 0, as is done by default, indicates - // there is no custom background brush. - virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; } - // this function should return the brush to paint the children controls // background or 0 if this window doesn't impose any particular background // on its children // - // the hDC parameter is the DC background will be drawn on, it can be used - // to call SetBrushOrgEx() on it if the returned brush is a bitmap one - // - // child parameter is never NULL, it can be this window itself or one of - // its (grand)children - // // the base class version returns a solid brush if we have a non default // background colour or 0 otherwise - virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child); + virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd); // return the background brush to use for painting the given window by - // querying the parent windows via MSWGetBgBrushForChild() recursively - WXHBRUSH MSWGetBgBrush(WXHDC hDC); - - enum MSWThemeColour - { - ThemeColourText = 0, - ThemeColourBackground, - ThemeColourBorder - }; - - // returns a specific theme colour, or if that is not possible then - // wxSystemSettings::GetColour(fallback) - wxColour MSWGetThemeColour(const wchar_t *themeName, - int themePart, - int themeState, - MSWThemeColour themeColour, - wxSystemColour fallback) const; + // quering the parent windows via their MSWGetBgBrushForChild() recursively + // + // hWndToPaint is normally NULL meaning this window itself, but it can also + // be a child of this window which is used by the static box and could be + // potentially useful for other transparent controls + WXHBRUSH MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint = NULL); // gives the parent the possibility to draw its children background, e.g. // this is used by wxNotebook to do it using DrawThemeBackground() @@ -478,42 +416,6 @@ public: return true; } - // This should be overridden to return true for the controls which have - // themed background that should through their children. Currently only - // wxNotebook uses this. - // - // The base class version already returns true if we have a solid - // background colour that should be propagated to our children. - virtual bool MSWHasInheritableBackground() const - { - return InheritsBackgroundColour(); - } - -#if !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__) - #define wxHAS_MSW_BACKGROUND_ERASE_HOOK -#endif - -#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK - // allows the child to hook into its parent WM_ERASEBKGND processing: call - // MSWSetEraseBgHook() with a non-NULL window to make parent call - // MSWEraseBgHook() on this window (don't forget to reset it to NULL - // afterwards) - // - // this hack is used by wxToolBar, see comments there - void MSWSetEraseBgHook(wxWindow *child); - - // return true if WM_ERASEBKGND is currently hooked - bool MSWHasEraseBgHook() const; - - // called when the window on which MSWSetEraseBgHook() had been called - // receives WM_ERASEBKGND - virtual bool MSWEraseBgHook(WXHDC WXUNUSED(hDC)) { return false; } -#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK - - // common part of Show/HideWithEffect() - bool MSWShowWithEffect(bool show, - wxShowEffect effect, - unsigned timeout); // Responds to colour changes: passes event on to children. void OnSysColourChanged(wxSysColourChangedEvent& event); @@ -526,9 +428,11 @@ public: // check if a native double-buffering applies for this window virtual bool IsDoubleBuffered() const; - + +#if wxABI_VERSION >= 20808 void SetDoubleBuffered(bool on); - +#endif + // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false void GenerateMouseLeave(); @@ -537,17 +441,6 @@ public: virtual void OnInternalIdle(); protected: - // this allows you to implement standard control borders without - // repeating the code in different classes that are not derived from - // wxControl - virtual wxBorder GetDefaultBorderForControl() const; - - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const; - - // Translate wxBORDER_THEME (and other border styles if necessary to the value - // that makes most sense for this Windows environment - virtual wxBorder TranslateBorder(wxBorder border) const; #if wxUSE_MENUS_NATIVE virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); @@ -568,11 +461,6 @@ protected: int m_yThumbSize; // implement the base class pure virtuals - virtual void DoGetTextExtent(const wxString& string, - int *x, int *y, - int *descent = NULL, - int *externalLeading = NULL, - const wxFont *font = NULL) const; virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoGetPosition( int *x, int *y ) const; @@ -583,16 +471,9 @@ protected: int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); - virtual wxSize DoGetBorderSize() const; - virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - virtual void DoEnable(bool enable); - - virtual void DoFreeze(); - virtual void DoThaw(); - // this simply moves/resizes the given HWND which is supposed to be our // sibling (this is useful for controls which are composite at MSW level // and for which DoMoveWindow() is not enough) @@ -617,29 +498,9 @@ protected: const wxString& ttip); #endif // wxUSE_TOOLTIPS - // This is used by CreateKeyEvent() and also for wxEVT_CHAR[_HOOK] event - // creation. Notice that this method doesn't initialize wxKeyEvent - // m_keyCode and m_uniChar fields. - void InitAnyKeyEvent(wxKeyEvent& event, - WXWPARAM wParam, - WXLPARAM lParam) const; - - // Helper functions used by HandleKeyXXX() methods and some derived - // classes, wParam and lParam have the same meaning as in WM_KEY{DOWN,UP}. - // - // NB: evType here must be wxEVT_KEY_{DOWN,UP} as wParam here contains the - // virtual key code, not character! - wxKeyEvent CreateKeyEvent(wxEventType evType, - WXWPARAM wParam, - WXLPARAM lParam = 0) const; - - // Another helper for creating wxKeyEvent for wxEVT_CHAR and related types. - // - // The wParam and lParam here must come from WM_CHAR event parameters, i.e. - // wParam must be a character and not a virtual code. - wxKeyEvent CreateCharEvent(wxEventType evType, - WXWPARAM wParam, - WXLPARAM lParam) const; + // the helper functions used by HandleChar/KeyXXX methods + wxKeyEvent CreateKeyEvent(wxEventType evType, int id, + WXLPARAM lParam = 0, WXWPARAM wParam = 0) const; // default OnEraseBackground() implementation, return true if we did erase @@ -654,24 +515,6 @@ protected: // for state as the system will decide for us what needs to be set void MSWUpdateUIState(int action, int state = 0); - // translate wxWidgets coords into Windows ones suitable to be passed to - // ::CreateWindow(), called from MSWCreate() - virtual void MSWGetCreateWindowCoords(const wxPoint& pos, - const wxSize& size, - int& x, int& y, - int& w, int& h) const; - - bool MSWEnableHWND(WXHWND hWnd, bool enable); - - // Return the pointer to this window or one of its sub-controls if this ID - // and HWND combination belongs to one of them. - // - // This is used by FindItem() and is overridden in wxControl, see there. - virtual wxWindow* MSWFindItem(long WXUNUSED(id), WXHWND WXUNUSED(hWnd)) const - { - return NULL; - } - private: // common part of all ctors void Init(); @@ -682,31 +525,21 @@ private: bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags); bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); -#ifndef __WXUNIVERSAL__ - // Call ::IsDialogMessage() if it is safe to do it (i.e. if it's not going - // to hang or do something else stupid) with the given message, return true - // if the message was handled by it. - bool MSWSafeIsDialogMessage(WXMSG* msg); -#endif // __WXUNIVERSAL__ + // list of disabled children before last call to our Disable() + wxWindowList *m_childrenDisabled; -#if wxUSE_DEFERRED_SIZING -protected: - // this function is called after the window was resized to its new size - virtual void MSWEndDeferWindowPos() - { - m_pendingPosition = wxDefaultPosition; - m_pendingSize = wxDefaultSize; - } + // number of calls to Freeze() minus number of calls to Thaw() + unsigned int m_frozenness; // current defer window position operation handle (may be NULL) WXHANDLE m_hDWP; +protected: // When deferred positioning is done these hold the pending changes, and // are used for the default values if another size/pos changes is done on // this window before the group of deferred changes is completed. wxPoint m_pendingPosition; wxSize m_pendingSize; -#endif // wxUSE_DEFERRED_SIZING private: #ifdef __POCKETPC__ @@ -714,10 +547,30 @@ private: #endif DECLARE_DYNAMIC_CLASS(wxWindowMSW) - wxDECLARE_NO_COPY_CLASS(wxWindowMSW); + DECLARE_NO_COPY_CLASS(wxWindowMSW) DECLARE_EVENT_TABLE() }; +// ---------------------------------------------------------------------------- +// inline functions +// ---------------------------------------------------------------------------- + +#if WXWIN_COMPATIBILITY_2_4 + +inline bool wxWindowMSW::GetUseCtl3D() const { return false; } +inline bool wxWindowMSW::GetTransparentBackground() const { return false; } +inline void wxWindowMSW::SetTransparent(bool WXUNUSED(t)) { } + +#endif // WXWIN_COMPATIBILITY_2_4 + +// --------------------------------------------------------------------------- +// global functions +// --------------------------------------------------------------------------- + +// kbd code translation +WXDLLEXPORT int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam = 0); +WXDLLEXPORT WXWORD wxCharCodeWXToMSW(int id, bool *IsVirtual = NULL); + // window creation helper class: before creating a new HWND, instantiate an // object of this class on stack - this allows to process the messages sent to // the window even before CreateWindow() returns @@ -728,4 +581,21 @@ public: ~wxWindowCreationHook(); }; +// ---------------------------------------------------------------------------- +// global objects +// ---------------------------------------------------------------------------- + +// notice that this hash must be defined after wxWindow declaration as it +// needs to "see" its dtor and not just forward declaration +#include "wx/hash.h" + +// pseudo-template HWND <-> wxWindow hash table +#if WXWIN_COMPATIBILITY_2_4 +WX_DECLARE_HASH(wxWindow, wxWindowList, wxWinHashTable); +#else +WX_DECLARE_HASH(wxWindowMSW, wxWindowList, wxWinHashTable); +#endif + +extern wxWinHashTable *wxWinHandleHash; + #endif // _WX_WINDOW_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/winundef.h b/Source/3rd Party/wx/include/wx/msw/winundef.h index cdcaffbf9..b8acb68b7 100644 --- a/Source/3rd Party/wx/include/wx/msw/winundef.h +++ b/Source/3rd Party/wx/include/wx/msw/winundef.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 16.05.99 +// RCS-ID: $Id: winundef.h 36044 2005-10-31 19:35:41Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -122,11 +123,11 @@ inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) { - #ifdef _UNICODE + #ifdef UNICODE return FindTextW(lpfindreplace); #else return FindTextA(lpfindreplace); - #endif + #endif // !UNICODE } #endif @@ -247,20 +248,26 @@ #endif +/* + When this file is included, sometimes the wxCHECK_W32API_VERSION macro + is undefined. With for example CodeWarrior this gives problems with + the following code: + #if 0 && wxCHECK_W32API_VERSION( 0, 5 ) + Because CodeWarrior does macro expansion before test evaluation. + We define wxCHECK_W32API_VERSION here if it's undefined. +*/ +#if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION) + #define wxCHECK_W32API_VERSION(maj, min) (0) +#endif + // StartDoc #ifdef StartDoc #undef StartDoc - - // Work around a bug in very old MinGW headers that didn't define DOCINFOW - // and DOCINFOA but only DOCINFO in both ANSI and Unicode. - #if defined( __GNUG__ ) - #if !wxCHECK_W32API_VERSION( 0, 5 ) - #define DOCINFOW DOCINFO - #define DOCINFOA DOCINFO - #endif + #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 ) + #define DOCINFOW DOCINFO + #define DOCINFOA DOCINFO #endif - #ifdef _UNICODE inline int StartDoc(HDC h, CONST DOCINFOW* info) { diff --git a/Source/3rd Party/wx/include/wx/msw/wrapcctl.h b/Source/3rd Party/wx/include/wx/msw/wrapcctl.h index 208c6f189..eaa68be04 100644 --- a/Source/3rd Party/wx/include/wx/msw/wrapcctl.h +++ b/Source/3rd Party/wx/include/wx/msw/wrapcctl.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.08.2003 +// RCS-ID: $Id: wrapcctl.h 41054 2006-09-07 19:01:45Z ABX $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,6 +12,28 @@ #ifndef _WX_MSW_WRAPCCTL_H_ #define _WX_MSW_WRAPCCTL_H_ +// define _WIN32_IE to a high value because we always check for the version +// of installed DLLs at runtime anyway (see wxApp::GetComCtl32Version()) unless +// the user really doesn't want it and had defined it to a (presumably lower) +// value +// +// just for the reference, here is the table showing what the different value +// of _WIN32_IE correspond to: +// +// 0x0200 for comctl32.dll 4.00 shipped with Win95/NT 4.0 +// 0x0300 4.70 IE 3.x +// 0x0400 4.71 IE 4.0 +// 0x0401 4.72 IE 4.01 and Win98 +// 0x0500 5.80 IE 5.x +// 0x0500 5.81 Win2k/ME +// 0x0600 6.00 WinXP + +#ifndef _WIN32_IE + // use maximal set of features by default, we check for them during + // run-time anyhow + #define _WIN32_IE 0x0600 +#endif // !defined(_WIN32_IE) + #include "wx/msw/wrapwin.h" #include @@ -34,17 +57,6 @@ inline void wxSetCCUnicodeFormat(HWND WXUNUSED_IN_WINCE(hwnd)) // this is implemented in msw/settings.cpp class wxFont; extern wxFont wxGetCCDefaultFont(); - -// this is just a wrapper for HDITEM which we can't use in the public header -// because we don't want to include commctrl.h (and hence windows.h) from there -struct wxHDITEM : public HDITEM -{ - wxHDITEM() - { - ::ZeroMemory(this, sizeof(*this)); - } -}; - -#endif // wxUSE_GUI +#endif #endif // _WX_MSW_WRAPCCTL_H_ diff --git a/Source/3rd Party/wx/include/wx/msw/wrapcdlg.h b/Source/3rd Party/wx/include/wx/msw/wrapcdlg.h index 6bececdee..907515291 100644 --- a/Source/3rd Party/wx/include/wx/msw/wrapcdlg.h +++ b/Source/3rd Party/wx/include/wx/msw/wrapcdlg.h @@ -4,6 +4,7 @@ // Author: Wlodzimierz ABX Skiba // Modified by: // Created: 22.03.2005 +// RCS-ID: $Id: wrapcdlg.h 43151 2006-11-07 09:08:33Z JS $ // Copyright: (c) 2005 Wlodzimierz Skiba // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/msw/wrapgdip.h b/Source/3rd Party/wx/include/wx/msw/wrapgdip.h deleted file mode 100644 index 04d4009a6..000000000 --- a/Source/3rd Party/wx/include/wx/msw/wrapgdip.h +++ /dev/null @@ -1,31 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/wrapgdip.h -// Purpose: wrapper around header -// Author: Vadim Zeitlin -// Created: 2007-03-15 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_MSW_WRAPGDIP_H_ -#define _WX_MSW_WRAPGDIP_H_ - -#include "wx/msw/wrapwin.h" - -// these macros must be defined before gdiplus.h is included but we explicitly -// prevent windows.h from defining them in wx/msw/wrapwin.h as they conflict -// with standard functions of the same name elsewhere, so we have to pay for it -// by manually redefining them ourselves here -#ifndef max - #define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#include -using namespace Gdiplus; - -#endif // _WX_MSW_WRAPGDIP_H_ - diff --git a/Source/3rd Party/wx/include/wx/msw/wrapshl.h b/Source/3rd Party/wx/include/wx/msw/wrapshl.h index 7eb12241f..282a81c01 100644 --- a/Source/3rd Party/wx/include/wx/msw/wrapshl.h +++ b/Source/3rd Party/wx/include/wx/msw/wrapshl.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2004-10-19 +// RCS-ID: $Id: wrapshl.h 40367 2006-07-29 19:19:50Z VZ $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,21 +12,16 @@ #ifndef _WX_MSW_WRAPSHL_H_ #define _WX_MSW_WRAPSHL_H_ -#include "wx/msw/wrapwin.h" - #ifdef __WXWINCE__ #include #include #include - #include #endif #include #include "wx/msw/winundef.h" -#include "wx/log.h" - // ---------------------------------------------------------------------------- // wxItemIdList implements RAII on top of ITEMIDLIST // ---------------------------------------------------------------------------- @@ -71,7 +67,7 @@ public: wxString path; if ( !SHGetPathFromIDList(m_pidl, wxStringBuffer(path, MAX_PATH)) ) { - wxLogLastError(wxT("SHGetPathFromIDList")); + wxLogLastError(_T("SHGetPathFromIDList")); } return path; @@ -80,7 +76,7 @@ public: private: LPITEMIDLIST m_pidl; - wxDECLARE_NO_COPY_CLASS(wxItemIdList); + DECLARE_NO_COPY_CLASS(wxItemIdList) }; // enable autocompleting filenames in the text control with given HWND diff --git a/Source/3rd Party/wx/include/wx/msw/wrapwin.h b/Source/3rd Party/wx/include/wx/msw/wrapwin.h index 162eade38..d1e6a0a86 100644 --- a/Source/3rd Party/wx/include/wx/msw/wrapwin.h +++ b/Source/3rd Party/wx/include/wx/msw/wrapwin.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msw/wrapwin.h +// Name: msw/wrapwin.h // Purpose: Wrapper around , to be included instead of it // Author: Vaclav Slavik // Created: 2003/07/22 +// RCS-ID: $Id: wrapwin.h 53877 2008-05-31 12:43:44Z SN $ // Copyright: (c) 2003 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -38,30 +39,15 @@ #endif #endif -// define _WIN32_WINNT and _WIN32_IE to the highest possible values because we -// always check for the version of installed DLLs at runtime anyway (see -// wxGetWinVersion() and wxApp::GetComCtl32Version()) unless the user really -// doesn't want to use APIs only available on later OS versions and had defined -// them to (presumably lower) values #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #endif -#ifndef _WIN32_IE - #define _WIN32_IE 0x0700 -#endif - /* Deal with clash with __WINDOWS__ include guard */ #if defined(__WXWINCE__) && defined(__WINDOWS__) #undef __WINDOWS__ #endif -// For IPv6 support, we must include winsock2.h before winsock.h, and -// windows.h include winsock.h so do it before including it -#if wxUSE_IPV6 - #include -#endif - #include #if defined(__WXWINCE__) && !defined(__WINDOWS__) @@ -71,15 +57,13 @@ // #undef the macros defined in winsows.h which conflict with code elsewhere #include "wx/msw/winundef.h" -// Types DWORD_PTR, ULONG_PTR and so on are used for 64-bit compatibility +// Types DWORD_PTR, ULONG_PTR and so on are used for 64-bit compatability // in the WINAPI SDK (they are an integral type that is the size of a -// pointer) on MSVC 7 and later. However, they are not available in older -// Platform SDKs, and since they are typedefs and not #defines we simply +// pointer) on MSVC 7 and later. However, they are not available in older +// Platform SDKs, and since they are typedefs and not #defines we simply // overwrite them if there is a chance that they're not defined #if (!defined(_MSC_VER) || (_MSC_VER < 1300)) && !defined(__WIN64__) #define UINT_PTR unsigned int - #define INT_PTR int - #define HANDLE_PTR unsigned long #define LONG_PTR long #define ULONG_PTR unsigned long #define DWORD_PTR unsigned long @@ -93,7 +77,7 @@ #if wxUSE_GUI -WXDLLIMPEXP_CORE int wxMSLU_DrawStateW(WXHDC dc, WXHBRUSH br, WXFARPROC outputFunc, +WXDLLEXPORT int wxMSLU_DrawStateW(WXHDC dc, WXHBRUSH br, WXFARPROC outputFunc, WXLPARAM lData, WXWPARAM wData, int x, int y, int cx, int cy, unsigned int flags); @@ -101,10 +85,10 @@ WXDLLIMPEXP_CORE int wxMSLU_DrawStateW(WXHDC dc, WXHBRUSH br, WXFARPROC outputFu wxMSLU_DrawStateW((WXHDC)dc,(WXHBRUSH)br,(WXFARPROC)func, \ ld, wd, x, y, cx, cy, flags) -WXDLLIMPEXP_CORE int wxMSLU_GetOpenFileNameW(void *ofn); +WXDLLEXPORT int wxMSLU_GetOpenFileNameW(void *ofn); #define GetOpenFileNameW(ofn) wxMSLU_GetOpenFileNameW((void*)ofn) -WXDLLIMPEXP_CORE int wxMSLU_GetSaveFileNameW(void *ofn); +WXDLLEXPORT int wxMSLU_GetSaveFileNameW(void *ofn); #define GetSaveFileNameW(ofn) wxMSLU_GetSaveFileNameW((void*)ofn) #endif // wxUSE_GUI @@ -113,4 +97,3 @@ WXDLLIMPEXP_CORE int wxMSLU_GetSaveFileNameW(void *ofn); #endif // _WX_WRAPWIN_H_ - diff --git a/Source/3rd Party/wx/include/wx/nativewin.h b/Source/3rd Party/wx/include/wx/nativewin.h deleted file mode 100644 index e0328e958..000000000 --- a/Source/3rd Party/wx/include/wx/nativewin.h +++ /dev/null @@ -1,173 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/nativewin.h -// Purpose: classes allowing to wrap a native window handle -// Author: Vadim Zeitlin -// Created: 2008-03-05 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_NATIVEWIN_H_ -#define _WX_NATIVEWIN_H_ - -#include "wx/toplevel.h" - -// this symbol can be tested in the user code to see if the current wx port has -// support for creating wxNativeContainerWindow from native windows -// -// be optimistic by default, we undefine it below if we don't have it finally -#define wxHAS_NATIVE_CONTAINER_WINDOW - -// we define the following typedefs for each of the platform supporting native -// windows wrapping: -// -// - wxNativeContainerWindowHandle is the toolkit-level handle of the native -// window, i.e. HWND/GdkWindow*/NSWindow -// -// - wxNativeContainerWindowId is the lowest level identifier of the native -// window, i.e. HWND/GdkNativeWindow/NSWindow (so it's the same as above for -// all platforms except GTK where we also can work with Window/XID) -// -// later we'll also have -// -// - wxNativeWindowHandle for child windows (which will be wrapped by -// wxNativeWindow class), it is HWND/GtkWidget*/ControlRef -#if defined(__WXMSW__) - #include "wx/msw/wrapwin.h" - - typedef HWND wxNativeContainerWindowId; - typedef HWND wxNativeContainerWindowHandle; -#elif defined(__WXGTK__) - // GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32 - #ifdef __UNIX__ - typedef unsigned long wxNativeContainerWindowId; - #else - typedef void *wxNativeContainerWindowId; - #endif - typedef GdkWindow *wxNativeContainerWindowHandle; -#else - // no support for using native windows under this platform yet - #undef wxHAS_NATIVE_CONTAINER_WINDOW -#endif - -#ifdef wxHAS_NATIVE_CONTAINER_WINDOW - -// ---------------------------------------------------------------------------- -// wxNativeContainerWindow: can be used for creating other wxWindows inside it -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxNativeContainerWindow : public wxTopLevelWindow -{ -public: - // default ctor, call Create() later - wxNativeContainerWindow() { } - - // create a window from an existing native window handle - // - // use GetHandle() to check if the creation was successful, it will return - // 0 if the handle was invalid - wxNativeContainerWindow(wxNativeContainerWindowHandle handle) - { - Create(handle); - } - - // same as ctor above but with a return code - bool Create(wxNativeContainerWindowHandle handle); - -#if defined(__WXGTK__) - // this is a convenient ctor for wxGTK applications which can also create - // the objects of this class from the really native window handles and not - // only the GdkWindow objects - // - // wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11 - // (when GDK_WINDOWING_X11 is defined) or HWND under Win32 - wxNativeContainerWindow(wxNativeContainerWindowId winid) { Create(winid); } - - bool Create(wxNativeContainerWindowId winid); -#endif // wxGTK - - // unlike for the normal windows, dtor will not destroy the native window - // as it normally doesn't belong to us - virtual ~wxNativeContainerWindow(); - - - // provide (trivial) implementation of the base class pure virtuals - virtual void SetTitle(const wxString& WXUNUSED(title)) - { - wxFAIL_MSG( "not implemented for native windows" ); - } - - virtual wxString GetTitle() const - { - wxFAIL_MSG( "not implemented for native windows" ); - - return wxString(); - } - - virtual void Maximize(bool WXUNUSED(maximize) = true) - { - wxFAIL_MSG( "not implemented for native windows" ); - } - - virtual bool IsMaximized() const - { - wxFAIL_MSG( "not implemented for native windows" ); - - return false; - } - - virtual void Iconize(bool WXUNUSED(iconize) = true) - { - wxFAIL_MSG( "not implemented for native windows" ); - } - - virtual bool IsIconized() const - { - // this is called by wxGTK implementation so don't assert - return false; - } - - virtual void Restore() - { - wxFAIL_MSG( "not implemented for native windows" ); - } - - virtual bool ShowFullScreen(bool WXUNUSED(show), - long WXUNUSED(style) = wxFULLSCREEN_ALL) - { - wxFAIL_MSG( "not implemented for native windows" ); - - return false; - } - - virtual bool IsFullScreen() const - { - wxFAIL_MSG( "not implemented for native windows" ); - - return false; - } - -#ifdef __WXMSW__ - virtual bool IsShown() const; -#endif // __WXMSW__ - - // this is an implementation detail: called when the native window is - // destroyed by an outside agency; deletes the C++ object too but can in - // principle be overridden to something else (knowing that the window - // handle of this object and all of its children is invalid any more) - virtual void OnNativeDestroyed(); - -protected: -#ifdef __WXMSW__ - virtual WXLRESULT - MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); -#endif // __WXMSW__ - -private: - wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow); -}; - -#endif // wxHAS_NATIVE_CONTAINER_WINDOW - -#endif // _WX_NATIVEWIN_H_ - diff --git a/Source/3rd Party/wx/include/wx/nonownedwnd.h b/Source/3rd Party/wx/include/wx/nonownedwnd.h deleted file mode 100644 index 7d8709933..000000000 --- a/Source/3rd Party/wx/include/wx/nonownedwnd.h +++ /dev/null @@ -1,113 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/nonownedwnd.h -// Purpose: declares wxNonTopLevelWindow class -// Author: Vaclav Slavik -// Modified by: -// Created: 2006-12-24 -// Copyright: (c) 2006 TT-Solutions -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_NONOWNEDWND_H_ -#define _WX_NONOWNEDWND_H_ - -#include "wx/window.h" - -// Styles that can be used with any wxNonOwnedWindow: -#define wxFRAME_SHAPED 0x0010 // Create a window that is able to be shaped - -class WXDLLIMPEXP_FWD_CORE wxGraphicsPath; - -// ---------------------------------------------------------------------------- -// wxNonOwnedWindow: a window that is not a child window of another one. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxNonOwnedWindowBase : public wxWindow -{ -public: - // Set the shape of the window to the given region. - // Returns true if the platform supports this feature (and the - // operation is successful.) - bool SetShape(const wxRegion& region) - { - // This style is in fact only needed by wxOSX/Carbon so once we don't - // use this port any more, we could get rid of this requirement, but - // for now you must specify wxFRAME_SHAPED for SetShape() to work on - // all platforms. - wxCHECK_MSG - ( - HasFlag(wxFRAME_SHAPED), false, - wxS("Shaped windows must be created with the wxFRAME_SHAPED style.") - ); - - return region.IsEmpty() ? DoClearShape() : DoSetRegionShape(region); - } - -#if wxUSE_GRAPHICS_CONTEXT - // Set the shape using the specified path. - bool SetShape(const wxGraphicsPath& path) - { - wxCHECK_MSG - ( - HasFlag(wxFRAME_SHAPED), false, - wxS("Shaped windows must be created with the wxFRAME_SHAPED style.") - ); - - return DoSetPathShape(path); - } -#endif // wxUSE_GRAPHICS_CONTEXT - - - // Overridden base class methods. - // ------------------------------ - - virtual void AdjustForParentClientOrigin(int& WXUNUSED(x), int& WXUNUSED(y), - int WXUNUSED(sizeFlags) = 0) const - { - // Non owned windows positions don't need to be adjusted for parent - // client area origin so simply do nothing here. - } - - virtual void InheritAttributes() - { - // Non owned windows don't inherit attributes from their parent window - // (if the parent frame is red, it doesn't mean that all dialogs shown - // by it should be red as well), so don't do anything here neither. - } - -protected: - virtual bool DoClearShape() - { - return false; - } - - virtual bool DoSetRegionShape(const wxRegion& WXUNUSED(region)) - { - return false; - } - -#if wxUSE_GRAPHICS_CONTEXT - virtual bool DoSetPathShape(const wxGraphicsPath& WXUNUSED(path)) - { - return false; - } -#endif // wxUSE_GRAPHICS_CONTEXT -}; - -#if defined(__WXDFB__) - #include "wx/dfb/nonownedwnd.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/nonownedwnd.h" -#elif defined(__WXMAC__) - #include "wx/osx/nonownedwnd.h" -#elif defined(__WXMSW__) && !defined(__WXWINCE__) - #include "wx/msw/nonownedwnd.h" -#else - // No special class needed in other ports, they can derive both wxTLW and - // wxPopupWindow directly from wxWindow and don't implement SetShape(). - class wxNonOwnedWindow : public wxNonOwnedWindowBase - { - }; -#endif - -#endif // _WX_NONOWNEDWND_H_ diff --git a/Source/3rd Party/wx/include/wx/notebook.h b/Source/3rd Party/wx/include/wx/notebook.h index 09c567f7e..db1dc1361 100644 --- a/Source/3rd Party/wx/include/wx/notebook.h +++ b/Source/3rd Party/wx/include/wx/notebook.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 01.02.01 +// RCS-ID: $Id: notebook.h 42152 2006-10-20 09:16:41Z VZ $ // Copyright: (c) 1996-2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -53,55 +54,17 @@ enum typedef wxWindow wxNotebookPage; // so far, any window can be a page -extern WXDLLIMPEXP_DATA_CORE(const char) wxNotebookNameStr[]; - -#if wxUSE_EXTENDED_RTTI - -// ---------------------------------------------------------------------------- -// XTI accessor -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxNotebookPageInfo : public wxObject -{ -public: - wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; } - virtual ~wxNotebookPageInfo() { } - - bool Create(wxNotebookPage *page, - const wxString& text, - bool selected, - int imageId) - { - m_page = page; - m_text = text; - m_selected = selected; - m_imageId = imageId; - return true; - } - - wxNotebookPage* GetPage() const { return m_page; } - wxString GetText() const { return m_text; } - bool GetSelected() const { return m_selected; } - int GetImageId() const { return m_imageId; } - -private: - wxNotebookPage *m_page; - wxString m_text; - bool m_selected; - int m_imageId; - - DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo) -}; - -WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); +extern WXDLLEXPORT_DATA(const wxChar) wxNotebookNameStr[]; +#if WXWIN_COMPATIBILITY_2_4 + #define wxNOTEBOOK_NAME wxNotebookNameStr #endif // ---------------------------------------------------------------------------- // wxNotebookBase: define wxNotebook interface // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxNotebookBase : public wxBookCtrlBase +class WXDLLEXPORT wxNotebookBase : public wxBookCtrlBase { public: // ctors @@ -109,6 +72,13 @@ public: wxNotebookBase() { } + wxNotebookBase(wxWindow *parent, + wxWindowID winid, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxNotebookNameStr) ; + // wxNotebook-specific additions to wxBookCtrlBase interface // --------------------------------------------------------- @@ -131,51 +101,59 @@ public: virtual wxColour GetThemeBackgroundColour() const { return wxNullColour; } - // send wxEVT_NOTEBOOK_PAGE_CHANGING/ED events + // send wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING/ED events // returns false if the change to nPage is vetoed by the program bool SendPageChangingEvent(int nPage); // sends the event about page change from old to new (or GetSelection() if - // new is wxNOT_FOUND) - void SendPageChangedEvent(int nPageOld, int nPageNew = wxNOT_FOUND); + // new is -1) + void SendPageChangedEvent(int nPageOld, int nPageNew = -1); - // wxBookCtrlBase overrides this method to return false but we do need - // focus because we have tabs - virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); } -#if wxUSE_EXTENDED_RTTI - // XTI accessors - virtual void AddPageInfo( wxNotebookPageInfo* info ); - virtual const wxNotebookPageInfoList& GetPageInfos() const; -#endif - protected: -#if wxUSE_EXTENDED_RTTI - wxNotebookPageInfoList m_pageInfos; -#endif - wxDECLARE_NO_COPY_CLASS(wxNotebookBase); + DECLARE_NO_COPY_CLASS(wxNotebookBase) }; // ---------------------------------------------------------------------------- // notebook event class and related stuff // ---------------------------------------------------------------------------- -// wxNotebookEvent is obsolete and defined for compatibility only (notice that -// we use #define and not typedef to also keep compatibility with the existing -// code which forward declares it) -#define wxNotebookEvent wxBookCtrlEvent -typedef wxBookCtrlEventFunction wxNotebookEventFunction; -#define wxNotebookEventHandler(func) wxBookCtrlEventHandler(func) +class WXDLLEXPORT wxNotebookEvent : public wxBookCtrlBaseEvent +{ +public: + wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, + int nSel = -1, int nOldSel = -1) + : wxBookCtrlBaseEvent(commandType, winid, nSel, nOldSel) + { + } -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); + wxNotebookEvent(const wxNotebookEvent& event) + : wxBookCtrlBaseEvent(event) + { + } + + virtual wxEvent *Clone() const { return new wxNotebookEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotebookEvent) +}; + +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 802) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 803) +END_DECLARE_EVENT_TYPES() + +typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&); + +#define wxNotebookEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNotebookEventFunction, &func) #define EVT_NOTEBOOK_PAGE_CHANGED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, winid, wxNotebookEventHandler(fn)) #define EVT_NOTEBOOK_PAGE_CHANGING(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, winid, wxNotebookEventHandler(fn)) // ---------------------------------------------------------------------------- // wxNotebook class itself @@ -192,17 +170,13 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGING, wxBook #elif defined(__WXGTK__) #include "wx/gtk1/notebook.h" #elif defined(__WXMAC__) - #include "wx/osx/notebook.h" + #include "wx/mac/notebook.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/notebook.h" #elif defined(__WXPM__) #include "wx/os2/notebook.h" #endif -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED -#define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING - #endif // wxUSE_NOTEBOOK #endif diff --git a/Source/3rd Party/wx/include/wx/notifmsg.h b/Source/3rd Party/wx/include/wx/notifmsg.h deleted file mode 100644 index fe49c8763..000000000 --- a/Source/3rd Party/wx/include/wx/notifmsg.h +++ /dev/null @@ -1,159 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/notifmsg.h -// Purpose: class allowing to show notification messages to the user -// Author: Vadim Zeitlin -// Created: 2007-11-19 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_NOTIFMSG_H_ -#define _WX_NOTIFMSG_H_ - -#include "wx/event.h" - -#if wxUSE_NOTIFICATION_MESSAGE - -// ---------------------------------------------------------------------------- -// wxNotificationMessage: allows to show the user a message non intrusively -// ---------------------------------------------------------------------------- - -// notice that this class is not a window and so doesn't derive from wxWindow - -class WXDLLIMPEXP_ADV wxNotificationMessageBase : public wxEvtHandler -{ -public: - // ctors and initializers - // ---------------------- - - // default ctor, use setters below to initialize it later - wxNotificationMessageBase() - { - m_parent = NULL; - m_flags = wxICON_INFORMATION; - } - - // create a notification object with the given title and message (the - // latter may be empty in which case only the title will be shown) - wxNotificationMessageBase(const wxString& title, - const wxString& message = wxEmptyString, - wxWindow *parent = NULL, - int flags = wxICON_INFORMATION) - : m_title(title), - m_message(message), - m_parent(parent) - { - SetFlags(flags); - } - - // note that the setters must be called before Show() - - // set the title: short string, markup not allowed - void SetTitle(const wxString& title) { m_title = title; } - - // set the text of the message: this is a longer string than the title and - // some platforms allow simple HTML-like markup in it - void SetMessage(const wxString& message) { m_message = message; } - - // set the parent for this notification: we'll be associated with the top - // level parent of this window or, if this method is not called, with the - // main application window by default - void SetParent(wxWindow *parent) { m_parent = parent; } - - // this method can currently be used to choose a standard icon to use: the - // parameter may be one of wxICON_INFORMATION, wxICON_WARNING or - // wxICON_ERROR only (but not wxICON_QUESTION) - void SetFlags(int flags) - { - wxASSERT_MSG( flags == wxICON_INFORMATION || - flags == wxICON_WARNING || flags == wxICON_ERROR, - "Invalid icon flags specified" ); - - m_flags = flags; - } - - - // showing and hiding - // ------------------ - - // possible values for Show() timeout - enum - { - Timeout_Auto = -1, // notification will be hidden automatically - Timeout_Never = 0 // notification will never time out - }; - - // show the notification to the user and hides it after timeout seconds - // pass (special values Timeout_Auto and Timeout_Never can be used) - // - // returns false if an error occurred - virtual bool Show(int timeout = Timeout_Auto) = 0; - - // hide the notification, returns true if it was hidden or false if it - // couldn't be done (e.g. on some systems automatically hidden - // notifications can't be hidden manually) - virtual bool Close() = 0; - -protected: - // accessors for the derived classes - const wxString& GetTitle() const { return m_title; } - const wxString& GetMessage() const { return m_message; } - wxWindow *GetParent() const { return m_parent; } - int GetFlags() const { return m_flags; } - - // return the concatenation of title and message separated by a new line, - // this is suitable for simple implementation which have no support for - // separate title and message parts of the notification - wxString GetFullMessage() const - { - wxString text(m_title); - if ( !m_message.empty() ) - { - text << "\n\n" << m_message; - } - - return text; - } - -private: - wxString m_title, - m_message; - - wxWindow *m_parent; - - int m_flags; - - wxDECLARE_NO_COPY_CLASS(wxNotificationMessageBase); -}; - -/* - TODO: Implement under OS X using notification centre (10.8+) or - Growl (http://growl.info/) for the previous versions. - */ -#if defined(__WXGTK__) && wxUSE_LIBNOTIFY - #include "wx/gtk/notifmsg.h" -#elif defined(__WXGTK__) && (wxUSE_LIBHILDON || wxUSE_LIBHILDON2) - #include "wx/gtk/hildon/notifmsg.h" -#elif defined(__WXMSW__) && wxUSE_TASKBARICON && wxUSE_TASKBARICON_BALLOONS - #include "wx/msw/notifmsg.h" -#else - #include "wx/generic/notifmsg.h" - - class wxNotificationMessage : public wxGenericNotificationMessage - { - public: - wxNotificationMessage() { } - wxNotificationMessage(const wxString& title, - const wxString& message = wxEmptyString, - wxWindow *parent = NULL, - int flags = wxICON_INFORMATION) - : wxGenericNotificationMessage(title, message, parent, flags) - { - } - }; -#endif - -#endif // wxUSE_NOTIFICATION_MESSAGE - -#endif // _WX_NOTIFMSG_H_ - diff --git a/Source/3rd Party/wx/include/wx/numdlg.h b/Source/3rd Party/wx/include/wx/numdlg.h index 9bdb188c8..741bc72fa 100644 --- a/Source/3rd Party/wx/include/wx/numdlg.h +++ b/Source/3rd Party/wx/include/wx/numdlg.h @@ -4,6 +4,7 @@ // Author: John Labenski // Modified by: // Created: 07.02.04 (extracted from wx/textdlg.h) +// RCS-ID: $Id: numdlg.h 37157 2006-01-26 15:33:27Z ABX $ // Copyright: (c) John Labenski // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/numformatter.h b/Source/3rd Party/wx/include/wx/numformatter.h deleted file mode 100644 index 13b47b210..000000000 --- a/Source/3rd Party/wx/include/wx/numformatter.h +++ /dev/null @@ -1,78 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/numformatter.h -// Purpose: wxNumberFormatter class -// Author: Fulvio Senore, Vadim Zeitlin -// Created: 2010-11-06 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_NUMFORMATTER_H_ -#define _WX_NUMFORMATTER_H_ - -#include "wx/string.h" - -// Helper class for formatting numbers with thousands separators which also -// supports parsing the numbers formatted by it. -class WXDLLIMPEXP_BASE wxNumberFormatter -{ -public: - // Bit masks for ToString() - enum Style - { - Style_None = 0x00, - Style_WithThousandsSep = 0x01, - Style_NoTrailingZeroes = 0x02 // Only for floating point numbers - }; - - // Format a number as a string. By default, the thousands separator is - // used, specify Style_None to prevent this. For floating point numbers, - // precision can also be specified. - static wxString ToString(long val, - int style = Style_WithThousandsSep); -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static wxString ToString(wxLongLong_t val, - int style = Style_WithThousandsSep); -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static wxString ToString(double val, - int precision, - int style = Style_WithThousandsSep); - - // Parse a string representing a number, possibly with thousands separator. - // - // Return true on success and stores the result in the provided location - // which must be a valid non-NULL pointer. - static bool FromString(wxString s, long *val); -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static bool FromString(wxString s, wxLongLong_t *val); -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static bool FromString(wxString s, double *val); - - - // Get the decimal separator for the current locale. It is always defined - // and we fall back to returning '.' in case of an error. - static wxChar GetDecimalSeparator(); - - // Get the thousands separator if grouping of the digits is used by the - // current locale. The value returned in sep should be only used if the - // function returns true. - static bool GetThousandsSeparatorIfUsed(wxChar *sep); - -private: - // Post-process the string representing an integer. - static wxString PostProcessIntString(wxString s, int style); - - // Add the thousands separators to a string representing a number without - // the separators. This is used by ToString(Style_WithThousandsSep). - static void AddThousandsSeparators(wxString& s); - - // Remove trailing zeroes and, if there is nothing left after it, the - // decimal separator itself from a string representing a floating point - // number. Also used by ToString(). - static void RemoveTrailingZeroes(wxString& s); - - // Remove all thousands separators from a string representing a number. - static void RemoveThousandsSeparators(wxString& s); -}; - -#endif // _WX_NUMFORMATTER_H_ diff --git a/Source/3rd Party/wx/include/wx/object.h b/Source/3rd Party/wx/include/wx/object.h index 2465ee9a7..37b11e6ec 100644 --- a/Source/3rd Party/wx/include/wx/object.h +++ b/Source/3rd Party/wx/include/wx/object.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Ron Lee // Created: 01/02/97 +// RCS-ID: $Id: object.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1997 Julian Smart // (c) 2001 Ron Lee // Licence: wxWindows licence @@ -18,49 +19,204 @@ #include "wx/memory.h" -#define wxDECLARE_CLASS_INFO_ITERATORS() \ -class WXDLLIMPEXP_BASE const_iterator \ - { \ - typedef wxHashTable_Node Node; \ - public: \ - typedef const wxClassInfo* value_type; \ - typedef const value_type& const_reference; \ - typedef const_iterator itor; \ - typedef value_type* ptr_type; \ - \ - Node* m_node; \ - wxHashTable* m_table; \ - public: \ - typedef const_reference reference_type; \ - typedef ptr_type pointer_type; \ - \ - const_iterator(Node* node, wxHashTable* table) \ - : m_node(node), m_table(table) { } \ - const_iterator() : m_node(NULL), m_table(NULL) { } \ - value_type operator*() const; \ - itor& operator++(); \ - const itor operator++(int); \ - bool operator!=(const itor& it) const \ - { return it.m_node != m_node; } \ - bool operator==(const itor& it) const \ - { return it.m_node == m_node; } \ - }; \ - \ - static const_iterator begin_classinfo(); \ - static const_iterator end_classinfo() +class WXDLLIMPEXP_FWD_BASE wxObject; -// based on the value of wxUSE_EXTENDED_RTTI symbol, -// only one of the RTTI system will be compiled: -// - the "old" one (defined by rtti.h) or -// - the "new" one (defined by xti.h) +#ifndef wxUSE_EXTENDED_RTTI +#define wxUSE_EXTENDED_RTTI 0 +#endif + +#if wxUSE_EXTENDED_RTTI #include "wx/xti.h" -#include "wx/rtti.h" +#else -#define wxIMPLEMENT_CLASS(name, basename) \ - wxIMPLEMENT_ABSTRACT_CLASS(name, basename) +// ---------------------------------------------------------------------------- +// conditional compilation +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_FWD_BASE wxClassInfo; +class WXDLLIMPEXP_FWD_BASE wxHashTable; +class WXDLLIMPEXP_FWD_BASE wxObjectRefData; + +// ---------------------------------------------------------------------------- +// wxClassInfo +// ---------------------------------------------------------------------------- + +typedef wxObject *(*wxObjectConstructorFn)(void); + +class WXDLLIMPEXP_BASE wxClassInfo +{ +public: + wxClassInfo( const wxChar *className, + const wxClassInfo *baseInfo1, + const wxClassInfo *baseInfo2, + int size, + wxObjectConstructorFn ctor ) + : m_className(className) + , m_objectSize(size) + , m_objectConstructor(ctor) + , m_baseInfo1(baseInfo1) + , m_baseInfo2(baseInfo2) + , m_next(sm_first) + { + sm_first = this; + Register(); + } + + ~wxClassInfo(); + + wxObject *CreateObject() const + { return m_objectConstructor ? (*m_objectConstructor)() : 0; } + bool IsDynamic() const { return (NULL != m_objectConstructor); } + + const wxChar *GetClassName() const { return m_className; } + const wxChar *GetBaseClassName1() const + { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; } + const wxChar *GetBaseClassName2() const + { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; } + const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; } + const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; } + int GetSize() const { return m_objectSize; } + + wxObjectConstructorFn GetConstructor() const + { return m_objectConstructor; } + static const wxClassInfo *GetFirst() { return sm_first; } + const wxClassInfo *GetNext() const { return m_next; } + static wxClassInfo *FindClass(const wxChar *className); + + // Climb upwards through inheritance hierarchy. + // Dual inheritance is catered for. + + bool IsKindOf(const wxClassInfo *info) const + { + return info != 0 && + ( info == this || + ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) || + ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) ); + } + +#if WXWIN_COMPATIBILITY_2_4 + // Initializes parent pointers and hash table for fast searching. + wxDEPRECATED( static void InitializeClasses() ); + // Cleans up hash table used for fast searching. + wxDEPRECATED( static void CleanUpClasses() ); +#endif + +public: + const wxChar *m_className; + int m_objectSize; + wxObjectConstructorFn m_objectConstructor; + + // Pointers to base wxClassInfos: set in InitializeClasses + + const wxClassInfo *m_baseInfo1; + const wxClassInfo *m_baseInfo2; + + // class info object live in a linked list: + // pointers to its head and the next element in it + + static wxClassInfo *sm_first; + wxClassInfo *m_next; + + // FIXME: this should be private (currently used directly by way too + // many clients) + static wxHashTable *sm_classTable; + +private: + // InitializeClasses() helper + static wxClassInfo *GetBaseByName(const wxChar *name); + + DECLARE_NO_COPY_CLASS(wxClassInfo) + +protected: + // registers the class + void Register(); + void Unregister(); +}; + +WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name); + +#if WXWIN_COMPATIBILITY_2_4 +inline void wxClassInfo::InitializeClasses() {} +inline void wxClassInfo::CleanUpClasses() {} +#endif + +// ---------------------------------------------------------------------------- +// Dynamic class macros +// ---------------------------------------------------------------------------- + +#define DECLARE_ABSTRACT_CLASS(name) \ + public: \ + static wxClassInfo ms_classInfo; \ + virtual wxClassInfo *GetClassInfo() const; + +#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ + DECLARE_NO_ASSIGN_CLASS(name) \ + DECLARE_DYNAMIC_CLASS(name) + +#define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \ + DECLARE_NO_COPY_CLASS(name) \ + DECLARE_DYNAMIC_CLASS(name) + +#define DECLARE_DYNAMIC_CLASS(name) \ + DECLARE_ABSTRACT_CLASS(name) \ + static wxObject* wxCreateObject(); + +#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name) + + +// common part of the macros below +#define wxIMPLEMENT_CLASS_COMMON(name, basename, baseclsinfo2, func) \ + wxClassInfo name::ms_classInfo(wxT(#name), \ + &basename::ms_classInfo, \ + baseclsinfo2, \ + (int) sizeof(name), \ + (wxObjectConstructorFn) func); \ + \ + wxClassInfo *name::GetClassInfo() const \ + { return &name::ms_classInfo; } + +#define wxIMPLEMENT_CLASS_COMMON1(name, basename, func) \ + wxIMPLEMENT_CLASS_COMMON(name, basename, NULL, func) + +#define wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, func) \ + wxIMPLEMENT_CLASS_COMMON(name, basename1, &basename2::ms_classInfo, func) + +// ----------------------------------- +// for concrete classes +// ----------------------------------- + + // Single inheritance with one base class +#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \ + wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject) \ + wxObject* name::wxCreateObject() \ + { return new name; } + + // Multiple inheritance with two base classes +#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \ + wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, \ + name::wxCreateObject) \ + wxObject* name::wxCreateObject() \ + { return new name; } + +// ----------------------------------- +// for abstract classes +// ----------------------------------- + + // Single inheritance with one base class + +#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \ + wxIMPLEMENT_CLASS_COMMON1(name, basename, NULL) + + // Multiple inheritance with two base classes + +#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ + wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, NULL) + +#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS +#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2 + +#endif // !wxUSE_EXTENDED_RTTI -#define wxIMPLEMENT_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) // ----------------------------------- // for pluggable classes @@ -82,7 +238,7 @@ public: \ name##PluginSentinel(); \ ~name##PluginSentinel(); \ }; \ -name##PluginSentinel m_pluginsentinel +name##PluginSentinel m_pluginsentinel; #define _IMPLEMENT_DL_SENTINEL(name) \ const wxString name::name##PluginSentinel::sm_className(#name); \ @@ -101,35 +257,35 @@ name##PluginSentinel m_pluginsentinel #endif // wxUSE_NESTED_CLASSES -#define wxDECLARE_PLUGGABLE_CLASS(name) \ - wxDECLARE_DYNAMIC_CLASS(name); _DECLARE_DL_SENTINEL(name, WXDLLIMPEXP_CORE) -#define wxDECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \ - wxDECLARE_ABSTRACT_CLASS(name); _DECLARE_DL_SENTINEL(name, WXDLLIMPEXP_CORE) +#define DECLARE_PLUGGABLE_CLASS(name) \ + DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT) +#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \ + DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT) -#define wxDECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \ - wxDECLARE_DYNAMIC_CLASS(name); _DECLARE_DL_SENTINEL(name, usergoo) -#define wxDECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \ - wxDECLARE_ABSTRACT_CLASS(name); _DECLARE_DL_SENTINEL(name, usergoo) +#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \ + DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo) +#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \ + DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo) -#define wxIMPLEMENT_PLUGGABLE_CLASS(name, basename) \ - wxIMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) -#define wxIMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) -#define wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ - wxIMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) -#define wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) +#define IMPLEMENT_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) +#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) +#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) +#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) -#define wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \ - wxIMPLEMENT_PLUGGABLE_CLASS(name, basename) -#define wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) -#define wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ - wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) -#define wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) -#define wxCLASSINFO(name) (&name::ms_classInfo) +#define CLASSINFO(name) (&name::ms_classInfo) #define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::ms_classInfo) @@ -143,8 +299,8 @@ name##PluginSentinel m_pluginsentinel // be replaced by it as long as there are any compilers not supporting it #define wxDynamicCast(obj, className) \ ((className *) wxCheckDynamicCast( \ - const_cast(static_cast(\ - const_cast(static_cast(obj)))), \ + wx_const_cast(wxObject *, wx_static_cast(const wxObject *, \ + wx_const_cast(className *, wx_static_cast(const className *, obj)))), \ &className::ms_classInfo)) // The 'this' pointer is always true, so use this version @@ -152,16 +308,20 @@ name##PluginSentinel m_pluginsentinel #define wxDynamicCastThis(className) \ (IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0) -// FIXME-VC6: dummy argument needed because VC6 doesn't support explicitly -// choosing the template function to call -template -inline T *wxCheckCast(const void *ptr, T * = NULL) +#ifdef __WXDEBUG__ +inline void* wxCheckCast(void *ptr) { - wxASSERT_MSG( wxDynamicCast(ptr, T), "wxStaticCast() used incorrectly" ); - return const_cast(static_cast(ptr)); + wxASSERT_MSG( ptr, wxT("wxStaticCast() used incorrectly") ); + return ptr; } +#define wxStaticCast(obj, className) \ + ((className *)wxCheckCast(wxDynamicCast(obj, className))) -#define wxStaticCast(obj, className) wxCheckCast((obj), (className *)NULL) +#else // !__WXDEBUG__ +#define wxStaticCast(obj, className) \ + wx_const_cast(className *, wx_static_cast(const className *, obj)) + +#endif // __WXDEBUG__ // ---------------------------------------------------------------------------- // set up memory debugging macros @@ -179,7 +339,7 @@ inline T *wxCheckCast(const void *ptr, T * = NULL) _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT = void operator delete[] (void* buf, wxChar*, int ) */ -#if wxUSE_MEMORY_TRACING +#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING // All compilers get this one #define _WX_WANT_NEW_SIZET_WXCHAR_INT @@ -194,8 +354,9 @@ inline T *wxCheckCast(const void *ptr, T * = NULL) #define _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET #endif -// Only VC++ 6 gets overloaded delete that matches new -#if (defined(__VISUALC__) && (__VISUALC__ >= 1200)) +// Only VC++ 6 and CodeWarrior get overloaded delete that matches new +#if (defined(__VISUALC__) && (__VISUALC__ >= 1200)) || \ + (defined(__MWERKS__) && (__MWERKS__ >= 0x2400)) #define _WX_WANT_DELETE_VOID_WXCHAR_INT #endif @@ -211,141 +372,32 @@ inline T *wxCheckCast(const void *ptr, T * = NULL) #if !defined(__VISUALC__) #define _WX_WANT_ARRAY_DELETE_VOID #endif + + // Only CodeWarrior 6 or higher + #if defined(__MWERKS__) && (__MWERKS__ >= 0x2400) + #define _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT + #endif + #endif // wxUSE_ARRAY_MEMORY_OPERATORS -#endif // wxUSE_MEMORY_TRACING - -// ---------------------------------------------------------------------------- -// Compatibility macro aliases DECLARE group -// ---------------------------------------------------------------------------- -// deprecated variants _not_ requiring a semicolon after them and without wx prefix. -// (note that also some wx-prefixed macro do _not_ require a semicolon because -// it's not always possible to force the compire to require it) - -#define DECLARE_CLASS_INFO_ITERATORS() wxDECLARE_CLASS_INFO_ITERATORS(); -#define DECLARE_ABSTRACT_CLASS(n) wxDECLARE_ABSTRACT_CLASS(n); -#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(n) wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(n); -#define DECLARE_DYNAMIC_CLASS_NO_COPY(n) wxDECLARE_DYNAMIC_CLASS_NO_COPY(n); -#define DECLARE_DYNAMIC_CLASS(n) wxDECLARE_DYNAMIC_CLASS(n); -#define DECLARE_CLASS(n) wxDECLARE_CLASS(n); - -#define DECLARE_PLUGGABLE_CLASS(n) wxDECLARE_PLUGGABLE_CLASS(n); -#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(n) wxDECLARE_ABSTRACT_PLUGGABLE_CLASS(n); -#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(n,u) wxDECLARE_USER_EXPORTED_PLUGGABLE_CLASS(n,u); -#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,u) wxDECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,u); - -// ---------------------------------------------------------------------------- -// wxRefCounter: ref counted data "manager" -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxRefCounter -{ -public: - wxRefCounter() { m_count = 1; } - - int GetRefCount() const { return m_count; } - - void IncRef() { m_count++; } - void DecRef(); - -protected: - // this object should never be destroyed directly but only as a - // result of a DecRef() call: - virtual ~wxRefCounter() { } - -private: - // our refcount: - int m_count; - - // It doesn't make sense to copy the reference counted objects, a new ref - // counter should be created for a new object instead and compilation - // errors in the code using wxRefCounter due to the lack of copy ctor often - // indicate a problem, e.g. a forgotten copy ctor implementation somewhere. - wxDECLARE_NO_COPY_CLASS(wxRefCounter); -}; +#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING // ---------------------------------------------------------------------------- // wxObjectRefData: ref counted data meant to be stored in wxObject // ---------------------------------------------------------------------------- -typedef wxRefCounter wxObjectRefData; - -// ---------------------------------------------------------------------------- -// wxObjectDataPtr: helper class to avoid memleaks because of missing calls -// to wxObjectRefData::DecRef -// ---------------------------------------------------------------------------- - -template -class wxObjectDataPtr +class WXDLLIMPEXP_BASE wxObjectRefData { + friend class WXDLLIMPEXP_FWD_BASE wxObject; + public: - typedef T element_type; + wxObjectRefData() : m_count(1) { } + virtual ~wxObjectRefData() { } - wxEXPLICIT wxObjectDataPtr(T *ptr = NULL) : m_ptr(ptr) {} - - // copy ctor - wxObjectDataPtr(const wxObjectDataPtr &tocopy) - : m_ptr(tocopy.m_ptr) - { - if (m_ptr) - m_ptr->IncRef(); - } - - ~wxObjectDataPtr() - { - if (m_ptr) - m_ptr->DecRef(); - } - - T *get() const { return m_ptr; } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxObjectDataPtr::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - return m_ptr ? &wxObjectDataPtr::get : NULL; - } - - T& operator*() const - { - wxASSERT(m_ptr != NULL); - return *(m_ptr); - } - - T *operator->() const - { - wxASSERT(m_ptr != NULL); - return get(); - } - - void reset(T *ptr) - { - if (m_ptr) - m_ptr->DecRef(); - m_ptr = ptr; - } - - wxObjectDataPtr& operator=(const wxObjectDataPtr &tocopy) - { - if (m_ptr) - m_ptr->DecRef(); - m_ptr = tocopy.m_ptr; - if (m_ptr) - m_ptr->IncRef(); - return *this; - } - - wxObjectDataPtr& operator=(T *ptr) - { - if (m_ptr) - m_ptr->DecRef(); - m_ptr = ptr; - return *this; - } + int GetRefCount() const { return m_count; } private: - T *m_ptr; + int m_count; }; // ---------------------------------------------------------------------------- @@ -354,7 +406,7 @@ private: class WXDLLIMPEXP_BASE wxObject { - wxDECLARE_ABSTRACT_CLASS(wxObject); + DECLARE_ABSTRACT_CLASS(wxObject) public: wxObject() { m_refData = NULL; } @@ -364,7 +416,7 @@ public: { m_refData = other.m_refData; if (m_refData) - m_refData->IncRef(); + m_refData->m_count++; } wxObject& operator=(const wxObject& other) @@ -376,7 +428,7 @@ public: return *this; } - bool IsKindOf(const wxClassInfo *info) const; + bool IsKindOf(wxClassInfo *info) const; // Turn on the correct set of new and delete operators @@ -450,48 +502,68 @@ inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo) return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : NULL; } -#include "wx/xti2.h" +#if wxUSE_EXTENDED_RTTI +class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject +{ + friend class WXDLLIMPEXP_BASE wxDynamicClassInfo ; +public: + // instantiates this object with an instance of its superclass + wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ; + virtual ~wxDynamicObject(); + + void SetProperty (const wxChar *propertyName, const wxxVariant &value); + wxxVariant GetProperty (const wxChar *propertyName) const ; + + // get the runtime identity of this object + wxClassInfo *GetClassInfo() const + { +#ifdef _MSC_VER + return (wxClassInfo*) m_classInfo; +#else + return wx_const_cast(wxClassInfo *, m_classInfo); +#endif + } + + wxObject* GetSuperClassInstance() const + { + return m_superClassInstance ; + } +private : + // removes an existing runtime-property + void RemoveProperty( const wxChar *propertyName ) ; + + // renames an existing runtime-property + void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ; + + wxObject *m_superClassInstance ; + const wxDynamicClassInfo *m_classInfo; + struct wxDynamicObjectInternal; + wxDynamicObjectInternal *m_data; +}; +#endif // ---------------------------------------------------------------------------- // more debugging macros // ---------------------------------------------------------------------------- -#if wxUSE_DEBUG_NEW_ALWAYS +// Redefine new to be the debugging version. This doesn't work with all +// compilers, in which case you need to use WXDEBUG_NEW explicitly if you wish +// to use the debugging version. + +#ifdef __WXDEBUG__ #define WXDEBUG_NEW new(__TFILE__,__LINE__) - #if wxUSE_GLOBAL_MEMORY_OPERATORS - #define new WXDEBUG_NEW - #elif defined(__VISUALC__) - // Including this file redefines new and allows leak reports to - // contain line numbers - #include "wx/msw/msvcrt.h" - #endif -#endif // wxUSE_DEBUG_NEW_ALWAYS - -// ---------------------------------------------------------------------------- -// Compatibility macro aliases IMPLEMENT group -// ---------------------------------------------------------------------------- - -// deprecated variants _not_ requiring a semicolon after them and without wx prefix. -// (note that also some wx-prefixed macro do _not_ require a semicolon because -// it's not always possible to force the compire to require it) - -#define IMPLEMENT_DYNAMIC_CLASS(n,b) wxIMPLEMENT_DYNAMIC_CLASS(n,b) -#define IMPLEMENT_DYNAMIC_CLASS2(n,b1,b2) wxIMPLEMENT_DYNAMIC_CLASS2(n,b1,b2) -#define IMPLEMENT_ABSTRACT_CLASS(n,b) wxIMPLEMENT_ABSTRACT_CLASS(n,b) -#define IMPLEMENT_ABSTRACT_CLASS2(n,b1,b2) wxIMPLEMENT_ABSTRACT_CLASS2(n,b1,b2) -#define IMPLEMENT_CLASS(n,b) wxIMPLEMENT_CLASS(n,b) -#define IMPLEMENT_CLASS2(n,b1,b2) wxIMPLEMENT_CLASS2(n,b1,b2) - -#define IMPLEMENT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_PLUGGABLE_CLASS(n,b) -#define IMPLEMENT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_PLUGGABLE_CLASS2(n,b,b2) -#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(n,b) -#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) -#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(n,b) -#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(n,b,b2) -#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,b) -#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) - -#define CLASSINFO(n) wxCLASSINFO(n) + #if wxUSE_DEBUG_NEW_ALWAYS + #if wxUSE_GLOBAL_MEMORY_OPERATORS + #define new WXDEBUG_NEW + #elif defined(__VISUALC__) + // Including this file redefines new and allows leak reports to + // contain line numbers + #include "wx/msw/msvcrt.h" + #endif + #endif // wxUSE_DEBUG_NEW_ALWAYS +#else // !__WXDEBUG__ + #define WXDEBUG_NEW new +#endif // __WXDEBUG__/!__WXDEBUG__ #endif // _WX_OBJECTH__ diff --git a/Source/3rd Party/wx/include/wx/odcombo.h b/Source/3rd Party/wx/include/wx/odcombo.h deleted file mode 100644 index af0f1160d..000000000 --- a/Source/3rd Party/wx/include/wx/odcombo.h +++ /dev/null @@ -1,399 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/odcombo.h -// Purpose: wxOwnerDrawnComboBox and wxVListBoxPopup -// Author: Jaakko Salli -// Modified by: -// Created: Apr-30-2006 -// Copyright: (c) Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_ODCOMBO_H_ -#define _WX_ODCOMBO_H_ - -#include "wx/defs.h" - -#if wxUSE_ODCOMBOBOX - -#include "wx/combo.h" -#include "wx/ctrlsub.h" -#include "wx/vlbox.h" -#include "wx/timer.h" - - -// -// New window styles for wxOwnerDrawnComboBox -// -enum -{ - // Double-clicking cycles item if wxCB_READONLY is also used. - wxODCB_DCLICK_CYCLES = wxCC_SPECIAL_DCLICK, - - // If used, control itself is not custom paint using callback. - // Even if this is not used, writable combo is never custom paint - // until SetCustomPaintWidth is called - wxODCB_STD_CONTROL_PAINT = 0x1000 -}; - - -// -// Callback flags (see wxOwnerDrawnComboBox::OnDrawItem) -// -enum wxOwnerDrawnComboBoxPaintingFlags -{ - // when set, we are painting the selected item in control, - // not in the popup - wxODCB_PAINTING_CONTROL = 0x0001, - - - // when set, we are painting an item which should have - // focus rectangle painted in the background. Text colour - // and clipping region are then appropriately set in - // the default OnDrawBackground implementation. - wxODCB_PAINTING_SELECTED = 0x0002 -}; - - -// ---------------------------------------------------------------------------- -// wxVListBoxComboPopup is a wxVListBox customized to act as a popup control. -// -// Notes: -// wxOwnerDrawnComboBox uses this as its popup. However, it always derives -// from native wxComboCtrl. If you need to use this popup with -// wxGenericComboControl, then remember that vast majority of item manipulation -// functionality is implemented in the wxVListBoxComboPopup class itself. -// -// ---------------------------------------------------------------------------- - - -class WXDLLIMPEXP_ADV wxVListBoxComboPopup : public wxVListBox, - public wxComboPopup -{ - friend class wxOwnerDrawnComboBox; -public: - - // init and dtor - wxVListBoxComboPopup() : wxVListBox(), wxComboPopup() { } - virtual ~wxVListBoxComboPopup(); - - // required virtuals - virtual void Init(); - virtual bool Create(wxWindow* parent); - virtual void SetFocus(); - virtual wxWindow *GetControl() { return this; } - virtual void SetStringValue( const wxString& value ); - virtual wxString GetStringValue() const; - - // more customization - virtual void OnPopup(); - virtual wxSize GetAdjustedSize( int minWidth, int prefHeight, int maxHeight ); - virtual void PaintComboControl( wxDC& dc, const wxRect& rect ); - virtual void OnComboKeyEvent( wxKeyEvent& event ); - virtual void OnComboCharEvent( wxKeyEvent& event ); - virtual void OnComboDoubleClick(); - virtual bool LazyCreate(); - virtual bool FindItem(const wxString& item, wxString* trueItem); - - // Item management - void SetSelection( int item ); - void Insert( const wxString& item, int pos ); - int Append(const wxString& item); - void Clear(); - void Delete( unsigned int item ); - void SetItemClientData(unsigned int n, void* clientData, wxClientDataType clientDataItemsType); - void *GetItemClientData(unsigned int n) const; - void SetString( int item, const wxString& str ); - wxString GetString( int item ) const; - unsigned int GetCount() const; - int FindString(const wxString& s, bool bCase = false) const; - int GetSelection() const; - - //void Populate( int n, const wxString choices[] ); - void Populate( const wxArrayString& choices ); - void ClearClientDatas(); - - // helpers - int GetItemAtPosition( const wxPoint& pos ) { return HitTest(pos); } - wxCoord GetTotalHeight() const { return EstimateTotalHeight(); } - wxCoord GetLineHeight(int line) const { return OnGetRowHeight(line); } - -protected: - - // Called by OnComboDoubleClick and OnCombo{Key,Char}Event - bool HandleKey( int keycode, bool saturate, wxChar keychar = 0 ); - - // sends combobox select event from the parent combo control - void SendComboBoxEvent( int selection ); - - // gets value, sends event and dismisses - void DismissWithEvent(); - - // OnMeasureItemWidth will be called on next GetAdjustedSize. - void ItemWidthChanged(unsigned int item) - { - m_widths[item] = -1; - m_widthsDirty = true; - } - - // Callbacks for drawing and measuring items. Override in a derived class for - // owner-drawnness. Font, background and text colour have been prepared according - // to selection, focus and such. - // - // item: item index to be drawn, may be wxNOT_FOUND when painting combo control itself - // and there is no valid selection - // flags: wxODCB_PAINTING_CONTROL is set if painting to combo control instead of list - // - // NOTE: If wxVListBoxComboPopup is used with a wxComboCtrl class not derived from - // wxOwnerDrawnComboBox, this method must be overridden. - virtual void OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags) const; - - // This is same as in wxVListBox - virtual wxCoord OnMeasureItem( size_t item ) const; - - // Return item width, or -1 for calculating from text extent (default) - virtual wxCoord OnMeasureItemWidth( size_t item ) const; - - // Draw item and combo control background. Flags are same as with OnDrawItem. - // NB: Can't use name OnDrawBackground because of virtual function hiding warnings. - virtual void OnDrawBg(wxDC& dc, const wxRect& rect, int item, int flags) const; - - // Additional wxVListBox implementation (no need to override in derived classes) - virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const; - void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; - - // filter mouse move events happening outside the list box - // move selection with cursor - void OnMouseMove(wxMouseEvent& event); - void OnKey(wxKeyEvent& event); - void OnChar(wxKeyEvent& event); - void OnLeftClick(wxMouseEvent& event); - - // Return the widest item width (recalculating it if necessary) - int GetWidestItemWidth() { CalcWidths(); return m_widestWidth; } - - // Return the index of the widest item (recalculating it if necessary) - int GetWidestItem() { CalcWidths(); return m_widestItem; } - - // Stop partial completion (when some other event occurs) - void StopPartialCompletion(); - - wxArrayString m_strings; - wxArrayPtrVoid m_clientDatas; - - wxFont m_useFont; - - //wxString m_stringValue; // displayed text (may be different than m_strings[m_value]) - int m_value; // selection - int m_itemHover; // on which item the cursor is - int m_itemHeight; // default item height (calculate from font size - // and used in the absence of callback) - wxClientDataType m_clientDataItemsType; - -private: - - // Cached item widths (in pixels). - wxArrayInt m_widths; - - // Width of currently widest item. - int m_widestWidth; - - // Index of currently widest item. - int m_widestItem; - - // Measure some items in next GetAdjustedSize? - bool m_widthsDirty; - - // Find widest item in next GetAdjustedSize? - bool m_findWidest; - - // has the mouse been released on this control? - bool m_clicked; - - // Recalculate widths if they are dirty - void CalcWidths(); - - // Partial completion string - wxString m_partialCompletionString; - - wxString m_stringValue; - -#if wxUSE_TIMER - // Partial completion timer - wxTimer m_partialCompletionTimer; -#endif // wxUSE_TIMER - - DECLARE_EVENT_TABLE() -}; - - -// ---------------------------------------------------------------------------- -// wxOwnerDrawnComboBox: a generic wxComboBox that allows custom paint items -// in addition to many other types of customization already allowed by -// the wxComboCtrl. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox : - public wxWindowWithItems -{ - //friend class wxComboPopupWindow; - friend class wxVListBoxComboPopup; -public: - - // ctors and such - wxOwnerDrawnComboBox() { Init(); } - - wxOwnerDrawnComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr) - { - Init(); - - (void)Create(parent, id, value, pos, size, n, - choices, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - wxOwnerDrawnComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const wxArrayString& choices = wxArrayString(), - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - virtual ~wxOwnerDrawnComboBox(); - - // Prevent app from using wxComboPopup - void SetPopupControl(wxVListBoxComboPopup* popup) - { - DoSetPopupControl(popup); - } - - // wxControlWithItems methods - virtual unsigned int GetCount() const; - virtual wxString GetString(unsigned int n) const; - virtual void SetString(unsigned int n, const wxString& s); - virtual int FindString(const wxString& s, bool bCase = false) const; - virtual void Select(int n); - virtual int GetSelection() const; - - // Override these just to maintain consistency with virtual methods - // between classes. - virtual void Clear(); - virtual void GetSelection(long *from, long *to) const; - - virtual void SetSelection(int n) { Select(n); } - - - // Prevent a method from being hidden - virtual void SetSelection(long from, long to) - { - wxComboCtrl::SetSelection(from,to); - } - - // Return the widest item width (recalculating it if necessary) - virtual int GetWidestItemWidth() { EnsurePopupControl(); return GetVListBoxComboPopup()->GetWidestItemWidth(); } - - // Return the index of the widest item (recalculating it if necessary) - virtual int GetWidestItem() { EnsurePopupControl(); return GetVListBoxComboPopup()->GetWidestItem(); } - - virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } - -protected: - virtual void DoClear(); - virtual void DoDeleteOneItem(unsigned int n); - - // Callback for drawing. Font, background and text colour have been - // prepared according to selection, focus and such. - // item: item index to be drawn, may be wxNOT_FOUND when painting combo control itself - // and there is no valid selection - // flags: wxODCB_PAINTING_CONTROL is set if painting to combo control instead of list - virtual void OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const; - - // Callback for item height, or -1 for default - virtual wxCoord OnMeasureItem( size_t item ) const; - - // Callback for item width, or -1 for default/undetermined - virtual wxCoord OnMeasureItemWidth( size_t item ) const; - - // override base implementation so we can return the size for the - // largest item - virtual wxSize DoGetBestSize() const; - - // Callback for background drawing. Flags are same as with - // OnDrawItem. - virtual void OnDrawBackground( wxDC& dc, const wxRect& rect, int item, int flags ) const; - - // NULL popup can be used to indicate default interface - virtual void DoSetPopupControl(wxComboPopup* popup); - - // clears all allocated client datas - void ClearClientDatas(); - - wxVListBoxComboPopup* GetVListBoxComboPopup() const - { - return (wxVListBoxComboPopup*) m_popupInterface; - } - - virtual int DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, wxClientDataType type); - virtual void DoSetItemClientData(unsigned int n, void* clientData); - virtual void* DoGetItemClientData(unsigned int n) const; - - // temporary storage for the initial choices - //const wxString* m_baseChoices; - //int m_baseChoicesCount; - wxArrayString m_initChs; - -private: - void Init(); - - DECLARE_EVENT_TABLE() - - DECLARE_DYNAMIC_CLASS(wxOwnerDrawnComboBox) -}; - - -#endif // wxUSE_ODCOMBOBOX - -#endif - // _WX_ODCOMBO_H_ diff --git a/Source/3rd Party/wx/include/wx/overlay.h b/Source/3rd Party/wx/include/wx/overlay.h index c7ca3a485..d0d2a11aa 100644 --- a/Source/3rd Party/wx/include/wx/overlay.h +++ b/Source/3rd Party/wx/include/wx/overlay.h @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 2006-10-20 +// RCS-ID: $Id: overlay.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,7 +14,7 @@ #include "wx/defs.h" -#if defined(__WXMAC__) && wxOSX_USE_CARBON +#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS #define wxHAS_NATIVE_OVERLAY 1 #elif defined(__WXDFB__) #define wxHAS_NATIVE_OVERLAY 1 @@ -28,9 +29,9 @@ // ---------------------------------------------------------------------------- class WXDLLIMPEXP_FWD_CORE wxOverlayImpl; -class WXDLLIMPEXP_FWD_CORE wxDC; +class WXDLLIMPEXP_FWD_CORE wxWindowDC; -class WXDLLIMPEXP_CORE wxOverlay +class WXDLLEXPORT wxOverlay { public: wxOverlay(); @@ -49,32 +50,32 @@ private: // returns true if it has been setup bool IsOk(); - void Init(wxDC* dc, int x , int y , int width , int height); + void Init(wxWindowDC* dc, int x , int y , int width , int height); - void BeginDrawing(wxDC* dc); + void BeginDrawing(wxWindowDC* dc); - void EndDrawing(wxDC* dc); + void EndDrawing(wxWindowDC* dc); - void Clear(wxDC* dc); + void Clear(wxWindowDC* dc); wxOverlayImpl* m_impl; bool m_inDrawing; - wxDECLARE_NO_COPY_CLASS(wxOverlay); + DECLARE_NO_COPY_CLASS(wxOverlay) }; -class WXDLLIMPEXP_CORE wxDCOverlay +class WXDLLEXPORT wxDCOverlay { public: // connects this overlay to the corresponding drawing dc, if the overlay is // not initialized yet this call will do so - wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height); + wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height); // convenience wrapper that behaves the same using the entire area of the dc - wxDCOverlay(wxOverlay &overlay, wxDC *dc); + wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc); // removes the connection between the overlay and the dc virtual ~wxDCOverlay(); @@ -83,14 +84,14 @@ public: void Clear(); private: - void Init(wxDC *dc, int x , int y , int width , int height); + void Init(wxWindowDC *dc, int x , int y , int width , int height); wxOverlay& m_overlay; - wxDC* m_dc; + wxWindowDC* m_dc; - wxDECLARE_NO_COPY_CLASS(wxDCOverlay); + DECLARE_NO_COPY_CLASS(wxDCOverlay) }; #endif // _WX_OVERLAY_H_ diff --git a/Source/3rd Party/wx/include/wx/ownerdrw.h b/Source/3rd Party/wx/include/wx/ownerdrw.h index b8a9e575f..fe673cec8 100644 --- a/Source/3rd Party/wx/include/wx/ownerdrw.h +++ b/Source/3rd Party/wx/include/wx/ownerdrw.h @@ -1,24 +1,24 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/ownerdrw.h +// Name: ownerdrw.h // Purpose: interface for owner-drawn GUI elements // Author: Vadim Zeitlin -// Modified by: Marcin Malich +// Modified by: // Created: 11.11.97 +// RCS-ID: $Id: ownerdrw.h 62511 2009-10-30 14:11:03Z JMS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _WX_OWNERDRW_H_BASE -#define _WX_OWNERDRW_H_BASE +#ifndef _OWNERDRW_H +#define _OWNERDRW_H #include "wx/defs.h" #if wxUSE_OWNER_DRAWN -#include "wx/font.h" +#include "wx/bitmap.h" #include "wx/colour.h" - -class WXDLLIMPEXP_FWD_CORE wxDC; +#include "wx/font.h" // ---------------------------------------------------------------------------- // wxOwnerDrawn - a mix-in base class, derive from it to implement owner-drawn @@ -29,116 +29,156 @@ class WXDLLIMPEXP_FWD_CORE wxDC; // element or one unchangeable bitmap otherwise. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxOwnerDrawnBase +class WXDLLEXPORT wxOwnerDrawn { public: - wxOwnerDrawnBase() - { - m_ownerDrawn = false; - m_margin = ms_defaultMargin; - } + // ctor & dtor + wxOwnerDrawn(const wxString& str = wxEmptyString, + bool bCheckable = false, + bool bMenuItem = false); // FIXME kludge for colors + virtual ~wxOwnerDrawn(); - virtual ~wxOwnerDrawnBase() {} + // fix appearance + void SetFont(const wxFont& font) + { m_font = font; m_bOwnerDrawn = true; } - void SetFont(const wxFont& font) - { m_font = font; m_ownerDrawn = true; } + wxFont& GetFont() const { return (wxFont &)m_font; } - wxFont& GetFont() const - { return (wxFont&) m_font; } + void SetTextColour(const wxColour& colText) + { m_colText = colText; m_bOwnerDrawn = true; } + wxColour& GetTextColour() const { return (wxColour&) m_colText; } - void SetTextColour(const wxColour& colText) - { m_colText = colText; m_ownerDrawn = true; } + void SetBackgroundColour(const wxColour& colBack) + { m_colBack = colBack; m_bOwnerDrawn = true; } - wxColour& GetTextColour() const - { return (wxColour&) m_colText; } + wxColour& GetBackgroundColour() const + { return (wxColour&) m_colBack ; } - void SetBackgroundColour(const wxColour& colBack) - { m_colBack = colBack; m_ownerDrawn = true; } + void SetBitmaps(const wxBitmap& bmpChecked, + const wxBitmap& bmpUnchecked = wxNullBitmap) + { m_bmpChecked = bmpChecked; + m_bmpUnchecked = bmpUnchecked; + m_bOwnerDrawn = true; } - wxColour& GetBackgroundColour() const - { return (wxColour&) m_colBack ; } + void SetBitmap(const wxBitmap& bmpChecked) + { m_bmpChecked = bmpChecked; + m_bOwnerDrawn = true; } + void SetDisabledBitmap( const wxBitmap& bmpDisabled ) + { m_bmpDisabled = bmpDisabled; + m_bOwnerDrawn = true; } - void SetMarginWidth(int width) - { m_margin = width; } + const wxBitmap& GetBitmap(bool bChecked = true) const + { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } - int GetMarginWidth() const - { return m_margin; } + const wxBitmap& GetDisabledBitmap() const + { return m_bmpDisabled; } - static int GetDefaultMarginWidth() - { return ms_defaultMargin; } + // the height of the menu checkmark (or bitmap) is determined by the font + // for the current item, but the width should be always the same (for the + // items to be aligned), so by default it's taken to be the same as for + // the last item (and default width for the first one). + // + // NB: default is too small for bitmaps, but ok for checkmarks. + void SetMarginWidth(int nWidth) + { + ms_nLastMarginWidth = m_nMarginWidth = (size_t) nWidth; + if ( ((size_t) nWidth) != ms_nDefaultMarginWidth ) + m_bOwnerDrawn = true; + } + int GetMarginWidth() const { return (int) m_nMarginWidth; } + static int GetDefaultMarginWidth() { return (int) ms_nDefaultMarginWidth; } - // get item name (with mnemonics if exist) - virtual wxString GetName() const = 0; + // accessors + void SetName(const wxString& strName) { m_strName = strName; } + const wxString& GetName() const { return m_strName; } + void SetCheckable(bool checkable) { m_bCheckable = checkable; } + bool IsCheckable() const { return m_bCheckable; } + // this is for menu items only: accel string is drawn right aligned after the + // menu item if not empty + void SetAccelString(const wxString& strAccel) { m_strAccel = strAccel; } // this function might seem strange, but if it returns false it means that // no non-standard attribute are set, so there is no need for this control // to be owner-drawn. Moreover, you can force owner-drawn to false if you // want to change, say, the color for the item but only if it is owner-drawn // (see wxMenuItem::wxMenuItem for example) - bool IsOwnerDrawn() const - { return m_ownerDrawn; } + bool IsOwnerDrawn() const { return m_bOwnerDrawn; } - // switch on/off owner-drawing the item - void SetOwnerDrawn(bool ownerDrawn = true) - { m_ownerDrawn = ownerDrawn; } + // switch on/off owner-drawing the item + void SetOwnerDrawn(bool ownerDrawn = true) { m_bOwnerDrawn = ownerDrawn; } + void ResetOwnerDrawn() { m_bOwnerDrawn = false; } +public: + // constants used in OnDrawItem + // (they have the same values as corresponding Win32 constants) + enum wxODAction + { + wxODDrawAll = 0x0001, // redraw entire control + wxODSelectChanged = 0x0002, // selection changed (see Status.Select) + wxODFocusChanged = 0x0004 // keyboard focus changed (see Status.Focus) + }; - // constants used in OnDrawItem - // (they have the same values as corresponding Win32 constants) - enum wxODAction - { - wxODDrawAll = 0x0001, // redraw entire control - wxODSelectChanged = 0x0002, // selection changed (see Status.Select) - wxODFocusChanged = 0x0004 // keyboard focus changed (see Status.Focus) - }; + enum wxODStatus + { + wxODSelected = 0x0001, // control is currently selected + wxODGrayed = 0x0002, // item is to be grayed + wxODDisabled = 0x0004, // item is to be drawn as disabled + wxODChecked = 0x0008, // item is to be checked + wxODHasFocus = 0x0010, // item has the keyboard focus + wxODDefault = 0x0020, // item is the default item + wxODHidePrefix= 0x0100 // hide keyboard cues (w2k and xp only) + }; - enum wxODStatus - { - wxODSelected = 0x0001, // control is currently selected - wxODGrayed = 0x0002, // item is to be grayed - wxODDisabled = 0x0004, // item is to be drawn as disabled - wxODChecked = 0x0008, // item is to be checked - wxODHasFocus = 0x0010, // item has the keyboard focus - wxODDefault = 0x0020, // item is the default item - wxODHidePrefix= 0x0100 // hide keyboard cues (w2k and xp only) - }; - - // virtual functions to implement drawing (return true if processed) - virtual bool OnMeasureItem(size_t *width, size_t *height); - virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat) = 0; + // virtual functions to implement drawing (return true if processed) + virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight); + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); protected: + // return true if this is a menu item + bool IsMenuItem() const; - // get the font and colour to use, whether it is set or not - virtual void GetFontToUse(wxFont& font) const; - virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const; + // get the font to use, whether m_font is set or not + wxFont GetFontToUse() const; + + // Same as wxOwnerDrawn::SetMarginWidth() but does not affect + // ms_nLastMarginWidth. Exists solely to work around bug #4068, + // and will not exist in wxWidgets 2.9.0 and later. + void SetOwnMarginWidth(int nWidth) + { + m_nMarginWidth = (size_t) nWidth; + if ( ((size_t) nWidth) != ms_nDefaultMarginWidth ) + m_bOwnerDrawn = true; + } + + + wxString m_strName, // label for a manu item + m_strAccel; // the accel string ("Ctrl-F17") if any private: - bool m_ownerDrawn; // true if something is non standard + static size_t ms_nDefaultMarginWidth; // menu check mark width + static size_t ms_nLastMarginWidth; // handy for aligning all items - wxFont m_font; // font to use for drawing - wxColour m_colText, // color ----"---"---"---- - m_colBack; // background color + bool m_bCheckable, // used only for menu or check listbox items + m_bOwnerDrawn, // true if something is non standard + m_isMenuItem; // true if this is a menu item - int m_margin; // space occupied by bitmap to the left of the item + wxFont m_font; // font to use for drawing + wxColour m_colText, // color ----"---"---"---- + m_colBack; // background color + wxBitmap m_bmpChecked, // bitmap to put near the item + m_bmpUnchecked, // (checked is used also for 'uncheckable' items) + m_bmpDisabled; - static int ms_defaultMargin; + size_t m_nHeight, // font height + m_nMinHeight, // minimum height, as determined by user's system settings + m_nMarginWidth; // space occupied by bitmap to the left of the item }; -// ---------------------------------------------------------------------------- -// include the platform-specific class declaration -// ---------------------------------------------------------------------------- - -#if defined(__WXMSW__) - #include "wx/msw/ownerdrw.h" -#elif defined(__WXPM__) - #include "wx/os2/ownerdrw.h" -#endif - #endif // wxUSE_OWNER_DRAWN -#endif // _WX_OWNERDRW_H_BASE +#endif + // _OWNERDRW_H diff --git a/Source/3rd Party/wx/include/wx/palette.h b/Source/3rd Party/wx/include/wx/palette.h index 512c779ff..3b2e3cb78 100644 --- a/Source/3rd Party/wx/include/wx/palette.h +++ b/Source/3rd Party/wx/include/wx/palette.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: palette.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -19,26 +20,40 @@ #include "wx/gdiobj.h" // wxPaletteBase -class WXDLLIMPEXP_CORE wxPaletteBase: public wxGDIObject +class WXDLLEXPORT wxPaletteBase: public wxGDIObject { public: virtual ~wxPaletteBase() { } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const = 0; virtual int GetColoursCount() const { wxFAIL_MSG( wxT("not implemented") ); return 0; } }; -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/palmos/palette.h" +#elif defined(__WXMSW__) #include "wx/msw/palette.h" -#elif defined(__WXX11__) || defined(__WXMOTIF__) - #include "wx/x11/palette.h" +#elif defined(__WXMOTIF__) + #include "wx/motif/palette.h" #elif defined(__WXGTK__) || defined(__WXCOCOA__) #include "wx/generic/paletteg.h" +#elif defined(__WXX11__) + #include "wx/x11/palette.h" +#elif defined(__WXMGL__) + #include "wx/mgl/palette.h" #elif defined(__WXMAC__) - #include "wx/osx/palette.h" + #include "wx/mac/palette.h" #elif defined(__WXPM__) #include "wx/os2/palette.h" #endif +#if WXWIN_COMPATIBILITY_2_4 + #define wxColorMap wxPalette + #define wxColourMap wxPalette +#endif + #endif // wxUSE_PALETTE -#endif // _WX_PALETTE_H_BASE_ +#endif + // _WX_PALETTE_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/panel.h b/Source/3rd Party/wx/include/wx/panel.h index 7496bbf63..260e2b972 100644 --- a/Source/3rd Party/wx/include/wx/panel.h +++ b/Source/3rd Party/wx/include/wx/panel.h @@ -4,69 +4,15 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: panel.h 33948 2005-05-04 18:57:50Z JS $ // Copyright: (c) Julian Smart -// (c) 2011 Vadim Zeitlin // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PANEL_H_BASE_ #define _WX_PANEL_H_BASE_ -// ---------------------------------------------------------------------------- -// headers and forward declarations -// ---------------------------------------------------------------------------- +#include "wx/generic/panelg.h" -#include "wx/window.h" -#include "wx/containr.h" - -class WXDLLIMPEXP_FWD_CORE wxControlContainer; - -extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[]; - -// ---------------------------------------------------------------------------- -// wxPanel contains other controls and implements TAB traversal between them -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPanelBase : public wxNavigationEnabled -{ -public: - wxPanelBase() { } - - // Derived classes should also provide this constructor: - /* - wxPanelBase(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxPanelNameStr); - */ - - // Pseudo ctor - bool Create(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxPanelNameStr); - - - // implementation from now on - // -------------------------- - - virtual void InitDialog(); - -private: - wxDECLARE_NO_COPY_CLASS(wxPanelBase); -}; - -#if defined(__WXUNIVERSAL__) - #include "wx/univ/panel.h" -#elif defined(__WXMSW__) - #include "wx/msw/panel.h" -#else - #define wxHAS_GENERIC_PANEL - #include "wx/generic/panelg.h" #endif - -#endif // _WX_PANELH_BASE_ + // _WX_PANELH_BASE_ diff --git a/Source/3rd Party/wx/include/wx/paper.h b/Source/3rd Party/wx/include/wx/paper.h index 5f6a9c18d..fe69bd471 100644 --- a/Source/3rd Party/wx/include/wx/paper.h +++ b/Source/3rd Party/wx/include/wx/paper.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/paper.h +// Name: paper.h // Purpose: Paper database types and classes // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: paper.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h) #endif -class WXDLLIMPEXP_CORE wxPrintPaperType: public wxObject +class WXDLLEXPORT wxPrintPaperType: public wxObject { public: wxPrintPaperType(); @@ -69,7 +70,7 @@ WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType*, wxStringToPrintPaperTypeHashMap); class WXDLLIMPEXP_FWD_CORE wxPrintPaperTypeList; -class WXDLLIMPEXP_CORE wxPrintPaperDatabase +class WXDLLEXPORT wxPrintPaperDatabase { public: wxPrintPaperDatabase(); @@ -114,7 +115,7 @@ private: // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) }; -extern WXDLLIMPEXP_DATA_CORE(wxPrintPaperDatabase*) wxThePrintPaperDatabase; +extern WXDLLEXPORT_DATA(wxPrintPaperDatabase*) wxThePrintPaperDatabase; #endif diff --git a/Source/3rd Party/wx/include/wx/pen.h b/Source/3rd Party/wx/include/wx/pen.h index d630409d8..cd28212f5 100644 --- a/Source/3rd Party/wx/include/wx/pen.h +++ b/Source/3rd Party/wx/include/wx/pen.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: pen.h 40865 2006-08-27 09:42:42Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -11,154 +12,29 @@ #ifndef _WX_PEN_H_BASE_ #define _WX_PEN_H_BASE_ -#include "wx/gdiobj.h" -#include "wx/gdicmn.h" +#include "wx/defs.h" -enum wxPenStyle -{ - wxPENSTYLE_INVALID = -1, - - wxPENSTYLE_SOLID = wxSOLID, - wxPENSTYLE_DOT = wxDOT, - wxPENSTYLE_LONG_DASH = wxLONG_DASH, - wxPENSTYLE_SHORT_DASH = wxSHORT_DASH, - wxPENSTYLE_DOT_DASH = wxDOT_DASH, - wxPENSTYLE_USER_DASH = wxUSER_DASH, - - wxPENSTYLE_TRANSPARENT = wxTRANSPARENT, - - wxPENSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE, - wxPENSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK, - wxPENSTYLE_STIPPLE = wxSTIPPLE, - - wxPENSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL, - wxPENSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG, - wxPENSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL, - wxPENSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS, - wxPENSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL, - wxPENSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL, - wxPENSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST, - wxPENSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST -}; - -enum wxPenJoin -{ - wxJOIN_INVALID = -1, - - wxJOIN_BEVEL = 120, - wxJOIN_MITER, - wxJOIN_ROUND -}; - -enum wxPenCap -{ - wxCAP_INVALID = -1, - - wxCAP_ROUND = 130, - wxCAP_PROJECTING, - wxCAP_BUTT -}; - - -class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject -{ -public: - virtual ~wxPenBase() { } - - virtual void SetColour(const wxColour& col) = 0; - virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0; - - virtual void SetWidth(int width) = 0; - virtual void SetStyle(wxPenStyle style) = 0; - virtual void SetStipple(const wxBitmap& stipple) = 0; - virtual void SetDashes(int nb_dashes, const wxDash *dash) = 0; - virtual void SetJoin(wxPenJoin join) = 0; - virtual void SetCap(wxPenCap cap) = 0; - - virtual wxColour GetColour() const = 0; - virtual wxBitmap *GetStipple() const = 0; - virtual wxPenStyle GetStyle() const = 0; - virtual wxPenJoin GetJoin() const = 0; - virtual wxPenCap GetCap() const = 0; - virtual int GetWidth() const = 0; - virtual int GetDashes(wxDash **ptr) const = 0; - - // Convenient helpers for testing whether the pen is a transparent one: - // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if - // the pen is invalid (they both return false in this case). - bool IsTransparent() const - { - return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT; - } - - bool IsNonTransparent() const - { - return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT; - } -}; - -#if defined(__WXMSW__) - #include "wx/msw/pen.h" +#if defined(__WXPALMOS__) +#include "wx/palmos/pen.h" +#elif defined(__WXMSW__) +#include "wx/msw/pen.h" #elif defined(__WXMOTIF__) || defined(__WXX11__) - #include "wx/x11/pen.h" +#include "wx/x11/pen.h" #elif defined(__WXGTK20__) - #include "wx/gtk/pen.h" +#include "wx/gtk/pen.h" #elif defined(__WXGTK__) - #include "wx/gtk1/pen.h" +#include "wx/gtk1/pen.h" +#elif defined(__WXMGL__) +#include "wx/mgl/pen.h" #elif defined(__WXDFB__) - #include "wx/dfb/pen.h" +#include "wx/dfb/pen.h" #elif defined(__WXMAC__) - #include "wx/osx/pen.h" +#include "wx/mac/pen.h" #elif defined(__WXCOCOA__) - #include "wx/cocoa/pen.h" +#include "wx/cocoa/pen.h" #elif defined(__WXPM__) - #include "wx/os2/pen.h" +#include "wx/os2/pen.h" #endif -class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase -{ -public: - wxPen *FindOrCreatePen(const wxColour& colour, - int width = 1, - wxPenStyle style = wxPENSTYLE_SOLID); - -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - wxPen *FindOrCreatePen(const wxColour& colour, int width, int style) - { return FindOrCreatePen(colour, width, (wxPenStyle)style); } #endif -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( void AddPen(wxPen*) ); - wxDEPRECATED( void RemovePen(wxPen*) ); -#endif -}; - -extern WXDLLIMPEXP_DATA_CORE(wxPenList*) wxThePenList; - -// provide comparison operators to allow code such as -// -// if ( pen.GetStyle() == wxTRANSPARENT ) -// -// to compile without warnings which it would otherwise provoke from some -// compilers as it compares elements of different enums -#if FUTURE_WXWIN_COMPATIBILITY_3_0 - -// Unfortunately some compilers have ambiguity issues when enum comparisons are -// overloaded so we have to disable the overloads in this case, see -// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details. -#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM - -inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t) -{ - return static_cast(s) == static_cast(t); -} - -inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t) -{ - return !(s == t); -} - -#endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM - -#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 - -#endif // _WX_PEN_H_BASE_ + // _WX_PEN_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/persist.h b/Source/3rd Party/wx/include/wx/persist.h deleted file mode 100644 index 45ed61eb9..000000000 --- a/Source/3rd Party/wx/include/wx/persist.h +++ /dev/null @@ -1,263 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/persist.h -// Purpose: common classes for persistence support -// Author: Vadim Zeitlin -// Created: 2009-01-18 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PERSIST_H_ -#define _WX_PERSIST_H_ - -#include "wx/string.h" -#include "wx/hashmap.h" -#include "wx/confbase.h" - -class wxPersistentObject; - -WX_DECLARE_VOIDPTR_HASH_MAP(wxPersistentObject *, wxPersistentObjectsMap); - -// ---------------------------------------------------------------------------- -// global functions -// ---------------------------------------------------------------------------- - -/* - We do _not_ declare this function as doing this would force us to specialize - it for the user classes deriving from the standard persistent classes. - However we do define overloads of wxCreatePersistentObject() for all the wx - classes which means that template wxPersistentObject::Restore() picks up the - right overload to use provided that the header defining the correct overload - is included before calling it. And a compilation error happens if this is - not done. - -template -wxPersistentObject *wxCreatePersistentObject(T *obj); - - */ - -// ---------------------------------------------------------------------------- -// wxPersistenceManager: global aspects of persistent windows -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPersistenceManager -{ -public: - // Call this method to specify a non-default persistence manager to use. - // This function should usually be called very early to affect creation of - // all persistent controls and the object passed to it must have a lifetime - // long enough to be still alive when the persistent controls are destroyed - // and need it to save their state so typically this would be a global or a - // wxApp member. - static void Set(wxPersistenceManager& manager); - - // accessor to the unique persistence manager object - static wxPersistenceManager& Get(); - - // trivial but virtual dtor - // - // FIXME-VC6: this only needs to be public because of VC6 bug - virtual ~wxPersistenceManager(); - - - // globally disable restoring or saving the persistent properties (both are - // enabled by default) - void DisableSaving() { m_doSave = false; } - void DisableRestoring() { m_doRestore = false; } - - - // register an object with the manager: when using the first overload, - // wxCreatePersistentObject() must be specialized for this object class; - // with the second one the persistent adapter is created by the caller - // - // the object shouldn't be already registered with us - template - wxPersistentObject *Register(T *obj) - { - return Register(obj, wxCreatePersistentObject(obj)); - } - - wxPersistentObject *Register(void *obj, wxPersistentObject *po); - - // check if the object is registered and return the associated - // wxPersistentObject if it is or NULL otherwise - wxPersistentObject *Find(void *obj) const; - - // unregister the object, this is called by wxPersistentObject itself so - // there is usually no need to do it explicitly - // - // deletes the associated wxPersistentObject - void Unregister(void *obj); - - - // save/restore the state of an object - // - // these methods do nothing if DisableSaving/Restoring() was called - // - // Restore() returns true if the object state was really restored - void Save(void *obj); - bool Restore(void *obj); - - // combines both Save() and Unregister() calls - void SaveAndUnregister(void *obj) - { - Save(obj); - Unregister(obj); - } - - // combines both Register() and Restore() calls - template - bool RegisterAndRestore(T *obj) - { - return Register(obj) && Restore(obj); - } - - bool RegisterAndRestore(void *obj, wxPersistentObject *po) - { - return Register(obj, po) && Restore(obj); - } - - - // methods used by the persistent objects to save and restore the data - // - // currently these methods simply use wxConfig::Get() but they may be - // overridden in the derived class (once we allow creating custom - // persistent managers) -#define wxPERSIST_DECLARE_SAVE_RESTORE_FOR(Type) \ - virtual bool SaveValue(const wxPersistentObject& who, \ - const wxString& name, \ - Type value); \ - \ - virtual bool \ - RestoreValue(const wxPersistentObject& who, \ - const wxString& name, \ - Type *value) - - wxPERSIST_DECLARE_SAVE_RESTORE_FOR(bool); - wxPERSIST_DECLARE_SAVE_RESTORE_FOR(int); - wxPERSIST_DECLARE_SAVE_RESTORE_FOR(long); - wxPERSIST_DECLARE_SAVE_RESTORE_FOR(wxString); - -#undef wxPERSIST_DECLARE_SAVE_RESTORE_FOR - -protected: - // ctor is private, use Get() - wxPersistenceManager() - { - m_doSave = - m_doRestore = true; - } - - - // Return the config object to use, by default just the global one but a - // different one could be used by the derived class if needed. - virtual wxConfigBase *GetConfig() const { return wxConfigBase::Get(); } - - // Return the path to use for saving the setting with the given name for - // the specified object (notice that the name is the name of the setting, - // not the name of the object itself which can be retrieved with GetName()). - virtual wxString GetKey(const wxPersistentObject& who, - const wxString& name) const; - - -private: - // map with the registered objects as keys and associated - // wxPersistentObjects as values - wxPersistentObjectsMap m_persistentObjects; - - // true if we should restore/save the settings (it doesn't make much sense - // to use this class when both of them are false but setting one of them to - // false may make sense in some situations) - bool m_doSave, - m_doRestore; - - wxDECLARE_NO_COPY_CLASS(wxPersistenceManager); -}; - -// ---------------------------------------------------------------------------- -// wxPersistentObject: ABC for anything persistent -// ---------------------------------------------------------------------------- - -class wxPersistentObject -{ -public: - // ctor associates us with the object whose options we save/restore - wxPersistentObject(void *obj) : m_obj(obj) { } - - // trivial but virtual dtor - virtual ~wxPersistentObject() { } - - - // methods used by wxPersistenceManager - // ------------------------------------ - - // save/restore the corresponding objects settings - // - // these methods shouldn't be used directly as they don't respect the - // global wxPersistenceManager::DisableSaving/Restoring() settings, use - // wxPersistenceManager methods with the same name instead - virtual void Save() const = 0; - virtual bool Restore() = 0; - - - // get the kind of the objects we correspond to, e.g. "Frame" - virtual wxString GetKind() const = 0; - - // get the name of the object we correspond to, e.g. "Main" - virtual wxString GetName() const = 0; - - - // return the associated object - void *GetObject() const { return m_obj; } - -protected: - // wrappers for wxPersistenceManager methods which don't require passing - // "this" as the first parameter all the time - template - bool SaveValue(const wxString& name, T value) const - { - return wxPersistenceManager::Get().SaveValue(*this, name, value); - } - - template - bool RestoreValue(const wxString& name, T *value) - { - return wxPersistenceManager::Get().RestoreValue(*this, name, value); - } - -private: - void * const m_obj; - - wxDECLARE_NO_COPY_CLASS(wxPersistentObject); -}; - -// FIXME-VC6: VC6 has troubles with template methods of DLL-exported classes, -// apparently it believes they should be defined in the DLL (which -// is, of course, impossible as the DLL doesn't know for which types -// will they be instantiated) instead of compiling them when -// building the main application itself. Because of this problem -// (which only arises in debug build!) we can't use the usual -// RegisterAndRestore(obj) with it and need to explicitly create the -// persistence adapter. To hide this ugliness we define a global -// function which does it for us. -template -inline bool wxPersistentRegisterAndRestore(T *obj) -{ - wxPersistentObject * const pers = wxCreatePersistentObject(obj); - - return wxPersistenceManager::Get().RegisterAndRestore(obj, pers); - -} - -// A helper function which also sets the name for the (wxWindow-derived) object -// before registering and restoring it. -template -inline bool wxPersistentRegisterAndRestore(T *obj, const wxString& name) -{ - obj->SetName(name); - - return wxPersistentRegisterAndRestore(obj); -} - -#endif // _WX_PERSIST_H_ - diff --git a/Source/3rd Party/wx/include/wx/pickerbase.h b/Source/3rd Party/wx/include/wx/pickerbase.h index 01b6fe6cd..da79f2dea 100644 --- a/Source/3rd Party/wx/include/wx/pickerbase.h +++ b/Source/3rd Party/wx/include/wx/pickerbase.h @@ -5,6 +5,7 @@ // Modified by: // Created: 14/4/2006 // Copyright: (c) Vadim Zeitlin, Francesco Montorsi +// RCS-ID: $Id: pickerbase.h 49804 2007-11-10 01:09:42Z VZ $ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -18,7 +19,7 @@ class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class WXDLLIMPEXP_FWD_CORE wxToolTip; -extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[]; // ---------------------------------------------------------------------------- // wxPickerBase is the base class for the picker controls which support @@ -30,14 +31,13 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; // ---------------------------------------------------------------------------- #define wxPB_USE_TEXTCTRL 0x0002 -#define wxPB_SMALL 0x8000 -class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled +class WXDLLIMPEXP_CORE wxPickerBase : public wxControl { public: // ctor: text is the associated text control wxPickerBase() : m_text(NULL), m_picker(NULL), m_sizer(NULL) - { } + { m_container.SetContainerWindow(this); } virtual ~wxPickerBase() {} @@ -105,11 +105,6 @@ public: // public API wxControl *GetPickerCtrl() { return m_picker; } - void SetTextCtrl(wxTextCtrl* text) - { m_text = text; } - void SetPickerCtrl(wxControl* picker) - { m_picker = picker; } - // methods that derived class must/may override virtual void UpdatePickerFromTextCtrl() = 0; virtual void UpdateTextCtrlFromPicker() = 0; @@ -126,6 +121,8 @@ protected: void OnTextCtrlUpdate(wxCommandEvent &); void OnTextCtrlKillFocus(wxFocusEvent &); + void OnSize(wxSizeEvent &); + // returns the set of styles for the attached wxTextCtrl // from given wxPickerBase's styles virtual long GetTextCtrlStyle(long style) const @@ -181,6 +178,10 @@ protected: private: DECLARE_ABSTRACT_CLASS(wxPickerBase) + DECLARE_EVENT_TABLE() + + // This class must be something just like a panel... + WX_DECLARE_CONTROL_CONTAINER(); }; diff --git a/Source/3rd Party/wx/include/wx/platform.h b/Source/3rd Party/wx/include/wx/platform.h index 6d1238d3e..471e28eba 100644 --- a/Source/3rd Party/wx/include/wx/platform.h +++ b/Source/3rd Party/wx/include/wx/platform.h @@ -4,6 +4,7 @@ * Author: Vadim Zeitlin * Modified by: * Created: 29.10.01 (extracted from wx/defs.h) +* RCS-ID: $Id: platform.h 63300 2010-01-28 21:36:09Z MW $ * Copyright: (c) 1997-2001 Vadim Zeitlin * Licence: wxWindows licence */ @@ -13,105 +14,129 @@ #ifndef _WX_PLATFORM_H_ #define _WX_PLATFORM_H_ -#ifdef __WXMAC_XCODE__ -# include -# include -# include -# ifndef MAC_OS_X_VERSION_10_4 -# define MAC_OS_X_VERSION_10_4 1040 -# endif -# ifndef MAC_OS_X_VERSION_10_5 -# define MAC_OS_X_VERSION_10_5 1050 -# endif -# ifndef MAC_OS_X_VERSION_10_6 -# define MAC_OS_X_VERSION_10_6 1060 -# endif -# ifndef MAC_OS_X_VERSION_10_7 -# define MAC_OS_X_VERSION_10_7 1070 -# endif -# ifndef MAC_OS_X_VERSION_10_8 -# define MAC_OS_X_VERSION_10_8 1080 -# endif -# include "wx/osx/config_xcode.h" -# ifndef __WXOSX__ -# define __WXOSX__ 1 -# endif -# ifndef __WXMAC__ -# define __WXMAC__ 1 + +/* + Codewarrior doesn't define any Windows symbols until some headers + are included +*/ +#ifdef __MWERKS__ +# include +#endif + +/* + WXMAC variants + __WXMAC_CLASSIC__ means ppc non-carbon builds, __WXMAC_CARBON__ means + carbon API available (mach or cfm builds) , __WXMAC_OSX__ means mach-o + builds, running under 10.2 + only +*/ +#ifdef __WXMAC__ +# if defined(__MACH__) +# define __WXMAC_OSX__ +# define __WXMAC_CARBON__ +# include +# ifndef MAC_OS_X_VERSION_10_4 +# define MAC_OS_X_VERSION_10_4 1040 +# endif +# ifndef MAC_OS_X_VERSION_10_5 +# define MAC_OS_X_VERSION_10_5 1050 +# endif +# ifdef __WXMAC_XCODE__ +# include +# include "wx/mac/carbon/config_xcode.h" +# endif +# else +# if TARGET_CARBON +# define __WXMAC_CARBON__ +# else +# define __WXMAC_CLASSIC__ +# endif # endif #endif /* - We use __WINDOWS__ as our main identification symbol for Microsoft Windows - but it's actually not predefined directly by any commonly used compilers - (only Watcom defines it itself and it's not supported any longer), so we - define it ourselves if any of the following macros is defined: - - - MSVC _WIN32 (notice that this is also defined under Win64) - - Borland __WIN32__ - - Our __WXMSW__ which selects Windows as platform automatically + __WXOSX__ is a common define to wxMac (Carbon) and wxCocoa ports under OS X. */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__WXMSW__) -# ifndef __WINDOWS__ -# define __WINDOWS__ -# endif /* !__WINDOWS__ */ -#endif /* Any standard symbol indicating Windows */ +#if defined(__WXMAC_OSX__) || defined(__WXCOCOA__) +# define __WXOSX__ +#endif -#if defined(__WINDOWS__) - /* Select wxMSW under Windows if no other port is specified. */ -# if !defined(__WXMSW__) && !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) -# define __WXMSW__ +/* + first define Windows symbols if they're not defined on the command line: we + can autodetect everything we need if _WIN32 is defined + */ +#if defined(__CYGWIN__) && defined(__WINDOWS__) +# ifndef __WXMSW__ +# define __WXMSW__ +# endif + +# ifndef _WIN32 +# define _WIN32 +# endif + +# ifndef WIN32 +# define WIN32 +# endif +#endif + +#if defined(__PALMOS__) +# if __PALMOS__ == 0x06000000 +# define __WXPALMOS6__ # endif +# if __PALMOS__ == 0x05000000 +# define __WXPALMOS5__ +# endif +# ifndef __WXPALMOS__ +# define __WXPALMOS__ +# endif +# ifdef __WXMSW__ +# undef __WXMSW__ +# endif +# ifdef __WINDOWS__ +# undef __WINDOWS__ +# endif +# ifdef __WIN32__ +# undef __WIN32__ +# endif +# ifdef WIN32 +# undef WIN32 +# endif +# ifdef _WIN32 +# undef _WIN32 +# endif +#endif +#if defined(_WIN64) +# ifndef _WIN32 + /* + a lot of code (mistakenly) uses #ifdef _WIN32 to either test for + Windows or to test for !__WIN16__, so we must define _WIN32 for + Win64 as well to ensure that the existing code continues to work. + */ +# define _WIN32 +# endif /* !_WIN32 */ + +# ifndef __WIN64__ +# define __WIN64__ +# endif /* !__WIN64__ */ +#endif /* _WIN64 */ + +#if (defined(_WIN32) || defined(WIN32) || defined(__NT__) || defined(__WXWINCE__)) \ + && !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) +# ifndef __WXMSW__ +# define __WXMSW__ +# endif + +# ifndef __WIN32__ +# define __WIN32__ +# endif +#endif /* Win32 */ + +#if defined(__WXMSW__) || defined(__WIN32__) # if !defined(__WINDOWS__) # define __WINDOWS__ # endif - -# ifndef _WIN32 -# define _WIN32 -# endif - -# ifndef WIN32 -# define WIN32 -# endif - -# ifndef __WIN32__ -# define __WIN32__ -# endif - - /* MSVC predefines _WIN64 for 64 bit builds, for gcc we use generic - architecture definitions. */ -# if defined(_WIN64) || defined(__x86_64__) -# ifndef __WIN64__ -# define __WIN64__ -# endif /* !__WIN64__ */ -# endif /* _WIN64 */ - -#endif /* __WINDOWS__ */ - -/* - Don't use widget toolkit specific code in non-GUI code in the library - itself to ensure that the same base library is used for both MSW and GTK - ports. But keep __WXMSW__ defined for (console) applications using - wxWidgets for compatibility. - */ -#if defined(WXBUILDING) && defined(wxUSE_GUI) && !wxUSE_GUI -# ifdef __WXMSW__ -# undef __WXMSW__ -# endif -# ifdef __WXGTK__ -# undef __WXGTK__ -# endif #endif -#if defined(__WXGTK__) && defined(__WINDOWS__) - -# ifdef __WXMSW__ -# undef __WXMSW__ -# endif - -#endif /* __WXGTK__ && __WINDOWS__ */ - /* detect MS SmartPhone */ #if defined( WIN32_PLATFORM_WFSP ) # ifndef __SMARTPHONE__ @@ -157,39 +182,19 @@ # endif #endif -#if defined(__WXWINCE__) && defined(_MSC_VER) && (_MSC_VER == 1201) - #define __EVC4__ -#endif - #if defined(__POCKETPC__) || defined(__SMARTPHONE__) || defined(__WXGPE__) # define __WXHANDHELD__ #endif -#ifdef __ANDROID__ -# define __WXANDROID__ -# include "wx/android/config_android.h" -#endif - -#include "wx/compiler.h" - /* Include wx/setup.h for the Unix platform defines generated by configure and the library compilation options Note that it must be included before defining hardware symbols below as they - could be already defined by configure but it must be included after defining - the compiler macros above as msvc/wx/setup.h relies on them under Windows. + could be already defined by configure */ #include "wx/setup.h" -/* - Convenience for any optional classes that use the wxAnyButton base class. - */ -#if wxUSE_TOGGLEBTN || wxUSE_BUTTON - #define wxHAS_ANY_BUTTON -#endif - - /* Hardware platform detection. @@ -246,351 +251,44 @@ # endif #endif /* wxUSE_UNICODE */ +#if defined( __MWERKS__ ) && !defined(__INTEL__) +/* otherwise MSL headers bring in WIN32 dependant APIs */ +#undef UNICODE +#endif /* - test for old versions of Borland C, normally need at least 5.82, Turbo - explorer, available for free at http://www.turboexplorer.com/downloads + Notice that Turbo Explorer (BCC 5.82) is available for free at + http://www.turboexplorer.com/downloads, you can get it if you have trouble + compiling wxWidgets with your current Borland compiler. */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x540) +# error "wxWidgets requires a newer version of Borland, we recommend upgrading to 5.82 (Turbo Explorer). You may at your own risk remove this line and try building but be prepared to get build errors." +#endif /* __BORLANDC__ */ - -/* - Older versions of Borland C have some compiler bugs that need - workarounds. Mostly pertains to the free command line compiler 5.5.1. -*/ -#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) - /* - The Borland free compiler is unable to handle overloaded enum - comparisons under certain conditions e.g. when any class has a - conversion ctor for an integral type and there's an overload to - compare between an integral type and that class type. - */ -# define wxCOMPILER_NO_OVERLOAD_ON_ENUM - - /* - This is needed to overcome bugs in 5.5.1 STL, linking errors will - result if it is not defined. - */ -# define _RWSTD_COMPILE_INSTANTIATE - - /* - Preprocessor in older Borland compilers have major problems - concatenating with ##. Specifically, if the string operands being - concatenated have special meaning (e.g. L"str", 123i64 etc) - then ## will not concatenate the operands correctly. - - As a workaround, define wxPREPEND* and wxAPPEND* without using - wxCONCAT_HELPER. - */ -# define wxCOMPILER_BROKEN_CONCAT_OPER +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x582) && (__BORLANDC__ > 0x559) +# ifndef _USE_OLD_RW_STL +# error "wxWidgets is incompatible with default Borland C++ 5.6 STL library, please add -D_USE_OLD_RW_STL to your bcc32.cfg to use RogueWave STL implementation." +# endif #endif /* __BORLANDC__ */ /* - OS: first of all, test for MS-DOS platform. We must do this before testing - for Unix, because DJGPP compiler defines __unix__ under MS-DOS - */ -#if defined(__GO32__) || defined(__DJGPP__) || defined(__DOS__) -# ifndef __DOS__ -# define __DOS__ -# endif - /* size_t is the same as unsigned int for Watcom 11 compiler, */ - /* so define it if it hadn't been done by configure yet */ -# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) -# ifdef __WATCOMC__ -# define wxSIZE_T_IS_UINT -# endif -# ifdef __DJGPP__ -# define wxSIZE_T_IS_ULONG -# endif -# endif - -/* - OS: then test for generic Unix defines, then for particular flavours and - finally for Unix-like systems - Mac OS X matches this case (__MACH__), prior Mac OS do not. - */ -#elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \ - defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || \ - defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) || \ - defined(__EMX__) || defined(__VMS) || defined(__BEOS__) || defined(__MACH__) - -# define __UNIX_LIKE__ - -# ifdef __SGI__ -# ifdef __GNUG__ -# else /* !gcc */ - /* - Note I use the term __SGI_CC__ for both cc and CC, its not a good - idea to mix gcc and cc/CC, the name mangling is different - */ -# define __SGI_CC__ -# endif /* gcc/!gcc */ - - /* system headers use this symbol and not __cplusplus in some places */ -# ifndef _LANGUAGE_C_PLUS_PLUS -# define _LANGUAGE_C_PLUS_PLUS -# endif -# endif /* SGI */ - -# ifdef __EMX__ -# define OS2EMX_PLAIN_CHAR -# endif -# if defined(__INNOTEK_LIBC__) - /* Ensure visibility of strnlen declaration */ -# define _GNU_SOURCE -# endif - - /* define __HPUX__ for HP-UX where standard macro is __hpux */ -# if defined(__hpux) && !defined(__HPUX__) -# define __HPUX__ -# endif /* HP-UX */ - - /* All of these should already be defined by including configure- - generated setup.h but we wish to support Xcode compilation without - requiring the user to define these himself. - */ -# if defined(__APPLE__) && defined(__MACH__) -# ifndef __UNIX__ -# define __UNIX__ 1 -# endif -# ifndef __BSD__ -# define __BSD__ 1 -# endif - /* __DARWIN__ is our own define to mean OS X or pure Darwin */ -# ifndef __DARWIN__ -# define __DARWIN__ 1 -# endif - /* NOTE: TARGET_CARBON is actually a 0/1 and must be 1 for OS X */ -# ifndef TARGET_CARBON -# define TARGET_CARBON 1 -# endif - /* OS X uses unsigned long size_t for both ILP32 and LP64 modes. */ -# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) -# define wxSIZE_T_IS_ULONG -# endif -# endif - -/* - OS: OS/2 - */ -#elif defined(__OS2__) - - /* wxOS2 vs. non wxOS2 ports on OS2 platform */ -# if !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) -# ifndef __WXPM__ -# define __WXPM__ -# endif -# endif - -# if defined(__IBMCPP__) -# define __VISAGEAVER__ __IBMCPP__ -# endif - - /* Place other OS/2 compiler environment defines here */ -# if defined(__VISAGECPP__) - /* VisualAge is the only thing that understands _Optlink */ -# define LINKAGEMODE _Optlink -# endif -# define wxSIZE_T_IS_UINT - -/* - OS: Windows - */ -#elif defined(__WINDOWS__) - - /* to be changed for Win64! */ -# ifndef __WIN32__ -# error "__WIN32__ should be defined for Win32 and Win64, Win16 is not supported" -# endif - - /* size_t is the same as unsigned int for all Windows compilers we know, */ - /* so define it if it hadn't been done by configure yet */ -# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) && !defined(__WIN64__) -# define wxSIZE_T_IS_UINT -# endif + This macro can be used to test the Open Watcom version. +*/ +#ifndef __WATCOMC__ +# define wxWATCOM_VERSION(major,minor) 0 +# define wxCHECK_WATCOM_VERSION(major,minor) 0 +# define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0 +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# error "Only Open Watcom is supported in this release" #else -# error "Unknown platform." -#endif /* OS */ - -/* - if we're on a Unix system but didn't use configure (so that setup.h didn't - define __UNIX__), do define __UNIX__ now - */ -#if !defined(__UNIX__) && defined(__UNIX_LIKE__) -# define __UNIX__ -#endif /* Unix */ - -#if defined(__WXMOTIF__) || defined(__WXX11__) -# define __X__ -#endif - -/* - We get "Large Files (ILP32) not supported in strict ANSI mode." #error - from HP-UX standard headers when compiling with g++ without this: - */ -#if defined(__HPUX__) && !defined(__STDC_EXT__) -# define __STDC_EXT__ 1 -#endif - -/* Force linking against required libraries under Windows: */ -#ifdef __WXWINCE__ -# include "wx/msw/wince/libraries.h" -#elif defined __WINDOWS__ -# include "wx/msw/libraries.h" -#endif - -#if defined(__BORLANDC__) || (defined(__GNUC__) && __GNUC__ < 3) -#define wxNEEDS_CHARPP -#endif - -/* - Note that wx/msw/gccpriv.h must be included after defining UNICODE and - _UNICODE macros as it includes _mingw.h which relies on them being set. - */ -#if ( defined( __GNUWIN32__ ) || defined( __MINGW32__ ) || \ - ( defined( __CYGWIN__ ) && defined( __WINDOWS__ ) ) || \ - wxCHECK_WATCOM_VERSION(1,0) ) && \ - !defined(__DOS__) && \ - !defined(__WXPM__) && \ - !defined(__WXMOTIF__) && \ - !defined(__WXX11__) -# include "wx/msw/gccpriv.h" -#else -# undef wxCHECK_W32API_VERSION -# define wxCHECK_W32API_VERSION(maj, min) (0) -# undef wxCHECK_MINGW32_VERSION -# define wxCHECK_MINGW32_VERSION( major, minor ) (0) -#endif - - -/* - Handle Darwin gcc universal compilation. Don't do this in an Apple- - specific case since no sane compiler should be defining either - __BIG_ENDIAN__ or __LITTLE_ENDIAN__ unless it really is generating - code that will be hosted on a machine with the appropriate endianness. - If a compiler defines neither, assume the user or configure set - WORDS_BIGENDIAN appropriately. - */ -#if defined(__BIG_ENDIAN__) -# undef WORDS_BIGENDIAN -# define WORDS_BIGENDIAN 1 -#elif defined(__LITTLE_ENDIAN__) -# undef WORDS_BIGENDIAN -#elif defined(__WXMAC__) && !defined(WORDS_BIGENDIAN) -/* According to Stefan even ancient Mac compilers defined __BIG_ENDIAN__ */ -# warning "Compiling wxMac with probably wrong endianness" -#endif -/* also the 32/64 bit universal builds must be handled accordingly */ -#ifdef __DARWIN__ -# ifdef __LP64__ -# undef SIZEOF_VOID_P -# undef SIZEOF_LONG -# undef SIZEOF_SIZE_T -# define SIZEOF_VOID_P 8 -# define SIZEOF_LONG 8 -# define SIZEOF_SIZE_T 8 -# else -# undef SIZEOF_VOID_P -# undef SIZEOF_LONG -# undef SIZEOF_SIZE_T -# define SIZEOF_VOID_P 4 -# define SIZEOF_LONG 4 -# define SIZEOF_SIZE_T 4 -# endif -#endif - -/* - Define various OS X symbols before including wx/chkconf.h which uses them. - - __WXOSX_MAC__ means Mac OS X, non embedded - __WXOSX_IPHONE__ means OS X iPhone - */ - -/* - Normally all of __WXOSX_XXX__, __WXOSX__ and __WXMAC__ are defined by - configure but ensure that we also define them if configure was not used for - whatever reason. - - The primary symbol remains __WXOSX_XXX__ one, __WXOSX__ exists to allow - checking for any OS X port (Carbon and Cocoa) and __WXMAC__ is an old name - for it. - */ -#if defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__) || defined(__WXOSX_IPHONE__) -# ifndef __WXOSX__ -# define __WXOSX__ 1 -# endif -# ifndef __WXMAC__ -# define __WXMAC__ 1 -# endif -#endif - -#ifdef __WXOSX__ -/* setup precise defines according to sdk used */ -# include -# if defined(__WXOSX_IPHONE__) -# if !( defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE ) -# error "incorrect SDK for an iPhone build" -# endif -# else -# if wxUSE_GUI && !(defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__)) -# error "one of __WXOSX_IPHONE__, __WXOSX_CARBON__ or __WXOSX_COCOA__ must be defined for the GUI build" -# endif -# if !( defined(TARGET_OS_MAC) && TARGET_OS_MAC ) -# error "incorrect SDK for a Mac OS X build" -# endif -# define __WXOSX_MAC__ 1 -# endif -#endif - -#ifdef __WXOSX_MAC__ -# if defined(__MACH__) -# include -# ifndef MAC_OS_X_VERSION_10_4 -# define MAC_OS_X_VERSION_10_4 1040 -# endif -# ifndef MAC_OS_X_VERSION_10_5 -# define MAC_OS_X_VERSION_10_5 1050 -# endif -# ifndef MAC_OS_X_VERSION_10_6 -# define MAC_OS_X_VERSION_10_6 1060 -# endif -# ifndef MAC_OS_X_VERSION_10_7 -# define MAC_OS_X_VERSION_10_7 1070 -# endif -# ifndef MAC_OS_X_VERSION_10_8 -# define MAC_OS_X_VERSION_10_8 1080 -# endif -# else -# error "only mach-o configurations are supported" -# endif -#endif - -/* - __WXOSX_OR_COCOA__ is a common define to wxOSX (Carbon or Cocoa) and wxCocoa ports under OS X. - - DO NOT use this define in base library code. Although wxMac has its own - private base library (and thus __WXOSX_OR_COCOA__,__WXMAC__ and related defines are - valid there), wxCocoa shares its library with other ports like wxGTK and wxX11. - - To keep wx authors from screwing this up, only enable __WXOSX_OR_COCOA__ for wxCocoa when - not compiling the base library. We determine this by first checking if - wxUSE_BASE is not defined. If it is not defined, then we're not buildling - the base library, and possibly not building wx at all (but actually building - user code that's using wx). If it is defined then we must check to make sure - it is not true. If it is true, we're building base. - - If you want it in the common darwin base library then use __DARWIN__. You - can use any Darwin-available libraries like CoreFoundation but please avoid - using OS X libraries like Carbon or CoreServices. - - */ -#if defined(__WXOSX__) || (defined(__WXCOCOA__) && (!defined(wxUSE_BASE) || !wxUSE_BASE)) -# define __WXOSX_OR_COCOA__ 1 +# define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 ) +# define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) ) +# define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) ) #endif /* check the consistency of the settings in setup.h: note that this must be done after setting wxUSE_UNICODE correctly as it is used in wx/chkconf.h - and after defining the compiler macros which are used in it too */ #include "wx/chkconf.h" @@ -625,13 +323,290 @@ # define wxSTD #endif -/* On OpenVMS with the most recent HP C++ compiler some function (i.e. wscanf) - * are only available in the std-namespace. (BUG???) +/* + OS: first of all, test for MS-DOS platform. We must do this before testing + for Unix, because DJGPP compiler defines __unix__ under MS-DOS */ -#if defined( __VMS ) && (__DECCXX_VER >= 70100000) && !defined(__STD_CFRONT) && !defined( __NONAMESPACE_STD ) -# define wxVMS_USE_STD std:: +#if defined(__GO32__) || defined(__DJGPP__) || defined(__DOS__) +# ifndef __DOS__ +# define __DOS__ +# endif + /* size_t is the same as unsigned int for Watcom 11 compiler, */ + /* so define it if it hadn't been done by configure yet */ +# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) +# ifdef __WATCOMC__ +# define wxSIZE_T_IS_UINT +# endif +# ifdef __DJGPP__ +# define wxSIZE_T_IS_ULONG +# endif +# endif + +/* + OS: then test for generic Unix defines, then for particular flavours and + finally for Unix-like systems + Mac OS X matches this case (__MACH__), prior Mac OS do not. + */ +#elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \ + defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || \ + defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) || \ + defined(__EMX__) || defined(__VMS) || defined(__BEOS__) || defined(__MACH__) + +# define __UNIX_LIKE__ + + /* Helps SGI compilation, apparently */ +# ifdef __SGI__ +# ifdef __GNUG__ +# define __need_wchar_t +# else /* !gcc */ + /* + Note I use the term __SGI_CC__ for both cc and CC, its not a good + idea to mix gcc and cc/CC, the name mangling is different + */ +# define __SGI_CC__ +# endif /* gcc/!gcc */ + + /* system headers use this symbol and not __cplusplus in some places */ +# ifndef _LANGUAGE_C_PLUS_PLUS +# define _LANGUAGE_C_PLUS_PLUS +# endif +# endif /* SGI */ + +# if defined(sun) || defined(__SUN__) +# ifndef __GNUG__ +# ifndef __SUNCC__ +# define __SUNCC__ +# endif /* Sun CC */ +# endif +# endif /* Sun */ + +# ifdef __EMX__ +# define OS2EMX_PLAIN_CHAR +# endif + + /* define __HPUX__ for HP-UX where standard macro is __hpux */ +# if defined(__hpux) && !defined(__HPUX__) +# define __HPUX__ +# endif /* HP-UX */ + +# if defined(__CYGWIN__) || defined(__WINE__) +# if !defined(wxSIZE_T_IS_UINT) +# define wxSIZE_T_IS_UINT +# endif +# endif + + /* All of these should already be defined by including configure- + generated setup.h but we wish to support Xcode compilation without + requiring the user to define these himself. + */ +# if defined(__APPLE__) && defined(__MACH__) +# ifndef __UNIX__ +# define __UNIX__ 1 +# endif +# ifndef __BSD__ +# define __BSD__ 1 +# endif + /* __DARWIN__ is our own define to mean OS X or pure Darwin */ +# ifndef __DARWIN__ +# define __DARWIN__ 1 +# endif + /* NOTE: TARGET_CARBON is actually a 0/1 and must be 1 for OS X */ +# ifndef TARGET_CARBON +# define TARGET_CARBON 1 +# endif + /* OS X uses unsigned long size_t for both ILP32 and LP64 modes. */ +# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) +# define wxSIZE_T_IS_ULONG +# endif +# endif + +/* + OS: Classic Mac OS + */ +#elif defined(applec) || \ + defined(THINK_C) || \ + (defined(__MWERKS__) && !defined(__INTEL__)) + /* MacOS */ +# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) +# define wxSIZE_T_IS_ULONG +# endif + +/* + OS: OS/2 + */ +#elif defined(__OS2__) + + /* wxOS2 vs. non wxOS2 ports on OS2 platform */ +# if !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) +# ifndef __WXPM__ +# define __WXPM__ +# endif +# endif + +# if defined(__IBMCPP__) +# define __VISAGEAVER__ __IBMCPP__ +# endif + + /* Place other OS/2 compiler environment defines here */ +# if defined(__VISAGECPP__) + /* VisualAge is the only thing that understands _Optlink */ +# define LINKAGEMODE _Optlink +# endif +# define wxSIZE_T_IS_UINT + +/* + OS: Palm OS + */ +#elif defined(__PALMOS__) +# ifdef __WIN32__ +# error "__WIN32__ should not be defined for PalmOS" +# endif +# ifdef __WINDOWS__ +# error "__WINDOWS__ should not be defined for PalmOS" +# endif +# ifdef __WXMSW__ +# error "__WXMSW__ should not be defined for PalmOS" +# endif + +/* + OS: Otherwise it must be Windows + */ +#else /* Windows */ +# ifndef __WINDOWS__ +# define __WINDOWS__ +# endif /* Windows */ + + /* to be changed for Win64! */ +# ifndef __WIN32__ +# error "__WIN32__ should be defined for Win32 and Win64, Win16 is not supported" +# endif + + /* + define another standard symbol for Microsoft Visual C++: the standard + one (_MSC_VER) is also defined by Metrowerks compiler + */ +# if defined(_MSC_VER) && !defined(__MWERKS__) +# define __VISUALC__ _MSC_VER +# elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) +# define __BORLANDC__ +# elif defined(__WATCOMC__) +# elif defined(__SC__) +# define __SYMANTECC__ +# endif /* compiler */ + + /* size_t is the same as unsigned int for all Windows compilers we know, */ + /* so define it if it hadn't been done by configure yet */ +# if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG) && !defined(__WIN64__) +# define wxSIZE_T_IS_UINT +# endif +#endif /* OS */ + +/* + if we're on a Unix system but didn't use configure (so that setup.h didn't + define __UNIX__), do define __UNIX__ now + */ +#if !defined(__UNIX__) && defined(__UNIX_LIKE__) +# define __UNIX__ +#endif /* Unix */ + +#if defined(__WXMOTIF__) || defined(__WXX11__) +# define __X__ +#endif + +#ifdef __SC__ +# ifdef __DMC__ +# define __DIGITALMARS__ +# else +# define __SYMANTEC__ +# endif +#endif + +#ifdef __INTEL_COMPILER +# define __INTELC__ +#endif + +/* + We get "Large Files (ILP32) not supported in strict ANSI mode." #error + from HP-UX standard headers when compiling with g++ without this: + */ +#if defined(__HPUX__) && !defined(__STDC_EXT__) +# define __STDC_EXT__ 1 +#endif + +/* Force linking against required libraries under Windows: */ +#ifdef __WXWINCE__ +# include "wx/msw/wince/libraries.h" +#elif defined __WINDOWS__ +# include "wx/msw/libraries.h" +#endif + +/* + This macro can be used to test the gcc version and can be used like this: + +# if wxCHECK_GCC_VERSION(3, 1) + ... we have gcc 3.1 or later ... +# else + ... no gcc at all or gcc < 3.1 ... +# endif +*/ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) + #define wxCHECK_GCC_VERSION( major, minor ) \ + ( ( __GNUC__ > (major) ) \ + || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) #else -# define wxVMS_USE_STD + #define wxCHECK_GCC_VERSION( major, minor ) 0 +#endif + +#if defined(__BORLANDC__) || (defined(__GNUC__) && __GNUC__ < 3) +#define wxNEEDS_CHARPP +#endif + +/* + This macro can be used to check that the version of mingw32 compiler is + at least maj.min + */ +#if ( defined( __GNUWIN32__ ) || defined( __MINGW32__ ) || \ + ( defined( __CYGWIN__ ) && defined( __WINDOWS__ ) ) || \ + wxCHECK_WATCOM_VERSION(1,0) ) && \ + !defined(__DOS__) && \ + !defined(__WXPM__) && \ + !defined(__WXMOTIF__) && \ + !defined(__WXGTK__) && \ + !defined(__WXX11__) && \ + !defined(__WXPALMOS__) +# include "wx/msw/gccpriv.h" +#else +# undef wxCHECK_W32API_VERSION +# define wxCHECK_W32API_VERSION(maj, min) (0) +# undef wxCHECK_MINGW32_VERSION +# define wxCHECK_MINGW32_VERSION(maj, min) (0) +#endif + +#if defined (__WXMSW__) +# if !wxONLY_WATCOM_EARLIER_THAN(1, 8) +# define wxHAVE_RAW_BITMAP +# endif +#endif +#if defined(__WXGTK20__) || defined(__WXMAC__) +# define wxHAVE_RAW_BITMAP +#endif + +/* + Handle Darwin gcc universal compilation. Don't do this in an Apple- + specific case since no sane compiler should be defining either + __BIG_ENDIAN__ or __LITTLE_ENDIAN__ unless it really is generating + code that will be hosted on a machine with the appropriate endianness. + If a compiler defines neither, assume the user or configure set + WORDS_BIGENDIAN appropriately. + */ +#if defined(__BIG_ENDIAN__) +# undef WORDS_BIGENDIAN +# define WORDS_BIGENDIAN 1 +#elif defined(__LITTLE_ENDIAN__) +# undef WORDS_BIGENDIAN +#elif defined(__WXMAC__) && !defined(WORDS_BIGENDIAN) +/* According to Stefan even ancient Mac compilers defined __BIG_ENDIAN__ */ +# warning "Compiling wxMac with probably wrong endianness" #endif #ifdef __VMS @@ -645,10 +620,10 @@ /* Choose which method we will use for updating menus * - in OnIdle, or when we receive a wxEVT_MENU_OPEN event. - * Presently, only Windows, OS X and GTK+ support wxEVT_MENU_OPEN. + * Presently, only Windows and GTK+ support wxEVT_MENU_OPEN. */ #ifndef wxUSE_IDLEMENUUPDATES -# if (defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXOSX__)) && !defined(__WXUNIVERSAL__) +# if (defined(__WXMSW__) || defined(__WXGTK__)) && !defined(__WXUNIVERSAL__) # define wxUSE_IDLEMENUUPDATES 0 # else # define wxUSE_IDLEMENUUPDATES 1 @@ -662,7 +637,7 @@ */ #ifndef wxUSE_FILECONFIG -# if wxUSE_CONFIG && wxUSE_TEXTFILE +# if wxUSE_CONFIG # define wxUSE_FILECONFIG 1 # else # define wxUSE_FILECONFIG 0 @@ -678,28 +653,12 @@ #endif /* - Optionally supported C++ features. - */ - -/* - RTTI: if it is disabled in build/msw/makefile.* then this symbol will - already be defined but it's also possible to do it from configure (with - g++) or by editing project files with MSVC so test for it here too. - */ -#ifndef wxNO_RTTI - /* - Only 4.3 defines __GXX_RTTI by default so its absence is not an - indication of disabled RTTI with the previous versions. - */ -# if wxCHECK_GCC_VERSION(4, 3) -# ifndef __GXX_RTTI -# define wxNO_RTTI -# endif -# elif defined(_MSC_VER) -# ifndef _CPPRTTI -# define wxNO_RTTI -# endif -# endif -#endif /* wxNO_RTTI */ + We need AvailabilityMacros.h for ifdefing out things that don't exist on + OSX 10.2 and lower + FIXME: We need a better way to detect for 10.3 then including a system header +*/ +#ifdef __DARWIN__ + #include +#endif #endif /* _WX_PLATFORM_H_ */ diff --git a/Source/3rd Party/wx/include/wx/platinfo.h b/Source/3rd Party/wx/include/wx/platinfo.h index b1a7efb28..d9382dd2e 100644 --- a/Source/3rd Party/wx/include/wx/platinfo.h +++ b/Source/3rd Party/wx/include/wx/platinfo.h @@ -4,8 +4,9 @@ // Author: Francesco Montorsi // Modified by: // Created: 07.07.2006 (based on wxToolkitInfo) +// RCS-ID: $Id: platinfo.h 41807 2006-10-09 15:58:56Z VZ $ // Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_PLATINFO_H_ @@ -14,7 +15,7 @@ #include "wx/string.h" // ---------------------------------------------------------------------------- -// wxPlatformInfo enums & structs +// wxPlatformInfo // ---------------------------------------------------------------------------- // VERY IMPORTANT: when changing these enum values, also change the relative @@ -71,14 +72,15 @@ enum wxPortId wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo - wxPORT_DFB = 1 << 4, // wxDFB, using wxUniversal + wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager - wxPORT_MAC = 1 << 7, // wxOSX (former wxMac), using Cocoa, Carbon or iPhone API - wxPORT_OSX = wxPORT_MAC, // wxOSX, using Cocoa, Carbon or iPhone API + wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API - wxPORT_WINCE = 1 << 9 // wxWinCE, toolkit is WinCE SDK API + wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API + wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API + wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal }; // architecture of the operating system @@ -107,31 +109,6 @@ enum wxEndianness wxENDIAN_MAX }; -// informations about a linux distro returned by the lsb_release utility -struct wxLinuxDistributionInfo -{ - wxString Id; - wxString Release; - wxString CodeName; - wxString Description; - - bool operator==(const wxLinuxDistributionInfo& ldi) const - { - return Id == ldi.Id && - Release == ldi.Release && - CodeName == ldi.CodeName && - Description == ldi.Description; - } - - bool operator!=(const wxLinuxDistributionInfo& ldi) const - { return !(*this == ldi); } -}; - - -// ---------------------------------------------------------------------------- -// wxPlatformInfo -// ---------------------------------------------------------------------------- - // Information about the toolkit that the app is running under and some basic // platform and architecture info class WXDLLIMPEXP_BASE wxPlatformInfo @@ -179,7 +156,6 @@ public: static wxString GetArchName(wxArchitecture arch); static wxString GetEndiannessName(wxEndianness end); - // getters // ----------------- @@ -215,8 +191,6 @@ public: wxOperatingSystemId GetOperatingSystemId() const { return m_os; } - wxLinuxDistributionInfo GetLinuxDistributionInfo() const - { return m_ldi; } wxPortId GetPortId() const { return m_port; } wxArchitecture GetArchitecture() const @@ -240,16 +214,6 @@ public: { return GetArchName(m_arch); } wxString GetEndiannessName() const { return GetEndiannessName(m_endian); } - wxString GetOperatingSystemDescription() const - { return m_osDesc; } - wxString GetDesktopEnvironment() const - { return m_desktopEnv; } - - static wxString GetOperatingSystemDirectory(); - // doesn't make sense to store inside wxPlatformInfo the OS directory, - // thus this function is static; note that this function simply calls - // wxGetOSDirectory() and is here just to make it easier for the user to - // find it that feature (global functions can be difficult to find in the docs) // setters // ----------------- @@ -261,8 +225,6 @@ public: void SetOperatingSystemId(wxOperatingSystemId n) { m_os = n; } - void SetOperatingSystemDescription(const wxString& desc) - { m_osDesc = desc; } void SetPortId(wxPortId n) { m_port = n; } void SetArchitecture(wxArchitecture n) @@ -270,12 +232,6 @@ public: void SetEndianness(wxEndianness n) { m_endian = n; } - void SetDesktopEnvironment(const wxString& de) - { m_desktopEnv = de; } - void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di) - { m_ldi = di; } - - // miscellaneous // ----------------- @@ -283,13 +239,9 @@ public: { return m_osVersionMajor != -1 && m_osVersionMinor != -1 && m_os != wxOS_UNKNOWN && - !m_osDesc.IsEmpty() && m_tkVersionMajor != -1 && m_tkVersionMinor != -1 && m_port != wxPORT_UNKNOWN && - m_arch != wxARCH_INVALID && - m_endian != wxENDIAN_INVALID; - - // do not check linux-specific info; it's ok to have them empty + m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID; } @@ -313,16 +265,6 @@ protected: // Operating system ID. wxOperatingSystemId m_os; - // Operating system description. - wxString m_osDesc; - - - // linux-specific - // ----------------- - - wxString m_desktopEnv; - wxLinuxDistributionInfo m_ldi; - // toolkit // ----------------- @@ -341,7 +283,7 @@ protected: // others // ----------------- - // architecture of the OS/machine + // architecture of the OS wxArchitecture m_arch; // endianness of the machine @@ -359,7 +301,9 @@ protected: #define wxWinCE wxOS_WINDOWS_CE #define wxWIN32S wxOS_WINDOWS_9X + #define wxPalmOS wxPORT_PALMOS #define wxOS2 wxPORT_OS2 + #define wxMGL wxPORT_MGL #define wxCocoa wxPORT_MAC #define wxMac wxPORT_MAC #define wxMotif wxPORT_MOTIF diff --git a/Source/3rd Party/wx/include/wx/popupwin.h b/Source/3rd Party/wx/include/wx/popupwin.h index 0a6e1973a..c72eafeb6 100644 --- a/Source/3rd Party/wx/include/wx/popupwin.h +++ b/Source/3rd Party/wx/include/wx/popupwin.h @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 06.01.01 +// RCS-ID: $Id: popupwin.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_POPUPWIN_H_BASE_ @@ -15,14 +16,14 @@ #if wxUSE_POPUPWIN -#include "wx/nonownedwnd.h" +#include "wx/window.h" // ---------------------------------------------------------------------------- // wxPopupWindow: a special kind of top level window used for popup menus, // combobox popups and such. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPopupWindowBase : public wxNonOwnedWindow +class WXDLLEXPORT wxPopupWindowBase : public wxWindow { public: wxPopupWindowBase() { } @@ -46,7 +47,7 @@ public: virtual bool IsTopLevel() const { return true; } - wxDECLARE_NO_COPY_CLASS(wxPopupWindowBase); + DECLARE_NO_COPY_CLASS(wxPopupWindowBase) }; @@ -63,10 +64,10 @@ public: #include "wx/x11/popupwin.h" #elif defined(__WXMOTIF__) #include "wx/motif/popupwin.h" -#elif defined(__WXDFB__) - #include "wx/dfb/popupwin.h" +#elif defined(__WXMGL__) + #include "wx/mgl/popupwin.h" #elif defined(__WXMAC__) - #include "wx/osx/popupwin.h" + #include "wx/mac/popupwin.h" #else #error "wxPopupWindow is not supported under this platform." #endif @@ -79,7 +80,7 @@ public: class WXDLLIMPEXP_FWD_CORE wxPopupWindowHandler; class WXDLLIMPEXP_FWD_CORE wxPopupFocusHandler; -class WXDLLIMPEXP_CORE wxPopupTransientWindow : public wxPopupWindow +class WXDLLEXPORT wxPopupTransientWindow : public wxPopupWindow { public: // ctors @@ -103,15 +104,12 @@ public: // called when a mouse is pressed while the popup is shown: return true // from here to prevent its normal processing by the popup (which consists - // in dismissing it if the mouse is clicked outside it) + // in dismissing it if the mouse is cilcked outside it) virtual bool ProcessLeftDown(wxMouseEvent& event); // Overridden to grab the input on some plaforms virtual bool Show( bool show = true ); - // Override to implement delayed destruction of this window. - virtual bool Destroy(); - protected: // common part of all ctors void Init(); @@ -129,9 +127,8 @@ protected: // get alerted when child gets deleted from under us void OnDestroy(wxWindowDestroyEvent& event); -#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON) - // Check if the mouse needs to be captured or released: we must release - // when it's inside our window if we want the embedded controls to work. +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) + // check if the mouse needs captured or released void OnIdle(wxIdleEvent& event); #endif @@ -151,7 +148,7 @@ protected: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxPopupTransientWindow) - wxDECLARE_NO_COPY_CLASS(wxPopupTransientWindow); + DECLARE_NO_COPY_CLASS(wxPopupTransientWindow) }; #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) @@ -160,10 +157,10 @@ protected: // wxPopupComboWindow: wxPopupTransientWindow used by wxComboBox // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_CORE wxComboBox; -class WXDLLIMPEXP_FWD_CORE wxComboCtrl; +class WXDLLEXPORT wxComboBox; +class WXDLLEXPORT wxComboCtrl; -class WXDLLIMPEXP_CORE wxPopupComboWindow : public wxPopupTransientWindow +class WXDLLEXPORT wxPopupComboWindow : public wxPopupTransientWindow { public: wxPopupComboWindow() { m_combo = NULL; } diff --git a/Source/3rd Party/wx/include/wx/position.h b/Source/3rd Party/wx/include/wx/position.h deleted file mode 100644 index bd324e234..000000000 --- a/Source/3rd Party/wx/include/wx/position.h +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/position.h -// Purpose: Common structure and methods for positional information. -// Author: Vadim Zeitlin, Robin Dunn, Brad Anderson, Bryan Petty -// Created: 2007-03-13 -// Copyright: (c) 2007 The wxWidgets Team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_POSITION_H_ -#define _WX_POSITION_H_ - -#include "wx/gdicmn.h" - -class WXDLLIMPEXP_CORE wxPosition -{ -public: - wxPosition() : m_row(0), m_column(0) {} - wxPosition(int row, int col) : m_row(row), m_column(col) {} - - // default copy ctor and assignment operator are okay. - - int GetRow() const { return m_row; } - int GetColumn() const { return m_column; } - int GetCol() const { return GetColumn(); } - void SetRow(int row) { m_row = row; } - void SetColumn(int column) { m_column = column; } - void SetCol(int column) { SetColumn(column); } - - bool operator==(const wxPosition& p) const - { return m_row == p.m_row && m_column == p.m_column; } - bool operator!=(const wxPosition& p) const - { return !(*this == p); } - - wxPosition& operator+=(const wxPosition& p) - { m_row += p.m_row; m_column += p.m_column; return *this; } - wxPosition& operator-=(const wxPosition& p) - { m_row -= p.m_row; m_column -= p.m_column; return *this; } - wxPosition& operator+=(const wxSize& s) - { m_row += s.y; m_column += s.x; return *this; } - wxPosition& operator-=(const wxSize& s) - { m_row -= s.y; m_column -= s.x; return *this; } - - wxPosition operator+(const wxPosition& p) const - { return wxPosition(m_row + p.m_row, m_column + p.m_column); } - wxPosition operator-(const wxPosition& p) const - { return wxPosition(m_row - p.m_row, m_column - p.m_column); } - wxPosition operator+(const wxSize& s) const - { return wxPosition(m_row + s.y, m_column + s.x); } - wxPosition operator-(const wxSize& s) const - { return wxPosition(m_row - s.y, m_column - s.x); } - -private: - int m_row; - int m_column; -}; - -#endif // _WX_POSITION_H_ - diff --git a/Source/3rd Party/wx/include/wx/power.h b/Source/3rd Party/wx/include/wx/power.h index 2cb80c7e1..66492cb55 100644 --- a/Source/3rd Party/wx/include/wx/power.h +++ b/Source/3rd Party/wx/include/wx/power.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2006-05-27 +// RCS-ID: $Id: power.h 48811 2007-09-19 23:11:28Z RD $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -41,16 +42,13 @@ enum wxBatteryState // compiling in the code for handling them which is never going to be invoked // under the other platforms, we define wxHAS_POWER_EVENTS symbol if this event // is available, it should be used to guard all code using wxPowerEvent -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #define wxHAS_POWER_EVENTS class WXDLLIMPEXP_BASE wxPowerEvent : public wxEvent { public: - wxPowerEvent() // just for use by wxRTTI - : m_veto(false) { } - wxPowerEvent(wxEventType evtType) : wxEvent(wxID_NONE, evtType) { m_veto = false; @@ -69,18 +67,23 @@ public: private: bool m_veto; - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPowerEvent) +#if wxABI_VERSION >= 20806 + DECLARE_ABSTRACT_CLASS(wxPowerEvent) +#endif }; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPENDING, wxPowerEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPENDED, wxPowerEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPEND_CANCEL, wxPowerEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_BASE, wxEVT_POWER_RESUME, wxPowerEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPENDING, 406) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPENDED, 407) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_POWER_SUSPEND_CANCEL, 408) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_POWER_RESUME, 444) +END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxPowerEventFunction)(wxPowerEvent&); #define wxPowerEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxPowerEventFunction, func) + (wxObjectEventFunction)(wxEventFunction) \ + wxStaticCastEvent(wxPowerEventFunction, &func) #define EVT_POWER_SUSPENDING(func) \ wx__DECLARE_EVT0(wxEVT_POWER_SUSPENDING, wxPowerEventHandler(func)) diff --git a/Source/3rd Party/wx/include/wx/preferences.h b/Source/3rd Party/wx/include/wx/preferences.h deleted file mode 100644 index 7eee64828..000000000 --- a/Source/3rd Party/wx/include/wx/preferences.h +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/preferences.h -// Purpose: Declaration of wxPreferencesEditor class. -// Author: Vaclav Slavik -// Created: 2013-02-19 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PREFERENCES_H_ -#define _WX_PREFERENCES_H_ - -#include "wx/defs.h" - -#if wxUSE_PREFERENCES_EDITOR - -#include "wx/bitmap.h" -#include "wx/vector.h" - -class WXDLLIMPEXP_FWD_CORE wxWindow; - -class wxPreferencesEditorImpl; - -#if defined(__WXOSX_COCOA__) - // GetLargeIcon() is used - #define wxHAS_PREF_EDITOR_ICONS - // Changes should be applied immediately - #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY - // The dialog is shown non-modally. - #define wxHAS_PREF_EDITOR_MODELESS -#elif defined(__WXGTK__) - // Changes should be applied immediately - #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY - // The dialog is shown non-modally. - #define wxHAS_PREF_EDITOR_MODELESS -#endif - -// ---------------------------------------------------------------------------- -// wxPreferencesEditor: Native preferences editing -// ---------------------------------------------------------------------------- - -// One page of a preferences window -class WXDLLIMPEXP_CORE wxPreferencesPage -{ -public: - wxPreferencesPage() {} - virtual ~wxPreferencesPage() {} - - // Name of the page, used e.g. for tabs - virtual wxString GetName() const = 0; - - // Return 32x32 icon used for the page. Currently only used on OS X, where - // implementation is required; unused on other platforms. Because of this, - // the method is only pure virtual on platforms that use it. -#ifdef wxHAS_PREF_EDITOR_ICONS - virtual wxBitmap GetLargeIcon() const = 0; -#else - virtual wxBitmap GetLargeIcon() const { return wxBitmap(); } -#endif - - // Create a window (usually a wxPanel) for this page. The caller takes - // ownership of the returned window. - virtual wxWindow *CreateWindow(wxWindow *parent) = 0; - - wxDECLARE_NO_COPY_CLASS(wxPreferencesPage); -}; - - -// Helper for implementing some common pages (General, Advanced) -class WXDLLIMPEXP_CORE wxStockPreferencesPage : public wxPreferencesPage -{ -public: - enum Kind - { - Kind_General, - Kind_Advanced - }; - - wxStockPreferencesPage(Kind kind) : m_kind(kind) {} - Kind GetKind() const { return m_kind; } - - virtual wxString GetName() const; -#ifdef __WXOSX_COCOA__ - virtual wxBitmap GetLargeIcon() const; -#endif - -private: - Kind m_kind; -}; - - -// Notice that this class does not inherit from wxWindow. -class WXDLLIMPEXP_CORE wxPreferencesEditor -{ -public: - // Ctor creates an empty editor, use AddPage() to add controls to it. - wxPreferencesEditor(const wxString& title = wxString()); - - // Dtor destroys the dialog if still shown. - virtual ~wxPreferencesEditor(); - - // Add a new page to the editor. The editor takes ownership of the page - // and won't delete it until it is destroyed itself. - void AddPage(wxPreferencesPage *page); - - // Show the preferences dialog or bring it to the top if it's already - // shown. Notice that this method may or may not block depending on the - // platform, i.e. depending on whether the dialog is modal or not. - virtual void Show(wxWindow* parent); - - // Hide the currently shown dialog, if any. This is typically used to - // dismiss the dialog if the object whose preferences it is editing was - // closed. - void Dismiss(); - - // Whether changes to values in the pages should be applied immediately - // (OS X, GTK+) or only when the user clicks OK/Apply (Windows) - static bool ShouldApplyChangesImmediately() - { -#ifdef wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY - return true; -#else - return false; -#endif - } - - // Whether the dialog is shown modally, i.e. Show() blocks, or not. - static bool ShownModally() - { -#ifdef wxHAS_PREF_EDITOR_MODELESS - return false; -#else - return true; -#endif - } - -private: - wxPreferencesEditorImpl* m_impl; - - wxDECLARE_NO_COPY_CLASS(wxPreferencesEditor); -}; - -#endif // wxUSE_PREFERENCES_EDITOR - -#endif // _WX_PREFERENCES_H_ diff --git a/Source/3rd Party/wx/include/wx/print.h b/Source/3rd Party/wx/include/wx/print.h index b6174212b..e4cf1e2e7 100644 --- a/Source/3rd Party/wx/include/wx/print.h +++ b/Source/3rd Party/wx/include/wx/print.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: print.h 41240 2006-09-15 16:45:48Z PC $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ #elif defined(__WXMAC__) -#include "wx/osx/printmac.h" +#include "wx/mac/printmac.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/printdlg.h b/Source/3rd Party/wx/include/wx/printdlg.h index d742e7598..4c98d251d 100644 --- a/Source/3rd Party/wx/include/wx/printdlg.h +++ b/Source/3rd Party/wx/include/wx/printdlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: printdlg.h 41020 2006-09-05 20:47:48Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -25,7 +26,7 @@ // wxPrintDialogBase: interface for the dialog for printing // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintDialogBase : public wxDialog +class WXDLLEXPORT wxPrintDialogBase : public wxDialog { public: wxPrintDialogBase() { } @@ -35,21 +36,21 @@ public: const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); - + virtual wxPrintDialogData& GetPrintDialogData() = 0; virtual wxPrintData& GetPrintData() = 0; virtual wxDC *GetPrintDC() = 0; - + private: DECLARE_ABSTRACT_CLASS(wxPrintDialogBase) - wxDECLARE_NO_COPY_CLASS(wxPrintDialogBase); + DECLARE_NO_COPY_CLASS(wxPrintDialogBase) }; // --------------------------------------------------------------------------- // wxPrintDialog: the dialog for printing. // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintDialog : public wxObject +class WXDLLEXPORT wxPrintDialog : public wxObject { public: wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL); @@ -61,20 +62,20 @@ public: virtual wxPrintDialogData& GetPrintDialogData(); virtual wxPrintData& GetPrintData(); virtual wxDC *GetPrintDC(); - + private: wxPrintDialogBase *m_pimpl; - + private: DECLARE_DYNAMIC_CLASS(wxPrintDialog) - wxDECLARE_NO_COPY_CLASS(wxPrintDialog); + DECLARE_NO_COPY_CLASS(wxPrintDialog) }; // --------------------------------------------------------------------------- // wxPageSetupDialogBase: interface for the page setup dialog // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPageSetupDialogBase: public wxDialog +class WXDLLEXPORT wxPageSetupDialogBase: public wxDialog { public: wxPageSetupDialogBase() { } @@ -89,14 +90,14 @@ public: private: DECLARE_ABSTRACT_CLASS(wxPageSetupDialogBase) - wxDECLARE_NO_COPY_CLASS(wxPageSetupDialogBase); + DECLARE_NO_COPY_CLASS(wxPageSetupDialogBase) }; // --------------------------------------------------------------------------- // wxPageSetupDialog: the page setup dialog // --------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPageSetupDialog: public wxObject +class WXDLLEXPORT wxPageSetupDialog: public wxObject { public: wxPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data = NULL); @@ -109,10 +110,10 @@ public: private: wxPageSetupDialogBase *m_pimpl; - + private: DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) - wxDECLARE_NO_COPY_CLASS(wxPageSetupDialog); + DECLARE_NO_COPY_CLASS(wxPageSetupDialog) }; #endif diff --git a/Source/3rd Party/wx/include/wx/private/browserhack28.h b/Source/3rd Party/wx/include/wx/private/browserhack28.h new file mode 100644 index 000000000..28d6da71b --- /dev/null +++ b/Source/3rd Party/wx/include/wx/private/browserhack28.h @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/private/browserhack28.h +// Purpose: Allows GUI library to override base wxLaunchDefaultBrowser. +// Author: David Elliott +// Modified by: +// Created: 2007-08-19 +// RCS-ID: $Id: browserhack28.h 48184 2007-08-19 19:22:09Z DE $ +// Copyright: (c) David Elliott +// Licence: wxWidgets licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRIVATE_BROWSERHACK28_H_ +#define _WX_PRIVATE_BROWSERHACK28_H_ + +typedef bool (*wxLaunchDefaultBrowserImpl_t)(const wxString& url, int flags); + +// Function the GUI library can call to provide a better implementation +WXDLLIMPEXP_BASE void wxSetLaunchDefaultBrowserImpl(wxLaunchDefaultBrowserImpl_t newImpl); + +#endif //ndef _WX_PRIVATE_BROWSERHACK28_H_ diff --git a/Source/3rd Party/wx/include/wx/private/eventloopsourcesmanager.h b/Source/3rd Party/wx/include/wx/private/eventloopsourcesmanager.h deleted file mode 100644 index 54ce5b0fc..000000000 --- a/Source/3rd Party/wx/include/wx/private/eventloopsourcesmanager.h +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/eventloopsourcesmanager.h -// Purpose: declares wxEventLoopSourcesManagerBase class -// Author: Rob Bresalier -// Created: 2013-06-19 -// Copyright: (c) 2013 Rob Bresalier -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_ -#define _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_ - -// For pulling in the value of wxUSE_EVENTLOOP_SOURCE -#include "wx/evtloop.h" - -class WXDLLIMPEXP_BASE wxEventLoopSourcesManagerBase -{ -public: -#if wxUSE_EVENTLOOP_SOURCE - virtual wxEventLoopSource* - AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags) = 0; -#endif -}; - -#endif // _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_ diff --git a/Source/3rd Party/wx/include/wx/private/fd.h b/Source/3rd Party/wx/include/wx/private/fd.h deleted file mode 100644 index 3f4a604c3..000000000 --- a/Source/3rd Party/wx/include/wx/private/fd.h +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fd.h -// Purpose: private stuff for working with file descriptors -// Author: Vadim Zeitlin -// Created: 2008-11-23 (moved from wx/unix/private.h) -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FD_H_ -#define _WX_PRIVATE_FD_H_ - -// standard Linux headers produce many warnings when used with icc so define -// our own replacements for FD_XXX macros -#if defined(__INTELC__) && defined(__LINUX__) - inline void wxFD_ZERO(fd_set *fds) - { - #pragma warning(push) - #pragma warning(disable:593) - FD_ZERO(fds); - #pragma warning(pop) - } - - inline void wxFD_SET(int fd, fd_set *fds) - { - #pragma warning(push, 1) - #pragma warning(disable:1469) - FD_SET(fd, fds); - #pragma warning(pop) - } - - inline bool wxFD_ISSET(int fd, fd_set *fds) - { - #pragma warning(push, 1) - #pragma warning(disable:1469) - return FD_ISSET(fd, fds); - #pragma warning(pop) - } - inline void wxFD_CLR(int fd, fd_set *fds) - { - #pragma warning(push, 1) - #pragma warning(disable:1469) - FD_CLR(fd, fds); - #pragma warning(pop) - } -#else // !__INTELC__ - #define wxFD_ZERO(fds) FD_ZERO(fds) - #define wxFD_SET(fd, fds) FD_SET(fd, fds) - #define wxFD_ISSET(fd, fds) FD_ISSET(fd, fds) - #define wxFD_CLR(fd, fds) FD_CLR(fd, fds) -#endif // __INTELC__/!__INTELC__ - -#endif // _WX_PRIVATE_FD_H_ diff --git a/Source/3rd Party/wx/include/wx/private/fdiodispatcher.h b/Source/3rd Party/wx/include/wx/private/fdiodispatcher.h deleted file mode 100644 index 0b85505cc..000000000 --- a/Source/3rd Party/wx/include/wx/private/fdiodispatcher.h +++ /dev/null @@ -1,118 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fdiodispatcher.h -// Purpose: classes for dispatching IO notifications for file descriptors -// Authors: Lukasz Michalski -// Created: December 2006 -// Copyright: (c) Lukasz Michalski -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FDIODISPATCHER_H_ -#define _WX_PRIVATE_FDIODISPATCHER_H_ - -#include "wx/hashmap.h" -#include "wx/private/fdiohandler.h" - -// those flags describes sets where descriptor should be added -enum wxFDIODispatcherEntryFlags -{ - wxFDIO_INPUT = 1, - wxFDIO_OUTPUT = 2, - wxFDIO_EXCEPTION = 4, - wxFDIO_ALL = wxFDIO_INPUT | wxFDIO_OUTPUT | wxFDIO_EXCEPTION -}; - -// base class for wxSelectDispatcher and wxEpollDispatcher -class WXDLLIMPEXP_BASE wxFDIODispatcher -{ -public: - enum { TIMEOUT_INFINITE = -1 }; - - // return the global dispatcher to be used for IO events, can be NULL only - // if wxSelectDispatcher wasn't compiled into the library at all as - // creating it never fails - // - // don't delete the returned pointer - static wxFDIODispatcher *Get(); - - // if we have any registered handlers, check for any pending events to them - // and dispatch them -- this is used from wxX11 and wxDFB event loops - // implementation - static void DispatchPending(); - - // register handler for the given descriptor with the dispatcher, return - // true on success or false on error - virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags) = 0; - - // modify descriptor flags or handler, return true on success - virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags) = 0; - - // unregister descriptor previously registered with RegisterFD() - virtual bool UnregisterFD(int fd) = 0; - - // check if any events are currently available without dispatching them - virtual bool HasPending() const = 0; - - // wait for an event for at most timeout milliseconds and process it; - // return the number of events processed (possibly 0 if timeout expired) or - // -1 if an error occurred - virtual int Dispatch(int timeout = TIMEOUT_INFINITE) = 0; - - virtual ~wxFDIODispatcher() { } -}; - -//entry for wxFDIOHandlerMap -struct wxFDIOHandlerEntry -{ - wxFDIOHandlerEntry() - { - } - - wxFDIOHandlerEntry(wxFDIOHandler *handler_, int flags_) - : handler(handler_), - flags(flags_) - { - } - - wxFDIOHandler *handler; - int flags; -}; - -// this hash is used to map file descriptors to their handlers -WX_DECLARE_HASH_MAP( - int, - wxFDIOHandlerEntry, - wxIntegerHash, - wxIntegerEqual, - wxFDIOHandlerMap -); - -// FDIODispatcher that holds map fd <-> FDIOHandler, this should be used if -// this map isn't maintained elsewhere already as it is usually needed anyhow -// -// notice that all functions for FD management have implementation -// in the base class and should be called from the derived classes -class WXDLLIMPEXP_BASE wxMappedFDIODispatcher : public wxFDIODispatcher -{ -public: - // find the handler for the given fd, return NULL if none - wxFDIOHandler *FindHandler(int fd) const; - - // register handler for the given descriptor with the dispatcher, return - // true on success or false on error - virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags); - - // modify descriptor flags or handler, return true on success - virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags); - - // unregister descriptor previously registered with RegisterFD() - virtual bool UnregisterFD(int fd); - - virtual ~wxMappedFDIODispatcher() { } - -protected: - // the fd -> handler map containing all the registered handlers - wxFDIOHandlerMap m_handlers; -}; - -#endif // _WX_PRIVATE_FDIODISPATCHER_H_ diff --git a/Source/3rd Party/wx/include/wx/private/fdioeventloopsourcehandler.h b/Source/3rd Party/wx/include/wx/private/fdioeventloopsourcehandler.h deleted file mode 100644 index f457a09e5..000000000 --- a/Source/3rd Party/wx/include/wx/private/fdioeventloopsourcehandler.h +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fdioeventloopsourcehandler.h -// Purpose: declares wxFDIOEventLoopSourceHandler class -// Author: Rob Bresalier, Vadim Zeitlin -// Created: 2013-06-13 (extracted from src/unix/evtloopunix.cpp) -// Copyright: (c) 2009 Vadim Zeitlin -// (c) 2013 Rob Bresalier -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FDIO_EVENT_LOOP_SOURCE_HANDLER_H -#define _WX_PRIVATE_FDIO_EVENT_LOOP_SOURCE_HANDLER_H - -#include "wx/evtloopsrc.h" - -// This class is a temporary bridge between event loop sources and -// FDIODispatcher. It is going to be removed soon, when all subject interfaces -// are modified -class wxFDIOEventLoopSourceHandler : public wxFDIOHandler -{ -public: - wxEXPLICIT wxFDIOEventLoopSourceHandler(wxEventLoopSourceHandler* handler) - : m_handler(handler) - { - } - - // Just forward to the real handler. - virtual void OnReadWaiting() { m_handler->OnReadWaiting(); } - virtual void OnWriteWaiting() { m_handler->OnWriteWaiting(); } - virtual void OnExceptionWaiting() { m_handler->OnExceptionWaiting(); } - -protected: - wxEventLoopSourceHandler* const m_handler; - - wxDECLARE_NO_COPY_CLASS(wxFDIOEventLoopSourceHandler); -}; - -#endif // _WX_PRIVATE_FDIO_EVENT_LOOP_SOURCE_HANDLER_H diff --git a/Source/3rd Party/wx/include/wx/private/fdiohandler.h b/Source/3rd Party/wx/include/wx/private/fdiohandler.h deleted file mode 100644 index 94e36490c..000000000 --- a/Source/3rd Party/wx/include/wx/private/fdiohandler.h +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fdiohandler.h -// Purpose: declares wxFDIOHandler class -// Author: Vadim Zeitlin -// Created: 2009-08-17 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FDIOHANDLER_H_ -#define _WX_PRIVATE_FDIOHANDLER_H_ - -// ---------------------------------------------------------------------------- -// wxFDIOHandler: interface used to process events on file descriptors -// ---------------------------------------------------------------------------- - -class wxFDIOHandler -{ -public: - wxFDIOHandler() { m_regmask = 0; } - - // called when descriptor is available for non-blocking read - virtual void OnReadWaiting() = 0; - - // called when descriptor is available for non-blocking write - virtual void OnWriteWaiting() = 0; - - // called when there is exception on descriptor - virtual void OnExceptionWaiting() = 0; - - // called to check if the handler is still valid, only used by - // wxSocketImplUnix currently - virtual bool IsOk() const { return true; } - - - // get/set the mask of events for which we're currently registered for: - // it's a combination of wxFDIO_{INPUT,OUTPUT,EXCEPTION} - int GetRegisteredEvents() const { return m_regmask; } - void SetRegisteredEvent(int flag) { m_regmask |= flag; } - void ClearRegisteredEvent(int flag) { m_regmask &= ~flag; } - - - // virtual dtor for the base class - virtual ~wxFDIOHandler() { } - -private: - int m_regmask; - - wxDECLARE_NO_COPY_CLASS(wxFDIOHandler); -}; - -#endif // _WX_PRIVATE_FDIOHANDLER_H_ - diff --git a/Source/3rd Party/wx/include/wx/private/fdiomanager.h b/Source/3rd Party/wx/include/wx/private/fdiomanager.h deleted file mode 100644 index 0721886f3..000000000 --- a/Source/3rd Party/wx/include/wx/private/fdiomanager.h +++ /dev/null @@ -1,42 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fdiomanager.h -// Purpose: declaration of wxFDIOManager -// Author: Vadim Zeitlin -// Created: 2009-08-17 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FDIOMANAGER_H_ -#define _WX_PRIVATE_FDIOMANAGER_H_ - -#include "wx/private/fdiohandler.h" - -// ---------------------------------------------------------------------------- -// wxFDIOManager: register or unregister wxFDIOHandlers -// ---------------------------------------------------------------------------- - -// currently only used in wxGTK and wxMotif, see wx/unix/apptrait.h - -class wxFDIOManager -{ -public: - // identifies either input or output direction - // - // NB: the values of this enum shouldn't change - enum Direction - { - INPUT, - OUTPUT - }; - - // start or stop monitoring the events on the given file descriptor - virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) = 0; - virtual void RemoveInput(wxFDIOHandler *handler, int fd, Direction d) = 0; - - // empty but virtual dtor for the base class - virtual ~wxFDIOManager() { } -}; - -#endif // _WX_PRIVATE_FDIOMANAGER_H_ - diff --git a/Source/3rd Party/wx/include/wx/private/fileback.h b/Source/3rd Party/wx/include/wx/private/fileback.h index 5929b4089..1ef8a4305 100644 --- a/Source/3rd Party/wx/include/wx/private/fileback.h +++ b/Source/3rd Party/wx/include/wx/private/fileback.h @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fileback.h +// Name: include/wx/private/fileback.h // Purpose: Back an input stream with memory or a file // Author: Mike Wetherell +// RCS-ID: $Id: fileback.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2006 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -74,7 +75,7 @@ private: wxBackingFile m_backer; wxFileOffset m_pos; - wxDECLARE_NO_COPY_CLASS(wxBackedInputStream); + DECLARE_NO_COPY_CLASS(wxBackedInputStream) }; #endif // wxUSE_FILESYSTEM diff --git a/Source/3rd Party/wx/include/wx/private/filename.h b/Source/3rd Party/wx/include/wx/private/filename.h index ba522732d..f25e33c8b 100644 --- a/Source/3rd Party/wx/include/wx/private/filename.h +++ b/Source/3rd Party/wx/include/wx/private/filename.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/filename.h +// Name: include/wx/private/filename.h // Purpose: Internal declarations for src/common/filename.cpp // Author: Mike Wetherell // Modified by: // Created: 2006-10-22 +// RCS-ID: $Id: filename.h 42277 2006-10-23 13:10:12Z MW $ // Copyright: (c) 2006 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/private/flagscheck.h b/Source/3rd Party/wx/include/wx/private/flagscheck.h deleted file mode 100644 index 3e3d9fbaa..000000000 --- a/Source/3rd Party/wx/include/wx/private/flagscheck.h +++ /dev/null @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/flagscheck.h -// Purpose: helpers for checking that (bit)flags don't overlap -// Author: Vaclav Slavik -// Created: 2008-02-21 -// Copyright: (c) 2008 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FLAGSCHECK_H_ -#define _WX_PRIVATE_FLAGSCHECK_H_ - -#include "wx/debug.h" - -// IBM xlC 8 can't parse the template syntax -#if !defined(__IBMCPP__) - -#include "wx/meta/if.h" - -namespace wxPrivate -{ - -// These templates are used to implement wxADD_FLAG macro below. -// -// The idea is that we want to trigger *compilation* error if the flags -// overlap, not just runtime assert failure. We can't implement the check -// using just a simple logical operation, we need checks equivalent to this -// code: -// -// mask = wxFLAG_1; -// assert( (mask & wxFLAG_2) == 0 ); // no overlap -// mask |= wxFLAG_3; -// assert( (mask & wxFLAG_3) == 0 ); // no overlap -// mask |= wxFLAG_3; -// ... -// -// This can be done at compilation time by using templates metaprogramming -// technique that makes the compiler carry on the computation. -// -// NB: If any of this doesn't compile with your compiler and would be too -// hard to make work, it's probably best to disable this code and replace -// the macros below with empty stubs, this isn't anything critical. - -template struct FlagsHaveConflictingValues -{ - // no value here - triggers compilation error -}; - -template struct FlagValue -{ - enum { value = val }; -}; - -// This template adds its template parameter integer 'add' to another integer -// 'all' and produces their OR-combination (all | add). The result is "stored" -// as constant SafelyAddToMask<>::value. Combination of many flags is achieved -// by chaining parameter lists: the 'add' parameter is value member of -// another (different) SafelyAddToMask<> instantiation. -template struct SafelyAddToMask -{ - // This typedefs ensures that no flags in the list conflict. If there's - // any overlap between the already constructed part of the mask ('all') - // and the value being added to it ('add'), the test that is wxIf<>'s - // first parameter will be non-zero and so Added value will be - // FlagsHaveConflictingValues. The next statement will try to use - // AddedValue::value, but there's no such thing in - // FlagsHaveConflictingValues<> and so compilation will fail. - typedef typename wxIf<(all & add) == 0, - FlagValue, - FlagsHaveConflictingValues >::value - AddedValue; - - enum { value = all | AddedValue::value }; -}; - -} // wxPrivate namespace - - - -// This macro is used to ensure that no two flags that can be combined in -// the same integer value have overlapping bits. This is sometimes not entirely -// trivial to ensure, for example in wxWindow styles or flags for wxSizerItem -// that span several enums, some of them used for multiple purposes. -// -// By constructing allowed flags mask using wxADD_FLAG macro and then using -// this mask to check flags passed as arguments, you can ensure that -// -// a) if any of the allowed flags overlap, you will get compilation error -// b) if invalid flag is used, there will be an assert at runtime -// -// Example usage: -// -// static const int SIZER_FLAGS_MASK = -// wxADD_FLAG(wxCENTRE, -// wxADD_FLAG(wxHORIZONTAL, -// wxADD_FLAG(wxVERTICAL, -// ... -// 0))...); -// -// And wherever flags are used: -// -// wxASSERT_VALID_FLAG( m_flag, SIZER_FLAGS_MASK ); - -#define wxADD_FLAG(f, others) \ - ::wxPrivate::SafelyAddToMask::value - -#else - #define wxADD_FLAG(f, others) (f | others) -#endif - -// Checks if flags value 'f' is within the mask of allowed values -#define wxASSERT_VALID_FLAGS(f, mask) \ - wxASSERT_MSG( (f & mask) == f, \ - "invalid flag: not within " #mask ) - -#endif // _WX_PRIVATE_FLAGSCHECK_H_ diff --git a/Source/3rd Party/wx/include/wx/private/fontmgr.h b/Source/3rd Party/wx/include/wx/private/fontmgr.h deleted file mode 100644 index c00270a6b..000000000 --- a/Source/3rd Party/wx/include/wx/private/fontmgr.h +++ /dev/null @@ -1,247 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fontmgr.h -// Purpose: font management for ports that don't have their own -// Author: Vaclav Slavik -// Created: 2006-11-18 -// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) -// (c) 2006 REA Elektronik GmbH -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_FONTMGR_H_ -#define _WX_PRIVATE_FONTMGR_H_ - -#include "wx/list.h" -#include "wx/fontutil.h" - -class wxFontsManager; -class wxFontInstance; -class wxFontInstanceList; -class wxFontFace; -class wxFontBundle; -class wxFontBundleHash; -class wxFontMgrFontRefData; - -WX_DECLARE_LIST(wxFontBundle, wxFontBundleList); - -/** - This class represents single font face with set parameters (point size, - antialiasing). - */ -class wxFontInstanceBase -{ -protected: - wxFontInstanceBase(float ptSize, bool aa) : m_ptSize(ptSize), m_aa(aa) {} - virtual ~wxFontInstanceBase() {} - -public: - float GetPointSize() const { return m_ptSize; } - bool IsAntiAliased() const { return m_aa; } - -protected: - float m_ptSize; - bool m_aa; -}; - - -/// This class represents loaded font face (bundle+weight+italics). -class wxFontFaceBase -{ -protected: - /// Ctor. Creates object with reference count = 0, Acquire() must be - /// called after the object is created. - wxFontFaceBase(); - virtual ~wxFontFaceBase(); - -public: - /// Increases reference count of the face - virtual void Acquire(); - - /** - Decreases reference count of the face. Call this when you no longer - use the object returned by wxFontBundle. Note that this doesn't destroy - the object, but only optionally shuts it down, so it's possible to - call Acquire() and Release() more than once. - */ - virtual void Release(); - - /** - Returns instance of the font at given size. - - @param ptSize point size of the font to create; note that this is - a float and not integer, it should be wxFont's point - size multipled by wxDC's scale factor - @param aa should the font be antialiased? - */ - virtual wxFontInstance *GetFontInstance(float ptSize, bool aa); - -protected: - /// Called to create a new instance of the font by GetFontInstance() if - /// it wasn't found it cache. - virtual wxFontInstance *CreateFontInstance(float ptSize, bool aa) = 0; - -protected: - unsigned m_refCnt; - wxFontInstanceList *m_instances; -}; - -/** - This class represents font bundle. Font bundle is set of faces that have - the same name, but differ in weight and italics. - */ -class wxFontBundleBase -{ -public: - wxFontBundleBase(); - virtual ~wxFontBundleBase(); - - /// Returns name of the bundle - virtual wxString GetName() const = 0; - - /// Returns true if the font is fixe-width - virtual bool IsFixed() const = 0; - - /// Type of faces in the bundle - enum FaceType - { - // NB: values of these constants are set so that it's possible to - // make OR-combinations of them and still get valid enum element - FaceType_Regular = 0, - FaceType_Italic = 1, - FaceType_Bold = 2, - FaceType_BoldItalic = FaceType_Italic | FaceType_Bold, - - FaceType_Max - }; - - /// Returns true if the given face is available - bool HasFace(FaceType type) const { return m_faces[type] != NULL; } - - /** - Returns font face object that can be used to render font of given type. - - Note that this method can only be called if HasFace(type) returns true. - - Acquire() was called on the returned object, you must call Release() - when you stop using it. - */ - wxFontFace *GetFace(FaceType type) const; - - /** - Returns font face object that can be used to render given font. - - Acquire() was called on the returned object, you must call Release() - when you stop using it. - */ - wxFontFace *GetFaceForFont(const wxFontMgrFontRefData& font) const; - -protected: - wxFontFace *m_faces[FaceType_Max]; -}; - - -/** - Base class for wxFontsManager class, which manages the list of all - available fonts and their loaded instances. - */ -class wxFontsManagerBase -{ -protected: - wxFontsManagerBase(); - virtual ~wxFontsManagerBase(); - -public: - /// Returns the font manager singleton, creating it if it doesn't exist - static wxFontsManager *Get(); - - /// Called by wxApp to shut down the manager - static void CleanUp(); - - /// Returns list of all available font bundles - const wxFontBundleList& GetBundles() const { return *m_list; } - - /** - Returns object representing font bundle with the given name. - - The returned object is owned by wxFontsManager, you must not delete it. - */ - wxFontBundle *GetBundle(const wxString& name) const; - - /** - Returns object representing font bundle that can be used to render - given font. - - The returned object is owned by wxFontsManager, you must not delete it. - */ - wxFontBundle *GetBundleForFont(const wxFontMgrFontRefData& font) const; - - /// This method must be called by derived - void AddBundle(wxFontBundle *bundle); - - /// Returns default facename for given wxFont family - virtual wxString GetDefaultFacename(wxFontFamily family) const = 0; - -private: - wxFontBundleHash *m_hash; - wxFontBundleList *m_list; - -protected: - static wxFontsManager *ms_instance; -}; - - - -#if defined(__WXDFB__) - #include "wx/dfb/private/fontmgr.h" -#endif - - - -/// wxFontMgrFontRefData implementation using wxFontsManager classes -class wxFontMgrFontRefData : public wxGDIRefData -{ -public: - wxFontMgrFontRefData(int size = wxDEFAULT, - wxFontFamily family = wxFONTFAMILY_DEFAULT, - wxFontStyle style = wxFONTSTYLE_NORMAL, - wxFontWeight weight = wxFONTWEIGHT_NORMAL, - bool underlined = false, - const wxString& faceName = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - wxFontMgrFontRefData(const wxFontMgrFontRefData& data); - ~wxFontMgrFontRefData(); - - wxFontBundle *GetFontBundle() const; - wxFontInstance *GetFontInstance(float scale, bool antialiased) const; - - bool IsFixedWidth() const { return GetFontBundle()->IsFixed(); } - - const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; } - - int GetPointSize() const { return m_info.pointSize; } - wxString GetFaceName() const { return m_info.faceName; } - wxFontFamily GetFamily() const { return m_info.family; } - wxFontStyle GetStyle() const { return m_info.style; } - wxFontWeight GetWeight() const { return m_info.weight; } - bool GetUnderlined() const { return m_info.underlined; } - wxFontEncoding GetEncoding() const { return m_info.encoding; } - - void SetPointSize(int pointSize); - void SetFamily(wxFontFamily family); - void SetStyle(wxFontStyle style); - void SetWeight(wxFontWeight weight); - void SetFaceName(const wxString& faceName); - void SetUnderlined(bool underlined); - void SetEncoding(wxFontEncoding encoding); - -private: - void EnsureValidFont(); - - wxNativeFontInfo m_info; - - wxFontFace *m_fontFace; - wxFontBundle *m_fontBundle; - bool m_fontValid; -}; - -#endif // _WX_PRIVATE_FONTMGR_H_ diff --git a/Source/3rd Party/wx/include/wx/private/fswatcher.h b/Source/3rd Party/wx/include/wx/private/fswatcher.h deleted file mode 100644 index e2bf55a89..000000000 --- a/Source/3rd Party/wx/include/wx/private/fswatcher.h +++ /dev/null @@ -1,115 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/fswatcher.h -// Purpose: File system watcher impl classes -// Author: Bartosz Bekier -// Created: 2009-05-26 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef WX_PRIVATE_FSWATCHER_H_ -#define WX_PRIVATE_FSWATCHER_H_ - -#include "wx/sharedptr.h" - -#ifdef wxHAS_INOTIFY - class wxFSWatchEntryUnix; - #define wxFSWatchEntry wxFSWatchEntryUnix - WX_DECLARE_STRING_HASH_MAP(wxSharedPtr,wxFSWatchEntries); - #include "wx/unix/private/fswatcher_inotify.h" -#elif defined(wxHAS_KQUEUE) - class wxFSWatchEntryKq; - #define wxFSWatchEntry wxFSWatchEntryKq - WX_DECLARE_STRING_HASH_MAP(wxSharedPtr,wxFSWatchEntries); - #include "wx/unix/private/fswatcher_kqueue.h" -#elif defined(__WINDOWS__) - class wxFSWatchEntryMSW; - #define wxFSWatchEntry wxFSWatchEntryMSW - WX_DECLARE_STRING_HASH_MAP(wxSharedPtr,wxFSWatchEntries); - #include "wx/msw/private/fswatcher.h" -#else - #define wxFSWatchEntry wxFSWatchEntryPolling -#endif - -class wxFSWatcherImpl -{ -public: - wxFSWatcherImpl(wxFileSystemWatcherBase* watcher) : - m_watcher(watcher) - { - } - - virtual ~wxFSWatcherImpl() - { - (void) RemoveAll(); - } - - virtual bool Init() = 0; - - virtual bool Add(const wxFSWatchInfo& winfo) - { - if ( m_watches.find(winfo.GetPath()) != m_watches.end() ) - { - wxLogTrace(wxTRACE_FSWATCHER, - "Path '%s' is already watched", winfo.GetPath()); - // This can happen if a dir is watched, then a parent tree added - return true; - } - - // construct watch entry - wxSharedPtr watch(new wxFSWatchEntry(winfo)); - - if (!DoAdd(watch)) - return false; - - // add watch to our map (always succeedes, checked above) - wxFSWatchEntries::value_type val(watch->GetPath(), watch); - return m_watches.insert(val).second; - } - - virtual bool Remove(const wxFSWatchInfo& winfo) - { - wxFSWatchEntries::iterator it = m_watches.find(winfo.GetPath()); - if ( it == m_watches.end() ) - { - wxLogTrace(wxTRACE_FSWATCHER, - "Path '%s' is not watched", winfo.GetPath()); - // This can happen if a dir is watched, then a parent tree added - return true; - } - wxSharedPtr watch = it->second; - m_watches.erase(it); - return DoRemove(watch); - } - - virtual bool RemoveAll() - { - bool ret = true; - for ( wxFSWatchEntries::iterator it = m_watches.begin(); - it != m_watches.end(); - ++it ) - { - if ( !DoRemove(it->second) ) - ret = false; - } - m_watches.clear(); - return ret; - } - - // Check whether any filespec matches the file's ext (if present) - bool MatchesFilespec(const wxFileName& fn, const wxString& filespec) const - { - return filespec.empty() || wxMatchWild(filespec, fn.GetFullName()); - } - -protected: - virtual bool DoAdd(wxSharedPtr watch) = 0; - - virtual bool DoRemove(wxSharedPtr watch) = 0; - - wxFSWatchEntries m_watches; - wxFileSystemWatcherBase* m_watcher; -}; - - -#endif /* WX_PRIVATE_FSWATCHER_H_ */ diff --git a/Source/3rd Party/wx/include/wx/private/graphics.h b/Source/3rd Party/wx/include/wx/private/graphics.h deleted file mode 100644 index a5f303dd4..000000000 --- a/Source/3rd Party/wx/include/wx/private/graphics.h +++ /dev/null @@ -1,168 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/graphics.h -// Purpose: private graphics context header -// Author: Stefan Csomor -// Modified by: -// Created: -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GRAPHICS_PRIVATE_H_ -#define _WX_GRAPHICS_PRIVATE_H_ - -#if wxUSE_GRAPHICS_CONTEXT - -#include "wx/graphics.h" - -class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData -{ - public : - wxGraphicsObjectRefData( wxGraphicsRenderer* renderer ); - wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data ); - wxGraphicsRenderer* GetRenderer() const ; - virtual wxGraphicsObjectRefData* Clone() const ; - - protected : - wxGraphicsRenderer* m_renderer; -} ; - -class WXDLLIMPEXP_CORE wxGraphicsBitmapData : public wxGraphicsObjectRefData -{ -public : - wxGraphicsBitmapData( wxGraphicsRenderer* renderer) : - wxGraphicsObjectRefData(renderer) {} - - virtual ~wxGraphicsBitmapData() {} - - // returns the native representation - virtual void * GetNativeBitmap() const = 0; -} ; - -class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData -{ -public : - wxGraphicsMatrixData( wxGraphicsRenderer* renderer) : - wxGraphicsObjectRefData(renderer) {} - - virtual ~wxGraphicsMatrixData() {} - - // concatenates the matrix - virtual void Concat( const wxGraphicsMatrixData *t ) = 0; - - // sets the matrix to the respective values - virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, - wxDouble tx=0.0, wxDouble ty=0.0) = 0; - - // gets the component valuess of the matrix - virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL, - wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const = 0; - - // makes this the inverse matrix - virtual void Invert() = 0; - - // returns true if the elements of the transformation matrix are equal ? - virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0; - - // return true if this is the identity matrix - virtual bool IsIdentity() const = 0; - - // - // transformation - // - - // add the translation to this matrix - virtual void Translate( wxDouble dx , wxDouble dy ) = 0; - - // add the scale to this matrix - virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0; - - // add the rotation to this matrix (radians) - virtual void Rotate( wxDouble angle ) = 0; - - // - // apply the transforms - // - - // applies that matrix to the point - virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0; - - // applies the matrix except for translations - virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0; - - // returns the native representation - virtual void * GetNativeMatrix() const = 0; -} ; - -class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData -{ -public : - wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {} - virtual ~wxGraphicsPathData() {} - - // - // These are the path primitives from which everything else can be constructed - // - - // begins a new subpath at (x,y) - virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0; - - // adds a straight line from the current point to (x,y) - virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0; - - // adds a cubic Bezier curve from the current point, using two control points and an end point - virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0; - - // adds another path - virtual void AddPath( const wxGraphicsPathData* path ) =0; - - // closes the current sub-path - virtual void CloseSubpath() = 0; - - // gets the last point of the current path, (0,0) if not yet set - virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0; - - // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle - virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0; - - // - // These are convenience functions which - if not available natively will be assembled - // using the primitives from above - // - - // adds a quadratic Bezier curve from the current point, using a control point and an end point - virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ); - - // appends a rectangle as a new closed subpath - virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); - - // appends an ellipsis as a new closed subpath fitting the passed rectangle - virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r ); - - // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1) - virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ; - - // appends an ellipse - virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); - - // appends a rounded rectangle - virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); - - // returns the native path - virtual void * GetNativePath() const = 0; - - // give the native path returned by GetNativePath() back (there might be some deallocations necessary) - virtual void UnGetNativePath(void *p) const= 0; - - // transforms each point of this path by the matrix - virtual void Transform( const wxGraphicsMatrixData* matrix ) =0; - - // gets the bounding box enclosing all points (possibly including control points) - virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0; - - virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const=0; -}; - -#endif - -#endif // _WX_GRAPHICS_PRIVATE_H_ diff --git a/Source/3rd Party/wx/include/wx/private/markupparser.h b/Source/3rd Party/wx/include/wx/private/markupparser.h deleted file mode 100644 index 855d92ad0..000000000 --- a/Source/3rd Party/wx/include/wx/private/markupparser.h +++ /dev/null @@ -1,176 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/markupparser.h -// Purpose: Classes for parsing simple markup. -// Author: Vadim Zeitlin -// Created: 2011-02-16 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_MARKUPPARSER_H_ -#define _WX_PRIVATE_MARKUPPARSER_H_ - -#include "wx/string.h" - -// ---------------------------------------------------------------------------- -// wxMarkupSpanAttributes: information about attributes for a markup span. -// ---------------------------------------------------------------------------- - -struct wxMarkupSpanAttributes -{ - enum OptionalBool - { - Unspecified = -1, - No, - Yes - }; - - wxMarkupSpanAttributes() - { - m_sizeKind = Size_Unspecified; - - m_isBold = - m_isItalic = - m_isUnderlined = - m_isStrikethrough = Unspecified; - } - - // If a string is empty, it means that the corresponding attribute is not - // set. - wxString m_fgCol, - m_bgCol, - m_fontFace; - - // There are many ways of specifying the size. First of all, the size may - // be relative in which case m_fontSize is either -1 or +1 meaning that - // it's one step smaller or larger than the current font. Second, it may be - // absolute in which case m_fontSize contains either the size in 1024th of - // a point (Pango convention) or its values are in [-3, 3] interval and map - // to [xx-small, xx-large] CSS-like font size specification. And finally it - // may be not specified at all, of course, in which case the value of - // m_fontSize doesn't matter and it shouldn't be used. - enum - { - Size_Unspecified, - Size_Relative, - Size_Symbolic, - Size_PointParts - } m_sizeKind; - int m_fontSize; - - // If the value is Unspecified, the attribute wasn't given. - OptionalBool m_isBold, - m_isItalic, - m_isUnderlined, - m_isStrikethrough; -}; - -// ---------------------------------------------------------------------------- -// wxMarkupParserOutput: gathers the results of parsing markup. -// ---------------------------------------------------------------------------- - -// A class deriving directly from this one needs to implement all the pure -// virtual functions below but as the handling of all simple tags (bold, italic -// &c) is often very similar, it is usually more convenient to inherit from -// wxMarkupParserFontOutput defined in wx/private/markupparserfont.h instead. -class wxMarkupParserOutput -{ -public: - wxMarkupParserOutput() { } - virtual ~wxMarkupParserOutput() { } - - // Virtual functions called by wxMarkupParser while parsing the markup. - - // Called for a run of normal text. - virtual void OnText(const wxString& text) = 0; - - // These functions correspond to the simple tags without parameters. - virtual void OnBoldStart() = 0; - virtual void OnBoldEnd() = 0; - - virtual void OnItalicStart() = 0; - virtual void OnItalicEnd() = 0; - - virtual void OnUnderlinedStart() = 0; - virtual void OnUnderlinedEnd() = 0; - - virtual void OnStrikethroughStart() = 0; - virtual void OnStrikethroughEnd() = 0; - - virtual void OnBigStart() = 0; - virtual void OnBigEnd() = 0; - - virtual void OnSmallStart() = 0; - virtual void OnSmallEnd() = 0; - - virtual void OnTeletypeStart() = 0; - virtual void OnTeletypeEnd() = 0; - - // The generic span start and end functions. - virtual void OnSpanStart(const wxMarkupSpanAttributes& attrs) = 0; - virtual void OnSpanEnd(const wxMarkupSpanAttributes& attrs) = 0; - -private: - wxDECLARE_NO_COPY_CLASS(wxMarkupParserOutput); -}; - -// ---------------------------------------------------------------------------- -// wxMarkupParser: parses the given markup text into wxMarkupParserOutput. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMarkupParser -{ -public: - // Initialize the parser with the object that will receive parsing results. - // This object lifetime must be greater than ours. - explicit wxMarkupParser(wxMarkupParserOutput& output) - : m_output(output) - { - } - - // Parse the entire string and call wxMarkupParserOutput methods. - // - // Return true if the string was successfully parsed or false if it failed - // (presumably because of syntax errors in the markup). - bool Parse(const wxString& text); - - // Quote a normal string, not meant to be interpreted as markup, so that it - // produces the same string when parsed as markup. This means, for example, - // replacing '<' in the input string with "<" to prevent them from being - // interpreted as tag opening characters. - static wxString Quote(const wxString& text); - - // Strip markup from a string, i.e. simply remove all tags and replace - // XML entities with their values (or with "&&" in case of "&" to - // prevent it from being interpreted as mnemonic marker). - static wxString Strip(const wxString& text); - -private: - // Simple struct combining the name of a tag and its attributes. - struct TagAndAttrs - { - TagAndAttrs(const wxString& name_) : name(name_) { } - - wxString name; - wxMarkupSpanAttributes attrs; - }; - - // Call the wxMarkupParserOutput method corresponding to the given tag. - // - // Return false if the tag doesn't match any of the known ones. - bool OutputTag(const TagAndAttrs& tagAndAttrs, bool start); - - // Parse the attributes and fill the provided TagAndAttrs object with the - // information about them. Does nothing if attrs string is empty. - // - // Returns empty string on success of a [fragment of an] error message if - // we failed to parse the attributes. - wxString ParseAttrs(wxString attrs, TagAndAttrs& tagAndAttrs); - - - wxMarkupParserOutput& m_output; - - wxDECLARE_NO_COPY_CLASS(wxMarkupParser); -}; - -#endif // _WX_PRIVATE_MARKUPPARSER_H_ diff --git a/Source/3rd Party/wx/include/wx/private/markupparserattr.h b/Source/3rd Party/wx/include/wx/private/markupparserattr.h deleted file mode 100644 index d433879da..000000000 --- a/Source/3rd Party/wx/include/wx/private/markupparserattr.h +++ /dev/null @@ -1,231 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/markupparserattr.h -// Purpose: Classes mapping markup attributes to wxFont/wxColour. -// Author: Vadim Zeitlin -// Created: 2011-02-18 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_MARKUPPARSERATTR_H_ -#define _WX_PRIVATE_MARKUPPARSERATTR_H_ - -#include "wx/private/markupparser.h" - -#include "wx/stack.h" - -#include "wx/colour.h" -#include "wx/font.h" - -// ---------------------------------------------------------------------------- -// wxMarkupParserAttrOutput: simplified wxFont-using version of the above. -// ---------------------------------------------------------------------------- - -// This class assumes that wxFont and wxColour are used to perform all the -// markup tags and implements the base class virtual functions in terms of -// OnAttr{Start,End}() only. -// -// Notice that you still must implement OnText() inherited from the base class -// when deriving from this one. -class wxMarkupParserAttrOutput : public wxMarkupParserOutput -{ -public: - // A simple container of font and colours. - struct Attr - { - Attr(const wxFont& font_, - const wxColour& foreground_ = wxColour(), - const wxColour& background_ = wxColour()) - : font(font_), foreground(foreground_), background(background_) - { - } - - wxFont font; - wxColour foreground, - background; - }; - - - // This object must be initialized with the font and colours to use - // initially, i.e. the ones used before any tags in the string. - wxMarkupParserAttrOutput(const wxFont& font, - const wxColour& foreground, - const wxColour& background) - { - m_attrs.push(Attr(font, foreground, background)); - } - - // Indicates the change of the font and/or colours used. Any of the - // fields of the argument may be invalid indicating that the corresponding - // attribute didn't actually change. - virtual void OnAttrStart(const Attr& attr) = 0; - - // Indicates the end of the region affected by the given attributes - // (the same ones that were passed to the matching OnAttrStart(), use - // GetAttr() to get the ones that will be used from now on). - virtual void OnAttrEnd(const Attr& attr) = 0; - - - // Implement all pure virtual methods inherited from the base class in - // terms of our own ones. - virtual void OnBoldStart() { DoChangeFont(&wxFont::Bold); } - virtual void OnBoldEnd() { DoEndAttr(); } - - virtual void OnItalicStart() { DoChangeFont(&wxFont::Italic); } - virtual void OnItalicEnd() { DoEndAttr(); } - - virtual void OnUnderlinedStart() { DoChangeFont(&wxFont::Underlined); } - virtual void OnUnderlinedEnd() { DoEndAttr(); } - - virtual void OnStrikethroughStart() { DoChangeFont(&wxFont::Strikethrough); } - virtual void OnStrikethroughEnd() { DoEndAttr(); } - - virtual void OnBigStart() { DoChangeFont(&wxFont::Larger); } - virtual void OnBigEnd() { DoEndAttr(); } - - virtual void OnSmallStart() { DoChangeFont(&wxFont::Smaller); } - virtual void OnSmallEnd() { DoEndAttr(); } - - virtual void OnTeletypeStart() - { - wxFont font(GetFont()); - font.SetFamily(wxFONTFAMILY_TELETYPE); - DoSetFont(font); - } - virtual void OnTeletypeEnd() { DoEndAttr(); } - - virtual void OnSpanStart(const wxMarkupSpanAttributes& spanAttr) - { - wxFont font(GetFont()); - if ( !spanAttr.m_fontFace.empty() ) - font.SetFaceName(spanAttr.m_fontFace); - - FontModifier()(spanAttr.m_isBold, - font, &wxFont::SetWeight, - wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD); - - FontModifier()(spanAttr.m_isItalic, - font, &wxFont::SetStyle, - wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC); - - FontModifier()(spanAttr.m_isUnderlined, - font, &wxFont::SetUnderlined, - false, true); - - // TODO: No support for strike-through yet. - - switch ( spanAttr.m_sizeKind ) - { - case wxMarkupSpanAttributes::Size_Unspecified: - break; - - case wxMarkupSpanAttributes::Size_Relative: - if ( spanAttr.m_fontSize > 0 ) - font.MakeLarger(); - else - font.MakeSmaller(); - break; - - case wxMarkupSpanAttributes::Size_Symbolic: - // The values of font size intentionally coincide with the - // values of wxFontSymbolicSize enum elements so simply cast - // one to the other. - font.SetSymbolicSize( - static_cast(spanAttr.m_fontSize) - ); - break; - - case wxMarkupSpanAttributes::Size_PointParts: - font.SetPointSize((spanAttr.m_fontSize + 1023)/1024); - break; - } - - - const Attr attr(font, spanAttr.m_fgCol, spanAttr.m_bgCol); - OnAttrStart(attr); - - m_attrs.push(attr); - } - - virtual void OnSpanEnd(const wxMarkupSpanAttributes& WXUNUSED(spanAttr)) - { - DoEndAttr(); - } - -protected: - // Get the current attributes, i.e. the ones that should be used for - // rendering (or measuring or whatever) the text at the current position in - // the string. - // - // It may be called from OnAttrStart() to get the old attributes used - // before and from OnAttrEnd() to get the new attributes that will be used - // from now on but is mostly meant to be used from overridden OnText() - // implementations. - const Attr& GetAttr() const { return m_attrs.top(); } - - // A shortcut for accessing the font of the current attribute. - const wxFont& GetFont() const { return GetAttr().font; } - -private: - // Change only the font to the given one. Call OnAttrStart() to notify - // about the change and update the attributes stack. - void DoSetFont(const wxFont& font) - { - const Attr attr(font); - - OnAttrStart(attr); - - m_attrs.push(attr); - } - - // Apply the given function to the font currently on top of the font stack, - // push the new font on the stack and call OnAttrStart() with it. - void DoChangeFont(wxFont (wxFont::*func)() const) - { - DoSetFont((GetFont().*func)()); - } - - void DoEndAttr() - { - const Attr attr(m_attrs.top()); - m_attrs.pop(); - - OnAttrEnd(attr); - } - - // A helper class used to apply the given function to a wxFont object - // depending on the value of an OptionalBool. - template - struct FontModifier - { - FontModifier() { } - - void operator()(wxMarkupSpanAttributes::OptionalBool isIt, - wxFont& font, - void (wxFont::*func)(T), - T noValue, - T yesValue) - { - switch ( isIt ) - { - case wxMarkupSpanAttributes::Unspecified: - break; - - case wxMarkupSpanAttributes::No: - (font.*func)(noValue); - break; - - case wxMarkupSpanAttributes::Yes: - (font.*func)(yesValue); - break; - } - } - }; - - - wxStack m_attrs; - - wxDECLARE_NO_COPY_CLASS(wxMarkupParserAttrOutput); -}; - -#endif // _WX_PRIVATE_MARKUPPARSERATTR_H_ diff --git a/Source/3rd Party/wx/include/wx/private/overlay.h b/Source/3rd Party/wx/include/wx/private/overlay.h index 066a7c72a..9203503ce 100644 --- a/Source/3rd Party/wx/include/wx/private/overlay.h +++ b/Source/3rd Party/wx/include/wx/private/overlay.h @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 2006-10-20 +// RCS-ID: $Id: overlay.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,7 @@ #ifdef wxHAS_NATIVE_OVERLAY #if defined(__WXMAC__) - #include "wx/osx/carbon/private/overlay.h" + #include "wx/mac/carbon/private/overlay.h" #elif defined(__WXDFB__) #include "wx/dfb/private/overlay.h" #else @@ -44,13 +45,13 @@ public: // returns true if it has been setup bool IsOk(); - void Init(wxDC* dc, int x , int y , int width , int height); + void Init(wxWindowDC* dc, int x , int y , int width , int height); - void BeginDrawing(wxDC* dc); + void BeginDrawing(wxWindowDC* dc); - void EndDrawing(wxDC* dc); + void EndDrawing(wxWindowDC* dc); - void Clear(wxDC* dc); + void Clear(wxWindowDC* dc); private: wxBitmap m_bmpSaved ; @@ -58,8 +59,13 @@ private: int m_y ; int m_width ; int m_height ; +// this is to enable wxMOTIF and UNIV to compile.... +// currently (10 oct 06) we don't use m_window +// ce - how do we fix this +#if defined(__WXGTK__) || defined(__WXMSW__) wxWindow* m_window ; -}; +#endif +} ; #endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY diff --git a/Source/3rd Party/wx/include/wx/private/pipestream.h b/Source/3rd Party/wx/include/wx/private/pipestream.h deleted file mode 100644 index 7fdcb7176..000000000 --- a/Source/3rd Party/wx/include/wx/private/pipestream.h +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/pipestream.h -// Purpose: Declares wxPipeInputStream and wxPipeOutputStream. -// Author: Vadim Zeitlin -// Modified by: Rob Bresalier -// Created: 2013-04-27 -// Copyright: (c) 2003 Vadim Zeitlin -// (c) 2013 Rob Bresalier -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_PIPESTREAM_H_ -#define _WX_PRIVATE_PIPESTREAM_H_ - -#include "wx/platform.h" - -// wxPipeInputStream is a platform-dependent input stream class (i.e. deriving, -// possible indirectly, from wxInputStream) for reading from a pipe, i.e. a -// pipe FD under Unix or a pipe HANDLE under MSW. It provides a single extra -// IsOpened() method. -// -// wxPipeOutputStream is similar but has no additional methods at all. -#if defined(__UNIX__) && !defined(__WINDOWS__) - #include "wx/unix/private/pipestream.h" -#elif defined(__WINDOWS__) && !defined(__WXWINCE__) - #include "wx/msw/private/pipestream.h" -#endif - -#endif // _WX_PRIVATE_PIPESTREAM_H_ diff --git a/Source/3rd Party/wx/include/wx/private/preferences.h b/Source/3rd Party/wx/include/wx/private/preferences.h deleted file mode 100644 index 8b926450b..000000000 --- a/Source/3rd Party/wx/include/wx/private/preferences.h +++ /dev/null @@ -1,40 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/preferences.h -// Purpose: wxPreferencesEditorImpl declaration. -// Author: Vaclav Slavik -// Created: 2013-02-19 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_PREFERENCES_H_ -#define _WX_PRIVATE_PREFERENCES_H_ - -#include "wx/preferences.h" - -#if wxUSE_TOOLBAR && defined(__WXOSX_COCOA__) && wxOSX_USE_NATIVE_TOOLBAR - #define wxHAS_PREF_EDITOR_NATIVE -#endif - -// ---------------------------------------------------------------------------- -// wxPreferencesEditorImpl: defines wxPreferencesEditor implementation. -// ---------------------------------------------------------------------------- - -class wxPreferencesEditorImpl -{ -public: - // This is implemented in a platform-specific way. - static wxPreferencesEditorImpl* Create(const wxString& title); - - // These methods simply mirror the public wxPreferencesEditor ones. - virtual void AddPage(wxPreferencesPage* page) = 0; - virtual void Show(wxWindow* parent) = 0; - virtual void Dismiss() = 0; - - virtual ~wxPreferencesEditorImpl() {} - -protected: - wxPreferencesEditorImpl() {} -}; - -#endif // _WX_PRIVATE_PREFERENCES_H_ diff --git a/Source/3rd Party/wx/include/wx/private/richtooltip.h b/Source/3rd Party/wx/include/wx/private/richtooltip.h deleted file mode 100644 index 89ce193fa..000000000 --- a/Source/3rd Party/wx/include/wx/private/richtooltip.h +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/richtooltip.h -// Purpose: wxRichToolTipImpl declaration. -// Author: Vadim Zeitlin -// Created: 2011-10-18 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_RICHTOOLTIP_H_ -#define _WX_PRIVATE_RICHTOOLTIP_H_ - -#include "wx/richtooltip.h" - -// ---------------------------------------------------------------------------- -// wxRichToolTipImpl: defines wxRichToolTip implementation. -// ---------------------------------------------------------------------------- - -class wxRichToolTipImpl -{ -public: - // This is implemented in a platform-specific way. - static wxRichToolTipImpl* Create(const wxString& title, - const wxString& message); - - // These methods simply mirror the public wxRichToolTip ones. - virtual void SetBackgroundColour(const wxColour& col, - const wxColour& colEnd) = 0; - virtual void SetCustomIcon(const wxIcon& icon) = 0; - virtual void SetStandardIcon(int icon) = 0; - virtual void SetTimeout(unsigned milliseconds, - unsigned millisecondsShowdelay = 0) = 0; - virtual void SetTipKind(wxTipKind tipKind) = 0; - virtual void SetTitleFont(const wxFont& font) = 0; - - virtual void ShowFor(wxWindow* win, const wxRect* rect = NULL) = 0; - - virtual ~wxRichToolTipImpl() { } - -protected: - wxRichToolTipImpl() { } -}; - -#endif // _WX_PRIVATE_RICHTOOLTIP_H_ diff --git a/Source/3rd Party/wx/include/wx/private/sckaddr.h b/Source/3rd Party/wx/include/wx/private/sckaddr.h deleted file mode 100644 index ba2063ed9..000000000 --- a/Source/3rd Party/wx/include/wx/private/sckaddr.h +++ /dev/null @@ -1,323 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/sckaddr.h -// Purpose: wxSockAddressImpl -// Author: Vadim Zeitlin -// Created: 2008-12-28 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_SOCKADDR_H_ -#define _WX_PRIVATE_SOCKADDR_H_ - -#ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" - - #if wxUSE_IPV6 - #include - #endif -#elif defined(__VMS__) - #include - - struct sockaddr_un - { - u_char sun_len; /* sockaddr len including null */ - u_char sun_family; /* AF_UNIX */ - char sun_path[108]; /* path name (gag) */ - }; - #include -#else // generic Unix - #include - #include - #include - #include -#endif // platform - -#include // for calloc() - -// this is a wrapper for sockaddr_storage if it's available or just sockaddr -// otherwise -union wxSockAddressStorage -{ -#if wxUSE_IPV6 - sockaddr_storage addr_storage; -#endif - sockaddr addr; -}; - -// ---------------------------------------------------------------------------- -// helpers for wxSockAddressImpl -// ---------------------------------------------------------------------------- - -// helper class mapping sockaddr_xxx types to corresponding AF_XXX values -// -// FIXME-VC6: we could leave the template undefined if not for VC6 which -// absolutely does need to have a generic version defining the -// template "interface" to compile the code below -template struct AddressFamily { enum { value = AF_UNSPEC }; }; - -template <> struct AddressFamily { enum { value = AF_INET }; }; - -#if wxUSE_IPV6 -template <> struct AddressFamily { enum { value = AF_INET6 }; }; -#endif // wxUSE_IPV6 - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS -template <> struct AddressFamily { enum { value = AF_UNIX }; }; -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - -// ---------------------------------------------------------------------------- -// wxSockAddressImpl -// ---------------------------------------------------------------------------- - -// Represents a socket endpoint, e.g. an (address, port) pair for PF_INET -// sockets. It can be initialized from an existing sockaddr struct and also -// provides access to sockaddr stored internally so that it can be easily used -// with e.g. connect(2). -// -// This class also performs (synchronous, hence potentially long) name lookups -// if necessary, i.e. if the host name strings don't contain addresses in -// numerical form (quad dotted for IPv4 or standard hexadecimal for IPv6). -// Notice that internally the potentially Unicode host names are encoded as -// UTF-8 before being passed to the lookup function but the host names should -// really be ASCII anyhow. -class wxSockAddressImpl -{ -public: - // as this is passed to socket() it should be a PF_XXX and not AF_XXX (even - // though they're the same in practice) - enum Family - { - FAMILY_INET = PF_INET, -#if wxUSE_IPV6 - FAMILY_INET6 = PF_INET6, -#endif -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - FAMILY_UNIX = PF_UNIX, -#endif - FAMILY_UNSPEC = PF_UNSPEC - }; - - // default ctor creates uninitialized object, use one of CreateXXX() below - wxSockAddressImpl() - { - InitUnspec(); - } - - // ctor from an existing sockaddr - wxSockAddressImpl(const sockaddr& addr, int len) - { - switch ( addr.sa_family ) - { - case PF_INET: -#if wxUSE_IPV6 - case PF_INET6: -#endif -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - case PF_UNIX: -#endif - m_family = static_cast(addr.sa_family); - break; - - default: - wxFAIL_MSG( "unsupported socket address family" ); - InitUnspec(); - return; - } - - InitFromSockaddr(addr, len); - } - - // copy ctor and assignment operators - wxSockAddressImpl(const wxSockAddressImpl& other) - { - InitFromOther(other); - } - - wxSockAddressImpl& operator=(const wxSockAddressImpl& other) - { - if (this != &other) - { - free(m_addr); - InitFromOther(other); - } - return *this; - } - - // dtor frees the memory used by m_addr - ~wxSockAddressImpl() - { - free(m_addr); - } - - - // reset the address to the initial uninitialized state - void Clear() - { - free(m_addr); - - InitUnspec(); - } - - // initialize the address to be of specific address family, it must be - // currently uninitialized (you may call Clear() to achieve this) - void CreateINET(); - void CreateINET6(); -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - void CreateUnix(); -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - void Create(Family family) - { - switch ( family ) - { - case FAMILY_INET: - CreateINET(); - break; - -#if wxUSE_IPV6 - case FAMILY_INET6: - CreateINET6(); - break; -#endif // wxUSE_IPV6 - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - case FAMILY_UNIX: - CreateUnix(); - break; -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - - default: - wxFAIL_MSG( "unsupported socket address family" ); - } - } - - // simple accessors - Family GetFamily() const { return m_family; } - bool Is(Family family) const { return m_family == family; } - bool IsOk() const { return m_family != FAMILY_UNSPEC; } - const sockaddr *GetAddr() const { return m_addr; } - sockaddr *GetWritableAddr() { return m_addr; } - int GetLen() const { return m_len; } - - // accessors for INET or INET6 address families -#if wxUSE_IPV6 - #define CALL_IPV4_OR_6(func, args) \ - Is(FAMILY_INET6) ? func##6(args) : func##4(args) - #define CALL_IPV4_OR_6_VOID(func) \ - Is(FAMILY_INET6) ? func##6() : func##4() -#else - #define CALL_IPV4_OR_6(func, args) func##4(args) - #define CALL_IPV4_OR_6_VOID(func) func##4() -#endif // IPv6 support on/off - - wxString GetHostName() const; - bool SetHostName(const wxString& name) - { - return CALL_IPV4_OR_6(SetHostName, (name)); - } - - wxUint16 GetPort() const { return CALL_IPV4_OR_6_VOID(GetPort); } - bool SetPort(wxUint16 port) { return CALL_IPV4_OR_6(SetPort, (port)); } - bool SetPortName(const wxString& name, const char *protocol); - - bool SetToAnyAddress() { return CALL_IPV4_OR_6_VOID(SetToAnyAddress); } - -#undef CALL_IPV4_OR_6 - - // accessors for INET addresses only - bool GetHostAddress(wxUint32 *address) const; - bool SetHostAddress(wxUint32 address); - - bool SetToBroadcastAddress() { return SetHostAddress(INADDR_BROADCAST); } - - // accessors for INET6 addresses only -#if wxUSE_IPV6 - bool GetHostAddress(in6_addr *address) const; - bool SetHostAddress(const in6_addr& address); -#endif // wxUSE_IPV6 - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - // methods valid for Unix address family addresses only - bool SetPath(const wxString& path); - wxString GetPath() const; -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - -private: - void DoAlloc(int len) - { - m_addr = static_cast(calloc(1, len)); - m_len = len; - } - - // FIXME-VC6: VC6 doesn't grok Foo() call syntax so we need the extra - // dummy parameter of type T, use the macros in sckaddr.cpp to - // hide it - template - T *Alloc(T *) - { - DoAlloc(sizeof(T)); - - return reinterpret_cast(m_addr); - } - - template - T *Get(T *) const - { - wxCHECK_MSG( static_cast(m_family) == AddressFamily::value, - NULL, - "socket address family mismatch" ); - - return reinterpret_cast(m_addr); - } - - void InitUnspec() - { - m_family = FAMILY_UNSPEC; - m_addr = NULL; - m_len = 0; - } - - void InitFromSockaddr(const sockaddr& addr, int len) - { - DoAlloc(len); - memcpy(m_addr, &addr, len); - } - - void InitFromOther(const wxSockAddressImpl& other) - { - m_family = other.m_family; - - if ( other.m_addr ) - { - InitFromSockaddr(*other.m_addr, other.m_len); - } - else // no address to copy - { - m_addr = NULL; - m_len = 0; - } - } - - // IPv4/6 implementations of public functions - bool SetHostName4(const wxString& name); - - bool SetPort4(wxUint16 port); - wxUint16 GetPort4() const; - - bool SetToAnyAddress4() { return SetHostAddress(INADDR_ANY); } - -#if wxUSE_IPV6 - bool SetHostName6(const wxString& name); - - bool SetPort6(wxUint16 port); - wxUint16 GetPort6() const; - - bool SetToAnyAddress6(); -#endif // wxUSE_IPV6 - - Family m_family; - sockaddr *m_addr; - int m_len; -}; - -#endif // _WX_PRIVATE_SOCKADDR_H_ diff --git a/Source/3rd Party/wx/include/wx/private/selectdispatcher.h b/Source/3rd Party/wx/include/wx/private/selectdispatcher.h deleted file mode 100644 index 644377739..000000000 --- a/Source/3rd Party/wx/include/wx/private/selectdispatcher.h +++ /dev/null @@ -1,126 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/selectdispatcher.h -// Purpose: wxSelectDispatcher class -// Authors: Lukasz Michalski and Vadim Zeitlin -// Created: December 2006 -// Copyright: (c) Lukasz Michalski -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_SELECTDISPATCHER_H_ -#define _WX_PRIVATE_SELECTDISPATCHER_H_ - -#include "wx/defs.h" - -#if wxUSE_SELECT_DISPATCHER - -#if defined(HAVE_SYS_SELECT_H) || defined(__WATCOMC__) - #include - #include -#endif - -#ifdef __WATCOMC__ - #include - #include - #include -#else - #include -#endif - -#include "wx/private/fdiodispatcher.h" - -// helper class storing all the select() fd sets -class WXDLLIMPEXP_BASE wxSelectSets -{ -public: - // ctor zeroes out all fd_sets - wxSelectSets(); - - // default copy ctor, assignment operator and dtor are ok - - - // return true if fd appears in any of the sets - bool HasFD(int fd) const; - - // add or remove FD to our sets depending on whether flags contains - // wxFDIO_INPUT/OUTPUT/EXCEPTION bits - bool SetFD(int fd, int flags); - - // same as SetFD() except it unsets the bits set in the flags for the given - // fd - bool ClearFD(int fd) - { - return SetFD(fd, 0); - } - - - // call select() with our sets: the other parameters are the same as for - // select() itself - int Select(int nfds, struct timeval *tv); - - // call the handler methods corresponding to the sets having this fd if it - // is present in any set and return true if it is - bool Handle(int fd, wxFDIOHandler& handler) const; - -private: - typedef void (wxFDIOHandler::*Callback)(); - - // the FD sets indices - enum - { - Read, - Write, - Except, - Max - }; - - // the sets used with select() - fd_set m_fds[Max]; - - // the wxFDIO_XXX flags, functions and names (used for debug messages only) - // corresponding to the FD sets above - static int ms_flags[Max]; - static const char *ms_names[Max]; - static Callback ms_handlers[Max]; -}; - -class WXDLLIMPEXP_BASE wxSelectDispatcher : public wxMappedFDIODispatcher -{ -public: - // default ctor - wxSelectDispatcher() { m_maxFD = -1; } - - // implement pure virtual methods of the base class - virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL); - virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL); - virtual bool UnregisterFD(int fd); - virtual bool HasPending() const; - virtual int Dispatch(int timeout = TIMEOUT_INFINITE); - -private: - // common part of RegisterFD() and ModifyFD() - bool DoUpdateFDAndHandler(int fd, wxFDIOHandler *handler, int flags); - - // call the handlers for the fds present in the given sets, return the - // number of handlers we called - int ProcessSets(const wxSelectSets& sets); - - // helper of ProcessSets(): call the handler if its fd is in the set - void DoProcessFD(int fd, const fd_set& fds, wxFDIOHandler *handler, - const char *name); - - // common part of HasPending() and Dispatch(): calls select() with the - // specified timeout - int DoSelect(wxSelectSets& sets, int timeout) const; - - - // the select sets containing all the registered fds - wxSelectSets m_sets; - - // the highest registered fd value or -1 if none - int m_maxFD; -}; - -#endif // wxUSE_SELECT_DISPATCHER - -#endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_ diff --git a/Source/3rd Party/wx/include/wx/private/socket.h b/Source/3rd Party/wx/include/wx/private/socket.h deleted file mode 100644 index 973b764f7..000000000 --- a/Source/3rd Party/wx/include/wx/private/socket.h +++ /dev/null @@ -1,373 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/socket.h -// Purpose: wxSocketImpl and related declarations -// Authors: Guilhem Lavaux, Vadim Zeitlin -// Created: April 1997 -// Copyright: (c) 1997 Guilhem Lavaux -// (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -/* - Brief overview of different socket classes: - - - wxSocketBase is the public class representing a socket ("Base" here - refers to the fact that wxSocketClient and wxSocketServer are derived - from it and predates the convention of using "Base" for common base - classes for platform-specific classes in wxWidgets) with implementation - common to all platforms and forwarding methods whose implementation - differs between platforms to wxSocketImpl which it contains. - - - wxSocketImpl is actually just an abstract base class having only code - common to all platforms, the concrete implementation classes derive from - it and are created by wxSocketImpl::Create(). - - - Some socket operations have different implementations in console-mode and - GUI applications. wxSocketManager class exists to abstract this in such - way that console applications (using wxBase) don't depend on wxNet. An - object of this class is made available via wxApp and GUI applications set - up a different kind of global socket manager from console ones. - - TODO: it looks like wxSocketManager could be eliminated by providing - methods for registering/unregistering sockets directly in - wxEventLoop. - */ - -#ifndef _WX_PRIVATE_SOCKET_H_ -#define _WX_PRIVATE_SOCKET_H_ - -#include "wx/defs.h" - -#if wxUSE_SOCKETS - -#include "wx/socket.h" -#include "wx/private/sckaddr.h" - -#include - -/* - Including sys/types.h under Cygwin results in the warnings about "fd_set - having been defined in sys/types.h" when winsock.h is included later and - doesn't seem to be necessary anyhow. It's not needed under Mac neither. - */ -#if !defined(__WXMAC__) && !defined(__WXMSW__) && !defined(__WXWINCE__) -#include -#endif - -#ifdef __WXWINCE__ -#include -#endif - -// include the header defining timeval: under Windows this struct is used only -// with sockets so we need to include winsock.h which we do via windows.h -#ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" -#else - #include // for timeval -#endif - -// these definitions are for MSW when we don't use configure, otherwise these -// symbols are defined by configure -#ifndef WX_SOCKLEN_T - #define WX_SOCKLEN_T int -#endif - -#ifndef SOCKOPTLEN_T - #define SOCKOPTLEN_T int -#endif - -// define some symbols which winsock.h defines but traditional BSD headers -// don't -#ifndef INVALID_SOCKET - #define INVALID_SOCKET (-1) -#endif - -#ifndef SOCKET_ERROR - #define SOCKET_ERROR (-1) -#endif - -typedef int wxSocketEventFlags; - -class wxSocketImpl; - -/* - Class providing hooks abstracting the differences between console and GUI - applications for socket code. - - We also have different implementations of this class for different platforms - allowing us to keep more things in the common code but the main reason for - its existence is that we want the same socket code work differently - depending on whether it's used from a console or a GUI program. This is - achieved by implementing the virtual methods of this class differently in - the objects returned by wxConsoleAppTraits::GetSocketManager() and the same - method in wxGUIAppTraits. - */ -class wxSocketManager -{ -public: - // set the manager to use, we don't take ownership of it - // - // this should be called before creating the first wxSocket object, - // otherwise the manager returned by wxAppTraits::GetSocketManager() will - // be used - static void Set(wxSocketManager *manager); - - // return the manager to use - // - // this initializes the manager at first use - static wxSocketManager *Get() - { - if ( !ms_manager ) - Init(); - - return ms_manager; - } - - // called before the first wxSocket is created and should do the - // initializations needed in order to use the network - // - // return true if initialized successfully; if this returns false sockets - // can't be used at all - virtual bool OnInit() = 0; - - // undo the initializations of OnInit() - virtual void OnExit() = 0; - - - // create the socket implementation object matching this manager - virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket) = 0; - - // these functions enable or disable monitoring of the given socket for the - // specified events inside the currently running event loop (but notice - // that both BSD and Winsock implementations actually use socket->m_server - // value to determine what exactly should be monitored so it needs to be - // set before calling these functions) - // - // the default event value is used just for the convenience of wxMSW - // implementation which doesn't use this parameter anyhow, it doesn't make - // sense to pass wxSOCKET_LOST for the Unix implementation which does use - // this parameter - virtual void Install_Callback(wxSocketImpl *socket, - wxSocketNotify event = wxSOCKET_LOST) = 0; - virtual void Uninstall_Callback(wxSocketImpl *socket, - wxSocketNotify event = wxSOCKET_LOST) = 0; - - virtual ~wxSocketManager() { } - -private: - // get the manager to use if we don't have it yet - static void Init(); - - static wxSocketManager *ms_manager; -}; - -/* - Base class for all socket implementations providing functionality common to - BSD and Winsock sockets. - - Objects of this class are not created directly but only via the factory - function wxSocketManager::CreateSocket(). - */ -class wxSocketImpl -{ -public: - virtual ~wxSocketImpl(); - - // set various socket properties: all of those can only be called before - // creating the socket - void SetTimeout(unsigned long millisec); - void SetReusable() { m_reusable = true; } - void SetBroadcast() { m_broadcast = true; } - void DontDoBind() { m_dobind = false; } - void SetInitialSocketBuffers(int recv, int send) - { - m_initialRecvBufferSize = recv; - m_initialSendBufferSize = send; - } - - wxSocketError SetLocal(const wxSockAddressImpl& address); - wxSocketError SetPeer(const wxSockAddressImpl& address); - - // accessors - // --------- - - bool IsServer() const { return m_server; } - - const wxSockAddressImpl& GetLocal(); // non const as may update m_local - const wxSockAddressImpl& GetPeer() const { return m_peer; } - - wxSocketError GetError() const { return m_error; } - bool IsOk() const { return m_error == wxSOCKET_NOERROR; } - - // get the error code corresponding to the last operation - virtual wxSocketError GetLastError() const = 0; - - - // creating/closing the socket - // -------------------------- - - // notice that SetLocal() must be called before creating the socket using - // any of the functions below - // - // all of Create() functions return wxSOCKET_NOERROR if the operation - // completed successfully or one of: - // wxSOCKET_INVSOCK - the socket is in use. - // wxSOCKET_INVADDR - the local (server) or peer (client) address has not - // been set. - // wxSOCKET_IOERR - any other error. - - // create a socket listening on the local address specified by SetLocal() - // (notice that DontDoBind() is ignored by this function) - wxSocketError CreateServer(); - - // create a socket connected to the peer address specified by SetPeer() - // (notice that DontDoBind() is ignored by this function) - // - // this function may return wxSOCKET_WOULDBLOCK in addition to the return - // values listed above if wait is false - wxSocketError CreateClient(bool wait); - - // create (and bind unless DontDoBind() had been called) an UDP socket - // associated with the given local address - wxSocketError CreateUDP(); - - // may be called whether the socket was created or not, calls DoClose() if - // it was indeed created - void Close(); - - // shuts down the writing end of the socket and closes it, this is a more - // graceful way to close - // - // does nothing if the socket wasn't created - void Shutdown(); - - - // IO operations - // ------------- - - // basic IO, work for both TCP and UDP sockets - // - // return the number of bytes read/written (possibly 0) or -1 on error - int Read(void *buffer, int size); - int Write(const void *buffer, int size); - - // basically a wrapper for select(): returns the condition of the socket, - // blocking for not longer than timeout if it is specified (otherwise just - // poll without blocking at all) - // - // flags defines what kind of conditions we're interested in, the return - // value is composed of a (possibly empty) subset of the bits set in flags - wxSocketEventFlags Select(wxSocketEventFlags flags, - const timeval *timeout = NULL); - - // convenient wrapper calling Select() with our default timeout - wxSocketEventFlags SelectWithTimeout(wxSocketEventFlags flags) - { - return Select(flags, &m_timeout); - } - - // just a wrapper for accept(): it is called to create a new wxSocketImpl - // corresponding to a new server connection represented by the given - // wxSocketBase, returns NULL on error (including immediately if there are - // no pending connections as our sockets are non-blocking) - wxSocketImpl *Accept(wxSocketBase& wxsocket); - - - // notifications - // ------------- - - // notify m_wxsocket about the given socket event by calling its (inaptly - // named) OnRequest() method - void NotifyOnStateChange(wxSocketNotify event); - - // called after reading/writing the data from/to the socket and should - // enable back the wxSOCKET_INPUT/OUTPUT_FLAG notifications if they were - // turned off when this data was first detected - virtual void ReenableEvents(wxSocketEventFlags flags) = 0; - - // TODO: make these fields protected and provide accessors for those of - // them that wxSocketBase really needs -//protected: - wxSOCKET_T m_fd; - - int m_initialRecvBufferSize; - int m_initialSendBufferSize; - - wxSockAddressImpl m_local, - m_peer; - wxSocketError m_error; - - bool m_stream; - bool m_establishing; - bool m_reusable; - bool m_broadcast; - bool m_dobind; - - struct timeval m_timeout; - -protected: - wxSocketImpl(wxSocketBase& wxsocket); - - // true if we're a listening stream socket - bool m_server; - -private: - // called by Close() if we have a valid m_fd - virtual void DoClose() = 0; - - // put this socket into non-blocking mode and enable monitoring this socket - // as part of the event loop - virtual void UnblockAndRegisterWithEventLoop() = 0; - - // check that the socket wasn't created yet and that the given address - // (either m_local or m_peer depending on the socket kind) is valid and - // set m_error and return false if this is not the case - bool PreCreateCheck(const wxSockAddressImpl& addr); - - // set the given socket option: this just wraps setsockopt(SOL_SOCKET) - int SetSocketOption(int optname, int optval) - { - // although modern Unix systems use "const void *" for the 4th - // parameter here, old systems and Winsock still use "const char *" - return setsockopt(m_fd, SOL_SOCKET, optname, - reinterpret_cast(&optval), - sizeof(optval)); - } - - // set the given socket option to true value: this is an even simpler - // wrapper for setsockopt(SOL_SOCKET) for boolean options - int EnableSocketOption(int optname) - { - return SetSocketOption(optname, 1); - } - - // apply the options to the (just created) socket and register it with the - // event loop by calling UnblockAndRegisterWithEventLoop() - void PostCreation(); - - // update local address after binding/connecting - wxSocketError UpdateLocalAddress(); - - // functions used to implement Read/Write() - int RecvStream(void *buffer, int size); - int RecvDgram(void *buffer, int size); - int SendStream(const void *buffer, int size); - int SendDgram(const void *buffer, int size); - - - // set in ctor and never changed except that it's reset to NULL when the - // socket is shut down - wxSocketBase *m_wxsocket; - - wxDECLARE_NO_COPY_CLASS(wxSocketImpl); -}; - -#if defined(__WINDOWS__) - #include "wx/msw/private/sockmsw.h" -#else - #include "wx/unix/private/sockunix.h" -#endif - -#endif /* wxUSE_SOCKETS */ - -#endif /* _WX_PRIVATE_SOCKET_H_ */ diff --git a/Source/3rd Party/wx/include/wx/private/textmeasure.h b/Source/3rd Party/wx/include/wx/private/textmeasure.h deleted file mode 100644 index a4db67cb5..000000000 --- a/Source/3rd Party/wx/include/wx/private/textmeasure.h +++ /dev/null @@ -1,174 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/textmeasure.h -// Purpose: declaration of wxTextMeasure class -// Author: Manuel Martin -// Created: 2012-10-05 -// Copyright: (c) 1997-2012 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_TEXTMEASURE_H_ -#define _WX_PRIVATE_TEXTMEASURE_H_ - -class WXDLLIMPEXP_FWD_CORE wxDC; -class WXDLLIMPEXP_FWD_CORE wxFont; -class WXDLLIMPEXP_FWD_CORE wxWindow; - -// ---------------------------------------------------------------------------- -// wxTextMeasure: class used to measure text extent. -// ---------------------------------------------------------------------------- - -class wxTextMeasureBase -{ -public: - // The first ctor argument must be non-NULL, i.e. each object of this class - // is associated with either a valid wxDC or a valid wxWindow. The font can - // be NULL to use the current DC/window font or can be specified explicitly. - wxTextMeasureBase(const wxDC *dc, const wxFont *theFont); - wxTextMeasureBase(const wxWindow *win, const wxFont *theFont); - - // Even though this class is not supposed to be used polymorphically, give - // it a virtual dtor to avoid compiler warnings. - virtual ~wxTextMeasureBase() { } - - - // Return the extent of a single line string. - void GetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL); - - // The same for a multiline (with '\n') string. - void GetMultiLineTextExtent(const wxString& text, - wxCoord *width, - wxCoord *height, - wxCoord *heightOneLine = NULL); - - // Find the dimensions of the largest string. - wxSize GetLargestStringExtent(size_t n, const wxString* strings); - wxSize GetLargestStringExtent(const wxArrayString& strings) - { - return GetLargestStringExtent(strings.size(), &strings[0]); - } - - // Fill the array with the widths for each "0..N" substrings for N from 1 - // to text.length(). - // - // The scaleX argument is the horizontal scale used by wxDC and is only - // used in the generic implementation. - bool GetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX); - - - // These functions are called by our public methods before and after each - // call to DoGetTextExtent(). Derived classes may override them to prepare - // for -- possibly several -- subsequent calls to DoGetTextExtent(). - // - // As these calls must be always paired, they're never called directly but - // only by our friend MeasuringGuard class. - // - // NB: They're public only to allow VC6 to compile this code, there doesn't - // seem to be any way to give MeasuringGuard access to them (FIXME-VC6) - virtual void BeginMeasuring() { } - virtual void EndMeasuring() { } - - // This is another method which is only used by MeasuringGuard. - bool IsUsingDCImpl() const { return m_useDCImpl; } - -protected: - // RAII wrapper for the two methods above. - class MeasuringGuard - { - public: - MeasuringGuard(wxTextMeasureBase& tm) : m_tm(tm) - { - // BeginMeasuring() should only be called if we have a native DC, - // so don't call it if we delegate to a DC of unknown type. - if ( !m_tm.IsUsingDCImpl() ) - m_tm.BeginMeasuring(); - } - - ~MeasuringGuard() - { - if ( !m_tm.IsUsingDCImpl() ) - m_tm.EndMeasuring(); - } - - private: - wxTextMeasureBase& m_tm; - }; - - - // The main function of this class, to be implemented in platform-specific - // way used by all our public methods. - // - // The width and height pointers here are never NULL and the input string - // is not empty. - virtual void DoGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL) = 0; - - // The real implementation of GetPartialTextExtents(). - // - // On input, widths array contains text.length() zero elements and the text - // is guaranteed to be non-empty. - virtual bool DoGetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX) = 0; - - // Call either DoGetTextExtent() or wxDC::GetTextExtent() depending on the - // value of m_useDCImpl. - // - // This must be always used instead of calling DoGetTextExtent() directly! - void CallGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL); - - // Return a valid font: if one was given to us in the ctor, use this one, - // otherwise use the current font of the associated wxDC or wxWindow. - wxFont GetFont() const; - - - // Exactly one of m_dc and m_win is non-NULL for any given object of this - // class. - const wxDC* const m_dc; - const wxWindow* const m_win; - - // If this is true, simply forward to wxDC::GetTextExtent() from our - // CallGetTextExtent() instead of calling our own DoGetTextExtent(). - // - // We need this because our DoGetTextExtent() typically only works with - // native DCs, i.e. those having an HDC under Windows or using Pango under - // GTK+. However wxTextMeasure object can be constructed for any wxDC, not - // necessarily a native one and in this case we must call back into the DC - // implementation of text measuring itself. - bool m_useDCImpl; - - // This one can be NULL or not. - const wxFont* const m_font; - - wxDECLARE_NO_COPY_CLASS(wxTextMeasureBase); -}; - -// Include the platform dependent class declaration, if any. -#if defined(__WXGTK20__) - #include "wx/gtk/private/textmeasure.h" -#elif defined(__WXMSW__) - #include "wx/msw/private/textmeasure.h" -#else // no platform-specific implementation of wxTextMeasure yet - #include "wx/generic/private/textmeasure.h" - - #define wxUSE_GENERIC_TEXTMEASURE 1 -#endif - -#ifndef wxUSE_GENERIC_TEXTMEASURE - #define wxUSE_GENERIC_TEXTMEASURE 0 -#endif - -#endif // _WX_PRIVATE_TEXTMEASURE_H_ diff --git a/Source/3rd Party/wx/include/wx/private/threadinfo.h b/Source/3rd Party/wx/include/wx/private/threadinfo.h deleted file mode 100644 index 27a71674b..000000000 --- a/Source/3rd Party/wx/include/wx/private/threadinfo.h +++ /dev/null @@ -1,69 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/private/threadinfo.h -// Purpose: declaration of wxThreadSpecificInfo: thread-specific information -// Author: Vadim Zeitlin -// Created: 2009-07-13 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_THREADINFO_H_ -#define _WX_PRIVATE_THREADINFO_H_ - -#include "wx/defs.h" - -class WXDLLIMPEXP_FWD_BASE wxLog; - -#if wxUSE_INTL -#include "wx/hashset.h" -WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual, - wxLocaleUntranslatedStrings); -#endif - - -// ---------------------------------------------------------------------------- -// wxThreadSpecificInfo: contains all thread-specific information used by wx -// ---------------------------------------------------------------------------- - -// Group all thread-specific information we use (e.g. the active wxLog target) -// a in this class to avoid consuming more TLS slots than necessary as there is -// only a limited number of them. -class wxThreadSpecificInfo -{ -public: - // Return this thread's instance. - static wxThreadSpecificInfo& Get(); - - // the thread-specific logger or NULL if the thread is using the global one - // (this is not used for the main thread which always uses the global - // logger) - wxLog *logger; - - // true if logging is currently disabled for this thread (this is also not - // used for the main thread which uses wxLog::ms_doLog) - // - // NB: we use a counter-intuitive "disabled" flag instead of "enabled" one - // because the default, for 0-initialized struct, should be to enable - // logging - bool loggingDisabled; - -#if wxUSE_INTL - // Storage for wxTranslations::GetUntranslatedString() - wxLocaleUntranslatedStrings untranslatedStrings; -#endif - -#if wxUSE_THREADS - // Cleans up storage for the current thread. Should be called when a thread - // is being destroyed. If it's not called, the only bad thing that happens - // is that the memory is deallocated later, on process termination. - static void ThreadCleanUp(); -#endif - -private: - wxThreadSpecificInfo() : logger(NULL), loggingDisabled(false) {} -}; - -#define wxThreadInfo wxThreadSpecificInfo::Get() - -#endif // _WX_PRIVATE_THREADINFO_H_ - diff --git a/Source/3rd Party/wx/include/wx/private/timer.h b/Source/3rd Party/wx/include/wx/private/timer.h deleted file mode 100644 index 5f4ce0d51..000000000 --- a/Source/3rd Party/wx/include/wx/private/timer.h +++ /dev/null @@ -1,72 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/timer.h -// Purpose: Base class for wxTimer implementations -// Author: Lukasz Michalski -// Created: 31.10.2006 -// Copyright: (c) 2006-2007 wxWidgets dev team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TIMERIMPL_H_BASE_ -#define _WX_TIMERIMPL_H_BASE_ - -#include "wx/defs.h" -#include "wx/event.h" -#include "wx/timer.h" - -// ---------------------------------------------------------------------------- -// wxTimerImpl: abstract base class for wxTimer implementations -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxTimerImpl -{ -public: - // default ctor, SetOwner() must be called after it (wxTimer does it) - wxTimerImpl(wxTimer *owner); - - // this must be called initially but may be also called later - void SetOwner(wxEvtHandler *owner, int timerid); - - // empty but virtual base class dtor, the caller is responsible for - // stopping the timer before it's destroyed (it can't be done from here as - // it's too late) - virtual ~wxTimerImpl() { } - - - // start the timer. When overriding call base version first. - virtual bool Start(int milliseconds = -1, bool oneShot = false); - - // stop the timer, only called if the timer is really running (unlike - // wxTimer::Stop()) - virtual void Stop() = 0; - - // return true if the timer is running - virtual bool IsRunning() const = 0; - - // this should be called by the port-specific code when the timer expires - virtual void Notify() { m_timer->Notify(); } - - // the default implementation of wxTimer::Notify(): generate a wxEVT_TIMER - void SendEvent(); - - - // accessors for wxTimer: - wxEvtHandler *GetOwner() const { return m_owner; } - int GetId() const { return m_idTimer; } - int GetInterval() const { return m_milli; } - bool IsOneShot() const { return m_oneShot; } - -protected: - wxTimer *m_timer; - - wxEvtHandler *m_owner; - - int m_idTimer; // id passed to wxTimerEvent - int m_milli; // the timer interval - bool m_oneShot; // true if one shot - - - wxDECLARE_NO_COPY_CLASS(wxTimerImpl); -}; - -#endif // _WX_TIMERIMPL_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/private/window.h b/Source/3rd Party/wx/include/wx/private/window.h deleted file mode 100644 index 1192fb97b..000000000 --- a/Source/3rd Party/wx/include/wx/private/window.h +++ /dev/null @@ -1,38 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/window.h -// Purpose: misc wxWindow helpers -// Author: Vaclav Slavik -// Created: 2010-01-21 -// Copyright: (c) 2010 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_WINDOW_H_ -#define _WX_PRIVATE_WINDOW_H_ - -#include "wx/gdicmn.h" - -namespace wxPrivate -{ - -// Windows' computes dialog units using average character width over upper- -// and lower-case ASCII alphabet and not using the average character width -// metadata stored in the font; see -// http://support.microsoft.com/default.aspx/kb/145994 for detailed discussion. -// -// This helper function computes font dimensions in the same way. It works with -// either wxDC or wxWindow argument. -template -inline wxSize GetAverageASCIILetterSize(const T& of_what) -{ - const wxStringCharType *TEXT_TO_MEASURE = - wxS("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); - - wxSize s = of_what.GetTextExtent(TEXT_TO_MEASURE); - s.x = (s.x / 26 + 1) / 2; - return s; -} - -} // namespace wxPrivate - -#endif // _WX_PRIVATE_WINDOW_H_ diff --git a/Source/3rd Party/wx/include/wx/private/wxprintf.h b/Source/3rd Party/wx/include/wx/private/wxprintf.h deleted file mode 100644 index 00013c193..000000000 --- a/Source/3rd Party/wx/include/wx/private/wxprintf.h +++ /dev/null @@ -1,934 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/private/wxprintf.h -// Purpose: wxWidgets wxPrintf() implementation -// Author: Ove Kaven -// Modified by: Ron Lee, Francesco Montorsi -// Created: 09/04/99 -// Copyright: (c) wxWidgets copyright -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PRIVATE_WXPRINTF_H_ -#define _WX_PRIVATE_WXPRINTF_H_ - -// --------------------------------------------------------------------------- -// headers and macros -// --------------------------------------------------------------------------- - -#include "wx/crt.h" -#include "wx/log.h" -#include "wx/utils.h" - -#include - -// prefer snprintf over sprintf -#if defined(__VISUALC__) || \ - (defined(__BORLANDC__) && __BORLANDC__ >= 0x540) - #define system_sprintf(buff, max, flags, data) \ - ::_snprintf(buff, max, flags, data) -#elif defined(HAVE_SNPRINTF) - #define system_sprintf(buff, max, flags, data) \ - ::snprintf(buff, max, flags, data) -#else // NB: at least sprintf() should always be available - // since 'max' is not used in this case, wxVsnprintf() should always - // ensure that 'buff' is big enough for all common needs - // (see wxMAX_SVNPRINTF_FLAGBUFFER_LEN and wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN) - #define system_sprintf(buff, max, flags, data) \ - ::sprintf(buff, flags, data) - - #define SYSTEM_SPRINTF_IS_UNSAFE -#endif - -// --------------------------------------------------------------------------- -// printf format string parsing -// --------------------------------------------------------------------------- - -// some limits of our implementation -#define wxMAX_SVNPRINTF_ARGUMENTS 64 -#define wxMAX_SVNPRINTF_FLAGBUFFER_LEN 32 -#define wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN 512 - - -// the conversion specifiers accepted by wxCRT_VsnprintfW -enum wxPrintfArgType -{ - wxPAT_INVALID = -1, - - wxPAT_INT, // %d, %i, %o, %u, %x, %X - wxPAT_LONGINT, // %ld, etc -#ifdef wxLongLong_t - wxPAT_LONGLONGINT, // %Ld, etc -#endif - wxPAT_SIZET, // %zd, etc - - wxPAT_DOUBLE, // %e, %E, %f, %g, %G - wxPAT_LONGDOUBLE, // %le, etc - - wxPAT_POINTER, // %p - - wxPAT_CHAR, // %hc (in ANSI mode: %c, too) - wxPAT_WCHAR, // %lc (in Unicode mode: %c, too) - - wxPAT_PCHAR, // %s (related to a char *) - wxPAT_PWCHAR, // %s (related to a wchar_t *) - - wxPAT_NINT, // %n - wxPAT_NSHORTINT, // %hn - wxPAT_NLONGINT, // %ln - - wxPAT_STAR // '*' used for width or precision -}; - -// an argument passed to wxCRT_VsnprintfW -union wxPrintfArg -{ - int pad_int; // %d, %i, %o, %u, %x, %X - long int pad_longint; // %ld, etc -#ifdef wxLongLong_t - wxLongLong_t pad_longlongint; // %Ld, etc -#endif - size_t pad_sizet; // %zd, etc - - double pad_double; // %e, %E, %f, %g, %G - long double pad_longdouble; // %le, etc - - void *pad_pointer; // %p - - char pad_char; // %hc (in ANSI mode: %c, too) - wchar_t pad_wchar; // %lc (in Unicode mode: %c, too) - - void *pad_str; // %s - - int *pad_nint; // %n - short int *pad_nshortint; // %hn - long int *pad_nlongint; // %ln -}; - -// helper for converting string into either char* or wchar_t* depending -// on the type of wxPrintfConvSpec instantiation: -template struct wxPrintfStringHelper {}; - -template<> struct wxPrintfStringHelper -{ - typedef const wxWX2MBbuf ConvertedType; - static ConvertedType Convert(const wxString& s) { return s.mb_str(); } -}; - -template<> struct wxPrintfStringHelper -{ - typedef const wxWX2WCbuf ConvertedType; - static ConvertedType Convert(const wxString& s) { return s.wc_str(); } -}; - - -// Contains parsed data relative to a conversion specifier given to -// wxCRT_VsnprintfW and parsed from the format string -// NOTE: in C++ there is almost no difference between struct & classes thus -// there is no performance gain by using a struct here... -template -class wxPrintfConvSpec -{ -public: - - // the position of the argument relative to this conversion specifier - size_t m_pos; - - // the type of this conversion specifier - wxPrintfArgType m_type; - - // the minimum and maximum width - // when one of this var is set to -1 it means: use the following argument - // in the stack as minimum/maximum width for this conversion specifier - int m_nMinWidth, m_nMaxWidth; - - // does the argument need to the be aligned to left ? - bool m_bAlignLeft; - - // pointer to the '%' of this conversion specifier in the format string - // NOTE: this points somewhere in the string given to the Parse() function - - // it's task of the caller ensure that memory is still valid ! - const CharType *m_pArgPos; - - // pointer to the last character of this conversion specifier in the - // format string - // NOTE: this points somewhere in the string given to the Parse() function - - // it's task of the caller ensure that memory is still valid ! - const CharType *m_pArgEnd; - - // a little buffer where formatting flags like #+\.hlqLz are stored by Parse() - // for use in Process() - char m_szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN]; - - -public: - - // we don't declare this as a constructor otherwise it would be called - // automatically and we don't want this: to be optimized, wxCRT_VsnprintfW - // calls this function only on really-used instances of this class. - void Init(); - - // Parses the first conversion specifier in the given string, which must - // begin with a '%'. Returns false if the first '%' does not introduce a - // (valid) conversion specifier and thus should be ignored. - bool Parse(const CharType *format); - - // Process this conversion specifier and puts the result in the given - // buffer. Returns the number of characters written in 'buf' or -1 if - // there's not enough space. - int Process(CharType *buf, size_t lenMax, wxPrintfArg *p, size_t written); - - // Loads the argument of this conversion specifier from given va_list. - bool LoadArg(wxPrintfArg *p, va_list &argptr); - -private: - // An helper function of LoadArg() which is used to handle the '*' flag - void ReplaceAsteriskWith(int w); -}; - -template -void wxPrintfConvSpec::Init() -{ - m_nMinWidth = 0; - m_nMaxWidth = 0xFFFF; - m_pos = 0; - m_bAlignLeft = false; - m_pArgPos = m_pArgEnd = NULL; - m_type = wxPAT_INVALID; - - memset(m_szFlags, 0, sizeof(m_szFlags)); - // this character will never be removed from m_szFlags array and - // is important when calling sprintf() in wxPrintfConvSpec::Process() ! - m_szFlags[0] = '%'; -} - -template -bool wxPrintfConvSpec::Parse(const CharType *format) -{ - bool done = false; - - // temporary parse data - size_t flagofs = 1; - bool in_prec, // true if we found the dot in some previous iteration - prec_dot; // true if the dot has been already added to m_szFlags - int ilen = 0; - - m_bAlignLeft = in_prec = prec_dot = false; - m_pArgPos = m_pArgEnd = format; - do - { -#define CHECK_PREC \ - if (in_prec && !prec_dot) \ - { \ - m_szFlags[flagofs++] = '.'; \ - prec_dot = true; \ - } - - // what follows '%'? - const CharType ch = *(++m_pArgEnd); - switch ( ch ) - { - case wxT('\0'): - return false; // not really an argument - - case wxT('%'): - return false; // not really an argument - - case wxT('#'): - case wxT('0'): - case wxT(' '): - case wxT('+'): - case wxT('\''): - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('-'): - CHECK_PREC - m_bAlignLeft = true; - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('.'): - // don't use CHECK_PREC here to avoid warning about the value - // assigned to prec_dot inside it being never used (because - // overwritten just below) from Borland in release build - if (in_prec && !prec_dot) - m_szFlags[flagofs++] = '.'; - in_prec = true; - prec_dot = false; - m_nMaxWidth = 0; - // dot will be auto-added to m_szFlags if non-negative - // number follows - break; - - case wxT('h'): - ilen = -1; - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('l'): - // NB: it's safe to use flagofs-1 as flagofs always start from 1 - if (m_szFlags[flagofs-1] == 'l') // 'll' modifier is the same as 'L' or 'q' - ilen = 2; - else - ilen = 1; - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('q'): - case wxT('L'): - ilen = 2; - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - break; -#ifdef __WINDOWS__ - // under Windows we support the special '%I64' notation as longlong - // integer conversion specifier for MSVC compatibility - // (it behaves exactly as '%lli' or '%Li' or '%qi') - case wxT('I'): - if (*(m_pArgEnd+1) == wxT('6') && - *(m_pArgEnd+2) == wxT('4')) - { - m_pArgEnd++; - m_pArgEnd++; - - ilen = 2; - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - m_szFlags[flagofs++] = '6'; - m_szFlags[flagofs++] = '4'; - break; - } - // else: fall-through, 'I' is MSVC equivalent of C99 'z' -#endif // __WINDOWS__ - - case wxT('z'): - case wxT('Z'): - // 'z' is C99 standard for size_t and ptrdiff_t, 'Z' was used - // for this purpose in libc5 and by wx <= 2.8 - ilen = 3; - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('*'): - if (in_prec) - { - CHECK_PREC - - // tell Process() to use the next argument - // in the stack as maxwidth... - m_nMaxWidth = -1; - } - else - { - // tell Process() to use the next argument - // in the stack as minwidth... - m_nMinWidth = -1; - } - - // save the * in our formatting buffer... - // will be replaced later by Process() - m_szFlags[flagofs++] = char(ch); - break; - - case wxT('1'): case wxT('2'): case wxT('3'): - case wxT('4'): case wxT('5'): case wxT('6'): - case wxT('7'): case wxT('8'): case wxT('9'): - { - int len = 0; - CHECK_PREC - while ( (*m_pArgEnd >= CharType('0')) && - (*m_pArgEnd <= CharType('9')) ) - { - m_szFlags[flagofs++] = char(*m_pArgEnd); - len = len*10 + (*m_pArgEnd - wxT('0')); - m_pArgEnd++; - } - - if (in_prec) - m_nMaxWidth = len; - else - m_nMinWidth = len; - - m_pArgEnd--; // the main loop pre-increments n again - } - break; - - case wxT('$'): // a positional parameter (e.g. %2$s) ? - { - if (m_nMinWidth <= 0) - break; // ignore this formatting flag as no - // numbers are preceding it - - // remove from m_szFlags all digits previously added - do { - flagofs--; - } while (m_szFlags[flagofs] >= '1' && - m_szFlags[flagofs] <= '9'); - - // re-adjust the offset making it point to the - // next free char of m_szFlags - flagofs++; - - m_pos = m_nMinWidth; - m_nMinWidth = 0; - } - break; - - case wxT('d'): - case wxT('i'): - case wxT('o'): - case wxT('u'): - case wxT('x'): - case wxT('X'): - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - if (ilen == 0) - m_type = wxPAT_INT; - else if (ilen == -1) - // NB: 'short int' value passed through '...' - // is promoted to 'int', so we have to get - // an int from stack even if we need a short - m_type = wxPAT_INT; - else if (ilen == 1) - m_type = wxPAT_LONGINT; - else if (ilen == 2) -#ifdef wxLongLong_t - m_type = wxPAT_LONGLONGINT; -#else // !wxLongLong_t - m_type = wxPAT_LONGINT; -#endif // wxLongLong_t/!wxLongLong_t - else if (ilen == 3) - m_type = wxPAT_SIZET; - done = true; - break; - - case wxT('e'): - case wxT('E'): - case wxT('f'): - case wxT('g'): - case wxT('G'): - CHECK_PREC - m_szFlags[flagofs++] = char(ch); - if (ilen == 2) - m_type = wxPAT_LONGDOUBLE; - else - m_type = wxPAT_DOUBLE; - done = true; - break; - - case wxT('p'): - m_type = wxPAT_POINTER; - m_szFlags[flagofs++] = char(ch); - done = true; - break; - - case wxT('c'): - if (ilen == -1) - { - // in Unicode mode %hc == ANSI character - // and in ANSI mode, %hc == %c == ANSI... - m_type = wxPAT_CHAR; - } - else if (ilen == 1) - { - // in ANSI mode %lc == Unicode character - // and in Unicode mode, %lc == %c == Unicode... - m_type = wxPAT_WCHAR; - } - else - { -#if wxUSE_UNICODE - // in Unicode mode, %c == Unicode character - m_type = wxPAT_WCHAR; -#else - // in ANSI mode, %c == ANSI character - m_type = wxPAT_CHAR; -#endif - } - done = true; - break; - - case wxT('s'): - if (ilen == -1) - { - // Unicode mode wx extension: we'll let %hs mean non-Unicode - // strings (when in ANSI mode, %s == %hs == ANSI string) - m_type = wxPAT_PCHAR; - } - else if (ilen == 1) - { - // in Unicode mode, %ls == %s == Unicode string - // in ANSI mode, %ls == Unicode string - m_type = wxPAT_PWCHAR; - } - else - { -#if wxUSE_UNICODE - m_type = wxPAT_PWCHAR; -#else - m_type = wxPAT_PCHAR; -#endif - } - done = true; - break; - - case wxT('n'): - if (ilen == 0) - m_type = wxPAT_NINT; - else if (ilen == -1) - m_type = wxPAT_NSHORTINT; - else if (ilen >= 1) - m_type = wxPAT_NLONGINT; - done = true; - break; - - default: - // bad format, don't consider this an argument; - // leave it unchanged - return false; - } - - if (flagofs == wxMAX_SVNPRINTF_FLAGBUFFER_LEN) - { - wxLogDebug(wxT("Too many flags specified for a single conversion specifier!")); - return false; - } - } - while (!done); - - return true; // parsing was successful -} - -template -void wxPrintfConvSpec::ReplaceAsteriskWith(int width) -{ - char temp[wxMAX_SVNPRINTF_FLAGBUFFER_LEN]; - - // find the first * in our flag buffer - char *pwidth = strchr(m_szFlags, '*'); - wxCHECK_RET(pwidth, wxT("field width must be specified")); - - // save what follows the * (the +1 is to skip the asterisk itself!) - strcpy(temp, pwidth+1); - if (width < 0) - { - pwidth[0] = wxT('-'); - pwidth++; - } - - // replace * with the actual integer given as width -#ifndef SYSTEM_SPRINTF_IS_UNSAFE - int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) / - sizeof(*m_szFlags); -#endif - int offset = system_sprintf(pwidth, maxlen, "%d", abs(width)); - - // restore after the expanded * what was following it - strcpy(pwidth+offset, temp); -} - -template -bool wxPrintfConvSpec::LoadArg(wxPrintfArg *p, va_list &argptr) -{ - // did the '*' width/precision specifier was used ? - if (m_nMaxWidth == -1) - { - // take the maxwidth specifier from the stack - m_nMaxWidth = va_arg(argptr, int); - if (m_nMaxWidth < 0) - m_nMaxWidth = 0; - else - ReplaceAsteriskWith(m_nMaxWidth); - } - - if (m_nMinWidth == -1) - { - // take the minwidth specifier from the stack - m_nMinWidth = va_arg(argptr, int); - - ReplaceAsteriskWith(m_nMinWidth); - if (m_nMinWidth < 0) - { - m_bAlignLeft = !m_bAlignLeft; - m_nMinWidth = -m_nMinWidth; - } - } - - switch (m_type) { - case wxPAT_INT: - p->pad_int = va_arg(argptr, int); - break; - case wxPAT_LONGINT: - p->pad_longint = va_arg(argptr, long int); - break; -#ifdef wxLongLong_t - case wxPAT_LONGLONGINT: - p->pad_longlongint = va_arg(argptr, wxLongLong_t); - break; -#endif // wxLongLong_t - case wxPAT_SIZET: - p->pad_sizet = va_arg(argptr, size_t); - break; - case wxPAT_DOUBLE: - p->pad_double = va_arg(argptr, double); - break; - case wxPAT_LONGDOUBLE: - p->pad_longdouble = va_arg(argptr, long double); - break; - case wxPAT_POINTER: - p->pad_pointer = va_arg(argptr, void *); - break; - - case wxPAT_CHAR: - p->pad_char = (char)va_arg(argptr, int); // char is promoted to int when passed through '...' - break; - case wxPAT_WCHAR: - p->pad_wchar = (wchar_t)va_arg(argptr, int); // char is promoted to int when passed through '...' - break; - - case wxPAT_PCHAR: - case wxPAT_PWCHAR: - p->pad_str = va_arg(argptr, void *); - break; - - case wxPAT_NINT: - p->pad_nint = va_arg(argptr, int *); - break; - case wxPAT_NSHORTINT: - p->pad_nshortint = va_arg(argptr, short int *); - break; - case wxPAT_NLONGINT: - p->pad_nlongint = va_arg(argptr, long int *); - break; - - case wxPAT_STAR: - // this will be handled as part of the next argument - return true; - - case wxPAT_INVALID: - default: - return false; - } - - return true; // loading was successful -} - -template -int wxPrintfConvSpec::Process(CharType *buf, size_t lenMax, wxPrintfArg *p, size_t written) -{ - // buffer to avoid dynamic memory allocation each time for small strings; - // note that this buffer is used only to hold results of number formatting, - // %s directly writes user's string in buf, without using szScratch - char szScratch[wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN]; - size_t lenScratch = 0, lenCur = 0; - -#define APPEND_CH(ch) \ - { \ - if ( lenCur == lenMax ) \ - return -1; \ - \ - buf[lenCur++] = ch; \ - } - - switch ( m_type ) - { - case wxPAT_INT: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_int); - break; - - case wxPAT_LONGINT: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longint); - break; - -#ifdef wxLongLong_t - case wxPAT_LONGLONGINT: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longlongint); - break; -#endif // SIZEOF_LONG_LONG - - case wxPAT_SIZET: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_sizet); - break; - - case wxPAT_LONGDOUBLE: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longdouble); - break; - - case wxPAT_DOUBLE: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_double); - break; - - case wxPAT_POINTER: - lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_pointer); - break; - - case wxPAT_CHAR: - case wxPAT_WCHAR: - { - wxUniChar ch; - if (m_type == wxPAT_CHAR) - ch = p->pad_char; - else // m_type == wxPAT_WCHAR - ch = p->pad_wchar; - - CharType val = ch; - - size_t i; - - if (!m_bAlignLeft) - for (i = 1; i < (size_t)m_nMinWidth; i++) - APPEND_CH(wxT(' ')); - - APPEND_CH(val); - - if (m_bAlignLeft) - for (i = 1; i < (size_t)m_nMinWidth; i++) - APPEND_CH(wxT(' ')); - } - break; - - case wxPAT_PCHAR: - case wxPAT_PWCHAR: - { - wxString s; - if ( !p->pad_str ) - { - if ( m_nMaxWidth >= 6 ) - s = wxT("(null)"); - } - else if (m_type == wxPAT_PCHAR) - s.assign(static_cast(p->pad_str)); - else // m_type == wxPAT_PWCHAR - s.assign(static_cast(p->pad_str)); - - typename wxPrintfStringHelper::ConvertedType strbuf( - wxPrintfStringHelper::Convert(s)); - - // at this point we are sure that m_nMaxWidth is positive or - // null (see top of wxPrintfConvSpec::LoadArg) - int len = wxMin((unsigned int)m_nMaxWidth, wxStrlen(strbuf)); - - int i; - - if (!m_bAlignLeft) - { - for (i = len; i < m_nMinWidth; i++) - APPEND_CH(wxT(' ')); - } - - len = wxMin((unsigned int)len, lenMax-lenCur); - wxStrncpy(buf+lenCur, strbuf, len); - lenCur += len; - - if (m_bAlignLeft) - { - for (i = len; i < m_nMinWidth; i++) - APPEND_CH(wxT(' ')); - } - } - break; - - case wxPAT_NINT: - *p->pad_nint = written; - break; - - case wxPAT_NSHORTINT: - *p->pad_nshortint = (short int)written; - break; - - case wxPAT_NLONGINT: - *p->pad_nlongint = written; - break; - - case wxPAT_INVALID: - default: - return -1; - } - - // if we used system's sprintf() then we now need to append the s_szScratch - // buffer to the given one... - switch (m_type) - { - case wxPAT_INT: - case wxPAT_LONGINT: -#ifdef wxLongLong_t - case wxPAT_LONGLONGINT: -#endif - case wxPAT_SIZET: - case wxPAT_LONGDOUBLE: - case wxPAT_DOUBLE: - case wxPAT_POINTER: - wxASSERT(lenScratch < wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN); - // NB: 1) we can compare lenMax (for CharType*, i.e. possibly - // wchar_t*) with lenScratch (char*) because this code is - // formatting integers and that will have the same length - // even in UTF-8 (the only case when char* length may be - // more than wchar_t* length of the same string) - // 2) wxStrncpy converts the 2nd argument to 1st argument's - // type transparently if their types differ, so this code - // works for both instantiations - if (lenMax < lenScratch) - { - // fill output buffer and then return -1 - wxStrncpy(buf, szScratch, lenMax); - return -1; - } - wxStrncpy(buf, szScratch, lenScratch); - lenCur += lenScratch; - break; - - default: - break; // all other cases were completed previously - } - - return lenCur; -} - - -// helper that parses format string -template -struct wxPrintfConvSpecParser -{ - typedef wxPrintfConvSpec ConvSpec; - - wxPrintfConvSpecParser(const CharType *fmt) - { - nargs = 0; - posarg_present = - nonposarg_present = false; - - memset(pspec, 0, sizeof(pspec)); - - // parse the format string - for ( const CharType *toparse = fmt; *toparse != wxT('\0'); toparse++ ) - { - // skip everything except format specifications - if ( *toparse != '%' ) - continue; - - // also skip escaped percent signs - if ( toparse[1] == '%' ) - { - toparse++; - continue; - } - - ConvSpec *spec = &specs[nargs]; - spec->Init(); - - // attempt to parse this format specification - if ( !spec->Parse(toparse) ) - continue; - - // advance to the end of this specifier - toparse = spec->m_pArgEnd; - - // special handling for specifications including asterisks: we need - // to reserve an extra slot (or two if asterisks were used for both - // width and precision) in specs array in this case - if ( const char *f = strchr(spec->m_szFlags, '*') ) - { - unsigned numAsterisks = 1; - if ( strchr(++f, '*') ) - numAsterisks++; - - for ( unsigned n = 0; n < numAsterisks; n++ ) - { - if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS ) - break; - - // TODO: we need to support specifiers of the form "%2$*1$s" - // (this is the same as "%*s") as if any positional arguments - // are used all asterisks must be positional as well but this - // requires a lot of changes in this code (basically we'd need - // to rewrite Parse() to return "*" and conversion itself as - // separate entries) - if ( posarg_present ) - { - wxFAIL_MSG - ( - wxString::Format - ( - "Format string \"%s\" uses both positional " - "parameters and '*' but this is not currently " - "supported by this implementation, sorry.", - fmt - ) - ); - } - - specs[nargs] = *spec; - - // make an entry for '*' and point to it from pspec - spec->Init(); - spec->m_type = wxPAT_STAR; - pspec[nargs - 1] = spec; - - spec = &specs[nargs]; - } - } - - - // check if this is a positional or normal argument - if ( spec->m_pos > 0 ) - { - // the positional arguments start from number 1 so we need - // to adjust the index - spec->m_pos--; - posarg_present = true; - } - else // not a positional argument... - { - spec->m_pos = nargs; - nonposarg_present = true; - } - - // this conversion specifier is tied to the pos-th argument... - pspec[spec->m_pos] = spec; - - if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS ) - break; - } - - - // warn if we lost any arguments (the program probably will crash - // anyhow because of stack corruption...) - if ( nargs == wxMAX_SVNPRINTF_ARGUMENTS ) - { - wxFAIL_MSG - ( - wxString::Format - ( - "wxVsnprintf() currently supports only %d arguments, " - "but format string \"%s\" defines more of them.\n" - "You need to change wxMAX_SVNPRINTF_ARGUMENTS and " - "recompile if more are really needed.", - fmt, wxMAX_SVNPRINTF_ARGUMENTS - ) - ); - } - } - - // total number of valid elements in specs - unsigned nargs; - - // all format specifications in this format string in order of their - // appearance (which may be different from arguments order) - ConvSpec specs[wxMAX_SVNPRINTF_ARGUMENTS]; - - // pointer to specs array element for the N-th argument - ConvSpec *pspec[wxMAX_SVNPRINTF_ARGUMENTS]; - - // true if any positional/non-positional parameters are used - bool posarg_present, - nonposarg_present; -}; - -#undef APPEND_CH -#undef CHECK_PREC - -#endif // _WX_PRIVATE_WXPRINTF_H_ diff --git a/Source/3rd Party/wx/include/wx/prntbase.h b/Source/3rd Party/wx/include/wx/prntbase.h index b2bb947fe..4c442a011 100644 --- a/Source/3rd Party/wx/include/wx/prntbase.h +++ b/Source/3rd Party/wx/include/wx/prntbase.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: prntbase.h 62502 2009-10-27 16:39:01Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,6 @@ #include "wx/scrolwin.h" #include "wx/dialog.h" #include "wx/frame.h" -#include "wx/dc.h" class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxButton; @@ -38,11 +38,6 @@ class WXDLLIMPEXP_FWD_CORE wxPreviewControlBar; class WXDLLIMPEXP_FWD_CORE wxPreviewFrame; class WXDLLIMPEXP_FWD_CORE wxPrintFactory; class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase; -class WXDLLIMPEXP_FWD_CORE wxPrintPreview; -class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog; -class WXDLLIMPEXP_FWD_CORE wxStaticText; -class wxPrintPageMaxCtrl; -class wxPrintPageTextCtrl; //---------------------------------------------------------------------------- // error consts @@ -55,24 +50,11 @@ enum wxPrinterError wxPRINTER_ERROR }; -// Preview frame modality kind used with wxPreviewFrame::Initialize() -enum wxPreviewFrameModalityKind -{ - // Disable all the other top level windows while the preview is shown. - wxPreviewFrame_AppModal, - - // Disable only the parent window while the preview is shown. - wxPreviewFrame_WindowModal, - - // Don't disable any windows. - wxPreviewFrame_NonModal -}; - //---------------------------------------------------------------------------- // wxPrintFactory //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintFactory +class WXDLLEXPORT wxPrintFactory { public: wxPrintFactory() {} @@ -95,7 +77,7 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ) = 0; - virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) = 0; + virtual wxDC* CreatePrinterDC( const wxPrintData& data ) = 0; // What to do and what to show in the wxPrintDialog // a) Use the generic print setup dialog or a native one? @@ -119,7 +101,7 @@ private: static wxPrintFactory *m_factory; }; -class WXDLLIMPEXP_CORE wxNativePrintFactory: public wxPrintFactory +class WXDLLEXPORT wxNativePrintFactory: public wxPrintFactory { public: virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); @@ -139,7 +121,7 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ); - virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); + virtual wxDC* CreatePrinterDC( const wxPrintData& data ); virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); @@ -156,7 +138,7 @@ public: // wxPrintNativeDataBase //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintNativeDataBase: public wxObject +class WXDLLEXPORT wxPrintNativeDataBase: public wxObject { public: wxPrintNativeDataBase(); @@ -172,7 +154,7 @@ public: private: DECLARE_CLASS(wxPrintNativeDataBase) - wxDECLARE_NO_COPY_CLASS(wxPrintNativeDataBase); + DECLARE_NO_COPY_CLASS(wxPrintNativeDataBase) }; //---------------------------------------------------------------------------- @@ -183,13 +165,13 @@ private: * Represents the printer: manages printing a wxPrintout object */ -class WXDLLIMPEXP_CORE wxPrinterBase: public wxObject +class WXDLLEXPORT wxPrinterBase: public wxObject { public: - wxPrinterBase(wxPrintDialogData *data = NULL); + wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL); virtual ~wxPrinterBase(); - virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); + virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message); virtual wxPrintDialogData& GetPrintDialogData() const; @@ -216,20 +198,20 @@ public: private: DECLARE_CLASS(wxPrinterBase) - wxDECLARE_NO_COPY_CLASS(wxPrinterBase); + DECLARE_NO_COPY_CLASS(wxPrinterBase) }; //---------------------------------------------------------------------------- // wxPrinter //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrinter: public wxPrinterBase +class WXDLLEXPORT wxPrinter: public wxPrinterBase { public: - wxPrinter(wxPrintDialogData *data = NULL); + wxPrinter(wxPrintDialogData *data = (wxPrintDialogData *) NULL); virtual ~wxPrinter(); - virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); + virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message); virtual bool Setup(wxWindow *parent); @@ -243,7 +225,7 @@ protected: private: DECLARE_CLASS(wxPrinter) - wxDECLARE_NO_COPY_CLASS(wxPrinter); + DECLARE_NO_COPY_CLASS(wxPrinter) }; //---------------------------------------------------------------------------- @@ -257,10 +239,10 @@ private: * object for previewing. */ -class WXDLLIMPEXP_CORE wxPrintout: public wxObject +class WXDLLEXPORT wxPrintout: public wxObject { public: - wxPrintout(const wxString& title = wxGetTranslation("Printout")); + wxPrintout(const wxString& title = wxT("Printout")); virtual ~wxPrintout(); virtual bool OnBeginDocument(int startPage, int endPage); @@ -301,26 +283,20 @@ public: void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; } void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; } - void SetPPIScreen(const wxSize& ppi) { SetPPIScreen(ppi.x, ppi.y); } void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; } void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; } - void SetPPIPrinter(const wxSize& ppi) { SetPPIPrinter(ppi.x, ppi.y); } void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; } void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; } wxRect GetPaperRectPixels() const { return m_paperRectPixels; } - // This must be called by wxPrintPreview to associate itself with the - // printout it uses. - virtual void SetPreview(wxPrintPreview *preview) { m_preview = preview; } + virtual bool IsPreview() const { return m_isPreview; } - wxPrintPreview *GetPreview() const { return m_preview; } - virtual bool IsPreview() const { return GetPreview() != NULL; } + virtual void SetIsPreview(bool p) { m_isPreview = p; } private: wxString m_printoutTitle; wxDC* m_printoutDC; - wxPrintPreview *m_preview; int m_pageWidthPixels; int m_pageHeightPixels; @@ -335,9 +311,11 @@ private: wxRect m_paperRectPixels; + bool m_isPreview; + private: DECLARE_ABSTRACT_CLASS(wxPrintout) - wxDECLARE_NO_COPY_CLASS(wxPrintout); + DECLARE_NO_COPY_CLASS(wxPrintout) }; //---------------------------------------------------------------------------- @@ -348,7 +326,7 @@ private: * Canvas upon which a preview is drawn. */ -class WXDLLIMPEXP_CORE wxPreviewCanvas: public wxScrolledWindow +class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow { public: wxPreviewCanvas(wxPrintPreviewBase *preview, @@ -359,8 +337,6 @@ public: const wxString& name = wxT("canvas")); virtual ~wxPreviewCanvas(); - void SetPreview(wxPrintPreviewBase *preview) { m_printPreview = preview; } - void OnPaint(wxPaintEvent& event); void OnChar(wxKeyEvent &event); // Responds to colour changes @@ -370,13 +346,12 @@ private: #if wxUSE_MOUSEWHEEL void OnMouseWheel(wxMouseEvent& event); #endif // wxUSE_MOUSEWHEEL - void OnIdle(wxIdleEvent& event); wxPrintPreviewBase* m_printPreview; DECLARE_CLASS(wxPreviewCanvas) DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxPreviewCanvas); + DECLARE_NO_COPY_CLASS(wxPreviewCanvas) }; //---------------------------------------------------------------------------- @@ -387,38 +362,20 @@ private: * Default frame for showing preview. */ -class WXDLLIMPEXP_CORE wxPreviewFrame: public wxFrame +class WXDLLEXPORT wxPreviewFrame: public wxFrame { public: wxPreviewFrame(wxPrintPreviewBase *preview, wxWindow *parent, - const wxString& title = wxGetTranslation("Print Preview"), + const wxString& title = wxT("Print Preview"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT, const wxString& name = wxFrameNameStr); virtual ~wxPreviewFrame(); - // Either Initialize() or InitializeWithModality() must be called before - // showing the preview frame, the former being just a particular case of - // the latter initializing the frame for being showing app-modally. - - // Notice that we must keep Initialize() with its existing signature to - // avoid breaking the old code that overrides it and we can't reuse the - // same name for the other functions to avoid virtual function hiding - // problem and the associated warnings given by some compilers (e.g. from - // g++ with -Woverloaded-virtual). - virtual void Initialize() - { - InitializeWithModality(wxPreviewFrame_AppModal); - } - - // Also note that this method is not virtual as it doesn't need to be - // overridden: it's never called by wxWidgets (of course, the same is true - // for Initialize() but, again, it must remain virtual for compatibility). - void InitializeWithModality(wxPreviewFrameModalityKind kind); - void OnCloseWindow(wxCloseEvent& event); + virtual void Initialize(); virtual void CreateCanvas(); virtual void CreateControlBar(); @@ -430,15 +387,10 @@ protected: wxPrintPreviewBase* m_printPreview; wxWindowDisabler* m_windowDisabler; - wxPreviewFrameModalityKind m_modalityKind; - - private: - void OnChar(wxKeyEvent& event); - - DECLARE_EVENT_TABLE() DECLARE_CLASS(wxPreviewFrame) - wxDECLARE_NO_COPY_CLASS(wxPreviewFrame); + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxPreviewFrame) }; //---------------------------------------------------------------------------- @@ -471,10 +423,8 @@ private: #define wxID_PREVIEW_FIRST 6 #define wxID_PREVIEW_LAST 7 #define wxID_PREVIEW_GOTO 8 -#define wxID_PREVIEW_ZOOM_IN 9 -#define wxID_PREVIEW_ZOOM_OUT 10 -class WXDLLIMPEXP_CORE wxPreviewControlBar: public wxPanel +class WXDLLEXPORT wxPreviewControlBar: public wxPanel { DECLARE_CLASS(wxPreviewControlBar) @@ -489,73 +439,42 @@ public: virtual ~wxPreviewControlBar(); virtual void CreateButtons(); - virtual void SetPageInfo(int minPage, int maxPage); virtual void SetZoomControl(int zoom); virtual int GetZoomControl(); virtual wxPrintPreviewBase *GetPrintPreview() const { return m_printPreview; } - - // Implementation only from now on. void OnWindowClose(wxCommandEvent& event); void OnNext(); void OnPrevious(); void OnFirst(); void OnLast(); - void OnGotoPage(); + void OnGoto(); void OnPrint(); - void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); } void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); } void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); } void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); } void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); } + void OnGotoButton(wxCommandEvent & WXUNUSED(event)) { OnGoto(); } + void OnZoom(wxCommandEvent& event); void OnPaint(wxPaintEvent& event); - void OnUpdateNextButton(wxUpdateUIEvent& event) - { event.Enable(IsNextEnabled()); } - void OnUpdatePreviousButton(wxUpdateUIEvent& event) - { event.Enable(IsPreviousEnabled()); } - void OnUpdateFirstButton(wxUpdateUIEvent& event) - { event.Enable(IsFirstEnabled()); } - void OnUpdateLastButton(wxUpdateUIEvent& event) - { event.Enable(IsLastEnabled()); } - void OnUpdateZoomInButton(wxUpdateUIEvent& event) - { event.Enable(IsZoomInEnabled()); } - void OnUpdateZoomOutButton(wxUpdateUIEvent& event) - { event.Enable(IsZoomOutEnabled()); } - - // These methods are not private because they are called by wxPreviewCanvas. - void DoZoomIn(); - void DoZoomOut(); - protected: wxPrintPreviewBase* m_printPreview; wxButton* m_closeButton; + wxButton* m_nextPageButton; + wxButton* m_previousPageButton; + wxButton* m_printButton; wxChoice* m_zoomControl; - wxPrintPageTextCtrl* m_currentPageText; - wxPrintPageMaxCtrl* m_maxPageText; - + wxButton* m_firstPageButton; + wxButton* m_lastPageButton; + wxButton* m_gotoPageButton; long m_buttonFlags; private: - void DoGotoPage(int page); - - void DoZoom(); - - bool IsNextEnabled() const; - bool IsPreviousEnabled() const; - bool IsFirstEnabled() const; - bool IsLastEnabled() const; - bool IsZoomInEnabled() const; - bool IsZoomOutEnabled() const; - - void OnZoomInButton(wxCommandEvent & WXUNUSED(event)) { DoZoomIn(); } - void OnZoomOutButton(wxCommandEvent & WXUNUSED(event)) { DoZoomOut(); } - void OnZoomChoice(wxCommandEvent& WXUNUSED(event)) { DoZoom(); } - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxPreviewControlBar); + DECLARE_NO_COPY_CLASS(wxPreviewControlBar) }; //---------------------------------------------------------------------------- @@ -566,12 +485,12 @@ private: * Programmer creates an object of this class to preview a wxPrintout. */ -class WXDLLIMPEXP_CORE wxPrintPreviewBase: public wxObject +class WXDLLEXPORT wxPrintPreviewBase: public wxObject { public: wxPrintPreviewBase(wxPrintout *printout, - wxPrintout *printoutForPrinting = NULL, - wxPrintDialogData *data = NULL); + wxPrintout *printoutForPrinting = (wxPrintout *) NULL, + wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data); @@ -597,10 +516,6 @@ public: // The preview canvas should call this from OnPaint virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc); - // Updates rendered page by calling RenderPage() if needed, returns true - // if there was some change. Preview canvas should call it at idle time - virtual bool UpdatePageRendering(); - // This draws a blank page onto the preview canvas virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); @@ -636,20 +551,11 @@ public: // the currently selected printer. virtual void DetermineScaling() = 0; -protected: - // helpers for RenderPage(): - virtual bool RenderPageIntoDC(wxDC& dc, int pageNum); - // renders preview into m_previewBitmap - virtual bool RenderPageIntoBitmap(wxBitmap& bmp, int pageNum); - - void InvalidatePreviewBitmap(); - protected: wxPrintDialogData m_printDialogData; wxPreviewCanvas* m_previewCanvas; wxFrame* m_previewFrame; wxBitmap* m_previewBitmap; - bool m_previewFailed; wxPrintout* m_previewPrintout; wxPrintout* m_printPrintout; int m_currentPage; @@ -669,7 +575,11 @@ protected: private: void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); - wxDECLARE_NO_COPY_CLASS(wxPrintPreviewBase); + // helpers for RenderPage(): + bool RenderPageIntoDC(wxDC& dc, int pageNum); + bool RenderPageIntoBitmap(wxBitmap& bmp, int pageNum); + + DECLARE_NO_COPY_CLASS(wxPrintPreviewBase) DECLARE_CLASS(wxPrintPreviewBase) }; @@ -677,12 +587,12 @@ private: // wxPrintPreview //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintPreview: public wxPrintPreviewBase +class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase { public: wxPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting = NULL, - wxPrintDialogData *data = NULL); + wxPrintout *printoutForPrinting = (wxPrintout *) NULL, + wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data); @@ -699,7 +609,6 @@ public: virtual wxFrame *GetFrame() const; virtual wxPreviewCanvas *GetCanvas() const; virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc); - virtual bool UpdatePageRendering(); virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); virtual void AdjustScrollbars(wxPreviewCanvas *canvas); virtual bool RenderPage(int pageNum); @@ -723,33 +632,31 @@ private: private: DECLARE_CLASS(wxPrintPreview) - wxDECLARE_NO_COPY_CLASS(wxPrintPreview); + DECLARE_NO_COPY_CLASS(wxPrintPreview) }; //---------------------------------------------------------------------------- // wxPrintAbortDialog //---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPrintAbortDialog: public wxDialog +class WXDLLEXPORT wxPrintAbortDialog: public wxDialog { public: wxPrintAbortDialog(wxWindow *parent, - const wxString& documentTitle, + const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxT("dialog")); - - void SetProgress(int currentPage, int totalPages, - int currentCopy, int totalCopies); + long style = 0, + const wxString& name = wxT("dialog")) + : wxDialog(parent, wxID_ANY, title, pos, size, style, name) + { + } void OnCancel(wxCommandEvent& event); private: - wxStaticText *m_progress; - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog); + DECLARE_NO_COPY_CLASS(wxPrintAbortDialog) }; #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/Source/3rd Party/wx/include/wx/process.h b/Source/3rd Party/wx/include/wx/process.h index 888ac2e4b..2c2f6185e 100644 --- a/Source/3rd Party/wx/include/wx/process.h +++ b/Source/3rd Party/wx/include/wx/process.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: Vadim Zeitlin to check error codes, added Detach() method // Created: 24/06/98 +// RCS-ID: $Id: process.h 42713 2006-10-30 11:56:12Z ABX $ // Copyright: (c) 1998 Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ public: // ctors - wxProcess(wxEvtHandler *parent = NULL, int nId = wxID_ANY) + wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, int nId = wxID_ANY) { Init(parent, nId, wxPROCESS_DEFAULT); } wxProcess(int flags) { Init(NULL, wxID_ANY, flags); } @@ -103,29 +104,13 @@ public: wxInputStream *errStream); #endif // wxUSE_STREAMS - // priority - // Sets the priority to the given value: see wxPRIORITY_XXX constants. - // - // NB: the priority can only be set before the process is created - void SetPriority(unsigned priority); - - // Get the current priority. - unsigned GetPriority() const { return m_priority; } - - // implementation only - don't use! - // -------------------------------- - - // needs to be public since it needs to be used from wxExecute() global func - void SetPid(long pid) { m_pid = pid; } - protected: void Init(wxEvtHandler *parent, int id, int flags); + void SetPid(long pid) { m_pid = pid; } int m_id; long m_pid; - unsigned m_priority; - #if wxUSE_STREAMS // these streams are connected to stdout, stderr and stdin of the child // process respectively (yes, m_inputStream corresponds to stdout -- very @@ -138,16 +123,16 @@ protected: bool m_redirect; DECLARE_DYNAMIC_CLASS(wxProcess) - wxDECLARE_NO_COPY_CLASS(wxProcess); + DECLARE_NO_COPY_CLASS(wxProcess) }; // ---------------------------------------------------------------------------- // wxProcess events // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_BASE wxProcessEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_BASE, wxEVT_END_PROCESS, wxProcessEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_END_PROCESS, 440) +END_DECLARE_EVENT_TYPES() class WXDLLIMPEXP_BASE wxProcessEvent : public wxEvent { @@ -179,7 +164,7 @@ public: typedef void (wxEvtHandler::*wxProcessEventFunction)(wxProcessEvent&); #define wxProcessEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxProcessEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxProcessEventFunction, &func) #define EVT_END_PROCESS(id, func) \ wx__DECLARE_EVT1(wxEVT_END_PROCESS, id, wxProcessEventHandler(func)) diff --git a/Source/3rd Party/wx/include/wx/progdlg.h b/Source/3rd Party/wx/include/wx/progdlg.h index 1f149a0ed..196192bce 100644 --- a/Source/3rd Party/wx/include/wx/progdlg.h +++ b/Source/3rd Party/wx/include/wx/progdlg.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: progdlg.h 41089 2006-09-09 13:36:54Z RR $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -13,8 +14,6 @@ #include "wx/defs.h" -#if wxUSE_PROGRESSDLG - /* * wxProgressDialog flags */ @@ -28,28 +27,10 @@ #define wxPD_CAN_SKIP 0x0080 -#include "wx/generic/progdlgg.h" - -#if defined(__WXMSW__) && wxUSE_THREADS && !defined(__WXUNIVERSAL__) - #include "wx/msw/progdlg.h" +#ifdef __WXPALMOS__ + #include "wx/palmos/progdlg.h" #else - class WXDLLIMPEXP_CORE wxProgressDialog - : public wxGenericProgressDialog - { - public: - wxProgressDialog( const wxString& title, const wxString& message, - int maximum = 100, - wxWindow *parent = NULL, - int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE ) - : wxGenericProgressDialog( title, message, maximum, - parent, style ) - { } - - private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxProgressDialog ); - }; -#endif // defined(__WXMSW__) && wxUSE_THREADS - -#endif // wxUSE_PROGRESSDLG + #include "wx/generic/progdlgg.h" +#endif #endif // _WX_PROGDLG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/propdlg.h b/Source/3rd Party/wx/include/wx/propdlg.h deleted file mode 100644 index 1f91c6fbc..000000000 --- a/Source/3rd Party/wx/include/wx/propdlg.h +++ /dev/null @@ -1,18 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/propdlg.h -// Purpose: wxPropertySheetDialog base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PROPDLG_H_BASE_ -#define _WX_PROPDLG_H_BASE_ - -#include "wx/generic/propdlg.h" - -#endif - // _WX_PROPDLG_H_BASE_ - diff --git a/Source/3rd Party/wx/include/wx/ptr_scpd.h b/Source/3rd Party/wx/include/wx/ptr_scpd.h index 1c4d77608..19c6588b7 100644 --- a/Source/3rd Party/wx/include/wx/ptr_scpd.h +++ b/Source/3rd Party/wx/include/wx/ptr_scpd.h @@ -1,13 +1,222 @@ -/////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // Name: wx/ptr_scpd.h -// Purpose: compatibility wrapper for wxScoped{Ptr,Array} -// Author: Vadim Zeitlin -// Created: 2009-02-03 -// Copyright: (c) 2009 Vadim Zeitlin +// Purpose: scoped smart pointer class +// Author: Jesse Lovelace +// Modified by: +// Created: 06/01/02 +// RCS-ID: $Id: ptr_scpd.h 35688 2005-09-25 19:59:19Z VZ $ +// Copyright: (c) Jesse Lovelace and original Boost authors (see below) // Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + +// This class closely follows the implementation of the boost +// library scoped_ptr and is an adaption for c++ macro's in +// the wxWidgets project. The original authors of the boost +// scoped_ptr are given below with their respective copyrights. + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation. +// + +#ifndef __WX_SCOPED_POINTER__ +#define __WX_SCOPED_POINTER__ + +#include "wx/defs.h" + +/* + checked deleters are used to make sure that the type being deleted is really + a complete type.: otherwise sizeof() would result in a compile-time error + + do { ... } while ( 0 ) construct is used to have an anonymous scope + (otherwise we could have name clashes between different "complete"s) but + still force a semicolon after the macro +*/ + +#ifdef __WATCOMC__ + #define wxFOR_ONCE(name) for(int name=0; name<1; name++) + #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name)) + #define wxPOST_NO_WARNING_SCOPE(name) +#else + #define wxPRE_NO_WARNING_SCOPE(name) do + #define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse ) +#endif + +#define wxCHECKED_DELETE(ptr) \ + wxPRE_NO_WARNING_SCOPE(scope_var1) \ + { \ + typedef char complete[sizeof(*ptr)]; \ + delete ptr; \ + } wxPOST_NO_WARNING_SCOPE(scope_var1) + +#define wxCHECKED_DELETE_ARRAY(ptr) \ + wxPRE_NO_WARNING_SCOPE(scope_var2) \ + { \ + typedef char complete[sizeof(*ptr)]; \ + delete [] ptr; \ + } wxPOST_NO_WARNING_SCOPE(scope_var2) + +/* These scoped pointers are *not* assignable and cannot be used + within a container. Look for wxDECLARE_SHARED_PTR for this + functionality. + + In addition, the type being used *must* be complete at the time + that wxDEFINE_SCOPED_* is called or a compiler error will result. + This is because the class checks for the completeness of the type + being used. +*/ + + +#define wxDECLARE_SCOPED_PTR(T, name) \ +class name \ +{ \ +private: \ + T * m_ptr; \ + \ + name(name const &); \ + name & operator=(name const &); \ + \ +public: \ + wxEXPLICIT name(T * ptr = NULL) \ + : m_ptr(ptr) { } \ + \ + ~name(); \ + \ + void reset(T * ptr = NULL) \ + { \ + if (m_ptr != ptr) \ + { \ + delete m_ptr; \ + m_ptr = ptr; \ + } \ + } \ + \ + T *release() \ + { \ + T *ptr = m_ptr; \ + m_ptr = NULL; \ + return ptr; \ + } \ + \ + T & operator*() const \ + { \ + wxASSERT(m_ptr != NULL); \ + return *m_ptr; \ + } \ + \ + T * operator->() const \ + { \ + wxASSERT(m_ptr != NULL); \ + return m_ptr; \ + } \ + \ + T * get() const \ + { \ + return m_ptr; \ + } \ + \ + void swap(name & ot) \ + { \ + T * tmp = ot.m_ptr; \ + ot.m_ptr = m_ptr; \ + m_ptr = tmp; \ + } \ +}; + +#define wxDEFINE_SCOPED_PTR(T, name)\ +name::~name() \ +{ \ + wxCHECKED_DELETE(m_ptr); \ +} + +// this macro can be used for the most common case when you want to declare and +// define the scoped pointer at the same time and want to use the standard +// naming convention: auto pointer to Foo is called FooPtr +#define wxDEFINE_SCOPED_PTR_TYPE(T) \ + wxDECLARE_SCOPED_PTR(T, T ## Ptr) \ + wxDEFINE_SCOPED_PTR(T, T ## Ptr) + +// the same but for arrays instead of simple pointers +#define wxDECLARE_SCOPED_ARRAY(T, name)\ +class name \ +{ \ +private: \ + T * m_ptr; \ + name(name const &); \ + name & operator=(name const &); \ + \ +public: \ + wxEXPLICIT name(T * p = NULL) : m_ptr(p) \ + {} \ + \ + ~name(); \ + void reset(T * p = NULL); \ + \ + T & operator[](long int i) const\ + { \ + wxASSERT(m_ptr != NULL); \ + wxASSERT(i >= 0); \ + return m_ptr[i]; \ + } \ + \ + T * get() const \ + { \ + return m_ptr; \ + } \ + \ + void swap(name & ot) \ + { \ + T * tmp = ot.m_ptr; \ + ot.m_ptr = m_ptr; \ + m_ptr = tmp; \ + } \ +}; + +#define wxDEFINE_SCOPED_ARRAY(T, name) \ +name::~name() \ +{ \ + wxCHECKED_DELETE_ARRAY(m_ptr); \ +} \ +void name::reset(T * p){ \ + if (m_ptr != p) \ + { \ + wxCHECKED_DELETE_ARRAY(m_ptr); \ + m_ptr = p; \ + } \ +} + +// ---------------------------------------------------------------------------- +// "Tied" scoped pointer: same as normal one but also sets the value of +// some other variable to the pointer value +// ---------------------------------------------------------------------------- + +#define wxDEFINE_TIED_SCOPED_PTR_TYPE(T) \ + wxDEFINE_SCOPED_PTR_TYPE(T) \ + class T ## TiedPtr : public T ## Ptr \ + { \ + public: \ + T ## TiedPtr(T **pp, T *p) \ + : T ## Ptr(p), m_pp(pp) \ + { \ + m_pOld = *pp; \ + *pp = p; \ + } \ + \ + ~ T ## TiedPtr() \ + { \ + *m_pp = m_pOld; \ + } \ + \ + private: \ + T **m_pp; \ + T *m_pOld; \ + }; + +#endif // __WX_SCOPED_POINTER__ -// do not include this file in any new code, include either wx/scopedptr.h or -// wx/scopedarray.h (or both) instead -#include "wx/scopedarray.h" -#include "wx/scopedptr.h" diff --git a/Source/3rd Party/wx/include/wx/ptr_shrd.h b/Source/3rd Party/wx/include/wx/ptr_shrd.h deleted file mode 100644 index 635cfe36e..000000000 --- a/Source/3rd Party/wx/include/wx/ptr_shrd.h +++ /dev/null @@ -1,11 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/ptr_shrd.h -// Purpose: compatibility wrapper for wx/sharedptr.h -// Author: Vadim Zeitlin -// Created: 2009-02-03 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// do not include this file in any new code, include wx/sharedptr.h instead -#include "wx/sharedptr.h" diff --git a/Source/3rd Party/wx/include/wx/quantize.h b/Source/3rd Party/wx/include/wx/quantize.h index 250cd748e..dd43f7a05 100644 --- a/Source/3rd Party/wx/include/wx/quantize.h +++ b/Source/3rd Party/wx/include/wx/quantize.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 22/6/2000 +// RCS-ID: $Id: quantize.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) Julian Smart // Licence: ///////////////////////////////////////////////////////////////////////////// @@ -33,7 +34,7 @@ class WXDLLIMPEXP_FWD_CORE wxPalette; #define wxQUANTIZE_RETURN_8BIT_DATA 0x02 #define wxQUANTIZE_FILL_DESTINATION_IMAGE 0x04 -class WXDLLIMPEXP_CORE wxQuantize: public wxObject +class WXDLLEXPORT wxQuantize: public wxObject { public: DECLARE_DYNAMIC_CLASS(wxQuantize) diff --git a/Source/3rd Party/wx/include/wx/radiobox.h b/Source/3rd Party/wx/include/wx/radiobox.h index 3157ffafe..e54aa7e71 100644 --- a/Source/3rd Party/wx/include/wx/radiobox.h +++ b/Source/3rd Party/wx/include/wx/radiobox.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 10.09.00 +// RCS-ID: $Id: radiobox.h 54930 2008-08-02 19:45:23Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,8 +12,6 @@ #ifndef _WX_RADIOBOX_H_BASE_ #define _WX_RADIOBOX_H_BASE_ -#include "wx/defs.h" - #if wxUSE_RADIOBOX #include "wx/ctrlsub.h" @@ -27,7 +26,7 @@ WX_DEFINE_EXPORTED_ARRAY_PTR(wxToolTip *, wxToolTipArray); #endif // wxUSE_TOOLTIPS -extern WXDLLIMPEXP_DATA_CORE(const char) wxRadioBoxNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxRadioBoxNameStr[]; // ---------------------------------------------------------------------------- // wxRadioBoxBase is not a normal base class, but rather a mix-in because the @@ -35,7 +34,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxRadioBoxNameStr[]; // example, it is a wxStaticBox in wxUniv and wxMSW but not in other ports // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRadioBoxBase : public wxItemContainerImmutable +class WXDLLEXPORT wxRadioBoxBase : public wxItemContainerImmutable { public: virtual ~wxRadioBoxBase(); @@ -86,6 +85,14 @@ public: } + // deprecated functions + // -------------------- + +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( int GetNumberOfRowsOrCols() const ); + wxDEPRECATED( void SetNumberOfRowsOrCols(int n) ); +#endif // WXWIN_COMPATIBILITY_2_4 + protected: wxRadioBoxBase() { @@ -98,8 +105,6 @@ protected: #endif // wxUSE_TOOLTIPS } - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - // return the number of items in major direction (which depends on whether // we have wxRA_SPECIFY_COLS or wxRA_SPECIFY_ROWS style) unsigned int GetMajorDim() const { return m_majorDim; } @@ -162,11 +167,13 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/radiobox.h" #elif defined(__WXMAC__) - #include "wx/osx/radiobox.h" + #include "wx/mac/radiobox.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/radiobox.h" #elif defined(__WXPM__) #include "wx/os2/radiobox.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/radiobox.h" #endif #endif // wxUSE_RADIOBOX diff --git a/Source/3rd Party/wx/include/wx/radiobut.h b/Source/3rd Party/wx/include/wx/radiobut.h index 4e7f5f3d6..2543ea8dc 100644 --- a/Source/3rd Party/wx/include/wx/radiobut.h +++ b/Source/3rd Party/wx/include/wx/radiobut.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 07.09.00 +// RCS-ID: $Id: radiobut.h 37066 2006-01-23 03:27:34Z MR $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -32,7 +33,7 @@ #include "wx/control.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxRadioButtonNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxRadioButtonNameStr[]; #if defined(__WXUNIVERSAL__) #include "wx/univ/radiobut.h" @@ -45,11 +46,13 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxRadioButtonNameStr[]; #elif defined(__WXGTK__) #include "wx/gtk1/radiobut.h" #elif defined(__WXMAC__) - #include "wx/osx/radiobut.h" + #include "wx/mac/radiobut.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/radiobut.h" #elif defined(__WXPM__) #include "wx/os2/radiobut.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/radiobut.h" #endif #endif // wxUSE_RADIOBTN diff --git a/Source/3rd Party/wx/include/wx/range.h b/Source/3rd Party/wx/include/wx/range.h deleted file mode 100644 index d59646e12..000000000 --- a/Source/3rd Party/wx/include/wx/range.h +++ /dev/null @@ -1,28 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/range.h -// Purpose: Range Value Class -// Author: Stefan Csomor -// Modified by: -// Created: 2011-01-07 -// Copyright: (c) 2011 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_RANGE_H_ -#define _WX_RANGE_H_ - -#include "wx/defs.h" - -class wxRange -{ -public : - wxRange(): m_minVal(0), m_maxVal(0) {} - wxRange( int minVal, int maxVal) : m_minVal(minVal), m_maxVal(maxVal) {} - int GetMin() const { return m_minVal; } - int GetMax() const { return m_maxVal; } -private : - int m_minVal; - int m_maxVal; -}; - -#endif // _WX_RANGE_H_ diff --git a/Source/3rd Party/wx/include/wx/rawbmp.h b/Source/3rd Party/wx/include/wx/rawbmp.h index 8aab5a536..c46028526 100644 --- a/Source/3rd Party/wx/include/wx/rawbmp.h +++ b/Source/3rd Party/wx/include/wx/rawbmp.h @@ -4,19 +4,15 @@ // Author: Eric Kidd, Vadim Zeitlin // Modified by: // Created: 10.03.03 +// RCS-ID: $Id: rawbmp.h 41661 2006-10-06 16:34:45Z PC $ // Copyright: (c) 2002 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _WX_RAWBMP_H_ -#define _WX_RAWBMP_H_ - -#include "wx/defs.h" - -#ifdef wxHAS_RAW_BITMAP +#ifndef _WX_RAWBMP_H_BASE_ +#define _WX_RAWBMP_H_BASE_ #include "wx/image.h" -#include "wx/bitmap.h" // ---------------------------------------------------------------------------- // Abstract Pixel API @@ -76,7 +72,7 @@ */ /* - Note: we do not use WXDLLIMPEXP_CORE with classes in this file because VC++ has + Note: we do not use WXDLLEXPORT with classes in this file because VC++ has problems with exporting inner class defined inside a specialization of a template class from a DLL. Besides, as all the methods are inline it's not really necessary to put them in DLL at all. @@ -171,16 +167,6 @@ typedef wxPixelFormat wxImagePixelFormat; // Under GTK+ 2.X we use GdkPixbuf, which is standard RGB or RGBA typedef wxPixelFormat wxNativePixelFormat; - #define wxPIXEL_FORMAT_ALPHA 3 -#elif defined(__WXPM__) - // Under PM, we can use standard RGB or RGBA - typedef wxPixelFormat wxNativePixelFormat; - - #define wxPIXEL_FORMAT_ALPHA 3 -#elif defined(__WXDFB__) - // Under DirectFB, RGB components are reversed, they're in BGR order - typedef wxPixelFormat wxNativePixelFormat; - #define wxPIXEL_FORMAT_ALPHA 3 #endif @@ -317,6 +303,9 @@ struct wxPixelDataOut // the pixel format we use typedef wxImagePixelFormat PixelFormat; + // the type of the pixel components + typedef typename dummyPixelFormat::ChannelType ChannelType; + // the pixel data we're working with typedef wxPixelDataOut::wxPixelDataIn PixelData; @@ -411,19 +400,11 @@ struct wxPixelDataOut // data access // ----------- - // access to individual colour components - PixelFormat::ChannelType& Red() { return m_pRGB[PixelFormat::RED]; } - PixelFormat::ChannelType& Green() { return m_pRGB[PixelFormat::GREEN]; } - PixelFormat::ChannelType& Blue() { return m_pRGB[PixelFormat::BLUE]; } - PixelFormat::ChannelType& Alpha() { return *m_pAlpha; } - - // address the pixel contents directly (always RGB, without alpha) - // - // this can't be used to modify the image as assigning a 32bpp - // value to 24bpp pixel would overwrite an extra byte in the next - // pixel or beyond the end of image - const typename PixelFormat::PixelType& Data() - { return *(typename PixelFormat::PixelType *)m_pRGB; } + // access to invidividual colour components + ChannelType& Red() { return m_pRGB[PixelFormat::RED]; } + ChannelType& Green() { return m_pRGB[PixelFormat::GREEN]; } + ChannelType& Blue() { return m_pRGB[PixelFormat::BLUE]; } + ChannelType& Alpha() { return *m_pAlpha; } // private: -- see comment in the beginning of the file @@ -439,7 +420,7 @@ struct wxPixelDataOut { m_width = image.GetWidth(); m_height = image.GetHeight(); - m_stride = Iterator::PixelFormat::SizePixel * m_width; + m_stride = Iterator::SizePixel * m_width; } // initializes us with the given region of the specified image @@ -447,7 +428,7 @@ struct wxPixelDataOut const wxPoint& pt, const wxSize& sz) : m_image(image), m_pixels(image) { - m_stride = Iterator::PixelFormat::SizePixel * m_width; + m_stride = Iterator::SizePixel * m_width; InitRect(pt, sz); } @@ -456,7 +437,7 @@ struct wxPixelDataOut wxPixelDataIn(ImageType& image, const wxRect& rect) : m_image(image), m_pixels(image) { - m_stride = Iterator::PixelFormat::SizePixel * m_width; + m_stride = Iterator::SizePixel * m_width; InitRect(rect.GetPosition(), rect.GetSize()); } @@ -544,7 +525,7 @@ struct wxPixelDataOut { m_ptr = NULL; } - + // return true if this iterator is valid bool IsOk() const { return m_ptr != NULL; } @@ -600,7 +581,7 @@ struct wxPixelDataOut // data access // ----------- - // access to individual colour components + // access to invidividual colour components ChannelType& Red() { return m_ptr[PixelFormat::RED]; } ChannelType& Green() { return m_ptr[PixelFormat::GREEN]; } ChannelType& Blue() { return m_ptr[PixelFormat::BLUE]; } @@ -609,10 +590,6 @@ struct wxPixelDataOut // address the pixel contents directly // // warning: the format is platform dependent - // - // warning 2: assigning to Data() only works correctly for 16bpp or - // 32bpp formats but using it for 24bpp ones overwrites - // one extra byte and so can't be done typename PixelFormat::PixelType& Data() { return *(typename PixelFormat::PixelType *)m_ptr; } @@ -654,22 +631,11 @@ struct wxPixelDataOut // dtor unlocks the bitmap ~wxPixelDataIn() { - if ( m_pixels.IsOk() ) - { -#if defined(__WXMSW__) || defined(__WXMAC__) - // this is a hack to mark wxBitmap as using alpha channel - if ( Format::HasAlpha ) - m_bmp.UseAlpha(); -#endif - m_bmp.UngetRawData(*this); - } - // else: don't call UngetRawData() if GetRawData() failed + m_bmp.UngetRawData(*this); } -#if WXWIN_COMPATIBILITY_2_8 - // not needed anymore, calls to it should be simply removed - wxDEPRECATED_INLINE( void UseAlpha(), wxEMPTY_PARAMETER_VALUE ) -#endif + // call this to indicate that we should use the alpha channel + void UseAlpha() { m_bmp.UseAlpha(); } // private: -- see comment in the beginning of the file @@ -690,21 +656,9 @@ struct wxPixelDataOut } }; }; - #endif //wxUSE_GUI -// FIXME-VC6: VC6 doesn't like typename in default template parameters while -// it is necessary with standard-conforming compilers, remove this -// #define and just use typename when we drop VC6 support -#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7) - #define wxTYPENAME_IN_TEMPLATE_DEFAULT_PARAM -#else - #define wxTYPENAME_IN_TEMPLATE_DEFAULT_PARAM typename -#endif - -template ::Format > +template > class wxPixelData : public wxPixelDataOut::template wxPixelDataIn { @@ -723,6 +677,7 @@ public: } }; + // some "predefined" pixel data classes #if wxUSE_IMAGE typedef wxPixelData wxImagePixelData; @@ -754,5 +709,5 @@ struct wxPixelIterator : public wxPixelData::Iterator { }; -#endif // wxHAS_RAW_BITMAP -#endif // _WX_RAWBMP_H_ +#endif // _WX_RAWBMP_H_BASE_ + diff --git a/Source/3rd Party/wx/include/wx/rearrangectrl.h b/Source/3rd Party/wx/include/wx/rearrangectrl.h deleted file mode 100644 index b54b04fa1..000000000 --- a/Source/3rd Party/wx/include/wx/rearrangectrl.h +++ /dev/null @@ -1,232 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/rearrangectrl.h -// Purpose: various controls for rearranging the items interactively -// Author: Vadim Zeitlin -// Created: 2008-12-15 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_REARRANGECTRL_H_ -#define _WX_REARRANGECTRL_H_ - -#include "wx/checklst.h" - -#if wxUSE_REARRANGECTRL - -#include "wx/panel.h" -#include "wx/dialog.h" - -#include "wx/arrstr.h" - -extern WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeListNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeDialogNameStr[]; - -// ---------------------------------------------------------------------------- -// wxRearrangeList: a (check) list box allowing to move items around -// ---------------------------------------------------------------------------- - -// This class works allows to change the order of the items shown in it as well -// as to check or uncheck them individually. The data structure used to allow -// this is the order array which contains the items indices indexed by their -// position with an added twist that the unchecked items are represented by the -// bitwise complement of the corresponding index (for any architecture using -// two's complement for negative numbers representation (i.e. just about any at -// all) this means that a checked item N is represented by -N-1 in unchecked -// state). -// -// So, for example, the array order [1 -3 0] used in conjunction with the items -// array ["first", "second", "third"] means that the items are displayed in the -// order "second", "third", "first" and the "third" item is unchecked while the -// other two are checked. -class WXDLLIMPEXP_CORE wxRearrangeList : public wxCheckListBox -{ -public: - // ctors and such - // -------------- - - // default ctor, call Create() later - wxRearrangeList() { } - - // ctor creating the control, the arguments are the same as for - // wxCheckListBox except for the extra order array which defines the - // (initial) display order of the items as well as their statuses, see the - // description above - wxRearrangeList(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRearrangeListNameStr) - { - Create(parent, id, pos, size, order, items, style, validator, name); - } - - // Create() function takes the same parameters as the base class one and - // the order array determining the initial display order - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRearrangeListNameStr); - - - // items order - // ----------- - - // get the current items order; the returned array uses the same convention - // as the one passed to the ctor - const wxArrayInt& GetCurrentOrder() const { return m_order; } - - // return true if the current item can be moved up or down (i.e. just that - // it's not the first or the last one) - bool CanMoveCurrentUp() const; - bool CanMoveCurrentDown() const; - - // move the current item one position up or down, return true if it was moved - // or false if the current item was the first/last one and so nothing was done - bool MoveCurrentUp(); - bool MoveCurrentDown(); - -private: - // swap two items at the given positions in the listbox - void Swap(int pos1, int pos2); - - // event handler for item checking/unchecking - void OnCheck(wxCommandEvent& event); - - - // the current order array - wxArrayInt m_order; - - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxRearrangeList); -}; - -// ---------------------------------------------------------------------------- -// wxRearrangeCtrl: composite control containing a wxRearrangeList and buttons -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxRearrangeCtrl : public wxPanel -{ -public: - // ctors/Create function are the same as for wxRearrangeList - wxRearrangeCtrl() - { - Init(); - } - - wxRearrangeCtrl(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRearrangeListNameStr) - { - Init(); - - Create(parent, id, pos, size, order, items, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRearrangeListNameStr); - - // get the underlying listbox - wxRearrangeList *GetList() const { return m_list; } - -private: - // common part of all ctors - void Init(); - - // event handlers for the buttons - void OnUpdateButtonUI(wxUpdateUIEvent& event); - void OnButton(wxCommandEvent& event); - - - wxRearrangeList *m_list; - - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxRearrangeCtrl); -}; - -// ---------------------------------------------------------------------------- -// wxRearrangeDialog: dialog containing a wxRearrangeCtrl -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxRearrangeDialog : public wxDialog -{ -public: - // default ctor, use Create() later - wxRearrangeDialog() { Init(); } - - // ctor for the dialog: message is shown inside the dialog itself, order - // and items are passed to wxRearrangeList used internally - wxRearrangeDialog(wxWindow *parent, - const wxString& message, - const wxString& title, - const wxArrayInt& order, - const wxArrayString& items, - const wxPoint& pos = wxDefaultPosition, - const wxString& name = wxRearrangeDialogNameStr) - { - Init(); - - Create(parent, message, title, order, items, pos, name); - } - - bool Create(wxWindow *parent, - const wxString& message, - const wxString& title, - const wxArrayInt& order, - const wxArrayString& items, - const wxPoint& pos = wxDefaultPosition, - const wxString& name = wxRearrangeDialogNameStr); - - - // methods for the dialog customization - - // add extra contents to the dialog below the wxRearrangeCtrl part: the - // given window (usually a wxPanel containing more control inside it) must - // have the dialog as its parent and will be inserted into it at the right - // place by this method - void AddExtraControls(wxWindow *win); - - // return the wxRearrangeList control used by the dialog - wxRearrangeList *GetList() const; - - - // get the order of items after it was modified by the user - wxArrayInt GetOrder() const; - -private: - // common part of all ctors - void Init() { m_ctrl = NULL; } - - wxRearrangeCtrl *m_ctrl; - - wxDECLARE_NO_COPY_CLASS(wxRearrangeDialog); -}; - -#endif // wxUSE_REARRANGECTRL - -#endif // _WX_REARRANGECTRL_H_ - diff --git a/Source/3rd Party/wx/include/wx/recguard.h b/Source/3rd Party/wx/include/wx/recguard.h index 13208bc23..045c27b26 100644 --- a/Source/3rd Party/wx/include/wx/recguard.h +++ b/Source/3rd Party/wx/include/wx/recguard.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 14.08.2003 +// RCS-ID: $Id: recguard.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/include/wx/regex.h b/Source/3rd Party/wx/include/wx/regex.h index c761e980c..87f319126 100644 --- a/Source/3rd Party/wx/include/wx/regex.h +++ b/Source/3rd Party/wx/include/wx/regex.h @@ -4,6 +4,7 @@ // Author: Karsten Ballueder // Modified by: VZ at 13.07.01 (integrated to wxWin) // Created: 05.02.2000 +// RCS-ID: $Id: regex.h 57779 2009-01-02 17:35:16Z PC $ // Copyright: (c) 2000 Karsten Ballueder // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -96,9 +97,10 @@ public: // len may be the length of text (ignored by most system regex libs) // // may only be called after successful call to Compile() - bool Matches(const wxString& text, int flags = 0) const; - bool Matches(const wxChar *text, int flags, size_t len) const - { return Matches(wxString(text, len), flags); } + bool Matches(const wxChar *text, int flags = 0) const; + bool Matches(const wxChar *text, int flags, size_t len) const; + bool Matches(const wxString& text, int flags = 0) const + { return Matches(text.c_str(), flags, text.length()); } // get the start index and the length of the match of the expression // (index 0) or a bracketed subexpression (index != 0) @@ -129,16 +131,16 @@ public: // pattern match // // maxMatches may be used to limit the number of replacements made, setting - // it to 1, for example, will only replace first occurrence (if any) of the + // it to 1, for example, will only replace first occurence (if any) of the // pattern in the text while default value of 0 means replace all int Replace(wxString *text, const wxString& replacement, size_t maxMatches = 0) const; - // replace the first occurrence + // replace the first occurence int ReplaceFirst(wxString *text, const wxString& replacement) const { return Replace(text, replacement, 1); } - // replace all occurrences: this is actually a synonym for Replace() + // replace all occurences: this is actually a synonym for Replace() int ReplaceAll(wxString *text, const wxString& replacement) const { return Replace(text, replacement, 0); } diff --git a/Source/3rd Party/wx/include/wx/region.h b/Source/3rd Party/wx/include/wx/region.h index cdebe0401..2bbaed5e0 100644 --- a/Source/3rd Party/wx/include/wx/region.h +++ b/Source/3rd Party/wx/include/wx/region.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: region.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ enum wxRegionOp // wxRegionBase defines wxRegion API // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRegionBase : public wxGDIObject +class WXDLLEXPORT wxRegionBase : public wxGDIObject { public: // ctors @@ -66,7 +67,7 @@ public: wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxRect& rect); - wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); + wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE); wxRegion(const wxBitmap& bmp); wxRegion(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0); #endif // 0 @@ -81,6 +82,9 @@ public: // accessors // --------- + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_refData != NULL; } + // Is region empty? virtual bool IsEmpty() const = 0; bool Empty() const { return IsEmpty(); } @@ -180,13 +184,14 @@ protected: // some ports implement a generic Combine() function while others only // implement individual wxRegion operations, factor out the common code for the // ports with Combine() in this class -#if defined(__WXMSW__) || \ - ( defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON ) || \ +#if defined(__WXPALMOS__) || \ + defined(__WXMSW__) || \ + defined(__WXMAC__) || \ defined(__WXPM__) #define wxHAS_REGION_COMBINE -class WXDLLIMPEXP_CORE wxRegionWithCombine : public wxRegionBase +class WXDLLEXPORT wxRegionWithCombine : public wxRegionBase { public: // these methods are not part of public API as they're not implemented on @@ -211,7 +216,9 @@ protected: #endif // ports with wxRegion::Combine() -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/palmos/region.h" +#elif defined(__WXMSW__) #include "wx/msw/region.h" #elif defined(__WXGTK20__) #include "wx/gtk/region.h" @@ -219,10 +226,12 @@ protected: #include "wx/gtk1/region.h" #elif defined(__WXMOTIF__) || defined(__WXX11__) #include "wx/x11/region.h" +#elif defined(__WXMGL__) + #include "wx/mgl/region.h" #elif defined(__WXDFB__) #include "wx/dfb/region.h" #elif defined(__WXMAC__) - #include "wx/osx/region.h" + #include "wx/mac/region.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/region.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/renderer.h b/Source/3rd Party/wx/include/wx/renderer.h index aef076d0b..b28ec8531 100644 --- a/Source/3rd Party/wx/include/wx/renderer.h +++ b/Source/3rd Party/wx/include/wx/renderer.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.07.2003 +// RCS-ID: $Id: renderer.h 53667 2008-05-20 09:28:48Z VS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -27,24 +28,19 @@ class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxWindow; -#include "wx/gdicmn.h" // for wxPoint, wxSize +#include "wx/gdicmn.h" // for wxPoint #include "wx/colour.h" #include "wx/font.h" #include "wx/bitmap.h" #include "wx/string.h" // some platforms have their own renderers, others use the generic one -#if defined(__WXMSW__) || ( defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON ) || defined(__WXGTK__) +#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK__) #define wxHAS_NATIVE_RENDERER #else #undef wxHAS_NATIVE_RENDERER #endif -// only MSW and OS X currently provides DrawTitleBarBitmap() method -#if defined(__WXMSW__) || (defined(__WXMAC__) && wxUSE_LIBPNG && wxUSE_IMAGE) - #define wxHAS_DRAW_TITLE_BAR_BITMAP -#endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -60,7 +56,6 @@ enum wxCONTROL_ISSUBMENU = wxCONTROL_SPECIAL, // only for the menu items wxCONTROL_EXPANDED = wxCONTROL_SPECIAL, // only for the tree items wxCONTROL_SIZEGRIP = wxCONTROL_SPECIAL, // only for the status bar panes - wxCONTROL_FLAT = wxCONTROL_SPECIAL, // checkboxes only: flat border wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked @@ -74,25 +69,12 @@ enum wxCONTROL_DIRTY = 0x80000000 }; -// title bar buttons supported by DrawTitleBarBitmap() -// -// NB: they have the same values as wxTOPLEVEL_BUTTON_XXX constants in -// wx/univ/toplevel.h as they really represent the same things -enum wxTitleBarButton -{ - wxTITLEBAR_BUTTON_CLOSE = 0x01000000, - wxTITLEBAR_BUTTON_MAXIMIZE = 0x02000000, - wxTITLEBAR_BUTTON_ICONIZE = 0x04000000, - wxTITLEBAR_BUTTON_RESTORE = 0x08000000, - wxTITLEBAR_BUTTON_HELP = 0x10000000 -}; - // ---------------------------------------------------------------------------- // helper structs // ---------------------------------------------------------------------------- // wxSplitterWindow parameters -struct WXDLLIMPEXP_CORE wxSplitterRenderParams +struct WXDLLEXPORT wxSplitterRenderParams { // the only way to initialize this struct is by using this ctor wxSplitterRenderParams(wxCoord widthSash_, wxCoord border_, bool isSens_) @@ -112,7 +94,7 @@ struct WXDLLIMPEXP_CORE wxSplitterRenderParams // extra optional parameters for DrawHeaderButton -struct WXDLLIMPEXP_CORE wxHeaderButtonParams +struct WXDLLEXPORT wxHeaderButtonParams { wxHeaderButtonParams() : m_labelAlignment(wxALIGN_LEFT) @@ -127,16 +109,15 @@ struct WXDLLIMPEXP_CORE wxHeaderButtonParams int m_labelAlignment; }; -enum wxHeaderSortIconType -{ +enum wxHeaderSortIconType { wxHDR_SORT_ICON_NONE, // Header button has no sort arrow - wxHDR_SORT_ICON_UP, // Header button an up sort arrow icon - wxHDR_SORT_ICON_DOWN // Header button a down sort arrow icon + wxHDR_SORT_ICON_UP, // Header button an an up sort arrow icon + wxHDR_SORT_ICON_DOWN // Header button an a down sort arrow icon }; // wxRendererNative interface version -struct WXDLLIMPEXP_CORE wxRendererVersion +struct WXDLLEXPORT wxRendererVersion { wxRendererVersion(int version_, int age_) : version(version_), age(age_) { } @@ -170,7 +151,7 @@ struct WXDLLIMPEXP_CORE wxRendererVersion // wxRendererNative: abstracts drawing methods needed by the native controls // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxRendererNative +class WXDLLEXPORT wxRendererNative { public: // drawing functions @@ -199,9 +180,6 @@ public: // height if available, or a generic height based on the window's font. virtual int GetHeaderButtonHeight(wxWindow *win) = 0; - // Returns the margin on left and right sides of header button's label - virtual int GetHeaderButtonMargin(wxWindow *win) = 0; - // draw the expanded/collapsed icon for a tree control item virtual void DrawTreeItemButton(wxWindow *win, @@ -248,9 +226,6 @@ public: const wxRect& rect, int flags = 0) = 0; - // Returns the default size of a check box. - virtual wxSize GetCheckBoxSize(wxWindow *win) = 0; - // draw blank button // // flags may use wxCONTROL_PRESSED, wxCONTROL_CURRENT and wxCONTROL_ISDEFAULT @@ -271,56 +246,6 @@ public: const wxRect& rect, int flags = 0) = 0; - // draw the focus rectangle around the label contained in the given rect - // - // only wxCONTROL_SELECTED makes sense in flags here - virtual void DrawFocusRect(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; - - // Draw a native wxChoice - virtual void DrawChoice(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; - - // Draw a native wxComboBox - virtual void DrawComboBox(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; - - // Draw a native wxTextCtrl frame - virtual void DrawTextCtrl(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; - - // Draw a native wxRadioButton bitmap - virtual void DrawRadioBitmap(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - // Draw one of the standard title bar buttons - // - // This is currently implemented only for MSW and OS X (for the close - // button only) because there is no way to render standard title bar - // buttons under the other platforms, the best can be done is to use normal - // (only) images which wxArtProvider provides for wxART_HELP and - // wxART_CLOSE (but not any other title bar buttons) - // - // NB: make sure PNG handler is enabled if using this function under OS X - virtual void DrawTitleBarBitmap(wxWindow *win, - wxDC& dc, - const wxRect& rect, - wxTitleBarButton button, - int flags = 0) = 0; -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - - // geometry functions // ------------------ @@ -374,7 +299,7 @@ public: // wxDelegateRendererNative: allows reuse of renderers code // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDelegateRendererNative : public wxRendererNative +class WXDLLEXPORT wxDelegateRendererNative : public wxRendererNative { public: wxDelegateRendererNative() @@ -403,9 +328,6 @@ public: virtual int GetHeaderButtonHeight(wxWindow *win) { return m_rendererNative.GetHeaderButtonHeight(win); } - virtual int GetHeaderButtonMargin(wxWindow *win) - { return m_rendererNative.GetHeaderButtonMargin(win); } - virtual void DrawTreeItemButton(wxWindow *win, wxDC& dc, const wxRect& rect, @@ -442,63 +364,21 @@ public: virtual void DrawCheckBox(wxWindow *win, wxDC& dc, const wxRect& rect, - int flags = 0) + int flags = 0 ) { m_rendererNative.DrawCheckBox( win, dc, rect, flags ); } - virtual wxSize GetCheckBoxSize(wxWindow *win) - { return m_rendererNative.GetCheckBoxSize(win); } - virtual void DrawPushButton(wxWindow *win, wxDC& dc, const wxRect& rect, - int flags = 0) + int flags = 0 ) { m_rendererNative.DrawPushButton( win, dc, rect, flags ); } virtual void DrawItemSelectionRect(wxWindow *win, wxDC& dc, const wxRect& rect, - int flags = 0) + int flags = 0 ) { m_rendererNative.DrawItemSelectionRect( win, dc, rect, flags ); } - virtual void DrawFocusRect(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) - { m_rendererNative.DrawFocusRect( win, dc, rect, flags ); } - - virtual void DrawChoice(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) - { m_rendererNative.DrawChoice( win, dc, rect, flags); } - - virtual void DrawComboBox(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) - { m_rendererNative.DrawComboBox( win, dc, rect, flags); } - - virtual void DrawTextCtrl(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) - { m_rendererNative.DrawTextCtrl( win, dc, rect, flags); } - - virtual void DrawRadioBitmap(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) - { m_rendererNative.DrawRadioBitmap(win, dc, rect, flags); } - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - virtual void DrawTitleBarBitmap(wxWindow *win, - wxDC& dc, - const wxRect& rect, - wxTitleBarButton button, - int flags = 0) - { m_rendererNative.DrawTitleBarBitmap(win, dc, rect, button, flags); } -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win) { return m_rendererNative.GetSplitterParams(win); } @@ -508,7 +388,7 @@ public: protected: wxRendererNative& m_rendererNative; - wxDECLARE_NO_COPY_CLASS(wxDelegateRendererNative); + DECLARE_NO_COPY_CLASS(wxDelegateRendererNative) }; // ---------------------------------------------------------------------------- @@ -526,4 +406,31 @@ wxRendererNative& wxRendererNative::GetDefault() #endif // !wxHAS_NATIVE_RENDERER + +// ---------------------------------------------------------------------------- +// Other renderer functions to be merged in to wxRenderer class in 2.9, but +// they are standalone functions here to protect the ABI. +// ---------------------------------------------------------------------------- + +#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__) +#if wxABI_VERSION >= 20808 + +// Draw a native wxChoice +void WXDLLEXPORT wxRenderer_DrawChoice(wxWindow* win, wxDC& dc, + const wxRect& rect, int flags=0); + +// Draw a native wxComboBox +void WXDLLEXPORT wxRenderer_DrawComboBox(wxWindow* win, wxDC& dc, + const wxRect& rect, int flags=0); + +// Draw a native wxTextCtrl frame +void WXDLLEXPORT wxRenderer_DrawTextCtrl(wxWindow* win, wxDC& dc, + const wxRect& rect, int flags=0); + +// Draw a native wxRadioButton (just the graphical portion) +void WXDLLEXPORT wxRenderer_DrawRadioButton(wxWindow* win, wxDC& dc, + const wxRect& rect, int flags=0); +#endif // wxABI_VERSION +#endif // (platforms) + #endif // _WX_RENDERER_H_ diff --git a/Source/3rd Party/wx/include/wx/richmsgdlg.h b/Source/3rd Party/wx/include/wx/richmsgdlg.h deleted file mode 100644 index ab49af7d0..000000000 --- a/Source/3rd Party/wx/include/wx/richmsgdlg.h +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/richmsgdlg.h -// Purpose: wxRichMessageDialogBase -// Author: Rickard Westerlund -// Created: 2010-07-03 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_RICHMSGDLG_H_BASE_ -#define _WX_RICHMSGDLG_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_RICHMSGDLG - -#include "wx/msgdlg.h" - -// Extends a message dialog with an optional checkbox and user-expandable -// detailed text. -class WXDLLIMPEXP_CORE wxRichMessageDialogBase : public wxGenericMessageDialog -{ -public: - wxRichMessageDialogBase( wxWindow *parent, - const wxString& message, - const wxString& caption, - long style ) - : wxGenericMessageDialog( parent, message, caption, style ), - m_detailsExpanderCollapsedLabel( wxGetTranslation("&See details") ), - m_detailsExpanderExpandedLabel( wxGetTranslation("&Hide details") ), - m_checkBoxValue( false ) - { } - - void ShowCheckBox(const wxString& checkBoxText, bool checked = false) - { - m_checkBoxText = checkBoxText; - m_checkBoxValue = checked; - } - - wxString GetCheckBoxText() const { return m_checkBoxText; } - - void ShowDetailedText(const wxString& detailedText) - { m_detailedText = detailedText; } - - wxString GetDetailedText() const { return m_detailedText; } - - virtual bool IsCheckBoxChecked() const { return m_checkBoxValue; } - -protected: - const wxString m_detailsExpanderCollapsedLabel; - const wxString m_detailsExpanderExpandedLabel; - - wxString m_checkBoxText; - bool m_checkBoxValue; - wxString m_detailedText; - -private: - void ShowDetails(bool shown); - - wxDECLARE_NO_COPY_CLASS(wxRichMessageDialogBase); -}; - -// Always include the generic version as it's currently used as the base class -// by the MSW native implementation too. -#include "wx/generic/richmsgdlgg.h" - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/richmsgdlg.h" -#else - class WXDLLIMPEXP_CORE wxRichMessageDialog - : public wxGenericRichMessageDialog - { - public: - wxRichMessageDialog( wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK | wxCENTRE ) - : wxGenericRichMessageDialog( parent, message, caption, style ) - { } - - private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxRichMessageDialog); - }; -#endif - -#endif // wxUSE_RICHMSGDLG - -#endif // _WX_RICHMSGDLG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/richtooltip.h b/Source/3rd Party/wx/include/wx/richtooltip.h deleted file mode 100644 index 1187e67ed..000000000 --- a/Source/3rd Party/wx/include/wx/richtooltip.h +++ /dev/null @@ -1,103 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/richtooltip.h -// Purpose: Declaration of wxRichToolTip class. -// Author: Vadim Zeitlin -// Created: 2011-10-07 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_RICHTOOLTIP_H_ -#define _WX_RICHTOOLTIP_H_ - -#include "wx/defs.h" - -#if wxUSE_RICHTOOLTIP - -#include "wx/colour.h" - -class WXDLLIMPEXP_FWD_CORE wxFont; -class WXDLLIMPEXP_FWD_CORE wxIcon; -class WXDLLIMPEXP_FWD_CORE wxWindow; - -class wxRichToolTipImpl; - -// This enum describes the kind of the tip shown which combines both the tip -// position and appearance because the two are related (when the tip is -// positioned asymmetrically, a right handed triangle is used but an -// equilateral one when it's in the middle of a side). -// -// Automatic selects the tip appearance best suited for the current platform -// and the position best suited for the window the tooltip is shown for, i.e. -// chosen in such a way that the tooltip is always fully on screen. -// -// Other values describe the position of the tooltip itself, not the window it -// relates to. E.g. wxTipKind_Top places the tip on the top of the tooltip and -// so the tooltip itself is located beneath its associated window. -enum wxTipKind -{ - wxTipKind_None, - wxTipKind_TopLeft, - wxTipKind_Top, - wxTipKind_TopRight, - wxTipKind_BottomLeft, - wxTipKind_Bottom, - wxTipKind_BottomRight, - wxTipKind_Auto -}; - -// ---------------------------------------------------------------------------- -// wxRichToolTip: a customizable but not necessarily native tooltip. -// ---------------------------------------------------------------------------- - -// Notice that this class does not inherit from wxWindow. -class WXDLLIMPEXP_ADV wxRichToolTip -{ -public: - // Ctor must specify the tooltip title and main message, additional - // attributes can be set later. - wxRichToolTip(const wxString& title, const wxString& message); - - // Set the background colour: if two colours are specified, the background - // is drawn using a gradient from top to bottom, otherwise a single solid - // colour is used. - void SetBackgroundColour(const wxColour& col, - const wxColour& colEnd = wxColour()); - - // Set the small icon to show: either one of the standard information/ - // warning/error ones (the question icon doesn't make sense for a tooltip) - // or a custom icon. - void SetIcon(int icon = wxICON_INFORMATION); - void SetIcon(const wxIcon& icon); - - // Set timeout after which the tooltip should disappear, in milliseconds. - // By default the tooltip is hidden after system-dependent interval of time - // elapses but this method can be used to change this or also disable - // hiding the tooltip automatically entirely by passing 0 in this parameter - // (but doing this can result in native version not being used). - // Optionally specify a show delay. - void SetTimeout(unsigned milliseconds, unsigned millisecondsShowdelay = 0); - - // Choose the tip kind, possibly none. By default the tip is positioned - // automatically, as if wxTipKind_Auto was used. - void SetTipKind(wxTipKind tipKind); - - // Set the title text font. By default it's emphasized using the font style - // or colour appropriate for the current platform. - void SetTitleFont(const wxFont& font); - - // Show the tooltip for the given window and optionally a specified area. - void ShowFor(wxWindow* win, const wxRect* rect = NULL); - - // Non-virtual dtor as this class is not supposed to be derived from. - ~wxRichToolTip(); - -private: - wxRichToolTipImpl* const m_impl; - - wxDECLARE_NO_COPY_CLASS(wxRichToolTip); -}; - -#endif // wxUSE_RICHTOOLTIP - -#endif // _WX_RICHTOOLTIP_H_ diff --git a/Source/3rd Party/wx/include/wx/rtti.h b/Source/3rd Party/wx/include/wx/rtti.h deleted file mode 100644 index 51017baa2..000000000 --- a/Source/3rd Party/wx/include/wx/rtti.h +++ /dev/null @@ -1,319 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/rtti.h -// Purpose: old RTTI macros (use XTI when possible instead) -// Author: Julian Smart -// Modified by: Ron Lee -// Created: 01/02/97 -// Copyright: (c) 1997 Julian Smart -// (c) 2001 Ron Lee -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_RTTIH__ -#define _WX_RTTIH__ - -#if !wxUSE_EXTENDED_RTTI // XTI system is meant to replace these macros - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/memory.h" - -// ---------------------------------------------------------------------------- -// forward declarations -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_BASE wxObject; -class WXDLLIMPEXP_FWD_BASE wxString; -class WXDLLIMPEXP_FWD_BASE wxClassInfo; -class WXDLLIMPEXP_FWD_BASE wxHashTable; -class WXDLLIMPEXP_FWD_BASE wxObject; -class WXDLLIMPEXP_FWD_BASE wxPluginLibrary; -class WXDLLIMPEXP_FWD_BASE wxHashTable_Node; - -// ---------------------------------------------------------------------------- -// wxClassInfo -// ---------------------------------------------------------------------------- - -typedef wxObject *(*wxObjectConstructorFn)(void); - -class WXDLLIMPEXP_BASE wxClassInfo -{ - friend class WXDLLIMPEXP_FWD_BASE wxObject; - friend WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); -public: - wxClassInfo( const wxChar *className, - const wxClassInfo *baseInfo1, - const wxClassInfo *baseInfo2, - int size, - wxObjectConstructorFn ctor ) - : m_className(className) - , m_objectSize(size) - , m_objectConstructor(ctor) - , m_baseInfo1(baseInfo1) - , m_baseInfo2(baseInfo2) - , m_next(sm_first) - { - sm_first = this; - Register(); - } - - ~wxClassInfo(); - - wxObject *CreateObject() const - { return m_objectConstructor ? (*m_objectConstructor)() : 0; } - bool IsDynamic() const { return (NULL != m_objectConstructor); } - - const wxChar *GetClassName() const { return m_className; } - const wxChar *GetBaseClassName1() const - { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; } - const wxChar *GetBaseClassName2() const - { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; } - const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; } - const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; } - int GetSize() const { return m_objectSize; } - - wxObjectConstructorFn GetConstructor() const - { return m_objectConstructor; } - static const wxClassInfo *GetFirst() { return sm_first; } - const wxClassInfo *GetNext() const { return m_next; } - static wxClassInfo *FindClass(const wxString& className); - - // Climb upwards through inheritance hierarchy. - // Dual inheritance is catered for. - - bool IsKindOf(const wxClassInfo *info) const - { - return info != 0 && - ( info == this || - ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) || - ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) ); - } - - wxDECLARE_CLASS_INFO_ITERATORS(); - -private: - const wxChar *m_className; - int m_objectSize; - wxObjectConstructorFn m_objectConstructor; - - // Pointers to base wxClassInfos - - const wxClassInfo *m_baseInfo1; - const wxClassInfo *m_baseInfo2; - - // class info object live in a linked list: - // pointers to its head and the next element in it - - static wxClassInfo *sm_first; - wxClassInfo *m_next; - - static wxHashTable *sm_classTable; - -protected: - // registers the class - void Register(); - void Unregister(); - - wxDECLARE_NO_COPY_CLASS(wxClassInfo); -}; - -WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); - -// ---------------------------------------------------------------------------- -// Dynamic class macros -// ---------------------------------------------------------------------------- - -#define wxDECLARE_ABSTRACT_CLASS(name) \ - public: \ - static wxClassInfo ms_classInfo; \ - virtual wxClassInfo *GetClassInfo() const - -#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ - wxDECLARE_NO_ASSIGN_CLASS(name); \ - wxDECLARE_DYNAMIC_CLASS(name) - -#define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \ - wxDECLARE_NO_COPY_CLASS(name); \ - wxDECLARE_DYNAMIC_CLASS(name) - -#define wxDECLARE_DYNAMIC_CLASS(name) \ - wxDECLARE_ABSTRACT_CLASS(name); \ - static wxObject* wxCreateObject() - -#define wxDECLARE_CLASS(name) \ - wxDECLARE_ABSTRACT_CLASS(name) - - -// common part of the macros below -#define wxIMPLEMENT_CLASS_COMMON(name, basename, baseclsinfo2, func) \ - wxClassInfo name::ms_classInfo(wxT(#name), \ - &basename::ms_classInfo, \ - baseclsinfo2, \ - (int) sizeof(name), \ - func); \ - \ - wxClassInfo *name::GetClassInfo() const \ - { return &name::ms_classInfo; } - -#define wxIMPLEMENT_CLASS_COMMON1(name, basename, func) \ - wxIMPLEMENT_CLASS_COMMON(name, basename, NULL, func) - -#define wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, func) \ - wxIMPLEMENT_CLASS_COMMON(name, basename1, &basename2::ms_classInfo, func) - -// ----------------------------------- -// for concrete classes -// ----------------------------------- - - // Single inheritance with one base class -#define wxIMPLEMENT_DYNAMIC_CLASS(name, basename) \ - wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject) \ - wxObject* name::wxCreateObject() \ - { return new name; } - - // Multiple inheritance with two base classes -#define wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, \ - name::wxCreateObject) \ - wxObject* name::wxCreateObject() \ - { return new name; } - -// ----------------------------------- -// for abstract classes -// ----------------------------------- - - // Single inheritance with one base class -#define wxIMPLEMENT_ABSTRACT_CLASS(name, basename) \ - wxIMPLEMENT_CLASS_COMMON1(name, basename, NULL) - - // Multiple inheritance with two base classes -#define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ - wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, NULL) - -// ----------------------------------- -// XTI-compatible macros -// ----------------------------------- - -#include "wx/flags.h" - -// these macros only do something when wxUSE_EXTENDED_RTTI=1 -// (and in that case they are defined by xti.h); however to avoid -// to be forced to wrap these macros (in user's source files) with -// -// #if wxUSE_EXTENDED_RTTI -// ... -// #endif -// -// blocks, we define them here as empty. - -#define wxEMPTY_PARAMETER_VALUE /**/ - -#define wxBEGIN_ENUM( e ) wxEMPTY_PARAMETER_VALUE -#define wxENUM_MEMBER( v ) wxEMPTY_PARAMETER_VALUE -#define wxEND_ENUM( e ) wxEMPTY_PARAMETER_VALUE - -#define wxIMPLEMENT_SET_STREAMING(SetName,e) wxEMPTY_PARAMETER_VALUE - -#define wxBEGIN_FLAGS( e ) wxEMPTY_PARAMETER_VALUE -#define wxFLAGS_MEMBER( v ) wxEMPTY_PARAMETER_VALUE -#define wxEND_FLAGS( e ) wxEMPTY_PARAMETER_VALUE - -#define wxCOLLECTION_TYPE_INFO( element, collection ) wxEMPTY_PARAMETER_VALUE - -#define wxHANDLER(name,eventClassType) wxEMPTY_PARAMETER_VALUE -#define wxBEGIN_HANDLERS_TABLE(theClass) wxEMPTY_PARAMETER_VALUE -#define wxEND_HANDLERS_TABLE() wxEMPTY_PARAMETER_VALUE - -#define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \ - wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) -#define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback ) \ - wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) - -#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \ - wxIMPLEMENT_DYNAMIC_CLASS( name, basename) - -#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \ - unit, toString, \ - fromString ) wxEMPTY_PARAMETER_VALUE -#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) wxEMPTY_PARAMETER_VALUE -#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) wxEMPTY_PARAMETER_VALUE - -#define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2 ) - -#define wxCONSTRUCTOR_0(klass) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_DUMMY(klass) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_0(klass) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_1(klass,t0,v0) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ - wxEMPTY_PARAMETER_VALUE -#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ - wxEMPTY_PARAMETER_VALUE -#define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ - wxEMPTY_PARAMETER_VALUE - -#define wxSETTER( property, Klass, valueType, setterMethod ) wxEMPTY_PARAMETER_VALUE -#define wxGETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE -#define wxADDER( property, Klass, valueType, addermethod ) wxEMPTY_PARAMETER_VALUE -#define wxCOLLECTION_GETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE - -#define wxBEGIN_PROPERTIES_TABLE(theClass) wxEMPTY_PARAMETER_VALUE -#define wxEND_PROPERTIES_TABLE() wxEMPTY_PARAMETER_VALUE -#define wxHIDE_PROPERTY( pname ) wxEMPTY_PARAMETER_VALUE - -#define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \ - wxEMPTY_PARAMETER_VALUE - -#define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \ - pflags, help, group) wxEMPTY_PARAMETER_VALUE - -#define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \ - wxGETTER( pname, class_t, type, getter ) wxEMPTY_PARAMETER_VALUE - -#define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \ - pflags, help, group) wxEMPTY_PARAMETER_VALUE - -#define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \ - flags, help, group ) wxEMPTY_PARAMETER_VALUE - -#define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \ - flags, help, group) wxEMPTY_PARAMETER_VALUE -#define wxEVENT_PROPERTY( name, eventType, eventClass ) wxEMPTY_PARAMETER_VALUE - -#define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) wxEMPTY_PARAMETER_VALUE - -#define wxIMPLEMENT_PROPERTY(name, type) wxEMPTY_PARAMETER_VALUE - -#define wxEMPTY_HANDLERS_TABLE(name) wxEMPTY_PARAMETER_VALUE - -#endif // !wxUSE_EXTENDED_RTTI -#endif // _WX_RTTIH__ diff --git a/Source/3rd Party/wx/include/wx/sashwin.h b/Source/3rd Party/wx/include/wx/sashwin.h deleted file mode 100644 index 21967a5c7..000000000 --- a/Source/3rd Party/wx/include/wx/sashwin.h +++ /dev/null @@ -1,17 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sashwin.h -// Purpose: Base header for wxSashWindow -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SASHWIN_H_BASE_ -#define _WX_SASHWIN_H_BASE_ - -#include "wx/generic/sashwin.h" - -#endif - // _WX_SASHWIN_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/sckaddr.h b/Source/3rd Party/wx/include/wx/sckaddr.h deleted file mode 100644 index 4ceefdf35..000000000 --- a/Source/3rd Party/wx/include/wx/sckaddr.h +++ /dev/null @@ -1,222 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sckaddr.h -// Purpose: Network address classes -// Author: Guilhem Lavaux -// Modified by: Vadim Zeitlin to switch to wxSockAddressImpl implementation -// Created: 26/04/1997 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// (c) 2008, 2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SCKADDR_H_ -#define _WX_SCKADDR_H_ - -#include "wx/defs.h" - -#if wxUSE_SOCKETS - -#include "wx/string.h" - -class wxSockAddressImpl; - -// forward declare it instead of including the system headers defining it which -// can bring in under Windows which we don't want to include from -// public wx headers -struct sockaddr; - -// Any socket address kind -class WXDLLIMPEXP_NET wxSockAddress : public wxObject -{ -public: - enum Family - { - NONE, - IPV4, - IPV6, - UNIX - }; - - wxSockAddress(); - wxSockAddress(const wxSockAddress& other); - virtual ~wxSockAddress(); - - wxSockAddress& operator=(const wxSockAddress& other); - - virtual void Clear(); - virtual Family Type() = 0; - - // accessors for the low level address represented by this object - const sockaddr *GetAddressData() const; - int GetAddressDataLen() const; - - // we need to be able to create copies of the addresses polymorphically - // (i.e. without knowing the exact address class) - virtual wxSockAddress *Clone() const = 0; - - - // implementation only, don't use - const wxSockAddressImpl& GetAddress() const { return *m_impl; } - void SetAddress(const wxSockAddressImpl& address); - -protected: - wxSockAddressImpl *m_impl; - -private: - void Init(); - DECLARE_ABSTRACT_CLASS(wxSockAddress) -}; - -// An IP address (either IPv4 or IPv6) -class WXDLLIMPEXP_NET wxIPaddress : public wxSockAddress -{ -public: - wxIPaddress() : wxSockAddress() { } - wxIPaddress(const wxIPaddress& other) - : wxSockAddress(other), - m_origHostname(other.m_origHostname) - { - } - - bool operator==(const wxIPaddress& addr) const; - - bool Hostname(const wxString& name); - bool Service(const wxString& name); - bool Service(unsigned short port); - - bool LocalHost(); - virtual bool IsLocalHost() const = 0; - - bool AnyAddress(); - - virtual wxString IPAddress() const = 0; - - wxString Hostname() const; - unsigned short Service() const; - - wxString OrigHostname() const { return m_origHostname; } - -protected: - // get m_impl initialized to the right family if it hadn't been done yet - wxSockAddressImpl& GetImpl(); - const wxSockAddressImpl& GetImpl() const - { - return const_cast(this)->GetImpl(); - } - - // host name originally passed to Hostname() - wxString m_origHostname; - -private: - // create the wxSockAddressImpl object of the correct family if it's - // currently uninitialized - virtual void DoInitImpl() = 0; - - - DECLARE_ABSTRACT_CLASS(wxIPaddress) -}; - -// An IPv4 address -class WXDLLIMPEXP_NET wxIPV4address : public wxIPaddress -{ -public: - wxIPV4address() : wxIPaddress() { } - wxIPV4address(const wxIPV4address& other) : wxIPaddress(other) { } - - // implement wxSockAddress pure virtuals: - virtual Family Type() { return IPV4; } - virtual wxSockAddress *Clone() const { return new wxIPV4address(*this); } - - - // implement wxIPaddress pure virtuals: - virtual bool IsLocalHost() const; - - virtual wxString IPAddress() const; - - - // IPv4-specific methods: - bool Hostname(unsigned long addr); - - // make base class methods hidden by our overload visible - // - // FIXME-VC6: replace this with "using IPAddress::Hostname" (not supported - // by VC6) when support for it is dropped - wxString Hostname() const { return wxIPaddress::Hostname(); } - bool Hostname(const wxString& name) { return wxIPaddress::Hostname(name); } - - bool BroadcastAddress(); - -private: - virtual void DoInitImpl(); - - DECLARE_DYNAMIC_CLASS(wxIPV4address) -}; - - -#if wxUSE_IPV6 - -// An IPv6 address -class WXDLLIMPEXP_NET wxIPV6address : public wxIPaddress -{ -public: - wxIPV6address() : wxIPaddress() { } - wxIPV6address(const wxIPV6address& other) : wxIPaddress(other) { } - - // implement wxSockAddress pure virtuals: - virtual Family Type() { return IPV6; } - virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); } - - - // implement wxIPaddress pure virtuals: - virtual bool IsLocalHost() const; - - virtual wxString IPAddress() const; - - // IPv6-specific methods: - bool Hostname(unsigned char addr[16]); - - using wxIPaddress::Hostname; - -private: - virtual void DoInitImpl(); - - DECLARE_DYNAMIC_CLASS(wxIPV6address) -}; - -#endif // wxUSE_IPV6 - -// Unix domain sockets are only available under, well, Unix -#if defined(__UNIX__) && !defined(__WINDOWS__) && !defined(__WINE__) - #define wxHAS_UNIX_DOMAIN_SOCKETS -#endif - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - -// A Unix domain socket address -class WXDLLIMPEXP_NET wxUNIXaddress : public wxSockAddress -{ -public: - wxUNIXaddress() : wxSockAddress() { } - wxUNIXaddress(const wxUNIXaddress& other) : wxSockAddress(other) { } - - void Filename(const wxString& name); - wxString Filename() const; - - virtual Family Type() { return UNIX; } - virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); } - -private: - wxSockAddressImpl& GetUNIX(); - const wxSockAddressImpl& GetUNIX() const - { - return const_cast(this)->GetUNIX(); - } - - DECLARE_DYNAMIC_CLASS(wxUNIXaddress) -}; - -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - -#endif // wxUSE_SOCKETS - -#endif // _WX_SCKADDR_H_ diff --git a/Source/3rd Party/wx/include/wx/sckipc.h b/Source/3rd Party/wx/include/wx/sckipc.h deleted file mode 100644 index 3801da8cf..000000000 --- a/Source/3rd Party/wx/include/wx/sckipc.h +++ /dev/null @@ -1,159 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sckipc.h -// Purpose: Interprocess communication implementation (wxSocket version) -// Author: Julian Smart -// Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998 -// Guillermo Rodriguez (updated for wxSocket v2) Jan 2000 -// (callbacks deprecated) Mar 2000 -// Created: 1993 -// Copyright: (c) Julian Smart 1993 -// (c) Guilhem Lavaux 1997, 1998 -// (c) 2000 Guillermo Rodriguez -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SCKIPC_H -#define _WX_SCKIPC_H - -#include "wx/defs.h" - -#if wxUSE_SOCKETS && wxUSE_IPC - -#include "wx/ipcbase.h" -#include "wx/socket.h" -#include "wx/sckstrm.h" -#include "wx/datstrm.h" - -/* - * Mini-DDE implementation - - Most transactions involve a topic name and an item name (choose these - as befits your application). - - A client can: - - - ask the server to execute commands (data) associated with a topic - - request data from server by topic and item - - poke data into the server - - ask the server to start an advice loop on topic/item - - ask the server to stop an advice loop - - A server can: - - - respond to execute, request, poke and advice start/stop - - send advise data to client - - Note that this limits the server in the ways it can send data to the - client, i.e. it can't send unsolicited information. - * - */ - -class WXDLLIMPEXP_FWD_NET wxTCPServer; -class WXDLLIMPEXP_FWD_NET wxTCPClient; - -class wxIPCSocketStreams; - -class WXDLLIMPEXP_NET wxTCPConnection : public wxConnectionBase -{ -public: - wxTCPConnection() { Init(); } - wxTCPConnection(void *buffer, size_t size) - : wxConnectionBase(buffer, size) - { - Init(); - } - - virtual ~wxTCPConnection(); - - // implement base class pure virtual methods - virtual const void *Request(const wxString& item, - size_t *size = NULL, - wxIPCFormat format = wxIPC_TEXT); - virtual bool StartAdvise(const wxString& item); - virtual bool StopAdvise(const wxString& item); - virtual bool Disconnect(void); - - // Will be used in the future to enable the compression but does nothing - // for now. - void Compress(bool on); - - -protected: - virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format); - virtual bool DoPoke(const wxString& item, const void *data, size_t size, - wxIPCFormat format); - virtual bool DoAdvise(const wxString& item, const void *data, size_t size, - wxIPCFormat format); - - - // notice that all the members below are only initialized once the - // connection is made, i.e. in MakeConnection() for the client objects and - // after OnAcceptConnection() in the server ones - - // the underlying socket (wxSocketClient for IPC client and wxSocketServer - // for IPC server) - wxSocketBase *m_sock; - - // various streams that we use - wxIPCSocketStreams *m_streams; - - // the topic of this connection - wxString m_topic; - -private: - // common part of both ctors - void Init(); - - friend class wxTCPServer; - friend class wxTCPClient; - friend class wxTCPEventHandler; - - wxDECLARE_NO_COPY_CLASS(wxTCPConnection); - DECLARE_DYNAMIC_CLASS(wxTCPConnection) -}; - -class WXDLLIMPEXP_NET wxTCPServer : public wxServerBase -{ -public: - wxTCPServer(); - virtual ~wxTCPServer(); - - // Returns false on error (e.g. port number is already in use) - virtual bool Create(const wxString& serverName); - - virtual wxConnectionBase *OnAcceptConnection(const wxString& topic); - -protected: - wxSocketServer *m_server; - -#ifdef __UNIX_LIKE__ - // the name of the file associated to the Unix domain socket, may be empty - wxString m_filename; -#endif // __UNIX_LIKE__ - - wxDECLARE_NO_COPY_CLASS(wxTCPServer); - DECLARE_DYNAMIC_CLASS(wxTCPServer) -}; - -class WXDLLIMPEXP_NET wxTCPClient : public wxClientBase -{ -public: - wxTCPClient(); - - virtual bool ValidHost(const wxString& host); - - // Call this to make a connection. Returns NULL if cannot. - virtual wxConnectionBase *MakeConnection(const wxString& host, - const wxString& server, - const wxString& topic); - - // Callbacks to CLIENT - override at will - virtual wxConnectionBase *OnMakeConnection(); - -private: - DECLARE_DYNAMIC_CLASS(wxTCPClient) -}; - -#endif // wxUSE_SOCKETS && wxUSE_IPC - -#endif // _WX_SCKIPC_H diff --git a/Source/3rd Party/wx/include/wx/sckstrm.h b/Source/3rd Party/wx/include/wx/sckstrm.h deleted file mode 100644 index 31f32706e..000000000 --- a/Source/3rd Party/wx/include/wx/sckstrm.h +++ /dev/null @@ -1,74 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sckstrm.h -// Purpose: wxSocket*Stream -// Author: Guilhem Lavaux -// Modified by: -// Created: 17/07/97 -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// -#ifndef __SCK_STREAM_H__ -#define __SCK_STREAM_H__ - -#include "wx/stream.h" - -#if wxUSE_SOCKETS && wxUSE_STREAMS - -#include "wx/socket.h" - -class WXDLLIMPEXP_NET wxSocketOutputStream : public wxOutputStream -{ -public: - wxSocketOutputStream(wxSocketBase& s); - virtual ~wxSocketOutputStream(); - -protected: - wxSocketBase *m_o_socket; - - size_t OnSysWrite(const void *buffer, size_t bufsize); - - // socket streams are both un-seekable and size-less streams: - wxFileOffset OnSysTell() const - { return wxInvalidOffset; } - wxFileOffset OnSysSeek(wxFileOffset WXUNUSED(pos), wxSeekMode WXUNUSED(mode)) - { return wxInvalidOffset; } - - wxDECLARE_NO_COPY_CLASS(wxSocketOutputStream); -}; - -class WXDLLIMPEXP_NET wxSocketInputStream : public wxInputStream -{ -public: - wxSocketInputStream(wxSocketBase& s); - virtual ~wxSocketInputStream(); - -protected: - wxSocketBase *m_i_socket; - - size_t OnSysRead(void *buffer, size_t bufsize); - - // socket streams are both un-seekable and size-less streams: - - wxFileOffset OnSysTell() const - { return wxInvalidOffset; } - wxFileOffset OnSysSeek(wxFileOffset WXUNUSED(pos), wxSeekMode WXUNUSED(mode)) - { return wxInvalidOffset; } - - wxDECLARE_NO_COPY_CLASS(wxSocketInputStream); -}; - -class WXDLLIMPEXP_NET wxSocketStream : public wxSocketInputStream, - public wxSocketOutputStream -{ -public: - wxSocketStream(wxSocketBase& s); - virtual ~wxSocketStream(); - - wxDECLARE_NO_COPY_CLASS(wxSocketStream); -}; - -#endif - // wxUSE_SOCKETS && wxUSE_STREAMS - -#endif - // __SCK_STREAM_H__ diff --git a/Source/3rd Party/wx/include/wx/scopedarray.h b/Source/3rd Party/wx/include/wx/scopedarray.h deleted file mode 100644 index e6246a235..000000000 --- a/Source/3rd Party/wx/include/wx/scopedarray.h +++ /dev/null @@ -1,119 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/scopedarray.h -// Purpose: scoped smart pointer class -// Author: Vadim Zeitlin -// Created: 2009-02-03 -// Copyright: (c) Jesse Lovelace and original Boost authors (see below) -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SCOPED_ARRAY_H_ -#define _WX_SCOPED_ARRAY_H_ - -#include "wx/defs.h" -#include "wx/checkeddelete.h" - -// ---------------------------------------------------------------------------- -// wxScopedArray: A scoped array -// ---------------------------------------------------------------------------- - -template -class wxScopedArray -{ -public: - typedef T element_type; - - wxEXPLICIT wxScopedArray(T * array = NULL) : m_array(array) { } - - ~wxScopedArray() { delete [] m_array; } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxScopedArray::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - return m_array ? &wxScopedArray::get : NULL; - } - - void reset(T *array = NULL) - { - if ( array != m_array ) - { - delete [] m_array; - m_array = array; - } - } - - T& operator[](size_t n) const { return m_array[n]; } - - T *get() const { return m_array; } - - void swap(wxScopedArray &other) - { - T * const tmp = other.m_array; - other.m_array = m_array; - m_array = tmp; - } - -private: - T *m_array; - - DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedArray, T) -}; - -// ---------------------------------------------------------------------------- -// old macro based implementation -// ---------------------------------------------------------------------------- - -// the same but for arrays instead of simple pointers -#define wxDECLARE_SCOPED_ARRAY(T, name)\ -class name \ -{ \ -private: \ - T * m_ptr; \ - name(name const &); \ - name & operator=(name const &); \ - \ -public: \ - wxEXPLICIT name(T * p = NULL) : m_ptr(p) \ - {} \ - \ - ~name(); \ - void reset(T * p = NULL); \ - \ - T & operator[](long int i) const\ - { \ - wxASSERT(m_ptr != NULL); \ - wxASSERT(i >= 0); \ - return m_ptr[i]; \ - } \ - \ - T * get() const \ - { \ - return m_ptr; \ - } \ - \ - void swap(name & ot) \ - { \ - T * tmp = ot.m_ptr; \ - ot.m_ptr = m_ptr; \ - m_ptr = tmp; \ - } \ -}; - -#define wxDEFINE_SCOPED_ARRAY(T, name) \ -name::~name() \ -{ \ - wxCHECKED_DELETE_ARRAY(m_ptr); \ -} \ -void name::reset(T * p){ \ - if (m_ptr != p) \ - { \ - wxCHECKED_DELETE_ARRAY(m_ptr); \ - m_ptr = p; \ - } \ -} - -#endif // _WX_SCOPED_ARRAY_H_ - diff --git a/Source/3rd Party/wx/include/wx/scopedptr.h b/Source/3rd Party/wx/include/wx/scopedptr.h deleted file mode 100644 index 5cc0c0770..000000000 --- a/Source/3rd Party/wx/include/wx/scopedptr.h +++ /dev/null @@ -1,214 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/scopedptr.h -// Purpose: scoped smart pointer class -// Author: Jesse Lovelace -// Created: 06/01/02 -// Copyright: (c) Jesse Lovelace and original Boost authors (see below) -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// This class closely follows the implementation of the boost -// library scoped_ptr and is an adaption for c++ macro's in -// the wxWidgets project. The original authors of the boost -// scoped_ptr are given below with their respective copyrights. - -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation. -// - -#ifndef _WX_SCOPED_PTR_H_ -#define _WX_SCOPED_PTR_H_ - -#include "wx/defs.h" -#include "wx/checkeddelete.h" - -// ---------------------------------------------------------------------------- -// wxScopedPtr: A scoped pointer -// ---------------------------------------------------------------------------- - -template -class wxScopedPtr -{ -public: - typedef T element_type; - - wxEXPLICIT wxScopedPtr(T * ptr = NULL) : m_ptr(ptr) { } - - ~wxScopedPtr() { wxCHECKED_DELETE(m_ptr); } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types -#ifdef __BORLANDC__ - // this compiler is too dumb to use unspecified_bool_type operator in tests - // of the form "if ( !ptr )" - typedef bool unspecified_bool_type; -#else - typedef T *(wxScopedPtr::*unspecified_bool_type)() const; -#endif // __BORLANDC__ - operator unspecified_bool_type() const - { - return m_ptr ? &wxScopedPtr::get : NULL; - } - - void reset(T * ptr = NULL) - { - if ( ptr != m_ptr ) - { - wxCHECKED_DELETE(m_ptr); - m_ptr = ptr; - } - } - - T *release() - { - T *ptr = m_ptr; - m_ptr = NULL; - return ptr; - } - - T & operator*() const - { - wxASSERT(m_ptr != NULL); - return *m_ptr; - } - - T * operator->() const - { - wxASSERT(m_ptr != NULL); - return m_ptr; - } - - T * get() const - { - return m_ptr; - } - - void swap(wxScopedPtr& other) - { - T * const tmp = other.m_ptr; - other.m_ptr = m_ptr; - m_ptr = tmp; - } - -private: - T * m_ptr; - - DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedPtr, T) -}; - -// ---------------------------------------------------------------------------- -// old macro based implementation -// ---------------------------------------------------------------------------- - -/* The type being used *must* be complete at the time - that wxDEFINE_SCOPED_* is called or a compiler error will result. - This is because the class checks for the completeness of the type - being used. */ - -#define wxDECLARE_SCOPED_PTR(T, name) \ -class name \ -{ \ -private: \ - T * m_ptr; \ - \ - name(name const &); \ - name & operator=(name const &); \ - \ -public: \ - wxEXPLICIT name(T * ptr = NULL) \ - : m_ptr(ptr) { } \ - \ - ~name(); \ - \ - void reset(T * ptr = NULL); \ - \ - T *release() \ - { \ - T *ptr = m_ptr; \ - m_ptr = NULL; \ - return ptr; \ - } \ - \ - T & operator*() const \ - { \ - wxASSERT(m_ptr != NULL); \ - return *m_ptr; \ - } \ - \ - T * operator->() const \ - { \ - wxASSERT(m_ptr != NULL); \ - return m_ptr; \ - } \ - \ - T * get() const \ - { \ - return m_ptr; \ - } \ - \ - void swap(name & ot) \ - { \ - T * tmp = ot.m_ptr; \ - ot.m_ptr = m_ptr; \ - m_ptr = tmp; \ - } \ -}; - -#define wxDEFINE_SCOPED_PTR(T, name)\ -void name::reset(T * ptr) \ -{ \ - if (m_ptr != ptr) \ - { \ - wxCHECKED_DELETE(m_ptr); \ - m_ptr = ptr; \ - } \ -} \ -name::~name() \ -{ \ - wxCHECKED_DELETE(m_ptr); \ -} - -// this macro can be used for the most common case when you want to declare and -// define the scoped pointer at the same time and want to use the standard -// naming convention: auto pointer to Foo is called FooPtr -#define wxDEFINE_SCOPED_PTR_TYPE(T) \ - wxDECLARE_SCOPED_PTR(T, T ## Ptr) \ - wxDEFINE_SCOPED_PTR(T, T ## Ptr) - -// ---------------------------------------------------------------------------- -// "Tied" scoped pointer: same as normal one but also sets the value of -// some other variable to the pointer value -// ---------------------------------------------------------------------------- - -#define wxDEFINE_TIED_SCOPED_PTR_TYPE(T) \ - wxDEFINE_SCOPED_PTR_TYPE(T) \ - class T ## TiedPtr : public T ## Ptr \ - { \ - public: \ - T ## TiedPtr(T **pp, T *p) \ - : T ## Ptr(p), m_pp(pp) \ - { \ - m_pOld = *pp; \ - *pp = p; \ - } \ - \ - ~ T ## TiedPtr() \ - { \ - *m_pp = m_pOld; \ - } \ - \ - private: \ - T **m_pp; \ - T *m_pOld; \ - }; - -#endif // _WX_SCOPED_PTR_H_ - diff --git a/Source/3rd Party/wx/include/wx/scopeguard.h b/Source/3rd Party/wx/include/wx/scopeguard.h index ce6c62503..2517e86e4 100644 --- a/Source/3rd Party/wx/include/wx/scopeguard.h +++ b/Source/3rd Party/wx/include/wx/scopeguard.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.07.2003 +// RCS-ID: $Id: scopeguard.h 44111 2007-01-07 13:28:16Z SN $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -50,8 +51,14 @@ #else +#if !defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 95) +// namespace support was first implemented in gcc-2.95, +// so avoid using it for older versions. namespace wxPrivate { +#else +#define wxPrivate +#endif // in the original implementation this was a member template function of // ScopeGuardImplBase but gcc 2.8 which is still used for OS/2 doesn't // support member templates and so we must make it global @@ -74,7 +81,9 @@ namespace wxPrivate void Use(const T& WXUNUSED(t)) { } +#if !defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 95) } // namespace wxPrivate +#endif #define wxPrivateOnScopeExit(n) wxPrivate::OnScopeExit(n) #define wxPrivateUse(n) wxPrivate::Use(n) @@ -94,12 +103,6 @@ class wxScopeGuardImplBase public: wxScopeGuardImplBase() : m_wasDismissed(false) { } - wxScopeGuardImplBase(const wxScopeGuardImplBase& other) - : m_wasDismissed(other.m_wasDismissed) - { - other.Dismiss(); - } - void Dismiss() const { m_wasDismissed = true; } // for OnScopeExit() only (we can't make it friend, unfortunately)! @@ -108,6 +111,12 @@ public: protected: ~wxScopeGuardImplBase() { } + wxScopeGuardImplBase(const wxScopeGuardImplBase& other) + : m_wasDismissed(other.m_wasDismissed) + { + other.Dismiss(); + } + // must be mutable for copy ctor to work mutable bool m_wasDismissed; @@ -115,9 +124,6 @@ private: wxScopeGuardImplBase& operator=(const wxScopeGuardImplBase&); }; -// wxScopeGuard is just a reference, see the explanation in CUJ article -typedef const wxScopeGuardImplBase& wxScopeGuard; - // ---------------------------------------------------------------------------- // wxScopeGuardImpl0: scope guard for actions without parameters // ---------------------------------------------------------------------------- @@ -214,41 +220,6 @@ inline wxScopeGuardImpl2 wxMakeGuard(F fun, P1 p1, P2 p2) return wxScopeGuardImpl2::MakeGuard(fun, p1, p2); } -// ---------------------------------------------------------------------------- -// wxScopeGuardImpl3: scope guard for actions with 3 parameters -// ---------------------------------------------------------------------------- - -template -class wxScopeGuardImpl3 : public wxScopeGuardImplBase -{ -public: - static wxScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) - { - return wxScopeGuardImpl3(fun, p1, p2, p3); - } - - ~wxScopeGuardImpl3() { wxPrivateOnScopeExit(*this); } - - void Execute() { m_fun(m_p1, m_p2, m_p3); } - -protected: - wxScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) - : m_fun(fun), m_p1(p1), m_p2(p2), m_p3(p3) { } - - F m_fun; - const P1 m_p1; - const P2 m_p2; - const P3 m_p3; - - wxScopeGuardImpl3& operator=(const wxScopeGuardImpl3&); -}; - -template -inline wxScopeGuardImpl3 wxMakeGuard(F fun, P1 p1, P2 p2, P3 p3) -{ - return wxScopeGuardImpl3::MakeGuard(fun, p1, p2, p3); -} - // ============================================================================ // wxScopeGuards for object methods // ============================================================================ @@ -347,125 +318,21 @@ wxMakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2) MakeObjGuard(obj, memFun, p1, p2); } -template -class wxObjScopeGuardImpl3 : public wxScopeGuardImplBase -{ -public: - static wxObjScopeGuardImpl3 - MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3) - { - return wxObjScopeGuardImpl3(obj, memFun, p1, p2, p3); - } - - ~wxObjScopeGuardImpl3() { wxPrivateOnScopeExit(*this); } - - void Execute() { (m_obj.*m_memfun)(m_p1, m_p2, m_p3); } - -protected: - wxObjScopeGuardImpl3(Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3) - : m_obj(obj), m_memfun(memFun), m_p1(p1), m_p2(p2), m_p3(p3) { } - - Obj& m_obj; - MemFun m_memfun; - const P1 m_p1; - const P2 m_p2; - const P3 m_p3; -}; - -template -inline wxObjScopeGuardImpl3 -wxMakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3) -{ - return wxObjScopeGuardImpl3:: - MakeObjGuard(obj, memFun, p1, p2, p3); -} - -// ---------------------------------------------------------------------------- -// wxVariableSetter: use the same technique as for wxScopeGuard to allow -// setting a variable to some value on block exit -// ---------------------------------------------------------------------------- - -namespace wxPrivate -{ - -// empty class just to be able to define a reference to it -class VariableSetterBase : public wxScopeGuardImplBase { }; - -typedef const VariableSetterBase& VariableSetter; - -template -class VariableSetterImpl : public VariableSetterBase -{ -public: - VariableSetterImpl(T& var, U value) - : m_var(var), - m_value(value) - { - } - - ~VariableSetterImpl() { wxPrivateOnScopeExit(*this); } - - void Execute() { m_var = m_value; } - -private: - T& m_var; - const U m_value; - - // suppress the warning about assignment operator not being generated - VariableSetterImpl& operator=(const VariableSetterImpl&); -}; - -template -class VariableNullerImpl : public VariableSetterBase -{ -public: - VariableNullerImpl(T& var) - : m_var(var) - { - } - - ~VariableNullerImpl() { wxPrivateOnScopeExit(*this); } - - void Execute() { m_var = NULL; } - -private: - T& m_var; - - VariableNullerImpl& operator=(const VariableNullerImpl&); -}; - -} // namespace wxPrivate - -template -inline -wxPrivate::VariableSetterImpl wxMakeVarSetter(T& var, U value) -{ - return wxPrivate::VariableSetterImpl(var, value); -} - -// calling wxMakeVarSetter(ptr, NULL) doesn't work because U is deduced to be -// "int" and subsequent assignment of "U" to "T *" fails, so provide a special -// function for this special case -template -inline -wxPrivate::VariableNullerImpl wxMakeVarNuller(T& var) -{ - return wxPrivate::VariableNullerImpl(var); -} - // ============================================================================ -// macros for declaring unnamed scoped guards (which can't be dismissed) +// public stuff // ============================================================================ +// wxScopeGuard is just a reference, see the explanation in CUJ article +typedef const wxScopeGuardImplBase& wxScopeGuard; + +// when an unnamed scope guard is needed, the macros below may be used +// // NB: the original code has a single (and much nicer) ON_BLOCK_EXIT macro // but this results in compiler warnings about unused variables and I // didn't find a way to work around this other than by having different -// macros with different names or using a less natural syntax for passing -// the arguments (e.g. as Boost preprocessor sequences, which would mean -// having to write wxON_BLOCK_EXIT(fwrite, (buf)(size)(n)(fp)) instead of -// wxON_BLOCK_EXIT4(fwrite, buf, size, n, fp)). +// macros with different names -#define wxGuardName wxMAKE_UNIQUE_NAME(wxScopeGuard) +#define wxGuardName wxMAKE_UNIQUE_NAME(scopeGuard) #define wxON_BLOCK_EXIT0_IMPL(n, f) \ wxScopeGuard n = wxMakeGuard(f); \ @@ -479,10 +346,6 @@ wxPrivate::VariableNullerImpl wxMakeVarNuller(T& var) #define wxON_BLOCK_EXIT_OBJ0(o, m) \ wxON_BLOCK_EXIT_OBJ0_IMPL(wxGuardName, o, &m) -#define wxON_BLOCK_EXIT_THIS0(m) \ - wxON_BLOCK_EXIT_OBJ0(*this, m) - - #define wxON_BLOCK_EXIT1_IMPL(n, f, p1) \ wxScopeGuard n = wxMakeGuard(f, p1); \ wxPrivateUse(n) @@ -495,10 +358,6 @@ wxPrivate::VariableNullerImpl wxMakeVarNuller(T& var) #define wxON_BLOCK_EXIT_OBJ1(o, m, p1) \ wxON_BLOCK_EXIT_OBJ1_IMPL(wxGuardName, o, &m, p1) -#define wxON_BLOCK_EXIT_THIS1(m, p1) \ - wxON_BLOCK_EXIT_OBJ1(*this, m, p1) - - #define wxON_BLOCK_EXIT2_IMPL(n, f, p1, p2) \ wxScopeGuard n = wxMakeGuard(f, p1, p2); \ wxPrivateUse(n) @@ -511,40 +370,4 @@ wxPrivate::VariableNullerImpl wxMakeVarNuller(T& var) #define wxON_BLOCK_EXIT_OBJ2(o, m, p1, p2) \ wxON_BLOCK_EXIT_OBJ2_IMPL(wxGuardName, o, &m, p1, p2) -#define wxON_BLOCK_EXIT_THIS2(m, p1, p2) \ - wxON_BLOCK_EXIT_OBJ2(*this, m, p1, p2) - - -#define wxON_BLOCK_EXIT3_IMPL(n, f, p1, p2, p3) \ - wxScopeGuard n = wxMakeGuard(f, p1, p2, p3); \ - wxPrivateUse(n) -#define wxON_BLOCK_EXIT3(f, p1, p2, p3) \ - wxON_BLOCK_EXIT3_IMPL(wxGuardName, f, p1, p2, p3) - -#define wxON_BLOCK_EXIT_OBJ3_IMPL(n, o, m, p1, p2, p3) \ - wxScopeGuard n = wxMakeObjGuard(o, m, p1, p2, p3); \ - wxPrivateUse(n) -#define wxON_BLOCK_EXIT_OBJ3(o, m, p1, p2, p3) \ - wxON_BLOCK_EXIT_OBJ3_IMPL(wxGuardName, o, &m, p1, p2, p3) - -#define wxON_BLOCK_EXIT_THIS3(m, p1, p2, p3) \ - wxON_BLOCK_EXIT_OBJ3(*this, m, p1, p2, p3) - - -#define wxSetterName wxMAKE_UNIQUE_NAME(wxVarSetter) - -#define wxON_BLOCK_EXIT_SET_IMPL(n, var, value) \ - wxPrivate::VariableSetter n = wxMakeVarSetter(var, value); \ - wxPrivateUse(n) - -#define wxON_BLOCK_EXIT_SET(var, value) \ - wxON_BLOCK_EXIT_SET_IMPL(wxSetterName, var, value) - -#define wxON_BLOCK_EXIT_NULL_IMPL(n, var) \ - wxPrivate::VariableSetter n = wxMakeVarNuller(var); \ - wxPrivateUse(n) - -#define wxON_BLOCK_EXIT_NULL(ptr) \ - wxON_BLOCK_EXIT_NULL_IMPL(wxSetterName, ptr) - #endif // _WX_SCOPEGUARD_H_ diff --git a/Source/3rd Party/wx/include/wx/scrolbar.h b/Source/3rd Party/wx/include/wx/scrolbar.h index 844ec9f5a..97dab1af9 100644 --- a/Source/3rd Party/wx/include/wx/scrolbar.h +++ b/Source/3rd Party/wx/include/wx/scrolbar.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/scrolbar.h +// Name: scrolbar.h // Purpose: wxScrollBar base header // Author: Julian Smart // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: scrolbar.h 37066 2006-01-23 03:27:34Z MR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,21 +18,18 @@ #include "wx/control.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxScrollBarNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxScrollBarNameStr[]; // ---------------------------------------------------------------------------- // wxScrollBar: a scroll bar control // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxScrollBarBase : public wxControl +class WXDLLEXPORT wxScrollBarBase : public wxControl { public: wxScrollBarBase() { } - /* - Derived classes should provide the following method and ctor with the - same parameters: - + // scrollbar construction bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -39,7 +37,6 @@ public: long style = wxSB_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxScrollBarNameStr); - */ // accessors virtual int GetThumbPosition() const = 0; @@ -55,11 +52,8 @@ public: int range, int pageSize, bool refresh = true) = 0; - // implementation-only - bool IsNeeded() const { return GetRange() > GetThumbSize(); } - private: - wxDECLARE_NO_COPY_CLASS(wxScrollBarBase); + DECLARE_NO_COPY_CLASS(wxScrollBarBase) }; #if defined(__WXUNIVERSAL__) @@ -73,7 +67,7 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/scrolbar.h" #elif defined(__WXMAC__) - #include "wx/osx/scrolbar.h" + #include "wx/mac/scrolbar.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/scrolbar.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/scrolwin.h b/Source/3rd Party/wx/include/wx/scrolwin.h index e84608815..c5d06fa1e 100644 --- a/Source/3rd Party/wx/include/wx/scrolwin.h +++ b/Source/3rd Party/wx/include/wx/scrolwin.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/scrolwin.h +// Name: include/wx/scrolwin.h // Purpose: wxScrolledWindow, wxScrolledControl and wxScrollHelper // Author: Vadim Zeitlin // Modified by: // Created: 30.08.00 +// RCS-ID: $Id: scrolwin.h 50864 2007-12-20 18:36:19Z VS $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,19 +15,11 @@ #include "wx/panel.h" class WXDLLIMPEXP_FWD_CORE wxScrollHelperEvtHandler; -class WXDLLIMPEXP_FWD_BASE wxTimer; +class WXDLLIMPEXP_FWD_CORE wxTimer; // default scrolled window style: scroll in both directions #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL) -// values for the second argument of wxScrollHelper::ShowScrollbars() -enum wxScrollbarVisibility -{ - wxSHOW_SB_NEVER = -1, // never show the scrollbar at all - wxSHOW_SB_DEFAULT, // show scrollbar only if it is needed - wxSHOW_SB_ALWAYS // always show scrollbar, even if not needed -}; - // ---------------------------------------------------------------------------- // The hierarchy of scrolling classes is a bit complicated because we want to // put as much functionality as possible in a mix-in class not deriving from @@ -36,15 +29,11 @@ enum wxScrollbarVisibility // // So we have // -// wxAnyScrollHelperBase +// wxScrollHelper // | // | // \|/ -// wxScrollHelperBase -// | -// | -// \|/ -// wxWindow wxScrollHelper +// wxWindow wxScrollHelperNative // | \ / / // | \ / / // | _| |_ / @@ -59,56 +48,12 @@ enum wxScrollbarVisibility // // ---------------------------------------------------------------------------- -// This class allows reusing some of wxScrollHelperBase functionality in -// wxVarScrollHelperBase in wx/vscroll.h without duplicating its code. -class WXDLLIMPEXP_CORE wxAnyScrollHelperBase -{ -public: - wxEXPLICIT wxAnyScrollHelperBase(wxWindow* win); - virtual ~wxAnyScrollHelperBase() {} - - // Disable use of keyboard keys for scrolling. By default cursor movement - // keys (including Home, End, Page Up and Down) are used to scroll the - // window appropriately. If the derived class uses these keys for something - // else, e.g. changing the currently selected item, this function can be - // used to disable this behaviour as it's not only not necessary then but - // can actually be actively harmful if another object forwards a keyboard - // event corresponding to one of the above keys to us using - // ProcessWindowEvent() because the event will always be processed which - // can be undesirable. - void DisableKeyboardScrolling() { m_kbdScrollingEnabled = false; } - - // Override this function to draw the graphic (or just process EVT_PAINT) - virtual void OnDraw(wxDC& WXUNUSED(dc)) { } - - // change the DC origin according to the scroll position. - virtual void DoPrepareDC(wxDC& dc) = 0; - - // Simple accessor for the window that is really being scrolled. - wxWindow *GetTargetWindow() const { return m_targetWindow; } - - - // The methods called from the window event handlers. - void HandleOnChar(wxKeyEvent& event); - void HandleOnPaint(wxPaintEvent& event); - -protected: - // the window that receives the scroll events and the window to actually - // scroll, respectively - wxWindow *m_win, - *m_targetWindow; - - // whether cursor keys should scroll the window - bool m_kbdScrollingEnabled; -}; - -// This is the class containing the guts of (uniform) scrolling logic. -class WXDLLIMPEXP_CORE wxScrollHelperBase : public wxAnyScrollHelperBase +class WXDLLEXPORT wxScrollHelper { public: // ctor must be given the associated window - wxScrollHelperBase(wxWindow *winToScroll); - virtual ~wxScrollHelperBase(); + wxScrollHelper(wxWindow *winToScroll); + virtual ~wxScrollHelper(); // configure the scrolling virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, @@ -117,18 +62,13 @@ public: bool noRefresh = false ); // scroll to the given (in logical coords) position - // - // notice that for backwards compatibility reasons Scroll() is virtual as - // the existing code could override it but new code should override - // DoScroll() instead - virtual void Scroll(int x, int y) { DoScroll(x, y); } - virtual void Scroll(const wxPoint& pt) { DoScroll(pt.x, pt.y); } + virtual void Scroll(int x, int y); // get/set the page size for this orientation (wxVERTICAL/wxHORIZONTAL) int GetScrollPageSize(int orient) const; void SetScrollPageSize(int orient, int pageSize); - // get the number of lines the window can scroll, + // get the number of lines the window can scroll, // returns 0 if no scrollbars are there. int GetScrollLines( int orient ) const; @@ -136,41 +76,18 @@ public: void SetScrollRate( int xstep, int ystep ); // get the size of one logical unit in physical ones - void GetScrollPixelsPerUnit(int *pixelsPerUnitX, int *pixelsPerUnitY) const; - - // Set scrollbar visibility: it is possible to show scrollbar only if it is - // needed (i.e. if our virtual size is greater than the current size of the - // associated window), always (as wxALWAYS_SHOW_SB style does) or never (in - // which case you should provide some other way to scroll the window as the - // user wouldn't be able to do it at all) - void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert) - { - DoShowScrollbars(horz, vert); - } - - // Test whether the specified scrollbar is shown. - virtual bool IsScrollbarShown(int orient) const = 0; + virtual void GetScrollPixelsPerUnit(int *pixelsPerUnitX, + int *pixelsPerUnitY) const; // Enable/disable Windows scrolling in either direction. If true, wxWidgets // scrolls the canvas and only a bit of the canvas is invalidated; no // Clear() is necessary. If false, the whole canvas is invalidated and a // Clear() is necessary. Disable for when the scroll increment is used to // actually scroll a non-constant distance - // - // Notice that calling this method with a false argument doesn't disable - // scrolling the window in this direction, it just changes the mechanism by - // which it is implemented to not use wxWindow::ScrollWindow(). virtual void EnableScrolling(bool x_scrolling, bool y_scrolling); // Get the view start - void GetViewStart(int *x, int *y) const { DoGetViewStart(x, y); } - - wxPoint GetViewStart() const - { - wxPoint pt; - DoGetViewStart(&pt.x, &pt.y); - return pt; - } + virtual void GetViewStart(int *x, int *y) const; // Set the scale factor, used in PrepareDC void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; } @@ -196,24 +113,29 @@ public: return p2; } - void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; - void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; + virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; + virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; // Adjust the scrollbars - virtual void AdjustScrollbars() = 0; + virtual void AdjustScrollbars(void); // Calculate scroll increment - int CalcScrollInc(wxScrollWinEvent& event); + virtual int CalcScrollInc(wxScrollWinEvent& event); // Normally the wxScrolledWindow will scroll itself, but in some rare // occasions you might want it to scroll [part of] another window (e.g. a // child of it in order to scroll only a portion the area between the // scrollbars (spreadsheet: only cell area will move). - void SetTargetWindow(wxWindow *target); + virtual void SetTargetWindow(wxWindow *target); + virtual wxWindow *GetTargetWindow() const; void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; } wxRect GetTargetRect() const { return m_rectToScroll; } + // Override this function to draw the graphic (or just process EVT_PAINT) + virtual void OnDraw(wxDC& WXUNUSED(dc)) { } + + // change the DC origin according to the scroll position. virtual void DoPrepareDC(wxDC& dc); // are we generating the autoscroll events? @@ -233,18 +155,21 @@ public: // the methods to be called from the window event handlers void HandleOnScroll(wxScrollWinEvent& event); void HandleOnSize(wxSizeEvent& event); + void HandleOnPaint(wxPaintEvent& event); + void HandleOnChar(wxKeyEvent& event); void HandleOnMouseEnter(wxMouseEvent& event); void HandleOnMouseLeave(wxMouseEvent& event); #if wxUSE_MOUSEWHEEL void HandleOnMouseWheel(wxMouseEvent& event); #endif // wxUSE_MOUSEWHEEL - void HandleOnChildFocus(wxChildFocusEvent& event); -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( - void OnScroll(wxScrollWinEvent& event) { HandleOnScroll(event); } - ) -#endif // WXWIN_COMPATIBILITY_2_8 +#if wxABI_VERSION >= 20808 + void HandleOnChildFocus(wxChildFocusEvent& event); +#endif + + // FIXME: this is needed for now for wxPlot compilation, should be removed + // once it is fixed! + void OnScroll(wxScrollWinEvent& event) { HandleOnScroll(event); } protected: // get pointer to our scroll rect if we use it or NULL @@ -269,17 +194,12 @@ protected: *h = size.y; } - // implementation of public methods with the same name - virtual void DoGetViewStart(int *x, int *y) const; - virtual void DoScroll(int x, int y) = 0; - virtual void DoShowScrollbars(wxScrollbarVisibility horz, - wxScrollbarVisibility vert) = 0; - // implementations of various wxWindow virtual methods which should be // forwarded to us (this can be done by WX_FORWARD_TO_SCROLL_HELPER()) bool ScrollLayout(); void ScrollDoSetVirtualSize(int x, int y); wxSize ScrollGetBestVirtualSize() const; + wxSize ScrollGetWindowSizeForVirtualSize(const wxSize& size) const; // change just the target window (unlike SetWindow which changes m_win as // well) @@ -288,34 +208,17 @@ protected: // delete the event handler we installed void DeleteEvtHandler(); - // this function should be overridden to return the size available for - // m_targetWindow inside m_win of the given size - // - // the default implementation is only good for m_targetWindow == m_win - // case, if we're scrolling a subwindow you must override this method - virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size) - { - // returning just size from here is wrong but it was decided that it is - // not wrong enough to break the existing code (which doesn't override - // this recently added function at all) by adding this assert - // - // wxASSERT_MSG( m_targetWindow == m_win, "must be overridden" ); - - return size; - } - double m_scaleX; double m_scaleY; + wxWindow *m_win, + *m_targetWindow; + wxRect m_rectToScroll; wxTimer *m_timerAutoScroll; - // The number of pixels to scroll in horizontal and vertical directions - // respectively. - // - // If 0, means that the scrolling in the given direction is disabled. int m_xScrollPixelsPerLine; int m_yScrollPixelsPerLine; int m_xScrollPosition; @@ -334,7 +237,7 @@ protected: wxScrollHelperEvtHandler *m_handler; - wxDECLARE_NO_COPY_CLASS(wxScrollHelperBase); + DECLARE_NO_COPY_CLASS(wxScrollHelper) }; // this macro can be used in a wxScrollHelper-derived class to forward wxWindow @@ -343,152 +246,69 @@ protected: public: \ virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \ virtual bool Layout() { return ScrollLayout(); } \ - virtual bool CanScroll(int orient) const \ - { return IsScrollbarShown(orient); } \ virtual void DoSetVirtualSize(int x, int y) \ { ScrollDoSetVirtualSize(x, y); } \ virtual wxSize GetBestVirtualSize() const \ - { return ScrollGetBestVirtualSize(); } + { return ScrollGetBestVirtualSize(); } \ +protected: \ + virtual wxSize GetWindowSizeForVirtualSize(const wxSize& size) const \ + { return ScrollGetWindowSizeForVirtualSize(size); } -// include the declaration of the real wxScrollHelper +// include the declaration of wxScrollHelperNative if needed #if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/scrolwin.h" #elif defined(__WXGTK__) && !defined(__WXUNIVERSAL__) #include "wx/gtk1/scrolwin.h" #else - #define wxHAS_GENERIC_SCROLLWIN - #include "wx/generic/scrolwin.h" + typedef wxScrollHelper wxScrollHelperNative; #endif // ---------------------------------------------------------------------------- -// wxScrolled: a wxWindow which knows how to scroll +// wxScrolledWindow: a wxWindow which knows how to scroll // ---------------------------------------------------------------------------- -// helper class for wxScrolled below -struct WXDLLIMPEXP_CORE wxScrolledT_Helper -{ - static wxSize FilterBestSize(const wxWindow *win, - const wxScrollHelper *helper, - const wxSize& origBest); -#ifdef __WXMSW__ - static WXLRESULT FilterMSWWindowProc(WXUINT nMsg, WXLRESULT origResult); -#endif -}; - -// Scrollable window base on window type T. This used to be wxScrolledWindow, -// but wxScrolledWindow includes wxControlContainer functionality and that's -// not always desirable. -template -class wxScrolled : public T, - public wxScrollHelper, - private wxScrolledT_Helper +class WXDLLEXPORT wxScrolledWindow : public wxPanel, + public wxScrollHelperNative { public: - wxScrolled() : wxScrollHelper(this) { } - wxScrolled(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxScrolledWindowStyle, - const wxString& name = wxPanelNameStr) - : wxScrollHelper(this) - { - Create(parent, winid, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID winid, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxScrolledWindowStyle, - const wxString& name = wxPanelNameStr) - { - m_targetWindow = this; - -#ifdef __WXMAC__ - this->MacSetClipChildren(true); -#endif - - // by default, we're scrollable in both directions (but if one of the - // styles is specified explicitly, we shouldn't add the other one - // automatically) - if ( !(style & (wxHSCROLL | wxVSCROLL)) ) - style |= wxHSCROLL | wxVSCROLL; - -#ifdef __WXOSX__ - bool retval = T::Create(parent, winid, pos, size, style, name); - if ( retval && (style & wxALWAYS_SHOW_SB) ) - ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS); - return retval; -#else - if ( style & wxALWAYS_SHOW_SB ) - ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS); - - return T::Create(parent, winid, pos, size, style, name); -#endif - } - -#ifdef __WXMSW__ - // we need to return a special WM_GETDLGCODE value to process just the - // arrows but let the other navigation characters through - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) - { - return FilterMSWWindowProc(nMsg, T::MSWWindowProc(nMsg, wParam, lParam)); - } - - // Take into account the scroll origin. - virtual void MSWAdjustBrushOrg(int* xOrg, int* yOrg) const - { - CalcUnscrolledPosition(*xOrg, *yOrg, xOrg, yOrg); - } -#endif // __WXMSW__ - - WX_FORWARD_TO_SCROLL_HELPER() - -protected: - virtual wxSize DoGetBestSize() const - { - return FilterBestSize(this, this, T::DoGetBestSize()); - } - -private: - // VC++ 6 gives warning for the declaration of template member function - // without definition -#ifndef __VISUALC6__ - wxDECLARE_NO_COPY_CLASS(wxScrolled); -#endif -}; - -#ifdef __VISUALC6__ - // disable the warning about non dll-interface class used as base for - // dll-interface class: it's harmless in this case - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -// for compatibility with existing code, we provide wxScrolledWindow -// "typedef" for wxScrolled. It's not a real typedef because we -// want wxScrolledWindow to show in wxRTTI information (the class is widely -// used and likelihood of its wxRTTI information being used too is high): -class WXDLLIMPEXP_CORE wxScrolledWindow : public wxScrolled -{ -public: - wxScrolledWindow() : wxScrolled() {} + wxScrolledWindow() : wxScrollHelperNative(this) { } wxScrolledWindow(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxScrolledWindowStyle, const wxString& name = wxPanelNameStr) - : wxScrolled(parent, winid, pos, size, style, name) {} + : wxScrollHelperNative(this) + { + Create(parent, winid, pos, size, style, name); + } + virtual ~wxScrolledWindow(); + + bool Create(wxWindow *parent, + wxWindowID winid, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxScrolledWindowStyle, + const wxString& name = wxPanelNameStr); + + // we need to return a special WM_GETDLGCODE value to process just the + // arrows but let the other navigation characters through +#ifdef __WXMSW__ + virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); +#endif // __WXMSW__ + + WX_FORWARD_TO_SCROLL_HELPER() + +protected: + // this is needed for wxEVT_PAINT processing hack described in + // wxScrollHelperEvtHandler::ProcessEvent() + void OnPaint(wxPaintEvent& event); + +private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxScrolledWindow) + DECLARE_EVENT_TABLE() }; -typedef wxScrolled wxScrolledCanvas; - -#ifdef __VISUALC6__ - #pragma warning(pop) -#endif - #endif // _WX_SCROLWIN_H_BASE_ + diff --git a/Source/3rd Party/wx/include/wx/selstore.h b/Source/3rd Party/wx/include/wx/selstore.h index 2680eba9d..56b11e4af 100644 --- a/Source/3rd Party/wx/include/wx/selstore.h +++ b/Source/3rd Party/wx/include/wx/selstore.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 08.06.03 (extracted from src/generic/listctrl.cpp) +// RCS-ID: $Id: selstore.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2000-2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,12 +18,14 @@ // wxSelectedIndices is just a sorted array of indices // ---------------------------------------------------------------------------- -inline int CMPFUNC_CONV wxUIntCmp(unsigned n1, unsigned n2) +inline int CMPFUNC_CONV wxSizeTCmpFn(size_t n1, size_t n2) { return (int)(n1 - n2); } -WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(unsigned, wxUIntCmp, wxSelectedIndices); +WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SIZE_T(size_t, + wxSizeTCmpFn, + wxSelectedIndices); // ---------------------------------------------------------------------------- // wxSelectionStore is used to store the selected items in the virtual @@ -36,43 +39,43 @@ WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(unsigned, wxUIntCmp, wxSelectedIndices); // individual items) without changing its API. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSelectionStore +class WXDLLEXPORT wxSelectionStore { public: - wxSelectionStore() : m_itemsSel(wxUIntCmp) { Init(); } + wxSelectionStore() : m_itemsSel(wxSizeTCmpFn) { Init(); } // set the total number of items we handle - void SetItemCount(unsigned count); + void SetItemCount(size_t count) { m_count = count; } // special case of SetItemCount(0) void Clear() { m_itemsSel.Clear(); m_count = 0; m_defaultState = false; } // must be called when a new item is inserted/added - void OnItemAdd(unsigned WXUNUSED(item)) { wxFAIL_MSG( wxT("TODO") ); } + void OnItemAdd(size_t WXUNUSED(item)) { wxFAIL_MSG( wxT("TODO") ); } // must be called when an item is deleted - void OnItemDelete(unsigned item); + void OnItemDelete(size_t item); // select one item, use SelectRange() insted if possible! // // returns true if the items selection really changed - bool SelectItem(unsigned item, bool select = true); + bool SelectItem(size_t item, bool select = true); - // select the range of items (inclusive) + // select the range of items // // return true and fill the itemsChanged array with the indices of items // which have changed state if "few" of them did, otherwise return false // (meaning that too many items changed state to bother counting them // individually) - bool SelectRange(unsigned itemFrom, unsigned itemTo, + bool SelectRange(size_t itemFrom, size_t itemTo, bool select = true, wxArrayInt *itemsChanged = NULL); // return true if the given item is selected - bool IsSelected(unsigned item) const; + bool IsSelected(size_t item) const; // return the total number of selected items - unsigned GetSelectedCount() const + size_t GetSelectedCount() const { return m_defaultState ? m_count - m_itemsSel.GetCount() : m_itemsSel.GetCount(); @@ -80,10 +83,10 @@ public: private: // (re)init - void Init() { m_count = 0; m_defaultState = false; } + void Init() { m_defaultState = false; } // the total number of items we handle - unsigned m_count; + size_t m_count; // the default state: normally, false (i.e. off) but maybe set to true if // there are more selected items than non selected ones - this allows to @@ -93,8 +96,9 @@ private: // the array of items whose selection state is different from default wxSelectedIndices m_itemsSel; - wxDECLARE_NO_COPY_CLASS(wxSelectionStore); + DECLARE_NO_COPY_CLASS(wxSelectionStore) }; + #endif // _WX_SELSTORE_H_ diff --git a/Source/3rd Party/wx/include/wx/settings.h b/Source/3rd Party/wx/include/wx/settings.h index 79f04c1d9..5d732d0d2 100644 --- a/Source/3rd Party/wx/include/wx/settings.h +++ b/Source/3rd Party/wx/include/wx/settings.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: settings.h 67017 2011-02-25 09:37:28Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,15 +28,8 @@ enum wxSystemFont wxSYS_ANSI_VAR_FONT, wxSYS_SYSTEM_FONT, wxSYS_DEVICE_DEFAULT_FONT, - - // don't use: this is here just to make the values of enum elements - // coincide with the corresponding MSW constants wxSYS_DEFAULT_PALETTE, - - // don't use: MSDN says that this is a stock object provided only - // for compatibility with 16-bit Windows versions earlier than 3.0! wxSYS_SYSTEM_FIXED_FONT, - wxSYS_DEFAULT_GUI_FONT, // this was just a temporary aberration, do not use it any more @@ -49,7 +43,8 @@ enum wxSystemFont enum wxSystemColour { wxSYS_COLOUR_SCROLLBAR, - wxSYS_COLOUR_DESKTOP, + wxSYS_COLOUR_BACKGROUND, + wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND, wxSYS_COLOUR_ACTIVECAPTION, wxSYS_COLOUR_INACTIVECAPTION, wxSYS_COLOUR_MENU, @@ -64,11 +59,16 @@ enum wxSystemColour wxSYS_COLOUR_HIGHLIGHT, wxSYS_COLOUR_HIGHLIGHTTEXT, wxSYS_COLOUR_BTNFACE, + wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE, wxSYS_COLOUR_BTNSHADOW, + wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW, wxSYS_COLOUR_GRAYTEXT, wxSYS_COLOUR_BTNTEXT, wxSYS_COLOUR_INACTIVECAPTIONTEXT, wxSYS_COLOUR_BTNHIGHLIGHT, + wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, + wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, + wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, wxSYS_COLOUR_3DDKSHADOW, wxSYS_COLOUR_3DLIGHT, wxSYS_COLOUR_INFOTEXT, @@ -82,16 +82,7 @@ enum wxSystemColour wxSYS_COLOUR_LISTBOXTEXT, wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT, - wxSYS_COLOUR_MAX, - - // synonyms - wxSYS_COLOUR_BACKGROUND = wxSYS_COLOUR_DESKTOP, - wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE, - wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW, - wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, - wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, - wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, - wxSYS_COLOUR_FRAMEBK = wxSYS_COLOUR_BTNFACE + wxSYS_COLOUR_MAX }; // possible values for wxSystemSettings::GetMetric() index parameter @@ -136,8 +127,7 @@ enum wxSystemMetric wxSYS_NETWORK_PRESENT, wxSYS_PENWINDOWS_PRESENT, wxSYS_SHOW_SOUNDS, - wxSYS_SWAP_BUTTONS, - wxSYS_DCLICK_MSEC + wxSYS_SWAP_BUTTONS }; // possible values for wxSystemSettings::HasFeature() parameter @@ -170,7 +160,7 @@ enum wxSystemScreenType // files (i.e. this is not a real base class as we can't override its virtual // functions because it doesn't have any) -class WXDLLIMPEXP_CORE wxSystemSettingsNative +class WXDLLEXPORT wxSystemSettingsNative { public: // get a standard system colour @@ -190,7 +180,7 @@ public: // include the declaration of the real platform-dependent class // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSystemSettings : public wxSystemSettingsNative +class WXDLLEXPORT wxSystemSettings : public wxSystemSettingsNative { public: #ifdef __WXUNIVERSAL__ @@ -198,10 +188,6 @@ public: // system ones, otherwise wxSystemSettings is just the same as // wxSystemSettingsNative static wxColour GetColour(wxSystemColour index); - - // some metrics are toolkit-dependent and provided by wxUniv, some are - // lowlevel - static int GetMetric(wxSystemMetric index, wxWindow *win = NULL); #endif // __WXUNIVERSAL__ // Get system screen design (desktop, pda, ..) used for @@ -214,6 +200,13 @@ public: // Value static wxSystemScreenType ms_screen; +#if WXWIN_COMPATIBILITY_2_4 + // the backwards compatible versions of wxSystemSettingsNative functions, + // don't use these methods in the new code! + wxDEPRECATED(static wxColour GetSystemColour(int index)); + wxDEPRECATED(static wxFont GetSystemFont(int index)); + wxDEPRECATED(static int GetSystemMetric(int index)); +#endif }; #endif diff --git a/Source/3rd Party/wx/include/wx/setup_inc.h b/Source/3rd Party/wx/include/wx/setup_inc.h deleted file mode 100644 index dbca6a4c7..000000000 --- a/Source/3rd Party/wx/include/wx/setup_inc.h +++ /dev/null @@ -1,1499 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/setup_inc.h -// Purpose: setup.h settings -// Author: Vadim Zeitlin -// Modified by: -// Created: -// Copyright: (c) Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// global settings -// ---------------------------------------------------------------------------- - -// define this to 0 when building wxBase library - this can also be done from -// makefile/project file overriding the value here -#ifndef wxUSE_GUI - #define wxUSE_GUI 1 -#endif // wxUSE_GUI - -// ---------------------------------------------------------------------------- -// compatibility settings -// ---------------------------------------------------------------------------- - -// This setting determines the compatibility with 2.6 API: set it to 0 to -// flag all cases of using deprecated functions. -// -// Default is 1 but please try building your code with 0 as the default will -// change to 0 in the next version and the deprecated functions will disappear -// in the version after it completely. -// -// Recommended setting: 0 (please update your code) -#define WXWIN_COMPATIBILITY_2_6 0 - -// This setting determines the compatibility with 2.8 API: set it to 0 to -// flag all cases of using deprecated functions. -// -// Default is 1 but please try building your code with 0 as the default will -// change to 0 in the next version and the deprecated functions will disappear -// in the version after it completely. -// -// Recommended setting: 0 (please update your code) -#define WXWIN_COMPATIBILITY_2_8 1 - -// MSW-only: Set to 0 for accurate dialog units, else 1 for old behaviour when -// default system font is used for wxWindow::GetCharWidth/Height() instead of -// the current font. -// -// Default is 0 -// -// Recommended setting: 0 -#define wxDIALOG_UNIT_COMPATIBILITY 0 - -// ---------------------------------------------------------------------------- -// debugging settings -// ---------------------------------------------------------------------------- - -// wxDEBUG_LEVEL will be defined as 1 in wx/debug.h so normally there is no -// need to define it here. You may do it for two reasons: either completely -// disable/compile out the asserts in release version (then do it inside #ifdef -// NDEBUG) or, on the contrary, enable more asserts, including the usually -// disabled ones, in the debug build (then do it inside #ifndef NDEBUG) -// -// #ifdef NDEBUG -// #define wxDEBUG_LEVEL 0 -// #else -// #define wxDEBUG_LEVEL 2 -// #endif - -// wxHandleFatalExceptions() may be used to catch the program faults at run -// time and, instead of terminating the program with a usual GPF message box, -// call the user-defined wxApp::OnFatalException() function. If you set -// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work. -// -// This setting is for Win32 only and can only be enabled if your compiler -// supports Win32 structured exception handling (currently only VC++ does) -// -// Default is 1 -// -// Recommended setting: 1 if your compiler supports it. -#define wxUSE_ON_FATAL_EXCEPTION 1 - -// Set this to 1 to be able to generate a human-readable (unlike -// machine-readable minidump created by wxCrashReport::Generate()) stack back -// trace when your program crashes using wxStackWalker -// -// Default is 1 if supported by the compiler. -// -// Recommended setting: 1, set to 0 if your programs never crash -#define wxUSE_STACKWALKER 1 - -// Set this to 1 to compile in wxDebugReport class which allows you to create -// and optionally upload to your web site a debug report consisting of back -// trace of the crash (if wxUSE_STACKWALKER == 1) and other information. -// -// Default is 1 if supported by the compiler. -// -// Recommended setting: 1, it is compiled into a separate library so there -// is no overhead if you don't use it -#define wxUSE_DEBUGREPORT 1 - -// Generic comment about debugging settings: they are very useful if you don't -// use any other memory leak detection tools such as Purify/BoundsChecker, but -// are probably redundant otherwise. Also, Visual C++ CRT has the same features -// as wxWidgets memory debugging subsystem built in since version 5.0 and you -// may prefer to use it instead of built in memory debugging code because it is -// faster and more fool proof. -// -// Using VC++ CRT memory debugging is enabled by default in debug build (_DEBUG -// is defined) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0) -// and if __NO_VC_CRTDBG__ is not defined. - -// The rest of the options in this section are obsolete and not supported, -// enable them at your own risk. - -// If 1, enables wxDebugContext, for writing error messages to file, etc. If -// __WXDEBUG__ is not defined, will still use the normal memory operators. -// -// Default is 0 -// -// Recommended setting: 0 -#define wxUSE_DEBUG_CONTEXT 0 - -// If 1, enables debugging versions of wxObject::new and wxObject::delete *IF* -// __WXDEBUG__ is also defined. -// -// WARNING: this code may not work with all architectures, especially if -// alignment is an issue. This switch is currently ignored for mingw / cygwin -// -// Default is 0 -// -// Recommended setting: 1 if you are not using a memory debugging tool, else 0 -#define wxUSE_MEMORY_TRACING 0 - -// In debug mode, cause new and delete to be redefined globally. -// If this causes problems (e.g. link errors which is a common problem -// especially if you use another library which also redefines the global new -// and delete), set this to 0. -// This switch is currently ignored for mingw / cygwin -// -// Default is 0 -// -// Recommended setting: 0 -#define wxUSE_GLOBAL_MEMORY_OPERATORS 0 - -// In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If -// this causes problems (e.g. link errors), set this to 0. You may need to set -// this to 0 if using templates (at least for VC++). This switch is currently -// ignored for MinGW/Cygwin. -// -// Default is 0 -// -// Recommended setting: 0 -#define wxUSE_DEBUG_NEW_ALWAYS 0 - - -// ---------------------------------------------------------------------------- -// Unicode support -// ---------------------------------------------------------------------------- - -// These settings are obsolete: the library is always built in Unicode mode -// now, only set wxUSE_UNICODE to 0 to compile legacy code in ANSI mode if -// absolutely necessary -- updating it is strongly recommended as the ANSI mode -// will disappear completely in future wxWidgets releases. -#ifndef wxUSE_UNICODE - #define wxUSE_UNICODE 1 -#endif - -// wxUSE_WCHAR_T is required by wxWidgets now, don't change. -#define wxUSE_WCHAR_T 1 - -// ---------------------------------------------------------------------------- -// global features -// ---------------------------------------------------------------------------- - -// Compile library in exception-safe mode? If set to 1, the library will try to -// behave correctly in presence of exceptions (even though it still will not -// use the exceptions itself) and notify the user code about any unhandled -// exceptions. If set to 0, propagation of the exceptions through the library -// code will lead to undefined behaviour -- but the code itself will be -// slightly smaller and faster. -// -// Note that like wxUSE_THREADS this option is automatically set to 0 if -// wxNO_EXCEPTIONS is defined. -// -// Default is 1 -// -// Recommended setting: depends on whether you intend to use C++ exceptions -// in your own code (1 if you do, 0 if you don't) -#define wxUSE_EXCEPTIONS 1 - -// Set wxUSE_EXTENDED_RTTI to 1 to use extended RTTI -// -// Default is 0 -// -// Recommended setting: 0 (this is still work in progress...) -#define wxUSE_EXTENDED_RTTI 0 - -// Support for message/error logging. This includes wxLogXXX() functions and -// wxLog and derived classes. Don't set this to 0 unless you really know what -// you are doing. -// -// Default is 1 -// -// Recommended setting: 1 (always) -#define wxUSE_LOG 1 - -// Recommended setting: 1 -#define wxUSE_LOGWINDOW 1 - -// Recommended setting: 1 -#define wxUSE_LOGGUI 1 - -// Recommended setting: 1 -#define wxUSE_LOG_DIALOG 1 - -// Support for command line parsing using wxCmdLineParser class. -// -// Default is 1 -// -// Recommended setting: 1 (can be set to 0 if you don't use the cmd line) -#define wxUSE_CMDLINE_PARSER 1 - -// Support for multithreaded applications: if 1, compile in thread classes -// (thread.h) and make the library a bit more thread safe. Although thread -// support is quite stable by now, you may still consider recompiling the -// library without it if you have no use for it - this will result in a -// somewhat smaller and faster operation. -// -// Notice that if wxNO_THREADS is defined, wxUSE_THREADS is automatically reset -// to 0 in wx/chkconf.h, so, for example, if you set USE_THREADS to 0 in -// build/msw/config.* file this value will have no effect. -// -// Default is 1 -// -// Recommended setting: 0 unless you do plan to develop MT applications -#define wxUSE_THREADS 1 - -// If enabled, compiles wxWidgets streams classes -// -// wx stream classes are used for image IO, process IO redirection, network -// protocols implementation and much more and so disabling this results in a -// lot of other functionality being lost. -// -// Default is 1 -// -// Recommended setting: 1 as setting it to 0 disables many other things -#define wxUSE_STREAMS 1 - -// Support for positional parameters (e.g. %1$d, %2$s ...) in wxVsnprintf. -// Note that if the system's implementation does not support positional -// parameters, setting this to 1 forces the use of the wxWidgets implementation -// of wxVsnprintf. The standard vsnprintf() supports positional parameters on -// many Unix systems but usually doesn't under Windows. -// -// Positional parameters are very useful when translating a program since using -// them in formatting strings allow translators to correctly reorder the -// translated sentences. -// -// Default is 1 -// -// Recommended setting: 1 if you want to support multiple languages -#define wxUSE_PRINTF_POS_PARAMS 1 - -// Enable the use of compiler-specific thread local storage keyword, if any. -// This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but is -// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets -// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under -// XP as this triggers a bug in compiler TLS support that results in crashes -// when any TLS variables are used. -// -// If you're absolutely sure that your build of wxWidgets is never going to be -// used in such situation, either because it's not going to be linked from any -// kind of plugin or because you only target Vista or later systems, you can -// set this to 2 to force the use of compiler TLS even under MSW. -// -// Default is 1 meaning that compiler TLS is used only if it's 100% safe. -// -// Recommended setting: 2 if you want to have maximal performance and don't -// care about the scenario described above. -#define wxUSE_COMPILER_TLS 1 - -// ---------------------------------------------------------------------------- -// Interoperability with the standard library. -// ---------------------------------------------------------------------------- - -// Set wxUSE_STL to 1 to enable maximal interoperability with the standard -// library, even at the cost of backwards compatibility. -// -// Default is 0 -// -// Recommended setting: 0 as the options below already provide a relatively -// good level of interoperability and changing this option arguably isn't worth -// diverging from the official builds of the library. -#define wxUSE_STL 0 - -// This is not a real option but is used as the default value for -// wxUSE_STD_IOSTREAM, wxUSE_STD_STRING and wxUSE_STD_CONTAINERS. -// -// Currently the Digital Mars and Watcom compilers come without standard C++ -// library headers by default, wxUSE_STD_STRING can be set to 1 if you do have -// them (e.g. from STLPort). -// -// VC++ 5.0 does include standard C++ library headers, however they produce -// many warnings that can't be turned off when compiled at warning level 4. -#if defined(__DMC__) || defined(__WATCOMC__) \ - || (defined(_MSC_VER) && _MSC_VER < 1200) - #define wxUSE_STD_DEFAULT 0 -#else - #define wxUSE_STD_DEFAULT 1 -#endif - -// Use standard C++ containers to implement wxVector<>, wxStack<>, wxDList<> -// and wxHashXXX<> classes. If disabled, wxWidgets own (mostly compatible but -// usually more limited) implementations are used which allows to avoid the -// dependency on the C++ run-time library. -// -// Notice that the compilers mentioned in wxUSE_STD_DEFAULT comment above don't -// support using standard containers and that VC6 needs non-default options for -// such build to avoid getting "fatal error C1076: compiler limit : internal -// heap limit reached; use /Zm to specify a higher limit" in its own standard -// headers, so you need to ensure you do increase the heap size before enabling -// this option for this compiler. -// -// Default is 0 for compatibility reasons. -// -// Recommended setting: 1 unless compatibility with the official wxWidgets -// build and/or the existing code is a concern. -#define wxUSE_STD_CONTAINERS 0 - -// Use standard C++ streams if 1 instead of wx streams in some places. If -// disabled, wx streams are used everywhere and wxWidgets doesn't depend on the -// standard streams library. -// -// Notice that enabling this does not replace wx streams with std streams -// everywhere, in a lot of places wx streams are used no matter what. -// -// Default is 1 if compiler supports it. -// -// Recommended setting: 1 if you use the standard streams anyhow and so -// dependency on the standard streams library is not a -// problem -#define wxUSE_STD_IOSTREAM wxUSE_STD_DEFAULT - -// Enable minimal interoperability with the standard C++ string class if 1. -// "Minimal" means that wxString can be constructed from std::string or -// std::wstring but can't be implicitly converted to them. You need to enable -// the option below for the latter. -// -// Default is 1 for most compilers. -// -// Recommended setting: 1 unless you want to ensure your program doesn't use -// the standard C++ library at all. -#define wxUSE_STD_STRING wxUSE_STD_DEFAULT - -// Make wxString as much interchangeable with std::[w]string as possible, in -// particular allow implicit conversion of wxString to either of these classes. -// This comes at a price (or a benefit, depending on your point of view) of not -// allowing implicit conversion to "const char *" and "const wchar_t *". -// -// Because a lot of existing code relies on these conversions, this option is -// disabled by default but can be enabled for your build if you don't care -// about compatibility. -// -// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled. -// -// Recommended setting: 0 to remain compatible with the official builds of -// wxWidgets. -#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL - -// VC++ 4.2 and above allows and but you can't mix -// them. Set this option to 1 to use , 0 to use . -// -// Note that newer compilers (including VC++ 7.1 and later) don't support -// wxUSE_IOSTREAMH == 1 and so will be used anyhow. -// -// Default is 0. -// -// Recommended setting: 0, only set to 1 if you use a really old compiler -#define wxUSE_IOSTREAMH 0 - - -// ---------------------------------------------------------------------------- -// non GUI features selection -// ---------------------------------------------------------------------------- - -// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit -// integer which is implemented in terms of native 64 bit integers if any or -// uses emulation otherwise. -// -// This class is required by wxDateTime and so you should enable it if you want -// to use wxDateTime. For most modern platforms, it will use the native 64 bit -// integers in which case (almost) all of its functions are inline and it -// almost does not take any space, so there should be no reason to switch it -// off. -// -// Recommended setting: 1 -#define wxUSE_LONGLONG 1 - -// Set wxUSE_BASE64 to 1, to compile in Base64 support. This is required for -// storing binary data in wxConfig on most platforms. -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_BASE64 1 - -// Set this to 1 to be able to use wxEventLoop even in console applications -// (i.e. using base library only, without GUI). This is mostly useful for -// processing socket events but is also necessary to use timers in console -// applications -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_CONSOLE_EVENTLOOP 1 - -// Set wxUSE_(F)FILE to 1 to compile wx(F)File classes. wxFile uses low level -// POSIX functions for file access, wxFFile uses ANSI C stdio.h functions. -// -// Default is 1 -// -// Recommended setting: 1 (wxFile is highly recommended as it is required by -// i18n code, wxFileConfig and others) -#define wxUSE_FILE 1 -#define wxUSE_FFILE 1 - -// Use wxFSVolume class providing access to the configured/active mount points -// -// Default is 1 -// -// Recommended setting: 1 (but may be safely disabled if you don't use it) -#define wxUSE_FSVOLUME 1 - -// Use wxStandardPaths class which allows to retrieve some standard locations -// in the file system -// -// Default is 1 -// -// Recommended setting: 1 (may be disabled to save space, but not much) -#define wxUSE_STDPATHS 1 - -// use wxTextBuffer class: required by wxTextFile -#define wxUSE_TEXTBUFFER 1 - -// use wxTextFile class: requires wxFile and wxTextBuffer, required by -// wxFileConfig -#define wxUSE_TEXTFILE 1 - -// i18n support: _() macro, wxLocale class. Requires wxTextFile. -#define wxUSE_INTL 1 - -// Provide wxFoo_l() functions similar to standard foo() functions but taking -// an extra locale parameter. -// -// Notice that this is fully implemented only for the systems providing POSIX -// xlocale support or Microsoft Visual C++ >= 8 (which provides proprietary -// almost-equivalent of xlocale functions), otherwise wxFoo_l() functions will -// only work for the current user locale and "C" locale. You can use -// wxHAS_XLOCALE_SUPPORT to test whether the full support is available. -// -// Default is 1 -// -// Recommended setting: 1 but may be disabled if you are writing programs -// running only in C locale anyhow -#define wxUSE_XLOCALE 1 - -// Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which -// allow to manipulate dates, times and time intervals. wxDateTime replaces the -// old wxTime and wxDate classes which are still provided for backwards -// compatibility (and implemented in terms of wxDateTime). -// -// Note that this class is relatively new and is still officially in alpha -// stage because some features are not yet (fully) implemented. It is already -// quite useful though and should only be disabled if you are aiming at -// absolutely minimal version of the library. -// -// Requires: wxUSE_LONGLONG -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_DATETIME 1 - -// Set wxUSE_TIMER to 1 to compile wxTimer class -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_TIMER 1 - -// Use wxStopWatch clas. -// -// Default is 1 -// -// Recommended setting: 1 (needed by wxSocket) -#define wxUSE_STOPWATCH 1 - -// Set wxUSE_FSWATCHER to 1 if you want to enable wxFileSystemWatcher -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_FSWATCHER 1 - -// Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes -// which allow the application to store its settings in the persistent -// storage. Setting this to 1 will also enable on-demand creation of the -// global config object in wxApp. -// -// See also wxUSE_CONFIG_NATIVE below. -// -// Recommended setting: 1 -#define wxUSE_CONFIG 1 - -// If wxUSE_CONFIG is 1, you may choose to use either the native config -// classes under Windows (using .INI files under Win16 and the registry under -// Win32) or the portable text file format used by the config classes under -// Unix. -// -// Default is 1 to use native classes. Note that you may still use -// wxFileConfig even if you set this to 1 - just the config object created by -// default for the applications needs will be a wxRegConfig or wxIniConfig and -// not wxFileConfig. -// -// Recommended setting: 1 -#define wxUSE_CONFIG_NATIVE 1 - -// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows -// to connect/disconnect from the network and be notified whenever the dial-up -// network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_DIALUP_MANAGER 1 - -// Compile in classes for run-time DLL loading and function calling. -// Required by wxUSE_DIALUP_MANAGER. -// -// This setting is for Win32 only -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_DYNLIB_CLASS 1 - -// experimental, don't use for now -#define wxUSE_DYNAMIC_LOADER 1 - -// Set to 1 to use socket classes -#define wxUSE_SOCKETS 1 - -// Set to 1 to use ipv6 socket classes (requires wxUSE_SOCKETS) -// -// Notice that currently setting this option under Windows will result in -// programs which can only run on recent OS versions (with ws2_32.dll -// installed) which is why it is disabled by default. -// -// Default is 1. -// -// Recommended setting: 1 if you need IPv6 support -#define wxUSE_IPV6 0 - -// Set to 1 to enable virtual file systems (required by wxHTML) -#define wxUSE_FILESYSTEM 1 - -// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM) -#define wxUSE_FS_ZIP 1 - -// Set to 1 to enable virtual archive filesystem (requires wxUSE_FILESYSTEM) -#define wxUSE_FS_ARCHIVE 1 - -// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM) -#define wxUSE_FS_INET 1 - -// wxArchive classes for accessing archives such as zip and tar -#define wxUSE_ARCHIVE_STREAMS 1 - -// Set to 1 to compile wxZipInput/OutputStream classes. -#define wxUSE_ZIPSTREAM 1 - -// Set to 1 to compile wxTarInput/OutputStream classes. -#define wxUSE_TARSTREAM 1 - -// Set to 1 to compile wxZlibInput/OutputStream classes. Also required by -// wxUSE_LIBPNG -#define wxUSE_ZLIB 1 - -// If enabled, the code written by Apple will be used to write, in a portable -// way, float on the disk. See extended.c for the license which is different -// from wxWidgets one. -// -// Default is 1. -// -// Recommended setting: 1 unless you don't like the license terms (unlikely) -#define wxUSE_APPLE_IEEE 1 - -// Joystick support class -#define wxUSE_JOYSTICK 1 - -// wxFontEnumerator class -#define wxUSE_FONTENUM 1 - -// wxFontMapper class -#define wxUSE_FONTMAP 1 - -// wxMimeTypesManager class -#define wxUSE_MIMETYPE 1 - -// wxProtocol and related classes: if you want to use either of wxFTP, wxHTTP -// or wxURL you need to set this to 1. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_PROTOCOL 1 - -// The settings for the individual URL schemes -#define wxUSE_PROTOCOL_FILE 1 -#define wxUSE_PROTOCOL_FTP 1 -#define wxUSE_PROTOCOL_HTTP 1 - -// Define this to use wxURL class. -#define wxUSE_URL 1 - -// Define this to use native platform url and protocol support. -// Currently valid only for MS-Windows. -// Note: if you set this to 1, you can open ftp/http/gopher sites -// and obtain a valid input stream for these sites -// even when you set wxUSE_PROTOCOL_FTP/HTTP to 0. -// Doing so reduces the code size. -// -// This code is experimental and subject to change. -#define wxUSE_URL_NATIVE 0 - -// Support for wxVariant class used in several places throughout the library, -// notably in wxDataViewCtrl API. -// -// Default is 1. -// -// Recommended setting: 1 unless you want to reduce the library size as much as -// possible in which case setting this to 0 can gain up to 100KB. -#define wxUSE_VARIANT 1 - -// Support for wxAny class, the successor for wxVariant. -// -// Default is 1. -// -// Recommended setting: 1 unless you want to reduce the library size by a small amount, -// or your compiler cannot for some reason cope with complexity of templates used. -#define wxUSE_ANY 1 - -// Support for regular expression matching via wxRegEx class: enable this to -// use POSIX regular expressions in your code. You need to compile regex -// library from src/regex to use it under Windows. -// -// Default is 0 -// -// Recommended setting: 1 if your compiler supports it, if it doesn't please -// contribute us a makefile for src/regex for it -#define wxUSE_REGEX 1 - -// wxSystemOptions class -#define wxUSE_SYSTEM_OPTIONS 1 - -// wxSound class -#define wxUSE_SOUND 1 - -// Use wxMediaCtrl -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_MEDIACTRL 1 - -// Use wxWidget's XRC XML-based resource system. Recommended. -// -// Default is 1 -// -// Recommended setting: 1 (requires wxUSE_XML) -#define wxUSE_XRC 1 - -// XML parsing classes. Note that their API will change in the future, so -// using wxXmlDocument and wxXmlNode in your app is not recommended. -// -// Default is the same as wxUSE_XRC, i.e. 1 by default. -// -// Recommended setting: 1 (required by XRC) -#define wxUSE_XML wxUSE_XRC - -// Use wxWidget's AUI docking system -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_AUI 1 - -// Use wxWidget's Ribbon classes for interfaces -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_RIBBON 1 - -// Use wxPropertyGrid. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_PROPGRID 1 - -// Use wxStyledTextCtrl, a wxWidgets implementation of Scintilla. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_STC 1 - -// Use wxWidget's web viewing classes -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_WEBVIEW 1 - -// Use the IE wxWebView backend -// -// Default is 1 on MSW -// -// Recommended setting: 1 -#ifdef __WXMSW__ -#define wxUSE_WEBVIEW_IE 1 -#else -#define wxUSE_WEBVIEW_IE 0 -#endif - -// Use the WebKit wxWebView backend -// -// Default is 1 on GTK and OSX -// -// Recommended setting: 1 -#if defined(__WXGTK__) || defined(__WXOSX__) -#define wxUSE_WEBVIEW_WEBKIT 1 -#else -#define wxUSE_WEBVIEW_WEBKIT 0 -#endif - -// Enable the new wxGraphicsPath and wxGraphicsContext classes for an advanced -// 2D drawing API. (Still somewhat experimental) -// -// Please note that on Windows gdiplus.dll is loaded dynamically which means -// that nothing special needs to be done as long as you don't use -// wxGraphicsContext at all or only use it on XP and later systems but you -// still do need to distribute it yourself for an application using -// wxGraphicsContext to be runnable on pre-XP systems. -// -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC7+ is known to ship with gdiplus.h. For other compilers (e.g. -// mingw32) you may need to install the headers (and just the headers) -// yourself. If you do, change the setting below manually. -// -// Recommended setting: 1 if supported by the compilation environment - -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER -# if _MSC_VER >= 1310 - // MSVC7.1+ comes with new enough Platform SDK, enable - // wxGraphicsContext support for it -# define wxUSE_GRAPHICS_CONTEXT 1 -# else - // MSVC 6 didn't include GDI+ headers so disable by default, enable it - // here if you use MSVC 6 with a newer SDK -# define wxUSE_GRAPHICS_CONTEXT 0 -# endif -#else - // Disable support for other Windows compilers, enable it if your compiler - // comes with new enough SDK or you installed the headers manually. - // - // Notice that this will be set by configure under non-Windows platforms - // anyhow so the value there is not important. -# define wxUSE_GRAPHICS_CONTEXT 0 -#endif - -// Enable wxGraphicsContext implementation using Cairo library. -// -// This is not needed under Windows and detected automatically by configure -// under other systems, however you may set this to 1 manually if you installed -// Cairo under Windows yourself and prefer to use it instead the native GDI+ -// implementation. -// -// Default is 0 -// -// Recommended setting: 0 -#define wxUSE_CAIRO 0 - - -// ---------------------------------------------------------------------------- -// Individual GUI controls -// ---------------------------------------------------------------------------- - -// You must set wxUSE_CONTROLS to 1 if you are using any controls at all -// (without it, wxControl class is not compiled) -// -// Default is 1 -// -// Recommended setting: 1 (don't change except for very special programs) -#define wxUSE_CONTROLS 1 - -// Support markup in control labels, i.e. provide wxControl::SetLabelMarkup(). -// Currently markup is supported only by a few controls and only some ports but -// their number will increase with time. -// -// Default is 1 -// -// Recommended setting: 1 (may be set to 0 if you want to save on code size) -#define wxUSE_MARKUP 1 - -// wxPopupWindow class is a top level transient window. It is currently used -// to implement wxTipWindow -// -// Default is 1 -// -// Recommended setting: 1 (may be set to 0 if you don't wxUSE_TIPWINDOW) -#define wxUSE_POPUPWIN 1 - -// wxTipWindow allows to implement the custom tooltips, it is used by the -// context help classes. Requires wxUSE_POPUPWIN. -// -// Default is 1 -// -// Recommended setting: 1 (may be set to 0) -#define wxUSE_TIPWINDOW 1 - -// Each of the settings below corresponds to one wxWidgets control. They are -// all switched on by default but may be disabled if you are sure that your -// program (including any standard dialogs it can show!) doesn't need them and -// if you desperately want to save some space. If you use any of these you must -// set wxUSE_CONTROLS as well. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl -#define wxUSE_BANNERWINDOW 1 // wxBannerWindow -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COLLPANE 1 // wxCollapsiblePane -#define wxUSE_COLOURPICKERCTRL 1 // wxColourPickerCtrl -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_COMMANDLINKBUTTON 1 // wxCommandLinkButton -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_DIRPICKERCTRL 1 // wxDirPickerCtrl -#define wxUSE_EDITABLELISTBOX 1 // wxEditableListBox -#define wxUSE_FILECTRL 1 // wxFileCtrl -#define wxUSE_FILEPICKERCTRL 1 // wxFilePickerCtrl -#define wxUSE_FONTPICKERCTRL 1 // wxFontPickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_HEADERCTRL 1 // wxHeaderCtrl -#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_RICHMSGDLG 1 // wxRichMessageDialog -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SEARCHCTRL 1 // wxSearchCtrl -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TIMEPICKCTRL 1 // wxTimePickerCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl -#define wxUSE_TREELISTCTRL 1 // wxTreeListCtrl - -// Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR -// below either wxStatusBar95 or a generic wxStatusBar will be used. -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_STATUSBAR 1 - -// Two status bar implementations are available under Win32: the generic one -// or the wrapper around native control. For native look and feel the native -// version should be used. -// -// Default is 1 for the platforms where native status bar is supported. -// -// Recommended setting: 1 (there is no advantage in using the generic one) -#define wxUSE_NATIVE_STATUSBAR 1 - -// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar -// classes at all. Otherwise, use the native toolbar class unless -// wxUSE_TOOLBAR_NATIVE is 0. -// -// Default is 1 for all settings. -// -// Recommended setting: 1 for wxUSE_TOOLBAR and wxUSE_TOOLBAR_NATIVE. -#define wxUSE_TOOLBAR 1 -#define wxUSE_TOOLBAR_NATIVE 1 - -// wxNotebook is a control with several "tabs" located on one of its sides. It -// may be used to logically organise the data presented to the user instead of -// putting everything in one huge dialog. It replaces wxTabControl and related -// classes of wxWin 1.6x. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_NOTEBOOK 1 - -// wxListbook control is similar to wxNotebook but uses wxListCtrl instead of -// the tabs -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_LISTBOOK 1 - -// wxChoicebook control is similar to wxNotebook but uses wxChoice instead of -// the tabs -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_CHOICEBOOK 1 - -// wxTreebook control is similar to wxNotebook but uses wxTreeCtrl instead of -// the tabs -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_TREEBOOK 1 - -// wxToolbook control is similar to wxNotebook but uses wxToolBar instead of -// tabs -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_TOOLBOOK 1 - -// wxTaskBarIcon is a small notification icon shown in the system toolbar or -// dock. -// -// Default is 1. -// -// Recommended setting: 1 (but can be set to 0 if you don't need it) -#define wxUSE_TASKBARICON 1 - -// wxGrid class -// -// Default is 1, set to 0 to cut down compilation time and binaries size if you -// don't use it. -// -// Recommended setting: 1 -// -#define wxUSE_GRID 1 - -// wxMiniFrame class: a frame with narrow title bar -// -// Default is 1. -// -// Recommended setting: 1 (it doesn't cost almost anything) -#define wxUSE_MINIFRAME 1 - -// wxComboCtrl and related classes: combobox with custom popup window and -// not necessarily a listbox. -// -// Default is 1. -// -// Recommended setting: 1 but can be safely set to 0 except for wxUniv where it -// it used by wxComboBox -#define wxUSE_COMBOCTRL 1 - -// wxOwnerDrawnComboBox is a custom combobox allowing to paint the combobox -// items. -// -// Default is 1. -// -// Recommended setting: 1 but can be safely set to 0, except where it is -// needed as a base class for generic wxBitmapComboBox. -#define wxUSE_ODCOMBOBOX 1 - -// wxBitmapComboBox is a combobox that can have images in front of text items. -// -// Default is 1. -// -// Recommended setting: 1 but can be safely set to 0 -#define wxUSE_BITMAPCOMBOBOX 1 - -// wxRearrangeCtrl is a wxCheckListBox with two buttons allowing to move items -// up and down in it. It is also used as part of wxRearrangeDialog. -// -// Default is 1. -// -// Recommended setting: 1 but can be safely set to 0 (currently used only by -// wxHeaderCtrl) -#define wxUSE_REARRANGECTRL 1 - -// ---------------------------------------------------------------------------- -// Miscellaneous GUI stuff -// ---------------------------------------------------------------------------- - -// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar) -#define wxUSE_ACCEL 1 - -// Use the standard art provider. The icons returned by this provider are -// embedded into the library as XPMs so disabling it reduces the library size -// somewhat but this should only be done if you use your own custom art -// provider returning the icons or never use any icons not provided by the -// native art provider (which might not be implemented at all for some -// platforms) or by the Tango icons provider (if it's not itself disabled -// below). -// -// Default is 1. -// -// Recommended setting: 1 unless you use your own custom art provider. -#define wxUSE_ARTPROVIDER_STD 1 - -// Use art provider providing Tango icons: this art provider has higher quality -// icons than the default ones using smaller size XPM icons without -// transparency but the embedded PNG icons add to the library size. -// -// Default is 1 under non-GTK ports. Under wxGTK the native art provider using -// the GTK+ stock icons replaces it so it is normally not necessary. -// -// Recommended setting: 1 but can be turned off to reduce the library size. -#define wxUSE_ARTPROVIDER_TANGO 1 - -// Hotkey support (currently Windows only) -#define wxUSE_HOTKEY 1 - -// Use wxCaret: a class implementing a "cursor" in a text control (called caret -// under Windows). -// -// Default is 1. -// -// Recommended setting: 1 (can be safely set to 0, not used by the library) -#define wxUSE_CARET 1 - -// Use wxDisplay class: it allows enumerating all displays on a system and -// their geometries as well as finding the display on which the given point or -// window lies. -// -// Default is 1. -// -// Recommended setting: 1 if you need it, can be safely set to 0 otherwise -#define wxUSE_DISPLAY 1 - -// Miscellaneous geometry code: needed for Canvas library -#define wxUSE_GEOMETRY 1 - -// Use wxImageList. This class is needed by wxNotebook, wxTreeCtrl and -// wxListCtrl. -// -// Default is 1. -// -// Recommended setting: 1 (set it to 0 if you don't use any of the controls -// enumerated above, then this class is mostly useless too) -#define wxUSE_IMAGLIST 1 - -// Use wxInfoBar class. -// -// Default is 1. -// -// Recommended setting: 1 (but can be disabled without problems as nothing -// depends on it) -#define wxUSE_INFOBAR 1 - -// Use wxMenu, wxMenuBar, wxMenuItem. -// -// Default is 1. -// -// Recommended setting: 1 (can't be disabled under MSW) -#define wxUSE_MENUS 1 - -// Use wxNotificationMessage. -// -// wxNotificationMessage allows to show non-intrusive messages to the user -// using balloons, banners, popups or whatever is the appropriate method for -// the current platform. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_NOTIFICATION_MESSAGE 1 - -// wxPreferencesEditor provides a common API for different ways of presenting -// the standard "Preferences" or "Properties" dialog under different platforms -// (e.g. some use modal dialogs, some use modeless ones; some apply the changes -// immediately while others require an explicit "Apply" button). -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely disabled if you don't use it) -#define wxUSE_PREFERENCES_EDITOR 1 - -// wxRichToolTip is a customizable tooltip class which has more functionality -// than the stock (but native, unlike this class) wxToolTip. -// -// Default is 1. -// -// Recommended setting: 1 (but can be safely set to 0 if you don't need it) -#define wxUSE_RICHTOOLTIP 1 - -// Use wxSashWindow class. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_SASH 1 - -// Use wxSplitterWindow class. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_SPLITTER 1 - -// Use wxToolTip and wxWindow::Set/GetToolTip() methods. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_TOOLTIPS 1 - -// wxValidator class and related methods -#define wxUSE_VALIDATORS 1 - -// Use reference counted ID management: this means that wxWidgets will track -// the automatically allocated ids (those used when you use wxID_ANY when -// creating a window, menu or toolbar item &c) instead of just supposing that -// the program never runs out of them. This is mostly useful only under wxMSW -// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where -// long-running programs can run into problems with ids reuse without this. On -// the other platforms, where the ids have the full int range, this shouldn't -// be necessary. -#ifdef __WXMSW__ -#define wxUSE_AUTOID_MANAGEMENT 1 -#else -#define wxUSE_AUTOID_MANAGEMENT 0 -#endif - -// ---------------------------------------------------------------------------- -// common dialogs -// ---------------------------------------------------------------------------- - -// On rare occasions (e.g. using DJGPP) may want to omit common dialogs (e.g. -// file selector, printer dialog). Switching this off also switches off the -// printing architecture and interactive wxPrinterDC. -// -// Default is 1 -// -// Recommended setting: 1 (unless it really doesn't work) -#define wxUSE_COMMON_DIALOGS 1 - -// wxBusyInfo displays window with message when app is busy. Works in same way -// as wxBusyCursor -#define wxUSE_BUSYINFO 1 - -// Use single/multiple choice dialogs. -// -// Default is 1 -// -// Recommended setting: 1 (used in the library itself) -#define wxUSE_CHOICEDLG 1 - -// Use colour picker dialog -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_COLOURDLG 1 - -// wxDirDlg class for getting a directory name from user -#define wxUSE_DIRDLG 1 - -// TODO: setting to choose the generic or native one - -// Use file open/save dialogs. -// -// Default is 1 -// -// Recommended setting: 1 (used in many places in the library itself) -#define wxUSE_FILEDLG 1 - -// Use find/replace dialogs. -// -// Default is 1 -// -// Recommended setting: 1 (but may be safely set to 0) -#define wxUSE_FINDREPLDLG 1 - -// Use font picker dialog -// -// Default is 1 -// -// Recommended setting: 1 (used in the library itself) -#define wxUSE_FONTDLG 1 - -// Use wxMessageDialog and wxMessageBox. -// -// Default is 1 -// -// Recommended setting: 1 (used in the library itself) -#define wxUSE_MSGDLG 1 - -// progress dialog class for lengthy operations -#define wxUSE_PROGRESSDLG 1 - -// support for startup tips (wxShowTip &c) -#define wxUSE_STARTUP_TIPS 1 - -// text entry dialog and wxGetTextFromUser function -#define wxUSE_TEXTDLG 1 - -// number entry dialog -#define wxUSE_NUMBERDLG 1 - -// splash screen class -#define wxUSE_SPLASH 1 - -// wizards -#define wxUSE_WIZARDDLG 1 - -// Compile in wxAboutBox() function showing the standard "About" dialog. -// -// Default is 1 -// -// Recommended setting: 1 but can be set to 0 to save some space if you don't -// use this function -#define wxUSE_ABOUTDLG 1 - -// wxFileHistory class -// -// Default is 1 -// -// Recommended setting: 1 -#define wxUSE_FILE_HISTORY 1 - -// ---------------------------------------------------------------------------- -// Metafiles support -// ---------------------------------------------------------------------------- - -// Windows supports the graphics format known as metafile which is, though not -// portable, is widely used under Windows and so is supported by wxWin (under -// Windows only, of course). Win16 (Win3.1) used the so-called "Window -// MetaFiles" or WMFs which were replaced with "Enhanced MetaFiles" or EMFs in -// Win32 (Win9x, NT, 2000). Both of these are supported in wxWin and, by -// default, WMFs will be used under Win16 and EMFs under Win32. This may be -// changed by setting wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting -// wxUSE_ENH_METAFILE to 0. You may also set wxUSE_METAFILE to 0 to not compile -// in any metafile related classes at all. -// -// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS. -// -// Recommended setting: default or 0 for everything for portable programs. -#define wxUSE_METAFILE 1 -#define wxUSE_ENH_METAFILE 1 -#define wxUSE_WIN_METAFILES_ALWAYS 0 - -// ---------------------------------------------------------------------------- -// Big GUI components -// ---------------------------------------------------------------------------- - -// Set to 0 to disable MDI support. -// -// Requires wxUSE_NOTEBOOK under platforms other than MSW. -// -// Default is 1. -// -// Recommended setting: 1, can be safely set to 0. -#define wxUSE_MDI 1 - -// Set to 0 to disable document/view architecture -#define wxUSE_DOC_VIEW_ARCHITECTURE 1 - -// Set to 0 to disable MDI document/view architecture -// -// Requires wxUSE_MDI && wxUSE_DOC_VIEW_ARCHITECTURE -#define wxUSE_MDI_ARCHITECTURE 1 - -// Set to 0 to disable print/preview architecture code -#define wxUSE_PRINTING_ARCHITECTURE 1 - -// wxHTML sublibrary allows to display HTML in wxWindow programs and much, -// much more. -// -// Default is 1. -// -// Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a -// smaller library. -#define wxUSE_HTML 1 - -// Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL -// headers and libraries to be able to compile the library with wxUSE_GLCANVAS -// set to 1 and, under Windows, also to add opengl32.lib and glu32.lib to the -// list of libraries used to link your application (although this is done -// implicitly for Microsoft Visual C++ users). -// -// Default is 1 unless the compiler is known to ship without the necessary -// headers (Digital Mars) or the platform doesn't support OpenGL (Windows CE). -// -// Recommended setting: 1 if you intend to use OpenGL, can be safely set to 0 -// otherwise. -#define wxUSE_GLCANVAS 1 - -// wxRichTextCtrl allows editing of styled text. -// -// Default is 1. -// -// Recommended setting: 1, set to 0 if you want compile a -// smaller library. -#define wxUSE_RICHTEXT 1 - -// ---------------------------------------------------------------------------- -// Data transfer -// ---------------------------------------------------------------------------- - -// Use wxClipboard class for clipboard copy/paste. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_CLIPBOARD 1 - -// Use wxDataObject and related classes. Needed for clipboard and OLE drag and -// drop -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_DATAOBJ 1 - -// Use wxDropTarget and wxDropSource classes for drag and drop (this is -// different from "built in" drag and drop in wxTreeCtrl which is always -// available). Requires wxUSE_DATAOBJ. -// -// Default is 1. -// -// Recommended setting: 1 -#define wxUSE_DRAG_AND_DROP 1 - -// Use wxAccessible for enhanced and customisable accessibility. -// Depends on wxUSE_OLE. -// -// Default is 0. -// -// Recommended setting (at present): 0 -#define wxUSE_ACCESSIBILITY 0 - -// ---------------------------------------------------------------------------- -// miscellaneous settings -// ---------------------------------------------------------------------------- - -// wxSingleInstanceChecker class allows to verify at startup if another program -// instance is running. -// -// Default is 1 -// -// Recommended setting: 1 (the class is tiny, disabling it won't save much -// space) -#define wxUSE_SNGLINST_CHECKER 1 - -#define wxUSE_DRAGIMAGE 1 - -#define wxUSE_IPC 1 - // 0 for no interprocess comms -#define wxUSE_HELP 1 - // 0 for no help facility - -// Should we use MS HTML help for wxHelpController? If disabled, neither -// wxCHMHelpController nor wxBestHelpController are available. -// -// Default is 1 under MSW, 0 is always used for the other platforms. -// -// Recommended setting: 1, only set to 0 if you have trouble compiling -// wxCHMHelpController (could be a problem with really ancient compilers) -#define wxUSE_MS_HTML_HELP 1 - - -// Use wxHTML-based help controller? -#define wxUSE_WXHTML_HELP 1 - -#define wxUSE_CONSTRAINTS 1 - // 0 for no window layout constraint system - -#define wxUSE_SPLINES 1 - // 0 for no splines - -#define wxUSE_MOUSEWHEEL 1 - // Include mouse wheel support - -// Compile wxUIActionSimulator class? -#define wxUSE_UIACTIONSIMULATOR 1 - -// ---------------------------------------------------------------------------- -// wxDC classes for various output formats -// ---------------------------------------------------------------------------- - -// Set to 1 for PostScript device context. -#define wxUSE_POSTSCRIPT 0 - -// Set to 1 to use font metric files in GetTextExtent -#define wxUSE_AFM_FOR_POSTSCRIPT 1 - -// Set to 1 to compile in support for wxSVGFileDC, a wxDC subclass which allows -// to create files in SVG (Scalable Vector Graphics) format. -#define wxUSE_SVG 1 - -// Should wxDC provide SetTransformMatrix() and related methods? -// -// Default is 1 but can be set to 0 if this functionality is not used. Notice -// that currently only wxMSW supports this so setting this to 0 doesn't change -// much for non-MSW platforms (although it will still save a few bytes -// probably). -// -// Recommended setting: 1. -#define wxUSE_DC_TRANSFORM_MATRIX 1 - -// ---------------------------------------------------------------------------- -// image format support -// ---------------------------------------------------------------------------- - -// wxImage supports many different image formats which can be configured at -// compile-time. BMP is always supported, others are optional and can be safely -// disabled if you don't plan to use images in such format sometimes saving -// substantial amount of code in the final library. -// -// Some formats require an extra library which is included in wxWin sources -// which is mentioned if it is the case. - -// Set to 1 for wxImage support (recommended). -#define wxUSE_IMAGE 1 - -// Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB. -#define wxUSE_LIBPNG 1 - -// Set to 1 for JPEG format support (requires libjpeg) -#define wxUSE_LIBJPEG 1 - -// Set to 1 for TIFF format support (requires libtiff) -#define wxUSE_LIBTIFF 1 - -// Set to 1 for TGA format support (loading only) -#define wxUSE_TGA 1 - -// Set to 1 for GIF format support -#define wxUSE_GIF 1 - -// Set to 1 for PNM format support -#define wxUSE_PNM 1 - -// Set to 1 for PCX format support -#define wxUSE_PCX 1 - -// Set to 1 for IFF format support (Amiga format) -#define wxUSE_IFF 0 - -// Set to 1 for XPM format support -#define wxUSE_XPM 1 - -// Set to 1 for MS Icons and Cursors format support -#define wxUSE_ICO_CUR 1 - -// Set to 1 to compile in wxPalette class -#define wxUSE_PALETTE 1 - -// ---------------------------------------------------------------------------- -// wxUniversal-only options -// ---------------------------------------------------------------------------- - -// Set to 1 to enable compilation of all themes, this is the default -#define wxUSE_ALL_THEMES 1 - -// Set to 1 to enable the compilation of individual theme if wxUSE_ALL_THEMES -// is unset, if it is set these options are not used; notice that metal theme -// uses Win32 one -#define wxUSE_THEME_GTK 0 -#define wxUSE_THEME_METAL 0 -#define wxUSE_THEME_MONO 0 -#define wxUSE_THEME_WIN32 0 - - diff --git a/Source/3rd Party/wx/include/wx/setup_redirect.h b/Source/3rd Party/wx/include/wx/setup_redirect.h deleted file mode 100644 index 7648c198b..000000000 --- a/Source/3rd Party/wx/include/wx/setup_redirect.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * wx/setup.h - * - * This file should not normally be used, except where makefiles - * have not yet been adjusted to take into account of the new scheme - * whereby a setup.h is created under the lib directory. - * - * Copyright: (c) Vadim Zeitlin - * Licence: wxWindows Licence - */ - -#ifdef __WXMSW__ -#include "wx/msw/setup.h" -#else -#error Please adjust your include path to pick up the wx/setup.h file under lib first. -#endif - diff --git a/Source/3rd Party/wx/include/wx/sharedptr.h b/Source/3rd Party/wx/include/wx/sharedptr.h deleted file mode 100644 index a9b6442c0..000000000 --- a/Source/3rd Party/wx/include/wx/sharedptr.h +++ /dev/null @@ -1,169 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sharedptr.h -// Purpose: Shared pointer based on the counted_ptr<> template, which -// is in the public domain -// Author: Robert Roebling, Yonat Sharon -// Copyright: Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SHAREDPTR_H_ -#define _WX_SHAREDPTR_H_ - -#include "wx/defs.h" -#include "wx/atomic.h" - -// ---------------------------------------------------------------------------- -// wxSharedPtr: A smart pointer with non-intrusive reference counting. -// ---------------------------------------------------------------------------- - -template -class wxSharedPtr -{ -public: - typedef T element_type; - - wxEXPLICIT wxSharedPtr( T* ptr = NULL ) - : m_ref(NULL) - { - if (ptr) - m_ref = new reftype(ptr); - } - - template - wxEXPLICIT wxSharedPtr(T* ptr, Deleter d) - : m_ref(NULL) - { - if (ptr) - m_ref = new reftype_with_deleter(ptr, d); - } - - ~wxSharedPtr() { Release(); } - wxSharedPtr(const wxSharedPtr& tocopy) { Acquire(tocopy.m_ref); } - - wxSharedPtr& operator=( const wxSharedPtr& tocopy ) - { - if (this != &tocopy) - { - Release(); - Acquire(tocopy.m_ref); - } - return *this; - } - - wxSharedPtr& operator=( T* ptr ) - { - if (get() != ptr) - { - Release(); - if (ptr) - m_ref = new reftype(ptr); - } - return *this; - } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxSharedPtr::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - if (m_ref && m_ref->m_ptr) - return &wxSharedPtr::get; - else - return NULL; - } - - T& operator*() const - { - wxASSERT(m_ref != NULL); - wxASSERT(m_ref->m_ptr != NULL); - return *(m_ref->m_ptr); - } - - T* operator->() const - { - wxASSERT(m_ref != NULL); - wxASSERT(m_ref->m_ptr != NULL); - return m_ref->m_ptr; - } - - T* get() const - { - return m_ref ? m_ref->m_ptr : NULL; - } - - void reset( T* ptr = NULL ) - { - Release(); - if (ptr) - m_ref = new reftype(ptr); - } - - template - void reset(T* ptr, Deleter d) - { - Release(); - if (ptr) - m_ref = new reftype_with_deleter(ptr, d); - } - - bool unique() const { return (m_ref ? m_ref->m_count == 1 : true); } - long use_count() const { return (m_ref ? (long)m_ref->m_count : 0); } - -private: - - struct reftype - { - reftype(T* ptr) : m_ptr(ptr), m_count(1) {} - virtual ~reftype() {} - virtual void delete_ptr() { delete m_ptr; } - - T* m_ptr; - wxAtomicInt m_count; - }; - - template - struct reftype_with_deleter : public reftype - { - reftype_with_deleter(T* ptr, Deleter d) : reftype(ptr), m_deleter(d) {} - virtual void delete_ptr() { m_deleter(this->m_ptr); } - - Deleter m_deleter; - }; - - reftype* m_ref; - - void Acquire(reftype* ref) - { - m_ref = ref; - if (ref) - wxAtomicInc( ref->m_count ); - } - - void Release() - { - if (m_ref) - { - if (!wxAtomicDec( m_ref->m_count )) - { - m_ref->delete_ptr(); - delete m_ref; - } - m_ref = NULL; - } - } -}; - -template -bool operator == (wxSharedPtr const &a, wxSharedPtr const &b ) -{ - return a.get() == b.get(); -} - -template -bool operator != (wxSharedPtr const &a, wxSharedPtr const &b ) -{ - return a.get() != b.get(); -} - -#endif // _WX_SHAREDPTR_H_ diff --git a/Source/3rd Party/wx/include/wx/simplebook.h b/Source/3rd Party/wx/include/wx/simplebook.h deleted file mode 100644 index 78cc87215..000000000 --- a/Source/3rd Party/wx/include/wx/simplebook.h +++ /dev/null @@ -1,222 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/simplebook.h -// Purpose: wxBookCtrlBase-derived class without any controller. -// Author: Vadim Zeitlin -// Created: 2012-08-21 -// Copyright: (c) 2012 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SIMPLEBOOK_H_ -#define _WX_SIMPLEBOOK_H_ - -#include "wx/bookctrl.h" - -#if wxUSE_BOOKCTRL - -#include "wx/vector.h" - -// ---------------------------------------------------------------------------- -// wxSimplebook: a book control without any user-actionable controller. -// ---------------------------------------------------------------------------- - -// NB: This class doesn't use DLL export declaration as it's fully inline. - -class wxSimplebook : public wxBookCtrlBase -{ -public: - wxSimplebook() - { - Init(); - } - - wxSimplebook(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxEmptyString) - : wxBookCtrlBase(parent, winid, pos, size, style | wxBK_TOP, name) - { - Init(); - } - - bool Create(wxWindow *parent, - wxWindowID winid = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxEmptyString) - { - return wxBookCtrlBase::Create(parent, winid, pos, size, style | wxBK_TOP, name); - } - - - // Methods specific to this class. - - // A method allowing to add a new page without any label (which is unused - // by this control) and show it immediately. - bool ShowNewPage(wxWindow* page) - { - return AddPage(page, wxString(), true /* select it */); - } - - - // Set effect to use for showing/hiding pages. - void SetEffects(wxShowEffect showEffect, wxShowEffect hideEffect) - { - m_showEffect = showEffect; - m_hideEffect = hideEffect; - } - - // Or the same effect for both of them. - void SetEffect(wxShowEffect effect) - { - SetEffects(effect, effect); - } - - // And the same for time outs. - void SetEffectsTimeouts(unsigned showTimeout, unsigned hideTimeout) - { - m_showTimeout = showTimeout; - m_hideTimeout = hideTimeout; - } - - void SetEffectTimeout(unsigned timeout) - { - SetEffectsTimeouts(timeout, timeout); - } - - - // Implement base class pure virtual methods. - - // Page management - virtual bool InsertPage(size_t n, - wxWindow *page, - const wxString& text, - bool bSelect = false, - int imageId = NO_IMAGE) - { - if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) ) - return false; - - m_pageTexts.insert(m_pageTexts.begin() + n, text); - - if ( !DoSetSelectionAfterInsertion(n, bSelect) ) - page->Hide(); - - return true; - } - - virtual int SetSelection(size_t n) - { - return DoSetSelection(n, SetSelection_SendEvent); - } - - virtual int ChangeSelection(size_t n) - { - return DoSetSelection(n); - } - - // Neither labels nor images are supported but we still store the labels - // just in case the user code attaches some importance to them. - virtual bool SetPageText(size_t n, const wxString& strText) - { - wxCHECK_MSG( n < GetPageCount(), false, wxS("Invalid page") ); - - m_pageTexts[n] = strText; - - return true; - } - - virtual wxString GetPageText(size_t n) const - { - wxCHECK_MSG( n < GetPageCount(), wxString(), wxS("Invalid page") ); - - return m_pageTexts[n]; - } - - virtual bool SetPageImage(size_t WXUNUSED(n), int WXUNUSED(imageId)) - { - return false; - } - - virtual int GetPageImage(size_t WXUNUSED(n)) const - { - return NO_IMAGE; - } - -protected: - virtual void UpdateSelectedPage(size_t newsel) - { - m_selection = (int)newsel; - } - - virtual wxBookCtrlEvent* CreatePageChangingEvent() const - { - return new wxBookCtrlEvent(wxEVT_BOOKCTRL_PAGE_CHANGING, - GetId()); - } - - virtual void MakeChangedEvent(wxBookCtrlEvent& event) - { - event.SetEventType(wxEVT_BOOKCTRL_PAGE_CHANGED); - } - - virtual wxWindow *DoRemovePage(size_t page) - { - wxWindow* const win = wxBookCtrlBase::DoRemovePage(page); - if ( win ) - { - m_pageTexts.erase(m_pageTexts.begin() + page); - - DoSetSelectionAfterRemoval(page); - } - - return win; - } - - virtual void DoSize() - { - wxWindow* const page = GetCurrentPage(); - if ( page ) - page->SetSize(GetPageRect()); - } - - virtual void DoShowPage(wxWindow* page, bool show) - { - if ( show ) - page->ShowWithEffect(m_showEffect, m_showTimeout); - else - page->HideWithEffect(m_hideEffect, m_hideTimeout); - } - -private: - void Init() - { - // We don't need any border as we don't have anything to separate the - // page contents from. - SetInternalBorder(0); - - // No effects by default. - m_showEffect = - m_hideEffect = wxSHOW_EFFECT_NONE; - - m_showTimeout = - m_hideTimeout = 0; - } - - wxVector m_pageTexts; - - wxShowEffect m_showEffect, - m_hideEffect; - - unsigned m_showTimeout, - m_hideTimeout; - - wxDECLARE_NO_COPY_CLASS(wxSimplebook); -}; - -#endif // wxUSE_BOOKCTRL - -#endif // _WX_SIMPLEBOOK_H_ diff --git a/Source/3rd Party/wx/include/wx/sizer.h b/Source/3rd Party/wx/include/wx/sizer.h index a86ef8caa..e95ab437e 100644 --- a/Source/3rd Party/wx/include/wx/sizer.h +++ b/Source/3rd Party/wx/include/wx/sizer.h @@ -4,6 +4,7 @@ // Author: Robert Roebling and Robin Dunn // Modified by: Ron Lee, Vadim Zeitlin (wxSizerFlags) // Created: +// RCS-ID: $Id: sizer.h 52331 2008-03-05 15:02:22Z VS $ // Copyright: (c) Robin Dunn, Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,6 +24,8 @@ class WXDLLIMPEXP_FWD_CORE wxButton; class WXDLLIMPEXP_FWD_CORE wxBoxSizer; class WXDLLIMPEXP_FWD_CORE wxSizerItem; class WXDLLIMPEXP_FWD_CORE wxSizer; +class WXDLLIMPEXP_FWD_CORE wxFlexGridSizer; +class WXDLLIMPEXP_FWD_CORE wxGridBagSizer; #ifndef wxUSE_BORDER_BY_DEFAULT #ifdef __SMARTPHONE__ @@ -37,7 +40,7 @@ class WXDLLIMPEXP_FWD_CORE wxSizer; // wxSizerFlags: flags used for an item in the sizer // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSizerFlags +class WXDLLEXPORT wxSizerFlags { public: // construct the flags object initialized with the given proportion (0 by @@ -57,15 +60,6 @@ public: return *this; } - wxSizerFlags& Expand() - { - m_flags |= wxEXPAND; - return *this; - } - - // notice that Align() replaces the current alignment flags, use specific - // methods below such as Top(), Left() &c if you want to set just the - // vertical or horizontal alignment wxSizerFlags& Align(int alignment) // combination of wxAlignment values { m_flags &= ~wxALIGN_MASK; @@ -74,48 +68,30 @@ public: return *this; } + wxSizerFlags& Expand() + { + m_flags |= wxEXPAND; + return *this; + } + // some shortcuts for Align() - wxSizerFlags& Centre() { return Align(wxALIGN_CENTRE); } + wxSizerFlags& Centre() { return Align(wxCENTRE); } wxSizerFlags& Center() { return Centre(); } + wxSizerFlags& Left() { return Align(wxALIGN_LEFT); } + wxSizerFlags& Right() { return Align(wxALIGN_RIGHT); } - wxSizerFlags& Top() - { - m_flags &= ~(wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL); - return *this; - } - - wxSizerFlags& Left() - { - m_flags &= ~(wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL); - return *this; - } - - wxSizerFlags& Right() - { - m_flags = (m_flags & ~wxALIGN_CENTRE_HORIZONTAL) | wxALIGN_RIGHT; - return *this; - } - - wxSizerFlags& Bottom() - { - m_flags = (m_flags & ~wxALIGN_CENTRE_VERTICAL) | wxALIGN_BOTTOM; - return *this; - } - +#if wxABI_VERSION >= 20802 + wxSizerFlags& Top() { return Align(wxALIGN_TOP); } + wxSizerFlags& Bottom() { return Align(wxALIGN_BOTTOM); } +#endif // wxABI 2.8.2+ // default border size used by Border() below static int GetDefaultBorder() { #if wxUSE_BORDER_BY_DEFAULT - #ifdef __WXGTK20__ - // GNOME HIG says to use 6px as the base unit: - // http://library.gnome.org/devel/hig-book/stable/design-window.html.en - return 6; - #else // FIXME: default border size shouldn't be hardcoded and at the very // least they should depend on the current font size return 5; - #endif #else return 0; #endif @@ -124,10 +100,6 @@ public: wxSizerFlags& Border(int direction, int borderInPixels) { - wxCHECK_MSG( !(direction & ~wxALL), *this, - wxS("direction must be a combination of wxDirection ") - wxS("enum values.") ); - m_flags &= ~wxALL; m_flags |= direction; @@ -188,6 +160,7 @@ public: #endif } +#if wxABI_VERSION >= 20802 // setters for the others flags wxSizerFlags& Shaped() { @@ -202,13 +175,12 @@ public: return *this; } +#endif // wx 2.8.2+ +#if wxABI_VERSION >= 20808 // makes the item ignore window's visibility status - wxSizerFlags& ReserveSpaceEvenIfHidden() - { - m_flags |= wxRESERVE_SPACE_EVEN_IF_HIDDEN; - return *this; - } + wxSizerFlags& ReserveSpaceEvenIfHidden(); +#endif // accessors for wxSizer only int GetProportion() const { return m_proportion; } @@ -226,7 +198,7 @@ private: // wxSizerSpacer: used by wxSizerItem to represent a spacer // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSizerSpacer +class WXDLLEXPORT wxSizerSpacer { public: wxSizerSpacer(const wxSize& size) : m_size(size), m_isShown(true) { } @@ -249,53 +221,53 @@ private: // wxSizerItem // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSizerItem : public wxObject +class WXDLLEXPORT wxSizerItem : public wxObject { public: // window wxSizerItem( wxWindow *window, - int proportion=0, - int flag=0, - int border=0, - wxObject* userData=NULL ); + int proportion, + int flag, + int border, + wxObject* userData ); // window with flags wxSizerItem(wxWindow *window, const wxSizerFlags& flags) { Init(flags); - DoSetWindow(window); + SetWindow(window); } // subsizer wxSizerItem( wxSizer *sizer, - int proportion=0, - int flag=0, - int border=0, - wxObject* userData=NULL ); + int proportion, + int flag, + int border, + wxObject* userData ); // sizer with flags wxSizerItem(wxSizer *sizer, const wxSizerFlags& flags) { Init(flags); - DoSetSizer(sizer); + SetSizer(sizer); } // spacer wxSizerItem( int width, int height, - int proportion=0, - int flag=0, - int border=0, - wxObject* userData=NULL); + int proportion, + int flag, + int border, + wxObject* userData); // spacer with flags wxSizerItem(int width, int height, const wxSizerFlags& flags) { Init(flags); - DoSetSpacer(wxSize(width, height)); + SetSpacer(width, height); } wxSizerItem(); @@ -314,10 +286,6 @@ public: { return m_minSize; } wxSize GetMinSizeWithBorder() const; - wxSize GetMaxSize() const - { return IsWindow() ? m_window->GetMaxSize() : wxDefaultSize; } - wxSize GetMaxSizeWithBorder() const; - void SetMinSize(const wxSize& size) { if ( IsWindow() ) @@ -342,11 +310,6 @@ public: virtual wxRect GetRect() { return m_rect; } - // set a sizer item id (different from a window id, all sizer items, - // including spacers, can have an associated id) - void SetId(int id) { m_id = id; } - int GetId() const { return m_id; } - bool IsWindow() const { return m_kind == Item_Window; } bool IsSizer() const { return m_kind == Item_Sizer; } bool IsSpacer() const { return m_kind == Item_Spacer; } @@ -376,12 +339,10 @@ public: { return m_kind == Item_Sizer ? m_sizer : NULL; } wxSize GetSpacer() const; - // This function behaves obviously for the windows and spacers but for the + // this function behaves obviously for the windows and spacers but for the // sizers it returns true if any sizer element is shown and only returns - // false if all of them are hidden. Also, it always returns true if - // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was used. + // false if all of them are hidden bool IsShown() const; - void Show(bool show); void SetUserData(wxObject* userData) @@ -391,61 +352,20 @@ public: wxPoint GetPosition() const { return m_pos; } - // Called once the first component of an item has been decided. This is - // used in algorithms that depend on knowing the size in one direction - // before the min size in the other direction can be known. - // Returns true if it made use of the information (and min size was changed). - bool InformFirstDirection( int direction, int size, int availableOtherDir=-1 ); - // these functions delete the current contents of the item if it's a sizer - // or a spacer but not if it is a window - void AssignWindow(wxWindow *window) - { - Free(); - DoSetWindow(window); - } - - void AssignSizer(wxSizer *sizer) - { - Free(); - DoSetSizer(sizer); - } - - void AssignSpacer(const wxSize& size) - { - Free(); - DoSetSpacer(size); - } - - void AssignSpacer(int w, int h) { AssignSpacer(wxSize(w, h)); } - -#if WXWIN_COMPATIBILITY_2_8 - // these functions do not free the old sizer/spacer and so can easily - // provoke the memory leaks and so shouldn't be used, use Assign() instead - wxDEPRECATED( void SetWindow(wxWindow *window) ); - wxDEPRECATED( void SetSizer(wxSizer *sizer) ); - wxDEPRECATED( void SetSpacer(const wxSize& size) ); - wxDEPRECATED( void SetSpacer(int width, int height) ); -#endif // WXWIN_COMPATIBILITY_2_8 + // these functions do not free old sizer/spacer + void SetWindow(wxWindow *window); + void SetSizer(wxSizer *sizer); + void SetSpacer(const wxSize& size); + void SetSpacer(int width, int height) { SetSpacer(wxSize(width, height)); } protected: // common part of several ctors - void Init() { m_userData = NULL; m_kind = Item_None; } + void Init() { m_userData = NULL; } // common part of ctors taking wxSizerFlags void Init(const wxSizerFlags& flags); - // free current contents - void Free(); - - // common parts of Set/AssignXXX() - void DoSetWindow(wxWindow *window); - void DoSetSizer(wxSizer *sizer); - void DoSetSpacer(const wxSize& size); - - // Add the border specified for this item to the given size - // if it's != wxDefaultSize, just return wxDefaultSize otherwise. - wxSize AddBorderToSize(const wxSize& size) const; // discriminated union: depending on m_kind one of the fields is valid enum @@ -468,7 +388,6 @@ protected: int m_proportion; int m_border; int m_flag; - int m_id; // on screen rectangle of this item (not including borders) wxRect m_rect; @@ -481,8 +400,15 @@ protected: wxObject *m_userData; private: + // 2.8-only implementation detail for wxRESERVE_SPACE_EVEN_IF_HIDDEN + bool ShouldAccountFor() const; + DECLARE_CLASS(wxSizerItem) - wxDECLARE_NO_COPY_CLASS(wxSizerItem); + DECLARE_NO_COPY_CLASS(wxSizerItem) + + friend class wxBoxSizer; + friend class wxFlexGridSizer; + friend class wxGridBagSizer; }; WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList ); @@ -492,7 +418,7 @@ WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList ); // wxSizer //--------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSizer: public wxObject, public wxClientDataContainer +class WXDLLEXPORT wxSizer: public wxObject, public wxClientDataContainer { public: wxSizer() { m_containingWindow = NULL; } @@ -518,10 +444,9 @@ public: wxObject* userData = NULL); wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags); wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags); - wxSizerItem* Add( int width, int height, const wxSizerFlags& flags); wxSizerItem* Add( wxSizerItem *item); - virtual wxSizerItem *AddSpacer(int size); + wxSizerItem* AddSpacer(int size); wxSizerItem* AddStretchSpacer(int prop = 1); wxSizerItem* Insert(size_t index, @@ -549,15 +474,7 @@ public: wxSizerItem* Insert(size_t index, wxSizer *sizer, const wxSizerFlags& flags); - wxSizerItem* Insert(size_t index, - int width, - int height, - const wxSizerFlags& flags); - - // NB: do _not_ override this function in the derived classes, this one is - // virtual for compatibility reasons only to allow old code overriding - // it to continue to work, override DoInsert() instead in the new code - virtual wxSizerItem* Insert(size_t index, wxSizerItem *item); + virtual wxSizerItem* Insert( size_t index, wxSizerItem *item); wxSizerItem* InsertSpacer(size_t index, int size); wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1); @@ -580,7 +497,6 @@ public: wxObject* userData = NULL); wxSizerItem* Prepend(wxWindow *window, const wxSizerFlags& flags); wxSizerItem* Prepend(wxSizer *sizer, const wxSizerFlags& flags); - wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags); wxSizerItem* Prepend(wxSizerItem *item); wxSizerItem* PrependSpacer(int size); @@ -611,11 +527,6 @@ public: virtual void Clear( bool delete_windows = false ); virtual void DeleteWindows(); - // Inform sizer about the first direction that has been decided (by parent item) - // Returns true if it made use of the information (and recalculated min size) - virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) ) - { return false; } - void SetMinSize( int width, int height ) { DoSetMinSize( width, height ); } void SetMinSize( const wxSize& size ) @@ -646,51 +557,29 @@ public: // Calculate the minimal size or return m_minSize if bigger. wxSize GetMinSize(); - // These virtual functions are used by the layout algorithm: first - // CalcMin() is called to calculate the minimal size of the sizer and - // prepare for laying it out and then RecalcSizes() is called to really - // update all the sizer items - virtual wxSize CalcMin() = 0; virtual void RecalcSizes() = 0; + virtual wxSize CalcMin() = 0; virtual void Layout(); +#if wxABI_VERSION >= 20808 wxSize ComputeFittingClientSize(wxWindow *window); wxSize ComputeFittingWindowSize(wxWindow *window); +#endif wxSize Fit( wxWindow *window ); void FitInside( wxWindow *window ); void SetSizeHints( wxWindow *window ); -#if WXWIN_COMPATIBILITY_2_8 - // This only calls FitInside() since 2.9 - wxDEPRECATED( void SetVirtualSizeHints( wxWindow *window ) ); -#endif + void SetVirtualSizeHints( wxWindow *window ); wxSizerItemList& GetChildren() { return m_children; } - const wxSizerItemList& GetChildren() const - { return m_children; } - void SetDimension(const wxPoint& pos, const wxSize& size) - { - m_position = pos; - m_size = size; - Layout(); - - // This call is required for wxWrapSizer to be able to calculate its - // minimal size correctly. - InformFirstDirection(wxHORIZONTAL, size.x, size.y); - } - void SetDimension(int x, int y, int width, int height) - { SetDimension(wxPoint(x, y), wxSize(width, height)); } - - size_t GetItemCount() const { return m_children.GetCount(); } - bool IsEmpty() const { return m_children.IsEmpty(); } + void SetDimension( int x, int y, int width, int height ); wxSizerItem* GetItem( wxWindow *window, bool recursive = false ); wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false ); wxSizerItem* GetItem( size_t index ); - wxSizerItem* GetItemById( int id, bool recursive = false ); // Manage whether individual scene items are considered // in the layout calculations or not. @@ -714,10 +603,6 @@ public: void Show(bool show) { ShowItems(show); } - // This is the ShowItems() counterpart and returns true if any of the sizer - // items are shown. - virtual bool AreAnyItemsShown() const; - protected: wxSize m_size; wxSize m_minSize; @@ -727,6 +612,8 @@ protected: // the window this sizer is used in, can be NULL wxWindow *m_containingWindow; + wxSize GetMaxWindowSize( wxWindow *window ) const; + wxSize GetMinWindowSize( wxWindow *window ); wxSize GetMaxClientSize( wxWindow *window ) const; wxSize GetMinClientSize( wxWindow *window ); wxSize VirtualFitSize( wxWindow *window ); @@ -736,10 +623,6 @@ protected: virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height ); virtual bool DoSetItemMinSize( size_t index, int width, int height ); - // insert a new item into m_children at given index and return the item - // itself - virtual wxSizerItem* DoInsert(size_t index, wxSizerItem *item); - private: DECLARE_CLASS(wxSizer) }; @@ -748,33 +631,17 @@ private: // wxGridSizer //--------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGridSizer: public wxSizer +class WXDLLEXPORT wxGridSizer: public wxSizer { public: - // ctors specifying the number of columns only: number of rows will be - // deduced automatically depending on the number of sizer elements - wxGridSizer( int cols, int vgap, int hgap ); - wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); - - // ctors specifying the number of rows and columns wxGridSizer( int rows, int cols, int vgap, int hgap ); - wxGridSizer( int rows, int cols, const wxSize& gap ); + wxGridSizer( int cols, int vgap = 0, int hgap = 0 ); virtual void RecalcSizes(); virtual wxSize CalcMin(); - void SetCols( int cols ) - { - wxASSERT_MSG( cols >= 0, "Number of columns must be non-negative"); - m_cols = cols; - } - - void SetRows( int rows ) - { - wxASSERT_MSG( rows >= 0, "Number of rows must be non-negative"); - m_rows = rows; - } - + void SetCols( int cols ) { m_cols = cols; } + void SetRows( int rows ) { m_rows = rows; } void SetVGap( int gap ) { m_vgap = gap; } void SetHGap( int gap ) { m_hgap = gap; } int GetCols() const { return m_cols; } @@ -782,51 +649,17 @@ public: int GetVGap() const { return m_vgap; } int GetHGap() const { return m_hgap; } - int GetEffectiveColsCount() const { return m_cols ? m_cols : CalcCols(); } - int GetEffectiveRowsCount() const { return m_rows ? m_rows : CalcRows(); } - - // return the number of total items and the number of columns and rows - // (for internal use only) - int CalcRowsCols(int& rows, int& cols) const; - protected: - // the number of rows/columns in the sizer, if 0 then it is determined - // dynamically depending on the total number of items int m_rows; int m_cols; - - // gaps between rows and columns int m_vgap; int m_hgap; - virtual wxSizerItem *DoInsert(size_t index, wxSizerItem *item); + // return the number of total items and the number of columns and rows + int CalcRowsCols(int& rows, int& cols) const; void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ); - // returns the number of columns/rows needed for the current total number - // of children (and the fixed number of rows/columns) - int CalcCols() const - { - wxCHECK_MSG - ( - m_rows, 0, - "Can't calculate number of cols if number of rows is not specified" - ); - - return int(m_children.GetCount() + m_rows - 1) / m_rows; - } - - int CalcRows() const - { - wxCHECK_MSG - ( - m_cols, 0, - "Can't calculate number of cols if number of rows is not specified" - ); - - return int(m_children.GetCount() + m_cols - 1) / m_cols; - } - private: DECLARE_CLASS(wxGridSizer) }; @@ -835,8 +668,8 @@ private: // wxFlexGridSizer //--------------------------------------------------------------------------- -// values which define the behaviour for resizing wxFlexGridSizer cells in the -// "non-flexible" direction +// the bevaiour for resizing wxFlexGridSizer cells in the "non-flexible" +// direction enum wxFlexSizerGrowMode { // don't resize the cells in non-flexible direction at all @@ -849,21 +682,15 @@ enum wxFlexSizerGrowMode wxFLEX_GROWMODE_ALL }; -class WXDLLIMPEXP_CORE wxFlexGridSizer: public wxGridSizer +class WXDLLEXPORT wxFlexGridSizer: public wxGridSizer { public: - // ctors specifying the number of columns only: number of rows will be - // deduced automatically depending on the number of sizer elements - wxFlexGridSizer( int cols, int vgap, int hgap ); - wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); - - // ctors specifying the number of rows and columns + // ctors/dtor wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); - wxFlexGridSizer( int rows, int cols, const wxSize& gap ); - - // dtor + wxFlexGridSizer( int cols, int vgap = 0, int hgap = 0 ); virtual ~wxFlexGridSizer(); + // set the rows/columns which will grow (the others will remain of the // constant initial size) void AddGrowableRow( size_t idx, int proportion = 0 ); @@ -871,8 +698,6 @@ public: void AddGrowableCol( size_t idx, int proportion = 0 ); void RemoveGrowableCol( size_t idx ); - bool IsRowGrowable( size_t idx ); - bool IsColGrowable( size_t idx ); // the sizer cells may grow in both directions, not grow at all or only // grow in one direction but not the other @@ -896,8 +721,8 @@ public: protected: void AdjustForFlexDirection(); - void AdjustForGrowables(const wxSize& sz); - void FindWidthsAndHeights(int nrows, int ncols); + void AdjustForGrowables(const wxSize& sz, const wxSize& minsz, + int nrows, int ncols); // the heights/widths of all rows/columns wxArrayInt m_rowHeights, @@ -921,93 +746,34 @@ protected: private: DECLARE_CLASS(wxFlexGridSizer) - wxDECLARE_NO_COPY_CLASS(wxFlexGridSizer); + DECLARE_NO_COPY_CLASS(wxFlexGridSizer) }; //--------------------------------------------------------------------------- // wxBoxSizer //--------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBoxSizer: public wxSizer +class WXDLLEXPORT wxBoxSizer: public wxSizer { public: - wxBoxSizer(int orient) - { - m_orient = orient; - m_totalProportion = 0; + wxBoxSizer( int orient ); - wxASSERT_MSG( m_orient == wxHORIZONTAL || m_orient == wxVERTICAL, - wxT("invalid value for wxBoxSizer orientation") ); - } + void RecalcSizes(); + wxSize CalcMin(); - virtual wxSizerItem *AddSpacer(int size); + int GetOrientation() const + { return m_orient; } - int GetOrientation() const { return m_orient; } - - bool IsVertical() const { return m_orient == wxVERTICAL; } - - void SetOrientation(int orient) { m_orient = orient; } - - // implementation of our resizing logic - virtual wxSize CalcMin(); - virtual void RecalcSizes(); + void SetOrientation(int orient) + { m_orient = orient; } protected: - // helpers for our code: this returns the component of the given wxSize in - // the direction of the sizer and in the other direction, respectively - int GetSizeInMajorDir(const wxSize& sz) const - { - return m_orient == wxHORIZONTAL ? sz.x : sz.y; - } - - int& SizeInMajorDir(wxSize& sz) - { - return m_orient == wxHORIZONTAL ? sz.x : sz.y; - } - - int& PosInMajorDir(wxPoint& pt) - { - return m_orient == wxHORIZONTAL ? pt.x : pt.y; - } - - int GetSizeInMinorDir(const wxSize& sz) const - { - return m_orient == wxHORIZONTAL ? sz.y : sz.x; - } - - int& SizeInMinorDir(wxSize& sz) - { - return m_orient == wxHORIZONTAL ? sz.y : sz.x; - } - - int& PosInMinorDir(wxPoint& pt) - { - return m_orient == wxHORIZONTAL ? pt.y : pt.x; - } - - // another helper: creates wxSize from major and minor components - wxSize SizeFromMajorMinor(int major, int minor) const - { - if ( m_orient == wxHORIZONTAL ) - { - return wxSize(major, minor); - } - else // wxVERTICAL - { - return wxSize(minor, major); - } - } - - - // either wxHORIZONTAL or wxVERTICAL int m_orient; - - // the sum of proportion of all of our elements - int m_totalProportion; - - // the minimal size needed for this sizer as calculated by the last call to - // our CalcMin() - wxSize m_minSize; + int m_stretchable; + int m_minWidth; + int m_minHeight; + int m_fixedWidth; + int m_fixedHeight; private: DECLARE_CLASS(wxBoxSizer) @@ -1021,7 +787,7 @@ private: class WXDLLIMPEXP_FWD_CORE wxStaticBox; -class WXDLLIMPEXP_CORE wxStaticBoxSizer: public wxBoxSizer +class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer { public: wxStaticBoxSizer(wxStaticBox *box, int orient); @@ -1036,7 +802,6 @@ public: // override to hide/show the static box as well virtual void ShowItems (bool show); - virtual bool AreAnyItemsShown() const; virtual bool Detach( wxWindow *window ); virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); } @@ -1047,18 +812,14 @@ protected: private: DECLARE_CLASS(wxStaticBoxSizer) - wxDECLARE_NO_COPY_CLASS(wxStaticBoxSizer); + DECLARE_NO_COPY_CLASS(wxStaticBoxSizer) }; #endif // wxUSE_STATBOX -//--------------------------------------------------------------------------- -// wxStdDialogButtonSizer -//--------------------------------------------------------------------------- - #if wxUSE_BUTTON -class WXDLLIMPEXP_CORE wxStdDialogButtonSizer: public wxBoxSizer +class WXDLLEXPORT wxStdDialogButtonSizer: public wxBoxSizer { public: // Constructor just creates a new wxBoxSizer, not much else. @@ -1092,54 +853,87 @@ public: protected: wxButton *m_buttonAffirmative; // wxID_OK, wxID_YES, wxID_SAVE go here - wxButton *m_buttonApply; // wxID_APPLY + wxButton *m_buttonApply; wxButton *m_buttonNegative; // wxID_NO - wxButton *m_buttonCancel; // wxID_CANCEL, wxID_CLOSE - wxButton *m_buttonHelp; // wxID_HELP, wxID_CONTEXT_HELP + wxButton *m_buttonCancel; + wxButton *m_buttonHelp; private: DECLARE_CLASS(wxStdDialogButtonSizer) - wxDECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer); + DECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer) }; #endif // wxUSE_BUTTON +#if WXWIN_COMPATIBILITY_2_4 +// NB: wxBookCtrlSizer and wxNotebookSizer are deprecated, they +// don't do anything. wxBookCtrlBase::DoGetBestSize does the job now. + +// ---------------------------------------------------------------------------- +// wxBookCtrlSizer +// ---------------------------------------------------------------------------- + +#if wxUSE_BOOKCTRL + +// this sizer works with wxNotebook/wxListbook/... and sizes the control to +// fit its pages +class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase; + +class WXDLLEXPORT wxBookCtrlSizer : public wxSizer +{ +public: +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( wxBookCtrlSizer(wxBookCtrlBase *bookctrl) ); +#endif // WXWIN_COMPATIBILITY_2_6 + + wxBookCtrlBase *GetControl() const { return m_bookctrl; } + + virtual void RecalcSizes(); + virtual wxSize CalcMin(); + +protected: + // this protected ctor lets us mark the real one above as deprecated + // and still have warning-free build of the library itself: + wxBookCtrlSizer() {} + + wxBookCtrlBase *m_bookctrl; + +private: + DECLARE_CLASS(wxBookCtrlSizer) + DECLARE_NO_COPY_CLASS(wxBookCtrlSizer) +}; + + +#if wxUSE_NOTEBOOK + +// before wxBookCtrlBase we only had wxNotebookSizer, keep it for backwards +// compatibility +class WXDLLIMPEXP_FWD_CORE wxNotebook; + +class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer +{ +public: +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( wxNotebookSizer(wxNotebook *nb) ); +#endif // WXWIN_COMPATIBILITY_2_6 + + wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; } + +private: + DECLARE_CLASS(wxNotebookSizer) + DECLARE_NO_COPY_CLASS(wxNotebookSizer) +}; + +#endif // wxUSE_NOTEBOOK + +#endif // wxUSE_BOOKCTRL + +#endif // WXWIN_COMPATIBILITY_2_4 // ---------------------------------------------------------------------------- // inline functions implementation // ---------------------------------------------------------------------------- -#if WXWIN_COMPATIBILITY_2_8 - -inline void wxSizerItem::SetWindow(wxWindow *window) -{ - DoSetWindow(window); -} - -inline void wxSizerItem::SetSizer(wxSizer *sizer) -{ - DoSetSizer(sizer); -} - -inline void wxSizerItem::SetSpacer(const wxSize& size) -{ - DoSetSpacer(size); -} - -inline void wxSizerItem::SetSpacer(int width, int height) -{ - DoSetSpacer(wxSize(width, height)); -} - -#endif // WXWIN_COMPATIBILITY_2_8 - -inline wxSizerItem* -wxSizer::Insert(size_t index, wxSizerItem *item) -{ - return DoInsert(index, item); -} - - inline wxSizerItem* wxSizer::Add( wxSizerItem *item ) { @@ -1176,12 +970,6 @@ wxSizer::Add( wxSizer *sizer, const wxSizerFlags& flags ) return Add( new wxSizerItem(sizer, flags) ); } -inline wxSizerItem* -wxSizer::Add( int width, int height, const wxSizerFlags& flags ) -{ - return Add( new wxSizerItem(width, height, flags) ); -} - inline wxSizerItem* wxSizer::AddSpacer(int size) { @@ -1242,12 +1030,6 @@ wxSizer::Prepend( wxSizer *sizer, const wxSizerFlags& flags ) return Prepend( new wxSizerItem(sizer, flags) ); } -inline wxSizerItem* -wxSizer::Prepend( int width, int height, const wxSizerFlags& flags ) -{ - return Prepend( new wxSizerItem(width, height, flags) ); -} - inline wxSizerItem* wxSizer::Insert( size_t index, wxWindow *window, @@ -1294,12 +1076,6 @@ wxSizer::Insert( size_t index, wxSizer *sizer, const wxSizerFlags& flags ) return Insert( index, new wxSizerItem(sizer, flags) ); } -inline wxSizerItem* -wxSizer::Insert( size_t index, int width, int height, const wxSizerFlags& flags ) -{ - return Insert( index, new wxSizerItem(width, height, flags) ); -} - inline wxSizerItem* wxSizer::InsertSpacer(size_t index, int size) { @@ -1312,4 +1088,5 @@ wxSizer::InsertStretchSpacer(size_t index, int prop) return Insert(index, 0, 0, prop); } + #endif // __WXSIZER_H__ diff --git a/Source/3rd Party/wx/include/wx/slider.h b/Source/3rd Party/wx/include/wx/slider.h index c77d5e252..77fcef253 100644 --- a/Source/3rd Party/wx/include/wx/slider.h +++ b/Source/3rd Party/wx/include/wx/slider.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 09.02.01 +// RCS-ID: $Id: slider.h 38717 2006-04-14 17:01:16Z ABX $ // Copyright: (c) 1996-2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -30,6 +31,7 @@ #define wxSL_TICKS 0x0010 #define wxSL_AUTOTICKS wxSL_TICKS // we don't support manual ticks +#define wxSL_LABELS 0x0020 #define wxSL_LEFT 0x0040 #define wxSL_TOP 0x0080 #define wxSL_RIGHT 0x0100 @@ -37,22 +39,19 @@ #define wxSL_BOTH 0x0400 #define wxSL_SELRANGE 0x0800 #define wxSL_INVERSE 0x1000 -#define wxSL_MIN_MAX_LABELS 0x2000 -#define wxSL_VALUE_LABEL 0x4000 -#define wxSL_LABELS (wxSL_MIN_MAX_LABELS|wxSL_VALUE_LABEL) #if WXWIN_COMPATIBILITY_2_6 // obsolete #define wxSL_NOTIFY_DRAG 0x0000 #endif // WXWIN_COMPATIBILITY_2_6 -extern WXDLLIMPEXP_DATA_CORE(const char) wxSliderNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxSliderNameStr[]; // ---------------------------------------------------------------------------- // wxSliderBase: define wxSlider interface // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSliderBase : public wxControl +class WXDLLEXPORT wxSliderBase : public wxControl { public: /* the ctor of the derived class should have the following form: @@ -94,7 +93,7 @@ public: // warning: most of subsequent methods are currently only implemented in // wxMSW under Win95 and are silently ignored on other platforms - void SetTickFreq(int freq) { DoSetTickFreq(freq); } + virtual void SetTickFreq(int WXUNUSED(n), int WXUNUSED(pos)) { } virtual int GetTickFreq() const { return 0; } virtual void ClearTicks() { } virtual void SetTick(int WXUNUSED(tickPos)) { } @@ -104,16 +103,7 @@ public: virtual int GetSelStart() const { return GetMax(); } virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED_INLINE( void SetTickFreq(int freq, int), DoSetTickFreq(freq); ) -#endif - protected: - // Platform-specific implementation of SetTickFreq - virtual void DoSetTickFreq(int WXUNUSED(freq)) { /* unsupported by default */ } - - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } // adjust value according to wxSL_INVERSE style virtual int ValueInvertOrNot(int value) const @@ -125,7 +115,7 @@ protected: } private: - wxDECLARE_NO_COPY_CLASS(wxSliderBase); + DECLARE_NO_COPY_CLASS(wxSliderBase) }; // ---------------------------------------------------------------------------- @@ -135,7 +125,10 @@ private: #if defined(__WXUNIVERSAL__) #include "wx/univ/slider.h" #elif defined(__WXMSW__) - #include "wx/msw/slider.h" + #include "wx/msw/slider95.h" + #if WXWIN_COMPATIBILITY_2_4 + #define wxSlider95 wxSlider + #endif #elif defined(__WXMOTIF__) #include "wx/motif/slider.h" #elif defined(__WXGTK20__) @@ -143,11 +136,13 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/slider.h" #elif defined(__WXMAC__) - #include "wx/osx/slider.h" + #include "wx/mac/slider.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/slider.h" #elif defined(__WXPM__) #include "wx/os2/slider.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/slider.h" #endif #endif // wxUSE_SLIDER diff --git a/Source/3rd Party/wx/include/wx/snglinst.h b/Source/3rd Party/wx/include/wx/snglinst.h index c2d570a5c..50a856332 100644 --- a/Source/3rd Party/wx/include/wx/snglinst.h +++ b/Source/3rd Party/wx/include/wx/snglinst.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 08.06.01 +// RCS-ID: $Id: snglinst.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,9 +15,6 @@ #if wxUSE_SNGLINST_CHECKER -#include "wx/app.h" -#include "wx/utils.h" - // ---------------------------------------------------------------------------- // wxSingleInstanceChecker // ---------------------------------------------------------------------------- @@ -35,11 +33,9 @@ public: Create(name, path); } - // notice that calling Create() is optional now, if you don't do it before - // calling IsAnotherRunning(), CreateDefault() is used automatically - // - // name it is used as the mutex name under Win32 and the lock file name - // under Unix so it should be as unique as possible and must be non-empty + // name must be given and be as unique as possible, it is used as the mutex + // name under Win32 and the lock file name under Unix - + // wxTheApp->GetAppName() may be a good value for this parameter // // path is optional and is ignored under Win32 and used as the directory to // create the lock file in under Unix (default is wxGetHomeDir()) @@ -48,32 +44,8 @@ public: // instance is running - use IsAnotherRunning() to check it bool Create(const wxString& name, const wxString& path = wxEmptyString); - // use the default name, which is a combination of wxTheApp->GetAppName() - // and wxGetUserId() for mutex/lock file - // - // this is called implicitly by IsAnotherRunning() if the checker hadn't - // been created until then - bool CreateDefault() - { - wxCHECK_MSG( wxTheApp, false, "must have application instance" ); - return Create(wxTheApp->GetAppName() + '-' + wxGetUserId()); - } - // is another copy of this program already running? - bool IsAnotherRunning() const - { - if ( !m_impl ) - { - if ( !const_cast(this)->CreateDefault() ) - { - // if creation failed, return false as it's better to not - // prevent this instance from starting up if there is an error - return false; - } - } - - return DoIsAnotherRunning(); - } + bool IsAnotherRunning() const; // dtor is not virtual, this class is not meant to be used polymorphically ~wxSingleInstanceChecker(); @@ -82,13 +54,10 @@ private: // common part of all ctors void Init() { m_impl = NULL; } - // do check if another instance is running, called only if m_impl != NULL - bool DoIsAnotherRunning() const; - // the implementation details (platform specific) class WXDLLIMPEXP_FWD_BASE wxSingleInstanceCheckerImpl *m_impl; - wxDECLARE_NO_COPY_CLASS(wxSingleInstanceChecker); + DECLARE_NO_COPY_CLASS(wxSingleInstanceChecker) }; #endif // wxUSE_SNGLINST_CHECKER diff --git a/Source/3rd Party/wx/include/wx/socket.h b/Source/3rd Party/wx/include/wx/socket.h deleted file mode 100644 index 35ff26621..000000000 --- a/Source/3rd Party/wx/include/wx/socket.h +++ /dev/null @@ -1,435 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/socket.h -// Purpose: Socket handling classes -// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia -// Modified by: -// Created: April 1997 -// Copyright: (c) Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SOCKET_H_ -#define _WX_SOCKET_H_ - -#include "wx/defs.h" - -#if wxUSE_SOCKETS - -// --------------------------------------------------------------------------- -// wxSocket headers -// --------------------------------------------------------------------------- - -#include "wx/event.h" -#include "wx/sckaddr.h" -#include "wx/list.h" - -class wxSocketImpl; - -// ------------------------------------------------------------------------ -// Types and constants -// ------------------------------------------------------------------------ - -// Define the type of native sockets. -#if defined(__WINDOWS__) - // Although socket descriptors are still 32 bit values, even under Win64, - // the socket type is 64 bit there. - typedef wxUIntPtr wxSOCKET_T; -#else - typedef int wxSOCKET_T; -#endif - - -// Types of different socket notifications or events. -// -// NB: the values here should be consecutive and start with 0 as they are -// used to construct the wxSOCKET_XXX_FLAG bit mask values below -enum wxSocketNotify -{ - wxSOCKET_INPUT, - wxSOCKET_OUTPUT, - wxSOCKET_CONNECTION, - wxSOCKET_LOST -}; - -enum -{ - wxSOCKET_INPUT_FLAG = 1 << wxSOCKET_INPUT, - wxSOCKET_OUTPUT_FLAG = 1 << wxSOCKET_OUTPUT, - wxSOCKET_CONNECTION_FLAG = 1 << wxSOCKET_CONNECTION, - wxSOCKET_LOST_FLAG = 1 << wxSOCKET_LOST -}; - -// this is a combination of the bit masks defined above -typedef int wxSocketEventFlags; - -enum wxSocketError -{ - wxSOCKET_NOERROR = 0, - wxSOCKET_INVOP, - wxSOCKET_IOERR, - wxSOCKET_INVADDR, - wxSOCKET_INVSOCK, - wxSOCKET_NOHOST, - wxSOCKET_INVPORT, - wxSOCKET_WOULDBLOCK, - wxSOCKET_TIMEDOUT, - wxSOCKET_MEMERR, - wxSOCKET_OPTERR -}; - -// socket options/flags bit masks -enum -{ - wxSOCKET_NONE = 0x0000, - wxSOCKET_NOWAIT_READ = 0x0001, - wxSOCKET_NOWAIT_WRITE = 0x0002, - wxSOCKET_NOWAIT = wxSOCKET_NOWAIT_READ | wxSOCKET_NOWAIT_WRITE, - wxSOCKET_WAITALL_READ = 0x0004, - wxSOCKET_WAITALL_WRITE = 0x0008, - wxSOCKET_WAITALL = wxSOCKET_WAITALL_READ | wxSOCKET_WAITALL_WRITE, - wxSOCKET_BLOCK = 0x0010, - wxSOCKET_REUSEADDR = 0x0020, - wxSOCKET_BROADCAST = 0x0040, - wxSOCKET_NOBIND = 0x0080 -}; - -typedef int wxSocketFlags; - -// socket kind values (badly defined, don't use) -enum wxSocketType -{ - wxSOCKET_UNINIT, - wxSOCKET_CLIENT, - wxSOCKET_SERVER, - wxSOCKET_BASE, - wxSOCKET_DATAGRAM -}; - - -// event -class WXDLLIMPEXP_FWD_NET wxSocketEvent; -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_NET, wxEVT_SOCKET, wxSocketEvent); - -// -------------------------------------------------------------------------- -// wxSocketBase -// -------------------------------------------------------------------------- - -class WXDLLIMPEXP_NET wxSocketBase : public wxObject -{ -public: - // Public interface - // ---------------- - - // ctors and dtors - wxSocketBase(); - wxSocketBase(wxSocketFlags flags, wxSocketType type); - virtual ~wxSocketBase(); - void Init(); - bool Destroy(); - - // state - bool Ok() const { return IsOk(); } - bool IsOk() const { return m_impl != NULL; } - bool Error() const { return LastError() != wxSOCKET_NOERROR; } - bool IsClosed() const { return m_closed; } - bool IsConnected() const { return m_connected; } - bool IsData() { return WaitForRead(0, 0); } - bool IsDisconnected() const { return !IsConnected(); } - wxUint32 LastCount() const { return m_lcount; } - wxUint32 LastReadCount() const { return m_lcount_read; } - wxUint32 LastWriteCount() const { return m_lcount_write; } - wxSocketError LastError() const; - void SaveState(); - void RestoreState(); - - // addresses - virtual bool GetLocal(wxSockAddress& addr_man) const; - virtual bool GetPeer(wxSockAddress& addr_man) const; - virtual bool SetLocal(const wxIPV4address& local); - - // base IO - virtual bool Close(); - void ShutdownOutput(); - wxSocketBase& Discard(); - wxSocketBase& Peek(void* buffer, wxUint32 nbytes); - wxSocketBase& Read(void* buffer, wxUint32 nbytes); - wxSocketBase& ReadMsg(void *buffer, wxUint32 nbytes); - wxSocketBase& Unread(const void *buffer, wxUint32 nbytes); - wxSocketBase& Write(const void *buffer, wxUint32 nbytes); - wxSocketBase& WriteMsg(const void *buffer, wxUint32 nbytes); - - // all Wait() functions wait until their condition is satisfied or the - // timeout expires; if seconds == -1 (default) then m_timeout value is used - // - // it is also possible to call InterruptWait() to cancel any current Wait() - - // wait for anything at all to happen with this socket - bool Wait(long seconds = -1, long milliseconds = 0); - - // wait until we can read from or write to the socket without blocking - // (notice that this does not mean that the operation will succeed but only - // that it will return immediately) - bool WaitForRead(long seconds = -1, long milliseconds = 0); - bool WaitForWrite(long seconds = -1, long milliseconds = 0); - - // wait until the connection is terminated - bool WaitForLost(long seconds = -1, long milliseconds = 0); - - void InterruptWait() { m_interrupt = true; } - - - wxSocketFlags GetFlags() const { return m_flags; } - void SetFlags(wxSocketFlags flags); - virtual void SetTimeout(long seconds); - long GetTimeout() const { return m_timeout; } - - bool GetOption(int level, int optname, void *optval, int *optlen); - bool SetOption(int level, int optname, const void *optval, int optlen); - wxUint32 GetLastIOSize() const { return m_lcount; } - wxUint32 GetLastIOReadSize() const { return m_lcount_read; } - wxUint32 GetLastIOWriteSize() const { return m_lcount_write; } - - // event handling - void *GetClientData() const { return m_clientData; } - void SetClientData(void *data) { m_clientData = data; } - void SetEventHandler(wxEvtHandler& handler, int id = wxID_ANY); - void SetNotify(wxSocketEventFlags flags); - void Notify(bool notify); - - // Get the underlying socket descriptor. - wxSOCKET_T GetSocket() const; - - // initialize/shutdown the sockets (done automatically so there is no need - // to call these functions usually) - // - // should always be called from the main thread only so one of the cases - // where they should indeed be called explicitly is when the first wxSocket - // object in the application is created in a different thread - static bool Initialize(); - static void Shutdown(); - - // check if wxSocket had been already initialized - // - // notice that this function should be only called from the main thread as - // otherwise it is inherently unsafe because Initialize/Shutdown() may be - // called concurrently with it in the main thread - static bool IsInitialized(); - - // Implementation from now on - // -------------------------- - - // do not use, should be private (called from wxSocketImpl only) - void OnRequest(wxSocketNotify notify); - - // do not use, not documented nor supported - bool IsNoWait() const { return ((m_flags & wxSOCKET_NOWAIT) != 0); } - wxSocketType GetType() const { return m_type; } - -private: - friend class wxSocketClient; - friend class wxSocketServer; - friend class wxDatagramSocket; - - // low level IO - wxUint32 DoRead(void* buffer, wxUint32 nbytes); - wxUint32 DoWrite(const void *buffer, wxUint32 nbytes); - - // wait until the given flags are set for this socket or the given timeout - // (or m_timeout) expires - // - // notice that wxSOCKET_LOST_FLAG is always taken into account and the - // function returns -1 if the connection was lost; otherwise it returns - // true if any of the events specified by flags argument happened or false - // if the timeout expired - int DoWait(long timeout, wxSocketEventFlags flags); - - // a helper calling DoWait() using the same convention as the public - // WaitForXXX() functions use, i.e. use our timeout if seconds == -1 or the - // specified timeout otherwise - int DoWait(long seconds, long milliseconds, wxSocketEventFlags flags); - - // another helper calling DoWait() using our m_timeout - int DoWaitWithTimeout(wxSocketEventFlags flags) - { - return DoWait(m_timeout*1000, flags); - } - - // pushback buffer - void Pushback(const void *buffer, wxUint32 size); - wxUint32 GetPushback(void *buffer, wxUint32 size, bool peek); - - // store the given error as the LastError() - void SetError(wxSocketError error); - -private: - // socket - wxSocketImpl *m_impl; // port-specific implementation - wxSocketType m_type; // wxSocket type - - // state - wxSocketFlags m_flags; // wxSocket flags - bool m_connected; // connected? - bool m_establishing; // establishing connection? - bool m_reading; // busy reading? - bool m_writing; // busy writing? - bool m_closed; // was the other end closed? - wxUint32 m_lcount; // last IO transaction size - wxUint32 m_lcount_read; // last IO transaction size of Read() direction. - wxUint32 m_lcount_write; // last IO transaction size of Write() direction. - unsigned long m_timeout; // IO timeout value in seconds - // (TODO: remove, wxSocketImpl has it too) - wxList m_states; // stack of states (TODO: remove!) - bool m_interrupt; // interrupt ongoing wait operations? - bool m_beingDeleted; // marked for delayed deletion? - wxIPV4address m_localAddress; // bind to local address? - - // pushback buffer - void *m_unread; // pushback buffer - wxUint32 m_unrd_size; // pushback buffer size - wxUint32 m_unrd_cur; // pushback pointer (index into buffer) - - // events - int m_id; // socket id - wxEvtHandler *m_handler; // event handler - void *m_clientData; // client data for events - bool m_notify; // notify events to users? - wxSocketEventFlags m_eventmask; // which events to notify? - wxSocketEventFlags m_eventsgot; // collects events received in OnRequest() - - - friend class wxSocketReadGuard; - friend class wxSocketWriteGuard; - - wxDECLARE_NO_COPY_CLASS(wxSocketBase); - DECLARE_CLASS(wxSocketBase) -}; - - -// -------------------------------------------------------------------------- -// wxSocketServer -// -------------------------------------------------------------------------- - -class WXDLLIMPEXP_NET wxSocketServer : public wxSocketBase -{ -public: - wxSocketServer(const wxSockAddress& addr, - wxSocketFlags flags = wxSOCKET_NONE); - - wxSocketBase* Accept(bool wait = true); - bool AcceptWith(wxSocketBase& socket, bool wait = true); - - bool WaitForAccept(long seconds = -1, long milliseconds = 0); - - wxDECLARE_NO_COPY_CLASS(wxSocketServer); - DECLARE_CLASS(wxSocketServer) -}; - - -// -------------------------------------------------------------------------- -// wxSocketClient -// -------------------------------------------------------------------------- - -class WXDLLIMPEXP_NET wxSocketClient : public wxSocketBase -{ -public: - wxSocketClient(wxSocketFlags flags = wxSOCKET_NONE); - - virtual bool Connect(const wxSockAddress& addr, bool wait = true); - bool Connect(const wxSockAddress& addr, - const wxSockAddress& local, - bool wait = true); - - bool WaitOnConnect(long seconds = -1, long milliseconds = 0); - - // Sets initial socket buffer sizes using the SO_SNDBUF and SO_RCVBUF - // options before calling connect (either one can be -1 to leave it - // unchanged) - void SetInitialSocketBuffers(int recv, int send) - { - m_initialRecvBufferSize = recv; - m_initialSendBufferSize = send; - } - -private: - virtual bool DoConnect(const wxSockAddress& addr, - const wxSockAddress* local, - bool wait = true); - - // buffer sizes, -1 if unset and defaults should be used - int m_initialRecvBufferSize; - int m_initialSendBufferSize; - - wxDECLARE_NO_COPY_CLASS(wxSocketClient); - DECLARE_CLASS(wxSocketClient) -}; - - -// -------------------------------------------------------------------------- -// wxDatagramSocket -// -------------------------------------------------------------------------- - -// WARNING: still in alpha stage - -class WXDLLIMPEXP_NET wxDatagramSocket : public wxSocketBase -{ -public: - wxDatagramSocket(const wxSockAddress& addr, - wxSocketFlags flags = wxSOCKET_NONE); - - wxDatagramSocket& RecvFrom(wxSockAddress& addr, - void *buf, - wxUint32 nBytes); - wxDatagramSocket& SendTo(const wxSockAddress& addr, - const void* buf, - wxUint32 nBytes); - - /* TODO: - bool Connect(wxSockAddress& addr); - */ - -private: - wxDECLARE_NO_COPY_CLASS(wxDatagramSocket); - DECLARE_CLASS(wxDatagramSocket) -}; - - -// -------------------------------------------------------------------------- -// wxSocketEvent -// -------------------------------------------------------------------------- - -class WXDLLIMPEXP_NET wxSocketEvent : public wxEvent -{ -public: - wxSocketEvent(int id = 0) - : wxEvent(id, wxEVT_SOCKET) - { - } - - wxSocketNotify GetSocketEvent() const { return m_event; } - wxSocketBase *GetSocket() const - { return (wxSocketBase *) GetEventObject(); } - void *GetClientData() const { return m_clientData; } - - virtual wxEvent *Clone() const { return new wxSocketEvent(*this); } - virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_SOCKET; } - -public: - wxSocketNotify m_event; - void *m_clientData; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSocketEvent) -}; - - -typedef void (wxEvtHandler::*wxSocketEventFunction)(wxSocketEvent&); - -#define wxSocketEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSocketEventFunction, func) - -#define EVT_SOCKET(id, func) \ - wx__DECLARE_EVT1(wxEVT_SOCKET, id, wxSocketEventHandler(func)) - -#endif // wxUSE_SOCKETS - -#endif // _WX_SOCKET_H_ - diff --git a/Source/3rd Party/wx/include/wx/sound.h b/Source/3rd Party/wx/include/wx/sound.h deleted file mode 100644 index b81a11cb4..000000000 --- a/Source/3rd Party/wx/include/wx/sound.h +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/sound.h -// Purpose: wxSoundBase class -// Author: Vaclav Slavik -// Modified by: -// Created: 2004/02/01 -// Copyright: (c) 2004, Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SOUND_H_BASE_ -#define _WX_SOUND_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_SOUND - -#include "wx/object.h" - -// ---------------------------------------------------------------------------- -// wxSoundBase: common wxSound code and interface -// ---------------------------------------------------------------------------- - -// Flags for wxSound::Play - -// NB: We can't use enum with some compilers, because they keep reporting -// nonexistent ambiguities between Play(unsigned) and static Play(const -// wxString&, unsigned). -#define wxSOUND_SYNC ((unsigned)0) -#define wxSOUND_ASYNC ((unsigned)1) -#define wxSOUND_LOOP ((unsigned)2) - -// Base class for wxSound implementations -class WXDLLIMPEXP_ADV wxSoundBase : public wxObject -{ -public: - // Play the sound: - bool Play(unsigned flags = wxSOUND_ASYNC) const - { - wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 || - (flags & wxSOUND_ASYNC) != 0, - wxT("sound can only be looped asynchronously") ); - return DoPlay(flags); - } - - // Plays sound from filename: - static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC); - -protected: - virtual bool DoPlay(unsigned flags) const = 0; -}; - -// ---------------------------------------------------------------------------- -// wxSound class implementation -// ---------------------------------------------------------------------------- - -#if defined(__WINDOWS__) - #include "wx/msw/sound.h" -#elif defined(__WXCOCOA__) - #include "wx/cocoa/sound.h" -#elif defined(__WXMAC__) - #include "wx/osx/sound.h" -#elif defined(__WXPM__) - #include "wx/os2/sound.h" -#elif defined(__UNIX__) - #include "wx/unix/sound.h" -#endif - -// ---------------------------------------------------------------------------- -// wxSoundBase methods -// ---------------------------------------------------------------------------- - -inline bool wxSoundBase::Play(const wxString& filename, unsigned flags) -{ - wxSound snd(filename); - return snd.IsOk() ? snd.Play(flags) : false; -} - -#endif // wxUSE_SOUND - -#endif // _WX_SOUND_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/spinbutt.h b/Source/3rd Party/wx/include/wx/spinbutt.h index 69230e18f..c24f35f01 100644 --- a/Source/3rd Party/wx/include/wx/spinbutt.h +++ b/Source/3rd Party/wx/include/wx/spinbutt.h @@ -4,6 +4,7 @@ // Author: Julian Smart, Vadim Zeitlin // Modified by: // Created: 23.07.99 +// RCS-ID: $Id: spinbutt.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,6 @@ #include "wx/control.h" #include "wx/event.h" -#include "wx/range.h" #define wxSPIN_BUTTON_NAME wxT("wxSpinButton") @@ -36,7 +36,7 @@ // wxSP_WRAP: value wraps at either end // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinButtonBase : public wxControl +class WXDLLEXPORT wxSpinButtonBase : public wxControl { public: // ctor initializes the range with the default (0..100) values @@ -46,7 +46,6 @@ public: virtual int GetValue() const = 0; virtual int GetMin() const { return m_min; } virtual int GetMax() const { return m_max; } - wxRange GetRange() const { return wxRange( GetMin(), GetMax() );} // operations virtual void SetValue(int val) = 0; @@ -57,7 +56,6 @@ public: m_min = minVal; m_max = maxVal; } - void SetRange( const wxRange& range) { SetRange( range.GetMin(), range.GetMax()); } // is this spin button vertically oriented? bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; } @@ -67,7 +65,7 @@ protected: int m_min; int m_max; - wxDECLARE_NO_COPY_CLASS(wxSpinButtonBase); + DECLARE_NO_COPY_CLASS(wxSpinButtonBase) }; // ---------------------------------------------------------------------------- @@ -85,7 +83,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/spinbutt.h" #elif defined(__WXMAC__) - #include "wx/osx/spinbutt.h" + #include "wx/mac/spinbutt.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/spinbutt.h" #elif defined(__WXPM__) @@ -96,7 +94,7 @@ protected: // the wxSpinButton event // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinEvent : public wxNotifyEvent +class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent { public: wxSpinEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) @@ -104,37 +102,26 @@ public: { } - wxSpinEvent(const wxSpinEvent& event) : wxNotifyEvent(event) {} - // get the current value of the control - int GetValue() const { return m_commandInt; } - void SetValue(int value) { m_commandInt = value; } - int GetPosition() const { return m_commandInt; } void SetPosition(int pos) { m_commandInt = pos; } - virtual wxEvent *Clone() const { return new wxSpinEvent(*this); } - private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxSpinEvent) }; typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&); #define wxSpinEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSpinEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSpinEventFunction, &func) -// macros for handling spin events: notice that we must use the real values of -// the event type constants and not their references (wxEVT_SPIN[_UP/DOWN]) -// here as otherwise the event tables could end up with non-initialized -// (because of undefined initialization order of the globals defined in -// different translation units) references in them +// macros for handling spin events #define EVT_SPIN_UP(winid, func) \ - wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func)) + wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxSpinEventHandler(func)) #define EVT_SPIN_DOWN(winid, func) \ - wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func)) + wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxSpinEventHandler(func)) #define EVT_SPIN(winid, func) \ - wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func)) + wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxSpinEventHandler(func)) #endif // wxUSE_SPINBTN diff --git a/Source/3rd Party/wx/include/wx/spinctrl.h b/Source/3rd Party/wx/include/wx/spinctrl.h index 1dcb58977..e27c1892d 100644 --- a/Source/3rd Party/wx/include/wx/spinctrl.h +++ b/Source/3rd Party/wx/include/wx/spinctrl.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/spinctrl.h +// Name: spinctrl.h // Purpose: wxSpinCtrlBase class // Author: Vadim Zeitlin // Modified by: // Created: 22.07.99 +// RCS-ID: $Id: spinctrl.h 37066 2006-01-23 03:27:34Z MR $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,138 +18,65 @@ #include "wx/spinbutt.h" // should make wxSpinEvent visible to the app -// Events -class WXDLLIMPEXP_FWD_CORE wxSpinDoubleEvent; - -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SPINCTRL, wxSpinEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SPINCTRLDOUBLE, wxSpinDoubleEvent); - // ---------------------------------------------------------------------------- -// A spin ctrl is a text control with a spin button which is usually used to -// prompt the user for a numeric input. -// There are two kinds for number types T=integer or T=double. +// a spin ctrl is a text control with a spin button which is usually used to +// prompt the user for a numeric input // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrlBase : public wxControl +/* there is no generic base class for this control because it's imlpemented + very differently under MSW and other platforms + +class WXDLLEXPORT wxSpinCtrlBase : public wxControl { public: - wxSpinCtrlBase() {} + wxSpinCtrlBase() { Init(); } - // accessor functions that derived classes are expected to have - // T GetValue() const - // T GetMin() const - // T GetMax() const - // T GetIncrement() const - virtual bool GetSnapToTicks() const = 0; - // unsigned GetDigits() const - wxSpinCtrlDouble only + // accessors + virtual int GetValue() const = 0; + virtual int GetMin() const { return m_min; } + virtual int GetMax() const { return m_max; } - // operation functions that derived classes are expected to have + // operations virtual void SetValue(const wxString& value) = 0; - // void SetValue(T val) - // void SetRange(T minVal, T maxVal) - // void SetIncrement(T inc) - virtual void SetSnapToTicks(bool snap_to_ticks) = 0; - // void SetDigits(unsigned digits) - wxSpinCtrlDouble only + virtual void SetValue(int val) = 0; + virtual void SetRange(int minVal, int maxVal) = 0; - // The base for numbers display, e.g. 10 or 16. - virtual int GetBase() const = 0; - virtual bool SetBase(int base) = 0; - - // Select text in the textctrl + // as the wxTextCtrl method virtual void SetSelection(long from, long to) = 0; -private: - wxDECLARE_NO_COPY_CLASS(wxSpinCtrlBase); -}; - -// ---------------------------------------------------------------------------- -// wxSpinDoubleEvent - a wxSpinEvent for double valued controls -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxSpinDoubleEvent : public wxNotifyEvent -{ -public: - wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, - double value = 0) - : wxNotifyEvent(commandType, winid), m_value(value) - { - } - - wxSpinDoubleEvent(const wxSpinDoubleEvent& event) - : wxNotifyEvent(event), m_value(event.GetValue()) - { - } - - double GetValue() const { return m_value; } - void SetValue(double value) { m_value = value; } - - virtual wxEvent *Clone() const { return new wxSpinDoubleEvent(*this); } - protected: - double m_value; + // initialize m_min/max with the default values + void Init() { m_min = 0; m_max = 100; } -private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent) + int m_min; + int m_max; }; - -// ---------------------------------------------------------------------------- -// wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h -// ---------------------------------------------------------------------------- - -typedef void (wxEvtHandler::*wxSpinDoubleEventFunction)(wxSpinDoubleEvent&); - -#define wxSpinDoubleEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxSpinDoubleEventFunction, func) - -// macros for handling spinctrl events - -#define EVT_SPINCTRL(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SPINCTRL, id, wxSpinEventHandler(fn)) - -#define EVT_SPINCTRLDOUBLE(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SPINCTRLDOUBLE, id, wxSpinDoubleEventHandler(fn)) +*/ // ---------------------------------------------------------------------------- // include the platform-dependent class implementation // ---------------------------------------------------------------------------- -// we may have a native wxSpinCtrl implementation, native wxSpinCtrl and -// wxSpinCtrlDouble implementations or neither, define the appropriate symbols -// and include the generic version if necessary to provide the missing class(es) - #if defined(__WXUNIVERSAL__) - // nothing, use generic controls + #include "wx/generic/spinctlg.h" #elif defined(__WXMSW__) - #define wxHAS_NATIVE_SPINCTRL #include "wx/msw/spinctrl.h" #elif defined(__WXPM__) - #define wxHAS_NATIVE_SPINCTRL #include "wx/os2/spinctrl.h" #elif defined(__WXGTK20__) - #define wxHAS_NATIVE_SPINCTRL - #define wxHAS_NATIVE_SPINCTRLDOUBLE #include "wx/gtk/spinctrl.h" #elif defined(__WXGTK__) - #define wxHAS_NATIVE_SPINCTRL #include "wx/gtk1/spinctrl.h" +#elif defined(__WXMOTIF__) + #include "wx/generic/spinctlg.h" +#elif defined(__WXMAC__) + #include "wx/mac/spinctrl.h" +#elif defined(__WXCOCOA__) + #include "wx/generic/spinctlg.h" #endif // platform -#if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE) - #include "wx/generic/spinctlg.h" -#endif - -namespace wxPrivate -{ - -// This is an internal helper function currently used by all ports: return the -// string containing hexadecimal representation of the given number. -extern wxString wxSpinCtrlFormatAsHex(long val, long maxVal); - -} // namespace wxPrivate - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_SPINCTRL_UPDATED wxEVT_SPINCTRL -#define wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED wxEVT_SPINCTRLDOUBLE +#define EVT_SPINCTRL(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxSpinEventHandler(fn)) #endif // wxUSE_SPINCTRL diff --git a/Source/3rd Party/wx/include/wx/splash.h b/Source/3rd Party/wx/include/wx/splash.h deleted file mode 100644 index e4fb0c21e..000000000 --- a/Source/3rd Party/wx/include/wx/splash.h +++ /dev/null @@ -1,17 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/splash.h -// Purpose: Base header for wxSplashScreen -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SPLASH_H_BASE_ -#define _WX_SPLASH_H_BASE_ - -#include "wx/generic/splash.h" - -#endif - // _WX_SPLASH_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/splitter.h b/Source/3rd Party/wx/include/wx/splitter.h index 538849959..fb96799f1 100644 --- a/Source/3rd Party/wx/include/wx/splitter.h +++ b/Source/3rd Party/wx/include/wx/splitter.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: +// RCS-ID: $Id: splitter.h 38717 2006-04-14 17:01:16Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -18,7 +19,6 @@ // ---------------------------------------------------------------------------- #define wxSP_NOBORDER 0x0000 -#define wxSP_THIN_SASH 0x0000 // NB: the default is 3D sash #define wxSP_NOSASH 0x0010 #define wxSP_PERMIT_UNSPLIT 0x0040 #define wxSP_LIVE_UPDATE 0x0080 @@ -34,13 +34,14 @@ #define wxSP_FULLSASH 0 #endif // WXWIN_COMPATIBILITY_2_6 -class WXDLLIMPEXP_FWD_CORE wxSplitterEvent; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_SPLITTER_SASH_POS_CHANGED, wxSplitterEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_SPLITTER_SASH_POS_CHANGING, wxSplitterEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_SPLITTER_DOUBLECLICKED, wxSplitterEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_SPLITTER_UNSPLIT, wxSplitterEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, 850) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, 851) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, 852) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT, 853) +END_DECLARE_EVENT_TYPES() #include "wx/generic/splitter.h" -#endif // _WX_SPLITTER_H_BASE_ +#endif + // _WX_SPLITTER_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/srchctrl.h b/Source/3rd Party/wx/include/wx/srchctrl.h index 25f56c7a8..af831bd0b 100644 --- a/Source/3rd Party/wx/include/wx/srchctrl.h +++ b/Source/3rd Party/wx/include/wx/srchctrl.h @@ -1,8 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/srchctrl.h +// Name: srchctrl.h // Purpose: wxSearchCtrlBase class // Author: Vince Harron // Created: 2006-02-18 +// RCS-ID: $Id: srchctrl.h 45828 2007-05-05 14:51:51Z VZ $ // Copyright: (c) Vince Harron // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +17,8 @@ #include "wx/textctrl.h" -#if !defined(__WXUNIVERSAL__) && defined(__WXMAC__) +#if !defined(__WXUNIVERSAL__) && defined(__WXMAC__) && defined(__WXMAC_OSX__) \ + && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) // search control was introduced in Mac OS X 10.3 Panther #define wxUSE_NATIVE_SEARCH_CONTROL 1 @@ -25,31 +27,26 @@ // no native version, use the generic one #define wxUSE_NATIVE_SEARCH_CONTROL 0 - #include "wx/compositewin.h" - #include "wx/containr.h" - - class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass - : public wxCompositeWindow< wxNavigationEnabled >, - public wxTextCtrlIface - { - }; + #define wxSearchCtrlBaseBaseClass wxTextCtrlBase #endif // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxSearchCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxSearchCtrlNameStr[]; -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1119) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1120) +END_DECLARE_EVENT_TYPES() // ---------------------------------------------------------------------------- // a search ctrl is a text control with a search button and a cancel button // it is based on the MacOSX 10.3 control HISearchFieldCreate // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSearchCtrlBase : public wxSearchCtrlBaseBaseClass +class WXDLLEXPORT wxSearchCtrlBase : public wxSearchCtrlBaseBaseClass { public: wxSearchCtrlBase() { } @@ -67,17 +64,13 @@ public: virtual void ShowCancelButton( bool show ) = 0; virtual bool IsCancelButtonVisible() const = 0; - -private: - // implement wxTextEntry pure virtual method - virtual wxWindow *GetEditableWindow() { return this; } }; // include the platform-dependent class implementation #if wxUSE_NATIVE_SEARCH_CONTROL #if defined(__WXMAC__) - #include "wx/osx/srchctrl.h" + #include "wx/mac/srchctrl.h" #endif #else #include "wx/generic/srchctlg.h" @@ -88,14 +81,10 @@ private: // ---------------------------------------------------------------------------- #define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn)) #define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN wxEVT_SEARCHCTRL_CANCEL_BTN -#define wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN wxEVT_SEARCHCTRL_SEARCH_BTN + wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn)) #endif // wxUSE_SEARCHCTRL diff --git a/Source/3rd Party/wx/include/wx/sstream.h b/Source/3rd Party/wx/include/wx/sstream.h index 0d8f7f0a2..febf2cf0d 100644 --- a/Source/3rd Party/wx/include/wx/sstream.h +++ b/Source/3rd Party/wx/include/wx/sstream.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2004-09-19 +// RCS-ID: $Id: sstream.h 45732 2007-05-01 13:52:19Z VZ $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -25,9 +26,9 @@ public: // ctor associates the stream with the given string which makes a copy of // it wxStringInputStream(const wxString& s); + virtual ~wxStringInputStream(); virtual wxFileOffset GetLength() const; - virtual bool IsSeekable() const { return true; } protected: virtual wxFileOffset OnSysSeek(wxFileOffset ofs, wxSeekMode mode); @@ -39,7 +40,7 @@ private: wxString m_str; // the buffer we're reading from - wxCharBuffer m_buf; + char* m_buf; // length of the buffer we're reading from size_t m_len; @@ -47,7 +48,7 @@ private: // position in the stream in bytes, *not* in chars size_t m_pos; - wxDECLARE_NO_COPY_CLASS(wxStringInputStream); + DECLARE_NO_COPY_CLASS(wxStringInputStream) }; // ---------------------------------------------------------------------------- @@ -59,25 +60,19 @@ class WXDLLIMPEXP_BASE wxStringOutputStream : public wxOutputStream public: // The stream will write data either to the provided string or to an // internal string which can be retrieved using GetString() - // - // Note that the conversion object should have the life time greater than - // this stream. - wxStringOutputStream(wxString *pString = NULL, - wxMBConv& conv = wxConvUTF8) - : m_conv(conv) -#if wxUSE_UNICODE - , m_unconv(0) -#endif // wxUSE_UNICODE + wxStringOutputStream(wxString *pString = NULL) { m_str = pString ? pString : &m_strInternal; m_pos = m_str->length() / sizeof(wxChar); } +#if wxABI_VERSION >= 20804 && wxUSE_UNICODE + virtual ~wxStringOutputStream(); +#endif // wx 2.8.4+ + // get the string containing current output const wxString& GetString() const { return *m_str; } - virtual bool IsSeekable() const { return true; } - protected: virtual wxFileOffset OnSysTell() const; virtual size_t OnSysWrite(const void *buffer, size_t size); @@ -92,17 +87,14 @@ private: // position in the stream in bytes, *not* in chars size_t m_pos; - // converter to use: notice that with the default UTF-8 one the input - // stream must contain valid UTF-8 data, use wxConvISO8859_1 to work with - // arbitrary 8 bit data - wxMBConv& m_conv; +#if wxUSE_WCHAR_T + // string encoding converter (UTF8 is the standard) + wxMBConvUTF8 m_conv; +#else + wxMBConv m_conv; +#endif -#if wxUSE_UNICODE - // unconverted data from the last call to OnSysWrite() - wxMemoryBuffer m_unconv; -#endif // wxUSE_UNICODE - - wxDECLARE_NO_COPY_CLASS(wxStringOutputStream); + DECLARE_NO_COPY_CLASS(wxStringOutputStream) }; #endif // wxUSE_STREAMS diff --git a/Source/3rd Party/wx/include/wx/stack.h b/Source/3rd Party/wx/include/wx/stack.h index a5f8c0a30..e58c0675d 100644 --- a/Source/3rd Party/wx/include/wx/stack.h +++ b/Source/3rd Party/wx/include/wx/stack.h @@ -1,10 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/stack.h // Purpose: STL stack clone -// Author: Lindsay Mathieson, Vadim Zeitlin +// Author: Lindsay Mathieson +// Modified by: // Created: 30.07.2001 -// Copyright: (c) 2001 Lindsay Mathieson (WX_DECLARE_STACK) -// 2011 Vadim Zeitlin +// Copyright: (c) 2001 Lindsay Mathieson // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -13,71 +13,30 @@ #include "wx/vector.h" -#if wxUSE_STD_CONTAINERS - -#include -#define wxStack std::stack - -#else // !wxUSE_STD_CONTAINERS - -// Notice that unlike std::stack, wxStack currently always uses wxVector and -// can't be used with any other underlying container type. -// -// Another difference is that comparison operators between stacks are not -// implemented (but they should be, see 23.2.3.3 of ISO/IEC 14882:1998). - -template -class wxStack -{ -public: - typedef wxVector container_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::value_type value_type; - - wxStack() { } - explicit wxStack(const container_type& cont) : m_cont(cont) { } - - // Default copy ctor, assignment operator and dtor are ok. - - - bool empty() const { return m_cont.empty(); } - size_type size() const { return m_cont.size(); } - - value_type& top() { return m_cont.back(); } - const value_type& top() const { return m_cont.back(); } - - void push(const value_type& val) { m_cont.push_back(val); } - void pop() { m_cont.pop_back(); } - -private: - container_type m_cont; -}; - -#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS - - -// Deprecated macro-based class for compatibility only, don't use any more. -#define WX_DECLARE_STACK(obj, cls) \ -class cls : public wxVector \ +#define WX_DECLARE_STACK(obj, cls)\ +class cls : public wxVectorBase\ {\ + WX_DECLARE_VECTORBASE(obj, cls);\ public:\ void push(const obj& o)\ {\ - push_back(o); \ + bool rc = Alloc(size() + 1);\ + wxASSERT(rc);\ + Append(new obj(o));\ };\ \ void pop()\ {\ - pop_back(); \ + RemoveAt(size() - 1);\ };\ \ obj& top()\ {\ - return at(size() - 1);\ + return *(obj *) GetItem(size() - 1);\ };\ const obj& top() const\ {\ - return at(size() - 1); \ + return *(obj *) GetItem(size() - 1);\ };\ } diff --git a/Source/3rd Party/wx/include/wx/stackwalk.h b/Source/3rd Party/wx/include/wx/stackwalk.h index cf2152a94..e051c71f1 100644 --- a/Source/3rd Party/wx/include/wx/stackwalk.h +++ b/Source/3rd Party/wx/include/wx/stackwalk.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/stackwalk.h +// Name: wx/wx/stackwalk.h // Purpose: wxStackWalker and related classes, common part // Author: Vadim Zeitlin // Modified by: // Created: 2005-01-07 +// RCS-ID: $Id: stackwalk.h 43346 2006-11-12 14:33:03Z RR $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,9 +16,7 @@ #if wxUSE_STACKWALKER -class WXDLLIMPEXP_FWD_BASE wxStackFrame; - -#define wxSTACKWALKER_MAX_DEPTH (200) +class WXDLLIMPEXP_BASE wxStackFrame; // ---------------------------------------------------------------------------- // wxStackFrame: a single stack level @@ -28,7 +27,7 @@ class WXDLLIMPEXP_BASE wxStackFrameBase private: // put this inline function here so that it is defined before use wxStackFrameBase *ConstCast() const - { return const_cast(this); } + { return wx_const_cast(wxStackFrameBase *, this); } public: wxStackFrameBase(size_t level, void *address = NULL) @@ -131,21 +130,19 @@ public: // number of them (this can be useful when Walk() is called from some known // location and you don't want to see the first few frames anyhow; also // notice that Walk() frame itself is not included if skip >= 1) - virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) = 0; + virtual void Walk(size_t skip = 1, size_t maxDepth = 200) = 0; -#if wxUSE_ON_FATAL_EXCEPTION // enumerate stack frames from the location of uncaught exception // // this version can only be called from wxApp::OnFatalException() - virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) = 0; -#endif // wxUSE_ON_FATAL_EXCEPTION + virtual void WalkFromException() = 0; protected: // this function must be overrided to process the given frame virtual void OnStackFrame(const wxStackFrame& frame) = 0; }; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include "wx/msw/stackwalk.h" #elif defined(__UNIX__) #include "wx/unix/stackwalk.h" diff --git a/Source/3rd Party/wx/include/wx/statbmp.h b/Source/3rd Party/wx/include/wx/statbmp.h index d716b9b9b..e32c0cca7 100644 --- a/Source/3rd Party/wx/include/wx/statbmp.h +++ b/Source/3rd Party/wx/include/wx/statbmp.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 25.08.00 +// RCS-ID: $Id: statbmp.h 37066 2006-01-23 03:27:34Z MR $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,10 +20,10 @@ #include "wx/bitmap.h" #include "wx/icon.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBitmapNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxStaticBitmapNameStr[]; // a control showing an icon or a bitmap -class WXDLLIMPEXP_CORE wxStaticBitmapBase : public wxControl +class WXDLLEXPORT wxStaticBitmapBase : public wxControl { public: wxStaticBitmapBase() { } @@ -39,17 +40,14 @@ public: return wxIcon(); } - // overridden base class virtuals + // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } virtual bool HasTransparentBackground() { return true; } protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - virtual wxSize DoGetBestSize() const; - wxDECLARE_NO_COPY_CLASS(wxStaticBitmapBase); + DECLARE_NO_COPY_CLASS(wxStaticBitmapBase) }; #if defined(__WXUNIVERSAL__) @@ -63,7 +61,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/statbmp.h" #elif defined(__WXMAC__) - #include "wx/osx/statbmp.h" + #include "wx/mac/statbmp.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/statbmp.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/statbox.h b/Source/3rd Party/wx/include/wx/statbox.h index 215cecd85..182881c93 100644 --- a/Source/3rd Party/wx/include/wx/statbox.h +++ b/Source/3rd Party/wx/include/wx/statbox.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/statbox.h +// Name: statbox.h // Purpose: wxStaticBox base header // Author: Julian Smart // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: statbox.h 37066 2006-01-23 03:27:34Z MR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,20 +17,20 @@ #if wxUSE_STATBOX #include "wx/control.h" -#include "wx/containr.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBoxNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxStaticBoxNameStr[]; // ---------------------------------------------------------------------------- // wxStaticBox: a grouping box with a label // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStaticBoxBase : public wxNavigationEnabled +class WXDLLEXPORT wxStaticBoxBase : public wxControl { public: - wxStaticBoxBase(); + wxStaticBoxBase() { } - // overridden base class virtuals + // overriden base class virtuals + virtual bool AcceptsFocus() const { return false; } virtual bool HasTransparentBackground() { return true; } // implementation only: this is used by wxStaticBoxSizer to account for the @@ -45,11 +46,8 @@ public: *borderOther = BORDER; } -protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - wxDECLARE_NO_COPY_CLASS(wxStaticBoxBase); +private: + DECLARE_NO_COPY_CLASS(wxStaticBoxBase) }; #if defined(__WXUNIVERSAL__) @@ -63,7 +61,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/statbox.h" #elif defined(__WXMAC__) - #include "wx/osx/statbox.h" + #include "wx/mac/statbox.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/statbox.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/statline.h b/Source/3rd Party/wx/include/wx/statline.h index bac9e8539..eac9078f4 100644 --- a/Source/3rd Party/wx/include/wx/statline.h +++ b/Source/3rd Party/wx/include/wx/statline.h @@ -3,6 +3,7 @@ // Purpose: wxStaticLine class interface // Author: Vadim Zeitlin // Created: 28.06.99 +// Version: $Id: statline.h 43874 2006-12-09 14:52:59Z VZ $ // Copyright: (c) 1999 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,13 +28,13 @@ // ---------------------------------------------------------------------------- // the default name for objects of class wxStaticLine -extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticLineNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxStaticLineNameStr[]; // ---------------------------------------------------------------------------- // wxStaticLine - a line in a dialog // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStaticLineBase : public wxControl +class WXDLLEXPORT wxStaticLineBase : public wxControl { public: // constructor @@ -45,13 +46,10 @@ public: // get the default size for the "lesser" dimension of the static line static int GetDefaultSize() { return 2; } - // overridden base class virtuals + // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - // set the right size for the right dimension wxSize AdjustSize(const wxSize& size) const { @@ -75,7 +73,7 @@ protected: return AdjustSize(wxDefaultSize); } - wxDECLARE_NO_COPY_CLASS(wxStaticLineBase); + DECLARE_NO_COPY_CLASS(wxStaticLineBase) }; // ---------------------------------------------------------------------------- @@ -93,7 +91,7 @@ protected: #elif defined(__WXPM__) #include "wx/os2/statline.h" #elif defined(__WXMAC__) - #include "wx/osx/statline.h" + #include "wx/mac/statline.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/statline.h" #else // use generic implementation for all other platforms diff --git a/Source/3rd Party/wx/include/wx/stattext.h b/Source/3rd Party/wx/include/wx/stattext.h index e63dfd635..99862b22e 100644 --- a/Source/3rd Party/wx/include/wx/stattext.h +++ b/Source/3rd Party/wx/include/wx/stattext.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/stattext.h +// Name: stattext.h // Purpose: wxStaticText base header // Author: Julian Smart // Modified by: // Created: // Copyright: (c) Julian Smart +// RCS-ID: $Id: stattext.h 37066 2006-01-23 03:27:34Z MR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,74 +18,31 @@ #include "wx/control.h" -/* - * wxStaticText flags - */ -#define wxST_NO_AUTORESIZE 0x0001 -// free 0x0002 bit -#define wxST_ELLIPSIZE_START 0x0004 -#define wxST_ELLIPSIZE_MIDDLE 0x0008 -#define wxST_ELLIPSIZE_END 0x0010 +extern WXDLLEXPORT_DATA(const wxChar) wxStaticTextNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[]; - -class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl +class WXDLLEXPORT wxStaticTextBase : public wxControl { public: wxStaticTextBase() { } + // in wxGTK wxStaticText doesn't derive from wxStaticTextBase so we have to + // declare this function directly in gtk header +#if !defined(__WXGTK__) || defined(__WXUNIVERSAL__) // wrap the text of the control so that no line is longer than the given // width (if possible: this function won't break words) - // This function will modify the value returned by GetLabel()! + // + // NB: implemented in dlgcmn.cpp for now void Wrap(int width); +#endif // ! native __WXGTK__ - // overridden base virtuals + // overriden base virtuals virtual bool AcceptsFocus() const { return false; } virtual bool HasTransparentBackground() { return true; } - bool IsEllipsized() const - { - return HasFlag(wxST_ELLIPSIZE_START) || - HasFlag(wxST_ELLIPSIZE_MIDDLE) || - HasFlag(wxST_ELLIPSIZE_END); - } - -protected: // functions required for wxST_ELLIPSIZE_* support - - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - // Calls Ellipsize() on the real label if necessary. Unlike GetLabelText(), - // keeps the mnemonics instead of removing them. - virtual wxString GetEllipsizedLabel() const; - - // Replaces parts of the string with ellipsis according to the ellipsize - // style. Shouldn't be called if we don't have any. - wxString Ellipsize(const wxString& label) const; - - // to be called when updating the size of the static text: - // updates the label redoing ellipsization calculations - void UpdateLabel(); - - // These functions are platform-specific and must be overridden in ports - // which do not natively support ellipsization and they must be implemented - // in a way so that the m_labelOrig member of wxControl is not touched: - - // returns the real label currently displayed inside the control. - virtual wxString DoGetLabel() const { return wxEmptyString; } - - // sets the real label currently displayed inside the control, - // _without_ invalidating the size. The text passed is always markup-free - // but may contain the mnemonic characters. - virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } - private: - wxDECLARE_NO_COPY_CLASS(wxStaticTextBase); + DECLARE_NO_COPY_CLASS(wxStaticTextBase) }; -// see wx/generic/stattextg.h for the explanation -#ifndef wxNO_PORT_STATTEXT_INCLUDE - #if defined(__WXUNIVERSAL__) #include "wx/univ/stattext.h" #elif defined(__WXMSW__) @@ -96,15 +54,16 @@ private: #elif defined(__WXGTK__) #include "wx/gtk1/stattext.h" #elif defined(__WXMAC__) - #include "wx/osx/stattext.h" + #include "wx/mac/stattext.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/stattext.h" #elif defined(__WXPM__) #include "wx/os2/stattext.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/stattext.h" #endif -#endif // !wxNO_PORT_STATTEXT_INCLUDE - #endif // wxUSE_STATTEXT -#endif // _WX_STATTEXT_H_BASE_ +#endif + // _WX_STATTEXT_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/statusbr.h b/Source/3rd Party/wx/include/wx/statusbr.h index 1f6d15bc5..5a19e7503 100644 --- a/Source/3rd Party/wx/include/wx/statusbr.h +++ b/Source/3rd Party/wx/include/wx/statusbr.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05.02.00 +// RCS-ID: $Id: statusbr.h 41035 2006-09-06 17:36:22Z PC $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,98 +16,28 @@ #if wxUSE_STATUSBAR -#include "wx/control.h" +#include "wx/window.h" #include "wx/list.h" #include "wx/dynarray.h" -extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr[]; +extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxStatusBarNameStr[]; + +WX_DECLARE_LIST(wxString, wxListString); // ---------------------------------------------------------------------------- // wxStatusBar constants // ---------------------------------------------------------------------------- -// wxStatusBar styles -#define wxSTB_SIZEGRIP 0x0010 -#define wxSTB_SHOW_TIPS 0x0020 - -#define wxSTB_ELLIPSIZE_START 0x0040 -#define wxSTB_ELLIPSIZE_MIDDLE 0x0080 -#define wxSTB_ELLIPSIZE_END 0x0100 - -#define wxSTB_DEFAULT_STYLE (wxSTB_SIZEGRIP|wxSTB_ELLIPSIZE_END|wxSTB_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE) - - -// old compat style name: -#define wxST_SIZEGRIP wxSTB_SIZEGRIP - - -// style flags for wxStatusBar fields +// style flags for fields #define wxSB_NORMAL 0x0000 #define wxSB_FLAT 0x0001 #define wxSB_RAISED 0x0002 -#define wxSB_SUNKEN 0x0003 - -// ---------------------------------------------------------------------------- -// wxStatusBarPane: an helper for wxStatusBar -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxStatusBarPane -{ -public: - wxStatusBarPane(int style = wxSB_NORMAL, int width = 0) - : m_nStyle(style), m_nWidth(width) - { m_bEllipsized = false; } - - int GetWidth() const { return m_nWidth; } - int GetStyle() const { return m_nStyle; } - wxString GetText() const { return m_text; } - - - // implementation-only from now on - // ------------------------------- - - bool IsEllipsized() const - { return m_bEllipsized; } - void SetIsEllipsized(bool isEllipsized) { m_bEllipsized = isEllipsized; } - - void SetWidth(int width) { m_nWidth = width; } - void SetStyle(int style) { m_nStyle = style; } - - // set text, return true if it changed or false if it was already set to - // this value - bool SetText(const wxString& text); - - // save the existing text on top of our stack and make the new text - // current; return true if the text really changed - bool PushText(const wxString& text); - - // restore the message saved by the last call to Push() (unless it was - // changed by an intervening call to SetText()) and return true if we - // really restored anything - bool PopText(); - -private: - int m_nStyle; - int m_nWidth; // may be negative, indicating a variable-width field - wxString m_text; - - // the array used to keep the previous values of this pane after a - // PushStatusText() call, its top element is the value to restore after the - // next PopStatusText() call while the currently shown value is always in - // m_text - wxArrayString m_arrStack; - - // is the currently shown value shown with ellipsis in the status bar? - bool m_bEllipsized; -}; - -WX_DECLARE_EXPORTED_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray); // ---------------------------------------------------------------------------- // wxStatusBar: a window near the bottom of the frame used for status info // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStatusBarBase : public wxControl +class WXDLLEXPORT wxStatusBarBase : public wxWindow { public: wxStatusBarBase(); @@ -119,17 +50,14 @@ public: // set the number of fields and call SetStatusWidths(widths) if widths are // given virtual void SetFieldsCount(int number = 1, const int *widths = NULL); - int GetFieldsCount() const { return (int)m_panes.GetCount(); } + int GetFieldsCount() const { return m_nFields; } // field text // ---------- - // just change or get the currently shown text - void SetStatusText(const wxString& text, int number = 0); - wxString GetStatusText(int number = 0) const; + virtual void SetStatusText(const wxString& text, int number = 0) = 0; + virtual wxString GetStatusText(int number = 0) const = 0; - // change the currently shown text to the new one and save the current - // value to be restored by the next call to PopStatusText() void PushStatusText(const wxString& text, int number = 0); void PopStatusText(int number = 0); @@ -144,18 +72,15 @@ public: // -2 grows twice as much as one with width -1 &c) virtual void SetStatusWidths(int n, const int widths[]); - int GetStatusWidth(int n) const - { return m_panes[n].GetWidth(); } - // field styles // ------------ - // Set the field border style to one of wxSB_XXX values. + // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D + // border around a field, wxSB_FLAT for no border around a field, so that it + // appears flat or wxSB_POPOUT to make the field appear raised. + // Setting field styles only works on wxMSW virtual void SetStatusStyles(int n, const int styles[]); - int GetStatusStyle(int n) const - { return m_panes[n].GetStyle(); } - // geometry // -------- @@ -169,59 +94,51 @@ public: virtual int GetBorderX() const = 0; virtual int GetBorderY() const = 0; - wxSize GetBorders() const - { return wxSize(GetBorderX(), GetBorderY()); } - - // miscellaneous - // ------------- - - const wxStatusBarPane& GetField(int n) const - { return m_panes[n]; } - - // wxWindow overrides: - // don't want status bars to accept the focus at all virtual bool AcceptsFocus() const { return false; } - // the client size of a toplevel window doesn't include the status bar - virtual bool CanBeOutsideClientArea() const { return true; } - protected: - // called after the status bar pane text changed and should update its - // display - virtual void DoUpdateStatusText(int number) = 0; + // set the widths array to NULL + void InitWidths(); + // free the status widths arrays + void FreeWidths(); - // wxWindow overrides: + // reset the widths + void ReinitWidths() { FreeWidths(); InitWidths(); } -#if wxUSE_TOOLTIPS - virtual void DoSetToolTip( wxToolTip *tip ) - { - wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS), - "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!"); - wxWindow::DoSetToolTip(tip); - } -#endif // wxUSE_TOOLTIPS - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + // same, for field styles + void InitStyles(); + void FreeStyles(); + void ReinitStyles() { FreeStyles(); InitStyles(); } - - // internal helpers & data: + // same, for text stacks + void InitStacks(); + void FreeStacks(); + void ReinitStacks() { FreeStacks(); InitStacks(); } // calculate the real field widths for the given total available size wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const; - // should be called to remember if the pane text is currently being show - // ellipsized or not - void SetEllipsizedFlag(int n, bool isEllipsized); + // use these functions to access the stacks of field strings + wxListString *GetStatusStack(int i) const; + wxListString *GetOrCreateStatusStack(int i); + // the current number of fields + int m_nFields; - // the array with the pane infos: - wxStatusBarPaneArray m_panes; + // the widths of the fields in pixels if !NULL, all fields have the same + // width otherwise + int *m_statusWidths; - // if true overrides the width info of the wxStatusBarPanes - bool m_bSameWidthForAllPanes; + // the styles of the fields + int *m_statusStyles; - wxDECLARE_NO_COPY_CLASS(wxStatusBarBase); + // stacks of previous values for PushStatusText/PopStatusText + // this is created on demand, use GetStatusStack/GetOrCreateStatusStack + wxListString **m_statusTextStacks; + + DECLARE_NO_COPY_CLASS(wxStatusBarBase) }; // ---------------------------------------------------------------------------- @@ -230,15 +147,24 @@ protected: #if defined(__WXUNIVERSAL__) #define wxStatusBarUniv wxStatusBar + #include "wx/univ/statusbr.h" -#elif defined(__WXMSW__) && wxUSE_NATIVE_STATUSBAR - #include "wx/msw/statusbar.h" +#elif defined(__WXPALMOS__) + #define wxStatusBarPalm wxStatusBar + + #include "wx/palmos/statusbr.h" +#elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR + #define wxStatusBar95 wxStatusBar + + #include "wx/msw/statbr95.h" #elif defined(__WXMAC__) #define wxStatusBarMac wxStatusBar + #include "wx/generic/statusbr.h" - #include "wx/osx/statusbr.h" + #include "wx/mac/statusbr.h" #else #define wxStatusBarGeneric wxStatusBar + #include "wx/generic/statusbr.h" #endif diff --git a/Source/3rd Party/wx/include/wx/stdpaths.h b/Source/3rd Party/wx/include/wx/stdpaths.h index 5e609686b..beb8b13b7 100644 --- a/Source/3rd Party/wx/include/wx/stdpaths.h +++ b/Source/3rd Party/wx/include/wx/stdpaths.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2004-10-17 +// RCS-ID: $Id: stdpaths.h 43340 2006-11-12 12:58:10Z RR $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -13,21 +14,19 @@ #include "wx/defs.h" +#if wxUSE_STDPATHS + #include "wx/string.h" #include "wx/filefn.h" -class WXDLLIMPEXP_FWD_BASE wxStandardPaths; - // ---------------------------------------------------------------------------- // wxStandardPaths returns the standard locations in the file system // ---------------------------------------------------------------------------- -// NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native -// wxStandardPaths class, but a minimal version is always available class WXDLLIMPEXP_BASE wxStandardPathsBase { public: - // possible resources categories + // possible resources categorires enum ResourceCat { // no special category @@ -40,18 +39,9 @@ public: ResourceCat_Max }; - // what should we use to construct paths unique to this application: - // (AppInfo_AppName and AppInfo_VendorName can be combined together) - enum - { - AppInfo_None = 0, // nothing - AppInfo_AppName = 1, // the application name - AppInfo_VendorName = 2 // the vendor name - }; - // return the global standard paths object - static wxStandardPaths& Get(); + static wxStandardPathsBase& Get(); // return the path (directory+filename) of the running executable or // wxEmptyString if it couldn't be determined. @@ -119,7 +109,7 @@ public: // different under Unix for message catalog category (namely the standard // prefix/share/locale/lang/LC_MESSAGES) virtual wxString - GetLocalizedResourcesDir(const wxString& lang, + GetLocalizedResourcesDir(const wxChar *lang, ResourceCat WXUNUSED(category) = ResourceCat_None) const { @@ -128,15 +118,10 @@ public: // return the "Documents" directory for the current user // - // C:\Documents and Settings\username\My Documents under Windows, + // C:\Documents and Settings\username\Documents under Windows, // $HOME under Unix and ~/Documents under Mac virtual wxString GetDocumentsDir() const; - // return the directory for the documents files used by this application: - // it's a subdirectory of GetDocumentsDir() constructed using the - // application name/vendor if it exists or just GetDocumentsDir() otherwise - virtual wxString GetAppDocumentsDir() const; - // return the temporary directory for the current user virtual wxString GetTempDir() const; @@ -144,57 +129,29 @@ public: // virtual dtor for the base class virtual ~wxStandardPathsBase(); - // Information used by AppendAppInfo - void UseAppInfo(int info) - { - m_usedAppInfo = info; - } - - bool UsesAppInfo(int info) const { return (m_usedAppInfo & info) != 0; } - - protected: - // Ctor is protected as this is a base class which should never be created - // directly. - wxStandardPathsBase(); - - // append the path component, with a leading path separator if a - // path separator or dot (.) is not already at the end of dir - static wxString AppendPathComponent(const wxString& dir, const wxString& component); - - // append application information determined by m_usedAppInfo to dir - wxString AppendAppInfo(const wxString& dir) const; - - - // combination of AppInfo_XXX flags used by AppendAppInfo() - int m_usedAppInfo; + // append "/appname" suffix if the app name is set (doesn't append the + // slash if dir already ends with a slash or dot) + static wxString AppendAppName(const wxString& dir); }; -#if wxUSE_STDPATHS - #if defined(__WINDOWS__) - #include "wx/msw/stdpaths.h" - #define wxHAS_NATIVE_STDPATHS - // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports) - #elif defined(__WXMAC__) || defined(__DARWIN__) - #include "wx/osx/core/stdpaths.h" - #define wxHAS_NATIVE_STDPATHS - #elif defined(__OS2__) - #include "wx/os2/stdpaths.h" - #define wxHAS_NATIVE_STDPATHS - #elif defined(__UNIX__) - #include "wx/unix/stdpaths.h" - #define wxHAS_NATIVE_STDPATHS - #endif -#endif +#if defined(__WXMSW__) + #include "wx/msw/stdpaths.h" +// We want CoreFoundation paths on both CarbonLib and Darwin (for all ports) +#elif defined(__WXMAC__) || defined(__DARWIN__) + #include "wx/mac/corefoundation/stdpaths.h" +#elif defined(__OS2__) + #include "wx/os2/stdpaths.h" +#elif defined(__UNIX__) + #include "wx/unix/stdpaths.h" +#elif defined(__PALMOS__) + #include "wx/palmos/stdpaths.h" +#else // ---------------------------------------------------------------------------- // Minimal generic implementation // ---------------------------------------------------------------------------- -// NB: Note that this minimal implementation is compiled in even if -// wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths. - -#ifndef wxHAS_NATIVE_STDPATHS class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase { public: @@ -210,16 +167,13 @@ public: virtual wxString GetPluginsDir() const { return m_prefix; } virtual wxString GetDocumentsDir() const { return m_prefix; } -protected: - // Ctor is protected because wxStandardPaths::Get() should always be used - // to access the global wxStandardPaths object of the correct type instead - // of creating one of a possibly wrong type yourself. - wxStandardPaths() { } - private: wxString m_prefix; }; -#endif // !wxHAS_NATIVE_STDPATHS + +#endif + +#endif // wxUSE_STDPATHS #endif // _WX_STDPATHS_H_ diff --git a/Source/3rd Party/wx/include/wx/stdstream.h b/Source/3rd Party/wx/include/wx/stdstream.h deleted file mode 100644 index 73ac0ac26..000000000 --- a/Source/3rd Party/wx/include/wx/stdstream.h +++ /dev/null @@ -1,122 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/stdstream.h -// Purpose: Header of std::istream and std::ostream derived wrappers for -// wxInputStream and wxOutputStream -// Author: Jonathan Liu -// Created: 2009-05-02 -// Copyright: (c) 2009 Jonathan Liu -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_STDSTREAM_H_ -#define _WX_STDSTREAM_H_ - -#include "wx/defs.h" // wxUSE_STD_IOSTREAM - -#if wxUSE_STREAMS && wxUSE_STD_IOSTREAM - -#include "wx/defs.h" -#include "wx/stream.h" -#include "wx/ioswrap.h" - -// ========================================================================== -// wxStdInputStreamBuffer -// ========================================================================== - -class WXDLLIMPEXP_BASE wxStdInputStreamBuffer : public std::streambuf -{ -public: - wxStdInputStreamBuffer(wxInputStream& stream); - virtual ~wxStdInputStreamBuffer() { } - -protected: - virtual std::streambuf *setbuf(char *s, std::streamsize n); - virtual std::streampos seekoff(std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which = - std::ios_base::in | - std::ios_base::out); - virtual std::streampos seekpos(std::streampos sp, - std::ios_base::openmode which = - std::ios_base::in | - std::ios_base::out); - virtual std::streamsize showmanyc(); - virtual std::streamsize xsgetn(char *s, std::streamsize n); - virtual int underflow(); - virtual int uflow(); - virtual int pbackfail(int c = EOF); - - // Special work around for VC8/9 (this bug was fixed in VC10 and later): - // these versions have non-standard _Xsgetn_s() that it being called from - // the stream code instead of xsgetn() and so our overridden implementation - // never actually gets used. To work around this, forward to it explicitly. -#if defined(__VISUALC8__) || defined(__VISUALC9__) - virtual std::streamsize - _Xsgetn_s(char *s, size_t WXUNUSED(size), std::streamsize n) - { - return xsgetn(s, n); - } -#endif // VC8 or VC9 - - wxInputStream& m_stream; - int m_lastChar; -}; - -// ========================================================================== -// wxStdInputStream -// ========================================================================== - -class WXDLLIMPEXP_BASE wxStdInputStream : public std::istream -{ -public: - wxStdInputStream(wxInputStream& stream); - virtual ~wxStdInputStream() { } - -protected: - wxStdInputStreamBuffer m_streamBuffer; -}; - -// ========================================================================== -// wxStdOutputStreamBuffer -// ========================================================================== - -class WXDLLIMPEXP_BASE wxStdOutputStreamBuffer : public std::streambuf -{ -public: - wxStdOutputStreamBuffer(wxOutputStream& stream); - virtual ~wxStdOutputStreamBuffer() { } - -protected: - virtual std::streambuf *setbuf(char *s, std::streamsize n); - virtual std::streampos seekoff(std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which = - std::ios_base::in | - std::ios_base::out); - virtual std::streampos seekpos(std::streampos sp, - std::ios_base::openmode which = - std::ios_base::in | - std::ios_base::out); - virtual std::streamsize xsputn(const char *s, std::streamsize n); - virtual int overflow(int c); - - wxOutputStream& m_stream; -}; - -// ========================================================================== -// wxStdOutputStream -// ========================================================================== - -class WXDLLIMPEXP_BASE wxStdOutputStream : public std::ostream -{ -public: - wxStdOutputStream(wxOutputStream& stream); - virtual ~wxStdOutputStream() { } - -protected: - wxStdOutputStreamBuffer m_streamBuffer; -}; - -#endif // wxUSE_STREAMS && wxUSE_STD_IOSTREAM - -#endif // _WX_STDSTREAM_H_ diff --git a/Source/3rd Party/wx/include/wx/stockitem.h b/Source/3rd Party/wx/include/wx/stockitem.h index acdd02513..31ac5213a 100644 --- a/Source/3rd Party/wx/include/wx/stockitem.h +++ b/Source/3rd Party/wx/include/wx/stockitem.h @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 2004-08-15 +// RCS-ID: $Id: stockitem.h 42935 2006-11-02 09:51:49Z JS $ // Copyright: (c) Vaclav Slavik, 2004 // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,7 +13,7 @@ #define _WX_STOCKITEM_H_ #include "wx/defs.h" -#include "wx/chartype.h" +#include "wx/wxchar.h" #include "wx/string.h" #include "wx/accel.h" @@ -21,40 +22,32 @@ // ---------------------------------------------------------------------------- // Returns true if the ID is in the list of recognized stock actions -WXDLLIMPEXP_CORE bool wxIsStockID(wxWindowID id); +WXDLLEXPORT bool wxIsStockID(wxWindowID id); // Returns true of the label is empty or label of a stock button with // given ID -WXDLLIMPEXP_CORE bool wxIsStockLabel(wxWindowID id, const wxString& label); +WXDLLEXPORT bool wxIsStockLabel(wxWindowID id, const wxString& label); enum wxStockLabelQueryFlag { wxSTOCK_NOFLAGS = 0, wxSTOCK_WITH_MNEMONIC = 1, - wxSTOCK_WITH_ACCELERATOR = 2, - - // by default, stock items text is returned with ellipsis, if appropriate, - // this flag allows to avoid having it - wxSTOCK_WITHOUT_ELLIPSIS = 4, - - // return label for button, not menu item: buttons should always use - // mnemonics and never use ellipsis - wxSTOCK_FOR_BUTTON = wxSTOCK_WITHOUT_ELLIPSIS | wxSTOCK_WITH_MNEMONIC + wxSTOCK_WITH_ACCELERATOR = 2 }; // Returns label that should be used for given stock UI element (e.g. "&OK" // for wxSTOCK_OK); if wxSTOCK_WITH_MNEMONIC is given, the & character // is included; if wxSTOCK_WITH_ACCELERATOR is given, the stock accelerator // for given ID is concatenated to the label using \t as separator -WXDLLIMPEXP_CORE wxString wxGetStockLabel(wxWindowID id, +WXDLLEXPORT wxString wxGetStockLabel(wxWindowID id, long flags = wxSTOCK_WITH_MNEMONIC); #if wxUSE_ACCEL // Returns the accelerator that should be used for given stock UI element // (e.g. "Ctrl+x" for wxSTOCK_EXIT) - WXDLLIMPEXP_CORE wxAcceleratorEntry wxGetStockAccelerator(wxWindowID id); + WXDLLEXPORT wxAcceleratorEntry wxGetStockAccelerator(wxWindowID id); #endif @@ -66,14 +59,14 @@ enum wxStockHelpStringClient }; // Returns an help string for the given stock UI element and for the given "context". -WXDLLIMPEXP_CORE wxString wxGetStockHelpString(wxWindowID id, +WXDLLEXPORT wxString wxGetStockHelpString(wxWindowID id, wxStockHelpStringClient client = wxSTOCK_MENU); #ifdef __WXGTK20__ -// Translates stock ID to GTK+'s stock item string identifier: -WXDLLIMPEXP_CORE const char *wxGetStockGtkID(wxWindowID id); +// Translates stock ID to GTK+'s stock item string indentifier: +WXDLLEXPORT const char *wxGetStockGtkID(wxWindowID id); #endif diff --git a/Source/3rd Party/wx/include/wx/stopwatch.h b/Source/3rd Party/wx/include/wx/stopwatch.h index ac982ed20..8733708c8 100644 --- a/Source/3rd Party/wx/include/wx/stopwatch.h +++ b/Source/3rd Party/wx/include/wx/stopwatch.h @@ -1,11 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/stopwatch.h // Purpose: wxStopWatch and global time-related functions -// Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch), -// Vadim Zeitlin (time functions, current wxStopWatch) +// Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch) // Created: 26.06.03 (extracted from wx/timer.h) +// RCS-ID: $Id: stopwatch.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998-2003 Julian Smart, Sylvain Bougnoux -// (c) 2011 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,11 +14,6 @@ #include "wx/defs.h" #include "wx/longlong.h" -// Time-related functions are also available via this header for compatibility -// but you should include wx/time.h directly if you need only them and not -// wxStopWatch itself. -#include "wx/time.h" - // ---------------------------------------------------------------------------- // wxStopWatch: measure time intervals with up to 1ms resolution // ---------------------------------------------------------------------------- @@ -32,16 +26,14 @@ public: // ctor starts the stop watch wxStopWatch() { m_pauseCount = 0; Start(); } - // Start the stop watch at the moment t0 expressed in milliseconds (i.e. - // calling Time() immediately afterwards returns t0). This can be used to - // restart an existing stopwatch. + // start the stop watch at the moment t0 void Start(long t0 = 0); // pause the stop watch void Pause() { if ( m_pauseCount++ == 0 ) - m_elapsedBeforePause = GetCurrentClockValue() - m_t0; + m_pause = GetElapsedTime(); } // resume it @@ -51,37 +43,22 @@ public: wxT("Resuming stop watch which is not paused") ); if ( --m_pauseCount == 0 ) - { - DoStart(); - m_t0 -= m_elapsedBeforePause; - } + Start(m_pause); } - // Get elapsed time since the last Start() in microseconds. - wxLongLong TimeInMicro() const; - // get elapsed time since the last Start() in milliseconds - long Time() const { return (TimeInMicro()/1000).ToLong(); } + long Time() const; + +protected: + // returns the elapsed time since t0 + long GetElapsedTime() const; private: - // Really starts the stop watch. The initial time is set to current clock - // value. - void DoStart(); - - // Returns the current clock value in its native units. - wxLongLong GetCurrentClockValue() const; - - // Return the frequency of the clock used in its ticks per second. - wxLongLong GetClockFreq() const; - - - // The clock value when the stop watch was last started. Its units vary - // depending on the platform. + // the time of the last Start() wxLongLong m_t0; - // The elapsed time as of last Pause() call (only valid if m_pauseCount > - // 0) in the same units as m_t0. - wxLongLong m_elapsedBeforePause; + // the time of the last Pause() (only valid if m_pauseCount > 0) + long m_pause; // if > 0, the stop watch is paused, otherwise it is running int m_pauseCount; @@ -101,4 +78,25 @@ private: #endif // wxUSE_LONGLONG && WXWIN_COMPATIBILITY_2_6 +// ---------------------------------------------------------------------------- +// global time functions +// ---------------------------------------------------------------------------- + +// Get number of seconds since local time 00:00:00 Jan 1st 1970. +extern long WXDLLIMPEXP_BASE wxGetLocalTime(); + +// Get number of seconds since GMT 00:00:00, Jan 1st 1970. +extern long WXDLLIMPEXP_BASE wxGetUTCTime(); + +#if wxUSE_LONGLONG + typedef wxLongLong wxMilliClock_t; +#else + typedef double wxMilliClock_t; +#endif // wxUSE_LONGLONG + +// Get number of milliseconds since local time 00:00:00 Jan 1st 1970 +extern wxMilliClock_t WXDLLIMPEXP_BASE wxGetLocalTimeMillis(); + +#define wxGetCurrentTime() wxGetLocalTime() + #endif // _WX_STOPWATCH_H_ diff --git a/Source/3rd Party/wx/include/wx/strconv.h b/Source/3rd Party/wx/include/wx/strconv.h index c68420b94..7d167fab7 100644 --- a/Source/3rd Party/wx/include/wx/strconv.h +++ b/Source/3rd Party/wx/include/wx/strconv.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: wx/strconv.h +// Name: strconv.h // Purpose: conversion routines for char sets any Unicode // Author: Ove Kaaven, Robert Roebling, Vadim Zeitlin // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: strconv.h 45893 2007-05-08 20:05:16Z VZ $ // Copyright: (c) 1998 Ove Kaaven, Robert Roebling // (c) 1998-2006 Vadim Zeitlin // Licence: wxWindows licence @@ -13,7 +14,7 @@ #define _WX_STRCONV_H_ #include "wx/defs.h" -#include "wx/chartype.h" +#include "wx/wxchar.h" #include "wx/buffer.h" #ifdef __DIGITALMARS__ @@ -26,11 +27,15 @@ #include -class WXDLLIMPEXP_FWD_BASE wxString; +#if wxUSE_WCHAR_T // the error value returned by wxMBConv methods #define wxCONV_FAILED ((size_t)-1) +// the default value for some length parameters meaning that the string is +// NUL-terminated +#define wxNO_LEN ((size_t)-1) + // ---------------------------------------------------------------------------- // wxMBConv (abstract base class for conversions) // ---------------------------------------------------------------------------- @@ -56,21 +61,19 @@ public: // there is not enough space for everything, including the trailing NUL // character(s), in the output buffer, wxCONV_FAILED is returned. // - // In the special case when dst is NULL (the value of dstLen is ignored - // then) the return value is the length of the needed buffer but nothing - // happens otherwise. If srcLen is wxNO_LEN, the entire string, up to and + // In the special case when dstLen is 0 (outputBuf may be NULL then) the + // return value is the length of the needed buffer but nothing happens + // otherwise. If srcLen is wxNO_LEN, the entire string, up to and // including the trailing NUL(s), is converted, otherwise exactly srcLen // bytes are. // // Typical usage: // // size_t dstLen = conv.ToWChar(NULL, 0, src); - // if ( dstLen == wxCONV_FAILED ) + // if ( dstLen != wxCONV_FAILED ) // ... handle error ... // wchar_t *wbuf = new wchar_t[dstLen]; // conv.ToWChar(wbuf, dstLen, src); - // ... work with wbuf ... - // delete [] wbuf; // virtual size_t ToWChar(wchar_t *dst, size_t dstLen, const char *src, size_t srcLen = wxNO_LEN) const; @@ -88,29 +91,20 @@ public: // Convenience functions for converting strings which may contain embedded // NULs and don't have to be NUL-terminated. // - // inLen is the length of the buffer including trailing NUL if any or - // wxNO_LEN if the input is NUL-terminated. + // inLen is the length of the buffer including trailing NUL if any: if the + // last 4 bytes of the buffer are all NULs, these functions are more + // efficient as they avoid copying the string, but otherwise a copy is made + // internally which could be quite bad for (very) long strings. // // outLen receives, if not NULL, the length of the converted string or 0 if // the conversion failed (returning 0 and not -1 in this case makes it // difficult to distinguish between failed conversion and empty input but - // this is done for backwards compatibility). Notice that the rules for - // whether outLen accounts or not for the last NUL are the same as for - // To/FromWChar() above: if inLen is specified, outLen is exactly the - // number of characters converted, whether the last one of them was NUL or - // not. But if inLen == wxNO_LEN then outLen doesn't account for the last - // NUL even though it is present. + // this is done for backwards compatibility) const wxWCharBuffer cMB2WC(const char *in, size_t inLen, size_t *outLen) const; const wxCharBuffer cWC2MB(const wchar_t *in, size_t inLen, size_t *outLen) const; - // And yet more convenience functions for converting the entire buffers: - // these are the simplest and least error-prone as you never need to bother - // with lengths/sizes directly. - const wxWCharBuffer cMB2WC(const wxScopedCharBuffer& in) const; - const wxCharBuffer cWC2MB(const wxScopedWCharBuffer& in) const; - // convenience functions for converting MB or WC to/from wxWin default #if wxUSE_UNICODE const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } @@ -141,12 +135,6 @@ public: // encoding static size_t GetMaxMBNulLen() { return 4 /* for UTF-32 */; } -#if wxUSE_UNICODE_UTF8 - // return true if the converter's charset is UTF-8, i.e. char* strings - // decoded using this object can be directly copied to wxString's internal - // storage without converting to WC and than back to UTF-8 MB string - virtual bool IsUTF8() const { return false; } -#endif // The old conversion functions. The existing classes currently mostly // implement these ones but we're in transition to using To/FromWChar() @@ -187,10 +175,6 @@ public: virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const; virtual wxMBConv *Clone() const { return new wxMBConvLibc; } - -#if wxUSE_UNICODE_UTF8 - virtual bool IsUTF8() const { return wxLocaleIsUtf8; } -#endif }; #ifdef __UNIX__ @@ -205,7 +189,7 @@ public: class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv { public: - wxConvBrokenFileNames(const wxString& charset); + wxConvBrokenFileNames(const wxChar *charset); wxConvBrokenFileNames(const wxConvBrokenFileNames& conv) : wxMBConv(), m_conv(conv.m_conv ? conv.m_conv->Clone() : NULL) @@ -229,17 +213,13 @@ public: return m_conv->GetMBNulLen(); } -#if wxUSE_UNICODE_UTF8 - virtual bool IsUTF8() const { return m_conv->IsUTF8(); } -#endif - virtual wxMBConv *Clone() const { return new wxConvBrokenFileNames(*this); } private: // the conversion object we forward to wxMBConv *m_conv; - wxDECLARE_NO_ASSIGN_CLASS(wxConvBrokenFileNames); + DECLARE_NO_ASSIGN_CLASS(wxConvBrokenFileNames) }; #endif // __UNIX__ @@ -251,113 +231,17 @@ private: class WXDLLIMPEXP_BASE wxMBConvUTF7 : public wxMBConv { public: - wxMBConvUTF7() { } - - // compiler-generated copy ctor, assignment operator and dtor are ok - // (assuming it's ok to copy the shift state -- not really sure about it) - - virtual size_t ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen = wxNO_LEN) const; - virtual size_t FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen = wxNO_LEN) const; + virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const; + virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const; virtual wxMBConv *Clone() const { return new wxMBConvUTF7; } - -private: - // UTF-7 decoder/encoder may be in direct mode or in shifted mode after a - // '+' (and until the '-' or any other non-base64 character) - struct StateMode - { - enum Mode - { - Direct, // pass through state - Shifted // after a '+' (and before '-') - }; - }; - - // the current decoder state: this is only used by ToWChar() if srcLen - // parameter is not wxNO_LEN, when working on the entire NUL-terminated - // strings we neither update nor use the state - class DecoderState : private StateMode - { - private: - // current state: this one is private as we want to enforce the use of - // ToDirect/ToShifted() methods below - Mode mode; - - public: - // the initial state is direct - DecoderState() { mode = Direct; } - - // switch to/from shifted mode - void ToDirect() { mode = Direct; } - void ToShifted() { mode = Shifted; accum = bit = 0; isLSB = false; } - - bool IsDirect() const { return mode == Direct; } - bool IsShifted() const { return mode == Shifted; } - - - // these variables are only used in shifted mode - - unsigned int accum; // accumulator of the bit we've already got - unsigned int bit; // the number of bits consumed mod 8 - unsigned char msb; // the high byte of UTF-16 word - bool isLSB; // whether we're decoding LSB or MSB of UTF-16 word - }; - - DecoderState m_stateDecoder; - - - // encoder state is simpler as we always receive entire Unicode characters - // on input - class EncoderState : private StateMode - { - private: - Mode mode; - - public: - EncoderState() { mode = Direct; } - - void ToDirect() { mode = Direct; } - void ToShifted() { mode = Shifted; accum = bit = 0; } - - bool IsDirect() const { return mode == Direct; } - bool IsShifted() const { return mode == Shifted; } - - unsigned int accum; - unsigned int bit; - }; - - EncoderState m_stateEncoder; }; // ---------------------------------------------------------------------------- // wxMBConvUTF8 (for conversion using UTF8 encoding) // ---------------------------------------------------------------------------- -// this is the real UTF-8 conversion class, it has to be called "strict UTF-8" -// for compatibility reasons: the wxMBConvUTF8 class below also supports lossy -// conversions if it is created with non default options -class WXDLLIMPEXP_BASE wxMBConvStrictUTF8 : public wxMBConv -{ -public: - // compiler-generated default ctor and other methods are ok - - virtual size_t ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen = wxNO_LEN) const; - virtual size_t FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen = wxNO_LEN) const; - - virtual wxMBConv *Clone() const { return new wxMBConvStrictUTF8(); } - -#if wxUSE_UNICODE_UTF8 - // NB: other mapping modes are not, strictly speaking, UTF-8, so we can't - // take the shortcut in that case - virtual bool IsUTF8() const { return true; } -#endif -}; - -class WXDLLIMPEXP_BASE wxMBConvUTF8 : public wxMBConvStrictUTF8 +class WXDLLIMPEXP_BASE wxMBConvUTF8 : public wxMBConv { public: enum @@ -368,20 +252,11 @@ public: }; wxMBConvUTF8(int options = MAP_INVALID_UTF8_NOT) : m_options(options) { } - - virtual size_t ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen = wxNO_LEN) const; - virtual size_t FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen = wxNO_LEN) const; + virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const; + virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const; virtual wxMBConv *Clone() const { return new wxMBConvUTF8(m_options); } -#if wxUSE_UNICODE_UTF8 - // NB: other mapping modes are not, strictly speaking, UTF-8, so we can't - // take the shortcut in that case - virtual bool IsUTF8() const { return m_options == MAP_INVALID_UTF8_NOT; } -#endif - private: int m_options; }; @@ -490,7 +365,7 @@ class WXDLLIMPEXP_BASE wxCSConv : public wxMBConv public: // we can be created either from charset name or from an encoding constant // but we can't have both at once - wxCSConv(const wxString& charset); + wxCSConv(const wxChar *charset); wxCSConv(wxFontEncoding encoding); wxCSConv(const wxCSConv& conv); @@ -502,53 +377,42 @@ public: const char *src, size_t srcLen = wxNO_LEN) const; virtual size_t FromWChar(char *dst, size_t dstLen, const wchar_t *src, size_t srcLen = wxNO_LEN) const; + virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const; + virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const; virtual size_t GetMBNulLen() const; -#if wxUSE_UNICODE_UTF8 - virtual bool IsUTF8() const; -#endif - virtual wxMBConv *Clone() const { return new wxCSConv(*this); } void Clear(); - // return true if the conversion could be initialized successfully +#if wxABI_VERSION >= 20802 + // return true if the conversion could be initilized successfully bool IsOk() const; +#endif // wx 2.8.2+ private: // common part of all ctors void Init(); - // Creates the conversion to use, called from all ctors to initialize - // m_convReal. + // creates m_convReal if necessary + void CreateConvIfNeeded() const; + + // do create m_convReal (unconditionally) wxMBConv *DoCreate() const; - // Set the name (may be only called when m_name == NULL), makes copy of - // the charset string. - void SetName(const char *charset); - - // Set m_encoding field respecting the rules below, i.e. making sure it has - // a valid value if m_name == NULL (thus this should be always called after - // SetName()). - // - // Input encoding may be valid or not. - void SetEncoding(wxFontEncoding encoding); + // set the name (may be only called when m_name == NULL), makes copy of + // charset string + void SetName(const wxChar *charset); - // The encoding we use is specified by the two fields below: - // - // 1. If m_name != NULL, m_encoding corresponds to it if it's one of - // encodings we know about (i.e. member of wxFontEncoding) or is - // wxFONTENCODING_SYSTEM otherwise. - // - // 2. If m_name == NULL, m_encoding is always valid, i.e. not one of - // wxFONTENCODING_{SYSTEM,DEFAULT,MAX}. - char *m_name; + // note that we can't use wxString here because of compilation + // dependencies: we're included from wx/string.h + wxChar *m_name; wxFontEncoding m_encoding; - // The conversion object for our encoding or NULL if we failed to create it - // in which case we fall back to hard-coded ISO8859-1 conversion. + // use CreateConvIfNeeded() before accessing m_convReal! wxMBConv *m_convReal; + bool m_deferred; }; @@ -556,35 +420,14 @@ private: // declare predefined conversion objects // ---------------------------------------------------------------------------- -// Note: this macro is an implementation detail (see the comment in -// strconv.cpp). The wxGet_XXX() and wxGet_XXXPtr() functions shouldn't be -// used by user code and neither should XXXPtr, use the wxConvXXX macro -// instead. -#define WX_DECLARE_GLOBAL_CONV(klass, name) \ - extern WXDLLIMPEXP_DATA_BASE(klass*) name##Ptr; \ - extern WXDLLIMPEXP_BASE klass* wxGet_##name##Ptr(); \ - inline klass& wxGet_##name() \ - { \ - if ( !name##Ptr ) \ - name##Ptr = wxGet_##name##Ptr(); \ - return *name##Ptr; \ - } - - // conversion to be used with all standard functions affected by locale, e.g. // strtol(), strftime(), ... -WX_DECLARE_GLOBAL_CONV(wxMBConv, wxConvLibc) -#define wxConvLibc wxGet_wxConvLibc() +extern WXDLLIMPEXP_DATA_BASE(wxMBConv&) wxConvLibc; // conversion ISO-8859-1/UTF-7/UTF-8 <-> wchar_t -WX_DECLARE_GLOBAL_CONV(wxCSConv, wxConvISO8859_1) -#define wxConvISO8859_1 wxGet_wxConvISO8859_1() - -WX_DECLARE_GLOBAL_CONV(wxMBConvStrictUTF8, wxConvUTF8) -#define wxConvUTF8 wxGet_wxConvUTF8() - -WX_DECLARE_GLOBAL_CONV(wxMBConvUTF7, wxConvUTF7) -#define wxConvUTF7 wxGet_wxConvUTF7() +extern WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvISO8859_1; +extern WXDLLIMPEXP_DATA_BASE(wxMBConvUTF7&) wxConvUTF7; +extern WXDLLIMPEXP_DATA_BASE(wxMBConvUTF8&) wxConvUTF8; // conversion used for the file names on the systems where they're not Unicode // (basically anything except Windows) @@ -603,8 +446,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName; extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent; // the conversion corresponding to the current locale -WX_DECLARE_GLOBAL_CONV(wxCSConv, wxConvLocal) -#define wxConvLocal wxGet_wxConvLocal() +extern WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal; // the conversion corresponding to the encoding of the standard UI elements // @@ -612,8 +454,6 @@ WX_DECLARE_GLOBAL_CONV(wxCSConv, wxConvLocal) // needs to use a fixed encoding extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; -#undef WX_DECLARE_GLOBAL_CONV - // ---------------------------------------------------------------------------- // endianness-dependent conversions // ---------------------------------------------------------------------------- @@ -631,11 +471,17 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; // ---------------------------------------------------------------------------- // filenames are multibyte on Unix and widechar on Windows +#if defined(__UNIX__) || defined(__WXMAC__) + #define wxMBFILES 1 +#else + #define wxMBFILES 0 +#endif + #if wxMBFILES && wxUSE_UNICODE #define wxFNCONV(name) wxConvFileName->cWX2MB(name) #define wxFNSTRINGCAST wxMBSTRINGCAST #else -#if defined( __WXOSX_OR_COCOA__ ) && wxMBFILES +#if defined( __WXOSX__ ) && wxMBFILES #define wxFNCONV(name) wxConvFileName->cWC2MB( wxConvLocal.cWX2WC(name) ) #else #define wxFNCONV(name) name @@ -643,6 +489,36 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; #define wxFNSTRINGCAST WXSTRINGCAST #endif +#else // !wxUSE_WCHAR_T + +// ---------------------------------------------------------------------------- +// stand-ins in absence of wchar_t +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxMBConv +{ +public: + const char* cMB2WX(const char *psz) const { return psz; } + const char* cWX2MB(const char *psz) const { return psz; } + wxMBConv *Clone() const { return NULL; } +}; + +#define wxConvFile wxConvLocal +#define wxConvUI wxConvCurrent + +typedef wxMBConv wxCSConv; + +extern WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, + wxConvLocal, + wxConvISO8859_1, + wxConvUTF8; +extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent; + +#define wxFNCONV(name) name +#define wxFNSTRINGCAST WXSTRINGCAST + +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T + // ---------------------------------------------------------------------------- // macros for the most common conversions // ---------------------------------------------------------------------------- @@ -651,6 +527,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; #define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) #define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s) +#if wxABI_VERSION >= 20802 // these functions should be used when the conversions really, really have // to succeed (usually because we pass their results to a standard C // function which would crash if we passed NULL to it), so these functions @@ -663,6 +540,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; // this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL) // if it fails extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws); +#endif // wxABI 2.8.2+ #else // ANSI // no conversions to do #define wxConvertWX2MB(s) (s) diff --git a/Source/3rd Party/wx/include/wx/stream.h b/Source/3rd Party/wx/include/wx/stream.h index f615e6246..bea273189 100644 --- a/Source/3rd Party/wx/include/wx/stream.h +++ b/Source/3rd Party/wx/include/wx/stream.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux, Guillermo Rodriguez Garcia, Vadim Zeitlin // Modified by: // Created: 11/07/98 +// RCS-ID: $Id: stream.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -51,7 +52,7 @@ const int wxEOF = -1; // wxStreamBase: common (but non virtual!) base for all stream classes // --------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxStreamBase : public wxObject +class WXDLLIMPEXP_BASE wxStreamBase { public: wxStreamBase(); @@ -63,7 +64,7 @@ public: bool operator!() const { return !IsOk(); } // reset the stream state - void Reset(wxStreamError error = wxSTREAM_NO_ERROR) { m_lasterror = error; } + void Reset() { m_lasterror = wxSTREAM_NO_ERROR; } // this doesn't make sense for all streams, always test its return value virtual size_t GetSize() const; @@ -81,8 +82,7 @@ protected: friend class wxStreamBuffer; - DECLARE_ABSTRACT_CLASS(wxStreamBase) - wxDECLARE_NO_COPY_CLASS(wxStreamBase); + DECLARE_NO_COPY_CLASS(wxStreamBase) }; // ---------------------------------------------------------------------------- @@ -127,11 +127,6 @@ public: // it means that EOF has been reached. virtual wxInputStream& Read(void *buffer, size_t size); - // Read exactly the given number of bytes, unlike Read(), which may read - // less than the requested amount of data without returning an error, this - // method either reads all the data or returns false. - bool ReadAll(void *buffer, size_t size); - // copy the entire contents of this stream into streamOut, stopping only // when EOF is reached or an error occurs wxInputStream& Read(wxOutputStream& streamOut); @@ -221,8 +216,7 @@ protected: friend class wxStreamBuffer; - DECLARE_ABSTRACT_CLASS(wxInputStream) - wxDECLARE_NO_COPY_CLASS(wxInputStream); + DECLARE_NO_COPY_CLASS(wxInputStream) }; // ---------------------------------------------------------------------------- @@ -237,12 +231,6 @@ public: void PutC(char c); virtual wxOutputStream& Write(const void *buffer, size_t size); - - // This is ReadAll() equivalent for Write(): it either writes exactly the - // given number of bytes or returns false, unlike Write() which can write - // less data than requested but still return without error. - bool WriteAll(const void *buffer, size_t size); - wxOutputStream& Write(wxInputStream& stream_in); virtual wxFileOffset SeekO(wxFileOffset pos, wxSeekMode mode = wxFromStart); @@ -263,8 +251,7 @@ protected: friend class wxStreamBuffer; - DECLARE_ABSTRACT_CLASS(wxOutputStream) - wxDECLARE_NO_COPY_CLASS(wxOutputStream); + DECLARE_NO_COPY_CLASS(wxOutputStream) }; // ============================================================================ @@ -280,20 +267,18 @@ class WXDLLIMPEXP_BASE wxCountingOutputStream : public wxOutputStream public: wxCountingOutputStream(); - virtual wxFileOffset GetLength() const; + wxFileOffset GetLength() const; bool Ok() const { return IsOk(); } - virtual bool IsOk() const { return true; } + bool IsOk() const { return true; } protected: virtual size_t OnSysWrite(const void *buffer, size_t size); virtual wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); virtual wxFileOffset OnSysTell() const; - size_t m_currentPos, - m_lastPos; + size_t m_currentPos; - DECLARE_DYNAMIC_CLASS(wxCountingOutputStream) - wxDECLARE_NO_COPY_CLASS(wxCountingOutputStream); + DECLARE_NO_COPY_CLASS(wxCountingOutputStream) }; // --------------------------------------------------------------------------- @@ -318,8 +303,7 @@ protected: wxInputStream *m_parent_i_stream; bool m_owns; - DECLARE_ABSTRACT_CLASS(wxFilterInputStream) - wxDECLARE_NO_COPY_CLASS(wxFilterInputStream); + DECLARE_NO_COPY_CLASS(wxFilterInputStream) }; class WXDLLIMPEXP_BASE wxFilterOutputStream : public wxOutputStream @@ -340,8 +324,7 @@ protected: wxOutputStream *m_parent_o_stream; bool m_owns; - DECLARE_ABSTRACT_CLASS(wxFilterOutputStream) - wxDECLARE_NO_COPY_CLASS(wxFilterOutputStream); + DECLARE_NO_COPY_CLASS(wxFilterOutputStream) }; enum wxStreamProtocolType @@ -365,12 +348,12 @@ public: virtual const wxChar * const *GetProtocols(wxStreamProtocolType type = wxSTREAM_PROTOCOL) const = 0; - bool CanHandle(const wxString& protocol, + bool CanHandle(const wxChar *protocol, wxStreamProtocolType type = wxSTREAM_PROTOCOL) const; protected: - wxString::size_type FindExtension(const wxString& location) const; + wxString::size_type FindExtension(const wxChar *location) const; DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase) }; @@ -385,7 +368,7 @@ public: virtual wxFilterInputStream *NewStream(wxInputStream *stream) const = 0; virtual wxFilterOutputStream *NewStream(wxOutputStream *stream) const = 0; - static const wxFilterClassFactory *Find(const wxString& protocol, + static const wxFilterClassFactory *Find(const wxChar *protocol, wxStreamProtocolType type = wxSTREAM_PROTOCOL); @@ -427,23 +410,7 @@ public: read_write }; - wxStreamBuffer(wxStreamBase& stream, BufMode mode) - { - InitWithStream(stream, mode); - } - - wxStreamBuffer(size_t bufsize, wxInputStream& stream) - { - InitWithStream(stream, read); - SetBufferIO(bufsize); - } - - wxStreamBuffer(size_t bufsize, wxOutputStream& stream) - { - InitWithStream(stream, write); - SetBufferIO(bufsize); - } - + wxStreamBuffer(wxStreamBase& stream, BufMode mode); wxStreamBuffer(const wxStreamBuffer& buf); virtual ~wxStreamBuffer(); @@ -461,7 +428,6 @@ public: // Buffer control void ResetBuffer(); - void Truncate(); // NB: the buffer must always be allocated with malloc() if takeOwn is // true as it will be deallocated by free() @@ -471,7 +437,7 @@ public: void *GetBufferStart() const { return m_buffer_start; } void *GetBufferEnd() const { return m_buffer_end; } void *GetBufferPos() const { return m_buffer_pos; } - size_t GetBufferSize() const { return m_buffer_end - m_buffer_start; } + size_t GetBufferSize() const { return m_buffer_size; } size_t GetIntPosition() const { return m_buffer_pos - m_buffer_start; } void SetIntPosition(size_t pos) { m_buffer_pos = m_buffer_start + pos; } size_t GetLastAccess() const { return m_buffer_end - m_buffer_start; } @@ -486,7 +452,7 @@ public: // misc accessors wxStreamBase *GetStream() const { return m_stream; } - bool HasBuffer() const { return m_buffer_start != m_buffer_end; } + bool HasBuffer() const { return m_buffer_size != 0; } bool IsFixed() const { return m_fixed; } bool IsFlushable() const { return m_flushable; } @@ -514,9 +480,6 @@ protected: // common part of several ctors void Init(); - // common part of ctors taking wxStreamBase parameter - void InitWithStream(wxStreamBase& stream, BufMode mode); - // init buffer variables to be empty void InitBuffer(); @@ -529,6 +492,10 @@ protected: *m_buffer_end, *m_buffer_pos; + // the buffer size + // FIXME: isn't it the same as m_buffer_end - m_buffer_start? (VZ) + size_t m_buffer_size; + // the stream we're associated with wxStreamBase *m_stream; @@ -540,8 +507,13 @@ protected: m_fixed, m_flushable; - - wxDECLARE_NO_ASSIGN_CLASS(wxStreamBuffer); +private: +// Cannot use +// DECLARE_NO_COPY_CLASS(wxStreamBuffer) +// because copy constructor is explicitly declared above; +// but no copy assignment operator is defined, so declare +// it private to prevent the compiler from defining it: + wxStreamBuffer& operator=(const wxStreamBuffer&); }; // --------------------------------------------------------------------------- @@ -551,19 +523,9 @@ protected: class WXDLLIMPEXP_BASE wxBufferedInputStream : public wxFilterInputStream { public: - // create a buffered stream on top of the specified low-level stream - // - // if a non NULL buffer is given to the stream, it will be deleted by it, - // otherwise a default 1KB buffer will be used + // if a non NULL buffer is given to the stream, it will be deleted by it wxBufferedInputStream(wxInputStream& stream, wxStreamBuffer *buffer = NULL); - - // ctor allowing to specify the buffer size, it's just a more convenient - // alternative to creating wxStreamBuffer, calling its SetBufferIO(bufsize) - // and using the ctor above - wxBufferedInputStream(wxInputStream& stream, size_t bufsize); - - virtual ~wxBufferedInputStream(); char Peek(); @@ -590,7 +552,7 @@ protected: wxStreamBuffer *m_i_streambuf; - wxDECLARE_NO_COPY_CLASS(wxBufferedInputStream); + DECLARE_NO_COPY_CLASS(wxBufferedInputStream) }; // ---------------------------------------------------------------------------- @@ -600,18 +562,9 @@ protected: class WXDLLIMPEXP_BASE wxBufferedOutputStream : public wxFilterOutputStream { public: - // create a buffered stream on top of the specified low-level stream - // - // if a non NULL buffer is given to the stream, it will be deleted by it, - // otherwise a default 1KB buffer will be used + // if a non NULL buffer is given to the stream, it will be deleted by it wxBufferedOutputStream(wxOutputStream& stream, wxStreamBuffer *buffer = NULL); - - // ctor allowing to specify the buffer size, it's just a more convenient - // alternative to creating wxStreamBuffer, calling its SetBufferIO(bufsize) - // and using the ctor above - wxBufferedOutputStream(wxOutputStream& stream, size_t bufsize); - virtual ~wxBufferedOutputStream(); wxOutputStream& Write(const void *buffer, size_t size); @@ -642,7 +595,7 @@ protected: wxStreamBuffer *m_o_streambuf; - wxDECLARE_NO_COPY_CLASS(wxBufferedOutputStream); + DECLARE_NO_COPY_CLASS(wxBufferedOutputStream) }; #if WXWIN_COMPATIBILITY_2_6 @@ -651,54 +604,6 @@ protected: inline wxStreamBuffer *wxBufferedOutputStream::OutputStreamBuffer() const { return m_o_streambuf; } #endif // WXWIN_COMPATIBILITY_2_6 -// --------------------------------------------------------------------------- -// wxWrapperInputStream: forwards all IO to another stream. -// --------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxWrapperInputStream : public wxFilterInputStream -{ -public: - // Constructor fully initializing the stream. The overload taking pointer - // takes ownership of the parent stream, the one taking reference does not. - // - // Notice that this class also has a default ctor but it's protected as the - // derived class is supposed to take care of calling InitParentStream() if - // it's used. - wxWrapperInputStream(wxInputStream& stream); - wxWrapperInputStream(wxInputStream* stream); - - // Override the base class methods to forward to the wrapped stream. - virtual wxFileOffset GetLength() const; - virtual bool IsSeekable() const; - -protected: - virtual size_t OnSysRead(void *buffer, size_t size); - virtual wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); - virtual wxFileOffset OnSysTell() const; - - // Ensure that our own last error is the same as that of the real stream. - // - // This method is const because the error must be updated even from const - // methods (in other words, it really should have been mutable in the first - // place). - void SynchronizeLastError() const - { - const_cast(this)-> - Reset(m_parent_i_stream->GetLastError()); - } - - // Default constructor, use InitParentStream() later. - wxWrapperInputStream(); - - // Set up the wrapped stream for an object initialized using the default - // constructor. The ownership logic is the same as above. - void InitParentStream(wxInputStream& stream); - void InitParentStream(wxInputStream* stream); - - wxDECLARE_NO_COPY_CLASS(wxWrapperInputStream); -}; - - #endif // wxUSE_STREAMS #endif // _WX_WXSTREAM_H__ diff --git a/Source/3rd Party/wx/include/wx/string.h b/Source/3rd Party/wx/include/wx/string.h index ecf47d654..b478747c8 100644 --- a/Source/3rd Party/wx/include/wx/string.h +++ b/Source/3rd Party/wx/include/wx/string.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/string.h -// Purpose: wxString class +// Purpose: wxString and wxArrayString classes // Author: Vadim Zeitlin // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: string.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,8 +15,8 @@ missing from string.h. */ -#ifndef _WX_WXSTRING_H__ -#define _WX_WXSTRING_H__ +#ifndef _WX_WXSTRINGH__ +#define _WX_WXSTRINGH__ // ---------------------------------------------------------------------------- // headers @@ -42,59 +43,20 @@ # include #endif -#include "wx/wxcrtbase.h" // for wxChar, wxStrlen() etc. -#include "wx/strvararg.h" +#ifdef HAVE_STRCASECMP_IN_STRINGS_H + #include // for strcasecmp() +#endif // HAVE_STRCASECMP_IN_STRINGS_H + +#ifdef __WXPALMOS__ + #include +#endif + +#include "wx/wxchar.h" // for wxChar #include "wx/buffer.h" // for wxCharBuffer #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes -#include "wx/stringimpl.h" -#include "wx/stringops.h" -#include "wx/unichar.h" - -// by default we cache the mapping of the positions in UTF-8 string to the byte -// offset as this results in noticeable performance improvements for loops over -// strings using indices; comment out this line to disable this -// -// notice that this optimization is well worth using even in debug builds as it -// changes asymptotic complexity of algorithms using indices to iterate over -// wxString back to expected linear from quadratic -// -// also notice that wxTLS_TYPE() (__declspec(thread) in this case) is unsafe to -// use in DLL build under pre-Vista Windows so we disable this code for now, if -// anybody really needs to use UTF-8 build under Windows with this optimization -// it would have to be re-tested and probably corrected -// CS: under OSX release builds the string destructor/cache cleanup sometimes -// crashes, disable until we find the true reason or a better workaround -#if wxUSE_UNICODE_UTF8 && !defined(__WINDOWS__) && !defined(__WXOSX__) - #define wxUSE_STRING_POS_CACHE 1 -#else - #define wxUSE_STRING_POS_CACHE 0 -#endif - -#if wxUSE_STRING_POS_CACHE - #include "wx/tls.h" - - // change this 0 to 1 to enable additional (very expensive) asserts - // verifying that string caching logic works as expected - #if 0 - #define wxSTRING_CACHE_ASSERT(cond) wxASSERT(cond) - #else - #define wxSTRING_CACHE_ASSERT(cond) - #endif -#endif // wxUSE_STRING_POS_CACHE class WXDLLIMPEXP_FWD_BASE wxString; -// unless this symbol is predefined to disable the compatibility functions, do -// use them -#ifndef WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - #define WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER 1 -#endif - -namespace wxPrivate -{ - template struct wxStringAsBufHelper; -} - // --------------------------------------------------------------------------- // macros // --------------------------------------------------------------------------- @@ -106,6 +68,10 @@ namespace wxPrivate #define wxMBSTRINGCAST (char *)(const char *) #define wxWCSTRINGCAST (wchar_t *)(const wchar_t *) +// implementation only +#define wxASSERT_VALID_INDEX(i) \ + wxASSERT_MSG( (size_t)(i) <= length(), wxT("invalid index in wxString") ) + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -115,293 +81,590 @@ namespace wxPrivate // deprecated in favour of wxString::npos, don't use in new code // // maximum possible length for a string means "take all string" everywhere -#define wxSTRING_MAXLEN wxString::npos +#define wxSTRING_MAXLEN wxStringBase::npos #endif // WXWIN_COMPATIBILITY_2_6 +// ---------------------------------------------------------------------------- +// global data +// ---------------------------------------------------------------------------- + +// global pointer to empty string +extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString; + // --------------------------------------------------------------------------- // global functions complementing standard C string library replacements for // strlen() and portable strcasecmp() //--------------------------------------------------------------------------- -#if WXWIN_COMPATIBILITY_2_8 -// Use wxXXX() functions from wxcrt.h instead! These functions are for +// Use wxXXX() functions from wxchar.h instead! These functions are for // backwards compatibility only. // checks whether the passed in pointer is NULL and if the string is empty -wxDEPRECATED_MSG("use wxIsEmpty() instead") inline bool IsEmpty(const char *p) { return (!p || !*p); } // safe version of strlen() (returns 0 if passed NULL pointer) -wxDEPRECATED_MSG("use wxStrlen() instead") inline size_t Strlen(const char *psz) { return psz ? strlen(psz) : 0; } // portable strcasecmp/_stricmp -wxDEPRECATED_MSG("use wxStricmp() instead") inline int Stricmp(const char *psz1, const char *psz2) - { return wxCRT_StricmpA(psz1, psz2); } - -#endif // WXWIN_COMPATIBILITY_2_8 - -// ---------------------------------------------------------------------------- -// wxCStrData -// ---------------------------------------------------------------------------- - -// Lightweight object returned by wxString::c_str() and implicitly convertible -// to either const char* or const wchar_t*. -class wxCStrData { -private: - // Ctors; for internal use by wxString and wxCStrData only - wxCStrData(const wxString *str, size_t offset = 0, bool owned = false) - : m_str(str), m_offset(offset), m_owned(owned) {} +#if defined(__VISUALC__) && defined(__WXWINCE__) + register char c1, c2; + do { + c1 = tolower(*psz1++); + c2 = tolower(*psz2++); + } while ( c1 && (c1 == c2) ); -public: - // Ctor constructs the object from char literal; they are needed to make - // operator?: compile and they intentionally take char*, not const char* - inline wxCStrData(char *buf); - inline wxCStrData(wchar_t *buf); - inline wxCStrData(const wxCStrData& data); + return c1 - c2; +#elif defined(__VISUALC__) || ( defined(__MWERKS__) && defined(__INTEL__) ) + return _stricmp(psz1, psz2); +#elif defined(__SC__) + return _stricmp(psz1, psz2); +#elif defined(__SALFORDC__) + return stricmp(psz1, psz2); +#elif defined(__BORLANDC__) + return stricmp(psz1, psz2); +#elif defined(__WATCOMC__) + return stricmp(psz1, psz2); +#elif defined(__DJGPP__) + return stricmp(psz1, psz2); +#elif defined(__EMX__) + return stricmp(psz1, psz2); +#elif defined(__WXPM__) + return stricmp(psz1, psz2); +#elif defined(__WXPALMOS__) || \ + defined(HAVE_STRCASECMP_IN_STRING_H) || \ + defined(HAVE_STRCASECMP_IN_STRINGS_H) || \ + defined(__GNUWIN32__) + return strcasecmp(psz1, psz2); +#elif defined(__MWERKS__) && !defined(__INTEL__) + register char c1, c2; + do { + c1 = tolower(*psz1++); + c2 = tolower(*psz2++); + } while ( c1 && (c1 == c2) ); - inline ~wxCStrData(); + return c1 - c2; +#else + // almost all compilers/libraries provide this function (unfortunately under + // different names), that's why we don't implement our own which will surely + // be more efficient than this code (uncomment to use): + /* + register char c1, c2; + do { + c1 = tolower(*psz1++); + c2 = tolower(*psz2++); + } while ( c1 && (c1 == c2) ); - // AsWChar() and AsChar() can't be defined here as they use wxString and so - // must come after it and because of this won't be inlined when called from - // wxString methods (without a lot of work to extract these wxString methods - // from inside the class itself). But we still define them being inline - // below to let compiler inline them from elsewhere. And because of this we - // must declare them as inline here because otherwise some compilers give - // warnings about them, e.g. mingw32 3.4.5 warns about " defined - // locally after being referenced with dllimport linkage" while IRIX - // mipsPro 7.4 warns about "function declared inline after being called". - inline const wchar_t* AsWChar() const; - operator const wchar_t*() const { return AsWChar(); } + return c1 - c2; + */ - inline const char* AsChar() const; - const unsigned char* AsUnsignedChar() const - { return (const unsigned char *) AsChar(); } - operator const char*() const { return AsChar(); } - operator const unsigned char*() const { return AsUnsignedChar(); } - - operator const void*() const { return AsChar(); } - - // returns buffers that are valid as long as the associated wxString exists - const wxScopedCharBuffer AsCharBuf() const - { - return wxScopedCharBuffer::CreateNonOwned(AsChar()); - } - - const wxScopedWCharBuffer AsWCharBuf() const - { - return wxScopedWCharBuffer::CreateNonOwned(AsWChar()); - } - - inline wxString AsString() const; - - // returns the value as C string in internal representation (equivalent - // to AsString().wx_str(), but more efficient) - const wxStringCharType *AsInternal() const; - - // allow expressions like "c_str()[0]": - inline wxUniChar operator[](size_t n) const; - wxUniChar operator[](int n) const { return operator[](size_t(n)); } - wxUniChar operator[](long n) const { return operator[](size_t(n)); } -#ifndef wxSIZE_T_IS_UINT - wxUniChar operator[](unsigned int n) const { return operator[](size_t(n)); } -#endif // size_t != unsigned int - - // These operators are needed to emulate the pointer semantics of c_str(): - // expressions like "wxChar *p = str.c_str() + 1;" should continue to work - // (we need both versions to resolve ambiguities). Note that this means - // the 'n' value is interpreted as addition to char*/wchar_t* pointer, it - // is *not* number of Unicode characters in wxString. - wxCStrData operator+(int n) const - { return wxCStrData(m_str, m_offset + n, m_owned); } - wxCStrData operator+(long n) const - { return wxCStrData(m_str, m_offset + n, m_owned); } - wxCStrData operator+(size_t n) const - { return wxCStrData(m_str, m_offset + n, m_owned); } - - // and these for "str.c_str() + (p2 - p1)" (it also works for any integer - // expression but it must be ptrdiff_t and not e.g. int to work in this - // example): - wxCStrData operator-(ptrdiff_t n) const - { - wxASSERT_MSG( n <= (ptrdiff_t)m_offset, - wxT("attempt to construct address before the beginning of the string") ); - return wxCStrData(m_str, m_offset - n, m_owned); - } - - // this operator is needed to make expressions like "*c_str()" or - // "*(c_str() + 2)" work - inline wxUniChar operator*() const; - -private: - // the wxString this object was returned for - const wxString *m_str; - // Offset into c_str() return value. Note that this is *not* offset in - // m_str in Unicode characters. Instead, it is index into the - // char*/wchar_t* buffer returned by c_str(). It's interpretation depends - // on how is the wxCStrData instance used: if it is eventually cast to - // const char*, m_offset will be in bytes form string's start; if it is - // cast to const wchar_t*, it will be in wchar_t values. - size_t m_offset; - // should m_str be deleted, i.e. is it owned by us? - bool m_owned; - - friend class WXDLLIMPEXP_FWD_BASE wxString; -}; + #error "Please define string case-insensitive compare for your OS/compiler" +#endif // OS/compiler +} // ---------------------------------------------------------------------------- -// wxStringPrintfMixin +// deal with STL/non-STL/non-STL-but-wxUSE_STD_STRING +// ---------------------------------------------------------------------------- + +// in both cases we need to define wxStdString +#if wxUSE_STL || wxUSE_STD_STRING + +#include "wx/beforestd.h" +#include +#include "wx/afterstd.h" + +#if wxUSE_UNICODE + #ifdef HAVE_STD_WSTRING + typedef std::wstring wxStdString; + #else + typedef std::basic_string wxStdString; + #endif +#else + typedef std::string wxStdString; +#endif + +#endif // need + +#if wxUSE_STL + + // we don't need an extra ctor from std::string when copy ctor already does + // the work + #undef wxUSE_STD_STRING + #define wxUSE_STD_STRING 0 + + #if (defined(__GNUG__) && (__GNUG__ < 3)) || \ + (defined(_MSC_VER) && (_MSC_VER <= 1200)) + #define wxSTRING_BASE_HASNT_CLEAR + #endif + + typedef wxStdString wxStringBase; +#else // if !wxUSE_STL + +#if !defined(HAVE_STD_STRING_COMPARE) && \ + (!defined(__WX_SETUP_H__) || wxUSE_STL == 0) + #define HAVE_STD_STRING_COMPARE +#endif + +// --------------------------------------------------------------------------- +// string data prepended with some housekeeping info (used by wxString class), +// is never used directly (but had to be put here to allow inlining) // --------------------------------------------------------------------------- -// NB: VC6 has a bug that causes linker errors if you have template methods -// in a class using __declspec(dllimport). The solution is to split such -// class into two classes, one that contains the template methods and does -// *not* use WXDLLIMPEXP_BASE and another class that contains the rest -// (with DLL linkage). -// -// We only do this for VC6 here, because the code is less efficient -// (Printf() has to use dynamic_cast<>) and because OpenWatcom compiler -// cannot compile this code. - -#if defined(__VISUALC__) && __VISUALC__ < 1300 - #define wxNEEDS_WXSTRING_PRINTF_MIXIN -#endif - -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN -// this class contains implementation of wxString's vararg methods, it's -// exported from wxBase DLL -class WXDLLIMPEXP_BASE wxStringPrintfMixinBase +struct WXDLLIMPEXP_BASE wxStringData { -protected: - wxStringPrintfMixinBase() {} + int nRefs; // reference count + size_t nDataLength, // actual string length + nAllocLength; // allocated memory size -#if !wxUSE_UTF8_LOCALE_ONLY - int DoPrintfWchar(const wxChar *format, ...); - static wxString DoFormatWchar(const wxChar *format, ...); + // mimics declaration 'wxChar data[nAllocLength]' + wxChar* data() const { return (wxChar*)(this + 1); } + + // empty string has a special ref count so it's never deleted + bool IsEmpty() const { return (nRefs == -1); } + bool IsShared() const { return (nRefs > 1); } + + // lock/unlock + void Lock() { if ( !IsEmpty() ) nRefs++; } + + // VC++ will refuse to inline Unlock but profiling shows that it is wrong +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) + __forceinline #endif -#if wxUSE_UNICODE_UTF8 - int DoPrintfUtf8(const char *format, ...); - static wxString DoFormatUtf8(const char *format, ...); + // VC++ free must take place in same DLL as allocation when using non dll + // run-time library (e.g. Multithreaded instead of Multithreaded DLL) +#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) + void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); } + // we must not inline deallocation since allocation is not inlined + void Free(); +#else + void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } #endif + + // if we had taken control over string memory (GetWriteBuf), it's + // intentionally put in invalid state + void Validate(bool b) { nRefs = (b ? 1 : 0); } + bool IsValid() const { return (nRefs != 0); } }; -// this class contains template wrappers for wxString's vararg methods, it's -// intentionally *not* exported from the DLL in order to fix the VC6 bug -// described above -class wxStringPrintfMixin : public wxStringPrintfMixinBase +class WXDLLIMPEXP_BASE wxStringBase { -private: - // to further complicate things, we can't return wxString from - // wxStringPrintfMixin::Format() because wxString is not yet declared at - // this point; the solution is to use this fake type trait template - this - // way the compiler won't know the return type until Format() is used - // (this doesn't compile with Watcom, but VC6 compiles it just fine): - template struct StringReturnType - { - typedef wxString type; - }; +#if !wxUSE_STL +friend class WXDLLIMPEXP_FWD_BASE wxArrayString; +#endif +public : + // an 'invalid' value for string index, moved to this place due to a CW bug + static const size_t npos; +protected: + // points to data preceded by wxStringData structure with ref count info + wxChar *m_pchData; + // accessor to string data + wxStringData* GetStringData() const { return (wxStringData*)m_pchData - 1; } + + // string (re)initialization functions + // initializes the string to the empty value (must be called only from + // ctors, use Reinit() otherwise) + void Init() { m_pchData = (wxChar *)wxEmptyString; } + // initializes the string with (a part of) C-string + void InitWith(const wxChar *psz, size_t nPos = 0, size_t nLen = npos); + // as Init, but also frees old data + void Reinit() { GetStringData()->Unlock(); Init(); } + + // memory allocation + // allocates memory for string of length nLen + bool AllocBuffer(size_t nLen); + // copies data to another string + bool AllocCopy(wxString&, int, int) const; + // effectively copies data to string + bool AssignCopy(size_t, const wxChar *); + + // append a (sub)string + bool ConcatSelf(size_t nLen, const wxChar *src, size_t nMaxLen); + bool ConcatSelf(size_t nLen, const wxChar *src) + { return ConcatSelf(nLen, src, nLen); } + + // functions called before writing to the string: they copy it if there + // are other references to our data (should be the only owner when writing) + bool CopyBeforeWrite(); + bool AllocBeforeWrite(size_t); + + // compatibility with wxString + bool Alloc(size_t nLen); public: - // these are duplicated wxString methods, they're also declared below - // if !wxNEEDS_WXSTRING_PRINTF_MIXIN: + // standard types + typedef wxChar value_type; + typedef wxChar char_type; + typedef size_t size_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type *iterator; + typedef const value_type *const_iterator; - // static wxString Format(const wString& format, ...) WX_ATTRIBUTE_PRINTF_1; - WX_DEFINE_VARARG_FUNC_SANS_N0(static typename StringReturnType::type, - Format, 1, (const wxFormatString&), - DoFormatWchar, DoFormatUtf8) - // We have to implement the version without template arguments manually - // because of the StringReturnType<> hack, although WX_DEFINE_VARARG_FUNC - // normally does it itself. It has to be a template so that we can use - // the hack, even though there's no real template parameter. We can't move - // it to wxStrig, because it would shadow these versions of Format() then. - template - inline static typename StringReturnType::type - Format(const T& fmt) - { - // NB: this doesn't compile if T is not (some form of) a string; - // this makes Format's prototype equivalent to - // Format(const wxFormatString& fmt) - return DoFormatWchar(wxFormatString(fmt)); +#define wxSTRING_REVERSE_ITERATOR(name, const_or_not) \ + class name \ + { \ + public: \ + typedef wxChar value_type; \ + typedef const_or_not value_type& reference; \ + typedef const_or_not value_type *pointer; \ + typedef const_or_not value_type *iterator_type; \ + \ + name(iterator_type i) : m_cur(i) { } \ + name(const name& ri) : m_cur(ri.m_cur) { } \ + \ + iterator_type base() const { return m_cur; } \ + \ + reference operator*() const { return *(m_cur - 1); } \ + \ + name& operator++() { --m_cur; return *this; } \ + name operator++(int) { name tmp = *this; --m_cur; return tmp; } \ + name& operator--() { ++m_cur; return *this; } \ + name operator--(int) { name tmp = *this; ++m_cur; return tmp; } \ + \ + bool operator==(name ri) const { return m_cur == ri.m_cur; } \ + bool operator!=(name ri) const { return !(*this == ri); } \ + \ + private: \ + iterator_type m_cur; \ + } + + wxSTRING_REVERSE_ITERATOR(const_reverse_iterator, const); + + #define wxSTRING_CONST + wxSTRING_REVERSE_ITERATOR(reverse_iterator, wxSTRING_CONST); + #undef wxSTRING_CONST + + #undef wxSTRING_REVERSE_ITERATOR + + + // constructors and destructor + // ctor for an empty string + wxStringBase() { Init(); } + // copy ctor + wxStringBase(const wxStringBase& stringSrc) + { + wxASSERT_MSG( stringSrc.GetStringData()->IsValid(), + wxT("did you forget to call UngetWriteBuf()?") ); + + if ( stringSrc.empty() ) { + // nothing to do for an empty string + Init(); } + else { + m_pchData = stringSrc.m_pchData; // share same data + GetStringData()->Lock(); // => one more copy + } + } + // string containing nRepeat copies of ch + wxStringBase(size_type nRepeat, wxChar ch); + // ctor takes first nLength characters from C string + // (default value of npos means take all the string) + wxStringBase(const wxChar *psz) + { InitWith(psz, 0, npos); } + wxStringBase(const wxChar *psz, size_t nLength) + { InitWith(psz, 0, nLength); } + wxStringBase(const wxChar *psz, + const wxMBConv& WXUNUSED(conv), + size_t nLength = npos) + { InitWith(psz, 0, nLength); } + // take nLen chars starting at nPos + wxStringBase(const wxStringBase& str, size_t nPos, size_t nLen) + { + wxASSERT_MSG( str.GetStringData()->IsValid(), + wxT("did you forget to call UngetWriteBuf()?") ); + Init(); + size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen; + InitWith(str.c_str(), nPos, nLen); + } + // take all characters from pStart to pEnd + wxStringBase(const void *pStart, const void *pEnd); - // int Printf(const wxString& format, ...); - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&), - DoPrintfWchar, DoPrintfUtf8) - // int sprintf(const wxString& format, ...) WX_ATTRIBUTE_PRINTF_2; - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxFormatString&), - DoPrintfWchar, DoPrintfUtf8) + // dtor is not virtual, this class must not be inherited from! + ~wxStringBase() + { +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) + //RN - according to the above VC++ does indeed inline this, + //even though it spits out two warnings + #pragma warning (disable:4714) +#endif -protected: - wxStringPrintfMixin() : wxStringPrintfMixinBase() {} + GetStringData()->Unlock(); + } + +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) + //re-enable inlining warning + #pragma warning (default:4714) +#endif + // overloaded assignment + // from another wxString + wxStringBase& operator=(const wxStringBase& stringSrc); + // from a character + wxStringBase& operator=(wxChar ch); + // from a C string + wxStringBase& operator=(const wxChar *psz); + + // return the length of the string + size_type length() const { return GetStringData()->nDataLength; } + // return the length of the string + size_type size() const { return length(); } + // return the maximum size of the string + size_type max_size() const { return npos; } + // resize the string, filling the space with c if c != 0 + void resize(size_t nSize, wxChar ch = wxT('\0')); + // delete the contents of the string + void clear() { erase(0, npos); } + // returns true if the string is empty + bool empty() const { return length() == 0; } + // inform string about planned change in size + void reserve(size_t sz) { Alloc(sz); } + size_type capacity() const { return GetStringData()->nAllocLength; } + + // lib.string.access + // return the character at position n + value_type at(size_type n) const + { wxASSERT_VALID_INDEX( n ); return m_pchData[n]; } + // returns the writable character at position n + reference at(size_type n) + { wxASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; } + + // lib.string.modifiers + // append elements str[pos], ..., str[pos+n] + wxStringBase& append(const wxStringBase& str, size_t pos, size_t n) + { + wxASSERT(pos <= str.length()); + ConcatSelf(n, str.c_str() + pos, str.length() - pos); + return *this; + } + // append a string + wxStringBase& append(const wxStringBase& str) + { ConcatSelf(str.length(), str.c_str()); return *this; } + // append first n (or all if n == npos) characters of sz + wxStringBase& append(const wxChar *sz) + { ConcatSelf(wxStrlen(sz), sz); return *this; } + wxStringBase& append(const wxChar *sz, size_t n) + { ConcatSelf(n, sz); return *this; } + // append n copies of ch + wxStringBase& append(size_t n, wxChar ch); + // append from first to last + wxStringBase& append(const_iterator first, const_iterator last) + { ConcatSelf(last - first, first); return *this; } + + // same as `this_string = str' + wxStringBase& assign(const wxStringBase& str) + { return *this = str; } + // same as ` = str[pos..pos + n] + wxStringBase& assign(const wxStringBase& str, size_t pos, size_t n) + { clear(); return append(str, pos, n); } + // same as `= first n (or all if n == npos) characters of sz' + wxStringBase& assign(const wxChar *sz) + { clear(); return append(sz, wxStrlen(sz)); } + wxStringBase& assign(const wxChar *sz, size_t n) + { clear(); return append(sz, n); } + // same as `= n copies of ch' + wxStringBase& assign(size_t n, wxChar ch) + { clear(); return append(n, ch); } + // assign from first to last + wxStringBase& assign(const_iterator first, const_iterator last) + { clear(); return append(first, last); } + + // first valid index position + const_iterator begin() const { return m_pchData; } + iterator begin(); + // position one after the last valid one + const_iterator end() const { return m_pchData + length(); } + iterator end(); + + // first element of the reversed string + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rbegin() { return reverse_iterator(end()); } + // one beyond the end of the reversed string + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + + // insert another string + wxStringBase& insert(size_t nPos, const wxStringBase& str) + { + wxASSERT( str.GetStringData()->IsValid() ); + return insert(nPos, str.c_str(), str.length()); + } + // insert n chars of str starting at nStart (in str) + wxStringBase& insert(size_t nPos, const wxStringBase& str, size_t nStart, size_t n) + { + wxASSERT( str.GetStringData()->IsValid() ); + wxASSERT( nStart < str.length() ); + size_t strLen = str.length() - nStart; + n = strLen < n ? strLen : n; + return insert(nPos, str.c_str() + nStart, n); + } + // insert first n (or all if n == npos) characters of sz + wxStringBase& insert(size_t nPos, const wxChar *sz, size_t n = npos); + // insert n copies of ch + wxStringBase& insert(size_t nPos, size_t n, wxChar ch) + { return insert(nPos, wxStringBase(n, ch)); } + iterator insert(iterator it, wxChar ch) + { size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; } + void insert(iterator it, const_iterator first, const_iterator last) + { insert(it - begin(), first, last - first); } + void insert(iterator it, size_type n, wxChar ch) + { insert(it - begin(), n, ch); } + + // delete characters from nStart to nStart + nLen + wxStringBase& erase(size_type pos = 0, size_type n = npos); + iterator erase(iterator first, iterator last) + { + size_t idx = first - begin(); + erase(idx, last - first); + return begin() + idx; + } + iterator erase(iterator first); + + // explicit conversion to C string (use this with printf()!) + const wxChar* c_str() const { return m_pchData; } + const wxChar* data() const { return m_pchData; } + + // replaces the substring of length nLen starting at nStart + wxStringBase& replace(size_t nStart, size_t nLen, const wxChar* sz); + // replaces the substring of length nLen starting at nStart + wxStringBase& replace(size_t nStart, size_t nLen, const wxStringBase& str) + { return replace(nStart, nLen, str.c_str()); } + // replaces the substring with nCount copies of ch + wxStringBase& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch); + // replaces a substring with another substring + wxStringBase& replace(size_t nStart, size_t nLen, + const wxStringBase& str, size_t nStart2, size_t nLen2); + // replaces the substring with first nCount chars of sz + wxStringBase& replace(size_t nStart, size_t nLen, + const wxChar* sz, size_t nCount); + wxStringBase& replace(iterator first, iterator last, const_pointer s) + { return replace(first - begin(), last - first, s); } + wxStringBase& replace(iterator first, iterator last, const_pointer s, + size_type n) + { return replace(first - begin(), last - first, s, n); } + wxStringBase& replace(iterator first, iterator last, const wxStringBase& s) + { return replace(first - begin(), last - first, s); } + wxStringBase& replace(iterator first, iterator last, size_type n, wxChar c) + { return replace(first - begin(), last - first, n, c); } + wxStringBase& replace(iterator first, iterator last, + const_iterator first1, const_iterator last1) + { return replace(first - begin(), last - first, first1, last1 - first1); } + + // swap two strings + void swap(wxStringBase& str); + + // All find() functions take the nStart argument which specifies the + // position to start the search on, the default value is 0. All functions + // return npos if there were no match. + + // find a substring + size_t find(const wxStringBase& str, size_t nStart = 0) const; + + // find first n characters of sz + size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const; + + // find the first occurence of character ch after nStart + size_t find(wxChar ch, size_t nStart = 0) const; + + // rfind() family is exactly like find() but works right to left + + // as find, but from the end + size_t rfind(const wxStringBase& str, size_t nStart = npos) const; + + // as find, but from the end + size_t rfind(const wxChar* sz, size_t nStart = npos, + size_t n = npos) const; + // as find, but from the end + size_t rfind(wxChar ch, size_t nStart = npos) const; + + // find first/last occurence of any character in the set + + // as strpbrk() but starts at nStart, returns npos if not found + size_t find_first_of(const wxStringBase& str, size_t nStart = 0) const + { return find_first_of(str.c_str(), nStart); } + // same as above + size_t find_first_of(const wxChar* sz, size_t nStart = 0) const; + size_t find_first_of(const wxChar* sz, size_t nStart, size_t n) const; + // same as find(char, size_t) + size_t find_first_of(wxChar c, size_t nStart = 0) const + { return find(c, nStart); } + // find the last (starting from nStart) char from str in this string + size_t find_last_of (const wxStringBase& str, size_t nStart = npos) const + { return find_last_of(str.c_str(), nStart); } + // same as above + size_t find_last_of (const wxChar* sz, size_t nStart = npos) const; + size_t find_last_of(const wxChar* sz, size_t nStart, size_t n) const; + // same as above + size_t find_last_of(wxChar c, size_t nStart = npos) const + { return rfind(c, nStart); } + + // find first/last occurence of any character not in the set + + // as strspn() (starting from nStart), returns npos on failure + size_t find_first_not_of(const wxStringBase& str, size_t nStart = 0) const + { return find_first_not_of(str.c_str(), nStart); } + // same as above + size_t find_first_not_of(const wxChar* sz, size_t nStart = 0) const; + size_t find_first_not_of(const wxChar* sz, size_t nStart, size_t n) const; + // same as above + size_t find_first_not_of(wxChar ch, size_t nStart = 0) const; + // as strcspn() + size_t find_last_not_of(const wxStringBase& str, size_t nStart = npos) const + { return find_last_not_of(str.c_str(), nStart); } + // same as above + size_t find_last_not_of(const wxChar* sz, size_t nStart = npos) const; + size_t find_last_not_of(const wxChar* sz, size_t nStart, size_t n) const; + // same as above + size_t find_last_not_of(wxChar ch, size_t nStart = npos) const; + + // All compare functions return -1, 0 or 1 if the [sub]string is less, + // equal or greater than the compare() argument. + + // comparison with another string + int compare(const wxStringBase& str) const; + // comparison with a substring + int compare(size_t nStart, size_t nLen, const wxStringBase& str) const; + // comparison of 2 substrings + int compare(size_t nStart, size_t nLen, + const wxStringBase& str, size_t nStart2, size_t nLen2) const; + // comparison with a c string + int compare(const wxChar* sz) const; + // substring comparison with first nCount characters of sz + int compare(size_t nStart, size_t nLen, + const wxChar* sz, size_t nCount = npos) const; + + size_type copy(wxChar* s, size_type n, size_type pos = 0); + + // substring extraction + wxStringBase substr(size_t nStart = 0, size_t nLen = npos) const; + + // string += string + wxStringBase& operator+=(const wxStringBase& s) { return append(s); } + // string += C string + wxStringBase& operator+=(const wxChar *psz) { return append(psz); } + // string += char + wxStringBase& operator+=(wxChar ch) { return append(1, ch); } }; -#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN +#endif // !wxUSE_STL // ---------------------------------------------------------------------------- // wxString: string class trying to be compatible with std::string, MFC // CString and wxWindows 1.x wxString all at once // --------------------------------------------------------------------------- -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN - // "non dll-interface class 'wxStringPrintfMixin' used as base interface - // for dll-interface class 'wxString'" -- this is OK in our case - #pragma warning (push) - #pragma warning (disable:4275) +class WXDLLIMPEXP_BASE wxString : public wxStringBase +{ +#if !wxUSE_STL +friend class WXDLLIMPEXP_FWD_BASE wxArrayString; #endif -#if wxUSE_UNICODE_UTF8 -// see the comment near wxString::iterator for why we need this -class WXDLLIMPEXP_BASE wxStringIteratorNode -{ -public: - wxStringIteratorNode() - : m_str(NULL), m_citer(NULL), m_iter(NULL), m_prev(NULL), m_next(NULL) {} - wxStringIteratorNode(const wxString *str, - wxStringImpl::const_iterator *citer) - { DoSet(str, citer, NULL); } - wxStringIteratorNode(const wxString *str, wxStringImpl::iterator *iter) - { DoSet(str, NULL, iter); } - ~wxStringIteratorNode() - { clear(); } - - inline void set(const wxString *str, wxStringImpl::const_iterator *citer) - { clear(); DoSet(str, citer, NULL); } - inline void set(const wxString *str, wxStringImpl::iterator *iter) - { clear(); DoSet(str, NULL, iter); } - - const wxString *m_str; - wxStringImpl::const_iterator *m_citer; - wxStringImpl::iterator *m_iter; - wxStringIteratorNode *m_prev, *m_next; - -private: - inline void clear(); - inline void DoSet(const wxString *str, - wxStringImpl::const_iterator *citer, - wxStringImpl::iterator *iter); - - // the node belongs to a particular iterator instance, it's not copied - // when a copy of the iterator is made - wxDECLARE_NO_COPY_CLASS(wxStringIteratorNode); -}; -#endif // wxUSE_UNICODE_UTF8 - -class WXDLLIMPEXP_BASE wxString -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN - : public wxStringPrintfMixin -#endif -{ // NB: special care was taken in arranging the member functions in such order // that all inline functions can be effectively inlined, verify that all // performance critical functions are still inlined if you change order! -public: - // an 'invalid' value for string index, moved to this place due to a CW bug - static const size_t npos; - private: // if we hadn't made these operators private, it would be possible to // compile "wxString s; s = 17;" without any warnings as 17 is implicitly @@ -418,1073 +681,64 @@ private: // try `s << i' or `s.Printf("%d", i)' instead wxString(int); - - // buffer for holding temporary substring when using any of the methods - // that take (char*,size_t) or (wchar_t*,size_t) arguments: - template - struct SubstrBufFromType - { - T data; - size_t len; - - SubstrBufFromType(const T& data_, size_t len_) - : data(data_), len(len_) - { - wxASSERT_MSG( len != npos, "must have real length" ); - } - }; - -#if wxUSE_UNICODE_UTF8 - // even char* -> char* needs conversion, from locale charset to UTF-8 - typedef SubstrBufFromType SubstrBufFromWC; - typedef SubstrBufFromType SubstrBufFromMB; -#elif wxUSE_UNICODE_WCHAR - typedef SubstrBufFromType SubstrBufFromWC; - typedef SubstrBufFromType SubstrBufFromMB; -#else - typedef SubstrBufFromType SubstrBufFromMB; - typedef SubstrBufFromType SubstrBufFromWC; -#endif - - - // Functions implementing primitive operations on string data; wxString - // methods and iterators are implemented in terms of it. The differences - // between UTF-8 and wchar_t* representations of the string are mostly - // contained here. - -#if wxUSE_UNICODE_UTF8 - static SubstrBufFromMB ConvertStr(const char *psz, size_t nLength, - const wxMBConv& conv); - static SubstrBufFromWC ConvertStr(const wchar_t *pwz, size_t nLength, - const wxMBConv& conv); -#elif wxUSE_UNICODE_WCHAR - static SubstrBufFromMB ConvertStr(const char *psz, size_t nLength, - const wxMBConv& conv); -#else - static SubstrBufFromWC ConvertStr(const wchar_t *pwz, size_t nLength, - const wxMBConv& conv); -#endif - -#if !wxUSE_UNICODE_UTF8 // wxUSE_UNICODE_WCHAR or !wxUSE_UNICODE - // returns C string encoded as the implementation expects: - #if wxUSE_UNICODE - static const wchar_t* ImplStr(const wchar_t* str) - { return str ? str : wxT(""); } - static const SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) - { return SubstrBufFromWC(str, (str && n == npos) ? wxWcslen(str) : n); } - static wxScopedWCharBuffer ImplStr(const char* str, - const wxMBConv& conv = wxConvLibc) - { return ConvertStr(str, npos, conv).data; } - static SubstrBufFromMB ImplStr(const char* str, size_t n, - const wxMBConv& conv = wxConvLibc) - { return ConvertStr(str, n, conv); } - #else - static const char* ImplStr(const char* str, - const wxMBConv& WXUNUSED(conv) = wxConvLibc) - { return str ? str : ""; } - static const SubstrBufFromMB ImplStr(const char* str, size_t n, - const wxMBConv& WXUNUSED(conv) = wxConvLibc) - { return SubstrBufFromMB(str, (str && n == npos) ? wxStrlen(str) : n); } - static wxScopedCharBuffer ImplStr(const wchar_t* str) - { return ConvertStr(str, npos, wxConvLibc).data; } - static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) - { return ConvertStr(str, n, wxConvLibc); } - #endif - - // translates position index in wxString to/from index in underlying - // wxStringImpl: - static size_t PosToImpl(size_t pos) { return pos; } - static void PosLenToImpl(size_t pos, size_t len, - size_t *implPos, size_t *implLen) - { *implPos = pos; *implLen = len; } - static size_t LenToImpl(size_t len) { return len; } - static size_t PosFromImpl(size_t pos) { return pos; } - - // we don't want to define these as empty inline functions as it could - // result in noticeable (and quite unnecessary in non-UTF-8 build) slowdown - // in debug build where the inline functions are not effectively inlined - #define wxSTRING_INVALIDATE_CACHE() - #define wxSTRING_INVALIDATE_CACHED_LENGTH() - #define wxSTRING_UPDATE_CACHED_LENGTH(n) - #define wxSTRING_SET_CACHED_LENGTH(n) - -#else // wxUSE_UNICODE_UTF8 - - static wxScopedCharBuffer ImplStr(const char* str, - const wxMBConv& conv = wxConvLibc) - { return ConvertStr(str, npos, conv).data; } - static SubstrBufFromMB ImplStr(const char* str, size_t n, - const wxMBConv& conv = wxConvLibc) - { return ConvertStr(str, n, conv); } - - static wxScopedCharBuffer ImplStr(const wchar_t* str) - { return ConvertStr(str, npos, wxMBConvUTF8()).data; } - static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) - { return ConvertStr(str, n, wxMBConvUTF8()); } - -#if wxUSE_STRING_POS_CACHE - // this is an extremely simple cache used by PosToImpl(): each cache element - // contains the string it applies to and the index corresponding to the last - // used position in this wxString in its m_impl string - // - // NB: notice that this struct (and nested Element one) must be a POD or we - // wouldn't be able to use a thread-local variable of this type, in - // particular it should have no ctor -- we rely on statics being - // initialized to 0 instead - struct Cache - { - enum { SIZE = 8 }; - - struct Element - { - const wxString *str; // the string to which this element applies - size_t pos, // the cached index in this string - impl, // the corresponding position in its m_impl - len; // cached length or npos if unknown - - // reset cached index to 0 - void ResetPos() { pos = impl = 0; } - - // reset position and length - void Reset() { ResetPos(); len = npos; } - }; - - // cache the indices mapping for the last few string used - Element cached[SIZE]; - - // the last used index - unsigned lastUsed; - }; - -#ifndef wxHAS_COMPILER_TLS - // we must use an accessor function and not a static variable when the TLS - // variables support is implemented in the library (and not by the compiler) - // because the global s_cache variable could be not yet initialized when a - // ctor of another global object is executed and if that ctor uses any - // wxString methods, bad things happen - // - // however notice that this approach does not work when compiler TLS is used, - // at least not with g++ 4.1.2 under amd64 as it apparently compiles code - // using this accessor incorrectly when optimizations are enabled (-O2 is - // enough) -- luckily we don't need it then neither as static __thread - // variables are initialized by 0 anyhow then and so we can use the variable - // directly - WXEXPORT static Cache& GetCache() - { - static wxTLS_TYPE(Cache) s_cache; - - return wxTLS_VALUE(s_cache); - } - - // this helper struct is used to ensure that GetCache() is called during - // static initialization time, i.e. before any threads creation, as otherwise - // the static s_cache construction inside GetCache() wouldn't be MT-safe - friend struct wxStrCacheInitializer; -#else // wxHAS_COMPILER_TLS - static wxTLS_TYPE(Cache) ms_cache; - static Cache& GetCache() { return wxTLS_VALUE(ms_cache); } -#endif // !wxHAS_COMPILER_TLS/wxHAS_COMPILER_TLS - - static Cache::Element *GetCacheBegin() { return GetCache().cached; } - static Cache::Element *GetCacheEnd() { return GetCacheBegin() + Cache::SIZE; } - static unsigned& LastUsedCacheElement() { return GetCache().lastUsed; } - - // this is used in debug builds only to provide a convenient function, - // callable from a debugger, to show the cache contents - friend struct wxStrCacheDumper; - - // uncomment this to have access to some profiling statistics on program - // termination - //#define wxPROFILE_STRING_CACHE - -#ifdef wxPROFILE_STRING_CACHE - static struct PosToImplCacheStats - { - unsigned postot, // total non-trivial calls to PosToImpl - poshits, // cache hits from PosToImpl() - mishits, // cached position beyond the needed one - sumpos, // sum of all positions, used to compute the - // average position after dividing by postot - sumofs, // sum of all offsets after using the cache, used to - // compute the average after dividing by hits - lentot, // number of total calls to length() - lenhits; // number of cache hits in length() - } ms_cacheStats; - - friend struct wxStrCacheStatsDumper; - - #define wxCACHE_PROFILE_FIELD_INC(field) ms_cacheStats.field++ - #define wxCACHE_PROFILE_FIELD_ADD(field, val) ms_cacheStats.field += (val) -#else // !wxPROFILE_STRING_CACHE - #define wxCACHE_PROFILE_FIELD_INC(field) - #define wxCACHE_PROFILE_FIELD_ADD(field, val) -#endif // wxPROFILE_STRING_CACHE/!wxPROFILE_STRING_CACHE - - // note: it could seem that the functions below shouldn't be inline because - // they are big, contain loops and so the compiler shouldn't be able to - // inline them anyhow, however moving them into string.cpp does decrease the - // code performance by ~5%, at least when using g++ 4.1 so do keep them here - // unless tests show that it's not advantageous any more - - // return the pointer to the cache element for this string or NULL if not - // cached - Cache::Element *FindCacheElement() const - { - // profiling seems to show a small but consistent gain if we use this - // simple loop instead of starting from the last used element (there are - // a lot of misses in this function...) - Cache::Element * const cacheBegin = GetCacheBegin(); -#ifndef wxHAS_COMPILER_TLS - // during destruction tls calls may return NULL, in this case return NULL - // immediately without accessing anything else - if ( cacheBegin == NULL ) - return NULL; -#endif - Cache::Element * const cacheEnd = GetCacheEnd(); - for ( Cache::Element *c = cacheBegin; c != cacheEnd; c++ ) - { - if ( c->str == this ) - return c; - } - - return NULL; - } - - // unlike FindCacheElement(), this one always returns a valid pointer to the - // cache element for this string, it may have valid last cached position and - // its corresponding index in the byte string or not - Cache::Element *GetCacheElement() const - { - Cache::Element * const cacheBegin = GetCacheBegin(); - Cache::Element * const cacheEnd = GetCacheEnd(); - Cache::Element * const cacheStart = cacheBegin + LastUsedCacheElement(); - - // check the last used first, this does no (measurable) harm for a miss - // but does help for simple loops addressing the same string all the time - if ( cacheStart->str == this ) - return cacheStart; - - // notice that we're going to check cacheStart again inside this call but - // profiling shows that it's still faster to use a simple loop like - // inside FindCacheElement() than manually looping with wrapping starting - // from the cache entry after the start one - Cache::Element *c = FindCacheElement(); - if ( !c ) - { - // claim the next cache entry for this string - c = cacheStart; - if ( ++c == cacheEnd ) - c = cacheBegin; - - c->str = this; - c->Reset(); - - // and remember the last used element - LastUsedCacheElement() = c - cacheBegin; - } - - return c; - } - - size_t DoPosToImpl(size_t pos) const - { - wxCACHE_PROFILE_FIELD_INC(postot); - - // NB: although the case of pos == 1 (and offset from cached position - // equal to 1) are common, nothing is gained by writing special code - // for handling them, the compiler (at least g++ 4.1 used) seems to - // optimize the code well enough on its own - - wxCACHE_PROFILE_FIELD_ADD(sumpos, pos); - - Cache::Element * const cache = GetCacheElement(); - - // cached position can't be 0 so if it is, it means that this entry was - // used for length caching only so far, i.e. it doesn't count as a hit - // from our point of view - if ( cache->pos ) - { - wxCACHE_PROFILE_FIELD_INC(poshits); - } - - if ( pos == cache->pos ) - return cache->impl; - - // this seems to happen only rarely so just reset the cache in this case - // instead of complicating code even further by seeking backwards in this - // case - if ( cache->pos > pos ) - { - wxCACHE_PROFILE_FIELD_INC(mishits); - - cache->ResetPos(); - } - - wxCACHE_PROFILE_FIELD_ADD(sumofs, pos - cache->pos); - - - wxStringImpl::const_iterator i(m_impl.begin() + cache->impl); - for ( size_t n = cache->pos; n < pos; n++ ) - wxStringOperations::IncIter(i); - - cache->pos = pos; - cache->impl = i - m_impl.begin(); - - wxSTRING_CACHE_ASSERT( - (int)cache->impl == (begin() + pos).impl() - m_impl.begin() ); - - return cache->impl; - } - - void InvalidateCache() - { - Cache::Element * const cache = FindCacheElement(); - if ( cache ) - cache->Reset(); - } - - void InvalidateCachedLength() - { - Cache::Element * const cache = FindCacheElement(); - if ( cache ) - cache->len = npos; - } - - void SetCachedLength(size_t len) - { - // we optimistically cache the length here even if the string wasn't - // present in the cache before, this seems to do no harm and the - // potential for avoiding length recomputation for long strings looks - // interesting - GetCacheElement()->len = len; - } - - void UpdateCachedLength(ptrdiff_t delta) - { - Cache::Element * const cache = FindCacheElement(); - if ( cache && cache->len != npos ) - { - wxSTRING_CACHE_ASSERT( (ptrdiff_t)cache->len + delta >= 0 ); - - cache->len += delta; - } - } - - #define wxSTRING_INVALIDATE_CACHE() InvalidateCache() - #define wxSTRING_INVALIDATE_CACHED_LENGTH() InvalidateCachedLength() - #define wxSTRING_UPDATE_CACHED_LENGTH(n) UpdateCachedLength(n) - #define wxSTRING_SET_CACHED_LENGTH(n) SetCachedLength(n) -#else // !wxUSE_STRING_POS_CACHE - size_t DoPosToImpl(size_t pos) const - { - return (begin() + pos).impl() - m_impl.begin(); - } - - #define wxSTRING_INVALIDATE_CACHE() - #define wxSTRING_INVALIDATE_CACHED_LENGTH() - #define wxSTRING_UPDATE_CACHED_LENGTH(n) - #define wxSTRING_SET_CACHED_LENGTH(n) -#endif // wxUSE_STRING_POS_CACHE/!wxUSE_STRING_POS_CACHE - - size_t PosToImpl(size_t pos) const - { - return pos == 0 || pos == npos ? pos : DoPosToImpl(pos); - } - - void PosLenToImpl(size_t pos, size_t len, size_t *implPos, size_t *implLen) const; - - size_t LenToImpl(size_t len) const - { - size_t pos, len2; - PosLenToImpl(0, len, &pos, &len2); - return len2; - } - - size_t PosFromImpl(size_t pos) const - { - if ( pos == 0 || pos == npos ) - return pos; - else - return const_iterator(this, m_impl.begin() + pos) - begin(); - } -#endif // !wxUSE_UNICODE_UTF8/wxUSE_UNICODE_UTF8 - -public: - // standard types - typedef wxUniChar value_type; - typedef wxUniChar char_type; - typedef wxUniCharRef reference; - typedef wxChar* pointer; - typedef const wxChar* const_pointer; - - typedef size_t size_type; - typedef wxUniChar const_reference; - -#if wxUSE_STD_STRING - #if wxUSE_UNICODE_UTF8 - // random access is not O(1), as required by Random Access Iterator - #define WX_STR_ITERATOR_TAG std::bidirectional_iterator_tag - #else - #define WX_STR_ITERATOR_TAG std::random_access_iterator_tag - #endif - #define WX_DEFINE_ITERATOR_CATEGORY(cat) typedef cat iterator_category; -#else - // not defining iterator_category at all in this case is better than defining - // it as some dummy type -- at least it results in more intelligible error - // messages - #define WX_DEFINE_ITERATOR_CATEGORY(cat) -#endif - - #define WX_STR_ITERATOR_IMPL(iterator_name, pointer_type, reference_type) \ - private: \ - typedef wxStringImpl::iterator_name underlying_iterator; \ - public: \ - WX_DEFINE_ITERATOR_CATEGORY(WX_STR_ITERATOR_TAG) \ - typedef wxUniChar value_type; \ - typedef ptrdiff_t difference_type; \ - typedef reference_type reference; \ - typedef pointer_type pointer; \ - \ - reference operator[](size_t n) const { return *(*this + n); } \ - \ - iterator_name& operator++() \ - { wxStringOperations::IncIter(m_cur); return *this; } \ - iterator_name& operator--() \ - { wxStringOperations::DecIter(m_cur); return *this; } \ - iterator_name operator++(int) \ - { \ - iterator_name tmp = *this; \ - wxStringOperations::IncIter(m_cur); \ - return tmp; \ - } \ - iterator_name operator--(int) \ - { \ - iterator_name tmp = *this; \ - wxStringOperations::DecIter(m_cur); \ - return tmp; \ - } \ - \ - iterator_name& operator+=(ptrdiff_t n) \ - { \ - m_cur = wxStringOperations::AddToIter(m_cur, n); \ - return *this; \ - } \ - iterator_name& operator-=(ptrdiff_t n) \ - { \ - m_cur = wxStringOperations::AddToIter(m_cur, -n); \ - return *this; \ - } \ - \ - difference_type operator-(const iterator_name& i) const \ - { return wxStringOperations::DiffIters(m_cur, i.m_cur); } \ - \ - bool operator==(const iterator_name& i) const \ - { return m_cur == i.m_cur; } \ - bool operator!=(const iterator_name& i) const \ - { return m_cur != i.m_cur; } \ - \ - bool operator<(const iterator_name& i) const \ - { return m_cur < i.m_cur; } \ - bool operator>(const iterator_name& i) const \ - { return m_cur > i.m_cur; } \ - bool operator<=(const iterator_name& i) const \ - { return m_cur <= i.m_cur; } \ - bool operator>=(const iterator_name& i) const \ - { return m_cur >= i.m_cur; } \ - \ - private: \ - /* for internal wxString use only: */ \ - underlying_iterator impl() const { return m_cur; } \ - \ - friend class wxString; \ - friend class wxCStrData; \ - \ - private: \ - underlying_iterator m_cur - - class WXDLLIMPEXP_FWD_BASE const_iterator; - -#if wxUSE_UNICODE_UTF8 - // NB: In UTF-8 build, (non-const) iterator needs to keep reference - // to the underlying wxStringImpl, because UTF-8 is variable-length - // encoding and changing the value pointer to by an iterator (using - // its operator*) requires calling wxStringImpl::replace() if the old - // and new values differ in their encoding's length. - // - // Furthermore, the replace() call may invalid all iterators for the - // string, so we have to keep track of outstanding iterators and update - // them if replace() happens. - // - // This is implemented by maintaining linked list of iterators for every - // string and traversing it in wxUniCharRef::operator=(). Head of the - // list is stored in wxString. (FIXME-UTF8) - - class WXDLLIMPEXP_BASE iterator - { - WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef); - - public: - iterator() {} - iterator(const iterator& i) - : m_cur(i.m_cur), m_node(i.str(), &m_cur) {} - iterator& operator=(const iterator& i) - { - if (&i != this) - { - m_cur = i.m_cur; - m_node.set(i.str(), &m_cur); - } - return *this; - } - - reference operator*() - { return wxUniCharRef::CreateForString(*str(), m_cur); } - - iterator operator+(ptrdiff_t n) const - { return iterator(str(), wxStringOperations::AddToIter(m_cur, n)); } - iterator operator-(ptrdiff_t n) const - { return iterator(str(), wxStringOperations::AddToIter(m_cur, -n)); } - - // Normal iterators need to be comparable with the const_iterators so - // declare the comparison operators and implement them below after the - // full const_iterator declaration. - bool operator==(const const_iterator& i) const; - bool operator!=(const const_iterator& i) const; - bool operator<(const const_iterator& i) const; - bool operator>(const const_iterator& i) const; - bool operator<=(const const_iterator& i) const; - bool operator>=(const const_iterator& i) const; - - private: - iterator(wxString *wxstr, underlying_iterator ptr) - : m_cur(ptr), m_node(wxstr, &m_cur) {} - - wxString* str() const { return const_cast(m_node.m_str); } - - wxStringIteratorNode m_node; - - friend class const_iterator; - }; - - class WXDLLIMPEXP_BASE const_iterator - { - // NB: reference_type is intentionally value, not reference, the character - // may be encoded differently in wxString data: - WX_STR_ITERATOR_IMPL(const_iterator, const wxChar*, wxUniChar); - - public: - const_iterator() {} - const_iterator(const const_iterator& i) - : m_cur(i.m_cur), m_node(i.str(), &m_cur) {} - const_iterator(const iterator& i) - : m_cur(i.m_cur), m_node(i.str(), &m_cur) {} - - const_iterator& operator=(const const_iterator& i) - { - if (&i != this) - { - m_cur = i.m_cur; - m_node.set(i.str(), &m_cur); - } - return *this; - } - const_iterator& operator=(const iterator& i) - { m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; } - - reference operator*() const - { return wxStringOperations::DecodeChar(m_cur); } - - const_iterator operator+(ptrdiff_t n) const - { return const_iterator(str(), wxStringOperations::AddToIter(m_cur, n)); } - const_iterator operator-(ptrdiff_t n) const - { return const_iterator(str(), wxStringOperations::AddToIter(m_cur, -n)); } - - // Notice that comparison operators taking non-const iterator are not - // needed here because of the implicit conversion from non-const iterator - // to const ones ensure that the versions for const_iterator declared - // inside WX_STR_ITERATOR_IMPL can be used. - - private: - // for internal wxString use only: - const_iterator(const wxString *wxstr, underlying_iterator ptr) - : m_cur(ptr), m_node(wxstr, &m_cur) {} - - const wxString* str() const { return m_node.m_str; } - - wxStringIteratorNode m_node; - }; - - size_t IterToImplPos(wxString::iterator i) const - { return wxStringImpl::const_iterator(i.impl()) - m_impl.begin(); } - - iterator GetIterForNthChar(size_t n) - { return iterator(this, m_impl.begin() + PosToImpl(n)); } - const_iterator GetIterForNthChar(size_t n) const - { return const_iterator(this, m_impl.begin() + PosToImpl(n)); } -#else // !wxUSE_UNICODE_UTF8 - - class WXDLLIMPEXP_BASE iterator - { - WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef); - - public: - iterator() {} - iterator(const iterator& i) : m_cur(i.m_cur) {} - - reference operator*() - { return wxUniCharRef::CreateForString(m_cur); } - - iterator operator+(ptrdiff_t n) const - { return iterator(wxStringOperations::AddToIter(m_cur, n)); } - iterator operator-(ptrdiff_t n) const - { return iterator(wxStringOperations::AddToIter(m_cur, -n)); } - - // As in UTF-8 case above, define comparison operators taking - // const_iterator too. - bool operator==(const const_iterator& i) const; - bool operator!=(const const_iterator& i) const; - bool operator<(const const_iterator& i) const; - bool operator>(const const_iterator& i) const; - bool operator<=(const const_iterator& i) const; - bool operator>=(const const_iterator& i) const; - - private: - // for internal wxString use only: - iterator(underlying_iterator ptr) : m_cur(ptr) {} - iterator(wxString *WXUNUSED(str), underlying_iterator ptr) : m_cur(ptr) {} - - friend class const_iterator; - }; - - class WXDLLIMPEXP_BASE const_iterator - { - // NB: reference_type is intentionally value, not reference, the character - // may be encoded differently in wxString data: - WX_STR_ITERATOR_IMPL(const_iterator, const wxChar*, wxUniChar); - - public: - const_iterator() {} - const_iterator(const const_iterator& i) : m_cur(i.m_cur) {} - const_iterator(const iterator& i) : m_cur(i.m_cur) {} - - reference operator*() const - { return wxStringOperations::DecodeChar(m_cur); } - - const_iterator operator+(ptrdiff_t n) const - { return const_iterator(wxStringOperations::AddToIter(m_cur, n)); } - const_iterator operator-(ptrdiff_t n) const - { return const_iterator(wxStringOperations::AddToIter(m_cur, -n)); } - - // As in UTF-8 case above, we don't need comparison operators taking - // iterator because we have an implicit conversion from iterator to - // const_iterator so the operators declared by WX_STR_ITERATOR_IMPL will - // be used. - - private: - // for internal wxString use only: - const_iterator(underlying_iterator ptr) : m_cur(ptr) {} - const_iterator(const wxString *WXUNUSED(str), underlying_iterator ptr) - : m_cur(ptr) {} - }; - - iterator GetIterForNthChar(size_t n) { return begin() + n; } - const_iterator GetIterForNthChar(size_t n) const { return begin() + n; } -#endif // wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 - - #undef WX_STR_ITERATOR_TAG - #undef WX_STR_ITERATOR_IMPL - - // This method is mostly used by wxWidgets itself and return the offset of - // the given iterator in bytes relative to the start of the buffer - // representing the current string contents in the current locale encoding. - // - // It is inefficient as it involves converting part of the string to this - // encoding (and also unsafe as it simply returns 0 if the conversion fails) - // and so should be avoided if possible, wx itself only uses it to implement - // backwards-compatible API. - ptrdiff_t IterOffsetInMBStr(const const_iterator& i) const - { - const wxString str(begin(), i); - - // This is logically equivalent to strlen(str.mb_str()) but avoids - // actually converting the string to multibyte and just computes the - // length that it would have after conversion. - size_t ofs = wxConvLibc.FromWChar(NULL, 0, str.wc_str(), str.length()); - return ofs == wxCONV_FAILED ? 0 : static_cast(ofs); - } - - friend class iterator; - friend class const_iterator; - - template - class reverse_iterator_impl - { - public: - typedef T iterator_type; - - WX_DEFINE_ITERATOR_CATEGORY(typename T::iterator_category) - typedef typename T::value_type value_type; - typedef typename T::difference_type difference_type; - typedef typename T::reference reference; - typedef typename T::pointer *pointer; - - reverse_iterator_impl() {} - reverse_iterator_impl(iterator_type i) : m_cur(i) {} - reverse_iterator_impl(const reverse_iterator_impl& ri) - : m_cur(ri.m_cur) {} - - iterator_type base() const { return m_cur; } - - reference operator*() const { return *(m_cur-1); } - reference operator[](size_t n) const { return *(*this + n); } - - reverse_iterator_impl& operator++() - { --m_cur; return *this; } - reverse_iterator_impl operator++(int) - { reverse_iterator_impl tmp = *this; --m_cur; return tmp; } - reverse_iterator_impl& operator--() - { ++m_cur; return *this; } - reverse_iterator_impl operator--(int) - { reverse_iterator_impl tmp = *this; ++m_cur; return tmp; } - - // NB: explicit in the functions below is to keep BCC 5.5 happy - reverse_iterator_impl operator+(ptrdiff_t n) const - { return reverse_iterator_impl(m_cur - n); } - reverse_iterator_impl operator-(ptrdiff_t n) const - { return reverse_iterator_impl(m_cur + n); } - reverse_iterator_impl operator+=(ptrdiff_t n) - { m_cur -= n; return *this; } - reverse_iterator_impl operator-=(ptrdiff_t n) - { m_cur += n; return *this; } - - unsigned operator-(const reverse_iterator_impl& i) const - { return i.m_cur - m_cur; } - - bool operator==(const reverse_iterator_impl& ri) const - { return m_cur == ri.m_cur; } - bool operator!=(const reverse_iterator_impl& ri) const - { return !(*this == ri); } - - bool operator<(const reverse_iterator_impl& i) const - { return m_cur > i.m_cur; } - bool operator>(const reverse_iterator_impl& i) const - { return m_cur < i.m_cur; } - bool operator<=(const reverse_iterator_impl& i) const - { return m_cur >= i.m_cur; } - bool operator>=(const reverse_iterator_impl& i) const - { return m_cur <= i.m_cur; } - - private: - iterator_type m_cur; - }; - - typedef reverse_iterator_impl reverse_iterator; - typedef reverse_iterator_impl const_reverse_iterator; - -private: - // used to transform an expression built using c_str() (and hence of type - // wxCStrData) to an iterator into the string - static const_iterator CreateConstIterator(const wxCStrData& data) - { - return const_iterator(data.m_str, - (data.m_str->begin() + data.m_offset).impl()); - } - - // in UTF-8 STL build, creation from std::string requires conversion under - // non-UTF8 locales, so we can't have and use wxString(wxStringImpl) ctor; - // instead we define dummy type that lets us have wxString ctor for creation - // from wxStringImpl that couldn't be used by user code (in all other builds, - // "standard" ctors can be used): -#if wxUSE_UNICODE_UTF8 && wxUSE_STL_BASED_WXSTRING - struct CtorFromStringImplTag {}; - - wxString(CtorFromStringImplTag* WXUNUSED(dummy), const wxStringImpl& src) - : m_impl(src) {} - - static wxString FromImpl(const wxStringImpl& src) - { return wxString((CtorFromStringImplTag*)NULL, src); } -#else - #if !wxUSE_STL_BASED_WXSTRING - wxString(const wxStringImpl& src) : m_impl(src) { } - // else: already defined as wxString(wxStdString) below - #endif - static wxString FromImpl(const wxStringImpl& src) { return wxString(src); } -#endif - public: // constructors and destructor // ctor for an empty string - wxString() {} - + wxString() : wxStringBase() { } // copy ctor - wxString(const wxString& stringSrc) : m_impl(stringSrc.m_impl) { } - + wxString(const wxStringBase& stringSrc) : wxStringBase(stringSrc) { } + wxString(const wxString& stringSrc) : wxStringBase(stringSrc) { } // string containing nRepeat copies of ch - wxString(wxUniChar ch, size_t nRepeat = 1 ) - { assign(nRepeat, ch); } - wxString(size_t nRepeat, wxUniChar ch) - { assign(nRepeat, ch); } - wxString(wxUniCharRef ch, size_t nRepeat = 1) - { assign(nRepeat, ch); } - wxString(size_t nRepeat, wxUniCharRef ch) - { assign(nRepeat, ch); } - wxString(char ch, size_t nRepeat = 1) - { assign(nRepeat, ch); } - wxString(size_t nRepeat, char ch) - { assign(nRepeat, ch); } - wxString(wchar_t ch, size_t nRepeat = 1) - { assign(nRepeat, ch); } - wxString(size_t nRepeat, wchar_t ch) - { assign(nRepeat, ch); } + wxString(wxChar ch, size_t nRepeat = 1) + : wxStringBase(nRepeat, ch) { } + wxString(size_t nRepeat, wxChar ch) + : wxStringBase(nRepeat, ch) { } + // ctor takes first nLength characters from C string + // (default value of npos means take all the string) + wxString(const wxChar *psz) + : wxStringBase(psz ? psz : wxT("")) { } + wxString(const wxChar *psz, size_t nLength) + : wxStringBase(psz, nLength) { } + wxString(const wxChar *psz, + const wxMBConv& WXUNUSED(conv), + size_t nLength = npos) + : wxStringBase(psz, nLength == npos ? wxStrlen(psz) : nLength) { } - // ctors from char* strings: - wxString(const char *psz) - : m_impl(ImplStr(psz)) {} - wxString(const char *psz, const wxMBConv& conv) - : m_impl(ImplStr(psz, conv)) {} - wxString(const char *psz, size_t nLength) - { assign(psz, nLength); } - wxString(const char *psz, const wxMBConv& conv, size_t nLength) - { - SubstrBufFromMB str(ImplStr(psz, nLength, conv)); - m_impl.assign(str.data, str.len); - } - - // and unsigned char*: - wxString(const unsigned char *psz) - : m_impl(ImplStr((const char*)psz)) {} - wxString(const unsigned char *psz, const wxMBConv& conv) - : m_impl(ImplStr((const char*)psz, conv)) {} - wxString(const unsigned char *psz, size_t nLength) - { assign((const char*)psz, nLength); } - wxString(const unsigned char *psz, const wxMBConv& conv, size_t nLength) - { - SubstrBufFromMB str(ImplStr((const char*)psz, nLength, conv)); - m_impl.assign(str.data, str.len); - } - - // ctors from wchar_t* strings: - wxString(const wchar_t *pwz) - : m_impl(ImplStr(pwz)) {} - wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv)) - : m_impl(ImplStr(pwz)) {} - wxString(const wchar_t *pwz, size_t nLength) - { assign(pwz, nLength); } - wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv), size_t nLength) - { assign(pwz, nLength); } - - wxString(const wxScopedCharBuffer& buf) - { assign(buf.data(), buf.length()); } - wxString(const wxScopedWCharBuffer& buf) - { assign(buf.data(), buf.length()); } - - // NB: this version uses m_impl.c_str() to force making a copy of the - // string, so that "wxString(str.c_str())" idiom for passing strings - // between threads works - wxString(const wxCStrData& cstr) - : m_impl(cstr.AsString().m_impl.c_str()) { } - - // as we provide both ctors with this signature for both char and unsigned - // char string, we need to provide one for wxCStrData to resolve ambiguity - wxString(const wxCStrData& cstr, size_t nLength) - : m_impl(cstr.AsString().Mid(0, nLength).m_impl) {} - - // and because wxString is convertible to wxCStrData and const wxChar * - // we also need to provide this one - wxString(const wxString& str, size_t nLength) - { assign(str, nLength); } - - -#if wxUSE_STRING_POS_CACHE - ~wxString() - { - // we need to invalidate our cache entry as another string could be - // recreated at the same address (unlikely, but still possible, with the - // heap-allocated strings but perfectly common with stack-allocated ones) - InvalidateCache(); - } -#endif // wxUSE_STRING_POS_CACHE - - // even if we're not built with wxUSE_STD_STRING_CONV_IN_WXSTRING == 1 it is - // very convenient to allow implicit conversions from std::string to wxString - // and vice verse as this allows to use the same strings in non-GUI and GUI - // code, however we don't want to unconditionally add this ctor as it would - // make wx lib dependent on libstdc++ on some Linux versions which is bad, so - // instead we ask the client code to define this wxUSE_STD_STRING symbol if - // they need it + // even if we're not built with wxUSE_STL == 1 it is very convenient to allow + // implicit conversions from std::string to wxString as this allows to use + // the same strings in non-GUI and GUI code, however we don't want to + // unconditionally add this ctor as it would make wx lib dependent on + // libstdc++ on some Linux versions which is bad, so instead we ask the + // client code to define this wxUSE_STD_STRING symbol if they need it #if wxUSE_STD_STRING - #if wxUSE_UNICODE_WCHAR - wxString(const wxStdWideString& str) : m_impl(str) {} - #else // UTF-8 or ANSI - wxString(const wxStdWideString& str) - { assign(str.c_str(), str.length()); } - #endif - - #if !wxUSE_UNICODE // ANSI build - // FIXME-UTF8: do this in UTF8 build #if wxUSE_UTF8_LOCALE_ONLY, too - wxString(const std::string& str) : m_impl(str) {} - #else // Unicode - wxString(const std::string& str) - { assign(str.c_str(), str.length()); } - #endif + wxString(const wxStdString& s) + : wxStringBase(s.c_str()) { } #endif // wxUSE_STD_STRING - // Also always provide explicit conversions to std::[w]string in any case, - // see below for the implicit ones. -#if wxUSE_STD_STRING - // We can avoid a copy if we already use this string type internally, - // otherwise we create a copy on the fly: - #if wxUSE_UNICODE_WCHAR && wxUSE_STL_BASED_WXSTRING - #define wxStringToStdWstringRetType const wxStdWideString& - const wxStdWideString& ToStdWstring() const { return m_impl; } - #else - // wxStringImpl is either not std::string or needs conversion - #define wxStringToStdWstringRetType wxStdWideString - wxStdWideString ToStdWstring() const - { -#if wxUSE_UNICODE_WCHAR - wxScopedWCharBuffer buf = - wxScopedWCharBuffer::CreateNonOwned(m_impl.c_str(), m_impl.length()); -#else // !wxUSE_UNICODE_WCHAR - wxScopedWCharBuffer buf(wc_str()); -#endif +#if wxUSE_UNICODE + // from multibyte string + wxString(const char *psz, const wxMBConv& conv, size_t nLength = npos); + // from wxWCharBuffer (i.e. return from wxGetString) + wxString(const wxWCharBuffer& psz) : wxStringBase(psz.data()) { } +#else // ANSI + // from C string (for compilers using unsigned char) + wxString(const unsigned char* psz) + : wxStringBase((const char*)psz) { } + // from part of C string (for compilers using unsigned char) + wxString(const unsigned char* psz, size_t nLength) + : wxStringBase((const char*)psz, nLength) { } - return wxStdWideString(buf.data(), buf.length()); - } - #endif +#if wxUSE_WCHAR_T + // from wide (Unicode) string + wxString(const wchar_t *pwz, + const wxMBConv& conv = wxConvLibc, + size_t nLength = npos); +#endif // !wxUSE_WCHAR_T - #if (!wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY) && wxUSE_STL_BASED_WXSTRING - // wxStringImpl is std::string in the encoding we want - #define wxStringToStdStringRetType const std::string& - const std::string& ToStdString() const { return m_impl; } - #else - // wxStringImpl is either not std::string or needs conversion - #define wxStringToStdStringRetType std::string - std::string ToStdString() const - { - wxScopedCharBuffer buf(mb_str()); - return std::string(buf.data(), buf.length()); - } - #endif - -#if wxUSE_STD_STRING_CONV_IN_WXSTRING - // Implicit conversions to std::[w]string are not provided by default as - // they conflict with the implicit conversions to "const char/wchar_t *" - // which we use for backwards compatibility but do provide them if - // explicitly requested. - operator wxStringToStdStringRetType() const { return ToStdString(); } - operator wxStringToStdWstringRetType() const { return ToStdWstring(); } -#endif // wxUSE_STD_STRING_CONV_IN_WXSTRING - -#undef wxStringToStdStringRetType -#undef wxStringToStdWstringRetType - -#endif // wxUSE_STD_STRING - - wxString Clone() const - { - // make a deep copy of the string, i.e. the returned string will have - // ref count = 1 with refcounted implementation - return wxString::FromImpl(wxStringImpl(m_impl.c_str(), m_impl.length())); - } - - // first valid index position - const_iterator begin() const { return const_iterator(this, m_impl.begin()); } - iterator begin() { return iterator(this, m_impl.begin()); } - // position one after the last valid one - const_iterator end() const { return const_iterator(this, m_impl.end()); } - iterator end() { return iterator(this, m_impl.end()); } - - // first element of the reversed string - const_reverse_iterator rbegin() const - { return const_reverse_iterator(end()); } - reverse_iterator rbegin() - { return reverse_iterator(end()); } - // one beyond the end of the reversed string - const_reverse_iterator rend() const - { return const_reverse_iterator(begin()); } - reverse_iterator rend() - { return reverse_iterator(begin()); } - - // std::string methods: -#if wxUSE_UNICODE_UTF8 - size_t length() const - { -#if wxUSE_STRING_POS_CACHE - wxCACHE_PROFILE_FIELD_INC(lentot); - - Cache::Element * const cache = GetCacheElement(); - - if ( cache->len == npos ) - { - // it's probably not worth trying to be clever and using cache->pos - // here as it's probably 0 anyhow -- you usually call length() before - // starting to index the string - cache->len = end() - begin(); - } - else - { - wxCACHE_PROFILE_FIELD_INC(lenhits); - - wxSTRING_CACHE_ASSERT( (int)cache->len == end() - begin() ); - } - - return cache->len; -#else // !wxUSE_STRING_POS_CACHE - return end() - begin(); -#endif // wxUSE_STRING_POS_CACHE/!wxUSE_STRING_POS_CACHE - } -#else - size_t length() const { return m_impl.length(); } -#endif - - size_type size() const { return length(); } - size_type max_size() const { return npos; } - - bool empty() const { return m_impl.empty(); } - - // NB: these methods don't have a well-defined meaning in UTF-8 case - size_type capacity() const { return m_impl.capacity(); } - void reserve(size_t sz) { m_impl.reserve(sz); } - - void resize(size_t nSize, wxUniChar ch = wxT('\0')) - { - const size_t len = length(); - if ( nSize == len) - return; - -#if wxUSE_UNICODE_UTF8 - if ( nSize < len ) - { - wxSTRING_INVALIDATE_CACHE(); - - // we can't use wxStringImpl::resize() for truncating the string as it - // counts in bytes, not characters - erase(nSize); - return; - } - - // we also can't use (presumably more efficient) resize() if we have to - // append characters taking more than one byte - if ( !ch.IsAscii() ) - { - append(nSize - len, ch); - } - else // can use (presumably faster) resize() version -#endif // wxUSE_UNICODE_UTF8 - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl.resize(nSize, (wxStringCharType)ch); - } - } - - wxString substr(size_t nStart = 0, size_t nLen = npos) const - { - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - return FromImpl(m_impl.substr(pos, len)); - } + // from wxCharBuffer + wxString(const wxCharBuffer& psz) + : wxStringBase(psz) { } +#endif // Unicode/ANSI // generic attributes & operations // as standard strlen() @@ -1496,9 +750,18 @@ public: // truncate the string to given length wxString& Truncate(size_t uiLen); // empty string contents - void Empty() { clear(); } + void Empty() + { + Truncate(0); + + wxASSERT_MSG( empty(), wxT("string not empty after call to Empty()?") ); + } // empty the string and free memory - void Clear() { clear(); } + void Clear() + { + wxString tmp(wxEmptyString); + swap(tmp); + } // contents test // Is an ascii value @@ -1510,162 +773,79 @@ public: // data access (all indexes are 0 based) // read access - wxUniChar at(size_t n) const - { return wxStringOperations::DecodeChar(m_impl.begin() + PosToImpl(n)); } - wxUniChar GetChar(size_t n) const + wxChar GetChar(size_t n) const { return at(n); } // read/write access - wxUniCharRef at(size_t n) - { return *GetIterForNthChar(n); } - wxUniCharRef GetWritableChar(size_t n) + wxChar& GetWritableChar(size_t n) { return at(n); } // write access - void SetChar(size_t n, wxUniChar ch) + void SetChar(size_t n, wxChar ch) { at(n) = ch; } // get last character - wxUniChar Last() const - { - wxASSERT_MSG( !empty(), wxT("wxString: index out of bounds") ); - return *rbegin(); - } + wxChar Last() const + { + wxASSERT_MSG( !empty(), wxT("wxString: index out of bounds") ); + + return at(length() - 1); + } // get writable last character - wxUniCharRef Last() - { - wxASSERT_MSG( !empty(), wxT("wxString: index out of bounds") ); - return *rbegin(); - } + wxChar& Last() + { + wxASSERT_MSG( !empty(), wxT("wxString: index out of bounds") ); + return at(length() - 1); + } /* Note that we we must define all of the overloads below to avoid - ambiguity when using str[0]. + ambiguity when using str[0]. Also note that for a conforming compiler we + don't need const version of operatorp[] at all as indexed access to + const string is provided by implicit conversion to "const wxChar *" + below and defining them would only result in ambiguities, but some other + compilers refuse to compile "str[0]" without them. */ - wxUniChar operator[](int n) const - { return at(n); } - wxUniChar operator[](long n) const - { return at(n); } - wxUniChar operator[](size_t n) const - { return at(n); } + +#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__MWERKS__) + wxChar operator[](int n) const + { return wxStringBase::at(n); } + wxChar operator[](size_type n) const + { return wxStringBase::at(n); } #ifndef wxSIZE_T_IS_UINT - wxUniChar operator[](unsigned int n) const - { return at(n); } + wxChar operator[](unsigned int n) const + { return wxStringBase::at(n); } #endif // size_t != unsigned int +#endif // broken compiler + // operator versions of GetWriteableChar() - wxUniCharRef operator[](int n) - { return at(n); } - wxUniCharRef operator[](long n) - { return at(n); } - wxUniCharRef operator[](size_t n) - { return at(n); } + wxChar& operator[](int n) + { return wxStringBase::at(n); } + wxChar& operator[](size_type n) + { return wxStringBase::at(n); } #ifndef wxSIZE_T_IS_UINT - wxUniCharRef operator[](unsigned int n) - { return at(n); } + wxChar& operator[](unsigned int n) + { return wxStringBase::at(n); } #endif // size_t != unsigned int + // implicit conversion to C string + operator const wxChar*() const { return c_str(); } - /* - Overview of wxString conversions, implicit and explicit: - - - wxString has a std::[w]string-like c_str() method, however it does - not return a C-style string directly but instead returns wxCStrData - helper object which is convertible to either "char *" narrow string - or "wchar_t *" wide string. Usually the correct conversion will be - applied by the compiler automatically but if this doesn't happen you - need to explicitly choose one using wxCStrData::AsChar() or AsWChar() - methods or another wxString conversion function. - - - One of the places where the conversion does *NOT* happen correctly is - when c_str() is passed to a vararg function such as printf() so you - must *NOT* use c_str() with them. Either use wxPrintf() (all wx - functions do handle c_str() correctly, even if they appear to be - vararg (but they're not, really)) or add an explicit AsChar() or, if - compatibility with previous wxWidgets versions is important, add a - cast to "const char *". - - - In non-STL mode only, wxString is also implicitly convertible to - wxCStrData. The same warning as above applies. - - - c_str() is polymorphic as it can be converted to either narrow or - wide string. If you explicitly need one or the other, choose to use - mb_str() (for narrow) or wc_str() (for wide) instead. Notice that - these functions can return either the pointer to string directly (if - this is what the string uses internally) or a temporary buffer - containing the string and convertible to it. Again, conversion will - usually be done automatically by the compiler but beware of the - vararg functions: you need an explicit cast when using them. - - - There are also non-const versions of mb_str() and wc_str() called - char_str() and wchar_str(). They are only meant to be used with - non-const-correct functions and they always return buffers. - - - Finally wx_str() returns whatever string representation is used by - wxString internally. It may be either a narrow or wide string - depending on wxWidgets build mode but it will always be a raw pointer - (and not a buffer). - */ - - // explicit conversion to wxCStrData - wxCStrData c_str() const { return wxCStrData(this); } - wxCStrData data() const { return c_str(); } - - // implicit conversion to wxCStrData - operator wxCStrData() const { return c_str(); } - - // the first two operators conflict with operators for conversion to - // std::string and they must be disabled if those conversions are enabled; - // the next one only makes sense if conversions to char* are also defined - // and not defining it in STL build also helps us to get more clear error - // messages for the code which relies on implicit conversion to char* in - // STL build -#if !wxUSE_STD_STRING_CONV_IN_WXSTRING - operator const char*() const { return c_str(); } - operator const wchar_t*() const { return c_str(); } - - // implicit conversion to untyped pointer for compatibility with previous - // wxWidgets versions: this is the same as conversion to const char * so it - // may fail! - operator const void*() const { return c_str(); } -#endif // !wxUSE_STD_STRING_CONV_IN_WXSTRING - + // identical to c_str(), for wxWin 1.6x compatibility + const wxChar* wx_str() const { return c_str(); } // identical to c_str(), for MFC compatibility - const wxCStrData GetData() const { return c_str(); } - - // explicit conversion to C string in internal representation (char*, - // wchar_t*, UTF-8-encoded char*, depending on the build): - const wxStringCharType *wx_str() const { return m_impl.c_str(); } + const wxChar* GetData() const { return c_str(); } +#if wxABI_VERSION >= 20804 // conversion to *non-const* multibyte or widestring buffer; modifying // returned buffer won't affect the string, these methods are only useful // for passing values to const-incorrect functions wxWritableCharBuffer char_str(const wxMBConv& conv = wxConvLibc) const - { return mb_str(conv); } - wxWritableWCharBuffer wchar_str() const { return wc_str(); } - - // conversion to the buffer of the given type T (= char or wchar_t) and - // also optionally return the buffer length - // - // this is mostly/only useful for the template functions - // - // FIXME-VC6: the second argument only exists for VC6 which doesn't support - // explicit template function selection, do not use it unless - // you must support VC6! - template - wxCharTypeBuffer tchar_str(size_t *len = NULL, - T * WXUNUSED(dummy) = NULL) const - { -#if wxUSE_UNICODE - // we need a helper dispatcher depending on type - return wxPrivate::wxStringAsBufHelper::Get(*this, len); -#else // ANSI - // T can only be char in ANSI build - if ( len ) - *len = length(); - - return wxCharTypeBuffer::CreateNonOwned(wx_str(), length()); -#endif // Unicode build kind - } + { return mb_str(conv); } +#if wxUSE_WCHAR_T + wxWritableWCharBuffer wchar_str() const { return wc_str(wxConvLibc); } +#endif +#endif // wxABI_VERSION >= 20804 // conversion to/from plain (i.e. 7 bit) ASCII: this is useful for // converting numbers or strings which are certain not to contain special @@ -1674,113 +854,40 @@ public: // the behaviour of these functions with the strings containing anything // else than 7 bit ASCII characters is undefined, use at your own risk. #if wxUSE_UNICODE - static wxString FromAscii(const char *ascii, size_t len); - static wxString FromAscii(const char *ascii); - static wxString FromAscii(char ascii); - const wxScopedCharBuffer ToAscii() const; + static wxString FromAscii(const char *ascii); // string + static wxString FromAscii(const char ascii); // char + const wxCharBuffer ToAscii() const; #else // ANSI static wxString FromAscii(const char *ascii) { return wxString( ascii ); } - static wxString FromAscii(const char *ascii, size_t len) - { return wxString( ascii, len ); } - static wxString FromAscii(char ascii) { return wxString( ascii ); } + static wxString FromAscii(const char ascii) { return wxString( ascii ); } const char *ToAscii() const { return c_str(); } #endif // Unicode/!Unicode - // also provide unsigned char overloads as signed/unsigned doesn't matter - // for 7 bit ASCII characters - static wxString FromAscii(const unsigned char *ascii) - { return FromAscii((const char *)ascii); } - static wxString FromAscii(const unsigned char *ascii, size_t len) - { return FromAscii((const char *)ascii, len); } - +#if wxABI_VERSION >= 20804 // conversion to/from UTF-8: -#if wxUSE_UNICODE_UTF8 - static wxString FromUTF8Unchecked(const char *utf8) - { - if ( !utf8 ) - return wxEmptyString; - - wxASSERT( wxStringOperations::IsValidUtf8String(utf8) ); - return FromImpl(wxStringImpl(utf8)); - } - static wxString FromUTF8Unchecked(const char *utf8, size_t len) - { - if ( !utf8 ) - return wxEmptyString; - if ( len == npos ) - return FromUTF8Unchecked(utf8); - - wxASSERT( wxStringOperations::IsValidUtf8String(utf8, len) ); - return FromImpl(wxStringImpl(utf8, len)); - } - +#if wxUSE_UNICODE static wxString FromUTF8(const char *utf8) - { - if ( !utf8 || !wxStringOperations::IsValidUtf8String(utf8) ) - return ""; - - return FromImpl(wxStringImpl(utf8)); - } + { return wxString(utf8, wxConvUTF8); } + static wxString FromUTF8(const char *utf8, size_t len) + { return wxString(utf8, wxConvUTF8, len); } + const wxCharBuffer utf8_str() const { return mb_str(wxConvUTF8); } + const wxCharBuffer ToUTF8() const { return utf8_str(); } +#elif wxUSE_WCHAR_T // ANSI + static wxString FromUTF8(const char *utf8) + { return wxString(wxConvUTF8.cMB2WC(utf8)); } static wxString FromUTF8(const char *utf8, size_t len) { - if ( len == npos ) - return FromUTF8(utf8); - - if ( !utf8 || !wxStringOperations::IsValidUtf8String(utf8, len) ) - return ""; - - return FromImpl(wxStringImpl(utf8, len)); + size_t wlen; + wxWCharBuffer buf(wxConvUTF8.cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen)); + return wxString(buf.data(), wxConvLibc, wlen); } + const wxCharBuffer utf8_str() const + { return wxConvUTF8.cWC2MB(wc_str(wxConvLibc)); } + const wxCharBuffer ToUTF8() const { return utf8_str(); } +#endif // Unicode/ANSI +#endif // wxABI_VERSION >= 20804 - const wxScopedCharBuffer utf8_str() const - { return wxCharBuffer::CreateNonOwned(m_impl.c_str(), m_impl.length()); } - - // this function exists in UTF-8 build only and returns the length of the - // internal UTF-8 representation - size_t utf8_length() const { return m_impl.length(); } -#elif wxUSE_UNICODE_WCHAR - static wxString FromUTF8(const char *utf8, size_t len = npos) - { return wxString(utf8, wxMBConvUTF8(), len); } - static wxString FromUTF8Unchecked(const char *utf8, size_t len = npos) - { - const wxString s(utf8, wxMBConvUTF8(), len); - wxASSERT_MSG( !utf8 || !*utf8 || !s.empty(), - "string must be valid UTF-8" ); - return s; - } - const wxScopedCharBuffer utf8_str() const { return mb_str(wxMBConvUTF8()); } -#else // ANSI - static wxString FromUTF8(const char *utf8) - { return wxString(wxMBConvUTF8().cMB2WC(utf8)); } - static wxString FromUTF8(const char *utf8, size_t len) - { - size_t wlen; - wxScopedWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen)); - return wxString(buf.data(), wlen); - } - static wxString FromUTF8Unchecked(const char *utf8, size_t len = npos) - { - size_t wlen; - wxScopedWCharBuffer buf - ( - wxMBConvUTF8().cMB2WC - ( - utf8, - len == npos ? wxNO_LEN : len, - &wlen - ) - ); - wxASSERT_MSG( !utf8 || !*utf8 || wlen, - "string must be valid UTF-8" ); - - return wxString(buf.data(), wlen); - } - const wxScopedCharBuffer utf8_str() const - { return wxMBConvUTF8().cWC2MB(wc_str()); } -#endif - - const wxScopedCharBuffer ToUTF8() const { return utf8_str(); } - +#if wxABI_VERSION >= 20804 // functions for storing binary data in wxString: #if wxUSE_UNICODE static wxString From8BitData(const char *data, size_t len) @@ -1788,17 +895,16 @@ public: // version for NUL-terminated data: static wxString From8BitData(const char *data) { return wxString(data, wxConvISO8859_1); } - const wxScopedCharBuffer To8BitData() const - { return mb_str(wxConvISO8859_1); } + const wxCharBuffer To8BitData() const { return mb_str(wxConvISO8859_1); } #else // ANSI static wxString From8BitData(const char *data, size_t len) { return wxString(data, len); } // version for NUL-terminated data: static wxString From8BitData(const char *data) { return wxString(data); } - const wxScopedCharBuffer To8BitData() const - { return wxScopedCharBuffer::CreateNonOwned(wx_str(), length()); } + const char *To8BitData() const { return c_str(); } #endif // Unicode/ANSI +#endif // wxABI_VERSION >= 20804 // conversions with (possible) format conversions: have to return a // buffer with temporary data @@ -1809,162 +915,71 @@ public: // accepting the file names. The return value is always the same, but the // type differs because a function may either return pointer to the buffer // directly or have to use intermediate buffer for translation. - #if wxUSE_UNICODE - - // this is an optimization: even though using mb_str(wxConvLibc) does the - // same thing (i.e. returns pointer to internal representation as locale is - // always an UTF-8 one) in wxUSE_UTF8_LOCALE_ONLY case, we can avoid the - // extra checks and the temporary buffer construction by providing a - // separate mb_str() overload -#if wxUSE_UTF8_LOCALE_ONLY - const char* mb_str() const { return wx_str(); } - const wxScopedCharBuffer mb_str(const wxMBConv& conv) const - { - return AsCharBuf(conv); - } -#else // !wxUSE_UTF8_LOCALE_ONLY - const wxScopedCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const - { - return AsCharBuf(conv); - } -#endif // wxUSE_UTF8_LOCALE_ONLY/!wxUSE_UTF8_LOCALE_ONLY + const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const; const wxWX2MBbuf mbc_str() const { return mb_str(*wxConvCurrent); } -#if wxUSE_UNICODE_WCHAR - const wchar_t* wc_str() const { return wx_str(); } -#elif wxUSE_UNICODE_UTF8 - const wxScopedWCharBuffer wc_str() const - { return AsWCharBuf(wxMBConvStrictUTF8()); } -#endif + const wxChar* wc_str() const { return c_str(); } + // for compatibility with !wxUSE_UNICODE version - const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const - { return wc_str(); } + const wxChar* wc_str(const wxMBConv& WXUNUSED(conv)) const { return c_str(); } #if wxMBFILES - const wxScopedCharBuffer fn_str() const { return mb_str(wxConvFile); } + const wxCharBuffer fn_str() const { return mb_str(wxConvFile); } #else // !wxMBFILES - const wxWX2WCbuf fn_str() const { return wc_str(); } + const wxChar* fn_str() const { return c_str(); } #endif // wxMBFILES/!wxMBFILES - #else // ANSI - const char* mb_str() const { return wx_str(); } + const wxChar* mb_str() const { return c_str(); } // for compatibility with wxUSE_UNICODE version - const char* mb_str(const wxMBConv& WXUNUSED(conv)) const { return wx_str(); } + const wxChar* mb_str(const wxMBConv& WXUNUSED(conv)) const { return c_str(); } const wxWX2MBbuf mbc_str() const { return mb_str(); } - const wxScopedWCharBuffer wc_str(const wxMBConv& conv = wxConvLibc) const - { return AsWCharBuf(conv); } - - const wxScopedCharBuffer fn_str() const - { return wxConvFile.cWC2WX( wc_str( wxConvLibc ) ); } -#endif // Unicode/ANSI - -#if wxUSE_UNICODE_UTF8 - const wxScopedWCharBuffer t_str() const { return wc_str(); } -#elif wxUSE_UNICODE_WCHAR - const wchar_t* t_str() const { return wx_str(); } +#if wxUSE_WCHAR_T + const wxWCharBuffer wc_str(const wxMBConv& conv) const; +#endif // wxUSE_WCHAR_T +#ifdef __WXOSX__ + const wxCharBuffer fn_str() const { return wxConvFile.cWC2WX( wc_str( wxConvLocal ) ); } #else - const char* t_str() const { return wx_str(); } + const wxChar* fn_str() const { return c_str(); } #endif - +#endif // Unicode/ANSI // overloaded assignment // from another wxString - wxString& operator=(const wxString& stringSrc) - { - if ( this != &stringSrc ) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl = stringSrc.m_impl; - } - - return *this; - } - - wxString& operator=(const wxCStrData& cstr) - { return *this = cstr.AsString(); } + wxString& operator=(const wxStringBase& stringSrc) + { return (wxString&)wxStringBase::operator=(stringSrc); } // from a character - wxString& operator=(wxUniChar ch) - { - wxSTRING_INVALIDATE_CACHE(); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl = wxStringOperations::EncodeChar(ch); - else -#endif // wxUSE_UNICODE_UTF8 - m_impl = (wxStringCharType)ch; - return *this; - } - - wxString& operator=(wxUniCharRef ch) - { return operator=((wxUniChar)ch); } - wxString& operator=(char ch) - { return operator=(wxUniChar(ch)); } - wxString& operator=(unsigned char ch) - { return operator=(wxUniChar(ch)); } - wxString& operator=(wchar_t ch) - { return operator=(wxUniChar(ch)); } + wxString& operator=(wxChar ch) + { return (wxString&)wxStringBase::operator=(ch); } // from a C string - STL probably will crash on NULL, // so we need to compensate in that case -#if wxUSE_STL_BASED_WXSTRING - wxString& operator=(const char *psz) - { - wxSTRING_INVALIDATE_CACHE(); +#if wxUSE_STL + wxString& operator=(const wxChar *psz) + { if(psz) wxStringBase::operator=(psz); else Clear(); return *this; } +#else + wxString& operator=(const wxChar *psz) + { return (wxString&)wxStringBase::operator=(psz); } +#endif - if ( psz ) - m_impl = ImplStr(psz); - else - clear(); - - return *this; - } - - wxString& operator=(const wchar_t *pwz) - { - wxSTRING_INVALIDATE_CACHE(); - - if ( pwz ) - m_impl = ImplStr(pwz); - else - clear(); - - return *this; - } -#else // !wxUSE_STL_BASED_WXSTRING - wxString& operator=(const char *psz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl = ImplStr(psz); - - return *this; - } - - wxString& operator=(const wchar_t *pwz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl = ImplStr(pwz); - - return *this; - } -#endif // wxUSE_STL_BASED_WXSTRING/!wxUSE_STL_BASED_WXSTRING - - wxString& operator=(const unsigned char *psz) - { return operator=((const char*)psz); } - - // from wxScopedWCharBuffer - wxString& operator=(const wxScopedWCharBuffer& s) - { return assign(s); } - // from wxScopedCharBuffer - wxString& operator=(const wxScopedCharBuffer& s) - { return assign(s); } +#if wxUSE_UNICODE + // from wxWCharBuffer + wxString& operator=(const wxWCharBuffer& psz) + { (void) operator=((const wchar_t *)psz); return *this; } +#else // ANSI + // from another kind of C string + wxString& operator=(const unsigned char* psz); +#if wxUSE_WCHAR_T + // from a wide string + wxString& operator=(const wchar_t *pwz); +#endif + // from wxCharBuffer + wxString& operator=(const wxCharBuffer& psz) + { (void) operator=((const char *)psz); return *this; } +#endif // Unicode/ANSI // string concatenation // in place concatenation @@ -1976,8 +991,8 @@ public: // string += string wxString& operator<<(const wxString& s) { -#if WXWIN_COMPATIBILITY_2_8 && !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 - wxASSERT_MSG( s.IsValid(), +#if !wxUSE_STL + wxASSERT_MSG( s.GetStringData()->IsValid(), wxT("did you forget to call UngetWriteBuf()?") ); #endif @@ -1985,24 +1000,23 @@ public: return *this; } // string += C string - wxString& operator<<(const char *psz) + wxString& operator<<(const wxChar *psz) { append(psz); return *this; } - wxString& operator<<(const wchar_t *pwz) - { append(pwz); return *this; } - wxString& operator<<(const wxCStrData& psz) - { append(psz.AsString()); return *this; } // string += char - wxString& operator<<(wxUniChar ch) { append(1, ch); return *this; } - wxString& operator<<(wxUniCharRef ch) { append(1, ch); return *this; } - wxString& operator<<(char ch) { append(1, ch); return *this; } - wxString& operator<<(unsigned char ch) { append(1, ch); return *this; } - wxString& operator<<(wchar_t ch) { append(1, ch); return *this; } + wxString& operator<<(wxChar ch) { append(1, ch); return *this; } // string += buffer (i.e. from wxGetString) - wxString& operator<<(const wxScopedWCharBuffer& s) - { return append(s); } - wxString& operator<<(const wxScopedCharBuffer& s) - { return append(s); } +#if wxUSE_UNICODE + wxString& operator<<(const wxWCharBuffer& s) + { (void)operator<<((const wchar_t *)s); return *this; } + void operator+=(const wxWCharBuffer& s) + { (void)operator<<((const wchar_t *)s); } +#else // !wxUSE_UNICODE + wxString& operator<<(const wxCharBuffer& s) + { (void)operator<<((const char *)s); return *this; } + void operator+=(const wxCharBuffer& s) + { (void)operator<<((const char *)s); } +#endif // wxUSE_UNICODE/!wxUSE_UNICODE // string += C string wxString& Append(const wxString& s) @@ -2014,37 +1028,13 @@ public: append(s); return *this; } - wxString& Append(const char* psz) + wxString& Append(const wxChar* psz) { append(psz); return *this; } - wxString& Append(const wchar_t* pwz) - { append(pwz); return *this; } - wxString& Append(const wxCStrData& psz) - { append(psz); return *this; } - wxString& Append(const wxScopedCharBuffer& psz) - { append(psz); return *this; } - wxString& Append(const wxScopedWCharBuffer& psz) - { append(psz); return *this; } - wxString& Append(const char* psz, size_t nLen) - { append(psz, nLen); return *this; } - wxString& Append(const wchar_t* pwz, size_t nLen) - { append(pwz, nLen); return *this; } - wxString& Append(const wxCStrData& psz, size_t nLen) - { append(psz, nLen); return *this; } - wxString& Append(const wxScopedCharBuffer& psz, size_t nLen) - { append(psz, nLen); return *this; } - wxString& Append(const wxScopedWCharBuffer& psz, size_t nLen) - { append(psz, nLen); return *this; } // append count copies of given character - wxString& Append(wxUniChar ch, size_t count = 1u) - { append(count, ch); return *this; } - wxString& Append(wxUniCharRef ch, size_t count = 1u) - { append(count, ch); return *this; } - wxString& Append(char ch, size_t count = 1u) - { append(count, ch); return *this; } - wxString& Append(unsigned char ch, size_t count = 1u) - { append(count, ch); return *this; } - wxString& Append(wchar_t ch, size_t count = 1u) + wxString& Append(wxChar ch, size_t count = 1u) { append(count, ch); return *this; } + wxString& Append(const wxChar* psz, size_t nLen) + { append(psz, nLen); return *this; } // prepend a string, return the string itself wxString& Prepend(const wxString& str) @@ -2055,18 +1045,14 @@ public: friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2); // string with a single char - friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxUniChar ch); + friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch); // char with a string - friend wxString WXDLLIMPEXP_BASE operator+(wxUniChar ch, const wxString& string); + friend wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string); // string with C string friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, - const char *psz); - friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, - const wchar_t *pwz); + const wxChar *psz); // C string with string - friend wxString WXDLLIMPEXP_BASE operator+(const char *psz, - const wxString& string); - friend wxString WXDLLIMPEXP_BASE operator+(const wchar_t *pwz, + friend wxString WXDLLIMPEXP_BASE operator+(const wxChar *psz, const wxString& string); // stream-like functions @@ -2082,18 +1068,20 @@ public: // insert an unsigned long into string wxString& operator<<(unsigned long ul) { return (*this) << Format(wxT("%lu"), ul); } -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#if defined wxLongLong_t && !defined wxLongLongIsLong // insert a long long if they exist and aren't longs wxString& operator<<(wxLongLong_t ll) { - return (*this) << Format("%" wxLongLongFmtSpec "d", ll); + const wxChar *fmt = wxT("%") wxLongLongFmtSpec wxT("d"); + return (*this) << Format(fmt, ll); } // insert an unsigned long long wxString& operator<<(wxULongLong_t ull) { - return (*this) << Format("%" wxLongLongFmtSpec "u" , ull); + const wxChar *fmt = wxT("%") wxLongLongFmtSpec wxT("u"); + return (*this) << Format(fmt , ull); } -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG +#endif // insert a float into string wxString& operator<<(float f) { return (*this) << Format(wxT("%f"), f); } @@ -2103,56 +1091,21 @@ public: // string comparison // case-sensitive comparison (returns a value < 0, = 0 or > 0) - int Cmp(const char *psz) const - { return compare(psz); } - int Cmp(const wchar_t *pwz) const - { return compare(pwz); } - int Cmp(const wxString& s) const - { return compare(s); } - int Cmp(const wxCStrData& s) const - { return compare(s); } - int Cmp(const wxScopedCharBuffer& s) const - { return compare(s); } - int Cmp(const wxScopedWCharBuffer& s) const - { return compare(s); } + int Cmp(const wxChar *psz) const; + int Cmp(const wxString& s) const; // same as Cmp() but not case-sensitive + int CmpNoCase(const wxChar *psz) const; int CmpNoCase(const wxString& s) const; - // test for the string equality, either considering case or not // (if compareWithCase then the case matters) - bool IsSameAs(const wxString& str, bool compareWithCase = true) const - { -#if !wxUSE_UNICODE_UTF8 - // in UTF-8 build, length() is O(n) and doing this would be _slower_ - if ( length() != str.length() ) - return false; -#endif - return (compareWithCase ? Cmp(str) : CmpNoCase(str)) == 0; - } - bool IsSameAs(const char *str, bool compareWithCase = true) const - { return (compareWithCase ? Cmp(str) : CmpNoCase(str)) == 0; } - bool IsSameAs(const wchar_t *str, bool compareWithCase = true) const - { return (compareWithCase ? Cmp(str) : CmpNoCase(str)) == 0; } - - bool IsSameAs(const wxCStrData& str, bool compareWithCase = true) const - { return IsSameAs(str.AsString(), compareWithCase); } - bool IsSameAs(const wxScopedCharBuffer& str, bool compareWithCase = true) const - { return IsSameAs(str.data(), compareWithCase); } - bool IsSameAs(const wxScopedWCharBuffer& str, bool compareWithCase = true) const - { return IsSameAs(str.data(), compareWithCase); } + bool IsSameAs(const wxChar *psz, bool compareWithCase = true) const + { return (compareWithCase ? Cmp(psz) : CmpNoCase(psz)) == 0; } // comparison with a single character: returns true if equal - bool IsSameAs(wxUniChar c, bool compareWithCase = true) const; - // FIXME-UTF8: remove these overloads - bool IsSameAs(wxUniCharRef c, bool compareWithCase = true) const - { return IsSameAs(wxUniChar(c), compareWithCase); } - bool IsSameAs(char c, bool compareWithCase = true) const - { return IsSameAs(wxUniChar(c), compareWithCase); } - bool IsSameAs(unsigned char c, bool compareWithCase = true) const - { return IsSameAs(wxUniChar(c), compareWithCase); } - bool IsSameAs(wchar_t c, bool compareWithCase = true) const - { return IsSameAs(wxUniChar(c), compareWithCase); } - bool IsSameAs(int c, bool compareWithCase = true) const - { return IsSameAs(wxUniChar(c), compareWithCase); } + bool IsSameAs(wxChar c, bool compareWithCase = true) const + { + return (length() == 1) && (compareWithCase ? GetChar(0u) == c + : wxToupper(GetChar(0u)) == wxToupper(c)); + } // simple sub-string extraction // return substring starting at nFirst of length nCount (or till the end @@ -2166,193 +1119,111 @@ public: // check if the string starts with the given prefix and return the rest // of the string in the provided pointer if it is not NULL; otherwise // return false - bool StartsWith(const wxString& prefix, wxString *rest = NULL) const; + bool StartsWith(const wxChar *prefix, wxString *rest = NULL) const; // check if the string ends with the given suffix and return the // beginning of the string before the suffix in the provided pointer if // it is not NULL; otherwise return false - bool EndsWith(const wxString& suffix, wxString *rest = NULL) const; + bool EndsWith(const wxChar *suffix, wxString *rest = NULL) const; // get first nCount characters wxString Left(size_t nCount) const; // get last nCount characters wxString Right(size_t nCount) const; - // get all characters before the first occurrence of ch - // (returns the whole string if ch not found) and also put everything - // following the first occurrence of ch into rest if it's non-NULL - wxString BeforeFirst(wxUniChar ch, wxString *rest = NULL) const; - // get all characters before the last occurrence of ch - // (returns empty string if ch not found) and also put everything - // following the last occurrence of ch into rest if it's non-NULL - wxString BeforeLast(wxUniChar ch, wxString *rest = NULL) const; - // get all characters after the first occurrence of ch - // (returns empty string if ch not found) - wxString AfterFirst(wxUniChar ch) const; - // get all characters after the last occurrence of ch + // get all characters before the first occurance of ch // (returns the whole string if ch not found) - wxString AfterLast(wxUniChar ch) const; + wxString BeforeFirst(wxChar ch) const; + // get all characters before the last occurence of ch + // (returns empty string if ch not found) + wxString BeforeLast(wxChar ch) const; + // get all characters after the first occurence of ch + // (returns empty string if ch not found) + wxString AfterFirst(wxChar ch) const; + // get all characters after the last occurence of ch + // (returns the whole string if ch not found) + wxString AfterLast(wxChar ch) const; // for compatibility only, use more explicitly named functions above - wxString Before(wxUniChar ch) const { return BeforeLast(ch); } - wxString After(wxUniChar ch) const { return AfterFirst(ch); } + wxString Before(wxChar ch) const { return BeforeLast(ch); } + wxString After(wxChar ch) const { return AfterFirst(ch); } // case conversion // convert to upper case in place, return the string itself wxString& MakeUpper(); // convert to upper case, return the copy of the string - wxString Upper() const { return wxString(*this).MakeUpper(); } + // Here's something to remember: BC++ doesn't like returns in inlines. + wxString Upper() const ; // convert to lower case in place, return the string itself wxString& MakeLower(); // convert to lower case, return the copy of the string - wxString Lower() const { return wxString(*this).MakeLower(); } - // convert the first character to the upper case and the rest to the - // lower one, return the modified string itself - wxString& MakeCapitalized(); - // convert the first character to the upper case and the rest to the - // lower one, return the copy of the string - wxString Capitalize() const { return wxString(*this).MakeCapitalized(); } + wxString Lower() const ; // trimming/padding whitespace (either side) and truncating // remove spaces from left or from right (default) side wxString& Trim(bool bFromRight = true); // add nCount copies chPad in the beginning or at the end (default) - wxString& Pad(size_t nCount, wxUniChar chPad = wxT(' '), bool bFromRight = true); + wxString& Pad(size_t nCount, wxChar chPad = wxT(' '), bool bFromRight = true); // searching and replacing // searching (return starting index, or -1 if not found) - int Find(wxUniChar ch, bool bFromEnd = false) const; // like strchr/strrchr - int Find(wxUniCharRef ch, bool bFromEnd = false) const - { return Find(wxUniChar(ch), bFromEnd); } - int Find(char ch, bool bFromEnd = false) const - { return Find(wxUniChar(ch), bFromEnd); } - int Find(unsigned char ch, bool bFromEnd = false) const - { return Find(wxUniChar(ch), bFromEnd); } - int Find(wchar_t ch, bool bFromEnd = false) const - { return Find(wxUniChar(ch), bFromEnd); } + int Find(wxChar ch, bool bFromEnd = false) const; // like strchr/strrchr // searching (return starting index, or -1 if not found) - int Find(const wxString& sub) const // like strstr - { - size_type idx = find(sub); - return (idx == npos) ? wxNOT_FOUND : (int)idx; - } - int Find(const char *sub) const // like strstr - { - size_type idx = find(sub); - return (idx == npos) ? wxNOT_FOUND : (int)idx; - } - int Find(const wchar_t *sub) const // like strstr - { - size_type idx = find(sub); - return (idx == npos) ? wxNOT_FOUND : (int)idx; - } - - int Find(const wxCStrData& sub) const - { return Find(sub.AsString()); } - int Find(const wxScopedCharBuffer& sub) const - { return Find(sub.data()); } - int Find(const wxScopedWCharBuffer& sub) const - { return Find(sub.data()); } - - // replace first (or all of bReplaceAll) occurrences of substring with + int Find(const wxChar *pszSub) const; // like strstr + // replace first (or all of bReplaceAll) occurences of substring with // another string, returns the number of replacements made - size_t Replace(const wxString& strOld, - const wxString& strNew, + size_t Replace(const wxChar *szOld, + const wxChar *szNew, bool bReplaceAll = true); // check if the string contents matches a mask containing '*' and '?' - bool Matches(const wxString& mask) const; + bool Matches(const wxChar *szMask) const; - // conversion to numbers: all functions return true only if the whole - // string is a number and put the value of this number into the pointer - // provided, the base is the numeric base in which the conversion should be - // done and must be comprised between 2 and 36 or be 0 in which case the - // standard C rules apply (leading '0' => octal, "0x" => hex) - // convert to a signed integer - bool ToLong(long *val, int base = 10) const; - // convert to an unsigned integer - bool ToULong(unsigned long *val, int base = 10) const; - // convert to wxLongLong + // conversion to numbers: all functions return true only if the whole + // string is a number and put the value of this number into the pointer + // provided, the base is the numeric base in which the conversion should be + // done and must be comprised between 2 and 36 or be 0 in which case the + // standard C rules apply (leading '0' => octal, "0x" => hex) + // convert to a signed integer + bool ToLong(long *val, int base = 10) const; + // convert to an unsigned integer + bool ToULong(unsigned long *val, int base = 10) const; + // convert to wxLongLong #if defined(wxLongLong_t) - bool ToLongLong(wxLongLong_t *val, int base = 10) const; - // convert to wxULongLong - bool ToULongLong(wxULongLong_t *val, int base = 10) const; + bool ToLongLong(wxLongLong_t *val, int base = 10) const; + // convert to wxULongLong + bool ToULongLong(wxULongLong_t *val, int base = 10) const; #endif // wxLongLong_t - // convert to a double - bool ToDouble(double *val) const; + // convert to a double + bool ToDouble(double *val) const; - // conversions to numbers using C locale - // convert to a signed integer - bool ToCLong(long *val, int base = 10) const; - // convert to an unsigned integer - bool ToCULong(unsigned long *val, int base = 10) const; - // convert to a double - bool ToCDouble(double *val) const; - // create a string representing the given floating point number with the - // default (like %g) or fixed (if precision >=0) precision - // in the current locale - static wxString FromDouble(double val, int precision = -1); - // in C locale - static wxString FromCDouble(double val, int precision = -1); -#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN // formatted input/output // as sprintf(), returns the number of characters written or < 0 on error // (take 'this' into account in attribute parameter count) - // int Printf(const wxString& format, ...); - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&), - DoPrintfWchar, DoPrintfUtf8) -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxString&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxCStrData&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const char*), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wchar_t*), - (wxFormatString(f1))); -#endif -#endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN + int Printf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2; // as vprintf(), returns the number of characters written or < 0 on error - int PrintfV(const wxString& format, va_list argptr); + int PrintfV(const wxChar* pszFormat, va_list argptr); -#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN // returns the string containing the result of Printf() to it - // static wxString Format(const wxString& format, ...) WX_ATTRIBUTE_PRINTF_1; - WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxFormatString&), - DoFormatWchar, DoFormatUtf8) -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxString&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxCStrData&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const char*), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wchar_t*), - (wxFormatString(f1))); -#endif -#endif + static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1; // the same as above, but takes a va_list - static wxString FormatV(const wxString& format, va_list argptr); + static wxString FormatV(const wxChar *pszFormat, va_list argptr); // raw access to string memory // ensure that string has space for at least nLen characters // only works if the data of this string is not shared - bool Alloc(size_t nLen) { reserve(nLen); return capacity() >= nLen; } + bool Alloc(size_t nLen) { reserve(nLen); /*return capacity() >= nLen;*/ return true; } // minimize the string's memory // only works if the data of this string is not shared bool Shrink(); -#if WXWIN_COMPATIBILITY_2_8 && !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 - // These are deprecated, use wxStringBuffer or wxStringBufferLength instead - // +#if !wxUSE_STL // get writable buffer of at least nLen bytes. Unget() *must* be called // a.s.a.p. to put string back in a reasonable state! - wxDEPRECATED( wxStringCharType *GetWriteBuf(size_t nLen) ); + wxChar *GetWriteBuf(size_t nLen); // call this immediately after GetWriteBuf() has been used - wxDEPRECATED( void UngetWriteBuf() ); - wxDEPRECATED( void UngetWriteBuf(size_t nLen) ); -#endif // WXWIN_COMPATIBILITY_2_8 && !wxUSE_STL_BASED_WXSTRING && wxUSE_UNICODE_UTF8 + void UngetWriteBuf(); + void UngetWriteBuf(size_t nLen); +#endif // wxWidgets version 1 compatibility functions @@ -2364,33 +1235,18 @@ public: // values for first parameter of Strip function enum stripType {leading = 0x1, trailing = 0x2, both = 0x3}; -#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN // use Printf() // (take 'this' into account in attribute parameter count) - // int sprintf(const wxString& format, ...) WX_ATTRIBUTE_PRINTF_2; - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxFormatString&), - DoPrintfWchar, DoPrintfUtf8) -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxString&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxCStrData&), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const char*), - (wxFormatString(f1))); - WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wchar_t*), - (wxFormatString(f1))); -#endif -#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN + int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2; // use Cmp() - int CompareTo(const wxChar* psz, caseCompare cmp = exact) const + inline int CompareTo(const wxChar* psz, caseCompare cmp = exact) const { return cmp == exact ? Cmp(psz) : CmpNoCase(psz); } - // use length() + // use Len size_t Length() const { return length(); } // Count the number of characters - int Freq(wxUniChar ch) const; + int Freq(wxChar ch) const; // use MakeLower void LowerCase() { MakeLower(); } // use MakeUpper @@ -2400,7 +1256,7 @@ public: // use Find (more general variants not yet supported) size_t Index(const wxChar* psz) const { return Find(psz); } - size_t Index(wxUniChar ch) const { return Find(ch); } + size_t Index(wxChar ch) const { return Find(ch); } // use Truncate wxString& Remove(size_t pos) { return Truncate(pos); } wxString& RemoveLast(size_t n = 1) { return Truncate(length() - n); } @@ -2409,13 +1265,10 @@ public: { return (wxString&)erase( nStart, nLen ); } // use Find() - int First( wxUniChar ch ) const { return Find(ch); } - int First( wxUniCharRef ch ) const { return Find(ch); } - int First( char ch ) const { return Find(ch); } - int First( unsigned char ch ) const { return Find(ch); } - int First( wchar_t ch ) const { return Find(ch); } - int First( const wxString& str ) const { return Find(str); } - int Last( wxUniChar ch ) const { return Find(ch, true); } + int First( const wxChar ch ) const { return Find(ch); } + int First( const wxChar* psz ) const { return Find(psz); } + int First( const wxString &str ) const { return Find(str); } + int Last( const wxChar ch ) const { return Find(ch, true); } bool Contains(const wxString& str) const { return Find(str) != wxNOT_FOUND; } // use empty() @@ -2425,1899 +1278,376 @@ public: // take nLen chars starting at nPos wxString(const wxString& str, size_t nPos, size_t nLen) - { assign(str, nPos, nLen); } - // take all characters from first to last + : wxStringBase(str, nPos, nLen) { } + // take all characters from pStart to pEnd + wxString(const void *pStart, const void *pEnd) + : wxStringBase((const wxChar*)pStart, (const wxChar*)pEnd) { } +#if wxUSE_STL wxString(const_iterator first, const_iterator last) - : m_impl(first.impl(), last.impl()) { } -#if WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - // the 2 overloads below are for compatibility with the existing code using - // pointers instead of iterators - wxString(const char *first, const char *last) - { - SubstrBufFromMB str(ImplStr(first, last - first)); - m_impl.assign(str.data, str.len); - } - wxString(const wchar_t *first, const wchar_t *last) - { - SubstrBufFromWC str(ImplStr(first, last - first)); - m_impl.assign(str.data, str.len); - } - // and this one is needed to compile code adding offsets to c_str() result - wxString(const wxCStrData& first, const wxCStrData& last) - : m_impl(CreateConstIterator(first).impl(), - CreateConstIterator(last).impl()) - { - wxASSERT_MSG( first.m_str == last.m_str, - wxT("pointers must be into the same string") ); - } -#endif // WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER + : wxStringBase(first, last) { } +#endif // lib.string.modifiers // append elements str[pos], ..., str[pos+n] wxString& append(const wxString& str, size_t pos, size_t n) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - size_t from, len; - str.PosLenToImpl(pos, n, &from, &len); - m_impl.append(str.m_impl, from, len); - return *this; - } + { return (wxString&)wxStringBase::append(str, pos, n); } // append a string wxString& append(const wxString& str) - { - wxSTRING_UPDATE_CACHED_LENGTH(str.length()); - - m_impl.append(str.m_impl); - return *this; - } - + { return (wxString&)wxStringBase::append(str); } // append first n (or all if n == npos) characters of sz - wxString& append(const char *sz) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl.append(ImplStr(sz)); - return *this; - } - - wxString& append(const wchar_t *sz) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl.append(ImplStr(sz)); - return *this; - } - - wxString& append(const char *sz, size_t n) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - SubstrBufFromMB str(ImplStr(sz, n)); - m_impl.append(str.data, str.len); - return *this; - } - wxString& append(const wchar_t *sz, size_t n) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - SubstrBufFromWC str(ImplStr(sz, n)); - m_impl.append(str.data, str.len); - return *this; - } - - wxString& append(const wxCStrData& str) - { return append(str.AsString()); } - wxString& append(const wxScopedCharBuffer& str) - { return append(str.data(), str.length()); } - wxString& append(const wxScopedWCharBuffer& str) - { return append(str.data(), str.length()); } - wxString& append(const wxCStrData& str, size_t n) - { return append(str.AsString(), 0, n); } - wxString& append(const wxScopedCharBuffer& str, size_t n) - { return append(str.data(), n); } - wxString& append(const wxScopedWCharBuffer& str, size_t n) - { return append(str.data(), n); } - + wxString& append(const wxChar *sz) + { return (wxString&)wxStringBase::append(sz); } + wxString& append(const wxChar *sz, size_t n) + { return (wxString&)wxStringBase::append(sz, n); } // append n copies of ch - wxString& append(size_t n, wxUniChar ch) - { -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl.append(wxStringOperations::EncodeNChars(n, ch)); - } - else // ASCII -#endif - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - m_impl.append(n, (wxStringCharType)ch); - } - - return *this; - } - - wxString& append(size_t n, wxUniCharRef ch) - { return append(n, wxUniChar(ch)); } - wxString& append(size_t n, char ch) - { return append(n, wxUniChar(ch)); } - wxString& append(size_t n, unsigned char ch) - { return append(n, wxUniChar(ch)); } - wxString& append(size_t n, wchar_t ch) - { return append(n, wxUniChar(ch)); } - + wxString& append(size_t n, wxChar ch) + { return (wxString&)wxStringBase::append(n, ch); } // append from first to last wxString& append(const_iterator first, const_iterator last) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl.append(first.impl(), last.impl()); - return *this; - } -#if WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - wxString& append(const char *first, const char *last) - { return append(first, last - first); } - wxString& append(const wchar_t *first, const wchar_t *last) - { return append(first, last - first); } - wxString& append(const wxCStrData& first, const wxCStrData& last) - { return append(CreateConstIterator(first), CreateConstIterator(last)); } -#endif // WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER + { return (wxString&)wxStringBase::append(first, last); } // same as `this_string = str' wxString& assign(const wxString& str) - { - wxSTRING_SET_CACHED_LENGTH(str.length()); - - m_impl = str.m_impl; - - return *this; - } - - // This is a non-standard-compliant overload taking the first "len" - // characters of the source string. - wxString& assign(const wxString& str, size_t len) - { -#if wxUSE_STRING_POS_CACHE - // It is legal to pass len > str.length() to wxStringImpl::assign() but - // by restricting it here we save some work for that function so it's not - // really less efficient and, at the same time, ensure that we don't - // cache invalid length. - const size_t lenSrc = str.length(); - if ( len > lenSrc ) - len = lenSrc; - - wxSTRING_SET_CACHED_LENGTH(len); -#endif // wxUSE_STRING_POS_CACHE - - m_impl.assign(str.m_impl, 0, str.LenToImpl(len)); - - return *this; - } - + { return (wxString&)wxStringBase::assign(str); } // same as ` = str[pos..pos + n] wxString& assign(const wxString& str, size_t pos, size_t n) - { - size_t from, len; - str.PosLenToImpl(pos, n, &from, &len); - m_impl.assign(str.m_impl, from, len); - - // it's important to call this after PosLenToImpl() above in case str is - // the same string as this one - wxSTRING_SET_CACHED_LENGTH(n); - - return *this; - } - + { return (wxString&)wxStringBase::assign(str, pos, n); } // same as `= first n (or all if n == npos) characters of sz' - wxString& assign(const char *sz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.assign(ImplStr(sz)); - - return *this; - } - - wxString& assign(const wchar_t *sz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.assign(ImplStr(sz)); - - return *this; - } - - wxString& assign(const char *sz, size_t n) - { - wxSTRING_INVALIDATE_CACHE(); - - SubstrBufFromMB str(ImplStr(sz, n)); - m_impl.assign(str.data, str.len); - - return *this; - } - - wxString& assign(const wchar_t *sz, size_t n) - { - wxSTRING_SET_CACHED_LENGTH(n); - - SubstrBufFromWC str(ImplStr(sz, n)); - m_impl.assign(str.data, str.len); - - return *this; - } - - wxString& assign(const wxCStrData& str) - { return assign(str.AsString()); } - wxString& assign(const wxScopedCharBuffer& str) - { return assign(str.data(), str.length()); } - wxString& assign(const wxScopedWCharBuffer& str) - { return assign(str.data(), str.length()); } - wxString& assign(const wxCStrData& str, size_t len) - { return assign(str.AsString(), len); } - wxString& assign(const wxScopedCharBuffer& str, size_t len) - { return assign(str.data(), len); } - wxString& assign(const wxScopedWCharBuffer& str, size_t len) - { return assign(str.data(), len); } - + wxString& assign(const wxChar *sz) + { return (wxString&)wxStringBase::assign(sz); } + wxString& assign(const wxChar *sz, size_t n) + { return (wxString&)wxStringBase::assign(sz, n); } // same as `= n copies of ch' - wxString& assign(size_t n, wxUniChar ch) - { - wxSTRING_SET_CACHED_LENGTH(n); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl.assign(wxStringOperations::EncodeNChars(n, ch)); - else -#endif - m_impl.assign(n, (wxStringCharType)ch); - - return *this; - } - - wxString& assign(size_t n, wxUniCharRef ch) - { return assign(n, wxUniChar(ch)); } - wxString& assign(size_t n, char ch) - { return assign(n, wxUniChar(ch)); } - wxString& assign(size_t n, unsigned char ch) - { return assign(n, wxUniChar(ch)); } - wxString& assign(size_t n, wchar_t ch) - { return assign(n, wxUniChar(ch)); } - + wxString& assign(size_t n, wxChar ch) + { return (wxString&)wxStringBase::assign(n, ch); } // assign from first to last wxString& assign(const_iterator first, const_iterator last) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.assign(first.impl(), last.impl()); - - return *this; - } -#if WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - wxString& assign(const char *first, const char *last) - { return assign(first, last - first); } - wxString& assign(const wchar_t *first, const wchar_t *last) - { return assign(first, last - first); } - wxString& assign(const wxCStrData& first, const wxCStrData& last) - { return assign(CreateConstIterator(first), CreateConstIterator(last)); } -#endif // WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER + { return (wxString&)wxStringBase::assign(first, last); } // string comparison - int compare(const wxString& str) const; - int compare(const char* sz) const; - int compare(const wchar_t* sz) const; - int compare(const wxCStrData& str) const - { return compare(str.AsString()); } - int compare(const wxScopedCharBuffer& str) const - { return compare(str.data()); } - int compare(const wxScopedWCharBuffer& str) const - { return compare(str.data()); } +#if !defined(HAVE_STD_STRING_COMPARE) + int compare(const wxStringBase& str) const; // comparison with a substring - int compare(size_t nStart, size_t nLen, const wxString& str) const; + int compare(size_t nStart, size_t nLen, const wxStringBase& str) const; // comparison of 2 substrings int compare(size_t nStart, size_t nLen, - const wxString& str, size_t nStart2, size_t nLen2) const; + const wxStringBase& str, size_t nStart2, size_t nLen2) const; + // just like strcmp() + int compare(const wxChar* sz) const; // substring comparison with first nCount characters of sz int compare(size_t nStart, size_t nLen, - const char* sz, size_t nCount = npos) const; - int compare(size_t nStart, size_t nLen, - const wchar_t* sz, size_t nCount = npos) const; + const wxChar* sz, size_t nCount = npos) const; +#endif // !defined HAVE_STD_STRING_COMPARE // insert another string wxString& insert(size_t nPos, const wxString& str) - { insert(GetIterForNthChar(nPos), str.begin(), str.end()); return *this; } + { return (wxString&)wxStringBase::insert(nPos, str); } // insert n chars of str starting at nStart (in str) wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - size_t from, len; - str.PosLenToImpl(nStart, n, &from, &len); - m_impl.insert(PosToImpl(nPos), str.m_impl, from, len); - - return *this; - } - + { return (wxString&)wxStringBase::insert(nPos, str, nStart, n); } // insert first n (or all if n == npos) characters of sz - wxString& insert(size_t nPos, const char *sz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.insert(PosToImpl(nPos), ImplStr(sz)); - - return *this; - } - - wxString& insert(size_t nPos, const wchar_t *sz) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.insert(PosToImpl(nPos), ImplStr(sz)); return *this; - } - - wxString& insert(size_t nPos, const char *sz, size_t n) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - SubstrBufFromMB str(ImplStr(sz, n)); - m_impl.insert(PosToImpl(nPos), str.data, str.len); - - return *this; - } - - wxString& insert(size_t nPos, const wchar_t *sz, size_t n) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - - SubstrBufFromWC str(ImplStr(sz, n)); - m_impl.insert(PosToImpl(nPos), str.data, str.len); - - return *this; - } - + wxString& insert(size_t nPos, const wxChar *sz) + { return (wxString&)wxStringBase::insert(nPos, sz); } + wxString& insert(size_t nPos, const wxChar *sz, size_t n) + { return (wxString&)wxStringBase::insert(nPos, sz, n); } // insert n copies of ch - wxString& insert(size_t nPos, size_t n, wxUniChar ch) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl.insert(PosToImpl(nPos), wxStringOperations::EncodeNChars(n, ch)); - else -#endif - m_impl.insert(PosToImpl(nPos), n, (wxStringCharType)ch); - return *this; - } - - iterator insert(iterator it, wxUniChar ch) - { - wxSTRING_UPDATE_CACHED_LENGTH(1); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - { - size_t pos = IterToImplPos(it); - m_impl.insert(pos, wxStringOperations::EncodeChar(ch)); - return iterator(this, m_impl.begin() + pos); - } - else -#endif - return iterator(this, m_impl.insert(it.impl(), (wxStringCharType)ch)); - } - + wxString& insert(size_t nPos, size_t n, wxChar ch) + { return (wxString&)wxStringBase::insert(nPos, n, ch); } + iterator insert(iterator it, wxChar ch) + { return wxStringBase::insert(it, ch); } void insert(iterator it, const_iterator first, const_iterator last) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.insert(it.impl(), first.impl(), last.impl()); - } - -#if WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - void insert(iterator it, const char *first, const char *last) - { insert(it - begin(), first, last - first); } - void insert(iterator it, const wchar_t *first, const wchar_t *last) - { insert(it - begin(), first, last - first); } - void insert(iterator it, const wxCStrData& first, const wxCStrData& last) - { insert(it, CreateConstIterator(first), CreateConstIterator(last)); } -#endif // WXWIN_COMPATIBILITY_STRING_PTR_AS_ITER - - void insert(iterator it, size_type n, wxUniChar ch) - { - wxSTRING_UPDATE_CACHED_LENGTH(n); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl.insert(IterToImplPos(it), wxStringOperations::EncodeNChars(n, ch)); - else -#endif - m_impl.insert(it.impl(), n, (wxStringCharType)ch); - } + { wxStringBase::insert(it, first, last); } + void insert(iterator it, size_type n, wxChar ch) + { wxStringBase::insert(it, n, ch); } // delete characters from nStart to nStart + nLen wxString& erase(size_type pos = 0, size_type n = npos) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(pos, n, &from, &len); - m_impl.erase(from, len); - - return *this; - } - - // delete characters from first up to last + { return (wxString&)wxStringBase::erase(pos, n); } iterator erase(iterator first, iterator last) - { - wxSTRING_INVALIDATE_CACHE(); - - return iterator(this, m_impl.erase(first.impl(), last.impl())); - } - + { return wxStringBase::erase(first, last); } iterator erase(iterator first) - { - wxSTRING_UPDATE_CACHED_LENGTH(-1); - - return iterator(this, m_impl.erase(first.impl())); - } + { return wxStringBase::erase(first); } #ifdef wxSTRING_BASE_HASNT_CLEAR void clear() { erase(); } -#else - void clear() - { - wxSTRING_SET_CACHED_LENGTH(0); - - m_impl.clear(); - } #endif // replaces the substring of length nLen starting at nStart - wxString& replace(size_t nStart, size_t nLen, const char* sz) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - m_impl.replace(from, len, ImplStr(sz)); - - return *this; - } - - wxString& replace(size_t nStart, size_t nLen, const wchar_t* sz) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - m_impl.replace(from, len, ImplStr(sz)); - - return *this; - } - + wxString& replace(size_t nStart, size_t nLen, const wxChar* sz) + { return (wxString&)wxStringBase::replace(nStart, nLen, sz); } // replaces the substring of length nLen starting at nStart wxString& replace(size_t nStart, size_t nLen, const wxString& str) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - m_impl.replace(from, len, str.m_impl); - - return *this; - } - + { return (wxString&)wxStringBase::replace(nStart, nLen, str); } // replaces the substring with nCount copies of ch - wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxUniChar ch) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl.replace(from, len, wxStringOperations::EncodeNChars(nCount, ch)); - else -#endif - m_impl.replace(from, len, nCount, (wxStringCharType)ch); - - return *this; - } - + wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch) + { return (wxString&)wxStringBase::replace(nStart, nLen, nCount, ch); } // replaces a substring with another substring wxString& replace(size_t nStart, size_t nLen, const wxString& str, size_t nStart2, size_t nLen2) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - - size_t from2, len2; - str.PosLenToImpl(nStart2, nLen2, &from2, &len2); - - m_impl.replace(from, len, str.m_impl, from2, len2); - - return *this; - } - + { return (wxString&)wxStringBase::replace(nStart, nLen, str, + nStart2, nLen2); } // replaces the substring with first nCount chars of sz wxString& replace(size_t nStart, size_t nLen, - const char* sz, size_t nCount) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - - SubstrBufFromMB str(ImplStr(sz, nCount)); - - m_impl.replace(from, len, str.data, str.len); - - return *this; - } - - wxString& replace(size_t nStart, size_t nLen, - const wchar_t* sz, size_t nCount) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - - SubstrBufFromWC str(ImplStr(sz, nCount)); - - m_impl.replace(from, len, str.data, str.len); - - return *this; - } - - wxString& replace(size_t nStart, size_t nLen, - const wxString& s, size_t nCount) - { - wxSTRING_INVALIDATE_CACHE(); - - size_t from, len; - PosLenToImpl(nStart, nLen, &from, &len); - m_impl.replace(from, len, s.m_impl.c_str(), s.LenToImpl(nCount)); - - return *this; - } - - wxString& replace(iterator first, iterator last, const char* s) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.replace(first.impl(), last.impl(), ImplStr(s)); - - return *this; - } - - wxString& replace(iterator first, iterator last, const wchar_t* s) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.replace(first.impl(), last.impl(), ImplStr(s)); - - return *this; - } - - wxString& replace(iterator first, iterator last, const char* s, size_type n) - { - wxSTRING_INVALIDATE_CACHE(); - - SubstrBufFromMB str(ImplStr(s, n)); - m_impl.replace(first.impl(), last.impl(), str.data, str.len); - - return *this; - } - - wxString& replace(iterator first, iterator last, const wchar_t* s, size_type n) - { - wxSTRING_INVALIDATE_CACHE(); - - SubstrBufFromWC str(ImplStr(s, n)); - m_impl.replace(first.impl(), last.impl(), str.data, str.len); - - return *this; - } - + const wxChar* sz, size_t nCount) + { return (wxString&)wxStringBase::replace(nStart, nLen, sz, nCount); } + wxString& replace(iterator first, iterator last, const_pointer s) + { return (wxString&)wxStringBase::replace(first, last, s); } + wxString& replace(iterator first, iterator last, const_pointer s, + size_type n) + { return (wxString&)wxStringBase::replace(first, last, s, n); } wxString& replace(iterator first, iterator last, const wxString& s) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.replace(first.impl(), last.impl(), s.m_impl); - - return *this; - } - - wxString& replace(iterator first, iterator last, size_type n, wxUniChar ch) - { - wxSTRING_INVALIDATE_CACHE(); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl.replace(first.impl(), last.impl(), - wxStringOperations::EncodeNChars(n, ch)); - else -#endif - m_impl.replace(first.impl(), last.impl(), n, (wxStringCharType)ch); - - return *this; - } - + { return (wxString&)wxStringBase::replace(first, last, s); } + wxString& replace(iterator first, iterator last, size_type n, wxChar c) + { return (wxString&)wxStringBase::replace(first, last, n, c); } wxString& replace(iterator first, iterator last, const_iterator first1, const_iterator last1) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.replace(first.impl(), last.impl(), first1.impl(), last1.impl()); - - return *this; - } - - wxString& replace(iterator first, iterator last, - const char *first1, const char *last1) - { replace(first, last, first1, last1 - first1); return *this; } - wxString& replace(iterator first, iterator last, - const wchar_t *first1, const wchar_t *last1) - { replace(first, last, first1, last1 - first1); return *this; } - - // swap two strings - void swap(wxString& str) - { -#if wxUSE_STRING_POS_CACHE - // we modify not only this string but also the other one directly so we - // need to invalidate cache for both of them (we could also try to - // exchange their cache entries but it seems unlikely to be worth it) - InvalidateCache(); - str.InvalidateCache(); -#endif // wxUSE_STRING_POS_CACHE - - m_impl.swap(str.m_impl); - } - - // find a substring - size_t find(const wxString& str, size_t nStart = 0) const - { return PosFromImpl(m_impl.find(str.m_impl, PosToImpl(nStart))); } - - // find first n characters of sz - size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const - { - SubstrBufFromMB str(ImplStr(sz, n)); - return PosFromImpl(m_impl.find(str.data, PosToImpl(nStart), str.len)); - } - size_t find(const wchar_t* sz, size_t nStart = 0, size_t n = npos) const - { - SubstrBufFromWC str(ImplStr(sz, n)); - return PosFromImpl(m_impl.find(str.data, PosToImpl(nStart), str.len)); - } - size_t find(const wxScopedCharBuffer& s, size_t nStart = 0, size_t n = npos) const - { return find(s.data(), nStart, n); } - size_t find(const wxScopedWCharBuffer& s, size_t nStart = 0, size_t n = npos) const - { return find(s.data(), nStart, n); } - size_t find(const wxCStrData& s, size_t nStart = 0, size_t n = npos) const - { return find(s.AsWChar(), nStart, n); } - - // find the first occurrence of character ch after nStart - size_t find(wxUniChar ch, size_t nStart = 0) const - { -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - return PosFromImpl(m_impl.find(wxStringOperations::EncodeChar(ch), - PosToImpl(nStart))); - else -#endif - return PosFromImpl(m_impl.find((wxStringCharType)ch, - PosToImpl(nStart))); - - } - size_t find(wxUniCharRef ch, size_t nStart = 0) const - { return find(wxUniChar(ch), nStart); } - size_t find(char ch, size_t nStart = 0) const - { return find(wxUniChar(ch), nStart); } - size_t find(unsigned char ch, size_t nStart = 0) const - { return find(wxUniChar(ch), nStart); } - size_t find(wchar_t ch, size_t nStart = 0) const - { return find(wxUniChar(ch), nStart); } - - // rfind() family is exactly like find() but works right to left - - // as find, but from the end - size_t rfind(const wxString& str, size_t nStart = npos) const - { return PosFromImpl(m_impl.rfind(str.m_impl, PosToImpl(nStart))); } - - // as find, but from the end - size_t rfind(const char* sz, size_t nStart = npos, size_t n = npos) const - { - SubstrBufFromMB str(ImplStr(sz, n)); - return PosFromImpl(m_impl.rfind(str.data, PosToImpl(nStart), str.len)); - } - size_t rfind(const wchar_t* sz, size_t nStart = npos, size_t n = npos) const - { - SubstrBufFromWC str(ImplStr(sz, n)); - return PosFromImpl(m_impl.rfind(str.data, PosToImpl(nStart), str.len)); - } - size_t rfind(const wxScopedCharBuffer& s, size_t nStart = npos, size_t n = npos) const - { return rfind(s.data(), nStart, n); } - size_t rfind(const wxScopedWCharBuffer& s, size_t nStart = npos, size_t n = npos) const - { return rfind(s.data(), nStart, n); } - size_t rfind(const wxCStrData& s, size_t nStart = npos, size_t n = npos) const - { return rfind(s.AsWChar(), nStart, n); } - // as find, but from the end - size_t rfind(wxUniChar ch, size_t nStart = npos) const - { -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - return PosFromImpl(m_impl.rfind(wxStringOperations::EncodeChar(ch), - PosToImpl(nStart))); - else -#endif - return PosFromImpl(m_impl.rfind((wxStringCharType)ch, - PosToImpl(nStart))); - } - size_t rfind(wxUniCharRef ch, size_t nStart = npos) const - { return rfind(wxUniChar(ch), nStart); } - size_t rfind(char ch, size_t nStart = npos) const - { return rfind(wxUniChar(ch), nStart); } - size_t rfind(unsigned char ch, size_t nStart = npos) const - { return rfind(wxUniChar(ch), nStart); } - size_t rfind(wchar_t ch, size_t nStart = npos) const - { return rfind(wxUniChar(ch), nStart); } - - // find first/last occurrence of any character (not) in the set: -#if wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 - // FIXME-UTF8: this is not entirely correct, because it doesn't work if - // sizeof(wchar_t)==2 and surrogates are present in the string; - // should we care? Probably not. - size_t find_first_of(const wxString& str, size_t nStart = 0) const - { return m_impl.find_first_of(str.m_impl, nStart); } - size_t find_first_of(const char* sz, size_t nStart = 0) const - { return m_impl.find_first_of(ImplStr(sz), nStart); } - size_t find_first_of(const wchar_t* sz, size_t nStart = 0) const - { return m_impl.find_first_of(ImplStr(sz), nStart); } - size_t find_first_of(const char* sz, size_t nStart, size_t n) const - { return m_impl.find_first_of(ImplStr(sz), nStart, n); } - size_t find_first_of(const wchar_t* sz, size_t nStart, size_t n) const - { return m_impl.find_first_of(ImplStr(sz), nStart, n); } - size_t find_first_of(wxUniChar c, size_t nStart = 0) const - { return m_impl.find_first_of((wxChar)c, nStart); } - - size_t find_last_of(const wxString& str, size_t nStart = npos) const - { return m_impl.find_last_of(str.m_impl, nStart); } - size_t find_last_of(const char* sz, size_t nStart = npos) const - { return m_impl.find_last_of(ImplStr(sz), nStart); } - size_t find_last_of(const wchar_t* sz, size_t nStart = npos) const - { return m_impl.find_last_of(ImplStr(sz), nStart); } - size_t find_last_of(const char* sz, size_t nStart, size_t n) const - { return m_impl.find_last_of(ImplStr(sz), nStart, n); } - size_t find_last_of(const wchar_t* sz, size_t nStart, size_t n) const - { return m_impl.find_last_of(ImplStr(sz), nStart, n); } - size_t find_last_of(wxUniChar c, size_t nStart = npos) const - { return m_impl.find_last_of((wxChar)c, nStart); } - - size_t find_first_not_of(const wxString& str, size_t nStart = 0) const - { return m_impl.find_first_not_of(str.m_impl, nStart); } - size_t find_first_not_of(const char* sz, size_t nStart = 0) const - { return m_impl.find_first_not_of(ImplStr(sz), nStart); } - size_t find_first_not_of(const wchar_t* sz, size_t nStart = 0) const - { return m_impl.find_first_not_of(ImplStr(sz), nStart); } - size_t find_first_not_of(const char* sz, size_t nStart, size_t n) const - { return m_impl.find_first_not_of(ImplStr(sz), nStart, n); } - size_t find_first_not_of(const wchar_t* sz, size_t nStart, size_t n) const - { return m_impl.find_first_not_of(ImplStr(sz), nStart, n); } - size_t find_first_not_of(wxUniChar c, size_t nStart = 0) const - { return m_impl.find_first_not_of((wxChar)c, nStart); } - - size_t find_last_not_of(const wxString& str, size_t nStart = npos) const - { return m_impl.find_last_not_of(str.m_impl, nStart); } - size_t find_last_not_of(const char* sz, size_t nStart = npos) const - { return m_impl.find_last_not_of(ImplStr(sz), nStart); } - size_t find_last_not_of(const wchar_t* sz, size_t nStart = npos) const - { return m_impl.find_last_not_of(ImplStr(sz), nStart); } - size_t find_last_not_of(const char* sz, size_t nStart, size_t n) const - { return m_impl.find_last_not_of(ImplStr(sz), nStart, n); } - size_t find_last_not_of(const wchar_t* sz, size_t nStart, size_t n) const - { return m_impl.find_last_not_of(ImplStr(sz), nStart, n); } - size_t find_last_not_of(wxUniChar c, size_t nStart = npos) const - { return m_impl.find_last_not_of((wxChar)c, nStart); } -#else - // we can't use std::string implementation in UTF-8 build, because the - // character sets would be interpreted wrongly: - - // as strpbrk() but starts at nStart, returns npos if not found - size_t find_first_of(const wxString& str, size_t nStart = 0) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_first_of(str.wc_str(), nStart); } -#else - { return find_first_of(str.mb_str(), nStart); } -#endif - // same as above - size_t find_first_of(const char* sz, size_t nStart = 0) const; - size_t find_first_of(const wchar_t* sz, size_t nStart = 0) const; - size_t find_first_of(const char* sz, size_t nStart, size_t n) const; - size_t find_first_of(const wchar_t* sz, size_t nStart, size_t n) const; - // same as find(char, size_t) - size_t find_first_of(wxUniChar c, size_t nStart = 0) const - { return find(c, nStart); } - // find the last (starting from nStart) char from str in this string - size_t find_last_of (const wxString& str, size_t nStart = npos) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_last_of(str.wc_str(), nStart); } -#else - { return find_last_of(str.mb_str(), nStart); } -#endif - // same as above - size_t find_last_of (const char* sz, size_t nStart = npos) const; - size_t find_last_of (const wchar_t* sz, size_t nStart = npos) const; - size_t find_last_of(const char* sz, size_t nStart, size_t n) const; - size_t find_last_of(const wchar_t* sz, size_t nStart, size_t n) const; - // same as above - size_t find_last_of(wxUniChar c, size_t nStart = npos) const - { return rfind(c, nStart); } - - // find first/last occurrence of any character not in the set - - // as strspn() (starting from nStart), returns npos on failure - size_t find_first_not_of(const wxString& str, size_t nStart = 0) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_first_not_of(str.wc_str(), nStart); } -#else - { return find_first_not_of(str.mb_str(), nStart); } -#endif - // same as above - size_t find_first_not_of(const char* sz, size_t nStart = 0) const; - size_t find_first_not_of(const wchar_t* sz, size_t nStart = 0) const; - size_t find_first_not_of(const char* sz, size_t nStart, size_t n) const; - size_t find_first_not_of(const wchar_t* sz, size_t nStart, size_t n) const; - // same as above - size_t find_first_not_of(wxUniChar ch, size_t nStart = 0) const; - // as strcspn() - size_t find_last_not_of(const wxString& str, size_t nStart = npos) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_last_not_of(str.wc_str(), nStart); } -#else - { return find_last_not_of(str.mb_str(), nStart); } -#endif - // same as above - size_t find_last_not_of(const char* sz, size_t nStart = npos) const; - size_t find_last_not_of(const wchar_t* sz, size_t nStart = npos) const; - size_t find_last_not_of(const char* sz, size_t nStart, size_t n) const; - size_t find_last_not_of(const wchar_t* sz, size_t nStart, size_t n) const; - // same as above - size_t find_last_not_of(wxUniChar ch, size_t nStart = npos) const; -#endif // wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 or not - - // provide char/wchar_t/wxUniCharRef overloads for char-finding functions - // above to resolve ambiguities: - size_t find_first_of(wxUniCharRef ch, size_t nStart = 0) const - { return find_first_of(wxUniChar(ch), nStart); } - size_t find_first_of(char ch, size_t nStart = 0) const - { return find_first_of(wxUniChar(ch), nStart); } - size_t find_first_of(unsigned char ch, size_t nStart = 0) const - { return find_first_of(wxUniChar(ch), nStart); } - size_t find_first_of(wchar_t ch, size_t nStart = 0) const - { return find_first_of(wxUniChar(ch), nStart); } - size_t find_last_of(wxUniCharRef ch, size_t nStart = npos) const - { return find_last_of(wxUniChar(ch), nStart); } - size_t find_last_of(char ch, size_t nStart = npos) const - { return find_last_of(wxUniChar(ch), nStart); } - size_t find_last_of(unsigned char ch, size_t nStart = npos) const - { return find_last_of(wxUniChar(ch), nStart); } - size_t find_last_of(wchar_t ch, size_t nStart = npos) const - { return find_last_of(wxUniChar(ch), nStart); } - size_t find_first_not_of(wxUniCharRef ch, size_t nStart = 0) const - { return find_first_not_of(wxUniChar(ch), nStart); } - size_t find_first_not_of(char ch, size_t nStart = 0) const - { return find_first_not_of(wxUniChar(ch), nStart); } - size_t find_first_not_of(unsigned char ch, size_t nStart = 0) const - { return find_first_not_of(wxUniChar(ch), nStart); } - size_t find_first_not_of(wchar_t ch, size_t nStart = 0) const - { return find_first_not_of(wxUniChar(ch), nStart); } - size_t find_last_not_of(wxUniCharRef ch, size_t nStart = npos) const - { return find_last_not_of(wxUniChar(ch), nStart); } - size_t find_last_not_of(char ch, size_t nStart = npos) const - { return find_last_not_of(wxUniChar(ch), nStart); } - size_t find_last_not_of(unsigned char ch, size_t nStart = npos) const - { return find_last_not_of(wxUniChar(ch), nStart); } - size_t find_last_not_of(wchar_t ch, size_t nStart = npos) const - { return find_last_not_of(wxUniChar(ch), nStart); } - - // and additional overloads for the versions taking strings: - size_t find_first_of(const wxCStrData& sz, size_t nStart = 0) const - { return find_first_of(sz.AsString(), nStart); } - size_t find_first_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const - { return find_first_of(sz.data(), nStart); } - size_t find_first_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const - { return find_first_of(sz.data(), nStart); } - size_t find_first_of(const wxCStrData& sz, size_t nStart, size_t n) const - { return find_first_of(sz.AsWChar(), nStart, n); } - size_t find_first_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const - { return find_first_of(sz.data(), nStart, n); } - size_t find_first_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const - { return find_first_of(sz.data(), nStart, n); } - - size_t find_last_of(const wxCStrData& sz, size_t nStart = 0) const - { return find_last_of(sz.AsString(), nStart); } - size_t find_last_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const - { return find_last_of(sz.data(), nStart); } - size_t find_last_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const - { return find_last_of(sz.data(), nStart); } - size_t find_last_of(const wxCStrData& sz, size_t nStart, size_t n) const - { return find_last_of(sz.AsWChar(), nStart, n); } - size_t find_last_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const - { return find_last_of(sz.data(), nStart, n); } - size_t find_last_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const - { return find_last_of(sz.data(), nStart, n); } - - size_t find_first_not_of(const wxCStrData& sz, size_t nStart = 0) const - { return find_first_not_of(sz.AsString(), nStart); } - size_t find_first_not_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const - { return find_first_not_of(sz.data(), nStart); } - size_t find_first_not_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const - { return find_first_not_of(sz.data(), nStart); } - size_t find_first_not_of(const wxCStrData& sz, size_t nStart, size_t n) const - { return find_first_not_of(sz.AsWChar(), nStart, n); } - size_t find_first_not_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const - { return find_first_not_of(sz.data(), nStart, n); } - size_t find_first_not_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const - { return find_first_not_of(sz.data(), nStart, n); } - - size_t find_last_not_of(const wxCStrData& sz, size_t nStart = 0) const - { return find_last_not_of(sz.AsString(), nStart); } - size_t find_last_not_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const - { return find_last_not_of(sz.data(), nStart); } - size_t find_last_not_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const - { return find_last_not_of(sz.data(), nStart); } - size_t find_last_not_of(const wxCStrData& sz, size_t nStart, size_t n) const - { return find_last_not_of(sz.AsWChar(), nStart, n); } - size_t find_last_not_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const - { return find_last_not_of(sz.data(), nStart, n); } - size_t find_last_not_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const - { return find_last_not_of(sz.data(), nStart, n); } + { return (wxString&)wxStringBase::replace(first, last, first1, last1); } // string += string wxString& operator+=(const wxString& s) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl += s.m_impl; - return *this; - } + { return (wxString&)wxStringBase::operator+=(s); } // string += C string - wxString& operator+=(const char *psz) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl += ImplStr(psz); - return *this; - } - wxString& operator+=(const wchar_t *pwz) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl += ImplStr(pwz); - return *this; - } - wxString& operator+=(const wxCStrData& s) - { - wxSTRING_INVALIDATE_CACHED_LENGTH(); - - m_impl += s.AsString().m_impl; - return *this; - } - wxString& operator+=(const wxScopedCharBuffer& s) - { return append(s); } - wxString& operator+=(const wxScopedWCharBuffer& s) - { return append(s); } + wxString& operator+=(const wxChar *psz) + { return (wxString&)wxStringBase::operator+=(psz); } // string += char - wxString& operator+=(wxUniChar ch) - { - wxSTRING_UPDATE_CACHED_LENGTH(1); - -#if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) - m_impl += wxStringOperations::EncodeChar(ch); - else -#endif - m_impl += (wxStringCharType)ch; - return *this; - } - wxString& operator+=(wxUniCharRef ch) { return *this += wxUniChar(ch); } - wxString& operator+=(int ch) { return *this += wxUniChar(ch); } - wxString& operator+=(char ch) { return *this += wxUniChar(ch); } - wxString& operator+=(unsigned char ch) { return *this += wxUniChar(ch); } - wxString& operator+=(wchar_t ch) { return *this += wxUniChar(ch); } - -private: -#if !wxUSE_STL_BASED_WXSTRING - // helpers for wxStringBuffer and wxStringBufferLength - wxStringCharType *DoGetWriteBuf(size_t nLen) - { - return m_impl.DoGetWriteBuf(nLen); - } - - void DoUngetWriteBuf() - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.DoUngetWriteBuf(); - } - - void DoUngetWriteBuf(size_t nLen) - { - wxSTRING_INVALIDATE_CACHE(); - - m_impl.DoUngetWriteBuf(nLen); - } -#endif // !wxUSE_STL_BASED_WXSTRING - -#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN - #if !wxUSE_UTF8_LOCALE_ONLY - int DoPrintfWchar(const wxChar *format, ...); - static wxString DoFormatWchar(const wxChar *format, ...); - #endif - #if wxUSE_UNICODE_UTF8 - int DoPrintfUtf8(const char *format, ...); - static wxString DoFormatUtf8(const char *format, ...); - #endif -#endif - -#if !wxUSE_STL_BASED_WXSTRING - // check string's data validity - bool IsValid() const { return m_impl.GetStringData()->IsValid(); } -#endif - -private: - wxStringImpl m_impl; - - // buffers for compatibility conversion from (char*)c_str() and - // (wchar_t*)c_str(): the pointers returned by these functions should remain - // valid until the string itself is modified for compatibility with the - // existing code and consistency with std::string::c_str() so returning a - // temporary buffer won't do and we need to cache the conversion results - - // TODO-UTF8: benchmark various approaches to keeping compatibility buffers - template - struct ConvertedBuffer - { - // notice that there is no need to initialize m_len here as it's unused - // as long as m_str is NULL - ConvertedBuffer() : m_str(NULL) {} - ~ConvertedBuffer() - { free(m_str); } - - bool Extend(size_t len) - { - // add extra 1 for the trailing NUL - void * const str = realloc(m_str, sizeof(T)*(len + 1)); - if ( !str ) - return false; - - m_str = static_cast(str); - m_len = len; - - return true; - } - - const wxScopedCharTypeBuffer AsScopedBuffer() const - { - return wxScopedCharTypeBuffer::CreateNonOwned(m_str, m_len); - } - - T *m_str; // pointer to the string data - size_t m_len; // length, not size, i.e. in chars and without last NUL - }; - - -#if wxUSE_UNICODE - // common mb_str() and wxCStrData::AsChar() helper: performs the conversion - // and returns either m_convertedToChar.m_str (in which case its m_len is - // also updated) or NULL if it failed - // - // there is an important exception: in wxUSE_UNICODE_UTF8 build if conv is a - // UTF-8 one, we return m_impl.c_str() directly, without doing any conversion - // as optimization and so the caller needs to check for this before using - // m_convertedToChar - // - // NB: AsChar() returns char* in any build, unlike mb_str() - const char *AsChar(const wxMBConv& conv) const; - - // mb_str() implementation helper - wxScopedCharBuffer AsCharBuf(const wxMBConv& conv) const - { -#if wxUSE_UNICODE_UTF8 - // avoid conversion if we can - if ( conv.IsUTF8() ) - { - return wxScopedCharBuffer::CreateNonOwned(m_impl.c_str(), - m_impl.length()); - } -#endif // wxUSE_UNICODE_UTF8 - - // call this solely in order to fill in m_convertedToChar as AsChar() - // updates it as a side effect: this is a bit ugly but it's a completely - // internal function so the users of this class shouldn't care or know - // about it and doing it like this, i.e. having a separate AsChar(), - // allows us to avoid the creation and destruction of a temporary buffer - // when using wxCStrData without duplicating any code - if ( !AsChar(conv) ) - { - // although it would be probably more correct to return NULL buffer - // from here if the conversion fails, a lot of existing code doesn't - // expect mb_str() (or wc_str()) to ever return NULL so return an - // empty string otherwise to avoid crashes in it - // - // also, some existing code does check for the conversion success and - // so asserting here would be bad too -- even if it does mean that - // silently losing data is possible for badly written code - return wxScopedCharBuffer::CreateNonOwned("", 0); - } - - return m_convertedToChar.AsScopedBuffer(); - } - - ConvertedBuffer m_convertedToChar; -#endif // !wxUSE_UNICODE - -#if !wxUSE_UNICODE_WCHAR - // common wc_str() and wxCStrData::AsWChar() helper for both UTF-8 and ANSI - // builds: converts the string contents into m_convertedToWChar and returns - // NULL if the conversion failed (this can only happen in ANSI build) - // - // NB: AsWChar() returns wchar_t* in any build, unlike wc_str() - const wchar_t *AsWChar(const wxMBConv& conv) const; - - // wc_str() implementation helper - wxScopedWCharBuffer AsWCharBuf(const wxMBConv& conv) const - { - if ( !AsWChar(conv) ) - return wxScopedWCharBuffer::CreateNonOwned(L"", 0); - - return m_convertedToWChar.AsScopedBuffer(); - } - - ConvertedBuffer m_convertedToWChar; -#endif // !wxUSE_UNICODE_WCHAR - -#if wxUSE_UNICODE_UTF8 - // FIXME-UTF8: (try to) move this elsewhere (TLS) or solve differently - // assigning to character pointer to by wxString::iterator may - // change the underlying wxStringImpl iterator, so we have to - // keep track of all iterators and update them as necessary: - struct wxStringIteratorNodeHead - { - wxStringIteratorNodeHead() : ptr(NULL) {} - wxStringIteratorNode *ptr; - - // copying is disallowed as it would result in more than one pointer into - // the same linked list - wxDECLARE_NO_COPY_CLASS(wxStringIteratorNodeHead); - }; - - wxStringIteratorNodeHead m_iterators; - - friend class WXDLLIMPEXP_FWD_BASE wxStringIteratorNode; - friend class WXDLLIMPEXP_FWD_BASE wxUniCharRef; -#endif // wxUSE_UNICODE_UTF8 - - friend class WXDLLIMPEXP_FWD_BASE wxCStrData; - friend class wxStringInternalBuffer; - friend class wxStringInternalBufferLength; + wxString& operator+=(wxChar ch) + { return (wxString&)wxStringBase::operator+=(ch); } }; -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN - #pragma warning (pop) -#endif - -// string iterator operators that satisfy STL Random Access Iterator -// requirements: -inline wxString::iterator operator+(ptrdiff_t n, wxString::iterator i) - { return i + n; } -inline wxString::const_iterator operator+(ptrdiff_t n, wxString::const_iterator i) - { return i + n; } -inline wxString::reverse_iterator operator+(ptrdiff_t n, wxString::reverse_iterator i) - { return i + n; } -inline wxString::const_reverse_iterator operator+(ptrdiff_t n, wxString::const_reverse_iterator i) - { return i + n; } - // notice that even though for many compilers the friend declarations above are // enough, from the point of view of C++ standard we must have the declarations // here as friend ones are not injected in the enclosing namespace and without // them the code fails to compile with conforming compilers such as xlC or g++4 -wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2); -wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const char *psz); -wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wchar_t *pwz); -wxString WXDLLIMPEXP_BASE operator+(const char *psz, const wxString& string); -wxString WXDLLIMPEXP_BASE operator+(const wchar_t *pwz, const wxString& string); - -wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxUniChar ch); -wxString WXDLLIMPEXP_BASE operator+(wxUniChar ch, const wxString& string); - -inline wxString operator+(const wxString& string, wxUniCharRef ch) - { return string + (wxUniChar)ch; } -inline wxString operator+(const wxString& string, char ch) - { return string + wxUniChar(ch); } -inline wxString operator+(const wxString& string, wchar_t ch) - { return string + wxUniChar(ch); } -inline wxString operator+(wxUniCharRef ch, const wxString& string) - { return (wxUniChar)ch + string; } -inline wxString operator+(char ch, const wxString& string) - { return wxUniChar(ch) + string; } -inline wxString operator+(wchar_t ch, const wxString& string) - { return wxUniChar(ch) + string; } +wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2); +wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch); +wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string); +wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wxChar *psz); +wxString WXDLLIMPEXP_BASE operator+(const wxChar *psz, const wxString& string); -#define wxGetEmptyString() wxString() +// define wxArrayString, for compatibility +#if WXWIN_COMPATIBILITY_2_4 && !wxUSE_STL + #include "wx/arrstr.h" +#endif -// ---------------------------------------------------------------------------- -// helper functions which couldn't be defined inline -// ---------------------------------------------------------------------------- - -namespace wxPrivate -{ - -#if wxUSE_UNICODE_WCHAR - -template <> -struct wxStringAsBufHelper -{ - static wxScopedCharBuffer Get(const wxString& s, size_t *len) +#if wxUSE_STL + // return an empty wxString (not very useful with wxUSE_STL == 1) + inline const wxString wxGetEmptyString() { return wxString(); } +#else // !wxUSE_STL + // return an empty wxString (more efficient than wxString() here) + inline const wxString& wxGetEmptyString() { - wxScopedCharBuffer buf(s.mb_str()); - if ( len ) - *len = buf ? strlen(buf) : 0; - return buf; + return *(wxString *)&wxEmptyString; } -}; - -template <> -struct wxStringAsBufHelper -{ - static wxScopedWCharBuffer Get(const wxString& s, size_t *len) - { - const size_t length = s.length(); - if ( len ) - *len = length; - return wxScopedWCharBuffer::CreateNonOwned(s.wx_str(), length); - } -}; - -#elif wxUSE_UNICODE_UTF8 - -template <> -struct wxStringAsBufHelper -{ - static wxScopedCharBuffer Get(const wxString& s, size_t *len) - { - const size_t length = s.utf8_length(); - if ( len ) - *len = length; - return wxScopedCharBuffer::CreateNonOwned(s.wx_str(), length); - } -}; - -template <> -struct wxStringAsBufHelper -{ - static wxScopedWCharBuffer Get(const wxString& s, size_t *len) - { - wxScopedWCharBuffer wbuf(s.wc_str()); - if ( len ) - *len = wxWcslen(wbuf); - return wbuf; - } -}; - -#endif // Unicode build kind - -} // namespace wxPrivate +#endif // wxUSE_STL/!wxUSE_STL // ---------------------------------------------------------------------------- // wxStringBuffer: a tiny class allowing to get a writable pointer into string // ---------------------------------------------------------------------------- -#if !wxUSE_STL_BASED_WXSTRING -// string buffer for direct access to string data in their native -// representation: -class wxStringInternalBuffer +#if wxUSE_STL + +class WXDLLIMPEXP_BASE wxStringBuffer { public: - typedef wxStringCharType CharType; + wxStringBuffer(wxString& str, size_t lenWanted = 1024) + : m_str(str), m_buf(lenWanted) + { } - wxStringInternalBuffer(wxString& str, size_t lenWanted = 1024) - : m_str(str), m_buf(NULL) - { m_buf = m_str.DoGetWriteBuf(lenWanted); } + ~wxStringBuffer() { m_str.assign(m_buf.data(), wxStrlen(m_buf.data())); } - ~wxStringInternalBuffer() { m_str.DoUngetWriteBuf(); } - - operator wxStringCharType*() const { return m_buf; } + operator wxChar*() { return m_buf.data(); } private: - wxString& m_str; - wxStringCharType *m_buf; + wxString& m_str; +#if wxUSE_UNICODE + wxWCharBuffer m_buf; +#else + wxCharBuffer m_buf; +#endif - wxDECLARE_NO_COPY_CLASS(wxStringInternalBuffer); + DECLARE_NO_COPY_CLASS(wxStringBuffer) }; -class wxStringInternalBufferLength +class WXDLLIMPEXP_BASE wxStringBufferLength { public: - typedef wxStringCharType CharType; + wxStringBufferLength(wxString& str, size_t lenWanted = 1024) + : m_str(str), m_buf(lenWanted), m_len(0), m_lenSet(false) + { } - wxStringInternalBufferLength(wxString& str, size_t lenWanted = 1024) + ~wxStringBufferLength() + { + wxASSERT(m_lenSet); + m_str.assign(m_buf.data(), m_len); + } + + operator wxChar*() { return m_buf.data(); } + void SetLength(size_t length) { m_len = length; m_lenSet = true; } + +private: + wxString& m_str; +#if wxUSE_UNICODE + wxWCharBuffer m_buf; +#else + wxCharBuffer m_buf; +#endif + size_t m_len; + bool m_lenSet; + + DECLARE_NO_COPY_CLASS(wxStringBufferLength) +}; + +#else // if !wxUSE_STL + +class WXDLLIMPEXP_BASE wxStringBuffer +{ +public: + wxStringBuffer(wxString& str, size_t lenWanted = 1024) + : m_str(str), m_buf(NULL) + { m_buf = m_str.GetWriteBuf(lenWanted); } + + ~wxStringBuffer() { m_str.UngetWriteBuf(); } + + operator wxChar*() const { return m_buf; } + +private: + wxString& m_str; + wxChar *m_buf; + + DECLARE_NO_COPY_CLASS(wxStringBuffer) +}; + +class WXDLLIMPEXP_BASE wxStringBufferLength +{ +public: + wxStringBufferLength(wxString& str, size_t lenWanted = 1024) : m_str(str), m_buf(NULL), m_len(0), m_lenSet(false) { - m_buf = m_str.DoGetWriteBuf(lenWanted); + m_buf = m_str.GetWriteBuf(lenWanted); wxASSERT(m_buf != NULL); } - ~wxStringInternalBufferLength() + ~wxStringBufferLength() { wxASSERT(m_lenSet); - m_str.DoUngetWriteBuf(m_len); + m_str.UngetWriteBuf(m_len); } - operator wxStringCharType*() const { return m_buf; } + operator wxChar*() const { return m_buf; } void SetLength(size_t length) { m_len = length; m_lenSet = true; } private: - wxString& m_str; - wxStringCharType *m_buf; - size_t m_len; - bool m_lenSet; - - wxDECLARE_NO_COPY_CLASS(wxStringInternalBufferLength); -}; - -#endif // !wxUSE_STL_BASED_WXSTRING - -template -class wxStringTypeBufferBase -{ -public: - typedef T CharType; - - wxStringTypeBufferBase(wxString& str, size_t lenWanted = 1024) - : m_str(str), m_buf(lenWanted) - { - // for compatibility with old wxStringBuffer which provided direct - // access to wxString internal buffer, initialize ourselves with the - // string initial contents - - // FIXME-VC6: remove the ugly (CharType *)NULL and use normal - // tchar_str - size_t len; - const wxCharTypeBuffer buf(str.tchar_str(&len, (CharType *)NULL)); - if ( buf ) - { - if ( len > lenWanted ) - { - // in this case there is not enough space for terminating NUL, - // ensure that we still put it there - m_buf.data()[lenWanted] = 0; - len = lenWanted - 1; - } - - memcpy(m_buf.data(), buf, (len + 1)*sizeof(CharType)); - } - //else: conversion failed, this can happen when trying to get Unicode - // string contents into a char string - } - - operator CharType*() { return m_buf.data(); } - -protected: wxString& m_str; - wxCharTypeBuffer m_buf; + wxChar *m_buf; + size_t m_len; + bool m_lenSet; + + DECLARE_NO_COPY_CLASS(wxStringBufferLength) }; -template -class wxStringTypeBufferLengthBase : public wxStringTypeBufferBase -{ -public: - wxStringTypeBufferLengthBase(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferBase(str, lenWanted), - m_len(0), - m_lenSet(false) - { } - - ~wxStringTypeBufferLengthBase() - { - wxASSERT_MSG( this->m_lenSet, "forgot to call SetLength()" ); - } - - void SetLength(size_t length) { m_len = length; m_lenSet = true; } - -protected: - size_t m_len; - bool m_lenSet; -}; - -template -class wxStringTypeBuffer : public wxStringTypeBufferBase -{ -public: - wxStringTypeBuffer(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferBase(str, lenWanted) - { } - - ~wxStringTypeBuffer() - { - this->m_str.assign(this->m_buf.data()); - } - - wxDECLARE_NO_COPY_CLASS(wxStringTypeBuffer); -}; - -template -class wxStringTypeBufferLength : public wxStringTypeBufferLengthBase -{ -public: - wxStringTypeBufferLength(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferLengthBase(str, lenWanted) - { } - - ~wxStringTypeBufferLength() - { - this->m_str.assign(this->m_buf.data(), this->m_len); - } - - wxDECLARE_NO_COPY_CLASS(wxStringTypeBufferLength); -}; - -#if wxUSE_STL_BASED_WXSTRING - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase ) - -class wxStringInternalBuffer : public wxStringTypeBufferBase -{ -public: - wxStringInternalBuffer(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferBase(str, lenWanted) {} - ~wxStringInternalBuffer() - { m_str.m_impl.assign(m_buf.data()); } - - wxDECLARE_NO_COPY_CLASS(wxStringInternalBuffer); -}; - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( - wxStringTypeBufferLengthBase ) - -class wxStringInternalBufferLength - : public wxStringTypeBufferLengthBase -{ -public: - wxStringInternalBufferLength(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferLengthBase(str, lenWanted) {} - - ~wxStringInternalBufferLength() - { - m_str.m_impl.assign(m_buf.data(), m_len); - } - - wxDECLARE_NO_COPY_CLASS(wxStringInternalBufferLength); -}; - -#endif // wxUSE_STL_BASED_WXSTRING - - -#if wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 -typedef wxStringTypeBuffer wxStringBuffer; -typedef wxStringTypeBufferLength wxStringBufferLength; -#else // if !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 -typedef wxStringInternalBuffer wxStringBuffer; -typedef wxStringInternalBufferLength wxStringBufferLength; -#endif // !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 - -#if wxUSE_UNICODE_UTF8 -typedef wxStringInternalBuffer wxUTF8StringBuffer; -typedef wxStringInternalBufferLength wxUTF8StringBufferLength; -#elif wxUSE_UNICODE_WCHAR - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase ) - -// Note about inlined dtors in the classes below: this is done not for -// performance reasons but just to avoid linking errors in the MSVC DLL build -// under Windows: if a class has non-inline methods it must be declared as -// being DLL-exported but, due to an extremely interesting feature of MSVC 7 -// and later, any template class which is used as a base of a DLL-exported -// class is implicitly made DLL-exported too, as explained at the bottom of -// http://msdn.microsoft.com/en-us/library/twa2aw10.aspx (just to confirm: yes, -// _inheriting_ from a class can change whether it is being exported from DLL) -// -// But this results in link errors because the base template class is not DLL- -// exported, whether it is declared with WXDLLIMPEXP_BASE or not, because it -// does have only inline functions. So the simplest fix is to just make all the -// functions of these classes inline too. - -class wxUTF8StringBuffer : public wxStringTypeBufferBase -{ -public: - wxUTF8StringBuffer(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferBase(str, lenWanted) {} - ~wxUTF8StringBuffer() - { - wxMBConvStrictUTF8 conv; - size_t wlen = conv.ToWChar(NULL, 0, m_buf); - wxCHECK_RET( wlen != wxCONV_FAILED, "invalid UTF-8 data in string buffer?" ); - - wxStringInternalBuffer wbuf(m_str, wlen); - conv.ToWChar(wbuf, wlen, m_buf); - } - - wxDECLARE_NO_COPY_CLASS(wxUTF8StringBuffer); -}; - -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferLengthBase ) - -class wxUTF8StringBufferLength : public wxStringTypeBufferLengthBase -{ -public: - wxUTF8StringBufferLength(wxString& str, size_t lenWanted = 1024) - : wxStringTypeBufferLengthBase(str, lenWanted) {} - ~wxUTF8StringBufferLength() - { - wxCHECK_RET(m_lenSet, "length not set"); - - wxMBConvStrictUTF8 conv; - size_t wlen = conv.ToWChar(NULL, 0, m_buf, m_len); - wxCHECK_RET( wlen != wxCONV_FAILED, "invalid UTF-8 data in string buffer?" ); - - wxStringInternalBufferLength wbuf(m_str, wlen); - conv.ToWChar(wbuf, wlen, m_buf, m_len); - wbuf.SetLength(wlen); - } - - wxDECLARE_NO_COPY_CLASS(wxUTF8StringBufferLength); -}; -#endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR - +#endif // !wxUSE_STL // --------------------------------------------------------------------------- // wxString comparison functions: operator versions are always case sensitive // --------------------------------------------------------------------------- -#define wxCMP_WXCHAR_STRING(p, s, op) 0 op s.Cmp(p) - -wxDEFINE_ALL_COMPARISONS(const wxChar *, const wxString&, wxCMP_WXCHAR_STRING) - -#undef wxCMP_WXCHAR_STRING +// note that when wxUSE_STL == 1 the comparison operators taking std::string +// are used and defining them also for wxString would only result in +// compilation ambiguities when comparing std::string and wxString +#if !wxUSE_STL inline bool operator==(const wxString& s1, const wxString& s2) - { return s1.IsSameAs(s2); } + { return (s1.Len() == s2.Len()) && (s1.Cmp(s2) == 0); } +inline bool operator==(const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) == 0; } +inline bool operator==(const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) == 0; } inline bool operator!=(const wxString& s1, const wxString& s2) - { return !s1.IsSameAs(s2); } + { return (s1.Len() != s2.Len()) || (s1.Cmp(s2) != 0); } +inline bool operator!=(const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) != 0; } +inline bool operator!=(const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) != 0; } inline bool operator< (const wxString& s1, const wxString& s2) { return s1.Cmp(s2) < 0; } +inline bool operator< (const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) < 0; } +inline bool operator< (const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) > 0; } inline bool operator> (const wxString& s1, const wxString& s2) { return s1.Cmp(s2) > 0; } +inline bool operator> (const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) > 0; } +inline bool operator> (const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) < 0; } inline bool operator<=(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) <= 0; } +inline bool operator<=(const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) <= 0; } +inline bool operator<=(const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) >= 0; } inline bool operator>=(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) >= 0; } +inline bool operator>=(const wxString& s1, const wxChar * s2) + { return s1.Cmp(s2) >= 0; } +inline bool operator>=(const wxChar * s1, const wxString& s2) + { return s2.Cmp(s1) <= 0; } -inline bool operator==(const wxString& s1, const wxCStrData& s2) - { return s1 == s2.AsString(); } -inline bool operator==(const wxCStrData& s1, const wxString& s2) - { return s1.AsString() == s2; } -inline bool operator!=(const wxString& s1, const wxCStrData& s2) - { return s1 != s2.AsString(); } -inline bool operator!=(const wxCStrData& s1, const wxString& s2) - { return s1.AsString() != s2; } - -inline bool operator==(const wxString& s1, const wxScopedWCharBuffer& s2) - { return (s1.Cmp((const wchar_t *)s2) == 0); } -inline bool operator==(const wxScopedWCharBuffer& s1, const wxString& s2) - { return (s2.Cmp((const wchar_t *)s1) == 0); } -inline bool operator!=(const wxString& s1, const wxScopedWCharBuffer& s2) - { return (s1.Cmp((const wchar_t *)s2) != 0); } -inline bool operator!=(const wxScopedWCharBuffer& s1, const wxString& s2) - { return (s2.Cmp((const wchar_t *)s1) != 0); } - -inline bool operator==(const wxString& s1, const wxScopedCharBuffer& s2) - { return (s1.Cmp((const char *)s2) == 0); } -inline bool operator==(const wxScopedCharBuffer& s1, const wxString& s2) - { return (s2.Cmp((const char *)s1) == 0); } -inline bool operator!=(const wxString& s1, const wxScopedCharBuffer& s2) - { return (s1.Cmp((const char *)s2) != 0); } -inline bool operator!=(const wxScopedCharBuffer& s1, const wxString& s2) - { return (s2.Cmp((const char *)s1) != 0); } - -inline wxString operator+(const wxString& string, const wxScopedWCharBuffer& buf) - { return string + (const wchar_t *)buf; } -inline wxString operator+(const wxScopedWCharBuffer& buf, const wxString& string) - { return (const wchar_t *)buf + string; } - -inline wxString operator+(const wxString& string, const wxScopedCharBuffer& buf) - { return string + (const char *)buf; } -inline wxString operator+(const wxScopedCharBuffer& buf, const wxString& string) - { return (const char *)buf + string; } - -// comparison with char -inline bool operator==(const wxUniChar& c, const wxString& s) { return s.IsSameAs(c); } -inline bool operator==(const wxUniCharRef& c, const wxString& s) { return s.IsSameAs(c); } -inline bool operator==(char c, const wxString& s) { return s.IsSameAs(c); } -inline bool operator==(wchar_t c, const wxString& s) { return s.IsSameAs(c); } -inline bool operator==(int c, const wxString& s) { return s.IsSameAs(c); } -inline bool operator==(const wxString& s, const wxUniChar& c) { return s.IsSameAs(c); } -inline bool operator==(const wxString& s, const wxUniCharRef& c) { return s.IsSameAs(c); } -inline bool operator==(const wxString& s, char c) { return s.IsSameAs(c); } -inline bool operator==(const wxString& s, wchar_t c) { return s.IsSameAs(c); } -inline bool operator!=(const wxUniChar& c, const wxString& s) { return !s.IsSameAs(c); } -inline bool operator!=(const wxUniCharRef& c, const wxString& s) { return !s.IsSameAs(c); } -inline bool operator!=(char c, const wxString& s) { return !s.IsSameAs(c); } -inline bool operator!=(wchar_t c, const wxString& s) { return !s.IsSameAs(c); } -inline bool operator!=(int c, const wxString& s) { return !s.IsSameAs(c); } -inline bool operator!=(const wxString& s, const wxUniChar& c) { return !s.IsSameAs(c); } -inline bool operator!=(const wxString& s, const wxUniCharRef& c) { return !s.IsSameAs(c); } -inline bool operator!=(const wxString& s, char c) { return !s.IsSameAs(c); } -inline bool operator!=(const wxString& s, wchar_t c) { return !s.IsSameAs(c); } - - -// wxString iterators comparisons -inline bool wxString::iterator::operator==(const const_iterator& i) const - { return i == *this; } -inline bool wxString::iterator::operator!=(const const_iterator& i) const - { return i != *this; } -inline bool wxString::iterator::operator<(const const_iterator& i) const - { return i > *this; } -inline bool wxString::iterator::operator>(const const_iterator& i) const - { return i < *this; } -inline bool wxString::iterator::operator<=(const const_iterator& i) const - { return i >= *this; } -inline bool wxString::iterator::operator>=(const const_iterator& i) const - { return i <= *this; } - -// comparison with C string in Unicode build #if wxUSE_UNICODE +inline bool operator==(const wxString& s1, const wxWCharBuffer& s2) + { return (s1.Cmp((const wchar_t *)s2) == 0); } +inline bool operator==(const wxWCharBuffer& s1, const wxString& s2) + { return (s2.Cmp((const wchar_t *)s1) == 0); } +inline bool operator!=(const wxString& s1, const wxWCharBuffer& s2) + { return (s1.Cmp((const wchar_t *)s2) != 0); } +inline bool operator!=(const wxWCharBuffer& s1, const wxString& s2) + { return (s2.Cmp((const wchar_t *)s1) != 0); } +#else // !wxUSE_UNICODE +inline bool operator==(const wxString& s1, const wxCharBuffer& s2) + { return (s1.Cmp((const char *)s2) == 0); } +inline bool operator==(const wxCharBuffer& s1, const wxString& s2) + { return (s2.Cmp((const char *)s1) == 0); } +inline bool operator!=(const wxString& s1, const wxCharBuffer& s2) + { return (s1.Cmp((const char *)s2) != 0); } +inline bool operator!=(const wxCharBuffer& s1, const wxString& s2) + { return (s2.Cmp((const char *)s1) != 0); } +#endif // wxUSE_UNICODE/!wxUSE_UNICODE -#define wxCMP_CHAR_STRING(p, s, op) wxString(p) op s +#if wxUSE_UNICODE +inline wxString operator+(const wxString& string, const wxWCharBuffer& buf) + { return string + (const wchar_t *)buf; } +inline wxString operator+(const wxWCharBuffer& buf, const wxString& string) + { return (const wchar_t *)buf + string; } +#else // !wxUSE_UNICODE +inline wxString operator+(const wxString& string, const wxCharBuffer& buf) + { return string + (const char *)buf; } +inline wxString operator+(const wxCharBuffer& buf, const wxString& string) + { return (const char *)buf + string; } +#endif // wxUSE_UNICODE/!wxUSE_UNICODE -wxDEFINE_ALL_COMPARISONS(const char *, const wxString&, wxCMP_CHAR_STRING) +#endif // !wxUSE_STL -#undef wxCMP_CHAR_STRING - -#endif // wxUSE_UNICODE - -// we also need to provide the operators for comparison with wxCStrData to -// resolve ambiguity between operator(const wxChar *,const wxString &) and -// operator(const wxChar *, const wxChar *) for "p == s.c_str()" -// -// notice that these are (shallow) pointer comparisons, not (deep) string ones -#define wxCMP_CHAR_CSTRDATA(p, s, op) p op s.AsChar() -#define wxCMP_WCHAR_CSTRDATA(p, s, op) p op s.AsWChar() - -wxDEFINE_ALL_COMPARISONS(const wchar_t *, const wxCStrData&, wxCMP_WCHAR_CSTRDATA) -wxDEFINE_ALL_COMPARISONS(const char *, const wxCStrData&, wxCMP_CHAR_CSTRDATA) - -#undef wxCMP_CHAR_CSTRDATA -#undef wxCMP_WCHAR_CSTRDATA +// comparison with char (those are not defined by std::[w]string and so should +// be always available) +inline bool operator==(wxChar c, const wxString& s) { return s.IsSameAs(c); } +inline bool operator==(const wxString& s, wxChar c) { return s.IsSameAs(c); } +inline bool operator!=(wxChar c, const wxString& s) { return !s.IsSameAs(c); } +inline bool operator!=(const wxString& s, wxChar c) { return !s.IsSameAs(c); } // --------------------------------------------------------------------------- // Implementation only from here until the end of file // --------------------------------------------------------------------------- +// don't pollute the library user's name space +#undef wxASSERT_VALID_INDEX + #if wxUSE_STD_IOSTREAM #include "wx/iosfwrap.h" WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&); -WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&); -WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedCharBuffer&); -#ifndef __BORLANDC__ -WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&); -#endif -#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#endif // wxSTD_STRING_COMPATIBILITY -WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxString&); -WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&); -WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxScopedWCharBuffer&); - -#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) - -#endif // wxUSE_STD_IOSTREAM - -// --------------------------------------------------------------------------- -// wxCStrData implementation -// --------------------------------------------------------------------------- - -inline wxCStrData::wxCStrData(char *buf) - : m_str(new wxString(buf)), m_offset(0), m_owned(true) {} -inline wxCStrData::wxCStrData(wchar_t *buf) - : m_str(new wxString(buf)), m_offset(0), m_owned(true) {} - -inline wxCStrData::wxCStrData(const wxCStrData& data) - : m_str(data.m_owned ? new wxString(*data.m_str) : data.m_str), - m_offset(data.m_offset), - m_owned(data.m_owned) -{ -} - -inline wxCStrData::~wxCStrData() -{ - if ( m_owned ) - delete const_cast(m_str); // cast to silence warnings -} - -// AsChar() and AsWChar() implementations simply forward to wxString methods - -inline const wchar_t* wxCStrData::AsWChar() const -{ - const wchar_t * const p = -#if wxUSE_UNICODE_WCHAR - m_str->wc_str(); -#elif wxUSE_UNICODE_UTF8 - m_str->AsWChar(wxMBConvStrictUTF8()); -#else - m_str->AsWChar(wxConvLibc); -#endif - - // in Unicode build the string always has a valid Unicode representation - // and even if a conversion is needed (as in UTF8 case) it can't fail - // - // but in ANSI build the string contents might be not convertible to - // Unicode using the current locale encoding so we do need to check for - // errors -#if !wxUSE_UNICODE - if ( !p ) - { - // if conversion fails, return empty string and not NULL to avoid - // crashes in code written with either wxWidgets 2 wxString or - // std::string behaviour in mind: neither of them ever returns NULL - // from its c_str() and so we shouldn't neither - // - // notice that the same is done in AsChar() below and - // wxString::wc_str() and mb_str() for the same reasons - return L""; - } -#endif // !wxUSE_UNICODE - - return p + m_offset; -} - -inline const char* wxCStrData::AsChar() const -{ -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY - const char * const p = m_str->AsChar(wxConvLibc); - if ( !p ) - return ""; -#else // !wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY - const char * const p = m_str->mb_str(); -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY - - return p + m_offset; -} - -inline wxString wxCStrData::AsString() const -{ - if ( m_offset == 0 ) - return *m_str; - else - return m_str->Mid(m_offset); -} - -inline const wxStringCharType *wxCStrData::AsInternal() const -{ -#if wxUSE_UNICODE_UTF8 - return wxStringOperations::AddToIter(m_str->wx_str(), m_offset); -#else - return m_str->wx_str() + m_offset; -#endif -} - -inline wxUniChar wxCStrData::operator*() const -{ - if ( m_str->empty() ) - return wxUniChar(wxT('\0')); - else - return (*m_str)[m_offset]; -} - -inline wxUniChar wxCStrData::operator[](size_t n) const -{ - // NB: we intentionally use operator[] and not at() here because the former - // works for the terminating NUL while the latter does not - return (*m_str)[m_offset + n]; -} - -// ---------------------------------------------------------------------------- -// more wxCStrData operators -// ---------------------------------------------------------------------------- - -// we need to define those to allow "size_t pos = p - s.c_str()" where p is -// some pointer into the string -inline size_t operator-(const char *p, const wxCStrData& cs) -{ - return p - cs.AsChar(); -} - -inline size_t operator-(const wchar_t *p, const wxCStrData& cs) -{ - return p - cs.AsWChar(); -} - -// ---------------------------------------------------------------------------- -// implementation of wx[W]CharBuffer inline methods using wxCStrData -// ---------------------------------------------------------------------------- - -// FIXME-UTF8: move this to buffer.h -inline wxCharBuffer::wxCharBuffer(const wxCStrData& cstr) - : wxCharTypeBufferBase(cstr.AsCharBuf()) -{ -} - -inline wxWCharBuffer::wxWCharBuffer(const wxCStrData& cstr) - : wxCharTypeBufferBase(cstr.AsWCharBuf()) -{ -} - -#if wxUSE_UNICODE_UTF8 -// ---------------------------------------------------------------------------- -// implementation of wxStringIteratorNode inline methods -// ---------------------------------------------------------------------------- - -void wxStringIteratorNode::DoSet(const wxString *str, - wxStringImpl::const_iterator *citer, - wxStringImpl::iterator *iter) -{ - m_prev = NULL; - m_iter = iter; - m_citer = citer; - m_str = str; - if ( str ) - { - m_next = str->m_iterators.ptr; - const_cast(m_str)->m_iterators.ptr = this; - if ( m_next ) - m_next->m_prev = this; - } - else - { - m_next = NULL; - } -} - -void wxStringIteratorNode::clear() -{ - if ( m_next ) - m_next->m_prev = m_prev; - if ( m_prev ) - m_prev->m_next = m_next; - else if ( m_str ) // first in the list - const_cast(m_str)->m_iterators.ptr = m_next; - - m_next = m_prev = NULL; - m_citer = NULL; - m_iter = NULL; - m_str = NULL; -} -#endif // wxUSE_UNICODE_UTF8 - -#if WXWIN_COMPATIBILITY_2_8 - // lot of code out there doesn't explicitly include wx/crt.h, but uses - // CRT wrappers that are now declared in wx/wxcrt.h and wx/wxcrtvararg.h, - // so let's include this header now that wxString is defined and it's safe - // to do it: - #include "wx/crt.h" -#endif - -// ---------------------------------------------------------------------------- -// Checks on wxString characters -// ---------------------------------------------------------------------------- - -template - inline bool wxStringCheck(const wxString& val) - { - for ( wxString::const_iterator i = val.begin(); - i != val.end(); - ++i ) - if (T(*i) == 0) - return false; - return true; - } - -#endif // _WX_WXSTRING_H_ +#endif // _WX_WXSTRINGH__ diff --git a/Source/3rd Party/wx/include/wx/stringimpl.h b/Source/3rd Party/wx/include/wx/stringimpl.h deleted file mode 100644 index 50d4af9c6..000000000 --- a/Source/3rd Party/wx/include/wx/stringimpl.h +++ /dev/null @@ -1,564 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/stringimpl.h -// Purpose: wxStringImpl class, implementation of wxString -// Author: Vadim Zeitlin -// Modified by: -// Created: 29/01/98 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -/* - This header implements std::string-like string class, wxStringImpl, that is - used by wxString to store the data. Alternatively, if wxUSE_STD_STRING=1, - wxStringImpl is just a typedef to std:: string class. -*/ - -#ifndef _WX_WXSTRINGIMPL_H__ -#define _WX_WXSTRINGIMPL_H__ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/defs.h" // everybody should include this -#include "wx/chartype.h" // for wxChar -#include "wx/wxcrtbase.h" // for wxStrlen() etc. - -#include - -// --------------------------------------------------------------------------- -// macros -// --------------------------------------------------------------------------- - -// implementation only -#define wxASSERT_VALID_INDEX(i) \ - wxASSERT_MSG( (size_t)(i) <= length(), wxT("invalid index in wxString") ) - - -// ---------------------------------------------------------------------------- -// global data -// ---------------------------------------------------------------------------- - -// global pointer to empty string -extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString; -#if wxUSE_UNICODE_UTF8 -// FIXME-UTF8: we should have only one wxEmptyString -extern WXDLLIMPEXP_DATA_BASE(const wxStringCharType*) wxEmptyStringImpl; -#endif - - -// ---------------------------------------------------------------------------- -// deal with various build options -// ---------------------------------------------------------------------------- - -// we use STL-based string internally if we use std::string at all now, there -// should be no reason to prefer our internal implement but if you really need -// it you can predefine wxUSE_STL_BASED_WXSTRING as 0 when building the library -#ifndef wxUSE_STL_BASED_WXSTRING - #define wxUSE_STL_BASED_WXSTRING wxUSE_STD_STRING -#endif - -// in both cases we need to define wxStdString -#if wxUSE_STL_BASED_WXSTRING || wxUSE_STD_STRING - -#include "wx/beforestd.h" -#include -#include "wx/afterstd.h" - -#ifdef HAVE_STD_WSTRING - typedef std::wstring wxStdWideString; -#else - typedef std::basic_string wxStdWideString; -#endif - -#if wxUSE_UNICODE_WCHAR - typedef wxStdWideString wxStdString; -#else - typedef std::string wxStdString; -#endif - -#endif // wxUSE_STL_BASED_WXSTRING || wxUSE_STD_STRING - - -#if wxUSE_STL_BASED_WXSTRING - - // we always want ctor from std::string when using std::string internally - #undef wxUSE_STD_STRING - #define wxUSE_STD_STRING 1 - - // the versions of std::string included with gcc 2.95 and VC6 (for which - // _MSC_VER == 1200) and eVC4 (_MSC_VER == 1201) lack clear() method - #if (defined(__GNUG__) && (__GNUG__ < 3)) || \ - !wxCHECK_VISUALC_VERSION(7) || defined(__EVC4__) - #define wxSTRING_BASE_HASNT_CLEAR - #endif - - typedef wxStdString wxStringImpl; -#else // if !wxUSE_STL_BASED_WXSTRING - -// in non-STL mode, compare() is implemented in wxString and not wxStringImpl -#undef HAVE_STD_STRING_COMPARE - -// --------------------------------------------------------------------------- -// string data prepended with some housekeeping info (used by wxString class), -// is never used directly (but had to be put here to allow inlining) -// --------------------------------------------------------------------------- - -struct WXDLLIMPEXP_BASE wxStringData -{ - int nRefs; // reference count - size_t nDataLength, // actual string length - nAllocLength; // allocated memory size - - // mimics declaration 'wxStringCharType data[nAllocLength]' - wxStringCharType* data() const { return (wxStringCharType*)(this + 1); } - - // empty string has a special ref count so it's never deleted - bool IsEmpty() const { return (nRefs == -1); } - bool IsShared() const { return (nRefs > 1); } - - // lock/unlock - void Lock() { if ( !IsEmpty() ) nRefs++; } - - // VC++ will refuse to inline Unlock but profiling shows that it is wrong -#if defined(__VISUALC__) && (__VISUALC__ >= 1200) - __forceinline -#endif - // VC++ free must take place in same DLL as allocation when using non dll - // run-time library (e.g. Multithreaded instead of Multithreaded DLL) -#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) - void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); } - // we must not inline deallocation since allocation is not inlined - void Free(); -#else - void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } -#endif - - // if we had taken control over string memory (GetWriteBuf), it's - // intentionally put in invalid state - void Validate(bool b) { nRefs = (b ? 1 : 0); } - bool IsValid() const { return (nRefs != 0); } -}; - -class WXDLLIMPEXP_BASE wxStringImpl -{ -public: - // an 'invalid' value for string index, moved to this place due to a CW bug - static const size_t npos; - -protected: - // points to data preceded by wxStringData structure with ref count info - wxStringCharType *m_pchData; - - // accessor to string data - wxStringData* GetStringData() const { return (wxStringData*)m_pchData - 1; } - - // string (re)initialization functions - // initializes the string to the empty value (must be called only from - // ctors, use Reinit() otherwise) -#if wxUSE_UNICODE_UTF8 - void Init() { m_pchData = (wxStringCharType *)wxEmptyStringImpl; } // FIXME-UTF8 -#else - void Init() { m_pchData = (wxStringCharType *)wxEmptyString; } -#endif - // initializes the string with (a part of) C-string - void InitWith(const wxStringCharType *psz, size_t nPos = 0, size_t nLen = npos); - // as Init, but also frees old data - void Reinit() { GetStringData()->Unlock(); Init(); } - - // memory allocation - // allocates memory for string of length nLen - bool AllocBuffer(size_t nLen); - // effectively copies data to string - bool AssignCopy(size_t, const wxStringCharType *); - - // append a (sub)string - bool ConcatSelf(size_t nLen, const wxStringCharType *src, size_t nMaxLen); - bool ConcatSelf(size_t nLen, const wxStringCharType *src) - { return ConcatSelf(nLen, src, nLen); } - - // functions called before writing to the string: they copy it if there - // are other references to our data (should be the only owner when writing) - bool CopyBeforeWrite(); - bool AllocBeforeWrite(size_t); - - // compatibility with wxString - bool Alloc(size_t nLen); - -public: - // standard types - typedef wxStringCharType value_type; - typedef wxStringCharType char_type; - typedef size_t size_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; - - // macro to define the bulk of iterator and const_iterator classes - #define WX_DEFINE_STRINGIMPL_ITERATOR(iterator_name, ref_type, ptr_type) \ - public: \ - typedef wxStringCharType value_type; \ - typedef ref_type reference; \ - typedef ptr_type pointer; \ - typedef int difference_type; \ - \ - iterator_name() : m_ptr(NULL) { } \ - iterator_name(pointer ptr) : m_ptr(ptr) { } \ - \ - reference operator*() const { return *m_ptr; } \ - \ - iterator_name& operator++() { m_ptr++; return *this; } \ - iterator_name operator++(int) \ - { \ - const iterator_name tmp(*this); \ - m_ptr++; \ - return tmp; \ - } \ - \ - iterator_name& operator--() { m_ptr--; return *this; } \ - iterator_name operator--(int) \ - { \ - const iterator_name tmp(*this); \ - m_ptr--; \ - return tmp; \ - } \ - \ - iterator_name operator+(ptrdiff_t n) const \ - { return iterator_name(m_ptr + n); } \ - iterator_name operator-(ptrdiff_t n) const \ - { return iterator_name(m_ptr - n); } \ - iterator_name& operator+=(ptrdiff_t n) \ - { m_ptr += n; return *this; } \ - iterator_name& operator-=(ptrdiff_t n) \ - { m_ptr -= n; return *this; } \ - \ - difference_type operator-(const iterator_name& i) const \ - { return m_ptr - i.m_ptr; } \ - \ - bool operator==(const iterator_name& i) const \ - { return m_ptr == i.m_ptr; } \ - bool operator!=(const iterator_name& i) const \ - { return m_ptr != i.m_ptr; } \ - \ - bool operator<(const iterator_name& i) const \ - { return m_ptr < i.m_ptr; } \ - bool operator>(const iterator_name& i) const \ - { return m_ptr > i.m_ptr; } \ - bool operator<=(const iterator_name& i) const \ - { return m_ptr <= i.m_ptr; } \ - bool operator>=(const iterator_name& i) const \ - { return m_ptr >= i.m_ptr; } \ - \ - private: \ - /* for wxStringImpl use only */ \ - pointer GetPtr() const { return m_ptr; } \ - \ - friend class wxStringImpl; \ - \ - pointer m_ptr - - // we need to declare const_iterator in wxStringImpl scope, the friend - // declaration inside iterator class itself is not enough, or at least not - // for g++ 3.4 (g++ 4 is ok) - class WXDLLIMPEXP_FWD_BASE const_iterator; - - class WXDLLIMPEXP_BASE iterator - { - WX_DEFINE_STRINGIMPL_ITERATOR(iterator, - wxStringCharType&, - wxStringCharType*); - - friend class const_iterator; - }; - - class WXDLLIMPEXP_BASE const_iterator - { - public: - const_iterator(iterator i) : m_ptr(i.m_ptr) { } - - WX_DEFINE_STRINGIMPL_ITERATOR(const_iterator, - const wxStringCharType&, - const wxStringCharType*); - }; - - #undef WX_DEFINE_STRINGIMPL_ITERATOR - - - // constructors and destructor - // ctor for an empty string - wxStringImpl() { Init(); } - // copy ctor - wxStringImpl(const wxStringImpl& stringSrc) - { - wxASSERT_MSG( stringSrc.GetStringData()->IsValid(), - wxT("did you forget to call UngetWriteBuf()?") ); - - if ( stringSrc.empty() ) { - // nothing to do for an empty string - Init(); - } - else { - m_pchData = stringSrc.m_pchData; // share same data - GetStringData()->Lock(); // => one more copy - } - } - // string containing nRepeat copies of ch - wxStringImpl(size_type nRepeat, wxStringCharType ch); - // ctor takes first nLength characters from C string - // (default value of npos means take all the string) - wxStringImpl(const wxStringCharType *psz) - { InitWith(psz, 0, npos); } - wxStringImpl(const wxStringCharType *psz, size_t nLength) - { InitWith(psz, 0, nLength); } - // take nLen chars starting at nPos - wxStringImpl(const wxStringImpl& str, size_t nPos, size_t nLen) - { - wxASSERT_MSG( str.GetStringData()->IsValid(), - wxT("did you forget to call UngetWriteBuf()?") ); - Init(); - size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen; - InitWith(str.c_str(), nPos, nLen); - } - // take everything between start and end - wxStringImpl(const_iterator start, const_iterator end); - - - // ctor from and conversion to std::string -#if wxUSE_STD_STRING - wxStringImpl(const wxStdString& impl) - { InitWith(impl.c_str(), 0, impl.length()); } - - operator wxStdString() const - { return wxStdString(c_str(), length()); } -#endif - -#if defined(__VISUALC__) && (__VISUALC__ >= 1200) - // disable warning about Unlock() below not being inlined (first, it - // seems to be inlined nevertheless and second, even if it isn't, there - // is nothing we can do about this - #pragma warning(push) - #pragma warning (disable:4714) -#endif - - // dtor is not virtual, this class must not be inherited from! - ~wxStringImpl() - { - GetStringData()->Unlock(); - } - -#if defined(__VISUALC__) && (__VISUALC__ >= 1200) - #pragma warning(pop) -#endif - - // overloaded assignment - // from another wxString - wxStringImpl& operator=(const wxStringImpl& stringSrc); - // from a character - wxStringImpl& operator=(wxStringCharType ch); - // from a C string - wxStringImpl& operator=(const wxStringCharType *psz); - - // return the length of the string - size_type length() const { return GetStringData()->nDataLength; } - // return the length of the string - size_type size() const { return length(); } - // return the maximum size of the string - size_type max_size() const { return npos; } - // resize the string, filling the space with c if c != 0 - void resize(size_t nSize, wxStringCharType ch = '\0'); - // delete the contents of the string - void clear() { erase(0, npos); } - // returns true if the string is empty - bool empty() const { return length() == 0; } - // inform string about planned change in size - void reserve(size_t sz) { Alloc(sz); } - size_type capacity() const { return GetStringData()->nAllocLength; } - - // lib.string.access - // return the character at position n - value_type operator[](size_type n) const { return m_pchData[n]; } - value_type at(size_type n) const - { wxASSERT_VALID_INDEX( n ); return m_pchData[n]; } - // returns the writable character at position n - reference operator[](size_type n) { CopyBeforeWrite(); return m_pchData[n]; } - reference at(size_type n) - { - wxASSERT_VALID_INDEX( n ); - CopyBeforeWrite(); - return m_pchData[n]; - } // FIXME-UTF8: not useful for us...? - - // lib.string.modifiers - // append elements str[pos], ..., str[pos+n] - wxStringImpl& append(const wxStringImpl& str, size_t pos, size_t n) - { - wxASSERT(pos <= str.length()); - ConcatSelf(n, str.c_str() + pos, str.length() - pos); - return *this; - } - // append a string - wxStringImpl& append(const wxStringImpl& str) - { ConcatSelf(str.length(), str.c_str()); return *this; } - // append first n (or all if n == npos) characters of sz - wxStringImpl& append(const wxStringCharType *sz) - { ConcatSelf(wxStrlen(sz), sz); return *this; } - wxStringImpl& append(const wxStringCharType *sz, size_t n) - { ConcatSelf(n, sz); return *this; } - // append n copies of ch - wxStringImpl& append(size_t n, wxStringCharType ch); - // append from first to last - wxStringImpl& append(const_iterator first, const_iterator last) - { ConcatSelf(last - first, first.GetPtr()); return *this; } - - // same as `this_string = str' - wxStringImpl& assign(const wxStringImpl& str) - { return *this = str; } - // same as ` = str[pos..pos + n] - wxStringImpl& assign(const wxStringImpl& str, size_t pos, size_t n) - { return replace(0, npos, str, pos, n); } - // same as `= first n (or all if n == npos) characters of sz' - wxStringImpl& assign(const wxStringCharType *sz) - { return replace(0, npos, sz, wxStrlen(sz)); } - wxStringImpl& assign(const wxStringCharType *sz, size_t n) - { return replace(0, npos, sz, n); } - // same as `= n copies of ch' - wxStringImpl& assign(size_t n, wxStringCharType ch) - { return replace(0, npos, n, ch); } - // assign from first to last - wxStringImpl& assign(const_iterator first, const_iterator last) - { return replace(begin(), end(), first, last); } - - // first valid index position - const_iterator begin() const { return m_pchData; } - iterator begin(); - // position one after the last valid one - const_iterator end() const { return m_pchData + length(); } - iterator end(); - - // insert another string - wxStringImpl& insert(size_t nPos, const wxStringImpl& str) - { - wxASSERT( str.GetStringData()->IsValid() ); - return insert(nPos, str.c_str(), str.length()); - } - // insert n chars of str starting at nStart (in str) - wxStringImpl& insert(size_t nPos, const wxStringImpl& str, size_t nStart, size_t n) - { - wxASSERT( str.GetStringData()->IsValid() ); - wxASSERT( nStart < str.length() ); - size_t strLen = str.length() - nStart; - n = strLen < n ? strLen : n; - return insert(nPos, str.c_str() + nStart, n); - } - // insert first n (or all if n == npos) characters of sz - wxStringImpl& insert(size_t nPos, const wxStringCharType *sz, size_t n = npos); - // insert n copies of ch - wxStringImpl& insert(size_t nPos, size_t n, wxStringCharType ch) - { return insert(nPos, wxStringImpl(n, ch)); } - iterator insert(iterator it, wxStringCharType ch) - { size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; } - void insert(iterator it, const_iterator first, const_iterator last) - { insert(it - begin(), first.GetPtr(), last - first); } - void insert(iterator it, size_type n, wxStringCharType ch) - { insert(it - begin(), n, ch); } - - // delete characters from nStart to nStart + nLen - wxStringImpl& erase(size_type pos = 0, size_type n = npos); - iterator erase(iterator first, iterator last) - { - size_t idx = first - begin(); - erase(idx, last - first); - return begin() + idx; - } - iterator erase(iterator first); - - // explicit conversion to C string (use this with printf()!) - const wxStringCharType* c_str() const { return m_pchData; } - const wxStringCharType* data() const { return m_pchData; } - - // replaces the substring of length nLen starting at nStart - wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringCharType* sz) - { return replace(nStart, nLen, sz, npos); } - // replaces the substring of length nLen starting at nStart - wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringImpl& str) - { return replace(nStart, nLen, str.c_str(), str.length()); } - // replaces the substring with nCount copies of ch - wxStringImpl& replace(size_t nStart, size_t nLen, - size_t nCount, wxStringCharType ch) - { return replace(nStart, nLen, wxStringImpl(nCount, ch)); } - // replaces a substring with another substring - wxStringImpl& replace(size_t nStart, size_t nLen, - const wxStringImpl& str, size_t nStart2, size_t nLen2) - { return replace(nStart, nLen, str.substr(nStart2, nLen2)); } - // replaces the substring with first nCount chars of sz - wxStringImpl& replace(size_t nStart, size_t nLen, - const wxStringCharType* sz, size_t nCount); - - wxStringImpl& replace(iterator first, iterator last, const_pointer s) - { return replace(first - begin(), last - first, s); } - wxStringImpl& replace(iterator first, iterator last, const_pointer s, - size_type n) - { return replace(first - begin(), last - first, s, n); } - wxStringImpl& replace(iterator first, iterator last, const wxStringImpl& s) - { return replace(first - begin(), last - first, s); } - wxStringImpl& replace(iterator first, iterator last, size_type n, wxStringCharType c) - { return replace(first - begin(), last - first, n, c); } - wxStringImpl& replace(iterator first, iterator last, - const_iterator first1, const_iterator last1) - { return replace(first - begin(), last - first, first1.GetPtr(), last1 - first1); } - - // swap two strings - void swap(wxStringImpl& str); - - // All find() functions take the nStart argument which specifies the - // position to start the search on, the default value is 0. All functions - // return npos if there were no match. - - // find a substring - size_t find(const wxStringImpl& str, size_t nStart = 0) const; - - // find first n characters of sz - size_t find(const wxStringCharType* sz, size_t nStart = 0, size_t n = npos) const; - - // find the first occurrence of character ch after nStart - size_t find(wxStringCharType ch, size_t nStart = 0) const; - - // rfind() family is exactly like find() but works right to left - - // as find, but from the end - size_t rfind(const wxStringImpl& str, size_t nStart = npos) const; - - // as find, but from the end - size_t rfind(const wxStringCharType* sz, size_t nStart = npos, - size_t n = npos) const; - // as find, but from the end - size_t rfind(wxStringCharType ch, size_t nStart = npos) const; - - size_type copy(wxStringCharType* s, size_type n, size_type pos = 0); - - // substring extraction - wxStringImpl substr(size_t nStart = 0, size_t nLen = npos) const; - - // string += string - wxStringImpl& operator+=(const wxStringImpl& s) { return append(s); } - // string += C string - wxStringImpl& operator+=(const wxStringCharType *psz) { return append(psz); } - // string += char - wxStringImpl& operator+=(wxStringCharType ch) { return append(1, ch); } - - // helpers for wxStringBuffer and wxStringBufferLength - wxStringCharType *DoGetWriteBuf(size_t nLen); - void DoUngetWriteBuf(); - void DoUngetWriteBuf(size_t nLen); - - friend class WXDLLIMPEXP_FWD_BASE wxString; -}; - -#endif // !wxUSE_STL_BASED_WXSTRING - -// don't pollute the library user's name space -#undef wxASSERT_VALID_INDEX - -#endif // _WX_WXSTRINGIMPL_H__ diff --git a/Source/3rd Party/wx/include/wx/stringops.h b/Source/3rd Party/wx/include/wx/stringops.h deleted file mode 100644 index 21c612178..000000000 --- a/Source/3rd Party/wx/include/wx/stringops.h +++ /dev/null @@ -1,172 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/stringops.h -// Purpose: implementation of wxString primitive operations -// Author: Vaclav Slavik -// Modified by: -// Created: 2007-04-16 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WXSTRINGOPS_H__ -#define _WX_WXSTRINGOPS_H__ - -#include "wx/chartype.h" -#include "wx/stringimpl.h" -#include "wx/unichar.h" -#include "wx/buffer.h" - -// This header contains wxStringOperations "namespace" class that implements -// elementary operations on string data as static methods; wxString methods and -// iterators are implemented in terms of it. Two implementations are available, -// one for UTF-8 encoded char* string and one for "raw" wchar_t* strings (or -// char* in ANSI build). - -// FIXME-UTF8: only wchar after we remove ANSI build -#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE -struct WXDLLIMPEXP_BASE wxStringOperationsWchar -{ - // moves the iterator to the next Unicode character - template - static void IncIter(Iterator& i) { ++i; } - - // moves the iterator to the previous Unicode character - template - static void DecIter(Iterator& i) { --i; } - - // moves the iterator by n Unicode characters - template - static Iterator AddToIter(const Iterator& i, ptrdiff_t n) - { return i + n; } - - // returns distance of the two iterators in Unicode characters - template - static ptrdiff_t DiffIters(const Iterator& i1, const Iterator& i2) - { return i1 - i2; } - - // encodes the character to a form used to represent it in internal - // representation (returns a string in UTF8 version) - static wxChar EncodeChar(const wxUniChar& ch) { return (wxChar)ch; } - - static wxUniChar DecodeChar(const wxStringImpl::const_iterator& i) - { return *i; } -}; -#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE - - -#if wxUSE_UNICODE_UTF8 -struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 -{ - // checks correctness of UTF-8 sequence - static bool IsValidUtf8String(const char *c, - size_t len = wxStringImpl::npos); - static bool IsValidUtf8LeadByte(unsigned char c) - { - return (c <= 0x7F) || (c >= 0xC2 && c <= 0xF4); - } - - // table of offsets to skip forward when iterating over UTF-8 sequence - static const unsigned char ms_utf8IterTable[256]; - - - template - static void IncIter(Iterator& i) - { - wxASSERT( IsValidUtf8LeadByte(*i) ); - i += ms_utf8IterTable[(unsigned char)*i]; - } - - template - static void DecIter(Iterator& i) - { - // Non-lead bytes are all in the 0x80..0xBF range (i.e. 10xxxxxx in - // binary), so we just have to go back until we hit a byte that is - // either < 0x80 (i.e. 0xxxxxxx in binary) or 0xC0..0xFF (11xxxxxx in - // binary; this includes some invalid values, but we can ignore it - // here, because we assume valid UTF-8 input for the purpose of - // efficient implementation). - --i; - while ( ((*i) & 0xC0) == 0x80 /* 2 highest bits are '10' */ ) - --i; - } - - template - static Iterator AddToIter(const Iterator& i, ptrdiff_t n) - { - Iterator out(i); - - if ( n > 0 ) - { - for ( ptrdiff_t j = 0; j < n; ++j ) - IncIter(out); - } - else if ( n < 0 ) - { - for ( ptrdiff_t j = 0; j > n; --j ) - DecIter(out); - } - - return out; - } - - template - static ptrdiff_t DiffIters(Iterator i1, Iterator i2) - { - ptrdiff_t dist = 0; - - if ( i1 < i2 ) - { - while ( i1 != i2 ) - { - IncIter(i1); - dist--; - } - } - else if ( i2 < i1 ) - { - while ( i2 != i1 ) - { - IncIter(i2); - dist++; - } - } - - return dist; - } - - // encodes the character as UTF-8: - typedef wxUniChar::Utf8CharBuffer Utf8CharBuffer; - static Utf8CharBuffer EncodeChar(const wxUniChar& ch) - { return ch.AsUTF8(); } - - // returns n copies of ch encoded in UTF-8 string - static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch); - - // returns the length of UTF-8 encoding of the character with lead byte 'c' - static size_t GetUtf8CharLength(char c) - { - wxASSERT( IsValidUtf8LeadByte(c) ); - return ms_utf8IterTable[(unsigned char)c]; - } - - // decodes single UTF-8 character from UTF-8 string - static wxUniChar DecodeChar(wxStringImpl::const_iterator i) - { - if ( (unsigned char)*i < 0x80 ) - return (int)*i; - return DecodeNonAsciiChar(i); - } - -private: - static wxUniChar DecodeNonAsciiChar(wxStringImpl::const_iterator i); -}; -#endif // wxUSE_UNICODE_UTF8 - - -#if wxUSE_UNICODE_UTF8 -typedef wxStringOperationsUtf8 wxStringOperations; -#else -typedef wxStringOperationsWchar wxStringOperations; -#endif - -#endif // _WX_WXSTRINGOPS_H_ diff --git a/Source/3rd Party/wx/include/wx/strvararg.h b/Source/3rd Party/wx/include/wx/strvararg.h deleted file mode 100644 index b26a89f69..000000000 --- a/Source/3rd Party/wx/include/wx/strvararg.h +++ /dev/null @@ -1,1227 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/strvararg.h -// Purpose: macros for implementing type-safe vararg passing of strings -// Author: Vaclav Slavik -// Created: 2007-02-19 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_STRVARARG_H_ -#define _WX_STRVARARG_H_ - -#include "wx/platform.h" -#if wxONLY_WATCOM_EARLIER_THAN(1,4) - #error "OpenWatcom version >= 1.4 is required to compile this code" -#endif - -#include "wx/cpp.h" -#include "wx/chartype.h" -#include "wx/strconv.h" -#include "wx/buffer.h" -#include "wx/unichar.h" - -#if defined(HAVE_TYPE_TRAITS) - #include -#elif defined(HAVE_TR1_TYPE_TRAITS) - #ifdef __VISUALC__ - #include - #else - #include - #endif -#endif - -class WXDLLIMPEXP_FWD_BASE wxCStrData; -class WXDLLIMPEXP_FWD_BASE wxString; - -// ---------------------------------------------------------------------------- -// WX_DEFINE_VARARG_FUNC* macros -// ---------------------------------------------------------------------------- - -// This macro is used to implement type-safe wrappers for variadic functions -// that accept strings as arguments. This makes it possible to pass char*, -// wchar_t* or even wxString (as opposed to having to use wxString::c_str()) -// to e.g. wxPrintf(). -// -// This is done by defining a set of N template function taking 1..N arguments -// (currently, N is set to 30 in this header). These functions are just thin -// wrappers around another variadic function ('impl' or 'implUtf8' arguments, -// see below) and the only thing the wrapper does is that it normalizes the -// arguments passed in so that they are of the type expected by variadic -// functions taking string arguments, i.e., char* or wchar_t*, depending on the -// build: -// * char* in the current locale's charset in ANSI build -// * char* with UTF-8 encoding if wxUSE_UNICODE_UTF8 and the app is running -// under an UTF-8 locale -// * wchar_t* if wxUSE_UNICODE_WCHAR or if wxUSE_UNICODE_UTF8 and the current -// locale is not UTF-8 -// -// Note that wxFormatString *must* be used for the format parameter of these -// functions, otherwise the implementation won't work correctly. Furthermore, -// it must be passed by value, not reference, because it's modified by the -// vararg templates internally. -// -// Parameters: -// [ there are examples in square brackets showing values of the parameters -// for the wxFprintf() wrapper for fprintf() function with the following -// prototype: -// int wxFprintf(FILE *stream, const wxString& format, ...); ] -// -// rettype Functions' return type [int] -// name Name of the function [fprintf] -// numfixed The number of leading "fixed" (i.e., not variadic) -// arguments of the function (e.g. "stream" and "format" -// arguments of fprintf()); their type is _not_ converted -// using wxArgNormalizer, unlike the rest of -// the function's arguments [2] -// fixed List of types of the leading "fixed" arguments, in -// parenthesis [(FILE*,const wxString&)] -// impl Name of the variadic function that implements 'name' for -// the native strings representation (wchar_t* if -// wxUSE_UNICODE_WCHAR or wxUSE_UNICODE_UTF8 when running under -// non-UTF8 locale, char* in ANSI build) [wxCrt_Fprintf] -// implUtf8 Like 'impl', but for the UTF-8 char* version to be used -// if wxUSE_UNICODE_UTF8 and running under UTF-8 locale -// (ignored otherwise) [fprintf] -// -#define WX_DEFINE_VARARG_FUNC(rettype, name, numfixed, fixed, impl, implUtf8) \ - _WX_VARARG_DEFINE_FUNC_N0(rettype, name, impl, implUtf8, numfixed, fixed) \ - WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, numfixed, fixed, impl, implUtf8) - -// ditto, but without the version with 0 template/vararg arguments -#define WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, \ - numfixed, fixed, impl, implUtf8) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_DEFINE_FUNC, \ - rettype, name, impl, implUtf8, numfixed, fixed) - -// Like WX_DEFINE_VARARG_FUNC, but for variadic functions that don't return -// a value. -#define WX_DEFINE_VARARG_FUNC_VOID(name, numfixed, fixed, impl, implUtf8) \ - _WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_DEFINE_FUNC_VOID, \ - void, name, impl, implUtf8, numfixed, fixed) - -// Like WX_DEFINE_VARARG_FUNC_VOID, but instead of wrapping an implementation -// function, does nothing in defined functions' bodies. -// -// Used to implement wxLogXXX functions if wxUSE_LOG=0. -#define WX_DEFINE_VARARG_FUNC_NOP(name, numfixed, fixed) \ - _WX_VARARG_DEFINE_FUNC_NOP_N0(name, numfixed, fixed) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_DEFINE_FUNC_NOP, \ - void, name, dummy, dummy, numfixed, fixed) - -// Like WX_DEFINE_VARARG_FUNC_CTOR, but for defining template constructors -#define WX_DEFINE_VARARG_FUNC_CTOR(name, numfixed, fixed, impl, implUtf8) \ - _WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, implUtf8, numfixed, fixed) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_DEFINE_FUNC_CTOR, \ - void, name, impl, implUtf8, numfixed, fixed) - - -// ---------------------------------------------------------------------------- -// wxFormatString -// ---------------------------------------------------------------------------- - -// This class must be used for format string argument of the functions -// defined using WX_DEFINE_VARARG_FUNC_* macros. It converts the string to -// char* or wchar_t* for passing to implementation function efficiently (i.e. -// without keeping the converted string in memory for longer than necessary, -// like c_str()). It also converts format string to the correct form that -// accounts for string changes done by wxArgNormalizer<> -// -// Note that this class can _only_ be used for function arguments! -class WXDLLIMPEXP_BASE wxFormatString -{ -public: - wxFormatString(const char *str) - : m_char(wxScopedCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {} - wxFormatString(const wchar_t *str) - : m_wchar(wxScopedWCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {} - wxFormatString(const wxString& str) - : m_str(&str), m_cstr(NULL) {} - wxFormatString(const wxCStrData& str) - : m_str(NULL), m_cstr(&str) {} - wxFormatString(const wxScopedCharBuffer& str) - : m_char(str), m_str(NULL), m_cstr(NULL) {} - wxFormatString(const wxScopedWCharBuffer& str) - : m_wchar(str), m_str(NULL), m_cstr(NULL) {} - - // Possible argument types. These are or-combinable for wxASSERT_ARG_TYPE - // convenience. Some of the values are or-combined with another value, this - // expresses "supertypes" for use with wxASSERT_ARG_TYPE masks. For example, - // a char* string is also a pointer and an integer is also a char. - enum ArgumentType - { -#if wxABI_VERSION >= 30001 - Arg_Unused = 0, // not used at all; the value of 0 is chosen to - // conveniently pass wxASSERT_ARG_TYPE's check -#endif - - Arg_Char = 0x0001, // character as char %c - Arg_Pointer = 0x0002, // %p - Arg_String = 0x0004 | Arg_Pointer, // any form of string (%s and %p too) - - Arg_Int = 0x0008 | Arg_Char, // (ints can be used with %c) -#if SIZEOF_INT == SIZEOF_LONG - Arg_LongInt = Arg_Int, -#else - Arg_LongInt = 0x0010, -#endif -#if defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == SIZEOF_LONG - Arg_LongLongInt = Arg_LongInt, -#elif defined(wxLongLong_t) - Arg_LongLongInt = 0x0020, -#endif - - Arg_Double = 0x0040, - Arg_LongDouble = 0x0080, - -#if defined(wxSIZE_T_IS_UINT) - Arg_Size_t = Arg_Int, -#elif defined(wxSIZE_T_IS_ULONG) - Arg_Size_t = Arg_LongInt, -#elif defined(SIZEOF_LONG_LONG) && SIZEOF_SIZE_T == SIZEOF_LONG_LONG - Arg_Size_t = Arg_LongLongInt, -#else - Arg_Size_t = 0x0100, -#endif - - Arg_IntPtr = 0x0200, // %n -- store # of chars written - Arg_ShortIntPtr = 0x0400, - Arg_LongIntPtr = 0x0800, - - Arg_Unknown = 0x8000 // unrecognized specifier (likely error) - }; - - // returns the type of format specifier for n-th variadic argument (this is - // not necessarily n-th format specifier if positional specifiers are used); - // called by wxArgNormalizer<> specializations to get information about - // n-th variadic argument desired representation - ArgumentType GetArgumentType(unsigned n) const; - - // returns the value passed to ctor, only converted to wxString, similarly - // to other InputAsXXX() methods - wxString InputAsString() const; - -#if !wxUSE_UNICODE_WCHAR - operator const char*() const - { return const_cast(this)->AsChar(); } -private: - // InputAsChar() returns the value passed to ctor, only converted - // to char, while AsChar() takes the string returned by InputAsChar() - // and does format string conversion on it as well (and similarly for - // ..AsWChar() below) - const char* InputAsChar(); - const char* AsChar(); - wxScopedCharBuffer m_convertedChar; -#endif // !wxUSE_UNICODE_WCHAR - -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY -public: - operator const wchar_t*() const - { return const_cast(this)->AsWChar(); } -private: - const wchar_t* InputAsWChar(); - const wchar_t* AsWChar(); - wxScopedWCharBuffer m_convertedWChar; -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY - -private: - wxScopedCharBuffer m_char; - wxScopedWCharBuffer m_wchar; - - // NB: we can use a pointer here, because wxFormatString is only used - // as function argument, so it has shorter life than the string - // passed to the ctor - const wxString * const m_str; - const wxCStrData * const m_cstr; - - wxDECLARE_NO_ASSIGN_CLASS(wxFormatString); -}; - -// these two helper classes are used to find wxFormatString argument among fixed -// arguments passed to a vararg template -struct wxFormatStringArgument -{ - wxFormatStringArgument(const wxFormatString *s = NULL) : m_str(s) {} - const wxFormatString *m_str; - - // overriding this operator allows us to reuse _WX_VARARG_JOIN macro - wxFormatStringArgument operator,(const wxFormatStringArgument& a) const - { - wxASSERT_MSG( m_str == NULL || a.m_str == NULL, - "can't have two format strings in vararg function" ); - return wxFormatStringArgument(m_str ? m_str : a.m_str); - } - - operator const wxFormatString*() const { return m_str; } -}; - -template -struct wxFormatStringArgumentFinder -{ - static wxFormatStringArgument find(T) - { - // by default, arguments are not format strings, so return "not found" - return wxFormatStringArgument(); - } -}; - -template<> -struct wxFormatStringArgumentFinder -{ - static wxFormatStringArgument find(const wxFormatString& arg) - { return wxFormatStringArgument(&arg); } -}; - -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - -// avoid passing big objects by value to wxFormatStringArgumentFinder::find() -// (and especially wx[W]CharBuffer with its auto_ptr<> style semantics!): -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - -template<> -struct wxFormatStringArgumentFinder - : public wxFormatStringArgumentFinder {}; - - -// ---------------------------------------------------------------------------- -// wxArgNormalizer* converters -// ---------------------------------------------------------------------------- - -#if wxDEBUG_LEVEL - // Check that the format specifier for index-th argument in 'fmt' has - // the correct type (one of wxFormatString::Arg_XXX or-combination in - // 'expected_mask'). - #define wxASSERT_ARG_TYPE(fmt, index, expected_mask) \ - wxSTATEMENT_MACRO_BEGIN \ - if ( !fmt ) \ - break; \ - const int argtype = fmt->GetArgumentType(index); \ - wxASSERT_MSG( (argtype & (expected_mask)) == argtype, \ - "format specifier doesn't match argument type" ); \ - wxSTATEMENT_MACRO_END -#else - // Just define it to suppress "unused parameter" warnings for the - // parameters which we don't use otherwise - #define wxASSERT_ARG_TYPE(fmt, index, expected_mask) \ - wxUnusedVar(fmt); \ - wxUnusedVar(index) -#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL - - -#if defined(HAVE_TYPE_TRAITS) || defined(HAVE_TR1_TYPE_TRAITS) - -// Note: this type is misnamed, so that the error message is easier to -// understand (no error happens for enums, because the IsEnum=true case is -// specialized). -template -struct wxFormatStringSpecifierNonPodType {}; - -template<> -struct wxFormatStringSpecifierNonPodType -{ - enum { value = wxFormatString::Arg_Int }; -}; - -template -struct wxFormatStringSpecifier -{ -#ifdef HAVE_TYPE_TRAITS - typedef std::is_enum is_enum; -#elif defined HAVE_TR1_TYPE_TRAITS - typedef std::tr1::is_enum is_enum; -#endif - enum { value = wxFormatStringSpecifierNonPodType::value }; -}; - -#else // !HAVE_(TR1_)TYPE_TRAITS - -template -struct wxFormatStringSpecifier -{ - // We can't detect enums without is_enum, so the only thing we can - // do is to accept unknown types. However, the only acceptable unknown - // types still are enums, which are promoted to ints, so return Arg_Int - // here. This will at least catch passing of non-POD types through ... at - // runtime. - // - // Furthermore, if the compiler doesn't have partial template - // specialization, we didn't cover pointers either. -#ifdef HAVE_PARTIAL_SPECIALIZATION - enum { value = wxFormatString::Arg_Int }; -#else - enum { value = wxFormatString::Arg_Int | wxFormatString::Arg_Pointer }; -#endif -}; - -#endif // HAVE_TR1_TYPE_TRAITS/!HAVE_TR1_TYPE_TRAITS - - -#ifdef HAVE_PARTIAL_SPECIALIZATION -template -struct wxFormatStringSpecifier -{ - enum { value = wxFormatString::Arg_Pointer }; -}; - -template -struct wxFormatStringSpecifier -{ - enum { value = wxFormatString::Arg_Pointer }; -}; -#endif // !HAVE_PARTIAL_SPECIALIZATION - - -#define wxFORMAT_STRING_SPECIFIER(T, arg) \ - template<> struct wxFormatStringSpecifier \ - { \ - enum { value = arg }; \ - }; - -wxFORMAT_STRING_SPECIFIER(bool, wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(int, wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(unsigned int, wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(short int, wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(short unsigned int, wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(long int, wxFormatString::Arg_LongInt) -wxFORMAT_STRING_SPECIFIER(long unsigned int, wxFormatString::Arg_LongInt) -#ifdef wxLongLong_t -wxFORMAT_STRING_SPECIFIER(wxLongLong_t, wxFormatString::Arg_LongLongInt) -wxFORMAT_STRING_SPECIFIER(wxULongLong_t, wxFormatString::Arg_LongLongInt) -#endif -wxFORMAT_STRING_SPECIFIER(float, wxFormatString::Arg_Double) -wxFORMAT_STRING_SPECIFIER(double, wxFormatString::Arg_Double) -wxFORMAT_STRING_SPECIFIER(long double, wxFormatString::Arg_LongDouble) - -#if wxWCHAR_T_IS_REAL_TYPE -wxFORMAT_STRING_SPECIFIER(wchar_t, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -#endif - -#if !wxUSE_UNICODE -wxFORMAT_STRING_SPECIFIER(char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(signed char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(unsigned char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -#endif - -wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(signed char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(const char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(const unsigned char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(const signed char*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(wchar_t*, wxFormatString::Arg_String) -wxFORMAT_STRING_SPECIFIER(const wchar_t*, wxFormatString::Arg_String) - -wxFORMAT_STRING_SPECIFIER(int*, wxFormatString::Arg_IntPtr | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(short int*, wxFormatString::Arg_ShortIntPtr | wxFormatString::Arg_Pointer) -wxFORMAT_STRING_SPECIFIER(long int*, wxFormatString::Arg_LongIntPtr | wxFormatString::Arg_Pointer) - -#undef wxFORMAT_STRING_SPECIFIER - - -// Converts an argument passed to wxPrint etc. into standard form expected, -// by wxXXX functions, e.g. all strings (wxString, char*, wchar_t*) are -// converted into wchar_t* or char* depending on the build. -template -struct wxArgNormalizer -{ - // Ctor. 'value' is the value passed as variadic argument, 'fmt' is pointer - // to printf-like format string or NULL if the variadic function doesn't - // use format string and 'index' is index of 'value' in variadic arguments - // list (starting at 1) - wxArgNormalizer(T value, - const wxFormatString *fmt, unsigned index) - : m_value(value) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatStringSpecifier::value ); - } - - // Returns the value in a form that can be safely passed to real vararg - // functions. In case of strings, this is char* in ANSI build and wchar_t* - // in Unicode build. - T get() const { return m_value; } - - T m_value; -}; - -// normalizer for passing arguments to functions working with wchar_t* (and -// until ANSI build is removed, char* in ANSI build as well - FIXME-UTF8) -// string representation -#if !wxUSE_UTF8_LOCALE_ONLY -template -struct wxArgNormalizerWchar : public wxArgNormalizer -{ - wxArgNormalizerWchar(T value, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizer(value, fmt, index) {} -}; -#endif // !wxUSE_UTF8_LOCALE_ONLY - -// normalizer for passing arguments to functions working with UTF-8 encoded -// char* strings -#if wxUSE_UNICODE_UTF8 - template - struct wxArgNormalizerUtf8 : public wxArgNormalizer - { - wxArgNormalizerUtf8(T value, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizer(value, fmt, index) {} - }; - - #define wxArgNormalizerNative wxArgNormalizerUtf8 -#else // wxUSE_UNICODE_WCHAR - #define wxArgNormalizerNative wxArgNormalizerWchar -#endif // wxUSE_UNICODE_UTF8 // wxUSE_UNICODE_UTF8 - - - -// special cases for converting strings: - - -// base class for wxArgNormalizer specializations that need to do conversion; -// CharType is either wxStringCharType or wchar_t in UTF-8 build when wrapping -// widechar CRT function -template -struct wxArgNormalizerWithBuffer -{ - typedef wxScopedCharTypeBuffer CharBuffer; - - wxArgNormalizerWithBuffer() {} - wxArgNormalizerWithBuffer(const CharBuffer& buf, - const wxFormatString *fmt, - unsigned index) - : m_value(buf) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); - } - - const CharType *get() const { return m_value; } - - CharBuffer m_value; -}; - -// string objects: -template<> -struct WXDLLIMPEXP_BASE wxArgNormalizerNative -{ - wxArgNormalizerNative(const wxString& s, - const wxFormatString *fmt, - unsigned index) - : m_value(s) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); - } - - const wxStringCharType *get() const; - - const wxString& m_value; -}; - -// c_str() values: -template<> -struct WXDLLIMPEXP_BASE wxArgNormalizerNative -{ - wxArgNormalizerNative(const wxCStrData& value, - const wxFormatString *fmt, - unsigned index) - : m_value(value) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); - } - - const wxStringCharType *get() const; - - const wxCStrData& m_value; -}; - -// wxString/wxCStrData conversion to wchar_t* value -#if wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY -template<> -struct WXDLLIMPEXP_BASE wxArgNormalizerWchar - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerWchar(const wxString& s, - const wxFormatString *fmt, unsigned index); -}; - -template<> -struct WXDLLIMPEXP_BASE wxArgNormalizerWchar - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerWchar(const wxCStrData& s, - const wxFormatString *fmt, unsigned index); -}; -#endif // wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY - - -// C string pointers of the wrong type (wchar_t* for ANSI or UTF8 build, -// char* for wchar_t Unicode build or UTF8): -#if wxUSE_UNICODE_WCHAR - -template<> -struct wxArgNormalizerWchar - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerWchar(const char* s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(wxConvLibc.cMB2WC(s), fmt, index) {} -}; - -#elif wxUSE_UNICODE_UTF8 - -template<> -struct wxArgNormalizerUtf8 - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerUtf8(const wchar_t* s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(wxConvUTF8.cWC2MB(s), fmt, index) {} -}; - -template<> -struct wxArgNormalizerUtf8 - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerUtf8(const char* s, - const wxFormatString *fmt, - unsigned index) - { - wxASSERT_ARG_TYPE( fmt, index, wxFormatString::Arg_String ); - - if ( wxLocaleIsUtf8 ) - { - m_value = wxScopedCharBuffer::CreateNonOwned(s); - } - else - { - // convert to widechar string first: - wxScopedWCharBuffer buf(wxConvLibc.cMB2WC(s)); - - // then to UTF-8: - if ( buf ) - m_value = wxConvUTF8.cWC2MB(buf); - } - } -}; - -// UTF-8 build needs conversion to wchar_t* too: -#if !wxUSE_UTF8_LOCALE_ONLY -template<> -struct wxArgNormalizerWchar - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerWchar(const char* s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(wxConvLibc.cMB2WC(s), fmt, index) {} -}; -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#else // ANSI - FIXME-UTF8 - -template<> -struct wxArgNormalizerWchar - : public wxArgNormalizerWithBuffer -{ - wxArgNormalizerWchar(const wchar_t* s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(wxConvLibc.cWC2MB(s), fmt, index) {} -}; - -#endif // wxUSE_UNICODE_WCHAR/wxUSE_UNICODE_UTF8/ANSI - - -// this macro is used to implement specialization that are exactly same as -// some other specialization, i.e. to "forward" the implementation (e.g. for -// T=wxString and T=const wxString&). Note that the ctor takes BaseT argument, -// not T! -#if wxUSE_UNICODE_UTF8 - #if wxUSE_UTF8_LOCALE_ONLY - #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \ - _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerUtf8, T, BaseT) - #else // possibly non-UTF8 locales - #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \ - _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerWchar, T, BaseT); \ - _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerUtf8, T, BaseT) - #endif -#else // wxUSE_UNICODE_WCHAR - #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \ - _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerWchar, T, BaseT) -#endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR - -#define _WX_ARG_NORMALIZER_FORWARD_IMPL(Normalizer, T, BaseT) \ - template<> \ - struct Normalizer : public Normalizer \ - { \ - Normalizer(BaseT value, \ - const wxFormatString *fmt, unsigned index) \ - : Normalizer(value, fmt, index) {} \ - } - -// non-reference versions of specializations for string objects -WX_ARG_NORMALIZER_FORWARD(wxString, const wxString&); -WX_ARG_NORMALIZER_FORWARD(wxCStrData, const wxCStrData&); - -// versions for passing non-const pointers: -WX_ARG_NORMALIZER_FORWARD(char*, const char*); -WX_ARG_NORMALIZER_FORWARD(wchar_t*, const wchar_t*); - -// versions for passing wx[W]CharBuffer: -WX_ARG_NORMALIZER_FORWARD(wxScopedCharBuffer, const char*); -WX_ARG_NORMALIZER_FORWARD(const wxScopedCharBuffer&, const char*); -WX_ARG_NORMALIZER_FORWARD(wxScopedWCharBuffer, const wchar_t*); -WX_ARG_NORMALIZER_FORWARD(const wxScopedWCharBuffer&, const wchar_t*); -WX_ARG_NORMALIZER_FORWARD(wxCharBuffer, const char*); -WX_ARG_NORMALIZER_FORWARD(const wxCharBuffer&, const char*); -WX_ARG_NORMALIZER_FORWARD(wxWCharBuffer, const wchar_t*); -WX_ARG_NORMALIZER_FORWARD(const wxWCharBuffer&, const wchar_t*); - -// versions for std::[w]string: -#if wxUSE_STD_STRING - -#include "wx/stringimpl.h" - -#if !wxUSE_UTF8_LOCALE_ONLY -template<> -struct wxArgNormalizerWchar - : public wxArgNormalizerWchar -{ - wxArgNormalizerWchar(const std::string& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWchar(s.c_str(), fmt, index) {} -}; - -template<> -struct wxArgNormalizerWchar - : public wxArgNormalizerWchar -{ - wxArgNormalizerWchar(const wxStdWideString& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWchar(s.c_str(), fmt, index) {} -}; -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -template<> -struct wxArgNormalizerUtf8 - : public wxArgNormalizerUtf8 -{ - wxArgNormalizerUtf8(const std::string& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerUtf8(s.c_str(), fmt, index) {} -}; - -template<> -struct wxArgNormalizerUtf8 - : public wxArgNormalizerUtf8 -{ - wxArgNormalizerUtf8(const wxStdWideString& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerUtf8(s.c_str(), fmt, index) {} -}; -#endif // wxUSE_UNICODE_UTF8 - -WX_ARG_NORMALIZER_FORWARD(std::string, const std::string&); -WX_ARG_NORMALIZER_FORWARD(wxStdWideString, const wxStdWideString&); - -#endif // wxUSE_STD_STRING - - -// versions for wxUniChar, wxUniCharRef: -// (this is same for UTF-8 and Wchar builds, we just convert to wchar_t) -template<> -struct wxArgNormalizer : public wxArgNormalizer -{ - wxArgNormalizer(const wxUniChar& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizer(wx_truncate_cast(wchar_t, s.GetValue()), fmt, index) {} -}; - -// for wchar_t, default handler does the right thing - -// char has to be treated differently in Unicode builds: a char argument may -// be used either for a character value (which should be converted into -// wxUniChar) or as an integer value (which should be left as-is). We take -// advantage of the fact that both char and wchar_t are converted into int -// in variadic arguments here. -#if wxUSE_UNICODE -template -struct wxArgNormalizerNarrowChar -{ - wxArgNormalizerNarrowChar(T value, - const wxFormatString *fmt, unsigned index) - { - wxASSERT_ARG_TYPE( fmt, index, - wxFormatString::Arg_Char | wxFormatString::Arg_Int ); - - // FIXME-UTF8: which one is better default in absence of fmt string - // (i.e. when used like e.g. Foo("foo", "bar", 'c', NULL)? - if ( !fmt || fmt->GetArgumentType(index) == wxFormatString::Arg_Char ) - m_value = wx_truncate_cast(T, wxUniChar(value).GetValue()); - else - m_value = value; - } - - int get() const { return m_value; } - - T m_value; -}; - -template<> -struct wxArgNormalizer : public wxArgNormalizerNarrowChar -{ - wxArgNormalizer(char value, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerNarrowChar(value, fmt, index) {} -}; - -template<> -struct wxArgNormalizer - : public wxArgNormalizerNarrowChar -{ - wxArgNormalizer(unsigned char value, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerNarrowChar(value, fmt, index) {} -}; - -template<> -struct wxArgNormalizer - : public wxArgNormalizerNarrowChar -{ - wxArgNormalizer(signed char value, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerNarrowChar(value, fmt, index) {} -}; - -#endif // wxUSE_UNICODE - -// convert references: -WX_ARG_NORMALIZER_FORWARD(wxUniChar, const wxUniChar&); -WX_ARG_NORMALIZER_FORWARD(const wxUniCharRef&, const wxUniChar&); -WX_ARG_NORMALIZER_FORWARD(wxUniCharRef, const wxUniChar&); -WX_ARG_NORMALIZER_FORWARD(const wchar_t&, wchar_t); - -WX_ARG_NORMALIZER_FORWARD(const char&, char); -WX_ARG_NORMALIZER_FORWARD(const unsigned char&, unsigned char); -WX_ARG_NORMALIZER_FORWARD(const signed char&, signed char); - - -#undef WX_ARG_NORMALIZER_FORWARD -#undef _WX_ARG_NORMALIZER_FORWARD_IMPL - -// NB: Don't #undef wxASSERT_ARG_TYPE here as it's also used in wx/longlong.h. - -// ---------------------------------------------------------------------------- -// WX_VA_ARG_STRING -// ---------------------------------------------------------------------------- - -// Replacement for va_arg() for use with strings in functions that accept -// strings normalized by wxArgNormalizer: - -struct WXDLLIMPEXP_BASE wxArgNormalizedString -{ - wxArgNormalizedString(const void* ptr) : m_ptr(ptr) {} - - // returns true if non-NULL string was passed in - bool IsValid() const { return m_ptr != NULL; } - operator bool() const { return IsValid(); } - - // extracts the string, returns empty string if NULL was passed in - wxString GetString() const; - operator wxString() const; - -private: - const void *m_ptr; -}; - -#define WX_VA_ARG_STRING(ap) wxArgNormalizedString(va_arg(ap, const void*)) - -// ---------------------------------------------------------------------------- -// implementation of the WX_DEFINE_VARARG_* macros -// ---------------------------------------------------------------------------- - -// NB: The vararg emulation code is limited to 30 variadic and 4 fixed -// arguments at the moment. -// If you need more variadic arguments, you need to -// 1) increase the value of _WX_VARARG_MAX_ARGS -// 2) add _WX_VARARG_JOIN_* and _WX_VARARG_ITER_* up to the new -// _WX_VARARG_MAX_ARGS value to the lists below -// If you need more fixed arguments, you need to -// 1) increase the value of _WX_VARARG_MAX_FIXED_ARGS -// 2) add _WX_VARARG_FIXED_EXPAND_* and _WX_VARARG_FIXED_UNUSED_EXPAND_* -// macros below -#define _WX_VARARG_MAX_ARGS 30 -#define _WX_VARARG_MAX_FIXED_ARGS 4 - -#define _WX_VARARG_JOIN_1(m) m(1) -#define _WX_VARARG_JOIN_2(m) _WX_VARARG_JOIN_1(m), m(2) -#define _WX_VARARG_JOIN_3(m) _WX_VARARG_JOIN_2(m), m(3) -#define _WX_VARARG_JOIN_4(m) _WX_VARARG_JOIN_3(m), m(4) -#define _WX_VARARG_JOIN_5(m) _WX_VARARG_JOIN_4(m), m(5) -#define _WX_VARARG_JOIN_6(m) _WX_VARARG_JOIN_5(m), m(6) -#define _WX_VARARG_JOIN_7(m) _WX_VARARG_JOIN_6(m), m(7) -#define _WX_VARARG_JOIN_8(m) _WX_VARARG_JOIN_7(m), m(8) -#define _WX_VARARG_JOIN_9(m) _WX_VARARG_JOIN_8(m), m(9) -#define _WX_VARARG_JOIN_10(m) _WX_VARARG_JOIN_9(m), m(10) -#define _WX_VARARG_JOIN_11(m) _WX_VARARG_JOIN_10(m), m(11) -#define _WX_VARARG_JOIN_12(m) _WX_VARARG_JOIN_11(m), m(12) -#define _WX_VARARG_JOIN_13(m) _WX_VARARG_JOIN_12(m), m(13) -#define _WX_VARARG_JOIN_14(m) _WX_VARARG_JOIN_13(m), m(14) -#define _WX_VARARG_JOIN_15(m) _WX_VARARG_JOIN_14(m), m(15) -#define _WX_VARARG_JOIN_16(m) _WX_VARARG_JOIN_15(m), m(16) -#define _WX_VARARG_JOIN_17(m) _WX_VARARG_JOIN_16(m), m(17) -#define _WX_VARARG_JOIN_18(m) _WX_VARARG_JOIN_17(m), m(18) -#define _WX_VARARG_JOIN_19(m) _WX_VARARG_JOIN_18(m), m(19) -#define _WX_VARARG_JOIN_20(m) _WX_VARARG_JOIN_19(m), m(20) -#define _WX_VARARG_JOIN_21(m) _WX_VARARG_JOIN_20(m), m(21) -#define _WX_VARARG_JOIN_22(m) _WX_VARARG_JOIN_21(m), m(22) -#define _WX_VARARG_JOIN_23(m) _WX_VARARG_JOIN_22(m), m(23) -#define _WX_VARARG_JOIN_24(m) _WX_VARARG_JOIN_23(m), m(24) -#define _WX_VARARG_JOIN_25(m) _WX_VARARG_JOIN_24(m), m(25) -#define _WX_VARARG_JOIN_26(m) _WX_VARARG_JOIN_25(m), m(26) -#define _WX_VARARG_JOIN_27(m) _WX_VARARG_JOIN_26(m), m(27) -#define _WX_VARARG_JOIN_28(m) _WX_VARARG_JOIN_27(m), m(28) -#define _WX_VARARG_JOIN_29(m) _WX_VARARG_JOIN_28(m), m(29) -#define _WX_VARARG_JOIN_30(m) _WX_VARARG_JOIN_29(m), m(30) - -#define _WX_VARARG_ITER_1(m,a,b,c,d,e,f) m(1,a,b,c,d,e,f) -#define _WX_VARARG_ITER_2(m,a,b,c,d,e,f) _WX_VARARG_ITER_1(m,a,b,c,d,e,f) m(2,a,b,c,d,e,f) -#define _WX_VARARG_ITER_3(m,a,b,c,d,e,f) _WX_VARARG_ITER_2(m,a,b,c,d,e,f) m(3,a,b,c,d,e,f) -#define _WX_VARARG_ITER_4(m,a,b,c,d,e,f) _WX_VARARG_ITER_3(m,a,b,c,d,e,f) m(4,a,b,c,d,e,f) -#define _WX_VARARG_ITER_5(m,a,b,c,d,e,f) _WX_VARARG_ITER_4(m,a,b,c,d,e,f) m(5,a,b,c,d,e,f) -#define _WX_VARARG_ITER_6(m,a,b,c,d,e,f) _WX_VARARG_ITER_5(m,a,b,c,d,e,f) m(6,a,b,c,d,e,f) -#define _WX_VARARG_ITER_7(m,a,b,c,d,e,f) _WX_VARARG_ITER_6(m,a,b,c,d,e,f) m(7,a,b,c,d,e,f) -#define _WX_VARARG_ITER_8(m,a,b,c,d,e,f) _WX_VARARG_ITER_7(m,a,b,c,d,e,f) m(8,a,b,c,d,e,f) -#define _WX_VARARG_ITER_9(m,a,b,c,d,e,f) _WX_VARARG_ITER_8(m,a,b,c,d,e,f) m(9,a,b,c,d,e,f) -#define _WX_VARARG_ITER_10(m,a,b,c,d,e,f) _WX_VARARG_ITER_9(m,a,b,c,d,e,f) m(10,a,b,c,d,e,f) -#define _WX_VARARG_ITER_11(m,a,b,c,d,e,f) _WX_VARARG_ITER_10(m,a,b,c,d,e,f) m(11,a,b,c,d,e,f) -#define _WX_VARARG_ITER_12(m,a,b,c,d,e,f) _WX_VARARG_ITER_11(m,a,b,c,d,e,f) m(12,a,b,c,d,e,f) -#define _WX_VARARG_ITER_13(m,a,b,c,d,e,f) _WX_VARARG_ITER_12(m,a,b,c,d,e,f) m(13,a,b,c,d,e,f) -#define _WX_VARARG_ITER_14(m,a,b,c,d,e,f) _WX_VARARG_ITER_13(m,a,b,c,d,e,f) m(14,a,b,c,d,e,f) -#define _WX_VARARG_ITER_15(m,a,b,c,d,e,f) _WX_VARARG_ITER_14(m,a,b,c,d,e,f) m(15,a,b,c,d,e,f) -#define _WX_VARARG_ITER_16(m,a,b,c,d,e,f) _WX_VARARG_ITER_15(m,a,b,c,d,e,f) m(16,a,b,c,d,e,f) -#define _WX_VARARG_ITER_17(m,a,b,c,d,e,f) _WX_VARARG_ITER_16(m,a,b,c,d,e,f) m(17,a,b,c,d,e,f) -#define _WX_VARARG_ITER_18(m,a,b,c,d,e,f) _WX_VARARG_ITER_17(m,a,b,c,d,e,f) m(18,a,b,c,d,e,f) -#define _WX_VARARG_ITER_19(m,a,b,c,d,e,f) _WX_VARARG_ITER_18(m,a,b,c,d,e,f) m(19,a,b,c,d,e,f) -#define _WX_VARARG_ITER_20(m,a,b,c,d,e,f) _WX_VARARG_ITER_19(m,a,b,c,d,e,f) m(20,a,b,c,d,e,f) -#define _WX_VARARG_ITER_21(m,a,b,c,d,e,f) _WX_VARARG_ITER_20(m,a,b,c,d,e,f) m(21,a,b,c,d,e,f) -#define _WX_VARARG_ITER_22(m,a,b,c,d,e,f) _WX_VARARG_ITER_21(m,a,b,c,d,e,f) m(22,a,b,c,d,e,f) -#define _WX_VARARG_ITER_23(m,a,b,c,d,e,f) _WX_VARARG_ITER_22(m,a,b,c,d,e,f) m(23,a,b,c,d,e,f) -#define _WX_VARARG_ITER_24(m,a,b,c,d,e,f) _WX_VARARG_ITER_23(m,a,b,c,d,e,f) m(24,a,b,c,d,e,f) -#define _WX_VARARG_ITER_25(m,a,b,c,d,e,f) _WX_VARARG_ITER_24(m,a,b,c,d,e,f) m(25,a,b,c,d,e,f) -#define _WX_VARARG_ITER_26(m,a,b,c,d,e,f) _WX_VARARG_ITER_25(m,a,b,c,d,e,f) m(26,a,b,c,d,e,f) -#define _WX_VARARG_ITER_27(m,a,b,c,d,e,f) _WX_VARARG_ITER_26(m,a,b,c,d,e,f) m(27,a,b,c,d,e,f) -#define _WX_VARARG_ITER_28(m,a,b,c,d,e,f) _WX_VARARG_ITER_27(m,a,b,c,d,e,f) m(28,a,b,c,d,e,f) -#define _WX_VARARG_ITER_29(m,a,b,c,d,e,f) _WX_VARARG_ITER_28(m,a,b,c,d,e,f) m(29,a,b,c,d,e,f) -#define _WX_VARARG_ITER_30(m,a,b,c,d,e,f) _WX_VARARG_ITER_29(m,a,b,c,d,e,f) m(30,a,b,c,d,e,f) - - -#define _WX_VARARG_FIXED_EXPAND_1(t1) \ - t1 f1 -#define _WX_VARARG_FIXED_EXPAND_2(t1,t2) \ - t1 f1, t2 f2 -#define _WX_VARARG_FIXED_EXPAND_3(t1,t2,t3) \ - t1 f1, t2 f2, t3 f3 -#define _WX_VARARG_FIXED_EXPAND_4(t1,t2,t3,t4) \ - t1 f1, t2 f2, t3 f3, t4 f4 - -#define _WX_VARARG_FIXED_UNUSED_EXPAND_1(t1) \ - t1 WXUNUSED(f1) -#define _WX_VARARG_FIXED_UNUSED_EXPAND_2(t1,t2) \ - t1 WXUNUSED(f1), t2 WXUNUSED(f2) -#define _WX_VARARG_FIXED_UNUSED_EXPAND_3(t1,t2,t3) \ - t1 WXUNUSED(f1), t2 WXUNUSED(f2), t3 WXUNUSED(f3) -#define _WX_VARARG_FIXED_UNUSED_EXPAND_4(t1,t2,t3,t4) \ - t1 WXUNUSED(f1), t2 WXUNUSED(f2), t3 WXUNUSED(f3), t4 WXUNUSED(f4) - -#define _WX_VARARG_FIXED_TYPEDEFS_1(t1) \ - typedef t1 TF1 -#define _WX_VARARG_FIXED_TYPEDEFS_2(t1,t2) \ - _WX_VARARG_FIXED_TYPEDEFS_1(t1); typedef t2 TF2 -#define _WX_VARARG_FIXED_TYPEDEFS_3(t1,t2,t3) \ - _WX_VARARG_FIXED_TYPEDEFS_2(t1,t2); typedef t3 TF3 -#define _WX_VARARG_FIXED_TYPEDEFS_4(t1,t2,t3,t4) \ - _WX_VARARG_FIXED_TYPEDEFS_3(t1,t2,t3); typedef t4 TF4 - -// This macro expands N-items tuple of fixed arguments types into part of -// function's declaration. For example, -// "_WX_VARARG_FIXED_EXPAND(3, (int, char*, int))" expands into -// "int f1, char* f2, int f3". -#define _WX_VARARG_FIXED_EXPAND(N, args) \ - _WX_VARARG_FIXED_EXPAND_IMPL(N, args) -#define _WX_VARARG_FIXED_EXPAND_IMPL(N, args) \ - _WX_VARARG_FIXED_EXPAND_##N args - -// Ditto for unused arguments -#define _WX_VARARG_FIXED_UNUSED_EXPAND(N, args) \ - _WX_VARARG_FIXED_UNUSED_EXPAND_IMPL(N, args) -#define _WX_VARARG_FIXED_UNUSED_EXPAND_IMPL(N, args) \ - _WX_VARARG_FIXED_UNUSED_EXPAND_##N args - -// Declarates typedefs for fixed arguments types; i-th fixed argument types -// will have TFi typedef. -#define _WX_VARARG_FIXED_TYPEDEFS(N, args) \ - _WX_VARARG_FIXED_TYPEDEFS_IMPL(N, args) -#define _WX_VARARG_FIXED_TYPEDEFS_IMPL(N, args) \ - _WX_VARARG_FIXED_TYPEDEFS_##N args - - -// This macro calls another macro 'm' passed as second argument 'N' times, -// with its only argument set to 1..N, and concatenates the results using -// comma as separator. -// -// An example: -// #define foo(i) x##i -// // this expands to "x1,x2,x3,x4" -// _WX_VARARG_JOIN(4, foo) -// -// -// N must not be greater than _WX_VARARG_MAX_ARGS (=30). -#define _WX_VARARG_JOIN(N, m) _WX_VARARG_JOIN_IMPL(N, m) -#define _WX_VARARG_JOIN_IMPL(N, m) _WX_VARARG_JOIN_##N(m) - - -// This macro calls another macro 'm' passed as second argument 'N' times, with -// its first argument set to 1..N and the remaining arguments set to 'a', 'b', -// 'c', 'd', 'e' and 'f'. The results are separated with whitespace in the -// expansion. -// -// An example: -// // this macro expands to: -// // foo(1,a,b,c,d,e,f) -// // foo(2,a,b,c,d,e,f) -// // foo(3,a,b,c,d,e,f) -// _WX_VARARG_ITER(3, foo, a, b, c, d, e, f) -// -// N must not be greater than _WX_VARARG_MAX_ARGS (=30). -#define _WX_VARARG_ITER(N,m,a,b,c,d,e,f) \ - _WX_VARARG_ITER_IMPL(N,m,a,b,c,d,e,f) -#define _WX_VARARG_ITER_IMPL(N,m,a,b,c,d,e,f) \ - _WX_VARARG_ITER_##N(m,a,b,c,d,e,f) - -// Generates code snippet for i-th "variadic" argument in vararg function's -// prototype: -#define _WX_VARARG_ARG(i) T##i a##i - -// Like _WX_VARARG_ARG_UNUSED, but outputs argument's type with WXUNUSED: -#define _WX_VARARG_ARG_UNUSED(i) T##i WXUNUSED(a##i) - -// Generates code snippet for i-th type in vararg function's template<...>: -#define _WX_VARARG_TEMPL(i) typename T##i - -// Generates code snippet for passing i-th argument of vararg function -// wrapper to its implementation, normalizing it in the process: -#define _WX_VARARG_PASS_WCHAR(i) \ - wxArgNormalizerWchar(a##i, fmt, i).get() -#define _WX_VARARG_PASS_UTF8(i) \ - wxArgNormalizerUtf8(a##i, fmt, i).get() - - -// And the same for fixed arguments, _not_ normalizing it: -#define _WX_VARARG_PASS_FIXED(i) f##i - -#define _WX_VARARG_FIND_FMT(i) \ - (wxFormatStringArgumentFinder::find(f##i)) - -#define _WX_VARARG_FORMAT_STRING(numfixed, fixed) \ - _WX_VARARG_FIXED_TYPEDEFS(numfixed, fixed); \ - const wxFormatString *fmt = \ - (_WX_VARARG_JOIN(numfixed, _WX_VARARG_FIND_FMT)) - -#if wxUSE_UNICODE_UTF8 - #define _WX_VARARG_DO_CALL_UTF8(return_kw, impl, implUtf8, N, numfixed) \ - return_kw implUtf8(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED), \ - _WX_VARARG_JOIN(N, _WX_VARARG_PASS_UTF8)) - #define _WX_VARARG_DO_CALL0_UTF8(return_kw, impl, implUtf8, numfixed) \ - return_kw implUtf8(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED)) -#endif // wxUSE_UNICODE_UTF8 - -#define _WX_VARARG_DO_CALL_WCHAR(return_kw, impl, implUtf8, N, numfixed) \ - return_kw impl(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED), \ - _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR)) -#define _WX_VARARG_DO_CALL0_WCHAR(return_kw, impl, implUtf8, numfixed) \ - return_kw impl(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED)) - -#if wxUSE_UNICODE_UTF8 - #if wxUSE_UTF8_LOCALE_ONLY - #define _WX_VARARG_DO_CALL _WX_VARARG_DO_CALL_UTF8 - #define _WX_VARARG_DO_CALL0 _WX_VARARG_DO_CALL0_UTF8 - #else // possibly non-UTF8 locales - #define _WX_VARARG_DO_CALL(return_kw, impl, implUtf8, N, numfixed) \ - if ( wxLocaleIsUtf8 ) \ - _WX_VARARG_DO_CALL_UTF8(return_kw, impl, implUtf8, N, numfixed);\ - else \ - _WX_VARARG_DO_CALL_WCHAR(return_kw, impl, implUtf8, N, numfixed) - - #define _WX_VARARG_DO_CALL0(return_kw, impl, implUtf8, numfixed) \ - if ( wxLocaleIsUtf8 ) \ - _WX_VARARG_DO_CALL0_UTF8(return_kw, impl, implUtf8, numfixed); \ - else \ - _WX_VARARG_DO_CALL0_WCHAR(return_kw, impl, implUtf8, numfixed) - #endif // wxUSE_UTF8_LOCALE_ONLY or not -#else // wxUSE_UNICODE_WCHAR or ANSI - #define _WX_VARARG_DO_CALL _WX_VARARG_DO_CALL_WCHAR - #define _WX_VARARG_DO_CALL0 _WX_VARARG_DO_CALL0_WCHAR -#endif // wxUSE_UNICODE_UTF8 / wxUSE_UNICODE_WCHAR - - -// Macro to be used with _WX_VARARG_ITER in the implementation of -// WX_DEFINE_VARARG_FUNC (see its documentation for the meaning of arguments) -#define _WX_VARARG_DEFINE_FUNC(N, rettype, name, \ - impl, implUtf8, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - _WX_VARARG_FORMAT_STRING(numfixed, fixed); \ - _WX_VARARG_DO_CALL(return, impl, implUtf8, N, numfixed); \ - } - -#define _WX_VARARG_DEFINE_FUNC_N0(rettype, name, \ - impl, implUtf8, numfixed, fixed) \ - inline rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \ - { \ - _WX_VARARG_DO_CALL0(return, impl, implUtf8, numfixed); \ - } - -// Macro to be used with _WX_VARARG_ITER in the implementation of -// WX_DEFINE_VARARG_FUNC_VOID (see its documentation for the meaning of -// arguments; rettype is ignored and is used only to satisfy _WX_VARARG_ITER's -// requirements). -#define _WX_VARARG_DEFINE_FUNC_VOID(N, rettype, name, \ - impl, implUtf8, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - void name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - _WX_VARARG_FORMAT_STRING(numfixed, fixed); \ - _WX_VARARG_DO_CALL(wxEMPTY_PARAMETER_VALUE, \ - impl, implUtf8, N, numfixed); \ - } - -#define _WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \ - inline void name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \ - { \ - _WX_VARARG_DO_CALL0(wxEMPTY_PARAMETER_VALUE, \ - impl, implUtf8, numfixed); \ - } - -// Macro to be used with _WX_VARARG_ITER in the implementation of -// WX_DEFINE_VARARG_FUNC_CTOR (see its documentation for the meaning of -// arguments; rettype is ignored and is used only to satisfy _WX_VARARG_ITER's -// requirements). -#define _WX_VARARG_DEFINE_FUNC_CTOR(N, rettype, name, \ - impl, implUtf8, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - _WX_VARARG_FORMAT_STRING(numfixed, fixed); \ - _WX_VARARG_DO_CALL(wxEMPTY_PARAMETER_VALUE, \ - impl, implUtf8, N, numfixed); \ - } - -#define _WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, implUtf8, numfixed, fixed) \ - inline name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \ - { \ - _WX_VARARG_DO_CALL0(wxEMPTY_PARAMETER_VALUE, \ - impl, implUtf8, numfixed); \ - } - -// Macro to be used with _WX_VARARG_ITER in the implementation of -// WX_DEFINE_VARARG_FUNC_NOP, i.e. empty stub for a disabled vararg function. -// The rettype and impl arguments are ignored. -#define _WX_VARARG_DEFINE_FUNC_NOP(N, rettype, name, \ - impl, implUtf8, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG_UNUSED)) \ - {} - -#define _WX_VARARG_DEFINE_FUNC_NOP_N0(name, numfixed, fixed) \ - inline void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed)) \ - {} - - -// ---------------------------------------------------------------------------- -// workaround for OpenWatcom bug #351 -// ---------------------------------------------------------------------------- - -#ifdef __WATCOMC__ -// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - -// This macro can be used to forward a 'vararg' template to another one with -// different fixed arguments types. Parameters are same as for -// WX_DEFINE_VARARG_FUNC (rettype=void can be used here), 'convfixed' is how -// to convert fixed arguments. For example, this is typical code for dealing -// with different forms of format string: -// -// WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&), -// DoPrintfWchar, DoPrintfUtf8) -// #ifdef __WATCOMC__ -// WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&), -// (wxFormatString(f1))) -// WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*), -// (wxFormatString(f1))) -// ... -#define WX_VARARG_WATCOM_WORKAROUND(rettype, name, numfixed, fixed, convfixed)\ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_WATCOM_WORKAROUND, \ - rettype, name, convfixed, dummy, numfixed, fixed) - -#define WX_VARARG_WATCOM_WORKAROUND_CTOR(name, numfixed, fixed, convfixed) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_VARARG_WATCOM_WORKAROUND_CTOR, \ - dummy, name, convfixed, dummy, numfixed, fixed) - -#define _WX_VARARG_WATCOM_UNPACK_1(a1) a1 -#define _WX_VARARG_WATCOM_UNPACK_2(a1, a2) a1, a2 -#define _WX_VARARG_WATCOM_UNPACK_3(a1, a2, a3) a1, a2, a3 -#define _WX_VARARG_WATCOM_UNPACK_4(a1, a2, a3, a4) a1, a2, a3, a4 -#define _WX_VARARG_WATCOM_UNPACK(N, convfixed) \ - _WX_VARARG_WATCOM_UNPACK_##N convfixed - -#define _WX_VARARG_PASS_WATCOM(i) a##i - -#define _WX_VARARG_WATCOM_WORKAROUND(N, rettype, name, \ - convfixed, dummy, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - return name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WATCOM)); \ - } - -#define _WX_VARARG_WATCOM_WORKAROUND_CTOR(N, dummy1, name, \ - convfixed, dummy2, numfixed, fixed) \ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WATCOM)); \ - } - -#endif // __WATCOMC__ - -#endif // _WX_STRVARARG_H_ diff --git a/Source/3rd Party/wx/include/wx/sysopt.h b/Source/3rd Party/wx/include/wx/sysopt.h index 33796a3f7..5c79a5478 100644 --- a/Source/3rd Party/wx/include/wx/sysopt.h +++ b/Source/3rd Party/wx/include/wx/sysopt.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/sysopt.h +// Name: sysopt.h // Purpose: wxSystemOptions // Author: Julian Smart // Modified by: // Created: 2001-07-10 +// RCS-ID: $Id: sysopt.h 33004 2005-03-23 20:48:50Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,11 +18,7 @@ // Enables an application to influence the wxWidgets implementation // ---------------------------------------------------------------------------- -class -#if wxUSE_SYSTEM_OPTIONS -WXDLLIMPEXP_BASE -#endif -wxSystemOptions : public wxObject +class WXDLLIMPEXP_BASE wxSystemOptions : public wxObject { public: wxSystemOptions() { } diff --git a/Source/3rd Party/wx/include/wx/tarstrm.h b/Source/3rd Party/wx/include/wx/tarstrm.h index 472194b57..c18400225 100644 --- a/Source/3rd Party/wx/include/wx/tarstrm.h +++ b/Source/3rd Party/wx/include/wx/tarstrm.h @@ -2,6 +2,7 @@ // Name: wx/tarstrm.h // Purpose: Streams for Tar files // Author: Mike Wetherell +// RCS-ID: $Id: tarstrm.h 43887 2006-12-09 22:28:11Z MW $ // Copyright: (c) 2004 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,8 +22,7 @@ // Constants // TypeFlag values -enum wxTarType -{ +enum { wxTAR_REGTYPE = '0', // regular file wxTAR_LNKTYPE = '1', // hard link wxTAR_SYMTYPE = '2', // symbolic link @@ -199,7 +199,7 @@ private: wxTarHeaderRecords *m_HeaderRecs; wxTarHeaderRecords *m_GlobalHeaderRecs; - wxDECLARE_NO_COPY_CLASS(wxTarInputStream); + DECLARE_NO_COPY_CLASS(wxTarInputStream) }; @@ -280,9 +280,8 @@ private: char *m_extendedHdr; size_t m_extendedSize; wxString m_badfit; - bool m_endrecWritten; - wxDECLARE_NO_COPY_CLASS(wxTarOutputStream); + DECLARE_NO_COPY_CLASS(wxTarOutputStream) }; diff --git a/Source/3rd Party/wx/include/wx/taskbar.h b/Source/3rd Party/wx/include/wx/taskbar.h deleted file mode 100644 index 4a81088b0..000000000 --- a/Source/3rd Party/wx/include/wx/taskbar.h +++ /dev/null @@ -1,154 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/taskbar.h -// Purpose: wxTaskBarIcon base header and class -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TASKBAR_H_BASE_ -#define _WX_TASKBAR_H_BASE_ - -#include "wx/defs.h" - -#if wxUSE_TASKBARICON - -#include "wx/event.h" - -class WXDLLIMPEXP_FWD_ADV wxTaskBarIconEvent; - -// ---------------------------------------------------------------------------- - -// type of taskbar item to create. Only applicable in wxOSX_COCOA -enum wxTaskBarIconType -{ - wxTBI_DOCK, - wxTBI_CUSTOM_STATUSITEM, -#if defined(wxOSX_USE_COCOA) && wxOSX_USE_COCOA - wxTBI_DEFAULT_TYPE = wxTBI_CUSTOM_STATUSITEM -#else - wxTBI_DEFAULT_TYPE = wxTBI_DOCK -#endif -}; - - -// ---------------------------------------------------------------------------- -// wxTaskBarIconBase: define wxTaskBarIcon interface -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxTaskBarIconBase : public wxEvtHandler -{ -public: - wxTaskBarIconBase() { } - -#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) - static bool IsAvailable(); -#else - static bool IsAvailable() { return true; } -#endif - - // Operations: - virtual bool SetIcon(const wxIcon& icon, - const wxString& tooltip = wxEmptyString) = 0; - virtual bool RemoveIcon() = 0; - virtual bool PopupMenu(wxMenu *menu) = 0; - - // delayed destruction (similarly to wxWindow::Destroy()) - void Destroy(); - -protected: - // creates menu to be displayed when user clicks on the icon - virtual wxMenu *CreatePopupMenu() { return NULL; } - -private: - // default events handling, calls CreatePopupMenu: - void OnRightButtonDown(wxTaskBarIconEvent& event); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTaskBarIconBase); -}; - - -// ---------------------------------------------------------------------------- -// now include the actual class declaration -// ---------------------------------------------------------------------------- - -#if defined(__WXMSW__) - #include "wx/msw/taskbar.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/taskbar.h" -#elif defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) - #include "wx/unix/taskbarx11.h" -#elif defined (__WXMAC__) - #include "wx/osx/taskbarosx.h" -#elif defined (__WXCOCOA__) - #include "wx/cocoa/taskbar.h" -#endif - -// ---------------------------------------------------------------------------- -// wxTaskBarIcon events -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxTaskBarIconEvent : public wxEvent -{ -public: - wxTaskBarIconEvent(wxEventType evtType, wxTaskBarIcon *tbIcon) - : wxEvent(wxID_ANY, evtType) - { - SetEventObject(tbIcon); - } - - virtual wxEvent *Clone() const { return new wxTaskBarIconEvent(*this); } - -private: - wxDECLARE_NO_ASSIGN_CLASS(wxTaskBarIconEvent); -}; - -typedef void (wxEvtHandler::*wxTaskBarIconEventFunction)(wxTaskBarIconEvent&); - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_MOVE, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_UP, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_DOWN, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_UP, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_DCLICK, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_DCLICK, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_BALLOON_TIMEOUT, wxTaskBarIconEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_BALLOON_CLICK, wxTaskBarIconEvent ); - -#define wxTaskBarIconEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxTaskBarIconEventFunction, func) - -#define wx__DECLARE_TASKBAREVT(evt, fn) \ - wx__DECLARE_EVT0(wxEVT_TASKBAR_ ## evt, wxTaskBarIconEventHandler(fn)) - -#define EVT_TASKBAR_MOVE(fn) wx__DECLARE_TASKBAREVT(MOVE, fn) -#define EVT_TASKBAR_LEFT_DOWN(fn) wx__DECLARE_TASKBAREVT(LEFT_DOWN, fn) -#define EVT_TASKBAR_LEFT_UP(fn) wx__DECLARE_TASKBAREVT(LEFT_UP, fn) -#define EVT_TASKBAR_RIGHT_DOWN(fn) wx__DECLARE_TASKBAREVT(RIGHT_DOWN, fn) -#define EVT_TASKBAR_RIGHT_UP(fn) wx__DECLARE_TASKBAREVT(RIGHT_UP, fn) -#define EVT_TASKBAR_LEFT_DCLICK(fn) wx__DECLARE_TASKBAREVT(LEFT_DCLICK, fn) -#define EVT_TASKBAR_RIGHT_DCLICK(fn) wx__DECLARE_TASKBAREVT(RIGHT_DCLICK, fn) - -// taskbar menu is shown on right button press under all platforms except MSW -// where it's shown on right button release, using this event type and macro -// allows to write code which works correctly on all platforms -#ifdef __WXMSW__ - #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_UP -#else - #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_DOWN -#endif -#define EVT_TASKBAR_CLICK(fn) wx__DECLARE_TASKBAREVT(CLICK, fn) - -// these events are currently generated only under wxMSW and only after (MSW- -// specific) ShowBalloon() had been called, don't use them in portable code -#define EVT_TASKBAR_BALLOON_TIMEOUT(fn) \ - wx__DECLARE_TASKBAREVT(BALLOON_TIMEOUT, fn) -#define EVT_TASKBAR_BALLOON_CLICK(fn) \ - wx__DECLARE_TASKBAREVT(BALLOON_CLICK, fn) - -#endif // wxUSE_TASKBARICON - -#endif // _WX_TASKBAR_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/tbarbase.h b/Source/3rd Party/wx/include/wx/tbarbase.h index f0443559b..1c0814955 100644 --- a/Source/3rd Party/wx/include/wx/tbarbase.h +++ b/Source/3rd Party/wx/include/wx/tbarbase.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: tbarbase.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,9 +32,9 @@ class WXDLLIMPEXP_FWD_CORE wxImage; // constants // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[]; -extern WXDLLIMPEXP_DATA_CORE(const wxSize) wxDefaultSize; -extern WXDLLIMPEXP_DATA_CORE(const wxPoint) wxDefaultPosition; +extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[]; +extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize; +extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition; enum wxToolBarToolStyle { @@ -53,54 +54,58 @@ enum wxToolBarToolStyle // for the applications status bar. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxToolBarToolBase : public wxObject +class WXDLLEXPORT wxToolBarToolBase : public wxObject { public: // ctors & dtor // ------------ - // generic ctor for any kind of tool - wxToolBarToolBase(wxToolBarBase *tbar = NULL, + wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, int toolid = wxID_SEPARATOR, const wxString& label = wxEmptyString, const wxBitmap& bmpNormal = wxNullBitmap, const wxBitmap& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, - wxObject *clientData = NULL, + wxObject *clientData = (wxObject *) NULL, const wxString& shortHelpString = wxEmptyString, const wxString& longHelpString = wxEmptyString) : m_label(label), m_shortHelpString(shortHelpString), m_longHelpString(longHelpString) { - Init - ( - tbar, - toolid == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR - : wxTOOL_STYLE_BUTTON, - toolid == wxID_ANY ? wxWindow::NewControlId() - : toolid, - kind - ); - + m_tbar = tbar; + m_id = toolid; + if (m_id == wxID_ANY) + m_id = wxNewId(); m_clientData = clientData; m_bmpNormal = bmpNormal; m_bmpDisabled = bmpDisabled; + + m_kind = kind; + + m_enabled = true; + m_toggled = false; + + m_toolStyle = toolid == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR + : wxTOOL_STYLE_BUTTON; } - // ctor for controls only - wxToolBarToolBase(wxToolBarBase *tbar, - wxControl *control, - const wxString& label) - : m_label(label) + wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control) { - Init(tbar, wxTOOL_STYLE_CONTROL, control->GetId(), wxITEM_MAX); - + m_tbar = tbar; m_control = control; + m_id = control->GetId(); + + m_kind = wxITEM_MAX; // invalid value + + m_enabled = true; + m_toggled = false; + + m_toolStyle = wxTOOL_STYLE_CONTROL; } - virtual ~wxToolBarToolBase(); + virtual ~wxToolBarToolBase(){} // accessors // --------- @@ -117,12 +122,10 @@ public: wxToolBarBase *GetToolBar() const { return m_tbar; } - // style/kind - bool IsStretchable() const { return m_stretchable; } + // style bool IsButton() const { return m_toolStyle == wxTOOL_STYLE_BUTTON; } bool IsControl() const { return m_toolStyle == wxTOOL_STYLE_CONTROL; } bool IsSeparator() const { return m_toolStyle == wxTOOL_STYLE_SEPARATOR; } - bool IsStretchableSpace() const { return IsSeparator() && IsStretchable(); } int GetStyle() const { return m_toolStyle; } wxItemKind GetKind() const { @@ -131,13 +134,6 @@ public: return m_kind; } - void MakeStretchable() - { - wxASSERT_MSG( IsSeparator(), "only separators can be stretchable" ); - - m_stretchable = true; - } - // state bool IsEnabled() const { return m_enabled; } bool IsToggled() const { return m_toggled; } @@ -169,16 +165,16 @@ public: } // modifiers: return true if the state really changed - virtual bool Enable(bool enable); - virtual bool Toggle(bool toggle); - virtual bool SetToggle(bool toggle); - virtual bool SetShortHelp(const wxString& help); - virtual bool SetLongHelp(const wxString& help); + bool Enable(bool enable); + bool Toggle(bool toggle); + bool SetToggle(bool toggle); + bool SetShortHelp(const wxString& help); + bool SetLongHelp(const wxString& help); void Toggle() { Toggle(!IsToggled()); } - virtual void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; } - virtual void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; } + void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; } + void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; } virtual void SetLabel(const wxString& label) { m_label = label; } @@ -195,45 +191,15 @@ public: } // add tool to/remove it from a toolbar - virtual void Detach() { m_tbar = NULL; } + virtual void Detach() { m_tbar = (wxToolBarBase *)NULL; } virtual void Attach(wxToolBarBase *tbar) { m_tbar = tbar; } -#if wxUSE_MENUS - // these methods are only for tools of wxITEM_DROPDOWN kind (but even such - // tools can have a NULL associated menu) - virtual void SetDropdownMenu(wxMenu *menu); - wxMenu *GetDropdownMenu() const { return m_dropdownMenu; } -#endif - protected: - // common part of all ctors - void Init(wxToolBarBase *tbar, - wxToolBarToolStyle style, - int toolid, - wxItemKind kind) - { - m_tbar = tbar; - m_toolStyle = style; - m_id = toolid; - m_kind = kind; - - m_clientData = NULL; - - m_stretchable = false; - m_toggled = false; - m_enabled = true; - -#if wxUSE_MENUS - m_dropdownMenu = NULL; -#endif - - } - wxToolBarBase *m_tbar; // the toolbar to which we belong (may be NULL) // tool parameters - wxToolBarToolStyle m_toolStyle; - wxWindowIDRef m_id; // the tool id, wxID_SEPARATOR for separator + int m_toolStyle; // see enum wxToolBarToolStyle + int m_id; // the tool id, wxID_SEPARATOR for separator wxItemKind m_kind; // for normal buttons may be wxITEM_NORMAL/CHECK/RADIO // as controls have their own client data, no need to waste memory @@ -243,9 +209,6 @@ protected: wxControl *m_control; }; - // true if this tool is stretchable: currently is only value for separators - bool m_stretchable; - // tool state bool m_toggled; bool m_enabled; @@ -261,10 +224,6 @@ protected: wxString m_shortHelpString; wxString m_longHelpString; -#if wxUSE_MENUS - wxMenu *m_dropdownMenu; -#endif - DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolBarToolBase) }; @@ -275,7 +234,7 @@ WX_DECLARE_EXPORTED_LIST(wxToolBarToolBase, wxToolBarToolsList); // the base class for all toolbars // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxToolBarBase : public wxControl +class WXDLLEXPORT wxToolBarBase : public wxControl { public: wxToolBarBase(); @@ -357,17 +316,13 @@ public: virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool); virtual wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool); - // add an arbitrary control to the toolbar (notice that the control will be - // deleted by the toolbar and that it will also adjust its position/size) + // add an arbitrary control to the toolbar (notice that + // the control will be deleted by the toolbar and that it will also adjust + // its position/size) // - // the label is optional and, if specified, will be shown near the control // NB: the control should have toolbar as its parent - virtual wxToolBarToolBase * - AddControl(wxControl *control, const wxString& label = wxEmptyString); - - virtual wxToolBarToolBase * - InsertControl(size_t pos, wxControl *control, - const wxString& label = wxEmptyString); + virtual wxToolBarToolBase *AddControl(wxControl *control); + virtual wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); // get the control with the given id or return NULL virtual wxControl *FindControl( int toolid ); @@ -376,12 +331,6 @@ public: virtual wxToolBarToolBase *AddSeparator(); virtual wxToolBarToolBase *InsertSeparator(size_t pos); - // add a stretchable space to the toolbar: this is similar to a separator - // except that it's always blank and that all the extra space the toolbar - // has is [equally] distributed among the stretchable spaces in it - virtual wxToolBarToolBase *AddStretchableSpace(); - virtual wxToolBarToolBase *InsertStretchableSpace(size_t pos); - // remove the tool from the toolbar: the caller is responsible for actually // deleting the pointer virtual wxToolBarToolBase *RemoveTool(int toolid); @@ -395,9 +344,6 @@ public: // must be called after all buttons have been created to finish toolbar // initialisation - // - // derived class versions should call the base one first, before doing - // platform-specific stuff virtual bool Realize(); // tools state @@ -426,12 +372,6 @@ public: virtual void SetToolLongHelp(int toolid, const wxString& helpString); virtual wxString GetToolLongHelp(int toolid) const; - virtual void SetToolNormalBitmap(int WXUNUSED(id), - const wxBitmap& WXUNUSED(bitmap)) {} - virtual void SetToolDisabledBitmap(int WXUNUSED(id), - const wxBitmap& WXUNUSED(bitmap)) {} - - // margins/packing/separation // -------------------------- @@ -472,7 +412,7 @@ public: { return GetToolBitmapSize(); } // returns a (non separator) tool containing the point (x, y) or NULL if - // there is no tool at this point (coordinates are client) + // there is no tool at this point (corrdinates are client) virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const = 0; @@ -480,17 +420,13 @@ public: wxToolBarToolBase *FindById(int toolid) const; // return true if this is a vertical toolbar, otherwise false - bool IsVertical() const; + bool IsVertical() const { return HasFlag(wxTB_LEFT | wxTB_RIGHT); } - // these methods allow to access tools by their index in the toolbar - size_t GetToolsCount() const { return m_tools.GetCount(); } - const wxToolBarToolBase *GetToolByPos(int pos) const { return m_tools[pos]; } -#if WXWIN_COMPATIBILITY_2_8 // the old versions of the various methods kept for compatibility // don't use in the new code! // -------------------------------------------------------------- - wxDEPRECATED_INLINE( + wxToolBarToolBase *AddTool(int toolid, const wxBitmap& bitmap, const wxBitmap& bmpDisabled, @@ -498,23 +434,23 @@ public: wxObject *clientData = NULL, const wxString& shortHelpString = wxEmptyString, const wxString& longHelpString = wxEmptyString) - , + { return AddTool(toolid, wxEmptyString, bitmap, bmpDisabled, toggle ? wxITEM_CHECK : wxITEM_NORMAL, shortHelpString, longHelpString, clientData); - ) - wxDEPRECATED_INLINE( + } + wxToolBarToolBase *AddTool(int toolid, const wxBitmap& bitmap, const wxString& shortHelpString = wxEmptyString, const wxString& longHelpString = wxEmptyString) - , + { return AddTool(toolid, wxEmptyString, bitmap, wxNullBitmap, wxITEM_NORMAL, shortHelpString, longHelpString, NULL); - ) - wxDEPRECATED_INLINE( + } + wxToolBarToolBase *AddTool(int toolid, const wxBitmap& bitmap, const wxBitmap& bmpDisabled, @@ -524,12 +460,12 @@ public: wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString) - , + { return DoAddTool(toolid, wxEmptyString, bitmap, bmpDisabled, toggle ? wxITEM_CHECK : wxITEM_NORMAL, shortHelp, longHelp, clientData, xPos, yPos); - ) - wxDEPRECATED_INLINE( + } + wxToolBarToolBase *InsertTool(size_t pos, int toolid, const wxBitmap& bitmap, @@ -538,12 +474,11 @@ public: wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString) - , + { return InsertTool(pos, toolid, wxEmptyString, bitmap, bmpDisabled, toggle ? wxITEM_CHECK : wxITEM_NORMAL, shortHelp, longHelp, clientData); - ) -#endif // WXWIN_COMPATIBILITY_2_8 + } // event handlers // -------------- @@ -566,51 +501,18 @@ public: // use GetToolMargins() instead wxSize GetMargins() const { return GetToolMargins(); } - // Tool factories, - // helper functions to create toolbar tools - // ------------------------- - virtual wxToolBarToolBase *CreateTool(int toolid, - const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, - wxItemKind kind = wxITEM_NORMAL, - wxObject *clientData = NULL, - const wxString& shortHelp = wxEmptyString, - const wxString& longHelp = wxEmptyString) = 0; - - virtual wxToolBarToolBase *CreateTool(wxControl *control, - const wxString& label) = 0; - - // this one is not virtual but just a simple helper/wrapper around - // CreateTool() for separators - wxToolBarToolBase *CreateSeparator() - { - return CreateTool(wxID_SEPARATOR, - wxEmptyString, - wxNullBitmap, wxNullBitmap, - wxITEM_SEPARATOR, NULL, - wxEmptyString, wxEmptyString); - } - - // implementation only from now on // ------------------------------- + size_t GetToolsCount() const { return m_tools.GetCount(); } + // Do the toolbar button updates (check for EVT_UPDATE_UI handlers) virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE) ; // don't want toolbars to accept the focus virtual bool AcceptsFocus() const { return false; } -#if wxUSE_MENUS - // Set dropdown menu - bool SetDropdownMenu(int toolid, wxMenu *menu); -#endif - protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - // to implement in derived classes // ------------------------------- @@ -647,6 +549,17 @@ protected: // called when the tools "can be toggled" flag changes virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) = 0; + // the functions to create toolbar tools + virtual wxToolBarToolBase *CreateTool(int toolid, + const wxString& label, + const wxBitmap& bmpNormal, + const wxBitmap& bmpDisabled, + wxItemKind kind, + wxObject *clientData, + const wxString& shortHelp, + const wxString& longHelp) = 0; + + virtual wxToolBarToolBase *CreateTool(wxControl *control) = 0; // helper functions // ---------------- @@ -661,21 +574,6 @@ protected: // un-toggle all buttons in the same radio group void UnToggleRadioGroup(wxToolBarToolBase *tool); - // make the size of the buttons big enough to fit the largest bitmap size - void AdjustToolBitmapSize(); - - // calls InsertTool() and deletes the tool if inserting it failed - wxToolBarToolBase *DoInsertNewTool(size_t pos, wxToolBarToolBase *tool) - { - if ( !InsertTool(pos, tool) ) - { - delete tool; - return NULL; - } - - return tool; - } - // the list of all our tools wxToolBarToolsList m_tools; @@ -696,17 +594,11 @@ protected: private: DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxToolBarBase); + DECLARE_NO_COPY_CLASS(wxToolBarBase) }; -// deprecated function for creating the image for disabled buttons, use -// wxImage::ConvertToGreyscale() instead -#if WXWIN_COMPATIBILITY_2_8 - -wxDEPRECATED( bool wxCreateGreyedImage(const wxImage& in, wxImage& out) ); - -#endif // WXWIN_COMPATIBILITY_2_8 - +// Helper function for creating the image for disabled buttons +bool wxCreateGreyedImage(const wxImage& in, wxImage& out) ; #endif // wxUSE_TOOLBAR diff --git a/Source/3rd Party/wx/include/wx/testing.h b/Source/3rd Party/wx/include/wx/testing.h deleted file mode 100644 index 57d9d0990..000000000 --- a/Source/3rd Party/wx/include/wx/testing.h +++ /dev/null @@ -1,351 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/testing.h -// Purpose: helpers for GUI testing -// Author: Vaclav Slavik -// Created: 2012-08-28 -// Copyright: (c) 2012 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TESTING_H_ -#define _WX_TESTING_H_ - -#include "wx/debug.h" -#include "wx/string.h" -#include "wx/modalhook.h" - -class WXDLLIMPEXP_FWD_CORE wxMessageDialogBase; -class WXDLLIMPEXP_FWD_CORE wxFileDialogBase; - -// ---------------------------------------------------------------------------- -// testing API -// ---------------------------------------------------------------------------- - -// Don't include this code when building the library itself -#ifndef WXBUILDING - -#include "wx/beforestd.h" -#include -#include -#include -#include "wx/afterstd.h" -#include "wx/cpp.h" -#include "wx/dialog.h" -#include "wx/msgdlg.h" -#include "wx/filedlg.h" - -class wxTestingModalHook; - -// Non-template base class for wxExpectModal (via wxExpectModalBase). -// Only used internally. -class wxModalExpectation -{ -public: - wxModalExpectation() : m_isOptional(false) {} - virtual ~wxModalExpectation() {} - - bool IsOptional() const { return m_isOptional; } - - virtual int Invoke(wxDialog *dlg) const = 0; - - virtual wxString GetDescription() const = 0; - -protected: - // Is this dialog optional, i.e. not required to be shown? - bool m_isOptional; -}; - - -// This must be specialized for each type. The specialization MUST be derived -// from wxExpectModalBase. -template class wxExpectModal {}; - - -/** - Base class for wxExpectModal specializations. - - Every such specialization must be derived from wxExpectModalBase; there's - no other use for this class than to serve as wxExpectModal's base class. - - T must be a class derived from wxDialog. - */ -template -class wxExpectModalBase : public wxModalExpectation -{ -public: - typedef T DialogType; - typedef wxExpectModal ExpectationType; - - /** - Returns a copy of the expectation where the expected dialog is marked - as optional. - - Optional dialogs aren't required to appear, it's not an error if they - don't. - */ - ExpectationType Optional() const - { - ExpectationType e(*static_cast(this)); - e.m_isOptional = true; - return e; - } - -protected: - virtual int Invoke(wxDialog *dlg) const - { - DialogType *t = dynamic_cast(dlg); - if ( t ) - return OnInvoked(t); - else - return wxID_NONE; // not handled - } - - /// Returns description of the expected dialog (by default, its class). - virtual wxString GetDescription() const - { - return wxCLASSINFO(T)->GetClassName(); - } - - /** - This method is called when ShowModal() was invoked on a dialog of type T. - - @return Return value is used as ShowModal()'s return value. - */ - virtual int OnInvoked(DialogType *dlg) const = 0; -}; - - -// wxExpectModal specializations for common dialogs: - -template<> -class wxExpectModal : public wxExpectModalBase -{ -public: - wxExpectModal(int id) - { - switch ( id ) - { - case wxYES: - m_id = wxID_YES; - break; - case wxNO: - m_id = wxID_NO; - break; - case wxCANCEL: - m_id = wxID_CANCEL; - break; - case wxOK: - m_id = wxID_OK; - break; - case wxHELP: - m_id = wxID_HELP; - break; - default: - m_id = id; - break; - } - } - -protected: - virtual int OnInvoked(wxMessageDialog *WXUNUSED(dlg)) const - { - return m_id; - } - - int m_id; -}; - -#if wxUSE_FILEDLG - -template<> -class wxExpectModal : public wxExpectModalBase -{ -public: - wxExpectModal(const wxString& path, int id = wxID_OK) - : m_path(path), m_id(id) - { - } - -protected: - virtual int OnInvoked(wxFileDialog *dlg) const - { - dlg->SetPath(m_path); - return m_id; - } - - wxString m_path; - int m_id; -}; - -#endif - -// Implementation of wxModalDialogHook for use in testing, with -// wxExpectModal and the wxTEST_DIALOG() macro. It is not intended for -// direct use, use the macro instead. -class wxTestingModalHook : public wxModalDialogHook -{ -public: - wxTestingModalHook() - { - Register(); - } - - // Called to verify that all expectations were met. This cannot be done in - // the destructor, because ReportFailure() may throw (either because it's - // overriden or because wx's assertions handling is, globally). And - // throwing from the destructor would introduce all sort of problems, - // including messing up the order of errors in some cases. - void CheckUnmetExpectations() - { - while ( !m_expectations.empty() ) - { - const wxModalExpectation *expect = m_expectations.front(); - m_expectations.pop(); - if ( expect->IsOptional() ) - continue; - - ReportFailure - ( - wxString::Format - ( - "Expected %s dialog was not shown.", - expect->GetDescription() - ) - ); - break; - } - } - - void AddExpectation(const wxModalExpectation& e) - { - m_expectations.push(&e); - } - -protected: - virtual int Enter(wxDialog *dlg) - { - while ( !m_expectations.empty() ) - { - const wxModalExpectation *expect = m_expectations.front(); - m_expectations.pop(); - - int ret = expect->Invoke(dlg); - if ( ret != wxID_NONE ) - return ret; // dialog shown as expected - - // not showing an optional dialog is OK, but showing an unexpected - // one definitely isn't: - if ( !expect->IsOptional() ) - { - ReportFailure - ( - wxString::Format - ( - "A %s dialog was shown unexpectedly, expected %s.", - dlg->GetClassInfo()->GetClassName(), - expect->GetDescription() - ) - ); - return wxID_NONE; - } - // else: try the next expectation in the chain - } - - ReportFailure - ( - wxString::Format - ( - "A dialog (%s) was shown unexpectedly.", - dlg->GetClassInfo()->GetClassName() - ) - ); - return wxID_NONE; - } - -protected: - virtual void ReportFailure(const wxString& msg) - { - wxFAIL_MSG( msg ); - } - -private: - std::queue m_expectations; - - wxDECLARE_NO_COPY_CLASS(wxTestingModalHook); -}; - - -// Redefining this value makes it possible to customize the hook class, -// including e.g. its error reporting. -#define wxTEST_DIALOG_HOOK_CLASS wxTestingModalHook - -#define WX_TEST_IMPL_ADD_EXPECTATION(pos, expect) \ - const wxModalExpectation& wx_exp##pos = expect; \ - wx_hook.AddExpectation(wx_exp##pos); - -/** - Runs given code with all modal dialogs redirected to wxExpectModal - hooks, instead of being shown to the user. - - The first argument is any valid expression, typically a function call. The - remaining arguments are wxExpectModal instances defining the dialogs - that are expected to be shown, in order of appearance. - - Some typical examples: - - @code - wxTEST_DIALOG - ( - rc = dlg.ShowModal(), - wxExpectModal(wxGetCwd() + "/test.txt") - ); - @endcode - - Sometimes, the code may show more than one dialog: - - @code - wxTEST_DIALOG - ( - RunSomeFunction(), - wxExpectModal(wxNO), - wxExpectModal(wxYES), - wxExpectModal(wxGetCwd() + "/test.txt") - ); - @endcode - - Notice that wxExpectModal has some convenience methods for further - tweaking the expectations. For example, it's possible to mark an expected - dialog as @em optional for situations when a dialog may be shown, but isn't - required to, by calling the Optional() method: - - @code - wxTEST_DIALOG - ( - RunSomeFunction(), - wxExpectModal(wxNO), - wxExpectModal(wxGetCwd() + "/test.txt").Optional() - ); - @endcode - - @note By default, errors are reported with wxFAIL_MSG(). You may customize this by - implementing a class derived from wxTestingModalHook, overriding its - ReportFailure() method and redefining the wxTEST_DIALOG_HOOK_CLASS - macro to be the name of this class. - - @note Custom dialogs are supported too. All you have to do is to specialize - wxExpectModal<> for your dialog type and implement its OnInvoked() - method. - */ -#ifdef HAVE_VARIADIC_MACROS -#define wxTEST_DIALOG(codeToRun, ...) \ - { \ - wxTEST_DIALOG_HOOK_CLASS wx_hook; \ - wxCALL_FOR_EACH(WX_TEST_IMPL_ADD_EXPECTATION, __VA_ARGS__) \ - codeToRun; \ - wx_hook.CheckUnmetExpectations(); \ - } -#endif /* HAVE_VARIADIC_MACROS */ - -#endif // !WXBUILDING - -#endif // _WX_TESTING_H_ diff --git a/Source/3rd Party/wx/include/wx/textbuf.h b/Source/3rd Party/wx/include/wx/textbuf.h index 14f804256..97246b6b2 100644 --- a/Source/3rd Party/wx/include/wx/textbuf.h +++ b/Source/3rd Party/wx/include/wx/textbuf.h @@ -20,7 +20,7 @@ // constants // ---------------------------------------------------------------------------- -// the line termination type (kept wxTextFileType name for compatibility) +// the line termination type (kept wxTextFileType name for compability) enum wxTextFileType { wxTextFileType_None, // incomplete (the last line of the file only) @@ -99,10 +99,8 @@ public: size_t GetLineCount() const { return m_aLines.size(); } // the returned line may be modified (but don't add CR/LF at the end!) - wxString& GetLine(size_t n) { return m_aLines[n]; } - const wxString& GetLine(size_t n) const { return m_aLines[n]; } - wxString& operator[](size_t n) { return m_aLines[n]; } - const wxString& operator[](size_t n) const { return m_aLines[n]; } + wxString& GetLine(size_t n) const { return (wxString&)m_aLines[n]; } + wxString& operator[](size_t n) const { return (wxString&)m_aLines[n]; } // the current line has meaning only when you're using // GetFirstLine()/GetNextLine() functions, it doesn't get updated when @@ -134,7 +132,7 @@ public: wxTextFileType GuessType() const; // get the name of the buffer - const wxString& GetName() const { return m_strBufferName; } + const wxChar *GetName() const { return m_strBufferName.c_str(); } // add/remove lines // ---------------- diff --git a/Source/3rd Party/wx/include/wx/textcompleter.h b/Source/3rd Party/wx/include/wx/textcompleter.h deleted file mode 100644 index bc4135f8b..000000000 --- a/Source/3rd Party/wx/include/wx/textcompleter.h +++ /dev/null @@ -1,86 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/textcompleter.h -// Purpose: Declaration of wxTextCompleter class. -// Author: Vadim Zeitlin -// Created: 2011-04-13 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TEXTCOMPLETER_H_ -#define _WX_TEXTCOMPLETER_H_ - -// ---------------------------------------------------------------------------- -// wxTextCompleter: used by wxTextEnter::AutoComplete() -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextCompleter -{ -public: - wxTextCompleter() { } - - // The virtual functions to be implemented by the derived classes: the - // first one is called to start preparing for completions for the given - // prefix and, if it returns true, GetNext() is called until it returns an - // empty string indicating that there are no more completions. - virtual bool Start(const wxString& prefix) = 0; - virtual wxString GetNext() = 0; - - virtual ~wxTextCompleter(); - -private: - wxDECLARE_NO_COPY_CLASS(wxTextCompleter); -}; - -// ---------------------------------------------------------------------------- -// wxTextCompleterSimple: returns the entire set of completions at once -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextCompleterSimple : public wxTextCompleter -{ -public: - wxTextCompleterSimple() { } - - // Must be implemented to return all the completions for the given prefix. - virtual void GetCompletions(const wxString& prefix, wxArrayString& res) = 0; - - virtual bool Start(const wxString& prefix); - virtual wxString GetNext(); - -private: - wxArrayString m_completions; - unsigned m_index; - - wxDECLARE_NO_COPY_CLASS(wxTextCompleterSimple); -}; - -// ---------------------------------------------------------------------------- -// wxTextCompleterFixed: Trivial wxTextCompleter implementation which always -// returns the same fixed array of completions. -// ---------------------------------------------------------------------------- - -// NB: This class is private and intentionally not documented as it is -// currently used only for implementation of completion with the fixed list -// of strings only by wxWidgets itself, do not use it outside of wxWidgets. - -class wxTextCompleterFixed : public wxTextCompleterSimple -{ -public: - void SetCompletions(const wxArrayString& strings) - { - m_strings = strings; - } - - virtual void GetCompletions(const wxString& WXUNUSED(prefix), - wxArrayString& res) - { - res = m_strings; - } - -private: - wxArrayString m_strings; -}; - - -#endif // _WX_TEXTCOMPLETER_H_ - diff --git a/Source/3rd Party/wx/include/wx/textctrl.h b/Source/3rd Party/wx/include/wx/textctrl.h index dd4bf6c33..b1b4c0a25 100644 --- a/Source/3rd Party/wx/include/wx/textctrl.h +++ b/Source/3rd Party/wx/include/wx/textctrl.h @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/textctrl.h -// Purpose: wxTextAttr and wxTextCtrlBase class - the interface of wxTextCtrl +// Purpose: wxTextCtrlBase class - the interface of wxTextCtrl // Author: Vadim Zeitlin // Modified by: // Created: 13.07.99 +// RCS-ID: $Id: textctrl.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -20,14 +21,16 @@ #if wxUSE_TEXTCTRL #include "wx/control.h" // the base class -#include "wx/textentry.h" // single-line text entry interface #include "wx/dynarray.h" // wxArrayInt #include "wx/gdicmn.h" // wxPoint -// some compilers don't have standard compliant rdbuf() (and MSVC has it only -// in its new iostream library, not in the old one used with iostream.h) +// Open Watcom 1.3 does allow only ios::rdbuf() while +// we want something with streambuf parameter +// Also, can't use streambuf if making or using a DLL :-( + #if defined(__WATCOMC__) || \ - ((defined(__VISUALC5__) || defined(__VISUALC6__)) && wxUSE_IOSTREAMH) + defined(__MWERKS__) || \ + (defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL))) #define wxHAS_TEXT_WINDOW_STREAM 0 #elif wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" @@ -36,6 +39,11 @@ #define wxHAS_TEXT_WINDOW_STREAM 0 #endif +#if WXWIN_COMPATIBILITY_2_4 && !wxHAS_TEXT_WINDOW_STREAM + // define old flag if one could use it somewhere + #define NO_TEXT_WINDOW_STREAM +#endif + class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class WXDLLIMPEXP_FWD_CORE wxTextCtrlBase; @@ -43,6 +51,9 @@ class WXDLLIMPEXP_FWD_CORE wxTextCtrlBase; // wxTextCtrl types // ---------------------------------------------------------------------------- +// wxTextPos is the position in the text +typedef long wxTextPos; + // wxTextCoord is the line or row number (which should have been unsigned but // is long for backwards compatibility) typedef long wxTextCoord; @@ -51,7 +62,7 @@ typedef long wxTextCoord; // constants // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(const char) wxTextCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxTextCtrlNameStr[]; // this is intentionally not enum to avoid warning fixes with // typecasting from enum type to wxTextCoord @@ -63,6 +74,7 @@ const wxTextCoord wxInvalidTextCoord = -2; // ---------------------------------------------------------------------------- #define wxTE_NO_VSCROLL 0x0002 +#define wxTE_AUTO_SCROLL 0x0008 #define wxTE_READONLY 0x0010 #define wxTE_MULTILINE 0x0020 @@ -105,11 +117,6 @@ const wxTextCoord wxInvalidTextCoord = -2; #define wxTE_LINEWRAP wxTE_CHARWRAP #endif // WXWIN_COMPATIBILITY_2_6 -#if WXWIN_COMPATIBILITY_2_8 - // this style is (or at least should be) on by default now, don't use it - #define wxTE_AUTO_SCROLL 0 -#endif // WXWIN_COMPATIBILITY_2_8 - // force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for // wxTE_RICH controls - can be used together with or instead of wxTE_RICH #define wxTE_RICH2 0x8000 @@ -159,290 +166,39 @@ enum wxTextAttrAlignment }; // Flags to indicate which attributes are being applied -enum wxTextAttrFlags -{ - wxTEXT_ATTR_TEXT_COLOUR = 0x00000001, - wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002, - wxTEXT_ATTR_FONT_FACE = 0x00000004, - wxTEXT_ATTR_FONT_POINT_SIZE = 0x00000008, - wxTEXT_ATTR_FONT_PIXEL_SIZE = 0x10000000, - wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, - wxTEXT_ATTR_FONT_ITALIC = 0x00000020, - wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, - wxTEXT_ATTR_FONT_STRIKETHROUGH = 0x08000000, - wxTEXT_ATTR_FONT_ENCODING = 0x02000000, - wxTEXT_ATTR_FONT_FAMILY = 0x04000000, - wxTEXT_ATTR_FONT_SIZE = \ - ( wxTEXT_ATTR_FONT_POINT_SIZE | wxTEXT_ATTR_FONT_PIXEL_SIZE ), - wxTEXT_ATTR_FONT = \ - ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ - wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_STRIKETHROUGH | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), - - wxTEXT_ATTR_ALIGNMENT = 0x00000080, - wxTEXT_ATTR_LEFT_INDENT = 0x00000100, - wxTEXT_ATTR_RIGHT_INDENT = 0x00000200, - wxTEXT_ATTR_TABS = 0x00000400, - wxTEXT_ATTR_PARA_SPACING_AFTER = 0x00000800, - wxTEXT_ATTR_PARA_SPACING_BEFORE = 0x00001000, - wxTEXT_ATTR_LINE_SPACING = 0x00002000, - wxTEXT_ATTR_CHARACTER_STYLE_NAME = 0x00004000, - wxTEXT_ATTR_PARAGRAPH_STYLE_NAME = 0x00008000, - wxTEXT_ATTR_LIST_STYLE_NAME = 0x00010000, - - wxTEXT_ATTR_BULLET_STYLE = 0x00020000, - wxTEXT_ATTR_BULLET_NUMBER = 0x00040000, - wxTEXT_ATTR_BULLET_TEXT = 0x00080000, - wxTEXT_ATTR_BULLET_NAME = 0x00100000, - - wxTEXT_ATTR_BULLET = \ - ( wxTEXT_ATTR_BULLET_STYLE | wxTEXT_ATTR_BULLET_NUMBER | wxTEXT_ATTR_BULLET_TEXT | \ - wxTEXT_ATTR_BULLET_NAME ), - - - wxTEXT_ATTR_URL = 0x00200000, - wxTEXT_ATTR_PAGE_BREAK = 0x00400000, - wxTEXT_ATTR_EFFECTS = 0x00800000, - wxTEXT_ATTR_OUTLINE_LEVEL = 0x01000000, - - /*! - * Character and paragraph combined styles - */ - - wxTEXT_ATTR_CHARACTER = \ - (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS| \ - wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL), - - wxTEXT_ATTR_PARAGRAPH = \ - (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\ - wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\ - wxTEXT_ATTR_BULLET|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL|wxTEXT_ATTR_PAGE_BREAK), - - wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) -}; - -/*! - * Styles for wxTextAttr::SetBulletStyle - */ -enum wxTextAttrBulletStyle -{ - wxTEXT_ATTR_BULLET_STYLE_NONE = 0x00000000, - wxTEXT_ATTR_BULLET_STYLE_ARABIC = 0x00000001, - wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER = 0x00000002, - wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER = 0x00000004, - wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER = 0x00000008, - wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER = 0x00000010, - wxTEXT_ATTR_BULLET_STYLE_SYMBOL = 0x00000020, - wxTEXT_ATTR_BULLET_STYLE_BITMAP = 0x00000040, - wxTEXT_ATTR_BULLET_STYLE_PARENTHESES = 0x00000080, - wxTEXT_ATTR_BULLET_STYLE_PERIOD = 0x00000100, - wxTEXT_ATTR_BULLET_STYLE_STANDARD = 0x00000200, - wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS = 0x00000400, - wxTEXT_ATTR_BULLET_STYLE_OUTLINE = 0x00000800, - - wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT = 0x00000000, - wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT = 0x00001000, - wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE = 0x00002000, - - wxTEXT_ATTR_BULLET_STYLE_CONTINUATION = 0x00004000 -}; - -/*! - * Styles for wxTextAttr::SetTextEffects - */ -enum wxTextAttrEffects -{ - wxTEXT_ATTR_EFFECT_NONE = 0x00000000, - wxTEXT_ATTR_EFFECT_CAPITALS = 0x00000001, - wxTEXT_ATTR_EFFECT_SMALL_CAPITALS = 0x00000002, - wxTEXT_ATTR_EFFECT_STRIKETHROUGH = 0x00000004, - wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH = 0x00000008, - wxTEXT_ATTR_EFFECT_SHADOW = 0x00000010, - wxTEXT_ATTR_EFFECT_EMBOSS = 0x00000020, - wxTEXT_ATTR_EFFECT_OUTLINE = 0x00000040, - wxTEXT_ATTR_EFFECT_ENGRAVE = 0x00000080, - wxTEXT_ATTR_EFFECT_SUPERSCRIPT = 0x00000100, - wxTEXT_ATTR_EFFECT_SUBSCRIPT = 0x00000200 -}; - -/*! - * Line spacing values - */ -enum wxTextAttrLineSpacing -{ - wxTEXT_ATTR_LINE_SPACING_NORMAL = 10, - wxTEXT_ATTR_LINE_SPACING_HALF = 15, - wxTEXT_ATTR_LINE_SPACING_TWICE = 20 -}; +#define wxTEXT_ATTR_TEXT_COLOUR 0x0001 +#define wxTEXT_ATTR_BACKGROUND_COLOUR 0x0002 +#define wxTEXT_ATTR_FONT_FACE 0x0004 +#define wxTEXT_ATTR_FONT_SIZE 0x0008 +#define wxTEXT_ATTR_FONT_WEIGHT 0x0010 +#define wxTEXT_ATTR_FONT_ITALIC 0x0020 +#define wxTEXT_ATTR_FONT_UNDERLINE 0x0040 +#define wxTEXT_ATTR_FONT \ + ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ + wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE ) +#define wxTEXT_ATTR_ALIGNMENT 0x0080 +#define wxTEXT_ATTR_LEFT_INDENT 0x0100 +#define wxTEXT_ATTR_RIGHT_INDENT 0x0200 +#define wxTEXT_ATTR_TABS 0x0400 // ---------------------------------------------------------------------------- // wxTextAttr: a structure containing the visual attributes of a text // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTextAttr +class WXDLLEXPORT wxTextAttr { public: // ctors wxTextAttr() { Init(); } - wxTextAttr(const wxTextAttr& attr) { Init(); Copy(attr); } wxTextAttr(const wxColour& colText, const wxColour& colBack = wxNullColour, const wxFont& font = wxNullFont, wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); - // Initialise this object. + // operations void Init(); - // Copy - void Copy(const wxTextAttr& attr); - - // Assignment - void operator= (const wxTextAttr& attr); - - // Equality test - bool operator== (const wxTextAttr& attr) const; - - // Partial equality test. If @a weakTest is @true, attributes of this object do not - // have to be present if those attributes of @a attr are present. If @a weakTest is - // @false, the function will fail if an attribute is present in @a attr but not - // in this object. - bool EqPartial(const wxTextAttr& attr, bool weakTest = true) const; - - // Get attributes from font. - bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT); - - // setters - void SetTextColour(const wxColour& colText) { m_colText = colText; m_flags |= wxTEXT_ATTR_TEXT_COLOUR; } - void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; } - void SetAlignment(wxTextAttrAlignment alignment) { m_textAlignment = alignment; m_flags |= wxTEXT_ATTR_ALIGNMENT; } - void SetTabs(const wxArrayInt& tabs) { m_tabs = tabs; m_flags |= wxTEXT_ATTR_TABS; } - void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; } - void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; } - - void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_POINT_SIZE; } - void SetFontPointSize(int pointSize) { m_fontSize = pointSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_POINT_SIZE; } - void SetFontPixelSize(int pixelSize) { m_fontSize = pixelSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_PIXEL_SIZE; } - void SetFontStyle(wxFontStyle fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; } - void SetFontWeight(wxFontWeight fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; } - void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; } - void SetFontUnderlined(bool underlined) { m_fontUnderlined = underlined; m_flags |= wxTEXT_ATTR_FONT_UNDERLINE; } - void SetFontStrikethrough(bool strikethrough) { m_fontStrikethrough = strikethrough; m_flags |= wxTEXT_ATTR_FONT_STRIKETHROUGH; } - void SetFontEncoding(wxFontEncoding encoding) { m_fontEncoding = encoding; m_flags |= wxTEXT_ATTR_FONT_ENCODING; } - void SetFontFamily(wxFontFamily family) { m_fontFamily = family; m_flags |= wxTEXT_ATTR_FONT_FAMILY; } - - // Set font - void SetFont(const wxFont& font, int flags = (wxTEXT_ATTR_FONT & ~wxTEXT_ATTR_FONT_PIXEL_SIZE)) { GetFontAttributes(font, flags); } - - void SetFlags(long flags) { m_flags = flags; } - - void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; } - void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; } - void SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME); } - void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; } - void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_BEFORE; } - void SetLineSpacing(int spacing) { m_lineSpacing = spacing; m_flags |= wxTEXT_ATTR_LINE_SPACING; } - void SetBulletStyle(int style) { m_bulletStyle = style; m_flags |= wxTEXT_ATTR_BULLET_STYLE; } - void SetBulletNumber(int n) { m_bulletNumber = n; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; } - void SetBulletText(const wxString& text) { m_bulletText = text; m_flags |= wxTEXT_ATTR_BULLET_TEXT; } - void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } - void SetBulletName(const wxString& name) { m_bulletName = name; m_flags |= wxTEXT_ATTR_BULLET_NAME; } - void SetURL(const wxString& url) { m_urlTarget = url; m_flags |= wxTEXT_ATTR_URL; } - void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); } - void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); } - void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; } - void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); } - - const wxColour& GetTextColour() const { return m_colText; } - const wxColour& GetBackgroundColour() const { return m_colBack; } - wxTextAttrAlignment GetAlignment() const { return m_textAlignment; } - const wxArrayInt& GetTabs() const { return m_tabs; } - long GetLeftIndent() const { return m_leftIndent; } - long GetLeftSubIndent() const { return m_leftSubIndent; } - long GetRightIndent() const { return m_rightIndent; } - long GetFlags() const { return m_flags; } - - int GetFontSize() const { return m_fontSize; } - wxFontStyle GetFontStyle() const { return m_fontStyle; } - wxFontWeight GetFontWeight() const { return m_fontWeight; } - bool GetFontUnderlined() const { return m_fontUnderlined; } - bool GetFontStrikethrough() const { return m_fontStrikethrough; } - const wxString& GetFontFaceName() const { return m_fontFaceName; } - wxFontEncoding GetFontEncoding() const { return m_fontEncoding; } - wxFontFamily GetFontFamily() const { return m_fontFamily; } - - wxFont GetFont() const; - - const wxString& GetCharacterStyleName() const { return m_characterStyleName; } - const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } - const wxString& GetListStyleName() const { return m_listStyleName; } - int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; } - int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; } - - int GetLineSpacing() const { return m_lineSpacing; } - int GetBulletStyle() const { return m_bulletStyle; } - int GetBulletNumber() const { return m_bulletNumber; } - const wxString& GetBulletText() const { return m_bulletText; } - const wxString& GetBulletFont() const { return m_bulletFont; } - const wxString& GetBulletName() const { return m_bulletName; } - const wxString& GetURL() const { return m_urlTarget; } - int GetTextEffects() const { return m_textEffects; } - int GetTextEffectFlags() const { return m_textEffectFlags; } - int GetOutlineLevel() const { return m_outlineLevel; } - - // accessors - bool HasTextColour() const { return m_colText.IsOk() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; } - bool HasBackgroundColour() const { return m_colBack.IsOk() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; } - bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) && HasFlag(wxTEXT_ATTR_ALIGNMENT) ; } - bool HasTabs() const { return HasFlag(wxTEXT_ATTR_TABS) ; } - bool HasLeftIndent() const { return HasFlag(wxTEXT_ATTR_LEFT_INDENT); } - bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); } - bool HasFontWeight() const { return HasFlag(wxTEXT_ATTR_FONT_WEIGHT); } - bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); } - bool HasFontPointSize() const { return HasFlag(wxTEXT_ATTR_FONT_POINT_SIZE); } - bool HasFontPixelSize() const { return HasFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); } - bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); } - bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } - bool HasFontStrikethrough() const { return HasFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH); } - bool HasFontFaceName() const { return HasFlag(wxTEXT_ATTR_FONT_FACE); } - bool HasFontEncoding() const { return HasFlag(wxTEXT_ATTR_FONT_ENCODING); } - bool HasFontFamily() const { return HasFlag(wxTEXT_ATTR_FONT_FAMILY); } - bool HasFont() const { return HasFlag(wxTEXT_ATTR_FONT); } - - bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } - bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); } - bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING); } - bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME) && !m_characterStyleName.IsEmpty(); } - bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && !m_paragraphStyleName.IsEmpty(); } - bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); } - bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); } - bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); } - bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT); } - bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); } - bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); } - bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); } - bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); } - bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); } - bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } - - bool HasFlag(long flag) const { return (m_flags & flag) != 0; } - void RemoveFlag(long flag) { m_flags &= ~flag; } - void AddFlag(long flag) { m_flags |= flag; } - - // Is this a character style? - bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); } - bool IsParagraphStyle() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH); } - - // returns false if we have any attributes set, true otherwise - bool IsDefault() const - { - return GetFlags() == 0; - } - - // Merges the given attributes. If compareWith - // is non-NULL, then it will be used to mask out those attributes that are the same in style - // and compareWith, for situations where we don't want to explicitly set inherited attributes. - bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL); - // merges the attributes of the base and the overlay objects and returns // the result; the parameter attributes take precedence // @@ -458,6 +214,47 @@ public: *this = Merge(*this, overlay); } + + // operators + void operator= (const wxTextAttr& attr); + + // setters + void SetTextColour(const wxColour& colText) { m_colText = colText; m_flags |= wxTEXT_ATTR_TEXT_COLOUR; } + void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; } + void SetFont(const wxFont& font, long flags = wxTEXT_ATTR_FONT) { m_font = font; m_flags |= flags; } + void SetAlignment(wxTextAttrAlignment alignment) { m_textAlignment = alignment; m_flags |= wxTEXT_ATTR_ALIGNMENT; } + void SetTabs(const wxArrayInt& tabs) { m_tabs = tabs; m_flags |= wxTEXT_ATTR_TABS; } + void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; } + void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; } + void SetFlags(long flags) { m_flags = flags; } + + // accessors + bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; } + bool HasBackgroundColour() const { return m_colBack.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; } + bool HasFont() const { return m_font.Ok() && HasFlag(wxTEXT_ATTR_FONT) ; } + bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) && ((m_flags & wxTEXT_ATTR_ALIGNMENT) != 0) ; } + bool HasTabs() const { return (m_flags & wxTEXT_ATTR_TABS) != 0 ; } + bool HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_INDENT) != 0 ; } + bool HasRightIndent() const { return (m_flags & wxTEXT_ATTR_RIGHT_INDENT) != 0 ; } + bool HasFlag(long flag) const { return (m_flags & flag) != 0; } + + const wxColour& GetTextColour() const { return m_colText; } + const wxColour& GetBackgroundColour() const { return m_colBack; } + const wxFont& GetFont() const { return m_font; } + wxTextAttrAlignment GetAlignment() const { return m_textAlignment; } + const wxArrayInt& GetTabs() const { return m_tabs; } + long GetLeftIndent() const { return m_leftIndent; } + long GetLeftSubIndent() const { return m_leftSubIndent; } + long GetRightIndent() const { return m_rightIndent; } + long GetFlags() const { return m_flags; } + + // returns false if we have any attributes set, true otherwise + bool IsDefault() const + { + return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() && + !HasTabs() && !HasLeftIndent() && !HasRightIndent() ; + } + // return the attribute having the valid font and colours: it uses the // attributes set in attr and falls back first to attrDefault and then to // the text control font/colours for those attributes which are not set @@ -465,98 +262,84 @@ public: const wxTextAttr& attrDef, const wxTextCtrlBase *text); - // Compare tabs - static bool TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); - - // Remove attributes - static bool RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style); - - // Combine two bitlists, specifying the bits of interest with separate flags. - static bool CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); - - // Compare two bitlists - static bool BitlistsEqPartial(int valueA, int valueB, int flags); - - // Split into paragraph and character styles - static bool SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle); - private: long m_flags; - - // Paragraph styles + wxColour m_colText, + m_colBack; + wxFont m_font; + wxTextAttrAlignment m_textAlignment; wxArrayInt m_tabs; // array of int: tab stops in 1/10 mm int m_leftIndent; // left indent in 1/10 mm int m_leftSubIndent; // left indent for all but the first // line in a paragraph relative to the // first line, in 1/10 mm int m_rightIndent; // right indent in 1/10 mm - wxTextAttrAlignment m_textAlignment; - - int m_paragraphSpacingAfter; - int m_paragraphSpacingBefore; - int m_lineSpacing; - int m_bulletStyle; - int m_bulletNumber; - int m_textEffects; - int m_textEffectFlags; - int m_outlineLevel; - wxString m_bulletText; - wxString m_bulletFont; - wxString m_bulletName; - wxString m_urlTarget; - wxFontEncoding m_fontEncoding; - - // Character styles - wxColour m_colText, - m_colBack; - int m_fontSize; - wxFontStyle m_fontStyle; - wxFontWeight m_fontWeight; - wxFontFamily m_fontFamily; - bool m_fontUnderlined; - bool m_fontStrikethrough; - wxString m_fontFaceName; - - // Character style - wxString m_characterStyleName; - - // Paragraph style - wxString m_paragraphStyleName; - - // List style - wxString m_listStyleName; }; // ---------------------------------------------------------------------------- -// wxTextAreaBase: multiline text control specific methods +// wxTextCtrl: a single or multiple line text zone where user can enter and +// edit text // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTextAreaBase +class WXDLLEXPORT wxTextCtrlBase : public wxControl +#if wxHAS_TEXT_WINDOW_STREAM + , public wxSTD streambuf +#endif + { public: - wxTextAreaBase() { } - virtual ~wxTextAreaBase() { } + // creation + // -------- - // lines access - // ------------ + wxTextCtrlBase(){} + virtual ~wxTextCtrlBase(){} + + // accessors + // --------- + + virtual wxString GetValue() const = 0; + virtual bool IsEmpty() const { return GetValue().empty(); } + + virtual void SetValue(const wxString& value) + { DoSetValue(value, SetValue_SendEvent); } + virtual void ChangeValue(const wxString& value) + { DoSetValue(value); } + + virtual wxString GetRange(long from, long to) const; virtual int GetLineLength(long lineNo) const = 0; virtual wxString GetLineText(long lineNo) const = 0; virtual int GetNumberOfLines() const = 0; - - // file IO - // ------- - - bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY) - { return DoLoadFile(file, fileType); } - bool SaveFile(const wxString& file = wxEmptyString, - int fileType = wxTEXT_TYPE_ANY); - - // dirty flag handling - // ------------------- - virtual bool IsModified() const = 0; + virtual bool IsEditable() const = 0; + + // more readable flag testing methods + bool IsSingleLine() const { return !HasFlag(wxTE_MULTILINE); } + bool IsMultiLine() const { return !IsSingleLine(); } + + // If the return values from and to are the same, there is no selection. + virtual void GetSelection(long* from, long* to) const = 0; + + virtual wxString GetStringSelection() const; + + // operations + // ---------- + + // editing + virtual void Clear() = 0; + virtual void Replace(long from, long to, const wxString& value) = 0; + virtual void Remove(long from, long to) = 0; + + // load/save the control's contents from/to a file + bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY) { return DoLoadFile(file, fileType); } + bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxTEXT_TYPE_ANY); + + // implementation for loading/saving + virtual bool DoLoadFile(const wxString& file, int fileType); + virtual bool DoSaveFile(const wxString& file, int fileType); + + // sets/clears the dirty flag virtual void MarkDirty() = 0; virtual void DiscardEdits() = 0; void SetModified(bool modified) @@ -567,21 +350,26 @@ public: DiscardEdits(); } + // set the max number of characters which may be entered in a single line + // text control + virtual void SetMaxLength(unsigned long WXUNUSED(len)) { } - // styles handling - // --------------- + // writing text inserts it at the current position, appending always + // inserts it at the end + virtual void WriteText(const wxString& text) = 0; + virtual void AppendText(const wxString& text) = 0; + + // insert the character which would have resulted from this key event, + // return true if anything has been inserted + virtual bool EmulateKeyPress(const wxKeyEvent& event); // text control under some platforms supports the text styles: these // methods allow to apply the given text style to the given selection or to // set/get the style which will be used for all appended text - virtual bool SetStyle(long start, long end, const wxTextAttr& style) = 0; - virtual bool GetStyle(long position, wxTextAttr& style) = 0; - virtual bool SetDefaultStyle(const wxTextAttr& style) = 0; - virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultStyle; } - - - // coordinates translation - // ----------------------- + virtual bool SetStyle(long start, long end, const wxTextAttr& style); + virtual bool GetStyle(long position, wxTextAttr& style); + virtual bool SetDefaultStyle(const wxTextAttr& style); + virtual const wxTextAttr& GetDefaultStyle() const; // translate between the position (which is just an index in the text ctrl // considering all its contents as a single strings) and (x, y) coordinates @@ -589,11 +377,6 @@ public: virtual long XYToPosition(long x, long y) const = 0; virtual bool PositionToXY(long pos, long *x, long *y) const = 0; - // translate the given position (which is just an index in the text control) - // to client coordinates - wxPoint PositionToCoords(long pos) const; - - virtual void ShowPosition(long pos) = 0; // find the character at position given in pixels @@ -604,21 +387,66 @@ public: virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const; - virtual wxString GetValue() const = 0; - virtual void SetValue(const wxString& value) = 0; + + // Clipboard operations + virtual void Copy() = 0; + virtual void Cut() = 0; + virtual void Paste() = 0; + + virtual bool CanCopy() const; + virtual bool CanCut() const; + virtual bool CanPaste() const; + + // Undo/redo + virtual void Undo() = 0; + virtual void Redo() = 0; + + virtual bool CanUndo() const = 0; + virtual bool CanRedo() const = 0; + + // Insertion point + virtual void SetInsertionPoint(long pos) = 0; + virtual void SetInsertionPointEnd() = 0; + virtual long GetInsertionPoint() const = 0; + virtual wxTextPos GetLastPosition() const = 0; + + virtual void SetSelection(long from, long to) = 0; + virtual void SelectAll(); + virtual void SetEditable(bool editable) = 0; + + // stream-like insertion operators: these are always available, whether we + // were, or not, compiled with streambuf support + wxTextCtrl& operator<<(const wxString& s); + wxTextCtrl& operator<<(int i); + wxTextCtrl& operator<<(long i); + wxTextCtrl& operator<<(float f); + wxTextCtrl& operator<<(double d); + wxTextCtrl& operator<<(const wxChar c); + + // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does + void SendTextUpdatedEvent(); + + // do the window-specific processing after processing the update event + virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); + + virtual bool ShouldInheritColours() const { return false; } protected: - // implementation of loading/saving - virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file, int fileType); + // override streambuf method +#if wxHAS_TEXT_WINDOW_STREAM + int overflow(int i); +#endif // wxHAS_TEXT_WINDOW_STREAM - // Return true if the given position is valid, i.e. positive and less than - // the last position. - virtual bool IsValidPosition(long pos) const = 0; + // flags for DoSetValue(): common part of SetValue() and ChangeValue() and + // also used to implement WriteText() in wxMSW + enum + { + SetValue_SendEvent = 1, + SetValue_SelectionOnly = 2 + }; + + virtual void DoSetValue(const wxString& value, int flags = 0) = 0; - // Default stub implementation of PositionToCoords() always returns - // wxDefaultPosition. - virtual wxPoint DoPositionToCoords(long pos) const; // the name of the last file loaded with LoadFile() which will be used by // SaveFile() by default @@ -627,145 +455,7 @@ protected: // the text style which will be used for any new text added to the control wxTextAttr m_defaultStyle; - - wxDECLARE_NO_COPY_CLASS(wxTextAreaBase); -}; - -// this class defines wxTextCtrl interface, wxTextCtrlBase actually implements -// too much things because it derives from wxTextEntry and not wxTextEntryBase -// and so any classes which "look like" wxTextCtrl (such as wxRichTextCtrl) -// but don't need the (native) implementation bits from wxTextEntry should -// actually derive from this one and not wxTextCtrlBase -class WXDLLIMPEXP_CORE wxTextCtrlIface : public wxTextAreaBase, - public wxTextEntryBase -{ -public: - wxTextCtrlIface() { } - - // wxTextAreaBase overrides - virtual wxString GetValue() const - { - return wxTextEntryBase::GetValue(); - } - virtual void SetValue(const wxString& value) - { - wxTextEntryBase::SetValue(value); - } - -protected: - virtual bool IsValidPosition(long pos) const - { - return pos >= 0 && pos <= GetLastPosition(); - } - -private: - wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface); -}; - -// ---------------------------------------------------------------------------- -// wxTextCtrl: a single or multiple line text zone where user can edit text -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextCtrlBase : public wxControl, -#if wxHAS_TEXT_WINDOW_STREAM - public wxSTD streambuf, -#endif - public wxTextAreaBase, - public wxTextEntry -{ -public: - // creation - // -------- - - wxTextCtrlBase() { } - virtual ~wxTextCtrlBase() { } - - - // more readable flag testing methods - bool IsSingleLine() const { return !HasFlag(wxTE_MULTILINE); } - bool IsMultiLine() const { return !IsSingleLine(); } - - // stream-like insertion operators: these are always available, whether we - // were, or not, compiled with streambuf support - wxTextCtrl& operator<<(const wxString& s); - wxTextCtrl& operator<<(int i); - wxTextCtrl& operator<<(long i); - wxTextCtrl& operator<<(float f) { return *this << double(f); } - wxTextCtrl& operator<<(double d); - wxTextCtrl& operator<<(char c) { return *this << wxString(c); } - wxTextCtrl& operator<<(wchar_t c) { return *this << wxString(c); } - - // insert the character which would have resulted from this key event, - // return true if anything has been inserted - virtual bool EmulateKeyPress(const wxKeyEvent& event); - - - // do the window-specific processing after processing the update event - virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); - - virtual bool ShouldInheritColours() const { return false; } - - // work around the problem with having HitTest() both in wxControl and - // wxTextAreaBase base classes - virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const - { - return wxTextAreaBase::HitTest(pt, pos); - } - - virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, - wxTextCoord *col, - wxTextCoord *row) const - { - return wxTextAreaBase::HitTest(pt, col, row); - } - - // we provide stubs for these functions as not all platforms have styles - // support, but we really should leave them pure virtual here - virtual bool SetStyle(long start, long end, const wxTextAttr& style); - virtual bool GetStyle(long position, wxTextAttr& style); - virtual bool SetDefaultStyle(const wxTextAttr& style); - - // wxTextAreaBase overrides - virtual wxString GetValue() const - { - return wxTextEntry::GetValue(); - } - virtual void SetValue(const wxString& value) - { - wxTextEntry::SetValue(value); - } - - // wxTextEntry overrides - virtual bool SetHint(const wxString& hint); - - // wxWindow overrides - virtual wxVisualAttributes GetDefaultAttributes() const - { - return GetClassDefaultAttributes(GetWindowVariant()); - } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) - { - return GetCompositeControlsDefaultAttributes(variant); - } - -protected: - // override streambuf method -#if wxHAS_TEXT_WINDOW_STREAM - int overflow(int i); -#endif // wxHAS_TEXT_WINDOW_STREAM - - // Another wxTextAreaBase override. - virtual bool IsValidPosition(long pos) const - { - return pos >= 0 && pos <= GetLastPosition(); - } - - // implement the wxTextEntry pure virtual method - virtual wxWindow *GetEditableWindow() { return this; } - - wxDECLARE_NO_COPY_CLASS(wxTextCtrlBase); + DECLARE_NO_COPY_CLASS(wxTextCtrlBase) DECLARE_ABSTRACT_CLASS(wxTextCtrlBase) }; @@ -788,7 +478,7 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/textctrl.h" #elif defined(__WXMAC__) - #include "wx/osx/textctrl.h" + #include "wx/mac/textctrl.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/textctrl.h" #elif defined(__WXPM__) @@ -799,28 +489,27 @@ protected: // wxTextCtrl events // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_CORE wxTextUrlEvent; +#if !WXWIN_COMPATIBILITY_EVENT_TYPES -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_ENTER, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_URL, wxTextUrlEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_MAXLEN, wxCommandEvent); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14) +END_DECLARE_EVENT_TYPES() -class WXDLLIMPEXP_CORE wxTextUrlEvent : public wxCommandEvent +#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES + +class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent { public: wxTextUrlEvent(int winid, const wxMouseEvent& evtMouse, long start, long end) - : wxCommandEvent(wxEVT_TEXT_URL, winid), - m_evtMouse(evtMouse), m_start(start), m_end(end) + : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid) + , m_evtMouse(evtMouse), m_start(start), m_end(end) { } - wxTextUrlEvent(const wxTextUrlEvent& event) - : wxCommandEvent(event), - m_evtMouse(event.m_evtMouse), - m_start(event.m_start), - m_end(event.m_end) { } - // get the mouse event which happened over the URL + // get the mouse event which happend over the URL const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; } // get the start of the URL @@ -829,8 +518,6 @@ public: // get the end of the URL long GetURLEnd() const { return m_end; } - virtual wxEvent *Clone() const { return new wxTextUrlEvent(*this); } - protected: // the corresponding mouse event wxMouseEvent m_evtMouse; @@ -840,7 +527,7 @@ protected: m_end; private: - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTextUrlEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent) public: // for wxWin RTTI only, don't use @@ -851,15 +538,15 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); #define wxTextEventHandler(func) wxCommandEventHandler(func) #define wxTextUrlEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxTextUrlEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTextUrlEventFunction, &func) #define wx__DECLARE_TEXTEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_TEXT_ ## evt, id, wxTextEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextEventHandler(fn)) #define wx__DECLARE_TEXTURLEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_TEXT_ ## evt, id, wxTextUrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextUrlEventHandler(fn)) -#define EVT_TEXT(id, fn) wx__DECLARE_EVT1(wxEVT_TEXT, id, wxTextEventHandler(fn)) +#define EVT_TEXT(id, fn) wx__DECLARE_TEXTEVT(UPDATED, id, fn) #define EVT_TEXT_ENTER(id, fn) wx__DECLARE_TEXTEVT(ENTER, id, fn) #define EVT_TEXT_URL(id, fn) wx__DECLARE_TEXTURLEVT(URL, id, fn) #define EVT_TEXT_MAXLEN(id, fn) wx__DECLARE_TEXTEVT(MAXLEN, id, fn) @@ -871,7 +558,7 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); // C++ stream to the wxTextCtrl given to its ctor during its lifetime. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxStreamToTextRedirector +class WXDLLEXPORT wxStreamToTextRedirector { private: void Init(wxTextCtrl *text) @@ -908,12 +595,6 @@ private: #endif // wxHAS_TEXT_WINDOW_STREAM -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TEXT_UPDATED wxEVT_TEXT -#define wxEVT_COMMAND_TEXT_ENTER wxEVT_TEXT_ENTER -#define wxEVT_COMMAND_TEXT_URL wxEVT_TEXT_URL -#define wxEVT_COMMAND_TEXT_MAXLEN wxEVT_TEXT_MAXLEN - #endif // wxUSE_TEXTCTRL #endif diff --git a/Source/3rd Party/wx/include/wx/textdlg.h b/Source/3rd Party/wx/include/wx/textdlg.h index fcd35d9a3..787233d4f 100644 --- a/Source/3rd Party/wx/include/wx/textdlg.h +++ b/Source/3rd Party/wx/include/wx/textdlg.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/textdlg.h +// Name: textdlg.h // Purpose: wxTextEntryDialog class // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: textdlg.h 27408 2004-05-23 20:53:33Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,5 +14,10 @@ #include "wx/generic/textdlgg.h" +#if WXWIN_COMPATIBILITY_2_4 + // for wxGetNumberFromUser() + #include "wx/numdlg.h" +#endif // WXWIN_COMPATIBILITY_2_4 + #endif // _WX_TEXTDLG_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/textentry.h b/Source/3rd Party/wx/include/wx/textentry.h deleted file mode 100644 index 2707afa20..000000000 --- a/Source/3rd Party/wx/include/wx/textentry.h +++ /dev/null @@ -1,332 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/textentry.h -// Purpose: declares wxTextEntry interface defining a simple text entry -// Author: Vadim Zeitlin -// Created: 2007-09-24 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TEXTENTRY_H_ -#define _WX_TEXTENTRY_H_ - -// wxTextPos is the position in the text (currently it's hardly used anywhere -// and should probably be replaced with int anyhow) -typedef long wxTextPos; - -class WXDLLIMPEXP_FWD_BASE wxArrayString; -class WXDLLIMPEXP_FWD_CORE wxTextCompleter; -class WXDLLIMPEXP_FWD_CORE wxTextEntryHintData; -class WXDLLIMPEXP_FWD_CORE wxWindow; - -#include "wx/filefn.h" // for wxFILE and wxDIR only -#include "wx/gdicmn.h" // for wxPoint - -// ---------------------------------------------------------------------------- -// wxTextEntryBase -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextEntryBase -{ -public: - wxTextEntryBase() { m_eventsBlock = 0; m_hintData = NULL; } - virtual ~wxTextEntryBase(); - - - // accessing the value - // ------------------- - - // SetValue() generates a text change event, ChangeValue() doesn't - virtual void SetValue(const wxString& value) - { DoSetValue(value, SetValue_SendEvent); } - virtual void ChangeValue(const wxString& value); - - // writing text inserts it at the current position replacing any current - // selection, appending always inserts it at the end and doesn't remove any - // existing text (but it will reset the selection if there is any) - virtual void WriteText(const wxString& text) = 0; - virtual void AppendText(const wxString& text); - - virtual wxString GetValue() const; - virtual wxString GetRange(long from, long to) const; - bool IsEmpty() const { return GetLastPosition() <= 0; } - - - // editing operations - // ------------------ - - virtual void Replace(long from, long to, const wxString& value); - virtual void Remove(long from, long to) = 0; - virtual void Clear() { SetValue(wxString()); } - void RemoveSelection(); - - - // clipboard operations - // -------------------- - - virtual void Copy() = 0; - virtual void Cut() = 0; - virtual void Paste() = 0; - - virtual bool CanCopy() const; - virtual bool CanCut() const; - virtual bool CanPaste() const; - - // undo/redo - // --------- - - virtual void Undo() = 0; - virtual void Redo() = 0; - - virtual bool CanUndo() const = 0; - virtual bool CanRedo() const = 0; - - - // insertion point - // --------------- - - // note that moving insertion point removes any current selection - virtual void SetInsertionPoint(long pos) = 0; - virtual void SetInsertionPointEnd() { SetInsertionPoint(-1); } - virtual long GetInsertionPoint() const = 0; - virtual long GetLastPosition() const = 0; - - - // selection - // --------- - - virtual void SetSelection(long from, long to) = 0; - virtual void SelectAll() { SetSelection(-1, -1); } - virtual void SelectNone() - { const long pos = GetInsertionPoint(); SetSelection(pos, pos); } - virtual void GetSelection(long *from, long *to) const = 0; - bool HasSelection() const; - virtual wxString GetStringSelection() const; - - - // auto-completion - // --------------- - - // these functions allow to auto-complete the text already entered into the - // control using either the given fixed list of strings, the paths from the - // file system or an arbitrary user-defined completer - // - // they all return true if completion was enabled or false on error (most - // commonly meaning that this functionality is not available under the - // current platform) - - bool AutoComplete(const wxArrayString& choices) - { return DoAutoCompleteStrings(choices); } - - bool AutoCompleteFileNames() - { return DoAutoCompleteFileNames(wxFILE); } - - bool AutoCompleteDirectories() - { return DoAutoCompleteFileNames(wxDIR); } - - // notice that we take ownership of the pointer and will delete it - // - // if the pointer is NULL auto-completion is disabled - bool AutoComplete(wxTextCompleter *completer) - { return DoAutoCompleteCustom(completer); } - - - // status - // ------ - - virtual bool IsEditable() const = 0; - virtual void SetEditable(bool editable) = 0; - - - // set the max number of characters which may be entered in a single line - // text control - virtual void SetMaxLength(unsigned long WXUNUSED(len)) { } - - - // hints - // ----- - - // hint is the (usually greyed out) text shown in the control as long as - // it's empty and doesn't have focus, it is typically used in controls used - // for searching to let the user know what is supposed to be entered there - - virtual bool SetHint(const wxString& hint); - virtual wxString GetHint() const; - - - // margins - // ------- - - // margins are the empty space between borders of control and the text - // itself. When setting margin, use value -1 to indicate that specific - // margin should not be changed. - - bool SetMargins(const wxPoint& pt) - { return DoSetMargins(pt); } - bool SetMargins(wxCoord left, wxCoord top = -1) - { return DoSetMargins(wxPoint(left, top)); } - wxPoint GetMargins() const - { return DoGetMargins(); } - - - // implementation only - // ------------------- - - // generate the wxEVT_TEXT event for GetEditableWindow(), - // like SetValue() does and return true if the event was processed - // - // NB: this is public for wxRichTextCtrl use only right now, do not call it - static bool SendTextUpdatedEvent(wxWindow *win); - - // generate the wxEVT_TEXT event for this window - bool SendTextUpdatedEvent() - { - return SendTextUpdatedEvent(GetEditableWindow()); - } - - - // generate the wxEVT_TEXT event for this window if the - // events are not currently disabled - void SendTextUpdatedEventIfAllowed() - { - if ( EventsAllowed() ) - SendTextUpdatedEvent(); - } - - // this function is provided solely for the purpose of forwarding text - // change notifications state from one control to another, e.g. it can be - // used by a wxComboBox which derives from wxTextEntry if it delegates all - // of its methods to another wxTextCtrl - void ForwardEnableTextChangedEvents(bool enable) - { - // it's important to call the functions which update m_eventsBlock here - // and not just our own EnableTextChangedEvents() because our state - // (i.e. the result of EventsAllowed()) must change as well - if ( enable ) - ResumeTextChangedEvents(); - else - SuppressTextChangedEvents(); - } - -protected: - // flags for DoSetValue(): common part of SetValue() and ChangeValue() and - // also used to implement WriteText() in wxMSW - enum - { - SetValue_NoEvent = 0, - SetValue_SendEvent = 1, - SetValue_SelectionOnly = 2 - }; - - virtual void DoSetValue(const wxString& value, int flags); - virtual wxString DoGetValue() const = 0; - - // override this to return the associated window, it will be used for event - // generation and also by generic hints implementation - virtual wxWindow *GetEditableWindow() = 0; - - // margins functions - virtual bool DoSetMargins(const wxPoint& pt); - virtual wxPoint DoGetMargins() const; - - // the derived classes should override these virtual methods to implement - // auto-completion, they do the same thing as their public counterparts but - // have different names to allow overriding just one of them without hiding - // the other one(s) - virtual bool DoAutoCompleteStrings(const wxArrayString& WXUNUSED(choices)) - { return false; } - virtual bool DoAutoCompleteFileNames(int WXUNUSED(flags)) // wxFILE | wxDIR - { return false; } - virtual bool DoAutoCompleteCustom(wxTextCompleter *completer); - - - // class which should be used to temporarily disable text change events - // - // if suppress argument in ctor is false, nothing is done - class EventsSuppressor - { - public: - EventsSuppressor(wxTextEntryBase *text, bool suppress = true) - : m_text(text), - m_suppress(suppress) - { - if ( m_suppress ) - m_text->SuppressTextChangedEvents(); - } - - ~EventsSuppressor() - { - if ( m_suppress ) - m_text->ResumeTextChangedEvents(); - } - - private: - wxTextEntryBase *m_text; - bool m_suppress; - }; - - friend class EventsSuppressor; - -private: - // suppress or resume the text changed events generation: don't use these - // functions directly, use EventsSuppressor class above instead - void SuppressTextChangedEvents() - { - if ( !m_eventsBlock++ ) - EnableTextChangedEvents(false); - } - - void ResumeTextChangedEvents() - { - if ( !--m_eventsBlock ) - EnableTextChangedEvents(true); - } - - - // this must be overridden in the derived classes if our implementation of - // SetValue() or Replace() is used to disable (and enable back) generation - // of the text changed events - // - // initially the generation of the events is enabled - virtual void EnableTextChangedEvents(bool WXUNUSED(enable)) { } - - // return true if the events are currently not suppressed - bool EventsAllowed() const { return m_eventsBlock == 0; } - - - // if this counter is non-null, events are blocked - unsigned m_eventsBlock; - - // hint-related stuff, only allocated if/when SetHint() is used - wxTextEntryHintData *m_hintData; - - // It needs to call our Do{Get,Set}Value() to work with the real control - // contents. - friend class wxTextEntryHintData; -}; - -#ifdef __WXUNIVERSAL__ - // TODO: we need to use wxTextEntryDelegate here, but for now just prevent - // the GTK/MSW classes from being used in wxUniv build - class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase - { - }; -#elif defined(__WXGTK20__) - #include "wx/gtk/textentry.h" -#elif defined(__WXMAC__) - #include "wx/osx/textentry.h" -#elif defined(__WXMSW__) - #include "wx/msw/textentry.h" -#elif defined(__WXMOTIF__) - #include "wx/motif/textentry.h" -#elif defined(__WXPM__) - #include "wx/os2/textentry.h" -#else - // no platform-specific implementation of wxTextEntry yet - class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase - { - }; -#endif - -#endif // _WX_TEXTENTRY_H_ - diff --git a/Source/3rd Party/wx/include/wx/textfile.h b/Source/3rd Party/wx/include/wx/textfile.h index 77d039012..5d9bcdb4a 100644 --- a/Source/3rd Party/wx/include/wx/textfile.h +++ b/Source/3rd Party/wx/include/wx/textfile.h @@ -6,6 +6,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.04.98 +// RCS-ID: $Id: textfile.h 38570 2006-04-05 14:37:47Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -45,7 +46,7 @@ private: wxFile m_file; - wxDECLARE_NO_COPY_CLASS(wxTextFile); + DECLARE_NO_COPY_CLASS(wxTextFile) }; #else // !wxUSE_TEXTFILE diff --git a/Source/3rd Party/wx/include/wx/textwrapper.h b/Source/3rd Party/wx/include/wx/textwrapper.h deleted file mode 100644 index a708cebd7..000000000 --- a/Source/3rd Party/wx/include/wx/textwrapper.h +++ /dev/null @@ -1,128 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/textwrapper.h -// Purpose: declaration of wxTextWrapper class -// Author: Vadim Zeitlin -// Created: 2009-05-31 (extracted from dlgcmn.cpp via wx/private/stattext.h) -// Copyright: (c) 1999, 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TEXTWRAPPER_H_ -#define _WX_TEXTWRAPPER_H_ - -#include "wx/window.h" - -// ---------------------------------------------------------------------------- -// wxTextWrapper -// ---------------------------------------------------------------------------- - -// this class is used to wrap the text on word boundary: wrapping is done by -// calling OnStartLine() and OnOutputLine() functions -class WXDLLIMPEXP_CORE wxTextWrapper -{ -public: - wxTextWrapper() { m_eol = false; } - - // win is used for getting the font, text is the text to wrap, width is the - // max line width or -1 to disable wrapping - void Wrap(wxWindow *win, const wxString& text, int widthMax); - - // we don't need it, but just to avoid compiler warnings - virtual ~wxTextWrapper() { } - -protected: - // line may be empty - virtual void OnOutputLine(const wxString& line) = 0; - - // called at the start of every new line (except the very first one) - virtual void OnNewLine() { } - -private: - // call OnOutputLine() and set m_eol to true - void DoOutputLine(const wxString& line) - { - OnOutputLine(line); - - m_eol = true; - } - - // this function is a destructive inspector: when it returns true it also - // resets the flag to false so calling it again wouldn't return true any - // more - bool IsStartOfNewLine() - { - if ( !m_eol ) - return false; - - m_eol = false; - - return true; - } - - - bool m_eol; - - wxDECLARE_NO_COPY_CLASS(wxTextWrapper); -}; - -#if wxUSE_STATTEXT - -#include "wx/sizer.h" -#include "wx/stattext.h" - -// A class creating a sizer with one static text per line of text. Creation of -// the controls used for each line can be customized by overriding -// OnCreateLine() function. -// -// This class is currently private to wxWidgets and used only by wxDialog -// itself. We may make it public later if there is sufficient interest. -class wxTextSizerWrapper : public wxTextWrapper -{ -public: - wxTextSizerWrapper(wxWindow *win) - { - m_win = win; - m_hLine = 0; - } - - wxSizer *CreateSizer(const wxString& text, int widthMax) - { - m_sizer = new wxBoxSizer(wxVERTICAL); - Wrap(m_win, text, widthMax); - return m_sizer; - } - - wxWindow *GetParent() const { return m_win; } - -protected: - virtual wxWindow *OnCreateLine(const wxString& line) - { - return new wxStaticText(m_win, wxID_ANY, - wxControl::EscapeMnemonics(line)); - } - - virtual void OnOutputLine(const wxString& line) - { - if ( !line.empty() ) - { - m_sizer->Add(OnCreateLine(line)); - } - else // empty line, no need to create a control for it - { - if ( !m_hLine ) - m_hLine = m_win->GetCharHeight(); - - m_sizer->Add(5, m_hLine); - } - } - -private: - wxWindow *m_win; - wxSizer *m_sizer; - int m_hLine; -}; - -#endif // wxUSE_STATTEXT - -#endif // _WX_TEXTWRAPPER_H_ - diff --git a/Source/3rd Party/wx/include/wx/tglbtn.h b/Source/3rd Party/wx/include/wx/tglbtn.h index 265bc65a8..c20b9e4a0 100644 --- a/Source/3rd Party/wx/include/wx/tglbtn.h +++ b/Source/3rd Party/wx/include/wx/tglbtn.h @@ -5,8 +5,9 @@ // Author: John Norris, minor changes by Axel Schlueter // Modified by: // Created: 08.02.01 +// RCS-ID: $Id: tglbtn.h 39293 2006-05-23 17:53:50Z JS $ // Copyright: (c) 2000 Johnny C. Norris II -// Licence: wxWindows Licence +// License: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TOGGLEBUTTON_H_BASE_ @@ -17,84 +18,33 @@ #if wxUSE_TOGGLEBTN #include "wx/event.h" -#include "wx/anybutton.h" // base class - -extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[]; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOGGLEBUTTON, wxCommandEvent ); - -// ---------------------------------------------------------------------------- -// wxToggleButtonBase -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxToggleButtonBase : public wxAnyButton -{ -public: - wxToggleButtonBase() { } - - // Get/set the value - virtual void SetValue(bool state) = 0; - virtual bool GetValue() const = 0; - - void UpdateWindowUI(long flags) - { - wxControl::UpdateWindowUI(flags); - - if ( !IsShown() ) - return; - - wxWindow *tlw = wxGetTopLevelParent( this ); - if (tlw && wxPendingDelete.Member( tlw )) - return; - - wxUpdateUIEvent event( GetId() ); - event.SetEventObject(this); - - if (GetEventHandler()->ProcessEvent(event) ) - { - if ( event.GetSetChecked() ) - SetValue( event.GetChecked() ); - } - } - - // Buttons on MSW can look bad if they are not native colours, because - // then they become owner-drawn and not theme-drawn. Disable it here - // in wxToggleButtonBase to make it consistent. - virtual bool ShouldInheritColours() const { return false; } - -protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - - wxDECLARE_NO_COPY_CLASS(wxToggleButtonBase); -}; +#include "wx/control.h" // base class +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, 19) +END_DECLARE_EVENT_TYPES() #define EVT_TOGGLEBUTTON(id, fn) \ - wx__DECLARE_EVT1(wxEVT_TOGGLEBUTTON, id, wxCommandEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, wxCommandEventHandler(fn)) #if defined(__WXUNIVERSAL__) #include "wx/univ/tglbtn.h" #elif defined(__WXMSW__) #include "wx/msw/tglbtn.h" - #define wxHAS_BITMAPTOGGLEBUTTON #elif defined(__WXGTK20__) #include "wx/gtk/tglbtn.h" - #define wxHAS_BITMAPTOGGLEBUTTON #elif defined(__WXGTK__) #include "wx/gtk1/tglbtn.h" # elif defined(__WXMOTIF__) #include "wx/motif/tglbtn.h" #elif defined(__WXMAC__) - #include "wx/osx/tglbtn.h" - #define wxHAS_BITMAPTOGGLEBUTTON + #include "wx/mac/tglbtn.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/tglbtn.h" #elif defined(__WXPM__) #include "wx/os2/tglbtn.h" #endif -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TOGGLEBUTTON_CLICKED wxEVT_TOGGLEBUTTON - #endif // wxUSE_TOGGLEBTN #endif // _WX_TOGGLEBUTTON_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/thread.h b/Source/3rd Party/wx/include/wx/thread.h index c059ee27d..bd913fe81 100644 --- a/Source/3rd Party/wx/include/wx/thread.h +++ b/Source/3rd Party/wx/include/wx/thread.h @@ -5,6 +5,7 @@ // Modified by: Vadim Zeitlin (modifications partly inspired by omnithreads // package from Olivetti & Oracle Research Laboratory) // Created: 04/13/98 +// RCS-ID: $Id: thread.h 66924 2011-02-16 22:58:53Z JS $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,6 +22,11 @@ #if wxUSE_THREADS +// Windows headers define it +#ifdef Yield + #undef Yield +#endif + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -32,7 +38,6 @@ enum wxMutexError wxMUTEX_DEAD_LOCK, // mutex is already locked by the calling thread wxMUTEX_BUSY, // mutex is already locked by another thread wxMUTEX_UNLOCKED, // attempt to unlock a mutex which is not locked - wxMUTEX_TIMEOUT, // LockTimeout() has timed out wxMUTEX_MISC_ERROR // any other error }; @@ -70,27 +75,12 @@ enum wxThreadKind wxTHREAD_JOINABLE }; -enum wxThreadWait -{ - wxTHREAD_WAIT_BLOCK, - wxTHREAD_WAIT_YIELD, // process events while waiting; MSW only - - // For compatibility reasons we use wxTHREAD_WAIT_YIELD by default as this - // was the default behaviour of wxMSW 2.8 but it should be avoided as it's - // dangerous and not portable. -#if WXWIN_COMPATIBILITY_2_8 - wxTHREAD_WAIT_DEFAULT = wxTHREAD_WAIT_YIELD -#else - wxTHREAD_WAIT_DEFAULT = wxTHREAD_WAIT_BLOCK -#endif -}; - -// Obsolete synonyms for wxPRIORITY_XXX for backwards compatibility-only +// defines the interval of priority enum { - WXTHREAD_MIN_PRIORITY = wxPRIORITY_MIN, - WXTHREAD_DEFAULT_PRIORITY = wxPRIORITY_DEFAULT, - WXTHREAD_MAX_PRIORITY = wxPRIORITY_MAX + WXTHREAD_MIN_PRIORITY = 0u, + WXTHREAD_DEFAULT_PRIORITY = 50u, + WXTHREAD_MAX_PRIORITY = 100u }; // There are 2 types of mutexes: normal mutexes and recursive ones. The attempt @@ -159,10 +149,6 @@ public: // The caller must call Unlock() later if Lock() returned wxMUTEX_NO_ERROR. wxMutexError Lock(); - // Same as Lock() but return wxMUTEX_TIMEOUT if the mutex can't be locked - // during the given number of milliseconds - wxMutexError LockTimeout(unsigned long ms); - // Try to lock the mutex: if it is currently locked, return immediately // with an error. Otherwise the caller must call Unlock(). wxMutexError TryLock(); @@ -175,7 +161,7 @@ protected: friend class wxConditionInternal; - wxDECLARE_NO_COPY_CLASS(wxMutex); + DECLARE_NO_COPY_CLASS(wxMutex) }; // a helper class which locks the mutex in the ctor and unlocks it in the dtor: @@ -218,46 +204,35 @@ private: // in order to avoid any overhead under platforms where critical sections are // just mutexes make all wxCriticalSection class functions inline -#if !defined(__WINDOWS__) +#if !defined(__WXMSW__) && !defined(__WXMAC__) #define wxCRITSECT_IS_MUTEX 1 - #define wxCRITSECT_INLINE WXEXPORT inline + #define wxCRITSECT_INLINE inline #else // MSW #define wxCRITSECT_IS_MUTEX 0 #define wxCRITSECT_INLINE #endif // MSW/!MSW -enum wxCriticalSectionType -{ - // recursive critical section - wxCRITSEC_DEFAULT, - - // non-recursive critical section - wxCRITSEC_NON_RECURSIVE -}; - // you should consider wxCriticalSectionLocker whenever possible instead of // directly working with wxCriticalSection class - it is safer class WXDLLIMPEXP_BASE wxCriticalSection { public: // ctor & dtor - wxCRITSECT_INLINE wxCriticalSection( wxCriticalSectionType critSecType = wxCRITSEC_DEFAULT ); + wxCRITSECT_INLINE wxCriticalSection(); wxCRITSECT_INLINE ~wxCriticalSection(); + // enter the section (the same as locking a mutex) wxCRITSECT_INLINE void Enter(); - // try to enter the section (the same as trying to lock a mutex) - wxCRITSECT_INLINE bool TryEnter(); - // leave the critical section (same as unlocking a mutex) wxCRITSECT_INLINE void Leave(); private: #if wxCRITSECT_IS_MUTEX wxMutex m_mutex; -#elif defined(__WINDOWS__) +#elif defined(__WXMSW__) // we can't allocate any memory in the ctor, so use placement new - // unfortunately, we have to hardcode the sizeof() here because we can't // include windows.h from this public header and we also have to use the @@ -265,6 +240,10 @@ private: // // if CRITICAL_SECTION size changes in Windows, you'll get an assert from // thread.cpp and will need to increase the buffer size + // + // finally, we need this typedef instead of declaring m_buffer directly + // because otherwise the assert mentioned above wouldn't compile with some + // compilers (notably CodeWarrior 8) #ifdef __WIN64__ typedef char wxCritSectBuffer[40]; #else // __WIN32__ @@ -277,19 +256,19 @@ private: wxCritSectBuffer m_buffer; }; +#elif defined(__WXMAC__) + void *m_critRegion ; #endif // Unix&OS2/Win32 - wxDECLARE_NO_COPY_CLASS(wxCriticalSection); + DECLARE_NO_COPY_CLASS(wxCriticalSection) }; #if wxCRITSECT_IS_MUTEX // implement wxCriticalSection using mutexes - inline wxCriticalSection::wxCriticalSection( wxCriticalSectionType critSecType ) - : m_mutex( critSecType == wxCRITSEC_DEFAULT ? wxMUTEX_RECURSIVE : wxMUTEX_DEFAULT ) { } + inline wxCriticalSection::wxCriticalSection() { } inline wxCriticalSection::~wxCriticalSection() { } inline void wxCriticalSection::Enter() { (void)m_mutex.Lock(); } - inline bool wxCriticalSection::TryEnter() { return m_mutex.TryLock() == wxMUTEX_NO_ERROR; } inline void wxCriticalSection::Leave() { (void)m_mutex.Unlock(); } #endif // wxCRITSECT_IS_MUTEX @@ -315,7 +294,7 @@ public: private: wxCriticalSection& m_critsect; - wxDECLARE_NO_COPY_CLASS(wxCriticalSectionLocker); + DECLARE_NO_COPY_CLASS(wxCriticalSectionLocker) }; // ---------------------------------------------------------------------------- @@ -344,23 +323,10 @@ public: // the lock on the associated mutex object, before returning. wxCondError Wait(); - // std::condition_variable-like variant that evaluates the associated condition - template - wxCondError Wait(const Functor& predicate) - { - while ( !predicate() ) - { - wxCondError e = Wait(); - if ( e != wxCOND_NO_ERROR ) - return e; - } - return wxCOND_NO_ERROR; - } - // exactly as Wait() except that it may also return if the specified // timeout elapses even if the condition hasn't been signalled: in this - // case, the return value is wxCOND_TIMEOUT, otherwise (i.e. in case of a - // normal return) it is wxCOND_NO_ERROR. + // case, the return value is false, otherwise (i.e. in case of a normal + // return) it is true // // the timeout parameter specifies an interval that needs to be waited for // in milliseconds @@ -391,7 +357,7 @@ public: private: wxConditionInternal *m_internal; - wxDECLARE_NO_COPY_CLASS(wxCondition); + DECLARE_NO_COPY_CLASS(wxCondition) }; #if WXWIN_COMPATIBILITY_2_6 @@ -436,7 +402,7 @@ public: private: wxSemaphoreInternal *m_internal; - wxDECLARE_NO_COPY_CLASS(wxSemaphore); + DECLARE_NO_COPY_CLASS(wxSemaphore) }; // ---------------------------------------------------------------------------- @@ -474,24 +440,14 @@ public: static wxThread *This(); // Returns true if current thread is the main thread. - // - // Notice that it also returns true if main thread id hadn't been - // initialized yet on the assumption that it's too early in wx startup - // process for any other threads to have been created in this case. - static bool IsMain() - { - return !ms_idMainThread || GetCurrentId() == ms_idMainThread; - } - - // Return the main thread id - static wxThreadIdType GetMainId() { return ms_idMainThread; } + static bool IsMain(); // Release the rest of our time slice letting the other threads run static void Yield(); // Sleep during the specified period of time in milliseconds // - // This is the same as wxMilliSleep(). + // NB: at least under MSW worker threads can not call ::wxSleep()! static void Sleep(unsigned long milliseconds); // get the number of system CPUs - useful with SetConcurrency() @@ -503,7 +459,7 @@ public: // Get the platform specific thread ID and return as a long. This // can be used to uniquely identify threads, even if they are not // wxThreads. This is used by wxPython. - static wxThreadIdType GetCurrentId(); + static wxThreadIdType GetCurrentId(); // sets the concurrency level: this is, roughly, the number of threads // the system tries to schedule to run in parallel. 0 means the @@ -543,14 +499,13 @@ public: // does it! // // will fill the rc pointer with the thread exit code if it's !NULL - wxThreadError Delete(ExitCode *rc = NULL, - wxThreadWait waitMode = wxTHREAD_WAIT_DEFAULT); + wxThreadError Delete(ExitCode *rc = (ExitCode *)NULL); // waits for a joinable thread to finish and returns its exit code // // Returns (ExitCode)-1 on error (for example, if the thread is not // joinable) - ExitCode Wait(wxThreadWait waitMode = wxTHREAD_WAIT_DEFAULT); + ExitCode Wait(); // kills the thread without giving it any chance to clean up - should // not be used under normal circumstances, use Delete() instead. @@ -570,8 +525,7 @@ public: wxThreadError Resume(); // priority - // Sets the priority to "prio" which must be in 0..100 range (see - // also wxPRIORITY_XXX constants). + // Sets the priority to "prio": see WXTHREAD_XXX_PRIORITY constants // // NB: the priority can only be set before the thread is created void SetPriority(unsigned int prio); @@ -594,8 +548,10 @@ public: // identifies a thread inside a process wxThreadIdType GetId() const; - wxThreadKind GetKind() const - { return m_isDetached ? wxTHREAD_DETACHED : wxTHREAD_JOINABLE; } + // called when the thread exits - in the context of this thread + // + // NB: this function will not be called if the thread is Kill()ed + virtual void OnExit() { } // Returns true if the thread was asked to terminate: this function should // be called by the thread from time to time, otherwise the main thread @@ -614,37 +570,12 @@ protected: // of this thread. virtual void *Entry() = 0; - // use this to call the Entry() virtual method - void *CallEntry(); - - // Callbacks which may be overridden by the derived class to perform some - // specific actions when the thread is deleted or killed. By default they - // do nothing. - - // This one is called by Delete() before actually deleting the thread and - // is executed in the context of the thread that called Delete(). - virtual void OnDelete() {} - - // This one is called by Kill() before killing the thread and is executed - // in the context of the thread that called Kill(). - virtual void OnKill() {} - private: // no copy ctor/assignment operator wxThread(const wxThread&); wxThread& operator=(const wxThread&); - // called when the thread exits - in the context of this thread - // - // NB: this function will not be called if the thread is Kill()ed - virtual void OnExit() { } - friend class wxThreadInternal; - friend class wxThreadModule; - - - // the main thread identifier, should be set on startup - static wxThreadIdType ms_idMainThread; // the (platform-dependent) thread class implementation wxThreadInternal *m_internal; @@ -664,8 +595,8 @@ class WXDLLIMPEXP_BASE wxThreadHelperThread : public wxThread public: // constructor only creates the C++ thread object and doesn't create (or // start) the real thread - wxThreadHelperThread(wxThreadHelper& owner, wxThreadKind kind) - : wxThread(kind), m_owner(owner) + wxThreadHelperThread(wxThreadHelper& owner) + : wxThread(wxTHREAD_JOINABLE), m_owner(owner) { } protected: @@ -692,44 +623,27 @@ class WXDLLIMPEXP_BASE wxThreadHelper private: void KillThread() { - // If wxThreadHelperThread is detached and is about to finish, it will - // set m_thread to NULL so don't delete it then. - // But if KillThread is called before wxThreadHelperThread (in detached mode) - // sets it to NULL, then the thread object still exists and can be killed - wxCriticalSectionLocker locker(m_critSection); - if ( m_thread ) { m_thread->Kill(); - - if ( m_kind == wxTHREAD_JOINABLE ) - delete m_thread; - - m_thread = NULL; + delete m_thread; } } public: // constructor only initializes m_thread to NULL - wxThreadHelper(wxThreadKind kind = wxTHREAD_JOINABLE) - : m_thread(NULL), m_kind(kind) { } + wxThreadHelper() : m_thread(NULL) { } // destructor deletes m_thread virtual ~wxThreadHelper() { KillThread(); } -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( wxThreadError Create(unsigned int stackSize = 0) ); -#endif - // create a new thread (and optionally set the stack size on platforms that // support/need that), call Run() to start it - wxThreadError CreateThread(wxThreadKind kind = wxTHREAD_JOINABLE, - unsigned int stackSize = 0) + wxThreadError Create(unsigned int stackSize = 0) { KillThread(); - m_kind = kind; - m_thread = new wxThreadHelperThread(*this, m_kind); + m_thread = new wxThreadHelperThread(*this); return m_thread->Create(stackSize); } @@ -739,43 +653,16 @@ public: virtual void *Entry() = 0; // returns a pointer to the thread which can be used to call Run() - wxThread *GetThread() const - { - wxCriticalSectionLocker locker((wxCriticalSection&)m_critSection); - - wxThread* thread = m_thread; - - return thread; - } + wxThread *GetThread() const { return m_thread; } protected: wxThread *m_thread; - wxThreadKind m_kind; - wxCriticalSection m_critSection; // To guard the m_thread variable - - friend class wxThreadHelperThread; }; -#if WXWIN_COMPATIBILITY_2_8 -inline wxThreadError wxThreadHelper::Create(unsigned int stackSize) -{ return CreateThread(m_kind, stackSize); } -#endif - // call Entry() in owner, put it down here to avoid circular declarations inline void *wxThreadHelperThread::Entry() { - void * const result = m_owner.Entry(); - - wxCriticalSectionLocker locker(m_owner.m_critSection); - - // Detached thread will be deleted after returning, so make sure - // wxThreadHelper::GetThread will not return an invalid pointer. - // And that wxThreadHelper::KillThread will not try to kill - // an already deleted thread - if ( m_owner.m_kind == wxTHREAD_DETACHED ) - m_owner.m_thread = NULL; - - return result; + return m_owner.Entry(); } // ---------------------------------------------------------------------------- @@ -801,8 +688,8 @@ inline bool wxIsMainThread() { return wxThread::IsMain(); } #else // !wxUSE_THREADS // no thread support -inline void wxMutexGuiEnter() { } -inline void wxMutexGuiLeave() { } +inline void WXDLLIMPEXP_BASE wxMutexGuiEnter() { } +inline void WXDLLIMPEXP_BASE wxMutexGuiLeave() { } // macros for entering/leaving critical sections which may be used without // having to take them inside "#if wxUSE_THREADS" @@ -855,7 +742,7 @@ public: #if wxUSE_THREADS -#if defined(__WINDOWS__) || defined(__OS2__) || defined(__EMX__) || defined(__DARWIN__) +#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__OS2__) || defined(__EMX__) // unlock GUI if there are threads waiting for and lock it back when // there are no more of them - should be called periodically by the main // thread @@ -867,12 +754,10 @@ public: // wakes up the main thread if it's sleeping inside ::GetMessage() extern void WXDLLIMPEXP_BASE wxWakeUpMainThread(); -#ifndef __DARWIN__ // return true if the main thread is waiting for some other to terminate: // wxApp then should block all "dangerous" messages extern bool WXDLLIMPEXP_BASE wxIsWaitingForThread(); -#endif -#endif // MSW, OS/2 +#endif // MSW, Mac, OS/2 #endif // wxUSE_THREADS diff --git a/Source/3rd Party/wx/include/wx/thrimpl.cpp b/Source/3rd Party/wx/include/wx/thrimpl.cpp index deec2c422..27780b8ab 100644 --- a/Source/3rd Party/wx/include/wx/thrimpl.cpp +++ b/Source/3rd Party/wx/include/wx/thrimpl.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/thrimpl.cpp +// Name: include/wx/thrimpl.cpp // Purpose: common part of wxThread Implementations // Author: Vadim Zeitlin // Modified by: // Created: 04.06.02 (extracted from src/*/thread.cpp files) +// RCS-ID: $Id: thrimpl.cpp 66922 2011-02-16 22:26:57Z JS $ // Copyright: (c) Vadim Zeitlin (2002) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -43,14 +44,6 @@ wxMutexError wxMutex::Lock() return m_internal->Lock(); } -wxMutexError wxMutex::LockTimeout(unsigned long ms) -{ - wxCHECK_MSG( m_internal, wxMUTEX_INVALID, - wxT("wxMutex::Lock(): not initialized") ); - - return m_internal->Lock(ms); -} - wxMutexError wxMutex::TryLock() { wxCHECK_MSG( m_internal, wxMUTEX_INVALID, @@ -75,7 +68,7 @@ wxMutexError wxMutex::Unlock() // variables and their events/event semaphores have quite different semantics, // so we reimplement the conditions from scratch using the mutexes and // semaphores -#if defined(__WINDOWS__) || defined(__OS2__) || defined(__EMX__) +#if defined(__WXMSW__) || defined(__OS2__) || defined(__EMX__) class wxConditionInternal { @@ -100,7 +93,7 @@ private: wxMutex& m_mutex; wxSemaphore m_semaphore; - wxDECLARE_NO_COPY_CLASS(wxConditionInternal); + DECLARE_NO_COPY_CLASS(wxConditionInternal) }; wxConditionInternal::wxConditionInternal(wxMutex& mutex) @@ -222,7 +215,7 @@ wxCondError wxConditionInternal::Broadcast() return wxCOND_NO_ERROR; } -#endif // __WINDOWS__ || __OS2__ || __EMX__ +#endif // MSW or OS2 // ---------------------------------------------------------------------------- // wxCondition @@ -337,21 +330,3 @@ wxSemaError wxSemaphore::Post() return m_internal->Post(); } -// ---------------------------------------------------------------------------- -// wxThread -// ---------------------------------------------------------------------------- - -#include "wx/utils.h" -#include "wx/private/threadinfo.h" -#include "wx/scopeguard.h" - -void wxThread::Sleep(unsigned long milliseconds) -{ - wxMilliSleep(milliseconds); -} - -void *wxThread::CallEntry() -{ - wxON_BLOCK_EXIT0(wxThreadSpecificInfo::ThreadCleanUp); - return Entry(); -} diff --git a/Source/3rd Party/wx/include/wx/time.h b/Source/3rd Party/wx/include/wx/time.h deleted file mode 100644 index 644422392..000000000 --- a/Source/3rd Party/wx/include/wx/time.h +++ /dev/null @@ -1,76 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/time.h -// Purpose: Miscellaneous time-related functions. -// Author: Vadim Zeitlin -// Created: 2011-11-26 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TIME_H_ -#define _WX_TIME_H_ - -#include "wx/longlong.h" - -// Returns the difference between UTC and local time in seconds. -WXDLLIMPEXP_BASE int wxGetTimeZone(); - -// Get number of seconds since local time 00:00:00 Jan 1st 1970. -extern long WXDLLIMPEXP_BASE wxGetLocalTime(); - -// Get number of seconds since GMT 00:00:00, Jan 1st 1970. -extern long WXDLLIMPEXP_BASE wxGetUTCTime(); - -#if wxUSE_LONGLONG - typedef wxLongLong wxMilliClock_t; - inline long wxMilliClockToLong(wxLongLong ll) { return ll.ToLong(); } -#else - typedef double wxMilliClock_t; - inline long wxMilliClockToLong(double d) { return wx_truncate_cast(long, d); } -#endif // wxUSE_LONGLONG - -// Get number of milliseconds since local time 00:00:00 Jan 1st 1970 -extern wxMilliClock_t WXDLLIMPEXP_BASE wxGetLocalTimeMillis(); - -#if wxUSE_LONGLONG - -// Get the number of milliseconds or microseconds since the Epoch. -wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeMillis(); -wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeUSec(); - -#endif // wxUSE_LONGLONG - -#define wxGetCurrentTime() wxGetLocalTime() - -// on some really old systems gettimeofday() doesn't have the second argument, -// define wxGetTimeOfDay() to hide this difference -#ifdef HAVE_GETTIMEOFDAY - #ifdef WX_GETTIMEOFDAY_NO_TZ - #define wxGetTimeOfDay(tv) gettimeofday(tv) - #else - #define wxGetTimeOfDay(tv) gettimeofday((tv), NULL) - #endif -#endif // HAVE_GETTIMEOFDAY - -/* Two wrapper functions for thread safety */ -#ifdef HAVE_LOCALTIME_R -#define wxLocaltime_r localtime_r -#else -WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*); -#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__) - // On Windows, localtime _is_ threadsafe! -#warning using pseudo thread-safe wrapper for localtime to emulate localtime_r -#endif -#endif - -#ifdef HAVE_GMTIME_R -#define wxGmtime_r gmtime_r -#else -WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*); -#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__) - // On Windows, gmtime _is_ threadsafe! -#warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r -#endif -#endif - -#endif // _WX_TIME_H_ diff --git a/Source/3rd Party/wx/include/wx/timectrl.h b/Source/3rd Party/wx/include/wx/timectrl.h deleted file mode 100644 index 928d9aedf..000000000 --- a/Source/3rd Party/wx/include/wx/timectrl.h +++ /dev/null @@ -1,124 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/timectrl.h -// Purpose: Declaration of wxTimePickerCtrl class. -// Author: Vadim Zeitlin -// Created: 2011-09-22 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TIMECTRL_H_ -#define _WX_TIMECTRL_H_ - -#include "wx/defs.h" - -#if wxUSE_TIMEPICKCTRL - -#include "wx/datetimectrl.h" - -#define wxTimePickerCtrlNameStr wxS("timectrl") - -// No special styles are currently defined for this control but still define a -// symbolic constant for the default style for consistency. -enum -{ - wxTP_DEFAULT = 0 -}; - -// ---------------------------------------------------------------------------- -// wxTimePickerCtrl: Allow the user to enter the time. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxTimePickerCtrlBase : public wxDateTimePickerCtrl -{ -public: - /* - The derived classes should implement ctor and Create() method with the - following signature: - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr); - */ - - /* - We also inherit Set/GetValue() methods from the base class which define - our public API. Notice that the date portion of the date passed as - input or received as output is or should be ignored, only the time part - of wxDateTime objects is really significant here. Use Set/GetTime() - below for possibly simpler interface. - */ - - // Set the given time. - bool SetTime(int hour, int min, int sec) - { - // Notice that we should use a date on which DST doesn't change to - // avoid any problems with time discontinuity so use a fixed date (on - // which nobody changes DST) instead of e.g. today. - wxDateTime dt(1, wxDateTime::Jan, 2012, hour, min, sec); - if ( !dt.IsValid() ) - { - // No need to assert here, wxDateTime already does it for us. - return false; - } - - SetValue(dt); - - return true; - } - - // Get the current time components. All pointers must be non-NULL. - bool GetTime(int* hour, int* min, int* sec) const - { - wxCHECK_MSG( hour && min && sec, false, - wxS("Time component pointers must be non-NULL") ); - - const wxDateTime::Tm tm = GetValue().GetTm(); - *hour = tm.hour; - *min = tm.min; - *sec = tm.sec; - - return true; - } -}; - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/timectrl.h" - - #define wxHAS_NATIVE_TIMEPICKERCTRL -#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__) - #include "wx/osx/timectrl.h" - - #define wxHAS_NATIVE_TIMEPICKERCTRL -#else - #include "wx/generic/timectrl.h" - - class WXDLLIMPEXP_ADV wxTimePickerCtrl : public wxTimePickerCtrlGeneric - { - public: - wxTimePickerCtrl() { } - wxTimePickerCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTP_DEFAULT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTimePickerCtrlNameStr) - : wxTimePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name) - { - } - - private: - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTimePickerCtrl); - }; -#endif - -#endif // wxUSE_TIMEPICKCTRL - -#endif // _WX_TIMECTRL_H_ diff --git a/Source/3rd Party/wx/include/wx/timer.h b/Source/3rd Party/wx/include/wx/timer.h index e8f4f0f09..f81cd3860 100644 --- a/Source/3rd Party/wx/include/wx/timer.h +++ b/Source/3rd Party/wx/include/wx/timer.h @@ -5,6 +5,7 @@ // Modified by: Vadim Zeitlin (wxTimerBase) // Guillermo Rodriguez (global clean up) // Created: 04/01/98 +// RCS-ID: $Id: timer.h 44244 2007-01-18 17:00:52Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,13 +15,13 @@ #include "wx/defs.h" -#if wxUSE_TIMER +#if wxUSE_GUI && wxUSE_TIMER #include "wx/object.h" #include "wx/longlong.h" #include "wx/event.h" #include "wx/stopwatch.h" // for backwards compatibility -#include "wx/utils.h" +#include "wx/window.h" // only for NewControlId() // more readable flags for Start(): @@ -31,14 +32,8 @@ // only send the notification once and then stop the timer #define wxTIMER_ONE_SHOT true -class WXDLLIMPEXP_FWD_BASE wxTimerImpl; -class WXDLLIMPEXP_FWD_BASE wxTimerEvent; - -// timer event type -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_TIMER, wxTimerEvent); - // the interface of wxTimer class -class WXDLLIMPEXP_BASE wxTimer : public wxEvtHandler +class WXDLLEXPORT wxTimerBase : public wxEvtHandler { public: // ctors and initializers @@ -46,33 +41,29 @@ public: // default: if you don't call SetOwner(), your only chance to get timer // notifications is to override Notify() in the derived class - wxTimer() - { - Init(); - SetOwner(this); - } + wxTimerBase() + { Init(); SetOwner(this); } // ctor which allows to avoid having to override Notify() in the derived // class: the owner will get timer notifications which can be handled with // EVT_TIMER - wxTimer(wxEvtHandler *owner, int timerid = wxID_ANY) - { - Init(); - SetOwner(owner, timerid); - } + wxTimerBase(wxEvtHandler *owner, int timerid = wxID_ANY) + { Init(); SetOwner(owner, timerid); } // same as ctor above - void SetOwner(wxEvtHandler *owner, int timerid = wxID_ANY); + void SetOwner(wxEvtHandler *owner, int timerid = wxID_ANY) + { + m_owner = owner; + m_idTimer = timerid == wxID_ANY ? wxWindow::NewControlId() : timerid; + } - virtual ~wxTimer(); + wxEvtHandler *GetOwner() const { return m_owner; } + virtual ~wxTimerBase(); // working with the timer // ---------------------- - // NB: Start() and Stop() are not supposed to be overridden, they are only - // virtual for historical reasons, only Notify() can be overridden - // start the timer: if milliseconds == -1, use the same value as for the // last Start() // @@ -80,50 +71,68 @@ public: // timer if it is already running virtual bool Start(int milliseconds = -1, bool oneShot = false); - // start the timer for one iteration only, this is just a simple wrapper - // for Start() - bool StartOnce(int milliseconds = -1) { return Start(milliseconds, true); } - - // stop the timer, does nothing if the timer is not running - virtual void Stop(); + // stop the timer + virtual void Stop() = 0; // override this in your wxTimer-derived class if you want to process timer // messages in it, use non default ctor or SetOwner() otherwise virtual void Notify(); - - // accessors - // --------- - - // get the object notified about the timer events - wxEvtHandler *GetOwner() const; + // getting info + // ------------ // return true if the timer is running - bool IsRunning() const; + virtual bool IsRunning() const = 0; // return the timer ID - int GetId() const; + int GetId() const { return m_idTimer; } // get the (last) timer interval in milliseconds - int GetInterval() const; + int GetInterval() const { return m_milli; } // return true if the timer is one shot - bool IsOneShot() const; + bool IsOneShot() const { return m_oneShot; } protected: // common part of all ctors - void Init(); + void Init() + { m_owner = NULL; m_idTimer = wxID_ANY; m_milli = 0; m_oneShot = false; } - wxTimerImpl *m_impl; + wxEvtHandler *m_owner; + int m_idTimer; + int m_milli; // the timer interval + bool m_oneShot; // true if one shot - wxDECLARE_NO_COPY_CLASS(wxTimer); + DECLARE_NO_COPY_CLASS(wxTimerBase) }; +// ---------------------------------------------------------------------------- +// wxTimer itself +// ---------------------------------------------------------------------------- + +#if defined(__WXMSW__) + #include "wx/msw/timer.h" +#elif defined(__WXMOTIF__) + #include "wx/motif/timer.h" +#elif defined(__WXGTK20__) + #include "wx/gtk/timer.h" +#elif defined(__WXGTK__) + #include "wx/gtk1/timer.h" +#elif defined(__WXX11__) || defined(__WXMGL__) || defined(__WXDFB__) + #include "wx/generic/timer.h" +#elif defined (__WXCOCOA__) + #include "wx/cocoa/timer.h" +#elif defined(__WXMAC__) + #include "wx/mac/timer.h" +#elif defined(__WXPM__) + #include "wx/os2/timer.h" +#endif + // ---------------------------------------------------------------------------- // wxTimerRunner: starts the timer in its ctor, stops in the dtor // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxTimerRunner +class WXDLLEXPORT wxTimerRunner { public: wxTimerRunner(wxTimer& timer) : m_timer(timer) { } @@ -149,36 +158,31 @@ public: private: wxTimer& m_timer; - wxDECLARE_NO_COPY_CLASS(wxTimerRunner); + DECLARE_NO_COPY_CLASS(wxTimerRunner) }; // ---------------------------------------------------------------------------- // wxTimerEvent // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxTimerEvent : public wxEvent +class WXDLLEXPORT wxTimerEvent : public wxEvent { public: - wxTimerEvent() - : wxEvent(wxID_ANY, wxEVT_TIMER) { m_timer=NULL; } - - wxTimerEvent(wxTimer& timer) - : wxEvent(timer.GetId(), wxEVT_TIMER), - m_timer(&timer) + wxTimerEvent(int timerid = 0, int interval = 0) : wxEvent(timerid) { - SetEventObject(timer.GetOwner()); + m_eventType = wxEVT_TIMER; + + m_interval = interval; } // accessors - int GetInterval() const { return m_timer->GetInterval(); } - wxTimer& GetTimer() const { return *m_timer; } + int GetInterval() const { return m_interval; } // implement the base class pure virtual virtual wxEvent *Clone() const { return new wxTimerEvent(*this); } - virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_TIMER; } private: - wxTimer* m_timer; + int m_interval; DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTimerEvent) }; @@ -186,11 +190,12 @@ private: typedef void (wxEvtHandler::*wxTimerEventFunction)(wxTimerEvent&); #define wxTimerEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxTimerEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTimerEventFunction, &func) #define EVT_TIMER(timerid, func) \ wx__DECLARE_EVT1(wxEVT_TIMER, timerid, wxTimerEventHandler(func)) -#endif // wxUSE_TIMER +#endif // wxUSE_GUI && wxUSE_TIMER -#endif // _WX_TIMER_H_BASE_ +#endif + // _WX_TIMER_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/tipdlg.h b/Source/3rd Party/wx/include/wx/tipdlg.h deleted file mode 100644 index e0093855f..000000000 --- a/Source/3rd Party/wx/include/wx/tipdlg.h +++ /dev/null @@ -1,85 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/tipdlg.h -// Purpose: declaration of wxTipDialog -// Author: Vadim Zeitlin -// Modified by: -// Created: 28.06.99 -// Copyright: (c) Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TIPDLG_H_ -#define _WX_TIPDLG_H_ - -// ---------------------------------------------------------------------------- -// headers which we must include here -// ---------------------------------------------------------------------------- - -#include "wx/defs.h" - -#if wxUSE_STARTUP_TIPS - -#include "wx/textfile.h" - -// ---------------------------------------------------------------------------- -// wxTipProvider - a class which is used by wxTipDialog to get the text of the -// tips -// ---------------------------------------------------------------------------- - -// the abstract base class: it provides the tips, i.e. implements the GetTip() -// function which returns the new tip each time it's called. To support this, -// wxTipProvider evidently needs some internal state which is the tip "index" -// and which should be saved/restored by the program to not always show one and -// the same tip (of course, you may use random starting position as well...) -class WXDLLIMPEXP_ADV wxTipProvider -{ -public: - wxTipProvider(size_t currentTip) { m_currentTip = currentTip; } - - // get the current tip and update the internal state to return the next tip - // when called for the next time - virtual wxString GetTip() = 0; - - // get the current tip "index" (or whatever allows the tip provider to know - // from where to start the next time) - size_t GetCurrentTip() const { return m_currentTip; } - - // Allows any user-derived class to optionally override this function to - // modify the tip as soon as it is read. If return wxEmptyString, then - // the tip is skipped, and the next one is read. - virtual wxString PreprocessTip(const wxString& tip) { return tip; } - - // virtual dtor for the base class - virtual ~wxTipProvider() { } - -protected: - size_t m_currentTip; -}; - -// a function which returns an implementation of wxTipProvider using the -// specified text file as the source of tips (each line is a tip). -// -// NB: the caller is responsible for deleting the pointer! -#if wxUSE_TEXTFILE -WXDLLIMPEXP_ADV wxTipProvider *wxCreateFileTipProvider(const wxString& filename, - size_t currentTip); -#endif // wxUSE_TEXTFILE - -// ---------------------------------------------------------------------------- -// wxTipDialog -// ---------------------------------------------------------------------------- - -// A dialog which shows a "tip" - a short and helpful messages describing to -// the user some program characteristic. Many programs show the tips at -// startup, so the dialog has "Show tips on startup" checkbox which allows to -// the user to disable this (however, it's the program which should show, or -// not, the dialog on startup depending on its value, not this class). -// -// The function returns true if this checkbox is checked, false otherwise. -WXDLLIMPEXP_ADV bool wxShowTip(wxWindow *parent, - wxTipProvider *tipProvider, - bool showAtStartup = true); - -#endif // wxUSE_STARTUP_TIPS - -#endif // _WX_TIPDLG_H_ diff --git a/Source/3rd Party/wx/include/wx/tipwin.h b/Source/3rd Party/wx/include/wx/tipwin.h index 8ae465f11..b6c8d350a 100644 --- a/Source/3rd Party/wx/include/wx/tipwin.h +++ b/Source/3rd Party/wx/include/wx/tipwin.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 10.09.00 +// RCS-ID: $Id: tipwin.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -31,7 +32,7 @@ class WXDLLIMPEXP_FWD_CORE wxTipWindowView; // wxTipWindow // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTipWindow : public wxTipWindowBase +class WXDLLEXPORT wxTipWindow : public wxTipWindowBase { public: // the mandatory ctor parameters are: the parent window and the text to @@ -89,7 +90,7 @@ private: friend class wxTipWindowView; - wxDECLARE_NO_COPY_CLASS(wxTipWindow); + DECLARE_NO_COPY_CLASS(wxTipWindow) }; #endif // wxUSE_TIPWINDOW diff --git a/Source/3rd Party/wx/include/wx/tls.h b/Source/3rd Party/wx/include/wx/tls.h deleted file mode 100644 index f05a3f42d..000000000 --- a/Source/3rd Party/wx/include/wx/tls.h +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/tls.h -// Purpose: Implementation of thread local storage -// Author: Vadim Zeitlin -// Created: 2008-08-08 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TLS_H_ -#define _WX_TLS_H_ - -#include "wx/defs.h" - -// ---------------------------------------------------------------------------- -// check for compiler support of thread-specific variables -// ---------------------------------------------------------------------------- - -// when not using threads at all, there is no need for thread-specific -// values to be really thread-specific -#if !wxUSE_THREADS - #define wxHAS_COMPILER_TLS - #define wxTHREAD_SPECIFIC_DECL -// otherwise try to find the compiler-specific way to handle TLS unless -// explicitly disabled by setting wxUSE_COMPILER_TLS to 0 (it is 1 by default). -#elif wxUSE_COMPILER_TLS -// __thread keyword is not supported correctly by MinGW, at least in some -// configurations, see http://sourceforge.net/support/tracker.php?aid=2837047 -// and when in doubt we prefer to not use it at all. -#if defined(HAVE___THREAD_KEYWORD) && !defined(__MINGW32__) - #define wxHAS_COMPILER_TLS - #define wxTHREAD_SPECIFIC_DECL __thread -// MSVC has its own version which might be supported by some other Windows -// compilers, to be tested -#elif wxCHECK_VISUALC_VERSION(7) - #define wxHAS_COMPILER_TLS - #define wxTHREAD_SPECIFIC_DECL __declspec(thread) -#endif // compilers -#endif // wxUSE_COMPILER_TLS - -// ---------------------------------------------------------------------------- -// define wxTLS_TYPE() -// ---------------------------------------------------------------------------- - -#ifdef wxHAS_COMPILER_TLS - #define wxTLS_TYPE(T) wxTHREAD_SPECIFIC_DECL T - #define wxTLS_TYPE_REF(T) T& - #define wxTLS_PTR(var) (&(var)) - #define wxTLS_VALUE(var) (var) -#else // !wxHAS_COMPILER_TLS - - extern "C" - { - typedef void (*wxTlsDestructorFunction)(void*); - } - - #if defined(__WINDOWS__) - #include "wx/msw/tls.h" - #elif defined(__OS2__) - #include "wx/os2/tls.h" - #elif defined(__UNIX__) - #include "wx/unix/tls.h" - #else - // TODO: we could emulate TLS for such platforms... - #error Neither compiler nor OS support thread-specific variables. - #endif - - #include // for calloc() - - // wxTlsValue represents a thread-specific value of type T but, unlike - // with native compiler thread-specific variables, it behaves like a - // (never NULL) pointer to T and so needs to be dereferenced before use - // - // Note: T must be a POD! - // - // Note: On Unix, thread-specific T value is freed when the thread exits. - // On Windows, thread-specific values are freed later, when given - // wxTlsValue is destroyed. The only exception to this is the - // value for the main thread, which is always freed when - // wxTlsValue is destroyed. - template - class wxTlsValue - { - public: - typedef T ValueType; - - // ctor doesn't do anything, the object is created on first access - wxTlsValue() : m_key(free) {} - - // dtor is only called in the main thread context and so is not enough - // to free memory allocated by us for the other threads, we use - // destructor function when using Pthreads for this (which is not - // called for the main thread as it doesn't call pthread_exit() but - // just to be safe we also reset the key anyhow) - ~wxTlsValue() - { - if ( m_key.Get() ) - m_key.Set(NULL); // this deletes the value - } - - // access the object creating it on demand - ValueType *Get() - { - void *value = m_key.Get(); - if ( !value ) - { - // ValueType must be POD to be used in wxHAS_COMPILER_TLS case - // anyhow (at least gcc doesn't accept non-POD values being - // declared with __thread) so initialize it as a POD too - value = calloc(1, sizeof(ValueType)); - - if ( !m_key.Set(value) ) - { - free(value); - - // this will probably result in a crash in the caller but - // it's arguably better to crash immediately instead of - // slowly dying from out-of-memory errors which would - // happen as the next access to this object would allocate - // another ValueType instance and so on forever - value = NULL; - } - } - - return static_cast(value); - } - - // pointer-like accessors - ValueType *operator->() { return Get(); } - ValueType& operator*() { return *Get(); } - - private: - wxTlsKey m_key; - - DECLARE_NO_COPY_TEMPLATE_CLASS(wxTlsValue, T) - }; - - #define wxTLS_TYPE(T) wxTlsValue - #define wxTLS_TYPE_REF(T) wxTLS_TYPE(T)& - #define wxTLS_PTR(var) ((var).Get()) - #define wxTLS_VALUE(var) (*(var)) -#endif // wxHAS_COMPILER_TLS/!wxHAS_COMPILER_TLS - -#endif // _WX_TLS_H_ - diff --git a/Source/3rd Party/wx/include/wx/tokenzr.h b/Source/3rd Party/wx/include/wx/tokenzr.h index 854efb640..e67b20176 100644 --- a/Source/3rd Party/wx/include/wx/tokenzr.h +++ b/Source/3rd Party/wx/include/wx/tokenzr.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: (or rather rewritten by) Vadim Zeitlin // Created: 04/22/98 +// RCS-ID: $Id: tokenzr.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -71,12 +72,12 @@ public: // get current tokenizer state // returns the part of the string which remains to tokenize (*not* the // initial string) - wxString GetString() const { return wxString(m_pos, m_string.end()); } + wxString GetString() const { return m_string.substr(m_pos); } // returns the current position (i.e. one index after the last // returned token or 0 if GetNextToken() has never been called) in the // original string - size_t GetPosition() const { return m_pos - m_string.begin(); } + size_t GetPosition() const { return m_pos; } // misc // get the current mode - can be different from the one passed to the @@ -110,24 +111,10 @@ public: protected: bool IsOk() const { return m_mode != wxTOKEN_INVALID; } - bool DoHasMoreTokens() const; + wxString m_string, // the string we tokenize + m_delims; // all possible delimiters - enum MoreTokensState - { - MoreTokens_Unknown, - MoreTokens_Yes, - MoreTokens_No - }; - - MoreTokensState m_hasMoreTokens; - - wxString m_string; // the string we tokenize - wxString::const_iterator m_stringEnd; - // FIXME-UTF8: use wxWcharBuffer - wxWxCharBuffer m_delims; // all possible delimiters - size_t m_delimsLen; - - wxString::const_iterator m_pos; // the current position in m_string + size_t m_pos; // the current position in m_string wxStringTokenizerMode m_mode; // see wxTOKEN_XXX values diff --git a/Source/3rd Party/wx/include/wx/toolbar.h b/Source/3rd Party/wx/include/wx/toolbar.h index fd963829c..a64868e48 100644 --- a/Source/3rd Party/wx/include/wx/toolbar.h +++ b/Source/3rd Party/wx/include/wx/toolbar.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.11.99 +// RCS-ID: $Id: toolbar.h 42645 2006-10-29 19:12:52Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -59,9 +60,7 @@ enum wxTB_BOTTOM = 0x2000, // lay out toolbar at the right edge of the window - wxTB_RIGHT = 0x4000, - - wxTB_DEFAULT_STYLE = wxTB_HORIZONTAL | wxTB_FLAT + wxTB_RIGHT = 0x4000 }; #if wxUSE_TOOLBAR @@ -69,18 +68,20 @@ enum #if defined(__WXUNIVERSAL__) #include "wx/univ/toolbar.h" + #elif defined(__WXPALMOS__) + #include "wx/palmos/toolbar.h" #elif defined(__WXMSW__) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) - #include "wx/msw/toolbar.h" + #include "wx/msw/tbar95.h" #elif defined(__WXWINCE__) #include "wx/msw/wince/tbarwce.h" #elif defined(__WXMOTIF__) #include "wx/motif/toolbar.h" #elif defined(__WXGTK20__) - #include "wx/gtk/toolbar.h" + #include "wx/gtk/tbargtk.h" #elif defined(__WXGTK__) - #include "wx/gtk1/toolbar.h" + #include "wx/gtk1/tbargtk.h" #elif defined(__WXMAC__) - #include "wx/osx/toolbar.h" + #include "wx/mac/toolbar.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/toolbar.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/toolbook.h b/Source/3rd Party/wx/include/wx/toolbook.h index 5f07e14b1..695ffa883 100644 --- a/Source/3rd Party/wx/include/wx/toolbook.h +++ b/Source/3rd Party/wx/include/wx/toolbook.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2006-01-29 +// RCS-ID: $Id: toolbook.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 2006 Julian Smart // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,31 +17,22 @@ #if wxUSE_TOOLBOOK #include "wx/bookctrl.h" -#include "wx/containr.h" class WXDLLIMPEXP_FWD_CORE wxToolBarBase; class WXDLLIMPEXP_FWD_CORE wxCommandEvent; -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOOLBOOK_PAGE_CHANGING, wxBookCtrlEvent ); +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING; // Use wxButtonToolBar -#define wxTBK_BUTTONBAR 0x0100 - -// Use wxTB_HORZ_LAYOUT style for the controlling toolbar -#define wxTBK_HORZ_LAYOUT 0x8000 - -// deprecated synonym, don't use -#if WXWIN_COMPATIBILITY_2_8 - #define wxBK_BUTTONBAR wxTBK_BUTTONBAR -#endif +#define wxBK_BUTTONBAR 0x0100 // ---------------------------------------------------------------------------- // wxToolbook // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxToolbook : public wxNavigationEnabled +class WXDLLEXPORT wxToolbook : public wxBookCtrlBase { public: wxToolbook() @@ -70,15 +62,17 @@ public: // implement base class virtuals + virtual int GetSelection() const; virtual bool SetPageText(size_t n, const wxString& strText); virtual wxString GetPageText(size_t n) const; virtual int GetPageImage(size_t n) const; virtual bool SetPageImage(size_t n, int imageId); + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; virtual bool InsertPage(size_t n, wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = -1); virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual void SetImageList(wxImageList *imageList); @@ -99,6 +93,9 @@ public: protected: virtual wxWindow *DoRemovePage(size_t page); + // get the size which the list control should have + virtual wxSize GetControllerSize() const; + // event handlers void OnToolSelected(wxCommandEvent& event); void OnSize(wxSizeEvent& event); @@ -106,8 +103,11 @@ protected: void UpdateSelectedPage(size_t newsel); - wxBookCtrlEvent* CreatePageChangingEvent() const; - void MakeChangedEvent(wxBookCtrlEvent &event); + wxBookCtrlBaseEvent* CreatePageChangingEvent() const; + void MakeChangedEvent(wxBookCtrlBaseEvent &event); + + // the currently selected page or wxNOT_FOUND if none + int m_selection; // whether the toolbar needs to be realized bool m_needsRealizing; @@ -127,21 +127,36 @@ private: // listbook event class and related stuff // ---------------------------------------------------------------------------- -// wxToolbookEvent is obsolete and defined for compatibility only -#define wxToolbookEvent wxBookCtrlEvent -typedef wxBookCtrlEventFunction wxToolbookEventFunction; -#define wxToolbookEventHandler(func) wxBookCtrlEventHandler(func) +class WXDLLEXPORT wxToolbookEvent : public wxBookCtrlBaseEvent +{ +public: + wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) + : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) + { + } + wxToolbookEvent(const wxToolbookEvent& event) + : wxBookCtrlBaseEvent(event) + { + } + + virtual wxEvent *Clone() const { return new wxToolbookEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent) +}; + +typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&); + +#define wxToolbookEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func) #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TOOLBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn)) #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TOOLBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED wxEVT_TOOLBOOK_PAGE_CHANGED -#define wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING wxEVT_TOOLBOOK_PAGE_CHANGING + wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn)) #endif // wxUSE_TOOLBOOK diff --git a/Source/3rd Party/wx/include/wx/tooltip.h b/Source/3rd Party/wx/include/wx/tooltip.h index 4baa66d5f..af29741f4 100644 --- a/Source/3rd Party/wx/include/wx/tooltip.h +++ b/Source/3rd Party/wx/include/wx/tooltip.h @@ -1,10 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/tooltip.h +// Name: tooltip.h // Purpose: wxToolTip base header // Author: Robert Roebling // Modified by: // Created: // Copyright: (c) Robert Roebling +// RCS-ID: $Id: tooltip.h 37066 2006-01-23 03:27:34Z MR $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,7 +25,7 @@ #elif defined(__WXGTK__) #include "wx/gtk1/tooltip.h" #elif defined(__WXMAC__) -#include "wx/osx/tooltip.h" +#include "wx/mac/tooltip.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/tooltip.h" #elif defined(__WXPM__) diff --git a/Source/3rd Party/wx/include/wx/toplevel.h b/Source/3rd Party/wx/include/wx/toplevel.h index c9aac7a52..2351d7cd9 100644 --- a/Source/3rd Party/wx/include/wx/toplevel.h +++ b/Source/3rd Party/wx/include/wx/toplevel.h @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin, Vaclav Slavik // Modified by: // Created: 06.08.01 +// RCS-ID: $Id: toplevel.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin // Vaclav Slavik // Licence: wxWindows licence @@ -17,12 +18,11 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/nonownedwnd.h" +#include "wx/window.h" #include "wx/iconbndl.h" -#include "wx/weakref.h" // the default names for various classes -extern WXDLLIMPEXP_DATA_CORE(const char) wxFrameNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxFrameNameStr[]; class WXDLLIMPEXP_FWD_CORE wxTopLevelWindowBase; @@ -30,59 +30,19 @@ class WXDLLIMPEXP_FWD_CORE wxTopLevelWindowBase; // constants // ---------------------------------------------------------------------------- -/* - Summary of the bits used (some of them are defined in wx/frame.h and - wx/dialog.h and not here): - - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - | | | | | | | | | | | | | | | | - | | | | | | | | | | | | | | | \_ wxCENTRE - | | | | | | | | | | | | | | \____ wxFRAME_NO_TASKBAR - | | | | | | | | | | | | | \_______ wxFRAME_TOOL_WINDOW - | | | | | | | | | | | | \__________ wxFRAME_FLOAT_ON_PARENT - | | | | | | | | | | | \_____________ wxFRAME_SHAPED - | | | | | | | | | | \________________ wxDIALOG_NO_PARENT - | | | | | | | | | \___________________ wxRESIZE_BORDER - | | | | | | | | \______________________ wxTINY_CAPTION_VERT - | | | | | | | \_________________________ - | | | | | | \____________________________ wxMAXIMIZE_BOX - | | | | | \_______________________________ wxMINIMIZE_BOX - | | | | \__________________________________ wxSYSTEM_MENU - | | | \_____________________________________ wxCLOSE_BOX - | | \________________________________________ wxMAXIMIZE - | \___________________________________________ wxMINIMIZE - \______________________________________________ wxSTAY_ON_TOP - - - Notice that the 8 lower bits overlap with wxCENTRE and the button selection - bits (wxYES, wxOK wxNO, wxCANCEL, wxAPPLY, wxCLOSE and wxNO_DEFAULT) which - can be combined with the dialog style for several standard dialogs and - hence shouldn't overlap with any styles which can be used for the dialogs. - Additionally, wxCENTRE can be used with frames also. - */ - // style common to both wxFrame and wxDialog #define wxSTAY_ON_TOP 0x8000 #define wxICONIZE 0x4000 #define wxMINIMIZE wxICONIZE #define wxMAXIMIZE 0x2000 -#define wxCLOSE_BOX 0x1000 // == wxHELP so can't be used with it +#define wxCLOSE_BOX 0x1000 #define wxSYSTEM_MENU 0x0800 #define wxMINIMIZE_BOX 0x0400 #define wxMAXIMIZE_BOX 0x0200 - -#define wxTINY_CAPTION 0x0080 // clashes with wxNO_DEFAULT -#define wxRESIZE_BORDER 0x0040 // == wxCLOSE - -#if WXWIN_COMPATIBILITY_2_8 - // HORIZ and VERT styles are equivalent anyhow so don't use different names - // for them - #define wxTINY_CAPTION_HORIZ wxTINY_CAPTION - #define wxTINY_CAPTION_VERT wxTINY_CAPTION -#endif +#define wxTINY_CAPTION_HORIZ 0x0100 +#define wxTINY_CAPTION_VERT 0x0080 +#define wxRESIZE_BORDER 0x0040 #if WXWIN_COMPATIBILITY_2_6 @@ -155,7 +115,7 @@ enum // wxTopLevelWindow: a top level (as opposed to child) window // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTopLevelWindowBase : public wxNonOwnedWindow +class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow { public: // construction @@ -185,26 +145,20 @@ public: virtual bool IsIconized() const = 0; // get the frame icon - wxIcon GetIcon() const; + const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); } // get the frame icons const wxIconBundle& GetIcons() const { return m_icons; } - // set the frame icon: implemented in terms of SetIcons() - void SetIcon(const wxIcon& icon); + // set the frame icon + virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); } // set the frame icons - virtual void SetIcons(const wxIconBundle& icons) { m_icons = icons; } + virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; } // maximize the window to cover entire screen virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0; - // shows the window, but doesn't activate it. If the base code is being run, - // it means the port doesn't implement this method yet and so alert the user. - virtual void ShowWithoutActivating() { - wxFAIL_MSG("ShowWithoutActivating not implemented on this platform."); - } - // return true if the frame is in fullscreen mode virtual bool IsFullScreen() const = 0; @@ -214,16 +168,19 @@ public: virtual wxString GetTitle() const = 0; // enable/disable close button [x] - virtual bool EnableCloseButton(bool WXUNUSED(enable) ) { return false; } + virtual bool EnableCloseButton(bool WXUNUSED(enable) ) { return false; } + + // Set the shape of the window to the given region. + // Returns true if the platform supports this feature (and the + // operation is successful.) + virtual bool SetShape(const wxRegion& WXUNUSED(region)) { return false; } // Attracts the users attention to this window if the application is // inactive (should be called when a background event occurs) virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO); // Is this the active frame (highlighted in the taskbar)? - // - // A TLW is active only if it contains the currently focused window. - virtual bool IsActive() { return IsDescendant(FindFocus()); } + virtual bool IsActive() { return wxGetTopLevelParent(FindFocus()) == this; } // this function may be overridden to return false to allow closing the // application even when this top level window is still open @@ -242,10 +199,6 @@ public: void CentreOnScreen(int dir = wxBOTH) { DoCentre(dir | wxCENTRE_ON_SCREEN); } void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); } - // Get the default size for a new top level window. This is used when - // creating a wxTLW under some platforms if no explicit size given. - static wxSize GetDefaultSize(); - // default item access: we have a permanent default item which is the one // set by the user code but we may also have a temporary default item which @@ -253,6 +206,9 @@ public: // reverts to the "permanent" default as soon as this temporary default // item loses focus + // used to reset default if pointing to removed child + virtual void RemoveChild(wxWindowBase *child); + // get the default item, temporary or permanent wxWindow *GetDefaultItem() const { return m_winTmpDefault ? m_winTmpDefault : m_winDefault; } @@ -269,13 +225,13 @@ public: wxWindow *SetTmpDefaultItem(wxWindow *win) { wxWindow *old = GetDefaultItem(); m_winTmpDefault = win; return old; } + // implementation only from now on // ------------------------------- // override some base class virtuals virtual bool Destroy(); virtual bool IsTopLevel() const { return true; } - virtual bool IsTopNavigationDomain() const { return true; } virtual bool IsVisible() const { return IsShown(); } // event handlers @@ -296,17 +252,10 @@ public: virtual void SetMinSize(const wxSize& minSize); virtual void SetMaxSize(const wxSize& maxSize); - virtual void OSXSetModified(bool modified) { m_modified = modified; } - virtual bool OSXIsModified() const { return m_modified; } - - virtual void SetRepresentedFilename(const wxString& WXUNUSED(filename)) { } - -#if wxUSE_MENUS || wxUSE_TOOLBAR - // show help text for the currently selected menu or toolbar item - // (typically in the status bar) or hide it and restore the status bar text - // originally shown before the menu was opened if show == false - virtual void DoGiveHelp(const wxString& WXUNUSED(text), bool WXUNUSED(show)) {} -#endif + // set size hints for "window manager" + virtual void DoSetSizeHints( int minW, int minH, + int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, + int incW = wxDefaultCoord, int incH = wxDefaultCoord ); protected: // the frame client to screen translation should take account of the @@ -339,28 +288,32 @@ protected: // client area void DoLayout(); + // Get the default size for the new window if no explicit size given. If + // there are better default sizes then these can be changed, just as long + // as they are not too small for TLWs (and not larger than screen). + static wxSize GetDefaultSize(); static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; } static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; } - // the frame icon wxIconBundle m_icons; // a default window (usually a button) or NULL - wxWindowRef m_winDefault; + wxWindow *m_winDefault; // a temporary override of m_winDefault, use the latter if NULL - wxWindowRef m_winTmpDefault; + wxWindow *m_winTmpDefault; - bool m_modified; - - wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowBase); + DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase) DECLARE_EVENT_TABLE() }; // include the real class declaration -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #include "wx/palmos/toplevel.h" + #define wxTopLevelWindowNative wxTopLevelWindowPalm +#elif defined(__WXMSW__) #include "wx/msw/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowMSW #elif defined(__WXGTK20__) @@ -372,11 +325,14 @@ protected: #elif defined(__WXX11__) #include "wx/x11/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowX11 +#elif defined(__WXMGL__) + #include "wx/mgl/toplevel.h" + #define wxTopLevelWindowNative wxTopLevelWindowMGL #elif defined(__WXDFB__) #include "wx/dfb/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowDFB #elif defined(__WXMAC__) - #include "wx/osx/toplevel.h" + #include "wx/mac/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowMac #elif defined(__WXCOCOA__) #include "wx/cocoa/toplevel.h" @@ -392,25 +348,28 @@ protected: #ifdef __WXUNIVERSAL__ #include "wx/univ/toplevel.h" #else // !__WXUNIVERSAL__ - class WXDLLIMPEXP_CORE wxTopLevelWindow : public wxTopLevelWindowNative - { - public: - // construction - wxTopLevelWindow() { } - wxTopLevelWindow(wxWindow *parent, - wxWindowID winid, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - : wxTopLevelWindowNative(parent, winid, title, - pos, size, style, name) + #ifdef wxTopLevelWindowNative + class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative { - } + public: + // construction + wxTopLevelWindow() { Init(); } + wxTopLevelWindow(wxWindow *parent, + wxWindowID winid, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + Init(); + Create(parent, winid, title, pos, size, style, name); + } - DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow) - }; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow) + }; + #endif // wxTopLevelWindowNative #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__ + #endif // _WX_TOPLEVEL_BASE_H_ diff --git a/Source/3rd Party/wx/include/wx/tracker.h b/Source/3rd Party/wx/include/wx/tracker.h deleted file mode 100644 index d8f272822..000000000 --- a/Source/3rd Party/wx/include/wx/tracker.h +++ /dev/null @@ -1,91 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/tracker.h -// Purpose: Support class for object lifetime tracking (wxWeakRef) -// Author: Arne Steinarson -// Created: 28 Dec 07 -// Copyright: (c) 2007 Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TRACKER_H_ -#define _WX_TRACKER_H_ - -#include "wx/defs.h" - -class wxEventConnectionRef; - -// This class represents an object tracker and is stored in a linked list -// in the tracked object. It is only used in one of its derived forms. -class WXDLLIMPEXP_BASE wxTrackerNode -{ -public: - wxTrackerNode() : m_nxt(NULL) { } - virtual ~wxTrackerNode() { } - - virtual void OnObjectDestroy() = 0; - - virtual wxEventConnectionRef *ToEventConnection() { return NULL; } - -private: - wxTrackerNode *m_nxt; - - friend class wxTrackable; // For list access - friend class wxEvtHandler; // For list access -}; - -// Add-on base class for a trackable object. -class WXDLLIMPEXP_BASE wxTrackable -{ -public: - void AddNode(wxTrackerNode *prn) - { - prn->m_nxt = m_first; - m_first = prn; - } - - void RemoveNode(wxTrackerNode *prn) - { - for ( wxTrackerNode **pprn = &m_first; *pprn; pprn = &(*pprn)->m_nxt ) - { - if ( *pprn == prn ) - { - *pprn = prn->m_nxt; - return; - } - } - - wxFAIL_MSG( "removing invalid tracker node" ); - } - - wxTrackerNode *GetFirst() const { return m_first; } - -protected: - // this class is only supposed to be used as a base class but never be - // created nor destroyed directly so all ctors and dtor are protected - - wxTrackable() : m_first(NULL) { } - - // copy ctor and assignment operator intentionally do not copy m_first: the - // objects which track the original trackable shouldn't track the new copy - wxTrackable(const wxTrackable& WXUNUSED(other)) : m_first(NULL) { } - wxTrackable& operator=(const wxTrackable& WXUNUSED(other)) { return *this; } - - // dtor is not virtual: this class is not supposed to be used - // polymorphically and adding a virtual table to it would add unwanted - // overhead - ~wxTrackable() - { - // Notify all registered refs - while ( m_first ) - { - wxTrackerNode * const first = m_first; - m_first = first->m_nxt; - first->OnObjectDestroy(); - } - } - - wxTrackerNode *m_first; -}; - -#endif // _WX_TRACKER_H_ - diff --git a/Source/3rd Party/wx/include/wx/translation.h b/Source/3rd Party/wx/include/wx/translation.h deleted file mode 100644 index 187caf366..000000000 --- a/Source/3rd Party/wx/include/wx/translation.h +++ /dev/null @@ -1,323 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/translation.h -// Purpose: Internationalization and localisation for wxWidgets -// Author: Vadim Zeitlin, Vaclav Slavik, -// Michael N. Filippov -// Created: 2010-04-23 -// Copyright: (c) 1998 Vadim Zeitlin -// (c) 2010 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TRANSLATION_H_ -#define _WX_TRANSLATION_H_ - -#include "wx/defs.h" -#include "wx/string.h" - -#if wxUSE_INTL - -#include "wx/buffer.h" -#include "wx/language.h" -#include "wx/hashmap.h" -#include "wx/strconv.h" -#include "wx/scopedptr.h" - -// ============================================================================ -// global decls -// ============================================================================ - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// gettext() style macros (notice that xgettext should be invoked with -// --keyword="_" --keyword="wxPLURAL:1,2" options -// to extract the strings from the sources) -#ifndef WXINTL_NO_GETTEXT_MACRO - #define _(s) wxGetTranslation((s)) - #define wxPLURAL(sing, plur, n) wxGetTranslation((sing), (plur), n) -#endif - -// another one which just marks the strings for extraction, but doesn't -// perform the translation (use -kwxTRANSLATE with xgettext!) -#define wxTRANSLATE(str) str - -// ---------------------------------------------------------------------------- -// forward decls -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_FWD_BASE wxArrayString; -class WXDLLIMPEXP_FWD_BASE wxTranslationsLoader; -class WXDLLIMPEXP_FWD_BASE wxLocale; - -class wxPluralFormsCalculator; -wxDECLARE_SCOPED_PTR(wxPluralFormsCalculator, wxPluralFormsCalculatorPtr) - -// ---------------------------------------------------------------------------- -// wxMsgCatalog corresponds to one loaded message catalog. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxMsgCatalog -{ -public: - // Ctor is protected, because CreateFromXXX functions must be used, - // but destruction should be unrestricted -#if !wxUSE_UNICODE - ~wxMsgCatalog(); -#endif - - // load the catalog from disk or from data; caller is responsible for - // deleting them if not NULL - static wxMsgCatalog *CreateFromFile(const wxString& filename, - const wxString& domain); - - static wxMsgCatalog *CreateFromData(const wxScopedCharBuffer& data, - const wxString& domain); - - // get name of the catalog - wxString GetDomain() const { return m_domain; } - - // get the translated string: returns NULL if not found - const wxString *GetString(const wxString& sz, unsigned n = UINT_MAX) const; - -protected: - wxMsgCatalog(const wxString& domain) - : m_pNext(NULL), m_domain(domain) -#if !wxUSE_UNICODE - , m_conv(NULL) -#endif - {} - -private: - // variable pointing to the next element in a linked list (or NULL) - wxMsgCatalog *m_pNext; - friend class wxTranslations; - - wxStringToStringHashMap m_messages; // all messages in the catalog - wxString m_domain; // name of the domain - -#if !wxUSE_UNICODE - // the conversion corresponding to this catalog charset if we installed it - // as the global one - wxCSConv *m_conv; -#endif - - wxPluralFormsCalculatorPtr m_pluralFormsCalculator; -}; - -// ---------------------------------------------------------------------------- -// wxTranslations: message catalogs -// ---------------------------------------------------------------------------- - -// this class allows to get translations for strings -class WXDLLIMPEXP_BASE wxTranslations -{ -public: - wxTranslations(); - ~wxTranslations(); - - // returns current translations object, may return NULL - static wxTranslations *Get(); - // sets current translations object (takes ownership; may be NULL) - static void Set(wxTranslations *t); - - // changes loader to non-default one; takes ownership of 'loader' - void SetLoader(wxTranslationsLoader *loader); - - void SetLanguage(wxLanguage lang); - void SetLanguage(const wxString& lang); - - // get languages available for this app - wxArrayString GetAvailableTranslations(const wxString& domain) const; - - // find best translation language for given domain - wxString GetBestTranslation(const wxString& domain, wxLanguage msgIdLanguage); - wxString GetBestTranslation(const wxString& domain, - const wxString& msgIdLanguage = "en"); - - // add standard wxWidgets catalog ("wxstd") - bool AddStdCatalog(); - - // add catalog with given domain name and language, looking it up via - // wxTranslationsLoader - bool AddCatalog(const wxString& domain); - bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage); -#if !wxUSE_UNICODE - bool AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage, - const wxString& msgIdCharset); -#endif - - // check if the given catalog is loaded - bool IsLoaded(const wxString& domain) const; - - // access to translations - const wxString *GetTranslatedString(const wxString& origString, - const wxString& domain = wxEmptyString) const; - const wxString *GetTranslatedString(const wxString& origString, - unsigned n, - const wxString& domain = wxEmptyString) const; - - wxString GetHeaderValue(const wxString& header, - const wxString& domain = wxEmptyString) const; - - // this is hack to work around a problem with wxGetTranslation() which - // returns const wxString& and not wxString, so when it returns untranslated - // string, it needs to have a copy of it somewhere - static const wxString& GetUntranslatedString(const wxString& str); - -private: - // perform loading of the catalog via m_loader - bool LoadCatalog(const wxString& domain, const wxString& lang, const wxString& msgIdLang); - - // find catalog by name in a linked list, return NULL if !found - wxMsgCatalog *FindCatalog(const wxString& domain) const; - - // same as Set(), without taking ownership; only for wxLocale - static void SetNonOwned(wxTranslations *t); - friend class wxLocale; - -private: - wxString m_lang; - wxTranslationsLoader *m_loader; - - wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs -}; - - -// abstraction of translations discovery and loading -class WXDLLIMPEXP_BASE wxTranslationsLoader -{ -public: - wxTranslationsLoader() {} - virtual ~wxTranslationsLoader() {} - - virtual wxMsgCatalog *LoadCatalog(const wxString& domain, - const wxString& lang) = 0; - - virtual wxArrayString GetAvailableTranslations(const wxString& domain) const = 0; -}; - - -// standard wxTranslationsLoader implementation, using filesystem -class WXDLLIMPEXP_BASE wxFileTranslationsLoader - : public wxTranslationsLoader -{ -public: - static void AddCatalogLookupPathPrefix(const wxString& prefix); - - virtual wxMsgCatalog *LoadCatalog(const wxString& domain, - const wxString& lang); - - virtual wxArrayString GetAvailableTranslations(const wxString& domain) const; -}; - - -#ifdef __WINDOWS__ -// loads translations from win32 resources -class WXDLLIMPEXP_BASE wxResourceTranslationsLoader - : public wxTranslationsLoader -{ -public: - virtual wxMsgCatalog *LoadCatalog(const wxString& domain, - const wxString& lang); - - virtual wxArrayString GetAvailableTranslations(const wxString& domain) const; - -protected: - // returns resource type to use for translations - virtual wxString GetResourceType() const { return "MOFILE"; } - - // returns module to load resources from - virtual WXHINSTANCE GetModule() const { return 0; } -}; -#endif // __WINDOWS__ - - -// ---------------------------------------------------------------------------- -// global functions -// ---------------------------------------------------------------------------- - -// get the translation of the string in the current locale -inline const wxString& wxGetTranslation(const wxString& str, - const wxString& domain = wxString()) -{ - wxTranslations *trans = wxTranslations::Get(); - const wxString *transStr = trans ? trans->GetTranslatedString(str, domain) - : NULL; - if ( transStr ) - return *transStr; - else - // NB: this function returns reference to a string, so we have to keep - // a copy of it somewhere - return wxTranslations::GetUntranslatedString(str); -} - -inline const wxString& wxGetTranslation(const wxString& str1, - const wxString& str2, - unsigned n, - const wxString& domain = wxString()) -{ - wxTranslations *trans = wxTranslations::Get(); - const wxString *transStr = trans ? trans->GetTranslatedString(str1, n, domain) - : NULL; - if ( transStr ) - return *transStr; - else - // NB: this function returns reference to a string, so we have to keep - // a copy of it somewhere - return n == 1 - ? wxTranslations::GetUntranslatedString(str1) - : wxTranslations::GetUntranslatedString(str2); -} - -#else // !wxUSE_INTL - -// the macros should still be defined - otherwise compilation would fail - -#if !defined(WXINTL_NO_GETTEXT_MACRO) - #if !defined(_) - #define _(s) (s) - #endif - #define wxPLURAL(sing, plur, n) ((n) == 1 ? (sing) : (plur)) -#endif - -#define wxTRANSLATE(str) str - -// NB: we use a template here in order to avoid using -// wxLocale::GetUntranslatedString() above, which would be required if -// we returned const wxString&; this way, the compiler should be able to -// optimize wxGetTranslation() away - -template -inline TString wxGetTranslation(TString str) - { return str; } - -template -inline TString wxGetTranslation(TString str, TDomain WXUNUSED(domain)) - { return str; } - -template -inline TString wxGetTranslation(TString str1, TString str2, size_t n) - { return n == 1 ? str1 : str2; } - -template -inline TString wxGetTranslation(TString str1, TString str2, size_t n, - TDomain WXUNUSED(domain)) - { return n == 1 ? str1 : str2; } - -#endif // wxUSE_INTL/!wxUSE_INTL - -// define this one just in case it occurs somewhere (instead of preferred -// wxTRANSLATE) too -#if !defined(WXINTL_NO_GETTEXT_MACRO) - #if !defined(gettext_noop) - #define gettext_noop(str) (str) - #endif - #if !defined(N_) - #define N_(s) (s) - #endif -#endif - -#endif // _WX_TRANSLATION_H_ diff --git a/Source/3rd Party/wx/include/wx/treebase.h b/Source/3rd Party/wx/include/wx/treebase.h index 11f8245a4..a89786268 100644 --- a/Source/3rd Party/wx/include/wx/treebase.h +++ b/Source/3rd Party/wx/include/wx/treebase.h @@ -4,6 +4,7 @@ // Author: Julian Smart et al // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: treebase.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 1997,1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,7 +23,6 @@ #include "wx/window.h" // for wxClientData #include "wx/event.h" #include "wx/dynarray.h" -#include "wx/itemid.h" #if WXWIN_COMPATIBILITY_2_6 @@ -38,19 +38,59 @@ enum #endif // WXWIN_COMPATIBILITY_2_6 // ---------------------------------------------------------------------------- -// wxTreeItemId identifies an element of the tree. It's opaque for the -// application and the only method which can be used by user code is IsOk(). +// wxTreeItemId identifies an element of the tree. In this implementation, it's +// just a trivial wrapper around Win32 HTREEITEM or a pointer to some private +// data structure in the generic version. It's opaque for the application and +// the only method which can be used by user code is IsOk(). // ---------------------------------------------------------------------------- -// This is a class and not a typedef because existing code may forward declare -// wxTreeItemId as a class and we don't want to break it without good reason. -class wxTreeItemId : public wxItemId +// Using this typedef removes an ambiguity when calling Remove() +typedef void *wxTreeItemIdValue; + +class WXDLLEXPORT wxTreeItemId { + friend bool operator==(const wxTreeItemId&, const wxTreeItemId&); public: - wxTreeItemId() : wxItemId() { } - wxTreeItemId(void* pItem) : wxItemId(pItem) { } + // ctors + // 0 is invalid value for HTREEITEM + wxTreeItemId() { m_pItem = 0; } + + // construct wxTreeItemId from the native item id + wxTreeItemId(void *pItem) { m_pItem = pItem; } + + // default copy ctor/assignment operator are ok for us + + // accessors + // is this a valid tree item? + bool IsOk() const { return m_pItem != 0; } + // return true if this item is not valid + bool operator!() const { return !IsOk(); } + + // operations + // invalidate the item + void Unset() { m_pItem = 0; } + +#if WXWIN_COMPATIBILITY_2_4 + // deprecated: only for compatibility, don't work on 64 bit archs + wxTreeItemId(long item) { m_pItem = wxUIntToPtr(item); } + operator long() const { return (long)wxPtrToUInt(m_pItem); } +#else // !WXWIN_COMPATIBILITY_2_4 + operator bool() const { return IsOk(); } +#endif // WXWIN_COMPATIBILITY_2_4/!WXWIN_COMPATIBILITY_2_4 + + wxTreeItemIdValue m_pItem; }; +inline bool operator==(const wxTreeItemId& i1, const wxTreeItemId& i2) +{ + return i1.m_pItem == i2.m_pItem; +} + +inline bool operator!=(const wxTreeItemId& i1, const wxTreeItemId& i2) +{ + return i1.m_pItem != i2.m_pItem; +} + // ---------------------------------------------------------------------------- // wxTreeItemData is some (arbitrary) user class associated with some item. The // main advantage of having this class (compared to old untyped interface) is @@ -65,7 +105,7 @@ public: // always be allocated on the heap! // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreeItemData: public wxClientData +class WXDLLEXPORT wxTreeItemData: public wxClientData { friend class WXDLLIMPEXP_FWD_CORE wxTreeCtrl; friend class WXDLLIMPEXP_FWD_CORE wxGenericTreeCtrl; @@ -85,14 +125,12 @@ protected: wxTreeItemId m_pItem; }; -typedef void *wxTreeItemIdValue; - WX_DEFINE_EXPORTED_ARRAY_PTR(wxTreeItemIdValue, wxArrayTreeItemIdsBase); // this is a wrapper around the array class defined above which allow to wok -// with values of natural wxTreeItemId type instead of using wxTreeItemIdValue +// with vaue of natural wxTreeItemId type instead of using wxTreeItemIdValue // and does it without any loss of efficiency -class WXDLLIMPEXP_CORE wxArrayTreeItemIds : public wxArrayTreeItemIdsBase +class WXDLLEXPORT wxArrayTreeItemIds : public wxArrayTreeItemIdsBase { public: void Add(const wxTreeItemId& id) @@ -118,11 +156,6 @@ enum wxTreeItemIcon wxTreeItemIcon_Max }; -// special values for the 'state' parameter of wxTreeCtrl::SetItemState() -static const int wxTREE_ITEMSTATE_NONE = -1; // not state (no display state image) -static const int wxTREE_ITEMSTATE_NEXT = -2; // cycle to the next state -static const int wxTREE_ITEMSTATE_PREV = -3; // cycle to the previous state - // ---------------------------------------------------------------------------- // wxTreeCtrl flags // ---------------------------------------------------------------------------- @@ -135,11 +168,7 @@ static const int wxTREE_ITEMSTATE_PREV = -3; // cycle to the previous state #define wxTR_SINGLE 0x0000 // for convenience #define wxTR_MULTIPLE 0x0020 // can select multiple items - -#if WXWIN_COMPATIBILITY_2_8 - #define wxTR_EXTENDED 0x0040 // deprecated, don't use -#endif // WXWIN_COMPATIBILITY_2_8 - +#define wxTR_EXTENDED 0x0040 // TODO: allow extended selection #define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says #define wxTR_EDIT_LABELS 0x0200 // can edit item labels @@ -148,15 +177,10 @@ static const int wxTREE_ITEMSTATE_PREV = -3; // cycle to the previous state #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space -// make the default control appearance look more native-like depending on the -// platform -#if defined(__WXGTK20__) - #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES) -#elif defined(__WXMAC__) - #define wxTR_DEFAULT_STYLE \ - (wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT) +#ifdef __WXGTK20__ +#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES) #else - #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) +#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) #endif #if WXWIN_COMPATIBILITY_2_6 @@ -198,13 +222,13 @@ static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL; // tree ctrl default name -extern WXDLLIMPEXP_DATA_CORE(const char) wxTreeCtrlNameStr[]; +extern WXDLLEXPORT_DATA(const wxChar) wxTreeCtrlNameStr[]; // ---------------------------------------------------------------------------- // wxTreeItemAttr: a structure containing the visual attributes of an item // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreeItemAttr +class WXDLLEXPORT wxTreeItemAttr { public: // ctors @@ -220,9 +244,9 @@ public: void SetFont(const wxFont& font) { m_font = font; } // accessors - bool HasTextColour() const { return m_colText.IsOk(); } - bool HasBackgroundColour() const { return m_colBack.IsOk(); } - bool HasFont() const { return m_font.IsOk(); } + bool HasTextColour() const { return m_colText.Ok(); } + bool HasBackgroundColour() const { return m_colBack.Ok(); } + bool HasFont() const { return m_font.Ok(); } const wxColour& GetTextColour() const { return m_colText; } const wxColour& GetBackgroundColour() const { return m_colBack; } @@ -243,34 +267,34 @@ private: class WXDLLIMPEXP_FWD_CORE wxTreeCtrlBase; -class WXDLLIMPEXP_CORE wxTreeEvent : public wxNotifyEvent +class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent { public: - wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); wxTreeEvent(wxEventType commandType, wxTreeCtrlBase *tree, const wxTreeItemId &item = wxTreeItemId()); + wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); wxTreeEvent(const wxTreeEvent& event); virtual wxEvent *Clone() const { return new wxTreeEvent(*this); } // accessors // get the item on which the operation was performed or the newly - // selected item for wxEVT_TREE_SEL_CHANGED/ING events + // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events wxTreeItemId GetItem() const { return m_item; } void SetItem(const wxTreeItemId& item) { m_item = item; } - // for wxEVT_TREE_SEL_CHANGED/ING events, get the previously + // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously // selected item wxTreeItemId GetOldItem() const { return m_itemOld; } void SetOldItem(const wxTreeItemId& item) { m_itemOld = item; } // the point where the mouse was when the drag operation started (for - // wxEVT_TREE_BEGIN_(R)DRAG events only) or click position + // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position wxPoint GetPoint() const { return m_pointDrag; } void SetPoint(const wxPoint& pt) { m_pointDrag = pt; } - // keyboard data (for wxEVT_TREE_KEY_DOWN only) + // keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only) const wxKeyEvent& GetKeyEvent() const { return m_evtKey; } int GetKeyCode() const { return m_evtKey.GetKeyCode(); } void SetKeyEvent(const wxKeyEvent& evt) { m_evtKey = evt; } @@ -308,33 +332,35 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); // tree control events and macros for handling them // ---------------------------------------------------------------------------- -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_BEGIN_DRAG, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_BEGIN_RDRAG, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_BEGIN_LABEL_EDIT, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_END_LABEL_EDIT, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_DELETE_ITEM, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_GET_INFO, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_SET_INFO, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_EXPANDED, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_EXPANDING, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_COLLAPSED, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_COLLAPSING, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_SEL_CHANGED, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_SEL_CHANGING, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_KEY_DOWN, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_ACTIVATED, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_RIGHT_CLICK, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_MIDDLE_CLICK, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_END_DRAG, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_STATE_IMAGE_CLICK, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_GETTOOLTIP, wxTreeEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_MENU, wxTreeEvent ); +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_DRAG, 600) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_RDRAG, 601) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, 602) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_LABEL_EDIT, 603) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_DELETE_ITEM, 604) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_GET_INFO, 605) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SET_INFO, 606) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDED, 607) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDING, 608) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, 609) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, 610) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGED, 611) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGING, 612) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_KEY_DOWN, 613) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, 614) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, 615) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, 616) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_DRAG, 617) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, 618) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 619) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_MENU, 620) +END_DECLARE_EVENT_TYPES() #define wxTreeEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxTreeEventFunction, func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTreeEventFunction, &func) #define wx__DECLARE_TREEEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_TREE_ ## evt, id, wxTreeEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn)) // GetItem() returns the item being dragged, GetPoint() the mouse coords // @@ -395,29 +421,6 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREE_ITEM_MENU, wxTreeEvent ); // GetItem() is the item for which the tooltip is being requested #define EVT_TREE_ITEM_GETTOOLTIP(id, fn) wx__DECLARE_TREEEVT(ITEM_GETTOOLTIP, id, fn) -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TREE_BEGIN_DRAG wxEVT_TREE_BEGIN_DRAG -#define wxEVT_COMMAND_TREE_BEGIN_RDRAG wxEVT_TREE_BEGIN_RDRAG -#define wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT wxEVT_TREE_BEGIN_LABEL_EDIT -#define wxEVT_COMMAND_TREE_END_LABEL_EDIT wxEVT_TREE_END_LABEL_EDIT -#define wxEVT_COMMAND_TREE_DELETE_ITEM wxEVT_TREE_DELETE_ITEM -#define wxEVT_COMMAND_TREE_GET_INFO wxEVT_TREE_GET_INFO -#define wxEVT_COMMAND_TREE_SET_INFO wxEVT_TREE_SET_INFO -#define wxEVT_COMMAND_TREE_ITEM_EXPANDED wxEVT_TREE_ITEM_EXPANDED -#define wxEVT_COMMAND_TREE_ITEM_EXPANDING wxEVT_TREE_ITEM_EXPANDING -#define wxEVT_COMMAND_TREE_ITEM_COLLAPSED wxEVT_TREE_ITEM_COLLAPSED -#define wxEVT_COMMAND_TREE_ITEM_COLLAPSING wxEVT_TREE_ITEM_COLLAPSING -#define wxEVT_COMMAND_TREE_SEL_CHANGED wxEVT_TREE_SEL_CHANGED -#define wxEVT_COMMAND_TREE_SEL_CHANGING wxEVT_TREE_SEL_CHANGING -#define wxEVT_COMMAND_TREE_KEY_DOWN wxEVT_TREE_KEY_DOWN -#define wxEVT_COMMAND_TREE_ITEM_ACTIVATED wxEVT_TREE_ITEM_ACTIVATED -#define wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK wxEVT_TREE_ITEM_RIGHT_CLICK -#define wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK wxEVT_TREE_ITEM_MIDDLE_CLICK -#define wxEVT_COMMAND_TREE_END_DRAG wxEVT_TREE_END_DRAG -#define wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK wxEVT_TREE_STATE_IMAGE_CLICK -#define wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP wxEVT_TREE_ITEM_GETTOOLTIP -#define wxEVT_COMMAND_TREE_ITEM_MENU wxEVT_TREE_ITEM_MENU - #endif // wxUSE_TREECTRL #endif // _WX_TREEBASE_H_ diff --git a/Source/3rd Party/wx/include/wx/treebook.h b/Source/3rd Party/wx/include/wx/treebook.h index 39cda53f7..dba636352 100644 --- a/Source/3rd Party/wx/include/wx/treebook.h +++ b/Source/3rd Party/wx/include/wx/treebook.h @@ -4,6 +4,7 @@ // Author: Evgeniy Tarassov, Vadim Zeitlin // Modified by: // Created: 2005-09-15 +// RCS-ID: $Id: treebook.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 2005 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -16,8 +17,8 @@ #if wxUSE_TREEBOOK #include "wx/bookctrl.h" -#include "wx/containr.h" #include "wx/treectrl.h" // for wxArrayTreeItemIds +#include "wx/containr.h" typedef wxWindow wxTreebookPage; @@ -27,7 +28,7 @@ class WXDLLIMPEXP_FWD_CORE wxTreeEvent; // wxTreebook // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreebook : public wxNavigationEnabled +class WXDLLEXPORT wxTreebook : public wxBookCtrlBase { public: // Constructors and such @@ -74,27 +75,27 @@ public: wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); // Inserts a new sub-page to the end of children of the page at given pos. virtual bool InsertSubPage(size_t pos, wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); // Adds a new page at top level after all other pages. virtual bool AddPage(wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); // Adds a new child-page to the last top-level page inserted. // Useful when constructing 1 level tree structure. virtual bool AddSubPage(wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); // Deletes the page and ALL its children. Could trigger page selection // change in a case when selected page is removed. In that case its parent @@ -126,10 +127,12 @@ public: // Standard operations inherited from wxBookCtrlBase // ------------------------------------------------- + virtual int GetSelection() const; virtual bool SetPageText(size_t n, const wxString& strText); virtual wxString GetPageText(size_t n) const; virtual int GetPageImage(size_t n) const; virtual bool SetPageImage(size_t n, int imageId); + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; @@ -151,6 +154,9 @@ protected: // array of page ids and page windows wxArrayTreeItemIds m_treeIds; + // the currently selected page or wxNOT_FOUND if none + int m_selection; + // in the situation when m_selection page is not wxNOT_FOUND but page is // NULL this is the first (sub)child that has a non-NULL page int m_actualSelection; @@ -169,16 +175,16 @@ private: wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); bool DoInsertSubPage(size_t pos, wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); bool DoAddSubPage(wxWindow *page, const wxString& text, bool bSelect = false, - int imageId = NO_IMAGE); + int imageId = wxNOT_FOUND); // Sets selection in the tree control and updates the page being shown. int DoSetSelection(size_t pos, int flags = 0); @@ -216,11 +222,12 @@ private: // Returns internal number of pages which can be different from // GetPageCount() while performing a page insertion or removal. - size_t DoInternalGetPageCount() const { return m_treeIds.GetCount(); } + size_t DoInternalGetPageCount() const { return m_treeIds.Count(); } DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxTreebook) + WX_DECLARE_CONTROL_CONTAINER(); }; @@ -228,34 +235,47 @@ private: // treebook event class and related stuff // ---------------------------------------------------------------------------- -// wxTreebookEvent is obsolete and defined for compatibility only -#define wxTreebookEvent wxBookCtrlEvent -typedef wxBookCtrlEventFunction wxTreebookEventFunction; -#define wxTreebookEventHandler(func) wxBookCtrlEventHandler(func) +class WXDLLEXPORT wxTreebookEvent : public wxBookCtrlBaseEvent +{ +public: + wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) + : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) + { + } + wxTreebookEvent(const wxTreebookEvent& event) + : wxBookCtrlBaseEvent(event) + { + } -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREEBOOK_NODE_COLLAPSED, wxBookCtrlEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TREEBOOK_NODE_EXPANDED, wxBookCtrlEvent ); + virtual wxEvent *Clone() const { return new wxTreebookEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTreebookEvent) +}; + +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED; +extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED; + +typedef void (wxEvtHandler::*wxTreebookEventFunction)(wxTreebookEvent&); + +#define wxTreebookEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTreebookEventFunction, &func) #define EVT_TREEBOOK_PAGE_CHANGED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TREEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, winid, wxTreebookEventHandler(fn)) #define EVT_TREEBOOK_PAGE_CHANGING(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TREEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, winid, wxTreebookEventHandler(fn)) #define EVT_TREEBOOK_NODE_COLLAPSED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TREEBOOK_NODE_COLLAPSED, winid, wxBookCtrlEventHandler(fn)) + wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, winid, wxTreebookEventHandler(fn)) #define EVT_TREEBOOK_NODE_EXPANDED(winid, fn) \ - wx__DECLARE_EVT1(wxEVT_TREEBOOK_NODE_EXPANDED, winid, wxBookCtrlEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED wxEVT_TREEBOOK_PAGE_CHANGED -#define wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING wxEVT_TREEBOOK_PAGE_CHANGING -#define wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED wxEVT_TREEBOOK_NODE_COLLAPSED -#define wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED wxEVT_TREEBOOK_NODE_EXPANDED + wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, winid, wxTreebookEventHandler(fn)) #endif // wxUSE_TREEBOOK diff --git a/Source/3rd Party/wx/include/wx/treectrl.h b/Source/3rd Party/wx/include/wx/treectrl.h index ffa71fe84..2b919cbd5 100644 --- a/Source/3rd Party/wx/include/wx/treectrl.h +++ b/Source/3rd Party/wx/include/wx/treectrl.h @@ -5,6 +5,7 @@ // Modified by: // Created: // Copyright: (c) Karsten Ballueder +// RCS-ID: $Id: treectrl.h 49563 2007-10-31 20:46:21Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ #include "wx/control.h" #include "wx/treebase.h" -#include "wx/textctrl.h" // wxTextCtrl::ms_classinfo used through wxCLASSINFO macro +#include "wx/textctrl.h" // wxTextCtrl::ms_classinfo used through CLASSINFO macro class WXDLLIMPEXP_FWD_CORE wxImageList; @@ -29,10 +30,23 @@ class WXDLLIMPEXP_FWD_CORE wxImageList; // wxTreeCtrlBase // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreeCtrlBase : public wxControl +class WXDLLEXPORT wxTreeCtrlBase : public wxControl { public: - wxTreeCtrlBase(); + wxTreeCtrlBase() + { + m_imageListNormal = + m_imageListState = NULL; + m_ownsImageListNormal = + m_ownsImageListState = false; + + // arbitrary default + m_spacing = 18; + + // quick DoGetBestSize calculation + m_quickBestSize = true; + } + virtual ~wxTreeCtrlBase(); // accessors @@ -104,18 +118,12 @@ public: // get the item's font virtual wxFont GetItemFont(const wxTreeItemId& item) const = 0; - // get the items state - int GetItemState(const wxTreeItemId& item) const - { - return DoGetItemState(item); - } - // modifiers // --------- // set items label virtual void SetItemText(const wxTreeItemId& item, const wxString& text) = 0; - // set one of the images associated with the item (normal by default) + // get one of the images associated with the item (normal by default) virtual void SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal) = 0; @@ -148,9 +156,6 @@ public: virtual void SetItemFont(const wxTreeItemId& item, const wxFont& font) = 0; - // set the items state (special state values: wxTREE_ITEMSTATE_NONE/NEXT/PREV) - void SetItemState(const wxTreeItemId& item, int state); - // item status inquiries // --------------------- @@ -167,8 +172,10 @@ public: virtual bool IsSelected(const wxTreeItemId& item) const = 0; // is item text in bold font? virtual bool IsBold(const wxTreeItemId& item) const = 0; +#if wxABI_VERSION >= 20801 // is the control empty? bool IsEmpty() const; +#endif // wxABI 2.8.1+ // number of children @@ -196,17 +203,6 @@ public: // control with a lot of items (~ O(number of items)). virtual size_t GetSelections(wxArrayTreeItemIds& selections) const = 0; - // get the last item to be clicked when the control has wxTR_MULTIPLE - // equivalent to GetSelection() if not wxTR_MULTIPLE - virtual wxTreeItemId GetFocusedItem() const = 0; - - - // Clears the currently focused item - virtual void ClearFocusedItem() = 0; - // Sets the currently focused item. Item should be valid - virtual void SetFocusedItem(const wxTreeItemId& item) = 0; - - // get the parent of this item (may return NULL if root) virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const = 0; @@ -288,24 +284,26 @@ public: // delete this item and associated data if any virtual void Delete(const wxTreeItemId& item) = 0; // delete all children (but don't delete the item itself) - // NB: this won't send wxEVT_TREE_ITEM_DELETED events + // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events virtual void DeleteChildren(const wxTreeItemId& item) = 0; // delete all items from the tree - // NB: this won't send wxEVT_TREE_ITEM_DELETED events + // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events virtual void DeleteAllItems() = 0; // expand this item virtual void Expand(const wxTreeItemId& item) = 0; - // expand the item and all its children recursively + // expand the item and all its childs and thats childs void ExpandAllChildren(const wxTreeItemId& item); // expand all items void ExpandAll(); // collapse the item without removing its children virtual void Collapse(const wxTreeItemId& item) = 0; - // collapse the item and all its children +#if wxABI_VERSION >= 20801 + // collapse the item and all its childs and thats childs void CollapseAllChildren(const wxTreeItemId& item); // collapse all items void CollapseAll(); +#endif // wxABI 2.8.1+ // collapse the item and remove all children virtual void CollapseAndReset(const wxTreeItemId& item) = 0; // toggles the current state @@ -317,9 +315,6 @@ public: virtual void UnselectAll() = 0; // select this item virtual void SelectItem(const wxTreeItemId& item, bool select = true) = 0; - // selects all (direct) children for given parent (only for - // multiselection controls) - virtual void SelectChildren(const wxTreeItemId& parent) = 0; // unselect this item void UnselectItem(const wxTreeItemId& item) { SelectItem(item, false); } // toggle item selection @@ -339,7 +334,7 @@ public: // been before. textCtrlClass parameter allows you to create an edit // control of arbitrary user-defined class deriving from wxTextCtrl. virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, - wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)) = 0; + wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)) = 0; // returns the same pointer as StartEdit() if the item is being edited, // NULL otherwise (it's assumed that no more than one item may be // edited simultaneously) @@ -348,10 +343,6 @@ public: virtual void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false) = 0; - // Enable or disable beep when incremental match doesn't find any item. - // Only implemented in the generic version currently. - virtual void EnableBellOnNoMatch(bool WXUNUSED(on) = true) { } - // sorting // ------- @@ -400,10 +391,6 @@ public: protected: virtual wxSize DoGetBestSize() const; - // common part of Get/SetItemState() - virtual int DoGetItemState(const wxTreeItemId& item) const = 0; - virtual void DoSetItemState(const wxTreeItemId& item, int state) = 0; - // common part of Append/Prepend/InsertItem() // // pos is the position at which to insert the item or (size_t)-1 to append @@ -442,14 +429,7 @@ protected: bool m_quickBestSize; -private: - // Intercept Escape and Return keys to ensure that our in-place edit - // control always gets them before they're used for dialog navigation or - // anything else. - void OnCharHook(wxKeyEvent& event); - - - wxDECLARE_NO_COPY_CLASS(wxTreeCtrlBase); + DECLARE_NO_COPY_CLASS(wxTreeCtrlBase) }; // ---------------------------------------------------------------------------- @@ -458,6 +438,8 @@ private: #if defined(__WXUNIVERSAL__) #include "wx/generic/treectlg.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/treectrl.h" #elif defined(__WXMSW__) #include "wx/msw/treectrl.h" #elif defined(__WXMOTIF__) diff --git a/Source/3rd Party/wx/include/wx/treelist.h b/Source/3rd Party/wx/include/wx/treelist.h deleted file mode 100644 index d06e35e86..000000000 --- a/Source/3rd Party/wx/include/wx/treelist.h +++ /dev/null @@ -1,576 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/treelist.h -// Purpose: wxTreeListCtrl class declaration. -// Author: Vadim Zeitlin -// Created: 2011-08-17 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TREELIST_H_ -#define _WX_TREELIST_H_ - -#include "wx/defs.h" - -#if wxUSE_TREELISTCTRL - -#include "wx/compositewin.h" -#include "wx/containr.h" -#include "wx/headercol.h" -#include "wx/itemid.h" -#include "wx/vector.h" -#include "wx/window.h" -#include "wx/withimages.h" - -class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; -class WXDLLIMPEXP_FWD_ADV wxDataViewEvent; - -extern WXDLLIMPEXP_DATA_ADV(const char) wxTreeListCtrlNameStr[]; - -class wxTreeListCtrl; -class wxTreeListModel; -class wxTreeListModelNode; - -// ---------------------------------------------------------------------------- -// Constants. -// ---------------------------------------------------------------------------- - -// wxTreeListCtrl styles. -// -// Notice that using wxTL_USER_3STATE implies wxTL_3STATE and wxTL_3STATE in -// turn implies wxTL_CHECKBOX. -enum -{ - wxTL_SINGLE = 0x0000, // This is the default anyhow. - wxTL_MULTIPLE = 0x0001, // Allow multiple selection. - wxTL_CHECKBOX = 0x0002, // Show checkboxes in the first column. - wxTL_3STATE = 0x0004, // Allow 3rd state in checkboxes. - wxTL_USER_3STATE = 0x0008, // Allow user to set 3rd state. - wxTL_NO_HEADER = 0x0010, // Column titles not visible. - - wxTL_DEFAULT_STYLE = wxTL_SINGLE, - wxTL_STYLE_MASK = wxTL_SINGLE | - wxTL_MULTIPLE | - wxTL_CHECKBOX | - wxTL_3STATE | - wxTL_USER_3STATE -}; - -// ---------------------------------------------------------------------------- -// wxTreeListItem: unique identifier of an item in wxTreeListCtrl. -// ---------------------------------------------------------------------------- - -// Make wxTreeListItem a forward-declarable class even though it's simple -// enough to possibly be declared as a simple typedef. -class wxTreeListItem : public wxItemId -{ -public: - wxTreeListItem(wxTreeListModelNode* item = NULL) - : wxItemId(item) - { - } -}; - -// Container of multiple items. -typedef wxVector wxTreeListItems; - -// Some special "items" that can be used with InsertItem(): -extern WXDLLIMPEXP_DATA_ADV(const wxTreeListItem) wxTLI_FIRST; -extern WXDLLIMPEXP_DATA_ADV(const wxTreeListItem) wxTLI_LAST; - -// ---------------------------------------------------------------------------- -// wxTreeListItemComparator: defines order of wxTreeListCtrl items. -// ---------------------------------------------------------------------------- - -class wxTreeListItemComparator -{ -public: - wxTreeListItemComparator() { } - - // The comparison function should return negative, null or positive value - // depending on whether the first item is less than, equal to or greater - // than the second one. The items should be compared using their values for - // the given column. - virtual int - Compare(wxTreeListCtrl* treelist, - unsigned column, - wxTreeListItem first, - wxTreeListItem second) = 0; - - // Although this class is not used polymorphically by wxWidgets itself, - // provide virtual dtor in case it's used like this in the user code. - virtual ~wxTreeListItemComparator() { } - -private: - wxDECLARE_NO_COPY_CLASS(wxTreeListItemComparator); -}; - -// ---------------------------------------------------------------------------- -// wxTreeListCtrl: a control combining wxTree- and wxListCtrl features. -// ---------------------------------------------------------------------------- - -// This control also provides easy to use high level interface. Although the -// implementation uses wxDataViewCtrl internally, this class is intentionally -// simpler than wxDataViewCtrl and doesn't provide all of its functionality. -// -// If you need extra features you can always use GetDataView() accessor to work -// with wxDataViewCtrl directly but doing this makes your unportable to possible -// future non-wxDataViewCtrl-based implementations of this class. - -class WXDLLIMPEXP_ADV wxTreeListCtrl - : public wxCompositeWindow< wxNavigationEnabled >, - public wxWithImages -{ -public: - // Constructors and such - // --------------------- - - wxTreeListCtrl() { Init(); } - wxTreeListCtrl(wxWindow* parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTL_DEFAULT_STYLE, - const wxString& name = wxTreeListCtrlNameStr) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow* parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTL_DEFAULT_STYLE, - const wxString& name = wxTreeListCtrlNameStr); - - - virtual ~wxTreeListCtrl(); - - // Columns methods - // --------------- - - // Add a column with the given title and attributes, returns the index of - // the new column or -1 on failure. - int AppendColumn(const wxString& title, - int width = wxCOL_WIDTH_AUTOSIZE, - wxAlignment align = wxALIGN_LEFT, - int flags = wxCOL_RESIZABLE) - { - return DoInsertColumn(title, -1, width, align, flags); - } - - // Return the total number of columns. - unsigned GetColumnCount() const; - - // Delete the column with the given index, returns false if index is - // invalid or deleting the column failed for some other reason. - bool DeleteColumn(unsigned col); - - // Delete all columns. - void ClearColumns(); - - // Set column width to either the given value in pixels or to the value - // large enough to fit all of the items if width == wxCOL_WIDTH_AUTOSIZE. - void SetColumnWidth(unsigned col, int width); - - // Get the current width of the given column in pixels. - int GetColumnWidth(unsigned col) const; - - // Get the width appropriate for showing the given text. This is typically - // used as second argument for AppendColumn() or with SetColumnWidth(). - int WidthFor(const wxString& text) const; - - - // Item methods - // ------------ - - // Adding items. The parent and text of the first column of the new item - // must always be specified, the rest is optional. - // - // Each item can have two images: one used for closed state and another for - // opened one. Only the first one is ever used for the items that don't - // have children. And both are not set by default. - // - // It is also possible to associate arbitrary client data pointer with the - // new item. It will be deleted by the control when the item is deleted - // (either by an explicit DeleteItem() call or because the entire control - // is destroyed). - - wxTreeListItem AppendItem(wxTreeListItem parent, - const wxString& text, - int imageClosed = NO_IMAGE, - int imageOpened = NO_IMAGE, - wxClientData* data = NULL) - { - return DoInsertItem(parent, wxTLI_LAST, text, - imageClosed, imageOpened, data); - } - - wxTreeListItem InsertItem(wxTreeListItem parent, - wxTreeListItem previous, - const wxString& text, - int imageClosed = NO_IMAGE, - int imageOpened = NO_IMAGE, - wxClientData* data = NULL) - { - return DoInsertItem(parent, previous, text, - imageClosed, imageOpened, data); - } - - wxTreeListItem PrependItem(wxTreeListItem parent, - const wxString& text, - int imageClosed = NO_IMAGE, - int imageOpened = NO_IMAGE, - wxClientData* data = NULL) - { - return DoInsertItem(parent, wxTLI_FIRST, text, - imageClosed, imageOpened, data); - } - - // Deleting items. - void DeleteItem(wxTreeListItem item); - void DeleteAllItems(); - - - // Tree navigation - // --------------- - - // Return the (never shown) root item. - wxTreeListItem GetRootItem() const; - - // The parent item may be invalid for the root-level items. - wxTreeListItem GetItemParent(wxTreeListItem item) const; - - // Iterate over the given item children: start by calling GetFirstChild() - // and then call GetNextSibling() for as long as it returns valid item. - wxTreeListItem GetFirstChild(wxTreeListItem item) const; - wxTreeListItem GetNextSibling(wxTreeListItem item) const; - - // Return the first child of the root item, which is also the first item of - // the tree in depth-first traversal order. - wxTreeListItem GetFirstItem() const { return GetFirstChild(GetRootItem()); } - - // Get item after the given one in the depth-first tree-traversal order. - // Calling this function starting with the result of GetFirstItem() allows - // iterating over all items in the tree. - wxTreeListItem GetNextItem(wxTreeListItem item) const; - - - // Items attributes - // ---------------- - - const wxString& GetItemText(wxTreeListItem item, unsigned col = 0) const; - - // The convenience overload below sets the text for the first column. - void SetItemText(wxTreeListItem item, unsigned col, const wxString& text); - void SetItemText(wxTreeListItem item, const wxString& text) - { - SetItemText(item, 0, text); - } - - // By default the opened image is the same as the normal, closed one (if - // it's used at all). - void SetItemImage(wxTreeListItem item, int closed, int opened = NO_IMAGE); - - // Retrieve or set the data associated with the item. - wxClientData* GetItemData(wxTreeListItem item) const; - void SetItemData(wxTreeListItem item, wxClientData* data); - - - // Expanding and collapsing - // ------------------------ - - void Expand(wxTreeListItem item); - void Collapse(wxTreeListItem item); - bool IsExpanded(wxTreeListItem item) const; - - - // Selection handling - // ------------------ - - // This function can be used with single selection controls, use - // GetSelections() with the multi-selection ones. - wxTreeListItem GetSelection() const; - - // This one can be used with either single or multi-selection controls. - unsigned GetSelections(wxTreeListItems& selections) const; - - // In single selection mode Select() deselects any other selected items, in - // multi-selection case it adds to the selection. - void Select(wxTreeListItem item); - - // Can be used in multiple selection mode only, single selected item in the - // single selection mode can't be unselected. - void Unselect(wxTreeListItem item); - - // Return true if the item is selected, can be used in both single and - // multiple selection modes. - bool IsSelected(wxTreeListItem item) const; - - // Select or unselect all items, only valid in multiple selection mode. - void SelectAll(); - void UnselectAll(); - - - // Checkbox handling - // ----------------- - - // Methods in this section can only be used with the controls created with - // wxTL_CHECKBOX style. - - // Simple set, unset or query the checked state. - void CheckItem(wxTreeListItem item, wxCheckBoxState state = wxCHK_CHECKED); - void UncheckItem(wxTreeListItem item) { CheckItem(item, wxCHK_UNCHECKED); } - - // The same but do it recursively for this item itself and its children. - void CheckItemRecursively(wxTreeListItem item, - wxCheckBoxState state = wxCHK_CHECKED); - - // Update the parent of this item recursively: if this item and all its - // siblings are checked, the parent will become checked as well. If this - // item and all its siblings are unchecked, the parent will be unchecked. - // And if the siblings of this item are not all in the same state, the - // parent will be switched to indeterminate state. And then the same logic - // will be applied to the parents parent and so on recursively. - // - // This is typically called when the state of the given item has changed - // from EVT_TREELIST_ITEM_CHECKED() handler in the controls which have - // wxTL_3STATE flag. Notice that without this flag this function can't work - // as it would be unable to set the state of a parent with both checked and - // unchecked items so it's only allowed to call it when this flag is set. - void UpdateItemParentStateRecursively(wxTreeListItem item); - - // Return the current state. - wxCheckBoxState GetCheckedState(wxTreeListItem item) const; - - // Return true if all item children (if any) are in the given state. - bool AreAllChildrenInState(wxTreeListItem item, - wxCheckBoxState state) const; - - - - // Sorting. - // -------- - - // Sort by the given column, either in ascending (default) or descending - // sort order. - // - // By default, simple alphabetical sorting is done by this column contents - // but SetItemComparator() may be called to perform comparison in some - // other way. - void SetSortColumn(unsigned col, bool ascendingOrder = true); - - // If the control contents is sorted, return true and fill the output - // parameters with the column which is currently used for sorting and - // whether we sort using ascending or descending order. Otherwise, i.e. if - // the control contents is unsorted, simply return false. - bool GetSortColumn(unsigned* col, bool* ascendingOrder = NULL); - - // Set the object to use for comparing the items. It will be called when - // the control is being sorted because the user clicked on a sortable - // column. - // - // The provided pointer is stored by the control so the object it points to - // must have a life-time equal or greater to that of the control itself. In - // addition, the pointer can be NULL to stop using custom comparator and - // revert to the default alphabetical comparison. - void SetItemComparator(wxTreeListItemComparator* comparator); - - - // View window functions. - // ---------------------- - - // This control itself is entirely covered by the "view window" which is - // currently a wxDataViewCtrl but if you want to avoid relying on this to - // allow your code to work with later versions which might not be - // wxDataViewCtrl-based, use the first function only and only use the - // second one if you really need to call wxDataViewCtrl methods on it. - wxWindow* GetView() const; - wxDataViewCtrl* GetDataView() const { return m_view; } - -private: - // Common part of all ctors. - void Init(); - - // Pure virtual method inherited from wxCompositeWindow. - virtual wxWindowList GetCompositeWindowParts() const; - - // Implementation of AppendColumn(). - int DoInsertColumn(const wxString& title, - int pos, // May be -1 meaning "append". - int width, - wxAlignment align, - int flags); - - // Common part of {Append,Insert,Prepend}Item(). - wxTreeListItem DoInsertItem(wxTreeListItem parent, - wxTreeListItem previous, - const wxString& text, - int imageClosed, - int imageOpened, - wxClientData* data); - - // Send wxTreeListEvent corresponding to the given wxDataViewEvent for an - // item (as opposed for column-oriented events). - // - // Also updates the original event "skipped" and "vetoed" flags. - void SendItemEvent(wxEventType evt, wxDataViewEvent& event); - - // Send wxTreeListEvent corresponding to the given column wxDataViewEvent. - void SendColumnEvent(wxEventType evt, wxDataViewEvent& event); - - - // Called by wxTreeListModel when an item is toggled by the user. - void OnItemToggled(wxTreeListItem item, wxCheckBoxState stateOld); - - // Event handlers. - void OnSelectionChanged(wxDataViewEvent& event); - void OnItemExpanding(wxDataViewEvent& event); - void OnItemExpanded(wxDataViewEvent& event); - void OnItemActivated(wxDataViewEvent& event); - void OnItemContextMenu(wxDataViewEvent& event); - void OnColumnSorted(wxDataViewEvent& event); - void OnSize(wxSizeEvent& event); - - wxDECLARE_EVENT_TABLE(); - - - wxDataViewCtrl* m_view; - wxTreeListModel* m_model; - - wxTreeListItemComparator* m_comparator; - - - // It calls our inherited protected wxWithImages::GetImage() method. - friend class wxTreeListModel; - - wxDECLARE_NO_COPY_CLASS(wxTreeListCtrl); -}; - -// ---------------------------------------------------------------------------- -// wxTreeListEvent: event generated by wxTreeListCtrl. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxTreeListEvent : public wxNotifyEvent -{ -public: - // Default ctor is provided for wxRTTI needs only but should never be used. - wxTreeListEvent() { Init(); } - - // The item affected by the event. Valid for all events except - // column-specific ones such as COLUMN_SORTED. - wxTreeListItem GetItem() const { return m_item; } - - // The previous state of the item checkbox for ITEM_CHECKED events only. - wxCheckBoxState GetOldCheckedState() const { return m_oldCheckedState; } - - // The index of the column affected by the event. Currently only used by - // COLUMN_SORTED event. - unsigned GetColumn() const { return m_column; } - - virtual wxEvent* Clone() const { return new wxTreeListEvent(*this); } - -private: - // Common part of all ctors. - void Init() - { - m_column = static_cast(-1); - - m_oldCheckedState = wxCHK_UNDETERMINED; - } - - // Ctor is private, only wxTreeListCtrl can create events of this type. - wxTreeListEvent(wxEventType evtType, - wxTreeListCtrl* treelist, - wxTreeListItem item) - : wxNotifyEvent(evtType, treelist->GetId()), - m_item(item) - { - SetEventObject(treelist); - - Init(); - } - - // Set the checkbox state before this event for ITEM_CHECKED events. - void SetOldCheckedState(wxCheckBoxState state) - { - m_oldCheckedState = state; - } - - // Set the column affected by this event for COLUMN_SORTED events. - void SetColumn(unsigned column) - { - m_column = column; - } - - - const wxTreeListItem m_item; - - wxCheckBoxState m_oldCheckedState; - - unsigned m_column; - - friend class wxTreeListCtrl; - - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTreeListEvent); -}; - -// Event types and event table macros. - -typedef void (wxEvtHandler::*wxTreeListEventFunction)(wxTreeListEvent&); - -#define wxTreeListEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxTreeListEventFunction, func) - -#define wxEVT_TREELIST_GENERIC(name, id, fn) \ - wx__DECLARE_EVT1(wxEVT_TREELIST_##name, id, wxTreeListEventHandler(fn)) - -#define wxDECLARE_TREELIST_EVENT(name) \ - wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, \ - wxEVT_TREELIST_##name, \ - wxTreeListEvent) - -wxDECLARE_TREELIST_EVENT(SELECTION_CHANGED); -#define EVT_TREELIST_SELECTION_CHANGED(id, fn) \ - wxEVT_TREELIST_GENERIC(SELECTION_CHANGED, id, fn) - -wxDECLARE_TREELIST_EVENT(ITEM_EXPANDING); -#define EVT_TREELIST_ITEM_EXPANDING(id, fn) \ - wxEVT_TREELIST_GENERIC(ITEM_EXPANDING, id, fn) - -wxDECLARE_TREELIST_EVENT(ITEM_EXPANDED); -#define EVT_TREELIST_ITEM_EXPANDED(id, fn) \ - wxEVT_TREELIST_GENERIC(ITEM_EXPANDED, id, fn) - -wxDECLARE_TREELIST_EVENT(ITEM_CHECKED); -#define EVT_TREELIST_ITEM_CHECKED(id, fn) \ - wxEVT_TREELIST_GENERIC(ITEM_CHECKED, id, fn) - -wxDECLARE_TREELIST_EVENT(ITEM_ACTIVATED); -#define EVT_TREELIST_ITEM_ACTIVATED(id, fn) \ - wxEVT_TREELIST_GENERIC(ITEM_ACTIVATED, id, fn) - -wxDECLARE_TREELIST_EVENT(ITEM_CONTEXT_MENU); -#define EVT_TREELIST_ITEM_CONTEXT_MENU(id, fn) \ - wxEVT_TREELIST_GENERIC(ITEM_CONTEXT_MENU, id, fn) - -wxDECLARE_TREELIST_EVENT(COLUMN_SORTED); -#define EVT_TREELIST_COLUMN_SORTED(id, fn) \ - wxEVT_TREELIST_GENERIC(COLUMN_SORTED, id, fn) - -#undef wxDECLARE_TREELIST_EVENT - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_TREELIST_SELECTION_CHANGED wxEVT_TREELIST_SELECTION_CHANGED -#define wxEVT_COMMAND_TREELIST_ITEM_EXPANDING wxEVT_TREELIST_ITEM_EXPANDING -#define wxEVT_COMMAND_TREELIST_ITEM_EXPANDED wxEVT_TREELIST_ITEM_EXPANDED -#define wxEVT_COMMAND_TREELIST_ITEM_CHECKED wxEVT_TREELIST_ITEM_CHECKED -#define wxEVT_COMMAND_TREELIST_ITEM_ACTIVATED wxEVT_TREELIST_ITEM_ACTIVATED -#define wxEVT_COMMAND_TREELIST_ITEM_CONTEXT_MENU wxEVT_TREELIST_ITEM_CONTEXT_MENU -#define wxEVT_COMMAND_TREELIST_COLUMN_SORTED wxEVT_TREELIST_COLUMN_SORTED - -#endif // wxUSE_TREELISTCTRL - -#endif // _WX_TREELIST_H_ diff --git a/Source/3rd Party/wx/include/wx/txtstrm.h b/Source/3rd Party/wx/include/wx/txtstrm.h index 3a367792d..0e2b0c955 100644 --- a/Source/3rd Party/wx/include/wx/txtstrm.h +++ b/Source/3rd Party/wx/include/wx/txtstrm.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: // Created: 28/06/1998 +// RCS-ID: $Id: txtstrm.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -44,8 +45,6 @@ public: #endif ~wxTextInputStream(); - const wxInputStream& GetInputStream() const { return m_input; } - wxUint32 Read32(int base = 10); // base may be between 2 and 36, inclusive, or the special 0 (= C format) wxUint16 Read16(int base = 10); wxUint8 Read8(int base = 10); @@ -94,7 +93,7 @@ protected: wxChar NextChar(); // this should be used instead of GetC() because of Unicode issues wxChar NextNonSeparators(); - wxDECLARE_NO_COPY_CLASS(wxTextInputStream); + DECLARE_NO_COPY_CLASS(wxTextInputStream) }; typedef enum @@ -117,8 +116,6 @@ public: #endif virtual ~wxTextOutputStream(); - const wxOutputStream& GetOutputStream() const { return m_output; } - void SetMode( wxEOL mode = wxEOL_NATIVE ); wxEOL GetMode() { return m_mode; } @@ -130,8 +127,7 @@ public: wxTextOutputStream& PutChar(wxChar c); - void Flush(); - + wxTextOutputStream& operator<<(const wxChar *string); wxTextOutputStream& operator<<(const wxString& string); wxTextOutputStream& operator<<(char c); #if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE @@ -154,7 +150,7 @@ protected: wxMBConv *m_conv; #endif - wxDECLARE_NO_COPY_CLASS(wxTextOutputStream); + DECLARE_NO_COPY_CLASS(wxTextOutputStream) }; #endif diff --git a/Source/3rd Party/wx/include/wx/typeinfo.h b/Source/3rd Party/wx/include/wx/typeinfo.h deleted file mode 100644 index a783af5d5..000000000 --- a/Source/3rd Party/wx/include/wx/typeinfo.h +++ /dev/null @@ -1,147 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/typeinfo.h -// Purpose: wxTypeId implementation -// Author: Jaakko Salli -// Created: 2009-11-19 -// Copyright: (c) wxWidgets Team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TYPEINFO_H_ -#define _WX_TYPEINFO_H_ - -// -// This file defines wxTypeId macro that should be used internally in -// wxWidgets instead of typeid(), for compatibility with builds that do -// not implement C++ RTTI. Also, type defining macros in this file are -// intended for internal use only at this time and may change in future -// versions. -// -// The reason why we need this simple RTTI system in addition to the older -// wxObject-based one is that the latter does not work in template -// classes. -// - -#include "wx/defs.h" - -#ifndef wxNO_RTTI - -// -// Let's trust that Visual C++ versions 9.0 and later implement C++ -// RTTI well enough, so we can use it and work around harmless memory -// leaks reported by the static run-time libraries. -// -#if wxCHECK_VISUALC_VERSION(9) - #define wxTRUST_CPP_RTTI 1 -#else - #define wxTRUST_CPP_RTTI 0 -#endif - -#include -#include - -#define _WX_DECLARE_TYPEINFO_CUSTOM(CLS, IDENTFUNC) -#define WX_DECLARE_TYPEINFO_INLINE(CLS) -#define WX_DECLARE_TYPEINFO(CLS) -#define WX_DEFINE_TYPEINFO(CLS) -#define WX_DECLARE_ABSTRACT_TYPEINFO(CLS) - -#if wxTRUST_CPP_RTTI - -#define wxTypeId typeid - -#else /* !wxTRUST_CPP_RTTI */ - -// -// For improved type-safety, let's make the check using class name -// comparison. Most modern compilers already do this, but we cannot -// rely on all supported compilers to work this well. However, in -// cases where we'd know that typeid() would be flawless (as such), -// wxTypeId could of course simply be defined as typeid. -// - -class wxTypeIdentifier -{ -public: - wxTypeIdentifier(const char* className) - { - m_className = className; - } - - bool operator==(const wxTypeIdentifier& other) - { - return strcmp(m_className, other.m_className) == 0; - } - - bool operator!=(const wxTypeIdentifier& other) - { - return strcmp(m_className, other.m_className) != 0; - } -private: - const char* m_className; -}; - -#define wxTypeId(OBJ) wxTypeIdentifier(typeid(OBJ).name()) - -#endif /* wxTRUST_CPP_RTTI/!wxTRUST_CPP_RTTI */ - -#else // if !wxNO_RTTI - -#define wxTRUST_CPP_RTTI 0 - -// -// When C++ RTTI is not available, we will have to make the type comparison -// using pointer to a dummy static member function. This will fail if -// declared type is used across DLL boundaries, although using -// WX_DECLARE_TYPEINFO() and WX_DEFINE_TYPEINFO() pair instead of -// WX_DECLARE_TYPEINFO_INLINE() should fix this. However, that approach is -// usually not possible when type info needs to be declared for a template -// class. -// - -typedef void (*wxTypeIdentifier)(); - -// Use this macro to declare type info with specified static function -// IDENTFUNC used as type identifier. Usually you should only use -// WX_DECLARE_TYPEINFO() or WX_DECLARE_TYPEINFO_INLINE() however. -#define _WX_DECLARE_TYPEINFO_CUSTOM(CLS, IDENTFUNC) \ -public: \ - virtual wxTypeIdentifier GetWxTypeId() const \ - { \ - return reinterpret_cast \ - (&IDENTFUNC); \ - } - -// Use this macro to declare type info with externally specified -// type identifier, defined with WX_DEFINE_TYPEINFO(). -#define WX_DECLARE_TYPEINFO(CLS) \ -private: \ - static CLS sm_wxClassInfo(); \ -_WX_DECLARE_TYPEINFO_CUSTOM(CLS, sm_wxClassInfo) - -// Use this macro to implement type identifier function required by -// WX_DECLARE_TYPEINFO(). -// NOTE: CLS is required to have default ctor. If it doesn't -// already, you should provide a private dummy one. -#define WX_DEFINE_TYPEINFO(CLS) \ -CLS CLS::sm_wxClassInfo() { return CLS(); } - -// Use this macro to declare type info fully inline in class. -// NOTE: CLS is required to have default ctor. If it doesn't -// already, you should provide a private dummy one. -#define WX_DECLARE_TYPEINFO_INLINE(CLS) \ -private: \ - static CLS sm_wxClassInfo() { return CLS(); } \ -_WX_DECLARE_TYPEINFO_CUSTOM(CLS, sm_wxClassInfo) - -#define wxTypeId(OBJ) (OBJ).GetWxTypeId() - -// Because abstract classes cannot be instantiated, we use -// this macro to define pure virtual type interface for them. -#define WX_DECLARE_ABSTRACT_TYPEINFO(CLS) \ -public: \ - virtual wxTypeIdentifier GetWxTypeId() const = 0; - -#endif // wxNO_RTTI/!wxNO_RTTI - -#endif // _WX_TYPEINFO_H_ diff --git a/Source/3rd Party/wx/include/wx/types.h b/Source/3rd Party/wx/include/wx/types.h deleted file mode 100644 index 2e5858216..000000000 --- a/Source/3rd Party/wx/include/wx/types.h +++ /dev/null @@ -1,92 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/types.h -// Purpose: Type identifiers, used by resource system -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TYPESH__ -#define _WX_TYPESH__ - -// Types of objects -#define wxTYPE_ANY 0 -#define wxTYPE_OBJECT wxTYPE_ANY -#define wxTYPE_WINDOW 1 -#define wxTYPE_DIALOG_BOX 2 -#define wxTYPE_ITEM 3 -#define wxTYPE_PANEL 4 -#define wxTYPE_CANVAS 5 -#define wxTYPE_TEXT_WINDOW 6 -#define wxTYPE_FRAME 7 - -#define wxTYPE_BUTTON 8 -#define wxTYPE_TEXT 9 -#define wxTYPE_MESSAGE 10 -#define wxTYPE_CHOICE 11 -#define wxTYPE_LIST_BOX 12 -#define wxTYPE_SLIDER 13 -#define wxTYPE_CHECK_BOX 14 -#define wxTYPE_MENU 15 -#define wxTYPE_MENU_BAR 16 -#define wxTYPE_MULTI_TEXT 17 -#define wxTYPE_RADIO_BOX 18 -#define wxTYPE_GROUP_BOX 19 -#define wxTYPE_GAUGE 20 -#define wxTYPE_SCROLL_BAR 21 -#define wxTYPE_VIRT_LIST_BOX 22 -#define wxTYPE_COMBO_BOX 23 -#define wxTYPE_RADIO_BUTTON 24 - -#define wxTYPE_EVENT 25 -#define wxTYPE_DC 26 -#define wxTYPE_DC_CANVAS 27 -#define wxTYPE_DC_POSTSCRIPT 28 -#define wxTYPE_DC_PRINTER 29 -#define wxTYPE_DC_METAFILE 30 -#define wxTYPE_DC_MEMORY 31 -#define wxTYPE_MOUSE_EVENT 32 -#define wxTYPE_KEY_EVENT 33 -#define wxTYPE_COMMAND_EVENT 34 -#define wxTYPE_DC_PANEL 35 - -#define wxTYPE_PEN 40 -#define wxTYPE_BRUSH 41 -#define wxTYPE_FONT 42 -#define wxTYPE_ICON 42 -#define wxTYPE_BITMAP 43 -#define wxTYPE_METAFILE 44 -#define wxTYPE_TIMER 45 -#define wxTYPE_COLOUR 46 -#define wxTYPE_COLOURMAP 47 -#define wxTYPE_CURSOR 48 - -#define wxTYPE_DDE_CLIENT 60 -#define wxTYPE_DDE_SERVER 61 -#define wxTYPE_DDE_CONNECTION 62 - -#define wxTYPE_HELP_INSTANCE 63 - -#define wxTYPE_LIST 70 -#define wxTYPE_STRING_LIST 71 -#define wxTYPE_HASH_TABLE 72 -#define wxTYPE_NODE 73 -#define wxTYPE_APP 74 -#define wxTYPE_DATE 75 - -#define wxTYPE_ENHANCED_DIALOG 80 -#define wxTYPE_TOOLBAR 81 -#define wxTYPE_BUTTONBAR 82 - -#define wxTYPE_DATABASE 90 -#define wxTYPE_QUERY_FIELD 91 -#define wxTYPE_QUERY_COL 92 -#define wxTYPE_RECORDSET 93 - -#define wxTYPE_USER 500 - -#endif - // _WX_TYPESH__ - diff --git a/Source/3rd Party/wx/include/wx/uiaction.h b/Source/3rd Party/wx/include/wx/uiaction.h deleted file mode 100644 index fb9652354..000000000 --- a/Source/3rd Party/wx/include/wx/uiaction.h +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/uiaction.h -// Purpose: wxUIActionSimulator interface -// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin -// Modified by: -// Created: 2010-03-06 -// Copyright: (c) Kevin Ollivier -// (c) 2010 Steven Lamerton -// (c) 2010 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_UIACTIONSIMULATOR_H_ -#define _WX_UIACTIONSIMULATOR_H_ - -#include "wx/defs.h" - -#if wxUSE_UIACTIONSIMULATOR - -#include "wx/mousestate.h" // for wxMOUSE_BTN_XXX constants - -class WXDLLIMPEXP_CORE wxUIActionSimulator -{ -public: - wxUIActionSimulator() { } - - - // Default dtor, copy ctor and assignment operator are ok (even though the - // last two don't make much sense for this class). - - - // Mouse simulation - // ---------------- - - // Low level methods - bool MouseMove(long x, long y); - bool MouseMove(const wxPoint& point) { return MouseMove(point.x, point.y); } - - bool MouseDown(int button = wxMOUSE_BTN_LEFT); - bool MouseUp(int button = wxMOUSE_BTN_LEFT); - - // Higher level interface, use it if possible instead - bool MouseClick(int button = wxMOUSE_BTN_LEFT); - bool MouseDblClick(int button = wxMOUSE_BTN_LEFT); - bool MouseDragDrop(long x1, long y1, long x2, long y2, - int button = wxMOUSE_BTN_LEFT); - bool MouseDragDrop(const wxPoint& p1, const wxPoint& p2, - int button = wxMOUSE_BTN_LEFT) - { return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); } - - // Keyboard simulation - // ------------------- - - // Low level methods for generating key presses and releases - bool KeyDown(int keycode, int modifiers = wxMOD_NONE) - { return Key(keycode, modifiers, true); } - - bool KeyUp(int keycode, int modifiers = wxMOD_NONE) - { return Key(keycode, modifiers, false); } - - // Higher level methods for generating both the key press and release for a - // single key or for all characters in the ASCII string "text" which can currently - // contain letters, digits and characters for the definition of numbers [+-., ]. - bool Char(int keycode, int modifiers = wxMOD_NONE); - - bool Text(const char *text); - -private: - // This is the common part of Key{Down,Up}() methods: while we keep them - // separate at public API level for consistency with Mouse{Down,Up}(), at - // implementation level it makes more sense to have them in a single - // function. - // - // It calls DoModifiers() to simulate pressing the modifier keys if - // necessary and then DoKey() for the key itself. - bool Key(int keycode, int modifiers, bool isDown); - - // Call DoKey() for all modifier keys whose bits are set in the parameter. - void SimulateModifiers(int modifier, bool isDown); - - - // The low-level port-specific function which really generates the key - // presses. It should generate exactly one key event with the given - // parameters. - bool DoKey(int keycode, int modifiers, bool isDown); -}; - -#endif // wxUSE_UIACTIONSIMULATOR - -#endif // _WX_UIACTIONSIMULATOR_H_ diff --git a/Source/3rd Party/wx/include/wx/unichar.h b/Source/3rd Party/wx/include/wx/unichar.h deleted file mode 100644 index e9726943a..000000000 --- a/Source/3rd Party/wx/include/wx/unichar.h +++ /dev/null @@ -1,308 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/unichar.h -// Purpose: wxUniChar and wxUniCharRef classes -// Author: Vaclav Slavik -// Created: 2007-03-19 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_UNICHAR_H_ -#define _WX_UNICHAR_H_ - -#include "wx/defs.h" -#include "wx/chartype.h" -#include "wx/stringimpl.h" - -class WXDLLIMPEXP_FWD_BASE wxUniCharRef; -class WXDLLIMPEXP_FWD_BASE wxString; - -// This class represents single Unicode character. It can be converted to -// and from char or wchar_t and implements commonly used character operations. -class WXDLLIMPEXP_BASE wxUniChar -{ -public: - // NB: this is not wchar_t on purpose, it needs to represent the entire - // Unicode code points range and wchar_t may be too small for that - // (e.g. on Win32 where wchar_t* is encoded in UTF-16) - typedef wxUint32 value_type; - - wxUniChar() : m_value(0) {} - - // Create the character from 8bit character value encoded in the current - // locale's charset. - wxUniChar(char c) { m_value = From8bit(c); } - wxUniChar(unsigned char c) { m_value = From8bit((char)c); } - -#define wxUNICHAR_DEFINE_CTOR(type) \ - wxUniChar(type c) { m_value = (value_type)c; } - wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_CTOR) -#undef wxUNICHAR_DEFINE_CTOR - - wxUniChar(const wxUniCharRef& c); - - // Returns Unicode code point value of the character - value_type GetValue() const { return m_value; } - -#if wxUSE_UNICODE_UTF8 - // buffer for single UTF-8 character - struct Utf8CharBuffer - { - char data[5]; - operator const char*() const { return data; } - }; - - // returns the character encoded as UTF-8 - // (NB: implemented in stringops.cpp) - Utf8CharBuffer AsUTF8() const; -#endif // wxUSE_UNICODE_UTF8 - - // Returns true if the character is an ASCII character: - bool IsAscii() const { return m_value < 0x80; } - - // Returns true if the character is representable as a single byte in the - // current locale encoding and return this byte in output argument c (which - // must be non-NULL) - bool GetAsChar(char *c) const - { -#if wxUSE_UNICODE - if ( !IsAscii() ) - { -#if !wxUSE_UTF8_LOCALE_ONLY - if ( GetAsHi8bit(m_value, c) ) - return true; -#endif // !wxUSE_UTF8_LOCALE_ONLY - - return false; - } -#endif // wxUSE_UNICODE - - *c = wx_truncate_cast(char, m_value); - return true; - } - - // Conversions to char and wchar_t types: all of those are needed to be - // able to pass wxUniChars to verious standard narrow and wide character - // functions - operator char() const { return To8bit(m_value); } - operator unsigned char() const { return (unsigned char)To8bit(m_value); } - -#define wxUNICHAR_DEFINE_OPERATOR_PAREN(type) \ - operator type() const { return (type)m_value; } - wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_OPERATOR_PAREN) -#undef wxUNICHAR_DEFINE_OPERATOR_PAREN - - // We need this operator for the "*p" part of expressions like "for ( - // const_iterator p = begin() + nStart; *p; ++p )". In this case, - // compilation would fail without it because the conversion to bool would - // be ambiguous (there are all these int types conversions...). (And adding - // operator unspecified_bool_type() would only makes the ambiguity worse.) - operator bool() const { return m_value != 0; } - bool operator!() const { return !((bool)*this); } - - // And this one is needed by some (not all, but not using ifdefs makes the - // code easier) compilers to parse "str[0] && *p" successfully - bool operator&&(bool v) const { return (bool)*this && v; } - - // Assignment operators: - wxUniChar& operator=(const wxUniChar& c) { if (&c != this) m_value = c.m_value; return *this; } - wxUniChar& operator=(const wxUniCharRef& c); - wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; } - wxUniChar& operator=(unsigned char c) { m_value = From8bit((char)c); return *this; } - -#define wxUNICHAR_DEFINE_OPERATOR_EQUAL(type) \ - wxUniChar& operator=(type c) { m_value = (value_type)c; return *this; } - wxDO_FOR_INT_TYPES(wxUNICHAR_DEFINE_OPERATOR_EQUAL) -#undef wxUNICHAR_DEFINE_OPERATOR_EQUAL - - // Comparison operators: -#define wxDEFINE_UNICHAR_CMP_WITH_INT(T, op) \ - bool operator op(T c) const { return m_value op (value_type)c; } - - // define the given comparison operator for all the types -#define wxDEFINE_UNICHAR_OPERATOR(op) \ - bool operator op(const wxUniChar& c) const { return m_value op c.m_value; }\ - bool operator op(char c) const { return m_value op From8bit(c); } \ - bool operator op(unsigned char c) const { return m_value op From8bit((char)c); } \ - wxDO_FOR_INT_TYPES_1(wxDEFINE_UNICHAR_CMP_WITH_INT, op) - - wxFOR_ALL_COMPARISONS(wxDEFINE_UNICHAR_OPERATOR) - -#undef wxDEFINE_UNICHAR_OPERATOR -#undef wxDEFINE_UNCHAR_CMP_WITH_INT - - // this is needed for expressions like 'Z'-c - int operator-(const wxUniChar& c) const { return m_value - c.m_value; } - int operator-(char c) const { return m_value - From8bit(c); } - int operator-(unsigned char c) const { return m_value - From8bit((char)c); } - int operator-(wchar_t c) const { return m_value - (value_type)c; } - - -private: - // notice that we implement these functions inline for 7-bit ASCII - // characters purely for performance reasons - static value_type From8bit(char c) - { -#if wxUSE_UNICODE - if ( (unsigned char)c < 0x80 ) - return c; - - return FromHi8bit(c); -#else - return c; -#endif - } - - static char To8bit(value_type c) - { -#if wxUSE_UNICODE - if ( c < 0x80 ) - return wx_truncate_cast(char, c); - - return ToHi8bit(c); -#else - return wx_truncate_cast(char, c); -#endif - } - - // helpers of the functions above called to deal with non-ASCII chars - static value_type FromHi8bit(char c); - static char ToHi8bit(value_type v); - static bool GetAsHi8bit(value_type v, char *c); - -private: - value_type m_value; -}; - - -// Writeable reference to a character in wxString. -// -// This class can be used in the same way wxChar is used, except that changing -// its value updates the underlying string object. -class WXDLLIMPEXP_BASE wxUniCharRef -{ -private: - typedef wxStringImpl::iterator iterator; - - // create the reference -#if wxUSE_UNICODE_UTF8 - wxUniCharRef(wxString& str, iterator pos) : m_str(str), m_pos(pos) {} -#else - wxUniCharRef(iterator pos) : m_pos(pos) {} -#endif - -public: - // NB: we have to make this public, because we don't have wxString - // declaration available here and so can't declare wxString::iterator - // as friend; so at least don't use a ctor but a static function - // that must be used explicitly (this is more than using 'explicit' - // keyword on ctor!): -#if wxUSE_UNICODE_UTF8 - static wxUniCharRef CreateForString(wxString& str, iterator pos) - { return wxUniCharRef(str, pos); } -#else - static wxUniCharRef CreateForString(iterator pos) - { return wxUniCharRef(pos); } -#endif - - wxUniChar::value_type GetValue() const { return UniChar().GetValue(); } - -#if wxUSE_UNICODE_UTF8 - wxUniChar::Utf8CharBuffer AsUTF8() const { return UniChar().AsUTF8(); } -#endif // wxUSE_UNICODE_UTF8 - - bool IsAscii() const { return UniChar().IsAscii(); } - bool GetAsChar(char *c) const { return UniChar().GetAsChar(c); } - - // Assignment operators: -#if wxUSE_UNICODE_UTF8 - wxUniCharRef& operator=(const wxUniChar& c); -#else - wxUniCharRef& operator=(const wxUniChar& c) { *m_pos = c; return *this; } -#endif - - wxUniCharRef& operator=(const wxUniCharRef& c) - { if (&c != this) *this = c.UniChar(); return *this; } - -#define wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL(type) \ - wxUniCharRef& operator=(type c) { return *this = wxUniChar(c); } - wxDO_FOR_CHAR_INT_TYPES(wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL) -#undef wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL - - // Conversions to the same types as wxUniChar is convertible too: -#define wxUNICHAR_REF_DEFINE_OPERATOR_PAREN(type) \ - operator type() const { return UniChar(); } - wxDO_FOR_CHAR_INT_TYPES(wxUNICHAR_REF_DEFINE_OPERATOR_PAREN) -#undef wxUNICHAR_REF_DEFINE_OPERATOR_PAREN - - // see wxUniChar::operator bool etc. for explanation - operator bool() const { return (bool)UniChar(); } - bool operator!() const { return !UniChar(); } - bool operator&&(bool v) const { return UniChar() && v; } - -#define wxDEFINE_UNICHARREF_CMP_WITH_INT(T, op) \ - bool operator op(T c) const { return UniChar() op c; } - - // Comparison operators: -#define wxDEFINE_UNICHARREF_OPERATOR(op) \ - bool operator op(const wxUniCharRef& c) const { return UniChar() op c.UniChar(); }\ - bool operator op(const wxUniChar& c) const { return UniChar() op c; } \ - wxDO_FOR_CHAR_INT_TYPES_1(wxDEFINE_UNICHARREF_CMP_WITH_INT, op) - - wxFOR_ALL_COMPARISONS(wxDEFINE_UNICHARREF_OPERATOR) - -#undef wxDEFINE_UNICHARREF_OPERATOR -#undef wxDEFINE_UNICHARREF_CMP_WITH_INT - - // for expressions like c-'A': - int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); } - int operator-(const wxUniChar& c) const { return UniChar() - c; } - int operator-(char c) const { return UniChar() - c; } - int operator-(unsigned char c) const { return UniChar() - c; } - int operator-(wchar_t c) const { return UniChar() - c; } - -private: -#if wxUSE_UNICODE_UTF8 - wxUniChar UniChar() const; -#else - wxUniChar UniChar() const { return *m_pos; } -#endif - - friend class WXDLLIMPEXP_FWD_BASE wxUniChar; - -private: - // reference to the string and pointer to the character in string -#if wxUSE_UNICODE_UTF8 - wxString& m_str; -#endif - iterator m_pos; -}; - -inline wxUniChar::wxUniChar(const wxUniCharRef& c) -{ - m_value = c.UniChar().m_value; -} - -inline wxUniChar& wxUniChar::operator=(const wxUniCharRef& c) -{ - m_value = c.UniChar().m_value; - return *this; -} - -// Comparison operators for the case when wxUniChar(Ref) is the second operand -// implemented in terms of member comparison functions - -wxDEFINE_COMPARISONS_BY_REV(char, const wxUniChar&) -wxDEFINE_COMPARISONS_BY_REV(char, const wxUniCharRef&) - -wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniChar&) -wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniCharRef&) - -wxDEFINE_COMPARISONS_BY_REV(const wxUniChar&, const wxUniCharRef&) - -// for expressions like c-'A': -inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); } -inline int operator-(const wxUniChar& c1, const wxUniCharRef& c2) { return -(c2 - c1); } -inline int operator-(wchar_t c1, const wxUniCharRef& c2) { return -(c2 - c1); } - -#endif /* _WX_UNICHAR_H_ */ diff --git a/Source/3rd Party/wx/include/wx/uri.h b/Source/3rd Party/wx/include/wx/uri.h index 9978d20bf..33d843c60 100644 --- a/Source/3rd Party/wx/include/wx/uri.h +++ b/Source/3rd Party/wx/include/wx/uri.h @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/uri.h +// Name: uri.h // Purpose: wxURI - Class for parsing URIs // Author: Ryan Norton -// Vadim Zeitlin (UTF-8 URI support, many other changes) +// Modified By: // Created: 07/01/2004 -// Copyright: (c) 2004 Ryan Norton -// 2008 Vadim Zeitlin +// RCS-ID: $Id: uri.h 35650 2005-09-23 12:56:45Z MR $ +// Copyright: (c) Ryan Norton // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +15,6 @@ #include "wx/defs.h" #include "wx/object.h" #include "wx/string.h" -#include "wx/arrstr.h" // Host Type that the server component can be enum wxURIHostType @@ -53,119 +52,84 @@ class WXDLLIMPEXP_BASE wxURI : public wxObject public: wxURI(); wxURI(const wxString& uri); + wxURI(const wxURI& uri); - // default copy ctor, assignment operator and dtor are ok + virtual ~wxURI(); - bool Create(const wxString& uri); + const wxChar* Create(const wxString& uri); - wxURI& operator=(const wxString& string) - { - Create(string); - return *this; - } + bool HasScheme() const { return (m_fields & wxURI_SCHEME) == wxURI_SCHEME; } + bool HasUserInfo() const { return (m_fields & wxURI_USERINFO) == wxURI_USERINFO; } + bool HasServer() const { return (m_fields & wxURI_SERVER) == wxURI_SERVER; } + bool HasPort() const { return (m_fields & wxURI_PORT) == wxURI_PORT; } + bool HasPath() const { return (m_fields & wxURI_PATH) == wxURI_PATH; } + bool HasQuery() const { return (m_fields & wxURI_QUERY) == wxURI_QUERY; } + bool HasFragment() const { return (m_fields & wxURI_FRAGMENT) == wxURI_FRAGMENT; } - bool operator==(const wxURI& uri) const; + const wxString& GetScheme() const { return m_scheme; } + const wxString& GetPath() const { return m_path; } + const wxString& GetQuery() const { return m_query; } + const wxString& GetFragment() const { return m_fragment; } + const wxString& GetPort() const { return m_port; } + const wxString& GetUserInfo() const { return m_userinfo; } + const wxString& GetServer() const { return m_server; } + const wxURIHostType& GetHostType() const { return m_hostType; } - // various accessors - - bool HasScheme() const { return (m_fields & wxURI_SCHEME) != 0; } - bool HasUserInfo() const { return (m_fields & wxURI_USERINFO) != 0; } - bool HasServer() const { return (m_fields & wxURI_SERVER) != 0; } - bool HasPort() const { return (m_fields & wxURI_PORT) != 0; } - bool HasPath() const { return (m_fields & wxURI_PATH) != 0; } - bool HasQuery() const { return (m_fields & wxURI_QUERY) != 0; } - bool HasFragment() const { return (m_fields & wxURI_FRAGMENT) != 0; } - - const wxString& GetScheme() const { return m_scheme; } - const wxString& GetPath() const { return m_path; } - const wxString& GetQuery() const { return m_query; } - const wxString& GetFragment() const { return m_fragment; } - const wxString& GetPort() const { return m_port; } - const wxString& GetUserInfo() const { return m_userinfo; } - const wxString& GetServer() const { return m_server; } - wxURIHostType GetHostType() const { return m_hostType; } - - // these functions only work if the user information part of the URI is in - // the usual (but insecure and hence explicitly recommended against by the - // RFC) "user:password" form + //Note that the following two get functions are explicitly depreciated by RFC 2396 wxString GetUser() const; wxString GetPassword() const; - - // combine all URI components into a single string - // - // BuildURI() returns the real URI suitable for use with network libraries, - // for example, while BuildUnescapedURI() returns a string suitable to be - // shown to the user. - wxString BuildURI() const { return DoBuildURI(&wxURI::Nothing); } - wxString BuildUnescapedURI() const { return DoBuildURI(&wxURI::Unescape); } - - // the escaped URI should contain only ASCII characters, including possible - // escape sequences - static wxString Unescape(const wxString& escapedURI); - + wxString BuildURI() const; + wxString BuildUnescapedURI() const; void Resolve(const wxURI& base, int flags = wxURI_STRICT); bool IsReference() const; + wxURI& operator = (const wxURI& uri); + wxURI& operator = (const wxString& string); + bool operator == (const wxURI& uri) const; + + static wxString Unescape (const wxString& szEscapedURI); + protected: + wxURI& Assign(const wxURI& uri); + void Clear(); - // common part of BuildURI() and BuildUnescapedURI() - wxString DoBuildURI(wxString (*funcDecode)(const wxString&)) const; - - // function which returns its argument unmodified, this is used by - // BuildURI() to tell DoBuildURI() that nothing needs to be done with the - // URI components - static wxString Nothing(const wxString& value) { return value; } - - bool Parse(const char* uri); - - const char* ParseAuthority (const char* uri); - const char* ParseScheme (const char* uri); - const char* ParseUserInfo (const char* uri); - const char* ParseServer (const char* uri); - const char* ParsePort (const char* uri); - const char* ParsePath (const char* uri); - const char* ParseQuery (const char* uri); - const char* ParseFragment (const char* uri); + const wxChar* Parse (const wxChar* uri); + const wxChar* ParseAuthority (const wxChar* uri); + const wxChar* ParseScheme (const wxChar* uri); + const wxChar* ParseUserInfo (const wxChar* uri); + const wxChar* ParseServer (const wxChar* uri); + const wxChar* ParsePort (const wxChar* uri); + const wxChar* ParsePath (const wxChar* uri, + bool bReference = false, + bool bNormalize = true); + const wxChar* ParseQuery (const wxChar* uri); + const wxChar* ParseFragment (const wxChar* uri); - static bool ParseH16(const char*& uri); - static bool ParseIPv4address(const char*& uri); - static bool ParseIPv6address(const char*& uri); - static bool ParseIPvFuture(const char*& uri); + static bool ParseH16(const wxChar*& uri); + static bool ParseIPv4address(const wxChar*& uri); + static bool ParseIPv6address(const wxChar*& uri); + static bool ParseIPvFuture(const wxChar*& uri); - // should be called with i pointing to '%', returns the encoded character - // following it or -1 if invalid and advances i past it (so that it points - // to the last character consumed on return) - static int DecodeEscape(wxString::const_iterator& i); + static void Normalize(wxChar* uri, bool bIgnoreLeads = false); + static void UpTree(const wxChar* uristart, const wxChar*& uri); - // append next character pointer to by p to the string in an escaped form - // and advance p past it - // - // if the next character is '%' and it's followed by 2 hex digits, they are - // not escaped (again) by this function, this allows to keep (backwards- - // compatible) ambiguity about the input format to wxURI::Create(): it can - // be either already escaped or not - void AppendNextEscaped(wxString& s, const char *& p); + static wxChar TranslateEscape(const wxChar* s); + static void Escape (wxString& s, const wxChar& c); + static bool IsEscape(const wxChar*& uri); - // convert hexadecimal digit to its value; return -1 if c isn't valid - static int CharToHex(char c); + static wxChar CharToHex(const wxChar& c); - // split an URI path string in its component segments (including empty and - // "." ones, no post-processing is done) - static wxArrayString SplitInSegments(const wxString& path); - - // various URI grammar helpers - static bool IsUnreserved(char c); - static bool IsReserved(char c); - static bool IsGenDelim(char c); - static bool IsSubDelim(char c); - static bool IsHex(char c); - static bool IsAlpha(char c); - static bool IsDigit(char c); - static bool IsEndPath(char c); + static bool IsUnreserved (const wxChar& c); + static bool IsReserved (const wxChar& c); + static bool IsGenDelim (const wxChar& c); + static bool IsSubDelim (const wxChar& c); + static bool IsHex(const wxChar& c); + static bool IsAlpha(const wxChar& c); + static bool IsDigit(const wxChar& c); wxString m_scheme; wxString m_path; diff --git a/Source/3rd Party/wx/include/wx/url.h b/Source/3rd Party/wx/include/wx/url.h deleted file mode 100644 index 572cae8b1..000000000 --- a/Source/3rd Party/wx/include/wx/url.h +++ /dev/null @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/url.h -// Purpose: URL parser -// Author: Guilhem Lavaux -// Modified by: Ryan Norton -// Created: 20/07/1997 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_URL_H -#define _WX_URL_H - -#include "wx/defs.h" - -#if wxUSE_URL - -#include "wx/uri.h" -#include "wx/protocol/protocol.h" - -#if wxUSE_PROTOCOL_HTTP - #include "wx/protocol/http.h" -#endif - -typedef enum { - wxURL_NOERR = 0, - wxURL_SNTXERR, - wxURL_NOPROTO, - wxURL_NOHOST, - wxURL_NOPATH, - wxURL_CONNERR, - wxURL_PROTOERR -} wxURLError; - -#if wxUSE_URL_NATIVE -class WXDLLIMPEXP_FWD_NET wxURL; - -class WXDLLIMPEXP_NET wxURLNativeImp : public wxObject -{ -public: - virtual ~wxURLNativeImp() { } - virtual wxInputStream *GetInputStream(wxURL *owner) = 0; -}; -#endif // wxUSE_URL_NATIVE - -class WXDLLIMPEXP_NET wxURL : public wxURI -{ -public: - wxURL(const wxString& sUrl = wxEmptyString); - wxURL(const wxURI& uri); - wxURL(const wxURL& url); - virtual ~wxURL(); - - wxURL& operator = (const wxString& url); - wxURL& operator = (const wxURI& uri); - wxURL& operator = (const wxURL& url); - - wxProtocol& GetProtocol() { return *m_protocol; } - wxURLError GetError() const { return m_error; } - wxString GetURL() const { return m_url; } - - wxURLError SetURL(const wxString &url) - { *this = url; return m_error; } - - bool IsOk() const - { return m_error == wxURL_NOERR; } - - wxInputStream *GetInputStream(); - -#if wxUSE_PROTOCOL_HTTP - static void SetDefaultProxy(const wxString& url_proxy); - void SetProxy(const wxString& url_proxy); -#endif // wxUSE_PROTOCOL_HTTP - -protected: - static wxProtoInfo *ms_protocols; - -#if wxUSE_PROTOCOL_HTTP - static wxHTTP *ms_proxyDefault; - static bool ms_useDefaultProxy; - wxHTTP *m_proxy; - bool m_useProxy; -#endif // wxUSE_PROTOCOL_HTTP - -#if wxUSE_URL_NATIVE - friend class wxURLNativeImp; - // pointer to a native URL implementation object - wxURLNativeImp *m_nativeImp; - // Creates on the heap and returns a native - // implementation object for the current platform. - static wxURLNativeImp *CreateNativeImpObject(); -#endif // wxUSE_URL_NATIVE - - wxProtoInfo *m_protoinfo; - wxProtocol *m_protocol; - - wxURLError m_error; - wxString m_url; - - void Init(const wxString&); - bool ParseURL(); - void CleanData(); - void Free(); - bool FetchProtocol(); - - friend class wxProtoInfo; - friend class wxURLModule; - -private: - DECLARE_DYNAMIC_CLASS(wxURL) -}; - -#endif // wxUSE_URL - -#endif // _WX_URL_H - diff --git a/Source/3rd Party/wx/include/wx/ustring.h b/Source/3rd Party/wx/include/wx/ustring.h deleted file mode 100644 index 7c58fddd8..000000000 --- a/Source/3rd Party/wx/include/wx/ustring.h +++ /dev/null @@ -1,749 +0,0 @@ - -// Name: wx/ustring.h -// Purpose: 32-bit string (UCS-4) -// Author: Robert Roebling -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_USTRING_H_ -#define _WX_USTRING_H_ - -#include "wx/defs.h" -#include "wx/string.h" - -#include - -#if SIZEOF_WCHAR_T == 2 -typedef wxWCharBuffer wxU16CharBuffer; -typedef wxScopedWCharBuffer wxScopedU16CharBuffer; -#else -typedef wxCharTypeBuffer wxU16CharBuffer; -typedef wxScopedCharTypeBuffer wxScopedU16CharBuffer; -#endif - -#if SIZEOF_WCHAR_T == 4 -typedef wxWCharBuffer wxU32CharBuffer; -typedef wxScopedWCharBuffer wxScopedU32CharBuffer; -#else -typedef wxCharTypeBuffer wxU32CharBuffer; -typedef wxScopedCharTypeBuffer wxScopedU32CharBuffer; -#endif - -#ifdef __VISUALC__ - // "non dll-interface class 'std::basic_string' used as base - // interface for dll-interface class 'wxString'" -- this is OK in our case - // (and warning is unavoidable anyhow) - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -class WXDLLIMPEXP_BASE wxUString: public std::basic_string -{ -public: - wxUString() { } - - wxUString( const wxChar32 *str ) { assign(str); } - wxUString( const wxScopedU32CharBuffer &buf ) { assign(buf); } - - wxUString( const char *str ) { assign(str); } - wxUString( const wxScopedCharBuffer &buf ) { assign(buf); } - wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); } - wxUString( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); } - - wxUString( const wxChar16 *str ) { assign(str); } - wxUString( const wxScopedU16CharBuffer &buf ) { assign(buf); } - - wxUString( const wxCStrData *cstr ) { assign(cstr); } - wxUString( const wxString &str ) { assign(str); } - - wxUString( char ch ) { assign(ch); } - wxUString( wxChar16 ch ) { assign(ch); } - wxUString( wxChar32 ch ) { assign(ch); } - wxUString( wxUniChar ch ) { assign(ch); } - wxUString( wxUniCharRef ch ) { assign(ch); } - wxUString( size_type n, char ch ) { assign(n,ch); } - wxUString( size_type n, wxChar16 ch ) { assign(n,ch); } - wxUString( size_type n, wxChar32 ch ) { assign(n,ch); } - wxUString( size_type n, wxUniChar ch ) { assign(n,ch); } - wxUString( size_type n, wxUniCharRef ch ) { assign(n,ch); } - - // static construction - - static wxUString FromAscii( const char *str, size_type n ) - { - wxUString ret; - ret.assignFromAscii( str, n ); - return ret; - } - - static wxUString FromAscii( const char *str ) - { - wxUString ret; - ret.assignFromAscii( str ); - return ret; - } - - static wxUString FromUTF8( const char *str, size_type n ) - { - wxUString ret; - ret.assignFromUTF8( str, n ); - return ret; - } - - static wxUString FromUTF8( const char *str ) - { - wxUString ret; - ret.assignFromUTF8( str ); - return ret; - } - - static wxUString FromUTF16( const wxChar16 *str, size_type n ) - { - wxUString ret; - ret.assignFromUTF16( str, n ); - return ret; - } - - static wxUString FromUTF16( const wxChar16 *str ) - { - wxUString ret; - ret.assignFromUTF16( str ); - return ret; - } - - // assign from encoding - - wxUString &assignFromAscii( const char *str ); - wxUString &assignFromAscii( const char *str, size_type n ); - wxUString &assignFromUTF8( const char *str ); - wxUString &assignFromUTF8( const char *str, size_type n ); - wxUString &assignFromUTF16( const wxChar16* str ); - wxUString &assignFromUTF16( const wxChar16* str, size_type n ); - wxUString &assignFromCString( const char* str ); - wxUString &assignFromCString( const char* str, const wxMBConv &conv ); - - // conversions - - wxScopedCharBuffer utf8_str() const; - wxScopedU16CharBuffer utf16_str() const; - -#if SIZEOF_WCHAR_T == 2 - wxScopedWCharBuffer wc_str() const - { - return utf16_str(); - } -#else - wchar_t *wc_str() const - { - return (wchar_t*) c_str(); - } -#endif - - operator wxString() const - { -#if wxUSE_UNICODE_UTF8 - return wxString::FromUTF8( utf8_str() ); -#else -#if SIZEOF_WCHAR_T == 2 - return wxString( utf16_str() ); -#else - return wxString( c_str() ); -#endif -#endif - } - -#if wxUSE_UNICODE_UTF8 - wxScopedCharBuffer wx_str() - { - return utf8_str(); - } -#else -#if SIZEOF_WCHAR_T == 2 - wxScopedWCharBuffer wx_str() - { - return utf16_str(); - } -#else - const wchar_t* wx_str() - { - return c_str(); - } -#endif -#endif - - // assign - - wxUString &assign( const wxChar32* str ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( str ); - } - - wxUString &assign( const wxChar32* str, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( str, n ); - } - - wxUString &assign( const wxUString &str ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( str ); - } - - wxUString &assign( const wxUString &str, size_type pos, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( str, pos, n ); - } - - // FIXME-VC6: VC 6.0 stl does not support all types of assign functions - #ifdef __VISUALC6__ - wxUString &assign( wxChar32 ch ) - { - wxChar32 chh[1]; - chh[0] = ch; - std::basic_string *base = this; - return (wxUString &)base->assign(chh); - } - - wxUString &assign( size_type n, wxChar32 ch ) - { - wxU32CharBuffer buffer(n); - wxChar32 *p = buffer.data(); - size_type i; - for (i = 0; i < n; i++) - { - *p = ch; - p++; - } - - std::basic_string *base = this; - return (wxUString &)base->assign(buffer.data()); - } - #else - wxUString &assign( wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( (size_type) 1, ch ); - } - - wxUString &assign( size_type n, wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( n, ch ); - } - #endif // __VISUALC6__ - - wxUString &assign( const wxScopedU32CharBuffer &buf ) - { - return assign( buf.data() ); - } - - wxUString &assign( const char *str ) - { - return assignFromCString( str ); - } - - wxUString &assign( const wxScopedCharBuffer &buf ) - { - return assignFromCString( buf.data() ); - } - - wxUString &assign( const char *str, const wxMBConv &conv ) - { - return assignFromCString( str, conv ); - } - - wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv ) - { - return assignFromCString( buf.data(), conv ); - } - - wxUString &assign( const wxChar16 *str ) - { - return assignFromUTF16( str ); - } - - wxUString &assign( const wxScopedU16CharBuffer &buf ) - { - return assignFromUTF16( buf.data() ); - } - - wxUString &assign( const wxCStrData *cstr ) - { -#if SIZEOF_WCHAR_T == 2 - return assignFromUTF16( cstr->AsWChar() ); -#else - return assign( cstr->AsWChar() ); -#endif - } - - wxUString &assign( const wxString &str ) - { -#if wxUSE_UNICODE_UTF8 - return assignFromUTF8( str.wx_str() ); -#else - #if SIZEOF_WCHAR_T == 2 - return assignFromUTF16( str.wc_str() ); - #else - return assign( str.wc_str() ); - #endif -#endif - } - - wxUString &assign( char ch ) - { - char buf[2]; - buf[0] = ch; - buf[1] = 0; - return assignFromCString( buf ); - } - - wxUString &assign( size_type n, char ch ) - { - wxCharBuffer buffer(n); - char *p = buffer.data(); - size_type i; - for (i = 0; i < n; i++) - { - *p = ch; - p++; - } - return assignFromCString( buffer.data() ); - } - - wxUString &assign( wxChar16 ch ) - { - wxChar16 buf[2]; - buf[0] = ch; - buf[1] = 0; - return assignFromUTF16( buf ); - } - - wxUString &assign( size_type n, wxChar16 ch ) - { - wxU16CharBuffer buffer(n); - wxChar16 *p = buffer.data(); - size_type i; - for (i = 0; i < n; i++) - { - *p = ch; - p++; - } - return assignFromUTF16( buffer.data() ); - } - - wxUString &assign( wxUniChar ch ) - { - return assign( (wxChar32) ch.GetValue() ); - } - - wxUString &assign( size_type n, wxUniChar ch ) - { - return assign( n, (wxChar32) ch.GetValue() ); - } - - wxUString &assign( wxUniCharRef ch ) - { - return assign( (wxChar32) ch.GetValue() ); - } - - wxUString &assign( size_type n, wxUniCharRef ch ) - { - return assign( n, (wxChar32) ch.GetValue() ); - } - - // append [STL overload] - - wxUString &append( const wxUString &s ) - { - std::basic_string *base = this; - return (wxUString &) base->append( s ); - } - - wxUString &append( const wxUString &s, size_type pos, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->append( s, pos, n ); - } - - wxUString &append( const wxChar32* s ) - { - std::basic_string *base = this; - return (wxUString &) base->append( s ); - } - - wxUString &append( const wxChar32* s, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->append( s, n ); - } - - // FIXME-VC6: VC 6.0 stl does not support all types of append functions - #ifdef __VISUALC6__ - wxUString &append( size_type n, wxChar32 c ) - { - wxU32CharBuffer buffer(n); - wxChar32 *p = buffer.data(); - size_type i; - for (i = 0; i < n; i++) - { - *p = c; - p++; - } - - std::basic_string *base = this; - return (wxUString &) base->append(buffer.data()); - } - #else - wxUString &append( size_type n, wxChar32 c ) - { - std::basic_string *base = this; - return (wxUString &) base->append( n, c ); - } - #endif // __VISUALC6__ - - wxUString &append( wxChar32 c ) - { - std::basic_string *base = this; - return (wxUString &) base->append( 1, c ); - } - - // append [wx overload] - - wxUString &append( const wxScopedU16CharBuffer &buf ) - { - return append( buf.data() ); - } - - wxUString &append( const wxScopedU32CharBuffer &buf ) - { - return append( buf.data() ); - } - - wxUString &append( const char *str ) - { - return append( wxUString( str ) ); - } - - wxUString &append( const wxScopedCharBuffer &buf ) - { - return append( wxUString( buf ) ); - } - - wxUString &append( const wxChar16 *str ) - { - return append( wxUString( str ) ); - } - - wxUString &append( const wxString &str ) - { - return append( wxUString( str ) ); - } - - wxUString &append( const wxCStrData *cstr ) - { - return append( wxUString( cstr ) ); - } - - wxUString &append( char ch ) - { - char buf[2]; - buf[0] = ch; - buf[1] = 0; - return append( buf ); - } - - wxUString &append( wxChar16 ch ) - { - wxChar16 buf[2]; - buf[0] = ch; - buf[1] = 0; - return append( buf ); - } - - wxUString &append( wxUniChar ch ) - { - return append( (size_type) 1, (wxChar32) ch.GetValue() ); - } - - wxUString &append( wxUniCharRef ch ) - { - return append( (size_type) 1, (wxChar32) ch.GetValue() ); - } - - - // insert [STL overloads] - - wxUString &insert( size_type pos, const wxUString &s ) - { - std::basic_string *base = this; - return (wxUString &) base->insert( pos, s ); - } - - wxUString &insert( size_type pos, const wxUString &s, size_type pos1, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->insert( pos, s, pos1, n ); - } - - wxUString &insert( size_type pos, const wxChar32 *s ) - { - std::basic_string *base = this; - return (wxUString &) base->insert( pos, s ); - } - - wxUString &insert( size_type pos, const wxChar32 *s, size_type n ) - { - std::basic_string *base = this; - return (wxUString &) base->insert( pos, s, n ); - } - - wxUString &insert( size_type pos, size_type n, wxChar32 c ) - { - std::basic_string *base = this; - return (wxUString &) base->insert( pos, n, c ); - } - - - // insert [STL overloads] - - wxUString &insert( size_type n, const char *s ) - { - return insert( n, wxUString( s ) ); - } - - wxUString &insert( size_type n, const wxChar16 *s ) - { - return insert( n, wxUString( s ) ); - } - - wxUString &insert( size_type n, const wxScopedCharBuffer &buf ) - { - return insert( n, wxUString( buf ) ); - } - - wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf ) - { - return insert( n, wxUString( buf ) ); - } - - wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf ) - { - return insert( n, buf.data() ); - } - - wxUString &insert( size_type n, const wxString &s ) - { - return insert( n, wxUString( s ) ); - } - - wxUString &insert( size_type n, const wxCStrData *cstr ) - { - return insert( n, wxUString( cstr ) ); - } - - wxUString &insert( size_type n, char ch ) - { - char buf[2]; - buf[0] = ch; - buf[1] = 0; - return insert( n, buf ); - } - - wxUString &insert( size_type n, wchar_t ch ) - { - wchar_t buf[2]; - buf[0] = ch; - buf[1] = 0; - return insert( n, buf ); - } - - // insert iterator - - iterator insert( iterator it, wxChar32 ch ) - { - std::basic_string *base = this; - return base->insert( it, ch ); - } - - void insert(iterator it, const_iterator first, const_iterator last) - { - std::basic_string *base = this; - base->insert( it, first, last ); - } - - - // operator = - wxUString& operator=(const wxString& s) - { return assign( s ); } - wxUString& operator=(const wxCStrData* s) - { return assign( s ); } - wxUString& operator=(const char *s) - { return assign( s ); } - wxUString& operator=(const wxChar16 *s) - { return assign( s ); } - wxUString& operator=(const wxChar32 *s) - { return assign( s ); } - wxUString& operator=(const wxScopedCharBuffer &s) - { return assign( s ); } - wxUString& operator=(const wxScopedU16CharBuffer &s) - { return assign( s ); } - wxUString& operator=(const wxScopedU32CharBuffer &s) - { return assign( s ); } - wxUString& operator=(const char ch) - { return assign( ch ); } - wxUString& operator=(const wxChar16 ch) - { return assign( ch ); } - wxUString& operator=(const wxChar32 ch) - { return assign( ch ); } - wxUString& operator=(const wxUniChar ch) - { return assign( ch ); } - wxUString& operator=(const wxUniCharRef ch) - { return assign( ch ); } - - // operator += - wxUString& operator+=(const wxUString& s) - { return append( s ); } - wxUString& operator+=(const wxString& s) - { return append( s ); } - wxUString& operator+=(const wxCStrData* s) - { return append( s ); } - wxUString& operator+=(const char *s) - { return append( s ); } - wxUString& operator+=(const wxChar16 *s) - { return append( s ); } - wxUString& operator+=(const wxChar32 *s) - { return append( s ); } - wxUString& operator+=(const wxScopedCharBuffer &s) - { return append( s ); } - wxUString& operator+=(const wxScopedU16CharBuffer &s) - { return append( s ); } - wxUString& operator+=(const wxScopedU32CharBuffer &s) - { return append( s ); } - wxUString& operator+=(const char ch) - { return append( ch ); } - wxUString& operator+=(const wxChar16 ch) - { return append( ch ); } - wxUString& operator+=(const wxChar32 ch) - { return append( ch ); } - wxUString& operator+=(const wxUniChar ch) - { return append( ch ); } - wxUString& operator+=(const wxUniCharRef ch) - { return append( ch ); } - -}; - -#ifdef __VISUALC__ - #pragma warning(pop) -#endif - -inline wxUString operator+(const wxUString &s1, const wxUString &s2) - { wxUString ret( s1 ); ret.append( s2 ); return ret; } -inline wxUString operator+(const wxUString &s1, const char *s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxString &s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxCStrData *s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxChar16* s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxChar32 *s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, char s2) - { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, wxChar32 s2) - { wxUString ret( s1 ); ret.append( s2 ); return ret; } -inline wxUString operator+(const wxUString &s1, wxChar16 s2) - { wxUString ret( s1 ); ret.append( (wxChar32) s2 ); return ret; } -inline wxUString operator+(const wxUString &s1, wxUniChar s2) - { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; } -inline wxUString operator+(const wxUString &s1, wxUniCharRef s2) - { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; } - -inline wxUString operator+(const char *s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxString &s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxCStrData *s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxChar16* s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxChar32 *s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(char s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(wxChar32 s1, const wxUString &s2 ) - { return wxUString(s1) + s2; } -inline wxUString operator+(wxChar16 s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(wxUniChar s1, const wxUString &s2) - { return wxUString(s1) + s2; } -inline wxUString operator+(wxUniCharRef s1, const wxUString &s2) - { return wxUString(s1) + s2; } - - -inline bool operator==(const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) == 0; } -inline bool operator!=(const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) != 0; } -inline bool operator< (const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) < 0; } -inline bool operator> (const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) > 0; } -inline bool operator<=(const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) <= 0; } -inline bool operator>=(const wxUString& s1, const wxUString& s2) - { return s1.compare( s2 ) >= 0; } - -#define wxUSTRING_COMP_OPERATORS( T ) \ -inline bool operator==(const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) == 0; } \ -inline bool operator!=(const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) != 0; } \ -inline bool operator< (const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) < 0; } \ -inline bool operator> (const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) > 0; } \ -inline bool operator<=(const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) <= 0; } \ -inline bool operator>=(const wxUString& s1, T s2) \ - { return s1.compare( wxUString(s2) ) >= 0; } \ -\ -inline bool operator==(T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) == 0; } \ -inline bool operator!=(T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) != 0; } \ -inline bool operator< (T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) > 0; } \ -inline bool operator> (T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) < 0; } \ -inline bool operator<=(T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) >= 0; } \ -inline bool operator>=(T s2, const wxUString& s1) \ - { return s1.compare( wxUString(s2) ) <= 0; } - -wxUSTRING_COMP_OPERATORS( const wxString & ) -wxUSTRING_COMP_OPERATORS( const char * ) -wxUSTRING_COMP_OPERATORS( const wxChar16 * ) -wxUSTRING_COMP_OPERATORS( const wxChar32 * ) -wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & ) -wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & ) -wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & ) -wxUSTRING_COMP_OPERATORS( const wxCStrData * ) - -#endif // _WX_USTRING_H_ diff --git a/Source/3rd Party/wx/include/wx/utils.h b/Source/3rd Party/wx/include/wx/utils.h index 3199597db..3ceca747a 100644 --- a/Source/3rd Party/wx/include/wx/utils.h +++ b/Source/3rd Party/wx/include/wx/utils.h @@ -4,12 +4,12 @@ // Author: Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: utils.h 62544 2009-11-03 14:11:30Z VZ $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_UTILS_H_ -#define _WX_UTILS_H_ +#ifndef _WX_UTILSH__ +#define _WX_UTILSH__ // ---------------------------------------------------------------------------- // headers @@ -18,13 +18,8 @@ #include "wx/object.h" #include "wx/list.h" #include "wx/filefn.h" -#include "wx/hashmap.h" -#include "wx/versioninfo.h" -#include "wx/meta/implicitconversion.h" - #if wxUSE_GUI #include "wx/gdicmn.h" - #include "wx/mousestate.h" #endif class WXDLLIMPEXP_FWD_BASE wxArrayString; @@ -34,7 +29,7 @@ class WXDLLIMPEXP_FWD_BASE wxArrayInt; // wxLongLong #include "wx/longlong.h" -// needed for wxOperatingSystemId, wxLinuxDistributionInfo +// need for wxOperatingSystemId #include "wx/platinfo.h" #ifdef __WATCOMC__ @@ -53,51 +48,15 @@ class WXDLLIMPEXP_FWD_BASE wxArrayInt; class WXDLLIMPEXP_FWD_BASE wxProcess; class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxWindow; -class wxWindowList; -class WXDLLIMPEXP_FWD_CORE wxEventLoop; +class WXDLLIMPEXP_FWD_CORE wxWindowList; // ---------------------------------------------------------------------------- -// Arithmetic functions +// Macros // ---------------------------------------------------------------------------- -template -inline typename wxImplicitConversionType::value -wxMax(T1 a, T2 b) -{ - typedef typename wxImplicitConversionType::value ResultType; - - // Cast both operands to the same type before comparing them to avoid - // warnings about signed/unsigned comparisons from some compilers: - return static_cast(a) > static_cast(b) ? a : b; -} - -template -inline typename wxImplicitConversionType::value -wxMin(T1 a, T2 b) -{ - typedef typename wxImplicitConversionType::value ResultType; - - return static_cast(a) < static_cast(b) ? a : b; -} - -template -inline typename wxImplicitConversionType3::value -wxClip(T1 a, T2 b, T3 c) -{ - typedef typename wxImplicitConversionType3::value ResultType; - - if ( static_cast(a) < static_cast(b) ) - return b; - - if ( static_cast(a) > static_cast(c) ) - return c; - - return a; -} - -// ---------------------------------------------------------------------------- -// wxMemorySize -// ---------------------------------------------------------------------------- +#define wxMax(a,b) (((a) > (b)) ? (a) : (b)) +#define wxMin(a,b) (((a) < (b)) ? (a) : (b)) +#define wxClip(a,b,c) (((a) < (b)) ? (b) : (((a) > (c)) ? (c) : (a))) // wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well // so to always use long long for its result type on all platforms which @@ -112,38 +71,32 @@ wxClip(T1 a, T2 b, T3 c) // String functions (deprecated, use wxString) // ---------------------------------------------------------------------------- -#if WXWIN_COMPATIBILITY_2_8 +// Make a copy of this string using 'new' +#if WXWIN_COMPATIBILITY_2_4 +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s) ); +#endif + // A shorter way of using strcmp -wxDEPRECATED_INLINE(inline bool wxStringEq(const char *s1, const char *s2), - return wxCRT_StrcmpA(s1, s2) == 0; ) - -#if wxUSE_UNICODE -wxDEPRECATED_INLINE(inline bool wxStringEq(const wchar_t *s1, const wchar_t *s2), - return wxCRT_StrcmpW(s1, s2) == 0; ) -#endif // wxUSE_UNICODE - -#endif // WXWIN_COMPATIBILITY_2_8 +#define wxStringEq(s1, s2) (s1 && s2 && (wxStrcmp(s1, s2) == 0)) // ---------------------------------------------------------------------------- // Miscellaneous functions // ---------------------------------------------------------------------------- // Sound the bell +#if !defined __EMX__ && \ + (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__) WXDLLIMPEXP_CORE void wxBell(); - -#if wxUSE_MSGDLG -// Show wxWidgets information -WXDLLIMPEXP_CORE void wxInfoMessageBox(wxWindow* parent); -#endif // wxUSE_MSGDLG - -WXDLLIMPEXP_CORE wxVersionInfo wxGetLibraryVersionInfo(); +#else +WXDLLIMPEXP_BASE void wxBell(); +#endif // Get OS description as a user-readable string WXDLLIMPEXP_BASE wxString wxGetOsDescription(); // Get OS version -WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL, - int *minorVsn = NULL); +WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = (int *) NULL, + int *minorVsn = (int *) NULL); // Get platform endianness WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); @@ -151,11 +104,6 @@ WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); // Get platform architecture WXDLLIMPEXP_BASE bool wxIsPlatform64Bit(); -#ifdef __LINUX__ -// Get linux-distro informations -WXDLLIMPEXP_BASE wxLinuxDistributionInfo wxGetLinuxDistributionInfo(); -#endif - // Return a string with the current date/time WXDLLIMPEXP_BASE wxString wxNow(); @@ -164,27 +112,6 @@ WXDLLIMPEXP_BASE const wxChar *wxGetInstallPrefix(); // Return path to wxWin data (/usr/share/wx/%{version}) (Unices) WXDLLIMPEXP_BASE wxString wxGetDataDir(); -#if wxUSE_GUI - -// Get the state of a key (true if pressed, false if not) -// This is generally most useful getting the state of -// the modifier or toggle keys. -WXDLLIMPEXP_CORE bool wxGetKeyState(wxKeyCode key); - -// Don't synthesize KeyUp events holding down a key and producing -// KeyDown events with autorepeat. On by default and always on -// in wxMSW. -WXDLLIMPEXP_CORE bool wxSetDetectableAutoRepeat( bool flag ); - -// Returns the current state of the mouse position, buttons and modifers -WXDLLIMPEXP_CORE wxMouseState wxGetMouseState(); - -#endif // wxUSE_GUI - -// ---------------------------------------------------------------------------- -// wxPlatform -// ---------------------------------------------------------------------------- - /* * Class to make it easier to specify platform-dependent values * @@ -208,7 +135,7 @@ class WXDLLIMPEXP_BASE wxPlatform public: wxPlatform() { Init(); } wxPlatform(const wxPlatform& platform) { Copy(platform); } - void operator = (const wxPlatform& platform) { if (&platform != this) Copy(platform); } + void operator = (const wxPlatform& platform) { Copy(platform); } void Copy(const wxPlatform& platform); // Specify an optional default value @@ -248,7 +175,8 @@ public: operator int() const { return (int) GetInteger(); } operator long() const { return GetInteger(); } operator double() const { return GetDouble(); } - operator const wxString&() const { return GetString(); } + operator const wxString() const { return GetString(); } + operator const wxChar*() const { return (const wxChar*) GetString(); } static void AddPlatform(int platform); static bool Is(int platform); @@ -267,48 +195,130 @@ private: /// Function for testing current platform inline bool wxPlatformIs(int platform) { return wxPlatform::Is(platform); } +#if wxUSE_GUI + +// Get the state of a key (true if pressed, false if not) +// This is generally most useful getting the state of +// the modifier or toggle keys. +WXDLLEXPORT bool wxGetKeyState(wxKeyCode key); + + +// Don't synthesize KeyUp events holding down a key and producing +// KeyDown events with autorepeat. On by default and always on +// in wxMSW. +WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag ); + + +// wxMouseState is used to hold information about button and modifier state +// and is what is returned from wxGetMouseState. +class WXDLLEXPORT wxMouseState +{ +public: + wxMouseState() + : m_x(0), m_y(0), + m_leftDown(false), m_middleDown(false), m_rightDown(false), + m_controlDown(false), m_shiftDown(false), m_altDown(false), + m_metaDown(false) + {} + + wxCoord GetX() { return m_x; } + wxCoord GetY() { return m_y; } + + bool LeftDown() { return m_leftDown; } + bool MiddleDown() { return m_middleDown; } + bool RightDown() { return m_rightDown; } + +#if wxABI_VERSION >= 20811 + bool LeftIsDown() { return m_leftDown; } + bool MiddleIsDown() { return m_middleDown; } + bool RightIsDown() { return m_rightDown; } +#endif // wx >= 2.8.11 + + bool ControlDown() { return m_controlDown; } + bool ShiftDown() { return m_shiftDown; } + bool AltDown() { return m_altDown; } + bool MetaDown() { return m_metaDown; } + bool CmdDown() + { +#if defined(__WXMAC__) || defined(__WXCOCOA__) + return MetaDown(); +#else + return ControlDown(); +#endif + } + + void SetX(wxCoord x) { m_x = x; } + void SetY(wxCoord y) { m_y = y; } + + void SetLeftDown(bool down) { m_leftDown = down; } + void SetMiddleDown(bool down) { m_middleDown = down; } + void SetRightDown(bool down) { m_rightDown = down; } + + void SetControlDown(bool down) { m_controlDown = down; } + void SetShiftDown(bool down) { m_shiftDown = down; } + void SetAltDown(bool down) { m_altDown = down; } + void SetMetaDown(bool down) { m_metaDown = down; } + +private: + wxCoord m_x; + wxCoord m_y; + + bool m_leftDown : 1; + bool m_middleDown : 1; + bool m_rightDown : 1; + + bool m_controlDown : 1; + bool m_shiftDown : 1; + bool m_altDown : 1; + bool m_metaDown : 1; +}; + + +// Returns the current state of the mouse position, buttons and modifers +WXDLLEXPORT wxMouseState wxGetMouseState(); + + // ---------------------------------------------------------------------------- // Window ID management // ---------------------------------------------------------------------------- +// Generate a unique ID +WXDLLEXPORT long wxNewId(); + // Ensure subsequent IDs don't clash with this one -WXDLLIMPEXP_BASE void wxRegisterId(int id); +WXDLLEXPORT void wxRegisterId(long id); // Return the current ID -WXDLLIMPEXP_BASE int wxGetCurrentId(); +WXDLLEXPORT long wxGetCurrentId(); -// Generate a unique ID -WXDLLIMPEXP_BASE int wxNewId(); +#endif // wxUSE_GUI // ---------------------------------------------------------------------------- // Various conversions // ---------------------------------------------------------------------------- +// these functions are deprecated, use wxString methods instead! +#if WXWIN_COMPATIBILITY_2_4 + +extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxFloatToStringStr; +extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDoubleToStringStr; + +wxDEPRECATED( WXDLLIMPEXP_BASE void StringToFloat(const wxChar *s, float *number) ); +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* FloatToString(float number, const wxChar *fmt = wxFloatToStringStr) ); +wxDEPRECATED( WXDLLIMPEXP_BASE void StringToDouble(const wxChar *s, double *number) ); +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* DoubleToString(double number, const wxChar *fmt = wxDoubleToStringStr) ); +wxDEPRECATED( WXDLLIMPEXP_BASE void StringToInt(const wxChar *s, int *number) ); +wxDEPRECATED( WXDLLIMPEXP_BASE void StringToLong(const wxChar *s, long *number) ); +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* IntToString(int number) ); +wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* LongToString(long number) ); + +#endif // WXWIN_COMPATIBILITY_2_4 + // Convert 2-digit hex number to decimal WXDLLIMPEXP_BASE int wxHexToDec(const wxString& buf); -// Convert 2-digit hex number to decimal -inline int wxHexToDec(const char* buf) -{ - int firstDigit, secondDigit; - - if (buf[0] >= 'A') - firstDigit = buf[0] - 'A' + 10; - else - firstDigit = buf[0] - '0'; - - if (buf[1] >= 'A') - secondDigit = buf[1] - 'A' + 10; - else - secondDigit = buf[1] - '0'; - - return (firstDigit & 0xF) * 16 + (secondDigit & 0xF ); -} - - // Convert decimal integer to 2-character hex string WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf); -WXDLLIMPEXP_BASE void wxDecToHex(int dec, char* ch1, char* ch2); WXDLLIMPEXP_BASE wxString wxDecToHex(int dec); // ---------------------------------------------------------------------------- @@ -328,46 +338,16 @@ enum // under Windows, don't hide the child even if it's IO is redirected (this // is done by default) - wxEXEC_SHOW_CONSOLE = 2, - - // deprecated synonym for wxEXEC_SHOW_CONSOLE, use the new name as it's - // more clear - wxEXEC_NOHIDE = wxEXEC_SHOW_CONSOLE, + wxEXEC_NOHIDE = 2, // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill // kills all children as well as pid - // under Windows (NT family only), sets the CREATE_NEW_PROCESS_GROUP flag, - // which allows to target Ctrl-Break signal to the spawned process. - // applies to console processes only. wxEXEC_MAKE_GROUP_LEADER = 4, // by default synchronous execution disables all program windows to avoid // that the user interacts with the program while the child process is // running, you can use this flag to prevent this from happening - wxEXEC_NODISABLE = 8, - - // by default, the event loop is run while waiting for synchronous execution - // to complete and this flag can be used to simply block the main process - // until the child process finishes - wxEXEC_NOEVENTS = 16, - - // under Windows, hide the console of the child process if it has one, even - // if its IO is not redirected - wxEXEC_HIDE_CONSOLE = 32, - - // convenient synonym for flags given system()-like behaviour - wxEXEC_BLOCK = wxEXEC_SYNC | wxEXEC_NOEVENTS -}; - -// Map storing environment variables. -typedef wxStringToStringHashMap wxEnvVariableHashMap; - -// Used to pass additional parameters for child process to wxExecute(). Could -// be extended with other fields later. -struct wxExecuteEnv -{ - wxString cwd; // If empty, CWD is not changed. - wxEnvVariableHashMap env; // If empty, environment is unchanged. + wxEXEC_NODISABLE = 8 }; // Execute another program. @@ -375,41 +355,29 @@ struct wxExecuteEnv // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on // failure and the PID of the launched process if ok. -WXDLLIMPEXP_BASE long wxExecute(const wxString& command, - int flags = wxEXEC_ASYNC, - wxProcess *process = NULL, - const wxExecuteEnv *env = NULL); -WXDLLIMPEXP_BASE long wxExecute(char **argv, - int flags = wxEXEC_ASYNC, - wxProcess *process = NULL, - const wxExecuteEnv *env = NULL); -#if wxUSE_UNICODE -WXDLLIMPEXP_BASE long wxExecute(wchar_t **argv, - int flags = wxEXEC_ASYNC, - wxProcess *process = NULL, - const wxExecuteEnv *env = NULL); -#endif // wxUSE_UNICODE +WXDLLIMPEXP_BASE long wxExecute(wxChar **argv, int flags = wxEXEC_ASYNC, + wxProcess *process = (wxProcess *) NULL); +WXDLLIMPEXP_BASE long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC, + wxProcess *process = (wxProcess *) NULL); // execute the command capturing its output into an array line by line, this is // always synchronous WXDLLIMPEXP_BASE long wxExecute(const wxString& command, wxArrayString& output, - int flags = 0, - const wxExecuteEnv *env = NULL); + int flags = 0); // also capture stderr (also synchronous) WXDLLIMPEXP_BASE long wxExecute(const wxString& command, wxArrayString& output, wxArrayString& error, - int flags = 0, - const wxExecuteEnv *env = NULL); + int flags = 0); -#if defined(__WINDOWS__) && wxUSE_IPC +#if defined(__WXMSW__) && wxUSE_IPC // ask a DDE server to execute the DDE request with given parameters WXDLLIMPEXP_BASE bool wxExecuteDDE(const wxString& ddeServer, const wxString& ddeTopic, const wxString& ddeCommand); -#endif // __WINDOWS__ && wxUSE_IPC +#endif // __WXMSW__ && wxUSE_IPC enum wxSignal { @@ -451,14 +419,12 @@ enum wxKillFlags enum wxShutdownFlags { - wxSHUTDOWN_FORCE = 1,// can be combined with other flags (MSW-only) - wxSHUTDOWN_POWEROFF = 2,// power off the computer - wxSHUTDOWN_REBOOT = 4,// shutdown and reboot - wxSHUTDOWN_LOGOFF = 8 // close session (currently MSW-only) + wxSHUTDOWN_POWEROFF, // power off the computer + wxSHUTDOWN_REBOOT // shutdown and reboot }; // Shutdown or reboot the PC -WXDLLIMPEXP_BASE bool wxShutdown(int flags = wxSHUTDOWN_POWEROFF); +WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags); // send the given signal to the process (only NONE and KILL are supported under // Windows, all others mean TERM), return 0 if ok and -1 on error @@ -486,10 +452,8 @@ WXDLLIMPEXP_BASE void wxMilliSleep(unsigned long milliseconds); // Sleep for a given amount of microseconds WXDLLIMPEXP_BASE void wxMicroSleep(unsigned long microseconds); -#if WXWIN_COMPATIBILITY_2_8 // Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep wxDEPRECATED( WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds) ); -#endif // Get the process id of the current process WXDLLIMPEXP_BASE unsigned long wxGetProcessId(); @@ -504,6 +468,15 @@ WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true); #endif // wxUSE_ON_FATAL_EXCEPTION +// flags for wxLaunchDefaultBrowser +enum +{ + wxBROWSER_NEW_WINDOW = 1 +}; + +// Launch url in the user's default internet browser +WXDLLIMPEXP_BASE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0); + // ---------------------------------------------------------------------------- // Environment variables // ---------------------------------------------------------------------------- @@ -513,37 +486,10 @@ WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true); WXDLLIMPEXP_BASE bool wxGetEnv(const wxString& var, wxString *value); // set the env var name to the given value, return true on success -WXDLLIMPEXP_BASE bool wxSetEnv(const wxString& var, const wxString& value); +WXDLLIMPEXP_BASE bool wxSetEnv(const wxString& var, const wxChar *value); // remove the env var from environment -WXDLLIMPEXP_BASE bool wxUnsetEnv(const wxString& var); - -#if WXWIN_COMPATIBILITY_2_8 -inline bool wxSetEnv(const wxString& var, const char *value) - { return wxSetEnv(var, wxString(value)); } -inline bool wxSetEnv(const wxString& var, const wchar_t *value) - { return wxSetEnv(var, wxString(value)); } -template -inline bool wxSetEnv(const wxString& var, const wxScopedCharTypeBuffer& value) - { return wxSetEnv(var, wxString(value)); } -inline bool wxSetEnv(const wxString& var, const wxCStrData& value) - { return wxSetEnv(var, wxString(value)); } - -// this one is for passing NULL directly - don't use it, use wxUnsetEnv instead -wxDEPRECATED( inline bool wxSetEnv(const wxString& var, int value) ); -inline bool wxSetEnv(const wxString& var, int value) -{ - wxASSERT_MSG( value == 0, "using non-NULL integer as string?" ); - - wxUnusedVar(value); // fix unused parameter warning in release build - - return wxUnsetEnv(var); -} -#endif // WXWIN_COMPATIBILITY_2_8 - -// Retrieve the complete environment by filling specified map. -// Returns true on success or false if an error occurred. -WXDLLIMPEXP_BASE bool wxGetEnvMap(wxEnvVariableHashMap *map); +inline bool wxUnsetEnv(const wxString& var) { return wxSetEnv(var, NULL); } // ---------------------------------------------------------------------------- // Network and username functions. @@ -575,10 +521,13 @@ WXDLLIMPEXP_BASE wxString wxGetUserName(); WXDLLIMPEXP_BASE wxString wxGetHomeDir(); WXDLLIMPEXP_BASE const wxChar* wxGetHomeDir(wxString *pstr); -// Get the user's (by default use the current user name) home dir, -// return empty string on error -WXDLLIMPEXP_BASE wxString wxGetUserHome(const wxString& user = wxEmptyString); - +// Get the user's home dir (caller must copy --- volatile) +// returns NULL is no HOME dir is known +#if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WINE__) +WXDLLIMPEXP_BASE const wxMB2WXbuf wxGetUserHome(const wxString& user = wxEmptyString); +#else +WXDLLIMPEXP_BASE wxChar* wxGetUserHome(const wxString& user = wxEmptyString); +#endif #if wxUSE_LONGLONG typedef wxLongLong wxDiskspaceSize_t; @@ -591,37 +540,8 @@ WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal = NULL, wxDiskspaceSize_t *pFree = NULL); - - -typedef int (*wxSortCallback)(const void* pItem1, - const void* pItem2, - const void* user_data); - - -WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems, - size_t size, wxSortCallback cmp, - const void* user_data); - - #if wxUSE_GUI // GUI only things from now on -// ---------------------------------------------------------------------------- -// Launch default browser -// ---------------------------------------------------------------------------- - -// flags for wxLaunchDefaultBrowser -enum -{ - wxBROWSER_NEW_WINDOW = 0x01, - wxBROWSER_NOBUSYCURSOR = 0x02 -}; - -// Launch url in the user's default internet browser -WXDLLIMPEXP_CORE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0); - -// Launch document in the user's default application -WXDLLIMPEXP_CORE bool wxLaunchDefaultApplication(const wxString& path, int flags = 0); - // ---------------------------------------------------------------------------- // Menu accelerators related things // ---------------------------------------------------------------------------- @@ -640,13 +560,13 @@ enum }; // strip mnemonics and/or accelerators from the label -WXDLLIMPEXP_CORE wxString +WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str, int flags = wxStrip_All); #if WXWIN_COMPATIBILITY_2_6 // obsolete and deprecated version, do not use, use the above overload instead wxDEPRECATED( - WXDLLIMPEXP_CORE wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = NULL) + WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = NULL) ); #if wxUSE_ACCEL @@ -654,7 +574,7 @@ class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry; // use wxAcceleratorEntry::Create() or FromString() methods instead wxDEPRECATED( - WXDLLIMPEXP_CORE wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) + WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) ); #endif // wxUSE_ACCEL @@ -665,68 +585,54 @@ wxDEPRECATED( // ---------------------------------------------------------------------------- // Returns menu item id or wxNOT_FOUND if none. -WXDLLIMPEXP_CORE int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); +WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); // Find the wxWindow at the given point. wxGenericFindWindowAtPoint // is always present but may be less reliable than a native version. -WXDLLIMPEXP_CORE wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); -WXDLLIMPEXP_CORE wxWindow* wxFindWindowAtPoint(const wxPoint& pt); +WXDLLEXPORT wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); +WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt); // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead // // Find the window/widget with the given title or label. // Pass a parent to begin the search from, or NULL to look through // all windows. -WXDLLIMPEXP_CORE wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = NULL); +WXDLLEXPORT wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = (wxWindow *) NULL); // NB: this function is obsolete, use wxWindow::FindWindowByName() instead // // Find window by name, and if that fails, by label. -WXDLLIMPEXP_CORE wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = NULL); +WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = (wxWindow *) NULL); // ---------------------------------------------------------------------------- // Message/event queue helpers // ---------------------------------------------------------------------------- // Yield to other apps/messages and disable user input -WXDLLIMPEXP_CORE bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = false); +WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = false); // Enable or disable input to all top level windows -WXDLLIMPEXP_CORE void wxEnableTopLevelWindows(bool enable = true); +WXDLLEXPORT void wxEnableTopLevelWindows(bool enable = true); // Check whether this window wants to process messages, e.g. Stop button // in long calculations. -WXDLLIMPEXP_CORE bool wxCheckForInterrupt(wxWindow *wnd); +WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd); // Consume all events until no more left -WXDLLIMPEXP_CORE void wxFlushEvents(); +WXDLLEXPORT void wxFlushEvents(); -// a class which disables all windows (except, may be, the given one) in its +// a class which disables all windows (except, may be, thegiven one) in its // ctor and enables them back in its dtor -class WXDLLIMPEXP_CORE wxWindowDisabler +class WXDLLEXPORT wxWindowDisabler { public: - // this ctor conditionally disables all windows: if the argument is false, - // it doesn't do anything - wxWindowDisabler(bool disable = true); - - // ctor disables all windows except winToSkip - wxWindowDisabler(wxWindow *winToSkip); - - // dtor enables back all windows disabled by the ctor + wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL); ~wxWindowDisabler(); private: - // disable all windows except the given one (used by both ctors) - void DoDisable(wxWindow *winToSkip = NULL); - -#if defined(__WXOSX__) && wxOSX_USE_COCOA - wxEventLoop* m_modalEventLoop; -#endif wxWindowList *m_winDisabled; - bool m_disabled; - wxDECLARE_NO_COPY_CLASS(wxWindowDisabler); + DECLARE_NO_COPY_CLASS(wxWindowDisabler) }; // ---------------------------------------------------------------------------- @@ -737,13 +643,13 @@ private: WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursor *cursor = wxHOURGLASS_CURSOR); // Restore cursor to normal -WXDLLIMPEXP_CORE void wxEndBusyCursor(); +WXDLLEXPORT void wxEndBusyCursor(); // true if we're between the above two calls -WXDLLIMPEXP_CORE bool wxIsBusy(); +WXDLLEXPORT bool wxIsBusy(); // Convenience class so we can just create a wxBusyCursor object on the stack -class WXDLLIMPEXP_CORE wxBusyCursor +class WXDLLEXPORT wxBusyCursor { public: wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR) @@ -751,21 +657,47 @@ public: ~wxBusyCursor() { wxEndBusyCursor(); } - // Obsolete internal methods, do not use. + // FIXME: These two methods are currently only implemented (and needed?) + // in wxGTK. BusyCursor handling should probably be moved to + // common code since the wxGTK and wxMSW implementations are very + // similar except for wxMSW using HCURSOR directly instead of + // wxCursor.. -- RL. static const wxCursor &GetStoredCursor(); static const wxCursor GetBusyCursor(); }; -void WXDLLIMPEXP_CORE wxGetMousePosition( int* x, int* y ); // ---------------------------------------------------------------------------- -// X11 Display access +// Reading and writing resources (eg WIN.INI, .Xdefaults) // ---------------------------------------------------------------------------- -#if defined(__X__) || defined(__WXGTK__) +#if wxUSE_RESOURCES +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file = wxEmptyString); + +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString); +#endif // wxUSE_RESOURCES + +void WXDLLEXPORT wxGetMousePosition( int* x, int* y ); + +// MSW only: get user-defined resource from the .res file. +// Returns NULL or newly-allocated memory, so use delete[] to clean up. +#ifdef __WXMSW__ + extern WXDLLEXPORT const wxChar* wxUserResourceStr; + WXDLLEXPORT wxChar* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr); +#endif // MSW + +// ---------------------------------------------------------------------------- +// Display and colorss (X only) +// ---------------------------------------------------------------------------- #ifdef __WXGTK__ - WXDLLIMPEXP_CORE void *wxGetDisplay(); + void *wxGetDisplay(); #endif #ifdef __X__ @@ -774,13 +706,18 @@ void WXDLLIMPEXP_CORE wxGetMousePosition( int* x, int* y ); WXDLLIMPEXP_CORE wxString wxGetDisplayName(); #endif // X or GTK+ -// use this function instead of the functions above in implementation code -inline struct _XDisplay *wxGetX11Display() -{ - return (_XDisplay *)wxGetDisplay(); -} +#ifdef __X__ -#endif // X11 || wxGTK +#ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++ + // The resulting warnings are switched off here +#pragma message disable nosimpint +#endif +// #include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#endif //__X__ #endif // wxUSE_GUI @@ -794,50 +731,16 @@ inline struct _XDisplay *wxGetX11Display() #define wx_YIELD_DECLARED // Yield to other apps/messages -WXDLLIMPEXP_CORE bool wxYield(); +WXDLLIMPEXP_BASE bool wxYield(); #endif // wx_YIELD_DECLARED // Like wxYield, but fails silently if the yield is recursive. -WXDLLIMPEXP_CORE bool wxYieldIfNeeded(); +WXDLLIMPEXP_BASE bool wxYieldIfNeeded(); // ---------------------------------------------------------------------------- -// Windows resources access +// Error message functions used by wxWidgets (deprecated, use wxLog) // ---------------------------------------------------------------------------- -// Windows only: get user-defined resource from the .res file. -#ifdef __WINDOWS__ - // default resource type for wxLoadUserResource() - extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxUserResourceStr; - - // Return the pointer to the resource data. This pointer is read-only, use - // the overload below if you need to modify the data. - // - // Notice that the resource type can be either a real string or an integer - // produced by MAKEINTRESOURCE(). In particular, any standard resource type, - // i.e any RT_XXX constant, could be passed here. - // - // Returns true on success, false on failure. Doesn't log an error message - // if the resource is not found (because this could be expected) but does - // log one if any other error occurs. - WXDLLIMPEXP_BASE bool - wxLoadUserResource(const void **outData, - size_t *outLen, - const wxString& resourceName, - const wxChar* resourceType = wxUserResourceStr, - WXHINSTANCE module = 0); - - // This function allocates a new buffer and makes a copy of the resource - // data, remember to delete[] the buffer. And avoid using it entirely if - // the overload above can be used. - // - // Returns NULL on failure. - WXDLLIMPEXP_BASE char* - wxLoadUserResource(const wxString& resourceName, - const wxChar* resourceType = wxUserResourceStr, - int* pLen = NULL, - WXHINSTANCE module = 0); -#endif // __WINDOWS__ - #endif // _WX_UTILSH__ diff --git a/Source/3rd Party/wx/include/wx/valgen.h b/Source/3rd Party/wx/include/wx/valgen.h index aba54153e..fd39c7e7d 100644 --- a/Source/3rd Party/wx/include/wx/valgen.h +++ b/Source/3rd Party/wx/include/wx/valgen.h @@ -1,8 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/valgen.h +// Name: valgen.h // Purpose: wxGenericValidator class // Author: Kevin Smith +// Modified by: // Created: Jan 22 1999 +// RCS-ID: // Copyright: (c) 1999 Julian Smart (assigned from Kevin) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,81 +16,54 @@ #if wxUSE_VALIDATORS -class WXDLLIMPEXP_FWD_BASE wxDateTime; -class WXDLLIMPEXP_FWD_BASE wxFileName; - -// ---------------------------------------------------------------------------- -// wxGenericValidator performs data transfer between many standard controls and -// variables of the type corresponding to their values. -// -// It doesn't do any validation so its name is a slight misnomer. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxGenericValidator: public wxValidator +class WXDLLEXPORT wxGenericValidator: public wxValidator { +DECLARE_CLASS(wxGenericValidator) public: - // Different constructors: each of them creates a validator which can only - // be used with some controls, the comments before each constructor - // indicate which ones: - // wxCheckBox, wxRadioButton, wx(Bitmap)ToggleButton - wxGenericValidator(bool* val); - // wxChoice, wxGauge, wxRadioBox, wxScrollBar, wxSlider, wxSpinButton - wxGenericValidator(int* val); - // wxComboBox, wxTextCtrl, wxButton, wxStaticText (read-only) - wxGenericValidator(wxString* val); - // wxListBox, wxCheckListBox - wxGenericValidator(wxArrayInt* val); -#if wxUSE_DATETIME - // wxDatePickerCtrl - wxGenericValidator(wxDateTime* val); -#endif // wxUSE_DATETIME - // wxTextCtrl - wxGenericValidator(wxFileName* val); - // wxTextCtrl - wxGenericValidator(float* val); - // wxTextCtrl - wxGenericValidator(double* val); + wxGenericValidator(bool* val); + wxGenericValidator(int* val); + wxGenericValidator(wxString* val); + wxGenericValidator(wxArrayInt* val); + wxGenericValidator(const wxGenericValidator& copyFrom); - wxGenericValidator(const wxGenericValidator& copyFrom); + virtual ~wxGenericValidator(){} - virtual ~wxGenericValidator(){} + // Make a clone of this validator (or return NULL) - currently necessary + // if you're passing a reference to a validator. + // Another possibility is to always pass a pointer to a new validator + // (so the calling code can use a copy constructor of the relevant class). + virtual wxObject *Clone() const { return new wxGenericValidator(*this); } + bool Copy(const wxGenericValidator& val); - // Make a clone of this validator (or return NULL) - currently necessary - // if you're passing a reference to a validator. - // Another possibility is to always pass a pointer to a new validator - // (so the calling code can use a copy constructor of the relevant class). - virtual wxObject *Clone() const { return new wxGenericValidator(*this); } - bool Copy(const wxGenericValidator& val); + // Called when the value in the window must be validated. + // This function can pop up an error message. + virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; } - // Called when the value in the window must be validated: this is not used - // by this class - virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; } + // Called to transfer data to the window + virtual bool TransferToWindow(); - // Called to transfer data to the window - virtual bool TransferToWindow(); - - // Called to transfer data to the window - virtual bool TransferFromWindow(); + // Called to transfer data to the window + virtual bool TransferFromWindow(); protected: - void Initialize(); + void Initialize(); - bool* m_pBool; - int* m_pInt; - wxString* m_pString; - wxArrayInt* m_pArrayInt; -#if wxUSE_DATETIME - wxDateTime* m_pDateTime; -#endif // wxUSE_DATETIME - wxFileName* m_pFileName; - float* m_pFloat; - double* m_pDouble; + bool* m_pBool; + int* m_pInt; + wxString* m_pString; + wxArrayInt* m_pArrayInt; private: - DECLARE_CLASS(wxGenericValidator) - wxDECLARE_NO_ASSIGN_CLASS(wxGenericValidator); +// Cannot use +// DECLARE_NO_COPY_CLASS(wxGenericValidator) +// because copy constructor is explicitly declared above; +// but no copy assignment operator is defined, so declare +// it private to prevent the compiler from defining it: + wxGenericValidator& operator=(const wxGenericValidator&); }; -#endif // wxUSE_VALIDATORS +#endif + // wxUSE_VALIDATORS -#endif // _WX_VALGENH__ +#endif + // _WX_VALGENH__ diff --git a/Source/3rd Party/wx/include/wx/validate.h b/Source/3rd Party/wx/include/wx/validate.h index 32a5bff14..ea8c80897 100644 --- a/Source/3rd Party/wx/include/wx/validate.h +++ b/Source/3rd Party/wx/include/wx/validate.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: validate.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,15 +33,10 @@ class WXDLLIMPEXP_FWD_CORE wxWindowBase; Note that wxValidator and derived classes use reference counting. */ -class WXDLLIMPEXP_CORE wxValidator : public wxEvtHandler +class WXDLLEXPORT wxValidator : public wxEvtHandler { public: wxValidator(); - wxValidator(const wxValidator& other) - : wxEvtHandler() - , m_validatorWindow(other.m_validatorWindow) - { - } virtual ~wxValidator(); // Make a clone of this validator (or return NULL) - currently necessary @@ -48,7 +44,7 @@ public: // Another possibility is to always pass a pointer to a new validator // (so the calling code can use a copy constructor of the relevant class). virtual wxObject *Clone() const - { return NULL; } + { return (wxValidator *)NULL; } bool Copy(const wxValidator& val) { m_validatorWindow = val.m_validatorWindow; return true; } @@ -66,23 +62,10 @@ public: wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; } void SetWindow(wxWindowBase *win) { m_validatorWindow = win; } - // validators beep by default if invalid key is pressed, this function - // allows to change this - static void SuppressBellOnError(bool suppress = true) - { ms_isSilent = suppress; } - - // test if beep is currently disabled + // validators beep by default if invalid key is pressed, these functions + // allow to change it static bool IsSilent() { return ms_isSilent; } - - // this function is deprecated because it handled its parameter - // unnaturally: it disabled the bell when it was true, not false as could - // be expected; use SuppressBellOnError() instead -#if WXWIN_COMPATIBILITY_2_8 - static wxDEPRECATED_INLINE( - void SetBellOnError(bool doIt = true), - ms_isSilent = doIt; - ) -#endif + static void SetBellOnError(bool doIt = true) { ms_isSilent = doIt; } protected: wxWindowBase *m_validatorWindow; @@ -91,10 +74,10 @@ private: static bool ms_isSilent; DECLARE_DYNAMIC_CLASS(wxValidator) - wxDECLARE_NO_ASSIGN_CLASS(wxValidator); + DECLARE_NO_COPY_CLASS(wxValidator) }; -extern WXDLLIMPEXP_DATA_CORE(const wxValidator) wxDefaultValidator; +extern WXDLLEXPORT_DATA(const wxValidator) wxDefaultValidator; #define wxVALIDATOR_PARAM(val) val @@ -103,9 +86,8 @@ extern WXDLLIMPEXP_DATA_CORE(const wxValidator) wxDefaultValidator; // want to be able to pass wxDefaultValidator to the functions which take // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS" // everywhere - class WXDLLIMPEXP_FWD_CORE wxValidator; - static const wxValidator* const wxDefaultValidatorPtr = NULL; - #define wxDefaultValidator (*wxDefaultValidatorPtr) + class WXDLLEXPORT wxValidator; + #define wxDefaultValidator (*((wxValidator *)NULL)) // this macro allows to avoid warnings about unused parameters when // wxUSE_VALIDATORS == 0 diff --git a/Source/3rd Party/wx/include/wx/valnum.h b/Source/3rd Party/wx/include/wx/valnum.h deleted file mode 100644 index 2fbfe607b..000000000 --- a/Source/3rd Party/wx/include/wx/valnum.h +++ /dev/null @@ -1,463 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/valnum.h -// Purpose: Numeric validator classes. -// Author: Vadim Zeitlin based on the submission of Fulvio Senore -// Created: 2010-11-06 -// Copyright: (c) 2010 wxWidgets team -// (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_VALNUM_H_ -#define _WX_VALNUM_H_ - -#include "wx/defs.h" - -#if wxUSE_VALIDATORS - -#include "wx/validate.h" - -#include - -// Bit masks used for numeric validator styles. -enum wxNumValidatorStyle -{ - wxNUM_VAL_DEFAULT = 0x0, - wxNUM_VAL_THOUSANDS_SEPARATOR = 0x1, - wxNUM_VAL_ZERO_AS_BLANK = 0x2, - wxNUM_VAL_NO_TRAILING_ZEROES = 0x4 -}; - -// ---------------------------------------------------------------------------- -// Base class for all numeric validators. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxNumValidatorBase : public wxValidator -{ -public: - // Change the validator style. Usually it's specified during construction. - void SetStyle(int style) { m_style = style; } - - - // Override base class method to not do anything but always return success: - // we don't need this as we do our validation on the fly here. - virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; } - -protected: - wxNumValidatorBase(int style) - { - m_style = style; - } - - wxNumValidatorBase(const wxNumValidatorBase& other) : wxValidator() - { - m_style = other.m_style; - } - - bool HasFlag(wxNumValidatorStyle style) const - { - return (m_style & style) != 0; - } - - // Get the text entry of the associated control. Normally shouldn't ever - // return NULL (and will assert if it does return it) but the caller should - // still test the return value for safety. - wxTextEntry *GetTextEntry() const; - - // Convert wxNUM_VAL_THOUSANDS_SEPARATOR and wxNUM_VAL_NO_TRAILING_ZEROES - // bits of our style to the corresponding wxNumberFormatter::Style values. - int GetFormatFlags() const; - - // Return true if pressing a '-' key is acceptable for the current control - // contents and insertion point. This is meant to be called from the - // derived class IsCharOk() implementation. - bool IsMinusOk(const wxString& val, int pos) const; - - // Return the string which would result from inserting the given character - // at the specified position. - wxString GetValueAfterInsertingChar(wxString val, int pos, wxChar ch) const - { - val.insert(pos, ch); - return val; - } - -private: - // Check whether the specified character can be inserted in the control at - // the given position in the string representing the current controls - // contents. - // - // Notice that the base class checks for '-' itself so it's never passed to - // this function. - virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const = 0; - - // NormalizeString the contents of the string if it's a valid number, return - // empty string otherwise. - virtual wxString NormalizeString(const wxString& s) const = 0; - - - // Event handlers. - void OnChar(wxKeyEvent& event); - void OnKillFocus(wxFocusEvent& event); - - - // Determine the current insertion point and text in the associated control. - void GetCurrentValueAndInsertionPoint(wxString& val, int& pos) const; - - - // Combination of wxVAL_NUM_XXX values. - int m_style; - - - wxDECLARE_EVENT_TABLE(); - - wxDECLARE_NO_ASSIGN_CLASS(wxNumValidatorBase); -}; - -namespace wxPrivate -{ - -// This is a helper class used by wxIntegerValidator and wxFloatingPointValidator -// below that implements Transfer{To,From}Window() adapted to the type of the -// variable. -// -// The template argument B is the name of the base class which must derive from -// wxNumValidatorBase and define LongestValueType type and {To,As}String() -// methods i.e. basically be one of wx{Integer,Number}ValidatorBase classes. -// -// The template argument T is just the type handled by the validator that will -// inherit from this one. -template -class wxNumValidator : public B -{ -public: - typedef B BaseValidator; - typedef T ValueType; - - typedef typename BaseValidator::LongestValueType LongestValueType; - - // FIXME-VC6: This compiler fails to compile the assert below with a - // nonsensical error C2248: "'LongestValueType' : cannot access protected - // typedef declared in class 'wxIntegerValidatorBase'" so just disable the - // check for it. -#ifndef __VISUALC6__ - wxCOMPILE_TIME_ASSERT - ( - sizeof(ValueType) <= sizeof(LongestValueType), - UnsupportedType - ); -#endif // __VISUALC6__ - - void SetMin(ValueType min) - { - this->DoSetMin(min); - } - - void SetMax(ValueType max) - { - this->DoSetMax(max); - } - - void SetRange(ValueType min, ValueType max) - { - SetMin(min); - SetMax(max); - } - - virtual bool TransferToWindow() - { - if ( m_value ) - { - wxTextEntry * const control = BaseValidator::GetTextEntry(); - if ( !control ) - return false; - - control->SetValue(NormalizeValue(*m_value)); - } - - return true; - } - - virtual bool TransferFromWindow() - { - if ( m_value ) - { - wxTextEntry * const control = BaseValidator::GetTextEntry(); - if ( !control ) - return false; - - const wxString s(control->GetValue()); - LongestValueType value; - if ( s.empty() && BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) ) - value = 0; - else if ( !BaseValidator::FromString(s, &value) ) - return false; - - if ( !this->IsInRange(value) ) - return false; - - *m_value = static_cast(value); - } - - return true; - } - -protected: - wxNumValidator(ValueType *value, int style) - : BaseValidator(style), - m_value(value) - { - } - - // Implement wxNumValidatorBase virtual method which is the same for - // both integer and floating point numbers. - virtual wxString NormalizeString(const wxString& s) const - { - LongestValueType value; - return BaseValidator::FromString(s, &value) ? NormalizeValue(value) - : wxString(); - } - -private: - // Just a helper which is a common part of TransferToWindow() and - // NormalizeString(): returns string representation of a number honouring - // wxNUM_VAL_ZERO_AS_BLANK flag. - wxString NormalizeValue(LongestValueType value) const - { - wxString s; - if ( value != 0 || !BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) ) - s = this->ToString(value); - - return s; - } - - - ValueType * const m_value; - - wxDECLARE_NO_ASSIGN_CLASS(wxNumValidator); -}; - -} // namespace wxPrivate - -// ---------------------------------------------------------------------------- -// Validators for integer numbers. -// ---------------------------------------------------------------------------- - -// Base class for integer numbers validator. This class contains all non -// type-dependent code of wxIntegerValidator<> and always works with values of -// type LongestValueType. It is not meant to be used directly, please use -// wxIntegerValidator<> only instead. -class WXDLLIMPEXP_CORE wxIntegerValidatorBase : public wxNumValidatorBase -{ -protected: - // Define the type we use here, it should be the maximal-sized integer type - // we support to make it possible to base wxIntegerValidator<> for any type - // on it. -#ifdef wxLongLong_t - typedef wxLongLong_t LongestValueType; -#else - typedef long LongestValueType; -#endif - - wxIntegerValidatorBase(int style) - : wxNumValidatorBase(style) - { - wxASSERT_MSG( !(style & wxNUM_VAL_NO_TRAILING_ZEROES), - "This style doesn't make sense for integers." ); - } - - wxIntegerValidatorBase(const wxIntegerValidatorBase& other) - : wxNumValidatorBase(other) - { - m_min = other.m_min; - m_max = other.m_max; - } - - // Provide methods for wxNumValidator use. - wxString ToString(LongestValueType value) const; - static bool FromString(const wxString& s, LongestValueType *value); - - void DoSetMin(LongestValueType min) { m_min = min; } - void DoSetMax(LongestValueType max) { m_max = max; } - - bool IsInRange(LongestValueType value) const - { - return m_min <= value && value <= m_max; - } - - // Implement wxNumValidatorBase pure virtual method. - virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const; - -private: - // Minimal and maximal values accepted (inclusive). - LongestValueType m_min, m_max; - - wxDECLARE_NO_ASSIGN_CLASS(wxIntegerValidatorBase); -}; - -// Validator for integer numbers. It can actually work with any integer type -// (short, int or long and long long if supported) and their unsigned versions -// as well. -template -class wxIntegerValidator - : public wxPrivate::wxNumValidator -{ -public: - typedef T ValueType; - - typedef - wxPrivate::wxNumValidator Base; - - // Ctor for an integer validator. - // - // Sets the range appropriately for the type, including setting 0 as the - // minimal value for the unsigned types. - wxIntegerValidator(ValueType *value = NULL, int style = wxNUM_VAL_DEFAULT) - : Base(value, style) - { - this->DoSetMin(std::numeric_limits::min()); - this->DoSetMax(std::numeric_limits::max()); - } - - virtual wxObject *Clone() const { return new wxIntegerValidator(*this); } - -private: - wxDECLARE_NO_ASSIGN_CLASS(wxIntegerValidator); -}; - -// Helper function for creating integer validators which allows to avoid -// explicitly specifying the type as it deduces it from its parameter. -template -inline wxIntegerValidator -wxMakeIntegerValidator(T *value, int style = wxNUM_VAL_DEFAULT) -{ - return wxIntegerValidator(value, style); -} - -// ---------------------------------------------------------------------------- -// Validators for floating point numbers. -// ---------------------------------------------------------------------------- - -// Similar to wxIntegerValidatorBase, this class is not meant to be used -// directly, only wxFloatingPointValidator<> should be used in the user code. -class WXDLLIMPEXP_CORE wxFloatingPointValidatorBase : public wxNumValidatorBase -{ -public: - // Set precision i.e. the number of digits shown (and accepted on input) - // after the decimal point. By default this is set to the maximal precision - // supported by the type handled by the validator. - void SetPrecision(unsigned precision) { m_precision = precision; } - -protected: - // Notice that we can't use "long double" here because it's not supported - // by wxNumberFormatter yet, so restrict ourselves to just double (and - // float). - typedef double LongestValueType; - - wxFloatingPointValidatorBase(int style) - : wxNumValidatorBase(style) - { - } - - wxFloatingPointValidatorBase(const wxFloatingPointValidatorBase& other) - : wxNumValidatorBase(other) - { - m_precision = other.m_precision; - - m_min = other.m_min; - m_max = other.m_max; - } - - // Provide methods for wxNumValidator use. - wxString ToString(LongestValueType value) const; - static bool FromString(const wxString& s, LongestValueType *value); - - void DoSetMin(LongestValueType min) { m_min = min; } - void DoSetMax(LongestValueType max) { m_max = max; } - - bool IsInRange(LongestValueType value) const - { - return m_min <= value && value <= m_max; - } - - // Implement wxNumValidatorBase pure virtual method. - virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const; - -private: - // Maximum number of decimals digits after the decimal separator. - unsigned m_precision; - - // Minimal and maximal values accepted (inclusive). - LongestValueType m_min, m_max; - - wxDECLARE_NO_ASSIGN_CLASS(wxFloatingPointValidatorBase); -}; - -// Validator for floating point numbers. It can be used with float, double or -// long double values. -template -class wxFloatingPointValidator - : public wxPrivate::wxNumValidator -{ -public: - typedef T ValueType; - typedef wxPrivate::wxNumValidator Base; - - // Ctor using implicit (maximal) precision for this type. - wxFloatingPointValidator(ValueType *value = NULL, - int style = wxNUM_VAL_DEFAULT) - : Base(value, style) - { - DoSetMinMax(); - - this->SetPrecision(std::numeric_limits::digits10); - } - - // Ctor specifying an explicit precision. - wxFloatingPointValidator(int precision, - ValueType *value = NULL, - int style = wxNUM_VAL_DEFAULT) - : Base(value, style) - { - DoSetMinMax(); - - this->SetPrecision(precision); - } - - virtual wxObject *Clone() const - { - return new wxFloatingPointValidator(*this); - } - -private: - void DoSetMinMax() - { - // NB: Do not use min(), it's not the smallest representable value for - // the floating point types but rather the smallest representable - // positive value. - this->DoSetMin(-std::numeric_limits::max()); - this->DoSetMax( std::numeric_limits::max()); - } -}; - -// Helper similar to wxMakeIntValidator(). -// -// NB: Unfortunately we can't just have a wxMakeNumericValidator() which would -// return either wxIntegerValidator<> or wxFloatingPointValidator<> so we -// do need two different functions. -template -inline wxFloatingPointValidator -wxMakeFloatingPointValidator(T *value, int style = wxNUM_VAL_DEFAULT) -{ - return wxFloatingPointValidator(value, style); -} - -template -inline wxFloatingPointValidator -wxMakeFloatingPointValidator(int precision, T *value, int style = wxNUM_VAL_DEFAULT) -{ - return wxFloatingPointValidator(precision, value, style); -} - -#endif // wxUSE_VALIDATORS - -#endif // _WX_VALNUM_H_ diff --git a/Source/3rd Party/wx/include/wx/valtext.h b/Source/3rd Party/wx/include/wx/valtext.h index 57d1fe185..7f2e1e693 100644 --- a/Source/3rd Party/wx/include/wx/valtext.h +++ b/Source/3rd Party/wx/include/wx/valtext.h @@ -1,43 +1,40 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/valtext.h +// Name: valtext.h // Purpose: wxTextValidator class // Author: Julian Smart -// Modified by: Francesco Montorsi +// Modified by: // Created: 29/01/98 +// RCS-ID: $Id: valtext.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_VALTEXT_H_ -#define _WX_VALTEXT_H_ +#ifndef _WX_VALTEXTH__ +#define _WX_VALTEXTH__ #include "wx/defs.h" -#if wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX) - -class WXDLLIMPEXP_FWD_CORE wxTextEntry; +#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL +#include "wx/textctrl.h" #include "wx/validate.h" -enum wxTextValidatorStyle -{ - wxFILTER_NONE = 0x0, - wxFILTER_EMPTY = 0x1, - wxFILTER_ASCII = 0x2, - wxFILTER_ALPHA = 0x4, - wxFILTER_ALPHANUMERIC = 0x8, - wxFILTER_DIGITS = 0x10, - wxFILTER_NUMERIC = 0x20, - wxFILTER_INCLUDE_LIST = 0x40, - wxFILTER_INCLUDE_CHAR_LIST = 0x80, - wxFILTER_EXCLUDE_LIST = 0x100, - wxFILTER_EXCLUDE_CHAR_LIST = 0x200 -}; +#define wxFILTER_NONE 0x0000 +#define wxFILTER_ASCII 0x0001 +#define wxFILTER_ALPHA 0x0002 +#define wxFILTER_ALPHANUMERIC 0x0004 +#define wxFILTER_NUMERIC 0x0008 +#define wxFILTER_INCLUDE_LIST 0x0010 +#define wxFILTER_EXCLUDE_LIST 0x0020 +#define wxFILTER_INCLUDE_CHAR_LIST 0x0040 +#define wxFILTER_EXCLUDE_CHAR_LIST 0x0080 -class WXDLLIMPEXP_CORE wxTextValidator: public wxValidator +class WXDLLEXPORT wxTextValidator: public wxValidator { +DECLARE_DYNAMIC_CLASS(wxTextValidator) public: - wxTextValidator(long style = wxFILTER_NONE, wxString *val = NULL); + + wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0); wxTextValidator(const wxTextValidator& val); virtual ~wxTextValidator(){} @@ -59,50 +56,67 @@ public: // Called to transfer data from the window virtual bool TransferFromWindow(); - // Filter keystrokes - void OnChar(wxKeyEvent& event); - // ACCESSORS inline long GetStyle() const { return m_validatorStyle; } - void SetStyle(long style); + inline void SetStyle(long style) { m_validatorStyle = style; } - wxTextEntry *GetTextEntry(); +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( void SetIncludeList(const wxStringList& list) ); + wxDEPRECATED( wxStringList& GetIncludeList() ); + + wxDEPRECATED( void SetExcludeList(const wxStringList& list) ); + wxDEPRECATED( wxStringList& GetExcludeList() ); + + wxDEPRECATED( bool IsInCharIncludeList(const wxString& val) ); + wxDEPRECATED( bool IsNotInCharExcludeList(const wxString& val) ); +#endif - void SetCharIncludes(const wxString& chars); void SetIncludes(const wxArrayString& includes) { m_includes = includes; } inline wxArrayString& GetIncludes() { return m_includes; } - void SetCharExcludes(const wxString& chars); void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; } inline wxArrayString& GetExcludes() { return m_excludes; } - bool HasFlag(wxTextValidatorStyle style) const - { return (m_validatorStyle & style) != 0; } + bool IsInCharIncludes(const wxString& val); + bool IsNotInCharExcludes(const wxString& val); + + // Filter keystrokes + void OnChar(wxKeyEvent& event); + + +DECLARE_EVENT_TABLE() protected: + long m_validatorStyle; + wxString * m_stringValue; +#if WXWIN_COMPATIBILITY_2_4 + wxStringList m_includeList; + wxStringList m_excludeList; +#endif + wxArrayString m_includes; + wxArrayString m_excludes; - // returns true if all characters of the given string are present in m_includes - bool ContainsOnlyIncludedCharacters(const wxString& val) const; + bool CheckValidator() const + { + wxCHECK_MSG( m_validatorWindow, false, + wxT("No window associated with validator") ); + wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), false, + wxT("wxTextValidator is only for wxTextCtrl's") ); - // returns true if at least one character of the given string is present in m_excludes - bool ContainsExcludedCharacters(const wxString& val) const; - - // returns the error message if the contents of 'val' are invalid - virtual wxString IsValid(const wxString& val) const; - -protected: - long m_validatorStyle; - wxString* m_stringValue; - wxArrayString m_includes; - wxArrayString m_excludes; + return true; + } private: - wxDECLARE_NO_ASSIGN_CLASS(wxTextValidator); - DECLARE_DYNAMIC_CLASS(wxTextValidator) - DECLARE_EVENT_TABLE() +// Cannot use +// DECLARE_NO_COPY_CLASS(wxTextValidator) +// because copy constructor is explicitly declared above; +// but no copy assignment operator is defined, so declare +// it private to prevent the compiler from defining it: + wxTextValidator& operator=(const wxTextValidator&); }; #endif - // wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX) + // wxUSE_VALIDATORS && wxUSE_TEXTCTRL -#endif // _WX_VALTEXT_H_ +#endif + // _WX_VALTEXTH__ diff --git a/Source/3rd Party/wx/include/wx/variant.h b/Source/3rd Party/wx/include/wx/variant.h index 1f86ac1ab..bccf32e88 100644 --- a/Source/3rd Party/wx/include/wx/variant.h +++ b/Source/3rd Party/wx/include/wx/variant.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 10/09/98 +// RCS-ID: $Id: variant.h 42997 2006-11-03 21:37:08Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -20,21 +21,26 @@ #include "wx/arrstr.h" #include "wx/list.h" #include "wx/cpp.h" -#include "wx/longlong.h" #if wxUSE_DATETIME #include "wx/datetime.h" #endif // wxUSE_DATETIME -#include "wx/iosfwrap.h" +#if wxUSE_ODBC + #include "wx/db.h" // will #include sqltypes.h +#endif //ODBC -class wxAny; +#include "wx/iosfwrap.h" /* * wxVariantData stores the actual data in a wxVariant object, * to allow it to store any type of data. * Derive from this to provide custom data handling. * + * NB: To prevent addition of extra vtbl pointer to wxVariantData, + * we don't multiple-inherit from wxObjectRefData. Instead, + * we simply replicate the wxObject ref-counting scheme. + * * NB: When you construct a wxVariantData, it will have refcount * of one. Refcount will not be further increased when * it is passed to wxVariant. This simulates old common @@ -53,11 +59,13 @@ class wxAny; * overloading wxVariant with unnecessary functionality. */ -class WXDLLIMPEXP_BASE wxVariantData : public wxObjectRefData +class WXDLLIMPEXP_BASE wxVariantData: public wxObject { friend class wxVariant; public: - wxVariantData() { } + wxVariantData() + : wxObject(), m_count(1) + { } // Override these to provide common functionality virtual bool Eq(wxVariantData& data) const = 0; @@ -75,20 +83,26 @@ public: // If it based on wxObject return the ClassInfo. virtual wxClassInfo* GetValueClassInfo() { return NULL; } - // Implement this to make wxVariant::UnShare work. Returns - // a copy of the data. - virtual wxVariantData* Clone() const { return NULL; } + void IncRef() { m_count++; } + void DecRef() + { + if ( --m_count == 0 ) + delete this; + } -#if wxUSE_ANY - // Converts value to wxAny, if possible. Return true if successful. - virtual bool GetAsAny(wxAny* WXUNUSED(any)) const { return false; } -#endif + int GetRefCount() const { return m_count; } protected: // Protected dtor should make some incompatible code // break more louder. That is, they should do data->DecRef() // instead of delete data. virtual ~wxVariantData() { } + +private: + int m_count; + +private: + DECLARE_ABSTRACT_CLASS(wxVariantData) }; /* @@ -96,10 +110,6 @@ protected: * built in. */ -class WXDLLIMPEXP_FWD_BASE wxVariant; - -WX_DECLARE_LIST_WITH_DECL(wxVariant, wxVariantList, class WXDLLIMPEXP_BASE); - class WXDLLIMPEXP_BASE wxVariant: public wxObject { public: @@ -107,9 +117,6 @@ public: wxVariant(const wxVariant& variant); wxVariant(wxVariantData* data, const wxString& name = wxEmptyString); -#if wxUSE_ANY - wxVariant(const wxAny& any); -#endif virtual ~wxVariant(); // generic assignment @@ -131,17 +138,14 @@ public: // For compatibility with wxWidgets <= 2.6, this doesn't increase // reference count. - wxVariantData* GetData() const - { - return (wxVariantData*) m_refData; - } + wxVariantData* GetData() const { return m_data; } void SetData(wxVariantData* data) ; // make a 'clone' of the object - void Ref(const wxVariant& clone) { wxObject::Ref(clone); } + void Ref(const wxVariant& clone); - // ensure that the data is exclusive to this variant, and not shared - bool Unshare(); + // destroy a reference + void UnRef(); // Make NULL (i.e. delete the data) void MakeNull(); @@ -159,10 +163,6 @@ public: // write contents to a string (e.g. for debugging) wxString MakeString() const; -#if wxUSE_ANY - wxAny GetAny() const; -#endif - // double wxVariant(double val, const wxString& name = wxEmptyString); bool operator== (double value) const; @@ -184,99 +184,59 @@ public: long GetLong() const; // bool +#ifdef HAVE_BOOL wxVariant(bool val, const wxString& name = wxEmptyString); bool operator== (bool value) const; bool operator!= (bool value) const; void operator= (bool value) ; inline operator bool () const { return GetBool(); } bool GetBool() const ; +#endif // wxDateTime #if wxUSE_DATETIME wxVariant(const wxDateTime& val, const wxString& name = wxEmptyString); +#if wxUSE_ODBC + wxVariant(const DATE_STRUCT* valptr, const wxString& name = wxEmptyString); + wxVariant(const TIME_STRUCT* valptr, const wxString& name = wxEmptyString); + wxVariant(const TIMESTAMP_STRUCT* valptr, const wxString& name = wxEmptyString); +#endif bool operator== (const wxDateTime& value) const; bool operator!= (const wxDateTime& value) const; void operator= (const wxDateTime& value) ; +#if wxUSE_ODBC + void operator= (const DATE_STRUCT* value) ; + void operator= (const TIME_STRUCT* value) ; + void operator= (const TIMESTAMP_STRUCT* value) ; +#endif inline operator wxDateTime () const { return GetDateTime(); } wxDateTime GetDateTime() const; #endif // wxString wxVariant(const wxString& val, const wxString& name = wxEmptyString); - // these overloads are necessary to prevent the compiler from using bool - // version instead of wxString one: - wxVariant(const char* val, const wxString& name = wxEmptyString); - wxVariant(const wchar_t* val, const wxString& name = wxEmptyString); - wxVariant(const wxCStrData& val, const wxString& name = wxEmptyString); - wxVariant(const wxScopedCharBuffer& val, const wxString& name = wxEmptyString); - wxVariant(const wxScopedWCharBuffer& val, const wxString& name = wxEmptyString); - + wxVariant(const wxChar* val, const wxString& name = wxEmptyString); // Necessary or VC++ assumes bool! bool operator== (const wxString& value) const; bool operator!= (const wxString& value) const; - wxVariant& operator=(const wxString& value); - // these overloads are necessary to prevent the compiler from using bool - // version instead of wxString one: - wxVariant& operator=(const char* value) - { return *this = wxString(value); } - wxVariant& operator=(const wchar_t* value) - { return *this = wxString(value); } - wxVariant& operator=(const wxCStrData& value) - { return *this = value.AsString(); } - template - wxVariant& operator=(const wxScopedCharTypeBuffer& value) - { return *this = value.data(); } - + void operator= (const wxString& value) ; + void operator= (const wxChar* value) ; // Necessary or VC++ assumes bool! inline operator wxString () const { return MakeString(); } wxString GetString() const; -#if wxUSE_STD_STRING - wxVariant(const std::string& val, const wxString& name = wxEmptyString); - bool operator==(const std::string& value) const - { return operator==(wxString(value)); } - bool operator!=(const std::string& value) const - { return operator!=(wxString(value)); } - wxVariant& operator=(const std::string& value) - { return operator=(wxString(value)); } - operator std::string() const { return (operator wxString()).ToStdString(); } - - wxVariant(const wxStdWideString& val, const wxString& name = wxEmptyString); - bool operator==(const wxStdWideString& value) const - { return operator==(wxString(value)); } - bool operator!=(const wxStdWideString& value) const - { return operator!=(wxString(value)); } - wxVariant& operator=(const wxStdWideString& value) - { return operator=(wxString(value)); } - operator wxStdWideString() const { return (operator wxString()).ToStdWstring(); } -#endif // wxUSE_STD_STRING - - // wxUniChar - wxVariant(const wxUniChar& val, const wxString& name = wxEmptyString); - wxVariant(const wxUniCharRef& val, const wxString& name = wxEmptyString); - wxVariant(char val, const wxString& name = wxEmptyString); - wxVariant(wchar_t val, const wxString& name = wxEmptyString); - bool operator==(const wxUniChar& value) const; - bool operator==(const wxUniCharRef& value) const { return *this == wxUniChar(value); } - bool operator==(char value) const { return *this == wxUniChar(value); } - bool operator==(wchar_t value) const { return *this == wxUniChar(value); } - bool operator!=(const wxUniChar& value) const { return !(*this == value); } - bool operator!=(const wxUniCharRef& value) const { return !(*this == value); } - bool operator!=(char value) const { return !(*this == value); } - bool operator!=(wchar_t value) const { return !(*this == value); } - wxVariant& operator=(const wxUniChar& value); - wxVariant& operator=(const wxUniCharRef& value) { return *this = wxUniChar(value); } - wxVariant& operator=(char value) { return *this = wxUniChar(value); } - wxVariant& operator=(wchar_t value) { return *this = wxUniChar(value); } - operator wxUniChar() const { return GetChar(); } - operator char() const { return GetChar(); } - operator wchar_t() const { return GetChar(); } - wxUniChar GetChar() const; + // wxChar + wxVariant(wxChar val, const wxString& name = wxEmptyString); + bool operator== (wxChar value) const; + bool operator!= (wxChar value) const; + void operator= (wxChar value) ; + inline operator wxChar () const { return GetChar(); } + wxChar GetChar() const ; // wxArrayString wxVariant(const wxArrayString& val, const wxString& name = wxEmptyString); bool operator== (const wxArrayString& value) const; bool operator!= (const wxArrayString& value) const; void operator= (const wxArrayString& value); - operator wxArrayString () const { return GetArrayString(); } + inline operator wxArrayString () const { return GetArrayString(); } wxArrayString GetArrayString() const; // void* @@ -284,7 +244,7 @@ public: bool operator== (void* value) const; bool operator!= (void* value) const; void operator= (void* value); - operator void* () const { return GetVoidPtr(); } + inline operator void* () const { return GetVoidPtr(); } void* GetVoidPtr() const; // wxObject* @@ -294,36 +254,27 @@ public: void operator= (wxObject* value); wxObject* GetWxObjectPtr() const; -#if wxUSE_LONGLONG - // wxLongLong - wxVariant(wxLongLong, const wxString& name = wxEmptyString); - bool operator==(wxLongLong value) const; - bool operator!=(wxLongLong value) const; - void operator=(wxLongLong value); - operator wxLongLong() const { return GetLongLong(); } - wxLongLong GetLongLong() const; - // wxULongLong - wxVariant(wxULongLong, const wxString& name = wxEmptyString); - bool operator==(wxULongLong value) const; - bool operator!=(wxULongLong value) const; - void operator=(wxULongLong value); - operator wxULongLong() const { return GetULongLong(); } - wxULongLong GetULongLong() const; +#if WXWIN_COMPATIBILITY_2_4 + wxDEPRECATED( wxVariant(const wxStringList& val, const wxString& name = wxEmptyString) ); + wxDEPRECATED( bool operator== (const wxStringList& value) const ); + wxDEPRECATED( bool operator!= (const wxStringList& value) const ); + wxDEPRECATED( void operator= (const wxStringList& value) ); + wxDEPRECATED( wxStringList& GetStringList() const ); #endif // ------------------------------ // list operations // ------------------------------ - wxVariant(const wxVariantList& val, const wxString& name = wxEmptyString); // List of variants - bool operator== (const wxVariantList& value) const; - bool operator!= (const wxVariantList& value) const; - void operator= (const wxVariantList& value) ; + wxVariant(const wxList& val, const wxString& name = wxEmptyString); // List of variants + bool operator== (const wxList& value) const; + bool operator!= (const wxList& value) const; + void operator= (const wxList& value) ; // Treat a list variant as an array wxVariant operator[] (size_t idx) const; wxVariant& operator[] (size_t idx) ; - wxVariantList& GetList() const ; + wxList& GetList() const ; // Return the number of elements in a list size_t GetCount() const; @@ -352,124 +303,20 @@ public: bool Convert(bool* value) const; bool Convert(double* value) const; bool Convert(wxString* value) const; - bool Convert(wxUniChar* value) const; - bool Convert(char* value) const; - bool Convert(wchar_t* value) const; + bool Convert(wxChar* value) const; #if wxUSE_DATETIME bool Convert(wxDateTime* value) const; #endif // wxUSE_DATETIME -#if wxUSE_LONGLONG - bool Convert(wxLongLong* value) const; - bool Convert(wxULongLong* value) const; - #ifdef wxLongLong_t - bool Convert(wxLongLong_t* value) const - { - wxLongLong temp; - if ( !Convert(&temp) ) - return false; - *value = temp.GetValue(); - return true; - } - bool Convert(wxULongLong_t* value) const - { - wxULongLong temp; - if ( !Convert(&temp) ) - return false; - *value = temp.GetValue(); - return true; - } - #endif // wxLongLong_t -#endif // wxUSE_LONGLONG // Attributes protected: - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - + wxVariantData* m_data; wxString m_name; private: DECLARE_DYNAMIC_CLASS(wxVariant) }; - -// -// wxVariant <-> wxAny conversion code -// -#if wxUSE_ANY - -#include "wx/any.h" - -// In order to convert wxAny to wxVariant, we need to be able to associate -// wxAnyValueType with a wxVariantData factory function. -typedef wxVariantData* (*wxVariantDataFactory)(const wxAny& any); - -// Actual Any-to-Variant registration must be postponed to a time when all -// global variables have been initialized. Hence this arrangement. -// wxAnyToVariantRegistration instances are kept in global scope and -// wxAnyValueTypeGlobals in any.cpp will use their data when the time is -// right. -class WXDLLIMPEXP_BASE wxAnyToVariantRegistration -{ -public: - wxAnyToVariantRegistration(wxVariantDataFactory factory); - virtual ~wxAnyToVariantRegistration(); - - virtual wxAnyValueType* GetAssociatedType() = 0; - wxVariantDataFactory GetFactory() const { return m_factory; } -private: - wxVariantDataFactory m_factory; -}; - -template -class wxAnyToVariantRegistrationImpl : public wxAnyToVariantRegistration -{ -public: - wxAnyToVariantRegistrationImpl(wxVariantDataFactory factory) - : wxAnyToVariantRegistration(factory) - { - } - - virtual wxAnyValueType* GetAssociatedType() - { - return wxAnyValueTypeImpl::GetInstance(); - } -private: -}; - -#define DECLARE_WXANY_CONVERSION() \ -virtual bool GetAsAny(wxAny* any) const; \ -static wxVariantData* VariantDataFactory(const wxAny& any); - -#define _REGISTER_WXANY_CONVERSION(T, CLASSNAME, FUNC) \ -static wxAnyToVariantRegistrationImpl \ - gs_##CLASSNAME##AnyToVariantRegistration = \ - wxAnyToVariantRegistrationImpl(&FUNC); - -#define REGISTER_WXANY_CONVERSION(T, CLASSNAME) \ -_REGISTER_WXANY_CONVERSION(T, CLASSNAME, CLASSNAME::VariantDataFactory) - -#define IMPLEMENT_TRIVIAL_WXANY_CONVERSION(T, CLASSNAME) \ -bool CLASSNAME::GetAsAny(wxAny* any) const \ -{ \ - *any = m_value; \ - return true; \ -} \ -wxVariantData* CLASSNAME::VariantDataFactory(const wxAny& any) \ -{ \ - return new CLASSNAME(wxANY_AS(any, T)); \ -} \ -REGISTER_WXANY_CONVERSION(T, CLASSNAME) - -#else // if !wxUSE_ANY - -#define DECLARE_WXANY_CONVERSION() -#define REGISTER_WXANY_CONVERSION(T, CLASSNAME) -#define IMPLEMENT_TRIVIAL_WXANY_CONVERSION(T, CLASSNAME) - -#endif // wxUSE_ANY/!wxUSE_ANY - - #define DECLARE_VARIANT_OBJECT(classname) \ DECLARE_VARIANT_OBJECT_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE) @@ -494,13 +341,15 @@ public:\ virtual wxString GetType() const; \ virtual wxClassInfo* GetValueClassInfo(); \ \ - virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \ -\ - DECLARE_WXANY_CONVERSION() \ protected:\ classname m_value; \ +\ +private: \ + DECLARE_CLASS(classname##VariantData) \ };\ \ +IMPLEMENT_CLASS(classname##VariantData, wxVariantData)\ +\ wxString classname##VariantData::GetType() const\ {\ return m_value.GetClassInfo()->GetClassName();\ @@ -513,7 +362,7 @@ wxClassInfo* classname##VariantData::GetValueClassInfo()\ \ expdecl classname& operator << ( classname &value, const wxVariant &variant )\ {\ - wxASSERT( variant.GetType() == #classname );\ + wxASSERT( wxIsKindOf( variant.GetData(), classname##VariantData ) );\ \ classname##VariantData *data = (classname##VariantData*) variant.GetData();\ value = data->GetValue();\ @@ -525,8 +374,7 @@ expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\ classname##VariantData *data = new classname##VariantData( value );\ variant.SetData( data );\ return variant;\ -} \ -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(classname, classname##VariantData) +} // implements a wxVariantData-derived class using for the Eq() method the // operator== which must have been provided by "classname" @@ -535,7 +383,7 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdec \ bool classname##VariantData::Eq(wxVariantData& data) const \ {\ - wxASSERT( GetType() == data.GetType() );\ + wxASSERT( wxIsKindOf((&data), classname##VariantData) );\ \ classname##VariantData & otherData = (classname##VariantData &) data;\ \ @@ -552,7 +400,7 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdec \ bool classname##VariantData::Eq(wxVariantData& data) const \ {\ - wxASSERT( GetType() == data.GetType() );\ + wxASSERT( wxIsKindOf((&data), classname##VariantData) );\ \ classname##VariantData & otherData = (classname##VariantData &) data;\ \ @@ -568,13 +416,6 @@ bool classname##VariantData::Eq(wxVariantData& data) const \ ((classname*)(var.IsValueKindOf(&classname::ms_classInfo) ?\ var.GetWxObjectPtr() : NULL)); -// Replacement for using wxDynamicCast on a wxVariantData object -#ifndef wxNO_RTTI - #define wxDynamicCastVariantData(data, classname) dynamic_cast(data) -#endif - -#define wxStaticCastVariantData(data, classname) static_cast(data) - extern wxVariant WXDLLIMPEXP_BASE wxNullVariant; #endif // wxUSE_VARIANT diff --git a/Source/3rd Party/wx/include/wx/variantbase.h b/Source/3rd Party/wx/include/wx/variantbase.h deleted file mode 100644 index 732671bdd..000000000 --- a/Source/3rd Party/wx/include/wx/variantbase.h +++ /dev/null @@ -1,278 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/variantbase.h -// Purpose: wxVariantBase class, a minimal version of wxVariant used by XTI -// Author: Julian Smart -// Modified by: Francesco Montorsi -// Created: 10/09/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_VARIANTBASE_H_ -#define _WX_VARIANTBASE_H_ - -#include "wx/defs.h" - -#if wxUSE_VARIANT - -#include "wx/string.h" -#include "wx/arrstr.h" -#include "wx/cpp.h" -#include - -#if wxUSE_DATETIME - #include "wx/datetime.h" -#endif // wxUSE_DATETIME - -#include "wx/iosfwrap.h" - -class wxTypeInfo; -class wxObject; -class wxClassInfo; - -/* - * wxVariantData stores the actual data in a wxVariant object, - * to allow it to store any type of data. - * Derive from this to provide custom data handling. - * - * NB: To prevent addition of extra vtbl pointer to wxVariantData, - * we don't multiple-inherit from wxObjectRefData. Instead, - * we simply replicate the wxObject ref-counting scheme. - * - * NB: When you construct a wxVariantData, it will have refcount - * of one. Refcount will not be further increased when - * it is passed to wxVariant. This simulates old common - * scenario where wxVariant took ownership of wxVariantData - * passed to it. - * If you create wxVariantData for other reasons than passing - * it to wxVariant, technically you are not required to call - * DecRef() before deleting it. - * - * TODO: in order to replace wxPropertyValue, we would need - * to consider adding constructors that take pointers to C++ variables, - * or removing that functionality from the wxProperty library. - * Essentially wxPropertyValue takes on some of the wxValidator functionality - * by storing pointers and not just actual values, allowing update of C++ data - * to be handled automatically. Perhaps there's another way of doing this without - * overloading wxVariant with unnecessary functionality. - */ - -class WXDLLIMPEXP_BASE wxVariantData -{ - friend class wxVariantBase; - -public: - wxVariantData() - : m_count(1) - { } - -#if wxUSE_STD_IOSTREAM - virtual bool Write(wxSTD ostream& WXUNUSED(str)) const { return false; } - virtual bool Read(wxSTD istream& WXUNUSED(str)) { return false; } -#endif - virtual bool Write(wxString& WXUNUSED(str)) const { return false; } - virtual bool Read(wxString& WXUNUSED(str)) { return false; } - - // Override these to provide common functionality - virtual bool Eq(wxVariantData& data) const = 0; - - // What type is it? Return a string name. - virtual wxString GetType() const = 0; - - // returns the type info of the content - virtual const wxTypeInfo* GetTypeInfo() const = 0; - - // If it based on wxObject return the ClassInfo. - virtual wxClassInfo* GetValueClassInfo() { return NULL; } - - int GetRefCount() const - { return m_count; } - void IncRef() - { m_count++; } - void DecRef() - { - if ( --m_count == 0 ) - delete this; - } - -protected: - // Protected dtor should make some incompatible code - // break more louder. That is, they should do data->DecRef() - // instead of delete data. - virtual ~wxVariantData() {} - -private: - int m_count; -}; - -template class wxVariantDataT : public wxVariantData -{ -public: - wxVariantDataT(const T& d) : m_data(d) {} - virtual ~wxVariantDataT() {} - - // get a ref to the stored data - T & Get() { return m_data; } - - // get a const ref to the stored data - const T & Get() const { return m_data; } - - // set the data - void Set(const T& d) { m_data = d; } - - // Override these to provide common functionality - virtual bool Eq(wxVariantData& WXUNUSED(data)) const - { return false; /* FIXME!! */ } - - // What type is it? Return a string name. - virtual wxString GetType() const - { return GetTypeInfo()->GetTypeName(); } - - // return a heap allocated duplicate - //virtual wxVariantData* Clone() const { return new wxVariantDataT( Get() ); } - - // returns the type info of the contentc - virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ); } - -private: - T m_data; -}; - - -/* - * wxVariantBase can store any kind of data, but has some basic types - * built in. - */ - -class WXDLLIMPEXP_BASE wxVariantBase -{ -public: - wxVariantBase(); - wxVariantBase(const wxVariantBase& variant); - wxVariantBase(wxVariantData* data, const wxString& name = wxEmptyString); - - template - wxVariantBase(const T& data, const wxString& name = wxEmptyString) : - m_data(new wxVariantDataT(data)), m_name(name) {} - - virtual ~wxVariantBase(); - - // generic assignment - void operator= (const wxVariantBase& variant); - - // Assignment using data, e.g. - // myVariant = new wxStringVariantData("hello"); - void operator= (wxVariantData* variantData); - - bool operator== (const wxVariantBase& variant) const; - bool operator!= (const wxVariantBase& variant) const; - - // Sets/gets name - inline void SetName(const wxString& name) { m_name = name; } - inline const wxString& GetName() const { return m_name; } - - // Tests whether there is data - bool IsNull() const; - - // FIXME: used by wxVariantBase code but is nice wording... - bool IsEmpty() const { return IsNull(); } - - // For compatibility with wxWidgets <= 2.6, this doesn't increase - // reference count. - wxVariantData* GetData() const { return m_data; } - void SetData(wxVariantData* data) ; - - // make a 'clone' of the object - void Ref(const wxVariantBase& clone); - - // destroy a reference - void UnRef(); - - // Make NULL (i.e. delete the data) - void MakeNull(); - - // write contents to a string (e.g. for debugging) - wxString MakeString() const; - - // Delete data and name - void Clear(); - - // Returns a string representing the type of the variant, - // e.g. "string", "bool", "stringlist", "list", "double", "long" - wxString GetType() const; - - bool IsType(const wxString& type) const; - bool IsValueKindOf(const wxClassInfo* type) const; - - // FIXME wxXTI methods: - - // get the typeinfo of the stored object - const wxTypeInfo* GetTypeInfo() const - { - if (!m_data) - return NULL; - return m_data->GetTypeInfo(); - } - - // get a ref to the stored data - template T& Get(wxTEMPLATED_MEMBER_FIX(T)) - { - wxVariantDataT *dataptr = - wx_dynamic_cast(wxVariantDataT*, m_data); - wxASSERT_MSG( dataptr, - wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ); - return dataptr->Get(); - } - - // get a const ref to the stored data - template const T& Get(wxTEMPLATED_MEMBER_FIX(T)) const - { - const wxVariantDataT *dataptr = - wx_dynamic_cast(const wxVariantDataT*, m_data); - wxASSERT_MSG( dataptr, - wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ); - return dataptr->Get(); - } - - template bool HasData(wxTEMPLATED_MEMBER_FIX(T)) const - { - const wxVariantDataT *dataptr = - wx_dynamic_cast(const wxVariantDataT*, m_data); - return dataptr != NULL; - } - - // returns this value as string - wxString GetAsString() const; - - // gets the stored data casted to a wxObject*, - // returning NULL if cast is not possible - wxObject* GetAsObject(); - -protected: - wxVariantData* m_data; - wxString m_name; -}; - -#include "wx/dynarray.h" -WX_DECLARE_OBJARRAY_WITH_DECL(wxVariantBase, wxVariantBaseArray, class WXDLLIMPEXP_BASE); - - -// templated streaming, every type must have their specialization for these methods - -template -void wxStringReadValue( const wxString &s, T &data ); - -template -void wxStringWriteValue( wxString &s, const T &data); - -template -void wxToStringConverter( const wxVariantBase &v, wxString &s wxTEMPLATED_FUNCTION_FIX(T)) \ - { wxStringWriteValue( s, v.wxTEMPLATED_MEMBER_CALL(Get, T) ); } - -template -void wxFromStringConverter( const wxString &s, wxVariantBase &v wxTEMPLATED_FUNCTION_FIX(T)) \ - { T d; wxStringReadValue( s, d ); v = wxVariantBase(d); } - - -#endif // wxUSE_VARIANT -#endif // _WX_VARIANTBASE_H_ diff --git a/Source/3rd Party/wx/include/wx/vector.h b/Source/3rd Party/wx/include/wx/vector.h index 8662ae066..b05d779ec 100644 --- a/Source/3rd Party/wx/include/wx/vector.h +++ b/Source/3rd Party/wx/include/wx/vector.h @@ -2,10 +2,9 @@ // Name: wx/vector.h // Purpose: STL vector clone // Author: Lindsay Mathieson -// Modified by: Vaclav Slavik - make it a template +// Modified by: // Created: 30.07.2001 -// Copyright: (c) 2001 Lindsay Mathieson , -// 2007 Vaclav Slavik +// Copyright: (c) 2001 Lindsay Mathieson // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -14,337 +13,100 @@ #include "wx/defs.h" -#if wxUSE_STD_CONTAINERS - -#include -#include - -#define wxVector std::vector -template -inline void wxVectorSort(wxVector& v) +class WXDLLIMPEXP_BASE wxVectorBase { - std::sort(v.begin(), v.end()); -} - -#else // !wxUSE_STD_CONTAINERS - -#include "wx/scopeguard.h" -#include "wx/meta/movable.h" -#include "wx/meta/if.h" - -#include "wx/beforestd.h" -#include // for placement new -#include "wx/afterstd.h" - -// wxQsort is declared in wx/utils.h, but can't include that file here, -// it indirectly includes this file. Just lovely... -typedef int (*wxSortCallback)(const void* pItem1, - const void* pItem2, - const void* user_data); -WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems, - size_t size, wxSortCallback cmp, - const void* user_data); - -namespace wxPrivate -{ - -// These templates encapsulate memory operations for use by wxVector; there are -// two implementations, both in generic way for any C++ types and as an -// optimized version for "movable" types that uses realloc() and memmove(). - -// version for movable types: -template -struct wxVectorMemOpsMovable -{ - static void Free(T* array) - { free(array); } - - static T* Realloc(T* old, size_t newCapacity, size_t WXUNUSED(occupiedSize)) - { return (T*)realloc(old, newCapacity * sizeof(T)); } - - static void MemmoveBackward(T* dest, T* source, size_t count) - { memmove(dest, source, count * sizeof(T)); } - - static void MemmoveForward(T* dest, T* source, size_t count) - { memmove(dest, source, count * sizeof(T)); } -}; - -// generic version for non-movable types: -template -struct wxVectorMemOpsGeneric -{ - static void Free(T* array) - { ::operator delete(array); } - - static T* Realloc(T* old, size_t newCapacity, size_t occupiedSize) - { - T *mem = (T*)::operator new(newCapacity * sizeof(T)); - for ( size_t i = 0; i < occupiedSize; i++ ) - { - ::new(mem + i) T(old[i]); - old[i].~T(); - } - ::operator delete(old); - return mem; - } - - static void MemmoveBackward(T* dest, T* source, size_t count) - { - wxASSERT( dest < source ); - T* destptr = dest; - T* sourceptr = source; - for ( size_t i = count; i > 0; --i, ++destptr, ++sourceptr ) - { - ::new(destptr) T(*sourceptr); - sourceptr->~T(); - } - } - - static void MemmoveForward(T* dest, T* source, size_t count) - { - wxASSERT( dest > source ); - T* destptr = dest + count - 1; - T* sourceptr = source + count - 1; - for ( size_t i = count; i > 0; --i, --destptr, --sourceptr ) - { - ::new(destptr) T(*sourceptr); - sourceptr->~T(); - } - } -}; - - -} // namespace wxPrivate - -template -class wxVector -{ -private: - // This cryptic expression means "typedef Ops to wxVectorMemOpsMovable if - // type T is movable type, otherwise to wxVectorMemOpsGeneric". - // - // Note that we use typedef instead of privately deriving from this (which - // would allowed us to omit "Ops::" prefixes below) to keep VC6 happy, - // it can't compile code that derives from wxIf<...>::value. - // - // Note that bcc needs the extra parentheses for non-type template - // arguments to compile this expression. - typedef typename wxIf< (wxIsMovable::value), - wxPrivate::wxVectorMemOpsMovable, - wxPrivate::wxVectorMemOpsGeneric >::value - Ops; - public: typedef size_t size_type; - typedef size_t difference_type; - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type* iterator; - typedef const value_type* const_iterator; - typedef value_type& reference; - typedef const value_type& const_reference; +private: + size_type m_allocsize; + size_type m_size, + m_capacity; + void **m_objects; - class reverse_iterator +protected: + bool Alloc(size_type sz) { - public: - reverse_iterator() : m_ptr(NULL) { } - wxEXPLICIT reverse_iterator(iterator it) : m_ptr(it) { } - reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { } + // work in multiples of m_allocsize; + sz = (sz / m_allocsize + 1) * m_allocsize; + if (sz <= m_capacity) + return true; - reference operator*() const { return *m_ptr; } - pointer operator->() const { return m_ptr; } - - iterator base() const { return m_ptr; } - - reverse_iterator& operator++() - { --m_ptr; return *this; } - reverse_iterator operator++(int) - { reverse_iterator tmp = *this; --m_ptr; return tmp; } - reverse_iterator& operator--() - { ++m_ptr; return *this; } - reverse_iterator operator--(int) - { reverse_iterator tmp = *this; ++m_ptr; return tmp; } - - reverse_iterator operator+(difference_type n) const - { return reverse_iterator(m_ptr - n); } - reverse_iterator& operator+=(difference_type n) - { m_ptr -= n; return *this; } - reverse_iterator operator-(difference_type n) const - { return reverse_iterator(m_ptr + n); } - reverse_iterator& operator-=(difference_type n) - { m_ptr += n; return *this; } - - reference operator[](difference_type n) const - { return *(*this + n); } - - bool operator ==(const reverse_iterator& it) const - { return m_ptr == it.m_ptr; } - bool operator !=(const reverse_iterator& it) const - { return m_ptr != it.m_ptr; } - - private: - value_type *m_ptr; - - friend class const_reverse_iterator; - }; - - class const_reverse_iterator - { - public: - const_reverse_iterator() : m_ptr(NULL) { } - wxEXPLICIT const_reverse_iterator(const_iterator it) : m_ptr(it) { } - const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { } - const_reverse_iterator(const const_reverse_iterator& it) : m_ptr(it.m_ptr) { } - - const_reference operator*() const { return *m_ptr; } - const_pointer operator->() const { return m_ptr; } - - const_iterator base() const { return m_ptr; } - - const_reverse_iterator& operator++() - { --m_ptr; return *this; } - const_reverse_iterator operator++(int) - { const_reverse_iterator tmp = *this; --m_ptr; return tmp; } - const_reverse_iterator& operator--() - { ++m_ptr; return *this; } - const_reverse_iterator operator--(int) - { const_reverse_iterator tmp = *this; ++m_ptr; return tmp; } - - const_reverse_iterator operator+(difference_type n) const - { return const_reverse_iterator(m_ptr - n); } - const_reverse_iterator& operator+=(difference_type n) - { m_ptr -= n; return *this; } - const_reverse_iterator operator-(difference_type n) const - { return const_reverse_iterator(m_ptr + n); } - const_reverse_iterator& operator-=(difference_type n) - { m_ptr += n; return *this; } - - const_reference operator[](difference_type n) const - { return *(*this + n); } - - bool operator ==(const const_reverse_iterator& it) const - { return m_ptr == it.m_ptr; } - bool operator !=(const const_reverse_iterator& it) const - { return m_ptr != it.m_ptr; } - - protected: - const value_type *m_ptr; - }; - - wxVector() : m_size(0), m_capacity(0), m_values(NULL) {} - - wxVector(size_type p_size) - : m_size(0), m_capacity(0), m_values(NULL) - { - reserve(p_size); - for ( size_t n = 0; n < p_size; n++ ) - push_back(value_type()); + // try to realloc + void *mem = realloc(m_objects, sizeof(void *) * sz); + if (! mem) + return false; // failed + // success + m_objects = (void **) mem; + m_capacity = sz; + return true; } - wxVector(size_type p_size, const value_type& v) - : m_size(0), m_capacity(0), m_values(NULL) + // untyped destructor of elements - must be overriden + virtual void Free(void *) = 0; + // untyped copy constructor of elements - must be overriden + virtual void *Copy(const void *) const = 0; + + const void *GetItem(size_type idx) const { - reserve(p_size); - for ( size_t n = 0; n < p_size; n++ ) - push_back(v); + wxASSERT(idx < m_size); + return m_objects[idx]; } - wxVector(const wxVector& c) : m_size(0), m_capacity(0), m_values(NULL) + void Append(void *obj) { - Copy(c); + wxASSERT(m_size < m_capacity); + m_objects[m_size] = obj; + m_size++; } - template - wxVector(InputIterator first, InputIterator last) - : m_size(0), m_capacity(0), m_values(NULL) + void RemoveAt(size_type idx) { - assign(first, last); + wxASSERT(idx < m_size); + Free(m_objects[idx]); + if (idx < m_size - 1) + memcpy( + m_objects + idx, + m_objects + idx + 1, + ( m_size - idx - 1 ) * sizeof(void*) ); + m_size--; } - ~wxVector() + bool copy(const wxVectorBase& vb) { clear(); + if (! Alloc(vb.size())) + return false; + + for (size_type i = 0; i < vb.size(); i++) + { + void *o = vb.Copy(vb.GetItem(i)); + if (! o) + return false; + Append(o); + } + + return true; } - void assign(size_type p_size, const value_type& v) - { - clear(); - reserve(p_size); - for ( size_t n = 0; n < p_size; n++ ) - push_back(v); - } - - template - void assign(InputIterator first, InputIterator last) - { - clear(); - - // Notice that it would be nice to call reserve() here but we can't do - // it for arbitrary input iterators, we should have a dispatch on - // iterator type and call it if possible. - - for ( InputIterator it = first; it != last; ++it ) - push_back(*it); - } - - void swap(wxVector& v) - { - wxSwap(m_size, v.m_size); - wxSwap(m_capacity, v.m_capacity); - wxSwap(m_values, v.m_values); - } +public: + wxVectorBase() : m_allocsize(16), m_size(0), m_capacity(0), m_objects(0) {} + virtual ~wxVectorBase() {} // calm down GCC void clear() { - // call destructors of stored objects: - for ( size_type i = 0; i < m_size; i++ ) - { - m_values[i].~T(); - } - - Ops::Free(m_values); - m_values = NULL; - m_size = - m_capacity = 0; + for (size_type i = 0; i < size(); i++) + Free(m_objects[i]); + free(m_objects); + m_objects = 0; + m_size = m_capacity = 0; } void reserve(size_type n) { - if ( n <= m_capacity ) - return; - - // increase the size twice, unless we're already too big or unless - // more is requested - // - // NB: casts to size_type are needed to suppress warnings about - // mixing enumeral and non-enumeral type in conditional expression - const size_type increment = m_size > 0 - ? m_size < ALLOC_MAX_SIZE - ? m_size - : (size_type)ALLOC_MAX_SIZE - : (size_type)ALLOC_INITIAL_SIZE; - if ( m_capacity + increment > n ) - n = m_capacity + increment; - - m_values = Ops::Realloc(m_values, n, m_size); - m_capacity = n; - } - - void resize(size_type n) - { - if ( n < m_size ) - Shrink(n); - else if ( n > m_size ) - Extend(n, value_type()); - } - - void resize(size_type n, const value_type& v) - { - if ( n < m_size ) - Shrink(n); - else if ( n > m_size ) - Extend(n, v); + if ( !Alloc(n) ) + { + wxFAIL_MSG( wxT("out of memory in wxVector::reserve()") ); + } } size_type size() const @@ -362,223 +124,89 @@ public: return size() == 0; } - wxVector& operator=(const wxVector& vb) + wxVectorBase& operator = (const wxVectorBase& vb) { - if (this != &vb) - { - clear(); - Copy(vb); - } + wxCHECK(copy(vb), *this); return *this; } - - void push_back(const value_type& v) - { - reserve(size() + 1); - - // use placement new to initialize new object in preallocated place in - // m_values and store 'v' in it: - void* const place = m_values + m_size; - ::new(place) value_type(v); - - // only increase m_size if the ctor didn't throw an exception; notice - // that if it _did_ throw, everything is OK, because we only increased - // vector's capacity so far and possibly written some data to - // uninitialized memory at the end of m_values - m_size++; - } - - void pop_back() - { - erase(end() - 1); - } - - const value_type& at(size_type idx) const - { - wxASSERT(idx < m_size); - return m_values[idx]; - } - - value_type& at(size_type idx) - { - wxASSERT(idx < m_size); - return m_values[idx]; - } - - const value_type& operator[](size_type idx) const { return at(idx); } - value_type& operator[](size_type idx) { return at(idx); } - const value_type& front() const { return at(0); } - value_type& front() { return at(0); } - const value_type& back() const { return at(size() - 1); } - value_type& back() { return at(size() - 1); } - - const_iterator begin() const { return m_values; } - iterator begin() { return m_values; } - const_iterator end() const { return m_values + size(); } - iterator end() { return m_values + size(); } - - reverse_iterator rbegin() { return reverse_iterator(end() - 1); } - reverse_iterator rend() { return reverse_iterator(begin() - 1); } - - const_reverse_iterator rbegin() const { return const_reverse_iterator(end() - 1); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin() - 1); } - - iterator insert(iterator it, const value_type& v = value_type()) - { - // NB: this must be done before reserve(), because reserve() - // invalidates iterators! - const size_t idx = it - begin(); - const size_t after = end() - it; - - reserve(size() + 1); - - // the place where the new element is going to be inserted - value_type * const place = m_values + idx; - - // unless we're inserting at the end, move following elements out of - // the way: - if ( after > 0 ) - Ops::MemmoveForward(place + 1, place, after); - - // if the ctor called below throws an exception, we need to move all - // the elements back to their original positions in m_values - wxScopeGuard moveBack = wxMakeGuard( - Ops::MemmoveBackward, place, place + 1, after); - if ( !after ) - moveBack.Dismiss(); - - // use placement new to initialize new object in preallocated place in - // m_values and store 'v' in it: - ::new(place) value_type(v); - - // now that we did successfully add the new element, increment the size - // and disable moving the items back - moveBack.Dismiss(); - m_size++; - - return begin() + idx; - } - - iterator erase(iterator it) - { - return erase(it, it + 1); - } - - iterator erase(iterator first, iterator last) - { - if ( first == last ) - return first; - wxASSERT( first < end() && last <= end() ); - - const size_type idx = first - begin(); - const size_type count = last - first; - const size_type after = end() - last; - - // erase elements by calling their destructors: - for ( iterator i = first; i < last; ++i ) - i->~T(); - - // once that's done, move following elements over to the freed space: - if ( after > 0 ) - { - Ops::MemmoveBackward(m_values + idx, m_values + idx + count, after); - } - - m_size -= count; - - return begin() + idx; - } - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( size_type erase(size_type n) ); -#endif // WXWIN_COMPATIBILITY_2_8 - -private: - // VC6 can't compile static const int members - enum { ALLOC_INITIAL_SIZE = 16 }; - enum { ALLOC_MAX_SIZE = 4096 }; - - void Copy(const wxVector& vb) - { - reserve(vb.size()); - - for ( const_iterator i = vb.begin(); i != vb.end(); ++i ) - push_back(*i); - } - -private: - void Shrink(size_type n) - { - for ( size_type i = n; i < m_size; i++ ) - m_values[i].~T(); - m_size = n; - } - - void Extend(size_type n, const value_type& v) - { - reserve(n); - for ( size_type i = m_size; i < n; i++ ) - push_back(v); - } - - size_type m_size, - m_capacity; - value_type *m_values; }; -#if WXWIN_COMPATIBILITY_2_8 -template -inline typename wxVector::size_type wxVector::erase(size_type n) -{ - erase(begin() + n); - return n; -} -#endif // WXWIN_COMPATIBILITY_2_8 - - - -namespace wxPrivate -{ - -// This is a helper for the wxVectorSort function, and should not be used -// directly in user's code. -template -struct wxVectorComparator -{ - static int - Compare(const void* pitem1, const void* pitem2, const void* ) - { - const T& item1 = *reinterpret_cast(pitem1); - const T& item2 = *reinterpret_cast(pitem2); - - if (item1 < item2) - return -1; - else if (item2 < item1) - return 1; - else - return 0; +#define WX_DECLARE_VECTORBASE(obj, cls)\ +protected:\ + virtual void Free(void *o)\ + {\ + delete (obj *) o;\ + }\ + virtual void *Copy(const void *o) const\ + {\ + return new obj(*(obj *) o);\ + }\ +public:\ + cls() {}\ + cls(const cls& c) : wxVectorBase()\ + {\ + wxCHECK2(copy(c), return);\ + }\ + ~cls()\ + {\ + clear();\ } -}; -} // namespace wxPrivate - - - -template -void wxVectorSort(wxVector& v) -{ - wxQsort(v.begin(), v.size(), sizeof(T), - wxPrivate::wxVectorComparator::Compare, NULL); +#define _WX_DECLARE_VECTOR(obj, cls, exp)\ +class exp cls : public wxVectorBase\ +{\ + WX_DECLARE_VECTORBASE(obj, cls)\ +public:\ + void push_back(const obj& o)\ + {\ + wxCHECK2(Alloc(size() + 1), return);\ + Append(new obj(o));\ + }\ + void pop_back()\ + {\ + RemoveAt(size() - 1);\ + }\ + const obj& at(size_type idx) const\ + {\ + return *(obj *) GetItem(idx);\ + }\ + obj& at(size_type idx)\ + {\ + return *(obj *) GetItem(idx);\ + }\ + const obj& operator[](size_type idx) const\ + {\ + return at(idx);\ + }\ + obj& operator[](size_type idx)\ + {\ + return at(idx);\ + }\ + const obj& front() const\ + {\ + return at(0);\ + }\ + obj& front()\ + {\ + return at(0);\ + }\ + const obj& back() const\ + {\ + return at(size() - 1);\ + }\ + obj& back()\ + {\ + return at(size() - 1);\ + }\ + size_type erase(size_type idx)\ + {\ + RemoveAt(idx);\ + return idx;\ + }\ } - - -#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS - -#if WXWIN_COMPATIBILITY_2_8 - #define WX_DECLARE_VECTORBASE(obj, cls) typedef wxVector cls - #define _WX_DECLARE_VECTOR(obj, cls, exp) WX_DECLARE_VECTORBASE(obj, cls) - #define WX_DECLARE_VECTOR(obj, cls) WX_DECLARE_VECTORBASE(obj, cls) -#endif // WXWIN_COMPATIBILITY_2_8 +#define WX_DECLARE_VECTOR(obj, cls) \ + _WX_DECLARE_VECTOR(obj, cls, WXDLLEXPORT) #endif // _WX_VECTOR_H_ + diff --git a/Source/3rd Party/wx/include/wx/version.h b/Source/3rd Party/wx/include/wx/version.h index 573918448..11cf33112 100644 --- a/Source/3rd Party/wx/include/wx/version.h +++ b/Source/3rd Party/wx/include/wx/version.h @@ -4,6 +4,7 @@ * Author: Julian Smart * Modified by: Ryan Norton (Converted to C) * Created: 29/01/98 + * RCS-ID: $Id: version.h 66910 2011-02-16 20:53:53Z JS $ * Copyright: (c) 1998 Julian Smart * Licence: wxWindows licence */ @@ -25,11 +26,11 @@ */ /* NB: this file is parsed by automatic tools so don't change its format! */ -#define wxMAJOR_VERSION 3 -#define wxMINOR_VERSION 0 -#define wxRELEASE_NUMBER 2 +#define wxMAJOR_VERSION 2 +#define wxMINOR_VERSION 8 +#define wxRELEASE_NUMBER 12 #define wxSUBRELEASE_NUMBER 0 -#define wxVERSION_STRING wxT("wxWidgets 3.0.2") +#define wxVERSION_STRING wxT("wxWidgets 2.8.12") /* nothing to update below this line when updating the version */ /* ---------------------------------------------------------------------------- */ diff --git a/Source/3rd Party/wx/include/wx/versioninfo.h b/Source/3rd Party/wx/include/wx/versioninfo.h deleted file mode 100644 index 79469111a..000000000 --- a/Source/3rd Party/wx/include/wx/versioninfo.h +++ /dev/null @@ -1,77 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/versioninfo.h -// Purpose: declaration of wxVersionInfo class -// Author: Troels K -// Created: 2010-11-22 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_VERSIONINFO_H_ -#define _WX_VERSIONINFO_H_ - -#include "wx/string.h" - -// ---------------------------------------------------------------------------- -// wxVersionInfo: represents version information -// ---------------------------------------------------------------------------- - -class wxVersionInfo -{ -public: - wxVersionInfo(const wxString& name = wxString(), - int major = 0, - int minor = 0, - int micro = 0, - const wxString& description = wxString(), - const wxString& copyright = wxString()) - { - m_name = name; - m_major = major; - m_minor = minor; - m_micro = micro; - m_description = description; - m_copyright = copyright; - } - - // Default copy ctor, assignment operator and dtor are ok. - - - const wxString& GetName() const { return m_name; } - - int GetMajor() const { return m_major; } - int GetMinor() const { return m_minor; } - int GetMicro() const { return m_micro; } - - wxString ToString() const - { - return HasDescription() ? GetDescription() : GetVersionString(); - } - - wxString GetVersionString() const - { - wxString str; - str << m_name << ' ' << GetMajor() << '.' << GetMinor(); - if ( GetMicro() ) - str << '.' << GetMicro(); - - return str; - } - - bool HasDescription() const { return !m_description.empty(); } - const wxString& GetDescription() const { return m_description; } - - bool HasCopyright() const { return !m_copyright.empty(); } - const wxString& GetCopyright() const { return m_copyright; } - -private: - wxString m_name, - m_description, - m_copyright; - - int m_major, - m_minor, - m_micro; -}; - -#endif // _WX_VERSIONINFO_H_ diff --git a/Source/3rd Party/wx/include/wx/vidmode.h b/Source/3rd Party/wx/include/wx/vidmode.h index ffe5dc7d6..343d0de94 100644 --- a/Source/3rd Party/wx/include/wx/vidmode.h +++ b/Source/3rd Party/wx/include/wx/vidmode.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 27.09.2003 (extracted from wx/display.h) +// RCS-ID: $Id: vidmode.h 27408 2004-05-23 20:53:33Z JS $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ // wxVideoMode: a simple struct containing video mode parameters for a display // ---------------------------------------------------------------------------- -struct WXDLLIMPEXP_CORE wxVideoMode +struct WXDLLEXPORT wxVideoMode { wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0) { @@ -53,7 +54,6 @@ struct WXDLLIMPEXP_CORE wxVideoMode int GetWidth() const { return w; } int GetHeight() const { return h; } int GetDepth() const { return bpp; } - int GetRefresh() const { return refresh; } // returns true if the object has been initialized bool IsOk() const { return w && h; } diff --git a/Source/3rd Party/wx/include/wx/vlbox.h b/Source/3rd Party/wx/include/wx/vlbox.h index c844da85a..4aa3bf5d3 100644 --- a/Source/3rd Party/wx/include/wx/vlbox.h +++ b/Source/3rd Party/wx/include/wx/vlbox.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 31.05.03 +// RCS-ID: $Id: vlbox.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,8 @@ #include "wx/bitmap.h" class WXDLLIMPEXP_FWD_CORE wxSelectionStore; -extern WXDLLIMPEXP_DATA_CORE(const char) wxVListBoxNameStr[]; + +#define wxVListBoxNameStr wxT("wxVListBox") // ---------------------------------------------------------------------------- // wxVListBox @@ -30,7 +32,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxVListBoxNameStr[]; It emits the same events as wxListBox and the same event macros may be used with it. */ -class WXDLLIMPEXP_CORE wxVListBox : public wxVScrolledWindow +class WXDLLEXPORT wxVListBox : public wxVScrolledWindow { public: // constructors and such @@ -73,7 +75,7 @@ public: // --------- // get the number of items in the control - size_t GetItemCount() const { return GetRowCount(); } + size_t GetItemCount() const { return GetLineCount(); } // does this control use multiple selection? bool HasMultipleSelection() const { return m_selStore != NULL; } @@ -125,15 +127,13 @@ public: // get the background colour of selected cells const wxColour& GetSelectionBackground() const { return m_colBgSel; } - // get the item rect, returns empty rect if the item is not visible - wxRect GetItemRect(size_t n) const; // operations // ---------- // set the number of items to be shown in the control // - // this is just a synonym for wxVScrolledWindow::SetRowCount() + // this is just a synonym for wxVScrolledWindow::SetLineCount() virtual void SetItemCount(size_t count); // delete all items from the control @@ -189,9 +189,6 @@ public: // change the background colour of the selected cells void SetSelectionBackground(const wxColour& col); - // refreshes only the selected items - void RefreshSelected(); - virtual wxVisualAttributes GetDefaultAttributes() const { @@ -202,8 +199,6 @@ public: GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_THEME; } - // the derived class must implement this function to actually draw the item // with the given index on the provided DC virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const = 0; @@ -228,11 +223,11 @@ protected: // current virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; - // we implement OnGetRowHeight() in terms of OnMeasureItem() because this + // we implement OnGetLineHeight() in terms of OnMeasureItem() because this // allows us to add borders to the items easily // // this function is not supposed to be overridden by the derived classes - virtual wxCoord OnGetRowHeight(size_t line) const; + virtual wxCoord OnGetLineHeight(size_t line) const; // event handlers @@ -240,15 +235,13 @@ protected: void OnKeyDown(wxKeyEvent& event); void OnLeftDown(wxMouseEvent& event); void OnLeftDClick(wxMouseEvent& event); - void OnSetOrKillFocus(wxFocusEvent& event); - void OnSize(wxSizeEvent& event); + // common part of all ctors void Init(); - // send the wxEVT_LISTBOX event + // send the wxEVT_COMMAND_LISTBOX_SELECTED event void SendSelectedEvent(); - virtual void InitEvent(wxCommandEvent& event, int n); // common implementation of SelectAll() and DeselectAll() bool DoSelectAll(bool select); @@ -271,14 +264,6 @@ protected: // common part of keyboard and mouse handling processing code void DoHandleItemClick(int item, int flags); - // paint the background of the given item using the provided colour if it's - // valid, otherwise just return false and do nothing (this is used by - // OnDrawBackground()) - bool DoDrawSolidBackground(const wxColour& col, - wxDC& dc, - const wxRect& rect, - size_t n) const; - private: // the current item or wxNOT_FOUND // @@ -303,7 +288,7 @@ private: wxColour m_colBgSel; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxVListBox); + DECLARE_NO_COPY_CLASS(wxVListBox) DECLARE_ABSTRACT_CLASS(wxVListBox) }; diff --git a/Source/3rd Party/wx/include/wx/vms_x_fix.h b/Source/3rd Party/wx/include/wx/vms_x_fix.h deleted file mode 100644 index 8d34abd7e..000000000 --- a/Source/3rd Party/wx/include/wx/vms_x_fix.h +++ /dev/null @@ -1,1213 +0,0 @@ -/*************************************************************************** - * * - * Author : Jouk Jansen (joukj@hrem.stm.tudelft.nl) * - * * - * Last revision : 7 October 2005 * - * * - * Repair definitions of Runtime library functions when compiling with * - * /name=(as_is) on OpenVMS * - * * - ***************************************************************************/ - -#ifndef VMS_X_FIX -#define VMS_X_FIX - -#define decw$_select DECW$_SELECT -#define DtSaverGetWindows DTSAVERGETWINDOWS -#define MrmFetchWidget MRMFETCHWIDGET -#define MrmInitialize MRMINITIALIZE -#define MrmOpenHierarchy MRMOPENHIERARCHY -#define MrmRegisterNames MRMREGISTERNAMES -#define XAddExtension XADDEXTENSION -#define XAddHosts XADDHOSTS -#define XAllocClassHint XALLOCCLASSHINT -#define XAllocColor XALLOCCOLOR -#define XAllocColorCells XALLOCCOLORCELLS -#define XAllocIconSize XALLOCICONSIZE -#define XAllocNamedColor XALLOCNAMEDCOLOR -#define XAllocSizeHints XALLOCSIZEHINTS -#define XAllocStandardColormap XALLOCSTANDARDCOLORMAP -#define XAllocWMHints XALLOCWMHINTS -#define XAllowEvents XALLOWEVENTS -#define XAutoRepeatOff XAUTOREPEATOFF -#define XAutoRepeatOn XAUTOREPEATON -#define XBaseFontNameListOfFontSet XBASEFONTNAMELISTOFFONTSET -#define XBell XBELL -#define XBitmapPad XBITMAPPAD -#define XBlackPixel XBLACKPIXEL -#define XBlackPixelOfScreen XBLACKPIXELOFSCREEN -#define XCellsOfScreen XCELLSOFSCREEN -#define XChangeActivePointerGrab XCHANGEACTIVEPOINTERGRAB -#define XChangeGC XCHANGEGC -#define XChangeKeyboardControl XCHANGEKEYBOARDCONTROL -#define XChangePointerControl XCHANGEPOINTERCONTROL -#define XChangeProperty XCHANGEPROPERTY -#define XChangeWindowAttributes XCHANGEWINDOWATTRIBUTES -#define XCheckIfEvent XCHECKIFEVENT -#define XCheckMaskEvent XCHECKMASKEVENT -#define XCheckTypedEvent XCHECKTYPEDEVENT -#define XCheckTypedWindowEvent XCHECKTYPEDWINDOWEVENT -#define XCheckWindowEvent XCHECKWINDOWEVENT -#define XClearArea XCLEARAREA -#define XClearWindow XCLEARWINDOW -#define XClipBox XCLIPBOX -#define XCloseDisplay XCLOSEDISPLAY -#define XCloseIM XCLOSEIM -#define XConfigureWindow XCONFIGUREWINDOW -#define XConvertSelection XCONVERTSELECTION -#define XCopyArea XCOPYAREA -#define XCopyColormapAndFree XCOPYCOLORMAPANDFREE -#define XCopyGC XCOPYGC -#define XCopyPlane XCOPYPLANE -#define XCreateBitmapFromData XCREATEBITMAPFROMDATA -#define XCreateColormap XCREATECOLORMAP -#define XCreateFontCursor XCREATEFONTCURSOR -#define XCreateFontSet XCREATEFONTSET -#define XCreateGC XCREATEGC -#define XCreateGlyphCursor XCREATEGLYPHCURSOR -#define XCreateIC XCREATEIC -#define XCreateImage XCREATEIMAGE -#define XCreatePixmap XCREATEPIXMAP -#define XCreatePixmapCursor XCREATEPIXMAPCURSOR -#define XCreatePixmapFromBitmapData XCREATEPIXMAPFROMBITMAPDATA -#define XCreateRegion XCREATEREGION -#define XCreateSimpleWindow XCREATESIMPLEWINDOW -#define XCreateWindow XCREATEWINDOW -#define XDefaultColormap XDEFAULTCOLORMAP -#define XDefaultColormapOfScreen XDEFAULTCOLORMAPOFSCREEN -#define XDefaultDepth XDEFAULTDEPTH -#define XDefaultDepthOfScreen XDEFAULTDEPTHOFSCREEN -#define XDefaultGC XDEFAULTGC -#define XDefaultRootWindow XDEFAULTROOTWINDOW -#define XDefaultScreen XDEFAULTSCREEN -#define XDefaultScreenOfDisplay XDEFAULTSCREENOFDISPLAY -#define XDefaultVisual XDEFAULTVISUAL -#define XDefaultVisualOfScreen XDEFAULTVISUALOFSCREEN -#define XDefineCursor XDEFINECURSOR -#define XDeleteContext XDELETECONTEXT -#define XDeleteProperty XDELETEPROPERTY -#define XDestroyIC XDESTROYIC -#define XDestroyRegion XDESTROYREGION -#define XDestroySubwindows XDESTROYSUBWINDOWS -#define XDestroyWindow XDESTROYWINDOW -#define XDisableAccessControl XDISABLEACCESSCONTROL -#define XDisplayCells XDISPLAYCELLS -#define XDisplayHeight XDISPLAYHEIGHT -#define XDisplayKeycodes XDISPLAYKEYCODES -#define XDisplayName XDISPLAYNAME -#define XDisplayOfIM XDISPLAYOFIM -#define XDisplayOfScreen XDISPLAYOFSCREEN -#define XDisplayString XDISPLAYSTRING -#define XDisplayWidth XDISPLAYWIDTH -#define XDoesBackingStore XDOESBACKINGSTORE -#define XDrawArc XDRAWARC -#define XDrawArcs XDRAWARCS -#define XDrawImageString XDRAWIMAGESTRING -#define XDrawImageString16 XDRAWIMAGESTRING16 -#define XDrawLine XDRAWLINE -#define XDrawLines XDRAWLINES -#define XDrawPoint XDRAWPOINT -#define XDrawPoints XDRAWPOINTS -#define XDrawRectangle XDRAWRECTANGLE -#define XDrawRectangles XDRAWRECTANGLES -#define XDrawSegments XDRAWSEGMENTS -#define XDrawString XDRAWSTRING -#define XDrawString16 XDRAWSTRING16 -#define XDrawText XDRAWTEXT -#define XDrawText16 XDRAWTEXT16 -#define XESetCloseDisplay XESETCLOSEDISPLAY -#define XEmptyRegion XEMPTYREGION -#define XEnableAccessControl XENABLEACCESSCONTROL -#define XEqualRegion XEQUALREGION -#define XEventsQueued XEVENTSQUEUED -#define XExtendedMaxRequestSize XEXTENDEDMAXREQUESTSIZE -#define XExtentsOfFontSet XEXTENTSOFFONTSET -#define XFetchBuffer XFETCHBUFFER -#define XFetchBytes XFETCHBYTES -#define XFetchName XFETCHNAME -#define XFillArc XFILLARC -#define XFillArcs XFILLARCS -#define XFillPolygon XFILLPOLYGON -#define XFillRectangle XFILLRECTANGLE -#define XFillRectangles XFILLRECTANGLES -#define XFilterEvent XFILTEREVENT -#define XFindContext XFINDCONTEXT -#define XFlush XFLUSH -#define XFontsOfFontSet XFONTSOFFONTSET -#define XForceScreenSaver XFORCESCREENSAVER -#define XFree XFREE -#define XFreeColormap XFREECOLORMAP -#define XFreeColors XFREECOLORS -#define XFreeCursor XFREECURSOR -#define XFreeDeviceList XFREEDEVICELIST -#define XFreeDeviceState XFREEDEVICESTATE -#define XFreeFont XFREEFONT -#define XFreeFontInfo XFREEFONTINFO -#define XFreeFontNames XFREEFONTNAMES -#define XFreeFontSet XFREEFONTSET -#define XFreeGC XFREEGC -#define XFreeModifiermap XFREEMODIFIERMAP -#define XFreePixmap XFREEPIXMAP -#define XFreeStringList XFREESTRINGLIST -#define XGContextFromGC XGCONTEXTFROMGC -#define XGeometry XGEOMETRY -#define XGetAtomName XGETATOMNAME -#define XGetCommand XGETCOMMAND -#define XGetDefault XGETDEFAULT -#define XGetErrorDatabaseText XGETERRORDATABASETEXT -#define XGetErrorText XGETERRORTEXT -#define XGetExtensionVersion XGETEXTENSIONVERSION -#define XGetFontProperty XGETFONTPROPERTY -#define XGetGCValues XGETGCVALUES -#define XGetGeometry XGETGEOMETRY -#define XGetICValues XGETICVALUES -#define XGetIMValues XGETIMVALUES -#define XGetIconName XGETICONNAME -#define XGetIconSizes XGETICONSIZES -#define XGetImage XGETIMAGE -#define XGetInputFocus XGETINPUTFOCUS -#define XGetKeyboardControl XGETKEYBOARDCONTROL -#define XGetKeyboardMapping XGETKEYBOARDMAPPING -#define XGetModifierMapping XGETMODIFIERMAPPING -#define XGetMotionEvents XGETMOTIONEVENTS -#define XGetNormalHints XGETNORMALHINTS -#define XGetPointerMapping XGETPOINTERMAPPING -#define XGetRGBColormaps XGETRGBCOLORMAPS -#define XGetScreenSaver XGETSCREENSAVER -#define XGetSelectionOwner XGETSELECTIONOWNER -#define XGetStandardColormap XGETSTANDARDCOLORMAP -#define XGetSubImage XGETSUBIMAGE -#define XGetTextProperty XGETTEXTPROPERTY -#define XGetVisualInfo XGETVISUALINFO -#define XGetWMColormapWindows XGETWMCOLORMAPWINDOWS -#define XGetWMHints XGETWMHINTS -#define XGetWMIconName XGETWMICONNAME -#define XGetWMName XGETWMNAME -#define XGetWMNormalHints XGETWMNORMALHINTS -#define XGetWindowAttributes XGETWINDOWATTRIBUTES -#define XGetWindowProperty XGETWINDOWPROPERTY -#define XGrabButton XGRABBUTTON -#define XGrabKeyboard XGRABKEYBOARD -#define XGrabPointer XGRABPOINTER -#define XGrabServer XGRABSERVER -#define XHeightMMOfScreen XHEIGHTMMOFSCREEN -#define XHeightOfScreen XHEIGHTOFSCREEN -#define XIconifyWindow XICONIFYWINDOW -#define XIfEvent XIFEVENT -#define XInitExtension XINITEXTENSION -#define XInitImage XINITIMAGE -#define XInstallColormap XINSTALLCOLORMAP -#define XInternAtom XINTERNATOM -#define XInternAtoms XINTERNATOMS -#define XIntersectRegion XINTERSECTREGION -#define XKeycodeToKeysym XKEYCODETOKEYSYM -#define XKeysymToKeycode XKEYSYMTOKEYCODE -#define XKeysymToString XKEYSYMTOSTRING -#define XKillClient XKILLCLIENT -#define XListDepths XLISTDEPTHS -#define XListFonts XLISTFONTS -#define XListFontsWithInfo XLISTFONTSWITHINFO -#define XListHosts XLISTHOSTS -#define XListInputDevices XLISTINPUTDEVICES -#define XListInstalledColormaps XLISTINSTALLEDCOLORMAPS -#define XListPixmapFormats XLISTPIXMAPFORMATS -#define XListProperties XLISTPROPERTIES -#define XLoadFont XLOADFONT -#define XLoadQueryFont XLOADQUERYFONT -#define XLookupColor XLOOKUPCOLOR -#define XLookupKeysym XLOOKUPKEYSYM -#define XLookupString XLOOKUPSTRING -#define XLowerWindow XLOWERWINDOW -#define XMapRaised XMAPRAISED -#define XMapSubwindows XMAPSUBWINDOWS -#define XMapWindow XMAPWINDOW -#define XMatchVisualInfo XMATCHVISUALINFO -#define XMaxRequestSize XMAXREQUESTSIZE -#define XMissingExtension XMISSINGEXTENSION -#define XMoveResizeWindow XMOVERESIZEWINDOW -#define XMoveWindow XMOVEWINDOW -#define XNextEvent XNEXTEVENT -#define XNextRequest XNEXTREQUEST -#define XNoOp XNOOP -#define XOffsetRegion XOFFSETREGION -#define XOpenDevice XOPENDEVICE -#define XOpenDisplay XOPENDISPLAY -#define XOpenIM XOPENIM -#define XParseColor XPARSECOLOR -#define XParseGeometry XPARSEGEOMETRY -#define XPeekEvent XPEEKEVENT -#define XPeekIfEvent XPEEKIFEVENT -#define XPending XPENDING -#define XPointInRegion XPOINTINREGION -#define XPolygonRegion XPOLYGONREGION -#define XPutBackEvent XPUTBACKEVENT -#define XPutImage XPUTIMAGE -#define XQLength XQLENGTH -#define XQueryBestCursor XQUERYBESTCURSOR -#define XQueryBestStipple XQUERYBESTSTIPPLE -#define XQueryColor XQUERYCOLOR -#define XQueryColors XQUERYCOLORS -#define XQueryDeviceState XQUERYDEVICESTATE -#define XQueryExtension XQUERYEXTENSION -#define XQueryFont XQUERYFONT -#define XQueryKeymap XQUERYKEYMAP -#define XQueryPointer XQUERYPOINTER -#define XQueryTree XQUERYTREE -#define XRaiseWindow XRAISEWINDOW -#define XReadBitmapFile XREADBITMAPFILE -#define XRecolorCursor XRECOLORCURSOR -#define XReconfigureWMWindow XRECONFIGUREWMWINDOW -#define XRectInRegion XRECTINREGION -#define XRefreshKeyboardMapping XREFRESHKEYBOARDMAPPING -#define XRemoveHosts XREMOVEHOSTS -#define XReparentWindow XREPARENTWINDOW -#define XResetScreenSaver XRESETSCREENSAVER -#define XResizeWindow XRESIZEWINDOW -#define XResourceManagerString XRESOURCEMANAGERSTRING -#define XRestackWindows XRESTACKWINDOWS -#define XRotateBuffers XROTATEBUFFERS -#define XRootWindow XROOTWINDOW -#define XRootWindowOfScreen XROOTWINDOWOFSCREEN -#define XSaveContext XSAVECONTEXT -#define XScreenNumberOfScreen XSCREENNUMBEROFSCREEN -#define XScreenOfDisplay XSCREENOFDISPLAY -#define XSelectAsyncEvent XSELECTASYNCEVENT -#define XSelectAsyncInput XSELECTASYNCINPUT -#define XSelectExtensionEvent XSELECTEXTENSIONEVENT -#define XSelectInput XSELECTINPUT -#define XSendEvent XSENDEVENT -#define XServerVendor XSERVERVENDOR -#define XSetArcMode XSETARCMODE -#define XSetBackground XSETBACKGROUND -#define XSetClassHint XSETCLASSHINT -#define XSetClipMask XSETCLIPMASK -#define XSetClipOrigin XSETCLIPORIGIN -#define XSetClipRectangles XSETCLIPRECTANGLES -#define XSetCloseDownMode XSETCLOSEDOWNMODE -#define XSetCommand XSETCOMMAND -#define XSetDashes XSETDASHES -#define XSetErrorHandler XSETERRORHANDLER -#define XSetFillRule XSETFILLRULE -#define XSetFillStyle XSETFILLSTYLE -#define XSetFont XSETFONT -#define XSetForeground XSETFOREGROUND -#define XSetFunction XSETFUNCTION -#define XSetGraphicsExposures XSETGRAPHICSEXPOSURES -#define XSetICFocus XSETICFOCUS -#define XSetICValues XSETICVALUES -#define XSetIOErrorHandler XSETIOERRORHANDLER -#define XSetIconName XSETICONNAME -#define XSetInputFocus XSETINPUTFOCUS -#define XSetLineAttributes XSETLINEATTRIBUTES -#define XSetLocaleModifiers XSETLOCALEMODIFIERS -#define XSetNormalHints XSETNORMALHINTS -#define XSetPlaneMask XSETPLANEMASK -#define XSetRegion XSETREGION -#define XSetRGBColormaps XSETRGBCOLORMAPS -#define XSetScreenSaver XSETSCREENSAVER -#define XSetSelectionOwner XSETSELECTIONOWNER -#define XSetStandardProperties XSETSTANDARDPROPERTIES -#define XSetState XSETSTATE -#define XSetStipple XSETSTIPPLE -#define XSetSubwindowMode XSETSUBWINDOWMODE -#define XSetTSOrigin XSETTSORIGIN -#define XSetTextProperty XSETTEXTPROPERTY -#define XSetTile XSETTILE -#define XSetTransientForHint XSETTRANSIENTFORHINT -#define XSetWMClientMachine XSETWMCLIENTMACHINE -#define XSetWMColormapWindows XSETWMCOLORMAPWINDOWS -#define XSetWMHints XSETWMHINTS -#define XSetWMIconName XSETWMICONNAME -#define XSetWMName XSETWMNAME -#define XSetWMNormalHints XSETWMNORMALHINTS -#define XSetWMProperties XSETWMPROPERTIES -#define XSetWMProtocols XSETWMPROTOCOLS -#define XSetWMSizeHints XSETWMSIZEHINTS -#define XSetWindowBackground XSETWINDOWBACKGROUND -#define XSetWindowBackgroundPixmap XSETWINDOWBACKGROUNDPIXMAP -#define XSetWindowBorder XSETWINDOWBORDER -#define XSetWindowBorderPixmap XSETWINDOWBORDERPIXMAP -#define XSetWindowBorderWidth XSETWINDOWBORDERWIDTH -#define XSetWindowColormap XSETWINDOWCOLORMAP -#define XShapeCombineMask XSHAPECOMBINEMASK -#define XShapeCombineRectangles XSHAPECOMBINERECTANGLES -#define XShapeGetRectangles XSHAPEGETRECTANGLES -#define XShapeQueryExtension XSHAPEQUERYEXTENSION -#define XShmAttach XSHMATTACH -#define XShmCreateImage XSHMCREATEIMAGE -#define XShmCreatePixmap XSHMCREATEPIXMAP -#define XShmDetach XSHMDETACH -#define XShmGetEventBase XSHMGETEVENTBASE -#define XShmPutImage XSHMPUTIMAGE -#define XShmQueryExtension XSHMQUERYEXTENSION -#define XShmQueryVersion XSHMQUERYVERSION -#define XShrinkRegion XSHRINKREGION -#define XStoreBuffer XSTOREBUFFER -#define XStoreBytes XSTOREBYTES -#define XStoreColor XSTORECOLOR -#define XStoreColors XSTORECOLORS -#define XStoreName XSTORENAME -#define XStringListToTextProperty XSTRINGLISTTOTEXTPROPERTY -#define XStringToKeysym XSTRINGTOKEYSYM -#define XSubtractRegion XSUBTRACTREGION -#define XSupportsLocale XSUPPORTSLOCALE -#define XSync XSYNC -#define XSynchronize XSYNCHRONIZE -#define XTextExtents XTEXTEXTENTS -#define XTextExtents16 XTEXTEXTENTS16 -#define XTextPropertyToStringList XTEXTPROPERTYTOSTRINGLIST -#define XTextWidth XTEXTWIDTH -#define XTextWidth16 XTEXTWIDTH16 -#define XTranslateCoordinates XTRANSLATECOORDINATES -#define XUndefineCursor XUNDEFINECURSOR -#define XUngrabButton XUNGRABBUTTON -#define XUngrabKeyboard XUNGRABKEYBOARD -#define XUngrabPointer XUNGRABPOINTER -#define XUngrabServer XUNGRABSERVER -#define XUninstallColormap XUNINSTALLCOLORMAP -#define XUnionRectWithRegion XUNIONRECTWITHREGION -#define XUnionRegion XUNIONREGION -#define XUniqueContext XUNIQUECONTEXT -#define XUnmapWindow XUNMAPWINDOW -#define XUnsetICFocus XUNSETICFOCUS -#define XVaCreateNestedList XVACREATENESTEDLIST -#define XVisualIDFromVisual XVISUALIDFROMVISUAL -#define XWMGeometry XWMGEOMETRY -#define XWarpPointer XWARPPOINTER -#define XWhitePixel XWHITEPIXEL -#define XWhitePixelOfScreen XWHITEPIXELOFSCREEN -#define XWidthMMOfScreen XWIDTHMMOFSCREEN -#define XWidthOfScreen XWIDTHOFSCREEN -#define XWindowEvent XWINDOWEVENT -#define XWithdrawWindow XWITHDRAWWINDOW -#define XXorRegion XXORREGION -#define XcmsQueryColor XCMSQUERYCOLOR -#define XdbeAllocateBackBufferName XDBEALLOCATEBACKBUFFERNAME -#define XdbeFreeVisualInfo XDBEFREEVISUALINFO -#define XdbeGetVisualInfo XDBEGETVISUALINFO -#define XdbeQueryExtension XDBEQUERYEXTENSION -#define XdbeSwapBuffers XDBESWAPBUFFERS -#define XextAddDisplay XEXTADDDISPLAY -#define XextFindDisplay XEXTFINDDISPLAY -#define XextRemoveDisplay XEXTREMOVEDISPLAY -#define XkbSetDetectableAutoRepeat XKBSETDETECTABLEAUTOREPEAT -#define XmActivateProtocol XMACTIVATEPROTOCOL -#define XmAddProtocolCallback XMADDPROTOCOLCALLBACK -#define XmAddProtocols XMADDPROTOCOLS -#define XmChangeColor XMCHANGECOLOR -#define XmClipboardCopy XMCLIPBOARDCOPY -#define XmClipboardCopyByName XMCLIPBOARDCOPYBYNAME -#define XmClipboardEndCopy XMCLIPBOARDENDCOPY -#define XmClipboardEndRetrieve XMCLIPBOARDENDRETRIEVE -#define XmClipboardInquireCount XMCLIPBOARDINQUIRECOUNT -#define XmClipboardInquireFormat XMCLIPBOARDINQUIREFORMAT -#define XmClipboardInquireLength XMCLIPBOARDINQUIRELENGTH -#define XmClipboardLock XMCLIPBOARDLOCK -#define XmClipboardRetrieve XMCLIPBOARDRETRIEVE -#define XmClipboardStartCopy XMCLIPBOARDSTARTCOPY -#define XmClipboardStartRetrieve XMCLIPBOARDSTARTRETRIEVE -#define XmClipboardUnlock XMCLIPBOARDUNLOCK -#define XmCommandError XMCOMMANDERROR -#define XmCommandGetChild XMCOMMANDGETCHILD -#define XmCommandSetValue XMCOMMANDSETVALUE -#define XmCreateArrowButton XMCREATEARROWBUTTON -#define XmCreateArrowButtonGadget XMCREATEARROWBUTTONGADGET -#define XmCreateBulletinBoardDialog XMCREATEBULLETINBOARDDIALOG -#define XmCreateCascadeButton XMCREATECASCADEBUTTON -#define XmCreateCascadeButtonGadget XMCREATECASCADEBUTTONGADGET -#define XmCreateDialogShell XMCREATEDIALOGSHELL -#define XmCreateDragIcon XMCREATEDRAGICON -#define XmCreateDrawingArea XMCREATEDRAWINGAREA -#define XmCreateDrawnButton XMCREATEDRAWNBUTTON -#define XmCreateErrorDialog XMCREATEERRORDIALOG -#define XmCreateFileSelectionBox XMCREATEFILESELECTIONBOX -#define XmCreateFileSelectionDialog XMCREATEFILESELECTIONDIALOG -#define XmCreateForm XMCREATEFORM -#define XmCreateFormDialog XMCREATEFORMDIALOG -#define XmCreateFrame XMCREATEFRAME -#define XmCreateInformationDialog XMCREATEINFORMATIONDIALOG -#define XmCreateLabel XMCREATELABEL -#define XmCreateLabelGadget XMCREATELABELGADGET -#define XmCreateList XMCREATELIST -#define XmCreateMainWindow XMCREATEMAINWINDOW -#define XmCreateMenuBar XMCREATEMENUBAR -#define XmCreateMessageBox XMCREATEMESSAGEBOX -#define XmCreateMessageDialog XMCREATEMESSAGEDIALOG -#define XmCreateOptionMenu XMCREATEOPTIONMENU -#define XmCreatePanedWindow XMCREATEPANEDWINDOW -#define XmCreatePopupMenu XMCREATEPOPUPMENU -#define XmCreatePromptDialog XMCREATEPROMPTDIALOG -#define XmCreatePulldownMenu XMCREATEPULLDOWNMENU -#define XmCreatePushButton XMCREATEPUSHBUTTON -#define XmCreatePushButtonGadget XMCREATEPUSHBUTTONGADGET -#define XmCreateQuestionDialog XMCREATEQUESTIONDIALOG -#define XmCreateRadioBox XMCREATERADIOBOX -#define XmCreateRowColumn XMCREATEROWCOLUMN -#define XmCreateScale XMCREATESCALE -#define XmCreateScrollBar XMCREATESCROLLBAR -#define XmCreateScrolledList XMCREATESCROLLEDLIST -#define XmCreateScrolledText XMCREATESCROLLEDTEXT -#define XmCreateScrolledWindow XMCREATESCROLLEDWINDOW -#define XmCreateSelectionDialog XMCREATESELECTIONDIALOG -#define XmCreateSeparator XMCREATESEPARATOR -#define XmCreateSeparatorGadget XMCREATESEPARATORGADGET -#define XmCreateTemplateDialog XMCREATETEMPLATEDIALOG -#define XmCreateText XMCREATETEXT -#define XmCreateTextField XMCREATETEXTFIELD -#define XmCreateToggleButton XMCREATETOGGLEBUTTON -#define XmCreateToggleButtonGadget XMCREATETOGGLEBUTTONGADGET -#define XmCreateWarningDialog XMCREATEWARNINGDIALOG -#define XmCvtCTToXmString XMCVTCTTOXMSTRING -#define XmDestroyPixmap XMDESTROYPIXMAP -#define XmDragStart XMDRAGSTART -#define XmDropSiteRegister XMDROPSITEREGISTER -#define XmDropSiteUnregister XMDROPSITEUNREGISTER -#define XmDropSiteUpdate XMDROPSITEUPDATE -#define XmDropTransferStart XMDROPTRANSFERSTART -#define XmFileSelectionBoxGetChild XMFILESELECTIONBOXGETCHILD -#define XmFileSelectionDoSearch XMFILESELECTIONDOSEARCH -#define XmFontListAppendEntry XMFONTLISTAPPENDENTRY -#define XmFontListCopy XMFONTLISTCOPY -#define XmFontListCreate XMFONTLISTCREATE -#define XmFontListEntryCreate XMFONTLISTENTRYCREATE -#define XmFontListEntryFree XMFONTLISTENTRYFREE -#define XmFontListEntryGetFont XMFONTLISTENTRYGETFONT -#define XmFontListEntryGetTag XMFONTLISTENTRYGETTAG -#define XmFontListEntryLoad XMFONTLISTENTRYLOAD -#define XmFontListFree XMFONTLISTFREE -#define XmFontListFreeFontContext XMFONTLISTFREEFONTCONTEXT -#define XmFontListGetNextFont XMFONTLISTGETNEXTFONT -#define XmFontListInitFontContext XMFONTLISTINITFONTCONTEXT -#define XmFontListNextEntry XMFONTLISTNEXTENTRY -#define XmGetColors XMGETCOLORS -#define XmGetColorCalculation XMGETCOLORCALCULATION -#define XmGetFocusWidget XMGETFOCUSWIDGET -#define XmGetMenuCursor XMGETMENUCURSOR -#define XmGetPixmap XMGETPIXMAP -#define XmGetPixmapByDepth XMGETPIXMAPBYDEPTH -#define XmGetTearOffControl XMGETTEAROFFCONTROL -#define XmGetXmDisplay XMGETXMDISPLAY -#define XmImMbLookupString XMIMMBLOOKUPSTRING -#define XmImRegister XMIMREGISTER -#define XmImSetFocusValues XMIMSETFOCUSVALUES -#define XmImSetValues XMIMSETVALUES -#define XmImUnregister XMIMUNREGISTER -#define XmImUnsetFocus XMIMUNSETFOCUS -#define XmInstallImage XMINSTALLIMAGE -#define XmInternAtom XMINTERNATOM -#define XmIsMotifWMRunning XMISMOTIFWMRUNNING -#define XmListAddItem XMLISTADDITEM -#define XmListAddItemUnselected XMLISTADDITEMUNSELECTED -#define XmListAddItems XMLISTADDITEMS -#define XmListAddItemsUnselected XMLISTADDITEMSUNSELECTED -#define XmListDeleteAllItems XMLISTDELETEALLITEMS -#define XmListDeleteItem XMLISTDELETEITEM -#define XmListDeleteItemsPos XMLISTDELETEITEMSPOS -#define XmListDeletePos XMLISTDELETEPOS -#define XmListDeselectAllItems XMLISTDESELECTALLITEMS -#define XmListDeselectPos XMLISTDESELECTPOS -#define XmListGetKbdItemPos XMLISTGETKBDITEMPOS -#define XmListGetMatchPos XMLISTGETMATCHPOS -#define XmListGetSelectedPos XMLISTGETSELECTEDPOS -#define XmListItemExists XMLISTITEMEXISTS -#define XmListItemPos XMLISTITEMPOS -#define XmListPosSelected XMLISTPOSSELECTED -#define XmListReplaceItems XMLISTREPLACEITEMS -#define XmListReplaceItemsPos XMLISTREPLACEITEMSPOS -#define XmListSelectItem XMLISTSELECTITEM -#define XmListSelectPos XMLISTSELECTPOS -#define XmListSetBottomPos XMLISTSETBOTTOMPOS -#define XmListSetItem XMLISTSETITEM -#define XmListSetKbdItemPos XMLISTSETKBDITEMPOS -#define XmListSetPos XMLISTSETPOS -#define XmMainWindowSetAreas XMMAINWINDOWSETAREAS -#define XmMenuPosition XMMENUPOSITION -#define XmMessageBoxGetChild XMMESSAGEBOXGETCHILD -#define XmOptionButtonGadget XMOPTIONBUTTONGADGET -#define XmOptionLabelGadget XMOPTIONLABELGADGET -#define XmProcessTraversal XMPROCESSTRAVERSAL -#define XmQmotif XMQMOTIF -#define XmRemoveProtocolCallback XMREMOVEPROTOCOLCALLBACK -#define XmRemoveProtocols XMREMOVEPROTOCOLS -#define XmRemoveTabGroup XMREMOVETABGROUP -#define XmRepTypeGetId XMREPTYPEGETID -#define XmRepTypeGetRecord XMREPTYPEGETRECORD -#define XmRepTypeInstallTearOffModelCon XMREPTYPEINSTALLTEAROFFMODELCON -#define XmRepTypeRegister XMREPTYPEREGISTER -#define XmRepTypeValidValue XMREPTYPEVALIDVALUE -#define XmScrollBarGetValues XMSCROLLBARGETVALUES -#define XmScrollBarSetValues XMSCROLLBARSETVALUES -#define XmScrolledWindowSetAreas XMSCROLLEDWINDOWSETAREAS -#define XmSelectionBoxGetChild XMSELECTIONBOXGETCHILD -#define XmSetColorCalculation XMSETCOLORCALCULATION -#define XmStringByteCompare XMSTRINGBYTECOMPARE -#define XmStringCompare XMSTRINGCOMPARE -#define XmStringConcat XMSTRINGCONCAT -#define XmStringCopy XMSTRINGCOPY -#define XmStringCreate XMSTRINGCREATE -#define XmStringCreateLocalized XMSTRINGCREATELOCALIZED -#define XmStringCreateLtoR XMSTRINGCREATELTOR -#define XmStringCreateSimple XMSTRINGCREATESIMPLE -#define XmStringDraw XMSTRINGDRAW -#define XmStringDrawUnderline XMSTRINGDRAWUNDERLINE -#define XmStringExtent XMSTRINGEXTENT -#define XmStringFree XMSTRINGFREE -#define XmStringFreeContext XMSTRINGFREECONTEXT -#define XmStringGetLtoR XMSTRINGGETLTOR -#define XmStringGetNextComponent XMSTRINGGETNEXTCOMPONENT -#define XmStringGetNextSegment XMSTRINGGETNEXTSEGMENT -#define XmStringInitContext XMSTRINGINITCONTEXT -#define XmStringLength XMSTRINGLENGTH -#define XmStringLtoRCreate XMSTRINGLTORCREATE -#define XmStringNConcat XMSTRINGNCONCAT -#define XmStringSegmentCreate XMSTRINGSEGMENTCREATE -#define XmStringSeparatorCreate XMSTRINGSEPARATORCREATE -#define XmStringWidth XMSTRINGWIDTH -#define XmTextClearSelection XMTEXTCLEARSELECTION -#define XmTextCopy XMTEXTCOPY -#define XmTextCut XMTEXTCUT -#define XmTextFieldClearSelection XMTEXTFIELDCLEARSELECTION -#define XmTextFieldCopy XMTEXTFIELDCOPY -#define XmTextFieldCut XMTEXTFIELDCUT -#define XmTextFieldGetEditable XMTEXTFIELDGETEDITABLE -#define XmTextFieldGetInsertionPosition XMTEXTFIELDGETINSERTIONPOSITION -#define XmTextFieldGetLastPosition XMTEXTFIELDGETLASTPOSITION -#define XmTextFieldGetMaxLength XMTEXTFIELDGETMAXLENGTH -#define XmTextFieldGetSelection XMTEXTFIELDGETSELECTION -#define XmTextFieldGetSelectionPosition XMTEXTFIELDGETSELECTIONPOSITION -#define XmTextFieldGetString XMTEXTFIELDGETSTRING -#define XmTextFieldInsert XMTEXTFIELDINSERT -#define XmTextFieldPaste XMTEXTFIELDPASTE -#define XmTextFieldRemove XMTEXTFIELDREMOVE -#define XmTextFieldReplace XMTEXTFIELDREPLACE -#define XmTextFieldSetAddMode XMTEXTFIELDSETADDMODE -#define XmTextFieldSetHighlight XMTEXTFIELDSETHIGHLIGHT -#define XmTextFieldSetInsertionPosition XMTEXTFIELDSETINSERTIONPOSITION -#define XmTextFieldSetMaxLength XMTEXTFIELDSETMAXLENGTH -#define XmTextFieldSetSelection XMTEXTFIELDSETSELECTION -#define XmTextFieldSetString XMTEXTFIELDSETSTRING -#define XmTextFieldShowPosition XMTEXTFIELDSHOWPOSITION -#define XmTextGetCursorPosition XMTEXTGETCURSORPOSITION -#define XmTextGetEditable XMTEXTGETEDITABLE -#define XmTextGetInsertionPosition XMTEXTGETINSERTIONPOSITION -#define XmTextGetLastPosition XMTEXTGETLASTPOSITION -#define XmTextGetMaxLength XMTEXTGETMAXLENGTH -#define XmTextGetSelection XMTEXTGETSELECTION -#define XmTextGetSelectionPosition XMTEXTGETSELECTIONPOSITION -#define XmTextGetString XMTEXTGETSTRING -#define XmTextInsert XMTEXTINSERT -#define XmTextPaste XMTEXTPASTE -#define XmTextPosToXY XMTEXTPOSTOXY -#define XmTextRemove XMTEXTREMOVE -#define XmTextReplace XMTEXTREPLACE -#define XmTextSetCursorPosition XMTEXTSETCURSORPOSITION -#define XmTextSetEditable XMTEXTSETEDITABLE -#define XmTextSetHighlight XMTEXTSETHIGHLIGHT -#define XmTextSetInsertionPosition XMTEXTSETINSERTIONPOSITION -#define XmTextSetSelection XMTEXTSETSELECTION -#define XmTextSetString XMTEXTSETSTRING -#define XmTextSetTopCharacter XMTEXTSETTOPCHARACTER -#define XmTextShowPosition XMTEXTSHOWPOSITION -#define XmToggleButtonGadgetGetState XMTOGGLEBUTTONGADGETGETSTATE -#define XmToggleButtonGadgetSetState XMTOGGLEBUTTONGADGETSETSTATE -#define XmToggleButtonGetState XMTOGGLEBUTTONGETSTATE -#define XmToggleButtonSetState XMTOGGLEBUTTONSETSTATE -#define XmUninstallImage XMUNINSTALLIMAGE -#define XmUpdateDisplay XMUPDATEDISPLAY -#define XmVaCreateSimpleRadioBox XMVACREATESIMPLERADIOBOX -#define XmbDrawString XMBDRAWSTRING -#define XmbLookupString XMBLOOKUPSTRING -#define XmbResetIC XMBRESETIC -#define XmbSetWMProperties XMBSETWMPROPERTIES -#define XmbTextEscapement XMBTEXTESCAPEMENT -#define XmbTextExtents XMBTEXTEXTENTS -#define XmbTextListToTextProperty XMBTEXTLISTTOTEXTPROPERTY -#define XmbTextPropertyToTextList XMBTEXTPROPERTYTOTEXTLIST -#define XmbufCreateBuffers XMBUFCREATEBUFFERS -#define XmbufDestroyBuffers XMBUFDESTROYBUFFERS -#define XmbufDisplayBuffers XMBUFDISPLAYBUFFERS -#define XmbufQueryExtension XMBUFQUERYEXTENSION -#define Xmemory_free XMEMORY_FREE -#define Xmemory_malloc XMEMORY_MALLOC -#define XmuClientWindow XMUCLIENTWINDOW -#define XmuConvertStandardSelection XMUCONVERTSTANDARDSELECTION -#define XmuCvtStringToBitmap XMUCVTSTRINGTOBITMAP -#define XmuInternAtom XMUINTERNATOM -#define XmuInternStrings XMUINTERNSTRINGS -#define XmuLookupStandardColormap XMULOOKUPSTANDARDCOLORMAP -#define XmuPrintDefaultErrorMessage XMUPRINTDEFAULTERRORMESSAGE -#define XrmCombineDatabase XRMCOMBINEDATABASE -#define XrmCombineFileDatabase XRMCOMBINEFILEDATABASE -#define XrmDestroyDatabase XRMDESTROYDATABASE -#define XrmGetDatabase XRMGETDATABASE -#define XrmGetFileDatabase XRMGETFILEDATABASE -#define XrmGetResource XRMGETRESOURCE -#define XrmGetStringDatabase XRMGETSTRINGDATABASE -#define XrmInitialize XRMINITIALIZE -#define XrmMergeDatabases XRMMERGEDATABASES -#define XrmParseCommand XRMPARSECOMMAND -#define XrmPermStringToQuark XRMPERMSTRINGTOQUARK -#define XrmPutFileDatabase XRMPUTFILEDATABASE -#define XrmPutLineResource XRMPUTLINERESOURCE -#define XrmPutStringResource XRMPUTSTRINGRESOURCE -#define XrmQGetResource XRMQGETRESOURCE -#define XrmQPutStringResource XRMQPUTSTRINGRESOURCE -#define XrmQuarkToString XRMQUARKTOSTRING -#define XrmSetDatabase XRMSETDATABASE -#define XrmStringToBindingQuarkList XRMSTRINGTOBINDINGQUARKLIST -#define XrmStringToQuark XRMSTRINGTOQUARK -#define XtAddCallback XTADDCALLBACK -#define XtAddCallbacks XTADDCALLBACKS -#define XtAddConverter XTADDCONVERTER -#define XtAddEventHandler XTADDEVENTHANDLER -#define XtAddExposureToRegion XTADDEXPOSURETOREGION -#define XtAddGrab XTADDGRAB -#define XtAddRawEventHandler XTADDRAWEVENTHANDLER -#define XtAllocateGC XTALLOCATEGC -#define XtAppAddActions XTAPPADDACTIONS -#define XtAppAddInput XTAPPADDINPUT -#define XtAppAddTimeOut XTAPPADDTIMEOUT -#define XtAppAddWorkProc XTAPPADDWORKPROC -#define XtAppCreateShell XTAPPCREATESHELL -#define XtAppError XTAPPERROR -#define XtAppErrorMsg XTAPPERRORMSG -#define XtAppInitialize XTAPPINITIALIZE -#define XtAppMainLoop XTAPPMAINLOOP -#define XtAppNextEvent XTAPPNEXTEVENT -#define XtAppPeekEvent XTAPPPEEKEVENT -#define XtAppPending XTAPPPENDING -#define XtAppProcessEvent XTAPPPROCESSEVENT -#define XtAppSetErrorHandler XTAPPSETERRORHANDLER -#define XtAppSetFallbackResources XTAPPSETFALLBACKRESOURCES -#define XtAppSetTypeConverter XTAPPSETTYPECONVERTER -#define XtAppSetWarningHandler XTAPPSETWARNINGHANDLER -#define XtAppWarningMsg XTAPPWARNINGMSG -#define XtAppSetWarningMsgHandler XTAPPSETWARNINGMSGHANDLER -#define XtAppWarning XTAPPWARNING -#define XtAugmentTranslations XTAUGMENTTRANSLATIONS -#define XtCallActionProc XTCALLACTIONPROC -#define XtCallCallbackList XTCALLCALLBACKLIST -#define XtCallCallbacks XTCALLCALLBACKS -#define XtCallConverter XTCALLCONVERTER -#define XtCalloc XTCALLOC -#ifndef NOXTDISPLAY -#define XtClass XTCLASS -#endif -#define XtCloseDisplay XTCLOSEDISPLAY -#define XtConfigureWidget XTCONFIGUREWIDGET -#define XtConvert XTCONVERT -#define XtConvertAndStore XTCONVERTANDSTORE -#define XtCreateApplicationContext XTCREATEAPPLICATIONCONTEXT -#define XtCreateManagedWidget XTCREATEMANAGEDWIDGET -#define XtCreatePopupShell XTCREATEPOPUPSHELL -#define XtCreateWidget XTCREATEWIDGET -#define XtCreateWindow XTCREATEWINDOW -#define XtCvtStringToFont XTCVTSTRINGTOFONT -#define XtDatabase XTDATABASE -#define XtDestroyApplicationContext XTDESTROYAPPLICATIONCONTEXT -#define XtDestroyWidget XTDESTROYWIDGET -#define XtDisownSelection XTDISOWNSELECTION -#define XtDispatchEvent XTDISPATCHEVENT -#ifndef NOXTDISPLAY -#define XtDisplay XTDISPLAY -#endif -#define XtDisplayOfObject XTDISPLAYOFOBJECT -#define XtDisplayStringConvWarning XTDISPLAYSTRINGCONVWARNING -#define XtDisplayToApplicationContext XTDISPLAYTOAPPLICATIONCONTEXT -#define XtError XTERROR -#define XtErrorMsg XTERRORMSG -#define XtFree XTFREE -#define XtGetActionKeysym XTGETACTIONKEYSYM -#define XtGetActionList XTGETACTIONLIST -#define XtGetApplicationNameAndClass XTGETAPPLICATIONNAMEANDCLASS -#define XtGetApplicationResources XTGETAPPLICATIONRESOURCES -#define XtGetClassExtension XTGETCLASSEXTENSION -#define XtGetConstraintResourceList XTGETCONSTRAINTRESOURCELIST -#define XtGetGC XTGETGC -#define XtGetMultiClickTime XTGETMULTICLICKTIME -#define XtGetResourceList XTGETRESOURCELIST -#define XtGetSelectionValue XTGETSELECTIONVALUE -#define XtGetSelectionValues XTGETSELECTIONVALUES -#define XtGetSubresources XTGETSUBRESOURCES -#define XtGetValues XTGETVALUES -#define XtGrabButton XTGRABBUTTON -#define XtGrabKeyboard XTGRABKEYBOARD -#define XtGrabPointer XTGRABPOINTER -#define XtHasCallbacks XTHASCALLBACKS -#define XtInitialize XTINITIALIZE -#define XtInitializeWidgetClass XTINITIALIZEWIDGETCLASS -#define XtInsertEventHandler XTINSERTEVENTHANDLER -#define XtInsertRawEventHandler XTINSERTRAWEVENTHANDLER -#define XtInstallAccelerators XTINSTALLACCELERATORS -#define XtIsManaged XTISMANAGED -#define XtIsObject XTISOBJECT -#ifndef NOXTDISPLAY -#define XtIsRealized XTISREALIZED -#endif -#define XtIsSensitive XTISSENSITIVE -#define XtIsSubclass XTISSUBCLASS -#define XtLastTimestampProcessed XTLASTTIMESTAMPPROCESSED -#define XtMainLoop XTMAINLOOP -#define XtMakeGeometryRequest XTMAKEGEOMETRYREQUEST -#define XtMakeResizeRequest XTMAKERESIZEREQUEST -#define XtMalloc XTMALLOC -#define XtManageChild XTMANAGECHILD -#define XtManageChildren XTMANAGECHILDREN -#define XtMergeArgLists XTMERGEARGLISTS -#define XtMoveWidget XTMOVEWIDGET -#define XtName XTNAME -#define XtNameToWidget XTNAMETOWIDGET -#define XtOpenApplication XTOPENAPPLICATION -#define XtOpenDisplay XTOPENDISPLAY -#define XtOverrideTranslations XTOVERRIDETRANSLATIONS -#define XtOwnSelection XTOWNSELECTION -#ifndef NOXTDISPLAY -#define XtParent XTPARENT -#endif -#define XtParseAcceleratorTable XTPARSEACCELERATORTABLE -#define XtParseTranslationTable XTPARSETRANSLATIONTABLE -#define XtPopdown XTPOPDOWN -#define XtPopup XTPOPUP -#define XtPopupSpringLoaded XTPOPUPSPRINGLOADED -#define XtQueryGeometry XTQUERYGEOMETRY -#define XtRealizeWidget XTREALIZEWIDGET -#define XtRealloc XTREALLOC -#define XtRegisterDrawable _XTREGISTERWINDOW -#define XtRegisterGrabAction XTREGISTERGRABACTION -#define XtReleaseGC XTRELEASEGC -#define XtRemoveAllCallbacks XTREMOVEALLCALLBACKS -#define XtRemoveCallback XTREMOVECALLBACK -#define XtRemoveEventHandler XTREMOVEEVENTHANDLER -#define XtRemoveGrab XTREMOVEGRAB -#define XtRemoveInput XTREMOVEINPUT -#define XtRemoveTimeOut XTREMOVETIMEOUT -#define XtRemoveWorkProc XTREMOVEWORKPROC -#define XtResizeWidget XTRESIZEWIDGET -#define XtResolvePathname XTRESOLVEPATHNAME -#ifndef NOXTDISPLAY -#define XtScreen XTSCREEN -#endif -#define XtScreenDatabase XTSCREENDATABASE -#define XtScreenOfObject XTSCREENOFOBJECT -#define XtSessionReturnToken XTSESSIONRETURNTOKEN -#define XtSetErrorHandler XTSETERRORHANDLER -#define XtSetKeyboardFocus XTSETKEYBOARDFOCUS -#define XtSetLanguageProc XTSETLANGUAGEPROC -#define XtSetMappedWhenManaged XTSETMAPPEDWHENMANAGED -#define XtSetSensitive XTSETSENSITIVE -#define XtSetTypeConverter XTSETTYPECONVERTER -#define XtSetValues XTSETVALUES -#define XtShellStrings XTSHELLSTRINGS -#define XtStringConversionWarning XTSTRINGCONVERSIONWARNING -#define XtStrings XTSTRINGS -#define XtToolkitInitialize XTTOOLKITINITIALIZE -#define XtTranslateCoords XTTRANSLATECOORDS -#define XtTranslateKeycode XTTRANSLATEKEYCODE -#define XtUngrabButton XTUNGRABBUTTON -#define XtUngrabKeyboard XTUNGRABKEYBOARD -#define XtUngrabPointer XTUNGRABPOINTER -#define XtUnmanageChild XTUNMANAGECHILD -#define XtUnmanageChildren XTUNMANAGECHILDREN -#define XtUnrealizeWidget XTUNREALIZEWIDGET -#define XtUnregisterDrawable _XTUNREGISTERWINDOW -#define XtVaCreateManagedWidget XTVACREATEMANAGEDWIDGET -#define XtVaCreatePopupShell XTVACREATEPOPUPSHELL -#define XtVaCreateWidget XTVACREATEWIDGET -#define XtVaGetApplicationResources XTVAGETAPPLICATIONRESOURCES -#define XtVaGetValues XTVAGETVALUES -#define XtVaSetValues XTVASETVALUES -#define XtWarning XTWARNING -#define XtWarningMsg XTWARNINGMSG -#define XtWidgetToApplicationContext XTWIDGETTOAPPLICATIONCONTEXT -#ifndef NOXTDISPLAY -#define XtWindow XTWINDOW -#endif -#define XtWindowOfObject XTWINDOWOFOBJECT -#define XtWindowToWidget XTWINDOWTOWIDGET -#define XwcDrawImageString XWCDRAWIMAGESTRING -#define XwcDrawString XWCDRAWSTRING -#define XwcFreeStringList XWCFREESTRINGLIST -#define XwcTextEscapement XWCTEXTESCAPEMENT -#define XwcTextExtents XWCTEXTEXTENTS -#define XwcTextListToTextProperty XWCTEXTLISTTOTEXTPROPERTY -#define XwcLookupString XWCLOOKUPSTRING -#define XwcTextPropertyToTextList XWCTEXTPROPERTYTOTEXTLIST -#define _XAllocTemp _XALLOCTEMP -#define _XDeqAsyncHandler _XDEQASYNCHANDLER -#define _XEatData _XEATDATA -#define _XFlush _XFLUSH -#define _XFreeTemp _XFREETEMP -#define _XGetAsyncReply _XGETASYNCREPLY -#define _XInitImageFuncPtrs _XINITIMAGEFUNCPTRS -#define _XRead _XREAD -#define _XReadPad _XREADPAD -#define _XRegisterFilterByType _XREGISTERFILTERBYTYPE -#define _XReply _XREPLY -#define _XSend _XSEND -#define _XUnregisterFilter _XUNREGISTERFILTER -#define _XVIDtoVisual _XVIDTOVISUAL -#define _XmBottomShadowColorDefault _XMBOTTOMSHADOWCOLORDEFAULT -#define _XmClearBorder _XMCLEARBORDER -#define _XmConfigureObject _XMCONFIGUREOBJECT -#define _XmDestroyParentCallback _XMDESTROYPARENTCALLBACK -#define _XmDrawArrow _XMDRAWARROW -#define _XmDrawShadows _XMDRAWSHADOWS -#define _XmFontListGetDefaultFont _XMFONTLISTGETDEFAULTFONT -#define _XmFromHorizontalPixels _XMFROMHORIZONTALPIXELS -#define _XmFromVerticalPixels _XMFROMVERTICALPIXELS -#define _XmGetClassExtensionPtr _XMGETCLASSEXTENSIONPTR -#define _XmGetDefaultFontList _XMGETDEFAULTFONTLIST -#define _XmGetTextualDragIcon _XMGETTEXTUALDRAGICON -#define _XmGetWidgetExtData _XMGETWIDGETEXTDATA -#define _XmGrabKeyboard _XMGRABKEYBOARD -#define _XmGrabPointer _XMGRABPOINTER -#define _XmInheritClass _XMINHERITCLASS -#define _XmInputForGadget _XMINPUTFORGADGET -#define _XmInputInGadget _XMINPUTINGADGET -#define _XmMakeGeometryRequest _XMMAKEGEOMETRYREQUEST -#define _XmMenuPopDown _XMMENUPOPDOWN -#define _XmMoveObject _XMMOVEOBJECT -#define _XmNavigChangeManaged _XMNAVIGCHANGEMANAGED -#define _XmOSBuildFileList _XMOSBUILDFILELIST -#define _XmOSFileCompare _XMOSFILECOMPARE -#define _XmOSFindPatternPart _XMOSFINDPATTERNPART -#define _XmOSQualifyFileSpec _XMOSQUALIFYFILESPEC -#define _XmPostPopupMenu _XMPOSTPOPUPMENU -#define _XmPrimitiveEnter _XMPRIMITIVEENTER -#define _XmPrimitiveLeave _XMPRIMITIVELEAVE -#define _XmRedisplayGadgets _XMREDISPLAYGADGETS -#define _XmShellIsExclusive _XMSHELLISEXCLUSIVE -#define _XmStringDraw _XMSTRINGDRAW -#define _XmStringGetTextConcat _XMSTRINGGETTEXTCONCAT -#define _XmStrings _XMSTRINGS -#define _XmToHorizontalPixels _XMTOHORIZONTALPIXELS -#define _XmToVerticalPixels _XMTOVERTICALPIXELS -#define _XmTopShadowColorDefault _XMTOPSHADOWCOLORDEFAULT -#define _Xm_fastPtr _XM_FASTPTR -#define _XtCheckSubclassFlag _XTCHECKSUBCLASSFLAG -#define _XtCopyFromArg _XTCOPYFROMARG -#define _XtCountVaList _XTCOUNTVALIST -#define _XtInherit _XTINHERIT -#define _XtInheritTranslations _XTINHERITTRANSLATIONS -#define _XtIsSubclassOf _XTISSUBCLASSOF -#define _XtVaToArgList _XTVATOARGLIST -#define applicationShellWidgetClass APPLICATIONSHELLWIDGETCLASS -#define cli$dcl_parse CLI$DCL_PARSE -#define cli$get_value CLI$GET_VALUE -#define cli$present CLI$PRESENT -#define compositeClassRec COMPOSITECLASSREC -#define compositeWidgetClass COMPOSITEWIDGETCLASS -#define constraintClassRec CONSTRAINTCLASSREC -#define constraintWidgetClass CONSTRAINTWIDGETCLASS -#define coreWidgetClass COREWIDGETCLASS -#define exe$getspi EXE$GETSPI -#define lbr$close LBR$CLOSE -#define lbr$get_header LBR$GET_HEADER -#define lbr$get_index LBR$GET_INDEX -#define lbr$get_record LBR$GET_RECORD -#define lbr$ini_control LBR$INI_CONTROL -#define lbr$lookup_key LBR$LOOKUP_KEY -#define lbr$open LBR$OPEN -#define lbr$output_help LBR$OUTPUT_HELP -#define lib$add_times LIB$ADD_TIMES -#define lib$addx LIB$ADDX -#define lib$create_dir LIB$CREATE_DIR -#define lib$create_vm_zone LIB$CREATE_VM_ZONE -#define lib$cvt_from_internal_time LIB$CVT_FROM_INTERNAL_TIME -#define lib$cvt_htb LIB$CVT_HTB -#define lib$cvt_vectim LIB$CVT_VECTIM -#define lib$day LIB$DAY -#define lib$day_of_week LIB$DAY_OF_WEEK -#define lib$delete_symbol LIB$DELETE_SYMBOL -#define lib$delete_vm_zone LIB$DELETE_VM_ZONE -#define lib$disable_ctrl LIB$DISABLE_CTRL -#define lib$ediv LIB$EDIV -#define lib$emul LIB$EMUL -#define lib$enable_ctrl LIB$ENABLE_CTRL -#define lib$find_vm_zone LIB$FIND_VM_ZONE -#define lib$format_date_time LIB$FORMAT_DATE_TIME -#define lib$free_timer LIB$FREE_TIMER -#define lib$free_vm LIB$FREE_VM -#define lib$get_ef LIB$GET_EF -#define lib$get_foreign LIB$GET_FOREIGN -#define lib$get_input LIB$GET_INPUT -#define lib$get_users_language LIB$GET_USERS_LANGUAGE -#define lib$get_vm LIB$GET_VM -#define lib$get_symbol LIB$GET_SYMBOL -#define lib$getdvi LIB$GETDVI -#define lib$init_date_time_context LIB$INIT_DATE_TIME_CONTEXT -#define lib$init_timer LIB$INIT_TIMER -#define lib$find_file LIB$FIND_FILE -#define lib$find_file_end LIB$FIND_FILE_END -#define lib$find_image_symbol LIB$FIND_IMAGE_SYMBOL -#define lib$mult_delta_time LIB$MULT_DELTA_TIME -#define lib$put_output LIB$PUT_OUTPUT -#define lib$rename_file LIB$RENAME_FILE -#define lib$reset_vm_zone LIB$RESET_VM_ZONE -#define lib$set_symbol LIB$SET_SYMBOL -#define lib$sfree1_dd LIB$SFREE1_DD -#define lib$show_vm LIB$SHOW_VM -#define lib$show_vm_zone LIB$SHOW_VM_ZONE -#define lib$spawn LIB$SPAWN -#define lib$stat_timer LIB$STAT_TIMER -#define lib$subx LIB$SUBX -#define lib$sub_times LIB$SUB_TIMES -#define lib$wait LIB$WAIT -#define mail$send_add_address MAIL$SEND_ADD_ADDRESS -#define mail$send_add_attribute MAIL$SEND_ADD_ATTRIBUTE -#define mail$send_add_bodypart MAIL$SEND_ADD_BODYPART -#define mail$send_begin MAIL$SEND_BEGIN -#define mail$send_end MAIL$SEND_END -#define mail$send_message MAIL$SEND_MESSAGE -#define ncs$convert NCS$CONVERT -#define ncs$get_cf NCS$GET_CF -#define objectClass OBJECTCLASS -#define objectClassRec OBJECTCLASSREC -#define overrideShellClassRec OVERRIDESHELLCLASSREC -#define overrideShellWidgetClass OVERRIDESHELLWIDGETCLASS -#define pthread_attr_create PTHREAD_ATTR_CREATE -#define pthread_attr_delete PTHREAD_ATTR_DELETE -#define pthread_attr_destroy PTHREAD_ATTR_DESTROY -#define pthread_attr_getdetach_np PTHREAD_ATTR_GETDETACH_NP -#define pthread_attr_getguardsize_np PTHREAD_ATTR_GETGUARDSIZE_NP -#define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED -#define pthread_attr_getprio PTHREAD_ATTR_GETPRIO -#define pthread_attr_getsched PTHREAD_ATTR_GETSCHED -#define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM -#define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY -#define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE -#define pthread_attr_init PTHREAD_ATTR_INIT -#define pthread_attr_setdetach_np PTHREAD_ATTR_SETDETACH_NP -#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE -#define pthread_attr_setguardsize_np PTHREAD_ATTR_SETGUARDSIZE_NP -#define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED -#define pthread_attr_setprio PTHREAD_ATTR_SETPRIO -#define pthread_attr_setsched PTHREAD_ATTR_SETSCHED -#define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM -#define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY -#ifndef pthread_attr_setscope -# define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE -#endif -#define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE -#define pthread_cancel PTHREAD_CANCEL -#define pthread_cancel_e PTHREAD_CANCEL_E -#define pthread_cond_broadcast PTHREAD_COND_BROADCAST -#define pthread_cond_destroy PTHREAD_COND_DESTROY -#define pthread_cond_init PTHREAD_COND_INIT -#define pthread_cond_sig_preempt_int_np PTHREAD_COND_SIG_PREEMPT_INT_NP -#define pthread_cond_signal PTHREAD_COND_SIGNAL -#define pthread_cond_signal_int_np PTHREAD_COND_SIGNAL_INT_NP -#define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT -#define pthread_cond_wait PTHREAD_COND_WAIT -#define pthread_condattr_create PTHREAD_CONDATTR_CREATE -#define pthread_condattr_delete PTHREAD_CONDATTR_DELETE -#define pthread_condattr_init PTHREAD_CONDATTR_INIT -#define pthread_create PTHREAD_CREATE -#define pthread_delay_np PTHREAD_DELAY_NP -#define pthread_detach PTHREAD_DETACH -#define pthread_equal PTHREAD_EQUAL -#define pthread_exc_fetch_fp_np PTHREAD_EXC_FETCH_FP_NP -#define pthread_exc_handler_np PTHREAD_EXC_HANDLER_NP -#define pthread_exc_matches_np PTHREAD_EXC_MATCHES_NP -#define pthread_exc_pop_ctx_np PTHREAD_EXC_POP_CTX_NP -#define pthread_exc_push_ctx_np PTHREAD_EXC_PUSH_CTX_NP -#define pthread_exc_raise_np PTHREAD_EXC_RAISE_NP -#define pthread_exc_savecontext_np PTHREAD_EXC_SAVECONTEXT_NP -#define pthread_exit PTHREAD_EXIT -#define pthread_get_expiration_np PTHREAD_GET_EXPIRATION_NP -#define pthread_getprio PTHREAD_GETPRIO -#define pthread_getschedparam PTHREAD_GETSCHEDPARAM -#define pthread_getscheduler PTHREAD_GETSCHEDULER -#define pthread_getspecific PTHREAD_GETSPECIFIC -#define pthread_getunique_np PTHREAD_GETUNIQUE_NP -#define pthread_join PTHREAD_JOIN -#define pthread_join32 PTHREAD_JOIN32 -#define pthread_key_create PTHREAD_KEY_CREATE -#define pthread_key_delete PTHREAD_KEY_DELETE -#define pthread_keycreate PTHREAD_KEYCREATE -#define pthread_kill PTHREAD_KILL -#define pthread_lock_global_np PTHREAD_LOCK_GLOBAL_NP -#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY -#define pthread_mutex_init PTHREAD_MUTEX_INIT -#define pthread_mutex_lock PTHREAD_MUTEX_LOCK -#define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK -#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK -#define pthread_mutexattr_create PTHREAD_MUTEXATTR_CREATE -#define pthread_mutexattr_delete PTHREAD_MUTEXATTR_DELETE -#define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY -#define pthread_mutexattr_getkind_np PTHREAD_MUTEXATTR_GETKIND_NP -#define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT -#define pthread_mutexattr_setkind_np PTHREAD_MUTEXATTR_SETKIND_NP -#define pthread_mutexattr_settype_np PTHREAD_MUTEXATTR_SETTYPE_NP -#define pthread_once PTHREAD_ONCE -#define pthread_resume_np PTHREAD_RESUME_NP -#define pthread_self PTHREAD_SELF -#define pthread_setasynccancel PTHREAD_SETASYNCCANCEL -#define pthread_setcancel PTHREAD_SETCANCEL -#define pthread_setcancelstate PTHREAD_SETCANCELSTATE -#define pthread_setcanceltype PTHREAD_SETCANCELTYPE -#define pthread_setprio PTHREAD_SETPRIO -#define pthread_setschedparam PTHREAD_SETSCHEDPARAM -#define pthread_setscheduler PTHREAD_SETSCHEDULER -#define pthread_setspecific PTHREAD_SETSPECIFIC -#define pthread_suspend_np PTHREAD_SUSPEND_NP -#define pthread_testcancel PTHREAD_TESTCANCEL -#define pthread_unlock_global_np PTHREAD_UNLOCK_GLOBAL_NP -#define pthread_yield PTHREAD_YIELD -#define pthread_yield_np PTHREAD_YIELD_NP -#define rectObjClass RECTOBJCLASS -#define rectObjClassRec RECTOBJCLASSREC -#define sessionShellWidgetClass SESSIONSHELLWIDGETCLASS -#define shellWidgetClass SHELLWIDGETCLASS -#define shmat SHMAT -#define shmctl SHMCTL -#define shmdt SHMDT -#define shmget SHMGET -#define smg$create_key_table SMG$CREATE_KEY_TABLE -#define smg$create_virtual_keyboard SMG$CREATE_VIRTUAL_KEYBOARD -#define smg$read_composed_line SMG$READ_COMPOSED_LINE -#define sys$add_ident SYS$ADD_IDENT -#define sys$asctoid SYS$ASCTOID -#define sys$assign SYS$ASSIGN -#define sys$bintim SYS$BINTIM -#define sys$cancel SYS$CANCEL -#define sys$cantim SYS$CANTIM -#define sys$check_access SYS$CHECK_ACCESS -#define sys$close SYS$CLOSE -#define sys$connect SYS$CONNECT -#define sys$create SYS$CREATE -#define sys$create_user_profile SYS$CREATE_USER_PROFILE -#define sys$crembx SYS$CREMBX -#define sys$creprc SYS$CREPRC -#define sys$crmpsc SYS$CRMPSC -#define sys$dassgn SYS$DASSGN -#define sys$dclast SYS$DCLAST -#define sys$dclexh SYS$DCLEXH -#define sys$delprc SYS$DELPRC -#define sys$deq SYS$DEQ -#define sys$dgblsc SYS$DGBLSC -#define sys$display SYS$DISPLAY -#define sys$enq SYS$ENQ -#define sys$enqw SYS$ENQW -#define sys$erase SYS$ERASE -#define sys$fao SYS$FAO -#define sys$faol SYS$FAOL -#define sys$find_held SYS$FIND_HELD -#define sys$finish_rdb SYS$FINISH_RDB -#define sys$flush SYS$FLUSH -#define sys$forcex SYS$FORCEX -#define sys$get SYS$GET -#define sys$get_security SYS$GET_SECURITY -#define sys$getdviw SYS$GETDVIW -#define sys$getjpi SYS$GETJPI -#define sys$getjpiw SYS$GETJPIW -#define sys$getlkiw SYS$GETLKIW -#define sys$getmsg SYS$GETMSG -#define sys$getsyi SYS$GETSYI -#define sys$getsyiw SYS$GETSYIW -#define sys$gettim SYS$GETTIM -#define sys$getuai SYS$GETUAI -#define sys$grantid SYS$GRANTID -#define sys$hash_password SYS$HASH_PASSWORD -#define sys$hiber SYS$HIBER -#define sys$mgblsc SYS$MGBLSC -#define sys$numtim SYS$NUMTIM -#define sys$open SYS$OPEN -#define sys$parse SYS$PARSE -#define sys$parse_acl SYS$PARSE_ACL -#define sys$parse_acl SYS$PARSE_ACL -#define sys$persona_assume SYS$PERSONA_ASSUME -#define sys$persona_create SYS$PERSONA_CREATE -#define sys$persona_delete SYS$PERSONA_DELETE -#define sys$process_scan SYS$PROCESS_SCAN -#define sys$put SYS$PUT -#define sys$qio SYS$QIO -#define sys$qiow SYS$QIOW -#define sys$read SYS$READ -#define sys$resched SYS$RESCHED -#define sys$rewind SYS$REWIND -#define sys$search SYS$SEARCH -#define sys$set_security SYS$SET_SECURITY -#define sys$setast SYS$SETAST -#define sys$setef SYS$SETEF -#define sys$setimr SYS$SETIMR -#define sys$setpri SYS$SETPRI -#define sys$setprn SYS$SETPRN -#define sys$setprv SYS$SETPRV -#define sys$setswm SYS$SETSWM -#define sys$setuai SYS$SETUAI -#define sys$sndopr SYS$SNDOPR -#define sys$synch SYS$SYNCH -#define sys$trnlnm SYS$TRNLNM -#define sys$update SYS$UPDATE -#define sys$wake SYS$WAKE -#define sys$write SYS$WRITE -#define topLevelShellClassRec TOPLEVELSHELLCLASSREC -#define topLevelShellWidgetClass TOPLEVELSHELLWIDGETCLASS -#define transientShellWidgetClass TRANSIENTSHELLWIDGETCLASS -#define vendorShellClassRec VENDORSHELLCLASSREC -#define vendorShellWidgetClass VENDORSHELLWIDGETCLASS -#define widgetClass WIDGETCLASS -#define widgetClassRec WIDGETCLASSREC -#define wmShellClassRec WMSHELLCLASSREC -#define wmShellWidgetClass WMSHELLWIDGETCLASS -#define x$soft_ast_lib_lock X$SOFT_AST_LIB_LOCK -#define x$soft_ast_lock_depth X$SOFT_AST_LOCK_DEPTH -#define x$soft_reenable_asts X$SOFT_REENABLE_ASTS -#define xmArrowButtonWidgetClass XMARROWBUTTONWIDGETCLASS -#define xmBulletinBoardWidgetClass XMBULLETINBOARDWIDGETCLASS -#define xmCascadeButtonClassRec XMCASCADEBUTTONCLASSREC -#define xmCascadeButtonGadgetClass XMCASCADEBUTTONGADGETCLASS -#define xmCascadeButtonWidgetClass XMCASCADEBUTTONWIDGETCLASS -#define xmCommandWidgetClass XMCOMMANDWIDGETCLASS -#define xmDialogShellWidgetClass XMDIALOGSHELLWIDGETCLASS -#define xmDrawingAreaWidgetClass XMDRAWINGAREAWIDGETCLASS -#define xmDrawnButtonWidgetClass XMDRAWNBUTTONWIDGETCLASS -#define xmFileSelectionBoxWidgetClass XMFILESELECTIONBOXWIDGETCLASS -#define xmFormWidgetClass XMFORMWIDGETCLASS -#define xmFrameWidgetClass XMFRAMEWIDGETCLASS -#define xmGadgetClass XMGADGETCLASS -#define xmLabelGadgetClass XMLABELGADGETCLASS -#define xmLabelWidgetClass XMLABELWIDGETCLASS -#define xmListWidgetClass XMLISTWIDGETCLASS -#define xmMainWindowWidgetClass XMMAINWINDOWWIDGETCLASS -#define xmManagerClassRec XMMANAGERCLASSREC -#define xmManagerWidgetClass XMMANAGERWIDGETCLASS -#define xmMenuShellWidgetClass XMMENUSHELLWIDGETCLASS -#define xmMessageBoxWidgetClass XMMESSAGEBOXWIDGETCLASS -#define xmPrimitiveClassRec XMPRIMITIVECLASSREC -#define xmPrimitiveWidgetClass XMPRIMITIVEWIDGETCLASS -#define xmPushButtonClassRec XMPUSHBUTTONCLASSREC -#define xmPushButtonGadgetClass XMPUSHBUTTONGADGETCLASS -#define xmPushButtonWidgetClass XMPUSHBUTTONWIDGETCLASS -#define xmRowColumnWidgetClass XMROWCOLUMNWIDGETCLASS -#define xmSashWidgetClass XMSASHWIDGETCLASS -#define xmScaleWidgetClass XMSCALEWIDGETCLASS -#define xmScrollBarWidgetClass XMSCROLLBARWIDGETCLASS -#define xmScrolledWindowClassRec XMSCROLLEDWINDOWCLASSREC -#define xmScrolledWindowWidgetClass XMSCROLLEDWINDOWWIDGETCLASS -#define xmSeparatorGadgetClass XMSEPARATORGADGETCLASS -#define xmSeparatorWidgetClass XMSEPARATORWIDGETCLASS -#define xmTextFieldWidgetClass XMTEXTFIELDWIDGETCLASS -#define xmTextWidgetClass XMTEXTWIDGETCLASS -#define xmToggleButtonGadgetClass XMTOGGLEBUTTONGADGETCLASS -#define xmToggleButtonWidgetClass XMTOGGLEBUTTONWIDGETCLASS - -#if (__VMS_VER < 80200000) -# define SetReqLen(req,n,badlen) \ - if ((req->length + n) > (unsigned)65535) { \ - n = badlen; \ - req->length += n; \ - } else \ - req->length += n -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern void XtFree(char*); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Source/3rd Party/wx/include/wx/volume.h b/Source/3rd Party/wx/include/wx/volume.h index cf479974c..7a958b98a 100644 --- a/Source/3rd Party/wx/include/wx/volume.h +++ b/Source/3rd Party/wx/include/wx/volume.h @@ -4,12 +4,13 @@ // Author: George Policello // Modified by: // Created: 28 Jan 02 +// RCS-ID: $Id: volume.h 39399 2006-05-28 23:08:31Z ABX $ // Copyright: (c) 2002 George Policello // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- -// wxFSVolume represents a volume/drive in a file system +// wxFSVolume represents a volume/drive/mount point in a file system // ---------------------------------------------------------------------------- #ifndef _WX_FSVOLUME_H_ @@ -22,7 +23,7 @@ #include "wx/arrstr.h" // the volume flags -enum wxFSVolumeFlags +enum { // is the volume mounted? wxFS_VOL_MOUNTED = 0x0001, diff --git a/Source/3rd Party/wx/include/wx/vscroll.h b/Source/3rd Party/wx/include/wx/vscroll.h index 9f1b54118..9063e108b 100644 --- a/Source/3rd Party/wx/include/wx/vscroll.h +++ b/Source/3rd Party/wx/include/wx/vscroll.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/vscroll.h -// Purpose: Variable scrolled windows (wx[V/H/HV]ScrolledWindow) +// Name: include/wx/vscroll.h +// Purpose: wxVScrolledWindow: generalization of wxScrolledWindow // Author: Vadim Zeitlin -// Modified by: Brad Anderson, Bryan Petty +// Modified by: // Created: 30.05.03 +// RCS-ID: $Id: vscroll.h 38917 2006-04-26 00:17:52Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,679 +12,34 @@ #ifndef _WX_VSCROLL_H_ #define _WX_VSCROLL_H_ -#include "wx/panel.h" -#include "wx/position.h" -#include "wx/scrolwin.h" +#include "wx/panel.h" // base class -class WXDLLIMPEXP_FWD_CORE wxVarScrollHelperEvtHandler; - - -// Using the same techniques as the wxScrolledWindow class | -// hierarchy, the wx[V/H/HV]ScrolledWindow classes are slightly | -// more complex (compare with the diagram outlined in | -// scrolwin.h) for the purpose of reducing code duplication | -// through the use of mix-in classes. | -// | -// wxAnyScrollHelperBase | -// | | -// | | -// | | -// V | -// wxVarScrollHelperBase | -// / \ | -// / \ | -// V V | -// wxVarHScrollHelper wxVarVScrollHelper | -// | \ / | | -// | \ / | | -// | V V | | -// | wxVarHVScrollHelper | | -// | | | | -// | | V | -// | wxPanel | wxVarVScrollLegacyAdaptor | -// | / \ \ | | | -// | / \ `-----|----------. | | -// | / \ | \ | | -// | / \ | \ | | -// V V \ | V V | -// wxHScrolledWindow \ | wxVScrolledWindow | -// V V | -// wxHVScrolledWindow | -// | -// | -// Border added to suppress GCC multi-line comment warnings ->| - - -// =========================================================================== -// wxVarScrollHelperBase -// =========================================================================== - -// Provides all base common scroll calculations needed for either orientation, -// automatic scrollbar functionality, saved scroll positions, functionality -// for changing the target window to be scrolled, as well as defining all -// required virtual functions that need to be implemented for any orientation -// specific work. - -class WXDLLIMPEXP_CORE wxVarScrollHelperBase : public wxAnyScrollHelperBase -{ -public: - // constructors and such - // --------------------- - - wxVarScrollHelperBase(wxWindow *winToScroll); - virtual ~wxVarScrollHelperBase(); - - // operations - // ---------- - - // with physical scrolling on, the device origin is changed properly when - // a wxPaintDC is prepared, children are actually moved and laid out - // properly, and the contents of the window (pixels) are actually moved - void EnablePhysicalScrolling(bool scrolling = true) - { m_physicalScrolling = scrolling; } - - // wxNOT_FOUND if none, i.e. if it is below the last item - int VirtualHitTest(wxCoord coord) const; - - // recalculate all our parameters and redisplay all units - virtual void RefreshAll(); - - // accessors - // --------- - - // get the first currently visible unit - size_t GetVisibleBegin() const { return m_unitFirst; } - - // get the last currently visible unit - size_t GetVisibleEnd() const - { return m_unitFirst + m_nUnitsVisible; } - - // is this unit currently visible? - bool IsVisible(size_t unit) const - { return unit >= m_unitFirst && unit < GetVisibleEnd(); } - - // translate between scrolled and unscrolled coordinates - int CalcScrolledPosition(int coord) const - { return DoCalcScrolledPosition(coord); } - int CalcUnscrolledPosition(int coord) const - { return DoCalcUnscrolledPosition(coord); } - - virtual int DoCalcScrolledPosition(int coord) const; - virtual int DoCalcUnscrolledPosition(int coord) const; - - // update the thumb size shown by the scrollbar - virtual void UpdateScrollbar(); - void RemoveScrollbar(); - - // Normally the wxScrolledWindow will scroll itself, but in some rare - // occasions you might want it to scroll [part of] another window (e.g. a - // child of it in order to scroll only a portion the area between the - // scrollbars (spreadsheet: only cell area will move). - virtual void SetTargetWindow(wxWindow *target); - - // change the DC origin according to the scroll position. To properly - // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER() - // derived class - virtual void DoPrepareDC(wxDC& dc); - - // the methods to be called from the window event handlers - void HandleOnScroll(wxScrollWinEvent& event); - void HandleOnSize(wxSizeEvent& event); -#if wxUSE_MOUSEWHEEL - void HandleOnMouseWheel(wxMouseEvent& event); -#endif // wxUSE_MOUSEWHEEL - - // these functions must be overidden in the derived class to return - // orientation specific data (e.g. the width for vertically scrolling - // derivatives in the case of GetOrientationTargetSize()) - virtual int GetOrientationTargetSize() const = 0; - virtual int GetNonOrientationTargetSize() const = 0; - virtual wxOrientation GetOrientation() const = 0; - -protected: - // all *Unit* functions are protected to be exposed by - // wxVarScrollHelperBase implementations (with appropriate names) - - // get the number of units this window contains (previously set by - // SetUnitCount()) - size_t GetUnitCount() const { return m_unitMax; } - - // set the number of units the helper contains: the derived class must - // provide the sizes for all units with indices up to the one given here - // in its OnGetUnitSize() - void SetUnitCount(size_t count); - - // redraw the specified unit - virtual void RefreshUnit(size_t unit); - - // redraw all units in the specified range (inclusive) - virtual void RefreshUnits(size_t from, size_t to); - - // scroll to the specified unit: it will become the first visible unit in - // the window - // - // return true if we scrolled the window, false if nothing was done - bool DoScrollToUnit(size_t unit); - - // scroll by the specified number of units/pages - virtual bool DoScrollUnits(int units); - virtual bool DoScrollPages(int pages); - - // this function must be overridden in the derived class and it should - // return the size of the given unit in pixels - virtual wxCoord OnGetUnitSize(size_t n) const = 0; - - // this function doesn't have to be overridden but it may be useful to do - // it if calculating the units' sizes is a relatively expensive operation - // as it gives the user code a possibility to calculate several of them at - // once - // - // OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but - // you shouldn't rely on the latter being called for all units in the - // interval specified here. It is also possible that OnGetUnitHeight() will - // be called for the units outside of this interval, so this is really just - // a hint, not a promise. - // - // finally note that unitMin is inclusive, while unitMax is exclusive, as - // usual - virtual void OnGetUnitsSizeHint(size_t WXUNUSED(unitMin), - size_t WXUNUSED(unitMax)) const - { } - - // when the number of units changes, we try to estimate the total size - // of all units which is a rather expensive operation in terms of unit - // access, so if the user code may estimate the average size - // better/faster than we do, it should override this function to implement - // its own logic - // - // this function should return the best guess for the total size it may - // make - virtual wxCoord EstimateTotalSize() const { return DoEstimateTotalSize(); } - - wxCoord DoEstimateTotalSize() const; - - // find the index of the unit we need to show to fit the specified unit on - // the opposite side either fully or partially (depending on fullyVisible) - size_t FindFirstVisibleFromLast(size_t last, - bool fullyVisible = false) const; - - // get the total size of the units between unitMin (inclusive) and - // unitMax (exclusive) - wxCoord GetUnitsSize(size_t unitMin, size_t unitMax) const; - - // get the offset of the first visible unit - wxCoord GetScrollOffset() const - { return GetUnitsSize(0, GetVisibleBegin()); } - - // get the size of the target window - wxSize GetTargetSize() const { return m_targetWindow->GetClientSize(); } - - void GetTargetSize(int *w, int *h) - { - wxSize size = GetTargetSize(); - if ( w ) - *w = size.x; - if ( h ) - *h = size.y; - } - - // calculate the new scroll position based on scroll event type - size_t GetNewScrollPosition(wxScrollWinEvent& event) const; - - // replacement implementation of wxWindow::Layout virtual method. To - // properly forward calls to wxWindow::Layout use - // WX_FORWARD_TO_SCROLL_HELPER() derived class - bool ScrollLayout(); - -#ifdef __WXMAC__ - // queue mac window update after handling scroll event - virtual void UpdateMacScrollWindow() { } -#endif // __WXMAC__ - - // change the target window - void DoSetTargetWindow(wxWindow *target); - - // delete the event handler we installed - void DeleteEvtHandler(); - - // helper function abstracting the orientation test: with vertical - // orientation, it assigns the first value to x and the second one to y, - // with horizontal orientation it reverses them, i.e. the first value is - // assigned to y and the second one to x - void AssignOrient(wxCoord& x, wxCoord& y, wxCoord first, wxCoord second); - - // similar to "oriented assignment" above but does "oriented increment": - // for vertical orientation, y is incremented by the given value and x if - // left unchanged, for horizontal orientation x is incremented - void IncOrient(wxCoord& x, wxCoord& y, wxCoord inc); - -private: - // the total number of (logical) units - size_t m_unitMax; - - // the total (estimated) size - wxCoord m_sizeTotal; - - // the first currently visible unit - size_t m_unitFirst; - - // the number of currently visible units (including the last, possibly only - // partly, visible one) - size_t m_nUnitsVisible; - - // accumulated mouse wheel rotation -#if wxUSE_MOUSEWHEEL - int m_sumWheelRotation; -#endif - - // do child scrolling (used in DoPrepareDC()) - bool m_physicalScrolling; - - // handler injected into target window to forward some useful events to us - wxVarScrollHelperEvtHandler *m_handler; -}; - - - -// =========================================================================== -// wxVarVScrollHelper -// =========================================================================== - -// Provides public API functions targeted for vertical-specific scrolling, -// wrapping the functionality of wxVarScrollHelperBase. - -class WXDLLIMPEXP_CORE wxVarVScrollHelper : public wxVarScrollHelperBase -{ -public: - // constructors and such - // --------------------- - - // ctor must be given the associated window - wxVarVScrollHelper(wxWindow *winToScroll) - : wxVarScrollHelperBase(winToScroll) - { - } - - // operators - - void SetRowCount(size_t rowCount) { SetUnitCount(rowCount); } - bool ScrollToRow(size_t row) { return DoScrollToUnit(row); } - - virtual bool ScrollRows(int rows) - { return DoScrollUnits(rows); } - virtual bool ScrollRowPages(int pages) - { return DoScrollPages(pages); } - - virtual void RefreshRow(size_t row) - { RefreshUnit(row); } - virtual void RefreshRows(size_t from, size_t to) - { RefreshUnits(from, to); } - - // accessors - - size_t GetRowCount() const { return GetUnitCount(); } - size_t GetVisibleRowsBegin() const { return GetVisibleBegin(); } - size_t GetVisibleRowsEnd() const { return GetVisibleEnd(); } - bool IsRowVisible(size_t row) const { return IsVisible(row); } - - virtual int GetOrientationTargetSize() const - { return GetTargetWindow()->GetClientSize().y; } - virtual int GetNonOrientationTargetSize() const - { return GetTargetWindow()->GetClientSize().x; } - virtual wxOrientation GetOrientation() const { return wxVERTICAL; } - -protected: - // this function must be overridden in the derived class and it should - // return the size of the given row in pixels - virtual wxCoord OnGetRowHeight(size_t n) const = 0; - wxCoord OnGetUnitSize(size_t n) const { return OnGetRowHeight(n); } - - virtual void OnGetRowsHeightHint(size_t WXUNUSED(rowMin), - size_t WXUNUSED(rowMax)) const { } - - // forward calls to OnGetRowsHeightHint() - virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const - { OnGetRowsHeightHint(unitMin, unitMax); } - - // again, if not overridden, it will fall back on default method - virtual wxCoord EstimateTotalHeight() const - { return DoEstimateTotalSize(); } - - // forward calls to EstimateTotalHeight() - virtual wxCoord EstimateTotalSize() const { return EstimateTotalHeight(); } - - wxCoord GetRowsHeight(size_t rowMin, size_t rowMax) const - { return GetUnitsSize(rowMin, rowMax); } -}; - - - -// =========================================================================== -// wxVarHScrollHelper -// =========================================================================== - -// Provides public API functions targeted for horizontal-specific scrolling, -// wrapping the functionality of wxVarScrollHelperBase. - -class WXDLLIMPEXP_CORE wxVarHScrollHelper : public wxVarScrollHelperBase -{ -public: - // constructors and such - // --------------------- - - // ctor must be given the associated window - wxVarHScrollHelper(wxWindow *winToScroll) - : wxVarScrollHelperBase(winToScroll) - { - } - - // operators - - void SetColumnCount(size_t columnCount) - { SetUnitCount(columnCount); } - - bool ScrollToColumn(size_t column) - { return DoScrollToUnit(column); } - virtual bool ScrollColumns(int columns) - { return DoScrollUnits(columns); } - virtual bool ScrollColumnPages(int pages) - { return DoScrollPages(pages); } - - virtual void RefreshColumn(size_t column) - { RefreshUnit(column); } - virtual void RefreshColumns(size_t from, size_t to) - { RefreshUnits(from, to); } - - // accessors - - size_t GetColumnCount() const - { return GetUnitCount(); } - size_t GetVisibleColumnsBegin() const - { return GetVisibleBegin(); } - size_t GetVisibleColumnsEnd() const - { return GetVisibleEnd(); } - bool IsColumnVisible(size_t column) const - { return IsVisible(column); } - - - virtual int GetOrientationTargetSize() const - { return GetTargetWindow()->GetClientSize().x; } - virtual int GetNonOrientationTargetSize() const - { return GetTargetWindow()->GetClientSize().y; } - virtual wxOrientation GetOrientation() const { return wxHORIZONTAL; } - -protected: - // this function must be overridden in the derived class and it should - // return the size of the given column in pixels - virtual wxCoord OnGetColumnWidth(size_t n) const = 0; - wxCoord OnGetUnitSize(size_t n) const { return OnGetColumnWidth(n); } - - virtual void OnGetColumnsWidthHint(size_t WXUNUSED(columnMin), - size_t WXUNUSED(columnMax)) const - { } - - // forward calls to OnGetColumnsWidthHint() - virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const - { OnGetColumnsWidthHint(unitMin, unitMax); } - - // again, if not overridden, it will fall back on default method - virtual wxCoord EstimateTotalWidth() const { return DoEstimateTotalSize(); } - - // forward calls to EstimateTotalWidth() - virtual wxCoord EstimateTotalSize() const { return EstimateTotalWidth(); } - - wxCoord GetColumnsWidth(size_t columnMin, size_t columnMax) const - { return GetUnitsSize(columnMin, columnMax); } -}; - - - -// =========================================================================== -// wxVarHVScrollHelper -// =========================================================================== - -// Provides public API functions targeted at functions with similar names in -// both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be -// specified (since we are using multiple inheritance). It also provides -// functions to make changing values for both orientations at the same time -// easier. - -class WXDLLIMPEXP_CORE wxVarHVScrollHelper : public wxVarVScrollHelper, - public wxVarHScrollHelper -{ -public: - // constructors and such - // --------------------- - - // ctor must be given the associated window - wxVarHVScrollHelper(wxWindow *winToScroll) - : wxVarVScrollHelper(winToScroll), wxVarHScrollHelper(winToScroll) { } - - // operators - // --------- - - // set the number of units the window contains for each axis: the derived - // class must provide the widths and heights for all units with indices up - // to each of the one given here in its OnGetColumnWidth() and - // OnGetRowHeight() - void SetRowColumnCount(size_t rowCount, size_t columnCount); - - - // with physical scrolling on, the device origin is changed properly when - // a wxPaintDC is prepared, children are actually moved and laid out - // properly, and the contents of the window (pixels) are actually moved - void EnablePhysicalScrolling(bool vscrolling = true, bool hscrolling = true) - { - wxVarVScrollHelper::EnablePhysicalScrolling(vscrolling); - wxVarHScrollHelper::EnablePhysicalScrolling(hscrolling); - } - - // scroll to the specified row/column: it will become the first visible - // cell in the window - // - // return true if we scrolled the window, false if nothing was done - bool ScrollToRowColumn(size_t row, size_t column); - bool ScrollToRowColumn(const wxPosition &pos) - { return ScrollToRowColumn(pos.GetRow(), pos.GetColumn()); } - - // redraw the specified cell - virtual void RefreshRowColumn(size_t row, size_t column); - virtual void RefreshRowColumn(const wxPosition &pos) - { RefreshRowColumn(pos.GetRow(), pos.GetColumn()); } - - // redraw the specified regions (inclusive). If the target window for - // both orientations is the same the rectangle of cells is refreshed; if - // the target windows differ the entire client size opposite the - // orientation direction is refreshed between the specified limits - virtual void RefreshRowsColumns(size_t fromRow, size_t toRow, - size_t fromColumn, size_t toColumn); - virtual void RefreshRowsColumns(const wxPosition& from, - const wxPosition& to) - { - RefreshRowsColumns(from.GetRow(), to.GetRow(), - from.GetColumn(), to.GetColumn()); - } - - // locate the virtual position from the given device coordinates - wxPosition VirtualHitTest(wxCoord x, wxCoord y) const; - wxPosition VirtualHitTest(const wxPoint &pos) const - { return VirtualHitTest(pos.x, pos.y); } - - // change the DC origin according to the scroll position. To properly - // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER() - // derived class. We use this version to call both base classes' - // DoPrepareDC() - virtual void DoPrepareDC(wxDC& dc); - - // replacement implementation of wxWindow::Layout virtual method. To - // properly forward calls to wxWindow::Layout use - // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to - // call both base classes' ScrollLayout() - bool ScrollLayout(); - - // accessors - // --------- - - // get the number of units this window contains (previously set by - // Set[Column/Row/RowColumn/Unit]Count()) - wxSize GetRowColumnCount() const; - - // get the first currently visible units - wxPosition GetVisibleBegin() const; - wxPosition GetVisibleEnd() const; - - // is this cell currently visible? - bool IsVisible(size_t row, size_t column) const; - bool IsVisible(const wxPosition &pos) const - { return IsVisible(pos.GetRow(), pos.GetColumn()); } -}; - - - -#if WXWIN_COMPATIBILITY_2_8 - -// =========================================================================== -// wxVarVScrollLegacyAdaptor -// =========================================================================== - -// Provides backwards compatible API for applications originally built using -// wxVScrolledWindow in 2.6 or 2.8. Originally, wxVScrolledWindow referred -// to scrolling "lines". We use "units" in wxVarScrollHelperBase to avoid -// implying any orientation (since the functions are used for both horizontal -// and vertical scrolling in derived classes). And in the new -// wxVScrolledWindow and wxHScrolledWindow classes, we refer to them as -// "rows" and "columns", respectively. This is to help clear some confusion -// in not only those classes, but also in wxHVScrolledWindow where functions -// are inherited from both. - -class WXDLLIMPEXP_CORE wxVarVScrollLegacyAdaptor : public wxVarVScrollHelper -{ -public: - // constructors and such - // --------------------- - wxVarVScrollLegacyAdaptor(wxWindow *winToScroll) - : wxVarVScrollHelper(winToScroll) - { - } - - // accessors - // --------- - - // this is the same as GetVisibleRowsBegin(), exists to match - // GetLastVisibleLine() and for backwards compatibility only - wxDEPRECATED( size_t GetFirstVisibleLine() const ); - - // get the last currently visible line - // - // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive - // number) if the control is empty, use GetVisibleRowsEnd() instead, this - // one is kept for backwards compatibility - wxDEPRECATED( size_t GetLastVisibleLine() const ); - - // "line" to "unit" compatibility functions - // ---------------------------------------- - - // get the number of lines this window contains (set by SetLineCount()) - wxDEPRECATED( size_t GetLineCount() const ); - - // set the number of lines the helper contains: the derived class must - // provide the sizes for all lines with indices up to the one given here - // in its OnGetLineHeight() - wxDEPRECATED( void SetLineCount(size_t count) ); - - // redraw the specified line - wxDEPRECATED( virtual void RefreshLine(size_t line) ); - - // redraw all lines in the specified range (inclusive) - wxDEPRECATED( virtual void RefreshLines(size_t from, size_t to) ); - - // scroll to the specified line: it will become the first visible line in - // the window - // - // return true if we scrolled the window, false if nothing was done - wxDEPRECATED( bool ScrollToLine(size_t line) ); - - // scroll by the specified number of lines/pages - wxDEPRECATED( virtual bool ScrollLines(int lines) ); - wxDEPRECATED( virtual bool ScrollPages(int pages) ); - -protected: - // unless the code has been updated to override OnGetRowHeight() instead, - // this function must be overridden in the derived class and it should - // return the height of the given row in pixels - wxDEPRECATED_BUT_USED_INTERNALLY( - virtual wxCoord OnGetLineHeight(size_t n) const ); - - // forwards the calls from base class pure virtual function to pure virtual - // OnGetLineHeight instead (backwards compatible name) - // note that we don't need to forward OnGetUnitSize() as it is already - // forwarded to OnGetRowHeight() in wxVarVScrollHelper - virtual wxCoord OnGetRowHeight(size_t n) const; - - // this function doesn't have to be overridden but it may be useful to do - // it if calculating the lines heights is a relatively expensive operation - // as it gives the user code a possibility to calculate several of them at - // once - // - // OnGetLinesHint() is normally called just before OnGetLineHeight() but you - // shouldn't rely on the latter being called for all lines in the interval - // specified here. It is also possible that OnGetLineHeight() will be - // called for the lines outside of this interval, so this is really just a - // hint, not a promise. - // - // finally note that lineMin is inclusive, while lineMax is exclusive, as - // usual - wxDEPRECATED_BUT_USED_INTERNALLY( virtual void OnGetLinesHint( - size_t lineMin, size_t lineMax) const ); - - // forwards the calls from base class pure virtual function to pure virtual - // OnGetLinesHint instead (backwards compatible name) - void OnGetRowsHeightHint(size_t rowMin, size_t rowMax) const; -}; - -#else // !WXWIN_COMPATIBILITY_2_8 - -// shortcut to avoid checking compatibility modes later -// remove this and all references to wxVarVScrollLegacyAdaptor once -// wxWidgets 2.6 and 2.8 compatibility is removed -typedef wxVarVScrollHelper wxVarVScrollLegacyAdaptor; - -#endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8 - - -// this macro must be used in declaration of wxVarScrollHelperBase-derived -// classes -#define WX_FORWARD_TO_VAR_SCROLL_HELPER() \ -public: \ - virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \ - virtual bool Layout() { return ScrollLayout(); } - - - -// =========================================================================== +// ---------------------------------------------------------------------------- // wxVScrolledWindow -// =========================================================================== +// ---------------------------------------------------------------------------- -// In the name of this class, "V" may stand for "variable" because it can be -// used for scrolling rows of variable heights; "virtual", because it is not -// necessary to know the heights of all rows in advance -- only those which -// are shown on the screen need to be measured; or even "vertical", because -// this class only supports scrolling vertically. +/* + In the name of this class, "V" may stand for "variable" because it can be + used for scrolling lines of variable heights; "virtual" because it is not + necessary to know the heights of all lines in advance -- only those which + are shown on the screen need to be measured; or, even, "vertical" because + this class only supports scrolling in one direction currently (this could + and probably will change in the future however). -// In any case, this is a generalization of the wxScrolledWindow class which -// can be only used when all rows have the same heights. It lacks some other -// wxScrolledWindow features however, notably it can't scroll only a rectangle -// of the window and not its entire client area. - -class WXDLLIMPEXP_CORE wxVScrolledWindow : public wxPanel, - public wxVarVScrollLegacyAdaptor + In any case, this is a generalization of the wxScrolledWindow class which + can be only used when all lines have the same height. It lacks some other + wxScrolledWindow features however, notably it currently lacks support for + horizontal scrolling; it can't scroll another window nor only a rectangle + of the window and not its entire client area. + */ +class WXDLLEXPORT wxVScrolledWindow : public wxPanel { public: // constructors and such // --------------------- // default ctor, you must call Create() later - wxVScrolledWindow() : wxVarVScrollLegacyAdaptor(this) { } + wxVScrolledWindow() { Init(); } // normal ctor, no need to call Create() after this one // @@ -695,8 +51,9 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr) - : wxVarVScrollLegacyAdaptor(this) { + Init(); + (void)Create(parent, id, pos, size, style, name); } @@ -714,158 +71,153 @@ public: return wxPanel::Create(parent, id, pos, size, style | wxVSCROLL, name); } -#if WXWIN_COMPATIBILITY_2_8 - // Make sure we prefer our version of HitTest rather than wxWindow's - // These functions should no longer be masked in favor of VirtualHitTest() - int HitTest(wxCoord WXUNUSED(x), wxCoord y) const - { return wxVarVScrollHelper::VirtualHitTest(y); } - int HitTest(const wxPoint& pt) const - { return HitTest(pt.x, pt.y); } -#endif // WXWIN_COMPATIBILITY_2_8 - WX_FORWARD_TO_VAR_SCROLL_HELPER() + // operations + // ---------- + + // set the number of lines the window contains: the derived class must + // provide the heights for all lines with indices up to the one given here + // in its OnGetLineHeight() + void SetLineCount(size_t count); + + // scroll to the specified line: it will become the first visible line in + // the window + // + // return true if we scrolled the window, false if nothing was done + bool ScrollToLine(size_t line); + + // scroll by the specified number of lines/pages + virtual bool ScrollLines(int lines); + virtual bool ScrollPages(int pages); + + // redraw the specified line + virtual void RefreshLine(size_t line); + + // redraw all lines in the specified range (inclusive) + virtual void RefreshLines(size_t from, size_t to); + + // return the item at the specified (in physical coordinates) position or. + + // wxNOT_FOUND if none, i.e. if it is below the last item + int HitTest(wxCoord x, wxCoord y) const; + int HitTest(const wxPoint& pt) const { return HitTest(pt.x, pt.y); } + + // recalculate all our parameters and redisplay all lines + virtual void RefreshAll(); + + + // accessors + // --------- + + // get the number of lines this window contains (previously set by + // SetLineCount()) + size_t GetLineCount() const { return m_lineMax; } + + // get the first currently visible line + size_t GetVisibleBegin() const { return m_lineFirst; } + + // get the first currently visible line + size_t GetVisibleEnd() const { return m_lineFirst + m_nVisible; } + + // is this line currently visible? + bool IsVisible(size_t line) const + { return line >= GetVisibleBegin() && line < GetVisibleEnd(); } + + + // this is the same as GetVisibleBegin(), exists to match + // GetLastVisibleLine() and for backwards compatibility only + size_t GetFirstVisibleLine() const { return m_lineFirst; } + + // get the last currently visible line + // + // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive + // number) if the control is empty, use GetVisibleEnd() instead, this one + // is kept for backwards compatibility + size_t GetLastVisibleLine() const { return GetVisibleEnd() - 1; } + + // layout the children (including the sizer if needed) + virtual bool Layout(); -#ifdef __WXMAC__ protected: - virtual void UpdateMacScrollWindow() { Update(); } -#endif // __WXMAC__ + // this function must be overridden in the derived class and it should + // return the height of the given line in pixels + virtual wxCoord OnGetLineHeight(size_t n) const = 0; + + // this function doesn't have to be overridden but it may be useful to do + // it if calculating the lines heights is a relatively expensive operation + // as it gives the user code a possibility to calculate several of them at + // once + // + // OnGetLinesHint() is normally called just before OnGetLineHeight() but you + // shouldn't rely on the latter being called for all lines in the interval + // specified here. It is also possible that OnGetLineHeight() will be + // called for the lines outside of this interval, so this is really just a + // hint, not a promise. + // + // finally note that lineMin is inclusive, while lineMax is exclusive, as + // usual + virtual void OnGetLinesHint(size_t WXUNUSED(lineMin), + size_t WXUNUSED(lineMax)) const { } + + // when the number of lines changes, we try to estimate the total height + // of all lines which is a rather expensive operation in terms of lines + // access, so if the user code may estimate the average height + // better/faster than we do, it should override this function to implement + // its own logic + // + // this function should return the best guess for the total height it may + // make + virtual wxCoord EstimateTotalHeight() const; + + + // the event handlers + void OnSize(wxSizeEvent& event); + void OnScroll(wxScrollWinEvent& event); +#if wxUSE_MOUSEWHEEL + void OnMouseWheel(wxMouseEvent& event); +#endif + + // find the index of the line we need to show at the top of the window such + // that the last (fully or partially) visible line is the given one + size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false); + + // get the total height of the lines between lineMin (inclusive) and + // lineMax (exclusive) + wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const; + + // update the thumb size shown by the scrollbar + void UpdateScrollbar(); + + // remove the scrollbar completely because we don't need it + void RemoveScrollbar(); private: - wxDECLARE_NO_COPY_CLASS(wxVScrolledWindow); + // common part of all ctors + void Init(); + + + // the total number of (logical) lines + size_t m_lineMax; + + // the total (estimated) height + wxCoord m_heightTotal; + + // the first currently visible line + size_t m_lineFirst; + + // the number of currently visible lines (including the last, possibly only + // partly, visible one) + size_t m_nVisible; + + // accumulated mouse wheel rotation +#if wxUSE_MOUSEWHEEL + int m_sumWheelRotation; +#endif + + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxVScrolledWindow) DECLARE_ABSTRACT_CLASS(wxVScrolledWindow) }; - - -// =========================================================================== -// wxHScrolledWindow -// =========================================================================== - -// In the name of this class, "H" stands for "horizontal" because it can be -// used for scrolling columns of variable widths. It is not necessary to know -// the widths of all columns in advance -- only those which are shown on the -// screen need to be measured. - -// This is a generalization of the wxScrolledWindow class which can be only -// used when all columns have the same width. It lacks some other -// wxScrolledWindow features however, notably it can't scroll only a rectangle -// of the window and not its entire client area. - -class WXDLLIMPEXP_CORE wxHScrolledWindow : public wxPanel, - public wxVarHScrollHelper -{ -public: - // constructors and such - // --------------------- - - // default ctor, you must call Create() later - wxHScrolledWindow() : wxVarHScrollHelper(this) { } - - // normal ctor, no need to call Create() after this one - // - // note that wxHSCROLL is always automatically added to our style, there is - // no need to specify it explicitly - wxHScrolledWindow(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) - : wxVarHScrollHelper(this) - { - (void)Create(parent, id, pos, size, style, name); - } - - // same as the previous ctor but returns status code: true if ok - // - // just as with the ctor above, wxHSCROLL style is always used, there is no - // need to specify it - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) - { - return wxPanel::Create(parent, id, pos, size, style | wxHSCROLL, name); - } - - WX_FORWARD_TO_VAR_SCROLL_HELPER() - -#ifdef __WXMAC__ -protected: - virtual void UpdateMacScrollWindow() { Update(); } -#endif // __WXMAC__ - -private: - wxDECLARE_NO_COPY_CLASS(wxHScrolledWindow); - DECLARE_ABSTRACT_CLASS(wxHScrolledWindow) -}; - - - -// =========================================================================== -// wxHVScrolledWindow -// =========================================================================== - -// This window inherits all functionality of both vertical and horizontal -// scrolled windows automatically handling everything needed to scroll both -// axis simultaneously. - -class WXDLLIMPEXP_CORE wxHVScrolledWindow : public wxPanel, - public wxVarHVScrollHelper -{ -public: - // constructors and such - // --------------------- - - // default ctor, you must call Create() later - wxHVScrolledWindow() - : wxPanel(), - wxVarHVScrollHelper(this) { } - - // normal ctor, no need to call Create() after this one - // - // note that wxVSCROLL and wxHSCROLL are always automatically added to our - // style, there is no need to specify them explicitly - wxHVScrolledWindow(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) - : wxPanel(), - wxVarHVScrollHelper(this) - { - (void)Create(parent, id, pos, size, style, name); - } - - // same as the previous ctor but returns status code: true if ok - // - // just as with the ctor above, wxVSCROLL and wxHSCROLL styles are always - // used, there is no need to specify them - bool Create(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) - { - return wxPanel::Create(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL, name); - } - - WX_FORWARD_TO_VAR_SCROLL_HELPER() - -#ifdef __WXMAC__ -protected: - virtual void UpdateMacScrollWindow() { Update(); } -#endif // __WXMAC__ - -private: - wxDECLARE_NO_COPY_CLASS(wxHVScrolledWindow); - DECLARE_ABSTRACT_CLASS(wxHVScrolledWindow) -}; - #endif // _WX_VSCROLL_H_ diff --git a/Source/3rd Party/wx/include/wx/weakref.h b/Source/3rd Party/wx/include/wx/weakref.h deleted file mode 100644 index b692f037e..000000000 --- a/Source/3rd Party/wx/include/wx/weakref.h +++ /dev/null @@ -1,352 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/weakref.h -// Purpose: wxWeakRef - Generic weak references for wxWidgets -// Author: Arne Steinarson -// Created: 27 Dec 07 -// Copyright: (c) 2007 Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WEAKREF_H_ -#define _WX_WEAKREF_H_ - -#include "wx/tracker.h" - - -// Some compilers (VC6, Borland, g++ < 3.3) have problem with template specialization. -// However, this is only used for optimization purposes (a smaller wxWeakRef pointer) -// (and the corner case of wxWeakRef). So for those compilers, we can fall -// back to the non-optimal case, where we use the same type of weak ref (static one) -// in all cases. See defs.h for various setting these defines depending on compiler. - -#if !defined(HAVE_PARTIAL_SPECIALIZATION) || \ - !defined(HAVE_TEMPLATE_OVERLOAD_RESOLUTION) || \ - (defined(__GNUC__) && !wxCHECK_GCC_VERSION(3, 3)) - #define USE_ONLY_STATIC_WEAKREF -#endif - - -#ifndef USE_ONLY_STATIC_WEAKREF - -// Avoid including this for simpler compilers -#include "wx/meta/convertible.h" -#include "wx/meta/int2type.h" - -template -struct wxIsStaticTrackable -{ - enum { value = wxConvertibleTo::value }; -}; - -#endif // !USE_ONLY_STATIC_WEAKREF - - -// Weak ref implementation when T has wxTrackable as a known base class -template -class wxWeakRefStatic : public wxTrackerNode -{ -public: - wxWeakRefStatic() : m_pobj(NULL) { } - - void Release() - { - // Release old object if any - if ( m_pobj ) - { - // Remove ourselves from object tracker list - wxTrackable *pt = static_cast(m_pobj); - pt->RemoveNode(this); - m_pobj = NULL; - } - } - - virtual void OnObjectDestroy() - { - // Tracked object itself removes us from list of trackers - wxASSERT(m_pobj != NULL); - m_pobj = NULL; - } - -protected: - void Assign(T* pobj) - { - if ( m_pobj == pobj ) - return; - - Release(); - - // Now set new trackable object - if ( pobj ) - { - // Add ourselves to object tracker list - wxTrackable *pt = static_cast(pobj); - pt->AddNode(this); - m_pobj = pobj; - } - } - - void AssignCopy(const wxWeakRefStatic& wr) - { - Assign( wr.m_pobj ); - } - - T *m_pobj; -}; - - - -#ifndef USE_ONLY_STATIC_WEAKREF - -template -struct wxWeakRefImpl; - -// Intermediate class, to select the static case above. -template -struct wxWeakRefImpl : public wxWeakRefStatic -{ - enum { value = 1 }; -}; - -// Weak ref implementation when T does not have wxTrackable as known base class -template -struct wxWeakRefImpl : public wxTrackerNode -{ - void Release() - { - // Release old object if any - if ( m_pobj ) - { - // Remove ourselves from object tracker list - m_ptbase->RemoveNode(this); - m_pobj = NULL; - m_ptbase = NULL; - } - } - - virtual void OnObjectDestroy() - { - // Tracked object itself removes us from list of trackers - wxASSERT(m_pobj != NULL); - m_pobj = NULL; - m_ptbase = NULL; - } - -protected: - wxWeakRefImpl() : m_pobj(NULL), m_ptbase(NULL) { } - - // Assign receives most derived class here and can use that - template - void Assign( TDerived* pobj ) - { - AssignHelper( pobj, wxInt2Type::value>() ); - } - - template - void AssignHelper(TDerived* pobj, wxInt2Type) - { - wxTrackable *ptbase = static_cast(pobj); - DoAssign( pobj, ptbase ); - } - -#ifndef wxNO_RTTI - void AssignHelper(T* pobj, wxInt2Type) - { - // A last way to get a trackable pointer - wxTrackable *ptbase = dynamic_cast(pobj); - if ( ptbase ) - { - DoAssign( pobj, ptbase ); - } - else - { - wxFAIL_MSG( "Tracked class should inherit from wxTrackable" ); - - Release(); - } - } -#endif // RTTI enabled - - void AssignCopy(const wxWeakRefImpl& wr) - { - DoAssign(wr.m_pobj, wr.m_ptbase); - } - - void DoAssign( T* pobj, wxTrackable *ptbase ) { - if( m_pobj==pobj ) return; - Release(); - - // Now set new trackable object - if( pobj ) - { - // Add ourselves to object tracker list - wxASSERT( ptbase ); - ptbase->AddNode( this ); - m_pobj = pobj; - m_ptbase = ptbase; - } - } - - T *m_pobj; - wxTrackable *m_ptbase; -}; - -#endif // #ifndef USE_ONLY_STATIC_WEAKREF - - - -// A weak reference to an object of type T, where T has base wxTrackable -// (usually statically but if not dynamic_cast<> is tried). -template -class wxWeakRef : public -#ifdef USE_ONLY_STATIC_WEAKREF - wxWeakRefStatic -#else - wxWeakRefImpl::value != 0> -#endif -{ -public: - typedef T element_type; - - // Default ctor - wxWeakRef() { } - - // Enabling this ctor for VC6 results in mysterious compilation failures in - // wx/window.h when assigning wxWindow pointers (FIXME-VC6) -#ifndef __VISUALC6__ - // Ctor from the object of this type: this is needed as the template ctor - // below is not used by at least g++4 when a literal NULL is used - wxWeakRef(T *pobj) - { - this->Assign(pobj); - } -#endif // !__VISUALC6__ - - // When we have the full type here, static_cast<> will always work - // (or give a straight compiler error). - template - wxWeakRef(TDerived* pobj) - { - this->Assign(pobj); - } - - // We need this copy ctor, since otherwise a default compiler (binary) copy - // happens (if embedded as an object member). - wxWeakRef(const wxWeakRef& wr) - { - this->Assign(wr.get()); - } - - wxWeakRef& operator=(const wxWeakRef& wr) - { - this->AssignCopy(wr); - return *this; - } - - virtual ~wxWeakRef() { this->Release(); } - - // Smart pointer functions - T& operator*() const { return *this->m_pobj; } - T* operator->() const { return this->m_pobj; } - - T* get() const { return this->m_pobj; } - operator T*() const { return this->m_pobj; } -}; - - -#ifndef wxNO_RTTI - -// Weak ref implementation assign objects are queried for wxTrackable -// using dynamic_cast<> -template -class wxWeakRefDynamic : public wxTrackerNode -{ -public: - wxWeakRefDynamic() : m_pobj(NULL) { } - - wxWeakRefDynamic(T* pobj) : m_pobj(pobj) - { - Assign(pobj); - } - - wxWeakRefDynamic(const wxWeakRef& wr) - { - Assign(wr.get()); - } - - virtual ~wxWeakRefDynamic() { Release(); } - - // Smart pointer functions - T& operator*() const { wxASSERT(m_pobj); return *m_pobj; } - T* operator->() const { wxASSERT(m_pobj); return m_pobj; } - - T* get() const { return m_pobj; } - operator T* () const { return m_pobj; } - - T* operator = (T* pobj) { Assign(pobj); return m_pobj; } - - // Assign from another weak ref, point to same object - T* operator = (const wxWeakRef &wr) { Assign( wr.get() ); return m_pobj; } - - void Release() - { - // Release old object if any - if( m_pobj ) - { - // Remove ourselves from object tracker list - wxTrackable *pt = dynamic_cast(m_pobj); - wxASSERT(pt); - pt->RemoveNode(this); - m_pobj = NULL; - } - } - - virtual void OnObjectDestroy() - { - wxASSERT_MSG(m_pobj, "tracked object should have removed us itself"); - - m_pobj = NULL; - } - -protected: - void Assign(T *pobj) - { - if ( m_pobj == pobj ) - return; - - Release(); - - // Now set new trackable object - if ( pobj ) - { - // Add ourselves to object tracker list - wxTrackable *pt = dynamic_cast(pobj); - if ( pt ) - { - pt->AddNode(this); - m_pobj = pobj; - } - else - { - // If the object we want to track does not support wxTackable, then - // log a message and keep the NULL object pointer. - wxFAIL_MSG( "Tracked class should inherit from wxTrackable" ); - } - } - } - - T *m_pobj; -}; - -#endif // RTTI enabled - - -// Provide some basic types of weak references -class WXDLLIMPEXP_FWD_BASE wxEvtHandler; -class WXDLLIMPEXP_FWD_CORE wxWindow; - - -typedef wxWeakRef wxEvtHandlerRef; -typedef wxWeakRef wxWindowRef; - -#endif // _WX_WEAKREF_H_ - diff --git a/Source/3rd Party/wx/include/wx/webview.h b/Source/3rd Party/wx/include/wx/webview.h deleted file mode 100644 index 25a235da9..000000000 --- a/Source/3rd Party/wx/include/wx/webview.h +++ /dev/null @@ -1,304 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webview.h -// Purpose: Common interface and events for web view component -// Author: Marianne Gagnon -// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WEBVIEW_H_ -#define _WX_WEBVIEW_H_ - -#include "wx/defs.h" - -#if wxUSE_WEBVIEW - -#include "wx/control.h" -#include "wx/event.h" -#include "wx/sstream.h" -#include "wx/sharedptr.h" -#include "wx/vector.h" - -#if defined(__WXOSX__) - #include "wx/osx/webviewhistoryitem_webkit.h" -#elif defined(__WXGTK__) - #include "wx/gtk/webviewhistoryitem_webkit.h" -#elif defined(__WXMSW__) - #include "wx/msw/webviewhistoryitem_ie.h" -#else - #error "wxWebView not implemented on this platform." -#endif - -class wxFSFile; -class wxFileSystem; -class wxWebView; - -enum wxWebViewZoom -{ - wxWEBVIEW_ZOOM_TINY, - wxWEBVIEW_ZOOM_SMALL, - wxWEBVIEW_ZOOM_MEDIUM, - wxWEBVIEW_ZOOM_LARGE, - wxWEBVIEW_ZOOM_LARGEST -}; - -enum wxWebViewZoomType -{ - //Scales entire page, including images - wxWEBVIEW_ZOOM_TYPE_LAYOUT, - wxWEBVIEW_ZOOM_TYPE_TEXT -}; - -enum wxWebViewNavigationError -{ - wxWEBVIEW_NAV_ERR_CONNECTION, - wxWEBVIEW_NAV_ERR_CERTIFICATE, - wxWEBVIEW_NAV_ERR_AUTH, - wxWEBVIEW_NAV_ERR_SECURITY, - wxWEBVIEW_NAV_ERR_NOT_FOUND, - wxWEBVIEW_NAV_ERR_REQUEST, - wxWEBVIEW_NAV_ERR_USER_CANCELLED, - wxWEBVIEW_NAV_ERR_OTHER -}; - -enum wxWebViewReloadFlags -{ - //Default, may access cache - wxWEBVIEW_RELOAD_DEFAULT, - wxWEBVIEW_RELOAD_NO_CACHE -}; - -enum wxWebViewFindFlags -{ - wxWEBVIEW_FIND_WRAP = 0x0001, - wxWEBVIEW_FIND_ENTIRE_WORD = 0x0002, - wxWEBVIEW_FIND_MATCH_CASE = 0x0004, - wxWEBVIEW_FIND_HIGHLIGHT_RESULT = 0x0008, - wxWEBVIEW_FIND_BACKWARDS = 0x0010, - wxWEBVIEW_FIND_DEFAULT = 0 -}; - -//Base class for custom scheme handlers -class WXDLLIMPEXP_WEBVIEW wxWebViewHandler -{ -public: - wxWebViewHandler(const wxString& scheme) : m_scheme(scheme) {} - virtual ~wxWebViewHandler() {} - virtual wxString GetName() const { return m_scheme; } - virtual wxFSFile* GetFile(const wxString &uri) = 0; -private: - wxString m_scheme; -}; - -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[]; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr[]; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[]; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE[]; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[]; - -class WXDLLIMPEXP_WEBVIEW wxWebViewFactory : public wxObject -{ -public: - virtual wxWebView* Create() = 0; - virtual wxWebView* Create(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxWebViewNameStr) = 0; -}; - -WX_DECLARE_STRING_HASH_MAP(wxSharedPtr, wxStringWebViewFactoryMap); - -class WXDLLIMPEXP_WEBVIEW wxWebView : public wxControl -{ -public: - wxWebView() - { - m_showMenu = true; - } - - virtual ~wxWebView() {} - - virtual bool Create(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxWebViewNameStr) = 0; - - // Factory methods allowing the use of custom factories registered with - // RegisterFactory - static wxWebView* New(const wxString& backend = wxWebViewBackendDefault); - static wxWebView* New(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const wxString& backend = wxWebViewBackendDefault, - long style = 0, - const wxString& name = wxWebViewNameStr); - - static void RegisterFactory(const wxString& backend, - wxSharedPtr factory); - - // General methods - virtual void EnableContextMenu(bool enable = true) - { - m_showMenu = enable; - } - virtual wxString GetCurrentTitle() const = 0; - virtual wxString GetCurrentURL() const = 0; - // TODO: handle choosing a frame when calling GetPageSource()? - virtual wxString GetPageSource() const = 0; - virtual wxString GetPageText() const = 0; - virtual bool IsBusy() const = 0; - virtual bool IsContextMenuEnabled() const { return m_showMenu; } - virtual bool IsEditable() const = 0; - virtual void LoadURL(const wxString& url) = 0; - virtual void Print() = 0; - virtual void RegisterHandler(wxSharedPtr handler) = 0; - virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0; - virtual void RunScript(const wxString& javascript) = 0; - virtual void SetEditable(bool enable = true) = 0; - void SetPage(const wxString& html, const wxString& baseUrl) - { - DoSetPage(html, baseUrl); - } - void SetPage(wxInputStream& html, wxString baseUrl) - { - wxStringOutputStream stream; - stream.Write(html); - DoSetPage(stream.GetString(), baseUrl); - } - virtual void Stop() = 0; - - //History - virtual bool CanGoBack() const = 0; - virtual bool CanGoForward() const = 0; - virtual void GoBack() = 0; - virtual void GoForward() = 0; - virtual void ClearHistory() = 0; - virtual void EnableHistory(bool enable = true) = 0; - virtual wxVector > GetBackwardHistory() = 0; - virtual wxVector > GetForwardHistory() = 0; - virtual void LoadHistoryItem(wxSharedPtr item) = 0; - - //Zoom - virtual bool CanSetZoomType(wxWebViewZoomType type) const = 0; - virtual wxWebViewZoom GetZoom() const = 0; - virtual wxWebViewZoomType GetZoomType() const = 0; - virtual void SetZoom(wxWebViewZoom zoom) = 0; - virtual void SetZoomType(wxWebViewZoomType zoomType) = 0; - - //Selection - virtual void SelectAll() = 0; - virtual bool HasSelection() const = 0; - virtual void DeleteSelection() = 0; - virtual wxString GetSelectedText() const = 0; - virtual wxString GetSelectedSource() const = 0; - virtual void ClearSelection() = 0; - - //Clipboard functions - virtual bool CanCut() const = 0; - virtual bool CanCopy() const = 0; - virtual bool CanPaste() const = 0; - virtual void Cut() = 0; - virtual void Copy() = 0; - virtual void Paste() = 0; - - //Undo / redo functionality - virtual bool CanUndo() const = 0; - virtual bool CanRedo() const = 0; - virtual void Undo() = 0; - virtual void Redo() = 0; - - //Get the pointer to the underlying native engine. - virtual void* GetNativeBackend() const = 0; - //Find function - virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT) = 0; - -protected: - virtual void DoSetPage(const wxString& html, const wxString& baseUrl) = 0; - -private: - static void InitFactoryMap(); - static wxStringWebViewFactoryMap::iterator FindFactory(const wxString &backend); - - bool m_showMenu; - static wxStringWebViewFactoryMap m_factoryMap; - - wxDECLARE_ABSTRACT_CLASS(wxWebView); -}; - -class WXDLLIMPEXP_WEBVIEW wxWebViewEvent : public wxNotifyEvent -{ -public: - wxWebViewEvent() {} - wxWebViewEvent(wxEventType type, int id, const wxString url, - const wxString target) - : wxNotifyEvent(type, id), m_url(url), m_target(target) - {} - - - const wxString& GetURL() const { return m_url; } - const wxString& GetTarget() const { return m_target; } - - virtual wxEvent* Clone() const { return new wxWebViewEvent(*this); } -private: - wxString m_url; - wxString m_target; - - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebViewEvent); -}; - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_NAVIGATING, wxWebViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_NAVIGATED, wxWebViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_LOADED, wxWebViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_ERROR, wxWebViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_NEWWINDOW, wxWebViewEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_TITLE_CHANGED, wxWebViewEvent ); - -typedef void (wxEvtHandler::*wxWebViewEventFunction) - (wxWebViewEvent&); - -#define wxWebViewEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxWebViewEventFunction, func) - -#define EVT_WEBVIEW_NAVIGATING(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_NAVIGATING, id, \ - wxWebViewEventHandler(fn)) - -#define EVT_WEBVIEW_NAVIGATED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_NAVIGATED, id, \ - wxWebViewEventHandler(fn)) - -#define EVT_WEBVIEW_LOADED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_LOADED, id, \ - wxWebViewEventHandler(fn)) - -#define EVT_WEBVIEW_ERROR(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_ERROR, id, \ - wxWebViewEventHandler(fn)) - -#define EVT_WEBVIEW_NEWWINDOW(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_NEWWINDOW, id, \ - wxWebViewEventHandler(fn)) - -#define EVT_WEBVIEW_TITLE_CHANGED(id, fn) \ - wx__DECLARE_EVT1(wxEVT_WEBVIEW_TITLE_CHANGED, id, \ - wxWebViewEventHandler(fn)) - -// old wxEVT_COMMAND_* constants -#define wxEVT_COMMAND_WEBVIEW_NAVIGATING wxEVT_WEBVIEW_NAVIGATING -#define wxEVT_COMMAND_WEBVIEW_NAVIGATED wxEVT_WEBVIEW_NAVIGATED -#define wxEVT_COMMAND_WEBVIEW_LOADED wxEVT_WEBVIEW_LOADED -#define wxEVT_COMMAND_WEBVIEW_ERROR wxEVT_WEBVIEW_ERROR -#define wxEVT_COMMAND_WEBVIEW_NEWWINDOW wxEVT_WEBVIEW_NEWWINDOW -#define wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED wxEVT_WEBVIEW_TITLE_CHANGED - -#endif // wxUSE_WEBVIEW - -#endif // _WX_WEBVIEW_H_ diff --git a/Source/3rd Party/wx/include/wx/webviewarchivehandler.h b/Source/3rd Party/wx/include/wx/webviewarchivehandler.h deleted file mode 100644 index 8b2eb1990..000000000 --- a/Source/3rd Party/wx/include/wx/webviewarchivehandler.h +++ /dev/null @@ -1,36 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webviewarchivehandler.h -// Purpose: Custom webview handler to allow archive browsing -// Author: Steven Lamerton -// Copyright: (c) 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WEBVIEW_FILE_HANDLER_H_ -#define _WX_WEBVIEW_FILE_HANDLER_H_ - -#include "wx/setup.h" - -#if wxUSE_WEBVIEW - -class wxFSFile; -class wxFileSystem; - -#include "wx/webview.h" - -//Loads from uris such as scheme:///C:/example/example.html or archives such as -//scheme:///C:/example/example.zip;protocol=zip/example.html - -class WXDLLIMPEXP_WEBVIEW wxWebViewArchiveHandler : public wxWebViewHandler -{ -public: - wxWebViewArchiveHandler(const wxString& scheme); - virtual ~wxWebViewArchiveHandler(); - virtual wxFSFile* GetFile(const wxString &uri); -private: - wxFileSystem* m_fileSystem; -}; - -#endif // wxUSE_WEBVIEW - -#endif // _WX_WEBVIEW_FILE_HANDLER_H_ diff --git a/Source/3rd Party/wx/include/wx/webviewfshandler.h b/Source/3rd Party/wx/include/wx/webviewfshandler.h deleted file mode 100644 index ebdbbcb90..000000000 --- a/Source/3rd Party/wx/include/wx/webviewfshandler.h +++ /dev/null @@ -1,37 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webviewfshandler.h -// Purpose: Custom webview handler for virtual file system -// Author: Nick Matthews -// Copyright: (c) 2012 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// Based on webviewarchivehandler.h file by Steven Lamerton - -#ifndef _WX_WEBVIEW_FS_HANDLER_H_ -#define _WX_WEBVIEW_FS_HANDLER_H_ - -#include "wx/setup.h" - -#if wxUSE_WEBVIEW - -class wxFSFile; -class wxFileSystem; - -#include "wx/webview.h" - -//Loads from uris such as scheme:example.html - -class WXDLLIMPEXP_WEBVIEW wxWebViewFSHandler : public wxWebViewHandler -{ -public: - wxWebViewFSHandler(const wxString& scheme); - virtual ~wxWebViewFSHandler(); - virtual wxFSFile* GetFile(const wxString &uri); -private: - wxFileSystem* m_fileSystem; -}; - -#endif // wxUSE_WEBVIEW - -#endif // _WX_WEBVIEW_FS_HANDLER_H_ diff --git a/Source/3rd Party/wx/include/wx/wfstream.h b/Source/3rd Party/wx/include/wx/wfstream.h index b6363203e..ead92d641 100644 --- a/Source/3rd Party/wx/include/wx/wfstream.h +++ b/Source/3rd Party/wx/include/wx/wfstream.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: // Created: 11/07/98 +// RCS-ID: $Id: wfstream.h 61872 2009-09-09 22:37:05Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -41,8 +42,6 @@ public: virtual bool IsOk() const; bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; } - wxFile* GetFile() const { return m_file; } - protected: wxFileInputStream(); @@ -54,7 +53,7 @@ protected: wxFile *m_file; bool m_file_destroy; - wxDECLARE_NO_COPY_CLASS(wxFileInputStream); + DECLARE_NO_COPY_CLASS(wxFileInputStream) }; class WXDLLIMPEXP_BASE wxFileOutputStream : public wxOutputStream @@ -73,8 +72,6 @@ public: virtual bool IsOk() const; bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; } - wxFile* GetFile() const { return m_file; } - protected: wxFileOutputStream(); @@ -86,7 +83,7 @@ protected: wxFile *m_file; bool m_file_destroy; - wxDECLARE_NO_COPY_CLASS(wxFileOutputStream); + DECLARE_NO_COPY_CLASS(wxFileOutputStream) }; class WXDLLIMPEXP_BASE wxTempFileOutputStream : public wxOutputStream @@ -96,8 +93,8 @@ public: virtual ~wxTempFileOutputStream(); bool Close() { return Commit(); } - WXDLLIMPEXP_INLINE_BASE virtual bool Commit() { return m_file->Commit(); } - WXDLLIMPEXP_INLINE_BASE virtual void Discard() { m_file->Discard(); } + virtual bool Commit() { return m_file->Commit(); } + virtual void Discard() { m_file->Discard(); } wxFileOffset GetLength() const { return m_file->Length(); } bool IsSeekable() const { return true; } @@ -111,7 +108,7 @@ protected: private: wxTempFile *m_file; - wxDECLARE_NO_COPY_CLASS(wxTempFileOutputStream); + DECLARE_NO_COPY_CLASS(wxTempFileOutputStream) }; class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream, @@ -119,35 +116,9 @@ class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream, { public: wxFileStream(const wxString& fileName); - virtual bool IsOk() const; - - // override (some) virtual functions inherited from both classes to resolve - // ambiguities (this wouldn't be necessary if wxStreamBase were a virtual - // base class but it isn't) - - virtual bool IsSeekable() const - { - return wxFileInputStream::IsSeekable(); - } - - virtual wxFileOffset GetLength() const - { - return wxFileInputStream::GetLength(); - } - -protected: - virtual wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode) - { - return wxFileInputStream::OnSysSeek(pos, mode); - } - - virtual wxFileOffset OnSysTell() const - { - return wxFileInputStream::OnSysTell(); - } private: - wxDECLARE_NO_COPY_CLASS(wxFileStream); + DECLARE_NO_COPY_CLASS(wxFileStream) }; #endif //wxUSE_FILE @@ -161,7 +132,7 @@ private: class WXDLLIMPEXP_BASE wxFFileInputStream : public wxInputStream { public: - wxFFileInputStream(const wxString& fileName, const wxString& mode = "rb"); + wxFFileInputStream(const wxString& fileName, const wxChar *mode = wxT("rb")); wxFFileInputStream(wxFFile& file); wxFFileInputStream(FILE *file); virtual ~wxFFileInputStream(); @@ -172,8 +143,6 @@ public: virtual bool IsOk() const; bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; } - wxFFile* GetFile() const { return m_file; } - protected: wxFFileInputStream(); @@ -185,13 +154,13 @@ protected: wxFFile *m_file; bool m_file_destroy; - wxDECLARE_NO_COPY_CLASS(wxFFileInputStream); + DECLARE_NO_COPY_CLASS(wxFFileInputStream) }; class WXDLLIMPEXP_BASE wxFFileOutputStream : public wxOutputStream { public: - wxFFileOutputStream(const wxString& fileName, const wxString& mode = "wb"); + wxFFileOutputStream(const wxString& fileName, const wxChar *mode = wxT("w+b")); wxFFileOutputStream(wxFFile& file); wxFFileOutputStream(FILE *file); virtual ~wxFFileOutputStream(); @@ -201,11 +170,9 @@ public: wxFileOffset GetLength() const; bool Ok() const { return IsOk(); } - virtual bool IsOk() const; + virtual bool IsOk() const ; bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; } - wxFFile* GetFile() const { return m_file; } - protected: wxFFileOutputStream(); @@ -217,43 +184,17 @@ protected: wxFFile *m_file; bool m_file_destroy; - wxDECLARE_NO_COPY_CLASS(wxFFileOutputStream); + DECLARE_NO_COPY_CLASS(wxFFileOutputStream) }; class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream, public wxFFileOutputStream { public: - wxFFileStream(const wxString& fileName, const wxString& mode = "w+b"); - - // override some virtual functions to resolve ambiguities, just as in - // wxFileStream - - virtual bool IsOk() const; - - virtual bool IsSeekable() const - { - return wxFFileInputStream::IsSeekable(); - } - - virtual wxFileOffset GetLength() const - { - return wxFFileInputStream::GetLength(); - } - -protected: - virtual wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode) - { - return wxFFileInputStream::OnSysSeek(pos, mode); - } - - virtual wxFileOffset OnSysTell() const - { - return wxFFileInputStream::OnSysTell(); - } + wxFFileStream(const wxString& fileName); private: - wxDECLARE_NO_COPY_CLASS(wxFFileStream); + DECLARE_NO_COPY_CLASS(wxFFileStream) }; #endif //wxUSE_FFILE diff --git a/Source/3rd Party/wx/include/wx/window.h b/Source/3rd Party/wx/include/wx/window.h index aa07bdd56..fc9e13e88 100644 --- a/Source/3rd Party/wx/include/wx/window.h +++ b/Source/3rd Party/wx/include/wx/window.h @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: Ron Lee // Created: 01/02/97 +// RCS-ID: $Id: window.h 56758 2008-11-13 22:32:21Z VS $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -48,26 +49,6 @@ #define wxUSE_MENUS_NATIVE wxUSE_MENUS #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__ - -// Define this macro if the corresponding operating system handles the state -// of children windows automatically when the parent is enabled/disabled. -// Otherwise wx itself must ensure that when the parent is disabled its -// children are disabled too, and their initial state is restored when the -// parent is enabled back. -#if defined(__WXMSW__) || defined(__WXPM__) - // must do everything ourselves - #undef wxHAS_NATIVE_ENABLED_MANAGEMENT -#elif defined(__WXOSX__) - #if wxOSX_USE_CARBON - #define wxHAS_NATIVE_ENABLED_MANAGEMENT - #else - // must do everything ourselves - #undef wxHAS_NATIVE_ENABLED_MANAGEMENT - #endif -#else - #define wxHAS_NATIVE_ENABLED_MANAGEMENT -#endif - // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- @@ -77,7 +58,9 @@ class WXDLLIMPEXP_FWD_CORE wxControl; class WXDLLIMPEXP_FWD_CORE wxCursor; class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxDropTarget; +class WXDLLIMPEXP_FWD_CORE wxItemResource; class WXDLLIMPEXP_FWD_CORE wxLayoutConstraints; +class WXDLLIMPEXP_FWD_CORE wxResourceTable; class WXDLLIMPEXP_FWD_CORE wxSizer; class WXDLLIMPEXP_FWD_CORE wxToolTip; class WXDLLIMPEXP_FWD_CORE wxWindowBase; @@ -93,7 +76,7 @@ class WXDLLIMPEXP_FWD_CORE wxAccessible; // ---------------------------------------------------------------------------- // struct containing all the visual attributes of a control -struct WXDLLIMPEXP_CORE wxVisualAttributes +struct WXDLLEXPORT wxVisualAttributes { // the font used for control label/text inside it wxFont font; @@ -121,43 +104,18 @@ enum wxWindowVariant #define wxWINDOW_DEFAULT_VARIANT wxT("window-default-variant") #endif -// valid values for Show/HideWithEffect() -enum wxShowEffect -{ - wxSHOW_EFFECT_NONE, - wxSHOW_EFFECT_ROLL_TO_LEFT, - wxSHOW_EFFECT_ROLL_TO_RIGHT, - wxSHOW_EFFECT_ROLL_TO_TOP, - wxSHOW_EFFECT_ROLL_TO_BOTTOM, - wxSHOW_EFFECT_SLIDE_TO_LEFT, - wxSHOW_EFFECT_SLIDE_TO_RIGHT, - wxSHOW_EFFECT_SLIDE_TO_TOP, - wxSHOW_EFFECT_SLIDE_TO_BOTTOM, - wxSHOW_EFFECT_BLEND, - wxSHOW_EFFECT_EXPAND, - wxSHOW_EFFECT_MAX -}; - -// flags for SendSizeEvent() -enum -{ - wxSEND_EVENT_POST = 1 -}; - // ---------------------------------------------------------------------------- // (pseudo)template list classes // ---------------------------------------------------------------------------- -WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLIMPEXP_CORE); +WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLEXPORT); // ---------------------------------------------------------------------------- // global variables // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows; - -// declared here for compatibility only, main declaration is in wx/app.h -extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; +extern WXDLLEXPORT_DATA(wxWindowList) wxTopLevelWindows; +extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; // ---------------------------------------------------------------------------- // wxWindowBase is the base class for all GUI controls/widgets, this is the public @@ -170,7 +128,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; // temporarily switches event handlers). // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowBase : public wxEvtHandler +class WXDLLEXPORT wxWindowBase : public wxEvtHandler { public: // creating the window @@ -180,6 +138,15 @@ public: // Create() wxWindowBase() ; + // pseudo ctor (can't be virtual, called from ctor) + bool CreateBase(wxWindowBase *parent, + wxWindowID winid, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxPanelNameStr); + virtual ~wxWindowBase(); // deleting the window @@ -199,7 +166,7 @@ public: bool DestroyChildren(); // is the window being deleted? - bool IsBeingDeleted() const; + bool IsBeingDeleted() const { return m_isBeingDeleted; } // window attributes // ----------------- @@ -221,6 +188,11 @@ public: wxWindowVariant GetWindowVariant() const { return m_windowVariant; } + // window id uniquely identifies the window among its siblings unless + // it is wxID_ANY which means "don't care" + void SetId( wxWindowID winid ) { m_windowId = winid; } + wxWindowID GetId() const { return m_windowId; } + // get or change the layout direction (LTR or RTL) for this window, // wxLayout_Default is returned if layout direction is not supported virtual wxLayoutDirection GetLayoutDirection() const @@ -234,28 +206,15 @@ public: wxCoord width, wxCoord widthTotal) const; - - // window id uniquely identifies the window among its siblings unless - // it is wxID_ANY which means "don't care" - void SetId( wxWindowID winid ) { m_windowId = winid; } - wxWindowID GetId() const { return m_windowId; } - - // generate a unique id (or count of them consecutively), returns a - // valid id in the auto-id range or wxID_NONE if failed. If using - // autoid management, it will mark the id as reserved until it is - // used (by assigning it to a wxWindowIDRef) or unreserved. - static wxWindowID NewControlId(int count = 1) - { - return wxIdManager::ReserveId(count); - } - - // If an ID generated from NewControlId is not assigned to a wxWindowIDRef, - // it must be unreserved - static void UnreserveControlId(wxWindowID id, int count = 1) - { - wxIdManager::UnreserveId(id, count); - } - + // generate a control id for the controls which were not given one by + // user + static int NewControlId() { return --ms_lastControlId; } + // get the id of the control following the one with the given + // (autogenerated) id + static int NextControlId(int winid) { return winid - 1; } + // get the id of the control preceding the one with the given + // (autogenerated) id + static int PrevControlId(int winid) { return winid + 1; } // moving/resizing // --------------- @@ -367,15 +326,21 @@ public: return wxRect(GetClientAreaOrigin(), GetClientSize()); } +#if wxABI_VERSION >= 20808 // client<->window size conversion - virtual wxSize ClientToWindowSize(const wxSize& size) const; - virtual wxSize WindowToClientSize(const wxSize& size) const; + wxSize ClientToWindowSize(const wxSize& size) const; + wxSize WindowToClientSize(const wxSize& size) const; +#endif // get the size best suited for the window (in fact, minimal // acceptable size using which it will still look "nice" in // most situations) - wxSize GetBestSize() const; - + wxSize GetBestSize() const + { + if (m_bestSizeCache.IsFullySpecified()) + return m_bestSizeCache; + return DoGetBestSize(); + } void GetBestSize(int *w, int *h) const { wxSize s = GetBestSize(); @@ -385,13 +350,6 @@ public: *h = s.y; } - // Determine the best size in the other direction if one of them is - // fixed. This is used with windows that can wrap their contents and - // returns input-independent best size for the others. - int GetBestHeight(int width) const; - int GetBestWidth(int height) const; - - void SetScrollHelper( wxScrollHelper *sh ) { m_scrollHelper = sh; } wxScrollHelper *GetScrollHelper() { return m_scrollHelper; } @@ -405,28 +363,23 @@ public: // This function will merge the window's best size into the window's // minimum size, giving priority to the min size components, and // returns the results. - virtual wxSize GetEffectiveMinSize() const; - - wxDEPRECATED_MSG("use GetEffectiveMinSize() instead") - wxSize GetBestFittingSize() const; - wxDEPRECATED_MSG("use GetEffectiveMinSize() instead") - wxSize GetAdjustedMinSize() const; + wxSize GetEffectiveMinSize() const; + wxDEPRECATED( wxSize GetBestFittingSize() const ); // replaced by GetEffectiveMinSize + wxDEPRECATED( wxSize GetAdjustedMinSize() const ); // replaced by GetEffectiveMinSize // A 'Smart' SetSize that will fill in default size values with 'best' // size. Sets the minsize to what was passed in. void SetInitialSize(const wxSize& size=wxDefaultSize); + wxDEPRECATED( void SetBestFittingSize(const wxSize& size=wxDefaultSize) ); // replaced by SetInitialSize - wxDEPRECATED_MSG("use SetInitialSize() instead") - void SetBestFittingSize(const wxSize& size=wxDefaultSize); - - + // the generic centre function - centers the window on parent by` // default or on screen if it doesn't have parent or // wxCENTER_ON_SCREEN flag is given void Centre(int dir = wxBOTH) { DoCentre(dir); } void Center(int dir = wxBOTH) { DoCentre(dir); } - // centre with respect to the parent window + // centre with respect to the the parent window void CentreOnParent(int dir = wxBOTH) { DoCentre(dir); } void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); } @@ -442,7 +395,7 @@ public: // and it is therefore overridden in wxTLW to do that. // In wxWindow(Base), it has (unfortunately) been abused // to mean the same as SetMinSize() and SetMaxSize(). - + virtual void SetSizeHints( int minW, int minH, int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, int incW = wxDefaultCoord, int incH = wxDefaultCoord ) @@ -453,40 +406,34 @@ public: const wxSize& incSize=wxDefaultSize) { DoSetSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y, incSize.x, incSize.y); } + virtual void DoSetSizeHints( int minW, int minH, + int maxW, int maxH, + int incW, int incH ); -#if WXWIN_COMPATIBILITY_2_8 - // these are useless and do nothing since wxWidgets 2.9 - wxDEPRECATED( virtual void SetVirtualSizeHints( int minW, int minH, - int maxW = wxDefaultCoord, int maxH = wxDefaultCoord ) ); - wxDEPRECATED( void SetVirtualSizeHints( const wxSize& minSize, - const wxSize& maxSize=wxDefaultSize) ); -#endif // WXWIN_COMPATIBILITY_2_8 + // Methods for setting virtual size hints + // FIXME: What are virtual size hints? + + virtual void SetVirtualSizeHints( int minW, int minH, + int maxW = wxDefaultCoord, int maxH = wxDefaultCoord ); + void SetVirtualSizeHints( const wxSize& minSize, + const wxSize& maxSize=wxDefaultSize) + { + SetVirtualSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y); + } - // Call these to override what GetBestSize() returns. This - // method is only virtual because it is overridden in wxTLW + // Call these to override what GetBestSize() returns. This + // method is only virtual because it is overriden in wxTLW // as a different API for SetSizeHints(). - virtual void SetMinSize(const wxSize& minSize); - virtual void SetMaxSize(const wxSize& maxSize); - - // Like Set*Size, but for client, not window, size - virtual void SetMinClientSize(const wxSize& size) - { SetMinSize(ClientToWindowSize(size)); } - virtual void SetMaxClientSize(const wxSize& size) - { SetMaxSize(ClientToWindowSize(size)); } + virtual void SetMinSize(const wxSize& minSize) { m_minWidth = minSize.x; m_minHeight = minSize.y; } + virtual void SetMaxSize(const wxSize& maxSize) { m_maxWidth = maxSize.x; m_maxHeight = maxSize.y; } // Override these methods to impose restrictions on min/max size. - // The easier way is to call SetMinSize() and SetMaxSize() which + // The easier way is to call SetMinSize() and SetMaxSize() which // will have the same effect. Doing both is non-sense. virtual wxSize GetMinSize() const { return wxSize(m_minWidth, m_minHeight); } virtual wxSize GetMaxSize() const { return wxSize(m_maxWidth, m_maxHeight); } - // Like Get*Size, but for client, not window, size - virtual wxSize GetMinClientSize() const - { return WindowToClientSize(GetMinSize()); } - virtual wxSize GetMaxClientSize() const - { return WindowToClientSize(GetMaxSize()); } - // Get the min and max values one by one int GetMinWidth() const { return GetMinSize().x; } int GetMinHeight() const { return GetMinSize().y; } @@ -498,7 +445,7 @@ public: // windows this is just the client area of the window, but for // some like scrolled windows it is more or less independent of // the screen window size. You may override the DoXXXVirtual - // methods below for classes where that is the case. + // methods below for classes where that is is the case. void SetVirtualSize( const wxSize &size ) { DoSetVirtualSize( size.x, size.y ); } void SetVirtualSize( int x, int y ) { DoSetVirtualSize( x, y ); } @@ -532,82 +479,10 @@ public: return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) ); } - // returns the magnification of the content of this window - // eg 2.0 for a window on a retina screen - virtual double GetContentScaleFactor() const - { return 1.0; } - // return the size of the left/right and top/bottom borders in x and y // components of the result respectively virtual wxSize GetWindowBorderSize() const; - // wxSizer and friends use this to give a chance to a component to recalc - // its min size once one of the final size components is known. Override - // this function when that is useful (such as for wxStaticText which can - // stretch over several lines). Parameter availableOtherDir - // tells the item how much more space there is available in the opposite - // direction (-1 if unknown). - virtual bool - InformFirstDirection(int direction, int size, int availableOtherDir); - - // sends a size event to the window using its current size -- this has an - // effect of refreshing the window layout - // - // by default the event is sent, i.e. processed immediately, but if flags - // value includes wxSEND_EVENT_POST then it's posted, i.e. only schedule - // for later processing - virtual void SendSizeEvent(int flags = 0); - - // this is a safe wrapper for GetParent()->SendSizeEvent(): it checks that - // we have a parent window and it's not in process of being deleted - // - // this is used by controls such as tool/status bars changes to which must - // also result in parent re-layout - void SendSizeEventToParent(int flags = 0); - - // this is a more readable synonym for SendSizeEvent(wxSEND_EVENT_POST) - void PostSizeEvent() { SendSizeEvent(wxSEND_EVENT_POST); } - - // this is the same as SendSizeEventToParent() but using PostSizeEvent() - void PostSizeEventToParent() { SendSizeEventToParent(wxSEND_EVENT_POST); } - - // These functions should be used before repositioning the children of - // this window to reduce flicker or, in MSW case, even avoid display - // corruption in some situations (so they're more than just optimization). - // - // EndRepositioningChildren() should be called if and only if - // BeginRepositioningChildren() returns true. To ensure that this is always - // done automatically, use ChildrenRepositioningGuard class below. - virtual bool BeginRepositioningChildren() { return false; } - virtual void EndRepositioningChildren() { } - - // A simple helper which ensures that EndRepositioningChildren() is called - // from its dtor if and only if calling BeginRepositioningChildren() from - // the ctor returned true. - class ChildrenRepositioningGuard - { - public: - // Notice that window can be NULL here, for convenience. In this case - // this class simply doesn't do anything. - wxEXPLICIT ChildrenRepositioningGuard(wxWindowBase* win) - : m_win(win), - m_callEnd(win && win->BeginRepositioningChildren()) - { - } - - ~ChildrenRepositioningGuard() - { - if ( m_callEnd ) - m_win->EndRepositioningChildren(); - } - - private: - wxWindowBase* const m_win; - const bool m_callEnd; - - wxDECLARE_NO_COPY_CLASS(ChildrenRepositioningGuard); - }; - // window state // ------------ @@ -617,43 +492,12 @@ public: virtual bool Show( bool show = true ); bool Hide() { return Show(false); } - // show or hide the window with a special effect, not implemented on - // most platforms (where it is the same as Show()/Hide() respectively) - // - // timeout specifies how long the animation should take, in ms, the - // default value of 0 means to use the default (system-dependent) value - virtual bool ShowWithEffect(wxShowEffect WXUNUSED(effect), - unsigned WXUNUSED(timeout) = 0) - { - return Show(); - } - - virtual bool HideWithEffect(wxShowEffect WXUNUSED(effect), - unsigned WXUNUSED(timeout) = 0) - { - return Hide(); - } - // returns true if window was enabled/disabled, false if nothing done virtual bool Enable( bool enable = true ); bool Disable() { return Enable(false); } virtual bool IsShown() const { return m_isShown; } - // returns true if the window is really enabled and false otherwise, - // whether because it had been explicitly disabled itself or because - // its parent is currently disabled -- then this method returns false - // whatever is the intrinsic state of this window, use IsThisEnabled(0 - // to retrieve it. In other words, this relation always holds: - // - // IsEnabled() == IsThisEnabled() && parent.IsEnabled() - // - bool IsEnabled() const; - - // returns the internal window state independently of the parent(s) - // state, i.e. the state in which the window would be if all its - // parents were enabled (use IsEnabled() above to get the effective - // window state) - bool IsThisEnabled() const { return m_isEnabled; } + virtual bool IsEnabled() const { return m_isEnabled; } // returns true if the window is visible, i.e. IsShown() returns true // if called on it and all its parents up to the first TLW @@ -664,7 +508,7 @@ public: virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; } virtual long GetWindowStyleFlag() const { return m_windowStyle; } - // just some (somewhat shorter) synonyms + // just some (somewhat shorter) synonims void SetWindowStyle( long style ) { SetWindowStyleFlag(style); } long GetWindowStyle() const { return GetWindowStyleFlag(); } @@ -681,12 +525,9 @@ public: virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; } long GetExtraStyle() const { return m_exStyle; } - bool HasExtraStyle(int exFlag) const { return (m_exStyle & exFlag) != 0; } - -#if WXWIN_COMPATIBILITY_2_8 // make the window modal (all other windows unresponsive) - wxDEPRECATED( virtual void MakeModal(bool modal = true) ); -#endif + virtual void MakeModal(bool modal = true); + // (primitive) theming support // --------------------------- @@ -709,78 +550,23 @@ public: static wxWindow *DoFindFocus() /* = 0: implement in derived classes */; - // return true if the window has focus (handles composite windows - // correctly - returns true if GetMainWindowOfCompositeControl() - // has focus) - virtual bool HasFocus() const; - - // can this window have focus in principle? - // - // the difference between AcceptsFocus[FromKeyboard]() and CanAcceptFocus - // [FromKeyboard]() is that the former functions are meant to be - // overridden in the derived classes to simply return false if the - // control can't have focus, while the latter are meant to be used by - // this class clients and take into account the current window state - virtual bool AcceptsFocus() const { return true; } - - // can this window or one of its children accept focus? - // - // usually it's the same as AcceptsFocus() but is overridden for - // container windows - virtual bool AcceptsFocusRecursively() const { return AcceptsFocus(); } + // can this window have focus? + virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); } // can this window be given focus by keyboard navigation? if not, the // only way to give it focus (provided it accepts it at all) is to // click it virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); } - - // Can this window be focused right now, in its current state? This - // shouldn't be called at all if AcceptsFocus() returns false. - // - // It is a convenient helper for the various functions using it below - // but also a hook allowing to override the default logic for some rare - // cases (currently just wxRadioBox in wxMSW) when it's inappropriate. - virtual bool CanBeFocused() const { return IsShown() && IsEnabled(); } - - // can this window itself have focus? - bool IsFocusable() const { return AcceptsFocus() && CanBeFocused(); } - - // can this window have focus right now? - // - // if this method returns true, it means that calling SetFocus() will - // put focus either to this window or one of its children, if you need - // to know whether this window accepts focus itself, use IsFocusable() - bool CanAcceptFocus() const - { return AcceptsFocusRecursively() && CanBeFocused(); } - - // can this window be assigned focus from keyboard right now? - bool CanAcceptFocusFromKeyboard() const - { return AcceptsFocusFromKeyboard() && CanBeFocused(); } - - // call this when the return value of AcceptsFocus() changes - virtual void SetCanFocus(bool WXUNUSED(canFocus)) { } - - // navigates inside this window - bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward) - { return DoNavigateIn(flags); } - - // navigates in the specified direction from this window, this is - // equivalent to GetParent()->NavigateIn() - bool Navigate(int flags = wxNavigationKeyEvent::IsForward) - { return m_parent && ((wxWindowBase *)m_parent)->DoNavigateIn(flags); } - - // this function will generate the appropriate call to Navigate() if the - // key event is one normally used for keyboard navigation and return true - // in this case - bool HandleAsNavigationKey(const wxKeyEvent& event); + // navigates in the specified direction by sending a wxNavigationKeyEvent + virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward); // move this window just before/after the specified one in tab order // (the other window must be our sibling!) void MoveBeforeInTabOrder(wxWindow *win) - { DoMoveInTabOrder(win, OrderBefore); } + { DoMoveInTabOrder(win, MoveBefore); } void MoveAfterInTabOrder(wxWindow *win) - { DoMoveInTabOrder(win, OrderAfter); } + { DoMoveInTabOrder(win, MoveAfter); } // parent/children relations @@ -793,10 +579,12 @@ public: // needed just for extended runtime const wxWindowList& GetWindowChildren() const { return GetChildren() ; } +#if wxABI_VERSION >= 20808 // get the window before/after this one in the parents children list, // returns NULL if this is the first/last window - wxWindow *GetPrevSibling() const { return DoGetSibling(OrderBefore); } - wxWindow *GetNextSibling() const { return DoGetSibling(OrderAfter); } + wxWindow *GetPrevSibling() const { return DoGetSibling(MoveBefore); } + wxWindow *GetNextSibling() const { return DoGetSibling(MoveAfter); } +#endif // wx 2.8.8+ // get the parent or the parent of the parent wxWindow *GetParent() const { return m_parent; } @@ -805,12 +593,8 @@ public: // is this window a top level one? virtual bool IsTopLevel() const; - // is this window a child or grand child of this one (inside the same - // TLW)? - bool IsDescendant(wxWindowBase* win) const; - // it doesn't really change parent, use Reparent() instead - void SetParent( wxWindowBase *parent ); + void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; } // change the real parent of this window, return true if the parent // was changed, false otherwise (error or newParent == oldParent) virtual bool Reparent( wxWindowBase *newParent ); @@ -819,11 +603,6 @@ public: virtual void AddChild( wxWindowBase *child ); virtual void RemoveChild( wxWindowBase *child ); - // returns true if the child is in the client area of the window, i.e. is - // not scrollbar, toolbar etc. - virtual bool IsClientAreaChild(const wxWindow *WXUNUSED(child)) const - { return true; } - // looking for windows // ------------------- @@ -847,7 +626,7 @@ public: // replace the event handler (allows to completely subclass the // window) - void SetEventHandler( wxEvtHandler *handler ); + void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; } // push/pop event handler: allows to chain a custom event handler to // alreasy existing ones @@ -861,59 +640,6 @@ public: // be there) bool RemoveEventHandler(wxEvtHandler *handler); - // Process an event by calling GetEventHandler()->ProcessEvent(): this - // is a straightforward replacement for ProcessEvent() itself which - // shouldn't be used directly with windows as it doesn't take into - // account any event handlers associated with the window - bool ProcessWindowEvent(wxEvent& event) - { return GetEventHandler()->ProcessEvent(event); } - - // Call GetEventHandler()->ProcessEventLocally(): this should be used - // instead of calling ProcessEventLocally() directly on the window - // itself as this wouldn't take any pushed event handlers into account - // correctly - bool ProcessWindowEventLocally(wxEvent& event) - { return GetEventHandler()->ProcessEventLocally(event); } - - // Process an event by calling GetEventHandler()->ProcessEvent() and - // handling any exceptions thrown by event handlers. It's mostly useful - // when processing wx events when called from C code (e.g. in GTK+ - // callback) when the exception wouldn't correctly propagate to - // wxEventLoop. - bool HandleWindowEvent(wxEvent& event) const; - - // disable wxEvtHandler double-linked list mechanism: - virtual void SetNextHandler(wxEvtHandler *handler); - virtual void SetPreviousHandler(wxEvtHandler *handler); - - - // Watcom doesn't allow reducing access with using access declaration, see - // #10749 -#ifndef __WATCOMC__ -protected: - - // NOTE: we change the access specifier of the following wxEvtHandler functions - // so that the user won't be able to call them directly. - // Calling wxWindow::ProcessEvent in fact only works when there are NO - // event handlers pushed on the window. - // To ensure correct operation, instead of wxWindow::ProcessEvent - // you must always call wxWindow::GetEventHandler()->ProcessEvent() - // or HandleWindowEvent(). - // The same holds for all other wxEvtHandler functions. - - using wxEvtHandler::ProcessEvent; - using wxEvtHandler::ProcessEventLocally; -#if wxUSE_THREADS - using wxEvtHandler::ProcessThreadEvent; -#endif - using wxEvtHandler::SafelyProcessEvent; - using wxEvtHandler::ProcessPendingEvents; - using wxEvtHandler::AddPendingEvent; - using wxEvtHandler::QueueEvent; -#endif // __WATCOMC__ - -public: - // validators // ---------- @@ -959,16 +685,16 @@ public: // dialog units translations // ------------------------- - wxPoint ConvertPixelsToDialog( const wxPoint& pt ) const; - wxPoint ConvertDialogToPixels( const wxPoint& pt ) const; - wxSize ConvertPixelsToDialog( const wxSize& sz ) const + wxPoint ConvertPixelsToDialog( const wxPoint& pt ); + wxPoint ConvertDialogToPixels( const wxPoint& pt ); + wxSize ConvertPixelsToDialog( const wxSize& sz ) { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } - wxSize ConvertDialogToPixels( const wxSize& sz ) const + wxSize ConvertDialogToPixels( const wxSize& sz ) { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); @@ -1016,13 +742,13 @@ public: virtual void ClearBackground(); // freeze the window: don't redraw it until it is thawed - void Freeze(); + virtual void Freeze() { } // thaw the window: redraw it after it had been frozen - void Thaw(); + virtual void Thaw() { } // return true if window had been frozen and not unthawed yet - bool IsFrozen() const { return m_freezeCount != 0; } + virtual bool IsFrozen() const { return false; } // adjust DC for drawing on this window virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { } @@ -1099,22 +825,15 @@ public: wxColour GetForegroundColour() const; // Set/get the background style. - virtual bool SetBackgroundStyle(wxBackgroundStyle style); - wxBackgroundStyle GetBackgroundStyle() const - { return m_backgroundStyle; } + // Pass one of wxBG_STYLE_SYSTEM, wxBG_STYLE_COLOUR, wxBG_STYLE_CUSTOM + virtual bool SetBackgroundStyle(wxBackgroundStyle style) { m_backgroundStyle = style; return true; } + virtual wxBackgroundStyle GetBackgroundStyle() const { return m_backgroundStyle; } // returns true if the control has "transparent" areas such as a // wxStaticText and wxCheckBox and the background should be adapted // from a parent window virtual bool HasTransparentBackground() { return false; } - // Returns true if background transparency is supported for this - // window, i.e. if calling SetBackgroundStyle(wxBG_STYLE_TRANSPARENT) - // has a chance of succeeding. If reason argument is non-NULL, returns a - // user-readable explanation of why it isn't supported if the return - // value is false. - virtual bool IsTransparentBackgroundSupported(wxString* reason = NULL) const; - // set/retrieve the font for the window (SetFont() returns true if the // font really changed) virtual bool SetFont(const wxFont& font) = 0; @@ -1143,21 +862,12 @@ public: // get the width/height/... of the text using current or specified // font - void GetTextExtent(const wxString& string, - int *x, int *y, - int *descent = NULL, - int *externalLeading = NULL, - const wxFont *font = NULL) const - { - DoGetTextExtent(string, x, y, descent, externalLeading, font); - } - - wxSize GetTextExtent(const wxString& string) const - { - wxCoord w, h; - GetTextExtent(string, &w, &h); - return wxSize(w, h); - } + virtual void GetTextExtent(const wxString& string, + int *x, int *y, + int *descent = (int *) NULL, + int *externalLeading = (int *) NULL, + const wxFont *theFont = (const wxFont *) NULL) + const = 0; // client <-> screen coords // ------------------------ @@ -1210,19 +920,10 @@ public: virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; #if wxUSE_MENUS - // show popup menu at the given position, generate events for the items - // selected in it bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition) - { return PopupMenu(menu, pos.x, pos.y); } - bool PopupMenu(wxMenu *menu, int x, int y); - - // simply return the id of the selected item or wxID_NONE without - // generating any events - int GetPopupMenuSelectionFromUser(wxMenu& menu, - const wxPoint& pos = wxDefaultPosition) - { return DoGetPopupMenuSelectionFromUser(menu, pos.x, pos.y); } - int GetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y) - { return DoGetPopupMenuSelectionFromUser(menu, x, y); } + { return DoPopupMenu(menu, pos.x, pos.y); } + bool PopupMenu(wxMenu *menu, int x, int y) + { return DoPopupMenu(menu, x, y); } #endif // wxUSE_MENUS // override this method to return true for controls having multiple pages @@ -1232,11 +933,12 @@ public: // scrollbars // ---------- - // can the window have the scrollbar in this orientation? - virtual bool CanScroll(int orient) const; - - // does the window have the scrollbar in this orientation? - bool HasScrollbar(int orient) const; + // does the window have the scrollbar for this orientation? + bool HasScrollbar(int orient) const + { + return (m_windowStyle & + (orient == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL)) != 0; + } // configure the window scrollbars virtual void SetScrollbar( int orient, @@ -1251,7 +953,7 @@ public: // scroll window to the specified position virtual void ScrollWindow( int dx, int dy, - const wxRect* rect = NULL ) = 0; + const wxRect* rect = (wxRect *) NULL ) = 0; // scrolls window by line/page: note that not all controls support this // @@ -1265,20 +967,6 @@ public: bool PageUp() { return ScrollPages(-1); } bool PageDown() { return ScrollPages(1); } - // call this to always show one or both scrollbars, even if the window - // is big enough to not require them - virtual void AlwaysShowScrollbars(bool WXUNUSED(horz) = true, - bool WXUNUSED(vert) = true) - { - } - - // return true if AlwaysShowScrollbars() had been called before for the - // corresponding orientation - virtual bool IsScrollbarAlwaysShown(int WXUNUSED(orient)) const - { - return false; - } - // context-sensitive help // ---------------------- @@ -1287,13 +975,9 @@ public: #if wxUSE_HELP // associate this help text with this window void SetHelpText(const wxString& text); - -#if WXWIN_COMPATIBILITY_2_8 - // Associate this help text with all windows with the same id as this one. - // Don't use this, do wxHelpProvider::Get()->AddHelp(id, text); - wxDEPRECATED( void SetHelpTextForId(const wxString& text) ); -#endif // WXWIN_COMPATIBILITY_2_8 - + // associate this help text with all windows with the same id as this + // one + void SetHelpTextForId(const wxString& text); // get the help string associated with the given position in this window // // notice that pt may be invalid if event origin is keyboard or unknown @@ -1318,28 +1002,22 @@ public: #if wxUSE_TOOLTIPS // the easiest way to set a tooltip for a window is to use this method void SetToolTip( const wxString &tip ); - // attach a tooltip to the window, pointer can be NULL to remove - // existing tooltip + // attach a tooltip to the window void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); } +#if wxABI_VERSION >= 20809 // more readable synonym for SetToolTip(NULL) void UnsetToolTip() { SetToolTip(NULL); } +#endif // wxABI_VERSION >= 2.8.9 // get the associated tooltip or NULL if none wxToolTip* GetToolTip() const { return m_tooltip; } - wxString GetToolTipText() const; - - // Use the same tool tip as the given one (which can be NULL to indicate - // that no tooltip should be used) for this window. This is currently only - // used by wxCompositeWindow::DoSetToolTip() implementation and is not part - // of the public wx API. - // - // Returns true if tip was valid and we copied it or false if it was NULL - // and we reset our own tooltip too. - bool CopyToolTip(wxToolTip *tip); + wxString GetToolTipText() const ; #else // !wxUSE_TOOLTIPS // make it much easier to compile apps in an environment // that doesn't support tooltips, such as PocketPC - void SetToolTip(const wxString & WXUNUSED(tip)) { } + void SetToolTip( const wxString & WXUNUSED(tip) ) {} +#if wxABI_VERSION >= 20809 void UnsetToolTip() { } +#endif // wxABI_VERSION >= 2.8.9 #endif // wxUSE_TOOLTIPS/!wxUSE_TOOLTIPS // drag and drop @@ -1350,14 +1028,12 @@ public: virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0; virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; } +#ifndef __WXMSW__ // MSW version is in msw/window.h +#if wxABI_VERSION >= 20810 // Accept files for dragging - virtual void DragAcceptFiles(bool accept) -#ifdef __WXMSW__ - // it does have common implementation but not for MSW which has its own - // native version of it - = 0 -#endif // __WXMSW__ - ; + void DragAcceptFiles(bool accept); +#endif // wxABI_VERSION >= 20810 +#endif // !__WXMSW__ #endif // wxUSE_DRAG_AND_DROP @@ -1446,11 +1122,10 @@ public: // virtual function for implementing internal idle // behaviour - virtual void OnInternalIdle(); + virtual void OnInternalIdle() {} - // Send idle event to window and all subwindows - // Returns true if more idle time is requested. - virtual bool SendIdleEvents(wxIdleEvent& event); + // call internal idle recursively +// void ProcessInternalIdle() ; // get the handle of the window for the underlying window system: this // is only used for wxWin itself or for user code which wants to call @@ -1489,13 +1164,32 @@ public: // behaviour in the most common case virtual bool ShouldInheritColours() const { return false; } - // returns true if the window can be positioned outside of parent's client - // area (normal windows can't, but e.g. menubar or statusbar can): - virtual bool CanBeOutsideClientArea() const { return false; } +protected: + // event handling specific to wxWindow + virtual bool TryValidator(wxEvent& event); + virtual bool TryParent(wxEvent& event); - // returns true if the platform should explicitly apply a theme border. Currently - // used only by Windows - virtual bool CanApplyThemeBorder() const { return true; } + enum MoveKind + { + MoveBefore, // insert before the given window + MoveAfter // insert after the given window + }; + +#if wxABI_VERSION >= 20808 + // common part of GetPrev/NextSibling() + wxWindow *DoGetSibling(MoveKind order) const; +#endif // wx 2.8.8+ + + // common part of MoveBefore/AfterInTabOrder() + virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move); + +#if wxUSE_CONSTRAINTS + // satisfy the constraints for the windows but don't set the window sizes + void SatisfyConstraints(); +#endif // wxUSE_CONSTRAINTS + + // Send the wxWindowDestroyEvent + void SendDestroyEvent(); // returns the main window of composite control; this is the window // that FindFocus returns if the focus is in one of composite control's @@ -1503,72 +1197,9 @@ public: virtual wxWindow *GetMainWindowOfCompositeControl() { return (wxWindow*)this; } - // If this function returns true, keyboard navigation events shouldn't - // escape from it. A typical example of such "navigation domain" is a top - // level window because pressing TAB in one of them must not transfer focus - // to a different top level window. But it's not limited to them, e.g. MDI - // children frames are not top level windows (and their IsTopLevel() - // returns false) but still are self-contained navigation domains as well. - virtual bool IsTopNavigationDomain() const { return false; } - - -protected: - // helper for the derived class Create() methods: the first overload, with - // validator parameter, should be used for child windows while the second - // one is used for top level ones - bool CreateBase(wxWindowBase *parent, - wxWindowID winid, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxPanelNameStr); - - bool CreateBase(wxWindowBase *parent, - wxWindowID winid, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name); - - // event handling specific to wxWindow - virtual bool TryBefore(wxEvent& event); - virtual bool TryAfter(wxEvent& event); - - enum WindowOrder - { - OrderBefore, // insert before the given window - OrderAfter // insert after the given window - }; - - // common part of GetPrev/NextSibling() - wxWindow *DoGetSibling(WindowOrder order) const; - - // common part of MoveBefore/AfterInTabOrder() - virtual void DoMoveInTabOrder(wxWindow *win, WindowOrder move); - - // implementation of Navigate() and NavigateIn() - virtual bool DoNavigateIn(int flags); - -#if wxUSE_CONSTRAINTS - // satisfy the constraints for the windows but don't set the window sizes - void SatisfyConstraints(); -#endif // wxUSE_CONSTRAINTS - - // Send the wxWindowDestroyEvent if not done yet and sets m_isBeingDeleted - // to true - void SendDestroyEvent(); - - // this method should be implemented to use operating system specific code - // to really enable/disable the widget, it will only be called when we - // really need to enable/disable window and so no additional checks on the - // widgets state are necessary - virtual void DoEnable(bool WXUNUSED(enable)) { } - - // the window id - a number which uniquely identifies a window among // its siblings unless it is wxID_ANY - wxWindowIDRef m_windowId; + wxWindowID m_windowId; // the parent window of this window (or NULL) and the list of the children // of this window @@ -1672,17 +1303,17 @@ protected: wxScrollHelper *m_scrollHelper; + int m_minVirtualWidth; // VirtualSizeHints + int m_minVirtualHeight; + int m_maxVirtualWidth; + int m_maxVirtualHeight; + wxWindowVariant m_windowVariant ; // override this to change the default (i.e. used when no style is // specified) border for the window class virtual wxBorder GetDefaultBorder() const; - // this allows you to implement standard control borders without - // repeating the code in different classes that are not derived from - // wxControl - virtual wxBorder GetDefaultBorderForControl() const { return wxBORDER_THEME; } - // Get the default size for the new window if no explicit size given. TLWs // have their own default size so this is just for non top-level windows. static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; } @@ -1693,10 +1324,8 @@ protected: // recalculated each time the value is needed. wxSize m_bestSizeCache; - wxDEPRECATED_MSG("use SetInitialSize() instead.") - void SetBestSize(const wxSize& size); - wxDEPRECATED_MSG("use SetInitialSize() instead.") - virtual void SetInitialBestSize(const wxSize& size); + wxDEPRECATED( void SetBestSize(const wxSize& size) ); // use SetInitialSize + wxDEPRECATED( virtual void SetInitialBestSize(const wxSize& size) ); // use SetInitialSize @@ -1712,13 +1341,6 @@ protected: // overloaded Something()s in terms of DoSomething() which will be the // only one to be virtual. - // text extent - virtual void DoGetTextExtent(const wxString& string, - int *x, int *y, - int *descent = NULL, - int *externalLeading = NULL, - const wxFont *font = NULL) const = 0; - // coordinates translation virtual void DoClientToScreen( int *x, int *y ) const = 0; virtual void DoScreenToClient( int *x, int *y ) const = 0; @@ -1740,20 +1362,15 @@ protected: // same size as it would have after a call to Fit() virtual wxSize DoGetBestSize() const; - // this method can be overridden instead of DoGetBestSize() if it computes - // the best size of the client area of the window only, excluding borders - // (GetBorderSize() will be used to add them) - virtual wxSize DoGetBestClientSize() const { return wxDefaultSize; } + // called from DoGetBestSize() to convert best virtual size (returned by + // the window sizer) to the best size for the window itself; this is + // overridden at wxScrolledWindow level to clump down virtual size to real + virtual wxSize GetWindowSizeForVirtualSize(const wxSize& size) const + { + return size; + } - // These two methods can be overridden to implement intelligent - // width-for-height and/or height-for-width best size determination for the - // window. By default the fixed best size is used. - virtual int DoGetBestClientHeight(int WXUNUSED(width)) const - { return wxDefaultCoord; } - virtual int DoGetBestClientWidth(int WXUNUSED(height)) const - { return wxDefaultCoord; } - - // this is the virtual function to be overridden in any derived class which + // this is the virtual function to be overriden in any derived class which // wants to change how SetSize() or Move() works - it is called by all // versions of these functions in the base class virtual void DoSetSize(int x, int y, @@ -1763,19 +1380,6 @@ protected: // same as DoSetSize() for the client size virtual void DoSetClientSize(int width, int height) = 0; - virtual void DoSetSizeHints( int minW, int minH, - int maxW, int maxH, - int incW, int incH ); - - // return the total size of the window borders, i.e. the sum of the widths - // of the left and the right border in the x component of the returned size - // and the sum of the heights of the top and bottom borders in the y one - // - // NB: this is currently only implemented properly for wxMSW, wxGTK and - // wxUniv and doesn't behave correctly in the presence of scrollbars in - // the other ports - virtual wxSize DoGetBorderSize() const; - // move the window to the specified location and resize it: this is called // from both DoSetSize() and DoSetClientSize() and would usually just // reposition this window except for composite controls which will want to @@ -1808,46 +1412,23 @@ protected: // implements the window variants virtual void DoSetWindowVariant( wxWindowVariant variant ) ; - - // really freeze/thaw the window (should have port-specific implementation) - virtual void DoFreeze() { } - virtual void DoThaw() { } - - // Must be called when mouse capture is lost to send // wxMouseCaptureLostEvent to windows on capture stack. static void NotifyCaptureLost(); private: - // recursively call our own and our children DoEnable() when the - // enabled/disabled status changed because a parent window had been - // enabled/disabled - void NotifyWindowOnEnableChange(bool enabled); - -#if wxUSE_MENUS - // temporary event handlers used by GetPopupMenuSelectionFromUser() - void InternalOnPopupMenu(wxCommandEvent& event); - void InternalOnPopupMenuUpdate(wxUpdateUIEvent& event); - - // implementation of the public GetPopupMenuSelectionFromUser() method - int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y); -#endif // wxUSE_MENUS - - // layout the window children when its size changes unless this was - // explicitly disabled with SetAutoLayout(false) - void InternalOnSize(wxSizeEvent& event); - - // base for dialog unit conversion, i.e. average character size - wxSize GetDlgUnitBase() const; - - - // number of Freeze() calls minus the number of Thaw() calls: we're frozen - // (i.e. not being updated) if it is positive - unsigned int m_freezeCount; + // contains the last id generated by NewControlId + static int ms_lastControlId; + // the stack of windows which have captured the mouse + static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext; + // the window that currently has mouse capture + static wxWindow *ms_winCaptureCurrent; + // indicates if execution is inside CaptureMouse/ReleaseMouse + static bool ms_winCaptureChanging; DECLARE_ABSTRACT_CLASS(wxWindowBase) - wxDECLARE_NO_COPY_CLASS(wxWindowBase); + DECLARE_NO_COPY_CLASS(wxWindowBase) DECLARE_EVENT_TABLE() }; @@ -1880,7 +1461,14 @@ inline void wxWindowBase::SetInitialBestSize(const wxSize& size) // ---------------------------------------------------------------------------- // include the declaration of the platform-specific class -#if defined(__WXMSW__) +#if defined(__WXPALMOS__) + #ifdef __WXUNIVERSAL__ + #define wxWindowNative wxWindowPalm + #else // !wxUniv + #define wxWindowPalm wxWindow + #endif // wxUniv/!wxUniv + #include "wx/palmos/window.h" +#elif defined(__WXMSW__) #ifdef __WXUNIVERSAL__ #define wxWindowNative wxWindowMSW #else // !wxUniv @@ -1910,6 +1498,9 @@ inline void wxWindowBase::SetInitialBestSize(const wxSize& size) #define wxWindowX11 wxWindow #endif // wxUniv #include "wx/x11/window.h" +#elif defined(__WXMGL__) + #define wxWindowNative wxWindowMGL + #include "wx/mgl/window.h" #elif defined(__WXDFB__) #define wxWindowNative wxWindowDFB #include "wx/dfb/window.h" @@ -1919,7 +1510,7 @@ inline void wxWindowBase::SetInitialBestSize(const wxSize& size) #else // !wxUniv #define wxWindowMac wxWindow #endif // wxUniv - #include "wx/osx/window.h" + #include "wx/mac/window.h" #elif defined(__WXCOCOA__) #ifdef __WXUNIVERSAL__ #define wxWindowNative wxWindowCocoa @@ -1953,7 +1544,7 @@ inline void wxWindowBase::SetInitialBestSize(const wxSize& size) inline wxWindow *wxWindowBase::GetGrandParent() const { - return m_parent ? m_parent->GetParent() : NULL; + return m_parent ? m_parent->GetParent() : (wxWindow *)NULL; } // ---------------------------------------------------------------------------- @@ -1962,20 +1553,21 @@ inline wxWindow *wxWindowBase::GetGrandParent() const // Find the wxWindow at the current mouse position, also returning the mouse // position. -extern WXDLLIMPEXP_CORE wxWindow* wxFindWindowAtPointer(wxPoint& pt); +extern WXDLLEXPORT wxWindow* wxFindWindowAtPointer(wxPoint& pt); // Get the current mouse position. -extern WXDLLIMPEXP_CORE wxPoint wxGetMousePosition(); +extern WXDLLEXPORT wxPoint wxGetMousePosition(); // get the currently active window of this application or NULL -extern WXDLLIMPEXP_CORE wxWindow *wxGetActiveWindow(); +extern WXDLLEXPORT wxWindow *wxGetActiveWindow(); // get the (first) top level parent window -WXDLLIMPEXP_CORE wxWindow* wxGetTopLevelParent(wxWindow *win); +WXDLLEXPORT wxWindow* wxGetTopLevelParent(wxWindow *win); #if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED_MSG("use wxWindow::NewControlId() instead") - inline wxWindowID NewControlId() { return wxWindowBase::NewControlId(); } + // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() + wxDEPRECATED( int NewControlId() ); + inline int NewControlId() { return wxWindowBase::NewControlId(); } #endif // WXWIN_COMPATIBILITY_2_6 #if wxUSE_ACCESSIBILITY @@ -1983,7 +1575,7 @@ WXDLLIMPEXP_CORE wxWindow* wxGetTopLevelParent(wxWindow *win); // accessible object for windows // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowAccessible: public wxAccessible +class WXDLLEXPORT wxWindowAccessible: public wxAccessible { public: wxWindowAccessible(wxWindow* win): wxAccessible(win) { if (win) win->SetAccessible(this); } diff --git a/Source/3rd Party/wx/include/wx/windowid.h b/Source/3rd Party/wx/include/wx/windowid.h deleted file mode 100644 index 0c174b5f0..000000000 --- a/Source/3rd Party/wx/include/wx/windowid.h +++ /dev/null @@ -1,189 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/windowid.h -// Purpose: wxWindowID class - a class for managing window ids -// Author: Brian Vanderburg II -// Created: 2007-09-21 -// Copyright: (c) 2007 Brian Vanderburg II -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WINDOWID_H_ -#define _WX_WINDOWID_H_ - -// NB: do not include defs.h as we are included from it - -typedef int wxWindowID; - -// ---------------------------------------------------------------------------- -// wxWindowIDRef: reference counted id value -// ---------------------------------------------------------------------------- - -// A wxWindowIDRef object wraps an id value and marks it as (un)used as -// necessary. All ids returned from wxWindow::NewControlId() should be assigned -// to an instance of this class to ensure that the id is marked as being in -// use. -// -// This class is always defined but it is trivial if wxUSE_AUTOID_MANAGEMENT is -// off. -class WXDLLIMPEXP_CORE wxWindowIDRef -{ -public: - // default ctor - wxWindowIDRef() - { - m_id = wxID_NONE; - } - - // ctor taking id values - wxWindowIDRef(int id) - { - Init(id); - } - - wxWindowIDRef(long id) - { - Init(wxWindowID(id)); - } - - wxWindowIDRef(const wxWindowIDRef& id) - { - Init(id.m_id); - } - - // dtor - ~wxWindowIDRef() - { - Assign(wxID_NONE); - } - - // assignment - wxWindowIDRef& operator=(int id) - { - Assign(id); - return *this; - } - - wxWindowIDRef& operator=(long id) - { - Assign(wxWindowID(id)); - return *this; - } - - wxWindowIDRef& operator=(const wxWindowIDRef& id) - { - if (&id != this) - Assign(id.m_id); - return *this; - } - - // access to the stored id value - wxWindowID GetValue() const - { - return m_id; - } - - operator wxWindowID() const - { - return m_id; - } - -private: -#if wxUSE_AUTOID_MANAGEMENT - // common part of all ctors: call Assign() for our new id - void Init(wxWindowID id) - { - // m_id must be initialized before calling Assign() - m_id = wxID_NONE; - Assign(id); - } - - // increase reference count of id, decrease the one of m_id - void Assign(wxWindowID id); -#else // !wxUSE_AUTOID_MANAGEMENT - // trivial stubs for the functions above - void Init(wxWindowID id) - { - m_id = id; - } - - void Assign(wxWindowID id) - { - m_id = id; - } -#endif // wxUSE_AUTOID_MANAGEMENT/!wxUSE_AUTOID_MANAGEMENT - - - wxWindowID m_id; -}; - -// comparison operators -inline bool operator==(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs) -{ - return lhs.GetValue() == rhs.GetValue(); -} - -inline bool operator==(const wxWindowIDRef& lhs, int rhs) -{ - return lhs.GetValue() == rhs; -} - -inline bool operator==(const wxWindowIDRef& lhs, long rhs) -{ - return lhs.GetValue() == rhs; -} - -inline bool operator==(int lhs, const wxWindowIDRef& rhs) -{ - return rhs == lhs; -} - -inline bool operator==(long lhs, const wxWindowIDRef& rhs) -{ - return rhs == lhs; -} - -inline bool operator!=(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs) -{ - return !(lhs == rhs); -} - -inline bool operator!=(const wxWindowIDRef& lhs, int rhs) -{ - return !(lhs == rhs); -} - -inline bool operator!=(const wxWindowIDRef& lhs, long rhs) -{ - return !(lhs == rhs); -} - -inline bool operator!=(int lhs, const wxWindowIDRef& rhs) -{ - return !(lhs == rhs); -} - -inline bool operator!=(long lhs, const wxWindowIDRef& rhs) -{ - return !(lhs == rhs); -} - -// ---------------------------------------------------------------------------- -// wxIdManager -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxIdManager -{ -public: - // This returns an id value and not an wxWindowIDRef. The returned value - // should be assigned a.s.a.p to a wxWindowIDRef. The IDs are marked as - // reserved so that another call to ReserveId before assigning the id to a - // wxWindowIDRef will not use the same ID - static wxWindowID ReserveId(int count = 1); - - // This will release an unused reserved ID. This should only be called - // if the ID returned by ReserveId was NOT assigned to a wxWindowIDRef - // for some purpose, maybe an early return from a function - static void UnreserveId(wxWindowID id, int count = 1); -}; - -#endif // _WX_WINDOWID_H_ diff --git a/Source/3rd Party/wx/include/wx/windowptr.h b/Source/3rd Party/wx/include/wx/windowptr.h deleted file mode 100644 index bebcf6ad8..000000000 --- a/Source/3rd Party/wx/include/wx/windowptr.h +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/windowptr.h -// Purpose: smart pointer for holding wxWindow instances -// Author: Vaclav Slavik -// Created: 2013-09-01 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WINDOWPTR_H_ -#define _WX_WINDOWPTR_H_ - -#include "wx/sharedptr.h" - -// ---------------------------------------------------------------------------- -// wxWindowPtr: A smart pointer with correct wxWindow destruction. -// ---------------------------------------------------------------------------- - -namespace wxPrivate -{ - -struct wxWindowDeleter -{ - void operator()(wxWindow *win) - { - win->Destroy(); - } -}; - -} // namespace wxPrivate - -template -class wxWindowPtr : public wxSharedPtr -{ -public: - typedef T element_type; - - wxEXPLICIT wxWindowPtr(element_type* win) - : wxSharedPtr(win, wxPrivate::wxWindowDeleter()) - { - } - - wxWindowPtr() {} - wxWindowPtr(const wxWindowPtr& tocopy) : wxSharedPtr(tocopy) {} - - wxWindowPtr& operator=(const wxWindowPtr& tocopy) - { - wxSharedPtr::operator=(tocopy); - return *this; - } - - wxWindowPtr& operator=(element_type* win) - { - return operator=(wxWindowPtr(win)); - } - - void reset(T* ptr = NULL) - { - wxSharedPtr::reset(ptr, wxPrivate::wxWindowDeleter()); - } -}; - -#endif // _WX_WINDOWPTR_H_ diff --git a/Source/3rd Party/wx/include/wx/withimages.h b/Source/3rd Party/wx/include/wx/withimages.h deleted file mode 100644 index 89120d3eb..000000000 --- a/Source/3rd Party/wx/include/wx/withimages.h +++ /dev/null @@ -1,96 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/withimages.h -// Purpose: Declaration of a simple wxWithImages class. -// Author: Vadim Zeitlin -// Created: 2011-08-17 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WITHIMAGES_H_ -#define _WX_WITHIMAGES_H_ - -#include "wx/defs.h" -#include "wx/icon.h" -#include "wx/imaglist.h" - -// ---------------------------------------------------------------------------- -// wxWithImages: mix-in class providing access to wxImageList. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxWithImages -{ -public: - enum - { - NO_IMAGE = -1 - }; - - wxWithImages() - { - m_imageList = NULL; - m_ownsImageList = false; - } - - virtual ~wxWithImages() - { - FreeIfNeeded(); - } - - // Sets the image list to use, it is *not* deleted by the control. - virtual void SetImageList(wxImageList* imageList) - { - FreeIfNeeded(); - m_imageList = imageList; - } - - // As SetImageList() but we will delete the image list ourselves. - void AssignImageList(wxImageList* imageList) - { - SetImageList(imageList); - m_ownsImageList = true; - } - - // Get pointer (may be NULL) to the associated image list. - wxImageList* GetImageList() const { return m_imageList; } - -protected: - // Return true if we have a valid image list. - bool HasImageList() const { return m_imageList != NULL; } - - // Return the image with the given index from the image list. - // - // If there is no image list or if index == NO_IMAGE, silently returns - // wxNullIcon. - wxIcon GetImage(int iconIndex) const - { - return m_imageList && iconIndex != NO_IMAGE - ? m_imageList->GetIcon(iconIndex) - : wxNullIcon; - } - -private: - // Free the image list if necessary, i.e. if we own it. - void FreeIfNeeded() - { - if ( m_ownsImageList ) - { - delete m_imageList; - m_imageList = NULL; - - // We don't own it any more. - m_ownsImageList = false; - } - } - - - // The associated image list or NULL. - wxImageList* m_imageList; - - // False by default, if true then we delete m_imageList. - bool m_ownsImageList; - - wxDECLARE_NO_COPY_CLASS(wxWithImages); -}; - -#endif // _WX_WITHIMAGES_H_ diff --git a/Source/3rd Party/wx/include/wx/wizard.h b/Source/3rd Party/wx/include/wx/wizard.h deleted file mode 100644 index 82dc438ac..000000000 --- a/Source/3rd Party/wx/include/wx/wizard.h +++ /dev/null @@ -1,337 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/wizard.h -// Purpose: wxWizard class: a GUI control presenting the user with a -// sequence of dialogs which allows to simply perform some task -// Author: Vadim Zeitlin (partly based on work by Ron Kuris and Kevin B. -// Smith) -// Modified by: Robert Cavanaugh -// Added capability to use .WXR resource files in Wizard pages -// Added wxWIZARD_HELP event -// Robert Vazan (sizers) -// Created: 15.08.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WIZARD_H_ -#define _WX_WIZARD_H_ - -#include "wx/defs.h" - -#if wxUSE_WIZARDDLG - -// ---------------------------------------------------------------------------- -// headers and other simple declarations -// ---------------------------------------------------------------------------- - -#include "wx/dialog.h" // the base class -#include "wx/panel.h" // ditto -#include "wx/event.h" // wxEVT_XXX constants -#include "wx/bitmap.h" - -// Extended style to specify a help button -#define wxWIZARD_EX_HELPBUTTON 0x00000010 - -// Placement flags -#define wxWIZARD_VALIGN_TOP 0x01 -#define wxWIZARD_VALIGN_CENTRE 0x02 -#define wxWIZARD_VALIGN_BOTTOM 0x04 -#define wxWIZARD_HALIGN_LEFT 0x08 -#define wxWIZARD_HALIGN_CENTRE 0x10 -#define wxWIZARD_HALIGN_RIGHT 0x20 -#define wxWIZARD_TILE 0x40 - -// forward declarations -class WXDLLIMPEXP_FWD_ADV wxWizard; - -// ---------------------------------------------------------------------------- -// wxWizardPage is one of the wizards screen: it must know what are the -// following and preceding pages (which may be NULL for the first/last page). -// -// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be -// used as such (i.e. controls may be placed directly on it &c). -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxWizardPage : public wxPanel -{ -public: - wxWizardPage() { Init(); } - - // ctor accepts an optional bitmap which will be used for this page instead - // of the default one for this wizard (should be of the same size). Notice - // that no other parameters are needed because the wizard will resize and - // reposition the page anyhow - wxWizardPage(wxWizard *parent, - const wxBitmap& bitmap = wxNullBitmap); - - bool Create(wxWizard *parent, - const wxBitmap& bitmap = wxNullBitmap); - - // these functions are used by the wizard to show another page when the - // user chooses "Back" or "Next" button - virtual wxWizardPage *GetPrev() const = 0; - virtual wxWizardPage *GetNext() const = 0; - - // default GetBitmap() will just return m_bitmap which is ok in 99% of - // cases - override this method if you want to create the bitmap to be used - // dynamically or to do something even more fancy. It's ok to return - // wxNullBitmap from here - the default one will be used then. - virtual wxBitmap GetBitmap() const { return m_bitmap; } - -#if wxUSE_VALIDATORS - // Override the base functions to allow a validator to be assigned to this page. - virtual bool TransferDataToWindow() - { - return GetValidator() ? GetValidator()->TransferToWindow() - : wxPanel::TransferDataToWindow(); - } - - virtual bool TransferDataFromWindow() - { - return GetValidator() ? GetValidator()->TransferFromWindow() - : wxPanel::TransferDataFromWindow(); - } - - virtual bool Validate() - { - return GetValidator() ? GetValidator()->Validate(this) - : wxPanel::Validate(); - } -#endif // wxUSE_VALIDATORS - -protected: - // common part of ctors: - void Init(); - - wxBitmap m_bitmap; - -private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxWizardPage) -}; - -// ---------------------------------------------------------------------------- -// wxWizardPageSimple just returns the pointers given to the ctor and is useful -// to create a simple wizard where the order of pages never changes. -// -// OTOH, it is also possible to dynamically decide which page to return (i.e. -// depending on the user's choices) as the wizard sample shows - in order to do -// this, you must derive from wxWizardPage directly. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxWizardPageSimple : public wxWizardPage -{ -public: - wxWizardPageSimple() { Init(); } - - // ctor takes the previous and next pages - wxWizardPageSimple(wxWizard *parent, - wxWizardPage *prev = NULL, - wxWizardPage *next = NULL, - const wxBitmap& bitmap = wxNullBitmap) - { - Create(parent, prev, next, bitmap); - } - - bool Create(wxWizard *parent = NULL, // let it be default ctor too - wxWizardPage *prev = NULL, - wxWizardPage *next = NULL, - const wxBitmap& bitmap = wxNullBitmap) - { - m_prev = prev; - m_next = next; - return wxWizardPage::Create(parent, bitmap); - } - - // the pointers may be also set later - but before starting the wizard - void SetPrev(wxWizardPage *prev) { m_prev = prev; } - void SetNext(wxWizardPage *next) { m_next = next; } - - // Convenience functions to make the pages follow each other without having - // to call their SetPrev() or SetNext() explicitly. - wxWizardPageSimple& Chain(wxWizardPageSimple* next) - { - SetNext(next); - next->SetPrev(this); - return *next; - } - - static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second) - { - wxCHECK_RET( first && second, - wxT("NULL passed to wxWizardPageSimple::Chain") ); - - first->SetNext(second); - second->SetPrev(first); - } - - // base class pure virtuals - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - -private: - // common part of ctors: - void Init() - { - m_prev = m_next = NULL; - } - - // pointers are private, the derived classes shouldn't mess with them - - // just derive from wxWizardPage directly to implement different behaviour - wxWizardPage *m_prev, - *m_next; - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxWizardPageSimple) -}; - -// ---------------------------------------------------------------------------- -// wxWizard -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxWizardBase : public wxDialog -{ -public: - /* - The derived class (i.e. the real wxWizard) has a ctor and Create() - function taking the following arguments: - - wxWizard(wxWindow *parent, - int id = wxID_ANY, - const wxString& title = wxEmptyString, - const wxBitmap& bitmap = wxNullBitmap, - const wxPoint& pos = wxDefaultPosition, - long style = wxDEFAULT_DIALOG_STYLE); - */ - wxWizardBase() { } - - // executes the wizard starting from the given page, returns true if it was - // successfully finished, false if user cancelled it - virtual bool RunWizard(wxWizardPage *firstPage) = 0; - - // get the current page (NULL if RunWizard() isn't running) - virtual wxWizardPage *GetCurrentPage() const = 0; - - // set the min size which should be available for the pages: a - // wizard will take into account the size of the bitmap (if any) - // itself and will never be less than some predefined fixed size - virtual void SetPageSize(const wxSize& size) = 0; - - // get the size available for the page - virtual wxSize GetPageSize() const = 0; - - // set the best size for the wizard, i.e. make it big enough to contain all - // of the pages starting from the given one - // - // this function may be called several times and possible with different - // pages in which case it will only increase the page size if needed (this - // may be useful if not all pages are accessible from the first one by - // default) - virtual void FitToPage(const wxWizardPage *firstPage) = 0; - - // Adding pages to page area sizer enlarges wizard - virtual wxSizer *GetPageAreaSizer() const = 0; - - // Set border around page area. Default is 0 if you add at least one - // page to GetPageAreaSizer and 5 if you don't. - virtual void SetBorder(int border) = 0; - - // the methods below may be overridden by the derived classes to provide - // custom logic for determining the pages order - - virtual bool HasNextPage(wxWizardPage *page) - { return page->GetNext() != NULL; } - - virtual bool HasPrevPage(wxWizardPage *page) - { return page->GetPrev() != NULL; } - - /// Override these functions to stop InitDialog from calling TransferDataToWindow - /// for _all_ pages when the wizard starts. Instead 'ShowPage' will call - /// TransferDataToWindow for the first page only. - bool TransferDataToWindow() { return true; } - bool TransferDataFromWindow() { return true; } - bool Validate() { return true; } - -private: - wxDECLARE_NO_COPY_CLASS(wxWizardBase); -}; - -// include the real class declaration -#include "wx/generic/wizard.h" - -// ---------------------------------------------------------------------------- -// wxWizardEvent class represents an event generated by the wizard: this event -// is first sent to the page itself and, if not processed there, goes up the -// window hierarchy as usual -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxWizardEvent : public wxNotifyEvent -{ -public: - wxWizardEvent(wxEventType type = wxEVT_NULL, - int id = wxID_ANY, - bool direction = true, - wxWizardPage* page = NULL); - - // for EVT_WIZARD_PAGE_CHANGING, return true if we're going forward or - // false otherwise and for EVT_WIZARD_PAGE_CHANGED return true if we came - // from the previous page and false if we returned from the next one - // (this function doesn't make sense for CANCEL events) - bool GetDirection() const { return m_direction; } - - wxWizardPage* GetPage() const { return m_page; } - - virtual wxEvent *Clone() const { return new wxWizardEvent(*this); } - -private: - bool m_direction; - wxWizardPage* m_page; - - DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWizardEvent) -}; - -// ---------------------------------------------------------------------------- -// macros for handling wxWizardEvents -// ---------------------------------------------------------------------------- - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_CANCEL, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_HELP, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_FINISHED, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_PAGE_SHOWN, wxWizardEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_WIZARD_BEFORE_PAGE_CHANGED, wxWizardEvent ); - -typedef void (wxEvtHandler::*wxWizardEventFunction)(wxWizardEvent&); - -#define wxWizardEventHandler(func) \ - wxEVENT_HANDLER_CAST(wxWizardEventFunction, func) - -#define wx__DECLARE_WIZARDEVT(evt, id, fn) \ - wx__DECLARE_EVT1(wxEVT_WIZARD_ ## evt, id, wxWizardEventHandler(fn)) - -// notifies that the page has just been changed (can't be vetoed) -#define EVT_WIZARD_PAGE_CHANGED(id, fn) wx__DECLARE_WIZARDEVT(PAGE_CHANGED, id, fn) - -// the user pressed "" button and the page is going to be -// changed - unless the event handler vetoes the event -#define EVT_WIZARD_PAGE_CHANGING(id, fn) wx__DECLARE_WIZARDEVT(PAGE_CHANGING, id, fn) - -// Called before GetNext/GetPrev is called, so that the handler can change state that will be -// used when GetNext/GetPrev is called. PAGE_CHANGING is called too late to influence GetNext/GetPrev. -#define EVT_WIZARD_BEFORE_PAGE_CHANGED(id, fn) wx__DECLARE_WIZARDEVT(BEFORE_PAGE_CHANGED, id, fn) - -// the user pressed "Cancel" button and the wizard is going to be dismissed - -// unless the event handler vetoes the event -#define EVT_WIZARD_CANCEL(id, fn) wx__DECLARE_WIZARDEVT(CANCEL, id, fn) - -// the user pressed "Finish" button and the wizard is going to be dismissed - -#define EVT_WIZARD_FINISHED(id, fn) wx__DECLARE_WIZARDEVT(FINISHED, id, fn) - -// the user pressed "Help" button -#define EVT_WIZARD_HELP(id, fn) wx__DECLARE_WIZARDEVT(HELP, id, fn) - -// the page was just shown and laid out -#define EVT_WIZARD_PAGE_SHOWN(id, fn) wx__DECLARE_WIZARDEVT(PAGE_SHOWN, id, fn) - -#endif // wxUSE_WIZARDDLG - -#endif // _WX_WIZARD_H_ diff --git a/Source/3rd Party/wx/include/wx/wrapsizer.h b/Source/3rd Party/wx/include/wx/wrapsizer.h deleted file mode 100644 index a4d614500..000000000 --- a/Source/3rd Party/wx/include/wx/wrapsizer.h +++ /dev/null @@ -1,99 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/wrapsizer.h -// Purpose: provide wrapping sizer for layout (wxWrapSizer) -// Author: Arne Steinarson -// Created: 2008-05-08 -// Copyright: (c) Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WRAPSIZER_H_ -#define _WX_WRAPSIZER_H_ - -#include "wx/sizer.h" - -// flags for wxWrapSizer -enum -{ - wxEXTEND_LAST_ON_EACH_LINE = 1, - // don't leave spacers in the beginning of a new row - wxREMOVE_LEADING_SPACES = 2, - - wxWRAPSIZER_DEFAULT_FLAGS = wxEXTEND_LAST_ON_EACH_LINE | - wxREMOVE_LEADING_SPACES -}; - -// ---------------------------------------------------------------------------- -// A box sizer that can wrap items on several lines when sum of widths exceed -// available line width. -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxWrapSizer : public wxBoxSizer -{ -public: - wxWrapSizer(int orient = wxHORIZONTAL, int flags = wxWRAPSIZER_DEFAULT_FLAGS); - virtual ~wxWrapSizer(); - - // override base class virtual methods - virtual wxSize CalcMin(); - virtual void RecalcSizes(); - - virtual bool InformFirstDirection(int direction, - int size, - int availableOtherDir); - -protected: - // This method is called to decide if an item represents empty space or - // not. We do this to avoid having space-only items first or last on a - // wrapped line (left alignment). - // - // By default only spacers are considered to be empty items but a derived - // class may override this item if some other kind of sizer elements should - // be also considered empty for some reason. - virtual bool IsSpaceItem(wxSizerItem *item) const - { - return item->IsSpacer(); - } - - // helpers of CalcMin() - void CalcMinFromMinor(int totMinor); - void CalcMinFromMajor(int totMajor); - void CalcMinUsingCurrentLayout(); - void CalcMinFittingSize(const wxSize& szBoundary); - void CalcMaxSingleItemSize(); - - // temporarily change the proportion of the last item of the N-th row to - // extend to the end of line if the appropriate flag is set - void AdjustLastRowItemProp(size_t n, wxSizerItem *itemLast); - - // remove all the items from m_rows - void ClearRows(); - - // return the N-th row sizer from m_rows creating it if necessary - wxSizer *GetRowSizer(size_t n); - - // should be called after completion of each row - void FinishRow(size_t n, int rowMajor, int rowMinor, wxSizerItem *itemLast); - - - const int m_flags; // Flags specified in the ctor - - int m_dirInform; // Direction for size information - int m_availSize; // Size available in m_dirInform direction - int m_availableOtherDir; // Size available in the other direction - bool m_lastUsed; // Indicates whether value from InformFirst... has - // been used yet - - // The sizes below are computed by RecalcSizes(), i.e. they don't have - // valid values during the initial call to CalcMin() and they are only - // valid for the current layout (i.e. the current number of rows) - int m_minSizeMinor; // Min size in minor direction - int m_maxSizeMajor; // Size of longest row - int m_minItemMajor; // Size of smallest item in major direction - - wxBoxSizer m_rows; // Sizer containing multiple rows of our items - - DECLARE_DYNAMIC_CLASS_NO_COPY(wxWrapSizer) -}; - -#endif // _WX_WRAPSIZER_H_ diff --git a/Source/3rd Party/wx/include/wx/wupdlock.h b/Source/3rd Party/wx/include/wx/wupdlock.h index 3bf36c550..c30ae00b1 100644 --- a/Source/3rd Party/wx/include/wx/wupdlock.h +++ b/Source/3rd Party/wx/include/wx/wupdlock.h @@ -3,6 +3,7 @@ // Purpose: wxWindowUpdateLocker prevents window redrawing // Author: Vadim Zeitlin // Created: 2006-03-06 +// RCS-ID: $Id: wupdlock.h 37842 2006-03-07 01:50:21Z VZ $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ public: private: wxWindow *m_win; - wxDECLARE_NO_COPY_CLASS(wxWindowUpdateLocker); + DECLARE_NO_COPY_CLASS(wxWindowUpdateLocker) }; #endif // _WX_WUPDLOCK_H_ diff --git a/Source/3rd Party/wx/include/wx/wx.h b/Source/3rd Party/wx/include/wx/wx.h index d91779dad..8c71e8ba1 100644 --- a/Source/3rd Party/wx/include/wx/wx.h +++ b/Source/3rd Party/wx/include/wx/wx.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: wx.h 40943 2006-08-31 19:31:43Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,10 +29,7 @@ #include "wx/memory.h" #include "wx/math.h" #include "wx/stopwatch.h" -#include "wx/timer.h" #include "wx/module.h" -#include "wx/wxcrt.h" -#include "wx/wxcrtvararg.h" #if wxUSE_GUI @@ -61,8 +59,10 @@ #include "wx/icon.h" #include "wx/cursor.h" #include "wx/dialog.h" +#include "wx/timer.h" #include "wx/settings.h" #include "wx/msgdlg.h" +#include "wx/cmndata.h" #include "wx/dataobj.h" #include "wx/control.h" @@ -87,19 +87,12 @@ #include "wx/combobox.h" #include "wx/layout.h" #include "wx/sizer.h" +#include "wx/mdi.h" #include "wx/statusbr.h" #include "wx/choicdlg.h" #include "wx/textdlg.h" #include "wx/filedlg.h" -// this one is included by exactly one file (mdi.cpp) during wx build so even -// although we keep it here for the library users, don't include it to avoid -// bloating the PCH and (worse) rebuilding the entire library when it changes -// when building the library itself -#ifndef WXBUILDING - #include "wx/mdi.h" -#endif - // always include, even if !wxUSE_VALIDATORS because we need wxDefaultValidator #include "wx/validate.h" diff --git a/Source/3rd Party/wx/include/wx/wxchar.h b/Source/3rd Party/wx/include/wx/wxchar.h index 597bbe159..0c33d6c96 100644 --- a/Source/3rd Party/wx/include/wx/wxchar.h +++ b/Source/3rd Party/wx/include/wx/wxchar.h @@ -1,18 +1,1413 @@ -////////////////////////////////////////////////////////////////////////////// -// Name: wx/wxchar.h -// Purpose: Declarations common to wx char/wchar_t usage (wide chars) -// Author: Joel Farley, Ove KÃ¥ven -// Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee -// Created: 1998/06/12 -// Copyright: (c) 1998-2006 wxWidgets dev team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// +/* + * Name: wx/wxchar.h + * Purpose: Declarations common to wx char/wchar_t usage (wide chars) + * Author: Joel Farley, Ove Kaaven + * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee + * Created: 1998/06/12 + * RCS-ID: $Id: wxchar.h 66970 2011-02-19 13:54:14Z VZ $ + * Copyright: (c) 1998-2006 wxWidgets dev team + * Licence: wxWindows licence + */ + +/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ #ifndef _WX_WXCHAR_H_ #define _WX_WXCHAR_H_ -// This header used to define CRT functions wrappers in wxWidgets 2.8. This is -// now done in (headers included by) wx/crt.h, so include it for compatibility: -#include "wx/crt.h" +/* defs.h indirectly includes this file, so don't include it here */ +#include "wx/platform.h" +#include "wx/dlimpexp.h" + +#include /* we use FILE below */ + +#if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS + char *strtok_r(char *, const char *, char **); +#endif + +/* check whether we have wchar_t and which size it is if we do */ +#if !defined(wxUSE_WCHAR_T) + #if defined(__UNIX__) + #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__) + #define wxUSE_WCHAR_T 1 + #else + #define wxUSE_WCHAR_T 0 + #endif + #elif defined(__GNUWIN32__) && !defined(__MINGW32__) + #define wxUSE_WCHAR_T 0 + #elif defined(__WATCOMC__) + #define wxUSE_WCHAR_T 0 + #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400) + #define wxUSE_WCHAR_T 0 + #else + /* add additional compiler checks if this fails */ + #define wxUSE_WCHAR_T 1 + #endif +#endif /* !defined(wxUSE_WCHAR_T) */ + +/* Unicode support requires wchar_t */ +#if wxUSE_UNICODE && !wxUSE_WCHAR_T + #error "wchar_t must be available in Unicode build" +#endif /* Unicode */ + +/* + Standard headers we need here. + + NB: don't include any wxWidgets headers here because almost all of them include + this one! + */ + +/* Required for wxPrintf() etc */ +#include + +/* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */ +/* and VC++ for Windows CE don't provide it */ +#if defined(__VISUALC__) && __VISUALC__ >= 1400 + #define wxStrdupA _strdup +#elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__) + /* use #define, not inline wrapper, as it is tested with #ifndef below */ + #define wxStrdupA strdup +#endif + +/* + non Unix compilers which do have wchar.h (but not tchar.h which is included + below and which includes wchar.h anyhow). + + Actually MinGW has tchar.h, but it does not include wchar.h + */ +#if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__) + #ifndef HAVE_WCHAR_H + #define HAVE_WCHAR_H + #endif +#endif +#if defined(__MWERKS__) && !defined(__MACH__) + #ifndef HAVE_WCSLEN + #define HAVE_WCSLEN + #endif +#endif + +#if wxUSE_WCHAR_T + #ifdef HAVE_WCHAR_H + /* the current (as of Nov 2002) version of cygwin has a bug in its */ + /* wchar.h -- there is no extern "C" around the declarations in it and */ + /* this results in linking errors later; also, at least on some */ + /* Cygwin versions, wchar.h requires sys/types.h */ + #ifdef __CYGWIN__ + #include + #ifdef __cplusplus + extern "C" { + #endif + #endif /* Cygwin */ + + #include + + #if defined(__CYGWIN__) && defined(__cplusplus) + } + #endif /* Cygwin and C++ */ + + #elif defined(HAVE_WCSTR_H) + /* old compilers have relevant declarations here */ + #include + #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__) + /* include stdlib.h for wchar_t */ + #include + #endif /* HAVE_WCHAR_H */ + + #ifdef HAVE_WIDEC_H + #include + #endif +#endif /* wxUSE_WCHAR_T */ + +/* ---------------------------------------------------------------------------- */ +/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */ +/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */ +/* the function mapping _tfoo() -> foo() or wfoo() */ +/* ---------------------------------------------------------------------------- */ + +/* VC++ and BC++ starting with 5.2 have TCHAR support */ +#ifdef __VISUALC__ + #define wxHAVE_TCHAR_SUPPORT +#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520) + #define wxHAVE_TCHAR_SUPPORT + #include + #include +#elif defined(__WATCOMC__) + #define wxHAVE_TCHAR_SUPPORT +#elif defined(__DMC__) + #define wxHAVE_TCHAR_SUPPORT +#elif defined(__WXPALMOS__) + #include +#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 ) + #define wxHAVE_TCHAR_SUPPORT + #include + #include + #include +#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400) + /* VZ: the old VisualAge definitions were completely wrong and had no */ + /* chance at all to work in Unicode build anyhow so let's pretend that */ + /* VisualAge does _not_ support TCHAR for the moment (as indicated by */ + /* "0 &&" above) until someone really has time to delve into Unicode */ + /* issues under OS/2 */ + + /* VisualAge 4.0+ supports TCHAR */ + #define wxHAVE_TCHAR_SUPPORT +#endif /* compilers with (good) TCHAR support */ + +#if defined(__MWERKS__) + /* Metrowerks only has wide char support for OS X >= 10.3 */ + #if !defined(__DARWIN__) || \ + (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) + #define wxHAVE_MWERKS_UNICODE + #endif + + #ifdef wxHAVE_MWERKS_UNICODE + #define HAVE_WPRINTF 1 + #define HAVE_WCSRTOMBS 1 + #define HAVE_VSWPRINTF 1 + #endif +#endif /* __MWERKS__ */ + +#ifdef wxHAVE_TCHAR_SUPPORT + /* get TCHAR definition if we've got it */ + #include + + /* we surely do have wchar_t if we have TCHAR */ + #ifndef wxUSE_WCHAR_T + #define wxUSE_WCHAR_T 1 + #endif /* !defined(wxUSE_WCHAR_T) */ + + /* and we also do have wcslen() */ + #ifndef HAVE_WCSLEN + #define HAVE_WCSLEN + #endif +#endif /* wxHAVE_TCHAR_SUPPORT */ + +/* ---------------------------------------------------------------------------- */ +/* define wxChar type */ +/* ---------------------------------------------------------------------------- */ + +/* TODO: define wxCharInt to be equal to either int or wint_t? */ + +#if !wxUSE_UNICODE + typedef char wxChar; + typedef signed char wxSChar; + typedef unsigned char wxUChar; +#else /* Unicode */ + /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */ + /* signed/unsigned version of it which (a) makes sense to me (unlike */ + /* char wchar_t is always unsigned) and (b) was how the previous */ + /* definitions worked so keep it like this */ + + /* Sun's SunPro compiler supports the wchar_t type and wide character */ + /* functions, but does not define __WCHAR_TYPE__. Define it here to */ + /* allow unicode enabled builds. */ + #if defined(__SUNPRO_CC) || defined(__SUNPRO_C) + #define __WCHAR_TYPE__ wxchar_t + #endif + + /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */ + /* comment below */ + #if !defined(__WCHAR_TYPE__) || \ + (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96)) + /* standard case */ + typedef wchar_t wxChar; + typedef wchar_t wxSChar; + typedef wchar_t wxUChar; + #else /* __WCHAR_TYPE__ and gcc < 2.96 */ + /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. However, */ + /* this doesn't work with new GCC 3.x compilers because wchar_t is */ + /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */ + /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */ + /* have to define wxChar conditionally depending on detected */ + /* compiler & compiler version. */ + /* with old definition of wxChar. */ + typedef __WCHAR_TYPE__ wxChar; + typedef __WCHAR_TYPE__ wxSChar; + typedef __WCHAR_TYPE__ wxUChar; + #endif /* __WCHAR_TYPE__ */ +#endif /* ASCII/Unicode */ + +/* ---------------------------------------------------------------------------- */ +/* define wxT() and related macros */ +/* ---------------------------------------------------------------------------- */ + +#if wxUSE_UNICODE + /* use wxCONCAT_HELPER so that x could be expanded if it's a macro */ + #define wxT(x) wxCONCAT_HELPER(L, x) +#else /* !Unicode */ + #define wxT(x) x +#endif /* Unicode/!Unicode */ + +/* + This macro is defined for forward compatibility with wxWidgets 3. It should + be used in the places where wxWidgets 2 API requires wxT() (in Unicode + build) but wxWidgets 3 doesn't accept it, e.g. wxCmdLineEntryDesc struct + elements initializers. + */ +#define wxT_2(x) wxT(x) + +/* + We define _T() as a synonym of wxT() for backwards compatibility and also + for the benefit of Windows programmers used to it. But this identifier is a + reserved one and this does create problems in practice, notably with Sun CC + which uses it in the recent versions of its standard headers. So avoid + defining it for this compiler at all, unless it was explicitly requested by + predefining wxNEEDS__T macro before including this header or if we're + building wx itself which does need and compiles fine thanks to the special + workarounds for Sun CC in wx/{before,after}std.h. + */ +#ifndef wxNEEDS__T + #if defined(WXBUILDING) || !(defined (__SUNPRO_C) || defined(__SUNPRO_CC)) + #define wxNEEDS__T + #endif +#endif + +#ifdef wxNEEDS__T + /* BSDs define _T() to be something different in ctype.h, override it */ + #if defined(__FreeBSD__) || defined(__DARWIN__) + #include + #endif + #undef _T + + #define _T(x) wxT(x) +#endif /* wxNEEDS__T */ + +/* this macro exists only for forward compatibility with wx 3.0 */ +#define wxS(x) wxT(x) + +/* a helper macro allowing to make another macro Unicode-friendly, see below */ +#define wxAPPLY_T(x) wxT(x) + +/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */ +#ifndef __TFILE__ + #define __TFILE__ wxAPPLY_T(__FILE__) +#endif + +#ifndef __TDATE__ + #define __TDATE__ wxAPPLY_T(__DATE__) +#endif + +#ifndef __TTIME__ + #define __TTIME__ wxAPPLY_T(__TIME__) +#endif + +/* + define wxFoo() function for each standard foo() function whose signature + (exceptionally including the return type) includes any mention of char: + wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have + the same signature but with char replaced by wxChar which allows us to use + it in Unicode build as well + */ + +#ifdef wxHAVE_TCHAR_SUPPORT + #include + + #if defined(__WATCOMC__) && defined(UNICODE) + #define WXWCHAR_T_CAST(c) (wint_t)(c) + #else + #define WXWCHAR_T_CAST(c) c + #endif + + /* ctype.h functions */ + #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c)) + #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c)) + #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c)) + #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c)) + #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c)) + #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c)) + #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c)) + #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c)) + #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c)) + #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c)) + #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c)) + + /* + There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with + signed chars < 0, so "fix" it here. + */ + #define wxTolower(c) _totlower((wxUChar)(c)) + #define wxToupper(c) _totupper((wxUChar)(c)) + + /* locale.h functons */ + #define wxSetlocale _tsetlocale + + /* string.h functions */ + #define wxStrcat _tcscat + #define wxStrchr _tcschr + #define wxStrcmp _tcscmp + #define wxStrcoll _tcscoll + #define wxStrcpy _tcscpy + #define wxStrcspn _tcscspn + #define wxStrdupW _wcsdup /* notice the 'W'! */ + #define wxStrftime _tcsftime + #define wxStricmp _tcsicmp + #define wxStrnicmp _tcsnicmp + #define wxStrlen_ _tcslen /* used in wxStrlen inline function */ + #define wxStrncat _tcsncat + #define wxStrncmp _tcsncmp + #define wxStrncpy _tcsncpy + #define wxStrpbrk _tcspbrk + #define wxStrrchr _tcsrchr + #define wxStrspn _tcsspn + #define wxStrstr _tcsstr + #define wxStrtod _tcstod + #define wxStrtol _tcstol + #define wxStrtoul _tcstoul + #ifdef __VISUALC__ + #if __VISUALC__ >= 1300 && !defined(__WXWINCE__) + #define wxStrtoll _tcstoi64 + #define wxStrtoull _tcstoui64 + #endif /* VC++ 7+ */ + #endif + #define wxStrxfrm _tcsxfrm + + /* stdio.h functions */ + #define wxFgetc _fgettc + #define wxFgetchar _fgettchar + #define wxFgets _fgetts + #if wxUSE_UNICODE_MSLU + WXDLLIMPEXP_BASE FILE * wxMSLU__tfopen(const wxChar *name, const wxChar *mode); + + #define wxFopen wxMSLU__tfopen + #else + #define wxFopen _tfopen + #endif + #define wxFputc _fputtc + #define wxFputchar _fputtchar + #define wxFprintf _ftprintf + #define wxFputs _fputts + #define wxFreopen _tfreopen + #define wxFscanf _ftscanf + #define wxGetc _gettc + #define wxGetchar _gettchar + #define wxGets _getts + #define wxPerror _tperror + #define wxPrintf _tprintf + #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f) + #define wxPutchar _puttchar + #define wxPuts _putts + #define wxScanf _tscanf + #if defined(__DMC__) + #if wxUSE_UNICODE + /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */ + int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ; + #else + /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */ + #define wxSprintf sprintf + #endif + #elif defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) + #if wxUSE_UNICODE + /* MinGW with STLPort 5.1 adds count to swprintf (C99) so prototype conversion see wxchar.cpp */ + int wxSprintf (wchar_t*, const wchar_t*, ...); + #else + /* MinGW with STLPort 5.1 has clashing defines for _stprintf so use sprintf */ + #define wxSprintf sprintf + #endif + #else + #define wxSprintf _stprintf + #endif + + #define wxSscanf _stscanf + #define wxTmpnam _ttmpnam + #define wxUngetc _tungetc + #define wxVfprintf _vftprintf + #define wxVprintf _vtprintf + #define wxVsscanf _vstscanf + #define wxVsprintf _vstprintf + + /* special case: these functions are missing under Win9x with Unicows so we */ + /* have to implement them ourselves */ + #if wxUSE_UNICODE_MSLU + WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname); + WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name); + + #define wxRemove wxMSLU__tremove + #define wxRename wxMSLU__trename + #else + #ifdef __WXWINCE__ + /* carefully: wxRemove() must return 0 on success while DeleteFile() + returns 0 on error, so don't just define one as the other */ + int wxRemove(const wxChar *path); + #else + #define wxRemove _tremove + #define wxRename _trename + #endif + #endif + + /* stdlib.h functions */ + #define wxAtoi _ttoi + #define wxAtol _ttol + /* #define wxAtof _tttof -- notice that there is no such thing (why?) */ + /* there are no env vars at all under CE, so no _tgetenv neither */ + #ifdef __WXWINCE__ + /* can't define as inline function as this is a C file... */ + #define wxGetenv(name) ((wxChar *)NULL) + #else + #define wxGetenv _tgetenv + #endif + #define wxSystem _tsystem + + /* time.h functions */ + #define wxAsctime _tasctime + #define wxCtime _tctime + + #define wxMbstowcs mbstowcs + #define wxWcstombs wcstombs +#else /* !TCHAR-aware compilers */ + /* + There are 2 unrelated problems with these functions under Mac: + a) Metrowerks MSL CRT implements them strictly in C99 sense and + doesn't support (very common) extension of allowing to call + mbstowcs(NULL, ...) which makes it pretty useless as you can't + know the size of the needed buffer + b) OS X <= 10.2 declares and even defined these functions but + doesn't really implement them -- they always return an error + + So use our own replacements in both cases. + */ + #if defined(__MWERKS__) && defined(__MSL__) + #define wxNEED_WX_MBSTOWCS + #endif + + #ifdef __DARWIN__ + #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 + #define wxNEED_WX_MBSTOWCS + #endif + #endif + + #ifdef wxNEED_WX_MBSTOWCS + /* even though they are defined and "implemented", they are bad and just + stubs so we need our own - we need these even in ANSI builds!! */ + WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t); + WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t); + #else + #define wxMbstowcs mbstowcs + #define wxWcstombs wcstombs + #endif + + /* + The system C library on Mac OS X 10.2 and below does not support + unicode: in other words all wide-character functions such as towupper et + al. do simply not exist so we need to provide our own in that context, + except for the wchar_t definition/typedef itself. + + We need to do this for both project builder and CodeWarrior as + the latter uses the system C library in Mach builds for wide character + support, which as mentioned does not exist on 10.2 and below. + */ + #if wxUSE_UNICODE && \ + defined(__DARWIN__) && \ + ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 ) + /* we need everything! */ + #define wxNEED_WX_STRING_H + #define wxNEED_WX_CTYPE_H + + #define wxFgetchar(c) wxFgetc(c, stdin) + #define wxFputc wxPutc + #define wxFputchar(c) wxPutc(c, stdout) + #define wxGetc wxFgetc + #define wxGetchar(c) wxFgetc(c, stdin) + + #include + + #define wxNEED_FGETC + #define wxNEED_FGETS + #define wxNEED_GETS + #define wxNEED_UNGETC + + #define wxNEED_FPUTS + #define wxNEED_PUTS + #define wxNEED_PUTC + + int wxFputs(const wxChar *ch, FILE *stream); + int wxPuts(const wxChar *ws); + int wxPutc(wxChar ch, FILE *stream); + + #ifdef __cplusplus + extern "C" { + #endif + WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s); + #ifdef __cplusplus + } + #endif + + #define wxPutchar(wch) wxPutc(wch, stdout) + + #define wxNEED_PRINTF_CONVERSION + #define wxNEED_WX_STDIO_H + #define wxNEED_WX_STDLIB_H + #define wxNEED_WX_TIME_H + + #elif wxUSE_UNICODE + #include + + /* this is probably glibc-specific */ + #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__) + /* ctype.h functions (wctype.h) */ + #define wxIsalnum iswalnum + #define wxIsalpha iswalpha + #define wxIscntrl iswcntrl + #define wxIsdigit iswdigit + #define wxIsgraph iswgraph + #define wxIslower iswlower + #define wxIsprint iswprint + #define wxIspunct iswpunct + #define wxIsspace iswspace + #define wxIsupper iswupper + #define wxIsxdigit iswxdigit + + #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) + /* /usr/include/wctype.h incorrectly declares translations */ + /* tables which provokes tons of compile-time warnings -- try */ + /* to correct this */ + #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower) + #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper) + #else /* !glibc 2.0 */ + #define wxTolower towlower + #define wxToupper towupper + #endif /* gcc/!gcc */ + + /* string.h functions (wchar.h) */ + #define wxStrcat wcscat + #define wxStrchr wcschr + #define wxStrcmp wcscmp + #define wxStrcoll wcscoll + #define wxStrcpy wcscpy + #define wxStrcspn wcscspn + #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */ + #define wxStrncat wcsncat + #define wxStrncmp wcsncmp + #define wxStrncpy wcsncpy + #define wxStrpbrk wcspbrk + #define wxStrrchr wcsrchr + #define wxStrspn wcsspn + #define wxStrstr wcsstr + #define wxStrtod wcstod + #define wxStrtol wcstol + #define wxStrtoul wcstoul + #ifdef HAVE_WCSTOULL + /* assume that we have wcstoull(), which is also C99, too */ + #define wxStrtoll wcstoll + #define wxStrtoull wcstoull + #endif /* HAVE_WCSTOULL */ + #define wxStrxfrm wcsxfrm + + #define wxFgetc fgetwc + #define wxFgetchar fgetwchar + #define wxFgets fgetws + #define wxFputc fputwc + #define wxFputchar fputwchar + #define wxGetc getwc + #define wxGetchar getwchar + #define wxGets getws + #define wxUngetc ungetwc + + #ifdef HAVE_FPUTWS + #define wxFputs fputws + #else + #define wxNEED_FPUTS + #include + int wxFputs(const wxChar *ch, FILE *stream); + #endif + + #ifdef HAVE_WPUTC + #define wxPutc wputc + #else + #define wxNEED_PUTC + #include + int wxPutc(wxChar ch, FILE *stream); + #endif + + #ifdef HAVE_WPUTCHAR + #define wxPutchar wputchar + #else + #define wxPutchar(wch) wxPutc(wch, stdout) + #endif + + #ifdef HAVE_PUTWS + #define wxPuts putws + #else + #define wxNEED_PUTS + int wxPuts(const wxChar *ws); + #endif + + /* we need %s to %ls conversion for printf and scanf etc */ + #define wxNEED_PRINTF_CONVERSION + + /* glibc doesn't have wide char equivalents of the other stuff so */ + /* use our own versions */ + #define wxNEED_WX_STDIO_H + #define wxNEED_WX_STDLIB_H + #define wxNEED_WX_TIME_H + #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) ) + /* ctype.h functions (wctype.h) */ + #define wxIsalnum iswalnum + #define wxIsalpha iswalpha + #define wxIscntrl iswcntrl + #define wxIsdigit iswdigit + #define wxIsgraph iswgraph + #define wxIslower iswlower + #define wxIsprint iswprint + #define wxIspunct iswpunct + #define wxIsspace iswspace + #define wxIsupper iswupper + #define wxIsxdigit iswxdigit + #define wxTolower towlower + #define wxToupper towupper + + /* string.h functions (wchar.h) */ + #define wxStrcat wcscat + #define wxStrchr wcschr + #define wxStrcmp wcscmp + #define wxStrcoll wcscoll + #define wxStrcpy wcscpy + #define wxStrcspn wcscspn + #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */ + #define wxStrncat wcsncat + #define wxStrncmp wcsncmp + #define wxStrncpy wcsncpy + #define wxStrpbrk wcspbrk + #define wxStrrchr wcsrchr + #define wxStrspn wcsspn + #define wxStrstr wcsstr + #define wxStrtod wcstod + #define wxStrtol wcstol + #define wxStrtoul wcstoul + #define wxStrxfrm wcsxfrm + + #define wxFgetc fgetwc + #define wxFgetchar fgetwchar + #define wxFgets fgetws + #define wxFputc fputwc + #define wxFputchar fputwchar + #define wxGetc getwc + #define wxGetchar getwchar + #define wxGets getws + #define wxUngetc ungetwc + + #define wxNEED_PRINTF_CONVERSION + + #define wxPutc putwc + #define wxPutchar putwchar + #define wxFputs fputws + + /* stdio.h functions */ + + #define wxNEED_WX_STDIO_H + + /* stdlib.h functions */ + #ifdef __MACH__ + #define wxNEED_WX_STDLIB_H + #else + #define wxAtof watof + #define wxAtoi watoi + #define wxAtol watol + #define wxGetenv(a) ((wxChar*)NULL) + #define wxSystem(a) ((int)NULL) + #endif + /* time.h functions */ + #define wxAsctime wasciitime + #define wxCtime wctime + /* #define wxStrftime wcsftime */ + + #define wxNEED_WX_TIME_H + #else /* !metrowerks for apple */ + #error "Please define wide character functions for your environment" + #endif + #else /* ASCII */ + #include + #include + + /* ctype.h functions */ + #define wxIsalnum isalnum + #define wxIsalpha isalpha + #define wxIscntrl iscntrl + #define wxIsdigit isdigit + #define wxIsgraph isgraph + #define wxIslower islower + #define wxIsprint isprint + #define wxIspunct ispunct + #define wxIsspace isspace + #define wxIsupper isupper + #define wxIsxdigit isxdigit + #define wxTolower tolower + #define wxToupper toupper + + /* locale.h functons */ + #define wxSetlocale setlocale + + /* string.h functions */ + #define wxStrcat strcat + #define wxStrchr strchr + #define wxStrcmp strcmp + #define wxStrcoll strcoll + #define wxStrcpy strcpy + #define wxStrcspn strcspn + + /* wxStricmp and wxStrnicmp are defined below */ + #define wxStrlen_ strlen /* used in wxStrlen inline function */ + #define wxStrncat strncat + #define wxStrncmp strncmp + #define wxStrncpy strncpy + #define wxStrpbrk strpbrk + #define wxStrrchr strrchr + #define wxStrspn strspn + #define wxStrstr strstr + #define wxStrtod strtod + #ifdef HAVE_STRTOK_R + #define wxStrtok(str, sep, last) strtok_r(str, sep, last) + #endif + #define wxStrtol strtol + #define wxStrtoul strtoul + #ifdef HAVE_STRTOULL + /* assume that we have wcstoull(), which is also C99, too */ + #define wxStrtoll strtoll + #define wxStrtoull strtoull + #endif /* HAVE_WCSTOULL */ + #define wxStrxfrm strxfrm + + /* stdio.h functions */ + #define wxFopen fopen + #define wxFreopen freopen + #define wxRemove remove + #define wxRename rename + + #define wxPerror perror + #define wxTmpnam tmpnam + + #define wxFgetc fgetc + #define wxFgetchar fgetchar + #define wxFgets fgets + #define wxFputc fputc + #define wxFputs fputs + #define wxFputchar fputchar + #define wxFprintf fprintf + #define wxFscanf fscanf + #define wxGetc getc + #define wxGetchar getchar + #define wxGets gets + #define wxPrintf printf + #define wxPutc putc + #define wxPutchar putchar + #define wxPuts puts + #define wxScanf scanf + #define wxSprintf sprintf + #define wxSscanf sscanf + #define wxUngetc ungetc + #define wxVfprintf vfprintf + #define wxVprintf vprintf + #define wxVsscanf vsscanf + #define wxVsprintf vsprintf + + /* stdlib.h functions */ + #define wxAtof atof + #define wxAtoi atoi + #define wxAtol atol + #define wxGetenv getenv + #define wxSystem system + + /* time.h functions */ + #define wxAsctime asctime + #define wxCtime ctime + #define wxStrftime strftime + #endif /* Unicode/ASCII */ +#endif /* TCHAR-aware compilers/the others */ + +#ifdef wxStrtoll + #define wxHAS_STRTOLL +#endif + +/* + various special cases + */ + +/* define wxStricmp and wxStrnicmp for various compilers */ + +/* note that in Unicode mode we definitely are going to need our own version */ +#if !defined(wxStricmp) && !wxUSE_UNICODE + #if defined(__BORLANDC__) || defined(__WATCOMC__) || \ + defined(__SALFORDC__) || defined(__VISAGECPP__) || \ + defined(__EMX__) || defined(__DJGPP__) + #define wxStricmp stricmp + #define wxStrnicmp strnicmp + #elif defined(__WXPALMOS__) + /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This + * quick hack should do until one can be written. + */ + #define wxStricmp StrCaselessCompare + #define wxStrnicmp strnicmp + #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \ + (defined(__MWERKS__) && defined(__INTEL__)) + #define wxStricmp _stricmp + #define wxStrnicmp _strnicmp + #elif defined(__UNIX__) || defined(__GNUWIN32__) + #define wxStricmp strcasecmp + #define wxStrnicmp strncasecmp + /* #else -- use wxWidgets implementation */ + #endif +#endif /* !defined(wxStricmp) */ + +/* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */ +/* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */ +/* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */ +#if wxUSE_WCHAR_T + #ifdef HAVE_WCSLEN + #define wxWcslen wcslen + #else + WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s); + #endif +#endif /* wxUSE_WCHAR_T */ + +#ifdef __cplusplus +/* checks whether the passed in pointer is NULL and if the string is empty */ +inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; } + +/* safe version of strlen() (returns 0 if passed NULL pointer) */ +inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; } +#endif + +/* + each of strdup() and wcsdup() may or may not be available but we need both + of them anyhow for wx/buffer.h so we define the missing one(s) in + wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW + defined -- if this is somehow not the case in some situations, please + correct that and not the lines here + */ +#if wxUSE_UNICODE + #define wxStrdup wxStrdupW +#else + #define wxStrdup wxStrdupA +#endif + +#ifdef __cplusplus +WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ +#endif + +/* printf() family saga */ + +/* + For some systems [v]snprintf() exists in the system libraries but not in the + headers, so we need to declare it ourselves to be able to use it. + */ +#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL) +#ifdef __cplusplus + extern "C" +#else + extern +#endif + int vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif /* !HAVE_VSNPRINTF_DECL */ + +#if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL) +#ifdef __cplusplus + extern "C" +#else + extern +#endif + WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...); +#endif /* !HAVE_SNPRINTF_DECL */ + +/* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the + * same isn't done for snprintf below, the builtin wxSnprintf_ is used + * instead since it's already a simple wrapper */ +#if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL + inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap) + { + return vsnprintf(str, size, (char*)format, ap); + } +#endif + +/* + MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility + presumably) and normally _vsnwprintf() is used instead (but as + STLPort 5.1 defines standard vswprintf(), don't do this for it) + */ +#if defined(HAVE_VSWPRINTF) && defined(__MINGW32__) && !( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) + #undef HAVE_VSWPRINTF +#endif + +#if wxUSE_PRINTF_POS_PARAMS + /* + The systems where vsnprintf() supports positional parameters should + define the HAVE_UNIX98_PRINTF symbol. + + On systems which don't (e.g. Windows) we are forced to use + our wxVsnprintf() implementation. + */ + #if defined(HAVE_UNIX98_PRINTF) + #if wxUSE_UNICODE + #ifdef HAVE_VSWPRINTF + #define wxVsnprintf_ vswprintf + #endif + #else /* ASCII */ + #ifdef HAVE_BROKEN_VSNPRINTF_DECL + #define wxVsnprintf_ wx_fixed_vsnprintf + #else + #define wxVsnprintf_ vsnprintf + #endif + #endif + #else /* !HAVE_UNIX98_PRINTF */ + /* + The only compiler with positional parameters support under Windows + is VC++ 8.0 which provides a new xxprintf_p() functions family. + The 2003 PSDK includes a slightly earlier version of VC8 than the + main release and does not have the printf_p functions. + */ + #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__ + #if wxUSE_UNICODE + #define wxVsnprintf_ _vswprintf_p + #else + #define wxVsnprintf_ _vsprintf_p + #endif + #endif + #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */ +#else /* !wxUSE_PRINTF_POS_PARAMS */ + /* + We always want to define safe snprintf() function to be used instead of + sprintf(). Some compilers already have it (or rather vsnprintf() which + we really need...), otherwise we implement it using our own printf() + code. + + We define function with a trailing underscore here because the real one + is a wrapper around it as explained below + */ + + /* first deal with TCHAR-aware compilers which have _vsntprintf */ + #ifndef wxVsnprintf_ + #if defined(__VISUALC__) || \ + (defined(__BORLANDC__) && __BORLANDC__ >= 0x540) + #define wxVsnprintf_ _vsntprintf + #define wxSnprintf_ _sntprintf + #endif + #endif + + /* if this didn't work, define it separately for Unicode and ANSI builds */ + #ifndef wxVsnprintf_ + #if wxUSE_UNICODE + #if defined(HAVE__VSNWPRINTF) + #define wxVsnprintf_ _vsnwprintf + #elif defined(HAVE_VSWPRINTF) + #define wxVsnprintf_ vswprintf + #elif defined(__WATCOMC__) + #define wxVsnprintf_ _vsnwprintf + #define wxSnprintf_ _snwprintf + #endif + #else /* ASCII */ + /* + All versions of CodeWarrior supported by wxWidgets apparently + have both snprintf() and vsnprintf() + */ + #if defined(HAVE_SNPRINTF) \ + || defined(__MWERKS__) || defined(__WATCOMC__) + #ifndef HAVE_BROKEN_SNPRINTF_DECL + #define wxSnprintf_ snprintf + #endif + #endif + #if defined(HAVE_VSNPRINTF) \ + || defined(__MWERKS__) || defined(__WATCOMC__) + #ifdef HAVE_BROKEN_VSNPRINTF_DECL + #define wxVsnprintf_ wx_fixed_vsnprintf + #else + #define wxVsnprintf_ vsnprintf + #endif + #endif + #endif /* Unicode/ASCII */ + #endif /* wxVsnprintf_ */ +#endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */ + +#ifndef wxSnprintf_ + /* no snprintf(), cook our own */ + WXDLLIMPEXP_BASE int + wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) ATTRIBUTE_PRINTF_3; +#endif +#ifndef wxVsnprintf_ + /* no (suitable) vsnprintf(), cook our own */ + WXDLLIMPEXP_BASE int + wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format, va_list argptr); + + #define wxUSE_WXVSNPRINTF 1 +#else + #define wxUSE_WXVSNPRINTF 0 +#endif + +/* + In Unicode mode we need to have all standard functions such as wprintf() and + so on but not all systems have them so use our own implementations in this + case. + */ +#if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF) + #define wxNEED_WPRINTF +#endif + +/* + More Unicode complications: although both ANSI C and C++ define a number of + wide character functions such as wprintf(), not all environments have them. + Worse, those which do have different behaviours: under Windows, %s format + specifier changes its meaning in Unicode build and expects a Unicode string + while under Unix/POSIX it still means an ASCII string even for wprintf() and + %ls has to be used for wide strings. + + We choose to always emulate Windows behaviour as more useful for us so even + if we have wprintf() we still must wrap it in a non trivial wxPrintf(). + +*/ + +#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF) + /* + we need to implement all wide character printf and scanf functions + either because we don't have them at all or because they don't have the + semantics we need + */ + int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1; + int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2; + int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2; + int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap ); + int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1; + int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2; + int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2; + int wxVfprintf( FILE *stream, const wxChar *format, va_list ap ); + int wxVprintf( const wxChar *format, va_list ap ); + int wxVsprintf( wxChar *str, const wxChar *format, va_list ap ); +#endif /* wxNEED_PRINTF_CONVERSION */ + +/* these 2 can be simply mapped to the versions with underscore at the end */ +/* if we don't have to do the conversion */ +/* + However, if we don't have any vswprintf() at all we don't need to redefine + anything as our own wxVsnprintf_() already behaves as needed. +*/ +#if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_) + int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3; + int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap ); +#else + #define wxSnprintf wxSnprintf_ + #define wxVsnprintf wxVsnprintf_ +#endif + +/* + various functions which might not be available in libc and for which we + provide our own replacements in wxchar.cpp + */ + +/* ctype.h functions */ + +/* RN: Used only under OSX <= 10.2 currently */ +#ifdef wxNEED_WX_CTYPE_H + WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch); + WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch); + WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch); + WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch); + WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch); + WXDLLIMPEXP_BASE int wxIslower(wxChar ch); + WXDLLIMPEXP_BASE int wxIsprint(wxChar ch); + WXDLLIMPEXP_BASE int wxIspunct(wxChar ch); + WXDLLIMPEXP_BASE int wxIsspace(wxChar ch); + WXDLLIMPEXP_BASE int wxIsupper(wxChar ch); + WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch); + WXDLLIMPEXP_BASE int wxTolower(wxChar ch); + WXDLLIMPEXP_BASE int wxToupper(wxChar ch); +#endif /* wxNEED_WX_CTYPE_H */ + +/* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */ +/* the file parsing -- this may be true for 5.0 as well, update #ifdef then */ +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE + #undef wxIsspace + #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c)) +#endif /* VC++ */ + +/* + a few compilers don't have the (non standard but common) isascii function, + define it ourselves for them + */ +#ifndef isascii + #if defined(__MWERKS__) + #define wxNEED_ISASCII + #elif defined(_WIN32_WCE) + #if _WIN32_WCE <= 211 + #define wxNEED_ISASCII + #endif + #endif +#endif /* isascii */ + +#ifdef wxNEED_ISASCII + inline int isascii(int c) { return (unsigned)c < 0x80; } +#endif + +#ifdef _WIN32_WCE + #if _WIN32_WCE <= 211 + #define isspace(c) ((c) == wxT(' ') || (c) == wxT('\t')) + #endif +#endif /* _WIN32_WCE */ + +/* + we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the + initial versions of this header -- now it is too late to remove it so + although we fixed the function/macro name above, still provide the + backwards-compatible synonym. + */ +#define wxIsctrl wxIscntrl + +/* string.h functions */ +#ifndef strdup + #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000) + #define wxNEED_STRDUP + #elif defined(__WXWINCE__) + #if _WIN32_WCE <= 211 + #define wxNEED_STRDUP + #endif + #endif +#endif /* strdup */ + +#ifdef wxNEED_STRDUP + WXDLLIMPEXP_BASE char *strdup(const char* s); +#endif + +/* RN: Used only under OSX <= 10.2 currently + The __cplusplus ifdefs are messy, but they are required to build + the regex library, since c does not support function overloading +*/ +#ifdef wxNEED_WX_STRING_H +# ifdef __cplusplus + extern "C" { +# endif + WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src); + WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c); + WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2); + WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2); + WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src); + WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject); + WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n); + WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n); + WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n); + WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept); + WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c); + WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept); + WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle); +# ifdef __cplusplus + } +# endif + + /* These functions use C++, so we can't c extern them */ + WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr); + WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base); + WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base); + WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n); + + /* inlined versions */ + #ifdef __cplusplus + inline wxChar * wxStrchr(wxChar *s, wxChar c) + { return (wxChar *)wxStrchr((const wxChar *)s, c); } + inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept) + { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); } + inline wxChar * wxStrrchr(wxChar *s, wxChar c) + { return (wxChar *)wxStrrchr((const wxChar *)s, c); } + inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle) + { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); } + #endif + +#endif /* wxNEED_WX_STRING_H */ + +#ifndef wxStrdupA +WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz); +#endif + +#ifndef wxStrdupW +WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz); +#endif + +#ifndef wxStricmp +WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2); +#endif + +#ifndef wxStrnicmp +WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len); +#endif + +#ifndef wxStrtok +WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr); +#endif + +#ifdef __cplusplus +#ifndef wxSetlocale +class WXDLLIMPEXP_BASE wxWCharBuffer; +WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale); +#endif +#endif + +/* stdio.h functions */ +#ifdef wxNEED_WX_STDIO_H + #include + WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode); + WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream); + WXDLLIMPEXP_BASE int wxRemove(const wxChar *path); + WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath); + + /* *printf() family is handled separately */ +#endif /* wxNEED_WX_STDIO_H */ + + +/* stdlib.h functions */ +#ifndef wxAtof +WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz); +#endif + +/* + mingw32 doesn't provide _tsystem() even though it does provide all the other + stdlib.h functions wrappers so check for it separately: + */ +#if defined(__MINGW32__) && wxUSE_UNICODE && !defined(_tsystem) + #define wxNEED_WXSYSTEM +#endif + +#ifdef wxNEED_WX_STDLIB_H +WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz); +WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz); +WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name); +#define wxNEED_WXSYSTEM +#endif + +#ifdef wxNEED_WXSYSTEM +WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz); +#endif + + +/* time.h functions */ +#ifdef wxNEED_WX_TIME_H +#if defined(__MWERKS__) && defined(macintosh) + #include +#endif + /*silent gabby compilers*/ + struct tm; + WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max, + const wxChar *fmt, const struct tm *tm); +#endif /* wxNEED_WX_TIME_H */ + +#ifndef wxCtime +#include +WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep); +#endif + + +/* missing functions in some WinCE versions */ +#ifdef _WIN32_WCE +#if (_WIN32_WCE < 300) +WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size ); +#endif +#endif /* _WIN32_WCE */ + +/* multibyte to wide char conversion functions and macros */ + +#if wxUSE_WCHAR_T + /* multibyte<->widechar conversion */ + WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n); + WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); + + #if wxUSE_UNICODE + #define wxMB2WX wxMB2WC + #define wxWX2MB wxWC2MB + #define wxWC2WX wxStrncpy + #define wxWX2WC wxStrncpy + #else + #define wxMB2WX wxStrncpy + #define wxWX2MB wxStrncpy + #define wxWC2WX wxWC2MB + #define wxWX2WC wxMB2WC + #endif +#else /* !wxUSE_UNICODE */ +/* Why is this here? +#error ha */ + /* No wxUSE_WCHAR_T: we have to do something (JACS) */ + #define wxMB2WC wxStrncpy + #define wxWC2MB wxStrncpy + #define wxMB2WX wxStrncpy + #define wxWX2MB wxStrncpy + #define wxWC2WX wxWC2MB + #define wxWX2WC wxMB2WC +#endif + +/* + RN: The following are not normal versions of memcpy et al., rather + these are either char or widechar versions depending on + if unicode is used or not. +*/ + +#ifdef __cplusplus + + // + // RN: We could do the usual tricky compiler detection here, + // and use their variant (such as wmemchr, etc.). The problem + // is that these functions are quite rare, even though they are + // part of the current POSIX standard. In addition, most compilers + // (including even MSC) inline them just like we do right in their + // headers. + // + #include + #if wxUSE_UNICODE + //implement our own wmem variants + inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l) + { + for(;l && *s != c;--l, ++s) {} + + if(l) + return (wxChar*)s; + return NULL; + } + + inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len) + { + for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {} + + if(len) + return *sz1 < *sz2 ? -1 : *sz1 > *sz2; + else + return 0; + } + + inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len) + { + return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar)); + } + + inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len) + { + return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar)); + } + + inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len) + { + wxChar* szRet = szOut; + + while (len--) + *szOut++ = cIn; + + return szRet; + } + #else /* !wxUSE_UNICODE */ + #if wxABI_VERSION >= 20805 + // for compatibility with earlier versions, these functions take + // "void *" but in the next wx version they will take "char *" so + // don't use them with void pointers (use the standard memxxx() + // with them) + inline char* wxTmemchr(const void* s, int c, size_t len) + { return (char*)memchr(s, c, len); } + inline int wxTmemcmp(const void* sz1, const void* sz2, size_t len) + { return memcmp(sz1, sz2, len); } + inline char* wxTmemcpy(void* szOut, const void* szIn, size_t len) + { return (char*)memcpy(szOut, szIn, len); } + inline char* wxTmemmove(void* szOut, const void* szIn, size_t len) + { return (char*)memmove(szOut, szIn, len); } + inline char* wxTmemset(void* szOut, int c, size_t len) + { return (char*)memset(szOut, c, len); } + #else + # define wxTmemchr memchr + # define wxTmemcmp memcmp + # define wxTmemcpy memcpy + # define wxTmemmove memmove + # define wxTmemset memset + #endif + #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */ + +#endif /*__cplusplus*/ + #endif /* _WX_WXCHAR_H_ */ + diff --git a/Source/3rd Party/wx/include/wx/wxcrt.h b/Source/3rd Party/wx/include/wx/wxcrt.h deleted file mode 100644 index dd579364f..000000000 --- a/Source/3rd Party/wx/include/wx/wxcrt.h +++ /dev/null @@ -1,986 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/wxcrt.h -// Purpose: Type-safe ANSI and Unicode builds compatible wrappers for -// CRT functions -// Author: Joel Farley, Ove Kaaven -// Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee, Vaclav Slavik -// Created: 1998/06/12 -// Copyright: (c) 1998-2006 wxWidgets dev team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WXCRT_H_ -#define _WX_WXCRT_H_ - -#include "wx/wxcrtbase.h" -#include "wx/string.h" - -#ifndef __WX_SETUP_H__ -// For non-configure builds assume vsscanf is available, if not Visual C or DMC -#if !defined (__VISUALC__) && !defined (__DMC__) - #define HAVE_VSSCANF 1 -#endif -#endif - -// ============================================================================ -// misc functions -// ============================================================================ - -/* checks whether the passed in pointer is NULL and if the string is empty */ -inline bool wxIsEmpty(const char *s) { return !s || !*s; } -inline bool wxIsEmpty(const wchar_t *s) { return !s || !*s; } -inline bool wxIsEmpty(const wxScopedCharBuffer& s) { return wxIsEmpty(s.data()); } -inline bool wxIsEmpty(const wxScopedWCharBuffer& s) { return wxIsEmpty(s.data()); } -inline bool wxIsEmpty(const wxString& s) { return s.empty(); } -inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); } - - - -/* multibyte to wide char conversion functions and macros */ - -/* multibyte<->widechar conversion */ -WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n); -WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); - -#if wxUSE_UNICODE - #define wxMB2WX wxMB2WC - #define wxWX2MB wxWC2MB - #define wxWC2WX wxStrncpy - #define wxWX2WC wxStrncpy -#else - #define wxMB2WX wxStrncpy - #define wxWX2MB wxStrncpy - #define wxWC2WX wxWC2MB - #define wxWX2WC wxMB2WC -#endif - - -// RN: We could do the usual tricky compiler detection here, -// and use their variant (such as wmemchr, etc.). The problem -// is that these functions are quite rare, even though they are -// part of the current POSIX standard. In addition, most compilers -// (including even MSC) inline them just like we do right in their -// headers. -// -#include - -#if wxUSE_UNICODE - //implement our own wmem variants - inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l) - { - for(;l && *s != c;--l, ++s) {} - - if(l) - return const_cast(s); - return NULL; - } - - inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len) - { - for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {} - - if(len) - return *sz1 < *sz2 ? -1 : *sz1 > *sz2; - else - return 0; - } - - inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len) - { - return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar)); - } - - inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len) - { - return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar)); - } - - inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len) - { - wxChar* szRet = szOut; - - while (len--) - *szOut++ = cIn; - - return szRet; - } -#endif /* wxUSE_UNICODE */ - -// provide trivial wrappers for char* versions for both ANSI and Unicode builds -// (notice that these intentionally return "char *" and not "void *" unlike the -// standard memxxx() for symmetry with the wide char versions): -inline char* wxTmemchr(const char* s, char c, size_t len) - { return (char*)memchr(s, c, len); } -inline int wxTmemcmp(const char* sz1, const char* sz2, size_t len) - { return memcmp(sz1, sz2, len); } -inline char* wxTmemcpy(char* szOut, const char* szIn, size_t len) - { return (char*)memcpy(szOut, szIn, len); } -inline char* wxTmemmove(char* szOut, const char* szIn, size_t len) - { return (char*)memmove(szOut, szIn, len); } -inline char* wxTmemset(char* szOut, const char cIn, size_t len) - { return (char*)memset(szOut, cIn, len); } - - -// ============================================================================ -// wx wrappers for CRT functions in both char* and wchar_t* versions -// ============================================================================ - -// A few notes on implementation of these wrappers: -// -// We need both char* and wchar_t* versions of functions like wxStrlen() for -// compatibility with both ANSI and Unicode builds. -// -// This makes passing wxString or c_str()/mb_str()/wc_str() result to them -// ambiguous, so we need to provide overrides for that as well (in cases where -// it makes sense). -// -// We can do this without problems for some functions (wxStrlen()), but in some -// cases, we can't stay compatible with both ANSI and Unicode builds, e.g. for -// wxStrcpy(const wxString&), which can only return either char* or wchar_t*. -// In these cases, we preserve ANSI build compatibility by returning char*. - -// ---------------------------------------------------------------------------- -// locale functions -// ---------------------------------------------------------------------------- - -// NB: we can't provide const wchar_t* (= wxChar*) overload, because calling -// wxSetlocale(category, NULL) -- which is a common thing to do -- would be -// ambiguous -WXDLLIMPEXP_BASE char* wxSetlocale(int category, const char *locale); -inline char* wxSetlocale(int category, const wxScopedCharBuffer& locale) - { return wxSetlocale(category, locale.data()); } -inline char* wxSetlocale(int category, const wxString& locale) - { return wxSetlocale(category, locale.mb_str()); } -inline char* wxSetlocale(int category, const wxCStrData& locale) - { return wxSetlocale(category, locale.AsCharBuf()); } - -// ---------------------------------------------------------------------------- -// string functions -// ---------------------------------------------------------------------------- - -/* safe version of strlen() (returns 0 if passed NULL pointer) */ -// NB: these are defined in wxcrtbase.h, see the comment there -// inline size_t wxStrlen(const char *s) { return s ? strlen(s) : 0; } -// inline size_t wxStrlen(const wchar_t *s) { return s ? wxCRT_Strlen_(s) : 0; } -inline size_t wxStrlen(const wxScopedCharBuffer& s) { return wxStrlen(s.data()); } -inline size_t wxStrlen(const wxScopedWCharBuffer& s) { return wxStrlen(s.data()); } -inline size_t wxStrlen(const wxString& s) { return s.length(); } -inline size_t wxStrlen(const wxCStrData& s) { return s.AsString().length(); } - -// this is a function new in 2.9 so we don't care about backwards compatibility and -// so don't need to support wxScopedCharBuffer/wxScopedWCharBuffer overloads -#if defined(wxCRT_StrnlenA) -inline size_t wxStrnlen(const char *str, size_t maxlen) { return wxCRT_StrnlenA(str, maxlen); } -#else -inline size_t wxStrnlen(const char *str, size_t maxlen) -{ - size_t n; - for ( n = 0; n < maxlen; n++ ) - if ( !str[n] ) - break; - - return n; -} -#endif - -#if defined(wxCRT_StrnlenW) -inline size_t wxStrnlen(const wchar_t *str, size_t maxlen) { return wxCRT_StrnlenW(str, maxlen); } -#else -inline size_t wxStrnlen(const wchar_t *str, size_t maxlen) -{ - size_t n; - for ( n = 0; n < maxlen; n++ ) - if ( !str[n] ) - break; - - return n; -} -#endif - -// NB: these are defined in wxcrtbase.h, see the comment there -// inline char* wxStrdup(const char *s) { return wxStrdupA(s); } -// inline wchar_t* wxStrdup(const wchar_t *s) { return wxStrdupW(s); } -inline char* wxStrdup(const wxScopedCharBuffer& s) { return wxStrdup(s.data()); } -inline wchar_t* wxStrdup(const wxScopedWCharBuffer& s) { return wxStrdup(s.data()); } -inline char* wxStrdup(const wxString& s) { return wxStrdup(s.mb_str()); } -inline char* wxStrdup(const wxCStrData& s) { return wxStrdup(s.AsCharBuf()); } - -inline char *wxStrcpy(char *dest, const char *src) - { return wxCRT_StrcpyA(dest, src); } -inline wchar_t *wxStrcpy(wchar_t *dest, const wchar_t *src) - { return wxCRT_StrcpyW(dest, src); } -inline char *wxStrcpy(char *dest, const wxString& src) - { return wxCRT_StrcpyA(dest, src.mb_str()); } -inline char *wxStrcpy(char *dest, const wxCStrData& src) - { return wxCRT_StrcpyA(dest, src.AsCharBuf()); } -inline char *wxStrcpy(char *dest, const wxScopedCharBuffer& src) - { return wxCRT_StrcpyA(dest, src.data()); } -inline wchar_t *wxStrcpy(wchar_t *dest, const wxString& src) - { return wxCRT_StrcpyW(dest, src.wc_str()); } -inline wchar_t *wxStrcpy(wchar_t *dest, const wxCStrData& src) - { return wxCRT_StrcpyW(dest, src.AsWCharBuf()); } -inline wchar_t *wxStrcpy(wchar_t *dest, const wxScopedWCharBuffer& src) - { return wxCRT_StrcpyW(dest, src.data()); } -inline char *wxStrcpy(char *dest, const wchar_t *src) - { return wxCRT_StrcpyA(dest, wxConvLibc.cWC2MB(src)); } -inline wchar_t *wxStrcpy(wchar_t *dest, const char *src) - { return wxCRT_StrcpyW(dest, wxConvLibc.cMB2WC(src)); } - -inline char *wxStrncpy(char *dest, const char *src, size_t n) - { return wxCRT_StrncpyA(dest, src, n); } -inline wchar_t *wxStrncpy(wchar_t *dest, const wchar_t *src, size_t n) - { return wxCRT_StrncpyW(dest, src, n); } -inline char *wxStrncpy(char *dest, const wxString& src, size_t n) - { return wxCRT_StrncpyA(dest, src.mb_str(), n); } -inline char *wxStrncpy(char *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrncpyA(dest, src.AsCharBuf(), n); } -inline char *wxStrncpy(char *dest, const wxScopedCharBuffer& src, size_t n) - { return wxCRT_StrncpyA(dest, src.data(), n); } -inline wchar_t *wxStrncpy(wchar_t *dest, const wxString& src, size_t n) - { return wxCRT_StrncpyW(dest, src.wc_str(), n); } -inline wchar_t *wxStrncpy(wchar_t *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrncpyW(dest, src.AsWCharBuf(), n); } -inline wchar_t *wxStrncpy(wchar_t *dest, const wxScopedWCharBuffer& src, size_t n) - { return wxCRT_StrncpyW(dest, src.data(), n); } -inline char *wxStrncpy(char *dest, const wchar_t *src, size_t n) - { return wxCRT_StrncpyA(dest, wxConvLibc.cWC2MB(src), n); } -inline wchar_t *wxStrncpy(wchar_t *dest, const char *src, size_t n) - { return wxCRT_StrncpyW(dest, wxConvLibc.cMB2WC(src), n); } - -// this is a function new in 2.9 so we don't care about backwards compatibility and -// so don't need to support wchar_t/char overloads -inline size_t wxStrlcpy(char *dest, const char *src, size_t n) -{ - const size_t len = wxCRT_StrlenA(src); - - if ( n ) - { - if ( n-- > len ) - n = len; - wxCRT_StrncpyA(dest, src, n); - dest[n] = '\0'; - } - - return len; -} -inline size_t wxStrlcpy(wchar_t *dest, const wchar_t *src, size_t n) -{ - const size_t len = wxCRT_StrlenW(src); - if ( n ) - { - if ( n-- > len ) - n = len; - wxCRT_StrncpyW(dest, src, n); - dest[n] = L'\0'; - } - - return len; -} - -inline char *wxStrcat(char *dest, const char *src) - { return wxCRT_StrcatA(dest, src); } -inline wchar_t *wxStrcat(wchar_t *dest, const wchar_t *src) - { return wxCRT_StrcatW(dest, src); } -inline char *wxStrcat(char *dest, const wxString& src) - { return wxCRT_StrcatA(dest, src.mb_str()); } -inline char *wxStrcat(char *dest, const wxCStrData& src) - { return wxCRT_StrcatA(dest, src.AsCharBuf()); } -inline char *wxStrcat(char *dest, const wxScopedCharBuffer& src) - { return wxCRT_StrcatA(dest, src.data()); } -inline wchar_t *wxStrcat(wchar_t *dest, const wxString& src) - { return wxCRT_StrcatW(dest, src.wc_str()); } -inline wchar_t *wxStrcat(wchar_t *dest, const wxCStrData& src) - { return wxCRT_StrcatW(dest, src.AsWCharBuf()); } -inline wchar_t *wxStrcat(wchar_t *dest, const wxScopedWCharBuffer& src) - { return wxCRT_StrcatW(dest, src.data()); } -inline char *wxStrcat(char *dest, const wchar_t *src) - { return wxCRT_StrcatA(dest, wxConvLibc.cWC2MB(src)); } -inline wchar_t *wxStrcat(wchar_t *dest, const char *src) - { return wxCRT_StrcatW(dest, wxConvLibc.cMB2WC(src)); } - -inline char *wxStrncat(char *dest, const char *src, size_t n) - { return wxCRT_StrncatA(dest, src, n); } -inline wchar_t *wxStrncat(wchar_t *dest, const wchar_t *src, size_t n) - { return wxCRT_StrncatW(dest, src, n); } -inline char *wxStrncat(char *dest, const wxString& src, size_t n) - { return wxCRT_StrncatA(dest, src.mb_str(), n); } -inline char *wxStrncat(char *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrncatA(dest, src.AsCharBuf(), n); } -inline char *wxStrncat(char *dest, const wxScopedCharBuffer& src, size_t n) - { return wxCRT_StrncatA(dest, src.data(), n); } -inline wchar_t *wxStrncat(wchar_t *dest, const wxString& src, size_t n) - { return wxCRT_StrncatW(dest, src.wc_str(), n); } -inline wchar_t *wxStrncat(wchar_t *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrncatW(dest, src.AsWCharBuf(), n); } -inline wchar_t *wxStrncat(wchar_t *dest, const wxScopedWCharBuffer& src, size_t n) - { return wxCRT_StrncatW(dest, src.data(), n); } -inline char *wxStrncat(char *dest, const wchar_t *src, size_t n) - { return wxCRT_StrncatA(dest, wxConvLibc.cWC2MB(src), n); } -inline wchar_t *wxStrncat(wchar_t *dest, const char *src, size_t n) - { return wxCRT_StrncatW(dest, wxConvLibc.cMB2WC(src), n); } - - -#define WX_STR_DECL(name, T1, T2) name(T1 s1, T2 s2) -#define WX_STR_CALL(func, a1, a2) func(a1, a2) - -// This macro defines string function for all possible variants of arguments, -// except for those taking wxString or wxCStrData as second argument. -// Parameters: -// rettype - return type -// name - name of the (overloaded) function to define -// crtA - function to call for char* versions (takes two arguments) -// crtW - ditto for wchar_t* function -// forString - function to call when the *first* argument is wxString; -// the second argument can be any string type, so this is -// typically a template -#define WX_STR_FUNC_NO_INVERT(rettype, name, crtA, crtW, forString) \ - inline rettype WX_STR_DECL(name, const char *, const char *) \ - { return WX_STR_CALL(crtA, s1, s2); } \ - inline rettype WX_STR_DECL(name, const char *, const wchar_t *) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - inline rettype WX_STR_DECL(name, const char *, const wxScopedCharBuffer&) \ - { return WX_STR_CALL(crtA, s1, s2.data()); } \ - inline rettype WX_STR_DECL(name, const char *, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(forString, wxString(s1), s2.data()); } \ - \ - inline rettype WX_STR_DECL(name, const wchar_t *, const wchar_t *) \ - { return WX_STR_CALL(crtW, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wchar_t *, const char *) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - inline rettype WX_STR_DECL(name, const wchar_t *, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(crtW, s1, s2.data()); } \ - inline rettype WX_STR_DECL(name, const wchar_t *, const wxScopedCharBuffer&) \ - { return WX_STR_CALL(forString, wxString(s1), s2.data()); } \ - \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const char *) \ - { return WX_STR_CALL(crtA, s1.data(), s2); } \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wchar_t *) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxScopedCharBuffer&)\ - { return WX_STR_CALL(crtA, s1.data(), s2.data()); } \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wchar_t *) \ - { return WX_STR_CALL(crtW, s1.data(), s2); } \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const char *) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(crtW, s1.data(), s2.data()); } \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxScopedCharBuffer&) \ - { return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \ - \ - inline rettype WX_STR_DECL(name, const wxString&, const char*) \ - { return WX_STR_CALL(forString, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wxString&, const wchar_t*) \ - { return WX_STR_CALL(forString, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wxString&, const wxScopedCharBuffer&) \ - { return WX_STR_CALL(forString, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wxString&, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(forString, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wxString&, const wxString&) \ - { return WX_STR_CALL(forString, s1, s2); } \ - inline rettype WX_STR_DECL(name, const wxString&, const wxCStrData&) \ - { return WX_STR_CALL(forString, s1, s2); } \ - \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const char*) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const wchar_t*) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const wxScopedCharBuffer&) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const wxScopedWCharBuffer&) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const wxString&) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } \ - inline rettype WX_STR_DECL(name, const wxCStrData&, const wxCStrData&) \ - { return WX_STR_CALL(forString, s1.AsString(), s2); } - -// This defines strcmp-like function, i.e. one returning the result of -// comparison; see WX_STR_FUNC_NO_INVERT for explanation of the arguments -#define WX_STRCMP_FUNC(name, crtA, crtW, forString) \ - WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString) \ - \ - inline int WX_STR_DECL(name, const char *, const wxCStrData&) \ - { return -WX_STR_CALL(forString, s2.AsString(), s1); } \ - inline int WX_STR_DECL(name, const char *, const wxString&) \ - { return -WX_STR_CALL(forString, s2, s1); } \ - \ - inline int WX_STR_DECL(name, const wchar_t *, const wxCStrData&) \ - { return -WX_STR_CALL(forString, s2.AsString(), s1); } \ - inline int WX_STR_DECL(name, const wchar_t *, const wxString&) \ - { return -WX_STR_CALL(forString, s2, s1); } \ - \ - inline int WX_STR_DECL(name, const wxScopedCharBuffer&, const wxCStrData&) \ - { return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \ - inline int WX_STR_DECL(name, const wxScopedCharBuffer&, const wxString&) \ - { return -WX_STR_CALL(forString, s2, s1.data()); } \ - \ - inline int WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxCStrData&) \ - { return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \ - inline int WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxString&) \ - { return -WX_STR_CALL(forString, s2, s1.data()); } - - -// This defines a string function that is *not* strcmp-like, i.e. doesn't -// return the result of comparison and so if the second argument is a string, -// it has to be converted to char* or wchar_t* -#define WX_STR_FUNC(rettype, name, crtA, crtW, forString) \ - WX_STR_FUNC_NO_INVERT(rettype, name, crtA, crtW, forString) \ - \ - inline rettype WX_STR_DECL(name, const char *, const wxCStrData&) \ - { return WX_STR_CALL(crtA, s1, s2.AsCharBuf()); } \ - inline rettype WX_STR_DECL(name, const char *, const wxString&) \ - { return WX_STR_CALL(crtA, s1, s2.mb_str()); } \ - \ - inline rettype WX_STR_DECL(name, const wchar_t *, const wxCStrData&) \ - { return WX_STR_CALL(crtW, s1, s2.AsWCharBuf()); } \ - inline rettype WX_STR_DECL(name, const wchar_t *, const wxString&) \ - { return WX_STR_CALL(crtW, s1, s2.wc_str()); } \ - \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxCStrData&) \ - { return WX_STR_CALL(crtA, s1.data(), s2.AsCharBuf()); } \ - inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxString&) \ - { return WX_STR_CALL(crtA, s1.data(), s2.mb_str()); } \ - \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxCStrData&) \ - { return WX_STR_CALL(crtW, s1.data(), s2.AsWCharBuf()); } \ - inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxString&) \ - { return WX_STR_CALL(crtW, s1.data(), s2.wc_str()); } - -template -inline int wxStrcmp_String(const wxString& s1, const T& s2) - { return s1.compare(s2); } -WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String) - -template -inline int wxStricmp_String(const wxString& s1, const T& s2) - { return s1.CmpNoCase(s2); } -WX_STRCMP_FUNC(wxStricmp, wxCRT_StricmpA, wxCRT_StricmpW, wxStricmp_String) - -#if defined(wxCRT_StrcollA) && defined(wxCRT_StrcollW) - -// GCC 3.4 and other compilers have a bug that causes it to fail compilation if -// the template's implementation uses overloaded function declared later (see -// the wxStrcoll() call in wxStrcoll_String()), so we have to -// forward-declare the template and implement it below WX_STRCMP_FUNC. OTOH, -// this fails to compile with VC6, so don't do it for VC. It also causes -// problems with GCC visibility in newer GCC versions. -#if !(defined(__VISUALC__) || (wxCHECK_GCC_VERSION(3,5) && !wxCHECK_GCC_VERSION(4,7))) || defined(__clang__) - #define wxNEEDS_DECL_BEFORE_TEMPLATE -#endif - -#ifdef wxNEEDS_DECL_BEFORE_TEMPLATE -template -inline int wxStrcoll_String(const wxString& s1, const T& s2); -WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String) -#endif // wxNEEDS_DECL_BEFORE_TEMPLATE - -template -inline int wxStrcoll_String(const wxString& s1, const T& s2) -{ -#if wxUSE_UNICODE - // NB: strcoll() doesn't work correctly on UTF-8 strings, so we have to use - // wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is - // there just as optimization to avoid going through - // wxStrcoll: - return wxStrcoll((const wchar_t*)s1.wc_str(), s2); -#else - return wxStrcoll((const char*)s1.mb_str(), s2); -#endif -} - -#ifndef wxNEEDS_DECL_BEFORE_TEMPLATE -// this is exactly the same WX_STRCMP_FUNC line as above, insde the -// wxNEEDS_DECL_BEFORE_TEMPLATE case -WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String) -#endif - -#endif // defined(wxCRT_Strcoll[AW]) - -template -inline size_t wxStrspn_String(const wxString& s1, const T& s2) -{ - size_t pos = s1.find_first_not_of(s2); - return pos == wxString::npos ? s1.length() : pos; -} -WX_STR_FUNC(size_t, wxStrspn, wxCRT_StrspnA, wxCRT_StrspnW, wxStrspn_String) - -template -inline size_t wxStrcspn_String(const wxString& s1, const T& s2) -{ - size_t pos = s1.find_first_of(s2); - return pos == wxString::npos ? s1.length() : pos; -} -WX_STR_FUNC(size_t, wxStrcspn, wxCRT_StrcspnA, wxCRT_StrcspnW, wxStrcspn_String) - -#undef WX_STR_DECL -#undef WX_STR_CALL -#define WX_STR_DECL(name, T1, T2) name(T1 s1, T2 s2, size_t n) -#define WX_STR_CALL(func, a1, a2) func(a1, a2, n) - -template -inline int wxStrncmp_String(const wxString& s1, const T& s2, size_t n) - { return s1.compare(0, n, s2, 0, n); } -WX_STRCMP_FUNC(wxStrncmp, wxCRT_StrncmpA, wxCRT_StrncmpW, wxStrncmp_String) - -template -inline int wxStrnicmp_String(const wxString& s1, const T& s2, size_t n) - { return s1.substr(0, n).CmpNoCase(wxString(s2).substr(0, n)); } -WX_STRCMP_FUNC(wxStrnicmp, wxCRT_StrnicmpA, wxCRT_StrnicmpW, wxStrnicmp_String) - -#undef WX_STR_DECL -#undef WX_STR_CALL -#undef WX_STRCMP_FUNC -#undef WX_STR_FUNC -#undef WX_STR_FUNC_NO_INVERT - -#if defined(wxCRT_StrxfrmA) && defined(wxCRT_StrxfrmW) - -inline size_t wxStrxfrm(char *dest, const char *src, size_t n) - { return wxCRT_StrxfrmA(dest, src, n); } -inline size_t wxStrxfrm(wchar_t *dest, const wchar_t *src, size_t n) - { return wxCRT_StrxfrmW(dest, src, n); } -template -inline size_t wxStrxfrm(T *dest, const wxScopedCharTypeBuffer& src, size_t n) - { return wxStrxfrm(dest, src.data(), n); } -inline size_t wxStrxfrm(char *dest, const wxString& src, size_t n) - { return wxCRT_StrxfrmA(dest, src.mb_str(), n); } -inline size_t wxStrxfrm(wchar_t *dest, const wxString& src, size_t n) - { return wxCRT_StrxfrmW(dest, src.wc_str(), n); } -inline size_t wxStrxfrm(char *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrxfrmA(dest, src.AsCharBuf(), n); } -inline size_t wxStrxfrm(wchar_t *dest, const wxCStrData& src, size_t n) - { return wxCRT_StrxfrmW(dest, src.AsWCharBuf(), n); } - -#endif // defined(wxCRT_Strxfrm[AW]) - -inline char *wxStrtok(char *str, const char *delim, char **saveptr) - { return wxCRT_StrtokA(str, delim, saveptr); } -inline wchar_t *wxStrtok(wchar_t *str, const wchar_t *delim, wchar_t **saveptr) - { return wxCRT_StrtokW(str, delim, saveptr); } -template -inline T *wxStrtok(T *str, const wxScopedCharTypeBuffer& delim, T **saveptr) - { return wxStrtok(str, delim.data(), saveptr); } -inline char *wxStrtok(char *str, const wxCStrData& delim, char **saveptr) - { return wxCRT_StrtokA(str, delim.AsCharBuf(), saveptr); } -inline wchar_t *wxStrtok(wchar_t *str, const wxCStrData& delim, wchar_t **saveptr) - { return wxCRT_StrtokW(str, delim.AsWCharBuf(), saveptr); } -inline char *wxStrtok(char *str, const wxString& delim, char **saveptr) - { return wxCRT_StrtokA(str, delim.mb_str(), saveptr); } -inline wchar_t *wxStrtok(wchar_t *str, const wxString& delim, wchar_t **saveptr) - { return wxCRT_StrtokW(str, delim.wc_str(), saveptr); } - -inline const char *wxStrstr(const char *haystack, const char *needle) - { return wxCRT_StrstrA(haystack, needle); } -inline const wchar_t *wxStrstr(const wchar_t *haystack, const wchar_t *needle) - { return wxCRT_StrstrW(haystack, needle); } -inline const char *wxStrstr(const char *haystack, const wxString& needle) - { return wxCRT_StrstrA(haystack, needle.mb_str()); } -inline const wchar_t *wxStrstr(const wchar_t *haystack, const wxString& needle) - { return wxCRT_StrstrW(haystack, needle.wc_str()); } -// these functions return char* pointer into the non-temporary conversion buffer -// used by c_str()'s implicit conversion to char*, for ANSI build compatibility -inline const char *wxStrstr(const wxString& haystack, const wxString& needle) - { return wxCRT_StrstrA(haystack.c_str(), needle.mb_str()); } -inline const char *wxStrstr(const wxCStrData& haystack, const wxString& needle) - { return wxCRT_StrstrA(haystack, needle.mb_str()); } -inline const char *wxStrstr(const wxCStrData& haystack, const wxCStrData& needle) - { return wxCRT_StrstrA(haystack, needle.AsCharBuf()); } -// if 'needle' is char/wchar_t, then the same is probably wanted as return value -inline const char *wxStrstr(const wxString& haystack, const char *needle) - { return wxCRT_StrstrA(haystack.c_str(), needle); } -inline const char *wxStrstr(const wxCStrData& haystack, const char *needle) - { return wxCRT_StrstrA(haystack, needle); } -inline const wchar_t *wxStrstr(const wxString& haystack, const wchar_t *needle) - { return wxCRT_StrstrW(haystack.c_str(), needle); } -inline const wchar_t *wxStrstr(const wxCStrData& haystack, const wchar_t *needle) - { return wxCRT_StrstrW(haystack, needle); } - -inline const char *wxStrchr(const char *s, char c) - { return wxCRT_StrchrA(s, c); } -inline const wchar_t *wxStrchr(const wchar_t *s, wchar_t c) - { return wxCRT_StrchrW(s, c); } -inline const char *wxStrrchr(const char *s, char c) - { return wxCRT_StrrchrA(s, c); } -inline const wchar_t *wxStrrchr(const wchar_t *s, wchar_t c) - { return wxCRT_StrrchrW(s, c); } -inline const char *wxStrchr(const char *s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s, c) : NULL; } -inline const wchar_t *wxStrchr(const wchar_t *s, const wxUniChar& c) - { return wxCRT_StrchrW(s, (wchar_t)c); } -inline const char *wxStrrchr(const char *s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s, c) : NULL; } -inline const wchar_t *wxStrrchr(const wchar_t *s, const wxUniChar& c) - { return wxCRT_StrrchrW(s, (wchar_t)c); } -inline const char *wxStrchr(const char *s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s, c) : NULL; } -inline const wchar_t *wxStrchr(const wchar_t *s, const wxUniCharRef& c) - { return wxCRT_StrchrW(s, (wchar_t)c); } -inline const char *wxStrrchr(const char *s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s, c) : NULL; } -inline const wchar_t *wxStrrchr(const wchar_t *s, const wxUniCharRef& c) - { return wxCRT_StrrchrW(s, (wchar_t)c); } -template -inline const T* wxStrchr(const wxScopedCharTypeBuffer& s, T c) - { return wxStrchr(s.data(), c); } -template -inline const T* wxStrrchr(const wxScopedCharTypeBuffer& s, T c) - { return wxStrrchr(s.data(), c); } -template -inline const T* wxStrchr(const wxScopedCharTypeBuffer& s, const wxUniChar& c) - { return wxStrchr(s.data(), (T)c); } -template -inline const T* wxStrrchr(const wxScopedCharTypeBuffer& s, const wxUniChar& c) - { return wxStrrchr(s.data(), (T)c); } -template -inline const T* wxStrchr(const wxScopedCharTypeBuffer& s, const wxUniCharRef& c) - { return wxStrchr(s.data(), (T)c); } -template -inline const T* wxStrrchr(const wxScopedCharTypeBuffer& s, const wxUniCharRef& c) - { return wxStrrchr(s.data(), (T)c); } -// these functions return char* pointer into the non-temporary conversion buffer -// used by c_str()'s implicit conversion to char*, for ANSI build compatibility -inline const char* wxStrchr(const wxString& s, char c) - { return wxCRT_StrchrA((const char*)s.c_str(), c); } -inline const char* wxStrrchr(const wxString& s, char c) - { return wxCRT_StrrchrA((const char*)s.c_str(), c); } -inline const char* wxStrchr(const wxString& s, int c) - { return wxCRT_StrchrA((const char*)s.c_str(), c); } -inline const char* wxStrrchr(const wxString& s, int c) - { return wxCRT_StrrchrA((const char*)s.c_str(), c); } -inline const char* wxStrchr(const wxString& s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s.c_str(), c) : NULL; } -inline const char* wxStrrchr(const wxString& s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s.c_str(), c) : NULL; } -inline const char* wxStrchr(const wxString& s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s.c_str(), c) : NULL; } -inline const char* wxStrrchr(const wxString& s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s.c_str(), c) : NULL; } -inline const wchar_t* wxStrchr(const wxString& s, wchar_t c) - { return wxCRT_StrchrW((const wchar_t*)s.c_str(), c); } -inline const wchar_t* wxStrrchr(const wxString& s, wchar_t c) - { return wxCRT_StrrchrW((const wchar_t*)s.c_str(), c); } -inline const char* wxStrchr(const wxCStrData& s, char c) - { return wxCRT_StrchrA(s.AsChar(), c); } -inline const char* wxStrrchr(const wxCStrData& s, char c) - { return wxCRT_StrrchrA(s.AsChar(), c); } -inline const char* wxStrchr(const wxCStrData& s, int c) - { return wxCRT_StrchrA(s.AsChar(), c); } -inline const char* wxStrrchr(const wxCStrData& s, int c) - { return wxCRT_StrrchrA(s.AsChar(), c); } -inline const char* wxStrchr(const wxCStrData& s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s, c) : NULL; } -inline const char* wxStrrchr(const wxCStrData& s, const wxUniChar& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s, c) : NULL; } -inline const char* wxStrchr(const wxCStrData& s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrchrA(s, c) : NULL; } -inline const char* wxStrrchr(const wxCStrData& s, const wxUniCharRef& uc) - { char c; return uc.GetAsChar(&c) ? wxCRT_StrrchrA(s, c) : NULL; } -inline const wchar_t* wxStrchr(const wxCStrData& s, wchar_t c) - { return wxCRT_StrchrW(s.AsWChar(), c); } -inline const wchar_t* wxStrrchr(const wxCStrData& s, wchar_t c) - { return wxCRT_StrrchrW(s.AsWChar(), c); } - -inline const char *wxStrpbrk(const char *s, const char *accept) - { return wxCRT_StrpbrkA(s, accept); } -inline const wchar_t *wxStrpbrk(const wchar_t *s, const wchar_t *accept) - { return wxCRT_StrpbrkW(s, accept); } -inline const char *wxStrpbrk(const char *s, const wxString& accept) - { return wxCRT_StrpbrkA(s, accept.mb_str()); } -inline const char *wxStrpbrk(const char *s, const wxCStrData& accept) - { return wxCRT_StrpbrkA(s, accept.AsCharBuf()); } -inline const wchar_t *wxStrpbrk(const wchar_t *s, const wxString& accept) - { return wxCRT_StrpbrkW(s, accept.wc_str()); } -inline const wchar_t *wxStrpbrk(const wchar_t *s, const wxCStrData& accept) - { return wxCRT_StrpbrkW(s, accept.AsWCharBuf()); } -inline const char *wxStrpbrk(const wxString& s, const wxString& accept) - { return wxCRT_StrpbrkA(s.c_str(), accept.mb_str()); } -inline const char *wxStrpbrk(const wxString& s, const char *accept) - { return wxCRT_StrpbrkA(s.c_str(), accept); } -inline const wchar_t *wxStrpbrk(const wxString& s, const wchar_t *accept) - { return wxCRT_StrpbrkW(s.wc_str(), accept); } -inline const char *wxStrpbrk(const wxString& s, const wxCStrData& accept) - { return wxCRT_StrpbrkA(s.c_str(), accept.AsCharBuf()); } -inline const char *wxStrpbrk(const wxCStrData& s, const wxString& accept) - { return wxCRT_StrpbrkA(s.AsChar(), accept.mb_str()); } -inline const char *wxStrpbrk(const wxCStrData& s, const char *accept) - { return wxCRT_StrpbrkA(s.AsChar(), accept); } -inline const wchar_t *wxStrpbrk(const wxCStrData& s, const wchar_t *accept) - { return wxCRT_StrpbrkW(s.AsWChar(), accept); } -inline const char *wxStrpbrk(const wxCStrData& s, const wxCStrData& accept) - { return wxCRT_StrpbrkA(s.AsChar(), accept.AsCharBuf()); } -template -inline const T *wxStrpbrk(const S& s, const wxScopedCharTypeBuffer& accept) - { return wxStrpbrk(s, accept.data()); } - - -/* inlined non-const versions */ -template -inline char *wxStrstr(char *haystack, T needle) - { return const_cast(wxStrstr(const_cast(haystack), needle)); } -template -inline wchar_t *wxStrstr(wchar_t *haystack, T needle) - { return const_cast(wxStrstr(const_cast(haystack), needle)); } - -template -inline char * wxStrchr(char *s, T c) - { return const_cast(wxStrchr(const_cast(s), c)); } -template -inline wchar_t * wxStrchr(wchar_t *s, T c) - { return (wchar_t *)wxStrchr((const wchar_t *)s, c); } -template -inline char * wxStrrchr(char *s, T c) - { return const_cast(wxStrrchr(const_cast(s), c)); } -template -inline wchar_t * wxStrrchr(wchar_t *s, T c) - { return const_cast(wxStrrchr(const_cast(s), c)); } - -template -inline char * wxStrpbrk(char *s, T accept) - { return const_cast(wxStrpbrk(const_cast(s), accept)); } -template -inline wchar_t * wxStrpbrk(wchar_t *s, T accept) - { return const_cast(wxStrpbrk(const_cast(s), accept)); } - - -// ---------------------------------------------------------------------------- -// stdio.h functions -// ---------------------------------------------------------------------------- - -// NB: using fn_str() for mode is a hack to get the same type (char*/wchar_t*) -// as needed, the conversion itself doesn't matter, it's ASCII -inline FILE *wxFopen(const wxString& path, const wxString& mode) - { return wxCRT_Fopen(path.fn_str(), mode.fn_str()); } -inline FILE *wxFreopen(const wxString& path, const wxString& mode, FILE *stream) - { return wxCRT_Freopen(path.fn_str(), mode.fn_str(), stream); } -inline int wxRemove(const wxString& path) - { return wxCRT_Remove(path.fn_str()); } -inline int wxRename(const wxString& oldpath, const wxString& newpath) - { return wxCRT_Rename(oldpath.fn_str(), newpath.fn_str()); } - -extern WXDLLIMPEXP_BASE int wxPuts(const wxString& s); -extern WXDLLIMPEXP_BASE int wxFputs(const wxString& s, FILE *stream); -extern WXDLLIMPEXP_BASE void wxPerror(const wxString& s); - -extern WXDLLIMPEXP_BASE int wxFputc(const wxUniChar& c, FILE *stream); - -#define wxPutc(c, stream) wxFputc(c, stream) -#define wxPutchar(c) wxFputc(c, stdout) -#define wxFputchar(c) wxPutchar(c) - -// NB: We only provide ANSI version of fgets() because fgetws() interprets the -// stream according to current locale, which is rarely what is desired. -inline char *wxFgets(char *s, int size, FILE *stream) - { return wxCRT_FgetsA(s, size, stream); } -// This version calls ANSI version and converts the string using wxConvLibc -extern WXDLLIMPEXP_BASE wchar_t *wxFgets(wchar_t *s, int size, FILE *stream); - -#define wxGets(s) wxGets_is_insecure_and_dangerous_use_wxFgets_instead - -// NB: We only provide ANSI versions of this for the same reasons as in the -// case of wxFgets() above -inline int wxFgetc(FILE *stream) { return wxCRT_FgetcA(stream); } -inline int wxUngetc(int c, FILE *stream) { return wxCRT_UngetcA(c, stream); } - -#define wxGetc(stream) wxFgetc(stream) -#define wxGetchar() wxFgetc(stdin) -#define wxFgetchar() wxGetchar() - -// ---------------------------------------------------------------------------- -// stdlib.h functions -// ---------------------------------------------------------------------------- - -#ifdef wxCRT_AtoiW -inline int wxAtoi(const wxString& str) { return wxCRT_AtoiW(str.wc_str()); } -#else -inline int wxAtoi(const wxString& str) { return wxCRT_AtoiA(str.mb_str()); } -#endif - -#ifdef wxCRT_AtolW -inline long wxAtol(const wxString& str) { return wxCRT_AtolW(str.wc_str()); } -#else -inline long wxAtol(const wxString& str) { return wxCRT_AtolA(str.mb_str()); } -#endif - -#ifdef wxCRT_AtofW -inline double wxAtof(const wxString& str) { return wxCRT_AtofW(str.wc_str()); } -#else -inline double wxAtof(const wxString& str) { return wxCRT_AtofA(str.mb_str()); } -#endif - -inline double wxStrtod(const char *nptr, char **endptr) - { return wxCRT_StrtodA(nptr, endptr); } -inline double wxStrtod(const wchar_t *nptr, wchar_t **endptr) - { return wxCRT_StrtodW(nptr, endptr); } -template -inline double wxStrtod(const wxScopedCharTypeBuffer& nptr, T **endptr) - { return wxStrtod(nptr.data(), endptr); } - -// We implement wxStrto*() like this so that the code compiles when NULL is -// passed in - - if we had just char** and wchar_t** overloads for 'endptr', it -// would be ambiguous. The solution is to use a template so that endptr can be -// any type: when NULL constant is used, the type will be int and we can handle -// that case specially. Otherwise, we infer the type that 'nptr' should be -// converted to from the type of 'endptr'. We need wxStrtoxCharType template -// to make the code compile even for T=int (that's the case when it's not going -// to be ever used, but it still has to compile). -template struct wxStrtoxCharType {}; -template<> struct wxStrtoxCharType -{ - typedef const char* Type; - static char** AsPointer(char **p) { return p; } -}; -template<> struct wxStrtoxCharType -{ - typedef const wchar_t* Type; - static wchar_t** AsPointer(wchar_t **p) { return p; } -}; -template<> struct wxStrtoxCharType -{ - typedef const char* Type; /* this one is never used */ - static char** AsPointer(int WXUNUSED_UNLESS_DEBUG(p)) - { - wxASSERT_MSG( p == 0, "passing non-NULL int is invalid" ); - return NULL; - } -}; - -template -inline double wxStrtod(const wxString& nptr, T endptr) -{ - if ( endptr == 0 ) - { - // when we don't care about endptr, use the string representation that - // doesn't require any conversion (it doesn't matter for this function - // even if its UTF-8): - return wxStrtod(nptr.wx_str(), (wxStringCharType**)NULL); - } - else - { - // note that it is important to use c_str() here and not mb_str() or - // wc_str(), because we store the pointer into (possibly converted) - // buffer in endptr and so it must be valid even when wxStrtod() returns - typedef typename wxStrtoxCharType::Type CharType; - return wxStrtod((CharType)nptr.c_str(), - wxStrtoxCharType::AsPointer(endptr)); - } -} -template -inline double wxStrtod(const wxCStrData& nptr, T endptr) - { return wxStrtod(nptr.AsString(), endptr); } - - -#define WX_STRTOX_FUNC(rettype, name, implA, implW) \ - /* see wxStrtod() above for explanation of this code: */ \ - inline rettype name(const char *nptr, char **endptr, int base) \ - { return implA(nptr, endptr, base); } \ - inline rettype name(const wchar_t *nptr, wchar_t **endptr, int base) \ - { return implW(nptr, endptr, base); } \ - template \ - inline rettype name(const wxScopedCharTypeBuffer& nptr, T **endptr, int)\ - { return name(nptr.data(), endptr); } \ - template \ - inline rettype name(const wxString& nptr, T endptr, int base) \ - { \ - if ( endptr == 0 ) \ - return name(nptr.wx_str(), (wxStringCharType**)NULL, base); \ - else \ - { \ - typedef typename wxStrtoxCharType::Type CharType; \ - return name((CharType)nptr.c_str(), \ - wxStrtoxCharType::AsPointer(endptr), \ - base); \ - } \ - } \ - template \ - inline rettype name(const wxCStrData& nptr, T endptr, int base) \ - { return name(nptr.AsString(), endptr, base); } - -WX_STRTOX_FUNC(long, wxStrtol, wxCRT_StrtolA, wxCRT_StrtolW) -WX_STRTOX_FUNC(unsigned long, wxStrtoul, wxCRT_StrtoulA, wxCRT_StrtoulW) -#ifdef wxLongLong_t -WX_STRTOX_FUNC(wxLongLong_t, wxStrtoll, wxCRT_StrtollA, wxCRT_StrtollW) -WX_STRTOX_FUNC(wxULongLong_t, wxStrtoull, wxCRT_StrtoullA, wxCRT_StrtoullW) -#endif // wxLongLong_t - -#undef WX_STRTOX_FUNC - - -// there is no command interpreter under CE, hence no system() -#ifndef __WXWINCE__ - -// mingw32 doesn't provide _tsystem() even though it provides other stdlib.h -// functions in their wide versions -#ifdef wxCRT_SystemW -inline int wxSystem(const wxString& str) { return wxCRT_SystemW(str.wc_str()); } -#else -inline int wxSystem(const wxString& str) { return wxCRT_SystemA(str.mb_str()); } -#endif - -#endif // !__WXWINCE__/__WXWINCE__ - -inline char* wxGetenv(const char *name) { return wxCRT_GetenvA(name); } -inline wchar_t* wxGetenv(const wchar_t *name) { return wxCRT_GetenvW(name); } -inline char* wxGetenv(const wxString& name) { return wxCRT_GetenvA(name.mb_str()); } -inline char* wxGetenv(const wxCStrData& name) { return wxCRT_GetenvA(name.AsCharBuf()); } -inline char* wxGetenv(const wxScopedCharBuffer& name) { return wxCRT_GetenvA(name.data()); } -inline wchar_t* wxGetenv(const wxScopedWCharBuffer& name) { return wxCRT_GetenvW(name.data()); } - -// ---------------------------------------------------------------------------- -// time.h functions -// ---------------------------------------------------------------------------- - -inline size_t wxStrftime(char *s, size_t max, - const wxString& format, const struct tm *tm) - { return wxCRT_StrftimeA(s, max, format.mb_str(), tm); } - -inline size_t wxStrftime(wchar_t *s, size_t max, - const wxString& format, const struct tm *tm) - { return wxCRT_StrftimeW(s, max, format.wc_str(), tm); } - -// NB: we can't provide both char* and wchar_t* versions for obvious reasons -// and returning wxString wouldn't work either (it would be immediately -// destroyed and if assigned to char*/wchar_t*, the pointer would be -// invalid), so we only keep ASCII version, because the returned value -// is always ASCII anyway -#define wxAsctime asctime -#define wxCtime ctime - - -// ---------------------------------------------------------------------------- -// ctype.h functions -// ---------------------------------------------------------------------------- - -// FIXME-UTF8: we'd be better off implementing these ourselves, as the CRT -// version is locale-dependent -// FIXME-UTF8: these don't work when EOF is passed in because of wxUniChar, -// is this OK or not? - -inline bool wxIsalnum(const wxUniChar& c) { return wxCRT_IsalnumW(c) != 0; } -inline bool wxIsalpha(const wxUniChar& c) { return wxCRT_IsalphaW(c) != 0; } -inline bool wxIscntrl(const wxUniChar& c) { return wxCRT_IscntrlW(c) != 0; } -inline bool wxIsdigit(const wxUniChar& c) { return wxCRT_IsdigitW(c) != 0; } -inline bool wxIsgraph(const wxUniChar& c) { return wxCRT_IsgraphW(c) != 0; } -inline bool wxIslower(const wxUniChar& c) { return wxCRT_IslowerW(c) != 0; } -inline bool wxIsprint(const wxUniChar& c) { return wxCRT_IsprintW(c) != 0; } -inline bool wxIspunct(const wxUniChar& c) { return wxCRT_IspunctW(c) != 0; } -inline bool wxIsspace(const wxUniChar& c) { return wxCRT_IsspaceW(c) != 0; } -inline bool wxIsupper(const wxUniChar& c) { return wxCRT_IsupperW(c) != 0; } -inline bool wxIsxdigit(const wxUniChar& c) { return wxCRT_IsxdigitW(c) != 0; } - -inline wxUniChar wxTolower(const wxUniChar& c) { return wxCRT_TolowerW(c); } -inline wxUniChar wxToupper(const wxUniChar& c) { return wxCRT_ToupperW(c); } - -#if WXWIN_COMPATIBILITY_2_8 -// we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the -// initial versions of this header -- now it is too late to remove it so -// although we fixed the function/macro name above, still provide the -// backwards-compatible synonym. -wxDEPRECATED( inline int wxIsctrl(const wxUniChar& c) ); -inline int wxIsctrl(const wxUniChar& c) { return wxIscntrl(c); } -#endif // WXWIN_COMPATIBILITY_2_8 - -inline bool wxIsascii(const wxUniChar& c) { return c.IsAscii(); } - -#endif /* _WX_WXCRT_H_ */ diff --git a/Source/3rd Party/wx/include/wx/wxcrtbase.h b/Source/3rd Party/wx/include/wx/wxcrtbase.h deleted file mode 100644 index 1c3522ec6..000000000 --- a/Source/3rd Party/wx/include/wx/wxcrtbase.h +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Name: wx/wxcrtbase.h - * Purpose: Type-safe ANSI and Unicode builds compatible wrappers for - * CRT functions - * Author: Joel Farley, Ove Kaaven - * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee - * Created: 1998/06/12 - * Copyright: (c) 1998-2006 wxWidgets dev team - * Licence: wxWindows licence - */ - -/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ - -#ifndef _WX_WXCRTBASE_H_ -#define _WX_WXCRTBASE_H_ - -/* ------------------------------------------------------------------------- - headers and missing declarations - ------------------------------------------------------------------------- */ - -#include "wx/chartype.h" - -/* - Standard headers we need here. - - NB: don't include any wxWidgets headers here because almost all of them - include this one! - - NB2: User code should include wx/crt.h instead of including this - header directly. - - */ - -#include -#include -#include -#include -#include - -#if defined(__WINDOWS__) && !defined(__WXWINCE__) - #include -#endif - -#if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS - char *strtok_r(char *, const char *, char **); -#endif - -/* - Using -std=c++{98,0x} option with mingw32 disables most of standard - library extensions, so we can't rely on the presence of common non-ANSI - functions, define a special symbol to test for this. Notice that this - doesn't need to be done for g++ under Linux where _GNU_SOURCE (which is - defined by default) still makes all common extensions available even in - ANSI mode. - */ -#if defined(__MINGW32__) && defined(__STRICT_ANSI__) - #define __WX_STRICT_ANSI_GCC__ -#endif - -/* - a few compilers don't have the (non standard but common) isascii function, - define it ourselves for them - */ -#ifndef isascii - #if defined(__WX_STRICT_ANSI_GCC__) - #define wxNEED_ISASCII - #elif defined(_WIN32_WCE) - #if _WIN32_WCE <= 211 - #define wxNEED_ISASCII - #endif - #endif -#endif /* isascii */ - -#ifdef wxNEED_ISASCII - inline int isascii(int c) { return (unsigned)c < 0x80; } -#endif - -#ifdef _WIN32_WCE - #if _WIN32_WCE <= 211 - #define isspace(c) ((c) == wxT(' ') || (c) == wxT('\t')) - #endif -#endif /* _WIN32_WCE */ - -/* string.h functions */ -#ifndef strdup - #if defined(__WXWINCE__) - #if _WIN32_WCE <= 211 - #define wxNEED_STRDUP - #endif - #endif -#endif /* strdup */ - -#ifdef wxNEED_STRDUP - WXDLLIMPEXP_BASE char *strdup(const char* s); -#endif - -/* missing functions in some WinCE versions */ -#ifdef _WIN32_WCE -#if (_WIN32_WCE < 300) -WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size ); -#endif -#endif /* _WIN32_WCE */ - - -/* ------------------------------------------------------------------------- - UTF-8 locale handling - ------------------------------------------------------------------------- */ - -#ifdef __cplusplus - #if wxUSE_UNICODE_UTF8 - /* flag indicating whether the current locale uses UTF-8 or not; must be - updated every time the locale is changed! */ - #if wxUSE_UTF8_LOCALE_ONLY - #define wxLocaleIsUtf8 true - #else - extern WXDLLIMPEXP_BASE bool wxLocaleIsUtf8; - #endif - /* function used to update the flag: */ - extern WXDLLIMPEXP_BASE void wxUpdateLocaleIsUtf8(); - #else /* !wxUSE_UNICODE_UTF8 */ - inline void wxUpdateLocaleIsUtf8() {} - #endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */ -#endif /* __cplusplus */ - - -/* ------------------------------------------------------------------------- - string.h - ------------------------------------------------------------------------- */ - -#define wxCRT_StrcatA strcat -#define wxCRT_StrchrA strchr -#define wxCRT_StrcmpA strcmp -#define wxCRT_StrcpyA strcpy -#define wxCRT_StrcspnA strcspn -#define wxCRT_StrlenA strlen -#define wxCRT_StrncatA strncat -#define wxCRT_StrncmpA strncmp -#define wxCRT_StrncpyA strncpy -#define wxCRT_StrpbrkA strpbrk -#define wxCRT_StrrchrA strrchr -#define wxCRT_StrspnA strspn -#define wxCRT_StrstrA strstr - -#define wxCRT_StrcatW wcscat -#define wxCRT_StrchrW wcschr -#define wxCRT_StrcmpW wcscmp -#define wxCRT_StrcpyW wcscpy -#define wxCRT_StrcspnW wcscspn -#define wxCRT_StrncatW wcsncat -#define wxCRT_StrncmpW wcsncmp -#define wxCRT_StrncpyW wcsncpy -#define wxCRT_StrpbrkW wcspbrk -#define wxCRT_StrrchrW wcsrchr -#define wxCRT_StrspnW wcsspn -#define wxCRT_StrstrW wcsstr - -/* these functions are not defined under CE, at least in VC8 CRT */ -#if !defined(__WXWINCE__) - #define wxCRT_StrcollA strcoll - #define wxCRT_StrxfrmA strxfrm - - #define wxCRT_StrcollW wcscoll - #define wxCRT_StrxfrmW wcsxfrm -#endif /* __WXWINCE__ */ - -/* Almost all compilers have strdup(), but VC++ and MinGW call it _strdup(). - And it's not available in MinGW strict ANSI mode nor under Windows CE. */ -#if (defined(__VISUALC__) && __VISUALC__ >= 1400) - #define wxCRT_StrdupA _strdup -#elif defined(__MINGW32__) - #ifndef __WX_STRICT_ANSI_GCC__ - #define wxCRT_StrdupA _strdup - #endif -#elif !defined(__WXWINCE__) - #define wxCRT_StrdupA strdup -#endif - -/* most Windows compilers provide _wcsdup() */ -#if defined(__WINDOWS__) && \ - !(defined(__CYGWIN__) || defined(__WX_STRICT_ANSI_GCC__)) - #define wxCRT_StrdupW _wcsdup -#elif defined(HAVE_WCSDUP) - #define wxCRT_StrdupW wcsdup -#endif - -#ifdef wxHAVE_TCHAR_SUPPORT - /* we surely have wchar_t if we have TCHAR have wcslen() */ - #ifndef HAVE_WCSLEN - #define HAVE_WCSLEN - #endif -#endif /* wxHAVE_TCHAR_SUPPORT */ - -#ifdef HAVE_WCSLEN - #define wxCRT_StrlenW wcslen -#endif - -#define wxCRT_StrtodA strtod -#define wxCRT_StrtolA strtol -#define wxCRT_StrtoulA strtoul -#define wxCRT_StrtodW wcstod -#define wxCRT_StrtolW wcstol -#define wxCRT_StrtoulW wcstoul - -#ifdef __VISUALC__ - #if __VISUALC__ >= 1300 && !defined(__WXWINCE__) - #define wxCRT_StrtollA _strtoi64 - #define wxCRT_StrtoullA _strtoui64 - #define wxCRT_StrtollW _wcstoi64 - #define wxCRT_StrtoullW _wcstoui64 - #endif /* VC++ 7+ */ -#else - #ifdef HAVE_STRTOULL - #define wxCRT_StrtollA strtoll - #define wxCRT_StrtoullA strtoull - #endif /* HAVE_STRTOULL */ - #ifdef HAVE_WCSTOULL - /* assume that we have wcstoull(), which is also C99, too */ - #define wxCRT_StrtollW wcstoll - #define wxCRT_StrtoullW wcstoull - #endif /* HAVE_WCSTOULL */ -#endif - -/* - Only VC8 and later provide strnlen() and wcsnlen() functions under Windows - and it's also only available starting from Windows CE 6.0 only in CE build. - */ -#if wxCHECK_VISUALC_VERSION(8) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 0x600)) - #ifndef HAVE_STRNLEN - #define HAVE_STRNLEN - #endif - #ifndef HAVE_WCSNLEN - #define HAVE_WCSNLEN - #endif -#endif - -#ifdef HAVE_STRNLEN - #define wxCRT_StrnlenA strnlen -#endif - -#ifdef HAVE_WCSNLEN - #define wxCRT_StrnlenW wcsnlen -#endif - -/* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */ - -#if defined(__BORLANDC__) || defined(__WATCOMC__) || \ - defined(__VISAGECPP__) || \ - defined(__EMX__) || defined(__DJGPP__) - #define wxCRT_StricmpA stricmp - #define wxCRT_StrnicmpA strnicmp -#elif defined(__SYMANTEC__) || (defined(__VISUALC__) && !defined(__WXWINCE__)) - #define wxCRT_StricmpA _stricmp - #define wxCRT_StrnicmpA _strnicmp -#elif defined(__UNIX__) || (defined(__GNUWIN32__) && !defined(__WX_STRICT_ANSI_GCC__)) - #define wxCRT_StricmpA strcasecmp - #define wxCRT_StrnicmpA strncasecmp -/* #else -- use wxWidgets implementation */ -#endif - -#ifdef __VISUALC__ - #define wxCRT_StricmpW _wcsicmp - #define wxCRT_StrnicmpW _wcsnicmp -#elif defined(__UNIX__) - #ifdef HAVE_WCSCASECMP - #define wxCRT_StricmpW wcscasecmp - #endif - #ifdef HAVE_WCSNCASECMP - #define wxCRT_StrnicmpW wcsncasecmp - #endif -/* #else -- use wxWidgets implementation */ -#endif - -#ifdef HAVE_STRTOK_R - #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last) -#endif -/* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */ - -/* these are extern "C" because they are used by regex lib: */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef wxCRT_StrlenW -WXDLLIMPEXP_BASE size_t wxCRT_StrlenW(const wchar_t *s); -#endif - -#ifndef wxCRT_StrncmpW -WXDLLIMPEXP_BASE int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t n); -#endif - -#ifdef __cplusplus -} -#endif - -/* FIXME-UTF8: remove this once we are Unicode only */ -#if wxUSE_UNICODE - #define wxCRT_StrlenNative wxCRT_StrlenW - #define wxCRT_StrncmpNative wxCRT_StrncmpW - #define wxCRT_ToupperNative wxCRT_ToupperW - #define wxCRT_TolowerNative wxCRT_TolowerW -#else - #define wxCRT_StrlenNative wxCRT_StrlenA - #define wxCRT_StrncmpNative wxCRT_StrncmpA - #define wxCRT_ToupperNative toupper - #define wxCRT_TolowerNative tolower -#endif - -#ifndef wxCRT_StrcatW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcatW(wchar_t *dest, const wchar_t *src); -#endif - -#ifndef wxCRT_StrchrW -WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrchrW(const wchar_t *s, wchar_t c); -#endif - -#ifndef wxCRT_StrcmpW -WXDLLIMPEXP_BASE int wxCRT_StrcmpW(const wchar_t *s1, const wchar_t *s2); -#endif - -#ifndef wxCRT_StrcollW -WXDLLIMPEXP_BASE int wxCRT_StrcollW(const wchar_t *s1, const wchar_t *s2); -#endif - -#ifndef wxCRT_StrcpyW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcpyW(wchar_t *dest, const wchar_t *src); -#endif - -#ifndef wxCRT_StrcspnW -WXDLLIMPEXP_BASE size_t wxCRT_StrcspnW(const wchar_t *s, const wchar_t *reject); -#endif - -#ifndef wxCRT_StrncatW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrncatW(wchar_t *dest, const wchar_t *src, size_t n); -#endif - -#ifndef wxCRT_StrncpyW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrncpyW(wchar_t *dest, const wchar_t *src, size_t n); -#endif - -#ifndef wxCRT_StrpbrkW -WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrpbrkW(const wchar_t *s, const wchar_t *accept); -#endif - -#ifndef wxCRT_StrrchrW -WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrrchrW(const wchar_t *s, wchar_t c); -#endif - -#ifndef wxCRT_StrspnW -WXDLLIMPEXP_BASE size_t wxCRT_StrspnW(const wchar_t *s, const wchar_t *accept); -#endif - -#ifndef wxCRT_StrstrW -WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrstrW(const wchar_t *haystack, const wchar_t *needle); -#endif - -#ifndef wxCRT_StrtodW -WXDLLIMPEXP_BASE double wxCRT_StrtodW(const wchar_t *nptr, wchar_t **endptr); -#endif - -#ifndef wxCRT_StrtolW -WXDLLIMPEXP_BASE long int wxCRT_StrtolW(const wchar_t *nptr, wchar_t **endptr, int base); -#endif - -#ifndef wxCRT_StrtoulW -WXDLLIMPEXP_BASE unsigned long int wxCRT_StrtoulW(const wchar_t *nptr, wchar_t **endptr, int base); -#endif - -#ifndef wxCRT_StrxfrmW -WXDLLIMPEXP_BASE size_t wxCRT_StrxfrmW(wchar_t *dest, const wchar_t *src, size_t n); -#endif - -#ifndef wxCRT_StrdupA -WXDLLIMPEXP_BASE char *wxCRT_StrdupA(const char *psz); -#endif - -#ifndef wxCRT_StrdupW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrdupW(const wchar_t *pwz); -#endif - -#ifndef wxCRT_StricmpA -WXDLLIMPEXP_BASE int wxCRT_StricmpA(const char *psz1, const char *psz2); -#endif - -#ifndef wxCRT_StricmpW -WXDLLIMPEXP_BASE int wxCRT_StricmpW(const wchar_t *psz1, const wchar_t *psz2); -#endif - -#ifndef wxCRT_StrnicmpA -WXDLLIMPEXP_BASE int wxCRT_StrnicmpA(const char *psz1, const char *psz2, size_t len); -#endif - -#ifndef wxCRT_StrnicmpW -WXDLLIMPEXP_BASE int wxCRT_StrnicmpW(const wchar_t *psz1, const wchar_t *psz2, size_t len); -#endif - -#ifndef wxCRT_StrtokA -WXDLLIMPEXP_BASE char *wxCRT_StrtokA(char *psz, const char *delim, char **save_ptr); -#endif - -#ifndef wxCRT_StrtokW -WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wchar_t **save_ptr); -#endif - -/* supply strtoll and strtoull, if needed */ -#ifdef wxLongLong_t - #ifndef wxCRT_StrtollA - WXDLLIMPEXP_BASE wxLongLong_t wxCRT_StrtollA(const char* nptr, - char** endptr, - int base); - WXDLLIMPEXP_BASE wxULongLong_t wxCRT_StrtoullA(const char* nptr, - char** endptr, - int base); - #endif - #ifndef wxCRT_StrtollW - WXDLLIMPEXP_BASE wxLongLong_t wxCRT_StrtollW(const wchar_t* nptr, - wchar_t** endptr, - int base); - WXDLLIMPEXP_BASE wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr, - wchar_t** endptr, - int base); - #endif -#endif /* wxLongLong_t */ - - -/* ------------------------------------------------------------------------- - stdio.h - ------------------------------------------------------------------------- */ - -#if defined(__UNIX__) || defined(__WXMAC__) - #define wxMBFILES 1 -#else - #define wxMBFILES 0 -#endif - - -/* these functions are only needed in the form used for filenames (i.e. char* - on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */ -#if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */ - - #define wxCRT_Fopen fopen - #define wxCRT_Freopen freopen - #define wxCRT_Remove remove - #define wxCRT_Rename rename - -#else /* Unicode filenames */ - /* special case: these functions are missing under Win9x with Unicows so we - have to implement them ourselves */ - #if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__) - WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name, const wchar_t *mode); - WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream); - WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname, const wchar_t *newname); - WXDLLIMPEXP_BASE int wxMSLU__wremove(const wchar_t *name); - #define wxCRT_Fopen wxMSLU__wfopen - #define wxCRT_Freopen wxMSLU__wfreopen - #define wxCRT_Remove wxMSLU__wremove - #define wxCRT_Rename wxMSLU__wrename - #else - /* WinCE CRT doesn't provide these functions so use our own */ - #ifdef __WXWINCE__ - WXDLLIMPEXP_BASE int wxCRT_Rename(const wchar_t *src, - const wchar_t *dst); - WXDLLIMPEXP_BASE int wxCRT_Remove(const wchar_t *path); - #else - #define wxCRT_Rename _wrename - #define wxCRT_Remove _wremove - #endif - #define wxCRT_Fopen _wfopen - #define wxCRT_Freopen _wfreopen - #endif - -#endif /* wxMBFILES/!wxMBFILES */ - -#define wxCRT_PutsA puts -#define wxCRT_FputsA fputs -#define wxCRT_FgetsA fgets -#define wxCRT_FputcA fputc -#define wxCRT_FgetcA fgetc -#define wxCRT_UngetcA ungetc - -#ifdef wxHAVE_TCHAR_SUPPORT - #define wxCRT_PutsW _putws - #define wxCRT_FputsW fputws - #define wxCRT_FputcW fputwc -#endif -#ifdef HAVE_FPUTWS - #define wxCRT_FputsW fputws -#endif -#ifdef HAVE_PUTWS - #define wxCRT_PutsW putws -#endif -#ifdef HAVE_FPUTWC - #define wxCRT_FputcW fputwc -#endif -#define wxCRT_FgetsW fgetws - -#ifndef wxCRT_PutsW -WXDLLIMPEXP_BASE int wxCRT_PutsW(const wchar_t *ws); -#endif - -#ifndef wxCRT_FputsW -WXDLLIMPEXP_BASE int wxCRT_FputsW(const wchar_t *ch, FILE *stream); -#endif - -#ifndef wxCRT_FputcW -WXDLLIMPEXP_BASE int wxCRT_FputcW(wchar_t wc, FILE *stream); -#endif - -/* - NB: tmpnam() is unsafe and thus is not wrapped! - Use other wxWidgets facilities instead: - wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream -*/ -#define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead - -/* FIXME-CE: provide our own perror() using ::GetLastError() */ -#ifndef __WXWINCE__ - -#define wxCRT_PerrorA perror -#ifdef wxHAVE_TCHAR_SUPPORT - #define wxCRT_PerrorW _wperror -#endif - -#endif /* !__WXWINCE__ */ - -/* ------------------------------------------------------------------------- - stdlib.h - ------------------------------------------------------------------------- */ - -/* there are no env vars at all under CE, so no _tgetenv neither */ -#ifdef __WXWINCE__ - /* can't define as inline function as this is a C file... */ - #define wxCRT_GetenvA(name) (name, NULL) - #define wxCRT_GetenvW(name) (name, NULL) -#else - #define wxCRT_GetenvA getenv - #ifdef _tgetenv - #define wxCRT_GetenvW _wgetenv - #endif -#endif - -#ifndef wxCRT_GetenvW -WXDLLIMPEXP_BASE wchar_t * wxCRT_GetenvW(const wchar_t *name); -#endif - - -#define wxCRT_SystemA system -/* mingw32 doesn't provide _tsystem() or _wsystem(): */ -#if defined(_tsystem) - #define wxCRT_SystemW _wsystem -#endif - -#define wxCRT_AtofA atof -#define wxCRT_AtoiA atoi -#define wxCRT_AtolA atol - -#if defined(wxHAVE_TCHAR_SUPPORT) && !defined(__WX_STRICT_ANSI_GCC__) - #define wxCRT_AtoiW _wtoi - #define wxCRT_AtolW _wtol - /* _wtof doesn't exist */ -#else -#ifndef __VMS - #define wxCRT_AtofW(s) wcstod(s, NULL) -#endif - #define wxCRT_AtolW(s) wcstol(s, NULL, 10) - /* wcstoi doesn't exist */ -#endif - -/* ------------------------------------------------------------------------- - time.h - ------------------------------------------------------------------------- */ - -#define wxCRT_StrftimeA strftime -#ifdef __SGI__ - /* - IRIX provides not one but two versions of wcsftime(): XPG4 one which - uses "const char*" for the third parameter and so can't be used and the - correct, XPG5, one. Unfortunately we can't just define _XOPEN_SOURCE - high enough to get XPG5 version as this undefines other symbols which - make other functions we use unavailable (see for gory - details). So just declare the XPG5 version ourselves, we're extremely - unlikely to ever be compiled on a system without it. But if we ever do, - a configure test would need to be added for it (and _MIPS_SYMBOL_PRESENT - should be used to check for its presence during run-time, i.e. it would - probably be simpler to just always use our own wxCRT_StrftimeW() below - if it does ever become a problem). - */ -#ifdef __cplusplus - extern "C" -#endif - size_t - _xpg5_wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm * ); - #define wxCRT_StrftimeW _xpg5_wcsftime -#else - /* - Assume it's always available under non-Unix systems as this does seem - to be the case for now. And under Unix we trust configure to detect it - (except for SGI special case above). - */ - #if defined(HAVE_WCSFTIME) || !defined(__UNIX__) - #define wxCRT_StrftimeW wcsftime - #endif -#endif - -#ifndef wxCRT_StrftimeW -WXDLLIMPEXP_BASE size_t wxCRT_StrftimeW(wchar_t *s, size_t max, - const wchar_t *fmt, - const struct tm *tm); -#endif - - - -/* ------------------------------------------------------------------------- - ctype.h - ------------------------------------------------------------------------- */ - -#ifdef __WATCOMC__ - #define WXWCHAR_T_CAST(c) (wint_t)(c) -#else - #define WXWCHAR_T_CAST(c) c -#endif - -#define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c)) -#define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c)) -#define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c)) -#define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c)) -#define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c)) -#define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c)) -#define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c)) -#define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c)) -#define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c)) -#define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c)) -#define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c)) - -#ifdef __GLIBC__ - #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) - /* /usr/include/wctype.h incorrectly declares translations */ - /* tables which provokes tons of compile-time warnings -- try */ - /* to correct this */ - #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower) - #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper) - #else /* !glibc 2.0 */ - #define wxCRT_TolowerW towlower - #define wxCRT_ToupperW towupper - #endif -#else /* !__GLIBC__ */ - /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything - with signed chars < 0, so "fix" it here. */ - #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c)) - #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c)) -#endif /* __GLIBC__/!__GLIBC__ */ - - - - - -/* ------------------------------------------------------------------------- - wx wrappers for CRT functions in both char* and wchar_t* versions - ------------------------------------------------------------------------- */ - -#ifdef __cplusplus - -/* NB: this belongs to wxcrt.h and not this header, but it makes life easier - * for buffer.h and stringimpl.h (both of which must be included before - * string.h, which is required by wxcrt.h) to have them here: */ - -/* safe version of strlen() (returns 0 if passed NULL pointer) */ -inline size_t wxStrlen(const char *s) { return s ? wxCRT_StrlenA(s) : 0; } -inline size_t wxStrlen(const wchar_t *s) { return s ? wxCRT_StrlenW(s) : 0; } -#ifndef wxWCHAR_T_IS_WXCHAR16 - WXDLLIMPEXP_BASE size_t wxStrlen(const wxChar16 *s ); -#endif -#ifndef wxWCHAR_T_IS_WXCHAR32 - WXDLLIMPEXP_BASE size_t wxStrlen(const wxChar32 *s ); -#endif -#define wxWcslen wxCRT_StrlenW - -#define wxStrdupA wxCRT_StrdupA -#define wxStrdupW wxCRT_StrdupW -inline char* wxStrdup(const char *s) { return wxCRT_StrdupA(s); } -inline wchar_t* wxStrdup(const wchar_t *s) { return wxCRT_StrdupW(s); } -#ifndef wxWCHAR_T_IS_WXCHAR16 - WXDLLIMPEXP_BASE wxChar16* wxStrdup(const wxChar16* s); -#endif -#ifndef wxWCHAR_T_IS_WXCHAR32 - WXDLLIMPEXP_BASE wxChar32* wxStrdup(const wxChar32* s); -#endif - -#endif /* __cplusplus */ - -#endif /* _WX_WXCRTBASE_H_ */ diff --git a/Source/3rd Party/wx/include/wx/wxcrtvararg.h b/Source/3rd Party/wx/include/wx/wxcrtvararg.h deleted file mode 100644 index 4ad5b9e20..000000000 --- a/Source/3rd Party/wx/include/wx/wxcrtvararg.h +++ /dev/null @@ -1,496 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/wxcrtvararg.h -// Purpose: Type-safe ANSI and Unicode builds compatible wrappers for -// printf(), scanf() and related CRT functions -// Author: Joel Farley, Ove KÃ¥ven -// Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee -// Created: 2007-02-19 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WXCRTVARARG_H_ -#define _WX_WXCRTVARARG_H_ - -// NB: User code should include wx/crt.h instead of including this -// header directly. - -#include "wx/wxcrt.h" -#include "wx/strvararg.h" - -#include "wx/string.h" - -// ---------------------------------------------------------------------------- -// CRT functions aliases -// ---------------------------------------------------------------------------- - -/* Required for wxPrintf() etc */ -#include - -/* printf() family saga */ - -/* - For many old Unix systems [v]snprintf()/vsscanf() exists in the system - libraries but not in the headers, so we need to declare it ourselves to be - able to use it. - */ -#ifdef __UNIX__ - -#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL) -#ifdef __cplusplus - extern "C" -#else - extern -#endif - int vsnprintf(char *str, size_t size, const char *format, va_list ap); -#endif /* !HAVE_VSNPRINTF_DECL */ - -#if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL) -#ifdef __cplusplus - extern "C" -#else - extern -#endif - int snprintf(char *str, size_t size, const char *format, ...); -#endif /* !HAVE_SNPRINTF_DECL */ - -#if defined(HAVE_VSSCANF) && !defined(HAVE_VSSCANF_DECL) -#ifdef __cplusplus - extern "C" -#else - extern -#endif - int vsscanf(const char *str, const char *format, va_list ap); -#endif /* !HAVE_VSSCANF_DECL */ - -/* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the - * same isn't done for snprintf below, the builtin wxSnprintf_ is used - * instead since it's already a simple wrapper */ -#if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL - inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap) - { - return vsnprintf(str, size, (char*)format, ap); - } -#endif - -#endif /* __UNIX__ */ - -/* - mingw32 normally uses MSVCRT which has non-standard vswprintf() and so - normally _vsnwprintf() is used instead, the only exception is when mingw32 - is used with STLPort which does have a standard vswprintf() starting from - version 5.1 which we can use. - */ -#ifdef __MINGW32__ - #if defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 - #ifndef HAVE_VSWPRINTF - #define HAVE_VSWPRINTF - #endif - #elif defined(HAVE_VSWPRINTF) - /* can't use non-standard vswprintf() */ - #undef HAVE_VSWPRINTF - #endif -#endif /* __MINGW32__ */ - -#if defined(__WATCOMC__) - #define HAVE_VSWPRINTF 1 -#endif - -#if wxUSE_PRINTF_POS_PARAMS - /* - The systems where vsnprintf() supports positional parameters should - define the HAVE_UNIX98_PRINTF symbol. - - On systems which don't (e.g. Windows) we are forced to use - our wxVsnprintf() implementation. - */ - #if defined(HAVE_UNIX98_PRINTF) - #ifdef HAVE_VSWPRINTF - #define wxCRT_VsnprintfW vswprintf - #endif - #ifdef HAVE_BROKEN_VSNPRINTF_DECL - #define wxCRT_VsnprintfA wx_fixed_vsnprintf - #else - #define wxCRT_VsnprintfA vsnprintf - #endif - #else /* !HAVE_UNIX98_PRINTF */ - /* - The only compiler with positional parameters support under Windows - is VC++ 8.0 which provides a new xxprintf_p() functions family. - The 2003 PSDK includes a slightly earlier version of VC8 than the - main release and does not have the printf_p functions. - */ - #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__ - #define wxCRT_VsnprintfA _vsprintf_p - #define wxCRT_VsnprintfW _vswprintf_p - #endif - #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */ -#else /* !wxUSE_PRINTF_POS_PARAMS */ - /* - We always want to define safe snprintf() function to be used instead of - sprintf(). Some compilers already have it (or rather vsnprintf() which - we really need...), otherwise we implement it using our own printf() - code. - - We define function with a trailing underscore here because the real one - is a wrapper around it as explained below - */ - - #if defined(__VISUALC__) || \ - (defined(__BORLANDC__) && __BORLANDC__ >= 0x540) - #define wxCRT_VsnprintfA _vsnprintf - #define wxCRT_VsnprintfW _vsnwprintf - #else - #if defined(HAVE__VSNWPRINTF) - #define wxCRT_VsnprintfW _vsnwprintf - #elif defined(HAVE_VSWPRINTF) - #define wxCRT_VsnprintfW vswprintf - #elif defined(__WATCOMC__) - #define wxCRT_VsnprintfW _vsnwprintf - #endif - - #if defined(HAVE_VSNPRINTF) \ - || defined(__WATCOMC__) - #ifdef HAVE_BROKEN_VSNPRINTF_DECL - #define wxCRT_VsnprintfA wx_fixed_vsnprintf - #else - #define wxCRT_VsnprintfA vsnprintf - #endif - #endif - #endif -#endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */ - -#ifndef wxCRT_VsnprintfW - /* no (suitable) vsnprintf(), cook our own */ - WXDLLIMPEXP_BASE int - wxCRT_VsnprintfW(wchar_t *buf, size_t len, const wchar_t *format, va_list argptr); - #define wxUSE_WXVSNPRINTFW 1 -#else - #define wxUSE_WXVSNPRINTFW 0 -#endif - -#ifndef wxCRT_VsnprintfA - /* no (suitable) vsnprintf(), cook our own */ - WXDLLIMPEXP_BASE int - wxCRT_VsnprintfA(char *buf, size_t len, const char *format, va_list argptr); - #define wxUSE_WXVSNPRINTFA 1 -#else - #define wxUSE_WXVSNPRINTFA 0 -#endif - -// for wxString code, define wxUSE_WXVSNPRINTF to indicate that wx -// implementation is used no matter what (in UTF-8 build, either *A or *W -// version may be called): -#if !wxUSE_UNICODE - #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA -#elif wxUSE_UNICODE_WCHAR - #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFW -#elif wxUSE_UTF8_LOCALE_ONLY - #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA -#else // UTF-8 under any locale - #define wxUSE_WXVSNPRINTF (wxUSE_WXVSNPRINTFA && wxUSE_WXVSNPRINTFW) -#endif - -#define wxCRT_FprintfA fprintf -#define wxCRT_PrintfA printf -#define wxCRT_VfprintfA vfprintf -#define wxCRT_VprintfA vprintf -#define wxCRT_VsprintfA vsprintf - -/* - In Unicode mode we need to have all standard functions such as wprintf() and - so on but not all systems have them so use our own implementations in this - case. - */ -#if !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF) - #define wxNEED_WPRINTF -#endif -#if !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_VSWSCANF) && defined(HAVE_VSSCANF) - #define wxNEED_VSWSCANF -#endif - - -#if defined(wxNEED_WPRINTF) - /* - we need to implement all wide character printf functions either because - we don't have them at all or because they don't have the semantics we - need - */ - int wxCRT_PrintfW( const wchar_t *format, ... ); - int wxCRT_FprintfW( FILE *stream, const wchar_t *format, ... ); - int wxCRT_VfprintfW( FILE *stream, const wchar_t *format, va_list ap ); - int wxCRT_VprintfW( const wchar_t *format, va_list ap ); - int wxCRT_VsprintfW( wchar_t *str, const wchar_t *format, va_list ap ); -#else /* !wxNEED_WPRINTF */ - #define wxCRT_FprintfW fwprintf - #define wxCRT_PrintfW wprintf - #define wxCRT_VfprintfW vfwprintf - #define wxCRT_VprintfW vwprintf - - #if defined(__WINDOWS__) && !defined(HAVE_VSWPRINTF) - // only non-standard vswprintf() without buffer size argument can be used here - #define wxCRT_VsprintfW vswprintf - #endif -#endif /* wxNEED_WPRINTF */ - - -/* Required for wxScanf() etc. */ -#define wxCRT_ScanfA scanf -#define wxCRT_SscanfA sscanf -#define wxCRT_FscanfA fscanf - -/* vsscanf() may have a wrong declaration with non-const first parameter, fix - * this by wrapping it if necessary. */ -#if defined __cplusplus && defined HAVE_BROKEN_VSSCANF_DECL - inline int wxCRT_VsscanfA(const char *str, const char *format, va_list ap) - { - return vsscanf(const_cast(str), format, ap); - } -#else - #define wxCRT_VsscanfA vsscanf -#endif - -#if defined(wxNEED_WPRINTF) - int wxCRT_ScanfW(const wchar_t *format, ...); - int wxCRT_SscanfW(const wchar_t *str, const wchar_t *format, ...); - int wxCRT_FscanfW(FILE *stream, const wchar_t *format, ...); -#else - #define wxCRT_ScanfW wxVMS_USE_STD wscanf - #define wxCRT_SscanfW wxVMS_USE_STD swscanf - #define wxCRT_FscanfW wxVMS_USE_STD fwscanf -#endif -#ifdef wxNEED_VSWSCANF - int wxCRT_VsscanfW(const wchar_t *str, const wchar_t *format, va_list ap); -#else - #define wxCRT_VsscanfW wxVMS_USE_STD vswscanf -#endif - -// ---------------------------------------------------------------------------- -// user-friendly wrappers to CRT functions -// ---------------------------------------------------------------------------- - -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - #define wxPrintf wxPrintf_Impl - #define wxFprintf wxFprintf_Impl - #define wxSprintf wxSprintf_Impl - #define wxSnprintf wxSnprintf_Impl -#endif - - // FIXME-UTF8: remove this -#if wxUSE_UNICODE - #define wxCRT_PrintfNative wxCRT_PrintfW - #define wxCRT_FprintfNative wxCRT_FprintfW -#else - #define wxCRT_PrintfNative wxCRT_PrintfA - #define wxCRT_FprintfNative wxCRT_FprintfA -#endif - - -WX_DEFINE_VARARG_FUNC_SANS_N0(int, wxPrintf, 1, (const wxFormatString&), - wxCRT_PrintfNative, wxCRT_PrintfA) -inline int wxPrintf(const wxFormatString& s) -{ - return wxPrintf("%s", s.InputAsString()); -} - -WX_DEFINE_VARARG_FUNC_SANS_N0(int, wxFprintf, 2, (FILE*, const wxFormatString&), - wxCRT_FprintfNative, wxCRT_FprintfA) -inline int wxFprintf(FILE *f, const wxFormatString& s) -{ - return wxFprintf(f, "%s", s.InputAsString()); -} - -// va_list versions of printf functions simply forward to the respective -// CRT function; note that they assume that va_list was created using -// wxArgNormalizer! -#if wxUSE_UNICODE_UTF8 - #if wxUSE_UTF8_LOCALE_ONLY - #define WX_VARARG_VFOO_IMPL(args, implW, implA) \ - return implA args - #else - #define WX_VARARG_VFOO_IMPL(args, implW, implA) \ - if ( wxLocaleIsUtf8 ) return implA args; \ - else return implW args - #endif -#elif wxUSE_UNICODE_WCHAR - #define WX_VARARG_VFOO_IMPL(args, implW, implA) \ - return implW args -#else // ANSI - #define WX_VARARG_VFOO_IMPL(args, implW, implA) \ - return implA args -#endif - -inline int -wxVprintf(const wxString& format, va_list ap) -{ - WX_VARARG_VFOO_IMPL((wxFormatString(format), ap), - wxCRT_VprintfW, wxCRT_VprintfA); -} - -inline int -wxVfprintf(FILE *f, const wxString& format, va_list ap) -{ - WX_VARARG_VFOO_IMPL((f, wxFormatString(format), ap), - wxCRT_VfprintfW, wxCRT_VfprintfA); -} - -#undef WX_VARARG_VFOO_IMPL - - -// wxSprintf() and friends have to be implemented in two forms, one for -// writing to char* buffer and one for writing to wchar_t*: - -#if !wxUSE_UTF8_LOCALE_ONLY -int WXDLLIMPEXP_BASE wxDoSprintfWchar(char *str, const wxChar *format, ...); -#endif -#if wxUSE_UNICODE_UTF8 -int WXDLLIMPEXP_BASE wxDoSprintfUtf8(char *str, const char *format, ...); -#endif -WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (char*, const wxFormatString&), - wxDoSprintfWchar, wxDoSprintfUtf8) - -int WXDLLIMPEXP_BASE -wxVsprintf(char *str, const wxString& format, va_list argptr); - -#if !wxUSE_UTF8_LOCALE_ONLY -int WXDLLIMPEXP_BASE wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...); -#endif -#if wxUSE_UNICODE_UTF8 -int WXDLLIMPEXP_BASE wxDoSnprintfUtf8(char *str, size_t size, const char *format, ...); -#endif -WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (char*, size_t, const wxFormatString&), - wxDoSnprintfWchar, wxDoSnprintfUtf8) - -int WXDLLIMPEXP_BASE -wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr); - -#if wxUSE_UNICODE - -#if !wxUSE_UTF8_LOCALE_ONLY -int WXDLLIMPEXP_BASE wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...); -#endif -#if wxUSE_UNICODE_UTF8 -int WXDLLIMPEXP_BASE wxDoSprintfUtf8(wchar_t *str, const char *format, ...); -#endif -WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (wchar_t*, const wxFormatString&), - wxDoSprintfWchar, wxDoSprintfUtf8) - -int WXDLLIMPEXP_BASE -wxVsprintf(wchar_t *str, const wxString& format, va_list argptr); - -#if !wxUSE_UTF8_LOCALE_ONLY -int WXDLLIMPEXP_BASE wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...); -#endif -#if wxUSE_UNICODE_UTF8 -int WXDLLIMPEXP_BASE wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...); -#endif -WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (wchar_t*, size_t, const wxFormatString&), - wxDoSnprintfWchar, wxDoSnprintfUtf8) - -int WXDLLIMPEXP_BASE -wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr); - -#endif // wxUSE_UNICODE - -#ifdef __WATCOMC__ - // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - // - // fortunately, OpenWatcom implements __VA_ARGS__, so we can provide macros - // that cast the format argument to wxString: - #undef wxPrintf - #undef wxFprintf - #undef wxSprintf - #undef wxSnprintf - - #define wxPrintf(fmt, ...) \ - wxPrintf_Impl(wxFormatString(fmt), __VA_ARGS__) - #define wxFprintf(f, fmt, ...) \ - wxFprintf_Impl(f, wxFormatString(fmt), __VA_ARGS__) - #define wxSprintf(s, fmt, ...) \ - wxSprintf_Impl(s, wxFormatString(fmt), __VA_ARGS__) - #define wxSnprintf(s, n, fmt, ...) \ - wxSnprintf_Impl(s, n, wxFormatString(fmt), __VA_ARGS__) -#endif // __WATCOMC__ - - -// We can't use wxArgNormalizer for variadic arguments to wxScanf() etc. -// because they are writable, so instead of providing friendly template -// vararg-like functions, we just provide both char* and wchar_t* variants -// of these functions. The type of output variadic arguments for %s must match -// the type of 'str' and 'format' arguments. -// -// For compatibility with earlier wx versions, we also provide wxSscanf() -// version with the first argument (input string) wxString; for this version, -// the type of output string values is determined by the type of format string -// only. - -#define _WX_SCANFUNC_EXTRACT_ARGS_1(x) x -#define _WX_SCANFUNC_EXTRACT_ARGS_2(x,y) x, y -#define _WX_SCANFUNC_EXTRACT_ARGS(N, args) _WX_SCANFUNC_EXTRACT_ARGS_##N args - -#define _WX_VARARG_PASS_WRITABLE(i) a##i - -#define _WX_DEFINE_SCANFUNC(N, dummy1, name, impl, passfixed, numfixed, fixed)\ - template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \ - int name(_WX_SCANFUNC_EXTRACT_ARGS(numfixed, fixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \ - { \ - return impl(_WX_SCANFUNC_EXTRACT_ARGS(numfixed, passfixed), \ - _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WRITABLE)); \ - } - -#define WX_DEFINE_SCANFUNC(name, numfixed, fixed, impl, passfixed) \ - _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ - _WX_DEFINE_SCANFUNC, \ - dummy1, name, impl, passfixed, numfixed, fixed) - -// this is needed to normalize the format string, see src/common/strvararg.cpp -// for more details -#ifdef __WINDOWS__ - #define wxScanfConvertFormatW(fmt) fmt -#else - const wxScopedWCharBuffer - WXDLLIMPEXP_BASE wxScanfConvertFormatW(const wchar_t *format); -#endif - -WX_DEFINE_SCANFUNC(wxScanf, 1, (const char *format), - wxCRT_ScanfA, (format)) -WX_DEFINE_SCANFUNC(wxScanf, 1, (const wchar_t *format), - wxCRT_ScanfW, (wxScanfConvertFormatW(format))) - -WX_DEFINE_SCANFUNC(wxFscanf, 2, (FILE *stream, const char *format), - wxCRT_FscanfA, (stream, format)) -WX_DEFINE_SCANFUNC(wxFscanf, 2, (FILE *stream, const wchar_t *format), - wxCRT_FscanfW, (stream, wxScanfConvertFormatW(format))) - -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const char *str, const char *format), - wxCRT_SscanfA, (str, format)) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wchar_t *str, const wchar_t *format), - wxCRT_SscanfW, (str, wxScanfConvertFormatW(format))) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedCharBuffer& str, const char *format), - wxCRT_SscanfA, (str.data(), format)) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedWCharBuffer& str, const wchar_t *format), - wxCRT_SscanfW, (str.data(), wxScanfConvertFormatW(format))) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const char *format), - wxCRT_SscanfA, (str.mb_str(), format)) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const wchar_t *format), - wxCRT_SscanfW, (str.wc_str(), wxScanfConvertFormatW(format))) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCStrData& str, const char *format), - wxCRT_SscanfA, (str.AsCharBuf(), format)) -WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCStrData& str, const wchar_t *format), - wxCRT_SscanfW, (str.AsWCharBuf(), wxScanfConvertFormatW(format))) - -// Visual C++ doesn't provide vsscanf() -#ifndef __VISUALC___ -int WXDLLIMPEXP_BASE wxVsscanf(const char *str, const char *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxScopedCharBuffer& str, const char *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxScopedWCharBuffer& str, const wchar_t *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const char *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const wchar_t *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const char *format, va_list ap); -int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap); -#endif // !__VISUALC__ - -#endif /* _WX_WXCRTVARARG_H_ */ diff --git a/Source/3rd Party/wx/include/wx/wxhtml.h b/Source/3rd Party/wx/include/wx/wxhtml.h deleted file mode 100644 index 9759dac06..000000000 --- a/Source/3rd Party/wx/include/wx/wxhtml.h +++ /dev/null @@ -1,21 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/wxhtml.h -// Purpose: wxHTML library for wxWidgets -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_HTML_H_ -#define _WX_HTML_H_ - -#include "wx/html/htmldefs.h" -#include "wx/html/htmltag.h" -#include "wx/html/htmlcell.h" -#include "wx/html/htmlpars.h" -#include "wx/html/htmlwin.h" -#include "wx/html/winpars.h" -#include "wx/filesys.h" -#include "wx/html/helpctrl.h" - -#endif // __WXHTML_H__ diff --git a/Source/3rd Party/wx/include/wx/wxprec.h b/Source/3rd Party/wx/include/wx/wxprec.h index 5bedcce2e..184914e6c 100644 --- a/Source/3rd Party/wx/include/wx/wxprec.h +++ b/Source/3rd Party/wx/include/wx/wxprec.h @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: wxprec.h 39484 2006-05-31 12:18:02Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,9 +17,10 @@ #if defined(__VISUALC__) || \ defined(__DMC__) || \ defined(__VISAGECPP__) || \ + defined(__MWERKS__) || \ defined(__WATCOMC__) || \ defined(__BORLANDC__) - + // If user did not request NOCPH and we're not building using configure // then assume user wants precompiled headers. @@ -34,26 +36,34 @@ #ifdef WX_PRECOMP -// include "wx/chartype.h" first to ensure that UNICODE macro is correctly set +// include "wx/wxchar.h" first to ensure that UNICODE macro is correctly set // _before_ including -#include "wx/chartype.h" +#include "wx/wxchar.h" // include standard Windows headers -#if defined(__WINDOWS__) - #include "wx/msw/wrapwin.h" - #include "wx/msw/private.h" -#endif #if defined(__WXMSW__) + #include "wx/msw/wrapwin.h" #include "wx/msw/wrapcctl.h" #include "wx/msw/wrapcdlg.h" + #include "wx/msw/private.h" #include "wx/msw/missing.h" #endif +// include all PalmOS headers at once +#ifdef __WXPALMOS__ +# include +#endif + // include #ifdef __OS2__ # include "wx/os2/private.h" #endif +// include mgl headers +#ifdef __WXMGL__ +# include "wx/mgl/private.h" +#endif + // include the most common wx headers #include "wx/wx.h" diff --git a/Source/3rd Party/wx/include/wx/xlocale.h b/Source/3rd Party/wx/include/wx/xlocale.h deleted file mode 100644 index 6a01ad311..000000000 --- a/Source/3rd Party/wx/include/wx/xlocale.h +++ /dev/null @@ -1,340 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Name: wx/xlocale.h -// Purpose: Header to provide some xlocale wrappers -// Author: Brian Vanderburg II, Vadim Zeitlin -// Created: 2008-01-07 -// Copyright: (c) 2008 Brian Vanderburg II -// 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -/* - This header defines portable wrappers around xlocale foo_l() functions or - their MSVC proprietary _foo_l() equivalents when they are available and - implements these functions for the "C" locale [only] if they are not. This - allows the program running under the default user locale to still use "C" - locale for operations such as reading data from files where they are stored - using decimal point &c. - - TODO: Currently only the character classification and transformation - functions and number <-> string functions, are implemented, - we also need at least - - formatted IO: scanf_l(), printf_l() &c - - time: strftime_l(), strptime_l() - */ - -#ifndef _WX_XLOCALE_H_ -#define _WX_XLOCALE_H_ - -#include "wx/defs.h" // wxUSE_XLOCALE - -#if wxUSE_XLOCALE - -#include "wx/crt.h" // Includes wx/chartype.h, wx/wxcrt.h(wx/string.h) -#include "wx/intl.h" // wxLanguage - -// The platform-specific locale type -// If wxXLocale_t is not defined, then only "C" locale support is provided -#ifdef wxHAS_XLOCALE_SUPPORT - #if wxCHECK_VISUALC_VERSION(8) && !defined(__WXWINCE__) - typedef _locale_t wxXLocale_t; - #define wxXLOCALE_IDENT(name) _ ## name - #elif defined(HAVE_LOCALE_T) - #include - #include - #include - #include - - #if wxUSE_UNICODE - #include - #endif - - // Locale type and identifier name - typedef locale_t wxXLocale_t; - - #define wxXLOCALE_IDENT(name) name - #else - #error "Unknown xlocale support" - #endif -#endif // wxHAS_XLOCALE_SUPPORT - - -// wxXLocale is a wrapper around the native type representing a locale. -// -// It is not to be confused with wxLocale, which handles actually changing the -// locale, loading message catalogs, etc. This just stores a locale value. -// The similarity of names is unfortunate, but there doesn't seem to be any -// better alternative right now. Perhaps by wxWidgets 4.0 better naming could -// be used, or this class could become wxLocale (a wrapper for the value), and -// some other class could be used to load the language catalogs or something -// that would be clearer -#ifdef wxHAS_XLOCALE_SUPPORT - -class WXDLLIMPEXP_BASE wxXLocale -{ -public: - // Construct an uninitialized locale - wxXLocale() { m_locale = NULL; } - - // Construct from a symbolic language constant - wxXLocale(wxLanguage lang); - - // Construct from the given language string - wxXLocale(const char *loc) { Init(loc); } - - // Destroy the locale - ~wxXLocale() { Free(); } - - - // Get the global "C" locale object - static wxXLocale& GetCLocale(); - - // Check if the object represents a valid locale (notice that without - // wxHAS_XLOCALE_SUPPORT the only valid locale is the "C" one) - bool IsOk() const { return m_locale != NULL; } - - // Get the type - wxXLocale_t Get() const { return m_locale; } - - bool operator== (const wxXLocale& loc) const - { return m_locale == loc.m_locale; } - -private: - // Special ctor for the "C" locale, it's only used internally as the user - // code is supposed to use GetCLocale() - wxXLocale(struct wxXLocaleCTag * WXUNUSED(dummy)) { Init("C"); } - - // Create from the given language string (called from ctors) - void Init(const char *loc); - - // Free the locale if it's non-NULL - void Free(); - - - // The corresponding locale handle, NULL if invalid - wxXLocale_t m_locale; - - - // POSIX xlocale API provides a duplocale() function but MSVC locale API - // doesn't give us any means to copy a _locale_t object so we reduce the - // functionality to least common denominator here -- it shouldn't be a - // problem as copying the locale objects shouldn't be often needed - wxDECLARE_NO_COPY_CLASS(wxXLocale); -}; - -#else // !wxHAS_XLOCALE_SUPPORT - -// Skeleton version supporting only the "C" locale for the systems without -// xlocale support -class WXDLLIMPEXP_BASE wxXLocale -{ -public: - // Construct an uninitialized locale - wxXLocale() { m_isC = false; } - - // Construct from a symbolic language constant: unless the language is - // wxLANGUAGE_ENGLISH_US (which we suppose to be the same as "C" locale) - // the object will be invalid - wxXLocale(wxLanguage lang) - { - m_isC = lang == wxLANGUAGE_ENGLISH_US; - } - - // Construct from the given language string: unless the string is "C" or - // "POSIX" the object will be invalid - wxXLocale(const char *loc) - { - m_isC = loc && (strcmp(loc, "C") == 0 || strcmp(loc, "POSIX") == 0); - } - - // Default copy ctor, assignment operator and dtor are ok (or would be if - // we didn't use DECLARE_NO_COPY_CLASS() for consistency with the xlocale - // version) - - - // Get the global "C" locale object - static wxXLocale& GetCLocale(); - - // Check if the object represents a valid locale (notice that without - // wxHAS_XLOCALE_SUPPORT the only valid locale is the "C" one) - bool IsOk() const { return m_isC; } - -private: - // Special ctor for the "C" locale, it's only used internally as the user - // code is supposed to use GetCLocale() - wxXLocale(struct wxXLocaleCTag * WXUNUSED(dummy)) { m_isC = true; } - - // Without xlocale support this class can only represent "C" locale, if - // this is false the object is invalid - bool m_isC; - - - // although it's not a problem to copy the objects of this class, we use - // this macro in this implementation for consistency with the xlocale-based - // one which can't be copied when using MSVC locale API - wxDECLARE_NO_COPY_CLASS(wxXLocale); -}; - -#endif // wxHAS_XLOCALE_SUPPORT/!wxHAS_XLOCALE_SUPPORT - - -// A shorter synonym for the most commonly used locale object -#define wxCLocale (wxXLocale::GetCLocale()) -extern WXDLLIMPEXP_DATA_BASE(wxXLocale) wxNullXLocale; - -// Wrappers for various functions: -#ifdef wxHAS_XLOCALE_SUPPORT - - // ctype functions - #define wxCRT_Isalnum_lA wxXLOCALE_IDENT(isalnum_l) - #define wxCRT_Isalpha_lA wxXLOCALE_IDENT(isalpha_l) - #define wxCRT_Iscntrl_lA wxXLOCALE_IDENT(iscntrl_l) - #define wxCRT_Isdigit_lA wxXLOCALE_IDENT(isdigit_l) - #define wxCRT_Isgraph_lA wxXLOCALE_IDENT(isgraph_l) - #define wxCRT_Islower_lA wxXLOCALE_IDENT(islower_l) - #define wxCRT_Isprint_lA wxXLOCALE_IDENT(isprint_l) - #define wxCRT_Ispunct_lA wxXLOCALE_IDENT(ispunct_l) - #define wxCRT_Isspace_lA wxXLOCALE_IDENT(isspace_l) - #define wxCRT_Isupper_lA wxXLOCALE_IDENT(isupper_l) - #define wxCRT_Isxdigit_lA wxXLOCALE_IDENT(isxdigit_l) - #define wxCRT_Tolower_lA wxXLOCALE_IDENT(tolower_l) - #define wxCRT_Toupper_lA wxXLOCALE_IDENT(toupper_l) - - inline int wxIsalnum_l(char c, const wxXLocale& loc) - { return wxCRT_Isalnum_lA(static_cast(c), loc.Get()); } - inline int wxIsalpha_l(char c, const wxXLocale& loc) - { return wxCRT_Isalpha_lA(static_cast(c), loc.Get()); } - inline int wxIscntrl_l(char c, const wxXLocale& loc) - { return wxCRT_Iscntrl_lA(static_cast(c), loc.Get()); } - inline int wxIsdigit_l(char c, const wxXLocale& loc) - { return wxCRT_Isdigit_lA(static_cast(c), loc.Get()); } - inline int wxIsgraph_l(char c, const wxXLocale& loc) - { return wxCRT_Isgraph_lA(static_cast(c), loc.Get()); } - inline int wxIslower_l(char c, const wxXLocale& loc) - { return wxCRT_Islower_lA(static_cast(c), loc.Get()); } - inline int wxIsprint_l(char c, const wxXLocale& loc) - { return wxCRT_Isprint_lA(static_cast(c), loc.Get()); } - inline int wxIspunct_l(char c, const wxXLocale& loc) - { return wxCRT_Ispunct_lA(static_cast(c), loc.Get()); } - inline int wxIsspace_l(char c, const wxXLocale& loc) - { return wxCRT_Isspace_lA(static_cast(c), loc.Get()); } - inline int wxIsupper_l(char c, const wxXLocale& loc) - { return wxCRT_Isupper_lA(static_cast(c), loc.Get()); } - inline int wxIsxdigit_l(char c, const wxXLocale& loc) - { return wxCRT_Isxdigit_lA(static_cast(c), loc.Get()); } - inline int wxTolower_l(char c, const wxXLocale& loc) - { return wxCRT_Tolower_lA(static_cast(c), loc.Get()); } - inline int wxToupper_l(char c, const wxXLocale& loc) - { return wxCRT_Toupper_lA(static_cast(c), loc.Get()); } - - - // stdlib functions for numeric <-> string conversion - // NOTE: GNU libc does not have ato[fil]_l functions; - // MSVC++8 does not have _strto[u]ll_l functions; - // thus we take the minimal set of functions provided in both environments: - - #define wxCRT_Strtod_lA wxXLOCALE_IDENT(strtod_l) - #define wxCRT_Strtol_lA wxXLOCALE_IDENT(strtol_l) - #define wxCRT_Strtoul_lA wxXLOCALE_IDENT(strtoul_l) - - inline double wxStrtod_lA(const char *c, char **endptr, const wxXLocale& loc) - { return wxCRT_Strtod_lA(c, endptr, loc.Get()); } - inline long wxStrtol_lA(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtol_lA(c, endptr, base, loc.Get()); } - inline unsigned long wxStrtoul_lA(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } - - #if wxUSE_UNICODE - - // ctype functions - #define wxCRT_Isalnum_lW wxXLOCALE_IDENT(iswalnum_l) - #define wxCRT_Isalpha_lW wxXLOCALE_IDENT(iswalpha_l) - #define wxCRT_Iscntrl_lW wxXLOCALE_IDENT(iswcntrl_l) - #define wxCRT_Isdigit_lW wxXLOCALE_IDENT(iswdigit_l) - #define wxCRT_Isgraph_lW wxXLOCALE_IDENT(iswgraph_l) - #define wxCRT_Islower_lW wxXLOCALE_IDENT(iswlower_l) - #define wxCRT_Isprint_lW wxXLOCALE_IDENT(iswprint_l) - #define wxCRT_Ispunct_lW wxXLOCALE_IDENT(iswpunct_l) - #define wxCRT_Isspace_lW wxXLOCALE_IDENT(iswspace_l) - #define wxCRT_Isupper_lW wxXLOCALE_IDENT(iswupper_l) - #define wxCRT_Isxdigit_lW wxXLOCALE_IDENT(iswxdigit_l) - #define wxCRT_Tolower_lW wxXLOCALE_IDENT(towlower_l) - #define wxCRT_Toupper_lW wxXLOCALE_IDENT(towupper_l) - - inline int wxIsalnum_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isalnum_lW(c, loc.Get()); } - inline int wxIsalpha_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isalpha_lW(c, loc.Get()); } - inline int wxIscntrl_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Iscntrl_lW(c, loc.Get()); } - inline int wxIsdigit_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isdigit_lW(c, loc.Get()); } - inline int wxIsgraph_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isgraph_lW(c, loc.Get()); } - inline int wxIslower_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Islower_lW(c, loc.Get()); } - inline int wxIsprint_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isprint_lW(c, loc.Get()); } - inline int wxIspunct_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Ispunct_lW(c, loc.Get()); } - inline int wxIsspace_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isspace_lW(c, loc.Get()); } - inline int wxIsupper_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isupper_lW(c, loc.Get()); } - inline int wxIsxdigit_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isxdigit_lW(c, loc.Get()); } - inline wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Tolower_lW(c, loc.Get()); } - inline wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Toupper_lW(c, loc.Get()); } - - - // stdlib functions for numeric <-> string conversion - // (see notes above about missing functions) - #define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l) - #define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l) - #define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l) - - inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc) - { return wxCRT_Strtod_lW(c, endptr, loc.Get()); } - inline long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtol_lW(c, endptr, base, loc.Get()); } - inline unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtoul_lW(c, endptr, base, loc.Get()); } - #else // !wxUSE_UNICODE - inline double wxStrtod_l(const char *c, char **endptr, const wxXLocale& loc) - { return wxCRT_Strtod_lA(c, endptr, loc.Get()); } - inline long wxStrtol_l(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtol_lA(c, endptr, base, loc.Get()); } - inline unsigned long wxStrtoul_l(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } - #endif // wxUSE_UNICODE -#else // !wxHAS_XLOCALE_SUPPORT - // ctype functions - int WXDLLIMPEXP_BASE wxIsalnum_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsalpha_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIscntrl_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsdigit_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsgraph_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIslower_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsprint_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIspunct_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsspace_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsupper_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxIsxdigit_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxTolower_l(const wxUniChar& c, const wxXLocale& loc); - int WXDLLIMPEXP_BASE wxToupper_l(const wxUniChar& c, const wxXLocale& loc); - - // stdlib functions - double WXDLLIMPEXP_BASE wxStrtod_l(const wchar_t* str, wchar_t **endptr, const wxXLocale& loc); - double WXDLLIMPEXP_BASE wxStrtod_l(const char* str, char **endptr, const wxXLocale& loc); - long WXDLLIMPEXP_BASE wxStrtol_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc); - long WXDLLIMPEXP_BASE wxStrtol_l(const char* str, char **endptr, int base, const wxXLocale& loc); - unsigned long WXDLLIMPEXP_BASE wxStrtoul_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc); - unsigned long WXDLLIMPEXP_BASE wxStrtoul_l(const char* str, char **endptr, int base, const wxXLocale& loc); - -#endif // wxHAS_XLOCALE_SUPPORT/!wxHAS_XLOCALE_SUPPORT - -#endif // wxUSE_XLOCALE - -#endif // _WX_XLOCALE_H_ diff --git a/Source/3rd Party/wx/include/wx/xpmdecod.h b/Source/3rd Party/wx/include/wx/xpmdecod.h index 0755f1aef..8cb516ae3 100644 --- a/Source/3rd Party/wx/include/wx/xpmdecod.h +++ b/Source/3rd Party/wx/include/wx/xpmdecod.h @@ -2,6 +2,7 @@ // Name: wx/xpmdecod.h // Purpose: wxXPMDecoder, XPM reader for wxImage and wxBitmap // Author: Vaclav Slavik +// CVS-ID: $Id: xpmdecod.h 49804 2007-11-10 01:09:42Z VZ $ // Copyright: (c) 2001 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -20,7 +21,7 @@ class WXDLLIMPEXP_FWD_BASE wxInputStream; // wxXPMDecoder class // -------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxXPMDecoder +class WXDLLEXPORT wxXPMDecoder { public: // constructor, destructor, etc. @@ -29,20 +30,15 @@ public: #if wxUSE_STREAMS // Is the stream XPM file? - // NOTE: this function modifies the current stream position bool CanRead(wxInputStream& stream); - // Read XPM file from the stream, parse it and create image from it wxImage ReadFile(wxInputStream& stream); #endif - // Read directly from XPM data (as passed to wxBitmap ctor): wxImage ReadData(const char* const* xpm_data); - #ifdef __BORLANDC__ // needed for Borland 5.5 - wxImage ReadData(char** xpm_data) - { return ReadData(const_cast(xpm_data)); } + wxImage ReadData(char** xpm_data) { return ReadData(wx_const_cast(const char* const*, xpm_data)); } #endif }; diff --git a/Source/3rd Party/wx/include/wx/xpmhand.h b/Source/3rd Party/wx/include/wx/xpmhand.h deleted file mode 100644 index 0952748d8..000000000 --- a/Source/3rd Party/wx/include/wx/xpmhand.h +++ /dev/null @@ -1,24 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xpmhand.h -// Purpose: XPM handler base header -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_XPMHAND_H_BASE_ -#define _WX_XPMHAND_H_BASE_ - -// Only wxMSW and wxPM currently defines a separate XPM handler, since -// mostly Windows and Presentation Manager apps won't need XPMs. -#if defined(__WXMSW__) -#error xpmhand.h is no longer needed since wxImage now handles XPMs. -#endif -#if defined(__WXPM__) -#include "wx/os2/xpmhand.h" -#endif - -#endif - // _WX_XPMHAND_H_BASE_ diff --git a/Source/3rd Party/wx/include/wx/xti.h b/Source/3rd Party/wx/include/wx/xti.h index 444303824..5fd35efb4 100644 --- a/Source/3rd Party/wx/include/wx/xti.h +++ b/Source/3rd Party/wx/include/wx/xti.h @@ -2,8 +2,9 @@ // Name: wx/xti.h // Purpose: runtime metadata information (extended class info) // Author: Stefan Csomor -// Modified by: Francesco Montorsi +// Modified by: // Created: 27/07/03 +// RCS-ID: $Id: xti.h 52488 2008-03-14 14:13:05Z JS $ // Copyright: (c) 1997 Julian Smart // (c) 2003 Stefan Csomor // Licence: wxWindows licence @@ -19,11 +20,11 @@ // This means we have the following domains : // // - Type Information for categorizing built in types as well as custom types -// this includes information about enums, their values and names -// - Type safe value storage : a kind of wxVariant, called right now wxAny -// which will be merged with wxVariant +// this includes information about enums, their values and names +// - Type safe value storage : a kind of wxVariant, called right now wxxVariant +// which will be merged with wxVariant // - Property Information and Property Accessors providing access to a class' -// values and exposed event delegates +// values and exposed event delegates // - Information about event handlers // - extended Class Information for accessing all these @@ -32,96 +33,1588 @@ // ---------------------------------------------------------------------------- #include "wx/defs.h" +#include "wx/memory.h" +#include "wx/flags.h" +#include "wx/string.h" +#include "wx/arrstr.h" +#include "wx/hashmap.h" +#include "wx/log.h" +#include "wx/intl.h" -#if wxUSE_EXTENDED_RTTI +#include -class WXDLLIMPEXP_FWD_BASE wxAny; -class WXDLLIMPEXP_FWD_BASE wxAnyList; -class WXDLLIMPEXP_FWD_BASE wxObject; -class WXDLLIMPEXP_FWD_BASE wxString; -class WXDLLIMPEXP_FWD_BASE wxClassInfo; -class WXDLLIMPEXP_FWD_BASE wxHashTable; -class WXDLLIMPEXP_FWD_BASE wxObject; -class WXDLLIMPEXP_FWD_BASE wxPluginLibrary; -class WXDLLIMPEXP_FWD_BASE wxHashTable; -class WXDLLIMPEXP_FWD_BASE wxHashTable_Node; +// we will move this later to defs.h -class WXDLLIMPEXP_FWD_BASE wxStringToAnyHashMap; -class WXDLLIMPEXP_FWD_BASE wxPropertyInfoMap; -class WXDLLIMPEXP_FWD_BASE wxPropertyAccessor; -class WXDLLIMPEXP_FWD_BASE wxObjectAllocatorAndCreator; -class WXDLLIMPEXP_FWD_BASE wxObjectAllocator; +#if defined(__GNUC__) && !wxCHECK_GCC_VERSION( 3 , 4 ) +# define wxUSE_MEMBER_TEMPLATES 0 +#endif + +#if defined(_MSC_VER) && _MSC_VER <= 1200 +# define wxUSE_MEMBER_TEMPLATES 0 +# define wxUSE_FUNC_TEMPLATE_POINTER 0 +#endif + +#ifndef wxUSE_MEMBER_TEMPLATES +# define wxUSE_MEMBER_TEMPLATES 1 +#endif + +#ifndef wxUSE_FUNC_TEMPLATE_POINTER +# define wxUSE_FUNC_TEMPLATE_POINTER 1 +#endif + +#if wxUSE_MEMBER_TEMPLATES +# define wxTEMPLATED_MEMBER_CALL( method , type ) method() +# define wxTEMPLATED_MEMBER_FIX( type ) +#else +# define wxTEMPLATED_MEMBER_CALL( method , type ) method((type*)NULL) +# define wxTEMPLATED_MEMBER_FIX( type ) type* =NULL +#endif + +#if defined(_MSC_VER) && _MSC_VER <= 1200 +# define wxTEMPLATED_FUNCTION_FIX( type ) , wxTEMPLATED_MEMBER_FIX(type) +# define wxINFUNC_CLASS_TYPE_FIX( type ) typedef type type; +#else +# define wxTEMPLATED_FUNCTION_FIX( type ) +# define wxINFUNC_CLASS_TYPE_FIX( type ) +#endif + +#define EMPTY_MACROVALUE /**/ + +class WXDLLIMPEXP_BASE wxObject; +class WXDLLIMPEXP_BASE wxClassInfo; +class WXDLLIMPEXP_BASE wxDynamicClassInfo; +class WXDLLIMPEXP_BASE wxHashTable; +class WXDLLIMPEXP_BASE wxObjectRefData; +class WXDLLIMPEXP_BASE wxEvent; +class WXDLLIMPEXP_BASE wxEvtHandler; + +typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); + +#if wxUSE_FUNC_TEMPLATE_POINTER +# define wxTO_STRING(type) wxToStringConverter +# define wxTO_STRING_IMP(type) +# define wxFROM_STRING(type) wxFromStringConverter +# define wxFROM_STRING_IMP(type) +#else +# define wxTO_STRING(type) ToString##type +# define wxTO_STRING_IMP(type) inline void ToString##type( const wxxVariant& data , wxString &result ) { wxToStringConverter(data, result); } +# define wxFROM_STRING(type) FromString##type +# define wxFROM_STRING_IMP(type) inline void FromString##type( const wxString& data , wxxVariant &result ) { wxFromStringConverter(data, result); } +#endif + +// ---------------------------------------------------------------------------- +// Enum Support +// +// In the header files there would no change from pure c++ code, in the +// implementation, an enum would have +// to be enumerated eg : +// +// wxBEGIN_ENUM( wxFlavor ) +// wxENUM_MEMBER( Vanilla ) +// wxENUM_MEMBER( Chocolate ) +// wxENUM_MEMBER( Strawberry ) +// wxEND_ENUM( wxFlavor ) +// ---------------------------------------------------------------------------- + +struct WXDLLIMPEXP_BASE wxEnumMemberData +{ + const wxChar* m_name; + int m_value; +}; + +class WXDLLIMPEXP_BASE wxEnumData +{ +public : + wxEnumData( wxEnumMemberData* data ) ; + + // returns true if the member has been found and sets the int value + // pointed to accordingly (if ptr != null ) + // if not found returns false, value left unchanged + bool HasEnumMemberValue( const wxChar *name , int *value = NULL ) const ; + + // returns the value of the member, if not found in debug mode an + // assert is issued, in release 0 is returned + int GetEnumMemberValue(const wxChar *name ) const ; + + // returns the name of the enum member having the passed in value + // returns an emtpy string if not found + const wxChar *GetEnumMemberName(int value) const ; + + // returns the number of members in this enum + int GetEnumCount() const { return m_count ; } + + // returns the value of the nth member + int GetEnumMemberValueByIndex( int n ) const ; + + // returns the value of the nth member + const wxChar *GetEnumMemberNameByIndex( int n ) const ; +private : + wxEnumMemberData *m_members; + int m_count ; +}; + +#define wxBEGIN_ENUM( e ) \ + wxEnumMemberData s_enumDataMembers##e[] = { + +#define wxENUM_MEMBER( v ) { wxT(#v), v } , + +#define wxEND_ENUM( e ) { NULL , 0 } } ; \ + wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \ + wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \ + template<> void wxStringReadValue(const wxString& s , e &data ) \ +{ \ + data = (e) s_enumData##e.GetEnumMemberValue(s) ; \ +} \ + template<> void wxStringWriteValue(wxString &s , const e &data ) \ +{ \ + s = s_enumData##e.GetEnumMemberName((int)data) ; \ +} \ + void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant((e)data) ;} \ + void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , e) ;} \ + wxTO_STRING_IMP( e ) \ + wxFROM_STRING_IMP( e ) \ + wxEnumTypeInfo s_typeInfo##e(wxT_ENUM , &s_enumData##e , &wxTO_STRING( e ) , &wxFROM_STRING( e ) , &ToLong##e , &FromLong##e , typeid(e).name() ) ; + +// ---------------------------------------------------------------------------- +// Set Support +// +// in the header : +// +// enum wxFlavor +// { +// Vanilla, +// Chocolate, +// Strawberry, +// }; +// +// typedef wxBitset wxCoupe ; +// +// in the implementation file : +// +// wxBEGIN_ENUM( wxFlavor ) +// wxENUM_MEMBER( Vanilla ) +// wxENUM_MEMBER( Chocolate ) +// wxENUM_MEMBER( Strawberry ) +// wxEND_ENUM( wxFlavor ) +// +// wxIMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor ) +// +// implementation note : no partial specialization for streaming, but a delegation to a +// different class +// +// ---------------------------------------------------------------------------- + +// in order to remove dependancy on string tokenizer +void WXDLLIMPEXP_BASE wxSetStringToArray( const wxString &s , wxArrayString &array ) ; + +template +void wxSetFromString(const wxString &s , wxBitset &data ) +{ + wxEnumData* edata = wxGetEnumData((e) 0) ; + data.reset() ; + + wxArrayString array ; + wxSetStringToArray( s , array ) ; + wxString flag; + for ( int i = 0 ; i < array.Count() ; ++i ) + { + flag = array[i] ; + int ivalue ; + if ( edata->HasEnumMemberValue( flag , &ivalue ) ) + { + data.set( (e) ivalue ) ; + } + } +} + +template +void wxSetToString( wxString &s , const wxBitset &data ) +{ + wxEnumData* edata = wxGetEnumData((e) 0) ; + int count = edata->GetEnumCount() ; + int i ; + s.Clear() ; + for ( i = 0 ; i < count ; i++ ) + { + e value = (e) edata->GetEnumMemberValueByIndex(i) ; + if ( data.test( value ) ) + { + // this could also be done by the templated calls + if ( !s.empty() ) + s +=wxT("|") ; + s += edata->GetEnumMemberNameByIndex(i) ; + } + } +} + +#define wxIMPLEMENT_SET_STREAMING(SetName,e) \ + template<> void wxStringReadValue(const wxString &s , wxBitset &data ) \ +{ \ + wxSetFromString( s , data ) ; \ +} \ + template<> void wxStringWriteValue( wxString &s , const wxBitset &data ) \ +{ \ + wxSetToString( s , data ) ; \ +} \ + void FromLong##SetName( long data , wxxVariant& result ) { result = wxxVariant(SetName((unsigned long)data)) ;} \ + void ToLong##SetName( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , SetName).to_ulong() ;} \ + wxTO_STRING_IMP( SetName ) \ + wxFROM_STRING_IMP( SetName ) \ + wxEnumTypeInfo s_typeInfo##SetName(wxT_SET , &s_enumData##e , &wxTO_STRING( SetName ) , &wxFROM_STRING( SetName ) , &ToLong##SetName , &FromLong##SetName, typeid(SetName).name() ) ; \ +} + +template +void wxFlagsFromString(const wxString &s , e &data ) +{ + wxEnumData* edata = wxGetEnumData((e*) 0) ; + data.m_data = 0 ; + + wxArrayString array ; + wxSetStringToArray( s , array ) ; + wxString flag; + for ( size_t i = 0 ; i < array.Count() ; ++i ) + { + flag = array[i] ; + int ivalue ; + if ( edata->HasEnumMemberValue( flag , &ivalue ) ) + { + data.m_data |= ivalue ; + } + } +} + +template +void wxFlagsToString( wxString &s , const e& data ) +{ + wxEnumData* edata = wxGetEnumData((e*) 0) ; + int count = edata->GetEnumCount() ; + int i ; + s.Clear() ; + long dataValue = data.m_data ; + for ( i = 0 ; i < count ; i++ ) + { + int value = edata->GetEnumMemberValueByIndex(i) ; + // make this to allow for multi-bit constants to work + if ( value && ( dataValue & value ) == value ) + { + // clear the flags we just set + dataValue &= ~value ; + // this could also be done by the templated calls + if ( !s.empty() ) + s +=wxT("|") ; + s += edata->GetEnumMemberNameByIndex(i) ; + } + } +} + +#define wxBEGIN_FLAGS( e ) \ + wxEnumMemberData s_enumDataMembers##e[] = { + +#define wxFLAGS_MEMBER( v ) { wxT(#v), v } , + +#define wxEND_FLAGS( e ) { NULL , 0 } } ; \ + wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \ + wxEnumData *wxGetEnumData(e*) { return &s_enumData##e ; } \ + template<> void wxStringReadValue(const wxString &s , e &data ) \ +{ \ + wxFlagsFromString( s , data ) ; \ +} \ + template<> void wxStringWriteValue( wxString &s , const e& data ) \ +{ \ + wxFlagsToString( s , data ) ; \ +} \ + void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant(e(data)) ;} \ + void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , e).m_data ;} \ + wxTO_STRING_IMP( e ) \ + wxFROM_STRING_IMP( e ) \ + wxEnumTypeInfo s_typeInfo##e(wxT_SET , &s_enumData##e , &wxTO_STRING( e ) , &wxFROM_STRING( e ) , &ToLong##e , &FromLong##e, typeid(e).name() ) ; +// ---------------------------------------------------------------------------- +// Type Information +// ---------------------------------------------------------------------------- +// +// +// All data exposed by the RTTI is characterized using the following classes. +// The first characterization is done by wxTypeKind. All enums up to and including +// wxT_CUSTOM represent so called simple types. These cannot be divided any further. +// They can be converted to and from wxStrings, that's all. -#define wx_dynamic_cast(t, x) dynamic_cast(x) +enum wxTypeKind +{ + wxT_VOID = 0, // unknown type + wxT_BOOL, + wxT_CHAR, + wxT_UCHAR, + wxT_INT, + wxT_UINT, + wxT_LONG, + wxT_ULONG, + wxT_FLOAT, + wxT_DOUBLE, + wxT_STRING, // must be wxString + wxT_SET, // must be wxBitset<> template + wxT_ENUM, + wxT_CUSTOM, // user defined type (e.g. wxPoint) -#include "wx/xtitypes.h" -#include "wx/xtihandler.h" + wxT_LAST_SIMPLE_TYPE_KIND = wxT_CUSTOM , + wxT_OBJECT_PTR, // object reference + wxT_OBJECT , // embedded object + wxT_COLLECTION , // collection + + wxT_DELEGATE , // for connecting against an event source + + wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging +}; + +class WXDLLIMPEXP_BASE wxxVariant ; +class WXDLLIMPEXP_BASE wxTypeInfo ; + +WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxTypeInfo* , wxTypeInfoMap , class WXDLLIMPEXP_BASE ) ; + +class WXDLLIMPEXP_BASE wxTypeInfo +{ +public : + typedef void (*converterToString_t)( const wxxVariant& data , wxString &result ) ; + typedef void (*converterFromString_t)( const wxString& data , wxxVariant &result ) ; + + wxTypeInfo(wxTypeKind kind, + converterToString_t to = NULL, converterFromString_t from = NULL, + const wxString &name = wxEmptyString): + m_toString(to), m_fromString(from), m_kind(kind), m_name(name) + { + Register(); + } +#if wxUSE_UNICODE + wxTypeInfo(wxTypeKind kind, + converterToString_t to, converterFromString_t from, + const char *name): + m_toString(to), m_fromString(from), m_kind(kind), m_name(wxString::FromAscii(name)) + { + Register(); + } +#endif + + virtual ~wxTypeInfo() + { + Unregister() ; + } + + // return the kind of this type (wxT_... constants) + wxTypeKind GetKind() const { return m_kind ; } + + // returns the unique name of this type + const wxString& GetTypeName() const { return m_name ; } + + // is this type a delegate type + bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; } + + // is this type a custom type + bool IsCustomType() const { return m_kind == wxT_CUSTOM ; } + + // is this type an object type + bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; } + + // can the content of this type be converted to and from strings ? + bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL ; } + + // convert a wxxVariant holding data of this type into a string + void ConvertToString( const wxxVariant& data , wxString &result ) const + + { if ( m_toString ) (*m_toString)( data , result ) ; else wxLogError( _("String conversions not supported") ) ; } + + // convert a string into a wxxVariant holding the corresponding data in this type + void ConvertFromString( const wxString& data , wxxVariant &result ) const + { if( m_fromString ) (*m_fromString)( data , result ) ; else wxLogError( _("String conversions not supported") ) ; } + +#if wxUSE_UNICODE + static wxTypeInfo *FindType(const char *typeName) { return FindType( wxString::FromAscii(typeName) ) ; } +#endif + static wxTypeInfo *FindType(const wxChar *typeName); + +private : + + void Register(); + void Unregister(); + + converterToString_t m_toString ; + converterFromString_t m_fromString ; + + static wxTypeInfoMap* ms_typeTable ; + + wxTypeKind m_kind; + wxString m_name; +}; + +class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo +{ +public : + wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from = NULL , const wxString &name = wxEmptyString ) : + wxTypeInfo( kind , to , from , name ) + { wxASSERT_MSG( GetKind() < wxT_SET , wxT("Illegal Kind for Base Type") ) ; } +#if wxUSE_UNICODE + wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to , converterFromString_t from , const char *name ) : + wxTypeInfo( kind , to , from , name ) + { wxASSERT_MSG( GetKind() < wxT_SET , wxT("Illegal Kind for Base Type") ) ; } +#endif +} ; + +class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo +{ +public : + wxCustomTypeInfo( const wxString &name , converterToString_t to , converterFromString_t from ) : + wxTypeInfo( wxT_CUSTOM , to , from , name ) + {} +#if wxUSE_UNICODE + wxCustomTypeInfo( const char *name , converterToString_t to , converterFromString_t from ) : + wxTypeInfo( wxT_CUSTOM , to , from , name ) + {} +#endif +} ; + +class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo +{ +public : + typedef void (*converterToLong_t)( const wxxVariant& data , long &result ) ; + typedef void (*converterFromLong_t)( long data , wxxVariant &result ) ; + + wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to , converterFromString_t from , + converterToLong_t toLong , converterFromLong_t fromLong , const wxString &name ) : + wxTypeInfo( kind , to , from , name ) , m_toLong( toLong ) , m_fromLong( fromLong ) + { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_enumInfo = enumInfo ;} + +#if wxUSE_UNICODE + wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to , converterFromString_t from , + converterToLong_t toLong , converterFromLong_t fromLong , const char * name ) : + wxTypeInfo( kind , to , from , name ) , m_toLong( toLong ) , m_fromLong( fromLong ) + { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_enumInfo = enumInfo ;} +#endif + const wxEnumData* GetEnumData() const { return m_enumInfo ; } + + // convert a wxxVariant holding data of this type into a long + void ConvertToLong( const wxxVariant& data , long &result ) const + + { if( m_toLong ) (*m_toLong)( data , result ) ; else wxLogError( _("Long Conversions not supported") ) ; } + + // convert a long into a wxxVariant holding the corresponding data in this type + void ConvertFromLong( long data , wxxVariant &result ) const + { if( m_fromLong ) (*m_fromLong)( data , result ) ; else wxLogError( _("Long Conversions not supported") ) ;} + +private : + converterToLong_t m_toLong ; + converterFromLong_t m_fromLong ; + + wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET +} ; + +class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo +{ +public : + wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to = NULL , converterFromString_t from = NULL , const wxString &name = wxEmptyString) ; +#if wxUSE_UNICODE + wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name ) ; +#endif + const wxClassInfo *GetClassInfo() const { return m_classInfo ; } +private : + wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL +} ; + +class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo +{ +public : + wxCollectionTypeInfo( const wxString &elementName , converterToString_t to , converterFromString_t from , const wxString &name) : + wxTypeInfo( wxT_COLLECTION , to , from , name ) + { m_elementTypeName = elementName ; m_elementType = NULL ;} +#if wxUSE_UNICODE + wxCollectionTypeInfo( const char *elementName , converterToString_t to , converterFromString_t from , const char *name ) : + wxTypeInfo( wxT_COLLECTION , to , from , name ) + { m_elementTypeName = wxString::FromAscii( elementName ) ; m_elementType = NULL ;} +#endif + const wxTypeInfo* GetElementType() const + { + if ( m_elementType == NULL ) + m_elementType = wxTypeInfo::FindType( m_elementTypeName ) ; + return m_elementType ; } +private : + mutable wxTypeInfo * m_elementType ; + wxString m_elementTypeName ; +} ; + +// a delegate is an exposed event source + +class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo +{ +public : + wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) ; + wxDelegateTypeInfo( int eventType , int lastEventType, wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) ; + int GetEventType() const { return m_eventType ; } + int GetLastEventType() const { return m_lastEventType ; } + const wxClassInfo* GetEventClass() const { return m_eventClass ; } +private : + const wxClassInfo *m_eventClass; // (extended will merge into classinfo) + int m_eventType ; + int m_lastEventType ; +} ; + +template const wxTypeInfo* wxGetTypeInfo( T * ) { return wxTypeInfo::FindType(typeid(T).name()) ; } + +// this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type + +#if wxUSE_FUNC_TEMPLATE_POINTER +#define wxCUSTOM_TYPE_INFO( e , toString , fromString ) \ + wxCustomTypeInfo s_typeInfo##e(typeid(e).name() , &toString , &fromString) ; +#else +#define wxCUSTOM_TYPE_INFO( e , toString , fromString ) \ + void ToString##e( const wxxVariant& data , wxString &result ) { toString(data, result); } \ + void FromString##e( const wxString& data , wxxVariant &result ) { fromString(data, result); } \ + wxCustomTypeInfo s_typeInfo##e(typeid(e).name() , &ToString##e , &FromString##e) ; +#endif + +#define wxCOLLECTION_TYPE_INFO( element , collection ) \ + wxCollectionTypeInfo s_typeInfo##collection( typeid(element).name() , NULL , NULL , typeid(collection).name() ) ; + +// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs, currently +// we don't have to play tricks, but if we will have to according to the compiler, we will use that macro for that + +#define wxILLEGAL_TYPE_SPECIALIZATION( a ) + +// ---------------------------------------------------------------------------- +// wxxVariant as typesafe data holder +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxxVariantData +{ +public: + virtual ~wxxVariantData() {} + + // return a heap allocated duplicate + virtual wxxVariantData* Clone() const = 0 ; + + // returns the type info of the contentc + virtual const wxTypeInfo* GetTypeInfo() const = 0 ; +} ; + +template class wxxVariantDataT : public wxxVariantData +{ +public: + wxxVariantDataT(const T& d) : m_data(d) {} + virtual ~wxxVariantDataT() {} + + // get a ref to the stored data + T & Get() { return m_data; } + + // get a const ref to the stored data + const T & Get() const { return m_data; } + + // set the data + void Set(const T& d) { m_data = d; } + + // return a heap allocated duplicate + virtual wxxVariantData* Clone() const { return new wxxVariantDataT( Get() ) ; } + + // returns the type info of the contentc + virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ) ; } + +private: + T m_data; +}; + +class WXDLLIMPEXP_BASE wxxVariant +{ +public : + wxxVariant() { m_data = NULL ; } + wxxVariant( wxxVariantData* data , const wxString& name = wxEmptyString ) : m_data(data) , m_name(name) {} + wxxVariant( const wxxVariant &d ) { if ( d.m_data ) m_data = d.m_data->Clone() ; else m_data = NULL ; m_name = d.m_name ; } + + template wxxVariant( const T& data , const wxString& name = wxEmptyString ) : + m_data(new wxxVariantDataT(data) ), m_name(name) {} + + ~wxxVariant() { delete m_data ; } + + // get a ref to the stored data + template T& Get(wxTEMPLATED_MEMBER_FIX(T)) + { + wxxVariantDataT *dataptr = dynamic_cast*> (m_data) ; + wxASSERT_MSG( dataptr , wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ) ; + return dataptr->Get() ; + } + + // get a ref to the stored data + template const T& Get(wxTEMPLATED_MEMBER_FIX(T)) const + { + const wxxVariantDataT *dataptr = dynamic_cast*> (m_data) ; + wxASSERT_MSG( dataptr , wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ) ; + return dataptr->Get() ; + } + + bool IsEmpty() const { return m_data == NULL ; } + + template bool HasData(wxTEMPLATED_MEMBER_FIX(T)) const + { + const wxxVariantDataT *dataptr = dynamic_cast*> (m_data) ; + return dataptr != NULL ; + } + + // stores the data + template void Set(const T& data) const + { + delete m_data ; + m_data = new wxxVariantDataT(data) ; + } + + wxxVariant& operator=(const wxxVariant &d) + { + delete m_data; + m_data = d.m_data ? d.m_data->Clone() : NULL ; + m_name = d.m_name ; + return *this ; + } + + // gets the stored data casted to a wxObject* , returning NULL if cast is not possible + wxObject* GetAsObject() ; + + // get the typeinfo of the stored object + const wxTypeInfo* GetTypeInfo() const { return m_data->GetTypeInfo() ; } + + // returns this value as string + wxString GetAsString() const + { + wxString s ; + GetTypeInfo()->ConvertToString( *this , s ) ; + return s ; + } + const wxString& GetName() const { return m_name ; } +private : + wxxVariantData* m_data ; + wxString m_name ; +} ; + +#include "wx/dynarray.h" + +WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant, wxxVariantArray, class WXDLLIMPEXP_BASE); + +// templated streaming, every type must have their specialization for these methods + +template +void wxStringReadValue( const wxString &s , T &data ); + +template +void wxStringWriteValue( wxString &s , const T &data); + +template +void wxToStringConverter( const wxxVariant &v, wxString &s wxTEMPLATED_FUNCTION_FIX(T)) { wxStringWriteValue( s , v.wxTEMPLATED_MEMBER_CALL(Get , T) ) ; } + +template +void wxFromStringConverter( const wxString &s, wxxVariant &v wxTEMPLATED_FUNCTION_FIX(T)) { T d ; wxStringReadValue( s , d ) ; v = wxxVariant(d) ; } + +// ---------------------------------------------------------------------------- +// Property Support +// +// wxPropertyInfo is used to inquire of the property by name. It doesn't +// provide access to the property, only information about it. If you +// want access, look at wxPropertyAccessor. +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxSetter +{ +public: + wxSetter( const wxString name ) { m_name = name ; } + virtual ~wxSetter() {} + virtual void Set( wxObject *object, const wxxVariant &variantValue ) const = 0; + const wxString& GetName() const { return m_name ; } +private: + wxString m_name; +}; + +class WXDLLIMPEXP_BASE wxGetter +{ +public: + wxGetter( const wxString name ) { m_name = name ; } + virtual ~wxGetter() {} + virtual void Get( const wxObject *object , wxxVariant& result) const = 0; + const wxString& GetName() const { return m_name ; } +private: + wxString m_name; +}; + +class WXDLLIMPEXP_BASE wxCollectionGetter +{ +public : + wxCollectionGetter( const wxString name ) { m_name = name ; } + virtual ~wxCollectionGetter() {} + virtual void Get( const wxObject *object , wxxVariantArray& result) const = 0; + const wxString& GetName() const { return m_name ; } +private : + wxString m_name ; +} ; + +template void WXDLLIMPEXP_BASE wxCollectionToVariantArray( const coll_t& coll , wxxVariantArray& result ) ; + +class WXDLLIMPEXP_BASE wxAdder +{ +public : + wxAdder( const wxString name ) { m_name = name ; } + virtual ~wxAdder() {} + virtual void Add( wxObject *object, const wxxVariant &variantValue ) const= 0; + const wxString& GetName() const { return m_name ; } +private : + wxString m_name ; +} ; + + +#define wxSETTER( property, Klass, valueType, setterMethod ) \ +class wxSetter##property : public wxSetter \ +{ \ +public: \ + wxINFUNC_CLASS_TYPE_FIX(Klass) \ + wxSetter##property() : wxSetter( wxT(#setterMethod) ) {} \ + virtual ~wxSetter##property() {} \ + void Set( wxObject *object, const wxxVariant &variantValue ) const \ +{ \ + Klass *obj = dynamic_cast(object) ; \ + if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ + obj->setterMethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType)) ; \ + else \ + obj->setterMethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType*)) ; \ +} \ +} ; + +#define wxGETTER( property, Klass, valueType , gettermethod ) \ +class wxGetter##property : public wxGetter \ +{ \ +public : \ + wxINFUNC_CLASS_TYPE_FIX(Klass) \ + wxGetter##property() : wxGetter( wxT(#gettermethod) ) {} \ + virtual ~wxGetter##property() {} \ + void Get( const wxObject *object , wxxVariant &result) const \ +{ \ + const Klass *obj = dynamic_cast(object) ; \ + result = wxxVariant( obj->gettermethod() ) ; \ +} \ +} ; + +#define wxADDER( property, Klass, valueType , addermethod ) \ +class wxAdder##property : public wxAdder \ +{ \ +public: \ + wxINFUNC_CLASS_TYPE_FIX(Klass) \ + wxAdder##property() : wxAdder( wxT(#addermethod) ) {} \ + virtual ~wxAdder##property() {} \ + void Add( wxObject *object, const wxxVariant &variantValue ) const \ +{ \ + Klass *obj = dynamic_cast(object) ; \ + if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ + obj->addermethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType)) ; \ + else \ + obj->addermethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType*)) ; \ +} \ +} ; + +#define wxCOLLECTION_GETTER( property, Klass, valueType , gettermethod ) \ +class wxCollectionGetter##property : public wxCollectionGetter \ +{ \ +public : \ + wxINFUNC_CLASS_TYPE_FIX(Klass) \ + wxCollectionGetter##property() : wxCollectionGetter( wxT(#gettermethod) ) {} \ + virtual ~wxCollectionGetter##property() {} \ + void Get( const wxObject *object , wxxVariantArray &result) const \ +{ \ + const Klass *obj = dynamic_cast(object) ; \ + wxCollectionToVariantArray( obj->gettermethod() , result ) ; \ +} \ +} ; + +class WXDLLIMPEXP_BASE wxPropertyAccessor +{ +public : + wxPropertyAccessor( wxSetter *setter , wxGetter *getter , wxAdder *adder , wxCollectionGetter *collectionGetter ) + { m_setter = setter ; m_getter = getter ; m_adder = adder ; m_collectionGetter = collectionGetter ;} + + virtual ~wxPropertyAccessor() {} + + // Setting a simple property (non-collection) + virtual void SetProperty(wxObject *object, const wxxVariant &value) const + { if ( m_setter ) m_setter->Set( object , value ) ; else wxLogError( _("SetProperty called w/o valid setter") ) ;} + + // Getting a simple property (non-collection) + virtual void GetProperty(const wxObject *object, wxxVariant &result) const + { if ( m_getter ) m_getter->Get( object , result ) ; else wxLogError( _("GetProperty called w/o valid getter") ) ;} + + // Adding an element to a collection property + virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const + { if ( m_adder ) m_adder->Add( object , value ) ; else wxLogError( _("AddToPropertyCollection called w/o valid adder") ) ;} + + // Getting a collection property + virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const + { if ( m_collectionGetter ) m_collectionGetter->Get( obj , result) ; else wxLogError( _("GetPropertyCollection called w/o valid collection getter") ) ;} + + virtual bool HasSetter() const { return m_setter != NULL ; } + virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL ; } + virtual bool HasGetter() const { return m_getter != NULL ; } + virtual bool HasAdder() const { return m_adder != NULL ; } + + virtual const wxString& GetCollectionGetterName() const + { return m_collectionGetter->GetName() ; } + virtual const wxString& GetGetterName() const + { return m_getter->GetName() ; } + virtual const wxString& GetSetterName() const + { return m_setter->GetName() ; } + virtual const wxString& GetAdderName() const + { return m_adder->GetName() ; } + +protected : + wxSetter *m_setter ; + wxAdder *m_adder ; + wxGetter *m_getter ; + wxCollectionGetter* m_collectionGetter ; +}; + +class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor +{ +public : + wxGenericPropertyAccessor( const wxString &propName ) ; + virtual ~wxGenericPropertyAccessor() ; + + void RenameProperty( const wxString& WXUNUSED_UNLESS_DEBUG(oldName), + const wxString& newName ) + { + wxASSERT( oldName == m_propertyName ) ; m_propertyName = newName ; + } + virtual bool HasSetter() const { return true ; } + virtual bool HasGetter() const { return true ; } + virtual bool HasAdder() const { return false ; } + virtual bool HasCollectionGetter() const { return false ; } + + virtual const wxString& GetGetterName() const + { return m_getterName ; } + virtual const wxString& GetSetterName() const + { return m_setterName ; } + + virtual void SetProperty(wxObject *object, const wxxVariant &value) const ; + virtual void GetProperty(const wxObject *object, wxxVariant &value) const ; + + // Adding an element to a collection property + virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), const wxxVariant &WXUNUSED(value)) const + { wxLogError( _("AddToPropertyCollection called on a generic accessor") ) ;} + + // Getting a collection property + virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), wxxVariantArray &WXUNUSED(result)) const + { wxLogError ( _("GetPropertyCollection called on a generic accessor") ) ;} +private : + struct wxGenericPropertyAccessorInternal ; + wxGenericPropertyAccessorInternal* m_data ; + wxString m_propertyName ; + wxString m_setterName ; + wxString m_getterName ; +} ; + +typedef long wxPropertyInfoFlags ; +enum { + // will be removed in future releases + wxPROP_DEPRECATED = 0x00000001 , + // object graph property, will be streamed with priority (after constructor properties) + wxPROP_OBJECT_GRAPH = 0x00000002 , + // this will only be streamed out and in as enum/set, the internal representation is still a long + wxPROP_ENUM_STORE_LONG = 0x00000004 , + // don't stream out this property, needed eg to avoid streaming out children that are always created by their parents + wxPROP_DONT_STREAM = 0x00000008 , +} ; + +class WXDLLIMPEXP_BASE wxPropertyInfo +{ + friend class WXDLLIMPEXP_BASE wxDynamicClassInfo ; +public : + wxPropertyInfo(wxPropertyInfo* &iter, + wxClassInfo* itsClass, + const wxString& name, + const wxString& typeName, + wxPropertyAccessor *accessor, + wxxVariant dv, + wxPropertyInfoFlags flags = 0, + const wxString& helpString = wxEmptyString, + const wxString& groupString = wxEmptyString) : + m_itsClass(itsClass), + m_name(name), + m_typeInfo(NULL), + m_typeName(typeName) , + m_collectionElementTypeInfo(NULL), + m_accessor(accessor), + m_defaultValue(dv), + m_flags(flags), + m_helpString(helpString), + m_groupString(groupString) + { + Insert(iter); + } + +#if wxUSE_UNICODE + wxPropertyInfo(wxPropertyInfo* &iter, + wxClassInfo* itsClass, + const wxString& name, + const char* typeName, + wxPropertyAccessor *accessor, + wxxVariant dv, + wxPropertyInfoFlags flags = 0, + const wxString& helpString = wxEmptyString, + const wxString& groupString = wxEmptyString) : + m_itsClass(itsClass), + m_name(name), + m_typeInfo(NULL), + m_typeName(wxString::FromAscii(typeName)) , + m_collectionElementTypeInfo(NULL), + m_accessor(accessor), + m_defaultValue(dv), + m_flags(flags), + m_helpString(helpString), + m_groupString(groupString) + { + Insert(iter); + } +#endif + wxPropertyInfo(wxPropertyInfo* &iter, + wxClassInfo* itsClass, + const wxString& name, + wxDelegateTypeInfo* type, + wxPropertyAccessor *accessor, + wxxVariant dv, + wxPropertyInfoFlags flags = 0, + const wxString& helpString = wxEmptyString, + const wxString& groupString = wxEmptyString) : + m_itsClass(itsClass), + m_name(name), + m_typeInfo(type), + m_collectionElementTypeInfo(NULL), + m_accessor(accessor), + m_defaultValue(dv), + m_flags(flags), + m_helpString(helpString), + m_groupString(groupString) + { + Insert(iter); + } + + wxPropertyInfo(wxPropertyInfo* &iter, + wxClassInfo* itsClass, const wxString& name, + const wxString& collectionTypeName, + const wxString& elementTypeName, + wxPropertyAccessor *accessor, + wxPropertyInfoFlags flags = 0, + const wxString& helpString = wxEmptyString, + const wxString& groupString = wxEmptyString) : + m_itsClass(itsClass), + m_name(name), + m_typeInfo(NULL), + m_typeName(collectionTypeName) , + m_collectionElementTypeInfo(NULL), + m_collectionElementTypeName(elementTypeName), + m_accessor(accessor) , + m_flags(flags), + m_helpString(helpString), + m_groupString(groupString) + { + Insert(iter); + } + +#if wxUSE_UNICODE + wxPropertyInfo(wxPropertyInfo* &iter, + wxClassInfo* itsClass, const wxString& name, + const char* collectionTypeName, + const char* elementTypeName, + wxPropertyAccessor *accessor, + wxPropertyInfoFlags flags = 0, + const wxString& helpString = wxEmptyString, + const wxString& groupString = wxEmptyString) : + m_itsClass(itsClass), + m_name(name), + m_typeInfo(NULL), + m_typeName(wxString::FromAscii(collectionTypeName)) , + m_collectionElementTypeInfo(NULL), + m_collectionElementTypeName(wxString::FromAscii(elementTypeName)), + m_accessor(accessor) , + m_flags(flags), + m_helpString(helpString), + m_groupString(groupString) + { + Insert(iter); + } +#endif + ~wxPropertyInfo() ; + + // return the class this property is declared in + const wxClassInfo* GetDeclaringClass() const { return m_itsClass ; } + + // return the name of this property + const wxString& GetName() const { return m_name ; } + + // returns the flags of this property + wxPropertyInfoFlags GetFlags() const { return m_flags ;} + + // returns the short help string of this property + const wxString& GetHelpString() const { return m_helpString ; } + + // returns the group string of this property + const wxString& GetGroupString() const { return m_groupString ; } + + // return the element type info of this property (for collections, otherwise NULL) + const wxTypeInfo * GetCollectionElementTypeInfo() const + { + if ( m_collectionElementTypeInfo == NULL ) + m_collectionElementTypeInfo = wxTypeInfo::FindType(m_collectionElementTypeName) ; + return m_collectionElementTypeInfo ; + } + + // return the type info of this property + const wxTypeInfo * GetTypeInfo() const + { + if ( m_typeInfo == NULL ) + m_typeInfo = wxTypeInfo::FindType(m_typeName) ; + return m_typeInfo ; + } + + // return the accessor for this property + wxPropertyAccessor* GetAccessor() const { return m_accessor ; } + + // returns NULL if this is the last property of this class + wxPropertyInfo* GetNext() const { return m_next ; } + + // returns the default value of this property, its kind may be wxT_VOID if it is not valid + wxxVariant GetDefaultValue() const { return m_defaultValue ; } +private : + void Insert(wxPropertyInfo* &iter) + { + m_next = NULL ; + if ( iter == NULL ) + iter = this ; + else + { + wxPropertyInfo* i = iter ; + while( i->m_next ) + i = i->m_next ; + + i->m_next = this ; + } + } + + wxClassInfo* m_itsClass ; + wxString m_name ; + mutable wxTypeInfo* m_typeInfo ; + wxString m_typeName ; + mutable wxTypeInfo* m_collectionElementTypeInfo ; + wxString m_collectionElementTypeName ; + wxPropertyAccessor* m_accessor ; + wxxVariant m_defaultValue; + wxPropertyInfoFlags m_flags ; + wxString m_helpString ; + wxString m_groupString ; + // string representation of the default value + // to be assigned by the designer to the property + // when the component is dropped on the container. + wxPropertyInfo* m_next ; +}; + +WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo* , wxPropertyInfoMap , class WXDLLIMPEXP_BASE ) ; + +#define wxBEGIN_PROPERTIES_TABLE(theClass) \ + wxPropertyInfo *theClass::GetPropertiesStatic() \ +{ \ + typedef theClass class_t; \ + static wxPropertyInfo* first = NULL ; + +#define wxEND_PROPERTIES_TABLE() \ + return first ; } + +#define wxHIDE_PROPERTY( pname ) \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(void).name() ,NULL , wxxVariant() , wxPROP_DONT_STREAM , wxEmptyString , wxEmptyString ) ; + +#define wxPROPERTY( pname , type , setter , getter , defaultValue , flags , help , group) \ + wxSETTER( pname , class_t , type , setter ) \ + static wxSetter##pname _setter##pname ; \ + wxGETTER( pname , class_t , type , getter ) \ + static wxGetter##pname _getter##pname ; \ + static wxPropertyAccessor _accessor##pname( &_setter##pname , &_getter##pname , NULL , NULL ) ; \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(type).name() ,&_accessor##pname , wxxVariant(defaultValue) , flags , group , help ) ; + +#define wxPROPERTY_FLAGS( pname , flags , type , setter , getter ,defaultValue , pflags , help , group) \ + wxSETTER( pname , class_t , type , setter ) \ + static wxSetter##pname _setter##pname ; \ + wxGETTER( pname , class_t , type , getter ) \ + static wxGetter##pname _getter##pname ; \ + static wxPropertyAccessor _accessor##pname( &_setter##pname , &_getter##pname , NULL , NULL ) ; \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(flags).name() ,&_accessor##pname , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ; + +#define wxREADONLY_PROPERTY( pname , type , getter ,defaultValue , flags , help , group) \ + wxGETTER( pname , class_t , type , getter ) \ + static wxGetter##pname _getter##pname ; \ + static wxPropertyAccessor _accessor##pname( NULL , &_getter##pname , NULL , NULL ) ; \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(type).name() ,&_accessor##pname , wxxVariant(defaultValue), flags , help , group ) ; + +#define wxREADONLY_PROPERTY_FLAGS( pname , flags , type , getter ,defaultValue , pflags , help , group) \ + wxGETTER( pname , class_t , type , getter ) \ + static wxGetter##pname _getter##pname ; \ + static wxPropertyAccessor _accessor##pname( NULL , &_getter##pname , NULL , NULL ) ; \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(flags).name() ,&_accessor##pname , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ; + +#define wxPROPERTY_COLLECTION( pname , colltype , addelemtype , adder , getter , flags , help , group ) \ + wxADDER( pname , class_t , addelemtype , adder ) \ + static wxAdder##pname _adder##pname ; \ + wxCOLLECTION_GETTER( pname , class_t , colltype , getter ) \ + static wxCollectionGetter##pname _collectionGetter##pname ; \ + static wxPropertyAccessor _accessor##pname( NULL , NULL ,&_adder##pname , &_collectionGetter##pname ) ; \ + static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(colltype).name() ,typeid(addelemtype).name() ,&_accessor##pname , flags , help , group ) ; + +#define wxREADONLY_PROPERTY_COLLECTION( pname , colltype , addelemtype , getter , flags , help , group) \ + wxCOLLECTION_GETTER( pname , class_t , colltype , getter ) \ + static wxCollectionGetter##pname _collectionGetter##pname ; \ + static wxPropertyAccessor _accessor##pname( NULL , NULL , NULL , &_collectionGetter##pname ) ; \ + static wxPropertyInfo _propertyInfo##pname( first ,class_t::GetClassInfoStatic() , wxT(#pname) , typeid(colltype).name() ,typeid(addelemtype).name() ,&_accessor##pname , flags , help , group ) ; + + +#define wxEVENT_PROPERTY( name , eventType , eventClass ) \ + static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \ + static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , wxT(#name) , &_typeInfo##name , NULL , wxxVariant() ) ; \ + +#define wxEVENT_RANGE_PROPERTY( name , eventType , lastEventType , eventClass ) \ + static wxDelegateTypeInfo _typeInfo##name( eventType , lastEventType , CLASSINFO( eventClass ) ) ; \ + static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , wxT(#name) , &_typeInfo##name , NULL , wxxVariant() ) ; \ + +// ---------------------------------------------------------------------------- +// Implementation Helper for Simple Properties +// ---------------------------------------------------------------------------- + +#define wxIMPLEMENT_PROPERTY(name, type) \ +private:\ + type m_##name; \ +public: \ + void Set##name( type const & p) { m_##name = p; } \ + type const & Get##name() const { return m_##name; } + +// ---------------------------------------------------------------------------- +// Handler Info +// +// this is describing an event sink +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxHandlerInfo +{ + friend class WXDLLIMPEXP_BASE wxDynamicClassInfo ; +public : + wxHandlerInfo(wxHandlerInfo* &iter, + wxClassInfo* itsClass, + const wxString& name, + wxObjectEventFunction address, + const wxClassInfo* eventClassInfo) : + m_eventFunction(address), + m_name(name), + m_eventClassInfo(eventClassInfo) , + m_itsClass(itsClass) + { + m_next = NULL ; + if ( iter == NULL ) + iter = this ; + else + { + wxHandlerInfo* i = iter ; + while( i->m_next ) + i = i->m_next ; + + i->m_next = this ; + } + } + + ~wxHandlerInfo() ; + + // return the name of this handler + const wxString& GetName() const { return m_name ; } + + // return the class info of the event + const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo ; } + + // get the handler function pointer + wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; } + + // returns NULL if this is the last handler of this class + wxHandlerInfo* GetNext() const { return m_next ; } + + // return the class this property is declared in + const wxClassInfo* GetDeclaringClass() const { return m_itsClass ; } + +private : + wxObjectEventFunction m_eventFunction ; + wxString m_name; + const wxClassInfo* m_eventClassInfo ; + wxHandlerInfo* m_next ; + wxClassInfo* m_itsClass ; +}; + +#define wxHANDLER(name,eventClassType) \ + static wxHandlerInfo _handlerInfo##name( first , class_t::GetClassInfoStatic() , wxT(#name) , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ; + +#define wxBEGIN_HANDLERS_TABLE(theClass) \ + wxHandlerInfo *theClass::GetHandlersStatic() \ +{ \ + typedef theClass class_t; \ + static wxHandlerInfo* first = NULL ; + +#define wxEND_HANDLERS_TABLE() \ + return first ; } + +// ---------------------------------------------------------------------------- +// Constructor Bridges +// +// allow to set up constructors with params during runtime +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxConstructorBridge +{ +public : + virtual void Create(wxObject * &o, wxxVariant *args) = 0; +}; + +// a direct constructor bridge calls the operator new for this class and +// passes all params to the constructor. needed for classes that cannot be +// instantiated using alloc-create semantics +class WXDLLIMPEXP_BASE wxDirectConstructorBrigde : public wxConstructorBridge +{ +public : + virtual void Create(wxObject * &o, wxxVariant *args) = 0; +} ; + +// Creator Bridges for all Numbers of Params + +// no params + +template +struct wxConstructorBridge_0 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *) + { + Class *obj = dynamic_cast(o); + obj->Create(); + } +}; + +struct wxConstructorBridge_Dummy : public wxConstructorBridge +{ + void Create(wxObject *&, wxxVariant *) + { + } +} ; + +#define wxCONSTRUCTOR_0(klass) \ + wxConstructorBridge_0 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { NULL } ; \ + const int klass::ms_constructorPropertiesCount = 0 ; + +#define wxCONSTRUCTOR_DUMMY(klass) \ + wxConstructorBridge_Dummy constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { NULL } ; \ + const int klass::ms_constructorPropertiesCount = 0 ; + +// 1 param + +template +struct wxConstructorBridge_1 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) + ); + } +}; + +#define wxCONSTRUCTOR_1(klass,t0,v0) \ + wxConstructorBridge_1 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) } ; \ + const int klass::ms_constructorPropertiesCount = 1 ; + +// 2 params + +template +struct wxConstructorBridge_2 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) + ); + } +}; + +#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \ + wxConstructorBridge_2 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) } ; \ + const int klass::ms_constructorPropertiesCount = 2; + +// direct constructor version + +template +struct wxDirectConstructorBridge_2 : public wxDirectConstructorBrigde +{ + void Create(wxObject * &o, wxxVariant *args) + { + o = new Class( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) + ); + } +}; + +#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \ + wxDirectConstructorBridge_2 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) } ; \ + const int klass::ms_constructorPropertiesCount = 2; + + +// 3 params + +template +struct wxConstructorBridge_3 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) + ); + } +}; + +#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ + wxConstructorBridge_3 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) } ; \ + const int klass::ms_constructorPropertiesCount = 3 ; + +// direct constructor version + +template +struct wxDirectConstructorBridge_3 : public wxDirectConstructorBrigde +{ + void Create(wxObject * &o, wxxVariant *args) + { + o = new Class( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) + ); + } +}; + +#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ + wxDirectConstructorBridge_3 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) } ; \ + const int klass::ms_constructorPropertiesCount = 3; + +// 4 params + +template +struct wxConstructorBridge_4 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) + ); + } +}; + +#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ + wxConstructorBridge_4 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) } ; \ + const int klass::ms_constructorPropertiesCount = 4 ; + +// 5 params + +template +struct wxConstructorBridge_5 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) , + args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) + ); + } +}; + +#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ + wxConstructorBridge_5 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) } ; \ + const int klass::ms_constructorPropertiesCount = 5; + +// 6 params + +template +struct wxConstructorBridge_6 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) , + args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) , + args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) + ); + } +}; + +#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ + wxConstructorBridge_6 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) } ; \ + const int klass::ms_constructorPropertiesCount = 6; + +// direct constructor version + +template +struct wxDirectConstructorBridge_6 : public wxDirectConstructorBrigde +{ + void Create(wxObject * &o, wxxVariant *args) + { + o = new Class( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) , + args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) , + args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) + ); + } +}; + +#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ + wxDirectConstructorBridge_6 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) } ; \ + const int klass::ms_constructorPropertiesCount = 6; + +// 7 params + +template +struct wxConstructorBridge_7 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) , + args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) , + args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) , + args[6].wxTEMPLATED_MEMBER_CALL(Get , T6) + ); + } +}; + +#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ + wxConstructorBridge_7 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) , wxT(#v6) } ; \ + const int klass::ms_constructorPropertiesCount = 7; + +// 8 params + +template +struct wxConstructorBridge_8 : public wxConstructorBridge +{ + void Create(wxObject * &o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) , + args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) , + args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) , + args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) , + args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) , + args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) , + args[6].wxTEMPLATED_MEMBER_CALL(Get , T6) , + args[7].wxTEMPLATED_MEMBER_CALL(Get , T7) + ); + } +}; + +#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ + wxConstructorBridge_8 constructor##klass ; \ + wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \ + const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) , wxT(#v6) , wxT(#v7) } ; \ + const int klass::ms_constructorPropertiesCount = 8; // ---------------------------------------------------------------------------- // wxClassInfo // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxObjectFunctor -{ -public: - virtual ~wxObjectFunctor(); - - // Invoke the actual event handler: - virtual void operator()(const wxObject *) = 0; -}; - -class WXDLLIMPEXP_FWD_BASE wxPropertyInfo; -class WXDLLIMPEXP_FWD_BASE wxHandlerInfo; - typedef wxObject *(*wxObjectConstructorFn)(void); -typedef wxPropertyInfo *(*wxPropertyInfoFn)(void); -typedef wxHandlerInfo *(*wxHandlerInfoFn)(void); -typedef void (*wxVariantToObjectConverter)( const wxAny &data, wxObjectFunctor* fn ); -typedef wxObject* (*wxVariantToObjectPtrConverter) ( const wxAny& data); -typedef wxAny (*wxObjectToVariantConverter)( wxObject* ); - -WXDLLIMPEXP_BASE wxString wxAnyGetAsString( const wxAny& data); -WXDLLIMPEXP_BASE const wxObject* wxAnyGetAsObjectPtr( const wxAny& data); - -class WXDLLIMPEXP_BASE wxObjectWriter; -class WXDLLIMPEXP_BASE wxObjectWriterCallback; - -typedef bool (*wxObjectStreamingCallback) ( const wxObject *, wxObjectWriter *, \ - wxObjectWriterCallback *, const wxStringToAnyHashMap & ); +typedef wxObject* (*wxVariantToObjectConverter)( wxxVariant &data ) ; +typedef wxxVariant (*wxObjectToVariantConverter)( wxObject* ) ; +class WXDLLIMPEXP_BASE wxWriter; +class WXDLLIMPEXP_BASE wxPersister; +typedef bool (*wxObjectStreamingCallback) ( const wxObject *, wxWriter * , wxPersister * , wxxVariantArray & ) ; class WXDLLIMPEXP_BASE wxClassInfo { - friend class WXDLLIMPEXP_BASE wxPropertyInfo; - friend class /* WXDLLIMPEXP_BASE */ wxHandlerInfo; - friend wxObject *wxCreateDynamicObject(const wxString& name); - + friend class WXDLLIMPEXP_BASE wxPropertyInfo ; + friend class WXDLLIMPEXP_BASE wxHandlerInfo ; public: wxClassInfo(const wxClassInfo **_Parents, - const wxChar *_UnitName, - const wxChar *_ClassName, - int size, - wxObjectConstructorFn ctor, - wxPropertyInfoFn _Props, - wxHandlerInfoFn _Handlers, - wxObjectAllocatorAndCreator* _Constructor, - const wxChar ** _ConstructorProperties, - const int _ConstructorPropertiesCount, - wxVariantToObjectPtrConverter _PtrConverter1, - wxVariantToObjectConverter _Converter2, - wxObjectToVariantConverter _Converter3, - wxObjectStreamingCallback _streamingCallback = NULL) : + const wxChar *_UnitName, + const wxChar *_ClassName, + int size, + wxObjectConstructorFn ctor , + wxPropertyInfo *_Props , + wxHandlerInfo *_Handlers , + wxConstructorBridge* _Constructor , + const wxChar ** _ConstructorProperties , + const int _ConstructorPropertiesCount , + wxVariantToObjectConverter _PtrConverter1 , + wxVariantToObjectConverter _Converter2 , + wxObjectToVariantConverter _Converter3 , + wxObjectStreamingCallback _streamingCallback = NULL + ) : + m_className(_ClassName), m_objectSize(size), m_objectConstructor(ctor), m_next(sm_first), - m_firstPropertyFn(_Props), - m_firstHandlerFn(_Handlers), - m_firstProperty(NULL), - m_firstHandler(NULL), - m_firstInited(false), + m_firstProperty(_Props), + m_firstHandler(_Handlers), m_parents(_Parents), m_unitName(_UnitName), m_constructor(_Constructor), @@ -133,7 +1626,7 @@ public: m_streamingCallback(_streamingCallback) { sm_first = this; - Register(); + Register() ; } wxClassInfo(const wxChar *_UnitName, const wxChar *_ClassName, @@ -142,11 +1635,8 @@ public: m_objectSize(0), m_objectConstructor(NULL), m_next(sm_first), - m_firstPropertyFn(NULL), - m_firstHandlerFn(NULL), m_firstProperty(NULL), m_firstHandler(NULL), - m_firstInited(true), m_parents(_Parents), m_unitName(_UnitName), m_constructor(NULL), @@ -158,211 +1648,177 @@ public: m_streamingCallback(NULL) { sm_first = this; - Register(); + Register() ; } - // ctor compatible with old RTTI system - wxClassInfo(const wxChar *_ClassName, - const wxClassInfo *_Parent1, - const wxClassInfo *_Parent2, - int size, - wxObjectConstructorFn ctor) : - m_className(_ClassName), - m_objectSize(size), - m_objectConstructor(ctor), - m_next(sm_first), - m_firstPropertyFn(NULL), - m_firstHandlerFn(NULL), - m_firstProperty(NULL), - m_firstHandler(NULL), - m_firstInited(true), - m_parents(NULL), - m_unitName(NULL), - m_constructor(NULL), - m_constructorProperties(NULL), - m_constructorPropertiesCount(0), - m_variantOfPtrToObjectConverter(NULL), - m_variantToObjectConverter(NULL), - m_objectToVariantConverter(NULL), - m_streamingCallback(NULL) - { - sm_first = this; - m_parents[0] = _Parent1; - m_parents[1] = _Parent2; - m_parents[2] = NULL; - Register(); - } + virtual ~wxClassInfo() ; - virtual ~wxClassInfo(); - - // allocates an instance of this class, this object does not have to be - // initialized or fully constructed as this call will be followed by a call to Create - virtual wxObject *AllocateObject() const - { return m_objectConstructor ? (*m_objectConstructor)() : 0; } + // allocates an instance of this class, this object does not have to be initialized or fully constructed + // as this call will be followed by a call to Create + virtual wxObject *AllocateObject() const { return m_objectConstructor ? (*m_objectConstructor)() : 0; } // 'old naming' for AllocateObject staying here for backward compatibility - wxObject *CreateObject() const { return AllocateObject(); } + wxObject *CreateObject() const { return AllocateObject() ; } // direct construction call for classes that cannot construct instances via alloc/create - wxObject *ConstructObject(int ParamCount, wxAny *Params) const; + wxObject *ConstructObject(int ParamCount, wxxVariant *Params) const + { + if ( ParamCount != m_constructorPropertiesCount ) + { + wxLogError( _("Illegal Parameter Count for ConstructObject Method") ) ; + return NULL ; + } + wxObject *object = NULL ; + m_constructor->Create( object , Params ) ; + return object ; + } - bool NeedsDirectConstruction() const; - - const wxChar *GetClassName() const - { return m_className; } + bool NeedsDirectConstruction() const { return dynamic_cast( m_constructor) != NULL ; } + + const wxChar *GetClassName() const { return m_className; } const wxChar *GetBaseClassName1() const { return m_parents[0] ? m_parents[0]->GetClassName() : NULL; } const wxChar *GetBaseClassName2() const { return (m_parents[0] && m_parents[1]) ? m_parents[1]->GetClassName() : NULL; } + const wxChar *GetIncludeName() const { return m_unitName ; } + const wxClassInfo **GetParents() const { return m_parents; } + int GetSize() const { return m_objectSize; } + bool IsDynamic() const { return (NULL != m_objectConstructor); } - const wxClassInfo *GetBaseClass1() const - { return m_parents[0]; } - const wxClassInfo *GetBaseClass2() const - { return m_parents[0] ? m_parents[1] : NULL; } - - const wxChar *GetIncludeName() const - { return m_unitName; } - const wxClassInfo **GetParents() const - { return m_parents; } - int GetSize() const - { return m_objectSize; } - bool IsDynamic() const - { return (NULL != m_objectConstructor); } - - wxObjectConstructorFn GetConstructor() const - { return m_objectConstructor; } - const wxClassInfo *GetNext() const - { return m_next; } - - // statics: - - static void CleanUp(); - static wxClassInfo *FindClass(const wxString& className); - static const wxClassInfo *GetFirst() - { return sm_first; } - + wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; } + static const wxClassInfo *GetFirst() { return sm_first; } + const wxClassInfo *GetNext() const { return m_next; } + static wxClassInfo *FindClass(const wxChar *className); // Climb upwards through inheritance hierarchy. // Dual inheritance is catered for. - bool IsKindOf(const wxClassInfo *info) const; + bool IsKindOf(const wxClassInfo *info) const + { + if ( info != 0 ) + { + if ( info == this ) + return true ; - wxDECLARE_CLASS_INFO_ITERATORS(); + for ( int i = 0 ; m_parents[i] ; ++ i ) + { + if ( m_parents[i]->IsKindOf( info ) ) + return true ; + } + } + return false ; + } // if there is a callback registered with that class it will be called // before this object will be written to disk, it can veto streaming out // this object by returning false, if this class has not registered a // callback, the search will go up the inheritance tree if no callback has // been registered true will be returned by default - bool BeforeWriteObject( const wxObject *obj, wxObjectWriter *streamer, - wxObjectWriterCallback *writercallback, const wxStringToAnyHashMap &metadata) const; + bool BeforeWriteObject( const wxObject *obj, wxWriter *streamer , wxPersister *persister , wxxVariantArray &metadata) const ; // gets the streaming callback from this class or any superclass - wxObjectStreamingCallback GetStreamingCallback() const; + wxObjectStreamingCallback GetStreamingCallback() const ; + +#if WXWIN_COMPATIBILITY_2_4 + // Initializes parent pointers and hash table for fast searching. + wxDEPRECATED( static void InitializeClasses() ); + // Cleans up hash table used for fast searching. + wxDEPRECATED( static void CleanUpClasses() ); +#endif + static void CleanUp(); // returns the first property - wxPropertyInfo* GetFirstProperty() const - { EnsureInfosInited(); return m_firstProperty; } + const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; } // returns the first handler - wxHandlerInfo* GetFirstHandler() const - { EnsureInfosInited(); return m_firstHandler; } + const wxHandlerInfo* GetFirstHandler() const { return m_firstHandler ; } // Call the Create upon an instance of the class, in the end the object is fully // initialized - virtual bool Create (wxObject *object, int ParamCount, wxAny *Params) const; + virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const + { + if ( ParamCount != m_constructorPropertiesCount ) + { + wxLogError( _("Illegal Parameter Count for Create Method") ) ; + return ; + } + m_constructor->Create( object , Params ) ; + } // get number of parameters for constructor - virtual int GetCreateParamCount() const - { return m_constructorPropertiesCount; } + virtual int GetCreateParamCount() const { return m_constructorPropertiesCount; } // get n-th constructor parameter - virtual const wxChar* GetCreateParamName(int n) const - { return m_constructorProperties[n]; } + virtual const wxChar* GetCreateParamName(int n) const { return m_constructorProperties[n] ; } - // Runtime access to objects for simple properties (get/set) by property - // name and variant data - virtual void SetProperty (wxObject *object, const wxChar *propertyName, - const wxAny &value) const; - virtual wxAny GetProperty (wxObject *object, const wxChar *propertyName) const; + // Runtime access to objects for simple properties (get/set) by property name, and variant data + virtual void SetProperty (wxObject *object, const wxChar *propertyName, const wxxVariant &value) const ; + virtual wxxVariant GetProperty (wxObject *object, const wxChar *propertyName) const; // Runtime access to objects for collection properties by property name - virtual wxAnyList GetPropertyCollection(wxObject *object, - const wxChar *propertyName) const; - virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName, - const wxAny& value) const; + virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ; + virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ; - // we must be able to cast variants to wxObject pointers, templates seem - // not to be suitable - void CallOnAny( const wxAny &data, wxObjectFunctor* functor ) const; + // we must be able to cast variants to wxObject pointers, templates seem not to be suitable + wxObject* VariantToInstance( wxxVariant &data ) const + { + if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT ) + return m_variantToObjectConverter( data ) ; + else + return m_variantOfPtrToObjectConverter( data ) ; + } - wxObject* AnyToObjectPtr( const wxAny &data) const; - - wxAny ObjectPtrToAny( wxObject *object ) const; + wxxVariant InstanceToVariant( wxObject *object ) const { return m_objectToVariantConverter( object ) ; } // find property by name - virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const; + virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const ; // find handler by name - virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *handlerName) const; + virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *PropertyName) const ; // find property by name - virtual wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const; + virtual wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const ; // find handler by name - virtual wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *handlerName) const; + virtual wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ; - // puts all the properties of this class and its superclasses in the map, - // as long as there is not yet an entry with the same name (overriding mechanism) - void GetProperties( wxPropertyInfoMap &map ) const; - -private: + // puts all the properties of this class and its superclasses in the map, as long as there is not yet + // an entry with the same name (overriding mechanism) + void GetProperties( wxPropertyInfoMap &map ) const ; +public: const wxChar *m_className; int m_objectSize; - wxObjectConstructorFn m_objectConstructor; + wxObjectConstructorFn m_objectConstructor; // class info object live in a linked list: // pointers to its head and the next element in it static wxClassInfo *sm_first; - wxClassInfo *m_next; + wxClassInfo *m_next; + // FIXME: this should be private (currently used directly by way too + // many clients) static wxHashTable *sm_classTable; - wxPropertyInfoFn m_firstPropertyFn; - wxHandlerInfoFn m_firstHandlerFn; - - -protected: - void EnsureInfosInited() const - { - if ( !m_firstInited) - { - if ( m_firstPropertyFn != NULL) - m_firstProperty = (*m_firstPropertyFn)(); - if ( m_firstHandlerFn != NULL) - m_firstHandler = (*m_firstHandlerFn)(); - m_firstInited = true; - } - } - mutable wxPropertyInfo* m_firstProperty; - mutable wxHandlerInfo* m_firstHandler; - +protected : + wxPropertyInfo * m_firstProperty ; + wxHandlerInfo * m_firstHandler ; private: - mutable bool m_firstInited; + const wxClassInfo** m_parents ; + const wxChar* m_unitName; - const wxClassInfo** m_parents; - const wxChar* m_unitName; + wxConstructorBridge* m_constructor ; + const wxChar ** m_constructorProperties ; + const int m_constructorPropertiesCount ; + wxVariantToObjectConverter m_variantOfPtrToObjectConverter ; + wxVariantToObjectConverter m_variantToObjectConverter ; + wxObjectToVariantConverter m_objectToVariantConverter ; + wxObjectStreamingCallback m_streamingCallback ; + const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const ; - wxObjectAllocatorAndCreator* m_constructor; - const wxChar ** m_constructorProperties; - const int m_constructorPropertiesCount; - wxVariantToObjectPtrConverter m_variantOfPtrToObjectConverter; - wxVariantToObjectConverter m_variantToObjectConverter; - wxObjectToVariantConverter m_objectToVariantConverter; - wxObjectStreamingCallback m_streamingCallback; - const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const; + // InitializeClasses() helper + static wxClassInfo *GetBaseByName(const wxChar *name) ; protected: // registers the class @@ -372,98 +1828,275 @@ protected: DECLARE_NO_COPY_CLASS(wxClassInfo) }; -WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); + +WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name); // ---------------------------------------------------------------------------- -// wxDynamicClassInfo +// wxDynamicObject // ---------------------------------------------------------------------------- - +// // this object leads to having a pure runtime-instantiation class WXDLLIMPEXP_BASE wxDynamicClassInfo : public wxClassInfo { - friend class WXDLLIMPEXP_BASE wxDynamicObject; - -public: - wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName, - const wxClassInfo* superClass ); - virtual ~wxDynamicClassInfo(); + friend class WXDLLIMPEXP_BASE wxDynamicObject ; +public : + wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName , const wxClassInfo* superClass ) ; + virtual ~wxDynamicClassInfo() ; // constructs a wxDynamicObject with an instance - virtual wxObject *AllocateObject() const; + virtual wxObject *AllocateObject() const ; // Call the Create method for a class - virtual bool Create (wxObject *object, int ParamCount, wxAny *Params) const; + virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const ; // get number of parameters for constructor - virtual int GetCreateParamCount() const; + virtual int GetCreateParamCount() const ; // get i-th constructor parameter - virtual const wxChar* GetCreateParamName(int i) const; + virtual const wxChar* GetCreateParamName(int i) const ; // Runtime access to objects by property name, and variant data - virtual void SetProperty (wxObject *object, const wxChar *PropertyName, - const wxAny &Value) const; - virtual wxAny GetProperty (wxObject *object, const wxChar *PropertyName) const; + virtual void SetProperty (wxObject *object, const wxChar *PropertyName, const wxxVariant &Value) const ; + virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName) const ; // adds a property to this class at runtime - void AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo ); + void AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo ) ; // removes an existing runtime-property - void RemoveProperty( const wxChar *propertyName ); + void RemoveProperty( const wxChar *propertyName ) ; // renames an existing runtime-property - void RenameProperty( const wxChar *oldPropertyName, const wxChar *newPropertyName ); + void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ; // as a handler to this class at runtime - void AddHandler( const wxChar *handlerName, wxObjectEventFunction address, - const wxClassInfo* eventClassInfo ); + void AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) ; // removes an existing runtime-handler - void RemoveHandler( const wxChar *handlerName ); + void RemoveHandler( const wxChar *handlerName ) ; // renames an existing runtime-handler - void RenameHandler( const wxChar *oldHandlerName, const wxChar *newHandlerName ); - -private: - struct wxDynamicClassInfoInternal; - wxDynamicClassInfoInternal* m_data; -}; + void RenameHandler( const wxChar *oldHandlerName , const wxChar *newHandlerName ) ; +private : + struct wxDynamicClassInfoInternal ; + wxDynamicClassInfoInternal* m_data ; +} ; // ---------------------------------------------------------------------------- -// wxDECLARE class macros +// Dynamic class macros // ---------------------------------------------------------------------------- -#define _DECLARE_DYNAMIC_CLASS(name) \ - public: \ - static wxClassInfo ms_classInfo; \ - static const wxClassInfo* ms_classParents[]; \ - static wxPropertyInfo* GetPropertiesStatic(); \ - static wxHandlerInfo* GetHandlersStatic(); \ - static wxClassInfo *GetClassInfoStatic() \ - { return &name::ms_classInfo; } \ - virtual wxClassInfo *GetClassInfo() const \ - { return &name::ms_classInfo; } +#define _DECLARE_DYNAMIC_CLASS(name) \ + public: \ + static wxClassInfo ms_classInfo; \ + static const wxClassInfo* ms_classParents[] ; \ + static wxPropertyInfo* GetPropertiesStatic() ; \ + static wxHandlerInfo* GetHandlersStatic() ; \ + static wxClassInfo *GetClassInfoStatic() \ +{ return &name::ms_classInfo; } \ + virtual wxClassInfo *GetClassInfo() const \ +{ return &name::ms_classInfo; } -#define wxDECLARE_DYNAMIC_CLASS(name) \ - static wxObjectAllocatorAndCreator* ms_constructor; \ - static const wxChar * ms_constructorProperties[]; \ - static const int ms_constructorPropertiesCount; \ +/* +#define _DECLARE_DYNAMIC_CLASS(name) \ + public: \ + static wxClassInfo ms_class##name; \ + static const wxClassInfo* ms_classParents##name[] ; \ + static wxPropertyInfo* GetPropertiesStatic() ; \ + static wxHandlerInfo* GetHandlersStatic() ; \ + static wxClassInfo *GetClassInfoStatic() \ +{ return &name::ms_class##name; } \ + virtual wxClassInfo *GetClassInfo() const \ +{ return &name::ms_class##name; } +*/ +#define DECLARE_DYNAMIC_CLASS(name) \ + static wxConstructorBridge* ms_constructor ; \ + static const wxChar * ms_constructorProperties[] ; \ + static const int ms_constructorPropertiesCount ; \ _DECLARE_DYNAMIC_CLASS(name) -#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ - wxDECLARE_NO_ASSIGN_CLASS(name); \ - wxDECLARE_DYNAMIC_CLASS(name) +#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ + DECLARE_NO_ASSIGN_CLASS(name) \ + DECLARE_DYNAMIC_CLASS(name) -#define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \ - wxDECLARE_NO_COPY_CLASS(name); \ - wxDECLARE_DYNAMIC_CLASS(name) +#define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \ + DECLARE_NO_COPY_CLASS(name) \ + DECLARE_DYNAMIC_CLASS(name) -#define wxDECLARE_CLASS(name) \ - wxDECLARE_DYNAMIC_CLASS(name) +#define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name) +#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name) + +// ----------------------------------- +// for concrete classes +// ----------------------------------- + +// Single inheritance with one base class + +#define _TYPEINFO_CLASSES(n , toString , fromString ) \ + wxClassTypeInfo s_typeInfo##n(wxT_OBJECT , &n::ms_classInfo , toString , fromString , typeid(n).name()) ; \ + wxClassTypeInfo s_typeInfoPtr##n(wxT_OBJECT_PTR , &n::ms_classInfo , toString , fromString , typeid(n*).name()) ; + +#define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit , callback) \ + wxObject* wxConstructorFor##name() \ +{ return new name; } \ + const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \ + wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \ + wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast (data) ) ; } \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) wxConstructorFor##name , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties , \ + name::ms_constructorPropertiesCount , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name , callback); + +#define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \ + wxObject* wxConstructorFor##name() \ +{ return new name; } \ + const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \ + wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.wxTEMPLATED_MEMBER_CALL(Get , name) ; } \ + wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \ + wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast (data) ) ; } \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) wxConstructorFor##name , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties, \ + name::ms_constructorPropertiesCount , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name, callback); + +#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \ + _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" , NULL ) \ + _TYPEINFO_CLASSES(name, NULL , NULL) \ + const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ + const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ + wxCONSTRUCTOR_DUMMY( name ) + +#define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \ + _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" , NULL ) \ + _TYPEINFO_CLASSES(name, NULL , NULL) \ + wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ + wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ + wxCONSTRUCTOR_DUMMY( name ) + +#define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \ + _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , NULL ) \ + _TYPEINFO_CLASSES(name, NULL , NULL) + +#define IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name , basename , unit , callback ) \ + _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , &callback ) \ + _TYPEINFO_CLASSES(name, NULL , NULL) + +#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \ + _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL ) \ + _TYPEINFO_CLASSES(name, NULL , NULL) + +#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name , basename , unit , toString , fromString ) \ + _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL ) \ + _TYPEINFO_CLASSES(name, toString , fromString) + +// this is for classes that do not derive from wxobject, there are no creators for these + +#define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \ + const wxClassInfo* name::ms_classParents[] = { NULL } ; \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) 0 , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ + 0 , 0 , 0 ); \ + _TYPEINFO_CLASSES(name, NULL , NULL) + +// this is for subclasses that still do not derive from wxobject + +#define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \ + const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) 0 , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ + 0 , 0 , 0 ); \ + _TYPEINFO_CLASSES(name, NULL , NULL) + + +// Multiple inheritance with two base classes + +#define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \ + wxObject* wxConstructorFor##name() \ +{ return new name; } \ + const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,&basename2::ms_classInfo , NULL } ; \ + wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \ + wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast (data) ) ; } \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) wxConstructorFor##name , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties , \ + name::ms_constructorPropertiesCount , wxVariantToObjectConverter##name, wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ + +#define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \ + _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \ + _TYPEINFO_CLASSES(name, NULL , NULL) \ + wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ + wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ + wxCONSTRUCTOR_DUMMY( name ) + +#define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \ + _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit) \ + _TYPEINFO_CLASSES(name, NULL , NULL) + + +// ----------------------------------- +// for abstract classes +// ----------------------------------- + +// Single inheritance with one base class + +#define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \ + const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \ + wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \ + wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \ + wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast (data) ) ; } \ + wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \ + (int) sizeof(name), \ + (wxObjectConstructorFn) 0 , \ + name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ + 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ + _TYPEINFO_CLASSES(name, NULL , NULL) + +#define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ + _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ + wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ + wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } + +// Multiple inheritance with two base classes + +#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ + wxClassInfo name::ms_classInfo(wxT(#name), wxT(#basename1), \ + wxT(#basename2), (int) sizeof(name), \ + (wxObjectConstructorFn) 0); + +#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS +#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2 + +#define wxBEGIN_EVENT_TABLE( a , b ) BEGIN_EVENT_TABLE( a , b ) +#define wxEND_EVENT_TABLE() END_EVENT_TABLE() + +// -------------------------------------------------------------------------- +// Collection Support +// -------------------------------------------------------------------------- + +template void wxListCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value ) +{ + iter current = coll.GetFirst() ; + while (current) + { + value.Add( new wxxVariant(current->GetData()) ) ; + current = current->GetNext(); + } +} + +template void wxArrayCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value ) +{ + for( size_t i = 0 ; i < coll.GetCount() ; i++ ) + { + value.Add( new wxxVariant(coll[i]) ) ; + } +} -#define wxDECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name) -#define wxCLASSINFO(name) (&name::ms_classInfo) -#endif // wxUSE_EXTENDED_RTTI #endif // _WX_XTIH__ diff --git a/Source/3rd Party/wx/include/wx/xti2.h b/Source/3rd Party/wx/include/wx/xti2.h deleted file mode 100644 index 16e5f212f..000000000 --- a/Source/3rd Party/wx/include/wx/xti2.h +++ /dev/null @@ -1,293 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/wxt2.h -// Purpose: runtime metadata information (extended class info) -// Author: Stefan Csomor -// Modified by: Francesco Montorsi -// Created: 27/07/03 -// Copyright: (c) 1997 Julian Smart -// (c) 2003 Stefan Csomor -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_XTI2H__ -#define _WX_XTI2H__ - -// ---------------------------------------------------------------------------- -// second part of xti headers, is included from object.h -// ---------------------------------------------------------------------------- - -#if wxUSE_EXTENDED_RTTI - -// ---------------------------------------------------------------------------- -// wxDynamicObject class, its instances connect to a 'super class instance' -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject -{ - friend class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo ; -public: - // instantiates this object with an instance of its superclass - wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ; - virtual ~wxDynamicObject(); - - void SetProperty (const wxChar *propertyName, const wxAny &value); - wxAny GetProperty (const wxChar *propertyName) const ; - - // get the runtime identity of this object - wxClassInfo *GetClassInfo() const - { -#ifdef _MSC_VER - return (wxClassInfo*) m_classInfo; -#else - wxDynamicClassInfo *nonconst = const_cast(m_classInfo); - return static_cast(nonconst); -#endif - } - - wxObject* GetSuperClassInstance() const - { - return m_superClassInstance ; - } -private : - // removes an existing runtime-property - void RemoveProperty( const wxChar *propertyName ) ; - - // renames an existing runtime-property - void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ; - - wxObject *m_superClassInstance ; - const wxDynamicClassInfo *m_classInfo; - struct wxDynamicObjectInternal; - wxDynamicObjectInternal *m_data; -}; - -// ---------------------------------------------------------------------------- -// String conversion templates supporting older compilers -// ---------------------------------------------------------------------------- - -#if wxUSE_FUNC_TEMPLATE_POINTER -# define wxTO_STRING(type) wxToStringConverter -# define wxTO_STRING_IMP(type) -# define wxFROM_STRING(type) wxFromStringConverter -# define wxFROM_STRING_IMP(type) -#else -# define wxTO_STRING(type) ToString##type -# define wxTO_STRING_IMP(type) \ - inline void ToString##type( const wxAny& data, wxString &result ) \ -{ wxToStringConverter(data, result); } - -# define wxFROM_STRING(type) FromString##type -# define wxFROM_STRING_IMP(type) \ - inline void FromString##type( const wxString& data, wxAny &result ) \ -{ wxFromStringConverter(data, result); } -#endif - -#include "wx/xtiprop.h" -#include "wx/xtictor.h" - -// ---------------------------------------------------------------------------- -// wxIMPLEMENT class macros for concrete classes -// ---------------------------------------------------------------------------- - -// Single inheritance with one base class - -#define _DEFAULT_CONSTRUCTOR(name) \ -wxObject* wxConstructorFor##name() \ -{ return new name; } - -#define _DEFAULT_CONVERTERS(name) \ -wxObject* wxVariantOfPtrToObjectConverter##name ( const wxAny &data ) \ -{ return data.As( (name**)NULL ); } \ - wxAny wxObjectToVariantConverter##name ( wxObject *data ) \ -{ return wxAny( wx_dynamic_cast(name*, data) ); } - -#define _TYPEINFO_CLASSES(n, toString, fromString ) \ - wxClassTypeInfo s_typeInfo##n(wxT_OBJECT, &n::ms_classInfo, \ - toString, fromString, typeid(n).name()); \ - wxClassTypeInfo s_typeInfoPtr##n(wxT_OBJECT_PTR, &n::ms_classInfo, \ - toString, fromString, typeid(n*).name()); - -#define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit, callback) \ - _DEFAULT_CONSTRUCTOR(name) \ - _DEFAULT_CONVERTERS(name) \ - \ - const wxClassInfo* name::ms_classParents[] = \ -{ &basename::ms_classInfo, NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ - name::GetPropertiesStatic, name::GetHandlersStatic, name::ms_constructor, \ - name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ - wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \ - callback); - -#define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \ - _DEFAULT_CONSTRUCTOR(name) \ - _DEFAULT_CONVERTERS(name) \ - void wxVariantToObjectConverter##name ( const wxAny &data, wxObjectFunctor* fn ) \ - { name o = wxANY_AS(data, name); (*fn)( &o ); } \ - \ - const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo,NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ - name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \ - name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ - wxVariantOfPtrToObjectConverter##name, wxVariantToObjectConverter##name, \ - wxObjectToVariantConverter##name, callback); - -#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename ) \ - _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, "", NULL ) \ - _TYPEINFO_CLASSES(name, NULL, NULL) \ - const wxPropertyInfo *name::GetPropertiesStatic() \ -{ return (wxPropertyInfo*) NULL; } \ - const wxHandlerInfo *name::GetHandlersStatic() \ -{ return (wxHandlerInfo*) NULL; } \ - wxCONSTRUCTOR_DUMMY( name ) - -#define wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) \ - _IMPLEMENT_DYNAMIC_CLASS( name, basename, "", NULL ) \ - _TYPEINFO_CLASSES(name, NULL, NULL) \ - wxPropertyInfo *name::GetPropertiesStatic() \ -{ return (wxPropertyInfo*) NULL; } \ - wxHandlerInfo *name::GetHandlersStatic() \ -{ return (wxHandlerInfo*) NULL; } \ - wxCONSTRUCTOR_DUMMY( name ) - -#define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \ - _IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, NULL ) \ - _TYPEINFO_CLASSES(name, NULL, NULL) - -#define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback )\ - _IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, &callback ) \ - _TYPEINFO_CLASSES(name, NULL, NULL) - -#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \ - _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \ - _TYPEINFO_CLASSES(name, NULL, NULL) - -#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \ - unit, toString, \ - fromString ) \ - _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \ - _TYPEINFO_CLASSES(name, toString, fromString) - -// this is for classes that do not derive from wxObject, there are no creators for these - -#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) \ - const wxClassInfo* name::ms_classParents[] = { NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ - name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ - 0, 0, 0 ); \ - _TYPEINFO_CLASSES(name, NULL, NULL) - -// this is for subclasses that still do not derive from wxObject - -#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) \ - const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo, NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ - name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ - 0, 0, 0 ); \ - _TYPEINFO_CLASSES(name, NULL, NULL) - - -// Multiple inheritance with two base classes - -#define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit, callback) \ - _DEFAULT_CONSTRUCTOR(name) \ - _DEFAULT_CONVERTERS(name) \ - \ - const wxClassInfo* name::ms_classParents[] = \ -{ &basename::ms_classInfo,&basename2::ms_classInfo, NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ - name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \ - name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ - wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \ - callback); - -#define wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2) \ - _IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, "", NULL) \ - _TYPEINFO_CLASSES(name, NULL, NULL) \ - wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; } \ - wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \ - wxCONSTRUCTOR_DUMMY( name ) - -#define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) \ - _IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, unit, NULL) \ - _TYPEINFO_CLASSES(name, NULL, NULL) - - - -// ---------------------------------------------------------------------------- -// wxIMPLEMENT class macros for abstract classes -// ---------------------------------------------------------------------------- - -// Single inheritance with one base class - -#define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \ - _DEFAULT_CONVERTERS(name) \ - \ - const wxClassInfo* name::ms_classParents[] = \ -{ &basename::ms_classInfo,NULL }; \ - wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ - wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ - name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ - 0, wxVariantOfPtrToObjectConverter##name,0, \ - wxObjectToVariantConverter##name); \ - _TYPEINFO_CLASSES(name, NULL, NULL) - -#define wxIMPLEMENT_ABSTRACT_CLASS( name, basename ) \ - _IMPLEMENT_ABSTRACT_CLASS( name, basename ) \ - wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \ - wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; } - -// Multiple inheritance with two base classes - -#define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ - wxClassInfo name::ms_classInfo(wxT(#name), wxT(#basename1), \ - wxT(#basename2), (int) sizeof(name), \ - (wxObjectConstructorFn) 0); - -// templated streaming, every type that can be converted to wxString -// must have their specialization for these methods - -template -void wxStringReadValue( const wxString &s, T &data ); - -template -void wxStringWriteValue( wxString &s, const T &data); - -template -void wxToStringConverter( const wxAny &v, wxString &s ) -{ wxStringWriteValue(s, wxANY_AS(v, T)); } - -template -void wxFromStringConverter( const wxString &s, wxAny &v) -{ T d; wxStringReadValue(s, d); v = wxAny(d); } - -// -------------------------------------------------------------------------- -// Collection Support -// -------------------------------------------------------------------------- - -template void wxListCollectionToAnyList( - const collection_t& coll, wxAnyList &value ) -{ - for ( iter current = coll.GetFirst(); current; - current = current->GetNext() ) - { - value.Append( new wxAny(current->GetData()) ); - } -} - -template void wxArrayCollectionToVariantArray( - const collection_t& coll, wxAnyList &value ) -{ - for( size_t i = 0; i < coll.GetCount(); i++ ) - { - value.Append( new wxAny(coll[i]) ); - } -} - -#endif - -#endif // _WX_XTIH2__ diff --git a/Source/3rd Party/wx/include/wx/xtictor.h b/Source/3rd Party/wx/include/wx/xtictor.h deleted file mode 100644 index 6969463f3..000000000 --- a/Source/3rd Party/wx/include/wx/xtictor.h +++ /dev/null @@ -1,509 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtictor.h -// Purpose: XTI constructors -// Author: Stefan Csomor -// Modified by: Francesco Montorsi -// Created: 27/07/03 -// Copyright: (c) 1997 Julian Smart -// (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _XTICTOR_H_ -#define _XTICTOR_H_ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/xti.h" - -// ---------------------------------------------------------------------------- -// Constructor Bridges -// ---------------------------------------------------------------------------- - -// A constructor bridge allows to call a ctor with an arbitrary number -// or parameters during runtime -class WXDLLIMPEXP_BASE wxObjectAllocatorAndCreator -{ -public: - virtual ~wxObjectAllocatorAndCreator() { } - virtual bool Create(wxObject * &o, wxAny *args) = 0; -}; - -// a direct constructor bridge calls the operator new for this class and -// passes all params to the constructor. Needed for classes that cannot be -// instantiated using alloc-create semantics -class WXDLLIMPEXP_BASE wxObjectAllocator : public wxObjectAllocatorAndCreator -{ -public: - virtual bool Create(wxObject * &o, wxAny *args) = 0; -}; - - -// ---------------------------------------------------------------------------- -// Constructor Bridges for all Numbers of Params -// ---------------------------------------------------------------------------- - -// no params - -template -struct wxObjectAllocatorAndCreator_0 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create(); - } -}; - -struct wxObjectAllocatorAndCreator_Dummy : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject *&, wxAny *) - { - return true; - } -}; - -#define wxCONSTRUCTOR_0(klass) \ - wxObjectAllocatorAndCreator_0 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { NULL }; \ - const int klass::ms_constructorPropertiesCount = 0; - -#define wxCONSTRUCTOR_DUMMY(klass) \ - wxObjectAllocatorAndCreator_Dummy constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { NULL }; \ - const int klass::ms_constructorPropertiesCount = 0; - -// direct constructor version - -template -struct wxDirectConstructorBridge_0 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_0(klass) \ - wxDirectConstructorBridge_0 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { NULL }; \ - const int klass::ms_constructorPropertiesCount = 0; - - -// 1 param - -template -struct wxObjectAllocatorAndCreator_1 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_1(klass,t0,v0) \ - wxObjectAllocatorAndCreator_1 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) }; \ - const int klass::ms_constructorPropertiesCount = 1; - -// direct constructor version - -template -struct wxDirectConstructorBridge_1 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \ - wxDirectConstructorBridge_1 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) }; \ - const int klass::ms_constructorPropertiesCount = 1; - - -// 2 params - -template -struct wxObjectAllocatorAndCreator_2 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \ - wxObjectAllocatorAndCreator_2 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1) }; \ - const int klass::ms_constructorPropertiesCount = 2; - -// direct constructor version - -template -struct wxDirectConstructorBridge_2 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \ - wxDirectConstructorBridge_2 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1) }; \ - const int klass::ms_constructorPropertiesCount = 2; - - -// 3 params - -template -struct wxObjectAllocatorAndCreator_3 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ - wxObjectAllocatorAndCreator_3 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), wxT(#v2) }; \ - const int klass::ms_constructorPropertiesCount = 3; - -// direct constructor version - -template -struct wxDirectConstructorBridge_3 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ - wxDirectConstructorBridge_3 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), wxT(#v2) }; \ - const int klass::ms_constructorPropertiesCount = 3; - - -// 4 params - -template -struct wxObjectAllocatorAndCreator_4 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ - wxObjectAllocatorAndCreator_4 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3) }; \ - const int klass::ms_constructorPropertiesCount = 4; - -// direct constructor version - -template -struct wxDirectConstructorBridge_4 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ - wxDirectConstructorBridge_4 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3) }; \ - const int klass::ms_constructorPropertiesCount = 4; - - -// 5 params - -template -struct wxObjectAllocatorAndCreator_5 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ - wxObjectAllocatorAndCreator_5 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4) }; \ - const int klass::ms_constructorPropertiesCount = 5; - -// direct constructor version - -template -struct wxDirectConstructorBridge_5 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ - wxDirectConstructorBridge_5 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4) }; \ - const int klass::ms_constructorPropertiesCount = 5; - - -// 6 params - -template -struct wxObjectAllocatorAndCreator_6 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ - wxObjectAllocatorAndCreator_6 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5) }; \ - const int klass::ms_constructorPropertiesCount = 6; - -// direct constructor version - -template -struct wxDirectConstructorBridge_6 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ - wxDirectConstructorBridge_6 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), \ - wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5) }; \ - const int klass::ms_constructorPropertiesCount = 6; - - -// 7 params - -template -struct wxObjectAllocatorAndCreator_7 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)), - (args[6]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ - wxObjectAllocatorAndCreator_7 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), \ - wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6) }; \ - const int klass::ms_constructorPropertiesCount = 7; - -// direct constructor version - -template -struct wxDirectConstructorBridge_7 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)), - (args[6]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ - wxDirectConstructorBridge_7 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6) }; \ - const int klass::ms_constructorPropertiesCount = 7; - - -// 8 params - -template -struct wxObjectAllocatorAndCreator_8 : public wxObjectAllocatorAndCreator -{ - bool Create(wxObject * &o, wxAny *args) - { - Class *obj = wx_dynamic_cast(Class*, o); - return obj->Create( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)), - (args[6]).As(static_cast(NULL)), - (args[7]).As(static_cast(NULL)) - ); - } -}; - -#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ - wxObjectAllocatorAndCreator_8 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6), wxT(#v7) }; \ - const int klass::ms_constructorPropertiesCount = 8; - -// direct constructor version - -template -struct wxDirectConstructorBridge_8 : public wxObjectAllocator -{ - bool Create(wxObject * &o, wxAny *args) - { - o = new Class( - (args[0]).As(static_cast(NULL)), - (args[1]).As(static_cast(NULL)), - (args[2]).As(static_cast(NULL)), - (args[3]).As(static_cast(NULL)), - (args[4]).As(static_cast(NULL)), - (args[5]).As(static_cast(NULL)), - (args[6]).As(static_cast(NULL)), - (args[7]).As(static_cast(NULL)) - ); - return o != NULL; - } -}; - -#define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ - wxDirectConstructorBridge_8 constructor##klass; \ - wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \ - const wxChar *klass::ms_constructorProperties[] = \ - { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6), wxT(#v7) }; \ - const int klass::ms_constructorPropertiesCount = 8; - -#endif // wxUSE_EXTENDED_RTTI -#endif // _XTICTOR_H_ diff --git a/Source/3rd Party/wx/include/wx/xtihandler.h b/Source/3rd Party/wx/include/wx/xtihandler.h deleted file mode 100644 index c63ddb3a3..000000000 --- a/Source/3rd Party/wx/include/wx/xtihandler.h +++ /dev/null @@ -1,112 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtihandler.h -// Purpose: XTI handlers -// Author: Stefan Csomor -// Modified by: Francesco Montorsi -// Created: 27/07/03 -// Copyright: (c) 1997 Julian Smart -// (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _XTIHANDLER_H_ -#define _XTIHANDLER_H_ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/xti.h" - -// copied from event.h which cannot be included at this place - -class WXDLLIMPEXP_FWD_BASE wxEvent; - -#ifdef __VISUALC__ -#define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance -#else -#define wxMSVC_FWD_MULTIPLE_BASES -#endif - -class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler; -typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); -typedef wxEventFunction wxObjectEventFunction; - -// ---------------------------------------------------------------------------- -// Handler Info -// -// this describes an event sink -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxHandlerInfo -{ - friend class WXDLLIMPEXP_BASE wxDynamicClassInfo; - -public: - wxHandlerInfo(wxHandlerInfo* &iter, - wxClassInfo* itsClass, - const wxString& name, - wxObjectEventFunction address, - const wxClassInfo* eventClassInfo) : - m_eventFunction(address), - m_name(name), - m_eventClassInfo(eventClassInfo), - m_itsClass(itsClass) - { - Insert(iter); - } - - ~wxHandlerInfo() - { Remove(); } - - // return the name of this handler - const wxString& GetName() const { return m_name; } - - // return the class info of the event - const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo; } - - // get the handler function pointer - wxObjectEventFunction GetEventFunction() const { return m_eventFunction; } - - // returns NULL if this is the last handler of this class - wxHandlerInfo* GetNext() const { return m_next; } - - // return the class this property is declared in - const wxClassInfo* GetDeclaringClass() const { return m_itsClass; } - -private: - - // inserts this handler at the end of the linked chain which begins - // with "iter" handler. - void Insert(wxHandlerInfo* &iter); - - // removes this handler from the linked chain of the m_itsClass handlers. - void Remove(); - - wxObjectEventFunction m_eventFunction; - wxString m_name; - const wxClassInfo* m_eventClassInfo; - wxHandlerInfo* m_next; - wxClassInfo* m_itsClass; -}; - -#define wxHANDLER(name,eventClassType) \ - static wxHandlerInfo _handlerInfo##name( first, class_t::GetClassInfoStatic(), \ - wxT(#name), (wxObjectEventFunction) (wxEventFunction) &name, \ - wxCLASSINFO( eventClassType ) ); - -#define wxBEGIN_HANDLERS_TABLE(theClass) \ - wxHandlerInfo *theClass::GetHandlersStatic() \ - { \ - typedef theClass class_t; \ - static wxHandlerInfo* first = NULL; - -#define wxEND_HANDLERS_TABLE() \ - return first; } - -#define wxEMPTY_HANDLERS_TABLE(theClass) \ - wxBEGIN_HANDLERS_TABLE(theClass) \ - wxEND_HANDLERS_TABLE() - -#endif // wxUSE_EXTENDED_RTTI -#endif // _XTIHANDLER_H_ diff --git a/Source/3rd Party/wx/include/wx/xtiprop.h b/Source/3rd Party/wx/include/wx/xtiprop.h deleted file mode 100644 index 18626f298..000000000 --- a/Source/3rd Party/wx/include/wx/xtiprop.h +++ /dev/null @@ -1,560 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtiprop.h -// Purpose: XTI properties -// Author: Stefan Csomor -// Modified by: Francesco Montorsi -// Created: 27/07/03 -// Copyright: (c) 1997 Julian Smart -// (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _XTIPROP_H_ -#define _XTIPROP_H_ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/xti.h" -#include "wx/any.h" - -/* -class WXDLLIMPEXP_BASE wxObject; -class WXDLLIMPEXP_BASE wxClassInfo; -class WXDLLIMPEXP_BASE wxDynamicClassInfo; -*/ -class WXDLLIMPEXP_BASE wxHashTable; -class WXDLLIMPEXP_BASE wxHashTable_Node; -class WXDLLIMPEXP_BASE wxEvent; -class WXDLLIMPEXP_BASE wxEvtHandler; - -// ---------------------------------------------------------------------------- -// Property Accessors -// -// wxPropertySetter/Getter/CollectionGetter/CollectionAdder are all property -// accessors which are managed by wxPropertyAccessor class which in turn is -// handled by wxPropertyInfo. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxPropertySetter -{ -public: - wxPropertySetter( const wxString name ) { m_name = name; } - virtual ~wxPropertySetter() {} - - virtual void Set( wxObject *object, const wxAny &variantValue ) const = 0; - const wxString& GetName() const { return m_name; } - -private: - wxString m_name; -}; - -class WXDLLIMPEXP_BASE wxPropertyGetter -{ -public: - wxPropertyGetter( const wxString name ) { m_name = name; } - virtual ~wxPropertyGetter() {} - - virtual void Get( const wxObject *object, wxAny& result) const = 0; - const wxString& GetName() const { return m_name; } - -private: - wxString m_name; -}; - -class WXDLLIMPEXP_BASE wxPropertyCollectionGetter -{ -public: - wxPropertyCollectionGetter( const wxString name ) { m_name = name; } - virtual ~wxPropertyCollectionGetter() {} - - virtual void Get( const wxObject *object, wxAnyList& result) const = 0; - const wxString& GetName() const { return m_name; } - -private: - wxString m_name; -}; - -template void WXDLLIMPEXP_BASE \ - wxCollectionToVariantArray( const coll_t& coll, wxAnyList& result ); - -class WXDLLIMPEXP_BASE wxPropertyCollectionAdder -{ -public: - wxPropertyCollectionAdder( const wxString name ) { m_name = name; } - virtual ~wxPropertyCollectionAdder() {} - - virtual void Add( wxObject *object, const wxAny &variantValue ) const= 0; - const wxString& GetName() const { return m_name; } - -private: - wxString m_name; -}; - -#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \ -class wxPropertySetter##property : public wxPropertySetter \ -{ \ -public: \ - wxINFUNC_CLASS_TYPE_FIX(Klass) \ - wxPropertySetter##property() : wxPropertySetter( wxT(#setterMethod) ) {} \ - virtual ~wxPropertySetter##property() {} \ - \ - void Set( wxObject *object, const wxAny &variantValue ) const \ - { \ - Klass *obj = dynamic_cast(object); \ - valueType tempobj; \ - if ( variantValue.GetAs(&tempobj) ) \ - obj->setterMethod(tempobj); \ - else \ - obj->setterMethod(*wxANY_AS(variantValue, valueType*)); \ - } \ -}; - -#define wxPROPERTY_GETTER( property, Klass, valueType, gettermethod ) \ -class wxPropertyGetter##property : public wxPropertyGetter \ -{ \ -public: \ - wxINFUNC_CLASS_TYPE_FIX(Klass) \ - wxPropertyGetter##property() : wxPropertyGetter( wxT(#gettermethod) ) {} \ - virtual ~wxPropertyGetter##property() {} \ - \ - void Get( const wxObject *object, wxAny &result) const \ - { \ - const Klass *obj = dynamic_cast(object); \ - result = wxAny( obj->gettermethod() ); \ - } \ -}; - -#define wxPROPERTY_COLLECTION_ADDER( property, Klass, valueType, addermethod ) \ -class wxPropertyCollectionAdder##property : public wxPropertyCollectionAdder \ -{ \ -public: \ - wxINFUNC_CLASS_TYPE_FIX(Klass) \ - wxPropertyCollectionAdder##property() : wxPropertyCollectionAdder( wxT(#addermethod) ) {} \ - virtual ~wxPropertyCollectionAdder##property() {} \ - \ - void Add( wxObject *object, const wxAny &variantValue ) const \ - { \ - Klass *obj = dynamic_cast(object); \ - valueType tempobj; \ - if ( variantValue.GetAs(&tempobj) ) \ - obj->addermethod(tempobj); \ - else \ - obj->addermethod(*wxANY_AS(variantValue, valueType*)); \ - } \ -}; - -#define wxPROPERTY_COLLECTION_GETTER( property, Klass, valueType, gettermethod ) \ -class wxPropertyCollectionGetter##property : public wxPropertyCollectionGetter \ -{ \ -public: \ - wxINFUNC_CLASS_TYPE_FIX(Klass) \ - wxPropertyCollectionGetter##property() : wxPropertyCollectionGetter( wxT(#gettermethod) ) {} \ - virtual ~wxPropertyCollectionGetter##property() {} \ - \ - void Get( const wxObject *object, wxAnyList &result) const \ - { \ - const Klass *obj = dynamic_cast(object); \ - wxCollectionToVariantArray( obj->gettermethod(), result ); \ - } \ -}; - -class WXDLLIMPEXP_BASE wxPropertyAccessor -{ -public: - wxPropertyAccessor( wxPropertySetter *setter, wxPropertyGetter *getter, - wxPropertyCollectionAdder *adder, wxPropertyCollectionGetter *collectionGetter ) - { m_setter = setter; m_getter = getter; m_adder = adder; - m_collectionGetter = collectionGetter; } - - virtual ~wxPropertyAccessor() {} - - // Setting a simple property (non-collection) - virtual void SetProperty(wxObject *object, const wxAny &value) const - { - if ( m_setter ) - m_setter->Set( object, value ); - else - wxLogError( wxGetTranslation("SetProperty called w/o valid setter") ); - } - - // Getting a simple property (non-collection) - virtual void GetProperty(const wxObject *object, wxAny &result) const - { - if ( m_getter ) - m_getter->Get( object, result ); - else - wxLogError( wxGetTranslation("GetProperty called w/o valid getter") ); - } - - // Adding an element to a collection property - virtual void AddToPropertyCollection(wxObject *object, const wxAny &value) const - { - if ( m_adder ) - m_adder->Add( object, value ); - else - wxLogError( wxGetTranslation("AddToPropertyCollection called w/o valid adder") ); - } - - // Getting a collection property - virtual void GetPropertyCollection( const wxObject *obj, wxAnyList &result) const - { - if ( m_collectionGetter ) - m_collectionGetter->Get( obj, result); - else - wxLogError( wxGetTranslation("GetPropertyCollection called w/o valid collection getter") ); - } - - virtual bool HasSetter() const { return m_setter != NULL; } - virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL; } - virtual bool HasGetter() const { return m_getter != NULL; } - virtual bool HasAdder() const { return m_adder != NULL; } - - virtual const wxString& GetCollectionGetterName() const - { return m_collectionGetter->GetName(); } - virtual const wxString& GetGetterName() const - { return m_getter->GetName(); } - virtual const wxString& GetSetterName() const - { return m_setter->GetName(); } - virtual const wxString& GetAdderName() const - { return m_adder->GetName(); } - -protected: - wxPropertySetter *m_setter; - wxPropertyCollectionAdder *m_adder; - wxPropertyGetter *m_getter; - wxPropertyCollectionGetter* m_collectionGetter; -}; - -class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor -{ -public: - wxGenericPropertyAccessor( const wxString &propName ); - virtual ~wxGenericPropertyAccessor(); - - void RenameProperty( const wxString& WXUNUSED_UNLESS_DEBUG(oldName), - const wxString& newName ) - { - wxASSERT( oldName == m_propertyName ); m_propertyName = newName; - } - - virtual bool HasSetter() const { return true; } - virtual bool HasGetter() const { return true; } - virtual bool HasAdder() const { return false; } - virtual bool HasCollectionGetter() const { return false; } - - virtual const wxString& GetGetterName() const - { return m_getterName; } - virtual const wxString& GetSetterName() const - { return m_setterName; } - - virtual void SetProperty(wxObject *object, const wxAny &value) const; - virtual void GetProperty(const wxObject *object, wxAny &value) const; - - // Adding an element to a collection property - virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), - const wxAny &WXUNUSED(value)) const - { - wxLogError( wxGetTranslation("AddToPropertyCollection called on a generic accessor") ); - } - - // Getting a collection property - virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), - wxAnyList &WXUNUSED(result)) const - { - wxLogError ( wxGetTranslation("GetPropertyCollection called on a generic accessor") ); - } - -private: - struct wxGenericPropertyAccessorInternal; - wxGenericPropertyAccessorInternal* m_data; - wxString m_propertyName; - wxString m_setterName; - wxString m_getterName; -}; - -typedef long wxPropertyInfoFlags; -enum -{ - // will be removed in future releases - wxPROP_DEPRECATED = 0x00000001, - - // object graph property, will be streamed with priority (after constructor properties) - wxPROP_OBJECT_GRAPH = 0x00000002, - - // this will only be streamed out and in as enum/set, the internal representation - // is still a long - wxPROP_ENUM_STORE_LONG = 0x00000004, - - // don't stream out this property, needed eg to avoid streaming out children - // that are always created by their parents - wxPROP_DONT_STREAM = 0x00000008 -}; - - -// ---------------------------------------------------------------------------- -// Property Support -// -// wxPropertyInfo is used to inquire of the property by name. It doesn't -// provide access to the property, only information about it. If you -// want access, look at wxPropertyAccessor. -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxPropertyInfo -{ - friend class /* WXDLLIMPEXP_BASE */ wxDynamicClassInfo; - -public: - wxPropertyInfo(wxPropertyInfo* &iter, - wxClassInfo* itsClass, - const wxString& name, - const wxString& typeName, - wxPropertyAccessor *accessor, - wxAny dv, - wxPropertyInfoFlags flags = 0, - const wxString& helpString = wxEmptyString, - const wxString& groupString = wxEmptyString) : - m_itsClass(itsClass), - m_name(name), - m_typeInfo(NULL), - m_typeName(typeName), - m_collectionElementTypeInfo(NULL), - m_accessor(accessor), - m_defaultValue(dv), - m_flags(flags), - m_helpString(helpString), - m_groupString(groupString) - { - Insert(iter); - } - - wxPropertyInfo(wxPropertyInfo* &iter, - wxClassInfo* itsClass, - const wxString& name, - wxEventSourceTypeInfo* type, - wxPropertyAccessor *accessor, - wxAny dv, - wxPropertyInfoFlags flags = 0, - const wxString& helpString = wxEmptyString, - const wxString& groupString = wxEmptyString) : - m_itsClass(itsClass), - m_name(name), - m_typeInfo(type), - m_collectionElementTypeInfo(NULL), - m_accessor(accessor), - m_defaultValue(dv), - m_flags(flags), - m_helpString(helpString), - m_groupString(groupString) - { - Insert(iter); - } - - wxPropertyInfo(wxPropertyInfo* &iter, - wxClassInfo* itsClass, const wxString& name, - const wxString& collectionTypeName, - const wxString& elementTypeName, - wxPropertyAccessor *accessor, - wxPropertyInfoFlags flags = 0, - const wxString& helpString = wxEmptyString, - const wxString& groupString = wxEmptyString) : - m_itsClass(itsClass), - m_name(name), - m_typeInfo(NULL), - m_typeName(collectionTypeName), - m_collectionElementTypeInfo(NULL), - m_collectionElementTypeName(elementTypeName), - m_accessor(accessor), - m_flags(flags), - m_helpString(helpString), - m_groupString(groupString) - { - Insert(iter); - } - - ~wxPropertyInfo() - { Remove(); } - - // return the class this property is declared in - const wxClassInfo* GetDeclaringClass() const { return m_itsClass; } - - // return the name of this property - const wxString& GetName() const { return m_name; } - - // returns the flags of this property - wxPropertyInfoFlags GetFlags() const { return m_flags; } - - // returns the short help string of this property - const wxString& GetHelpString() const { return m_helpString; } - - // returns the group string of this property - const wxString& GetGroupString() const { return m_groupString; } - - // return the element type info of this property (for collections, otherwise NULL) - const wxTypeInfo * GetCollectionElementTypeInfo() const - { - if ( m_collectionElementTypeInfo == NULL ) - m_collectionElementTypeInfo = wxTypeInfo::FindType(m_collectionElementTypeName); - return m_collectionElementTypeInfo; - } - - // return the type info of this property - const wxTypeInfo * GetTypeInfo() const - { - if ( m_typeInfo == NULL ) - m_typeInfo = wxTypeInfo::FindType(m_typeName); - return m_typeInfo; - } - - // return the accessor for this property - wxPropertyAccessor* GetAccessor() const { return m_accessor; } - - // returns NULL if this is the last property of this class - wxPropertyInfo* GetNext() const { return m_next; } - - // returns the default value of this property, its kind may be wxT_VOID if it is not valid - wxAny GetDefaultValue() const { return m_defaultValue; } - -private: - - // inserts this property at the end of the linked chain which begins - // with "iter" property. - void Insert(wxPropertyInfo* &iter); - - // removes this property from the linked chain of the m_itsClass properties. - void Remove(); - - wxClassInfo* m_itsClass; - wxString m_name; - mutable wxTypeInfo* m_typeInfo; - wxString m_typeName; - mutable wxTypeInfo* m_collectionElementTypeInfo; - wxString m_collectionElementTypeName; - wxPropertyAccessor* m_accessor; - wxAny m_defaultValue; - wxPropertyInfoFlags m_flags; - wxString m_helpString; - wxString m_groupString; - wxPropertyInfo* m_next; - - // FIXME: what's this comment about?? - // string representation of the default value - // to be assigned by the designer to the property - // when the component is dropped on the container. -}; - -// stl is giving problems when forwarding declarations, therefore we define it as a subclass - -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMapBase, - class WXDLLIMPEXP_BASE ); - -class WXDLLIMPEXP_BASE wxPropertyInfoMap : public wxPropertyInfoMapBase { -}; - -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxAny, wxStringToAnyHashMapBase, - class WXDLLIMPEXP_BASE ); - -class WXDLLIMPEXP_FWD_BASE wxStringToAnyHashMap : public wxStringToAnyHashMapBase { -}; - -#define wxBEGIN_PROPERTIES_TABLE(theClass) \ - wxPropertyInfo *theClass::GetPropertiesStatic() \ - { \ - typedef theClass class_t; \ - static wxPropertyInfo* first = NULL; - -#define wxEND_PROPERTIES_TABLE() \ - return first; } - -#define wxHIDE_PROPERTY( pname ) \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(void).name(), NULL, wxAny(), wxPROP_DONT_STREAM, \ - wxEmptyString, wxEmptyString ); - -#define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \ - wxPROPERTY_SETTER( pname, class_t, type, setter ) \ - static wxPropertySetter##pname _setter##pname; \ - wxPROPERTY_GETTER( pname, class_t, type, getter ) \ - static wxPropertyGetter##pname _getter##pname; \ - static wxPropertyAccessor _accessor##pname( &_setter##pname, \ - &_getter##pname, NULL, NULL ); \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(type).name(), &_accessor##pname, \ - wxAny(defaultValue), flags, group, help ); - -#define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \ - pflags, help, group) \ - wxPROPERTY_SETTER( pname, class_t, type, setter ) \ - static wxPropertySetter##pname _setter##pname; \ - wxPROPERTY_GETTER( pname, class_t, type, getter ) \ - static wxPropertyGetter##pname _getter##pname; \ - static wxPropertyAccessor _accessor##pname( &_setter##pname, \ - &_getter##pname, NULL, NULL ); \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(flags).name(), &_accessor##pname, \ - wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); - -#define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \ - wxPROPERTY_GETTER( pname, class_t, type, getter ) \ - static wxPropertyGetter##pname _getter##pname; \ - static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(type).name(),&_accessor##pname, \ - wxAny(defaultValue), flags, help, group ); - -#define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \ - pflags, help, group) \ - wxPROPERTY_GETTER( pname, class_t, type, getter ) \ - static wxPropertyGetter##pname _getter##pname; \ - static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(flags).name(),&_accessor##pname, \ - wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); - -#define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \ - flags, help, group ) \ - wxPROPERTY_COLLECTION_ADDER( pname, class_t, addelemtype, adder ) \ - static wxPropertyCollectionAdder##pname _adder##pname; \ - wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \ - static wxPropertyCollectionGetter##pname _collectionGetter##pname; \ - static wxPropertyAccessor _accessor##pname( NULL, NULL,&_adder##pname, \ - &_collectionGetter##pname ); \ - static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \ - &_accessor##pname, flags, help, group ); - -#define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \ - flags, help, group) \ - wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \ - static wxPropertyCollectionGetter##pname _collectionGetter##pname; \ - static wxPropertyAccessor _accessor##pname( NULL, NULL, NULL, \ - &_collectionGetter##pname ); \ - static wxPropertyInfo _propertyInfo##pname( first,class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \ - &_accessor##pname, flags, help, group ); - -#define wxEVENT_PROPERTY( name, eventType, eventClass ) \ - static wxEventSourceTypeInfo _typeInfo##name( eventType, wxCLASSINFO( eventClass ) ); \ - static wxPropertyInfo _propertyInfo##name( first,class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxAny() ); - -#define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) \ - static wxEventSourceTypeInfo _typeInfo##name( eventType, lastEventType, \ - wxCLASSINFO( eventClass ) ); \ - static wxPropertyInfo _propertyInfo##name( first, class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxAny() ); - -// ---------------------------------------------------------------------------- -// Implementation Helper for Simple Properties -// ---------------------------------------------------------------------------- - -#define wxIMPLEMENT_PROPERTY(name, type) \ -private: \ - type m_##name; \ -public: \ - void Set##name( type const & p) { m_##name = p; } \ - type const & Get##name() const { return m_##name; } - -#endif // wxUSE_EXTENDED_RTTI -#endif // _XTIPROP_H_ diff --git a/Source/3rd Party/wx/include/wx/xtistrm.h b/Source/3rd Party/wx/include/wx/xtistrm.h deleted file mode 100644 index 0621ead1e..000000000 --- a/Source/3rd Party/wx/include/wx/xtistrm.h +++ /dev/null @@ -1,408 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtistrm.h -// Purpose: streaming runtime metadata information (extended class info) -// Author: Stefan Csomor -// Modified by: -// Created: 27/07/03 -// Copyright: (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_XTISTRMH__ -#define _WX_XTISTRMH__ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/object.h" - -const int wxInvalidObjectID = -2; -const int wxNullObjectID = -3; - -// Filer contains the interfaces for streaming objects in and out of XML, -// rendering them either to objects in memory, or to code. Note: We -// consider the process of generating code to be one of *depersisting* the -// object from xml, *not* of persisting the object to code from an object -// in memory. This distinction can be confusing, and should be kept -// in mind when looking at the property streamers and callback interfaces -// listed below. - - -// ---------------------------------------------------------------------------- -// wxObjectWriterCallback -// -// This class will be asked during the streaming-out process about every single -// property or object instance. It can veto streaming out by returning false -// or modify the value before it is streamed-out. -// ---------------------------------------------------------------------------- - -/* - class WXDLLIMPEXP_BASE wxClassInfo; - class WXDLLIMPEXP_BASE wxAnyList; - class WXDLLIMPEXP_BASE wxPropertyInfo; - class WXDLLIMPEXP_BASE wxAny; - class WXDLLIMPEXP_BASE wxHandlerInfo; - */ - -class WXDLLIMPEXP_BASE wxObjectWriter; -class WXDLLIMPEXP_BASE wxObjectReader; - -class WXDLLIMPEXP_BASE wxObjectWriterCallback -{ -public: - virtual ~wxObjectWriterCallback() {} - - // will be called before an object is written, may veto by returning false - virtual bool BeforeWriteObject( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxClassInfo *WXUNUSED(classInfo), - const wxStringToAnyHashMap &WXUNUSED(metadata)) - { return true; } - - // will be called after this object has been written, may be - // needed for adjusting stacks - virtual void AfterWriteObject( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxClassInfo *WXUNUSED(classInfo) ) - {} - - // will be called before a property gets written, may change the value, - // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord ) - // or veto writing that property at all by returning false - virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxPropertyInfo *WXUNUSED(propInfo), - const wxAny &WXUNUSED(value) ) - { return true; } - - // will be called before a property gets written, may change the value, - // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord ) - // or veto writing that property at all by returning false - virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxPropertyInfo *WXUNUSED(propInfo), - const wxAnyList &WXUNUSED(value) ) - { return true; } - - // will be called after a property has been written out, may be needed - // for adjusting stacks - virtual void AfterWriteProperty( wxObjectWriter *WXUNUSED(writer), - const wxPropertyInfo *WXUNUSED(propInfo) ) - {} - - // will be called before this delegate gets written - virtual bool BeforeWriteDelegate( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxClassInfo* WXUNUSED(classInfo), - const wxPropertyInfo *WXUNUSED(propInfo), - const wxObject *&WXUNUSED(eventSink), - const wxHandlerInfo* &WXUNUSED(handlerInfo) ) - { return true; } - - virtual void AfterWriteDelegate( wxObjectWriter *WXUNUSED(writer), - const wxObject *WXUNUSED(object), - const wxClassInfo* WXUNUSED(classInfo), - const wxPropertyInfo *WXUNUSED(propInfo), - const wxObject *&WXUNUSED(eventSink), - const wxHandlerInfo* &WXUNUSED(handlerInfo) ) - { } -}; - -class WXDLLIMPEXP_BASE wxObjectWriterFunctor: public wxObjectFunctor -{ -}; - -class WXDLLIMPEXP_BASE wxObjectWriter: public wxObject -{ - friend class wxObjectWriterFunctor; -public: - wxObjectWriter(); - virtual ~wxObjectWriter(); - - // with this call you start writing out a new top-level object - void WriteObject(const wxObject *object, const wxClassInfo *classInfo, - wxObjectWriterCallback *writercallback, const wxString &name, - const wxStringToAnyHashMap &metadata); - - // Managing the object identity table a.k.a context - // - // these methods make sure that no object gets written twice, - // because sometimes multiple calls to the WriteObject will be - // made without wanting to have duplicate objects written, the - // object identity table will be reset manually - virtual void ClearObjectContext(); - - // gets the object Id for a passed in object in the context - int GetObjectID(const wxObject *obj); - - // returns true if this object has already been written in this context - bool IsObjectKnown( const wxObject *obj ); - - // - // streaming callbacks - // - // these callbacks really write out the values in the stream format - - // begins writing out a new toplevel entry which has the indicated unique name - virtual void DoBeginWriteTopLevelEntry( const wxString &name ) = 0; - - // ends writing out a new toplevel entry which has the indicated unique name - virtual void DoEndWriteTopLevelEntry( const wxString &name ) = 0; - - // start of writing an object having the passed in ID - virtual void DoBeginWriteObject(const wxObject *object, const wxClassInfo *classInfo, - int objectID, const wxStringToAnyHashMap &metadata ) = 0; - - // end of writing an toplevel object name param is used for unique - // identification within the container - virtual void DoEndWriteObject(const wxObject *object, - const wxClassInfo *classInfo, int objectID ) = 0; - - // writes a simple property in the stream format - virtual void DoWriteSimpleType( const wxAny &value ) = 0; - - // start of writing a complex property into the stream ( - virtual void DoBeginWriteProperty( const wxPropertyInfo *propInfo ) = 0; - - // end of writing a complex property into the stream - virtual void DoEndWriteProperty( const wxPropertyInfo *propInfo ) = 0; - - virtual void DoBeginWriteElement() = 0; - virtual void DoEndWriteElement() = 0; - // insert an object reference to an already written object - virtual void DoWriteRepeatedObject( int objectID ) = 0; - - // insert a null reference - virtual void DoWriteNullObject() = 0; - - // writes a delegate in the stream format - virtual void DoWriteDelegate( const wxObject *object, const wxClassInfo* classInfo, - const wxPropertyInfo *propInfo, const wxObject *eventSink, - int sinkObjectID, const wxClassInfo* eventSinkClassInfo, - const wxHandlerInfo* handlerIndo ) = 0; - - void WriteObject(const wxObject *object, const wxClassInfo *classInfo, - wxObjectWriterCallback *writercallback, bool isEmbedded, const wxStringToAnyHashMap &metadata ); - -protected: - struct wxObjectWriterInternal; - wxObjectWriterInternal* m_data; - - struct wxObjectWriterInternalPropertiesData; - - void WriteAllProperties( const wxObject * obj, const wxClassInfo* ci, - wxObjectWriterCallback *writercallback, - wxObjectWriterInternalPropertiesData * data ); - - void WriteOneProperty( const wxObject *obj, const wxClassInfo* ci, - const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback, - wxObjectWriterInternalPropertiesData *data ); - - - void FindConnectEntry(const wxEvtHandler * evSource, - const wxEventSourceTypeInfo* dti, const wxObject* &sink, - const wxHandlerInfo *&handler); -}; - - -/* -Streaming callbacks for depersisting XML to code, or running objects -*/ - -class WXDLLIMPEXP_BASE wxObjectReaderCallback; - -/* -wxObjectReader handles streaming in a class from a arbitrary format. -While walking through it issues calls out to interfaces to readercallback -the guts from the underlying storage format. -*/ - -class WXDLLIMPEXP_BASE wxObjectReader: public wxObject -{ -public: - wxObjectReader(); - virtual ~wxObjectReader(); - - // the only thing wxObjectReader knows about is the class info by object ID - wxClassInfo *GetObjectClassInfo(int objectID); - bool HasObjectClassInfo( int objectID ); - void SetObjectClassInfo(int objectID, wxClassInfo* classInfo); - - // Reads the component the reader is pointed at from the underlying format. - // The return value is the root object ID, which can - // then be used to ask the depersister about that object - // if there was a problem you will get back wxInvalidObjectID and the current - // error log will carry the problems encoutered - virtual int ReadObject( const wxString &name, wxObjectReaderCallback *readercallback ) = 0; - -private: - struct wxObjectReaderInternal; - wxObjectReaderInternal *m_data; -}; - -// This abstract class matches the allocate-init/create model of creation of objects. -// At runtime, these will create actual instances, and manipulate them. -// When generating code, these will just create statements of C++ -// code to create the objects. - -class WXDLLIMPEXP_BASE wxObjectReaderCallback -{ -public: - virtual ~wxObjectReaderCallback() {} - - // allocate the new object on the heap, that object will have the passed in ID - virtual void AllocateObject(int objectID, wxClassInfo *classInfo, - wxStringToAnyHashMap &metadata) = 0; - - // initialize the already allocated object having the ID objectID with the Create method - // creation parameters which are objects are having their Ids passed in objectIDValues - // having objectId <> wxInvalidObjectID - - virtual void CreateObject(int objectID, - const wxClassInfo *classInfo, - int paramCount, - wxAny *VariantValues, - int *objectIDValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &metadata) = 0; - - // construct the new object on the heap, that object will have the passed in ID - // (for objects that don't support allocate-create type of creation) - // creation parameters which are objects are having their Ids passed in - // objectIDValues having objectId <> wxInvalidObjectID - - virtual void ConstructObject(int objectID, - const wxClassInfo *classInfo, - int paramCount, - wxAny *VariantValues, - int *objectIDValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &metadata) = 0; - - // destroy the heap-allocated object having the ID objectID, this may be used - // if an object is embedded in another object and set via value semantics, - // so the intermediate object can be destroyed after safely - virtual void DestroyObject(int objectID, wxClassInfo *classInfo) = 0; - - // set the corresponding property - virtual void SetProperty(int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - const wxAny &VariantValue) = 0; - - // sets the corresponding property (value is an object) - virtual void SetPropertyAsObject(int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - int valueObjectId) = 0; - - // adds an element to a property collection - virtual void AddToPropertyCollection( int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - const wxAny &VariantValue) = 0; - - // sets the corresponding property (value is an object) - virtual void AddToPropertyCollectionAsObject(int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - int valueObjectId) = 0; - - // sets the corresponding event handler - virtual void SetConnect(int EventSourceObjectID, - const wxClassInfo *EventSourceClassInfo, - const wxPropertyInfo *delegateInfo, - const wxClassInfo *EventSinkClassInfo, - const wxHandlerInfo* handlerInfo, - int EventSinkObjectID ) = 0; -}; - -/* -wxObjectRuntimeReaderCallback implements the callbacks that will bring back -an object into a life memory instance -*/ - -class WXDLLIMPEXP_BASE wxObjectRuntimeReaderCallback: public wxObjectReaderCallback -{ - struct wxObjectRuntimeReaderCallbackInternal; - wxObjectRuntimeReaderCallbackInternal * m_data; - -public: - wxObjectRuntimeReaderCallback(); - virtual ~wxObjectRuntimeReaderCallback(); - - // returns the object having the corresponding ID fully constructed - wxObject *GetObject(int objectID); - - // allocate the new object on the heap, that object will have the passed in ID - virtual void AllocateObject(int objectID, wxClassInfo *classInfo, - wxStringToAnyHashMap &metadata); - - // initialize the already allocated object having the ID objectID with - // the Create method creation parameters which are objects are having - // their Ids passed in objectIDValues having objectId <> wxInvalidObjectID - - virtual void CreateObject(int objectID, - const wxClassInfo *classInfo, - int paramCount, - wxAny *VariantValues, - int *objectIDValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &metadata - ); - - // construct the new object on the heap, that object will have the - // passed in ID (for objects that don't support allocate-create type of - // creation) creation parameters which are objects are having their Ids - // passed in objectIDValues having objectId <> wxInvalidObjectID - - virtual void ConstructObject(int objectID, - const wxClassInfo *classInfo, - int paramCount, - wxAny *VariantValues, - int *objectIDValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &metadata); - - // destroy the heap-allocated object having the ID objectID, this may be - // used if an object is embedded in another object and set via value semantics, - // so the intermediate object can be destroyed after safely - virtual void DestroyObject(int objectID, wxClassInfo *classInfo); - - // set the corresponding property - virtual void SetProperty(int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - const wxAny &variantValue); - - // sets the corresponding property (value is an object) - virtual void SetPropertyAsObject(int objectId, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - int valueObjectId); - - // adds an element to a property collection - virtual void AddToPropertyCollection( int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - const wxAny &VariantValue); - - // sets the corresponding property (value is an object) - virtual void AddToPropertyCollectionAsObject(int objectID, - const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - int valueObjectId); - - // sets the corresponding event handler - virtual void SetConnect(int eventSourceObjectID, - const wxClassInfo *eventSourceClassInfo, - const wxPropertyInfo *delegateInfo, - const wxClassInfo *eventSinkClassInfo, - const wxHandlerInfo* handlerInfo, - int eventSinkObjectID ); -}; - -#endif // wxUSE_EXTENDED_RTTI - -#endif diff --git a/Source/3rd Party/wx/include/wx/xtitypes.h b/Source/3rd Party/wx/include/wx/xtitypes.h deleted file mode 100644 index afd5c07b4..000000000 --- a/Source/3rd Party/wx/include/wx/xtitypes.h +++ /dev/null @@ -1,532 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtitypes.h -// Purpose: enum, set, basic types support -// Author: Stefan Csomor -// Modified by: Francesco Montorsi -// Created: 27/07/03 -// Copyright: (c) 1997 Julian Smart -// (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _XTITYPES_H_ -#define _XTITYPES_H_ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/string.h" -#include "wx/hashmap.h" -#include "wx/arrstr.h" -#include "wx/flags.h" -#include "wx/intl.h" -#include "wx/log.h" -#include - -class WXDLLIMPEXP_BASE wxClassInfo; - -// ---------------------------------------------------------------------------- -// Enum Support -// -// In the header files XTI requires no change from pure c++ code, however in the -// implementation, an enum needs to be enumerated eg: -// -// wxBEGIN_ENUM( wxFlavor ) -// wxENUM_MEMBER( Vanilla ) -// wxENUM_MEMBER( Chocolate ) -// wxENUM_MEMBER( Strawberry ) -// wxEND_ENUM( wxFlavor ) -// ---------------------------------------------------------------------------- - -struct WXDLLIMPEXP_BASE wxEnumMemberData -{ - const wxChar* m_name; - int m_value; -}; - -class WXDLLIMPEXP_BASE wxEnumData -{ -public: - wxEnumData( wxEnumMemberData* data ); - - // returns true if the member has been found and sets the int value - // pointed to accordingly (if ptr != null ) - // if not found returns false, value left unchanged - bool HasEnumMemberValue( const wxChar *name, int *value = NULL ) const; - - // returns the value of the member, if not found in debug mode an - // assert is issued, in release 0 is returned - int GetEnumMemberValue(const wxChar *name ) const; - - // returns the name of the enum member having the passed in value - // returns an emtpy string if not found - const wxChar *GetEnumMemberName(int value) const; - - // returns the number of members in this enum - int GetEnumCount() const { return m_count; } - - // returns the value of the nth member - int GetEnumMemberValueByIndex( int n ) const; - - // returns the value of the nth member - const wxChar *GetEnumMemberNameByIndex( int n ) const; - -private: - wxEnumMemberData *m_members; - int m_count; -}; - -#define wxBEGIN_ENUM( e ) \ - wxEnumMemberData s_enumDataMembers##e[] = { - -#define wxENUM_MEMBER( v ) { wxT(#v), v }, - -#define wxEND_ENUM( e ) \ - { NULL, 0 } }; \ - wxEnumData s_enumData##e( s_enumDataMembers##e ); \ - wxEnumData *wxGetEnumData(e) { return &s_enumData##e; } \ - template<> void wxStringReadValue(const wxString& s, e &data ) \ - { data = (e) s_enumData##e.GetEnumMemberValue(s.c_str()); } \ - template<> void wxStringWriteValue(wxString &s, const e &data ) \ - { s = s_enumData##e.GetEnumMemberName((int)data); } \ - void FromLong##e( long data, wxAny& result ) \ - { result = wxAny((e)data); } \ - void ToLong##e( const wxAny& data, long &result ) \ - { result = (long) (data).As(static_cast(NULL)); } \ - \ - wxTO_STRING_IMP( e ) \ - wxFROM_STRING_IMP( e ) \ - wxEnumTypeInfo s_typeInfo##e(wxT_ENUM, &s_enumData##e, \ - &wxTO_STRING( e ), &wxFROM_STRING( e ), &ToLong##e, \ - &FromLong##e, typeid(e).name() ); - - -// ---------------------------------------------------------------------------- -// Set Support -// -// in the header : -// -// enum wxFlavor -// { -// Vanilla, -// Chocolate, -// Strawberry, -// }; -// -// typedef wxBitset wxCoupe; -// -// in the implementation file : -// -// wxBEGIN_ENUM( wxFlavor ) -// wxENUM_MEMBER( Vanilla ) -// wxENUM_MEMBER( Chocolate ) -// wxENUM_MEMBER( Strawberry ) -// wxEND_ENUM( wxFlavor ) -// -// wxIMPLEMENT_SET_STREAMING( wxCoupe, wxFlavor ) -// -// implementation note: no partial specialization for streaming, but a delegation -// to a different class -// -// ---------------------------------------------------------------------------- - -void WXDLLIMPEXP_BASE wxSetStringToArray( const wxString &s, wxArrayString &array ); - -template -void wxSetFromString(const wxString &s, wxBitset &data ) -{ - wxEnumData* edata = wxGetEnumData((e) 0); - data.reset(); - - wxArrayString array; - wxSetStringToArray( s, array ); - wxString flag; - for ( int i = 0; i < array.Count(); ++i ) - { - flag = array[i]; - int ivalue; - if ( edata->HasEnumMemberValue( flag.c_str(), &ivalue ) ) - { - data.set( (e) ivalue ); - } - } -} - -template -void wxSetToString( wxString &s, const wxBitset &data ) -{ - wxEnumData* edata = wxGetEnumData((e) 0); - int count = edata->GetEnumCount(); - int i; - s.Clear(); - for ( i = 0; i < count; i++ ) - { - e value = (e) edata->GetEnumMemberValueByIndex(i); - if ( data.test( value ) ) - { - // this could also be done by the templated calls - if ( !s.empty() ) - s += wxT("|"); - s += edata->GetEnumMemberNameByIndex(i); - } - } -} - -#define wxIMPLEMENT_SET_STREAMING(SetName,e) \ - template<> void wxStringReadValue(const wxString &s, wxBitset &data ) \ - { wxSetFromString( s, data ); } \ - template<> void wxStringWriteValue( wxString &s, const wxBitset &data ) \ - { wxSetToString( s, data ); } \ - void FromLong##SetName( long data, wxAny& result ) \ - { result = wxAny(SetName((unsigned long)data)); } \ - void ToLong##SetName( const wxAny& data, long &result ) \ - { result = (long) (data).As(static_cast(NULL)).to_ulong(); } \ - wxTO_STRING_IMP( SetName ) \ - wxFROM_STRING_IMP( SetName ) \ - wxEnumTypeInfo s_typeInfo##SetName(wxT_SET, &s_enumData##e, \ - &wxTO_STRING( SetName ), &wxFROM_STRING( SetName ), \ - &ToLong##SetName, &FromLong##SetName, typeid(SetName).name() ); - -template -void wxFlagsFromString(const wxString &s, e &data ) -{ - wxEnumData* edata = wxGetEnumData((e*) 0); - data.m_data = 0; - - wxArrayString array; - wxSetStringToArray( s, array ); - wxString flag; - for ( size_t i = 0; i < array.Count(); ++i ) - { - flag = array[i]; - int ivalue; - if ( edata->HasEnumMemberValue( flag.c_str(), &ivalue ) ) - { - data.m_data |= ivalue; - } - } -} - -template -void wxFlagsToString( wxString &s, const e& data ) -{ - wxEnumData* edata = wxGetEnumData((e*) 0); - int count = edata->GetEnumCount(); - int i; - s.Clear(); - long dataValue = data.m_data; - for ( i = 0; i < count; i++ ) - { - int value = edata->GetEnumMemberValueByIndex(i); - // make this to allow for multi-bit constants to work - if ( value && ( dataValue & value ) == value ) - { - // clear the flags we just set - dataValue &= ~value; - // this could also be done by the templated calls - if ( !s.empty() ) - s +=wxT("|"); - s += edata->GetEnumMemberNameByIndex(i); - } - } -} - -#define wxBEGIN_FLAGS( e ) \ - wxEnumMemberData s_enumDataMembers##e[] = { - -#define wxFLAGS_MEMBER( v ) { wxT(#v), static_cast(v) }, - -#define wxEND_FLAGS( e ) \ - { NULL, 0 } }; \ - wxEnumData s_enumData##e( s_enumDataMembers##e ); \ - wxEnumData *wxGetEnumData(e*) { return &s_enumData##e; } \ - template<> void wxStringReadValue(const wxString &s, e &data ) \ - { wxFlagsFromString( s, data ); } \ - template<> void wxStringWriteValue( wxString &s, const e& data ) \ - { wxFlagsToString( s, data ); } \ - void FromLong##e( long data, wxAny& result ) \ - { result = wxAny(e(data)); } \ - void ToLong##e( const wxAny& data, long &result ) \ - { result = (long) (data).As(static_cast(NULL)).m_data; } \ - wxTO_STRING_IMP( e ) \ - wxFROM_STRING_IMP( e ) \ - wxEnumTypeInfo s_typeInfo##e(wxT_SET, &s_enumData##e, \ - &wxTO_STRING( e ), &wxFROM_STRING( e ), &ToLong##e, \ - &FromLong##e, typeid(e).name() ); - -// ---------------------------------------------------------------------------- -// Type Information -// ---------------------------------------------------------------------------- - -// All data exposed by the RTTI is characterized using the following classes. -// The first characterization is done by wxTypeKind. All enums up to and including -// wxT_CUSTOM represent so called simple types. These cannot be divided any further. -// They can be converted to and from wxStrings, that's all. -// Other wxTypeKinds can instead be splitted recursively into smaller parts until -// the simple types are reached. - -enum wxTypeKind -{ - wxT_VOID = 0, // unknown type - wxT_BOOL, - wxT_CHAR, - wxT_UCHAR, - wxT_INT, - wxT_UINT, - wxT_LONG, - wxT_ULONG, - wxT_LONGLONG, - wxT_ULONGLONG, - wxT_FLOAT, - wxT_DOUBLE, - wxT_STRING, // must be wxString - wxT_SET, // must be wxBitset<> template - wxT_ENUM, - wxT_CUSTOM, // user defined type (e.g. wxPoint) - - wxT_LAST_SIMPLE_TYPE_KIND = wxT_CUSTOM, - - wxT_OBJECT_PTR, // object reference - wxT_OBJECT, // embedded object - wxT_COLLECTION, // collection - - wxT_DELEGATE, // for connecting against an event source - - wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging -}; - -class WXDLLIMPEXP_BASE wxAny; -class WXDLLIMPEXP_BASE wxTypeInfo; - -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxTypeInfo*, wxTypeInfoMap, class WXDLLIMPEXP_BASE ); - -class WXDLLIMPEXP_BASE wxTypeInfo -{ -public: - typedef void (*wxVariant2StringFnc)( const wxAny& data, wxString &result ); - typedef void (*wxString2VariantFnc)( const wxString& data, wxAny &result ); - - wxTypeInfo(wxTypeKind kind, - wxVariant2StringFnc to = NULL, wxString2VariantFnc from = NULL, - const wxString &name = wxEmptyString): - m_toString(to), m_fromString(from), m_kind(kind), m_name(name) - { - Register(); - } -#if 0 // wxUSE_UNICODE - wxTypeInfo(wxTypeKind kind, - wxVariant2StringFnc to, wxString2VariantFnc from, - const char *name): - m_toString(to), m_fromString(from), m_kind(kind), - m_name(wxString::FromAscii(name)) - { - Register(); - } -#endif - - virtual ~wxTypeInfo() - { - Unregister(); - } - - // return the kind of this type (wxT_... constants) - wxTypeKind GetKind() const { return m_kind; } - - // returns the unique name of this type - const wxString& GetTypeName() const { return m_name; } - - // is this type a delegate type - bool IsDelegateType() const { return m_kind == wxT_DELEGATE; } - - // is this type a custom type - bool IsCustomType() const { return m_kind == wxT_CUSTOM; } - - // is this type an object type - bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR; } - - // can the content of this type be converted to and from strings ? - bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL; } - - // convert a wxAny holding data of this type into a string - void ConvertToString( const wxAny& data, wxString &result ) const - { - if ( m_toString ) - (*m_toString)( data, result ); - else - wxLogError( wxGetTranslation(wxT("String conversions not supported")) ); - } - - // convert a string into a wxAny holding the corresponding data in this type - void ConvertFromString( const wxString& data, wxAny &result ) const - { - if( m_fromString ) - (*m_fromString)( data, result ); - else - wxLogError( wxGetTranslation(wxT("String conversions not supported")) ); - } - - // statics: - - // looks for the corresponding type, will return NULL if not found - static wxTypeInfo *FindType( const wxString& typeName ); -private: - void Register(); - void Unregister(); - - wxVariant2StringFnc m_toString; - wxString2VariantFnc m_fromString; - - wxTypeKind m_kind; - wxString m_name; - - // the static list of all types we know about - static wxTypeInfoMap* ms_typeTable; -}; - -class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo -{ -public: - wxBuiltInTypeInfo( wxTypeKind kind, wxVariant2StringFnc to = NULL, - wxString2VariantFnc from = NULL, - const wxString &name = wxEmptyString ) : - wxTypeInfo( kind, to, from, name ) - { wxASSERT_MSG( GetKind() < wxT_SET, wxT("Illegal Kind for Base Type") ); } -}; - -class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo -{ -public: - wxCustomTypeInfo( const wxString &name, wxVariant2StringFnc to, - wxString2VariantFnc from ) : - wxTypeInfo( wxT_CUSTOM, to, from, name ) - {} -}; - -class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo -{ -public: - typedef void (*converterToLong_t)( const wxAny& data, long &result ); - typedef void (*converterFromLong_t)( long data, wxAny &result ); - - wxEnumTypeInfo( wxTypeKind kind, wxEnumData* enumInfo, wxVariant2StringFnc to, - wxString2VariantFnc from, converterToLong_t toLong, - converterFromLong_t fromLong, const wxString &name ) : - wxTypeInfo( kind, to, from, name ), m_toLong( toLong ), m_fromLong( fromLong ) - { - wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET, - wxT("Illegal Kind for Enum Type")); - m_enumInfo = enumInfo; - } - - const wxEnumData* GetEnumData() const { return m_enumInfo; } - - // convert a wxAny holding data of this type into a long - void ConvertToLong( const wxAny& data, long &result ) const - { - if( m_toLong ) - (*m_toLong)( data, result ); - else - wxLogError( wxGetTranslation(wxT("Long Conversions not supported")) ); - } - - // convert a long into a wxAny holding the corresponding data in this type - void ConvertFromLong( long data, wxAny &result ) const - { - if( m_fromLong ) - (*m_fromLong)( data, result ); - else - wxLogError( wxGetTranslation(wxT("Long Conversions not supported")) ); - } - -private: - converterToLong_t m_toLong; - converterFromLong_t m_fromLong; - - wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET -}; - -class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo -{ -public: - wxClassTypeInfo( wxTypeKind kind, wxClassInfo* classInfo, - wxVariant2StringFnc to = NULL, wxString2VariantFnc from = NULL, - const wxString &name = wxEmptyString); - - const wxClassInfo *GetClassInfo() const { return m_classInfo; } - -private: - wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL -}; - -class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo -{ -public: - wxCollectionTypeInfo( const wxString &elementName, wxVariant2StringFnc to, - wxString2VariantFnc from , const wxString &name) : - wxTypeInfo( wxT_COLLECTION, to, from, name ) - { m_elementTypeName = elementName; m_elementType = NULL; } - - const wxTypeInfo* GetElementType() const - { - if ( m_elementType == NULL ) - m_elementType = wxTypeInfo::FindType( m_elementTypeName ); - return m_elementType; - } - -private: - mutable wxTypeInfo * m_elementType; - wxString m_elementTypeName; -}; - -class WXDLLIMPEXP_BASE wxEventSourceTypeInfo : public wxTypeInfo -{ -public: - wxEventSourceTypeInfo( int eventType, wxClassInfo* eventClass, - wxVariant2StringFnc to = NULL, - wxString2VariantFnc from = NULL ); - wxEventSourceTypeInfo( int eventType, int lastEventType, wxClassInfo* eventClass, - wxVariant2StringFnc to = NULL, wxString2VariantFnc from = NULL ); - - int GetEventType() const { return m_eventType; } - int GetLastEventType() const { return m_lastEventType; } - const wxClassInfo* GetEventClass() const { return m_eventClass; } - -private: - const wxClassInfo *m_eventClass; // (extended will merge into classinfo) - int m_eventType; - int m_lastEventType; -}; - -template const wxTypeInfo* wxGetTypeInfo( T * ) - { return wxTypeInfo::FindType(typeid(T).name()); } - -// this macro is for usage with custom, non-object derived classes and structs, -// wxPoint is such a custom type - -#if wxUSE_FUNC_TEMPLATE_POINTER - #define wxCUSTOM_TYPE_INFO( e, toString, fromString ) \ - wxCustomTypeInfo s_typeInfo##e(typeid(e).name(), &toString, &fromString); -#else - #define wxCUSTOM_TYPE_INFO( e, toString, fromString ) \ - void ToString##e( const wxAny& data, wxString &result ) \ - { toString(data, result); } \ - void FromString##e( const wxString& data, wxAny &result ) \ - { fromString(data, result); } \ - wxCustomTypeInfo s_typeInfo##e(typeid(e).name(), \ - &ToString##e, &FromString##e); -#endif - -#define wxCOLLECTION_TYPE_INFO( element, collection ) \ - wxCollectionTypeInfo s_typeInfo##collection( typeid(element).name(), \ - NULL, NULL, typeid(collection).name() ); - -// sometimes a compiler invents specializations that are nowhere called, -// use this macro to satisfy the refs, currently we don't have to play -// tricks, but if we will have to according to the compiler, we will use -// that macro for that - -#define wxILLEGAL_TYPE_SPECIALIZATION( a ) - -#endif // wxUSE_EXTENDED_RTTI -#endif // _XTITYPES_H_ diff --git a/Source/3rd Party/wx/include/wx/xtixml.h b/Source/3rd Party/wx/include/wx/xtixml.h deleted file mode 100644 index 100e0653e..000000000 --- a/Source/3rd Party/wx/include/wx/xtixml.h +++ /dev/null @@ -1,119 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/xtixml.h -// Purpose: xml streaming runtime metadata information (extended class info) -// Author: Stefan Csomor -// Modified by: -// Created: 27/07/03 -// Copyright: (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_XTIXMLH__ -#define _WX_XTIXMLH__ - -#include "wx/defs.h" - -#if wxUSE_EXTENDED_RTTI - -#include "wx/string.h" -#include "wx/xtistrm.h" - -/* -class WXDLLIMPEXP_XML wxXmlNode; -class WXDLLIMPEXP_BASE wxPropertyInfo; -class WXDLLIMPEXP_BASE wxObject; -class WXDLLIMPEXP_BASE wxClassInfo; -class WXDLLIMPEXP_BASE wxAnyList; -class WXDLLIMPEXP_BASE wxHandlerInfo; -class WXDLLIMPEXP_BASE wxObjectWriterCallback; -*/ - -class WXDLLIMPEXP_XML wxObjectXmlWriter: public wxObjectWriter -{ -public: - - wxObjectXmlWriter( wxXmlNode * parent ); - virtual ~wxObjectXmlWriter(); - - // - // streaming callbacks - // - // these callbacks really write out the values in the stream format - // - - // - // streaming callbacks - // - // these callbacks really write out the values in the stream format - - // begins writing out a new toplevel entry which has the indicated unique name - virtual void DoBeginWriteTopLevelEntry( const wxString &name ); - - // ends writing out a new toplevel entry which has the indicated unique name - virtual void DoEndWriteTopLevelEntry( const wxString &name ); - - // start of writing an object having the passed in ID - virtual void DoBeginWriteObject(const wxObject *object, - const wxClassInfo *classInfo, int objectID, const wxStringToAnyHashMap &metadata ); - - // end of writing an toplevel object name param is used for unique - // identification within the container - virtual void DoEndWriteObject(const wxObject *object, - const wxClassInfo *classInfo, int objectID ); - - // writes a simple property in the stream format - virtual void DoWriteSimpleType( const wxAny &value ); - - // start of writing a complex property into the stream ( - virtual void DoBeginWriteProperty( const wxPropertyInfo *propInfo ); - - // end of writing a complex property into the stream - virtual void DoEndWriteProperty( const wxPropertyInfo *propInfo ); - - virtual void DoBeginWriteElement(); - virtual void DoEndWriteElement(); - - // insert an object reference to an already written object - virtual void DoWriteRepeatedObject( int objectID ); - - // insert a null reference - virtual void DoWriteNullObject(); - - // writes a delegate in the stream format - virtual void DoWriteDelegate( const wxObject *object, - const wxClassInfo* classInfo, const wxPropertyInfo *propInfo, - const wxObject *eventSink, int sinkObjectID, - const wxClassInfo* eventSinkClassInfo, const wxHandlerInfo* handlerIndo ); - -private: - struct wxObjectXmlWriterInternal; - wxObjectXmlWriterInternal* m_data; -}; - -/* -wxObjectXmlReader handles streaming in a class from XML -*/ - -class WXDLLIMPEXP_XML wxObjectXmlReader: public wxObjectReader -{ -public: - wxObjectXmlReader(wxXmlNode *parent) { m_parent = parent; } - virtual ~wxObjectXmlReader() {} - - // Reads a component from XML. The return value is the root object ID, which can - // then be used to ask the readercallback about that object - - virtual int ReadObject( const wxString &name, wxObjectReaderCallback *readercallback ); - -private: - int ReadComponent(wxXmlNode *parent, wxObjectReaderCallback *callbacks); - - // read the content of this node (simple type) and return the corresponding value - wxAny ReadValue(wxXmlNode *Node, const wxTypeInfo *type ); - - wxXmlNode * m_parent; -}; - -#endif // wxUSE_EXTENDED_RTTI - -#endif diff --git a/Source/3rd Party/wx/include/wx/zipstrm.h b/Source/3rd Party/wx/include/wx/zipstrm.h index 9cc47afaf..572b88a9f 100644 --- a/Source/3rd Party/wx/include/wx/zipstrm.h +++ b/Source/3rd Party/wx/include/wx/zipstrm.h @@ -2,6 +2,7 @@ // Name: wx/zipstrm.h // Purpose: Streams for Zip files // Author: Mike Wetherell +// RCS-ID: $Id: zipstrm.h 53135 2008-04-12 02:31:04Z VZ $ // Copyright: (c) Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -345,9 +346,8 @@ private: int m_level; wxFileOffset m_offsetAdjustment; wxString m_Comment; - bool m_endrecWritten; - wxDECLARE_NO_COPY_CLASS(wxZipOutputStream); + DECLARE_NO_COPY_CLASS(wxZipOutputStream) }; @@ -445,7 +445,7 @@ private: friend class wxArchiveFSHandler; #endif - wxDECLARE_NO_COPY_CLASS(wxZipInputStream); + DECLARE_NO_COPY_CLASS(wxZipInputStream) }; diff --git a/Source/3rd Party/wx/include/wx/zstream.h b/Source/3rd Party/wx/include/wx/zstream.h index e43df73e6..cb7011d1f 100644 --- a/Source/3rd Party/wx/include/wx/zstream.h +++ b/Source/3rd Party/wx/include/wx/zstream.h @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: Mike Wetherell // Created: 11/07/98 +// RCS-ID: $Id: zstream.h 54688 2008-07-18 08:06:44Z MW $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,10 +16,9 @@ #if wxUSE_ZLIB && wxUSE_STREAMS #include "wx/stream.h" -#include "wx/versioninfo.h" // Compression level -enum wxZlibCompressionLevels { +enum { wxZ_DEFAULT_COMPRESSION = -1, wxZ_NO_COMPRESSION = 0, wxZ_BEST_SPEED = 1, @@ -26,7 +26,10 @@ enum wxZlibCompressionLevels { }; // Flags -enum wxZLibFlags { +enum { +#if WXWIN_COMPATIBILITY_2_4 + wxZLIB_24COMPATIBLE = 4, // read v2.4.x data without error +#endif wxZLIB_NO_HEADER = 0, // raw deflate stream, no header or checksum wxZLIB_ZLIB = 1, // zlib header and checksum wxZLIB_GZIP = 2, // gzip header and checksum, requires zlib 1.2.1+ @@ -44,9 +47,6 @@ class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream { static bool CanHandleGZip(); - bool SetDictionary(const char *data, const size_t datalen); - bool SetDictionary(const wxMemoryBuffer &buf); - protected: size_t OnSysRead(void *buffer, size_t size); wxFileOffset OnSysTell() const { return m_pos; } @@ -59,8 +59,11 @@ class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream { unsigned char *m_z_buffer; struct z_stream_s *m_inflate; wxFileOffset m_pos; +#if WXWIN_COMPATIBILITY_2_4 + bool m_24compatibilty; +#endif - wxDECLARE_NO_COPY_CLASS(wxZlibInputStream); + DECLARE_NO_COPY_CLASS(wxZlibInputStream) }; class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream { @@ -75,9 +78,6 @@ class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream { static bool CanHandleGZip(); - bool SetDictionary(const char *data, const size_t datalen); - bool SetDictionary(const wxMemoryBuffer &buf); - protected: size_t OnSysWrite(const void *buffer, size_t size); wxFileOffset OnSysTell() const { return m_pos; } @@ -93,7 +93,7 @@ class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream { struct z_stream_s *m_deflate; wxFileOffset m_pos; - wxDECLARE_NO_COPY_CLASS(wxZlibOutputStream); + DECLARE_NO_COPY_CLASS(wxZlibOutputStream) }; class WXDLLIMPEXP_BASE wxZlibClassFactory: public wxFilterClassFactory @@ -125,11 +125,11 @@ public: wxFilterInputStream *NewStream(wxInputStream& stream) const { return new wxZlibInputStream(stream); } wxFilterOutputStream *NewStream(wxOutputStream& stream) const - { return new wxZlibOutputStream(stream, -1); } + { return new wxZlibOutputStream(stream, -1, wxZLIB_GZIP); } wxFilterInputStream *NewStream(wxInputStream *stream) const { return new wxZlibInputStream(stream); } wxFilterOutputStream *NewStream(wxOutputStream *stream) const - { return new wxZlibOutputStream(stream, -1); } + { return new wxZlibOutputStream(stream, -1, wxZLIB_GZIP); } const wxChar * const *GetProtocols(wxStreamProtocolType type = wxSTREAM_PROTOCOL) const; @@ -138,8 +138,6 @@ private: DECLARE_DYNAMIC_CLASS(wxGzipClassFactory) }; -WXDLLIMPEXP_BASE wxVersionInfo wxGetZlibVersionInfo(); - #endif // wxUSE_ZLIB && wxUSE_STREAMS diff --git a/Source/3rd Party/wx/src/common/accelcmn.cpp b/Source/3rd Party/wx/src/common/accelcmn.cpp deleted file mode 100644 index 003ecbc51..000000000 --- a/Source/3rd Party/wx/src/common/accelcmn.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/accelcmn.cpp -// Purpose: implementation of platform-independent wxAcceleratorEntry parts -// Author: Vadim Zeitlin -// Created: 2007-05-05 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ACCEL - -#ifndef WX_PRECOMP - #include "wx/accel.h" - #include "wx/string.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/crt.h" -#endif //WX_PRECOMP - -wxAcceleratorTable wxNullAcceleratorTable; - -// ============================================================================ -// wxAcceleratorEntry implementation -// ============================================================================ - -static const struct wxKeyName -{ - wxKeyCode code; - const char *name; -} wxKeyNames[] = -{ - { WXK_DELETE, wxTRANSLATE("DEL") }, - { WXK_DELETE, wxTRANSLATE("DELETE") }, - { WXK_BACK, wxTRANSLATE("BACK") }, - { WXK_INSERT, wxTRANSLATE("INS") }, - { WXK_INSERT, wxTRANSLATE("INSERT") }, - { WXK_RETURN, wxTRANSLATE("ENTER") }, - { WXK_RETURN, wxTRANSLATE("RETURN") }, - { WXK_PAGEUP, wxTRANSLATE("PGUP") }, - { WXK_PAGEDOWN, wxTRANSLATE("PGDN") }, - { WXK_LEFT, wxTRANSLATE("LEFT") }, - { WXK_RIGHT, wxTRANSLATE("RIGHT") }, - { WXK_UP, wxTRANSLATE("UP") }, - { WXK_DOWN, wxTRANSLATE("DOWN") }, - { WXK_HOME, wxTRANSLATE("HOME") }, - { WXK_END, wxTRANSLATE("END") }, - { WXK_SPACE, wxTRANSLATE("SPACE") }, - { WXK_TAB, wxTRANSLATE("TAB") }, - { WXK_ESCAPE, wxTRANSLATE("ESC") }, - { WXK_ESCAPE, wxTRANSLATE("ESCAPE") }, - { WXK_CANCEL, wxTRANSLATE("CANCEL") }, - { WXK_CLEAR, wxTRANSLATE("CLEAR") }, - { WXK_MENU, wxTRANSLATE("MENU") }, - { WXK_PAUSE, wxTRANSLATE("PAUSE") }, - { WXK_CAPITAL, wxTRANSLATE("CAPITAL") }, - { WXK_SELECT, wxTRANSLATE("SELECT") }, - { WXK_PRINT, wxTRANSLATE("PRINT") }, - { WXK_EXECUTE, wxTRANSLATE("EXECUTE") }, - { WXK_SNAPSHOT, wxTRANSLATE("SNAPSHOT") }, - { WXK_HELP, wxTRANSLATE("HELP") }, - { WXK_ADD, wxTRANSLATE("ADD") }, - { WXK_SEPARATOR, wxTRANSLATE("SEPARATOR") }, - { WXK_SUBTRACT, wxTRANSLATE("SUBTRACT") }, - { WXK_DECIMAL, wxTRANSLATE("DECIMAL") }, - { WXK_DIVIDE, wxTRANSLATE("DIVIDE") }, - { WXK_NUMLOCK, wxTRANSLATE("NUM_LOCK") }, - { WXK_SCROLL, wxTRANSLATE("SCROLL_LOCK") }, - { WXK_PAGEUP, wxTRANSLATE("PAGEUP") }, - { WXK_PAGEDOWN, wxTRANSLATE("PAGEDOWN") }, - { WXK_NUMPAD_SPACE, wxTRANSLATE("KP_SPACE") }, - { WXK_NUMPAD_TAB, wxTRANSLATE("KP_TAB") }, - { WXK_NUMPAD_ENTER, wxTRANSLATE("KP_ENTER") }, - { WXK_NUMPAD_HOME, wxTRANSLATE("KP_HOME") }, - { WXK_NUMPAD_LEFT, wxTRANSLATE("KP_LEFT") }, - { WXK_NUMPAD_UP, wxTRANSLATE("KP_UP") }, - { WXK_NUMPAD_RIGHT, wxTRANSLATE("KP_RIGHT") }, - { WXK_NUMPAD_DOWN, wxTRANSLATE("KP_DOWN") }, - { WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PRIOR") }, - { WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PAGEUP") }, - { WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_NEXT") }, - { WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_PAGEDOWN") }, - { WXK_NUMPAD_END, wxTRANSLATE("KP_END") }, - { WXK_NUMPAD_BEGIN, wxTRANSLATE("KP_BEGIN") }, - { WXK_NUMPAD_INSERT, wxTRANSLATE("KP_INSERT") }, - { WXK_NUMPAD_DELETE, wxTRANSLATE("KP_DELETE") }, - { WXK_NUMPAD_EQUAL, wxTRANSLATE("KP_EQUAL") }, - { WXK_NUMPAD_MULTIPLY, wxTRANSLATE("KP_MULTIPLY") }, - { WXK_NUMPAD_ADD, wxTRANSLATE("KP_ADD") }, - { WXK_NUMPAD_SEPARATOR, wxTRANSLATE("KP_SEPARATOR") }, - { WXK_NUMPAD_SUBTRACT, wxTRANSLATE("KP_SUBTRACT") }, - { WXK_NUMPAD_DECIMAL, wxTRANSLATE("KP_DECIMAL") }, - { WXK_NUMPAD_DIVIDE, wxTRANSLATE("KP_DIVIDE") }, - { WXK_WINDOWS_LEFT, wxTRANSLATE("WINDOWS_LEFT") }, - { WXK_WINDOWS_RIGHT, wxTRANSLATE("WINDOWS_RIGHT") }, - { WXK_WINDOWS_MENU, wxTRANSLATE("WINDOWS_MENU") }, - { WXK_COMMAND, wxTRANSLATE("COMMAND") }, -}; - -// return true if the 2 strings refer to the same accel -// -// as accels can be either translated or not, check for both possibilities and -// also compare case-insensitively as the key names case doesn't count -static inline bool CompareAccelString(const wxString& str, const char *accel) -{ - return str.CmpNoCase(accel) == 0 -#if wxUSE_INTL - || str.CmpNoCase(wxGetTranslation(accel)) == 0 -#endif - ; -} - -// return prefixCode+number if the string is of the form "" and -// 0 if it isn't -// -// first and last parameter specify the valid domain for "number" part -static int IsNumberedAccelKey(const wxString& str, - const char *prefix, - wxKeyCode prefixCode, - unsigned first, - unsigned last) -{ - const size_t lenPrefix = wxStrlen(prefix); - if ( !CompareAccelString(str.Left(lenPrefix), prefix) ) - return 0; - - unsigned long num; - if ( !str.Mid(lenPrefix).ToULong(&num) ) - return 0; - - if ( num < first || num > last ) - { - // this must be a mistake, chances that this is a valid name of another - // key are vanishingly small - wxLogDebug(wxT("Invalid key string \"%s\""), str.c_str()); - return 0; - } - - return prefixCode + num - first; -} - -/* static */ -bool -wxAcceleratorEntry::ParseAccel(const wxString& text, int *flagsOut, int *keyOut) -{ - // the parser won't like trailing spaces - wxString label = text; - label.Trim(true); - - // For compatibility with the old wx versions which accepted (and actually - // even required) a TAB character in the string passed to this function we - // ignore anything up to the first TAB. Notice however that the correct - // input consists of just the accelerator itself and nothing else, this is - // done for compatibility and compatibility only. - int posTab = label.Find(wxT('\t')); - if ( posTab == wxNOT_FOUND ) - posTab = 0; - else - posTab++; - - // parse the accelerator string - int accelFlags = wxACCEL_NORMAL; - wxString current; - for ( size_t n = (size_t)posTab; n < label.length(); n++ ) - { - if ( (label[n] == '+') || (label[n] == '-') ) - { - if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) - accelFlags |= wxACCEL_CTRL; - else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) - accelFlags |= wxACCEL_ALT; - else if ( CompareAccelString(current, wxTRANSLATE("shift")) ) - accelFlags |= wxACCEL_SHIFT; - else if ( CompareAccelString(current, wxTRANSLATE("rawctrl")) ) - accelFlags |= wxACCEL_RAW_CTRL; - else // not a recognized modifier name - { - // we may have "Ctrl-+", for example, but we still want to - // catch typos like "Crtl-A" so only give the warning if we - // have something before the current '+' or '-', else take - // it as a literal symbol - if ( current.empty() ) - { - current += label[n]; - - // skip clearing it below - continue; - } - else - { - wxLogDebug(wxT("Unknown accel modifier: '%s'"), - current.c_str()); - } - } - - current.clear(); - } - else // not special character - { - current += (wxChar) wxTolower(label[n]); - } - } - - int keyCode; - const size_t len = current.length(); - switch ( len ) - { - case 0: - wxLogDebug(wxT("No accel key found, accel string ignored.")); - return false; - - case 1: - // it's just a letter - keyCode = current[0U]; - - // if the key is used with any modifiers, make it an uppercase one - // because Ctrl-A and Ctrl-a are the same; but keep it as is if it's - // used alone as 'a' and 'A' are different - if ( accelFlags != wxACCEL_NORMAL ) - keyCode = wxToupper(keyCode); - break; - - default: - keyCode = IsNumberedAccelKey(current, wxTRANSLATE("F"), - WXK_F1, 1, 12); - if ( !keyCode ) - { - for ( size_t n = 0; n < WXSIZEOF(wxKeyNames); n++ ) - { - const wxKeyName& kn = wxKeyNames[n]; - if ( CompareAccelString(current, kn.name) ) - { - keyCode = kn.code; - break; - } - } - } - - if ( !keyCode ) - keyCode = IsNumberedAccelKey(current, wxTRANSLATE("KP_"), - WXK_NUMPAD0, 0, 9); - if ( !keyCode ) - keyCode = IsNumberedAccelKey(current, wxTRANSLATE("SPECIAL"), - WXK_SPECIAL1, 1, 20); - - if ( !keyCode ) - { - wxLogDebug(wxT("Unrecognized accel key '%s', accel string ignored."), - current.c_str()); - return false; - } - } - - - wxASSERT_MSG( keyCode, wxT("logic error: should have key code here") ); - - if ( flagsOut ) - *flagsOut = accelFlags; - if ( keyOut ) - *keyOut = keyCode; - - return true; -} - -/* static */ -wxAcceleratorEntry *wxAcceleratorEntry::Create(const wxString& str) -{ - const wxString accelStr = str.AfterFirst('\t'); - if ( accelStr.empty() ) - { - // It's ok to pass strings not containing any accelerators at all to - // this function, wxMenuItem code does it and we should just return - // NULL in this case. - return NULL; - } - - int flags, - keyCode; - if ( !ParseAccel(accelStr, &flags, &keyCode) ) - return NULL; - - return new wxAcceleratorEntry(flags, keyCode); -} - -bool wxAcceleratorEntry::FromString(const wxString& str) -{ - return ParseAccel(str, &m_flags, &m_keyCode); -} - -namespace -{ - -wxString PossiblyLocalize(const wxString& str, bool localize) -{ - return localize ? wxGetTranslation(str) : str; -} - -} - -wxString wxAcceleratorEntry::AsPossiblyLocalizedString(bool localized) const -{ - wxString text; - - int flags = GetFlags(); - if ( flags & wxACCEL_ALT ) - text += PossiblyLocalize(wxTRANSLATE("Alt+"), localized); - if ( flags & wxACCEL_CTRL ) - text += PossiblyLocalize(wxTRANSLATE("Ctrl+"), localized); - if ( flags & wxACCEL_SHIFT ) - text += PossiblyLocalize(wxTRANSLATE("Shift+"), localized); -#if defined(__WXMAC__) || defined(__WXCOCOA__) - if ( flags & wxACCEL_RAW_CTRL ) - text += PossiblyLocalize(wxTRANSLATE("RawCtrl+"), localized); -#endif - - const int code = GetKeyCode(); - - if ( code >= WXK_F1 && code <= WXK_F12 ) - text << PossiblyLocalize(wxTRANSLATE("F"), localized) - << code - WXK_F1 + 1; - else if ( code >= WXK_NUMPAD0 && code <= WXK_NUMPAD9 ) - text << PossiblyLocalize(wxTRANSLATE("KP_"), localized) - << code - WXK_NUMPAD0; - else if ( code >= WXK_SPECIAL1 && code <= WXK_SPECIAL20 ) - text << PossiblyLocalize(wxTRANSLATE("SPECIAL"), localized) - << code - WXK_SPECIAL1 + 1; - else // check the named keys - { - size_t n; - for ( n = 0; n < WXSIZEOF(wxKeyNames); n++ ) - { - const wxKeyName& kn = wxKeyNames[n]; - if ( code == kn.code ) - { - text << PossiblyLocalize(kn.name, localized); - break; - } - } - - if ( n == WXSIZEOF(wxKeyNames) ) - { - // must be a simple key - if ( -#if !wxUSE_UNICODE - // we can't call wxIsalnum() for non-ASCII characters in ASCII - // build as they're only defined for the ASCII range (or EOF) - wxIsascii(code) && -#endif // ANSI - wxIsprint(code) ) - { - text << (wxChar)code; - } - else - { - wxFAIL_MSG( wxT("unknown keyboard accelerator code") ); - } - } - } - - return text; -} - -wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) -{ - return wxAcceleratorEntry::Create(label); -} - -#endif // wxUSE_ACCEL - - - diff --git a/Source/3rd Party/wx/src/common/accesscmn.cpp b/Source/3rd Party/wx/src/common/accesscmn.cpp index 660f1090d..168425822 100644 --- a/Source/3rd Party/wx/src/common/accesscmn.cpp +++ b/Source/3rd Party/wx/src/common/accesscmn.cpp @@ -1,8 +1,9 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/common/accesscmn.cpp +// Name: common/accesscmn.cpp // Author: Julian Smart // Modified by: // Created: 2003-02-12 +// RCS-ID: $Id: accesscmn.cpp 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/src/common/affinematrix2d.cpp b/Source/3rd Party/wx/src/common/affinematrix2d.cpp deleted file mode 100644 index 5013b31f1..000000000 --- a/Source/3rd Party/wx/src/common/affinematrix2d.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: affinematrix2d.cpp -// Purpose: implementation of wxAffineMatrix2D -// Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart -// Created: 2011-04-05 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_GEOMETRY - -#include "wx/affinematrix2d.h" -#include "wx/math.h" - -// sets the matrix to the respective values -void wxAffineMatrix2D::Set(const wxMatrix2D &mat2D, const wxPoint2DDouble &tr) -{ - m_11 = mat2D.m_11; - m_12 = mat2D.m_12; - m_21 = mat2D.m_21; - m_22 = mat2D.m_22; - m_tx = tr.m_x; - m_ty = tr.m_y; -} - -// gets the component valuess of the matrix -void wxAffineMatrix2D::Get(wxMatrix2D *mat2D, wxPoint2DDouble *tr) const -{ - mat2D->m_11 = m_11; - mat2D->m_12 = m_12; - mat2D->m_21 = m_21; - mat2D->m_22 = m_22; - - if ( tr ) - { - tr->m_x = m_tx; - tr->m_y = m_ty; - } -} - -// concatenates the matrix -// | t.m_11 t.m_12 0 | | m_11 m_12 0 | -// | t.m_21 t.m_22 0 | x | m_21 m_22 0 | -// | t.m_tx t.m_ty 1 | | m_tx m_ty 1 | -void wxAffineMatrix2D::Concat(const wxAffineMatrix2DBase &t) -{ - wxMatrix2D mat; - wxPoint2DDouble tr; - t.Get(&mat, &tr); - - m_tx += tr.m_x*m_11 + tr.m_y*m_21; - m_ty += tr.m_x*m_12 + tr.m_y*m_22; - wxDouble e11 = mat.m_11*m_11 + mat.m_12*m_21; - wxDouble e12 = mat.m_11*m_12 + mat.m_12*m_22; - wxDouble e21 = mat.m_21*m_11 + mat.m_22*m_21; - m_22 = mat.m_21*m_12 + mat.m_22*m_22; - m_11 = e11; - m_12 = e12; - m_21 = e21; -} - -// makes this its inverse matrix. -// Invert -// | m_11 m_12 0 | -// | m_21 m_22 0 | -// | m_tx m_ty 1 | -bool wxAffineMatrix2D::Invert() -{ - const wxDouble det = m_11*m_22 - m_12*m_21; - - if ( !det ) - return false; - - wxDouble ex = (m_21*m_ty - m_22*m_tx) / det; - m_ty = (-m_11*m_ty + m_12*m_tx) / det; - m_tx = ex; - wxDouble e11 = m_22 / det; - m_12 = -m_12 / det; - m_21 = -m_21 / det; - m_22 = m_11 / det; - m_11 = e11; - - return true; -} - -// returns true if the elements of the transformation matrix are equal -bool wxAffineMatrix2D::IsEqual(const wxAffineMatrix2DBase& t) const -{ - wxMatrix2D mat; - wxPoint2DDouble tr; - t.Get(&mat, &tr); - - return m_11 == mat.m_11 && m_12 == mat.m_12 && - m_21 == mat.m_21 && m_22 == mat.m_22 && - m_tx == tr.m_x && m_ty == tr.m_y; -} - -// -// transformations -// - -// add the translation to this matrix -// | 1 0 0 | | m_11 m_12 0 | -// | 0 1 0 | x | m_21 m_22 0 | -// | dx dy 1 | | m_tx m_ty 1 | -void wxAffineMatrix2D::Translate(wxDouble dx, wxDouble dy) -{ - m_tx += m_11 * dx + m_21 * dy; - m_ty += m_12 * dx + m_22 * dy; -} - -// add the scale to this matrix -// | xScale 0 0 | | m_11 m_12 0 | -// | 0 yScale 0 | x | m_21 m_22 0 | -// | 0 0 1 | | m_tx m_ty 1 | -void wxAffineMatrix2D::Scale(wxDouble xScale, wxDouble yScale) -{ - m_11 *= xScale; - m_12 *= xScale; - m_21 *= yScale; - m_22 *= yScale; -} - -// add the rotation to this matrix (clockwise, radians) -// | cos sin 0 | | m_11 m_12 0 | -// | -sin cos 0 | x | m_21 m_22 0 | -// | 0 0 1 | | m_tx m_ty 1 | -void wxAffineMatrix2D::Rotate(wxDouble cRadians) -{ - wxDouble c = cos(cRadians); - wxDouble s = sin(cRadians); - - wxDouble e11 = c*m_11 + s*m_21; - wxDouble e12 = c*m_12 + s*m_22; - m_21 = c*m_21 - s*m_11; - m_22 = c*m_22 - s*m_12; - m_11 = e11; - m_12 = e12; -} - -// -// apply the transforms -// - -// applies that matrix to the point -// | m_11 m_12 0 | -// | src.m_x src._my 1 | x | m_21 m_22 0 | -// | m_tx m_ty 1 | -wxPoint2DDouble -wxAffineMatrix2D::DoTransformPoint(const wxPoint2DDouble& src) const -{ - if ( IsIdentity() ) - return src; - - return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21 + m_tx, - src.m_x * m_12 + src.m_y * m_22 + m_ty); -} - -// applies the matrix except for translations -// | m_11 m_12 0 | -// | src.m_x src._my 0 | x | m_21 m_22 0 | -// | m_tx m_ty 1 | -wxPoint2DDouble -wxAffineMatrix2D::DoTransformDistance(const wxPoint2DDouble& src) const -{ - if ( IsIdentity() ) - return src; - - return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21, - src.m_x * m_12 + src.m_y * m_22); -} - -bool wxAffineMatrix2D::IsIdentity() const -{ - return m_11 == 1 && m_12 == 0 && - m_21 == 0 && m_22 == 1 && - m_tx == 0 && m_ty == 0; -} - -#endif // wxUSE_GEOMETRY diff --git a/Source/3rd Party/wx/src/common/anidecod.cpp b/Source/3rd Party/wx/src/common/anidecod.cpp index d62c00b45..4a905f802 100644 --- a/Source/3rd Party/wx/src/common/anidecod.cpp +++ b/Source/3rd Party/wx/src/common/anidecod.cpp @@ -2,6 +2,7 @@ // Name: src/common/anidecod.cpp // Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation // Author: Francesco Montorsi +// RCS-ID: $Id: anidecod.cpp 43898 2006-12-10 14:18:37Z VZ $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -112,10 +113,10 @@ wxColour wxANIDecoder::GetTransparentColour(unsigned int frame) const // ANI reading and decoding //--------------------------------------------------------------------------- -bool wxANIDecoder::DoCanRead(wxInputStream& stream) const +bool wxANIDecoder::CanRead(wxInputStream& stream) const { wxInt32 FCC1, FCC2; - wxUint32 datalen; + wxUint32 datalen ; wxInt32 riff32; memcpy( &riff32, "RIFF", 4 ); @@ -126,11 +127,7 @@ bool wxANIDecoder::DoCanRead(wxInputStream& stream) const wxInt32 anih32; memcpy( &anih32, "anih", 4 ); - if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) - { - return false; - } - + stream.SeekI(0); if ( !stream.Read(&FCC1, 4) ) return false; @@ -157,8 +154,7 @@ bool wxANIDecoder::DoCanRead(wxInputStream& stream) const } else { - if ( stream.SeekI(stream.TellI() + datalen) == wxInvalidOffset ) - return false; + stream.SeekI(stream.TellI() + datalen); } // try to read next data chunk: @@ -224,13 +220,8 @@ bool wxANIDecoder::Load( wxInputStream& stream ) wxInt32 seq32; memcpy( &seq32, "seq ", 4 ); - if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) - { - return false; - } - - if ( !stream.Read(&FCC1, 4) ) - return false; + stream.SeekI(0); + stream.Read(&FCC1, 4); if ( FCC1 != riff32 ) return false; @@ -241,12 +232,10 @@ bool wxANIDecoder::Load( wxInputStream& stream ) m_info.Clear(); // we have a riff file: - while ( !stream.Eof() ) + while ( stream.IsOk() ) { // we always have a data size: - if (!stream.Read(&datalen, 4)) - return false; - + stream.Read(&datalen, 4); datalen = wxINT32_SWAP_ON_BE(datalen); //data should be padded to make even number of bytes @@ -255,8 +244,7 @@ bool wxANIDecoder::Load( wxInputStream& stream ) // now either data or a FCC: if ( (FCC1 == riff32) || (FCC1 == list32) ) { - if (!stream.Read(&FCC2, 4)) - return false; + stream.Read(&FCC2, 4); } else if ( FCC1 == anih32 ) { @@ -267,8 +255,7 @@ bool wxANIDecoder::Load( wxInputStream& stream ) return false; // already parsed an ani header? struct wxANIHeader header; - if (!stream.Read(&header, sizeof(wxANIHeader))) - return false; + stream.Read(&header, sizeof(wxANIHeader)); header.AdjustEndianness(); // we should have a global frame size @@ -293,8 +280,7 @@ bool wxANIDecoder::Load( wxInputStream& stream ) wxASSERT(m_info.GetCount() == m_nFrames); for (unsigned int i=0; i(type_); - - wxAnyTypeToVariantDataFactoryMap& anyToVariant = m_anyToVariant; - wxAnyTypeToVariantDataFactoryMap::const_iterator it; - it = anyToVariant.find(type); - if ( it != anyToVariant.end() ) - return it->second; - - // Not found, handle pre-registrations - size_t i = m_anyToVariantRegs.size(); - while ( i > 0 ) - { - i--; - wxAnyToVariantRegistration* reg = m_anyToVariantRegs[i]; - wxAnyValueType* assocType = reg->GetAssociatedType(); - if ( assocType ) - { - // Both variant data and wxAnyValueType have been - // now been properly initialized, so remove the - // pre-registration entry and move data to anyToVarian - // map. - anyToVariant[assocType] = reg->GetFactory(); - m_anyToVariantRegs.erase( m_anyToVariantRegs.begin() + i ); - } - } - - // Then try again - it = anyToVariant.find(type); - if ( it != anyToVariant.end() ) - return it->second; - - // Finally, attempt to find a compatible type - for ( it = anyToVariant.begin(); it != anyToVariant.end(); it++ ) - { - if ( type->IsSameType(it->first) ) - { - wxVariantDataFactory f = it->second; - anyToVariant[type] = f; - return f; - } - } - - // Nothing found - return NULL; - } - -private: - wxAnyTypeToVariantDataFactoryMap m_anyToVariant; - wxVector m_anyToVariantRegs; -}; - -static wxAnyValueTypeGlobals* g_wxAnyValueTypeGlobals = NULL; - - -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplVariantData) - -void wxPreRegisterAnyToVariant(wxAnyToVariantRegistration* reg) -{ - if ( !g_wxAnyValueTypeGlobals ) - g_wxAnyValueTypeGlobals = new wxAnyValueTypeGlobals(); - g_wxAnyValueTypeGlobals->PreRegisterAnyToVariant(reg); -} - -bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant) -{ - if ( any.IsNull() ) - { - variant->MakeNull(); - return true; - } - - // (signed) integer is a special case, because there is only one type - // in wxAny, and two ("long" and "longlong") in wxVariant. For better - // backwards compatibility, convert all values that fit in "long", - // and others to "longlong". - if ( wxANY_CHECK_TYPE(any, signed int) ) - { -#ifdef wxLongLong_t - wxLongLong_t ll = 0; - if ( any.GetAs(&ll) ) - { - // NB: Do not use LONG_MAX here. Explicitly using 32-bit - // integer constraint yields more consistent behaviour across - // builds. - if ( ll > wxINT32_MAX || ll < wxINT32_MIN ) - *variant = wxLongLong(ll); - else - *variant = (long) wxLongLong(ll).GetLo(); - } - else - { - return false; - } -#else - long l; - if ( any.GetAs(&l) ) - *variant = l; - else - return false; -#endif - return true; - } - - // Find matching factory function - wxVariantDataFactory f = - g_wxAnyValueTypeGlobals->FindVariantDataFactory(any.GetType()); - - wxVariantData* data = NULL; - - if ( f ) - { - data = f(any); - } - else - { - // Check if wxAny wrapped wxVariantData* - if ( !any.GetAs(&data) ) - { - // Ok, one last chance: while unlikely, it is possible that the - // wxAny actually contains wxVariant. - if ( wxANY_CHECK_TYPE(any, wxVariant) ) - *variant = wxANY_AS(any, wxVariant); - return false; - } - - // Wrapper's GetValue() does not increase reference - // count, se have to do it before the data gets passed - // to a new variant. - data->IncRef(); - } - - variant->SetData(data); - return true; -} - -// -// This class is to make sure that wxAnyValueType instances -// etc. get freed correctly. We must use a separate wxAnyValueTypeGlobals -// because wxModule itself is instantiated too late. -// -class wxAnyValueTypeGlobalsManager : public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager) -public: - wxAnyValueTypeGlobalsManager() : wxModule() { } - virtual ~wxAnyValueTypeGlobalsManager() { } - - virtual bool OnInit() - { - return true; - } - virtual void OnExit() - { - wxDELETE(g_wxAnyValueTypeGlobals); - } -private: -}; - -IMPLEMENT_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager, wxModule) - -#endif // wxUSE_VARIANT - - -//------------------------------------------------------------------------- -// Dynamic conversion member functions -//------------------------------------------------------------------------- - -// -// Define integer minimum and maximum as helpers -#ifdef wxLongLong_t - #define UseIntMin (wxINT64_MIN) - #define UseIntMax (wxINT64_MAX) - #define UseUintMax (wxUINT64_MAX) -#else - #define UseIntMin (LONG_MIN) - #define UseIntMax (LONG_MAX) - #define UseUintMax (ULONG_MAX) -#endif - -namespace -{ - -const double UseIntMinF = static_cast(UseIntMin); -const double UseIntMaxF = static_cast(UseIntMax); -const double UseUintMaxF = static_cast(UseUintMax); - -} // anonymous namespace - -bool wxAnyValueTypeImplInt::ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const -{ - wxAnyBaseIntType value = GetValue(src); - if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) - { -#ifdef wxLongLong_t - wxLongLong ll(value); - wxString s = ll.ToString(); -#else - wxString s = wxString::Format(wxS("%ld"), (long)value); -#endif - wxAnyValueTypeImpl::SetValue(s, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) ) - { - if ( value < 0 ) - return false; - wxAnyBaseUintType ul = (wxAnyBaseUintType) value; - wxAnyValueTypeImplUint::SetValue(ul, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) ) - { - double value2 = static_cast(value); - wxAnyValueTypeImplDouble::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) ) - { - bool value2 = value ? true : false; - wxAnyValueTypeImpl::SetValue(value2, dst); - } - else - return false; - - return true; -} - -bool wxAnyValueTypeImplUint::ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const -{ - wxAnyBaseUintType value = GetValue(src); - if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) - { -#ifdef wxLongLong_t - wxULongLong ull(value); - wxString s = ull.ToString(); -#else - wxString s = wxString::Format(wxS("%lu"), (long)value); -#endif - wxAnyValueTypeImpl::SetValue(s, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) ) - { - if ( value > UseIntMax ) - return false; - wxAnyBaseIntType l = (wxAnyBaseIntType) value; - wxAnyValueTypeImplInt::SetValue(l, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) ) - { -#ifndef __VISUALC6__ - double value2 = static_cast(value); -#else - // VC6 doesn't implement conversion from unsigned __int64 to double - wxAnyBaseIntType value0 = static_cast(value); - double value2 = static_cast(value0); -#endif - wxAnyValueTypeImplDouble::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) ) - { - bool value2 = value ? true : false; - wxAnyValueTypeImpl::SetValue(value2, dst); - } - else - return false; - - return true; -} - -// Convert wxString to destination wxAny value type -bool wxAnyConvertString(const wxString& value, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) -{ - if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) - { - wxAnyValueTypeImpl::SetValue(value, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) ) - { - wxAnyBaseIntType value2; -#ifdef wxLongLong_t - if ( !value.ToLongLong(&value2) ) -#else - if ( !value.ToLong(&value2) ) -#endif - return false; - wxAnyValueTypeImplInt::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) ) - { - wxAnyBaseUintType value2; -#ifdef wxLongLong_t - if ( !value.ToULongLong(&value2) ) -#else - if ( !value.ToULong(&value2) ) -#endif - return false; - wxAnyValueTypeImplUint::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) ) - { - double value2; - if ( !value.ToCDouble(&value2) ) - return false; - wxAnyValueTypeImplDouble::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) ) - { - bool value2; - wxString s(value); - s.MakeLower(); - if ( s == wxS("true") || - s == wxS("yes") || - s == wxS('1') ) - value2 = true; - else if ( s == wxS("false") || - s == wxS("no") || - s == wxS('0') ) - value2 = false; - else - return false; - - wxAnyValueTypeImpl::SetValue(value2, dst); - } - else - return false; - - return true; -} - -bool wxAnyValueTypeImpl::ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const -{ - bool value = GetValue(src); - if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) ) - { - wxAnyBaseIntType value2 = static_cast(value); - wxAnyValueTypeImplInt::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) ) - { - wxAnyBaseIntType value2 = static_cast(value); - wxAnyValueTypeImplUint::SetValue(value2, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) - { - wxString s; - if ( value ) - s = wxS("true"); - else - s = wxS("false"); - wxAnyValueTypeImpl::SetValue(s, dst); - } - else - return false; - - return true; -} - -bool wxAnyValueTypeImplDouble::ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const -{ - double value = GetValue(src); - if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) ) - { - if ( value < UseIntMinF || value > UseIntMaxF ) - return false; - wxAnyBaseUintType ul = static_cast(value); - wxAnyValueTypeImplUint::SetValue(ul, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) ) - { - if ( value < 0.0 || value > UseUintMaxF ) - return false; - wxAnyBaseUintType ul = static_cast(value); - wxAnyValueTypeImplUint::SetValue(ul, dst); - } - else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) - { - wxString s = wxString::FromCDouble(value, 14); - wxAnyValueTypeImpl::SetValue(s, dst); - } - else - return false; - - return true; -} - -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplInt) -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplUint) -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble) - -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplwxString) -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplConstCharPtr) -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplConstWchar_tPtr) - -#if wxUSE_DATETIME -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -#endif // wxUSE_DATETIME - -//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) - -//------------------------------------------------------------------------- -// wxAnyNullValueType implementation -//------------------------------------------------------------------------- - -class wxAnyNullValue -{ -protected: - // this field is unused, but can't be private to avoid Clang's - // "Private field 'm_dummy' is not used" warning - void* m_dummy; -}; - -template <> -class wxAnyValueTypeImpl : public wxAnyValueType -{ - WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -public: - // Dummy implementations - virtual void DeleteValue(wxAnyValueBuffer& buf) const - { - wxUnusedVar(buf); - } - - virtual void CopyBuffer(const wxAnyValueBuffer& src, - wxAnyValueBuffer& dst) const - { - wxUnusedVar(src); - wxUnusedVar(dst); - } - - virtual bool ConvertValue(const wxAnyValueBuffer& src, - wxAnyValueType* dstType, - wxAnyValueBuffer& dst) const - { - wxUnusedVar(src); - wxUnusedVar(dstType); - wxUnusedVar(dst); - return false; - } - -#if wxUSE_EXTENDED_RTTI - virtual const wxTypeInfo* GetTypeInfo() const - { - wxFAIL_MSG("Null Type Info not available"); - return NULL; - } -#endif - -private: -}; - -WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) - -wxAnyValueType* wxAnyNullValueType = - wxAnyValueTypeImpl::GetInstance(); - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxAnyList) - -#endif // wxUSE_ANY diff --git a/Source/3rd Party/wx/src/common/appbase.cpp b/Source/3rd Party/wx/src/common/appbase.cpp index 68113d995..c696e9c07 100644 --- a/Source/3rd Party/wx/src/common/appbase.cpp +++ b/Source/3rd Party/wx/src/common/appbase.cpp @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// // Name: src/common/appbase.cpp -// Purpose: implements wxAppConsoleBase class +// Purpose: implements wxAppConsole class // Author: Vadim Zeitlin // Modified by: // Created: 19.06.2003 (extracted from common/appcmn.cpp) +// RCS-ID: $Id: appbase.cpp 52093 2008-02-25 13:43:07Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -24,7 +25,7 @@ #endif #ifndef WX_PRECOMP - #ifdef __WINDOWS__ + #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" // includes windows.h for MessageBox() #endif #include "wx/list.h" @@ -32,50 +33,46 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" - #include "wx/wxcrtvararg.h" #endif //WX_PRECOMP #include "wx/apptrait.h" #include "wx/cmdline.h" #include "wx/confbase.h" -#include "wx/evtloop.h" #include "wx/filename.h" #include "wx/msgout.h" -#include "wx/scopedptr.h" -#include "wx/sysopt.h" #include "wx/tokenzr.h" -#include "wx/thread.h" -#if wxUSE_STL - #if wxUSE_EXCEPTIONS - #include - #include - #endif - #if wxUSE_INTL - #include - #endif -#endif // wxUSE_STL - -#if !defined(__WINDOWS__) || defined(__WXMICROWIN__) +#if !defined(__WXMSW__) || defined(__WXMICROWIN__) #include // for SIGTRAP used by wxTrap() #endif //Win/Unix -#include - #if wxUSE_FONTMAP #include "wx/fontmap.h" #endif // wxUSE_FONTMAP -#if wxDEBUG_LEVEL +#if defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS + // For MacTypes.h for Debugger function + #include +#endif + +#if defined(__WXMAC__) + #ifdef __DARWIN__ + #include + #else + #include "wx/mac/private.h" // includes mac headers + #endif +#endif // __WXMAC__ + +#ifdef __WXDEBUG__ #if wxUSE_STACKWALKER #include "wx/stackwalk.h" - #ifdef __WINDOWS__ + #ifdef __WXMSW__ #include "wx/msw/debughlp.h" #endif #endif // wxUSE_STACKWALKER #include "wx/recguard.h" -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ // wxABI_VERSION can be defined when compiling applications but it should be // left undefined when compiling the library itself, it is then set to its @@ -88,22 +85,20 @@ // private functions prototypes // ---------------------------------------------------------------------------- -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ // really just show the assert dialog static bool DoShowAssertDialog(const wxString& msg); // prepare for showing the assert dialog, use the given traits or // DoShowAssertDialog() as last fallback to really show it static - void ShowAssertDialog(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg, + void ShowAssertDialog(const wxChar *szFile, + int nLine, + const wxChar *szFunc, + const wxChar *szCond, + const wxChar *szMsg, wxAppTraits *traits = NULL); -#endif // wxDEBUG_LEVEL -#ifdef __WXDEBUG__ // turn on the trace masks specified in the env variable WXTRACE static void LINKAGEMODE SetTraceMasks(); #endif // __WXDEBUG__ @@ -112,36 +107,23 @@ // global vars // ---------------------------------------------------------------------------- -wxAppConsole *wxAppConsoleBase::ms_appInstance = NULL; +wxAppConsole *wxAppConsole::ms_appInstance = NULL; -wxAppInitializerFunction wxAppConsoleBase::ms_appInitFn = NULL; - -wxSocketManager *wxAppTraitsBase::ms_manager = NULL; - -WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; - -// ---------------------------------------------------------------------------- -// wxEventLoopPtr -// ---------------------------------------------------------------------------- - -// this defines wxEventLoopPtr -wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoopBase) +wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL; // ============================================================================ -// wxAppConsoleBase implementation +// wxAppConsole implementation // ============================================================================ // ---------------------------------------------------------------------------- // ctor/dtor // ---------------------------------------------------------------------------- -wxAppConsoleBase::wxAppConsoleBase() +wxAppConsole::wxAppConsole() { m_traits = NULL; - m_mainLoop = NULL; - m_bDoPendingEventProcessing = true; - ms_appInstance = static_cast(this); + ms_appInstance = this; #ifdef __WXDEBUG__ SetTraceMasks(); @@ -149,82 +131,47 @@ wxAppConsoleBase::wxAppConsoleBase() // In unicode mode the SetTraceMasks call can cause an apptraits to be // created, but since we are still in the constructor the wrong kind will // be created for GUI apps. Destroy it so it can be created again later. - wxDELETE(m_traits); + delete m_traits; + m_traits = NULL; #endif #endif - - wxEvtHandler::AddFilter(this); } -wxAppConsoleBase::~wxAppConsoleBase() +wxAppConsole::~wxAppConsole() { - wxEvtHandler::RemoveFilter(this); - - // we're being destroyed and using this object from now on may not work or - // even crash so don't leave dangling pointers to it - ms_appInstance = NULL; - delete m_traits; } // ---------------------------------------------------------------------------- -// initialization/cleanup +// initilization/cleanup // ---------------------------------------------------------------------------- -bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **WXUNUSED(argv)) +bool wxAppConsole::Initialize(int& argcOrig, wxChar **argvOrig) { -#if defined(__WINDOWS__) && !defined(__WXWINCE__) - SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); + // remember the command line arguments + argc = argcOrig; + argv = argvOrig; + +#ifndef __WXPALMOS__ + if ( m_appName.empty() && argv ) + { + // the application name is, by default, the name of its executable file + wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL); + } #endif return true; } -wxString wxAppConsoleBase::GetAppName() const +void wxAppConsole::CleanUp() { - wxString name = m_appName; - if ( name.empty() ) - { - if ( argv ) - { - // the application name is, by default, the name of its executable file - wxFileName::SplitPath(argv[0], NULL, &name, NULL); - } - } - return name; -} - -wxString wxAppConsoleBase::GetAppDisplayName() const -{ - // use the explicitly provided display name, if any - if ( !m_appDisplayName.empty() ) - return m_appDisplayName; - - // if the application name was explicitly set, use it as is as capitalizing - // it won't always produce good results - if ( !m_appName.empty() ) - return m_appName; - - // if neither is set, use the capitalized version of the program file as - // it's the most reasonable default - return GetAppName().Capitalize(); -} - -wxEventLoopBase *wxAppConsoleBase::CreateMainLoop() -{ - return GetTraits()->CreateEventLoop(); -} - -void wxAppConsoleBase::CleanUp() -{ - wxDELETE(m_mainLoop); } // ---------------------------------------------------------------------------- // OnXXX() callbacks // ---------------------------------------------------------------------------- -bool wxAppConsoleBase::OnInit() +bool wxAppConsole::OnInit() { #if wxUSE_CMDLINE_PARSER wxCmdLineParser parser(argc, argv); @@ -254,346 +201,110 @@ bool wxAppConsoleBase::OnInit() return true; } -int wxAppConsoleBase::OnRun() -{ - return MainLoop(); -} - -void wxAppConsoleBase::OnLaunched() -{ -} - -int wxAppConsoleBase::OnExit() +int wxAppConsole::OnExit() { #if wxUSE_CONFIG // delete the config object if any (don't use Get() here, but Set() // because Get() could create a new config object) - delete wxConfigBase::Set(NULL); + delete wxConfigBase::Set((wxConfigBase *) NULL); #endif // wxUSE_CONFIG return 0; } -void wxAppConsoleBase::Exit() +void wxAppConsole::Exit() { - if (m_mainLoop != NULL) - ExitMainLoop(); - else - exit(-1); + exit(-1); } // ---------------------------------------------------------------------------- // traits stuff // ---------------------------------------------------------------------------- -wxAppTraits *wxAppConsoleBase::CreateTraits() +wxAppTraits *wxAppConsole::CreateTraits() { return new wxConsoleAppTraits; } -wxAppTraits *wxAppConsoleBase::GetTraits() +wxAppTraits *wxAppConsole::GetTraits() { // FIXME-MT: protect this with a CS? if ( !m_traits ) { m_traits = CreateTraits(); - wxASSERT_MSG( m_traits, wxT("wxApp::CreateTraits() failed?") ); + wxASSERT_MSG( m_traits, _T("wxApp::CreateTraits() failed?") ); } return m_traits; } -/* static */ -wxAppTraits *wxAppConsoleBase::GetTraitsIfExists() -{ - wxAppConsole * const app = GetInstance(); - return app ? app->GetTraits() : NULL; -} - -/* static */ -wxAppTraits& wxAppConsoleBase::GetValidTraits() -{ - static wxConsoleAppTraits s_traitsConsole; - wxAppTraits* const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - - return traits ? *traits : s_traitsConsole; -} - -// ---------------------------------------------------------------------------- -// wxEventLoop redirection -// ---------------------------------------------------------------------------- - -int wxAppConsoleBase::MainLoop() -{ - wxEventLoopBaseTiedPtr mainLoop(&m_mainLoop, CreateMainLoop()); - - if (wxTheApp) - wxTheApp->OnLaunched(); - - return m_mainLoop ? m_mainLoop->Run() : -1; -} - -void wxAppConsoleBase::ExitMainLoop() -{ - // we should exit from the main event loop, not just any currently active - // (e.g. modal dialog) event loop - if ( m_mainLoop && m_mainLoop->IsRunning() ) - { - m_mainLoop->Exit(0); - } -} - -bool wxAppConsoleBase::Pending() -{ - // use the currently active message loop here, not m_mainLoop, because if - // we're showing a modal dialog (with its own event loop) currently the - // main event loop is not running anyhow - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - - return loop && loop->Pending(); -} - -bool wxAppConsoleBase::Dispatch() -{ - // see comment in Pending() - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - - return loop && loop->Dispatch(); -} - -bool wxAppConsoleBase::Yield(bool onlyIfNeeded) -{ - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - if ( loop ) - return loop->Yield(onlyIfNeeded); - - wxScopedPtr tmpLoop(CreateMainLoop()); - return tmpLoop->Yield(onlyIfNeeded); -} - -void wxAppConsoleBase::WakeUpIdle() -{ - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - - if ( loop ) - loop->WakeUp(); -} - -bool wxAppConsoleBase::ProcessIdle() -{ - // synthesize an idle event and check if more of them are needed - wxIdleEvent event; - event.SetEventObject(this); - ProcessEvent(event); +// we must implement CreateXXX() in wxApp itself for backwards compatibility +#if WXWIN_COMPATIBILITY_2_4 #if wxUSE_LOG - // flush the logged messages if any (do this after processing the events - // which could have logged new messages) - wxLog::FlushActive(); + +wxLog *wxAppConsole::CreateLogTarget() +{ + wxAppTraits *traits = GetTraits(); + return traits ? traits->CreateLogTarget() : NULL; +} + +#endif // wxUSE_LOG + +wxMessageOutput *wxAppConsole::CreateMessageOutput() +{ + wxAppTraits *traits = GetTraits(); + return traits ? traits->CreateMessageOutput() : NULL; +} + +#endif // WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// event processing +// ---------------------------------------------------------------------------- + +void wxAppConsole::ProcessPendingEvents() +{ +#if wxUSE_THREADS + if ( !wxPendingEventsLocker ) + return; #endif - // Garbage collect all objects previously scheduled for destruction. - DeletePendingObjects(); + // ensure that we're the only thread to modify the pending events list + wxENTER_CRIT_SECT( *wxPendingEventsLocker ); - return event.MoreRequested(); -} - -bool wxAppConsoleBase::UsesEventLoop() const -{ - // in console applications we don't know whether we're going to have an - // event loop so assume we won't -- unless we already have one running - return wxEventLoopBase::GetActive() != NULL; -} - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -/* static */ -bool wxAppConsoleBase::IsMainLoopRunning() -{ - const wxAppConsole * const app = GetInstance(); - - return app && app->m_mainLoop != NULL; -} - -int wxAppConsoleBase::FilterEvent(wxEvent& WXUNUSED(event)) -{ - // process the events normally by default - return Event_Skip; -} - -void wxAppConsoleBase::DelayPendingEventHandler(wxEvtHandler* toDelay) -{ - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - - // move the handler from the list of handlers with processable pending events - // to the list of handlers with pending events which needs to be processed later - m_handlersWithPendingEvents.Remove(toDelay); - - if (m_handlersWithPendingDelayedEvents.Index(toDelay) == wxNOT_FOUND) - m_handlersWithPendingDelayedEvents.Add(toDelay); - - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); -} - -void wxAppConsoleBase::RemovePendingEventHandler(wxEvtHandler* toRemove) -{ - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - - if (m_handlersWithPendingEvents.Index(toRemove) != wxNOT_FOUND) + if ( !wxPendingEvents ) { - m_handlersWithPendingEvents.Remove(toRemove); - - // check that the handler was present only once in the list - wxASSERT_MSG( m_handlersWithPendingEvents.Index(toRemove) == wxNOT_FOUND, - "Handler occurs twice in the m_handlersWithPendingEvents list!" ); - } - //else: it wasn't in this list at all, it's ok - - if (m_handlersWithPendingDelayedEvents.Index(toRemove) != wxNOT_FOUND) - { - m_handlersWithPendingDelayedEvents.Remove(toRemove); - - // check that the handler was present only once in the list - wxASSERT_MSG( m_handlersWithPendingDelayedEvents.Index(toRemove) == wxNOT_FOUND, - "Handler occurs twice in m_handlersWithPendingDelayedEvents list!" ); - } - //else: it wasn't in this list at all, it's ok - - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); -} - -void wxAppConsoleBase::AppendPendingEventHandler(wxEvtHandler* toAppend) -{ - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - - if ( m_handlersWithPendingEvents.Index(toAppend) == wxNOT_FOUND ) - m_handlersWithPendingEvents.Add(toAppend); - - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); -} - -bool wxAppConsoleBase::HasPendingEvents() const -{ - wxENTER_CRIT_SECT(const_cast(this)->m_handlersWithPendingEventsLocker); - - bool has = !m_handlersWithPendingEvents.IsEmpty(); - - wxLEAVE_CRIT_SECT(const_cast(this)->m_handlersWithPendingEventsLocker); - - return has; -} - -void wxAppConsoleBase::SuspendProcessingOfPendingEvents() -{ - m_bDoPendingEventProcessing = false; -} - -void wxAppConsoleBase::ResumeProcessingOfPendingEvents() -{ - m_bDoPendingEventProcessing = true; -} - -void wxAppConsoleBase::ProcessPendingEvents() -{ - if ( m_bDoPendingEventProcessing ) - { - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - - wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(), - "this helper list should be empty" ); - - // iterate until the list becomes empty: the handlers remove themselves - // from it when they don't have any more pending events - while (!m_handlersWithPendingEvents.IsEmpty()) - { - // In ProcessPendingEvents(), new handlers might be added - // and we can safely leave the critical section here. - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); - - // NOTE: we always call ProcessPendingEvents() on the first event handler - // with pending events because handlers auto-remove themselves - // from this list (see RemovePendingEventHandler) if they have no - // more pending events. - m_handlersWithPendingEvents[0]->ProcessPendingEvents(); - - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - } - - // now the wxHandlersWithPendingEvents is surely empty; however some event - // handlers may have moved themselves into wxHandlersWithPendingDelayedEvents - // because of a selective wxYield call in progress. - // Now we need to move them back to wxHandlersWithPendingEvents so the next - // call to this function has the chance of processing them: - if (!m_handlersWithPendingDelayedEvents.IsEmpty()) - { - WX_APPEND_ARRAY(m_handlersWithPendingEvents, m_handlersWithPendingDelayedEvents); - m_handlersWithPendingDelayedEvents.Clear(); - } - - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); - } -} - -void wxAppConsoleBase::DeletePendingEvents() -{ - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); - - wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(), - "this helper list should be empty" ); - - for (unsigned int i=0; iDeletePendingEvents(); - - m_handlersWithPendingEvents.Clear(); - - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); -} - -// ---------------------------------------------------------------------------- -// delayed objects destruction -// ---------------------------------------------------------------------------- - -bool wxAppConsoleBase::IsScheduledForDestruction(wxObject *object) const -{ - return wxPendingDelete.Member(object); -} - -void wxAppConsoleBase::ScheduleForDestruction(wxObject *object) -{ - if ( !UsesEventLoop() ) - { - // we won't be able to delete it later so do it right now - delete object; + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); return; } - //else: we either already have or will soon start an event loop - if ( !wxPendingDelete.Member(object) ) - wxPendingDelete.Append(object); -} - -void wxAppConsoleBase::DeletePendingObjects() -{ - wxList::compatibility_iterator node = wxPendingDelete.GetFirst(); + // iterate until the list becomes empty + wxList::compatibility_iterator node = wxPendingEvents->GetFirst(); while (node) { - wxObject *obj = node->GetData(); + wxEvtHandler *handler = (wxEvtHandler *)node->GetData(); + wxPendingEvents->Erase(node); - // remove it from the list first so that if we get back here somehow - // during the object deletion (e.g. wxYield called from its dtor) we - // wouldn't try to delete it the second time - if ( wxPendingDelete.Member(obj) ) - wxPendingDelete.Erase(node); + // In ProcessPendingEvents(), new handlers might be add + // and we can safely leave the critical section here. + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); - delete obj; + handler->ProcessPendingEvents(); - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); + wxENTER_CRIT_SECT( *wxPendingEventsLocker ); + + node = wxPendingEvents->GetFirst(); } + + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); +} + +int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event)) +{ + // process the events normally by default + return -1; } // ---------------------------------------------------------------------------- @@ -603,70 +314,14 @@ void wxAppConsoleBase::DeletePendingObjects() #if wxUSE_EXCEPTIONS void -wxAppConsoleBase::HandleEvent(wxEvtHandler *handler, - wxEventFunction func, - wxEvent& event) const +wxAppConsole::HandleEvent(wxEvtHandler *handler, + wxEventFunction func, + wxEvent& event) const { // by default, simply call the handler (handler->*func)(event); } -void wxAppConsoleBase::CallEventHandler(wxEvtHandler *handler, - wxEventFunctor& functor, - wxEvent& event) const -{ - // If the functor holds a method then, for backward compatibility, call - // HandleEvent(): - wxEventFunction eventFunction = functor.GetEvtMethod(); - - if ( eventFunction ) - HandleEvent(handler, eventFunction, event); - else - functor(handler, event); -} - -void wxAppConsoleBase::OnUnhandledException() -{ -#ifdef __WXDEBUG__ - // we're called from an exception handler so we can re-throw the exception - // to recover its type - wxString what; - try - { - throw; - } -#if wxUSE_STL - catch ( std::exception& e ) - { - what.Printf("std::exception of type \"%s\", what() = \"%s\"", - typeid(e).name(), e.what()); - } -#endif // wxUSE_STL - catch ( ... ) - { - what = "unknown exception"; - } - - wxMessageOutputBest().Printf( - "*** Caught unhandled %s; terminating\n", what - ); -#endif // __WXDEBUG__ -} - -// ---------------------------------------------------------------------------- -// exceptions support -// ---------------------------------------------------------------------------- - -bool wxAppConsoleBase::OnExceptionInMainLoop() -{ - throw; - - // some compilers are too stupid to know that we never return after throw -#if defined(__DMC__) || (defined(_MSC_VER) && _MSC_VER < 1200) - return false; -#endif -} - #endif // wxUSE_EXCEPTIONS // ---------------------------------------------------------------------------- @@ -675,17 +330,17 @@ bool wxAppConsoleBase::OnExceptionInMainLoop() #if wxUSE_CMDLINE_PARSER -#define OPTION_VERBOSE "verbose" +#define OPTION_VERBOSE _T("verbose") -void wxAppConsoleBase::OnInitCmdLine(wxCmdLineParser& parser) +void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser) { // the standard command line options static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, - "h", - "help", + _T("h"), + _T("help"), gettext_noop("show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP @@ -694,7 +349,7 @@ void wxAppConsoleBase::OnInitCmdLine(wxCmdLineParser& parser) #if wxUSE_LOG { wxCMD_LINE_SWITCH, - NULL, + wxEmptyString, OPTION_VERBOSE, gettext_noop("generate verbose log messages"), wxCMD_LINE_VAL_NONE, @@ -703,13 +358,20 @@ void wxAppConsoleBase::OnInitCmdLine(wxCmdLineParser& parser) #endif // wxUSE_LOG // terminator - wxCMD_LINE_DESC_END + { + wxCMD_LINE_NONE, + wxEmptyString, + wxEmptyString, + wxEmptyString, + wxCMD_LINE_VAL_NONE, + 0x0 + } }; parser.SetDesc(cmdLineDesc); } -bool wxAppConsoleBase::OnCmdLineParsed(wxCmdLineParser& parser) +bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser) { #if wxUSE_LOG if ( parser.Found(OPTION_VERBOSE) ) @@ -723,14 +385,14 @@ bool wxAppConsoleBase::OnCmdLineParsed(wxCmdLineParser& parser) return true; } -bool wxAppConsoleBase::OnCmdLineHelp(wxCmdLineParser& parser) +bool wxAppConsole::OnCmdLineHelp(wxCmdLineParser& parser) { parser.Usage(); return false; } -bool wxAppConsoleBase::OnCmdLineError(wxCmdLineParser& parser) +bool wxAppConsole::OnCmdLineError(wxCmdLineParser& parser) { parser.Usage(); @@ -744,8 +406,8 @@ bool wxAppConsoleBase::OnCmdLineError(wxCmdLineParser& parser) // ---------------------------------------------------------------------------- /* static */ -bool wxAppConsoleBase::CheckBuildOptions(const char *optionsSignature, - const char *componentName) +bool wxAppConsole::CheckBuildOptions(const char *optionsSignature, + const char *componentName) { #if 0 // can't use wxLogTrace, not up and running yet printf("checking build options object '%s' (ptr %p) in '%s'\n", @@ -759,7 +421,7 @@ bool wxAppConsoleBase::CheckBuildOptions(const char *optionsSignature, wxString progName = wxString::FromAscii(componentName); wxString msg; - msg.Printf(wxT("Mismatch between the program and library build versions detected.\nThe library used %s,\nand %s used %s."), + msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %s,\nand %s used %s."), lib.c_str(), progName.c_str(), prog.c_str()); wxLogFatalError(msg.c_str()); @@ -767,50 +429,41 @@ bool wxAppConsoleBase::CheckBuildOptions(const char *optionsSignature, // normally wxLogFatalError doesn't return return false; } +#undef wxCMP return true; } -void wxAppConsoleBase::OnAssertFailure(const wxChar *file, - int line, - const wxChar *func, - const wxChar *cond, - const wxChar *msg) +#ifdef __WXDEBUG__ + +void wxAppConsole::OnAssertFailure(const wxChar *file, + int line, + const wxChar *func, + const wxChar *cond, + const wxChar *msg) { -#if wxDEBUG_LEVEL ShowAssertDialog(file, line, func, cond, msg, GetTraits()); -#else - // this function is still present even in debug level 0 build for ABI - // compatibility reasons but is never called there and so can simply do - // nothing in it - wxUnusedVar(file); - wxUnusedVar(line); - wxUnusedVar(func); - wxUnusedVar(cond); - wxUnusedVar(msg); -#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL } -void wxAppConsoleBase::OnAssert(const wxChar *file, - int line, - const wxChar *cond, - const wxChar *msg) +void wxAppConsole::OnAssert(const wxChar *file, + int line, + const wxChar *cond, + const wxChar *msg) { OnAssertFailure(file, line, NULL, cond, msg); } -// ---------------------------------------------------------------------------- -// Miscellaneous other methods -// ---------------------------------------------------------------------------- +#endif // __WXDEBUG__ -void wxAppConsoleBase::SetCLocale() +#if WXWIN_COMPATIBILITY_2_4 + +bool wxAppConsole::CheckBuildOptions(const wxBuildOptions& buildOptions) { - // We want to use the user locale by default in GUI applications in order - // to show the numbers, dates &c in the familiar format -- and also accept - // this format on input (especially important for decimal comma/dot). - wxSetlocale(LC_ALL, ""); + return CheckBuildOptions(buildOptions.m_signature, "your program"); } +#endif + // ============================================================================ // other classes implementations // ============================================================================ @@ -848,10 +501,12 @@ wxRendererNative *wxConsoleAppTraitsBase::CreateRenderer() return NULL; } +#ifdef __WXDEBUG__ bool wxConsoleAppTraitsBase::ShowAssertDialog(const wxString& msg) { return wxAppTraitsBase::ShowAssertDialog(msg); } +#endif bool wxConsoleAppTraitsBase::HasStderr() { @@ -859,75 +514,52 @@ bool wxConsoleAppTraitsBase::HasStderr() return true; } +void wxConsoleAppTraitsBase::ScheduleForDestroy(wxObject *object) +{ + delete object; +} + +void wxConsoleAppTraitsBase::RemoveFromPendingDelete(wxObject * WXUNUSED(object)) +{ + // nothing to do +} + +#if wxUSE_SOCKETS +GSocketGUIFunctionsTable* wxConsoleAppTraitsBase::GetSocketGUIFunctionsTable() +{ + return NULL; +} +#endif + // ---------------------------------------------------------------------------- // wxAppTraits // ---------------------------------------------------------------------------- -#if wxUSE_THREADS -void wxMutexGuiEnterImpl(); -void wxMutexGuiLeaveImpl(); - -void wxAppTraitsBase::MutexGuiEnter() -{ - wxMutexGuiEnterImpl(); -} - -void wxAppTraitsBase::MutexGuiLeave() -{ - wxMutexGuiLeaveImpl(); -} - -void WXDLLIMPEXP_BASE wxMutexGuiEnter() -{ - wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists(); - if ( traits ) - traits->MutexGuiEnter(); -} - -void WXDLLIMPEXP_BASE wxMutexGuiLeave() -{ - wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists(); - if ( traits ) - traits->MutexGuiLeave(); -} -#endif // wxUSE_THREADS +#ifdef __WXDEBUG__ bool wxAppTraitsBase::ShowAssertDialog(const wxString& msgOriginal) { -#if wxDEBUG_LEVEL - wxString msg; + wxString msg = msgOriginal; #if wxUSE_STACKWALKER +#if !defined(__WXMSW__) + // on Unix stack frame generation may take some time, depending on the + // size of the executable mainly... warn the user that we are working + wxFprintf(stderr, wxT("[Debug] Generating a stack trace... please wait")); + fflush(stderr); +#endif + const wxString stackTrace = GetAssertStackTrace(); if ( !stackTrace.empty() ) - { - msg << wxT("\n\nCall stack:\n") << stackTrace; - - wxMessageOutputDebug().Output(msg); - } + msg << _T("\n\nCall stack:\n") << stackTrace; #endif // wxUSE_STACKWALKER - return DoShowAssertDialog(msgOriginal + msg); -#else // !wxDEBUG_LEVEL - wxUnusedVar(msgOriginal); - - return false; -#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL + return DoShowAssertDialog(msg); } #if wxUSE_STACKWALKER wxString wxAppTraitsBase::GetAssertStackTrace() { -#if wxDEBUG_LEVEL - -#if !defined(__WINDOWS__) - // on Unix stack frame generation may take some time, depending on the - // size of the executable mainly... warn the user that we are working - wxFprintf(stderr, "Collecting stack trace information, please wait..."); - fflush(stderr); -#endif // !__WINDOWS__ - - wxString stackTrace; class StackDump : public wxStackWalker @@ -942,29 +574,29 @@ wxString wxAppTraitsBase::GetAssertStackTrace() { m_stackTrace << wxString::Format ( - wxT("[%02d] "), + _T("[%02d] "), wx_truncate_cast(int, frame.GetLevel()) ); wxString name = frame.GetName(); if ( !name.empty() ) { - m_stackTrace << wxString::Format(wxT("%-40s"), name.c_str()); + m_stackTrace << wxString::Format(_T("%-40s"), name.c_str()); } else { - m_stackTrace << wxString::Format(wxT("%p"), frame.GetAddress()); + m_stackTrace << wxString::Format(_T("%p"), frame.GetAddress()); } if ( frame.HasSourceLocation() ) { - m_stackTrace << wxT('\t') + m_stackTrace << _T('\t') << frame.GetFileName() - << wxT(':') + << _T(':') << frame.GetLine(); } - m_stackTrace << wxT('\n'); + m_stackTrace << _T('\n'); } private: @@ -977,7 +609,7 @@ wxString wxAppTraitsBase::GetAssertStackTrace() static const int maxLines = 20; StackDump dump; - dump.Walk(8, maxLines); // 8 is chosen to hide all OnAssert() calls + dump.Walk(2, maxLines); // don't show OnAssert() call itself stackTrace = dump.GetStackTrace(); const int count = stackTrace.Freq(wxT('\n')); @@ -985,15 +617,12 @@ wxString wxAppTraitsBase::GetAssertStackTrace() stackTrace = stackTrace.BeforeLast(wxT('\n')); return stackTrace; -#else // !wxDEBUG_LEVEL - // this function is still present for ABI-compatibility even in debug level - // 0 build but is not used there and so can simply do nothing - return wxString(); -#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL } #endif // wxUSE_STACKWALKER +#endif // __WXDEBUG__ + // ============================================================================ // global functions implementation // ============================================================================ @@ -1020,30 +649,25 @@ void wxWakeUpIdle() //else: do nothing, what can we do? } +#ifdef __WXDEBUG__ + // wxASSERT() helper bool wxAssertIsEqual(int x, int y) { return x == y; } -void wxAbort() -{ -#ifdef __WXWINCE__ - ExitThread(3); -#else - abort(); -#endif -} - -#if wxDEBUG_LEVEL - // break into the debugger -#ifndef wxTrap - void wxTrap() { -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) +#if defined(__WXMSW__) && !defined(__WXMICROWIN__) DebugBreak(); +#elif defined(__WXMAC__) && !defined(__DARWIN__) + #if __powerc + Debugger(); + #else + SysBreak(); + #endif #elif defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS Debugger(); #elif defined(__UNIX__) @@ -1053,20 +677,13 @@ void wxTrap() #endif // Win/Unix } -#endif // wxTrap already defined as a macro - -// default assert handler -static void -wxDefaultAssertHandler(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg) +// this function is called when an assert fails +void wxOnAssert(const wxChar *szFile, + int nLine, + const char *szFunc, + const wxChar *szCond, + const wxChar *szMsg) { - // If this option is set, we should abort immediately when assert happens. - if ( wxSystemOptions::GetOptionInt("exit-on-assert") ) - wxAbort(); - // FIXME MT-unsafe static int s_bInAssert = 0; @@ -1079,107 +696,23 @@ wxDefaultAssertHandler(const wxString& file, return; } + // __FUNCTION__ is always in ASCII, convert it to wide char if needed + const wxString strFunc = wxString::FromAscii(szFunc); + if ( !wxTheApp ) { // by default, show the assert dialog box -- we can't customize this // behaviour - ShowAssertDialog(file, line, func, cond, msg); + ShowAssertDialog(szFile, nLine, strFunc, szCond, szMsg); } else { // let the app process it as it wants - // FIXME-UTF8: use wc_str(), not c_str(), when ANSI build is removed - wxTheApp->OnAssertFailure(file.c_str(), line, func.c_str(), - cond.c_str(), msg.c_str()); + wxTheApp->OnAssertFailure(szFile, nLine, strFunc, szCond, szMsg); } } -wxAssertHandler_t wxTheAssertHandler = wxDefaultAssertHandler; - -void wxSetDefaultAssertHandler() -{ - wxTheAssertHandler = wxDefaultAssertHandler; -} - -void wxOnAssert(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg) -{ - wxTheAssertHandler(file, line, func, cond, msg); -} - -void wxOnAssert(const wxString& file, - int line, - const wxString& func, - const wxString& cond) -{ - wxTheAssertHandler(file, line, func, cond, wxString()); -} - -void wxOnAssert(const wxChar *file, - int line, - const char *func, - const wxChar *cond, - const wxChar *msg) -{ - // this is the backwards-compatible version (unless we don't use Unicode) - // so it could be called directly from the user code and this might happen - // even when wxTheAssertHandler is NULL -#if wxUSE_UNICODE - if ( wxTheAssertHandler ) -#endif // wxUSE_UNICODE - wxTheAssertHandler(file, line, func, cond, msg); -} - -void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxString& msg) -{ - wxTheAssertHandler(file, line, func, cond, msg); -} - -void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxCStrData& msg) -{ - wxTheAssertHandler(file, line, func, cond, msg); -} - -#if wxUSE_UNICODE -void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond) -{ - wxTheAssertHandler(file, line, func, cond, wxString()); -} - -void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const char *msg) -{ - wxTheAssertHandler(file, line, func, cond, msg); -} - -void wxOnAssert(const char *file, - int line, - const char *func, - const char *cond, - const wxChar *msg) -{ - wxTheAssertHandler(file, line, func, cond, msg); -} -#endif // wxUSE_UNICODE - -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ // ============================================================================ // private functions implementation @@ -1200,38 +733,23 @@ static void LINKAGEMODE SetTraceMasks() #endif // wxUSE_LOG } -#endif // __WXDEBUG__ - -#if wxDEBUG_LEVEL - -bool wxTrapInAssert = false; - -static bool DoShowAssertDialog(const wxString& msg) { - // under Windows we can show the dialog even in the console mode -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) + // under MSW we can show the dialog even in the console mode +#if defined(__WXMSW__) && !defined(__WXMICROWIN__) wxString msgDlg(msg); - // this message is intentionally not translated -- it is for developers - // only -- and the less code we use here, less is the danger of recursively - // asserting and dying + // this message is intentionally not translated -- it is for + // developpers only msgDlg += wxT("\nDo you want to stop the program?\n") wxT("You can also choose [Cancel] to suppress ") wxT("further warnings."); - switch ( ::MessageBox(NULL, msgDlg.t_str(), wxT("wxWidgets Debug Alert"), + switch ( ::MessageBox(NULL, msgDlg, _T("wxWidgets Debug Alert"), MB_YESNOCANCEL | MB_ICONSTOP ) ) { case IDYES: - // If we called wxTrap() directly from here, the programmer would - // see this function and a few more calls between his own code and - // it in the stack trace which would be perfectly useless and often - // confusing. So instead just set the flag here and let the macros - // defined in wx/debug.h call wxTrap() themselves, this ensures - // that the debugger will show the line in the user code containing - // the failing assert. - wxTrapInAssert = true; + wxTrap(); break; case IDCANCEL: @@ -1240,21 +758,25 @@ bool DoShowAssertDialog(const wxString& msg) //case IDNO: nothing to do } -#else // !__WINDOWS__ - wxUnusedVar(msg); -#endif // __WINDOWS__/!__WINDOWS__ +#else // !__WXMSW__ + wxFprintf(stderr, wxT("%s\n"), msg.c_str()); + fflush(stderr); - // continue with the asserts by default + // TODO: ask the user to enter "Y" or "N" on the console? + wxTrap(); +#endif // __WXMSW__/!__WXMSW__ + + // continue with the asserts return false; } -// show the standard assert dialog +// show the assert modal dialog static -void ShowAssertDialog(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msgUser, +void ShowAssertDialog(const wxChar *szFile, + int nLine, + const wxChar *szFunc, + const wxChar *szCond, + const wxChar *szMsg, wxAppTraits *traits) { // this variable can be set to true to suppress "assert failure" messages @@ -1266,20 +788,20 @@ void ShowAssertDialog(const wxString& file, // make life easier for people using VC++ IDE by using this format: like // this, clicking on the message will take us immediately to the place of // the failed assert - msg.Printf(wxT("%s(%d): assert \"%s\" failed"), file, line, cond); + msg.Printf(wxT("%s(%d): assert \"%s\" failed"), szFile, nLine, szCond); // add the function name, if any - if ( !func.empty() ) - msg << wxT(" in ") << func << wxT("()"); + if ( szFunc && *szFunc ) + msg << _T(" in ") << szFunc << _T("()"); // and the message itself - if ( !msgUser.empty() ) + if ( szMsg ) { - msg << wxT(": ") << msgUser; + msg << _T(": ") << szMsg; } else // no message given { - msg << wxT('.'); + msg << _T('.'); } #if wxUSE_THREADS @@ -1287,15 +809,27 @@ void ShowAssertDialog(const wxString& file, // since dialogs cannot be displayed if ( !wxThread::IsMain() ) { - msg += wxString::Format(" [in thread %lx]", wxThread::GetCurrentId()); - } -#endif // wxUSE_THREADS + msg += wxT(" [in child thread]"); - // log the assert in any case - wxMessageOutputDebug().Output(msg); +#if defined(__WXMSW__) && !defined(__WXMICROWIN__) + msg << wxT("\r\n"); + OutputDebugString(msg ); +#else + // send to stderr + wxFprintf(stderr, wxT("%s\n"), msg.c_str()); + fflush(stderr); +#endif + // He-e-e-e-elp!! we're asserting in a child thread + wxTrap(); + } + else +#endif // wxUSE_THREADS if ( !s_bNoAsserts ) { + // send it to the normal log destination + wxLogDebug(_T("%s"), msg.c_str()); + if ( traits ) { // delegate showing assert dialog (if possible) to that class @@ -1309,4 +843,4 @@ void ShowAssertDialog(const wxString& file, } } -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ diff --git a/Source/3rd Party/wx/src/common/appcmn.cpp b/Source/3rd Party/wx/src/common/appcmn.cpp index 821f695ba..bc1a30c11 100644 --- a/Source/3rd Party/wx/src/common/appcmn.cpp +++ b/Source/3rd Party/wx/src/common/appcmn.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/common/appcmn.cpp -// Purpose: wxAppBase methods common to all platforms +// Purpose: wxAppConsole and wxAppBase methods common to all platforms // Author: Vadim Zeitlin // Modified by: // Created: 18.10.99 +// RCS-ID: $Id: appcmn.cpp 47229 2007-07-08 05:31:32Z PC $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,15 +32,29 @@ #include "wx/msgdlg.h" #include "wx/confbase.h" #include "wx/utils.h" - #include "wx/wxcrtvararg.h" #endif #include "wx/apptrait.h" #include "wx/cmdline.h" +#include "wx/evtloop.h" #include "wx/msgout.h" #include "wx/thread.h" #include "wx/vidmode.h" -#include "wx/evtloop.h" +#include "wx/ptr_scpd.h" + +#ifdef __WXDEBUG__ + #if wxUSE_STACKWALKER + #include "wx/stackwalk.h" + #endif // wxUSE_STACKWALKER +#endif // __WXDEBUG__ + +#if defined(__WXMSW__) + #include "wx/msw/private.h" // includes windows.h for LOGFONT +#endif + +#if defined(__WXMAC__) + #include "wx/mac/private.h" +#endif #if wxUSE_FONTMAP #include "wx/fontmap.h" @@ -49,6 +64,15 @@ #include "wx/build.h" WX_CHECK_BUILD_OPTIONS("wxCore") +WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; + +// ---------------------------------------------------------------------------- +// wxEventLoopPtr +// ---------------------------------------------------------------------------- + +// this defines wxEventLoopPtr +wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop) + // ============================================================================ // wxAppBase implementation // ============================================================================ @@ -59,13 +83,15 @@ WX_CHECK_BUILD_OPTIONS("wxCore") wxAppBase::wxAppBase() { - m_topWindow = NULL; - + m_topWindow = (wxWindow *)NULL; + m_useBestVisual = false; m_forceTrueColour = false; - + m_isActive = true; + m_mainLoop = NULL; + // We don't want to exit the app if the user code shows a dialog from its // OnInit() -- but this is what would happen if we set m_exitOnFrameDelete // to Yes initially as this dialog would be the last top level window. @@ -83,38 +109,17 @@ wxAppBase::wxAppBase() bool wxAppBase::Initialize(int& argcOrig, wxChar **argvOrig) { -#ifdef __WXOSX__ - // Mac OS X passes a process serial number command line argument when - // the application is launched from the Finder. This argument must be - // removed from the command line arguments before being handled by the - // application (otherwise applications would need to handle it) - // - // Notice that this has to be done for all ports that can be used under OS - // X (e.g. wxGTK) and not just wxOSX itself, hence this code is here and - // not in a port-specific file. - if ( argcOrig > 1 ) - { - static const wxChar *ARG_PSN = wxT("-psn_"); - if ( wxStrncmp(argvOrig[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) - { - // remove this argument - --argcOrig; - memmove(argvOrig + 1, argvOrig + 2, argcOrig * sizeof(wxChar*)); - } - } -#endif // __WXOSX__ - if ( !wxAppConsole::Initialize(argcOrig, argvOrig) ) return false; +#if wxUSE_THREADS + wxPendingEventsLocker = new wxCriticalSection; +#endif + wxInitializeStockLists(); wxBitmap::InitStandardHandlers(); - // for compatibility call the old initialization function too - if ( !OnInitGui() ) - return false; - return true; } @@ -148,9 +153,21 @@ void wxAppBase::CleanUp() wxDeleteStockLists(); - wxDELETE(wxTheColourDatabase); + delete wxTheColourDatabase; + wxTheColourDatabase = NULL; - wxAppConsole::CleanUp(); + delete wxPendingEvents; + wxPendingEvents = NULL; + +#if wxUSE_THREADS + delete wxPendingEventsLocker; + wxPendingEventsLocker = NULL; + + #if wxUSE_VALIDATORS + // If we don't do the following, we get an apparent memory leak. + ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); + #endif // wxUSE_VALIDATORS +#endif // wxUSE_THREADS } // ---------------------------------------------------------------------------- @@ -194,8 +211,8 @@ wxLayoutDirection wxAppBase::GetLayoutDirection() const // GUI-specific command line options handling // ---------------------------------------------------------------------------- -#define OPTION_THEME "theme" -#define OPTION_MODE "mode" +#define OPTION_THEME _T("theme") +#define OPTION_MODE _T("mode") void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser) { @@ -208,7 +225,7 @@ void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser) #ifdef __WXUNIVERSAL__ { wxCMD_LINE_OPTION, - NULL, + wxEmptyString, OPTION_THEME, gettext_noop("specify the theme to use"), wxCMD_LINE_VAL_STRING, @@ -216,22 +233,29 @@ void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser) }, #endif // __WXUNIVERSAL__ -#if defined(__WXDFB__) - // VS: this is not specific to wxDFB, all fullscreen (framebuffer) ports +#if defined(__WXMGL__) + // VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports // should provide this option. That's why it is in common/appcmn.cpp - // and not dfb/app.cpp + // and not mgl/app.cpp { wxCMD_LINE_OPTION, - NULL, + wxEmptyString, OPTION_MODE, gettext_noop("specify display mode to use (e.g. 640x480-16)"), wxCMD_LINE_VAL_STRING, 0x0 }, -#endif // __WXDFB__ +#endif // __WXMGL__ // terminator - wxCMD_LINE_DESC_END + { + wxCMD_LINE_NONE, + wxEmptyString, + wxEmptyString, + wxEmptyString, + wxCMD_LINE_VAL_NONE, + 0x0 + } }; parser.SetDesc(cmdLineGUIDesc); @@ -256,12 +280,12 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser) } #endif // __WXUNIVERSAL__ -#if defined(__WXDFB__) +#if defined(__WXMGL__) wxString modeDesc; if ( parser.Found(OPTION_MODE, &modeDesc) ) { unsigned w, h, bpp; - if ( wxSscanf(modeDesc.c_str(), wxT("%ux%u-%u"), &w, &h, &bpp) != 3 ) + if ( wxSscanf(modeDesc.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3 ) { wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str()); return false; @@ -270,13 +294,52 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser) if ( !SetDisplayMode(wxVideoMode(w, h, bpp)) ) return false; } -#endif // __WXDFB__ +#endif // __WXMGL__ return wxAppConsole::OnCmdLineParsed(parser); } #endif // wxUSE_CMDLINE_PARSER +// ---------------------------------------------------------------------------- +// main event loop implementation +// ---------------------------------------------------------------------------- + +int wxAppBase::MainLoop() +{ + wxEventLoopTiedPtr mainLoop(&m_mainLoop, new wxEventLoop); + + return m_mainLoop->Run(); +} + +void wxAppBase::ExitMainLoop() +{ + // we should exit from the main event loop, not just any currently active + // (e.g. modal dialog) event loop + if ( m_mainLoop && m_mainLoop->IsRunning() ) + { + m_mainLoop->Exit(0); + } +} + +bool wxAppBase::Pending() +{ + // use the currently active message loop here, not m_mainLoop, because if + // we're showing a modal dialog (with its own event loop) currently the + // main event loop is not running anyhow + wxEventLoop * const loop = wxEventLoop::GetActive(); + + return loop && loop->Pending(); +} + +bool wxAppBase::Dispatch() +{ + // see comment in Pending() + wxEventLoop * const loop = wxEventLoop::GetActive(); + + return loop && loop->Dispatch(); +} + // ---------------------------------------------------------------------------- // OnXXX() hooks // ---------------------------------------------------------------------------- @@ -301,7 +364,7 @@ int wxAppBase::OnRun() } //else: it has been changed, assume the user knows what he is doing - return wxAppConsole::OnRun(); + return MainLoop(); } int wxAppBase::OnExit() @@ -313,6 +376,11 @@ int wxAppBase::OnExit() return wxAppConsole::OnExit(); } +void wxAppBase::Exit() +{ + ExitMainLoop(); +} + wxAppTraits *wxAppBase::CreateTraits() { return new wxGUIAppTraits; @@ -335,53 +403,116 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus)) (void)ProcessEvent(event); } -bool wxAppBase::SafeYield(wxWindow *win, bool onlyIfNeeded) -{ - wxWindowDisabler wd(win); - - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - - return loop && loop->Yield(onlyIfNeeded); -} - -bool wxAppBase::SafeYieldFor(wxWindow *win, long eventsToProcess) -{ - wxWindowDisabler wd(win); - - wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - - return loop && loop->YieldFor(eventsToProcess); -} - - // ---------------------------------------------------------------------------- // idle handling // ---------------------------------------------------------------------------- +void wxAppBase::DeletePendingObjects() +{ + wxList::compatibility_iterator node = wxPendingDelete.GetFirst(); + while (node) + { + wxObject *obj = node->GetData(); + + // remove it from the list first so that if we get back here somehow + // during the object deletion (e.g. wxYield called from its dtor) we + // wouldn't try to delete it the second time + if ( wxPendingDelete.Member(obj) ) + wxPendingDelete.Erase(node); + + delete obj; + + // Deleting one object may have deleted other pending + // objects, so start from beginning of list again. + node = wxPendingDelete.GetFirst(); + } +} + // Returns true if more time is needed. bool wxAppBase::ProcessIdle() { - // call the base class version first to send the idle event to wxTheApp - // itself - bool needMore = wxAppConsoleBase::ProcessIdle(); + // process pending wx events before sending idle events + ProcessPendingEvents(); + wxIdleEvent event; + bool needMore = false; wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); while (node) { wxWindow* win = node->GetData(); - - // Don't send idle events to the windows that are about to be destroyed - // anyhow, this is wasteful and unexpected. - if ( !wxPendingDelete.Member(win) && win->SendIdleEvents(event) ) + if (SendIdleEvents(win, event)) needMore = true; node = node->GetNext(); } + event.SetEventObject(this); + (void) ProcessEvent(event); + if (event.MoreRequested()) + needMore = true; + + // 'Garbage' collection of windows deleted with Close(). + DeletePendingObjects(); + +#if wxUSE_LOG + // flush the logged messages if any + wxLog::FlushActive(); +#endif + wxUpdateUIEvent::ResetUpdateTime(); return needMore; } +// Send idle event to window and all subwindows +bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event) +{ + bool needMore = false; + + win->OnInternalIdle(); + + if (wxIdleEvent::CanSend(win)) + { + event.SetEventObject(win); + win->GetEventHandler()->ProcessEvent(event); + + if (event.MoreRequested()) + needMore = true; + } + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); + while ( node ) + { + wxWindow *child = node->GetData(); + if (SendIdleEvents(child, event)) + needMore = true; + + node = node->GetNext(); + } + + return needMore; +} + +void wxAppBase::OnIdle(wxIdleEvent& WXUNUSED(event)) +{ +} + +// ---------------------------------------------------------------------------- +// exceptions support +// ---------------------------------------------------------------------------- + +#if wxUSE_EXCEPTIONS + +bool wxAppBase::OnExceptionInMainLoop() +{ + throw; + + // some compilers are too stupid to know that we never return after throw +#if defined(__DMC__) || (defined(_MSC_VER) && _MSC_VER < 1200) + return false; +#endif +} + +#endif // wxUSE_EXCEPTIONS + // ---------------------------------------------------------------------------- // wxGUIAppTraitsBase // ---------------------------------------------------------------------------- @@ -391,11 +522,7 @@ bool wxAppBase::ProcessIdle() wxLog *wxGUIAppTraitsBase::CreateLogTarget() { #if wxUSE_LOGGUI -#ifndef __WXOSX_IPHONE__ return new wxLogGui; -#else - return new wxLogStderr; -#endif #else // we must have something! return new wxLogStderr; @@ -410,18 +537,15 @@ wxMessageOutput *wxGUIAppTraitsBase::CreateMessageOutput() // is (according to common practice): // - console apps: to stderr (on any platform) // - GUI apps: stderr on Unix platforms (!) - // stderr if available and message box otherwise on others - // (currently stderr only Windows if app running from console) + // message box under Windows and others #ifdef __UNIX__ return new wxMessageOutputStderr; #else // !__UNIX__ // wxMessageOutputMessageBox doesn't work under Motif #ifdef __WXMOTIF__ return new wxMessageOutputLog; - #elif wxUSE_MSGDLG - return new wxMessageOutputBest(wxMSGOUT_PREFER_STDERR); #else - return new wxMessageOutputStderr; + return new wxMessageOutputMessageBox; #endif #endif // __UNIX__/!__UNIX__ } @@ -441,59 +565,77 @@ wxRendererNative *wxGUIAppTraitsBase::CreateRenderer() return NULL; } +#ifdef __WXDEBUG__ + bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg) { -#if wxDEBUG_LEVEL +#if defined(__WXMSW__) || !wxUSE_MSGDLG // under MSW we prefer to use the base class version using ::MessageBox() // even if wxMessageBox() is available because it has less chances to // double fault our app than our wxMessageBox() - // - // under DFB the message dialog is not always functional right now - // - // and finally we can't use wxMessageBox() if it wasn't compiled in, of - // course -#if !defined(__WXMSW__) && !defined(__WXDFB__) && wxUSE_MSGDLG - - // we can't (safely) show the GUI dialog from another thread, only do it - // for the asserts in the main thread - if ( wxIsMainThread() ) - { - wxString msgDlg = msg; + return wxAppTraitsBase::ShowAssertDialog(msg); +#else // wxUSE_MSGDLG + wxString msgDlg = msg; #if wxUSE_STACKWALKER - const wxString stackTrace = GetAssertStackTrace(); - if ( !stackTrace.empty() ) - msgDlg << wxT("\n\nCall stack:\n") << stackTrace; + // on Unix stack frame generation may take some time, depending on the + // size of the executable mainly... warn the user that we are working + wxFprintf(stderr, wxT("[Debug] Generating a stack trace... please wait")); + fflush(stderr); + + const wxString stackTrace = GetAssertStackTrace(); + if ( !stackTrace.empty() ) + msgDlg << _T("\n\nCall stack:\n") << stackTrace; #endif // wxUSE_STACKWALKER - // this message is intentionally not translated -- it is for - // developpers only - msgDlg += wxT("\nDo you want to stop the program?\n") - wxT("You can also choose [Cancel] to suppress ") - wxT("further warnings."); + // this message is intentionally not translated -- it is for + // developpers only + msgDlg += wxT("\nDo you want to stop the program?\n") + wxT("You can also choose [Cancel] to suppress ") + wxT("further warnings."); - switch ( wxMessageBox(msgDlg, wxT("wxWidgets Debug Alert"), - wxYES_NO | wxCANCEL | wxICON_STOP ) ) +#ifdef __WXMAC__ + // in order to avoid reentrancy problems, use the lowest alert API available + CFOptionFlags exitButton; + wxMacCFStringHolder cfText(msgDlg); + OSStatus err = CFUserNotificationDisplayAlert( + 0, kAlertStopAlert, NULL, NULL, NULL, CFSTR("wxWidgets Debug Alert"), cfText, + CFSTR("Yes"), CFSTR("No"), CFSTR("Cancel"), &exitButton ); + if ( err == noErr ) + { + switch( exitButton ) { - case wxYES: + case 0 : // yes wxTrap(); break; - - case wxCANCEL: + case 2 : // cancel // no more asserts return true; - - //case wxNO: nothing to do + case 1 : // no -> nothing to do + break ; } - - return false; } -#endif // wxUSE_MSGDLG -#endif // wxDEBUG_LEVEL +#else + switch ( wxMessageBox(msgDlg, wxT("wxWidgets Debug Alert"), + wxYES_NO | wxCANCEL | wxICON_STOP ) ) + { + case wxYES: + wxTrap(); + break; - return wxAppTraitsBase::ShowAssertDialog(msg); + case wxCANCEL: + // no more asserts + return true; + + //case wxNO: nothing to do + } +#endif + return false; +#endif // !wxUSE_MSGDLG/wxUSE_MSGDLG } +#endif // __WXDEBUG__ + bool wxGUIAppTraitsBase::HasStderr() { // we consider that under Unix stderr always goes somewhere, even if the @@ -505,3 +647,45 @@ bool wxGUIAppTraitsBase::HasStderr() #endif } +void wxGUIAppTraitsBase::ScheduleForDestroy(wxObject *object) +{ + if ( !wxPendingDelete.Member(object) ) + wxPendingDelete.Append(object); +} + +void wxGUIAppTraitsBase::RemoveFromPendingDelete(wxObject *object) +{ + wxPendingDelete.DeleteObject(object); +} + +#if wxUSE_SOCKETS + +#if defined(__WINDOWS__) + #include "wx/msw/gsockmsw.h" +#elif defined(__UNIX__) || defined(__DARWIN__) || defined(__OS2__) + #include "wx/unix/gsockunx.h" +#elif defined(__WXMAC__) + #include + #define OTUNIXERRORS 1 + #include + #include + #include + + #include "wx/mac/gsockmac.h" +#else + #error "Must include correct GSocket header here" +#endif + +GSocketGUIFunctionsTable* wxGUIAppTraitsBase::GetSocketGUIFunctionsTable() +{ +#if defined(__WXMAC__) && !defined(__DARWIN__) + // NB: wxMac CFM does not have any GUI-specific functions in gsocket.c and + // so it doesn't need this table at all + return NULL; +#else // !__WXMAC__ || __DARWIN__ + static GSocketGUIFunctionsTableConcrete table; + return &table; +#endif // !__WXMAC__ || __DARWIN__ +} + +#endif diff --git a/Source/3rd Party/wx/src/common/arcall.cpp b/Source/3rd Party/wx/src/common/arcall.cpp index 49776dcce..bedf19bec 100644 --- a/Source/3rd Party/wx/src/common/arcall.cpp +++ b/Source/3rd Party/wx/src/common/arcall.cpp @@ -2,6 +2,7 @@ // Name: src/common/arcall.cpp // Purpose: wxArchive link all archive streams // Author: Mike Wetherell +// RCS-ID: $Id: arcall.cpp 42508 2006-10-27 09:53:38Z MW $ // Copyright: (c) 2006 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/src/common/arcfind.cpp b/Source/3rd Party/wx/src/common/arcfind.cpp index 6f90d5cc5..c105dc640 100644 --- a/Source/3rd Party/wx/src/common/arcfind.cpp +++ b/Source/3rd Party/wx/src/common/arcfind.cpp @@ -2,6 +2,7 @@ // Name: src/common/arcfind.cpp // Purpose: Streams for archive formats // Author: Mike Wetherell +// RCS-ID: $Id: arcfind.cpp 42508 2006-10-27 09:53:38Z MW $ // Copyright: (c) Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,7 +23,7 @@ // the archive classes they use. const wxArchiveClassFactory * -wxArchiveClassFactory::Find(const wxString& protocol, wxStreamProtocolType type) +wxArchiveClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type) { for (const wxArchiveClassFactory *f = GetFirst(); f; f = f->GetNext()) if (f->CanHandle(protocol, type)) diff --git a/Source/3rd Party/wx/src/common/archive.cpp b/Source/3rd Party/wx/src/common/archive.cpp index 360f22936..1c2dfdb44 100644 --- a/Source/3rd Party/wx/src/common/archive.cpp +++ b/Source/3rd Party/wx/src/common/archive.cpp @@ -2,6 +2,7 @@ // Name: src/common/archive.cpp // Purpose: Streams for archive formats // Author: Mike Wetherell +// RCS-ID: $Id: archive.cpp 42508 2006-10-27 09:53:38Z MW $ // Copyright: (c) Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/src/common/arrstr.cpp b/Source/3rd Party/wx/src/common/arrstr.cpp deleted file mode 100644 index 4111fd087..000000000 --- a/Source/3rd Party/wx/src/common/arrstr.cpp +++ /dev/null @@ -1,576 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/arrstr.cpp -// Purpose: wxArrayString class -// Author: Vadim Zeitlin -// Modified by: -// Created: 29/01/98 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// headers, declarations, constants -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/arrstr.h" -#include "wx/scopedarray.h" - -#include "wx/beforestd.h" -#include -#include -#include "wx/afterstd.h" - -// ============================================================================ -// ArrayString -// ============================================================================ - -wxArrayString::wxArrayString(size_t sz, const char** a) -{ -#if !wxUSE_STD_CONTAINERS - Init(false); -#endif - for (size_t i=0; i < sz; i++) - Add(a[i]); -} - -wxArrayString::wxArrayString(size_t sz, const wchar_t** a) -{ -#if !wxUSE_STD_CONTAINERS - Init(false); -#endif - for (size_t i=0; i < sz; i++) - Add(a[i]); -} - -wxArrayString::wxArrayString(size_t sz, const wxString* a) -{ -#if !wxUSE_STD_CONTAINERS - Init(false); -#endif - for (size_t i=0; i < sz; i++) - Add(a[i]); -} - -#if !wxUSE_STD_CONTAINERS - -// size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT) -#define ARRAY_MAXSIZE_INCREMENT 4096 - -#ifndef ARRAY_DEFAULT_INITIAL_SIZE // also defined in dynarray.h -#define ARRAY_DEFAULT_INITIAL_SIZE (16) -#endif - -// ctor -void wxArrayString::Init(bool autoSort) -{ - m_nSize = - m_nCount = 0; - m_pItems = NULL; - m_autoSort = autoSort; -} - -// copy ctor -wxArrayString::wxArrayString(const wxArrayString& src) -{ - Init(src.m_autoSort); - - *this = src; -} - -// assignment operator -wxArrayString& wxArrayString::operator=(const wxArrayString& src) -{ - if ( m_nSize > 0 ) - Clear(); - - Copy(src); - - m_autoSort = src.m_autoSort; - - return *this; -} - -void wxArrayString::Copy(const wxArrayString& src) -{ - if ( src.m_nCount > ARRAY_DEFAULT_INITIAL_SIZE ) - Alloc(src.m_nCount); - - for ( size_t n = 0; n < src.m_nCount; n++ ) - Add(src[n]); -} - -// grow the array -wxString *wxArrayString::Grow(size_t nIncrement) -{ - if ( (m_nSize - m_nCount) >= nIncrement ) - { - // We already have enough space. - return NULL; - } - - // if ARRAY_DEFAULT_INITIAL_SIZE were set to 0, the initially empty would - // be never resized! - #if ARRAY_DEFAULT_INITIAL_SIZE == 0 - #error "ARRAY_DEFAULT_INITIAL_SIZE must be > 0!" - #endif - - if ( m_nSize == 0 ) { - // was empty, alloc some memory - m_nSize = ARRAY_DEFAULT_INITIAL_SIZE; - if (m_nSize < nIncrement) - m_nSize = nIncrement; - m_pItems = new wxString[m_nSize]; - - // Nothing to free, we hadn't had any memory before. - return NULL; - } - else { - // otherwise when it's called for the first time, nIncrement would be 0 - // and the array would never be expanded - // add 50% but not too much - size_t ndefIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE - ? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1; - if ( ndefIncrement > ARRAY_MAXSIZE_INCREMENT ) - ndefIncrement = ARRAY_MAXSIZE_INCREMENT; - if ( nIncrement < ndefIncrement ) - nIncrement = ndefIncrement; - m_nSize += nIncrement; - wxString *pNew = new wxString[m_nSize]; - - // copy data to new location - for ( size_t j = 0; j < m_nCount; j++ ) - pNew[j] = m_pItems[j]; - - wxString* const pItemsOld = m_pItems; - - m_pItems = pNew; - - return pItemsOld; - } -} - -// deletes all the strings from the list -void wxArrayString::Empty() -{ - m_nCount = 0; -} - -// as Empty, but also frees memory -void wxArrayString::Clear() -{ - m_nSize = - m_nCount = 0; - - wxDELETEA(m_pItems); -} - -// dtor -wxArrayString::~wxArrayString() -{ - delete [] m_pItems; -} - -void wxArrayString::reserve(size_t nSize) -{ - Alloc(nSize); -} - -// pre-allocates memory (frees the previous data!) -void wxArrayString::Alloc(size_t nSize) -{ - // only if old buffer was not big enough - if ( nSize > m_nSize ) { - wxString *pNew = new wxString[nSize]; - if ( !pNew ) - return; - - for ( size_t j = 0; j < m_nCount; j++ ) - pNew[j] = m_pItems[j]; - delete [] m_pItems; - - m_pItems = pNew; - m_nSize = nSize; - } -} - -// minimizes the memory usage by freeing unused memory -void wxArrayString::Shrink() -{ - // only do it if we have some memory to free - if( m_nCount < m_nSize ) { - // allocates exactly as much memory as we need - wxString *pNew = new wxString[m_nCount]; - - // copy data to new location - for ( size_t j = 0; j < m_nCount; j++ ) - pNew[j] = m_pItems[j]; - delete [] m_pItems; - m_pItems = pNew; - m_nSize = m_nCount; - } -} - -// searches the array for an item (forward or backwards) -int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const -{ - if ( m_autoSort ) { - // use binary search in the sorted array - wxASSERT_MSG( bCase && !bFromEnd, - wxT("search parameters ignored for auto sorted array") ); - - size_t i, - lo = 0, - hi = m_nCount; - int res; - while ( lo < hi ) { - i = (lo + hi)/2; - - res = str.compare(m_pItems[i]); - if ( res < 0 ) - hi = i; - else if ( res > 0 ) - lo = i + 1; - else - return i; - } - - return wxNOT_FOUND; - } - else { - // use linear search in unsorted array - if ( bFromEnd ) { - if ( m_nCount > 0 ) { - size_t ui = m_nCount; - do { - if ( m_pItems[--ui].IsSameAs(str, bCase) ) - return ui; - } - while ( ui != 0 ); - } - } - else { - for( size_t ui = 0; ui < m_nCount; ui++ ) { - if( m_pItems[ui].IsSameAs(str, bCase) ) - return ui; - } - } - } - - return wxNOT_FOUND; -} - -// add item at the end -size_t wxArrayString::Add(const wxString& str, size_t nInsert) -{ - if ( m_autoSort ) { - // insert the string at the correct position to keep the array sorted - size_t i, - lo = 0, - hi = m_nCount; - int res; - while ( lo < hi ) { - i = (lo + hi)/2; - - res = str.Cmp(m_pItems[i]); - if ( res < 0 ) - hi = i; - else if ( res > 0 ) - lo = i + 1; - else { - lo = hi = i; - break; - } - } - - wxASSERT_MSG( lo == hi, wxT("binary search broken") ); - - Insert(str, lo, nInsert); - - return (size_t)lo; - } - else { - // Now that we must postpone freeing the old memory until we don't need it - // any more, i.e. don't reference "str" which could be a reference to one - // of our own strings. - wxScopedArray oldStrings(Grow(nInsert)); - - for (size_t i = 0; i < nInsert; i++) - { - // just append - m_pItems[m_nCount + i] = str; - } - size_t ret = m_nCount; - m_nCount += nInsert; - return ret; - } -} - -// add item at the given position -void wxArrayString::Insert(const wxString& str, size_t nIndex, size_t nInsert) -{ - wxCHECK_RET( nIndex <= m_nCount, wxT("bad index in wxArrayString::Insert") ); - wxCHECK_RET( m_nCount <= m_nCount + nInsert, - wxT("array size overflow in wxArrayString::Insert") ); - - wxScopedArray oldStrings(Grow(nInsert)); - - for (int j = m_nCount - nIndex - 1; j >= 0; j--) - m_pItems[nIndex + nInsert + j] = m_pItems[nIndex + j]; - - for (size_t i = 0; i < nInsert; i++) - { - m_pItems[nIndex + i] = str; - } - m_nCount += nInsert; -} - -// range insert (STL 23.2.4.3) -void -wxArrayString::insert(iterator it, const_iterator first, const_iterator last) -{ - const int idx = it - begin(); - - // grow it once - wxScopedArray oldStrings(Grow(last - first)); - - // reset "it" since it can change inside Grow() - it = begin() + idx; - - while ( first != last ) - { - it = insert(it, *first); - - // insert returns an iterator to the last element inserted but we need - // insert the next after this one, that is before the next one - ++it; - - ++first; - } -} - -void wxArrayString::resize(size_type n, value_type v) -{ - if ( n < m_nCount ) - m_nCount = n; - else if ( n > m_nCount ) - Add(v, n - m_nCount); -} - -// expand the array -void wxArrayString::SetCount(size_t count) -{ - Alloc(count); - - wxString s; - while ( m_nCount < count ) - m_pItems[m_nCount++] = s; -} - -// removes item from array (by index) -void wxArrayString::RemoveAt(size_t nIndex, size_t nRemove) -{ - wxCHECK_RET( nIndex < m_nCount, wxT("bad index in wxArrayString::Remove") ); - wxCHECK_RET( nIndex + nRemove <= m_nCount, - wxT("removing too many elements in wxArrayString::Remove") ); - - for ( size_t j = 0; j < m_nCount - nIndex -nRemove; j++) - m_pItems[nIndex + j] = m_pItems[nIndex + nRemove + j]; - - m_nCount -= nRemove; -} - -// removes item from array (by value) -void wxArrayString::Remove(const wxString& sz) -{ - int iIndex = Index(sz); - - wxCHECK_RET( iIndex != wxNOT_FOUND, - wxT("removing inexistent element in wxArrayString::Remove") ); - - RemoveAt(iIndex); -} - -// ---------------------------------------------------------------------------- -// sorting -// ---------------------------------------------------------------------------- - -// we need an adaptor as our predicates use qsort() convention and so return -// negative, null or positive value depending on whether the first item is less -// than, equal to or greater than the other one while we need a real boolean -// predicate now that we use std::sort() -struct wxSortPredicateAdaptor -{ - wxSortPredicateAdaptor(wxArrayString::CompareFunction compareFunction) - : m_compareFunction(compareFunction) - { - } - - bool operator()(const wxString& first, const wxString& second) const - { - return (*m_compareFunction)(first, second) < 0; - } - - wxArrayString::CompareFunction m_compareFunction; -}; - -void wxArrayString::Sort(CompareFunction compareFunction) -{ - wxCHECK_RET( !m_autoSort, wxT("can't use this method with sorted arrays") ); - - std::sort(m_pItems, m_pItems + m_nCount, - wxSortPredicateAdaptor(compareFunction)); -} - -struct wxSortPredicateAdaptor2 -{ - wxSortPredicateAdaptor2(wxArrayString::CompareFunction2 compareFunction) - : m_compareFunction(compareFunction) - { - } - - bool operator()(const wxString& first, const wxString& second) const - { - return (*m_compareFunction)(const_cast(&first), - const_cast(&second)) < 0; - } - - wxArrayString::CompareFunction2 m_compareFunction; -}; - -void wxArrayString::Sort(CompareFunction2 compareFunction) -{ - std::sort(m_pItems, m_pItems + m_nCount, - wxSortPredicateAdaptor2(compareFunction)); -} - -void wxArrayString::Sort(bool reverseOrder) -{ - if ( reverseOrder ) - std::sort(m_pItems, m_pItems + m_nCount, std::greater()); - else // normal sort - std::sort(m_pItems, m_pItems + m_nCount); -} - -bool wxArrayString::operator==(const wxArrayString& a) const -{ - if ( m_nCount != a.m_nCount ) - return false; - - for ( size_t n = 0; n < m_nCount; n++ ) - { - if ( Item(n) != a[n] ) - return false; - } - - return true; -} - -#endif // !wxUSE_STD_CONTAINERS - -// =========================================================================== -// wxJoin and wxSplit -// =========================================================================== - -#include "wx/tokenzr.h" - -wxString wxJoin(const wxArrayString& arr, const wxChar sep, const wxChar escape) -{ - size_t count = arr.size(); - if ( count == 0 ) - return wxEmptyString; - - wxString str; - - // pre-allocate memory using the estimation of the average length of the - // strings in the given array: this is very imprecise, of course, but - // better than nothing - str.reserve(count*(arr[0].length() + arr[count-1].length()) / 2); - - if ( escape == wxT('\0') ) - { - // escaping is disabled: - for ( size_t i = 0; i < count; i++ ) - { - if ( i ) - str += sep; - str += arr[i]; - } - } - else // use escape character - { - for ( size_t n = 0; n < count; n++ ) - { - if ( n ) - str += sep; - - for ( wxString::const_iterator i = arr[n].begin(), - end = arr[n].end(); - i != end; - ++i ) - { - const wxChar ch = *i; - if ( ch == sep ) - str += escape; // escape this separator - str += ch; - } - } - } - - str.Shrink(); // release extra memory if we allocated too much - return str; -} - -wxArrayString wxSplit(const wxString& str, const wxChar sep, const wxChar escape) -{ - if ( escape == wxT('\0') ) - { - // simple case: we don't need to honour the escape character - return wxStringTokenize(str, sep, wxTOKEN_RET_EMPTY_ALL); - } - - wxArrayString ret; - wxString curr; - wxChar prev = wxT('\0'); - - for ( wxString::const_iterator i = str.begin(), - end = str.end(); - i != end; - ++i ) - { - const wxChar ch = *i; - - if ( ch == sep ) - { - if ( prev == escape ) - { - // remove the escape character and don't consider this - // occurrence of 'sep' as a real separator - *curr.rbegin() = sep; - } - else // real separator - { - ret.push_back(curr); - curr.clear(); - } - } - else // normal character - { - curr += ch; - } - - prev = ch; - } - - // add the last token - if ( !curr.empty() || prev == sep ) - ret.Add(curr); - - return ret; -} diff --git a/Source/3rd Party/wx/src/common/artprov.cpp b/Source/3rd Party/wx/src/common/artprov.cpp index f2551614d..5fec0e1c9 100644 --- a/Source/3rd Party/wx/src/common/artprov.cpp +++ b/Source/3rd Party/wx/src/common/artprov.cpp @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 18/03/2002 +// RCS-ID: $Id: artprov.cpp 57701 2008-12-31 23:40:06Z VS $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,6 +30,10 @@ #include "wx/module.h" #endif +#ifdef __WXMSW__ + #include "wx/msw/wrapwin.h" +#endif + // =========================================================================== // implementation // =========================================================================== @@ -42,7 +47,6 @@ WX_DEFINE_LIST(wxArtProvidersList) // ---------------------------------------------------------------------------- WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxBitmap, wxArtProviderBitmapsHash); -WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxIconBundle, wxArtProviderIconBundlesHash); class WXDLLEXPORT wxArtProviderCache { @@ -51,22 +55,14 @@ public: void PutBitmap(const wxString& full_id, const wxBitmap& bmp) { m_bitmapsHash[full_id] = bmp; } - bool GetIconBundle(const wxString& full_id, wxIconBundle* bmp); - void PutIconBundle(const wxString& full_id, const wxIconBundle& iconbundle) - { m_iconBundlesHash[full_id] = iconbundle; } - void Clear(); static wxString ConstructHashID(const wxArtID& id, const wxArtClient& client, const wxSize& size); - static wxString ConstructHashID(const wxArtID& id, - const wxArtClient& client); - private: - wxArtProviderBitmapsHash m_bitmapsHash; // cache of wxBitmaps - wxArtProviderIconBundlesHash m_iconBundlesHash; // cache of wxIconBundles + wxArtProviderBitmapsHash m_bitmapsHash; }; bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp) @@ -83,43 +79,21 @@ bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp) } } -bool wxArtProviderCache::GetIconBundle(const wxString& full_id, wxIconBundle* bmp) -{ - wxArtProviderIconBundlesHash::iterator entry = m_iconBundlesHash.find(full_id); - if ( entry == m_iconBundlesHash.end() ) - { - return false; - } - else - { - *bmp = entry->second; - return true; - } -} - void wxArtProviderCache::Clear() { m_bitmapsHash.clear(); - m_iconBundlesHash.clear(); } -/* static */ wxString -wxArtProviderCache::ConstructHashID(const wxArtID& id, - const wxArtClient& client) +/*static*/ wxString wxArtProviderCache::ConstructHashID( + const wxArtID& id, const wxArtClient& client, + const wxSize& size) { - return id + wxT('-') + client; + wxString str; + str.Printf(wxT("%s-%s-%i-%i"), id.c_str(), client.c_str(), size.x, size.y); + return str; } -/* static */ wxString -wxArtProviderCache::ConstructHashID(const wxArtID& id, - const wxArtClient& client, - const wxSize& size) -{ - return ConstructHashID(id, client) + wxT('-') + - wxString::Format(wxT("%d-%d"), size.x, size.y); -} - // ============================================================================ // wxArtProvider class // ============================================================================ @@ -159,16 +133,21 @@ wxArtProvider::~wxArtProvider() sm_providers->Insert(provider); } -/*static*/ void wxArtProvider::PushBack(wxArtProvider *provider) +/*static*/ void wxArtProvider::Insert(wxArtProvider *provider) { CommonAddingProvider(); sm_providers->Append(provider); } +/*static*/ void wxArtProvider::PushBack(wxArtProvider *provider) +{ + Insert(provider); +} + /*static*/ bool wxArtProvider::Pop() { - wxCHECK_MSG( sm_providers, false, wxT("no wxArtProvider exists") ); - wxCHECK_MSG( !sm_providers->empty(), false, wxT("wxArtProviders stack is empty") ); + wxCHECK_MSG( sm_providers, false, _T("no wxArtProvider exists") ); + wxCHECK_MSG( !sm_providers->empty(), false, _T("wxArtProviders stack is empty") ); delete sm_providers->GetFirst()->GetData(); sm_cache->Clear(); @@ -177,7 +156,7 @@ wxArtProvider::~wxArtProvider() /*static*/ bool wxArtProvider::Remove(wxArtProvider *provider) { - wxCHECK_MSG( sm_providers, false, wxT("no wxArtProvider exists") ); + wxCHECK_MSG( sm_providers, false, _T("no wxArtProvider exists") ); if ( sm_providers->DeleteObject(provider) ) { @@ -203,8 +182,11 @@ wxArtProvider::~wxArtProvider() while ( !sm_providers->empty() ) delete *sm_providers->begin(); - wxDELETE(sm_providers); - wxDELETE(sm_cache); + delete sm_providers; + sm_providers = NULL; + + delete sm_cache; + sm_cache = NULL; } } @@ -217,9 +199,9 @@ wxArtProvider::~wxArtProvider() const wxSize& size) { // safety-check against writing client,id,size instead of id,client,size: - wxASSERT_MSG( client.Last() == wxT('C'), wxT("invalid 'client' parameter") ); + wxASSERT_MSG( client.Last() == _T('C'), _T("invalid 'client' parameter") ); - wxCHECK_MSG( sm_providers, wxNullBitmap, wxT("no wxArtProvider exists") ); + wxCHECK_MSG( sm_providers, wxNullBitmap, _T("no wxArtProvider exists") ); wxString hashId = wxArtProviderCache::ConstructHashID(id, client, size); @@ -230,43 +212,20 @@ wxArtProvider::~wxArtProvider() node; node = node->GetNext()) { bmp = node->GetData()->CreateBitmap(id, client, size); - if ( bmp.IsOk() ) - break; - } - - wxSize sizeNeeded = size; - if ( !bmp.IsOk() ) - { - // no bitmap created -- as a fallback, try if we can find desired - // icon in a bundle - wxIconBundle iconBundle = DoGetIconBundle(id, client); - if ( iconBundle.IsOk() ) + if ( bmp.Ok() ) { - if ( sizeNeeded == wxDefaultSize ) - sizeNeeded = GetNativeSizeHint(client); - - wxIcon icon(iconBundle.GetIcon(sizeNeeded)); - if ( icon.IsOk() ) - { - // this icon may be not of the correct size, it will be - // rescaled below in such case - bmp.CopyFromIcon(icon); - } - } - } - - // if we didn't get the correct size, resize the bitmap #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB) - if ( bmp.IsOk() && sizeNeeded != wxDefaultSize ) - { - if ( bmp.GetSize() != sizeNeeded ) - { - wxImage img = bmp.ConvertToImage(); - img.Rescale(sizeNeeded.x, sizeNeeded.y); - bmp = wxBitmap(img); + if ( size != wxDefaultSize && + (bmp.GetWidth() != size.x || bmp.GetHeight() != size.y) ) + { + wxImage img = bmp.ConvertToImage(); + img.Rescale(size.x, size.y); + bmp = wxBitmap(img); + } +#endif + break; } } -#endif // wxUSE_IMAGE sm_cache->PutBitmap(hashId, bmp); } @@ -274,56 +233,14 @@ wxArtProvider::~wxArtProvider() return bmp; } -/*static*/ -wxIconBundle wxArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client) -{ - wxIconBundle iconbundle(DoGetIconBundle(id, client)); - - if ( iconbundle.IsOk() ) - { - return iconbundle; - } - else - { - // fall back to single-icon bundle - return wxIconBundle(GetIcon(id, client)); - } -} - -/*static*/ -wxIconBundle wxArtProvider::DoGetIconBundle(const wxArtID& id, const wxArtClient& client) -{ - // safety-check against writing client,id,size instead of id,client,size: - wxASSERT_MSG( client.Last() == wxT('C'), wxT("invalid 'client' parameter") ); - - wxCHECK_MSG( sm_providers, wxNullIconBundle, wxT("no wxArtProvider exists") ); - - wxString hashId = wxArtProviderCache::ConstructHashID(id, client); - - wxIconBundle iconbundle; - if ( !sm_cache->GetIconBundle(hashId, &iconbundle) ) - { - for (wxArtProvidersList::compatibility_iterator node = sm_providers->GetFirst(); - node; node = node->GetNext()) - { - iconbundle = node->GetData()->CreateIconBundle(id, client); - if ( iconbundle.IsOk() ) - break; - } - - sm_cache->PutIconBundle(hashId, iconbundle); - } - - return iconbundle; -} - /*static*/ wxIcon wxArtProvider::GetIcon(const wxArtID& id, const wxArtClient& client, const wxSize& size) { - wxBitmap bmp = GetBitmap(id, client, size); + wxCHECK_MSG( sm_providers, wxNullIcon, _T("no wxArtProvider exists") ); - if ( !bmp.IsOk() ) + wxBitmap bmp = GetBitmap(id, client, size); + if ( !bmp.Ok() ) return wxNullIcon; wxIcon icon; @@ -331,28 +248,10 @@ wxIconBundle wxArtProvider::DoGetIconBundle(const wxArtID& id, const wxArtClient return icon; } -/* static */ -wxArtID wxArtProvider::GetMessageBoxIconId(int flags) -{ - switch ( flags & wxICON_MASK ) - { - default: - wxFAIL_MSG(wxT("incorrect message box icon flags")); - // fall through - - case wxICON_ERROR: - return wxART_ERROR; - - case wxICON_INFORMATION: - return wxART_INFORMATION; - - case wxICON_WARNING: - return wxART_WARNING; - - case wxICON_QUESTION: - return wxART_QUESTION; - } -} +#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) + #include "wx/gtk/private.h" + extern GtkIconSize wxArtClientToIconSize(const wxArtClient& client); +#endif // defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) /*static*/ wxSize wxArtProvider::GetSizeHint(const wxArtClient& client, bool platform_dependent) @@ -364,33 +263,41 @@ wxArtID wxArtProvider::GetMessageBoxIconId(int flags) return node->GetData()->DoGetSizeHint(client); } - return GetNativeSizeHint(client); -} + // else return platform dependent size -#ifndef wxHAS_NATIVE_ART_PROVIDER_IMPL -/*static*/ -wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& WXUNUSED(client)) -{ - // rather than returning some arbitrary value that doesn't make much - // sense (as 2.8 used to do), tell the caller that we don't have a clue: - return wxDefaultSize; -} - -/*static*/ -void wxArtProvider::InitNativeProvider() -{ -} -#endif // !wxHAS_NATIVE_ART_PROVIDER_IMPL - - -/* static */ -bool wxArtProvider::HasNativeProvider() -{ -#ifdef __WXGTK20__ - return true; +#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) + // Gtk has specific sizes for each client, see artgtk.cpp + GtkIconSize gtk_size = wxArtClientToIconSize(client); + // no size hints for this client + if (gtk_size == GTK_ICON_SIZE_INVALID) + return wxDefaultSize; + gint width, height; + gtk_icon_size_lookup( gtk_size, &width, &height); + return wxSize(width, height); +#else // !GTK+ 2 + // NB: These size hints may have to be adjusted per platform + if (client == wxART_TOOLBAR) + return wxSize(16, 15); + else if (client == wxART_MENU) + return wxSize(16, 15); + else if (client == wxART_FRAME_ICON) + { +#ifdef __WXMSW__ + return wxSize(::GetSystemMetrics(SM_CXSMICON), + ::GetSystemMetrics(SM_CYSMICON)); #else - return false; -#endif + return wxSize(16, 16); +#endif // __WXMSW__/!__WXMSW__ + } + else if (client == wxART_CMN_DIALOG || client == wxART_MESSAGE_BOX) + return wxSize(32, 32); + else if (client == wxART_HELP_BROWSER) + return wxSize(16, 15); + else if (client == wxART_BUTTON) + return wxSize(16, 15); + else // wxART_OTHER or perhaps a user's client, no specified size + return wxDefaultSize; +#endif // GTK+ 2/else } // ---------------------------------------------------------------------------- @@ -406,7 +313,7 @@ bool wxArtProvider::HasNativeProvider() /* static */ void wxArtProvider::InsertProvider(wxArtProvider *provider) { - PushBack(provider); + Insert(provider); } /* static */ bool wxArtProvider::PopProvider() @@ -423,13 +330,6 @@ bool wxArtProvider::HasNativeProvider() #endif // WXWIN_COMPATIBILITY_2_6 -#if WXWIN_COMPATIBILITY_2_8 -/* static */ void wxArtProvider::Insert(wxArtProvider *provider) -{ - PushBack(provider); -} -#endif // WXWIN_COMPATIBILITY_2_8 - // ============================================================================ // wxArtProviderModule // ============================================================================ @@ -439,16 +339,8 @@ class wxArtProviderModule: public wxModule public: bool OnInit() { - // The order here is such that the native provider will be used first - // and the standard one last as all these default providers add - // themselves to the bottom of the stack. - wxArtProvider::InitNativeProvider(); -#if wxUSE_ARTPROVIDER_TANGO - wxArtProvider::InitTangoProvider(); -#endif // wxUSE_ARTPROVIDER_TANGO -#if wxUSE_ARTPROVIDER_STD wxArtProvider::InitStdProvider(); -#endif // wxUSE_ARTPROVIDER_STD + wxArtProvider::InitNativeProvider(); return true; } void OnExit() diff --git a/Source/3rd Party/wx/src/common/artstd.cpp b/Source/3rd Party/wx/src/common/artstd.cpp index 471146647..c50aae5f6 100644 --- a/Source/3rd Party/wx/src/common/artstd.cpp +++ b/Source/3rd Party/wx/src/common/artstd.cpp @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 18/03/2002 +// RCS-ID: $Id: artstd.cpp 52561 2008-03-16 00:36:37Z VS $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,8 +20,6 @@ #pragma hdrstop #endif -#if wxUSE_ARTPROVIDER_STD - #ifndef WX_PRECOMP #include "wx/image.h" #endif @@ -38,15 +37,6 @@ protected: const wxSize& size); }; -// ---------------------------------------------------------------------------- -// wxArtProvider::InitStdProvider -// ---------------------------------------------------------------------------- - -/*static*/ void wxArtProvider::InitStdProvider() -{ - wxArtProvider::PushBack(new wxDefaultArtProvider); -} - // ---------------------------------------------------------------------------- // helper macros // ---------------------------------------------------------------------------- @@ -55,23 +45,61 @@ protected: #define ART(artId, xpmRc) \ if ( id == artId ) return wxBitmap(xpmRc##_xpm); +// There are two ways of getting the standard icon: either via XPMs or via +// wxIcon ctor. This depends on the platform: +#if defined(__WXUNIVERSAL__) + #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap; +#elif defined(__WXGTK__) || defined(__WXMOTIF__) + #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm); +#else + #define CREATE_STD_ICON(iconId, xpmRc) \ + { \ + wxIcon icon(_T(iconId)); \ + wxBitmap bmp; \ + bmp.CopyFromIcon(icon); \ + return bmp; \ + } +#endif + +// Macro used in CreateBitmap to get wxICON_FOO icons: +#define ART_MSGBOX(artId, iconId, xpmRc) \ + if ( id == artId ) \ + { \ + CREATE_STD_ICON(#iconId, xpmRc) \ + } + +// ---------------------------------------------------------------------------- +// wxArtProvider::InitStdProvider +// ---------------------------------------------------------------------------- + +/*static*/ void wxArtProvider::InitStdProvider() +{ + wxArtProvider::Push(new wxDefaultArtProvider); +} + +#if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__) +/*static*/ void wxArtProvider::InitNativeProvider() +{ +} +#endif + + // ---------------------------------------------------------------------------- // XPMs with the art // ---------------------------------------------------------------------------- -#ifndef __WXUNIVERSAL__ - #if defined(__WXGTK__) - #include "../../art/gtk/info.xpm" - #include "../../art/gtk/error.xpm" - #include "../../art/gtk/warning.xpm" - #include "../../art/gtk/question.xpm" - #elif defined(__WXMOTIF__) - #include "../../art/motif/info.xpm" - #include "../../art/motif/error.xpm" - #include "../../art/motif/warning.xpm" - #include "../../art/motif/question.xpm" - #endif -#endif // !__WXUNIVERSAL__ + +#if defined(__WXGTK__) + #include "../../art/gtk/info.xpm" + #include "../../art/gtk/error.xpm" + #include "../../art/gtk/warning.xpm" + #include "../../art/gtk/question.xpm" +#elif defined(__WXMOTIF__) + #include "../../art/motif/info.xpm" + #include "../../art/motif/error.xpm" + #include "../../art/motif/warning.xpm" + #include "../../art/motif/question.xpm" +#endif #if wxUSE_HTML #include "../../art/htmsidep.xpm" @@ -94,8 +122,6 @@ protected: #include "../../art/helpicon.xpm" #include "../../art/tipicon.xpm" #include "../../art/home.xpm" -#include "../../art/first.xpm" -#include "../../art/last.xpm" #include "../../art/repview.xpm" #include "../../art/listview.xpm" #include "../../art/new_dir.xpm" @@ -120,22 +146,19 @@ protected: #include "../../art/new.xpm" #include "../../art/undo.xpm" #include "../../art/redo.xpm" -#include "../../art/plus.xpm" -#include "../../art/minus.xpm" -#include "../../art/close.xpm" #include "../../art/quit.xpm" #include "../../art/find.xpm" #include "../../art/findrepl.xpm" + + wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id) { -#if !defined(__WXUNIVERSAL__) && (defined(__WXGTK__) || defined(__WXMOTIF__)) // wxMessageBox icons: - ART(wxART_ERROR, error) - ART(wxART_INFORMATION, info) - ART(wxART_WARNING, warning) - ART(wxART_QUESTION, question) -#endif + 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) // standard icons: #if wxUSE_HTML @@ -154,8 +177,6 @@ wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id) ART(wxART_GO_DOWN, down) ART(wxART_GO_TO_PARENT, toparent) ART(wxART_GO_HOME, home) - ART(wxART_GOTO_FIRST, first) - ART(wxART_GOTO_LAST, last) ART(wxART_FILE_OPEN, fileopen) ART(wxART_PRINT, print) ART(wxART_HELP, helpicon) @@ -183,9 +204,6 @@ wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id) ART(wxART_DELETE, delete) ART(wxART_UNDO, undo) ART(wxART_REDO, redo) - ART(wxART_PLUS, plus) - ART(wxART_MINUS, minus) - ART(wxART_CLOSE, close) ART(wxART_QUIT, quit) ART(wxART_FIND, find) ART(wxART_FIND_AND_REPLACE, findrepl) @@ -206,7 +224,7 @@ wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id, wxBitmap bmp = wxDefaultArtProvider_CreateBitmap(id); #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB) - if (bmp.IsOk()) + if (bmp.Ok()) { // fit into transparent image with desired size hint from the client if (reqSize == wxDefaultSize) @@ -218,14 +236,9 @@ wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id, int bmp_w = bmp.GetWidth(); int bmp_h = bmp.GetHeight(); - if (bmp_w == 16 && bmp_h == 15 && bestSize == wxSize(16, 16)) + if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y)) { - // Do nothing in this special but quite common case, because scaling - // with only a pixel difference will look horrible. - } - else if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y)) - { - // the caller wants default size, which is larger than + // the caller wants default size, which is larger than // the image we have; to avoid degrading it visually by // scaling it up, paste it into transparent image instead: wxPoint offset((bestSize.x - bmp_w)/2, (bestSize.y - bmp_h)/2); @@ -252,5 +265,3 @@ wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id, return bmp; } - -#endif // wxUSE_ARTPROVIDER_STD diff --git a/Source/3rd Party/wx/src/common/arttango.cpp b/Source/3rd Party/wx/src/common/arttango.cpp deleted file mode 100644 index 156ae8fc0..000000000 --- a/Source/3rd Party/wx/src/common/arttango.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/arttango.cpp -// Purpose: art provider using embedded PNG versions of Tango icons -// Author: Vadim Zeitlin -// Created: 2010-12-27 -// Copyright: (c) 2010 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ARTPROVIDER_TANGO - -#ifndef WX_PRECOMP - #include "wx/image.h" - #include "wx/log.h" -#endif // WX_PRECOMP - -#include "wx/artprov.h" - -#include "wx/mstream.h" - -// ---------------------------------------------------------------------------- -// image data -// ---------------------------------------------------------------------------- - -// All files in art/tango in alphabetical order: -#include "../../art/tango/application_x_executable.h" -#include "../../art/tango/dialog_error.h" -#include "../../art/tango/dialog_information.h" -#include "../../art/tango/dialog_warning.h" -#include "../../art/tango/document_new.h" -#include "../../art/tango/document_open.h" -#include "../../art/tango/document_print.h" -#include "../../art/tango/document_save.h" -#include "../../art/tango/document_save_as.h" -#include "../../art/tango/drive_harddisk.h" -#include "../../art/tango/drive_optical.h" -#include "../../art/tango/drive_removable_media.h" -#include "../../art/tango/edit_copy.h" -#include "../../art/tango/edit_cut.h" -#include "../../art/tango/edit_delete.h" -#include "../../art/tango/edit_find.h" -#include "../../art/tango/edit_find_replace.h" -#include "../../art/tango/edit_paste.h" -#include "../../art/tango/edit_redo.h" -#include "../../art/tango/edit_undo.h" -#include "../../art/tango/folder.h" -#include "../../art/tango/folder_new.h" -#include "../../art/tango/folder_open.h" -#include "../../art/tango/go_down.h" -#include "../../art/tango/go_first.h" -#include "../../art/tango/go_home.h" -#include "../../art/tango/go_last.h" -#include "../../art/tango/go_next.h" -#include "../../art/tango/go_previous.h" -#include "../../art/tango/go_up.h" -#include "../../art/tango/image_missing.h" -#include "../../art/tango/text_x_generic.h" -#include "../../art/tango/list_add.h" -#include "../../art/tango/list_remove.h" - -// ---------------------------------------------------------------------------- -// art provider class -// ---------------------------------------------------------------------------- - -namespace -{ - -class wxTangoArtProvider : public wxArtProvider -{ -public: - wxTangoArtProvider() - { - m_imageHandledAdded = false; - } - -protected: - virtual wxBitmap CreateBitmap(const wxArtID& id, - const wxArtClient& client, - const wxSize& size); - -private: - bool m_imageHandledAdded; - - wxDECLARE_NO_COPY_CLASS(wxTangoArtProvider); -}; - -} // anonymous namespace - -// ============================================================================ -// implementation -// ============================================================================ - -wxBitmap -wxTangoArtProvider::CreateBitmap(const wxArtID& id, - const wxArtClient& client, - const wxSize& sizeHint) -{ - // Array indexed by the id names with pointers to image data in 16 and 32 - // pixel sizes as values. The order of the elements in this array is the - // same as the definition order in wx/artprov.h. While it's not very - // logical, this should make it simpler to add new icons later. Notice that - // most elements without Tango equivalents are simply omitted. - - // To avoid repetition use BITMAP_DATA to only specify the image name once - // (this is especially important if we decide to add more image sizes - // later). - #define BITMAP_ARRAY_NAME(name, size) \ - name ## _ ## size ## x ## size ## _png - #define BITMAP_DATA_FOR_SIZE(name, size) \ - BITMAP_ARRAY_NAME(name, size), sizeof(BITMAP_ARRAY_NAME(name, size)) - #define BITMAP_DATA(name) \ - BITMAP_DATA_FOR_SIZE(name, 16), BITMAP_DATA_FOR_SIZE(name, 24) - - static const struct BitmapEntry - { - const char *id; - const unsigned char *data16; - size_t len16; - const unsigned char *data24; - size_t len24; - } s_allBitmaps[] = - { - // Tango does have bookmark-new but no matching bookmark-delete and - // using mismatching icons would be ugly so we don't provide this one - // neither, we should add both of them if Tango ever adds the other one. - //{ wxART_ADD_BOOKMARK, BITMAP_DATA(bookmark_new)}, - //{ wxART_DEL_BOOKMARK, BITMAP_DATA() }, - - { wxART_GO_BACK, BITMAP_DATA(go_previous) }, - { wxART_GO_FORWARD, BITMAP_DATA(go_next) }, - { wxART_GO_UP, BITMAP_DATA(go_up) }, - { wxART_GO_DOWN, BITMAP_DATA(go_down) }, - // wxART_GO_TO_PARENT doesn't seem to exist in Tango - { wxART_GO_HOME, BITMAP_DATA(go_home) }, - { wxART_GOTO_FIRST, BITMAP_DATA(go_first) }, - { wxART_GOTO_LAST, BITMAP_DATA(go_last) }, - - { wxART_FILE_OPEN, BITMAP_DATA(document_open) }, - { wxART_FILE_SAVE, BITMAP_DATA(document_save) }, - { wxART_FILE_SAVE_AS, BITMAP_DATA(document_save_as) }, - { wxART_PRINT, BITMAP_DATA(document_print) }, - - // Should we use help-browser for wxART_HELP? - - { wxART_NEW_DIR, BITMAP_DATA(folder_new) }, - { wxART_HARDDISK, BITMAP_DATA(drive_harddisk) }, - // drive-removable-media seems to be better than media-floppy - { wxART_FLOPPY, BITMAP_DATA(drive_removable_media) }, - { wxART_CDROM, BITMAP_DATA(drive_optical) }, - { wxART_REMOVABLE, BITMAP_DATA(drive_removable_media) }, - - { wxART_FOLDER, BITMAP_DATA(folder) }, - { wxART_FOLDER_OPEN, BITMAP_DATA(folder_open) }, - // wxART_GO_DIR_UP doesn't seem to exist in Tango - - { wxART_EXECUTABLE_FILE, BITMAP_DATA(application_x_executable) }, - { wxART_NORMAL_FILE, BITMAP_DATA(text_x_generic) }, - - // There is no dialog-question in Tango so use the information icon - // too, this is better for consistency and we do have a precedent for - // doing this as Windows Vista/7 does the same thing natively. - { wxART_ERROR, BITMAP_DATA(dialog_error) }, - { wxART_QUESTION, BITMAP_DATA(dialog_information) }, - { wxART_WARNING, BITMAP_DATA(dialog_warning) }, - { wxART_INFORMATION, BITMAP_DATA(dialog_information) }, - - { wxART_MISSING_IMAGE, BITMAP_DATA(image_missing) }, - - { wxART_COPY, BITMAP_DATA(edit_copy) }, - { wxART_CUT, BITMAP_DATA(edit_cut) }, - { wxART_PASTE, BITMAP_DATA(edit_paste) }, - { wxART_DELETE, BITMAP_DATA(edit_delete) }, - { wxART_NEW, BITMAP_DATA(document_new) }, - { wxART_UNDO, BITMAP_DATA(edit_undo) }, - { wxART_REDO, BITMAP_DATA(edit_redo) }, - - { wxART_PLUS, BITMAP_DATA(list_add) }, - { wxART_MINUS, BITMAP_DATA(list_remove) }, - - // Surprisingly Tango doesn't seem to have neither wxART_CLOSE nor - // wxART_QUIT. We could use system-log-out for the latter but it - // doesn't seem quite right. - - { wxART_FIND, BITMAP_DATA(edit_find) }, - { wxART_FIND_AND_REPLACE, BITMAP_DATA(edit_find_replace) }, - }; - - #undef BITMAP_ARRAY_NAME - #undef BITMAP_DATA_FOR_SIZE - #undef BITMAP_DATA - - for ( unsigned n = 0; n < WXSIZEOF(s_allBitmaps); n++ ) - { - const BitmapEntry& entry = s_allBitmaps[n]; - if ( entry.id != id ) - continue; - - // This is one of the bitmaps that we have, determine in which size we - // should return it. - - wxSize size; - bool sizeIsAHint; - if ( sizeHint == wxDefaultSize ) - { - // Use the normal platform-specific icon size. - size = GetNativeSizeHint(client); - - if ( size == wxDefaultSize ) - { - // If we failed to get it, determine the best size more or less - // arbitrarily. This definitely won't look good but then it - // shouldn't normally happen, all platforms should implement - // GetNativeSizeHint() properly. - if ( client == wxART_MENU || client == wxART_BUTTON ) - size = wxSize(16, 16); - else - size = wxSize(24, 24); - } - - // We should return the icon of exactly this size so it's more than - // just a hint. - sizeIsAHint = false; - } - else // We have a size hint - { - // Use it for determining the version of the icon to return. - size = sizeHint; - - // But we don't need to return the image of exactly the same size - // as the hint, after all it's just that, a hint. - sizeIsAHint = true; - } - - enum - { - TangoSize_16, - TangoSize_24 - } tangoSize; - - // We prefer to downscale the image rather than upscale it if possible - // so use the smaller one if we can, otherwise the large one. - if ( size.x <= 16 && size.y <= 16 ) - tangoSize = TangoSize_16; - else - tangoSize = TangoSize_24; - - const unsigned char *data; - size_t len; - switch ( tangoSize ) - { - default: - wxFAIL_MSG( "Unsupported Tango bitmap size" ); - // fall through - - case TangoSize_16: - data = entry.data16; - len = entry.len16; - break; - - case TangoSize_24: - data = entry.data24; - len = entry.len24; - break; - } - - wxMemoryInputStream is(data, len); - - // Before reading the image data from the stream for the first time, - // add the handler for PNG images: we do it here and not in, say, - // InitTangoProvider() to do it as lately as possible and so to avoid - // the asserts about adding an already added handler if the user code - // adds the handler itself. - if ( !m_imageHandledAdded ) - { - // Of course, if the user code did add it already, we have nothing - // to do. - if ( !wxImage::FindHandler(wxBITMAP_TYPE_PNG) ) - wxImage::AddHandler(new wxPNGHandler); - - // In any case, no need to do it again. - m_imageHandledAdded = true; - } - - wxImage image(is, wxBITMAP_TYPE_PNG); - if ( !image.IsOk() ) - { - // This should normally never happen as all the embedded images are - // well-formed. - wxLogDebug("Failed to load embedded PNG image for \"%s\"", id); - return wxNullBitmap; - } - - if ( !sizeIsAHint ) - { - // Notice that this won't do anything if the size is already right. - image.Rescale(size.x, size.y, wxIMAGE_QUALITY_HIGH); - } - - return image; - } - - // Not one of the bitmaps that we support. - return wxNullBitmap; -} - -/* static */ -void wxArtProvider::InitTangoProvider() -{ - wxArtProvider::PushBack(new wxTangoArtProvider); -} - -#endif // wxUSE_ARTPROVIDER_TANGO diff --git a/Source/3rd Party/wx/src/common/base64.cpp b/Source/3rd Party/wx/src/common/base64.cpp deleted file mode 100644 index 5ee3a7a3c..000000000 --- a/Source/3rd Party/wx/src/common/base64.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/base64.cpp -// Purpose: implementation of BASE64 encoding/decoding functions -// Author: Charles Reimers, Vadim Zeitlin -// Created: 2007-06-18 -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BASE64 - -#include "wx/base64.h" - -size_t -wxBase64Encode(char *dst, size_t dstLen, const void *src_, size_t srcLen) -{ - wxCHECK_MSG( src_, wxCONV_FAILED, wxT("NULL input buffer") ); - - const unsigned char *src = static_cast(src_); - - static const char b64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - - size_t encLen = 0; - - // encode blocks of 3 bytes into 4 base64 characters - for ( ; srcLen >= 3; srcLen -= 3, src += 3 ) - { - encLen += 4; - if ( dst ) - { - if ( encLen > dstLen ) - return wxCONV_FAILED; - - *dst++ = b64[src[0] >> 2]; - *dst++ = b64[((src[0] & 0x03) << 4) | ((src[1] & 0xf0) >> 4)]; - *dst++ = b64[((src[1] & 0x0f) << 2) | ((src[2] & 0xc0) >> 6)]; - *dst++ = b64[src[2] & 0x3f]; - } - } - - // finish with the remaining characters - if ( srcLen ) - { - encLen += 4; - if ( dst ) - { - if ( encLen > dstLen ) - return wxCONV_FAILED; - - // we have definitely one and maybe two bytes remaining - unsigned char next = srcLen == 2 ? src[1] : 0; - *dst++ = b64[src[0] >> 2]; - *dst++ = b64[((src[0] & 0x03) << 4) | ((next & 0xf0) >> 4)]; - *dst++ = srcLen == 2 ? b64[((next & 0x0f) << 2)] : '='; - *dst = '='; - } - } - - return encLen; -} - -size_t -wxBase64Decode(void *dst_, size_t dstLen, - const char *src, size_t srcLen, - wxBase64DecodeMode mode, - size_t *posErr) -{ - wxCHECK_MSG( src, wxCONV_FAILED, wxT("NULL input buffer") ); - - unsigned char *dst = static_cast(dst_); - - size_t decLen = 0; - - if ( srcLen == wxNO_LEN ) - srcLen = strlen(src); - - // this table contains the values, in base 64, of all valid characters and - // special values WSP or INV for white space and invalid characters - // respectively as well as a special PAD value for '=' - enum - { - WSP = 200, - INV, - PAD - }; - - static const unsigned char decode[256] = - { - WSP,INV,INV,INV,INV,INV,INV,INV,INV,WSP,WSP,INV,WSP,WSP,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - WSP,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,076,INV,INV,INV,077, - 064,065,066,067,070,071,072,073,074,075,INV,INV,INV,PAD,INV,INV, - INV,000,001,002,003,004,005,006,007,010,011,012,013,014,015,016, - 017,020,021,022,023,024,025,026,027,030,031,INV,INV,INV,INV,INV, - INV,032,033,034,035,036,037,040,041,042,043,044,045,046,047,050, - 051,052,053,054,055,056,057,060,061,062,063,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, - }; - - // we decode input by groups of 4 characters but things are complicated by - // the fact that there can be whitespace and other junk in it too so keep - // record of where exactly we're inside the current quartet in this var - int n = 0; - unsigned char in[4]; // current quartet - bool end = false; // set when we find padding - size_t padLen = 0; // length lost to padding - const char *p; - for ( p = src; srcLen; p++, srcLen-- ) - { - const unsigned char c = decode[static_cast(*p)]; - switch ( c ) - { - case WSP: - if ( mode == wxBase64DecodeMode_SkipWS ) - continue; - // fall through - - case INV: - if ( mode == wxBase64DecodeMode_Relaxed ) - continue; - - // force the loop to stop and an error to be returned - n = -1; - srcLen = 1; - break; - - case PAD: - // set the flag telling us that we're past the end now - end = true; - - // there can be either a single '=' at the end of a quartet or - // "==" in positions 2 and 3 - if ( n == 3 ) - { - padLen = 1; - in[n++] = '\0'; - } - else if ( (n == 2) && (--srcLen && *++p == '=') ) - { - padLen = 2; - in[n++] = '\0'; - in[n++] = '\0'; - } - else // invalid padding - { - // force the loop terminate with an error - n = -1; - srcLen = 1; - } - break; - - default: - if ( end ) - { - // nothing is allowed after the end so provoke error return - n = -1; - srcLen = 1; - break; - } - - in[n++] = c; - } - - if ( n == 4 ) - { - // got entire block, decode - decLen += 3 - padLen; - if ( dst ) - { - if ( decLen > dstLen ) - return wxCONV_FAILED; - - // undo the bit shifting done during encoding - *dst++ = in[0] << 2 | in[1] >> 4; - - // be careful to not overwrite the output buffer with NUL pad - // bytes - if ( padLen != 2 ) - { - *dst++ = in[1] << 4 | in[2] >> 2; - if ( !padLen ) - *dst++ = in[2] << 6 | in[3]; - } - } - - n = 0; - } - } - - if ( n ) - { - if ( posErr ) - { - // notice that the error was on a previous position as we did one - // extra "p++" in the loop line after it - *posErr = p - src - 1; - } - - return wxCONV_FAILED; - } - - return decLen; -} - -wxMemoryBuffer wxBase64Decode(const char *src, - size_t srcLen, - wxBase64DecodeMode mode, - size_t *posErr) -{ - wxMemoryBuffer buf; - wxCHECK_MSG( src, buf, wxT("NULL input buffer") ); - - if ( srcLen == wxNO_LEN ) - srcLen = strlen(src); - - size_t len = wxBase64DecodedSize(srcLen); - len = wxBase64Decode(buf.GetWriteBuf(len), len, src, srcLen, mode, posErr); - if ( len == wxCONV_FAILED ) - len = 0; - - buf.SetDataLen(len); - - return buf; -} - -#endif // wxUSE_BASE64 diff --git a/Source/3rd Party/wx/src/common/bmpbase.cpp b/Source/3rd Party/wx/src/common/bmpbase.cpp index 763b9597f..0c7edd3ac 100644 --- a/Source/3rd Party/wx/src/common/bmpbase.cpp +++ b/Source/3rd Party/wx/src/common/bmpbase.cpp @@ -3,6 +3,7 @@ // Purpose: wxBitmapBase // Author: VaclavSlavik // Created: 2001/04/11 +// RCS-ID: $Id: bmpbase.cpp 42752 2006-10-30 19:26:48Z VZ $ // Copyright: (c) 2001, Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,12 +23,6 @@ #include "wx/image.h" #endif // WX_PRECOMP -#if wxUSE_IMAGE && wxUSE_LIBPNG && wxUSE_STREAMS - #define wxHAS_PNG_LOAD - - #include "wx/mstream.h" -#endif - // ---------------------------------------------------------------------------- // wxVariant support // ---------------------------------------------------------------------------- @@ -37,36 +32,6 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxBitmap,WXDLLEXPORT) IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxIcon,WXDLLEXPORT) #endif -#if wxUSE_EXTENDED_RTTI -//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -#endif - -// ---------------------------------------------------------------------------- -// wxBitmapHelpers -// ---------------------------------------------------------------------------- - -// wxOSX has a native version and doesn't use this one. - -#ifndef __WXOSX__ - -/* static */ -wxBitmap wxBitmapHelpers::NewFromPNGData(const void* data, size_t size) -{ - wxBitmap bitmap; - -#ifdef wxHAS_PNG_LOAD - wxMemoryInputStream is(data, size); - wxImage image(is, wxBITMAP_TYPE_PNG); - if ( image.IsOk() ) - bitmap = wxBitmap(image); -#endif // wxHAS_PNG_LOAD - - return bitmap; -} - -#endif // !__WXOSX__ - // ---------------------------------------------------------------------------- // wxBitmapBase // ---------------------------------------------------------------------------- @@ -82,16 +47,16 @@ wxBitmap wxBitmapHelpers::NewFromPNGData(const void* data, size_t size) IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject) -IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject) wxList wxBitmapBase::sm_handlers; -void wxBitmapBase::AddHandler(wxBitmapHandler *handler) +void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler) { sm_handlers.Append(handler); } -void wxBitmapBase::InsertHandler(wxBitmapHandler *handler) +void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler) { sm_handlers.Insert(handler); } @@ -161,6 +126,21 @@ void wxBitmapBase::CleanUpHandlers() } } +bool wxBitmapHandlerBase::Create(wxBitmap*, const void*, long, int, int, int) +{ + return false; +} + +bool wxBitmapHandlerBase::LoadFile(wxBitmap*, const wxString&, long, int, int) +{ + return false; +} + +bool wxBitmapHandlerBase::SaveFile(const wxBitmap*, const wxString&, int, const wxPalette*) +{ + return false; +} + class wxBitmapBaseModule: public wxModule { DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule) @@ -186,11 +166,11 @@ wxBitmap::wxBitmap(const char* const* bits) #if wxUSE_IMAGE && wxUSE_XPM wxImage image(bits); - wxCHECK2_MSG(image.IsOk(), return, wxT("invalid bitmap data")); + wxCHECK2_MSG(image.Ok(), return, wxT("invalid bitmap data")); *this = wxBitmap(image); #else - wxFAIL_MSG(wxT("creating bitmaps from XPMs not supported")); + wxFAIL_MSG(_T("creating bitmaps from XPMs not supported")); #endif // wxUSE_IMAGE && wxUSE_XPM } #endif // !(defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__)) diff --git a/Source/3rd Party/wx/src/common/bmpbtncmn.cpp b/Source/3rd Party/wx/src/common/bmpbtncmn.cpp deleted file mode 100644 index 8760c70c0..000000000 --- a/Source/3rd Party/wx/src/common/bmpbtncmn.cpp +++ /dev/null @@ -1,158 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/bmpbtncmn.cpp -// Purpose: wxBitmapButton common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BMPBUTTON - -#include "wx/bmpbuttn.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/dcmemory.h" - #include "wx/image.h" -#endif - -#include "wx/artprov.h" -#include "wx/renderer.h" - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxBitmapButtonStyle ) -wxBEGIN_FLAGS( wxBitmapButtonStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxBU_AUTODRAW) - wxFLAGS_MEMBER(wxBU_LEFT) - wxFLAGS_MEMBER(wxBU_RIGHT) - wxFLAGS_MEMBER(wxBU_TOP) - wxFLAGS_MEMBER(wxBU_BOTTOM) -wxEND_FLAGS( wxBitmapButtonStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton, wxButton, "wx/bmpbuttn.h") - -wxBEGIN_PROPERTIES_TABLE(wxBitmapButton) - wxPROPERTY_FLAGS( WindowStyle, wxBitmapButtonStyle, long, \ - SetWindowStyleFlag, GetWindowStyleFlag, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), \ - wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxBitmapButton) - -wxCONSTRUCTOR_5( wxBitmapButton, wxWindow*, Parent, wxWindowID, Id, \ - wxBitmap, Bitmap, wxPoint, Position, wxSize, Size ) - -/* -TODO PROPERTIES : - -long "style" , wxBU_AUTODRAW -bool "default" , 0 -bitmap "selected" , -bitmap "focus" , -bitmap "disabled" , -*/ - -namespace -{ - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - -wxBitmap -GetCloseButtonBitmap(wxWindow *win, - const wxSize& size, - const wxColour& colBg, - int flags = 0) -{ - wxBitmap bmp(size); - wxMemoryDC dc(bmp); - dc.SetBackground(colBg); - dc.Clear(); - wxRendererNative::Get(). - DrawTitleBarBitmap(win, dc, size, wxTITLEBAR_BUTTON_CLOSE, flags); - return bmp; -} - -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - -} // anonymous namespace - -/* static */ -wxBitmapButton* -wxBitmapButtonBase::NewCloseButton(wxWindow* parent, wxWindowID winid) -{ - wxCHECK_MSG( parent, NULL, wxS("Must have a valid parent") ); - - const wxColour colBg = parent->GetBackgroundColour(); - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - const wxSize sizeBmp = wxArtProvider::GetSizeHint(wxART_BUTTON); - wxBitmap bmp = GetCloseButtonBitmap(parent, sizeBmp, colBg); -#else // !wxHAS_DRAW_TITLE_BAR_BITMAP - wxBitmap bmp = wxArtProvider::GetBitmap(wxART_CLOSE, wxART_BUTTON); -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - - wxBitmapButton* const button = new wxBitmapButton - ( - parent, - winid, - bmp, - wxDefaultPosition, - wxDefaultSize, - wxBORDER_NONE - ); - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - button->SetBitmapPressed( - GetCloseButtonBitmap(parent, sizeBmp, colBg, wxCONTROL_PRESSED)); - - button->SetBitmapCurrent( - GetCloseButtonBitmap(parent, sizeBmp, colBg, wxCONTROL_CURRENT)); -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - - // The button should blend with its parent background. - button->SetBackgroundColour(colBg); - - return button; -} - -#endif // wxUSE_BMPBUTTON diff --git a/Source/3rd Party/wx/src/common/bmpcboxcmn.cpp b/Source/3rd Party/wx/src/common/bmpcboxcmn.cpp deleted file mode 100644 index 1fa3c83ff..000000000 --- a/Source/3rd Party/wx/src/common/bmpcboxcmn.cpp +++ /dev/null @@ -1,243 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/bmpcboxcmn.cpp -// Purpose: wxBitmapComboBox -// Author: Jaakko Salli -// Created: 2008-04-09 -// Copyright: (c) 2008 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/bmpcbox.h" - -#if wxUSE_BITMAPCOMBOBOX - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/dc.h" - #include "wx/ctrlsub.h" -#endif - -#include "wx/settings.h" - -// For wxODCB_XXX flags -#include "wx/odcombo.h" - - -const char wxBitmapComboBoxNameStr[] = "bitmapComboBox"; - -#if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED) - -#define IMAGE_SPACING_RIGHT 4 // Space left of image - -#define IMAGE_SPACING_LEFT 4 // Space right of image, left of text - -#define EXTRA_FONT_HEIGHT 0 // Add to increase min. height of list items - -#define wxBCB_DEFAULT_ITEM_HEIGHT 13 - - -// This macros allows wxArrayPtrVoid to be used in more convenient manner -#define GetBitmapPtr(n) ((wxBitmap*)m_bitmaps[n]) - - -// ---------------------------------------------------------------------------- -// Initialization -// ---------------------------------------------------------------------------- - -void wxBitmapComboBoxBase::Init() -{ - m_fontHeight = 0; - m_imgAreaWidth = 0; - m_indent = 0; - m_usedImgSize = wxSize(-1, -1); -} - -void wxBitmapComboBoxBase::UpdateInternals() -{ - m_fontHeight = GetControl()->GetCharHeight() + EXTRA_FONT_HEIGHT; - - while ( m_bitmaps.GetCount() < GetItemContainer()->GetCount() ) - m_bitmaps.Add( new wxBitmap() ); -} - -// ---------------------------------------------------------------------------- -// Item manipulation -// ---------------------------------------------------------------------------- - -void wxBitmapComboBoxBase::DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap) -{ - wxCHECK_RET( n < m_bitmaps.size(), "invalid item index" ); - *GetBitmapPtr(n) = bitmap; -} - -wxBitmap wxBitmapComboBoxBase::GetItemBitmap(unsigned int n) const -{ - wxCHECK_MSG( n < m_bitmaps.size(), wxNullBitmap, "invalid item index" ); - return *GetBitmapPtr(n); -} - -// ---------------------------------------------------------------------------- -// wxItemContainer methods -// ---------------------------------------------------------------------------- - -void wxBitmapComboBoxBase::BCBDoClear() -{ - for ( unsigned i = 0; i < m_bitmaps.size(); i++ ) - delete GetBitmapPtr(i); - - m_bitmaps.Empty(); - - m_usedImgSize.x = -1; - m_usedImgSize.y = -1; - - DetermineIndent(); -} - -void wxBitmapComboBoxBase::BCBDoDeleteOneItem(unsigned int n) -{ - delete GetBitmapPtr(n); - m_bitmaps.RemoveAt(n); -} - -// ---------------------------------------------------------------------------- -// Preparation and Calculations -// ---------------------------------------------------------------------------- - -bool wxBitmapComboBoxBase::OnAddBitmap(const wxBitmap& bitmap) -{ - if ( bitmap.IsOk() ) - { - int width = bitmap.GetWidth(); - int height = bitmap.GetHeight(); - - if ( m_usedImgSize.x < 0 ) - { - // If size not yet determined, get it from this image. - m_usedImgSize.x = width; - m_usedImgSize.y = height; - - // Adjust control size to vertically fit the bitmap - wxWindow* ctrl = GetControl(); - ctrl->InvalidateBestSize(); - wxSize newSz = ctrl->GetBestSize(); - wxSize sz = ctrl->GetSize(); - if ( newSz.y > sz.y ) - ctrl->SetSize(sz.x, newSz.y); - else - DetermineIndent(); - } - - wxCHECK_MSG( width == m_usedImgSize.x && height == m_usedImgSize.y, - false, - "you can only add images of same size" ); - - return true; - } - - return false; -} - -int wxBitmapComboBoxBase::DetermineIndent() -{ - // Recalculate amount of empty space needed in front of - // text in control itself. - int indent = m_imgAreaWidth = 0; - - if ( m_usedImgSize.x > 0 ) - { - indent = m_usedImgSize.x + IMAGE_SPACING_LEFT + IMAGE_SPACING_RIGHT; - m_imgAreaWidth = indent; - - indent -= 3; - } - - return indent; -} - -// ---------------------------------------------------------------------------- -// Item drawing and measuring -// ---------------------------------------------------------------------------- - -void wxBitmapComboBoxBase::DrawBackground(wxDC& dc, - const wxRect& rect, - int WXUNUSED(item), - int flags) const -{ - if ( flags & wxODCB_PAINTING_SELECTED ) - { - const int vSizeDec = 0; // Vertical size reduction of selection rectangle edges - - dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); - - wxColour selCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - dc.SetPen(selCol); - dc.SetBrush(selCol); - dc.DrawRectangle(rect.x, - rect.y+vSizeDec, - rect.width, - rect.height-(vSizeDec*2)); - } - else - { - dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - - wxColour selCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - dc.SetPen(selCol); - dc.SetBrush(selCol); - dc.DrawRectangle(rect); - } -} - -void wxBitmapComboBoxBase::DrawItem(wxDC& dc, - const wxRect& rect, - int item, - const wxString& text, - int WXUNUSED(flags)) const -{ - const wxBitmap& bmp = *GetBitmapPtr(item); - if ( bmp.IsOk() ) - { - wxCoord w = bmp.GetWidth(); - wxCoord h = bmp.GetHeight(); - - // Draw the image centered - dc.DrawBitmap(bmp, - rect.x + (m_usedImgSize.x-w)/2 + IMAGE_SPACING_LEFT, - rect.y + (rect.height-h)/2, - true); - } - - if ( !text.empty() ) - dc.DrawText(text, - rect.x + m_imgAreaWidth + 1, - rect.y + (rect.height-dc.GetCharHeight())/2); -} - -wxCoord wxBitmapComboBoxBase::MeasureItem(size_t WXUNUSED(item)) const -{ - if ( m_usedImgSize.y >= 0 ) - { - int imgHeightArea = m_usedImgSize.y + 2; - return imgHeightArea > m_fontHeight ? imgHeightArea : m_fontHeight; - } - - return wxBCB_DEFAULT_ITEM_HEIGHT; -} - -#endif // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED - -#endif // wxUSE_BITMAPCOMBOBOX diff --git a/Source/3rd Party/wx/src/common/bookctrl.cpp b/Source/3rd Party/wx/src/common/bookctrl.cpp index 4b321322b..ca6c2a590 100644 --- a/Source/3rd Party/wx/src/common/bookctrl.cpp +++ b/Source/3rd Party/wx/src/common/bookctrl.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.08.03 +// RCS-ID: $Id: bookctrl.cpp 53783 2008-05-27 14:15:14Z SC $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -52,8 +53,9 @@ END_EVENT_TABLE() void wxBookCtrlBase::Init() { - m_selection = wxNOT_FOUND; m_bookctrl = NULL; + m_imageList = NULL; + m_ownsImageList = false; m_fitToCurrentPage = false; #if defined(__WXWINCE__) @@ -86,6 +88,39 @@ wxBookCtrlBase::Create(wxWindow *parent, ); } +wxBookCtrlBase::~wxBookCtrlBase() +{ + if ( m_ownsImageList ) + { + // may be NULL, ok + delete m_imageList; + } +} + +// ---------------------------------------------------------------------------- +// image list +// ---------------------------------------------------------------------------- + +void wxBookCtrlBase::SetImageList(wxImageList *imageList) +{ + if ( m_ownsImageList ) + { + // may be NULL, ok + delete m_imageList; + + m_ownsImageList = false; + } + + m_imageList = imageList; +} + +void wxBookCtrlBase::AssignImageList(wxImageList* imageList) +{ + SetImageList(imageList); + + m_ownsImageList = true; +} + // ---------------------------------------------------------------------------- // geometry // ---------------------------------------------------------------------------- @@ -102,27 +137,6 @@ void wxBookCtrlBase::DoInvalidateBestSize() wxControl::InvalidateBestSize(); } -wxSize wxBookCtrlBase::CalcSizeFromPage(const wxSize& sizePage) const -{ - // Add the size of the controller and the border between if it's shown. - if ( !m_bookctrl || !m_bookctrl->IsShown() ) - return sizePage; - - // Notice that the controller size is its current size while we really want - // to have its best size. So we only take into account its size in the - // direction in which we should add it but not in the other one, where the - // controller size is determined by the size of wxBookCtrl itself. - const wxSize sizeController = GetControllerSize(); - - wxSize size = sizePage; - if ( IsVertical() ) - size.y += sizeController.y + GetInternalBorder(); - else // left/right aligned - size.x += sizeController.x + GetInternalBorder(); - - return size; -} - void wxBookCtrlBase::SetPageSize(const wxSize& size) { SetClientSize(CalcSizeFromPage(size)); @@ -132,22 +146,26 @@ wxSize wxBookCtrlBase::DoGetBestSize() const { wxSize bestSize; - if (m_fitToCurrentPage && GetCurrentPage()) + // iterate over all pages, get the largest width and height + const size_t nCount = m_pages.size(); + for ( size_t nPage = 0; nPage < nCount; nPage++ ) { - bestSize = GetCurrentPage()->GetBestSize(); - } - else - { - // iterate over all pages, get the largest width and height - const size_t nCount = m_pages.size(); - for ( size_t nPage = 0; nPage < nCount; nPage++ ) + const wxWindow * const pPage = m_pages[nPage]; + if( pPage ) { - const wxWindow * const pPage = m_pages[nPage]; - if ( pPage ) - bestSize.IncTo(pPage->GetBestSize()); + wxSize childBestSize(pPage->GetBestSize()); + + if ( childBestSize.x > bestSize.x ) + bestSize.x = childBestSize.x; + + if ( childBestSize.y > bestSize.y ) + bestSize.y = childBestSize.y; } } + if (m_fitToCurrentPage && GetCurrentPage()) + bestSize = GetCurrentPage()->GetBestSize(); + // convert display area to window area, adding the size necessary for the // tabs wxSize best = CalcSizeFromPage(bestSize); @@ -165,7 +183,7 @@ wxRect wxBookCtrlBase::GetPageRect() const switch ( GetWindowStyle() & wxBK_ALIGN_MASK ) { default: - wxFAIL_MSG( wxT("unexpected alignment") ); + wxFAIL_MSG( _T("unexpected alignment") ); // fall through case wxBK_TOP: @@ -224,7 +242,7 @@ void wxBookCtrlBase::DoSize() switch ( GetWindowStyle() & wxBK_ALIGN_MASK ) { default: - wxFAIL_MSG( wxT("unexpected alignment") ); + wxFAIL_MSG( _T("unexpected alignment") ); // fall through case wxBK_TOP: @@ -247,14 +265,14 @@ void wxBookCtrlBase::DoSize() // resize all pages to fit the new control size const wxRect pageRect = GetPageRect(); - const unsigned pagesCount = m_pages.GetCount(); + const unsigned pagesCount = m_pages.Count(); for ( unsigned int i = 0; i < pagesCount; ++i ) { wxWindow * const page = m_pages[i]; if ( !page ) { wxASSERT_MSG( AllowNullPage(), - wxT("Null page in a control that does not allow null pages?") ); + _T("Null page in a control that does not allow null pages?") ); continue; } @@ -271,25 +289,23 @@ void wxBookCtrlBase::OnSize(wxSizeEvent& event) wxSize wxBookCtrlBase::GetControllerSize() const { - // For at least some book controls (e.g. wxChoicebook) it may make sense to - // (temporarily?) hide the controller and we shouldn't leave extra space - // for the hidden control in this case. - if ( !m_bookctrl || !m_bookctrl->IsShown() ) - return wxSize(0, 0); + if(!m_bookctrl) + return wxSize(0,0); - const wxSize sizeClient = GetClientSize(); + const wxSize sizeClient = GetClientSize(), + sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(), + sizeCtrl = m_bookctrl->GetBestSize() + sizeBorder; wxSize size; - // Ask for the best width/height considering the other direction. if ( IsVertical() ) { size.x = sizeClient.x; - size.y = m_bookctrl->GetBestHeight(sizeClient.x); + size.y = sizeCtrl.y; } else // left/right aligned { - size.x = m_bookctrl->GetBestWidth(sizeClient.y); + size.x = sizeCtrl.x; size.y = sizeClient.y; } @@ -370,9 +386,9 @@ wxBookCtrlBase::InsertPage(size_t nPage, int WXUNUSED(imageId)) { wxCHECK_MSG( page || AllowNullPage(), false, - wxT("NULL page in wxBookCtrlBase::InsertPage()") ); + _T("NULL page in wxBookCtrlBase::InsertPage()") ); wxCHECK_MSG( nPage <= m_pages.size(), false, - wxT("invalid page index in wxBookCtrlBase::InsertPage()") ); + _T("invalid page index in wxBookCtrlBase::InsertPage()") ); m_pages.Insert(page, nPage); if ( page ) @@ -398,7 +414,7 @@ bool wxBookCtrlBase::DeletePage(size_t nPage) wxWindow *wxBookCtrlBase::DoRemovePage(size_t nPage) { wxCHECK_MSG( nPage < m_pages.size(), NULL, - wxT("invalid page index in wxBookCtrlBase::DoRemovePage()") ); + _T("invalid page index in wxBookCtrlBase::DoRemovePage()") ); wxWindow *pageRemoved = m_pages[nPage]; m_pages.RemoveAt(nPage); @@ -430,51 +446,6 @@ int wxBookCtrlBase::GetNextPage(bool forward) const return nPage; } -int wxBookCtrlBase::FindPage(const wxWindow* page) const -{ - const size_t nCount = m_pages.size(); - for ( size_t nPage = 0; nPage < nCount; nPage++ ) - { - if ( m_pages[nPage] == page ) - return (int)nPage; - } - - return wxNOT_FOUND; -} - -bool wxBookCtrlBase::DoSetSelectionAfterInsertion(size_t n, bool bSelect) -{ - if ( bSelect ) - SetSelection(n); - else if ( m_selection == wxNOT_FOUND ) - ChangeSelection(0); - else // We're not going to select this page. - return false; - - // Return true to indicate that we selected this page. - return true; -} - -void wxBookCtrlBase::DoSetSelectionAfterRemoval(size_t n) -{ - if ( m_selection >= (int)n ) - { - // ensure that the selection is valid - int sel; - if ( GetPageCount() == 0 ) - sel = wxNOT_FOUND; - else - sel = m_selection ? m_selection - 1 : 0; - - // if deleting current page we shouldn't try to hide it - m_selection = m_selection == (int)n ? wxNOT_FOUND - : m_selection - 1; - - if ( sel != wxNOT_FOUND && sel != m_selection ) - SetSelection(sel); - } -} - int wxBookCtrlBase::DoSetSelection(size_t n, int flags) { wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND, @@ -484,7 +455,7 @@ int wxBookCtrlBase::DoSetSelection(size_t n, int flags) if ( n != (size_t)oldSel ) { - wxBookCtrlEvent *event = CreatePageChangingEvent(); + wxBookCtrlBaseEvent *event = CreatePageChangingEvent(); bool allowed = false; if ( flags & SetSelection_SendEvent ) @@ -499,11 +470,11 @@ int wxBookCtrlBase::DoSetSelection(size_t n, int flags) if ( !(flags & SetSelection_SendEvent) || allowed) { if ( oldSel != wxNOT_FOUND ) - DoShowPage(m_pages[oldSel], false); + m_pages[oldSel]->Hide(); wxWindow *page = m_pages[n]; page->SetSize(GetPageRect()); - DoShowPage(page, true); + page->Show(); // change selection now to ignore the selection change event UpdateSelectedPage(n); @@ -522,6 +493,5 @@ int wxBookCtrlBase::DoSetSelection(size_t n, int flags) return oldSel; } -IMPLEMENT_DYNAMIC_CLASS(wxBookCtrlEvent, wxNotifyEvent) #endif // wxUSE_BOOKCTRL diff --git a/Source/3rd Party/wx/src/common/btncmn.cpp b/Source/3rd Party/wx/src/common/btncmn.cpp deleted file mode 100644 index cbbfd0f14..000000000 --- a/Source/3rd Party/wx/src/common/btncmn.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/btncmn.cpp -// Purpose: implementation of wxButtonBase -// Author: Vadim Zeitlin -// Created: 2007-04-08 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BUTTON - -#ifndef WX_PRECOMP - #include "wx/button.h" - #include "wx/toplevel.h" -#endif //WX_PRECOMP - -extern WXDLLEXPORT_DATA(const char) wxButtonNameStr[] = "button"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxButtonStyle ) -wxBEGIN_FLAGS( wxButtonStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxBU_LEFT) -wxFLAGS_MEMBER(wxBU_RIGHT) -wxFLAGS_MEMBER(wxBU_TOP) -wxFLAGS_MEMBER(wxBU_BOTTOM) -wxFLAGS_MEMBER(wxBU_EXACTFIT) -wxEND_FLAGS( wxButtonStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxButton, wxControl, "wx/button.h") - -wxBEGIN_PROPERTIES_TABLE(wxButton) -wxEVENT_PROPERTY( Click, wxEVT_BUTTON, wxCommandEvent ) - -wxPROPERTY( Font, wxFont, SetFont, GetFont, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("The font associated with the button label"), wxT("group")) -wxPROPERTY( Label, wxString, SetLabel, GetLabel, wxString(), \ - 0 /*flags*/, wxT("The button label"), wxT("group") ) - -wxPROPERTY_FLAGS( WindowStyle, wxButtonStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("The button style"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxButton) - -wxCONSTRUCTOR_6( wxButton, wxWindow*, Parent, wxWindowID, Id, wxString, \ - Label, wxPoint, Position, wxSize, Size, long, WindowStyle ) - - -// ============================================================================ -// implementation -// ============================================================================ - -wxWindow *wxButtonBase::SetDefault() -{ - wxTopLevelWindow * const - tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); - - wxCHECK_MSG( tlw, NULL, wxT("button without top level window?") ); - - return tlw->SetDefaultItem(this); -} - -void wxAnyButtonBase::SetBitmapPosition(wxDirection dir) -{ - wxASSERT_MSG( !(dir & ~wxDIRECTION_MASK), "non-direction flag used" ); - wxASSERT_MSG( !!(dir & wxLEFT) + - !!(dir & wxRIGHT) + - !!(dir & wxTOP) + - !!(dir & wxBOTTOM) == 1, - "exactly one direction flag must be set" ); - - DoSetBitmapPosition(dir); - -} -#endif // wxUSE_BUTTON diff --git a/Source/3rd Party/wx/src/common/cairo.cpp b/Source/3rd Party/wx/src/common/cairo.cpp deleted file mode 100644 index bfb69a293..000000000 --- a/Source/3rd Party/wx/src/common/cairo.cpp +++ /dev/null @@ -1,440 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/cairo.cpp -// Purpose: Cairo library -// Author: Anthony Betaudeau -// Created: 2007-08-25 -// Copyright: (c) Anthony Bretaudeau -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CAIRO - -// keep cairo.h from defining dllimport as we're defining the symbols inside -// the wx dll in order to load them dynamically. -#define cairo_public - -#include -#include "wx/dynlib.h" - -#ifdef __WXMSW__ -#include "wx/msw/wrapwin.h" -#endif - -#ifdef __WXMAC__ -#include "wx/osx/private.h" -#include -#endif - -#ifndef WX_PRECOMP - #include "wx/module.h" - #include "wx/log.h" -#endif - -#define wxCAIRO_METHOD_TYPE(name) \ - wxCairo##name##_t - -#define wxCAIRO_STATIC_METHOD_DEFINE(rettype, name, args, argnames, defret) \ - static wxCAIRO_METHOD_TYPE(name) name; - -#define wxCAIRO_STATIC_VOIDMETHOD_DEFINE(name, args, argnames) \ - wxCAIRO_STATIC_METHOD_DEFINE(void, name, args, argnames, NULL) - -#define wxFOR_ALL_CAIRO_VOIDMETHODS(m) \ - m( cairo_append_path, \ - (cairo_t *cr, const cairo_path_t *path), (cr, path) ) \ - m( cairo_arc, \ - (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2) ) \ - m( cairo_arc_negative, \ - (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2) ) \ - m( cairo_clip, \ - (cairo_t *cr), (cr) ) \ - m( cairo_close_path, \ - (cairo_t *cr), (cr) ) \ - m( cairo_curve_to, \ - (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3), (cr, x1, y1, x2, y2, x3, y3) ) \ - m( cairo_destroy, \ - (cairo_t *cr), (cr) ) \ - m( cairo_fill, \ - (cairo_t *cr), (cr) ) \ - m( cairo_fill_preserve, \ - (cairo_t *cr), (cr) ) \ - m( cairo_font_extents, \ - (cairo_t *cr, cairo_font_extents_t *extents), (cr, extents) ) \ - m( cairo_font_face_destroy, \ - (cairo_font_face_t *font_face), (font_face) ) \ - m( cairo_get_current_point, \ - (cairo_t *cr, double *x, double *y), (cr, x, y) ) \ - m( cairo_get_matrix, \ - (cairo_t *cr, cairo_matrix_t *matrix), (cr, matrix) ) \ - m( cairo_line_to, \ - (cairo_t *cr, double x, double y), (cr, x, y) ) \ - m( cairo_matrix_init, \ - (cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0), (matrix, xx, yx, xy, yy, x0, y0) ) \ - m( cairo_matrix_multiply, \ - (cairo_matrix_t *result, const cairo_matrix_t *a, const cairo_matrix_t *b), (result, a, b) ) \ - m( cairo_matrix_rotate, \ - (cairo_matrix_t *matrix, double radians), (matrix, radians) ) \ - m( cairo_matrix_scale, \ - (cairo_matrix_t *matrix, double sx, double sy), (matrix, sx, sy) ) \ - m( cairo_matrix_transform_distance, \ - (const cairo_matrix_t *matrix, double *dx, double *dy), (matrix, dx, dy) ) \ - m( cairo_matrix_transform_point, \ - (const cairo_matrix_t *matrix, double *x, double *y), (matrix, x, y) ) \ - m( cairo_matrix_translate, \ - (cairo_matrix_t *matrix, double tx, double ty), (matrix, tx, ty) ) \ - m( cairo_move_to, \ - (cairo_t *cr, double x, double y), (cr, x, y) ) \ - m( cairo_new_path, \ - (cairo_t *cr), (cr) ) \ - m( cairo_paint, \ - (cairo_t *cr), (cr) ) \ - m( cairo_paint_with_alpha, \ - (cairo_t *cr, double alpha), (cr, alpha) ) \ - m( cairo_path_destroy, \ - (cairo_path_t *path), (path) ) \ - m( cairo_pattern_add_color_stop_rgba, \ - (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha), (pattern, offset, red, green, blue, alpha) ) \ - m( cairo_pattern_destroy, \ - (cairo_pattern_t *pattern), (pattern) ) \ - m( cairo_pattern_set_extend, \ - (cairo_pattern_t *pattern, cairo_extend_t extend), (pattern, extend) ) \ - m( cairo_pattern_set_filter, \ - (cairo_pattern_t *pattern, cairo_filter_t filter), (pattern, filter) ) \ - m( cairo_pop_group_to_source, \ - (cairo_t *cr), (cr) ) \ - m( cairo_push_group, \ - (cairo_t *cr), (cr) ) \ - m( cairo_rectangle, \ - (cairo_t *cr, double x, double y, double width, double height), (cr, x, y, width, height) ) \ - m( cairo_reset_clip, \ - (cairo_t *cr), (cr) ) \ - m( cairo_restore, \ - (cairo_t *cr), (cr) ) \ - m( cairo_rotate, \ - (cairo_t *cr, double angle), (cr, angle) ) \ - m( cairo_save, \ - (cairo_t *cr), (cr) ) \ - m( cairo_scale, \ - (cairo_t *cr, double sx, double sy), (cr, sx, sy) ) \ - m( cairo_select_font_face, \ - (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight), (cr, family, slant, weight) ) \ - m( cairo_set_antialias, \ - (cairo_t *cr, cairo_antialias_t antialias), (cr, antialias) ) \ - m( cairo_set_dash, \ - (cairo_t *cr, const double *dashes, int num_dashes, double offset), (cr, dashes, num_dashes, offset) ) \ - m( cairo_set_fill_rule, \ - (cairo_t *cr, cairo_fill_rule_t fill_rule), (cr, fill_rule) ) \ - m( cairo_set_font_face, \ - (cairo_t *cr, cairo_font_face_t *font_face), (cr, font_face) ) \ - m( cairo_set_font_size, \ - (cairo_t *cr, double size), (cr, size) ) \ - m( cairo_set_line_cap, \ - (cairo_t *cr, cairo_line_cap_t line_cap), (cr, line_cap) ) \ - m( cairo_set_line_join, \ - (cairo_t *cr, cairo_line_join_t line_join), (cr, line_join) ) \ - m( cairo_set_line_width, \ - (cairo_t *cr, double width), (cr, width) ) \ - m( cairo_set_matrix, \ - (cairo_t *cr, const cairo_matrix_t *matrix), (cr, matrix) ) \ - m( cairo_set_operator, \ - (cairo_t *cr, cairo_operator_t op), (cr, op) ) \ - m( cairo_set_source, \ - (cairo_t *cr, cairo_pattern_t *source), (cr, source) ) \ - m( cairo_set_source_rgba, \ - (cairo_t *cr, double red, double green, double blue, double alpha), (cr, red, green, blue, alpha) ) \ - m( cairo_show_text, \ - (cairo_t *cr, const char *utf8), (cr, utf8) ) \ - m( cairo_stroke, \ - (cairo_t *cr), (cr) ) \ - m( cairo_stroke_extents, \ - (cairo_t *cr, double *x1, double *y1, double *x2, double *y2), (cr, x1, y1, x2, y2) ) \ - m( cairo_stroke_preserve, \ - (cairo_t *cr), (cr) ) \ - m( cairo_surface_destroy, \ - (cairo_surface_t *surface), (surface) ) \ - m( cairo_text_extents, \ - (cairo_t *cr, const char *utf8, cairo_text_extents_t *extents), (cr, utf8, extents) ) \ - m( cairo_transform, \ - (cairo_t *cr, const cairo_matrix_t *matrix), (cr, matrix) ) \ - m( cairo_translate, \ - (cairo_t *cr, double tx, double ty), (cr, tx, ty) ) \ - -#ifdef __WXMAC__ -#define wxCAIRO_PLATFORM_METHODS(m) \ - m( cairo_font_face_t*, cairo_quartz_font_face_create_for_cgfont, \ - (CGFontRef font), (font), NULL ) \ - m( cairo_surface_t*, cairo_quartz_surface_create_for_cg_context, \ - (CGContextRef cgContext, unsigned int width, unsigned int height), (cgContext, width, height), NULL ) -#elif defined(__WXMSW__) -#define wxCAIRO_PLATFORM_METHODS(m) \ - m( cairo_surface_t*, cairo_win32_surface_create, \ - (HDC hdc), (hdc), NULL ) \ - m( cairo_surface_t*, cairo_win32_printing_surface_create, \ - (HDC hdc), (hdc), NULL ) -#else -#define wxCAIRO_PLATFORM_METHODS(m) -#endif - -#define wxFOR_ALL_CAIRO_METHODS(m) \ - m( cairo_path_t*, cairo_copy_path, \ - (cairo_t *cr), (cr), NULL ) \ - m( cairo_t*, cairo_create, \ - (cairo_surface_t *target), (target), NULL) \ - m( cairo_surface_t*, cairo_get_target, \ - (cairo_t *cr), (cr), NULL) \ - m( cairo_surface_t*, cairo_image_surface_create, \ - (cairo_format_t format, int width, int height), (format, width, height), NULL ) \ - m( cairo_surface_t*, cairo_image_surface_create_for_data, \ - (unsigned char *data, cairo_format_t format, int width, int height, int stride), (data, format, width, height, stride), NULL) \ - m( cairo_bool_t, cairo_in_fill, \ - (cairo_t *cr, double x, double y), (cr, x, y), false ) \ - m( cairo_status_t, cairo_matrix_invert, \ - (cairo_matrix_t *matrix), (matrix), NULL) \ - m( cairo_pattern_t*, cairo_pattern_create_for_surface, \ - (cairo_surface_t *surface), (surface), NULL) \ - m( cairo_pattern_t*, cairo_pattern_create_linear, \ - (double x0, double y0, double x1, double y1), (x0, y0, x1, y1), NULL) \ - m( cairo_pattern_t*, cairo_pattern_create_radial, \ - (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1), (cx0, cy0, radius0, cx1, cy1, radius1), NULL) \ - m( cairo_status_t, cairo_pattern_status, \ - (cairo_pattern_t *pattern), (pattern), 4) \ - m( cairo_t*, cairo_reference, \ - (cairo_t *cr), (cr), NULL ) \ - m( cairo_surface_t*, cairo_surface_create_similar, \ - (cairo_surface_t *other, cairo_content_t content, int width, int height), (other, content, width, height), NULL) \ - m( int, cairo_format_stride_for_width, \ - (cairo_format_t format, int width), (format, width), 0) \ - m( int, cairo_version, \ - (), (), 0) \ - m( int, cairo_image_surface_get_width, \ - (cairo_surface_t *surface), (surface), 0) \ - m( int, cairo_image_surface_get_height, \ - (cairo_surface_t *surface), (surface), 0) \ - m( int, cairo_image_surface_get_stride, \ - (cairo_surface_t *surface), (surface), 0) \ - m( unsigned char *, cairo_image_surface_get_data, \ - (cairo_surface_t *surface), (surface), NULL) \ - m( cairo_format_t, cairo_image_surface_get_format, \ - (cairo_surface_t *surface), (surface), CAIRO_FORMAT_INVALID) \ - m( cairo_surface_type_t, cairo_surface_get_type, \ - (cairo_surface_t *surface), (surface), -1) \ - wxCAIRO_PLATFORM_METHODS(m) - - -#if wxUSE_PANGO -#define wxFOR_ALL_PANGO_CAIRO_VOIDMETHODS(m) \ - m( pango_cairo_update_layout, \ - (cairo_t *cr, PangoLayout *layout), (cr, layout) ) \ - m( pango_cairo_show_layout, \ - (cairo_t *cr, PangoLayout *layout), (cr, layout) ) -#endif - -#define wxCAIRO_DECLARE_TYPE(rettype, name, args, argnames, defret) \ - typedef rettype (*wxCAIRO_METHOD_TYPE(name)) args ; \ - wxCAIRO_METHOD_TYPE(name) wxDL_METHOD_NAME(name); - -#define wxCAIRO_DECLARE_VOIDTYPE(name, args, argnames) \ - wxCAIRO_DECLARE_TYPE(void, name, args, argnames, NULL) - -wxFOR_ALL_CAIRO_VOIDMETHODS(wxCAIRO_DECLARE_VOIDTYPE) -wxFOR_ALL_CAIRO_METHODS(wxCAIRO_DECLARE_TYPE) - - -class wxCairo -{ -public: - static bool Initialize(); - - // for internal use only - static void CleanUp(); - -private: - // the single wxCairo instance or NULL - static wxCairo *ms_lib; - - wxCairo(); - ~wxCairo(); - - bool IsOk(); - - wxDynamicLibrary m_libCairo; - wxDynamicLibrary m_libPangoCairo; - - // true if we successfully loaded the libraries and can use them - // - // note that this field must have this name as it's used by wxDL_XXX macros - bool m_ok; - -public: - - wxFOR_ALL_CAIRO_VOIDMETHODS(wxCAIRO_STATIC_VOIDMETHOD_DEFINE) - wxFOR_ALL_CAIRO_METHODS(wxCAIRO_STATIC_METHOD_DEFINE) -#if wxUSE_PANGO // untested, uncomment to test compilation. - //wxFOR_ALL_PANGO_METHODS(wxDL_STATIC_METHOD_DEFINE) -#endif - - wxDECLARE_NO_COPY_CLASS(wxCairo); -}; - -#define wxINIT_CAIRO_VOIDFUNC(name, params, args) \ - wxCAIRO_METHOD_TYPE(name) wxCairo::name = NULL; - -#define wxINIT_CAIRO_FUNC(rettype, name, params, args, defret) \ - wxCAIRO_METHOD_TYPE(name) wxCairo::name = NULL; - -wxFOR_ALL_CAIRO_VOIDMETHODS(wxINIT_CAIRO_VOIDFUNC) -wxFOR_ALL_CAIRO_METHODS(wxINIT_CAIRO_FUNC) - -#undef wxINIT_CAIRO_FUNC - -wxCairo *wxCairo::ms_lib = NULL; - -//---------------------------------------------------------------------------- -// wxCairoLibrary -//---------------------------------------------------------------------------- - -wxCairo::wxCairo() -{ - wxLogNull log; - -#ifdef __WXMSW__ - wxString cairoDllStr("libcairo-2.dll"); -#else - wxString cairoDllStr("libcairo.so.2"); -#endif - m_libCairo.Load(cairoDllStr); - m_ok = m_libCairo.IsLoaded(); - if ( !m_ok ) - return; - -#if wxUSE_PANGO - m_libPangoCairo.Load("libpangocairo-1.0.so.0"); - m_ok = m_libPangoCairo.IsLoaded(); - if ( !m_ok ) - { - m_libCairo.Unload(); - return; - } -#endif - - -#define wxDO_LOAD_FUNC(name, nameStr) \ - name = (wxCAIRO_METHOD_TYPE(name))m_libCairo.RawGetSymbol(nameStr); \ - if ( !name ) \ - return; - -#define wxLOAD_CAIRO_VOIDFUNC(name, params, args) \ - wxDO_LOAD_FUNC(name, wxSTRINGIZE_T(name)) - -#define wxLOAD_CAIRO_FUNC(rettype, name, params, args, defret) \ - wxDO_LOAD_FUNC(name, wxSTRINGIZE_T(name)) - -wxFOR_ALL_CAIRO_VOIDMETHODS(wxLOAD_CAIRO_VOIDFUNC) -wxFOR_ALL_CAIRO_METHODS(wxLOAD_CAIRO_FUNC) - -#undef wxLOAD_CAIRO_FUNC - - m_ok = true; -} - -wxCairo::~wxCairo() -{ -} - -/* static */ bool wxCairo::Initialize() -{ - if ( !ms_lib ) - { - ms_lib = new wxCairo(); - if ( !ms_lib->IsOk() ) - { - delete ms_lib; - ms_lib = NULL; - } - } - - return ms_lib != NULL; -} - -/* static */ void wxCairo::CleanUp() -{ - if (ms_lib) - { - delete ms_lib; - ms_lib = NULL; - } -} - -bool wxCairo::IsOk() -{ - return m_ok; -} - -// ============================================================================ -// implementation of the functions themselves -// ============================================================================ - -bool wxCairoInit() -{ - return wxCairo::Initialize(); -} - -extern "C" -{ - -#define wxIMPL_CAIRO_FUNC(rettype, name, params, args, defret) \ - rettype name params \ - { \ - wxASSERT_MSG(wxCairo::Initialize(), "Cairo not initialized"); \ - return wxCairo::name args; \ - } - -#define wxIMPL_CAIRO_VOIDFUNC(name, params, args) \ - wxIMPL_CAIRO_FUNC(void, name, params, args, NULL) - -// we currently link directly to Cairo on GTK since it is usually available there, -// so don't use our cairo_xyz wrapper functions until the decision is made to -// always load Cairo dynamically there. -#ifndef __WXGTK__ -wxFOR_ALL_CAIRO_VOIDMETHODS(wxIMPL_CAIRO_VOIDFUNC) -wxFOR_ALL_CAIRO_METHODS(wxIMPL_CAIRO_FUNC) -#endif - -} // extern "C" - -//---------------------------------------------------------------------------- -// wxCairoModule -//---------------------------------------------------------------------------- - -class wxCairoModule : public wxModule -{ -public: - wxCairoModule() { } - virtual bool OnInit(); - virtual void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxCairoModule) -}; - -bool wxCairoModule::OnInit() -{ - return true; -} - -void wxCairoModule::OnExit() -{ - wxCairo::CleanUp(); -} - -IMPLEMENT_DYNAMIC_CLASS(wxCairoModule, wxModule) - -#endif // wxUSE_CAIRO diff --git a/Source/3rd Party/wx/src/common/calctrlcmn.cpp b/Source/3rd Party/wx/src/common/calctrlcmn.cpp deleted file mode 100644 index 2b869127b..000000000 --- a/Source/3rd Party/wx/src/common/calctrlcmn.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/calctrlcmn.cpp -// Author: Marcin Wojdyr -// Created: 2008-03-26 -// Copyright: (C) Marcin Wojdyr -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#endif //WX_PRECOMP - -#if wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL - -#include "wx/dateevt.h" -IMPLEMENT_DYNAMIC_CLASS(wxDateEvent, wxCommandEvent) -wxDEFINE_EVENT(wxEVT_DATE_CHANGED, wxDateEvent); -wxDEFINE_EVENT(wxEVT_TIME_CHANGED, wxDateEvent); - -#endif // wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL - - -#if wxUSE_CALENDARCTRL - -#include "wx/calctrl.h" - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxCalendarCtrlStyle ) -wxBEGIN_FLAGS( wxCalendarCtrlStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxCAL_SUNDAY_FIRST) -wxFLAGS_MEMBER(wxCAL_MONDAY_FIRST) -wxFLAGS_MEMBER(wxCAL_SHOW_HOLIDAYS) -wxFLAGS_MEMBER(wxCAL_NO_YEAR_CHANGE) -wxFLAGS_MEMBER(wxCAL_NO_MONTH_CHANGE) -wxFLAGS_MEMBER(wxCAL_SEQUENTIAL_MONTH_SELECTION) -wxFLAGS_MEMBER(wxCAL_SHOW_SURROUNDING_WEEKS) - -wxEND_FLAGS( wxCalendarCtrlStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxCalendarCtrl, wxControl, "wx/calctrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxCalendarCtrl) -wxEVENT_RANGE_PROPERTY( Updated, wxEVT_CALENDAR_SEL_CHANGED, \ - wxEVT_CALENDAR_WEEKDAY_CLICKED, wxCalendarEvent ) - -wxHIDE_PROPERTY( Children ) - -wxPROPERTY( Date,wxDateTime, SetDate, GetDate, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY_FLAGS( WindowStyle, wxCalendarCtrlStyle, long, \ - SetWindowStyleFlag, GetWindowStyleFlag, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), \ - wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxCalendarCtrl) - -wxCONSTRUCTOR_6( wxCalendarCtrl, wxWindow*, Parent, wxWindowID, Id, \ - wxDateTime, Date, wxPoint, Position, wxSize, Size, long, WindowStyle ) - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxDateEvent) - -wxDEFINE_EVENT( wxEVT_CALENDAR_SEL_CHANGED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_PAGE_CHANGED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_DOUBLECLICKED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_WEEKDAY_CLICKED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_WEEK_CLICKED, wxCalendarEvent ); - -// deprecated events -wxDEFINE_EVENT( wxEVT_CALENDAR_DAY_CHANGED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_MONTH_CHANGED, wxCalendarEvent ); -wxDEFINE_EVENT( wxEVT_CALENDAR_YEAR_CHANGED, wxCalendarEvent ); - - -wxCalendarDateAttr wxCalendarDateAttr::m_mark(wxCAL_BORDER_SQUARE); - -bool wxCalendarCtrlBase::EnableMonthChange(bool enable) -{ - const long styleOrig = GetWindowStyle(); - long style = enable ? styleOrig & ~wxCAL_NO_MONTH_CHANGE - : styleOrig | wxCAL_NO_MONTH_CHANGE; - if ( style == styleOrig ) - return false; - - SetWindowStyle(style); - - return true; -} - -bool wxCalendarCtrlBase::GenerateAllChangeEvents(const wxDateTime& dateOld) -{ - const wxDateTime::Tm tm1 = dateOld.GetTm(), - tm2 = GetDate().GetTm(); - - bool pageChanged = false; - - GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); - if ( tm1.year != tm2.year || tm1.mon != tm2.mon ) - { - GenerateEvent(wxEVT_CALENDAR_PAGE_CHANGED); - - pageChanged = true; - } - - // send also one of the deprecated events - if ( tm1.year != tm2.year ) - GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED); - else if ( tm1.mon != tm2.mon ) - GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED); - else - GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); - - return pageChanged; -} - -void wxCalendarCtrlBase::EnableHolidayDisplay(bool display) -{ - long style = GetWindowStyle(); - if ( display ) - style |= wxCAL_SHOW_HOLIDAYS; - else - style &= ~wxCAL_SHOW_HOLIDAYS; - - if ( style == GetWindowStyle() ) - return; - - SetWindowStyle(style); - - if ( display ) - SetHolidayAttrs(); - else - ResetHolidayAttrs(); - - RefreshHolidays(); -} - -bool wxCalendarCtrlBase::SetHolidayAttrs() -{ - if ( !HasFlag(wxCAL_SHOW_HOLIDAYS) ) - return false; - - ResetHolidayAttrs(); - - wxDateTime::Tm tm = GetDate().GetTm(); - wxDateTime dtStart(1, tm.mon, tm.year), - dtEnd = dtStart.GetLastMonthDay(); - - wxDateTimeArray hol; - wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol); - - const size_t count = hol.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - SetHoliday(hol[n].GetDay()); - } - - return true; -} - -#endif // wxUSE_CALENDARCTRL - diff --git a/Source/3rd Party/wx/src/common/checkboxcmn.cpp b/Source/3rd Party/wx/src/common/checkboxcmn.cpp deleted file mode 100644 index b31d85338..000000000 --- a/Source/3rd Party/wx/src/common/checkboxcmn.cpp +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/checkboxcmn.cpp -// Purpose: wxCheckBox common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CHECKBOX - -#include "wx/checkbox.h" - -extern WXDLLEXPORT_DATA(const char) wxCheckBoxNameStr[] = "check"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxCheckBoxStyle ) -wxBEGIN_FLAGS( wxCheckBoxStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxNO_BORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - -wxEND_FLAGS( wxCheckBoxStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckBox, wxControl, "wx/checkbox.h") - -wxBEGIN_PROPERTIES_TABLE(wxCheckBox) - wxEVENT_PROPERTY( Click, wxEVT_CHECKBOX, wxCommandEvent ) - - wxPROPERTY( Font, wxFont, SetFont, GetFont, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( Value,bool, SetValue, GetValue, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - - wxPROPERTY_FLAGS( WindowStyle, wxCheckBoxStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxCheckBox) - -wxCONSTRUCTOR_6( wxCheckBox, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Label, wxPoint, Position, wxSize, Size, long, WindowStyle ) - - -#endif // wxUSE_CHECKBOX diff --git a/Source/3rd Party/wx/src/common/checklstcmn.cpp b/Source/3rd Party/wx/src/common/checklstcmn.cpp deleted file mode 100644 index be56ca3e1..000000000 --- a/Source/3rd Party/wx/src/common/checklstcmn.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/checklstcmn.cpp -// Purpose: wxCheckListBox common code -// Author: Vadim Zeitlin -// Modified by: -// Created: 16.11.97 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CHECKLISTBOX - -#include "wx/checklst.h" - -#ifndef WX_PRECOMP - #include "wx/object.h" - #include "wx/colour.h" - #include "wx/font.h" - #include "wx/bitmap.h" - #include "wx/window.h" - #include "wx/listbox.h" - #include "wx/dcmemory.h" - #include "wx/settings.h" - #include "wx/log.h" -#endif - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxCheckListBoxStyle ) -wxBEGIN_FLAGS( wxCheckListBoxStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxLB_SINGLE) - wxFLAGS_MEMBER(wxLB_MULTIPLE) - wxFLAGS_MEMBER(wxLB_EXTENDED) - wxFLAGS_MEMBER(wxLB_HSCROLL) - wxFLAGS_MEMBER(wxLB_ALWAYS_SB) - wxFLAGS_MEMBER(wxLB_NEEDED_SB) - wxFLAGS_MEMBER(wxLB_SORT) - wxFLAGS_MEMBER(wxLB_OWNERDRAW) - -wxEND_FLAGS( wxCheckListBoxStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckListBox, wxListBox, "wx/checklst.h") - -wxBEGIN_PROPERTIES_TABLE(wxCheckListBox) - wxEVENT_PROPERTY( Toggle, wxEVT_CHECKLISTBOX, wxCommandEvent ) - wxPROPERTY_FLAGS( WindowStyle, wxCheckListBoxStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, wxLB_OWNERDRAW /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxCheckListBox) - -wxCONSTRUCTOR_4( wxCheckListBox, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size ) - - -// ============================================================================ -// implementation -// ============================================================================ - -unsigned int wxCheckListBoxBase::GetCheckedItems(wxArrayInt& checkedItems) const -{ - unsigned int const numberOfItems = GetCount(); - - checkedItems.clear(); - for ( unsigned int i = 0; i < numberOfItems; ++i ) - { - if ( IsChecked(i) ) - checkedItems.push_back(i); - } - - return checkedItems.size(); -} - -#endif diff --git a/Source/3rd Party/wx/src/common/choiccmn.cpp b/Source/3rd Party/wx/src/common/choiccmn.cpp index 6ac940b42..7febe79e6 100644 --- a/Source/3rd Party/wx/src/common/choiccmn.cpp +++ b/Source/3rd Party/wx/src/common/choiccmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.07.99 +// RCS-ID: $Id: choiccmn.cpp 39470 2006-05-30 07:34:30Z ABX $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,73 +28,10 @@ #include "wx/choice.h" -#include "wx/private/textmeasure.h" - #ifndef WX_PRECOMP #endif -const char wxChoiceNameStr[] = "choice"; - - -wxDEFINE_FLAGS( wxChoiceStyle ) -wxBEGIN_FLAGS( wxChoiceStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxEND_FLAGS( wxChoiceStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h") - -wxBEGIN_PROPERTIES_TABLE(wxChoice) -wxEVENT_PROPERTY( Select, wxEVT_CHOICE, wxCommandEvent ) - -wxPROPERTY( Font, wxFont, SetFont, GetFont , wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY_COLLECTION( Choices, wxArrayString, wxString, AppendString, \ - GetStrings, 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY( Selection,int, SetSelection, GetSelection, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - -/* - TODO PROPERTIES - selection (long) - content (list) - item - */ - -wxPROPERTY_FLAGS( WindowStyle, wxChoiceStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxChoice) - -wxCONSTRUCTOR_4( wxChoice, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size ) +const wxChar wxChoiceNameStr[] = wxT("choice"); // ============================================================================ // implementation @@ -104,21 +42,6 @@ wxChoiceBase::~wxChoiceBase() // this destructor is required for Darwin } -wxSize wxChoiceBase::DoGetBestSize() const -{ - // a reasonable width for an empty choice list - wxSize best(80, -1); - - const unsigned int nItems = GetCount(); - if ( nItems > 0 ) - { - wxTextMeasure txm(this); - best.x = txm.GetLargestStringExtent(GetStrings()).x; - } - - return best; -} - // ---------------------------------------------------------------------------- // misc // ---------------------------------------------------------------------------- @@ -126,7 +49,7 @@ wxSize wxChoiceBase::DoGetBestSize() const void wxChoiceBase::Command(wxCommandEvent& event) { SetSelection(event.GetInt()); - (void)GetEventHandler()->ProcessEvent(event); + (void)ProcessEvent(event); } #endif // wxUSE_CHOICE diff --git a/Source/3rd Party/wx/src/common/clipcmn.cpp b/Source/3rd Party/wx/src/common/clipcmn.cpp index b10894425..2421c48fe 100644 --- a/Source/3rd Party/wx/src/common/clipcmn.cpp +++ b/Source/3rd Party/wx/src/common/clipcmn.cpp @@ -4,6 +4,7 @@ // Author: Robert Roebling // Modified by: // Created: 28.06.99 +// RCS-ID: $Id: clipcmn.cpp 40943 2006-08-31 19:31:43Z ABX $ // Copyright: (c) Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,45 +29,9 @@ #include "wx/clipbrd.h" #ifndef WX_PRECOMP - #include "wx/dataobj.h" #include "wx/module.h" #endif -// --------------------------------------------------------- -// wxClipboardEvent -// --------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent) - -wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent ); - -bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const -{ -#ifdef __WXGTK20__ - for (wxVector::size_type n = 0; n < m_formats.size(); n++) - { - if (m_formats[n] == format) - return true; - } - - return false; -#else - // All other ports just query the clipboard directly - // from here - wxClipboard* clipboard = (wxClipboard*) GetEventObject(); - return clipboard->IsSupported( format ); -#endif -} - -void wxClipboardEvent::AddFormat(const wxDataFormat& format) -{ - m_formats.push_back( format ); -} - -// --------------------------------------------------------- -// wxClipboardBase -// --------------------------------------------------------- - static wxClipboard *gs_clipboard = NULL; /*static*/ wxClipboard *wxClipboardBase::Get() @@ -78,19 +43,6 @@ static wxClipboard *gs_clipboard = NULL; return gs_clipboard; } -bool wxClipboardBase::IsSupportedAsync( wxEvtHandler *sink ) -{ - // We just imitate an asynchronous API on most platforms. - // This method is overridden uner GTK. - wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED); - event->SetEventObject( this ); - - sink->QueueEvent( event ); - - return true; -} - - // ---------------------------------------------------------------------------- // wxClipboardModule: module responsible for destroying the global clipboard // object diff --git a/Source/3rd Party/wx/src/common/clntdata.cpp b/Source/3rd Party/wx/src/common/clntdata.cpp index 1cb559578..d226f15b3 100644 --- a/Source/3rd Party/wx/src/common/clntdata.cpp +++ b/Source/3rd Party/wx/src/common/clntdata.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/clntdata.cpp +// Name: common/clntdata.cpp // Purpose: A mixin class for holding a wxClientData or void pointer // Author: Robin Dunn // Modified by: // Created: 9-Oct-2001 +// RCS-ID: $Id: clntdata.cpp 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/src/common/clrpickercmn.cpp b/Source/3rd Party/wx/src/common/clrpickercmn.cpp index 832017859..8e21d7f6e 100644 --- a/Source/3rd Party/wx/src/common/clrpickercmn.cpp +++ b/Source/3rd Party/wx/src/common/clrpickercmn.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi (readapted code written by Vadim Zeitlin) // Modified by: // Created: 15/04/2006 +// RCS-ID: $Id: clrpickercmn.cpp 42219 2006-10-21 19:53:05Z PC $ // Copyright: (c) Vadim Zeitlin, Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -31,14 +32,14 @@ #include "wx/textctrl.h" #endif -const char wxColourPickerCtrlNameStr[] = "colourpicker"; -const char wxColourPickerWidgetNameStr[] = "colourpickerwidget"; +const wxChar wxColourPickerCtrlNameStr[] = wxT("colourpicker"); +const wxChar wxColourPickerWidgetNameStr[] = wxT("colourpickerwidget"); // ============================================================================ // implementation // ============================================================================ -wxDEFINE_EVENT(wxEVT_COLOURPICKER_CHANGED, wxColourPickerEvent); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_COLOURPICKER_CHANGED) IMPLEMENT_DYNAMIC_CLASS(wxColourPickerCtrl, wxPickerBase) IMPLEMENT_DYNAMIC_CLASS(wxColourPickerEvent, wxEvent) @@ -67,7 +68,7 @@ bool wxColourPickerCtrl::Create( wxWindow *parent, wxWindowID id, // complete sizer creation wxPickerBase::PostCreation(); - m_picker->Connect(wxEVT_COLOURPICKER_CHANGED, + m_picker->Connect(wxEVT_COMMAND_COLOURPICKER_CHANGED, wxColourPickerEventHandler(wxColourPickerCtrl::OnColourChange), NULL, this); @@ -83,7 +84,7 @@ void wxColourPickerCtrl::SetColour(const wxColour &col) bool wxColourPickerCtrl::SetColour(const wxString &text) { wxColour col(text); // smart wxString->wxColour conversion - if ( !col.IsOk() ) + if ( !col.Ok() ) return false; M_PICKER->SetColour(col); UpdateTextCtrlFromPicker(); @@ -95,9 +96,16 @@ void wxColourPickerCtrl::UpdatePickerFromTextCtrl() { wxASSERT(m_text); + if (m_bIgnoreNextTextCtrlUpdate) + { + // ignore this update + m_bIgnoreNextTextCtrlUpdate = false; + return; + } + // wxString -> wxColour conversion wxColour col(m_text->GetValue()); - if ( !col.IsOk() ) + if ( !col.Ok() ) return; // invalid user input if (M_PICKER->GetColour() != col) @@ -115,9 +123,11 @@ void wxColourPickerCtrl::UpdateTextCtrlFromPicker() if (!m_text) return; // no textctrl to update - // Take care to use ChangeValue() here and not SetValue() to avoid - // infinite recursion. - m_text->ChangeValue(M_PICKER->GetColour().GetAsString()); + // NOTE: this SetValue() will generate an unwanted wxEVT_COMMAND_TEXT_UPDATED + // which will trigger a unneeded UpdateFromTextCtrl(); thus before using + // SetValue() we set the m_bIgnoreNextTextCtrlUpdate flag... + m_bIgnoreNextTextCtrlUpdate = true; + m_text->SetValue(M_PICKER->GetColour().GetAsString()); } diff --git a/Source/3rd Party/wx/src/common/cmdline.cpp b/Source/3rd Party/wx/src/common/cmdline.cpp index 1362a6577..c7b135d0c 100644 --- a/Source/3rd Party/wx/src/common/cmdline.cpp +++ b/Source/3rd Party/wx/src/common/cmdline.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05.01.00 +// RCS-ID: $Id: cmdline.cpp 66920 2011-02-16 22:00:30Z JS $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -36,13 +37,10 @@ #if wxUSE_CMDLINE_PARSER #include -#include // for LC_ALL #include "wx/datetime.h" #include "wx/msgout.h" #include "wx/filename.h" -#include "wx/apptrait.h" -#include "wx/scopeguard.h" // ---------------------------------------------------------------------------- // private functions @@ -50,15 +48,11 @@ static wxString GetTypeName(wxCmdLineParamType type); -static wxString GetOptionName(wxString::const_iterator p, - wxString::const_iterator end, - const wxChar *allowedChars); +static wxString GetOptionName(const wxChar *p, const wxChar *allowedChars); -static wxString GetShortOptionName(wxString::const_iterator p, - wxString::const_iterator end); +static wxString GetShortOptionName(const wxChar *p); -static wxString GetLongOptionName(wxString::const_iterator p, - wxString::const_iterator end); +static wxString GetLongOptionName(const wxChar *p); // ---------------------------------------------------------------------------- // private structs @@ -74,27 +68,21 @@ struct wxCmdLineOption wxCmdLineParamType typ, int fl) { - // wxCMD_LINE_USAGE_TEXT uses only description, shortName and longName is empty - if ( k != wxCMD_LINE_USAGE_TEXT ) - { - wxASSERT_MSG - ( - !shrt.empty() || !lng.empty(), - wxT("option should have at least one name") - ); + wxASSERT_MSG( !shrt.empty() || !lng.empty(), + _T("option should have at least one name") ); - wxASSERT_MSG + wxASSERT_MSG ( - GetShortOptionName(shrt.begin(), shrt.end()).Len() == shrt.Len(), + GetShortOptionName(shrt).Len() == shrt.Len(), wxT("Short option contains invalid characters") ); - wxASSERT_MSG + wxASSERT_MSG ( - GetLongOptionName(lng.begin(), lng.end()).Len() == lng.Len(), + GetLongOptionName(lng).Len() == lng.Len(), wxT("Long option contains invalid characters") ); - } + kind = k; @@ -105,7 +93,7 @@ struct wxCmdLineOption type = typ; flags = fl; - Reset(); + m_hasVal = false; } // can't use union easily here, so just store all possible data fields, we @@ -115,11 +103,9 @@ struct wxCmdLineOption void Check(wxCmdLineParamType WXUNUSED_UNLESS_DEBUG(typ)) const { - wxASSERT_MSG( type == typ, wxT("type mismatch in wxCmdLineOption") ); + wxASSERT_MSG( type == typ, _T("type mismatch in wxCmdLineOption") ); } - double GetDoubleVal() const - { Check(wxCMD_LINE_VAL_DOUBLE); return m_doubleVal; } long GetLongVal() const { Check(wxCMD_LINE_VAL_NUMBER); return m_longVal; } const wxString& GetStrVal() const @@ -129,8 +115,6 @@ struct wxCmdLineOption { Check(wxCMD_LINE_VAL_DATE); return m_dateVal; } #endif // wxUSE_DATETIME - void SetDoubleVal(double val) - { Check(wxCMD_LINE_VAL_DOUBLE); m_doubleVal = val; m_hasVal = true; } void SetLongVal(long val) { Check(wxCMD_LINE_VAL_NUMBER); m_longVal = val; m_hasVal = true; } void SetStrVal(const wxString& val) @@ -140,25 +124,9 @@ struct wxCmdLineOption { Check(wxCMD_LINE_VAL_DATE); m_dateVal = val; m_hasVal = true; } #endif // wxUSE_DATETIME - void SetHasValue() { m_hasVal = true; } + void SetHasValue(bool hasValue = true) { m_hasVal = hasValue; } bool HasValue() const { return m_hasVal; } - void SetNegated() { m_isNegated = true; } - bool IsNegated() const - { - wxASSERT_MSG( kind == wxCMD_LINE_SWITCH, - wxT("kind mismatch in wxCmdLineArg") ); - - return m_isNegated; - } - - // Reset to the initial state, called before parsing another command line. - void Reset() - { - m_hasVal = - m_isNegated = false; - } - public: wxCmdLineEntryType kind; wxString shortName, @@ -169,9 +137,7 @@ public: private: bool m_hasVal; - bool m_isNegated; - double m_doubleVal; long m_longVal; wxString m_strVal; #if wxUSE_DATETIME @@ -213,7 +179,7 @@ struct wxCmdLineParserData // cmd line data wxArrayString m_arguments; // == argv, argc == m_arguments.GetCount() - wxArrayOptions m_options; // all possible options and switches + wxArrayOptions m_options; // all possible options and switchrs wxArrayParams m_paramDesc; // description of all possible params wxArrayString m_parameters; // all params found @@ -222,17 +188,11 @@ struct wxCmdLineParserData void SetArguments(int argc, char **argv); #if wxUSE_UNICODE void SetArguments(int argc, wxChar **argv); - void SetArguments(int argc, const wxCmdLineArgsArray& argv); #endif // wxUSE_UNICODE void SetArguments(const wxString& cmdline); int FindOption(const wxString& name); int FindOptionByLongName(const wxString& name); - - // Find the option by either its short or long name. - // - // Asserts and returns NULL if option with this name is not found. - const wxCmdLineOption* FindOptionByAnyName(const wxString& name); }; // ============================================================================ @@ -247,52 +207,19 @@ wxCmdLineParserData::wxCmdLineParserData() { m_enableLongOptions = true; #ifdef __UNIX_LIKE__ - m_switchChars = wxT("-"); + m_switchChars = _T("-"); #else // !Unix - m_switchChars = wxT("/-"); + m_switchChars = _T("/-"); #endif } -namespace -{ - -// Small helper function setting locale for all categories. -// -// We define it because wxSetlocale() can't be easily used with wxScopeGuard as -// it has several overloads -- while this one can. -inline char *SetAllLocaleFacets(const char *loc) -{ - return wxSetlocale(LC_ALL, loc); -} - -} // private namespace - void wxCmdLineParserData::SetArguments(int argc, char **argv) { m_arguments.clear(); - // Command-line arguments are supposed to be in the user locale encoding - // (what else?) but wxLocale probably wasn't initialized yet as we're - // called early during the program startup and so our locale might not have - // been set from the environment yet. To work around this problem we - // temporarily change the locale here. The only drawback is that changing - // the locale is thread-unsafe but precisely because we're called so early - // it's hopefully safe to assume that no other threads had been created yet. - char * const locOld = SetAllLocaleFacets(NULL); - SetAllLocaleFacets(""); - wxON_BLOCK_EXIT1( SetAllLocaleFacets, locOld ); - for ( int n = 0; n < argc; n++ ) { - // try to interpret the string as being in the current locale - wxString arg(argv[n]); - - // but just in case we guessed wrongly and the conversion failed, do - // try to salvage at least something - if ( arg.empty() && argv[n][0] != '\0' ) - arg = wxString(argv[n], wxConvISO8859_1); - - m_arguments.push_back(arg); + m_arguments.push_back(wxString::FromAscii(argv[n])); } } @@ -308,12 +235,6 @@ void wxCmdLineParserData::SetArguments(int argc, wxChar **argv) } } -void wxCmdLineParserData::SetArguments(int WXUNUSED(argc), - const wxCmdLineArgsArray& argv) -{ - m_arguments = argv.GetArguments(); -} - #endif // wxUSE_UNICODE void wxCmdLineParserData::SetArguments(const wxString& cmdLine) @@ -363,24 +284,6 @@ int wxCmdLineParserData::FindOptionByLongName(const wxString& name) return wxNOT_FOUND; } -const wxCmdLineOption* -wxCmdLineParserData::FindOptionByAnyName(const wxString& name) -{ - int i = FindOption(name); - if ( i == wxNOT_FOUND ) - { - i = FindOptionByLongName(name); - - if ( i == wxNOT_FOUND ) - { - wxFAIL_MSG( wxS("Unknown option ") + name ); - return NULL; - } - } - - return &m_options[(size_t)i]; -} - // ---------------------------------------------------------------------------- // construction and destruction // ---------------------------------------------------------------------------- @@ -402,11 +305,6 @@ void wxCmdLineParser::SetCmdLine(int argc, wxChar **argv) m_data->SetArguments(argc, argv); } -void wxCmdLineParser::SetCmdLine(int argc, const wxCmdLineArgsArray& argv) -{ - m_data->SetArguments(argc, argv); -} - #endif // wxUSE_UNICODE void wxCmdLineParser::SetCmdLine(const wxString& cmdline) @@ -433,7 +331,7 @@ void wxCmdLineParser::EnableLongOptions(bool enable) m_data->m_enableLongOptions = enable; } -bool wxCmdLineParser::AreLongOptionsEnabled() const +bool wxCmdLineParser::AreLongOptionsEnabled() { return m_data->m_enableLongOptions; } @@ -454,28 +352,21 @@ void wxCmdLineParser::SetDesc(const wxCmdLineEntryDesc *desc) switch ( desc->kind ) { case wxCMD_LINE_SWITCH: - AddSwitch(desc->shortName, desc->longName, - wxGetTranslation(desc->description), + AddSwitch(desc->shortName, desc->longName, desc->description, desc->flags); break; case wxCMD_LINE_OPTION: - AddOption(desc->shortName, desc->longName, - wxGetTranslation(desc->description), + AddOption(desc->shortName, desc->longName, desc->description, desc->type, desc->flags); break; case wxCMD_LINE_PARAM: - AddParam(wxGetTranslation(desc->description), - desc->type, desc->flags); - break; - - case wxCMD_LINE_USAGE_TEXT: - AddUsageText(wxGetTranslation(desc->description)); + AddParam(desc->description, desc->type, desc->flags); break; default: - wxFAIL_MSG( wxT("unknown command line entry type") ); + wxFAIL_MSG( _T("unknown command line entry type") ); // still fall through case wxCMD_LINE_NONE: @@ -490,7 +381,7 @@ void wxCmdLineParser::AddSwitch(const wxString& shortName, int flags) { wxASSERT_MSG( m_data->FindOption(shortName) == wxNOT_FOUND, - wxT("duplicate switch") ); + _T("duplicate switch") ); wxCmdLineOption *option = new wxCmdLineOption(wxCMD_LINE_SWITCH, shortName, longName, desc, @@ -506,7 +397,7 @@ void wxCmdLineParser::AddOption(const wxString& shortName, int flags) { wxASSERT_MSG( m_data->FindOption(shortName) == wxNOT_FOUND, - wxT("duplicate option") ); + _T("duplicate option") ); wxCmdLineOption *option = new wxCmdLineOption(wxCMD_LINE_OPTION, shortName, longName, desc, @@ -521,97 +412,80 @@ void wxCmdLineParser::AddParam(const wxString& desc, { // do some consistency checks: a required parameter can't follow an // optional one and nothing should follow a parameter with MULTIPLE flag -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ if ( !m_data->m_paramDesc.IsEmpty() ) { wxCmdLineParam& param = m_data->m_paramDesc.Last(); wxASSERT_MSG( !(param.flags & wxCMD_LINE_PARAM_MULTIPLE), - wxT("all parameters after the one with wxCMD_LINE_PARAM_MULTIPLE style will be ignored") ); + _T("all parameters after the one with wxCMD_LINE_PARAM_MULTIPLE style will be ignored") ); if ( !(flags & wxCMD_LINE_PARAM_OPTIONAL) ) { wxASSERT_MSG( !(param.flags & wxCMD_LINE_PARAM_OPTIONAL), - wxT("a required parameter can't follow an optional one") ); + _T("a required parameter can't follow an optional one") ); } } -#endif // wxDEBUG_LEVEL +#endif // Debug wxCmdLineParam *param = new wxCmdLineParam(desc, type, flags); m_data->m_paramDesc.Add(param); } -void wxCmdLineParser::AddUsageText(const wxString& text) -{ - wxASSERT_MSG( !text.empty(), wxT("text can't be empty") ); - - wxCmdLineOption *option = new wxCmdLineOption(wxCMD_LINE_USAGE_TEXT, - wxEmptyString, wxEmptyString, - text, wxCMD_LINE_VAL_NONE, 0); - - m_data->m_options.Add(option); -} - // ---------------------------------------------------------------------------- // access to parse command line // ---------------------------------------------------------------------------- bool wxCmdLineParser::Found(const wxString& name) const { - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); + int i = m_data->FindOption(name); + if ( i == wxNOT_FOUND ) + i = m_data->FindOptionByLongName(name); - return opt && opt->HasValue(); -} + wxCHECK_MSG( i != wxNOT_FOUND, false, _T("unknown switch") ); -wxCmdLineSwitchState wxCmdLineParser::FoundSwitch(const wxString& name) const -{ - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); + wxCmdLineOption& opt = m_data->m_options[(size_t)i]; + if ( !opt.HasValue() ) + return false; - if ( !opt || !opt->HasValue() ) - return wxCMD_SWITCH_NOT_FOUND; - - return opt->IsNegated() ? wxCMD_SWITCH_OFF : wxCMD_SWITCH_ON; + return true; } bool wxCmdLineParser::Found(const wxString& name, wxString *value) const { - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); + int i = m_data->FindOption(name); + if ( i == wxNOT_FOUND ) + i = m_data->FindOptionByLongName(name); - if ( !opt || !opt->HasValue() ) + wxCHECK_MSG( i != wxNOT_FOUND, false, _T("unknown option") ); + + wxCmdLineOption& opt = m_data->m_options[(size_t)i]; + if ( !opt.HasValue() ) return false; - wxCHECK_MSG( value, false, wxT("NULL pointer in wxCmdLineOption::Found") ); + wxCHECK_MSG( value, false, _T("NULL pointer in wxCmdLineOption::Found") ); - *value = opt->GetStrVal(); + *value = opt.GetStrVal(); return true; } bool wxCmdLineParser::Found(const wxString& name, long *value) const { - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); + int i = m_data->FindOption(name); + if ( i == wxNOT_FOUND ) + i = m_data->FindOptionByLongName(name); - if ( !opt || !opt->HasValue() ) + wxCHECK_MSG( i != wxNOT_FOUND, false, _T("unknown option") ); + + wxCmdLineOption& opt = m_data->m_options[(size_t)i]; + if ( !opt.HasValue() ) return false; - wxCHECK_MSG( value, false, wxT("NULL pointer in wxCmdLineOption::Found") ); + wxCHECK_MSG( value, false, _T("NULL pointer in wxCmdLineOption::Found") ); - *value = opt->GetLongVal(); - - return true; -} - -bool wxCmdLineParser::Found(const wxString& name, double *value) const -{ - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); - - if ( !opt || !opt->HasValue() ) - return false; - - wxCHECK_MSG( value, false, wxT("NULL pointer in wxCmdLineOption::Found") ); - - *value = opt->GetDoubleVal(); + *value = opt.GetLongVal(); return true; } @@ -619,14 +493,19 @@ bool wxCmdLineParser::Found(const wxString& name, double *value) const #if wxUSE_DATETIME bool wxCmdLineParser::Found(const wxString& name, wxDateTime *value) const { - const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name); + int i = m_data->FindOption(name); + if ( i == wxNOT_FOUND ) + i = m_data->FindOptionByLongName(name); - if ( !opt || !opt->HasValue() ) + wxCHECK_MSG( i != wxNOT_FOUND, false, _T("unknown option") ); + + wxCmdLineOption& opt = m_data->m_options[(size_t)i]; + if ( !opt.HasValue() ) return false; - wxCHECK_MSG( value, false, wxT("NULL pointer in wxCmdLineOption::Found") ); + wxCHECK_MSG( value, false, _T("NULL pointer in wxCmdLineOption::Found") ); - *value = opt->GetDateVal(); + *value = opt.GetDateVal(); return true; } @@ -639,7 +518,7 @@ size_t wxCmdLineParser::GetParamCount() const wxString wxCmdLineParser::GetParam(size_t n) const { - wxCHECK_MSG( n < GetParamCount(), wxEmptyString, wxT("invalid param index") ); + wxCHECK_MSG( n < GetParamCount(), wxEmptyString, _T("invalid param index") ); return m_data->m_parameters[n]; } @@ -647,9 +526,10 @@ wxString wxCmdLineParser::GetParam(size_t n) const // Resets switches and options void wxCmdLineParser::Reset() { - for ( size_t i = 0; i < m_data->m_options.GetCount(); i++ ) + for ( size_t i = 0; i < m_data->m_options.Count(); i++ ) { - m_data->m_options[i].Reset(); + wxCmdLineOption& opt = m_data->m_options[i]; + opt.SetHasValue(false); } } @@ -673,7 +553,6 @@ int wxCmdLineParser::Parse(bool showUsage) Reset(); // parse everything - m_data->m_parameters.clear(); wxString arg; size_t count = m_data->m_arguments.size(); for ( size_t n = 1; ok && (n < count); n++ ) // 0 is program name @@ -683,84 +562,41 @@ int wxCmdLineParser::Parse(bool showUsage) // special case: "--" should be discarded and all following arguments // should be considered as parameters, even if they start with '-' and // not like options (this is POSIX-like) - if ( arg == wxT("--") ) + if ( arg == _T("--") ) { maybeOption = false; continue; } -#ifdef __WXOSX__ - if ( arg == wxT("-ApplePersistenceIgnoreState") ) - { - maybeOption = false; - - continue; - } -#endif - + // empty argument or just '-' is not an option but a parameter if ( maybeOption && arg.length() > 1 && - // FIXME-UTF8: use wc_str() after removing ANSI build - wxStrchr(m_data->m_switchChars.c_str(), arg[0u]) ) + wxStrchr(m_data->m_switchChars, arg[0u]) ) { bool isLong; wxString name; int optInd = wxNOT_FOUND; // init to suppress warnings // an option or a switch: find whether it's a long or a short one - if ( arg.length() >= 3 && arg[0u] == wxT('-') && arg[1u] == wxT('-') ) + if ( arg[0u] == _T('-') && arg[1u] == _T('-') ) { // a long one isLong = true; // Skip leading "--" - wxString::const_iterator p = arg.begin() + 2; + const wxChar *p = arg.c_str() + 2; bool longOptionsEnabled = AreLongOptionsEnabled(); - name = GetLongOptionName(p, arg.end()); + name = GetLongOptionName(p); if (longOptionsEnabled) { - wxString errorOpt; - optInd = m_data->FindOptionByLongName(name); if ( optInd == wxNOT_FOUND ) { - // Check if this could be a negatable long option. - if ( name.Last() == '-' ) - { - name.RemoveLast(); - - optInd = m_data->FindOptionByLongName(name); - if ( optInd != wxNOT_FOUND ) - { - if ( !(m_data->m_options[optInd].flags & - wxCMD_LINE_SWITCH_NEGATABLE) ) - { - errorOpt.Printf - ( - _("Option '%s' can't be negated"), - name - ); - optInd = wxNOT_FOUND; - } - } - } - - if ( optInd == wxNOT_FOUND ) - { - if ( errorOpt.empty() ) - { - errorOpt.Printf - ( - _("Unknown long option '%s'"), - name - ); - } - - errorMsg << errorOpt << wxT('\n'); - } + errorMsg << wxString::Format(_("Unknown long option '%s'"), name.c_str()) + << _T('\n'); } } else @@ -770,7 +606,7 @@ int wxCmdLineParser::Parse(bool showUsage) // Print the argument including leading "--" name.Prepend( wxT("--") ); errorMsg << wxString::Format(_("Unknown option '%s'"), name.c_str()) - << wxT('\n'); + << _T('\n'); } } @@ -780,9 +616,9 @@ int wxCmdLineParser::Parse(bool showUsage) // a short one: as they can be cumulated, we try to find the // longest substring which is a valid option - wxString::const_iterator p = arg.begin() + 1; + const wxChar *p = arg.c_str() + 1; - name = GetShortOptionName(p, arg.end()); + name = GetShortOptionName(p); size_t len = name.length(); do @@ -792,7 +628,7 @@ int wxCmdLineParser::Parse(bool showUsage) // we couldn't find a valid option name in the // beginning of this string errorMsg << wxString::Format(_("Unknown option '%s'"), name.c_str()) - << wxT('\n'); + << _T('\n'); break; } @@ -819,14 +655,6 @@ int wxCmdLineParser::Parse(bool showUsage) if ( m_data->m_options[(size_t)optInd].kind == wxCMD_LINE_SWITCH ) { - // if the switch is negatable and it is just followed - // by '-' the '-' is considered to be part of this - // switch - if ( (m_data->m_options[(size_t)optInd].flags & - wxCMD_LINE_SWITCH_NEGATABLE) && - arg[len] == '-' ) - ++len; - // pretend that all the rest of the argument is the // next argument, in fact wxString arg2 = arg[0u]; @@ -835,10 +663,6 @@ int wxCmdLineParser::Parse(bool showUsage) m_data->m_arguments.insert (m_data->m_arguments.begin() + n + 1, arg2); count++; - - // only leave the part which wasn't extracted into the - // next argument in this one - arg = arg.Left(len + 1); } //else: it's our value, we'll deal with it below } @@ -854,31 +678,24 @@ int wxCmdLineParser::Parse(bool showUsage) // look at what follows: // +1 for leading '-' - wxString::const_iterator p = arg.begin() + 1 + name.length(); - wxString::const_iterator end = arg.end(); - + const wxChar *p = arg.c_str() + 1 + name.length(); if ( isLong ) - ++p; // for another leading '-' + p++; // for another leading '-' wxCmdLineOption& opt = m_data->m_options[(size_t)optInd]; if ( opt.kind == wxCMD_LINE_SWITCH ) { // we must check that there is no value following the switch - bool negated = (opt.flags & wxCMD_LINE_SWITCH_NEGATABLE) && - p != arg.end() && *p == '-'; - - if ( !negated && p != arg.end() ) + if ( *p != _T('\0') ) { errorMsg << wxString::Format(_("Unexpected characters following option '%s'."), name.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } else // no value, as expected { // nothing more to do opt.SetHasValue(); - if ( negated ) - opt.SetNegated(); if ( opt.flags & wxCMD_LINE_OPTION_HELP ) { @@ -891,53 +708,66 @@ int wxCmdLineParser::Parse(bool showUsage) } else // it's an option. not a switch { - switch ( p == end ? '\0' : (*p).GetValue() ) + // get the value + if ( isLong ) { - case '=': - case ':': - // the value follows - ++p; - break; + if ( *p++ != _T('=') ) + { + errorMsg << wxString::Format(_("Option '%s' requires a value, '=' expected."), name.c_str()) + << _T('\n'); - case '\0': - // the value is in the next argument - if ( ++n == count ) - { - // ... but there is none - errorMsg << wxString::Format(_("Option '%s' requires a value."), - name.c_str()) - << wxT('\n'); + ok = false; + } + } + else // short option + { + switch ( *p ) + { + case _T('='): + case _T(':'): + // the value follows + p++; + break; - ok = false; - } - else - { - // ... take it from there - p = m_data->m_arguments[n].begin(); - end = m_data->m_arguments[n].end(); - } - break; + case 0: + // the value is in the next argument + if ( ++n == count ) + { + // ... but there is none + errorMsg << wxString::Format(_("Option '%s' requires a value."), + name.c_str()) + << _T('\n'); - default: - // the value is right here: this may be legal or - // not depending on the option style - if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR ) - { - errorMsg << wxString::Format(_("Separator expected after the option '%s'."), - name.c_str()) - << wxT('\n'); + ok = false; + } + else + { + // ... take it from there + p = m_data->m_arguments[n].c_str(); + } + break; - ok = false; - } + default: + // the value is right here: this may be legal or + // not depending on the option style + if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR ) + { + errorMsg << wxString::Format(_("Separator expected after the option '%s'."), + name.c_str()) + << _T('\n'); + + ok = false; + } + } } if ( ok ) { - wxString value(p, end); + wxString value = p; switch ( opt.type ) { default: - wxFAIL_MSG( wxT("unknown option type") ); + wxFAIL_MSG( _T("unknown option type") ); // still fall through case wxCMD_LINE_VAL_STRING: @@ -955,25 +785,7 @@ int wxCmdLineParser::Parse(bool showUsage) { errorMsg << wxString::Format(_("'%s' is not a correct numeric value for option '%s'."), value.c_str(), name.c_str()) - << wxT('\n'); - - ok = false; - } - } - break; - - case wxCMD_LINE_VAL_DOUBLE: - { - double val; - if ( value.ToDouble(&val) ) - { - opt.SetDoubleVal(val); - } - else - { - errorMsg << wxString::Format(_("'%s' is not a correct numeric value for option '%s'."), - value.c_str(), name.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } @@ -984,12 +796,12 @@ int wxCmdLineParser::Parse(bool showUsage) case wxCMD_LINE_VAL_DATE: { wxDateTime dt; - wxString::const_iterator endDate; - if ( !dt.ParseDate(value, &endDate) || endDate != value.end() ) + const wxChar *res = dt.ParseDate(value); + if ( !res || *res ) { errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."), name.c_str(), value.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } @@ -1021,7 +833,7 @@ int wxCmdLineParser::Parse(bool showUsage) else { wxASSERT_MSG( currentParam == countParam - 1, - wxT("all parameters after the one with wxCMD_LINE_PARAM_MULTIPLE style are ignored") ); + _T("all parameters after the one with wxCMD_LINE_PARAM_MULTIPLE style are ignored") ); // remember that we did have this last repeatable parameter hadRepeatableParam = true; @@ -1030,7 +842,7 @@ int wxCmdLineParser::Parse(bool showUsage) else { errorMsg << wxString::Format(_("Unexpected parameter '%s'"), arg.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } @@ -1068,7 +880,7 @@ int wxCmdLineParser::Parse(bool showUsage) errorMsg << wxString::Format(_("The value for the option '%s' must be specified."), optName.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } @@ -1090,7 +902,7 @@ int wxCmdLineParser::Parse(bool showUsage) { errorMsg << wxString::Format(_("The required parameter '%s' was not specified."), param.description.c_str()) - << wxT('\n'); + << _T('\n'); ok = false; } @@ -1112,7 +924,7 @@ int wxCmdLineParser::Parse(bool showUsage) } else { - wxFAIL_MSG( wxT("no wxMessageOutput object?") ); + wxFAIL_MSG( _T("no wxMessageOutput object?") ); } } @@ -1123,7 +935,7 @@ int wxCmdLineParser::Parse(bool showUsage) // give the usage message // ---------------------------------------------------------------------------- -void wxCmdLineParser::Usage() const +void wxCmdLineParser::Usage() { wxMessageOutput* msgOut = wxMessageOutput::Get(); if ( msgOut ) @@ -1132,21 +944,20 @@ void wxCmdLineParser::Usage() const } else { - wxFAIL_MSG( wxT("no wxMessageOutput object?") ); + wxFAIL_MSG( _T("no wxMessageOutput object?") ); } } -wxString wxCmdLineParser::GetUsageString() const +wxString wxCmdLineParser::GetUsageString() { wxString appname; - if ( m_data->m_arguments.empty() ) + if ( wxTheApp ) { - if ( wxTheApp ) - appname = wxTheApp->GetAppName(); + appname = wxFileName(wxTheApp->argv[0]).GetFullName(); } - else // use argv[0] + else if (!m_data->m_arguments.empty() ) { - appname = wxFileName(m_data->m_arguments[0]).GetName(); + appname = wxFileName(m_data->m_arguments[0]).GetFullName(); } // we construct the brief cmd line desc on the fly, but not the detailed @@ -1157,14 +968,14 @@ wxString wxCmdLineParser::GetUsageString() const if ( !m_data->m_logo.empty() ) { - usage << m_data->m_logo << wxT('\n'); + usage << m_data->m_logo << _T('\n'); } usage << wxString::Format(_("Usage: %s"), appname.c_str()); // the switch char is usually '-' but this can be changed with // SetSwitchChars() and then the first one of possible chars is used - wxChar chSwitch = !m_data->m_switchChars ? wxT('-') + wxChar chSwitch = !m_data->m_switchChars ? _T('-') : m_data->m_switchChars[0u]; bool areLongOptionsEnabled = AreLongOptionsEnabled(); @@ -1172,63 +983,58 @@ wxString wxCmdLineParser::GetUsageString() const for ( n = 0; n < count; n++ ) { wxCmdLineOption& opt = m_data->m_options[n]; - wxString option, negator; - if ( opt.kind != wxCMD_LINE_USAGE_TEXT ) + usage << _T(' '); + if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) { - usage << wxT(' '); - if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) - { - usage << wxT('['); - } + usage << _T('['); + } - if ( opt.flags & wxCMD_LINE_SWITCH_NEGATABLE ) - negator = wxT("[-]"); - - if ( !opt.shortName.empty() ) + if ( !opt.shortName.empty() ) + { + usage << chSwitch << opt.shortName; + } + else if ( areLongOptionsEnabled && !opt.longName.empty() ) + { + usage << _T("--") << opt.longName; + } + else + { + if (!opt.longName.empty()) { - usage << chSwitch << opt.shortName << negator; - } - else if ( areLongOptionsEnabled && !opt.longName.empty() ) - { - usage << wxT("--") << opt.longName << negator; + wxFAIL_MSG( wxT("option with only a long name while long ") + wxT("options are disabled") ); } else { - if (!opt.longName.empty()) - { - wxFAIL_MSG( wxT("option with only a long name while long ") - wxT("options are disabled") ); - } - else - { - wxFAIL_MSG( wxT("option without neither short nor long name") ); - } + wxFAIL_MSG( _T("option without neither short nor long name") ); } + } - if ( !opt.shortName.empty() ) - { - option << wxT(" ") << chSwitch << opt.shortName; - } + wxString option; - if ( areLongOptionsEnabled && !opt.longName.empty() ) - { - option << (option.empty() ? wxT(" ") : wxT(", ")) - << wxT("--") << opt.longName; - } + if ( !opt.shortName.empty() ) + { + option << _T(" ") << chSwitch << opt.shortName; + } - if ( opt.kind != wxCMD_LINE_SWITCH ) - { - wxString val; - val << wxT('<') << GetTypeName(opt.type) << wxT('>'); - usage << wxT(' ') << val; - option << (!opt.longName ? wxT(':') : wxT('=')) << val; - } + if ( areLongOptionsEnabled && !opt.longName.empty() ) + { + option << (option.empty() ? _T(" ") : _T(", ")) + << _T("--") << opt.longName; + } - if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) - { - usage << wxT(']'); - } + if ( opt.kind != wxCMD_LINE_SWITCH ) + { + wxString val; + val << _T('<') << GetTypeName(opt.type) << _T('>'); + usage << _T(' ') << val; + option << (!opt.longName ? _T(':') : _T('=')) << val; + } + + if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) + { + usage << _T(']'); } namesOptions.push_back(option); @@ -1240,63 +1046,44 @@ wxString wxCmdLineParser::GetUsageString() const { wxCmdLineParam& param = m_data->m_paramDesc[n]; - usage << wxT(' '); + usage << _T(' '); if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL ) { - usage << wxT('['); + usage << _T('['); } usage << param.description; if ( param.flags & wxCMD_LINE_PARAM_MULTIPLE ) { - usage << wxT("..."); + usage << _T("..."); } if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL ) { - usage << wxT(']'); + usage << _T(']'); } } - usage << wxT('\n'); - - // set to number of our own options, not counting the standard ones - count = namesOptions.size(); - - // get option names & descriptions for standard options, if any: - wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - wxString stdDesc; - if ( traits ) - stdDesc = traits->GetStandardCmdLineOptions(namesOptions, descOptions); + usage << _T('\n'); // now construct the detailed help message size_t len, lenMax = 0; - for ( n = 0; n < namesOptions.size(); n++ ) + count = namesOptions.size(); + for ( n = 0; n < count; n++ ) { len = namesOptions[n].length(); if ( len > lenMax ) lenMax = len; } - for ( n = 0; n < namesOptions.size(); n++ ) + for ( n = 0; n < count; n++ ) { - if ( n == count ) - usage << wxT('\n') << stdDesc; - len = namesOptions[n].length(); - // desc contains text if name is empty - if (len == 0) - { - usage << descOptions[n] << wxT('\n'); - } - else - { - usage << namesOptions[n] - << wxString(wxT(' '), lenMax - len) << wxT('\t') - << descOptions[n] - << wxT('\n'); - } + usage << namesOptions[n] + << wxString(_T(' '), lenMax - len) << _T('\t') + << descOptions[n] + << _T('\n'); } return usage; @@ -1312,7 +1099,7 @@ static wxString GetTypeName(wxCmdLineParamType type) switch ( type ) { default: - wxFAIL_MSG( wxT("unknown option type") ); + wxFAIL_MSG( _T("unknown option type") ); // still fall through case wxCMD_LINE_VAL_STRING: @@ -1323,10 +1110,6 @@ static wxString GetTypeName(wxCmdLineParamType type) s = _("num"); break; - case wxCMD_LINE_VAL_DOUBLE: - s = _("double"); - break; - case wxCMD_LINE_VAL_DATE: s = _("date"); break; @@ -1344,13 +1127,12 @@ the parameter allowedChars. For example, if p points to "abcde-@-_", and allowedChars is "-_", this function returns "abcde-". */ -static wxString GetOptionName(wxString::const_iterator p, - wxString::const_iterator end, - const wxChar *allowedChars) +static wxString GetOptionName(const wxChar *p, + const wxChar *allowedChars) { wxString argName; - while ( p != end && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) ) + while ( *p && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) ) { argName += *p++; } @@ -1368,16 +1150,14 @@ static wxString GetOptionName(wxString::const_iterator p, #define wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION \ wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION wxT("-") -static wxString GetShortOptionName(wxString::const_iterator p, - wxString::const_iterator end) +static wxString GetShortOptionName(const wxChar *p) { - return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION); + return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION); } -static wxString GetLongOptionName(wxString::const_iterator p, - wxString::const_iterator end) +static wxString GetLongOptionName(const wxChar *p) { - return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION); + return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION); } #endif // wxUSE_CMDLINE_PARSER @@ -1392,60 +1172,35 @@ static wxString GetLongOptionName(wxString::const_iterator p, Windows conventions for the command line handling, not Unix ones. For instance, backslash is not special except when it precedes double quote when it does quote it. - - TODO: Rewrite this to follow the even more complicated rule used by Windows - CommandLineToArgv(): - - * A string of backslashes not followed by a quotation mark has no special - meaning. - * An even number of backslashes followed by a quotation mark is treated as - pairs of protected backslashes, followed by a word terminator. - * An odd number of backslashes followed by a quotation mark is treated as - pairs of protected backslashes, followed by a protected quotation mark. - - See http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx - - It could also be useful to provide a converse function which is also - non-trivial, see - - http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx */ /* static */ -wxArrayString -wxCmdLineParser::ConvertStringToArgs(const wxString& cmdline, - wxCmdLineSplitType type) +wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p) { wxArrayString args; wxString arg; arg.reserve(1024); - const wxString::const_iterator end = cmdline.end(); - wxString::const_iterator p = cmdline.begin(); - + bool isInsideQuotes = false; for ( ;; ) { // skip white space - while ( p != end && (*p == ' ' || *p == '\t') ) - ++p; + while ( *p == _T(' ') || *p == _T('\t') ) + p++; // anything left? - if ( p == end ) + if ( *p == _T('\0') ) break; // parse this parameter - bool lastBS = false, - isInsideQuotes = false; - wxChar chDelim = '\0'; - for ( arg.clear(); p != end; ++p ) + bool endParam = false; + bool lastBS = false; + for ( arg.clear(); !endParam; p++ ) { - const wxChar ch = *p; - - if ( type == wxCMD_LINE_SPLIT_DOS ) + switch ( *p ) { - if ( ch == '"' ) - { + case _T('"'): if ( !lastBS ) { isInsideQuotes = !isInsideQuotes; @@ -1456,57 +1211,32 @@ wxCmdLineParser::ConvertStringToArgs(const wxString& cmdline, //else: quote has no special meaning but the backslash // still remains -- makes no sense but this is what // Windows does - } - // note that backslash does *not* quote the space, only quotes do - else if ( !isInsideQuotes && (ch == ' ' || ch == '\t') ) - { - ++p; // skip this space anyhow break; - } - lastBS = !lastBS && ch == '\\'; - } - else // type == wxCMD_LINE_SPLIT_UNIX - { - if ( !lastBS ) - { + case _T(' '): + case _T('\t'): + // backslash does *not* quote the space, only quotes do if ( isInsideQuotes ) { - if ( ch == chDelim ) - { - isInsideQuotes = false; - - continue; // don't use the quote itself - } + // skip assignment below + break; } - else // not in quotes and not escaped - { - if ( ch == '\'' || ch == '"' ) - { - isInsideQuotes = true; - chDelim = ch; + // fall through - continue; // don't use the quote itself - } + case _T('\0'): + endParam = true; - if ( ch == ' ' || ch == '\t' ) - { - ++p; // skip this space anyhow - break; - } - } - - lastBS = ch == '\\'; - if ( lastBS ) - continue; - } - else // escaped by backslash, just use as is - { - lastBS = false; - } + break; } - arg += ch; + if ( endParam ) + { + break; + } + + lastBS = !lastBS && *p == _T('\\'); + + arg += *p; } args.push_back(arg); diff --git a/Source/3rd Party/wx/src/common/cmdproc.cpp b/Source/3rd Party/wx/src/common/cmdproc.cpp index 4534de633..808f7bd95 100644 --- a/Source/3rd Party/wx/src/common/cmdproc.cpp +++ b/Source/3rd Party/wx/src/common/cmdproc.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart (extracted from docview.h by VZ) // Modified by: // Created: 05.11.00 +// RCS-ID: $Id: cmdproc.cpp 65725 2010-10-02 13:05:08Z TIK $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -27,7 +28,6 @@ #include "wx/intl.h" #include "wx/string.h" #include "wx/menu.h" - #include "wx/accel.h" #endif //WX_PRECOMP #include "wx/cmdproc.h" @@ -57,13 +57,10 @@ wxCommandProcessor::wxCommandProcessor(int maxCommands) { m_maxNoCommands = maxCommands; #if wxUSE_MENUS - m_commandEditMenu = NULL; + m_commandEditMenu = (wxMenu *) NULL; #endif // wxUSE_MENUS - -#if wxUSE_ACCEL - m_undoAccelerator = '\t' + wxAcceleratorEntry(wxACCEL_CTRL, 'Z').ToString(); - m_redoAccelerator = '\t' + wxAcceleratorEntry(wxACCEL_CTRL, 'Y').ToString(); -#endif // wxUSE_ACCEL + m_undoAccelerator = wxT("\tCtrl+Z"); + m_redoAccelerator = wxT("\tCtrl+Y"); m_lastSavedCommand = m_currentCommand = wxList::compatibility_iterator(); @@ -89,7 +86,7 @@ bool wxCommandProcessor::UndoCommand(wxCommand& cmd) // storeIt is false. bool wxCommandProcessor::Submit(wxCommand *command, bool storeIt) { - wxCHECK_MSG( command, false, wxT("no command in wxCommandProcessor::Submit") ); + wxCHECK_MSG( command, false, _T("no command in wxCommandProcessor::Submit") ); if ( !DoCommand(*command) ) { @@ -109,7 +106,7 @@ bool wxCommandProcessor::Submit(wxCommand *command, bool storeIt) void wxCommandProcessor::Store(wxCommand *command) { - wxCHECK_RET( command, wxT("no command in wxCommandProcessor::Store") ); + wxCHECK_RET( command, _T("no command in wxCommandProcessor::Store") ); // Correct a bug: we must chop off the current 'branch' // so that we're at the end of the command list. @@ -121,14 +118,13 @@ void wxCommandProcessor::Store(wxCommand *command) while (node) { wxList::compatibility_iterator next = node->GetNext(); - - // Make sure m_lastSavedCommand won't point to freed memory - if ( m_lastSavedCommand && m_lastSavedCommand == node ) - m_lastSavedCommand = wxList::compatibility_iterator(); - delete (wxCommand *)node->GetData(); m_commands.Erase(node); + // Make sure m_lastSavedCommand won't point to freed memory + if ( m_lastSavedCommand == node ) + m_lastSavedCommand = wxList::compatibility_iterator(); + node = next; } } @@ -136,14 +132,13 @@ void wxCommandProcessor::Store(wxCommand *command) if ( (int)m_commands.GetCount() == m_maxNoCommands ) { wxList::compatibility_iterator firstNode = m_commands.GetFirst(); - - // Make sure m_lastSavedCommand won't point to freed memory - if ( m_lastSavedCommand && m_lastSavedCommand == firstNode ) - m_lastSavedCommand = wxList::compatibility_iterator(); - wxCommand *firstCommand = (wxCommand *)firstNode->GetData(); delete firstCommand; m_commands.Erase(firstNode); + + // Make sure m_lastSavedCommand won't point to freed memory + if ( m_lastSavedCommand == firstNode ) + m_lastSavedCommand = wxList::compatibility_iterator(); } m_commands.Append(command); @@ -169,11 +164,11 @@ bool wxCommandProcessor::Undo() bool wxCommandProcessor::Redo() { - wxCommand *redoCommand = NULL; + wxCommand *redoCommand = (wxCommand *) NULL; wxList::compatibility_iterator redoNode -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL = NULL // just to avoid warnings -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL ; if ( m_currentCommand ) @@ -327,23 +322,4 @@ void wxCommandProcessor::ClearCommands() m_lastSavedCommand = wxList::compatibility_iterator(); } -bool wxCommandProcessor::IsDirty() const -{ - if ( !m_lastSavedCommand ) - { - // We have never been saved, so we are dirty if and only if we have any - // commands at all. - return m_currentCommand; - } - - if ( !m_currentCommand ) - { - // This only happens if all commands were undone after saving the - // document: we're dirty then. - return true; - } - - // Finally if both iterators are valid, we may just compare them. - return m_currentCommand != m_lastSavedCommand; -} diff --git a/Source/3rd Party/wx/src/common/cmndata.cpp b/Source/3rd Party/wx/src/common/cmndata.cpp index 18b2ef927..a6edb97b2 100644 --- a/Source/3rd Party/wx/src/common/cmndata.cpp +++ b/Source/3rd Party/wx/src/common/cmndata.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: cmndata.cpp 60700 2009-05-20 13:18:11Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,8 +24,6 @@ #pragma hdrstop #endif -#if wxUSE_PRINTING_ARCHITECTURE - #include "wx/cmndata.h" #ifndef WX_PRECOMP @@ -41,17 +40,109 @@ #include "wx/prntbase.h" #include "wx/printdlg.h" + +#if wxUSE_FONTDLG + #include "wx/fontdlg.h" +#endif // wxUSE_FONTDLG + +#if wxUSE_PRINTING_ARCHITECTURE + #include "wx/paper.h" +#if defined(__WXMAC__) + #include "wx/mac/private/print.h" +#endif IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject) +#endif // wxUSE_PRINTING_ARCHITECTURE + +IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) + // ============================================================================ // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// wxColourData +// ---------------------------------------------------------------------------- + +wxColourData::wxColourData() +{ + m_chooseFull = false; + m_dataColour.Set(0,0,0); + // m_custColours are wxNullColours initially +} + +wxColourData::wxColourData(const wxColourData& data) + : wxObject() +{ + (*this) = data; +} + +wxColourData::~wxColourData() +{ +} + +void wxColourData::SetCustomColour(int i, const wxColour& colour) +{ + wxCHECK_RET( (i >= 0 && i < 16), _T("custom colour index out of range") ); + + m_custColours[i] = colour; +} + +wxColour wxColourData::GetCustomColour(int i) +{ + wxCHECK_MSG( (i >= 0 && i < 16), wxColour(0,0,0), + _T("custom colour index out of range") ); + + return m_custColours[i]; +} + +void wxColourData::operator=(const wxColourData& data) +{ + int i; + for (i = 0; i < 16; i++) + m_custColours[i] = data.m_custColours[i]; + + m_dataColour = (wxColour&)data.m_dataColour; + m_chooseFull = data.m_chooseFull; +} + +// ---------------------------------------------------------------------------- +// Font data +// ---------------------------------------------------------------------------- + +wxFontData::wxFontData() +{ + // Intialize colour to black. + m_fontColour = wxNullColour; + + m_showHelp = false; + m_allowSymbols = true; + m_enableEffects = true; + m_minSize = 0; + m_maxSize = 0; + + m_encoding = wxFONTENCODING_SYSTEM; +} + +wxFontData::~wxFontData() +{ +} + +#if wxUSE_FONTDLG + +wxFontDialogBase::~wxFontDialogBase() +{ +} + +#endif // wxUSE_FONTDLG + +#if wxUSE_PRINTING_ARCHITECTURE // ---------------------------------------------------------------------------- // Print data // ---------------------------------------------------------------------------- @@ -93,7 +184,11 @@ wxPrintData::wxPrintData(const wxPrintData& printData) void wxPrintData::SetPrivData( char *privData, int len ) { - wxDELETEA(m_privData); + if (m_privData) + { + delete [] m_privData; + m_privData = NULL; + } m_privDataLen = len; if (m_privDataLen > 0) { @@ -122,11 +217,8 @@ void wxPrintData::ConvertFromNative() m_nativeData->TransferTo( *this ) ; } -wxPrintData& wxPrintData::operator=(const wxPrintData& data) +void wxPrintData::operator=(const wxPrintData& data) { - if ( &data == this ) - return *this; - m_printNoCopies = data.m_printNoCopies; m_printCollate = data.m_printCollate; m_printOrientation = data.m_printOrientation; @@ -153,15 +245,17 @@ wxPrintData& wxPrintData::operator=(const wxPrintData& data) m_nativeData = data.GetNativeData(); m_nativeData->m_ref++; - wxDELETEA(m_privData); + if (m_privData) + { + delete [] m_privData; + m_privData = NULL; + } m_privDataLen = data.GetPrivDataLen(); if (m_privDataLen > 0) { m_privData = new char[m_privDataLen]; memcpy( m_privData, data.GetPrivData(), m_privDataLen ); } - - return *this; } // Is this data OK for showing the print dialog? @@ -169,9 +263,174 @@ bool wxPrintData::IsOk() const { m_nativeData->TransferFrom( *this ); - return m_nativeData->IsOk(); + return m_nativeData->Ok(); } +// What should happen here? wxPostScriptPrintNativeData is not +// defined unless all this is true on MSW. +#if WXWIN_COMPATIBILITY_2_4 && wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) + +#include "wx/generic/prntdlgg.h" + +#if wxUSE_POSTSCRIPT + #define WXUNUSED_WITHOUT_PS(name) name +#else + #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name) +#endif + +wxString wxPrintData::GetPrinterCommand() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand(); +#endif + return wxEmptyString; +} + +wxString wxPrintData::GetPrinterOptions() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions(); +#endif + return wxEmptyString; +} + +wxString wxPrintData::GetPreviewCommand() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand(); +#endif + return wxEmptyString; +} + +wxString wxPrintData::GetFontMetricPath() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath(); +#endif + return wxEmptyString; +} + +double wxPrintData::GetPrinterScaleX() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX(); +#endif + return 1.0; +} + +double wxPrintData::GetPrinterScaleY() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY(); +#endif + return 1.0; +} + +long wxPrintData::GetPrinterTranslateX() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX(); +#endif + return 0; +} + +long wxPrintData::GetPrinterTranslateY() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY(); +#endif + return 0; +} + +void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command ); +#endif +} + +void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options ); +#endif +} + +void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command ); +#endif +} + +void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path ); +#endif +} + +void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x ); +#endif +} + +void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y ); +#endif +} + +void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y ); +#endif +} + +void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x ); +#endif +} + +void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y ); +#endif +} + +void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y)) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y ); +#endif +} +#endif + // ---------------------------------------------------------------------------- // Print dialog data // ---------------------------------------------------------------------------- @@ -194,6 +453,9 @@ wxPrintDialogData::wxPrintDialogData() m_printEnablePrintToFile = ! factory->HasOwnPrintToFile(); m_printEnableHelp = false; +#if WXWIN_COMPATIBILITY_2_4 + m_printSetupDialog = false; +#endif } wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) @@ -209,12 +471,7 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) m_printMinPage = 1; m_printMaxPage = 9999; m_printNoCopies = 1; - // On Mac the Print dialog always defaults to "All Pages" -#ifdef __WXMAC__ - m_printAllPages = true; -#else m_printAllPages = false; -#endif m_printCollate = false; m_printToFile = false; m_printSelection = false; @@ -222,6 +479,9 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) m_printEnablePageNumbers = true; m_printEnablePrintToFile = true; m_printEnableHelp = false; +#if WXWIN_COMPATIBILITY_2_4 + m_printSetupDialog = false; +#endif m_printData = printData; } @@ -244,6 +504,9 @@ void wxPrintDialogData::operator=(const wxPrintDialogData& data) m_printEnablePageNumbers = data.m_printEnablePageNumbers; m_printEnableHelp = data.m_printEnableHelp; m_printEnablePrintToFile = data.m_printEnablePrintToFile; +#if WXWIN_COMPATIBILITY_2_4 + m_printSetupDialog = data.m_printSetupDialog; +#endif m_printData = data.m_printData; } @@ -366,7 +629,7 @@ void wxPageSetupDialogData::SetPrintData(const wxPrintData& printData) // paper id void wxPageSetupDialogData::CalculateIdFromPaperSize() { - wxASSERT_MSG( (wxThePrintPaperDatabase != NULL), + wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); wxSize sz = GetPaperSize(); @@ -381,7 +644,7 @@ void wxPageSetupDialogData::CalculateIdFromPaperSize() // Use paper id in wxPrintData to set this object's paper size void wxPageSetupDialogData::CalculatePaperSizeFromId() { - wxASSERT_MSG( (wxThePrintPaperDatabase != NULL), + wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); diff --git a/Source/3rd Party/wx/src/common/colourcmn.cpp b/Source/3rd Party/wx/src/common/colourcmn.cpp index 12b5f2007..5851dfcdf 100644 --- a/Source/3rd Party/wx/src/common/colourcmn.cpp +++ b/Source/3rd Party/wx/src/common/colourcmn.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 20/4/2006 +// RCS-ID: $Id: colourcmn.cpp 41538 2006-09-30 20:45:15Z RR $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,147 +23,40 @@ #include "wx/log.h" #include "wx/utils.h" #include "wx/gdicmn.h" - #include "wx/wxcrtvararg.h" #endif #if wxUSE_VARIANT IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT) #endif - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -#if wxUSE_EXTENDED_RTTI - -#include - -template<> void wxStringReadValue(const wxString &s, wxColour &data ) -{ - if ( !data.Set(s) ) - { - wxLogError(_("String To Colour : Incorrect colour specification : %s"), - s.c_str() ); - data = wxNullColour; - } -} - -template<> void wxStringWriteValue(wxString &s, const wxColour &data ) -{ - s = data.GetAsString(wxC2S_HTML_SYNTAX); -} - -wxTO_STRING_IMP( wxColour ) -wxFROM_STRING_IMP( wxColour ) - -wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour, wxObject, \ - "wx/colour.h", &wxTO_STRING( wxColour ), &wxFROM_STRING( wxColour )) -//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -wxBEGIN_PROPERTIES_TABLE(wxColour) -wxREADONLY_PROPERTY( Red, unsigned char, Red, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxREADONLY_PROPERTY( Green, unsigned char, Green, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxREADONLY_PROPERTY( Blue, unsigned char, Blue, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxDIRECT_CONSTRUCTOR_3( wxColour, unsigned char, Red, \ - unsigned char, Green, unsigned char, Blue ) - -wxEMPTY_HANDLERS_TABLE(wxColour) -#else - -#if wxCOLOUR_IS_GDIOBJECT -wxIMPLEMENT_DYNAMIC_CLASS(wxColour, wxGDIObject) -#else -wxIMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) -#endif - -#endif - // ============================================================================ // wxString <-> wxColour conversions // ============================================================================ -bool wxColourBase::FromString(const wxString& str) +bool wxColourBase::FromString(const wxChar *str) { - if ( str.empty() ) + if ( str == NULL || str[0] == wxT('\0')) return false; // invalid or empty string - if ( wxStrnicmp(str, wxT("RGB"), 3) == 0 ) + if ( wxStrncmp(str, wxT("RGB"), 3) == 0 || + wxStrncmp(str, wxT("rgb"), 3) == 0 ) { // CSS-like RGB specification - // according to http://www.w3.org/TR/css3-color/#colorunits + // according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units // values outside 0-255 range are allowed but should be clipped - int red, green, blue, - alpha = wxALPHA_OPAQUE; - if ( str.length() > 3 && (str[3] == wxT('a') || str[3] == wxT('A')) ) - { - // We can't use sscanf() for the alpha value as sscanf() uses the - // current locale while the floating point numbers in CSS always - // use point as decimal separator, regardless of locale. So parse - // the tail of the string manually by putting it in a buffer and - // using wxString::ToCDouble() below. Notice that we can't use "%s" - // for this as it stops at white space and we need "%c" to avoid - // this and really get all the rest of the string into the buffer. + int red, green, blue; + if (wxSscanf(&str[3], wxT("(%d, %d, %d)"), &red, &green, &blue) != 3) + return false; - const unsigned len = str.length(); // always big enough - wxCharBuffer alphaBuf(len); - char * const alphaPtr = alphaBuf.data(); - - for ( unsigned n = 0; n < len; n++ ) - alphaPtr[n] = '\0'; - - // Construct the format string which ensures that the last argument - // receives all the rest of the string. - wxString formatStr; - formatStr << wxS("( %d , %d , %d , %") << len << 'c'; - - // Notice that we use sscanf() here because if the string is not - // ASCII it can't represent a valid RGB colour specification anyhow - // and like this we can be sure that %c corresponds to "char *" - // while with wxSscanf() it depends on the type of the string - // passed as first argument: if it is a wide string, then %c - // expects "wchar_t *" matching parameter under MSW for example. - if ( sscanf(str.c_str() + 4, - formatStr.mb_str(), - &red, &green, &blue, alphaPtr) != 4 ) - return false; - - // Notice that we must explicitly specify the length to get rid of - // trailing NULs. - wxString alphaStr(alphaPtr, wxStrlen(alphaPtr)); - if ( alphaStr.empty() || alphaStr.Last() != ')' ) - return false; - - alphaStr.RemoveLast(); - alphaStr.Trim(); - - double a; - if ( !alphaStr.ToCDouble(&a) ) - return false; - - alpha = wxRound(a * 255); - } - else // no 'a' following "rgb" - { - if ( wxSscanf(str.wx_str() + 3, wxT("( %d , %d , %d )"), - &red, &green, &blue) != 3 ) - return false; - } - - Set((unsigned char)wxClip(red, 0, 255), - (unsigned char)wxClip(green, 0, 255), - (unsigned char)wxClip(blue, 0, 255), - (unsigned char)wxClip(alpha, 0, 255)); + Set((unsigned char)wxClip(red,0,255), + (unsigned char)wxClip(green,0,255), + (unsigned char)wxClip(blue,0,255)); } else if ( str[0] == wxT('#') && wxStrlen(str) == 7 ) { // hexadecimal prefixed with # (HTML syntax) unsigned long tmp; - if (wxSscanf(str.wx_str() + 1, wxT("%lx"), &tmp) != 1) + if (wxSscanf(&str[1], wxT("%lx"), &tmp) != 1) return false; Set((unsigned char)(tmp >> 16), @@ -176,13 +70,13 @@ bool wxColourBase::FromString(const wxString& str) // because this place can be called from constructor // and 'this' could not be available yet wxColour clr = wxTheColourDatabase->Find(str); - if (clr.IsOk()) + if (clr.Ok()) Set((unsigned char)clr.Red(), (unsigned char)clr.Green(), (unsigned char)clr.Blue()); } - if (IsOk()) + if (Ok()) return true; wxLogDebug(wxT("wxColour::Set - couldn't set to colour string '%s'"), str); @@ -193,153 +87,29 @@ wxString wxColourBase::GetAsString(long flags) const { wxString colName; - const bool isOpaque = Alpha() == wxALPHA_OPAQUE; + if (flags & wxC2S_NAME) + colName = wxTheColourDatabase->FindName((const wxColour &)(*this)).MakeLower(); - // we can't use the name format if the colour is not opaque as the alpha - // information would be lost - if ( (flags & wxC2S_NAME) && isOpaque ) + if ( colName.empty() && (flags & wxC2S_CSS_SYNTAX) ) { - colName = wxTheColourDatabase->FindName( - static_cast(*this)).MakeLower(); + // no name for this colour; return it in CSS syntax + colName.Printf(wxT("rgb(%d, %d, %d)"), + Red(), Green(), Blue()); + } + else if ( colName.empty() && (flags & wxC2S_HTML_SYNTAX) ) + { + // no name for this colour; return it in HTML syntax + colName.Printf(wxT("#%02X%02X%02X"), + Red(), Green(), Blue()); } - if ( colName.empty() ) - { - const int red = Red(), - blue = Blue(), - green = Green(); - - if ( flags & wxC2S_CSS_SYNTAX ) - { - // no name for this colour; return it in CSS syntax - if ( isOpaque ) - { - colName.Printf(wxT("rgb(%d, %d, %d)"), red, green, blue); - } - else // use rgba() form - { - colName.Printf(wxT("rgba(%d, %d, %d, %s)"), - red, green, blue, - wxString::FromCDouble(Alpha() / 255., 3)); - } - } - else if ( flags & wxC2S_HTML_SYNTAX ) - { - wxASSERT_MSG( isOpaque, "alpha is lost in HTML syntax" ); - - // no name for this colour; return it in HTML syntax - colName.Printf(wxT("#%02X%02X%02X"), red, green, blue); - } - } - - // this function should alway returns a non-empty string + // this function always returns a non-empty string wxASSERT_MSG(!colName.empty(), wxT("Invalid wxColour -> wxString conversion flags")); return colName; } -// static -void wxColourBase::MakeMono(unsigned char* r, unsigned char* g, unsigned char* b, - bool on) -{ - *r = *g = *b = on ? 255 : 0; -} - -// static -void wxColourBase::MakeGrey(unsigned char* r, unsigned char* g, unsigned char* b - /*, unsigned char brightness */ - ) -{ - *r = *g = *b = (wxByte)(((*b)*117UL + (*g)*601UL + (*r)*306UL) >> 10); -} - -// static -void wxColourBase::MakeGrey(unsigned char* r, unsigned char* g, unsigned char* b, - double weight_r, double weight_g, double weight_b) -{ - double luma = (*r) * weight_r + (*g) * weight_g + (*b) * weight_b; - *r = *g = *b = (wxByte)wxRound(luma); -} - -// static -void wxColourBase::MakeDisabled(unsigned char* r, unsigned char* g, unsigned char* b, - unsigned char brightness) -{ - //MakeGrey(r, g, b, brightness); // grey no-blend version - *r = AlphaBlend(*r, brightness, 0.4); - *g = AlphaBlend(*g, brightness, 0.4); - *b = AlphaBlend(*b, brightness, 0.4); -} - -wxColour& wxColourBase::MakeDisabled(unsigned char brightness) -{ - unsigned char r = Red(), - g = Green(), - b = Blue(); - MakeDisabled(&r, &g, &b, brightness); - Set(r, g, b, Alpha()); - return static_cast(*this); -} - -// AlphaBlend is used by ChangeLightness and MakeDisabled - -// static -unsigned char wxColourBase::AlphaBlend(unsigned char fg, unsigned char bg, - double alpha) -{ - double result = bg + (alpha * (fg - bg)); - result = wxMax(result, 0.0); - result = wxMin(result, 255.0); - return (unsigned char)result; -} - -// ChangeLightness() is a utility function that simply darkens -// or lightens a color, based on the specified percentage -// ialpha of 0 would be completely black, 100 completely white -// an ialpha of 100 returns the same colour - -// static -void wxColourBase::ChangeLightness(unsigned char* r, unsigned char* g, unsigned char* b, - int ialpha) -{ - if (ialpha == 100) return; - - // ialpha is 0..200 where 0 is completely black - // and 200 is completely white and 100 is the same - // convert that to normal alpha 0.0 - 1.0 - ialpha = wxMax(ialpha, 0); - ialpha = wxMin(ialpha, 200); - double alpha = ((double)(ialpha - 100.0))/100.0; - - unsigned char bg; - if (ialpha > 100) - { - // blend with white - bg = 255; - alpha = 1.0 - alpha; // 0 = transparent fg; 1 = opaque fg - } - else - { - // blend with black - bg = 0; - alpha = 1.0 + alpha; // 0 = transparent fg; 1 = opaque fg - } - - *r = AlphaBlend(*r, bg, alpha); - *g = AlphaBlend(*g, bg, alpha); - *b = AlphaBlend(*b, bg, alpha); -} - -wxColour wxColourBase::ChangeLightness(int ialpha) const -{ - wxByte r = Red(); - wxByte g = Green(); - wxByte b = Blue(); - ChangeLightness(&r, &g, &b, ialpha); - return wxColour(r,g,b); -} - #if WXWIN_COMPATIBILITY_2_6 // static @@ -354,25 +124,3 @@ void wxColourBase::InitFromName(const wxString& col) } #endif // WXWIN_COMPATIBILITY_2_6 - -// wxColour <-> wxString utilities, used by wxConfig -wxString wxToString(const wxColourBase& col) -{ - return col.IsOk() ? col.GetAsString(wxC2S_CSS_SYNTAX) - : wxString(); -} - -bool wxFromString(const wxString& str, wxColourBase *col) -{ - wxCHECK_MSG( col, false, wxT("NULL output parameter") ); - - if ( str.empty() ) - { - *col = wxNullColour; - return true; - } - - return col->Set(str); -} - - diff --git a/Source/3rd Party/wx/src/common/colourdata.cpp b/Source/3rd Party/wx/src/common/colourdata.cpp deleted file mode 100644 index 3569c5051..000000000 --- a/Source/3rd Party/wx/src/common/colourdata.cpp +++ /dev/null @@ -1,167 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/colourdata.cpp -// Author: Julian Smart -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_COLOURDLG || wxUSE_COLOURPICKERCTRL - -#include "wx/colourdata.h" -#include "wx/tokenzr.h" - -// ---------------------------------------------------------------------------- -// wxColourData -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) - -wxColourData::wxColourData() -{ - m_chooseFull = false; - m_dataColour.Set(0,0,0); - // m_custColours are wxNullColours initially -} - -wxColourData::wxColourData(const wxColourData& data) - : wxObject() -{ - (*this) = data; -} - -wxColourData::~wxColourData() -{ -} - -void wxColourData::SetCustomColour(int i, const wxColour& colour) -{ - wxCHECK_RET( i >= 0 && i < NUM_CUSTOM, wxT("custom colour index out of range") ); - - m_custColours[i] = colour; -} - -wxColour wxColourData::GetCustomColour(int i) const -{ - wxCHECK_MSG( i >= 0 && i < NUM_CUSTOM, wxColour(0,0,0), - wxT("custom colour index out of range") ); - - return m_custColours[i]; -} - -wxColourData& wxColourData::operator=(const wxColourData& data) -{ - for ( int i = 0; i < NUM_CUSTOM; i++) - m_custColours[i] = data.m_custColours[i]; - - m_dataColour = data.m_dataColour; - m_chooseFull = data.m_chooseFull; - - return *this; -} - -// ---------------------------------------------------------------------------- -// [de]serialization -// ---------------------------------------------------------------------------- - -// separator used between different fields -static const char wxCOL_DATA_SEP = ','; - -wxString wxColourData::ToString() const -{ - wxString str(m_chooseFull ? '1' : '0'); - - for ( int i = 0; i < NUM_CUSTOM; i++ ) - { - str += wxCOL_DATA_SEP; - - const wxColour& clr = m_custColours[i]; - if ( clr.IsOk() ) - str += clr.GetAsString(wxC2S_HTML_SYNTAX); - } - - return str; -} - -bool wxColourData::FromString(const wxString& str) -{ - wxStringTokenizer tokenizer(str, wxCOL_DATA_SEP); - wxString token = tokenizer.GetNextToken(); - m_chooseFull = token == '1'; - bool success = m_chooseFull || token == '0'; - for (int i = 0; success && i < NUM_CUSTOM; i++) - { - token = tokenizer.GetNextToken(); - if (token.empty()) - m_custColours[i] = wxColour(); - else - success = m_custColours[i].Set(token); - } - return success; -} - -#if wxUSE_COLOURDLG - -#include "wx/colordlg.h" - -wxColour wxGetColourFromUser(wxWindow *parent, - const wxColour& colInit, - const wxString& caption, - wxColourData *ptrData) -{ - // contains serialized representation of wxColourData used the last time - // the dialog was shown: we want to reuse it the next time in order to show - // the same custom colours to the user (and we can't just have static - // wxColourData itself because it's a GUI object and so should be destroyed - // before GUI shutdown and doing it during static cleanup is too late) - static wxString s_strColourData; - - wxColourData data; - if ( !ptrData ) - { - ptrData = &data; - if ( !s_strColourData.empty() ) - { - if ( !data.FromString(s_strColourData) ) - { - wxFAIL_MSG( "bug in wxColourData::FromString()?" ); - } - -#ifdef __WXMSW__ - // we don't get back the "choose full" flag value from the native - // dialog and so we can't preserve it between runs, so we decide to - // always use it as it seems better than not using it (user can - // just ignore the extra controls in the dialog but having to click - // a button each time to show them would be very annoying - data.SetChooseFull(true); -#endif // __WXMSW__ - } - } - - if ( colInit.IsOk() ) - { - ptrData->SetColour(colInit); - } - - wxColour colRet; - wxColourDialog dialog(parent, ptrData); - if (!caption.empty()) - dialog.SetTitle(caption); - if ( dialog.ShowModal() == wxID_OK ) - { - *ptrData = dialog.GetColourData(); - colRet = ptrData->GetColour(); - s_strColourData = ptrData->ToString(); - } - //else: leave colRet invalid - - return colRet; -} - -#endif // wxUSE_COLOURDLG -#endif // wxUSE_COLOURDLG || wxUSE_COLOURPICKERCTRL diff --git a/Source/3rd Party/wx/src/common/combocmn.cpp b/Source/3rd Party/wx/src/common/combocmn.cpp index 34abc09ca..f67061a3c 100644 --- a/Source/3rd Party/wx/src/common/combocmn.cpp +++ b/Source/3rd Party/wx/src/common/combocmn.cpp @@ -4,6 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 +// RCS-ID: $Id: combocmn.cpp 67178 2011-03-13 09:32:19Z JMS $ // Copyright: (c) 2005 Jaakko Salli // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,97 +23,25 @@ #pragma hdrstop #endif -#include "wx/combo.h" - -#ifdef __WXMSW__ -#include "wx/msw/private.h" -#endif - -#if wxUSE_COMBOBOX -#include "wx/combobox.h" -extern WXDLLEXPORT_DATA(const char) wxComboBoxNameStr[] = "comboBox"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxComboBoxStyle ) -wxBEGIN_FLAGS( wxComboBoxStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxCB_SIMPLE) -wxFLAGS_MEMBER(wxCB_SORT) -wxFLAGS_MEMBER(wxCB_READONLY) -wxFLAGS_MEMBER(wxCB_DROPDOWN) - -wxEND_FLAGS( wxComboBoxStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxComboBox, wxControl, "wx/combobox.h") - -wxBEGIN_PROPERTIES_TABLE(wxComboBox) -wxEVENT_PROPERTY( Select, wxEVT_COMBOBOX, wxCommandEvent ) -wxEVENT_PROPERTY( TextEnter, wxEVT_TEXT_ENTER, wxCommandEvent ) - -// TODO DELEGATES -wxPROPERTY( Font, wxFont, SetFont, GetFont, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY_COLLECTION( Choices, wxArrayString, wxString, AppendString, \ - GetStrings, 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY( Value,wxString, SetValue, GetValue, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY( Selection,int, SetSelection, GetSelection, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - -wxPROPERTY_FLAGS( WindowStyle, wxComboBoxStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxComboBox) - -wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Value, wxPoint, Position, wxSize, Size ) - -#endif // wxUSE_COMBOBOX - #if wxUSE_COMBOCTRL +#include "wx/combobox.h" + #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/log.h" #include "wx/dcclient.h" #include "wx/settings.h" + #include "wx/dialog.h" #include "wx/timer.h" - #include "wx/textctrl.h" #endif #include "wx/tooltip.h" +#include "wx/combo.h" + + + // constants // ---------------------------------------------------------------------------- @@ -129,11 +58,6 @@ wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ #if defined(__WXMSW__) -// Let's use wxFrame as a fall-back solution until wxMSW gets wxNonOwnedWindow -#include "wx/frame.h" -#define wxCC_GENERIC_TLW_IS_FRAME -#define wxComboCtrlGenericTLW wxFrame - #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform) #define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common // native controls work on it like normal. @@ -152,22 +76,8 @@ wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ // reflected (or something like that - atleast commenting out ->Hide() // seemed to eliminate the position change). -#include "wx/dialog.h" -#define wxCC_GENERIC_TLW_IS_DIALOG -#define wxComboCtrlGenericTLW wxDialog - -#if defined(__WXGTK20__) -# include "wx/gtk/private.h" -#else -# include "wx/gtk1/private.h" -#endif - -// NB: Let's not be afraid to use wxGTK's wxPopupTransientWindow as a -// 'perfect' popup, as it can successfully host child controls even in -// popups that are shown in modal dialogs. - #define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform) -#define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common +#define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common // native controls work on it like normal. #define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window. #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered @@ -175,14 +85,10 @@ wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ #elif defined(__WXMAC__) -#include "wx/nonownedwnd.h" -#define wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW -#define wxComboCtrlGenericTLW wxNonOwnedWindow - -#define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform) -#define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common +#define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform) +#define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common // native controls work on it like normal. -#define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window. +#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window. #define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered #define FOCUS_RING 3 // Reserve room for the textctrl's focus ring to display @@ -193,10 +99,6 @@ wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ #else -#include "wx/dialog.h" -#define wxCC_GENERIC_TLW_IS_DIALOG -#define wxComboCtrlGenericTLW wxDialog - #define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform) #define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common // native controls work on it like normal. @@ -210,7 +112,7 @@ wxCONSTRUCTOR_5( wxComboBox, wxWindow*, Parent, wxWindowID, Id, \ // Popupwin is really only supported on wxMSW (not WINCE) and wxGTK, regardless // what the wxUSE_POPUPWIN says. // FIXME: Why isn't wxUSE_POPUPWIN reliable any longer? (it was in wxW2.6.2) -#if (!defined(__WXMSW__) && !defined(__WXGTK__) && !defined(__WXMAC__)) || defined(__WXWINCE__) +#if (!defined(__WXMSW__) && !defined(__WXGTK__)) || defined(__WXWINCE__) #undef wxUSE_POPUPWIN #define wxUSE_POPUPWIN 0 #endif @@ -230,7 +132,7 @@ enum POPUPWIN_NONE = 0, POPUPWIN_WXPOPUPTRANSIENTWINDOW = 1, POPUPWIN_WXPOPUPWINDOW = 2, - POPUPWIN_GENERICTLW = 3 + POPUPWIN_WXDIALOG = 3 }; @@ -248,9 +150,9 @@ enum #define SECONDARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW #define USES_WXPOPUPWINDOW 1 #else - #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW - #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW - #define USES_GENERICTLW 1 + #define wxComboPopupWindowBase2 wxDialog + #define SECONDARY_POPUP_TYPE POPUPWIN_WXDIALOG + #define USES_WXDIALOG 1 #endif #elif wxUSE_POPUPWIN @@ -261,17 +163,17 @@ enum #define USES_WXPOPUPWINDOW 1 #if !POPUPWIN_IS_PERFECT - #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW - #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW - #define USES_GENERICTLW 1 + #define wxComboPopupWindowBase2 wxDialog + #define SECONDARY_POPUP_TYPE POPUPWIN_WXDIALOG + #define USES_WXDIALOG 1 #endif #else // wxPopupWindow is not implemented - #define wxComboPopupWindowBase wxComboCtrlGenericTLW - #define PRIMARY_POPUP_TYPE POPUPWIN_GENERICTLW - #define USES_GENERICTLW 1 + #define wxComboPopupWindowBase wxDialog + #define PRIMARY_POPUP_TYPE POPUPWIN_WXDIALOG + #define USES_WXDIALOG 1 #endif @@ -284,8 +186,8 @@ enum #define USES_WXPOPUPWINDOW 0 #endif -#ifndef USES_GENERICTLW - #define USES_GENERICTLW 0 +#ifndef USES_WXDIALOG + #define USES_WXDIALOG 0 #endif @@ -296,26 +198,6 @@ enum #endif -// Returns true if given popup window type can be classified as perfect -// on this platform. -static inline bool IsPopupWinTypePerfect( wxByte popupWinType ) -{ -#if POPUPWIN_IS_PERFECT && TRANSIENT_POPUPWIN_IS_PERFECT - wxUnusedVar(popupWinType); - return true; -#else - return ( popupWinType == POPUPWIN_GENERICTLW - #if POPUPWIN_IS_PERFECT - || popupWinType == POPUPWIN_WXPOPUPWINDOW - #endif - #if TRANSIENT_POPUPWIN_IS_PERFECT - || popupWinType == POPUPWIN_WXPOPUPTRANSIENTWINDOW - #endif - ); -#endif -} - - // // ** TODO ** // * wxComboPopupWindow for external use (ie. replace old wxUniv wxPopupComboWindow) @@ -392,7 +274,7 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event ) wxWindow* popup = m_combo->GetPopupControl()->GetControl(); wxWindow* winpopup = m_combo->GetPopupWindow(); - if ( !winFocused || ( + if ( winFocused != m_focusStart && winFocused != popup && winFocused->GetParent() != popup && @@ -401,9 +283,8 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event ) winFocused != m_combo && winFocused != m_combo->GetButton() // GTK (atleast) requires this ) - ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); } event.Skip(); @@ -411,37 +292,37 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event ) void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } void wxComboFrameEventHandler::OnClose( wxCloseEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } void wxComboFrameEventHandler::OnActivate( wxActivateEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } void wxComboFrameEventHandler::OnResize( wxSizeEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } void wxComboFrameEventHandler::OnMove( wxMoveEvent& event ) { - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } @@ -493,16 +374,15 @@ bool wxComboPopupWindow::Show( bool show ) m_inShow++; - wxPopupTransientWindow* const - ptw = static_cast(this); + wxASSERT( IsKindOf(CLASSINFO(wxPopupTransientWindow)) ); + + wxPopupTransientWindow* ptw = (wxPopupTransientWindow*) this; + wxComboCtrlBase* combo = (wxComboCtrlBase*) GetParent(); if ( show != ptw->IsShown() ) { if ( show ) - // We used to do wxPopupTransientWindow::Popup here, - // but this would hide normal Show, which we are - // also going to need. - ptw->Show(); + ptw->Popup(combo->GetPopupControl()->GetControl()); else ptw->Dismiss(); } @@ -521,10 +401,10 @@ bool wxComboPopupWindow::ProcessLeftDown(wxMouseEvent& event) void wxComboPopupWindow::OnDismiss() { wxComboCtrlBase* combo = (wxComboCtrlBase*) GetParent(); - wxASSERT_MSG( wxDynamicCast(combo, wxComboCtrlBase), + wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxComboCtrlBase)), wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") ); - combo->OnPopupDismiss(true); + combo->OnPopupDismiss(); } #endif // USES_WXPOPUPTRANSIENTWINDOW @@ -546,7 +426,7 @@ public: void OnSizeEvent( wxSizeEvent& event ); void OnKeyEvent(wxKeyEvent& event); -#if USES_GENERICTLW +#if USES_WXDIALOG void OnActivate( wxActivateEvent& event ); #endif @@ -560,8 +440,7 @@ private: BEGIN_EVENT_TABLE(wxComboPopupWindowEvtHandler, wxEvtHandler) EVT_KEY_DOWN(wxComboPopupWindowEvtHandler::OnKeyEvent) EVT_KEY_UP(wxComboPopupWindowEvtHandler::OnKeyEvent) - EVT_CHAR(wxComboPopupWindowEvtHandler::OnKeyEvent) -#if USES_GENERICTLW +#if USES_WXDIALOG EVT_ACTIVATE(wxComboPopupWindowEvtHandler::OnActivate) #endif EVT_SIZE(wxComboPopupWindowEvtHandler::OnSizeEvent) @@ -579,16 +458,16 @@ void wxComboPopupWindowEvtHandler::OnKeyEvent( wxKeyEvent& event ) wxWindowList children = m_combo->GetPopupWindow()->GetChildren(); wxWindowList::iterator node = children.begin(); wxWindow* child = (wxWindow*)*node; - child->GetEventHandler()->ProcessEvent(event); + child->AddPendingEvent(event); } -#if USES_GENERICTLW +#if USES_WXDIALOG void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event ) { if ( !event.GetActive() ) { // Tell combo control that we are dismissed. - m_combo->HidePopup(true); + m_combo->HidePopup(); event.Skip(); } @@ -613,11 +492,6 @@ void wxComboPopup::OnDismiss() { } -wxComboCtrl* wxComboPopup::GetComboCtrl() const -{ - return wxStaticCast(m_combo, wxComboCtrl); -} - wxSize wxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int WXUNUSED(maxHeight) ) @@ -633,7 +507,7 @@ void wxComboPopup::DefaultPaintComboControl( wxComboCtrlBase* combo, combo->PrepareBackground(dc,rect,0); dc.DrawText( combo->GetValue(), - rect.x + combo->m_marginLeft, + rect.x + combo->GetTextIndent(), (rect.height-dc.GetCharHeight())/2 + rect.y ); } } @@ -648,11 +522,6 @@ void wxComboPopup::OnComboKeyEvent( wxKeyEvent& event ) event.Skip(); } -void wxComboPopup::OnComboCharEvent( wxKeyEvent& event ) -{ - event.Skip(); -} - void wxComboPopup::OnComboDoubleClick() { } @@ -661,12 +530,6 @@ void wxComboPopup::SetStringValue( const wxString& WXUNUSED(value) ) { } -bool wxComboPopup::FindItem(const wxString& WXUNUSED(item), - wxString* WXUNUSED(trueItem)) -{ - return true; -} - bool wxComboPopup::LazyCreate() { return false; @@ -674,35 +537,7 @@ bool wxComboPopup::LazyCreate() void wxComboPopup::Dismiss() { - m_combo->HidePopup(true); -} - -void wxComboPopup::DestroyPopup() -{ - // Here we make sure that the popup control's Destroy() gets called. - // This is necessary for the wxPersistentWindow to work properly. - wxWindow* popupCtrl = GetControl(); - if ( popupCtrl ) - { - // While all wxComboCtrl examples have m_popupInterface and - // popupCtrl as the same class (that will be deleted via the - // Destroy() call below), it is technically still possible to - // have implementations where they are in fact not same - // multiple-inherited class. Here we use C++ RTTI to check for - // this rare case. - #ifndef wxNO_RTTI - // It is probably better to delete m_popupInterface first, so - // that it retains access to its popup control window. - if ( dynamic_cast(this) != - dynamic_cast(popupCtrl) ) - delete this; - #endif - popupCtrl->Destroy(); - } - else - { - delete this; - } + m_combo->HidePopup(); } // ---------------------------------------------------------------------------- @@ -738,7 +573,6 @@ BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler, wxEvtHandler) EVT_KEY_UP(wxComboBoxExtraInputHandler::OnKey) EVT_CHAR(wxComboBoxExtraInputHandler::OnKey) EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus) - EVT_KILL_FOCUS(wxComboBoxExtraInputHandler::OnFocus) END_EVENT_TABLE() @@ -763,13 +597,12 @@ void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event) { // FIXME: This code does run when control is clicked, // yet on Windows it doesn't select all the text. - if ( event.GetEventType() == wxEVT_SET_FOCUS && - !(m_combo->GetInternalFlags() & wxCC_NO_TEXT_AUTO_SELECT) ) + if ( !(m_combo->GetInternalFlags() & wxCC_NO_TEXT_AUTO_SELECT) ) { if ( m_combo->GetTextCtrl() ) m_combo->GetTextCtrl()->SelectAll(); else - m_combo->SelectAll(); + m_combo->SetSelection(-1,-1); } // Send focus indication to parent. @@ -778,8 +611,7 @@ void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event) // wxEVT_SET_FOCUSes (since m_text->SetFocus is called // from combo's focus event handler), they should be quite // harmless. - wxFocusEvent evt2(event); - evt2.SetId(m_combo->GetId()); + wxFocusEvent evt2(wxEVT_SET_FOCUS,m_combo->GetId()); evt2.SetEventObject(m_combo); m_combo->GetEventHandler()->ProcessEvent(evt2); @@ -791,21 +623,17 @@ void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event) // This is pushed to the event handler queue of the control in popup. // -class wxComboPopupEvtHandler : public wxEvtHandler +class wxComboPopupExtraEventHandler : public wxEvtHandler { public: - wxComboPopupEvtHandler( wxComboCtrlBase* combo ) + wxComboPopupExtraEventHandler( wxComboCtrlBase* combo ) : wxEvtHandler() { m_combo = combo; m_beenInside = false; - - // Let's make it so that the popup control will not receive mouse - // events until mouse left button has been up. - m_blockEventsToPopup = true; } - virtual ~wxComboPopupEvtHandler() { } + virtual ~wxComboPopupExtraEventHandler() { } void OnMouseEvent( wxMouseEvent& event ); @@ -813,163 +641,92 @@ public: void OnPopupDismiss() { m_beenInside = false; - m_blockEventsToPopup = true; } protected: wxComboCtrlBase* m_combo; - bool m_beenInside; - bool m_blockEventsToPopup; + bool m_beenInside; private: DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(wxComboPopupEvtHandler, wxEvtHandler) - EVT_MOUSE_EVENTS(wxComboPopupEvtHandler::OnMouseEvent) +BEGIN_EVENT_TABLE(wxComboPopupExtraEventHandler, wxEvtHandler) + EVT_MOUSE_EVENTS(wxComboPopupExtraEventHandler::OnMouseEvent) END_EVENT_TABLE() -void wxComboPopupEvtHandler::OnMouseEvent( wxMouseEvent& event ) +void wxComboPopupExtraEventHandler::OnMouseEvent( wxMouseEvent& event ) { wxPoint pt = event.GetPosition(); wxSize sz = m_combo->GetPopupControl()->GetControl()->GetClientSize(); int evtType = event.GetEventType(); bool isInside = pt.x >= 0 && pt.y >= 0 && pt.x < sz.x && pt.y < sz.y; - bool relayToButton = false; - event.Skip(); - - if ( !isInside || !m_combo->IsPopupShown() ) + if ( evtType == wxEVT_MOTION || + evtType == wxEVT_LEFT_DOWN || + evtType == wxEVT_RIGHT_DOWN ) { - // Mouse is outside the popup or popup is not actually shown (yet) - - if ( evtType == wxEVT_MOTION || - evtType == wxEVT_LEFT_DOWN || - evtType == wxEVT_LEFT_UP || - evtType == wxEVT_RIGHT_DOWN ) - { - // Block motion and click events outside the popup - event.Skip(false); - } - } - else - { - // Mouse is inside the popup, which is fully shown - - m_beenInside = true; - - // Do not let the popup control respond to mouse events until - // mouse press used to display the popup has been lifted. This - // is important for users with slower mouse fingers or mouse - // drivers. Note that we have some redundancy here, just in - // case the popup is some native control that does not emit all - // mouse event types. - if ( evtType == wxEVT_MOTION ) - { - if ( m_blockEventsToPopup ) - { - if ( event.LeftIsDown() ) - event.Skip(false); - else - m_blockEventsToPopup = false; - } - } - else if ( evtType == wxEVT_LEFT_DOWN ) - { - if ( m_blockEventsToPopup ) - m_blockEventsToPopup = false; - } - else if ( evtType == wxEVT_LEFT_UP ) - { - if ( m_blockEventsToPopup ) - { - // On first left up, stop blocking mouse events (but still - // block this one) - m_blockEventsToPopup = false; - event.Skip(false); - - // Also, this button press was (probably) used to display - // the popup, so relay it back to the drop-down button - // (which supposedly originated it). This is necessary to - // refresh it properly. - relayToButton = true; - } - } - else if ( m_blockEventsToPopup ) + // Block motion and click events outside the popup + if ( !isInside || !m_combo->IsPopupShown() ) { event.Skip(false); + return; } } - - // - // Some mouse events to popup that happen outside it, before cursor - // has been inside the popup, need to be ignored by it but relayed to - // the dropbutton. - // - if ( evtType == wxEVT_LEFT_UP ) + else if ( evtType == wxEVT_LEFT_UP ) { if ( !m_combo->IsPopupShown() ) { event.Skip(false); - relayToButton = true; + return; } - else if ( !isInside && !m_beenInside ) + + if ( !m_beenInside ) { - // Popup is shown but the cursor is not inside, nor it has been - relayToButton = true; + if ( isInside ) + { + m_beenInside = true; + } + else + { + // + // Some mouse events to popup that happen outside it, before cursor + // has been inside the popu, need to be ignored by it but relayed to + // the dropbutton. + // + wxWindow* btn = m_combo->GetButton(); + if ( btn ) + btn->GetEventHandler()->AddPendingEvent(event); + else + m_combo->GetEventHandler()->AddPendingEvent(event); + + return; + } + + event.Skip(); } } - if ( relayToButton ) - { - wxWindow* btn = m_combo->GetButton(); - if ( btn ) - btn->GetEventHandler()->ProcessEvent(event); - else - // Bypass the event handling mechanism. Using it would be - // confusing for the platform-specific wxComboCtrl - // implementations. - m_combo->HandleButtonMouseEvent(event, 0); - } + event.Skip(); } -// ---------------------------------------------------------------------------- -// wxComboCtrlTextCtrl -// ---------------------------------------------------------------------------- - -class wxComboCtrlTextCtrl : public wxTextCtrl -{ -public: - wxComboCtrlTextCtrl() : wxTextCtrl() { } - virtual ~wxComboCtrlTextCtrl() { } - - virtual wxWindow *GetMainWindowOfCompositeControl() - { - wxComboCtrl* combo = (wxComboCtrl*) GetParent(); - - // Returning this instead of just 'parent' lets FindFocus work - // correctly even when parent control is a child of a composite - // generic control (as is case with wxGenericDatePickerCtrl). - return combo->GetMainWindowOfCompositeControl(); - } -}; - // ---------------------------------------------------------------------------- // wxComboCtrlBase // ---------------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxComboCtrlBase, wxControl) + EVT_TEXT(wxID_ANY,wxComboCtrlBase::OnTextCtrlEvent) EVT_SIZE(wxComboCtrlBase::OnSizeEvent) EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent) EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent) EVT_IDLE(wxComboCtrlBase::OnIdleEvent) //EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent) EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent) - EVT_CHAR(wxComboCtrlBase::OnCharEvent) + EVT_TEXT_ENTER(wxID_ANY,wxComboCtrlBase::OnTextCtrlEvent) EVT_SYS_COLOUR_CHANGED(wxComboCtrlBase::OnSysColourChanged) END_EVENT_TABLE() @@ -978,18 +735,18 @@ IMPLEMENT_ABSTRACT_CLASS(wxComboCtrlBase, wxControl) void wxComboCtrlBase::Init() { - m_winPopup = NULL; - m_popup = NULL; + m_winPopup = (wxWindow *)NULL; + m_popup = (wxWindow *)NULL; m_popupWinState = Hidden; - m_btn = NULL; - m_text = NULL; - m_popupInterface = NULL; + m_btn = (wxWindow*) NULL; + m_text = (wxTextCtrl*) NULL; + m_popupInterface = (wxComboPopup*) NULL; - m_popupEvtHandler = NULL; - m_textEvtHandler = NULL; + m_popupExtraHandler = (wxEvtHandler*) NULL; + m_textEvtHandler = (wxEvtHandler*) NULL; #if INSTALL_TOPLEV_HANDLER - m_toplevEvtHandler = NULL; + m_toplevEvtHandler = (wxEvtHandler*) NULL; #endif m_mainCtrlWnd = this; @@ -1011,13 +768,11 @@ void wxComboCtrlBase::Init() m_extLeft = 0; m_extRight = 0; - m_marginLeft = -1; + m_absIndent = -1; m_iFlags = 0; - m_textCtrlStyle = 0; m_timeCanAcceptClick = 0; m_resetFocus = false; - m_hasTcBgCol = false; } bool wxComboCtrlBase::Create(wxWindow *parent, @@ -1042,16 +797,15 @@ bool wxComboCtrlBase::Create(wxWindow *parent, // Get colours OnThemeChange(); - m_marginLeft = GetNativeTextIndent(); + m_absIndent = GetNativeTextIndent(); m_iFlags |= wxCC_IFLAG_CREATED; // If x and y indicate valid size, wxSizeEvent won't be - // emitted automatically, so we need to add artificial one. + // emitted automatically, so we need to add artifical one. if ( size.x > 0 && size.y > 0 ) { wxSizeEvent evt(size,GetId()); - evt.SetEventObject(this); GetEventHandler()->AddPendingEvent(evt); } @@ -1068,7 +822,7 @@ void wxComboCtrlBase::InstallInputHandlers() } void -wxComboCtrlBase::CreateTextCtrl(int style) +wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator) { if ( !(m_windowStyle & wxCB_READONLY) ) { @@ -1079,7 +833,7 @@ wxComboCtrlBase::CreateTextCtrl(int style) // not used by the wxPropertyGrid and therefore the tab is processed by // looking at ancestors to see if they have wxTAB_TRAVERSAL. The // navigation event is then sent to the wrong window. - style |= wxTE_PROCESS_TAB | m_textCtrlStyle; + style |= wxTE_PROCESS_TAB; if ( HasFlag(wxTE_PROCESS_ENTER) ) style |= wxTE_PROCESS_ENTER; @@ -1092,53 +846,31 @@ wxComboCtrlBase::CreateTextCtrl(int style) else m_ignoreEvtText = 0; - m_text = new wxComboCtrlTextCtrl(); - m_text->Create(this, wxID_ANY, m_valueString, - wxDefaultPosition, wxSize(10,-1), - style); - - // Connecting the events is currently the most reliable way - wxWindowID id = m_text->GetId(); - m_text->Connect(id, wxEVT_TEXT, - wxCommandEventHandler(wxComboCtrlBase::OnTextCtrlEvent), - NULL, this); - m_text->Connect(id, wxEVT_TEXT_ENTER, - wxCommandEventHandler(wxComboCtrlBase::OnTextCtrlEvent), - NULL, this); - - m_text->SetHint(m_hintText); + m_text = new wxTextCtrl(this, wxID_ANY, m_valueString, + wxDefaultPosition, wxSize(10,-1), + style, validator); } } void wxComboCtrlBase::OnThemeChange() { - // Because wxComboCtrl has transparent parts on most platforms, we - // don't want to touch the actual background colour. Instead, we just - // usually re-obtain m_tcBgCol here. - -#if defined(__WXMSW__) || defined(__WXGTK__) - wxVisualAttributes vattrs = wxComboBox::GetClassDefaultAttributes(); -#else - wxVisualAttributes vattrs; - vattrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); - vattrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); -#endif - - if ( !m_hasTcBgCol ) - m_tcBgCol = vattrs.colBg; - + // Leave the default bg on the Mac so the area used by the focus ring will + // be the correct colour and themed brush. Instead we'll use + // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed. #ifndef __WXMAC__ - // Only change the colours if application has not specified - // custom ones. - if ( !m_hasFgCol ) + if ( !m_hasBgCol ) { - SetOwnForegroundColour(vattrs.colFg); +#ifdef __WXGTK__ + // Set background to gtk_rc_get_style(m_widget)->bg[GTK_STATE_NORMAL], + // which can be different than the background of text entry. + wxColour bgCol = GetDefaultAttributes().colBg; +#else + wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#endif + SetOwnBackgroundColour(bgCol); + m_hasBgCol = false; } - if ( !HasTransparentBackground() ) - { - SetOwnBackgroundColour(GetParent()->GetBackgroundColour()); - } -#endif // !__WXMAC__ +#endif } wxComboCtrlBase::~wxComboCtrlBase() @@ -1148,7 +880,7 @@ wxComboCtrlBase::~wxComboCtrlBase() #if INSTALL_TOPLEV_HANDLER delete ((wxComboFrameEventHandler*)m_toplevEvtHandler); - m_toplevEvtHandler = NULL; + m_toplevEvtHandler = (wxEvtHandler*) NULL; #endif DestroyPopup(); @@ -1175,19 +907,13 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth ) // its platform default or bitmap+pushbutton background is used, but not if // there is vertical size adjustment or horizontal spacing. if ( ( (m_iFlags & wxCC_BUTTON_OUTSIDE_BORDER) || - (m_bmpNormal.IsOk() && m_blankButtonBg) ) && + (m_bmpNormal.Ok() && m_blankButtonBg) ) && m_btnSpacingX == 0 && m_btnHei <= 0 ) { m_iFlags |= wxCC_IFLAG_BUTTON_OUTSIDE; btnBorder = 0; } - else if ( (m_iFlags & wxCC_BUTTON_COVERS_BORDER) && - m_btnSpacingX == 0 && !m_bmpNormal.IsOk() ) - { - m_iFlags &= ~(wxCC_IFLAG_BUTTON_OUTSIDE); - btnBorder = 0; - } else { m_iFlags &= ~(wxCC_IFLAG_BUTTON_OUTSIDE); @@ -1195,8 +921,8 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth ) } // Defaul indentation - if ( m_marginLeft < 0 ) - m_marginLeft = GetNativeTextIndent(); + if ( m_absIndent < 0 ) + m_absIndent = GetNativeTextIndent(); int butWidth = btnWidth; @@ -1240,7 +966,7 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth ) // It is larger // OR // button width is set to default and blank button bg is not drawn - if ( m_bmpNormal.IsOk() ) + if ( m_bmpNormal.Ok() ) { int bmpReqWidth = m_bmpNormal.GetWidth(); int bmpReqHeight = m_bmpNormal.GetHeight(); @@ -1262,11 +988,6 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth ) { int newY = butHeight+(customBorder*2); SetClientSize(wxDefaultCoord,newY); - if ( m_bmpNormal.IsOk() || m_btnArea.width != butWidth || m_btnArea.height != butHeight ) - m_iFlags |= wxCC_IFLAG_HAS_NONSTANDARD_BUTTON; - else - m_iFlags &= ~wxCC_IFLAG_HAS_NONSTANDARD_BUTTON; - sz.y = newY; } } @@ -1300,122 +1021,70 @@ void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust if ( !m_text ) return; +#if !TEXTCTRL_TEXT_CENTERED + wxSize sz = GetClientSize(); int customBorder = m_widthCustomBorder; if ( (m_text->GetWindowStyleFlag() & wxBORDER_MASK) == wxNO_BORDER ) { - int x; - - if ( !m_widthCustomPaint ) - { - // No special custom paint area - we can use 0 left margin - // with wxTextCtrl. - if ( m_text->SetMargins(0) ) - textCtrlXAdjust = 0; - x = m_tcArea.x + m_marginLeft + textCtrlXAdjust; - } - else - { - // There is special custom paint area - it is better to - // use some margin with the wxTextCtrl. - m_text->SetMargins(m_marginLeft); - x = m_tcArea.x + m_widthCustomPaint + - m_marginLeft + textCtrlXAdjust; - } - - // Centre textctrl vertically, if needed -#if !TEXTCTRL_TEXT_CENTERED + // Centre textctrl int tcSizeY = m_text->GetBestSize().y; - int diff0 = sz.y - tcSizeY; - int y = textCtrlYAdjust + (diff0/2); -#else - wxUnusedVar(textCtrlYAdjust); - int y = 0; -#endif + int diff = sz.y - tcSizeY; + int y = textCtrlYAdjust + (diff/2); if ( y < customBorder ) y = customBorder; - m_text->SetSize(x, - y, - m_tcArea.width - m_tcArea.x - x, - -1 ); + m_text->SetSize( m_tcArea.x + m_widthCustomPaint + m_absIndent + textCtrlXAdjust, + y, + m_tcArea.width - COMBO_MARGIN - + (textCtrlXAdjust + m_widthCustomPaint + m_absIndent), + -1 ); // Make sure textctrl doesn't exceed the bottom custom border wxSize tsz = m_text->GetSize(); - int diff1 = (y + tsz.y) - (sz.y - customBorder); - if ( diff1 >= 0 ) + diff = (y + tsz.y) - (sz.y - customBorder); + if ( diff >= 0 ) { - tsz.y = tsz.y - diff1 - 1; + tsz.y = tsz.y - diff - 1; m_text->SetSize(tsz); } } else +#else // TEXTCTRL_TEXT_CENTERED + wxUnusedVar(textCtrlXAdjust); + wxUnusedVar(textCtrlYAdjust); +#endif // !TEXTCTRL_TEXT_CENTERED/TEXTCTRL_TEXT_CENTERED { - // If it has border, have textctrl fill the entire text field. - int w = m_tcArea.width - m_widthCustomPaint; - if (w < 0) w = 0; + // If it has border, have textctrl will the entire text field. m_text->SetSize( m_tcArea.x + m_widthCustomPaint, m_tcArea.y, - w, + m_tcArea.width - m_widthCustomPaint, m_tcArea.height ); } } wxSize wxComboCtrlBase::DoGetBestSize() const { - int width = m_text ? m_text->GetBestSize().x : 80; + wxSize sizeText(150,0); - return GetSizeFromTextSize(width); -} + if ( m_text ) + sizeText = m_text->GetBestSize(); -wxSize wxComboCtrlBase::DoGetSizeFromTextSize(int xlen, int ylen) const -{ - // Calculate close-to-native control height + // TODO: Better method to calculate close-to-native control height. int fhei; - -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - fhei = EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight()); -#elif defined(__WXGTK__) && !defined(__WXUNIVERSAL__) - // Control creation is not entirely cheap, so cache the heights to - // avoid repeatedly creating dummy controls: - static wxString s_last_font; - static int s_last_fhei = -1; - wxString fontdesc; - if ( m_font.IsOk() ) - fontdesc = m_font.GetNativeFontInfoDesc(); - if ( s_last_fhei != -1 && fontdesc == s_last_font ) - { - fhei = s_last_fhei; - } - else - { - wxComboBox* cb = new wxComboBox; -#ifndef __WXGTK3__ - // GTK3 returns zero for the preferred size of a hidden widget - cb->Hide(); -#endif - cb->Create(const_cast(this), wxID_ANY); - if ( m_font.IsOk() ) - cb->SetFont(m_font); - s_last_font = fontdesc; - s_last_fhei = fhei = cb->GetBestSize().y; - cb->Destroy(); - } -#else - if ( m_font.IsOk() ) + if ( m_font.Ok() ) fhei = (m_font.GetPointSize()*2) + 5; - else if ( wxNORMAL_FONT->IsOk() ) + else if ( wxNORMAL_FONT->Ok() ) fhei = (wxNORMAL_FONT->GetPointSize()*2) + 5; else - fhei = 22; -#endif // only for wxComboBox on MSW or GTK + fhei = sizeText.y + 4; - // Need to force height to accommodate bitmap? + // Need to force height to accomodate bitmap? int btnSizeY = m_btnSize.y; - if ( m_bmpNormal.IsOk() && fhei < btnSizeY ) + if ( m_bmpNormal.Ok() && fhei < btnSizeY ) fhei = btnSizeY; // Control height doesn't depend on border @@ -1431,6 +1100,11 @@ wxSize wxComboCtrlBase::DoGetSizeFromTextSize(int xlen, int ylen) const fhei += 4; */ + // Final adjustments +#ifdef __WXGTK__ + fhei += 1; +#endif + #ifdef __WXMAC__ // these are the numbers from the HIG: switch ( m_windowVariant ) @@ -1449,19 +1123,11 @@ wxSize wxComboCtrlBase::DoGetSizeFromTextSize(int xlen, int ylen) const #endif fhei += 2 * FOCUS_RING; + int width = sizeText.x + FOCUS_RING + COMBO_MARGIN + DEFAULT_DROPBUTTON_WIDTH; - // Calculate width - int fwid = xlen + FOCUS_RING + COMBO_MARGIN + DEFAULT_DROPBUTTON_WIDTH; - - // Add the margins we have previously set - wxPoint marg( GetMargins() ); - fwid += wxMax(0, marg.x); - fhei += wxMax(0, marg.y); - - if ( ylen > 0 ) - fhei += ylen - GetCharHeight(); - - return wxSize(fwid, fhei); + wxSize ret(width, fhei); + CacheBestSize(ret); + return ret; } void wxComboCtrlBase::OnSizeEvent( wxSizeEvent& event ) @@ -1488,7 +1154,7 @@ bool wxComboCtrlBase::Enable(bool enable) m_btn->Enable(enable); if ( m_text ) m_text->Enable(enable); - + Refresh(); return true; @@ -1513,15 +1179,8 @@ bool wxComboCtrlBase::SetFont ( const wxFont& font ) if ( !wxControl::SetFont(font) ) return false; - if ( m_text ) - { - // Without hiding the wxTextCtrl there would be some - // visible 'flicker' (at least on Windows XP). - m_text->Hide(); + if (m_text) m_text->SetFont(font); - OnResize(); - m_text->Show(); - } return true; } @@ -1540,38 +1199,30 @@ void wxComboCtrlBase::DoSetToolTip(wxToolTip *tooltip) } else { - if ( m_text ) m_text->SetToolTip( NULL ); - if ( m_btn ) m_btn->SetToolTip( NULL ); + if ( m_text ) m_text->SetToolTip( (wxToolTip*) NULL ); + if ( m_btn ) m_btn->SetToolTip( (wxToolTip*) NULL ); } } #endif // wxUSE_TOOLTIPS -bool wxComboCtrlBase::SetForegroundColour(const wxColour& colour) +#if wxUSE_VALIDATORS +void wxComboCtrlBase::SetValidator(const wxValidator& validator) { - if ( wxControl::SetForegroundColour(colour) ) - { - if ( m_text ) - m_text->SetForegroundColour(colour); - return true; - } - return false; + wxTextCtrl* textCtrl = GetTextCtrl(); + + if ( textCtrl ) + textCtrl->SetValidator( validator ); + else + wxControl::SetValidator( validator ); } -bool wxComboCtrlBase::SetBackgroundColour(const wxColour& colour) +wxValidator* wxComboCtrlBase::GetValidator() { - if ( m_text ) - m_text->SetBackgroundColour(colour); - m_tcBgCol = colour; - m_hasTcBgCol = true; - return true; -} + wxTextCtrl* textCtrl = GetTextCtrl(); -wxColour wxComboCtrlBase::GetBackgroundColour() const -{ - if ( m_text ) - return m_text->GetBackgroundColour(); - return m_tcBgCol; + return textCtrl ? textCtrl->GetValidator() : wxControl::GetValidator(); } +#endif // wxUSE_VALIDATORS // ---------------------------------------------------------------------------- // painting @@ -1583,7 +1234,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags { wxSize sz = GetClientSize(); bool isEnabled; - bool doDrawFocusRect; // also selected + bool isFocused; // also selected // For smaller size control (and for disabled background) use less spacing int focusSpacingX; @@ -1593,7 +1244,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags { // Drawing control isEnabled = IsEnabled(); - doDrawFocusRect = ShouldDrawFocus() && !(m_iFlags & wxCC_FULL_BUTTON); + isFocused = ShouldDrawFocus(); // Windows-style: for smaller size control (and for disabled background) use less spacing focusSpacingX = isEnabled ? 2 : 1; @@ -1603,7 +1254,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags { // Drawing a list item isEnabled = true; // they are never disabled - doDrawFocusRect = (flags & wxCONTROL_SELECTED) != 0; + isFocused = flags & wxCONTROL_SELECTED ? true : false; focusSpacingX = 0; focusSpacingY = 0; @@ -1622,71 +1273,51 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags selRect.x += wcp + focusSpacingX; selRect.width -= wcp + (focusSpacingX*2); - wxColour bgCol; wxColour fgCol; + wxColour bgCol; - bool doDrawSelRect = true; - - // Determine foreground colour if ( isEnabled ) { - if ( doDrawFocusRect ) - { + if ( isFocused ) fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - } else if ( m_hasFgCol ) - { // Honour the custom foreground colour fgCol = GetForegroundColour(); - } else - { fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); - } } else { fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } - // Determine background colour if ( isEnabled ) { - if ( doDrawFocusRect ) - { + if ( isFocused ) bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - } - else if ( m_hasTcBgCol ) - { + else if ( m_hasBgCol ) // Honour the custom background colour - bgCol = m_tcBgCol; - } - else - { -#ifndef __WXMAC__ // see note in OnThemeChange - doDrawSelRect = false; bgCol = GetBackgroundColour(); -#else + else +#if defined(__WXMAC__) || defined(__WXGTK__) // see note in OnThemeChange bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#else + bgCol = GetBackgroundColour(); #endif - } } else { -#ifndef __WXMAC__ // see note in OnThemeChange - bgCol = GetBackgroundColour(); -#else +#if defined(__WXMAC__) || defined(__WXGTK__) // see note in OnThemeChange bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#else + bgCol = GetBackgroundColour(); #endif } dc.SetTextForeground( fgCol ); dc.SetBrush( bgCol ); - if ( doDrawSelRect ) - { - dc.SetPen( bgCol ); - dc.DrawRectangle( selRect ); - } + dc.SetPen( bgCol ); + dc.DrawRectangle( selRect ); // Don't clip exactly to the selection rectangle so we can draw // to the non-selected area in front of it. @@ -1705,9 +1336,10 @@ void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, int flags ) { int drawState = m_btnState; - if ( (m_iFlags & wxCC_BUTTON_STAYS_DOWN) && - GetPopupWindowState() >= Animating ) +#ifdef __WXGTK__ + if ( GetPopupWindowState() >= Animating ) drawState |= wxCONTROL_PRESSED; +#endif wxRect drawRect(rect.x+m_btnSpacingX, rect.y+((rect.height-m_btnSize.y)/2), @@ -1725,29 +1357,26 @@ void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, int flags ) if ( !enabled ) drawState |= wxCONTROL_DISABLED; - // Need to clear button background even if m_btn is present - // and also when using custom bitmap for the button - if ( (flags & Button_PaintBackground) && - (!HasTransparentBackground() || - !(m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE)) ) + if ( !m_bmpNormal.Ok() ) { - wxColour bgCol; - - if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) - bgCol = GetParent()->GetBackgroundColour(); - else - bgCol = GetBackgroundColour(); - - dc.SetBrush(bgCol); - dc.SetPen(bgCol); - dc.DrawRectangle(rect); - } - - if ( !m_bmpNormal.IsOk() ) - { - if ( flags & Button_BitmapOnly ) + if ( flags & Draw_BitmapOnly ) return; + // Need to clear button background even if m_btn is present + if ( flags & Draw_PaintBg ) + { + wxColour bgCol; + + if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) + bgCol = GetParent()->GetBackgroundColour(); + else + bgCol = GetBackgroundColour(); + + dc.SetBrush(bgCol); + dc.SetPen(bgCol); + dc.DrawRectangle(rect); + } + // Draw standard button wxRendererNative::Get().DrawComboBoxDropButton(this, dc, @@ -1771,13 +1400,30 @@ void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, int flags ) if ( m_blankButtonBg ) { - if ( !(flags & Button_BitmapOnly) ) + // If using blank button background, we need to clear its background + // with button face colour instead of colour for rest of the control. + if ( flags & Draw_PaintBg ) { - wxRendererNative::Get().DrawPushButton(this, - dc, - drawRect, - drawState); + wxColour bgCol = GetParent()->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); + //wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + dc.SetPen(bgCol); + dc.SetBrush(bgCol); + dc.DrawRectangle(rect); } + + wxRendererNative::Get().DrawPushButton(this, + dc, + drawRect, + drawState); + + } + else + + { + // Need to clear button background even if m_btn is present + // (assume non-button background was cleared just before this call so brushes are good) + if ( flags & Draw_PaintBg ) + dc.DrawRectangle(rect); } // Draw bitmap centered in drawRect @@ -1793,7 +1439,6 @@ void wxComboCtrlBase::RecalcAndRefresh() if ( IsCreated() ) { wxSizeEvent evt(GetSize(),GetId()); - evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); Refresh(); } @@ -1805,14 +1450,7 @@ void wxComboCtrlBase::RecalcAndRefresh() void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent& event) { - // Avoid infinite recursion - if ( event.GetEventObject() == this ) - { - event.Skip(); - return; - } - - if ( event.GetEventType() == wxEVT_TEXT ) + if ( event.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED ) { if ( m_ignoreEvtText > 0 ) { @@ -1821,25 +1459,23 @@ void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent& event) } } - // For safety, completely re-create a new wxCommandEvent - wxCommandEvent evt2(event); - evt2.SetId(GetId()); - evt2.SetEventObject(this); - HandleWindowEvent(evt2); - - event.StopPropagation(); + // Change event id, object and string before relaying it forward + event.SetId(GetId()); + wxString s = event.GetString(); + event.SetEventObject(this); + event.SetString(s); + event.Skip(); } // call if cursor is on button area or mouse is captured for the button bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent& event, - int flags ) + int flags ) { int type = event.GetEventType(); if ( type == wxEVT_MOTION ) { - if ( (flags & wxCC_MF_ON_BUTTON) && - IsPopupWindowState(Hidden) ) + if ( flags & wxCC_MF_ON_BUTTON ) { if ( !(m_btnState & wxCONTROL_CURRENT) ) { @@ -1908,11 +1544,6 @@ bool wxComboCtrlBase::HandleButtonMouseEvent( wxMouseEvent& event, else return false; - // Never have 'hot' state when popup is being shown - // (this is mostly needed because of the animation). - if ( !IsPopupWindowState(Hidden) ) - m_btnState &= ~wxCONTROL_CURRENT; - return true; } @@ -1923,19 +1554,19 @@ bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent& event, wxLongLong t = ::wxGetLocalTimeMillis(); int evtType = event.GetEventType(); -#if USES_WXPOPUPWINDOW || USES_GENERICTLW +#if USES_WXPOPUPWINDOW || USES_WXDIALOG if ( m_popupWinType != POPUPWIN_WXPOPUPTRANSIENTWINDOW ) { if ( IsPopupWindowState(Visible) && ( evtType == wxEVT_LEFT_DOWN || evtType == wxEVT_RIGHT_DOWN ) ) { - HidePopup(true); + HidePopup(); return true; } } #endif - // Filter out clicks on button immediately after popup dismiss + // Filter out clicks on button immediately after popup dismiss (Windows like behaviour) if ( evtType == wxEVT_LEFT_DOWN && t < m_timeCanAcceptClick ) { event.SetEventType(0); @@ -1957,7 +1588,7 @@ void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent& event ) #if USES_WXPOPUPWINDOW // Click here always hides the popup. if ( m_popupWinType == POPUPWIN_WXPOPUPWINDOW ) - HidePopup(true); + HidePopup(); #endif } else @@ -1977,35 +1608,15 @@ void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent& event ) } } } - else if ( evtType == wxEVT_MOUSEWHEEL ) + else + if ( IsPopupShown() ) { - if ( IsPopupShown() ) - { - // relay (some) mouse events to the popup - m_popup->GetEventHandler()->ProcessEvent(event); - } - else if ( event.GetWheelAxis() == 0 && - event.GetWheelRotation() != 0 && - event.GetModifiers() == 0 ) - { - // Translate mousewheel actions into key up/down. This is - // the simplest way of getting native behaviour: scrolling the - // wheel moves selection up/down by one item. - wxKeyEvent kevent(wxEVT_KEY_DOWN); - kevent.m_keyCode = event.GetWheelRotation() > 0 - ? WXK_UP - : WXK_DOWN; - GetEventHandler()->ProcessEvent(kevent); - } - else - { - event.Skip(); - } + // relay (some) mouse events to the popup + if ( evtType == wxEVT_MOUSEWHEEL ) + m_popup->AddPendingEvent(event); } else if ( evtType ) - { event.Skip(); - } } void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event) @@ -2013,16 +1624,26 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event) if ( IsPopupShown() ) { // pass it to the popped up control - GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event); + GetPopupControl()->GetControl()->AddPendingEvent(event); } else // no popup { + int keycode = event.GetKeyCode(); + wxWindow* mainCtrl = GetMainWindowOfCompositeControl(); - if ( mainCtrl->GetParent()->HasFlag(wxTAB_TRAVERSAL) ) + if ( mainCtrl->GetParent()->HasFlag(wxTAB_TRAVERSAL) && + keycode == WXK_TAB ) { - if ( mainCtrl->HandleAsNavigationKey(event) ) - return; + wxNavigationKeyEvent evt; + + evt.SetFlags(wxNavigationKeyEvent::FromTab| + (!event.ShiftDown() ? wxNavigationKeyEvent::IsForward + : wxNavigationKeyEvent::IsBackward)); + evt.SetEventObject(mainCtrl); + evt.SetCurrentFocus(mainCtrl); + mainCtrl->GetParent()->GetEventHandler()->AddPendingEvent(evt); + return; } if ( IsKeyPopupToggle(event) ) @@ -2040,8 +1661,6 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event) return; } - int keycode = event.GetKeyCode(); - if ( (comboStyle & wxCB_READONLY) || (keycode != WXK_RIGHT && keycode != WXK_LEFT) ) { @@ -2052,45 +1671,19 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event) } } -void wxComboCtrlBase::OnCharEvent(wxKeyEvent& event) -{ - if ( IsPopupShown() ) - { - // pass it to the popped up control - GetPopupControl()->GetControl()->GetEventHandler()->ProcessEvent(event); - } - else // no popup - { - wxComboPopup* popupInterface = GetPopupControl(); - if ( popupInterface ) - { - popupInterface->OnComboCharEvent(event); - } - else - { - event.Skip(); - } - } -} - void wxComboCtrlBase::OnFocusEvent( wxFocusEvent& event ) { - // On Mac, setting focus here leads to infinite recursion and eventually - // a crash due to the SetFocus call producing another event. - // Handle Mac in OnIdleEvent using m_resetFocus. - if ( event.GetEventType() == wxEVT_SET_FOCUS ) { - if ( GetTextCtrl() && !GetTextCtrl()->HasFocus() ) - { + wxWindow* tc = GetTextCtrl(); + if ( tc && tc != DoFindFocus() ) #ifdef __WXMAC__ m_resetFocus = true; #else - GetTextCtrl()->SetFocus(); + tc->SetFocus(); #endif - } } - + Refresh(); } @@ -2099,17 +1692,18 @@ void wxComboCtrlBase::OnIdleEvent( wxIdleEvent& WXUNUSED(event) ) if ( m_resetFocus ) { m_resetFocus = false; - if ( GetTextCtrl() ) - GetTextCtrl()->SetFocus(); + wxWindow* tc = GetTextCtrl(); + if ( tc ) + tc->SetFocus(); } } void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) { OnThemeChange(); - // left margin may also have changed - if ( !(m_iFlags & wxCC_IFLAG_LEFT_MARGIN_SET) ) - m_marginLeft = GetNativeTextIndent(); + // indentation may also have changed + if ( !(m_iFlags & wxCC_IFLAG_INDENT_SET) ) + m_absIndent = GetNativeTextIndent(); RecalcAndRefresh(); } @@ -2128,28 +1722,17 @@ void wxComboCtrlBase::CreatePopup() #ifdef wxComboPopupWindowBase2 if ( m_iFlags & wxCC_IFLAG_USE_ALT_POPUP ) { - #if !USES_GENERICTLW + #if !USES_WXDIALOG m_winPopup = new wxComboPopupWindowBase2( this, wxNO_BORDER ); #else - int tlwFlags = wxNO_BORDER; - #ifdef wxCC_GENERIC_TLW_IS_FRAME - tlwFlags |= wxFRAME_NO_TASKBAR; - #endif - - #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW - m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY, - wxPoint(-21,-21), wxSize(20, 20), - tlwFlags ); - #else m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY, wxEmptyString, wxPoint(-21,-21), wxSize(20, 20), - tlwFlags ); - #endif + wxNO_BORDER ); #endif m_popupWinType = SECONDARY_POPUP_TYPE; } else -#endif // wxComboPopupWindowBase2 +#endif { m_winPopup = new wxComboPopupWindow( this, wxNO_BORDER ); m_popupWinType = PRIMARY_POPUP_TYPE; @@ -2161,8 +1744,8 @@ void wxComboCtrlBase::CreatePopup() popupInterface->Create(m_winPopup); m_popup = popup = popupInterface->GetControl(); - m_popupEvtHandler = new wxComboPopupEvtHandler(this); - popup->PushEventHandler( m_popupEvtHandler ); + m_popupExtraHandler = new wxComboPopupExtraEventHandler(this); + popup->PushEventHandler( m_popupExtraHandler ); // This may be helpful on some platforms // (eg. it bypasses a wxGTK popupwindow bug where @@ -2175,29 +1758,27 @@ void wxComboCtrlBase::CreatePopup() // Destroy popup window and the child control void wxComboCtrlBase::DestroyPopup() { - HidePopup(true); + HidePopup(); if ( m_popup ) - m_popup->RemoveEventHandler(m_popupEvtHandler); + m_popup->RemoveEventHandler(m_popupExtraHandler); - wxDELETE(m_popupEvtHandler); + delete m_popupExtraHandler; - if ( m_popupInterface ) - { - // NB: DestroyPopup() performs 'delete this'. - m_popupInterface->DestroyPopup(); - m_popupInterface = NULL; - } + delete m_popupInterface; if ( m_winPopup ) { m_winPopup->RemoveEventHandler(m_popupWinEvtHandler); - wxDELETE(m_popupWinEvtHandler); + delete m_popupWinEvtHandler; + m_popupWinEvtHandler = NULL; m_winPopup->Destroy(); - m_winPopup = NULL; } - m_popup = NULL; + m_popupExtraHandler = (wxEvtHandler*) NULL; + m_popupInterface = (wxComboPopup*) NULL; + m_winPopup = (wxWindow*) NULL; + m_popup = (wxWindow*) NULL; } void wxComboCtrlBase::DoSetPopupControl(wxComboPopup* iface) @@ -2217,11 +1798,11 @@ void wxComboCtrlBase::DoSetPopupControl(wxComboPopup* iface) } else { - m_popup = NULL; + m_popup = (wxWindow*) NULL; } // This must be done after creation - if ( !m_valueString.empty() ) + if ( m_valueString.length() ) { iface->SetStringValue(m_valueString); //Refresh(); @@ -2239,30 +1820,10 @@ void wxComboCtrlBase::OnButtonClick() { // Derived classes can override this method for totally custom // popup action - switch ( GetPopupWindowState() ) - { - case Hidden: - { - Popup(); - break; - } - - case Animating: - case Visible: - { - HidePopup(true); - break; - } - } -} - -void wxComboCtrlBase::Popup() -{ - wxCommandEvent event(wxEVT_COMBOBOX_DROPDOWN, GetId()); - event.SetEventObject(this); - HandleWindowEvent(event); - - ShowPopup(); + if ( !IsPopupWindowState(Visible) ) + ShowPopup(); + else + HidePopup(); } void wxComboCtrlBase::ShowPopup() @@ -2309,8 +1870,7 @@ void wxComboCtrlBase::ShowPopup() // that if transient popup is open, then tab traversal is to be ignored. // However, I think this code would still be needed for cases where // transient popup doesn't work yet (wxWinCE?). - wxWindow* mainCtrl = GetMainWindowOfCompositeControl(); - wxWindow* parent = mainCtrl->GetParent(); + wxWindow* parent = GetParent(); int parentFlags = parent->GetWindowStyle(); if ( parentFlags & wxTAB_TRAVERSAL ) { @@ -2461,21 +2021,9 @@ void wxComboCtrlBase::DoShowPopup( const wxRect& rect, int WXUNUSED(flags) ) // (though the bug was probably fixed). winPopup->SetSize( rect ); -#if USES_WXPOPUPTRANSIENTWINDOW - if ( m_popupWinType == POPUPWIN_WXPOPUPTRANSIENTWINDOW ) - ((wxPopupTransientWindow*)winPopup)->Popup(m_popup); - else -#endif - winPopup->Show(); + winPopup->Show(); m_popupWinState = Visible; - - // If popup window was a generic top-level window, or the - // wxPopupWindow implemenation on this platform is classified as - // perfect, then we should be able to safely set focus to the popup - // control. - if ( IsPopupWinTypePerfect(m_popupWinType) ) - m_popup->SetFocus(); } else if ( IsPopupWindowState(Hidden) ) { @@ -2485,11 +2033,9 @@ void wxComboCtrlBase::DoShowPopup( const wxRect& rect, int WXUNUSED(flags) ) m_popupWinState = Hidden; } - - Refresh(); } -void wxComboCtrlBase::OnPopupDismiss(bool generateEvent) +void wxComboCtrlBase::OnPopupDismiss() { // Just in case, avoid double dismiss if ( IsPopupWindowState(Hidden) ) @@ -2505,8 +2051,8 @@ void wxComboCtrlBase::OnPopupDismiss(bool generateEvent) // Inform popup control itself m_popupInterface->OnDismiss(); - if ( m_popupEvtHandler ) - ((wxComboPopupEvtHandler*)m_popupEvtHandler)->OnPopupDismiss(); + if ( m_popupExtraHandler ) + ((wxComboPopupExtraEventHandler*)m_popupExtraHandler)->OnPopupDismiss(); #if INSTALL_TOPLEV_HANDLER // Remove top level window event handler @@ -2541,16 +2087,9 @@ void wxComboCtrlBase::OnPopupDismiss(bool generateEvent) Refresh(); SetFocus(); - - if ( generateEvent ) - { - wxCommandEvent event(wxEVT_COMBOBOX_CLOSEUP, GetId()); - event.SetEventObject(this); - HandleWindowEvent(event); - } } -void wxComboCtrlBase::HidePopup(bool generateEvent) +void wxComboCtrlBase::HidePopup() { // Should be able to call this without popup interface if ( IsPopupWindowState(Hidden) ) @@ -2558,11 +2097,11 @@ void wxComboCtrlBase::HidePopup(bool generateEvent) // transfer value and show it in textctrl, if any if ( !IsPopupWindowState(Animating) ) - SetValueByUser( m_popupInterface->GetStringValue() ); + SetValue( m_popupInterface->GetStringValue() ); m_winPopup->Hide(); - OnPopupDismiss(generateEvent); + OnPopupDismiss(); } // ---------------------------------------------------------------------------- @@ -2611,17 +2150,17 @@ void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap& bmpNormal, m_bmpNormal = bmpNormal; m_blankButtonBg = blankButtonBg; - if ( bmpPressed.IsOk() ) + if ( bmpPressed.Ok() ) m_bmpPressed = bmpPressed; else m_bmpPressed = bmpNormal; - if ( bmpHover.IsOk() ) + if ( bmpHover.Ok() ) m_bmpHover = bmpHover; else m_bmpHover = bmpNormal; - if ( bmpDisabled.IsOk() ) + if ( bmpDisabled.Ok() ) m_bmpDisabled = bmpDisabled; else m_bmpDisabled = bmpNormal; @@ -2646,139 +2185,68 @@ void wxComboCtrlBase::SetCustomPaintWidth( int width ) RecalcAndRefresh(); } -bool wxComboCtrlBase::DoSetMargins(const wxPoint& margins) -{ - // For general sanity's sake, we ignore top margin. Instead - // we will always try to center the text vertically. - bool res = true; - - if ( margins.x != -1 ) - { - m_marginLeft = margins.x; - m_iFlags |= wxCC_IFLAG_LEFT_MARGIN_SET; - } - else - { - m_marginLeft = GetNativeTextIndent(); - m_iFlags &= ~(wxCC_IFLAG_LEFT_MARGIN_SET); - } - - if ( margins.y != -1 ) - { - res = false; - } - - RecalcAndRefresh(); - - return res; -} - -wxPoint wxComboCtrlBase::DoGetMargins() const -{ - return wxPoint(m_marginLeft, -1); -} - -#if WXWIN_COMPATIBILITY_2_8 void wxComboCtrlBase::SetTextIndent( int indent ) { if ( indent < 0 ) { - m_marginLeft = GetNativeTextIndent(); - m_iFlags &= ~(wxCC_IFLAG_LEFT_MARGIN_SET); + m_absIndent = GetNativeTextIndent(); + m_iFlags &= ~(wxCC_IFLAG_INDENT_SET); } else { - m_marginLeft = indent; - m_iFlags |= wxCC_IFLAG_LEFT_MARGIN_SET; + m_absIndent = indent; + m_iFlags |= wxCC_IFLAG_INDENT_SET; } RecalcAndRefresh(); } -wxCoord wxComboCtrlBase::GetTextIndent() const -{ - return m_marginLeft; -} -#endif - wxCoord wxComboCtrlBase::GetNativeTextIndent() const { return DEFAULT_TEXT_INDENT; } -void wxComboCtrlBase::SetTextCtrlStyle( int style ) -{ - m_textCtrlStyle = style; - - if ( m_text ) - m_text->SetWindowStyle(style); -} - // ---------------------------------------------------------------------------- -// wxTextEntry interface +// methods forwarded to wxTextCtrl // ---------------------------------------------------------------------------- -wxString wxComboCtrlBase::DoGetValue() const +wxString wxComboCtrlBase::GetValue() const { if ( m_text ) return m_text->GetValue(); return m_valueString; } -void wxComboCtrlBase::SetValueWithEvent(const wxString& value, - bool withEvent) +void wxComboCtrlBase::SetValueWithEvent(const wxString& value, bool withEvent) { - DoSetValue(value, withEvent ? SetValue_SendEvent : 0); -} + if ( m_text ) + { + if ( !withEvent ) + m_ignoreEvtText++; -void wxComboCtrlBase::OnSetValue(const wxString& value) -{ - // Note: before wxComboCtrl inherited from wxTextEntry, - // this code used to be in SetValueWithEvent(). + m_text->SetValue(value); + if ( !(m_iFlags & wxCC_NO_TEXT_AUTO_SELECT) ) + m_text->SelectAll(); + } // Since wxComboPopup may want to paint the combo as well, we need // to set the string value here (as well as sometimes in ShowPopup). if ( m_valueString != value ) { - bool found = true; - wxString trueValue = value; + m_valueString = value; - // Conform to wxComboBox behaviour: read-only control can only accept - // valid list items and empty string - if ( m_popupInterface && HasFlag(wxCB_READONLY) && value.length() ) - { - found = m_popupInterface->FindItem(value, - &trueValue); - } + EnsurePopupControl(); - if ( found ) - { - m_valueString = trueValue; - - EnsurePopupControl(); - - if ( m_popupInterface ) - m_popupInterface->SetStringValue(trueValue); - } + if (m_popupInterface) + m_popupInterface->SetStringValue(value); } Refresh(); } -void wxComboCtrlBase::SetValueByUser(const wxString& value) +void wxComboCtrlBase::SetValue(const wxString& value) { - // NB: Order of function calls is important here. Otherwise - // the SelectAll() may not work. - - if ( m_text ) - { - m_text->SetValue(value); - - if ( !(m_iFlags & wxCC_NO_TEXT_AUTO_SELECT) ) - m_text->SelectAll(); - } - - OnSetValue(value); + SetValueWithEvent(value, false); } // In this SetValue variant wxComboPopup::SetStringValue is not called @@ -2823,6 +2291,12 @@ void wxComboCtrlBase::SetInsertionPoint(long pos) m_text->SetInsertionPoint(pos); } +void wxComboCtrlBase::SetInsertionPointEnd() +{ + if ( m_text ) + m_text->SetInsertionPointEnd(); +} + long wxComboCtrlBase::GetInsertionPoint() const { if ( m_text ) @@ -2839,48 +2313,16 @@ long wxComboCtrlBase::GetLastPosition() const return 0; } -void wxComboCtrlBase::WriteText(const wxString& text) -{ - if ( m_text ) - { - m_text->WriteText(text); - OnSetValue(m_text->GetValue()); - } - else - { - OnSetValue(text); - } -} - -void wxComboCtrlBase::DoSetValue(const wxString& value, int flags) -{ - if ( m_text ) - { - if ( flags & SetValue_SendEvent ) - m_text->SetValue(value); - else - m_text->ChangeValue(value); - } - - OnSetValue(value); -} - void wxComboCtrlBase::Replace(long from, long to, const wxString& value) { if ( m_text ) - { m_text->Replace(from, to, value); - OnSetValue(m_text->GetValue()); - } } void wxComboCtrlBase::Remove(long from, long to) { if ( m_text ) - { m_text->Remove(from, to); - OnSetValue(m_text->GetValue()); - } } void wxComboCtrlBase::SetSelection(long from, long to) @@ -2889,73 +2331,10 @@ void wxComboCtrlBase::SetSelection(long from, long to) m_text->SetSelection(from, to); } -void wxComboCtrlBase::GetSelection(long *from, long *to) const -{ - if ( m_text ) - { - m_text->GetSelection(from, to); - } - else - { - *from = 0; - *to = 0; - } -} - -bool wxComboCtrlBase::IsEditable() const -{ - if ( m_text ) - return m_text->IsEditable(); - return false; -} - -void wxComboCtrlBase::SetEditable(bool editable) -{ - if ( m_text ) - m_text->SetEditable(editable); -} - void wxComboCtrlBase::Undo() { if ( m_text ) m_text->Undo(); } -void wxComboCtrlBase::Redo() -{ - if ( m_text ) - m_text->Redo(); -} - -bool wxComboCtrlBase::CanUndo() const -{ - if ( m_text ) - return m_text->CanUndo(); - - return false; -} - -bool wxComboCtrlBase::CanRedo() const -{ - if ( m_text ) - return m_text->CanRedo(); - - return false; -} - -bool wxComboCtrlBase::SetHint(const wxString& hint) -{ - m_hintText = hint; - bool res = true; - if ( m_text ) - res = m_text->SetHint(hint); - Refresh(); - return res; -} - -wxString wxComboCtrlBase::GetHint() const -{ - return m_hintText; -} - #endif // wxUSE_COMBOCTRL diff --git a/Source/3rd Party/wx/src/common/config.cpp b/Source/3rd Party/wx/src/common/config.cpp index 852dd13f1..ce169563f 100644 --- a/Source/3rd Party/wx/src/common/config.cpp +++ b/Source/3rd Party/wx/src/common/config.cpp @@ -4,7 +4,8 @@ // Author: Vadim Zeitlin // Modified by: // Created: 07.04.98 -// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net +// RCS-ID: $Id: config.cpp 50711 2007-12-15 02:57:58Z VZ $ +// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net // Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -36,13 +37,11 @@ #if wxUSE_CONFIG && ((wxUSE_FILE && wxUSE_TEXTFILE) || wxUSE_CONFIG_NATIVE) -#include "wx/apptrait.h" #include "wx/file.h" #include #include #include // for INT_MAX -#include // for FLT_MAX // ---------------------------------------------------------------------------- // global and class static variables @@ -55,24 +54,9 @@ bool wxConfigBase::ms_bAutoCreate = true; // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// wxAppTraitsBase -// ---------------------------------------------------------------------------- - -wxConfigBase *wxAppTraitsBase::CreateConfig() -{ - return new - #if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE - wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName()); - #else // either we're under Unix or wish to use files even under Windows - wxFileConfig(wxTheApp->GetAppName()); - #endif -} - // ---------------------------------------------------------------------------- // wxConfigBase // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxConfigBase, wxObject) // Not all args will always be used by derived classes, but including them all // in each class ensures compatibility. @@ -102,10 +86,14 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig) wxConfigBase *wxConfigBase::Create() { if ( ms_bAutoCreate && ms_pConfig == NULL ) { - wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - wxCHECK_MSG( traits, NULL, wxT("create wxApp before calling this") ); - - ms_pConfig = traits->CreateConfig(); + ms_pConfig = + #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE + new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName()); + #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE + new wxPrefConfig(wxTheApp->GetAppName()); + #else // either we're under Unix or wish to use files even under Windows + new wxFileConfig(wxTheApp->GetAppName()); + #endif } return ms_pConfig; @@ -119,7 +107,7 @@ wxConfigBase *wxConfigBase::Create() #define IMPLEMENT_READ_FOR_TYPE(name, type, deftype, extra) \ bool wxConfigBase::Read(const wxString& key, type *val) const \ { \ - wxCHECK_MSG( val, false, wxT("wxConfig::Read(): NULL parameter") ); \ + wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") ); \ \ if ( !DoRead##name(key, val) ) \ return false; \ @@ -133,7 +121,7 @@ wxConfigBase *wxConfigBase::Create() type *val, \ deftype defVal) const \ { \ - wxCHECK_MSG( val, false, wxT("wxConfig::Read(): NULL parameter") ); \ + wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") ); \ \ bool read = DoRead##name(key, val); \ if ( !read ) \ @@ -154,79 +142,38 @@ wxConfigBase *wxConfigBase::Create() IMPLEMENT_READ_FOR_TYPE(String, wxString, const wxString&, ExpandEnvVars) IMPLEMENT_READ_FOR_TYPE(Long, long, long, long) +IMPLEMENT_READ_FOR_TYPE(Int, int, int, int) IMPLEMENT_READ_FOR_TYPE(Double, double, double, double) IMPLEMENT_READ_FOR_TYPE(Bool, bool, bool, bool) #undef IMPLEMENT_READ_FOR_TYPE -// int is stored as long -bool wxConfigBase::Read(const wxString& key, int *pi) const -{ - long l = *pi; - bool r = Read(key, &l); - wxASSERT_MSG( l < INT_MAX, wxT("int overflow in wxConfig::Read") ); - *pi = (int)l; - return r; -} - -bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const -{ - long l = *pi; - bool r = Read(key, &l, defVal); - wxASSERT_MSG( l < INT_MAX, wxT("int overflow in wxConfig::Read") ); - *pi = (int)l; - return r; -} - -// Read floats as doubles then just type cast it down. -bool wxConfigBase::Read(const wxString& key, float* val) const -{ - wxCHECK_MSG( val, false, wxT("wxConfig::Read(): NULL parameter") ); - - double temp; - if ( !Read(key, &temp) ) - return false; - - wxCHECK_MSG( fabs(temp) <= FLT_MAX, false, - wxT("float overflow in wxConfig::Read") ); - wxCHECK_MSG( (temp == 0.0) || (fabs(temp) >= FLT_MIN), false, - wxT("float underflow in wxConfig::Read") ); - - *val = static_cast(temp); - - return true; -} - -bool wxConfigBase::Read(const wxString& key, float* val, float defVal) const -{ - wxCHECK_MSG( val, false, wxT("wxConfig::Read(): NULL parameter") ); - - if ( Read(key, val) ) - return true; - - *val = defVal; - return false; -} - // the DoReadXXX() for the other types have implementation in the base class // but can be overridden in the derived ones -bool wxConfigBase::DoReadBool(const wxString& key, bool* val) const +bool wxConfigBase::DoReadInt(const wxString& key, int *pi) const { - wxCHECK_MSG( val, false, wxT("wxConfig::Read(): NULL parameter") ); + wxCHECK_MSG( pi, false, _T("wxConfig::Read(): NULL parameter") ); long l; if ( !DoReadLong(key, &l) ) return false; - if ( l != 0 && l != 1 ) - { - // Don't assert here as this could happen in the result of user editing - // the file directly and this not indicate a bug in the program but - // still complain that something is wrong. - wxLogWarning(_("Invalid value %ld for a boolean key \"%s\" in " - "config file."), - l, key); - } + wxASSERT_MSG( l < INT_MAX, _T("overflow in wxConfig::DoReadInt") ); + + *pi = (int)l; + + return true; +} + +bool wxConfigBase::DoReadBool(const wxString& key, bool* val) const +{ + wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") ); + + long l; + if ( !DoReadLong(key, &l) ) + return false; + + wxASSERT_MSG( l == 0 || l == 1, _T("bad bool value in wxConfig::DoReadInt") ); *val = l != 0; @@ -238,14 +185,7 @@ bool wxConfigBase::DoReadDouble(const wxString& key, double* val) const wxString str; if ( Read(key, &str) ) { - if ( str.ToCDouble(val) ) - return true; - - // Previous versions of wxFileConfig wrote the numbers out using the - // current locale and not the C one as now, so attempt to parse the - // string as a number in the current locale too, for compatibility. - if ( str.ToDouble(val) ) - return true; + return str.ToDouble(val); } return false; @@ -268,10 +208,12 @@ wxString wxConfigBase::ExpandEnvVars(const wxString& str) const bool wxConfigBase::DoWriteDouble(const wxString& key, double val) { - // Notice that we always write out the numbers in C locale and not the - // current one. This makes the config files portable between machines using - // different locales. - return DoWriteString(key, wxString::FromCDouble(val)); + return DoWriteString(key, wxString::Format(_T("%g"), val)); +} + +bool wxConfigBase::DoWriteInt(const wxString& key, int value) +{ + return DoWriteLong(key, (long)value); } bool wxConfigBase::DoWriteBool(const wxString& key, bool value) @@ -287,11 +229,10 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer, const wxString& strEntry) { m_bChanged = false; - m_pContainer = const_cast(pContainer); + m_pContainer = (wxConfigBase *)pContainer; - // the path is everything which precedes the last slash and the name is - // everything after it -- and this works correctly if there is no slash too - wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR, &m_strName); + // the path is everything which precedes the last slash + wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR); // except in the special case of "/keyname" when there is nothing before "/" if ( strPath.empty() && @@ -309,20 +250,27 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer, /* JACS: work around a memory bug that causes an assert when using wxRegConfig, related to reference-counting. - Can be reproduced by removing .wc_str() below and + Can be reproduced by removing (const wxChar*) below and adding the following code to the config sample OnInit under Windows: pConfig->SetPath(wxT("MySettings")); pConfig->SetPath(wxT("..")); int value; - pConfig->Read(wxT("MainWindowX"), & value); + pConfig->Read(_T("MainWindowX"), & value); */ - m_strOldPath = m_pContainer->GetPath().wc_str(); + m_strOldPath = (const wxChar*) m_pContainer->GetPath(); if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR ) m_strOldPath += wxCONFIG_PATH_SEPARATOR; m_pContainer->SetPath(strPath); } + + // in any case, use the just the name, not full path + m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR); + } + else { + // it's a name only, without path - nothing to do + m_strName = strEntry; } } @@ -384,7 +332,7 @@ enum Bracket Bracket_None, Bracket_Normal = ')', Bracket_Curly = '}', -#ifdef __WINDOWS__ +#ifdef __WXMSW__ Bracket_Windows = '%', // yeah, Windows people are a bit strange ;-) #endif Bracket_Max @@ -397,23 +345,23 @@ wxString wxExpandEnvVars(const wxString& str) size_t m; for ( size_t n = 0; n < str.length(); n++ ) { - switch ( str[n].GetValue() ) { -#ifdef __WINDOWS__ + switch ( str[n] ) { +#ifdef __WXMSW__ case wxT('%'): -#endif // __WINDOWS__ +#endif //WINDOWS case wxT('$'): { Bracket bracket; - #ifdef __WINDOWS__ + #ifdef __WXMSW__ if ( str[n] == wxT('%') ) bracket = Bracket_Windows; else - #endif // __WINDOWS__ + #endif //WINDOWS if ( n == str.length() - 1 ) { bracket = Bracket_None; } else { - switch ( str[n + 1].GetValue() ) { + switch ( str[n + 1] ) { case wxT('('): bracket = Bracket_Normal; n++; // skip the bracket @@ -437,22 +385,21 @@ wxString wxExpandEnvVars(const wxString& str) wxString strVarName(str.c_str() + n + 1, m - n - 1); #ifdef __WXWINCE__ - const bool expanded = false; + const wxChar *pszValue = NULL; #else // NB: use wxGetEnv instead of wxGetenv as otherwise variables // set through wxSetEnv may not be read correctly! - bool expanded = false; + const wxChar *pszValue = NULL; wxString tmp; if (wxGetEnv(strVarName, &tmp)) - { - strResult += tmp; - expanded = true; - } - else + pszValue = tmp; #endif - { + if ( pszValue != NULL ) { + strResult += pszValue; + } + else { // variable doesn't exist => don't change anything - #ifdef __WINDOWS__ + #ifdef __WXMSW__ if ( bracket != Bracket_Windows ) #endif if ( bracket != Bracket_None ) @@ -469,14 +416,14 @@ wxString wxExpandEnvVars(const wxString& str) // // under Unix, OTOH, this warning could be useful for the user to // understand why isn't the variable expanded as intended - #ifndef __WINDOWS__ + #ifndef __WXMSW__ wxLogWarning(_("Environment variables expansion failed: missing '%c' at position %u in '%s'."), (char)bracket, (unsigned int) (m + 1), str.c_str()); - #endif // __WINDOWS__ + #endif // __WXMSW__ } else { // skip closing bracket unless the variables wasn't expanded - if ( !expanded ) + if ( pszValue == NULL ) strResult << (wxChar)bracket; m++; } @@ -486,7 +433,7 @@ wxString wxExpandEnvVars(const wxString& str) } break; - case wxT('\\'): + case '\\': // backslash can be used to suppress special meaning of % and $ if ( n != str.length() - 1 && (str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) { @@ -505,27 +452,23 @@ wxString wxExpandEnvVars(const wxString& str) } // this function is used to properly interpret '..' in path -void wxSplitPath(wxArrayString& aParts, const wxString& path) +void wxSplitPath(wxArrayString& aParts, const wxChar *sz) { aParts.clear(); wxString strCurrent; - wxString::const_iterator pc = path.begin(); + const wxChar *pc = sz; for ( ;; ) { - if ( pc == path.end() || *pc == wxCONFIG_PATH_SEPARATOR ) { + if ( *pc == wxT('\0') || *pc == wxCONFIG_PATH_SEPARATOR ) { if ( strCurrent == wxT(".") ) { // ignore } else if ( strCurrent == wxT("..") ) { // go up one level if ( aParts.size() == 0 ) - { - wxLogWarning(_("'%s' has extra '..', ignored."), path); - } + wxLogWarning(_("'%s' has extra '..', ignored."), sz); else - { aParts.erase(aParts.end() - 1); - } strCurrent.Empty(); } @@ -536,12 +479,12 @@ void wxSplitPath(wxArrayString& aParts, const wxString& path) //else: // could log an error here, but we prefer to ignore extra '/' - if ( pc == path.end() ) + if ( *pc == wxT('\0') ) break; } else strCurrent += *pc; - ++pc; + pc++; } } diff --git a/Source/3rd Party/wx/src/common/containr.cpp b/Source/3rd Party/wx/src/common/containr.cpp index 50bbd6aef..ffa9ce975 100644 --- a/Source/3rd Party/wx/src/common/containr.cpp +++ b/Source/3rd Party/wx/src/common/containr.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 06.08.01 +// RCS-ID: $Id: containr.cpp 44273 2007-01-21 01:21:45Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -23,154 +24,70 @@ #pragma hdrstop #endif -#ifndef WX_PRECOMP - #include "wx/containr.h" -#endif - #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/event.h" #include "wx/window.h" #include "wx/scrolbar.h" #include "wx/radiobut.h" + #include "wx/containr.h" #endif //WX_PRECOMP // trace mask for focus messages -#define TRACE_FOCUS wxT("focus") +#define TRACE_FOCUS _T("focus") // ============================================================================ // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// wxControlContainerBase -// ---------------------------------------------------------------------------- - -void wxControlContainerBase::UpdateParentCanFocus() -{ - // In the ports where it does something non trivial, the parent window - // should only be focusable if it doesn't have any focusable children - // (e.g. native focus handling in wxGTK totally breaks down otherwise). - m_winParent->SetCanFocus(m_acceptsFocusSelf && !m_acceptsFocusChildren); -} - -bool wxControlContainerBase::UpdateCanFocusChildren() -{ - const bool acceptsFocusChildren = HasAnyFocusableChildren(); - if ( acceptsFocusChildren != m_acceptsFocusChildren ) - { - m_acceptsFocusChildren = acceptsFocusChildren; - - UpdateParentCanFocus(); - } - - return m_acceptsFocusChildren; -} - -bool wxControlContainerBase::HasAnyFocusableChildren() const -{ - const wxWindowList& children = m_winParent->GetChildren(); - for ( wxWindowList::const_iterator i = children.begin(), - end = children.end(); - i != end; - ++i ) - { - const wxWindow * const child = *i; - - if ( !m_winParent->IsClientAreaChild(child) ) - continue; - - // Here we check whether the child can accept the focus at all, as we - // want to try focusing it later even if it can't accept it right now. - if ( child->AcceptsFocusRecursively() ) - return true; - } - - return false; -} - -bool wxControlContainerBase::HasAnyChildrenAcceptingFocus() const -{ - const wxWindowList& children = m_winParent->GetChildren(); - for ( wxWindowList::const_iterator i = children.begin(), - end = children.end(); - i != end; - ++i ) - { - const wxWindow * const child = *i; - - if ( !m_winParent->IsClientAreaChild(child) ) - continue; - - // Here we check if the child accepts focus right now as we need to - // know if we can give the focus to it or not. - if ( child->CanAcceptFocus() ) - return true; - } - - return false; -} - -bool wxControlContainerBase::DoSetFocus() -{ - wxLogTrace(TRACE_FOCUS, wxT("SetFocus on wxPanel 0x%p."), - m_winParent->GetHandle()); - - if (m_inSetFocus) - return true; - - // when the panel gets the focus we move the focus to either the last - // window that had the focus or the first one that can get it unless the - // focus had been already set to some other child - - wxWindow *win = wxWindow::FindFocus(); - while ( win ) - { - if ( win == m_winParent ) - { - // our child already has focus, don't take it away from it - return true; - } - - if ( win->IsTopLevel() ) - { - // don't look beyond the first top level parent - useless and - // unnecessary - break; - } - - win = win->GetParent(); - } - - // protect against infinite recursion: - m_inSetFocus = true; - - bool ret = SetFocusToChild(); - - m_inSetFocus = false; - - return ret; -} - -bool wxControlContainerBase::AcceptsFocus() const -{ - return m_acceptsFocusSelf && m_winParent->CanBeFocused(); -} - -bool wxControlContainerBase::SetFocusToChild() -{ - return wxSetFocusToChild(m_winParent, &m_winLastFocused); -} - -#ifndef wxHAS_NATIVE_TAB_TRAVERSAL - -// ---------------------------------------------------------------------------- -// generic wxControlContainer -// ---------------------------------------------------------------------------- - -wxControlContainer::wxControlContainer() +wxControlContainer::wxControlContainer(wxWindow *winParent) { + m_winParent = winParent; m_winLastFocused = NULL; + m_inSetFocus = false; +} + +bool wxControlContainer::AcceptsFocus() const +{ + // if we're not shown or disabled, we can't accept focus + if ( m_winParent->IsShown() && m_winParent->IsEnabled() ) + { + // otherwise we can accept focus either if we have no children at all + // (in this case we're probably not used as a container) or only when + // at least one child will accept focus + wxWindowList::compatibility_iterator node = m_winParent->GetChildren().GetFirst(); + if ( !node ) + return true; + +#ifdef __WXMAC__ + // wxMac has eventually the two scrollbars as children, they don't count + // as real children in the algorithm mentioned above + bool hasRealChildren = false ; +#endif + + while ( node ) + { + wxWindow *child = node->GetData(); + node = node->GetNext(); + +#ifdef __WXMAC__ + if ( m_winParent->MacIsWindowScrollbar( child ) ) + continue; + hasRealChildren = true ; +#endif + if ( child->AcceptsFocus() ) + { + return true; + } + } + +#ifdef __WXMAC__ + if ( !hasRealChildren ) + return true ; +#endif + } + + return false; } void wxControlContainer::SetLastFocus(wxWindow *win) @@ -196,7 +113,7 @@ void wxControlContainer::SetLastFocus(wxWindow *win) // (under wxGTK) wxASSERT_MSG( winParent, - wxT("Setting last focus for a window that is not our child?") ); + _T("Setting last focus for a window that is not our child?") ); } } @@ -204,15 +121,24 @@ void wxControlContainer::SetLastFocus(wxWindow *win) if ( win ) { - wxLogTrace(TRACE_FOCUS, wxT("Set last focus to %s(%s)"), + wxLogTrace(TRACE_FOCUS, _T("Set last focus to %s(%s)"), win->GetClassInfo()->GetClassName(), win->GetLabel().c_str()); } else { - wxLogTrace(TRACE_FOCUS, wxT("No more last focus")); + wxLogTrace(TRACE_FOCUS, _T("No more last focus")); } } + + // propagate the last focus upwards so that our parent can set focus back + // to us if it loses it now and regains later + wxWindow *parent = m_winParent->GetParent(); + if ( parent ) + { + wxChildFocusEvent eventFocus(m_winParent); + parent->GetEventHandler()->ProcessEvent(eventFocus); + } } // -------------------------------------------------------------------- @@ -220,7 +146,7 @@ void wxControlContainer::SetLastFocus(wxWindow *win) // within the same group. Used by wxSetFocusToChild on wxMSW // -------------------------------------------------------------------- -#if wxUSE_RADIOBTN +#ifdef __WXMSW__ wxRadioButton* wxGetPreviousButtonInGroup(wxRadioButton *btn) { @@ -229,7 +155,7 @@ wxRadioButton* wxGetPreviousButtonInGroup(wxRadioButton *btn) const wxWindowList& siblings = btn->GetParent()->GetChildren(); wxWindowList::compatibility_iterator nodeThis = siblings.Find(btn); - wxCHECK_MSG( nodeThis, NULL, wxT("radio button not a child of its parent?") ); + wxCHECK_MSG( nodeThis, NULL, _T("radio button not a child of its parent?") ); // Iterate over all previous siblings until we find the next radio button wxWindowList::compatibility_iterator nodeBefore = nodeThis->GetPrevious(); @@ -259,7 +185,7 @@ wxRadioButton* wxGetNextButtonInGroup(wxRadioButton *btn) const wxWindowList& siblings = btn->GetParent()->GetChildren(); wxWindowList::compatibility_iterator nodeThis = siblings.Find(btn); - wxCHECK_MSG( nodeThis, NULL, wxT("radio button not a child of its parent?") ); + wxCHECK_MSG( nodeThis, NULL, _T("radio button not a child of its parent?") ); // Iterate over all previous siblings until we find the next radio button wxWindowList::compatibility_iterator nodeNext = nodeThis->GetNext(); @@ -342,10 +268,7 @@ wxRadioButton* wxGetSelectedButtonInGroup(wxRadioButton *btn) void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) { - // for a TLW we shouldn't involve the parent window, it has nothing to do - // with keyboard navigation inside this TLW - wxWindow *parent = m_winParent->IsTopLevel() ? NULL - : m_winParent->GetParent(); + wxWindow *parent = m_winParent->GetParent(); // the event is propagated downwards if the event emitter was our parent bool goingDown = event.GetEventObject() == parent; @@ -424,7 +347,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) { // just to be sure it's not used (normally this is not necessary, but // doesn't hurt neither) - m_winLastFocused = NULL; + m_winLastFocused = (wxWindow *)NULL; // start from first or last depending on where we're going node = forward ? children.GetFirst() : children.GetLast(); @@ -446,12 +369,12 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) if ( winFocus ) { -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#ifdef __WXMSW__ // If we are in a radio button group, start from the first item in the // group if ( event.IsFromTab() && wxIsKindOf(winFocus, wxRadioButton ) ) winFocus = wxGetFirstButtonInGroup((wxRadioButton*)winFocus); -#endif // __WXMSW__ +#endif // ok, we found the focus - now is it our child? start_node = children.Find( winFocus ); } @@ -498,21 +421,18 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // looping inside this panel (normally, the focus will go to // the next/previous item after this panel in the parent // panel). - wxWindow *focusedParent = m_winParent; + wxWindow *focussed_child_of_parent = m_winParent; while ( parent ) { - // We don't want to tab into a different dialog or frame or - // even an MDI child frame, so test for this explicitly - // (and in particular don't just use IsTopLevel() which - // would return false in the latter case). - if ( focusedParent->IsTopNavigationDomain() ) + // we don't want to tab into a different dialog or frame + if ( focussed_child_of_parent->IsTopLevel() ) break; - event.SetCurrentFocus( focusedParent ); + event.SetCurrentFocus( focussed_child_of_parent ); if ( parent->GetEventHandler()->ProcessEvent( event ) ) return; - focusedParent = parent; + focussed_child_of_parent = parent; parent = parent->GetParent(); } @@ -528,15 +448,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxWindow *child = node->GetData(); - // don't TAB to another TLW - if ( child->IsTopLevel() ) - { - node = forward ? node->GetNext() : node->GetPrevious(); - - continue; - } - -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#ifdef __WXMSW__ if ( event.IsFromTab() ) { if ( wxIsKindOf(child, wxRadioButton) ) @@ -561,27 +473,24 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxIsKindOf(m_winLastFocused, wxRadioButton) && !m_winLastFocused->HasFlag(wxRB_SINGLE) ) { - wxRadioButton * const - lastBtn = static_cast(m_winLastFocused); - // cursor keys don't navigate out of a radio button group so // find the correct radio button to focus if ( forward ) { - child = wxGetNextButtonInGroup(lastBtn); + child = wxGetNextButtonInGroup((wxRadioButton*)m_winLastFocused); if ( !child ) { // no next button in group, set it to the first button - child = wxGetFirstButtonInGroup(lastBtn); + child = wxGetFirstButtonInGroup((wxRadioButton*)m_winLastFocused); } } else { - child = wxGetPreviousButtonInGroup(lastBtn); + child = wxGetPreviousButtonInGroup((wxRadioButton*)m_winLastFocused); if ( !child ) { // no previous button in group, set it to the last button - child = wxGetLastButtonInGroup(lastBtn); + child = wxGetLastButtonInGroup((wxRadioButton*)m_winLastFocused); } } @@ -595,7 +504,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } #endif // __WXMSW__ - if ( child->CanAcceptFocusFromKeyboard() ) + if ( child->AcceptsFocusFromKeyboard() ) { // if we're setting the focus to a child panel we should prevent it // from giving it to the child which had the focus the last time @@ -640,9 +549,50 @@ void wxControlContainer::HandleOnWindowDestroy(wxWindowBase *child) // focus handling // ---------------------------------------------------------------------------- +bool wxControlContainer::DoSetFocus() +{ + wxLogTrace(TRACE_FOCUS, _T("SetFocus on wxPanel 0x%p."), + m_winParent->GetHandle()); + + if (m_inSetFocus) + return true; + + // when the panel gets the focus we move the focus to either the last + // window that had the focus or the first one that can get it unless the + // focus had been already set to some other child + + wxWindow *win = wxWindow::FindFocus(); + while ( win ) + { + if ( win == m_winParent ) + { + // our child already has focus, don't take it away from it + return true; + } + + if ( win->IsTopLevel() ) + { + // don't look beyond the first top level parent - useless and + // unnecessary + break; + } + + win = win->GetParent(); + } + + // protect against infinite recursion: + m_inSetFocus = true; + + bool ret = SetFocusToChild(); + + m_inSetFocus = false; + + return ret; +} + void wxControlContainer::HandleOnFocus(wxFocusEvent& event) { - wxLogTrace(TRACE_FOCUS, wxT("OnFocus on wxPanel 0x%p, name: %s"), + wxLogTrace(TRACE_FOCUS, _T("OnFocus on wxPanel 0x%p, name: %s"), m_winParent->GetHandle(), m_winParent->GetName().c_str() ); @@ -651,18 +601,11 @@ void wxControlContainer::HandleOnFocus(wxFocusEvent& event) event.Skip(); } - -#else - // wxHAS_NATIVE_TAB_TRAVERSAL - bool wxControlContainer::SetFocusToChild() { - return wxSetFocusToChild(m_winParent, NULL); + return wxSetFocusToChild(m_winParent, &m_winLastFocused); } - -#endif // !wxHAS_NATIVE_TAB_TRAVERSAL - // ---------------------------------------------------------------------------- // SetFocusToChild(): this function is used by wxPanel but also by wxFrame in // wxMSW, this is why it is outside of wxControlContainer class @@ -670,50 +613,28 @@ bool wxControlContainer::SetFocusToChild() bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) { - wxCHECK_MSG( win, false, wxT("wxSetFocusToChild(): invalid window") ); - // wxCHECK_MSG( childLastFocused, false, - // wxT("wxSetFocusToChild(): NULL child poonter") ); + wxCHECK_MSG( win, false, _T("wxSetFocusToChild(): invalid window") ); + wxCHECK_MSG( childLastFocused, false, + _T("wxSetFocusToChild(): NULL child poonter") ); - if ( childLastFocused && *childLastFocused ) + if ( *childLastFocused ) { // It might happen that the window got reparented if ( (*childLastFocused)->GetParent() == win ) { - // And it also could have become hidden in the meanwhile - // We want to focus on the deepest widget visible - wxWindow *deepestVisibleWindow = NULL; + wxLogTrace(TRACE_FOCUS, + _T("SetFocusToChild() => last child (0x%p)."), + (*childLastFocused)->GetHandle()); - while ( *childLastFocused ) - { - if ( (*childLastFocused)->IsShown() ) - { - if ( !deepestVisibleWindow ) - deepestVisibleWindow = *childLastFocused; - } - else - deepestVisibleWindow = NULL; - - *childLastFocused = (*childLastFocused)->GetParent(); - } - - if ( deepestVisibleWindow ) - { - *childLastFocused = deepestVisibleWindow; - - wxLogTrace(TRACE_FOCUS, - wxT("SetFocusToChild() => last child (0x%p)."), - (*childLastFocused)->GetHandle()); - - // not SetFocusFromKbd(): we're restoring focus back to the old - // window and not setting it as the result of a kbd action - (*childLastFocused)->SetFocus(); - return true; - } + // not SetFocusFromKbd(): we're restoring focus back to the old + // window and not setting it as the result of a kbd action + (*childLastFocused)->SetFocus(); + return true; } else { // it doesn't count as such any more - *childLastFocused = NULL; + *childLastFocused = (wxWindow *)NULL; } } @@ -724,13 +645,14 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) wxWindow *child = node->GetData(); node = node->GetNext(); - // skip special windows: - if ( !win->IsClientAreaChild(child) ) +#ifdef __WXMAC__ + if ( child->GetParent()->MacIsWindowScrollbar( child ) ) continue; - - if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() ) +#endif + + if ( child->AcceptsFocusFromKeyboard() && !child->IsTopLevel() ) { -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#ifdef __WXMSW__ // If a radiobutton is the first focusable child, search for the // selected radiobutton in the same group wxRadioButton* btn = wxDynamicCast(child, wxRadioButton); @@ -740,14 +662,13 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) if (selected) child = selected; } -#endif // __WXMSW__ +#endif wxLogTrace(TRACE_FOCUS, - wxT("SetFocusToChild() => first child (0x%p)."), + _T("SetFocusToChild() => first child (0x%p)."), child->GetHandle()); - if (childLastFocused) - *childLastFocused = child; + *childLastFocused = child; child->SetFocusFromKbd(); return true; } @@ -755,4 +676,3 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) return false; } - diff --git a/Source/3rd Party/wx/src/common/convauto.cpp b/Source/3rd Party/wx/src/common/convauto.cpp index 6a5fba4ec..3205b7bea 100644 --- a/Source/3rd Party/wx/src/common/convauto.cpp +++ b/Source/3rd Party/wx/src/common/convauto.cpp @@ -3,6 +3,7 @@ // Purpose: implementation of wxConvAuto // Author: Vadim Zeitlin // Created: 2006-04-04 +// RCS-ID: $Id: convauto.cpp 38570 2006-04-05 14:37:47Z VZ $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -22,199 +23,112 @@ #pragma hdrstop #endif +#if wxUSE_WCHAR_T + +#ifndef WX_PRECOMP +#endif //WX_PRECOMP + #include "wx/convauto.h" -// we use latin1 by default as it seems the least bad choice: the files we need -// to detect input of don't always come from the user system (they are often -// received from other machines) and so using wxFONTENCODING_SYSTEM doesn't -// seem to be a good idea and there is no other reasonable alternative -wxFontEncoding wxConvAuto::ms_defaultMBEncoding = wxFONTENCODING_ISO8859_1; - -namespace -{ - -const char BOM_UTF32BE[] = { '\x00', '\x00', '\xFE', '\xFF' }; -const char BOM_UTF32LE[] = { '\xFF', '\xFE', '\x00', '\x00' }; -const char BOM_UTF16BE[] = { '\xFE', '\xFF' }; -const char BOM_UTF16LE[] = { '\xFF', '\xFE' }; -const char BOM_UTF8[] = { '\xEF', '\xBB', '\xBF' }; - -} // anonymous namespace - // ============================================================================ // implementation // ============================================================================ /* static */ -void wxConvAuto::SetFallbackEncoding(wxFontEncoding enc) +wxConvAuto::BOMType wxConvAuto::DetectBOM(const char *src, size_t srcLen) { - wxASSERT_MSG( enc != wxFONTENCODING_DEFAULT, - wxT("wxFONTENCODING_DEFAULT doesn't make sense here") ); - - ms_defaultMBEncoding = enc; -} - -/* static */ -const char* wxConvAuto::GetBOMChars(wxBOM bom, size_t* count) -{ - wxCHECK_MSG( count , NULL, wxS("count pointer must be provided") ); - - switch ( bom ) + if ( srcLen < 2 ) { - case wxBOM_UTF32BE: *count = WXSIZEOF(BOM_UTF32BE); return BOM_UTF32BE; - case wxBOM_UTF32LE: *count = WXSIZEOF(BOM_UTF32LE); return BOM_UTF32LE; - case wxBOM_UTF16BE: *count = WXSIZEOF(BOM_UTF16BE); return BOM_UTF16BE; - case wxBOM_UTF16LE: *count = WXSIZEOF(BOM_UTF16LE); return BOM_UTF16LE; - case wxBOM_UTF8 : *count = WXSIZEOF(BOM_UTF8 ); return BOM_UTF8; - case wxBOM_Unknown: - case wxBOM_None: - wxFAIL_MSG( wxS("Invalid BOM type") ); - return NULL; + // minimal BOM is 2 bytes so bail out immediately and simplify the code + // below which wouldn't need to check for length for UTF-16 cases + return BOM_None; } - wxFAIL_MSG( wxS("Unknown BOM type") ); - return NULL; -} - -/* static */ -wxBOM wxConvAuto::DetectBOM(const char *src, size_t srcLen) -{ // examine the buffer for BOM presence // - // quoting from http://www.unicode.org/faq/utf_bom.html#BOM: - // - // Bytes Encoding Form - // - // 00 00 FE FF UTF-32, big-endian - // FF FE 00 00 UTF-32, little-endian - // FE FF UTF-16, big-endian - // FF FE UTF-16, little-endian - // EF BB BF UTF-8 - // - // as some BOMs are prefixes of other ones we may need to read more bytes - // to disambiguate them - - switch ( srcLen ) + // see http://www.unicode.org/faq/utf_bom.html#BOM + switch ( *src++ ) { - case 0: - return wxBOM_Unknown; - - case 1: - if ( src[0] == '\x00' || src[0] == '\xFF' || - src[0] == '\xFE' || src[0] == '\xEF') + case '\0': + // could only be big endian UTF-32 (00 00 FE FF) + if ( srcLen >= 4 && + src[0] == '\0' && + src[1] == '\xfe' && + src[2] == '\xff' ) { - // this could be a BOM but we don't know yet - return wxBOM_Unknown; + return BOM_UTF32BE; } break; - case 2: - case 3: - if ( src[0] == '\xEF' && src[1] == '\xBB' ) + case '\xfe': + // could only be big endian UTF-16 (FE FF) + if ( *src++ == '\xff' ) { - if ( srcLen == 3 ) - return src[2] == '\xBF' ? wxBOM_UTF8 : wxBOM_None; - - return wxBOM_Unknown; - } - - if ( src[0] == '\xFE' && src[1] == '\xFF' ) - return wxBOM_UTF16BE; - - if ( src[0] == '\xFF' && src[1] == '\xFE' ) - { - // if the next byte is 0, it could be an UTF-32LE BOM but if it - // isn't we can be sure it's UTF-16LE - if ( srcLen == 3 && src[2] != '\x00' ) - return wxBOM_UTF16LE; - - return wxBOM_Unknown; - } - - if ( src[0] == '\x00' && src[1] == '\x00' ) - { - // this could only be UTF-32BE, check that the data we have so - // far allows for it - if ( srcLen == 3 && src[2] != '\xFE' ) - return wxBOM_None; - - return wxBOM_Unknown; + return BOM_UTF16BE; } break; - default: - // we have at least 4 characters so we may finally decide whether - // we have a BOM or not - if ( src[0] == '\xEF' && src[1] == '\xBB' && src[2] == '\xBF' ) - return wxBOM_UTF8; + case '\xff': + // could be either little endian UTF-16 or UTF-32, both start + // with FF FE + if ( *src++ == '\xfe' ) + { + return srcLen >= 4 && src[0] == '\0' && src[1] == '\0' + ? BOM_UTF32LE + : BOM_UTF16LE; + } + break; - if ( src[0] == '\x00' && src[1] == '\x00' && - src[2] == '\xFE' && src[3] == '\xFF' ) - return wxBOM_UTF32BE; - - if ( src[0] == '\xFF' && src[1] == '\xFE' && - src[2] == '\x00' && src[3] == '\x00' ) - return wxBOM_UTF32LE; - - if ( src[0] == '\xFE' && src[1] == '\xFF' ) - return wxBOM_UTF16BE; - - if ( src[0] == '\xFF' && src[1] == '\xFE' ) - return wxBOM_UTF16LE; + case '\xef': + // is this UTF-8 BOM (EF BB BF)? + if ( srcLen >= 3 && src[0] == '\xbb' && src[1] == '\xbf' ) + { + return BOM_UTF8; + } + break; } - return wxBOM_None; + return BOM_None; } -void wxConvAuto::InitFromBOM(wxBOM bomType) +void wxConvAuto::InitFromBOM(BOMType bomType) { m_consumedBOM = false; switch ( bomType ) { - case wxBOM_Unknown: - wxFAIL_MSG( "shouldn't be called for this BOM type" ); - break; - - case wxBOM_None: - // use the default - break; - - case wxBOM_UTF32BE: + case BOM_UTF32BE: m_conv = new wxMBConvUTF32BE; m_ownsConv = true; break; - case wxBOM_UTF32LE: + case BOM_UTF32LE: m_conv = new wxMBConvUTF32LE; m_ownsConv = true; break; - case wxBOM_UTF16BE: + case BOM_UTF16BE: m_conv = new wxMBConvUTF16BE; m_ownsConv = true; break; - case wxBOM_UTF16LE: + case BOM_UTF16LE: m_conv = new wxMBConvUTF16LE; m_ownsConv = true; break; - case wxBOM_UTF8: - InitWithUTF8(); + case BOM_UTF8: + m_conv = &wxConvUTF8; + m_ownsConv = false; break; default: - wxFAIL_MSG( "unknown BOM type" ); - } + wxFAIL_MSG( _T("unexpected BOM type") ); + // fall through: still need to create something - if ( !m_conv ) - { - // we end up here if there is no BOM or we didn't recognize it somehow - // (this shouldn't happen but still don't crash if it does), so use the - // default encoding - InitWithUTF8(); - m_consumedBOM = true; // as there is nothing to consume + case BOM_None: + InitWithDefault(); + m_consumedBOM = true; // as there is nothing to consume } } @@ -223,31 +137,26 @@ void wxConvAuto::SkipBOM(const char **src, size_t *len) const int ofs; switch ( m_bomType ) { - case wxBOM_Unknown: - wxFAIL_MSG( "shouldn't be called for this BOM type" ); - return; - - case wxBOM_None: - ofs = 0; - break; - - case wxBOM_UTF32BE: - case wxBOM_UTF32LE: + case BOM_UTF32BE: + case BOM_UTF32LE: ofs = 4; break; - case wxBOM_UTF16BE: - case wxBOM_UTF16LE: + case BOM_UTF16BE: + case BOM_UTF16LE: ofs = 2; break; - case wxBOM_UTF8: + case BOM_UTF8: ofs = 3; break; default: - wxFAIL_MSG( "unknown BOM type" ); - return; + wxFAIL_MSG( _T("unexpected BOM type") ); + // fall through: still need to create something + + case BOM_None: + ofs = 0; } *src += ofs; @@ -255,15 +164,11 @@ void wxConvAuto::SkipBOM(const char **src, size_t *len) const *len -= ofs; } -bool wxConvAuto::InitFromInput(const char *src, size_t len) +void wxConvAuto::InitFromInput(const char **src, size_t *len) { - m_bomType = DetectBOM(src, len == wxNO_LEN ? strlen(src) : len); - if ( m_bomType == wxBOM_Unknown ) - return false; - + m_bomType = DetectBOM(*src, *len); InitFromBOM(m_bomType); - - return true; + SkipBOM(src, len); } size_t @@ -275,61 +180,21 @@ wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen, // during this initial call but also during the first call with non-NULL // dst as typically we're first called with NULL dst to calculate the // needed buffer size - wxConvAuto *self = const_cast(this); - - + wxConvAuto *self = wx_const_cast(wxConvAuto *, this); if ( !m_conv ) { - if ( !self->InitFromInput(src, srcLen) ) - { - // there is not enough data to determine whether we have a BOM or - // not, so fail for now -- the caller is supposed to call us again - // with more data - return wxCONV_FAILED; - } + self->InitFromInput(&src, &srcLen); + if ( dst ) + self->m_consumedBOM = true; } - if ( !m_consumedBOM ) + if ( !m_consumedBOM && dst ) { - SkipBOM(&src, &srcLen); - if ( srcLen == 0 ) - { - // there is nothing left except the BOM so we'd return 0 below but - // this is unexpected: decoding a non-empty string must either fail - // or return something non-empty, in particular this would break - // the code in wxTextInputStream::NextChar() - // - // so still return an error as we need some more data to be able to - // decode it - return wxCONV_FAILED; - } - } - - // try to convert using the auto-detected encoding - size_t rc = m_conv->ToWChar(dst, dstLen, src, srcLen); - if ( rc == wxCONV_FAILED && m_bomType == wxBOM_None ) - { - // if the conversion failed but we didn't really detect anything and - // simply tried UTF-8 by default, retry it using the fall-back - if ( m_encDefault != wxFONTENCODING_MAX ) - { - if ( m_ownsConv ) - delete m_conv; - - self->m_conv = new wxCSConv(m_encDefault == wxFONTENCODING_DEFAULT - ? GetFallbackEncoding() - : m_encDefault); - self->m_ownsConv = true; - - rc = m_conv->ToWChar(dst, dstLen, src, srcLen); - } - } - - // don't skip the BOM again the next time if we really consumed it - if ( rc != wxCONV_FAILED && dst && !m_consumedBOM ) self->m_consumedBOM = true; + SkipBOM(&src, &srcLen); + } - return rc; + return m_conv->ToWChar(dst, dstLen, src, srcLen); } size_t @@ -339,8 +204,11 @@ wxConvAuto::FromWChar(char *dst, size_t dstLen, if ( !m_conv ) { // default to UTF-8 for the multibyte output - const_cast(this)->InitWithUTF8(); + wx_const_cast(wxConvAuto *, this)->InitWithDefault(); } return m_conv->FromWChar(dst, dstLen, src, srcLen); } + +#endif // wxUSE_WCHAR_T + diff --git a/Source/3rd Party/wx/src/common/cshelp.cpp b/Source/3rd Party/wx/src/common/cshelp.cpp index 26484e26a..6bd3d5cc0 100644 --- a/Source/3rd Party/wx/src/common/cshelp.cpp +++ b/Source/3rd Party/wx/src/common/cshelp.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart, Vadim Zeitlin // Modified by: // Created: 08/09/2000 +// RCS-ID: $Id: cshelp.cpp 52329 2008-03-05 13:20:26Z VZ $ // Copyright: (c) 2000 Julian Smart, Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -57,7 +58,7 @@ public: //// Data wxContextHelp* m_contextHelp; - wxDECLARE_NO_COPY_CLASS(wxContextHelpEvtHandler); + DECLARE_NO_COPY_CLASS(wxContextHelpEvtHandler) }; // ============================================================================ @@ -231,7 +232,7 @@ bool wxContextHelpEvtHandler::ProcessEvent(wxEvent& event) // Dispatch the help event to the relevant window bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt) { - wxCHECK_MSG( win, false, wxT("win parameter can't be NULL") ); + wxCHECK_MSG( win, false, _T("win parameter can't be NULL") ); wxHelpEvent helpEvent(wxEVT_HELP, win->GetId(), pt, wxHelpEvent::Origin_HelpButton); @@ -283,7 +284,7 @@ wxContextHelpButton::wxContextHelpButton(wxWindow* parent, long style) #if defined(__WXPM__) : wxBitmapButton(parent, id, wxBitmap(wxCSQUERY_BITMAP - ,wxBITMAP_TYPE_BMP_RESOURCE + ,wxBITMAP_TYPE_RESOURCE ), pos, size, style) #else @@ -302,7 +303,7 @@ void wxContextHelpButton::OnContextHelp(wxCommandEvent& WXUNUSED(event)) // wxHelpProvider // ---------------------------------------------------------------------------- -wxHelpProvider *wxHelpProvider::ms_helpProvider = NULL; +wxHelpProvider *wxHelpProvider::ms_helpProvider = (wxHelpProvider *)NULL; // trivial implementation of some methods which we don't want to make pure // virtual for convenience @@ -331,7 +332,7 @@ wxString wxHelpProvider::GetHelpTextMaybeAtPoint(wxWindowBase *window) if ( m_helptextAtPoint != wxDefaultPosition || m_helptextOrigin != wxHelpEvent::Origin_Unknown ) { - wxCHECK_MSG( window, wxEmptyString, wxT("window must not be NULL") ); + wxCHECK_MSG( window, wxEmptyString, _T("window must not be NULL") ); wxPoint pt = m_helptextAtPoint; wxHelpEvent::Origin origin = m_helptextOrigin; @@ -471,7 +472,7 @@ bool wxHelpControllerHelpProvider::ShowHelp(wxWindowBase *window) // Convenience function for turning context id into wxString wxString wxContextId(int id) { - return wxString::Format(wxT("%d"), id); + return wxString::Format(_T("%d"), id); } // ---------------------------------------------------------------------------- diff --git a/Source/3rd Party/wx/src/common/ctrlcmn.cpp b/Source/3rd Party/wx/src/common/ctrlcmn.cpp index dbfbc9f70..9326835e9 100644 --- a/Source/3rd Party/wx/src/common/ctrlcmn.cpp +++ b/Source/3rd Party/wx/src/common/ctrlcmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.07.99 +// RCS-ID: $Id: ctrlcmn.cpp 40329 2006-07-25 18:40:04Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,18 +29,14 @@ #include "wx/control.h" #ifndef WX_PRECOMP - #include "wx/dc.h" #include "wx/log.h" #include "wx/radiobut.h" #include "wx/statbmp.h" #include "wx/bitmap.h" #include "wx/utils.h" // for wxStripMenuCodes() - #include "wx/settings.h" #endif -#include "wx/private/markupparser.h" - -const char wxControlNameStr[] = "control"; +const wxChar wxControlNameStr[] = wxT("control"); // ============================================================================ // implementation @@ -89,6 +86,13 @@ bool wxControlBase::CreateControl(wxWindowBase *parent, return true; } +/* static */ +wxString wxControlBase::GetLabelText(const wxString& label) +{ + // we don't want strip the TABs here, just the mnemonics + return wxStripMenuCodes(label, wxStrip_Mnemonics); +} + void wxControlBase::Command(wxCommandEvent& event) { (void)GetEventHandler()->ProcessEvent(event); @@ -96,7 +100,7 @@ void wxControlBase::Command(wxCommandEvent& event) void wxControlBase::InitCommandEvent(wxCommandEvent& event) const { - event.SetEventObject(const_cast(this)); + event.SetEventObject((wxControlBase *)this); // const_cast // event.SetId(GetId()); -- this is usuall done in the event ctor @@ -116,6 +120,13 @@ void wxControlBase::InitCommandEvent(wxCommandEvent& event) const } } + +void wxControlBase::SetLabel( const wxString &label ) +{ + InvalidateBestSize(); + wxWindow::SetLabel(label); +} + bool wxControlBase::SetFont(const wxFont& font) { InvalidateBestSize(); @@ -148,426 +159,6 @@ void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent& event) #endif // wxUSE_RADIOBTN } -wxSize wxControlBase::DoGetSizeFromTextSize(int WXUNUSED(xlen), - int WXUNUSED(ylen)) const -{ - return wxSize(-1, -1); -} - -/* static */ -wxString wxControlBase::GetLabelText(const wxString& label) -{ - // we don't want strip the TABs here, just the mnemonics - return wxStripMenuCodes(label, wxStrip_Mnemonics); -} - -/* static */ -wxString wxControlBase::RemoveMnemonics(const wxString& str) -{ - // we don't want strip the TABs here, just the mnemonics - return wxStripMenuCodes(str, wxStrip_Mnemonics); -} - -/* static */ -wxString wxControlBase::EscapeMnemonics(const wxString& text) -{ - wxString label(text); - label.Replace("&", "&&"); - return label; -} - -/* static */ -int wxControlBase::FindAccelIndex(const wxString& label, wxString *labelOnly) -{ - // the character following MNEMONIC_PREFIX is the accelerator for this - // control unless it is MNEMONIC_PREFIX too - this allows to insert - // literal MNEMONIC_PREFIX chars into the label - static const wxChar MNEMONIC_PREFIX = wxT('&'); - - if ( labelOnly ) - { - labelOnly->Empty(); - labelOnly->Alloc(label.length()); - } - - int indexAccel = -1; - for ( wxString::const_iterator pc = label.begin(); pc != label.end(); ++pc ) - { - if ( *pc == MNEMONIC_PREFIX ) - { - ++pc; // skip it - if ( pc == label.end() ) - break; - else if ( *pc != MNEMONIC_PREFIX ) - { - if ( indexAccel == -1 ) - { - // remember it (-1 is for MNEMONIC_PREFIX itself - indexAccel = pc - label.begin() - 1; - } - else - { - wxFAIL_MSG(wxT("duplicate accel char in control label")); - } - } - } - - if ( labelOnly ) - { - *labelOnly += *pc; - } - } - - return indexAccel; -} - -wxBorder wxControlBase::GetDefaultBorder() const -{ - return wxBORDER_THEME; -} - -/* static */ wxVisualAttributes -wxControlBase::GetCompositeControlsDefaultAttributes(wxWindowVariant WXUNUSED(variant)) -{ - wxVisualAttributes attrs; - attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); - attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - - return attrs; -} - -// ---------------------------------------------------------------------------- -// wxControl markup support -// ---------------------------------------------------------------------------- - -#if wxUSE_MARKUP - -/* static */ -wxString wxControlBase::RemoveMarkup(const wxString& markup) -{ - return wxMarkupParser::Strip(markup); -} - -bool wxControlBase::DoSetLabelMarkup(const wxString& markup) -{ - const wxString label = RemoveMarkup(markup); - if ( label.empty() && !markup.empty() ) - return false; - - SetLabel(label); - - return true; -} - -#endif // wxUSE_MARKUP - -// ---------------------------------------------------------------------------- -// wxControlBase - ellipsization code -// ---------------------------------------------------------------------------- - -#define wxELLIPSE_REPLACEMENT wxS("...") - -namespace -{ - -struct EllipsizeCalculator -{ - EllipsizeCalculator(const wxString& s, const wxDC& dc, - int maxFinalWidthPx, int replacementWidthPx) - : - m_initialCharToRemove(0), - m_nCharsToRemove(0), - m_outputNeedsUpdate(true), - m_str(s), - m_dc(dc), - m_maxFinalWidthPx(maxFinalWidthPx), - m_replacementWidthPx(replacementWidthPx) - { - m_isOk = dc.GetPartialTextExtents(s, m_charOffsetsPx); - wxASSERT( m_charOffsetsPx.GetCount() == s.length() ); - } - - bool IsOk() const { return m_isOk; } - - bool EllipsizationNotNeeded() const - { - // NOTE: charOffsetsPx[n] is the width in pixels of the first n characters (with the last one INCLUDED) - // thus charOffsetsPx[len-1] is the total width of the string - return m_charOffsetsPx.Last() <= m_maxFinalWidthPx; - } - - void Init(size_t initialCharToRemove, size_t nCharsToRemove) - { - m_initialCharToRemove = initialCharToRemove; - m_nCharsToRemove = nCharsToRemove; - } - - void RemoveFromEnd() - { - m_nCharsToRemove++; - } - - void RemoveFromStart() - { - m_initialCharToRemove--; - m_nCharsToRemove++; - } - - size_t GetFirstRemoved() const { return m_initialCharToRemove; } - size_t GetLastRemoved() const { return m_initialCharToRemove + m_nCharsToRemove - 1; } - - const wxString& GetEllipsizedText() - { - if ( m_outputNeedsUpdate ) - { - wxASSERT(m_initialCharToRemove <= m_str.length() - 1); // see valid range for initialCharToRemove above - wxASSERT(m_nCharsToRemove >= 1 && m_nCharsToRemove <= m_str.length() - m_initialCharToRemove); // see valid range for nCharsToRemove above - - // erase m_nCharsToRemove characters after m_initialCharToRemove (included); - // e.g. if we have the string "foobar" (len = 6) - // ^ - // \--- m_initialCharToRemove = 2 - // and m_nCharsToRemove = 2, then we get "foar" - m_output = m_str; - m_output.replace(m_initialCharToRemove, m_nCharsToRemove, wxELLIPSE_REPLACEMENT); - } - - return m_output; - } - - bool IsShortEnough() - { - if ( m_nCharsToRemove == m_str.length() ) - return true; // that's the best we could do - - // Width calculation using partial extents is just an inaccurate - // estimate: partial extents have sub-pixel precision and are rounded - // by GetPartialTextExtents(); replacing part of the string with "..." - // may change them too thanks to changes in ligatures, kerning etc. - // - // The correct algorithm would be to call GetTextExtent() in every step - // of ellipsization, but that would be too expensive, especially when - // the difference is just a few pixels. So we use partial extents to - // estimate string width and only verify it with GetTextExtent() when - // it looks good. - - int estimatedWidth = m_replacementWidthPx; // length of "..." - - // length of text before the removed part: - if ( m_initialCharToRemove > 0 ) - estimatedWidth += m_charOffsetsPx[m_initialCharToRemove - 1]; - - // length of text after the removed part: - - if ( GetLastRemoved() < m_str.length() ) - estimatedWidth += m_charOffsetsPx.Last() - m_charOffsetsPx[GetLastRemoved()]; - - if ( estimatedWidth > m_maxFinalWidthPx ) - return false; - - return m_dc.GetTextExtent(GetEllipsizedText()).GetWidth() <= m_maxFinalWidthPx; - } - - // calculation state: - - // REMEMBER: indexes inside the string have a valid range of [0;len-1] if not otherwise constrained - // lengths/counts of characters (e.g. nCharsToRemove) have a - // valid range of [0;len] if not otherwise constrained - // NOTE: since this point we know we have for sure a non-empty string from which we need - // to remove _at least_ one character (thus nCharsToRemove below is constrained to be >= 1) - - // index of first character to erase, valid range is [0;len-1]: - size_t m_initialCharToRemove; - // how many chars do we need to erase? valid range is [0;len-m_initialCharToRemove] - size_t m_nCharsToRemove; - - wxString m_output; - bool m_outputNeedsUpdate; - - // inputs: - wxString m_str; - const wxDC& m_dc; - int m_maxFinalWidthPx; - int m_replacementWidthPx; - wxArrayInt m_charOffsetsPx; - - bool m_isOk; -}; - -} // anonymous namespace - -/* static and protected */ -wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxDC& dc, - wxEllipsizeMode mode, int maxFinalWidthPx, - int replacementWidthPx) -{ - wxASSERT_MSG(replacementWidthPx > 0, "Invalid parameters"); - wxASSERT_LEVEL_2_MSG(!curLine.Contains('\n'), - "Use Ellipsize() instead!"); - - wxASSERT_MSG( mode != wxELLIPSIZE_NONE, "shouldn't be called at all then" ); - - // NOTE: this function assumes that any mnemonic/tab character has already - // been handled if it was necessary to handle them (see Ellipsize()) - - if (maxFinalWidthPx <= 0) - return wxEmptyString; - - size_t len = curLine.length(); - if (len <= 1 ) - return curLine; - - EllipsizeCalculator calc(curLine, dc, maxFinalWidthPx, replacementWidthPx); - - if ( !calc.IsOk() ) - return curLine; - - if ( calc.EllipsizationNotNeeded() ) - return curLine; - - // let's compute the range of characters to remove depending on the ellipsization mode: - switch (mode) - { - case wxELLIPSIZE_START: - { - calc.Init(0, 1); - while ( !calc.IsShortEnough() ) - calc.RemoveFromEnd(); - - // always show at least one character of the string: - if ( calc.m_nCharsToRemove == len ) - return wxString(wxELLIPSE_REPLACEMENT) + curLine[len-1]; - - break; - } - - case wxELLIPSIZE_MIDDLE: - { - // NOTE: the following piece of code works also when len == 1 - - // start the removal process from the middle of the string - // i.e. separe the string in three parts: - // - the first one to preserve, valid range [0;initialCharToRemove-1] or the empty range if initialCharToRemove==0 - // - the second one to remove, valid range [initialCharToRemove;endCharToRemove] - // - the third one to preserve, valid range [endCharToRemove+1;len-1] or the empty range if endCharToRemove==len-1 - // NOTE: empty range != range [0;0] since the range [0;0] contains 1 character (the zero-th one)! - - calc.Init(len/2, 0); - - bool removeFromStart = true; - - while ( !calc.IsShortEnough() ) - { - const bool canRemoveFromStart = calc.GetFirstRemoved() > 0; - const bool canRemoveFromEnd = calc.GetLastRemoved() < len - 1; - - if ( !canRemoveFromStart && !canRemoveFromEnd ) - { - // we need to remove all the characters of the string! - break; - } - - // Remove from the beginning in even steps and from the end - // in odd steps, unless we exhausted one side already: - removeFromStart = !removeFromStart; - if ( removeFromStart && !canRemoveFromStart ) - removeFromStart = false; - else if ( !removeFromStart && !canRemoveFromEnd ) - removeFromStart = true; - - if ( removeFromStart ) - calc.RemoveFromStart(); - else - calc.RemoveFromEnd(); - } - - // Always show at least one character of the string. - // Additionally, if there's only one character left, prefer - // "a..." to "...a": - if ( calc.m_nCharsToRemove == len || - calc.m_nCharsToRemove == len - 1 ) - { - return curLine[0] + wxString(wxELLIPSE_REPLACEMENT); - } - } - break; - - case wxELLIPSIZE_END: - { - calc.Init(len - 1, 1); - while ( !calc.IsShortEnough() ) - calc.RemoveFromStart(); - - // always show at least one character of the string: - if ( calc.m_nCharsToRemove == len ) - return curLine[0] + wxString(wxELLIPSE_REPLACEMENT); - - break; - } - - case wxELLIPSIZE_NONE: - default: - wxFAIL_MSG("invalid ellipsize mode"); - return curLine; - } - - return calc.GetEllipsizedText(); -} - -/* static */ -wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc, - wxEllipsizeMode mode, int maxFinalWidth, - int flags) -{ - wxString ret; - - // these cannot be cached between different Ellipsize() calls as they can - // change because of e.g. a font change; however we calculate them only once - // when ellipsizing multiline labels: - int replacementWidth = dc.GetTextExtent(wxELLIPSE_REPLACEMENT).GetWidth(); - - // NB: we must handle correctly labels with newlines: - wxString curLine; - for ( wxString::const_iterator pc = label.begin(); ; ++pc ) - { - if ( pc == label.end() || *pc == wxS('\n') ) - { - curLine = DoEllipsizeSingleLine(curLine, dc, mode, maxFinalWidth, - replacementWidth); - - // add this (ellipsized) row to the rest of the label - ret << curLine; - if ( pc == label.end() ) - break; - - ret << *pc; - curLine.clear(); - } - // we need to remove mnemonics from the label for correct calculations - else if ( *pc == wxS('&') && (flags & wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS) ) - { - // pc+1 is safe: at worst we'll be at end() - wxString::const_iterator next = pc + 1; - if ( next != label.end() && *next == wxS('&') ) - curLine += wxS('&'); // && becomes & - //else: remove this ampersand - } - // we need also to expand tabs to properly calc their size - else if ( *pc == wxS('\t') && (flags & wxELLIPSIZE_FLAGS_EXPAND_TABS) ) - { - // Windows natively expands the TABs to 6 spaces. Do the same: - curLine += wxS(" "); - } - else - { - curLine += *pc; - } - } - - return ret; -} - // ---------------------------------------------------------------------------- // wxStaticBitmap // ---------------------------------------------------------------------------- @@ -583,8 +174,8 @@ wxSize wxStaticBitmapBase::DoGetBestSize() const { wxSize best; wxBitmap bmp = GetBitmap(); - if ( bmp.IsOk() ) - best = bmp.GetScaledSize(); + if ( bmp.Ok() ) + best = wxSize(bmp.GetWidth(), bmp.GetHeight()); else // this is completely arbitrary best = wxSize(16, 16); diff --git a/Source/3rd Party/wx/src/common/ctrlsub.cpp b/Source/3rd Party/wx/src/common/ctrlsub.cpp index 7bf15a929..387b174cc 100644 --- a/Source/3rd Party/wx/src/common/ctrlsub.cpp +++ b/Source/3rd Party/wx/src/common/ctrlsub.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 22.10.99 +// RCS-ID: $Id: ctrlsub.cpp 39077 2006-05-06 19:05:50Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -89,196 +90,93 @@ wxItemContainer::~wxItemContainer() } // ---------------------------------------------------------------------------- -// deleting items +// appending items // ---------------------------------------------------------------------------- -void wxItemContainer::Clear() +void wxItemContainer::Append(const wxArrayString& strings) { - if ( HasClientObjectData() ) + const size_t count = strings.GetCount(); + for ( size_t n = 0; n < count; n++ ) { - const unsigned count = GetCount(); - for ( unsigned i = 0; i < count; ++i ) - ResetItemClientObject(i); - } - - SetClientDataType(wxClientData_None); - - DoClear(); -} - -void wxItemContainer::Delete(unsigned int pos) -{ - wxCHECK_RET( pos < GetCount(), wxT("invalid index") ); - - if ( HasClientObjectData() ) - ResetItemClientObject(pos); - - DoDeleteOneItem(pos); - - if ( IsEmpty() ) - { - SetClientDataType(wxClientData_None); + Append(strings[n]); } } -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- - -int wxItemContainer::DoInsertItemsInLoop(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) +int wxItemContainer::Insert(const wxString& item, unsigned int pos, void *clientData) { - int n = wxNOT_FOUND; - - const unsigned int count = items.GetCount(); - for ( unsigned int i = 0; i < count; ++i ) - { - n = DoInsertOneItem(items[i], pos++); - if ( n == wxNOT_FOUND ) - break; - - AssignNewItemClientData(n, clientData, i, type); - } + int n = DoInsert(item, pos); + if ( n != wxNOT_FOUND ) + SetClientData(n, clientData); return n; } -int -wxItemContainer::DoInsertOneItem(const wxString& WXUNUSED(item), - unsigned int WXUNUSED(pos)) +int wxItemContainer::Insert(const wxString& item, unsigned int pos, wxClientData *clientData) { - wxFAIL_MSG( wxT("Must be overridden if DoInsertItemsInLoop() is used") ); + int n = DoInsert(item, pos); + if ( n != wxNOT_FOUND ) + SetClientObject(n, clientData); - return wxNOT_FOUND; + return n; } - // ---------------------------------------------------------------------------- // client data // ---------------------------------------------------------------------------- void wxItemContainer::SetClientObject(unsigned int n, wxClientData *data) { - wxASSERT_MSG( !HasClientUntypedData(), + wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, wxT("can't have both object and void client data") ); - wxCHECK_RET( IsValid(n), "Invalid index passed to SetClientObject()" ); - - if ( HasClientObjectData() ) + // when we call SetClientObject() for the first time, m_clientDataItemsType + // is still wxClientData_None and so calling DoGetItemClientObject() would + // fail (in addition to being useless) - don't do it + if ( m_clientDataItemsType == wxClientData_Object ) { - wxClientData * clientDataOld - = static_cast(DoGetItemClientData(n)); + wxClientData *clientDataOld = DoGetItemClientObject(n); if ( clientDataOld ) delete clientDataOld; } - else // didn't have any client data so far + else // m_clientDataItemsType == wxClientData_None { // now we have object client data - DoInitItemClientData(); - - SetClientDataType(wxClientData_Object); + m_clientDataItemsType = wxClientData_Object; } - DoSetItemClientData(n, data); + DoSetItemClientObject(n, data); } wxClientData *wxItemContainer::GetClientObject(unsigned int n) const { - wxCHECK_MSG( HasClientObjectData(), NULL, + wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object, wxT("this window doesn't have object client data") ); - wxCHECK_MSG( IsValid(n), NULL, - "Invalid index passed to GetClientObject()" ); - - return static_cast(DoGetItemClientData(n)); -} - -wxClientData *wxItemContainer::DetachClientObject(unsigned int n) -{ - wxClientData * const data = GetClientObject(n); - if ( data ) - { - // reset the pointer as we don't own it any more - DoSetItemClientData(n, NULL); - } - - return data; + return DoGetItemClientObject(n); } void wxItemContainer::SetClientData(unsigned int n, void *data) { - if ( !HasClientData() ) - { - DoInitItemClientData(); - SetClientDataType(wxClientData_Void); - } - - wxASSERT_MSG( HasClientUntypedData(), + wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, wxT("can't have both object and void client data") ); - wxCHECK_RET( IsValid(n), "Invalid index passed to SetClientData()" ); - DoSetItemClientData(n, data); + m_clientDataItemsType = wxClientData_Void; } void *wxItemContainer::GetClientData(unsigned int n) const { - wxCHECK_MSG( HasClientUntypedData(), NULL, + wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void, wxT("this window doesn't have void client data") ); - wxCHECK_MSG( IsValid(n), NULL, - "Invalid index passed to GetClientData()" ); - return DoGetItemClientData(n); } -void wxItemContainer::AssignNewItemClientData(unsigned int pos, - void **clientData, - unsigned int n, - wxClientDataType type) -{ - switch ( type ) - { - case wxClientData_Object: - SetClientObject - ( - pos, - (reinterpret_cast(clientData))[n] - ); - break; - - case wxClientData_Void: - SetClientData(pos, clientData[n]); - break; - - default: - wxFAIL_MSG( wxT("unknown client data type") ); - // fall through - - case wxClientData_None: - // nothing to do - break; - } -} - -void wxItemContainer::ResetItemClientObject(unsigned int n) -{ - wxClientData * const data = GetClientObject(n); - if ( data ) - { - delete data; - DoSetItemClientData(n, NULL); - } -} - // ============================================================================ // wxControlWithItems implementation // ============================================================================ -void -wxControlWithItemsBase::InitCommandEventWithItems(wxCommandEvent& event, int n) +void wxControlWithItems::InitCommandEventWithItems(wxCommandEvent& event, int n) { InitCommandEvent(event); @@ -291,19 +189,9 @@ wxControlWithItemsBase::InitCommandEventWithItems(wxCommandEvent& event, int n) } } -void wxControlWithItemsBase::SendSelectionChangedEvent(wxEventType eventType) +wxControlWithItems::~wxControlWithItems() { - const int n = GetSelection(); - if ( n == wxNOT_FOUND ) - return; - - wxCommandEvent event(eventType, m_windowId); - event.SetInt(n); - event.SetEventObject(this); - event.SetString(GetStringSelection()); - InitCommandEventWithItems(event, n); - - HandleWindowEvent(event); + // this destructor is required for Darwin } #endif // wxUSE_CONTROLS diff --git a/Source/3rd Party/wx/src/common/datacmn.cpp b/Source/3rd Party/wx/src/common/datacmn.cpp new file mode 100644 index 000000000..e82b5ead5 --- /dev/null +++ b/Source/3rd Party/wx/src/common/datacmn.cpp @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: common/datacmn.cpp +// Purpose: contains definitions of various global wxWidgets variables +// Author: Vadim Zeitlin +// Modified by: +// Created: 10.04.03 (from src/*/data.cpp files) +// RCS-ID: $Id: datacmn.cpp 43874 2006-12-09 14:52:59Z VZ $ +// Copyright: (c) 1997-2002 wxWidgets development team +// License: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#endif // WX_PRECOMP + +#include "wx/accel.h" + +// ============================================================================ +// implementation +// ============================================================================ + +// 'Null' objects +#if wxUSE_ACCEL +wxAcceleratorTable wxNullAcceleratorTable; +#endif // wxUSE_ACCEL + +// Default window names +extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[] = wxT("button"); +extern WXDLLEXPORT_DATA(const wxChar) wxCheckBoxNameStr[] = wxT("check"); +extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[] = wxT("comboBox"); +extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[] = wxT("dialog"); +extern WXDLLEXPORT_DATA(const wxChar) wxFrameNameStr[] = wxT("frame"); +extern WXDLLEXPORT_DATA(const wxChar) wxStaticBoxNameStr[] = wxT("groupBox"); +extern WXDLLEXPORT_DATA(const wxChar) wxListBoxNameStr[] = wxT("listBox"); +extern WXDLLEXPORT_DATA(const wxChar) wxStaticLineNameStr[] = wxT("staticLine"); +extern WXDLLEXPORT_DATA(const wxChar) wxStaticTextNameStr[] = wxT("staticText"); +extern WXDLLEXPORT_DATA(const wxChar) wxStaticBitmapNameStr[] = wxT("staticBitmap"); +extern WXDLLEXPORT_DATA(const wxChar) wxNotebookNameStr[] = wxT("notebook"); +extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[] = wxT("panel"); +extern WXDLLEXPORT_DATA(const wxChar) wxRadioBoxNameStr[] = wxT("radioBox"); +extern WXDLLEXPORT_DATA(const wxChar) wxRadioButtonNameStr[] = wxT("radioButton"); +extern WXDLLEXPORT_DATA(const wxChar) wxBitmapRadioButtonNameStr[] = wxT("radioButton"); +extern WXDLLEXPORT_DATA(const wxChar) wxScrollBarNameStr[] = wxT("scrollBar"); +extern WXDLLEXPORT_DATA(const wxChar) wxSliderNameStr[] = wxT("slider"); +extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[] = wxT("status_line"); +extern WXDLLEXPORT_DATA(const wxChar) wxTextCtrlNameStr[] = wxT("text"); +extern WXDLLEXPORT_DATA(const wxChar) wxTreeCtrlNameStr[] = wxT("treeCtrl"); +extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[] = wxT("toolbar"); + +// Default messages +extern WXDLLEXPORT_DATA(const wxChar) wxMessageBoxCaptionStr[] = wxT("Message"); +extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[] = wxT("Select a file"); +extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[] = wxT("Select a directory"); + +// Other default strings +extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[] = +#if defined(__WXMSW__) || defined(__OS2__) + wxT("*.*") +#else // Unix/Mac + wxT("*") +#endif + ; +extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[] = wxT("wxDirCtrl"); +extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogDefaultFolderStr[] = wxT("/"); + +extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[] = wxT("filedlg"); +#if defined(__WXMSW__) || defined(__OS2__) +WXDLLEXPORT_DATA(const wxChar *) wxUserResourceStr = wxT("TEXT"); +#endif diff --git a/Source/3rd Party/wx/src/common/datavcmn.cpp b/Source/3rd Party/wx/src/common/datavcmn.cpp deleted file mode 100644 index 25d85f4f1..000000000 --- a/Source/3rd Party/wx/src/common/datavcmn.cpp +++ /dev/null @@ -1,2559 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/datavcmn.cpp -// Purpose: wxDataViewCtrl base classes and common parts -// Author: Robert Roebling -// Created: 2006/02/20 -// Copyright: (c) 2006, Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DATAVIEWCTRL - -#include "wx/dataview.h" - -#ifndef WX_PRECOMP - #include "wx/dc.h" - #include "wx/settings.h" - #include "wx/log.h" - #include "wx/crt.h" -#endif - -#include "wx/datectrl.h" -#include "wx/spinctrl.h" -#include "wx/choice.h" -#include "wx/imaglist.h" - -const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; - -namespace -{ - -// Custom handler pushed on top of the edit control used by wxDataViewCtrl to -// forward some events to the main control itself. -class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler -{ -public: - wxDataViewEditorCtrlEvtHandler(wxWindow *editor, wxDataViewRenderer *owner) - { - m_editorCtrl = editor; - m_owner = owner; - - m_finished = false; - } - - void AcceptChangesAndFinish(); - void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } - -protected: - void OnChar( wxKeyEvent &event ); - void OnTextEnter( wxCommandEvent &event ); - void OnKillFocus( wxFocusEvent &event ); - void OnIdle( wxIdleEvent &event ); - -private: - wxDataViewRenderer *m_owner; - wxWindow *m_editorCtrl; - bool m_finished; - bool m_focusOnIdle; - -private: - DECLARE_EVENT_TABLE() -}; - -} // anonymous namespace - -// --------------------------------------------------------- -// wxDataViewItemAttr -// --------------------------------------------------------- - -wxFont wxDataViewItemAttr::GetEffectiveFont(const wxFont& font) const -{ - if ( !HasFont() ) - return font; - - wxFont f(font); - if ( GetBold() ) - f.MakeBold(); - if ( GetItalic() ) - f.MakeItalic(); - return f; -} - - -// --------------------------------------------------------- -// wxDataViewModelNotifier -// --------------------------------------------------------- - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxDataViewModelNotifiers) - -bool wxDataViewModelNotifier::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ) -{ - size_t count = items.GetCount(); - size_t i; - for (i = 0; i < count; i++) - if (!ItemAdded( parent, items[i] )) return false; - - return true; -} - -bool wxDataViewModelNotifier::ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ) -{ - size_t count = items.GetCount(); - size_t i; - for (i = 0; i < count; i++) - if (!ItemDeleted( parent, items[i] )) return false; - - return true; -} - -bool wxDataViewModelNotifier::ItemsChanged( const wxDataViewItemArray &items ) -{ - size_t count = items.GetCount(); - size_t i; - for (i = 0; i < count; i++) - if (!ItemChanged( items[i] )) return false; - - return true; -} - -// --------------------------------------------------------- -// wxDataViewModel -// --------------------------------------------------------- - -wxDataViewModel::wxDataViewModel() -{ - m_notifiers.DeleteContents( true ); -} - -bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemAdded( parent, item )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemDeleted( parent, item )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ItemChanged( const wxDataViewItem &item ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemChanged( item )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemsAdded( parent, items )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemsDeleted( parent, items )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ItemsChanged( const wxDataViewItemArray &items ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ItemsChanged( items )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::ValueChanged( const wxDataViewItem &item, unsigned int col ) -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->ValueChanged( item, col )) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::Cleared() -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->Cleared()) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::BeforeReset() -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->BeforeReset()) - ret = false; - } - - return ret; -} - -bool wxDataViewModel::AfterReset() -{ - bool ret = true; - - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - if (!notifier->AfterReset()) - ret = false; - } - - return ret; -} - -void wxDataViewModel::Resort() -{ - wxDataViewModelNotifiers::iterator iter; - for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) - { - wxDataViewModelNotifier* notifier = *iter; - notifier->Resort(); - } -} - -void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier ) -{ - m_notifiers.push_back( notifier ); - notifier->SetOwner( this ); -} - -void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier ) -{ - m_notifiers.DeleteObject( notifier ); -} - -int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ) const -{ - wxVariant value1,value2; - GetValue( value1, item1, column ); - GetValue( value2, item2, column ); - - if (!ascending) - { - wxVariant temp = value1; - value1 = value2; - value2 = temp; - } - - if (value1.GetType() == wxT("string")) - { - wxString str1 = value1.GetString(); - wxString str2 = value2.GetString(); - int res = str1.Cmp( str2 ); - if (res) - return res; - } - else if (value1.GetType() == wxT("long")) - { - long l1 = value1.GetLong(); - long l2 = value2.GetLong(); - if (l1 < l2) - return -1; - else if (l1 > l2) - return 1; - } - else if (value1.GetType() == wxT("double")) - { - double d1 = value1.GetDouble(); - double d2 = value2.GetDouble(); - if (d1 < d2) - return -1; - else if (d1 > d2) - return 1; - } - else if (value1.GetType() == wxT("datetime")) - { - wxDateTime dt1 = value1.GetDateTime(); - wxDateTime dt2 = value2.GetDateTime(); - if (dt1.IsEarlierThan(dt2)) - return -1; - if (dt2.IsEarlierThan(dt1)) - return 1; - } - else if (value1.GetType() == wxT("bool")) - { - bool b1 = value1.GetBool(); - bool b2 = value2.GetBool(); - - if (b1 != b2) - return b1 ? 1 : -1; - } - else if (value1.GetType() == wxT("wxDataViewIconText")) - { - wxDataViewIconText iconText1, iconText2; - - iconText1 << value1; - iconText2 << value2; - - int res = iconText1.GetText().Cmp(iconText2.GetText()); - if (res != 0) - return res; - } - - - // items must be different - wxUIntPtr id1 = wxPtrToUInt(item1.GetID()), - id2 = wxPtrToUInt(item2.GetID()); - - return ascending ? id1 - id2 : id2 - id1; -} - -// --------------------------------------------------------- -// wxDataViewIndexListModel -// --------------------------------------------------------- - -static int my_sort( int *v1, int *v2 ) -{ - return *v2-*v1; -} - - -wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size ) -{ - // IDs are ordered until an item gets deleted or inserted - m_ordered = true; - - // build initial index - unsigned int i; - for (i = 1; i < initial_size+1; i++) - m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) ); - m_nextFreeID = initial_size + 1; -} - -void wxDataViewIndexListModel::Reset( unsigned int new_size ) -{ - /* wxDataViewModel:: */ BeforeReset(); - - m_hash.Clear(); - - // IDs are ordered until an item gets deleted or inserted - m_ordered = true; - - // build initial index - unsigned int i; - for (i = 1; i < new_size+1; i++) - m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) ); - - m_nextFreeID = new_size + 1; - - /* wxDataViewModel:: */ AfterReset(); -} - -void wxDataViewIndexListModel::RowPrepended() -{ - m_ordered = false; - - unsigned int id = m_nextFreeID; - m_nextFreeID++; - - wxDataViewItem item( wxUIntToPtr(id) ); - m_hash.Insert( item, 0 ); - ItemAdded( wxDataViewItem(0), item ); - -} - -void wxDataViewIndexListModel::RowInserted( unsigned int before ) -{ - m_ordered = false; - - unsigned int id = m_nextFreeID; - m_nextFreeID++; - - wxDataViewItem item( wxUIntToPtr(id) ); - m_hash.Insert( item, before ); - ItemAdded( wxDataViewItem(0), item ); -} - -void wxDataViewIndexListModel::RowAppended() -{ - unsigned int id = m_nextFreeID; - m_nextFreeID++; - - wxDataViewItem item( wxUIntToPtr(id) ); - m_hash.Add( item ); - ItemAdded( wxDataViewItem(0), item ); -} - -void wxDataViewIndexListModel::RowDeleted( unsigned int row ) -{ - m_ordered = false; - - wxDataViewItem item( m_hash[row] ); - m_hash.RemoveAt( row ); - /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item ); -} - -void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows ) -{ - m_ordered = false; - - wxDataViewItemArray array; - unsigned int i; - for (i = 0; i < rows.GetCount(); i++) - { - wxDataViewItem item( m_hash[rows[i]] ); - array.Add( item ); - } - - wxArrayInt sorted = rows; - sorted.Sort( my_sort ); - for (i = 0; i < sorted.GetCount(); i++) - m_hash.RemoveAt( sorted[i] ); - - /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array ); -} - -void wxDataViewIndexListModel::RowChanged( unsigned int row ) -{ - /* wxDataViewModel:: */ ItemChanged( GetItem(row) ); -} - -void wxDataViewIndexListModel::RowValueChanged( unsigned int row, unsigned int col ) -{ - /* wxDataViewModel:: */ ValueChanged( GetItem(row), col ); -} - -unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const -{ - if (m_ordered) - return wxPtrToUInt(item.GetID())-1; - - // assert for not found - return (unsigned int) m_hash.Index( item ); -} - -wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const -{ - wxASSERT( row < m_hash.GetCount() ); - return wxDataViewItem( m_hash[row] ); -} - -unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const -{ - if (item.IsOk()) - return 0; - - children = m_hash; - - return m_hash.GetCount(); -} - -// --------------------------------------------------------- -// wxDataViewVirtualListModel -// --------------------------------------------------------- - -#ifndef __WXMAC__ - -wxDataViewVirtualListModel::wxDataViewVirtualListModel( unsigned int initial_size ) -{ - m_size = initial_size; -} - -void wxDataViewVirtualListModel::Reset( unsigned int new_size ) -{ - /* wxDataViewModel:: */ BeforeReset(); - - m_size = new_size; - - /* wxDataViewModel:: */ AfterReset(); -} - -void wxDataViewVirtualListModel::RowPrepended() -{ - m_size++; - wxDataViewItem item( wxUIntToPtr(1) ); - ItemAdded( wxDataViewItem(0), item ); -} - -void wxDataViewVirtualListModel::RowInserted( unsigned int before ) -{ - m_size++; - wxDataViewItem item( wxUIntToPtr(before+1) ); - ItemAdded( wxDataViewItem(0), item ); -} - -void wxDataViewVirtualListModel::RowAppended() -{ - m_size++; - wxDataViewItem item( wxUIntToPtr(m_size) ); - ItemAdded( wxDataViewItem(0), item ); -} - -void wxDataViewVirtualListModel::RowDeleted( unsigned int row ) -{ - m_size--; - wxDataViewItem item( wxUIntToPtr(row+1) ); - /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item ); -} - -void wxDataViewVirtualListModel::RowsDeleted( const wxArrayInt &rows ) -{ - m_size -= rows.GetCount(); - - wxArrayInt sorted = rows; - sorted.Sort( my_sort ); - - wxDataViewItemArray array; - unsigned int i; - for (i = 0; i < sorted.GetCount(); i++) - { - wxDataViewItem item( wxUIntToPtr(sorted[i]+1) ); - array.Add( item ); - } - /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array ); -} - -void wxDataViewVirtualListModel::RowChanged( unsigned int row ) -{ - /* wxDataViewModel:: */ ItemChanged( GetItem(row) ); -} - -void wxDataViewVirtualListModel::RowValueChanged( unsigned int row, unsigned int col ) -{ - /* wxDataViewModel:: */ ValueChanged( GetItem(row), col ); -} - -unsigned int wxDataViewVirtualListModel::GetRow( const wxDataViewItem &item ) const -{ - return wxPtrToUInt( item.GetID() ) -1; -} - -wxDataViewItem wxDataViewVirtualListModel::GetItem( unsigned int row ) const -{ - return wxDataViewItem( wxUIntToPtr(row+1) ); -} - -bool wxDataViewVirtualListModel::HasDefaultCompare() const -{ - return true; -} - -int wxDataViewVirtualListModel::Compare(const wxDataViewItem& item1, - const wxDataViewItem& item2, - unsigned int WXUNUSED(column), - bool ascending) const -{ - unsigned int pos1 = wxPtrToUInt(item1.GetID()); // -1 not needed here - unsigned int pos2 = wxPtrToUInt(item2.GetID()); // -1 not needed here - - if (ascending) - return pos1 - pos2; - else - return pos2 - pos1; -} - -unsigned int wxDataViewVirtualListModel::GetChildren( const wxDataViewItem &WXUNUSED(item), wxDataViewItemArray &WXUNUSED(children) ) const -{ - return 0; // should we report an error ? -} - -#endif // __WXMAC__ - -//----------------------------------------------------------------------------- -// wxDataViewIconText -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxDataViewIconText,wxObject) - -IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) - -// --------------------------------------------------------- -// wxDataViewRendererBase -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject) - -wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, - wxDataViewCellMode WXUNUSED(mode), - int WXUNUSED(align) ) -{ - m_variantType = varianttype; - m_owner = NULL; -} - -wxDataViewRendererBase::~wxDataViewRendererBase() -{ - if ( m_editorCtrl ) - DestroyEditControl(); -} - -wxDataViewCtrl* wxDataViewRendererBase::GetView() const -{ - return const_cast(this)->GetOwner()->GetOwner(); -} - -bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect ) -{ - wxDataViewCtrl* dv_ctrl = GetOwner()->GetOwner(); - - // Before doing anything we send an event asking if editing of this item is really wanted. - wxDataViewEvent start_event( wxEVT_DATAVIEW_ITEM_START_EDITING, dv_ctrl->GetId() ); - start_event.SetDataViewColumn( GetOwner() ); - start_event.SetModel( dv_ctrl->GetModel() ); - start_event.SetItem( item ); - start_event.SetEventObject( dv_ctrl ); - dv_ctrl->GetEventHandler()->ProcessEvent( start_event ); - if( !start_event.IsAllowed() ) - return false; - - m_item = item; // remember for later - - unsigned int col = GetOwner()->GetModelColumn(); - wxVariant value; - dv_ctrl->GetModel()->GetValue( value, item, col ); - - m_editorCtrl = CreateEditorCtrl( dv_ctrl->GetMainWindow(), labelRect, value ); - - // there might be no editor control for the given item - if(!m_editorCtrl) - return false; - - wxDataViewEditorCtrlEvtHandler *handler = - new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ); - - m_editorCtrl->PushEventHandler( handler ); - -#if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL) - handler->SetFocusOnIdle(); -#else - m_editorCtrl->SetFocus(); -#endif - - // Now we should send Editing Started event - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EDITING_STARTED, dv_ctrl->GetId() ); - event.SetDataViewColumn( GetOwner() ); - event.SetModel( dv_ctrl->GetModel() ); - event.SetItem( item ); - event.SetEventObject( dv_ctrl ); - dv_ctrl->GetEventHandler()->ProcessEvent( event ); - - return true; -} - -void wxDataViewRendererBase::DestroyEditControl() -{ - // Remove our event handler first to prevent it from (recursively) calling - // us again as it would do via a call to FinishEditing() when the editor - // loses focus when we hide it below. - wxEvtHandler * const handler = m_editorCtrl->PopEventHandler(); - - // Hide the control immediately but don't delete it yet as there could be - // some pending messages for it. - m_editorCtrl->Hide(); - - wxPendingDelete.Append(handler); - wxPendingDelete.Append(m_editorCtrl); - - // Ensure that DestroyEditControl() is not called again for this control. - m_editorCtrl.Release(); -} - -void wxDataViewRendererBase::CancelEditing() -{ - if (!m_editorCtrl) - return; - - DestroyEditControl(); -} - -bool wxDataViewRendererBase::FinishEditing() -{ - if (!m_editorCtrl) - return true; - - wxVariant value; - GetValueFromEditorCtrl( m_editorCtrl, value ); - - wxDataViewCtrl* dv_ctrl = GetOwner()->GetOwner(); - - DestroyEditControl(); - - dv_ctrl->GetMainWindow()->SetFocus(); - - bool isValid = Validate(value); - unsigned int col = GetOwner()->GetModelColumn(); - - // Now we should send Editing Done event - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EDITING_DONE, dv_ctrl->GetId() ); - event.SetDataViewColumn( GetOwner() ); - event.SetModel( dv_ctrl->GetModel() ); - event.SetItem( m_item ); - event.SetValue( value ); - event.SetColumn( col ); - event.SetEditCanceled( !isValid ); - event.SetEventObject( dv_ctrl ); - dv_ctrl->GetEventHandler()->ProcessEvent( event ); - - if ( isValid && event.IsAllowed() ) - { - dv_ctrl->GetModel()->ChangeValue(value, m_item, col); - return true; - } - - return false; -} - -void wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model, - const wxDataViewItem& item, - unsigned column) -{ - wxVariant value; - model->GetValue(value, item, column); - SetValue(value); - - wxDataViewItemAttr attr; - model->GetAttr(item, column, attr); - SetAttr(attr); - - SetEnabled(model->IsEnabled(item, column)); -} - - -int wxDataViewRendererBase::GetEffectiveAlignment() const -{ - int alignment = GetAlignment(); - - if ( alignment == wxDVR_DEFAULT_ALIGNMENT ) - { - // if we don't have an explicit alignment ourselves, use that of the - // column in horizontal direction and default vertical alignment - alignment = GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL; - } - - return alignment; -} - -// ---------------------------------------------------------------------------- -// wxDataViewCustomRendererBase -// ---------------------------------------------------------------------------- - -bool wxDataViewCustomRendererBase::ActivateCell(const wxRect& cell, - wxDataViewModel *model, - const wxDataViewItem & item, - unsigned int col, - const wxMouseEvent* mouseEvent) -{ - // Compatibility code - if ( mouseEvent ) - return LeftClick(mouseEvent->GetPosition(), cell, model, item, col); - else - return Activate(cell, model, item, col); -} - -void wxDataViewCustomRendererBase::RenderBackground(wxDC* dc, const wxRect& rect) -{ - if ( !m_attr.HasBackgroundColour() ) - return; - - const wxColour& colour = m_attr.GetBackgroundColour(); - wxDCPenChanger changePen(*dc, colour); - wxDCBrushChanger changeBrush(*dc, colour); - - dc->DrawRectangle(rect); -} - -void -wxDataViewCustomRendererBase::WXCallRender(wxRect rectCell, wxDC *dc, int state) -{ - wxCHECK_RET( dc, "no DC to draw on in custom renderer?" ); - - // adjust the rectangle ourselves to account for the alignment - wxRect rectItem = rectCell; - const int align = GetEffectiveAlignment(); - - const wxSize size = GetSize(); - - // take alignment into account only if there is enough space, otherwise - // show as much contents as possible - // - // notice that many existing renderers (e.g. wxDataViewSpinRenderer) - // return hard-coded size which can be more than they need and if we - // trusted their GetSize() we'd draw the text out of cell bounds - // entirely - - if ( size.x >= 0 && size.x < rectCell.width ) - { - if ( align & wxALIGN_CENTER_HORIZONTAL ) - rectItem.x += (rectCell.width - size.x)/2; - else if ( align & wxALIGN_RIGHT ) - rectItem.x += rectCell.width - size.x; - // else: wxALIGN_LEFT is the default - - rectItem.width = size.x; - } - - if ( size.y >= 0 && size.y < rectCell.height ) - { - if ( align & wxALIGN_CENTER_VERTICAL ) - rectItem.y += (rectCell.height - size.y)/2; - else if ( align & wxALIGN_BOTTOM ) - rectItem.y += rectCell.height - size.y; - // else: wxALIGN_TOP is the default - - rectItem.height = size.y; - } - - - // set up the DC attributes - - // override custom foreground with the standard one for the selected items - // because we currently don't allow changing the selection background and - // custom colours may be unreadable on it - wxColour col; - if ( state & wxDATAVIEW_CELL_SELECTED ) - col = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - else if ( m_attr.HasColour() ) - col = m_attr.GetColour(); - else // use default foreground - col = GetOwner()->GetOwner()->GetForegroundColour(); - - wxDCTextColourChanger changeFg(*dc, col); - - wxDCFontChanger changeFont(*dc); - if ( m_attr.HasFont() ) - changeFont.Set(m_attr.GetEffectiveFont(dc->GetFont())); - - Render(rectItem, dc, state); -} - -wxSize wxDataViewCustomRendererBase::GetTextExtent(const wxString& str) const -{ - const wxDataViewCtrl *view = GetView(); - - if ( m_attr.HasFont() ) - { - wxFont font(m_attr.GetEffectiveFont(view->GetFont())); - wxSize size; - view->GetTextExtent(str, &size.x, &size.y, NULL, NULL, &font); - return size; - } - else - { - return view->GetTextExtent(str); - } -} - -void -wxDataViewCustomRendererBase::RenderText(const wxString& text, - int xoffset, - wxRect rect, - wxDC *dc, - int WXUNUSED(state)) -{ - wxRect rectText = rect; - rectText.x += xoffset; - rectText.width -= xoffset; - - // check if we want to ellipsize the text if it doesn't fit - wxString ellipsizedText; - if ( GetEllipsizeMode() != wxELLIPSIZE_NONE ) - { - ellipsizedText = wxControl::Ellipsize - ( - text, - *dc, - GetEllipsizeMode(), - rectText.width, - wxELLIPSIZE_FLAGS_NONE - ); - } - - // get the alignment to use - dc->DrawLabel(ellipsizedText.empty() ? text : ellipsizedText, - rectText, GetEffectiveAlignment()); -} - -//----------------------------------------------------------------------------- -// wxDataViewEditorCtrlEvtHandler -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler) - EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar) - EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus) - EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle) - EVT_TEXT_ENTER (-1, wxDataViewEditorCtrlEvtHandler::OnTextEnter) -END_EVENT_TABLE() - -void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event ) -{ - if (m_focusOnIdle) - { - m_focusOnIdle = false; - if (wxWindow::FindFocus() != m_editorCtrl) - m_editorCtrl->SetFocus(); - } - - event.Skip(); -} - -void wxDataViewEditorCtrlEvtHandler::OnTextEnter( wxCommandEvent &WXUNUSED(event) ) -{ - m_finished = true; - m_owner->FinishEditing(); -} - -void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event ) -{ - switch ( event.m_keyCode ) - { - case WXK_RETURN: - m_finished = true; - m_owner->FinishEditing(); - break; - - case WXK_ESCAPE: - { - m_finished = true; - m_owner->CancelEditing(); - break; - } - default: - event.Skip(); - } -} - -void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event ) -{ - if (!m_finished) - { - m_finished = true; - m_owner->FinishEditing(); - } - - event.Skip(); -} - -// --------------------------------------------------------- -// wxDataViewColumnBase -// --------------------------------------------------------- - -void wxDataViewColumnBase::Init(wxDataViewRenderer *renderer, - unsigned int model_column) -{ - m_renderer = renderer; - m_model_column = model_column; - m_owner = NULL; - m_renderer->SetOwner( (wxDataViewColumn*) this ); -} - -wxDataViewColumnBase::~wxDataViewColumnBase() -{ - delete m_renderer; -} - -// --------------------------------------------------------- -// wxDataViewCtrlBase -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl) - -wxDataViewCtrlBase::wxDataViewCtrlBase() -{ - m_model = NULL; - m_expander_column = 0; - m_indent = 8; -} - -wxDataViewCtrlBase::~wxDataViewCtrlBase() -{ - if (m_model) - { - m_model->DecRef(); - m_model = NULL; - } -} - -bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model ) -{ - if (m_model) - { - m_model->DecRef(); // discard old model, if any - } - - // add our own reference to the new model: - m_model = model; - if (m_model) - { - m_model->IncRef(); - } - - return true; -} - -wxDataViewModel* wxDataViewCtrlBase::GetModel() -{ - return m_model; -} - -const wxDataViewModel* wxDataViewCtrlBase::GetModel() const -{ - return m_model; -} - -void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item ) -{ - if (!m_model) return; - - if (!item.IsOk()) return; - - wxVector parentChain; - - // at first we get all the parents of the selected item - wxDataViewItem parent = m_model->GetParent(item); - while (parent.IsOk()) - { - parentChain.push_back(parent); - parent = m_model->GetParent(parent); - } - - // then we expand the parents, starting at the root - while (!parentChain.empty()) - { - Expand(parentChain.back()); - parentChain.pop_back(); - } -} - -wxDataViewItem wxDataViewCtrlBase::GetCurrentItem() const -{ - return HasFlag(wxDV_MULTIPLE) ? DoGetCurrentItem() - : GetSelection(); -} - -void wxDataViewCtrlBase::SetCurrentItem(const wxDataViewItem& item) -{ - wxCHECK_RET( item.IsOk(), "Can't make current an invalid item." ); - - if ( HasFlag(wxDV_MULTIPLE) ) - DoSetCurrentItem(item); - else - Select(item); -} - -wxDataViewItem wxDataViewCtrlBase::GetSelection() const -{ - if ( GetSelectedItemsCount() != 1 ) - return wxDataViewItem(); - - wxDataViewItemArray selections; - GetSelections(selections); - return selections[0]; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewTextRenderer( wxT("string"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendIconTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewToggleRenderer( wxT("bool"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewDateRenderer( wxT("datetime"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewTextRenderer( wxT("string"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewToggleRenderer( wxT("bool"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewDateRenderer( wxT("datetime"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), - model_column, width, align, flags ); - AppendColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewTextRenderer( wxT("string"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependIconTextColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependToggleColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewToggleRenderer( wxT("bool"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependProgressColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependDateColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewDateRenderer( wxT("datetime"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependBitmapColumn( const wxString &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewTextRenderer( wxT("string"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependToggleColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewToggleRenderer( wxT("bool"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependProgressColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependDateColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewDateRenderer( wxT("datetime"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -wxDataViewColumn * -wxDataViewCtrlBase::PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), - model_column, width, align, flags ); - PrependColumn( ret ); - return ret; -} - -bool -wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) -{ - col->SetOwner( (wxDataViewCtrl*) this ); - return true; -} - -bool -wxDataViewCtrlBase::PrependColumn( wxDataViewColumn *col ) -{ - col->SetOwner( (wxDataViewCtrl*) this ); - return true; -} - -bool -wxDataViewCtrlBase::InsertColumn( unsigned int WXUNUSED(pos), wxDataViewColumn *col ) -{ - col->SetOwner( (wxDataViewCtrl*) this ); - return true; -} - -void wxDataViewCtrlBase::StartEditor(const wxDataViewItem& item, unsigned int column) -{ - EditItem(item, GetColumn(column)); -} - -// --------------------------------------------------------- -// wxDataViewEvent -// --------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) - -wxDEFINE_EVENT( wxEVT_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); - -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); - -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); - -wxDEFINE_EVENT( wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); - -wxDEFINE_EVENT( wxEVT_DATAVIEW_CACHE_HINT, wxDataViewEvent ); - -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent ); - - - -// ------------------------------------- -// wxDataViewSpinRenderer -// ------------------------------------- - -wxDataViewSpinRenderer::wxDataViewSpinRenderer( int min, int max, wxDataViewCellMode mode, int alignment ) : - wxDataViewCustomRenderer(wxT("long"), mode, alignment ) -{ - m_min = min; - m_max = max; -} - -wxWindow* wxDataViewSpinRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ) -{ - long l = value; - wxString str; - str.Printf( wxT("%d"), (int) l ); - wxSpinCtrl *sc = new wxSpinCtrl( parent, wxID_ANY, str, - labelRect.GetTopLeft(), labelRect.GetSize(), wxSP_ARROW_KEYS|wxTE_PROCESS_ENTER, m_min, m_max, l ); -#ifdef __WXMAC__ - const wxSize size = sc->GetSize(); - wxPoint pt = sc->GetPosition(); - sc->SetSize( pt.x - 4, pt.y - 4, size.x, size.y ); -#endif - - return sc; -} - -bool wxDataViewSpinRenderer::GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ) -{ - wxSpinCtrl *sc = (wxSpinCtrl*) editor; - long l = sc->GetValue(); - value = l; - return true; -} - -bool wxDataViewSpinRenderer::Render( wxRect rect, wxDC *dc, int state ) -{ - wxString str; - str.Printf(wxT("%d"), (int) m_data ); - RenderText( str, 0, rect, dc, state ); - return true; -} - -wxSize wxDataViewSpinRenderer::GetSize() const -{ - wxSize sz = GetTextExtent(wxString::Format("%d", (int)m_data)); - - // Allow some space for the spin buttons, which is approximately the size - // of a scrollbar (and getting pixel-exact value would be complicated). - // Also add some whitespace between the text and the button: - sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - sz.x += GetTextExtent("M").x; - - return sz; -} - -bool wxDataViewSpinRenderer::SetValue( const wxVariant &value ) -{ - m_data = value.GetLong(); - return true; -} - -bool wxDataViewSpinRenderer::GetValue( wxVariant &value ) const -{ - value = m_data; - return true; -} - -// ------------------------------------- -// wxDataViewChoiceRenderer -// ------------------------------------- - -#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__) - -wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices, wxDataViewCellMode mode, int alignment ) : - wxDataViewCustomRenderer(wxT("string"), mode, alignment ) -{ - m_choices = choices; -} - -wxWindow* wxDataViewChoiceRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ) -{ - wxChoice* c = new wxChoice - ( - parent, - wxID_ANY, - labelRect.GetTopLeft(), - wxSize(labelRect.GetWidth(), -1), - m_choices - ); - c->Move(labelRect.GetRight() - c->GetRect().width, wxDefaultCoord); - c->SetStringSelection( value.GetString() ); - return c; -} - -bool wxDataViewChoiceRenderer::GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ) -{ - wxChoice *c = (wxChoice*) editor; - wxString s = c->GetStringSelection(); - value = s; - return true; -} - -bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state ) -{ - RenderText( m_data, 0, rect, dc, state ); - return true; -} - -wxSize wxDataViewChoiceRenderer::GetSize() const -{ - wxSize sz; - - for ( wxArrayString::const_iterator i = m_choices.begin(); i != m_choices.end(); ++i ) - sz.IncTo(GetTextExtent(*i)); - - // Allow some space for the right-side button, which is approximately the - // size of a scrollbar (and getting pixel-exact value would be complicated). - // Also add some whitespace between the text and the button: - sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - sz.x += GetTextExtent("M").x; - - return sz; -} - -bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value ) -{ - m_data = value.GetString(); - return true; -} - -bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const -{ - value = m_data; - return true; -} - -// ---------------------------------------------------------------------------- -// wxDataViewChoiceByIndexRenderer -// ---------------------------------------------------------------------------- - -wxDataViewChoiceByIndexRenderer::wxDataViewChoiceByIndexRenderer( const wxArrayString &choices, - wxDataViewCellMode mode, int alignment ) : - wxDataViewChoiceRenderer( choices, mode, alignment ) -{ -} - -wxWindow* wxDataViewChoiceByIndexRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ) -{ - wxVariant string_value = GetChoice( value.GetLong() ); - - return wxDataViewChoiceRenderer::CreateEditorCtrl( parent, labelRect, string_value ); -} - -bool wxDataViewChoiceByIndexRenderer::GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ) -{ - wxVariant string_value; - if (!wxDataViewChoiceRenderer::GetValueFromEditorCtrl( editor, string_value )) - return false; - - value = (long) GetChoices().Index( string_value.GetString() ); - return true; -} - -bool wxDataViewChoiceByIndexRenderer::SetValue( const wxVariant &value ) -{ - wxVariant string_value = GetChoice( value.GetLong() ); - return wxDataViewChoiceRenderer::SetValue( string_value ); -} - -bool wxDataViewChoiceByIndexRenderer::GetValue( wxVariant &value ) const -{ - wxVariant string_value; - if (!wxDataViewChoiceRenderer::GetValue( string_value )) - return false; - - value = (long) GetChoices().Index( string_value.GetString() ); - return true; -} - -#endif - -// --------------------------------------------------------- -// wxDataViewDateRenderer -// --------------------------------------------------------- - -#if (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL - -wxDataViewDateRenderer::wxDataViewDateRenderer(const wxString& varianttype, - wxDataViewCellMode mode, int align) - : wxDataViewCustomRenderer(varianttype, mode, align) -{ -} - -wxWindow * -wxDataViewDateRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value) -{ - return new wxDatePickerCtrl - ( - parent, - wxID_ANY, - value.GetDateTime(), - labelRect.GetTopLeft(), - labelRect.GetSize() - ); -} - -bool wxDataViewDateRenderer::GetValueFromEditorCtrl(wxWindow *editor, wxVariant& value) -{ - wxDatePickerCtrl *ctrl = static_cast(editor); - value = ctrl->GetValue(); - return true; -} - -bool wxDataViewDateRenderer::SetValue(const wxVariant& value) -{ - m_date = value.GetDateTime(); - return true; -} - -bool wxDataViewDateRenderer::GetValue(wxVariant& value) const -{ - value = m_date; - return true; -} - -bool wxDataViewDateRenderer::Render(wxRect cell, wxDC* dc, int state) -{ - wxString tmp = m_date.FormatDate(); - RenderText( tmp, 0, cell, dc, state ); - return true; -} - -wxSize wxDataViewDateRenderer::GetSize() const -{ - return GetTextExtent(m_date.FormatDate()); -} - -#endif // (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL - -//----------------------------------------------------------------------------- -// wxDataViewListStore -//----------------------------------------------------------------------------- - -wxDataViewListStore::wxDataViewListStore() -{ -} - -wxDataViewListStore::~wxDataViewListStore() -{ - wxVector::iterator it; - for (it = m_data.begin(); it != m_data.end(); ++it) - { - wxDataViewListStoreLine* line = *it; - delete line; - } -} - -void wxDataViewListStore::PrependColumn( const wxString &varianttype ) -{ - m_cols.Insert( varianttype, 0 ); -} - -void wxDataViewListStore::InsertColumn( unsigned int pos, const wxString &varianttype ) -{ - m_cols.Insert( varianttype, pos ); -} - -void wxDataViewListStore::AppendColumn( const wxString &varianttype ) -{ - m_cols.Add( varianttype ); -} - -unsigned int wxDataViewListStore::GetColumnCount() const -{ - return m_cols.GetCount(); -} - -unsigned int wxDataViewListStore::GetItemCount() const -{ - return m_data.size(); -} - -wxString wxDataViewListStore::GetColumnType( unsigned int pos ) const -{ - return m_cols[pos]; -} - -void wxDataViewListStore::AppendItem( const wxVector &values, wxUIntPtr data ) -{ - wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); - line->m_values = values; - m_data.push_back( line ); - - RowAppended(); -} - -void wxDataViewListStore::PrependItem( const wxVector &values, wxUIntPtr data ) -{ - wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); - line->m_values = values; - m_data.insert( m_data.begin(), line ); - - RowPrepended(); -} - -void wxDataViewListStore::InsertItem( unsigned int row, const wxVector &values, - wxUIntPtr data ) -{ - wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); - line->m_values = values; - m_data.insert( m_data.begin()+row, line ); - - RowInserted( row ); -} - -void wxDataViewListStore::DeleteItem( unsigned int row ) -{ - wxVector::iterator it = m_data.begin() + row; - delete *it; - m_data.erase( it ); - - RowDeleted( row ); -} - -void wxDataViewListStore::DeleteAllItems() -{ - wxVector::iterator it; - for (it = m_data.begin(); it != m_data.end(); ++it) - { - wxDataViewListStoreLine* line = *it; - delete line; - } - - m_data.clear(); - - Reset( 0 ); -} - -void wxDataViewListStore::ClearColumns() -{ - m_cols.clear(); -} - -void wxDataViewListStore::SetItemData( const wxDataViewItem& item, wxUIntPtr data ) -{ - wxDataViewListStoreLine* line = m_data[GetRow(item)]; - if (!line) return; - - line->SetData( data ); -} - -wxUIntPtr wxDataViewListStore::GetItemData( const wxDataViewItem& item ) const -{ - wxDataViewListStoreLine* line = m_data[GetRow(item)]; - if (!line) return 0; - - return line->GetData(); -} - -void wxDataViewListStore::GetValueByRow( wxVariant &value, unsigned int row, unsigned int col ) const -{ - wxDataViewListStoreLine *line = m_data[row]; - value = line->m_values[col]; -} - -bool wxDataViewListStore::SetValueByRow( const wxVariant &value, unsigned int row, unsigned int col ) -{ - wxDataViewListStoreLine *line = m_data[row]; - line->m_values[col] = value; - - return true; -} - -//----------------------------------------------------------------------------- -// wxDataViewListCtrl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxDataViewListCtrl,wxDataViewCtrl) - -BEGIN_EVENT_TABLE(wxDataViewListCtrl,wxDataViewCtrl) - EVT_SIZE( wxDataViewListCtrl::OnSize ) -END_EVENT_TABLE() - -wxDataViewListCtrl::wxDataViewListCtrl() -{ -} - -wxDataViewListCtrl::wxDataViewListCtrl( wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, - const wxValidator& validator ) -{ - Create( parent, id, pos, size, style, validator ); -} - -wxDataViewListCtrl::~wxDataViewListCtrl() -{ -} - - -bool wxDataViewListCtrl::Create( wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, - const wxValidator& validator ) -{ - if ( !wxDataViewCtrl::Create( parent, id, pos, size, style, validator ) ) - return false; - - wxDataViewListStore *store = new wxDataViewListStore; - AssociateModel( store ); - store->DecRef(); - - return true; -} - -bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *column, const wxString &varianttype ) -{ - GetStore()->AppendColumn( varianttype ); - return wxDataViewCtrl::AppendColumn( column ); -} - -bool wxDataViewListCtrl::PrependColumn( wxDataViewColumn *column, const wxString &varianttype ) -{ - GetStore()->PrependColumn( varianttype ); - return wxDataViewCtrl::PrependColumn( column ); -} - -bool wxDataViewListCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ) -{ - GetStore()->InsertColumn( pos, varianttype ); - return wxDataViewCtrl::InsertColumn( pos, column ); -} - -bool wxDataViewListCtrl::PrependColumn( wxDataViewColumn *col ) -{ - return PrependColumn( col, col->GetRenderer()->GetVariantType() ); -} - -bool wxDataViewListCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col ) -{ - return InsertColumn( pos, col, col->GetRenderer()->GetVariantType() ); -} - -bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *col ) -{ - return AppendColumn( col, col->GetRenderer()->GetVariantType() ); -} - -bool wxDataViewListCtrl::ClearColumns() -{ - GetStore()->ClearColumns(); - return wxDataViewCtrl::ClearColumns(); -} - -wxDataViewColumn *wxDataViewListCtrl::AppendTextColumn( const wxString &label, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - GetStore()->AppendColumn( wxT("string") ); - - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewTextRenderer( wxT("string"), mode ), - GetStore()->GetColumnCount()-1, width, align, flags ); - - wxDataViewCtrl::AppendColumn( ret ); - - return ret; -} - -wxDataViewColumn *wxDataViewListCtrl::AppendToggleColumn( const wxString &label, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - GetStore()->AppendColumn( wxT("bool") ); - - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewToggleRenderer( wxT("bool"), mode ), - GetStore()->GetColumnCount()-1, width, align, flags ); - - wxDataViewCtrl::AppendColumn( ret ); - - return ret; -} - -wxDataViewColumn *wxDataViewListCtrl::AppendProgressColumn( const wxString &label, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - GetStore()->AppendColumn( wxT("long") ); - - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), - GetStore()->GetColumnCount()-1, width, align, flags ); - - wxDataViewCtrl::AppendColumn( ret ); - - return ret; -} - -wxDataViewColumn *wxDataViewListCtrl::AppendIconTextColumn( const wxString &label, - wxDataViewCellMode mode, int width, wxAlignment align, int flags ) -{ - GetStore()->AppendColumn( wxT("wxDataViewIconText") ); - - wxDataViewColumn *ret = new wxDataViewColumn( label, - new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), - GetStore()->GetColumnCount()-1, width, align, flags ); - - wxDataViewCtrl::AppendColumn( ret ); - - return ret; -} - -void wxDataViewListCtrl::OnSize( wxSizeEvent &event ) -{ - event.Skip( true ); -} - -//----------------------------------------------------------------------------- -// wxDataViewTreeStore -//----------------------------------------------------------------------------- - -wxDataViewTreeStoreNode::wxDataViewTreeStoreNode( - wxDataViewTreeStoreNode *parent, - const wxString &text, const wxIcon &icon, wxClientData *data ) -{ - m_parent = parent; - m_text = text; - m_icon = icon; - m_data = data; -} - -wxDataViewTreeStoreNode::~wxDataViewTreeStoreNode() -{ - if (m_data) - delete m_data; -} - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxDataViewTreeStoreNodeList) - -wxDataViewTreeStoreContainerNode::wxDataViewTreeStoreContainerNode( - wxDataViewTreeStoreNode *parent, const wxString &text, - const wxIcon &icon, const wxIcon &expanded, wxClientData *data ) : - wxDataViewTreeStoreNode( parent, text, icon, data ) -{ - m_iconExpanded = expanded; - m_isExpanded = false; - m_children.DeleteContents(true); -} - -wxDataViewTreeStoreContainerNode::~wxDataViewTreeStoreContainerNode() -{ -} - -//----------------------------------------------------------------------------- - -wxDataViewTreeStore::wxDataViewTreeStore() -{ - m_root = new wxDataViewTreeStoreContainerNode( NULL, wxEmptyString ); -} - -wxDataViewTreeStore::~wxDataViewTreeStore() -{ - delete m_root; -} - -wxDataViewItem wxDataViewTreeStore::AppendItem( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon, wxClientData *data ) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *node = - new wxDataViewTreeStoreNode( parent_node, text, icon, data ); - parent_node->GetChildren().Append( node ); - - return node->GetItem(); -} - -wxDataViewItem wxDataViewTreeStore::PrependItem( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon, wxClientData *data ) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *node = - new wxDataViewTreeStoreNode( parent_node, text, icon, data ); - parent_node->GetChildren().Insert( node ); - - return node->GetItem(); -} - -wxDataViewItem -wxDataViewTreeStore::InsertItem(const wxDataViewItem& parent, - const wxDataViewItem& previous, - const wxString& text, - const wxIcon& icon, - wxClientData *data) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *previous_node = FindNode( previous ); - int pos = parent_node->GetChildren().IndexOf( previous_node ); - if (pos == wxNOT_FOUND) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *node = - new wxDataViewTreeStoreNode( parent_node, text, icon, data ); - parent_node->GetChildren().Insert( (size_t) pos, node ); - - return node->GetItem(); -} - -wxDataViewItem wxDataViewTreeStore::PrependContainer( const wxDataViewItem& parent, - const wxString &text, const wxIcon &icon, const wxIcon &expanded, - wxClientData *data ) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreContainerNode *node = - new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data ); - parent_node->GetChildren().Insert( node ); - - return node->GetItem(); -} - -wxDataViewItem -wxDataViewTreeStore::AppendContainer(const wxDataViewItem& parent, - const wxString &text, - const wxIcon& icon, - const wxIcon& expanded, - wxClientData * data) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreContainerNode *node = - new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data ); - parent_node->GetChildren().Append( node ); - - return node->GetItem(); -} - -wxDataViewItem -wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent, - const wxDataViewItem& previous, - const wxString& text, - const wxIcon& icon, - const wxIcon& expanded, - wxClientData * data) -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *previous_node = FindNode( previous ); - int pos = parent_node->GetChildren().IndexOf( previous_node ); - if (pos == wxNOT_FOUND) return wxDataViewItem(0); - - wxDataViewTreeStoreContainerNode *node = - new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data ); - parent_node->GetChildren().Insert( (size_t) pos, node ); - - return node->GetItem(); -} - -bool wxDataViewTreeStore::IsContainer( const wxDataViewItem& item ) const -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return false; - - return node->IsContainer(); -} - -wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const -{ - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); - if (!parent_node) return wxDataViewItem(0); - - wxDataViewTreeStoreNodeList::compatibility_iterator node = parent_node->GetChildren().Item( pos ); - if (node) - return wxDataViewItem(node->GetData()); - - return wxDataViewItem(0); -} - -int wxDataViewTreeStore::GetChildCount( const wxDataViewItem& parent ) const -{ - wxDataViewTreeStoreNode *node = FindNode( parent ); - if (!node) return -1; - - if (!node->IsContainer()) - return 0; - - wxDataViewTreeStoreContainerNode *container_node = (wxDataViewTreeStoreContainerNode*) node; - return (int) container_node->GetChildren().GetCount(); -} - -void wxDataViewTreeStore::SetItemText( const wxDataViewItem& item, const wxString &text ) -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return; - - node->SetText( text ); -} - -wxString wxDataViewTreeStore::GetItemText( const wxDataViewItem& item ) const -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return wxEmptyString; - - return node->GetText(); -} - -void wxDataViewTreeStore::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return; - - node->SetIcon( icon ); -} - -const wxIcon &wxDataViewTreeStore::GetItemIcon( const wxDataViewItem& item ) const -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return wxNullIcon; - - return node->GetIcon(); -} - -void wxDataViewTreeStore::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) -{ - wxDataViewTreeStoreContainerNode *node = FindContainerNode( item ); - if (!node) return; - - node->SetExpandedIcon( icon ); -} - -const wxIcon &wxDataViewTreeStore::GetItemExpandedIcon( const wxDataViewItem& item ) const -{ - wxDataViewTreeStoreContainerNode *node = FindContainerNode( item ); - if (!node) return wxNullIcon; - - return node->GetExpandedIcon(); -} - -void wxDataViewTreeStore::SetItemData( const wxDataViewItem& item, wxClientData *data ) -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return; - - node->SetData( data ); -} - -wxClientData *wxDataViewTreeStore::GetItemData( const wxDataViewItem& item ) const -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return NULL; - - return node->GetData(); -} - -void wxDataViewTreeStore::DeleteItem( const wxDataViewItem& item ) -{ - if (!item.IsOk()) return; - - wxDataViewItem parent_item = GetParent( item ); - - wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent_item ); - if (!parent_node) return; - - parent_node->GetChildren().DeleteObject( FindNode(item) ); -} - -void wxDataViewTreeStore::DeleteChildren( const wxDataViewItem& item ) -{ - wxDataViewTreeStoreContainerNode *node = FindContainerNode( item ); - if (!node) return; - - node->GetChildren().clear(); -} - -void wxDataViewTreeStore::DeleteAllItems() -{ - DeleteChildren(wxDataViewItem(m_root)); -} - -void -wxDataViewTreeStore::GetValue(wxVariant &variant, - const wxDataViewItem &item, - unsigned int WXUNUSED(col)) const -{ - // if (col != 0) return; - - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return; - - wxIcon icon( node->GetIcon()); - if (node->IsContainer()) - { - wxDataViewTreeStoreContainerNode *container = (wxDataViewTreeStoreContainerNode*) node; - if (container->IsExpanded() && container->GetExpandedIcon().IsOk()) - icon = container->GetExpandedIcon(); - } - - wxDataViewIconText data( node->GetText(), icon ); - - variant << data; -} - -bool -wxDataViewTreeStore::SetValue(const wxVariant& variant, - const wxDataViewItem& item, - unsigned int WXUNUSED(col)) -{ - // if (col != 0) return false; - - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return false; - - wxDataViewIconText data; - - data << variant; - - node->SetText( data.GetText() ); - node->SetIcon( data.GetIcon() ); - - return true; -} - -wxDataViewItem wxDataViewTreeStore::GetParent( const wxDataViewItem &item ) const -{ - wxDataViewTreeStoreNode *node = FindNode( item ); - if (!node) return wxDataViewItem(0); - - wxDataViewTreeStoreNode *parent = node->GetParent(); - if (!parent) return wxDataViewItem(0); - - if (parent == m_root) - return wxDataViewItem(0); - - return parent->GetItem(); -} - -unsigned int wxDataViewTreeStore::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const -{ - wxDataViewTreeStoreContainerNode *node = FindContainerNode( item ); - if (!node) return 0; - - wxDataViewTreeStoreNodeList::iterator iter; - for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++) - { - wxDataViewTreeStoreNode* child = *iter; - children.Add( child->GetItem() ); - } - - return node->GetChildren().GetCount(); -} - -int wxDataViewTreeStore::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int WXUNUSED(column), bool WXUNUSED(ascending) ) const -{ - wxDataViewTreeStoreNode *node1 = FindNode( item1 ); - wxDataViewTreeStoreNode *node2 = FindNode( item2 ); - - if (!node1 || !node2) - return 0; - - wxDataViewTreeStoreContainerNode* parent1 = - (wxDataViewTreeStoreContainerNode*) node1->GetParent(); - wxDataViewTreeStoreContainerNode* parent2 = - (wxDataViewTreeStoreContainerNode*) node2->GetParent(); - - if (parent1 != parent2) - { - wxLogError( wxT("Comparing items with different parent.") ); - return 0; - } - - if (node1->IsContainer() && !node2->IsContainer()) - return -1; - - if (node2->IsContainer() && !node1->IsContainer()) - return 1; - - return parent1->GetChildren().IndexOf( node1 ) - parent2->GetChildren().IndexOf( node2 ); -} - -wxDataViewTreeStoreNode *wxDataViewTreeStore::FindNode( const wxDataViewItem &item ) const -{ - if (!item.IsOk()) - return m_root; - - return (wxDataViewTreeStoreNode*) item.GetID(); -} - -wxDataViewTreeStoreContainerNode *wxDataViewTreeStore::FindContainerNode( const wxDataViewItem &item ) const -{ - if (!item.IsOk()) - return (wxDataViewTreeStoreContainerNode*) m_root; - - wxDataViewTreeStoreNode* node = (wxDataViewTreeStoreNode*) item.GetID(); - - if (!node->IsContainer()) - return NULL; - - return (wxDataViewTreeStoreContainerNode*) node; -} - -//----------------------------------------------------------------------------- -// wxDataViewTreeCtrl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxDataViewTreeCtrl,wxDataViewCtrl) - -BEGIN_EVENT_TABLE(wxDataViewTreeCtrl,wxDataViewCtrl) - EVT_DATAVIEW_ITEM_EXPANDED(-1, wxDataViewTreeCtrl::OnExpanded) - EVT_DATAVIEW_ITEM_COLLAPSED(-1, wxDataViewTreeCtrl::OnCollapsed) - EVT_SIZE( wxDataViewTreeCtrl::OnSize ) -END_EVENT_TABLE() - -bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator ) -{ - if ( !wxDataViewCtrl::Create( parent, id, pos, size, style, validator ) ) - return false; - - // create the standard model and a column in the tree - wxDataViewTreeStore *store = new wxDataViewTreeStore; - AssociateModel( store ); - store->DecRef(); - - AppendIconTextColumn - ( - wxString(), // no label (header is not shown anyhow) - 0, // the only model column - wxDATAVIEW_CELL_EDITABLE, - -1, // default width - wxALIGN_NOT, // and alignment - 0 // not resizable - ); - - return true; -} - -wxDataViewItem wxDataViewTreeCtrl::AppendItem( const wxDataViewItem& parent, - const wxString &text, int iconIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - AppendItem( parent, text, GetImage(iconIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent, - const wxString &text, int iconIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - PrependItem( parent, text, GetImage(iconIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, int iconIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - InsertItem( parent, previous, text, GetImage(iconIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& parent, - const wxString &text, int iconIndex, int expandedIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - PrependContainer( parent, text, - GetImage(iconIndex), GetImage(expandedIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent, - const wxString &text, int iconIndex, int expandedIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - AppendContainer( parent, text, - GetImage(iconIndex), GetImage(expandedIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, - const wxString &text, int iconIndex, int expandedIndex, wxClientData *data ) -{ - wxDataViewItem res = GetStore()-> - InsertContainer( parent, previous, text, - GetImage(iconIndex), GetImage(expandedIndex), data ); - - GetStore()->ItemAdded( parent, res ); - - return res; -} - -void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString &text ) -{ - GetStore()->SetItemText(item,text); - - // notify control - GetStore()->ValueChanged( item, 0 ); -} - -void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) -{ - GetStore()->SetItemIcon(item,icon); - - // notify control - GetStore()->ValueChanged( item, 0 ); -} - -void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) -{ - GetStore()->SetItemExpandedIcon(item,icon); - - // notify control - GetStore()->ValueChanged( item, 0 ); -} - -void wxDataViewTreeCtrl::DeleteItem( const wxDataViewItem& item ) -{ - wxDataViewItem parent_item = GetStore()->GetParent( item ); - - GetStore()->DeleteItem(item); - - // notify control - GetStore()->ItemDeleted( parent_item, item ); -} - -void wxDataViewTreeCtrl::DeleteChildren( const wxDataViewItem& item ) -{ - wxDataViewTreeStoreContainerNode *node = GetStore()->FindContainerNode( item ); - if (!node) return; - - wxDataViewItemArray array; - wxDataViewTreeStoreNodeList::iterator iter; - for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++) - { - wxDataViewTreeStoreNode* child = *iter; - array.Add( child->GetItem() ); - } - - GetStore()->DeleteChildren( item ); - - // notify control - GetStore()->ItemsDeleted( item, array ); -} - -void wxDataViewTreeCtrl::DeleteAllItems() -{ - GetStore()->DeleteAllItems(); - - GetStore()->Cleared(); -} - -void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event ) -{ - if (HasImageList()) return; - - wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() ); - if (!container) return; - - container->SetExpanded( true ); - - GetStore()->ItemChanged( event.GetItem() ); -} - -void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event ) -{ - if (HasImageList()) return; - - wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() ); - if (!container) return; - - container->SetExpanded( false ); - - GetStore()->ItemChanged( event.GetItem() ); -} - -void wxDataViewTreeCtrl::OnSize( wxSizeEvent &event ) -{ -#if defined(wxUSE_GENERICDATAVIEWCTRL) - // automatically resize our only column to take the entire control width - if ( GetColumnCount() ) - { - wxSize size = GetClientSize(); - GetColumn(0)->SetWidth(size.x); - } -#endif - event.Skip( true ); -} - -#endif // wxUSE_DATAVIEWCTRL - diff --git a/Source/3rd Party/wx/src/common/datetime.cpp b/Source/3rd Party/wx/src/common/datetime.cpp index 4446a3340..30db343e8 100644 --- a/Source/3rd Party/wx/src/common/datetime.cpp +++ b/Source/3rd Party/wx/src/common/datetime.cpp @@ -1,10 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: src/common/datetime.cpp // Purpose: implementation of time/date related classes -// (for formatting&parsing see datetimefmt.cpp) // Author: Vadim Zeitlin // Modified by: // Created: 11.05.99 +// RCS-ID: $Id: datetime.cpp 65730 2010-10-02 16:50:34Z TIK $ // Copyright: (c) 1999 Vadim Zeitlin // parts of code taken from sndcal library by Scott E. Lee: // @@ -62,7 +62,7 @@ #if !defined(wxUSE_DATETIME) || wxUSE_DATETIME #ifndef WX_PRECOMP - #ifdef __WINDOWS__ + #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" #endif #include "wx/string.h" @@ -70,11 +70,9 @@ #include "wx/intl.h" #include "wx/stopwatch.h" // for wxGetLocalTimeMillis() #include "wx/module.h" - #include "wx/crt.h" #endif // WX_PRECOMP #include "wx/thread.h" -#include "wx/time.h" #include "wx/tokenzr.h" #include @@ -88,25 +86,162 @@ #include "wx/datetime.h" -// ---------------------------------------------------------------------------- -// wxXTI -// ---------------------------------------------------------------------------- +const long wxDateTime::TIME_T_FACTOR = 1000l; #if wxUSE_EXTENDED_RTTI template<> void wxStringReadValue(const wxString &s , wxDateTime &data ) { - data.ParseFormat(s,"%Y-%m-%d %H:%M:%S", NULL); + data.ParseFormat(s,wxT("%Y-%m-%d %H:%M:%S")) ; } template<> void wxStringWriteValue(wxString &s , const wxDateTime &data ) { - s = data.Format("%Y-%m-%d %H:%M:%S"); + s = data.Format(wxT("%Y-%m-%d %H:%M:%S")) ; } wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringConverter) -#endif // wxUSE_EXTENDED_RTTI +#endif + +// +// ---------------------------------------------------------------------------- +// conditional compilation +// ---------------------------------------------------------------------------- + +#if defined(HAVE_STRPTIME) && defined(__GLIBC__) && \ + ((__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)) + // glibc 2.0.7 strptime() is broken - the following snippet causes it to + // crash (instead of just failing): + // + // strncpy(buf, "Tue Dec 21 20:25:40 1999", 128); + // strptime(buf, "%x", &tm); + // + // so don't use it + #undef HAVE_STRPTIME +#endif // broken strptime() + +#if defined(HAVE_STRPTIME) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS + // configure detects strptime as linkable because it's in the OS X + // System library but MSL headers don't declare it. + +// char *strptime(const char *, const char *, struct tm *); + // However, we DON'T want to just provide it here because we would + // crash and/or overwrite data when strptime from OS X tries + // to fill in MW's struct tm which is two fields shorter (no TZ stuff) + // So for now let's just say we don't have strptime + #undef HAVE_STRPTIME +#endif + +#if defined(__MWERKS__) && wxUSE_UNICODE + #include +#endif + +// define a special symbol for VC8 instead of writing tests for 1400 repeatedly +#ifdef __VISUALC__ + #if __VISUALC__ >= 1400 + #define __VISUALC8__ + #endif +#endif + +#if !defined(WX_TIMEZONE) && !defined(WX_GMTOFF_IN_TM) + #if defined(__WXPALMOS__) + #define WX_GMTOFF_IN_TM + #elif defined(__WXMSW__) + static long wxGetTimeZone() + { + TIME_ZONE_INFORMATION info; + GetTimeZoneInformation(&info); + long timeZone = info.Bias * 60; // convert minutes to seconds + return timeZone; + } + #define WX_TIMEZONE wxGetTimeZone() + #elif defined(__VISAGECPP__) + #define WX_TIMEZONE _timezone + #elif defined(__MWERKS__) + long wxmw_timezone = 28800; + #define WX_TIMEZONE wxmw_timezone + #elif defined(__DARWIN__) + #define WX_GMTOFF_IN_TM + #else // unknown platform - try timezone + #define WX_TIMEZONE timezone + #endif +#endif // !WX_TIMEZONE && !WX_GMTOFF_IN_TM + +// everyone has strftime except Win CE unless VC8 is used +#if !defined(__WXWINCE__) || defined(__VISUALC8__) + #define HAVE_STRFTIME +#endif + +// NB: VC8 safe time functions could/should be used for wxMSW as well probably +#if defined(__WXWINCE__) && defined(__VISUALC8__) + +struct tm *wxLocaltime_r(const time_t *t, struct tm* tm) +{ + __time64_t t64 = *t; + return _localtime64_s(tm, &t64) == 0 ? tm : NULL; +} + +struct tm *wxGmtime_r(const time_t* t, struct tm* tm) +{ + __time64_t t64 = *t; + return _gmtime64_s(tm, &t64) == 0 ? tm : NULL; +} + +#else // !wxWinCE with VC8 + +#if (!defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)) && wxUSE_THREADS && !defined(__WINDOWS__) +static wxMutex timeLock; +#endif + +#ifndef HAVE_LOCALTIME_R +struct tm *wxLocaltime_r(const time_t* ticks, struct tm* temp) +{ +#if wxUSE_THREADS && !defined(__WINDOWS__) + // No need to waste time with a mutex on windows since it's using + // thread local storage for localtime anyway. + wxMutexLocker locker(timeLock); +#endif + + // Borland CRT crashes when passed 0 ticks for some reason, see SF bug 1704438 +#ifdef __BORLANDC__ + if ( !*ticks ) + return NULL; +#endif + + const tm * const t = localtime(ticks); + if ( !t ) + return NULL; + + memcpy(temp, t, sizeof(struct tm)); + return temp; +} +#endif // !HAVE_LOCALTIME_R + +#ifndef HAVE_GMTIME_R +struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp) +{ +#if wxUSE_THREADS && !defined(__WINDOWS__) + // No need to waste time with a mutex on windows since it's + // using thread local storage for gmtime anyway. + wxMutexLocker locker(timeLock); +#endif + +#ifdef __BORLANDC__ + if ( !*ticks ) + return NULL; +#endif + + const tm * const t = gmtime(ticks); + if ( !t ) + return NULL; + + memcpy(temp, gmtime(ticks), sizeof(struct tm)); + return temp; +} +#endif // !HAVE_GMTIME_R + +#endif // wxWinCE with VC8/other platforms // ---------------------------------------------------------------------------- // macros @@ -153,6 +288,8 @@ static const int SEC_PER_MIN = 60; static const int MIN_PER_HOUR = 60; +static const int HOURS_PER_DAY = 24; + static const long SECONDS_PER_DAY = 86400l; static const int DAYS_PER_WEEK = 7; @@ -163,15 +300,14 @@ static const long MILLISECONDS_PER_DAY = 86400000l; // (i.e. JDN(Jan 1, 1970) = 2440587.5) static const long EPOCH_JDN = 2440587l; -// these values are only used in asserts so don't define them if asserts are -// disabled to avoid warnings about unused static variables -#if wxDEBUG_LEVEL +// used only in asserts +#ifdef __WXDEBUG__ // the date of JDN -0.5 (as we don't work with fractional parts, this is the // reference date for us) is Nov 24, 4714BC static const int JDN_0_YEAR = -4713; static const int JDN_0_MONTH = wxDateTime::Nov; static const int JDN_0_DAY = 24; -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ // the constants used for JDN calculations static const long JDN_OFFSET = 32046l; @@ -187,14 +323,12 @@ static const wxDateTime::wxDateTime_t gs_cumulatedDays[2][MONTHS_IN_YEAR] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 } }; -const long wxDateTime::TIME_T_FACTOR = 1000l; - // ---------------------------------------------------------------------------- // global data // ---------------------------------------------------------------------------- -const char wxDefaultDateTimeFormat[] = "%c"; -const char wxDefaultTimeSpanFormat[] = "%H:%M:%S"; +const wxChar * wxDefaultDateTimeFormat = wxT("%c"); +const wxChar * wxDefaultTimeSpanFormat = wxT("%H:%M:%S"); // in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to // indicate an invalid wxDateTime object @@ -206,19 +340,17 @@ wxDateTime::Country wxDateTime::ms_country = wxDateTime::Country_Unknown; // private functions // ---------------------------------------------------------------------------- -// debugger helper: this function can be called from a debugger to show what -// the date really is -extern const char *wxDumpDate(const wxDateTime* dt) +// debugger helper: shows what the date really is +#ifdef __WXDEBUG__ +extern const wxChar *wxDumpDate(const wxDateTime* dt) { - static char buf[128]; + static wxChar buf[128]; - wxString fmt(dt->Format("%Y-%m-%d (%a) %H:%M:%S")); - wxStrlcpy(buf, - (fmt + " (" + dt->GetValue().ToString() + " ticks)").ToAscii(), - WXSIZEOF(buf)); + wxStrcpy(buf, dt->Format(_T("%Y-%m-%d (%a) %H:%M:%S"))); return buf; } +#endif // Debug // get the number of days in the given month of the given year static inline @@ -226,7 +358,7 @@ wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month) { // the number of days in month in Julian/Gregorian calendar: the first line // is for normal years, the second one is for the leap ones - static const wxDateTime::wxDateTime_t daysInMonth[2][MONTHS_IN_YEAR] = + static wxDateTime::wxDateTime_t daysInMonth[2][MONTHS_IN_YEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } @@ -235,6 +367,37 @@ wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month) return daysInMonth[wxDateTime::IsLeapYear(year)][month]; } +// returns the time zone in the C sense, i.e. the difference UTC - local +// (in seconds) +static int GetTimeZone() +{ +#ifdef WX_GMTOFF_IN_TM + // set to true when the timezone is set + static bool s_timezoneSet = false; + static long gmtoffset = LONG_MAX; // invalid timezone + + // ensure that the timezone variable is set by calling wxLocaltime_r + if ( !s_timezoneSet ) + { + // just call wxLocaltime_r() instead of figuring out whether this + // system supports tzset(), _tzset() or something else + time_t t = 0; + struct tm tm; + + wxLocaltime_r(&t, &tm); + s_timezoneSet = true; + + // note that GMT offset is the opposite of time zone and so to return + // consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM + // cases we have to negate it + gmtoffset = -tm.tm_gmtoff; + } + return (int)gmtoffset; +#else // !WX_GMTOFF_IN_TM + return WX_TIMEZONE; +#endif // WX_GMTOFF_IN_TM/!WX_GMTOFF_IN_TM +} + // return the integral part of the JDN for the midnight of the given date (to // get the real JDN you need to add 0.5, this is, in fact, JDN of the // noon of the previous day) @@ -249,7 +412,7 @@ static long GetTruncatedJDN(wxDateTime::wxDateTime_t day, (year > JDN_0_YEAR) || ((year == JDN_0_YEAR) && (mon > JDN_0_MONTH)) || ((year == JDN_0_YEAR) && (mon == JDN_0_MONTH) && (day >= JDN_0_DAY)), - wxT("date out of range - can't convert to JDN") + _T("date out of range - can't convert to JDN") ); // make the year positive to avoid problems with negative numbers division @@ -275,11 +438,10 @@ static long GetTruncatedJDN(wxDateTime::wxDateTime_t day, - JDN_OFFSET; } -#ifdef wxHAS_STRFTIME +#ifdef HAVE_STRFTIME // this function is a wrapper around strftime(3) adding error checking -// NOTE: not static because used by datetimefmt.cpp -wxString CallStrftime(const wxString& format, const tm* tm) +static wxString CallStrftime(const wxChar *format, const tm* tm) { wxChar buf[4096]; // Create temp wxString here to work around mingw/cygwin bug 1046059 @@ -288,24 +450,50 @@ wxString CallStrftime(const wxString& format, const tm* tm) if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) ) { - // There is one special case in which strftime() can return 0 without - // indicating an error: "%p" may give empty string depending on the - // locale, so check for it explicitly. Apparently it's really the only - // exception. - if ( format != wxS("%p") ) - { - // if the format is valid, buffer must be too small? - wxFAIL_MSG(wxT("strftime() failed")); - } - - buf[0] = '\0'; + // buffer is too small? + wxFAIL_MSG(_T("strftime() failed")); } s = buf; return s; } -#endif // wxHAS_STRFTIME +#endif // HAVE_STRFTIME + +#ifdef HAVE_STRPTIME + +#if wxUSE_UNIX && !defined(HAVE_STRPTIME_DECL) + // configure detected that we had strptime() but not its declaration, + // provide it ourselves + extern "C" char *strptime(const char *, const char *, struct tm *); +#endif + +// Unicode-friendly strptime() wrapper +static const wxChar * +CallStrptime(const wxChar *input, const char *fmt, tm *tm) +{ + // the problem here is that strptime() returns pointer into the string we + // passed to it while we're really interested in the pointer into the + // original, Unicode, string so we try to transform the pointer back +#if wxUSE_UNICODE + wxCharBuffer inputMB(wxConvertWX2MB(input)); +#else // ASCII + const char * const inputMB = input; +#endif // Unicode/Ascii + + const char *result = strptime(inputMB, fmt, tm); + if ( !result ) + return NULL; + +#if wxUSE_UNICODE + // FIXME: this is wrong in presence of surrogates &c + return input + (result - inputMB.data()); +#else // ASCII + return result; +#endif // Unicode/Ascii +} + +#endif // HAVE_STRPTIME // if year and/or month have invalid values, replace them with the current ones static void ReplaceDefaultYearMonthWithCurrent(int *year, @@ -330,9 +518,8 @@ static void ReplaceDefaultYearMonthWithCurrent(int *year, } } -// fill the struct tm with default values -// NOTE: not static because used by datetimefmt.cpp -void InitTm(struct tm& tm) +// fll the struct tm with default values +static void InitTm(struct tm& tm) { // struct tm may have etxra fields (undocumented and with unportable // names) which, nevertheless, must be set to 0 @@ -343,6 +530,104 @@ void InitTm(struct tm& tm) tm.tm_isdst = -1; // auto determine } +// parsing helpers +// --------------- + +// return the month if the string is a month name or Inv_Month otherwise +static wxDateTime::Month GetMonthFromName(const wxString& name, int flags) +{ + wxDateTime::Month mon; + for ( mon = wxDateTime::Jan; mon < wxDateTime::Inv_Month; wxNextMonth(mon) ) + { + // case-insensitive comparison either one of or with both abbreviated + // and not versions + if ( flags & wxDateTime::Name_Full ) + { + if ( name.CmpNoCase(wxDateTime:: + GetMonthName(mon, wxDateTime::Name_Full)) == 0 ) + { + break; + } + } + + if ( flags & wxDateTime::Name_Abbr ) + { + if ( name.CmpNoCase(wxDateTime:: + GetMonthName(mon, wxDateTime::Name_Abbr)) == 0 ) + { + break; + } + } + } + + return mon; +} + +// return the weekday if the string is a weekday name or Inv_WeekDay otherwise +static wxDateTime::WeekDay GetWeekDayFromName(const wxString& name, int flags) +{ + wxDateTime::WeekDay wd; + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + { + // case-insensitive comparison either one of or with both abbreviated + // and not versions + if ( flags & wxDateTime::Name_Full ) + { + if ( name.CmpNoCase(wxDateTime:: + GetWeekDayName(wd, wxDateTime::Name_Full)) == 0 ) + { + break; + } + } + + if ( flags & wxDateTime::Name_Abbr ) + { + if ( name.CmpNoCase(wxDateTime:: + GetWeekDayName(wd, wxDateTime::Name_Abbr)) == 0 ) + { + break; + } + } + } + + return wd; +} + +/* static */ +struct tm *wxDateTime::GetTmNow(struct tm *tmstruct) +{ + time_t t = GetTimeNow(); + return wxLocaltime_r(&t, tmstruct); +} + +// scans all digits (but no more than len) and returns the resulting number +static bool GetNumericToken(size_t len, const wxChar*& p, unsigned long *number) +{ + size_t n = 1; + wxString s; + while ( wxIsdigit(*p) ) + { + s += *p++; + + if ( len && ++n > len ) + break; + } + + return !s.empty() && s.ToULong(number); +} + +// scans all alphabetic characters and returns the resulting string +static wxString GetAlphaToken(const wxChar*& p) +{ + wxString s; + while ( wxIsalpha(*p) ) + { + s += *p++; + } + + return s; +} + // ============================================================================ // implementation of wxDateTime // ============================================================================ @@ -355,12 +640,8 @@ wxDateTime::Tm::Tm() { year = (wxDateTime_t)wxDateTime::Inv_Year; mon = wxDateTime::Inv_Month; - mday = - yday = 0; - hour = - min = - sec = - msec = 0; + mday = 0; + hour = min = sec = msec = 0; wday = wxDateTime::Inv_WeekDay; } @@ -380,17 +661,9 @@ wxDateTime::Tm::Tm(const struct tm& tm, const TimeZone& tz) bool wxDateTime::Tm::IsValid() const { - if ( mon == wxDateTime::Inv_Month ) - return false; - - // We need to check this here to avoid crashing in GetNumOfDaysInMonth() if - // somebody passed us "(wxDateTime::Month)1000". - wxCHECK_MSG( mon >= wxDateTime::Jan && mon < wxDateTime::Inv_Month, false, - wxS("Invalid month value") ); - // we allow for the leap seconds, although we don't use them (yet) return (year != wxDateTime::Inv_Year) && (mon != wxDateTime::Inv_Month) && - (mday > 0 && mday <= GetNumOfDaysInMonth(year, mon)) && + (mday <= GetNumOfDaysInMonth(year, mon)) && (hour < 24) && (min < 60) && (sec < 62) && (msec < 1000); } @@ -421,7 +694,7 @@ void wxDateTime::Tm::AddMonths(int monDiff) mon = (wxDateTime::Month)(mon + monDiff); - wxASSERT_MSG( mon >= 0 && mon < MONTHS_IN_YEAR, wxT("logic error") ); + wxASSERT_MSG( mon >= 0 && mon < MONTHS_IN_YEAR, _T("logic error") ); // NB: we don't check here that the resulting date is valid, this function // is private and the caller must check it if needed @@ -446,7 +719,7 @@ void wxDateTime::Tm::AddDays(int dayDiff) } wxASSERT_MSG( mday > 0 && mday <= GetNumOfDaysInMonth(year, mon), - wxT("logic error") ); + _T("logic error") ); } // ---------------------------------------------------------------------------- @@ -460,7 +733,7 @@ wxDateTime::TimeZone::TimeZone(wxDateTime::TZ tz) case wxDateTime::Local: // get the offset from C RTL: it returns the difference GMT-local // while we want to have the offset _from_ GMT, hence the '-' - m_offset = -wxGetTimeZone(); + m_offset = -GetTimeZone(); break; case wxDateTime::GMT_12: @@ -501,7 +774,7 @@ wxDateTime::TimeZone::TimeZone(wxDateTime::TZ tz) break; default: - wxFAIL_MSG( wxT("unknown time zone") ); + wxFAIL_MSG( _T("unknown time zone") ); } } @@ -509,13 +782,6 @@ wxDateTime::TimeZone::TimeZone(wxDateTime::TZ tz) // static functions // ---------------------------------------------------------------------------- -/* static */ -struct tm *wxDateTime::GetTmNow(struct tm *tmstruct) -{ - time_t t = GetTimeNow(); - return wxLocaltime_r(&t, tmstruct); -} - /* static */ bool wxDateTime::IsLeapYear(int year, wxDateTime::Calendar cal) { @@ -537,7 +803,7 @@ bool wxDateTime::IsLeapYear(int year, wxDateTime::Calendar cal) } else { - wxFAIL_MSG(wxT("unknown calendar")); + wxFAIL_MSG(_T("unknown calendar")); return false; } @@ -565,11 +831,11 @@ int wxDateTime::GetCurrentYear(wxDateTime::Calendar cal) return Now().GetYear(); case Julian: - wxFAIL_MSG(wxT("TODO")); + wxFAIL_MSG(_T("TODO")); break; default: - wxFAIL_MSG(wxT("unsupported calendar")); + wxFAIL_MSG(_T("unsupported calendar")); break; } @@ -585,11 +851,11 @@ wxDateTime::Month wxDateTime::GetCurrentMonth(wxDateTime::Calendar cal) return Now().GetMonth(); case Julian: - wxFAIL_MSG(wxT("TODO")); + wxFAIL_MSG(_T("TODO")); break; default: - wxFAIL_MSG(wxT("unsupported calendar")); + wxFAIL_MSG(_T("unsupported calendar")); break; } @@ -612,7 +878,7 @@ wxDateTime::wxDateTime_t wxDateTime::GetNumberOfDays(int year, Calendar cal) return IsLeapYear(year) ? 366 : 365; default: - wxFAIL_MSG(wxT("unsupported calendar")); + wxFAIL_MSG(_T("unsupported calendar")); break; } @@ -624,7 +890,7 @@ wxDateTime::wxDateTime_t wxDateTime::GetNumberOfDays(wxDateTime::Month month, int year, wxDateTime::Calendar cal) { - wxCHECK_MSG( month < MONTHS_IN_YEAR, 0, wxT("invalid month") ); + wxCHECK_MSG( month < MONTHS_IN_YEAR, 0, _T("invalid month") ); if ( cal == Gregorian || cal == Julian ) { @@ -638,105 +904,76 @@ wxDateTime::wxDateTime_t wxDateTime::GetNumberOfDays(wxDateTime::Month month, } else { - wxFAIL_MSG(wxT("unsupported calendar")); + wxFAIL_MSG(_T("unsupported calendar")); return 0; } } -namespace -{ - -// helper function used by GetEnglish/WeekDayName(): returns 0 if flags is -// Name_Full and 1 if it is Name_Abbr or -1 if the flags is incorrect (and -// asserts in this case) -// -// the return value of this function is used as an index into 2D array -// containing full names in its first row and abbreviated ones in the 2nd one -int NameArrayIndexFromFlag(wxDateTime::NameFlags flags) -{ - switch ( flags ) - { - case wxDateTime::Name_Full: - return 0; - - case wxDateTime::Name_Abbr: - return 1; - - default: - wxFAIL_MSG( "unknown wxDateTime::NameFlags value" ); - } - - return -1; -} - -} // anonymous namespace - -/* static */ -wxString wxDateTime::GetEnglishMonthName(Month month, NameFlags flags) -{ - wxCHECK_MSG( month != Inv_Month, wxEmptyString, "invalid month" ); - - static const char *const monthNames[2][MONTHS_IN_YEAR] = - { - { "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" }, - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } - }; - - const int idx = NameArrayIndexFromFlag(flags); - if ( idx == -1 ) - return wxString(); - - return monthNames[idx][month]; -} - /* static */ wxString wxDateTime::GetMonthName(wxDateTime::Month month, wxDateTime::NameFlags flags) { -#ifdef wxHAS_STRFTIME - wxCHECK_MSG( month != Inv_Month, wxEmptyString, wxT("invalid month") ); - + wxCHECK_MSG( month != Inv_Month, wxEmptyString, _T("invalid month") ); +#ifdef HAVE_STRFTIME // notice that we must set all the fields to avoid confusing libc (GNU one // gets confused to a crash if we don't do this) tm tm; InitTm(tm); tm.tm_mon = month; - return CallStrftime(flags == Name_Abbr ? wxT("%b") : wxT("%B"), &tm); -#else // !wxHAS_STRFTIME - return GetEnglishMonthName(month, flags); -#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME -} - -/* static */ -wxString wxDateTime::GetEnglishWeekDayName(WeekDay wday, NameFlags flags) -{ - wxCHECK_MSG( wday != Inv_WeekDay, wxEmptyString, wxT("invalid weekday") ); - - static const char *const weekdayNames[2][DAYS_PER_WEEK] = + return CallStrftime(flags == Name_Abbr ? _T("%b") : _T("%B"), &tm); +#else // !HAVE_STRFTIME + wxString ret; + switch(month) { - { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", - "Saturday" }, - { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, - }; - - const int idx = NameArrayIndexFromFlag(flags); - if ( idx == -1 ) - return wxString(); - - return weekdayNames[idx][wday]; + case Jan: + ret = (flags == Name_Abbr ? wxT("Jan"): wxT("January")); + break; + case Feb: + ret = (flags == Name_Abbr ? wxT("Feb"): wxT("Febuary")); + break; + case Mar: + ret = (flags == Name_Abbr ? wxT("Mar"): wxT("March")); + break; + case Apr: + ret = (flags == Name_Abbr ? wxT("Apr"): wxT("April")); + break; + case May: + ret = (flags == Name_Abbr ? wxT("May"): wxT("May")); + break; + case Jun: + ret = (flags == Name_Abbr ? wxT("Jun"): wxT("June")); + break; + case Jul: + ret = (flags == Name_Abbr ? wxT("Jul"): wxT("July")); + break; + case Aug: + ret = (flags == Name_Abbr ? wxT("Aug"): wxT("August")); + break; + case Sep: + ret = (flags == Name_Abbr ? wxT("Sep"): wxT("September")); + break; + case Oct: + ret = (flags == Name_Abbr ? wxT("Oct"): wxT("October")); + break; + case Nov: + ret = (flags == Name_Abbr ? wxT("Nov"): wxT("November")); + break; + case Dec: + ret = (flags == Name_Abbr ? wxT("Dec"): wxT("December")); + break; + } + return ret; +#endif // HAVE_STRFTIME/!HAVE_STRFTIME } /* static */ wxString wxDateTime::GetWeekDayName(wxDateTime::WeekDay wday, wxDateTime::NameFlags flags) { -#ifdef wxHAS_STRFTIME - wxCHECK_MSG( wday != Inv_WeekDay, wxEmptyString, wxT("invalid weekday") ); - + wxCHECK_MSG( wday != Inv_WeekDay, wxEmptyString, _T("invalid weekday") ); +#ifdef HAVE_STRFTIME // take some arbitrary Sunday (but notice that the day should be such that // after adding wday to it below we still have a valid date, e.g. don't // take 28 here!) @@ -753,10 +990,35 @@ wxString wxDateTime::GetWeekDayName(wxDateTime::WeekDay wday, (void)mktime(&tm); // ... and call strftime() - return CallStrftime(flags == Name_Abbr ? wxT("%a") : wxT("%A"), &tm); -#else // !wxHAS_STRFTIME - return GetEnglishWeekDayName(wday, flags); -#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME + return CallStrftime(flags == Name_Abbr ? _T("%a") : _T("%A"), &tm); +#else // !HAVE_STRFTIME + wxString ret; + switch(wday) + { + case Sun: + ret = (flags == Name_Abbr ? wxT("Sun") : wxT("Sunday")); + break; + case Mon: + ret = (flags == Name_Abbr ? wxT("Mon") : wxT("Monday")); + break; + case Tue: + ret = (flags == Name_Abbr ? wxT("Tue") : wxT("Tuesday")); + break; + case Wed: + ret = (flags == Name_Abbr ? wxT("Wed") : wxT("Wednesday")); + break; + case Thu: + ret = (flags == Name_Abbr ? wxT("Thu") : wxT("Thursday")); + break; + case Fri: + ret = (flags == Name_Abbr ? wxT("Fri") : wxT("Friday")); + break; + case Sat: + ret = (flags == Name_Abbr ? wxT("Sat") : wxT("Saturday")); + break; + } + return ret; +#endif // HAVE_STRFTIME/!HAVE_STRFTIME } /* static */ @@ -775,7 +1037,7 @@ void wxDateTime::GetAmPmStrings(wxString *am, wxString *pm) // assert, even though it is a perfectly legal use. if ( am ) { - if (wxStrftime(buffer, WXSIZEOF(buffer), wxT("%p"), &tm) > 0) + if (wxStrftime(buffer, sizeof(buffer)/sizeof(wxChar), _T("%p"), &tm) > 0) *am = wxString(buffer); else *am = wxString(); @@ -783,14 +1045,13 @@ void wxDateTime::GetAmPmStrings(wxString *am, wxString *pm) if ( pm ) { tm.tm_hour = 13; - if (wxStrftime(buffer, WXSIZEOF(buffer), wxT("%p"), &tm) > 0) + if (wxStrftime(buffer, sizeof(buffer)/sizeof(wxChar), _T("%p"), &tm) > 0) *pm = wxString(buffer); else *pm = wxString(); } } - // ---------------------------------------------------------------------------- // Country stuff: date calculations depend on the country (DST, work days, // ...), so we need to know which rules to follow. @@ -808,24 +1069,24 @@ wxDateTime::Country wxDateTime::GetCountry() struct tm tmstruct; struct tm *tm = wxLocaltime_r(&t, &tmstruct); - wxString tz = CallStrftime(wxT("%Z"), tm); - if ( tz == wxT("WET") || tz == wxT("WEST") ) + wxString tz = CallStrftime(_T("%Z"), tm); + if ( tz == _T("WET") || tz == _T("WEST") ) { ms_country = UK; } - else if ( tz == wxT("CET") || tz == wxT("CEST") ) + else if ( tz == _T("CET") || tz == _T("CEST") ) { ms_country = Country_EEC; } - else if ( tz == wxT("MSK") || tz == wxT("MSD") ) + else if ( tz == _T("MSK") || tz == _T("MSD") ) { ms_country = Russia; } - else if ( tz == wxT("AST") || tz == wxT("ADT") || - tz == wxT("EST") || tz == wxT("EDT") || - tz == wxT("CST") || tz == wxT("CDT") || - tz == wxT("MST") || tz == wxT("MDT") || - tz == wxT("PST") || tz == wxT("PDT") ) + else if ( tz == _T("AST") || tz == _T("ADT") || + tz == _T("EST") || tz == _T("EDT") || + tz == _T("CST") || tz == _T("CDT") || + tz == _T("MST") || tz == _T("MDT") || + tz == _T("PST") || tz == _T("PDT") ) { ms_country = USA; } @@ -924,10 +1185,13 @@ wxDateTime wxDateTime::GetBeginDST(int year, Country country) if ( !dt.SetToLastWeekDay(Sun, Mar, year) ) { // weird... - wxFAIL_MSG( wxT("no last Sunday in March?") ); + wxFAIL_MSG( _T("no last Sunday in March?") ); } dt += wxTimeSpan::Hours(1); + + // disable DST tests because it could result in an infinite recursion! + dt.MakeGMT(true); } else switch ( country ) { @@ -967,7 +1231,7 @@ wxDateTime wxDateTime::GetBeginDST(int year, Country country) if ( !dt.SetToLastWeekDay(Sun, Apr, year) ) { // weird... - wxFAIL_MSG( wxT("no first Sunday in April?") ); + wxFAIL_MSG( _T("no first Sunday in April?") ); } } else if ( year > 2006 ) @@ -978,7 +1242,7 @@ wxDateTime wxDateTime::GetBeginDST(int year, Country country) if ( !dt.SetToWeekDay(Sun, 2, Mar, year) ) { // weird... - wxFAIL_MSG( wxT("no second Sunday in March?") ); + wxFAIL_MSG( _T("no second Sunday in March?") ); } } else @@ -986,7 +1250,7 @@ wxDateTime wxDateTime::GetBeginDST(int year, Country country) if ( !dt.SetToWeekDay(Sun, 1, Apr, year) ) { // weird... - wxFAIL_MSG( wxT("no first Sunday in April?") ); + wxFAIL_MSG( _T("no first Sunday in April?") ); } } @@ -1033,10 +1297,13 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country) if ( !dt.SetToLastWeekDay(Sun, Oct, year) ) { // weirder and weirder... - wxFAIL_MSG( wxT("no last Sunday in October?") ); + wxFAIL_MSG( _T("no last Sunday in October?") ); } dt += wxTimeSpan::Hours(1); + + // disable DST tests because it could result in an infinite recursion! + dt.MakeGMT(true); } else switch ( country ) { @@ -1066,7 +1333,7 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country) if ( !dt.SetToWeekDay(Sun, 1, Nov, year) ) { // weird... - wxFAIL_MSG( wxT("no first Sunday in November?") ); + wxFAIL_MSG( _T("no first Sunday in November?") ); } } else @@ -1076,7 +1343,7 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country) if ( !dt.SetToLastWeekDay(Sun, Oct, year) ) { // weirder and weirder... - wxFAIL_MSG( wxT("no last Sunday in October?") ); + wxFAIL_MSG( _T("no last Sunday in October?") ); } } @@ -1101,7 +1368,7 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country) // return the current time with ms precision /* static */ wxDateTime wxDateTime::UNow() { - return wxDateTime(wxGetUTCTimeMillis()); + return wxDateTime(wxGetLocalTimeMillis()); } // the values in the tm structure contain the local time @@ -1117,49 +1384,22 @@ wxDateTime& wxDateTime::Set(const struct tm& tm) if ( tm2.tm_year == 70 && tm2.tm_mon == 0 && tm2.tm_mday == 1 ) { return Set((time_t)( - wxGetTimeZone() + + GetTimeZone() + tm2.tm_hour * MIN_PER_HOUR * SEC_PER_MIN + tm2.tm_min * SEC_PER_MIN + tm2.tm_sec)); } - wxFAIL_MSG( wxT("mktime() failed") ); + wxFAIL_MSG( _T("mktime() failed") ); *this = wxInvalidDateTime; return *this; } - - // mktime() only adjusts tm_wday, tm_yday and tm_isdst fields normally, if - // it changed anything else, it must have performed the DST adjustment. But - // the trouble with this is that different implementations do it - // differently, e.g. GNU libc moves the time forward if the specified time - // is invalid in the local time zone, while MSVC CRT moves it backwards - // which is especially pernicious as it can change the date if the DST - // starts at midnight, as it does in some time zones (see #15419), and this - // is completely unexpected for the code working with dates only. - // - // So standardize on moving the time forwards to have consistent behaviour - // under all platforms and to avoid the problem above. - if ( tm2.tm_hour != tm.tm_hour ) + else { - tm2 = tm; - tm2.tm_hour++; - if ( tm2.tm_hour == 24 ) - { - // This shouldn't normally happen as the DST never starts at 23:00 - // but if it does, we have a problem as we need to adjust the day - // as well. However we stop here, i.e. we don't adjust the month - // (or the year) because mktime() is supposed to take care of this - // for us. - tm2.tm_hour = 0; - tm2.tm_mday++; - } - - timet = mktime(&tm2); + return Set(timet); } - - return Set(timet); } wxDateTime& wxDateTime::Set(wxDateTime_t hour, @@ -1173,13 +1413,13 @@ wxDateTime& wxDateTime::Set(wxDateTime_t hour, second < 62 && minute < 60 && millisec < 1000, - wxT("Invalid time in wxDateTime::Set()") ); + _T("Invalid time in wxDateTime::Set()") ); // get the current date from system struct tm tmstruct; struct tm *tm = GetTmNow(&tmstruct); - wxDATETIME_CHECK( tm, wxT("wxLocaltime_r() failed") ); + wxDATETIME_CHECK( tm, _T("wxLocaltime_r() failed") ); // make a copy so it isn't clobbered by the call to mktime() below struct tm tm1(*tm); @@ -1213,12 +1453,12 @@ wxDateTime& wxDateTime::Set(wxDateTime_t day, second < 62 && minute < 60 && millisec < 1000, - wxT("Invalid time in wxDateTime::Set()") ); + _T("Invalid time in wxDateTime::Set()") ); ReplaceDefaultYearMonthWithCurrent(&year, &month); wxDATETIME_CHECK( (0 < day) && (day <= GetNumberOfDays(month, year)), - wxT("Invalid date in wxDateTime::Set()") ); + _T("Invalid date in wxDateTime::Set()") ); // the range of time_t type (inclusive) static const int yearMinInRange = 1970; @@ -1258,7 +1498,7 @@ wxDateTime& wxDateTime::Set(wxDateTime_t day, m_time *= SECONDS_PER_DAY * TIME_T_FACTOR; // JDN corresponds to GMT, we take localtime - Add(wxTimeSpan(hour, minute, second + wxGetTimeZone(), millisec)); + Add(wxTimeSpan(hour, minute, second + GetTimeZone(), millisec)); } return *this; @@ -1357,7 +1597,7 @@ unsigned long wxDateTime::GetAsDOS() const time_t ticks = GetTicks(); struct tm tmstruct; struct tm *tm = wxLocaltime_r(&ticks, &tmstruct); - wxCHECK_MSG( tm, ULONG_MAX, wxT("time can't be represented in DOS format") ); + wxCHECK_MSG( tm, ULONG_MAX, _T("time can't be represented in DOS format") ); long year = tm->tm_year; year -= 80; @@ -1389,7 +1629,7 @@ unsigned long wxDateTime::GetAsDOS() const wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); time_t time = GetTicks(); if ( time != (time_t)-1 ) @@ -1397,13 +1637,13 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const // use C RTL functions struct tm tmstruct; tm *tm; - if ( tz.GetOffset() == -wxGetTimeZone() ) + if ( tz.GetOffset() == -GetTimeZone() ) { // we are working with local time tm = wxLocaltime_r(&time, &tmstruct); // should never happen - wxCHECK_MSG( tm, Tm(), wxT("wxLocaltime_r() failed") ); + wxCHECK_MSG( tm, Tm(), _T("wxLocaltime_r() failed") ); } else { @@ -1418,7 +1658,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const tm = wxGmtime_r(&time, &tmstruct); // should never happen - wxCHECK_MSG( tm, Tm(), wxT("wxGmtime_r() failed") ); + wxCHECK_MSG( tm, Tm(), _T("wxGmtime_r() failed") ); } else { @@ -1461,7 +1701,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const // CREDIT: code below is by Scott E. Lee (but bugs are mine) - wxASSERT_MSG( jdn > -2, wxT("JDN out of range") ); + wxASSERT_MSG( jdn > -2, _T("JDN out of range") ); // calculate the century long temp = (jdn + JDN_OFFSET) * 4 - 1; @@ -1492,13 +1732,12 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const year -= 4800; // check that the algorithm gave us something reasonable - wxASSERT_MSG( (0 < month) && (month <= 12), wxT("invalid month") ); - wxASSERT_MSG( (1 <= day) && (day < 32), wxT("invalid day") ); + wxASSERT_MSG( (0 < month) && (month <= 12), _T("invalid month") ); + wxASSERT_MSG( (1 <= day) && (day < 32), _T("invalid day") ); // construct Tm from these values Tm tm; tm.year = (int)year; - tm.yday = (wxDateTime_t)(dayOfYear - 1); // use C convention for day number tm.mon = (Month)(month - 1); // algorithm yields 1 for January, not 0 tm.mday = (wxDateTime_t)day; tm.msec = (wxDateTime_t)(timeOnly % 1000); @@ -1519,7 +1758,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const wxDateTime& wxDateTime::SetYear(int year) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.year = year; @@ -1530,7 +1769,7 @@ wxDateTime& wxDateTime::SetYear(int year) wxDateTime& wxDateTime::SetMonth(Month month) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.mon = month; @@ -1541,7 +1780,7 @@ wxDateTime& wxDateTime::SetMonth(Month month) wxDateTime& wxDateTime::SetDay(wxDateTime_t mday) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.mday = mday; @@ -1552,7 +1791,7 @@ wxDateTime& wxDateTime::SetDay(wxDateTime_t mday) wxDateTime& wxDateTime::SetHour(wxDateTime_t hour) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.hour = hour; @@ -1563,7 +1802,7 @@ wxDateTime& wxDateTime::SetHour(wxDateTime_t hour) wxDateTime& wxDateTime::SetMinute(wxDateTime_t min) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.min = min; @@ -1574,7 +1813,7 @@ wxDateTime& wxDateTime::SetMinute(wxDateTime_t min) wxDateTime& wxDateTime::SetSecond(wxDateTime_t sec) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); Tm tm(GetTm()); tm.sec = sec; @@ -1585,7 +1824,7 @@ wxDateTime& wxDateTime::SetSecond(wxDateTime_t sec) wxDateTime& wxDateTime::SetMillisecond(wxDateTime_t millisecond) { - wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime") ); + wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); // we don't need to use GetTm() for this one m_time -= m_time % 1000l; @@ -1623,61 +1862,11 @@ wxDateTime& wxDateTime::Add(const wxDateSpan& diff) Set(tm); wxASSERT_MSG( IsSameTime(tm), - wxT("Add(wxDateSpan) shouldn't modify time") ); + _T("Add(wxDateSpan) shouldn't modify time") ); return *this; } -wxDateSpan wxDateTime::DiffAsDateSpan(const wxDateTime& dt) const -{ - wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime")); - - // If dt is larger than this, calculations below needs to be inverted. - int inv = 1; - if ( dt > *this ) - inv = -1; - - int y = GetYear() - dt.GetYear(); - int m = GetMonth() - dt.GetMonth(); - int d = GetDay() - dt.GetDay(); - - // If month diff is negative, dt is the year before, so decrease year - // and set month diff to its inverse, e.g. January - December should be 1, - // not -11. - if ( m * inv < 0 || (m == 0 && d * inv < 0)) - { - m += inv * MONTHS_IN_YEAR; - y -= inv; - } - - // Same logic for days as for months above. - if ( d * inv < 0 ) - { - // Use number of days in month from the month which end date we're - // crossing. That is month before this for positive diff, and this - // month for negative diff. - // If we're on january and using previous month, we get december - // previous year, but don't care, december has same amount of days - // every year. - wxDateTime::Month monthfordays = GetMonth(); - if (inv > 0 && monthfordays == wxDateTime::Jan) - monthfordays = wxDateTime::Dec; - else if (inv > 0) - monthfordays = static_cast(monthfordays - 1); - - d += inv * wxDateTime::GetNumberOfDays(monthfordays, GetYear()); - m -= inv; - } - - int w = d / DAYS_PER_WEEK; - - // Remove weeks from d, since wxDateSpan only keep days as the ones - // not in complete weeks - d -= w * DAYS_PER_WEEK; - - return wxDateSpan(y, m, w, d); -} - // ---------------------------------------------------------------------------- // Weekday and monthday stuff // ---------------------------------------------------------------------------- @@ -1693,7 +1882,7 @@ wxDateTime wxDateTime::SetToWeekOfYear(int year, wxDateTime_t numWeek, WeekDay wd) { wxASSERT_MSG( numWeek > 0, - wxT("invalid week number: weeks are counted from 1") ); + _T("invalid week number: weeks are counted from 1") ); // Jan 4 always lies in the 1st week of the year wxDateTime dt(4, Jan, year); @@ -1757,7 +1946,7 @@ wxDateTime& wxDateTime::SetToLastMonthDay(Month month, wxDateTime& wxDateTime::SetToWeekDayInSameWeek(WeekDay weekday, WeekFlags flags) { - wxDATETIME_CHECK( weekday != Inv_WeekDay, wxT("invalid weekday") ); + wxDATETIME_CHECK( weekday != Inv_WeekDay, _T("invalid weekday") ); int wdayDst = weekday, wdayThis = GetWeekDay(); @@ -1797,7 +1986,7 @@ wxDateTime& wxDateTime::SetToWeekDayInSameWeek(WeekDay weekday, WeekFlags flags) wxDateTime& wxDateTime::SetToNextWeekDay(WeekDay weekday) { - wxDATETIME_CHECK( weekday != Inv_WeekDay, wxT("invalid weekday") ); + wxDATETIME_CHECK( weekday != Inv_WeekDay, _T("invalid weekday") ); int diff; WeekDay wdayThis = GetWeekDay(); @@ -1821,7 +2010,7 @@ wxDateTime& wxDateTime::SetToNextWeekDay(WeekDay weekday) wxDateTime& wxDateTime::SetToPrevWeekDay(WeekDay weekday) { - wxDATETIME_CHECK( weekday != Inv_WeekDay, wxT("invalid weekday") ); + wxDATETIME_CHECK( weekday != Inv_WeekDay, _T("invalid weekday") ); int diff; WeekDay wdayThis = GetWeekDay(); @@ -1848,7 +2037,7 @@ bool wxDateTime::SetToWeekDay(WeekDay weekday, Month month, int year) { - wxCHECK_MSG( weekday != Inv_WeekDay, false, wxT("invalid weekday") ); + wxCHECK_MSG( weekday != Inv_WeekDay, false, _T("invalid weekday") ); // we don't check explicitly that -5 <= n <= 5 because we will return false // anyhow in such case - but may be should still give an assert for it? @@ -1947,6 +2136,7 @@ wxDateTime::GetWeekOfYear(wxDateTime::WeekFlags flags, const TimeZone& tz) const { // adjust the weekdays to non-US style. wdYearStart = ConvertWeekDayToMondayBase(wdYearStart); + wdTarget = ConvertWeekDayToMondayBase(wdTarget); // quoting from http://www.cl.cam.ac.uk/~mgk25/iso-time.html: // @@ -1962,24 +2152,22 @@ wxDateTime::GetWeekOfYear(wxDateTime::WeekFlags flags, const TimeZone& tz) const // // if Jan 1 is Thursday or less, it is in the first week of this year - int dayCountFix = wdYearStart < 4 ? 6 : -1; - - // count the number of week - week = (nDayInYear + wdYearStart + dayCountFix) / DAYS_PER_WEEK; - - // check if we happen to be at the last week of previous year: - if ( week == 0 ) + if ( wdYearStart < 4 ) { - week = wxDateTime(31, Dec, GetYear() - 1).GetWeekOfYear(); + // count the number of entire weeks between Jan 1 and this date + week = (nDayInYear + wdYearStart + 6 - wdTarget)/7; + + // be careful to check for overflow in the next year + if ( week == 53 && tm.mday - wdTarget > 28 ) + week = 1; } - else if ( week == 53 ) + else // Jan 1 is in the last week of the previous year { - int wdYearEnd = (wdYearStart + 364 + IsLeapYear(GetYear())) - % DAYS_PER_WEEK; - - // Week 53 only if last day of year is Thursday or later. - if ( wdYearEnd < 3 ) - week = 1; + // check if we happen to be at the last week of previous year: + if ( tm.mon == Jan && tm.mday < 8 - wdYearStart ) + week = wxDateTime(31, Dec, GetYear()-1).GetWeekOfYear(); + else + week = (nDayInYear + wdYearStart - 1 - wdTarget)/7; } } @@ -2012,7 +2200,7 @@ wxDateTime& wxDateTime::SetToYearDay(wxDateTime::wxDateTime_t yday) { int year = GetYear(); wxDATETIME_CHECK( (0 < yday) && (yday <= GetNumberOfDays(year)), - wxT("invalid year day") ); + _T("invalid year day") ); bool isLeap = IsLeapYear(year); for ( Month mon = Jan; mon < Inv_Month; wxNextMonth(mon) ) @@ -2053,7 +2241,7 @@ double wxDateTime::GetRataDie() const int wxDateTime::IsDST(wxDateTime::Country country) const { wxCHECK_MSG( country == Country_Default, -1, - wxT("country support not implemented") ); + _T("country support not implemented") ); // use the C RTL for the dates in the standard range time_t timet = GetTicks(); @@ -2062,7 +2250,7 @@ int wxDateTime::IsDST(wxDateTime::Country country) const struct tm tmstruct; tm *tm = wxLocaltime_r(&timet, &tmstruct); - wxCHECK_MSG( tm, -1, wxT("wxLocaltime_r() failed") ); + wxCHECK_MSG( tm, -1, _T("wxLocaltime_r() failed") ); return tm->tm_isdst; } @@ -2082,17 +2270,11 @@ int wxDateTime::IsDST(wxDateTime::Country country) const wxDateTime& wxDateTime::MakeTimezone(const TimeZone& tz, bool noDST) { - long secDiff = wxGetTimeZone() + tz.GetOffset(); + long secDiff = GetTimeZone() + tz.GetOffset(); - // We are converting from the local time, but local time zone does not - // include the DST offset (as it varies depending on the date), so we have - // to handle DST manually, unless a special flag inhibiting this was - // specified. - // - // Notice that we also shouldn't add the DST offset if we're already in the - // local time zone, as indicated by offset of 0, converting from local time - // to local time zone shouldn't change it, whether DST is in effect or not. - if ( !noDST && secDiff && (IsDST() == 1) ) + // we need to know whether DST is or not in effect for this date unless + // the test disabled by the caller + if ( !noDST && (IsDST() == 1) ) { // FIXME we assume that the DST is always shifted by 1 hour secDiff -= 3600; @@ -2103,10 +2285,11 @@ wxDateTime& wxDateTime::MakeTimezone(const TimeZone& tz, bool noDST) wxDateTime& wxDateTime::MakeFromTimezone(const TimeZone& tz, bool noDST) { - long secDiff = wxGetTimeZone() + tz.GetOffset(); + long secDiff = GetTimeZone() + tz.GetOffset(); - // See comment in MakeTimezone() above, the logic here is exactly the same. - if ( !noDST && secDiff && (IsDST() == 1) ) + // we need to know whether DST is or not in effect for this date unless + // the test disabled by the caller + if ( !noDST && (IsDST() == 1) ) { // FIXME we assume that the DST is always shifted by 1 hour secDiff -= 3600; @@ -2115,6 +2298,2155 @@ wxDateTime& wxDateTime::MakeFromTimezone(const TimeZone& tz, bool noDST) return Subtract(wxTimeSpan::Seconds(secDiff)); } +// ---------------------------------------------------------------------------- +// wxDateTime to/from text representations +// ---------------------------------------------------------------------------- + +wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const +{ + wxCHECK_MSG( format, wxEmptyString, _T("NULL format in wxDateTime::Format") ); + + time_t time = GetTicks(); + + // we have to use our own implementation if the date is out of range of + // strftime() or if we use non standard specificators +#ifdef HAVE_STRFTIME + if ( (time != (time_t)-1) && !wxStrstr(format, _T("%l")) ) + { + // use strftime() + struct tm tmstruct; + struct tm *tm; + if ( tz.GetOffset() == -GetTimeZone() ) + { + // we are working with local time + tm = wxLocaltime_r(&time, &tmstruct); + + // should never happen + wxCHECK_MSG( tm, wxEmptyString, _T("wxLocaltime_r() failed") ); + } + else + { + time += (int)tz.GetOffset(); + +#if defined(__VMS__) || defined(__WATCOMC__) // time is unsigned so avoid warning + int time2 = (int) time; + if ( time2 >= 0 ) +#else + if ( time >= 0 ) +#endif + { + tm = wxGmtime_r(&time, &tmstruct); + + // should never happen + wxCHECK_MSG( tm, wxEmptyString, _T("wxGmtime_r() failed") ); + } + else + { + tm = (struct tm *)NULL; + } + } + + if ( tm ) + { + return CallStrftime(format, tm); + } + } + //else: use generic code below +#endif // HAVE_STRFTIME + + // we only parse ANSI C format specifications here, no POSIX 2 + // complications, no GNU extensions but we do add support for a "%l" format + // specifier allowing to get the number of milliseconds + Tm tm = GetTm(tz); + + // used for calls to strftime() when we only deal with time + struct tm tmTimeOnly; + memset(&tmTimeOnly, 0, sizeof(tmTimeOnly)); + tmTimeOnly.tm_hour = tm.hour; + tmTimeOnly.tm_min = tm.min; + tmTimeOnly.tm_sec = tm.sec; + tmTimeOnly.tm_wday = 0; + tmTimeOnly.tm_yday = 0; + tmTimeOnly.tm_mday = 1; // any date will do, use 1976-01-01 + tmTimeOnly.tm_mon = 0; + tmTimeOnly.tm_year = 76; + tmTimeOnly.tm_isdst = 0; // no DST, we adjust for tz ourselves + + wxString tmp, res, fmt; + for ( const wxChar *p = format; *p; p++ ) + { + if ( *p != _T('%') ) + { + // copy as is + res += *p; + + continue; + } + + // set the default format + switch ( *++p ) + { + case _T('Y'): // year has 4 digits + fmt = _T("%04d"); + break; + + case _T('j'): // day of year has 3 digits + case _T('l'): // milliseconds have 3 digits + fmt = _T("%03d"); + break; + + case _T('w'): // week day as number has only one + fmt = _T("%d"); + break; + + default: + // it's either another valid format specifier in which case + // the format is "%02d" (for all the rest) or we have the + // field width preceding the format in which case it will + // override the default format anyhow + fmt = _T("%02d"); + } + + bool restart = true; + while ( restart ) + { + restart = false; + + // start of the format specification + switch ( *p ) + { + case _T('a'): // a weekday name + case _T('A'): + // second parameter should be true for abbreviated names + res += GetWeekDayName(tm.GetWeekDay(), + *p == _T('a') ? Name_Abbr : Name_Full); + break; + + case _T('b'): // a month name + case _T('B'): + res += GetMonthName(tm.mon, + *p == _T('b') ? Name_Abbr : Name_Full); + break; + + case _T('c'): // locale default date and time representation + case _T('x'): // locale default date representation +#ifdef HAVE_STRFTIME + // + // the problem: there is no way to know what do these format + // specifications correspond to for the current locale. + // + // the solution: use a hack and still use strftime(): first + // find the YEAR which is a year in the strftime() range (1970 + // - 2038) whose Jan 1 falls on the same week day as the Jan 1 + // of the real year. Then make a copy of the format and + // replace all occurrences of YEAR in it with some unique + // string not appearing anywhere else in it, then use + // strftime() to format the date in year YEAR and then replace + // YEAR back by the real year and the unique replacement + // string back with YEAR. Notice that "all occurrences of YEAR" + // means all occurrences of 4 digit as well as 2 digit form! + // + // the bugs: we assume that neither of %c nor %x contains any + // fields which may change between the YEAR and real year. For + // example, the week number (%U, %W) and the day number (%j) + // will change if one of these years is leap and the other one + // is not! + { + // find the YEAR: normally, for any year X, Jan 1 or the + // year X + 28 is the same weekday as Jan 1 of X (because + // the weekday advances by 1 for each normal X and by 2 + // for each leap X, hence by 5 every 4 years or by 35 + // which is 0 mod 7 every 28 years) but this rule breaks + // down if there are years between X and Y which are + // divisible by 4 but not leap (i.e. divisible by 100 but + // not 400), hence the correction. + + int yearReal = GetYear(tz); + int mod28 = yearReal % 28; + + // be careful to not go too far - we risk to leave the + // supported range + int year; + if ( mod28 < 10 ) + { + year = 1988 + mod28; // 1988 == 0 (mod 28) + } + else + { + year = 1970 + mod28 - 10; // 1970 == 10 (mod 28) + } + + int nCentury = year / 100, + nCenturyReal = yearReal / 100; + + // need to adjust for the years divisble by 400 which are + // not leap but are counted like leap ones if we just take + // the number of centuries in between for nLostWeekDays + int nLostWeekDays = (nCentury - nCenturyReal) - + (nCentury / 4 - nCenturyReal / 4); + + // we have to gain back the "lost" weekdays: note that the + // effect of this loop is to not do anything to + // nLostWeekDays (which we won't use any more), but to + // (indirectly) set the year correctly + while ( (nLostWeekDays % 7) != 0 ) + { + nLostWeekDays += year++ % 4 ? 1 : 2; + } + + // Keep year below 2000 so the 2digit year number + // can never match the month or day of the month + if (year>=2000) year-=28; + // at any rate, we couldn't go further than 1988 + 9 + 28! + wxASSERT_MSG( year < 2030, + _T("logic error in wxDateTime::Format") ); + + wxString strYear, strYear2; + strYear.Printf(_T("%d"), year); + strYear2.Printf(_T("%d"), year % 100); + + // find four strings not occurring in format (this is surely + // not the optimal way of doing it... improvements welcome!) + wxString fmt2 = format; + wxString replacement,replacement2,replacement3,replacement4; + for (int rnr=1; rnr<5 ; rnr++) + { + wxString r = (wxChar)-rnr; + while ( fmt2.Find(r) != wxNOT_FOUND ) + { + r << (wxChar)-rnr; + } + + switch (rnr) + { + case 1: replacement=r; break; + case 2: replacement2=r; break; + case 3: replacement3=r; break; + case 4: replacement4=r; break; + } + } + // replace all occurrences of year with it + bool wasReplaced = fmt2.Replace(strYear, replacement) > 0; + // evaluation order ensures we always attempt the replacement. + wasReplaced = (fmt2.Replace(strYear2, replacement2) > 0) || wasReplaced; + + // use strftime() to format the same date but in supported + // year + // + // NB: we assume that strftime() doesn't check for the + // date validity and will happily format the date + // corresponding to Feb 29 of a non leap year (which + // may happen if yearReal was leap and year is not) + struct tm tmAdjusted; + InitTm(tmAdjusted); + tmAdjusted.tm_hour = tm.hour; + tmAdjusted.tm_min = tm.min; + tmAdjusted.tm_sec = tm.sec; + tmAdjusted.tm_wday = tm.GetWeekDay(); + tmAdjusted.tm_yday = GetDayOfYear(); + tmAdjusted.tm_mday = tm.mday; + tmAdjusted.tm_mon = tm.mon; + tmAdjusted.tm_year = year - 1900; + tmAdjusted.tm_isdst = 0; // no DST, already adjusted + wxString str = CallStrftime(*p == _T('c') ? _T("%c") + : _T("%x"), + &tmAdjusted); + + // now replace the occurrence of 1999 with the real year + // we do this in two stages to stop the 2 digit year + // matching any substring of the 4 digit year. + // Any day,month hours and minutes components should be safe due + // to ensuring the range of the years. + wxString strYearReal, strYearReal2; + strYearReal.Printf(_T("%04d"), yearReal); + strYearReal2.Printf(_T("%02d"), yearReal % 100); + str.Replace(strYear, replacement3); + str.Replace(strYear2,replacement4); + str.Replace(replacement3, strYearReal); + str.Replace(replacement4, strYearReal2); + + // and replace back all occurrences of replacement string + if ( wasReplaced ) + { + str.Replace(replacement2, strYear2); + str.Replace(replacement, strYear); + } + + res += str; + } +#else // !HAVE_STRFTIME + // Use "%m/%d/%y %H:%M:%S" format instead + res += wxString::Format(wxT("%02d/%02d/%04d %02d:%02d:%02d"), + tm.mon+1,tm.mday, tm.year, tm.hour, tm.min, tm.sec); +#endif // HAVE_STRFTIME/!HAVE_STRFTIME + break; + + case _T('d'): // day of a month (01-31) + res += wxString::Format(fmt, tm.mday); + break; + + case _T('H'): // hour in 24h format (00-23) + res += wxString::Format(fmt, tm.hour); + break; + + case _T('I'): // hour in 12h format (01-12) + { + // 24h -> 12h, 0h -> 12h too + int hour12 = tm.hour > 12 ? tm.hour - 12 + : tm.hour ? tm.hour : 12; + res += wxString::Format(fmt, hour12); + } + break; + + case _T('j'): // day of the year + res += wxString::Format(fmt, GetDayOfYear(tz)); + break; + + case _T('l'): // milliseconds (NOT STANDARD) + res += wxString::Format(fmt, GetMillisecond(tz)); + break; + + case _T('m'): // month as a number (01-12) + res += wxString::Format(fmt, tm.mon + 1); + break; + + case _T('M'): // minute as a decimal number (00-59) + res += wxString::Format(fmt, tm.min); + break; + + case _T('p'): // AM or PM string +#ifdef HAVE_STRFTIME + res += CallStrftime(_T("%p"), &tmTimeOnly); +#else // !HAVE_STRFTIME + res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am"); +#endif // HAVE_STRFTIME/!HAVE_STRFTIME + break; + + case _T('S'): // second as a decimal number (00-61) + res += wxString::Format(fmt, tm.sec); + break; + + case _T('U'): // week number in the year (Sunday 1st week day) + res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz)); + break; + + case _T('W'): // week number in the year (Monday 1st week day) + res += wxString::Format(fmt, GetWeekOfYear(Monday_First, tz)); + break; + + case _T('w'): // weekday as a number (0-6), Sunday = 0 + res += wxString::Format(fmt, tm.GetWeekDay()); + break; + + // case _T('x'): -- handled with "%c" + + case _T('X'): // locale default time representation + // just use strftime() to format the time for us +#ifdef HAVE_STRFTIME + res += CallStrftime(_T("%X"), &tmTimeOnly); +#else // !HAVE_STRFTIME + res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec); +#endif // HAVE_STRFTIME/!HAVE_STRFTIME + break; + + case _T('y'): // year without century (00-99) + res += wxString::Format(fmt, tm.year % 100); + break; + + case _T('Y'): // year with century + res += wxString::Format(fmt, tm.year); + break; + + case _T('Z'): // timezone name +#ifdef HAVE_STRFTIME + res += CallStrftime(_T("%Z"), &tmTimeOnly); +#endif + break; + + default: + // is it the format width? + for( fmt.clear(); + *p == _T('-') || *p == _T('+') || + *p == _T(' ') || wxIsdigit(*p); + ++p ) + { + fmt += *p; + } + + if ( !fmt.empty() ) + { + // we've only got the flags and width so far in fmt + fmt.Prepend(_T('%')); + fmt.Append(_T('d')); + + restart = true; + + break; + } + + // no, it wasn't the width + wxFAIL_MSG(_T("unknown format specificator")); + + // fall through and just copy it nevertheless + + case _T('%'): // a percent sign + res += *p; + break; + + case 0: // the end of string + wxFAIL_MSG(_T("missing format at the end of string")); + + // just put the '%' which was the last char in format + res += _T('%'); + break; + } + } + } + + return res; +} + +// this function parses a string in (strict) RFC 822 format: see the section 5 +// of the RFC for the detailed description, but briefly it's something of the +// form "Sat, 18 Dec 1999 00:48:30 +0100" +// +// this function is "strict" by design - it must reject anything except true +// RFC822 time specs. +// +// TODO a great candidate for using reg exps +const wxChar *wxDateTime::ParseRfc822Date(const wxChar* date) +{ + wxCHECK_MSG( date, (wxChar *)NULL, _T("NULL pointer in wxDateTime::Parse") ); + + const wxChar *p = date; + const wxChar *comma = wxStrchr(p, _T(',')); + if ( comma ) + { + // the part before comma is the weekday + + // skip it for now - we don't use but might check that it really + // corresponds to the specfied date + p = comma + 1; + + if ( *p != _T(' ') ) + { + wxLogDebug(_T("no space after weekday in RFC822 time spec")); + + return (wxChar *)NULL; + } + + p++; // skip space + } + + // the following 1 or 2 digits are the day number + if ( !wxIsdigit(*p) ) + { + wxLogDebug(_T("day number expected in RFC822 time spec, none found")); + + return (wxChar *)NULL; + } + + wxDateTime_t day = (wxDateTime_t)(*p++ - _T('0')); + if ( wxIsdigit(*p) ) + { + day *= 10; + day = (wxDateTime_t)(day + (*p++ - _T('0'))); + } + + if ( *p++ != _T(' ') ) + { + return (wxChar *)NULL; + } + + // the following 3 letters specify the month + wxString monName(p, 3); + Month mon; + if ( monName == _T("Jan") ) + mon = Jan; + else if ( monName == _T("Feb") ) + mon = Feb; + else if ( monName == _T("Mar") ) + mon = Mar; + else if ( monName == _T("Apr") ) + mon = Apr; + else if ( monName == _T("May") ) + mon = May; + else if ( monName == _T("Jun") ) + mon = Jun; + else if ( monName == _T("Jul") ) + mon = Jul; + else if ( monName == _T("Aug") ) + mon = Aug; + else if ( monName == _T("Sep") ) + mon = Sep; + else if ( monName == _T("Oct") ) + mon = Oct; + else if ( monName == _T("Nov") ) + mon = Nov; + else if ( monName == _T("Dec") ) + mon = Dec; + else + { + wxLogDebug(_T("Invalid RFC 822 month name '%s'"), monName.c_str()); + + return (wxChar *)NULL; + } + + p += 3; + + if ( *p++ != _T(' ') ) + { + return (wxChar *)NULL; + } + + // next is the year + if ( !wxIsdigit(*p) ) + { + // no year? + return (wxChar *)NULL; + } + + int year = *p++ - _T('0'); + + if ( !wxIsdigit(*p) ) + { + // should have at least 2 digits in the year + return (wxChar *)NULL; + } + + year *= 10; + year += *p++ - _T('0'); + + // is it a 2 digit year (as per original RFC 822) or a 4 digit one? + if ( wxIsdigit(*p) ) + { + year *= 10; + year += *p++ - _T('0'); + + if ( !wxIsdigit(*p) ) + { + // no 3 digit years please + return (wxChar *)NULL; + } + + year *= 10; + year += *p++ - _T('0'); + } + + if ( *p++ != _T(' ') ) + { + return (wxChar *)NULL; + } + + // time is in the format hh:mm:ss and seconds are optional + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + wxDateTime_t hour = (wxDateTime_t)(*p++ - _T('0')); + + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + hour *= 10; + hour = (wxDateTime_t)(hour + (*p++ - _T('0'))); + + if ( *p++ != _T(':') ) + { + return (wxChar *)NULL; + } + + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + wxDateTime_t min = (wxDateTime_t)(*p++ - _T('0')); + + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + min *= 10; + min = (wxDateTime_t)(min + *p++ - _T('0')); + + wxDateTime_t sec = 0; + if ( *p == _T(':') ) + { + p++; + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + sec = (wxDateTime_t)(*p++ - _T('0')); + + if ( !wxIsdigit(*p) ) + { + return (wxChar *)NULL; + } + + sec *= 10; + sec = (wxDateTime_t)(sec + *p++ - _T('0')); + } + + if ( *p++ != _T(' ') ) + { + return (wxChar *)NULL; + } + + // and now the interesting part: the timezone + int offset wxDUMMY_INITIALIZE(0); + if ( *p == _T('-') || *p == _T('+') ) + { + // the explicit offset given: it has the form of hhmm + bool plus = *p++ == _T('+'); + + if ( !wxIsdigit(*p) || !wxIsdigit(*(p + 1)) ) + { + return (wxChar *)NULL; + } + + // hours + offset = MIN_PER_HOUR*(10*(*p - _T('0')) + (*(p + 1) - _T('0'))); + + p += 2; + + if ( !wxIsdigit(*p) || !wxIsdigit(*(p + 1)) ) + { + return (wxChar *)NULL; + } + + // minutes + offset += 10*(*p - _T('0')) + (*(p + 1) - _T('0')); + + if ( !plus ) + { + offset = -offset; + } + + p += 2; + } + else + { + // the symbolic timezone given: may be either military timezone or one + // of standard abbreviations + if ( !*(p + 1) ) + { + // military: Z = UTC, J unused, A = -1, ..., Y = +12 + static const int offsets[26] = + { + //A B C D E F G H I J K L M + -1, -2, -3, -4, -5, -6, -7, -8, -9, 0, -10, -11, -12, + //N O P R Q S T U V W Z Y Z + +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, 0 + }; + + if ( *p < _T('A') || *p > _T('Z') || *p == _T('J') ) + { + wxLogDebug(_T("Invalid militaty timezone '%c'"), *p); + + return (wxChar *)NULL; + } + + offset = offsets[*p++ - _T('A')]; + } + else + { + // abbreviation + wxString tz = p; + if ( tz == _T("UT") || tz == _T("UTC") || tz == _T("GMT") ) + offset = 0; + else if ( tz == _T("AST") ) + offset = AST - GMT0; + else if ( tz == _T("ADT") ) + offset = ADT - GMT0; + else if ( tz == _T("EST") ) + offset = EST - GMT0; + else if ( tz == _T("EDT") ) + offset = EDT - GMT0; + else if ( tz == _T("CST") ) + offset = CST - GMT0; + else if ( tz == _T("CDT") ) + offset = CDT - GMT0; + else if ( tz == _T("MST") ) + offset = MST - GMT0; + else if ( tz == _T("MDT") ) + offset = MDT - GMT0; + else if ( tz == _T("PST") ) + offset = PST - GMT0; + else if ( tz == _T("PDT") ) + offset = PDT - GMT0; + else + { + wxLogDebug(_T("Unknown RFC 822 timezone '%s'"), p); + + return (wxChar *)NULL; + } + + p += tz.length(); + } + + // make it minutes + offset *= MIN_PER_HOUR; + } + + // the spec was correct, construct the date from the values we found + Set(day, mon, year, hour, min, sec); + MakeFromTimezone(TimeZone::Make(offset*SEC_PER_MIN)); + + return p; +} + +#ifdef __WINDOWS__ + +// returns the string containing strftime() format used for short dates in the +// current locale or an empty string +static wxString GetLocaleDateFormat() +{ + wxString fmtWX; + + // there is no setlocale() under Windows CE, so just always query the + // system there +#ifndef __WXWINCE__ + if ( strcmp(setlocale(LC_ALL, NULL), "C") != 0 ) +#endif + { + // The locale was programatically set to non-C. We assume that this was + // done using wxLocale, in which case thread's current locale is also + // set to correct LCID value and we can use GetLocaleInfo to determine + // the correct formatting string: +#ifdef __WXWINCE__ + LCID lcid = LOCALE_USER_DEFAULT; +#else + LCID lcid = GetThreadLocale(); +#endif + // according to MSDN 80 chars is max allowed for short date format + wxChar fmt[81]; + if ( ::GetLocaleInfo(lcid, LOCALE_SSHORTDATE, fmt, WXSIZEOF(fmt)) ) + { + wxChar chLast = _T('\0'); + size_t lastCount = 0; + for ( const wxChar *p = fmt; /* NUL handled inside */; p++ ) + { + if ( *p == chLast ) + { + lastCount++; + continue; + } + + switch ( *p ) + { + // these characters come in groups, start counting them + case _T('d'): + case _T('M'): + case _T('y'): + case _T('g'): + chLast = *p; + lastCount = 1; + break; + + default: + // first deal with any special characters we have had + if ( lastCount ) + { + switch ( chLast ) + { + case _T('d'): + switch ( lastCount ) + { + case 1: // d + case 2: // dd + // these two are the same as we + // don't distinguish between 1 and + // 2 digits for days + fmtWX += _T("%d"); + break; + + case 3: // ddd + fmtWX += _T("%a"); + break; + + case 4: // dddd + fmtWX += _T("%A"); + break; + + default: + wxFAIL_MSG( _T("too many 'd's") ); + } + break; + + case _T('M'): + switch ( lastCount ) + { + case 1: // M + case 2: // MM + // as for 'd' and 'dd' above + fmtWX += _T("%m"); + break; + + case 3: + fmtWX += _T("%b"); + break; + + case 4: + fmtWX += _T("%B"); + break; + + default: + wxFAIL_MSG( _T("too many 'M's") ); + } + break; + + case _T('y'): + switch ( lastCount ) + { + case 1: // y + case 2: // yy + fmtWX += _T("%y"); + break; + + case 4: // yyyy + fmtWX += _T("%Y"); + break; + + default: + wxFAIL_MSG( _T("wrong number of 'y's") ); + } + break; + + case _T('g'): + // strftime() doesn't have era string, + // ignore this format + wxASSERT_MSG( lastCount <= 2, + _T("too many 'g's") ); + break; + + default: + wxFAIL_MSG( _T("unreachable") ); + } + + chLast = _T('\0'); + lastCount = 0; + } + + // not a special character so must be just a separator, + // treat as is + if ( *p != _T('\0') ) + { + if ( *p == _T('%') ) + { + // this one needs to be escaped + fmtWX += _T('%'); + } + + fmtWX += *p; + } + } + + if ( *p == _T('\0') ) + break; + } + } + //else: GetLocaleInfo() failed, leave fmtDate value unchanged and + // try our luck with the default formats + } + //else: default C locale, default formats should work + + return fmtWX; +} + +#endif // __WINDOWS__ + +const wxChar *wxDateTime::ParseFormat(const wxChar *date, + const wxChar *format, + const wxDateTime& dateDef) +{ + wxCHECK_MSG( date && format, (wxChar *)NULL, + _T("NULL pointer in wxDateTime::ParseFormat()") ); + + wxString str; + unsigned long num; + + // what fields have we found? + bool haveWDay = false, + haveYDay = false, + haveDay = false, + haveMon = false, + haveYear = false, + haveHour = false, + haveMin = false, + haveSec = false; + + bool hourIsIn12hFormat = false, // or in 24h one? + isPM = false; // AM by default + + // and the value of the items we have (init them to get rid of warnings) + wxDateTime_t sec = 0, + min = 0, + hour = 0; + WeekDay wday = Inv_WeekDay; + wxDateTime_t yday = 0, + mday = 0; + wxDateTime::Month mon = Inv_Month; + int year = 0; + + const wxChar *input = date; + for ( const wxChar *fmt = format; *fmt; fmt++ ) + { + if ( *fmt != _T('%') ) + { + if ( wxIsspace(*fmt) ) + { + // a white space in the format string matches 0 or more white + // spaces in the input + while ( wxIsspace(*input) ) + { + input++; + } + } + else // !space + { + // any other character (not whitespace, not '%') must be + // matched by itself in the input + if ( *input++ != *fmt ) + { + // no match + return (wxChar *)NULL; + } + } + + // done with this format char + continue; + } + + // start of a format specification + + // parse the optional width + size_t width = 0; + while ( wxIsdigit(*++fmt) ) + { + width *= 10; + width += *fmt - _T('0'); + } + + // the default widths for the various fields + if ( !width ) + { + switch ( *fmt ) + { + case _T('Y'): // year has 4 digits + width = 4; + break; + + case _T('j'): // day of year has 3 digits + case _T('l'): // milliseconds have 3 digits + width = 3; + break; + + case _T('w'): // week day as number has only one + width = 1; + break; + + default: + // default for all other fields + width = 2; + } + } + + // then the format itself + switch ( *fmt ) + { + case _T('a'): // a weekday name + case _T('A'): + { + int flag = *fmt == _T('a') ? Name_Abbr : Name_Full; + wday = GetWeekDayFromName(GetAlphaToken(input), flag); + if ( wday == Inv_WeekDay ) + { + // no match + return (wxChar *)NULL; + } + } + haveWDay = true; + break; + + case _T('b'): // a month name + case _T('B'): + { + int flag = *fmt == _T('b') ? Name_Abbr : Name_Full; + mon = GetMonthFromName(GetAlphaToken(input), flag); + if ( mon == Inv_Month ) + { + // no match + return (wxChar *)NULL; + } + } + haveMon = true; + break; + + case _T('c'): // locale default date and time representation + { + wxDateTime dt; + + // this is the format which corresponds to ctime() output + // and strptime("%c") should parse it, so try it first + static const wxChar *fmtCtime = _T("%a %b %d %H:%M:%S %Y"); + + const wxChar *result = dt.ParseFormat(input, fmtCtime); + if ( !result ) + { + result = dt.ParseFormat(input, _T("%x %X")); + } + + if ( !result ) + { + result = dt.ParseFormat(input, _T("%X %x")); + } + + if ( !result ) + { + // we've tried everything and still no match + return (wxChar *)NULL; + } + + Tm tm = dt.GetTm(); + + haveDay = haveMon = haveYear = + haveHour = haveMin = haveSec = true; + + hour = tm.hour; + min = tm.min; + sec = tm.sec; + + year = tm.year; + mon = tm.mon; + mday = tm.mday; + + input = result; + } + break; + + case _T('d'): // day of a month (01-31) + if ( !GetNumericToken(width, input, &num) || + (num > 31) || (num < 1) ) + { + // no match + return (wxChar *)NULL; + } + + // we can't check whether the day range is correct yet, will + // do it later - assume ok for now + haveDay = true; + mday = (wxDateTime_t)num; + break; + + case _T('H'): // hour in 24h format (00-23) + if ( !GetNumericToken(width, input, &num) || (num > 23) ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = true; + hour = (wxDateTime_t)num; + break; + + case _T('I'): // hour in 12h format (01-12) + if ( !GetNumericToken(width, input, &num) || !num || (num > 12) ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = true; + hourIsIn12hFormat = true; + hour = (wxDateTime_t)(num % 12); // 12 should be 0 + break; + + case _T('j'): // day of the year + if ( !GetNumericToken(width, input, &num) || !num || (num > 366) ) + { + // no match + return (wxChar *)NULL; + } + + haveYDay = true; + yday = (wxDateTime_t)num; + break; + + case _T('m'): // month as a number (01-12) + if ( !GetNumericToken(width, input, &num) || !num || (num > 12) ) + { + // no match + return (wxChar *)NULL; + } + + haveMon = true; + mon = (Month)(num - 1); + break; + + case _T('M'): // minute as a decimal number (00-59) + if ( !GetNumericToken(width, input, &num) || (num > 59) ) + { + // no match + return (wxChar *)NULL; + } + + haveMin = true; + min = (wxDateTime_t)num; + break; + + case _T('p'): // AM or PM string + { + wxString am, pm, token = GetAlphaToken(input); + + GetAmPmStrings(&am, &pm); + if (am.empty() && pm.empty()) + return (wxChar *)NULL; // no am/pm strings defined + if ( token.CmpNoCase(pm) == 0 ) + { + isPM = true; + } + else if ( token.CmpNoCase(am) != 0 ) + { + // no match + return (wxChar *)NULL; + } + } + break; + + case _T('r'): // time as %I:%M:%S %p + { + wxDateTime dt; + input = dt.ParseFormat(input, _T("%I:%M:%S %p")); + if ( !input ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = haveMin = haveSec = true; + + Tm tm = dt.GetTm(); + hour = tm.hour; + min = tm.min; + sec = tm.sec; + } + break; + + case _T('R'): // time as %H:%M + { + wxDateTime dt; + input = dt.ParseFormat(input, _T("%H:%M")); + if ( !input ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = haveMin = true; + + Tm tm = dt.GetTm(); + hour = tm.hour; + min = tm.min; + } + break; + + case _T('S'): // second as a decimal number (00-61) + if ( !GetNumericToken(width, input, &num) || (num > 61) ) + { + // no match + return (wxChar *)NULL; + } + + haveSec = true; + sec = (wxDateTime_t)num; + break; + + case _T('T'): // time as %H:%M:%S + { + wxDateTime dt; + input = dt.ParseFormat(input, _T("%H:%M:%S")); + if ( !input ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = haveMin = haveSec = true; + + Tm tm = dt.GetTm(); + hour = tm.hour; + min = tm.min; + sec = tm.sec; + } + break; + + case _T('w'): // weekday as a number (0-6), Sunday = 0 + if ( !GetNumericToken(width, input, &num) || (wday > 6) ) + { + // no match + return (wxChar *)NULL; + } + + haveWDay = true; + wday = (WeekDay)num; + break; + + case _T('x'): // locale default date representation +#ifdef HAVE_STRPTIME + // try using strptime() -- it may fail even if the input is + // correct but the date is out of range, so we will fall back + // to our generic code anyhow + { + struct tm tm; + + const wxChar *result = CallStrptime(input, "%x", &tm); + if ( result ) + { + input = result; + + haveDay = haveMon = haveYear = true; + + year = 1900 + tm.tm_year; + mon = (Month)tm.tm_mon; + mday = tm.tm_mday; + + break; + } + } +#endif // HAVE_STRPTIME + + { + wxDateTime dt; + wxString fmtDate, + fmtDateAlt; + +#ifdef __WINDOWS__ + // The above doesn't work for all locales, try to query + // Windows for the right way of formatting the date: + fmtDate = GetLocaleDateFormat(); + if ( fmtDate.empty() ) +#endif + { + if ( IsWestEuropeanCountry(GetCountry()) || + GetCountry() == Russia ) + { + fmtDate = _T("%d/%m/%y"); + fmtDateAlt = _T("%m/%d/%y"); + } + else // assume USA + { + fmtDate = _T("%m/%d/%y"); + fmtDateAlt = _T("%d/%m/%y"); + } + } + + const wxChar *result = dt.ParseFormat(input, fmtDate); + + if ( !result && !fmtDateAlt.empty() ) + { + // ok, be nice and try another one + result = dt.ParseFormat(input, fmtDateAlt); + } + + if ( !result ) + { + // bad luck + return (wxChar *)NULL; + } + + Tm tm = dt.GetTm(); + + haveDay = haveMon = haveYear = true; + + year = tm.year; + mon = tm.mon; + mday = tm.mday; + + input = result; + } + + break; + + case _T('X'): // locale default time representation +#ifdef HAVE_STRPTIME + { + // use strptime() to do it for us (FIXME !Unicode friendly) + struct tm tm; + input = CallStrptime(input, "%X", &tm); + if ( !input ) + { + return (wxChar *)NULL; + } + + haveHour = haveMin = haveSec = true; + + hour = tm.tm_hour; + min = tm.tm_min; + sec = tm.tm_sec; + } +#else // !HAVE_STRPTIME + // TODO under Win32 we can query the LOCALE_ITIME system + // setting which says whether the default time format is + // 24 or 12 hour + { + // try to parse what follows as "%H:%M:%S" and, if this + // fails, as "%I:%M:%S %p" - this should catch the most + // common cases + wxDateTime dt; + + const wxChar *result = dt.ParseFormat(input, _T("%T")); + if ( !result ) + { + result = dt.ParseFormat(input, _T("%r")); + } + + if ( !result ) + { + // no match + return (wxChar *)NULL; + } + + haveHour = haveMin = haveSec = true; + + Tm tm = dt.GetTm(); + hour = tm.hour; + min = tm.min; + sec = tm.sec; + + input = result; + } +#endif // HAVE_STRPTIME/!HAVE_STRPTIME + break; + + case _T('y'): // year without century (00-99) + if ( !GetNumericToken(width, input, &num) || (num > 99) ) + { + // no match + return (wxChar *)NULL; + } + + haveYear = true; + + // TODO should have an option for roll over date instead of + // hard coding it here + year = (num > 30 ? 1900 : 2000) + (wxDateTime_t)num; + break; + + case _T('Y'): // year with century + if ( !GetNumericToken(width, input, &num) ) + { + // no match + return (wxChar *)NULL; + } + + haveYear = true; + year = (wxDateTime_t)num; + break; + + case _T('Z'): // timezone name + wxFAIL_MSG(_T("TODO")); + break; + + case _T('%'): // a percent sign + if ( *input++ != _T('%') ) + { + // no match + return (wxChar *)NULL; + } + break; + + case 0: // the end of string + wxFAIL_MSG(_T("unexpected format end")); + + // fall through + + default: // not a known format spec + return (wxChar *)NULL; + } + } + + // format matched, try to construct a date from what we have now + Tm tmDef; + if ( dateDef.IsValid() ) + { + // take this date as default + tmDef = dateDef.GetTm(); + } + else if ( IsValid() ) + { + // if this date is valid, don't change it + tmDef = GetTm(); + } + else + { + // no default and this date is invalid - fall back to Today() + tmDef = Today().GetTm(); + } + + Tm tm = tmDef; + + // set the date + if ( haveYear ) + { + tm.year = year; + } + + // TODO we don't check here that the values are consistent, if both year + // day and month/day were found, we just ignore the year day and we + // also always ignore the week day + if ( haveMon && haveDay ) + { + if ( mday > GetNumOfDaysInMonth(tm.year, mon) ) + { + wxLogDebug(_T("bad month day in wxDateTime::ParseFormat")); + + return (wxChar *)NULL; + } + + tm.mon = mon; + tm.mday = mday; + } + else if ( haveYDay ) + { + if ( yday > GetNumberOfDays(tm.year) ) + { + wxLogDebug(_T("bad year day in wxDateTime::ParseFormat")); + + return (wxChar *)NULL; + } + + Tm tm2 = wxDateTime(1, Jan, tm.year).SetToYearDay(yday).GetTm(); + + tm.mon = tm2.mon; + tm.mday = tm2.mday; + } + + // deal with AM/PM + if ( haveHour && hourIsIn12hFormat && isPM ) + { + // translate to 24hour format + hour += 12; + } + //else: either already in 24h format or no translation needed + + // set the time + if ( haveHour ) + { + tm.hour = hour; + } + + if ( haveMin ) + { + tm.min = min; + } + + if ( haveSec ) + { + tm.sec = sec; + } + + Set(tm); + + // finally check that the week day is consistent -- if we had it + if ( haveWDay && GetWeekDay() != wday ) + { + wxLogDebug(_T("inconsistsnet week day in wxDateTime::ParseFormat()")); + + return NULL; + } + + return input; +} + +const wxChar *wxDateTime::ParseDateTime(const wxChar *date) +{ + wxCHECK_MSG( date, (wxChar *)NULL, _T("NULL pointer in wxDateTime::Parse") ); + + // Set to current day and hour, so strings like '14:00' becomes today at + // 14, not some other random date + wxDateTime dtDate = wxDateTime::Today(); + wxDateTime dtTime = wxDateTime::Today(); + + const wxChar* pchTime; + + // Try to parse the beginning of the string as a date + const wxChar* pchDate = dtDate.ParseDate(date); + + // We got a date in the beginning, see if there is a time specified after the date + if ( pchDate ) + { + // Skip spaces, as the ParseTime() function fails on spaces + while ( wxIsspace(*pchDate) ) + pchDate++; + + pchTime = dtTime.ParseTime(pchDate); + } + else // no date in the beginning + { + // check and see if we have a time followed by a date + pchTime = dtTime.ParseTime(date); + if ( pchTime ) + { + while ( wxIsspace(*pchTime) ) + pchTime++; + + pchDate = dtDate.ParseDate(pchTime); + } + } + + // If we have a date specified, set our own data to the same date + if ( !pchDate || !pchTime ) + return NULL; + + Set(dtDate.GetDay(), dtDate.GetMonth(), dtDate.GetYear(), + dtTime.GetHour(), dtTime.GetMinute(), dtTime.GetSecond(), + dtTime.GetMillisecond()); + + // Return endpoint of scan + return pchDate > pchTime ? pchDate : pchTime; +} + +const wxChar *wxDateTime::ParseDate(const wxChar *date) +{ + // this is a simplified version of ParseDateTime() which understands only + // "today" (for wxDate compatibility) and digits only otherwise (and not + // all esoteric constructions ParseDateTime() knows about) + + wxCHECK_MSG( date, (wxChar *)NULL, _T("NULL pointer in wxDateTime::Parse") ); + + const wxChar *p = date; + while ( wxIsspace(*p) ) + p++; + + // some special cases + static struct + { + const wxChar *str; + int dayDiffFromToday; + } literalDates[] = + { + { wxTRANSLATE("today"), 0 }, + { wxTRANSLATE("yesterday"), -1 }, + { wxTRANSLATE("tomorrow"), 1 }, + }; + + for ( size_t n = 0; n < WXSIZEOF(literalDates); n++ ) + { + const wxString dateStr = wxGetTranslation(literalDates[n].str); + size_t len = dateStr.length(); + if ( wxStrlen(p) >= len ) + { + wxString str(p, len); + if ( str.CmpNoCase(dateStr) == 0 ) + { + // nothing can follow this, so stop here + p += len; + + int dayDiffFromToday = literalDates[n].dayDiffFromToday; + *this = Today(); + if ( dayDiffFromToday ) + { + *this += wxDateSpan::Days(dayDiffFromToday); + } + + return p; + } + } + } + + // We try to guess what we have here: for each new (numeric) token, we + // determine if it can be a month, day or a year. Of course, there is an + // ambiguity as some numbers may be days as well as months, so we also + // have the ability to back track. + + // what do we have? + bool haveDay = false, // the months day? + haveWDay = false, // the day of week? + haveMon = false, // the month? + haveYear = false; // the year? + + // and the value of the items we have (init them to get rid of warnings) + WeekDay wday = Inv_WeekDay; + wxDateTime_t day = 0; + wxDateTime::Month mon = Inv_Month; + int year = 0; + + // tokenize the string + size_t nPosCur = 0; + static const wxChar *dateDelimiters = _T(".,/-\t\r\n "); + wxStringTokenizer tok(p, dateDelimiters); + while ( tok.HasMoreTokens() ) + { + wxString token = tok.GetNextToken(); + if ( !token ) + continue; + + // is it a number? + unsigned long val; + if ( token.ToULong(&val) ) + { + // guess what this number is + + bool isDay = false, + isMonth = false, + isYear = false; + + if ( !haveMon && val > 0 && val <= 12 ) + { + // assume it is month + isMonth = true; + } + else // not the month + { + if ( haveDay ) + { + // this can only be the year + isYear = true; + } + else // may be either day or year + { + // use a leap year if we don't have the year yet to allow + // dates like 2/29/1976 which would be rejected otherwise + wxDateTime_t max_days = (wxDateTime_t)( + haveMon + ? GetNumOfDaysInMonth(haveYear ? year : 1976, mon) + : 31 + ); + + // can it be day? + if ( (val == 0) || (val > (unsigned long)max_days) ) + { + // no + isYear = true; + } + else // yes, suppose it's the day + { + isDay = true; + } + } + } + + if ( isYear ) + { + if ( haveYear ) + break; + + haveYear = true; + + year = (wxDateTime_t)val; + } + else if ( isDay ) + { + if ( haveDay ) + break; + + haveDay = true; + + day = (wxDateTime_t)val; + } + else if ( isMonth ) + { + haveMon = true; + + mon = (Month)(val - 1); + } + } + else // not a number + { + // be careful not to overwrite the current mon value + Month mon2 = GetMonthFromName(token, Name_Full | Name_Abbr); + if ( mon2 != Inv_Month ) + { + // it's a month + if ( haveMon ) + { + // but we already have a month - maybe we guessed wrong? + if ( !haveDay ) + { + // no need to check in month range as always < 12, but + // the days are counted from 1 unlike the months + day = (wxDateTime_t)(mon + 1); + haveDay = true; + } + else + { + // could possible be the year (doesn't the year come + // before the month in the japanese format?) (FIXME) + break; + } + } + + mon = mon2; + + haveMon = true; + } + else // not a valid month name + { + WeekDay wday2 = GetWeekDayFromName(token, Name_Full | Name_Abbr); + if ( wday2 != Inv_WeekDay ) + { + // a week day + if ( haveWDay ) + { + break; + } + + wday = wday2; + + haveWDay = true; + } + else // not a valid weekday name + { + // try the ordinals + static const wxChar *ordinals[] = + { + wxTRANSLATE("first"), + wxTRANSLATE("second"), + wxTRANSLATE("third"), + wxTRANSLATE("fourth"), + wxTRANSLATE("fifth"), + wxTRANSLATE("sixth"), + wxTRANSLATE("seventh"), + wxTRANSLATE("eighth"), + wxTRANSLATE("ninth"), + wxTRANSLATE("tenth"), + wxTRANSLATE("eleventh"), + wxTRANSLATE("twelfth"), + wxTRANSLATE("thirteenth"), + wxTRANSLATE("fourteenth"), + wxTRANSLATE("fifteenth"), + wxTRANSLATE("sixteenth"), + wxTRANSLATE("seventeenth"), + wxTRANSLATE("eighteenth"), + wxTRANSLATE("nineteenth"), + wxTRANSLATE("twentieth"), + // that's enough - otherwise we'd have problems with + // composite (or not) ordinals + }; + + size_t n; + for ( n = 0; n < WXSIZEOF(ordinals); n++ ) + { + if ( token.CmpNoCase(ordinals[n]) == 0 ) + { + break; + } + } + + if ( n == WXSIZEOF(ordinals) ) + { + // stop here - something unknown + break; + } + + // it's a day + if ( haveDay ) + { + // don't try anything here (as in case of numeric day + // above) - the symbolic day spec should always + // precede the month/year + break; + } + + haveDay = true; + + day = (wxDateTime_t)(n + 1); + } + } + } + + nPosCur = tok.GetPosition(); + } + + // either no more tokens or the scan was stopped by something we couldn't + // parse - in any case, see if we can construct a date from what we have + if ( !haveDay && !haveWDay ) + { + wxLogDebug(_T("ParseDate: no day, no weekday hence no date.")); + + return NULL; + } + + if ( haveWDay && (haveMon || haveYear || haveDay) && + !(haveDay && haveMon && haveYear) ) + { + // without adjectives (which we don't support here) the week day only + // makes sense completely separately or with the full date + // specification (what would "Wed 1999" mean?) + return NULL; + } + + if ( !haveWDay && haveYear && !(haveDay && haveMon) ) + { + // may be we have month and day instead of day and year? + if ( haveDay && !haveMon ) + { + if ( day <= 12 ) + { + // exchange day and month + mon = (wxDateTime::Month)(day - 1); + + // we're in the current year then + if ( (year > 0) && (year <= (int)GetNumOfDaysInMonth(Inv_Year, mon)) ) + { + day = (wxDateTime_t)year; + + haveMon = true; + haveYear = false; + } + //else: no, can't exchange, leave haveMon == false + } + } + + if ( !haveMon ) + { + // if we give the year, month and day must be given too + wxLogDebug(_T("ParseDate: day and month should be specified if year is.")); + + return NULL; + } + } + + if ( !haveMon ) + { + mon = GetCurrentMonth(); + } + + if ( !haveYear ) + { + year = GetCurrentYear(); + } + + if ( haveDay ) + { + // normally we check the day above but the check is optimistic in case + // we find the day before its month/year so we have to redo it now + if ( day > GetNumOfDaysInMonth(year, mon) ) + return NULL; + + Set(day, mon, year); + + if ( haveWDay ) + { + // check that it is really the same + if ( GetWeekDay() != wday ) + { + // inconsistency detected + wxLogDebug(_T("ParseDate: inconsistent day/weekday.")); + + return (wxChar *)NULL; + } + } + } + else // haveWDay + { + *this = Today(); + + SetToWeekDayInSameWeek(wday); + } + + // return the pointer to the first unparsed char + p += nPosCur; + if ( nPosCur && wxStrchr(dateDelimiters, *(p - 1)) ) + { + // if we couldn't parse the token after the delimiter, put back the + // delimiter as well + p--; + } + + return p; +} + +const wxChar *wxDateTime::ParseTime(const wxChar *time) +{ + wxCHECK_MSG( time, (wxChar *)NULL, _T("NULL pointer in wxDateTime::Parse") ); + + // first try some extra things + static const struct + { + const wxChar *name; + wxDateTime_t hour; + } stdTimes[] = + { + { wxTRANSLATE("noon"), 12 }, + { wxTRANSLATE("midnight"), 00 }, + // anything else? + }; + + for ( size_t n = 0; n < WXSIZEOF(stdTimes); n++ ) + { + wxString timeString = wxGetTranslation(stdTimes[n].name); + size_t len = timeString.length(); + if ( timeString.CmpNoCase(wxString(time, len)) == 0 ) + { + // casts required by DigitalMars + Set(stdTimes[n].hour, wxDateTime_t(0), wxDateTime_t(0)); + + return time + len; + } + } + + // try all time formats we may think about in the order from longest to + // shortest + + // 12hour with AM/PM? + const wxChar *result = ParseFormat(time, _T("%I:%M:%S %p")); + + if ( !result ) + { + // normally, it's the same, but why not try it? + result = ParseFormat(time, _T("%H:%M:%S")); + } + + if ( !result ) + { + // 12hour with AM/PM but without seconds? + result = ParseFormat(time, _T("%I:%M %p")); + } + + if ( !result ) + { + // without seconds? + result = ParseFormat(time, _T("%H:%M")); + } + + if ( !result ) + { + // just the hour and AM/PM? + result = ParseFormat(time, _T("%I %p")); + } + + if ( !result ) + { + // just the hour? + result = ParseFormat(time, _T("%H")); + } + + if ( !result ) + { + // parse the standard format: normally it is one of the formats above + // but it may be set to something completely different by the user + result = ParseFormat(time, _T("%X")); + } + + // TODO: parse timezones + + return result; +} + +// ---------------------------------------------------------------------------- +// Workdays and holidays support +// ---------------------------------------------------------------------------- + +bool wxDateTime::IsWorkDay(Country WXUNUSED(country)) const +{ + return !wxDateTimeHolidayAuthority::IsHoliday(*this); +} + +// ============================================================================ +// wxDateSpan +// ============================================================================ + +wxDateSpan WXDLLIMPEXP_BASE operator*(int n, const wxDateSpan& ds) +{ + wxDateSpan ds1(ds); + return ds1.Multiply(n); +} + +// ============================================================================ +// wxTimeSpan +// ============================================================================ + +wxTimeSpan WXDLLIMPEXP_BASE operator*(int n, const wxTimeSpan& ts) +{ + return wxTimeSpan(ts).Multiply(n); +} + +// this enum is only used in wxTimeSpan::Format() below but we can't declare +// it locally to the method as it provokes an internal compiler error in egcs +// 2.91.60 when building with -O2 +enum TimeSpanPart +{ + Part_Week, + Part_Day, + Part_Hour, + Part_Min, + Part_Sec, + Part_MSec +}; + +// not all strftime(3) format specifiers make sense here because, for example, +// a time span doesn't have a year nor a timezone +// +// Here are the ones which are supported (all of them are supported by strftime +// as well): +// %H hour in 24 hour format +// %M minute (00 - 59) +// %S second (00 - 59) +// %% percent sign +// +// Also, for MFC CTimeSpan compatibility, we support +// %D number of days +// +// And, to be better than MFC :-), we also have +// %E number of wEeks +// %l milliseconds (000 - 999) +wxString wxTimeSpan::Format(const wxChar *format) const +{ + // we deal with only positive time spans here and just add the sign in + // front for the negative ones + if ( IsNegative() ) + { + wxString str(Negate().Format(format)); + return _T("-") + str; + } + + wxCHECK_MSG( format, wxEmptyString, + _T("NULL format in wxTimeSpan::Format") ); + + wxString str; + str.Alloc(wxStrlen(format)); + + // Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */) + // + // Then, of course, ts.Format("%H:%M:%S") must return "01:02:03", but the + // question is what should ts.Format("%S") do? The code here returns "3273" + // in this case (i.e. the total number of seconds, not just seconds % 60) + // because, for me, this call means "give me entire time interval in + // seconds" and not "give me the seconds part of the time interval" + // + // If we agree that it should behave like this, it is clear that the + // interpretation of each format specifier depends on the presence of the + // other format specs in the string: if there was "%H" before "%M", we + // should use GetMinutes() % 60, otherwise just GetMinutes() &c + + // we remember the most important unit found so far + TimeSpanPart partBiggest = Part_MSec; + + for ( const wxChar *pch = format; *pch; pch++ ) + { + wxChar ch = *pch; + + if ( ch == _T('%') ) + { + // the start of the format specification of the printf() below + wxString fmtPrefix(_T('%')); + + // the number + long n; + + // the number of digits for the format string, 0 if unused + unsigned digits = 0; + + ch = *++pch; // get the format spec char + switch ( ch ) + { + default: + wxFAIL_MSG( _T("invalid format character") ); + // fall through + + case _T('%'): + str += ch; + + // skip the part below switch + continue; + + case _T('D'): + n = GetDays(); + if ( partBiggest < Part_Day ) + { + n %= DAYS_PER_WEEK; + } + else + { + partBiggest = Part_Day; + } + break; + + case _T('E'): + partBiggest = Part_Week; + n = GetWeeks(); + break; + + case _T('H'): + n = GetHours(); + if ( partBiggest < Part_Hour ) + { + n %= HOURS_PER_DAY; + } + else + { + partBiggest = Part_Hour; + } + + digits = 2; + break; + + case _T('l'): + n = GetMilliseconds().ToLong(); + if ( partBiggest < Part_MSec ) + { + n %= 1000; + } + //else: no need to reset partBiggest to Part_MSec, it is + // the least significant one anyhow + + digits = 3; + break; + + case _T('M'): + n = GetMinutes(); + if ( partBiggest < Part_Min ) + { + n %= MIN_PER_HOUR; + } + else + { + partBiggest = Part_Min; + } + + digits = 2; + break; + + case _T('S'): + n = GetSeconds().ToLong(); + if ( partBiggest < Part_Sec ) + { + n %= SEC_PER_MIN; + } + else + { + partBiggest = Part_Sec; + } + + digits = 2; + break; + } + + if ( digits ) + { + fmtPrefix << _T("0") << digits; + } + + str += wxString::Format(fmtPrefix + _T("ld"), n); + } + else + { + // normal character, just copy + str += ch; + } + } + + return str; +} + // ============================================================================ // wxDateTimeHolidayAuthority and related classes // ============================================================================ @@ -2210,7 +4542,7 @@ size_t wxDateTimeWorkDays::DoGetHolidaysInRange(const wxDateTime& dtStart, { if ( dtStart > dtEnd ) { - wxFAIL_MSG( wxT("invalid date range in GetHolidaysInRange") ); + wxFAIL_MSG( _T("invalid date range in GetHolidaysInRange") ); return 0u; } @@ -2250,7 +4582,7 @@ size_t wxDateTimeWorkDays::DoGetHolidaysInRange(const wxDateTime& dtStart, WXDLLIMPEXP_BASE void wxNextMonth(wxDateTime::Month& m) { - wxASSERT_MSG( m < wxDateTime::Inv_Month, wxT("invalid month") ); + wxASSERT_MSG( m < wxDateTime::Inv_Month, _T("invalid month") ); // no wrapping or the for loop above would never end! m = (wxDateTime::Month)(m + 1); @@ -2258,7 +4590,7 @@ WXDLLIMPEXP_BASE void wxNextMonth(wxDateTime::Month& m) WXDLLIMPEXP_BASE void wxPrevMonth(wxDateTime::Month& m) { - wxASSERT_MSG( m < wxDateTime::Inv_Month, wxT("invalid month") ); + wxASSERT_MSG( m < wxDateTime::Inv_Month, _T("invalid month") ); m = m == wxDateTime::Jan ? wxDateTime::Inv_Month : (wxDateTime::Month)(m - 1); @@ -2266,7 +4598,7 @@ WXDLLIMPEXP_BASE void wxPrevMonth(wxDateTime::Month& m) WXDLLIMPEXP_BASE void wxNextWDay(wxDateTime::WeekDay& wd) { - wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, wxT("invalid week day") ); + wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, _T("invalid week day") ); // no wrapping or the for loop above would never end! wd = (wxDateTime::WeekDay)(wd + 1); @@ -2274,60 +4606,10 @@ WXDLLIMPEXP_BASE void wxNextWDay(wxDateTime::WeekDay& wd) WXDLLIMPEXP_BASE void wxPrevWDay(wxDateTime::WeekDay& wd) { - wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, wxT("invalid week day") ); + wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, _T("invalid week day") ); wd = wd == wxDateTime::Sun ? wxDateTime::Inv_WeekDay : (wxDateTime::WeekDay)(wd - 1); } -#ifdef __WINDOWS__ - -wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st) -{ - return Set(st.wDay, - static_cast(wxDateTime::Jan + st.wMonth - 1), - st.wYear, - st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); -} - -wxDateTime& wxDateTime::SetFromMSWSysDate(const SYSTEMTIME& st) -{ - return Set(st.wDay, - static_cast(wxDateTime::Jan + st.wMonth - 1), - st.wYear, - 0, 0, 0, 0); -} - -void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const -{ - const wxDateTime::Tm tm(GetTm()); - - st->wYear = (WXWORD)tm.year; - st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1); - st->wDay = tm.mday; - - st->wDayOfWeek = 0; - st->wHour = tm.hour; - st->wMinute = tm.min; - st->wSecond = tm.sec; - st->wMilliseconds = tm.msec; -} - -void wxDateTime::GetAsMSWSysDate(SYSTEMTIME* st) const -{ - const wxDateTime::Tm tm(GetTm()); - - st->wYear = (WXWORD)tm.year; - st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1); - st->wDay = tm.mday; - - st->wDayOfWeek = - st->wHour = - st->wMinute = - st->wSecond = - st->wMilliseconds = 0; -} - -#endif // __WINDOWS__ - #endif // wxUSE_DATETIME diff --git a/Source/3rd Party/wx/src/common/datetimefmt.cpp b/Source/3rd Party/wx/src/common/datetimefmt.cpp deleted file mode 100644 index 5084c282e..000000000 --- a/Source/3rd Party/wx/src/common/datetimefmt.cpp +++ /dev/null @@ -1,2417 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/datetimefmt.cpp -// Purpose: wxDateTime formatting & parsing code -// Author: Vadim Zeitlin -// Modified by: -// Created: 11.05.99 -// Copyright: (c) 1999 Vadim Zeitlin -// parts of code taken from sndcal library by Scott E. Lee: -// -// Copyright 1993-1995, Scott E. Lee, all rights reserved. -// Permission granted to use, copy, modify, distribute and sell -// so long as the above copyright and this permission statement -// are retained in all copies. -// -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if !defined(wxUSE_DATETIME) || wxUSE_DATETIME - -#ifndef WX_PRECOMP - #ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" - #endif - #include "wx/string.h" - #include "wx/log.h" - #include "wx/intl.h" - #include "wx/stopwatch.h" // for wxGetLocalTimeMillis() - #include "wx/module.h" - #include "wx/crt.h" -#endif // WX_PRECOMP - -#include "wx/thread.h" - -#include - -#ifdef __WINDOWS__ - #include - #ifndef __WXWINCE__ - #include - #endif -#endif - -#include "wx/datetime.h" -#include "wx/time.h" - -// ============================================================================ -// implementation of wxDateTime -// ============================================================================ - -// ---------------------------------------------------------------------------- -// helpers shared between datetime.cpp and datetimefmt.cpp -// ---------------------------------------------------------------------------- - -extern void InitTm(struct tm& tm); - -extern wxString CallStrftime(const wxString& format, const tm* tm); - -// ---------------------------------------------------------------------------- -// constants (see also datetime.cpp) -// ---------------------------------------------------------------------------- - -static const int DAYS_PER_WEEK = 7; - -static const int HOURS_PER_DAY = 24; - -static const int SEC_PER_MIN = 60; - -static const int MIN_PER_HOUR = 60; - -// ---------------------------------------------------------------------------- -// parsing helpers -// ---------------------------------------------------------------------------- - -namespace -{ - -// all the functions below taking non-const wxString::const_iterator p advance -// it until the end of the match - -// scans all digits (but no more than len) and returns the resulting number -bool GetNumericToken(size_t len, - wxString::const_iterator& p, - const wxString::const_iterator& end, - unsigned long *number) -{ - size_t n = 1; - wxString s; - while ( p != end && wxIsdigit(*p) ) - { - s += *p++; - - if ( len && ++n > len ) - break; - } - - return !s.empty() && s.ToULong(number); -} - -// scans all alphabetic characters and returns the resulting string -wxString -GetAlphaToken(wxString::const_iterator& p, - const wxString::const_iterator& end) -{ - wxString s; - while ( p != end && wxIsalpha(*p) ) - { - s += *p++; - } - - return s; -} - -enum -{ - DateLang_English = 1, - DateLang_Local = 2 -}; - -// return the month if the string is a month name or Inv_Month otherwise -// -// flags can contain wxDateTime::Name_Abbr/Name_Full or both of them and lang -// can be either DateLang_Local (default) to interpret string as a localized -// month name or DateLang_English to parse it as a standard English name or -// their combination to interpret it in any way -wxDateTime::Month -GetMonthFromName(wxString::const_iterator& p, - const wxString::const_iterator& end, - int flags, - int lang) -{ - const wxString::const_iterator pOrig = p; - const wxString name = GetAlphaToken(p, end); - if ( name.empty() ) - return wxDateTime::Inv_Month; - - wxDateTime::Month mon; - for ( mon = wxDateTime::Jan; mon < wxDateTime::Inv_Month; wxNextMonth(mon) ) - { - // case-insensitive comparison either one of or with both abbreviated - // and not versions - if ( flags & wxDateTime::Name_Full ) - { - if ( lang & DateLang_English ) - { - if ( name.CmpNoCase(wxDateTime::GetEnglishMonthName(mon, - wxDateTime::Name_Full)) == 0 ) - break; - } - - if ( lang & DateLang_Local ) - { - if ( name.CmpNoCase(wxDateTime::GetMonthName(mon, - wxDateTime::Name_Full)) == 0 ) - break; - } - } - - if ( flags & wxDateTime::Name_Abbr ) - { - if ( lang & DateLang_English ) - { - if ( name.CmpNoCase(wxDateTime::GetEnglishMonthName(mon, - wxDateTime::Name_Abbr)) == 0 ) - break; - } - - if ( lang & DateLang_Local ) - { - // some locales (e.g. French one) use periods for the - // abbreviated month names but it's never part of name so - // compare it specially - wxString nameAbbr = wxDateTime::GetMonthName(mon, - wxDateTime::Name_Abbr); - const bool hasPeriod = *nameAbbr.rbegin() == '.'; - if ( hasPeriod ) - nameAbbr.erase(nameAbbr.end() - 1); - - if ( name.CmpNoCase(nameAbbr) == 0 ) - { - if ( hasPeriod ) - { - // skip trailing period if it was part of the match - if ( *p == '.' ) - ++p; - else // no match as no matching period - continue; - } - - break; - } - } - } - } - - if ( mon == wxDateTime::Inv_Month ) - p = pOrig; - - return mon; -} - -// return the weekday if the string is a weekday name or Inv_WeekDay otherwise -// -// flags and lang parameters have the same meaning as for GetMonthFromName() -// above -wxDateTime::WeekDay -GetWeekDayFromName(wxString::const_iterator& p, - const wxString::const_iterator& end, - int flags, int lang) -{ - const wxString::const_iterator pOrig = p; - const wxString name = GetAlphaToken(p, end); - if ( name.empty() ) - return wxDateTime::Inv_WeekDay; - - wxDateTime::WeekDay wd; - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) - { - if ( flags & wxDateTime::Name_Full ) - { - if ( lang & DateLang_English ) - { - if ( name.CmpNoCase(wxDateTime::GetEnglishWeekDayName(wd, - wxDateTime::Name_Full)) == 0 ) - break; - } - - if ( lang & DateLang_Local ) - { - if ( name.CmpNoCase(wxDateTime::GetWeekDayName(wd, - wxDateTime::Name_Full)) == 0 ) - break; - } - } - - if ( flags & wxDateTime::Name_Abbr ) - { - if ( lang & DateLang_English ) - { - if ( name.CmpNoCase(wxDateTime::GetEnglishWeekDayName(wd, - wxDateTime::Name_Abbr)) == 0 ) - break; - } - - if ( lang & DateLang_Local ) - { - if ( name.CmpNoCase(wxDateTime::GetWeekDayName(wd, - wxDateTime::Name_Abbr)) == 0 ) - break; - } - } - } - - if ( wd == wxDateTime::Inv_WeekDay ) - p = pOrig; - - return wd; -} - -// return the year of the Monday of the week containing the given date -int -GetWeekBasedYear(const wxDateTime& dt) -{ - const wxDateTime::Tm tm = dt.GetTm(); - - int year = tm.year; - - // The week-based year can only be different from the normal year for few - // days in the beginning and the end of the year. - if ( tm.yday > 361 ) - { - if ( dt.GetWeekOfYear() == 1 ) - year++; - } - else if ( tm.yday < 5 ) - { - if ( dt.GetWeekOfYear() == 53 ) - year--; - } - - return year; -} - -// parses string starting at given iterator using the specified format and, -// optionally, a fall back format (and optionally another one... but it stops -// there, really) -// -// if unsuccessful, returns invalid wxDateTime without changing p; otherwise -// advance p to the end of the match and returns wxDateTime containing the -// results of the parsing -wxDateTime -ParseFormatAt(wxString::const_iterator& p, - const wxString::const_iterator& end, - const wxString& fmt, - // FIXME-VC6: using wxString() instead of wxEmptyString in the - // line below results in error C2062: type 'class - // wxString (__cdecl *)(void)' unexpected - const wxString& fmtAlt = wxEmptyString) -{ - const wxString str(p, end); - wxString::const_iterator endParse; - wxDateTime dt; - - // Use a default date outside of the DST period to avoid problems with - // parsing the time differently depending on the today's date (which is used - // as the fall back date if none is explicitly specified). - static const wxDateTime dtDef(1, wxDateTime::Jan, 2012); - - if ( dt.ParseFormat(str, fmt, dtDef, &endParse) || - (!fmtAlt.empty() && dt.ParseFormat(str, fmtAlt, dtDef, &endParse)) ) - { - p += endParse - str.begin(); - } - //else: all formats failed - - return dt; -} - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// wxDateTime to/from text representations -// ---------------------------------------------------------------------------- - -wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const -{ - wxCHECK_MSG( !formatp.empty(), wxEmptyString, - wxT("NULL format in wxDateTime::Format") ); - - wxString format = formatp; -#ifdef __WXOSX__ - format.Replace("%c",wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT)); - format.Replace("%x",wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT)); - format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT)); -#endif - // we have to use our own implementation if the date is out of range of - // strftime() -#ifdef wxHAS_STRFTIME - time_t time = GetTicks(); - - bool canUseStrftime = time != (time_t)-1; - - // We also can't use strftime() if we use non standard specifier: either - // our own extension "%l" or one of "%g", "%G", "%V", "%z" which are POSIX - // but not supported under Windows. - for ( wxString::const_iterator p = format.begin(); - canUseStrftime && p != format.end(); - ++p ) - { - if ( *p != '%' ) - continue; - - // set the default format - switch ( (*++p).GetValue() ) - { - case 'l': -#ifdef __WINDOWS__ - case 'g': - case 'G': - case 'V': - case 'z': -#endif // __WINDOWS__ - canUseStrftime = false; - break; - } - } - - if ( canUseStrftime ) - { - // use strftime() - struct tm tmstruct; - struct tm *tm; - if ( tz.GetOffset() == -wxGetTimeZone() ) - { - // we are working with local time - tm = wxLocaltime_r(&time, &tmstruct); - - // should never happen - wxCHECK_MSG( tm, wxEmptyString, wxT("wxLocaltime_r() failed") ); - } - else - { - time += (int)tz.GetOffset(); - -#if defined(__VMS__) || defined(__WATCOMC__) // time is unsigned so avoid warning - int time2 = (int) time; - if ( time2 >= 0 ) -#else - if ( time >= 0 ) -#endif - { - tm = wxGmtime_r(&time, &tmstruct); - - // should never happen - wxCHECK_MSG( tm, wxEmptyString, wxT("wxGmtime_r() failed") ); - } - else - { - tm = (struct tm *)NULL; - } - } - - if ( tm ) - { - return CallStrftime(format, tm); - } - } - //else: use generic code below -#endif // wxHAS_STRFTIME - - // we only parse ANSI C format specifications here, no POSIX 2 - // complications, no GNU extensions but we do add support for a "%l" format - // specifier allowing to get the number of milliseconds - Tm tm = GetTm(tz); - - // used for calls to strftime() when we only deal with time - struct tm tmTimeOnly; - memset(&tmTimeOnly, 0, sizeof(tmTimeOnly)); - tmTimeOnly.tm_hour = tm.hour; - tmTimeOnly.tm_min = tm.min; - tmTimeOnly.tm_sec = tm.sec; - tmTimeOnly.tm_mday = 1; // any date will do, use 1976-01-01 - tmTimeOnly.tm_mon = 0; - tmTimeOnly.tm_year = 76; - tmTimeOnly.tm_isdst = 0; // no DST, we adjust for tz ourselves - - wxString tmp, res, fmt; - for ( wxString::const_iterator p = format.begin(); p != format.end(); ++p ) - { - if ( *p != wxT('%') ) - { - // copy as is - res += *p; - - continue; - } - - // set the default format - switch ( (*++p).GetValue() ) - { - case wxT('Y'): // year has 4 digits - case wxT('G'): // (and ISO week year too) - case wxT('z'): // time zone as well - fmt = wxT("%04d"); - break; - - case wxT('j'): // day of year has 3 digits - case wxT('l'): // milliseconds have 3 digits - fmt = wxT("%03d"); - break; - - case wxT('w'): // week day as number has only one - fmt = wxT("%d"); - break; - - default: - // it's either another valid format specifier in which case - // the format is "%02d" (for all the rest) or we have the - // field width preceding the format in which case it will - // override the default format anyhow - fmt = wxT("%02d"); - } - - bool restart = true; - while ( restart ) - { - restart = false; - - // start of the format specification - switch ( (*p).GetValue() ) - { - case wxT('a'): // a weekday name - case wxT('A'): - // second parameter should be true for abbreviated names - res += GetWeekDayName(tm.GetWeekDay(), - *p == wxT('a') ? Name_Abbr : Name_Full); - break; - - case wxT('b'): // a month name - case wxT('B'): - res += GetMonthName(tm.mon, - *p == wxT('b') ? Name_Abbr : Name_Full); - break; - - case wxT('c'): // locale default date and time representation - case wxT('x'): // locale default date representation -#ifdef wxHAS_STRFTIME - // - // the problem: there is no way to know what do these format - // specifications correspond to for the current locale. - // - // the solution: use a hack and still use strftime(): first - // find the YEAR which is a year in the strftime() range (1970 - // - 2038) whose Jan 1 falls on the same week day as the Jan 1 - // of the real year. Then make a copy of the format and - // replace all occurrences of YEAR in it with some unique - // string not appearing anywhere else in it, then use - // strftime() to format the date in year YEAR and then replace - // YEAR back by the real year and the unique replacement - // string back with YEAR. Notice that "all occurrences of YEAR" - // means all occurrences of 4 digit as well as 2 digit form! - // - // the bugs: we assume that neither of %c nor %x contains any - // fields which may change between the YEAR and real year. For - // example, the week number (%U, %W) and the day number (%j) - // will change if one of these years is leap and the other one - // is not! - { - // find the YEAR: normally, for any year X, Jan 1 of the - // year X + 28 is the same weekday as Jan 1 of X (because - // the weekday advances by 1 for each normal X and by 2 - // for each leap X, hence by 5 every 4 years or by 35 - // which is 0 mod 7 every 28 years) but this rule breaks - // down if there are years between X and Y which are - // divisible by 4 but not leap (i.e. divisible by 100 but - // not 400), hence the correction. - - int yearReal = GetYear(tz); - int mod28 = yearReal % 28; - - // be careful to not go too far - we risk to leave the - // supported range - int year; - if ( mod28 < 10 ) - { - year = 1988 + mod28; // 1988 == 0 (mod 28) - } - else - { - year = 1970 + mod28 - 10; // 1970 == 10 (mod 28) - } - - int nCentury = year / 100, - nCenturyReal = yearReal / 100; - - // need to adjust for the years divisble by 400 which are - // not leap but are counted like leap ones if we just take - // the number of centuries in between for nLostWeekDays - int nLostWeekDays = (nCentury - nCenturyReal) - - (nCentury / 4 - nCenturyReal / 4); - - // we have to gain back the "lost" weekdays: note that the - // effect of this loop is to not do anything to - // nLostWeekDays (which we won't use any more), but to - // (indirectly) set the year correctly - while ( (nLostWeekDays % 7) != 0 ) - { - nLostWeekDays += (year++ % 4) ? 1 : 2; - } - - // finally move the year below 2000 so that the 2-digit - // year number can never match the month or day of the - // month when we do the replacements below - if ( year >= 2000 ) - year -= 28; - - wxASSERT_MSG( year >= 1970 && year < 2000, - wxT("logic error in wxDateTime::Format") ); - - - // use strftime() to format the same date but in supported - // year - // - // NB: we assume that strftime() doesn't check for the - // date validity and will happily format the date - // corresponding to Feb 29 of a non leap year (which - // may happen if yearReal was leap and year is not) - struct tm tmAdjusted; - InitTm(tmAdjusted); - tmAdjusted.tm_hour = tm.hour; - tmAdjusted.tm_min = tm.min; - tmAdjusted.tm_sec = tm.sec; - tmAdjusted.tm_wday = tm.GetWeekDay(); - tmAdjusted.tm_yday = GetDayOfYear(); - tmAdjusted.tm_mday = tm.mday; - tmAdjusted.tm_mon = tm.mon; - tmAdjusted.tm_year = year - 1900; - tmAdjusted.tm_isdst = 0; // no DST, already adjusted - wxString str = CallStrftime(*p == wxT('c') ? wxT("%c") - : wxT("%x"), - &tmAdjusted); - - // now replace the replacement year with the real year: - // notice that we have to replace the 4 digit year with - // a unique string not appearing in strftime() output - // first to prevent the 2 digit year from matching any - // substring of the 4 digit year (but any day, month, - // hours or minutes components should be safe because - // they are never in 70-99 range) - wxString replacement("|"); - while ( str.find(replacement) != wxString::npos ) - replacement += '|'; - - str.Replace(wxString::Format("%d", year), - replacement); - str.Replace(wxString::Format("%d", year % 100), - wxString::Format("%d", yearReal % 100)); - str.Replace(replacement, - wxString::Format("%d", yearReal)); - - res += str; - } -#else // !wxHAS_STRFTIME - // Use "%m/%d/%y %H:%M:%S" format instead - res += wxString::Format(wxT("%02d/%02d/%04d %02d:%02d:%02d"), - tm.mon+1,tm.mday, tm.year, tm.hour, tm.min, tm.sec); -#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME - break; - - case wxT('d'): // day of a month (01-31) - res += wxString::Format(fmt, tm.mday); - break; - - case wxT('g'): // 2-digit week-based year - res += wxString::Format(fmt, GetWeekBasedYear(*this) % 100); - break; - - case wxT('G'): // week-based year with century - res += wxString::Format(fmt, GetWeekBasedYear(*this)); - break; - - case wxT('H'): // hour in 24h format (00-23) - res += wxString::Format(fmt, tm.hour); - break; - - case wxT('I'): // hour in 12h format (01-12) - { - // 24h -> 12h, 0h -> 12h too - int hour12 = tm.hour > 12 ? tm.hour - 12 - : tm.hour ? tm.hour : 12; - res += wxString::Format(fmt, hour12); - } - break; - - case wxT('j'): // day of the year - res += wxString::Format(fmt, GetDayOfYear(tz)); - break; - - case wxT('l'): // milliseconds (NOT STANDARD) - res += wxString::Format(fmt, GetMillisecond(tz)); - break; - - case wxT('m'): // month as a number (01-12) - res += wxString::Format(fmt, tm.mon + 1); - break; - - case wxT('M'): // minute as a decimal number (00-59) - res += wxString::Format(fmt, tm.min); - break; - - case wxT('p'): // AM or PM string -#ifdef wxHAS_STRFTIME - res += CallStrftime(wxT("%p"), &tmTimeOnly); -#else // !wxHAS_STRFTIME - res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am"); -#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME - break; - - case wxT('S'): // second as a decimal number (00-61) - res += wxString::Format(fmt, tm.sec); - break; - - case wxT('U'): // week number in the year (Sunday 1st week day) - res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz)); - break; - - case wxT('V'): // ISO week number - case wxT('W'): // week number in the year (Monday 1st week day) - res += wxString::Format(fmt, GetWeekOfYear(Monday_First, tz)); - break; - - case wxT('w'): // weekday as a number (0-6), Sunday = 0 - res += wxString::Format(fmt, tm.GetWeekDay()); - break; - - // case wxT('x'): -- handled with "%c" - - case wxT('X'): // locale default time representation - // just use strftime() to format the time for us -#ifdef wxHAS_STRFTIME - res += CallStrftime(wxT("%X"), &tmTimeOnly); -#else // !wxHAS_STRFTIME - res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec); -#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME - break; - - case wxT('y'): // year without century (00-99) - res += wxString::Format(fmt, tm.year % 100); - break; - - case wxT('Y'): // year with century - res += wxString::Format(fmt, tm.year); - break; - - case wxT('z'): // time zone as [-+]HHMM - { - int ofs = tz.GetOffset(); - - // The time zone offset does not include the DST, but - // we do need to take it into account when showing the - // time in the local time zone to the user. - if ( ofs == -wxGetTimeZone() && IsDST() == 1 ) - { - // FIXME: As elsewhere in wxDateTime, we assume - // that the DST is always 1 hour, but this is not - // true in general. - ofs += 3600; - } - - if ( ofs < 0 ) - { - res += '-'; - ofs = -ofs; - } - else - { - res += '+'; - } - - // Converts seconds to HHMM representation. - res += wxString::Format(fmt, - 100*(ofs/3600) + (ofs/60)%60); - } - break; - - case wxT('Z'): // timezone name -#ifdef wxHAS_STRFTIME - res += CallStrftime(wxT("%Z"), &tmTimeOnly); -#endif - break; - - default: - // is it the format width? - for ( fmt.clear(); - *p == wxT('-') || *p == wxT('+') || - *p == wxT(' ') || wxIsdigit(*p); - ++p ) - { - fmt += *p; - } - - if ( !fmt.empty() ) - { - // we've only got the flags and width so far in fmt - fmt.Prepend(wxT('%')); - fmt.Append(wxT('d')); - - restart = true; - - break; - } - - // no, it wasn't the width - wxFAIL_MSG(wxT("unknown format specifier")); - - // fall through and just copy it nevertheless - - case wxT('%'): // a percent sign - res += *p; - break; - - case 0: // the end of string - wxFAIL_MSG(wxT("missing format at the end of string")); - - // just put the '%' which was the last char in format - res += wxT('%'); - break; - } - } - } - - return res; -} - -// this function parses a string in (strict) RFC 822 format: see the section 5 -// of the RFC for the detailed description, but briefly it's something of the -// form "Sat, 18 Dec 1999 00:48:30 +0100" -// -// this function is "strict" by design - it must reject anything except true -// RFC822 time specs. -bool -wxDateTime::ParseRfc822Date(const wxString& date, wxString::const_iterator *end) -{ - const wxString::const_iterator pEnd = date.end(); - wxString::const_iterator p = date.begin(); - - // 1. week day - const wxDateTime::WeekDay - wd = GetWeekDayFromName(p, pEnd, Name_Abbr, DateLang_English); - if ( wd == Inv_WeekDay ) - return false; - //else: ignore week day for now, we could also check that it really - // corresponds to the specified date - - // 2. separating comma - if ( *p++ != ',' || *p++ != ' ' ) - return false; - - // 3. day number - if ( !wxIsdigit(*p) ) - return false; - - wxDateTime_t day = (wxDateTime_t)(*p++ - '0'); - if ( wxIsdigit(*p) ) - { - day *= 10; - day = (wxDateTime_t)(day + (*p++ - '0')); - } - - if ( *p++ != ' ' ) - return false; - - // 4. month name - const Month mon = GetMonthFromName(p, pEnd, Name_Abbr, DateLang_English); - if ( mon == Inv_Month ) - return false; - - if ( *p++ != ' ' ) - return false; - - // 5. year - if ( !wxIsdigit(*p) ) - return false; - - int year = *p++ - '0'; - if ( !wxIsdigit(*p) ) // should have at least 2 digits in the year - return false; - - year *= 10; - year += *p++ - '0'; - - // is it a 2 digit year (as per original RFC 822) or a 4 digit one? - if ( wxIsdigit(*p) ) - { - year *= 10; - year += *p++ - '0'; - - if ( !wxIsdigit(*p) ) - { - // no 3 digit years please - return false; - } - - year *= 10; - year += *p++ - '0'; - } - - if ( *p++ != ' ' ) - return false; - - // 6. time in hh:mm:ss format with seconds being optional - if ( !wxIsdigit(*p) ) - return false; - - wxDateTime_t hour = (wxDateTime_t)(*p++ - '0'); - - if ( !wxIsdigit(*p) ) - return false; - - hour *= 10; - hour = (wxDateTime_t)(hour + (*p++ - '0')); - - if ( *p++ != ':' ) - return false; - - if ( !wxIsdigit(*p) ) - return false; - - wxDateTime_t min = (wxDateTime_t)(*p++ - '0'); - - if ( !wxIsdigit(*p) ) - return false; - - min *= 10; - min += (wxDateTime_t)(*p++ - '0'); - - wxDateTime_t sec = 0; - if ( *p == ':' ) - { - p++; - if ( !wxIsdigit(*p) ) - return false; - - sec = (wxDateTime_t)(*p++ - '0'); - - if ( !wxIsdigit(*p) ) - return false; - - sec *= 10; - sec += (wxDateTime_t)(*p++ - '0'); - } - - if ( *p++ != ' ' ) - return false; - - // 7. now the interesting part: the timezone - int offset = 0; // just to suppress warnings - if ( *p == '-' || *p == '+' ) - { - // the explicit offset given: it has the form of hhmm - bool plus = *p++ == '+'; - - if ( !wxIsdigit(*p) || !wxIsdigit(*(p + 1)) ) - return false; - - - // hours - offset = MIN_PER_HOUR*(10*(*p - '0') + (*(p + 1) - '0')); - - p += 2; - - if ( !wxIsdigit(*p) || !wxIsdigit(*(p + 1)) ) - return false; - - // minutes - offset += 10*(*p - '0') + (*(p + 1) - '0'); - - if ( !plus ) - offset = -offset; - - p += 2; - } - else // not numeric - { - // the symbolic timezone given: may be either military timezone or one - // of standard abbreviations - if ( !*(p + 1) ) - { - // military: Z = UTC, J unused, A = -1, ..., Y = +12 - static const int offsets[26] = - { - //A B C D E F G H I J K L M - -1, -2, -3, -4, -5, -6, -7, -8, -9, 0, -10, -11, -12, - //N O P R Q S T U V W Z Y Z - +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, 0 - }; - - if ( *p < wxT('A') || *p > wxT('Z') || *p == wxT('J') ) - return false; - - offset = offsets[*p++ - 'A']; - } - else - { - // abbreviation - const wxString tz(p, date.end()); - if ( tz == wxT("UT") || tz == wxT("UTC") || tz == wxT("GMT") ) - offset = 0; - else if ( tz == wxT("AST") ) - offset = AST - GMT0; - else if ( tz == wxT("ADT") ) - offset = ADT - GMT0; - else if ( tz == wxT("EST") ) - offset = EST - GMT0; - else if ( tz == wxT("EDT") ) - offset = EDT - GMT0; - else if ( tz == wxT("CST") ) - offset = CST - GMT0; - else if ( tz == wxT("CDT") ) - offset = CDT - GMT0; - else if ( tz == wxT("MST") ) - offset = MST - GMT0; - else if ( tz == wxT("MDT") ) - offset = MDT - GMT0; - else if ( tz == wxT("PST") ) - offset = PST - GMT0; - else if ( tz == wxT("PDT") ) - offset = PDT - GMT0; - else - return false; - - p += tz.length(); - } - - // make it minutes - offset *= MIN_PER_HOUR; - } - - - // the spec was correct, construct the date from the values we found - Set(day, mon, year, hour, min, sec); - MakeFromTimezone(TimeZone::Make(offset*SEC_PER_MIN)); - - if ( end ) - *end = p; - - return true; -} - -const char* wxDateTime::ParseRfc822Date(const char* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseRfc822Date(dateStr, &end) ) - return NULL; - - return date + dateStr.IterOffsetInMBStr(end); -} - -const wchar_t* wxDateTime::ParseRfc822Date(const wchar_t* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseRfc822Date(dateStr, &end) ) - return NULL; - - return date + (end - dateStr.begin()); -} - -bool -wxDateTime::ParseFormat(const wxString& date, - const wxString& format, - const wxDateTime& dateDef, - wxString::const_iterator *endParse) -{ - wxCHECK_MSG( !format.empty(), false, "format can't be empty" ); - wxCHECK_MSG( endParse, false, "end iterator pointer must be specified" ); - - wxString str; - unsigned long num; - - // what fields have we found? - bool haveWDay = false, - haveYDay = false, - haveDay = false, - haveMon = false, - haveYear = false, - haveHour = false, - haveMin = false, - haveSec = false, - haveMsec = false; - - bool hourIsIn12hFormat = false, // or in 24h one? - isPM = false; // AM by default - - bool haveTimeZone = false; - - // and the value of the items we have (init them to get rid of warnings) - wxDateTime_t msec = 0, - sec = 0, - min = 0, - hour = 0; - WeekDay wday = Inv_WeekDay; - wxDateTime_t yday = 0, - mday = 0; - wxDateTime::Month mon = Inv_Month; - int year = 0; - long timeZone = 0; // time zone in seconds as expected in Tm structure - - wxString::const_iterator input = date.begin(); - const wxString::const_iterator end = date.end(); - for ( wxString::const_iterator fmt = format.begin(); fmt != format.end(); ++fmt ) - { - if ( *fmt != wxT('%') ) - { - if ( wxIsspace(*fmt) ) - { - // a white space in the format string matches 0 or more white - // spaces in the input - while ( input != end && wxIsspace(*input) ) - { - input++; - } - } - else // !space - { - // any other character (not whitespace, not '%') must be - // matched by itself in the input - if ( input == end || *input++ != *fmt ) - { - // no match - return false; - } - } - - // done with this format char - continue; - } - - // start of a format specification - - // parse the optional width - size_t width = 0; - while ( wxIsdigit(*++fmt) ) - { - width *= 10; - width += *fmt - '0'; - } - - // the default widths for the various fields - if ( !width ) - { - switch ( (*fmt).GetValue() ) - { - case wxT('Y'): // year has 4 digits - width = 4; - break; - - case wxT('j'): // day of year has 3 digits - case wxT('l'): // milliseconds have 3 digits - width = 3; - break; - - case wxT('w'): // week day as number has only one - width = 1; - break; - - default: - // default for all other fields - width = 2; - } - } - - // then the format itself - switch ( (*fmt).GetValue() ) - { - case wxT('a'): // a weekday name - case wxT('A'): - { - wday = GetWeekDayFromName - ( - input, end, - *fmt == 'a' ? Name_Abbr : Name_Full, - DateLang_Local - ); - if ( wday == Inv_WeekDay ) - { - // no match - return false; - } - } - haveWDay = true; - break; - - case wxT('b'): // a month name - case wxT('B'): - { - mon = GetMonthFromName - ( - input, end, - *fmt == 'b' ? Name_Abbr : Name_Full, - DateLang_Local - ); - if ( mon == Inv_Month ) - { - // no match - return false; - } - } - haveMon = true; - break; - - case wxT('c'): // locale default date and time representation - { - wxDateTime dt; - -#if wxUSE_INTL - const wxString - fmtDateTime = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT); - if ( !fmtDateTime.empty() ) - dt = ParseFormatAt(input, end, fmtDateTime); -#endif // wxUSE_INTL - if ( !dt.IsValid() ) - { - // also try the format which corresponds to ctime() - // output (i.e. the "C" locale default) - dt = ParseFormatAt(input, end, wxS("%a %b %d %H:%M:%S %Y")); - } - - if ( !dt.IsValid() ) - { - // and finally also the two generic date/time formats - dt = ParseFormatAt(input, end, wxS("%x %X"), wxS("%X %x")); - } - - if ( !dt.IsValid() ) - return false; - - const Tm tm = dt.GetTm(); - - hour = tm.hour; - min = tm.min; - sec = tm.sec; - - year = tm.year; - mon = tm.mon; - mday = tm.mday; - - haveDay = haveMon = haveYear = - haveHour = haveMin = haveSec = true; - } - break; - - case wxT('d'): // day of a month (01-31) - case 'e': // day of a month (1-31) (GNU extension) - if ( !GetNumericToken(width, input, end, &num) || - (num > 31) || (num < 1) ) - { - // no match - return false; - } - - // we can't check whether the day range is correct yet, will - // do it later - assume ok for now - haveDay = true; - mday = (wxDateTime_t)num; - break; - - case wxT('H'): // hour in 24h format (00-23) - if ( !GetNumericToken(width, input, end, &num) || (num > 23) ) - { - // no match - return false; - } - - haveHour = true; - hour = (wxDateTime_t)num; - break; - - case wxT('I'): // hour in 12h format (01-12) - if ( !GetNumericToken(width, input, end, &num) || - !num || (num > 12) ) - { - // no match - return false; - } - - haveHour = true; - hourIsIn12hFormat = true; - hour = (wxDateTime_t)(num % 12); // 12 should be 0 - break; - - case wxT('j'): // day of the year - if ( !GetNumericToken(width, input, end, &num) || - !num || (num > 366) ) - { - // no match - return false; - } - - haveYDay = true; - yday = (wxDateTime_t)num; - break; - - case wxT('l'): // milliseconds (0-999) - if ( !GetNumericToken(width, input, end, &num) ) - return false; - - haveMsec = true; - msec = (wxDateTime_t)num; - break; - - case wxT('m'): // month as a number (01-12) - if ( !GetNumericToken(width, input, end, &num) || - !num || (num > 12) ) - { - // no match - return false; - } - - haveMon = true; - mon = (Month)(num - 1); - break; - - case wxT('M'): // minute as a decimal number (00-59) - if ( !GetNumericToken(width, input, end, &num) || - (num > 59) ) - { - // no match - return false; - } - - haveMin = true; - min = (wxDateTime_t)num; - break; - - case wxT('p'): // AM or PM string - { - wxString am, pm; - GetAmPmStrings(&am, &pm); - - // we can never match %p in locales which don't use AM/PM - if ( am.empty() || pm.empty() ) - return false; - - const size_t pos = input - date.begin(); - if ( date.compare(pos, pm.length(), pm) == 0 ) - { - isPM = true; - input += pm.length(); - } - else if ( date.compare(pos, am.length(), am) == 0 ) - { - input += am.length(); - } - else // no match - { - return false; - } - } - break; - - case wxT('r'): // time as %I:%M:%S %p - { - wxDateTime dt; - if ( !dt.ParseFormat(wxString(input, end), - wxS("%I:%M:%S %p"), &input) ) - return false; - - haveHour = haveMin = haveSec = true; - - const Tm tm = dt.GetTm(); - hour = tm.hour; - min = tm.min; - sec = tm.sec; - } - break; - - case wxT('R'): // time as %H:%M - { - const wxDateTime - dt = ParseFormatAt(input, end, wxS("%H:%M")); - if ( !dt.IsValid() ) - return false; - - haveHour = - haveMin = true; - - const Tm tm = dt.GetTm(); - hour = tm.hour; - min = tm.min; - } - break; - - case wxT('S'): // second as a decimal number (00-61) - if ( !GetNumericToken(width, input, end, &num) || - (num > 61) ) - { - // no match - return false; - } - - haveSec = true; - sec = (wxDateTime_t)num; - break; - - case wxT('T'): // time as %H:%M:%S - { - const wxDateTime - dt = ParseFormatAt(input, end, wxS("%H:%M:%S")); - if ( !dt.IsValid() ) - return false; - - haveHour = - haveMin = - haveSec = true; - - const Tm tm = dt.GetTm(); - hour = tm.hour; - min = tm.min; - sec = tm.sec; - } - break; - - case wxT('w'): // weekday as a number (0-6), Sunday = 0 - if ( !GetNumericToken(width, input, end, &num) || - (wday > 6) ) - { - // no match - return false; - } - - haveWDay = true; - wday = (WeekDay)num; - break; - - case wxT('x'): // locale default date representation - { -#if wxUSE_INTL - wxString - fmtDate = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT), - fmtDateAlt = wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT); -#else // !wxUSE_INTL - wxString fmtDate, fmtDateAlt; -#endif // wxUSE_INTL/!wxUSE_INTL - if ( fmtDate.empty() ) - { - if ( IsWestEuropeanCountry(GetCountry()) || - GetCountry() == Russia ) - { - fmtDate = wxS("%d/%m/%Y"); - fmtDateAlt = wxS("%m/%d/%Y"); - } - else // assume USA - { - fmtDate = wxS("%m/%d/%Y"); - fmtDateAlt = wxS("%d/%m/%Y"); - } - } - - wxDateTime - dt = ParseFormatAt(input, end, fmtDate, fmtDateAlt); - - if ( !dt.IsValid() ) - { - // try with short years too - fmtDate.Replace("%Y","%y"); - fmtDateAlt.Replace("%Y","%y"); - dt = ParseFormatAt(input, end, fmtDate, fmtDateAlt); - - if ( !dt.IsValid() ) - return false; - } - - const Tm tm = dt.GetTm(); - - haveDay = - haveMon = - haveYear = true; - - year = tm.year; - mon = tm.mon; - mday = tm.mday; - } - - break; - - case wxT('X'): // locale default time representation - { -#if wxUSE_INTL - wxString fmtTime = wxLocale::GetInfo(wxLOCALE_TIME_FMT), - fmtTimeAlt; -#else // !wxUSE_INTL - wxString fmtTime, fmtTimeAlt; -#endif // wxUSE_INTL/!wxUSE_INTL - if ( fmtTime.empty() ) - { - // try to parse what follows as "%H:%M:%S" and, if this - // fails, as "%I:%M:%S %p" - this should catch the most - // common cases - fmtTime = "%T"; - fmtTimeAlt = "%r"; - } - - const wxDateTime - dt = ParseFormatAt(input, end, fmtTime, fmtTimeAlt); - if ( !dt.IsValid() ) - return false; - - haveHour = - haveMin = - haveSec = true; - - const Tm tm = dt.GetTm(); - hour = tm.hour; - min = tm.min; - sec = tm.sec; - } - break; - - case wxT('y'): // year without century (00-99) - if ( !GetNumericToken(width, input, end, &num) || - (num > 99) ) - { - // no match - return false; - } - - haveYear = true; - - // TODO should have an option for roll over date instead of - // hard coding it here - year = (num > 30 ? 1900 : 2000) + (wxDateTime_t)num; - break; - - case wxT('Y'): // year with century - if ( !GetNumericToken(width, input, end, &num) ) - { - // no match - return false; - } - - haveYear = true; - year = (wxDateTime_t)num; - break; - - case wxT('z'): - { - // check that we have something here at all - if ( input == end ) - return false; - - // and then check that it's either plus or minus sign - bool minusFound; - if ( *input == wxT('-') ) - minusFound = true; - else if ( *input == wxT('+') ) - minusFound = false; - else - return false; // no match - - // here should follow 4 digits HHMM - ++input; - unsigned long tzHourMin; - if ( !GetNumericToken(4, input, end, &tzHourMin) ) - return false; // no match - - const unsigned hours = tzHourMin / 100; - const unsigned minutes = tzHourMin % 100; - - if ( hours > 12 || minutes > 59 ) - return false; // bad format - - timeZone = 3600*hours + 60*minutes; - if ( minusFound ) - timeZone = -timeZone; - - haveTimeZone = true; - } - break; - - case wxT('Z'): // timezone name - // FIXME: currently we just ignore everything that looks like a - // time zone here - GetAlphaToken(input, end); - break; - - case wxT('%'): // a percent sign - if ( input == end || *input++ != wxT('%') ) - { - // no match - return false; - } - break; - - case 0: // the end of string - wxFAIL_MSG(wxT("unexpected format end")); - - // fall through - - default: // not a known format spec - return false; - } - } - - // format matched, try to construct a date from what we have now - Tm tmDef; - if ( dateDef.IsValid() ) - { - // take this date as default - tmDef = dateDef.GetTm(); - } - else if ( IsValid() ) - { - // if this date is valid, don't change it - tmDef = GetTm(); - } - else - { - // no default and this date is invalid - fall back to Today() - tmDef = Today().GetTm(); - } - - Tm tm = tmDef; - - // set the date - if ( haveMon ) - { - tm.mon = mon; - } - - if ( haveYear ) - { - tm.year = year; - } - - // TODO we don't check here that the values are consistent, if both year - // day and month/day were found, we just ignore the year day and we - // also always ignore the week day - if ( haveDay ) - { - if ( mday > GetNumberOfDays(tm.mon, tm.year) ) - return false; - - tm.mday = mday; - } - else if ( haveYDay ) - { - if ( yday > GetNumberOfDays(tm.year) ) - return false; - - Tm tm2 = wxDateTime(1, Jan, tm.year).SetToYearDay(yday).GetTm(); - - tm.mon = tm2.mon; - tm.mday = tm2.mday; - } - - // deal with AM/PM - if ( haveHour && hourIsIn12hFormat && isPM ) - { - // translate to 24hour format - hour += 12; - } - //else: either already in 24h format or no translation needed - - // set the time - if ( haveHour ) - { - tm.hour = hour; - } - - if ( haveMin ) - { - tm.min = min; - } - - if ( haveSec ) - { - tm.sec = sec; - } - - if ( haveMsec ) - tm.msec = msec; - - Set(tm); - - // If a time zone was specified and it is not the local time zone, we need - // to shift the time accordingly. - // - // Note that avoiding the call to MakeFromTimeZone is necessary to avoid - // DST problems. - if ( haveTimeZone && timeZone != -wxGetTimeZone() ) - MakeFromTimezone(timeZone); - - // finally check that the week day is consistent -- if we had it - if ( haveWDay && GetWeekDay() != wday ) - return false; - - *endParse = input; - - return true; -} - -const char* -wxDateTime::ParseFormat(const char* date, - const wxString& format, - const wxDateTime& dateDef) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseFormat(dateStr, format, dateDef, &end) ) - return NULL; - - return date + dateStr.IterOffsetInMBStr(end); -} - -const wchar_t* -wxDateTime::ParseFormat(const wchar_t* date, - const wxString& format, - const wxDateTime& dateDef) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseFormat(dateStr, format, dateDef, &end) ) - return NULL; - - return date + (end - dateStr.begin()); -} - -bool -wxDateTime::ParseDateTime(const wxString& date, wxString::const_iterator *end) -{ - wxCHECK_MSG( end, false, "end iterator pointer must be specified" ); - - wxDateTime - dtDate, - dtTime; - - wxString::const_iterator - endTime, - endDate, - endBoth; - - // If we got a date in the beginning, see if there is a time specified - // after the date - if ( dtDate.ParseDate(date, &endDate) ) - { - // Skip spaces, as the ParseTime() function fails on spaces - while ( endDate != date.end() && wxIsspace(*endDate) ) - ++endDate; - - const wxString timestr(endDate, date.end()); - if ( !dtTime.ParseTime(timestr, &endTime) ) - return false; - - endBoth = endDate + (endTime - timestr.begin()); - } - else // no date in the beginning - { - // check if we have a time followed by a date - if ( !dtTime.ParseTime(date, &endTime) ) - return false; - - while ( endTime != date.end() && wxIsspace(*endTime) ) - ++endTime; - - const wxString datestr(endTime, date.end()); - if ( !dtDate.ParseDate(datestr, &endDate) ) - return false; - - endBoth = endTime + (endDate - datestr.begin()); - } - - Set(dtDate.GetDay(), dtDate.GetMonth(), dtDate.GetYear(), - dtTime.GetHour(), dtTime.GetMinute(), dtTime.GetSecond(), - dtTime.GetMillisecond()); - - *end = endBoth; - - return true; -} - -const char* wxDateTime::ParseDateTime(const char* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseDateTime(dateStr, &end) ) - return NULL; - - return date + dateStr.IterOffsetInMBStr(end); -} - -const wchar_t* wxDateTime::ParseDateTime(const wchar_t* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseDateTime(dateStr, &end) ) - return NULL; - - return date + (end - dateStr.begin()); -} - -bool -wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end) -{ - wxCHECK_MSG( end, false, "end iterator pointer must be specified" ); - - // this is a simplified version of ParseDateTime() which understands only - // "today" (for wxDate compatibility) and digits only otherwise (and not - // all esoteric constructions ParseDateTime() knows about) - - const wxString::const_iterator pBegin = date.begin(); - const wxString::const_iterator pEnd = date.end(); - - wxString::const_iterator p = pBegin; - while ( p != pEnd && wxIsspace(*p) ) - p++; - - // some special cases - static struct - { - const char *str; - int dayDiffFromToday; - } literalDates[] = - { - { wxTRANSLATE("today"), 0 }, - { wxTRANSLATE("yesterday"), -1 }, - { wxTRANSLATE("tomorrow"), 1 }, - }; - - const size_t lenRest = pEnd - p; - for ( size_t n = 0; n < WXSIZEOF(literalDates); n++ ) - { - const wxString dateStr = wxGetTranslation(literalDates[n].str); - size_t len = dateStr.length(); - - if ( len > lenRest ) - continue; - - const wxString::const_iterator pEndStr = p + len; - if ( wxString(p, pEndStr).CmpNoCase(dateStr) == 0 ) - { - // nothing can follow this, so stop here - - p = pEndStr; - - int dayDiffFromToday = literalDates[n].dayDiffFromToday; - *this = Today(); - if ( dayDiffFromToday ) - { - *this += wxDateSpan::Days(dayDiffFromToday); - } - - *end = pEndStr; - - return true; - } - } - - // We try to guess what we have here: for each new (numeric) token, we - // determine if it can be a month, day or a year. Of course, there is an - // ambiguity as some numbers may be days as well as months, so we also - // have the ability to back track. - - // what do we have? - bool haveDay = false, // the months day? - haveWDay = false, // the day of week? - haveMon = false, // the month? - haveYear = false; // the year? - - bool monWasNumeric = false; // was month specified as a number? - - // and the value of the items we have (init them to get rid of warnings) - WeekDay wday = Inv_WeekDay; - wxDateTime_t day = 0; - wxDateTime::Month mon = Inv_Month; - int year = 0; - - // tokenize the string - while ( p != pEnd ) - { - // skip white space and date delimiters - if ( wxStrchr(".,/-\t\r\n ", *p) ) - { - ++p; - continue; - } - - // modify copy of the iterator as we're not sure if the next token is - // still part of the date at all - wxString::const_iterator pCopy = p; - - // we can have either alphabetic or numeric token, start by testing if - // it's the latter - unsigned long val; - if ( GetNumericToken(10 /* max length */, pCopy, pEnd, &val) ) - { - // guess what this number is - - bool isDay = false, - isMonth = false, - isYear = false; - - if ( !haveMon && val > 0 && val <= 12 ) - { - // assume it is month - isMonth = true; - } - else // not the month - { - if ( haveDay ) - { - // this can only be the year - isYear = true; - } - else // may be either day or year - { - // use a leap year if we don't have the year yet to allow - // dates like 2/29/1976 which would be rejected otherwise - wxDateTime_t max_days = (wxDateTime_t)( - haveMon - ? GetNumberOfDays(mon, haveYear ? year : 1976) - : 31 - ); - - // can it be day? - if ( (val == 0) || (val > (unsigned long)max_days) ) - { - // no - isYear = true; - } - else // yes, suppose it's the day - { - isDay = true; - } - } - } - - if ( isYear ) - { - if ( haveYear ) - break; - - haveYear = true; - - year = (wxDateTime_t)val; - } - else if ( isDay ) - { - if ( haveDay ) - break; - - haveDay = true; - - day = (wxDateTime_t)val; - } - else if ( isMonth ) - { - haveMon = true; - monWasNumeric = true; - - mon = (Month)(val - 1); - } - } - else // not a number - { - // be careful not to overwrite the current mon value - Month mon2 = GetMonthFromName - ( - pCopy, pEnd, - Name_Full | Name_Abbr, - DateLang_Local | DateLang_English - ); - if ( mon2 != Inv_Month ) - { - // it's a month - if ( haveMon ) - { - // but we already have a month - maybe we guessed wrong - // when we had interpreted that numeric value as a month - // and it was the day number instead? - if ( haveDay || !monWasNumeric ) - break; - - // assume we did and change our mind: reinterpret the month - // value as a day (notice that there is no need to check - // that it is valid as month values are always < 12, but - // the days are counted from 1 unlike the months) - day = (wxDateTime_t)(mon + 1); - haveDay = true; - } - - mon = mon2; - - haveMon = true; - } - else // not a valid month name - { - WeekDay wday2 = GetWeekDayFromName - ( - pCopy, pEnd, - Name_Full | Name_Abbr, - DateLang_Local | DateLang_English - ); - if ( wday2 != Inv_WeekDay ) - { - // a week day - if ( haveWDay ) - break; - - wday = wday2; - - haveWDay = true; - } - else // not a valid weekday name - { - // try the ordinals - static const char *const ordinals[] = - { - wxTRANSLATE("first"), - wxTRANSLATE("second"), - wxTRANSLATE("third"), - wxTRANSLATE("fourth"), - wxTRANSLATE("fifth"), - wxTRANSLATE("sixth"), - wxTRANSLATE("seventh"), - wxTRANSLATE("eighth"), - wxTRANSLATE("ninth"), - wxTRANSLATE("tenth"), - wxTRANSLATE("eleventh"), - wxTRANSLATE("twelfth"), - wxTRANSLATE("thirteenth"), - wxTRANSLATE("fourteenth"), - wxTRANSLATE("fifteenth"), - wxTRANSLATE("sixteenth"), - wxTRANSLATE("seventeenth"), - wxTRANSLATE("eighteenth"), - wxTRANSLATE("nineteenth"), - wxTRANSLATE("twentieth"), - // that's enough - otherwise we'd have problems with - // composite (or not) ordinals - }; - - size_t n; - for ( n = 0; n < WXSIZEOF(ordinals); n++ ) - { - const wxString ord = wxGetTranslation(ordinals[n]); - const size_t len = ord.length(); - if ( date.compare(p - pBegin, len, ord) == 0 ) - { - p += len; - break; - } - } - - if ( n == WXSIZEOF(ordinals) ) - { - // stop here - something unknown - break; - } - - // it's a day - if ( haveDay ) - { - // don't try anything here (as in case of numeric day - // above) - the symbolic day spec should always - // precede the month/year - break; - } - - haveDay = true; - - day = (wxDateTime_t)(n + 1); - } - } - } - - // advance iterator past a successfully parsed token - p = pCopy; - } - - // either no more tokens or the scan was stopped by something we couldn't - // parse - in any case, see if we can construct a date from what we have - if ( !haveDay && !haveWDay ) - return false; - - if ( haveWDay && (haveMon || haveYear || haveDay) && - !(haveDay && haveMon && haveYear) ) - { - // without adjectives (which we don't support here) the week day only - // makes sense completely separately or with the full date - // specification (what would "Wed 1999" mean?) - return false; - } - - if ( !haveWDay && haveYear && !(haveDay && haveMon) ) - { - // may be we have month and day instead of day and year? - if ( haveDay && !haveMon ) - { - if ( day <= 12 ) - { - // exchange day and month - mon = (wxDateTime::Month)(day - 1); - - // we're in the current year then - if ( (year > 0) && (year <= (int)GetNumberOfDays(mon, Inv_Year)) ) - { - day = (wxDateTime_t)year; - - haveMon = true; - haveYear = false; - } - //else: no, can't exchange, leave haveMon == false - } - } - - if ( !haveMon ) - return false; - } - - if ( !haveMon ) - { - mon = GetCurrentMonth(); - } - - if ( !haveYear ) - { - year = GetCurrentYear(); - } - - if ( haveDay ) - { - // normally we check the day above but the check is optimistic in case - // we find the day before its month/year so we have to redo it now - if ( day > GetNumberOfDays(mon, year) ) - return false; - - Set(day, mon, year); - - if ( haveWDay ) - { - // check that it is really the same - if ( GetWeekDay() != wday ) - return false; - } - } - else // haveWDay - { - *this = Today(); - - SetToWeekDayInSameWeek(wday); - } - - *end = p; - - return true; -} - -const char* wxDateTime::ParseDate(const char* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseDate(dateStr, &end) ) - return NULL; - - return date + dateStr.IterOffsetInMBStr(end); -} - -const wchar_t* wxDateTime::ParseDate(const wchar_t* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseDate(dateStr, &end) ) - return NULL; - - return date + (end - dateStr.begin()); -} - -bool -wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end) -{ - wxCHECK_MSG( end, false, "end iterator pointer must be specified" ); - - // first try some extra things - static const struct - { - const char *name; - wxDateTime_t hour; - } stdTimes[] = - { - { wxTRANSLATE("noon"), 12 }, - { wxTRANSLATE("midnight"), 00 }, - // anything else? - }; - - for ( size_t n = 0; n < WXSIZEOF(stdTimes); n++ ) - { - const wxString timeString = wxGetTranslation(stdTimes[n].name); - if ( timeString.CmpNoCase(wxString(time, timeString.length())) == 0 ) - { - // casts required by DigitalMars - Set(stdTimes[n].hour, wxDateTime_t(0), wxDateTime_t(0)); - - if ( end ) - *end = time.begin() + timeString.length(); - - return true; - } - } - - // try all time formats we may think about in the order from longest to - // shortest - static const char *const timeFormats[] = - { - "%I:%M:%S %p", // 12hour with AM/PM - "%H:%M:%S", // could be the same or 24 hour one so try it too - "%I:%M %p", // 12hour with AM/PM but without seconds - "%H:%M", // and a possibly 24 hour version without seconds - "%I %p", // just hour with AM/AM - "%H", // just hour in 24 hour version - "%X", // possibly something from above or maybe something - // completely different -- try it last - - // TODO: parse timezones - }; - - for ( size_t nFmt = 0; nFmt < WXSIZEOF(timeFormats); nFmt++ ) - { - if ( ParseFormat(time, timeFormats[nFmt], end) ) - return true; - } - - return false; -} - -const char* wxDateTime::ParseTime(const char* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseTime(dateStr, &end) ) - return NULL; - - return date + dateStr.IterOffsetInMBStr(end); -} - -const wchar_t* wxDateTime::ParseTime(const wchar_t* date) -{ - wxString::const_iterator end; - wxString dateStr(date); - if ( !ParseTime(dateStr, &end) ) - return NULL; - - return date + (end - dateStr.begin()); -} - -// ---------------------------------------------------------------------------- -// Workdays and holidays support -// ---------------------------------------------------------------------------- - -bool wxDateTime::IsWorkDay(Country WXUNUSED(country)) const -{ - return !wxDateTimeHolidayAuthority::IsHoliday(*this); -} - -// ============================================================================ -// wxDateSpan -// ============================================================================ - -wxDateSpan WXDLLIMPEXP_BASE operator*(int n, const wxDateSpan& ds) -{ - wxDateSpan ds1(ds); - return ds1.Multiply(n); -} - -// ============================================================================ -// wxTimeSpan -// ============================================================================ - -wxTimeSpan WXDLLIMPEXP_BASE operator*(int n, const wxTimeSpan& ts) -{ - return wxTimeSpan(ts).Multiply(n); -} - -// this enum is only used in wxTimeSpan::Format() below but we can't declare -// it locally to the method as it provokes an internal compiler error in egcs -// 2.91.60 when building with -O2 -enum TimeSpanPart -{ - Part_Week, - Part_Day, - Part_Hour, - Part_Min, - Part_Sec, - Part_MSec -}; - -// not all strftime(3) format specifiers make sense here because, for example, -// a time span doesn't have a year nor a timezone -// -// Here are the ones which are supported (all of them are supported by strftime -// as well): -// %H hour in 24 hour format -// %M minute (00 - 59) -// %S second (00 - 59) -// %% percent sign -// -// Also, for MFC CTimeSpan compatibility, we support -// %D number of days -// -// And, to be better than MFC :-), we also have -// %E number of wEeks -// %l milliseconds (000 - 999) -wxString wxTimeSpan::Format(const wxString& format) const -{ - // we deal with only positive time spans here and just add the sign in - // front for the negative ones - if ( IsNegative() ) - { - wxString str(Negate().Format(format)); - return "-" + str; - } - - wxCHECK_MSG( !format.empty(), wxEmptyString, - wxT("NULL format in wxTimeSpan::Format") ); - - wxString str; - str.Alloc(format.length()); - - // Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */) - // - // Then, of course, ts.Format("%H:%M:%S") must return "01:02:03", but the - // question is what should ts.Format("%S") do? The code here returns "3273" - // in this case (i.e. the total number of seconds, not just seconds % 60) - // because, for me, this call means "give me entire time interval in - // seconds" and not "give me the seconds part of the time interval" - // - // If we agree that it should behave like this, it is clear that the - // interpretation of each format specifier depends on the presence of the - // other format specs in the string: if there was "%H" before "%M", we - // should use GetMinutes() % 60, otherwise just GetMinutes() &c - - // we remember the most important unit found so far - TimeSpanPart partBiggest = Part_MSec; - - for ( wxString::const_iterator pch = format.begin(); pch != format.end(); ++pch ) - { - wxChar ch = *pch; - - if ( ch == wxT('%') ) - { - // the start of the format specification of the printf() below - wxString fmtPrefix(wxT('%')); - - // the number - long n; - - // the number of digits for the format string, 0 if unused - unsigned digits = 0; - - ch = *++pch; // get the format spec char - switch ( ch ) - { - default: - wxFAIL_MSG( wxT("invalid format character") ); - // fall through - - case wxT('%'): - str += ch; - - // skip the part below switch - continue; - - case wxT('D'): - n = GetDays(); - if ( partBiggest < Part_Day ) - { - n %= DAYS_PER_WEEK; - } - else - { - partBiggest = Part_Day; - } - break; - - case wxT('E'): - partBiggest = Part_Week; - n = GetWeeks(); - break; - - case wxT('H'): - n = GetHours(); - if ( partBiggest < Part_Hour ) - { - n %= HOURS_PER_DAY; - } - else - { - partBiggest = Part_Hour; - } - - digits = 2; - break; - - case wxT('l'): - n = GetMilliseconds().ToLong(); - if ( partBiggest < Part_MSec ) - { - n %= 1000; - } - //else: no need to reset partBiggest to Part_MSec, it is - // the least significant one anyhow - - digits = 3; - break; - - case wxT('M'): - n = GetMinutes(); - if ( partBiggest < Part_Min ) - { - n %= MIN_PER_HOUR; - } - else - { - partBiggest = Part_Min; - } - - digits = 2; - break; - - case wxT('S'): - n = GetSeconds().ToLong(); - if ( partBiggest < Part_Sec ) - { - n %= SEC_PER_MIN; - } - else - { - partBiggest = Part_Sec; - } - - digits = 2; - break; - } - - if ( digits ) - { - fmtPrefix << wxT("0") << digits; - } - - str += wxString::Format(fmtPrefix + wxT("ld"), n); - } - else - { - // normal character, just copy - str += ch; - } - } - - return str; -} - -#endif // wxUSE_DATETIME diff --git a/Source/3rd Party/wx/src/common/datstrm.cpp b/Source/3rd Party/wx/src/common/datstrm.cpp index 904e692e5..fd16e9223 100644 --- a/Source/3rd Party/wx/src/common/datstrm.cpp +++ b/Source/3rd Party/wx/src/common/datstrm.cpp @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: Mickael Gilabert // Created: 28/06/98 +// RCS-ID: $Id: datstrm.cpp 53028 2008-04-05 17:28:32Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,70 +24,27 @@ #include "wx/math.h" #endif //WX_PRECOMP -namespace -{ - -// helper unions used to swap bytes of floats and doubles -union Float32Data -{ - wxFloat32 f; - wxUint32 i; -}; - -union Float64Data -{ - wxFloat64 f; - wxUint32 i[2]; -}; - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// wxDataStreamBase -// ---------------------------------------------------------------------------- - -wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv) -#if wxUSE_UNICODE - : m_conv(conv.Clone()) -#endif // wxUSE_UNICODE -{ - // It is unused in non-Unicode build, so suppress a warning there. - wxUnusedVar(conv); - - m_be_order = false; - - // For compatibility with the existing data files, we use extended - // precision if it is available, i.e. if wxUSE_APPLE_IEEE is on. -#if wxUSE_APPLE_IEEE - m_useExtendedPrecision = true; -#endif // wxUSE_APPLE_IEEE -} - -#if wxUSE_UNICODE -void wxDataStreamBase::SetConv( const wxMBConv &conv ) -{ - delete m_conv; - m_conv = conv.Clone(); -} -#endif - -wxDataStreamBase::~wxDataStreamBase() -{ -#if wxUSE_UNICODE - delete m_conv; -#endif // wxUSE_UNICODE -} - // --------------------------------------------------------------------------- // wxDataInputStream // --------------------------------------------------------------------------- +#if wxUSE_UNICODE wxDataInputStream::wxDataInputStream(wxInputStream& s, const wxMBConv& conv) - : wxDataStreamBase(conv), - m_input(&s) + : m_input(&s), m_be_order(false), m_conv(conv.Clone()) +#else +wxDataInputStream::wxDataInputStream(wxInputStream& s) + : m_input(&s), m_be_order(false) +#endif { } +wxDataInputStream::~wxDataInputStream() +{ +#if wxUSE_UNICODE + delete m_conv; +#endif // wxUSE_UNICODE +} + #if wxHAS_INT64 wxUint64 wxDataInputStream::Read64() { @@ -131,48 +89,13 @@ wxUint8 wxDataInputStream::Read8() double wxDataInputStream::ReadDouble() { #if wxUSE_APPLE_IEEE - if ( m_useExtendedPrecision ) - { - char buf[10]; + char buf[10]; - m_input->Read(buf, 10); - return wxConvertFromIeeeExtended((const wxInt8 *)buf); - } - else -#endif // wxUSE_APPLE_IEEE - { - Float64Data floatData; - - if ( m_be_order == (wxBYTE_ORDER == wxBIG_ENDIAN) ) - { - floatData.i[0] = Read32(); - floatData.i[1] = Read32(); - } - else - { - floatData.i[1] = Read32(); - floatData.i[0] = Read32(); - } - - return static_cast(floatData.f); - } -} - -float wxDataInputStream::ReadFloat() -{ -#if wxUSE_APPLE_IEEE - if ( m_useExtendedPrecision ) - { - return (float)ReadDouble(); - } - else -#endif // wxUSE_APPLE_IEEE - { - Float32Data floatData; - - floatData.i = Read32(); - return static_cast(floatData.f); - } + m_input->Read(buf, 10); + return ConvertFromIeeeExtended((const wxInt8 *)buf); +#else + return 0.0; +#endif } wxString wxDataInputStream::ReadString() @@ -183,10 +106,11 @@ wxString wxDataInputStream::ReadString() if ( len > 0 ) { #if wxUSE_UNICODE - wxCharBuffer tmp(len); + wxCharBuffer tmp(len + 1); if ( tmp ) { m_input->Read(tmp.data(), len); + tmp.data()[len] = '\0'; ret = m_conv->cMB2WX(tmp.data()); } #else @@ -446,14 +370,6 @@ void wxDataInputStream::ReadDouble(double *buffer, size_t size) } } -void wxDataInputStream::ReadFloat(float *buffer, size_t size) -{ - for (wxUint32 i=0; i>(wxString& s) { s = ReadString(); @@ -524,15 +440,15 @@ wxDataInputStream& wxDataInputStream::operator>>(wxLongLong& i) } #endif // wxLongLong_t -wxDataInputStream& wxDataInputStream::operator>>(double& d) +wxDataInputStream& wxDataInputStream::operator>>(double& i) { - d = ReadDouble(); + i = ReadDouble(); return *this; } wxDataInputStream& wxDataInputStream::operator>>(float& f) { - f = ReadFloat(); + f = (float)ReadDouble(); return *this; } @@ -540,12 +456,23 @@ wxDataInputStream& wxDataInputStream::operator>>(float& f) // wxDataOutputStream // --------------------------------------------------------------------------- +#if wxUSE_UNICODE wxDataOutputStream::wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv) - : wxDataStreamBase(conv), - m_output(&s) + : m_output(&s), m_be_order(false), m_conv(conv.Clone()) +#else +wxDataOutputStream::wxDataOutputStream(wxOutputStream& s) + : m_output(&s), m_be_order(false) +#endif { } +wxDataOutputStream::~wxDataOutputStream() +{ +#if wxUSE_UNICODE + delete m_conv; +#endif // wxUSE_UNICODE +} + #if wxHAS_INT64 void wxDataOutputStream::Write64(wxUint64 i) { @@ -601,49 +528,17 @@ void wxDataOutputStream::WriteString(const wxString& string) void wxDataOutputStream::WriteDouble(double d) { + char buf[10]; + #if wxUSE_APPLE_IEEE - if ( m_useExtendedPrecision ) - { - char buf[10]; - - wxConvertToIeeeExtended(d, (wxInt8 *)buf); - m_output->Write(buf, 10); - } - else -#endif // wxUSE_APPLE_IEEE - { - Float64Data floatData; - - floatData.f = (wxFloat64)d; - - if ( m_be_order == (wxBYTE_ORDER == wxBIG_ENDIAN) ) - { - Write32(floatData.i[0]); - Write32(floatData.i[1]); - } - else - { - Write32(floatData.i[1]); - Write32(floatData.i[0]); - } - } -} - -void wxDataOutputStream::WriteFloat(float f) -{ -#if wxUSE_APPLE_IEEE - if ( m_useExtendedPrecision ) - { - WriteDouble((double)f); - } - else -#endif // wxUSE_APPLE_IEEE - { - Float32Data floatData; - - floatData.f = (wxFloat32)f; - Write32(floatData.i); - } + ConvertToIeeeExtended(d, (wxInt8 *)buf); +#else +#if !defined(__VMS__) && !defined(__GNUG__) +# pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!" +#endif + buf[0] = '\0'; +#endif + m_output->Write(buf, 10); } #if wxHAS_INT64 @@ -757,12 +652,11 @@ void wxDataOutputStream::WriteDouble(const double *buffer, size_t size) } } -void wxDataOutputStream::WriteFloat(const float *buffer, size_t size) +wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string) { - for (wxUint32 i=0; iWrite((const char *)string, wxStrlen(string)*sizeof(wxChar)); + return *this; } wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string) @@ -835,15 +729,15 @@ wxDataOutputStream& wxDataOutputStream::operator<<(const wxLongLong &i) } #endif // wxLongLong_t -wxDataOutputStream& wxDataOutputStream::operator<<(double d) +wxDataOutputStream& wxDataOutputStream::operator<<(double f) { - WriteDouble(d); + WriteDouble(f); return *this; } wxDataOutputStream& wxDataOutputStream::operator<<(float f) { - WriteFloat(f); + WriteDouble((double)f); return *this; } diff --git a/Source/3rd Party/wx/src/common/dcbase.cpp b/Source/3rd Party/wx/src/common/dcbase.cpp index c8008344f..ecc821d00 100644 --- a/Source/3rd Party/wx/src/common/dcbase.cpp +++ b/Source/3rd Party/wx/src/common/dcbase.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05/25/99 +// RCS-ID: $Id: dcbase.cpp 56135 2008-10-06 21:04:02Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,521 +25,48 @@ #endif #include "wx/dc.h" -#include "wx/dcclient.h" -#include "wx/dcmemory.h" -#include "wx/dcscreen.h" -#include "wx/dcprint.h" -#include "wx/prntbase.h" -#include "wx/scopeguard.h" +#include "wx/dcbuffer.h" // for IMPLEMENT_DYNAMIC_CLASS #ifndef WX_PRECOMP #include "wx/math.h" - #include "wx/module.h" - #include "wx/window.h" #endif -#include "wx/private/textmeasure.h" +// bool wxDCBase::sm_cacheing = false; -#ifdef __WXMSW__ - #include "wx/msw/dcclient.h" - #include "wx/msw/dcmemory.h" - #include "wx/msw/dcscreen.h" -#endif +IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject) -#ifdef __WXGTK3__ - #include "wx/gtk/dc.h" -#elif defined __WXGTK20__ - #include "wx/gtk/dcclient.h" - #include "wx/gtk/dcmemory.h" - #include "wx/gtk/dcscreen.h" -#elif defined(__WXGTK__) - #include "wx/gtk1/dcclient.h" - #include "wx/gtk1/dcmemory.h" - #include "wx/gtk1/dcscreen.h" -#endif +// ============================================================================ +// implementation +// ============================================================================ -#ifdef __WXMAC__ - #include "wx/osx/dcclient.h" - #include "wx/osx/dcmemory.h" - #include "wx/osx/dcscreen.h" -#endif +IMPLEMENT_DYNAMIC_CLASS(wxBufferedDC, wxMemoryDC) +IMPLEMENT_ABSTRACT_CLASS(wxBufferedPaintDC, wxBufferedDC) -#ifdef __WXPM__ - #include "wx/os2/dcclient.h" - #include "wx/os2/dcmemory.h" - #include "wx/os2/dcscreen.h" -#endif - -#ifdef __WXCOCOA__ - #include "wx/cocoa/dcclient.h" - #include "wx/cocoa/dcmemory.h" - #include "wx/cocoa/dcscreen.h" -#endif - -#ifdef __WXMOTIF__ - #include "wx/motif/dcclient.h" - #include "wx/motif/dcmemory.h" - #include "wx/motif/dcscreen.h" -#endif - -#ifdef __WXX11__ - #include "wx/x11/dcclient.h" - #include "wx/x11/dcmemory.h" - #include "wx/x11/dcscreen.h" -#endif - -#ifdef __WXDFB__ - #include "wx/dfb/dcclient.h" - #include "wx/dfb/dcmemory.h" - #include "wx/dfb/dcscreen.h" -#endif - -//---------------------------------------------------------------------------- -// wxDCFactory -//---------------------------------------------------------------------------- - -wxDCFactory *wxDCFactory::m_factory = NULL; - -void wxDCFactory::Set(wxDCFactory *factory) -{ - delete m_factory; - - m_factory = factory; -} - -wxDCFactory *wxDCFactory::Get() -{ - if ( !m_factory ) - m_factory = new wxNativeDCFactory; - - return m_factory; -} - -class wxDCFactoryCleanupModule : public wxModule -{ -public: - virtual bool OnInit() { return true; } - virtual void OnExit() { wxDCFactory::Set(NULL); } - -private: - DECLARE_DYNAMIC_CLASS(wxDCFactoryCleanupModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxDCFactoryCleanupModule, wxModule) - -//----------------------------------------------------------------------------- -// wxNativeDCFactory -//----------------------------------------------------------------------------- - -wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window ) -{ - wxDCImpl * const impl = new wxWindowDCImpl( owner, window ); - impl->InheritAttributes(window); - return impl; -} - -wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window ) -{ - wxDCImpl * const impl = new wxClientDCImpl( owner, window ); - impl->InheritAttributes(window); - return impl; -} - -wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window ) -{ - wxDCImpl * const impl = new wxPaintDCImpl( owner, window ); - impl->InheritAttributes(window); - return impl; -} - -wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner ) -{ - return new wxMemoryDCImpl( owner ); -} - -wxDCImpl* wxNativeDCFactory::CreateMemoryDC(wxMemoryDC *owner, wxBitmap& bitmap) -{ - // the bitmap may be modified when it's selected into a memory DC so make - // sure changing this bitmap doesn't affect any other shallow copies of it - // (see wxMemoryDC::SelectObject()) - // - // notice that we don't provide any ctor equivalent to SelectObjectAsSource - // method because this should be rarely needed and easy to work around by - // using the default ctor and calling SelectObjectAsSource itself - if ( bitmap.IsOk() ) - bitmap.UnShare(); - - return new wxMemoryDCImpl(owner, bitmap); -} - -wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) -{ - return new wxMemoryDCImpl( owner, dc ); -} - -wxDCImpl* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner ) -{ - return new wxScreenDCImpl( owner ); -} - -#if wxUSE_PRINTING_ARCHITECTURE -wxDCImpl *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) -{ - wxPrintFactory *factory = wxPrintFactory::GetFactory(); - return factory->CreatePrinterDCImpl( owner, data ); -} -#endif - -//----------------------------------------------------------------------------- -// wxWindowDC -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxWindowDC, wxDC) - -wxWindowDC::wxWindowDC(wxWindow *win) - : wxDC(wxDCFactory::Get()->CreateWindowDC(this, win)) +#if WXWIN_COMPATIBILITY_2_6 +void wxDCBase::BeginDrawing() { } -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxClientDC, wxWindowDC) - -wxClientDC::wxClientDC(wxWindow *win) - : wxWindowDC(wxDCFactory::Get()->CreateClientDC(this, win)) -{ -} - -//----------------------------------------------------------------------------- -// wxMemoryDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) - -wxMemoryDC::wxMemoryDC() - : wxDC(wxDCFactory::Get()->CreateMemoryDC(this)) -{ -} - -wxMemoryDC::wxMemoryDC(wxBitmap& bitmap) - : wxDC(wxDCFactory::Get()->CreateMemoryDC(this, bitmap)) -{ -} - -wxMemoryDC::wxMemoryDC(wxDC *dc) - : wxDC(wxDCFactory::Get()->CreateMemoryDC(this, dc)) -{ -} - -void wxMemoryDC::SelectObject(wxBitmap& bmp) -{ - if ( bmp.IsSameAs(GetSelectedBitmap()) ) - { - // Nothing to do, this bitmap is already selected. - return; - } - - // make sure that the given wxBitmap is not sharing its data with other - // wxBitmap instances as its contents will be modified by any drawing - // operation done on this DC - if (bmp.IsOk()) - bmp.UnShare(); - - GetImpl()->DoSelect(bmp); -} - -void wxMemoryDC::SelectObjectAsSource(const wxBitmap& bmp) -{ - GetImpl()->DoSelect(bmp); -} - -const wxBitmap& wxMemoryDC::GetSelectedBitmap() const -{ - return GetImpl()->GetSelectedBitmap(); -} - -wxBitmap& wxMemoryDC::GetSelectedBitmap() -{ - return GetImpl()->GetSelectedBitmap(); -} - - -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxPaintDC, wxClientDC) - -wxPaintDC::wxPaintDC(wxWindow *win) - : wxClientDC(wxDCFactory::Get()->CreatePaintDC(this, win)) -{ -} - -//----------------------------------------------------------------------------- -// wxScreenDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) - -wxScreenDC::wxScreenDC() - : wxDC(wxDCFactory::Get()->CreateScreenDC(this)) -{ -} - -//----------------------------------------------------------------------------- -// wxPrinterDC -//----------------------------------------------------------------------------- - -#if wxUSE_PRINTING_ARCHITECTURE - -IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC) - -wxPrinterDC::wxPrinterDC() - : wxDC(wxDCFactory::Get()->CreatePrinterDC(this, wxPrintData())) -{ -} - -wxPrinterDC::wxPrinterDC(const wxPrintData& data) - : wxDC(wxDCFactory::Get()->CreatePrinterDC(this, data)) -{ -} - -wxRect wxPrinterDC::GetPaperRect() const -{ - return GetImpl()->GetPaperRect(); -} - -int wxPrinterDC::GetResolution() const -{ - return GetImpl()->GetResolution(); -} - -#endif // wxUSE_PRINTING_ARCHITECTURE - -//----------------------------------------------------------------------------- -// wxDCImpl -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDCImpl, wxObject) - -wxDCImpl::wxDCImpl( wxDC *owner ) - : m_window(NULL) - , m_colour(wxColourDisplay()) - , m_ok(true) - , m_clipping(false) - , m_isInteractive(0) - , m_isBBoxValid(false) - , m_logicalOriginX(0), m_logicalOriginY(0) - , m_deviceOriginX(0), m_deviceOriginY(0) - , m_deviceLocalOriginX(0), m_deviceLocalOriginY(0) - , m_logicalScaleX(1.0), m_logicalScaleY(1.0) - , m_userScaleX(1.0), m_userScaleY(1.0) - , m_scaleX(1.0), m_scaleY(1.0) - , m_signX(1), m_signY(1) - , m_contentScaleFactor(1) - , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) - , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0) - , m_logicalFunction(wxCOPY) - , m_backgroundMode(wxBRUSHSTYLE_TRANSPARENT) - , m_mappingMode(wxMM_TEXT) - , m_pen() - , m_brush() - , m_backgroundBrush() - , m_textForegroundColour(*wxBLACK) - , m_textBackgroundColour(*wxWHITE) - , m_font() -#if wxUSE_PALETTE - , m_palette() - , m_hasCustomPalette(false) -#endif // wxUSE_PALETTE -{ - m_owner = owner; - - m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / - (double)wxGetDisplaySizeMM().GetWidth(); - m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / - (double)wxGetDisplaySizeMM().GetHeight(); - - ResetBoundingBox(); - ResetClipping(); -} - -wxDCImpl::~wxDCImpl() +void wxDCBase::EndDrawing() { } +#endif // WXWIN_COMPATIBILITY_2_6 // ---------------------------------------------------------------------------- -// clipping +// special symbols // ---------------------------------------------------------------------------- -void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) -{ - if ( m_clipping ) - { - m_clipX1 = wxMax( m_clipX1, x ); - m_clipY1 = wxMax( m_clipY1, y ); - m_clipX2 = wxMin( m_clipX2, (x + w) ); - m_clipY2 = wxMin( m_clipY2, (y + h) ); - } - else - { - m_clipping = true; - - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + w; - m_clipY2 = y + h; - } -} - -// ---------------------------------------------------------------------------- -// coordinate conversions and transforms -// ---------------------------------------------------------------------------- - -wxCoord wxDCImpl::DeviceToLogicalX(wxCoord x) const -{ - return wxRound( (double)((x - m_deviceOriginX - m_deviceLocalOriginX) * m_signX) / m_scaleX ) + m_logicalOriginX ; -} - -wxCoord wxDCImpl::DeviceToLogicalY(wxCoord y) const -{ - return wxRound( (double)((y - m_deviceOriginY - m_deviceLocalOriginY) * m_signY) / m_scaleY ) + m_logicalOriginY ; -} - -wxCoord wxDCImpl::DeviceToLogicalXRel(wxCoord x) const -{ - return wxRound((double)(x) / m_scaleX); -} - -wxCoord wxDCImpl::DeviceToLogicalYRel(wxCoord y) const -{ - return wxRound((double)(y) / m_scaleY); -} - -wxCoord wxDCImpl::LogicalToDeviceX(wxCoord x) const -{ - return wxRound( (double)((x - m_logicalOriginX) * m_signX) * m_scaleX) + m_deviceOriginX + m_deviceLocalOriginX; -} - -wxCoord wxDCImpl::LogicalToDeviceY(wxCoord y) const -{ - return wxRound( (double)((y - m_logicalOriginY) * m_signY) * m_scaleY) + m_deviceOriginY + m_deviceLocalOriginY; -} - -wxCoord wxDCImpl::LogicalToDeviceXRel(wxCoord x) const -{ - return wxRound((double)(x) * m_scaleX); -} - -wxCoord wxDCImpl::LogicalToDeviceYRel(wxCoord y) const -{ - return wxRound((double)(y) * m_scaleY); -} - -void wxDCImpl::ComputeScaleAndOrigin() -{ - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; -} - -void wxDCImpl::SetMapMode( wxMappingMode mode ) -{ - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; - case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; - case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; - case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; - default: - case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - } - m_mappingMode = mode; -} - -void wxDCImpl::SetUserScale( double x, double y ) -{ - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDCImpl::SetLogicalScale( double x, double y ) -{ - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDCImpl::SetLogicalOrigin( wxCoord x, wxCoord y ) -{ - m_logicalOriginX = x * m_signX; - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); -} - -void wxDCImpl::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - m_deviceOriginX = x; - m_deviceOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDCImpl::SetDeviceLocalOrigin( wxCoord x, wxCoord y ) -{ - m_deviceLocalOriginX = x; - m_deviceLocalOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there - // wxWidgets 2.9: no longer override it - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -} - -bool wxDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const -{ - wxTextMeasure tm(GetOwner(), &m_font); - return tm.GetPartialTextExtents(text, widths, m_scaleX); -} - -void wxDCImpl::GetMultiLineTextExtent(const wxString& text, - wxCoord *x, - wxCoord *y, - wxCoord *h, - const wxFont *font) const -{ - wxTextMeasure tm(GetOwner(), font && font->IsOk() ? font : &m_font); - tm.GetMultiLineTextExtent(text, x, y, h); -} - -void wxDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, +void wxDCBase::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) { - wxCHECK_RET( IsOk(), wxT("invalid window dc") ); + wxCHECK_RET( Ok(), wxT("invalid window dc") ); wxCoord x2 = x1 + width, y2 = y1 + height; // the pen width is calibrated to give 3 for width == height == 10 - wxDCPenChanger pen( *m_owner, wxPen(GetTextForeground(), (width + height + 1)/7)); + wxDCPenChanger pen((wxDC&)*this, + wxPen(GetTextForeground(), (width + height + 1)/7)); // we're drawing a scaled version of wx/generic/tick.xpm here wxCoord x3 = x1 + (4*width) / 10, // x of the tick bottom @@ -550,47 +78,19 @@ void wxDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, CalcBoundingBox(x2, y2); } -bool -wxDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode rop, - bool useMask, - wxCoord xsrcMask, - wxCoord ysrcMask) -{ - wxCHECK_MSG( srcWidth && srcHeight && dstWidth && dstHeight, false, - wxT("invalid blit size") ); +// ---------------------------------------------------------------------------- +// line/polygons +// ---------------------------------------------------------------------------- - // emulate the stretching by modifying the DC scale - double xscale = (double)srcWidth/dstWidth, - yscale = (double)srcHeight/dstHeight; - - double xscaleOld, yscaleOld; - GetUserScale(&xscaleOld, &yscaleOld); - SetUserScale(xscaleOld/xscale, yscaleOld/yscale); - - bool rc = DoBlit(wxCoord(xdest*xscale), wxCoord(ydest*yscale), - wxCoord(dstWidth*xscale), wxCoord(dstHeight*yscale), - source, - xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); - - SetUserScale(xscaleOld, yscaleOld); - - return rc; -} - -void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset) +void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset) { int n = list->GetCount(); wxPoint *points = new wxPoint[n]; int i = 0; - for ( wxPointList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) + for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { - wxPoint *point = node->GetData(); + wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; points[i].y = point->y; } @@ -600,17 +100,18 @@ void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffs delete [] points; } -void wxDCImpl::DrawPolygon(const wxPointList *list, + +void wxDCBase::DrawPolygon(const wxList *list, wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle) + int fillStyle) { int n = list->GetCount(); wxPoint *points = new wxPoint[n]; int i = 0; - for ( wxPointList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) + for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { - wxPoint *point = node->GetData(); + wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; points[i].y = point->y; } @@ -621,11 +122,11 @@ void wxDCImpl::DrawPolygon(const wxPointList *list, } void -wxDCImpl::DoDrawPolyPolygon(int n, - const int count[], - const wxPoint points[], +wxDCBase::DoDrawPolyPolygon(int n, + int count[], + wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle) + int fillStyle) { if ( n == 1 ) { @@ -635,6 +136,7 @@ wxDCImpl::DoDrawPolyPolygon(int n, int i, j, lastOfs; wxPoint* pts; + wxPen pen; for (i = j = lastOfs = 0; i < n; i++) { @@ -650,11 +152,10 @@ wxDCImpl::DoDrawPolyPolygon(int n, pts[j++] = pts[lastOfs]; } - { - wxDCPenChanger setTransp(*m_owner, *wxTRANSPARENT_PEN); - DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle); - } - + pen = GetPen(); + SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT)); + DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle); + SetPen(pen); for (i = j = 0; i < n; i++) { DoDrawLines(count[i], pts+j, xoffset, yoffset); @@ -663,21 +164,45 @@ wxDCImpl::DoDrawPolyPolygon(int n, delete[] pts; } +// ---------------------------------------------------------------------------- +// splines +// ---------------------------------------------------------------------------- + #if wxUSE_SPLINES -void wxDCImpl::DrawSpline(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord x3, wxCoord y3) +// TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) +void wxDCBase::DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) { - wxPoint points[] = { wxPoint(x1, y1), wxPoint(x2, y2), wxPoint(x3, y3) }; - DrawSpline(WXSIZEOF(points), points); + wxList point_list; + + wxPoint *point1 = new wxPoint; + point1->x = x1; point1->y = y1; + point_list.Append((wxObject*)point1); + + wxPoint *point2 = new wxPoint; + point2->x = x2; point2->y = y2; + point_list.Append((wxObject*)point2); + + wxPoint *point3 = new wxPoint; + point3->x = x3; point3->y = y3; + point_list.Append((wxObject*)point3); + + DrawSpline(&point_list); + + for( wxList::compatibility_iterator node = point_list.GetFirst(); node; node = node->GetNext() ) + { + wxPoint *p = (wxPoint *)node->GetData(); + delete p; + } } -void wxDCImpl::DrawSpline(int n, const wxPoint points[]) +void wxDCBase::DrawSpline(int n, wxPoint points[]) { - wxPointList list; - for ( int i = 0; i < n; i++ ) - list.Append(const_cast(&points[i])); + wxList list; + for (int i =0; i < n; i++) + { + list.Append((wxObject*)&points[i]); + } DrawSpline(&list); } @@ -692,9 +217,9 @@ int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); static bool wx_spline_add_point(double x, double y); -static void wx_spline_draw_point_array(wxDC *dc); +static void wx_spline_draw_point_array(wxDCBase *dc); -static wxPointList wx_spline_point_list; +wxList wx_spline_point_list; #define half(z1, z2) ((z1+z2)/2.0) #define THRESHOLD 5 @@ -704,8 +229,8 @@ static wxPointList wx_spline_point_list; void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4, double b4) { - double xmid, ymid; - double x1, y1, x2, y2, x3, y3, x4, y4; + register double xmid, ymid; + double x1, y1, x2, y2, x3, y3, x4, y4; wx_clear_stack(); wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4); @@ -777,44 +302,46 @@ int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, static bool wx_spline_add_point(double x, double y) { - wxPoint *point = new wxPoint( wxRound(x), wxRound(y) ); - wx_spline_point_list.Append(point ); - return true; + wxPoint *point = new wxPoint ; + point->x = (int) x; + point->y = (int) y; + wx_spline_point_list.Append((wxObject*)point); + return true; } -static void wx_spline_draw_point_array(wxDC *dc) +static void wx_spline_draw_point_array(wxDCBase *dc) { - dc->DrawLines(&wx_spline_point_list, 0, 0 ); - wxPointList::compatibility_iterator node = wx_spline_point_list.GetFirst(); - while (node) - { - wxPoint *point = node->GetData(); - delete point; - wx_spline_point_list.Erase(node); - node = wx_spline_point_list.GetFirst(); - } + dc->DrawLines(&wx_spline_point_list, 0, 0 ); + wxList::compatibility_iterator node = wx_spline_point_list.GetFirst(); + while (node) + { + wxPoint *point = (wxPoint *)node->GetData(); + delete point; + wx_spline_point_list.Erase(node); + node = wx_spline_point_list.GetFirst(); + } } -void wxDCImpl::DoDrawSpline( const wxPointList *points ) +void wxDCBase::DoDrawSpline( wxList *points ) { - wxCHECK_RET( IsOk(), wxT("invalid window dc") ); + wxCHECK_RET( Ok(), wxT("invalid window dc") ); - const wxPoint *p; + wxPoint *p; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; double x1, y1, x2, y2; - wxPointList::compatibility_iterator node = points->GetFirst(); + wxList::compatibility_iterator node = points->GetFirst(); if (!node) // empty list return; - p = node->GetData(); + p = (wxPoint *)node->GetData(); x1 = p->x; y1 = p->y; node = node->GetNext(); - p = node->GetData(); + p = (wxPoint *)node->GetData(); x2 = p->x; y2 = p->y; @@ -826,12 +353,12 @@ void wxDCImpl::DoDrawSpline( const wxPointList *points ) wx_spline_add_point(x1, y1); while ((node = node->GetNext()) -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL != NULL -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL ) { - p = node->GetData(); + p = (wxPoint *)node->GetData(); x1 = x2; y1 = y2; x2 = p->x; @@ -852,14 +379,319 @@ void wxDCImpl::DoDrawSpline( const wxPointList *points ) wx_spline_add_point( cx1, cy1 ); wx_spline_add_point( x2, y2 ); - wx_spline_draw_point_array( m_owner ); + wx_spline_draw_point_array( this ); } #endif // wxUSE_SPLINES +// ---------------------------------------------------------------------------- +// Partial Text Extents +// ---------------------------------------------------------------------------- -void wxDCImpl::DoGradientFillLinear(const wxRect& rect, +// Each element of the widths array will be the width of the string up to and +// including the corresponding character in text. This is the generic +// implementation, the port-specific classes should do this with native APIs +// if available and if faster. Note: pango_layout_index_to_pos is much slower +// than calling GetTextExtent!! + +#define FWC_SIZE 256 + +class FontWidthCache +{ +public: + FontWidthCache() : m_scaleX(1), m_widths(NULL) { } + ~FontWidthCache() { delete []m_widths; } + + void Reset() + { + if (!m_widths) + m_widths = new int[FWC_SIZE]; + + memset(m_widths, 0, sizeof(int)*FWC_SIZE); + } + + wxFont m_font; + double m_scaleX; + int *m_widths; +}; + +static FontWidthCache s_fontWidthCache; + +bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +{ + int totalWidth = 0; + + const size_t len = text.length(); + widths.Empty(); + widths.Add(0, len); + + // reset the cache if font or horizontal scale have changed + if ( !s_fontWidthCache.m_widths || + !wxIsSameDouble(s_fontWidthCache.m_scaleX, m_scaleX) || + (s_fontWidthCache.m_font != GetFont()) ) + { + s_fontWidthCache.Reset(); + s_fontWidthCache.m_font = GetFont(); + s_fontWidthCache.m_scaleX = m_scaleX; + } + + // Calculate the position of each character based on the widths of + // the previous characters + int w, h; + for ( size_t i = 0; i < len; i++ ) + { + const wxChar c = text[i]; + unsigned int c_int = (unsigned int)c; + + if ((c_int < FWC_SIZE) && (s_fontWidthCache.m_widths[c_int] != 0)) + { + w = s_fontWidthCache.m_widths[c_int]; + } + else + { + GetTextExtent(c, &w, &h); + if (c_int < FWC_SIZE) + s_fontWidthCache.m_widths[c_int] = w; + } + + totalWidth += w; + widths[i] = totalWidth; + } + + return true; +} + + +// ---------------------------------------------------------------------------- +// enhanced text drawing +// ---------------------------------------------------------------------------- + +void wxDCBase::GetMultiLineTextExtent(const wxString& text, + wxCoord *x, + wxCoord *y, + wxCoord *h, + wxFont *font) const +{ + wxCoord widthTextMax = 0, widthLine, + heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; + + wxString curLine; + for ( const wxChar *pc = text; ; pc++ ) + { + if ( *pc == _T('\n') || *pc == _T('\0') ) + { + if ( curLine.empty() ) + { + // we can't use GetTextExtent - it will return 0 for both width + // and height and an empty line should count in height + // calculation + + // assume that this line has the same height as the previous + // one + if ( !heightLineDefault ) + heightLineDefault = heightLine; + + if ( !heightLineDefault ) + { + // but we don't know it yet - choose something reasonable + GetTextExtent(_T("W"), NULL, &heightLineDefault, + NULL, NULL, font); + } + + heightTextTotal += heightLineDefault; + } + else + { + GetTextExtent(curLine, &widthLine, &heightLine, + NULL, NULL, font); + if ( widthLine > widthTextMax ) + widthTextMax = widthLine; + heightTextTotal += heightLine; + } + + if ( *pc == _T('\n') ) + { + curLine.clear(); + } + else + { + // the end of string + break; + } + } + else + { + curLine += *pc; + } + } + + if ( x ) + *x = widthTextMax; + if ( y ) + *y = heightTextTotal; + if ( h ) + *h = heightLine; +} + +void wxDCBase::DrawLabel(const wxString& text, + const wxBitmap& bitmap, + const wxRect& rect, + int alignment, + int indexAccel, + wxRect *rectBounding) +{ + // find the text position + wxCoord widthText, heightText, heightLine; + GetMultiLineTextExtent(text, &widthText, &heightText, &heightLine); + + wxCoord width, height; + if ( bitmap.Ok() ) + { + width = widthText + bitmap.GetWidth(); + height = bitmap.GetHeight(); + } + else // no bitmap + { + width = widthText; + height = heightText; + } + + wxCoord x, y; + if ( alignment & wxALIGN_RIGHT ) + { + x = rect.GetRight() - width; + } + else if ( alignment & wxALIGN_CENTRE_HORIZONTAL ) + { + x = (rect.GetLeft() + rect.GetRight() + 1 - width) / 2; + } + else // alignment & wxALIGN_LEFT + { + x = rect.GetLeft(); + } + + if ( alignment & wxALIGN_BOTTOM ) + { + y = rect.GetBottom() - height; + } + else if ( alignment & wxALIGN_CENTRE_VERTICAL ) + { + y = (rect.GetTop() + rect.GetBottom() + 1 - height) / 2; + } + else // alignment & wxALIGN_TOP + { + y = rect.GetTop(); + } + + // draw the bitmap first + wxCoord x0 = x, + y0 = y, + width0 = width; + if ( bitmap.Ok() ) + { + DrawBitmap(bitmap, x, y, true /* use mask */); + + wxCoord offset = bitmap.GetWidth() + 4; + x += offset; + width -= offset; + + y += (height - heightText) / 2; + } + + // we will draw the underscore under the accel char later + wxCoord startUnderscore = 0, + endUnderscore = 0, + yUnderscore = 0; + + // split the string into lines and draw each of them separately + wxString curLine; + for ( const wxChar *pc = text; ; pc++ ) + { + if ( *pc == _T('\n') || *pc == _T('\0') ) + { + int xRealStart = x; // init it here to avoid compielr warnings + + if ( !curLine.empty() ) + { + // NB: can't test for !(alignment & wxALIGN_LEFT) because + // wxALIGN_LEFT is 0 + if ( alignment & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL) ) + { + wxCoord widthLine; + GetTextExtent(curLine, &widthLine, NULL); + + if ( alignment & wxALIGN_RIGHT ) + { + xRealStart += width - widthLine; + } + else // if ( alignment & wxALIGN_CENTRE_HORIZONTAL ) + { + xRealStart += (width - widthLine) / 2; + } + } + //else: left aligned, nothing to do + + DrawText(curLine, xRealStart, y); + } + + y += heightLine; + + // do we have underscore in this line? we can check yUnderscore + // because it is set below to just y + heightLine if we do + if ( y == yUnderscore ) + { + // adjust the horz positions to account for the shift + startUnderscore += xRealStart; + endUnderscore += xRealStart; + } + + if ( *pc == _T('\0') ) + break; + + curLine.clear(); + } + else // not end of line + { + if ( pc - text.c_str() == indexAccel ) + { + // remeber to draw underscore here + GetTextExtent(curLine, &startUnderscore, NULL); + curLine += *pc; + GetTextExtent(curLine, &endUnderscore, NULL); + + yUnderscore = y + heightLine; + } + else + { + curLine += *pc; + } + } + } + + // draw the underscore if found + if ( startUnderscore != endUnderscore ) + { + // it should be of the same colour as text + SetPen(wxPen(GetTextForeground(), 0, wxSOLID)); + + yUnderscore--; + + DrawLine(startUnderscore, yUnderscore, endUnderscore, yUnderscore); + } + + // return bounding rect if requested + if ( rectBounding ) + { + *rectBounding = wxRect(x, y - heightText, widthText, heightText); + } + + CalcBoundingBox(x0, y0); + CalcBoundingBox(x0 + width0, y0 + height); +} + + +void wxDCBase::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) @@ -903,13 +735,13 @@ void wxDCImpl::DoGradientFillLinear(const wxRect& rect, nB = nB1 + (nB2-nB1)*(w-x)/w; wxColour colour(nR,nG,nB); - SetPen(wxPen(colour, 1, wxPENSTYLE_SOLID)); + SetPen(wxPen(colour, 1, wxSOLID)); SetBrush(wxBrush(colour)); if(nDirection == wxEAST) - DoDrawRectangle(rect.GetRight()-x-xDelta+1, rect.GetTop(), + DrawRectangle(rect.GetRight()-x-xDelta+1, rect.GetTop(), xDelta, rect.GetHeight()); else //nDirection == wxWEST - DoDrawRectangle(rect.GetLeft()+x, rect.GetTop(), + DrawRectangle(rect.GetLeft()+x, rect.GetTop(), xDelta, rect.GetHeight()); } } @@ -940,13 +772,13 @@ void wxDCImpl::DoGradientFillLinear(const wxRect& rect, nB = nB1 + (nB2-nB1)*(w-y)/w; wxColour colour(nR,nG,nB); - SetPen(wxPen(colour, 1, wxPENSTYLE_SOLID)); + SetPen(wxPen(colour, 1, wxSOLID)); SetBrush(wxBrush(colour)); if(nDirection == wxNORTH) - DoDrawRectangle(rect.GetLeft(), rect.GetTop()+y, + DrawRectangle(rect.GetLeft(), rect.GetTop()+y, rect.GetWidth(), yDelta); else //nDirection == wxSOUTH - DoDrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta+1, + DrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta+1, rect.GetWidth(), yDelta); } } @@ -955,14 +787,13 @@ void wxDCImpl::DoGradientFillLinear(const wxRect& rect, SetBrush(oldBrush); } -void wxDCImpl::DoGradientFillConcentric(const wxRect& rect, +void wxDCBase::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) { - // save the old pen and ensure it is restored on exit - const wxPen penOrig = m_pen; - wxON_BLOCK_EXIT_SET(m_pen, penOrig); + //save the old pen color + wxColour oldPenColour = m_pen.GetColour(); wxUint8 nR1 = destColour.Red(); wxUint8 nG1 = destColour.Green(); @@ -974,331 +805,47 @@ void wxDCImpl::DoGradientFillConcentric(const wxRect& rect, //Radius - double cx = rect.GetWidth() / 2; - double cy = rect.GetHeight() / 2; - double dRadius; + wxInt32 cx = rect.GetWidth() / 2; + wxInt32 cy = rect.GetHeight() / 2; + wxInt32 nRadius; if (cx < cy) - dRadius = cx; + nRadius = cx; else - dRadius = cy; + nRadius = cy; //Offset of circle - double ptX, ptY; - ptX = circleCenter.x; - ptY = circleCenter.y; - double nCircleOffX = ptX - cx; - double nCircleOffY = ptY - cy; - - double dGradient; - double dx, dy; + wxInt32 nCircleOffX = circleCenter.x - (rect.GetWidth() / 2); + wxInt32 nCircleOffY = circleCenter.y - (rect.GetHeight() / 2); for ( wxInt32 x = 0; x < rect.GetWidth(); x++ ) { for ( wxInt32 y = 0; y < rect.GetHeight(); y++ ) { //get color difference - dx = x; - dy = y; - - dGradient = ((dRadius - sqrt( (dx - cx - nCircleOffX) * (dx - cx - nCircleOffX) - +(dy - cy - nCircleOffY) * (dy - cy - nCircleOffY) - ) - ) * 100 - ) / dRadius; + wxInt32 nGradient = ((nRadius - + (wxInt32)sqrt( + pow((double)(x - cx - nCircleOffX), 2) + + pow((double)(y - cy - nCircleOffY), 2) + )) * 100) / nRadius; //normalize Gradient - if (dGradient < 0) - dGradient = 0.0; + if (nGradient < 0 ) + nGradient = 0; //get dest colors - nR = (wxUint8)(nR1 + ((nR2 - nR1) * dGradient / 100)); - nG = (wxUint8)(nG1 + ((nG2 - nG1) * dGradient / 100)); - nB = (wxUint8)(nB1 + ((nB2 - nB1) * dGradient / 100)); + nR = (wxUint8)(nR1 + ((nR2 - nR1) * nGradient / 100)); + nG = (wxUint8)(nG1 + ((nG2 - nG1) * nGradient / 100)); + nB = (wxUint8)(nB1 + ((nB2 - nB1) * nGradient / 100)); //set the pixel - SetPen(wxColour(nR,nG,nB)); - DoDrawPoint(x + rect.GetLeft(), y + rect.GetTop()); + m_pen.SetColour(wxColour(nR,nG,nB)); + DrawPoint(wxPoint(x + rect.GetLeft(), y + rect.GetTop())); } } + //return old pen color + m_pen.SetColour(oldPenColour); } -void wxDCImpl::InheritAttributes(wxWindow *win) -{ - wxCHECK_RET( win, "window can't be NULL" ); - - SetFont(win->GetFont()); - SetTextForeground(win->GetForegroundColour()); - SetTextBackground(win->GetBackgroundColour()); - SetBackground(win->GetBackgroundColour()); - SetLayoutDirection(win->GetLayoutDirection()); -} - -void wxDCImpl::DoGetFontMetrics(int *height, - int *ascent, - int *descent, - int *internalLeading, - int *externalLeading, - int *averageWidth) const -{ - // Average width is typically the same as width of 'x'. - wxCoord h, d; - DoGetTextExtent("x", averageWidth, &h, &d, externalLeading); - - if ( height ) - *height = h; - if ( ascent ) - *ascent = h - d; - if ( descent ) - *descent = d; - if ( internalLeading ) - *internalLeading = 0; -} - -//----------------------------------------------------------------------------- -// wxDC -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) - -void wxDC::CopyAttributes(const wxDC& dc) -{ - SetFont(dc.GetFont()); - SetTextForeground(dc.GetTextForeground()); - SetTextBackground(dc.GetTextBackground()); - SetBackground(dc.GetBackground()); - SetLayoutDirection(dc.GetLayoutDirection()); -} - -void wxDC::DrawLabel(const wxString& text, - const wxBitmap& bitmap, - const wxRect& rect, - int alignment, - int indexAccel, - wxRect *rectBounding) -{ - // find the text position - wxCoord widthText, heightText, heightLine; - GetMultiLineTextExtent(text, &widthText, &heightText, &heightLine); - - wxCoord width, height; - if ( bitmap.IsOk() ) - { - width = widthText + bitmap.GetWidth(); - height = bitmap.GetHeight(); - } - else // no bitmap - { - width = widthText; - height = heightText; - } - - wxCoord x, y; - if ( alignment & wxALIGN_RIGHT ) - { - x = rect.GetRight() - width; - } - else if ( alignment & wxALIGN_CENTRE_HORIZONTAL ) - { - x = (rect.GetLeft() + rect.GetRight() + 1 - width) / 2; - } - else // alignment & wxALIGN_LEFT - { - x = rect.GetLeft(); - } - - if ( alignment & wxALIGN_BOTTOM ) - { - y = rect.GetBottom() - height; - } - else if ( alignment & wxALIGN_CENTRE_VERTICAL ) - { - y = (rect.GetTop() + rect.GetBottom() + 1 - height) / 2; - } - else // alignment & wxALIGN_TOP - { - y = rect.GetTop(); - } - - // draw the bitmap first - wxCoord x0 = x, - y0 = y, - width0 = width; - if ( bitmap.IsOk() ) - { - DrawBitmap(bitmap, x, y, true /* use mask */); - - wxCoord offset = bitmap.GetWidth() + 4; - x += offset; - width -= offset; - - y += (height - heightText) / 2; - } - - // we will draw the underscore under the accel char later - wxCoord startUnderscore = 0, - endUnderscore = 0, - yUnderscore = 0; - - // split the string into lines and draw each of them separately - // - // NB: while wxDC::DrawText() on some platforms supports drawing multi-line - // strings natively, this is not the case for all of them, notably not - // wxMSW which uses this function for multi-line texts, so we may only - // call DrawText() for single-line strings from here to avoid infinite - // recursion. - wxString curLine; - for ( wxString::const_iterator pc = text.begin(); ; ++pc ) - { - if ( pc == text.end() || *pc == '\n' ) - { - int xRealStart = x; // init it here to avoid compielr warnings - - if ( !curLine.empty() ) - { - // NB: can't test for !(alignment & wxALIGN_LEFT) because - // wxALIGN_LEFT is 0 - if ( alignment & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL) ) - { - wxCoord widthLine; - GetTextExtent(curLine, &widthLine, NULL); - - if ( alignment & wxALIGN_RIGHT ) - { - xRealStart += width - widthLine; - } - else // if ( alignment & wxALIGN_CENTRE_HORIZONTAL ) - { - xRealStart += (width - widthLine) / 2; - } - } - //else: left aligned, nothing to do - - DrawText(curLine, xRealStart, y); - } - - y += heightLine; - - // do we have underscore in this line? we can check yUnderscore - // because it is set below to just y + heightLine if we do - if ( y == yUnderscore ) - { - // adjust the horz positions to account for the shift - startUnderscore += xRealStart; - endUnderscore += xRealStart; - } - - if ( pc == text.end() ) - break; - - curLine.clear(); - } - else // not end of line - { - if ( pc - text.begin() == indexAccel ) - { - // remember to draw underscore here - GetTextExtent(curLine, &startUnderscore, NULL); - curLine += *pc; - GetTextExtent(curLine, &endUnderscore, NULL); - - yUnderscore = y + heightLine; - } - else - { - curLine += *pc; - } - } - } - - // draw the underscore if found - if ( startUnderscore != endUnderscore ) - { - // it should be of the same colour as text - SetPen(wxPen(GetTextForeground(), 0, wxPENSTYLE_SOLID)); - - // This adjustment is relatively arbitrary: we need to draw the - // underline slightly higher to avoid overflowing the character cell - // but whether we should do it 1, 2 or 3 pixels higher is not clear. - // - // The currently used value seems to be compatible with native MSW - // behaviour, i.e. it results in the same appearance of the owner-drawn - // and normal labels. - yUnderscore -= 2; - - DrawLine(startUnderscore, yUnderscore, endUnderscore, yUnderscore); - } - - // return bounding rect if requested - if ( rectBounding ) - { - *rectBounding = wxRect(x, y - heightText, widthText, heightText); - } - - CalcBoundingBox(x0, y0); - CalcBoundingBox(x0 + width0, y0 + height); -} - -#if WXWIN_COMPATIBILITY_2_8 - // for compatibility with the old code when wxCoord was long everywhere -void wxDC::GetTextExtent(const wxString& string, - long *x, long *y, - long *descent, - long *externalLeading, - const wxFont *theFont) const - { - wxCoord x2, y2, descent2, externalLeading2; - m_pimpl->DoGetTextExtent(string, &x2, &y2, - &descent2, &externalLeading2, - theFont); - if ( x ) - *x = x2; - if ( y ) - *y = y2; - if ( descent ) - *descent = descent2; - if ( externalLeading ) - *externalLeading = externalLeading2; - } - -void wxDC::GetLogicalOrigin(long *x, long *y) const - { - wxCoord x2, y2; - m_pimpl->DoGetLogicalOrigin(&x2, &y2); - if ( x ) - *x = x2; - if ( y ) - *y = y2; - } - -void wxDC::GetDeviceOrigin(long *x, long *y) const - { - wxCoord x2, y2; - m_pimpl->DoGetDeviceOrigin(&x2, &y2); - if ( x ) - *x = x2; - if ( y ) - *y = y2; - } - -void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const - { - wxCoord xx,yy,ww,hh; - m_pimpl->DoGetClippingBox(&xx, &yy, &ww, &hh); - if (x) *x = xx; - if (y) *y = yy; - if (w) *w = ww; - if (h) *h = hh; - } - -void wxDC::DrawObject(wxDrawObject* drawobject) -{ - drawobject->Draw(*this); - CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); - CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); -} - -#endif // WXWIN_COMPATIBILITY_2_8 - /* Notes for wxWidgets DrawEllipticArcRot(...) @@ -1341,26 +888,26 @@ p.lenhard@t-online.de */ #ifdef __WXWINCE__ -void wxDCImpl::DoDrawEllipticArcRot( wxCoord x, wxCoord y, +void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea, double angle ) { - wxPointList list; + wxList list; CalculateEllipticPoints( &list, x, y, w, h, sa, ea ); Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) ); // Add center (for polygon/pie) - list.Append( new wxPoint( x+w/2, y+h/2 ) ); + list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) ); // copy list into array and delete list elements int n = list.GetCount(); wxPoint *points = new wxPoint[n]; int i = 0; - wxPointList::compatibility_iterator node; + wxNode* node = 0; for ( node = list.GetFirst(); node; node = node->GetNext(), i++ ) { - wxPoint *point = node->GetData(); + wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; points[i].y = point->y; delete point; @@ -1386,17 +933,16 @@ void wxDCImpl::DoDrawEllipticArcRot( wxCoord x, wxCoord y, } // DrawEllipticArcRot -void wxDCImpl::Rotate( wxPointList* points, double angle, wxPoint center ) +void wxDCBase::Rotate( wxList* points, double angle, wxPoint center ) { if( angle != 0.0 ) { double pi(M_PI); double dSinA = -sin(angle*2.0*pi/360.0); double dCosA = cos(angle*2.0*pi/360.0); - wxPointList::compatibility_iterator node; - for ( node = points->GetFirst(); node; node = node->GetNext() ) + for ( wxNode* node = points->GetFirst(); node; node = node->GetNext() ) { - wxPoint* point = node->GetData(); + wxPoint* point = (wxPoint*)node->GetData(); // transform coordinates, if necessary if( center.x ) point->x -= center.x; @@ -1414,7 +960,7 @@ void wxDCImpl::Rotate( wxPointList* points, double angle, wxPoint center ) } } -void wxDCImpl::CalculateEllipticPoints( wxPointList* points, +void wxDCBase::CalculateEllipticPoints( wxList* points, wxCoord xStart, wxCoord yStart, wxCoord w, wxCoord h, double sa, double ea ) @@ -1484,13 +1030,15 @@ void wxDCImpl::CalculateEllipticPoints( wxPointList* points, wxCoord y = b; long x2 = 1; long y2 = y*y; + long y2_old = 0; long y_old = 0; // Lists for quadrant 1 to 4 - wxPointList pointsarray[4]; + wxList pointsarray[4]; // Calculate points for first quadrant and set in all quadrants for( x = 0; x <= a; ++x ) { x2 = x2+x+x-1; + y2_old = y2; y_old = y; bool bNewPoint = false; while( y2 > c1 - c2 * x2 && y > 0 ) @@ -1499,46 +1047,45 @@ void wxDCImpl::CalculateEllipticPoints( wxPointList* points, y2 = y2-y-y+1; --y; } - // old y now too big: set point with old y, old x + // old y now to big: set point with old y, old x if( bNewPoint && x>1) { int x1 = x - 1; // remove points on the same line - pointsarray[0].Insert( new wxPoint( xCenter + x1 - decrX, yCenter - y_old ) ); - pointsarray[1].Append( new wxPoint( xCenter - x1, yCenter - y_old ) ); - pointsarray[2].Insert( new wxPoint( xCenter - x1, yCenter + y_old - decrY ) ); - pointsarray[3].Append( new wxPoint( xCenter + x1 - decrX, yCenter + y_old - decrY ) ); + pointsarray[0].Insert( (wxObject*) new wxPoint( xCenter + x1 - decrX, yCenter - y_old ) ); + pointsarray[1].Append( (wxObject*) new wxPoint( xCenter - x1, yCenter - y_old ) ); + pointsarray[2].Insert( (wxObject*) new wxPoint( xCenter - x1, yCenter + y_old - decrY ) ); + pointsarray[3].Append( (wxObject*) new wxPoint( xCenter + x1 - decrX, yCenter + y_old - decrY ) ); } // set point } // calculate point // Starting and/or ending points for the quadrants, first quadrant gets both. - pointsarray[0].Insert( new wxPoint( xCenter + a - decrX, yCenter ) ); - pointsarray[0].Append( new wxPoint( xCenter, yCenter - b ) ); - pointsarray[1].Append( new wxPoint( xCenter - a, yCenter ) ); - pointsarray[2].Append( new wxPoint( xCenter, yCenter + b - decrY ) ); - pointsarray[3].Append( new wxPoint( xCenter + a - decrX, yCenter ) ); + pointsarray[0].Insert( (wxObject*) new wxPoint( xCenter + a - decrX, yCenter ) ); + pointsarray[0].Append( (wxObject*) new wxPoint( xCenter, yCenter - b ) ); + pointsarray[1].Append( (wxObject*) new wxPoint( xCenter - a, yCenter ) ); + pointsarray[2].Append( (wxObject*) new wxPoint( xCenter, yCenter + b - decrY ) ); + pointsarray[3].Append( (wxObject*) new wxPoint( xCenter + a - decrX, yCenter ) ); // copy quadrants in original list if( bUseAngles ) { // Copy the right part of the points in the lists // and delete the wxPoints, because they do not leave this method. - points->Append( new wxPoint( xsa, ysa ) ); + points->Append( (wxObject*) new wxPoint( xsa, ysa ) ); int q = sq; bool bStarted = false; bool bReady = false; bool bForceTurn = ( sq == eq && sa > ea ); while( !bReady ) { - wxPointList::compatibility_iterator node; - for( node = pointsarray[q].GetFirst(); node; node = node->GetNext() ) + for( wxNode *node = pointsarray[q].GetFirst(); node; node = node->GetNext() ) { // once: go to starting point in start quadrant if( !bStarted && ( - node->GetData()->x < xsa+1 && q <= 1 + ( (wxPoint*) node->GetData() )->x < xsa+1 && q <= 1 || - node->GetData()->x > xsa-1 && q >= 2 + ( (wxPoint*) node->GetData() )->x > xsa-1 && q >= 2 ) ) { @@ -1556,10 +1103,10 @@ void wxDCImpl::CalculateEllipticPoints( wxPointList* points, ) { // copy point - wxPoint* pPoint = new wxPoint( *(node->GetData()) ); - points->Append( pPoint ); + wxPoint* pPoint = new wxPoint( *((wxPoint*) node->GetData() ) ); + points->Append( (wxObject*) pPoint ); } - else if( q == eq && !bForceTurn || node->GetData()->x == xea) + else if( q == eq && !bForceTurn || ( (wxPoint*) node->GetData() )->x == xea) { bReady = true; } @@ -1570,49 +1117,49 @@ void wxDCImpl::CalculateEllipticPoints( wxPointList* points, bForceTurn = false; bStarted = true; } // while not bReady - points->Append( new wxPoint( xea, yea ) ); + points->Append( (wxObject*) new wxPoint( xea, yea ) ); // delete points for( q = 0; q < 4; ++q ) { - wxPointList::compatibility_iterator node; - for( node = pointsarray[q].GetFirst(); node; node = node->GetNext() ) + for( wxNode *node = pointsarray[q].GetFirst(); node; node = node->GetNext() ) { - wxPoint *p = node->GetData(); + wxPoint *p = (wxPoint *)node->GetData(); delete p; } } } else { - wxPointList::compatibility_iterator node; + wxNode* node; // copy whole ellipse, wxPoints will be deleted outside for( node = pointsarray[0].GetFirst(); node; node = node->GetNext() ) { - wxPoint *p = node->GetData(); + wxObject *p = node->GetData(); points->Append( p ); } for( node = pointsarray[1].GetFirst(); node; node = node->GetNext() ) { - wxPoint *p = node->GetData(); + wxObject *p = node->GetData(); points->Append( p ); } for( node = pointsarray[2].GetFirst(); node; node = node->GetNext() ) { - wxPoint *p = node->GetData(); + wxObject *p = node->GetData(); points->Append( p ); } for( node = pointsarray[3].GetFirst(); node; node = node->GetNext() ) { - wxPoint *p = node->GetData(); + wxObject *p = node->GetData(); points->Append( p ); } } // not iUseAngles } // CalculateEllipticPoints -#endif // __WXWINCE__ +#endif -float wxDCImpl::GetFontPointSizeAdjustment(float dpi) + +float wxDCBase::GetFontPointSizeAdjustment(float dpi) { // wxMSW has long-standing bug where wxFont point size is interpreted as // "pixel size corresponding to given point size *on screen*". In other @@ -1620,6 +1167,8 @@ float wxDCImpl::GetFontPointSizeAdjustment(float dpi) // are ~6 times smaller when printing. Unfortunately, this bug is so severe // that *all* printing code has to account for it and consequently, other // ports need to emulate this bug too: - const wxSize screenPPI = wxGetDisplayPPI(); - return float(screenPPI.y) / dpi; + const wxSize screenPixels = wxGetDisplaySize(); + const wxSize screenMM = wxGetDisplaySizeMM(); + const float screenPPI_y = (screenPixels.y * 25.4) / screenMM.y; + return screenPPI_y / dpi; } diff --git a/Source/3rd Party/wx/src/common/dcbufcmn.cpp b/Source/3rd Party/wx/src/common/dcbufcmn.cpp index 3bc2e275e..3ac28eae9 100644 --- a/Source/3rd Party/wx/src/common/dcbufcmn.cpp +++ b/Source/3rd Party/wx/src/common/dcbufcmn.cpp @@ -4,6 +4,7 @@ // Author: Ron Lee, Jaakko Salli // Modified by: // Created: Sep-20-2006 +// RCS-ID: $Id: dcbufcmn.cpp 52152 2008-02-27 18:03:12Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -33,9 +34,6 @@ // implementation // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxBufferedDC,wxMemoryDC) -IMPLEMENT_ABSTRACT_CLASS(wxBufferedPaintDC,wxBufferedDC) - // ---------------------------------------------------------------------------- // wxSharedDCBufferManager: helper class maintaining backing store bitmap // ---------------------------------------------------------------------------- @@ -50,9 +48,6 @@ public: static wxBitmap* GetBuffer(int w, int h) { - if ( ms_usingSharedBuffer ) - return new wxBitmap(w, h); - if ( !ms_buffer || w > ms_buffer->GetWidth() || h > ms_buffer->GetHeight() ) @@ -68,33 +63,16 @@ public: ms_buffer = new wxBitmap(w, h); } - - ms_usingSharedBuffer = true; return ms_buffer; } - static void ReleaseBuffer(wxBitmap* buffer) - { - if ( buffer == ms_buffer ) - { - wxASSERT_MSG( ms_usingSharedBuffer, wxT("shared buffer already released") ); - ms_usingSharedBuffer = false; - } - else - { - delete buffer; - } - } - private: static wxBitmap *ms_buffer; - static bool ms_usingSharedBuffer; DECLARE_DYNAMIC_CLASS(wxSharedDCBufferManager) }; wxBitmap* wxSharedDCBufferManager::ms_buffer = NULL; -bool wxSharedDCBufferManager::ms_usingSharedBuffer = false; IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager, wxModule) @@ -104,63 +82,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager, wxModule) void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h) { - wxCHECK_RET( w >= -1 && h >= -1, "Invalid buffer size" ); - if ( !m_buffer || !m_buffer->IsOk() ) { if ( w == -1 || h == -1 ) m_dc->GetSize(&w, &h); m_buffer = wxSharedDCBufferManager::GetBuffer(w, h); - m_style |= wxBUFFER_USES_SHARED_BUFFER; - m_area.Set(w,h); } - else - m_area = m_buffer->GetSize(); SelectObject(*m_buffer); - - // now that the DC is valid we can inherit the attributes (fonts, colours, - // layout direction, ...) from the original DC - if ( m_dc && m_dc->IsOk() ) - CopyAttributes(*m_dc); } -void wxBufferedDC::UnMask() -{ - wxCHECK_RET( m_dc, wxT("no underlying wxDC?") ); - wxASSERT_MSG( m_buffer && m_buffer->IsOk(), wxT("invalid backing store") ); - - wxCoord x = 0, - y = 0; - - // Ensure the scale matches the device - SetUserScale(1.0, 1.0); - - if ( m_style & wxBUFFER_CLIENT_AREA ) - GetDeviceOrigin(&x, &y); - - // It's possible that the buffer may be bigger than the area that needs to - // be drawn (the client size of the window is smaller than the bitmap, or - // a shared bitmap has been reused for a smaller area, etc.) so avoid - // blitting too much if possible, but only use the real DC size if the - // wxBUFFER_VIRTUAL_AREA style is not set. - int width = m_area.GetWidth(), - height = m_area.GetHeight(); - - if (!(m_style & wxBUFFER_VIRTUAL_AREA)) - { - int widthDC, - heightDC; - m_dc->GetSize(&widthDC, &heightDC); - width = wxMin(width, widthDC); - height = wxMin(height, heightDC); - } - - const wxPoint origin = GetLogicalOrigin(); - m_dc->Blit(-origin.x, -origin.y, width, height, this, -x, -y); - m_dc = NULL; - - if ( m_style & wxBUFFER_USES_SHARED_BUFFER ) - wxSharedDCBufferManager::ReleaseBuffer(m_buffer); -} diff --git a/Source/3rd Party/wx/src/common/dcgraph.cpp b/Source/3rd Party/wx/src/common/dcgraph.cpp index d27e9cc02..c9d5e11fe 100644 --- a/Source/3rd Party/wx/src/common/dcgraph.cpp +++ b/Source/3rd Party/wx/src/common/dcgraph.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/dcgraph.cpp +// Name: src/common/graphcmn.cpp // Purpose: graphics context methods common to all platforms // Author: Stefan Csomor // Modified by: // Created: +// RCS-ID: $Id: dcgraph.cpp 60190 2009-04-16 00:57:35Z KO $ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,17 +18,18 @@ #if wxUSE_GRAPHICS_CONTEXT -#include "wx/dcgraph.h" -#include "wx/rawbmp.h" +#include "wx/graphics.h" #ifndef WX_PRECOMP #include "wx/icon.h" - #include "wx/dcclient.h" + #include "wx/bitmap.h" #include "wx/dcmemory.h" - #include "wx/math.h" - #include "wx/geometry.h" + #include "wx/region.h" #endif +#ifdef __WXMAC__ +#include "wx/mac/private.h" +#endif //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- @@ -43,112 +45,22 @@ static inline double DegToRad(double deg) return (deg * M_PI) / 180.0; } -static wxCompositionMode TranslateRasterOp(wxRasterOperationMode function) -{ - switch ( function ) - { - case wxCOPY: // src - // since we are supporting alpha, _OVER is closer to the intention than _SOURCE - // since the latter would overwrite even when alpha is not set to opaque - return wxCOMPOSITION_OVER; - - case wxOR: // src OR dst - return wxCOMPOSITION_ADD; - - case wxNO_OP: // dst - return wxCOMPOSITION_DEST; // ignore the source - - case wxCLEAR: // 0 - return wxCOMPOSITION_CLEAR;// clear dst - - case wxXOR: // src XOR dst - return wxCOMPOSITION_XOR; - - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxAND_REVERSE:// src AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxINVERT: // NOT dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxNOR: // (NOT src) AND (NOT dst) - case wxOR_INVERT: // (NOT src) OR dst - case wxOR_REVERSE: // src OR (NOT dst) - case wxSET: // 1 - case wxSRC_INVERT: // NOT src - break; - } - - return wxCOMPOSITION_INVALID; -} - //----------------------------------------------------------------------------- // wxDC bridge class //----------------------------------------------------------------------------- +#ifdef __WXMAC__ +IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDCBase) +#else IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDC) - -wxGCDC::wxGCDC(const wxWindowDC& dc) : - wxDC( new wxGCDCImpl( this, dc ) ) -{ -} - -wxGCDC::wxGCDC( const wxMemoryDC& dc) : - wxDC( new wxGCDCImpl( this, dc ) ) -{ -} - -#if wxUSE_PRINTING_ARCHITECTURE -wxGCDC::wxGCDC( const wxPrinterDC& dc) : - wxDC( new wxGCDCImpl( this, dc ) ) -{ -} #endif -#if defined(__WXMSW__) && wxUSE_ENH_METAFILE -wxGCDC::wxGCDC(const wxEnhMetaFileDC& dc) - : wxDC(new wxGCDCImpl(this, dc)) +wxGCDC::wxGCDC() { -} -#endif - -wxGCDC::wxGCDC(wxGraphicsContext* context) : - wxDC( new wxGCDCImpl( this ) ) -{ - SetGraphicsContext(context); -} - -wxGCDC::wxGCDC() : - wxDC( new wxGCDCImpl( this ) ) -{ -} - -wxGCDC::~wxGCDC() -{ -} - -wxGraphicsContext* wxGCDC::GetGraphicsContext() const -{ - if (!m_pimpl) return NULL; - wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl; - return gc_impl->GetGraphicsContext(); + Init(); } void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) -{ - if (!m_pimpl) return; - wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl; - gc_impl->SetGraphicsContext( ctx ); -} - -IMPLEMENT_ABSTRACT_CLASS(wxGCDCImpl, wxDCImpl) - -wxGCDCImpl::wxGCDCImpl( wxDC *owner ) : - wxDCImpl( owner ) -{ - Init(wxGraphicsContext::Create()); -} - -void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx ) { delete m_graphicContext; m_graphicContext = ctx; @@ -164,98 +76,29 @@ void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx ) } } -wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) : - wxDCImpl( owner ) +wxGCDC::wxGCDC(const wxWindowDC& dc) { - Init(wxGraphicsContext::Create(dc)); - m_window = dc.GetWindow(); -} - -wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) : - wxDCImpl( owner ) -{ -#if defined(__WXMSW__) && wxUSE_WXDIB - // It seems that GDI+ sets invalid values for alpha channel when used with - // a compatible bitmap (DDB). So we need to convert the currently selected - // bitmap to a DIB before using it with any GDI+ functions to ensure that - // we get the correct alpha channel values in it at the end. - - wxBitmap bmp = dc.GetSelectedBitmap(); - wxASSERT_MSG( bmp.IsOk(), "Should select a bitmap before creating wxGCDC" ); - - // We don't need to convert it if it can't have alpha at all (any depth but - // 32) or is already a DIB with alpha. - if ( bmp.GetDepth() == 32 && (!bmp.IsDIB() || !bmp.HasAlpha()) ) - { - // We need to temporarily deselect this bitmap from the memory DC - // before modifying it. - const_cast(dc).SelectObject(wxNullBitmap); - - bmp.ConvertToDIB(); // Does nothing if already a DIB. - - if( !bmp.HasAlpha() ) - { - // Initialize alpha channel, even if we don't have any alpha yet, - // we should have correct (opaque) alpha values in it for GDI+ - // functions to work correctly. - { - wxAlphaPixelData data(bmp); - if ( data ) - { - wxAlphaPixelData::Iterator p(data); - for ( int y = 0; y < data.GetHeight(); y++ ) - { - wxAlphaPixelData::Iterator rowStart = p; - - for ( int x = 0; x < data.GetWidth(); x++ ) - { - p.Alpha() = wxALPHA_OPAQUE; - ++p; - } - - p = rowStart; - p.OffsetY(data, 1); - } - } - } // End of block modifying the bitmap. - - // Using wxAlphaPixelData sets the internal "has alpha" flag but we - // don't really have any alpha yet, so reset it back for now. - bmp.ResetAlpha(); - } - - // Undo SelectObject() at the beginning of this block. - const_cast(dc).SelectObjectAsSource(bmp); - } -#endif // wxUSE_WXDIB - - Init(wxGraphicsContext::Create(dc)); -} - -#if wxUSE_PRINTING_ARCHITECTURE -wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) : - wxDCImpl( owner ) -{ - Init(wxGraphicsContext::Create(dc)); -} + Init(); + wxGraphicsContext* context; +#if wxUSE_CAIRO + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer(); + context = renderer->CreateContext(dc); +#else + context = wxGraphicsContext::Create(dc); #endif -#if defined(__WXMSW__) && wxUSE_ENH_METAFILE -wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc) - : wxDCImpl(owner) -{ - Init(wxGraphicsContext::Create(dc)); -} -#endif - -wxGCDCImpl::wxGCDCImpl(wxDC* owner, int) - : wxDCImpl(owner) -{ - // derived class will set a context - Init(NULL); + SetGraphicsContext( context ); } -void wxGCDCImpl::Init(wxGraphicsContext* ctx) +#ifdef __WXMSW__ +wxGCDC::wxGCDC(const wxMemoryDC& dc) +{ + Init(); + SetGraphicsContext( wxGraphicsContext::Create(dc) ); +} +#endif + +void wxGCDC::Init() { m_ok = false; m_colour = true; @@ -267,99 +110,96 @@ void wxGCDCImpl::Init(wxGraphicsContext* ctx) m_brush = *wxWHITE_BRUSH; m_graphicContext = NULL; - if (ctx) - SetGraphicsContext(ctx); - m_logicalFunctionSupported = true; } -wxGCDCImpl::~wxGCDCImpl() + +wxGCDC::~wxGCDC() { delete m_graphicContext; } -void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask ) +void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); - wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); + wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); - int w = bmp.GetScaledWidth(); - int h = bmp.GetScaledHeight(); if ( bmp.GetDepth() == 1 ) { m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) ); - m_graphicContext->DrawRectangle( x, y, w, h ); + m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) ); - m_graphicContext->DrawBitmap( bmp, x, y, w, h ); + m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush)); m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen)); } - else // not a monochrome bitmap, handle it normally - { - // make a copy in case we need to remove its mask, if we don't modify - // it the copy is cheap as bitmaps are reference-counted - wxBitmap bmpCopy(bmp); - if ( !useMask && bmp.GetMask() ) - bmpCopy.SetMask(NULL); - - m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h ); - } - - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); + else + m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); } -void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) +void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") ); - wxCHECK_RET( icon.IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") ); + wxCHECK_RET( icon.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") ); wxCoord w = icon.GetWidth(); wxCoord h = icon.GetHeight(); m_graphicContext->DrawIcon( icon , x, y, w, h ); - - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); } -bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) ) +bool wxGCDC::StartDoc( const wxString& WXUNUSED(message) ) { return true; } -void wxGCDCImpl::EndDoc() +void wxGCDC::EndDoc() { } -void wxGCDCImpl::StartPage() +void wxGCDC::StartPage() { } -void wxGCDCImpl::EndPage() +void wxGCDC::EndPage() { } - -void wxGCDCImpl::Flush() + +void wxGCDC::Flush() { - m_graphicContext->Flush(); +#ifdef __WXMAC__ + CGContextFlush( (CGContextRef) m_graphicContext->GetNativeContext() ); +#endif } -void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) +void wxGCDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") ); m_graphicContext->Clip( x, y, w, h ); + if ( m_clipping ) + { + m_clipX1 = wxMax( m_clipX1, x ); + m_clipY1 = wxMax( m_clipY1, y ); + m_clipX2 = wxMin( m_clipX2, (x + w) ); + m_clipY2 = wxMin( m_clipY2, (y + h) ); + } + else + { + m_clipping = true; - wxDCImpl::DoSetClippingRegion(x, y, w, h); + m_clipX1 = x; + m_clipY1 = y; + m_clipX2 = x + w; + m_clipY2 = y + h; + } } -void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion ) +void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) { // region is in device coordinates - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") ); if (region.Empty()) { @@ -392,113 +232,172 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion ) } } -void wxGCDCImpl::DestroyClippingRegion() +void wxGCDC::DestroyClippingRegion() { m_graphicContext->ResetClip(); // currently the clip eg of a window extends to the area between the scrollbars - // so we must explicitly make sure it only covers the area we want it to draw + // so we must explicitely make sure it only covers the area we want it to draw int width, height ; - GetOwner()->GetSize( &width , &height ) ; + GetSize( &width , &height ) ; m_graphicContext->Clip( DeviceToLogicalX(0) , DeviceToLogicalY(0) , DeviceToLogicalXRel(width), DeviceToLogicalYRel(height) ); - + m_graphicContext->SetPen( m_pen ); m_graphicContext->SetBrush( m_brush ); m_clipping = false; } -void wxGCDCImpl::DoGetSizeMM( int* width, int* height ) const +void wxGCDC::DoGetSizeMM( int* width, int* height ) const { int w = 0, h = 0; - GetOwner()->GetSize( &w, &h ); + GetSize( &w, &h ); if (width) *width = long( double(w) / (m_scaleX * m_mm_to_pix_x) ); if (height) *height = long( double(h) / (m_scaleY * m_mm_to_pix_y) ); } -void wxGCDCImpl::SetTextForeground( const wxColour &col ) +void wxGCDC::SetTextForeground( const wxColour &col ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") ); - // don't set m_textForegroundColour to an invalid colour as we'd crash - // later then (we use m_textForegroundColour.GetColor() without checking - // in a few places) - if ( col.IsOk() ) + if ( col != m_textForegroundColour ) { m_textForegroundColour = col; m_graphicContext->SetFont( m_font, m_textForegroundColour ); } } -void wxGCDCImpl::SetTextBackground( const wxColour &col ) +void wxGCDC::SetTextBackground( const wxColour &col ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") ); m_textBackgroundColour = col; } -wxSize wxGCDCImpl::GetPPI() const +void wxGCDC::SetMapMode( int mode ) +{ + switch (mode) + { + case wxMM_TWIPS: + SetLogicalScale( twips2mm * m_mm_to_pix_x, twips2mm * m_mm_to_pix_y ); + break; + + case wxMM_POINTS: + SetLogicalScale( pt2mm * m_mm_to_pix_x, pt2mm * m_mm_to_pix_y ); + break; + + case wxMM_METRIC: + SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); + break; + + case wxMM_LOMETRIC: + SetLogicalScale( m_mm_to_pix_x / 10.0, m_mm_to_pix_y / 10.0 ); + break; + + case wxMM_TEXT: + default: + SetLogicalScale( 1.0, 1.0 ); + break; + } + + ComputeScaleAndOrigin(); +} + +void wxGCDC::SetUserScale( double x, double y ) +{ + // allow negative ? -> no + + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); +} + +void wxGCDC::SetLogicalScale( double x, double y ) +{ + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); +} + +void wxGCDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +{ + m_logicalOriginX = x * m_signX; // is this still correct ? + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); +} + +void wxGCDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +{ + m_deviceOriginX = x; + m_deviceOriginY = y; + ComputeScaleAndOrigin(); +} + +void wxGCDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +{ + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? -1 : 1); + ComputeScaleAndOrigin(); +} + +wxSize wxGCDC::GetPPI() const { return wxSize(72, 72); } -int wxGCDCImpl::GetDepth() const +int wxGCDC::GetDepth() const { return 32; } -void wxGCDCImpl::ComputeScaleAndOrigin() +void wxGCDC::ComputeScaleAndOrigin() { - wxDCImpl::ComputeScaleAndOrigin(); + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; if ( m_graphicContext ) { m_matrixCurrent = m_graphicContext->CreateMatrix(); - + m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY ); + m_matrixCurrent.Scale( m_scaleX, m_scaleY ); // the logical origin sets the origin to have new coordinates - m_matrixCurrent.Translate( m_deviceOriginX - m_logicalOriginX * m_signX * m_scaleX, - m_deviceOriginY - m_logicalOriginY * m_signY * m_scaleY); - - m_matrixCurrent.Scale( m_scaleX * m_signX, m_scaleY * m_signY ); + m_matrixCurrent.Translate( -m_logicalOriginX, -m_logicalOriginY ); m_graphicContext->SetTransform( m_matrixOriginal ); m_graphicContext->ConcatTransform( m_matrixCurrent ); } } -void* wxGCDCImpl::GetHandle() const -{ - void* cgctx = NULL; - wxGraphicsContext* gc = GetGraphicsContext(); - if (gc) { - cgctx = gc->GetNativeContext(); - } - return cgctx; -} - -void wxGCDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) +void wxGCDC::SetPalette( const wxPalette& WXUNUSED(palette) ) { } -void wxGCDCImpl::SetBackgroundMode( int mode ) +void wxGCDC::SetBackgroundMode( int mode ) { m_backgroundMode = mode; } -void wxGCDCImpl::SetFont( const wxFont &font ) +void wxGCDC::SetFont( const wxFont &font ) { m_font = font; if ( m_graphicContext ) { - m_graphicContext->SetFont(font, m_textForegroundColour); + wxFont f = font; + if ( f.Ok() ) + f.SetPointSize( /*LogicalToDeviceYRel*/(font.GetPointSize())); + m_graphicContext->SetFont( f, m_textForegroundColour ); } } -void wxGCDCImpl::SetPen( const wxPen &pen ) +void wxGCDC::SetPen( const wxPen &pen ) { + if ( m_pen == pen ) + return; + m_pen = pen; if ( m_graphicContext ) { @@ -506,53 +405,55 @@ void wxGCDCImpl::SetPen( const wxPen &pen ) } } -void wxGCDCImpl::SetBrush( const wxBrush &brush ) +void wxGCDC::SetBrush( const wxBrush &brush ) { + if (m_brush == brush) + return; + m_brush = brush; if ( m_graphicContext ) { m_graphicContext->SetBrush( m_brush ); } } - -void wxGCDCImpl::SetBackground( const wxBrush &brush ) + +void wxGCDC::SetBackground( const wxBrush &brush ) { + if (m_backgroundBrush == brush) + return; + m_backgroundBrush = brush; - if (!m_backgroundBrush.IsOk()) + if (!m_backgroundBrush.Ok()) return; } -void wxGCDCImpl::SetLogicalFunction( wxRasterOperationMode function ) +void wxGCDC::SetLogicalFunction( int function ) { + if (m_logicalFunction == function) + return; + m_logicalFunction = function; - - wxCompositionMode mode = TranslateRasterOp( function ); - m_logicalFunctionSupported = mode != wxCOMPOSITION_INVALID; - if (m_logicalFunctionSupported) - m_logicalFunctionSupported = m_graphicContext->SetCompositionMode(mode); - - if ( function == wxXOR ) - m_graphicContext->SetAntialiasMode(wxANTIALIAS_NONE); + if ( m_graphicContext->SetLogicalFunction( function ) ) + m_logicalFunctionSupported=true; else - m_graphicContext->SetAntialiasMode(wxANTIALIAS_DEFAULT); + m_logicalFunctionSupported=false; } -bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), - const wxColour& WXUNUSED(col), - wxFloodFillStyle WXUNUSED(style)) +bool wxGCDC::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), + const wxColour& WXUNUSED(col), int WXUNUSED(style)) { return false; } -bool wxGCDCImpl::DoGetPixel( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour *WXUNUSED(col) ) const +bool wxGCDC::DoGetPixel( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour *WXUNUSED(col) ) const { // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") ); return false; } -void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) +void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -563,29 +464,29 @@ void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) CalcBoundingBox(x2, y2); } -void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y ) +void wxGCDC::DoCrossHair( wxCoord x, wxCoord y ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") ); if ( !m_logicalFunctionSupported ) return; int w = 0, h = 0; - GetOwner()->GetSize( &w, &h ); + GetSize( &w, &h ); m_graphicContext->StrokeLine(0,y,w,y); m_graphicContext->StrokeLine(x,0,x,h); CalcBoundingBox(0, 0); - CalcBoundingBox(w, h); + CalcBoundingBox(0+w, 0+h); } -void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, +void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -625,34 +526,26 @@ void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, if ( fill && ((x1!=x2)||(y1!=y2)) ) path.AddLineToPoint( xc, yc ); m_graphicContext->DrawPath(path); - - wxRect2DDouble box = path.GetBox(); - CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); - CalcBoundingBox(wxRound(box.m_x + box.m_width), - wxRound(box.m_y + box.m_height)); } -void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, +void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; - wxCoord dx = x + w / 2.0; - wxCoord dy = y + h / 2.0; - wxDouble factor = ((wxDouble) w) / h; m_graphicContext->PushState(); - m_graphicContext->Translate(dx, dy); - m_graphicContext->Scale(factor, 1.0); - wxGraphicsPath path; + m_graphicContext->Translate(x+w/2.0,y+h/2.0); + wxDouble factor = ((wxDouble) w) / h; + m_graphicContext->Scale( factor , 1.0); // since these angles (ea,sa) are measured counter-clockwise, we invert them to // get clockwise angles if ( m_brush.GetStyle() != wxTRANSPARENT ) { - path = m_graphicContext->CreatePath(); + wxGraphicsPath path = m_graphicContext->CreatePath(); path.MoveToPoint( 0, 0 ); path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea ); path.AddLineToPoint( 0, 0 ); @@ -669,83 +562,57 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, m_graphicContext->DrawPath( path ); } - wxRect2DDouble box = path.GetBox(); - // apply the transformation to the box - box.m_x *= factor; - box.m_width *= factor; - box.m_x += dx; - box.m_y += dy; - - CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); - CalcBoundingBox(wxRound(box.m_x + box.m_width), - wxRound(box.m_y + box.m_height)); - m_graphicContext->PopState(); } -void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) +void wxGCDC::DoDrawPoint( wxCoord x, wxCoord y ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") ); DoDrawLine( x , y , x + 1 , y + 1 ); } -void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], +void wxGCDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); - wxASSERT_MSG( n > 0, wxT("wxGCDC(cg)::DoDrawLines - number of points too small") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); if ( !m_logicalFunctionSupported ) return; - int minX = points[0].x; - int minY = points[0].y; - int maxX = minX; - int maxY = minY; - wxPoint2DDouble* pointsD = new wxPoint2DDouble[n]; for( int i = 0; i < n; ++i) { - wxPoint p = points[i]; - pointsD[i].m_x = p.x + xoffset; - pointsD[i].m_y = p.y + yoffset; - - if (p.x < minX) minX = p.x; - else if (p.x > maxX) maxX = p.x; - if (p.y < minY) minY = p.y; - else if (p.y > maxY) maxY = p.y; + pointsD[i].m_x = points[i].x + xoffset; + pointsD[i].m_y = points[i].y + yoffset; } m_graphicContext->StrokeLines( n , pointsD); delete[] pointsD; - - CalcBoundingBox(minX + xoffset, minY + yoffset); - CalcBoundingBox(maxX + xoffset, maxY + yoffset); } #if wxUSE_SPLINES -void wxGCDCImpl::DoDrawSpline(const wxPointList *points) +void wxGCDC::DoDrawSpline(wxList *points) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); if ( !m_logicalFunctionSupported ) return; wxGraphicsPath path = m_graphicContext->CreatePath(); - wxPointList::compatibility_iterator node = points->GetFirst(); - if ( !node ) + wxList::compatibility_iterator node = points->GetFirst(); + if (node == wxList::compatibility_iterator()) // empty list return; - const wxPoint *p = node->GetData(); + wxPoint *p = (wxPoint *)node->GetData(); wxCoord x1 = p->x; wxCoord y1 = p->y; node = node->GetNext(); - p = node->GetData(); + p = (wxPoint *)node->GetData(); wxCoord x2 = p->x; wxCoord y2 = p->y; @@ -754,16 +621,16 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points) path.MoveToPoint( x1 , y1 ); path.AddLineToPoint( cx1 , cy1 ); -#if !wxUSE_STD_CONTAINERS +#if !wxUSE_STL while ((node = node->GetNext()) != NULL) #else while ((node = node->GetNext())) -#endif // !wxUSE_STD_CONTAINERS +#endif // !wxUSE_STL { - p = node->GetData(); + p = (wxPoint *)node->GetData(); x1 = x2; y1 = y2; x2 = p->x; @@ -780,19 +647,14 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points) path.AddLineToPoint( x2 , y2 ); m_graphicContext->StrokePath( path ); - - wxRect2DDouble box = path.GetBox(); - CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); - CalcBoundingBox(wxRound(box.m_x + box.m_width), - wxRound(box.m_y + box.m_height)); } #endif // wxUSE_SPLINES -void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle ) +void wxGCDC::DoDrawPolygon( int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle ) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") ); if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) ) return; @@ -803,39 +665,25 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[], if (points[n-1] != points[0]) closeIt = true; - int minX = points[0].x; - int minY = points[0].y; - int maxX = minX; - int maxY = minY; - wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)]; for( int i = 0; i < n; ++i) { - wxPoint p = points[i]; - pointsD[i].m_x = p.x + xoffset; - pointsD[i].m_y = p.y + yoffset; - - if (p.x < minX) minX = p.x; - else if (p.x > maxX) maxX = p.x; - if (p.y < minY) minY = p.y; - else if (p.y > maxY) maxY = p.y; + pointsD[i].m_x = points[i].x + xoffset; + pointsD[i].m_y = points[i].y + yoffset; } if ( closeIt ) pointsD[n] = pointsD[0]; m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle); delete[] pointsD; - - CalcBoundingBox(minX + xoffset, minY + yoffset); - CalcBoundingBox(maxX + xoffset, maxY + yoffset); } -void wxGCDCImpl::DoDrawPolyPolygon(int n, - const int count[], - const wxPoint points[], +void wxGCDC::DoDrawPolyPolygon(int n, + int count[], + wxPoint points[], wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle) + int fillStyle) { wxASSERT(n > 1); wxGraphicsPath path = m_graphicContext->CreatePath(); @@ -857,16 +705,11 @@ void wxGCDCImpl::DoDrawPolyPolygon(int n, path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset); } m_graphicContext->DrawPath( path , fillStyle); - - wxRect2DDouble box = path.GetBox(); - CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); - CalcBoundingBox(wxRound(box.m_x + box.m_width), - wxRound(box.m_y + box.m_height)); } -void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -875,9 +718,6 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) if (w == 0 || h == 0) return; - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) { // if we are offsetting the entire rectangle is moved 0.5, so the @@ -888,11 +728,11 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_graphicContext->DrawRectangle(x,y,w,h); } -void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, +void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double radius) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -904,9 +744,6 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, if (w == 0 || h == 0) return; - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) { // if we are offsetting the entire rectangle is moved 0.5, so the @@ -917,16 +754,13 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius); } -void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); if ( !m_logicalFunctionSupported ) return; - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) { // if we are offsetting the entire rectangle is moved 0.5, so the @@ -937,186 +771,90 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_graphicContext->DrawEllipse(x,y,w,h); } -bool wxGCDCImpl::CanDrawBitmap() const +bool wxGCDC::CanDrawBitmap() const { return true; } -bool wxGCDCImpl::DoBlit( +bool wxGCDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode logical_func , bool useMask, + wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool WXUNUSED(useMask), wxCoord xsrcMask, wxCoord ysrcMask ) { - return DoStretchBlit( xdest, ydest, width, height, - source, xsrc, ysrc, width, height, logical_func, useMask, - xsrcMask,ysrcMask ); -} - -bool wxGCDCImpl::DoStretchBlit( - wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, wxCoord xsrc, wxCoord ysrc, wxCoord srcWidth, wxCoord srcHeight, - wxRasterOperationMode logical_func , bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask ) -{ - wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid DC") ); - wxCHECK_MSG( source->IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid source DC") ); + wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") ); + wxCHECK_MSG( source->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") ); if ( logical_func == wxNO_OP ) return true; - - wxCompositionMode mode = TranslateRasterOp(logical_func); - if ( mode == wxCOMPOSITION_INVALID ) + else if ( !m_graphicContext->SetLogicalFunction( logical_func ) ) + { - wxFAIL_MSG( wxT("Blitting is not supported with this logical operation.") ); + wxFAIL_MSG( wxT("Logical function is not supported by the graphics context.") ); return false; } + if (xsrcMask == -1 && ysrcMask == -1) + { + xsrcMask = xsrc; + ysrcMask = ysrc; + } + wxRect subrect(source->LogicalToDeviceX(xsrc), source->LogicalToDeviceY(ysrc), - source->LogicalToDeviceXRel(srcWidth), - source->LogicalToDeviceYRel(srcHeight)); - const wxRect subrectOrig = subrect; - // clip the subrect down to the size of the source DC - wxRect clip; - source->GetSize(&clip.width, &clip.height); - subrect.Intersect(clip); - if (subrect.width == 0) - return true; + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height)); - bool retval = true; + // if needed clip the subrect down to the size of the source DC + wxCoord sw, sh; + source->GetSize(&sw, &sh); + sw = source->LogicalToDeviceXRel(sw); + sh = source->LogicalToDeviceYRel(sh); + if (subrect.x + subrect.width > sw) + subrect.width = sw - subrect.x; + if (subrect.y + subrect.height > sh) + subrect.height = sh - subrect.y; - wxCompositionMode formerMode = m_graphicContext->GetCompositionMode(); - if (m_graphicContext->SetCompositionMode(mode)) + wxBitmap blit = source->GetAsBitmap( &subrect ); + + if ( blit.Ok() ) { - wxAntialiasMode formerAa = m_graphicContext->GetAntialiasMode(); - if (mode == wxCOMPOSITION_XOR) - { - m_graphicContext->SetAntialiasMode(wxANTIALIAS_NONE); - } - - if (xsrcMask == -1 && ysrcMask == -1) - { - xsrcMask = xsrc; - ysrcMask = ysrc; - } - - wxBitmap blit = source->GetAsBitmap( &subrect ); - - if ( blit.IsOk() ) - { - if ( !useMask && blit.GetMask() ) - blit.SetMask(NULL); - - double x = xdest; - double y = ydest; - double w = dstWidth; - double h = dstHeight; - // adjust dest rect if source rect is clipped - if (subrect.width != subrectOrig.width || subrect.height != subrectOrig.height) - { - x += (subrect.x - subrectOrig.x) / double(subrectOrig.width) * dstWidth; - y += (subrect.y - subrectOrig.y) / double(subrectOrig.height) * dstHeight; - w *= double(subrect.width) / subrectOrig.width; - h *= double(subrect.height) / subrectOrig.height; - } - m_graphicContext->DrawBitmap(blit, x, y, w, h); - } - else - { - wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") ); - retval = false; - } - - if (mode == wxCOMPOSITION_XOR) - { - m_graphicContext->SetAntialiasMode(formerAa); - } + m_graphicContext->DrawBitmap( blit, xdest, ydest, + wxMin(width, blit.GetWidth()), + wxMin(height, blit.GetHeight())); + } + else + { + wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") ); + return false; } - // reset composition - m_graphicContext->SetCompositionMode(formerMode); - CalcBoundingBox(xdest, ydest); - CalcBoundingBox(xdest + dstWidth, ydest + dstHeight); + // reset logical function + m_graphicContext->SetLogicalFunction( m_logicalFunction ); - return retval; + return true; } -void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, +void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, double angle) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); - if ( text.empty() ) + if ( str.length() == 0 ) return; if ( !m_logicalFunctionSupported ) return; - // we test that we have some font because otherwise we should still use the - // "else" part below to avoid that DrawRotatedText(angle = 180) and - // DrawRotatedText(angle = 0) use different fonts (we can't use the default - // font for drawing rotated fonts unfortunately) - if ( (angle == 0.0) && m_font.IsOk() ) - { - DoDrawText(text, x, y); - - // Bounding box already updated by DoDrawText(), no need to do it again. - return; - } - - // Get extent of whole text. - wxCoord w, h, heightLine; - GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine); - - // Compute the shift for the origin of the next line. - const double rad = DegToRad(angle); - const double dx = heightLine * sin(rad); - const double dy = heightLine * cos(rad); - - // Draw all text line by line - const wxArrayString lines = wxSplit(text, '\n', '\0'); - for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) - { - // Calculate origin for each line to avoid accumulation of - // rounding errors. - if ( m_backgroundMode == wxTRANSPARENT ) - m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), DegToRad(angle )); - else - m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), DegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); - } - - // call the bounding box by adding all four vertices of the rectangle - // containing the text to it (simpler and probably not slower than - // determining which of them is really topmost/leftmost/...) - - // "upper left" and "upper right" - CalcBoundingBox(x, y); - CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); - - // "bottom left" and "bottom right" - x += (wxCoord)(h*sin(rad)); - y += (wxCoord)(h*cos(rad)); - CalcBoundingBox(x, y); - CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); + if ( m_backgroundMode == wxTRANSPARENT ) + m_graphicContext->DrawText( str, x ,y , DegToRad(angle )); + else + m_graphicContext->DrawText( str, x ,y , DegToRad(angle ), m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) ); } -void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) +void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y) { - // For compatibility with other ports (notably wxGTK) and because it's - // genuinely useful, we allow passing multiline strings to DrawText(). - // However there is no native OSX function to draw them directly so we - // instead reuse the generic DrawLabel() method to render them. Of course, - // DrawLabel() itself will call back to us but with single line strings - // only so there won't be any infinite recursion here. - if ( str.find('\n') != wxString::npos ) - { - GetOwner()->DrawLabel(str, wxRect(x, y, 0, 0)); - return; - } + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") ); - - if ( str.empty() ) + if ( str.length() == 0 ) return; if ( !m_logicalFunctionSupported ) @@ -1126,25 +864,20 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) m_graphicContext->DrawText( str, x ,y); else m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) ); - - wxCoord w, h; - GetOwner()->GetTextExtent(str, &w, &h); - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); } -bool wxGCDCImpl::CanGetTextExtent() const +bool wxGCDC::CanGetTextExtent() const { - wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") ); + wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") ); return true; } -void wxGCDCImpl::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, +void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading , - const wxFont *theFont ) const + wxFont *theFont ) const { - wxCHECK_RET( m_graphicContext, wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") ); if ( theFont ) { @@ -1170,9 +903,9 @@ void wxGCDCImpl::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord * } } -bool wxGCDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +bool wxGCDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { - wxCHECK_MSG( m_graphicContext, false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") ); + wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") ); widths.Clear(); widths.Add(0,text.Length()); if ( text.IsEmpty() ) @@ -1187,7 +920,7 @@ bool wxGCDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& width return true; } -wxCoord wxGCDCImpl::GetCharWidth(void) const +wxCoord wxGCDC::GetCharWidth(void) const { wxCoord width; DoGetTextExtent( wxT("g") , &width , NULL , NULL , NULL , NULL ); @@ -1195,7 +928,7 @@ wxCoord wxGCDCImpl::GetCharWidth(void) const return width; } -wxCoord wxGCDCImpl::GetCharHeight(void) const +wxCoord wxGCDC::GetCharHeight(void) const { wxCoord height; DoGetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL ); @@ -1203,36 +936,25 @@ wxCoord wxGCDCImpl::GetCharHeight(void) const return height; } -void wxGCDCImpl::Clear(void) +void wxGCDC::Clear(void) { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::Clear - invalid DC") ); + wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") ); // TODO better implementation / incorporate size info into wxGCDC or context m_graphicContext->SetBrush( m_backgroundBrush ); wxPen p = *wxTRANSPARENT_PEN; m_graphicContext->SetPen( p ); - wxCompositionMode formerMode = m_graphicContext->GetCompositionMode(); - m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE); - // maximum positive coordinate Cairo can handle is 2^23 - 1 - DoDrawRectangle( - DeviceToLogicalX(0), DeviceToLogicalY(0), - DeviceToLogicalXRel(0x007fffff), DeviceToLogicalYRel(0x007fffff)); - m_graphicContext->SetCompositionMode(formerMode); + DoDrawRectangle( 0, 0, 32000 , 32000 ); m_graphicContext->SetPen( m_pen ); m_graphicContext->SetBrush( m_brush ); } -void wxGCDCImpl::DoGetSize(int *width, int *height) const +void wxGCDC::DoGetSize(int *width, int *height) const { - wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoGetSize - invalid DC") ); - wxDouble w,h; - m_graphicContext->GetSize( &w, &h ); - if ( height ) - *height = (int) (h+0.5); - if ( width ) - *width = (int) (w+0.5); + *width = 10000; + *height = 10000; } -void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, +void wxGCDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection ) @@ -1273,13 +995,9 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height); m_graphicContext->SetPen(m_pen); - m_graphicContext->SetBrush(m_brush); - - CalcBoundingBox(rect.x, rect.y); - CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); } -void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect, +void wxGCDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) @@ -1305,33 +1023,12 @@ void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect, m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height); m_graphicContext->SetPen(m_pen); - m_graphicContext->SetBrush(m_brush); - - CalcBoundingBox(rect.x, rect.y); - CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); } -void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y, +void wxGCDC::DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxDCImpl::DoDrawCheckMark(x,y,width,height); + wxDCBase::DoDrawCheckMark(x,y,width,height); } -#ifdef __WXMSW__ -wxRect wxGCDCImpl::MSWApplyGDIPlusTransform(const wxRect& r) const -{ - wxGraphicsContext* const gc = GetGraphicsContext(); - wxCHECK_MSG( gc, r, wxT("Invalid wxGCDC") ); - - double x = 0, - y = 0; - gc->GetTransform().TransformPoint(&x, &y); - - wxRect rect(r); - rect.Offset(x, y); - - return rect; -} -#endif // __WXMSW__ - #endif // wxUSE_GRAPHICS_CONTEXT diff --git a/Source/3rd Party/wx/src/common/dcsvg.cpp b/Source/3rd Party/wx/src/common/dcsvg.cpp deleted file mode 100644 index 5c55a0b93..000000000 --- a/Source/3rd Party/wx/src/common/dcsvg.cpp +++ /dev/null @@ -1,741 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/svg.cpp -// Purpose: SVG sample -// Author: Chris Elliott -// Modified by: -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_SVG - -#ifndef WX_PRECOMP - #include "wx/dcmemory.h" - #include "wx/dcscreen.h" - #include "wx/icon.h" - #include "wx/image.h" -#endif - -#include "wx/dcsvg.h" -#include "wx/wfstream.h" -#include "wx/filename.h" - -#include "wx/private/markupparser.h" - -// ---------------------------------------------------------- -// Global utilities -// ---------------------------------------------------------- - -namespace -{ - -inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } - -// This function returns a string representation of a floating point number in -// C locale (i.e. always using "." for the decimal separator) and with the -// fixed precision (which is 2 for some unknown reason but this is what it was -// in this code originally). -inline wxString NumStr(double f) -{ - return wxString::FromCDouble(f, 2); -} - -// Return the colour representation as HTML-like "#rrggbb" string and also -// returns its alpha as opacity number in 0..1 range. -wxString Col2SVG(wxColour c, float *opacity) -{ - if ( c.Alpha() != wxALPHA_OPAQUE ) - { - *opacity = c.Alpha()/255.; - - // Remove the alpha before using GetAsString(wxC2S_HTML_SYNTAX) as it - // doesn't support colours with alpha channel. - c = wxColour(c.GetRGB()); - } - else // No alpha. - { - *opacity = 1.; - } - - return c.GetAsString(wxC2S_HTML_SYNTAX); -} - -wxString wxPenString(wxColour c, int style = wxPENSTYLE_SOLID) -{ - float opacity; - wxString s = wxT("stroke:") + Col2SVG(c, &opacity) + wxT("; "); - - switch ( style ) - { - case wxPENSTYLE_SOLID: - s += wxString::Format(wxT("stroke-opacity:%s; "), NumStr(opacity)); - break; - case wxPENSTYLE_TRANSPARENT: - s += wxT("stroke-opacity:0.0; "); - break; - default : - wxASSERT_MSG(false, wxT("wxSVGFileDC::Requested Pen Style not available")); - } - - return s; -} - -wxString wxBrushString(wxColour c, int style = wxBRUSHSTYLE_SOLID) -{ - float opacity; - wxString s = wxT("fill:") + Col2SVG(c, &opacity) + wxT("; "); - - switch ( style ) - { - case wxBRUSHSTYLE_SOLID: - s += wxString::Format(wxT("fill-opacity:%s; "), NumStr(opacity)); - break; - case wxBRUSHSTYLE_TRANSPARENT: - s += wxT("fill-opacity:0.0; "); - break; - default : - wxASSERT_MSG(false, wxT("wxSVGFileDC::Requested Brush Style not available")); - } - - return s; -} - -} // anonymous namespace - -// ---------------------------------------------------------- -// wxSVGFileDCImpl -// ---------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxSVGFileDCImpl, wxDC) - -wxSVGFileDCImpl::wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename, - int width, int height, double dpi ) : - wxDCImpl( owner ) - { - Init( filename, width, height, dpi ); - } - -void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, double dpi) -{ - m_width = Width; - m_height = Height; - - m_dpi = dpi; - - m_OK = true; - - m_clipUniqueId = 0; - m_clipNestingLevel = 0; - - m_mm_to_pix_x = dpi/25.4; - m_mm_to_pix_y = dpi/25.4; - - m_backgroundBrush = *wxTRANSPARENT_BRUSH; - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_colour = wxColourDisplay(); - - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxWHITE_BRUSH; - - m_graphics_changed = true; - - ////////////////////code here - - m_outfile = new wxFileOutputStream(filename); - m_OK = m_outfile->IsOk(); - if (m_OK) - { - m_filename = filename; - m_sub_images = 0; - wxString s; - s = wxT("\n"); - write(s); - s = wxT("\n"); - write(s); - s = wxT("\n"), NumStr(float(Width)/dpi*2.54), NumStr(float(Height)/dpi*2.54), Width, Height ); - write(s); - s = wxT("SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" \n"); - write(s); - s = wxString (wxT("Picture generated by wxSVG ")) + wxSVGVersion + wxT(" \n"); - write(s); - s = wxT("\n"); - write(s); - } -} - -wxSVGFileDCImpl::~wxSVGFileDCImpl() -{ - wxString s = wxT(" \n \n"); - write(s); - delete m_outfile; -} - -void wxSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const -{ - if (width) - *width = wxRound( (double)m_width / m_mm_to_pix_x ); - - if (height) - *height = wxRound( (double)m_height / m_mm_to_pix_y ); -} - -wxSize wxSVGFileDCImpl::GetPPI() const -{ - return wxSize( wxRound(m_dpi), wxRound(m_dpi) ); -} - -void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) -{ - NewGraphicsIfNeeded(); - wxString s; - s.Printf ( wxT(" \n"), x1,y1,x2,y2 ); - if (m_OK) - { - write(s); - } - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); -} - -void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset , wxCoord yoffset ) -{ - for ( int i = 1; i < n; i++ ) - { - DoDrawLine ( points [i-1].x + xoffset, points [i-1].y + yoffset, - points [ i ].x + xoffset, points [ i ].y + yoffset ); - } -} - -void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1) -{ - wxString s; - NewGraphicsIfNeeded(); - s = wxT(" \n"); - write(s); - DoDrawLine ( x1,y1,x1,y1 ); - s = wxT(""); - write(s); -} - -void wxSVGFileDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) -{ - wxDCImpl::DoDrawCheckMark (x1,y1,width,height); -} - -void wxSVGFileDCImpl::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) -{ - DoDrawRotatedText(text, x1,y1,0.0); -} - -void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) -{ - //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW - NewGraphicsIfNeeded(); - wxString s, sTmp; - - // calculate bounding box - wxCoord w, h, desc; - DoGetTextExtent(sText, &w, &h, &desc); - - double rad = DegToRad(angle); - - // wxT("upper left") and wxT("upper right") - CalcBoundingBox(x, y); - CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad))); - - // wxT("bottom left") and wxT("bottom right") - CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad))); - CalcBoundingBox((wxCoord)(x + h*sin(rad) + w*cos(rad)), (wxCoord)(y + h*cos(rad) - w*sin(rad))); - - if (m_backgroundMode == wxBRUSHSTYLE_SOLID) - { - // draw background first - // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background - - sTmp.Printf ( wxT(" "), NumStr(-angle), x,y ); - s += sTmp + wxT("\n"); - write(s); - } - - // convert x,y to SVG text x,y (the coordinates of the text baseline) - x = (wxCoord)(x + (h-desc)*sin(rad)); - y = (wxCoord)(y + (h-desc)*cos(rad)); - - //now do the text itself - s.Printf (wxT(" 0) s += wxT("style=\"font-family:") + sTmp + wxT("; "); - else s += wxT("style=\" "); - - wxString fontweights [3] = { wxT("normal"), wxT("lighter"), wxT("bold") }; - s += wxT("font-weight:") + fontweights[m_font.GetWeight() - wxNORMAL] + wxT("; "); - - wxString fontstyles [5] = { wxT("normal"), wxT("style error"), wxT("style error"), wxT("italic"), wxT("oblique") }; - s += wxT("font-style:") + fontstyles[m_font.GetStyle() - wxNORMAL] + wxT("; "); - - sTmp.Printf (wxT("font-size:%dpt; "), m_font.GetPointSize() ); - s += sTmp; - //text will be solid, unless alpha value isn't opaque in the foreground colour - s += wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour); - sTmp.Printf ( wxT("stroke-width:0;\" transform=\"rotate( %s %d %d ) \" >"), NumStr(-angle), x,y ); - s += sTmp + wxMarkupParser::Quote(sText) + wxT(" ") + wxT("\n"); - if (m_OK) - { - write(s); - } -} - -void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) -{ - DoDrawRoundedRectangle(x, y, width, height, 0); -} - -void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) - -{ - NewGraphicsIfNeeded(); - wxString s; - - s.Printf ( wxT(" \n"); - write(s); - - CalcBoundingBox(x, y); - CalcBoundingBox(x + width, y + height); -} - -void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - wxPolygonFillMode fillStyle) -{ - NewGraphicsIfNeeded(); - wxString s, sTmp; - s = wxT(" \n"); - write(s); -} - -void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) - -{ - NewGraphicsIfNeeded(); - - int rh = height /2; - int rw = width /2; - - wxString s; - s.Printf ( wxT(" \n"); - - write(s); - - CalcBoundingBox(x, y); - CalcBoundingBox(x + width, y + height); -} - -void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) -{ - /* Draws an arc of a circle, centred on (xc, yc), with starting point - (x1, y1) and ending at (x2, y2). The current pen is used for the outline - and the current brush for filling the shape. - - The arc is drawn in an anticlockwise direction from the start point to - the end point. - - Might be better described as Pie drawing */ - - NewGraphicsIfNeeded(); - wxString s; - - // we need the radius of the circle which has two estimates - double r1 = sqrt ( double( (x1-xc)*(x1-xc) ) + double( (y1-yc)*(y1-yc) ) ); - double r2 = sqrt ( double( (x2-xc)*(x2-xc) ) + double( (y2-yc)*(y2-yc) ) ); - - wxASSERT_MSG( (fabs ( r2-r1 ) <= 3), wxT("wxSVGFileDC::DoDrawArc Error in getting radii of circle")); - if ( fabs ( r2-r1 ) > 3 ) //pixels - { - s = wxT(" \n"); - write(s); - } - - double theta1 = atan2((double)(yc-y1),(double)(x1-xc)); - if ( theta1 < 0 ) theta1 = theta1 + M_PI * 2; - double theta2 = atan2((double)(yc-y2), (double)(x2-xc)); - if ( theta2 < 0 ) theta2 = theta2 + M_PI * 2; - if ( theta2 < theta1 ) theta2 = theta2 + M_PI *2; - - int fArc; // flag for large or small arc 0 means less than 180 degrees - if ( fabs(theta2 - theta1) > M_PI ) fArc = 1; else fArc = 0; - - int fSweep = 0; // flag for sweep always 0 - - s.Printf ( wxT(" \n"); - - - if (m_OK) - { - write(s); - } -} - -void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) -{ - /* - Draws an arc of an ellipse. The current pen is used for drawing the arc - and the current brush is used for drawing the pie. This function is - currently only available for X window and PostScript device contexts. - - x and y specify the x and y coordinates of the upper-left corner of the - rectangle that contains the ellipse. - - width and height specify the width and height of the rectangle that - contains the ellipse. - - start and end specify the start and end of the arc relative to the - three-o'clock position from the center of the rectangle. Angles are - specified in degrees (360 is a complete circle). Positive values mean - counter-clockwise motion. If start is equal to end, a complete ellipse - will be drawn. */ - - //known bug: SVG draws with the current pen along the radii, but this does not happen in wxMSW - - NewGraphicsIfNeeded(); - - wxString s; - //radius - double rx = w / 2; - double ry = h / 2; - // center - double xc = x + rx; - double yc = y + ry; - - double xs, ys, xe, ye; - xs = xc + rx * cos (DegToRad(sa)); - xe = xc + rx * cos (DegToRad(ea)); - ys = yc - ry * sin (DegToRad(sa)); - ye = yc - ry * sin (DegToRad(ea)); - - ///now same as circle arc... - - double theta1 = atan2(ys-yc, xs-xc); - double theta2 = atan2(ye-yc, xe-xc); - - int fArc; // flag for large or small arc 0 means less than 180 degrees - if ( (theta2 - theta1) > 0 ) fArc = 1; else fArc = 0; - - int fSweep; - if ( fabs(theta2 - theta1) > M_PI) fSweep = 1; else fSweep = 0; - - s.Printf ( wxT(" \n"); - - if (m_OK) - { - write(s); - } -} - -void wxSVGFileDCImpl::DoSetClippingRegion( int x, int y, int width, int height ) -{ - wxString svg; - - // End current graphics group to ensure proper xml nesting (e.g. so that - // graphics can be subsequently changed inside the clipping region) - svg << "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"; - - write(svg); - - // Re-apply current graphics to ensure proper xml nesting - DoStartNewGraphics(); - - m_clipUniqueId++; - m_clipNestingLevel++; -} - -void wxSVGFileDCImpl::DestroyClippingRegion() -{ - wxString svg; - - // End current graphics element to ensure proper xml nesting (e.g. graphics - // might have been changed inside the clipping region) - svg << "\n"; - - // Close clipping group elements - for ( size_t i = 0; i < m_clipUniqueId; i++ ) - { - svg << ""; - } - svg << "\n"; - - write(svg); - - // Re-apply current graphics (e.g. brush may have been changed inside one - // of the clipped regions - that change will have been lost after xml - // elements for the clipped region have been closed). - DoStartNewGraphics(); - - m_clipUniqueId = 0; -} - -void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const - -{ - wxScreenDC sDC; - - sDC.SetFont (m_font); - if ( font != NULL ) sDC.SetFont ( *font ); - sDC.GetTextExtent(string, w, h, descent, externalLeading ); -} - -wxCoord wxSVGFileDCImpl::GetCharHeight() const -{ - wxScreenDC sDC; - sDC.SetFont (m_font); - - return sDC.GetCharHeight(); - -} - -wxCoord wxSVGFileDCImpl::GetCharWidth() const -{ - wxScreenDC sDC; - sDC.SetFont (m_font); - - return sDC.GetCharWidth(); -} - - -// ---------------------------------------------------------- -// wxSVGFileDCImpl - set functions -// ---------------------------------------------------------- - -void wxSVGFileDCImpl::SetBackground( const wxBrush &brush ) -{ - m_backgroundBrush = brush; -} - - -void wxSVGFileDCImpl::SetBackgroundMode( int mode ) -{ - m_backgroundMode = mode; -} - - -void wxSVGFileDCImpl::SetBrush(const wxBrush& brush) -{ - m_brush = brush; - - m_graphics_changed = true; -} - - -void wxSVGFileDCImpl::SetPen(const wxPen& pen) -{ - // width, color, ends, joins : currently implemented - // dashes, stipple : not implemented - m_pen = pen; - - m_graphics_changed = true; -} - -void wxSVGFileDCImpl::NewGraphicsIfNeeded() -{ - if ( !m_graphics_changed ) - return; - - m_graphics_changed = false; - - write(wxS("\n")); - - DoStartNewGraphics(); -} - -void wxSVGFileDCImpl::DoStartNewGraphics() -{ - wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast; - - sBrush = wxS(""), - m_pen.GetWidth(), NumStr(m_logicalOriginX), NumStr(m_logicalOriginY), NumStr(m_scaleX), NumStr(m_scaleY) ); - - s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + wxT("\n"); - write(s); -} - - -void wxSVGFileDCImpl::SetFont(const wxFont& font) - -{ - m_font = font; -} - -// export a bitmap as a raster image in png -bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC* source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode logicalFunc /*= wxCOPY*/, bool useMask /*= false*/, - wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) -{ - if (logicalFunc != wxCOPY) - { - wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible")); - return false; - } - if (useMask != false) - { - wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested false mask; this is not possible")); - return false; - } - wxBitmap myBitmap (width, height); - wxMemoryDC memDC; - memDC.SelectObject( myBitmap ); - memDC.Blit(0, 0, width, height, source, xsrc, ysrc); - memDC.SelectObject( wxNullBitmap ); - DoDrawBitmap(myBitmap, xdest, ydest); - return false; -} - -void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) -{ - wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ); - wxMemoryDC memDC; - memDC.SelectObject( myBitmap ); - memDC.DrawIcon(myIcon,0,0); - memDC.SelectObject( wxNullBitmap ); - DoDrawBitmap(myBitmap, x, y); -} - -void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y , bool WXUNUSED(bTransparent) /*=0*/ ) -{ - NewGraphicsIfNeeded(); - - wxString sTmp, s, sPNG; - if ( wxImage::FindHandler(wxBITMAP_TYPE_PNG) == NULL ) - wxImage::AddHandler(new wxPNGHandler); - -// create suitable file name - sTmp.Printf ( wxT("_image%d.png"), m_sub_images); - sPNG = m_filename.BeforeLast(wxT('.')) + sTmp; - while (wxFile::Exists(sPNG) ) - { - m_sub_images ++; - sTmp.Printf ( wxT("_image%d.png"), m_sub_images); - sPNG = m_filename.BeforeLast(wxT('.')) + sTmp; - } - -//create copy of bitmap (wxGTK doesn't like saving a constant bitmap) - wxBitmap myBitmap = bmp; -//save it - bool bPNG_OK = myBitmap.SaveFile(sPNG,wxBITMAP_TYPE_PNG); - -// reference the bitmap from the SVG doc -// only use filename & ext - sPNG = sPNG.AfterLast(wxFileName::GetPathSeparator()); - -// reference the bitmap from the SVG doc - int w = myBitmap.GetWidth(); - int h = myBitmap.GetHeight(); - sTmp.Printf ( wxT(" \n"), sPNG.c_str() ); - s += sTmp + wxT("Image from wxSVG ") + wxT("\n"); - - if (m_OK && bPNG_OK) - { - write(s); - } - m_OK = m_outfile->IsOk() && bPNG_OK; -} - -void wxSVGFileDCImpl::write(const wxString &s) -{ - const wxCharBuffer buf = s.utf8_str(); - m_outfile->Write(buf, strlen((const char *)buf)); - m_OK = m_outfile->IsOk(); -} - - -#ifdef __BORLANDC__ -#pragma warn .rch -#pragma warn .ccc -#endif - -#endif // wxUSE_SVG - diff --git a/Source/3rd Party/wx/src/common/debugrpt.cpp b/Source/3rd Party/wx/src/common/debugrpt.cpp deleted file mode 100644 index 7f3c5fba0..000000000 --- a/Source/3rd Party/wx/src/common/debugrpt.cpp +++ /dev/null @@ -1,751 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/debugrpt.cpp -// Purpose: wxDebugReport and related classes implementation -// Author: Vadim Zeitlin -// Modified by: -// Created: 2005-01-17 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/app.h" - #include "wx/log.h" - #include "wx/intl.h" - #include "wx/utils.h" -#endif // WX_PRECOMP - -#if wxUSE_DEBUGREPORT && wxUSE_XML - -#include "wx/debugrpt.h" -#if wxUSE_FFILE - #include "wx/ffile.h" -#elif wxUSE_FILE - #include "wx/file.h" -#endif - -#include "wx/filename.h" -#include "wx/dir.h" -#include "wx/dynlib.h" - -#include "wx/xml/xml.h" - -#if wxUSE_STACKWALKER - #include "wx/stackwalk.h" -#endif - -#if wxUSE_CRASHREPORT - #include "wx/msw/crashrpt.h" -#endif - -#if wxUSE_ZIPSTREAM - #include "wx/wfstream.h" - #include "wx/zipstrm.h" -#endif // wxUSE_ZIPSTREAM - -WX_CHECK_BUILD_OPTIONS("wxQA") - -// ---------------------------------------------------------------------------- -// XmlStackWalker: stack walker specialization which dumps stack in XML -// ---------------------------------------------------------------------------- - -#if wxUSE_STACKWALKER - -class XmlStackWalker : public wxStackWalker -{ -public: - XmlStackWalker(wxXmlNode *nodeStack) - { - m_isOk = false; - m_nodeStack = nodeStack; - } - - bool IsOk() const { return m_isOk; } - -protected: - virtual void OnStackFrame(const wxStackFrame& frame); - - wxXmlNode *m_nodeStack; - bool m_isOk; -}; - -// ---------------------------------------------------------------------------- -// local functions -// ---------------------------------------------------------------------------- - -static inline void -HexProperty(wxXmlNode *node, const wxChar *name, unsigned long value) -{ - node->AddAttribute(name, wxString::Format(wxT("%08lx"), value)); -} - -static inline void -NumProperty(wxXmlNode *node, const wxChar *name, unsigned long value) -{ - node->AddAttribute(name, wxString::Format(wxT("%lu"), value)); -} - -static inline void -TextElement(wxXmlNode *node, const wxChar *name, const wxString& value) -{ - wxXmlNode *nodeChild = new wxXmlNode(wxXML_ELEMENT_NODE, name); - node->AddChild(nodeChild); - nodeChild->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString, value)); -} - -#if wxUSE_CRASHREPORT && defined(__INTEL__) - -static inline void -HexElement(wxXmlNode *node, const wxChar *name, unsigned long value) -{ - TextElement(node, name, wxString::Format(wxT("%08lx"), value)); -} - -#endif // wxUSE_CRASHREPORT - -// ============================================================================ -// XmlStackWalker implementation -// ============================================================================ - -void XmlStackWalker::OnStackFrame(const wxStackFrame& frame) -{ - m_isOk = true; - - wxXmlNode *nodeFrame = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("frame")); - m_nodeStack->AddChild(nodeFrame); - - NumProperty(nodeFrame, wxT("level"), frame.GetLevel()); - wxString func = frame.GetName(); - if ( !func.empty() ) - { - nodeFrame->AddAttribute(wxT("function"), func); - HexProperty(nodeFrame, wxT("offset"), frame.GetOffset()); - } - - if ( frame.HasSourceLocation() ) - { - nodeFrame->AddAttribute(wxT("file"), frame.GetFileName()); - NumProperty(nodeFrame, wxT("line"), frame.GetLine()); - } - - const size_t nParams = frame.GetParamCount(); - if ( nParams ) - { - wxXmlNode *nodeParams = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameters")); - nodeFrame->AddChild(nodeParams); - - for ( size_t n = 0; n < nParams; n++ ) - { - wxXmlNode * - nodeParam = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameter")); - nodeParams->AddChild(nodeParam); - - NumProperty(nodeParam, wxT("number"), n); - - wxString type, name, value; - if ( !frame.GetParam(n, &type, &name, &value) ) - continue; - - if ( !type.empty() ) - TextElement(nodeParam, wxT("type"), type); - - if ( !name.empty() ) - TextElement(nodeParam, wxT("name"), name); - - if ( !value.empty() ) - TextElement(nodeParam, wxT("value"), value); - } - } -} - -#endif // wxUSE_STACKWALKER - -// ============================================================================ -// wxDebugReport implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// initialization and cleanup -// ---------------------------------------------------------------------------- - -wxDebugReport::wxDebugReport() -{ - // get a temporary directory name - wxString appname = GetReportName(); - - // we can't use CreateTempFileName() because it creates a file, not a - // directory, so do our best to create a unique name ourselves - // - // of course, this doesn't protect us against malicious users... -#if wxUSE_DATETIME - m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu-%s"), - wxFileName::GetTempDir(), wxFILE_SEP_PATH, appname, - wxGetProcessId(), - wxDateTime::Now().Format(wxT("%Y%m%dT%H%M%S"))); -#else - m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu"), - wxFileName::GetTempDir(), wxFILE_SEP_PATH, appname, - wxGetProcessId()); -#endif - - // as we are going to save the process state there use restrictive - // permissions - if ( !wxMkdir(m_dir, 0700) ) - { - wxLogSysError(_("Failed to create directory \"%s\""), m_dir.c_str()); - wxLogError(_("Debug report couldn't be created.")); - - Reset(); - } -} - -wxDebugReport::~wxDebugReport() -{ - if ( !m_dir.empty() ) - { - // remove all files in this directory - wxDir dir(m_dir); - wxString file; - for ( bool cont = dir.GetFirst(&file); cont; cont = dir.GetNext(&file) ) - { - if ( wxRemove(wxFileName(m_dir, file).GetFullPath()) != 0 ) - { - wxLogSysError(_("Failed to remove debug report file \"%s\""), - file.c_str()); - m_dir.clear(); - break; - } - } - } - - if ( !m_dir.empty() ) - { - // Temp fix: what should this be? eVC++ doesn't like wxRmDir -#ifdef __WXWINCE__ - if ( wxRmdir(m_dir.fn_str()) != 0 ) -#else - if ( wxRmDir(m_dir.fn_str()) != 0 ) -#endif - { - wxLogSysError(_("Failed to clean up debug report directory \"%s\""), - m_dir.c_str()); - } - } -} - -// ---------------------------------------------------------------------------- -// various helpers -// ---------------------------------------------------------------------------- - -wxString wxDebugReport::GetReportName() const -{ - if ( wxTheApp ) - return wxTheApp->GetAppName(); - - return wxT("wx"); -} - -void -wxDebugReport::AddFile(const wxString& filename, const wxString& description) -{ - wxString name; - wxFileName fn(filename); - if ( fn.IsAbsolute() ) - { - // we need to copy the file to the debug report directory: give it the - // same name there - name = fn.GetFullName(); - - if (!wxCopyFile(fn.GetFullPath(), - wxFileName(GetDirectory(), name).GetFullPath())) - return; - } - else // file relative to the report directory - { - name = filename; - - wxASSERT_MSG( wxFileName(GetDirectory(), name).FileExists(), - wxT("file should exist in debug report directory") ); - } - - m_files.Add(name); - m_descriptions.Add(description); -} - -bool -wxDebugReport::AddText(const wxString& filename, - const wxString& text, - const wxString& description) -{ -#if wxUSE_FFILE || wxUSE_FILE - wxASSERT_MSG( !wxFileName(filename).IsAbsolute(), - wxT("filename should be relative to debug report directory") ); - - const wxString fullPath = wxFileName(GetDirectory(), filename).GetFullPath(); -#if wxUSE_FFILE - wxFFile file(fullPath, wxT("w")); -#elif wxUSE_FILE - wxFile file(fullPath, wxFile::write); -#endif - if ( !file.IsOpened() || !file.Write(text, wxConvAuto()) ) - return false; - - AddFile(filename, description); - - return true; -#else // !wxUSE_FFILE && !wxUSE_FILE - return false; -#endif -} - -void wxDebugReport::RemoveFile(const wxString& name) -{ - const int n = m_files.Index(name); - wxCHECK_RET( n != wxNOT_FOUND, wxT("No such file in wxDebugReport") ); - - m_files.RemoveAt(n); - m_descriptions.RemoveAt(n); - - wxRemove(wxFileName(GetDirectory(), name).GetFullPath()); -} - -bool wxDebugReport::GetFile(size_t n, wxString *name, wxString *desc) const -{ - if ( n >= m_files.GetCount() ) - return false; - - if ( name ) - *name = m_files[n]; - if ( desc ) - *desc = m_descriptions[n]; - - return true; -} - -void wxDebugReport::AddAll(Context context) -{ -#if wxUSE_STACKWALKER - AddContext(context); -#endif // wxUSE_STACKWALKER - -#if wxUSE_CRASHREPORT - AddDump(context); -#endif // wxUSE_CRASHREPORT - -#if !wxUSE_STACKWALKER && !wxUSE_CRASHREPORT - wxUnusedVar(context); -#endif -} - -// ---------------------------------------------------------------------------- -// adding basic text information about current context -// ---------------------------------------------------------------------------- - -#if wxUSE_STACKWALKER - -bool wxDebugReport::DoAddSystemInfo(wxXmlNode *nodeSystemInfo) -{ - nodeSystemInfo->AddAttribute(wxT("description"), wxGetOsDescription()); - - return true; -} - -bool wxDebugReport::DoAddLoadedModules(wxXmlNode *nodeModules) -{ - wxDynamicLibraryDetailsArray modules(wxDynamicLibrary::ListLoaded()); - const size_t count = modules.GetCount(); - if ( !count ) - return false; - - for ( size_t n = 0; n < count; n++ ) - { - const wxDynamicLibraryDetails& info = modules[n]; - - wxXmlNode *nodeModule = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("module")); - nodeModules->AddChild(nodeModule); - - wxString path = info.GetPath(); - if ( path.empty() ) - path = info.GetName(); - if ( !path.empty() ) - nodeModule->AddAttribute(wxT("path"), path); - - void *addr = NULL; - size_t len = 0; - if ( info.GetAddress(&addr, &len) ) - { - HexProperty(nodeModule, wxT("address"), wxPtrToUInt(addr)); - HexProperty(nodeModule, wxT("size"), len); - } - - wxString ver = info.GetVersion(); - if ( !ver.empty() ) - { - nodeModule->AddAttribute(wxT("version"), ver); - } - } - - return true; -} - -bool wxDebugReport::DoAddExceptionInfo(wxXmlNode *nodeContext) -{ -#if wxUSE_CRASHREPORT - wxCrashContext c; - if ( !c.code ) - return false; - - wxXmlNode *nodeExc = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("exception")); - nodeContext->AddChild(nodeExc); - - HexProperty(nodeExc, wxT("code"), c.code); - nodeExc->AddAttribute(wxT("name"), c.GetExceptionString()); - HexProperty(nodeExc, wxT("address"), wxPtrToUInt(c.addr)); - -#ifdef __INTEL__ - wxXmlNode *nodeRegs = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("registers")); - nodeContext->AddChild(nodeRegs); - HexElement(nodeRegs, wxT("eax"), c.regs.eax); - HexElement(nodeRegs, wxT("ebx"), c.regs.ebx); - HexElement(nodeRegs, wxT("ecx"), c.regs.edx); - HexElement(nodeRegs, wxT("edx"), c.regs.edx); - HexElement(nodeRegs, wxT("esi"), c.regs.esi); - HexElement(nodeRegs, wxT("edi"), c.regs.edi); - - HexElement(nodeRegs, wxT("ebp"), c.regs.ebp); - HexElement(nodeRegs, wxT("esp"), c.regs.esp); - HexElement(nodeRegs, wxT("eip"), c.regs.eip); - - HexElement(nodeRegs, wxT("cs"), c.regs.cs); - HexElement(nodeRegs, wxT("ds"), c.regs.ds); - HexElement(nodeRegs, wxT("es"), c.regs.es); - HexElement(nodeRegs, wxT("fs"), c.regs.fs); - HexElement(nodeRegs, wxT("gs"), c.regs.gs); - HexElement(nodeRegs, wxT("ss"), c.regs.ss); - - HexElement(nodeRegs, wxT("flags"), c.regs.flags); -#endif // __INTEL__ - - return true; -#else // !wxUSE_CRASHREPORT - wxUnusedVar(nodeContext); - - return false; -#endif // wxUSE_CRASHREPORT/!wxUSE_CRASHREPORT -} - -bool wxDebugReport::AddContext(wxDebugReport::Context ctx) -{ - wxCHECK_MSG( IsOk(), false, wxT("use IsOk() first") ); - - // create XML dump of current context - wxXmlDocument xmldoc; - wxXmlNode *nodeRoot = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("report")); - xmldoc.SetRoot(nodeRoot); - nodeRoot->AddAttribute(wxT("version"), wxT("1.0")); - nodeRoot->AddAttribute(wxT("kind"), ctx == Context_Current ? wxT("user") - : wxT("exception")); - - // add system information - wxXmlNode *nodeSystemInfo = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("system")); - if ( DoAddSystemInfo(nodeSystemInfo) ) - nodeRoot->AddChild(nodeSystemInfo); - else - delete nodeSystemInfo; - - // add information about the loaded modules - wxXmlNode *nodeModules = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("modules")); - if ( DoAddLoadedModules(nodeModules) ) - nodeRoot->AddChild(nodeModules); - else - delete nodeModules; - - // add CPU context information: this only makes sense for exceptions as our - // current context is not very interesting otherwise - if ( ctx == Context_Exception ) - { - wxXmlNode *nodeContext = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("context")); - if ( DoAddExceptionInfo(nodeContext) ) - nodeRoot->AddChild(nodeContext); - else - delete nodeContext; - } - - // add stack traceback -#if wxUSE_STACKWALKER - wxXmlNode *nodeStack = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("stack")); - XmlStackWalker sw(nodeStack); -#if wxUSE_ON_FATAL_EXCEPTION - if ( ctx == Context_Exception ) - { - sw.WalkFromException(); - } - else // Context_Current -#endif // wxUSE_ON_FATAL_EXCEPTION - { - sw.Walk(); - } - - if ( sw.IsOk() ) - nodeRoot->AddChild(nodeStack); - else - delete nodeStack; -#endif // wxUSE_STACKWALKER - - // finally let the user add any extra information he needs - DoAddCustomContext(nodeRoot); - - - // save the entire context dump in a file - wxFileName fn(m_dir, GetReportName(), wxT("xml")); - - if ( !xmldoc.Save(fn.GetFullPath()) ) - return false; - - AddFile(fn.GetFullName(), _("process context description")); - - return true; -} - -#endif // wxUSE_STACKWALKER - -// ---------------------------------------------------------------------------- -// adding core dump -// ---------------------------------------------------------------------------- - -#if wxUSE_CRASHREPORT - -bool wxDebugReport::AddDump(Context ctx) -{ - wxCHECK_MSG( IsOk(), false, wxT("use IsOk() first") ); - - wxFileName fn(m_dir, GetReportName(), wxT("dmp")); - wxCrashReport::SetFileName(fn.GetFullPath()); - - if ( !(ctx == Context_Exception ? wxCrashReport::Generate() - : wxCrashReport::GenerateNow()) ) - return false; - - AddFile(fn.GetFullName(), _("dump of the process state (binary)")); - - return true; -} - -#endif // wxUSE_CRASHREPORT - -// ---------------------------------------------------------------------------- -// report processing -// ---------------------------------------------------------------------------- - -bool wxDebugReport::Process() -{ - if ( !GetFilesCount() ) - { - wxLogError(_("Debug report generation has failed.")); - - return false; - } - - if ( !DoProcess() ) - { - wxLogError(_("Processing debug report has failed, leaving the files in \"%s\" directory."), - GetDirectory().c_str()); - - Reset(); - - return false; - } - - return true; -} - -bool wxDebugReport::DoProcess() -{ - wxString msg(_("A debug report has been generated. It can be found in")); - msg << wxT("\n") - wxT("\t") << GetDirectory() << wxT("\n\n") - << _("And includes the following files:\n"); - - wxString name, desc; - const size_t count = GetFilesCount(); - for ( size_t n = 0; n < count; n++ ) - { - GetFile(n, &name, &desc); - msg += wxString::Format("\t%s: %s\n", name, desc); - } - - msg += _("\nPlease send this report to the program maintainer, thank you!\n"); - - wxLogMessage(wxT("%s"), msg.c_str()); - - // we have to do this or the report would be deleted, and we don't even - // have any way to ask the user if he wants to keep it from here - Reset(); - - return true; -} - -// ============================================================================ -// wxDebugReport-derived classes -// ============================================================================ - -#if wxUSE_ZIPSTREAM - -// ---------------------------------------------------------------------------- -// wxDebugReportCompress -// ---------------------------------------------------------------------------- - -void wxDebugReportCompress::SetCompressedFileDirectory(const wxString& dir) -{ - wxASSERT_MSG( m_zipfile.empty(), "Too late: call this before Process()" ); - - m_zipDir = dir; -} - -void wxDebugReportCompress::SetCompressedFileBaseName(const wxString& name) -{ - wxASSERT_MSG( m_zipfile.empty(), "Too late: call this before Process()" ); - - m_zipName = name; -} - -bool wxDebugReportCompress::DoProcess() -{ -#define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE)) -#if HAS_FILE_STREAMS - const size_t count = GetFilesCount(); - if ( !count ) - return false; - - // create the compressed report file outside of the directory with the - // report files as it will be deleted by wxDebugReport dtor but we want to - // keep this one: for this we simply treat the directory name as the name - // of the file so that its last component becomes our base name - wxFileName fn(GetDirectory()); - if ( !m_zipDir.empty() ) - fn.SetPath(m_zipDir); - if ( !m_zipName.empty() ) - fn.SetName(m_zipName); - fn.SetExt("zip"); - - // create the streams - const wxString ofullPath = fn.GetFullPath(); -#if wxUSE_FFILE - wxFFileOutputStream os(ofullPath, wxT("wb")); -#elif wxUSE_FILE - wxFileOutputStream os(ofullPath); -#endif - if ( !os.IsOk() ) - return false; - wxZipOutputStream zos(os, 9); - - // add all files to the ZIP one - wxString name, desc; - for ( size_t n = 0; n < count; n++ ) - { - GetFile(n, &name, &desc); - - wxZipEntry *ze = new wxZipEntry(name); - ze->SetComment(desc); - - if ( !zos.PutNextEntry(ze) ) - return false; - - const wxString ifullPath = wxFileName(GetDirectory(), name).GetFullPath(); -#if wxUSE_FFILE - wxFFileInputStream is(ifullPath); -#elif wxUSE_FILE - wxFileInputStream is(ifullPath); -#endif - if ( !is.IsOk() || !zos.Write(is).IsOk() ) - return false; - } - - if ( !zos.Close() ) - return false; - - m_zipfile = ofullPath; - - return true; -#else - return false; -#endif // HAS_FILE_STREAMS -} - -// ---------------------------------------------------------------------------- -// wxDebugReportUpload -// ---------------------------------------------------------------------------- - -wxDebugReportUpload::wxDebugReportUpload(const wxString& url, - const wxString& input, - const wxString& action, - const wxString& curl) - : m_uploadURL(url), - m_inputField(input), - m_curlCmd(curl) -{ - if ( m_uploadURL.Last() != wxT('/') ) - m_uploadURL += wxT('/'); - m_uploadURL += action; -} - -bool wxDebugReportUpload::DoProcess() -{ - if ( !wxDebugReportCompress::DoProcess() ) - return false; - - - wxArrayString output, errors; - int rc = wxExecute(wxString::Format - ( - wxT("%s -F \"%s=@%s\" %s"), - m_curlCmd.c_str(), - m_inputField.c_str(), - GetCompressedFileName().c_str(), - m_uploadURL.c_str() - ), - output, - errors); - if ( rc == -1 ) - { - wxLogError(_("Failed to execute curl, please install it in PATH.")); - } - else if ( rc != 0 ) - { - const size_t count = errors.GetCount(); - if ( count ) - { - for ( size_t n = 0; n < count; n++ ) - { - wxLogWarning(wxT("%s"), errors[n].c_str()); - } - } - - wxLogError(_("Failed to upload the debug report (error code %d)."), rc); - } - else // rc == 0 - { - if ( OnServerReply(output) ) - return true; - } - - return false; -} - -#endif // wxUSE_ZIPSTREAM - -#endif // wxUSE_DEBUGREPORT diff --git a/Source/3rd Party/wx/src/common/dircmn.cpp b/Source/3rd Party/wx/src/common/dircmn.cpp index 11856868f..3e79a7a4e 100644 --- a/Source/3rd Party/wx/src/common/dircmn.cpp +++ b/Source/3rd Party/wx/src/common/dircmn.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.05.01 +// RCS-ID: $Id: dircmn.cpp 40665 2006-08-19 08:45:31Z JS $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -54,16 +55,16 @@ wxDirTraverser::OnOpenError(const wxString& WXUNUSED(dirname)) // dumb generic implementation -bool wxDir::HasFiles(const wxString& spec) const +bool wxDir::HasFiles(const wxString& spec) { wxString s; return GetFirst(&s, spec, wxDIR_FILES | wxDIR_HIDDEN); } // we have a (much) faster version for Unix -#if (defined(__CYGWIN__) && defined(__WINDOWS__)) || !defined(__UNIX_LIKE__) || defined(__EMX__) || defined(__WINE__) +#if (defined(__CYGWIN__) && defined(__WINDOWS__)) || !defined(__UNIX_LIKE__) || defined(__WXMAC__) || defined(__EMX__) || defined(__WINE__) -bool wxDir::HasSubDirs(const wxString& spec) const +bool wxDir::HasSubDirs(const wxString& spec) { wxString s; return GetFirst(&s, spec, wxDIR_DIRS | wxDIR_HIDDEN); @@ -71,28 +72,6 @@ bool wxDir::HasSubDirs(const wxString& spec) const #endif // !Unix -// ---------------------------------------------------------------------------- -// wxDir::GetNameWithSep() -// ---------------------------------------------------------------------------- - -wxString wxDir::GetNameWithSep() const -{ - // Note that for historical reasons (i.e. because GetName() was there - // first) we implement this one in terms of GetName() even though it might - // actually make more sense to reverse this logic. - - wxString name = GetName(); - if ( !name.empty() ) - { - // Notice that even though GetName() isn't supposed to return the - // separator, it can still be present for the root directory name. - if ( name.Last() != wxFILE_SEP_PATH ) - name += wxFILE_SEP_PATH; - } - - return name; -} - // ---------------------------------------------------------------------------- // wxDir::Traverse() // ---------------------------------------------------------------------------- @@ -102,21 +81,20 @@ size_t wxDir::Traverse(wxDirTraverser& sink, int flags) const { wxCHECK_MSG( IsOpened(), (size_t)-1, - wxT("dir must be opened before traversing it") ); + _T("dir must be opened before traversing it") ); // the total number of files found size_t nFiles = 0; // the name of this dir with path delimiter at the end - const wxString prefix = GetNameWithSep(); + wxString prefix = GetName(); + prefix += wxFILE_SEP_PATH; // first, recurse into subdirs if ( flags & wxDIR_DIRS ) { wxString dirname; - for ( bool cont = GetFirst(&dirname, wxEmptyString, - (flags & ~(wxDIR_FILES | wxDIR_DOTDOT)) - | wxDIR_DIRS); + for ( bool cont = GetFirst(&dirname, wxEmptyString, wxDIR_DIRS | (flags & wxDIR_HIDDEN) ); cont; cont = cont && GetNext(&dirname) ) { @@ -125,7 +103,7 @@ size_t wxDir::Traverse(wxDirTraverser& sink, switch ( sink.OnDir(fulldirname) ) { default: - wxFAIL_MSG(wxT("unexpected OnDir() return value") ); + wxFAIL_MSG(_T("unexpected OnDir() return value") ); // fall through case wxDIR_STOP: @@ -153,7 +131,7 @@ size_t wxDir::Traverse(wxDirTraverser& sink, switch ( sink.OnOpenError(fulldirname) ) { default: - wxFAIL_MSG(wxT("unexpected OnOpenError() return value") ); + wxFAIL_MSG(_T("unexpected OnOpenError() return value") ); // fall through case wxDIR_STOP: @@ -202,7 +180,7 @@ size_t wxDir::Traverse(wxDirTraverser& sink, break; wxASSERT_MSG( res == wxDIR_CONTINUE, - wxT("unexpected OnFile() return value") ); + _T("unexpected OnFile() return value") ); nFiles++; @@ -236,7 +214,7 @@ public: private: wxArrayString& m_files; - wxDECLARE_NO_COPY_CLASS(wxDirTraverserSimple); + DECLARE_NO_COPY_CLASS(wxDirTraverserSimple) }; /* static */ @@ -245,7 +223,7 @@ size_t wxDir::GetAllFiles(const wxString& dirname, const wxString& filespec, int flags) { - wxCHECK_MSG( files, (size_t)-1, wxT("NULL pointer in wxDir::GetAllFiles") ); + wxCHECK_MSG( files, (size_t)-1, _T("NULL pointer in wxDir::GetAllFiles") ); size_t nFiles = 0; @@ -288,7 +266,7 @@ public: private: wxString m_file; - wxDECLARE_NO_COPY_CLASS(wxDirTraverserFindFirst); + DECLARE_NO_COPY_CLASS(wxDirTraverserFindFirst) }; /* static */ @@ -313,8 +291,6 @@ wxString wxDir::FindFirst(const wxString& dirname, // wxDir::GetTotalSize() // ---------------------------------------------------------------------------- -#if wxUSE_LONGLONG - class wxDirTraverserSumSize : public wxDirTraverser { public: @@ -322,11 +298,11 @@ public: virtual wxDirTraverseResult OnFile(const wxString& filename) { + wxULongLong sz = wxFileName::GetSize(filename); + // wxFileName::GetSize won't use this class again as // we're passing it a file and not a directory; // thus we are sure to avoid an endless loop - wxULongLong sz = wxFileName::GetSize(filename); - if (sz == wxInvalidSize) { // if the GetSize() failed (this can happen because e.g. a @@ -349,7 +325,7 @@ public: wxULongLong GetTotalSize() const { return m_sz; } - const wxArrayString& GetSkippedFiles() const + wxArrayString &FilesSkipped() { return m_skippedFiles; } protected: @@ -369,36 +345,13 @@ wxULongLong wxDir::GetTotalSize(const wxString &dirname, wxArrayString *filesSki return wxInvalidSize; wxDirTraverserSumSize traverser; - if (dir.Traverse(traverser) == (size_t)-1 ) + if (dir.Traverse(traverser) == (size_t)-1 || + traverser.GetTotalSize() == 0) return wxInvalidSize; if (filesSkipped) - *filesSkipped = traverser.GetSkippedFiles(); + *filesSkipped = traverser.FilesSkipped(); return traverser.GetTotalSize(); } -#endif // wxUSE_LONGLONG - -// ---------------------------------------------------------------------------- -// wxDir helpers -// ---------------------------------------------------------------------------- - -/* static */ -bool wxDir::Exists(const wxString& dir) -{ - return wxFileName::DirExists(dir); -} - -/* static */ -bool wxDir::Make(const wxString &dir, int perm, int flags) -{ - return wxFileName::Mkdir(dir, perm, flags); -} - -/* static */ -bool wxDir::Remove(const wxString &dir, int flags) -{ - return wxFileName::Rmdir(dir, flags); -} - diff --git a/Source/3rd Party/wx/src/common/dirctrlcmn.cpp b/Source/3rd Party/wx/src/common/dirctrlcmn.cpp deleted file mode 100644 index 617875f1f..000000000 --- a/Source/3rd Party/wx/src/common/dirctrlcmn.cpp +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/dirctrlcmn.cpp -// Purpose: wxGenericDirCtrl common code -// Author: Harm van der Heijden, Robert Roebling, Julian Smart -// Modified by: -// Created: 12/12/98 -// Copyright: (c) Harm van der Heijden, Robert Roebling and Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DIRDLG || wxUSE_FILEDLG - -#include "wx/generic/dirctrlg.h" - -extern WXDLLEXPORT_DATA(const char) wxDirDialogNameStr[] = "wxDirCtrl"; -extern WXDLLEXPORT_DATA(const char) wxDirDialogDefaultFolderStr[] = "/"; -extern WXDLLEXPORT_DATA(const char) wxDirSelectorPromptStr[] = "Select a directory"; - -//----------------------------------------------------------------------------- -// XTI -//----------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxGenericDirCtrlStyle ) -wxBEGIN_FLAGS( wxGenericDirCtrlStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxDIRCTRL_DIR_ONLY) - wxFLAGS_MEMBER(wxDIRCTRL_3D_INTERNAL) - wxFLAGS_MEMBER(wxDIRCTRL_SELECT_FIRST) - wxFLAGS_MEMBER(wxDIRCTRL_SHOW_FILTERS) -wxEND_FLAGS( wxGenericDirCtrlStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGenericDirCtrl, wxControl, "wx/dirctrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxGenericDirCtrl) - wxHIDE_PROPERTY( Children ) - - wxPROPERTY( DefaultPath, wxString, SetDefaultPath, GetDefaultPath, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( Filter, wxString, SetFilter, GetFilter, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) - wxPROPERTY( DefaultFilter, int, SetFilterIndex, GetFilterIndex, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group") ) - - wxPROPERTY_FLAGS( WindowStyle, wxGenericDirCtrlStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0, wxT("Helpstring"), \ - wxT("group") ) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxGenericDirCtrl) - -wxCONSTRUCTOR_8( wxGenericDirCtrl, wxWindow*, Parent, wxWindowID, Id, \ - wxString, DefaultPath, wxPoint, Position, wxSize, Size, \ - long, WindowStyle, wxString, Filter, int, DefaultFilter ) - -#endif // wxUSE_DIRDLG || wxUSE_FILEDLG diff --git a/Source/3rd Party/wx/src/common/dlgcmn.cpp b/Source/3rd Party/wx/src/common/dlgcmn.cpp index d410ebb7a..597b14e2c 100644 --- a/Source/3rd Party/wx/src/common/dlgcmn.cpp +++ b/Source/3rd Party/wx/src/common/dlgcmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 28.06.99 +// RCS-ID: $Id: dlgcmn.cpp 49747 2007-11-09 15:06:52Z JS $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -26,7 +27,6 @@ #include "wx/dialog.h" #ifndef WX_PRECOMP - #include "wx/app.h" #include "wx/button.h" #include "wx/dcclient.h" #include "wx/intl.h" @@ -38,77 +38,61 @@ #include "wx/statline.h" #include "wx/sysopt.h" -#include "wx/module.h" -#include "wx/bookctrl.h" -#include "wx/scrolwin.h" -#include "wx/textwrapper.h" -#include "wx/modalhook.h" -#if wxUSE_DISPLAY -#include "wx/display.h" -#endif - -extern WXDLLEXPORT_DATA(const char) wxDialogNameStr[] = "dialog"; +#if wxUSE_STATTEXT // ---------------------------------------------------------------------------- -// XTI +// wxTextWrapper // ---------------------------------------------------------------------------- -wxDEFINE_FLAGS( wxDialogStyle ) -wxBEGIN_FLAGS( wxDialogStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) +// this class is used to wrap the text on word boundary: wrapping is done by +// calling OnStartLine() and OnOutputLine() functions +class wxTextWrapper +{ +public: + wxTextWrapper() { m_eol = false; } -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxNO_BORDER) + // win is used for getting the font, text is the text to wrap, width is the + // max line width or -1 to disable wrapping + void Wrap(wxWindow *win, const wxString& text, int widthMax); -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) + // we don't need it, but just to avoid compiler warnings + virtual ~wxTextWrapper() { } -// dialog styles -wxFLAGS_MEMBER(wxWS_EX_VALIDATE_RECURSIVELY) -wxFLAGS_MEMBER(wxSTAY_ON_TOP) -wxFLAGS_MEMBER(wxCAPTION) -#if WXWIN_COMPATIBILITY_2_6 -wxFLAGS_MEMBER(wxTHICK_FRAME) -#endif // WXWIN_COMPATIBILITY_2_6 -wxFLAGS_MEMBER(wxSYSTEM_MENU) -wxFLAGS_MEMBER(wxRESIZE_BORDER) -#if WXWIN_COMPATIBILITY_2_6 -wxFLAGS_MEMBER(wxRESIZE_BOX) -#endif // WXWIN_COMPATIBILITY_2_6 -wxFLAGS_MEMBER(wxCLOSE_BOX) -wxFLAGS_MEMBER(wxMAXIMIZE_BOX) -wxFLAGS_MEMBER(wxMINIMIZE_BOX) -wxEND_FLAGS( wxDialogStyle ) +protected: + // line may be empty + virtual void OnOutputLine(const wxString& line) = 0; -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxDialog, wxTopLevelWindow, "wx/dialog.h") + // called at the start of every new line (except the very first one) + virtual void OnNewLine() { } -wxBEGIN_PROPERTIES_TABLE(wxDialog) -wxPROPERTY( Title, wxString, SetTitle, GetTitle, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) +private: + // call OnOutputLine() and set m_eol to true + void DoOutputLine(const wxString& line) + { + OnOutputLine(line); -wxPROPERTY_FLAGS( WindowStyle, wxDialogStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() + m_eol = true; + } -wxEMPTY_HANDLERS_TABLE(wxDialog) + // this function is a destructive inspector: when it returns true it also + // resets the flag to false so calling it again woulnd't return true any + // more + bool IsStartOfNewLine() + { + if ( !m_eol ) + return false; -wxCONSTRUCTOR_6( wxDialog, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Title, wxPoint, Position, wxSize, Size, long, WindowStyle) + m_eol = false; + + return true; + } + + + bool m_eol; +}; + +#endif // wxUSE_STATTEXT // ---------------------------------------------------------------------------- // wxDialogBase @@ -120,100 +104,119 @@ BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow) EVT_CLOSE(wxDialogBase::OnCloseWindow) EVT_CHAR_HOOK(wxDialogBase::OnCharHook) + + WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase) END_EVENT_TABLE() -wxDialogLayoutAdapter* wxDialogBase::sm_layoutAdapter = NULL; -bool wxDialogBase::sm_layoutAdaptation = false; +WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase, wxTopLevelWindow) -wxDialogBase::wxDialogBase() +void wxDialogBase::Init() { m_returnCode = 0; m_affirmativeId = wxID_OK; m_escapeId = wxID_ANY; - m_layoutAdaptationLevel = 3; - m_layoutAdaptationDone = FALSE; - m_layoutAdaptationMode = wxDIALOG_ADAPTATION_MODE_DEFAULT; // the dialogs have this flag on by default to prevent the events from the // dialog controls from reaching the parent frame which is usually // undesirable and can lead to unexpected and hard to find bugs SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); -} -wxWindow *wxDialogBase::CheckIfCanBeUsedAsParent(wxWindow *parent) const -{ - if ( !parent ) - return NULL; - - extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; - if ( wxPendingDelete.Member(parent) || parent->IsBeingDeleted() ) - { - // this window is being deleted and we shouldn't create any children - // under it - return NULL; - } - - if ( parent->HasExtraStyle(wxWS_EX_TRANSIENT) ) - { - // this window is not being deleted yet but it's going to disappear - // soon so still don't parent this window under it - return NULL; - } - - if ( !parent->IsShownOnScreen() ) - { - // using hidden parent won't work correctly neither - return NULL; - } - - // FIXME-VC6: this compiler requires an explicit const cast or it fails - // with error C2446 - if ( const_cast(parent) == this ) - { - // not sure if this can really happen but it doesn't hurt to guard - // against this clearly invalid situation - return NULL; - } - - return parent; -} - -wxWindow * -wxDialogBase::GetParentForModalDialog(wxWindow *parent, long style) const -{ - // creating a parent-less modal dialog will result (under e.g. wxGTK2) - // in an unfocused dialog, so try to find a valid parent for it unless we - // were explicitly asked not to - if ( style & wxDIALOG_NO_PARENT ) - return NULL; - - // first try the given parent - if ( parent ) - parent = CheckIfCanBeUsedAsParent(wxGetTopLevelParent(parent)); - - // then the currently active window - if ( !parent ) - parent = CheckIfCanBeUsedAsParent( - wxGetTopLevelParent(wxGetActiveWindow())); - - // and finally the application main window - if ( !parent ) - parent = CheckIfCanBeUsedAsParent(wxTheApp->GetTopWindow()); - - return parent; + m_container.SetContainerWindow(this); } #if wxUSE_STATTEXT -wxSizer *wxDialogBase::CreateTextSizer(const wxString& message) +void wxTextWrapper::Wrap(wxWindow *win, const wxString& text, int widthMax) { - wxTextSizerWrapper wrapper(this); + const wxChar *lastSpace = NULL; + wxString line; - return CreateTextSizer(message, wrapper); + const wxChar *lineStart = text.c_str(); + for ( const wxChar *p = lineStart; ; p++ ) + { + if ( IsStartOfNewLine() ) + { + OnNewLine(); + + lastSpace = NULL; + line.clear(); + lineStart = p; + } + + if ( *p == _T('\n') || *p == _T('\0') ) + { + DoOutputLine(line); + + if ( *p == _T('\0') ) + break; + } + else // not EOL + { + if ( *p == _T(' ') ) + lastSpace = p; + + line += *p; + + if ( widthMax >= 0 && lastSpace ) + { + int width; + win->GetTextExtent(line, &width, NULL); + + if ( width > widthMax ) + { + // remove the last word from this line + line.erase(lastSpace - lineStart, p + 1 - lineStart); + DoOutputLine(line); + + // go back to the last word of this line which we didn't + // output yet + p = lastSpace; + } + } + //else: no wrapping at all or impossible to wrap + } + } } -wxSizer *wxDialogBase::CreateTextSizer(const wxString& message, - wxTextSizerWrapper& wrapper) +class wxTextSizerWrapper : public wxTextWrapper +{ +public: + wxTextSizerWrapper(wxWindow *win) + { + m_win = win; + m_hLine = 0; + } + + wxSizer *CreateSizer(const wxString& text, int widthMax) + { + m_sizer = new wxBoxSizer(wxVERTICAL); + Wrap(m_win, text, widthMax); + return m_sizer; + } + +protected: + virtual void OnOutputLine(const wxString& line) + { + if ( !line.empty() ) + { + m_sizer->Add(new wxStaticText(m_win, wxID_ANY, line)); + } + else // empty line, no need to create a control for it + { + if ( !m_hLine ) + m_hLine = m_win->GetCharHeight(); + + m_sizer->Add(5, m_hLine); + } + } + +private: + wxWindow *m_win; + wxSizer *m_sizer; + int m_hLine; +}; + +wxSizer *wxDialogBase::CreateTextSizer(const wxString& message) { // I admit that this is complete bogus, but it makes // message boxes work for pda screens temporarily.. @@ -224,13 +227,62 @@ wxSizer *wxDialogBase::CreateTextSizer(const wxString& message, widthMax = wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) - 25; } - return wrapper.CreateSizer(message, widthMax); + // '&' is used as accel mnemonic prefix in the wxWidgets controls but in + // the static messages created by CreateTextSizer() (used by wxMessageBox, + // for example), we don't want this special meaning, so we need to quote it + wxString text(message); + text.Replace(_T("&"), _T("&&")); + + wxTextSizerWrapper wrapper(this); + + return wrapper.CreateSizer(text, widthMax); +} + +class wxLabelWrapper : public wxTextWrapper +{ +public: + void WrapLabel(wxWindow *text, int widthMax) + { + m_text.clear(); + Wrap(text, text->GetLabel(), widthMax); + text->SetLabel(m_text); + } + +protected: + virtual void OnOutputLine(const wxString& line) + { + m_text += line; + } + + virtual void OnNewLine() + { + m_text += _T('\n'); + } + +private: + wxString m_text; +}; + +// NB: don't "factor out" the scope operator, SGI MIPSpro 7.3 (but not 7.4) +// gets confused if it doesn't immediately follow the class name +void +#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__) +wxStaticText:: +#else +wxStaticTextBase:: +#endif +Wrap(int width) +{ + wxLabelWrapper wrapper; + wrapper.WrapLabel(this, width); } #endif // wxUSE_STATTEXT wxSizer *wxDialogBase::CreateButtonSizer(long flags) { + wxSizer *sizer = NULL; + #ifdef __SMARTPHONE__ wxDialog* dialog = (wxDialog*) this; if ( flags & wxOK ) @@ -244,8 +296,6 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags) if ( flags & wxNO ) dialog->SetRightMenu(wxID_NO); - - return NULL; #else // !__SMARTPHONE__ #if wxUSE_BUTTON @@ -259,23 +309,21 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags) wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel")) ) #endif // __POCKETPC__ { - return CreateStdDialogButtonSizer(flags); + sizer = CreateStdDialogButtonSizer(flags); } -#ifdef __POCKETPC__ - return NULL; -#endif // __POCKETPC__ - -#else // !wxUSE_BUTTON - wxUnusedVar(flags); - - return NULL; -#endif // wxUSE_BUTTON/!wxUSE_BUTTON +#endif // wxUSE_BUTTON #endif // __SMARTPHONE__/!__SMARTPHONE__ + + return sizer; } -wxSizer *wxDialogBase::CreateSeparatedSizer(wxSizer *sizer) +wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags) { + wxSizer *sizer = CreateButtonSizer(flags); + if ( !sizer ) + return NULL; + // Mac Human Interface Guidelines recommend not to use static lines as // grouping elements #if wxUSE_STATLINE && !defined(__WXMAC__) @@ -289,15 +337,6 @@ wxSizer *wxDialogBase::CreateSeparatedSizer(wxSizer *sizer) return sizer; } -wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags) -{ - wxSizer *sizer = CreateButtonSizer(flags); - if ( !sizer ) - return NULL; - - return CreateSeparatedSizer(sizer); -} - #if wxUSE_BUTTON wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) @@ -332,18 +371,6 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) sizer->AddButton(no); } - if (flags & wxAPPLY) - { - wxButton *apply = new wxButton(this, wxID_APPLY); - sizer->AddButton(apply); - } - - if (flags & wxCLOSE) - { - wxButton *close = new wxButton(this, wxID_CLOSE); - sizer->AddButton(close); - } - if (flags & wxHELP) { wxButton *help = new wxButton(this, wxID_HELP); @@ -376,8 +403,6 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) SetAffirmativeId(wxID_OK); else if (flags & wxYES) SetAffirmativeId(wxID_YES); - else if (flags & wxCLOSE) - SetAffirmativeId(wxID_CLOSE); sizer->Realize(); @@ -424,7 +449,7 @@ bool wxDialogBase::EmulateButtonClickIfPresent(int id) if ( !btn || !btn->IsEnabled() || !btn->IsShown() ) return false; - wxCommandEvent event(wxEVT_BUTTON, id); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, id); event.SetEventObject(btn); btn->GetEventHandler()->ProcessEvent(event); @@ -435,49 +460,36 @@ bool wxDialogBase::EmulateButtonClickIfPresent(int id) #endif // wxUSE_BUTTON/!wxUSE_BUTTON } -bool wxDialogBase::SendCloseButtonClickEvent() -{ - int idCancel = GetEscapeId(); - switch ( idCancel ) - { - case wxID_NONE: - // The user doesn't want this dialog to close "implicitly". - break; - - case wxID_ANY: - // this value is special: it means translate Esc to wxID_CANCEL - // but if there is no such button, then fall back to wxID_OK - if ( EmulateButtonClickIfPresent(wxID_CANCEL) ) - return true; - idCancel = GetAffirmativeId(); - // fall through - - default: - // translate Esc to button press for the button with given id - if ( EmulateButtonClickIfPresent(idCancel) ) - return true; - } - - return false; -} - bool wxDialogBase::IsEscapeKey(const wxKeyEvent& event) { - // For most platforms, Esc key is used to close the dialogs. - // - // Notice that we intentionally don't check for modifiers here, Shift-Esc, - // Alt-Esc and so on still close the dialog, typically. - return event.GetKeyCode() == WXK_ESCAPE; + // for most platforms, Esc key is used to close the dialogs + return event.GetKeyCode() == WXK_ESCAPE && + event.GetModifiers() == wxMOD_NONE; } void wxDialogBase::OnCharHook(wxKeyEvent& event) { - if ( IsEscapeKey(event) ) + if ( event.GetKeyCode() == WXK_ESCAPE ) { - if ( SendCloseButtonClickEvent() ) + int idCancel = GetEscapeId(); + switch ( idCancel ) { - // Skip the call to event.Skip() below, we did handle this key. - return; + case wxID_NONE: + // don't handle Esc specially at all + break; + + case wxID_ANY: + // this value is special: it means translate Esc to wxID_CANCEL + // but if there is no such button, then fall back to wxID_OK + if ( EmulateButtonClickIfPresent(wxID_CANCEL) ) + return; + idCancel = GetAffirmativeId(); + // fall through + + default: + // translate Esc to button press for the button with given id + if ( EmulateButtonClickIfPresent(idCancel) ) + return; } } @@ -509,47 +521,6 @@ void wxDialogBase::OnButton(wxCommandEvent& event) } } -// ---------------------------------------------------------------------------- -// compatibility methods for supporting the modality API -// ---------------------------------------------------------------------------- - -wxDEFINE_EVENT( wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent ); - -IMPLEMENT_DYNAMIC_CLASS(wxWindowModalDialogEvent, wxCommandEvent) - -void wxDialogBase::ShowWindowModal () -{ - int retval = ShowModal(); - // wxWindowModalDialogEvent relies on GetReturnCode() returning correct - // code. Rather than doing it manually in all ShowModal() overrides for - // native dialogs (and getting accidentally broken again), set it here. - // The worst that can happen is that it will be set twice to the same - // value. - SetReturnCode(retval); - SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); -} - -void wxDialogBase::SendWindowModalDialogEvent ( wxEventType type ) -{ - wxWindowModalDialogEvent event ( type, GetId()); - event.SetEventObject(this); - - if ( !GetEventHandler()->ProcessEvent(event) ) - { - // the event is not propagated upwards to the parent automatically - // because the dialog is a top level window, so do it manually as - // in 9 cases of 10 the message must be processed by the dialog - // owner and not the dialog itself - (void)GetParent()->GetEventHandler()->ProcessEvent(event); - } -} - - -wxDialogModality wxDialogBase::GetModality() const -{ - return IsModal() ? wxDIALOG_MODALITY_APP_MODAL : wxDIALOG_MODALITY_NONE; -} - // ---------------------------------------------------------------------------- // other event handlers // ---------------------------------------------------------------------------- @@ -557,9 +528,17 @@ wxDialogModality wxDialogBase::GetModality() const void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { // We'll send a Cancel message by default, which may close the dialog. - // Check for looping if the Cancel event handler calls Close(). - // + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). We wouldn't want to destroy the dialog by default, since + // the dialog may have been created on the stack. However, this does mean + // that calling dialog->Close() won't delete the dialog unless the handler + // for wxID_CANCEL does so. So use Destroy() if you want to be sure to + // destroy the dialog. The default OnCancel (above) simply ends a modal + // dialog, and hides a modeless dialog. + // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global // lists here? don't dare to change it now, but should be done later! static wxList closing; @@ -569,17 +548,9 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) closing.Append(this); - if ( !SendCloseButtonClickEvent() ) - { - // If the handler didn't close the dialog (e.g. because there is no - // button with matching id) we still want to close it when the user - // clicks the "x" button in the title bar, otherwise we shouldn't even - // have put it there. - // - // Notice that using wxID_CLOSE might have been a better choice but we - // use wxID_CANCEL for compatibility reasons. - EndDialog(wxID_CANCEL); - } + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); } @@ -590,427 +561,5 @@ void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& event) SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); Refresh(); #endif - event.Skip(); } - -/// Do the adaptation -bool wxDialogBase::DoLayoutAdaptation() -{ - if (GetLayoutAdapter()) - { - wxWindow* focusWindow = wxFindFocusDescendant(this); // from event.h - if (GetLayoutAdapter()->DoLayoutAdaptation((wxDialog*) this)) - { - if (focusWindow) - focusWindow->SetFocus(); - return true; - } - else - return false; - } - else - return false; -} - -/// Can we do the adaptation? -bool wxDialogBase::CanDoLayoutAdaptation() -{ - // Check if local setting overrides the global setting - bool layoutEnabled = (GetLayoutAdaptationMode() == wxDIALOG_ADAPTATION_MODE_ENABLED) || (IsLayoutAdaptationEnabled() && (GetLayoutAdaptationMode() != wxDIALOG_ADAPTATION_MODE_DISABLED)); - - return (layoutEnabled && !m_layoutAdaptationDone && GetLayoutAdaptationLevel() != 0 && GetLayoutAdapter() != NULL && GetLayoutAdapter()->CanDoLayoutAdaptation((wxDialog*) this)); -} - -/// Set scrolling adapter class, returning old adapter -wxDialogLayoutAdapter* wxDialogBase::SetLayoutAdapter(wxDialogLayoutAdapter* adapter) -{ - wxDialogLayoutAdapter* oldLayoutAdapter = sm_layoutAdapter; - sm_layoutAdapter = adapter; - return oldLayoutAdapter; -} - -/*! - * Standard adapter - */ - -IMPLEMENT_CLASS(wxDialogLayoutAdapter, wxObject) - -IMPLEMENT_CLASS(wxStandardDialogLayoutAdapter, wxDialogLayoutAdapter) - -// Allow for caption size on wxWidgets < 2.9 -#if defined(__WXGTK__) && !wxCHECK_VERSION(2,9,0) -#define wxEXTRA_DIALOG_HEIGHT 30 -#else -#define wxEXTRA_DIALOG_HEIGHT 0 -#endif - -/// Indicate that adaptation should be done -bool wxStandardDialogLayoutAdapter::CanDoLayoutAdaptation(wxDialog* dialog) -{ - if (dialog->GetSizer()) - { - wxSize windowSize, displaySize; - return MustScroll(dialog, windowSize, displaySize) != 0; - } - else - return false; -} - -bool wxStandardDialogLayoutAdapter::DoLayoutAdaptation(wxDialog* dialog) -{ - if (dialog->GetSizer()) - { -#if wxUSE_BOOKCTRL - wxBookCtrlBase* bookContentWindow = wxDynamicCast(dialog->GetContentWindow(), wxBookCtrlBase); - - if (bookContentWindow) - { - // If we have a book control, make all the pages (that use sizers) scrollable - wxWindowList windows; - for (size_t i = 0; i < bookContentWindow->GetPageCount(); i++) - { - wxWindow* page = bookContentWindow->GetPage(i); - - wxScrolledWindow* scrolledWindow = wxDynamicCast(page, wxScrolledWindow); - if (scrolledWindow) - windows.Append(scrolledWindow); - else if (!scrolledWindow && page->GetSizer()) - { - // Create a scrolled window and reparent - scrolledWindow = CreateScrolledWindow(page); - wxSizer* oldSizer = page->GetSizer(); - - wxSizer* newSizer = new wxBoxSizer(wxVERTICAL); - newSizer->Add(scrolledWindow,1, wxEXPAND, 0); - - page->SetSizer(newSizer, false /* don't delete the old sizer */); - - scrolledWindow->SetSizer(oldSizer); - - ReparentControls(page, scrolledWindow); - - windows.Append(scrolledWindow); - } - } - - FitWithScrolling(dialog, windows); - } - else -#endif // wxUSE_BOOKCTRL - { -#if wxUSE_BUTTON - // If we have an arbitrary dialog, create a scrolling area for the main content, and a button sizer - // for the main buttons. - wxScrolledWindow* scrolledWindow = CreateScrolledWindow(dialog); - - int buttonSizerBorder = 0; - - // First try to find a wxStdDialogButtonSizer - wxSizer* buttonSizer = FindButtonSizer(true /* find std button sizer */, dialog, dialog->GetSizer(), buttonSizerBorder); - - // Next try to find a wxBoxSizer containing the controls - if (!buttonSizer && dialog->GetLayoutAdaptationLevel() > wxDIALOG_ADAPTATION_STANDARD_SIZER) - buttonSizer = FindButtonSizer(false /* find ordinary sizer */, dialog, dialog->GetSizer(), buttonSizerBorder); - - // If we still don't have a button sizer, collect any 'loose' buttons in the layout - if (!buttonSizer && dialog->GetLayoutAdaptationLevel() > wxDIALOG_ADAPTATION_ANY_SIZER) - { - int count = 0; - wxStdDialogButtonSizer* stdButtonSizer = new wxStdDialogButtonSizer; - buttonSizer = stdButtonSizer; - - FindLooseButtons(dialog, stdButtonSizer, dialog->GetSizer(), count); - if (count > 0) - stdButtonSizer->Realize(); - else - { - wxDELETE(buttonSizer); - } - } - - if (buttonSizerBorder == 0) - buttonSizerBorder = 5; - - ReparentControls(dialog, scrolledWindow, buttonSizer); - - wxBoxSizer* newTopSizer = new wxBoxSizer(wxVERTICAL); - wxSizer* oldSizer = dialog->GetSizer(); - - dialog->SetSizer(newTopSizer, false /* don't delete old sizer */); - - newTopSizer->Add(scrolledWindow, 1, wxEXPAND|wxALL, 0); - if (buttonSizer) - newTopSizer->Add(buttonSizer, 0, wxEXPAND|wxALL, buttonSizerBorder); - - scrolledWindow->SetSizer(oldSizer); - - FitWithScrolling(dialog, scrolledWindow); -#endif // wxUSE_BUTTON - } - } - - dialog->SetLayoutAdaptationDone(true); - return true; -} - -// Create the scrolled window -wxScrolledWindow* wxStandardDialogLayoutAdapter::CreateScrolledWindow(wxWindow* parent) -{ - wxScrolledWindow* scrolledWindow = new wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxVSCROLL|wxHSCROLL|wxBORDER_NONE); - return scrolledWindow; -} - -#if wxUSE_BUTTON - -/// Find and remove the button sizer, if any -wxSizer* wxStandardDialogLayoutAdapter::FindButtonSizer(bool stdButtonSizer, wxDialog* dialog, wxSizer* sizer, int& retBorder, int accumlatedBorder) -{ - for ( wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst(); - node; node = node->GetNext() ) - { - wxSizerItem *item = node->GetData(); - wxSizer *childSizer = item->GetSizer(); - - if ( childSizer ) - { - int newBorder = accumlatedBorder; - if (item->GetFlag() & wxALL) - newBorder += item->GetBorder(); - - if (stdButtonSizer) // find wxStdDialogButtonSizer - { - wxStdDialogButtonSizer* buttonSizer = wxDynamicCast(childSizer, wxStdDialogButtonSizer); - if (buttonSizer) - { - sizer->Detach(childSizer); - retBorder = newBorder; - return buttonSizer; - } - } - else // find a horizontal box sizer containing standard buttons - { - wxBoxSizer* buttonSizer = wxDynamicCast(childSizer, wxBoxSizer); - if (buttonSizer && IsOrdinaryButtonSizer(dialog, buttonSizer)) - { - sizer->Detach(childSizer); - retBorder = newBorder; - return buttonSizer; - } - } - - wxSizer* s = FindButtonSizer(stdButtonSizer, dialog, childSizer, retBorder, newBorder); - if (s) - return s; - } - } - return NULL; -} - -/// Check if this sizer contains standard buttons, and so can be repositioned in the dialog -bool wxStandardDialogLayoutAdapter::IsOrdinaryButtonSizer(wxDialog* dialog, wxBoxSizer* sizer) -{ - if (sizer->GetOrientation() != wxHORIZONTAL) - return false; - - for ( wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst(); - node; node = node->GetNext() ) - { - wxSizerItem *item = node->GetData(); - wxButton *childButton = wxDynamicCast(item->GetWindow(), wxButton); - - if (childButton && IsStandardButton(dialog, childButton)) - return true; - } - return false; -} - -/// Check if this is a standard button -bool wxStandardDialogLayoutAdapter::IsStandardButton(wxDialog* dialog, wxButton* button) -{ - wxWindowID id = button->GetId(); - - return (id == wxID_OK || id == wxID_CANCEL || id == wxID_YES || id == wxID_NO || id == wxID_SAVE || - id == wxID_APPLY || id == wxID_HELP || id == wxID_CONTEXT_HELP || dialog->IsMainButtonId(id)); -} - -/// Find 'loose' main buttons in the existing layout and add them to the standard dialog sizer -bool wxStandardDialogLayoutAdapter::FindLooseButtons(wxDialog* dialog, wxStdDialogButtonSizer* buttonSizer, wxSizer* sizer, int& count) -{ - wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst(); - while (node) - { - wxSizerItemList::compatibility_iterator next = node->GetNext(); - wxSizerItem *item = node->GetData(); - wxSizer *childSizer = item->GetSizer(); - wxButton *childButton = wxDynamicCast(item->GetWindow(), wxButton); - - if (childButton && IsStandardButton(dialog, childButton)) - { - sizer->Detach(childButton); - buttonSizer->AddButton(childButton); - count ++; - } - - if (childSizer) - FindLooseButtons(dialog, buttonSizer, childSizer, count); - - node = next; - } - return true; -} - -#endif // wxUSE_BUTTON - -/// Reparent the controls to the scrolled window -void wxStandardDialogLayoutAdapter::ReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer) -{ - DoReparentControls(parent, reparentTo, buttonSizer); -} - -void wxStandardDialogLayoutAdapter::DoReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer) -{ - wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); - while (node) - { - wxWindowList::compatibility_iterator next = node->GetNext(); - - wxWindow *win = node->GetData(); - - // Don't reparent the scrolled window or buttons in the button sizer - if (win != reparentTo && (!buttonSizer || !buttonSizer->GetItem(win))) - { - win->Reparent(reparentTo); -#ifdef __WXMSW__ - // Restore correct tab order - ::SetWindowPos((HWND) win->GetHWND(), HWND_BOTTOM, -1, -1, -1, -1, SWP_NOMOVE|SWP_NOSIZE); -#endif - } - - node = next; - } -} - -/// Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both -int wxStandardDialogLayoutAdapter::MustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize) -{ - return DoMustScroll(dialog, windowSize, displaySize); -} - -/// Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both -int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize) -{ - wxSize minWindowSize = dialog->GetSizer()->GetMinSize(); - windowSize = dialog->GetSize(); - windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y)); -#if wxUSE_DISPLAY - displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize(); -#else - displaySize = wxGetClientDisplayRect().GetSize(); -#endif - - int flags = 0; - - if (windowSize.y >= (displaySize.y - wxEXTRA_DIALOG_HEIGHT)) - flags |= wxVERTICAL; - if (windowSize.x >= displaySize.x) - flags |= wxHORIZONTAL; - - return flags; -} - -// A function to fit the dialog around its contents, and then adjust for screen size. -// If scrolled windows are passed, scrolling is enabled in the required orientation(s). -bool wxStandardDialogLayoutAdapter::FitWithScrolling(wxDialog* dialog, wxWindowList& windows) -{ - return DoFitWithScrolling(dialog, windows); -} - -// A function to fit the dialog around its contents, and then adjust for screen size. -// If a scrolled window is passed, scrolling is enabled in the required orientation(s). -bool wxStandardDialogLayoutAdapter::FitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow) -{ - return DoFitWithScrolling(dialog, scrolledWindow); -} - -// A function to fit the dialog around its contents, and then adjust for screen size. -// If a scrolled window is passed, scrolling is enabled in the required orientation(s). -bool wxStandardDialogLayoutAdapter::DoFitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow) -{ - wxWindowList windows; - windows.Append(scrolledWindow); - return DoFitWithScrolling(dialog, windows); -} - -bool wxStandardDialogLayoutAdapter::DoFitWithScrolling(wxDialog* dialog, wxWindowList& windows) -{ - wxSizer* sizer = dialog->GetSizer(); - if (!sizer) - return false; - - sizer->SetSizeHints(dialog); - - wxSize windowSize, displaySize; - int scrollFlags = DoMustScroll(dialog, windowSize, displaySize); - int scrollBarSize = 20; - - if (scrollFlags) - { - int scrollBarExtraX = 0, scrollBarExtraY = 0; - bool resizeHorizontally = (scrollFlags & wxHORIZONTAL) != 0; - bool resizeVertically = (scrollFlags & wxVERTICAL) != 0; - - if (windows.GetCount() != 0) - { - // Allow extra for a scrollbar, assuming we resizing in one direction only. - if ((resizeVertically && !resizeHorizontally) && (windowSize.x < (displaySize.x - scrollBarSize))) - scrollBarExtraX = scrollBarSize; - if ((resizeHorizontally && !resizeVertically) && (windowSize.y < (displaySize.y - scrollBarSize))) - scrollBarExtraY = scrollBarSize; - } - - wxWindowList::compatibility_iterator node = windows.GetFirst(); - while (node) - { - wxWindow *win = node->GetData(); - wxScrolledWindow* scrolledWindow = wxDynamicCast(win, wxScrolledWindow); - if (scrolledWindow) - { - scrolledWindow->SetScrollRate(resizeHorizontally ? 10 : 0, resizeVertically ? 10 : 0); - - if (scrolledWindow->GetSizer()) - scrolledWindow->GetSizer()->Fit(scrolledWindow); - } - - node = node->GetNext(); - } - - wxSize limitTo = windowSize + wxSize(scrollBarExtraX, scrollBarExtraY); - if (resizeVertically) - limitTo.y = displaySize.y - wxEXTRA_DIALOG_HEIGHT; - if (resizeHorizontally) - limitTo.x = displaySize.x; - - dialog->SetMinSize(limitTo); - dialog->SetSize(limitTo); - - dialog->SetSizeHints( limitTo.x, limitTo.y, dialog->GetMaxWidth(), dialog->GetMaxHeight() ); - } - - return true; -} - -/*! - * Module to initialise standard adapter - */ - -class wxDialogLayoutAdapterModule: public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxDialogLayoutAdapterModule) -public: - wxDialogLayoutAdapterModule() {} - virtual void OnExit() { delete wxDialogBase::SetLayoutAdapter(NULL); } - virtual bool OnInit() { wxDialogBase::SetLayoutAdapter(new wxStandardDialogLayoutAdapter); return true; } -}; - -IMPLEMENT_DYNAMIC_CLASS(wxDialogLayoutAdapterModule, wxModule) diff --git a/Source/3rd Party/wx/src/common/dndcmn.cpp b/Source/3rd Party/wx/src/common/dndcmn.cpp index 5bd9e1345..5daf3da7d 100644 --- a/Source/3rd Party/wx/src/common/dndcmn.cpp +++ b/Source/3rd Party/wx/src/common/dndcmn.cpp @@ -1,8 +1,9 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/common/dndcmn.cpp +// Name: common/dndcmn.cpp // Author: Robert Roebling // Modified by: // Created: 19.10.99 +// RCS-ID: $Id: dndcmn.cpp 43664 2006-11-26 21:50:51Z JS $ // Copyright: (c) wxWidgets Team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// diff --git a/Source/3rd Party/wx/src/common/dobjcmn.cpp b/Source/3rd Party/wx/src/common/dobjcmn.cpp index 5e4d43dcc..68b194d3e 100644 --- a/Source/3rd Party/wx/src/common/dobjcmn.cpp +++ b/Source/3rd Party/wx/src/common/dobjcmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin, Robert Roebling // Modified by: // Created: 19.10.99 +// RCS-ID: $Id: dobjcmn.cpp 49036 2007-10-04 10:10:06Z SC $ // Copyright: (c) wxWidgets Team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -23,8 +24,6 @@ #include "wx/app.h" #endif -#include "wx/textbuf.h" - // ---------------------------------------------------------------------------- // lists // ---------------------------------------------------------------------------- @@ -95,19 +94,22 @@ wxDataObjectComposite::~wxDataObjectComposite() } wxDataObjectSimple * -wxDataObjectComposite::GetObject(const wxDataFormat& format, wxDataObjectBase::Direction dir) const +wxDataObjectComposite::GetObject(const wxDataFormat& format) const { wxSimpleDataObjectList::compatibility_iterator node = m_dataObjects.GetFirst(); - while ( node ) { wxDataObjectSimple *dataObj = node->GetData(); - if (dataObj->IsSupported(format,dir)) - return dataObj; + if ( dataObj->GetFormat() == format ) + { + return dataObj; + } + node = node->GetNext(); } - return NULL; + + return (wxDataObjectSimple *)NULL; } void wxDataObjectComposite::Add(wxDataObjectSimple *dataObject, bool preferred) @@ -174,33 +176,21 @@ void* wxDataObjectComposite::SetSizeInBuffer( void* buffer, size_t size, #endif -size_t wxDataObjectComposite::GetFormatCount(Direction dir) const +size_t wxDataObjectComposite::GetFormatCount(Direction WXUNUSED(dir)) const { - size_t n = 0; - - // NOTE: some wxDataObjectSimple objects may return a number greater than 1 - // from GetFormatCount(): this is the case of e.g. wxTextDataObject - // under wxMac and wxGTK - wxSimpleDataObjectList::compatibility_iterator node; - for ( node = m_dataObjects.GetFirst(); node; node = node->GetNext() ) - n += node->GetData()->GetFormatCount(dir); - - return n; + // TODO what about the Get/Set only formats? + return m_dataObjects.GetCount(); } void wxDataObjectComposite::GetAllFormats(wxDataFormat *formats, - Direction dir) const + Direction WXUNUSED(dir)) const { - size_t index(0); + size_t n = 0; wxSimpleDataObjectList::compatibility_iterator node; - for ( node = m_dataObjects.GetFirst(); node; node = node->GetNext() ) { - // NOTE: some wxDataObjectSimple objects may return more than 1 format - // from GetAllFormats(): this is the case of e.g. wxTextDataObject - // under wxMac and wxGTK - node->GetData()->GetAllFormats(formats+index, dir); - index += node->GetData()->GetFormatCount(dir); + // TODO if ( !outputOnlyToo ) && this one counts ... + formats[n++] = node->GetData()->GetFormat(); } } @@ -235,25 +225,14 @@ bool wxDataObjectComposite::SetData(const wxDataFormat& format, wxT("unsupported format in wxDataObjectComposite")); m_receivedFormat = format; - - // Notice that we must pass "format" here as wxTextDataObject, that we can - // have as one of our "simple" sub-objects actually is not that simple and - // can support multiple formats (ASCII/UTF-8/UTF-16/...) and so needs to - // know which one it is given. - return dataObj->SetData( format, len, buf ); + return dataObj->SetData( len, buf ); } // ---------------------------------------------------------------------------- // wxTextDataObject // ---------------------------------------------------------------------------- -#ifdef wxNEEDS_UTF8_FOR_TEXT_DATAOBJ - -// FIXME-UTF8: we should be able to merge wchar_t and UTF-8 versions once we -// have a way to get UTF-8 string (and its length) in both builds -// without loss of efficiency (i.e. extra buffer copy/strlen call) - -#if wxUSE_UNICODE_WCHAR +#if defined(__WXGTK20__) && wxUSE_UNICODE static inline wxMBConv& GetConv(const wxDataFormat& format) { @@ -296,89 +275,26 @@ bool wxTextDataObject::SetData(const wxDataFormat& format, return true; } -#else // wxUSE_UNICODE_UTF8 +#elif wxUSE_UNICODE && defined(__WXMAC__) + +static wxMBConvUTF16 sUTF16Converter; + +static inline wxMBConv& GetConv(const wxDataFormat& format) +{ + return + format == wxDF_UNICODETEXT + ? (wxMBConv&) sUTF16Converter + : (wxMBConv&) wxConvLocal; +} size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const { - const wxString& text = GetText(); - if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) - { - return text.utf8_length(); - } - else // wxDF_TEXT - { - const wxCharBuffer buf(wxConvLocal.cWC2MB(text.wc_str())); - return buf ? strlen(buf) : 0; - } -} + wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); + if ( !buffer ) + return 0; -bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const -{ - if ( !buf ) - return false; - - const wxString& text = GetText(); - if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) - { - memcpy(buf, text.utf8_str(), text.utf8_length()); - } - else // wxDF_TEXT - { - const wxCharBuffer bufLocal(wxConvLocal.cWC2MB(text.wc_str())); - if ( !bufLocal ) - return false; - - memcpy(buf, bufLocal, strlen(bufLocal)); - } - - return true; -} - -bool wxTextDataObject::SetData(const wxDataFormat& format, - size_t len, const void *buf_) -{ - const char * const buf = static_cast(buf_); - - if ( buf == NULL ) - return false; - - if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) - { - // normally the data is in UTF-8 so we could use FromUTF8Unchecked() - // but it's not absolutely clear what GTK+ does if the clipboard data - // is not in UTF-8 so do an extra check for tranquility, it shouldn't - // matter much if we lose a bit of performance when pasting from - // clipboard - SetText(wxString::FromUTF8(buf, len)); - } - else // wxDF_TEXT, convert from current (non-UTF8) locale - { - SetText(wxConvLocal.cMB2WC(buf, len, NULL)); - } - - return true; -} - -#endif // wxUSE_UNICODE_WCHAR/wxUSE_UNICODE_UTF8 - -#elif defined(wxNEEDS_UTF16_FOR_TEXT_DATAOBJ) - -namespace -{ - -inline wxMBConv& GetConv(const wxDataFormat& format) -{ - static wxMBConvUTF16 s_UTF16Converter; - - return format == wxDF_UNICODETEXT ? static_cast(s_UTF16Converter) - : static_cast(wxConvLocal); -} - -} // anonymous namespace - -size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const -{ - return GetConv(format).WC2MB(NULL, GetText().wc_str(), 0); + size_t len = GetConv(format).WC2MB( NULL, GetText().c_str(), 0 ); + return len; } bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const @@ -386,173 +302,98 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const if ( buf == NULL ) return false; - wxCharBuffer buffer(GetConv(format).cWX2MB(GetText().c_str())); + wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); + if ( !buffer ) + return false; - memcpy(buf, buffer.data(), buffer.length()); + size_t len = GetConv(format).WC2MB( NULL, GetText().c_str(), 0 ); + memcpy( (char*)buf, (const char*)buffer, len ); return true; } bool wxTextDataObject::SetData(const wxDataFormat& format, - size_t WXUNUSED(len), - const void *buf) + size_t WXUNUSED(len), const void *buf) { if ( buf == NULL ) return false; - SetText(GetConv(format).cMB2WX(static_cast(buf))); + wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); + + SetText( buffer ); return true; } -#else // !wxNEEDS_UTF{8,16}_FOR_TEXT_DATAOBJ - -// NB: This branch, using native wxChar for the clipboard, is only used under -// Windows currently. It's just a coincidence, but Windows is also the only -// platform where we need to convert the text to the native EOL format, so -// wxTextBuffer::Translate() is only used here and not in the code above. +#else size_t wxTextDataObject::GetDataSize() const { - return (wxTextBuffer::Translate(GetText()).length() + 1)*sizeof(wxChar); + return GetTextLength() * sizeof(wxChar); } bool wxTextDataObject::GetDataHere(void *buf) const { - const wxString textNative = wxTextBuffer::Translate(GetText()); - - // NOTE: use wxTmemcpy() instead of wxStrncpy() to allow - // retrieval of strings with embedded NULLs - wxTmemcpy(static_cast(buf), - textNative.t_str(), - textNative.length() + 1); + wxStrcpy( (wxChar*)buf, GetText().c_str() ); return true; } -bool wxTextDataObject::SetData(size_t len, const void *buf) +bool wxTextDataObject::SetData(size_t WXUNUSED(len), const void *buf) { - const wxString - text = wxString(static_cast(buf), len/sizeof(wxChar)); - SetText(wxTextBuffer::Translate(text, wxTextFileType_Unix)); + SetText( wxString((const wxChar*)buf) ); return true; } -#endif // different wxTextDataObject implementations - -// ---------------------------------------------------------------------------- -// wxHTMLDataObject -// ---------------------------------------------------------------------------- - -size_t wxHTMLDataObject::GetDataSize() const -{ - // Ensure that the temporary string returned by GetHTML() is kept alive for - // as long as we need it here. - const wxString& htmlStr = GetHTML(); - const wxScopedCharBuffer buffer(htmlStr.utf8_str()); - - size_t size = buffer.length(); - -#ifdef __WXMSW__ - // On Windows we need to add some stuff to the string to satisfy - // its clipboard format requirements. - size += 400; #endif - return size; -} +// ---------------------------------------------------------------------------- +// wxFileDataObjectBase +// ---------------------------------------------------------------------------- -bool wxHTMLDataObject::GetDataHere(void *buf) const +// VZ: I don't need this in MSW finally, so if it is needed in wxGTK, it should +// be moved to gtk/dataobj.cpp +#if 0 + +wxString wxFileDataObjectBase::GetFilenames() const { - if ( !buf ) - return false; - - // Windows and Mac always use UTF-8, and docs suggest GTK does as well. - const wxString& htmlStr = GetHTML(); - const wxScopedCharBuffer html(htmlStr.utf8_str()); - if ( !html ) - return false; - - char* const buffer = static_cast(buf); - -#ifdef __WXMSW__ - // add the extra info that the MSW clipboard format requires. - - // Create a template string for the HTML header... - strcpy(buffer, - "Version:0.9\r\n" - "StartHTML:00000000\r\n" - "EndHTML:00000000\r\n" - "StartFragment:00000000\r\n" - "EndFragment:00000000\r\n" - "\r\n" - "\r\n"); - - // Append the HTML... - strcat(buffer, html); - strcat(buffer, "\r\n"); - // Finish up the HTML format... - strcat(buffer, - "\r\n" - "\r\n" - ""); - - // Now go back, calculate all the lengths, and write out the - // necessary header information. Note, wsprintf() truncates the - // string when you overwrite it so you follow up with code to replace - // the 0 appended at the end with a '\r'... - char *ptr = strstr(buffer, "StartHTML"); - sprintf(ptr+10, "%08u", (unsigned)(strstr(buffer, "") - buffer)); - *(ptr+10+8) = '\r'; - - ptr = strstr(buffer, "EndHTML"); - sprintf(ptr+8, "%08u", (unsigned)strlen(buffer)); - *(ptr+8+8) = '\r'; - - ptr = strstr(buffer, "StartFragment"); - sprintf(ptr+14, "%08u", (unsigned)(strstr(buffer, "", fragmentStart) + 3; - int endCommentStart = html.rfind(" SetPosition -// wxMediaCtrl::Tell --> GetPosition -// wxMediaCtrl::Length --> GetDuration -// wxMediaCtrl::GetState -// wxMediaCtrl::DoGetBestSize -// wxMediaCtrl::SetVolume -// wxMediaCtrl::GetVolume -// wxMediaCtrl::ShowInterface -// wxMediaCtrl::GetDownloadProgress -// wxMediaCtrl::GetDownloadTotal -// -// 1) Check to see whether the backend exists and is loading -// 2) Call the backend's version of the method, returning success -// if the backend's version succeeds -//--------------------------------------------------------------------------- -bool wxMediaCtrl::Play() -{ - if(m_imp && m_bLoaded) - return m_imp->Play(); - return 0; -} - -bool wxMediaCtrl::Pause() -{ - if(m_imp && m_bLoaded) - return m_imp->Pause(); - return 0; -} - -bool wxMediaCtrl::Stop() -{ - if(m_imp && m_bLoaded) - return m_imp->Stop(); - return 0; -} - -double wxMediaCtrl::GetPlaybackRate() -{ - if(m_imp && m_bLoaded) - return m_imp->GetPlaybackRate(); - return 0; -} - -bool wxMediaCtrl::SetPlaybackRate(double dRate) -{ - if(m_imp && m_bLoaded) - return m_imp->SetPlaybackRate(dRate); - return false; -} - -wxFileOffset wxMediaCtrl::Seek(wxFileOffset where, wxSeekMode mode) -{ - wxFileOffset offset; - - switch (mode) - { - case wxFromStart: - offset = where; - break; - case wxFromEnd: - offset = Length() - where; - break; -// case wxFromCurrent: - default: - offset = Tell() + where; - break; - } - - if(m_imp && m_bLoaded && m_imp->SetPosition(offset)) - return offset; - return wxInvalidOffset; -} - -wxFileOffset wxMediaCtrl::Tell() -{ - if(m_imp && m_bLoaded) - return (wxFileOffset) m_imp->GetPosition().ToLong(); - return wxInvalidOffset; -} - -wxFileOffset wxMediaCtrl::Length() -{ - if(m_imp && m_bLoaded) - return (wxFileOffset) m_imp->GetDuration().ToLong(); - return wxInvalidOffset; -} - -wxMediaState wxMediaCtrl::GetState() -{ - if(m_imp && m_bLoaded) - return m_imp->GetState(); - return wxMEDIASTATE_STOPPED; -} - -wxSize wxMediaCtrl::DoGetBestSize() const -{ - if(m_imp) - return m_imp->GetVideoSize(); - return wxSize(0,0); -} - -double wxMediaCtrl::GetVolume() -{ - if(m_imp && m_bLoaded) - return m_imp->GetVolume(); - return 0.0; -} - -bool wxMediaCtrl::SetVolume(double dVolume) -{ - if(m_imp && m_bLoaded) - return m_imp->SetVolume(dVolume); - return false; -} - -bool wxMediaCtrl::ShowPlayerControls(wxMediaCtrlPlayerControls flags) -{ - if(m_imp) - return m_imp->ShowPlayerControls(flags); - return false; -} - -wxFileOffset wxMediaCtrl::GetDownloadProgress() -{ - if(m_imp && m_bLoaded) - return (wxFileOffset) m_imp->GetDownloadProgress().ToLong(); - return wxInvalidOffset; -} - -wxFileOffset wxMediaCtrl::GetDownloadTotal() -{ - if(m_imp && m_bLoaded) - return (wxFileOffset) m_imp->GetDownloadTotal().ToLong(); - return wxInvalidOffset; -} - -//--------------------------------------------------------------------------- -// wxMediaCtrl::DoMoveWindow -// -// 1) Call parent's version so that our control's window moves where -// it's supposed to -// 2) If the backend exists and is loaded, move the video -// of the media to where our control's window is now located -//--------------------------------------------------------------------------- -void wxMediaCtrl::DoMoveWindow(int x, int y, int w, int h) -{ - wxControl::DoMoveWindow(x,y,w,h); - - if(m_imp) - m_imp->Move(x, y, w, h); -} - -//--------------------------------------------------------------------------- -// wxMediaCtrl::MacVisibilityChanged -//--------------------------------------------------------------------------- -#ifdef __WXOSX_CARBON__ -void wxMediaCtrl::MacVisibilityChanged() -{ - wxControl::MacVisibilityChanged(); - - if(m_imp) - m_imp->MacVisibilityChanged(); -} -#endif - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// -// wxMediaBackendCommonBase -// -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -void wxMediaBackendCommonBase::NotifyMovieSizeChanged() -{ - // our best size changed after opening a new file - m_ctrl->InvalidateBestSize(); - m_ctrl->SetSize(m_ctrl->GetSize()); - - // if the parent of the control has a sizer ask it to refresh our size - wxWindow * const parent = m_ctrl->GetParent(); - if ( parent->GetSizer() ) - { - m_ctrl->GetParent()->Layout(); - m_ctrl->GetParent()->Refresh(); - m_ctrl->GetParent()->Update(); - } -} - -void wxMediaBackendCommonBase::NotifyMovieLoaded() -{ - NotifyMovieSizeChanged(); - - // notify about movie being fully loaded - QueueEvent(wxEVT_MEDIA_LOADED); -} - -bool wxMediaBackendCommonBase::SendStopEvent() -{ - wxMediaEvent theEvent(wxEVT_MEDIA_STOP, m_ctrl->GetId()); - - return !m_ctrl->GetEventHandler()->ProcessEvent(theEvent) || theEvent.IsAllowed(); -} - -void wxMediaBackendCommonBase::QueueEvent(wxEventType evtType) -{ - wxMediaEvent theEvent(evtType, m_ctrl->GetId()); - m_ctrl->GetEventHandler()->AddPendingEvent(theEvent); -} - -void wxMediaBackendCommonBase::QueuePlayEvent() -{ - QueueEvent(wxEVT_MEDIA_STATECHANGED); - QueueEvent(wxEVT_MEDIA_PLAY); -} - -void wxMediaBackendCommonBase::QueuePauseEvent() -{ - QueueEvent(wxEVT_MEDIA_STATECHANGED); - QueueEvent(wxEVT_MEDIA_PAUSE); -} - -void wxMediaBackendCommonBase::QueueStopEvent() -{ - QueueEvent(wxEVT_MEDIA_STATECHANGED); - QueueEvent(wxEVT_MEDIA_STOP); -} - - -// -// Force link default backends in - -// see http://wiki.wxwidgets.org/wiki.pl?RTTI -// -#include "wx/html/forcelnk.h" - -#ifdef __WXMSW__ // MSW has huge backends so we do it separately -FORCE_LINK(wxmediabackend_am) -FORCE_LINK(wxmediabackend_wmp10) -#else -FORCE_LINK(basewxmediabackends) -#endif - -#endif //wxUSE_MEDIACTRL diff --git a/Source/3rd Party/wx/src/common/memory.cpp b/Source/3rd Party/wx/src/common/memory.cpp index 6dc5d026d..e3a1d7866 100644 --- a/Source/3rd Party/wx/src/common/memory.cpp +++ b/Source/3rd Party/wx/src/common/memory.cpp @@ -4,6 +4,7 @@ // Author: Arthur Seaton, Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: memory.cpp 41054 2006-09-07 19:01:45Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,12 +16,12 @@ #pragma hdrstop #endif -#if wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #include "wx/memory.h" #ifndef WX_PRECOMP - #ifdef __WINDOWS__ + #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" #endif #include "wx/utils.h" @@ -37,14 +38,15 @@ #include "wx/ioswrap.h" -#if !defined(__WATCOMC__) && !(defined(__VMS__) && ( __VMS_VER < 70000000 ) ) +#if !defined(__WATCOMC__) && !(defined(__VMS__) && ( __VMS_VER < 70000000 ) )\ + && !defined( __MWERKS__ ) && !defined(__SALFORDC__) #include #endif #include #include -#if wxUSE_THREADS +#if wxUSE_THREADS && defined(__WXDEBUG__) #define USE_THREADSAFE_MEMORY_ALLOCATION 1 #else #define USE_THREADSAFE_MEMORY_ALLOCATION 0 @@ -116,9 +118,8 @@ void wxMemStruct::ErrorMsg () */ int wxMemStruct::AssertList () { - if ((wxDebugContext::GetHead() && !wxDebugContext::GetHead()->AssertIt()) || - (wxDebugContext::GetTail() && !wxDebugContext::GetTail()->AssertIt())) - { + if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () || + wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) { ErrorMsg ("Head or tail pointers trashed"); return 0; } @@ -369,7 +370,7 @@ void wxMemStruct::Dump () msg2.Printf(wxT(" at 0x%lX, size %d"), (long)GetActualData(), (int)RequestSize()); msg += msg2; - wxDebugContext::OutputDumpLine(msg.c_str()); + wxDebugContext::OutputDumpLine(msg); } else { @@ -380,7 +381,7 @@ void wxMemStruct::Dump () wxString msg2; msg2.Printf(wxT("non-object data at 0x%lX, size %d"), (long)GetActualData(), (int)RequestSize() ); msg += msg2; - wxDebugContext::OutputDumpLine(msg.c_str()); + wxDebugContext::OutputDumpLine(msg); } } @@ -451,9 +452,6 @@ static wxMarkerType markerCalc[2]; int wxDebugContext::m_balign = (int)((char *)&markerCalc[1] - (char*)&markerCalc[0]); int wxDebugContext::m_balignmask = (int)((char *)&markerCalc[1] - (char*)&markerCalc[0]) - 1; -// Pointer to global function to call at shutdown -wxShutdownNotifyFunction wxDebugContext::sm_shutdownFn; - wxDebugContext::wxDebugContext(void) { } @@ -574,21 +572,26 @@ void wxDebugContext::TraverseList (PmSFV func, wxMemStruct *from) */ bool wxDebugContext::PrintList (void) { - TraverseList ((PmSFV)&wxMemStruct::PrintNode, (checkPoint ? checkPoint->m_next : NULL)); +#ifdef __WXDEBUG__ + TraverseList ((PmSFV)&wxMemStruct::PrintNode, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); return true; +#else + return false; +#endif } bool wxDebugContext::Dump(void) { +#ifdef __WXDEBUG__ { - const wxChar* appName = wxT("application"); + wxChar* appName = (wxChar*) wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr.c_str(); - OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, static_cast(wxNow().c_str())); + appName = WXSTRINGCAST appNameStr; + OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); } else { @@ -596,14 +599,18 @@ bool wxDebugContext::Dump(void) } } - TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : NULL)); + TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; +#else + return false; +#endif } +#ifdef __WXDEBUG__ struct wxDebugStatsStruct { long instanceCount; @@ -628,17 +635,19 @@ static wxDebugStatsStruct *InsertStatsStruct(wxDebugStatsStruct *head, wxDebugSt st->next = head; return st; } +#endif bool wxDebugContext::PrintStatistics(bool detailed) { +#ifdef __WXDEBUG__ { - const wxChar* appName = wxT("application"); + wxChar* appName = (wxChar*) wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr.c_str(); - OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, static_cast(wxNow().c_str())); + appName = WXSTRINGCAST appNameStr; + OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); } else { @@ -655,7 +664,7 @@ bool wxDebugContext::PrintStatistics(bool detailed) wxDebugStatsStruct *list = NULL; - wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); + wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); if (!from) from = wxDebugContext::GetHead (); @@ -717,29 +726,34 @@ bool wxDebugContext::PrintStatistics(bool detailed) OutputDumpLine(wxEmptyString); return true; +#else + (void)detailed; + return false; +#endif } bool wxDebugContext::PrintClasses(void) { { - const wxChar* appName = wxT("application"); + wxChar* appName = (wxChar*) wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr.c_str(); + appName = WXSTRINGCAST appNameStr; wxLogMessage(wxT("----- Classes in %s -----"), appName); } } int n = 0; - const wxClassInfo *info; + wxHashTable::compatibility_iterator node; + wxClassInfo *info; - for (wxClassInfo::const_iterator node = wxClassInfo::begin_classinfo(), - end = wxClassInfo::end_classinfo(); - node != end; ++node) + wxClassInfo::sm_classTable->BeginFind(); + node = wxClassInfo::sm_classTable->Next(); + while (node) { - info = *node; + info = (wxClassInfo *)node->GetData(); if (info->GetClassName()) { wxString msg(info->GetClassName()); @@ -762,6 +776,7 @@ bool wxDebugContext::PrintClasses(void) wxLogMessage(msg); } + node = wxClassInfo::sm_classTable->Next(); n ++; } wxLogMessage(wxEmptyString); @@ -784,7 +799,7 @@ int wxDebugContext::Check(bool checkAll) { int nFailures = 0; - wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); + wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); if (!from || checkAll) from = wxDebugContext::GetHead (); @@ -830,26 +845,21 @@ void wxDebugContext::OutputDumpLine(const wxChar *szFormat, ...) int count; va_list argptr; va_start(argptr, szFormat); - buf[WXSIZEOF(buf)-1] = wxT('\0'); + buf[sizeof(buf)/sizeof(wxChar)-1] = _T('\0'); // keep 3 bytes for a \r\n\0 - count = wxVsnprintf(buf, WXSIZEOF(buf)-3, szFormat, argptr); + count = wxVsnprintf(buf, sizeof(buf)/sizeof(wxChar)-3, szFormat, argptr); if ( count < 0 ) - count = WXSIZEOF(buf)-3; - buf[count]=wxT('\r'); - buf[count+1]=wxT('\n'); - buf[count+2]=wxT('\0'); + count = sizeof(buf)/sizeof(wxChar)-3; + buf[count]=_T('\r'); + buf[count+1]=_T('\n'); + buf[count+2]=_T('\0'); wxMessageOutputDebug dbgout; dbgout.Printf(buf); } -void wxDebugContext::SetShutdownNotifyFunction(wxShutdownNotifyFunction shutdownFn) -{ - sm_shutdownFn = shutdownFn; -} - #if USE_THREADSAFE_MEMORY_ALLOCATION static bool memSectionOk = false; @@ -886,7 +896,8 @@ static MemoryCriticalSection memLocker; #endif // USE_THREADSAFE_MEMORY_ALLOCATION -#if !(defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) +#ifdef __WXDEBUG__ +#if !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) #if wxUSE_GLOBAL_MEMORY_OPERATORS void * operator new (size_t size, wxChar * fileName, int lineNum) { @@ -920,7 +931,7 @@ void operator delete[] (void * buf) } #endif // wxUSE_ARRAY_MEMORY_OPERATORS #endif // wxUSE_GLOBAL_MEMORY_OPERATORS -#endif // !(defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) +#endif // !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) // TODO: store whether this is a vector or not. void * wxDebugAlloc(size_t size, wxChar * fileName, int lineNum, bool isObject, bool WXUNUSED(isVect) ) @@ -1032,6 +1043,8 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) free((char *)st); } +#endif // __WXDEBUG__ + // Trace: send output to the current debugging stream void wxTrace(const wxChar * ...) { @@ -1043,7 +1056,7 @@ void wxTrace(const wxChar * ...) va_start(ap, fmt); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ wvsprintf(buffer,fmt,ap) ; #else vsprintf(buffer,fmt,ap) ; @@ -1057,7 +1070,7 @@ void wxTrace(const wxChar * ...) wxDebugContext::GetStream().flush(); } else -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #ifdef __WIN32__ OutputDebugString((LPCTSTR)buffer) ; #else @@ -1083,7 +1096,7 @@ void wxTraceLevel(int, const wxChar * ...) va_start(ap, fmt); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ wxWvsprintf(buffer,fmt,ap) ; #else vsprintf(buffer,fmt,ap) ; @@ -1097,7 +1110,7 @@ void wxTraceLevel(int, const wxChar * ...) wxDebugContext::GetStream().flush(); } else -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #ifdef __WIN32__ OutputDebugString((LPCTSTR)buffer) ; #else @@ -1118,22 +1131,6 @@ void wxTraceLevel(int, const wxChar * ...) // All global variables are initialized to 0 at the very beginning, and this is just fine. int wxDebugContextDumpDelayCounter::sm_count; -wxDebugContextDumpDelayCounter::wxDebugContextDumpDelayCounter() -{ - sm_count++; -} - -wxDebugContextDumpDelayCounter::~wxDebugContextDumpDelayCounter() -{ - if ( !--sm_count ) - { - // Notify app if we've been asked to do that - if( wxDebugContext::sm_shutdownFn ) - wxDebugContext::sm_shutdownFn(); - DoDump(); - } -} - void wxDebugContextDumpDelayCounter::DoDump() { if (wxDebugContext::CountObjectsLeft(true) > 0) @@ -1148,4 +1145,4 @@ void wxDebugContextDumpDelayCounter::DoDump() // least one cleanup counter object static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_One; -#endif // wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT +#endif // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT diff --git a/Source/3rd Party/wx/src/common/menucmn.cpp b/Source/3rd Party/wx/src/common/menucmn.cpp index e92a04704..145fe9b01 100644 --- a/Source/3rd Party/wx/src/common/menucmn.cpp +++ b/Source/3rd Party/wx/src/common/menucmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 26.10.99 +// RCS-ID: $Id: menucmn.cpp 57852 2009-01-06 09:40:34Z SC $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -25,11 +26,12 @@ #if wxUSE_MENUS +#include + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" #include "wx/menu.h" - #include "wx/frame.h" #endif #include "wx/stockitem.h" @@ -48,229 +50,356 @@ WX_DEFINE_LIST(wxMenuItemList) // ============================================================================ // ---------------------------------------------------------------------------- -// XTI for wxMenu(Bar) +// wxAcceleratorEntry // ---------------------------------------------------------------------------- -wxDEFINE_FLAGS( wxMenuStyle ) -wxBEGIN_FLAGS( wxMenuStyle ) -wxFLAGS_MEMBER(wxMENU_TEAROFF) -wxEND_FLAGS( wxMenuStyle ) -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxMenu, wxEvtHandler, "wx/menu.h") -wxCOLLECTION_TYPE_INFO( wxMenuItem *, wxMenuItemList ) ; +#if wxUSE_ACCEL -#if wxUSE_EXTENDED_RTTI -template<> void wxCollectionToVariantArray( wxMenuItemList const &theList, - wxAnyList &value) +static const struct wxKeyName { - wxListCollectionToAnyList( theList, value ) ; -} + wxKeyCode code; + const wxChar *name; +} wxKeyNames[] = +{ + { WXK_DELETE, wxTRANSLATE("DEL") }, + { WXK_DELETE, wxTRANSLATE("DELETE") }, + { WXK_BACK, wxTRANSLATE("BACK") }, + { WXK_INSERT, wxTRANSLATE("INS") }, + { WXK_INSERT, wxTRANSLATE("INSERT") }, + { WXK_RETURN, wxTRANSLATE("ENTER") }, + { WXK_RETURN, wxTRANSLATE("RETURN") }, + { WXK_PAGEUP, wxTRANSLATE("PGUP") }, + { WXK_PAGEDOWN, wxTRANSLATE("PGDN") }, + { WXK_LEFT, wxTRANSLATE("LEFT") }, + { WXK_RIGHT, wxTRANSLATE("RIGHT") }, + { WXK_UP, wxTRANSLATE("UP") }, + { WXK_DOWN, wxTRANSLATE("DOWN") }, + { WXK_HOME, wxTRANSLATE("HOME") }, + { WXK_END, wxTRANSLATE("END") }, + { WXK_SPACE, wxTRANSLATE("SPACE") }, + { WXK_TAB, wxTRANSLATE("TAB") }, + { WXK_ESCAPE, wxTRANSLATE("ESC") }, + { WXK_ESCAPE, wxTRANSLATE("ESCAPE") }, + { WXK_CANCEL, wxTRANSLATE("CANCEL") }, + { WXK_CLEAR, wxTRANSLATE("CLEAR") }, + { WXK_MENU, wxTRANSLATE("MENU") }, + { WXK_PAUSE, wxTRANSLATE("PAUSE") }, + { WXK_CAPITAL, wxTRANSLATE("CAPITAL") }, + { WXK_SELECT, wxTRANSLATE("SELECT") }, + { WXK_PRINT, wxTRANSLATE("PRINT") }, + { WXK_EXECUTE, wxTRANSLATE("EXECUTE") }, + { WXK_SNAPSHOT, wxTRANSLATE("SNAPSHOT") }, + { WXK_HELP, wxTRANSLATE("HELP") }, + { WXK_ADD, wxTRANSLATE("ADD") }, + { WXK_SEPARATOR, wxTRANSLATE("SEPARATOR") }, + { WXK_SUBTRACT, wxTRANSLATE("SUBTRACT") }, + { WXK_DECIMAL, wxTRANSLATE("DECIMAL") }, + { WXK_DIVIDE, wxTRANSLATE("DIVIDE") }, + { WXK_NUMLOCK, wxTRANSLATE("NUM_LOCK") }, + { WXK_SCROLL, wxTRANSLATE("SCROLL_LOCK") }, + { WXK_PAGEUP, wxTRANSLATE("PAGEUP") }, + { WXK_PAGEDOWN, wxTRANSLATE("PAGEDOWN") }, + { WXK_NUMPAD_SPACE, wxTRANSLATE("KP_SPACE") }, + { WXK_NUMPAD_TAB, wxTRANSLATE("KP_TAB") }, + { WXK_NUMPAD_ENTER, wxTRANSLATE("KP_ENTER") }, + { WXK_NUMPAD_HOME, wxTRANSLATE("KP_HOME") }, + { WXK_NUMPAD_LEFT, wxTRANSLATE("KP_LEFT") }, + { WXK_NUMPAD_UP, wxTRANSLATE("KP_UP") }, + { WXK_NUMPAD_RIGHT, wxTRANSLATE("KP_RIGHT") }, + { WXK_NUMPAD_DOWN, wxTRANSLATE("KP_DOWN") }, + { WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PRIOR") }, + { WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PAGEUP") }, + { WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_NEXT") }, + { WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_PAGEDOWN") }, + { WXK_NUMPAD_END, wxTRANSLATE("KP_END") }, + { WXK_NUMPAD_BEGIN, wxTRANSLATE("KP_BEGIN") }, + { WXK_NUMPAD_INSERT, wxTRANSLATE("KP_INSERT") }, + { WXK_NUMPAD_DELETE, wxTRANSLATE("KP_DELETE") }, + { WXK_NUMPAD_EQUAL, wxTRANSLATE("KP_EQUAL") }, + { WXK_NUMPAD_MULTIPLY, wxTRANSLATE("KP_MULTIPLY") }, + { WXK_NUMPAD_ADD, wxTRANSLATE("KP_ADD") }, + { WXK_NUMPAD_SEPARATOR, wxTRANSLATE("KP_SEPARATOR") }, + { WXK_NUMPAD_SUBTRACT, wxTRANSLATE("KP_SUBTRACT") }, + { WXK_NUMPAD_DECIMAL, wxTRANSLATE("KP_DECIMAL") }, + { WXK_NUMPAD_DIVIDE, wxTRANSLATE("KP_DIVIDE") }, + { WXK_WINDOWS_LEFT, wxTRANSLATE("WINDOWS_LEFT") }, + { WXK_WINDOWS_RIGHT, wxTRANSLATE("WINDOWS_RIGHT") }, + { WXK_WINDOWS_MENU, wxTRANSLATE("WINDOWS_MENU") }, + { WXK_COMMAND, wxTRANSLATE("COMMAND") }, +}; + +// return true if the 2 strings refer to the same accel +// +// as accels can be either translated or not, check for both possibilities and +// also compare case-insensitively as the key names case doesn't count +static inline bool CompareAccelString(const wxString& str, const wxChar *accel) +{ + return str.CmpNoCase(accel) == 0 +#if wxUSE_INTL + || str.CmpNoCase(wxGetTranslation(accel)) == 0 #endif - -wxBEGIN_PROPERTIES_TABLE(wxMenu) -wxEVENT_PROPERTY( Select, wxEVT_MENU, wxCommandEvent) - -wxPROPERTY( Title, wxString, SetTitle, GetTitle, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) - -wxREADONLY_PROPERTY_FLAGS( MenuStyle, wxMenuStyle, long, GetStyle, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), \ - wxT("group")) // style - -wxPROPERTY_COLLECTION( MenuItems, wxMenuItemList, wxMenuItem*, Append, \ - GetMenuItems, 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxMenu) - -wxDIRECT_CONSTRUCTOR_2( wxMenu, wxString, Title, long, MenuStyle ) - -wxDEFINE_FLAGS( wxMenuBarStyle ) - -wxBEGIN_FLAGS( wxMenuBarStyle ) -wxFLAGS_MEMBER(wxMB_DOCKABLE) -wxEND_FLAGS( wxMenuBarStyle ) - -#if wxUSE_EXTENDED_RTTI -// the negative id would lead the window (its superclass !) to -// vetoe streaming out otherwise -bool wxMenuBarStreamingCallback( const wxObject *WXUNUSED(object), wxObjectWriter *, - wxObjectWriterCallback *, const wxStringToAnyHashMap & ) -{ - return true; -} -#endif - -wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow, "wx/menu.h", \ - wxMenuBarStreamingCallback) - - -#if wxUSE_EXTENDED_RTTI -WX_DEFINE_LIST( wxMenuInfoHelperList ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxMenuInfoHelper, wxObject, "wx/menu.h") - -wxBEGIN_PROPERTIES_TABLE(wxMenuInfoHelper) -wxREADONLY_PROPERTY( Menu, wxMenu*, GetMenu, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - -wxREADONLY_PROPERTY( Title, wxString, GetTitle, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxMenuInfoHelper) - -wxCONSTRUCTOR_2( wxMenuInfoHelper, wxMenu*, Menu, wxString, Title ) - -wxCOLLECTION_TYPE_INFO( wxMenuInfoHelper *, wxMenuInfoHelperList ) ; - -template<> void wxCollectionToVariantArray( wxMenuInfoHelperList const &theList, - wxAnyList &value) -{ - wxListCollectionToAnyList( theList, value ) ; + ; } -#endif - -wxBEGIN_PROPERTIES_TABLE(wxMenuBar) -wxPROPERTY_COLLECTION( MenuInfos, wxMenuInfoHelperList, wxMenuInfoHelper*, AppendMenuInfo, \ - GetMenuInfos, 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxMenuBar) - -wxCONSTRUCTOR_DUMMY( wxMenuBar ) - -#if wxUSE_EXTENDED_RTTI - -const wxMenuInfoHelperList& wxMenuBarBase::GetMenuInfos() const +// return prefixCode+number if the string is of the form "" and +// 0 if it isn't +// +// first and last parameter specify the valid domain for "number" part +static int + IsNumberedAccelKey(const wxString& str, + const wxChar *prefix, + wxKeyCode prefixCode, + unsigned first, + unsigned last) { - wxMenuInfoHelperList* list = const_cast< wxMenuInfoHelperList* > (& m_menuInfos); - WX_CLEAR_LIST( wxMenuInfoHelperList, *list); - for (size_t i = 0 ; i < GetMenuCount(); ++i) + const size_t lenPrefix = wxStrlen(prefix); + if ( !CompareAccelString(str.Left(lenPrefix), prefix) ) + return 0; + + unsigned long num; + if ( !str.Mid(lenPrefix).ToULong(&num) ) + return 0; + + if ( num < first || num > last ) { - wxMenuInfoHelper* info = new wxMenuInfoHelper(); - info->Create( GetMenu(i), GetMenuLabel(i)); - list->Append(info); + // this must be a mistake, chances that this is a valid name of another + // key are vanishingly small + wxLogDebug(_T("Invalid key string \"%s\""), str.c_str()); + return 0; } - return m_menuInfos; + + return prefixCode + num - first; } -#endif - -// ---------------------------------------------------------------------------- -// XTI for wxMenuItem -// ---------------------------------------------------------------------------- - -#if wxUSE_EXTENDED_RTTI - -bool wxMenuItemStreamingCallback( const wxObject *object, wxObjectWriter *, - wxObjectWriterCallback *, const wxStringToAnyHashMap & ) +/* static */ +bool +wxAcceleratorEntry::ParseAccel(const wxString& text, int *flagsOut, int *keyOut) { - const wxMenuItem * mitem = wx_dynamic_cast(const wxMenuItem*, object); - if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().empty() ) + // the parser won't like trailing spaces + wxString label = text; + label.Trim(true); // the initial \t must be preserved so don't strip leading whitespaces + + // check for accelerators: they are given after '\t' + int posTab = label.Find(wxT('\t')); + if ( posTab == wxNOT_FOUND ) { - // we don't stream out the first two items for menus with a title, - // they will be reconstructed - if ( mitem->GetMenu()->FindItemByPosition(0) == mitem || - mitem->GetMenu()->FindItemByPosition(1) == mitem ) + return false; + } + + // parse the accelerator string + int accelFlags = wxACCEL_NORMAL; + wxString current; + for ( size_t n = (size_t)posTab + 1; n < label.length(); n++ ) + { + if ( (label[n] == '+') || (label[n] == '-') ) + { + // differentiate between a ctrl that will be translated to cmd on mac + // and an explicit xctrl that will not be translated and remains a ctrl + if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) + accelFlags |= wxACCEL_CMD; + else if ( CompareAccelString(current, wxTRANSLATE("xctrl")) ) + accelFlags |= wxACCEL_CTRL; + else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) + accelFlags |= wxACCEL_ALT; + else if ( CompareAccelString(current, wxTRANSLATE("shift")) ) + accelFlags |= wxACCEL_SHIFT; + else // not a recognized modifier name + { + // we may have "Ctrl-+", for example, but we still want to + // catch typos like "Crtl-A" so only give the warning if we + // have something before the current '+' or '-', else take + // it as a literal symbol + if ( current.empty() ) + { + current += label[n]; + + // skip clearing it below + continue; + } + else + { + wxLogDebug(wxT("Unknown accel modifier: '%s'"), + current.c_str()); + } + } + + current.clear(); + } + else // not special character + { + current += (wxChar) wxTolower(label[n]); + } + } + + int keyCode; + const size_t len = current.length(); + switch ( len ) + { + case 0: + wxLogDebug(wxT("No accel key found, accel string ignored.")); return false; + + case 1: + // it's just a letter + keyCode = current[0U]; + + // if the key is used with any modifiers, make it an uppercase one + // because Ctrl-A and Ctrl-a are the same; but keep it as is if it's + // used alone as 'a' and 'A' are different + if ( accelFlags != wxACCEL_NORMAL ) + keyCode = wxToupper(keyCode); + break; + + default: + keyCode = IsNumberedAccelKey(current, wxTRANSLATE("F"), + WXK_F1, 1, 12); + if ( !keyCode ) + { + for ( size_t n = 0; n < WXSIZEOF(wxKeyNames); n++ ) + { + const wxKeyName& kn = wxKeyNames[n]; + if ( CompareAccelString(current, kn.name) ) + { + keyCode = kn.code; + break; + } + } + } + + if ( !keyCode ) + keyCode = IsNumberedAccelKey(current, wxTRANSLATE("KP_"), + WXK_NUMPAD0, 0, 9); + if ( !keyCode ) + keyCode = IsNumberedAccelKey(current, wxTRANSLATE("SPECIAL"), + WXK_SPECIAL1, 1, 20); + + if ( !keyCode ) + { + wxLogDebug(wxT("Unrecognized accel key '%s', accel string ignored."), + current.c_str()); + return false; + } } + + + wxASSERT_MSG( keyCode, _T("logic error: should have key code here") ); + + if ( flagsOut ) + *flagsOut = accelFlags; + if ( keyOut ) + *keyOut = keyCode; + return true; } +/* static */ +wxAcceleratorEntry *wxAcceleratorEntry::Create(const wxString& str) +{ + int flags, + keyCode; + if ( !ParseAccel(str, &flags, &keyCode) ) + return NULL; + + return new wxAcceleratorEntry(flags, keyCode); +} + +bool wxAcceleratorEntry::FromString(const wxString& str) +{ + return ParseAccel(str, &m_flags, &m_keyCode); +} + +wxString wxAcceleratorEntry::ToString() const +{ + wxString text; + + int flags = GetFlags(); + if ( flags & wxACCEL_ALT ) + text += _("Alt-"); + if ( flags & wxACCEL_CMD ) + text += _("Ctrl-"); +#ifdef __WXMAC__ + if ( flags & wxACCEL_CTRL ) + text += _("XCtrl-"); #endif + if ( flags & wxACCEL_SHIFT ) + text += _("Shift-"); -wxBEGIN_ENUM( wxItemKind ) -wxENUM_MEMBER( wxITEM_SEPARATOR ) -wxENUM_MEMBER( wxITEM_NORMAL ) -wxENUM_MEMBER( wxITEM_CHECK ) -wxENUM_MEMBER( wxITEM_RADIO ) -wxEND_ENUM( wxItemKind ) + const int code = GetKeyCode(); -wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject, "wx/menuitem.h", \ - wxMenuItemStreamingCallback) + if ( code >= WXK_F1 && code <= WXK_F12 ) + text << _("F") << code - WXK_F1 + 1; + else if ( code >= WXK_NUMPAD0 && code <= WXK_NUMPAD9 ) + text << _("KP_") << code - WXK_NUMPAD0; + else if ( code >= WXK_SPECIAL1 && code <= WXK_SPECIAL20 ) + text << _("SPECIAL") << code - WXK_SPECIAL1 + 1; + else // check the named keys + { + size_t n; + for ( n = 0; n < WXSIZEOF(wxKeyNames); n++ ) + { + const wxKeyName& kn = wxKeyNames[n]; + if ( code == kn.code ) + { + text << wxGetTranslation(kn.name); + break; + } + } -wxBEGIN_PROPERTIES_TABLE(wxMenuItem) -wxPROPERTY( Parent, wxMenu*, SetMenu, GetMenu, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Id, int, SetId, GetId, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( ItemLabel, wxString, SetItemLabel, GetItemLabel, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Help, wxString, SetHelp, GetHelp, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxREADONLY_PROPERTY( Kind, wxItemKind, GetKind, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( SubMenu, wxMenu*, SetSubMenu, GetSubMenu, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxAny((bool)true), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Checked, bool, Check, IsChecked, wxAny((bool)false), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Checkable, bool, SetCheckable, IsCheckable, wxAny((bool)false), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxEND_PROPERTIES_TABLE() + if ( n == WXSIZEOF(wxKeyNames) ) + { + // must be a simple key + if ( +#if !wxUSE_UNICODE + isascii(code) && +#endif // ANSI + wxIsalnum(code) ) + { + text << (wxChar)code; + } + else + { + wxFAIL_MSG( wxT("unknown keyboard accelerator code") ); + } + } + } -wxEMPTY_HANDLERS_TABLE(wxMenuItem) + return text; +} + +wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) +{ + return wxAcceleratorEntry::Create(label); +} + +#endif // wxUSE_ACCEL -wxDIRECT_CONSTRUCTOR_6( wxMenuItem, wxMenu*, Parent, int, Id, wxString, \ - Text, wxString, Help, wxItemKind, Kind, wxMenu*, SubMenu ) // ---------------------------------------------------------------------------- -// wxMenuItemBase +// wxMenuItem // ---------------------------------------------------------------------------- wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu, - int itemid, + int id, const wxString& text, const wxString& help, wxItemKind kind, wxMenu *subMenu) { - switch ( itemid ) - { - case wxID_ANY: - m_id = wxWindow::NewControlId(); - break; - - case wxID_SEPARATOR: - m_id = wxID_SEPARATOR; - - // there is a lot of existing code just doing Append(wxID_SEPARATOR) - // and it makes sense to omit the following optional parameters, - // including the kind one which doesn't default to wxITEM_SEPARATOR, - // of course, so override it here - kind = wxITEM_SEPARATOR; - break; - - case wxID_NONE: - // (popup) menu titles in wxMSW use this ID to indicate that - // it's not a real menu item, so we don't want the check below to - // apply to it - m_id = itemid; - break; - - default: - // ids are limited to 16 bits under MSW so portable code shouldn't - // use ids outside of this range (negative ids generated by wx are - // fine though) - wxASSERT_MSG( (itemid >= 0 && itemid < SHRT_MAX) || - (itemid >= wxID_AUTO_LOWEST && itemid <= wxID_AUTO_HIGHEST), - wxS("invalid itemid value") ); - m_id = itemid; - } - - // notice that parentMenu can be NULL: the item can be attached to the menu - // later with SetMenu() + wxASSERT_MSG( parentMenu != NULL, wxT("menuitem should have a menu") ); m_parentMenu = parentMenu; m_subMenu = subMenu; m_isEnabled = true; m_isChecked = false; + m_id = id; m_kind = kind; + if (m_id == wxID_ANY) + m_id = wxNewId(); + if (m_id == wxID_SEPARATOR) + m_kind = wxITEM_SEPARATOR; - SetItemLabel(text); + SetText(text); SetHelp(help); } @@ -283,7 +412,7 @@ wxMenuItemBase::~wxMenuItemBase() wxAcceleratorEntry *wxMenuItemBase::GetAccel() const { - return wxAcceleratorEntry::Create(GetItemLabel()); + return wxAcceleratorEntry::Create(GetText()); } void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) @@ -295,12 +424,12 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) text += accel->ToString(); } - SetItemLabel(text); + SetText(text); } #endif // wxUSE_ACCEL -void wxMenuItemBase::SetItemLabel(const wxString& str) +void wxMenuItemBase::SetText(const wxString& str) { m_text = str; @@ -324,19 +453,10 @@ void wxMenuItemBase::SetHelp(const wxString& str) } } -#ifndef __WXPM__ -wxString wxMenuItemBase::GetLabelText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& label) { - return wxStripMenuCodes(text); + return GetLabelFromText(label); } -#endif - -#if WXWIN_COMPATIBILITY_2_8 -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) -{ - return GetLabelText(text); -} -#endif bool wxMenuBase::ms_locked = true; @@ -346,12 +466,12 @@ bool wxMenuBase::ms_locked = true; void wxMenuBase::Init(long style) { - m_menuBar = NULL; - m_menuParent = NULL; + m_menuBar = (wxMenuBar *)NULL; + m_menuParent = (wxMenu *)NULL; - m_invokingWindow = NULL; + m_invokingWindow = (wxWindow *)NULL; m_style = style; - m_clientData = NULL; + m_clientData = (void *)NULL; m_eventHandler = this; } @@ -366,7 +486,7 @@ wxMenuBase::~wxMenuBase() void wxMenuBase::AddSubMenu(wxMenu *submenu) { - wxCHECK_RET( submenu, wxT("can't add a NULL submenu") ); + wxCHECK_RET( submenu, _T("can't add a NULL submenu") ); submenu->SetParent((wxMenu *)this); } @@ -438,11 +558,11 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item) m_items.Erase(node); // item isn't attached to anything any more - item->SetMenu(NULL); + item->SetMenu((wxMenu *)NULL); wxMenu *submenu = item->GetSubMenu(); if ( submenu ) { - submenu->SetParent(NULL); + submenu->SetParent((wxMenu *)NULL); if ( submenu->IsAttached() ) submenu->Detach(); } @@ -463,7 +583,7 @@ bool wxMenuBase::DoDelete(wxMenuItem *item) wxCHECK_MSG( item2, false, wxT("failed to delete menu item") ); // don't delete the submenu - item2->SetSubMenu(NULL); + item2->SetSubMenu((wxMenu *)NULL); delete item2; @@ -494,7 +614,7 @@ bool wxMenuBase::DoDestroy(wxMenuItem *item) // Finds the item id matching the given string, wxNOT_FOUND if not found. int wxMenuBase::FindItem(const wxString& text) const { - wxString label = wxMenuItem::GetLabelText(text); + wxString label = wxMenuItem::GetLabelFromText(text); for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); node; node = node->GetNext() ) @@ -511,7 +631,7 @@ int wxMenuBase::FindItem(const wxString& text) const // name just like the ordinary items if ( !item->IsSeparator() ) { - if ( item->GetItemLabelText() == label ) + if ( item->GetLabel() == label ) return item->GetId(); } } @@ -552,15 +672,15 @@ wxMenuItem *wxMenuBase::FindItem(int itemId, wxMenu **itemMenu) const } // non recursive search -wxMenuItem *wxMenuBase::FindChildItem(int itemid, size_t *ppos) const +wxMenuItem *wxMenuBase::FindChildItem(int id, size_t *ppos) const { - wxMenuItem *item = NULL; + wxMenuItem *item = (wxMenuItem *)NULL; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); size_t pos; for ( pos = 0; node; pos++ ) { - if ( node->GetData()->GetId() == itemid ) + if ( node->GetData()->GetId() == id ) { item = node->GetData(); @@ -582,7 +702,7 @@ wxMenuItem *wxMenuBase::FindChildItem(int itemid, size_t *ppos) const wxMenuItem* wxMenuBase::FindItemByPosition(size_t position) const { wxCHECK_MSG( position < m_items.GetCount(), NULL, - wxT("wxMenu::FindItemByPosition(): invalid menu index") ); + _T("wxMenu::FindItemByPosition(): invalid menu index") ); return m_items.Item( position )->GetData(); } @@ -596,10 +716,17 @@ wxMenuItem* wxMenuBase::FindItemByPosition(size_t position) const // window will be used. void wxMenuBase::UpdateUI(wxEvtHandler* source) { - wxWindow * const win = GetWindow(); + if (GetInvokingWindow()) + { + // Don't update menus if the parent + // frame is about to get deleted + wxWindow *tlw = wxGetTopLevelParent( GetInvokingWindow() ); + if (tlw && wxPendingDelete.Member(tlw)) + return; + } - if ( !source && win ) - source = win->GetEventHandler(); + if ( !source && GetInvokingWindow() ) + source = GetInvokingWindow()->GetEventHandler(); if ( !source ) source = GetEventHandler(); if ( !source ) @@ -611,19 +738,19 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source) wxMenuItem* item = node->GetData(); if ( !item->IsSeparator() ) { - wxWindowID itemid = item->GetId(); - wxUpdateUIEvent event(itemid); - event.SetEventObject( this ); + wxWindowID id = item->GetId(); + wxUpdateUIEvent event(id); + event.SetEventObject( source ); if ( source->ProcessEvent(event) ) { // if anything changed, update the changed attribute if (event.GetSetText()) - SetLabel(itemid, event.GetText()); + SetLabel(id, event.GetText()); if (event.GetSetChecked()) - Check(itemid, event.GetChecked()); + Check(id, event.GetChecked()); if (event.GetSetEnabled()) - Enable(itemid, event.GetEnabled()); + Enable(id, event.GetEnabled()); } // recurse to the submenus @@ -636,41 +763,41 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source) } } -bool wxMenuBase::SendEvent(int itemid, int checked) +bool wxMenuBase::SendEvent(int id, int checked) { - wxCommandEvent event(wxEVT_MENU, itemid); + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id); event.SetEventObject(this); event.SetInt(checked); - wxWindow* const win = GetWindow(); - wxMenuBar* const mb = GetMenuBar(); + bool processed = false; - // Try the menu's event handler first - wxEvtHandler *handler = GetEventHandler(); - if ( handler ) + // Try the menu's event handler + // if ( !processed ) { - // Indicate to the event processing code that we're going to pass this - // event to another handler if it's not processed here to prevent it - // from passing the event to wxTheApp: this will be done below if we do - // have the associated window. - if ( win || mb ) - event.SetWillBeProcessedAgain(); - - if ( handler->SafelyProcessEvent(event) ) - return true; + wxEvtHandler *handler = GetEventHandler(); + if ( handler ) + processed = handler->ProcessEvent(event); } - // If this menu is part of the menu bar, process the event there: this will - // also propagate it upwards to the window containing the menu bar. - if ( mb ) - return mb->HandleWindowEvent(event); + // Try the window the menu was popped up from (and up through the + // hierarchy) + if ( !processed ) + { + const wxMenuBase *menu = this; + while ( menu ) + { + wxWindow *win = menu->GetInvokingWindow(); + if ( win ) + { + processed = win->GetEventHandler()->ProcessEvent(event); + break; + } - // Try the window the menu was popped up from. - if ( win ) - return win->HandleWindowEvent(event); + menu = menu->GetParent(); + } + } - // Not processed. - return false; + return processed; } // ---------------------------------------------------------------------------- @@ -687,10 +814,10 @@ wxMenuBar* wxMenuBase::GetMenuBar() const void wxMenuBase::Attach(wxMenuBarBase *menubar) { // use Detach() instead! - wxASSERT_MSG( menubar, wxT("menu can't be attached to NULL menubar") ); + wxASSERT_MSG( menubar, _T("menu can't be attached to NULL menubar") ); // use IsAttached() to prevent this from happening - wxASSERT_MSG( !m_menuBar, wxT("attaching menu twice?") ); + wxASSERT_MSG( !m_menuBar, _T("attaching menu twice?") ); m_menuBar = (wxMenuBar *)menubar; } @@ -698,109 +825,81 @@ void wxMenuBase::Attach(wxMenuBarBase *menubar) void wxMenuBase::Detach() { // use IsAttached() to prevent this from happening - wxASSERT_MSG( m_menuBar, wxT("detaching unattached menu?") ); + wxASSERT_MSG( m_menuBar, _T("detaching unattached menu?") ); m_menuBar = NULL; } -// ---------------------------------------------------------------------------- -// wxMenu invoking window handling -// ---------------------------------------------------------------------------- - -void wxMenuBase::SetInvokingWindow(wxWindow *win) -{ - wxASSERT_MSG( !GetParent(), - "should only be called for top level popup menus" ); - wxASSERT_MSG( !IsAttached(), - "menus attached to menu bar can't have invoking window" ); - - m_invokingWindow = win; -} - -wxWindow *wxMenuBase::GetWindow() const -{ - // only the top level menus have non-NULL invoking window or a pointer to - // the menu bar so recurse upwards until we find it - const wxMenuBase *menu = this; - while ( menu->GetParent() ) - { - menu = menu->GetParent(); - } - - return menu->GetMenuBar() ? menu->GetMenuBar()->GetFrame() - : menu->GetInvokingWindow(); -} - // ---------------------------------------------------------------------------- // wxMenu functions forwarded to wxMenuItem // ---------------------------------------------------------------------------- -void wxMenuBase::Enable( int itemid, bool enable ) +void wxMenuBase::Enable( int id, bool enable ) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenu::Enable: no such item") ); item->Enable(enable); } -bool wxMenuBase::IsEnabled( int itemid ) const +bool wxMenuBase::IsEnabled( int id ) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, false, wxT("wxMenu::IsEnabled: no such item") ); return item->IsEnabled(); } -void wxMenuBase::Check( int itemid, bool enable ) +void wxMenuBase::Check( int id, bool enable ) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenu::Check: no such item") ); item->Check(enable); } -bool wxMenuBase::IsChecked( int itemid ) const +bool wxMenuBase::IsChecked( int id ) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, false, wxT("wxMenu::IsChecked: no such item") ); return item->IsChecked(); } -void wxMenuBase::SetLabel( int itemid, const wxString &label ) +void wxMenuBase::SetLabel( int id, const wxString &label ) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenu::SetLabel: no such item") ); - item->SetItemLabel(label); + item->SetText(label); } -wxString wxMenuBase::GetLabel( int itemid ) const +wxString wxMenuBase::GetLabel( int id ) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, wxEmptyString, wxT("wxMenu::GetLabel: no such item") ); - return item->GetItemLabel(); + return item->GetText(); } -void wxMenuBase::SetHelpString( int itemid, const wxString& helpString ) +void wxMenuBase::SetHelpString( int id, const wxString& helpString ) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenu::SetHelpString: no such item") ); item->SetHelp( helpString ); } -wxString wxMenuBase::GetHelpString( int itemid ) const +wxString wxMenuBase::GetHelpString( int id ) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, wxEmptyString, wxT("wxMenu::GetHelpString: no such item") ); @@ -835,10 +934,9 @@ wxMenu *wxMenuBarBase::GetMenu(size_t pos) const return node->GetData(); } -bool wxMenuBarBase::Append(wxMenu *menu, const wxString& title) +bool wxMenuBarBase::Append(wxMenu *menu, const wxString& WXUNUSED(title)) { wxCHECK_MSG( menu, false, wxT("can't append NULL menu") ); - wxCHECK_MSG( !title.empty(), false, wxT("can't append menu with empty title") ); m_menus.Append(menu); menu->Attach(this); @@ -898,14 +996,14 @@ wxMenu *wxMenuBarBase::Remove(size_t pos) int wxMenuBarBase::FindMenu(const wxString& title) const { - wxString label = wxMenuItem::GetLabelText(title); + wxString label = wxMenuItem::GetLabelFromText(title); size_t count = GetMenuCount(); for ( size_t i = 0; i < count; i++ ) { - wxString title2 = GetMenuLabel(i); + wxString title2 = GetLabelTop(i); if ( (title2 == title) || - (wxMenuItem::GetLabelText(title2) == label) ) + (wxMenuItem::GetLabelFromText(title2) == label) ) { // found return (int)i; @@ -924,7 +1022,6 @@ void wxMenuBarBase::Attach(wxFrame *frame) { wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") ); - SetParent(frame); m_menuBarFrame = frame; } @@ -933,14 +1030,13 @@ void wxMenuBarBase::Detach() wxASSERT_MSG( IsAttached(), wxT("detaching unattached menubar") ); m_menuBarFrame = NULL; - SetParent(NULL); } // ---------------------------------------------------------------------------- // wxMenuBar searching for items // ---------------------------------------------------------------------------- -wxMenuItem *wxMenuBarBase::FindItem(int itemid, wxMenu **menu) const +wxMenuItem *wxMenuBarBase::FindItem(int id, wxMenu **menu) const { if ( menu ) *menu = NULL; @@ -950,7 +1046,7 @@ wxMenuItem *wxMenuBarBase::FindItem(int itemid, wxMenu **menu) const wxMenuList::const_iterator it; for ( i = 0, it = m_menus.begin(); !item && (i < count); i++, it++ ) { - item = (*it)->FindItem(itemid, menu); + item = (*it)->FindItem(id, menu); } return item; @@ -958,13 +1054,13 @@ wxMenuItem *wxMenuBarBase::FindItem(int itemid, wxMenu **menu) const int wxMenuBarBase::FindMenuItem(const wxString& menu, const wxString& item) const { - wxString label = wxMenuItem::GetLabelText(menu); + wxString label = wxMenuItem::GetLabelFromText(menu); int i = 0; wxMenuList::compatibility_iterator node; for ( node = m_menus.GetFirst(); node; node = node->GetNext(), i++ ) { - if ( label == wxMenuItem::GetLabelText(GetMenuLabel(i)) ) + if ( label == wxMenuItem::GetLabelFromText(GetLabelTop(i)) ) return node->GetData()->FindItem(item); } @@ -975,18 +1071,18 @@ int wxMenuBarBase::FindMenuItem(const wxString& menu, const wxString& item) cons // wxMenuBar functions forwarded to wxMenuItem // --------------------------------------------------------------------------- -void wxMenuBarBase::Enable(int itemid, bool enable) +void wxMenuBarBase::Enable(int id, bool enable) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("attempt to enable an item which doesn't exist") ); item->Enable(enable); } -void wxMenuBarBase::Check(int itemid, bool check) +void wxMenuBarBase::Check(int id, bool check) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("attempt to check an item which doesn't exist") ); wxCHECK_RET( item->IsCheckable(), wxT("attempt to check an uncheckable item") ); @@ -994,55 +1090,55 @@ void wxMenuBarBase::Check(int itemid, bool check) item->Check(check); } -bool wxMenuBarBase::IsChecked(int itemid) const +bool wxMenuBarBase::IsChecked(int id) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, false, wxT("wxMenuBar::IsChecked(): no such item") ); return item->IsChecked(); } -bool wxMenuBarBase::IsEnabled(int itemid) const +bool wxMenuBarBase::IsEnabled(int id) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, false, wxT("wxMenuBar::IsEnabled(): no such item") ); return item->IsEnabled(); } -void wxMenuBarBase::SetLabel(int itemid, const wxString& label) +void wxMenuBarBase::SetLabel(int id, const wxString& label) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenuBar::SetLabel(): no such item") ); - item->SetItemLabel(label); + item->SetText(label); } -wxString wxMenuBarBase::GetLabel(int itemid) const +wxString wxMenuBarBase::GetLabel(int id) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, wxEmptyString, wxT("wxMenuBar::GetLabel(): no such item") ); - return item->GetItemLabel(); + return item->GetText(); } -void wxMenuBarBase::SetHelpString(int itemid, const wxString& helpString) +void wxMenuBarBase::SetHelpString(int id, const wxString& helpString) { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_RET( item, wxT("wxMenuBar::SetHelpString(): no such item") ); item->SetHelp(helpString); } -wxString wxMenuBarBase::GetHelpString(int itemid) const +wxString wxMenuBarBase::GetHelpString(int id) const { - wxMenuItem *item = FindItem(itemid); + wxMenuItem *item = FindItem(id); wxCHECK_MSG( item, wxEmptyString, wxT("wxMenuBar::GetHelpString(): no such item") ); @@ -1050,29 +1146,28 @@ wxString wxMenuBarBase::GetHelpString(int itemid) const return item->GetHelp(); } -void wxMenuBarBase::UpdateMenus() +void wxMenuBarBase::UpdateMenus( void ) { + wxEvtHandler* source; wxMenu* menu; int nCount = GetMenuCount(); for (int n = 0; n < nCount; n++) { menu = GetMenu( n ); if (menu != NULL) - menu->UpdateUI( NULL ); + { + source = menu->GetEventHandler(); + if (source != NULL) + menu->UpdateUI( source ); + } } } -#if WXWIN_COMPATIBILITY_2_8 -// get or change the label of the menu at given position -void wxMenuBarBase::SetLabelTop(size_t pos, const wxString& label) +// Get the text only, from the label +wxString wxMenuBarBase::GetMenuLabelText(size_t pos) const { - SetMenuLabel(pos, label); + return wxMenuItem::GetLabelText(((wxMenuBar*)this)->GetMenuLabel(pos)); } -wxString wxMenuBarBase::GetLabelTop(size_t pos) const -{ - return GetMenuLabelText(pos); -} -#endif #endif // wxUSE_MENUS diff --git a/Source/3rd Party/wx/src/common/mimecmn.cpp b/Source/3rd Party/wx/src/common/mimecmn.cpp index ceb86221e..8f914e347 100644 --- a/Source/3rd Party/wx/src/common/mimecmn.cpp +++ b/Source/3rd Party/wx/src/common/mimecmn.cpp @@ -5,6 +5,7 @@ // Modified by: // Chris Elliott (biol75@york.ac.uk) 5 Dec 00: write support for Win32 // Created: 23.09.98 +// RCS-ID: $Id: mimecmn.cpp 47027 2007-06-29 18:23:39Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// @@ -34,7 +35,6 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/module.h" - #include "wx/crt.h" #endif //WX_PRECOMP #include "wx/file.h" @@ -45,10 +45,10 @@ #include // implementation classes: -#if defined(__WINDOWS__) +#if defined(__WXMSW__) #include "wx/msw/mimetype.h" -#elif ( defined(__DARWIN__) ) - #include "wx/osx/mimetype.h" +#elif defined(__WXMAC__) + #include "wx/mac/mimetype.h" #elif defined(__WXPM__) || defined (__EMX__) #include "wx/os2/mimetype.h" #undef __UNIX__ @@ -111,16 +111,18 @@ wxString wxMimeTypeCommands::GetVerbCmd(size_t n) const // wxFileTypeInfo // ---------------------------------------------------------------------------- -void wxFileTypeInfo::DoVarArgInit(const wxString& mimeType, - const wxString& openCmd, - const wxString& printCmd, - const wxString& desc, - va_list argptr) +wxFileTypeInfo::wxFileTypeInfo(const wxChar *mimeType, + const wxChar *openCmd, + const wxChar *printCmd, + const wxChar *desc, + ...) + : m_mimeType(mimeType), + m_openCmd(openCmd), + m_printCmd(printCmd), + m_desc(desc) { - m_mimeType = mimeType; - m_openCmd = openCmd; - m_printCmd = printCmd; - m_desc = desc; + va_list argptr; + va_start(argptr, desc); for ( ;; ) { @@ -130,7 +132,7 @@ void wxFileTypeInfo::DoVarArgInit(const wxString& mimeType, #pragma warning(disable: 1684) #endif - wxArgNormalizedString ext(WX_VA_ARG_STRING(argptr)); + const wxChar *ext = va_arg(argptr, const wxChar *); #ifdef __INTELC__ #pragma warning(pop) @@ -141,20 +143,8 @@ void wxFileTypeInfo::DoVarArgInit(const wxString& mimeType, break; } - m_exts.Add(ext.GetString()); + m_exts.Add(ext); } -} - -void wxFileTypeInfo::VarArgInit(const wxString *mimeType, - const wxString *openCmd, - const wxString *printCmd, - const wxString *desc, - ...) -{ - va_list argptr; - va_start(argptr, desc); - - DoVarArgInit(*mimeType, *openCmd, *printCmd, *desc, argptr); va_end(argptr); } @@ -191,28 +181,22 @@ wxString wxFileType::ExpandCommand(const wxString& command, { bool hasFilename = false; - // We consider that only the file names with spaces in them need to be - // handled specially. This is not perfect, but this can be done easily - // under all platforms while handling the file names with quotes in them, - // for example, needs to be done differently. - const bool needToQuoteFilename = params.GetFileName().find_first_of(" \t") - != wxString::npos; - wxString str; for ( const wxChar *pc = command.c_str(); *pc != wxT('\0'); pc++ ) { if ( *pc == wxT('%') ) { switch ( *++pc ) { case wxT('s'): - // don't quote the file name if it's already quoted: notice - // that we check for a quote following it and not preceding - // it as at least under Windows we can have commands - // containing "file://%s" (with quotes) in them so the - // argument may be quoted even if there is no quote - // directly before "%s" itself - if ( needToQuoteFilename && pc[1] != '"' ) - str << wxT('"') << params.GetFileName() << wxT('"'); - else + // '%s' expands into file name (quoted because it might + // contain spaces) - except if there are already quotes + // there because otherwise some programs may get confused + // by double double quotes +#if 0 + if ( *(pc - 2) == wxT('"') ) str << params.GetFileName(); + else + str << wxT('"') << params.GetFileName() << wxT('"'); +#endif + str << params.GetFileName(); hasFilename = true; break; @@ -267,16 +251,10 @@ wxString wxFileType::ExpandCommand(const wxString& command, // test now carried out on reading file so test should never get here if ( !hasFilename && !str.empty() #ifdef __UNIX__ - && !str.StartsWith(wxT("test ")) + && !str.StartsWith(_T("test ")) #endif // Unix - ) - { - str << wxT(" < "); - if ( needToQuoteFilename ) - str << '"'; - str << params.GetFileName(); - if ( needToQuoteFilename ) - str << '"'; + ) { + str << wxT(" < '") << params.GetFileName() << wxT('\''); } return str; @@ -313,7 +291,7 @@ bool wxFileType::GetExtensions(wxArrayString& extensions) bool wxFileType::GetMimeType(wxString *mimeType) const { - wxCHECK_MSG( mimeType, false, wxT("invalid parameter in GetMimeType") ); + wxCHECK_MSG( mimeType, false, _T("invalid parameter in GetMimeType") ); if ( m_info ) { @@ -345,9 +323,9 @@ bool wxFileType::GetIcon(wxIconLocation *iconLoc) const if ( iconLoc ) { iconLoc->SetFileName(m_info->GetIconFile()); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ iconLoc->SetIndex(m_info->GetIconIndex()); -#endif // __WINDOWS__ +#endif // __WXMSW__ } return true; @@ -377,7 +355,7 @@ wxFileType::GetIcon(wxIconLocation *iconloc, bool wxFileType::GetDescription(wxString *desc) const { - wxCHECK_MSG( desc, false, wxT("invalid parameter in GetDescription") ); + wxCHECK_MSG( desc, false, _T("invalid parameter in GetDescription") ); if ( m_info ) { @@ -393,7 +371,7 @@ bool wxFileType::GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const { - wxCHECK_MSG( openCmd, false, wxT("invalid parameter in GetOpenCommand") ); + wxCHECK_MSG( openCmd, false, _T("invalid parameter in GetOpenCommand") ); if ( m_info ) { @@ -421,7 +399,7 @@ bool wxFileType::GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const { - wxCHECK_MSG( printCmd, false, wxT("invalid parameter in GetPrintCommand") ); + wxCHECK_MSG( printCmd, false, _T("invalid parameter in GetPrintCommand") ); if ( m_info ) { @@ -443,9 +421,9 @@ size_t wxFileType::GetAllCommands(wxArrayString *verbs, if ( commands ) commands->Clear(); -#if defined (__WINDOWS__) || defined(__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->GetAllCommands(verbs, commands, params); -#else // !__WINDOWS__ || __UNIX__ +#else // !__WXMSW__ || Unix // we don't know how to retrieve all commands, so just try the 2 we know // about size_t count = 0; @@ -453,7 +431,7 @@ size_t wxFileType::GetAllCommands(wxArrayString *verbs, if ( GetOpenCommand(&cmd, params) ) { if ( verbs ) - verbs->Add(wxT("Open")); + verbs->Add(_T("Open")); if ( commands ) commands->Add(cmd); count++; @@ -462,7 +440,7 @@ size_t wxFileType::GetAllCommands(wxArrayString *verbs, if ( GetPrintCommand(&cmd, params) ) { if ( verbs ) - verbs->Add(wxT("Print")); + verbs->Add(_T("Print")); if ( commands ) commands->Add(cmd); @@ -470,17 +448,17 @@ size_t wxFileType::GetAllCommands(wxArrayString *verbs, } return count; -#endif // __WINDOWS__/| __UNIX__ +#endif // __WXMSW__/| __UNIX__ } bool wxFileType::Unassociate() { -#if defined(__WINDOWS__) +#if defined(__WXMSW__) return m_impl->Unassociate(); #elif defined(__UNIX__) return m_impl->Unassociate(this); #else - wxFAIL_MSG( wxT("not implemented") ); // TODO + wxFAIL_MSG( _T("not implemented") ); // TODO return false; #endif } @@ -489,13 +467,13 @@ bool wxFileType::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt) { -#if defined (__WINDOWS__) || defined(__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetCommand(cmd, verb, overwriteprompt); #else wxUnusedVar(cmd); wxUnusedVar(verb); wxUnusedVar(overwriteprompt); - wxFAIL_MSG(wxT("not implemented")); + wxFAIL_MSG(_T("not implemented")); return false; #endif } @@ -503,19 +481,19 @@ bool wxFileType::SetCommand(const wxString& cmd, bool wxFileType::SetDefaultIcon(const wxString& cmd, int index) { wxString sTmp = cmd; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // VZ: should we do this? // chris elliott : only makes sense in MS windows if ( sTmp.empty() ) GetOpenCommand(&sTmp, wxFileType::MessageParameters(wxEmptyString, wxEmptyString)); #endif - wxCHECK_MSG( !sTmp.empty(), false, wxT("need the icon file") ); + wxCHECK_MSG( !sTmp.empty(), false, _T("need the icon file") ); -#if defined (__WINDOWS__) || defined(__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetDefaultIcon (cmd, index); #else wxUnusedVar(index); - wxFAIL_MSG(wxT("not implemented")); + wxFAIL_MSG(_T("not implemented")); return false; #endif } @@ -609,11 +587,11 @@ wxMimeTypesManager::Associate(const wxFileTypeInfo& ftInfo) { EnsureImpl(); -#if defined(__WINDOWS__) || defined(__UNIX__) +#if defined(__WXMSW__) || defined(__UNIX__) return m_impl->Associate(ftInfo); #else // other platforms wxUnusedVar(ftInfo); - wxFAIL_MSG( wxT("not implemented") ); // TODO + wxFAIL_MSG( _T("not implemented") ); // TODO return NULL; #endif // platforms } @@ -631,7 +609,7 @@ wxMimeTypesManager::GetFileTypeFromExtension(const wxString& ext) else extWithoutDot = ext; - wxCHECK_MSG( !ext.empty(), NULL, wxT("extension can't be empty") ); + wxCHECK_MSG( !ext.empty(), NULL, _T("extension can't be empty") ); wxFileType *ft = m_impl->GetFileTypeFromExtension(extWithoutDot); @@ -678,6 +656,18 @@ wxMimeTypesManager::GetFileTypeFromMimeType(const wxString& mimeType) return ft; } +bool wxMimeTypesManager::ReadMailcap(const wxString& filename, bool fallback) +{ + EnsureImpl(); + return m_impl->ReadMailcap(filename, fallback); +} + +bool wxMimeTypesManager::ReadMimeTypes(const wxString& filename) +{ + EnsureImpl(); + return m_impl->ReadMimeTypes(filename); +} + void wxMimeTypesManager::AddFallbacks(const wxFileTypeInfo *filetypes) { EnsureImpl(); @@ -748,7 +738,8 @@ public: if ( gs_mimeTypesManager.m_impl != NULL ) { - wxDELETE(gs_mimeTypesManager.m_impl); + delete gs_mimeTypesManager.m_impl; + gs_mimeTypesManager.m_impl = NULL; gs_mimeTypesManager.m_fallbacks.Clear(); } } diff --git a/Source/3rd Party/wx/src/common/modalhook.cpp b/Source/3rd Party/wx/src/common/modalhook.cpp deleted file mode 100644 index 20250381e..000000000 --- a/Source/3rd Party/wx/src/common/modalhook.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/modalhook.cpp -// Purpose: wxModalDialogHook implementation -// Author: Vadim Zeitlin -// Created: 2013-05-19 -// Copyright: (c) 2013 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/modalhook.h" - -#ifndef WX_PRECOMP -#endif // WX_PRECOMP - -wxModalDialogHook::Hooks wxModalDialogHook::ms_hooks; - -// ============================================================================ -// wxModalDialogHook implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Hooks management -// ---------------------------------------------------------------------------- - -void wxModalDialogHook::Register() -{ -#if wxDEBUG_LEVEL - for ( Hooks::const_iterator it = ms_hooks.begin(); - it != ms_hooks.end(); - ++it) - { - if ( *it == this ) - { - wxFAIL_MSG( wxS("Registering already registered hook?") ); - return; - } - } -#endif // wxDEBUG_LEVEL - - ms_hooks.insert(ms_hooks.begin(), this); -} - -void wxModalDialogHook::Unregister() -{ - if ( !DoUnregister() ) - { - wxFAIL_MSG( wxS("Unregistering not registered hook?") ); - } -} - -bool wxModalDialogHook::DoUnregister() -{ - for ( Hooks::iterator it = ms_hooks.begin(); - it != ms_hooks.end(); - ++it ) - { - if ( *it == this ) - { - ms_hooks.erase(it); - return true; - } - } - - return false; -} - -// ---------------------------------------------------------------------------- -// Invoking hooks methods -// ---------------------------------------------------------------------------- - -/* static */ -int wxModalDialogHook::CallEnter(wxDialog* dialog) -{ - // Make a copy of the hooks list to avoid problems if it's modified while - // we're iterating over it: this is unlikely to happen in our case, but - // quite possible in CallExit() as the hooks may remove themselves after - // the call to their Exit(), so do it here for symmetry as well. - const Hooks hooks = ms_hooks; - - for ( Hooks::const_iterator it = hooks.begin(); it != hooks.end(); ++it ) - { - const int rc = (*it)->Enter(dialog); - if ( rc != wxID_NONE ) - { - // Skip calling all the rest of the hooks if one of them preempts - // showing the dialog completely. - return rc; - } - } - - return wxID_NONE; -} - -/* static */ -void wxModalDialogHook::CallExit(wxDialog* dialog) -{ - // See comment in CallEnter() for the reasons for making a copy here. - const Hooks hooks = ms_hooks; - - for ( Hooks::const_iterator it = hooks.begin(); it != hooks.end(); ++it ) - { - (*it)->Exit(dialog); - } -} diff --git a/Source/3rd Party/wx/src/common/module.cpp b/Source/3rd Party/wx/src/common/module.cpp index b8438d460..d4d963b63 100644 --- a/Source/3rd Party/wx/src/common/module.cpp +++ b/Source/3rd Party/wx/src/common/module.cpp @@ -4,6 +4,7 @@ // Author: Wolfram Gloger/adapted by Guilhem Lavaux // Modified by: // Created: 04/11/98 +// RCS-ID: $Id: module.cpp 39677 2006-06-11 22:19:12Z VZ $ // Copyright: (c) Wolfram Gloger and Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -25,11 +26,11 @@ #include "wx/listimpl.cpp" -#define TRACE_MODULE wxT("module") +#define TRACE_MODULE _T("module") WX_DEFINE_LIST(wxModuleList) -wxIMPLEMENT_ABSTRACT_CLASS(wxModule, wxObject) +IMPLEMENT_CLASS(wxModule, wxObject) wxModuleList wxModule::m_modules; @@ -49,20 +50,23 @@ void wxModule::UnregisterModule(wxModule* module) // and register them. void wxModule::RegisterModules() { - for (wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo(), - end = wxClassInfo::end_classinfo(); - it != end; ++it) - { - const wxClassInfo* classInfo = *it; + wxHashTable::compatibility_iterator node; + wxClassInfo* classInfo; - if ( classInfo->IsKindOf(wxCLASSINFO(wxModule)) && - (classInfo != (& (wxModule::ms_classInfo))) ) + wxClassInfo::sm_classTable->BeginFind(); + node = wxClassInfo::sm_classTable->Next(); + while (node) + { + classInfo = (wxClassInfo *)node->GetData(); + if ( classInfo->IsKindOf(CLASSINFO(wxModule)) && + (classInfo != (& (wxModule::ms_classInfo))) ) { wxLogTrace(TRACE_MODULE, wxT("Registering module %s"), classInfo->GetClassName()); wxModule* module = (wxModule *)classInfo->CreateObject(); - wxModule::RegisterModule(module); + RegisterModule(module); } + node = wxClassInfo::sm_classTable->Next(); } } @@ -78,10 +82,6 @@ bool wxModule::DoInitializeModule(wxModule *module, module->m_state = State_Initializing; - // translate named dependencies to the normal ones first - if ( !module->ResolveNamedDependencies() ) - return false; - const wxArrayClassInfo& dependencies = module->m_dependencies; // satisfy module dependencies by loading them before the current module @@ -191,7 +191,7 @@ void wxModule::DoCleanUpModules(const wxModuleList& modules) wxModule * module = node->GetData(); wxASSERT_MSG( module->m_state == State_Initialized, - wxT("not initialized module being cleaned up") ); + _T("not initialized module being cleaned up") ); module->Exit(); module->m_state = State_Registered; @@ -200,25 +200,3 @@ void wxModule::DoCleanUpModules(const wxModuleList& modules) // clear all modules, even the non-initialized ones WX_CLEAR_LIST(wxModuleList, m_modules); } - -bool wxModule::ResolveNamedDependencies() -{ - // first resolve required dependencies - for ( size_t i = 0; i < m_namedDependencies.size(); ++i ) - { - wxClassInfo *info = wxClassInfo::FindClass(m_namedDependencies[i]); - - if ( !info ) - { - // required dependency not found - return false; - } - - // add it even if it is not derived from wxModule because - // DoInitializeModule() will make sure a module with the same class - // info exists and fail if it doesn't - m_dependencies.Add(info); - } - - return true; -} diff --git a/Source/3rd Party/wx/src/common/mousemanager.cpp b/Source/3rd Party/wx/src/common/mousemanager.cpp deleted file mode 100644 index b000c1b46..000000000 --- a/Source/3rd Party/wx/src/common/mousemanager.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/mousemanager.cpp -// Purpose: implementation of wxMouseEventsManager class -// Author: Vadim Zeitlin -// Created: 2009-04-21 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/settings.h" - #include "wx/window.h" -#endif // WX_PRECOMP - -#include "wx/mousemanager.h" - -// ---------------------------------------------------------------------------- -// event tables -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxMouseEventsManager, wxEvtHandler) - EVT_MOUSE_CAPTURE_LOST(wxMouseEventsManager::OnCaptureLost) - EVT_LEFT_DOWN(wxMouseEventsManager::OnLeftDown) - EVT_LEFT_UP(wxMouseEventsManager::OnLeftUp) - EVT_MOTION(wxMouseEventsManager::OnMove) -END_EVENT_TABLE() - -// ============================================================================ -// wxMouseEventsManager implementation -// ============================================================================ - -void wxMouseEventsManager::Init() -{ - m_win = NULL; - m_state = State_Normal; - m_item = wxNOT_FOUND; -} - -bool wxMouseEventsManager::Create(wxWindow *win) -{ - wxASSERT_MSG( !m_win, "Create() must not be called twice" ); - - m_win = win; - win->PushEventHandler(this); - - return true; -} - -wxMouseEventsManager::~wxMouseEventsManager() -{ - if ( m_win ) - m_win->RemoveEventHandler(this); -} - -void wxMouseEventsManager::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) -{ - switch ( m_state ) - { - case State_Normal: - wxFAIL_MSG( "mouse shouldn't be captured in normal state" ); - break; - - case State_Pressed: - MouseClickCancelled(m_item); - break; - - case State_Dragging: - MouseDragCancelled(m_item); - break; - } - - m_state = State_Normal; - m_item = wxNOT_FOUND; -} - -void wxMouseEventsManager::OnLeftDown(wxMouseEvent& event) -{ - wxASSERT_MSG( m_state == State_Normal, - "state hasn't been reset to normal somehow" ); - - m_posLast = event.GetPosition(); - m_item = MouseHitTest(m_posLast); - if ( m_item == wxNOT_FOUND ) - { - event.Skip(); - return; - } - - m_state = State_Pressed; - m_win->SetFocus(); - m_win->CaptureMouse(); - MouseClickBegin(m_item); -} - -void wxMouseEventsManager::OnLeftUp(wxMouseEvent& event) -{ - switch ( m_state ) - { - case State_Normal: - // ignore it, the mouse hasn't been pressed over any item initially - // so releasing it shouldn't do anything - event.Skip(); - - // skip releasing the capture below - return; - - case State_Pressed: - if ( MouseHitTest(event.GetPosition()) == m_item ) - { - // mouse released over the same item, so it was a click - MouseClicked(m_item); - } - break; - - case State_Dragging: - MouseDragEnd(m_item, event.GetPosition()); - break; - } - - m_state = State_Normal; - m_item = wxNOT_FOUND; - m_win->ReleaseMouse(); -} - -void wxMouseEventsManager::OnMove(wxMouseEvent& event) -{ - switch ( m_state ) - { - case State_Normal: - event.Skip(); - break; - - case State_Pressed: - wxASSERT_MSG( event.LeftIsDown(), - "should have detected mouse being released" ); - - { - // it's probably a bad idea to query the system for these - // values every time the mouse is moved so cache them on the - // assumption that they don't change -- which is wrong, of - // course, the user can change them but it doesn't happen often - static const int - dragMinX = wxSystemSettings::GetMetric(wxSYS_DRAG_X); - static const int - dragMinY = wxSystemSettings::GetMetric(wxSYS_DRAG_Y); - - const wxPoint& pos = event.GetPosition(); - const wxPoint ofs = pos - m_posLast; - if ( abs(ofs.x) > dragMinX || abs(ofs.y) > dragMinY ) - { - // the mouse left the rectangle inside which its movements - // are considered to be too small to constitute a start of - // drag operation, do [attempt to] start it now - if ( MouseDragBegin(m_item, pos) ) - { - m_state = State_Dragging; - } - } - else // still didn't move far enough away - { - event.Skip(); - } - } - break; - - case State_Dragging: - m_posLast = event.GetPosition(); - MouseDragging(m_item, m_posLast); - break; - } -} - diff --git a/Source/3rd Party/wx/src/common/msgout.cpp b/Source/3rd Party/wx/src/common/msgout.cpp index bf98eb489..ebeed13be 100644 --- a/Source/3rd Party/wx/src/common/msgout.cpp +++ b/Source/3rd Party/wx/src/common/msgout.cpp @@ -4,6 +4,7 @@ // Author: Mattia Barbon // Modified by: // Created: 17.07.02 +// RCS-ID: $Id: msgout.cpp 38920 2006-04-26 08:21:31Z ABX $ // Copyright: (c) the wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -42,6 +43,9 @@ #if defined(__WINDOWS__) #include "wx/msw/private.h" #endif +#ifdef __WXMAC__ + #include "wx/mac/private.h" +#endif // =========================================================================== // implementation @@ -72,106 +76,98 @@ wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout) return old; } -#if !wxUSE_UTF8_LOCALE_ONLY -void wxMessageOutput::DoPrintfWchar(const wxChar *format, ...) -{ - va_list args; - va_start(args, format); - wxString out; - - out.PrintfV(format, args); - va_end(args); - - Output(out); -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -void wxMessageOutput::DoPrintfUtf8(const char *format, ...) -{ - va_list args; - va_start(args, format); - wxString out; - - out.PrintfV(format, args); - va_end(args); - - Output(out); -} -#endif // wxUSE_UNICODE_UTF8 - // ---------------------------------------------------------------------------- // wxMessageOutputBest // ---------------------------------------------------------------------------- -void wxMessageOutputBest::Output(const wxString& str) -{ #ifdef __WINDOWS__ - // decide whether to use console output or not - wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - const bool hasStderr = traits ? traits->CanUseStderr() : false; - if ( !(m_flags & wxMSGOUT_PREFER_MSGBOX) ) +// check if we're running in a console under Windows +static inline bool IsInConsole() +{ +#ifdef __WXWINCE__ + return false; +#else // !__WXWINCE__ + HANDLE hStdErr = ::GetStdHandle(STD_ERROR_HANDLE); + return hStdErr && hStdErr != INVALID_HANDLE_VALUE; +#endif // __WXWINCE__/!__WXWINCE__ +} + +#endif // __WINDOWS__ + +void wxMessageOutputBest::Printf(const wxChar* format, ...) +{ + va_list args; + va_start(args, format); + wxString out; + + out.PrintfV(format, args); + va_end(args); + +#ifdef __WINDOWS__ + if ( !IsInConsole() ) { - if ( hasStderr && traits->WriteToStderr(AppendLineFeedIfNeeded(str)) ) - return; + ::MessageBox(NULL, out, _T("wxWidgets"), MB_ICONINFORMATION | MB_OK); } - - wxString title; - if ( wxTheApp ) - title = wxTheApp->GetAppDisplayName(); - else // Use some title to avoid default "Error" - title = _("Message"); - - ::MessageBox(NULL, str.t_str(), title.t_str(), MB_ICONINFORMATION | MB_OK); -#else // !__WINDOWS__ - wxUnusedVar(m_flags); - - // TODO: use the native message box for the other ports too - wxMessageOutputStderr::Output(str); + else #endif // __WINDOWS__/!__WINDOWS__ + { + fprintf(stderr, "%s", (const char*) out.mb_str()); + } } // ---------------------------------------------------------------------------- // wxMessageOutputStderr // ---------------------------------------------------------------------------- -wxString wxMessageOutputStderr::AppendLineFeedIfNeeded(const wxString& str) +void wxMessageOutputStderr::Printf(const wxChar* format, ...) { - wxString strLF(str); - if ( strLF.empty() || *strLF.rbegin() != '\n' ) - strLF += '\n'; + va_list args; + va_start(args, format); + wxString out; - return strLF; -} + out.PrintfV(format, args); + va_end(args); -void wxMessageOutputStderr::Output(const wxString& str) -{ - const wxString strWithLF = AppendLineFeedIfNeeded(str); - const wxWX2MBbuf buf = strWithLF.mb_str(); - - if ( buf ) - fprintf(m_fp, "%s", (const char*) buf); - else // print at least something - fprintf(m_fp, "%s", (const char*) strWithLF.ToAscii()); - - fflush(m_fp); + fprintf(stderr, "%s", (const char*) out.mb_str()); } // ---------------------------------------------------------------------------- // wxMessageOutputDebug // ---------------------------------------------------------------------------- -void wxMessageOutputDebug::Output(const wxString& str) +void wxMessageOutputDebug::Printf(const wxChar* format, ...) { -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) - wxString out(AppendLineFeedIfNeeded(str)); + wxString out; + + va_list args; + va_start(args, format); + + out.PrintfV(format, args); + va_end(args); + +#if defined(__WXMSW__) && !defined(__WXMICROWIN__) out.Replace(wxT("\t"), wxT(" ")); out.Replace(wxT("\n"), wxT("\r\n")); - ::OutputDebugString(out.t_str()); + ::OutputDebugString(out); +#elif defined(__WXMAC__) && !defined(__DARWIN__) + if ( wxIsDebuggerRunning() ) + { + Str255 pstr; + wxString output = out + wxT(";g") ; + wxMacStringToPascal(output.c_str(), pstr); + + #ifdef __powerc + DebugStr(pstr); + #else + SysBreakStr(pstr); + #endif + } #else - // TODO: use native debug output function for the other ports too - wxMessageOutputStderr::Output(str); + wxFputs( out , stderr ) ; + if ( out.Right(1) != wxT("\n") ) + wxFputs( wxT("\n") , stderr ) ; + fflush( stderr ) ; #endif // platform } @@ -179,13 +175,19 @@ void wxMessageOutputDebug::Output(const wxString& str) // wxMessageOutputLog // ---------------------------------------------------------------------------- -void wxMessageOutputLog::Output(const wxString& str) +void wxMessageOutputLog::Printf(const wxChar* format, ...) { - wxString out(str); + wxString out; + + va_list args; + va_start(args, format); + + out.PrintfV(format, args); + va_end(args); out.Replace(wxT("\t"), wxT(" ")); - wxLogMessage(wxT("%s"), out.c_str()); + ::wxLogMessage(wxT("%s"), out.c_str()); } #endif // wxUSE_BASE @@ -194,21 +196,25 @@ void wxMessageOutputLog::Output(const wxString& str) // wxMessageOutputMessageBox // ---------------------------------------------------------------------------- -#if wxUSE_GUI && wxUSE_MSGDLG +#if wxUSE_GUI -extern WXDLLEXPORT_DATA(const char) wxMessageBoxCaptionStr[] = "Message"; - -void wxMessageOutputMessageBox::Output(const wxString& str) +void wxMessageOutputMessageBox::Printf(const wxChar* format, ...) { - wxString out(str); + va_list args; + va_start(args, format); + wxString out; + + out.PrintfV(format, args); + va_end(args); // the native MSW msg box understands the TABs, others don't -#ifndef __WINDOWS__ +#ifndef __WXMSW__ out.Replace(wxT("\t"), wxT(" ")); #endif - wxString title = wxT("wxWidgets") ; - if (wxTheApp) title = wxTheApp->GetAppDisplayName(); + wxString title; + if ( wxTheApp ) + title.Printf(_("%s message"), wxTheApp->GetAppName().c_str()); ::wxMessageBox(out, title); } diff --git a/Source/3rd Party/wx/src/common/mstream.cpp b/Source/3rd Party/wx/src/common/mstream.cpp index 5e5c6495c..cbefd2a7c 100644 --- a/Source/3rd Party/wx/src/common/mstream.cpp +++ b/Source/3rd Party/wx/src/common/mstream.cpp @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: VZ (23.11.00): general code review // Created: 04/01/98 +// RCS-ID: $Id: mstream.cpp 39001 2006-05-03 21:50:35Z ABX $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -41,12 +42,10 @@ // wxMemoryInputStream // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxMemoryInputStream, wxInputStream) - wxMemoryInputStream::wxMemoryInputStream(const void *data, size_t len) { m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read); - m_i_streambuf->SetBufferIO(const_cast(data), len); + m_i_streambuf->SetBufferIO((void *)data, len); // const_cast m_i_streambuf->SetIntPosition(0); // seek to start pos m_i_streambuf->Fixed(true); @@ -64,7 +63,7 @@ wxMemoryInputStream::wxMemoryInputStream(const wxMemoryOutputStream& stream) } const size_t len = wx_truncate_cast(size_t, lenFile); - wxASSERT_MSG( len == lenFile + size_t(0), wxT("huge files not supported") ); + wxASSERT_MSG( len == lenFile + size_t(0), _T("huge files not supported") ); m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read); m_i_streambuf->SetBufferIO(len); // create buffer @@ -74,35 +73,6 @@ wxMemoryInputStream::wxMemoryInputStream(const wxMemoryOutputStream& stream) m_length = len; } -void -wxMemoryInputStream::InitFromStream(wxInputStream& stream, wxFileOffset lenFile) -{ - if ( lenFile == wxInvalidOffset ) - lenFile = stream.GetLength(); - - if ( lenFile == wxInvalidOffset ) - { - m_i_streambuf = NULL; - m_lasterror = wxSTREAM_EOF; - return; - } - - const size_t len = wx_truncate_cast(size_t, lenFile); - wxASSERT_MSG( (wxFileOffset)len == lenFile, wxT("huge files not supported") ); - - m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read); - m_i_streambuf->SetBufferIO(len); // create buffer - stream.Read(m_i_streambuf->GetBufferStart(), len); - m_i_streambuf->SetIntPosition(0); // seek to start pos - m_i_streambuf->Fixed(true); - m_length = stream.LastRead(); -} - -bool wxMemoryInputStream::CanRead() const -{ - return m_i_streambuf->GetIntPosition() != m_length; -} - wxMemoryInputStream::~wxMemoryInputStream() { delete m_i_streambuf; @@ -152,8 +122,6 @@ wxFileOffset wxMemoryInputStream::OnSysTell() const // wxMemoryOutputStream // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxOutputStream) - wxMemoryOutputStream::wxMemoryOutputStream(void *data, size_t len) { m_o_streambuf = new wxStreamBuffer(wxStreamBuffer::write); @@ -193,7 +161,7 @@ wxFileOffset wxMemoryOutputStream::OnSysTell() const size_t wxMemoryOutputStream::CopyTo(void *buffer, size_t len) const { - wxCHECK_MSG( buffer, 0, wxT("must have buffer to CopyTo") ); + wxCHECK_MSG( buffer, 0, _T("must have buffer to CopyTo") ); if ( len > GetSize() ) len = GetSize(); diff --git a/Source/3rd Party/wx/src/common/nbkbase.cpp b/Source/3rd Party/wx/src/common/nbkbase.cpp index 3ee7af5f6..011f53e16 100644 --- a/Source/3rd Party/wx/src/common/nbkbase.cpp +++ b/Source/3rd Party/wx/src/common/nbkbase.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 02.07.01 +// RCS-ID: $Id: nbkbase.cpp 41764 2006-10-08 23:41:52Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,127 +35,6 @@ // implementation // ============================================================================ -extern WXDLLEXPORT_DATA(const char) wxNotebookNameStr[] = "notebook"; - -wxDEFINE_EVENT( wxEVT_NOTEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_NOTEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -#include "wx/listimpl.cpp" -wxDEFINE_FLAGS( wxNotebookStyle ) -wxBEGIN_FLAGS( wxNotebookStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxNB_FIXEDWIDTH) -wxFLAGS_MEMBER(wxBK_DEFAULT) -wxFLAGS_MEMBER(wxBK_TOP) -wxFLAGS_MEMBER(wxBK_LEFT) -wxFLAGS_MEMBER(wxBK_RIGHT) -wxFLAGS_MEMBER(wxBK_BOTTOM) -wxFLAGS_MEMBER(wxNB_NOPAGETHEME) -wxFLAGS_MEMBER(wxNB_FLAT) -wxEND_FLAGS( wxNotebookStyle ) - -#if wxUSE_EXTENDED_RTTI - -WX_DEFINE_LIST( wxNotebookPageInfoList ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject, "wx/notebook.h" ) - -wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo *, wxNotebookPageInfoList ); - -template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, - wxAnyList &value) -{ - wxListCollectionToAnyList( theList, value ); -} - -wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo) -wxREADONLY_PROPERTY( Page, wxNotebookPage*, GetPage, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxREADONLY_PROPERTY( Text, wxString, GetText, wxString(), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) -wxREADONLY_PROPERTY( Selected, bool, GetSelected, false, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group") ) -wxREADONLY_PROPERTY( ImageId, int, GetImageId, -1, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxNotebookPageInfo) - -wxCONSTRUCTOR_4( wxNotebookPageInfo, wxNotebookPage*, Page, \ - wxString, Text, bool, Selected, int, ImageId ) - -// WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) -// XTI accessors: - -void wxNotebookBase::AddPageInfo( wxNotebookPageInfo* info ) -{ - AddPage( info->GetPage(), info->GetText(), info->GetSelected(), info->GetImageId() ); -} - -const wxNotebookPageInfoList& wxNotebookBase::GetPageInfos() const -{ - wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ); - WX_CLEAR_LIST( wxNotebookPageInfoList, *list ); - for( size_t i = 0; i < GetPageCount(); ++i ) - { - wxNotebookPageInfo *info = new wxNotebookPageInfo(); - info->Create( const_cast(this)->GetPage(i), GetPageText(i), - GetSelection() == int(i), GetPageImage(i) ); - list->Append( info ); - } - return m_pageInfos; -} - -#endif - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxBookCtrlBase, "wx/notebook.h") -wxBEGIN_PROPERTIES_TABLE(wxNotebook) -wxEVENT_PROPERTY( PageChanging, wxEVT_NOTEBOOK_PAGE_CHANGING, wxNotebookEvent ) -wxEVENT_PROPERTY( PageChanged, wxEVT_NOTEBOOK_PAGE_CHANGED, wxNotebookEvent ) - -wxPROPERTY_COLLECTION( PageInfos, wxNotebookPageInfoList, wxNotebookPageInfo*, \ - AddPageInfo, GetPageInfos, 0 /*flags*/, wxT("Helpstring"), \ - wxT("group")) -wxPROPERTY_FLAGS( WindowStyle, wxNotebookStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxNotebook) - -wxCONSTRUCTOR_5( wxNotebook, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle) - // ---------------------------------------------------------------------------- // geometry // ---------------------------------------------------------------------------- @@ -185,7 +65,7 @@ wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage) const bool wxNotebookBase::SendPageChangingEvent(int nPage) { - wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGING, GetId()); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, GetId()); event.SetSelection(nPage); event.SetOldSelection(GetSelection()); event.SetEventObject(this); @@ -194,7 +74,7 @@ bool wxNotebookBase::SendPageChangingEvent(int nPage) void wxNotebookBase::SendPageChangedEvent(int nPageOld, int nPageNew) { - wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGED, GetId()); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, GetId()); event.SetSelection(nPageNew == -1 ? GetSelection() : nPageNew); event.SetOldSelection(nPageOld); event.SetEventObject(this); diff --git a/Source/3rd Party/wx/src/common/numformatter.cpp b/Source/3rd Party/wx/src/common/numformatter.cpp deleted file mode 100644 index 12de60e84..000000000 --- a/Source/3rd Party/wx/src/common/numformatter.cpp +++ /dev/null @@ -1,305 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/numformatter.cpp -// Purpose: wxNumberFormatter -// Author: Fulvio Senore, Vadim Zeitlin -// Created: 2010-11-06 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/numformatter.h" -#include "wx/intl.h" - -#include // for setlocale and LC_ALL - -// ---------------------------------------------------------------------------- -// local helpers -// ---------------------------------------------------------------------------- - -namespace -{ - -// Contains information about the locale which was used to initialize our -// cached values of the decimal and thousands separators. Notice that it isn't -// enough to store just wxLocale because the user code may call setlocale() -// directly and storing just C locale string is not enough because we can use -// the OS API directly instead of the CRT ones on some platforms. So just store -// both. -class LocaleId -{ -public: - LocaleId() - { -#if wxUSE_INTL - m_wxloc = NULL; -#endif // wxUSE_INTL - m_cloc = NULL; - } - - ~LocaleId() - { - Free(); - } - -#if wxUSE_INTL - // Return true if this is the first time this function is called for this - // object or if the program locale has changed since the last time it was - // called. Otherwise just return false indicating that updating locale- - // dependent information is not necessary. - bool NotInitializedOrHasChanged() - { - wxLocale * const wxloc = wxGetLocale(); - const char * const cloc = setlocale(LC_ALL, NULL); - if ( m_wxloc || m_cloc ) - { - if ( m_wxloc == wxloc && strcmp(m_cloc, cloc) == 0 ) - return false; - - Free(); - } - //else: Not initialized yet. - - m_wxloc = wxloc; - m_cloc = wxCRT_StrdupA(cloc); - - return true; - } -#endif // wxUSE_INTL - -private: - void Free() - { -#if wxUSE_INTL - free(m_cloc); -#endif // wxUSE_INTL - } - -#if wxUSE_INTL - // Non-owned pointer to wxLocale which was used. - wxLocale *m_wxloc; -#endif // wxUSE_INTL - - // Owned pointer to the C locale string. - char *m_cloc; - - wxDECLARE_NO_COPY_CLASS(LocaleId); -}; - -} // anonymous namespace - -// ============================================================================ -// wxNumberFormatter implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Locale information accessors -// ---------------------------------------------------------------------------- - -wxChar wxNumberFormatter::GetDecimalSeparator() -{ -#if wxUSE_INTL - // Notice that while using static variable here is not MT-safe, the worst - // that can happen is that we redo the initialization if we're called - // concurrently from more than one thread so it's not a real problem. - static wxChar s_decimalSeparator = 0; - - // Remember the locale which was current when we initialized, we must redo - // the initialization if the locale changed. - static LocaleId s_localeUsedForInit; - - if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) - { - const wxString - s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); - if ( s.empty() ) - { - // We really must have something for decimal separator, so fall - // back to the C locale default. - s_decimalSeparator = '.'; - } - else - { - // To the best of my knowledge there are no locales like this. - wxASSERT_MSG( s.length() == 1, - "Multi-character decimal separator?" ); - - s_decimalSeparator = s[0]; - } - } - - return s_decimalSeparator; -#else // !wxUSE_INTL - return wxT('.'); -#endif // wxUSE_INTL/!wxUSE_INTL -} - -bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep) -{ -#if wxUSE_INTL - static wxChar s_thousandsSeparator = 0; - static LocaleId s_localeUsedForInit; - - if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) - { - const wxString - s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER); - if ( !s.empty() ) - { - wxASSERT_MSG( s.length() == 1, - "Multi-character thousands separator?" ); - - s_thousandsSeparator = s[0]; - } - //else: Unlike above it's perfectly fine for the thousands separator to - // be empty if grouping is not used, so just leave it as 0. - } - - if ( !s_thousandsSeparator ) - return false; - - if ( sep ) - *sep = s_thousandsSeparator; - - return true; -#else // !wxUSE_INTL - wxUnusedVar(sep); - return false; -#endif // wxUSE_INTL/!wxUSE_INTL -} - -// ---------------------------------------------------------------------------- -// Conversion to string and helpers -// ---------------------------------------------------------------------------- - -wxString wxNumberFormatter::PostProcessIntString(wxString s, int style) -{ - if ( style & Style_WithThousandsSep ) - AddThousandsSeparators(s); - - wxASSERT_MSG( !(style & Style_NoTrailingZeroes), - "Style_NoTrailingZeroes can't be used with integer values" ); - - return s; -} - -wxString wxNumberFormatter::ToString(long val, int style) -{ - return PostProcessIntString(wxString::Format("%ld", val), style); -} - -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - -wxString wxNumberFormatter::ToString(wxLongLong_t val, int style) -{ - return PostProcessIntString(wxString::Format("%" wxLongLongFmtSpec "d", val), - style); -} - -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - -wxString wxNumberFormatter::ToString(double val, int precision, int style) -{ - wxString s = wxString::FromDouble(val,precision); - - if ( style & Style_WithThousandsSep ) - AddThousandsSeparators(s); - - if ( style & Style_NoTrailingZeroes ) - RemoveTrailingZeroes(s); - - return s; -} - -void wxNumberFormatter::AddThousandsSeparators(wxString& s) -{ - wxChar thousandsSep; - if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) - return; - - size_t pos = s.find(GetDecimalSeparator()); - if ( pos == wxString::npos ) - { - // Start grouping at the end of an integer number. - pos = s.length(); - } - - // End grouping at the beginning of the digits -- there could be at a sign - // before their start. - const size_t start = s.find_first_of("0123456789"); - - // We currently group digits by 3 independently of the locale. This is not - // the right thing to do and we should use lconv::grouping (under POSIX) - // and GetLocaleInfo(LOCALE_SGROUPING) (under MSW) to get information about - // the correct grouping to use. This is something that needs to be done at - // wxLocale level first and then used here in the future (TODO). - const size_t GROUP_LEN = 3; - - while ( pos > start + GROUP_LEN ) - { - pos -= GROUP_LEN; - s.insert(pos, thousandsSep); - } -} - -void wxNumberFormatter::RemoveTrailingZeroes(wxString& s) -{ - const size_t posDecSep = s.find(GetDecimalSeparator()); - wxCHECK_RET( posDecSep != wxString::npos, - wxString::Format("No decimal separator in \"%s\"", s) ); - wxCHECK_RET( posDecSep, "Can't start with decimal separator" ); - - // Find the last character to keep. - size_t posLastNonZero = s.find_last_not_of("0"); - - // If it's the decimal separator itself, don't keep it neither. - if ( posLastNonZero == posDecSep ) - posLastNonZero--; - - s.erase(posLastNonZero + 1); -} - -// ---------------------------------------------------------------------------- -// Conversion from strings -// ---------------------------------------------------------------------------- - -void wxNumberFormatter::RemoveThousandsSeparators(wxString& s) -{ - wxChar thousandsSep; - if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) - return; - - s.Replace(wxString(thousandsSep), wxString()); -} - -bool wxNumberFormatter::FromString(wxString s, long *val) -{ - RemoveThousandsSeparators(s); - return s.ToLong(val); -} - -#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - -bool wxNumberFormatter::FromString(wxString s, wxLongLong_t *val) -{ - RemoveThousandsSeparators(s); - return s.ToLongLong(val); -} - -#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG - -bool wxNumberFormatter::FromString(wxString s, double *val) -{ - RemoveThousandsSeparators(s); - return s.ToDouble(val); -} diff --git a/Source/3rd Party/wx/src/common/object.cpp b/Source/3rd Party/wx/src/common/object.cpp index b11379747..24eddcde7 100644 --- a/Source/3rd Party/wx/src/common/object.cpp +++ b/Source/3rd Party/wx/src/common/object.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Ron Lee // Created: 04/01/98 +// RCS-ID: $Id: object.cpp 56500 2008-10-23 14:48:31Z MW $ // Copyright: (c) 1998 Julian Smart // (c) 2001 Ron Lee // Licence: wxWindows licence @@ -20,19 +21,18 @@ #include "wx/object.h" #include "wx/hash.h" #include "wx/memory.h" - #include "wx/crt.h" #endif #include -#if wxUSE_DEBUG_CONTEXT +#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT #if defined(__VISAGECPP__) #define DEBUG_PRINTF(NAME) { static int raz=0; \ printf( #NAME " %i\n",raz); fflush(stdout); raz++; } #else #define DEBUG_PRINTF(NAME) #endif -#endif // wxUSE_DEBUG_CONTEXT +#endif // __WXDEBUG__ || wxUSE_DEBUG_CONTEXT // we must disable optimizations for VC.NET because otherwise its too eager // linker discards wxClassInfo objects in release build thus breaking many, @@ -43,20 +43,21 @@ #if wxUSE_EXTENDED_RTTI const wxClassInfo* wxObject::ms_classParents[] = { NULL } ; -wxObject* wxVariantOfPtrToObjectConverterwxObject ( const wxAny &data ) -{ return wxANY_AS(data, wxObject*); } - wxAny wxObjectToVariantConverterwxObject ( wxObject *data ) - { return wxAny( dynamic_cast (data) ) ; } - + wxObject* wxVariantToObjectConverterwxObject ( wxxVariant &data ) +{ return data.wxTEMPLATED_MEMBER_CALL(Get , wxObject*) ; } + wxObject* wxVariantOfPtrToObjectConverterwxObject ( wxxVariant &data ) +{ return &data.wxTEMPLATED_MEMBER_CALL(Get , wxObject) ; } + wxxVariant wxObjectToVariantConverterwxObject ( wxObject *data ) + { return wxxVariant( dynamic_cast (data) ) ; } wxClassInfo wxObject::ms_classInfo(ms_classParents , wxEmptyString , wxT("wxObject"), (int) sizeof(wxObject), \ (wxObjectConstructorFn) 0 , - NULL,NULL,0 , 0 , - 0 , wxVariantOfPtrToObjectConverterwxObject , 0 , wxObjectToVariantConverterwxObject); - - template<> void wxStringWriteValue(wxString & , wxObject* const & ){ wxFAIL_MSG("unreachable"); } - template<> void wxStringWriteValue(wxString & , wxObject const & ){ wxFAIL_MSG("unreachable"); } - + (wxPropertyInfo*) NULL,(wxHandlerInfo*) NULL,0 , 0 , + 0 , wxVariantOfPtrToObjectConverterwxObject , wxVariantToObjectConverterwxObject , wxObjectToVariantConverterwxObject); + template<> void wxStringReadValue(const wxString & , wxObject * & ){assert(0) ;} + template<> void wxStringWriteValue(wxString & , wxObject* const & ){assert(0) ;} + template<> void wxStringReadValue(const wxString & , wxObject & ){assert(0) ;} + template<> void wxStringWriteValue(wxString & , wxObject const & ){assert(0) ;} wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject*).name() ) ; wxClassTypeInfo s_typeInfowxObject(wxT_OBJECT , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject).name() ) ; #else @@ -95,13 +96,13 @@ const bool wxFalse = false; // E.g. is wxWindow a kind of wxObject? // Go from this class to superclass, taking into account // two possible base classes. -bool wxObject::IsKindOf(const wxClassInfo *info) const +bool wxObject::IsKindOf(wxClassInfo *info) const { - const wxClassInfo *thisInfo = GetClassInfo(); + wxClassInfo *thisInfo = GetClassInfo(); return (thisInfo) ? thisInfo->IsKindOf(info) : false ; } -#if wxUSE_MEMORY_TRACING && defined( new ) +#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING && defined( new ) #undef new #endif @@ -186,7 +187,7 @@ wxClassInfo::~wxClassInfo() Unregister(); } -wxClassInfo *wxClassInfo::FindClass(const wxString& className) +wxClassInfo *wxClassInfo::FindClass(const wxChar *className) { if ( sm_classTable ) { @@ -196,7 +197,7 @@ wxClassInfo *wxClassInfo::FindClass(const wxString& className) { for ( wxClassInfo *info = sm_first; info ; info = info->m_next ) { - if ( className == info->GetClassName() ) + if ( wxStrcmp(info->GetClassName(), className) == 0 ) return info; } @@ -218,10 +219,10 @@ wxClassInfo *wxClassInfo::FindClass(const wxString& className) void wxClassInfo::Register() { -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ // reentrance guard - see note above static int entry = 0; -#endif // wxDEBUG_LEVEL +#endif wxHashTable *classTable; @@ -233,7 +234,7 @@ void wxClassInfo::Register() else { // guard againt reentrance once the global has been created - wxASSERT_MSG(++entry == 1, wxT("wxClassInfo::Register() reentrance")); + wxASSERT_MSG(++entry == 1, _T("wxClassInfo::Register() reentrance")); classTable = sm_classTable; } @@ -245,7 +246,7 @@ void wxClassInfo::Register() wxASSERT_MSG( classTable->Get(m_className) == NULL, wxString::Format ( - wxT("Class \"%s\" already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() multiple times or linked some object file twice)?"), + _T("Class \"%s\" already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() multiple times or linked some object file twice)?"), m_className ) ); @@ -269,9 +270,9 @@ void wxClassInfo::Register() } } -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ entry = 0; -#endif // wxDEBUG_LEVEL +#endif } void wxClassInfo::Unregister() @@ -281,14 +282,15 @@ void wxClassInfo::Unregister() sm_classTable->Delete(m_className); if ( sm_classTable->GetCount() == 0 ) { - wxDELETE(sm_classTable); + delete sm_classTable; + sm_classTable = NULL; } } } -wxObject *wxCreateDynamicObject(const wxString& name) +wxObject *wxCreateDynamicObject(const wxChar *name) { -#if wxUSE_DEBUG_CONTEXT +#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT DEBUG_PRINTF(wxObject *wxCreateDynamicObject) #endif @@ -311,50 +313,6 @@ wxObject *wxCreateDynamicObject(const wxString& name) } } -// iterator interface -wxClassInfo::const_iterator::value_type -wxClassInfo::const_iterator::operator*() const -{ - return (wxClassInfo*)m_node->GetData(); -} - -wxClassInfo::const_iterator& wxClassInfo::const_iterator::operator++() -{ - m_node = m_table->Next(); - return *this; -} - -const wxClassInfo::const_iterator wxClassInfo::const_iterator::operator++(int) -{ - wxClassInfo::const_iterator tmp = *this; - m_node = m_table->Next(); - return tmp; -} - -wxClassInfo::const_iterator wxClassInfo::begin_classinfo() -{ - sm_classTable->BeginFind(); - - return const_iterator(sm_classTable->Next(), sm_classTable); -} - -wxClassInfo::const_iterator wxClassInfo::end_classinfo() -{ - return const_iterator(NULL, NULL); -} - -// ---------------------------------------------------------------------------- -// wxObjectRefData -// ---------------------------------------------------------------------------- - -void wxRefCounter::DecRef() -{ - wxASSERT_MSG( m_count > 0, "invalid ref data count" ); - - if ( --m_count == 0 ) - delete this; -} - // ---------------------------------------------------------------------------- // wxObject @@ -362,7 +320,7 @@ void wxRefCounter::DecRef() void wxObject::Ref(const wxObject& clone) { -#if wxUSE_DEBUG_CONTEXT +#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT DEBUG_PRINTF(wxObject::Ref) #endif @@ -377,7 +335,7 @@ void wxObject::Ref(const wxObject& clone) if ( clone.m_refData ) { m_refData = clone.m_refData; - m_refData->IncRef(); + ++(m_refData->m_count); } } @@ -385,7 +343,10 @@ void wxObject::UnRef() { if ( m_refData ) { - m_refData->DecRef(); + wxASSERT_MSG( m_refData->m_count > 0, _T("invalid ref data count") ); + + if ( --m_refData->m_count == 0 ) + delete m_refData; m_refData = NULL; } } @@ -408,13 +369,13 @@ void wxObject::AllocExclusive() //else: ref count is 1, we are exclusive owners of m_refData anyhow wxASSERT_MSG( m_refData && m_refData->GetRefCount() == 1, - wxT("wxObject::AllocExclusive() failed.") ); + _T("wxObject::AllocExclusive() failed.") ); } wxObjectRefData *wxObject::CreateRefData() const { // if you use AllocExclusive() you must override this method - wxFAIL_MSG( wxT("CreateRefData() must be overridden if called!") ); + wxFAIL_MSG( _T("CreateRefData() must be overridden if called!") ); return NULL; } @@ -423,7 +384,7 @@ wxObjectRefData * wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const { // if you use AllocExclusive() you must override this method - wxFAIL_MSG( wxT("CloneRefData() must be overridden if called!") ); + wxFAIL_MSG( _T("CloneRefData() must be overridden if called!") ); return NULL; } diff --git a/Source/3rd Party/wx/src/common/odcombocmn.cpp b/Source/3rd Party/wx/src/common/odcombocmn.cpp deleted file mode 100644 index 096c9c51b..000000000 --- a/Source/3rd Party/wx/src/common/odcombocmn.cpp +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/odcombocmn.cpp -// Purpose: wxOwnerDrawnComboBox common code -// Author: Jaakko Salli -// Modified by: -// Created: Apr-30-2006 -// Copyright: (c) 2005 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ODCOMBOBOX - -#include "wx/odcombo.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/combobox.h" - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/dialog.h" -#endif - -#include "wx/combo.h" - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxIMPLEMENT_DYNAMIC_CLASS2_XTI(wxOwnerDrawnComboBox, wxComboCtrl, \ - wxControlWithItems, "wx/odcombo.h") - -wxBEGIN_PROPERTIES_TABLE(wxOwnerDrawnComboBox) -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxOwnerDrawnComboBox) - -wxCONSTRUCTOR_5( wxOwnerDrawnComboBox , wxWindow* , Parent , wxWindowID , \ - Id , wxString , Value , wxPoint , Position , wxSize , Size ) - -#endif // wxUSE_ODCOMBOBOX diff --git a/Source/3rd Party/wx/src/common/overlaycmn.cpp b/Source/3rd Party/wx/src/common/overlaycmn.cpp index 74b20c8d2..7867edb0e 100644 --- a/Source/3rd Party/wx/src/common/overlaycmn.cpp +++ b/Source/3rd Party/wx/src/common/overlaycmn.cpp @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 2006-10-20 +// RCS-ID: $Id: overlaycmn.cpp 42397 2006-10-25 12:12:56Z VS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -52,24 +53,24 @@ bool wxOverlay::IsOk() return m_impl->IsOk(); } -void wxOverlay::Init( wxDC* dc, int x , int y , int width , int height ) +void wxOverlay::Init( wxWindowDC* dc, int x , int y , int width , int height ) { m_impl->Init(dc, x, y, width, height); } -void wxOverlay::BeginDrawing( wxDC* dc) +void wxOverlay::BeginDrawing( wxWindowDC* dc) { m_impl->BeginDrawing(dc); m_inDrawing = true ; } -void wxOverlay::EndDrawing( wxDC* dc) +void wxOverlay::EndDrawing( wxWindowDC* dc) { m_impl->EndDrawing(dc); m_inDrawing = false ; } -void wxOverlay::Clear( wxDC* dc) +void wxOverlay::Clear( wxWindowDC* dc) { m_impl->Clear(dc); } @@ -85,13 +86,13 @@ void wxOverlay::Reset() // wxDCOverlay // ---------------------------------------------------------------------------- -wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height) : +wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height) : m_overlay(overlay) { Init(dc, x, y, width, height); } -wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc) : +wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc) : m_overlay(overlay) { int width; @@ -105,7 +106,7 @@ wxDCOverlay::~wxDCOverlay() m_overlay.EndDrawing(m_dc); } -void wxDCOverlay::Init(wxDC *dc, int x , int y , int width , int height ) +void wxDCOverlay::Init(wxWindowDC *dc, int x , int y , int width , int height ) { m_dc = dc ; if ( !m_overlay.IsOk() ) @@ -115,7 +116,7 @@ void wxDCOverlay::Init(wxDC *dc, int x , int y , int width , int height ) m_overlay.BeginDrawing(dc); } -void wxDCOverlay::Clear() +void wxDCOverlay::Clear() { m_overlay.Clear(m_dc); } @@ -128,7 +129,9 @@ void wxDCOverlay::Clear() wxOverlayImpl::wxOverlayImpl() { +#if defined(__WXGTK__) || defined(__WXMSW__) m_window = NULL ; +#endif m_x = m_y = m_width = m_height = 0 ; } @@ -136,14 +139,21 @@ wxOverlayImpl::~wxOverlayImpl() { } -bool wxOverlayImpl::IsOk() +bool wxOverlayImpl::IsOk() { - return m_bmpSaved.IsOk() ; + return m_bmpSaved.Ok() ; } -void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height ) +void wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height ) { +#if defined(__WXGTK__) + m_window = dc->m_owner; +#else + #if defined (__WXMSW__) m_window = dc->GetWindow(); + #endif // __WXMSW__ + +#endif wxMemoryDC dcMem ; m_bmpSaved.Create( width, height ); dcMem.SelectObject( m_bmpSaved ); @@ -151,12 +161,17 @@ void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height ) m_y = y ; m_width = width ; m_height = height ; +#if defined(__WXGTK__) && !defined(__WX_DC_BLIT_FIXED__) + wxPoint pt = dc->GetDeviceOrigin(); + x += pt.x; + y += pt.y; +#endif // broken wxGTK wxDC::Blit dcMem.Blit(0, 0, m_width, m_height, dc, x, y); dcMem.SelectObject( wxNullBitmap ); } -void wxOverlayImpl::Clear(wxDC* dc) +void wxOverlayImpl::Clear(wxWindowDC* dc) { wxMemoryDC dcMem ; dcMem.SelectObject( m_bmpSaved ); @@ -169,11 +184,11 @@ void wxOverlayImpl::Reset() m_bmpSaved = wxBitmap(); } -void wxOverlayImpl::BeginDrawing(wxDC* WXUNUSED(dc)) +void wxOverlayImpl::BeginDrawing(wxWindowDC* WXUNUSED(dc)) { } -void wxOverlayImpl::EndDrawing(wxDC* WXUNUSED(dc)) +void wxOverlayImpl::EndDrawing(wxWindowDC* WXUNUSED(dc)) { } diff --git a/Source/3rd Party/wx/src/common/ownerdrwcmn.cpp b/Source/3rd Party/wx/src/common/ownerdrwcmn.cpp deleted file mode 100644 index 967a5a285..000000000 --- a/Source/3rd Party/wx/src/common/ownerdrwcmn.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/ownerdrwcmn.cpp -// Purpose: wxOwnerDrawn class methods common to all platforms -// Author: Marcin Malich -// Modified by: -// Created: 2009-09-22 -// Copyright: (c) 2009 Marcin Malich -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_OWNER_DRAWN - -#include "wx/ownerdrw.h" - -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/font.h" - #include "wx/colour.h" - #include "wx/dcmemory.h" - #include "wx/settings.h" - #include "wx/utils.h" -#endif - -// ============================================================================ -// implementation -// ============================================================================ - -bool wxOwnerDrawnBase::OnMeasureItem(size_t *width, size_t *height) -{ - if ( IsOwnerDrawn() ) - { - wxMemoryDC dc; - wxFont font; - GetFontToUse(font); - dc.SetFont(font); - - // item name/text without mnemonics - wxString name = wxStripMenuCodes(GetName(), wxStrip_Mnemonics); - - wxCoord w, h; - dc.GetTextExtent(name, &w, &h); - - *width = w + m_margin; - *height = h; - } - else - { - *width = 0; - *height = 0; - } - - return true; -} - -void wxOwnerDrawnBase::GetFontToUse(wxFont& font) const -{ - font = m_font.IsOk() ? m_font : *wxNORMAL_FONT; -} - -void wxOwnerDrawnBase::GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const -{ - if ( stat & wxODSelected ) - { - colText = wxSystemSettings::GetColour( - !(stat & wxODDisabled) ? wxSYS_COLOUR_HIGHLIGHTTEXT - : wxSYS_COLOUR_GRAYTEXT); - - colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - } - else - { - // fall back to default colors if none explicitly specified - - if ( stat & wxODDisabled ) - { - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - } - else - { - colText = m_colText.IsOk() ? m_colText - : wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT); - } - - colBack = m_colBack.IsOk() ? m_colBack - : wxSystemSettings::GetColour(wxSYS_COLOUR_MENU); - } -} - -#endif // wxUSE_OWNER_DRAWN diff --git a/Source/3rd Party/wx/src/common/paper.cpp b/Source/3rd Party/wx/src/common/paper.cpp index 5eb966937..714eee286 100644 --- a/Source/3rd Party/wx/src/common/paper.cpp +++ b/Source/3rd Party/wx/src/common/paper.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: paper.cpp 60706 2009-05-21 10:17:44Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -78,7 +79,7 @@ WX_DECLARE_LIST(wxPrintPaperType, wxPrintPaperTypeList); #include "wx/listimpl.cpp" WX_DEFINE_LIST(wxPrintPaperTypeList) -wxPrintPaperDatabase* wxThePrintPaperDatabase = NULL; +wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL; wxPrintPaperDatabase::wxPrintPaperDatabase() { @@ -135,7 +136,7 @@ void wxPrintPaperDatabase::CreateDatabase() WXADDPAPER(wxPAPER_FANFOLD_STD_GERMAN, DMPAPER_FANFOLD_STD_GERMAN, wxTRANSLATE("German Std Fanfold, 8 1/2 x 12 in"), 2159, 3048); WXADDPAPER(wxPAPER_FANFOLD_LGL_GERMAN, DMPAPER_FANFOLD_LGL_GERMAN, wxTRANSLATE("German Legal Fanfold, 8 1/2 x 13 in"), 2159, 3302); - WXADDPAPER(wxPAPER_ISO_B4, DMPAPER_ISO_B4, wxTRANSLATE("B4 (ISO) 250 x 353 mm"), 2500, 3530); + WXADDPAPER(wxPAPER_ISO_B4, DMPAPER_ISO_B4, wxTRANSLATE("B4 (ISO) 250 x 353 mm"), 2500, 2530); WXADDPAPER(wxPAPER_JAPANESE_POSTCARD, DMPAPER_JAPANESE_POSTCARD, wxTRANSLATE("Japanese Postcard 100 x 148 mm"), 1000, 1480); WXADDPAPER(wxPAPER_9X11, DMPAPER_9X11, wxTRANSLATE("9 x 11 in"), 2286, 2794); WXADDPAPER(wxPAPER_10X11, DMPAPER_10X11, wxTRANSLATE("10 x 11 in"), 2540, 2794); @@ -211,12 +212,6 @@ void wxPrintPaperDatabase::CreateDatabase() WXADDPAPER(wxPAPER_PENV_8_ROTATED, 116, wxTRANSLATE("PRC Envelope #8 Rotated 309 x 120 mm"), 3090, 1200); WXADDPAPER(wxPAPER_PENV_9_ROTATED, 117, wxTRANSLATE("PRC Envelope #9 Rotated 324 x 229 mm"), 3240, 2290); WXADDPAPER(wxPAPER_PENV_10_ROTATED, 118, wxTRANSLATE("PRC Envelope #10 Rotated 458 x 324 mm"), 4580, 3240); - - // notice that the values 135 and 136 for Windows paper size ids of A0 and - // A1 formats are not documented anywhere but seem to work for at least - // some printers so we use them until we find a better way (see #11083) - WXADDPAPER(wxPAPER_A0, 136, wxTRANSLATE("A0 sheet, 841 x 1189 mm"), 8410, 11888); - WXADDPAPER(wxPAPER_A1, 135, wxTRANSLATE("A1 sheet, 594 x 841 mm"), 5940, 8410); } void wxPrintPaperDatabase::ClearDatabase() @@ -283,11 +278,12 @@ wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz) // are likely to be taken into account first. This fixes problems with, // for example, Letter reverting to A4 in the page setup dialog because // it was wrongly translated to Note. - for ( size_t i = 0; i < GetCount(); i++ ) + size_t i; + for (i = 0; i < GetCount(); i++) { - wxPrintPaperType* const paperType = Item(i); - const wxSize paperSize = paperType->GetSize() ; - if ( abs(paperSize.x - sz.x) < 10 && abs(paperSize.y - sz.y) < 10 ) + wxPrintPaperType* paperType = Item(i); + wxSize paperSize = paperType->GetSize() ; + if ( abs( paperSize.x - sz.x ) < 10 && abs( paperSize.y - sz.y ) < 10 ) return paperType; } @@ -373,7 +369,8 @@ bool wxPrintPaperModule::OnInit() void wxPrintPaperModule::OnExit() { - wxDELETE(wxThePrintPaperDatabase); + delete wxThePrintPaperDatabase; + wxThePrintPaperDatabase = NULL; } #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/Source/3rd Party/wx/src/common/persist.cpp b/Source/3rd Party/wx/src/common/persist.cpp deleted file mode 100644 index f1e951957..000000000 --- a/Source/3rd Party/wx/src/common/persist.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/persist.cpp -// Purpose: common persistence support classes -// Author: Vadim Zeitlin -// Created: 2009-01-20 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CONFIG - -#ifndef WX_PRECOMP -#endif // WX_PRECOMP - -#include "wx/persist.h" - -namespace -{ - -wxPersistenceManager* gs_manager = NULL; - -} // anonymous namespace - -// ============================================================================ -// wxPersistenceManager implementation -// ============================================================================ - -/* static */ -void wxPersistenceManager::Set(wxPersistenceManager& manager) -{ - gs_manager = &manager; -} - -/* static */ -wxPersistenceManager& wxPersistenceManager::Get() -{ - if ( !gs_manager ) - { - static wxPersistenceManager s_manager; - - gs_manager = &s_manager; - } - - return *gs_manager; -} - -wxPersistenceManager::~wxPersistenceManager() -{ -} - -wxString -wxPersistenceManager::GetKey(const wxPersistentObject& who, - const wxString& name) const -{ - wxString key("Persistent_Options"); // TODO: make this configurable - key << wxCONFIG_PATH_SEPARATOR << who.GetKind() - << wxCONFIG_PATH_SEPARATOR << who.GetName() - << wxCONFIG_PATH_SEPARATOR << name; - - return key; -} - -wxPersistentObject *wxPersistenceManager::Find(void *obj) const -{ - const wxPersistentObjectsMap::const_iterator - it = m_persistentObjects.find(obj); - return it == m_persistentObjects.end() ? NULL : it->second; -} - -wxPersistentObject * -wxPersistenceManager::Register(void *obj, wxPersistentObject *po) -{ - if ( wxPersistentObject *old = Find(obj) ) - { - wxFAIL_MSG( "object is already registered" ); - - delete po; // still avoid the memory leaks - return old; - } - - m_persistentObjects[obj] = po; - - return po; -} - -void wxPersistenceManager::Unregister(void *obj) -{ - wxPersistentObjectsMap::iterator it = m_persistentObjects.find(obj); - wxCHECK_RET( it != m_persistentObjects.end(), "not registered" ); - - wxPersistentObject * const po = it->second; - m_persistentObjects.erase(it); - delete po; -} - -void wxPersistenceManager::Save(void *obj) -{ - if ( !m_doSave ) - return; - - wxPersistentObjectsMap::iterator it = m_persistentObjects.find(obj); - wxCHECK_RET( it != m_persistentObjects.end(), "not registered" ); - - it->second->Save(); -} - -bool wxPersistenceManager::Restore(void *obj) -{ - if ( !m_doRestore ) - return false; - - wxPersistentObjectsMap::iterator it = m_persistentObjects.find(obj); - wxCHECK_MSG( it != m_persistentObjects.end(), false, "not registered" ); - - return it->second->Restore(); -} - -namespace -{ - -template -inline bool -DoSaveValue(wxConfigBase *conf, const wxString& key, T value) -{ - return conf && conf->Write(key, value); -} - -template -bool -DoRestoreValue(wxConfigBase *conf, const wxString& key, T *value) -{ - return conf && conf->Read(key, value); -} - -} // anonymous namespace - -#define wxPERSIST_DEFINE_SAVE_RESTORE_FOR(Type) \ - bool wxPersistenceManager::SaveValue(const wxPersistentObject& who, \ - const wxString& name, \ - Type value) \ - { \ - return DoSaveValue(GetConfig(), GetKey(who, name), value); \ - } \ - \ - bool wxPersistenceManager::RestoreValue(const wxPersistentObject& who, \ - const wxString& name, \ - Type *value) \ - { \ - return DoRestoreValue(GetConfig(), GetKey(who, name), value); \ - } - -wxPERSIST_DEFINE_SAVE_RESTORE_FOR(bool) -wxPERSIST_DEFINE_SAVE_RESTORE_FOR(int) -wxPERSIST_DEFINE_SAVE_RESTORE_FOR(long) -wxPERSIST_DEFINE_SAVE_RESTORE_FOR(wxString) - -#undef wxPERSIST_DEFINE_SAVE_RESTORE_FOR - -#endif // wxUSE_CONFIG diff --git a/Source/3rd Party/wx/src/common/pickerbase.cpp b/Source/3rd Party/wx/src/common/pickerbase.cpp index b68d7b1c9..87c99066c 100644 --- a/Source/3rd Party/wx/src/common/pickerbase.cpp +++ b/Source/3rd Party/wx/src/common/pickerbase.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 15/04/2006 +// RCS-ID: $Id: pickerbase.cpp 58463 2009-01-27 17:39:50Z BP $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -42,6 +43,13 @@ IMPLEMENT_ABSTRACT_CLASS(wxPickerBase, wxControl) +BEGIN_EVENT_TABLE(wxPickerBase, wxControl) + EVT_SIZE(wxPickerBase::OnSize) + WX_EVENT_TABLE_CONTROL_CONTAINER(wxPickerBase) +END_EVENT_TABLE() +WX_DELEGATE_TO_CONTROL_CONTAINER(wxPickerBase, wxControl) + + // ---------------------------------------------------------------------------- // wxPickerBase // ---------------------------------------------------------------------------- @@ -58,13 +66,10 @@ bool wxPickerBase::CreateBase(wxWindow *parent, // remove any border style from our style as wxPickerBase's window must be // invisible (user styles must be set on the textctrl or the platform-dependent picker) style &= ~wxBORDER_MASK; - if (!wxControl::Create(parent, id, pos, size, style | wxNO_BORDER | wxTAB_TRAVERSAL, validator, name)) return false; - SetMinSize( size ); - m_sizer = new wxBoxSizer(wxHORIZONTAL); if (HasFlag(wxPB_USE_TEXTCTRL)) @@ -81,7 +86,7 @@ bool wxPickerBase::CreateBase(wxWindow *parent, return false; } - // set the maximum length allowed for this textctrl. + // set the maximum lenght allowed for this textctrl. // This is very important since any change to it will trigger an update in // the m_picker; for very long strings, this real-time synchronization could // become a CPU-blocker and thus should be avoided. @@ -91,7 +96,7 @@ bool wxPickerBase::CreateBase(wxWindow *parent, // set the initial contents of the textctrl m_text->SetValue(text); - m_text->Connect(m_text->GetId(), wxEVT_TEXT, + m_text->Connect(m_text->GetId(), wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(wxPickerBase::OnTextCtrlUpdate), NULL, this); m_text->Connect(m_text->GetId(), wxEVT_KILL_FOCUS, @@ -115,24 +120,8 @@ void wxPickerBase::PostCreation() // associated with it - in that case it defaults to 0 m_sizer->Add(m_picker, HasTextCtrl() ? 0 : 1, GetDefaultPickerCtrlFlag(), 5); - // For aesthetic reasons, make sure the picker is at least as high as the - // associated text control and is always at least square, unless we are - // explicitly using wxPB_SMALL style to force it to take as little space as - // possible. - if ( !HasFlag(wxPB_SMALL) ) - { - const wxSize pickerBestSize(m_picker->GetBestSize()); - const wxSize textBestSize( HasTextCtrl() ? m_text->GetBestSize() : wxSize()); - wxSize pickerMinSize; - pickerMinSize.y = wxMax(pickerBestSize.y, textBestSize.y); - pickerMinSize.x = wxMax(pickerBestSize.x, pickerMinSize.y); - if ( pickerMinSize != pickerBestSize ) - m_picker->SetMinSize(pickerMinSize); - } - SetSizer(m_sizer); - - SetInitialSize( GetMinSize() ); + SetMinSize( m_sizer->GetMinSize() ); } #if wxUSE_TOOLTIPS @@ -176,4 +165,11 @@ void wxPickerBase::OnTextCtrlUpdate(wxCommandEvent &) UpdatePickerFromTextCtrl(); } +void wxPickerBase::OnSize(wxSizeEvent &event) +{ + if (GetAutoLayout()) + Layout(); + event.Skip(); +} + #endif // Any picker in use diff --git a/Source/3rd Party/wx/src/common/platinfo.cpp b/Source/3rd Party/wx/src/common/platinfo.cpp index ee943915c..bf33db2e6 100644 --- a/Source/3rd Party/wx/src/common/platinfo.cpp +++ b/Source/3rd Party/wx/src/common/platinfo.cpp @@ -4,8 +4,9 @@ // Author: Francesco Montorsi // Modified by: // Created: 07.07.2006 (based on wxToolkitInfo) +// RCS-ID: $Id: platinfo.cpp 44078 2006-12-30 21:46:22Z SN $ // Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -44,66 +45,68 @@ static wxPlatformInfo gs_platInfo(wxPORT_UNKNOWN); static const wxChar* const wxOperatingSystemIdNames[] = { - wxT("Apple Mac OS"), - wxT("Apple Mac OS X"), + _T("Apple Mac OS"), + _T("Apple Mac OS X"), - wxT("Microsoft Windows 9X"), - wxT("Microsoft Windows NT"), - wxT("Microsoft Windows Micro"), - wxT("Microsoft Windows CE"), + _T("Microsoft Windows 9X"), + _T("Microsoft Windows NT"), + _T("Microsoft Windows Micro"), + _T("Microsoft Windows CE"), - wxT("Linux"), - wxT("FreeBSD"), - wxT("OpenBSD"), - wxT("NetBSD"), + _T("Linux"), + _T("FreeBSD"), + _T("OpenBSD"), + _T("NetBSD"), - wxT("SunOS"), - wxT("AIX"), - wxT("HPUX"), + _T("SunOS"), + _T("AIX"), + _T("HPUX"), - wxT("Other Unix"), - wxT("Other Unix"), + _T("Other Unix"), + _T("Other Unix"), - wxT("DOS"), - wxT("OS/2"), + _T("DOS"), + _T("OS/2") }; static const wxChar* const wxPortIdNames[] = { - wxT("wxBase"), - wxT("wxMSW"), - wxT("wxMotif"), - wxT("wxGTK"), - wxT("wxDFB"), - wxT("wxX11"), - wxT("wxOS2"), - wxT("wxMac"), - wxT("wxCocoa"), - wxT("wxWinCE"), + _T("wxBase"), + _T("wxMSW"), + _T("wxMotif"), + _T("wxGTK"), + _T("wxMGL"), + _T("wxX11"), + _T("wxOS2"), + _T("wxMac"), + _T("wxCocoa"), + _T("wxWinCE"), + _T("wxPalmOS"), + _T("wxDFB") }; static const wxChar* const wxArchitectureNames[] = { - wxT("32 bit"), - wxT("64 bit") + _T("32 bit"), + _T("64 bit") }; static const wxChar* const wxEndiannessNames[] = { - wxT("Big endian"), - wxT("Little endian"), - wxT("PDP endian") + _T("Big endian"), + _T("Little endian"), + _T("PDP endian") }; // ---------------------------------------------------------------------------- // local functions // ---------------------------------------------------------------------------- -// returns the logarithm in base 2 of 'value'; this maps the enum values to the -// corresponding indexes of the string arrays above +// returns log in base 2 of the value, this maps the enum values to the +// corresponding indices static unsigned wxGetIndexFromEnumValue(int value) { - wxCHECK_MSG( value, (unsigned)-1, wxT("invalid enum value") ); + wxCHECK_MSG( value, (unsigned)-1, _T("invalid enum value") ); int n = 0; while ( !(value & 1) ) @@ -112,7 +115,7 @@ static unsigned wxGetIndexFromEnumValue(int value) n++; } - wxASSERT_MSG( value == 1, wxT("more than one bit set in enum value") ); + wxASSERT_MSG( value == 1, _T("more than one bit set in enum value") ); return n; } @@ -153,9 +156,6 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const m_osVersionMajor == t.m_osVersionMajor && m_osVersionMinor == t.m_osVersionMinor && m_os == t.m_os && - m_osDesc == t.m_osDesc && - m_ldi == t.m_ldi && - m_desktopEnv == t.m_desktopEnv && m_port == t.m_port && m_usingUniversal == t.m_usingUniversal && m_arch == t.m_arch && @@ -168,7 +168,7 @@ void wxPlatformInfo::InitForCurrentPlatform() const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; if ( !traits ) { - wxFAIL_MSG( wxT("failed to initialize wxPlatformInfo") ); + wxFAIL_MSG( _T("failed to initialize wxPlatformInfo") ); m_port = wxPORT_UNKNOWN; m_usingUniversal = false; @@ -179,18 +179,11 @@ void wxPlatformInfo::InitForCurrentPlatform() { m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor); m_usingUniversal = traits->IsUsingUniversalWidgets(); - m_desktopEnv = traits->GetDesktopEnvironment(); } m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor); - m_osDesc = wxGetOsDescription(); m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG; m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32; - -#ifdef __LINUX__ - m_ldi = wxGetLinuxDistributionInfo(); -#endif - // else: leave m_ldi empty } /* static */ @@ -206,12 +199,6 @@ const wxPlatformInfo& wxPlatformInfo::Get() return gs_platInfo; } -/* static */ -wxString wxPlatformInfo::GetOperatingSystemDirectory() -{ - return wxGetOSDirectory(); -} - // ---------------------------------------------------------------------------- @@ -220,17 +207,17 @@ wxString wxPlatformInfo::GetOperatingSystemDirectory() wxString wxPlatformInfo::GetOperatingSystemFamilyName(wxOperatingSystemId os) { - const wxChar* string = wxT("Unknown"); + const wxChar* string = _T("Unknown"); if ( os & wxOS_MAC ) - string = wxT("Macintosh"); + string = _T("Macintosh"); else if ( os & wxOS_WINDOWS ) - string = wxT("Windows"); + string = _T("Windows"); else if ( os & wxOS_UNIX ) - string = wxT("Unix"); + string = _T("Unix"); else if ( os == wxOS_DOS ) - string = wxT("DOS"); + string = _T("DOS"); else if ( os == wxOS_OS2 ) - string = wxT("OS/2"); + string = _T("OS/2"); return string; } @@ -240,7 +227,7 @@ wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os) const unsigned idx = wxGetIndexFromEnumValue(os); wxCHECK_MSG( idx < WXSIZEOF(wxOperatingSystemIdNames), wxEmptyString, - wxT("invalid OS id") ); + _T("invalid OS id") ); return wxOperatingSystemIdNames[idx]; } @@ -250,7 +237,7 @@ wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal) const unsigned idx = wxGetIndexFromEnumValue(port); wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, - wxT("invalid port id") ); + _T("invalid port id") ); wxString ret = wxPortIdNames[idx]; @@ -265,7 +252,7 @@ wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal) const unsigned idx = wxGetIndexFromEnumValue(port); wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, - wxT("invalid port id") ); + _T("invalid port id") ); wxString ret = wxPortIdNames[idx]; ret = ret.Mid(2).Lower(); // remove 'wx' prefix @@ -337,11 +324,11 @@ wxArchitecture wxPlatformInfo::GetArch(const wxString &arch) wxEndianness wxPlatformInfo::GetEndianness(const wxString& end) { - const wxString endl(end.Lower()); - if ( endl.StartsWith(wxT("little")) ) + wxString endl(end.Lower()); + if ( end.StartsWith(wxT("little")) ) return wxENDIAN_LITTLE; - if ( endl.StartsWith(wxT("big")) ) + if ( end.StartsWith(wxT("big")) ) return wxENDIAN_BIG; return wxENDIAN_INVALID; diff --git a/Source/3rd Party/wx/src/common/popupcmn.cpp b/Source/3rd Party/wx/src/common/popupcmn.cpp index e50dc3e62..7582c313e 100644 --- a/Source/3rd Party/wx/src/common/popupcmn.cpp +++ b/Source/3rd Party/wx/src/common/popupcmn.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 06.01.01 +// RCS-ID: $Id: popupcmn.cpp 61466 2009-07-19 16:45:08Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -43,11 +44,6 @@ #ifdef __WXGTK__ #include - #if GTK_CHECK_VERSION(2,0,0) - #include "wx/gtk/private/gtk2-compat.h" - #else - #define gtk_widget_get_window(x) x->window - #endif #elif defined(__WXMSW__) #include "wx/msw/private.h" #elif defined(__WXX11__) @@ -75,13 +71,12 @@ public: protected: // event handlers void OnLeftDown(wxMouseEvent& event); - void OnCaptureLost(wxMouseCaptureLostEvent& event); private: wxPopupTransientWindow *m_popup; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxPopupWindowHandler); + DECLARE_NO_COPY_CLASS(wxPopupWindowHandler) }; class wxPopupFocusHandler : public wxEvtHandler @@ -91,13 +86,13 @@ public: protected: void OnKillFocus(wxFocusEvent& event); - void OnChar(wxKeyEvent& event); + void OnKeyDown(wxKeyEvent& event); private: wxPopupTransientWindow *m_popup; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxPopupFocusHandler); + DECLARE_NO_COPY_CLASS(wxPopupFocusHandler) }; // ---------------------------------------------------------------------------- @@ -106,16 +101,15 @@ private: BEGIN_EVENT_TABLE(wxPopupWindowHandler, wxEvtHandler) EVT_LEFT_DOWN(wxPopupWindowHandler::OnLeftDown) - EVT_MOUSE_CAPTURE_LOST(wxPopupWindowHandler::OnCaptureLost) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler) EVT_KILL_FOCUS(wxPopupFocusHandler::OnKillFocus) - EVT_CHAR(wxPopupFocusHandler::OnChar) + EVT_KEY_DOWN(wxPopupFocusHandler::OnKeyDown) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxPopupTransientWindow, wxPopupWindow) -#if defined(__WXMSW__) || (defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON) +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) EVT_IDLE(wxPopupTransientWindow::OnIdle) #endif END_EVENT_TABLE() @@ -210,7 +204,7 @@ void wxPopupWindowBase::Position(const wxPoint& ptOrigin, void wxPopupTransientWindow::Init() { m_child = - m_focus = NULL; + m_focus = (wxWindow *)NULL; m_handlerFocus = NULL; m_handlerPopup = NULL; @@ -265,16 +259,8 @@ void wxPopupTransientWindow::PopHandlers() void wxPopupTransientWindow::Popup(wxWindow *winFocus) { - // If we have a single child, we suppose that it must cover the entire - // popup window and hence we give the mouse capture to it instead of - // keeping it for ourselves. - // - // Notice that this works best for combobox-like popups which have a single - // control inside them and not so well for popups containing a single - // wxPanel with multiple children inside it but OTOH it does no harm in - // this case neither and we can't reliably distinguish between them. const wxWindowList& children = GetChildren(); - if ( children.GetCount() == 1 ) + if ( children.GetCount() ) { m_child = children.GetFirst()->GetData(); } @@ -285,7 +271,7 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus) Show(); - // There is a problem if these are still in use + // There is is a problem if these are still in use wxASSERT(!m_handlerFocus || !m_handlerFocus->GetNextHandler()); wxASSERT(!m_handlerPopup || !m_handlerPopup->GetNextHandler()); @@ -305,7 +291,7 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus) m_focus->SetFocus(); } -#if defined( __WXMSW__ ) || (defined( __WXMAC__) && wxOSX_USE_COCOA_OR_CARBON) +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) // MSW doesn't allow to set focus to the popup window, but we need to // subclass the window which has the focus, and not winFocus passed in or // otherwise everything else breaks down @@ -330,14 +316,7 @@ bool wxPopupTransientWindow::Show( bool show ) #ifdef __WXGTK__ if (!show) { -#ifdef __WXGTK3__ - GdkDisplay* display = gtk_widget_get_display(m_widget); - GdkDeviceManager* manager = gdk_display_get_device_manager(display); - GdkDevice* device = gdk_device_manager_get_client_pointer(manager); - gdk_device_ungrab(device, unsigned(GDK_CURRENT_TIME)); -#else gdk_pointer_ungrab( (guint32)GDK_CURRENT_TIME ); -#endif gtk_grab_remove( m_widget ); } @@ -350,7 +329,7 @@ bool wxPopupTransientWindow::Show( bool show ) } #endif -#if defined( __WXMSW__ ) || defined( __WXMAC__) +#if defined( __WXMSW__ ) || defined( __WMAC__ ) if (!show && m_child && m_child->HasCapture()) { m_child->ReleaseMouse(); @@ -364,25 +343,15 @@ bool wxPopupTransientWindow::Show( bool show ) { gtk_grab_add( m_widget ); - const GdkEventMask mask = GdkEventMask( - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_POINTER_MOTION_MASK); - GdkWindow* window = gtk_widget_get_window(m_widget); -#ifdef __WXGTK3__ - GdkDisplay* display = gdk_window_get_display(window); - GdkDeviceManager* manager = gdk_display_get_device_manager(display); - GdkDevice* device = gdk_device_manager_get_client_pointer(manager); - gdk_device_grab(device, window, - GDK_OWNERSHIP_NONE, true, mask, NULL, unsigned(GDK_CURRENT_TIME)); -#else - gdk_pointer_grab( window, true, - mask, - NULL, - NULL, + gdk_pointer_grab( m_widget->window, TRUE, + (GdkEventMask) + (GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_HINT_MASK | + GDK_POINTER_MOTION_MASK), + (GdkWindow *) NULL, + (GdkCursor *) NULL, (guint32)GDK_CURRENT_TIME ); -#endif } #endif @@ -402,7 +371,7 @@ bool wxPopupTransientWindow::Show( bool show ) } #endif -#if defined( __WXMSW__ ) || defined( __WXMAC__) +#if defined( __WXMSW__ ) || defined( __WMAC__ ) if (show && m_child) { // Assume that the mouse is outside the popup to begin with @@ -413,20 +382,6 @@ bool wxPopupTransientWindow::Show( bool show ) return ret; } -bool wxPopupTransientWindow::Destroy() -{ - // The popup window can be deleted at any moment, even while some events - // are still being processed for it, so delay its real destruction until - // the next idle time when we're sure that it's safe to really destroy it. - - wxCHECK_MSG( !wxPendingDelete.Member(this), false, - wxS("Shouldn't destroy the popup twice.") ); - - wxPendingDelete.Append(this); - - return true; -} - void wxPopupTransientWindow::Dismiss() { Hide(); @@ -450,43 +405,33 @@ bool wxPopupTransientWindow::ProcessLeftDown(wxMouseEvent& WXUNUSED(event)) return false; } -#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON) +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) void wxPopupTransientWindow::OnIdle(wxIdleEvent& event) { event.Skip(); if (IsShown() && m_child) { - // Store the last mouse position to minimize the number of calls to - // wxFindWindowAtPoint() which are quite expensive. - static wxPoint s_posLast; - const wxPoint pos = wxGetMousePosition(); - if ( pos != s_posLast ) + wxPoint pos = ScreenToClient(wxGetMousePosition()); + wxRect rect(GetSize()); + + if ( rect.Contains(pos) ) { - s_posLast = pos; - - wxWindow* const winUnderMouse = wxFindWindowAtPoint(pos); - - // We release the mouse capture while the mouse is inside the popup - // itself to allow using it normally with the controls inside it. - if ( wxGetTopLevelParent(winUnderMouse) == this ) + if ( m_child->HasCapture() ) { - if ( m_child->HasCapture() ) - { - m_child->ReleaseMouse(); - } + m_child->ReleaseMouse(); } - else // And we reacquire it as soon as the mouse goes outside. + } + else + { + if ( !m_child->HasCapture() ) { - if ( !m_child->HasCapture() ) - { - m_child->CaptureMouse(); - } + m_child->CaptureMouse(); } } } } -#endif // wxOSX/Carbon +#endif // __WXMSW__ #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) @@ -533,12 +478,12 @@ void wxPopupComboWindow::PositionNearCombo() void wxPopupComboWindow::OnDismiss() { - m_combo->OnPopupDismiss(true); + m_combo->OnPopupDismiss(); } void wxPopupComboWindow::OnKeyDown(wxKeyEvent& event) { - m_combo->ProcessWindowEvent(event); + m_combo->ProcessEvent(event); } #endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) @@ -590,7 +535,7 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) winUnder->ScreenToClient(&event2.m_x, &event2.m_y); event2.SetEventObject(winUnder); - wxPostEvent(winUnder->GetEventHandler(), event2); + wxPostEvent(winUnder, event2); } } break; @@ -607,7 +552,7 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) default: // forgot to update the switch after adding a new hit test code? - wxFAIL_MSG( wxT("unexpected HitTest() return value") ); + wxFAIL_MSG( _T("unexpected HitTest() return value") ); // fall through case wxHT_WINDOW_CORNER: @@ -636,15 +581,6 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) #endif // __WXUNIVERSAL__ && wxUSE_SCROLLBAR } -void -wxPopupWindowHandler::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) -{ - m_popup->DismissAndNotify(); - - // There is no need to skip the event here, normally we've already dealt - // with the focus loss. -} - // ---------------------------------------------------------------------------- // wxPopupFocusHandler // ---------------------------------------------------------------------------- @@ -664,7 +600,7 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event) m_popup->DismissAndNotify(); } -void wxPopupFocusHandler::OnChar(wxKeyEvent& event) +void wxPopupFocusHandler::OnKeyDown(wxKeyEvent& event) { // we can be associated with the popup itself in which case we should avoid // infinite recursion diff --git a/Source/3rd Party/wx/src/common/powercmn.cpp b/Source/3rd Party/wx/src/common/powercmn.cpp index 40a31aadd..cf2086ff8 100644 --- a/Source/3rd Party/wx/src/common/powercmn.cpp +++ b/Source/3rd Party/wx/src/common/powercmn.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 2006-05-27 +// RCS-ID: $Id: powercmn.cpp 48811 2007-09-19 23:11:28Z RD $ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -33,16 +34,16 @@ // ============================================================================ #ifdef wxHAS_POWER_EVENTS - wxDEFINE_EVENT( wxEVT_POWER_SUSPENDING, wxPowerEvent ); - wxDEFINE_EVENT( wxEVT_POWER_SUSPENDED, wxPowerEvent ); - wxDEFINE_EVENT( wxEVT_POWER_SUSPEND_CANCEL, wxPowerEvent ); - wxDEFINE_EVENT( wxEVT_POWER_RESUME, wxPowerEvent ); + DEFINE_EVENT_TYPE(wxEVT_POWER_SUSPENDING) + DEFINE_EVENT_TYPE(wxEVT_POWER_SUSPENDED) + DEFINE_EVENT_TYPE(wxEVT_POWER_SUSPEND_CANCEL) + DEFINE_EVENT_TYPE(wxEVT_POWER_RESUME) - IMPLEMENT_DYNAMIC_CLASS(wxPowerEvent, wxEvent) + IMPLEMENT_ABSTRACT_CLASS(wxPowerEvent, wxEvent) #endif - + // provide stubs for the systems not implementing these functions -#if !defined(__WINDOWS__) +#if !defined(__WXPALMOS__) && !defined(__WXMSW__) wxPowerType wxGetPowerType() { diff --git a/Source/3rd Party/wx/src/common/preferencescmn.cpp b/Source/3rd Party/wx/src/common/preferencescmn.cpp deleted file mode 100644 index 964949433..000000000 --- a/Source/3rd Party/wx/src/common/preferencescmn.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/preferencescmn.cpp -// Purpose: wxPreferencesEditor implementation common to all platforms. -// Author: Vaclav Slavik -// Created: 2013-02-19 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_PREFERENCES_EDITOR - -#include "wx/private/preferences.h" -#include "wx/intl.h" - -// ============================================================================ -// implementation -// ============================================================================ - -wxString wxStockPreferencesPage::GetName() const -{ - switch ( m_kind ) - { - case Kind_General: - return _("General"); - case Kind_Advanced: - return _("Advanced"); - } - return wxString(); // silence compiler warning -} - -wxPreferencesEditor::wxPreferencesEditor(const wxString& title) - : m_impl(wxPreferencesEditorImpl::Create(title)) -{ -} - -wxPreferencesEditor::~wxPreferencesEditor() -{ - delete m_impl; -} - -void wxPreferencesEditor::AddPage(wxPreferencesPage* page) -{ - wxCHECK_RET( page, "can't set NULL page" ); - m_impl->AddPage(page); -} - -void wxPreferencesEditor::Show(wxWindow* parent) -{ - m_impl->Show(parent); -} - -void wxPreferencesEditor::Dismiss() -{ - m_impl->Dismiss(); -} - -#endif // wxUSE_PREFERENCES_EDITOR diff --git a/Source/3rd Party/wx/src/common/prntbase.cpp b/Source/3rd Party/wx/src/common/prntbase.cpp index ed0d4712f..b45b319b8 100644 --- a/Source/3rd Party/wx/src/common/prntbase.cpp +++ b/Source/3rd Party/wx/src/common/prntbase.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: prntbase.cpp 60850 2009-06-01 10:16:13Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,6 +18,25 @@ #if wxUSE_PRINTING_ARCHITECTURE +// change this to 1 to use experimental high-quality printing on Windows +// (NB: this can't be in msw/printwin.cpp because of binary compatibility) +#define wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW 0 + +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + #if !defined(__WXMSW__) || !wxUSE_IMAGE || !wxUSE_WXDIB + #undef wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + #define wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW 0 + #endif +#endif + +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW +#include "wx/msw/enhmeta.h" +#endif + +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW && !wxUSE_ENH_METAFILE_FROM_DC +#error Please set wxUSE_ENH_METAFILE_FROM_DC to 1 in include/wx/msw/enhmeta.h. +#endif + #include "wx/dcprint.h" #ifndef WX_PRECOMP @@ -31,10 +51,8 @@ #include "wx/layout.h" #include "wx/choice.h" #include "wx/button.h" - #include "wx/bmpbuttn.h" #include "wx/settings.h" #include "wx/dcmemory.h" - #include "wx/dcclient.h" #include "wx/stattext.h" #include "wx/intl.h" #include "wx/textdlg.h" @@ -46,21 +64,15 @@ #include "wx/printdlg.h" #include "wx/print.h" #include "wx/dcprint.h" -#include "wx/artprov.h" #include #include #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #include "wx/msw/printdlg.h" -#include "wx/msw/dcprint.h" #elif defined(__WXMAC__) -#include "wx/osx/printdlg.h" -#include "wx/osx/private/print.h" -#include "wx/osx/dcprint.h" -#elif defined(__WXPM__) -#include "wx/os2/dcprint.h" -#include "wx/generic/prntdlgg.h" +#include "wx/mac/printdlg.h" +#include "wx/mac/private/print.h" #else #include "wx/generic/prntdlgg.h" #include "wx/dcps.h" @@ -72,6 +84,17 @@ #endif #endif // __WXMSW__ +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + +#include "wx/msw/dib.h" +#include "wx/image.h" + +typedef bool (wxPrintPreviewBase::*RenderPageIntoDCFunc)(wxDC&, int); +static bool RenderPageIntoBitmapHQ(wxPrintPreviewBase *preview, + RenderPageIntoDCFunc RenderPageIntoDC, + wxBitmap& bmp, int pageNum); +#endif // wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + //---------------------------------------------------------------------------- // wxPrintFactory //---------------------------------------------------------------------------- @@ -211,12 +234,14 @@ wxDialog *wxNativePrintFactory::CreatePrintSetupDialog( wxWindow *parent, #endif } -wxDCImpl* wxNativePrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) +wxDC* wxNativePrintFactory::CreatePrinterDC( const wxPrintData& data ) { -#if defined(__WXGTK__) || defined(__WXMOTIF__) || ( defined(__WXUNIVERSAL__) && !defined(__WXMAC__) ) - return new wxPostScriptDCImpl( owner, data ); +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) + return new wxPrinterDC(data); +#elif defined(__WXMAC__) + return new wxPrinterDC(data); #else - return new wxPrinterDCImpl( owner, data ); + return new wxPostScriptDC(data); #endif } @@ -262,7 +287,7 @@ wxPrintNativeDataBase *wxNativePrintFactory::CreatePrintNativeData() #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) return new wxWindowsPrintNativeData; #elif defined(__WXMAC__) - return wxOSXCreatePrintData(); + return new wxMacCarbonPrintData; #else return new wxPostScriptPrintNativeData; #endif @@ -304,15 +329,15 @@ IMPLEMENT_CLASS(wxPrinterBase, wxObject) wxPrinterBase::wxPrinterBase(wxPrintDialogData *data) { - m_currentPrintout = NULL; - sm_abortWindow = NULL; + m_currentPrintout = (wxPrintout *) NULL; + sm_abortWindow = (wxWindow *) NULL; sm_abortIt = false; if (data) m_printDialogData = (*data); sm_lastError = wxPRINTER_NO_ERROR; } -wxWindow *wxPrinterBase::sm_abortWindow = NULL; +wxWindow *wxPrinterBase::sm_abortWindow = (wxWindow *) NULL; bool wxPrinterBase::sm_abortIt = false; wxPrinterError wxPrinterBase::sm_lastError = wxPRINTER_NO_ERROR; @@ -320,9 +345,21 @@ wxPrinterBase::~wxPrinterBase() { } -wxPrintAbortDialog *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout * printout) +wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout * printout) { - return new wxPrintAbortDialog(parent, printout->GetTitle()); + wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing ") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE); + + wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL ); + button_sizer->Add( new wxStaticText(dialog, wxID_ANY, _("Please wait while printing\n") + printout->GetTitle() ), 0, wxALL, 10 ); + button_sizer->Add( new wxButton( dialog, wxID_CANCEL, wxT("Cancel") ), 0, wxALL | wxALIGN_CENTER, 10 ); + + dialog->SetAutoLayout( true ); + dialog->SetSizer( button_sizer ); + + button_sizer->Fit(dialog); + button_sizer->SetSizeHints (dialog) ; + + return dialog; } void wxPrinterBase::ReportError(wxWindow *parent, wxPrintout *WXUNUSED(printout), const wxString& message) @@ -351,7 +388,7 @@ wxPrinter::~wxPrinter() delete m_pimpl; } -wxPrintAbortDialog *wxPrinter::CreateAbortWindow(wxWindow *parent, wxPrintout *printout) +wxWindow *wxPrinter::CreateAbortWindow(wxWindow *parent, wxPrintout *printout) { return m_pimpl->CreateAbortWindow( parent, printout ); } @@ -368,19 +405,6 @@ bool wxPrinter::Setup(wxWindow *parent) bool wxPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { - if ( !prompt && m_printDialogData.GetToPage() == 0 ) - { - // If the dialog is not shown, set the pages range to print everything - // by default (as otherwise we wouldn't print anything at all which is - // certainly not a reasonable default behaviour). - int minPage, maxPage, selFrom, selTo; - printout->GetPageInfo(&minPage, &maxPage, &selFrom, &selTo); - - wxPrintDialogData& pdd = m_pimpl->GetPrintDialogData(); - pdd.SetFromPage(minPage); - pdd.SetToPage(maxPage); - } - return m_pimpl->Print( parent, printout, prompt ); } @@ -509,51 +533,13 @@ BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel) END_EVENT_TABLE() -wxPrintAbortDialog::wxPrintAbortDialog(wxWindow *parent, - const wxString& documentTitle, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) - : wxDialog(parent, wxID_ANY, _("Printing"), pos, size, style, name) -{ - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Please wait while printing...")), - wxSizerFlags().Expand().DoubleBorder()); - - wxFlexGridSizer *gridSizer = new wxFlexGridSizer(2, wxSize(20, 0)); - gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Document:"))); - gridSizer->AddGrowableCol(1); - gridSizer->Add(new wxStaticText(this, wxID_ANY, documentTitle)); - gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Progress:"))); - m_progress = new wxStaticText(this, wxID_ANY, _("Preparing")); - m_progress->SetMinSize(wxSize(250, -1)); - gridSizer->Add(m_progress); - mainSizer->Add(gridSizer, wxSizerFlags().Expand().DoubleBorder(wxLEFT | wxRIGHT)); - - mainSizer->Add(CreateStdDialogButtonSizer(wxCANCEL), - wxSizerFlags().Expand().DoubleBorder()); - - SetSizerAndFit(mainSizer); -} - -void wxPrintAbortDialog::SetProgress(int currentPage, int totalPages, - int currentCopy, int totalCopies) -{ - wxString text; - text.Printf(_("Printing page %d of %d"), currentPage, totalPages); - if ( totalCopies > 1 ) - text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies); - m_progress->SetLabel(text); -} - void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - wxCHECK_RET( wxPrinterBase::sm_abortWindow != NULL, "OnCancel called twice" ); - wxPrinterBase::sm_abortIt = true; + wxPrinterBase::sm_abortWindow->Show(false); + wxPrinterBase::sm_abortWindow->Close(true); wxPrinterBase::sm_abortWindow->Destroy(); - wxPrinterBase::sm_abortWindow = NULL; + wxPrinterBase::sm_abortWindow = (wxWindow *) NULL; } //---------------------------------------------------------------------------- @@ -565,7 +551,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxPrintout, wxObject) wxPrintout::wxPrintout(const wxString& title) { m_printoutTitle = title ; - m_printoutDC = NULL; + m_printoutDC = (wxDC *) NULL; m_pageWidthMM = 0; m_pageHeightMM = 0; m_pageWidthPixels = 0; @@ -574,7 +560,7 @@ wxPrintout::wxPrintout(const wxString& title) m_PPIScreenY = 0; m_PPIPrinterX = 0; m_PPIPrinterY = 0; - m_preview = NULL; + m_isPreview = false; } wxPrintout::~wxPrintout() @@ -627,7 +613,7 @@ void wxPrintout::FitThisSizeToPaper(const wxSize& imageSize) float scaleX = ((float(paperRect.width) * w) / (float(pw) * imageSize.x)); float scaleY = ((float(paperRect.height) * h) / (float(ph) * imageSize.y)); float actualScale = wxMin(scaleX, scaleY); - m_printoutDC->SetUserScale(actualScale, actualScale); + m_printoutDC->SetUserScale(actualScale, actualScale); m_printoutDC->SetDeviceOrigin(0, 0); wxRect logicalPaperRect = GetLogicalPaperRect(); SetLogicalOrigin(logicalPaperRect.x, logicalPaperRect.y); @@ -644,7 +630,7 @@ void wxPrintout::FitThisSizeToPage(const wxSize& imageSize) float scaleX = float(w) / imageSize.x; float scaleY = float(h) / imageSize.y; float actualScale = wxMin(scaleX, scaleY); - m_printoutDC->SetUserScale(actualScale, actualScale); + m_printoutDC->SetUserScale(actualScale, actualScale); m_printoutDC->SetDeviceOrigin(0, 0); } @@ -672,7 +658,7 @@ void wxPrintout::FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageS float scaleX = (float(pageMarginsRect.width) * w) / (float(pw) * imageSize.x); float scaleY = (float(pageMarginsRect.height) * h) / (float(ph) * imageSize.y); float actualScale = wxMin(scaleX, scaleY); - m_printoutDC->SetUserScale(actualScale, actualScale); + m_printoutDC->SetUserScale(actualScale, actualScale); m_printoutDC->SetDeviceOrigin(0, 0); wxRect logicalPageMarginsRect = GetLogicalPageMarginsRect(pageSetupData); SetLogicalOrigin(logicalPageMarginsRect.x, logicalPageMarginsRect.y); @@ -695,16 +681,16 @@ void wxPrintout::MapScreenSizeToPage() // Set the DC scale and origin so that an image on the screen is the same // size on the paper and the origin is at the top left of the printable area. if (!m_printoutDC) return; - int ppiScreenX, ppiScreenY; - GetPPIScreen(&ppiScreenX, &ppiScreenY); - int ppiPrinterX, ppiPrinterY; - GetPPIPrinter(&ppiPrinterX, &ppiPrinterY); - int w, h; - m_printoutDC->GetSize(&w, &h); - int pageSizePixelsX, pageSizePixelsY; - GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY); - float userScaleX = (float(ppiPrinterX) * w) / (float(ppiScreenX) * pageSizePixelsX); - float userScaleY = (float(ppiPrinterY) * h) / (float(ppiScreenY) * pageSizePixelsY); + int ppiScreenX, ppiScreenY; + GetPPIScreen(&ppiScreenX, &ppiScreenY); + int ppiPrinterX, ppiPrinterY; + GetPPIPrinter(&ppiPrinterX, &ppiPrinterY); + int w, h; + m_printoutDC->GetSize(&w, &h); + int pageSizePixelsX, pageSizePixelsY; + GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY); + float userScaleX = (float(ppiPrinterX) * w) / (float(ppiScreenX) * pageSizePixelsX); + float userScaleY = (float(ppiPrinterY) * h) / (float(ppiScreenY) * pageSizePixelsY); m_printoutDC->SetUserScale(userScaleX, userScaleY); m_printoutDC->SetDeviceOrigin(0, 0); } @@ -725,12 +711,12 @@ void wxPrintout::MapScreenSizeToDevice() // Set the DC scale so that a screen pixel is the same size as a device // pixel and the origin is at the top left of the printable area. if (!m_printoutDC) return; - int w, h; - m_printoutDC->GetSize(&w, &h); - int pageSizePixelsX, pageSizePixelsY; - GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY); - float userScaleX = float(w) / pageSizePixelsX; - float userScaleY = float(h) / pageSizePixelsY; + int w, h; + m_printoutDC->GetSize(&w, &h); + int pageSizePixelsX, pageSizePixelsY; + GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY); + float userScaleX = float(w) / pageSizePixelsX; + float userScaleY = float(h) / pageSizePixelsY; m_printoutDC->SetUserScale(userScaleX, userScaleY); m_printoutDC->SetDeviceOrigin(0, 0); } @@ -746,17 +732,17 @@ wxRect wxPrintout::GetLogicalPaperRect() const m_printoutDC->GetSize(&w, &h); if (w == pw && h == ph) { // this DC matches the printed page, so no scaling - return wxRect(m_printoutDC->DeviceToLogicalX(paperRect.x), - m_printoutDC->DeviceToLogicalY(paperRect.y), - m_printoutDC->DeviceToLogicalXRel(paperRect.width), + return wxRect(m_printoutDC->DeviceToLogicalX(paperRect.x), + m_printoutDC->DeviceToLogicalY(paperRect.y), + m_printoutDC->DeviceToLogicalXRel(paperRect.width), m_printoutDC->DeviceToLogicalYRel(paperRect.height)); } // This DC doesn't match the printed page, so we have to scale. float scaleX = float(w) / pw; float scaleY = float(h) / ph; - return wxRect(m_printoutDC->DeviceToLogicalX(wxRound(paperRect.x * scaleX)), - m_printoutDC->DeviceToLogicalY(wxRound(paperRect.y * scaleY)), - m_printoutDC->DeviceToLogicalXRel(wxRound(paperRect.width * scaleX)), + return wxRect(m_printoutDC->DeviceToLogicalX(wxRound(paperRect.x * scaleX)), + m_printoutDC->DeviceToLogicalY(wxRound(paperRect.y * scaleY)), + m_printoutDC->DeviceToLogicalXRel(wxRound(paperRect.width * scaleX)), m_printoutDC->DeviceToLogicalYRel(wxRound(paperRect.height * scaleY))); } @@ -766,9 +752,9 @@ wxRect wxPrintout::GetLogicalPageRect() const // area. int w, h; m_printoutDC->GetSize(&w, &h); - return wxRect(m_printoutDC->DeviceToLogicalX(0), - m_printoutDC->DeviceToLogicalY(0), - m_printoutDC->DeviceToLogicalXRel(w), + return wxRect(m_printoutDC->DeviceToLogicalX(0), + m_printoutDC->DeviceToLogicalY(0), + m_printoutDC->DeviceToLogicalXRel(w), m_printoutDC->DeviceToLogicalYRel(h)); } @@ -777,68 +763,53 @@ wxRect wxPrintout::GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSe // Return the rectangle in logical units that corresponds to the region // within the page margins as specified by the given wxPageSetupDialogData // object. - - // We get the paper size in device units and the margins in mm, - // so we need to calculate the conversion with this trick + wxRect paperRect = GetPaperRectPixels(); wxCoord pw, ph; GetPageSizePixels(&pw, &ph); + wxPoint topLeft = pageSetupData.GetMarginTopLeft(); + wxPoint bottomRight = pageSetupData.GetMarginBottomRight(); wxCoord mw, mh; GetPageSizeMM(&mw, &mh); float mmToDeviceX = float(pw) / mw; float mmToDeviceY = float(ph) / mh; - - // paper size in device units - wxRect paperRect = GetPaperRectPixels(); - - // margins in mm - wxPoint topLeft = pageSetupData.GetMarginTopLeft(); - wxPoint bottomRight = pageSetupData.GetMarginBottomRight(); - - // calculate margins in device units - wxRect pageMarginsRect( - paperRect.x + wxRound(mmToDeviceX * topLeft.x), - paperRect.y + wxRound(mmToDeviceY * topLeft.y), - paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)), + wxRect pageMarginsRect(paperRect.x + wxRound(mmToDeviceX * topLeft.x), + paperRect.y + wxRound(mmToDeviceY * topLeft.y), + paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)), paperRect.height - wxRound(mmToDeviceY * (topLeft.y + bottomRight.y))); - wxCoord w, h; m_printoutDC->GetSize(&w, &h); - if (w == pw && h == ph) - { + if (w == pw && h == ph) { // this DC matches the printed page, so no scaling - return wxRect( - m_printoutDC->DeviceToLogicalX(pageMarginsRect.x), - m_printoutDC->DeviceToLogicalY(pageMarginsRect.y), - m_printoutDC->DeviceToLogicalXRel(pageMarginsRect.width), + return wxRect(m_printoutDC->DeviceToLogicalX(pageMarginsRect.x), + m_printoutDC->DeviceToLogicalY(pageMarginsRect.y), + m_printoutDC->DeviceToLogicalXRel(pageMarginsRect.width), m_printoutDC->DeviceToLogicalYRel(pageMarginsRect.height)); } - // This DC doesn't match the printed page, so we have to scale. float scaleX = float(w) / pw; float scaleY = float(h) / ph; - return wxRect(m_printoutDC->DeviceToLogicalX(wxRound(pageMarginsRect.x * scaleX)), - m_printoutDC->DeviceToLogicalY(wxRound(pageMarginsRect.y * scaleY)), - m_printoutDC->DeviceToLogicalXRel(wxRound(pageMarginsRect.width * scaleX)), + return wxRect(m_printoutDC->DeviceToLogicalX(wxRound(pageMarginsRect.x * scaleX)), + m_printoutDC->DeviceToLogicalY(wxRound(pageMarginsRect.y * scaleY)), + m_printoutDC->DeviceToLogicalXRel(wxRound(pageMarginsRect.width * scaleX)), m_printoutDC->DeviceToLogicalYRel(wxRound(pageMarginsRect.height * scaleY))); } void wxPrintout::SetLogicalOrigin(wxCoord x, wxCoord y) { // Set the device origin by specifying a point in logical coordinates. - m_printoutDC->SetDeviceOrigin( - m_printoutDC->LogicalToDeviceX(x), - m_printoutDC->LogicalToDeviceY(y) ); + m_printoutDC->SetDeviceOrigin(m_printoutDC->LogicalToDeviceX(x), + m_printoutDC->LogicalToDeviceY(y)); } - + void wxPrintout::OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff) { // Offset the device origin by a specified distance in device coordinates. - wxPoint dev_org = m_printoutDC->GetDeviceOrigin(); - m_printoutDC->SetDeviceOrigin( - dev_org.x + m_printoutDC->LogicalToDeviceXRel(xoff), - dev_org.y + m_printoutDC->LogicalToDeviceYRel(yoff) ); + wxCoord x = m_printoutDC->LogicalToDeviceX(0); + wxCoord y = m_printoutDC->LogicalToDeviceY(0); + m_printoutDC->SetDeviceOrigin(x + m_printoutDC->LogicalToDeviceXRel(xoff), + y + m_printoutDC->LogicalToDeviceYRel(yoff)); } - + //---------------------------------------------------------------------------- // wxPreviewCanvas @@ -849,7 +820,6 @@ IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow) BEGIN_EVENT_TABLE(wxPreviewCanvas, wxScrolledWindow) EVT_PAINT(wxPreviewCanvas::OnPaint) EVT_CHAR(wxPreviewCanvas::OnChar) - EVT_IDLE(wxPreviewCanvas::OnIdle) EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged) #if wxUSE_MOUSEWHEEL EVT_MOUSEWHEEL(wxPreviewCanvas::OnMouseWheel) @@ -901,25 +871,6 @@ void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) } } -void wxPreviewCanvas::OnIdle(wxIdleEvent& event) -{ - event.Skip(); - - // prevent UpdatePageRendering() from being called recursively: - static bool s_inIdle = false; - if ( s_inIdle ) - return; - s_inIdle = true; - - if ( m_printPreview ) - { - if ( m_printPreview->UpdatePageRendering() ) - Refresh(); - } - - s_inIdle = false; -} - // Responds to colour changes, and passes event on to children. void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event) { @@ -942,21 +893,20 @@ void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event) void wxPreviewCanvas::OnChar(wxKeyEvent &event) { wxPreviewControlBar* controlBar = ((wxPreviewFrame*) GetParent())->GetControlBar(); - switch (event.GetKeyCode()) + if (event.GetKeyCode() == WXK_ESCAPE) { - case WXK_RETURN: - controlBar->OnPrint(); - return; - case (int)'+': - case WXK_NUMPAD_ADD: - case WXK_ADD: - controlBar->DoZoomIn(); - return; - case (int)'-': - case WXK_NUMPAD_SUBTRACT: - case WXK_SUBTRACT: - controlBar->DoZoomOut(); - return; + ((wxPreviewFrame*) GetParent())->Close(true); + return; + } + else if (event.GetKeyCode() == WXK_TAB) + { + controlBar->OnGoto(); + return; + } + else if (event.GetKeyCode() == WXK_RETURN) + { + controlBar->OnPrint(); + return; } if (!event.ControlDown()) @@ -1024,188 +974,6 @@ void wxPreviewCanvas::OnMouseWheel(wxMouseEvent& event) #endif // wxUSE_MOUSEWHEEL -namespace -{ - -// This is by the controls in the print preview as the maximal (and hence -// longest) page number we may have to display. -enum { MAX_PAGE_NUMBER = 99999 }; - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// wxPrintPageMaxCtrl -// ---------------------------------------------------------------------------- - -// A simple static control showing the maximal number of pages. -class wxPrintPageMaxCtrl : public wxStaticText -{ -public: - wxPrintPageMaxCtrl(wxWindow *parent) - : wxStaticText( - parent, - wxID_ANY, - wxString(), - wxDefaultPosition, - wxSize - ( - parent->GetTextExtent(MaxAsString(MAX_PAGE_NUMBER)).x, - wxDefaultCoord - ), - wxST_NO_AUTORESIZE | wxALIGN_CENTRE - ) - { - } - - // Set the maximal page to display once we really know what it is. - void SetMaxPage(int maxPage) - { - SetLabel(MaxAsString(maxPage)); - } - -private: - static wxString MaxAsString(int maxPage) - { - return wxString::Format("/ %d", maxPage); - } - - wxDECLARE_NO_COPY_CLASS(wxPrintPageMaxCtrl); -}; - -// ---------------------------------------------------------------------------- -// wxPrintPageTextCtrl -// ---------------------------------------------------------------------------- - -// This text control contains the page number in the specified interval. -// -// Invalid pages are not accepted and the control contents is validated when it -// loses focus. Conversely, if the user changes the page to another valid one -// or presses Enter, OnGotoPage() method of the preview object will be called. -class wxPrintPageTextCtrl : public wxTextCtrl -{ -public: - wxPrintPageTextCtrl(wxPreviewControlBar *preview) - : wxTextCtrl(preview, - wxID_PREVIEW_GOTO, - wxString(), - wxDefaultPosition, - // We use hardcoded maximal page number for the width - // instead of fitting it to the values we can show because - // the control looks uncomfortably narrow if the real page - // number is just one or two digits. - wxSize - ( - preview->GetTextExtent(PageAsString(MAX_PAGE_NUMBER)).x, - wxDefaultCoord - ), - wxTE_PROCESS_ENTER -#if wxUSE_VALIDATORS - , wxTextValidator(wxFILTER_DIGITS) -#endif // wxUSE_VALIDATORS - ), - m_preview(preview) - { - m_minPage = - m_maxPage = - m_page = 1; - - Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(wxPrintPageTextCtrl::OnKillFocus)); - Connect(wxEVT_TEXT_ENTER, - wxCommandEventHandler(wxPrintPageTextCtrl::OnTextEnter)); - } - - // Update the pages range, must be called after OnPreparePrinting() as - // these values are not known before. - void SetPageInfo(int minPage, int maxPage) - { - m_minPage = minPage; - m_maxPage = maxPage; - - // Show the first page by default. - SetPageNumber(minPage); - } - - // Helpers to conveniently set or get the current page number. Return value - // is 0 if the current controls contents is invalid. - void SetPageNumber(int page) - { - wxASSERT( IsValidPage(page) ); - - SetValue(PageAsString(page)); - } - - int GetPageNumber() const - { - long value; - if ( !GetValue().ToLong(&value) || !IsValidPage(value) ) - return 0; - - // Cast is safe because the value is less than (int) m_maxPage. - return static_cast(value); - } - -private: - static wxString PageAsString(int page) - { - return wxString::Format("%d", page); - } - - bool IsValidPage(int page) const - { - return page >= m_minPage && page <= m_maxPage; - } - - bool DoChangePage() - { - const int page = GetPageNumber(); - - if ( !page ) - return false; - - if ( page != m_page ) - { - // We have a valid page, remember it. - m_page = page; - - // And notify the owner about the change. - m_preview->OnGotoPage(); - } - //else: Nothing really changed. - - return true; - } - - void OnKillFocus(wxFocusEvent& event) - { - if ( !DoChangePage() ) - { - // The current contents is invalid so reset it back to the last - // known good page index. - SetPageNumber(m_page); - } - - event.Skip(); - } - - void OnTextEnter(wxCommandEvent& WXUNUSED(event)) - { - DoChangePage(); - } - - - wxPreviewControlBar * const m_preview; - - int m_minPage, - m_maxPage; - - // This is the last valid page value that we had, we revert to it if an - // invalid page is entered. - int m_page; - - wxDECLARE_NO_COPY_CLASS(wxPrintPageTextCtrl); -}; - //---------------------------------------------------------------------------- // wxPreviewControlBar //---------------------------------------------------------------------------- @@ -1219,19 +987,9 @@ BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel) EVT_BUTTON(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnNextButton) EVT_BUTTON(wxID_PREVIEW_FIRST, wxPreviewControlBar::OnFirstButton) EVT_BUTTON(wxID_PREVIEW_LAST, wxPreviewControlBar::OnLastButton) - EVT_BUTTON(wxID_PREVIEW_ZOOM_IN, wxPreviewControlBar::OnZoomInButton) - EVT_BUTTON(wxID_PREVIEW_ZOOM_OUT, wxPreviewControlBar::OnZoomOutButton) - - EVT_UPDATE_UI(wxID_PREVIEW_PREVIOUS, wxPreviewControlBar::OnUpdatePreviousButton) - EVT_UPDATE_UI(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnUpdateNextButton) - EVT_UPDATE_UI(wxID_PREVIEW_FIRST, wxPreviewControlBar::OnUpdateFirstButton) - EVT_UPDATE_UI(wxID_PREVIEW_LAST, wxPreviewControlBar::OnUpdateLastButton) - EVT_UPDATE_UI(wxID_PREVIEW_ZOOM_IN, wxPreviewControlBar::OnUpdateZoomInButton) - EVT_UPDATE_UI(wxID_PREVIEW_ZOOM_OUT, wxPreviewControlBar::OnUpdateZoomOutButton) - - EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoomChoice) + EVT_BUTTON(wxID_PREVIEW_GOTO, wxPreviewControlBar::OnGotoButton) + EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoom) EVT_PAINT(wxPreviewControlBar::OnPaint) - END_EVENT_TABLE() wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons, @@ -1240,10 +998,11 @@ wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long butto wxPanel(parent, wxID_ANY, pos, size, style, name) { m_printPreview = preview; - m_closeButton = NULL; - m_zoomControl = NULL; - m_currentPageText = NULL; - m_maxPageText = NULL; + m_closeButton = (wxButton *) NULL; + m_nextPageButton = (wxButton *) NULL; + m_previousPageButton = (wxButton *) NULL; + m_printButton = (wxButton *) NULL; + m_zoomControl = (wxChoice *) NULL; m_buttonFlags = buttons; } @@ -1274,281 +1033,155 @@ void wxPreviewControlBar::OnPrint(void) preview->Print(true); } -void wxPreviewControlBar::OnNext() -{ - if ( IsNextEnabled() ) - DoGotoPage(GetPrintPreview()->GetCurrentPage() + 1); -} - -void wxPreviewControlBar::OnPrevious() -{ - if ( IsPreviousEnabled() ) - DoGotoPage(GetPrintPreview()->GetCurrentPage() - 1); -} - -void wxPreviewControlBar::OnFirst() -{ - if ( IsFirstEnabled() ) - DoGotoPage(GetPrintPreview()->GetMinPage()); -} - -void wxPreviewControlBar::OnLast() -{ - if ( IsLastEnabled() ) - DoGotoPage(GetPrintPreview()->GetMaxPage()); -} - -bool wxPreviewControlBar::IsNextEnabled() const -{ - wxPrintPreviewBase *preview = GetPrintPreview(); - if ( !preview ) - return false; - - const int currentPage = preview->GetCurrentPage(); - return currentPage < preview->GetMaxPage() && - preview->GetPrintout()->HasPage(currentPage + 1); -} - -bool wxPreviewControlBar::IsPreviousEnabled() const -{ - wxPrintPreviewBase *preview = GetPrintPreview(); - if ( !preview ) - return false; - - const int currentPage = preview->GetCurrentPage(); - return currentPage > preview->GetMinPage() && - preview->GetPrintout()->HasPage(currentPage - 1); -} - -bool wxPreviewControlBar::IsFirstEnabled() const -{ - wxPrintPreviewBase *preview = GetPrintPreview(); - if (!preview) - return false; - - return preview->GetPrintout()->HasPage(preview->GetMinPage()); -} - -bool wxPreviewControlBar::IsLastEnabled() const -{ - wxPrintPreviewBase *preview = GetPrintPreview(); - if (!preview) - return false; - - return preview->GetPrintout()->HasPage(preview->GetMaxPage()); -} - -void wxPreviewControlBar::DoGotoPage(int page) -{ - wxPrintPreviewBase *preview = GetPrintPreview(); - wxCHECK_RET( preview, "Shouldn't be called if there is no preview." ); - - preview->SetCurrentPage(page); - - if ( m_currentPageText ) - m_currentPageText->SetPageNumber(page); -} - -void wxPreviewControlBar::OnGotoPage() +void wxPreviewControlBar::OnNext(void) { wxPrintPreviewBase *preview = GetPrintPreview(); if (preview) { - if (preview->GetMinPage() > 0) + int currentPage = preview->GetCurrentPage(); + if ((preview->GetMaxPage() > 0) && + (currentPage < preview->GetMaxPage()) && + preview->GetPrintout()->HasPage(currentPage + 1)) { - long currentPage = m_currentPageText->GetPageNumber(); - if ( currentPage ) - { - if (preview->GetPrintout()->HasPage(currentPage)) - { - preview->SetCurrentPage(currentPage); - } - } + preview->SetCurrentPage(currentPage + 1); } } } -void wxPreviewControlBar::DoZoom() +void wxPreviewControlBar::OnPrevious(void) +{ + wxPrintPreviewBase *preview = GetPrintPreview(); + if (preview) + { + int currentPage = preview->GetCurrentPage(); + if ((preview->GetMinPage() > 0) && + (currentPage > preview->GetMinPage()) && + preview->GetPrintout()->HasPage(currentPage - 1)) + { + preview->SetCurrentPage(currentPage - 1); + } + } +} + +void wxPreviewControlBar::OnFirst(void) +{ + wxPrintPreviewBase *preview = GetPrintPreview(); + if (preview) + { + int currentPage = preview->GetMinPage(); + if (preview->GetPrintout()->HasPage(currentPage)) + { + preview->SetCurrentPage(currentPage); + } + } +} + +void wxPreviewControlBar::OnLast(void) +{ + wxPrintPreviewBase *preview = GetPrintPreview(); + if (preview) + { + int currentPage = preview->GetMaxPage(); + if (preview->GetPrintout()->HasPage(currentPage)) + { + preview->SetCurrentPage(currentPage); + } + } +} + +void wxPreviewControlBar::OnGoto(void) +{ + wxPrintPreviewBase *preview = GetPrintPreview(); + if (preview) + { + long currentPage; + + if (preview->GetMinPage() > 0) + { + wxString strPrompt; + wxString strPage; + + strPrompt.Printf( _("Enter a page number between %d and %d:"), + preview->GetMinPage(), preview->GetMaxPage()); + strPage.Printf( wxT("%d"), preview->GetCurrentPage() ); + + strPage = + wxGetTextFromUser( strPrompt, _("Goto Page"), strPage, GetParent()); + + if ( strPage.ToLong( ¤tPage ) ) + if (preview->GetPrintout()->HasPage(currentPage)) + { + preview->SetCurrentPage(currentPage); + } + } + } +} + +void wxPreviewControlBar::OnZoom(wxCommandEvent& WXUNUSED(event)) { int zoom = GetZoomControl(); if (GetPrintPreview()) GetPrintPreview()->SetZoom(zoom); } -bool wxPreviewControlBar::IsZoomInEnabled() const -{ - if ( !m_zoomControl ) - return false; - - const unsigned sel = m_zoomControl->GetSelection(); - return sel < m_zoomControl->GetCount() - 1; -} - -bool wxPreviewControlBar::IsZoomOutEnabled() const -{ - return m_zoomControl && m_zoomControl->GetSelection() > 0; -} - -void wxPreviewControlBar::DoZoomIn() -{ - if (IsZoomInEnabled()) - { - m_zoomControl->SetSelection(m_zoomControl->GetSelection() + 1); - DoZoom(); - } -} - -void wxPreviewControlBar::DoZoomOut() -{ - if (IsZoomOutEnabled()) - { - m_zoomControl->SetSelection(m_zoomControl->GetSelection() - 1); - DoZoom(); - } -} - -namespace -{ - -// Helper class used by wxPreviewControlBar::CreateButtons() to add buttons -// sequentially to it in the simplest way possible. -class SizerWithButtons -{ -public: - // Constructor creates the sizer that will hold the buttons and stores the - // parent that will be used for their creation. - SizerWithButtons(wxWindow *parent) - : m_sizer(new wxBoxSizer(wxHORIZONTAL)), - m_parent(parent) - { - m_hasContents = - m_needsSeparator = false; - } - - // Destructor associates the sizer with the parent window. - ~SizerWithButtons() - { - m_parent->SetSizer(m_sizer); - m_sizer->Fit(m_parent); - } - - - // Add an arbitrary window to the sizer. - void Add(wxWindow *win) - { - if ( m_needsSeparator ) - { - m_needsSeparator = false; - - m_sizer->AddSpacer(2*wxSizerFlags::GetDefaultBorder()); - } - - m_hasContents = true; - - m_sizer->Add(win, - wxSizerFlags().Border(wxLEFT | wxTOP | wxBOTTOM).Center()); - } - - // Add a button with the specified id, bitmap and tooltip. - void AddButton(wxWindowID btnId, - const wxArtID& artId, - const wxString& tooltip) - { - // We don't use (smaller) images inside a button with a text label but - // rather toolbar-like bitmap buttons hence use wxART_TOOLBAR and not - // wxART_BUTTON here. - wxBitmap bmp = wxArtProvider::GetBitmap(artId, wxART_TOOLBAR); - wxBitmapButton * const btn = new wxBitmapButton(m_parent, btnId, bmp); - btn->SetToolTip(tooltip); - - Add(btn); - } - - // Add a control at the right end of the window. This should be called last - // as everything else added after it will be added on the right side too. - void AddAtEnd(wxWindow *win) - { - m_sizer->AddStretchSpacer(); - m_sizer->Add(win, - wxSizerFlags().Border(wxTOP | wxBOTTOM | wxRIGHT).Center()); - } - - // Indicates the end of a group of buttons, a separator will be added after - // it. - void EndOfGroup() - { - if ( m_hasContents ) - { - m_needsSeparator = true; - m_hasContents = false; - } - } - -private: - wxSizer * const m_sizer; - wxWindow * const m_parent; - - // If true, we have some controls since the last group beginning. This is - // used to avoid inserting two consecutive separators if EndOfGroup() is - // called twice. - bool m_hasContents; - - // If true, a separator should be inserted before adding the next button. - bool m_needsSeparator; - - wxDECLARE_NO_COPY_CLASS(SizerWithButtons); -}; - -} // anonymous namespace - void wxPreviewControlBar::CreateButtons() { - SizerWithButtons sizer(this); + SetSize(0, 0, 400, 40); + + wxBoxSizer *item0 = new wxBoxSizer( wxHORIZONTAL ); + + m_closeButton = new wxButton( this, wxID_PREVIEW_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + item0->Add( m_closeButton, 0, wxALIGN_CENTRE|wxALL, 5 ); - // Print button group (a single button). if (m_buttonFlags & wxPREVIEW_PRINT) { - sizer.AddButton(wxID_PREVIEW_PRINT, wxART_PRINT, _("Print")); - sizer.EndOfGroup(); + m_printButton = new wxButton( this, wxID_PREVIEW_PRINT, _("&Print..."), wxDefaultPosition, wxDefaultSize, 0 ); + item0->Add( m_printButton, 0, wxALIGN_CENTRE|wxALL, 5 ); } - // Page selection buttons group. + // Exact-fit buttons are too tiny on wxUniversal + int navButtonStyle; + wxSize navButtonSize; +#ifdef __WXUNIVERSAL__ + navButtonStyle = 0; + navButtonSize = wxSize(40, m_closeButton->GetSize().y); +#else + navButtonStyle = wxBU_EXACTFIT; + navButtonSize = wxDefaultSize; +#endif + if (m_buttonFlags & wxPREVIEW_FIRST) { - sizer.AddButton(wxID_PREVIEW_FIRST, wxART_GOTO_FIRST, _("First page")); + m_firstPageButton = new wxButton( this, wxID_PREVIEW_FIRST, _("|<<"), wxDefaultPosition, navButtonSize, navButtonStyle ); + item0->Add( m_firstPageButton, 0, wxALIGN_CENTRE|wxALL, 5 ); } if (m_buttonFlags & wxPREVIEW_PREVIOUS) { - sizer.AddButton(wxID_PREVIEW_PREVIOUS, wxART_GO_BACK, _("Previous page")); - } - - if (m_buttonFlags & wxPREVIEW_GOTO) - { - m_currentPageText = new wxPrintPageTextCtrl(this); - sizer.Add(m_currentPageText); - - m_maxPageText = new wxPrintPageMaxCtrl(this); - sizer.Add(m_maxPageText); + m_previousPageButton = new wxButton( this, wxID_PREVIEW_PREVIOUS, _("<<"), wxDefaultPosition, navButtonSize, navButtonStyle ); + item0->Add( m_previousPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); } if (m_buttonFlags & wxPREVIEW_NEXT) { - sizer.AddButton(wxID_PREVIEW_NEXT, wxART_GO_FORWARD, _("Next page")); + m_nextPageButton = new wxButton( this, wxID_PREVIEW_NEXT, _(">>"), wxDefaultPosition, navButtonSize, navButtonStyle ); + item0->Add( m_nextPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); } if (m_buttonFlags & wxPREVIEW_LAST) { - sizer.AddButton(wxID_PREVIEW_LAST, wxART_GOTO_LAST, _("Last page")); + m_lastPageButton = new wxButton( this, wxID_PREVIEW_LAST, _(">>|"), wxDefaultPosition, navButtonSize, navButtonStyle ); + item0->Add( m_lastPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); } - sizer.EndOfGroup(); + if (m_buttonFlags & wxPREVIEW_GOTO) + { + m_gotoPageButton = new wxButton( this, wxID_PREVIEW_GOTO, _("&Goto..."), wxDefaultPosition, wxDefaultSize, 0 ); + item0->Add( m_gotoPageButton, 0, wxALIGN_CENTRE|wxALL, 5 ); + } - // Zoom controls group. if (m_buttonFlags & wxPREVIEW_ZOOM) { - sizer.AddButton(wxID_PREVIEW_ZOOM_OUT, wxART_MINUS, _("Zoom Out")); - wxString choices[] = { wxT("10%"), wxT("15%"), wxT("20%"), wxT("25%"), wxT("30%"), wxT("35%"), wxT("40%"), wxT("45%"), wxT("50%"), wxT("55%"), @@ -1558,26 +1191,12 @@ void wxPreviewControlBar::CreateButtons() int n = WXSIZEOF(choices); m_zoomControl = new wxChoice( this, wxID_PREVIEW_ZOOM, wxDefaultPosition, wxSize(70,wxDefaultCoord), n, choices, 0 ); - sizer.Add(m_zoomControl); + item0->Add( m_zoomControl, 0, wxALIGN_CENTRE|wxALL, 5 ); SetZoomControl(m_printPreview->GetZoom()); - - sizer.AddButton(wxID_PREVIEW_ZOOM_IN, wxART_PLUS, _("Zoom In")); - - sizer.EndOfGroup(); } - // Close button group (single button again). - m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("&Close")); - sizer.AddAtEnd(m_closeButton); -} - -void wxPreviewControlBar::SetPageInfo(int minPage, int maxPage) -{ - if ( m_currentPageText ) - m_currentPageText->SetPageInfo(minPage, maxPage); - - if ( m_maxPageText ) - m_maxPageText->SetMaxPage(maxPage); + SetSizer(item0); + item0->Fit(this); } void wxPreviewControlBar::SetZoomControl(int zoom) @@ -1620,22 +1239,9 @@ int wxPreviewControlBar::GetZoomControl() IMPLEMENT_CLASS(wxPreviewFrame, wxFrame) BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame) - EVT_CHAR_HOOK(wxPreviewFrame::OnChar) EVT_CLOSE(wxPreviewFrame::OnCloseWindow) END_EVENT_TABLE() -void wxPreviewFrame::OnChar(wxKeyEvent &event) -{ - if ( event.GetKeyCode() == WXK_ESCAPE ) - { - Close(true); - } - else - { - event.Skip(); - } -} - wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxFrame(parent, wxID_ANY, title, pos, size, style, name) @@ -1644,18 +1250,25 @@ wxFrame(parent, wxID_ANY, title, pos, size, style, name) m_controlBar = NULL; m_previewCanvas = NULL; m_windowDisabler = NULL; - m_modalityKind = wxPreviewFrame_NonModal; // Give the application icon #ifdef __WXMSW__ wxFrame* topFrame = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame); if (topFrame) - SetIcons(topFrame->GetIcons()); + SetIcon(topFrame->GetIcon()); #endif } wxPreviewFrame::~wxPreviewFrame() { +} + +void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) +{ + if (m_windowDisabler) + delete m_windowDisabler; + + // Need to delete the printout and the print preview wxPrintout *printout = m_printPreview->GetPrintout(); if (printout) { @@ -1664,35 +1277,12 @@ wxPreviewFrame::~wxPreviewFrame() m_printPreview->SetCanvas(NULL); m_printPreview->SetFrame(NULL); } - - m_previewCanvas->SetPreview(NULL); delete m_printPreview; -} - -void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - // Reenable any windows we disabled by undoing whatever we did in our - // Initialize(). - switch ( m_modalityKind ) - { - case wxPreviewFrame_AppModal: - delete m_windowDisabler; - m_windowDisabler = NULL; - break; - - case wxPreviewFrame_WindowModal: - if ( GetParent() ) - GetParent()->Enable(); - break; - - case wxPreviewFrame_NonModal: - break; - } Destroy(); } -void wxPreviewFrame::InitializeWithModality(wxPreviewFrameModalityKind kind) +void wxPreviewFrame::Initialize() { #if wxUSE_STATUSBAR CreateStatusBar(); @@ -1711,32 +1301,7 @@ void wxPreviewFrame::InitializeWithModality(wxPreviewFrameModalityKind kind) SetAutoLayout( true ); SetSizer( item0 ); - m_modalityKind = kind; - switch ( m_modalityKind ) - { - case wxPreviewFrame_AppModal: - // Disable everything. - m_windowDisabler = new wxWindowDisabler( this ); - break; - - case wxPreviewFrame_WindowModal: - // Disable our parent if we have one. - if ( GetParent() ) - GetParent()->Disable(); - break; - - case wxPreviewFrame_NonModal: - // Nothing to do, we don't need to disable any windows. - break; - } - - if ( m_modalityKind != wxPreviewFrame_NonModal ) - { - // Behave like modal dialogs, don't show in taskbar. This implies - // removing the minimize box, because minimizing windows without - // taskbar entry is confusing. - SetWindowStyle((GetWindowStyle() & ~wxMINIMIZE_BOX) | wxFRAME_NO_TASKBAR); - } + m_windowDisabler = new wxWindowDisabler(this); Layout(); @@ -1756,7 +1321,7 @@ void wxPreviewFrame::CreateControlBar() if (m_printPreview->GetPrintoutForPrinting()) buttons |= wxPREVIEW_PRINT; - m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this); + m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0,0), wxSize(400, 40)); m_controlBar->CreateButtons(); } @@ -1792,18 +1357,17 @@ void wxPrintPreviewBase::Init(wxPrintout *printout, m_isOk = true; m_previewPrintout = printout; if (m_previewPrintout) - m_previewPrintout->SetPreview(static_cast(this)); + m_previewPrintout->SetIsPreview(true); m_printPrintout = printoutForPrinting; m_previewCanvas = NULL; m_previewFrame = NULL; m_previewBitmap = NULL; - m_previewFailed = false; m_currentPage = 1; m_currentZoom = 70; - m_topMargin = - m_leftMargin = 2*wxSizerFlags::GetDefaultBorder(); + m_topMargin = 40; + m_leftMargin = 40; m_pageWidth = 0; m_pageHeight = 0; m_printingPrepared = false; @@ -1827,13 +1391,18 @@ bool wxPrintPreviewBase::SetCurrentPage(int pageNum) return true; m_currentPage = pageNum; - - InvalidatePreviewBitmap(); + if (m_previewBitmap) + { + delete m_previewBitmap; + m_previewBitmap = NULL; + } if (m_previewCanvas) { AdjustScrollbars(m_previewCanvas); + if (!RenderPage(pageNum)) + return false; m_previewCanvas->Refresh(); m_previewCanvas->SetFocus(); } @@ -1890,35 +1459,13 @@ void wxPrintPreviewBase::CalcRects(wxPreviewCanvas *canvas, wxRect& pageRect, wx } -void wxPrintPreviewBase::InvalidatePreviewBitmap() -{ - wxDELETE(m_previewBitmap); - // if there was a problem with rendering the preview, try again now - // that it changed in some way (less memory may be needed, for example): - m_previewFailed = false; -} - -bool wxPrintPreviewBase::UpdatePageRendering() -{ - if ( m_previewBitmap ) - return false; - - if ( m_previewFailed ) - return false; - - if ( !RenderPage(m_currentPage) ) - { - m_previewFailed = true; // don't waste time failing again - return false; - } - - return true; -} - bool wxPrintPreviewBase::PaintPage(wxPreviewCanvas *canvas, wxDC& dc) { DrawBlankPage(canvas, dc); + if (!m_previewBitmap) + if (!RenderPage(m_currentPage)) + return false; if (!m_previewBitmap) return false; if (!canvas) @@ -1929,7 +1476,7 @@ bool wxPrintPreviewBase::PaintPage(wxPreviewCanvas *canvas, wxDC& dc) wxMemoryDC temp_dc; temp_dc.SelectObject(*m_previewBitmap); - dc.Blit(pageRect.x, pageRect.y, + dc.Blit(pageRect.x, pageRect.y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0); temp_dc.SelectObject(wxNullBitmap); @@ -1959,23 +1506,13 @@ bool wxPrintPreviewBase::RenderPageIntoDC(wxDC& dc, int pageNum) m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight); // Need to delay OnPreparePrinting() until here, so we have enough - // information and a wxDC. + // information. if (!m_printingPrepared) { - m_printingPrepared = true; - m_previewPrintout->OnPreparePrinting(); int selFrom, selTo; m_previewPrintout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo); - - // Update the wxPreviewControlBar page range display. - if ( m_previewFrame ) - { - wxPreviewControlBar * const - controlBar = ((wxPreviewFrame*)m_previewFrame)->GetControlBar(); - if ( controlBar ) - controlBar->SetPageInfo(m_minPage, m_maxPage); - } + m_printingPrepared = true; } m_previewPrintout->OnBeginPrinting(); @@ -1997,6 +1534,17 @@ bool wxPrintPreviewBase::RenderPageIntoDC(wxDC& dc, int pageNum) bool wxPrintPreviewBase::RenderPageIntoBitmap(wxBitmap& bmp, int pageNum) { +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + { + if ( RenderPageIntoBitmapHQ(this, + &wxPrintPreviewBase::RenderPageIntoDC, + bmp, pageNum) ) + { + return true; + } + } +#endif // wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + wxMemoryDC memoryDC; memoryDC.SelectObject(bmp); memoryDC.Clear(); @@ -2010,7 +1558,7 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) if (!m_previewCanvas) { - wxFAIL_MSG(wxT("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!")); + wxFAIL_MSG(_T("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!")); return false; } @@ -2021,9 +1569,12 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) { m_previewBitmap = new wxBitmap(pageRect.width, pageRect.height); - if (!m_previewBitmap || !m_previewBitmap->IsOk()) + if (!m_previewBitmap || !m_previewBitmap->Ok()) { - InvalidatePreviewBitmap(); + if (m_previewBitmap) { + delete m_previewBitmap; + m_previewBitmap = NULL; + } wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK); return false; } @@ -2031,8 +1582,10 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) if ( !RenderPageIntoBitmap(*m_previewBitmap, pageNum) ) { - InvalidatePreviewBitmap(); - wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK); + wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK); + + delete m_previewBitmap; + m_previewBitmap = NULL; return false; } @@ -2070,7 +1623,7 @@ bool wxPrintPreviewBase::DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc) // Draw blank page allowing for 1-pixel border AROUND the actual paper dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); - dc.DrawRectangle(paperRect.x - 2, paperRect.y - 1, + dc.DrawRectangle(paperRect.x - 2, paperRect.y - 1, paperRect.width + 3, paperRect.height + 2); return true; @@ -2082,12 +1635,16 @@ void wxPrintPreviewBase::SetZoom(int percent) return; m_currentZoom = percent; - - InvalidatePreviewBitmap(); + if (m_previewBitmap) + { + delete m_previewBitmap; + m_previewBitmap = NULL; + } if (m_previewCanvas) { AdjustScrollbars(m_previewCanvas); + RenderPage(m_currentPage); ((wxScrolledWindow *) m_previewCanvas)->Scroll(0, 0); m_previewCanvas->ClearBackground(); m_previewCanvas->Refresh(); @@ -2195,11 +1752,6 @@ bool wxPrintPreview::PaintPage(wxPreviewCanvas *canvas, wxDC& dc) return m_pimpl->PaintPage( canvas, dc ); } -bool wxPrintPreview::UpdatePageRendering() -{ - return m_pimpl->UpdatePageRendering(); -} - bool wxPrintPreview::DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc) { return m_pimpl->DrawBlankPage( canvas, dc ); @@ -2242,7 +1794,7 @@ int wxPrintPreview::GetMinPage() const bool wxPrintPreview::IsOk() const { - return m_pimpl->IsOk(); + return m_pimpl->Ok(); } void wxPrintPreview::SetOk(bool ok) @@ -2260,4 +1812,58 @@ void wxPrintPreview::DetermineScaling() m_pimpl->DetermineScaling(); } +//---------------------------------------------------------------------------- +// experimental backport of high-quality preview on Windows +//---------------------------------------------------------------------------- + +#if wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW +static bool RenderPageIntoBitmapHQ(wxPrintPreviewBase *preview, + RenderPageIntoDCFunc RenderPageIntoDC, + wxBitmap& bmp, int pageNum) +{ + // The preview, as implemented in wxPrintPreviewBase (and as used prior to + // wx3) is inexact: it uses screen DC, which has much lower resolution and + // has other properties different from printer DC, so the preview is not + // quite right. + // + // To make matters worse, if the application depends heavily on + // GetTextExtent() or does text layout itself, the output in preview and on + // paper can be very different. In particular, wxHtmlEasyPrinting is + // affected and the preview can be easily off by several pages. + // + // To fix this, we render the preview into high-resolution enhanced + // metafile with properties identical to the printer DC. This guarantees + // metrics correctness while still being fast. + + + // print the preview into a metafile: + wxPrinterDC printerDC(preview->GetPrintDialogData().GetPrintData()); + wxEnhMetaFileDC metaDC(printerDC, + wxEmptyString, + printerDC.GetSize().x, printerDC.GetSize().y); + + if ( !(preview->*RenderPageIntoDC)(metaDC, pageNum) ) + return false; + + wxEnhMetaFile *metafile = metaDC.Close(); + if ( !metafile ) + return false; + + // now render the metafile: + wxMemoryDC bmpDC; + bmpDC.SelectObject(bmp); + bmpDC.Clear(); + + wxRect outRect(0, 0, bmp.GetWidth(), bmp.GetHeight()); + metafile->Play(&bmpDC, &outRect); + + + delete metafile; + + // TODO: we should keep the metafile and reuse it when changing zoom level + + return true; +} +#endif // wxUSE_HIGH_QUALITY_PREVIEW_IN_WXMSW + #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/Source/3rd Party/wx/src/common/process.cpp b/Source/3rd Party/wx/src/common/process.cpp index 6dd44d891..9e8681ad2 100644 --- a/Source/3rd Party/wx/src/common/process.cpp +++ b/Source/3rd Party/wx/src/common/process.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/process.cpp +// Name: process.cpp // Purpose: Process termination classes // Author: Guilhem Lavaux // Modified by: Vadim Zeitlin to check error codes, added Detach() method // Created: 24/06/98 +// RCS-ID: $Id: process.cpp 42702 2006-10-30 09:03:18Z JS $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ // event tables and such // ---------------------------------------------------------------------------- -wxDEFINE_EVENT( wxEVT_END_PROCESS, wxProcessEvent ); +DEFINE_EVENT_TYPE(wxEVT_END_PROCESS) IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent) @@ -49,7 +50,6 @@ void wxProcess::Init(wxEvtHandler *parent, int id, int flags) m_id = id; m_pid = 0; - m_priority = wxPRIORITY_DEFAULT; m_redirect = (flags & wxPROCESS_REDIRECT) != 0; #if wxUSE_STREAMS @@ -102,13 +102,7 @@ void wxProcess::OnTerminate(int pid, int status) void wxProcess::Detach() { - // we just detach from the next handler of the chain (i.e. our "parent" -- see ctor) - // not also from the previous handler like wxEvtHandler::Unlink() would do: - - if (m_nextHandler) - m_nextHandler->SetPreviousHandler(m_previousHandler); - - m_nextHandler = NULL; + SetNextHandler(NULL); } // ---------------------------------------------------------------------------- @@ -168,7 +162,7 @@ bool wxProcess::Exists(int pid) default: case wxKILL_ERROR: case wxKILL_BAD_SIGNAL: - wxFAIL_MSG( wxT("unexpected wxProcess::Kill() return code") ); + wxFAIL_MSG( _T("unexpected wxProcess::Kill() return code") ); // fall through case wxKILL_NO_PROCESS: @@ -176,10 +170,3 @@ bool wxProcess::Exists(int pid) } } -void wxProcess::SetPriority(unsigned priority) -{ - wxCHECK_RET( priority <= wxPRIORITY_MAX, - wxS("Invalid process priority value.") ); - - m_priority = priority; -} diff --git a/Source/3rd Party/wx/src/common/protocol.cpp b/Source/3rd Party/wx/src/common/protocol.cpp deleted file mode 100644 index 74662adb8..000000000 --- a/Source/3rd Party/wx/src/common/protocol.cpp +++ /dev/null @@ -1,218 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/protocol.cpp -// Purpose: Implement protocol base class -// Author: Guilhem Lavaux -// Modified by: -// Created: 07/07/1997 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_PROTOCOL - -#include "wx/protocol/protocol.h" -#include "wx/protocol/log.h" - -#ifndef WX_PRECOMP - #include "wx/module.h" -#endif - -#include "wx/url.h" -#include "wx/log.h" - -#include - -// ---------------------------------------------------------------------------- -// wxProtoInfo -// ---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxProtoInfo, wxObject) - -wxProtoInfo::wxProtoInfo(const wxChar *name, const wxChar *serv, - const bool need_host1, wxClassInfo *info) - : m_protoname(name), - m_servname(serv) -{ - m_cinfo = info; - m_needhost = need_host1; -#if wxUSE_URL - next = wxURL::ms_protocols; - wxURL::ms_protocols = this; -#else - next = NULL; -#endif -} - - -// ---------------------------------------------------------------------------- -// wxProtocol -// ---------------------------------------------------------------------------- - -#if wxUSE_SOCKETS -IMPLEMENT_ABSTRACT_CLASS(wxProtocol, wxSocketClient) -#else -IMPLEMENT_ABSTRACT_CLASS(wxProtocol, wxObject) -#endif - -wxProtocol::wxProtocol() -#if wxUSE_SOCKETS - : wxSocketClient() -#endif -{ - m_lastError = wxPROTO_NOERR; - m_log = NULL; - SetDefaultTimeout(60); // default timeout is 60 seconds -} - -void wxProtocol::SetDefaultTimeout(wxUint32 Value) -{ - m_uiDefaultTimeout = Value; -#if wxUSE_SOCKETS - wxSocketBase::SetTimeout(Value); // sets it for this socket -#endif -} - -wxProtocol::~wxProtocol() -{ - delete m_log; -} - -#if wxUSE_SOCKETS -bool wxProtocol::Reconnect() -{ - wxIPV4address addr; - - if (!GetPeer(addr)) - { - Close(); - return false; - } - - if (!Close()) - return false; - - if (!Connect(addr)) - return false; - - return true; -} - -// ---------------------------------------------------------------------------- -// Read a line from socket -// ---------------------------------------------------------------------------- - -/* static */ -wxProtocolError wxProtocol::ReadLine(wxSocketBase *sock, wxString& result) -{ - static const int LINE_BUF = 4095; - - result.clear(); - - wxCharBuffer buf(LINE_BUF); - char *pBuf = buf.data(); - while ( sock->WaitForRead() ) - { - // peek at the socket to see if there is a CRLF - sock->Peek(pBuf, LINE_BUF); - - size_t nRead = sock->LastCount(); - if ( !nRead && sock->Error() ) - return wxPROTO_NETERR; - - // look for "\r\n" paying attention to a special case: "\r\n" could - // have been split by buffer boundary, so check also for \r at the end - // of the last chunk and \n at the beginning of this one - pBuf[nRead] = '\0'; - const char *eol = strchr(pBuf, '\n'); - - // if we found '\n', is there a '\r' as well? - if ( eol ) - { - if ( eol == pBuf ) - { - // check for case of "\r\n" being split - if ( result.empty() || result.Last() != wxT('\r') ) - { - // ignore the stray '\n' - eol = NULL; - } - //else: ok, got real EOL - - // read just this '\n' and restart - nRead = 1; - } - else // '\n' in the middle of the buffer - { - // in any case, read everything up to and including '\n' - nRead = eol - pBuf + 1; - - if ( eol[-1] != '\r' ) - { - // as above, simply ignore stray '\n' - eol = NULL; - } - } - } - - sock->Read(pBuf, nRead); - if ( sock->LastCount() != nRead ) - return wxPROTO_NETERR; - - pBuf[nRead] = '\0'; - result += wxString::FromAscii(pBuf); - - if ( eol ) - { - // remove trailing "\r\n" - result.RemoveLast(2); - - return wxPROTO_NOERR; - } - } - - return wxPROTO_NETERR; -} - -wxProtocolError wxProtocol::ReadLine(wxString& result) -{ - return ReadLine(this, result); -} - -#endif // wxUSE_SOCKETS - -// ---------------------------------------------------------------------------- -// logging -// ---------------------------------------------------------------------------- - -void wxProtocol::SetLog(wxProtocolLog *log) -{ - delete m_log; - m_log = log; -} - -void wxProtocol::LogRequest(const wxString& str) -{ - if ( m_log ) - m_log->LogRequest(str); -} - -void wxProtocol::LogResponse(const wxString& str) -{ - if ( m_log ) - m_log->LogResponse(str); -} - -void wxProtocolLog::DoLogString(const wxString& str) -{ - wxUnusedVar(str); // unused if wxLogTrace() is disabled - wxLogTrace(m_traceMask, "%s", str); -} - -#endif // wxUSE_PROTOCOL diff --git a/Source/3rd Party/wx/src/common/quantize.cpp b/Source/3rd Party/wx/src/common/quantize.cpp index 4d96d1b92..7ffa7b19a 100644 --- a/Source/3rd Party/wx/src/common/quantize.cpp +++ b/Source/3rd Party/wx/src/common/quantize.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 22/6/2000 +// RCS-ID: $Id: quantize.cpp 39957 2006-07-03 19:02:54Z ABX $ // Copyright: (c) Thomas G. Lane, Vaclav Slavik, Julian Smart // Licence: wxWindows licence + JPEG library licence ///////////////////////////////////////////////////////////////////////////// @@ -337,9 +338,9 @@ prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, JSAMPARRAY WXUNUSED(output_buf), int num_rows) { my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW ptr; - histptr histp; - hist3d histogram = cquantize->histogram; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; int row; JDIMENSION col; JDIMENSION width = cinfo->output_width; @@ -390,9 +391,9 @@ find_biggest_color_pop (boxptr boxlist, int numboxes) /* Find the splittable box with the largest color population */ /* Returns NULL if no splittable boxes remain */ { - boxptr boxp; - int i; - long maxc = 0; + register boxptr boxp; + register int i; + register long maxc = 0; boxptr which = NULL; for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { @@ -410,9 +411,9 @@ find_biggest_volume (boxptr boxlist, int numboxes) /* Find the splittable box with the largest (scaled) volume */ /* Returns NULL if no splittable boxes remain */ { - boxptr boxp; - int i; - INT32 maxv = 0; + register boxptr boxp; + register int i; + register INT32 maxv = 0; boxptr which = NULL; for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { @@ -543,7 +544,7 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, { int n,lb; int c0,c1,c2,cmax; - boxptr b1,b2; + register boxptr b1,b2; while (numboxes < desired_colors) { /* Select box to split. @@ -915,12 +916,12 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, { int ic0, ic1, ic2; int i, icolor; - INT32 * bptr; /* pointer into bestdist[] array */ + register INT32 * bptr; /* pointer into bestdist[] array */ JSAMPLE * cptr; /* pointer into bestcolor[] array */ INT32 dist0, dist1; /* initial distance values */ - INT32 dist2; /* current distance in inner loop */ + register INT32 dist2; /* current distance in inner loop */ INT32 xx0, xx1; /* distance increments */ - INT32 xx2; + register INT32 xx2; INT32 inc0, inc1, inc2; /* initial values for increments */ /* This array holds the distance to the nearest-so-far color for each cell */ INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; @@ -993,8 +994,8 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) hist3d histogram = cquantize->histogram; int minc0, minc1, minc2; /* lower left corner of update box */ int ic0, ic1, ic2; - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - histptr cachep; /* pointer into main cache array */ + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ /* This array lists the candidate colormap indexes. */ JSAMPLE colorlist[MAXNUMCOLORS]; int numcolors; /* number of candidate colors */ @@ -1050,9 +1051,9 @@ pass2_no_dither (j_decompress_ptr cinfo, { my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; hist3d histogram = cquantize->histogram; - JSAMPROW inptr, outptr; - histptr cachep; - int c0, c1, c2; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; int row; JDIMENSION col; JDIMENSION width = cinfo->output_width; @@ -1084,10 +1085,10 @@ pass2_fs_dither (j_decompress_ptr cinfo, { my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; hist3d histogram = cquantize->histogram; - LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - FSERRPTR errorptr; /* => fserrors[] at column before current */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ JSAMPROW inptr; /* => current input pixel */ JSAMPROW outptr; /* => current output pixel */ histptr cachep; @@ -1162,7 +1163,7 @@ pass2_fs_dither (j_decompress_ptr cinfo, if (*cachep == 0) fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); /* Now emit the colormap index for this cell */ - { int pixcode = *cachep - 1; + { register int pixcode = *cachep - 1; *outptr = (JSAMPLE) pixcode; /* Compute representation error for this pixel */ cur0 -= GETJSAMPLE(colormap0[pixcode]); @@ -1173,7 +1174,7 @@ pass2_fs_dither (j_decompress_ptr cinfo, * Add these into the running sums, and simultaneously shift the * next-line error sums left by 1 column. */ - { LOCFSERROR bnexterr, delta; + { register LOCFSERROR bnexterr, delta; bnexterr = cur0; /* Process component 0 */ delta = cur0 * 2; @@ -1545,7 +1546,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, if (flags & wxQUANTIZE_FILL_DESTINATION_IMAGE) { - if (!dest.IsOk()) + if (!dest.Ok()) dest.Create(w, h); imgdt = dest.GetData(); @@ -1620,9 +1621,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, delete[] g; delete[] b; } -#else // !wxUSE_PALETTE - wxUnusedVar(pPalette); -#endif // wxUSE_PALETTE/!wxUSE_PALETTE +#endif // wxUSE_PALETTE return true; } diff --git a/Source/3rd Party/wx/src/common/radiobtncmn.cpp b/Source/3rd Party/wx/src/common/radiobtncmn.cpp deleted file mode 100644 index 5fe82fe1c..000000000 --- a/Source/3rd Party/wx/src/common/radiobtncmn.cpp +++ /dev/null @@ -1,95 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/radiobtncmn.cpp -// Purpose: wxRadioButton common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_RADIOBTN - -#include "wx/radiobut.h" - -#ifndef WX_PRECOMP - #include "wx/settings.h" - #include "wx/dcscreen.h" -#endif - -extern WXDLLEXPORT_DATA(const char) wxRadioButtonNameStr[] = "radioButton"; -extern WXDLLEXPORT_DATA(const char) wxBitmapRadioButtonNameStr[] = "radioButton"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxRadioButtonStyle ) -wxBEGIN_FLAGS( wxRadioButtonStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxRB_GROUP) -wxEND_FLAGS( wxRadioButtonStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton, wxControl, "wx/radiobut.h") - -wxBEGIN_PROPERTIES_TABLE(wxRadioButton) - wxEVENT_PROPERTY( Click, wxEVT_RADIOBUTTON, wxCommandEvent ) - wxPROPERTY( Font, wxFont, SetFont, GetFont , wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString(), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group") ) - wxPROPERTY( Value,bool, SetValue, GetValue, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group") ) - wxPROPERTY_FLAGS( WindowStyle, wxRadioButtonStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxRadioButton) - -wxCONSTRUCTOR_6( wxRadioButton, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Label, wxPoint, Position, wxSize, Size, long, WindowStyle ) - - -#endif // wxUSE_RADIOBTN diff --git a/Source/3rd Party/wx/src/common/radiocmn.cpp b/Source/3rd Party/wx/src/common/radiocmn.cpp index 5d69bf595..418d4f04f 100644 --- a/Source/3rd Party/wx/src/common/radiocmn.cpp +++ b/Source/3rd Party/wx/src/common/radiocmn.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.06.01 +// RCS-ID: $Id: radiocmn.cpp 54930 2008-08-02 19:45:23Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -37,80 +38,13 @@ #include "wx/cshelp.h" #endif -extern WXDLLEXPORT_DATA(const char) wxRadioBoxNameStr[] = "radioBox"; - // ============================================================================ // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -// TODO: wxCONSTRUCTOR -#if 0 // wxUSE_EXTENDED_RTTI -wxDEFINE_FLAGS( wxRadioBoxStyle ) - -wxBEGIN_FLAGS( wxRadioBoxStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxRA_SPECIFY_COLS) -wxFLAGS_MEMBER(wxRA_HORIZONTAL) -wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS) -wxFLAGS_MEMBER(wxRA_VERTICAL) - -wxEND_FLAGS( wxRadioBoxStyle ) - -IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox, wxControl,"wx/radiobox.h") - -wxBEGIN_PROPERTIES_TABLE(wxRadioBox) -wxEVENT_PROPERTY( Select , wxEVT_RADIOBOX , wxCommandEvent ) -wxPROPERTY_FLAGS( WindowStyle , wxRadioBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -/* - selection - content - label - dimension - item - */ - -#endif - - -// ---------------------------------------------------------------------------- -// wxRadioBoxBase -// ---------------------------------------------------------------------------- - void wxRadioBoxBase::SetMajorDim(unsigned int majorDim, long style) { - wxCHECK_RET( majorDim != 0, wxT("major radiobox dimension can't be 0") ); + wxCHECK_RET( majorDim != 0, _T("major radiobox dimension can't be 0") ); m_majorDim = majorDim; @@ -191,7 +125,7 @@ int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const break; default: - wxFAIL_MSG( wxT("unexpected wxDirection value") ); + wxFAIL_MSG( _T("unexpected wxDirection value") ); return wxNOT_FOUND; } @@ -224,7 +158,7 @@ int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const } wxASSERT_MSG( item < count && item >= 0, - wxT("logic error in wxRadioBox::GetNextItem()") ); + _T("logic error in wxRadioBox::GetNextItem()") ); } // we shouldn't select the non-active items, continue looking for a // visible and shown one unless we came back to the item we started from in @@ -238,7 +172,7 @@ int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const void wxRadioBoxBase::SetItemToolTip(unsigned int item, const wxString& text) { - wxASSERT_MSG( item < GetCount(), wxT("Invalid item index") ); + wxASSERT_MSG( item < GetCount(), _T("Invalid item index") ); // extend the array to have entries for all our items on first use if ( !m_itemsTooltips ) @@ -255,7 +189,8 @@ void wxRadioBoxBase::SetItemToolTip(unsigned int item, const wxString& text) if ( tooltip ) { // delete the tooltip - wxDELETE(tooltip); + delete tooltip; + tooltip = NULL; } else // nothing to do { @@ -312,7 +247,7 @@ wxRadioBoxBase::~wxRadioBoxBase() // set helptext for a particular item void wxRadioBoxBase::SetItemHelpText(unsigned int n, const wxString& helpText) { - wxCHECK_RET( n < GetCount(), wxT("Invalid item index") ); + wxCHECK_RET( n < GetCount(), _T("Invalid item index") ); if ( m_itemsHelpTexts.empty() ) { @@ -326,7 +261,7 @@ void wxRadioBoxBase::SetItemHelpText(unsigned int n, const wxString& helpText) // retrieve helptext for a particular item wxString wxRadioBoxBase::GetItemHelpText( unsigned int n ) const { - wxCHECK_MSG( n < GetCount(), wxEmptyString, wxT("Invalid item index") ); + wxCHECK_MSG( n < GetCount(), wxEmptyString, _T("Invalid item index") ); return m_itemsHelpTexts.empty() ? wxString() : m_itemsHelpTexts[n]; } @@ -336,30 +271,13 @@ wxString wxRadioBoxBase::DoGetHelpTextAtPoint(const wxWindow *derived, const wxPoint& pt, wxHelpEvent::Origin origin) const { - int item; - switch ( origin ) - { - case wxHelpEvent::Origin_HelpButton: - item = GetItemFromPoint(pt); - break; - - case wxHelpEvent::Origin_Keyboard: - item = GetSelection(); - break; - - default: - wxFAIL_MSG( "unknown help even origin" ); - // fall through - - case wxHelpEvent::Origin_Unknown: - // this value is used when we're called from GetHelpText() for the - // radio box itself, so don't return item-specific text in this case - item = wxNOT_FOUND; - } + const int item = origin == wxHelpEvent::Origin_HelpButton + ? GetItemFromPoint(pt) + : GetSelection(); if ( item != wxNOT_FOUND ) { - wxString text = GetItemHelpText(static_cast(item)); + wxString text = GetItemHelpText(wx_static_cast(unsigned int, item)); if( !text.empty() ) return text; } @@ -369,4 +287,18 @@ wxString wxRadioBoxBase::DoGetHelpTextAtPoint(const wxWindow *derived, #endif // wxUSE_HELP +#if WXWIN_COMPATIBILITY_2_4 + +// these functions are deprecated and don't do anything +int wxRadioBoxBase::GetNumberOfRowsOrCols() const +{ + return 1; +} + +void wxRadioBoxBase::SetNumberOfRowsOrCols(int WXUNUSED(n)) +{ +} + +#endif // WXWIN_COMPATIBILITY_2_4 + #endif // wxUSE_RADIOBOX diff --git a/Source/3rd Party/wx/src/common/rearrangectrl.cpp b/Source/3rd Party/wx/src/common/rearrangectrl.cpp deleted file mode 100644 index a6865f903..000000000 --- a/Source/3rd Party/wx/src/common/rearrangectrl.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/rearrangectrl.cpp -// Purpose: implementation of classes in wx/rearrangectrl.h -// Author: Vadim Zeitlin -// Created: 2008-12-15 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_REARRANGECTRL - -#ifndef WX_PRECOMP - #include "wx/button.h" - #include "wx/stattext.h" - #include "wx/sizer.h" -#endif // WX_PRECOMP - -#include "wx/rearrangectrl.h" - -// ============================================================================ -// wxRearrangeList implementation -// ============================================================================ - -extern -WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeListNameStr[] = "wxRearrangeList"; - -BEGIN_EVENT_TABLE(wxRearrangeList, wxCheckListBox) - EVT_CHECKLISTBOX(wxID_ANY, wxRearrangeList::OnCheck) -END_EVENT_TABLE() - -bool wxRearrangeList::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style, - const wxValidator& validator, - const wxString& name) -{ - // construct the array of items in the order in which they should appear in - // the control - const size_t count = items.size(); - wxCHECK_MSG( order.size() == count, false, "arrays not in sync" ); - - wxArrayString itemsInOrder; - itemsInOrder.reserve(count); - size_t n; - for ( n = 0; n < count; n++ ) - { - int idx = order[n]; - if ( idx < 0 ) - idx = -idx - 1; - itemsInOrder.push_back(items[idx]); - } - - // do create the real control - if ( !wxCheckListBox::Create(parent, id, pos, size, itemsInOrder, - style, validator, name) ) - return false; - - // and now check all the items which should be initially checked - for ( n = 0; n < count; n++ ) - { - if ( order[n] >= 0 ) - Check(n); - } - - m_order = order; - - return true; -} - -bool wxRearrangeList::CanMoveCurrentUp() const -{ - const int sel = GetSelection(); - return sel != wxNOT_FOUND && sel != 0; -} - -bool wxRearrangeList::CanMoveCurrentDown() const -{ - const int sel = GetSelection(); - return sel != wxNOT_FOUND && static_cast(sel) != GetCount() - 1; -} - -bool wxRearrangeList::MoveCurrentUp() -{ - const int sel = GetSelection(); - if ( sel == wxNOT_FOUND || sel == 0 ) - return false; - - Swap(sel, sel - 1); - SetSelection(sel - 1); - - return true; -} - -bool wxRearrangeList::MoveCurrentDown() -{ - const int sel = GetSelection(); - if ( sel == wxNOT_FOUND || static_cast(sel) == GetCount() - 1 ) - return false; - - Swap(sel, sel + 1); - SetSelection(sel + 1); - - return true; -} - -void wxRearrangeList::Swap(int pos1, int pos2) -{ - // update the internally stored order - wxSwap(m_order[pos1], m_order[pos2]); - - - // and now also swap all the attributes of the items - - // first the label - const wxString stringTmp = GetString(pos1); - SetString(pos1, GetString(pos2)); - SetString(pos2, stringTmp); - - // then the checked state - const bool checkedTmp = IsChecked(pos1); - Check(pos1, IsChecked(pos2)); - Check(pos2, checkedTmp); - - // and finally the client data, if necessary - switch ( GetClientDataType() ) - { - case wxClientData_None: - // nothing to do - break; - - case wxClientData_Object: - { - wxClientData * const dataTmp = DetachClientObject(pos1); - SetClientObject(pos1, DetachClientObject(pos2)); - SetClientObject(pos2, dataTmp); - } - break; - - case wxClientData_Void: - { - void * const dataTmp = GetClientData(pos1); - SetClientData(pos1, GetClientData(pos2)); - SetClientData(pos2, dataTmp); - } - break; - } -} - -void wxRearrangeList::OnCheck(wxCommandEvent& event) -{ - // update the internal state to match the new item state - const int n = event.GetInt(); - - m_order[n] = ~m_order[n]; - - wxASSERT_MSG( (m_order[n] >= 0) == IsChecked(n), - "discrepancy between internal state and GUI" ); -} - -// ============================================================================ -// wxRearrangeCtrl implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxRearrangeCtrl, wxPanel) - EVT_UPDATE_UI(wxID_UP, wxRearrangeCtrl::OnUpdateButtonUI) - EVT_UPDATE_UI(wxID_DOWN, wxRearrangeCtrl::OnUpdateButtonUI) - - EVT_BUTTON(wxID_UP, wxRearrangeCtrl::OnButton) - EVT_BUTTON(wxID_DOWN, wxRearrangeCtrl::OnButton) -END_EVENT_TABLE() - -void wxRearrangeCtrl::Init() -{ - m_list = NULL; -} - -bool -wxRearrangeCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayInt& order, - const wxArrayString& items, - long style, - const wxValidator& validator, - const wxString& name) -{ - // create all the windows - if ( !wxPanel::Create(parent, id, pos, size, wxTAB_TRAVERSAL, name) ) - return false; - - m_list = new wxRearrangeList(this, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - order, items, - style, validator); - wxButton * const btnUp = new wxButton(this, wxID_UP); - wxButton * const btnDown = new wxButton(this, wxID_DOWN); - - // arrange them in a sizer - wxSizer * const sizerBtns = new wxBoxSizer(wxVERTICAL); - sizerBtns->Add(btnUp, wxSizerFlags().Centre().Border(wxBOTTOM)); - sizerBtns->Add(btnDown, wxSizerFlags().Centre().Border(wxTOP)); - - wxSizer * const sizerTop = new wxBoxSizer(wxHORIZONTAL); - sizerTop->Add(m_list, wxSizerFlags(1).Expand().Border(wxRIGHT)); - sizerTop->Add(sizerBtns, wxSizerFlags(0).Centre().Border(wxLEFT)); - SetSizer(sizerTop); - - m_list->SetFocus(); - - return true; -} - -void wxRearrangeCtrl::OnUpdateButtonUI(wxUpdateUIEvent& event) -{ - event.Enable( event.GetId() == wxID_UP ? m_list->CanMoveCurrentUp() - : m_list->CanMoveCurrentDown() ); -} - -void wxRearrangeCtrl::OnButton(wxCommandEvent& event) -{ - if ( event.GetId() == wxID_UP ) - m_list->MoveCurrentUp(); - else - m_list->MoveCurrentDown(); -} - -// ============================================================================ -// wxRearrangeDialog implementation -// ============================================================================ - -extern -WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeDialogNameStr[] = "wxRearrangeDlg"; - -namespace -{ - -enum wxRearrangeDialogSizerPositions -{ - Pos_Label, - Pos_Ctrl, - Pos_Buttons, - Pos_Max -}; - -} // anonymous namespace - -bool wxRearrangeDialog::Create(wxWindow *parent, - const wxString& message, - const wxString& title, - const wxArrayInt& order, - const wxArrayString& items, - const wxPoint& pos, - const wxString& name) -{ - if ( !wxDialog::Create(parent, wxID_ANY, title, - pos, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, - name) ) - return false; - - m_ctrl = new wxRearrangeCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - order, items); - - // notice that the items in this sizer should be inserted accordingly to - // wxRearrangeDialogSizerPositions order - wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL); - - if ( !message.empty() ) - { - sizerTop->Add(new wxStaticText(this, wxID_ANY, message), - wxSizerFlags().Border()); - } - else - { - // for convenience of other wxRearrangeDialog code that depends on - // positions of sizer items, insert a dummy zero-sized item - sizerTop->AddSpacer(0); - } - - sizerTop->Add(m_ctrl, - wxSizerFlags(1).Expand().Border()); - sizerTop->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL), - wxSizerFlags().Expand().Border()); - SetSizerAndFit(sizerTop); - - return true; -} - -void wxRearrangeDialog::AddExtraControls(wxWindow *win) -{ - wxSizer * const sizer = GetSizer(); - wxCHECK_RET( sizer, "the dialog must be created first" ); - - wxASSERT_MSG( sizer->GetChildren().GetCount() == Pos_Max, - "calling AddExtraControls() twice?" ); - - sizer->Insert(Pos_Buttons, win, wxSizerFlags().Expand().Border()); - - win->MoveAfterInTabOrder(m_ctrl); - - // we need to update the initial/minimal window size - sizer->SetSizeHints(this); -} - -wxRearrangeList *wxRearrangeDialog::GetList() const -{ - wxCHECK_MSG( m_ctrl, NULL, "the dialog must be created first" ); - - return m_ctrl->GetList(); -} - -wxArrayInt wxRearrangeDialog::GetOrder() const -{ - wxCHECK_MSG( m_ctrl, wxArrayInt(), "the dialog must be created first" ); - - return m_ctrl->GetList()->GetCurrentOrder(); -} - -#endif // wxUSE_REARRANGECTRL diff --git a/Source/3rd Party/wx/src/common/regex.cpp b/Source/3rd Party/wx/src/common/regex.cpp index a93ca08bf..bd77aafe2 100644 --- a/Source/3rd Party/wx/src/common/regex.cpp +++ b/Source/3rd Party/wx/src/common/regex.cpp @@ -4,6 +4,7 @@ // Author: Karsten Ballueder and Vadim Zeitlin // Modified by: // Created: 13.07.01 +// RCS-ID: $Id: regex.cpp 57779 2009-01-02 17:35:16Z PC $ // Copyright: (c) 2000 Karsten Ballueder // 2001 Vadim Zeitlin // Licence: wxWindows licence @@ -32,7 +33,6 @@ #include "wx/object.h" #include "wx/log.h" #include "wx/intl.h" - #include "wx/crt.h" #endif //WX_PRECOMP // FreeBSD, Watcom and DMars require this, CW doesn't have nor need it. @@ -56,11 +56,7 @@ #ifdef __REG_NOFRONT # define WXREGEX_USING_BUILTIN # define WXREGEX_IF_NEED_LEN(x) ,x -# if wxUSE_UNICODE -# define WXREGEX_CHAR(x) (x).wc_str() -# else -# define WXREGEX_CHAR(x) (x).mb_str() -# endif +# define WXREGEX_CHAR(x) x #else # ifdef HAVE_RE_SEARCH # define WXREGEX_IF_NEED_LEN(x) ,x @@ -71,7 +67,7 @@ # if wxUSE_UNICODE # define WXREGEX_CONVERT_TO_MB # endif -# define WXREGEX_CHAR(x) (x).mb_str() +# define WXREGEX_CHAR(x) wxConvertWX2MB(x) # define wx_regfree regfree # define wx_regerror regerror #endif @@ -253,7 +249,7 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode, bool badconv) const (void)wx_regerror(errorcode, &m_RegEx, szcmbError, len); - szError = wxConvLibc.cMB2WX(szcmbError); + szError = wxConvertMB2WX(szcmbError); delete [] szcmbError; } else // regerror() returned 0 @@ -273,10 +269,10 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags) #else # define FLAVORS (wxRE_ADVANCED | wxRE_BASIC) wxASSERT_MSG( (flags & FLAVORS) != FLAVORS, - wxT("incompatible flags in wxRegEx::Compile") ); + _T("incompatible flags in wxRegEx::Compile") ); #endif wxASSERT_MSG( !(flags & ~(FLAVORS | wxRE_ICASE | wxRE_NOSUB | wxRE_NEWLINE)), - wxT("unrecognized flags in wxRegEx::Compile") ); + _T("unrecognized flags in wxRegEx::Compile") ); // translate our flags to regcomp() ones int flagsRE = 0; @@ -289,6 +285,7 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags) #endif flagsRE |= REG_EXTENDED; } + if ( flags & wxRE_ICASE ) flagsRE |= REG_ICASE; if ( flags & wxRE_NOSUB ) @@ -299,11 +296,8 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags) // compile it #ifdef WXREGEX_USING_BUILTIN bool conv = true; - // FIXME-UTF8: use wc_str() after removing ANSI build - int errorcode = wx_re_comp(&m_RegEx, expr.c_str(), expr.length(), flagsRE); + int errorcode = wx_re_comp(&m_RegEx, expr, expr.length(), flagsRE); #else - // FIXME-UTF8: this is potentially broken, we shouldn't even try it - // and should always use builtin regex library (or PCRE?) const wxWX2MBbuf conv = expr.mbc_str(); int errorcode = conv ? regcomp(&m_RegEx, conv, flagsRE) : REG_BADPAT; #endif @@ -334,15 +328,15 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags) // and some more for bracketed subexperessions for ( const wxChar *cptr = expr.c_str(); *cptr; cptr++ ) { - if ( *cptr == wxT('\\') ) + if ( *cptr == _T('\\') ) { // in basic RE syntax groups are inside \(...\) - if ( *++cptr == wxT('(') && (flags & wxRE_BASIC) ) + if ( *++cptr == _T('(') && (flags & wxRE_BASIC) ) { m_nMatches++; } } - else if ( *cptr == wxT('(') && !(flags & wxRE_BASIC) ) + else if ( *cptr == _T('(') && !(flags & wxRE_BASIC) ) { // we know that the previous character is not an unquoted // backslash because it would have been eaten above, so we @@ -350,7 +344,7 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags) // extended syntax. '(?' is used for extensions by perl- // like REs (e.g. advanced), and is not valid for POSIX // extended, so ignore them always. - if ( cptr[1] != wxT('?') ) + if ( cptr[1] != _T('?') ) m_nMatches++; } } @@ -377,7 +371,7 @@ static int ReSearch(const regex_t *preg, re_registers *matches, int eflags) { - regex_t *pattern = const_cast(preg); + regex_t *pattern = wx_const_cast(regex_t*, preg); pattern->not_bol = (eflags & REG_NOTBOL) != 0; pattern->not_eol = (eflags & REG_NOTEOL) != 0; @@ -393,11 +387,11 @@ bool wxRegExImpl::Matches(const wxRegChar *str, int flags WXREGEX_IF_NEED_LEN(size_t len)) const { - wxCHECK_MSG( IsValid(), false, wxT("must successfully Compile() first") ); + wxCHECK_MSG( IsValid(), false, _T("must successfully Compile() first") ); // translate our flags to regexec() ones wxASSERT_MSG( !(flags & ~(wxRE_NOTBOL | wxRE_NOTEOL)), - wxT("unrecognized flags in wxRegEx::Matches") ); + _T("unrecognized flags in wxRegEx::Matches") ); int flagsRE = 0; if ( flags & wxRE_NOTBOL ) @@ -443,10 +437,10 @@ bool wxRegExImpl::Matches(const wxRegChar *str, bool wxRegExImpl::GetMatch(size_t *start, size_t *len, size_t index) const { - wxCHECK_MSG( IsValid(), false, wxT("must successfully Compile() first") ); - wxCHECK_MSG( m_nMatches, false, wxT("can't use with wxRE_NOSUB") ); - wxCHECK_MSG( m_Matches, false, wxT("must call Matches() first") ); - wxCHECK_MSG( index < m_nMatches, false, wxT("invalid match index") ); + wxCHECK_MSG( IsValid(), false, _T("must successfully Compile() first") ); + wxCHECK_MSG( m_nMatches, false, _T("can't use with wxRE_NOSUB") ); + wxCHECK_MSG( m_Matches, false, _T("must call Matches() first") ); + wxCHECK_MSG( index < m_nMatches, false, _T("invalid match index") ); if ( start ) *start = m_Matches->Start(index); @@ -458,8 +452,8 @@ bool wxRegExImpl::GetMatch(size_t *start, size_t *len, size_t index) const size_t wxRegExImpl::GetMatchCount() const { - wxCHECK_MSG( IsValid(), 0, wxT("must successfully Compile() first") ); - wxCHECK_MSG( m_nMatches, 0, wxT("can't use with wxRE_NOSUB") ); + wxCHECK_MSG( IsValid(), 0, _T("must successfully Compile() first") ); + wxCHECK_MSG( m_nMatches, 0, _T("can't use with wxRE_NOSUB") ); return m_nMatches; } @@ -468,8 +462,8 @@ int wxRegExImpl::Replace(wxString *text, const wxString& replacement, size_t maxMatches) const { - wxCHECK_MSG( text, wxNOT_FOUND, wxT("NULL text in wxRegEx::Replace") ); - wxCHECK_MSG( IsValid(), wxNOT_FOUND, wxT("must successfully Compile() first") ); + wxCHECK_MSG( text, wxNOT_FOUND, _T("NULL text in wxRegEx::Replace") ); + wxCHECK_MSG( IsValid(), wxNOT_FOUND, _T("must successfully Compile() first") ); // the input string #ifndef WXREGEX_CONVERT_TO_MB @@ -497,7 +491,7 @@ int wxRegExImpl::Replace(wxString *text, // attempt at optimization: don't iterate over the string if it doesn't // contain back references at all bool mayHaveBackrefs = - replacement.find_first_of(wxT("\\&")) != wxString::npos; + replacement.find_first_of(_T("\\&")) != wxString::npos; if ( !mayHaveBackrefs ) { @@ -514,12 +508,7 @@ int wxRegExImpl::Replace(wxString *text, // note that "^" shouldn't match after the first call to Matches() so we // use wxRE_NOTBOL to prevent it from happening while ( (!maxMatches || countRepl < maxMatches) && - Matches( -#ifndef WXREGEX_CONVERT_TO_MB - textstr + matchStart, -#else - textstr.data() + matchStart, -#endif + Matches(textstr + matchStart, countRepl ? wxRE_NOTBOL : 0 WXREGEX_IF_NEED_LEN(textlen - matchStart)) ) { @@ -535,7 +524,7 @@ int wxRegExImpl::Replace(wxString *text, { size_t index = (size_t)-1; - if ( *p == wxT('\\') ) + if ( *p == _T('\\') ) { if ( wxIsdigit(*++p) ) { @@ -546,7 +535,7 @@ int wxRegExImpl::Replace(wxString *text, } //else: backslash used as escape character } - else if ( *p == wxT('&') ) + else if ( *p == _T('&') ) { // treat this as "\0" for compatbility with ed and such index = 0; @@ -559,20 +548,14 @@ int wxRegExImpl::Replace(wxString *text, size_t start, len; if ( !GetMatch(&start, &len, index) ) { - wxFAIL_MSG( wxT("invalid back reference") ); + wxFAIL_MSG( _T("invalid back reference") ); // just eat it... } else { - textNew += wxString( -#ifndef WXREGEX_CONVERT_TO_MB - textstr -#else - textstr.data() -#endif - + matchStart + start, - *wxConvCurrent, len); + textNew += wxString(textstr + matchStart + start, + *wxConvCurrent, len); mayHaveBackrefs = true; } @@ -588,7 +571,7 @@ int wxRegExImpl::Replace(wxString *text, if ( !GetMatch(&start, &len) ) { // we did have match as Matches() returned true above! - wxFAIL_MSG( wxT("internal logic error in wxRegEx::Replace") ); + wxFAIL_MSG( _T("internal logic error in wxRegEx::Replace") ); return wxNOT_FOUND; } @@ -601,7 +584,7 @@ int wxRegExImpl::Replace(wxString *text, #ifndef WXREGEX_CONVERT_TO_MB result.append(*text, matchStart, start); #else - result.append(wxString(textstr.data() + matchStart, *wxConvCurrent, start)); + result.append(wxString(textstr + matchStart, *wxConvCurrent, start)); #endif matchStart += start; result.append(textNew); @@ -614,7 +597,7 @@ int wxRegExImpl::Replace(wxString *text, #ifndef WXREGEX_CONVERT_TO_MB result.append(*text, matchStart, wxString::npos); #else - result.append(wxString(textstr.data() + matchStart, *wxConvCurrent)); + result.append(wxString(textstr + matchStart, *wxConvCurrent)); #endif *text = result; @@ -645,7 +628,8 @@ bool wxRegEx::Compile(const wxString& expr, int flags) if ( !m_impl->Compile(expr, flags) ) { // error message already given in wxRegExImpl::Compile - wxDELETE(m_impl); + delete m_impl; + m_impl = NULL; return false; } @@ -653,17 +637,26 @@ bool wxRegEx::Compile(const wxString& expr, int flags) return true; } -bool wxRegEx::Matches(const wxString& str, int flags) const +bool wxRegEx::Matches(const wxChar *str, int flags, size_t len) const { - wxCHECK_MSG( IsValid(), false, wxT("must successfully Compile() first") ); + wxCHECK_MSG( IsValid(), false, _T("must successfully Compile() first") ); + (void)len; - return m_impl->Matches(WXREGEX_CHAR(str), flags - WXREGEX_IF_NEED_LEN(str.length())); + return m_impl->Matches(WXREGEX_CHAR(str), flags WXREGEX_IF_NEED_LEN(len)); +} + +bool wxRegEx::Matches(const wxChar *str, int flags) const +{ + wxCHECK_MSG( IsValid(), false, _T("must successfully Compile() first") ); + + return m_impl->Matches(WXREGEX_CHAR(str), + flags + WXREGEX_IF_NEED_LEN(wxStrlen(str))); } bool wxRegEx::GetMatch(size_t *start, size_t *len, size_t index) const { - wxCHECK_MSG( IsValid(), false, wxT("must successfully Compile() first") ); + wxCHECK_MSG( IsValid(), false, _T("must successfully Compile() first") ); return m_impl->GetMatch(start, len, index); } @@ -679,7 +672,7 @@ wxString wxRegEx::GetMatch(const wxString& text, size_t index) const size_t wxRegEx::GetMatchCount() const { - wxCHECK_MSG( IsValid(), 0, wxT("must successfully Compile() first") ); + wxCHECK_MSG( IsValid(), 0, _T("must successfully Compile() first") ); return m_impl->GetMatchCount(); } @@ -688,7 +681,7 @@ int wxRegEx::Replace(wxString *pattern, const wxString& replacement, size_t maxMatches) const { - wxCHECK_MSG( IsValid(), wxNOT_FOUND, wxT("must successfully Compile() first") ); + wxCHECK_MSG( IsValid(), wxNOT_FOUND, _T("must successfully Compile() first") ); return m_impl->Replace(pattern, replacement, maxMatches); } diff --git a/Source/3rd Party/wx/src/common/rendcmn.cpp b/Source/3rd Party/wx/src/common/rendcmn.cpp index 455d2d5ac..702ffb4fa 100644 --- a/Source/3rd Party/wx/src/common/rendcmn.cpp +++ b/Source/3rd Party/wx/src/common/rendcmn.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 28.07.03 +// RCS-ID: $Id: rendcmn.cpp 41216 2006-09-14 16:04:18Z ABX $ // Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -31,7 +32,7 @@ #include "wx/apptrait.h" #include "wx/renderer.h" -#include "wx/scopedptr.h" +#include "wx/ptr_scpd.h" #if wxUSE_DYNLIB_CLASS #include "wx/dynlib.h" @@ -41,7 +42,8 @@ // wxRendererPtr: auto pointer holding the global renderer // ---------------------------------------------------------------------------- -typedef wxScopedPtr wxRendererPtrBase; +wxDECLARE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase) +wxDEFINE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase) class wxRendererPtr : public wxRendererPtrBase { @@ -81,7 +83,7 @@ private: // just to suppress a gcc warning friend class wxRendererPtrDummyFriend; - wxDECLARE_NO_COPY_CLASS(wxRendererPtr); + DECLARE_NO_COPY_CLASS(wxRendererPtr) }; // return the global and unique wxRendererPtr diff --git a/Source/3rd Party/wx/src/common/rgncmn.cpp b/Source/3rd Party/wx/src/common/rgncmn.cpp index 9c756c35d..0f9c8b216 100644 --- a/Source/3rd Party/wx/src/common/rgncmn.cpp +++ b/Source/3rd Party/wx/src/common/rgncmn.cpp @@ -4,6 +4,7 @@ // Author: Robin Dunn // Modified by: // Created: 27-Mar-2003 +// RCS-ID: $Id: rgncmn.cpp 41901 2006-10-10 17:33:49Z PC $ // Copyright: (c) Robin Dunn // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,7 +33,7 @@ // ============================================================================ // ---------------------------------------------------------------------------- -// region comparison +// region comparision // ---------------------------------------------------------------------------- bool wxRegionBase::IsEqual(const wxRegion& region) const @@ -59,12 +60,12 @@ bool wxRegionBase::IsEqual(const wxRegion& region) const wxBitmap wxRegionBase::ConvertToBitmap() const { wxRect box = GetBox(); - wxBitmap bmp(box.GetRight() + 1, box.GetBottom() + 1); + wxBitmap bmp(box.GetRight(), box.GetBottom()); wxMemoryDC dc; dc.SelectObject(bmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); - dc.SetDeviceClippingRegion(*static_cast(this)); + dc.SetClippingRegion(*wx_static_cast(const wxRegion *, this)); dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); @@ -130,7 +131,7 @@ bool wxRegionBase::Union(const wxBitmap& bmp) if (bmp.GetMask()) { wxImage image = bmp.ConvertToImage(); - wxASSERT_MSG( image.HasMask(), wxT("wxBitmap::ConvertToImage doesn't preserve mask?") ); + wxASSERT_MSG( image.HasMask(), _T("wxBitmap::ConvertToImage doesn't preserve mask?") ); return DoRegionUnion(*this, image, image.GetMaskRed(), image.GetMaskGreen(), diff --git a/Source/3rd Party/wx/src/common/richtooltipcmn.cpp b/Source/3rd Party/wx/src/common/richtooltipcmn.cpp deleted file mode 100644 index 6788488ff..000000000 --- a/Source/3rd Party/wx/src/common/richtooltipcmn.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/richtooltipcmn.cpp -// Purpose: wxRichToolTip implementation common to all platforms. -// Author: Vadim Zeitlin -// Created: 2011-10-18 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_RICHTOOLTIP - -#ifndef WX_PRECOMP - #include "wx/icon.h" -#endif // WX_PRECOMP - -#include "wx/private/richtooltip.h" - -// ============================================================================ -// implementation -// ============================================================================ - -wxRichToolTip::wxRichToolTip(const wxString& title, - const wxString& message) : - m_impl(wxRichToolTipImpl::Create(title, message)) -{ -} - -void -wxRichToolTip::SetBackgroundColour(const wxColour& col, const wxColour& colEnd) -{ - m_impl->SetBackgroundColour(col, colEnd); -} - -void wxRichToolTip::SetIcon(int icon) -{ - m_impl->SetStandardIcon(icon); -} - -void wxRichToolTip::SetIcon(const wxIcon& icon) -{ - m_impl->SetCustomIcon(icon); -} - -void wxRichToolTip::SetTimeout(unsigned milliseconds, - unsigned millisecondsDelay) -{ - m_impl->SetTimeout(milliseconds, millisecondsDelay); -} - -void wxRichToolTip::SetTipKind(wxTipKind tipKind) -{ - m_impl->SetTipKind(tipKind); -} - -void wxRichToolTip::SetTitleFont(const wxFont& font) -{ - m_impl->SetTitleFont(font); -} - -void wxRichToolTip::ShowFor(wxWindow* win, const wxRect* rect) -{ - wxCHECK_RET( win, wxS("Must have a valid window") ); - - m_impl->ShowFor(win, rect); -} - -wxRichToolTip::~wxRichToolTip() -{ - delete m_impl; -} - -#endif // wxUSE_RICHTOOLTIP diff --git a/Source/3rd Party/wx/src/common/sckaddr.cpp b/Source/3rd Party/wx/src/common/sckaddr.cpp deleted file mode 100644 index f2adc5634..000000000 --- a/Source/3rd Party/wx/src/common/sckaddr.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/sckaddr.cpp -// Purpose: Network address manager -// Author: Guilhem Lavaux -// Created: 26/04/97 -// Modified by: Vadim Zeitlin to use wxSockAddressImpl on 2008-12-28 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SOCKETS - -#ifndef WX_PRECOMP - #include "wx/object.h" - #include "wx/log.h" - #include "wx/intl.h" - #include "wx/thread.h" - - #include - #include - #include - - #include -#endif // !WX_PRECOMP - -#include "wx/socket.h" -#include "wx/sckaddr.h" -#include "wx/private/socket.h" -#include "wx/private/sckaddr.h" - -#include - -#if defined(__UNIX__) && !defined(__WINDOWS__) - #include - #include -#endif // __UNIX__ - -#ifndef INADDR_NONE - #define INADDR_NONE INADDR_ANY -#endif - -// ---------------------------------------------------------------------------- -// wxRTTI macros -// ---------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxSockAddress, wxObject) -IMPLEMENT_ABSTRACT_CLASS(wxIPaddress, wxSockAddress) -IMPLEMENT_DYNAMIC_CLASS(wxIPV4address, wxIPaddress) -#if wxUSE_IPV6 -IMPLEMENT_DYNAMIC_CLASS(wxIPV6address, wxIPaddress) -#endif -#if defined(__UNIX__) && !defined(__WINDOWS__) && !defined(__WINE__) -IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress) -#endif - -// ============================================================================ -// implementation of thread-safe/reentrant functions if they're missing -// ============================================================================ - -// TODO: use POSIX getaddrinfo() (also available in Winsock 2) for simplicity -// and to use the same code for IPv4 and IPv6 support - -#ifdef __WINDOWS__ - #define HAVE_INET_ADDR - - #ifndef HAVE_GETHOSTBYNAME - #define HAVE_GETHOSTBYNAME - #endif - #ifndef HAVE_GETSERVBYNAME - #define HAVE_GETSERVBYNAME - #endif - - // under MSW getxxxbyname() functions are MT-safe (but not reentrant) so - // we don't need to serialize calls to them - #define wxHAS_MT_SAFE_GETBY_FUNCS - - #if wxUSE_IPV6 - #ifdef __VISUALC__ - // this header does dynamic dispatching of getaddrinfo/freeaddrinfo() - // by implementing them in its own code if the system versions are - // not available (as is the case for anything < XP) - #pragma warning(push) - #pragma warning(disable:4706) - #include - #pragma warning(pop) - #else - // TODO: Use wxDynamicLibrary to bind to these functions - // dynamically on older Windows systems, currently a program - // built with wxUSE_IPV6==1 won't even start there, even if - // it doesn't actually use the socket stuff. - #include - #endif - #endif -#endif // __WINDOWS__ - -// we assume that we have gethostbyaddr_r() if and only if we have -// gethostbyname_r() and that it uses the similar conventions to it (see -// comment in configure) -#define HAVE_GETHOSTBYADDR HAVE_GETHOSTBYNAME -#ifdef HAVE_FUNC_GETHOSTBYNAME_R_3 - #define HAVE_FUNC_GETHOSTBYADDR_R_3 -#endif -#ifdef HAVE_FUNC_GETHOSTBYNAME_R_5 - #define HAVE_FUNC_GETHOSTBYADDR_R_5 -#endif -#ifdef HAVE_FUNC_GETHOSTBYNAME_R_6 - #define HAVE_FUNC_GETHOSTBYADDR_R_6 -#endif - -// the _r functions need the extra buffer parameter but unfortunately its type -// differs between different systems and for the systems which use opaque -// structs for it (at least AIX and OpenBSD) it must be zero-filled before -// being passed to the system functions -#ifdef HAVE_FUNC_GETHOSTBYNAME_R_3 - struct wxGethostBuf : hostent_data - { - wxGethostBuf() - { - memset(this, 0, sizeof(hostent_data)); - } - }; -#else - typedef char wxGethostBuf[1024]; -#endif - -#ifdef HAVE_FUNC_GETSERVBYNAME_R_4 - struct wxGetservBuf : servent_data - { - wxGetservBuf() - { - memset(this, 0, sizeof(servent_data)); - } - }; -#else - typedef char wxGetservBuf[1024]; -#endif - -#if defined(wxHAS_MT_SAFE_GETBY_FUNCS) || !wxUSE_THREADS - #define wxLOCK_GETBY_MUTEX(name) -#else // may need mutexes to protect getxxxbyxxx() calls - #if defined(HAVE_GETHOSTBYNAME) || \ - defined(HAVE_GETHOSTBYADDR) || \ - defined(HAVE_GETSERVBYNAME) - #include "wx/thread.h" - - namespace - { - // these mutexes are used to serialize - wxMutex nameLock, // gethostbyname() - addrLock, // gethostbyaddr() - servLock; // getservbyname() - } - - #define wxLOCK_GETBY_MUTEX(name) wxMutexLocker locker(name ## Lock) - #endif // we don't have _r functions -#endif // wxUSE_THREADS - -namespace -{ - -#if defined(HAVE_GETHOSTBYNAME) -hostent *deepCopyHostent(hostent *h, - const hostent *he, - char *buffer, - int size, - int *err) -{ - /* copy old structure */ - memcpy(h, he, sizeof(hostent)); - - /* copy name */ - int len = strlen(h->h_name); - if (len > size) - { - *err = ENOMEM; - return NULL; - } - memcpy(buffer, h->h_name, len); - buffer[len] = '\0'; - h->h_name = buffer; - - /* track position in the buffer */ - int pos = len + 1; - - /* reuse len to store address length */ - len = h->h_length; - - /* ensure pointer alignment */ - unsigned int misalign = sizeof(char *) - pos%sizeof(char *); - if(misalign < sizeof(char *)) - pos += misalign; - - /* leave space for pointer list */ - char **p = h->h_addr_list, **q; - char **h_addr_list = (char **)(buffer + pos); - while(*(p++) != 0) - pos += sizeof(char *); - - /* copy addresses and fill new pointer list */ - for (p = h->h_addr_list, q = h_addr_list; *p != 0; p++, q++) - { - if (size < pos + len) - { - *err = ENOMEM; - return NULL; - } - memcpy(buffer + pos, *p, len); /* copy content */ - *q = buffer + pos; /* set copied pointer to copied content */ - pos += len; - } - *++q = 0; /* null terminate the pointer list */ - h->h_addr_list = h_addr_list; /* copy pointer to pointers */ - - /* ensure word alignment of pointers */ - misalign = sizeof(char *) - pos%sizeof(char *); - if(misalign < sizeof(char *)) - pos += misalign; - - /* leave space for pointer list */ - p = h->h_aliases; - char **h_aliases = (char **)(buffer + pos); - while(*(p++) != 0) - pos += sizeof(char *); - - /* copy aliases and fill new pointer list */ - for (p = h->h_aliases, q = h_aliases; *p != 0; p++, q++) - { - len = strlen(*p); - if (size <= pos + len) - { - *err = ENOMEM; - return NULL; - } - memcpy(buffer + pos, *p, len); /* copy content */ - buffer[pos + len] = '\0'; - *q = buffer + pos; /* set copied pointer to copied content */ - pos += len + 1; - } - *++q = 0; /* null terminate the pointer list */ - h->h_aliases = h_aliases; /* copy pointer to pointers */ - - return h; -} -#endif // HAVE_GETHOSTBYNAME - -hostent *wxGethostbyname_r(const char *hostname, - hostent *h, - wxGethostBuf buffer, - int size, - int *err) -{ - hostent *he; -#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6) - gethostbyname_r(hostname, h, buffer, size, &he, err); -#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5) - he = gethostbyname_r(hostname, h, buffer, size, err); -#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3) - wxUnusedVar(var); - *err = gethostbyname_r(hostname, h, &buffer); - he = h; -#elif defined(HAVE_GETHOSTBYNAME) - wxLOCK_GETBY_MUTEX(name); - - he = gethostbyname(hostname); - *err = h_errno; - - if ( he ) - he = deepCopyHostent(h, he, buffer, size, err); -#else - #error "No gethostbyname[_r]()" -#endif - - return he; -} - -hostent *wxGethostbyaddr_r(const char *addr_buf, - int buf_size, - int proto, - hostent *h, - wxGethostBuf buffer, - int size, - int *err) -{ - hostent *he; -#if defined(HAVE_FUNC_GETHOSTBYADDR_R_6) - gethostbyaddr_r(addr_buf, buf_size, proto, h, buffer, size, &he, err); -#elif defined(HAVE_FUNC_GETHOSTBYADDR_R_5) - he = gethostbyaddr_r(addr_buf, buf_size, proto, h, buffer, size, err); -#elif defined(HAVE_FUNC_GETHOSTBYADDR_R_3) - wxUnusedVar(size); - *err = gethostbyaddr_r(addr_buf, buf_size, proto, h, &buffer); - he = h; -#elif defined(HAVE_GETHOSTBYADDR) - wxLOCK_GETBY_MUTEX(addr); - - he = gethostbyaddr(addr_buf, buf_size, proto); - *err = h_errno; - - if ( he ) - he = deepCopyHostent(h, he, buffer, size, err); -#else - #error "No gethostbyaddr[_r]()" -#endif - - return he; -} - -#if defined(HAVE_GETSERVBYNAME) -servent *deepCopyServent(servent *s, - servent *se, - char *buffer, - int size) -{ - /* copy plain old structure */ - memcpy(s, se, sizeof(servent)); - - /* copy name */ - int len = strlen(s->s_name); - if (len >= size) - { - return NULL; - } - memcpy(buffer, s->s_name, len); - buffer[len] = '\0'; - s->s_name = buffer; - - /* track position in the buffer */ - int pos = len + 1; - - /* copy protocol */ - len = strlen(s->s_proto); - if (pos + len >= size) - { - return NULL; - } - memcpy(buffer + pos, s->s_proto, len); - buffer[pos + len] = '\0'; - s->s_proto = buffer + pos; - - /* track position in the buffer */ - pos += len + 1; - - /* ensure pointer alignment */ - unsigned int misalign = sizeof(char *) - pos%sizeof(char *); - if(misalign < sizeof(char *)) - pos += misalign; - - /* leave space for pointer list */ - char **p = s->s_aliases, **q; - char **s_aliases = (char **)(buffer + pos); - while(*(p++) != 0) - pos += sizeof(char *); - - /* copy addresses and fill new pointer list */ - for (p = s->s_aliases, q = s_aliases; *p != 0; p++, q++){ - len = strlen(*p); - if (size <= pos + len) - { - return NULL; - } - memcpy(buffer + pos, *p, len); /* copy content */ - buffer[pos + len] = '\0'; - *q = buffer + pos; /* set copied pointer to copied content */ - pos += len + 1; - } - *++q = 0; /* null terminate the pointer list */ - s->s_aliases = s_aliases; /* copy pointer to pointers */ - return s; -} -#endif // HAVE_GETSERVBYNAME - -servent *wxGetservbyname_r(const char *port, - const char *protocol, - servent *serv, - wxGetservBuf& buffer, - int size) -{ - servent *se; -#if defined(HAVE_FUNC_GETSERVBYNAME_R_6) - getservbyname_r(port, protocol, serv, buffer, size, &se); -#elif defined(HAVE_FUNC_GETSERVBYNAME_R_5) - se = getservbyname_r(port, protocol, serv, buffer, size); -#elif defined(HAVE_FUNC_GETSERVBYNAME_R_4) - wxUnusedVar(size); - if ( getservbyname_r(port, protocol, serv, &buffer) != 0 ) - return NULL; -#elif defined(HAVE_GETSERVBYNAME) - wxLOCK_GETBY_MUTEX(serv); - - se = getservbyname(port, protocol); - if ( se ) - se = deepCopyServent(serv, se, buffer, size); -#else - #error "No getservbyname[_r]()" -#endif - return se; -} - -} // anonymous namespace - -// ============================================================================ -// wxSockAddressImpl implementation -// ============================================================================ - -// FIXME-VC6: helper macros to call Alloc/Get() hiding the ugly dummy argument -#define ALLOC(T) Alloc(static_cast(NULL)) -#define GET(T) Get(static_cast(NULL)) - -// ---------------------------------------------------------------------------- -// INET or INET6 address family -// ---------------------------------------------------------------------------- - -wxString wxSockAddressImpl::GetHostName() const -{ - const void *addrbuf; - int addrbuflen; - -#if wxUSE_IPV6 - if ( m_family == FAMILY_INET6 ) - { - sockaddr_in6 * const addr6 = GET(sockaddr_in6); - addrbuf = &addr6->sin6_addr; - addrbuflen = sizeof(addr6->sin6_addr); - } - else -#endif // wxUSE_IPV6 - { - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return wxString(); - - addrbuf = &addr->sin_addr; - addrbuflen = sizeof(addr->sin_addr); - } - - hostent he; - wxGethostBuf buffer; - int err; - if ( !wxGethostbyaddr_r - ( - static_cast(addrbuf), - addrbuflen, - m_family, - &he, - buffer, - sizeof(buffer), - &err - ) ) - { - return wxString(); - } - - return wxString::FromUTF8(he.h_name); -} - -bool wxSockAddressImpl::SetPortName(const wxString& name, const char *protocol) -{ - // test whether it's a number first - unsigned long port; - if ( name.ToULong(&port) ) - { - if ( port > 65535 ) - return false; - } - else // it's a service name - { - wxGetservBuf buffer; - servent se; - if ( !wxGetservbyname_r(name.utf8_str(), protocol, &se, - buffer, sizeof(buffer)) ) - return false; - - // s_port is in network byte order and SetPort() uses the host byte - // order and we prefer to reuse it from here instead of assigning to - // sin_port directly - port = ntohs(se.s_port); - } - - return SetPort(port); -} - -// ---------------------------------------------------------------------------- -// INET address family -// ---------------------------------------------------------------------------- - -void wxSockAddressImpl::CreateINET() -{ - wxASSERT_MSG( Is(FAMILY_UNSPEC), "recreating address as different type?" ); - - m_family = FAMILY_INET; - sockaddr_in * const addr = ALLOC(sockaddr_in); - addr->sin_family = FAMILY_INET; -} - -bool wxSockAddressImpl::SetHostName4(const wxString& name) -{ - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return false; - - const wxScopedCharBuffer namebuf(name.utf8_str()); - - // first check if this is an address in quad dotted notation -#if defined(HAVE_INET_ATON) - if ( inet_aton(namebuf, &addr->sin_addr) ) - return true; -#elif defined(HAVE_INET_ADDR) - addr->sin_addr.s_addr = inet_addr(namebuf); - if ( addr->sin_addr.s_addr != INADDR_NONE ) - return true; -#else - #error "Neither inet_aton() nor inet_addr() is available?" -#endif - - // it's a host name, resolve it - hostent he; - wxGethostBuf buffer; - int err; - if ( !wxGethostbyname_r(namebuf, &he, buffer, sizeof(buffer), &err) ) - return false; - - addr->sin_addr.s_addr = ((in_addr *)he.h_addr)->s_addr; - return true; -} - -bool wxSockAddressImpl::GetHostAddress(wxUint32 *address) const -{ - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return false; - - *address = ntohl(addr->sin_addr.s_addr); - - return true; -} - -bool wxSockAddressImpl::SetHostAddress(wxUint32 address) -{ - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return false; - - addr->sin_addr.s_addr = htonl(address); - - return true; -} - -wxUint16 wxSockAddressImpl::GetPort4() const -{ - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return 0; - - return ntohs(addr->sin_port); -} - -bool wxSockAddressImpl::SetPort4(wxUint16 port) -{ - sockaddr_in * const addr = GET(sockaddr_in); - if ( !addr ) - return false; - - addr->sin_port = htons(port); - - return true; -} - -#if wxUSE_IPV6 - -// ---------------------------------------------------------------------------- -// INET6 address family -// ---------------------------------------------------------------------------- - -void wxSockAddressImpl::CreateINET6() -{ - wxASSERT_MSG( Is(FAMILY_UNSPEC), "recreating address as different type?" ); - - m_family = FAMILY_INET6; - sockaddr_in6 * const addr = ALLOC(sockaddr_in6); - addr->sin6_family = FAMILY_INET6; -} - -bool wxSockAddressImpl::SetHostName6(const wxString& hostname) -{ - sockaddr_in6 * const addr = GET(sockaddr_in6); - if ( !addr ) - return false; - - addrinfo hints; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET6; - - addrinfo *info = NULL; - int rc = getaddrinfo(hostname.utf8_str(), NULL, &hints, &info); - if ( rc ) - { - // use gai_strerror()? - return false; - } - - wxCHECK_MSG( info, false, "should have info on success" ); - - wxASSERT_MSG( int(info->ai_addrlen) == m_len, "unexpected address length" ); - - memcpy(addr, info->ai_addr, info->ai_addrlen); - freeaddrinfo(info); - - return true; -} - -bool wxSockAddressImpl::GetHostAddress(in6_addr *address) const -{ - sockaddr_in6 * const addr = GET(sockaddr_in6); - if ( !addr ) - return false; - - *address = addr->sin6_addr; - - return true; -} - -bool wxSockAddressImpl::SetHostAddress(const in6_addr& address) -{ - sockaddr_in6 * const addr = GET(sockaddr_in6); - if ( !addr ) - return false; - - addr->sin6_addr = address; - - return true; -} - -wxUint16 wxSockAddressImpl::GetPort6() const -{ - sockaddr_in6 * const addr = GET(sockaddr_in6); - if ( !addr ) - return 0; - - return ntohs(addr->sin6_port); -} - -bool wxSockAddressImpl::SetPort6(wxUint16 port) -{ - sockaddr_in6 * const addr = GET(sockaddr_in6); - if ( !addr ) - return false; - - addr->sin6_port = htons(port); - - return true; -} - -bool wxSockAddressImpl::SetToAnyAddress6() -{ - static const in6_addr any = IN6ADDR_ANY_INIT; - - return SetHostAddress(any); -} - -#endif // wxUSE_IPV6 - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - -// ---------------------------------------------------------------------------- -// Unix address family -// ---------------------------------------------------------------------------- - -#ifndef UNIX_PATH_MAX - #define UNIX_PATH_MAX (WXSIZEOF(((sockaddr_un *)NULL)->sun_path)) -#endif - -void wxSockAddressImpl::CreateUnix() -{ - wxASSERT_MSG( Is(FAMILY_UNSPEC), "recreating address as different type?" ); - - m_family = FAMILY_UNIX; - sockaddr_un * const addr = ALLOC(sockaddr_un); - addr->sun_family = FAMILY_UNIX; - addr->sun_path[0] = '\0'; -} - -bool wxSockAddressImpl::SetPath(const wxString& path) -{ - sockaddr_un * const addr = GET(sockaddr_un); - if ( !addr ) - return false; - - const wxScopedCharBuffer buf(path.utf8_str()); - if ( strlen(buf) >= UNIX_PATH_MAX ) - return false; - - wxStrlcpy(addr->sun_path, buf, UNIX_PATH_MAX); - - return true; -} - -wxString wxSockAddressImpl::GetPath() const -{ - sockaddr_un * const addr = GET(sockaddr_un); - if ( !addr ) - return wxString(); - - return wxString::FromUTF8(addr->sun_path); -} - -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - -#undef GET -#undef ALLOC - -// ---------------------------------------------------------------------------- -// wxSockAddress -// ---------------------------------------------------------------------------- - -const sockaddr *wxSockAddress::GetAddressData() const -{ - return GetAddress().GetAddr(); -} - -int wxSockAddress::GetAddressDataLen() const -{ - return GetAddress().GetLen(); -} - -void wxSockAddress::Init() -{ - if ( wxIsMainThread() && !wxSocketBase::IsInitialized() ) - { - // we must do it before using any socket functions - (void)wxSocketBase::Initialize(); - } -} - -wxSockAddress::wxSockAddress() -{ - Init(); - - m_impl = new wxSockAddressImpl(); -} - -wxSockAddress::wxSockAddress(const wxSockAddress& other) - : wxObject() -{ - Init(); - - m_impl = new wxSockAddressImpl(*other.m_impl); -} - -wxSockAddress::~wxSockAddress() -{ - delete m_impl; -} - -void wxSockAddress::SetAddress(const wxSockAddressImpl& address) -{ - if ( &address != m_impl ) - { - delete m_impl; - m_impl = new wxSockAddressImpl(address); - } -} - -wxSockAddress& wxSockAddress::operator=(const wxSockAddress& addr) -{ - SetAddress(addr.GetAddress()); - - return *this; -} - -void wxSockAddress::Clear() -{ - m_impl->Clear(); -} - -// ---------------------------------------------------------------------------- -// wxIPaddress -// ---------------------------------------------------------------------------- - -wxSockAddressImpl& wxIPaddress::GetImpl() -{ - if ( m_impl->GetFamily() == wxSockAddressImpl::FAMILY_UNSPEC ) - m_impl->CreateINET(); - - return *m_impl; -} - -bool wxIPaddress::Hostname(const wxString& name) -{ - wxCHECK_MSG( !name.empty(), false, "empty host name is invalid" ); - - m_origHostname = name; - - return GetImpl().SetHostName(name); -} - -bool wxIPaddress::Service(const wxString& name) -{ - return GetImpl().SetPortName(name, "tcp"); -} - -bool wxIPaddress::Service(unsigned short port) -{ - return GetImpl().SetPort(port); -} - -bool wxIPaddress::LocalHost() -{ - return Hostname("localhost"); -} - -wxString wxIPaddress::Hostname() const -{ - return GetImpl().GetHostName(); -} - -unsigned short wxIPaddress::Service() const -{ - return GetImpl().GetPort(); -} - -bool wxIPaddress::operator==(const wxIPaddress& addr) const -{ - return Hostname().Cmp(addr.Hostname()) == 0 && - Service() == addr.Service(); -} - -bool wxIPaddress::AnyAddress() -{ - return GetImpl().SetToAnyAddress(); -} - -// ---------------------------------------------------------------------------- -// wxIPV4address -// ---------------------------------------------------------------------------- - -void wxIPV4address::DoInitImpl() -{ - m_impl->CreateINET(); -} - -bool wxIPV4address::Hostname(unsigned long addr) -{ - if ( !GetImpl().SetHostAddress(addr) ) - { - m_origHostname.clear(); - return false; - } - - m_origHostname = Hostname(); - return true; -} - -bool wxIPV4address::IsLocalHost() const -{ - return Hostname() == "localhost" || IPAddress() == "127.0.0.1"; -} - -wxString wxIPV4address::IPAddress() const -{ - wxUint32 addr; - if ( !GetImpl().GetHostAddress(&addr) ) - return wxString(); - - return wxString::Format - ( - "%u.%u.%u.%u", - (addr >> 24) & 0xff, - (addr >> 16) & 0xff, - (addr >> 8) & 0xff, - addr & 0xff - ); -} - -bool wxIPV4address::BroadcastAddress() -{ - return GetImpl().SetToBroadcastAddress(); -} - -#if wxUSE_IPV6 - -// --------------------------------------------------------------------------- -// wxIPV6address -// --------------------------------------------------------------------------- - -void wxIPV6address::DoInitImpl() -{ - m_impl->CreateINET6(); -} - -bool wxIPV6address::Hostname(unsigned char addr[16]) -{ - unsigned short wk[8]; - for ( int i = 0; i < 8; ++i ) - { - wk[i] = addr[2*i]; - wk[i] <<= 8; - wk[i] |= addr[2*i+1]; - } - - return Hostname - ( - wxString::Format - ( - "%x:%x:%x:%x:%x:%x:%x:%x", - wk[0], wk[1], wk[2], wk[3], wk[4], wk[5], wk[6], wk[7] - ) - ); -} - -bool wxIPV6address::IsLocalHost() const -{ - if ( Hostname() == "localhost" ) - return true; - - wxString addr = IPAddress(); - return addr == wxT("::1") || - addr == wxT("0:0:0:0:0:0:0:1") || - addr == wxT("::ffff:127.0.0.1"); -} - -wxString wxIPV6address::IPAddress() const -{ - union - { - in6_addr addr6; - wxUint8 bytes[16]; - } u; - - if ( !GetImpl().GetHostAddress(&u.addr6) ) - return wxString(); - - const wxUint8 * const addr = u.bytes; - - wxUint16 words[8]; - int i, - prefix_zero_count = 0; - for ( i = 0; i < 8; ++i ) - { - words[i] = addr[i*2]; - words[i] <<= 8; - words[i] |= addr[i*2+1]; - if ( i == prefix_zero_count && words[i] == 0 ) - ++prefix_zero_count; - } - - wxString result; - if ( prefix_zero_count == 8 ) - { - result = wxT( "::" ); - } - else if ( prefix_zero_count == 6 && words[5] == 0xFFFF ) - { - // IPv4 mapped - result.Printf("::ffff:%d.%d.%d.%d", - addr[12], addr[13], addr[14], addr[15]); - } - else // general case - { - result = ":"; - for ( i = prefix_zero_count; i < 8; ++i ) - { - result += wxString::Format(":%x", words[i]); - } - } - - return result; -} - -#endif // wxUSE_IPV6 - -#ifdef wxHAS_UNIX_DOMAIN_SOCKETS - -// --------------------------------------------------------------------------- -// wxUNIXaddress -// --------------------------------------------------------------------------- - -wxSockAddressImpl& wxUNIXaddress::GetUNIX() -{ - if ( m_impl->GetFamily() == wxSockAddressImpl::FAMILY_UNSPEC ) - m_impl->CreateUnix(); - - return *m_impl; -} - -void wxUNIXaddress::Filename(const wxString& fname) -{ - GetUNIX().SetPath(fname); -} - -wxString wxUNIXaddress::Filename() const -{ - return GetUNIX().GetPath(); -} - -#endif // wxHAS_UNIX_DOMAIN_SOCKETS - -#endif // wxUSE_SOCKETS diff --git a/Source/3rd Party/wx/src/common/sckfile.cpp b/Source/3rd Party/wx/src/common/sckfile.cpp deleted file mode 100644 index 4b7b6cee1..000000000 --- a/Source/3rd Party/wx/src/common/sckfile.cpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/sckfile.cpp -// Purpose: File protocol -// Author: Guilhem Lavaux -// Modified by: -// Created: 20/07/97 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STREAMS && wxUSE_PROTOCOL_FILE - -#ifndef WX_PRECOMP -#endif - -#include "wx/uri.h" -#include "wx/wfstream.h" -#include "wx/protocol/file.h" - - -// ---------------------------------------------------------------------------- -// wxFileProto -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFileProto, wxProtocol) -IMPLEMENT_PROTOCOL(wxFileProto, wxT("file"), NULL, false) - -wxFileProto::wxFileProto() - : wxProtocol() -{ -} - -wxFileProto::~wxFileProto() -{ -} - -wxInputStream *wxFileProto::GetInputStream(const wxString& path) -{ - wxFileInputStream *retval = new wxFileInputStream(wxURI::Unescape(path)); - if ( retval->IsOk() ) - { - m_lastError = wxPROTO_NOERR; - return retval; - } - - m_lastError = wxPROTO_NOFILE; - delete retval; - - return NULL; -} - -#endif // wxUSE_STREAMS && wxUSE_PROTOCOL_FILE diff --git a/Source/3rd Party/wx/src/common/sckipc.cpp b/Source/3rd Party/wx/src/common/sckipc.cpp deleted file mode 100644 index ea1de8eb8..000000000 --- a/Source/3rd Party/wx/src/common/sckipc.cpp +++ /dev/null @@ -1,931 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/sckipc.cpp -// Purpose: Interprocess communication implementation (wxSocket version) -// Author: Julian Smart -// Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998 -// Guillermo Rodriguez (updated for wxSocket v2) Jan 2000 -// (callbacks deprecated) Mar 2000 -// Vadim Zeitlin (added support for Unix sockets) Apr 2002 -// (use buffering, many fixes/cleanup) Oct 2008 -// Created: 1993 -// Copyright: (c) Julian Smart 1993 -// (c) Guilhem Lavaux 1997, 1998 -// (c) 2000 Guillermo Rodriguez -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ========================================================================== -// declarations -// ========================================================================== - -// -------------------------------------------------------------------------- -// headers -// -------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SOCKETS && wxUSE_IPC && wxUSE_STREAMS - -#include "wx/sckipc.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/event.h" - #include "wx/module.h" -#endif - -#include -#include -#include - -#include "wx/socket.h" - -// -------------------------------------------------------------------------- -// macros and constants -// -------------------------------------------------------------------------- - -namespace -{ - -// Message codes (don't change them to avoid breaking the existing code using -// wxIPC protocol!) -enum IPCCode -{ - IPC_EXECUTE = 1, - IPC_REQUEST = 2, - IPC_POKE = 3, - IPC_ADVISE_START = 4, - IPC_ADVISE_REQUEST = 5, - IPC_ADVISE = 6, - IPC_ADVISE_STOP = 7, - IPC_REQUEST_REPLY = 8, - IPC_FAIL = 9, - IPC_CONNECT = 10, - IPC_DISCONNECT = 11, - IPC_MAX -}; - -} // anonymous namespace - -// headers needed for umask() -#ifdef __UNIX_LIKE__ - #include - #include -#endif // __UNIX_LIKE__ - -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -// get the address object for the given server name, the caller must delete it -static wxSockAddress * -GetAddressFromName(const wxString& serverName, - const wxString& host = wxEmptyString) -{ - // we always use INET sockets under non-Unix systems -#if defined(__UNIX__) && !defined(__WINDOWS__) && !defined(__WINE__) - // under Unix, if the server name looks like a path, create a AF_UNIX - // socket instead of AF_INET one - if ( serverName.Find(wxT('/')) != wxNOT_FOUND ) - { - wxUNIXaddress *addr = new wxUNIXaddress; - addr->Filename(serverName); - - return addr; - } -#endif // Unix/!Unix - { - wxIPV4address *addr = new wxIPV4address; - addr->Service(serverName); - if ( !host.empty() ) - { - addr->Hostname(host); - } - - return addr; - } -} - -// -------------------------------------------------------------------------- -// wxTCPEventHandler stuff (private class) -// -------------------------------------------------------------------------- - -class wxTCPEventHandler : public wxEvtHandler -{ -public: - wxTCPEventHandler() : wxEvtHandler() { } - - void Client_OnRequest(wxSocketEvent& event); - void Server_OnRequest(wxSocketEvent& event); - -private: - void HandleDisconnect(wxTCPConnection *connection); - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTCPEventHandler); -}; - -enum -{ - _CLIENT_ONREQUEST_ID = 1000, - _SERVER_ONREQUEST_ID -}; - -// -------------------------------------------------------------------------- -// wxTCPEventHandlerModule (private class) -// -------------------------------------------------------------------------- - -class wxTCPEventHandlerModule : public wxModule -{ -public: - wxTCPEventHandlerModule() : wxModule() { } - - // get the global wxTCPEventHandler creating it if necessary - static wxTCPEventHandler& GetHandler() - { - if ( !ms_handler ) - ms_handler = new wxTCPEventHandler; - - return *ms_handler; - } - - // as ms_handler is initialized on demand, don't do anything in OnInit() - virtual bool OnInit() { return true; } - virtual void OnExit() { wxDELETE(ms_handler); } - -private: - static wxTCPEventHandler *ms_handler; - - DECLARE_DYNAMIC_CLASS(wxTCPEventHandlerModule) - wxDECLARE_NO_COPY_CLASS(wxTCPEventHandlerModule); -}; - -IMPLEMENT_DYNAMIC_CLASS(wxTCPEventHandlerModule, wxModule) - -wxTCPEventHandler *wxTCPEventHandlerModule::ms_handler = NULL; - -// -------------------------------------------------------------------------- -// wxIPCSocketStreams -// -------------------------------------------------------------------------- - -#define USE_BUFFER - -// this class contains the various (related) streams used by wxTCPConnection -// and also provides a way to read from the socket stream directly -// -// for writing to the stream use the IPCOutput class below -class wxIPCSocketStreams -{ -public: - // ctor initializes all the streams on top of the given socket - // - // note that we use a bigger than default buffer size which matches the - // typical Ethernet MTU (minus TCP header overhead) - wxIPCSocketStreams(wxSocketBase& sock) - : m_socketStream(sock), -#ifdef USE_BUFFER - m_bufferedOut(m_socketStream, 1448), -#else - m_bufferedOut(m_socketStream), -#endif - m_dataIn(m_socketStream), - m_dataOut(m_bufferedOut) - { - } - - // expose the IO methods needed by IPC code (notice that writing is only - // done via IPCOutput) - - // flush output - void Flush() - { -#ifdef USE_BUFFER - m_bufferedOut.Sync(); -#endif - } - - // simple wrappers around the functions with the same name in - // wxDataInputStream - wxUint8 Read8() - { - Flush(); - return m_dataIn.Read8(); - } - - wxUint32 Read32() - { - Flush(); - return m_dataIn.Read32(); - } - - wxString ReadString() - { - Flush(); - return m_dataIn.ReadString(); - } - - // read arbitrary (size-prepended) data - // - // connection parameter is needed to call its GetBufferAtLeast() method - void *ReadData(wxConnectionBase *conn, size_t *size) - { - Flush(); - - wxCHECK_MSG( conn, NULL, "NULL connection parameter" ); - wxCHECK_MSG( size, NULL, "NULL size parameter" ); - - *size = Read32(); - - void * const data = conn->GetBufferAtLeast(*size); - wxCHECK_MSG( data, NULL, "IPC buffer allocation failed" ); - - m_socketStream.Read(data, *size); - - return data; - } - - // same as above but for data preceded by the format - void * - ReadFormatData(wxConnectionBase *conn, wxIPCFormat *format, size_t *size) - { - wxCHECK_MSG( format, NULL, "NULL format parameter" ); - - *format = static_cast(Read8()); - - return ReadData(conn, size); - } - - - // these methods are only used by IPCOutput and not directly - wxDataOutputStream& GetDataOut() { return m_dataOut; } - wxOutputStream& GetUnformattedOut() { return m_bufferedOut; } - -private: - // this is the low-level underlying stream using the connection socket - wxSocketStream m_socketStream; - - // the buffered stream is used to avoid writing all pieces of an IPC - // request to the socket one by one but to instead do it all at once when - // we're done with it -#ifdef USE_BUFFER - wxBufferedOutputStream m_bufferedOut; -#else - wxOutputStream& m_bufferedOut; -#endif - - // finally the data streams are used to be able to write typed data into - // the above streams easily - wxDataInputStream m_dataIn; - wxDataOutputStream m_dataOut; - - wxDECLARE_NO_COPY_CLASS(wxIPCSocketStreams); -}; - -namespace -{ - -// an object of this class should be instantiated on the stack to write to the -// underlying socket stream -// -// this class is intentionally separated from wxIPCSocketStreams to ensure that -// Flush() is always called -class IPCOutput -{ -public: - // construct an object associated with the given streams (which must have - // life time greater than ours as we keep a reference to it) - IPCOutput(wxIPCSocketStreams *streams) - : m_streams(*streams) - { - wxASSERT_MSG( streams, "NULL streams pointer" ); - } - - // dtor calls Flush() really sending the IPC data to the network - ~IPCOutput() { m_streams.Flush(); } - - - // write a byte - void Write8(wxUint8 i) - { - m_streams.GetDataOut().Write8(i); - } - - // write the reply code and a string - void Write(IPCCode code, const wxString& str) - { - Write8(code); - m_streams.GetDataOut().WriteString(str); - } - - // write the reply code, a string and a format in this order - void Write(IPCCode code, const wxString& str, wxIPCFormat format) - { - Write(code, str); - Write8(format); - } - - // write arbitrary data - void WriteData(const void *data, size_t size) - { - m_streams.GetDataOut().Write32(size); - m_streams.GetUnformattedOut().Write(data, size); - } - - -private: - wxIPCSocketStreams& m_streams; - - wxDECLARE_NO_COPY_CLASS(IPCOutput); -}; - -} // anonymous namespace - -// ========================================================================== -// implementation -// ========================================================================== - -IMPLEMENT_DYNAMIC_CLASS(wxTCPServer, wxServerBase) -IMPLEMENT_DYNAMIC_CLASS(wxTCPClient, wxClientBase) -IMPLEMENT_CLASS(wxTCPConnection, wxConnectionBase) - -// -------------------------------------------------------------------------- -// wxTCPClient -// -------------------------------------------------------------------------- - -wxTCPClient::wxTCPClient() - : wxClientBase() -{ -} - -bool wxTCPClient::ValidHost(const wxString& host) -{ - wxIPV4address addr; - - return addr.Hostname(host); -} - -wxConnectionBase *wxTCPClient::MakeConnection(const wxString& host, - const wxString& serverName, - const wxString& topic) -{ - wxSockAddress *addr = GetAddressFromName(serverName, host); - if ( !addr ) - return NULL; - - wxSocketClient * const client = new wxSocketClient(wxSOCKET_WAITALL); - wxIPCSocketStreams * const streams = new wxIPCSocketStreams(*client); - - bool ok = client->Connect(*addr); - delete addr; - - if ( ok ) - { - // Send topic name, and enquire whether this has succeeded - IPCOutput(streams).Write(IPC_CONNECT, topic); - - unsigned char msg = streams->Read8(); - - // OK! Confirmation. - if (msg == IPC_CONNECT) - { - wxTCPConnection * - connection = (wxTCPConnection *)OnMakeConnection (); - - if (connection) - { - if (wxDynamicCast(connection, wxTCPConnection)) - { - connection->m_topic = topic; - connection->m_sock = client; - connection->m_streams = streams; - client->SetEventHandler(wxTCPEventHandlerModule::GetHandler(), - _CLIENT_ONREQUEST_ID); - client->SetClientData(connection); - client->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); - client->Notify(true); - return connection; - } - else - { - delete connection; - // and fall through to delete everything else - } - } - } - } - - // Something went wrong, delete everything - delete streams; - client->Destroy(); - - return NULL; -} - -wxConnectionBase *wxTCPClient::OnMakeConnection() -{ - return new wxTCPConnection(); -} - -// -------------------------------------------------------------------------- -// wxTCPServer -// -------------------------------------------------------------------------- - -wxTCPServer::wxTCPServer() - : wxServerBase() -{ - m_server = NULL; -} - -bool wxTCPServer::Create(const wxString& serverName) -{ - // Destroy previous server, if any - if (m_server) - { - m_server->SetClientData(NULL); - m_server->Destroy(); - m_server = NULL; - } - - wxSockAddress *addr = GetAddressFromName(serverName); - if ( !addr ) - return false; - -#ifdef __UNIX_LIKE__ - mode_t umaskOld; - if ( addr->Type() == wxSockAddress::UNIX ) - { - // ensure that the file doesn't exist as otherwise calling socket() - // would fail - int rc = remove(serverName.fn_str()); - if ( rc < 0 && errno != ENOENT ) - { - delete addr; - - return false; - } - - // also set the umask to prevent the others from reading our file - umaskOld = umask(077); - } - else - { - // unused anyhow but shut down the compiler warnings - umaskOld = 0; - } -#endif // __UNIX_LIKE__ - - // Create a socket listening on the specified port (reusing it to allow - // restarting the server listening on the same port as was used by the - // previous instance of this server) - m_server = new wxSocketServer(*addr, wxSOCKET_WAITALL | wxSOCKET_REUSEADDR); - -#ifdef __UNIX_LIKE__ - if ( addr->Type() == wxSockAddress::UNIX ) - { - // restore the umask - umask(umaskOld); - - // save the file name to remove it later - m_filename = serverName; - } -#endif // __UNIX_LIKE__ - - delete addr; - - if (!m_server->IsOk()) - { - m_server->Destroy(); - m_server = NULL; - - return false; - } - - m_server->SetEventHandler(wxTCPEventHandlerModule::GetHandler(), - _SERVER_ONREQUEST_ID); - m_server->SetClientData(this); - m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); - m_server->Notify(true); - - return true; -} - -wxTCPServer::~wxTCPServer() -{ - if ( m_server ) - { - m_server->SetClientData(NULL); - m_server->Destroy(); - } - -#ifdef __UNIX_LIKE__ - if ( !m_filename.empty() ) - { - if ( remove(m_filename.fn_str()) != 0 ) - { - wxLogDebug(wxT("Stale AF_UNIX file '%s' left."), m_filename.c_str()); - } - } -#endif // __UNIX_LIKE__ -} - -wxConnectionBase * -wxTCPServer::OnAcceptConnection(const wxString& WXUNUSED(topic)) -{ - return new wxTCPConnection(); -} - -// -------------------------------------------------------------------------- -// wxTCPConnection -// -------------------------------------------------------------------------- - -void wxTCPConnection::Init() -{ - m_sock = NULL; - m_streams = NULL; -} - -wxTCPConnection::~wxTCPConnection() -{ - Disconnect(); - - if ( m_sock ) - { - m_sock->SetClientData(NULL); - m_sock->Destroy(); - } - - delete m_streams; -} - -void wxTCPConnection::Compress(bool WXUNUSED(on)) -{ - // TODO -} - -// Calls that CLIENT can make. -bool wxTCPConnection::Disconnect() -{ - if ( !GetConnected() ) - return true; - - // Send the disconnect message to the peer. - IPCOutput(m_streams).Write8(IPC_DISCONNECT); - - if ( m_sock ) - { - m_sock->Notify(false); - m_sock->Close(); - } - - SetConnected(false); - - return true; -} - -bool wxTCPConnection::DoExecute(const void *data, - size_t size, - wxIPCFormat format) -{ - if ( !m_sock->IsConnected() ) - return false; - - // Prepare EXECUTE message - IPCOutput out(m_streams); - out.Write8(IPC_EXECUTE); - out.Write8(format); - - out.WriteData(data, size); - - return true; -} - -const void *wxTCPConnection::Request(const wxString& item, - size_t *size, - wxIPCFormat format) -{ - if ( !m_sock->IsConnected() ) - return NULL; - - IPCOutput(m_streams).Write(IPC_REQUEST, item, format); - - const int ret = m_streams->Read8(); - if ( ret != IPC_REQUEST_REPLY ) - return NULL; - - // ReadData() needs a non-NULL size pointer but the client code can call us - // with NULL pointer (this makes sense if it knows that it always works - // with NUL-terminated strings) - size_t sizeFallback; - return m_streams->ReadData(this, size ? size : &sizeFallback); -} - -bool wxTCPConnection::DoPoke(const wxString& item, - const void *data, - size_t size, - wxIPCFormat format) -{ - if ( !m_sock->IsConnected() ) - return false; - - IPCOutput out(m_streams); - out.Write(IPC_POKE, item, format); - out.WriteData(data, size); - - return true; -} - -bool wxTCPConnection::StartAdvise(const wxString& item) -{ - if ( !m_sock->IsConnected() ) - return false; - - IPCOutput(m_streams).Write(IPC_ADVISE_START, item); - - const int ret = m_streams->Read8(); - - return ret == IPC_ADVISE_START; -} - -bool wxTCPConnection::StopAdvise (const wxString& item) -{ - if ( !m_sock->IsConnected() ) - return false; - - IPCOutput(m_streams).Write(IPC_ADVISE_STOP, item); - - const int ret = m_streams->Read8(); - - return ret == IPC_ADVISE_STOP; -} - -// Calls that SERVER can make -bool wxTCPConnection::DoAdvise(const wxString& item, - const void *data, - size_t size, - wxIPCFormat format) -{ - if ( !m_sock->IsConnected() ) - return false; - - IPCOutput out(m_streams); - out.Write(IPC_ADVISE, item, format); - out.WriteData(data, size); - - return true; -} - -// -------------------------------------------------------------------------- -// wxTCPEventHandler (private class) -// -------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxTCPEventHandler, wxEvtHandler) - EVT_SOCKET(_CLIENT_ONREQUEST_ID, wxTCPEventHandler::Client_OnRequest) - EVT_SOCKET(_SERVER_ONREQUEST_ID, wxTCPEventHandler::Server_OnRequest) -END_EVENT_TABLE() - -void wxTCPEventHandler::HandleDisconnect(wxTCPConnection *connection) -{ - // connection was closed (either gracefully or not): destroy everything - connection->m_sock->Notify(false); - connection->m_sock->Close(); - - // don't leave references to this soon-to-be-dangling connection in the - // socket as it won't be destroyed immediately as its destruction will be - // delayed in case there are more events pending for it - connection->m_sock->SetClientData(NULL); - - connection->SetConnected(false); - connection->OnDisconnect(); -} - -void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event) -{ - wxSocketBase *sock = event.GetSocket(); - if (!sock) - return; - - wxSocketNotify evt = event.GetSocketEvent(); - wxTCPConnection * const - connection = static_cast(sock->GetClientData()); - - // This socket is being deleted; skip this event - if (!connection) - return; - - if ( evt == wxSOCKET_LOST ) - { - HandleDisconnect(connection); - return; - } - - // Receive message number. - wxIPCSocketStreams * const streams = connection->m_streams; - - const wxString topic = connection->m_topic; - wxString item; - - bool error = false; - - const int msg = streams->Read8(); - switch ( msg ) - { - case IPC_EXECUTE: - { - wxIPCFormat format; - size_t size wxDUMMY_INITIALIZE(0); - void * const - data = streams->ReadFormatData(connection, &format, &size); - if ( data ) - connection->OnExecute(topic, data, size, format); - else - error = true; - } - break; - - case IPC_ADVISE: - { - item = streams->ReadString(); - - wxIPCFormat format; - size_t size wxDUMMY_INITIALIZE(0); - void * const - data = streams->ReadFormatData(connection, &format, &size); - - if ( data ) - connection->OnAdvise(topic, item, data, size, format); - else - error = true; - } - break; - - case IPC_ADVISE_START: - { - item = streams->ReadString(); - - IPCOutput(streams).Write8(connection->OnStartAdvise(topic, item) - ? IPC_ADVISE_START - : IPC_FAIL); - } - break; - - case IPC_ADVISE_STOP: - { - item = streams->ReadString(); - - IPCOutput(streams).Write8(connection->OnStopAdvise(topic, item) - ? IPC_ADVISE_STOP - : IPC_FAIL); - } - break; - - case IPC_POKE: - { - item = streams->ReadString(); - wxIPCFormat format = (wxIPCFormat)streams->Read8(); - - size_t size wxDUMMY_INITIALIZE(0); - void * const data = streams->ReadData(connection, &size); - - if ( data ) - connection->OnPoke(topic, item, data, size, format); - else - error = true; - } - break; - - case IPC_REQUEST: - { - item = streams->ReadString(); - - wxIPCFormat format = (wxIPCFormat)streams->Read8(); - - size_t user_size = wxNO_LEN; - const void *user_data = connection->OnRequest(topic, - item, - &user_size, - format); - - if ( !user_data ) - { - IPCOutput(streams).Write8(IPC_FAIL); - break; - } - - IPCOutput out(streams); - out.Write8(IPC_REQUEST_REPLY); - - if ( user_size == wxNO_LEN ) - { - switch ( format ) - { - case wxIPC_TEXT: - case wxIPC_UTF8TEXT: - user_size = strlen((const char *)user_data) + 1; // includes final NUL - break; - case wxIPC_UNICODETEXT: - user_size = (wcslen((const wchar_t *)user_data) + 1) * sizeof(wchar_t); // includes final NUL - break; - default: - user_size = 0; - } - } - - out.WriteData(user_data, user_size); - } - break; - - case IPC_DISCONNECT: - HandleDisconnect(connection); - break; - - case IPC_FAIL: - wxLogDebug("Unexpected IPC_FAIL received"); - error = true; - break; - - default: - wxLogDebug("Unknown message code %d received.", msg); - error = true; - break; - } - - if ( error ) - IPCOutput(streams).Write8(IPC_FAIL); -} - -void wxTCPEventHandler::Server_OnRequest(wxSocketEvent &event) -{ - wxSocketServer *server = (wxSocketServer *) event.GetSocket(); - if (!server) - return; - wxTCPServer *ipcserv = (wxTCPServer *) server->GetClientData(); - - // This socket is being deleted; skip this event - if (!ipcserv) - return; - - if (event.GetSocketEvent() != wxSOCKET_CONNECTION) - return; - - // Accept the connection, getting a new socket - wxSocketBase *sock = server->Accept(); - if (!sock) - return; - if (!sock->IsOk()) - { - sock->Destroy(); - return; - } - - wxIPCSocketStreams *streams = new wxIPCSocketStreams(*sock); - - { - IPCOutput out(streams); - - const int msg = streams->Read8(); - if ( msg == IPC_CONNECT ) - { - const wxString topic = streams->ReadString(); - - wxTCPConnection *new_connection = - (wxTCPConnection *)ipcserv->OnAcceptConnection (topic); - - if (new_connection) - { - if (wxDynamicCast(new_connection, wxTCPConnection)) - { - // Acknowledge success - out.Write8(IPC_CONNECT); - - new_connection->m_sock = sock; - new_connection->m_streams = streams; - new_connection->m_topic = topic; - sock->SetEventHandler(wxTCPEventHandlerModule::GetHandler(), - _CLIENT_ONREQUEST_ID); - sock->SetClientData(new_connection); - sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); - sock->Notify(true); - return; - } - else - { - delete new_connection; - // and fall through to delete everything else - } - } - } - - // Something went wrong, send failure message and delete everything - out.Write8(IPC_FAIL); - } // IPCOutput object is destroyed here, before destroying stream - - delete streams; - sock->Destroy(); -} - -#endif // wxUSE_SOCKETS && wxUSE_IPC && wxUSE_STREAMS diff --git a/Source/3rd Party/wx/src/common/sckstrm.cpp b/Source/3rd Party/wx/src/common/sckstrm.cpp deleted file mode 100644 index 8f64727d7..000000000 --- a/Source/3rd Party/wx/src/common/sckstrm.cpp +++ /dev/null @@ -1,87 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/sckstrm.cpp -// Purpose: wxSocket*Stream -// Author: Guilhem Lavaux -// Modified by: -// Created: 17/07/97 -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SOCKETS && wxUSE_STREAMS - -#include "wx/sckstrm.h" - -#ifndef WX_PRECOMP - #include "wx/stream.h" -#endif - -#include "wx/socket.h" - -// --------------------------------------------------------------------------- -// wxSocketOutputStream -// --------------------------------------------------------------------------- - -wxSocketOutputStream::wxSocketOutputStream(wxSocketBase& s) - : m_o_socket(&s) -{ -} - -wxSocketOutputStream::~wxSocketOutputStream() -{ -} - -size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size) -{ - const size_t ret = m_o_socket->Write(buffer, size).LastCount(); - m_lasterror = m_o_socket->Error() - ? m_o_socket->IsClosed() ? wxSTREAM_EOF - : wxSTREAM_WRITE_ERROR - : wxSTREAM_NO_ERROR; - return ret; -} - -// --------------------------------------------------------------------------- -// wxSocketInputStream -// --------------------------------------------------------------------------- - -wxSocketInputStream::wxSocketInputStream(wxSocketBase& s) - : m_i_socket(&s) -{ -} - -wxSocketInputStream::~wxSocketInputStream() -{ -} - -size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size) -{ - const size_t ret = m_i_socket->Read(buffer, size).LastCount(); - m_lasterror = m_i_socket->Error() - ? m_i_socket->IsClosed() ? wxSTREAM_EOF - : wxSTREAM_READ_ERROR - : wxSTREAM_NO_ERROR; - return ret; -} - -// --------------------------------------------------------------------------- -// wxSocketStream -// --------------------------------------------------------------------------- - -wxSocketStream::wxSocketStream(wxSocketBase& s) - : wxSocketInputStream(s), wxSocketOutputStream(s) -{ -} - -wxSocketStream::~wxSocketStream() -{ -} - -#endif // wxUSE_STREAMS && wxUSE_SOCKETS diff --git a/Source/3rd Party/wx/src/common/scrolbarcmn.cpp b/Source/3rd Party/wx/src/common/scrolbarcmn.cpp deleted file mode 100644 index 65db8fb2d..000000000 --- a/Source/3rd Party/wx/src/common/scrolbarcmn.cpp +++ /dev/null @@ -1,91 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/scrolbarcmn.cpp -// Purpose: wxScrollBar common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SCROLLBAR - -#include "wx/scrolbar.h" - -#ifndef WX_PRECOMP - #include "wx/utils.h" - #include "wx/settings.h" -#endif - -extern WXDLLEXPORT_DATA(const char) wxScrollBarNameStr[] = "scrollBar"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxScrollBarStyle ) -wxBEGIN_FLAGS( wxScrollBarStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxSB_HORIZONTAL) - wxFLAGS_MEMBER(wxSB_VERTICAL) -wxEND_FLAGS( wxScrollBarStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxScrollBar, wxControl, "wx/scrolbar.h") - -wxBEGIN_PROPERTIES_TABLE(wxScrollBar) - wxEVENT_RANGE_PROPERTY( Scroll, wxEVT_SCROLL_TOP, \ - wxEVT_SCROLL_CHANGED, wxScrollEvent ) - - wxPROPERTY( ThumbPosition, int, SetThumbPosition, GetThumbPosition, 0, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( Range, int, SetRange, GetRange, 0, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( ThumbSize, int, SetThumbSize, GetThumbSize, 0, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - wxPROPERTY( PageSize, int, SetPageSize, GetPageSize, 0, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - - wxPROPERTY_FLAGS( WindowStyle, wxScrollBarStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxScrollBar) - -wxCONSTRUCTOR_5( wxScrollBar, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle ) - -#endif // wxUSE_SCROLLBAR diff --git a/Source/3rd Party/wx/src/common/selectdispatcher.cpp b/Source/3rd Party/wx/src/common/selectdispatcher.cpp deleted file mode 100644 index db763eca3..000000000 --- a/Source/3rd Party/wx/src/common/selectdispatcher.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/selectdispatcher.cpp -// Purpose: implements dispatcher for select() call -// Author: Lukasz Michalski and Vadim Zeitlin -// Created: December 2006 -// Copyright: (c) 2006 Lukasz Michalski -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SELECT_DISPATCHER - -#include "wx/private/selectdispatcher.h" -#include "wx/unix/private.h" - -#ifndef WX_PRECOMP - #include "wx/hash.h" - #include "wx/log.h" - #include "wx/intl.h" -#endif - -#include - -#define wxSelectDispatcher_Trace wxT("selectdispatcher") - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxSelectSets -// ---------------------------------------------------------------------------- - -int wxSelectSets::ms_flags[wxSelectSets::Max] = -{ - wxFDIO_INPUT, - wxFDIO_OUTPUT, - wxFDIO_EXCEPTION, -}; - -const char *wxSelectSets::ms_names[wxSelectSets::Max] = -{ - "input", - "output", - "exceptional", -}; - -wxSelectSets::Callback wxSelectSets::ms_handlers[wxSelectSets::Max] = -{ - &wxFDIOHandler::OnReadWaiting, - &wxFDIOHandler::OnWriteWaiting, - &wxFDIOHandler::OnExceptionWaiting, -}; - -wxSelectSets::wxSelectSets() -{ - for ( int n = 0; n < Max; n++ ) - { - wxFD_ZERO(&m_fds[n]); - } -} - -bool wxSelectSets::HasFD(int fd) const -{ - for ( int n = 0; n < Max; n++ ) - { - if ( wxFD_ISSET(fd, (fd_set*) &m_fds[n]) ) - return true; - } - - return false; -} - -bool wxSelectSets::SetFD(int fd, int flags) -{ - wxCHECK_MSG( fd >= 0, false, wxT("invalid descriptor") ); - - for ( int n = 0; n < Max; n++ ) - { - if ( flags & ms_flags[n] ) - { - wxFD_SET(fd, &m_fds[n]); - } - else if ( wxFD_ISSET(fd, (fd_set*) &m_fds[n]) ) - { - wxFD_CLR(fd, &m_fds[n]); - } - } - - return true; -} - -int wxSelectSets::Select(int nfds, struct timeval *tv) -{ - return select(nfds, &m_fds[Read], &m_fds[Write], &m_fds[Except], tv); -} - -bool wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const -{ - for ( int n = 0; n < Max; n++ ) - { - if ( wxFD_ISSET(fd, (fd_set*) &m_fds[n]) ) - { - wxLogTrace(wxSelectDispatcher_Trace, - wxT("Got %s event on fd %d"), ms_names[n], fd); - (handler.*ms_handlers[n])(); - // callback can modify sets and destroy handler - // this forces that one event can be processed at one time - return true; - } - } - - return false; -} - -// ---------------------------------------------------------------------------- -// wxSelectDispatcher -// ---------------------------------------------------------------------------- - -bool wxSelectDispatcher::RegisterFD(int fd, wxFDIOHandler *handler, int flags) -{ - if ( !wxMappedFDIODispatcher::RegisterFD(fd, handler, flags) ) - return false; - - if ( !m_sets.SetFD(fd, flags) ) - return false; - - if ( fd > m_maxFD ) - m_maxFD = fd; - - wxLogTrace(wxSelectDispatcher_Trace, - wxT("Registered fd %d: input:%d, output:%d, exceptional:%d"), fd, (flags & wxFDIO_INPUT) == wxFDIO_INPUT, (flags & wxFDIO_OUTPUT), (flags & wxFDIO_EXCEPTION) == wxFDIO_EXCEPTION); - return true; -} - -bool wxSelectDispatcher::ModifyFD(int fd, wxFDIOHandler *handler, int flags) -{ - if ( !wxMappedFDIODispatcher::ModifyFD(fd, handler, flags) ) - return false; - - wxASSERT_MSG( fd <= m_maxFD, wxT("logic error: registered fd > m_maxFD?") ); - - wxLogTrace(wxSelectDispatcher_Trace, - wxT("Modified fd %d: input:%d, output:%d, exceptional:%d"), fd, (flags & wxFDIO_INPUT) == wxFDIO_INPUT, (flags & wxFDIO_OUTPUT) == wxFDIO_OUTPUT, (flags & wxFDIO_EXCEPTION) == wxFDIO_EXCEPTION); - return m_sets.SetFD(fd, flags); -} - -bool wxSelectDispatcher::UnregisterFD(int fd) -{ - m_sets.ClearFD(fd); - - if ( !wxMappedFDIODispatcher::UnregisterFD(fd) ) - return false; - - // remove the handler if we don't need it any more - if ( !m_sets.HasFD(fd) ) - { - if ( fd == m_maxFD ) - { - // need to find new max fd - m_maxFD = -1; - for ( wxFDIOHandlerMap::const_iterator it = m_handlers.begin(); - it != m_handlers.end(); - ++it ) - { - if ( it->first > m_maxFD ) - { - m_maxFD = it->first; - } - } - } - } - - wxLogTrace(wxSelectDispatcher_Trace, - wxT("Removed fd %d, current max: %d"), fd, m_maxFD); - return true; -} - -int wxSelectDispatcher::ProcessSets(const wxSelectSets& sets) -{ - int numEvents = 0; - for ( int fd = 0; fd <= m_maxFD; fd++ ) - { - if ( !sets.HasFD(fd) ) - continue; - - wxFDIOHandler * const handler = FindHandler(fd); - if ( !handler ) - { - wxFAIL_MSG( wxT("NULL handler in wxSelectDispatcher?") ); - continue; - } - - if ( sets.Handle(fd, *handler) ) - numEvents++; - } - - return numEvents; -} - -int wxSelectDispatcher::DoSelect(wxSelectSets& sets, int timeout) const -{ - struct timeval tv, - *ptv; - if ( timeout != TIMEOUT_INFINITE ) - { - ptv = &tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000)*1000; - } - else // no timeout - { - ptv = NULL; - } - - int ret = sets.Select(m_maxFD + 1, ptv); - - // TODO: we need to restart select() in this case but for now just return - // as if timeout expired - if ( ret == -1 && errno == EINTR ) - ret = 0; - - return ret; -} - -bool wxSelectDispatcher::HasPending() const -{ - wxSelectSets sets(m_sets); - return DoSelect(sets, 0) > 0; -} - -int wxSelectDispatcher::Dispatch(int timeout) -{ - wxSelectSets sets(m_sets); - switch ( DoSelect(sets, timeout) ) - { - case -1: - wxLogSysError(_("Failed to monitor I/O channels")); - return -1; - - case 0: - // timeout expired without anything happening - return 0; - - default: - return ProcessSets(sets); - } -} - -#endif // wxUSE_SELECT_DISPATCHER diff --git a/Source/3rd Party/wx/src/common/settcmn.cpp b/Source/3rd Party/wx/src/common/settcmn.cpp index c9c011d5f..334a8f8b8 100644 --- a/Source/3rd Party/wx/src/common/settcmn.cpp +++ b/Source/3rd Party/wx/src/common/settcmn.cpp @@ -2,6 +2,7 @@ // Name: src/common/settcmn.cpp // Purpose: common (to all ports) wxWindow functions // Author: Robert Roebling +// RCS-ID: $Id: settcmn.cpp 39310 2006-05-24 07:16:32Z ABX $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -66,3 +67,22 @@ void wxSystemSettings::SetScreenType( wxSystemScreenType screen ) { ms_screen = screen; } + +#if WXWIN_COMPATIBILITY_2_4 + +wxColour wxSystemSettings::GetSystemColour(int index) +{ + return GetColour((wxSystemColour)index); +} + +wxFont wxSystemSettings::GetSystemFont(int index) +{ + return GetFont((wxSystemFont)index); +} + +int wxSystemSettings::GetSystemMetric(int index) +{ + return GetMetric((wxSystemMetric)index); +} + +#endif // WXWIN_COMPATIBILITY_2_4 diff --git a/Source/3rd Party/wx/src/common/sizer.cpp b/Source/3rd Party/wx/src/common/sizer.cpp index 6f810e3e4..34a649aaa 100644 --- a/Source/3rd Party/wx/src/common/sizer.cpp +++ b/Source/3rd Party/wx/src/common/sizer.cpp @@ -5,6 +5,7 @@ // Dirk Holtwick, Ron Lee // Modified by: Ron Lee // Created: +// RCS-ID: $Id: sizer.cpp 66936 2011-02-17 09:52:57Z JS $ // Copyright: (c) Robin Dunn, Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,8 +17,8 @@ #pragma hdrstop #endif +#include "wx/display.h" #include "wx/sizer.h" -#include "wx/private/flagscheck.h" #ifndef WX_PRECOMP #include "wx/string.h" @@ -30,10 +31,11 @@ #include "wx/toplevel.h" #endif // WX_PRECOMP -#include "wx/display.h" -#include "wx/vector.h" #include "wx/listimpl.cpp" +#if WXWIN_COMPATIBILITY_2_4 + #include "wx/notebook.h" +#endif //--------------------------------------------------------------------------- @@ -84,35 +86,21 @@ WX_DEFINE_EXPORTED_LIST( wxSizerItemList ) minsize */ + +// ---------------------------------------------------------------------------- +// wxSizerFlags +// ---------------------------------------------------------------------------- + +wxSizerFlags& wxSizerFlags::ReserveSpaceEvenIfHidden() +{ + m_flags |= wxRESERVE_SPACE_EVEN_IF_HIDDEN; + return *this; +} + // ---------------------------------------------------------------------------- // wxSizerItem // ---------------------------------------------------------------------------- -// check for flags conflicts -static const int SIZER_FLAGS_MASK = - wxADD_FLAG(wxCENTRE, - wxADD_FLAG(wxHORIZONTAL, - wxADD_FLAG(wxVERTICAL, - wxADD_FLAG(wxLEFT, - wxADD_FLAG(wxRIGHT, - wxADD_FLAG(wxUP, - wxADD_FLAG(wxDOWN, - wxADD_FLAG(wxALIGN_NOT, - wxADD_FLAG(wxALIGN_CENTER_HORIZONTAL, - wxADD_FLAG(wxALIGN_RIGHT, - wxADD_FLAG(wxALIGN_BOTTOM, - wxADD_FLAG(wxALIGN_CENTER_VERTICAL, - wxADD_FLAG(wxFIXED_MINSIZE, - wxADD_FLAG(wxRESERVE_SPACE_EVEN_IF_HIDDEN, - wxADD_FLAG(wxSTRETCH_NOT, - wxADD_FLAG(wxSHRINK, - wxADD_FLAG(wxGROW, - wxADD_FLAG(wxSHAPED, - 0)))))))))))))))))); - -#define ASSERT_VALID_SIZER_FLAGS(f) wxASSERT_VALID_FLAGS(f, SIZER_FLAGS_MASK) - - void wxSizerItem::Init(const wxSizerFlags& flags) { Init(); @@ -120,8 +108,6 @@ void wxSizerItem::Init(const wxSizerFlags& flags) m_proportion = flags.GetProportion(); m_flag = flags.GetFlags(); m_border = flags.GetBorderInPixels(); - - ASSERT_VALID_SIZER_FLAGS( m_flag ); } wxSizerItem::wxSizerItem() @@ -131,13 +117,14 @@ wxSizerItem::wxSizerItem() m_proportion = 0; m_border = 0; m_flag = 0; - m_id = wxID_NONE; + + m_kind = Item_None; } // window item -void wxSizerItem::DoSetWindow(wxWindow *window) +void wxSizerItem::SetWindow(wxWindow *window) { - wxCHECK_RET( window, wxT("NULL window in wxSizerItem::SetWindow()") ); + wxCHECK_RET( window, _T("NULL window in wxSizerItem::SetWindow()") ); m_kind = Item_Window; m_window = window; @@ -157,20 +144,16 @@ wxSizerItem::wxSizerItem(wxWindow *window, int flag, int border, wxObject* userData) - : m_kind(Item_None), - m_proportion(proportion), + : m_proportion(proportion), m_border(border), m_flag(flag), - m_id(wxID_NONE), m_userData(userData) { - ASSERT_VALID_SIZER_FLAGS( m_flag ); - - DoSetWindow(window); + SetWindow(window); } // sizer item -void wxSizerItem::DoSetSizer(wxSizer *sizer) +void wxSizerItem::SetSizer(wxSizer *sizer) { m_kind = Item_Sizer; m_sizer = sizer; @@ -181,24 +164,19 @@ wxSizerItem::wxSizerItem(wxSizer *sizer, int flag, int border, wxObject* userData) - : m_kind(Item_None), - m_sizer(NULL), - m_proportion(proportion), + : m_proportion(proportion), m_border(border), m_flag(flag), - m_id(wxID_NONE), m_ratio(0.0), m_userData(userData) { - ASSERT_VALID_SIZER_FLAGS( m_flag ); - - DoSetSizer(sizer); + SetSizer(sizer); // m_minSize is set later } // spacer item -void wxSizerItem::DoSetSpacer(const wxSize& size) +void wxSizerItem::SetSpacer(const wxSize& size) { m_kind = Item_Spacer; m_spacer = new wxSizerSpacer(size); @@ -206,61 +184,25 @@ void wxSizerItem::DoSetSpacer(const wxSize& size) SetRatio(size); } -wxSize wxSizerItem::AddBorderToSize(const wxSize& size) const -{ - wxSize result = size; - - // Notice that we shouldn't modify the unspecified component(s) of the - // size, it's perfectly valid to have either min or max size specified in - // one direction only and it shouldn't be applied in the other one then. - - if ( result.x != wxDefaultCoord ) - { - if (m_flag & wxWEST) - result.x += m_border; - if (m_flag & wxEAST) - result.x += m_border; - } - - if ( result.y != wxDefaultCoord ) - { - if (m_flag & wxNORTH) - result.y += m_border; - if (m_flag & wxSOUTH) - result.y += m_border; - } - - return result; -} - wxSizerItem::wxSizerItem(int width, int height, int proportion, int flag, int border, wxObject* userData) - : m_kind(Item_None), - m_sizer(NULL), - m_minSize(width, height), // minimal size is the initial size + : m_minSize(width, height), // minimal size is the initial size m_proportion(proportion), m_border(border), m_flag(flag), - m_id(wxID_NONE), m_userData(userData) { - ASSERT_VALID_SIZER_FLAGS( m_flag ); - - DoSetSpacer(wxSize(width, height)); + SetSpacer(width, height); } wxSizerItem::~wxSizerItem() { delete m_userData; - Free(); -} -void wxSizerItem::Free() -{ switch ( m_kind ) { case Item_None: @@ -280,10 +222,8 @@ void wxSizerItem::Free() case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } - - m_kind = Item_None; } wxSize wxSizerItem::GetSpacer() const @@ -318,7 +258,7 @@ wxSize wxSizerItem::GetSize() const case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } if (m_flag & wxWEST) @@ -333,73 +273,6 @@ wxSize wxSizerItem::GetSize() const return ret; } -bool wxSizerItem::InformFirstDirection(int direction, int size, int availableOtherDir) -{ - // The size that come here will be including borders. Child items should get it - // without borders. - if( size>0 ) - { - if( direction==wxHORIZONTAL ) - { - if (m_flag & wxWEST) - size -= m_border; - if (m_flag & wxEAST) - size -= m_border; - } - else if( direction==wxVERTICAL ) - { - if (m_flag & wxNORTH) - size -= m_border; - if (m_flag & wxSOUTH) - size -= m_border; - } - } - - bool didUse = false; - // Pass the information along to the held object - if (IsSizer()) - { - didUse = GetSizer()->InformFirstDirection(direction,size,availableOtherDir); - if (didUse) - m_minSize = GetSizer()->CalcMin(); - } - else if (IsWindow()) - { - didUse = GetWindow()->InformFirstDirection(direction,size,availableOtherDir); - if (didUse) - m_minSize = m_window->GetEffectiveMinSize(); - - // This information is useful for items with wxSHAPED flag, since - // we can request an optimal min size for such an item. Even if - // we overwrite the m_minSize member here, we can read it back from - // the owned window (happens automatically). - if( (m_flag & wxSHAPED) && (m_flag & wxEXPAND) && direction ) - { - if( !wxIsNullDouble(m_ratio) ) - { - wxCHECK_MSG( (m_proportion==0), false, wxT("Shaped item, non-zero proportion in wxSizerItem::InformFirstDirection()") ); - if( direction==wxHORIZONTAL && !wxIsNullDouble(m_ratio) ) - { - // Clip size so that we don't take too much - if( availableOtherDir>=0 && int(size/m_ratio)-m_minSize.y>availableOtherDir ) - size = int((availableOtherDir+m_minSize.y)*m_ratio); - m_minSize = wxSize(size,int(size/m_ratio)); - } - else if( direction==wxVERTICAL ) - { - // Clip size so that we don't take too much - if( availableOtherDir>=0 && int(size*m_ratio)-m_minSize.x>availableOtherDir ) - size = int((availableOtherDir+m_minSize.x)/m_ratio); - m_minSize = wxSize(int(size*m_ratio),size); - } - didUse = true; - } - } - } - - return didUse; -} - wxSize wxSizerItem::CalcMin() { if (IsSizer()) @@ -423,13 +296,20 @@ wxSize wxSizerItem::CalcMin() wxSize wxSizerItem::GetMinSizeWithBorder() const { - return AddBorderToSize(m_minSize); + wxSize ret = m_minSize; + + if (m_flag & wxWEST) + ret.x += m_border; + if (m_flag & wxEAST) + ret.x += m_border; + if (m_flag & wxNORTH) + ret.y += m_border; + if (m_flag & wxSOUTH) + ret.y += m_border; + + return ret; } -wxSize wxSizerItem::GetMaxSizeWithBorder() const -{ - return AddBorderToSize(GetMaxSize()); -} void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ ) { @@ -496,27 +376,16 @@ void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ ) switch ( m_kind ) { case Item_None: - wxFAIL_MSG( wxT("can't set size of uninitialized sizer item") ); + wxFAIL_MSG( _T("can't set size of uninitialized sizer item") ); break; case Item_Window: - { - // Use wxSIZE_FORCE_EVENT here since a sizer item might - // have changed alignment or some other property which would - // not change the size of the window. In such a case, no - // wxSizeEvent would normally be generated and thus the - // control wouldn't get laid out correctly here. -#if 1 m_window->SetSize(pos.x, pos.y, size.x, size.y, - wxSIZE_ALLOW_MINUS_ONE|wxSIZE_FORCE_EVENT ); -#else - m_window->SetSize(pos.x, pos.y, size.x, size.y, - wxSIZE_ALLOW_MINUS_ONE ); -#endif + wxSIZE_ALLOW_MINUS_ONE); break; - } + case Item_Sizer: - m_sizer->SetDimension(pos, size); + m_sizer->SetDimension(pos.x, pos.y, size.x, size.y); break; case Item_Spacer: @@ -525,7 +394,7 @@ void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ ) case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } } @@ -554,7 +423,7 @@ void wxSizerItem::DeleteWindows() case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } } @@ -564,7 +433,7 @@ void wxSizerItem::Show( bool show ) switch ( m_kind ) { case Item_None: - wxFAIL_MSG( wxT("can't show uninitialized sizer item") ); + wxFAIL_MSG( _T("can't show uninitialized sizer item") ); break; case Item_Window: @@ -581,15 +450,12 @@ void wxSizerItem::Show( bool show ) case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } } bool wxSizerItem::IsShown() const { - if ( m_flag & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) - return true; - switch ( m_kind ) { case Item_None: @@ -604,19 +470,65 @@ bool wxSizerItem::IsShown() const // arbitrarily decide that if at least one of our elements is // shown, so are we (this arbitrariness is the reason for // deprecating this function) - return m_sizer->AreAnyItemsShown(); + { + // Some apps (such as dialog editors) depend on an empty sizer still + // being laid out correctly and reporting the correct size and position. + if (m_sizer->GetChildren().GetCount() == 0) + return true; + + for ( wxSizerItemList::compatibility_iterator + node = m_sizer->GetChildren().GetFirst(); + node; + node = node->GetNext() ) + { + if ( node->GetData()->IsShown() ) + return true; + } + } + return false; case Item_Spacer: return m_spacer->IsShown(); case Item_Max: default: - wxFAIL_MSG( wxT("unexpected wxSizerItem::m_kind") ); + wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") ); } return false; } +// This is a helper to support wxRESERVE_SPACE_EVEN_IF_HIDDEN. In wx 2.9+, +// this flag is respected by IsShown(), but not in wx 2.8. +bool wxSizerItem::ShouldAccountFor() const +{ + if ( m_flag & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) + return true; + + if ( IsSizer() ) + { + // this mirrors wxSizerItem::IsShown() code above + const wxSizerItemList& children = m_sizer->GetChildren(); + if ( children.GetCount() == 0 ) + return true; + + for ( wxSizerItemList::compatibility_iterator + node = children.GetFirst(); + node; + node = node->GetNext() ) + { + if ( node->GetData()->ShouldAccountFor() ) + return true; + } + return false; + } + else + { + return IsShown(); + } +} + + #if WXWIN_COMPATIBILITY_2_6 void wxSizerItem::SetOption( int option ) { @@ -639,7 +551,7 @@ wxSizer::~wxSizer() WX_CLEAR_LIST(wxSizerItemList, m_children); } -wxSizerItem* wxSizer::DoInsert( size_t index, wxSizerItem *item ) +wxSizerItem* wxSizer::Insert( size_t index, wxSizerItem *item ) { m_children.Insert( index, item ); @@ -684,7 +596,7 @@ bool wxSizer::Remove( wxWindow *window ) bool wxSizer::Remove( wxSizer *sizer ) { - wxASSERT_MSG( sizer, wxT("Removing NULL sizer") ); + wxASSERT_MSG( sizer, _T("Removing NULL sizer") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -708,21 +620,25 @@ bool wxSizer::Remove( int index ) { wxCHECK_MSG( index >= 0 && (size_t)index < m_children.GetCount(), false, - wxT("Remove index is out of range") ); + _T("Remove index is out of range") ); wxSizerItemList::compatibility_iterator node = m_children.Item( index ); - wxCHECK_MSG( node, false, wxT("Failed to find child node") ); + wxCHECK_MSG( node, false, _T("Failed to find child node") ); - delete node->GetData(); + wxSizerItem *item = node->GetData(); + + if ( item->IsWindow() ) + item->GetWindow()->SetContainingSizer( NULL ); + + delete item; m_children.Erase( node ); - return true; } bool wxSizer::Detach( wxSizer *sizer ) { - wxASSERT_MSG( sizer, wxT("Detaching NULL sizer") ); + wxASSERT_MSG( sizer, _T("Detaching NULL sizer") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -744,7 +660,7 @@ bool wxSizer::Detach( wxSizer *sizer ) bool wxSizer::Detach( wxWindow *window ) { - wxASSERT_MSG( window, wxT("Detaching NULL window") ); + wxASSERT_MSG( window, _T("Detaching NULL window") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -753,6 +669,7 @@ bool wxSizer::Detach( wxWindow *window ) if (item->GetWindow() == window) { + item->GetWindow()->SetContainingSizer( NULL ); delete item; m_children.Erase( node ); return true; @@ -767,16 +684,18 @@ bool wxSizer::Detach( int index ) { wxCHECK_MSG( index >= 0 && (size_t)index < m_children.GetCount(), false, - wxT("Detach index is out of range") ); + _T("Detach index is out of range") ); wxSizerItemList::compatibility_iterator node = m_children.Item( index ); - wxCHECK_MSG( node, false, wxT("Failed to find child node") ); + wxCHECK_MSG( node, false, _T("Failed to find child node") ); wxSizerItem *item = node->GetData(); if ( item->IsSizer() ) item->DetachSizer(); + else if ( item->IsWindow() ) + item->GetWindow()->SetContainingSizer( NULL ); delete item; m_children.Erase( node ); @@ -785,8 +704,8 @@ bool wxSizer::Detach( int index ) bool wxSizer::Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive ) { - wxASSERT_MSG( oldwin, wxT("Replacing NULL window") ); - wxASSERT_MSG( newwin, wxT("Replacing with NULL window") ); + wxASSERT_MSG( oldwin, _T("Replacing NULL window") ); + wxASSERT_MSG( newwin, _T("Replacing with NULL window") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -795,7 +714,8 @@ bool wxSizer::Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive ) if (item->GetWindow() == oldwin) { - item->AssignWindow(newwin); + item->GetWindow()->SetContainingSizer( NULL ); + item->SetWindow(newwin); newwin->SetContainingSizer( this ); return true; } @@ -813,8 +733,8 @@ bool wxSizer::Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive ) bool wxSizer::Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive ) { - wxASSERT_MSG( oldsz, wxT("Replacing NULL sizer") ); - wxASSERT_MSG( newsz, wxT("Replacing with NULL sizer") ); + wxASSERT_MSG( oldsz, _T("Replacing NULL sizer") ); + wxASSERT_MSG( newsz, _T("Replacing with NULL sizer") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -823,7 +743,9 @@ bool wxSizer::Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive ) if (item->GetSizer() == oldsz) { - item->AssignSizer(newsz); + wxSizer *old = item->GetSizer(); + item->SetSizer(newsz); + delete old; return true; } else if (recursive && item->IsSizer()) @@ -840,12 +762,12 @@ bool wxSizer::Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive ) bool wxSizer::Replace( size_t old, wxSizerItem *newitem ) { - wxCHECK_MSG( old < m_children.GetCount(), false, wxT("Replace index is out of range") ); - wxASSERT_MSG( newitem, wxT("Replacing with NULL item") ); + wxCHECK_MSG( old < m_children.GetCount(), false, _T("Replace index is out of range") ); + wxASSERT_MSG( newitem, _T("Replacing with NULL item") ); wxSizerItemList::compatibility_iterator node = m_children.Item( old ); - wxCHECK_MSG( node, false, wxT("Failed to find child node") ); + wxCHECK_MSG( node, false, _T("Failed to find child node") ); wxSizerItem *item = node->GetData(); node->SetData(newitem); @@ -891,13 +813,11 @@ void wxSizer::DeleteWindows() } } -wxSize wxSizer::ComputeFittingClientSize(wxWindow *window) +wxSize wxSizer::ComputeFittingWindowSize(wxWindow *window) { - wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" ); - // take the min size by default and limit it by max size - wxSize size = GetMinClientSize(window); - wxSize sizeMax; + wxSize size = GetMinWindowSize(window); + wxSize sizeMax = GetMaxWindowSize(window); wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow); if ( tlw ) @@ -905,56 +825,42 @@ wxSize wxSizer::ComputeFittingClientSize(wxWindow *window) // hack for small screen devices where TLWs are always full screen if ( tlw->IsAlwaysMaximized() ) { - return tlw->GetClientSize(); + size = tlw->GetSize(); } - - // limit the window to the size of the display it is on - int disp = wxDisplay::GetFromWindow(window); - if ( disp == wxNOT_FOUND ) + else // normal situation { - // or, if we don't know which one it is, of the main one - disp = 0; + // limit the window to the size of the display it is on + int disp = wxDisplay::GetFromWindow(window); + if ( disp == wxNOT_FOUND ) + { + // or, if we don't know which one it is, of the main one + disp = 0; + } + + sizeMax = wxDisplay(disp).GetClientArea().GetSize(); } - - sizeMax = wxDisplay(disp).GetClientArea().GetSize(); - - // If determining the display size failed, skip the max size checks as - // we really don't want to create windows of (0, 0) size. - if ( !sizeMax.x || !sizeMax.y ) - return size; - - // space for decorations and toolbars etc. - sizeMax = tlw->WindowToClientSize(sizeMax); - } - else - { - sizeMax = GetMaxClientSize(window); } if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x ) - size.x = sizeMax.x; + size.x = sizeMax.x; if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y ) - size.y = sizeMax.y; + size.y = sizeMax.y; return size; } -wxSize wxSizer::ComputeFittingWindowSize(wxWindow *window) +wxSize wxSizer::ComputeFittingClientSize(wxWindow *window) { - wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" ); + wxCHECK_MSG( window, wxDefaultSize, _T("window can't be NULL") ); - return window->ClientToWindowSize(ComputeFittingClientSize(window)); + return window->WindowToClientSize(ComputeFittingWindowSize(window)); } wxSize wxSizer::Fit( wxWindow *window ) { - wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" ); - - // set client size - window->SetClientSize(ComputeFittingClientSize(window)); - - // return entire size - return window->GetSize(); + wxSize size = ComputeFittingWindowSize(window); + window->SetSize(size); + return size; } void wxSizer::FitInside( wxWindow *window ) @@ -975,8 +881,6 @@ void wxSizer::Layout() CalcMin(); // Applies the layout and repositions/resizes the items - wxWindow::ChildrenRepositioningGuard repositionGuard(m_containingWindow); - RecalcSizes(); } @@ -987,29 +891,64 @@ void wxSizer::SetSizeHints( wxWindow *window ) // This is equivalent to calling Fit(), except that we need to set // the size hints _in between_ the two steps performed by Fit - // (1. ComputeFittingClientSize, 2. SetClientSize). That's because - // otherwise SetClientSize() could have no effect if there already are - // size hints in effect that forbid requested client size. + // (1. ComputeFittingWindowSize, 2. SetSize). That's because + // otherwise SetSize() could have no effect if there already are + // size hints in effect that forbid requested size. + const wxSize size = ComputeFittingWindowSize(window); - const wxSize clientSize = ComputeFittingClientSize(window); + window->SetSizeHints( size.x, + size.y, + window->GetMaxWidth(), + window->GetMaxHeight() ); - window->SetMinClientSize(clientSize); - window->SetClientSize(clientSize); + window->SetSize(size); } -#if WXWIN_COMPATIBILITY_2_8 void wxSizer::SetVirtualSizeHints( wxWindow *window ) { + // Preserve the window's max size hints, but set the + // lower bound according to the sizer calculations. + FitInside( window ); + wxSize size( window->GetVirtualSize() ); + window->SetVirtualSizeHints( size.x, + size.y, + window->GetMaxWidth(), + window->GetMaxHeight() ); +} + +wxSize wxSizer::GetMaxWindowSize( wxWindow *window ) const +{ + return window->GetMaxSize(); +} + +wxSize wxSizer::GetMinWindowSize( wxWindow *window ) +{ + wxSize minSize( GetMinSize() ); + wxSize size( window->GetSize() ); + wxSize client_size( window->GetClientSize() ); + + return wxSize( minSize.x+size.x-client_size.x, + minSize.y+size.y-client_size.y ); } -#endif // WXWIN_COMPATIBILITY_2_8 // TODO on mac we need a function that determines how much free space this // min size contains, in order to make sure that we have 20 pixels of free // space around the controls wxSize wxSizer::GetMaxClientSize( wxWindow *window ) const { - return window->WindowToClientSize(window->GetMaxSize()); + wxSize maxSize( window->GetMaxSize() ); + + if ( maxSize != wxDefaultSize ) + { + wxSize size( window->GetSize() ); + wxSize client_size( window->GetClientSize() ); + + return wxSize( maxSize.x + client_size.x - size.x, + maxSize.y + client_size.y - size.y ); + } + else + return wxDefaultSize; } wxSize wxSizer::GetMinClientSize( wxWindow *WXUNUSED(window) ) @@ -1032,6 +971,15 @@ wxSize wxSizer::VirtualFitSize( wxWindow *window ) return size; } +void wxSizer::SetDimension( int x, int y, int width, int height ) +{ + m_position.x = x; + m_position.y = y; + m_size.x = width; + m_size.y = height; + Layout(); +} + wxSize wxSizer::GetMinSize() { wxSize ret( CalcMin() ); @@ -1048,7 +996,7 @@ void wxSizer::DoSetMinSize( int width, int height ) bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) { - wxASSERT_MSG( window, wxT("SetMinSize for NULL window") ); + wxASSERT_MSG( window, _T("SetMinSize for NULL window") ); // Is it our immediate child? @@ -1086,7 +1034,7 @@ bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) bool wxSizer::DoSetItemMinSize( wxSizer *sizer, int width, int height ) { - wxASSERT_MSG( sizer, wxT("SetMinSize for NULL sizer") ); + wxASSERT_MSG( sizer, _T("SetMinSize for NULL sizer") ); // Is it our immediate child? @@ -1126,7 +1074,7 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) { wxSizerItemList::compatibility_iterator node = m_children.Item( index ); - wxCHECK_MSG( node, false, wxT("Failed to find child node") ); + wxCHECK_MSG( node, false, _T("Failed to find child node") ); wxSizerItem *item = node->GetData(); @@ -1146,7 +1094,7 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) wxSizerItem* wxSizer::GetItem( wxWindow *window, bool recursive ) { - wxASSERT_MSG( window, wxT("GetItem for NULL window") ); + wxASSERT_MSG( window, _T("GetItem for NULL window") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -1172,7 +1120,7 @@ wxSizerItem* wxSizer::GetItem( wxWindow *window, bool recursive ) wxSizerItem* wxSizer::GetItem( wxSizer *sizer, bool recursive ) { - wxASSERT_MSG( sizer, wxT("GetItem for NULL sizer") ); + wxASSERT_MSG( sizer, _T("GetItem for NULL sizer") ); wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) @@ -1200,38 +1148,11 @@ wxSizerItem* wxSizer::GetItem( size_t index ) { wxCHECK_MSG( index < m_children.GetCount(), NULL, - wxT("GetItem index is out of range") ); + _T("GetItem index is out of range") ); return m_children.Item( index )->GetData(); } -wxSizerItem* wxSizer::GetItemById( int id, bool recursive ) -{ - // This gets a sizer item by the id of the sizer item - // and NOT the id of a window if the item is a window. - - wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); - while (node) - { - wxSizerItem *item = node->GetData(); - - if (item->GetId() == id) - { - return item; - } - else if (recursive && item->IsSizer()) - { - wxSizerItem *subitem = item->GetSizer()->GetItemById( id, true ); - if (subitem) - return subitem; - } - - node = node->GetNext(); - } - - return NULL; -} - bool wxSizer::Show( wxWindow *window, bool show, bool recursive ) { wxSizerItem *item = GetItem( window, recursive ); @@ -1281,19 +1202,6 @@ void wxSizer::ShowItems( bool show ) } } -bool wxSizer::AreAnyItemsShown() const -{ - wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); - while (node) - { - if ( node->GetData()->IsShown() ) - return true; - node = node->GetNext(); - } - - return false; -} - bool wxSizer::IsShown( wxWindow *window ) const { wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); @@ -1308,7 +1216,7 @@ bool wxSizer::IsShown( wxWindow *window ) const node = node->GetNext(); } - wxFAIL_MSG( wxT("IsShown failed to find sizer item") ); + wxFAIL_MSG( _T("IsShown failed to find sizer item") ); return false; } @@ -1327,7 +1235,7 @@ bool wxSizer::IsShown( wxSizer *sizer ) const node = node->GetNext(); } - wxFAIL_MSG( wxT("IsShown failed to find sizer item") ); + wxFAIL_MSG( _T("IsShown failed to find sizer item") ); return false; } @@ -1336,7 +1244,7 @@ bool wxSizer::IsShown( size_t index ) const { wxCHECK_MSG( index < m_children.GetCount(), false, - wxT("IsShown index is out of range") ); + _T("IsShown index is out of range") ); return m_children.Item( index )->GetData()->IsShown(); } @@ -1346,85 +1254,44 @@ bool wxSizer::IsShown( size_t index ) const // wxGridSizer //--------------------------------------------------------------------------- -wxGridSizer::wxGridSizer( int cols, int vgap, int hgap ) - : m_rows( cols == 0 ? 1 : 0 ), - m_cols( cols ), - m_vgap( vgap ), - m_hgap( hgap ) -{ - wxASSERT(cols >= 0); -} - -wxGridSizer::wxGridSizer( int cols, const wxSize& gap ) - : m_rows( cols == 0 ? 1 : 0 ), - m_cols( cols ), - m_vgap( gap.GetHeight() ), - m_hgap( gap.GetWidth() ) -{ - wxASSERT(cols >= 0); -} - wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap ) - : m_rows( rows || cols ? rows : 1 ), - m_cols( cols ), - m_vgap( vgap ), - m_hgap( hgap ) + : m_rows( ( cols == 0 && rows == 0 ) ? 1 : rows ) + , m_cols( cols ) + , m_vgap( vgap ) + , m_hgap( hgap ) { - wxASSERT(rows >= 0 && cols >= 0); } -wxGridSizer::wxGridSizer( int rows, int cols, const wxSize& gap ) - : m_rows( rows || cols ? rows : 1 ), - m_cols( cols ), - m_vgap( gap.GetHeight() ), - m_hgap( gap.GetWidth() ) +wxGridSizer::wxGridSizer( int cols, int vgap, int hgap ) + : m_rows( cols == 0 ? 1 : 0 ) + , m_cols( cols ) + , m_vgap( vgap ) + , m_hgap( hgap ) { - wxASSERT(rows >= 0 && cols >= 0); -} - -wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item) -{ - // if only the number of columns or the number of rows is specified for a - // sizer, arbitrarily many items can be added to it but if both of them are - // fixed, then the sizer can't have more than that many items -- check for - // this here to ensure that we detect errors as soon as possible - if ( m_cols && m_rows ) - { - const int nitems = m_children.GetCount(); - if ( nitems == m_cols*m_rows ) - { - wxFAIL_MSG( - wxString::Format( - "too many items (%d > %d*%d) in grid sizer (maybe you " - "should omit the number of either rows or columns?)", - nitems + 1, m_cols, m_rows) - ); - - // additionally, continuing to use the specified number of columns - // and rows is not a good idea as callers of CalcRowsCols() expect - // that all sizer items can fit into m_cols-/m_rows-sized arrays - // which is not the case if there are too many items and results in - // crashes, so let it compute the number of rows automatically by - // forgetting the (wrong) number of rows specified (this also has a - // nice side effect of giving only one assert even if there are - // many more items than allowed in this sizer) - m_rows = 0; - } - } - - return wxSizer::DoInsert(index, item); } int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const { - const int nitems = m_children.GetCount(); + int nitems = m_children.GetCount(); + if ( nitems) + { + if ( m_cols ) + { + ncols = m_cols; + nrows = (nitems + m_cols - 1) / m_cols; + } + else if ( m_rows ) + { + ncols = (nitems + m_rows - 1) / m_rows; + nrows = m_rows; + } + else // 0 columns, 0 rows? + { + wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") ); - ncols = GetEffectiveColsCount(); - nrows = GetEffectiveRowsCount(); - - // Since Insert() checks for overpopulation, the following - // should only assert if the grid was shrunk via SetRows() / SetCols() - wxASSERT_MSG( nitems <= ncols*nrows, "logic error in wxGridSizer" ); + nrows = ncols = 0; + } + } return nitems; } @@ -1452,7 +1319,7 @@ void wxGridSizer::RecalcSizes() { wxSizerItemList::compatibility_iterator node = m_children.Item( i ); - wxASSERT_MSG( node, wxT("Failed to find SizerItemList node") ); + wxASSERT_MSG( node, _T("Failed to find SizerItemList node") ); SetItemBounds( node->GetData(), x, y, w, h); } @@ -1484,35 +1351,6 @@ wxSize wxGridSizer::CalcMin() node = node->GetNext(); } - // In case we have a nested sizer with a two step algo , give it - // a chance to adjust to that (we give it width component) - node = m_children.GetFirst(); - bool didChangeMinSize = false; - while (node) - { - wxSizerItem *item = node->GetData(); - didChangeMinSize |= item->InformFirstDirection( wxHORIZONTAL, w, -1 ); - - node = node->GetNext(); - } - - // And redo iteration in case min size changed - if( didChangeMinSize ) - { - node = m_children.GetFirst(); - w = h = 0; - while (node) - { - wxSizerItem *item = node->GetData(); - wxSize sz( item->GetMinSizeWithBorder() ); - - w = wxMax( w, sz.x ); - h = wxMax( h, sz.y ); - - node = node->GetNext(); - } - } - return wxSize( ncols * w + (ncols-1) * m_hgap, nrows * h + (nrows-1) * m_vgap ); } @@ -1555,20 +1393,6 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) // wxFlexGridSizer //--------------------------------------------------------------------------- -wxFlexGridSizer::wxFlexGridSizer( int cols, int vgap, int hgap ) - : wxGridSizer( cols, vgap, hgap ), - m_flexDirection(wxBOTH), - m_growMode(wxFLEX_GROWMODE_SPECIFIED) -{ -} - -wxFlexGridSizer::wxFlexGridSizer( int cols, const wxSize& gap ) - : wxGridSizer( cols, gap ), - m_flexDirection(wxBOTH), - m_growMode(wxFLEX_GROWMODE_SPECIFIED) -{ -} - wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, int vgap, int hgap ) : wxGridSizer( rows, cols, vgap, hgap ), m_flexDirection(wxBOTH), @@ -1576,8 +1400,8 @@ wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, int vgap, int hgap ) { } -wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, const wxSize& gap ) - : wxGridSizer( rows, cols, gap ), +wxFlexGridSizer::wxFlexGridSizer( int cols, int vgap, int hgap ) + : wxGridSizer( cols, vgap, hgap ), m_flexDirection(wxBOTH), m_growMode(wxFLEX_GROWMODE_SPECIFIED) { @@ -1589,158 +1413,105 @@ wxFlexGridSizer::~wxFlexGridSizer() void wxFlexGridSizer::RecalcSizes() { - int nrows, ncols; - if ( !CalcRowsCols(nrows, ncols) ) + int nitems, nrows, ncols; + if ( (nitems = CalcRowsCols(nrows, ncols)) == 0 ) return; - const wxPoint pt(GetPosition()); - const wxSize sz(GetSize()); + wxPoint pt( GetPosition() ); + wxSize sz( GetSize() ); - AdjustForGrowables(sz); + AdjustForGrowables(sz, m_calculatedMinSize, nrows, ncols); - wxSizerItemList::const_iterator i = m_children.begin(); - const wxSizerItemList::const_iterator end = m_children.end(); + sz = wxSize( pt.x + sz.x, pt.y + sz.y ); - int y = 0; - for ( int r = 0; r < nrows; r++ ) + int x = pt.x; + for (int c = 0; c < ncols; c++) { - if ( m_rowHeights[r] == -1 ) + int y = pt.y; + for (int r = 0; r < nrows; r++) { - // this row is entirely hidden, skip it - for ( int c = 0; c < ncols; c++ ) + int i = r * ncols + c; + if (i < nitems) { - if ( i == end ) - return; + wxSizerItemList::compatibility_iterator node = m_children.Item( i ); - ++i; + wxASSERT_MSG( node, _T("Failed to find node") ); + + int w = wxMax( 0, wxMin( m_colWidths[c], sz.x - x ) ); + int h = wxMax( 0, wxMin( m_rowHeights[r], sz.y - y ) ); + + SetItemBounds( node->GetData(), x, y, w, h); } - - continue; + if (m_rowHeights[r] != -1) + y = y + m_rowHeights[r] + m_vgap; } - - const int hrow = m_rowHeights[r]; - int h = sz.y - y; // max remaining height, don't overflow it - if ( hrow < h ) - h = hrow; - - int x = 0; - for ( int c = 0; c < ncols && i != end; c++, ++i ) - { - const int wcol = m_colWidths[c]; - - if ( wcol == -1 ) - continue; - - int w = sz.x - x; // max possible value, ensure we don't overflow - if ( wcol < w ) - w = wcol; - - SetItemBounds(*i, pt.x + x, pt.y + y, w, h); - - x += wcol + m_hgap; - } - - if ( i == end ) - return; - - y += hrow + m_vgap; + if (m_colWidths[c] != -1) + x = x + m_colWidths[c] + m_hgap; } } -// helper function used in CalcMin() to sum up the sizes of non-hidden items -static int SumArraySizes(const wxArrayInt& sizes, int gap) -{ - // Sum total minimum size, including gaps between rows/columns. - // -1 is used as a magic number meaning empty row/column. - int total = 0; - - const size_t count = sizes.size(); - for ( size_t n = 0; n < count; n++ ) - { - if ( sizes[n] != -1 ) - { - if ( total ) - total += gap; // separate from the previous column - - total += sizes[n]; - } - } - - return total; -} - -void wxFlexGridSizer::FindWidthsAndHeights(int nrows, int ncols) -{ - // We have to recalculate the sizes in case the item minimum size has - // changed since the previous layout, or the item has been hidden using - // wxSizer::Show(). If all the items in a row/column are hidden, the final - // dimension of the row/column will be -1, indicating that the column - // itself is hidden. - m_rowHeights.assign(nrows, -1); - m_colWidths.assign(ncols, -1); - - // n is the index of the item in left-to-right top-to-bottom order - size_t n = 0; - for ( wxSizerItemList::iterator i = m_children.begin(); - i != m_children.end(); - ++i, ++n ) - { - wxSizerItem * const item = *i; - if ( item->IsShown() ) - { - // NOTE: Not doing the calculation here, this is just - // for finding max values. - const wxSize sz(item->GetMinSizeWithBorder()); - - const int row = n / ncols; - const int col = n % ncols; - - if ( sz.y > m_rowHeights[row] ) - m_rowHeights[row] = sz.y; - if ( sz.x > m_colWidths[col] ) - m_colWidths[col] = sz.x; - } - } - - AdjustForFlexDirection(); - - m_calculatedMinSize = wxSize(SumArraySizes(m_colWidths, m_hgap), - SumArraySizes(m_rowHeights, m_vgap)); -} - wxSize wxFlexGridSizer::CalcMin() { - int nrows, - ncols; + int nrows, + ncols; + size_t i, s; // Number of rows/columns can change as items are added or removed. if ( !CalcRowsCols(nrows, ncols) ) return wxSize(); + m_rowHeights.SetCount(nrows); + m_colWidths.SetCount(ncols); - // We have to recalculate the sizes in case the item minimum size has + // We have to recalcuate the sizes in case the item minimum size has // changed since the previous layout, or the item has been hidden using // wxSizer::Show(). If all the items in a row/column are hidden, the final // dimension of the row/column will be -1, indicating that the column // itself is hidden. - m_rowHeights.assign(nrows, -1); - m_colWidths.assign(ncols, -1); + for( s = m_rowHeights.GetCount(), i = 0; i < s; ++i ) + m_rowHeights[ i ] = -1; + for( s = m_colWidths.GetCount(), i = 0; i < s; ++i ) + m_colWidths[ i ] = -1; - for ( wxSizerItemList::iterator i = m_children.begin(); - i != m_children.end(); - ++i) + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + + i = 0; + while (node) { - wxSizerItem * const item = *i; - if ( item->IsShown() ) + wxSizerItem *item = node->GetData(); + if ( item->ShouldAccountFor() ) { - item->CalcMin(); + wxSize sz( item->CalcMin() ); + int row = i / ncols; + int col = i % ncols; + + m_rowHeights[ row ] = wxMax( wxMax( 0, sz.y ), m_rowHeights[ row ] ); + m_colWidths[ col ] = wxMax( wxMax( 0, sz.x ), m_colWidths[ col ] ); } + + node = node->GetNext(); + i++; } - // The stage of looking for max values in each row/column has been - // made a separate function, since it's reused in AdjustForGrowables. - FindWidthsAndHeights(nrows,ncols); + AdjustForFlexDirection(); + // Sum total minimum size, including gaps between rows/columns. + // -1 is used as a magic number meaning empty column. + int width = 0; + for (int col = 0; col < ncols; col++) + if ( m_colWidths[ col ] != -1 ) + width += m_colWidths[ col ] + m_hgap; + if (width > 0) + width -= m_hgap; + + int height = 0; + for (int row = 0; row < nrows; row++) + if ( m_rowHeights[ row ] != -1 ) + height += m_rowHeights[ row ] + m_vgap; + if (height > 0) + height -= m_vgap; + + m_calculatedMinSize = wxSize( width, height ); return m_calculatedMinSize; } @@ -1777,208 +1548,119 @@ void wxFlexGridSizer::AdjustForFlexDirection() } } -// helper of AdjustForGrowables() which is called for rows/columns separately -// -// parameters: -// delta: the extra space, we do nothing unless it's positive -// growable: indices or growable rows/cols in sizes array -// sizes: the height/widths of rows/cols to adjust -// proportions: proportions of the growable rows/cols or NULL if they all -// should be assumed to have proportion of 1 -static void -DoAdjustForGrowables(int delta, - const wxArrayInt& growable, - wxArrayInt& sizes, - const wxArrayInt *proportions) + +void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz, + int nrows, int ncols) { - if ( delta <= 0 ) - return; - - // total sum of proportions of all non-hidden rows - int sum_proportions = 0; - - // number of currently shown growable rows - int num = 0; - - const int max_idx = sizes.size(); - - const size_t count = growable.size(); - size_t idx; - for ( idx = 0; idx < count; idx++ ) + // what to do with the rows? by default, resize them proportionally + if ( sz.y > minsz.y && ( (m_flexDirection & wxVERTICAL) || (m_growMode == wxFLEX_GROWMODE_SPECIFIED) ) ) { - // Since the number of rows/columns can change as items are - // inserted/deleted, we need to verify at runtime that the - // requested growable rows/columns are still valid. - if ( growable[idx] >= max_idx ) - continue; - - // If all items in a row/column are hidden, that row/column will - // have a dimension of -1. This causes the row/column to be - // hidden completely. - if ( sizes[growable[idx]] == -1 ) - continue; - - if ( proportions ) - sum_proportions += (*proportions)[idx]; - - num++; - } - - if ( !num ) - return; - - // the remaining extra free space, adjusted during each iteration - for ( idx = 0; idx < count; idx++ ) - { - if ( growable[idx] >= max_idx ) - continue; - - if ( sizes[ growable[idx] ] == -1 ) - continue; - - int cur_delta; - if ( sum_proportions == 0 ) + int sum_proportions = 0; + int growable_space = 0; + int num = 0; + size_t idx; + for (idx = 0; idx < m_growableRows.GetCount(); idx++) { - // no growable rows -- divide extra space evenly among all - cur_delta = delta/num; - num--; - } - else // allocate extra space proportionally - { - const int cur_prop = (*proportions)[idx]; - cur_delta = (delta*cur_prop)/sum_proportions; - sum_proportions -= cur_prop; + // Since the number of rows/columns can change as items are + // inserted/deleted, we need to verify at runtime that the + // requested growable rows/columns are still valid. + if (m_growableRows[idx] >= nrows) + continue; + + // If all items in a row/column are hidden, that row/column will + // have a dimension of -1. This causes the row/column to be + // hidden completely. + if (m_rowHeights[ m_growableRows[idx] ] == -1) + continue; + sum_proportions += m_growableRowsProportions[idx]; + growable_space += m_rowHeights[ m_growableRows[idx] ]; + num++; } - sizes[growable[idx]] += cur_delta; - delta -= cur_delta; - } -} - -void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) -{ -#if wxDEBUG_LEVEL - // by the time this function is called, the sizer should be already fully - // initialized and hence the number of its columns and rows is known and we - // can check that all indices in m_growableCols/Rows are valid (see also - // comments in AddGrowableCol/Row()) - if ( !m_rows || !m_cols ) - { - if ( !m_rows ) + if (num > 0) { - int nrows = CalcRows(); - - for ( size_t n = 0; n < m_growableRows.size(); n++ ) + for (idx = 0; idx < m_growableRows.GetCount(); idx++) { - wxASSERT_MSG( m_growableRows[n] < nrows, - "invalid growable row index" ); - } - } - - if ( !m_cols ) - { - int ncols = CalcCols(); - - for ( size_t n = 0; n < m_growableCols.size(); n++ ) - { - wxASSERT_MSG( m_growableCols[n] < ncols, - "invalid growable column index" ); + if (m_growableRows[idx] >= nrows ) + continue; + if (m_rowHeights[ m_growableRows[idx] ] != -1) + { + int delta = (sz.y - minsz.y); + if (sum_proportions == 0) + delta = (delta/num) + m_rowHeights[ m_growableRows[idx] ]; + else + delta = ((delta+growable_space)*m_growableRowsProportions[idx]) / sum_proportions; + m_rowHeights[ m_growableRows[idx] ] = delta; + } } } } -#endif // wxDEBUG_LEVEL - - - if ( (m_flexDirection & wxHORIZONTAL) || (m_growMode != wxFLEX_GROWMODE_NONE) ) + else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.y > minsz.y) ) { - DoAdjustForGrowables - ( - sz.x - m_calculatedMinSize.x, - m_growableCols, - m_colWidths, - m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableColsProportions - : NULL - ); - - // This gives nested objects that benefit from knowing one size - // component in advance the chance to use that. - bool didAdjustMinSize = false; - - // Iterate over all items and inform about column width - const int ncols = GetEffectiveColsCount(); - int col = 0; - for ( wxSizerItemList::iterator i = m_children.begin(); - i != m_children.end(); - ++i ) - { - didAdjustMinSize |= (*i)->InformFirstDirection(wxHORIZONTAL, m_colWidths[col], sz.y - m_calculatedMinSize.y); - if ( ++col == ncols ) - col = 0; - } - - // Only redo if info was actually used - if( didAdjustMinSize ) - { - DoAdjustForGrowables - ( - sz.x - m_calculatedMinSize.x, - m_growableCols, - m_colWidths, - m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableColsProportions - : NULL - ); - } + // rounding problem? + for ( int row = 0; row < nrows; ++row ) + m_rowHeights[ row ] = sz.y / nrows; } - if ( (m_flexDirection & wxVERTICAL) || (m_growMode != wxFLEX_GROWMODE_NONE) ) + // the same logic as above but for the columns + if ( sz.x > minsz.x && ( (m_flexDirection & wxHORIZONTAL) || (m_growMode == wxFLEX_GROWMODE_SPECIFIED) ) ) { - // pass NULL instead of proportions if the grow mode is ALL as we - // should treat all rows as having proportion of 1 then - DoAdjustForGrowables - ( - sz.y - m_calculatedMinSize.y, - m_growableRows, - m_rowHeights, - m_growMode == wxFLEX_GROWMODE_SPECIFIED ? &m_growableRowsProportions - : NULL - ); + int sum_proportions = 0; + int growable_space = 0; + int num = 0; + size_t idx; + for (idx = 0; idx < m_growableCols.GetCount(); idx++) + { + // Since the number of rows/columns can change as items are + // inserted/deleted, we need to verify at runtime that the + // requested growable rows/columns are still valid. + if (m_growableCols[idx] >= ncols) + continue; + + // If all items in a row/column are hidden, that row/column will + // have a dimension of -1. This causes the column to be hidden + // completely. + if (m_colWidths[ m_growableCols[idx] ] == -1) + continue; + sum_proportions += m_growableColsProportions[idx]; + growable_space += m_colWidths[ m_growableCols[idx] ]; + num++; + } + + if (num > 0) + { + for (idx = 0; idx < m_growableCols.GetCount(); idx++) + { + if (m_growableCols[idx] >= ncols ) + continue; + if (m_colWidths[ m_growableCols[idx] ] != -1) + { + int delta = (sz.x - minsz.x); + if (sum_proportions == 0) + delta = (delta/num) + m_colWidths[ m_growableCols[idx] ]; + else + delta = ((delta+growable_space)*m_growableColsProportions[idx])/sum_proportions; + m_colWidths[ m_growableCols[idx] ] = delta; + } + } + } + } + else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.x > minsz.x) ) + { + for ( int col=0; col < ncols; ++col ) + m_colWidths[ col ] = sz.x / ncols; } } -bool wxFlexGridSizer::IsRowGrowable( size_t idx ) -{ - return m_growableRows.Index( idx ) != wxNOT_FOUND; -} - -bool wxFlexGridSizer::IsColGrowable( size_t idx ) -{ - return m_growableCols.Index( idx ) != wxNOT_FOUND; -} void wxFlexGridSizer::AddGrowableRow( size_t idx, int proportion ) { - wxASSERT_MSG( !IsRowGrowable( idx ), - "AddGrowableRow() called for growable row" ); - - // notice that we intentionally don't check the index validity here in (the - // common) case when the number of rows was not specified in the ctor -- in - // this case it will be computed only later, when all items are added to - // the sizer, and the check will be done in AdjustForGrowables() - wxCHECK_RET( !m_rows || idx < (size_t)m_rows, "invalid row index" ); - m_growableRows.Add( idx ); m_growableRowsProportions.Add( proportion ); } void wxFlexGridSizer::AddGrowableCol( size_t idx, int proportion ) { - wxASSERT_MSG( !IsColGrowable( idx ), - "AddGrowableCol() called for growable column" ); - - // see comment in AddGrowableRow(): although it's less common to omit the - // specification of the number of columns, it still can also happen - wxCHECK_RET( !m_cols || idx < (size_t)m_cols, "invalid column index" ); - m_growableCols.Add( idx ); m_growableColsProportions.Add( proportion ); } @@ -1998,7 +1680,7 @@ DoRemoveFromArrays(size_t idx, wxArrayInt& items, wxArrayInt& proportions) } } - wxFAIL_MSG( wxT("column/row is already not growable") ); + wxFAIL_MSG( _T("column/row is already not growable") ); } void wxFlexGridSizer::RemoveGrowableCol( size_t idx ) @@ -2015,431 +1697,209 @@ void wxFlexGridSizer::RemoveGrowableRow( size_t idx ) // wxBoxSizer //--------------------------------------------------------------------------- -wxSizerItem *wxBoxSizer::AddSpacer(int size) +wxBoxSizer::wxBoxSizer( int orient ) + : m_orient( orient ) { - return IsVertical() ? Add(0, size) : Add(size, 0); } -namespace -{ - -/* - Helper of RecalcSizes(): checks if there is enough remaining space for the - min size of the given item and returns its min size or the entire remaining - space depending on which one is greater. - - This function updates the remaining space parameter to account for the size - effectively allocated to the item. - */ -int -GetMinOrRemainingSize(int orient, const wxSizerItem *item, int *remainingSpace_) -{ - int& remainingSpace = *remainingSpace_; - - wxCoord size; - if ( remainingSpace > 0 ) - { - const wxSize sizeMin = item->GetMinSizeWithBorder(); - size = orient == wxHORIZONTAL ? sizeMin.x : sizeMin.y; - - if ( size >= remainingSpace ) - { - // truncate the item to fit in the remaining space, this is better - // than showing it only partially in general, even if both choices - // are bad -- but there is nothing else we can do - size = remainingSpace; - } - - remainingSpace -= size; - } - else // no remaining space - { - // no space at all left, no need to even query the item for its min - // size as we can't give it to it anyhow - size = 0; - } - - return size; -} - -} // anonymous namespace - void wxBoxSizer::RecalcSizes() { - if ( m_children.empty() ) + if (m_children.GetCount() == 0) return; - const wxCoord totalMinorSize = GetSizeInMinorDir(m_size); - const wxCoord totalMajorSize = GetSizeInMajorDir(m_size); - - // the amount of free space which we should redistribute among the - // stretchable items (i.e. those with non zero proportion) - int delta = totalMajorSize - GetSizeInMajorDir(m_minSize); - - // declare loop variables used below: - wxSizerItemList::const_iterator i; // iterator in m_children list - unsigned n = 0; // item index in majorSizes array - - - // First, inform item about the available size in minor direction as this - // can change their size in the major direction. Also compute the number of - // visible items and sum of their min sizes in major direction. - - int minMajorSize = 0; - for ( i = m_children.begin(); i != m_children.end(); ++i ) + int delta = 0; + if (m_stretchable) { - wxSizerItem * const item = *i; - - if ( !item->IsShown() ) - continue; - - wxSize szMinPrev = item->GetMinSizeWithBorder(); - item->InformFirstDirection(m_orient^wxBOTH,totalMinorSize,delta); - wxSize szMin = item->GetMinSizeWithBorder(); - int deltaChange = GetSizeInMajorDir(szMin-szMinPrev); - if( deltaChange ) - { - // Since we passed available space along to the item, it should not - // take too much, so delta should not become negative. - delta -= deltaChange; - } - minMajorSize += GetSizeInMajorDir(item->GetMinSizeWithBorder()); + if (m_orient == wxHORIZONTAL) + delta = m_size.x - m_fixedWidth; + else + delta = m_size.y - m_fixedHeight; } - // update our min size have changed - SizeInMajorDir(m_minSize) = minMajorSize; + wxPoint pt( m_position ); - - // space and sum of proportions for the remaining items, both may change - // below - wxCoord remaining = totalMajorSize; - int totalProportion = m_totalProportion; - - // size of the (visible) items in major direction, -1 means "not fixed yet" - wxVector majorSizes(GetItemCount(), wxDefaultCoord); - - - // Check for the degenerated case when we don't have enough space for even - // the min sizes of all the items: in this case we really can't do much - // more than to allocate the min size to as many of fixed size items as - // possible (on the assumption that variable size items such as text zones - // or list boxes may use scrollbars to show their content even if their - // size is less than min size but that fixed size items such as buttons - // will suffer even more if we don't give them their min size) - if ( totalMajorSize < minMajorSize ) + int stretchable = m_stretchable; + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + while (node) { - // Second degenerated case pass: allocate min size to all fixed size - // items. - for ( i = m_children.begin(), n = 0; i != m_children.end(); ++i, ++n ) + wxSizerItem *item = node->GetData(); + + if (item->ShouldAccountFor()) { - wxSizerItem * const item = *i; + wxSize size( item->GetMinSizeWithBorder() ); - if ( !item->IsShown() ) - continue; - - // deal with fixed size items only during this pass - if ( item->GetProportion() ) - continue; - - majorSizes[n] = GetMinOrRemainingSize(m_orient, item, &remaining); - } - - - // Third degenerated case pass: allocate min size to all the remaining, - // i.e. non-fixed size, items. - for ( i = m_children.begin(), n = 0; i != m_children.end(); ++i, ++n ) - { - wxSizerItem * const item = *i; - - if ( !item->IsShown() ) - continue; - - // we've already dealt with fixed size items above - if ( !item->GetProportion() ) - continue; - - majorSizes[n] = GetMinOrRemainingSize(m_orient, item, &remaining); - } - } - else // we do have enough space to give at least min sizes to all items - { - // Second and maybe more passes in the non-degenerated case: deal with - // fixed size items and items whose min size is greater than what we - // would allocate to them taking their proportion into account. For - // both of them, we will just use their min size, but for the latter we - // also need to reexamine all the items as the items which fitted - // before we adjusted their size upwards might not fit any more. This - // does make for a quadratic algorithm but it's not obvious how to - // avoid it and hopefully it's not a huge problem in practice as the - // sizers don't have many items usually (and, of course, the algorithm - // still reduces into a linear one if there is enough space for all the - // min sizes). - bool nonFixedSpaceChanged = false; - for ( i = m_children.begin(), n = 0; ; ++i, ++n ) - { - if ( nonFixedSpaceChanged ) + if (m_orient == wxVERTICAL) { - i = m_children.begin(); - n = 0; - nonFixedSpaceChanged = false; - } - - // check for the end of the loop only after the check above as - // otherwise we wouldn't do another pass if the last child resulted - // in non fixed space reduction - if ( i == m_children.end() ) - break; - - wxSizerItem * const item = *i; - - if ( !item->IsShown() ) - continue; - - // don't check the item which we had already dealt with during a - // previous pass (this is more than an optimization, the code - // wouldn't work correctly if we kept adjusting for the same item - // over and over again) - if ( majorSizes[n] != wxDefaultCoord ) - continue; - - wxCoord minMajor = GetSizeInMajorDir(item->GetMinSizeWithBorder()); - - // it doesn't make sense for min size to be negative but right now - // it's possible to create e.g. a spacer with (-1, 10) as size and - // people do it in their code apparently (see #11842) so ensure - // that we don't use this -1 as real min size as it conflicts with - // the meaning we use for it here and negative min sizes just don't - // make sense anyhow (which is why it might be a better idea to - // deal with them at wxSizerItem level in the future but for now - // this is the minimal fix for the bug) - if ( minMajor < 0 ) - minMajor = 0; - - const int propItem = item->GetProportion(); - if ( propItem ) - { - // is the desired size of this item big enough? - if ( (remaining*propItem)/totalProportion >= minMajor ) + wxCoord height = size.y; + if (item->GetProportion()) { - // yes, it is, we'll determine the real size of this - // item later, for now just leave it as wxDefaultCoord - continue; + // Because of at least one visible item has non-zero + // proportion then m_stretchable is not zero + height = (delta * item->GetProportion()) / stretchable; + delta -= height; + stretchable -= item->GetProportion(); } - // the proportion of this item won't count, it has - // effectively become fixed - totalProportion -= propItem; + wxPoint child_pos( pt ); + wxSize child_size( size.x, height ); + + if (item->GetFlag() & (wxEXPAND | wxSHAPED)) + child_size.x = m_size.x; + else if (item->GetFlag() & wxALIGN_RIGHT) + child_pos.x += m_size.x - size.x; + else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_HORIZONTAL)) + // XXX wxCENTER is added for backward compatibility; + // wxALIGN_CENTER should be used in new code + child_pos.x += (m_size.x - size.x) / 2; + + item->SetDimension( child_pos, child_size ); + + pt.y += height; } - - // we can already allocate space for this item - majorSizes[n] = minMajor; - - // change the amount of the space remaining to the other items, - // as this can result in not being able to satisfy their - // proportions any more we will need to redo another loop - // iteration - remaining -= minMajor; - - nonFixedSpaceChanged = true; - } - - // Similar to the previous loop, but dealing with items whose max size - // is less than what we would allocate to them taking their proportion - // into account. - nonFixedSpaceChanged = false; - for ( i = m_children.begin(), n = 0; ; ++i, ++n ) - { - if ( nonFixedSpaceChanged ) + else { - i = m_children.begin(); - n = 0; - nonFixedSpaceChanged = false; - } + wxCoord width = size.x; + if (item->GetProportion()) + { + // Because of at least one visible item has non-zero + // proportion then m_stretchable is not zero + width = (delta * item->GetProportion()) / stretchable; + delta -= width; + stretchable -= item->GetProportion(); + } - // check for the end of the loop only after the check above as - // otherwise we wouldn't do another pass if the last child resulted - // in non fixed space reduction - if ( i == m_children.end() ) - break; + wxPoint child_pos( pt ); + wxSize child_size( width, size.y ); - wxSizerItem * const item = *i; + if (item->GetFlag() & (wxEXPAND | wxSHAPED)) + child_size.y = m_size.y; + else if (item->GetFlag() & wxALIGN_BOTTOM) + child_pos.y += m_size.y - size.y; + else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_VERTICAL)) + // XXX wxCENTER is added for backward compatibility; + // wxALIGN_CENTER should be used in new code + child_pos.y += (m_size.y - size.y) / 2; - if ( !item->IsShown() ) - continue; + if ( m_containingWindow ) + { + child_pos.x = m_containingWindow->AdjustForLayoutDirection + ( + child_pos.x, + width, + m_size.x + ); + } - // don't check the item which we had already dealt with during a - // previous pass (this is more than an optimization, the code - // wouldn't work correctly if we kept adjusting for the same item - // over and over again) - if ( majorSizes[n] != wxDefaultCoord ) - continue; + item->SetDimension( child_pos, child_size ); - wxCoord maxMajor = GetSizeInMajorDir(item->GetMaxSizeWithBorder()); - - // must be nonzero, fixed-size items were dealt with in previous loop - const int propItem = item->GetProportion(); - - // is the desired size of this item small enough? - if ( maxMajor < 0 || - (remaining*propItem)/totalProportion <= maxMajor ) - { - // yes, it is, we'll determine the real size of this - // item later, for now just leave it as wxDefaultCoord - continue; - } - - // the proportion of this item won't count, it has - // effectively become fixed - totalProportion -= propItem; - - // we can already allocate space for this item - majorSizes[n] = maxMajor; - - // change the amount of the space remaining to the other items, - // as this can result in not being able to satisfy their - // proportions any more we will need to redo another loop - // iteration - remaining -= maxMajor; - - nonFixedSpaceChanged = true; - } - - // Last by one pass: distribute the remaining space among the non-fixed - // items whose size weren't fixed yet according to their proportions. - for ( i = m_children.begin(), n = 0; i != m_children.end(); ++i, ++n ) - { - wxSizerItem * const item = *i; - - if ( !item->IsShown() ) - continue; - - if ( majorSizes[n] == wxDefaultCoord ) - { - const int propItem = item->GetProportion(); - majorSizes[n] = (remaining*propItem)/totalProportion; - - remaining -= majorSizes[n]; - totalProportion -= propItem; + pt.x += width; } } - } - - // the position at which we put the next child - wxPoint pt(m_position); - - - // Final pass: finally do position the items correctly using their sizes as - // determined above. - for ( i = m_children.begin(), n = 0; i != m_children.end(); ++i, ++n ) - { - wxSizerItem * const item = *i; - - if ( !item->IsShown() ) - continue; - - const int majorSize = majorSizes[n]; - - const wxSize sizeThis(item->GetMinSizeWithBorder()); - - // apply the alignment in the minor direction - wxPoint posChild(pt); - - wxCoord minorSize = GetSizeInMinorDir(sizeThis); - const int flag = item->GetFlag(); - if ( (flag & (wxEXPAND | wxSHAPED)) || (minorSize > totalMinorSize) ) - { - // occupy all the available space if wxEXPAND was given and also if - // the item is too big to fit -- in this case we truncate it below - // its minimal size which is bad but better than not showing parts - // of the window at all - minorSize = totalMinorSize; - - // do not allow the size in the minor direction to grow beyond the max - // size of the item in the minor direction - const wxCoord maxMinorSize = GetSizeInMinorDir(item->GetMaxSizeWithBorder()); - if ( maxMinorSize >= 0 && minorSize > maxMinorSize ) - minorSize = maxMinorSize; - } - - if ( flag & (IsVertical() ? wxALIGN_RIGHT : wxALIGN_BOTTOM) ) - { - PosInMinorDir(posChild) += totalMinorSize - minorSize; - } - // NB: wxCENTRE is used here only for backwards compatibility, - // wxALIGN_CENTRE should be used in new code - else if ( flag & (wxCENTER | (IsVertical() ? wxALIGN_CENTRE_HORIZONTAL - : wxALIGN_CENTRE_VERTICAL)) ) - { - PosInMinorDir(posChild) += (totalMinorSize - minorSize) / 2; - } - - - // apply RTL adjustment for horizontal sizers: - if ( !IsVertical() && m_containingWindow ) - { - posChild.x = m_containingWindow->AdjustForLayoutDirection - ( - posChild.x, - majorSize, - m_size.x - ); - } - - // finally set size of this child and advance to the next one - item->SetDimension(posChild, SizeFromMajorMinor(majorSize, minorSize)); - - PosInMajorDir(pt) += majorSize; + node = node->GetNext(); } } wxSize wxBoxSizer::CalcMin() { - m_totalProportion = 0; - m_minSize = wxSize(0, 0); + if (m_children.GetCount() == 0) + return wxSize(); - // The minimal size for the sizer should be big enough to allocate its - // element at least its minimal size but also, and this is the non trivial - // part, to respect the children proportion. To satisfy the latter - // condition we must find the greatest min-size-to-proportion ratio for all - // elements with non-zero proportion. - float maxMinSizeToProp = 0.; - for ( wxSizerItemList::const_iterator i = m_children.begin(); - i != m_children.end(); - ++i ) + m_stretchable = 0; + m_minWidth = 0; + m_minHeight = 0; + m_fixedWidth = 0; + m_fixedHeight = 0; + + // precalc item minsizes and count proportions + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + while (node) { - wxSizerItem * const item = *i; + wxSizerItem *item = node->GetData(); - if ( !item->IsShown() ) - continue; - - const wxSize sizeMinThis = item->CalcMin(); - if ( const int propThis = item->GetProportion() ) + if ( item->ShouldAccountFor() ) { - float minSizeToProp = GetSizeInMajorDir(sizeMinThis); - minSizeToProp /= propThis; + item->CalcMin(); // result is stored in the item - if ( minSizeToProp > maxMinSizeToProp ) - maxMinSizeToProp = minSizeToProp; - - m_totalProportion += item->GetProportion(); - } - else // fixed size item - { - // Just account for its size directly - SizeInMajorDir(m_minSize) += GetSizeInMajorDir(sizeMinThis); + m_stretchable += item->GetProportion(); } - // In the transversal direction we just need to find the maximum. - if ( GetSizeInMinorDir(sizeMinThis) > GetSizeInMinorDir(m_minSize) ) - SizeInMinorDir(m_minSize) = GetSizeInMinorDir(sizeMinThis); + node = node->GetNext(); } - // Using the max ratio ensures that the min size is big enough for all - // items to have their min size and satisfy the proportions among them. - SizeInMajorDir(m_minSize) += (int)(maxMinSizeToProp*m_totalProportion); + // Total minimum size (width or height) of sizer + int maxMinSize = 0; - return m_minSize; + node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = node->GetData(); + + if (item->ShouldAccountFor() && item->GetProportion() != 0) + { + int stretch = item->GetProportion(); + wxSize size( item->GetMinSizeWithBorder() ); + int minSize; + + // Integer division rounded up is (a + b - 1) / b + // Round up needed in order to guarantee that all + // all items will have size not less then their min size + if (m_orient == wxHORIZONTAL) + minSize = ( size.x*m_stretchable + stretch - 1)/stretch; + else + minSize = ( size.y*m_stretchable + stretch - 1)/stretch; + + if (minSize > maxMinSize) + maxMinSize = minSize; + } + node = node->GetNext(); + } + + // Calculate overall minimum size + node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = node->GetData(); + + if (item->ShouldAccountFor()) + { + wxSize size( item->GetMinSizeWithBorder() ); + if (item->GetProportion() != 0) + { + if (m_orient == wxHORIZONTAL) + size.x = (maxMinSize*item->GetProportion())/m_stretchable; + else + size.y = (maxMinSize*item->GetProportion())/m_stretchable; + } + else + { + if (m_orient == wxVERTICAL) + { + m_fixedHeight += size.y; + m_fixedWidth = wxMax( m_fixedWidth, size.x ); + } + else + { + m_fixedWidth += size.x; + m_fixedHeight = wxMax( m_fixedHeight, size.y ); + } + } + + if (m_orient == wxHORIZONTAL) + { + m_minWidth += size.x; + m_minHeight = wxMax( m_minHeight, size.y ); + } + else + { + m_minHeight += size.y; + m_minWidth = wxMax( m_minWidth, size.x ); + } + } + node = node->GetNext(); + } + + return wxSize( m_minWidth, m_minHeight ); } //--------------------------------------------------------------------------- @@ -2469,75 +1929,32 @@ wxStaticBoxSizer::wxStaticBoxSizer(int orient, wxWindow *win, const wxString& s) wxStaticBoxSizer::~wxStaticBoxSizer() { - // As an exception to the general rule that sizers own other sizers that - // they contain but not the windows managed by them, this sizer does own - // the static box associated with it (which is not very logical but - // convenient in practice and, most importantly, can't be changed any more - // because of compatibility). However we definitely should not destroy the - // children of this static box when we're being destroyed, as this would be - // unexpected and break the existing code which worked with the windows - // created as siblings of the static box instead of its children in the - // previous wxWidgets versions, so ensure they are left alive. + delete m_staticBox; +} - if ( m_staticBox ) - { - // Notice that we must make a copy of the list as it will be changed by - // Reparent() calls in the loop. - const wxWindowList children = m_staticBox->GetChildren(); - wxWindow* const parent = m_staticBox->GetParent(); - for ( wxWindowList::const_iterator i = children.begin(); - i != children.end(); - ++i ) - { - (*i)->Reparent(parent); - } - - delete m_staticBox; - } +static void GetStaticBoxBorders( wxStaticBox *box, + int *borderTop, + int *borderOther) +{ + // this has to be done platform by platform as there is no way to + // guess the thickness of a wxStaticBox border + box->GetBordersForSizer(borderTop, borderOther); } void wxStaticBoxSizer::RecalcSizes() { int top_border, other_border; - m_staticBox->GetBordersForSizer(&top_border, &other_border); + GetStaticBoxBorders(m_staticBox, &top_border, &other_border); m_staticBox->SetSize( m_position.x, m_position.y, m_size.x, m_size.y ); + wxPoint old_pos( m_position ); + m_position.x += other_border; + m_position.y += top_border; wxSize old_size( m_size ); m_size.x -= 2*other_border; m_size.y -= top_border + other_border; - wxPoint old_pos( m_position ); - if (m_staticBox->GetChildren().GetCount() > 0) - { -#if defined( __WXGTK20__ ) - // if the wxStaticBox has created a wxPizza to contain its children - // (see wxStaticBox::AddChild) then we need to place the items it contains - // in the wxBoxSizer::RecalcSizes() call below using coordinates relative - // to the top-left corner of the staticbox: - m_position.x = m_position.y = 0; -#elif defined(__WXOSX__) && wxOSX_USE_COCOA - // the distance from the 'inner' content view to the embedded controls - // this is independent of the title, therefore top_border is not relevant - m_position.x = m_position.y = 10; -#else - // if the wxStaticBox has children, then these windows must be placed - // by the wxBoxSizer::RecalcSizes() call below using coordinates relative - // to the top-left corner of the staticbox (but unlike wxGTK, we need - // to keep in count the static borders here!): - m_position.x = other_border; - m_position.y = top_border; -#endif - } - else - { - // the windows contained in the staticbox have been created as siblings of the - // staticbox (this is the "old" way of staticbox contents creation); in this - // case we need to position them with coordinates relative to our common parent - m_position.x += other_border; - m_position.y += top_border; - } - wxBoxSizer::RecalcSizes(); m_position = old_pos; @@ -2547,17 +1964,10 @@ void wxStaticBoxSizer::RecalcSizes() wxSize wxStaticBoxSizer::CalcMin() { int top_border, other_border; - m_staticBox->GetBordersForSizer(&top_border, &other_border); + GetStaticBoxBorders(m_staticBox, &top_border, &other_border); wxSize ret( wxBoxSizer::CalcMin() ); ret.x += 2*other_border; - - // ensure that we're wide enough to show the static box label (there is no - // need to check for the static box best size in vertical direction though) - const int boxWidth = m_staticBox->GetBestSize().x; - if ( ret.x < boxWidth ) - ret.x = boxWidth; - ret.y += other_border + top_border; return ret; @@ -2569,16 +1979,6 @@ void wxStaticBoxSizer::ShowItems( bool show ) wxBoxSizer::ShowItems( show ); } -bool wxStaticBoxSizer::AreAnyItemsShown() const -{ - // We don't need to check the status of our child items: if the box is - // shown, this sizer should be considered shown even if all its elements - // are hidden (or, more prosaically, there are no elements at all). And, - // conversely, if the box is hidden then all our items, which are its - // children, are hidden too. - return m_staticBox->IsShown(); -} - bool wxStaticBoxSizer::Detach( wxWindow *window ) { // avoid deleting m_staticBox in our dtor if it's being detached from the @@ -2595,10 +1995,6 @@ bool wxStaticBoxSizer::Detach( wxWindow *window ) #endif // wxUSE_STATBOX -//--------------------------------------------------------------------------- -// wxStdDialogButtonSizer -//--------------------------------------------------------------------------- - #if wxUSE_BUTTON wxStdDialogButtonSizer::wxStdDialogButtonSizer() @@ -2640,7 +2036,6 @@ void wxStdDialogButtonSizer::AddButton(wxButton *mybutton) m_buttonNegative = mybutton; break; case wxID_CANCEL: - case wxID_CLOSE: m_buttonCancel = mybutton; break; case wxID_HELP: @@ -2706,40 +2101,30 @@ void wxStdDialogButtonSizer::Realize() } // Extra space around and at the right - Add(12, 40); + Add(12, 24); #elif defined(__WXGTK20__) - // http://library.gnome.org/devel/hig-book/stable/windows-alert.html.en - // says that the correct button order is - // - // [Help] [Alternative] [Cancel] [Affirmative] - - // Flags ensuring that margins between the buttons are 6 pixels. - const wxSizerFlags - flagsBtn = wxSizerFlags().Centre().Border(wxLEFT | wxRIGHT, 3); - - // Margin around the entire sizer button should be 12. - AddSpacer(9); - + Add(0, 0, 0, wxLEFT, 9); if (m_buttonHelp) - Add(m_buttonHelp, flagsBtn); + Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); - // Align the rest of the buttons to the right. - AddStretchSpacer(); + // extra whitespace between help and cancel/ok buttons + Add(0, 0, 1, wxEXPAND, 0); - if (m_buttonNegative) - Add(m_buttonNegative, flagsBtn); + if (m_buttonNegative){ + Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + } + + if (m_buttonCancel){ + Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + // Cancel or help should be default + // m_buttonCancel->SetDefaultButton(); + } if (m_buttonApply) - Add(m_buttonApply, flagsBtn); - - if (m_buttonCancel) - Add(m_buttonCancel, flagsBtn); + Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); if (m_buttonAffirmative) - Add(m_buttonAffirmative, flagsBtn); - - // Ensure that the right margin is 12 as well. - AddSpacer(9); + Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT, 6); #elif defined(__WXMSW__) // Windows @@ -2793,3 +2178,88 @@ void wxStdDialogButtonSizer::Realize() } #endif // wxUSE_BUTTON + +#if WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// wxNotebookSizer +// ---------------------------------------------------------------------------- + +#if wxUSE_BOOKCTRL +IMPLEMENT_CLASS(wxBookCtrlSizer, wxSizer) +#if wxUSE_NOTEBOOK +IMPLEMENT_CLASS(wxNotebookSizer, wxBookCtrlSizer) +#endif // wxUSE_NOTEBOOK +#endif // wxUSE_BOOKCTRL + +#if wxUSE_BOOKCTRL + +#if WXWIN_COMPATIBILITY_2_6 + +wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrlBase *bookctrl) + : m_bookctrl(bookctrl) +{ + wxASSERT_MSG( bookctrl, wxT("wxBookCtrlSizer needs a control") ); +} + +#endif // WXWIN_COMPATIBILITY_2_6 + +void wxBookCtrlSizer::RecalcSizes() +{ + m_bookctrl->SetSize( m_position.x, m_position.y, m_size.x, m_size.y ); +} + +wxSize wxBookCtrlSizer::CalcMin() +{ + wxSize sizeBorder = m_bookctrl->CalcSizeFromPage(wxSize(0,0)); + + sizeBorder.x += 5; + sizeBorder.y += 5; + + if ( m_bookctrl->GetPageCount() == 0 ) + { + return wxSize(sizeBorder.x + 10, sizeBorder.y + 10); + } + + int maxX = 0; + int maxY = 0; + + wxWindowList::compatibility_iterator + node = m_bookctrl->GetChildren().GetFirst(); + while (node) + { + wxWindow *item = node->GetData(); + wxSizer *itemsizer = item->GetSizer(); + + if (itemsizer) + { + wxSize subsize( itemsizer->CalcMin() ); + + if (subsize.x > maxX) + maxX = subsize.x; + if (subsize.y > maxY) + maxY = subsize.y; + } + + node = node->GetNext(); + } + + return wxSize( maxX, maxY ) + sizeBorder; +} + +#if wxUSE_NOTEBOOK + +#if WXWIN_COMPATIBILITY_2_6 + +wxNotebookSizer::wxNotebookSizer(wxNotebook *nb) +{ + wxASSERT_MSG( nb, wxT("wxNotebookSizer needs a control") ); + m_bookctrl = nb; +} + +#endif // WXWIN_COMPATIBILITY_2_6 + +#endif // wxUSE_NOTEBOOOK +#endif // wxUSE_BOOKCTRL + +#endif // WXWIN_COMPATIBILITY_2_4 diff --git a/Source/3rd Party/wx/src/common/slidercmn.cpp b/Source/3rd Party/wx/src/common/slidercmn.cpp deleted file mode 100644 index 8da1506d7..000000000 --- a/Source/3rd Party/wx/src/common/slidercmn.cpp +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/slidercmn.cpp -// Purpose: wxSlider common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart 1998 -// Vadim Zeitlin 2004 -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SLIDER - -#include "wx/slider.h" - -extern WXDLLEXPORT_DATA(const char) wxSliderNameStr[] = "slider"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxSliderStyle ) -wxBEGIN_FLAGS( wxSliderStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxSL_HORIZONTAL) - wxFLAGS_MEMBER(wxSL_VERTICAL) - wxFLAGS_MEMBER(wxSL_AUTOTICKS) - wxFLAGS_MEMBER(wxSL_LABELS) - wxFLAGS_MEMBER(wxSL_LEFT) - wxFLAGS_MEMBER(wxSL_TOP) - wxFLAGS_MEMBER(wxSL_RIGHT) - wxFLAGS_MEMBER(wxSL_BOTTOM) - wxFLAGS_MEMBER(wxSL_BOTH) - wxFLAGS_MEMBER(wxSL_SELRANGE) - wxFLAGS_MEMBER(wxSL_INVERSE) -wxEND_FLAGS( wxSliderStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSlider, wxControl, "wx/slider.h") - -wxBEGIN_PROPERTIES_TABLE(wxSlider) - wxEVENT_RANGE_PROPERTY( Scroll, wxEVT_SCROLL_TOP, wxEVT_SCROLL_CHANGED, wxScrollEvent ) - wxEVENT_PROPERTY( Updated, wxEVT_SLIDER, wxCommandEvent ) - - wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( Minimum, int, SetMin, GetMin, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( Maximum, int, SetMax, GetMax, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( PageSize, int, SetPageSize, GetLineSize, 1, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( LineSize, int, SetLineSize, GetLineSize, 1, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( ThumbLength, int, SetThumbLength, GetThumbLength, 1, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - - wxPROPERTY_FLAGS( WindowStyle, wxSliderStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxSlider) - -wxCONSTRUCTOR_8( wxSlider, wxWindow*, Parent, wxWindowID, Id, int, Value, \ - int, Minimum, int, Maximum, wxPoint, Position, wxSize, Size, \ - long, WindowStyle ) - -#endif // wxUSE_SLIDER diff --git a/Source/3rd Party/wx/src/common/socket.cpp b/Source/3rd Party/wx/src/common/socket.cpp deleted file mode 100644 index bcb331fcc..000000000 --- a/Source/3rd Party/wx/src/common/socket.cpp +++ /dev/null @@ -1,2164 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/socket.cpp -// Purpose: Socket handler classes -// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia -// Created: April 1997 -// Copyright: (C) 1999-1997, Guilhem Lavaux -// (C) 1999-2000, Guillermo Rodriguez Garcia -// (C) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ========================================================================== -// Declarations -// ========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SOCKETS - -#include "wx/socket.h" - -#ifndef WX_PRECOMP - #include "wx/object.h" - #include "wx/string.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/event.h" - #include "wx/app.h" - #include "wx/utils.h" - #include "wx/timer.h" - #include "wx/module.h" -#endif - -#include "wx/apptrait.h" -#include "wx/sckaddr.h" -#include "wx/stopwatch.h" -#include "wx/thread.h" -#include "wx/evtloop.h" -#include "wx/link.h" - -#include "wx/private/fd.h" -#include "wx/private/socket.h" - -#ifdef __UNIX__ - #include -#endif - -// we use MSG_NOSIGNAL to avoid getting SIGPIPE when sending data to a remote -// host which closed the connection if it is available, otherwise we rely on -// SO_NOSIGPIPE existency -// -// this should cover all the current Unix systems (Windows never sends any -// signals anyhow) but if we find one that has neither we should explicitly -// ignore SIGPIPE for it -// OpenVMS has neither MSG_NOSIGNAL nor SO_NOSIGPIPE. However the socket sample -// seems to work. Not sure if problems will show up on OpenVMS using sockets. -#ifdef MSG_NOSIGNAL - #define wxSOCKET_MSG_NOSIGNAL MSG_NOSIGNAL -#else // MSG_NOSIGNAL not available (BSD including OS X) - // next best possibility is to use SO_NOSIGPIPE socket option, this covers - // BSD systems (including OS X) -- but if we don't have it neither (AIX and - // old HP-UX do not), we have to fall back to the old way of simply - // disabling SIGPIPE temporarily, so define a class to do it in a safe way - #if defined(__UNIX__) && !defined(SO_NOSIGPIPE) - extern "C" { typedef void (*wxSigHandler_t)(int); } - namespace - { - class IgnoreSignal - { - public: - // ctor disables the given signal - IgnoreSignal(int sig) - : m_handler(signal(sig, SIG_IGN)), - m_sig(sig) - { - } - - // dtor restores the old handler - ~IgnoreSignal() - { - signal(m_sig, m_handler); - } - - private: - const wxSigHandler_t m_handler; - const int m_sig; - - wxDECLARE_NO_COPY_CLASS(IgnoreSignal); - }; - } // anonymous namespace - - #define wxNEEDS_IGNORE_SIGPIPE - #endif // Unix without SO_NOSIGPIPE - - #define wxSOCKET_MSG_NOSIGNAL 0 -#endif - -// DLL options compatibility check: -#include "wx/build.h" -WX_CHECK_BUILD_OPTIONS("wxNet") - -// -------------------------------------------------------------------------- -// macros and constants -// -------------------------------------------------------------------------- - -// event -wxDEFINE_EVENT(wxEVT_SOCKET, wxSocketEvent); - -// discard buffer -#define MAX_DISCARD_SIZE (10 * 1024) - -#define wxTRACE_Socket wxT("wxSocket") - -// -------------------------------------------------------------------------- -// wxWin macros -// -------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxSocketBase, wxObject) -IMPLEMENT_CLASS(wxSocketServer, wxSocketBase) -IMPLEMENT_CLASS(wxSocketClient, wxSocketBase) -IMPLEMENT_CLASS(wxDatagramSocket, wxSocketBase) -IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent) - -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -namespace -{ - -void SetTimeValFromMS(timeval& tv, unsigned long ms) -{ - tv.tv_sec = (ms / 1000); - tv.tv_usec = (ms % 1000) * 1000; -} - -} // anonymous namespace - -// -------------------------------------------------------------------------- -// private classes -// -------------------------------------------------------------------------- - -class wxSocketState : public wxObject -{ -public: - wxSocketFlags m_flags; - wxSocketEventFlags m_eventmask; - bool m_notify; - void *m_clientData; - -public: - wxSocketState() : wxObject() {} - - wxDECLARE_NO_COPY_CLASS(wxSocketState); -}; - -// wxSocketWaitModeChanger: temporarily change the socket flags affecting its -// wait mode -class wxSocketWaitModeChanger -{ -public: - // temporarily set the flags to include the flag value which may be either - // wxSOCKET_NOWAIT or wxSOCKET_WAITALL - wxSocketWaitModeChanger(wxSocketBase *socket, int flag) - : m_socket(socket), - m_oldflags(socket->GetFlags()) - - { - // We can be passed only wxSOCKET_WAITALL{_READ,_WRITE} or - // wxSOCKET_NOWAIT{_READ,_WRITE} normally. - wxASSERT_MSG( !(flag & wxSOCKET_WAITALL) || !(flag & wxSOCKET_NOWAIT), - "not a wait flag" ); - - // preserve wxSOCKET_BLOCK value when switching to wxSOCKET_WAITALL - // mode but not when switching to wxSOCKET_NOWAIT as the latter is - // incompatible with wxSOCKET_BLOCK - if ( flag != wxSOCKET_NOWAIT ) - flag |= m_oldflags & wxSOCKET_BLOCK; - - socket->SetFlags(flag); - } - - ~wxSocketWaitModeChanger() - { - m_socket->SetFlags(m_oldflags); - } - -private: - wxSocketBase * const m_socket; - const int m_oldflags; - - wxDECLARE_NO_COPY_CLASS(wxSocketWaitModeChanger); -}; - -// wxSocketRead/WriteGuard are instantiated before starting reading -// from/writing to the socket -class wxSocketReadGuard -{ -public: - wxSocketReadGuard(wxSocketBase *socket) - : m_socket(socket) - { - wxASSERT_MSG( !m_socket->m_reading, "read reentrancy?" ); - - m_socket->m_reading = true; - } - - ~wxSocketReadGuard() - { - m_socket->m_reading = false; - - // connection could have been lost while reading, in this case calling - // ReenableEvents() would assert and is not necessary anyhow - wxSocketImpl * const impl = m_socket->m_impl; - if ( impl && impl->m_fd != INVALID_SOCKET ) - impl->ReenableEvents(wxSOCKET_INPUT_FLAG); - } - -private: - wxSocketBase * const m_socket; - - wxDECLARE_NO_COPY_CLASS(wxSocketReadGuard); -}; - -class wxSocketWriteGuard -{ -public: - wxSocketWriteGuard(wxSocketBase *socket) - : m_socket(socket) - { - wxASSERT_MSG( !m_socket->m_writing, "write reentrancy?" ); - - m_socket->m_writing = true; - } - - ~wxSocketWriteGuard() - { - m_socket->m_writing = false; - - wxSocketImpl * const impl = m_socket->m_impl; - if ( impl && impl->m_fd != INVALID_SOCKET ) - impl->ReenableEvents(wxSOCKET_OUTPUT_FLAG); - } - -private: - wxSocketBase * const m_socket; - - wxDECLARE_NO_COPY_CLASS(wxSocketWriteGuard); -}; - -// ============================================================================ -// wxSocketManager -// ============================================================================ - -wxSocketManager *wxSocketManager::ms_manager = NULL; - -/* static */ -void wxSocketManager::Set(wxSocketManager *manager) -{ - wxASSERT_MSG( !ms_manager, "too late to set manager now" ); - - ms_manager = manager; -} - -/* static */ -void wxSocketManager::Init() -{ - wxASSERT_MSG( !ms_manager, "shouldn't be initialized twice" ); - - /* - Details: Initialize() creates a hidden window as a sink for socket - events, such as 'read completed'. wxMSW has only one message loop - for the main thread. If Initialize is called in a secondary thread, - the socket window will be created for the secondary thread, but - since there is no message loop on this thread, it will never - receive events and all socket operations will time out. - BTW, the main thread must not be stopped using sleep or block - on a semaphore (a bad idea in any case) or socket operations - will time out. - - On the Mac side, Initialize() stores a pointer to the CFRunLoop for - the main thread. Because secondary threads do not have run loops, - adding event notifications to the "Current" loop would have no - effect at all, events would never fire. - */ - wxASSERT_MSG( wxIsMainThread(), - "sockets must be initialized from the main thread" ); - - wxAppConsole * const app = wxAppConsole::GetInstance(); - wxCHECK_RET( app, "sockets can't be initialized without wxApp" ); - - ms_manager = app->GetTraits()->GetSocketManager(); -} - -// ========================================================================== -// wxSocketImpl -// ========================================================================== - -wxSocketImpl::wxSocketImpl(wxSocketBase& wxsocket) - : m_wxsocket(&wxsocket) -{ - m_fd = INVALID_SOCKET; - m_error = wxSOCKET_NOERROR; - m_server = false; - m_stream = true; - - SetTimeout(wxsocket.GetTimeout() * 1000); - - m_establishing = false; - m_reusable = false; - m_broadcast = false; - m_dobind = true; - m_initialRecvBufferSize = -1; - m_initialSendBufferSize = -1; -} - -wxSocketImpl::~wxSocketImpl() -{ - if ( m_fd != INVALID_SOCKET ) - Shutdown(); -} - -bool wxSocketImpl::PreCreateCheck(const wxSockAddressImpl& addr) -{ - if ( m_fd != INVALID_SOCKET ) - { - m_error = wxSOCKET_INVSOCK; - return false; - } - - if ( !addr.IsOk() ) - { - m_error = wxSOCKET_INVADDR; - return false; - } - - return true; -} - -void wxSocketImpl::PostCreation() -{ - // FreeBSD variants can't use MSG_NOSIGNAL, and instead use a socket option -#ifdef SO_NOSIGPIPE - EnableSocketOption(SO_NOSIGPIPE); -#endif - - if ( m_reusable ) - EnableSocketOption(SO_REUSEADDR); - - if ( m_broadcast ) - { - wxASSERT_MSG( !m_stream, "broadcasting is for datagram sockets only" ); - - EnableSocketOption(SO_BROADCAST); - } - - if ( m_initialRecvBufferSize >= 0 ) - SetSocketOption(SO_RCVBUF, m_initialRecvBufferSize); - if ( m_initialSendBufferSize >= 0 ) - SetSocketOption(SO_SNDBUF, m_initialSendBufferSize); - - // we always put our sockets in unblocked mode and handle blocking - // ourselves in DoRead/Write() if wxSOCKET_WAITALL is specified - UnblockAndRegisterWithEventLoop(); -} - -wxSocketError wxSocketImpl::UpdateLocalAddress() -{ - if ( !m_local.IsOk() ) - { - // ensure that we have a valid object using the correct family: correct - // being the same one as our peer uses as we have no other way to - // determine it - m_local.Create(m_peer.GetFamily()); - } - - WX_SOCKLEN_T lenAddr = m_local.GetLen(); - if ( getsockname(m_fd, m_local.GetWritableAddr(), &lenAddr) != 0 ) - { - Close(); - m_error = wxSOCKET_IOERR; - return m_error; - } - - return wxSOCKET_NOERROR; -} - -wxSocketError wxSocketImpl::CreateServer() -{ - if ( !PreCreateCheck(m_local) ) - return m_error; - - m_server = true; - m_stream = true; - - // do create the socket - m_fd = socket(m_local.GetFamily(), SOCK_STREAM, 0); - - if ( m_fd == INVALID_SOCKET ) - { - m_error = wxSOCKET_IOERR; - return wxSOCKET_IOERR; - } - - PostCreation(); - - // and then bind to and listen on it - // - // FIXME: should we test for m_dobind here? - if ( bind(m_fd, m_local.GetAddr(), m_local.GetLen()) != 0 ) - m_error = wxSOCKET_IOERR; - - if ( IsOk() ) - { - if ( listen(m_fd, 5) != 0 ) - m_error = wxSOCKET_IOERR; - } - - if ( !IsOk() ) - { - Close(); - return m_error; - } - - // finally retrieve the address we effectively bound to - return UpdateLocalAddress(); -} - -wxSocketError wxSocketImpl::CreateClient(bool wait) -{ - if ( !PreCreateCheck(m_peer) ) - return m_error; - - m_fd = socket(m_peer.GetFamily(), SOCK_STREAM, 0); - - if ( m_fd == INVALID_SOCKET ) - { - m_error = wxSOCKET_IOERR; - return wxSOCKET_IOERR; - } - - PostCreation(); - - // If a local address has been set, then bind to it before calling connect - if ( m_local.IsOk() ) - { - if ( bind(m_fd, m_local.GetAddr(), m_local.GetLen()) != 0 ) - { - Close(); - m_error = wxSOCKET_IOERR; - return m_error; - } - } - - // Do connect now - int rc = connect(m_fd, m_peer.GetAddr(), m_peer.GetLen()); - if ( rc == SOCKET_ERROR ) - { - wxSocketError err = GetLastError(); - if ( err == wxSOCKET_WOULDBLOCK ) - { - m_establishing = true; - - // block waiting for connection if we should (otherwise just return - // wxSOCKET_WOULDBLOCK to the caller) - if ( wait ) - { - err = SelectWithTimeout(wxSOCKET_CONNECTION_FLAG) - ? wxSOCKET_NOERROR - : wxSOCKET_TIMEDOUT; - m_establishing = false; - } - } - - m_error = err; - } - else // connected - { - m_error = wxSOCKET_NOERROR; - } - - return m_error; -} - - -wxSocketError wxSocketImpl::CreateUDP() -{ - if ( !PreCreateCheck(m_local) ) - return m_error; - - m_stream = false; - m_server = false; - - m_fd = socket(m_local.GetFamily(), SOCK_DGRAM, 0); - - if ( m_fd == INVALID_SOCKET ) - { - m_error = wxSOCKET_IOERR; - return wxSOCKET_IOERR; - } - - PostCreation(); - - if ( m_dobind ) - { - if ( bind(m_fd, m_local.GetAddr(), m_local.GetLen()) != 0 ) - { - Close(); - m_error = wxSOCKET_IOERR; - return m_error; - } - - return UpdateLocalAddress(); - } - - return wxSOCKET_NOERROR; -} - -wxSocketImpl *wxSocketImpl::Accept(wxSocketBase& wxsocket) -{ - wxSockAddressStorage from; - WX_SOCKLEN_T fromlen = sizeof(from); - const wxSOCKET_T fd = accept(m_fd, &from.addr, &fromlen); - - // accepting is similar to reading in the sense that it resets "ready for - // read" flag on the socket - ReenableEvents(wxSOCKET_INPUT_FLAG); - - if ( fd == INVALID_SOCKET ) - return NULL; - - wxSocketManager * const manager = wxSocketManager::Get(); - if ( !manager ) - return NULL; - - wxSocketImpl * const sock = manager->CreateSocket(wxsocket); - if ( !sock ) - return NULL; - - sock->m_fd = fd; - sock->m_peer = wxSockAddressImpl(from.addr, fromlen); - - sock->UnblockAndRegisterWithEventLoop(); - - return sock; -} - - -void wxSocketImpl::Close() -{ - if ( m_fd != INVALID_SOCKET ) - { - DoClose(); - m_fd = INVALID_SOCKET; - } -} - -void wxSocketImpl::Shutdown() -{ - if ( m_fd != INVALID_SOCKET ) - { - shutdown(m_fd, 1 /* SD_SEND */); - Close(); - } -} - -/* - * Sets the timeout for blocking calls. Time is expressed in - * milliseconds. - */ -void wxSocketImpl::SetTimeout(unsigned long millis) -{ - SetTimeValFromMS(m_timeout, millis); -} - -void wxSocketImpl::NotifyOnStateChange(wxSocketNotify event) -{ - m_wxsocket->OnRequest(event); -} - -/* Address handling */ -wxSocketError wxSocketImpl::SetLocal(const wxSockAddressImpl& local) -{ - /* the socket must be initialized, or it must be a server */ - if (m_fd != INVALID_SOCKET && !m_server) - { - m_error = wxSOCKET_INVSOCK; - return wxSOCKET_INVSOCK; - } - - if ( !local.IsOk() ) - { - m_error = wxSOCKET_INVADDR; - return wxSOCKET_INVADDR; - } - - m_local = local; - - return wxSOCKET_NOERROR; -} - -wxSocketError wxSocketImpl::SetPeer(const wxSockAddressImpl& peer) -{ - if ( !peer.IsOk() ) - { - m_error = wxSOCKET_INVADDR; - return wxSOCKET_INVADDR; - } - - m_peer = peer; - - return wxSOCKET_NOERROR; -} - -const wxSockAddressImpl& wxSocketImpl::GetLocal() -{ - if ( !m_local.IsOk() ) - UpdateLocalAddress(); - - return m_local; -} - -// ---------------------------------------------------------------------------- -// wxSocketImpl IO -// ---------------------------------------------------------------------------- - -// this macro wraps the given expression (normally a syscall) in a loop which -// ignores any interruptions, i.e. reevaluates it again if it failed and errno -// is EINTR -#ifdef __UNIX__ - #define DO_WHILE_EINTR( rc, syscall ) \ - do { \ - rc = (syscall); \ - } \ - while ( rc == -1 && errno == EINTR ) -#else - #define DO_WHILE_EINTR( rc, syscall ) rc = (syscall) -#endif - -int wxSocketImpl::RecvStream(void *buffer, int size) -{ - int ret; - DO_WHILE_EINTR( ret, recv(m_fd, static_cast(buffer), size, 0) ); - - if ( !ret ) - { - // receiving 0 bytes for a TCP socket indicates that the connection was - // closed by peer so shut down our end as well (for UDP sockets empty - // datagrams are also possible) - m_establishing = false; - NotifyOnStateChange(wxSOCKET_LOST); - - Shutdown(); - - // do not return an error in this case however - } - - return ret; -} - -int wxSocketImpl::SendStream(const void *buffer, int size) -{ -#ifdef wxNEEDS_IGNORE_SIGPIPE - IgnoreSignal ignore(SIGPIPE); -#endif - - int ret; - DO_WHILE_EINTR( ret, send(m_fd, static_cast(buffer), size, - wxSOCKET_MSG_NOSIGNAL) ); - - return ret; -} - -int wxSocketImpl::RecvDgram(void *buffer, int size) -{ - wxSockAddressStorage from; - WX_SOCKLEN_T fromlen = sizeof(from); - - int ret; - DO_WHILE_EINTR( ret, recvfrom(m_fd, static_cast(buffer), size, - 0, &from.addr, &fromlen) ); - - if ( ret == SOCKET_ERROR ) - return SOCKET_ERROR; - - m_peer = wxSockAddressImpl(from.addr, fromlen); - if ( !m_peer.IsOk() ) - return -1; - - return ret; -} - -int wxSocketImpl::SendDgram(const void *buffer, int size) -{ - if ( !m_peer.IsOk() ) - { - m_error = wxSOCKET_INVADDR; - return -1; - } - - int ret; - DO_WHILE_EINTR( ret, sendto(m_fd, static_cast(buffer), size, - 0, m_peer.GetAddr(), m_peer.GetLen()) ); - - return ret; -} - -int wxSocketImpl::Read(void *buffer, int size) -{ - // server sockets can't be used for IO, only to accept new connections - if ( m_fd == INVALID_SOCKET || m_server ) - { - m_error = wxSOCKET_INVSOCK; - return -1; - } - - int ret = m_stream ? RecvStream(buffer, size) - : RecvDgram(buffer, size); - - m_error = ret == SOCKET_ERROR ? GetLastError() : wxSOCKET_NOERROR; - - return ret; -} - -int wxSocketImpl::Write(const void *buffer, int size) -{ - if ( m_fd == INVALID_SOCKET || m_server ) - { - m_error = wxSOCKET_INVSOCK; - return -1; - } - - int ret = m_stream ? SendStream(buffer, size) - : SendDgram(buffer, size); - - m_error = ret == SOCKET_ERROR ? GetLastError() : wxSOCKET_NOERROR; - - return ret; -} - -// ========================================================================== -// wxSocketBase -// ========================================================================== - -// -------------------------------------------------------------------------- -// Initialization and shutdown -// -------------------------------------------------------------------------- - -namespace -{ - -// counts the number of calls to Initialize() minus the number of calls to -// Shutdown(): we don't really need it any more but it was documented that -// Shutdown() must be called the same number of times as Initialize() and using -// a counter helps us to check it -int gs_socketInitCount = 0; - -} // anonymous namespace - -bool wxSocketBase::IsInitialized() -{ - wxASSERT_MSG( wxIsMainThread(), "unsafe to call from other threads" ); - - return gs_socketInitCount != 0; -} - -bool wxSocketBase::Initialize() -{ - wxCHECK_MSG( wxIsMainThread(), false, - "must be called from the main thread" ); - - if ( !gs_socketInitCount ) - { - wxSocketManager * const manager = wxSocketManager::Get(); - if ( !manager || !manager->OnInit() ) - return false; - } - - gs_socketInitCount++; - - return true; -} - -void wxSocketBase::Shutdown() -{ - wxCHECK_RET( wxIsMainThread(), "must be called from the main thread" ); - - wxCHECK_RET( gs_socketInitCount > 0, "too many calls to Shutdown()" ); - - if ( !--gs_socketInitCount ) - { - wxSocketManager * const manager = wxSocketManager::Get(); - wxCHECK_RET( manager, "should have a socket manager" ); - - manager->OnExit(); - } -} - -// -------------------------------------------------------------------------- -// Ctor and dtor -// -------------------------------------------------------------------------- - -void wxSocketBase::Init() -{ - m_impl = NULL; - m_type = wxSOCKET_UNINIT; - - // state - m_flags = 0; - m_connected = - m_establishing = - m_reading = - m_writing = - m_closed = false; - m_lcount = 0; - m_lcount_read = 0; - m_lcount_write = 0; - m_timeout = 600; - m_beingDeleted = false; - - // pushback buffer - m_unread = NULL; - m_unrd_size = 0; - m_unrd_cur = 0; - - // events - m_id = wxID_ANY; - m_handler = NULL; - m_clientData = NULL; - m_notify = false; - m_eventmask = - m_eventsgot = 0; - - // when we create the first socket in the main thread we initialize the - // OS-dependent socket stuff: notice that this means that the user code - // needs to call wxSocket::Initialize() itself if the first socket it - // creates is not created in the main thread - if ( wxIsMainThread() ) - { - if ( !Initialize() ) - { - wxLogError(_("Cannot initialize sockets")); - } - } -} - -wxSocketBase::wxSocketBase() -{ - Init(); -} - -wxSocketBase::wxSocketBase(wxSocketFlags flags, wxSocketType type) -{ - Init(); - - SetFlags(flags); - - m_type = type; -} - -wxSocketBase::~wxSocketBase() -{ - // Shutdown and close the socket - if (!m_beingDeleted) - Close(); - - // Destroy the implementation object - delete m_impl; - - // Free the pushback buffer - free(m_unread); -} - -bool wxSocketBase::Destroy() -{ - // Delayed destruction: the socket will be deleted during the next idle - // loop iteration. This ensures that all pending events have been - // processed. - m_beingDeleted = true; - - // Shutdown and close the socket - Close(); - - // Suppress events from now on - Notify(false); - - // Schedule this object for deletion instead of destroying it right now if - // it can have other events pending for it and we have a way to do it. - // - // Notice that sockets used in other threads won't have any events for them - // and we shouldn't use delayed destruction mechanism for them as it's not - // MT-safe. - if ( wxIsMainThread() && wxTheApp ) - { - wxTheApp->ScheduleForDestruction(this); - } - else // no app - { - // in wxBase we might have no app object at all, don't leak memory - delete this; - } - - return true; -} - -// ---------------------------------------------------------------------------- -// simple accessors -// ---------------------------------------------------------------------------- - -void wxSocketBase::SetError(wxSocketError error) -{ - m_impl->m_error = error; -} - -wxSocketError wxSocketBase::LastError() const -{ - return m_impl->GetError(); -} - -// -------------------------------------------------------------------------- -// Basic IO calls -// -------------------------------------------------------------------------- - -// The following IO operations update m_lcount: -// {Read, Write, ReadMsg, WriteMsg, Peek, Unread, Discard} -bool wxSocketBase::Close() -{ - // Interrupt pending waits - InterruptWait(); - - ShutdownOutput(); - - m_connected = false; - m_establishing = false; - return true; -} - -void wxSocketBase::ShutdownOutput() -{ - if ( m_impl ) - m_impl->Shutdown(); -} - -wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes) -{ - wxSocketReadGuard read(this); - - m_lcount_read = DoRead(buffer, nbytes); - m_lcount = m_lcount_read; - - return *this; -} - -wxUint32 wxSocketBase::DoRead(void* buffer_, wxUint32 nbytes) -{ - wxCHECK_MSG( m_impl, 0, "socket must be valid" ); - - // We use pointer arithmetic here which doesn't work with void pointers. - char *buffer = static_cast(buffer_); - wxCHECK_MSG( buffer, 0, "NULL buffer" ); - - // Try the push back buffer first, even before checking whether the socket - // is valid to allow reading previously pushed back data from an already - // closed socket. - wxUint32 total = GetPushback(buffer, nbytes, false); - nbytes -= total; - buffer += total; - - while ( nbytes ) - { - // our socket is non-blocking so Read() will return immediately if - // there is nothing to read yet and it's more efficient to try it first - // before entering DoWait() which is going to start dispatching GUI - // events and, even more importantly, we must do this under Windows - // where we're not going to get notifications about socket being ready - // for reading before we read all the existing data from it - const int ret = !m_impl->m_stream || m_connected - ? m_impl->Read(buffer, nbytes) - : 0; - if ( ret == -1 ) - { - if ( m_impl->GetLastError() == wxSOCKET_WOULDBLOCK ) - { - // if we don't want to wait, just return immediately - if ( m_flags & wxSOCKET_NOWAIT_READ ) - { - // this shouldn't be counted as an error in this case - SetError(wxSOCKET_NOERROR); - break; - } - - // otherwise wait until the socket becomes ready for reading or - // an error occurs on it - if ( !DoWaitWithTimeout(wxSOCKET_INPUT_FLAG) ) - { - // and exit if the timeout elapsed before it did - SetError(wxSOCKET_TIMEDOUT); - break; - } - - // retry reading - continue; - } - else // "real" error - { - SetError(wxSOCKET_IOERR); - break; - } - } - else if ( ret == 0 ) - { - // for connection-oriented (e.g. TCP) sockets we can only read - // 0 bytes if the other end has been closed, and for connectionless - // ones (UDP) this flag doesn't make sense anyhow so we can set it - // to true too without doing any harm - m_closed = true; - - // we're not going to read anything else and so if we haven't read - // anything (or not everything in wxSOCKET_WAITALL case) already, - // signal an error - if ( (m_flags & wxSOCKET_WAITALL_READ) || !total ) - SetError(wxSOCKET_IOERR); - break; - } - - total += ret; - - // if we are happy to read something and not the entire nbytes bytes, - // then we're done - if ( !(m_flags & wxSOCKET_WAITALL_READ) ) - break; - - nbytes -= ret; - buffer += ret; - } - - return total; -} - -wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes) -{ - struct - { - unsigned char sig[4]; - unsigned char len[4]; - } msg; - - wxSocketReadGuard read(this); - - wxSocketWaitModeChanger changeFlags(this, wxSOCKET_WAITALL_READ); - - bool ok = false; - if ( DoRead(&msg, sizeof(msg)) == sizeof(msg) ) - { - wxUint32 sig = (wxUint32)msg.sig[0]; - sig |= (wxUint32)(msg.sig[1] << 8); - sig |= (wxUint32)(msg.sig[2] << 16); - sig |= (wxUint32)(msg.sig[3] << 24); - - if ( sig == 0xfeeddead ) - { - wxUint32 len = (wxUint32)msg.len[0]; - len |= (wxUint32)(msg.len[1] << 8); - len |= (wxUint32)(msg.len[2] << 16); - len |= (wxUint32)(msg.len[3] << 24); - - wxUint32 len2; - if (len > nbytes) - { - len2 = len - nbytes; - len = nbytes; - } - else - len2 = 0; - - // Don't attempt to read if the msg was zero bytes long. - m_lcount_read = len ? DoRead(buffer, len) : 0; - m_lcount = m_lcount_read; - - if ( len2 ) - { - char discard_buffer[MAX_DISCARD_SIZE]; - long discard_len; - - // NOTE: discarded bytes don't add to m_lcount. - do - { - discard_len = len2 > MAX_DISCARD_SIZE - ? MAX_DISCARD_SIZE - : len2; - discard_len = DoRead(discard_buffer, (wxUint32)discard_len); - len2 -= (wxUint32)discard_len; - } - while ((discard_len > 0) && len2); - } - - if ( !len2 && DoRead(&msg, sizeof(msg)) == sizeof(msg) ) - { - sig = (wxUint32)msg.sig[0]; - sig |= (wxUint32)(msg.sig[1] << 8); - sig |= (wxUint32)(msg.sig[2] << 16); - sig |= (wxUint32)(msg.sig[3] << 24); - - if ( sig == 0xdeadfeed ) - ok = true; - } - } - } - - if ( !ok ) - SetError(wxSOCKET_IOERR); - - return *this; -} - -wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes) -{ - wxSocketReadGuard read(this); - - // Peek() should never block - wxSocketWaitModeChanger changeFlags(this, wxSOCKET_NOWAIT); - - m_lcount = DoRead(buffer, nbytes); - - Pushback(buffer, m_lcount); - - return *this; -} - -wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes) -{ - wxSocketWriteGuard write(this); - - m_lcount_write = DoWrite(buffer, nbytes); - m_lcount = m_lcount_write; - - return *this; -} - -// This function is a mirror image of DoRead() except that it doesn't use the -// push back buffer and doesn't treat 0 return value specially (normally this -// shouldn't happen at all here), so please see comments there for explanations -wxUint32 wxSocketBase::DoWrite(const void *buffer_, wxUint32 nbytes) -{ - wxCHECK_MSG( m_impl, 0, "socket must be valid" ); - - const char *buffer = static_cast(buffer_); - wxCHECK_MSG( buffer, 0, "NULL buffer" ); - - wxUint32 total = 0; - while ( nbytes ) - { - if ( m_impl->m_stream && !m_connected ) - { - if ( (m_flags & wxSOCKET_WAITALL_WRITE) || !total ) - SetError(wxSOCKET_IOERR); - break; - } - - const int ret = m_impl->Write(buffer, nbytes); - if ( ret == -1 ) - { - if ( m_impl->GetLastError() == wxSOCKET_WOULDBLOCK ) - { - if ( m_flags & wxSOCKET_NOWAIT_WRITE ) - break; - - if ( !DoWaitWithTimeout(wxSOCKET_OUTPUT_FLAG) ) - { - SetError(wxSOCKET_TIMEDOUT); - break; - } - - continue; - } - else // "real" error - { - SetError(wxSOCKET_IOERR); - break; - } - } - - total += ret; - - if ( !(m_flags & wxSOCKET_WAITALL_WRITE) ) - break; - - nbytes -= ret; - buffer += ret; - } - - return total; -} - -wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes) -{ - struct - { - unsigned char sig[4]; - unsigned char len[4]; - } msg; - - wxSocketWriteGuard write(this); - - wxSocketWaitModeChanger changeFlags(this, wxSOCKET_WAITALL_WRITE); - - msg.sig[0] = (unsigned char) 0xad; - msg.sig[1] = (unsigned char) 0xde; - msg.sig[2] = (unsigned char) 0xed; - msg.sig[3] = (unsigned char) 0xfe; - - msg.len[0] = (unsigned char) (nbytes & 0xff); - msg.len[1] = (unsigned char) ((nbytes >> 8) & 0xff); - msg.len[2] = (unsigned char) ((nbytes >> 16) & 0xff); - msg.len[3] = (unsigned char) ((nbytes >> 24) & 0xff); - - bool ok = false; - if ( DoWrite(&msg, sizeof(msg)) == sizeof(msg) ) - { - m_lcount_write = DoWrite(buffer, nbytes); - m_lcount = m_lcount_write; - if ( m_lcount_write == nbytes ) - { - msg.sig[0] = (unsigned char) 0xed; - msg.sig[1] = (unsigned char) 0xfe; - msg.sig[2] = (unsigned char) 0xad; - msg.sig[3] = (unsigned char) 0xde; - msg.len[0] = - msg.len[1] = - msg.len[2] = - msg.len[3] = (char) 0; - - if ( DoWrite(&msg, sizeof(msg)) == sizeof(msg)) - ok = true; - } - } - - if ( !ok ) - SetError(wxSOCKET_IOERR); - - return *this; -} - -wxSocketBase& wxSocketBase::Unread(const void *buffer, wxUint32 nbytes) -{ - if (nbytes != 0) - Pushback(buffer, nbytes); - - SetError(wxSOCKET_NOERROR); - m_lcount = nbytes; - - return *this; -} - -wxSocketBase& wxSocketBase::Discard() -{ - char *buffer = new char[MAX_DISCARD_SIZE]; - wxUint32 ret; - wxUint32 total = 0; - - wxSocketReadGuard read(this); - - wxSocketWaitModeChanger changeFlags(this, wxSOCKET_NOWAIT); - - do - { - ret = DoRead(buffer, MAX_DISCARD_SIZE); - total += ret; - } - while (ret == MAX_DISCARD_SIZE); - - delete[] buffer; - m_lcount = total; - SetError(wxSOCKET_NOERROR); - - return *this; -} - -// -------------------------------------------------------------------------- -// Wait functions -// -------------------------------------------------------------------------- - -/* - This function will check for the events specified in the flags parameter, - and it will return a mask indicating which operations can be performed. - */ -wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags, - const timeval *timeout) -{ - if ( m_fd == INVALID_SOCKET ) - return (wxSOCKET_LOST_FLAG & flags); - - struct timeval tv; - if ( timeout ) - tv = *timeout; - else - tv.tv_sec = tv.tv_usec = 0; - - // prepare the FD sets, passing NULL for the one(s) we don't use - fd_set - readfds, *preadfds = NULL, - writefds, *pwritefds = NULL, - exceptfds; // always want to know about errors - - if ( flags & wxSOCKET_INPUT_FLAG ) - preadfds = &readfds; - - if ( flags & wxSOCKET_OUTPUT_FLAG ) - pwritefds = &writefds; - - // When using non-blocking connect() the client socket becomes connected - // (successfully or not) when it becomes writable but when using - // non-blocking accept() the server socket becomes connected when it - // becomes readable. - if ( flags & wxSOCKET_CONNECTION_FLAG ) - { - if ( m_server ) - preadfds = &readfds; - else - pwritefds = &writefds; - } - - if ( preadfds ) - { - wxFD_ZERO(preadfds); - wxFD_SET(m_fd, preadfds); - } - - if ( pwritefds ) - { - wxFD_ZERO(pwritefds); - wxFD_SET(m_fd, pwritefds); - } - - wxFD_ZERO(&exceptfds); - wxFD_SET(m_fd, &exceptfds); - - const int rc = select(m_fd + 1, preadfds, pwritefds, &exceptfds, &tv); - - // check for errors first - if ( rc == -1 || wxFD_ISSET(m_fd, &exceptfds) ) - { - m_establishing = false; - - return wxSOCKET_LOST_FLAG & flags; - } - - if ( rc == 0 ) - return 0; - - wxASSERT_MSG( rc == 1, "unexpected select() return value" ); - - wxSocketEventFlags detected = 0; - if ( preadfds && wxFD_ISSET(m_fd, preadfds) ) - { - // check for the case of a server socket waiting for connection - if ( m_server && (flags & wxSOCKET_CONNECTION_FLAG) ) - { - int error; - SOCKOPTLEN_T len = sizeof(error); - m_establishing = false; - getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len); - - if ( error ) - detected = wxSOCKET_LOST_FLAG; - else - detected |= wxSOCKET_CONNECTION_FLAG; - } - else // not called to get non-blocking accept() status - { - detected |= wxSOCKET_INPUT_FLAG; - } - } - - if ( pwritefds && wxFD_ISSET(m_fd, pwritefds) ) - { - // check for the case of non-blocking connect() - if ( m_establishing && !m_server ) - { - int error; - SOCKOPTLEN_T len = sizeof(error); - m_establishing = false; - getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len); - - if ( error ) - detected = wxSOCKET_LOST_FLAG; - else - detected |= wxSOCKET_CONNECTION_FLAG; - } - else // not called to get non-blocking connect() status - { - detected |= wxSOCKET_OUTPUT_FLAG; - } - } - - return detected & flags; -} - -int -wxSocketBase::DoWait(long seconds, long milliseconds, wxSocketEventFlags flags) -{ - // Use either the provided timeout or the default timeout value associated - // with this socket. - // - // TODO: allow waiting forever, see #9443 - const long timeout = seconds == -1 ? m_timeout * 1000 - : seconds * 1000 + milliseconds; - - return DoWait(timeout, flags); -} - -int -wxSocketBase::DoWait(long timeout, wxSocketEventFlags flags) -{ - wxCHECK_MSG( m_impl, -1, "can't wait on invalid socket" ); - - // we're never going to become ready in a TCP client if we're not connected - // any more (OTOH a server can call this to precisely wait for a connection - // so do wait for it in this case and UDP client is never "connected") - if ( !m_impl->IsServer() && - m_impl->m_stream && !m_connected && !m_establishing ) - return -1; - - // This can be set to true from Interrupt() to exit this function a.s.a.p. - m_interrupt = false; - - - const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout; - - // Get the active event loop which we'll use for the message dispatching - // when running in the main thread unless this was explicitly disabled by - // setting wxSOCKET_BLOCK flag - wxEventLoopBase *eventLoop; - if ( !(m_flags & wxSOCKET_BLOCK) && wxIsMainThread() ) - { - eventLoop = wxEventLoop::GetActive(); - } - else // in worker thread - { - // We never dispatch messages from threads other than the main one. - eventLoop = NULL; - } - - // Make sure the events we're interested in are enabled before waiting for - // them: this is really necessary here as otherwise this could happen: - // 1. DoRead(wxSOCKET_WAITALL) is called - // 2. There is nothing to read so DoWait(wxSOCKET_INPUT_FLAG) is called - // 3. Some, but not all data appears, wxSocketImplUnix::OnReadWaiting() - // is called and wxSOCKET_INPUT_FLAG events are disabled in it - // 4. Because of wxSOCKET_WAITALL we call DoWait() again but the events - // are still disabled and we block forever - // - // More elegant solution would be nice but for now simply re-enabling the - // events here will do - m_impl->ReenableEvents(flags & (wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)); - - - // Wait until we receive the event we're waiting for or the timeout expires - // (but note that we always execute the loop at least once, even if timeout - // is 0 as this is used for polling) - int rc = 0; - for ( bool firstTime = true; !m_interrupt; firstTime = false ) - { - long timeLeft = wxMilliClockToLong(timeEnd - wxGetLocalTimeMillis()); - if ( timeLeft < 0 ) - { - if ( !firstTime ) - break; // timed out - - timeLeft = 0; - } - - wxSocketEventFlags events; - if ( eventLoop ) - { - // reset them before starting to wait - m_eventsgot = 0; - - eventLoop->DispatchTimeout(timeLeft); - - events = m_eventsgot; - } - else // no event loop or waiting in another thread - { - // as explained below, we should always check for wxSOCKET_LOST_FLAG - timeval tv; - SetTimeValFromMS(tv, timeLeft); - events = m_impl->Select(flags | wxSOCKET_LOST_FLAG, &tv); - } - - // always check for wxSOCKET_LOST_FLAG, even if flags doesn't include - // it, as continuing to wait for anything else after getting it is - // pointless - if ( events & wxSOCKET_LOST_FLAG ) - { - m_connected = false; - m_establishing = false; - rc = -1; - break; - } - - // otherwise mask out the bits we're not interested in - events &= flags; - - // Incoming connection (server) or connection established (client)? - if ( events & wxSOCKET_CONNECTION_FLAG ) - { - m_connected = true; - m_establishing = false; - rc = true; - break; - } - - // Data available or output buffer ready? - if ( (events & wxSOCKET_INPUT_FLAG) || (events & wxSOCKET_OUTPUT_FLAG) ) - { - rc = true; - break; - } - } - - return rc; -} - -bool wxSocketBase::Wait(long seconds, long milliseconds) -{ - return DoWait(seconds, milliseconds, - wxSOCKET_INPUT_FLAG | - wxSOCKET_OUTPUT_FLAG | - wxSOCKET_CONNECTION_FLAG) != 0; -} - -bool wxSocketBase::WaitForRead(long seconds, long milliseconds) -{ - // Check pushback buffer before entering DoWait - if ( m_unread ) - return true; - - // Check if the socket is not already ready for input, if it is, there is - // no need to start waiting for it (worse, we'll actually never get a - // notification about the socket becoming ready if it is already under - // Windows) - if ( m_impl->Select(wxSOCKET_INPUT_FLAG) ) - return true; - - return DoWait(seconds, milliseconds, wxSOCKET_INPUT_FLAG) != 0; -} - - -bool wxSocketBase::WaitForWrite(long seconds, long milliseconds) -{ - if ( m_impl->Select(wxSOCKET_OUTPUT_FLAG) ) - return true; - - return DoWait(seconds, milliseconds, wxSOCKET_OUTPUT_FLAG) != 0; -} - -bool wxSocketBase::WaitForLost(long seconds, long milliseconds) -{ - return DoWait(seconds, milliseconds, wxSOCKET_LOST_FLAG) == -1; -} - -// -------------------------------------------------------------------------- -// Miscellaneous -// -------------------------------------------------------------------------- - -// -// Get local or peer address -// - -bool wxSocketBase::GetPeer(wxSockAddress& addr) const -{ - wxCHECK_MSG( m_impl, false, "invalid socket" ); - - const wxSockAddressImpl& peer = m_impl->GetPeer(); - if ( !peer.IsOk() ) - return false; - - addr.SetAddress(peer); - - return true; -} - -bool wxSocketBase::GetLocal(wxSockAddress& addr) const -{ - wxCHECK_MSG( m_impl, false, "invalid socket" ); - - const wxSockAddressImpl& local = m_impl->GetLocal(); - if ( !local.IsOk() ) - return false; - - addr.SetAddress(local); - - return true; -} - -// -// Save and restore socket state -// - -void wxSocketBase::SaveState() -{ - wxSocketState *state; - - state = new wxSocketState(); - - state->m_flags = m_flags; - state->m_notify = m_notify; - state->m_eventmask = m_eventmask; - state->m_clientData = m_clientData; - - m_states.Append(state); -} - -void wxSocketBase::RestoreState() -{ - wxList::compatibility_iterator node; - wxSocketState *state; - - node = m_states.GetLast(); - if (!node) - return; - - state = (wxSocketState *)node->GetData(); - - m_flags = state->m_flags; - m_notify = state->m_notify; - m_eventmask = state->m_eventmask; - m_clientData = state->m_clientData; - - m_states.Erase(node); - delete state; -} - -// -// Timeout and flags -// - -void wxSocketBase::SetTimeout(long seconds) -{ - m_timeout = seconds; - - if (m_impl) - m_impl->SetTimeout(m_timeout * 1000); -} - -void wxSocketBase::SetFlags(wxSocketFlags flags) -{ - // Do some sanity checking on the flags used: not all values can be used - // together. - wxASSERT_MSG( !(flags & wxSOCKET_NOWAIT) || - !(flags & (wxSOCKET_WAITALL | wxSOCKET_BLOCK)), - "Using wxSOCKET_WAITALL or wxSOCKET_BLOCK with " - "wxSOCKET_NOWAIT doesn't make sense" ); - - m_flags = flags; -} - - -// -------------------------------------------------------------------------- -// Event handling -// -------------------------------------------------------------------------- - -void wxSocketBase::OnRequest(wxSocketNotify notification) -{ - wxSocketEventFlags flag = 0; - switch ( notification ) - { - case wxSOCKET_INPUT: - flag = wxSOCKET_INPUT_FLAG; - break; - - case wxSOCKET_OUTPUT: - flag = wxSOCKET_OUTPUT_FLAG; - break; - - case wxSOCKET_CONNECTION: - flag = wxSOCKET_CONNECTION_FLAG; - - // we're now successfully connected - m_connected = true; - m_establishing = false; - - // error was previously set to wxSOCKET_WOULDBLOCK, but this is not - // the case any longer - SetError(wxSOCKET_NOERROR); - break; - - case wxSOCKET_LOST: - flag = wxSOCKET_LOST_FLAG; - - // if we lost the connection the socket is now closed and not - // connected any more - m_connected = false; - m_closed = true; - break; - - default: - wxFAIL_MSG( "unknown wxSocket notification" ); - } - - // remember the events which were generated for this socket, we're going to - // use this in DoWait() - m_eventsgot |= flag; - - // send the wx event if enabled and we're interested in it - if ( m_notify && (m_eventmask & flag) && m_handler ) - { - // don't generate the events when we're inside DoWait() called from our - // own code as we are going to consume the data that has just become - // available ourselves and the user code won't see it at all - if ( (notification == wxSOCKET_INPUT && m_reading) || - (notification == wxSOCKET_OUTPUT && m_writing) ) - { - return; - } - - wxSocketEvent event(m_id); - event.m_event = notification; - event.m_clientData = m_clientData; - event.SetEventObject(this); - - m_handler->AddPendingEvent(event); - } -} - -void wxSocketBase::Notify(bool notify) -{ - m_notify = notify; -} - -void wxSocketBase::SetNotify(wxSocketEventFlags flags) -{ - m_eventmask = flags; -} - -void wxSocketBase::SetEventHandler(wxEvtHandler& handler, int id) -{ - m_handler = &handler; - m_id = id; -} - -// -------------------------------------------------------------------------- -// Pushback buffer -// -------------------------------------------------------------------------- - -void wxSocketBase::Pushback(const void *buffer, wxUint32 size) -{ - if (!size) return; - - if (m_unread == NULL) - m_unread = malloc(size); - else - { - void *tmp; - - tmp = malloc(m_unrd_size + size); - memcpy((char *)tmp + size, m_unread, m_unrd_size); - free(m_unread); - - m_unread = tmp; - } - - m_unrd_size += size; - - memcpy(m_unread, buffer, size); -} - -wxUint32 wxSocketBase::GetPushback(void *buffer, wxUint32 size, bool peek) -{ - wxCHECK_MSG( buffer, 0, "NULL buffer" ); - - if (!m_unrd_size) - return 0; - - if (size > (m_unrd_size-m_unrd_cur)) - size = m_unrd_size-m_unrd_cur; - - memcpy(buffer, (char *)m_unread + m_unrd_cur, size); - - if (!peek) - { - m_unrd_cur += size; - if (m_unrd_size == m_unrd_cur) - { - free(m_unread); - m_unread = NULL; - m_unrd_size = 0; - m_unrd_cur = 0; - } - } - - return size; -} - - -// ========================================================================== -// wxSocketServer -// ========================================================================== - -// -------------------------------------------------------------------------- -// Ctor -// -------------------------------------------------------------------------- - -wxSocketServer::wxSocketServer(const wxSockAddress& addr, - wxSocketFlags flags) - : wxSocketBase(flags, wxSOCKET_SERVER) -{ - wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") ); - - wxSocketManager * const manager = wxSocketManager::Get(); - m_impl = manager ? manager->CreateSocket(*this) : NULL; - - if (!m_impl) - { - wxLogTrace( wxTRACE_Socket, wxT("*** Failed to create m_impl") ); - return; - } - - // Setup the socket as server - m_impl->SetLocal(addr.GetAddress()); - - if (GetFlags() & wxSOCKET_REUSEADDR) { - m_impl->SetReusable(); - } - if (GetFlags() & wxSOCKET_BROADCAST) { - m_impl->SetBroadcast(); - } - if (GetFlags() & wxSOCKET_NOBIND) { - m_impl->DontDoBind(); - } - - if (m_impl->CreateServer() != wxSOCKET_NOERROR) - { - wxDELETE(m_impl); - - wxLogTrace( wxTRACE_Socket, wxT("*** CreateServer() failed") ); - return; - } - - // Notice that we need a cast as wxSOCKET_T is 64 bit under Win64 and that - // the cast is safe because a wxSOCKET_T is a handle and so limited to 32 - // (or, actually, even 24) bit values anyhow. - wxLogTrace( wxTRACE_Socket, wxT("wxSocketServer on fd %u"), - static_cast(m_impl->m_fd) ); -} - -// -------------------------------------------------------------------------- -// Accept -// -------------------------------------------------------------------------- - -bool wxSocketServer::AcceptWith(wxSocketBase& sock, bool wait) -{ - if ( !m_impl || (m_impl->m_fd == INVALID_SOCKET) || !m_impl->IsServer() ) - { - wxFAIL_MSG( "can only be called for a valid server socket" ); - - SetError(wxSOCKET_INVSOCK); - - return false; - } - - if ( wait ) - { - // wait until we get a connection - if ( !m_impl->SelectWithTimeout(wxSOCKET_INPUT_FLAG) ) - { - SetError(wxSOCKET_TIMEDOUT); - - return false; - } - } - - sock.m_impl = m_impl->Accept(sock); - - if ( !sock.m_impl ) - { - SetError(m_impl->GetLastError()); - - return false; - } - - sock.m_type = wxSOCKET_BASE; - sock.m_connected = true; - - return true; -} - -wxSocketBase *wxSocketServer::Accept(bool wait) -{ - wxSocketBase* sock = new wxSocketBase(); - - sock->SetFlags(m_flags); - - if (!AcceptWith(*sock, wait)) - { - sock->Destroy(); - sock = NULL; - } - - return sock; -} - -bool wxSocketServer::WaitForAccept(long seconds, long milliseconds) -{ - return DoWait(seconds, milliseconds, wxSOCKET_CONNECTION_FLAG) == 1; -} - -wxSOCKET_T wxSocketBase::GetSocket() const -{ - wxASSERT_MSG( m_impl, wxS("Socket not initialised") ); - - return m_impl->m_fd; -} - - -bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen) -{ - wxASSERT_MSG( m_impl, wxT("Socket not initialised") ); - - SOCKOPTLEN_T lenreal = *optlen; - if ( getsockopt(m_impl->m_fd, level, optname, - static_cast(optval), &lenreal) != 0 ) - return false; - - *optlen = lenreal; - - return true; -} - -bool -wxSocketBase::SetOption(int level, int optname, const void *optval, int optlen) -{ - wxASSERT_MSG( m_impl, wxT("Socket not initialised") ); - - return setsockopt(m_impl->m_fd, level, optname, - static_cast(optval), optlen) == 0; -} - -bool wxSocketBase::SetLocal(const wxIPV4address& local) -{ - m_localAddress = local; - - return true; -} - -// ========================================================================== -// wxSocketClient -// ========================================================================== - -// -------------------------------------------------------------------------- -// Ctor and dtor -// -------------------------------------------------------------------------- - -wxSocketClient::wxSocketClient(wxSocketFlags flags) - : wxSocketBase(flags, wxSOCKET_CLIENT) -{ - m_initialRecvBufferSize = - m_initialSendBufferSize = -1; -} - -// -------------------------------------------------------------------------- -// Connect -// -------------------------------------------------------------------------- - -bool wxSocketClient::DoConnect(const wxSockAddress& remote, - const wxSockAddress* local, - bool wait) -{ - if ( m_impl ) - { - // Shutdown and destroy the old socket - Close(); - delete m_impl; - } - - m_connected = false; - m_establishing = false; - - // Create and set up the new one - wxSocketManager * const manager = wxSocketManager::Get(); - m_impl = manager ? manager->CreateSocket(*this) : NULL; - if ( !m_impl ) - return false; - - // Reuse makes sense for clients too, if we are trying to rebind to the same port - if (GetFlags() & wxSOCKET_REUSEADDR) - m_impl->SetReusable(); - if (GetFlags() & wxSOCKET_BROADCAST) - m_impl->SetBroadcast(); - if (GetFlags() & wxSOCKET_NOBIND) - m_impl->DontDoBind(); - - // Bind to the local IP address and port, when provided or if one had been - // set before - if ( !local && m_localAddress.GetAddress().IsOk() ) - local = &m_localAddress; - - if ( local ) - m_impl->SetLocal(local->GetAddress()); - - m_impl->SetInitialSocketBuffers(m_initialRecvBufferSize, m_initialSendBufferSize); - - m_impl->SetPeer(remote.GetAddress()); - - // Finally do create the socket and connect to the peer - const wxSocketError err = m_impl->CreateClient(wait); - - if ( err != wxSOCKET_NOERROR ) - { - if ( err == wxSOCKET_WOULDBLOCK ) - { - wxASSERT_MSG( !wait, "shouldn't get this for blocking connect" ); - - m_establishing = true; - } - - return false; - } - - m_connected = true; - return true; -} - -bool wxSocketClient::Connect(const wxSockAddress& remote, bool wait) -{ - return DoConnect(remote, NULL, wait); -} - -bool wxSocketClient::Connect(const wxSockAddress& remote, - const wxSockAddress& local, - bool wait) -{ - return DoConnect(remote, &local, wait); -} - -bool wxSocketClient::WaitOnConnect(long seconds, long milliseconds) -{ - if ( m_connected ) - { - // this happens if the initial attempt to connect succeeded without - // blocking - return true; - } - - wxCHECK_MSG( m_establishing && m_impl, false, - "No connection establishment attempt in progress" ); - - // notice that we return true even if DoWait() returned -1, i.e. if an - // error occurred and connection was lost: this is intentional as we should - // return false only if timeout expired without anything happening - return DoWait(seconds, milliseconds, wxSOCKET_CONNECTION_FLAG) != 0; -} - -// ========================================================================== -// wxDatagramSocket -// ========================================================================== - -wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr, - wxSocketFlags flags ) - : wxSocketBase( flags, wxSOCKET_DATAGRAM ) -{ - // Create the socket - wxSocketManager * const manager = wxSocketManager::Get(); - m_impl = manager ? manager->CreateSocket(*this) : NULL; - - if (!m_impl) - return; - - // Setup the socket as non connection oriented - m_impl->SetLocal(addr.GetAddress()); - if (flags & wxSOCKET_REUSEADDR) - { - m_impl->SetReusable(); - } - if (GetFlags() & wxSOCKET_BROADCAST) - { - m_impl->SetBroadcast(); - } - if (GetFlags() & wxSOCKET_NOBIND) - { - m_impl->DontDoBind(); - } - - if ( m_impl->CreateUDP() != wxSOCKET_NOERROR ) - { - wxDELETE(m_impl); - return; - } - - // Initialize all stuff - m_connected = false; - m_establishing = false; -} - -wxDatagramSocket& wxDatagramSocket::RecvFrom( wxSockAddress& addr, - void* buf, - wxUint32 nBytes ) -{ - Read(buf, nBytes); - GetPeer(addr); - return (*this); -} - -wxDatagramSocket& wxDatagramSocket::SendTo( const wxSockAddress& addr, - const void* buf, - wxUint32 nBytes ) -{ - wxASSERT_MSG( m_impl, wxT("Socket not initialised") ); - - m_impl->SetPeer(addr.GetAddress()); - Write(buf, nBytes); - return (*this); -} - -// ========================================================================== -// wxSocketModule -// ========================================================================== - -class wxSocketModule : public wxModule -{ -public: - virtual bool OnInit() - { - // wxSocketBase will call Initialize() itself only if sockets are - // really used, don't do it from here - return true; - } - - virtual void OnExit() - { - if ( wxSocketBase::IsInitialized() ) - wxSocketBase::Shutdown(); - } - -private: - DECLARE_DYNAMIC_CLASS(wxSocketModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule) - -#if defined(wxUSE_SELECT_DISPATCHER) && wxUSE_SELECT_DISPATCHER -// NOTE: we need to force linking against socketiohandler.cpp otherwise in -// static builds of wxWidgets the ManagerSetter::ManagerSetter ctor -// contained there wouldn't be ever called -wxFORCE_LINK_MODULE( socketiohandler ) -#endif - -// same for ManagerSetter in the MSW file -#ifdef __WINDOWS__ - wxFORCE_LINK_MODULE( mswsocket ) -#endif - -// and for OSXManagerSetter in the OS X one -#ifdef __WXOSX__ - wxFORCE_LINK_MODULE( osxsocket ) -#endif - -#endif // wxUSE_SOCKETS diff --git a/Source/3rd Party/wx/src/common/socketiohandler.cpp b/Source/3rd Party/wx/src/common/socketiohandler.cpp deleted file mode 100644 index 92f9e7f5f..000000000 --- a/Source/3rd Party/wx/src/common/socketiohandler.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/socketiohandler.cpp -// Purpose: implementation of wxFDIOHandler for wxSocket -// Author: Angel Vidal, Lukasz Michalski -// Created: 08.24.06 -// Copyright: (c) 2006 Angel vidal -// (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SOCKETS - -#include "wx/app.h" -#include "wx/apptrait.h" -#include "wx/private/socket.h" -#include "wx/link.h" - -// ============================================================================ -// wxSocketFDBasedManager implementation -// ============================================================================ - -bool wxSocketFDBasedManager::OnInit() -{ - wxAppTraits * const traits = wxApp::GetTraitsIfExists(); - if ( !traits ) - return false; - - m_fdioManager = traits->GetFDIOManager(); - return m_fdioManager != NULL; -} - -void wxSocketFDBasedManager::Install_Callback(wxSocketImpl *socket_, - wxSocketNotify event) -{ - wxSocketImplUnix * const - socket = static_cast(socket_); - - wxCHECK_RET( socket->m_fd != -1, - "shouldn't be called on invalid socket" ); - - const wxFDIOManager::Direction d = GetDirForEvent(socket, event); - - int& fd = FD(socket, d); - if ( fd != -1 ) - m_fdioManager->RemoveInput(socket, fd, d); - - fd = m_fdioManager->AddInput(socket, socket->m_fd, d); -} - -void wxSocketFDBasedManager::Uninstall_Callback(wxSocketImpl *socket_, - wxSocketNotify event) -{ - wxSocketImplUnix * const - socket = static_cast(socket_); - - const wxFDIOManager::Direction d = GetDirForEvent(socket, event); - - int& fd = FD(socket, d); - if ( fd != -1 ) - { - m_fdioManager->RemoveInput(socket, fd, d); - fd = -1; - } -} - -wxFDIOManager::Direction -wxSocketFDBasedManager::GetDirForEvent(wxSocketImpl *socket, - wxSocketNotify event) -{ - switch ( event ) - { - default: - wxFAIL_MSG( "unknown socket event" ); - return wxFDIOManager::INPUT; // we must return something - - case wxSOCKET_LOST: - wxFAIL_MSG( "unexpected socket event" ); - return wxFDIOManager::INPUT; // as above - - case wxSOCKET_INPUT: - return wxFDIOManager::INPUT; - - case wxSOCKET_OUTPUT: - return wxFDIOManager::OUTPUT; - - case wxSOCKET_CONNECTION: - // for server sockets we're interested in events indicating - // that a new connection is pending, i.e. that accept() will - // succeed and this is indicated by socket becoming ready for - // reading, while for the other ones we're interested in the - // completion of non-blocking connect() which is indicated by - // the socket becoming ready for writing - return socket->IsServer() ? wxFDIOManager::INPUT - : wxFDIOManager::OUTPUT; - } -} - -// set the wxBase variable to point to our wxSocketManager implementation -// -// see comments in wx/apptrait.h for the explanation of why do we do it -// like this -static struct ManagerSetter -{ - ManagerSetter() - { - static wxSocketFDBasedManager s_manager; - wxAppTraits::SetDefaultSocketManager(&s_manager); - } -} gs_managerSetter; - - -// see the relative linker macro in socket.cpp -wxFORCE_LINK_THIS_MODULE( socketiohandler ); - -#endif // wxUSE_SOCKETS diff --git a/Source/3rd Party/wx/src/common/spinbtncmn.cpp b/Source/3rd Party/wx/src/common/spinbtncmn.cpp deleted file mode 100644 index 9f2de7748..000000000 --- a/Source/3rd Party/wx/src/common/spinbtncmn.cpp +++ /dev/null @@ -1,98 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/spinbtncmn.cpp -// Purpose: wxSpinButton common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/app.h" -#endif - -#if wxUSE_SPINBTN - -#include "wx/spinbutt.h" - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxSpinButtonStyle ) -wxBEGIN_FLAGS( wxSpinButtonStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxSP_HORIZONTAL) - wxFLAGS_MEMBER(wxSP_VERTICAL) - wxFLAGS_MEMBER(wxSP_ARROW_KEYS) - wxFLAGS_MEMBER(wxSP_WRAP) -wxEND_FLAGS( wxSpinButtonStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinButton, wxControl, "wx/spinbutt.h") - -wxBEGIN_PROPERTIES_TABLE(wxSpinButton) - wxEVENT_RANGE_PROPERTY( Spin, wxEVT_SCROLL_TOP, wxEVT_SCROLL_CHANGED, wxSpinEvent ) - - wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( Min, int, SetMin, GetMin, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY( Max, int, SetMax, GetMax, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - - wxPROPERTY_FLAGS( WindowStyle, wxSpinButtonStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxSpinButton) - -wxCONSTRUCTOR_5( wxSpinButton, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle ) - -IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent) - - -#endif // wxUSE_SPINBTN diff --git a/Source/3rd Party/wx/src/common/spinctrlcmn.cpp b/Source/3rd Party/wx/src/common/spinctrlcmn.cpp deleted file mode 100644 index 4a0596b66..000000000 --- a/Source/3rd Party/wx/src/common/spinctrlcmn.cpp +++ /dev/null @@ -1,118 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/spinctrlcmn.cpp -// Purpose: define wxSpinCtrl event types -// Author: Peter Most -// Created: 01.11.08 -// Copyright: (c) 2008-2009 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/spinbutt.h" -#include "wx/spinctrl.h" - -#if wxUSE_SPINCTRL - -wxDEFINE_EVENT(wxEVT_SPINCTRL, wxSpinEvent); -wxDEFINE_EVENT(wxEVT_SPINCTRLDOUBLE, wxSpinDoubleEvent); - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxSpinCtrlStyle ) -wxBEGIN_FLAGS( wxSpinCtrlStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxSP_HORIZONTAL) -wxFLAGS_MEMBER(wxSP_VERTICAL) -wxFLAGS_MEMBER(wxSP_ARROW_KEYS) -wxFLAGS_MEMBER(wxSP_WRAP) -wxEND_FLAGS( wxSpinCtrlStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl, wxControl, "wx/spinctrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxSpinCtrl) -wxEVENT_RANGE_PROPERTY( Spin, wxEVT_SCROLL_TOP, wxEVT_SCROLL_CHANGED, wxSpinEvent ) - -wxEVENT_PROPERTY( Updated, wxEVT_SPINCTRL, wxCommandEvent ) -wxEVENT_PROPERTY( TextUpdated, wxEVT_TEXT, wxCommandEvent ) -wxEVENT_PROPERTY( TextEnter, wxEVT_TEXT_ENTER, wxCommandEvent ) - -wxPROPERTY( ValueString, wxString, SetValue, GetValue, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) ; -wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) -#if 0 - wxPROPERTY( Min, int, SetMin, GetMin, 0, 0 /*flags*/, wxT("Helpstring"), wxT("group") ) - wxPROPERTY( Max, int, SetMax, GetMax, 0, 0 /*flags*/, wxT("Helpstring"), wxT("group")) -#endif -wxPROPERTY_FLAGS( WindowStyle, wxSpinCtrlStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -/* - TODO PROPERTIES - style wxSP_ARROW_KEYS - */ -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxSpinCtrl) - -wxCONSTRUCTOR_6( wxSpinCtrl, wxWindow*, Parent, wxWindowID, Id, \ - wxString, ValueString, wxPoint, Position, \ - wxSize, Size, long, WindowStyle ) - - -wxString wxPrivate::wxSpinCtrlFormatAsHex(long val, long maxVal) -{ - // We format the value like this is for compatibility with (native - // behaviour of) wxMSW - wxString text; - if ( maxVal < 0x10000 ) - text.Printf(wxS("0x%04lx"), val); - else - text.Printf(wxS("0x%08lx"), val); - - return text; -} - -#endif // wxUSE_SPINCTRL diff --git a/Source/3rd Party/wx/src/common/srchcmn.cpp b/Source/3rd Party/wx/src/common/srchcmn.cpp index 1e524b539..093577f5c 100644 --- a/Source/3rd Party/wx/src/common/srchcmn.cpp +++ b/Source/3rd Party/wx/src/common/srchcmn.cpp @@ -4,6 +4,7 @@ // Author: Robin Dunn // Modified by: // Created: 19-Dec-2006 +// RCS-ID: $Id: srchcmn.cpp 43939 2006-12-11 20:32:16Z KO $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,10 +33,10 @@ // ---------------------------------------------------------------------------- -const char wxSearchCtrlNameStr[] = "searchCtrl"; +const wxChar wxSearchCtrlNameStr[] = wxT("searchCtrl"); -wxDEFINE_EVENT(wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent); -wxDEFINE_EVENT(wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN) #endif // wxUSE_SEARCHCTRL diff --git a/Source/3rd Party/wx/src/common/sstream.cpp b/Source/3rd Party/wx/src/common/sstream.cpp index 009e2c04b..3d792b174 100644 --- a/Source/3rd Party/wx/src/common/sstream.cpp +++ b/Source/3rd Party/wx/src/common/sstream.cpp @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/common/sstream.cpp +// Name: common/sstream.cpp // Purpose: string-based streams implementation // Author: Vadim Zeitlin // Modified by: Ryan Norton (UTF8 UNICODE) // Created: 2004-09-19 +// RCS-ID: $Id: sstream.cpp 45772 2007-05-03 02:19:16Z VZ $ // Copyright: (c) 2004 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -27,6 +28,10 @@ #include "wx/sstream.h" +#if wxUSE_UNICODE + #include "wx/hashmap.h" +#endif + // ============================================================================ // wxStringInputStream implementation // ============================================================================ @@ -39,18 +44,25 @@ // just add +1 to m_len in the ctor wxStringInputStream::wxStringInputStream(const wxString& s) #if wxUSE_UNICODE - // FIXME-UTF8: use wxCharBufferWithLength if we have it - : m_str(s), m_buf(s.utf8_str()), m_len(strlen(m_buf)) + : m_str(s), m_buf(wxMBConvUTF8().cWX2MB(s).release()), m_len(strlen(m_buf)) #else - : m_str(s), m_buf(s.mb_str()), m_len(s.length()) + : m_str(s), m_buf((char*)s.c_str()), m_len(s.length()) #endif { #if wxUSE_UNICODE - wxASSERT_MSG(m_buf.data() != NULL, wxT("Could not convert string to UTF8!")); + wxASSERT_MSG(m_buf != NULL, _T("Could not convert string to UTF8!")); #endif m_pos = 0; } +wxStringInputStream::~wxStringInputStream() +{ +#if wxUSE_UNICODE + // Note: wx[W]CharBuffer uses malloc()/free() + free(m_buf); +#endif +} + // ---------------------------------------------------------------------------- // getlength // ---------------------------------------------------------------------------- @@ -81,11 +93,11 @@ wxFileOffset wxStringInputStream::OnSysSeek(wxFileOffset ofs, wxSeekMode mode) break; default: - wxFAIL_MSG( wxT("invalid seek mode") ); + wxFAIL_MSG( _T("invalid seek mode") ); return wxInvalidOffset; } - if ( ofs < 0 || ofs > static_cast(m_len) ) + if ( ofs < 0 || ofs > wx_static_cast(wxFileOffset, m_len) ) return wxInvalidOffset; // FIXME: this can't be right @@ -96,7 +108,7 @@ wxFileOffset wxStringInputStream::OnSysSeek(wxFileOffset ofs, wxSeekMode mode) wxFileOffset wxStringInputStream::OnSysTell() const { - return static_cast(m_pos); + return wx_static_cast(wxFileOffset, m_pos); } // ---------------------------------------------------------------------------- @@ -118,7 +130,7 @@ size_t wxStringInputStream::OnSysRead(void *buffer, size_t size) size = sizeMax; } - memcpy(buffer, m_buf.data() + m_pos, size); + memcpy(buffer, m_buf + m_pos, size); m_pos += size; return size; @@ -134,16 +146,36 @@ size_t wxStringInputStream::OnSysRead(void *buffer, size_t size) wxFileOffset wxStringOutputStream::OnSysTell() const { - return static_cast(m_pos); + return wx_static_cast(wxFileOffset, m_pos); } // ---------------------------------------------------------------------------- // actual IO // ---------------------------------------------------------------------------- +#if wxUSE_UNICODE + +// we can't add a member to wxStringOutputStream in 2.8 branch without breaking +// backwards binary compatibility, so we emulate it by using a hash indexed by +// wxStringOutputStream pointers + +// can't use wxCharBuffer as it has incorrect copying semantics and doesn't +// store the length which we need here +WX_DECLARE_VOIDPTR_HASH_MAP(wxMemoryBuffer, wxStringStreamUnconvBuffers); + +static wxStringStreamUnconvBuffers gs_unconverted; + +wxStringOutputStream::~wxStringOutputStream() +{ + // TODO: check that nothing remains (i.e. the unconverted buffer is empty)? + gs_unconverted.erase(this); +} + +#endif // wxUSE_UNICODE + size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) { - const char *p = static_cast(buffer); + const char *p = wx_static_cast(const char *, buffer); #if wxUSE_UNICODE // the part of the string we have here may be incomplete, i.e. it can stop @@ -153,12 +185,13 @@ size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) // left unconverted before) const char *src; size_t srcLen; - if ( m_unconv.GetDataLen() ) + wxMemoryBuffer& unconv = gs_unconverted[this]; + if ( unconv.GetDataLen() ) { // append the new data to the data remaining since the last time - m_unconv.AppendData(p, size); - src = m_unconv; - srcLen = m_unconv.GetDataLen(); + unconv.AppendData(p, size); + src = unconv; + srcLen = unconv.GetDataLen(); } else // no unconverted data left, avoid extra copy { @@ -166,21 +199,20 @@ size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) srcLen = size; } - size_t wlen; - wxWCharBuffer wbuf(m_conv.cMB2WC(src, srcLen, &wlen)); + wxWCharBuffer wbuf(m_conv.cMB2WC(src, srcLen, NULL /* out len */)); if ( wbuf ) { // conversion succeeded, clear the unconverted buffer - m_unconv = wxMemoryBuffer(0); + unconv = wxMemoryBuffer(0); - m_str->append(wbuf, wlen); + *m_str += wbuf; } else // conversion failed { // remember unconverted data if there had been none before (otherwise // we've already got it in the buffer) if ( src == p ) - m_unconv.AppendData(src, srcLen); + unconv.AppendData(src, srcLen); // pretend that we wrote the data anyhow, otherwise the caller would // believe there was an error and this might not be the case, but do @@ -188,8 +220,8 @@ size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) return size; } #else // !wxUSE_UNICODE - // no recoding necessary - m_str->append(p, size); + // append directly, no conversion necessary + m_str->Append(wxString(p, size)); #endif // wxUSE_UNICODE/!wxUSE_UNICODE // update position diff --git a/Source/3rd Party/wx/src/common/statbar.cpp b/Source/3rd Party/wx/src/common/statbar.cpp index 4746f7bd9..82de44f33 100644 --- a/Source/3rd Party/wx/src/common/statbar.cpp +++ b/Source/3rd Party/wx/src/common/statbar.cpp @@ -2,10 +2,11 @@ // Name: src/common/statbar.cpp // Purpose: wxStatusBarBase implementation // Author: Vadim Zeitlin -// Modified by: Francesco Montorsi +// Modified by: // Created: 14.10.01 +// RCS-ID: $Id: statbar.cpp 42171 2006-10-20 14:54:14Z VS $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -31,76 +32,10 @@ #include "wx/frame.h" #endif //WX_PRECOMP -const char wxStatusBarNameStr[] = "statusBar"; +#include "wx/listimpl.cpp" +WX_DEFINE_LIST(wxListString) -// ============================================================================ -// wxStatusBarPane implementation -// ============================================================================ - -bool wxStatusBarPane::SetText(const wxString& text) -{ - if ( text == m_text ) - return false; - - /* - If we have a message to restore on the stack, we update it to - correspond to the current one so that a sequence of calls such as - - 1. SetStatusText("foo") - 2. PushStatusText("bar") - 3. SetStatusText("new foo") - 4. PopStatusText() - - doesn't overwrite the "new foo" which should be shown at the end with - the old value "foo". This would be unexpected and hard to avoid, - especially when PushStatusText() is used internally by wxWidgets - without knowledge of the user program, as it is for showing the menu - and toolbar help strings. - - By updating the top of the stack we ensure that the next call to - PopStatusText() basically becomes a NOP without breaking the balance - between the calls to push and pop as we would have done if we really - called PopStatusText() here. - */ - if ( !m_arrStack.empty() ) - { - m_arrStack.back() = text; - } - - m_text = text; - - return true; -} - -bool wxStatusBarPane::PushText(const wxString& text) -{ - // save the currently shown text - m_arrStack.push_back(m_text); - - // and update the new one if necessary - if ( text == m_text ) - return false; - - m_text = text; - - return true; -} - -bool wxStatusBarPane::PopText() -{ - wxCHECK_MSG( !m_arrStack.empty(), false, "no status message to pop" ); - - const wxString text = m_arrStack.back(); - - m_arrStack.pop_back(); - - if ( text == m_text ) - return false; - - m_text = text; - - return true; -} +const wxChar wxStatusBarNameStr[] = wxT("statusBar"); // ============================================================================ // wxStatusBarBase implementation @@ -108,26 +43,60 @@ bool wxStatusBarPane::PopText() IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow) -#include "wx/arrimpl.cpp" // This is a magic incantation which must be done! -WX_DEFINE_EXPORTED_OBJARRAY(wxStatusBarPaneArray) - - // ---------------------------------------------------------------------------- // ctor/dtor // ---------------------------------------------------------------------------- wxStatusBarBase::wxStatusBarBase() { - m_bSameWidthForAllPanes = true; + m_nFields = 0; + + InitWidths(); + InitStacks(); + InitStyles(); } wxStatusBarBase::~wxStatusBarBase() { + FreeWidths(); + FreeStacks(); + FreeStyles(); + // notify the frame that it doesn't have a status bar any longer to avoid // dangling pointers wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); if ( frame && frame->GetStatusBar() == this ) + { frame->SetStatusBar(NULL); + } +} + +// ---------------------------------------------------------------------------- +// widths array handling +// ---------------------------------------------------------------------------- + +void wxStatusBarBase::InitWidths() +{ + m_statusWidths = NULL; +} + +void wxStatusBarBase::FreeWidths() +{ + delete [] m_statusWidths; +} + +// ---------------------------------------------------------------------------- +// styles array handling +// ---------------------------------------------------------------------------- + +void wxStatusBarBase::InitStyles() +{ + m_statusStyles = NULL; +} + +void wxStatusBarBase::FreeStyles() +{ + delete [] m_statusStyles; } // ---------------------------------------------------------------------------- @@ -136,44 +105,90 @@ wxStatusBarBase::~wxStatusBarBase() void wxStatusBarBase::SetFieldsCount(int number, const int *widths) { - wxCHECK_RET( number > 0, wxT("invalid field number in SetFieldsCount") ); + wxCHECK_RET( number > 0, _T("invalid field number in SetFieldsCount") ); - if ( (size_t)number > m_panes.GetCount() ) + bool refresh = false; + + if ( number != m_nFields ) { - wxStatusBarPane newPane; + // copy stacks if present + if(m_statusTextStacks) + { + wxListString **newStacks = new wxListString*[number]; + size_t i, j, max = wxMin(number, m_nFields); - // add more entries with the default style and zero width - // (this will be set later) - for (size_t i = m_panes.GetCount(); i < (size_t)number; ++i) - m_panes.Add(newPane); + // copy old stacks + for(i = 0; i < max; ++i) + newStacks[i] = m_statusTextStacks[i]; + // free old stacks in excess + for(j = i; j < (size_t)m_nFields; ++j) + { + if(m_statusTextStacks[j]) + { + m_statusTextStacks[j]->Clear(); + delete m_statusTextStacks[j]; + } + } + // initialize new stacks to NULL + for(j = i; j < (size_t)number; ++j) + newStacks[j] = 0; + + m_statusTextStacks = newStacks; + } + + // Resize styles array + if (m_statusStyles) + { + int *oldStyles = m_statusStyles; + m_statusStyles = new int[number]; + int i, max = wxMin(number, m_nFields); + + // copy old styles + for (i = 0; i < max; ++i) + m_statusStyles[i] = oldStyles[i]; + + // initialize new styles to wxSB_NORMAL + for (i = max; i < number; ++i) + m_statusStyles[i] = wxSB_NORMAL; + + // free old styles + delete [] oldStyles; + } + + + m_nFields = number; + + ReinitWidths(); + + refresh = true; } - else if ( (size_t)number < m_panes.GetCount() ) + //else: keep the old m_statusWidths if we had them + + if ( widths ) { - // remove entries in excess - m_panes.RemoveAt(number, m_panes.GetCount()-number); + SetStatusWidths(number, widths); + + // already done from SetStatusWidths() + refresh = false; } - // SetStatusWidths will automatically refresh - SetStatusWidths(number, widths); + if ( refresh ) + Refresh(); } void wxStatusBarBase::SetStatusWidths(int WXUNUSED_UNLESS_DEBUG(n), - const int widths[]) + const int widths[]) { - wxASSERT_MSG( (size_t)n == m_panes.GetCount(), wxT("field number mismatch") ); + wxCHECK_RET( widths, _T("NULL pointer in SetStatusWidths") ); - if (widths == NULL) - { - // special value meaning: override explicit pane widths and make them all - // of the same size - m_bSameWidthForAllPanes = true; - } - else - { - for ( size_t i = 0; i < m_panes.GetCount(); i++ ) - m_panes[i].SetWidth(widths[i]); + wxASSERT_MSG( n == m_nFields, _T("field number mismatch") ); - m_bSameWidthForAllPanes = false; + if ( !m_statusWidths ) + m_statusWidths = new int[m_nFields]; + + for ( int i = 0; i < m_nFields; i++ ) + { + m_statusWidths[i] = widths[i]; } // update the display after the widths changed @@ -181,14 +196,19 @@ void wxStatusBarBase::SetStatusWidths(int WXUNUSED_UNLESS_DEBUG(n), } void wxStatusBarBase::SetStatusStyles(int WXUNUSED_UNLESS_DEBUG(n), - const int styles[]) + const int styles[]) { - wxCHECK_RET( styles, wxT("NULL pointer in SetStatusStyles") ); + wxCHECK_RET( styles, _T("NULL pointer in SetStatusStyles") ); - wxASSERT_MSG( (size_t)n == m_panes.GetCount(), wxT("field number mismatch") ); + wxASSERT_MSG( n == m_nFields, _T("field number mismatch") ); - for ( size_t i = 0; i < m_panes.GetCount(); i++ ) - m_panes[i].SetStyle(styles[i]); + if ( !m_statusStyles ) + m_statusStyles = new int[m_nFields]; + + for ( int i = 0; i < m_nFields; i++ ) + { + m_statusStyles[i] = styles[i]; + } // update the display after the widths changed Refresh(); @@ -198,51 +218,61 @@ wxArrayInt wxStatusBarBase::CalculateAbsWidths(wxCoord widthTotal) const { wxArrayInt widths; - if ( m_bSameWidthForAllPanes ) + if ( m_statusWidths == NULL ) { - // Default: all fields have the same width. This is not always - // possible to do exactly (if widthTotal is not divisible by - // m_panes.GetCount()) - if that happens, we distribute the extra - // pixels among all fields: - int widthToUse = widthTotal; - - for ( size_t i = m_panes.GetCount(); i > 0; i-- ) + if ( m_nFields ) { - // divide the unassigned width evently between the - // not yet processed fields: - int w = widthToUse / i; - widths.Add(w); - widthToUse -= w; + // Default: all fields have the same width. This is not always + // possible to do exactly (if widthTotal is not divisible by + // m_nFields) - if that happens, we distribute the extra pixels + // among all fields: + int widthToUse = widthTotal; + + for ( int i = m_nFields; i > 0; i-- ) + { + // divide the unassigned width evently between the + // not yet processed fields: + int w = widthToUse / i; + widths.Add(w); + widthToUse -= w; + } + } + //else: we're empty anyhow } - else // do not override explicit pane widths + else // have explicit status widths { // calculate the total width of all the fixed width fields and the // total number of var field widths counting with multiplicity - size_t nTotalWidth = 0, + int nTotalWidth = 0, nVarCount = 0, i; - - for ( i = 0; i < m_panes.GetCount(); i++ ) + for ( i = 0; i < m_nFields; i++ ) { - if ( m_panes[i].GetWidth() >= 0 ) - nTotalWidth += m_panes[i].GetWidth(); + if ( m_statusWidths[i] >= 0 ) + { + nTotalWidth += m_statusWidths[i]; + } else - nVarCount += -m_panes[i].GetWidth(); + { + nVarCount += -m_statusWidths[i]; + } } // the amount of extra width we have per each var width field int widthExtra = widthTotal - nTotalWidth; // do fill the array - for ( i = 0; i < m_panes.GetCount(); i++ ) + for ( i = 0; i < m_nFields; i++ ) { - if ( m_panes[i].GetWidth() >= 0 ) - widths.Add(m_panes[i].GetWidth()); + if ( m_statusWidths[i] >= 0 ) + { + widths.Add(m_statusWidths[i]); + } else { - int nVarWidth = widthExtra > 0 ? (widthExtra * (-m_panes[i].GetWidth())) / nVarCount : 0; - nVarCount += m_panes[i].GetWidth(); + int nVarWidth = widthExtra > 0 ? (widthExtra * -m_statusWidths[i]) / nVarCount : 0; + nVarCount += m_statusWidths[i]; widthExtra -= nVarWidth; widths.Add(nVarWidth); } @@ -253,54 +283,86 @@ wxArrayInt wxStatusBarBase::CalculateAbsWidths(wxCoord widthTotal) const } // ---------------------------------------------------------------------------- -// setting/getting status text +// text stacks handling // ---------------------------------------------------------------------------- -void wxStatusBarBase::SetStatusText(const wxString& text, int number) +void wxStatusBarBase::InitStacks() { - wxCHECK_RET( (unsigned)number < m_panes.size(), - "invalid status bar field index" ); - - if ( m_panes[number].SetText(text) ) - DoUpdateStatusText(number); + m_statusTextStacks = NULL; } -wxString wxStatusBarBase::GetStatusText(int number) const +void wxStatusBarBase::FreeStacks() { - wxCHECK_MSG( (unsigned)number < m_panes.size(), wxString(), - "invalid status bar field index" ); + if ( !m_statusTextStacks ) + return; - return m_panes[number].GetText(); -} + for ( size_t i = 0; i < (size_t)m_nFields; ++i ) + { + if ( m_statusTextStacks[i] ) + { + wxListString& t = *m_statusTextStacks[i]; + WX_CLEAR_LIST(wxListString, t); + delete m_statusTextStacks[i]; + } + } -void wxStatusBarBase::SetEllipsizedFlag(int number, bool isEllipsized) -{ - wxCHECK_RET( (unsigned)number < m_panes.size(), - "invalid status bar field index" ); - - m_panes[number].SetIsEllipsized(isEllipsized); + delete[] m_statusTextStacks; } // ---------------------------------------------------------------------------- -// pushing/popping status text +// text stacks // ---------------------------------------------------------------------------- void wxStatusBarBase::PushStatusText(const wxString& text, int number) { - wxCHECK_RET( (unsigned)number < m_panes.size(), - "invalid status bar field index" ); - - if ( m_panes[number].PushText(text) ) - DoUpdateStatusText(number); + wxListString* st = GetOrCreateStatusStack(number); + // This long-winded way around avoids an internal compiler error + // in VC++ 6 with RTTI enabled + wxString tmp1(GetStatusText(number)); + wxString* tmp = new wxString(tmp1); + st->Insert(tmp); + SetStatusText(text, number); } void wxStatusBarBase::PopStatusText(int number) { - wxCHECK_RET( (unsigned)number < m_panes.size(), - "invalid status bar field index" ); + wxListString *st = GetStatusStack(number); + wxCHECK_RET( st, _T("Unbalanced PushStatusText/PopStatusText") ); + wxListString::compatibility_iterator top = st->GetFirst(); - if ( m_panes[number].PopText() ) - DoUpdateStatusText(number); + SetStatusText(*top->GetData(), number); + delete top->GetData(); + st->Erase(top); + if(st->GetCount() == 0) + { + delete st; + m_statusTextStacks[number] = 0; + } +} + +wxListString *wxStatusBarBase::GetStatusStack(int i) const +{ + if(!m_statusTextStacks) + return 0; + return m_statusTextStacks[i]; +} + +wxListString *wxStatusBarBase::GetOrCreateStatusStack(int i) +{ + if(!m_statusTextStacks) + { + m_statusTextStacks = new wxListString*[m_nFields]; + + size_t j; + for(j = 0; j < (size_t)m_nFields; ++j) m_statusTextStacks[j] = 0; + } + + if(!m_statusTextStacks[i]) + { + m_statusTextStacks[i] = new wxListString(); + } + + return m_statusTextStacks[i]; } #endif // wxUSE_STATUSBAR diff --git a/Source/3rd Party/wx/src/common/statbmpcmn.cpp b/Source/3rd Party/wx/src/common/statbmpcmn.cpp deleted file mode 100644 index 5768c6c51..000000000 --- a/Source/3rd Party/wx/src/common/statbmpcmn.cpp +++ /dev/null @@ -1,86 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/statbmpcmn.cpp -// Purpose: wxStaticBitmap common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// declarations -// =========================================================================== - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STATBMP - -#include "wx/statbmp.h" - -extern WXDLLEXPORT_DATA(const char) wxStaticBitmapNameStr[] = "staticBitmap"; - -// --------------------------------------------------------------------------- -// XTI -// --------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxStaticBitmapStyle ) -wxBEGIN_FLAGS( wxStaticBitmapStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - -wxEND_FLAGS( wxStaticBitmapStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBitmap, wxControl, "wx/statbmp.h") - -wxBEGIN_PROPERTIES_TABLE(wxStaticBitmap) - wxPROPERTY_FLAGS( WindowStyle, wxStaticBitmapStyle, long, \ - SetWindowStyleFlag, GetWindowStyleFlag, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), \ - wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxStaticBitmap) - -wxCONSTRUCTOR_5( wxStaticBitmap, wxWindow*, Parent, wxWindowID, Id, \ - wxBitmap, Bitmap, wxPoint, Position, wxSize, Size ) - -/* - TODO PROPERTIES : - bitmap -*/ - -#endif // wxUSE_STATBMP diff --git a/Source/3rd Party/wx/src/common/statboxcmn.cpp b/Source/3rd Party/wx/src/common/statboxcmn.cpp deleted file mode 100644 index 5f0f05cbe..000000000 --- a/Source/3rd Party/wx/src/common/statboxcmn.cpp +++ /dev/null @@ -1,89 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/statboxcmn.cpp -// Purpose: wxStaticBox common code -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STATBOX - -#include "wx/statbox.h" - -extern WXDLLEXPORT_DATA(const char) wxStaticBoxNameStr[] = "groupBox"; - -wxStaticBoxBase::wxStaticBoxBase() -{ -#ifndef __WXGTK__ - m_container.DisableSelfFocus(); -#endif -} - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxStaticBoxStyle ) -wxBEGIN_FLAGS( wxStaticBoxStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) -wxEND_FLAGS( wxStaticBoxStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl, "wx/statbox.h") - -wxBEGIN_PROPERTIES_TABLE(wxStaticBox) - wxPROPERTY( Label, wxString, SetLabel, GetLabel, wxString(), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - wxPROPERTY_FLAGS( WindowStyle, wxStaticBoxStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxStaticBox) - -wxCONSTRUCTOR_6( wxStaticBox, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Label, wxPoint, Position, wxSize, Size, \ - long, WindowStyle ) - -#endif // wxUSE_STATBOX diff --git a/Source/3rd Party/wx/src/common/statlinecmn.cpp b/Source/3rd Party/wx/src/common/statlinecmn.cpp deleted file mode 100644 index ce311dfcc..000000000 --- a/Source/3rd Party/wx/src/common/statlinecmn.cpp +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/statlinecmn.cpp -// Purpose: wxStaticLine common code -// Author: Vadim Zeitlin -// Created: 28.06.99 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/statline.h" - -#if wxUSE_STATLINE - -extern WXDLLEXPORT_DATA(const char) wxStaticLineNameStr[] = "staticLine"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxStaticLineStyle ) -wxBEGIN_FLAGS( wxStaticLineStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxLI_HORIZONTAL) - wxFLAGS_MEMBER(wxLI_VERTICAL) -wxEND_FLAGS( wxStaticLineStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticLine, wxControl, "wx/statline.h") - -wxBEGIN_PROPERTIES_TABLE(wxStaticLine) - wxPROPERTY_FLAGS( WindowStyle, wxStaticLineStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxStaticLine) - -wxCONSTRUCTOR_5( wxStaticLine, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle) - -#endif // wxUSE_STATLINE diff --git a/Source/3rd Party/wx/src/common/stattextcmn.cpp b/Source/3rd Party/wx/src/common/stattextcmn.cpp deleted file mode 100644 index ba7d7f602..000000000 --- a/Source/3rd Party/wx/src/common/stattextcmn.cpp +++ /dev/null @@ -1,262 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/stattextcmn.cpp -// Purpose: common (to all ports) wxStaticText functions -// Author: Vadim Zeitlin, Francesco Montorsi -// Created: 2007-01-07 (extracted from dlgcmn.cpp) -// Copyright: (c) 1999-2006 Vadim Zeitlin -// (c) 2007 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STATTEXT - -#ifndef WX_PRECOMP - #include "wx/stattext.h" - #include "wx/button.h" - #include "wx/dcclient.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/settings.h" - #include "wx/sizer.h" - #include "wx/containr.h" -#endif - -#include "wx/textwrapper.h" - -#include "wx/private/markupparser.h" - -extern WXDLLEXPORT_DATA(const char) wxStaticTextNameStr[] = "staticText"; - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxStaticTextStyle ) -wxBEGIN_FLAGS( wxStaticTextStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxST_NO_AUTORESIZE) -wxFLAGS_MEMBER(wxALIGN_LEFT) -wxFLAGS_MEMBER(wxALIGN_RIGHT) -wxFLAGS_MEMBER(wxALIGN_CENTRE) -wxEND_FLAGS( wxStaticTextStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticText, wxControl, "wx/stattext.h") - -wxBEGIN_PROPERTIES_TABLE(wxStaticText) -wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString(), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) -wxPROPERTY_FLAGS( WindowStyle, wxStaticTextStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxStaticText) - -wxCONSTRUCTOR_6( wxStaticText, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Label, wxPoint, Position, wxSize, Size, long, WindowStyle ) - - -// ---------------------------------------------------------------------------- -// wxTextWrapper -// ---------------------------------------------------------------------------- - -void wxTextWrapper::Wrap(wxWindow *win, const wxString& text, int widthMax) -{ - wxString line; - - wxString::const_iterator lastSpace = text.end(); - wxString::const_iterator lineStart = text.begin(); - for ( wxString::const_iterator p = lineStart; ; ++p ) - { - if ( IsStartOfNewLine() ) - { - OnNewLine(); - - lastSpace = text.end(); - line.clear(); - lineStart = p; - } - - if ( p == text.end() || *p == wxT('\n') ) - { - DoOutputLine(line); - - if ( p == text.end() ) - break; - } - else // not EOL - { - if ( *p == wxT(' ') ) - lastSpace = p; - - line += *p; - - if ( widthMax >= 0 && lastSpace != text.end() ) - { - int width; - win->GetTextExtent(line, &width, NULL); - - if ( width > widthMax ) - { - // remove the last word from this line - line.erase(lastSpace - lineStart, p + 1 - lineStart); - DoOutputLine(line); - - // go back to the last word of this line which we didn't - // output yet - p = lastSpace; - } - } - //else: no wrapping at all or impossible to wrap - } - } -} - - -// ---------------------------------------------------------------------------- -// wxLabelWrapper: helper class for wxStaticTextBase::Wrap() -// ---------------------------------------------------------------------------- - -class wxLabelWrapper : public wxTextWrapper -{ -public: - void WrapLabel(wxWindow *text, int widthMax) - { - m_text.clear(); - Wrap(text, text->GetLabel(), widthMax); - text->SetLabel(m_text); - } - -protected: - virtual void OnOutputLine(const wxString& line) - { - m_text += line; - } - - virtual void OnNewLine() - { - m_text += wxT('\n'); - } - -private: - wxString m_text; -}; - - -// ---------------------------------------------------------------------------- -// wxStaticTextBase -// ---------------------------------------------------------------------------- - -void wxStaticTextBase::Wrap(int width) -{ - wxLabelWrapper wrapper; - wrapper.WrapLabel(this, width); -} - -// ---------------------------------------------------------------------------- -// wxStaticTextBase - generic implementation for wxST_ELLIPSIZE_* support -// ---------------------------------------------------------------------------- - -void wxStaticTextBase::UpdateLabel() -{ - if (!IsEllipsized()) - return; - - wxString newlabel = GetEllipsizedLabel(); - - // we need to touch the "real" label (i.e. the text set inside the control, - // using port-specific functions) instead of the string returned by GetLabel(). - // - // In fact, we must be careful not to touch the original label passed to - // SetLabel() otherwise GetLabel() will behave in a strange way to the user - // (e.g. returning a "Ver...ing" instead of "Very long string") ! - if (newlabel == DoGetLabel()) - return; - DoSetLabel(newlabel); -} - -wxString wxStaticTextBase::GetEllipsizedLabel() const -{ - // this function should be used only by ports which do not support - // ellipsis in static texts: we first remove markup (which cannot - // be handled safely by Ellipsize()) and then ellipsize the result. - - wxString ret(m_labelOrig); - - if (IsEllipsized()) - ret = Ellipsize(ret); - - return ret; -} - -wxString wxStaticTextBase::Ellipsize(const wxString& label) const -{ - wxSize sz(GetSize()); - if (sz.GetWidth() < 2 || sz.GetHeight() < 2) - { - // the size of this window is not valid (yet) - return label; - } - - wxClientDC dc(const_cast(this)); - dc.SetFont(GetFont()); - - wxEllipsizeMode mode; - if ( HasFlag(wxST_ELLIPSIZE_START) ) - mode = wxELLIPSIZE_START; - else if ( HasFlag(wxST_ELLIPSIZE_MIDDLE) ) - mode = wxELLIPSIZE_MIDDLE; - else if ( HasFlag(wxST_ELLIPSIZE_END) ) - mode = wxELLIPSIZE_END; - else - { - wxFAIL_MSG( "should only be called if have one of wxST_ELLIPSIZE_XXX" ); - - return label; - } - - return wxControl::Ellipsize(label, dc, mode, sz.GetWidth()); -} - -#endif // wxUSE_STATTEXT diff --git a/Source/3rd Party/wx/src/common/stdpbase.cpp b/Source/3rd Party/wx/src/common/stdpbase.cpp index 41e27e772..f2d4ff6b0 100644 --- a/Source/3rd Party/wx/src/common/stdpbase.cpp +++ b/Source/3rd Party/wx/src/common/stdpbase.cpp @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/common/stdpbase.cpp +// Name: common/stdpbase.cpp // Purpose: wxStandardPathsBase methods common to all ports // Author: Vadim Zeitlin // Modified by: // Created: 2004-10-19 +// RCS-ID: $Id: stdpbase.cpp 53093 2008-04-08 13:51:17Z JS $ // Copyright: (c) 2004 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -23,6 +24,8 @@ #pragma hdrstop #endif +#if wxUSE_STDPATHS + #ifndef WX_PRECOMP #include "wx/app.h" #endif //WX_PRECOMP @@ -31,35 +34,26 @@ #include "wx/filename.h" #include "wx/stdpaths.h" +#if defined(__UNIX__) && !defined(__WXMAC__) +#include "wx/log.h" +#include "wx/textfile.h" +#endif + // ---------------------------------------------------------------------------- // module globals // ---------------------------------------------------------------------------- -namespace -{ - -// Derive a class just to be able to create it: wxStandardPaths ctor is -// protected to prevent its misuse, but it also means we can't create an object -// of this class directly. -class wxStandardPathsDefault : public wxStandardPaths -{ -public: - wxStandardPathsDefault() { } -}; - -static wxStandardPathsDefault gs_stdPaths; - -} // anonymous namespace +static wxStandardPaths gs_stdPaths; // ============================================================================ // implementation // ============================================================================ /* static */ -wxStandardPaths& wxStandardPathsBase::Get() +wxStandardPathsBase& wxStandardPathsBase::Get() { wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - wxCHECK_MSG( traits, gs_stdPaths, wxT("create wxApp before calling this") ); + wxCHECK_MSG( traits, gs_stdPaths, _T("create wxApp before calling this") ); return traits->GetStandardPaths(); } @@ -85,20 +79,11 @@ wxString wxStandardPathsBase::GetExecutablePath() const return filename.GetFullPath(); } -wxStandardPaths& wxAppTraitsBase::GetStandardPaths() +wxStandardPathsBase& wxAppTraitsBase::GetStandardPaths() { return gs_stdPaths; } -wxStandardPathsBase::wxStandardPathsBase() -{ - // Set the default information that is used when - // forming some paths (by AppendAppInfo). - // Derived classes can call this in their constructors - // to set the platform-specific settings - UseAppInfo(AppInfo_AppName); -} - wxStandardPathsBase::~wxStandardPathsBase() { // nothing to do here @@ -116,17 +101,46 @@ wxString wxStandardPathsBase::GetUserLocalDataDir() const wxString wxStandardPathsBase::GetDocumentsDir() const { +#if defined(__UNIX__) && !defined(__WXMAC__) + { + wxLogNull logNull; + wxString homeDir = wxFileName::GetHomeDir(); + wxString configPath; + if (wxGetenv(wxT("XDG_CONFIG_HOME"))) + configPath = wxGetenv(wxT("XDG_CONFIG_HOME")); + else + configPath = homeDir + wxT("/.config"); + wxString dirsFile = configPath + wxT("/user-dirs.dirs"); + if (wxFileExists(dirsFile)) + { + wxTextFile textFile; + if (textFile.Open(dirsFile)) + { + size_t i; + for (i = 0; i < textFile.GetLineCount(); i++) + { + wxString line(textFile[i]); + int pos = line.Find(wxT("XDG_DOCUMENTS_DIR")); + if (pos != wxNOT_FOUND) + { + wxString value = line.AfterFirst(wxT('=')); + value.Replace(wxT("$HOME"), homeDir); + value.Trim(true); + value.Trim(false); + if (!value.IsEmpty() && wxDirExists(value)) + return value; + else + break; + } + } + } + } + } +#endif + return wxFileName::GetHomeDir(); } -wxString wxStandardPathsBase::GetAppDocumentsDir() const -{ - const wxString docsDir = GetDocumentsDir(); - wxString appDocsDir = AppendAppInfo(docsDir); - - return wxDirExists(appDocsDir) ? appDocsDir : docsDir; -} - // return the temporary directory for the current user wxString wxStandardPathsBase::GetTempDir() const { @@ -134,43 +148,25 @@ wxString wxStandardPathsBase::GetTempDir() const } /* static */ -wxString -wxStandardPathsBase::AppendPathComponent(const wxString& dir, - const wxString& component) +wxString wxStandardPathsBase::AppendAppName(const wxString& dir) { wxString subdir(dir); // empty string indicates that an error has occurred, don't touch it then if ( !subdir.empty() ) { - if ( !component.empty() ) + const wxString appname = wxTheApp->GetAppName(); + if ( !appname.empty() ) { const wxChar ch = *(subdir.end() - 1); - if ( !wxFileName::IsPathSeparator(ch) && ch != wxT('.') ) + if ( !wxFileName::IsPathSeparator(ch) && ch != _T('.') ) subdir += wxFileName::GetPathSeparator(); - subdir += component; + subdir += appname; } } return subdir; } - -wxString wxStandardPathsBase::AppendAppInfo(const wxString& dir) const -{ - wxString subdir(dir); - - if ( UsesAppInfo(AppInfo_VendorName) ) - { - subdir = AppendPathComponent(subdir, wxTheApp->GetVendorName()); - } - - if ( UsesAppInfo(AppInfo_AppName) ) - { - subdir = AppendPathComponent(subdir, wxTheApp->GetAppName()); - } - - return subdir; -} - +#endif // wxUSE_STDPATHS diff --git a/Source/3rd Party/wx/src/common/stdstream.cpp b/Source/3rd Party/wx/src/common/stdstream.cpp deleted file mode 100644 index f7a0cecf9..000000000 --- a/Source/3rd Party/wx/src/common/stdstream.cpp +++ /dev/null @@ -1,292 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/stdstream.cpp -// Purpose: Implementation of std::istream and std::ostream derived -// wrappers for wxInputStream and wxOutputStream -// Author: Jonathan Liu -// Created: 2009-05-02 -// Copyright: (c) 2009 Jonathan Liu -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ========================================================================== -// Declarations -// ========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STREAMS && wxUSE_STD_IOSTREAM - -#ifndef WX_PRECOMP -#endif - -#include "wx/stdstream.h" - -#include -#include -#include -#include - -// ========================================================================== -// Helpers -// ========================================================================== - -namespace -{ - -bool -IosSeekDirToWxSeekMode(std::ios_base::seekdir way, - wxSeekMode& seekMode) -{ - switch ( way ) - { - case std::ios_base::beg: - seekMode = wxFromStart; - break; - case std::ios_base::cur: - seekMode = wxFromCurrent; - break; - case std::ios_base::end: - seekMode = wxFromEnd; - break; - default: - return false; - } - - return true; -} - -} // anonymous namespace - -// ========================================================================== -// wxStdInputStreamBuffer -// ========================================================================== - -wxStdInputStreamBuffer::wxStdInputStreamBuffer(wxInputStream& stream) : - m_stream(stream), m_lastChar(EOF) -{ -} - -std::streambuf * -wxStdInputStreamBuffer::setbuf(char *WXUNUSED(s), - std::streamsize WXUNUSED(n)) -{ - return NULL; -} - -std::streampos -wxStdInputStreamBuffer::seekoff(std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which) -{ - wxSeekMode seekMode; - - if ( !IosSeekDirToWxSeekMode(way, seekMode) ) - return -1; - if ( !(which & std::ios_base::in) ) - return -1; - - off_t newPos = m_stream.SeekI((off_t) off, seekMode); - - if ( newPos != wxInvalidOffset ) - return (std::streampos) newPos; - else - return -1; -} - -std::streampos -wxStdInputStreamBuffer::seekpos(std::streampos sp, - std::ios_base::openmode which) -{ - if ( !(which & std::ios_base::in) ) - return -1; - - off_t newPos = m_stream.SeekI((off_t) sp); - - if ( newPos != wxInvalidOffset ) - return (std::streampos) newPos; - else - return -1; -} - -std::streamsize -wxStdInputStreamBuffer::showmanyc() -{ - if ( m_stream.CanRead() && (off_t) m_stream.GetSize() > m_stream.TellI() ) - return m_stream.GetSize() - m_stream.TellI(); - else - return 0; -} - -std::streamsize -wxStdInputStreamBuffer::xsgetn(char *s, std::streamsize n) -{ - m_stream.Read((void *) s, (size_t) n); - - std::streamsize read = m_stream.LastRead(); - - if ( read > 0 ) - m_lastChar = (unsigned char) s[read - 1]; - - return read; -} - -int -wxStdInputStreamBuffer::underflow() -{ - int ch = m_stream.GetC(); - - if ( m_stream.LastRead() == 1 ) - { - m_stream.Ungetch((char) ch); - return ch; - } - else - { - return EOF; - } -} - -int -wxStdInputStreamBuffer::uflow() -{ - int ch = m_stream.GetC(); - - if ( m_stream.LastRead() == 1 ) - { - m_lastChar = ch; - return ch; - } - else - { - return EOF; - } -} - -int -wxStdInputStreamBuffer::pbackfail(int c) -{ - if ( c == EOF ) - { - if ( m_lastChar == EOF ) - return EOF; - - c = m_lastChar; - m_lastChar = EOF; - } - - return m_stream.Ungetch((char) c) ? c : EOF; -} - -// ========================================================================== -// wxStdOutputStreamBuffer -// ========================================================================== - -wxStdOutputStreamBuffer::wxStdOutputStreamBuffer(wxOutputStream& stream) : - m_stream(stream) -{ -} - -std::streambuf * -wxStdOutputStreamBuffer::setbuf(char *WXUNUSED(s), - std::streamsize WXUNUSED(n)) -{ - return NULL; -} - -std::streampos -wxStdOutputStreamBuffer::seekoff(std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which) -{ - wxSeekMode seekMode; - - if ( !IosSeekDirToWxSeekMode(way, seekMode) ) - return -1; - if ( !(which & std::ios_base::out) ) - return -1; - - off_t newPos = m_stream.SeekO((off_t) off, seekMode); - - if ( newPos != wxInvalidOffset ) - return (std::streampos) newPos; - else - return -1; -} - -std::streampos -wxStdOutputStreamBuffer::seekpos(std::streampos sp, - std::ios_base::openmode which) -{ - if ( !(which & std::ios_base::out) ) - return -1; - - off_t newPos = m_stream.SeekO((off_t) sp); - - if ( newPos != wxInvalidOffset ) - return (std::streampos) newPos; - else - return -1; -} - -std::streamsize -wxStdOutputStreamBuffer::xsputn(const char *s, - std::streamsize n) -{ - m_stream.Write((const void *) s, (size_t) n); - return (std::streamsize) m_stream.LastWrite(); -} - -int -wxStdOutputStreamBuffer::overflow(int c) -{ - m_stream.PutC(c); - return m_stream.IsOk() ? c : EOF; -} - -// ========================================================================== -// wxStdInputStream and wxStdOutputStream -// ========================================================================== - -// FIXME-VC6: it is impossible to call basic_ios::init() with this -// compiler, it complains about invalid call to non-static member -// function so use a suspicious (as it uses a pointer to not yet -// constructed streambuf) but working workaround -// -// It also doesn't like using istream in the ctor initializer list -// and we must spell it out as basic_istream. -#ifdef __VISUALC6__ - -wxStdInputStream::wxStdInputStream(wxInputStream& stream) - : std::basic_istream >(&m_streamBuffer), - m_streamBuffer(stream) -{ -} - -wxStdOutputStream::wxStdOutputStream(wxOutputStream& stream) - : std::basic_ostream >(&m_streamBuffer), - m_streamBuffer(stream) -{ -} - -#else // !VC6 - -wxStdInputStream::wxStdInputStream(wxInputStream& stream) : - std::istream(NULL), m_streamBuffer(stream) -{ - std::ios::init(&m_streamBuffer); -} - -wxStdOutputStream::wxStdOutputStream(wxOutputStream& stream) : - std::ostream(NULL), m_streamBuffer(stream) -{ - std::ios::init(&m_streamBuffer); -} - -#endif // VC6/!VC6 - -#endif // wxUSE_STREAMS && wxUSE_STD_IOSTREAM diff --git a/Source/3rd Party/wx/src/common/stockitem.cpp b/Source/3rd Party/wx/src/common/stockitem.cpp index fad05d7b8..8c1cd480b 100644 --- a/Source/3rd Party/wx/src/common/stockitem.cpp +++ b/Source/3rd Party/wx/src/common/stockitem.cpp @@ -4,6 +4,7 @@ // Author: Vaclav Slavik // Modified by: // Created: 2004-08-15 +// RCS-ID: $Id: stockitem.cpp 58617 2009-02-02 05:12:43Z SC $ // Copyright: (c) Vaclav Slavik, 2004 // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -37,70 +38,52 @@ bool wxIsStockID(wxWindowID id) case wxID_ABOUT: case wxID_ADD: case wxID_APPLY: - case wxID_BACKWARD: case wxID_BOLD: - case wxID_BOTTOM: case wxID_CANCEL: - case wxID_CDROM: case wxID_CLEAR: case wxID_CLOSE: - case wxID_CONVERT: case wxID_COPY: case wxID_CUT: case wxID_DELETE: - case wxID_DOWN: case wxID_EDIT: - case wxID_EXECUTE: - case wxID_EXIT: - case wxID_FILE: case wxID_FIND: - case wxID_FIRST: - case wxID_FLOPPY: + case wxID_FILE: + case wxID_REPLACE: + case wxID_BACKWARD: + case wxID_DOWN: case wxID_FORWARD: - case wxID_HARDDISK: + case wxID_UP: case wxID_HELP: case wxID_HOME: case wxID_INDENT: case wxID_INDEX: - case wxID_INFO: case wxID_ITALIC: - case wxID_JUMP_TO: case wxID_JUSTIFY_CENTER: case wxID_JUSTIFY_FILL: case wxID_JUSTIFY_LEFT: case wxID_JUSTIFY_RIGHT: - case wxID_LAST: - case wxID_NETWORK: case wxID_NEW: case wxID_NO: case wxID_OK: case wxID_OPEN: case wxID_PASTE: case wxID_PREFERENCES: - case wxID_PREVIEW: case wxID_PRINT: + case wxID_PREVIEW: case wxID_PROPERTIES: + case wxID_EXIT: case wxID_REDO: case wxID_REFRESH: case wxID_REMOVE: - case wxID_REPLACE: case wxID_REVERT_TO_SAVED: case wxID_SAVE: case wxID_SAVEAS: case wxID_SELECTALL: - case wxID_SELECT_COLOR: - case wxID_SELECT_FONT: - case wxID_SORT_ASCENDING: - case wxID_SORT_DESCENDING: - case wxID_SPELL_CHECK: case wxID_STOP: - case wxID_STRIKETHROUGH: - case wxID_TOP: case wxID_UNDELETE: case wxID_UNDERLINE: case wxID_UNDO: case wxID_UNINDENT: - case wxID_UP: case wxID_YES: case wxID_ZOOM_100: case wxID_ZOOM_FIT: @@ -117,116 +100,78 @@ wxString wxGetStockLabel(wxWindowID id, long flags) { wxString stockLabel; -#ifdef __WXMSW__ - // special case: the "Cancel" button shouldn't have a mnemonic under MSW - // for consistency with the native dialogs (which don't use any mnemonic - // for it because it is already bound to Esc implicitly) - if ( id == wxID_CANCEL ) - flags &= ~wxSTOCK_WITH_MNEMONIC; -#endif // __WXMSW__ - - - #define STOCKITEM(stockid, labelWithMnemonic, labelPlain) \ - case stockid: \ - if(flags & wxSTOCK_WITH_MNEMONIC) \ - stockLabel = labelWithMnemonic; \ - else \ - stockLabel = labelPlain; \ - break + #define STOCKITEM(stockid, label) \ + case stockid: \ + stockLabel = label; \ + break; switch (id) { - STOCKITEM(wxID_ABOUT, _("&About"), _("About")); - STOCKITEM(wxID_ADD, _("Add"), _("Add")); - STOCKITEM(wxID_APPLY, _("&Apply"), _("Apply")); - STOCKITEM(wxID_BACKWARD, _("&Back"), _("Back")); - STOCKITEM(wxID_BOLD, _("&Bold"), _("Bold")); - STOCKITEM(wxID_BOTTOM, _("&Bottom"), _("Bottom")); - STOCKITEM(wxID_CANCEL, _("&Cancel"), _("Cancel")); - STOCKITEM(wxID_CDROM, _("&CD-Rom"), _("CD-Rom")); - STOCKITEM(wxID_CLEAR, _("&Clear"), _("Clear")); - STOCKITEM(wxID_CLOSE, _("&Close"), _("Close")); - STOCKITEM(wxID_CONVERT, _("&Convert"), _("Convert")); - STOCKITEM(wxID_COPY, _("&Copy"), _("Copy")); - STOCKITEM(wxID_CUT, _("Cu&t"), _("Cut")); - STOCKITEM(wxID_DELETE, _("&Delete"), _("Delete")); - STOCKITEM(wxID_DOWN, _("&Down"), _("Down")); - STOCKITEM(wxID_EDIT, _("&Edit"), _("Edit")); - STOCKITEM(wxID_EXECUTE, _("&Execute"), _("Execute")); - STOCKITEM(wxID_EXIT, _("&Quit"), _("Quit")); - STOCKITEM(wxID_FILE, _("&File"), _("File")); - STOCKITEM(wxID_FIND, _("&Find"), _("Find")); - STOCKITEM(wxID_FIRST, _("&First"), _("First")); - STOCKITEM(wxID_FLOPPY, _("&Floppy"), _("Floppy")); - STOCKITEM(wxID_FORWARD, _("&Forward"), _("Forward")); - STOCKITEM(wxID_HARDDISK, _("&Harddisk"), _("Harddisk")); - STOCKITEM(wxID_HELP, _("&Help"), _("Help")); - STOCKITEM(wxID_HOME, _("&Home"), _("Home")); - STOCKITEM(wxID_INDENT, _("Indent"), _("Indent")); - STOCKITEM(wxID_INDEX, _("&Index"), _("Index")); - STOCKITEM(wxID_INFO, _("&Info"), _("Info")); - STOCKITEM(wxID_ITALIC, _("&Italic"), _("Italic")); - STOCKITEM(wxID_JUMP_TO, _("&Jump to"), _("Jump to")); - STOCKITEM(wxID_JUSTIFY_CENTER, _("Centered"), _("Centered")); - STOCKITEM(wxID_JUSTIFY_FILL, _("Justified"), _("Justified")); - STOCKITEM(wxID_JUSTIFY_LEFT, _("Align Left"), _("Align Left")); - STOCKITEM(wxID_JUSTIFY_RIGHT, _("Align Right"), _("Align Right")); - STOCKITEM(wxID_LAST, _("&Last"), _("Last")); - STOCKITEM(wxID_NETWORK, _("&Network"), _("Network")); - STOCKITEM(wxID_NEW, _("&New"), _("New")); - STOCKITEM(wxID_NO, _("&No"), _("No")); - STOCKITEM(wxID_OK, _("&OK"), _("OK")); - STOCKITEM(wxID_OPEN, _("&Open..."), _("Open...")); - STOCKITEM(wxID_PASTE, _("&Paste"), _("Paste")); - STOCKITEM(wxID_PREFERENCES, _("&Preferences"), _("Preferences")); - STOCKITEM(wxID_PREVIEW, _("Print previe&w..."), _("Print preview...")); - STOCKITEM(wxID_PRINT, _("&Print..."), _("Print...")); - STOCKITEM(wxID_PROPERTIES, _("&Properties"), _("Properties")); - STOCKITEM(wxID_REDO, _("&Redo"), _("Redo")); - STOCKITEM(wxID_REFRESH, _("Refresh"), _("Refresh")); - STOCKITEM(wxID_REMOVE, _("Remove"), _("Remove")); - STOCKITEM(wxID_REPLACE, _("Rep&lace"), _("Replace")); - STOCKITEM(wxID_REVERT_TO_SAVED, _("Revert to Saved"), _("Revert to Saved")); - STOCKITEM(wxID_SAVE, _("&Save"), _("Save")); - STOCKITEM(wxID_SAVEAS, _("&Save as"), _("Save as")); - STOCKITEM(wxID_SELECTALL, _("Select &All"), _("Select All")); - STOCKITEM(wxID_SELECT_COLOR, _("&Color"), _("Color")); - STOCKITEM(wxID_SELECT_FONT, _("&Font"), _("Font")); - STOCKITEM(wxID_SORT_ASCENDING, _("&Ascending"), _("Ascending")); - STOCKITEM(wxID_SORT_DESCENDING, _("&Descending"), _("Descending")); - STOCKITEM(wxID_SPELL_CHECK, _("&Spell Check"), _("Spell Check")); - STOCKITEM(wxID_STOP, _("&Stop"), _("Stop")); - STOCKITEM(wxID_STRIKETHROUGH, _("&Strikethrough"), _("Strikethrough")); - STOCKITEM(wxID_TOP, _("&Top"), _("Top")); - STOCKITEM(wxID_UNDELETE, _("Undelete"), _("Undelete")); - STOCKITEM(wxID_UNDERLINE, _("&Underline"), _("Underline")); - STOCKITEM(wxID_UNDO, _("&Undo"), _("Undo")); - STOCKITEM(wxID_UNINDENT, _("&Unindent"), _("Unindent")); - STOCKITEM(wxID_UP, _("&Up"), _("Up")); - STOCKITEM(wxID_YES, _("&Yes"), _("Yes")); - STOCKITEM(wxID_ZOOM_100, _("&Actual Size"), _("Actual Size")); - STOCKITEM(wxID_ZOOM_FIT, _("Zoom to &Fit"), _("Zoom to Fit")); - STOCKITEM(wxID_ZOOM_IN, _("Zoom &In"), _("Zoom In")); - STOCKITEM(wxID_ZOOM_OUT, _("Zoom &Out"), _("Zoom Out")); + STOCKITEM(wxID_ABOUT, _("&About")) + STOCKITEM(wxID_ADD, _("Add")) + STOCKITEM(wxID_APPLY, _("&Apply")) + STOCKITEM(wxID_BOLD, _("&Bold")) + STOCKITEM(wxID_CANCEL, _("&Cancel")) + STOCKITEM(wxID_CLEAR, _("&Clear")) + STOCKITEM(wxID_CLOSE, _("&Close")) + STOCKITEM(wxID_COPY, _("&Copy")) + STOCKITEM(wxID_CUT, _("Cu&t")) + STOCKITEM(wxID_DELETE, _("&Delete")) + STOCKITEM(wxID_EDIT, _("&Edit")) + STOCKITEM(wxID_FIND, _("&Find")) + STOCKITEM(wxID_FILE, _("&File")) + STOCKITEM(wxID_REPLACE, _("Rep&lace")) + STOCKITEM(wxID_BACKWARD, _("&Back")) + STOCKITEM(wxID_DOWN, _("&Down")) + STOCKITEM(wxID_FORWARD, _("&Forward")) + STOCKITEM(wxID_UP, _("&Up")) + STOCKITEM(wxID_HELP, _("&Help")) + STOCKITEM(wxID_HOME, _("&Home")) + STOCKITEM(wxID_INDENT, _("Indent")) + STOCKITEM(wxID_INDEX, _("&Index")) + STOCKITEM(wxID_ITALIC, _("&Italic")) + STOCKITEM(wxID_JUSTIFY_CENTER, _("Centered")) + STOCKITEM(wxID_JUSTIFY_FILL, _("Justified")) + STOCKITEM(wxID_JUSTIFY_LEFT, _("Align Left")) + STOCKITEM(wxID_JUSTIFY_RIGHT, _("Align Right")) + STOCKITEM(wxID_NEW, _("&New")) + STOCKITEM(wxID_NO, _("&No")) + STOCKITEM(wxID_OK, _("&OK")) + STOCKITEM(wxID_OPEN, _("&Open")) + STOCKITEM(wxID_PASTE, _("&Paste")) + STOCKITEM(wxID_PREFERENCES, _("&Preferences")) + STOCKITEM(wxID_PRINT, _("&Print")) + STOCKITEM(wxID_PREVIEW, _("Print previe&w")) + STOCKITEM(wxID_PROPERTIES, _("&Properties")) + STOCKITEM(wxID_EXIT, _("&Quit")) + STOCKITEM(wxID_REDO, _("&Redo")) + STOCKITEM(wxID_REFRESH, _("Refresh")) + STOCKITEM(wxID_REMOVE, _("Remove")) + STOCKITEM(wxID_REVERT_TO_SAVED, _("Revert to Saved")) + STOCKITEM(wxID_SAVE, _("&Save")) + STOCKITEM(wxID_SAVEAS, _("Save &As...")) + STOCKITEM(wxID_SELECTALL, _("Select all")) + STOCKITEM(wxID_STOP, _("&Stop")) + STOCKITEM(wxID_UNDELETE, _("Undelete")) + STOCKITEM(wxID_UNDERLINE, _("&Underline")) + STOCKITEM(wxID_UNDO, _("&Undo")) + STOCKITEM(wxID_UNINDENT, _("&Unindent")) + STOCKITEM(wxID_YES, _("&Yes")) + STOCKITEM(wxID_ZOOM_100, _("&Actual Size")) + STOCKITEM(wxID_ZOOM_FIT, _("Zoom to &Fit")) + STOCKITEM(wxID_ZOOM_IN, _("Zoom &In")) + STOCKITEM(wxID_ZOOM_OUT, _("Zoom &Out")) default: - wxFAIL_MSG( wxT("invalid stock item ID") ); + wxFAIL_MSG( _T("invalid stock item ID") ); break; }; #undef STOCKITEM - if ( flags & wxSTOCK_WITHOUT_ELLIPSIS ) + if ( !(flags & wxSTOCK_WITH_MNEMONIC) ) { - wxString baseLabel; - if ( stockLabel.EndsWith("...", &baseLabel) ) - stockLabel = baseLabel; - - // accelerators only make sense for the menu items which should have - // ellipsis too while wxSTOCK_WITHOUT_ELLIPSIS is mostly useful for - // buttons which shouldn't have accelerators in their labels - wxASSERT_MSG( !(flags & wxSTOCK_WITH_ACCELERATOR), - "labels without ellipsis shouldn't use accelerators" ); + stockLabel = wxStripMenuCodes(stockLabel); } #if wxUSE_ACCEL @@ -234,7 +179,7 @@ wxString wxGetStockLabel(wxWindowID id, long flags) { wxAcceleratorEntry accel = wxGetStockAccelerator(id); if (accel.IsOk()) - stockLabel << wxT('\t') << accel.ToString(); + stockLabel << _T('\t') << accel.ToString(); } #endif // wxUSE_ACCEL @@ -290,21 +235,15 @@ wxAcceleratorEntry wxGetStockAccelerator(wxWindowID id) switch (id) { - STOCKITEM(wxID_COPY, wxACCEL_CTRL,'C') - STOCKITEM(wxID_CUT, wxACCEL_CTRL,'X') - STOCKITEM(wxID_FIND, wxACCEL_CTRL,'F') - STOCKITEM(wxID_HELP, wxACCEL_CTRL,'H') - STOCKITEM(wxID_NEW, wxACCEL_CTRL,'N') - STOCKITEM(wxID_OPEN, wxACCEL_CTRL,'O') - STOCKITEM(wxID_PASTE, wxACCEL_CTRL,'V') - STOCKITEM(wxID_PRINT, wxACCEL_CTRL,'P') - STOCKITEM(wxID_REDO, wxACCEL_CTRL | wxACCEL_SHIFT,'Z') - STOCKITEM(wxID_REPLACE, wxACCEL_CTRL,'R') - STOCKITEM(wxID_SAVE, wxACCEL_CTRL,'S') - STOCKITEM(wxID_UNDO, wxACCEL_CTRL,'Z') -#ifdef __WXOSX__ - STOCKITEM(wxID_PREFERENCES, wxACCEL_CTRL,',') -#endif + STOCKITEM(wxID_COPY, wxACCEL_CMD,'C') + STOCKITEM(wxID_CUT, wxACCEL_CMD,'X') + STOCKITEM(wxID_FIND, wxACCEL_CMD,'F') + STOCKITEM(wxID_REPLACE, wxACCEL_CMD,'R') + STOCKITEM(wxID_HELP, wxACCEL_CMD,'H') + STOCKITEM(wxID_NEW, wxACCEL_CMD,'N') + STOCKITEM(wxID_OPEN, wxACCEL_CMD,'O') + STOCKITEM(wxID_PASTE, wxACCEL_CMD,'V') + STOCKITEM(wxID_SAVE, wxACCEL_CMD,'S') default: // set the wxAcceleratorEntry to return into an invalid state: @@ -331,7 +270,7 @@ bool wxIsStockLabel(wxWindowID id, const wxString& label) if (label == stock) return true; - stock.Replace(wxT("&"), wxEmptyString); + stock.Replace(_T("&"), wxEmptyString); if (label == stock) return true; diff --git a/Source/3rd Party/wx/src/common/stopwatch.cpp b/Source/3rd Party/wx/src/common/stopwatch.cpp index aad2b0bb6..eefbae7e9 100644 --- a/Source/3rd Party/wx/src/common/stopwatch.cpp +++ b/Source/3rd Party/wx/src/common/stopwatch.cpp @@ -8,8 +8,9 @@ // Guillermo Rodriguez rewrote from scratch (Dic/99) // Modified by: // Created: 20.06.2003 (extracted from common/timercmn.cpp) +// RCS-ID: $Id: stopwatch.cpp 41054 2006-09-07 19:01:45Z ABX $ // Copyright: (c) 1998-2003 wxWidgets Team -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -29,16 +30,82 @@ #include "wx/stopwatch.h" -#if wxUSE_STOPWATCH - #ifndef WX_PRECOMP - #ifdef __WINDOWS__ + #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" #endif + #include "wx/intl.h" #include "wx/log.h" - #include "wx/thread.h" #endif //WX_PRECOMP +// ---------------------------------------------------------------------------- +// System headers +// ---------------------------------------------------------------------------- + +#if defined(__WIN32__) && !defined(HAVE_FTIME) && !defined(__MWERKS__) && !defined(__WXWINCE__) + #define HAVE_FTIME +#endif + +#if defined(__VISAGECPP__) && !defined(HAVE_FTIME) + #define HAVE_FTIME +# if __IBMCPP__ >= 400 + # define ftime(x) _ftime(x) +# endif +#endif + +#if defined(__MWERKS__) && defined(__WXMSW__) +# undef HAVE_FTIME +# undef HAVE_GETTIMEOFDAY +#endif + +#ifndef __WXWINCE__ +#include +#else +#include "wx/msw/private.h" +#include "wx/msw/wince/time.h" +#endif + +#if !defined(__WXMAC__) && !defined(__WXWINCE__) + #include // for time_t +#endif + +#if defined(HAVE_GETTIMEOFDAY) + #include + #include +#elif defined(HAVE_FTIME) + #include +#endif + +#ifdef __WXMAC__ +#ifndef __DARWIN__ + #include + #include +#else + #include +#endif +#endif + +#ifdef __WXPALMOS__ + #include + #include + #include +#endif + +// ---------------------------------------------------------------------------- +// macros +// ---------------------------------------------------------------------------- + +// on some really old systems gettimeofday() doesn't have the second argument, +// define wxGetTimeOfDay() to hide this difference +#ifdef HAVE_GETTIMEOFDAY + #ifdef WX_GETTIMEOFDAY_NO_TZ + struct timezone; + #define wxGetTimeOfDay(tv, tz) gettimeofday(tv) + #else + #define wxGetTimeOfDay(tv, tz) gettimeofday((tv), (tz)) + #endif +#endif // HAVE_GETTIMEOFDAY + // ============================================================================ // implementation // ============================================================================ @@ -47,129 +114,57 @@ // wxStopWatch // ---------------------------------------------------------------------------- -namespace -{ +#if wxUSE_STOPWATCH -#ifdef __WINDOWS__ - -struct PerfCounter +void wxStopWatch::Start(long t) { - PerfCounter() +#if 0 +// __WXMSW__ + LARGE_INTEGER frequency_li; + ::QueryPerformanceFrequency( &frequency_li ); + m_frequency = frequency_li.QuadPart; + if (m_frequency == 0) { - init = false; + m_t0 = wxGetLocalTimeMillis() - t; } - - bool CanBeUsed() const + else { - return freq.QuadPart != 0; + LARGE_INTEGER counter_li; + ::QueryPerformanceCounter( &counter_li ); + wxLongLong counter = counter_li.QuadPart; + m_t0 = (counter * 10000 / m_frequency) - t*10; } - - wxCRIT_SECT_DECLARE_MEMBER(cs); - LARGE_INTEGER freq; - bool init; -}; - -// Return the global perf counter state. -// -// This is wrapped in a function to avoid initialization order problems, -// otherwise simply creating a global wxStopWatch variable could crash because -// it would be using a (possibly) still uninitialized critical section. -PerfCounter& GetPerfCounterState() -{ - static PerfCounter s_perfCounter; - - return s_perfCounter; -} - -#endif // __WINDOWS__ - -const int MILLISECONDS_PER_SECOND = 1000; -const int MICROSECONDS_PER_SECOND = 1000*1000; - -} // anonymous namespace - -void wxStopWatch::DoStart() -{ -#ifdef __WINDOWS__ - PerfCounter& perfCounter = GetPerfCounterState(); - if ( !perfCounter.init ) - { - wxCRIT_SECT_LOCKER(lock, perfCounter.cs); - ::QueryPerformanceFrequency(&perfCounter.freq); - - // Just a sanity check: it's not supposed to happen but verify that - // ::QueryPerformanceCounter() succeeds so that we can really use it. - LARGE_INTEGER counter; - if ( !::QueryPerformanceCounter(&counter) ) - { - wxLogDebug("QueryPerformanceCounter() unexpected failed (%s), " - "will not use it.", wxSysErrorMsg()); - - perfCounter.freq.QuadPart = 0; - } - - perfCounter.init = true; - } -#endif // __WINDOWS__ - - m_t0 = GetCurrentClockValue(); -} - -wxLongLong wxStopWatch::GetClockFreq() const -{ -#ifdef __WINDOWS__ - // Under MSW we use the high resolution performance counter timer which has - // its own frequency (usually related to the CPU clock speed). - if ( GetPerfCounterState().CanBeUsed() ) - return GetPerfCounterState().freq.QuadPart; -#endif // __WINDOWS__ - -#ifdef HAVE_GETTIMEOFDAY - // With gettimeofday() we can have nominally microsecond precision and - // while this is not the case in practice, it's still better than - // millisecond. - return MICROSECONDS_PER_SECOND; -#else // !HAVE_GETTIMEOFDAY - // Currently milliseconds are used everywhere else. - return MILLISECONDS_PER_SECOND; -#endif // HAVE_GETTIMEOFDAY/!HAVE_GETTIMEOFDAY -} - -void wxStopWatch::Start(long t0) -{ - // Calling Start() makes the stop watch run however many times it was - // paused before. +#else + m_t0 = wxGetLocalTimeMillis() - t; +#endif + m_pause = 0; m_pauseCount = 0; - - DoStart(); - - m_t0 -= (wxLongLong(t0)*GetClockFreq())/MILLISECONDS_PER_SECOND; } -wxLongLong wxStopWatch::GetCurrentClockValue() const +long wxStopWatch::GetElapsedTime() const { -#ifdef __WINDOWS__ - if ( GetPerfCounterState().CanBeUsed() ) +#if 0 +//__WXMSW__ + if (m_frequency == 0) { - LARGE_INTEGER counter; - ::QueryPerformanceCounter(&counter); - return counter.QuadPart; + return (wxGetLocalTimeMillis() - m_t0).GetLo(); } -#endif // __WINDOWS__ - -#ifdef HAVE_GETTIMEOFDAY - return wxGetUTCTimeUSec(); -#else // !HAVE_GETTIMEOFDAY - return wxGetUTCTimeMillis(); -#endif // HAVE_GETTIMEOFDAY/!HAVE_GETTIMEOFDAY + else + { + LARGE_INTEGER counter_li; + ::QueryPerformanceCounter( &counter_li ); + wxLongLong counter = counter_li.QuadPart; + wxLongLong res = (counter * 10000 / m_frequency) - m_t0; + return res.GetLo() / 10; + } +#else + return (wxGetLocalTimeMillis() - m_t0).GetLo(); +#endif } -wxLongLong wxStopWatch::TimeInMicro() const +long wxStopWatch::Time() const { - const wxLongLong elapsed(m_pauseCount ? m_elapsedBeforePause - : GetCurrentClockValue() - m_t0); - - return (elapsed*MICROSECONDS_PER_SECOND)/GetClockFreq(); + return m_pauseCount ? m_pause : GetElapsedTime(); } #endif // wxUSE_STOPWATCH @@ -185,14 +180,14 @@ static wxLongLong wxStartTime = 0l; // starts the global timer void wxStartTimer() { - wxStartTime = wxGetUTCTimeMillis(); + wxStartTime = wxGetLocalTimeMillis(); } // Returns elapsed time in milliseconds long wxGetElapsedTime(bool resetTimer) { wxLongLong oldTime = wxStartTime; - wxLongLong newTime = wxGetUTCTimeMillis(); + wxLongLong newTime = wxGetLocalTimeMillis(); if ( resetTimer ) wxStartTime = newTime; @@ -201,3 +196,177 @@ long wxGetElapsedTime(bool resetTimer) } #endif // wxUSE_LONGLONG + +// ---------------------------------------------------------------------------- +// the functions to get the current time and timezone info +// ---------------------------------------------------------------------------- + +// Get local time as seconds since 00:00:00, Jan 1st 1970 +long wxGetLocalTime() +{ + struct tm tm; + time_t t0, t1; + + // This cannot be made static because mktime can overwrite it. + // + memset(&tm, 0, sizeof(tm)); + tm.tm_year = 70; + tm.tm_mon = 0; + tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature' + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; // let mktime guess + + // Note that mktime assumes that the struct tm contains local time. + // + t1 = time(&t1); // now + t0 = mktime(&tm); // origin + + // Return the difference in seconds. + // + if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 )) + return (long)difftime(t1, t0) + (60 * 60 * 24 * 4); + + wxLogSysError(_("Failed to get the local system time")); + return -1; +} + +// Get UTC time as seconds since 00:00:00, Jan 1st 1970 +long wxGetUTCTime() +{ + return (long)time(NULL); +} + +#if wxUSE_LONGLONG + +// Get local time as milliseconds since 00:00:00, Jan 1st 1970 +wxLongLong wxGetLocalTimeMillis() +{ + wxLongLong val = 1000l; + + // If possible, use a function which avoids conversions from + // broken-up time structures to milliseconds + +#if defined(__WXPALMOS__) + DateTimeType thenst; + thenst.second = 0; + thenst.minute = 0; + thenst.hour = 0; + thenst.day = 1; + thenst.month = 1; + thenst.year = 1970; + thenst.weekDay = 5; + uint32_t now = TimGetSeconds(); + uint32_t then = TimDateTimeToSeconds (&thenst); + return SysTimeToMilliSecs(SysTimeInSecs(now - then)); +#elif defined(__WXMSW__) && (defined(__WINE__) || defined(__MWERKS__)) + // This should probably be the way all WXMSW compilers should do it + // Go direct to the OS for time + + SYSTEMTIME thenst = { 1970, 1, 4, 1, 0, 0, 0, 0 }; // 00:00:00 Jan 1st 1970 + FILETIME thenft; + SystemTimeToFileTime( &thenst, &thenft ); + wxLongLong then( thenft.dwHighDateTime, thenft.dwLowDateTime ); // time in 100 nanoseconds + + SYSTEMTIME nowst; + GetLocalTime( &nowst ); + FILETIME nowft; + SystemTimeToFileTime( &nowst, &nowft ); + wxLongLong now( nowft.dwHighDateTime, nowft.dwLowDateTime ); // time in 100 nanoseconds + + return ( now - then ) / 10000.0; // time from 00:00:00 Jan 1st 1970 to now in milliseconds + +#elif defined(HAVE_GETTIMEOFDAY) + struct timeval tp; + if ( wxGetTimeOfDay(&tp, (struct timezone *)NULL) != -1 ) + { + val *= tp.tv_sec; + return (val + (tp.tv_usec / 1000)); + } + else + { + wxLogError(_("wxGetTimeOfDay failed.")); + return 0; + } +#elif defined(HAVE_FTIME) + struct timeb tp; + + // ftime() is void and not int in some mingw32 headers, so don't + // test the return code (well, it shouldn't fail anyhow...) + (void)::ftime(&tp); + val *= tp.time; + return (val + tp.millitm); +#elif defined(__WXMAC__) + + static UInt64 gMilliAtStart = 0; + + Nanoseconds upTime = AbsoluteToNanoseconds( UpTime() ); + + if ( gMilliAtStart == 0 ) + { + time_t start = time(NULL); + gMilliAtStart = ((UInt64) start) * 1000000L; + gMilliAtStart -= upTime.lo / 1000 ; + gMilliAtStart -= ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000); + } + + UInt64 millival = gMilliAtStart; + millival += upTime.lo / (1000 * 1000); + millival += ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000); + val = millival; + + return val; +#else // no gettimeofday() nor ftime() + // We use wxGetLocalTime() to get the seconds since + // 00:00:00 Jan 1st 1970 and then whatever is available + // to get millisecond resolution. + // + // NOTE that this might lead to a problem if the clocks + // use different sources, so this approach should be + // avoided where possible. + + val *= wxGetLocalTime(); + +// GRG: This will go soon as all WIN32 seem to have ftime +// JACS: unfortunately not. WinCE doesn't have it. +#if defined (__WIN32__) + // If your platform/compiler needs to use two different functions + // to get ms resolution, please do NOT just shut off these warnings, + // drop me a line instead at + + // FIXME +#ifndef __WXWINCE__ + #warning "Possible clock skew bug in wxGetLocalTimeMillis()!" +#endif + + SYSTEMTIME st; + ::GetLocalTime(&st); + val += st.wMilliseconds; +#else // !Win32 + // If your platform/compiler does not support ms resolution please + // do NOT just shut off these warnings, drop me a line instead at + // + + #if defined(__VISUALC__) || defined (__WATCOMC__) + #pragma message("wxStopWatch will be up to second resolution!") + #elif defined(__BORLANDC__) + #pragma message "wxStopWatch will be up to second resolution!" + #else + #warning "wxStopWatch will be up to second resolution!" + #endif // compiler +#endif + + return val; + +#endif // time functions +} + +#else // !wxUSE_LONGLONG + +double wxGetLocalTimeMillis(void) +{ + return (double(clock()) / double(CLOCKS_PER_SEC)) * 1000.0; +} + +#endif // wxUSE_LONGLONG/!wxUSE_LONGLONG diff --git a/Source/3rd Party/wx/src/common/strconv.cpp b/Source/3rd Party/wx/src/common/strconv.cpp index b2eaa7157..102462916 100644 --- a/Source/3rd Party/wx/src/common/strconv.cpp +++ b/Source/3rd Party/wx/src/common/strconv.cpp @@ -5,6 +5,7 @@ // Ryan Norton, Fredrik Roubert (UTF7) // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: strconv.cpp 64156 2010-04-27 08:52:30Z VZ $ // Copyright: (c) 1999 Ove Kaaven, Robert Roebling, Vaclav Slavik // (c) 2000-2003 Vadim Zeitlin // (c) 2004 Ryan Norton, Fredrik Roubert @@ -14,11 +15,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif //__BORLANDC__ - #ifndef WX_PRECOMP + #ifdef __WXMSW__ + #include "wx/msw/missing.h" + #endif #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" @@ -27,6 +27,12 @@ #include "wx/strconv.h" +#if wxUSE_WCHAR_T + +#ifdef __WINDOWS__ + #include "wx/msw/private.h" +#endif + #ifndef __WXWINCE__ #include #endif @@ -36,11 +42,13 @@ #include #if defined(__WIN32__) && !defined(__WXMICROWIN__) - #include "wx/msw/private.h" - #include "wx/msw/missing.h" #define wxHAVE_WIN32_MB2WC #endif +#ifdef __SALFORDC__ + #include +#endif + #ifdef HAVE_ICONV #include #include "wx/thread.h" @@ -49,12 +57,21 @@ #include "wx/encconv.h" #include "wx/fontmap.h" -#ifdef __DARWIN__ -#include "wx/osx/core/private/strconv_cf.h" -#endif //def __DARWIN__ +#ifdef __WXMAC__ +#ifndef __DARWIN__ +#include +#include +#include +#endif + +// includes Mac headers +#include "wx/mac/private.h" +#include "wx/thread.h" + +#endif -#define TRACE_STRCONV wxT("strconv") +#define TRACE_STRCONV _T("strconv") // WC_UTF16 is defined only if sizeof(wchar_t) == 2, otherwise it's supposed to // be 4 bytes @@ -139,7 +156,7 @@ static wxUint32 wxDecodeSurrogate(const wxDecodeSurrogate_t **pSrc) { wxUint32 out; const size_t - n = decode_utf16(reinterpret_cast(*pSrc), out); + n = decode_utf16(wx_reinterpret_cast(const wxUint16 *, *pSrc), out); if ( n == wxCONV_FAILED ) *pSrc = NULL; else @@ -157,15 +174,11 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen, const char *src, size_t srcLen) const { // although new conversion classes are supposed to implement this function - // directly, the existing ones only implement the old MB2WC() and so, to + // directly, the existins ones only implement the old MB2WC() and so, to // avoid to have to rewrite all conversion classes at once, we provide a // default (but not efficient) implementation of this one in terms of the // old function by copying the input to ensure that it's NUL-terminated and // then using MB2WC() to convert it - // - // moreover, some conversion classes simply can't implement ToWChar() - // directly, the primary example is wxConvLibc: mbstowcs() only handles - // NUL-terminated strings // the number of chars [which would be] written to dst [if it were not NULL] size_t dstWritten = 0; @@ -206,21 +219,6 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen, srcEnd = NULL; } - // the idea of this code is straightforward: it converts a NUL-terminated - // chunk of the string during each iteration and updates the output buffer - // with the result - // - // all the complication come from the fact that this function, for - // historical reasons, must behave in 2 subtly different ways when it's - // called with a fixed number of characters and when it's called for the - // entire NUL-terminated string: in the former case (srcEnd != NULL) we - // must count all characters we convert, NUL or not; but in the latter we - // do not count the trailing NUL -- but still count all the NULs inside the - // string - // - // so for the (simple) former case we just always count the trailing NUL, - // but for the latter we need to wait until we see if there is going to be - // another loop iteration and only count it then for ( ;; ) { // try to convert the current chunk @@ -228,11 +226,11 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen, if ( lenChunk == wxCONV_FAILED ) return wxCONV_FAILED; - dstWritten += lenChunk; - if ( !srcEnd ) - dstWritten++; + lenChunk++; // for the L'\0' at the end of this chunk - if ( !lenChunk ) + dstWritten += lenChunk; + + if ( lenChunk == 1 ) { // nothing left in the input string, conversion succeeded break; @@ -243,25 +241,20 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen, if ( dstWritten > dstLen ) return wxCONV_FAILED; - // +1 is for trailing NUL - if ( MB2WC(dst, src, lenChunk + 1) == wxCONV_FAILED ) + if ( MB2WC(dst, src, lenChunk) == wxCONV_FAILED ) return wxCONV_FAILED; dst += lenChunk; - if ( !srcEnd ) - dst++; } if ( !srcEnd ) { // we convert just one chunk in this case as this is the entire - // string anyhow (and we don't count the trailing NUL in this case) + // string anyhow break; } - // advance the input pointer past the end of this chunk: notice that we - // will always stop before srcEnd because we know that the chunk is - // always properly NUL-terminated + // advance the input pointer past the end of this chunk while ( NotAllNULs(src, nulLen) ) { // notice that we must skip over multiple bytes here as we suppose @@ -271,18 +264,11 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen, src += nulLen; } - // if the buffer ends before this NUL, we shouldn't count it in our - // output so skip the code below - if ( src == srcEnd ) - break; - - // do count this terminator as it's inside the buffer we convert - dstWritten++; - if ( dst ) - dst++; - - src += nulLen; // skip the terminator itself + src += nulLen; // skipping over its terminator as well + // note that ">=" (and not just "==") is needed here as the terminator + // we skipped just above could be inside or just after the buffer + // delimited by inEnd if ( src >= srcEnd ) break; } @@ -297,15 +283,13 @@ wxMBConv::FromWChar(char *dst, size_t dstLen, // the number of chars [which would be] written to dst [if it were not NULL] size_t dstWritten = 0; - // if we don't know its length we have no choice but to assume that it is - // NUL-terminated (notice that it can still be NUL-terminated even if - // explicit length is given but it doesn't change our return value) - const bool isNulTerminated = srcLen == wxNO_LEN; - // make a copy of the input string unless it is already properly // NUL-terminated + // + // if we don't know its length we have no choice but to assume that it is, + // indeed, properly terminated wxWCharBuffer bufTmp; - if ( isNulTerminated ) + if ( srcLen == wxNO_LEN ) { srcLen = wxWcslen(src) + 1; } @@ -320,65 +304,27 @@ wxMBConv::FromWChar(char *dst, size_t dstLen, const size_t lenNul = GetMBNulLen(); for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; - src++ /* skip L'\0' too */ ) + src += wxWcslen(src) + 1 /* skip L'\0' too */ ) { // try to convert the current chunk size_t lenChunk = WC2MB(NULL, src, 0); + if ( lenChunk == wxCONV_FAILED ) return wxCONV_FAILED; + lenChunk += lenNul; dstWritten += lenChunk; - const wchar_t * const - chunkEnd = isNulTerminated ? srcEnd - 1 : src + wxWcslen(src); - - // our return value accounts for the trailing NUL(s), unlike that of - // WC2MB(), however don't do it for the last NUL we artificially added - // ourselves above - if ( chunkEnd < srcEnd ) - dstWritten += lenNul; - if ( dst ) { if ( dstWritten > dstLen ) return wxCONV_FAILED; - // if we know that there is enough space in the destination buffer - // (because we accounted for lenNul in dstWritten above), we can - // convert directly in place -- but otherwise we need another - // temporary buffer to ensure that we don't overwrite the output - wxCharBuffer dstBuf; - char *dstTmp; - if ( chunkEnd == srcEnd ) - { - dstBuf = wxCharBuffer(lenChunk + lenNul - 1); - dstTmp = dstBuf.data(); - } - else - { - dstTmp = dst; - } - - if ( WC2MB(dstTmp, src, lenChunk + lenNul) == wxCONV_FAILED ) + if ( WC2MB(dst, src, lenChunk) == wxCONV_FAILED ) return wxCONV_FAILED; - if ( dstTmp != dst ) - { - // copy everything up to but excluding the terminating NUL(s) - // into the real output buffer - memcpy(dst, dstTmp, lenChunk); - - // micro-optimization: if dstTmp != dst it means that chunkEnd - // == srcEnd and so we're done, no need to update anything below - break; - } - dst += lenChunk; - if ( chunkEnd < srcEnd ) - dst += lenNul; } - - src = chunkEnd; } return dstWritten; @@ -418,14 +364,14 @@ const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const if ( psz ) { // calculate the length of the buffer needed first - const size_t nLen = ToWChar(NULL, 0, psz); + const size_t nLen = MB2WC(NULL, psz, 0); if ( nLen != wxCONV_FAILED ) { // now do the actual conversion - wxWCharBuffer buf(nLen - 1 /* +1 added implicitly */); + wxWCharBuffer buf(nLen /* +1 added implicitly */); // +1 for the trailing NULL - if ( ToWChar(buf.data(), nLen, psz) != wxCONV_FAILED ) + if ( MB2WC(buf.data(), psz, nLen + 1) != wxCONV_FAILED ) return buf; } } @@ -437,11 +383,14 @@ const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const { if ( pwz ) { - const size_t nLen = FromWChar(NULL, 0, pwz); + const size_t nLen = WC2MB(NULL, pwz, 0); if ( nLen != wxCONV_FAILED ) { - wxCharBuffer buf(nLen - 1); - if ( FromWChar(buf.data(), nLen, pwz) != wxCONV_FAILED ) + // extra space for trailing NUL(s) + static const size_t extraLen = GetMaxMBNulLen(); + + wxCharBuffer buf(nLen + extraLen - 1); + if ( WC2MB(buf.data(), pwz, nLen + extraLen) != wxCONV_FAILED ) return buf; } } @@ -455,22 +404,13 @@ wxMBConv::cMB2WC(const char *inBuff, size_t inLen, size_t *outLen) const const size_t dstLen = ToWChar(NULL, 0, inBuff, inLen); if ( dstLen != wxCONV_FAILED ) { - // notice that we allocate space for dstLen+1 wide characters here - // because we want the buffer to always be NUL-terminated, even if the - // input isn't (as otherwise the caller has no way to know its length) - wxWCharBuffer wbuf(dstLen); + wxWCharBuffer wbuf(dstLen - 1); if ( ToWChar(wbuf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED ) { if ( outLen ) { *outLen = dstLen; - - // we also need to handle NUL-terminated input strings - // specially: for them the output is the length of the string - // excluding the trailing NUL, however if we're asked to - // convert a specific number of characters we return the length - // of the resulting output even if it's NUL-terminated - if ( inLen == wxNO_LEN ) + if ( wbuf[dstLen - 1] == L'\0' ) (*outLen)--; } @@ -490,22 +430,21 @@ wxMBConv::cWC2MB(const wchar_t *inBuff, size_t inLen, size_t *outLen) const size_t dstLen = FromWChar(NULL, 0, inBuff, inLen); if ( dstLen != wxCONV_FAILED ) { - const size_t nulLen = GetMBNulLen(); - - // as above, ensure that the buffer is always NUL-terminated, even if - // the input is not - wxCharBuffer buf(dstLen + nulLen - 1); - memset(buf.data() + dstLen, 0, nulLen); + // special case of empty input: can't allocate 0 size buffer below as + // wxCharBuffer insists on NUL-terminating it + wxCharBuffer buf(dstLen ? dstLen - 1 : 1); if ( FromWChar(buf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED ) { if ( outLen ) { *outLen = dstLen; - if ( inLen == wxNO_LEN ) + const size_t nulLen = GetMBNulLen(); + if ( dstLen >= nulLen && + !NotAllNULs(buf.data() + dstLen - nulLen, nulLen) ) { - // in this case both input and output are NUL-terminated - // and we're not supposed to count NUL + // in this case the output is NUL-terminated and we're not + // supposed to count NUL *outLen -= nulLen; } } @@ -520,42 +459,6 @@ wxMBConv::cWC2MB(const wchar_t *inBuff, size_t inLen, size_t *outLen) const return wxCharBuffer(); } -const wxWCharBuffer wxMBConv::cMB2WC(const wxScopedCharBuffer& buf) const -{ - const size_t srcLen = buf.length(); - if ( srcLen ) - { - const size_t dstLen = ToWChar(NULL, 0, buf, srcLen); - if ( dstLen != wxCONV_FAILED ) - { - wxWCharBuffer wbuf(dstLen); - wbuf.data()[dstLen] = L'\0'; - if ( ToWChar(wbuf.data(), dstLen, buf, srcLen) != wxCONV_FAILED ) - return wbuf; - } - } - - return wxScopedWCharBuffer::CreateNonOwned(L"", 0); -} - -const wxCharBuffer wxMBConv::cWC2MB(const wxScopedWCharBuffer& wbuf) const -{ - const size_t srcLen = wbuf.length(); - if ( srcLen ) - { - const size_t dstLen = FromWChar(NULL, 0, wbuf, srcLen); - if ( dstLen != wxCONV_FAILED ) - { - wxCharBuffer buf(dstLen); - buf.data()[dstLen] = '\0'; - if ( FromWChar(buf.data(), dstLen, wbuf, srcLen) != wxCONV_FAILED ) - return buf; - } - } - - return wxScopedCharBuffer::CreateNonOwned("", 0); -} - // ---------------------------------------------------------------------------- // wxMBConvLibc // ---------------------------------------------------------------------------- @@ -576,10 +479,10 @@ size_t wxMBConvLibc::WC2MB(char *buf, const wchar_t *psz, size_t n) const #ifdef __UNIX__ -wxConvBrokenFileNames::wxConvBrokenFileNames(const wxString& charset) +wxConvBrokenFileNames::wxConvBrokenFileNames(const wxChar *charset) { - if ( wxStricmp(charset, wxT("UTF-8")) == 0 || - wxStricmp(charset, wxT("UTF8")) == 0 ) + if ( !charset || wxStricmp(charset, _T("UTF-8")) == 0 + || wxStricmp(charset, _T("UTF8")) == 0 ) m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA); else m_conv = new wxCSConv(charset); @@ -592,8 +495,6 @@ wxConvBrokenFileNames::wxConvBrokenFileNames(const wxString& charset) // ---------------------------------------------------------------------------- // Implementation (C) 2004 Fredrik Roubert -// -// Changes to work in streaming mode (C) 2008 Vadim Zeitlin // // BASE64 decoding table @@ -634,149 +535,70 @@ static const unsigned char utf7unb64[] = 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -size_t wxMBConvUTF7::ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen) const +size_t wxMBConvUTF7::MB2WC(wchar_t *buf, const char *psz, size_t n) const { - DecoderState stateOrig, - *statePtr; - if ( srcLen == wxNO_LEN ) - { - // convert the entire string, up to and including the trailing NUL - srcLen = strlen(src) + 1; - - // when working on the entire strings we don't update nor use the shift - // state from the previous call - statePtr = &stateOrig; - } - else // when working with partial strings we do use the shift state - { - statePtr = const_cast(&m_stateDecoder); - - // also save the old state to be able to rollback to it on error - stateOrig = m_stateDecoder; - } - - // but to simplify the code below we use this variable in both cases - DecoderState& state = *statePtr; - - - // number of characters [which would have been] written to dst [if it were - // not NULL] size_t len = 0; - const char * const srcEnd = src + srcLen; - - while ( (src < srcEnd) && (!dst || (len < dstLen)) ) + while ( *psz && (!buf || (len < n)) ) { - const unsigned char cc = *src++; - - if ( state.IsShifted() ) + unsigned char cc = *psz++; + if (cc != '+') { - const unsigned char dc = utf7unb64[cc]; - if ( dc == 0xff ) - { - // end of encoded part, check that nothing was left: there can - // be up to 4 bits of 0 padding but nothing else (we also need - // to check isLSB as we count bits modulo 8 while a valid UTF-7 - // encoded sequence must contain an integral number of UTF-16 - // characters) - if ( state.isLSB || state.bit > 4 || - (state.accum & ((1 << state.bit) - 1)) ) - { - if ( !len ) - state = stateOrig; - - return wxCONV_FAILED; - } - - state.ToDirect(); - - // re-parse this character normally below unless it's '-' which - // is consumed by the decoder - if ( cc == '-' ) - continue; - } - else // valid encoded character - { - // mini base64 decoder: each character is 6 bits - state.bit += 6; - state.accum <<= 6; - state.accum += dc; - - if ( state.bit >= 8 ) - { - // got the full byte, consume it - state.bit -= 8; - unsigned char b = (state.accum >> state.bit) & 0x00ff; - - if ( state.isLSB ) - { - // we've got the full word, output it - if ( dst ) - *dst++ = (state.msb << 8) | b; - len++; - state.isLSB = false; - } - else // MSB - { - // just store it while we wait for LSB - state.msb = b; - state.isLSB = true; - } - } - } + // plain ASCII char + if (buf) + *buf++ = cc; + len++; } - - if ( state.IsDirect() ) + else if (*psz == '-') { - // start of an encoded segment? - if ( cc == '+' ) + // encoded plus sign + if (buf) + *buf++ = cc; + len++; + psz++; + } + else // start of BASE64 encoded string + { + bool lsb, ok; + unsigned int d, l; + for ( ok = lsb = false, d = 0, l = 0; + (cc = utf7unb64[(unsigned char)*psz]) != 0xff; + psz++ ) { - if ( *src == '-' ) + d <<= 6; + d += cc; + for (l += 6; l >= 8; lsb = !lsb) { - // just the encoded plus sign, don't switch to shifted mode - if ( dst ) - *dst++ = '+'; - len++; - src++; - } - else if ( utf7unb64[(unsigned)*src] == 0xff ) - { - // empty encoded chunks are not allowed - if ( !len ) - state = stateOrig; + unsigned char c = (unsigned char)((d >> (l -= 8)) % 256); + if (lsb) + { + if (buf) + *buf++ |= c; + len ++; + } + else + { + if (buf) + *buf = (wchar_t)(c << 8); + } - return wxCONV_FAILED; - } - else // base-64 encoded chunk follows - { - state.ToShifted(); + ok = true; } } - else // not '+' - { - // only printable 7 bit ASCII characters (with the exception of - // NUL, TAB, CR and LF) can be used directly - if ( cc >= 0x7f || (cc < ' ' && - !(cc == '\0' || cc == '\t' || cc == '\r' || cc == '\n')) ) - return wxCONV_FAILED; - if ( dst ) - *dst++ = cc; - len++; + if ( !ok ) + { + // in valid UTF7 we should have valid characters after '+' + return wxCONV_FAILED; } + + if (*psz == '-') + psz++; } } - if ( !len ) - { - // as we didn't read any characters we should be called with the same - // data (followed by some more new data) again later so don't save our - // state - state = stateOrig; - - return wxCONV_FAILED; - } + if ( buf && (len < n) ) + *buf = '\0'; return len; } @@ -806,7 +628,7 @@ static const unsigned char utf7enb64[] = // static const unsigned char utf7encode[128] = { - 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, @@ -816,72 +638,21 @@ static const unsigned char utf7encode[128] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 3 }; -static inline bool wxIsUTF7Direct(wchar_t wc) +size_t wxMBConvUTF7::WC2MB(char *buf, const wchar_t *psz, size_t n) const { - return wc < 0x80 && utf7encode[wc] < 1; -} - -size_t wxMBConvUTF7::FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen) const -{ - EncoderState stateOrig, - *statePtr; - if ( srcLen == wxNO_LEN ) - { - // we don't apply the stored state when operating on entire strings at - // once - statePtr = &stateOrig; - - srcLen = wxWcslen(src) + 1; - } - else // do use the mode we left the output in previously - { - stateOrig = m_stateEncoder; - statePtr = const_cast(&m_stateEncoder); - } - - EncoderState& state = *statePtr; - - size_t len = 0; - const wchar_t * const srcEnd = src + srcLen; - while ( src < srcEnd && (!dst || len < dstLen) ) + while (*psz && ((!buf) || (len < n))) { - wchar_t cc = *src++; - if ( wxIsUTF7Direct(cc) ) + wchar_t cc = *psz++; + if (cc < 0x80 && utf7encode[cc] < 1) { - if ( state.IsShifted() ) - { - // pad with zeros the last encoded block if necessary - if ( state.bit ) - { - if ( dst ) - *dst++ = utf7enb64[((state.accum % 16) << (6 - state.bit)) % 64]; - len++; - } + // plain ASCII char + if (buf) + *buf++ = (char)cc; - state.ToDirect(); - - if ( dst ) - *dst++ = '-'; - len++; - } - - if ( dst ) - *dst++ = (char)cc; len++; } - else if ( cc == '+' && state.IsDirect() ) - { - if ( dst ) - { - *dst++ = '+'; - *dst++ = '-'; - } - - len += 2; - } #ifndef WC_UTF16 else if (((wxUint32)cc) > 0xffff) { @@ -891,45 +662,52 @@ size_t wxMBConvUTF7::FromWChar(char *dst, size_t dstLen, #endif else { - if ( state.IsDirect() ) - { - state.ToShifted(); + if (buf) + *buf++ = '+'; - if ( dst ) - *dst++ = '+'; - len++; - } - - // BASE64 encode string - for ( ;; ) + len++; + if (cc != '+') { - for ( unsigned lsb = 0; lsb < 2; lsb++ ) + // BASE64 encode string + unsigned int lsb, d, l; + for (d = 0, l = 0; /*nothing*/; psz++) { - state.accum <<= 8; - state.accum += lsb ? cc & 0xff : (cc & 0xff00) >> 8; - - for (state.bit += 8; state.bit >= 6; ) + for (lsb = 0; lsb < 2; lsb ++) { - state.bit -= 6; - if ( dst ) - *dst++ = utf7enb64[(state.accum >> state.bit) % 64]; - len++; + d <<= 8; + d += lsb ? cc & 0xff : (cc & 0xff00) >> 8; + + for (l += 8; l >= 6; ) + { + l -= 6; + if (buf) + *buf++ = utf7enb64[(d >> l) % 64]; + len++; + } } + + cc = *psz; + if (!(cc) || (cc < 0x80 && utf7encode[cc] < 1)) + break; } - if ( src == srcEnd || wxIsUTF7Direct(cc = *src) ) - break; + if (l != 0) + { + if (buf) + *buf++ = utf7enb64[((d % 16) << (6 - l)) % 64]; - src++; + len++; + } } + + if (buf) + *buf++ = '-'; + len++; } } - // we need to restore the original encoder state if we were called just to - // calculate the amount of space needed as we will presumably be called - // again to really convert the data now - if ( !dst ) - state = stateOrig; + if (buf && (len < n)) + *buf = 0; return len; } @@ -938,7 +716,7 @@ size_t wxMBConvUTF7::FromWChar(char *dst, size_t dstLen, // UTF-8 // ---------------------------------------------------------------------------- -static const wxUint32 utf8_max[]= +static wxUint32 utf8_max[]= { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff, 0xffffffff }; // boundaries of the private use area we use to (temporarily) remap invalid @@ -946,294 +724,11 @@ static const wxUint32 utf8_max[]= const wxUint32 wxUnicodePUA = 0x100000; const wxUint32 wxUnicodePUAEnd = wxUnicodePUA + 256; -// this table gives the length of the UTF-8 encoding from its first character: -const unsigned char tableUtf8Lengths[256] = { - // single-byte sequences (ASCII): - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00..0F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10..1F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20..2F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30..3F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40..4F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50..5F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60..6F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70..7F - - // these are invalid: - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80..8F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90..9F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A0..AF - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B0..BF - 0, 0, // C0,C1 - - // two-byte sequences: - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C2..CF - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0..DF - - // three-byte sequences: - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0..EF - - // four-byte sequences: - 4, 4, 4, 4, 4, // F0..F4 - - // these are invalid again (5- or 6-byte - // sequences and sequences for code points - // above U+10FFFF, as restricted by RFC 3629): - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // F5..FF -}; - -size_t -wxMBConvStrictUTF8::ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen) const +size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const { - wchar_t *out = dstLen ? dst : NULL; - size_t written = 0; - - if ( srcLen == wxNO_LEN ) - srcLen = strlen(src) + 1; - - for ( const char *p = src; ; p++ ) - { - if ( (srcLen == wxNO_LEN ? !*p : !srcLen) ) - { - // all done successfully, just add the trailing NULL if we are not - // using explicit length - if ( srcLen == wxNO_LEN ) - { - if ( out ) - { - if ( !dstLen ) - break; - - *out = L'\0'; - } - - written++; - } - - return written; - } - - if ( out && !dstLen-- ) - break; - - wxUint32 code; - unsigned char c = *p; - - if ( c < 0x80 ) - { - if ( srcLen == 0 ) // the test works for wxNO_LEN too - break; - - if ( srcLen != wxNO_LEN ) - srcLen--; - - code = c; - } - else - { - unsigned len = tableUtf8Lengths[c]; - if ( !len ) - break; - - if ( srcLen < len ) // the test works for wxNO_LEN too - break; - - if ( srcLen != wxNO_LEN ) - srcLen -= len; - - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // ----------------------+---------------------------------------- - // 0000 0000 - 0000 007F | 0xxxxxxx - // 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Code point value is stored in bits marked with 'x', - // lowest-order bit of the value on the right side in the diagram - // above. (from RFC 3629) - - // mask to extract lead byte's value ('x' bits above), by sequence - // length: - static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 }; - - // mask and value of lead byte's most significant bits, by length: - static const unsigned char leadMarkerMask[] = { 0x80, 0xE0, 0xF0, 0xF8 }; - static const unsigned char leadMarkerVal[] = { 0x00, 0xC0, 0xE0, 0xF0 }; - - len--; // it's more convenient to work with 0-based length here - - // extract the lead byte's value bits: - if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] ) - break; - - code = c & leadValueMask[len]; - - // all remaining bytes, if any, are handled in the same way - // regardless of sequence's length: - for ( ; len; --len ) - { - c = *++p; - if ( (c & 0xC0) != 0x80 ) - return wxCONV_FAILED; - - code <<= 6; - code |= c & 0x3F; - } - } - -#ifdef WC_UTF16 - // cast is ok because wchar_t == wxUint16 if WC_UTF16 - if ( encode_utf16(code, (wxUint16 *)out) == 2 ) - { - if ( out ) - out++; - written++; - } -#else // !WC_UTF16 - if ( out ) - *out = code; -#endif // WC_UTF16/!WC_UTF16 - - if ( out ) - out++; - - written++; - } - - return wxCONV_FAILED; -} - -size_t -wxMBConvStrictUTF8::FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen) const -{ - char *out = dstLen ? dst : NULL; - size_t written = 0; - - for ( const wchar_t *wp = src; ; wp++ ) - { - if ( (srcLen == wxNO_LEN ? !*wp : !srcLen) ) - { - // all done successfully, just add the trailing NULL if we are not - // using explicit length - if ( srcLen == wxNO_LEN ) - { - if ( out ) - { - if ( !dstLen ) - break; - - *out = '\0'; - } - - written++; - } - - return written; - } - - if ( srcLen != wxNO_LEN ) - srcLen--; - - wxUint32 code; -#ifdef WC_UTF16 - // cast is ok for WC_UTF16 - if ( decode_utf16((const wxUint16 *)wp, code) == 2 ) - { - // skip the next char too as we decoded a surrogate - wp++; - if ( srcLen != wxNO_LEN ) - srcLen--; - } -#else // wchar_t is UTF-32 - code = *wp & 0x7fffffff; -#endif - - unsigned len; - if ( code <= 0x7F ) - { - len = 1; - if ( out ) - { - if ( dstLen < len ) - break; - - out[0] = (char)code; - } - } - else if ( code <= 0x07FF ) - { - len = 2; - if ( out ) - { - if ( dstLen < len ) - break; - - // NB: this line takes 6 least significant bits, encodes them as - // 10xxxxxx and discards them so that the next byte can be encoded: - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xC0 | code; - } - } - else if ( code < 0xFFFF ) - { - len = 3; - if ( out ) - { - if ( dstLen < len ) - break; - - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xE0 | code; - } - } - else if ( code <= 0x10FFFF ) - { - len = 4; - if ( out ) - { - if ( dstLen < len ) - break; - - out[3] = 0x80 | (code & 0x3F); code >>= 6; - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xF0 | code; - } - } - else - { - wxFAIL_MSG( wxT("trying to encode undefined Unicode character") ); - break; - } - - if ( out ) - { - out += len; - dstLen -= len; - } - - written += len; - } - - // we only get here if an error occurs during decoding - return wxCONV_FAILED; -} - -size_t wxMBConvUTF8::ToWChar(wchar_t *buf, size_t n, - const char *psz, size_t srcLen) const -{ - if ( m_options == MAP_INVALID_UTF8_NOT ) - return wxMBConvStrictUTF8::ToWChar(buf, n, psz, srcLen); - size_t len = 0; - // The length can be either given explicitly or computed implicitly for the - // NUL-terminated strings. - const bool isNulTerminated = srcLen == wxNO_LEN; - while ((isNulTerminated ? *psz : srcLen--) && ((!buf) || (len < n))) + while (*psz && ((!buf) || (len < n))) { const char *opsz = psz; bool invalid = false; @@ -1272,14 +767,6 @@ size_t wxMBConvUTF8::ToWChar(wchar_t *buf, size_t n, wxUint32 res = cc & (0x3f >> cnt); while (cnt--) { - if (!isNulTerminated && !srcLen) - { - // invalid UTF-8 sequence ending before the end of code - // point. - invalid = true; - break; - } - cc = *psz; if ((cc & 0xC0) != 0x80) { @@ -1289,8 +776,6 @@ size_t wxMBConvUTF8::ToWChar(wchar_t *buf, size_t n, } psz++; - if (!isNulTerminated) - srcLen--; res = (res << 6) | (cc & 0x3f); } @@ -1310,7 +795,7 @@ size_t wxMBConvUTF8::ToWChar(wchar_t *buf, size_t n, else { #ifdef WC_UTF16 - // cast is ok because wchar_t == wxUint16 if WC_UTF16 + // cast is ok because wchar_t == wxUuint16 if WC_UTF16 size_t pa = encode_utf16(res, (wxUint16 *)buf); if (pa == wxCONV_FAILED) { @@ -1377,15 +862,8 @@ size_t wxMBConvUTF8::ToWChar(wchar_t *buf, size_t n, } } - if ( isNulTerminated ) - { - // Add the trailing NUL in this case if we have a large enough buffer. - if ( buf && (len < n) ) - *buf = 0; - - // And count it in any case. - len++; - } + if (buf && (len < n)) + *buf = 0; return len; } @@ -1395,18 +873,11 @@ static inline bool isoctal(wchar_t wch) return L'0' <= wch && wch <= L'7'; } -size_t wxMBConvUTF8::FromWChar(char *buf, size_t n, - const wchar_t *psz, size_t srcLen) const +size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const { - if ( m_options == MAP_INVALID_UTF8_NOT ) - return wxMBConvStrictUTF8::FromWChar(buf, n, psz, srcLen); - size_t len = 0; - // The length can be either given explicitly or computed implicitly for the - // NUL-terminated strings. - const bool isNulTerminated = srcLen == wxNO_LEN; - while ((isNulTerminated ? *psz : srcLen--) && ((!buf) || (len < n))) + while (*psz && ((!buf) || (len < n))) { wxUint32 cc; @@ -1474,15 +945,8 @@ size_t wxMBConvUTF8::FromWChar(char *buf, size_t n, } } - if ( isNulTerminated ) - { - // Add the trailing NUL in this case if we have a large enough buffer. - if ( buf && (len < n) ) - *buf = 0; - - // And count it in any case. - len++; - } + if (buf && (len < n)) + *buf = 0; return len; } @@ -1505,7 +969,7 @@ size_t wxMBConvUTF16Base::GetLength(const char *src, size_t srcLen) if ( srcLen == wxNO_LEN ) { // count the number of bytes in input, including the trailing NULs - const wxUint16 *inBuff = reinterpret_cast(src); + const wxUint16 *inBuff = wx_reinterpret_cast(const wxUint16 *, src); for ( srcLen = 1; *inBuff++; srcLen++ ) ; @@ -1589,7 +1053,7 @@ wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen, if ( dstLen < srcLen ) return wxCONV_FAILED; - const wxUint16 *inBuff = reinterpret_cast(src); + const wxUint16 *inBuff = wx_reinterpret_cast(const wxUint16 *, src); for ( size_t n = 0; n < srcLen; n++, inBuff++ ) { *dst++ = wxUINT16_SWAP_ALWAYS(*inBuff); @@ -1613,7 +1077,7 @@ wxMBConvUTF16swap::FromWChar(char *dst, size_t dstLen, if ( dstLen < srcLen ) return wxCONV_FAILED; - wxUint16 *outBuff = reinterpret_cast(dst); + wxUint16 *outBuff = wx_reinterpret_cast(wxUint16 *, dst); for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ ) { *outBuff++ = wxUINT16_SWAP_ALWAYS(*src); @@ -1638,23 +1102,26 @@ wxMBConvUTF16straight::ToWChar(wchar_t *dst, size_t dstLen, return wxCONV_FAILED; const size_t inLen = srcLen / BYTES_PER_CHAR; + if ( !dst ) + { + // optimization: return maximal space which could be needed for this + // string even if the real size could be smaller if the buffer contains + // any surrogates + return inLen; + } + size_t outLen = 0; - const wxUint16 *inBuff = reinterpret_cast(src); + const wxUint16 *inBuff = wx_reinterpret_cast(const wxUint16 *, src); for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; ) { const wxUint32 ch = wxDecodeSurrogate(&inBuff); if ( !inBuff ) return wxCONV_FAILED; - outLen++; + if ( ++outLen > dstLen ) + return wxCONV_FAILED; - if ( dst ) - { - if ( outLen > dstLen ) - return wxCONV_FAILED; - - *dst++ = ch; - } + *dst++ = ch; } @@ -1669,10 +1136,10 @@ wxMBConvUTF16straight::FromWChar(char *dst, size_t dstLen, srcLen = wxWcslen(src) + 1; size_t outLen = 0; - wxUint16 *outBuff = reinterpret_cast(dst); + wxUint16 *outBuff = wx_reinterpret_cast(wxUint16 *, dst); for ( size_t n = 0; n < srcLen; n++ ) { - wxUint16 cc[2] = { 0 }; + wxUint16 cc[2]; const size_t numChars = encode_utf16(*src++, cc); if ( numChars == wxCONV_FAILED ) return wxCONV_FAILED; @@ -1708,8 +1175,16 @@ wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen, return wxCONV_FAILED; const size_t inLen = srcLen / BYTES_PER_CHAR; + if ( !dst ) + { + // optimization: return maximal space which could be needed for this + // string even if the real size could be smaller if the buffer contains + // any surrogates + return inLen; + } + size_t outLen = 0; - const wxUint16 *inBuff = reinterpret_cast(src); + const wxUint16 *inBuff = wx_reinterpret_cast(const wxUint16 *, src); for ( const wxUint16 * const inEnd = inBuff + inLen; inBuff < inEnd; ) { wxUint32 ch; @@ -1726,15 +1201,10 @@ wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen, if ( numChars == 2 ) inBuff++; - outLen++; + if ( ++outLen > dstLen ) + return wxCONV_FAILED; - if ( dst ) - { - if ( outLen > dstLen ) - return wxCONV_FAILED; - - *dst++ = ch; - } + *dst++ = ch; } @@ -1749,10 +1219,10 @@ wxMBConvUTF16swap::FromWChar(char *dst, size_t dstLen, srcLen = wxWcslen(src) + 1; size_t outLen = 0; - wxUint16 *outBuff = reinterpret_cast(dst); + wxUint16 *outBuff = wx_reinterpret_cast(wxUint16 *, dst); for ( const wchar_t *srcEnd = src + srcLen; src < srcEnd; src++ ) { - wxUint16 cc[2] = { 0 }; + wxUint16 cc[2]; const size_t numChars = encode_utf16(*src, cc); if ( numChars == wxCONV_FAILED ) return wxCONV_FAILED; @@ -1800,7 +1270,7 @@ size_t wxMBConvUTF32Base::GetLength(const char *src, size_t srcLen) if ( srcLen == wxNO_LEN ) { // count the number of bytes in input, including the trailing NULs - const wxUint32 *inBuff = reinterpret_cast(src); + const wxUint32 *inBuff = wx_reinterpret_cast(const wxUint32 *, src); for ( srcLen = 1; *inBuff++; srcLen++ ) ; @@ -1831,12 +1301,12 @@ wxMBConvUTF32straight::ToWChar(wchar_t *dst, size_t dstLen, if ( srcLen == wxNO_LEN ) return wxCONV_FAILED; - const wxUint32 *inBuff = reinterpret_cast(src); + const wxUint32 *inBuff = wx_reinterpret_cast(const wxUint32 *, src); const size_t inLen = srcLen / BYTES_PER_CHAR; size_t outLen = 0; for ( size_t n = 0; n < inLen; n++ ) { - wxUint16 cc[2] = { 0 }; + wxUint16 cc[2]; const size_t numChars = encode_utf16(*inBuff++, cc); if ( numChars == wxCONV_FAILED ) return wxCONV_FAILED; @@ -1878,7 +1348,7 @@ wxMBConvUTF32straight::FromWChar(char *dst, size_t dstLen, return srcLen * BYTES_PER_CHAR; } - wxUint32 *outBuff = reinterpret_cast(dst); + wxUint32 *outBuff = wx_reinterpret_cast(wxUint32 *, dst); size_t outLen = 0; for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; ) { @@ -1909,12 +1379,12 @@ wxMBConvUTF32swap::ToWChar(wchar_t *dst, size_t dstLen, if ( srcLen == wxNO_LEN ) return wxCONV_FAILED; - const wxUint32 *inBuff = reinterpret_cast(src); + const wxUint32 *inBuff = wx_reinterpret_cast(const wxUint32 *, src); const size_t inLen = srcLen / BYTES_PER_CHAR; size_t outLen = 0; for ( size_t n = 0; n < inLen; n++, inBuff++ ) { - wxUint16 cc[2] = { 0 }; + wxUint16 cc[2]; const size_t numChars = encode_utf16(wxUINT32_SWAP_ALWAYS(*inBuff), cc); if ( numChars == wxCONV_FAILED ) return wxCONV_FAILED; @@ -1956,7 +1426,7 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen, return srcLen*BYTES_PER_CHAR; } - wxUint32 *outBuff = reinterpret_cast(dst); + wxUint32 *outBuff = wx_reinterpret_cast(wxUint32 *, dst); size_t outLen = 0; for ( const wchar_t * const srcEnd = src + srcLen; src < srcEnd; ) { @@ -2041,7 +1511,7 @@ wxMBConvUTF32swap::ToWChar(wchar_t *dst, size_t dstLen, if ( dstLen < srcLen ) return wxCONV_FAILED; - const wxUint32 *inBuff = reinterpret_cast(src); + const wxUint32 *inBuff = wx_reinterpret_cast(const wxUint32 *, src); for ( size_t n = 0; n < srcLen; n++, inBuff++ ) { *dst++ = wxUINT32_SWAP_ALWAYS(*inBuff); @@ -2065,7 +1535,7 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen, if ( dstLen < srcLen ) return wxCONV_FAILED; - wxUint32 *outBuff = reinterpret_cast(dst); + wxUint32 *outBuff = wx_reinterpret_cast(wxUint32 *, dst); for ( size_t n = 0; n < srcLen; n += BYTES_PER_CHAR, src++ ) { *outBuff++ = wxUINT32_SWAP_ALWAYS(*src); @@ -2121,19 +1591,14 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen, class wxMBConv_iconv : public wxMBConv { public: - wxMBConv_iconv(const char *name); + wxMBConv_iconv(const wxChar *name); virtual ~wxMBConv_iconv(); - // implement base class virtual methods - virtual size_t ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen = wxNO_LEN) const; - virtual size_t FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen = wxNO_LEN) const; - virtual size_t GetMBNulLen() const; + virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const; + virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; -#if wxUSE_UNICODE_UTF8 - virtual bool IsUTF8() const; -#endif + // classify this encoding as explained in wxMBConv::GetMBNulLen() comment + virtual size_t GetMBNulLen() const; virtual wxMBConv *Clone() const { @@ -2167,7 +1632,7 @@ private: // name of the encoding handled by this conversion - const char *m_name; + wxString m_name; // cached result of GetMBNulLen(); set to 0 meaning "unknown" // initially @@ -2175,7 +1640,7 @@ private: }; // make the constructor available for unit testing -WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name ) +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name ) { wxMBConv_iconv* result = new wxMBConv_iconv( name ); if ( !result->IsOk() ) @@ -2190,29 +1655,33 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name ) wxString wxMBConv_iconv::ms_wcCharsetName; bool wxMBConv_iconv::ms_wcNeedsSwap = false; -wxMBConv_iconv::wxMBConv_iconv(const char *name) - : m_name(wxStrdup(name)) +wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) + : m_name(name) { m_minMBCharWidth = 0; + // iconv operates with chars, not wxChars, but luckily it uses only ASCII + // names for the charsets + const wxCharBuffer cname(wxString(name).ToAscii()); + // check for charset that represents wchar_t: if ( ms_wcCharsetName.empty() ) { - wxLogTrace(TRACE_STRCONV, wxT("Looking for wide char codeset:")); + wxLogTrace(TRACE_STRCONV, _T("Looking for wide char codeset:")); #if wxUSE_FONTMAP - const wxChar *const *names = wxFontMapperBase::GetAllEncodingNames(WC_ENC); + const wxChar **names = wxFontMapperBase::GetAllEncodingNames(WC_ENC); #else // !wxUSE_FONTMAP - static const wxChar *const names_static[] = + static const wxChar *names_static[] = { #if SIZEOF_WCHAR_T == 4 - wxT("UCS-4"), + _T("UCS-4"), #elif SIZEOF_WCHAR_T == 2 - wxT("UCS-2"), + _T("UCS-2"), #endif NULL }; - const wxChar *const *names = names_static; + const wxChar **names = names_static; #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP for ( ; *names && ms_wcCharsetName.empty(); ++names ) @@ -2223,27 +1692,27 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name) wxString nameXE(nameCS); #ifdef WORDS_BIGENDIAN - nameXE += wxT("BE"); + nameXE += _T("BE"); #else // little endian - nameXE += wxT("LE"); + nameXE += _T("LE"); #endif - wxLogTrace(TRACE_STRCONV, wxT(" trying charset \"%s\""), + wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""), nameXE.c_str()); - m2w = iconv_open(nameXE.ToAscii(), name); + m2w = iconv_open(nameXE.ToAscii(), cname); if ( m2w == ICONV_T_INVALID ) { // try charset w/o bytesex info (e.g. "UCS4") - wxLogTrace(TRACE_STRCONV, wxT(" trying charset \"%s\""), + wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""), nameCS.c_str()); - m2w = iconv_open(nameCS.ToAscii(), name); + m2w = iconv_open(nameCS.ToAscii(), cname); // and check for bytesex ourselves: if ( m2w != ICONV_T_INVALID ) { char buf[2], *bufPtr; - wchar_t wbuf[2]; + wchar_t wbuf[2], *wbufPtr; size_t insz, outsz; size_t res; @@ -2252,12 +1721,12 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name) wbuf[0] = 0; insz = 2; outsz = SIZEOF_WCHAR_T * 2; - char* wbufPtr = (char*)wbuf; + wbufPtr = wbuf; bufPtr = buf; res = iconv( m2w, ICONV_CHAR_CAST(&bufPtr), &insz, - &wbufPtr, &outsz); + (char**)&wbufPtr, &outsz); if (ICONV_FAILED(res, insz)) { @@ -2280,14 +1749,14 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name) wxLogTrace(TRACE_STRCONV, wxT("iconv wchar_t charset is \"%s\"%s"), - ms_wcCharsetName.empty() ? wxString("") - : ms_wcCharsetName, - ms_wcNeedsSwap ? wxT(" (needs swap)") - : wxT("")); + ms_wcCharsetName.empty() ? _T("") + : ms_wcCharsetName.c_str(), + ms_wcNeedsSwap ? _T(" (needs swap)") + : _T("")); } else // we already have ms_wcCharsetName { - m2w = iconv_open(ms_wcCharsetName.ToAscii(), name); + m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname); } if ( ms_wcCharsetName.empty() ) @@ -2296,67 +1765,51 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name) } else { - w2m = iconv_open(name, ms_wcCharsetName.ToAscii()); + w2m = iconv_open(cname, ms_wcCharsetName.ToAscii()); if ( w2m == ICONV_T_INVALID ) { wxLogTrace(TRACE_STRCONV, wxT("\"%s\" -> \"%s\" works but not the converse!?"), - ms_wcCharsetName.c_str(), name); + ms_wcCharsetName.c_str(), cname.data()); } } } wxMBConv_iconv::~wxMBConv_iconv() { - free(const_cast(m_name)); - if ( m2w != ICONV_T_INVALID ) iconv_close(m2w); if ( w2m != ICONV_T_INVALID ) iconv_close(w2m); } -size_t -wxMBConv_iconv::ToWChar(wchar_t *dst, size_t dstLen, - const char *src, size_t srcLen) const +size_t wxMBConv_iconv::MB2WC(wchar_t *buf, const char *psz, size_t n) const { - if ( srcLen == wxNO_LEN ) + // find the string length: notice that must be done differently for + // NUL-terminated strings and UTF-16/32 which are terminated with 2/4 NULs + size_t inbuf; + const size_t nulLen = GetMBNulLen(); + switch ( nulLen ) { - // find the string length: notice that must be done differently for - // NUL-terminated strings and UTF-16/32 which are terminated with 2/4 - // consecutive NULs - const size_t nulLen = GetMBNulLen(); - switch ( nulLen ) - { - default: - return wxCONV_FAILED; + default: + return wxCONV_FAILED; - case 1: - srcLen = strlen(src); // arguably more optimized than our version - break; + case 1: + inbuf = strlen(psz); // arguably more optimized than our version + break; - case 2: - case 4: - // for UTF-16/32 not only we need to have 2/4 consecutive NULs - // but they also have to start at character boundary and not - // span two adjacent characters - const char *p; - for ( p = src; NotAllNULs(p, nulLen); p += nulLen ) - ; - srcLen = p - src; - break; - } - - // when we're determining the length of the string ourselves we count - // the terminating NUL(s) as part of it and always NUL-terminate the - // output - srcLen += nulLen; + case 2: + case 4: + // for UTF-16/32 not only we need to have 2/4 consecutive NULs but + // they also have to start at character boundary and not span two + // adjacent characters + const char *p; + for ( p = psz; NotAllNULs(p, nulLen); p += nulLen ) + ; + inbuf = p - psz; + break; } - // we express length in the number of (wide) characters but iconv always - // counts buffer sizes it in bytes - dstLen *= SIZEOF_WCHAR_T; - #if wxUSE_THREADS // NB: iconv() is MT-safe, but each thread must use its own iconv_t handle. // Unfortunately there are a couple of global wxCSConv objects such as @@ -2367,51 +1820,53 @@ wxMBConv_iconv::ToWChar(wchar_t *dst, size_t dstLen, wxMutexLocker lock(wxConstCast(this, wxMBConv_iconv)->m_iconvMutex); #endif // wxUSE_THREADS + size_t outbuf = n * SIZEOF_WCHAR_T; size_t res, cres; - const char *pszPtr = src; + // VS: Use these instead of psz, buf because iconv() modifies its arguments: + wchar_t *bufPtr = buf; + const char *pszPtr = psz; - if ( dst ) + if (buf) { - char* bufPtr = (char*)dst; - // have destination buffer, convert there - size_t dstLenOrig = dstLen; cres = iconv(m2w, - ICONV_CHAR_CAST(&pszPtr), &srcLen, - &bufPtr, &dstLen); - - // convert the number of bytes converted as returned by iconv to the - // number of (wide) characters converted that we need - res = (dstLenOrig - dstLen) / SIZEOF_WCHAR_T; + ICONV_CHAR_CAST(&pszPtr), &inbuf, + (char**)&bufPtr, &outbuf); + res = n - (outbuf / SIZEOF_WCHAR_T); if (ms_wcNeedsSwap) { // convert to native endianness for ( unsigned i = 0; i < res; i++ ) - dst[i] = WC_BSWAP(dst[i]); + buf[n] = WC_BSWAP(buf[i]); } + + // NUL-terminate the string if there is any space left + if (res < n) + buf[res] = 0; } - else // no destination buffer + else { - // convert using temp buffer to calculate the size of the buffer needed - wchar_t tbuf[256]; + // no destination buffer... convert using temp buffer + // to calculate destination buffer requirement + wchar_t tbuf[8]; res = 0; do { - char* bufPtr = (char*)tbuf; - dstLen = 8 * SIZEOF_WCHAR_T; + bufPtr = tbuf; + outbuf = 8 * SIZEOF_WCHAR_T; cres = iconv(m2w, - ICONV_CHAR_CAST(&pszPtr), &srcLen, - &bufPtr, &dstLen ); + ICONV_CHAR_CAST(&pszPtr), &inbuf, + (char**)&bufPtr, &outbuf ); - res += 8 - (dstLen / SIZEOF_WCHAR_T); + res += 8 - (outbuf / SIZEOF_WCHAR_T); } while ((cres == (size_t)-1) && (errno == E2BIG)); } - if (ICONV_FAILED(cres, srcLen)) + if (ICONV_FAILED(cres, inbuf)) { //VS: it is ok if iconv fails, hence trace only wxLogTrace(TRACE_STRCONV, wxT("iconv failed: %s"), wxSysErrorMsg(wxSysErrorCode())); @@ -2421,19 +1876,16 @@ wxMBConv_iconv::ToWChar(wchar_t *dst, size_t dstLen, return res; } -size_t wxMBConv_iconv::FromWChar(char *dst, size_t dstLen, - const wchar_t *src, size_t srcLen) const +size_t wxMBConv_iconv::WC2MB(char *buf, const wchar_t *psz, size_t n) const { #if wxUSE_THREADS // NB: explained in MB2WC wxMutexLocker lock(wxConstCast(this, wxMBConv_iconv)->m_iconvMutex); #endif - if ( srcLen == wxNO_LEN ) - srcLen = wxWcslen(src) + 1; - - size_t inbuflen = srcLen * SIZEOF_WCHAR_T; - size_t outbuflen = dstLen; + size_t inlen = wxWcslen(psz); + size_t inbuf = inlen * SIZEOF_WCHAR_T; + size_t outbuf = n; size_t res, cres; wchar_t *tmpbuf = 0; @@ -2441,36 +1893,43 @@ size_t wxMBConv_iconv::FromWChar(char *dst, size_t dstLen, if (ms_wcNeedsSwap) { // need to copy to temp buffer to switch endianness - // (doing WC_BSWAP twice on the original buffer won't work, as it + // (doing WC_BSWAP twice on the original buffer won't help, as it // could be in read-only memory, or be accessed in some other thread) - tmpbuf = (wchar_t *)malloc(inbuflen); - for ( size_t i = 0; i < srcLen; i++ ) - tmpbuf[i] = WC_BSWAP(src[i]); + tmpbuf = (wchar_t *)malloc(inbuf + SIZEOF_WCHAR_T); + for ( size_t i = 0; i < inlen; i++ ) + tmpbuf[n] = WC_BSWAP(psz[i]); - src = tmpbuf; + tmpbuf[inlen] = L'\0'; + psz = tmpbuf; } - char* inbuf = (char*)src; - if ( dst ) + if (buf) { // have destination buffer, convert there - cres = iconv(w2m, ICONV_CHAR_CAST(&inbuf), &inbuflen, &dst, &outbuflen); + cres = iconv( w2m, ICONV_CHAR_CAST(&psz), &inbuf, &buf, &outbuf ); - res = dstLen - outbuflen; + res = n - outbuf; + + // NB: iconv was given only wcslen(psz) characters on input, and so + // it couldn't convert the trailing zero. Let's do it ourselves + // if there's some room left for it in the output buffer. + if (res < n) + buf[0] = 0; } - else // no destination buffer + else { - // convert using temp buffer to calculate the size of the buffer needed - char tbuf[256]; + // no destination buffer: convert using temp buffer + // to calculate destination buffer requirement + char tbuf[16]; res = 0; do { - dst = tbuf; - outbuflen = WXSIZEOF(tbuf); + buf = tbuf; + outbuf = 16; - cres = iconv(w2m, ICONV_CHAR_CAST(&inbuf), &inbuflen, &dst, &outbuflen); + cres = iconv( w2m, ICONV_CHAR_CAST(&psz), &inbuf, &buf, &outbuf ); - res += WXSIZEOF(tbuf) - outbuflen; + res += 16 - outbuf; } while ((cres == (size_t)-1) && (errno == E2BIG)); } @@ -2480,7 +1939,7 @@ size_t wxMBConv_iconv::FromWChar(char *dst, size_t dstLen, free(tmpbuf); } - if (ICONV_FAILED(cres, inbuflen)) + if (ICONV_FAILED(cres, inbuf)) { wxLogTrace(TRACE_STRCONV, wxT("iconv failed: %s"), wxSysErrorMsg(wxSysErrorCode())); return wxCONV_FAILED; @@ -2519,14 +1978,6 @@ size_t wxMBConv_iconv::GetMBNulLen() const return m_minMBCharWidth; } -#if wxUSE_UNICODE_UTF8 -bool wxMBConv_iconv::IsUTF8() const -{ - return wxStricmp(m_name, "UTF-8") == 0 || - wxStricmp(m_name, "UTF8") == 0; -} -#endif - #endif // HAVE_ICONV @@ -2538,7 +1989,7 @@ bool wxMBConv_iconv::IsUTF8() const // from utils.cpp #if wxUSE_FONTMAP -extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const char *charset); +extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const wxChar *charset); extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding); #endif @@ -2559,7 +2010,7 @@ public: } #if wxUSE_FONTMAP - wxMBConv_win32(const char* name) + wxMBConv_win32(const wxChar* name) { m_CodePage = wxCharsetToCodepage(name); m_minMBCharWidth = 0; @@ -2587,12 +2038,12 @@ public: // http://msdn.microsoft.com/library/en-us/intl/unicode_17si.asp if ( m_CodePage == CP_UTF8 ) { - return wxMBConvUTF8().MB2WC(buf, psz, n); + return wxConvUTF8.MB2WC(buf, psz, n); } if ( m_CodePage == CP_UTF7 ) { - return wxMBConvUTF7().MB2WC(buf, psz, n); + return wxConvUTF7.MB2WC(buf, psz, n); } int flags = 0; @@ -2702,38 +2153,26 @@ public: return wxCONV_FAILED; } - // we did something, check if we really succeeded - if ( flags ) + // if we were really converting, check if we succeeded + if ( buf ) { - // check if the conversion failed, i.e. if any replacements - // were done - if ( usedDef ) - return wxCONV_FAILED; - } - else // we must resort to double tripping... - { - // first we need to ensure that we really have the MB data: this is - // not the case if we're called with NULL buffer, in which case we - // need to do the conversion yet again - wxCharBuffer bufDef; - if ( !buf ) + if ( flags ) { - bufDef = wxCharBuffer(len); - buf = bufDef.data(); - if ( !::WideCharToMultiByte(m_CodePage, flags, pwz, -1, - buf, len, NULL, NULL) ) + // check if the conversion failed, i.e. if any replacements + // were done + if ( usedDef ) return wxCONV_FAILED; } - - if ( !n ) - n = wcslen(pwz); - wxWCharBuffer wcBuf(n); - if ( MB2WC(wcBuf.data(), buf, n + 1) == wxCONV_FAILED || - wcscmp(wcBuf, pwz) != 0 ) + else // we must resort to double tripping... { - // we didn't obtain the same thing we started from, hence - // the conversion was lossy and we consider that it failed - return wxCONV_FAILED; + wxWCharBuffer wcBuf(n); + if ( MB2WC(wcBuf.data(), buf, n) == wxCONV_FAILED || + wcscmp(wcBuf, pwz) != 0 ) + { + // we didn't obtain the same thing we started from, hence + // the conversion was lossy and we consider that it failed + return wxCONV_FAILED; + } } } @@ -2761,7 +2200,7 @@ public: switch ( len ) { default: - wxLogDebug(wxT("Unexpected NUL length %d"), len); + wxLogDebug(_T("Unexpected NUL length %d"), len); self->m_minMBCharWidth = (size_t)-1; break; @@ -2808,7 +2247,7 @@ private: break; } - wxASSERT_MSG( s_isWin98Or2k != -1, wxT("should be set above") ); + wxASSERT_MSG( s_isWin98Or2k != -1, _T("should be set above") ); } return s_isWin98Or2k == 1; @@ -2852,6 +2291,827 @@ private: #endif // wxHAVE_WIN32_MB2WC +// ============================================================================ +// Cocoa conversion classes +// ============================================================================ + +#if defined(__WXCOCOA__) + +// RN: There is no UTF-32 support in either Core Foundation or Cocoa. +// Strangely enough, internally Core Foundation uses +// UTF-32 internally quite a bit - its just not public (yet). + +#include +#include + +CFStringEncoding wxCFStringEncFromFontEnc(wxFontEncoding encoding) +{ + CFStringEncoding enc = kCFStringEncodingInvalidId ; + + switch (encoding) + { + case wxFONTENCODING_DEFAULT : + enc = CFStringGetSystemEncoding(); + break ; + + case wxFONTENCODING_ISO8859_1 : + enc = kCFStringEncodingISOLatin1 ; + break ; + case wxFONTENCODING_ISO8859_2 : + enc = kCFStringEncodingISOLatin2; + break ; + case wxFONTENCODING_ISO8859_3 : + enc = kCFStringEncodingISOLatin3 ; + break ; + case wxFONTENCODING_ISO8859_4 : + enc = kCFStringEncodingISOLatin4; + break ; + case wxFONTENCODING_ISO8859_5 : + enc = kCFStringEncodingISOLatinCyrillic; + break ; + case wxFONTENCODING_ISO8859_6 : + enc = kCFStringEncodingISOLatinArabic; + break ; + case wxFONTENCODING_ISO8859_7 : + enc = kCFStringEncodingISOLatinGreek; + break ; + case wxFONTENCODING_ISO8859_8 : + enc = kCFStringEncodingISOLatinHebrew; + break ; + case wxFONTENCODING_ISO8859_9 : + enc = kCFStringEncodingISOLatin5; + break ; + case wxFONTENCODING_ISO8859_10 : + enc = kCFStringEncodingISOLatin6; + break ; + case wxFONTENCODING_ISO8859_11 : + enc = kCFStringEncodingISOLatinThai; + break ; + case wxFONTENCODING_ISO8859_13 : + enc = kCFStringEncodingISOLatin7; + break ; + case wxFONTENCODING_ISO8859_14 : + enc = kCFStringEncodingISOLatin8; + break ; + case wxFONTENCODING_ISO8859_15 : + enc = kCFStringEncodingISOLatin9; + break ; + + case wxFONTENCODING_KOI8 : + enc = kCFStringEncodingKOI8_R; + break ; + case wxFONTENCODING_ALTERNATIVE : // MS-DOS CP866 + enc = kCFStringEncodingDOSRussian; + break ; + +// case wxFONTENCODING_BULGARIAN : +// enc = ; +// break ; + + case wxFONTENCODING_CP437 : + enc = kCFStringEncodingDOSLatinUS ; + break ; + case wxFONTENCODING_CP850 : + enc = kCFStringEncodingDOSLatin1; + break ; + case wxFONTENCODING_CP852 : + enc = kCFStringEncodingDOSLatin2; + break ; + case wxFONTENCODING_CP855 : + enc = kCFStringEncodingDOSCyrillic; + break ; + case wxFONTENCODING_CP866 : + enc = kCFStringEncodingDOSRussian ; + break ; + case wxFONTENCODING_CP874 : + enc = kCFStringEncodingDOSThai; + break ; + case wxFONTENCODING_CP932 : + enc = kCFStringEncodingDOSJapanese; + break ; + case wxFONTENCODING_CP936 : + enc = kCFStringEncodingDOSChineseSimplif ; + break ; + case wxFONTENCODING_CP949 : + enc = kCFStringEncodingDOSKorean; + break ; + case wxFONTENCODING_CP950 : + enc = kCFStringEncodingDOSChineseTrad; + break ; + case wxFONTENCODING_CP1250 : + enc = kCFStringEncodingWindowsLatin2; + break ; + case wxFONTENCODING_CP1251 : + enc = kCFStringEncodingWindowsCyrillic ; + break ; + case wxFONTENCODING_CP1252 : + enc = kCFStringEncodingWindowsLatin1 ; + break ; + case wxFONTENCODING_CP1253 : + enc = kCFStringEncodingWindowsGreek; + break ; + case wxFONTENCODING_CP1254 : + enc = kCFStringEncodingWindowsLatin5; + break ; + case wxFONTENCODING_CP1255 : + enc = kCFStringEncodingWindowsHebrew ; + break ; + case wxFONTENCODING_CP1256 : + enc = kCFStringEncodingWindowsArabic ; + break ; + case wxFONTENCODING_CP1257 : + enc = kCFStringEncodingWindowsBalticRim; + break ; +// This only really encodes to UTF7 (if that) evidently +// case wxFONTENCODING_UTF7 : +// enc = kCFStringEncodingNonLossyASCII ; +// break ; + case wxFONTENCODING_UTF8 : + enc = kCFStringEncodingUTF8 ; + break ; + case wxFONTENCODING_EUC_JP : + enc = kCFStringEncodingEUC_JP; + break ; + case wxFONTENCODING_UTF16 : + enc = kCFStringEncodingUnicode ; + break ; + case wxFONTENCODING_MACROMAN : + enc = kCFStringEncodingMacRoman ; + break ; + case wxFONTENCODING_MACJAPANESE : + enc = kCFStringEncodingMacJapanese ; + break ; + case wxFONTENCODING_MACCHINESETRAD : + enc = kCFStringEncodingMacChineseTrad ; + break ; + case wxFONTENCODING_MACKOREAN : + enc = kCFStringEncodingMacKorean ; + break ; + case wxFONTENCODING_MACARABIC : + enc = kCFStringEncodingMacArabic ; + break ; + case wxFONTENCODING_MACHEBREW : + enc = kCFStringEncodingMacHebrew ; + break ; + case wxFONTENCODING_MACGREEK : + enc = kCFStringEncodingMacGreek ; + break ; + case wxFONTENCODING_MACCYRILLIC : + enc = kCFStringEncodingMacCyrillic ; + break ; + case wxFONTENCODING_MACDEVANAGARI : + enc = kCFStringEncodingMacDevanagari ; + break ; + case wxFONTENCODING_MACGURMUKHI : + enc = kCFStringEncodingMacGurmukhi ; + break ; + case wxFONTENCODING_MACGUJARATI : + enc = kCFStringEncodingMacGujarati ; + break ; + case wxFONTENCODING_MACORIYA : + enc = kCFStringEncodingMacOriya ; + break ; + case wxFONTENCODING_MACBENGALI : + enc = kCFStringEncodingMacBengali ; + break ; + case wxFONTENCODING_MACTAMIL : + enc = kCFStringEncodingMacTamil ; + break ; + case wxFONTENCODING_MACTELUGU : + enc = kCFStringEncodingMacTelugu ; + break ; + case wxFONTENCODING_MACKANNADA : + enc = kCFStringEncodingMacKannada ; + break ; + case wxFONTENCODING_MACMALAJALAM : + enc = kCFStringEncodingMacMalayalam ; + break ; + case wxFONTENCODING_MACSINHALESE : + enc = kCFStringEncodingMacSinhalese ; + break ; + case wxFONTENCODING_MACBURMESE : + enc = kCFStringEncodingMacBurmese ; + break ; + case wxFONTENCODING_MACKHMER : + enc = kCFStringEncodingMacKhmer ; + break ; + case wxFONTENCODING_MACTHAI : + enc = kCFStringEncodingMacThai ; + break ; + case wxFONTENCODING_MACLAOTIAN : + enc = kCFStringEncodingMacLaotian ; + break ; + case wxFONTENCODING_MACGEORGIAN : + enc = kCFStringEncodingMacGeorgian ; + break ; + case wxFONTENCODING_MACARMENIAN : + enc = kCFStringEncodingMacArmenian ; + break ; + case wxFONTENCODING_MACCHINESESIMP : + enc = kCFStringEncodingMacChineseSimp ; + break ; + case wxFONTENCODING_MACTIBETAN : + enc = kCFStringEncodingMacTibetan ; + break ; + case wxFONTENCODING_MACMONGOLIAN : + enc = kCFStringEncodingMacMongolian ; + break ; + case wxFONTENCODING_MACETHIOPIC : + enc = kCFStringEncodingMacEthiopic ; + break ; + case wxFONTENCODING_MACCENTRALEUR : + enc = kCFStringEncodingMacCentralEurRoman ; + break ; + case wxFONTENCODING_MACVIATNAMESE : + enc = kCFStringEncodingMacVietnamese ; + break ; + case wxFONTENCODING_MACARABICEXT : + enc = kCFStringEncodingMacExtArabic ; + break ; + case wxFONTENCODING_MACSYMBOL : + enc = kCFStringEncodingMacSymbol ; + break ; + case wxFONTENCODING_MACDINGBATS : + enc = kCFStringEncodingMacDingbats ; + break ; + case wxFONTENCODING_MACTURKISH : + enc = kCFStringEncodingMacTurkish ; + break ; + case wxFONTENCODING_MACCROATIAN : + enc = kCFStringEncodingMacCroatian ; + break ; + case wxFONTENCODING_MACICELANDIC : + enc = kCFStringEncodingMacIcelandic ; + break ; + case wxFONTENCODING_MACROMANIAN : + enc = kCFStringEncodingMacRomanian ; + break ; + case wxFONTENCODING_MACCELTIC : + enc = kCFStringEncodingMacCeltic ; + break ; + case wxFONTENCODING_MACGAELIC : + enc = kCFStringEncodingMacGaelic ; + break ; +// case wxFONTENCODING_MACKEYBOARD : +// enc = kCFStringEncodingMacKeyboardGlyphs ; +// break ; + + default : + // because gcc is picky + break ; + } + + return enc ; +} + +class wxMBConv_cocoa : public wxMBConv +{ +public: + wxMBConv_cocoa() + { + Init(CFStringGetSystemEncoding()) ; + } + + wxMBConv_cocoa(const wxMBConv_cocoa& conv) + { + m_encoding = conv.m_encoding; + } + +#if wxUSE_FONTMAP + wxMBConv_cocoa(const wxChar* name) + { + Init( wxCFStringEncFromFontEnc(wxFontMapperBase::Get()->CharsetToEncoding(name, false) ) ) ; + } +#endif + + wxMBConv_cocoa(wxFontEncoding encoding) + { + Init( wxCFStringEncFromFontEnc(encoding) ); + } + + virtual ~wxMBConv_cocoa() + { + } + + void Init( CFStringEncoding encoding) + { + m_encoding = encoding ; + } + + size_t MB2WC(wchar_t * szOut, const char * szUnConv, size_t nOutSize) const + { + wxASSERT(szUnConv); + + CFStringRef theString = CFStringCreateWithBytes ( + NULL, //the allocator + (const UInt8*)szUnConv, + strlen(szUnConv), + m_encoding, + false //no BOM/external representation + ); + + wxASSERT(theString); + + size_t nOutLength = CFStringGetLength(theString); + + if (szOut == NULL) + { + CFRelease(theString); + return nOutLength; + } + + CFRange theRange = { 0, nOutSize }; + +#if SIZEOF_WCHAR_T == 4 + UniChar* szUniCharBuffer = new UniChar[nOutSize]; +#endif + + CFStringGetCharacters(theString, theRange, szUniCharBuffer); + + CFRelease(theString); + + szUniCharBuffer[nOutLength] = '\0'; + +#if SIZEOF_WCHAR_T == 4 + wxMBConvUTF16 converter; + converter.MB2WC( szOut, (const char*)szUniCharBuffer, nOutSize ); + delete [] szUniCharBuffer; +#endif + + return nOutLength; + } + + size_t WC2MB(char *szOut, const wchar_t *szUnConv, size_t nOutSize) const + { + wxASSERT(szUnConv); + + size_t nRealOutSize; + size_t nBufSize = wxWcslen(szUnConv); + UniChar* szUniBuffer = (UniChar*) szUnConv; + +#if SIZEOF_WCHAR_T == 4 + wxMBConvUTF16 converter ; + nBufSize = converter.WC2MB( NULL, szUnConv, 0 ); + szUniBuffer = new UniChar[ (nBufSize / sizeof(UniChar)) + 1]; + converter.WC2MB( (char*) szUniBuffer, szUnConv, nBufSize + sizeof(UniChar)); + nBufSize /= sizeof(UniChar); +#endif + + CFStringRef theString = CFStringCreateWithCharactersNoCopy( + NULL, //allocator + szUniBuffer, + nBufSize, + kCFAllocatorNull //deallocator - we want to deallocate it ourselves + ); + + wxASSERT(theString); + + //Note that CER puts a BOM when converting to unicode + //so we check and use getchars instead in that case + if (m_encoding == kCFStringEncodingUnicode) + { + if (szOut != NULL) + CFStringGetCharacters(theString, CFRangeMake(0, nOutSize - 1), (UniChar*) szOut); + + nRealOutSize = CFStringGetLength(theString) + 1; + } + else + { + CFStringGetBytes( + theString, + CFRangeMake(0, CFStringGetLength(theString)), + m_encoding, + 0, //what to put in characters that can't be converted - + //0 tells CFString to return NULL if it meets such a character + false, //not an external representation + (UInt8*) szOut, + nOutSize, + (CFIndex*) &nRealOutSize + ); + } + + CFRelease(theString); + +#if SIZEOF_WCHAR_T == 4 + delete[] szUniBuffer; +#endif + + return nRealOutSize - 1; + } + + virtual wxMBConv *Clone() const { return new wxMBConv_cocoa(*this); } + + bool IsOk() const + { + return m_encoding != kCFStringEncodingInvalidId && + CFStringIsEncodingAvailable(m_encoding); + } + +private: + CFStringEncoding m_encoding ; +}; + +#endif // defined(__WXCOCOA__) + +// ============================================================================ +// Mac conversion classes +// ============================================================================ + +#if defined(__WXMAC__) && defined(TARGET_CARBON) + +class wxMBConv_mac : public wxMBConv +{ +public: + wxMBConv_mac() + { + Init(CFStringGetSystemEncoding()) ; + } + + wxMBConv_mac(const wxMBConv_mac& conv) + { + Init(conv.m_char_encoding); + } + +#if wxUSE_FONTMAP + wxMBConv_mac(const wxChar* name) + { + wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false); + Init( (enc != wxFONTENCODING_SYSTEM) ? wxMacGetSystemEncFromFontEnc( enc ) : kTextEncodingUnknown); + } +#endif + + wxMBConv_mac(wxFontEncoding encoding) + { + Init( wxMacGetSystemEncFromFontEnc(encoding) ); + } + + virtual ~wxMBConv_mac() + { + OSStatus status = noErr ; + if (m_MB2WC_converter) + status = TECDisposeConverter(m_MB2WC_converter); + if (m_WC2MB_converter) + status = TECDisposeConverter(m_WC2MB_converter); + } + + void Init( TextEncodingBase encoding,TextEncodingVariant encodingVariant = kTextEncodingDefaultVariant , + TextEncodingFormat encodingFormat = kTextEncodingDefaultFormat) + { + m_MB2WC_converter = NULL ; + m_WC2MB_converter = NULL ; + if ( encoding != kTextEncodingUnknown ) + { + m_char_encoding = CreateTextEncoding(encoding, encodingVariant, encodingFormat) ; + m_unicode_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault, 0, kUnicode16BitFormat) ; + } + else + { + m_char_encoding = kTextEncodingUnknown; + m_unicode_encoding = kTextEncodingUnknown; + } + } + + virtual void CreateIfNeeded() const + { + if ( m_MB2WC_converter == NULL && m_WC2MB_converter == NULL && + m_char_encoding != kTextEncodingUnknown && m_unicode_encoding != kTextEncodingUnknown ) + { + OSStatus status = noErr ; + status = TECCreateConverter(&m_MB2WC_converter, + m_char_encoding, + m_unicode_encoding); + wxASSERT_MSG( status == noErr , _("Unable to create TextEncodingConverter")) ; + status = TECCreateConverter(&m_WC2MB_converter, + m_unicode_encoding, + m_char_encoding); + wxASSERT_MSG( status == noErr , _("Unable to create TextEncodingConverter")) ; + } + } + + size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const + { + CreateIfNeeded() ; + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = strlen(psz) + 1; + wchar_t *tbuf = NULL ; + UniChar* ubuf = NULL ; + size_t res = 0 ; + + if (buf == NULL) + { + // Apple specs say at least 32 + n = wxMax( 32, byteInLen ) ; + tbuf = (wchar_t*) malloc( n * SIZEOF_WCHAR_T ) ; + } + + ByteCount byteBufferLen = n * sizeof( UniChar ) ; + +#if SIZEOF_WCHAR_T == 4 + ubuf = (UniChar*) malloc( byteBufferLen + 2 ) ; +#else + ubuf = (UniChar*) (buf ? buf : tbuf) ; +#endif + { +#if wxUSE_THREADS + wxMutexLocker lock( m_MB2WC_guard ); +#endif + status = TECConvertText( + m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen, + (TextPtr) ubuf, byteBufferLen, &byteOutLen); + } + +#if SIZEOF_WCHAR_T == 4 + // we have to terminate here, because n might be larger for the trailing zero, and if UniChar + // is not properly terminated we get random characters at the end + ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ; + wxMBConvUTF16 converter ; + res = converter.MB2WC( (buf ? buf : tbuf), (const char*)ubuf, n ) ; + free( ubuf ) ; +#else + res = byteOutLen / sizeof( UniChar ) ; +#endif + + if ( buf == NULL ) + free(tbuf) ; + + if ( buf && res < n) + buf[res] = 0; + + return res ; + } + + size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const + { + CreateIfNeeded() ; + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = wxWcslen(psz) * SIZEOF_WCHAR_T ; + + char *tbuf = NULL ; + + if (buf == NULL) + { + // Apple specs say at least 32 + n = wxMax( 32, ((byteInLen / SIZEOF_WCHAR_T) * 8) + SIZEOF_WCHAR_T ); + tbuf = (char*) malloc( n ) ; + } + + ByteCount byteBufferLen = n ; + UniChar* ubuf = NULL ; + +#if SIZEOF_WCHAR_T == 4 + wxMBConvUTF16 converter ; + size_t unicharlen = converter.WC2MB( NULL, psz, 0 ) ; + byteInLen = unicharlen ; + ubuf = (UniChar*) malloc( byteInLen + 2 ) ; + converter.WC2MB( (char*) ubuf, psz, unicharlen + 2 ) ; +#else + ubuf = (UniChar*) psz ; +#endif + + { +#if wxUSE_THREADS + wxMutexLocker lock( m_WC2MB_guard ); +#endif + status = TECConvertText( + m_WC2MB_converter, (ConstTextPtr) ubuf, byteInLen, &byteInLen, + (TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen); + } + +#if SIZEOF_WCHAR_T == 4 + free( ubuf ) ; +#endif + + if ( buf == NULL ) + free(tbuf) ; + + size_t res = byteOutLen ; + if ( buf && res < n) + { + buf[res] = 0; + + //we need to double-trip to verify it didn't insert any ? in place + //of bogus characters + wxWCharBuffer wcBuf(n); + size_t pszlen = wxWcslen(psz); + if ( MB2WC(wcBuf.data(), buf, n) == wxCONV_FAILED || + wxWcslen(wcBuf) != pszlen || + memcmp(wcBuf, psz, pszlen * sizeof(wchar_t)) != 0 ) + { + // we didn't obtain the same thing we started from, hence + // the conversion was lossy and we consider that it failed + return wxCONV_FAILED; + } + } + + return res ; + } + + virtual wxMBConv *Clone() const { return new wxMBConv_mac(*this); } + + bool IsOk() const + { + CreateIfNeeded() ; + return m_MB2WC_converter != NULL && m_WC2MB_converter != NULL; + } + +protected : + mutable TECObjectRef m_MB2WC_converter; + mutable TECObjectRef m_WC2MB_converter; +#if wxUSE_THREADS + mutable wxMutex m_MB2WC_guard; + mutable wxMutex m_WC2MB_guard; +#endif + + TextEncodingBase m_char_encoding; + TextEncodingBase m_unicode_encoding; +}; + +// MB is decomposed (D) normalized UTF8 + +class wxMBConv_macUTF8D : public wxMBConv_mac +{ +public : + wxMBConv_macUTF8D() + { + Init( kTextEncodingUnicodeDefault , kUnicodeNoSubset , kUnicodeUTF8Format ) ; + m_uni = NULL; + m_uniBack = NULL ; + } + + virtual ~wxMBConv_macUTF8D() + { + if (m_uni!=NULL) + DisposeUnicodeToTextInfo(&m_uni); + if (m_uniBack!=NULL) + DisposeUnicodeToTextInfo(&m_uniBack); + } + + size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const + { + CreateIfNeeded() ; + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = wxWcslen(psz) * SIZEOF_WCHAR_T ; + + char *tbuf = NULL ; + + if (buf == NULL) + { + // Apple specs say at least 32 + n = wxMax( 32, ((byteInLen / SIZEOF_WCHAR_T) * 8) + SIZEOF_WCHAR_T ); + tbuf = (char*) malloc( n ) ; + } + + ByteCount byteBufferLen = n ; + UniChar* ubuf = NULL ; + +#if SIZEOF_WCHAR_T == 4 + wxMBConvUTF16 converter ; + size_t unicharlen = converter.WC2MB( NULL, psz, 0 ) ; + byteInLen = unicharlen ; + ubuf = (UniChar*) malloc( byteInLen + 2 ) ; + converter.WC2MB( (char*) ubuf, psz, unicharlen + 2 ) ; +#else + ubuf = (UniChar*) psz ; +#endif + + // ubuf is a non-decomposed UniChar buffer + + ByteCount dcubuflen = byteInLen * 2 + 2 ; + ByteCount dcubufread , dcubufwritten ; + UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ; + + { +#if wxUSE_THREADS + wxMutexLocker lock( m_WC2MB_guard ); +#endif + ConvertFromUnicodeToText( m_uni , byteInLen , ubuf , + kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , dcubuf ) ; + + // we now convert that decomposed buffer into UTF8 + + status = TECConvertText( + m_WC2MB_converter, (ConstTextPtr) dcubuf, dcubufwritten, &dcubufread, + (TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen); + } + + free( dcubuf ); + +#if SIZEOF_WCHAR_T == 4 + free( ubuf ) ; +#endif + + if ( buf == NULL ) + free(tbuf) ; + + size_t res = byteOutLen ; + if ( buf && res < n) + { + buf[res] = 0; + // don't test for round-trip fidelity yet, we cannot guarantee it yet + } + + return res ; + } + + size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const + { + CreateIfNeeded() ; + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = strlen(psz) + 1; + wchar_t *tbuf = NULL ; + UniChar* ubuf = NULL ; + size_t res = 0 ; + + if (buf == NULL) + { + // Apple specs say at least 32 + n = wxMax( 32, byteInLen ) ; + tbuf = (wchar_t*) malloc( n * SIZEOF_WCHAR_T ) ; + } + + ByteCount byteBufferLen = n * sizeof( UniChar ) ; + +#if SIZEOF_WCHAR_T == 4 + ubuf = (UniChar*) malloc( byteBufferLen + 2 ) ; +#else + ubuf = (UniChar*) (buf ? buf : tbuf) ; +#endif + + ByteCount dcubuflen = byteBufferLen * 2 + 2 ; + ByteCount dcubufread , dcubufwritten ; + UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ; + + { +#if wxUSE_THREADS + wxMutexLocker lock( m_MB2WC_guard ); +#endif + status = TECConvertText( + m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen, + (TextPtr) dcubuf, dcubuflen, &byteOutLen); + // we have to terminate here, because n might be larger for the trailing zero, and if UniChar + // is not properly terminated we get random characters at the end + dcubuf[byteOutLen / sizeof( UniChar ) ] = 0 ; + + // now from the decomposed UniChar to properly composed uniChar + ConvertFromUnicodeToText( m_uniBack , byteOutLen , dcubuf , + kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , ubuf ) ; + } + + free( dcubuf ); + byteOutLen = dcubufwritten ; + ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ; + + +#if SIZEOF_WCHAR_T == 4 + wxMBConvUTF16 converter ; + res = converter.MB2WC( (buf ? buf : tbuf), (const char*)ubuf, n ) ; + free( ubuf ) ; +#else + res = byteOutLen / sizeof( UniChar ) ; +#endif + + if ( buf == NULL ) + free(tbuf) ; + + if ( buf && res < n) + buf[res] = 0; + + return res ; + } + + virtual void CreateIfNeeded() const + { + wxMBConv_mac::CreateIfNeeded() ; + if ( m_uni == NULL ) + { + m_map.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kUnicodeNoSubset, kTextEncodingDefaultFormat); + m_map.otherEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kUnicodeCanonicalDecompVariant, kTextEncodingDefaultFormat); + m_map.mappingVersion = kUnicodeUseLatestMapping; + + OSStatus err = CreateUnicodeToTextInfo(&m_map, &m_uni); + wxASSERT_MSG( err == noErr , _(" Couldn't create the UnicodeConverter")) ; + + m_map.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kUnicodeNoSubset, kTextEncodingDefaultFormat); + m_map.otherEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kUnicodeCanonicalCompVariant, kTextEncodingDefaultFormat); + m_map.mappingVersion = kUnicodeUseLatestMapping; + err = CreateUnicodeToTextInfo(&m_map, &m_uniBack); + wxASSERT_MSG( err == noErr , _(" Couldn't create the UnicodeConverter")) ; + } + } +protected : + mutable UnicodeToTextInfo m_uni; + mutable UnicodeToTextInfo m_uniBack; + mutable UnicodeMapping m_map; +}; +#endif // defined(__WXMAC__) && defined(TARGET_CARBON) // ============================================================================ // wxEncodingConverter based conversion classes @@ -2864,17 +3124,14 @@ class wxMBConv_wxwin : public wxMBConv private: void Init() { - // Refuse to use broken wxEncodingConverter code for Mac-specific encodings. - // The wxMBConv_cf class does a better job. - m_ok = (m_enc < wxFONTENCODING_MACMIN || m_enc > wxFONTENCODING_MACMAX) && - m2w.Init(m_enc, wxFONTENCODING_UNICODE) && + m_ok = m2w.Init(m_enc, wxFONTENCODING_UNICODE) && w2m.Init(wxFONTENCODING_UNICODE, m_enc); } public: // temporarily just use wxEncodingConverter stuff, // so that it works while a better implementation is built - wxMBConv_wxwin(const char* name) + wxMBConv_wxwin(const wxChar* name) { if (name) m_enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false); @@ -2943,11 +3200,11 @@ private: // were we initialized successfully? bool m_ok; - wxDECLARE_NO_COPY_CLASS(wxMBConv_wxwin); + DECLARE_NO_COPY_CLASS(wxMBConv_wxwin) }; // make the constructors available for unit testing -WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name ) +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name ) { wxMBConv_wxwin* result = new wxMBConv_wxwin( name ); if ( !result->IsOk() ) @@ -2969,75 +3226,47 @@ void wxCSConv::Init() { m_name = NULL; m_convReal = NULL; + m_deferred = true; } -void wxCSConv::SetEncoding(wxFontEncoding encoding) -{ - switch ( encoding ) - { - case wxFONTENCODING_MAX: - case wxFONTENCODING_SYSTEM: - if ( m_name ) - { - // It's ok to not have encoding value if we have a name for it. - m_encoding = wxFONTENCODING_SYSTEM; - } - else // No name neither. - { - // Fall back to the system default encoding in this case (not - // sure how much sense does this make but this is how the old - // code used to behave). -#if wxUSE_INTL - m_encoding = wxLocale::GetSystemEncoding(); - if ( m_encoding == wxFONTENCODING_SYSTEM ) -#endif // wxUSE_INTL - m_encoding = wxFONTENCODING_ISO8859_1; - } - break; - - case wxFONTENCODING_DEFAULT: - // wxFONTENCODING_DEFAULT is same as US-ASCII in this context - m_encoding = wxFONTENCODING_ISO8859_1; - break; - - default: - // Just use the provided encoding. - m_encoding = encoding; - } -} - -wxCSConv::wxCSConv(const wxString& charset) +wxCSConv::wxCSConv(const wxChar *charset) { Init(); - if ( !charset.empty() ) + if ( charset ) { - SetName(charset.ToAscii()); + SetName(charset); } #if wxUSE_FONTMAP - SetEncoding(wxFontMapperBase::GetEncodingFromName(charset)); + m_encoding = wxFontMapperBase::GetEncodingFromName(charset); + if ( m_encoding == wxFONTENCODING_MAX ) + { + // set to unknown/invalid value + m_encoding = wxFONTENCODING_SYSTEM; + } + else if ( m_encoding == wxFONTENCODING_DEFAULT ) + { + // wxFONTENCODING_DEFAULT is same as US-ASCII in this context + m_encoding = wxFONTENCODING_ISO8859_1; + } #else - SetEncoding(wxFONTENCODING_SYSTEM); + m_encoding = wxFONTENCODING_SYSTEM; #endif - - m_convReal = DoCreate(); } wxCSConv::wxCSConv(wxFontEncoding encoding) { if ( encoding == wxFONTENCODING_MAX || encoding == wxFONTENCODING_DEFAULT ) { - wxFAIL_MSG( wxT("invalid encoding value in wxCSConv ctor") ); + wxFAIL_MSG( _T("invalid encoding value in wxCSConv ctor") ); encoding = wxFONTENCODING_SYSTEM; } Init(); - SetEncoding(encoding); - - m_convReal = DoCreate(); + m_encoding = encoding; } wxCSConv::~wxCSConv() @@ -3051,9 +3280,7 @@ wxCSConv::wxCSConv(const wxCSConv& conv) Init(); SetName(conv.m_name); - SetEncoding(conv.m_encoding); - - m_convReal = DoCreate(); + m_encoding = conv.m_encoding; } wxCSConv& wxCSConv::operator=(const wxCSConv& conv) @@ -3061,9 +3288,7 @@ wxCSConv& wxCSConv::operator=(const wxCSConv& conv) Clear(); SetName(conv.m_name); - SetEncoding(conv.m_encoding); - - m_convReal = DoCreate(); + m_encoding = conv.m_encoding; return *this; } @@ -3071,15 +3296,19 @@ wxCSConv& wxCSConv::operator=(const wxCSConv& conv) void wxCSConv::Clear() { free(m_name); - m_name = NULL; + delete m_convReal; - wxDELETE(m_convReal); + m_name = NULL; + m_convReal = NULL; } -void wxCSConv::SetName(const char *charset) +void wxCSConv::SetName(const wxChar *charset) { - if ( charset ) + if (charset) + { m_name = wxStrdup(charset); + m_deferred = true; + } } #if wxUSE_FONTMAP @@ -3096,13 +3325,14 @@ wxMBConv *wxCSConv::DoCreate() const wxLogTrace(TRACE_STRCONV, wxT("creating conversion for %s"), (m_name ? m_name - : (const char*)wxFontMapperBase::GetEncodingName(m_encoding).mb_str())); + : wxFontMapperBase::GetEncodingName(m_encoding).c_str())); #endif // wxUSE_FONTMAP // check for the special case of ASCII or ISO8859-1 charset: as we have // special knowledge of it anyhow, we don't need to create a special // conversion object - if ( m_encoding == wxFONTENCODING_ISO8859_1 ) + if ( m_encoding == wxFONTENCODING_ISO8859_1 || + m_encoding == wxFONTENCODING_DEFAULT ) { // don't convert at all return NULL; @@ -3122,13 +3352,14 @@ wxMBConv *wxCSConv::DoCreate() const if ( m_name ) #endif // !wxUSE_FONTMAP { + wxString name(m_name); #if wxUSE_FONTMAP wxFontEncoding encoding(m_encoding); #endif - if ( m_name ) + if ( !name.empty() ) { - wxMBConv_iconv *conv = new wxMBConv_iconv(m_name); + wxMBConv_iconv *conv = new wxMBConv_iconv(name); if ( conv->IsOk() ) return conv; @@ -3136,7 +3367,7 @@ wxMBConv *wxCSConv::DoCreate() const #if wxUSE_FONTMAP encoding = - wxFontMapperBase::Get()->CharsetToEncoding(m_name, false); + wxFontMapperBase::Get()->CharsetToEncoding(name, false); #endif // wxUSE_FONTMAP } #if wxUSE_FONTMAP @@ -3147,27 +3378,23 @@ wxMBConv *wxCSConv::DoCreate() const if ( it->second.empty() ) return NULL; - wxMBConv_iconv *conv = new wxMBConv_iconv(it->second.ToAscii()); + wxMBConv_iconv *conv = new wxMBConv_iconv(it->second); if ( conv->IsOk() ) return conv; delete conv; } - const wxChar* const* names = wxFontMapperBase::GetAllEncodingNames(encoding); - // CS : in case this does not return valid names (eg for MacRoman) - // encoding got a 'failure' entry in the cache all the same, - // although it just has to be created using a different method, so - // only store failed iconv creation attempts (or perhaps we - // shoulnd't do this at all ?) + const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding); + // CS : in case this does not return valid names (eg for MacRoman) encoding + // got a 'failure' entry in the cache all the same, although it just has to + // be created using a different method, so only store failed iconv creation + // attempts (or perhaps we shoulnd't do this at all ?) if ( names[0] != NULL ) { for ( ; *names; ++names ) { - // FIXME-UTF8: wxFontMapperBase::GetAllEncodingNames() - // will need changes that will obsolete this - wxString name(*names); - wxMBConv_iconv *conv = new wxMBConv_iconv(name.ToAscii()); + wxMBConv_iconv *conv = new wxMBConv_iconv(*names); if ( conv->IsOk() ) { gs_nameCache[encoding] = *names; @@ -3177,7 +3404,7 @@ wxMBConv *wxCSConv::DoCreate() const delete conv; } - gs_nameCache[encoding] = wxT(""); // cache the failure + gs_nameCache[encoding] = _T(""); // cache the failure } } #endif // wxUSE_FONTMAP @@ -3199,17 +3426,35 @@ wxMBConv *wxCSConv::DoCreate() const } #endif // wxHAVE_WIN32_MB2WC -#ifdef __DARWIN__ +#if defined(__WXMAC__) { // leave UTF16 and UTF32 to the built-ins of wx if ( m_name || ( m_encoding < wxFONTENCODING_UTF16BE || ( m_encoding >= wxFONTENCODING_MACMIN && m_encoding <= wxFONTENCODING_MACMAX ) ) ) { #if wxUSE_FONTMAP - wxMBConv_cf *conv = m_name ? new wxMBConv_cf(m_name) - : new wxMBConv_cf(m_encoding); + wxMBConv_mac *conv = m_name ? new wxMBConv_mac(m_name) + : new wxMBConv_mac(m_encoding); #else - wxMBConv_cf *conv = new wxMBConv_cf(m_encoding); + wxMBConv_mac *conv = new wxMBConv_mac(m_encoding); +#endif + if ( conv->IsOk() ) + return conv; + + delete conv; + } + } +#endif + +#if defined(__WXCOCOA__) + { + if ( m_name || ( m_encoding <= wxFONTENCODING_UTF16 ) ) + { +#if wxUSE_FONTMAP + wxMBConv_cocoa *conv = m_name ? new wxMBConv_cocoa(m_name) + : new wxMBConv_cocoa(m_encoding); +#else + wxMBConv_cocoa *conv = new wxMBConv_cocoa(m_encoding); #endif if ( conv->IsOk() ) @@ -3218,8 +3463,7 @@ wxMBConv *wxCSConv::DoCreate() const delete conv; } } -#endif // __DARWIN__ - +#endif // step (2) wxFontEncoding enc = m_encoding; #if wxUSE_FONTMAP @@ -3267,18 +3511,62 @@ wxMBConv *wxCSConv::DoCreate() const delete conv; } - - wxLogTrace(TRACE_STRCONV, - wxT("encoding \"%s\" is not supported by this system"), - (m_name ? wxString(m_name) - : wxFontMapperBase::GetEncodingName(m_encoding))); #endif // wxUSE_FONTMAP + // NB: This is a hack to prevent deadlock. What could otherwise happen + // in Unicode build: wxConvLocal creation ends up being here + // because of some failure and logs the error. But wxLog will try to + // attach a timestamp, for which it will need wxConvLocal (to convert + // time to char* and then wchar_t*), but that fails, tries to log the + // error, but wxLog has an (already locked) critical section that + // guards the static buffer. + static bool alreadyLoggingError = false; + if (!alreadyLoggingError) + { + alreadyLoggingError = true; + wxLogError(_("Cannot convert from the charset '%s'!"), + m_name ? m_name + : +#if wxUSE_FONTMAP + wxFontMapperBase::GetEncodingDescription(m_encoding).c_str() +#else // !wxUSE_FONTMAP + wxString::Format(_("encoding %i"), m_encoding).c_str() +#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP + ); + + alreadyLoggingError = false; + } + return NULL; } +void wxCSConv::CreateConvIfNeeded() const +{ + if ( m_deferred ) + { + wxCSConv *self = (wxCSConv *)this; // const_cast + + // if we don't have neither the name nor the encoding, use the default + // encoding for this system + if ( !m_name && m_encoding == wxFONTENCODING_SYSTEM ) + { +#if wxUSE_INTL + self->m_encoding = wxLocale::GetSystemEncoding(); +#else + // fallback to some reasonable default: + self->m_encoding = wxFONTENCODING_ISO8859_1; +#endif // wxUSE_INTL + } + + self->m_convReal = DoCreate(); + self->m_deferred = false; + } +} + bool wxCSConv::IsOk() const { + CreateConvIfNeeded(); + // special case: no convReal created for wxFONTENCODING_ISO8859_1 if ( m_encoding == wxFONTENCODING_ISO8859_1 ) return true; // always ok as we do it ourselves @@ -3291,6 +3579,8 @@ bool wxCSConv::IsOk() const size_t wxCSConv::ToWChar(wchar_t *dst, size_t dstLen, const char *src, size_t srcLen) const { + CreateConvIfNeeded(); + if (m_convReal) return m_convReal->ToWChar(dst, dstLen, src, srcLen); @@ -3313,6 +3603,8 @@ size_t wxCSConv::ToWChar(wchar_t *dst, size_t dstLen, size_t wxCSConv::FromWChar(char *dst, size_t dstLen, const wchar_t *src, size_t srcLen) const { + CreateConvIfNeeded(); + if (m_convReal) return m_convReal->FromWChar(dst, dstLen, src, srcLen); @@ -3346,26 +3638,66 @@ size_t wxCSConv::FromWChar(char *dst, size_t dstLen, return srcLen; } +size_t wxCSConv::MB2WC(wchar_t *buf, const char *psz, size_t n) const +{ + // this function exists only for ABI-compatibility in 2.8 branch + return wxMBConv::MB2WC(buf, psz, n); +} + +size_t wxCSConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const +{ + // this function exists only for ABI-compatibility in 2.8 branch + return wxMBConv::WC2MB(buf, psz, n); +} + size_t wxCSConv::GetMBNulLen() const { - if ( m_convReal ) - return m_convReal->GetMBNulLen(); + CreateConvIfNeeded(); + + if ( m_convReal ) + { + return m_convReal->GetMBNulLen(); + } - // otherwise, we are ISO-8859-1 return 1; } -#if wxUSE_UNICODE_UTF8 -bool wxCSConv::IsUTF8() const -{ - if ( m_convReal ) - return m_convReal->IsUTF8(); +// ---------------------------------------------------------------------------- +// globals +// ---------------------------------------------------------------------------- - // otherwise, we are ISO-8859-1 - return false; -} +#ifdef __WINDOWS__ + static wxMBConv_win32 wxConvLibcObj; +#elif defined(__WXMAC__) && !defined(__MACH__) + static wxMBConv_mac wxConvLibcObj ; +#else + static wxMBConvLibc wxConvLibcObj; #endif +static wxCSConv wxConvLocalObj(wxFONTENCODING_SYSTEM); +static wxCSConv wxConvISO8859_1Obj(wxFONTENCODING_ISO8859_1); +static wxMBConvUTF7 wxConvUTF7Obj; +static wxMBConvUTF8 wxConvUTF8Obj; +#if defined(__WXMAC__) && defined(TARGET_CARBON) +static wxMBConv_macUTF8D wxConvMacUTF8DObj; +#endif +WXDLLIMPEXP_DATA_BASE(wxMBConv&) wxConvLibc = wxConvLibcObj; +WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal = wxConvLocalObj; +WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvISO8859_1 = wxConvISO8859_1Obj; +WXDLLIMPEXP_DATA_BASE(wxMBConvUTF7&) wxConvUTF7 = wxConvUTF7Obj; +WXDLLIMPEXP_DATA_BASE(wxMBConvUTF8&) wxConvUTF8 = wxConvUTF8Obj; +WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent = &wxConvLibcObj; +WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI = &wxConvLocal; +WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = & +#ifdef __WXOSX__ +#if defined(__WXMAC__) && defined(TARGET_CARBON) + wxConvMacUTF8DObj; +#else + wxConvUTF8Obj; +#endif +#else // !__WXOSX__ + wxConvLibcObj; +#endif // __WXOSX__/!__WXOSX__ #if wxUSE_UNICODE @@ -3376,7 +3708,7 @@ wxWCharBuffer wxSafeConvertMB2WX(const char *s) wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s)); if ( !wbuf ) - wbuf = wxMBConvUTF8().cMB2WX(s); + wbuf = wxConvUTF8.cMB2WX(s); if ( !wbuf ) wbuf = wxConvISO8859_1.cMB2WX(s); @@ -3397,76 +3729,14 @@ wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) #endif // wxUSE_UNICODE -// ---------------------------------------------------------------------------- -// globals -// ---------------------------------------------------------------------------- +#else // !wxUSE_WCHAR_T -// NB: The reason why we create converted objects in this convoluted way, -// using a factory function instead of global variable, is that they -// may be used at static initialization time (some of them are used by -// wxString ctors and there may be a global wxString object). In other -// words, possibly _before_ the converter global object would be -// initialized. +// stand-ins in absence of wchar_t +WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, + wxConvISO8859_1, + wxConvLocal, + wxConvUTF8; -#undef wxConvLibc -#undef wxConvUTF8 -#undef wxConvUTF7 -#undef wxConvLocal -#undef wxConvISO8859_1 +WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent = NULL; -#define WX_DEFINE_GLOBAL_CONV2(klass, impl_klass, name, ctor_args) \ - WXDLLIMPEXP_DATA_BASE(klass*) name##Ptr = NULL; \ - WXDLLIMPEXP_BASE klass* wxGet_##name##Ptr() \ - { \ - static impl_klass name##Obj ctor_args; \ - return &name##Obj; \ - } \ - /* this ensures that all global converter objects are created */ \ - /* by the time static initialization is done, i.e. before any */ \ - /* thread is launched: */ \ - static klass* gs_##name##instance = wxGet_##name##Ptr() - -#define WX_DEFINE_GLOBAL_CONV(klass, name, ctor_args) \ - WX_DEFINE_GLOBAL_CONV2(klass, klass, name, ctor_args) - -#ifdef __INTELC__ - // disable warning "variable 'xxx' was declared but never referenced" - #pragma warning(disable: 177) -#endif // Intel C++ - -#ifdef __WINDOWS__ - WX_DEFINE_GLOBAL_CONV2(wxMBConv, wxMBConv_win32, wxConvLibc, wxEMPTY_PARAMETER_VALUE); -#elif 0 // defined(__WXOSX__) - WX_DEFINE_GLOBAL_CONV2(wxMBConv, wxMBConv_cf, wxConvLibc, (wxFONTENCODING_UTF8)); -#else - WX_DEFINE_GLOBAL_CONV2(wxMBConv, wxMBConvLibc, wxConvLibc, wxEMPTY_PARAMETER_VALUE); -#endif - -// NB: we can't use wxEMPTY_PARAMETER_VALUE as final argument here because it's -// passed to WX_DEFINE_GLOBAL_CONV2 after a macro expansion and so still -// provokes an error message about "not enough macro parameters"; and we -// can't use "()" here as the name##Obj declaration would be parsed as a -// function declaration then, so use a semicolon and live with an extra -// empty statement (and hope that no compilers warns about this) -WX_DEFINE_GLOBAL_CONV(wxMBConvStrictUTF8, wxConvUTF8, ;); -WX_DEFINE_GLOBAL_CONV(wxMBConvUTF7, wxConvUTF7, ;); - -WX_DEFINE_GLOBAL_CONV(wxCSConv, wxConvLocal, (wxFONTENCODING_SYSTEM)); -WX_DEFINE_GLOBAL_CONV(wxCSConv, wxConvISO8859_1, (wxFONTENCODING_ISO8859_1)); - -WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent = wxGet_wxConvLibcPtr(); -WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI = wxGet_wxConvLocalPtr(); - -#ifdef __DARWIN__ -// It is important to use this conversion object under Darwin as it ensures -// that Unicode strings are (re)composed correctly even though xnu kernel uses -// decomposed form internally (at least for the file names). -static wxMBConv_cf wxConvMacUTF8DObj(wxFONTENCODING_UTF8); -#endif - -WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = -#ifdef __DARWIN__ - &wxConvMacUTF8DObj; -#else // !__DARWIN__ - wxGet_wxConvLibcPtr(); -#endif // __DARWIN__/!__DARWIN__ +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T diff --git a/Source/3rd Party/wx/src/common/stream.cpp b/Source/3rd Party/wx/src/common/stream.cpp index 3dcf8a0c8..27a9a7cc8 100644 --- a/Source/3rd Party/wx/src/common/stream.cpp +++ b/Source/3rd Party/wx/src/common/stream.cpp @@ -5,6 +5,7 @@ // Modified by: VZ (23.11.00) to fix realloc()ing new[]ed memory, // general code review // Created: 11/07/98 +// RCS-ID: $Id: stream.cpp 51662 2008-02-11 20:23:29Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,7 +36,6 @@ #include #include "wx/datstrm.h" #include "wx/textfile.h" -#include "wx/scopeguard.h" // ---------------------------------------------------------------------------- // constants @@ -63,6 +63,7 @@ void wxStreamBuffer::InitBuffer() m_buffer_start = m_buffer_end = m_buffer_pos = NULL; + m_buffer_size = 0; // if we are going to allocate the buffer, we should free it later as well m_destroybuf = true; @@ -75,16 +76,6 @@ void wxStreamBuffer::Init() m_fixed = true; } -void wxStreamBuffer::InitWithStream(wxStreamBase& stream, BufMode mode) -{ - Init(); - - m_stream = &stream; - m_mode = mode; - - m_flushable = true; -} - wxStreamBuffer::wxStreamBuffer(BufMode mode) { Init(); @@ -95,16 +86,27 @@ wxStreamBuffer::wxStreamBuffer(BufMode mode) m_flushable = false; } +wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode) +{ + Init(); + + m_stream = &stream; + m_mode = mode; + + m_flushable = true; +} + wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer) { // doing this has big chances to lead to a crash when the source buffer is // destroyed (otherwise assume the caller knows what he does) wxASSERT_MSG( !buffer.m_destroybuf, - wxT("it's a bad idea to copy this buffer") ); + _T("it's a bad idea to copy this buffer") ); m_buffer_start = buffer.m_buffer_start; m_buffer_end = buffer.m_buffer_end; m_buffer_pos = buffer.m_buffer_pos; + m_buffer_size = buffer.m_buffer_size; m_fixed = buffer.m_fixed; m_flushable = buffer.m_flushable; m_stream = buffer.m_stream; @@ -154,6 +156,8 @@ void wxStreamBuffer::SetBufferIO(void *start, m_buffer_start = (char *)start; m_buffer_end = m_buffer_start + len; + m_buffer_size = len; + // if we own it, we free it m_destroybuf = takeOwnership; @@ -188,27 +192,6 @@ void wxStreamBuffer::ResetBuffer() : m_buffer_start; } -void wxStreamBuffer::Truncate() -{ - size_t new_size = m_buffer_pos - m_buffer_start; - if ( m_buffer_pos == m_buffer_end ) - return; - - if ( !new_size ) - { - FreeBuffer(); - InitBuffer(); - return; - } - - char *new_start = (char *)realloc(m_buffer_start, new_size); - wxCHECK_RET( new_size, wxT("shrinking buffer shouldn't fail") ); - - m_buffer_start = new_start; - m_buffer_end = m_buffer_start + new_size; - m_buffer_pos = m_buffer_end; -} - // fill the buffer with as much data as possible (only for read buffers) bool wxStreamBuffer::FillBuffer() { @@ -218,7 +201,7 @@ bool wxStreamBuffer::FillBuffer() if ( !inStream ) return false; - size_t count = inStream->OnSysRead(GetBufferStart(), GetBufferSize()); + size_t count = inStream->OnSysRead(m_buffer_start, m_buffer_size); if ( !count ) return false; @@ -231,7 +214,7 @@ bool wxStreamBuffer::FillBuffer() // write the buffer contents to the stream (only for write buffers) bool wxStreamBuffer::FlushBuffer() { - wxCHECK_MSG( m_flushable, false, wxT("can't flush this buffer") ); + wxCHECK_MSG( m_flushable, false, _T("can't flush this buffer") ); // FIXME: what is this check for? (VZ) if ( m_buffer_pos == m_buffer_start ) @@ -239,7 +222,7 @@ bool wxStreamBuffer::FlushBuffer() wxOutputStream *outStream = GetOutputStream(); - wxCHECK_MSG( outStream, false, wxT("should have a stream in wxStreamBuffer") ); + wxCHECK_MSG( outStream, false, _T("should have a stream in wxStreamBuffer") ); size_t current = m_buffer_pos - m_buffer_start; size_t count = outStream->OnSysWrite(m_buffer_start, current); @@ -288,26 +271,24 @@ void wxStreamBuffer::PutToBuffer(const void *buffer, size_t size) else // !m_fixed { // realloc the buffer to have enough space for the data - if ( m_buffer_pos + size > m_buffer_end ) + size_t delta = m_buffer_pos - m_buffer_start; + + char *startOld = m_buffer_start; + m_buffer_size += size; + m_buffer_start = (char *)realloc(m_buffer_start, m_buffer_size); + if ( !m_buffer_start ) { - size_t delta = m_buffer_pos - m_buffer_start; - size_t new_size = delta + size; + // don't leak memory if realloc() failed + m_buffer_start = startOld; + m_buffer_size -= size; - char *startOld = m_buffer_start; - m_buffer_start = (char *)realloc(m_buffer_start, new_size); - if ( !m_buffer_start ) - { - // don't leak memory if realloc() failed - m_buffer_start = startOld; + // what else can we do? + return; + } - // what else can we do? - return; - } - - // adjust the pointers invalidated by realloc() - m_buffer_pos = m_buffer_start + delta; - m_buffer_end = m_buffer_start + new_size; - } // else: the buffer is big enough + // adjust the pointers invalidated by realloc() + m_buffer_pos = m_buffer_start + delta; + m_buffer_end = m_buffer_start + m_buffer_size; } } @@ -319,7 +300,7 @@ void wxStreamBuffer::PutChar(char c) { wxOutputStream *outStream = GetOutputStream(); - wxCHECK_RET( outStream, wxT("should have a stream in wxStreamBuffer") ); + wxCHECK_RET( outStream, _T("should have a stream in wxStreamBuffer") ); // if we don't have buffer at all, just forward this call to the stream, if ( !HasBuffer() ) @@ -345,7 +326,7 @@ void wxStreamBuffer::PutChar(char c) char wxStreamBuffer::Peek() { wxCHECK_MSG( m_stream && HasBuffer(), 0, - wxT("should have the stream and the buffer in wxStreamBuffer") ); + _T("should have the stream and the buffer in wxStreamBuffer") ); if ( !GetDataLeft() ) { @@ -364,7 +345,7 @@ char wxStreamBuffer::GetChar() { wxInputStream *inStream = GetInputStream(); - wxCHECK_MSG( inStream, 0, wxT("should have a stream in wxStreamBuffer") ); + wxCHECK_MSG( inStream, 0, _T("should have a stream in wxStreamBuffer") ); char c; if ( !HasBuffer() ) @@ -390,7 +371,7 @@ char wxStreamBuffer::GetChar() size_t wxStreamBuffer::Read(void *buffer, size_t size) { - wxASSERT_MSG( buffer, wxT("Warning: Null pointer is about to be used") ); + wxASSERT_MSG( buffer, _T("Warning: Null pointer is about to be used") ); /* Clear buffer first */ memset(buffer, 0x00, size); @@ -404,7 +385,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size) { wxInputStream *inStream = GetInputStream(); - wxCHECK_MSG( inStream, 0, wxT("should have a stream in wxStreamBuffer") ); + wxCHECK_MSG( inStream, 0, _T("should have a stream in wxStreamBuffer") ); readBytes = inStream->OnSysRead(buffer, size); } @@ -449,7 +430,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size) // this should really be called "Copy()" size_t wxStreamBuffer::Read(wxStreamBuffer *dbuf) { - wxCHECK_MSG( m_mode != write, 0, wxT("can't read from this buffer") ); + wxCHECK_MSG( m_mode != write, 0, _T("can't read from this buffer") ); char buf[BUF_TEMP_SIZE]; size_t nRead, @@ -471,7 +452,7 @@ size_t wxStreamBuffer::Read(wxStreamBuffer *dbuf) size_t wxStreamBuffer::Write(const void *buffer, size_t size) { - wxASSERT_MSG( buffer, wxT("Warning: Null pointer is about to be send") ); + wxASSERT_MSG( buffer, _T("Warning: Null pointer is about to be send") ); if (m_stream) { @@ -485,7 +466,7 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size) { wxOutputStream *outStream = GetOutputStream(); - wxCHECK_MSG( outStream, 0, wxT("should have a stream in wxStreamBuffer") ); + wxCHECK_MSG( outStream, 0, _T("should have a stream in wxStreamBuffer") ); // no buffer, just forward the call to the stream ret = outStream->OnSysWrite(buffer, size); @@ -543,8 +524,8 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size) size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf) { - wxCHECK_MSG( m_mode != read, 0, wxT("can't write to this buffer") ); - wxCHECK_MSG( sbuf->m_mode != write, 0, wxT("can't read from that buffer") ); + wxCHECK_MSG( m_mode != read, 0, _T("can't write to this buffer") ); + wxCHECK_MSG( sbuf->m_mode != write, 0, _T("can't read from that buffer") ); char buf[BUF_TEMP_SIZE]; size_t nWrite, @@ -599,7 +580,7 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) break; default: - wxFAIL_MSG( wxT("invalid seek mode") ); + wxFAIL_MSG( _T("invalid seek mode") ); return wxInvalidOffset; } @@ -635,7 +616,7 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) size_t int_diff = wx_truncate_cast(size_t, diff); wxCHECK_MSG( (wxFileOffset)int_diff == diff, wxInvalidOffset, wxT("huge file not supported") ); SetIntPosition(int_diff); - return diff; + return pos; } case wxFromEnd: @@ -676,8 +657,6 @@ wxFileOffset wxStreamBuffer::Tell() const // wxStreamBase // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxStreamBase, wxObject) - wxStreamBase::wxStreamBase() { m_lasterror = wxSTREAM_NO_ERROR; @@ -695,7 +674,7 @@ size_t wxStreamBase::GetSize() const return 0; const size_t len = wx_truncate_cast(size_t, length); - wxASSERT_MSG( len == length + size_t(0), wxT("large files not supported") ); + wxASSERT_MSG( len == length + size_t(0), _T("large files not supported") ); return len; } @@ -714,8 +693,6 @@ wxFileOffset wxStreamBase::OnSysTell() const // wxInputStream // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxStreamBase) - wxInputStream::wxInputStream() { m_wback = NULL; @@ -771,7 +748,7 @@ char *wxInputStream::AllocSpaceWBack(size_t needed_size) size_t wxInputStream::GetWBack(void *buf, size_t size) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be used") ); + wxASSERT_MSG( buf, _T("Warning: Null pointer is about to be used") ); /* Clear buffer first */ memset(buf, 0x00, size); @@ -807,7 +784,7 @@ size_t wxInputStream::GetWBack(void *buf, size_t size) size_t wxInputStream::Ungetch(const void *buf, size_t bufsize) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be used in Ungetch()") ); + wxASSERT_MSG( buf, _T("Warning: Null pointer is about to be used in Ungetch()") ); if ( m_lasterror != wxSTREAM_NO_ERROR && m_lasterror != wxSTREAM_EOF ) { @@ -841,7 +818,7 @@ int wxInputStream::GetC() wxInputStream& wxInputStream::Read(void *buf, size_t size) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be read") ); + wxASSERT_MSG( buf, _T("Warning: Null pointer is about to be read") ); char *p = (char *)buf; m_lastcount = 0; @@ -912,93 +889,17 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out) return *this; } -bool wxInputStream::ReadAll(void *buffer_, size_t size) -{ - char* buffer = static_cast(buffer_); - - size_t totalCount = 0; - - for ( ;; ) - { - const size_t lastCount = Read(buffer, size).LastRead(); - - // There is no point in continuing looping if we can't read anything at - // all. - if ( !lastCount ) - break; - - totalCount += lastCount; - - // ... Or if an error occurred on the stream. - if ( !IsOk() ) - break; - - // Return successfully if we read exactly the requested number of - // bytes (normally the ">" case should never occur and so we could use - // "==" test, but be safe and avoid overflowing size even in case of - // bugs in LastRead()). - if ( lastCount >= size ) - { - size = 0; - break; - } - - // Advance the buffer before trying to read the rest of data. - size -= lastCount; - buffer += lastCount; - } - - m_lastcount = totalCount; - - return size == 0; -} - wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode) { // RR: This code is duplicated in wxBufferedInputStream. This is // not really a good design, but buffered stream are different - // from all others in that they handle two stream-related objects: + // from all other in that they handle two stream-related objects, // the stream buffer and parent stream. // I don't know whether it should be put as well in wxFileInputStream::OnSysSeek if (m_lasterror==wxSTREAM_EOF) m_lasterror=wxSTREAM_NO_ERROR; - // avoid unnecessary seek operations (optimization) - wxFileOffset currentPos = TellI(), size = GetLength(); - if ((mode == wxFromStart && currentPos == pos) || - (mode == wxFromCurrent && pos == 0) || - (mode == wxFromEnd && size != wxInvalidOffset && currentPos == size-pos)) - return currentPos; - - if (!IsSeekable() && mode == wxFromCurrent && pos > 0) - { - // rather than seeking, we can just read data and discard it; - // this allows to forward-seek also non-seekable streams! - char buf[BUF_TEMP_SIZE]; - size_t bytes_read; - - // read chunks of BUF_TEMP_SIZE bytes until we reach the new position - for ( ; pos >= BUF_TEMP_SIZE; pos -= bytes_read) - { - bytes_read = Read(buf, WXSIZEOF(buf)).LastRead(); - if ( m_lasterror != wxSTREAM_NO_ERROR ) - return wxInvalidOffset; - - wxASSERT(bytes_read == WXSIZEOF(buf)); - } - - // read the last 'pos' bytes - bytes_read = Read(buf, (size_t)pos).LastRead(); - if ( m_lasterror != wxSTREAM_NO_ERROR ) - return wxInvalidOffset; - - wxASSERT(bytes_read == (size_t)pos); - - // we should now have sought to the right position... - return TellI(); - } - /* RR: A call to SeekI() will automatically invalidate any previous call to Ungetch(), otherwise it would be possible to SeekI() to one position, unread some bytes there, SeekI() to another position @@ -1037,8 +938,6 @@ wxFileOffset wxInputStream::TellI() const // wxOutputStream // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxStreamBase) - wxOutputStream::wxOutputStream() { } @@ -1070,38 +969,6 @@ wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in) return *this; } -bool wxOutputStream::WriteAll(const void *buffer_, size_t size) -{ - // This exactly mirrors ReadAll(), see there for more comments. - const char* buffer = static_cast(buffer_); - - size_t totalCount = 0; - - for ( ;; ) - { - const size_t lastCount = Write(buffer, size).LastWrite(); - if ( !lastCount ) - break; - - totalCount += lastCount; - - if ( !IsOk() ) - break; - - if ( lastCount >= size ) - { - size = 0; - break; - } - - size -= lastCount; - buffer += lastCount; - } - - m_lastcount = totalCount; - return size == 0; -} - wxFileOffset wxOutputStream::TellO() const { return OnSysTell(); @@ -1121,27 +988,24 @@ void wxOutputStream::Sync() // wxCountingOutputStream // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxCountingOutputStream, wxOutputStream) - wxCountingOutputStream::wxCountingOutputStream () { - m_currentPos = - m_lastPos = 0; + m_currentPos = 0; } wxFileOffset wxCountingOutputStream::GetLength() const { - return m_lastPos; + return m_lastcount; } size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer), size_t size) { m_currentPos += size; - if ( m_currentPos > m_lastPos ) - m_lastPos = m_currentPos; + if (m_currentPos > m_lastcount) + m_lastcount = m_currentPos; - return size; + return m_currentPos; } wxFileOffset wxCountingOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) @@ -1155,24 +1019,24 @@ wxFileOffset wxCountingOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode break; case wxFromEnd: - new_pos += m_lastPos; - wxCHECK_MSG( (wxFileOffset)new_pos == (wxFileOffset)(m_lastPos + pos), wxInvalidOffset, wxT("huge position not supported") ); + new_pos = m_lastcount + new_pos; + wxCHECK_MSG( (wxFileOffset)new_pos == (wxFileOffset)(m_lastcount + pos), wxInvalidOffset, wxT("huge position not supported") ); break; case wxFromCurrent: - new_pos += m_currentPos; + new_pos = m_currentPos + new_pos; wxCHECK_MSG( (wxFileOffset)new_pos == (wxFileOffset)(m_currentPos + pos), wxInvalidOffset, wxT("huge position not supported") ); break; default: - wxFAIL_MSG( wxT("invalid seek mode") ); + wxFAIL_MSG( _T("invalid seek mode") ); return wxInvalidOffset; } m_currentPos = new_pos; - if ( m_currentPos > m_lastPos ) - m_lastPos = m_currentPos; + if (m_currentPos > m_lastcount) + m_lastcount = m_currentPos; return m_currentPos; } @@ -1186,8 +1050,6 @@ wxFileOffset wxCountingOutputStream::OnSysTell() const // wxFilterInputStream // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxFilterInputStream, wxInputStream) - wxFilterInputStream::wxFilterInputStream() : m_parent_i_stream(NULL), m_owns(false) @@ -1216,8 +1078,6 @@ wxFilterInputStream::~wxFilterInputStream() // wxFilterOutputStream // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxFilterOutputStream, wxOutputStream) - wxFilterOutputStream::wxFilterOutputStream() : m_parent_o_stream(NULL), m_owns(false) @@ -1262,25 +1122,29 @@ wxString wxFilterClassFactoryBase::PopExtension(const wxString& location) const } wxString::size_type wxFilterClassFactoryBase::FindExtension( - const wxString& location) const + const wxChar *location) const { + size_t len = wxStrlen(location); + for (const wxChar *const *p = GetProtocols(wxSTREAM_FILEEXT); *p; p++) { - if ( location.EndsWith(*p) ) - return location.length() - wxStrlen(*p); + size_t l = wxStrlen(*p); + + if (l <= len && wxStrcmp(*p, location + len - l) == 0) + return len - l; } return wxString::npos; } -bool wxFilterClassFactoryBase::CanHandle(const wxString& protocol, +bool wxFilterClassFactoryBase::CanHandle(const wxChar *protocol, wxStreamProtocolType type) const { if (type == wxSTREAM_FILEEXT) return FindExtension(protocol) != wxString::npos; else for (const wxChar *const *p = GetProtocols(type); *p; p++) - if (protocol == *p) + if (wxStrcmp(*p, protocol) == 0) return true; return false; @@ -1313,33 +1177,21 @@ void wxFilterClassFactory::Remove() // wxBufferedInputStream // ---------------------------------------------------------------------------- -namespace -{ - -// helper function used for initializing the buffer used by -// wxBufferedInput/OutputStream: it simply returns the provided buffer if it's -// not NULL or creates a buffer of the given size otherwise -template -wxStreamBuffer * -CreateBufferIfNeeded(T& stream, wxStreamBuffer *buffer, size_t bufsize = 1024) -{ - return buffer ? buffer : new wxStreamBuffer(bufsize, stream); -} - -} // anonymous namespace - -wxBufferedInputStream::wxBufferedInputStream(wxInputStream& stream, +wxBufferedInputStream::wxBufferedInputStream(wxInputStream& s, wxStreamBuffer *buffer) - : wxFilterInputStream(stream) + : wxFilterInputStream(s) { - m_i_streambuf = CreateBufferIfNeeded(*this, buffer); -} + if ( buffer ) + { + // use the buffer provided by the user + m_i_streambuf = buffer; + } + else // create a default buffer + { + m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read); -wxBufferedInputStream::wxBufferedInputStream(wxInputStream& stream, - size_t bufsize) - : wxFilterInputStream(stream) -{ - m_i_streambuf = CreateBufferIfNeeded(*this, NULL, bufsize); + m_i_streambuf->SetBufferIO(1024); + } } wxBufferedInputStream::~wxBufferedInputStream() @@ -1431,7 +1283,7 @@ wxFileOffset wxBufferedInputStream::OnSysTell() const void wxBufferedInputStream::SetInputStreamBuffer(wxStreamBuffer *buffer) { - wxCHECK_RET( buffer, wxT("wxBufferedInputStream needs buffer") ); + wxCHECK_RET( buffer, _T("wxBufferedInputStream needs buffer") ); delete m_i_streambuf; m_i_streambuf = buffer; @@ -1441,18 +1293,20 @@ void wxBufferedInputStream::SetInputStreamBuffer(wxStreamBuffer *buffer) // wxBufferedOutputStream // ---------------------------------------------------------------------------- -wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream& stream, +wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream& s, wxStreamBuffer *buffer) - : wxFilterOutputStream(stream) + : wxFilterOutputStream(s) { - m_o_streambuf = CreateBufferIfNeeded(*this, buffer); -} + if ( buffer ) + { + m_o_streambuf = buffer; + } + else // create a default one + { + m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write); -wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream& stream, - size_t bufsize) - : wxFilterOutputStream(stream) -{ - m_o_streambuf = CreateBufferIfNeeded(*this, NULL, bufsize); + m_o_streambuf->SetBufferIO(1024); + } } wxBufferedOutputStream::~wxBufferedOutputStream() @@ -1488,11 +1342,8 @@ wxFileOffset wxBufferedOutputStream::TellO() const void wxBufferedOutputStream::Sync() { - if (m_o_streambuf) - { - m_o_streambuf->FlushBuffer(); - m_parent_o_stream->Sync(); - } + m_o_streambuf->FlushBuffer(); + m_parent_o_stream->Sync(); } size_t wxBufferedOutputStream::OnSysWrite(const void *buffer, size_t bufsize) @@ -1517,99 +1368,12 @@ wxFileOffset wxBufferedOutputStream::GetLength() const void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer *buffer) { - wxCHECK_RET( buffer, wxT("wxBufferedOutputStream needs buffer") ); + wxCHECK_RET( buffer, _T("wxBufferedOutputStream needs buffer") ); delete m_o_streambuf; m_o_streambuf = buffer; } -// --------------------------------------------------------------------------- -// wxWrapperInputStream implementation -// --------------------------------------------------------------------------- - -wxWrapperInputStream::wxWrapperInputStream() -{ - m_lasterror = wxSTREAM_READ_ERROR; -} - -wxWrapperInputStream::wxWrapperInputStream(wxInputStream& stream) - : wxFilterInputStream(stream) -{ - SynchronizeLastError(); -} - -wxWrapperInputStream::wxWrapperInputStream(wxInputStream *stream) - : wxFilterInputStream(stream) -{ - if ( m_parent_i_stream ) - SynchronizeLastError(); - else - m_lasterror = wxSTREAM_READ_ERROR; -} - -void wxWrapperInputStream::InitParentStream(wxInputStream& stream) -{ - wxCHECK_RET( !m_parent_i_stream, "Can't init parent stream twice" ); - - m_parent_i_stream = &stream; - - SynchronizeLastError(); -} - -void wxWrapperInputStream::InitParentStream(wxInputStream* stream) -{ - wxCHECK_RET( !m_parent_i_stream, "Can't init parent stream twice" ); - - m_parent_i_stream = stream; - - if ( m_parent_i_stream ) - { - m_owns = true; - - SynchronizeLastError(); - } -} - -wxFileOffset wxWrapperInputStream::GetLength() const -{ - wxCHECK_MSG(m_parent_i_stream, wxInvalidOffset, "Stream not valid"); - - wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError); - return m_parent_i_stream->GetLength(); -} - -bool wxWrapperInputStream::IsSeekable() const -{ - wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid"); - return m_parent_i_stream->IsSeekable(); -} - -size_t wxWrapperInputStream::OnSysRead(void *buffer, size_t size) -{ - wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid"); - - wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError); - - m_parent_i_stream->Read(buffer, size); - return m_parent_i_stream->LastRead(); -} - -wxFileOffset wxWrapperInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) -{ - wxCHECK_MSG(IsSeekable(), false, "Stream not seekable"); - - wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError); - return m_parent_i_stream->SeekI (pos, mode); -} - -wxFileOffset wxWrapperInputStream::OnSysTell() const -{ - wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid"); - - wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError); - return m_parent_i_stream->TellI(); -} - // ---------------------------------------------------------------------------- // Some IOManip function // ---------------------------------------------------------------------------- diff --git a/Source/3rd Party/wx/src/common/string.cpp b/Source/3rd Party/wx/src/common/string.cpp index 2d30e939e..1bb1052ed 100644 --- a/Source/3rd Party/wx/src/common/string.cpp +++ b/Source/3rd Party/wx/src/common/string.cpp @@ -4,11 +4,19 @@ // Author: Vadim Zeitlin, Ryan Norton // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: string.cpp 63008 2009-12-28 20:01:39Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // (c) 2004 Ryan Norton // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +/* + * About ref counting: + * 1) all empty strings use g_strEmpty, nRefs = -1 (set in Init()) + * 2) AllocBuffer() sets nRefs to 1, Lock() increments it by one + * 3) Unlock() decrements nRefs and frees memory if it goes to 0 + */ + // =========================================================================== // headers, declarations, constants // =========================================================================== @@ -22,9 +30,8 @@ #ifndef WX_PRECOMP #include "wx/string.h" - #include "wx/wxcrtvararg.h" #include "wx/intl.h" - #include "wx/log.h" + #include "wx/thread.h" #endif #include @@ -36,153 +43,47 @@ #include #include -#include "wx/hashmap.h" -#include "wx/vector.h" -#include "wx/xlocale.h" - -#ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" -#endif // __WINDOWS__ - -#if wxUSE_STD_IOSTREAM - #include +#ifdef __SALFORDC__ + #include #endif -// string handling functions used by wxString: -#if wxUSE_UNICODE_UTF8 - #define wxStringMemcpy memcpy - #define wxStringMemcmp memcmp - #define wxStringMemchr memchr - #define wxStringStrlen strlen -#else - #define wxStringMemcpy wxTmemcpy - #define wxStringMemcmp wxTmemcmp - #define wxStringMemchr wxTmemchr - #define wxStringStrlen wxStrlen -#endif - -// define a function declared in wx/buffer.h here as we don't have buffer.cpp -// and don't want to add it just because of this simple function -namespace wxPrivate -{ - -// wxXXXBuffer classes can be (implicitly) used during global statics -// initialization so wrap the status UntypedBufferData variable in a function -// to make it safe to access it even before all global statics are initialized -UntypedBufferData *GetUntypedNullData() -{ - static UntypedBufferData s_untypedNullData(NULL, 0); - - return &s_untypedNullData; -} - -} // namespace wxPrivate +// allocating extra space for each string consumes more memory but speeds up +// the concatenation operations (nLen is the current string's length) +// NB: EXTRA_ALLOC must be >= 0! +#define EXTRA_ALLOC (19 - nLen % 16) // --------------------------------------------------------------------------- // static class variables definition // --------------------------------------------------------------------------- -//According to STL _must_ be a -1 size_t -const size_t wxString::npos = (size_t) -1; +#if !wxUSE_STL + //According to STL _must_ be a -1 size_t + const size_t wxStringBase::npos = (size_t) -1; +#endif -#if wxUSE_STRING_POS_CACHE +// ---------------------------------------------------------------------------- +// static data +// ---------------------------------------------------------------------------- -#ifdef wxHAS_COMPILER_TLS +#if wxUSE_STL -wxTLS_TYPE(wxString::Cache) wxString::ms_cache; +extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = _T(""); -#else // !wxHAS_COMPILER_TLS +#else -struct wxStrCacheInitializer +// for an empty string, GetStringData() will return this address: this +// structure has the same layout as wxStringData and it's data() method will +// return the empty string (dummy pointer) +static const struct { - wxStrCacheInitializer() - { - // calling this function triggers s_cache initialization in it, and - // from now on it becomes safe to call from multiple threads - wxString::GetCache(); - } -}; + wxStringData data; + wxChar dummy; +} g_strEmpty = { {-1, 0, 0}, wxT('\0') }; -/* -wxString::Cache& wxString::GetCache() -{ - static wxTLS_TYPE(Cache) s_cache; +// empty C style string: points to 'string data' byte of g_strEmpty +extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy; - return wxTLS_VALUE(s_cache); -} -*/ - -static wxStrCacheInitializer gs_stringCacheInit; - -#endif // wxHAS_COMPILER_TLS/!wxHAS_COMPILER_TLS - -// gdb seems to be unable to display thread-local variables correctly, at least -// not my 6.4.98 version under amd64, so provide this debugging helper to do it -#if wxDEBUG_LEVEL >= 2 - -struct wxStrCacheDumper -{ - static void ShowAll() - { - puts("*** wxString cache dump:"); - for ( unsigned n = 0; n < wxString::Cache::SIZE; n++ ) - { - const wxString::Cache::Element& - c = wxString::GetCacheBegin()[n]; - - printf("\t%u%s\t%p: pos=(%lu, %lu), len=%ld\n", - n, - n == wxString::LastUsedCacheElement() ? " [*]" : "", - c.str, - (unsigned long)c.pos, - (unsigned long)c.impl, - (long)c.len); - } - } -}; - -void wxDumpStrCache() { wxStrCacheDumper::ShowAll(); } - -#endif // wxDEBUG_LEVEL >= 2 - -#ifdef wxPROFILE_STRING_CACHE - -wxString::CacheStats wxString::ms_cacheStats; - -struct wxStrCacheStatsDumper -{ - ~wxStrCacheStatsDumper() - { - const wxString::CacheStats& stats = wxString::ms_cacheStats; - - if ( stats.postot ) - { - puts("*** wxString cache statistics:"); - printf("\tTotal non-trivial calls to PosToImpl(): %u\n", - stats.postot); - printf("\tHits %u (of which %u not used) or %.2f%%\n", - stats.poshits, - stats.mishits, - 100.*float(stats.poshits - stats.mishits)/stats.postot); - printf("\tAverage position requested: %.2f\n", - float(stats.sumpos) / stats.postot); - printf("\tAverage offset after cached hint: %.2f\n", - float(stats.sumofs) / stats.postot); - } - - if ( stats.lentot ) - { - printf("\tNumber of calls to length(): %u, hits=%.2f%%\n", - stats.lentot, 100.*float(stats.lenhits)/stats.lentot); - } - } -}; - -static wxStrCacheStatsDumper s_showCacheStats; - -#endif // wxPROFILE_STRING_CACHE - -#endif // wxUSE_STRING_POS_CACHE +#endif // ---------------------------------------------------------------------------- // global functions @@ -192,187 +93,908 @@ static wxStrCacheStatsDumper s_showCacheStats; #include -wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) -{ -#if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 - const wxScopedCharBuffer buf(str.AsCharBuf()); - if ( !buf ) - os.clear(wxSTD ios_base::failbit); - else - os << buf.data(); - - return os; -#else - return os << str.AsInternal(); -#endif -} - wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str) { - return os << str.c_str(); -} - -wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedCharBuffer& str) -{ - return os << str.data(); -} - -#ifndef __BORLANDC__ -wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str) -{ - return os << str.data(); -} +#ifdef __BORLANDC__ + os << str.mb_str(); +#else + os << str.c_str(); #endif - -#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) - -wxSTD wostream& operator<<(wxSTD wostream& wos, const wxString& str) -{ - return wos << str.wc_str(); + return os; } -wxSTD wostream& operator<<(wxSTD wostream& wos, const wxCStrData& str) -{ - return wos << str.AsWChar(); -} - -wxSTD wostream& operator<<(wxSTD wostream& wos, const wxScopedWCharBuffer& str) -{ - return wos << str.data(); -} - -#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) - #endif // wxUSE_STD_IOSTREAM +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +// this small class is used to gather statistics for performance tuning +//#define WXSTRING_STATISTICS +#ifdef WXSTRING_STATISTICS + class Averager + { + public: + Averager(const wxChar *sz) { m_sz = sz; m_nTotal = m_nCount = 0; } + ~Averager() + { wxPrintf("wxString: average %s = %f\n", m_sz, ((float)m_nTotal)/m_nCount); } + + void Add(size_t n) { m_nTotal += n; m_nCount++; } + + private: + size_t m_nCount, m_nTotal; + const wxChar *m_sz; + } g_averageLength("allocation size"), + g_averageSummandLength("summand length"), + g_averageConcatHit("hit probability in concat"), + g_averageInitialLength("initial string length"); + + #define STATISTICS_ADD(av, val) g_average##av.Add(val) +#else + #define STATISTICS_ADD(av, val) +#endif // WXSTRING_STATISTICS + +#if !wxUSE_STL + // =========================================================================== -// wxString class core +// wxStringData class deallocation // =========================================================================== -#if wxUSE_UNICODE_UTF8 - -void wxString::PosLenToImpl(size_t pos, size_t len, - size_t *implPos, size_t *implLen) const +#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) +# pragma message (__FILE__ ": building with Multithreaded non DLL runtime has a performance impact on wxString!") +void wxStringData::Free() { - if ( pos == npos ) - { - *implPos = npos; + free(this); +} +#endif + +// =========================================================================== +// wxStringBase +// =========================================================================== + +// takes nLength elements of psz starting at nPos +void wxStringBase::InitWith(const wxChar *psz, size_t nPos, size_t nLength) +{ + Init(); + + // if the length is not given, assume the string to be NUL terminated + if ( nLength == npos ) { + wxASSERT_MSG( nPos <= wxStrlen(psz), _T("index out of bounds") ); + + nLength = wxStrlen(psz + nPos); + } + + STATISTICS_ADD(InitialLength, nLength); + + if ( nLength > 0 ) { + // trailing '\0' is written in AllocBuffer() + if ( !AllocBuffer(nLength) ) { + wxFAIL_MSG( _T("out of memory in wxStringBase::InitWith") ); + return; } - else // have valid start position + wxTmemcpy(m_pchData, psz + nPos, nLength); + } +} + +// poor man's iterators are "void *" pointers +wxStringBase::wxStringBase(const void *pStart, const void *pEnd) +{ + if ( pEnd >= pStart ) + { + InitWith((const wxChar *)pStart, 0, + (const wxChar *)pEnd - (const wxChar *)pStart); + } + else + { + wxFAIL_MSG( _T("pStart is not before pEnd") ); + Init(); + } +} + +wxStringBase::wxStringBase(size_type n, wxChar ch) +{ + Init(); + append(n, ch); +} + +// --------------------------------------------------------------------------- +// memory allocation +// --------------------------------------------------------------------------- + +// allocates memory needed to store a C string of length nLen +bool wxStringBase::AllocBuffer(size_t nLen) +{ + // allocating 0 sized buffer doesn't make sense, all empty strings should + // reuse g_strEmpty + wxASSERT( nLen > 0 ); + + // make sure that we don't overflow + wxCHECK( nLen < (INT_MAX / sizeof(wxChar)) - + (sizeof(wxStringData) + EXTRA_ALLOC + 1), false ); + + STATISTICS_ADD(Length, nLen); + + // allocate memory: + // 1) one extra character for '\0' termination + // 2) sizeof(wxStringData) for housekeeping info + wxStringData* pData = (wxStringData*) + malloc(sizeof(wxStringData) + (nLen + EXTRA_ALLOC + 1)*sizeof(wxChar)); + + if ( pData == NULL ) { + // allocation failures are handled by the caller + return false; + } + + pData->nRefs = 1; + pData->nDataLength = nLen; + pData->nAllocLength = nLen + EXTRA_ALLOC; + m_pchData = pData->data(); // data starts after wxStringData + m_pchData[nLen] = wxT('\0'); + return true; +} + +// must be called before changing this string +bool wxStringBase::CopyBeforeWrite() +{ + wxStringData* pData = GetStringData(); + + if ( pData->IsShared() ) { + pData->Unlock(); // memory not freed because shared + size_t nLen = pData->nDataLength; + if ( !AllocBuffer(nLen) ) { + // allocation failures are handled by the caller + return false; + } + wxTmemcpy(m_pchData, pData->data(), nLen); + } + + wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner + + return true; +} + +// must be called before replacing contents of this string +bool wxStringBase::AllocBeforeWrite(size_t nLen) +{ + wxASSERT( nLen != 0 ); // doesn't make any sense + + // must not share string and must have enough space + wxStringData* pData = GetStringData(); + if ( pData->IsShared() || pData->IsEmpty() ) { + // can't work with old buffer, get new one + pData->Unlock(); + if ( !AllocBuffer(nLen) ) { + // allocation failures are handled by the caller + return false; + } + } + else { + if ( nLen > pData->nAllocLength ) { + // realloc the buffer instead of calling malloc() again, this is more + // efficient + STATISTICS_ADD(Length, nLen); + + nLen += EXTRA_ALLOC; + + pData = (wxStringData*) + realloc(pData, sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); + + if ( pData == NULL ) { + // allocation failures are handled by the caller + // keep previous data since reallocation failed + return false; + } + + pData->nAllocLength = nLen; + m_pchData = pData->data(); + } + } + + wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner + + // it doesn't really matter what the string length is as it's going to be + // overwritten later but, for extra safety, set it to 0 for now as we may + // have some junk in m_pchData + GetStringData()->nDataLength = 0; + + return true; +} + +wxStringBase& wxStringBase::append(size_t n, wxChar ch) +{ + size_type len = length(); + + if ( !Alloc(len + n) || !CopyBeforeWrite() ) { + wxFAIL_MSG( _T("out of memory in wxStringBase::append") ); + } + GetStringData()->nDataLength = len + n; + m_pchData[len + n] = '\0'; + for ( size_t i = 0; i < n; ++i ) + m_pchData[len + i] = ch; + return *this; +} + +void wxStringBase::resize(size_t nSize, wxChar ch) +{ + size_t len = length(); + + if ( nSize < len ) { - const const_iterator b = GetIterForNthChar(pos); - *implPos = wxStringImpl::const_iterator(b.impl()) - m_impl.begin(); - if ( len == npos ) + erase(begin() + nSize, end()); + } + else if ( nSize > len ) + { + append(nSize - len, ch); + } + //else: we have exactly the specified length, nothing to do +} + +// allocate enough memory for nLen characters +bool wxStringBase::Alloc(size_t nLen) +{ + wxStringData *pData = GetStringData(); + if ( pData->nAllocLength <= nLen ) { + if ( pData->IsEmpty() ) { + nLen += EXTRA_ALLOC; + + pData = (wxStringData *) + malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); + + if ( pData == NULL ) { + // allocation failure handled by caller + return false; + } + + pData->nRefs = 1; + pData->nDataLength = 0; + pData->nAllocLength = nLen; + m_pchData = pData->data(); // data starts after wxStringData + m_pchData[0u] = wxT('\0'); + } + else if ( pData->IsShared() ) { + pData->Unlock(); // memory not freed because shared + size_t nOldLen = pData->nDataLength; + if ( !AllocBuffer(nLen) ) { + // allocation failure handled by caller + return false; + } + // +1 to copy the terminator, too + memcpy(m_pchData, pData->data(), (nOldLen+1)*sizeof(wxChar)); + GetStringData()->nDataLength = nOldLen; + } + else { + nLen += EXTRA_ALLOC; + + pData = (wxStringData *) + realloc(pData, sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); + + if ( pData == NULL ) { + // allocation failure handled by caller + // keep previous data since reallocation failed + return false; + } + + // it's not important if the pointer changed or not (the check for this + // is not faster than assigning to m_pchData in all cases) + pData->nAllocLength = nLen; + m_pchData = pData->data(); + } + } + //else: we've already got enough + return true; +} + +wxStringBase::iterator wxStringBase::begin() +{ + if (length() > 0) + CopyBeforeWrite(); + return m_pchData; +} + +wxStringBase::iterator wxStringBase::end() +{ + if (length() > 0) + CopyBeforeWrite(); + return m_pchData + length(); +} + +wxStringBase::iterator wxStringBase::erase(iterator it) +{ + size_type idx = it - begin(); + erase(idx, 1); + return begin() + idx; +} + +wxStringBase& wxStringBase::erase(size_t nStart, size_t nLen) +{ + wxASSERT(nStart <= length()); + size_t strLen = length() - nStart; + // delete nLen or up to the end of the string characters + nLen = strLen < nLen ? strLen : nLen; + wxString strTmp(c_str(), nStart); + strTmp.append(c_str() + nStart + nLen, length() - nStart - nLen); + + swap(strTmp); + return *this; +} + +wxStringBase& wxStringBase::insert(size_t nPos, const wxChar *sz, size_t n) +{ + wxASSERT( nPos <= length() ); + + if ( n == npos ) n = wxStrlen(sz); + if ( n == 0 ) return *this; + + if ( !Alloc(length() + n) || !CopyBeforeWrite() ) { + wxFAIL_MSG( _T("out of memory in wxStringBase::insert") ); + } + + memmove(m_pchData + nPos + n, m_pchData + nPos, + (length() - nPos) * sizeof(wxChar)); + memcpy(m_pchData + nPos, sz, n * sizeof(wxChar)); + GetStringData()->nDataLength = length() + n; + m_pchData[length()] = '\0'; + + return *this; +} + +void wxStringBase::swap(wxStringBase& str) +{ + wxChar* tmp = str.m_pchData; + str.m_pchData = m_pchData; + m_pchData = tmp; +} + +size_t wxStringBase::find(const wxStringBase& str, size_t nStart) const +{ + // deal with the special case of empty string first + const size_t nLen = length(); + const size_t nLenOther = str.length(); + + if ( !nLenOther ) + { + // empty string is a substring of anything + return 0; + } + + if ( !nLen ) + { + // the other string is non empty so can't be our substring + return npos; + } + + wxASSERT( str.GetStringData()->IsValid() ); + wxASSERT( nStart <= nLen ); + + const wxChar * const other = str.c_str(); + + // anchor + const wxChar* p = (const wxChar*)wxTmemchr(c_str() + nStart, + *other, + nLen - nStart); + + if ( !p ) + return npos; + + while ( p - c_str() + nLenOther <= nLen && wxTmemcmp(p, other, nLenOther) ) + { + p++; + + // anchor again + p = (const wxChar*)wxTmemchr(p, *other, nLen - (p - c_str())); + + if ( !p ) + return npos; + } + + return p - c_str() + nLenOther <= nLen ? p - c_str() : npos; +} + +size_t wxStringBase::find(const wxChar* sz, size_t nStart, size_t n) const +{ + return find(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::find(wxChar ch, size_t nStart) const +{ + wxASSERT( nStart <= length() ); + + const wxChar *p = (const wxChar*)wxTmemchr(c_str() + nStart, ch, length() - nStart); + + return p == NULL ? npos : p - c_str(); +} + +size_t wxStringBase::rfind(const wxStringBase& str, size_t nStart) const +{ + wxASSERT( str.GetStringData()->IsValid() ); + wxASSERT( nStart == npos || nStart <= length() ); + + if ( length() >= str.length() ) + { + // avoids a corner case later + if ( length() == 0 && str.length() == 0 ) + return 0; + + // "top" is the point where search starts from + size_t top = length() - str.length(); + + if ( nStart == npos ) + nStart = length() - 1; + if ( nStart < top ) + top = nStart; + + const wxChar *cursor = c_str() + top; + do { - *implLen = npos; - } - else // have valid length too - { - // we need to handle the case of length specifying a substring - // going beyond the end of the string, just as std::string does - const const_iterator e(end()); - const_iterator i(b); - while ( len && i <= e ) + if ( wxTmemcmp(cursor, str.c_str(), + str.length()) == 0 ) { - ++i; - --len; + return cursor - c_str(); } - - *implLen = i.impl() - b.impl(); - } + } while ( cursor-- > c_str() ); } + + return npos; } -#endif // wxUSE_UNICODE_UTF8 - -// ---------------------------------------------------------------------------- -// wxCStrData converted strings caching -// ---------------------------------------------------------------------------- - -// FIXME-UTF8: temporarily disabled because it doesn't work with global -// string objects; re-enable after fixing this bug and benchmarking -// performance to see if using a hash is a good idea at all -#if 0 - -// For backward compatibility reasons, it must be possible to assign the value -// returned by wxString::c_str() to a char* or wchar_t* variable and work with -// it. Returning wxCharBuffer from (const char*)c_str() wouldn't do the trick, -// because the memory would be freed immediately, but it has to be valid as long -// as the string is not modified, so that code like this still works: -// -// const wxChar *s = str.c_str(); -// while ( s ) { ... } - -// FIXME-UTF8: not thread safe! -// FIXME-UTF8: we currently clear the cached conversion only when the string is -// destroyed, but we should do it when the string is modified, to -// keep memory usage down -// FIXME-UTF8: we do the conversion every time As[W]Char() is called, but if we -// invalidated the cache on every change, we could keep the previous -// conversion -// FIXME-UTF8: add tracing of usage of these two methods - new code is supposed -// to use mb_str() or wc_str() instead of (const [w]char*)c_str() - -template -static inline void DeleteStringFromConversionCache(T& hash, const wxString *s) +size_t wxStringBase::rfind(const wxChar* sz, size_t nStart, size_t n) const { - typename T::iterator i = hash.find(wxConstCast(s, wxString)); - if ( i != hash.end() ) + return rfind(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::rfind(wxChar ch, size_t nStart) const +{ + if ( nStart == npos ) { - free(i->second); - hash.erase(i); + nStart = length(); + } + else + { + wxASSERT( nStart <= length() ); + } + + const wxChar *actual; + for ( actual = c_str() + ( nStart == npos ? length() : nStart + 1 ); + actual > c_str(); --actual ) + { + if ( *(actual - 1) == ch ) + return (actual - 1) - c_str(); + } + + return npos; +} + +size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart) const +{ + wxASSERT(nStart <= length()); + + size_t len = wxStrlen(sz); + + size_t i; + for(i = nStart; i < this->length(); ++i) + { + if (wxTmemchr(sz, *(c_str() + i), len)) + break; + } + + if(i == this->length()) + return npos; + else + return i; +} + +size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart, + size_t n) const +{ + return find_first_of(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::find_last_of(const wxChar* sz, size_t nStart) const +{ + if ( nStart == npos ) + { + nStart = length() - 1; + } + else + { + wxASSERT_MSG( nStart <= length(), + _T("invalid index in find_last_of()") ); + } + + size_t len = wxStrlen(sz); + + for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p ) + { + if ( wxTmemchr(sz, *p, len) ) + return p - c_str(); + } + + return npos; +} + +size_t wxStringBase::find_last_of(const wxChar* sz, size_t nStart, + size_t n) const +{ + return find_last_of(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::find_first_not_of(const wxChar* sz, size_t nStart) const +{ + if ( nStart == npos ) + { + nStart = length(); + } + else + { + wxASSERT( nStart <= length() ); + } + + size_t len = wxStrlen(sz); + + size_t i; + for(i = nStart; i < this->length(); ++i) + { + if (!wxTmemchr(sz, *(c_str() + i), len)) + break; + } + + if(i == this->length()) + return npos; + else + return i; +} + +size_t wxStringBase::find_first_not_of(const wxChar* sz, size_t nStart, + size_t n) const +{ + return find_first_not_of(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::find_first_not_of(wxChar ch, size_t nStart) const +{ + wxASSERT( nStart <= length() ); + + for ( const wxChar *p = c_str() + nStart; *p; p++ ) + { + if ( *p != ch ) + return p - c_str(); + } + + return npos; +} + +size_t wxStringBase::find_last_not_of(const wxChar* sz, size_t nStart) const +{ + if ( nStart == npos ) + { + nStart = length() - 1; + } + else + { + wxASSERT( nStart <= length() ); + } + + size_t len = wxStrlen(sz); + + for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p ) + { + if ( !wxTmemchr(sz, *p,len) ) + return p - c_str(); + } + + return npos; +} + +size_t wxStringBase::find_last_not_of(const wxChar* sz, size_t nStart, + size_t n) const +{ + return find_last_not_of(wxStringBase(sz, n), nStart); +} + +size_t wxStringBase::find_last_not_of(wxChar ch, size_t nStart) const +{ + if ( nStart == npos ) + { + nStart = length() - 1; + } + else + { + wxASSERT( nStart <= length() ); + } + + for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p ) + { + if ( *p != ch ) + return p - c_str(); + } + + return npos; +} + +wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen, + const wxChar *sz) +{ + wxASSERT_MSG( nStart <= length(), + _T("index out of bounds in wxStringBase::replace") ); + size_t strLen = length() - nStart; + nLen = strLen < nLen ? strLen : nLen; + + wxStringBase strTmp; + strTmp.reserve(length()); // micro optimisation to avoid multiple mem allocs + + //This is kind of inefficient, but its pretty good considering... + //we don't want to use character access operators here because on STL + //it will freeze the reference count of strTmp, which means a deep copy + //at the end when swap is called + // + //Also, we can't use append with the full character pointer and must + //do it manually because this string can contain null characters + for(size_t i1 = 0; i1 < nStart; ++i1) + strTmp.append(1, this->c_str()[i1]); + + //its safe to do the full version here because + //sz must be a normal c string + strTmp.append(sz); + + for(size_t i2 = nStart + nLen; i2 < length(); ++i2) + strTmp.append(1, this->c_str()[i2]); + + swap(strTmp); + return *this; +} + +wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen, + size_t nCount, wxChar ch) +{ + return replace(nStart, nLen, wxStringBase(nCount, ch).c_str()); +} + +wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen, + const wxStringBase& str, + size_t nStart2, size_t nLen2) +{ + return replace(nStart, nLen, str.substr(nStart2, nLen2)); +} + +wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen, + const wxChar* sz, size_t nCount) +{ + return replace(nStart, nLen, wxStringBase(sz, nCount).c_str()); +} + +wxStringBase wxStringBase::substr(size_t nStart, size_t nLen) const +{ + if ( nLen == npos ) + nLen = length() - nStart; + return wxStringBase(*this, nStart, nLen); +} + +// assigns one string to another +wxStringBase& wxStringBase::operator=(const wxStringBase& stringSrc) +{ + wxASSERT( stringSrc.GetStringData()->IsValid() ); + + // don't copy string over itself + if ( m_pchData != stringSrc.m_pchData ) { + if ( stringSrc.GetStringData()->IsEmpty() ) { + Reinit(); + } + else { + // adjust references + GetStringData()->Unlock(); + m_pchData = stringSrc.m_pchData; + GetStringData()->Lock(); + } + } + + return *this; +} + +// assigns a single character +wxStringBase& wxStringBase::operator=(wxChar ch) +{ + if ( !AssignCopy(1, &ch) ) { + wxFAIL_MSG( _T("out of memory in wxStringBase::operator=(wxChar)") ); + } + return *this; +} + +// assigns C string +wxStringBase& wxStringBase::operator=(const wxChar *psz) +{ + if ( !AssignCopy(wxStrlen(psz), psz) ) { + wxFAIL_MSG( _T("out of memory in wxStringBase::operator=(const wxChar *)") ); + } + return *this; +} + +// helper function: does real copy +bool wxStringBase::AssignCopy(size_t nSrcLen, const wxChar *pszSrcData) +{ + if ( nSrcLen == 0 ) { + Reinit(); + } + else { + if ( !AllocBeforeWrite(nSrcLen) ) { + // allocation failure handled by caller + return false; + } + + // use memmove() and not memcpy() here as we might be copying from our own + // buffer in case of assignment such as "s = s.c_str()" (see #11294) + memmove(m_pchData, pszSrcData, nSrcLen*sizeof(wxChar)); + + GetStringData()->nDataLength = nSrcLen; + m_pchData[nSrcLen] = wxT('\0'); + } + return true; +} + +// --------------------------------------------------------------------------- +// string concatenation +// --------------------------------------------------------------------------- + +// add something to this string +bool wxStringBase::ConcatSelf(size_t nSrcLen, const wxChar *pszSrcData, + size_t nMaxLen) +{ + STATISTICS_ADD(SummandLength, nSrcLen); + + nSrcLen = nSrcLen < nMaxLen ? nSrcLen : nMaxLen; + + // concatenating an empty string is a NOP + if ( nSrcLen > 0 ) { + wxStringData *pData = GetStringData(); + size_t nLen = pData->nDataLength; + size_t nNewLen = nLen + nSrcLen; + + // take special care when appending part of this string to itself: the code + // below reallocates our buffer and this invalidates pszSrcData pointer so + // we have to copy it in another temporary string in this case (but avoid + // doing this unnecessarily) + if ( pszSrcData >= m_pchData && pszSrcData < m_pchData + nLen ) + { + wxStringBase tmp(pszSrcData, nSrcLen); + return ConcatSelf(nSrcLen, tmp.m_pchData, nSrcLen); + } + + // alloc new buffer if current is too small + if ( pData->IsShared() ) { + STATISTICS_ADD(ConcatHit, 0); + + // we have to allocate another buffer + wxStringData* pOldData = GetStringData(); + if ( !AllocBuffer(nNewLen) ) { + // allocation failure handled by caller + return false; + } + memcpy(m_pchData, pOldData->data(), nLen*sizeof(wxChar)); + pOldData->Unlock(); + } + else if ( nNewLen > pData->nAllocLength ) { + STATISTICS_ADD(ConcatHit, 0); + + reserve(nNewLen); + // we have to grow the buffer + if ( capacity() < nNewLen ) { + // allocation failure handled by caller + return false; + } + } + else { + STATISTICS_ADD(ConcatHit, 1); + + // the buffer is already big enough + } + + // should be enough space + wxASSERT( nNewLen <= GetStringData()->nAllocLength ); + + // fast concatenation - all is done in our buffer + memcpy(m_pchData + nLen, pszSrcData, nSrcLen*sizeof(wxChar)); + + m_pchData[nNewLen] = wxT('\0'); // put terminating '\0' + GetStringData()->nDataLength = nNewLen; // and fix the length + } + //else: the string to append was empty + return true; +} + +// --------------------------------------------------------------------------- +// simple sub-string extraction +// --------------------------------------------------------------------------- + +// helper function: clone the data attached to this string +bool wxStringBase::AllocCopy(wxString& dest, int nCopyLen, int nCopyIndex) const +{ + if ( nCopyLen == 0 ) { + dest.Init(); + } + else { + if ( !dest.AllocBuffer(nCopyLen) ) { + // allocation failure handled by caller + return false; + } + memcpy(dest.m_pchData, m_pchData + nCopyIndex, nCopyLen*sizeof(wxChar)); + } + return true; +} + +#endif // !wxUSE_STL + +#if !wxUSE_STL || !defined(HAVE_STD_STRING_COMPARE) + +#if !wxUSE_STL + #define STRINGCLASS wxStringBase +#else + #define STRINGCLASS wxString +#endif + +static inline int wxDoCmp(const wxChar* s1, size_t l1, + const wxChar* s2, size_t l2) +{ + if( l1 == l2 ) + return wxTmemcmp(s1, s2, l1); + else if( l1 < l2 ) + { + int ret = wxTmemcmp(s1, s2, l1); + return ret == 0 ? -1 : ret; + } + else + { + int ret = wxTmemcmp(s1, s2, l2); + return ret == 0 ? +1 : ret; } } -#if wxUSE_UNICODE -// NB: non-STL implementation doesn't compile with "const wxString*" key type, -// so we have to use wxString* here and const-cast when used -WX_DECLARE_HASH_MAP(wxString*, char*, wxPointerHash, wxPointerEqual, - wxStringCharConversionCache); -static wxStringCharConversionCache gs_stringsCharCache; - -const char* wxCStrData::AsChar() const +int STRINGCLASS::compare(const wxStringBase& str) const { - // remove previously cache value, if any (see FIXMEs above): - DeleteStringFromConversionCache(gs_stringsCharCache, m_str); - - // convert the string and keep it: - const char *s = gs_stringsCharCache[wxConstCast(m_str, wxString)] = - m_str->mb_str().release(); - - return s + m_offset; + return ::wxDoCmp(data(), length(), str.data(), str.length()); } -#endif // wxUSE_UNICODE -#if !wxUSE_UNICODE_WCHAR -WX_DECLARE_HASH_MAP(wxString*, wchar_t*, wxPointerHash, wxPointerEqual, - wxStringWCharConversionCache); -static wxStringWCharConversionCache gs_stringsWCharCache; - -const wchar_t* wxCStrData::AsWChar() const +int STRINGCLASS::compare(size_t nStart, size_t nLen, + const wxStringBase& str) const { - // remove previously cache value, if any (see FIXMEs above): - DeleteStringFromConversionCache(gs_stringsWCharCache, m_str); - - // convert the string and keep it: - const wchar_t *s = gs_stringsWCharCache[wxConstCast(m_str, wxString)] = - m_str->wc_str().release(); - - return s + m_offset; + wxASSERT(nStart <= length()); + size_type strLen = length() - nStart; + nLen = strLen < nLen ? strLen : nLen; + return ::wxDoCmp(data() + nStart, nLen, str.data(), str.length()); } -#endif // !wxUSE_UNICODE_WCHAR -wxString::~wxString() +int STRINGCLASS::compare(size_t nStart, size_t nLen, + const wxStringBase& str, + size_t nStart2, size_t nLen2) const { -#if wxUSE_UNICODE - // FIXME-UTF8: do this only if locale is not UTF8 if wxUSE_UNICODE_UTF8 - DeleteStringFromConversionCache(gs_stringsCharCache, this); -#endif -#if !wxUSE_UNICODE_WCHAR - DeleteStringFromConversionCache(gs_stringsWCharCache, this); -#endif + wxASSERT(nStart <= length()); + wxASSERT(nStart2 <= str.length()); + size_type strLen = length() - nStart, + strLen2 = str.length() - nStart2; + nLen = strLen < nLen ? strLen : nLen; + nLen2 = strLen2 < nLen2 ? strLen2 : nLen2; + return ::wxDoCmp(data() + nStart, nLen, str.data() + nStart2, nLen2); } -#endif + +int STRINGCLASS::compare(const wxChar* sz) const +{ + size_t nLen = wxStrlen(sz); + return ::wxDoCmp(data(), length(), sz, nLen); +} + +int STRINGCLASS::compare(size_t nStart, size_t nLen, + const wxChar* sz, size_t nCount) const +{ + wxASSERT(nStart <= length()); + size_type strLen = length() - nStart; + nLen = strLen < nLen ? strLen : nLen; + if( nCount == npos ) + nCount = wxStrlen(sz); + + return ::wxDoCmp(data() + nStart, nLen, sz, nCount); +} + +#undef STRINGCLASS + +#endif // !wxUSE_STL || !defined(HAVE_STD_STRING_COMPARE) // =========================================================================== // wxString class core @@ -382,183 +1004,66 @@ wxString::~wxString() // construction and conversion // --------------------------------------------------------------------------- -#if wxUSE_UNICODE_WCHAR -/* static */ -wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength, - const wxMBConv& conv) -{ - // anything to do? - if ( !psz || nLength == 0 ) - return SubstrBufFromMB(wxWCharBuffer(L""), 0); - - if ( nLength == npos ) - nLength = wxNO_LEN; - - size_t wcLen; - wxScopedWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen)); - if ( !wcLen ) - return SubstrBufFromMB(wxWCharBuffer(L""), 0); - else - return SubstrBufFromMB(wcBuf, wcLen); -} -#endif // wxUSE_UNICODE_WCHAR - -#if wxUSE_UNICODE_UTF8 -/* static */ -wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength, - const wxMBConv& conv) -{ - // anything to do? - if ( !psz || nLength == 0 ) - return SubstrBufFromMB(wxCharBuffer(""), 0); - - // if psz is already in UTF-8, we don't have to do the roundtrip to - // wchar_t* and back: - if ( conv.IsUTF8() ) - { - // we need to validate the input because UTF8 iterators assume valid - // UTF-8 sequence and psz may be invalid: - if ( wxStringOperations::IsValidUtf8String(psz, nLength) ) - { - // we must pass the real string length to SubstrBufFromMB ctor - if ( nLength == npos ) - nLength = psz ? strlen(psz) : 0; - return SubstrBufFromMB(wxScopedCharBuffer::CreateNonOwned(psz, nLength), - nLength); - } - // else: do the roundtrip through wchar_t* - } - - if ( nLength == npos ) - nLength = wxNO_LEN; - - // first convert to wide string: - size_t wcLen; - wxScopedWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen)); - if ( !wcLen ) - return SubstrBufFromMB(wxCharBuffer(""), 0); - - // and then to UTF-8: - SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvStrictUTF8())); - // widechar -> UTF-8 conversion isn't supposed to ever fail: - wxASSERT_MSG( buf.data, wxT("conversion to UTF-8 failed") ); - - return buf; -} -#endif // wxUSE_UNICODE_UTF8 - -#if wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE -/* static */ -wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLength, - const wxMBConv& conv) -{ - // anything to do? - if ( !pwz || nLength == 0 ) - return SubstrBufFromWC(wxCharBuffer(""), 0); - - if ( nLength == npos ) - nLength = wxNO_LEN; - - size_t mbLen; - wxScopedCharBuffer mbBuf(conv.cWC2MB(pwz, nLength, &mbLen)); - if ( !mbLen ) - return SubstrBufFromWC(wxCharBuffer(""), 0); - else - return SubstrBufFromWC(mbBuf, mbLen); -} -#endif // wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE - -// This std::string::c_str()-like method returns a wide char pointer to string -// contents. In wxUSE_UNICODE_WCHAR case it is trivial as it can simply return -// a pointer to the internal representation. Otherwise a conversion is required -// and it returns a temporary buffer. -// -// However for compatibility with c_str() and to avoid breaking existing code -// doing -// -// for ( const wchar_t *p = s.wc_str(); *p; p++ ) -// ... use *p... -// -// we actually need to ensure that the returned buffer is _not_ temporary and -// so we use wxString::m_convertedToWChar to store the returned data -#if !wxUSE_UNICODE_WCHAR - -const wchar_t *wxString::AsWChar(const wxMBConv& conv) const -{ - const char * const strMB = m_impl.c_str(); - const size_t lenMB = m_impl.length(); - - // find out the size of the buffer needed - const size_t lenWC = conv.ToWChar(NULL, 0, strMB, lenMB); - if ( lenWC == wxCONV_FAILED ) - return NULL; - - // keep the same buffer if the string size didn't change: this is not only - // an optimization but also ensure that code which modifies string - // character by character (without changing its length) can continue to use - // the pointer returned by a previous wc_str() call even after changing the - // string - - // TODO-UTF8: we could check for ">" instead of "!=" here as this would - // allow to save on buffer reallocations but at the cost of - // consuming (even) more memory, we should benchmark this to - // determine if it's worth doing - if ( !m_convertedToWChar.m_str || lenWC != m_convertedToWChar.m_len ) - { - if ( !const_cast(this)->m_convertedToWChar.Extend(lenWC) ) - return NULL; - } - - // finally do convert - m_convertedToWChar.m_str[lenWC] = L'\0'; - if ( conv.ToWChar(m_convertedToWChar.m_str, lenWC, - strMB, lenMB) == wxCONV_FAILED ) - return NULL; - - return m_convertedToWChar.m_str; -} - -#endif // !wxUSE_UNICODE_WCHAR - - -// Same thing for mb_str() which returns a normal char pointer to string -// contents: this always requires converting it to the specified encoding in -// non-ANSI build except if we need to convert to UTF-8 and this is what we -// already use internally. #if wxUSE_UNICODE -const char *wxString::AsChar(const wxMBConv& conv) const +// from multibyte string +wxString::wxString(const char *psz, const wxMBConv& conv, size_t nLength) { -#if wxUSE_UNICODE_UTF8 - if ( conv.IsUTF8() ) - return m_impl.c_str(); - - const wchar_t * const strWC = AsWChar(wxMBConvStrictUTF8()); - const size_t lenWC = m_convertedToWChar.m_len; -#else // wxUSE_UNICODE_WCHAR - const wchar_t * const strWC = m_impl.c_str(); - const size_t lenWC = m_impl.length(); -#endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR - - const size_t lenMB = conv.FromWChar(NULL, 0, strWC, lenWC); - if ( lenMB == wxCONV_FAILED ) - return NULL; - - if ( !m_convertedToChar.m_str || lenMB != m_convertedToChar.m_len ) + // anything to do? + if ( psz && nLength != 0 ) { - if ( !const_cast(this)->m_convertedToChar.Extend(lenMB) ) - return NULL; + if ( nLength == npos ) + { + nLength = wxNO_LEN; + } + + size_t nLenWide; + wxWCharBuffer wbuf = conv.cMB2WC(psz, nLength, &nLenWide); + + if ( nLenWide ) + assign(wbuf, nLenWide); } - - m_convertedToChar.m_str[lenMB] = '\0'; - if ( conv.FromWChar(m_convertedToChar.m_str, lenMB, - strWC, lenWC) == wxCONV_FAILED ) - return NULL; - - return m_convertedToChar.m_str; } -#endif // wxUSE_UNICODE +//Convert wxString in Unicode mode to a multi-byte string +const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const +{ + return conv.cWC2MB(c_str(), length() + 1 /* size, not length */, NULL); +} + +#else // ANSI + +#if wxUSE_WCHAR_T + +// from wide string +wxString::wxString(const wchar_t *pwz, const wxMBConv& conv, size_t nLength) +{ + // anything to do? + if ( pwz && nLength != 0 ) + { + if ( nLength == npos ) + { + nLength = wxNO_LEN; + } + + size_t nLenMB; + wxCharBuffer buf = conv.cWC2MB(pwz, nLength, &nLenMB); + + if ( nLenMB ) + assign(buf, nLenMB); + } +} + +//Converts this string to a wide character string if unicode +//mode is not enabled and wxUSE_WCHAR_T is enabled +const wxWCharBuffer wxString::wc_str(const wxMBConv& conv) const +{ + return conv.cMB2WC(c_str(), length() + 1 /* size, not length */, NULL); +} + +#endif // wxUSE_WCHAR_T + +#endif // Unicode/ANSI // shrink to minimal size (releasing extra memory) bool wxString::Shrink() @@ -568,24 +1073,39 @@ bool wxString::Shrink() return tmp.length() == length(); } -// deprecated compatibility code: -#if WXWIN_COMPATIBILITY_2_8 && !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 -wxStringCharType *wxString::GetWriteBuf(size_t nLen) +#if !wxUSE_STL +// get the pointer to writable buffer of (at least) nLen bytes +wxChar *wxString::GetWriteBuf(size_t nLen) { - return DoGetWriteBuf(nLen); + if ( !AllocBeforeWrite(nLen) ) { + // allocation failure handled by caller + return NULL; + } + + wxASSERT( GetStringData()->nRefs == 1 ); + GetStringData()->Validate(false); + + return m_pchData; } +// put string back in a reasonable state after GetWriteBuf void wxString::UngetWriteBuf() { - DoUngetWriteBuf(); + UngetWriteBuf(wxStrlen(m_pchData)); } void wxString::UngetWriteBuf(size_t nLen) { - DoUngetWriteBuf(nLen); -} -#endif // WXWIN_COMPATIBILITY_2_8 && !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8 + wxStringData * const pData = GetStringData(); + wxASSERT_MSG( nLen < pData->nAllocLength, _T("buffer overrun") ); + + // the strings we store are always NUL-terminated + pData->data()[nLen] = _T('\0'); + pData->nDataLength = nLen; + pData->Validate(true); +} +#endif // !wxUSE_STL // --------------------------------------------------------------------------- // data access @@ -594,9 +1114,29 @@ void wxString::UngetWriteBuf(size_t nLen) // all functions are inline in string.h // --------------------------------------------------------------------------- -// concatenation operators +// assignment operators // --------------------------------------------------------------------------- +#if !wxUSE_UNICODE + +// same as 'signed char' variant +wxString& wxString::operator=(const unsigned char* psz) +{ + *this = (const char *)psz; + return *this; +} + +#if wxUSE_WCHAR_T +wxString& wxString::operator=(const wchar_t *pwz) +{ + wxString str(pwz); + swap(str); + return *this; +} +#endif + +#endif + /* * concatenation functions come in 5 flavours: * string + string @@ -606,9 +1146,9 @@ void wxString::UngetWriteBuf(size_t nLen) wxString operator+(const wxString& str1, const wxString& str2) { -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str1.IsValid() ); - wxASSERT( str2.IsValid() ); +#if !wxUSE_STL + wxASSERT( str1.GetStringData()->IsValid() ); + wxASSERT( str2.GetStringData()->IsValid() ); #endif wxString s = str1; @@ -617,10 +1157,10 @@ wxString operator+(const wxString& str1, const wxString& str2) return s; } -wxString operator+(const wxString& str, wxUniChar ch) +wxString operator+(const wxString& str, wxChar ch) { -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); +#if !wxUSE_STL + wxASSERT( str.GetStringData()->IsValid() ); #endif wxString s = str; @@ -629,10 +1169,10 @@ wxString operator+(const wxString& str, wxUniChar ch) return s; } -wxString operator+(wxUniChar ch, const wxString& str) +wxString operator+(wxChar ch, const wxString& str) { -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); +#if !wxUSE_STL + wxASSERT( str.GetStringData()->IsValid() ); #endif wxString s = ch; @@ -641,15 +1181,15 @@ wxString operator+(wxUniChar ch, const wxString& str) return s; } -wxString operator+(const wxString& str, const char *psz) +wxString operator+(const wxString& str, const wxChar *psz) { -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); +#if !wxUSE_STL + wxASSERT( str.GetStringData()->IsValid() ); #endif wxString s; - if ( !s.Alloc(strlen(psz) + str.length()) ) { - wxFAIL_MSG( wxT("out of memory in wxString::operator+") ); + if ( !s.Alloc(wxStrlen(psz) + str.length()) ) { + wxFAIL_MSG( _T("out of memory in wxString::operator+") ); } s += str; s += psz; @@ -657,31 +1197,15 @@ wxString operator+(const wxString& str, const char *psz) return s; } -wxString operator+(const wxString& str, const wchar_t *pwz) +wxString operator+(const wxChar *psz, const wxString& str) { -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); +#if !wxUSE_STL + wxASSERT( str.GetStringData()->IsValid() ); #endif wxString s; - if ( !s.Alloc(wxWcslen(pwz) + str.length()) ) { - wxFAIL_MSG( wxT("out of memory in wxString::operator+") ); - } - s += str; - s += pwz; - - return s; -} - -wxString operator+(const char *psz, const wxString& str) -{ -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); -#endif - - wxString s; - if ( !s.Alloc(strlen(psz) + str.length()) ) { - wxFAIL_MSG( wxT("out of memory in wxString::operator+") ); + if ( !s.Alloc(wxStrlen(psz) + str.length()) ) { + wxFAIL_MSG( _T("out of memory in wxString::operator+") ); } s = psz; s += str; @@ -689,548 +1213,132 @@ wxString operator+(const char *psz, const wxString& str) return s; } -wxString operator+(const wchar_t *pwz, const wxString& str) -{ -#if !wxUSE_STL_BASED_WXSTRING - wxASSERT( str.IsValid() ); -#endif - - wxString s; - if ( !s.Alloc(wxWcslen(pwz) + str.length()) ) { - wxFAIL_MSG( wxT("out of memory in wxString::operator+") ); - } - s = pwz; - s += str; - - return s; -} - -// --------------------------------------------------------------------------- -// string comparison -// --------------------------------------------------------------------------- - -bool wxString::IsSameAs(wxUniChar c, bool compareWithCase) const -{ - return (length() == 1) && (compareWithCase ? GetChar(0u) == c - : wxToupper(GetChar(0u)) == wxToupper(c)); -} - -#ifdef HAVE_STD_STRING_COMPARE - -// NB: Comparison code (both if HAVE_STD_STRING_COMPARE and if not) works with -// UTF-8 encoded strings too, thanks to UTF-8's design which allows us to -// sort strings in characters code point order by sorting the byte sequence -// in byte values order (i.e. what strcmp() and memcmp() do). - -int wxString::compare(const wxString& str) const -{ - return m_impl.compare(str.m_impl); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wxString& str) const -{ - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - return m_impl.compare(pos, len, str.m_impl); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wxString& str, - size_t nStart2, size_t nLen2) const -{ - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - size_t pos2, len2; - str.PosLenToImpl(nStart2, nLen2, &pos2, &len2); - - return m_impl.compare(pos, len, str.m_impl, pos2, len2); -} - -int wxString::compare(const char* sz) const -{ - return m_impl.compare(ImplStr(sz)); -} - -int wxString::compare(const wchar_t* sz) const -{ - return m_impl.compare(ImplStr(sz)); -} - -int wxString::compare(size_t nStart, size_t nLen, - const char* sz, size_t nCount) const -{ - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - SubstrBufFromMB str(ImplStr(sz, nCount)); - - return m_impl.compare(pos, len, str.data, str.len); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wchar_t* sz, size_t nCount) const -{ - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - SubstrBufFromWC str(ImplStr(sz, nCount)); - - return m_impl.compare(pos, len, str.data, str.len); -} - -#else // !HAVE_STD_STRING_COMPARE - -static inline int wxDoCmp(const wxStringCharType* s1, size_t l1, - const wxStringCharType* s2, size_t l2) -{ - if( l1 == l2 ) - return wxStringMemcmp(s1, s2, l1); - else if( l1 < l2 ) - { - int ret = wxStringMemcmp(s1, s2, l1); - return ret == 0 ? -1 : ret; - } - else - { - int ret = wxStringMemcmp(s1, s2, l2); - return ret == 0 ? +1 : ret; - } -} - -int wxString::compare(const wxString& str) const -{ - return ::wxDoCmp(m_impl.data(), m_impl.length(), - str.m_impl.data(), str.m_impl.length()); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wxString& str) const -{ - wxASSERT(nStart <= length()); - size_type strLen = length() - nStart; - nLen = strLen < nLen ? strLen : nLen; - - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - return ::wxDoCmp(m_impl.data() + pos, len, - str.m_impl.data(), str.m_impl.length()); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wxString& str, - size_t nStart2, size_t nLen2) const -{ - wxASSERT(nStart <= length()); - wxASSERT(nStart2 <= str.length()); - size_type strLen = length() - nStart, - strLen2 = str.length() - nStart2; - nLen = strLen < nLen ? strLen : nLen; - nLen2 = strLen2 < nLen2 ? strLen2 : nLen2; - - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - size_t pos2, len2; - str.PosLenToImpl(nStart2, nLen2, &pos2, &len2); - - return ::wxDoCmp(m_impl.data() + pos, len, - str.m_impl.data() + pos2, len2); -} - -int wxString::compare(const char* sz) const -{ - SubstrBufFromMB str(ImplStr(sz, npos)); - if ( str.len == npos ) - str.len = wxStringStrlen(str.data); - return ::wxDoCmp(m_impl.data(), m_impl.length(), str.data, str.len); -} - -int wxString::compare(const wchar_t* sz) const -{ - SubstrBufFromWC str(ImplStr(sz, npos)); - if ( str.len == npos ) - str.len = wxStringStrlen(str.data); - return ::wxDoCmp(m_impl.data(), m_impl.length(), str.data, str.len); -} - -int wxString::compare(size_t nStart, size_t nLen, - const char* sz, size_t nCount) const -{ - wxASSERT(nStart <= length()); - size_type strLen = length() - nStart; - nLen = strLen < nLen ? strLen : nLen; - - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - SubstrBufFromMB str(ImplStr(sz, nCount)); - if ( str.len == npos ) - str.len = wxStringStrlen(str.data); - - return ::wxDoCmp(m_impl.data() + pos, len, str.data, str.len); -} - -int wxString::compare(size_t nStart, size_t nLen, - const wchar_t* sz, size_t nCount) const -{ - wxASSERT(nStart <= length()); - size_type strLen = length() - nStart; - nLen = strLen < nLen ? strLen : nLen; - - size_t pos, len; - PosLenToImpl(nStart, nLen, &pos, &len); - - SubstrBufFromWC str(ImplStr(sz, nCount)); - if ( str.len == npos ) - str.len = wxStringStrlen(str.data); - - return ::wxDoCmp(m_impl.data() + pos, len, str.data, str.len); -} - -#endif // HAVE_STD_STRING_COMPARE/!HAVE_STD_STRING_COMPARE - - -// --------------------------------------------------------------------------- -// find_{first,last}_[not]_of functions -// --------------------------------------------------------------------------- - -#if !wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 - -// NB: All these functions are implemented with the argument being wxChar*, -// i.e. widechar string in any Unicode build, even though native string -// representation is char* in the UTF-8 build. This is because we couldn't -// use memchr() to determine if a character is in a set encoded as UTF-8. - -size_t wxString::find_first_of(const wxChar* sz, size_t nStart) const -{ - return find_first_of(sz, nStart, wxStrlen(sz)); -} - -size_t wxString::find_first_not_of(const wxChar* sz, size_t nStart) const -{ - return find_first_not_of(sz, nStart, wxStrlen(sz)); -} - -size_t wxString::find_first_of(const wxChar* sz, size_t nStart, size_t n) const -{ - wxASSERT_MSG( nStart <= length(), wxT("invalid index") ); - - size_t idx = nStart; - for ( const_iterator i = begin() + nStart; i != end(); ++idx, ++i ) - { - if ( wxTmemchr(sz, *i, n) ) - return idx; - } - - return npos; -} - -size_t wxString::find_first_not_of(const wxChar* sz, size_t nStart, size_t n) const -{ - wxASSERT_MSG( nStart <= length(), wxT("invalid index") ); - - size_t idx = nStart; - for ( const_iterator i = begin() + nStart; i != end(); ++idx, ++i ) - { - if ( !wxTmemchr(sz, *i, n) ) - return idx; - } - - return npos; -} - - -size_t wxString::find_last_of(const wxChar* sz, size_t nStart) const -{ - return find_last_of(sz, nStart, wxStrlen(sz)); -} - -size_t wxString::find_last_not_of(const wxChar* sz, size_t nStart) const -{ - return find_last_not_of(sz, nStart, wxStrlen(sz)); -} - -size_t wxString::find_last_of(const wxChar* sz, size_t nStart, size_t n) const -{ - size_t len = length(); - - if ( nStart == npos ) - { - nStart = len - 1; - } - else - { - wxASSERT_MSG( nStart <= len, wxT("invalid index") ); - } - - size_t idx = nStart; - for ( const_reverse_iterator i = rbegin() + (len - nStart - 1); - i != rend(); --idx, ++i ) - { - if ( wxTmemchr(sz, *i, n) ) - return idx; - } - - return npos; -} - -size_t wxString::find_last_not_of(const wxChar* sz, size_t nStart, size_t n) const -{ - size_t len = length(); - - if ( nStart == npos ) - { - nStart = len - 1; - } - else - { - wxASSERT_MSG( nStart <= len, wxT("invalid index") ); - } - - size_t idx = nStart; - for ( const_reverse_iterator i = rbegin() + (len - nStart - 1); - i != rend(); --idx, ++i ) - { - if ( !wxTmemchr(sz, *i, n) ) - return idx; - } - - return npos; -} - -size_t wxString::find_first_not_of(wxUniChar ch, size_t nStart) const -{ - wxASSERT_MSG( nStart <= length(), wxT("invalid index") ); - - size_t idx = nStart; - for ( const_iterator i = begin() + nStart; i != end(); ++idx, ++i ) - { - if ( *i != ch ) - return idx; - } - - return npos; -} - -size_t wxString::find_last_not_of(wxUniChar ch, size_t nStart) const -{ - size_t len = length(); - - if ( nStart == npos ) - { - nStart = len - 1; - } - else - { - wxASSERT_MSG( nStart <= len, wxT("invalid index") ); - } - - size_t idx = nStart; - for ( const_reverse_iterator i = rbegin() + (len - nStart - 1); - i != rend(); --idx, ++i ) - { - if ( *i != ch ) - return idx; - } - - return npos; -} - -// the functions above were implemented for wchar_t* arguments in Unicode -// build and char* in ANSI build; below are implementations for the other -// version: -#if wxUSE_UNICODE - #define wxOtherCharType char - #define STRCONV (const wxChar*)wxConvLibc.cMB2WC -#else - #define wxOtherCharType wchar_t - #define STRCONV (const wxChar*)wxConvLibc.cWC2MB -#endif - -size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart) const - { return find_first_of(STRCONV(sz), nStart); } - -size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart, - size_t n) const - { return find_first_of(STRCONV(sz, n, NULL), nStart, n); } -size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart) const - { return find_last_of(STRCONV(sz), nStart); } -size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart, - size_t n) const - { return find_last_of(STRCONV(sz, n, NULL), nStart, n); } -size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart) const - { return find_first_not_of(STRCONV(sz), nStart); } -size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart, - size_t n) const - { return find_first_not_of(STRCONV(sz, n, NULL), nStart, n); } -size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart) const - { return find_last_not_of(STRCONV(sz), nStart); } -size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart, - size_t n) const - { return find_last_not_of(STRCONV(sz, n, NULL), nStart, n); } - -#undef wxOtherCharType -#undef STRCONV - -#endif // !wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 - // =========================================================================== // other common string functions // =========================================================================== +int wxString::Cmp(const wxString& s) const +{ + return compare(s); +} + +int wxString::Cmp(const wxChar* psz) const +{ + return compare(psz); +} + +static inline int wxDoCmpNoCase(const wxChar* s1, size_t l1, + const wxChar* s2, size_t l2) +{ + size_t i; + + if( l1 == l2 ) + { + for(i = 0; i < l1; ++i) + { + if(wxTolower(s1[i]) != wxTolower(s2[i])) + break; + } + return i == l1 ? 0 : wxTolower(s1[i]) < wxTolower(s2[i]) ? -1 : 1; + } + else if( l1 < l2 ) + { + for(i = 0; i < l1; ++i) + { + if(wxTolower(s1[i]) != wxTolower(s2[i])) + break; + } + return i == l1 ? -1 : wxTolower(s1[i]) < wxTolower(s2[i]) ? -1 : 1; + } + else + { + for(i = 0; i < l2; ++i) + { + if(wxTolower(s1[i]) != wxTolower(s2[i])) + break; + } + return i == l2 ? 1 : wxTolower(s1[i]) < wxTolower(s2[i]) ? -1 : 1; + } +} + int wxString::CmpNoCase(const wxString& s) const { -#if !wxUSE_UNICODE_UTF8 - // We compare NUL-delimited chunks of the strings inside the loop. We will - // do as many iterations as there are embedded NULs in the string, i.e. - // usually we will run it just once. + return wxDoCmpNoCase(data(), length(), s.data(), s.length()); +} - typedef const wxStringImpl::value_type *pchar_type; - const pchar_type thisBegin = m_impl.c_str(); - const pchar_type thatBegin = s.m_impl.c_str(); +int wxString::CmpNoCase(const wxChar* psz) const +{ + int nLen = wxStrlen(psz); - const pchar_type thisEnd = thisBegin + m_impl.length(); - const pchar_type thatEnd = thatBegin + s.m_impl.length(); - - pchar_type thisCur = thisBegin; - pchar_type thatCur = thatBegin; - - int rc; - for ( ;; ) - { - // Compare until the next NUL, if the strings differ this is the final - // result. - rc = wxStricmp(thisCur, thatCur); - if ( rc ) - break; - - const size_t lenChunk = wxStrlen(thisCur); - thisCur += lenChunk; - thatCur += lenChunk; - - // Skip all the NULs as wxStricmp() doesn't handle them. - for ( ; !*thisCur; thisCur++, thatCur++ ) - { - // Check if we exhausted either of the strings. - if ( thisCur == thisEnd ) - { - // This one is exhausted, is the other one too? - return thatCur == thatEnd ? 0 : -1; - } - - if ( thatCur == thatEnd ) - { - // Because of the test above we know that this one is not - // exhausted yet so it's greater than the other one that is. - return 1; - } - - if ( *thatCur ) - { - // Anything non-NUL is greater than NUL. - return -1; - } - } - } - - return rc; -#else // wxUSE_UNICODE_UTF8 - // CRT functions can't be used for case-insensitive comparison of UTF-8 - // strings so do it in the naive, simple and inefficient way. - - // FIXME-UTF8: use wxUniChar::ToLower/ToUpper once added - const_iterator i1 = begin(); - const_iterator end1 = end(); - const_iterator i2 = s.begin(); - const_iterator end2 = s.end(); - - for ( ; i1 != end1 && i2 != end2; ++i1, ++i2 ) - { - wxUniChar lower1 = (wxChar)wxTolower(*i1); - wxUniChar lower2 = (wxChar)wxTolower(*i2); - if ( lower1 != lower2 ) - return lower1 < lower2 ? -1 : 1; - } - - size_t len1 = length(); - size_t len2 = s.length(); - - if ( len1 < len2 ) - return -1; - else if ( len1 > len2 ) - return 1; - return 0; -#endif // !wxUSE_UNICODE_UTF8/wxUSE_UNICODE_UTF8 + return wxDoCmpNoCase(data(), length(), psz, nLen); } #if wxUSE_UNICODE -wxString wxString::FromAscii(const char *ascii, size_t len) +#ifdef __MWERKS__ +#ifndef __SCHAR_MAX__ +#define __SCHAR_MAX__ 127 +#endif +#endif + +wxString wxString::FromAscii(const char *ascii) { - if (!ascii || len == 0) + if (!ascii) return wxEmptyString; + size_t len = strlen( ascii ); wxString res; + if ( len ) { - wxStringInternalBuffer buf(res, len); - wxStringCharType *dest = buf; + wxStringBuffer buf(res, len); - for ( ; len > 0; --len ) + wchar_t *dest = buf; + + for ( ;; ) { - unsigned char c = (unsigned char)*ascii++; - wxASSERT_MSG( c < 0x80, - wxT("Non-ASCII value passed to FromAscii().") ); - - *dest++ = (wchar_t)c; + if ( (*dest++ = (wchar_t)(unsigned char)*ascii++) == L'\0' ) + break; } } return res; } -wxString wxString::FromAscii(const char *ascii) -{ - return FromAscii(ascii, wxStrlen(ascii)); -} - -wxString wxString::FromAscii(char ascii) +wxString wxString::FromAscii(const char ascii) { // What do we do with '\0' ? - unsigned char c = (unsigned char)ascii; + wxString res; + res += (wchar_t)(unsigned char) ascii; - wxASSERT_MSG( c < 0x80, wxT("Non-ASCII value passed to FromAscii().") ); - - // NB: the cast to wchar_t causes interpretation of 'ascii' as Latin1 value - return wxString(wxUniChar((wchar_t)c)); + return res; } -const wxScopedCharBuffer wxString::ToAscii() const +const wxCharBuffer wxString::ToAscii() const { // this will allocate enough space for the terminating NUL too wxCharBuffer buffer(length()); + + char *dest = buffer.data(); - for ( const_iterator i = begin(); i != end(); ++i ) + const wchar_t *pwc = c_str(); + for ( ;; ) { - wxUniChar c(*i); - // FIXME-UTF8: unify substituted char ('_') with wxUniChar ('?') - *dest++ = c.IsAscii() ? (char)c : '_'; + *dest++ = (char)(*pwc > SCHAR_MAX ? wxT('_') : *pwc); // the output string can't have embedded NULs anyhow, so we can safely // stop at first of them even if we do have any - if ( !c ) + if ( !*pwc++ ) break; } return buffer; } -#endif // wxUSE_UNICODE +#endif // Unicode // extract string of length nCount starting at nFirst wxString wxString::Mid(size_t nFirst, size_t nCount) const @@ -1244,21 +1352,21 @@ wxString wxString::Mid(size_t nFirst, size_t nCount) const } // out-of-bounds requests return sensible things + if ( nFirst + nCount > nLen ) + { + nCount = nLen - nFirst; + } + if ( nFirst > nLen ) { // AllocCopy() will return empty string return wxEmptyString; } - if ( nCount > nLen - nFirst ) - { - nCount = nLen - nFirst; - } - wxString dest(*this, nFirst, nCount); if ( dest.length() != nCount ) { - wxFAIL_MSG( wxT("out of memory in wxString::Mid") ); + wxFAIL_MSG( _T("out of memory in wxString::Mid") ); } return dest; @@ -1266,15 +1374,28 @@ wxString wxString::Mid(size_t nFirst, size_t nCount) const // check that the string starts with prefix and return the rest of the string // in the provided pointer if it is not NULL, otherwise return false -bool wxString::StartsWith(const wxString& prefix, wxString *rest) const +bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const { - if ( compare(0, prefix.length(), prefix) != 0 ) - return false; + wxASSERT_MSG( prefix, _T("invalid parameter in wxString::StartsWith") ); + + // first check if the beginning of the string matches the prefix: note + // that we don't have to check that we don't run out of this string as + // when we reach the terminating NUL, either prefix string ends too (and + // then it's ok) or we break out of the loop because there is no match + const wxChar *p = c_str(); + while ( *prefix ) + { + if ( *prefix++ != *p++ ) + { + // no match + return false; + } + } if ( rest ) { // put the rest of the string into provided pointer - rest->assign(*this, prefix.length(), npos); + *rest = p; } return true; @@ -1283,11 +1404,12 @@ bool wxString::StartsWith(const wxString& prefix, wxString *rest) const // check that the string ends with suffix and return the rest of it in the // provided pointer if it is not NULL, otherwise return false -bool wxString::EndsWith(const wxString& suffix, wxString *rest) const +bool wxString::EndsWith(const wxChar *suffix, wxString *rest) const { - int start = length() - suffix.length(); + wxASSERT_MSG( suffix, _T("invalid parameter in wxString::EndssWith") ); - if ( start < 0 || compare(start, npos, suffix) != 0 ) + int start = length() - wxStrlen(suffix); + if ( start < 0 || wxStrcmp(c_str() + start, suffix) != 0 ) return false; if ( rest ) @@ -1308,21 +1430,21 @@ wxString wxString::Right(size_t nCount) const wxString dest(*this, length() - nCount, nCount); if ( dest.length() != nCount ) { - wxFAIL_MSG( wxT("out of memory in wxString::Right") ); + wxFAIL_MSG( _T("out of memory in wxString::Right") ); } return dest; } -// get all characters after the last occurrence of ch +// get all characters after the last occurence of ch // (returns the whole string if ch not found) -wxString wxString::AfterLast(wxUniChar ch) const +wxString wxString::AfterLast(wxChar ch) const { wxString str; int iPos = Find(ch, true); if ( iPos == wxNOT_FOUND ) str = *this; else - str.assign(*this, iPos + 1, npos); + str = c_str() + iPos + 1; return str; } @@ -1335,97 +1457,66 @@ wxString wxString::Left(size_t nCount) const wxString dest(*this, 0, nCount); if ( dest.length() != nCount ) { - wxFAIL_MSG( wxT("out of memory in wxString::Left") ); + wxFAIL_MSG( _T("out of memory in wxString::Left") ); } return dest; } -// get all characters before the first occurrence of ch +// get all characters before the first occurence of ch // (returns the whole string if ch not found) -wxString wxString::BeforeFirst(wxUniChar ch, wxString *rest) const +wxString wxString::BeforeFirst(wxChar ch) const { int iPos = Find(ch); - if ( iPos == wxNOT_FOUND ) - { - iPos = length(); - if ( rest ) - rest->clear(); - } - else - { - if ( rest ) - rest->assign(*this, iPos + 1, npos); - } - + if ( iPos == wxNOT_FOUND ) iPos = length(); return wxString(*this, 0, iPos); } -/// get all characters before the last occurrence of ch +/// get all characters before the last occurence of ch /// (returns empty string if ch not found) -wxString wxString::BeforeLast(wxUniChar ch, wxString *rest) const +wxString wxString::BeforeLast(wxChar ch) const { wxString str; int iPos = Find(ch, true); - if ( iPos != wxNOT_FOUND ) - { - if ( iPos != 0 ) - str.assign(*this, 0, iPos); - - if ( rest ) - rest->assign(*this, iPos + 1, npos); - } - else - { - if ( rest ) - *rest = *this; - } + if ( iPos != wxNOT_FOUND && iPos != 0 ) + str = wxString(c_str(), iPos); return str; } -/// get all characters after the first occurrence of ch +/// get all characters after the first occurence of ch /// (returns empty string if ch not found) -wxString wxString::AfterFirst(wxUniChar ch) const +wxString wxString::AfterFirst(wxChar ch) const { wxString str; int iPos = Find(ch); if ( iPos != wxNOT_FOUND ) - str.assign(*this, iPos + 1, npos); + str = c_str() + iPos + 1; return str; } -// replace first (or all) occurrences of some substring with another one -size_t wxString::Replace(const wxString& strOld, - const wxString& strNew, bool bReplaceAll) +// replace first (or all) occurences of some substring with another one +size_t +wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll) { // if we tried to replace an empty string we'd enter an infinite loop below - wxCHECK_MSG( !strOld.empty(), 0, - wxT("wxString::Replace(): invalid parameter") ); - - wxSTRING_INVALIDATE_CACHE(); + wxCHECK_MSG( szOld && *szOld && szNew, 0, + _T("wxString::Replace(): invalid parameter") ); size_t uiCount = 0; // count of replacements made - // optimize the special common case: replacement of one character by - // another one (in UTF-8 case we can only do this for ASCII characters) - // - // benchmarks show that this special version is around 3 times faster - // (depending on the proportion of matching characters and UTF-8/wchar_t - // build) - if ( strOld.m_impl.length() == 1 && strNew.m_impl.length() == 1 ) + // optimize the special common case of replacing one character with another + // one + if ( szOld[1] == '\0' && (szNew[0] != '\0' && szNew[1] == '\0') ) { - const wxStringCharType chOld = strOld.m_impl[0], - chNew = strNew.m_impl[0]; - // this loop is the simplified version of the one below for ( size_t pos = 0; ; ) { - pos = m_impl.find(chOld, pos); + pos = find(*szOld, pos); if ( pos == npos ) break; - m_impl[pos++] = chNew; + (*this)[pos++] = *szNew; uiCount++; @@ -1433,106 +1524,65 @@ size_t wxString::Replace(const wxString& strOld, break; } } - else if ( !bReplaceAll) + else // general case { - size_t pos = m_impl.find(strOld.m_impl, 0); - if ( pos != npos ) + const size_t uiOldLen = wxStrlen(szOld); + const size_t uiNewLen = wxStrlen(szNew); + + for ( size_t pos = 0; ; ) { - m_impl.replace(pos, strOld.m_impl.length(), strNew.m_impl); - uiCount = 1; + pos = find(szOld, pos); + if ( pos == npos ) + break; + + // replace this occurrence of the old string with the new one + replace(pos, uiOldLen, szNew, uiNewLen); + + // move past the string that was replaced + pos += uiNewLen; + + // increase replace count + uiCount++; + + // stop now? + if ( !bReplaceAll ) + break; } } - else // replace all occurrences - { - const size_t uiOldLen = strOld.m_impl.length(); - const size_t uiNewLen = strNew.m_impl.length(); - - // first scan the string to find all positions at which the replacement - // should be made - wxVector replacePositions; - - size_t pos; - for ( pos = m_impl.find(strOld.m_impl, 0); - pos != npos; - pos = m_impl.find(strOld.m_impl, pos + uiOldLen)) - { - replacePositions.push_back(pos); - ++uiCount; - } - - if ( !uiCount ) - return 0; - - // allocate enough memory for the whole new string - wxString tmp; - tmp.m_impl.reserve(m_impl.length() + uiCount*(uiNewLen - uiOldLen)); - - // copy this string to tmp doing replacements on the fly - size_t replNum = 0; - for ( pos = 0; replNum < uiCount; replNum++ ) - { - const size_t nextReplPos = replacePositions[replNum]; - - if ( pos != nextReplPos ) - { - tmp.m_impl.append(m_impl, pos, nextReplPos - pos); - } - - tmp.m_impl.append(strNew.m_impl); - pos = nextReplPos + uiOldLen; - } - - if ( pos != m_impl.length() ) - { - // append the rest of the string unchanged - tmp.m_impl.append(m_impl, pos, m_impl.length() - pos); - } - - swap(tmp); - } return uiCount; } bool wxString::IsAscii() const { - for ( const_iterator i = begin(); i != end(); ++i ) - { - if ( !(*i).IsAscii() ) - return false; - } - - return true; + const wxChar *s = (const wxChar*) *this; + while(*s){ + if(!isascii(*s)) return(false); + s++; + } + return(true); } bool wxString::IsWord() const { - for ( const_iterator i = begin(); i != end(); ++i ) - { - if ( !wxIsalpha(*i) ) - return false; - } - - return true; + const wxChar *s = (const wxChar*) *this; + while(*s){ + if(!wxIsalpha(*s)) return(false); + s++; + } + return(true); } bool wxString::IsNumber() const { - if ( empty() ) - return true; - - const_iterator i = begin(); - - if ( *i == wxT('-') || *i == wxT('+') ) - ++i; - - for ( ; i != end(); ++i ) - { - if ( !wxIsdigit(*i) ) - return false; - } - - return true; + const wxChar *s = (const wxChar*) *this; + if (wxStrlen(s)) + if ((s[0] == wxT('-')) || (s[0] == wxT('+'))) s++; + while(*s){ + if(!wxIsdigit(*s)) return(false); + s++; + } + return(true); } wxString wxString::Strip(stripType w) const @@ -1563,27 +1613,13 @@ wxString& wxString::MakeLower() return *this; } -wxString& wxString::MakeCapitalized() -{ - const iterator en = end(); - iterator it = begin(); - if ( it != en ) - { - *it = (wxChar)wxToupper(*it); - for ( ++it; it != en; ++it ) - *it = (wxChar)wxTolower(*it); - } - - return *this; -} - // --------------------------------------------------------------------------- // trimming and padding // --------------------------------------------------------------------------- // some compilers (VC++ 6.0 not to name them) return true for a call to // isspace('\xEA') in the C locale which seems to be broken to me, but we have -// to live with this by checking that the character is a 7 bit one - even if +// to live with this by checking that the character is a 7 bit one - even if // this may fail to detect some spaces (I don't know if Unicode doesn't have // space-like symbols somewhere except in the first 128 chars), it is arguably // still better than trimming away accented letters @@ -1605,7 +1641,7 @@ wxString& wxString::Trim(bool bFromRight) // find last non-space character reverse_iterator psz = rbegin(); while ( (psz != rend()) && wxSafeIsspace(*psz) ) - ++psz; + psz++; // truncate at trailing space start erase(psz.base(), end()); @@ -1615,7 +1651,7 @@ wxString& wxString::Trim(bool bFromRight) // find first non-space character iterator psz = begin(); while ( (psz != end()) && wxSafeIsspace(*psz) ) - ++psz; + psz++; // fix up data and length erase(begin(), psz); @@ -1626,7 +1662,7 @@ wxString& wxString::Trim(bool bFromRight) } // adds nCount characters chPad to the string from either side -wxString& wxString::Pad(size_t nCount, wxUniChar chPad, bool bFromRight) +wxString& wxString::Pad(size_t nCount, wxChar chPad, bool bFromRight) { wxString s(chPad, nCount); @@ -1658,320 +1694,145 @@ wxString& wxString::Truncate(size_t uiLen) // --------------------------------------------------------------------------- // find a character -int wxString::Find(wxUniChar ch, bool bFromEnd) const +int wxString::Find(wxChar ch, bool bFromEnd) const { size_type idx = bFromEnd ? find_last_of(ch) : find_first_of(ch); return (idx == npos) ? wxNOT_FOUND : (int)idx; } +// find a sub-string (like strstr) +int wxString::Find(const wxChar *pszSub) const +{ + size_type idx = find(pszSub); + + return (idx == npos) ? wxNOT_FOUND : (int)idx; +} + // ---------------------------------------------------------------------------- // conversion to numbers // ---------------------------------------------------------------------------- -// The implementation of all the functions below is exactly the same so factor -// it out. Note that number extraction works correctly on UTF-8 strings, so -// we can use wxStringCharType and wx_str() for maximum efficiency. +// the implementation of all the functions below is exactly the same so factor +// it out + +template +bool wxStringToIntType(const wxChar *start, + T *val, + int base, + F func) +{ + wxCHECK_MSG( val, false, _T("NULL output pointer") ); + wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); #ifndef __WXWINCE__ - #define DO_IF_NOT_WINCE(x) x -#else - #define DO_IF_NOT_WINCE(x) + errno = 0; #endif -#define WX_STRING_TO_X_TYPE_START \ - wxCHECK_MSG( pVal, false, wxT("NULL output pointer") ); \ - DO_IF_NOT_WINCE( errno = 0; ) \ - const wxStringCharType *start = wx_str(); \ - wxStringCharType *end; + wxChar *end; + *val = (*func)(start, &end, base); -// notice that we return false without modifying the output parameter at all if -// nothing could be parsed but we do modify it and return false then if we did -// parse something successfully but not the entire string -#define WX_STRING_TO_X_TYPE_END \ - if ( end == start DO_IF_NOT_WINCE(|| errno == ERANGE) ) \ - return false; \ - *pVal = val; \ - return !*end; - -bool wxString::ToLong(long *pVal, int base) const -{ - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); - - WX_STRING_TO_X_TYPE_START - long val = wxStrtol(start, &end, base); - WX_STRING_TO_X_TYPE_END -} - -bool wxString::ToULong(unsigned long *pVal, int base) const -{ - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); - - WX_STRING_TO_X_TYPE_START - unsigned long val = wxStrtoul(start, &end, base); - WX_STRING_TO_X_TYPE_END -} - -bool wxString::ToLongLong(wxLongLong_t *pVal, int base) const -{ - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); - - WX_STRING_TO_X_TYPE_START - wxLongLong_t val = wxStrtoll(start, &end, base); - WX_STRING_TO_X_TYPE_END -} - -bool wxString::ToULongLong(wxULongLong_t *pVal, int base) const -{ - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); - - WX_STRING_TO_X_TYPE_START - wxULongLong_t val = wxStrtoull(start, &end, base); - WX_STRING_TO_X_TYPE_END -} - -bool wxString::ToDouble(double *pVal) const -{ - WX_STRING_TO_X_TYPE_START - double val = wxStrtod(start, &end); - WX_STRING_TO_X_TYPE_END -} - -#if wxUSE_XLOCALE - -bool wxString::ToCLong(long *pVal, int base) const -{ - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); - - WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) - long val = wxStrtol_lA(start, &end, base, wxCLocale); -#else - long val = wxStrtol_l(start, &end, base, wxCLocale); + // return true only if scan was stopped by the terminating NUL and if the + // string was not empty to start with and no under/overflow occurred + return !*end && (end != start) +#ifndef __WXWINCE__ + && (errno != ERANGE) #endif - WX_STRING_TO_X_TYPE_END + ; } -bool wxString::ToCULong(unsigned long *pVal, int base) const +bool wxString::ToLong(long *val, int base) const { - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); + return wxStringToIntType(c_str(), val, base, wxStrtol); +} - WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) - unsigned long val = wxStrtoul_lA(start, &end, base, wxCLocale); +bool wxString::ToULong(unsigned long *val, int base) const +{ + return wxStringToIntType(c_str(), val, base, wxStrtoul); +} + +bool wxString::ToLongLong(wxLongLong_t *val, int base) const +{ +#ifdef wxHAS_STRTOLL + return wxStringToIntType(c_str(), val, base, wxStrtoll); #else - unsigned long val = wxStrtoul_l(start, &end, base, wxCLocale); -#endif - WX_STRING_TO_X_TYPE_END + // TODO: implement this ourselves + wxUnusedVar(val); + wxUnusedVar(base); + return false; +#endif // wxHAS_STRTOLL } -bool wxString::ToCDouble(double *pVal) const +bool wxString::ToULongLong(wxULongLong_t *val, int base) const { - WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) - double val = wxStrtod_lA(start, &end, wxCLocale); +#ifdef wxHAS_STRTOLL + return wxStringToIntType(c_str(), val, base, wxStrtoull); #else - double val = wxStrtod_l(start, &end, wxCLocale); + // TODO: implement this ourselves + wxUnusedVar(val); + wxUnusedVar(base); + return false; #endif - WX_STRING_TO_X_TYPE_END } -#else // wxUSE_XLOCALE - -// Provide implementation of these functions even when wxUSE_XLOCALE is -// disabled, we still need them in wxWidgets internal code. - -// For integers we just assume the current locale uses the same number -// representation as the C one as there is nothing else we can do. -bool wxString::ToCLong(long *pVal, int base) const +bool wxString::ToDouble(double *val) const { - return ToLong(pVal, base); -} + wxCHECK_MSG( val, false, _T("NULL pointer in wxString::ToDouble") ); -bool wxString::ToCULong(unsigned long *pVal, int base) const -{ - return ToULong(pVal, base); -} +#ifndef __WXWINCE__ + errno = 0; +#endif -// For floating point numbers we have to handle the problem of the decimal -// point which is different in different locales. -bool wxString::ToCDouble(double *pVal) const -{ - // See the explanations in FromCDouble() below for the reasons for all this. + const wxChar *start = c_str(); + wxChar *end; + *val = wxStrtod(start, &end); - // Create a copy of this string using the decimal point instead of whatever - // separator the current locale uses. -#if wxUSE_INTL - wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, - wxLOCALE_CAT_NUMBER); - if ( sep == "." ) - { - // We can avoid an unnecessary string copy in this case. - return ToDouble(pVal); - } -#else // !wxUSE_INTL - // We don't know what the current separator is so it might even be a point - // already, try to parse the string as a double: - if ( ToDouble(pVal) ) - { - // It must have been the point, nothing else to do. - return true; - } - - // Try to guess the separator, using the most common alternative value. - wxString sep(","); -#endif // wxUSE_INTL/!wxUSE_INTL - wxString cstr(*this); - cstr.Replace(".", sep); - - return cstr.ToDouble(pVal); -} - -#endif // wxUSE_XLOCALE/!wxUSE_XLOCALE - -// ---------------------------------------------------------------------------- -// number to string conversion -// ---------------------------------------------------------------------------- - -/* static */ -wxString wxString::FromDouble(double val, int precision) -{ - wxCHECK_MSG( precision >= -1, wxString(), "Invalid negative precision" ); - - wxString format; - if ( precision == -1 ) - { - format = "%g"; - } - else // Use fixed precision. - { - format.Printf("%%.%df", precision); - } - - return wxString::Format(format, val); -} - -/* static */ -wxString wxString::FromCDouble(double val, int precision) -{ - wxCHECK_MSG( precision >= -1, wxString(), "Invalid negative precision" ); - - // Unfortunately there is no good way to get the number directly in the C - // locale. Some platforms provide special functions to do this (e.g. - // _sprintf_l() in MSVS or sprintf_l() in BSD systems), but some systems we - // still support don't have them and it doesn't seem worth it to have two - // different ways to do the same thing. Also, in principle, using the - // standard C++ streams should allow us to do it, but some implementations - // of them are horribly broken and actually change the global C locale, - // thus randomly affecting the results produced in other threads, when - // imbue() stream method is called (for the record, the latest libstdc++ - // version included in OS X does it and so seem to do the versions - // currently included in Android NDK and both FreeBSD and OpenBSD), so we - // can't do this neither and are reduced to this hack. - - wxString s = FromDouble(val, precision); -#if wxUSE_INTL - wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, - wxLOCALE_CAT_NUMBER); -#else // !wxUSE_INTL - // As above, this is the most common alternative value. Notice that here it - // doesn't matter if we guess wrongly and the current separator is already - // ".": we'll just waste a call to Replace() in this case. - wxString sep(","); -#endif // wxUSE_INTL/!wxUSE_INTL - - s.Replace(sep, "."); - return s; + // return true only if scan was stopped by the terminating NUL and if the + // string was not empty to start with and no under/overflow occurred + return !*end && (end != start) +#ifndef __WXWINCE__ + && (errno != ERANGE) +#endif + ; } // --------------------------------------------------------------------------- // formatted output // --------------------------------------------------------------------------- -#if !wxUSE_UTF8_LOCALE_ONLY /* static */ -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN -wxString wxStringPrintfMixinBase::DoFormatWchar(const wxChar *format, ...) -#else -wxString wxString::DoFormatWchar(const wxChar *format, ...) -#endif +wxString wxString::Format(const wxChar *pszFormat, ...) { va_list argptr; - va_start(argptr, format); + va_start(argptr, pszFormat); wxString s; - s.PrintfV(format, argptr); + s.PrintfV(pszFormat, argptr); va_end(argptr); return s; } -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -/* static */ -wxString wxString::DoFormatUtf8(const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - wxString s; - s.PrintfV(format, argptr); - - va_end(argptr); - - return s; -} -#endif // wxUSE_UNICODE_UTF8 /* static */ -wxString wxString::FormatV(const wxString& format, va_list argptr) +wxString wxString::FormatV(const wxChar *pszFormat, va_list argptr) { wxString s; - s.PrintfV(format, argptr); + s.PrintfV(pszFormat, argptr); return s; } -#if !wxUSE_UTF8_LOCALE_ONLY -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN -int wxStringPrintfMixinBase::DoPrintfWchar(const wxChar *format, ...) -#else -int wxString::DoPrintfWchar(const wxChar *format, ...) -#endif +int wxString::Printf(const wxChar *pszFormat, ...) { va_list argptr; - va_start(argptr, format); + va_start(argptr, pszFormat); -#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN - // get a pointer to the wxString instance; we have to use dynamic_cast<> - // because it's the only cast that works safely for downcasting when - // multiple inheritance is used: - wxString *str = static_cast(this); -#else - wxString *str = this; -#endif - - int iLen = str->PrintfV(format, argptr); + int iLen = PrintfV(pszFormat, argptr); va_end(argptr); return iLen; } -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int wxString::DoPrintfUtf8(const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int iLen = PrintfV(format, argptr); - - va_end(argptr); - - return iLen; -} -#endif // wxUSE_UNICODE_UTF8 /* Uses wxVsnprintf and places the result into the this string. @@ -2001,16 +1862,16 @@ int wxString::DoPrintfUtf8(const char *format, ...) Since EILSEQ and EINVAL are rather common but EOVERFLOW is not and since EILSEQ and EINVAL are specifically defined to mean the error is other than an undersized buffer and no other errno are defined we treat those two - as meaning hard errors and everything else gets the old behaviour which + as meaning hard errors and everything else gets the old behavior which is to keep looping and increasing buffer size until the function succeeds. - - In practice it's impossible to determine before compilation which behaviour - may be used. The vswprintf function may have vsnprintf-like behaviour or - vice-versa. Behaviour detected on one release can theoretically change + + In practice it's impossible to determine before compilation which behavior + may be used. The vswprintf function may have vsnprintf-like behavior or + vice-versa. Behavior detected on one release can theoretically change with an updated release. Not to mention that configure testing for it would require the test to be run on the host system, not the build system which makes cross compilation difficult. Therefore, we make no assumptions - about behaviour and try our best to handle every known case, including the + about behavior and try our best to handle every known case, including the case where wxVsnprintf returns a negative number and fails to set errno. There is yet one more non-standard implementation and that is our own. @@ -2021,33 +1882,24 @@ int wxString::DoPrintfUtf8(const char *format, ...) at the given buffer size minus 1. It is supposed to do this even if it turns out that the buffer is sized too small. - Darwin (tested on 10.5) follows the C99 behaviour exactly. + Darwin (tested on 10.5) follows the C99 behavior exactly. - Glibc 2.6 almost follows the C99 behaviour except vswprintf never sets + Glibc 2.6 almost follows the C99 behavior except vswprintf never sets errno even when it fails. However, it only seems to ever fail due to an undersized buffer. */ -#if wxUSE_UNICODE_UTF8 -template -#else -// we only need one version in non-UTF8 builds and at least two Windows -// compilers have problems with this function template, so use just one -// normal function here -#endif -static int DoStringPrintfV(wxString& str, - const wxString& format, va_list argptr) +int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) { int size = 1024; for ( ;; ) { -#if wxUSE_UNICODE_UTF8 - BufferType tmp(str, size + 1); - typename BufferType::CharType *buf = tmp; -#else - wxStringBuffer tmp(str, size + 1); + // Allocate 1 more character than we tell wxVsnprintf about + // just in case it is buggy. + // FIXME: I have a feeling that the underlying function was not buggy + // and I suspect it was to fix the buf[size] = '\0' line below + wxStringBuffer tmp(*this, size + 1); wxChar *buf = tmp; -#endif if ( !buf ) { @@ -2064,7 +1916,7 @@ static int DoStringPrintfV(wxString& str, // Set errno to 0 to make it determinate if wxVsnprintf fails to set it. errno = 0; #endif - int len = wxVsnprintf(buf, size, format, argptrcopy); + int len = wxVsnprintf(buf, size, pszFormat, argptrcopy); va_end(argptrcopy); // some implementations of vsnprintf() don't NUL terminate @@ -2072,28 +1924,20 @@ static int DoStringPrintfV(wxString& str, // always do it manually // FIXME: This really seems to be the wrong and would be an off-by-one // bug except the code above allocates an extra character. - buf[size] = wxT('\0'); + buf[size] = _T('\0'); // vsnprintf() may return either -1 (traditional Unix behaviour) or the // total number of characters which would have been written if the // buffer were large enough (newer standards such as Unix98) if ( len < 0 ) { - // NB: wxVsnprintf() may call either wxCRT_VsnprintfW or - // wxCRT_VsnprintfA in UTF-8 build; wxUSE_WXVSNPRINTF - // is true if *both* of them use our own implementation, - // otherwise we can't be sure #if wxUSE_WXVSNPRINTF // we know that our own implementation of wxVsnprintf() returns -1 // only for a format error - thus there's something wrong with // the user's format string - buf[0] = '\0'; return -1; -#else // possibly using system version - // assume it only returns error if there is not enough space, but - // as we don't know how much we need, double the current size of - // the buffer -#ifndef __WXWINCE__ +#else // assume that system version only returns error if not enough space +#if !defined(__WXWINCE__) && (!defined(__OS2__) || defined(__INNOTEK_LIBC__)) if( (errno == EILSEQ) || (errno == EINVAL) ) // If errno was set to one of the two well-known hard errors // then fail immediately to avoid an infinite loop. @@ -2108,7 +1952,7 @@ static int DoStringPrintfV(wxString& str, else if ( len >= size ) { #if wxUSE_WXVSNPRINTF - // we know that our own implementation of wxVsnprintf() returns + // we know that our own implementation of wxVsnprintf() returns // size+1 when there's not enough space but that's not the size // of the required buffer! size *= 2; // so we just double the current size of the buffer @@ -2130,34 +1974,9 @@ static int DoStringPrintfV(wxString& str, } // we could have overshot - str.Shrink(); + Shrink(); - return str.length(); -} - -int wxString::PrintfV(const wxString& format, va_list argptr) -{ -#if wxUSE_UNICODE_UTF8 - #if wxUSE_STL_BASED_WXSTRING - typedef wxStringTypeBuffer Utf8Buffer; - #else - typedef wxStringInternalBuffer Utf8Buffer; - #endif -#endif - -#if wxUSE_UTF8_LOCALE_ONLY - return DoStringPrintfV(*this, format, argptr); -#else - #if wxUSE_UNICODE_UTF8 - if ( wxLocaleIsUtf8 ) - return DoStringPrintfV(*this, format, argptr); - else - // wxChar* version - return DoStringPrintfV(*this, format, argptr); - #else - return DoStringPrintfV(*this, format, argptr); - #endif // UTF8/WCHAR -#endif + return length(); } // ---------------------------------------------------------------------------- @@ -2167,7 +1986,7 @@ int wxString::PrintfV(const wxString& format, va_list argptr) // returns true if the string matches the pattern which may contain '*' and // '?' metacharacters (as usual, '?' matches any character and '*' any number // of them) -bool wxString::Matches(const wxString& mask) const +bool wxString::Matches(const wxChar *pszMask) const { // I disable this code as it doesn't seem to be faster (in fact, it seems // to be much slower) than the old, hand-written code below and using it @@ -2178,31 +1997,31 @@ bool wxString::Matches(const wxString& mask) const wxString pattern; pattern.reserve(wxStrlen(pszMask)); - pattern += wxT('^'); + pattern += _T('^'); while ( *pszMask ) { switch ( *pszMask ) { - case wxT('?'): - pattern += wxT('.'); + case _T('?'): + pattern += _T('.'); break; - case wxT('*'): - pattern += wxT(".*"); + case _T('*'): + pattern += _T(".*"); break; - case wxT('^'): - case wxT('.'): - case wxT('$'): - case wxT('('): - case wxT(')'): - case wxT('|'): - case wxT('+'): - case wxT('\\'): + case _T('^'): + case _T('.'): + case _T('$'): + case _T('('): + case _T(')'): + case _T('|'): + case _T('+'): + case _T('\\'): // these characters are special in a RE, quote them // (however note that we don't quote '[' and ']' to allow // using them for Unix shell like matching) - pattern += wxT('\\'); + pattern += _T('\\'); // fall through default: @@ -2211,24 +2030,15 @@ bool wxString::Matches(const wxString& mask) const pszMask++; } - pattern += wxT('$'); + pattern += _T('$'); // and now use it return wxRegEx(pattern, wxRE_NOSUB | wxRE_EXTENDED).Matches(c_str()); #else // !wxUSE_REGEX // TODO: this is, of course, awfully inefficient... - // FIXME-UTF8: implement using iterators, remove #if -#if wxUSE_UNICODE_UTF8 - const wxScopedWCharBuffer maskBuf = mask.wc_str(); - const wxScopedWCharBuffer txtBuf = wc_str(); - const wxChar *pszMask = maskBuf.data(); - const wxChar *pszTxt = txtBuf.data(); -#else - const wxChar *pszMask = mask.wx_str(); // the char currently being checked - const wxChar *pszTxt = wx_str(); -#endif + const wxChar *pszTxt = c_str(); // the last location where '*' matched const wxChar *pszLastStarInText = NULL; @@ -2312,14 +2122,538 @@ match: } // Count the number of chars -int wxString::Freq(wxUniChar ch) const +int wxString::Freq(wxChar ch) const { int count = 0; - for ( const_iterator i = begin(); i != end(); ++i ) + int len = length(); + for (int i = 0; i < len; i++) { - if ( *i == ch ) + if (GetChar(i) == ch) count ++; } return count; } +// convert to upper case, return the copy of the string +wxString wxString::Upper() const +{ wxString s(*this); return s.MakeUpper(); } + +// convert to lower case, return the copy of the string +wxString wxString::Lower() const { wxString s(*this); return s.MakeLower(); } + +int wxString::sprintf(const wxChar *pszFormat, ...) + { + va_list argptr; + va_start(argptr, pszFormat); + int iLen = PrintfV(pszFormat, argptr); + va_end(argptr); + return iLen; + } + +// ============================================================================ +// ArrayString +// ============================================================================ + +#include "wx/arrstr.h" + +wxArrayString::wxArrayString(size_t sz, const wxChar** a) +{ +#if !wxUSE_STL + Init(false); +#endif + for (size_t i=0; i < sz; i++) + Add(a[i]); +} + +wxArrayString::wxArrayString(size_t sz, const wxString* a) +{ +#if !wxUSE_STL + Init(false); +#endif + for (size_t i=0; i < sz; i++) + Add(a[i]); +} + +#if !wxUSE_STL + +// size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT) +#define ARRAY_MAXSIZE_INCREMENT 4096 + +#ifndef ARRAY_DEFAULT_INITIAL_SIZE // also defined in dynarray.h +#define ARRAY_DEFAULT_INITIAL_SIZE (16) +#endif + +#define STRING(p) ((wxString *)(&(p))) + +// ctor +void wxArrayString::Init(bool autoSort) +{ + m_nSize = + m_nCount = 0; + m_pItems = (wxChar **) NULL; + m_autoSort = autoSort; +} + +// copy ctor +wxArrayString::wxArrayString(const wxArrayString& src) +{ + Init(src.m_autoSort); + + *this = src; +} + +// assignment operator +wxArrayString& wxArrayString::operator=(const wxArrayString& src) +{ + if ( m_nSize > 0 ) + Clear(); + + Copy(src); + + m_autoSort = src.m_autoSort; + + return *this; +} + +void wxArrayString::Copy(const wxArrayString& src) +{ + if ( src.m_nCount > ARRAY_DEFAULT_INITIAL_SIZE ) + Alloc(src.m_nCount); + + for ( size_t n = 0; n < src.m_nCount; n++ ) + Add(src[n]); +} + +// grow the array +void wxArrayString::Grow(size_t nIncrement) +{ + // only do it if no more place + if ( (m_nSize - m_nCount) < nIncrement ) { + // if ARRAY_DEFAULT_INITIAL_SIZE were set to 0, the initially empty would + // be never resized! + #if ARRAY_DEFAULT_INITIAL_SIZE == 0 + #error "ARRAY_DEFAULT_INITIAL_SIZE must be > 0!" + #endif + + if ( m_nSize == 0 ) { + // was empty, alloc some memory + m_nSize = ARRAY_DEFAULT_INITIAL_SIZE; + if (m_nSize < nIncrement) + m_nSize = nIncrement; + m_pItems = new wxChar *[m_nSize]; + } + else { + // otherwise when it's called for the first time, nIncrement would be 0 + // and the array would never be expanded + // add 50% but not too much + size_t ndefIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE + ? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1; + if ( ndefIncrement > ARRAY_MAXSIZE_INCREMENT ) + ndefIncrement = ARRAY_MAXSIZE_INCREMENT; + if ( nIncrement < ndefIncrement ) + nIncrement = ndefIncrement; + m_nSize += nIncrement; + wxChar **pNew = new wxChar *[m_nSize]; + + // copy data to new location + memcpy(pNew, m_pItems, m_nCount*sizeof(wxChar *)); + + // delete old memory (but do not release the strings!) + wxDELETEA(m_pItems); + + m_pItems = pNew; + } + } +} + +void wxArrayString::Free() +{ + for ( size_t n = 0; n < m_nCount; n++ ) { + STRING(m_pItems[n])->GetStringData()->Unlock(); + } +} + +// deletes all the strings from the list +void wxArrayString::Empty() +{ + Free(); + + m_nCount = 0; +} + +// as Empty, but also frees memory +void wxArrayString::Clear() +{ + Free(); + + m_nSize = + m_nCount = 0; + + wxDELETEA(m_pItems); +} + +// dtor +wxArrayString::~wxArrayString() +{ + Free(); + + wxDELETEA(m_pItems); +} + +void wxArrayString::reserve(size_t nSize) +{ + Alloc(nSize); +} + +// pre-allocates memory (frees the previous data!) +void wxArrayString::Alloc(size_t nSize) +{ + // only if old buffer was not big enough + if ( nSize > m_nSize ) { + wxChar **pNew = new wxChar *[nSize]; + if ( !pNew ) + return; + + memcpy(pNew, m_pItems, m_nCount*sizeof(wxChar *)); + delete [] m_pItems; + + m_pItems = pNew; + m_nSize = nSize; + } +} + +// minimizes the memory usage by freeing unused memory +void wxArrayString::Shrink() +{ + // only do it if we have some memory to free + if( m_nCount < m_nSize ) { + // allocates exactly as much memory as we need + wxChar **pNew = new wxChar *[m_nCount]; + + // copy data to new location + memcpy(pNew, m_pItems, m_nCount*sizeof(wxChar *)); + delete [] m_pItems; + m_pItems = pNew; + m_nSize = m_nCount; + } +} + +#if WXWIN_COMPATIBILITY_2_4 + +// return a wxString[] as required for some control ctors. +wxString* wxArrayString::GetStringArray() const +{ + wxString *array = 0; + + if( m_nCount > 0 ) + { + array = new wxString[m_nCount]; + for( size_t i = 0; i < m_nCount; i++ ) + array[i] = m_pItems[i]; + } + + return array; +} + +void wxArrayString::Remove(size_t nIndex, size_t nRemove) +{ + RemoveAt(nIndex, nRemove); +} + +#endif // WXWIN_COMPATIBILITY_2_4 + +// searches the array for an item (forward or backwards) +int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const +{ + if ( m_autoSort ) { + // use binary search in the sorted array + wxASSERT_MSG( bCase && !bFromEnd, + wxT("search parameters ignored for auto sorted array") ); + + size_t i, + lo = 0, + hi = m_nCount; + int res; + while ( lo < hi ) { + i = (lo + hi)/2; + + res = wxStrcmp(sz, m_pItems[i]); + if ( res < 0 ) + hi = i; + else if ( res > 0 ) + lo = i + 1; + else + return i; + } + + return wxNOT_FOUND; + } + else { + // use linear search in unsorted array + if ( bFromEnd ) { + if ( m_nCount > 0 ) { + size_t ui = m_nCount; + do { + if ( STRING(m_pItems[--ui])->IsSameAs(sz, bCase) ) + return ui; + } + while ( ui != 0 ); + } + } + else { + for( size_t ui = 0; ui < m_nCount; ui++ ) { + if( STRING(m_pItems[ui])->IsSameAs(sz, bCase) ) + return ui; + } + } + } + + return wxNOT_FOUND; +} + +// add item at the end +size_t wxArrayString::Add(const wxString& str, size_t nInsert) +{ + if ( m_autoSort ) { + // insert the string at the correct position to keep the array sorted + size_t i, + lo = 0, + hi = m_nCount; + int res; + while ( lo < hi ) { + i = (lo + hi)/2; + + res = str.Cmp(m_pItems[i]); + if ( res < 0 ) + hi = i; + else if ( res > 0 ) + lo = i + 1; + else { + lo = hi = i; + break; + } + } + + wxASSERT_MSG( lo == hi, wxT("binary search broken") ); + + Insert(str, lo, nInsert); + + return (size_t)lo; + } + else { + wxASSERT( str.GetStringData()->IsValid() ); + + Grow(nInsert); + + for (size_t i = 0; i < nInsert; i++) + { + // the string data must not be deleted! + str.GetStringData()->Lock(); + + // just append + m_pItems[m_nCount + i] = (wxChar *)str.c_str(); // const_cast + } + size_t ret = m_nCount; + m_nCount += nInsert; + return ret; + } +} + +// add item at the given position +void wxArrayString::Insert(const wxString& str, size_t nIndex, size_t nInsert) +{ + wxASSERT( str.GetStringData()->IsValid() ); + + wxCHECK_RET( nIndex <= m_nCount, wxT("bad index in wxArrayString::Insert") ); + wxCHECK_RET( m_nCount <= m_nCount + nInsert, + wxT("array size overflow in wxArrayString::Insert") ); + + Grow(nInsert); + + memmove(&m_pItems[nIndex + nInsert], &m_pItems[nIndex], + (m_nCount - nIndex)*sizeof(wxChar *)); + + for (size_t i = 0; i < nInsert; i++) + { + str.GetStringData()->Lock(); + m_pItems[nIndex + i] = (wxChar *)str.c_str(); + } + m_nCount += nInsert; +} + +// range insert (STL 23.2.4.3) +void +wxArrayString::insert(iterator it, const_iterator first, const_iterator last) +{ + const int idx = it - begin(); + + // grow it once + Grow(last - first); + + // reset "it" since it can change inside Grow() + it = begin() + idx; + + while ( first != last ) + { + it = insert(it, *first); + + // insert returns an iterator to the last element inserted but we need + // insert the next after this one, that is before the next one + ++it; + + ++first; + } +} + +// expand the array +void wxArrayString::SetCount(size_t count) +{ + Alloc(count); + + wxString s; + while ( m_nCount < count ) + m_pItems[m_nCount++] = (wxChar *)s.c_str(); +} + +// removes item from array (by index) +void wxArrayString::RemoveAt(size_t nIndex, size_t nRemove) +{ + wxCHECK_RET( nIndex < m_nCount, wxT("bad index in wxArrayString::Remove") ); + wxCHECK_RET( nIndex + nRemove <= m_nCount, + wxT("removing too many elements in wxArrayString::Remove") ); + + // release our lock + for (size_t i = 0; i < nRemove; i++) + Item(nIndex + i).GetStringData()->Unlock(); + + memmove(&m_pItems[nIndex], &m_pItems[nIndex + nRemove], + (m_nCount - nIndex - nRemove)*sizeof(wxChar *)); + m_nCount -= nRemove; +} + +// removes item from array (by value) +void wxArrayString::Remove(const wxChar *sz) +{ + int iIndex = Index(sz); + + wxCHECK_RET( iIndex != wxNOT_FOUND, + wxT("removing inexistent element in wxArrayString::Remove") ); + + RemoveAt(iIndex); +} + +void wxArrayString::assign(const_iterator first, const_iterator last) +{ + reserve(last - first); + for(; first != last; ++first) + push_back(*first); +} + +// ---------------------------------------------------------------------------- +// sorting +// ---------------------------------------------------------------------------- + +// we can only sort one array at a time with the quick-sort based +// implementation +#if wxUSE_THREADS + // need a critical section to protect access to gs_compareFunction and + // gs_sortAscending variables + static wxCriticalSection gs_critsectStringSort; +#endif // wxUSE_THREADS + +// function to use for string comparaison +static wxArrayString::CompareFunction gs_compareFunction = NULL; + +// if we don't use the compare function, this flag tells us if we sort the +// array in ascending or descending order +static bool gs_sortAscending = true; + +// function which is called by quick sort +extern "C" int wxC_CALLING_CONV // LINKAGEMODE +wxStringCompareFunction(const void *first, const void *second) +{ + wxString *strFirst = (wxString *)first; + wxString *strSecond = (wxString *)second; + + if ( gs_compareFunction ) { + return gs_compareFunction(*strFirst, *strSecond); + } + else { + // maybe we should use wxStrcoll + int result = strFirst->Cmp(*strSecond); + + return gs_sortAscending ? result : -result; + } +} + +// sort array elements using passed comparaison function +void wxArrayString::Sort(CompareFunction compareFunction) +{ + wxCRIT_SECT_LOCKER(lockCmpFunc, gs_critsectStringSort); + + wxASSERT( !gs_compareFunction ); // must have been reset to NULL + gs_compareFunction = compareFunction; + + DoSort(); + + // reset it to NULL so that Sort(bool) will work the next time + gs_compareFunction = NULL; +} + +extern "C" +{ + typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, + const void *second); +} + +void wxArrayString::Sort(CompareFunction2 compareFunction) +{ + qsort(m_pItems, m_nCount, sizeof(wxChar *), (wxStringCompareFn)compareFunction); +} + +void wxArrayString::Sort(bool reverseOrder) +{ + Sort(reverseOrder ? wxStringSortDescending : wxStringSortAscending); +} + +void wxArrayString::DoSort() +{ + wxCHECK_RET( !m_autoSort, wxT("can't use this method with sorted arrays") ); + + // just sort the pointers using qsort() - of course it only works because + // wxString() *is* a pointer to its data + qsort(m_pItems, m_nCount, sizeof(wxChar *), wxStringCompareFunction); +} + +bool wxArrayString::operator==(const wxArrayString& a) const +{ + if ( m_nCount != a.m_nCount ) + return false; + + for ( size_t n = 0; n < m_nCount; n++ ) + { + if ( Item(n) != a[n] ) + return false; + } + + return true; +} + +#endif // !wxUSE_STL + +int wxCMPFUNC_CONV wxStringSortAscending(wxString* s1, wxString* s2) +{ + return s1->Cmp(*s2); +} + +int wxCMPFUNC_CONV wxStringSortDescending(wxString* s1, wxString* s2) +{ + return -s1->Cmp(*s2); +} + +wxString* wxCArrayString::Release() +{ + wxString *r = GetStrings(); + m_strings = NULL; + return r; +} diff --git a/Source/3rd Party/wx/src/common/stringimpl.cpp b/Source/3rd Party/wx/src/common/stringimpl.cpp deleted file mode 100644 index 3dad9eb3c..000000000 --- a/Source/3rd Party/wx/src/common/stringimpl.cpp +++ /dev/null @@ -1,798 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/stringimpl.cpp -// Purpose: wxString class -// Author: Vadim Zeitlin, Ryan Norton -// Modified by: -// Created: 29/01/98 -// Copyright: (c) 1998 Vadim Zeitlin -// (c) 2004 Ryan Norton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -/* - * About ref counting: - * 1) all empty strings use g_strEmpty, nRefs = -1 (set in Init()) - * 2) AllocBuffer() sets nRefs to 1, Lock() increments it by one - * 3) Unlock() decrements nRefs and frees memory if it goes to 0 - */ - -// =========================================================================== -// headers, declarations, constants -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/stringimpl.h" - #include "wx/wxcrt.h" -#endif - -#include - -#ifndef __WXWINCE__ - #include -#endif - -#include -#include - -// allocating extra space for each string consumes more memory but speeds up -// the concatenation operations (nLen is the current string's length) -// NB: EXTRA_ALLOC must be >= 0! -#define EXTRA_ALLOC (19 - nLen % 16) - - -// string handling functions used by wxString: -#if wxUSE_UNICODE_UTF8 - #define wxStringMemcpy memcpy - #define wxStringMemcmp memcmp - #define wxStringMemchr memchr -#else - #define wxStringMemcpy wxTmemcpy - #define wxStringMemcmp wxTmemcmp - #define wxStringMemchr wxTmemchr -#endif - - -// --------------------------------------------------------------------------- -// static class variables definition -// --------------------------------------------------------------------------- - -#if !wxUSE_STL_BASED_WXSTRING -//According to STL _must_ be a -1 size_t -const size_t wxStringImpl::npos = (size_t) -1; -#endif - -// ---------------------------------------------------------------------------- -// static data -// ---------------------------------------------------------------------------- - -#if wxUSE_STL_BASED_WXSTRING - -// FIXME-UTF8: get rid of this, have only one wxEmptyString -#if wxUSE_UNICODE_UTF8 -const wxStringCharType WXDLLIMPEXP_BASE *wxEmptyStringImpl = ""; -#endif -const wxChar WXDLLIMPEXP_BASE *wxEmptyString = wxT(""); - -#else - -// for an empty string, GetStringData() will return this address: this -// structure has the same layout as wxStringData and it's data() method will -// return the empty string (dummy pointer) -static const struct -{ - wxStringData data; - wxStringCharType dummy; -} g_strEmpty = { {-1, 0, 0}, wxT('\0') }; - -// empty C style string: points to 'string data' byte of g_strEmpty -#if wxUSE_UNICODE_UTF8 -// FIXME-UTF8: get rid of this, have only one wxEmptyString -const wxStringCharType WXDLLIMPEXP_BASE *wxEmptyStringImpl = &g_strEmpty.dummy; -const wxChar WXDLLIMPEXP_BASE *wxEmptyString = wxT(""); -#else -const wxStringCharType WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy; -#endif - -#endif - - -#if !wxUSE_STL_BASED_WXSTRING - -// ---------------------------------------------------------------------------- -// private classes -// ---------------------------------------------------------------------------- - -// this small class is used to gather statistics for performance tuning - -// uncomment this to enable gathering of some statistics about wxString -// efficiency -//#define WXSTRING_STATISTICS - -#ifdef WXSTRING_STATISTICS - class Averager - { - public: - Averager(const wxStringCharType *sz) { m_sz = sz; m_nTotal = m_nCount = 0; } - ~Averager() - { - wxPrintf("wxString %s: total = %lu, average = %f\n", - m_sz, m_nTotal, ((float)m_nTotal)/m_nCount); - } - - void Add(size_t n) { m_nTotal += n; m_nCount++; } - - private: - unsigned long m_nCount, m_nTotal; - const wxStringCharType *m_sz; - } g_averageLength("allocation size"), - g_averageSummandLength("summand length"), - g_averageConcatHit("hit probability in concat"), - g_averageInitialLength("initial string length"); - - #define STATISTICS_ADD(av, val) g_average##av.Add(val) -#else - #define STATISTICS_ADD(av, val) -#endif // WXSTRING_STATISTICS - -// =========================================================================== -// wxStringData class deallocation -// =========================================================================== - -#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) -# pragma message (__FILE__ ": building with Multithreaded non DLL runtime has a performance impact on wxString!") -void wxStringData::Free() -{ - free(this); -} -#endif - -// =========================================================================== -// wxStringImpl -// =========================================================================== - -// takes nLength elements of psz starting at nPos -void wxStringImpl::InitWith(const wxStringCharType *psz, - size_t nPos, size_t nLength) -{ - Init(); - - // if the length is not given, assume the string to be NUL terminated - if ( nLength == npos ) { - wxASSERT_MSG( nPos <= wxStrlen(psz), wxT("index out of bounds") ); - - nLength = wxStrlen(psz + nPos); - } - - STATISTICS_ADD(InitialLength, nLength); - - if ( nLength > 0 ) { - // trailing '\0' is written in AllocBuffer() - if ( !AllocBuffer(nLength) ) { - wxFAIL_MSG( wxT("out of memory in wxStringImpl::InitWith") ); - return; - } - wxStringMemcpy(m_pchData, psz + nPos, nLength); - } -} - -wxStringImpl::wxStringImpl(const_iterator first, const_iterator last) -{ - if ( last >= first ) - { - InitWith(first.GetPtr(), 0, last - first); - } - else - { - wxFAIL_MSG( wxT("first must be before last") ); - Init(); - } -} - -wxStringImpl::wxStringImpl(size_type n, wxStringCharType ch) -{ - Init(); - append(n, ch); -} - -// --------------------------------------------------------------------------- -// memory allocation -// --------------------------------------------------------------------------- - -// allocates memory needed to store a C string of length nLen -bool wxStringImpl::AllocBuffer(size_t nLen) -{ - // allocating 0 sized buffer doesn't make sense, all empty strings should - // reuse g_strEmpty - wxASSERT( nLen > 0 ); - - // make sure that we don't overflow - wxCHECK( nLen < (INT_MAX / sizeof(wxStringCharType)) - - (sizeof(wxStringData) + EXTRA_ALLOC + 1), false ); - - STATISTICS_ADD(Length, nLen); - - // allocate memory: - // 1) one extra character for '\0' termination - // 2) sizeof(wxStringData) for housekeeping info - wxStringData* pData = (wxStringData*) - malloc(sizeof(wxStringData) + (nLen + EXTRA_ALLOC + 1)*sizeof(wxStringCharType)); - - if ( pData == NULL ) { - // allocation failures are handled by the caller - return false; - } - - pData->nRefs = 1; - pData->nDataLength = nLen; - pData->nAllocLength = nLen + EXTRA_ALLOC; - m_pchData = pData->data(); // data starts after wxStringData - m_pchData[nLen] = wxT('\0'); - return true; -} - -// must be called before changing this string -bool wxStringImpl::CopyBeforeWrite() -{ - wxStringData* pData = GetStringData(); - - if ( pData->IsShared() ) { - pData->Unlock(); // memory not freed because shared - size_t nLen = pData->nDataLength; - if ( !AllocBuffer(nLen) ) { - // allocation failures are handled by the caller - return false; - } - wxStringMemcpy(m_pchData, pData->data(), nLen); - } - - wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner - - return true; -} - -// must be called before replacing contents of this string -bool wxStringImpl::AllocBeforeWrite(size_t nLen) -{ - wxASSERT( nLen != 0 ); // doesn't make any sense - - // must not share string and must have enough space - wxStringData* pData = GetStringData(); - if ( pData->IsShared() || pData->IsEmpty() ) { - // can't work with old buffer, get new one - pData->Unlock(); - if ( !AllocBuffer(nLen) ) { - // allocation failures are handled by the caller - return false; - } - } - else { - if ( nLen > pData->nAllocLength ) { - // realloc the buffer instead of calling malloc() again, this is more - // efficient - STATISTICS_ADD(Length, nLen); - - nLen += EXTRA_ALLOC; - - pData = (wxStringData*) - realloc(pData, - sizeof(wxStringData) + (nLen + 1)*sizeof(wxStringCharType)); - - if ( pData == NULL ) { - // allocation failures are handled by the caller - // keep previous data since reallocation failed - return false; - } - - pData->nAllocLength = nLen; - m_pchData = pData->data(); - } - } - - wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner - - // it doesn't really matter what the string length is as it's going to be - // overwritten later but, for extra safety, set it to 0 for now as we may - // have some junk in m_pchData - GetStringData()->nDataLength = 0; - - return true; -} - -wxStringImpl& wxStringImpl::append(size_t n, wxStringCharType ch) -{ - size_type len = length(); - - if ( !Alloc(len + n) || !CopyBeforeWrite() ) { - wxFAIL_MSG( wxT("out of memory in wxStringImpl::append") ); - return *this; - } - GetStringData()->nDataLength = len + n; - m_pchData[len + n] = '\0'; - for ( size_t i = 0; i < n; ++i ) - m_pchData[len + i] = ch; - return *this; -} - -void wxStringImpl::resize(size_t nSize, wxStringCharType ch) -{ - size_t len = length(); - - if ( nSize < len ) - { - erase(begin() + nSize, end()); - } - else if ( nSize > len ) - { - append(nSize - len, ch); - } - //else: we have exactly the specified length, nothing to do -} - -// allocate enough memory for nLen characters -bool wxStringImpl::Alloc(size_t nLen) -{ - wxStringData *pData = GetStringData(); - if ( pData->nAllocLength <= nLen ) { - if ( pData->IsEmpty() ) { - STATISTICS_ADD(Length, nLen); - - nLen += EXTRA_ALLOC; - - pData = (wxStringData *) - malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxStringCharType)); - - if ( pData == NULL ) { - // allocation failure handled by caller - return false; - } - - pData->nRefs = 1; - pData->nDataLength = 0; - pData->nAllocLength = nLen; - m_pchData = pData->data(); // data starts after wxStringData - m_pchData[0u] = wxT('\0'); - } - else if ( pData->IsShared() ) { - pData->Unlock(); // memory not freed because shared - size_t nOldLen = pData->nDataLength; - if ( !AllocBuffer(nLen) ) { - // allocation failure handled by caller - return false; - } - // +1 to copy the terminator, too - memcpy(m_pchData, pData->data(), (nOldLen+1)*sizeof(wxStringCharType)); - GetStringData()->nDataLength = nOldLen; - } - else { - nLen += EXTRA_ALLOC; - - pData = (wxStringData *) - realloc(pData, sizeof(wxStringData) + (nLen + 1)*sizeof(wxStringCharType)); - - if ( pData == NULL ) { - // allocation failure handled by caller - // keep previous data since reallocation failed - return false; - } - - // it's not important if the pointer changed or not (the check for this - // is not faster than assigning to m_pchData in all cases) - pData->nAllocLength = nLen; - m_pchData = pData->data(); - } - } - //else: we've already got enough - return true; -} - -wxStringImpl::iterator wxStringImpl::begin() -{ - if ( !empty() ) - CopyBeforeWrite(); - return m_pchData; -} - -wxStringImpl::iterator wxStringImpl::end() -{ - if ( !empty() ) - CopyBeforeWrite(); - return m_pchData + length(); -} - -wxStringImpl::iterator wxStringImpl::erase(iterator it) -{ - size_type idx = it - begin(); - erase(idx, 1); - return begin() + idx; -} - -wxStringImpl& wxStringImpl::erase(size_t nStart, size_t nLen) -{ - wxASSERT(nStart <= length()); - size_t strLen = length() - nStart; - // delete nLen or up to the end of the string characters - nLen = strLen < nLen ? strLen : nLen; - wxStringImpl strTmp(c_str(), nStart); - strTmp.append(c_str() + nStart + nLen, length() - nStart - nLen); - - swap(strTmp); - return *this; -} - -wxStringImpl& wxStringImpl::insert(size_t nPos, - const wxStringCharType *sz, size_t n) -{ - wxASSERT( nPos <= length() ); - - if ( n == npos ) n = wxStrlen(sz); - if ( n == 0 ) return *this; - - if ( !Alloc(length() + n) || !CopyBeforeWrite() ) { - wxFAIL_MSG( wxT("out of memory in wxStringImpl::insert") ); - return *this; - } - - memmove(m_pchData + nPos + n, m_pchData + nPos, - (length() - nPos) * sizeof(wxStringCharType)); - memcpy(m_pchData + nPos, sz, n * sizeof(wxStringCharType)); - GetStringData()->nDataLength = length() + n; - m_pchData[length()] = '\0'; - - return *this; -} - -void wxStringImpl::swap(wxStringImpl& str) -{ - wxStringCharType* tmp = str.m_pchData; - str.m_pchData = m_pchData; - m_pchData = tmp; -} - -size_t wxStringImpl::find(const wxStringImpl& str, size_t nStart) const -{ - // deal with the special case of empty string first - const size_t nLen = length(); - const size_t nLenOther = str.length(); - - if ( !nLenOther ) - { - // empty string is a substring of anything - return 0; - } - - if ( !nLen ) - { - // the other string is non empty so can't be our substring - return npos; - } - - wxASSERT( str.GetStringData()->IsValid() ); - wxASSERT( nStart <= nLen ); - - const wxStringCharType * const other = str.c_str(); - - // anchor - const wxStringCharType* p = - (const wxStringCharType*)wxStringMemchr(c_str() + nStart, - *other, - nLen - nStart); - - if ( !p ) - return npos; - - while ( p - c_str() + nLenOther <= nLen && - wxStringMemcmp(p, other, nLenOther) ) - { - p++; - - // anchor again - p = (const wxStringCharType*) - wxStringMemchr(p, *other, nLen - (p - c_str())); - - if ( !p ) - return npos; - } - - return p - c_str() + nLenOther <= nLen ? p - c_str() : npos; -} - -size_t wxStringImpl::find(const wxStringCharType* sz, - size_t nStart, size_t n) const -{ - return find(wxStringImpl(sz, n), nStart); -} - -size_t wxStringImpl::find(wxStringCharType ch, size_t nStart) const -{ - wxASSERT( nStart <= length() ); - - const wxStringCharType *p = (const wxStringCharType*) - wxStringMemchr(c_str() + nStart, ch, length() - nStart); - - return p == NULL ? npos : p - c_str(); -} - -size_t wxStringImpl::rfind(const wxStringImpl& str, size_t nStart) const -{ - wxASSERT( str.GetStringData()->IsValid() ); - wxASSERT( nStart == npos || nStart <= length() ); - - if ( length() >= str.length() ) - { - // avoids a corner case later - if ( empty() && str.empty() ) - return 0; - - // "top" is the point where search starts from - size_t top = length() - str.length(); - - if ( nStart == npos ) - nStart = length() - 1; - if ( nStart < top ) - top = nStart; - - const wxStringCharType *cursor = c_str() + top; - do - { - if ( wxStringMemcmp(cursor, str.c_str(), str.length()) == 0 ) - { - return cursor - c_str(); - } - } while ( cursor-- > c_str() ); - } - - return npos; -} - -size_t wxStringImpl::rfind(const wxStringCharType* sz, - size_t nStart, size_t n) const -{ - return rfind(wxStringImpl(sz, n), nStart); -} - -size_t wxStringImpl::rfind(wxStringCharType ch, size_t nStart) const -{ - if ( nStart == npos ) - { - nStart = length(); - } - else - { - wxASSERT( nStart <= length() ); - } - - const wxStringCharType *actual; - for ( actual = c_str() + ( nStart == npos ? length() : nStart + 1 ); - actual > c_str(); --actual ) - { - if ( *(actual - 1) == ch ) - return (actual - 1) - c_str(); - } - - return npos; -} - -wxStringImpl& wxStringImpl::replace(size_t nStart, size_t nLen, - const wxStringCharType *sz, size_t nCount) -{ - // check and adjust parameters - const size_t lenOld = length(); - - wxASSERT_MSG( nStart <= lenOld, - wxT("index out of bounds in wxStringImpl::replace") ); - size_t nEnd = nStart + nLen; - if ( nLen > lenOld - nStart ) - { - // nLen may be out of range, as it can be npos, just clump it down - nLen = lenOld - nStart; - nEnd = lenOld; - } - - if ( nCount == npos ) - nCount = wxStrlen(sz); - - // build the new string from 3 pieces: part of this string before nStart, - // the new substring and the part of this string after nStart+nLen - wxStringImpl tmp; - const size_t lenNew = lenOld + nCount - nLen; - if ( lenNew ) - { - tmp.AllocBuffer(lenOld + nCount - nLen); - - wxStringCharType *dst = tmp.m_pchData; - memcpy(dst, m_pchData, nStart*sizeof(wxStringCharType)); - dst += nStart; - - memcpy(dst, sz, nCount*sizeof(wxStringCharType)); - dst += nCount; - - memcpy(dst, m_pchData + nEnd, (lenOld - nEnd)*sizeof(wxStringCharType)); - } - - // and replace this string contents with the new one - swap(tmp); - return *this; -} - -wxStringImpl wxStringImpl::substr(size_t nStart, size_t nLen) const -{ - if ( nLen == npos ) - nLen = length() - nStart; - return wxStringImpl(*this, nStart, nLen); -} - -// assigns one string to another -wxStringImpl& wxStringImpl::operator=(const wxStringImpl& stringSrc) -{ - wxASSERT( stringSrc.GetStringData()->IsValid() ); - - // don't copy string over itself - if ( m_pchData != stringSrc.m_pchData ) { - if ( stringSrc.GetStringData()->IsEmpty() ) { - Reinit(); - } - else { - // adjust references - GetStringData()->Unlock(); - m_pchData = stringSrc.m_pchData; - GetStringData()->Lock(); - } - } - - return *this; -} - -// assigns a single character -wxStringImpl& wxStringImpl::operator=(wxStringCharType ch) -{ - wxStringCharType c(ch); - if ( !AssignCopy(1, &c) ) { - wxFAIL_MSG( wxT("out of memory in wxStringImpl::operator=(wxStringCharType)") ); - } - return *this; -} - -// assigns C string -wxStringImpl& wxStringImpl::operator=(const wxStringCharType *psz) -{ - if ( !AssignCopy(wxStrlen(psz), psz) ) { - wxFAIL_MSG( wxT("out of memory in wxStringImpl::operator=(const wxStringCharType *)") ); - } - return *this; -} - -// helper function: does real copy -bool wxStringImpl::AssignCopy(size_t nSrcLen, - const wxStringCharType *pszSrcData) -{ - if ( nSrcLen == 0 ) { - Reinit(); - } - else { - if ( !AllocBeforeWrite(nSrcLen) ) { - // allocation failure handled by caller - return false; - } - - // use memmove() and not memcpy() here as we might be copying from our own - // buffer in case of assignment such as "s = s.c_str()" (see #11294) - memmove(m_pchData, pszSrcData, nSrcLen*sizeof(wxStringCharType)); - - GetStringData()->nDataLength = nSrcLen; - m_pchData[nSrcLen] = wxT('\0'); - } - return true; -} - -// --------------------------------------------------------------------------- -// string concatenation -// --------------------------------------------------------------------------- - -// add something to this string -bool wxStringImpl::ConcatSelf(size_t nSrcLen, - const wxStringCharType *pszSrcData, - size_t nMaxLen) -{ - STATISTICS_ADD(SummandLength, nSrcLen); - - nSrcLen = nSrcLen < nMaxLen ? nSrcLen : nMaxLen; - - // concatenating an empty string is a NOP - if ( nSrcLen > 0 ) { - wxStringData *pData = GetStringData(); - size_t nLen = pData->nDataLength; - - // take special care when appending part of this string to itself: the code - // below reallocates our buffer and this invalidates pszSrcData pointer so - // we have to copy it in another temporary string in this case (but avoid - // doing this unnecessarily) - if ( pszSrcData >= m_pchData && pszSrcData < m_pchData + nLen ) - { - wxStringImpl tmp(pszSrcData, nSrcLen); - return ConcatSelf(nSrcLen, tmp.m_pchData, nSrcLen); - } - - size_t nNewLen = nLen + nSrcLen; - - // alloc new buffer if current is too small - if ( pData->IsShared() ) { - STATISTICS_ADD(ConcatHit, 0); - - // we have to allocate another buffer - wxStringData* pOldData = GetStringData(); - if ( !AllocBuffer(nNewLen) ) { - // allocation failure handled by caller - return false; - } - memcpy(m_pchData, pOldData->data(), nLen*sizeof(wxStringCharType)); - pOldData->Unlock(); - } - else if ( nNewLen > pData->nAllocLength ) { - STATISTICS_ADD(ConcatHit, 0); - - reserve(nNewLen); - // we have to grow the buffer - if ( capacity() < nNewLen ) { - // allocation failure handled by caller - return false; - } - } - else { - STATISTICS_ADD(ConcatHit, 1); - - // the buffer is already big enough - } - - // should be enough space - wxASSERT( nNewLen <= GetStringData()->nAllocLength ); - - // fast concatenation - all is done in our buffer - memcpy(m_pchData + nLen, pszSrcData, nSrcLen*sizeof(wxStringCharType)); - - m_pchData[nNewLen] = wxT('\0'); // put terminating '\0' - GetStringData()->nDataLength = nNewLen; // and fix the length - } - //else: the string to append was empty - return true; -} - -// get the pointer to writable buffer of (at least) nLen bytes -wxStringCharType *wxStringImpl::DoGetWriteBuf(size_t nLen) -{ - if ( !AllocBeforeWrite(nLen) ) { - // allocation failure handled by caller - return NULL; - } - - wxASSERT( GetStringData()->nRefs == 1 ); - GetStringData()->Validate(false); - - return m_pchData; -} - -// put string back in a reasonable state after GetWriteBuf -void wxStringImpl::DoUngetWriteBuf() -{ - DoUngetWriteBuf(wxStrlen(m_pchData)); -} - -void wxStringImpl::DoUngetWriteBuf(size_t nLen) -{ - wxStringData * const pData = GetStringData(); - - wxASSERT_MSG( nLen < pData->nAllocLength, wxT("buffer overrun") ); - - // the strings we store are always NUL-terminated - pData->data()[nLen] = wxT('\0'); - pData->nDataLength = nLen; - pData->Validate(true); -} - -#endif // !wxUSE_STL_BASED_WXSTRING diff --git a/Source/3rd Party/wx/src/common/stringops.cpp b/Source/3rd Party/wx/src/common/stringops.cpp deleted file mode 100644 index 159270687..000000000 --- a/Source/3rd Party/wx/src/common/stringops.cpp +++ /dev/null @@ -1,315 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/stringops.cpp -// Purpose: implementation of wxString primitive operations -// Author: Vaclav Slavik -// Modified by: -// Created: 2007-04-16 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// headers -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/stringops.h" -#endif - -// =========================================================================== -// implementation -// =========================================================================== - -#if wxUSE_UNICODE_UTF8 - -// --------------------------------------------------------------------------- -// UTF-8 sequences lengths -// --------------------------------------------------------------------------- - -const unsigned char wxStringOperationsUtf8::ms_utf8IterTable[256] = { - // single-byte sequences (ASCII): - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00..0F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10..1F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20..2F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30..3F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40..4F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50..5F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60..6F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70..7F - - // these are invalid, we use step 1 to skip - // over them (should never happen): - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80..8F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90..9F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A0..AF - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B0..BF - 1, 1, // C0,C1 - - // two-byte sequences: - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C2..CF - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0..DF - - // three-byte sequences: - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0..EF - - // four-byte sequences: - 4, 4, 4, 4, 4, // F0..F4 - - // these are invalid again (5- or 6-byte - // sequences and sequences for code points - // above U+10FFFF, as restricted by RFC 3629): - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F5..FF -}; - -// --------------------------------------------------------------------------- -// UTF-8 operations -// --------------------------------------------------------------------------- - -// -// Table 3.1B from Unicode spec: Legal UTF-8 Byte Sequences -// -// Code Points | 1st Byte | 2nd Byte | 3rd Byte | 4th Byte | -// -------------------+----------+----------+----------+----------+ -// U+0000..U+007F | 00..7F | | | | -// U+0080..U+07FF | C2..DF | 80..BF | | | -// U+0800..U+0FFF | E0 | A0..BF | 80..BF | | -// U+1000..U+FFFF | E1..EF | 80..BF | 80..BF | | -// U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF | -// U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF | -// U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF | -// -------------------+----------+----------+----------+----------+ - -bool wxStringOperationsUtf8::IsValidUtf8String(const char *str, size_t len) -{ - if ( !str ) - return true; // empty string is UTF8 string - - const unsigned char *c = (const unsigned char*)str; - const unsigned char * const end = (len == wxStringImpl::npos) ? NULL : c + len; - - for ( ; c != end && *c; ++c ) - { - unsigned char b = *c; - - if ( end != NULL ) - { - // if the string is not NULL-terminated, verify we have enough - // bytes in it left for current character's encoding: - if ( c + ms_utf8IterTable[*c] > end ) - return false; - } - - if ( b <= 0x7F ) // 00..7F - continue; - - else if ( b < 0xC2 ) // invalid lead bytes: 80..C1 - return false; - - // two-byte sequences: - else if ( b <= 0xDF ) // C2..DF - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - - // three-byte sequences: - else if ( b == 0xE0 ) - { - b = *(++c); - if ( !(b >= 0xA0 && b <= 0xBF ) ) - return false; - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - else if ( b == 0xED ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0x9F ) ) - return false; - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - else if ( b <= 0xEF ) // E1..EC EE..EF - { - for ( int i = 0; i < 2; ++i ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - } - - // four-byte sequences: - else if ( b == 0xF0 ) - { - b = *(++c); - if ( !(b >= 0x90 && b <= 0xBF ) ) - return false; - for ( int i = 0; i < 2; ++i ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - } - else if ( b <= 0xF3 ) // F1..F3 - { - for ( int i = 0; i < 3; ++i ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - } - else if ( b == 0xF4 ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0x8F ) ) - return false; - for ( int i = 0; i < 2; ++i ) - { - b = *(++c); - if ( !(b >= 0x80 && b <= 0xBF ) ) - return false; - } - } - else // otherwise, it's invalid lead byte - return false; - } - - return true; -} - -// NB: this is in this file and not unichar.cpp to keep all UTF-8 encoding -// code in single place -wxUniChar::Utf8CharBuffer wxUniChar::AsUTF8() const -{ - Utf8CharBuffer buf = { "" }; // init to avoid g++ 4.1 warning with -O2 - char *out = buf.data; - - value_type code = GetValue(); - - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // ----------------------+--------------------------------------------- - // 0000 0000 - 0000 007F | 0xxxxxxx - // 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Code point value is stored in bits marked with 'x', lowest-order bit - // of the value on the right side in the diagram above. - // (from RFC 3629) - - if ( code <= 0x7F ) - { - out[1] = 0; - out[0] = (char)code; - } - else if ( code <= 0x07FF ) - { - out[2] = 0; - // NB: this line takes 6 least significant bits, encodes them as - // 10xxxxxx and discards them so that the next byte can be encoded: - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xC0 | code; - } - else if ( code < 0xFFFF ) - { - out[3] = 0; - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xE0 | code; - } - else if ( code <= 0x10FFFF ) - { - out[4] = 0; - out[3] = 0x80 | (code & 0x3F); code >>= 6; - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xF0 | code; - } - else - { - wxFAIL_MSG( wxT("trying to encode undefined Unicode character") ); - out[0] = 0; - } - - return buf; -} - -wxUniChar -wxStringOperationsUtf8::DecodeNonAsciiChar(wxStringImpl::const_iterator i) -{ - wxASSERT( IsValidUtf8LeadByte(*i) ); - - size_t len = GetUtf8CharLength(*i); - wxASSERT_MSG( len <= 4, wxT("invalid UTF-8 sequence length") ); - - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // ----------------------+--------------------------------------------- - // 0000 0000 - 0000 007F | 0xxxxxxx - // 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Code point value is stored in bits marked with 'x', lowest-order bit - // of the value on the right side in the diagram above. - // (from RFC 3629) - - // mask to extract lead byte's value ('x' bits above), by sequence's length: - static const unsigned char s_leadValueMask[4] = { 0x7F, 0x1F, 0x0F, 0x07 }; -#if wxDEBUG_LEVEL - // mask and value of lead byte's most significant bits, by length: - static const unsigned char s_leadMarkerMask[4] = { 0x80, 0xE0, 0xF0, 0xF8 }; - static const unsigned char s_leadMarkerVal[4] = { 0x00, 0xC0, 0xE0, 0xF0 }; -#endif - - // extract the lead byte's value bits: - wxASSERT_MSG( ((unsigned char)*i & s_leadMarkerMask[len-1]) == - s_leadMarkerVal[len-1], - wxT("invalid UTF-8 lead byte") ); - wxUniChar::value_type code = (unsigned char)*i & s_leadValueMask[len-1]; - - // all remaining bytes, if any, are handled in the same way regardless of - // sequence's length: - for ( ++i ; len > 1; --len, ++i ) - { - wxASSERT_MSG( ((unsigned char)*i & 0xC0) == 0x80, - wxT("invalid UTF-8 byte") ); - - code <<= 6; - code |= (unsigned char)*i & 0x3F; - } - - return wxUniChar(code); -} - -wxCharBuffer wxStringOperationsUtf8::EncodeNChars(size_t n, const wxUniChar& ch) -{ - Utf8CharBuffer once(EncodeChar(ch)); - // the IncIter() table can be used to determine the length of ch's encoding: - size_t len = ms_utf8IterTable[(unsigned char)once.data[0]]; - - wxCharBuffer buf(n * len); - char *ptr = buf.data(); - for ( size_t i = 0; i < n; i++, ptr += len ) - { - memcpy(ptr, once.data, len); - } - - return buf; -} - -#endif // wxUSE_UNICODE_UTF8 diff --git a/Source/3rd Party/wx/src/common/strvararg.cpp b/Source/3rd Party/wx/src/common/strvararg.cpp deleted file mode 100644 index 83d82b338..000000000 --- a/Source/3rd Party/wx/src/common/strvararg.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/strvararg.cpp -// Purpose: macros for implementing type-safe vararg passing of strings -// Author: Vaclav Slavik -// Created: 2007-02-19 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/strvararg.h" -#include "wx/string.h" -#include "wx/crt.h" -#include "wx/private/wxprintf.h" - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxArgNormalizer<> -// ---------------------------------------------------------------------------- - -const wxStringCharType *wxArgNormalizerNative::get() const -{ - return m_value.wx_str(); -} - -const wxStringCharType *wxArgNormalizerNative::get() const -{ - return m_value.AsInternal(); -} - -#if wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY -wxArgNormalizerWchar::wxArgNormalizerWchar( - const wxString& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(s.wc_str(), fmt, index) -{ -} - -wxArgNormalizerWchar::wxArgNormalizerWchar( - const wxCStrData& s, - const wxFormatString *fmt, unsigned index) - : wxArgNormalizerWithBuffer(s.AsWCharBuf(), fmt, index) -{ -} -#endif // wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY - -// ---------------------------------------------------------------------------- -// wxArgNormalizedString -// ---------------------------------------------------------------------------- - -wxString wxArgNormalizedString::GetString() const -{ - if ( !IsValid() ) - return wxEmptyString; - -#if wxUSE_UTF8_LOCALE_ONLY - return wxString(reinterpret_cast(m_ptr)); -#else - #if wxUSE_UNICODE_UTF8 - if ( wxLocaleIsUtf8 ) - return wxString(reinterpret_cast(m_ptr)); - else - #endif - return wxString(reinterpret_cast(m_ptr)); -#endif // !wxUSE_UTF8_LOCALE_ONLY -} - -wxArgNormalizedString::operator wxString() const -{ - return GetString(); -} - -// ---------------------------------------------------------------------------- -// wxFormatConverter: class doing the "%s" and "%c" normalization -// ---------------------------------------------------------------------------- - -/* - There are four problems with wxPrintf() etc. format strings: - - 1) The printf vararg macros convert all forms of strings into - wxStringCharType* representation. This may make the format string - incorrect: for example, if %ls was used together with a wchar_t* - variadic argument, this would no longer work, because the templates - would change wchar_t* argument to wxStringCharType* and %ls would now - be incorrect in e.g. UTF-8 build. We need make sure only one specifier - form is used. - - 2) To complicate matters further, the meaning of %s and %c is different - under Windows and on Unix. The Windows/MS convention is as follows: - - In ANSI mode: - - format specifier results in - ----------------------------------- - %s, %hs, %hS char* - %ls, %S, %lS wchar_t* - - In Unicode mode: - - format specifier results in - ----------------------------------- - %hs, %S, %hS char* - %s, %ls, %lS wchar_t* - - (While on POSIX systems we have %C identical to %lc and %c always means - char (in any mode) while %lc always means wchar_t.) - - In other words, we should _only_ use %s on Windows and %ls on Unix for - wxUSE_UNICODE_WCHAR build. - - 3) To make things even worse, we need two forms in UTF-8 build: one for - passing strings to ANSI functions under UTF-8 locales (this one should - use %s) and one for widechar functions used under non-UTF-8 locales - (this one should use %ls). - - And, of course, the same should be done for %c as well. - - - wxScanf() family of functions is simpler, because we don't normalize their - variadic arguments and we only have to handle 2) above and only for widechar - versions. -*/ - -template -class wxFormatConverterBase -{ -public: - typedef T CharType; - - wxFormatConverterBase() - { - m_fmtOrig = NULL; - m_fmtLast = NULL; - m_nCopied = 0; - } - - wxScopedCharTypeBuffer Convert(const CharType *format) - { - // this is reset to NULL if we modify the format string - m_fmtOrig = format; - - while ( *format ) - { - if ( CopyFmtChar(*format++) == wxT('%') ) - { -#if wxUSE_PRINTF_POS_PARAMS - if ( *format >= '0' && *format <= '9' ) - { - SkipDigits(&format); - if ( *format == '$' ) - { - // It was a positional argument specification. - CopyFmtChar(*format++); - } - //else: it was a width specification, nothing else to do. - } -#endif // wxUSE_PRINTF_POS_PARAMS - - // skip any flags - while ( IsFlagChar(*format) ) - CopyFmtChar(*format++); - - // and possible width - if ( *format == wxT('*') ) - CopyFmtChar(*format++); - else - SkipDigits(&format); - - // precision? - if ( *format == wxT('.') ) - { - CopyFmtChar(*format++); - if ( *format == wxT('*') ) - CopyFmtChar(*format++); - else - SkipDigits(&format); - } - - // next we can have a size modifier - SizeModifier size; - - switch ( *format ) - { - case 'h': - size = Size_Short; - format++; - break; - - case 'l': - // "ll" has a different meaning! - if ( format[1] != 'l' ) - { - size = Size_Long; - format++; - break; - } - //else: fall through - - default: - size = Size_Default; - } - - CharType outConv = *format; - SizeModifier outSize = size; - - // and finally we should have the type - switch ( *format ) - { - case wxT('S'): - case wxT('s'): - // all strings were converted into the same form by - // wxArgNormalizer, this form depends on the context - // in which the value is used (scanf/printf/wprintf): - HandleString(*format, size, outConv, outSize); - break; - - case wxT('C'): - case wxT('c'): - HandleChar(*format, size, outConv, outSize); - break; - - default: - // nothing special to do - break; - } - - if ( outConv == *format && outSize == size ) // no change - { - if ( size != Size_Default ) - CopyFmtChar(*(format - 1)); - CopyFmtChar(*format); - } - else // something changed - { - switch ( outSize ) - { - case Size_Long: - InsertFmtChar(wxT('l')); - break; - - case Size_Short: - InsertFmtChar(wxT('h')); - break; - - case Size_Default: - // nothing to do - break; - } - InsertFmtChar(outConv); - } - - format++; - } - } - - // notice that we only translated the string if m_fmtOrig == NULL (as - // set by CopyAllBefore()), otherwise we should simply use the original - // format - if ( m_fmtOrig ) - { - return wxScopedCharTypeBuffer::CreateNonOwned(m_fmtOrig); - } - else - { - // shrink converted format string to actual size (instead of - // over-sized allocation from CopyAllBefore()) and NUL-terminate - // it: - m_fmt.shrink(m_fmtLast - m_fmt.data()); - return m_fmt; - } - } - - virtual ~wxFormatConverterBase() {} - -protected: - enum SizeModifier - { - Size_Default, - Size_Short, - Size_Long - }; - - // called to handle %S or %s; 'conv' is conversion specifier ('S' or 's' - // respectively), 'size' is the preceding size modifier; the new values of - // conversion and size specifiers must be written to outConv and outSize - virtual void HandleString(CharType conv, SizeModifier size, - CharType& outConv, SizeModifier& outSize) = 0; - - // ditto for %C or %c - virtual void HandleChar(CharType conv, SizeModifier size, - CharType& outConv, SizeModifier& outSize) = 0; - -private: - // copy another character to the translated format: this function does the - // copy if we are translating but doesn't do anything at all if we don't, - // so we don't create the translated format string at all unless we really - // need to (i.e. InsertFmtChar() is called) - CharType CopyFmtChar(CharType ch) - { - if ( !m_fmtOrig ) - { - // we're translating, do copy - *(m_fmtLast++) = ch; - } - else - { - // simply increase the count which should be copied by - // CopyAllBefore() later if needed - m_nCopied++; - } - - return ch; - } - - // insert an extra character - void InsertFmtChar(CharType ch) - { - if ( m_fmtOrig ) - { - // so far we haven't translated anything yet - CopyAllBefore(); - } - - *(m_fmtLast++) = ch; - } - - void CopyAllBefore() - { - wxASSERT_MSG( m_fmtOrig && m_fmt.data() == NULL, "logic error" ); - - // the modified format string is guaranteed to be no longer than - // 3/2 of the original (worst case: the entire format string consists - // of "%s" repeated and is expanded to "%ls" on Unix), so we can - // allocate the buffer now and not worry about running out of space if - // we over-allocate a bit: - size_t fmtLen = wxStrlen(m_fmtOrig); - // worst case is of even length, so there's no rounding error in *3/2: - m_fmt.extend(fmtLen * 3 / 2); - - if ( m_nCopied > 0 ) - wxStrncpy(m_fmt.data(), m_fmtOrig, m_nCopied); - m_fmtLast = m_fmt.data() + m_nCopied; - - // we won't need it any longer and resetting it also indicates that we - // modified the format - m_fmtOrig = NULL; - } - - static bool IsFlagChar(CharType ch) - { - return ch == wxT('-') || ch == wxT('+') || - ch == wxT('0') || ch == wxT(' ') || ch == wxT('#'); - } - - void SkipDigits(const CharType **ptpc) - { - while ( **ptpc >= wxT('0') && **ptpc <= wxT('9') ) - CopyFmtChar(*(*ptpc)++); - } - - // the translated format - wxCharTypeBuffer m_fmt; - CharType *m_fmtLast; - - // the original format - const CharType *m_fmtOrig; - - // the number of characters already copied (i.e. already parsed, but left - // unmodified) - size_t m_nCopied; -}; - -#if defined(__WINDOWS__) && !defined(__CYGWIN__) - -// on Windows, we should use %s and %c regardless of the build: -class wxPrintfFormatConverterWchar : public wxFormatConverterBase -{ - virtual void HandleString(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = Size_Default; - } - - virtual void HandleChar(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 'c'; - outSize = Size_Default; - } -}; - -#else // !__WINDOWS__ - -// on Unix, it's %s for ANSI functions and %ls for widechar: - -#if !wxUSE_UTF8_LOCALE_ONLY -class wxPrintfFormatConverterWchar : public wxFormatConverterBase -{ - virtual void HandleString(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = Size_Long; - } - - virtual void HandleChar(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 'c'; - outSize = Size_Long; - } -}; -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#endif // __WINDOWS__/!__WINDOWS__ - -#if wxUSE_UNICODE_UTF8 -class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase -{ - virtual void HandleString(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = Size_Default; - } - - virtual void HandleChar(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - // chars are represented using wchar_t in both builds, so this is - // the same as above - outConv = 'c'; - outSize = Size_Long; - } -}; -#endif // wxUSE_UNICODE_UTF8 - -#if !wxUSE_UNICODE // FIXME-UTF8: remove -class wxPrintfFormatConverterANSI : public wxFormatConverterBase -{ - virtual void HandleString(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = Size_Default; - } - - virtual void HandleChar(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 'c'; - outSize = Size_Default; - } -}; -#endif // ANSI - -#ifndef __WINDOWS__ -/* - - wxScanf() format translation is different, we need to translate %s to %ls - and %c to %lc on Unix (but not Windows and for widechar functions only!). - - So to use native functions in order to get our semantics we must do the - following translations in Unicode mode: - - wxWidgets specifier POSIX specifier - ---------------------------------------- - - %hc, %C, %hC %c - %c %lc - - */ -class wxScanfFormatConverterWchar : public wxFormatConverterBase -{ - virtual void HandleString(CharType conv, SizeModifier size, - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = GetOutSize(conv == 'S', size); - } - - virtual void HandleChar(CharType conv, SizeModifier size, - CharType& outConv, SizeModifier& outSize) - { - outConv = 'c'; - outSize = GetOutSize(conv == 'C', size); - } - - SizeModifier GetOutSize(bool convIsUpper, SizeModifier size) - { - // %S and %hS -> %s and %lS -> %ls - if ( convIsUpper ) - { - if ( size == Size_Long ) - return Size_Long; - else - return Size_Default; - } - else // %s or %c - { - if ( size == Size_Default ) - return Size_Long; - else - return size; - } - } -}; - -const wxScopedWCharBuffer wxScanfConvertFormatW(const wchar_t *format) -{ - return wxScanfFormatConverterWchar().Convert(format); -} -#endif // !__WINDOWS__ - - -// ---------------------------------------------------------------------------- -// wxFormatString -// ---------------------------------------------------------------------------- - -#if !wxUSE_UNICODE_WCHAR -const char* wxFormatString::InputAsChar() -{ - if ( m_char ) - return m_char.data(); - - // in ANSI build, wx_str() returns char*, in UTF-8 build, this function - // is only called under UTF-8 locales, so we should return UTF-8 string, - // which is, again, what wx_str() returns: - if ( m_str ) - return m_str->wx_str(); - - // ditto wxCStrData: - if ( m_cstr ) - return m_cstr->AsInternal(); - - // the last case is that wide string was passed in: in that case, we need - // to convert it: - wxASSERT( m_wchar ); - - m_char = wxConvLibc.cWC2MB(m_wchar.data()); - - return m_char.data(); -} - -const char* wxFormatString::AsChar() -{ - if ( !m_convertedChar ) -#if !wxUSE_UNICODE // FIXME-UTF8: remove this - m_convertedChar = wxPrintfFormatConverterANSI().Convert(InputAsChar()); -#else - m_convertedChar = wxPrintfFormatConverterUtf8().Convert(InputAsChar()); -#endif - - return m_convertedChar.data(); -} -#endif // !wxUSE_UNICODE_WCHAR - -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY -const wchar_t* wxFormatString::InputAsWChar() -{ - if ( m_wchar ) - return m_wchar.data(); - -#if wxUSE_UNICODE_WCHAR - if ( m_str ) - return m_str->wc_str(); - if ( m_cstr ) - return m_cstr->AsInternal(); -#else // wxUSE_UNICODE_UTF8 - if ( m_str ) - { - m_wchar = m_str->wc_str(); - return m_wchar.data(); - } - if ( m_cstr ) - { - m_wchar = m_cstr->AsWCharBuf(); - return m_wchar.data(); - } -#endif // wxUSE_UNICODE_WCHAR/UTF8 - - // the last case is that narrow string was passed in: in that case, we need - // to convert it: - wxASSERT( m_char ); - - m_wchar = wxConvLibc.cMB2WC(m_char.data()); - - return m_wchar.data(); -} - -const wchar_t* wxFormatString::AsWChar() -{ - if ( !m_convertedWChar ) - m_convertedWChar = wxPrintfFormatConverterWchar().Convert(InputAsWChar()); - - return m_convertedWChar.data(); -} -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY - -wxString wxFormatString::InputAsString() const -{ - if ( m_str ) - return *m_str; - if ( m_cstr ) - return m_cstr->AsString(); - if ( m_wchar ) - return wxString(m_wchar); - if ( m_char ) - return wxString(m_char); - - wxFAIL_MSG( "invalid wxFormatString - not initialized?" ); - return wxString(); -} - -// ---------------------------------------------------------------------------- -// wxFormatString::GetArgumentType() -// ---------------------------------------------------------------------------- - -namespace -{ - -template -wxFormatString::ArgumentType DoGetArgumentType(const CharType *format, - unsigned n) -{ - wxCHECK_MSG( format, wxFormatString::Arg_Unknown, - "empty format string not allowed here" ); - - wxPrintfConvSpecParser parser(format); - - if ( n > parser.nargs ) - { - // The n-th argument doesn't appear in the format string and is unused. - // This can happen e.g. if a translation of the format string is used - // and the translation language tends to avoid numbers in singular forms. - // The translator would then typically replace "%d" with "One" (e.g. in - // Hebrew). Passing too many vararg arguments does not harm, so its - // better to be more permissive here and allow legitimate uses in favour - // of catching harmless errors. - return wxFormatString::Arg_Unused; - } - - wxCHECK_MSG( parser.pspec[n-1] != NULL, wxFormatString::Arg_Unknown, - "requested argument not found - invalid format string?" ); - - switch ( parser.pspec[n-1]->m_type ) - { - case wxPAT_CHAR: - case wxPAT_WCHAR: - return wxFormatString::Arg_Char; - - case wxPAT_PCHAR: - case wxPAT_PWCHAR: - return wxFormatString::Arg_String; - - case wxPAT_INT: - return wxFormatString::Arg_Int; - case wxPAT_LONGINT: - return wxFormatString::Arg_LongInt; -#ifdef wxLongLong_t - case wxPAT_LONGLONGINT: - return wxFormatString::Arg_LongLongInt; -#endif - case wxPAT_SIZET: - return wxFormatString::Arg_Size_t; - - case wxPAT_DOUBLE: - return wxFormatString::Arg_Double; - case wxPAT_LONGDOUBLE: - return wxFormatString::Arg_LongDouble; - - case wxPAT_POINTER: - return wxFormatString::Arg_Pointer; - - case wxPAT_NINT: - return wxFormatString::Arg_IntPtr; - case wxPAT_NSHORTINT: - return wxFormatString::Arg_ShortIntPtr; - case wxPAT_NLONGINT: - return wxFormatString::Arg_LongIntPtr; - - case wxPAT_STAR: - // "*" requires argument of type int - return wxFormatString::Arg_Int; - - case wxPAT_INVALID: - // (handled after the switch statement) - break; - } - - // silence warning - wxFAIL_MSG( "unexpected argument type" ); - return wxFormatString::Arg_Unknown; -} - -} // anonymous namespace - -wxFormatString::ArgumentType wxFormatString::GetArgumentType(unsigned n) const -{ - if ( m_char ) - return DoGetArgumentType(m_char.data(), n); - else if ( m_wchar ) - return DoGetArgumentType(m_wchar.data(), n); - else if ( m_str ) - return DoGetArgumentType(m_str->wx_str(), n); - else if ( m_cstr ) - return DoGetArgumentType(m_cstr->AsInternal(), n); - - wxFAIL_MSG( "unreachable code" ); - return Arg_Unknown; -} diff --git a/Source/3rd Party/wx/src/common/sysopt.cpp b/Source/3rd Party/wx/src/common/sysopt.cpp index ede2e7a54..7a61ad01b 100644 --- a/Source/3rd Party/wx/src/common/sysopt.cpp +++ b/Source/3rd Party/wx/src/common/sysopt.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2001-07-10 +// RCS-ID: $Id: sysopt.cpp 39851 2006-06-27 14:33:14Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -75,24 +76,23 @@ wxString wxSystemOptions::GetOption(const wxString& name) { val = gs_optionValues[idx]; } - else // not set explicitly + else // not set explicitely { // look in the environment: first for a variable named "wx_appname_name" // which can be set to affect the behaviour or just this application // and then for "wx_name" which can be set to change the option globally wxString var(name); - var.Replace(wxT("."), wxT("_")); // '.'s not allowed in env var names - var.Replace(wxT("-"), wxT("_")); // and neither are '-'s + var.Replace(_T("."), _T("_")); // '.'s not allowed in env var names wxString appname; if ( wxTheApp ) appname = wxTheApp->GetAppName(); if ( !appname.empty() ) - val = wxGetenv(wxT("wx_") + appname + wxT('_') + var); + val = wxGetenv(_T("wx_") + appname + _T('_') + var); if ( val.empty() ) - val = wxGetenv(wxT("wx_") + var); + val = wxGetenv(_T("wx_") + var); } return val; @@ -100,7 +100,7 @@ wxString wxSystemOptions::GetOption(const wxString& name) int wxSystemOptions::GetOptionInt(const wxString& name) { - return wxAtoi (GetOption(name)); + return wxAtoi(GetOption(name)); } bool wxSystemOptions::HasOption(const wxString& name) diff --git a/Source/3rd Party/wx/src/common/tarstrm.cpp b/Source/3rd Party/wx/src/common/tarstrm.cpp index ef74c3d8e..5315a996c 100644 --- a/Source/3rd Party/wx/src/common/tarstrm.cpp +++ b/Source/3rd Party/wx/src/common/tarstrm.cpp @@ -1,7 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/tarstrm.cpp +// Name: tarstrm.cpp // Purpose: Streams for Tar files // Author: Mike Wetherell +// RCS-ID: $Id: tarstrm.cpp 63302 2010-01-28 21:46:09Z MW $ // Copyright: (c) 2004 Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -25,7 +26,7 @@ #include "wx/buffer.h" #include "wx/datetime.h" -#include "wx/scopedptr.h" +#include "wx/ptr_scpd.h" #include "wx/filename.h" #include "wx/thread.h" @@ -103,9 +104,9 @@ wxTarClassFactory::wxTarClassFactory() const wxChar * const * wxTarClassFactory::GetProtocols(wxStreamProtocolType type) const { - static const wxChar *protocols[] = { wxT("tar"), NULL }; - static const wxChar *mimetypes[] = { wxT("application/x-tar"), NULL }; - static const wxChar *fileexts[] = { wxT(".tar"), NULL }; + static const wxChar *protocols[] = { _T("tar"), NULL }; + static const wxChar *mimetypes[] = { _T("application/x-tar"), NULL }; + static const wxChar *fileexts[] = { _T(".tar"), NULL }; static const wxChar *empty[] = { NULL }; switch (type) { @@ -160,23 +161,23 @@ wxDEFINE_SCOPED_PTR_TYPE(wxTarHeaderBlock) // A table giving the field names and offsets in a tar header block const wxTarField wxTarHeaderBlock::fields[] = { - { wxT("name"), 0 }, // 100 - { wxT("mode"), 100 }, // 8 - { wxT("uid"), 108 }, // 8 - { wxT("gid"), 116 }, // 8 - { wxT("size"), 124 }, // 12 - { wxT("mtime"), 136 }, // 12 - { wxT("chksum"), 148 }, // 8 - { wxT("typeflag"), 156 }, // 1 - { wxT("linkname"), 157 }, // 100 - { wxT("magic"), 257 }, // 6 - { wxT("version"), 263 }, // 2 - { wxT("uname"), 265 }, // 32 - { wxT("gname"), 297 }, // 32 - { wxT("devmajor"), 329 }, // 8 - { wxT("devminor"), 337 }, // 8 - { wxT("prefix"), 345 }, // 155 - { wxT("unused"), 500 }, // 12 + { _T("name"), 0 }, // 100 + { _T("mode"), 100 }, // 8 + { _T("uid"), 108 }, // 8 + { _T("gid"), 116 }, // 8 + { _T("size"), 124 }, // 12 + { _T("mtime"), 136 }, // 12 + { _T("chksum"), 148 }, // 8 + { _T("typeflag"), 156 }, // 1 + { _T("linkname"), 157 }, // 100 + { _T("magic"), 257 }, // 6 + { _T("version"), 263 }, // 2 + { _T("uname"), 265 }, // 32 + { _T("gname"), 297 }, // 32 + { _T("devmajor"), 329 }, // 8 + { _T("devminor"), 337 }, // 8 + { _T("prefix"), 345 }, // 155 + { _T("unused"), 500 }, // 12 { NULL, TAR_BLOCKSIZE } }; @@ -290,10 +291,7 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv) size_t len = name.length(); wxCharBuffer approx(len); for (size_t i = 0; i < len; i++) - { - wxChar c = name[i]; - approx.data()[i] = c & ~0x7F ? '_' : c; - } + approx.data()[i] = name[i] & ~0x7F ? '_' : name[i]; nameBuf = approx; } @@ -538,15 +536,15 @@ wxString wxTarEntry::GetName(wxPathFormat format /*=wxPATH_NATIVE*/) const switch (wxFileName::GetFormat(format)) { case wxPATH_DOS: { - wxString name(isDir ? m_Name + wxT("\\") : m_Name); + wxString name(isDir ? m_Name + _T("\\") : m_Name); for (size_t i = 0; i < name.length(); i++) - if (name[i] == wxT('/')) - name[i] = wxT('\\'); + if (name[i] == _T('/')) + name[i] = _T('\\'); return name; } case wxPATH_UNIX: - return isDir ? m_Name + wxT("/") : m_Name; + return isDir ? m_Name + _T("/") : m_Name; default: ; @@ -593,9 +591,9 @@ wxString wxTarEntry::GetInternalName(const wxString& name, while (!internal.empty() && *internal.begin() == '/') internal.erase(0, 1); - while (!internal.empty() && internal.compare(0, 2, wxT("./")) == 0) + while (!internal.empty() && internal.compare(0, 2, _T("./")) == 0) internal.erase(0, 2); - if (internal == wxT(".") || internal == wxT("..")) + if (internal == _T(".") || internal == _T("..")) internal = wxEmptyString; return internal; @@ -694,9 +692,9 @@ wxTarEntry *wxTarInputStream::GetNextEntry() entry->SetOffset(m_offset); - entry->SetDateTime(GetHeaderDate(wxT("mtime"))); - entry->SetAccessTime(GetHeaderDate(wxT("atime"))); - entry->SetCreateTime(GetHeaderDate(wxT("ctime"))); + entry->SetDateTime(GetHeaderDate(_T("mtime"))); + entry->SetAccessTime(GetHeaderDate(_T("atime"))); + entry->SetCreateTime(GetHeaderDate(_T("ctime"))); entry->SetTypeFlag(*m_hdr->Get(TAR_TYPEFLAG)); bool isDir = entry->IsDir(); @@ -792,9 +790,7 @@ wxStreamError wxTarInputStream::ReadHeaders() while (!done) { m_hdr->Read(*m_parent_i_stream); if (m_parent_i_stream->Eof()) - { wxLogError(_("incomplete header block in tar")); - } if (!*m_parent_i_stream) return wxSTREAM_READ_ERROR; m_offset += TAR_BLOCKSIZE; @@ -867,7 +863,7 @@ wxString wxTarInputStream::GetHeaderPath() const { wxString path; - if ((path = GetExtendedHeader(wxT("path"))) != wxEmptyString) + if ((path = GetExtendedHeader(_T("path"))) != wxEmptyString) return path; path = wxString(m_hdr->Get(TAR_NAME), GetConv()); @@ -875,7 +871,7 @@ wxString wxTarInputStream::GetHeaderPath() const return path; const char *prefix = m_hdr->Get(TAR_PREFIX); - return *prefix ? wxString(prefix, GetConv()) + wxT("/") + path : path; + return *prefix ? wxString(prefix, GetConv()) + _T("/") + path : path; } wxDateTime wxTarInputStream::GetHeaderDate(const wxString& key) const @@ -889,7 +885,7 @@ wxDateTime wxTarInputStream::GetHeaderDate(const wxString& key) const return ll; } - if (key == wxT("mtime")) + if (key == _T("mtime")) return wxLongLong(m_hdr->GetOctal(TAR_MTIME)) * 1000L; return wxDateTime(); @@ -901,8 +897,8 @@ wxTarNumber wxTarInputStream::GetHeaderNumber(int id) const if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString) { wxTarNumber n = 0; - wxString::const_iterator p = value.begin(); - while (p != value.end() && *p == ' ') + const wxChar *p = value; + while (*p == ' ') p++; while (isdigit(*p)) n = n * 10 + (*p++ - '0'); @@ -946,7 +942,7 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs) size_t recPos, recSize; bool ok = true; - for (recPos = 0; recPos < len && ok; recPos += recSize) { + for (recPos = 0; recPos < len; recPos += recSize) { char *pRec = buf.data() + recPos; char *p = pRec; @@ -1041,9 +1037,7 @@ size_t wxTarInputStream::OnSysRead(void *buffer, size_t size) } else if (!m_parent_i_stream->IsOk()) { // any other error will have been reported by the underlying stream if (m_parent_i_stream->Eof()) - { wxLogError(_("unexpected end of file")); - } m_lasterror = wxSTREAM_READ_ERROR; } @@ -1088,12 +1082,12 @@ void wxTarOutputStream::Init(wxTarFormat format) m_extendedHdr = NULL; m_extendedSize = 0; m_lasterror = m_parent_o_stream->GetLastError(); - m_endrecWritten = false; } wxTarOutputStream::~wxTarOutputStream() { - Close(); + if (m_tarsize) + Close(); delete m_hdr; delete m_hdr2; delete [] m_extendedHdr; @@ -1212,7 +1206,7 @@ bool wxTarOutputStream::CloseEntry() bool wxTarOutputStream::Close() { - if (!CloseEntry() || (m_tarsize == 0 && m_endrecWritten)) + if (!CloseEntry()) return false; memset(m_hdr, 0, sizeof(*m_hdr)); @@ -1224,7 +1218,6 @@ bool wxTarOutputStream::Close() m_tarsize = 0; m_tarstart = wxInvalidOffset; m_lasterror = m_parent_o_stream->GetLastError(); - m_endrecWritten = true; return IsOk(); } @@ -1242,11 +1235,11 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry) entry.SetSize(0); m_large = !SetHeaderNumber(TAR_SIZE, entry.GetSize()); - SetHeaderDate(wxT("mtime"), entry.GetDateTime()); + SetHeaderDate(_T("mtime"), entry.GetDateTime()); if (entry.GetAccessTime().IsValid()) - SetHeaderDate(wxT("atime"), entry.GetAccessTime()); + SetHeaderDate(_T("atime"), entry.GetAccessTime()); if (entry.GetCreateTime().IsValid()) - SetHeaderDate(wxT("ctime"), entry.GetCreateTime()); + SetHeaderDate(_T("ctime"), entry.GetCreateTime()); *m_hdr->Get(TAR_TYPEFLAG) = char(entry.GetTypeFlag()); @@ -1281,7 +1274,7 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry) // an old tar that doesn't understand extended headers will // extract it as a file, so give these fields reasonable values // so that the user will have access to read and remove it. - m_hdr2->SetPath(PaxHeaderPath(wxT("%d/PaxHeaders.%p/%f"), + m_hdr2->SetPath(PaxHeaderPath(_T("%d/PaxHeaders.%p/%f"), entry.GetName(wxPATH_UNIX)), GetConv()); m_hdr2->SetOctal(TAR_MODE, 0600); strcpy(m_hdr2->Get(TAR_UID), m_hdr->Get(TAR_UID)); @@ -1331,12 +1324,12 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry) wxString wxTarOutputStream::PaxHeaderPath(const wxString& format, const wxString& path) { - wxString d = path.BeforeLast(wxT('/')); - wxString f = path.AfterLast(wxT('/')); + wxString d = path.BeforeLast(_T('/')); + wxString f = path.AfterLast(_T('/')); wxString ret; if (d.empty()) - d = wxT("."); + d = _T("."); ret.reserve(format.length() + path.length() + 16); @@ -1348,11 +1341,11 @@ wxString wxTarOutputStream::PaxHeaderPath(const wxString& format, if (end == wxString::npos || end + 1 >= format.length()) break; ret << format.substr(begin, end - begin); - switch ( format[end + 1].GetValue() ) { + switch (format[end + 1]) { case 'd': ret << d; break; case 'f': ret << f; break; case 'p': ret << wxGetProcessId(); break; - case '%': ret << wxT("%"); break; + case '%': ret << _T("%"); break; } begin = end + 2; } @@ -1397,7 +1390,7 @@ bool wxTarOutputStream::ModifyHeader() void wxTarOutputStream::SetHeaderPath(const wxString& name) { if (!m_hdr->SetPath(name, GetConv()) || (m_pax && !name.IsAscii())) - SetExtendedHeader(wxT("path"), name); + SetExtendedHeader(_T("path"), name); } bool wxTarOutputStream::SetHeaderNumber(int id, wxTarNumber n) @@ -1423,13 +1416,13 @@ void wxTarOutputStream::SetHeaderDate(const wxString& key, wxLongLong ll = datetime.IsValid() ? datetime.GetValue() : wxLongLong(0); wxLongLong secs = ll / 1000L; - if (key != wxT("mtime") + if (key != _T("mtime") || !m_hdr->SetOctal(TAR_MTIME, wxTarNumber(secs.GetValue())) || secs <= 0 || secs >= 0x7fffffff) { wxString str; if (ll >= LONG_MIN && ll <= LONG_MAX) { - str.Printf(wxT("%g"), ll.ToLong() / 1000.0); + str.Printf(_T("%g"), ll.ToLong() / 1000.0); } else { str = ll.ToString(); str.insert(str.end() - 3, '.'); @@ -1442,16 +1435,11 @@ void wxTarOutputStream::SetExtendedHeader(const wxString& key, const wxString& value) { if (m_pax) { -#if wxUSE_UNICODE - const wxCharBuffer utf_key = key.utf8_str(); - const wxCharBuffer utf_value = value.utf8_str(); -#else const wxWX2WCbuf wide_key = key.wc_str(GetConv()); const wxCharBuffer utf_key = wxConvUTF8.cWC2MB(wide_key); const wxWX2WCbuf wide_value = value.wc_str(GetConv()); const wxCharBuffer utf_value = wxConvUTF8.cWC2MB(wide_value); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // a small buffer to format the length field in char buf[32]; @@ -1491,7 +1479,7 @@ void wxTarOutputStream::SetExtendedHeader(const wxString& key, else { // if not pax then make a list of fields to report as errors if (!m_badfit.empty()) - m_badfit += wxT(", "); + m_badfit += _T(", "); m_badfit += key; } } diff --git a/Source/3rd Party/wx/src/common/taskbarcmn.cpp b/Source/3rd Party/wx/src/common/taskbarcmn.cpp deleted file mode 100644 index 54133a57d..000000000 --- a/Source/3rd Party/wx/src/common/taskbarcmn.cpp +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// File: src/common/taskbarcmn.cpp -// Purpose: Common parts of wxTaskBarIcon class -// Author: Julian Smart -// Modified by: -// Created: 04/04/2003 -// Copyright: (c) Julian Smart, 2003 -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_TASKBARICON - -#include "wx/taskbar.h" - -#ifndef WX_PRECOMP - #include "wx/app.h" - #include "wx/list.h" - #include "wx/menu.h" -#endif - -extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; - -// DLL options compatibility check: -WX_CHECK_BUILD_OPTIONS("wxAdvanced") - -wxDEFINE_EVENT( wxEVT_TASKBAR_MOVE, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_LEFT_UP, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_RIGHT_DOWN, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_RIGHT_UP, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_LEFT_DCLICK, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_RIGHT_DCLICK, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_BALLOON_TIMEOUT, wxTaskBarIconEvent ); -wxDEFINE_EVENT( wxEVT_TASKBAR_BALLOON_CLICK, wxTaskBarIconEvent ); - - -BEGIN_EVENT_TABLE(wxTaskBarIconBase, wxEvtHandler) - EVT_TASKBAR_CLICK(wxTaskBarIconBase::OnRightButtonDown) -END_EVENT_TABLE() - -void wxTaskBarIconBase::OnRightButtonDown(wxTaskBarIconEvent& WXUNUSED(event)) -{ - wxMenu *menu = CreatePopupMenu(); - if (menu) - { - PopupMenu(menu); - delete menu; - } -} - -void wxTaskBarIconBase::Destroy() -{ - wxPendingDelete.Append(this); -} - -#endif // wxUSE_TASKBARICON diff --git a/Source/3rd Party/wx/src/common/tbarbase.cpp b/Source/3rd Party/wx/src/common/tbarbase.cpp index e36d96ecc..084d17c06 100644 --- a/Source/3rd Party/wx/src/common/tbarbase.cpp +++ b/Source/3rd Party/wx/src/common/tbarbase.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: VZ at 11.12.99 (wxScrollableToolBar split off) // Created: 04/01/98 +// RCS-ID: $Id: tbarbase.cpp 42840 2006-10-31 13:09:08Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,14 +32,9 @@ #include "wx/control.h" #include "wx/frame.h" #include "wx/settings.h" - #if WXWIN_COMPATIBILITY_2_8 - #include "wx/image.h" - #endif // WXWIN_COMPATIBILITY_2_8 - #include "wx/menu.h" + #include "wx/image.h" #endif -extern WXDLLEXPORT_DATA(const char) wxToolBarNameStr[] = "toolbar"; - // ---------------------------------------------------------------------------- // wxWidgets macros // ---------------------------------------------------------------------------- @@ -60,17 +56,6 @@ WX_DEFINE_LIST(wxToolBarToolsList) IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) -wxToolBarToolBase::~wxToolBarToolBase() -{ -#if wxUSE_MENUS - delete m_dropdownMenu; -#endif - - if ( IsControl() ) - GetControl()->Destroy(); -} - - bool wxToolBarToolBase::Enable(bool enable) { if ( m_enabled == enable ) @@ -83,7 +68,7 @@ bool wxToolBarToolBase::Enable(bool enable) bool wxToolBarToolBase::Toggle(bool toggle) { - wxASSERT_MSG( CanBeToggled(), wxT("can't toggle this tool") ); + wxASSERT_MSG( CanBeToggled(), _T("can't toggle this tool") ); if ( m_toggled == toggle ) return false; @@ -124,16 +109,6 @@ bool wxToolBarToolBase::SetLongHelp(const wxString& help) return true; } - -#if wxUSE_MENUS -void wxToolBarToolBase::SetDropdownMenu(wxMenu* menu) -{ - delete m_dropdownMenu; - m_dropdownMenu = menu; -} -#endif - - // ---------------------------------------------------------------------------- // wxToolBarBase adding/deleting items // ---------------------------------------------------------------------------- @@ -157,7 +132,7 @@ void wxToolBarBase::FixupStyle() } } -wxToolBarToolBase *wxToolBarBase::DoAddTool(int toolid, +wxToolBarToolBase *wxToolBarBase::DoAddTool(int id, const wxString& label, const wxBitmap& bitmap, const wxBitmap& bmpDisabled, @@ -169,12 +144,12 @@ wxToolBarToolBase *wxToolBarBase::DoAddTool(int toolid, wxCoord WXUNUSED(yPos)) { InvalidateBestSize(); - return InsertTool(GetToolsCount(), toolid, label, bitmap, bmpDisabled, + return InsertTool(GetToolsCount(), id, label, bitmap, bmpDisabled, kind, shortHelp, longHelp, clientData); } wxToolBarToolBase *wxToolBarBase::InsertTool(size_t pos, - int toolid, + int id, const wxString& label, const wxBitmap& bitmap, const wxBitmap& bmpDisabled, @@ -183,11 +158,20 @@ wxToolBarToolBase *wxToolBarBase::InsertTool(size_t pos, const wxString& longHelp, wxObject *clientData) { - wxCHECK_MSG( pos <= GetToolsCount(), NULL, - wxT("invalid position in wxToolBar::InsertTool()") ); + wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL, + _T("invalid position in wxToolBar::InsertTool()") ); - return DoInsertNewTool(pos, CreateTool(toolid, label, bitmap, bmpDisabled, kind, - clientData, shortHelp, longHelp)); + wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind, + clientData, shortHelp, longHelp); + + if ( !InsertTool(pos, tool) ) + { + delete tool; + + return NULL; + } + + return tool; } wxToolBarToolBase *wxToolBarBase::AddTool(wxToolBarToolBase *tool) @@ -198,8 +182,8 @@ wxToolBarToolBase *wxToolBarBase::AddTool(wxToolBarToolBase *tool) wxToolBarToolBase * wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool) { - wxCHECK_MSG( pos <= GetToolsCount(), NULL, - wxT("invalid position in wxToolBar::InsertTool()") ); + wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL, + _T("invalid position in wxToolBar::InsertTool()") ); if ( !tool || !DoInsertTool(pos, tool) ) { @@ -207,32 +191,39 @@ wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool) } m_tools.Insert(pos, tool); - tool->Attach(this); return tool; } -wxToolBarToolBase * -wxToolBarBase::AddControl(wxControl *control, const wxString& label) +wxToolBarToolBase *wxToolBarBase::AddControl(wxControl *control) { - return InsertControl(GetToolsCount(), control, label); + return InsertControl(GetToolsCount(), control); } -wxToolBarToolBase * -wxToolBarBase::InsertControl(size_t pos, - wxControl *control, - const wxString& label) +wxToolBarToolBase *wxToolBarBase::InsertControl(size_t pos, wxControl *control) { - wxCHECK_MSG( control, NULL, - wxT("toolbar: can't insert NULL control") ); + wxCHECK_MSG( control, (wxToolBarToolBase *)NULL, + _T("toolbar: can't insert NULL control") ); - wxCHECK_MSG( control->GetParent() == this, NULL, - wxT("control must have toolbar as parent") ); + wxCHECK_MSG( control->GetParent() == this, (wxToolBarToolBase *)NULL, + _T("control must have toolbar as parent") ); - return DoInsertNewTool(pos, CreateTool(control, label)); + wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL, + _T("invalid position in wxToolBar::InsertControl()") ); + + wxToolBarToolBase *tool = CreateTool(control); + + if ( !InsertTool(pos, tool) ) + { + delete tool; + + return NULL; + } + + return tool; } -wxControl *wxToolBarBase::FindControl( int toolid ) +wxControl *wxToolBarBase::FindControl( int id ) { for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; @@ -245,9 +236,9 @@ wxControl *wxToolBarBase::FindControl( int toolid ) if ( !control ) { - wxFAIL_MSG( wxT("NULL control in toolbar?") ); + wxFAIL_MSG( _T("NULL control in toolbar?") ); } - else if ( control->GetId() == toolid ) + else if ( control->GetId() == id ) { // found return control; @@ -265,38 +256,34 @@ wxToolBarToolBase *wxToolBarBase::AddSeparator() wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos) { - return DoInsertNewTool(pos, CreateSeparator()); -} + wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL, + _T("invalid position in wxToolBar::InsertSeparator()") ); -wxToolBarToolBase *wxToolBarBase::AddStretchableSpace() -{ - return InsertStretchableSpace(GetToolsCount()); -} + wxToolBarToolBase *tool = CreateTool(wxID_SEPARATOR, + wxEmptyString, + wxNullBitmap, wxNullBitmap, + wxITEM_SEPARATOR, (wxObject *)NULL, + wxEmptyString, wxEmptyString); -wxToolBarToolBase *wxToolBarBase::InsertStretchableSpace(size_t pos) -{ - wxToolBarToolBase * const tool = CreateSeparator(); - if ( tool ) + if ( !tool || !DoInsertTool(pos, tool) ) { - // this is a hack but we know that all the current implementations - // don't really use the tool when it's created, they will do it - // InsertTool() at earliest and maybe even in Realize() much later - // - // so we can create the tool as a plain separator and mark it as being - // a stretchable space later - tool->MakeStretchable(); + delete tool; + + return NULL; } - return DoInsertNewTool(pos, tool); + m_tools.Insert(pos, tool); + + return tool; } -wxToolBarToolBase *wxToolBarBase::RemoveTool(int toolid) +wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) { size_t pos = 0; wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { - if ( node->GetData()->GetId() == toolid ) + if ( node->GetData()->GetId() == id ) break; pos++; @@ -306,26 +293,24 @@ wxToolBarToolBase *wxToolBarBase::RemoveTool(int toolid) { // don't give any error messages - sometimes we might call RemoveTool() // without knowing whether the tool is or not in the toolbar - return NULL; + return (wxToolBarToolBase *)NULL; } wxToolBarToolBase *tool = node->GetData(); - wxCHECK_MSG( tool, NULL, "NULL tool in the tools list?" ); - if ( !DoDeleteTool(pos, tool) ) - return NULL; + { + return (wxToolBarToolBase *)NULL; + } m_tools.Erase(node); - tool->Detach(); - return tool; } bool wxToolBarBase::DeleteToolByPos(size_t pos) { wxCHECK_MSG( pos < GetToolsCount(), false, - wxT("invalid position in wxToolBar::DeleteToolByPos()") ); + _T("invalid position in wxToolBar::DeleteToolByPos()") ); wxToolBarToolsList::compatibility_iterator node = m_tools.Item(pos); @@ -340,13 +325,13 @@ bool wxToolBarBase::DeleteToolByPos(size_t pos) return true; } -bool wxToolBarBase::DeleteTool(int toolid) +bool wxToolBarBase::DeleteTool(int id) { size_t pos = 0; wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { - if ( node->GetData()->GetId() == toolid ) + if ( node->GetData()->GetId() == id ) break; pos++; @@ -363,16 +348,16 @@ bool wxToolBarBase::DeleteTool(int toolid) return true; } -wxToolBarToolBase *wxToolBarBase::FindById(int toolid) const +wxToolBarToolBase *wxToolBarBase::FindById(int id) const { - wxToolBarToolBase *tool = NULL; + wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL; for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { tool = node->GetData(); - if ( tool->GetId() == toolid ) + if ( tool->GetId() == id ) { // found break; @@ -386,13 +371,13 @@ wxToolBarToolBase *wxToolBarBase::FindById(int toolid) const void wxToolBarBase::UnToggleRadioGroup(wxToolBarToolBase *tool) { - wxCHECK_RET( tool, wxT("NULL tool in wxToolBarTool::UnToggleRadioGroup") ); + wxCHECK_RET( tool, _T("NULL tool in wxToolBarTool::UnToggleRadioGroup") ); if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO ) return; wxToolBarToolsList::compatibility_iterator node = m_tools.Find(tool); - wxCHECK_RET( node, wxT("invalid tool in wxToolBarTool::UnToggleRadioGroup") ); + wxCHECK_RET( node, _T("invalid tool in wxToolBarTool::UnToggleRadioGroup") ); wxToolBarToolsList::compatibility_iterator nodeNext = node->GetNext(); while ( nodeNext ) @@ -435,34 +420,8 @@ void wxToolBarBase::ClearTools() } } -void wxToolBarBase::AdjustToolBitmapSize() -{ - const wxSize sizeOrig(m_defaultWidth, m_defaultHeight); - - wxSize sizeActual(sizeOrig); - - for ( wxToolBarToolsList::const_iterator i = m_tools.begin(); - i != m_tools.end(); - ++i ) - { - const wxBitmap& bmp = (*i)->GetNormalBitmap(); - if ( bmp.IsOk() ) - sizeActual.IncTo(bmp.GetSize()); - } - - if ( sizeActual != sizeOrig ) - SetToolBitmapSize(sizeActual); -} - bool wxToolBarBase::Realize() { - // check if we have anything to do - if ( m_tools.empty() ) - return false; - - // make sure tool size is large enough for all bitmaps to fit in - AdjustToolBitmapSize(); - return true; } @@ -483,9 +442,9 @@ wxToolBarBase::~wxToolBarBase() // wxToolBarBase tools state // ---------------------------------------------------------------------------- -void wxToolBarBase::EnableTool(int toolid, bool enable) +void wxToolBarBase::EnableTool(int id, bool enable) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); if ( tool ) { if ( tool->Enable(enable) ) @@ -495,9 +454,9 @@ void wxToolBarBase::EnableTool(int toolid, bool enable) } } -void wxToolBarBase::ToggleTool(int toolid, bool toggle) +void wxToolBarBase::ToggleTool(int id, bool toggle) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); if ( tool && tool->CanBeToggled() ) { if ( tool->Toggle(toggle) ) @@ -508,9 +467,9 @@ void wxToolBarBase::ToggleTool(int toolid, bool toggle) } } -void wxToolBarBase::SetToggle(int toolid, bool toggle) +void wxToolBarBase::SetToggle(int id, bool toggle) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); if ( tool ) { if ( tool->SetToggle(toggle) ) @@ -520,48 +479,48 @@ void wxToolBarBase::SetToggle(int toolid, bool toggle) } } -void wxToolBarBase::SetToolShortHelp(int toolid, const wxString& help) +void wxToolBarBase::SetToolShortHelp(int id, const wxString& help) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); if ( tool ) { (void)tool->SetShortHelp(help); } } -void wxToolBarBase::SetToolLongHelp(int toolid, const wxString& help) +void wxToolBarBase::SetToolLongHelp(int id, const wxString& help) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); if ( tool ) { (void)tool->SetLongHelp(help); } } -wxObject *wxToolBarBase::GetToolClientData(int toolid) const +wxObject *wxToolBarBase::GetToolClientData(int id) const { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); - return tool ? tool->GetClientData() : NULL; + return tool ? tool->GetClientData() : (wxObject *)NULL; } -void wxToolBarBase::SetToolClientData(int toolid, wxObject *clientData) +void wxToolBarBase::SetToolClientData(int id, wxObject *clientData) { - wxToolBarToolBase *tool = FindById(toolid); + wxToolBarToolBase *tool = FindById(id); - wxCHECK_RET( tool, wxT("no such tool in wxToolBar::SetToolClientData") ); + wxCHECK_RET( tool, _T("no such tool in wxToolBar::SetToolClientData") ); tool->SetClientData(clientData); } -int wxToolBarBase::GetToolPos(int toolid) const +int wxToolBarBase::GetToolPos(int id) const { size_t pos = 0; wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { - if ( node->GetData()->GetId() == toolid ) + if ( node->GetData()->GetId() == id ) return pos; pos++; @@ -570,34 +529,34 @@ int wxToolBarBase::GetToolPos(int toolid) const return wxNOT_FOUND; } -bool wxToolBarBase::GetToolState(int toolid) const +bool wxToolBarBase::GetToolState(int id) const { - wxToolBarToolBase *tool = FindById(toolid); - wxCHECK_MSG( tool, false, wxT("no such tool") ); + wxToolBarToolBase *tool = FindById(id); + wxCHECK_MSG( tool, false, _T("no such tool") ); return tool->IsToggled(); } -bool wxToolBarBase::GetToolEnabled(int toolid) const +bool wxToolBarBase::GetToolEnabled(int id) const { - wxToolBarToolBase *tool = FindById(toolid); - wxCHECK_MSG( tool, false, wxT("no such tool") ); + wxToolBarToolBase *tool = FindById(id); + wxCHECK_MSG( tool, false, _T("no such tool") ); return tool->IsEnabled(); } -wxString wxToolBarBase::GetToolShortHelp(int toolid) const +wxString wxToolBarBase::GetToolShortHelp(int id) const { - wxToolBarToolBase *tool = FindById(toolid); - wxCHECK_MSG( tool, wxEmptyString, wxT("no such tool") ); + wxToolBarToolBase *tool = FindById(id); + wxCHECK_MSG( tool, wxEmptyString, _T("no such tool") ); return tool->GetShortHelp(); } -wxString wxToolBarBase::GetToolLongHelp(int toolid) const +wxString wxToolBarBase::GetToolLongHelp(int id) const { - wxToolBarToolBase *tool = FindById(toolid); - wxCHECK_MSG( tool, wxEmptyString, wxT("no such tool") ); + wxToolBarToolBase *tool = FindById(id); + wxCHECK_MSG( tool, wxEmptyString, _T("no such tool") ); return tool->GetLongHelp(); } @@ -617,20 +576,14 @@ void wxToolBarBase::SetRows(int WXUNUSED(nRows)) // nothing } -bool wxToolBarBase::IsVertical() const -{ - return HasFlag(wxTB_LEFT | wxTB_RIGHT); -} - - // ---------------------------------------------------------------------------- // event processing // ---------------------------------------------------------------------------- // Only allow toggle if returns true -bool wxToolBarBase::OnLeftClick(int toolid, bool toggleDown) +bool wxToolBarBase::OnLeftClick(int id, bool toggleDown) { - wxCommandEvent event(wxEVT_TOOL, toolid); + wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, id); event.SetEventObject(this); // we use SetInt() to make wxCommandEvent::IsChecked() return toggleDown @@ -640,48 +593,42 @@ bool wxToolBarBase::OnLeftClick(int toolid, bool toggleDown) event.SetExtraLong((long)toggleDown); // Send events to this toolbar instead (and thence up the window hierarchy) - HandleWindowEvent(event); + GetEventHandler()->ProcessEvent(event); return true; } // Call when right button down. -void wxToolBarBase::OnRightClick(int toolid, +void wxToolBarBase::OnRightClick(int id, long WXUNUSED(x), long WXUNUSED(y)) { - wxCommandEvent event(wxEVT_TOOL_RCLICKED, toolid); + wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, id); event.SetEventObject(this); - event.SetInt(toolid); + event.SetInt(id); GetEventHandler()->ProcessEvent(event); } // Called when the mouse cursor enters a tool bitmap (no button pressed). // Argument is wxID_ANY if mouse is exiting the toolbar. -// Note that for this event, the toolid of the window is used, +// Note that for this event, the id of the window is used, // and the integer parameter of wxCommandEvent is used to retrieve -// the tool toolid. -void wxToolBarBase::OnMouseEnter(int toolid) +// the tool id. +void wxToolBarBase::OnMouseEnter(int id) { - wxCommandEvent event(wxEVT_TOOL_ENTER, GetId()); + wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, GetId()); event.SetEventObject(this); - event.SetInt(toolid); + event.SetInt(id); wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); - if ( frame ) + if( frame ) { wxString help; - if ( toolid != wxID_ANY ) - { - const wxToolBarToolBase * const tool = FindById(toolid); - if ( tool ) - help = tool->GetLongHelp(); - } - - // call DoGiveHelp() even if help string is empty to avoid showing the - // help for the previously selected tool when another one is selected - frame->DoGiveHelp(help, toolid != wxID_ANY); + wxToolBarToolBase* tool = id == wxID_ANY ? (wxToolBarToolBase*)NULL : FindById(id); + if(tool) + help = tool->GetLongHelp(); + frame->DoGiveHelp( help, id != wxID_ANY ); } (void)GetEventHandler()->ProcessEvent(event); @@ -696,8 +643,10 @@ void wxToolBarBase::UpdateWindowUI(long flags) { wxWindowBase::UpdateWindowUI(flags); - // don't waste time updating state of tools in a hidden toolbar - if ( !IsShown() ) + // There is no sense in updating the toolbar UI + // if the parent window is about to get destroyed + wxWindow *tlw = wxGetTopLevelParent( this ); + if (tlw && wxPendingDelete.Member( tlw )) return; wxEvtHandler* evtHandler = GetEventHandler() ; @@ -706,21 +655,17 @@ void wxToolBarBase::UpdateWindowUI(long flags) node; node = node->GetNext() ) { - wxToolBarToolBase * const tool = node->GetData(); - if ( tool->IsSeparator() ) - continue; + int id = node->GetData()->GetId(); - int toolid = tool->GetId(); - - wxUpdateUIEvent event(toolid); + wxUpdateUIEvent event(id); event.SetEventObject(this); if ( evtHandler->ProcessEvent(event) ) { if ( event.GetSetEnabled() ) - EnableTool(toolid, event.GetEnabled()); + EnableTool(id, event.GetEnabled()); if ( event.GetSetChecked() ) - ToggleTool(toolid, event.GetChecked()); + ToggleTool(id, event.GetChecked()); #if 0 if ( event.GetSetText() ) // Set tooltip? @@ -729,33 +674,73 @@ void wxToolBarBase::UpdateWindowUI(long flags) } } -#if wxUSE_MENUS -bool wxToolBarBase::SetDropdownMenu(int toolid, wxMenu* menu) +#if wxUSE_IMAGE + +/* + * Make a greyed-out image suitable for disabled buttons. + * This code is adapted from wxNewBitmapButton in FL. + */ + +bool wxCreateGreyedImage(const wxImage& src, wxImage& dst) { - wxToolBarToolBase * const tool = FindById(toolid); - wxCHECK_MSG( tool, false, wxT("invalid tool toolid") ); + dst = src.Copy(); - wxCHECK_MSG( tool->GetKind() == wxITEM_DROPDOWN, false, - wxT("menu can be only associated with drop down tools") ); + unsigned char rBg, gBg, bBg; + if ( src.HasMask() ) + { + src.GetOrFindMaskColour(&rBg, &gBg, &bBg); + dst.SetMaskColour(rBg, gBg, bBg); + } + else // assuming the pixels along the edges are of the background color + { + rBg = src.GetRed(0, 0); + gBg = src.GetGreen(0, 0); + bBg = src.GetBlue(0, 0); + } - tool->SetDropdownMenu(menu); + const wxColour colBg(rBg, gBg, bBg); + + const wxColour colDark = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); + const wxColour colLight = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT); + + // Second attempt, just making things monochrome + const int width = src.GetWidth(); + const int height = src.GetHeight(); + + for ( int x = 0; x < width; x++ ) + { + for ( int y = 0; y < height; y++ ) + { + const int r = src.GetRed(x, y); + const int g = src.GetGreen(x, y); + const int b = src.GetBlue(x, y); + + if ( r == rBg && g == gBg && b == bBg ) + { + // Leave the background colour as-is + continue; + } + + // Change light things to the background colour + wxColour col; + if ( r >= (colLight.Red() - 50) && + g >= (colLight.Green() - 50) && + b >= (colLight.Blue() - 50) ) + { + col = colBg; + } + else // Change dark things to really dark + { + col = colDark; + } + + dst.SetRGB(x, y, col.Red(), col.Green(), col.Blue()); + } + } return true; } -#endif -#if WXWIN_COMPATIBILITY_2_8 - -bool wxCreateGreyedImage(const wxImage& in, wxImage& out) -{ -#if wxUSE_IMAGE - out = in.ConvertToGreyscale(); - if ( out.IsOk() ) - return true; #endif // wxUSE_IMAGE - return false; -} - -#endif // WXWIN_COMPATIBILITY_2_8 #endif // wxUSE_TOOLBAR diff --git a/Source/3rd Party/wx/src/common/textbuf.cpp b/Source/3rd Party/wx/src/common/textbuf.cpp index 406043e58..6f97b98ca 100644 --- a/Source/3rd Party/wx/src/common/textbuf.cpp +++ b/Source/3rd Party/wx/src/common/textbuf.cpp @@ -3,6 +3,7 @@ // Purpose: implementation of wxTextBuffer class // Created: 14.11.01 // Author: Morten Hanssen, Vadim Zeitlin +// RCS-ID: $Id: textbuf.cpp 38570 2006-04-05 14:37:47Z VZ $ // Copyright: (c) 1998-2001 wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,12 +35,17 @@ // ---------------------------------------------------------------------------- // default type is the native one +// the native type under Mac OS X is: +// - Unix when compiling with the Apple Developer Tools (__UNIX__) +// - Mac when compiling with CodeWarrior (__WXMAC__) const wxTextFileType wxTextBuffer::typeDefault = -#if defined(__WINDOWS__) || defined(__DOS__) +#if defined(__WINDOWS__) || defined(__DOS__) || defined(__PALMOS__) wxTextFileType_Dos; #elif defined(__UNIX__) wxTextFileType_Unix; +#elif defined(__WXMAC__) + wxTextFileType_Mac; #elif defined(__OS2__) wxTextFileType_Os2; #else @@ -74,35 +80,35 @@ wxString wxTextBuffer::Translate(const wxString& text, wxTextFileType type) wxString eol = GetEOL(type), result; // optimization: we know that the length of the new string will be about - // the same as the length of the old one, so prealloc memory to avoid + // the same as the length of the old one, so prealloc memory to aviod // unnecessary relocations result.Alloc(text.Len()); wxChar chLast = 0; - for ( wxString::const_iterator i = text.begin(); i != text.end(); ++i ) + for ( const wxChar *pc = text.c_str(); *pc; pc++ ) { - wxChar ch = *i; + wxChar ch = *pc; switch ( ch ) { - case wxT('\n'): + case _T('\n'): // Dos/Unix line termination result += eol; chLast = 0; break; - case wxT('\r'): - if ( chLast == wxT('\r') ) { + case _T('\r'): + if ( chLast == _T('\r') ) { // Mac empty line result += eol; } else { // just remember it: we don't know whether it is just "\r" // or "\r\n" yet - chLast = wxT('\r'); + chLast = _T('\r'); } break; default: - if ( chLast == wxT('\r') ) { + if ( chLast == _T('\r') ) { // Mac line termination result += eol; @@ -212,7 +218,7 @@ wxTextFileType wxTextBuffer::GuessType() const // we take MAX_LINES_SCAN in the beginning, middle and the end of buffer #define MAX_LINES_SCAN (10) - size_t nCount = m_aLines.GetCount() / 3, + size_t nCount = m_aLines.Count() / 3, nScan = nCount > 3*MAX_LINES_SCAN ? MAX_LINES_SCAN : nCount / 3; #define AnalyseLine(n) \ @@ -220,7 +226,7 @@ wxTextFileType wxTextBuffer::GuessType() const case wxTextFileType_Unix: nUnix++; break; \ case wxTextFileType_Dos: nDos++; break; \ case wxTextFileType_Mac: nMac++; break; \ - default: wxFAIL_MSG(wxT("unknown line terminator")); \ + default: wxFAIL_MSG(_("unknown line terminator")); \ } size_t n; diff --git a/Source/3rd Party/wx/src/common/textcmn.cpp b/Source/3rd Party/wx/src/common/textcmn.cpp index 4cba1dec5..952fcf974 100644 --- a/Source/3rd Party/wx/src/common/textcmn.cpp +++ b/Source/3rd Party/wx/src/common/textcmn.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 13.07.99 +// RCS-ID: $Id: textcmn.cpp 62095 2009-09-24 18:20:21Z JS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,8 +35,6 @@ #include "wx/ffile.h" -extern WXDLLEXPORT_DATA(const char) wxTextCtrlNameStr[] = "text"; - // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -48,109 +47,36 @@ extern WXDLLEXPORT_DATA(const char) wxTextCtrlNameStr[] = "text"; // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxTextCtrlStyle ) -wxBEGIN_FLAGS( wxTextCtrlStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxTE_PROCESS_ENTER) -wxFLAGS_MEMBER(wxTE_PROCESS_TAB) -wxFLAGS_MEMBER(wxTE_MULTILINE) -wxFLAGS_MEMBER(wxTE_PASSWORD) -wxFLAGS_MEMBER(wxTE_READONLY) -wxFLAGS_MEMBER(wxHSCROLL) -wxFLAGS_MEMBER(wxTE_RICH) -wxFLAGS_MEMBER(wxTE_RICH2) -wxFLAGS_MEMBER(wxTE_AUTO_URL) -wxFLAGS_MEMBER(wxTE_NOHIDESEL) -wxFLAGS_MEMBER(wxTE_LEFT) -wxFLAGS_MEMBER(wxTE_CENTRE) -wxFLAGS_MEMBER(wxTE_RIGHT) -wxFLAGS_MEMBER(wxTE_DONTWRAP) -wxFLAGS_MEMBER(wxTE_CHARWRAP) -wxFLAGS_MEMBER(wxTE_WORDWRAP) -wxEND_FLAGS( wxTextCtrlStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl, "wx/textctrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxTextCtrl) -wxEVENT_PROPERTY( TextUpdated, wxEVT_TEXT, wxCommandEvent ) -wxEVENT_PROPERTY( TextEnter, wxEVT_TEXT_ENTER, wxCommandEvent ) - -wxPROPERTY( Font, wxFont, SetFont, GetFont , wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Value, wxString, SetValue, GetValue, wxString(), \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) - -wxPROPERTY_FLAGS( WindowStyle, wxTextCtrlStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxTextCtrl) - -wxCONSTRUCTOR_6( wxTextCtrl, wxWindow*, Parent, wxWindowID, Id, \ - wxString, Value, wxPoint, Position, wxSize, Size, \ - long, WindowStyle) - - IMPLEMENT_DYNAMIC_CLASS(wxTextUrlEvent, wxCommandEvent) -wxDEFINE_EVENT( wxEVT_TEXT, wxCommandEvent ); -wxDEFINE_EVENT( wxEVT_TEXT_ENTER, wxCommandEvent ); -wxDEFINE_EVENT( wxEVT_TEXT_URL, wxTextUrlEvent ); -wxDEFINE_EVENT( wxEVT_TEXT_MAXLEN, wxCommandEvent ); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN) IMPLEMENT_ABSTRACT_CLASS(wxTextCtrlBase, wxControl) -// ============================================================================ -// wxTextAttr implementation -// ============================================================================ +// ---------------------------------------------------------------------------- +// style functions - not implemented here +// ---------------------------------------------------------------------------- wxTextAttr::wxTextAttr(const wxColour& colText, const wxColour& colBack, const wxFont& font, - wxTextAttrAlignment alignment): m_textAlignment(alignment), m_colText(colText), m_colBack(colBack) + wxTextAttrAlignment alignment) + : m_colText(colText), m_colBack(colBack), m_font(font), m_textAlignment(alignment) { - Init(); - - if (m_colText.IsOk()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR; - if (m_colBack.IsOk()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; + m_flags = 0; + m_leftIndent = 0; + m_leftSubIndent = 0; + m_rightIndent = 0; + if (m_colText.Ok()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR; + if (m_colBack.Ok()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; + if (m_font.Ok()) m_flags |= wxTEXT_ATTR_FONT; if (alignment != wxTEXT_ALIGNMENT_DEFAULT) m_flags |= wxTEXT_ATTR_ALIGNMENT; - - GetFontAttributes(font); } -// Initialisation void wxTextAttr::Init() { m_textAlignment = wxTEXT_ALIGNMENT_DEFAULT; @@ -158,582 +84,6 @@ void wxTextAttr::Init() m_leftIndent = 0; m_leftSubIndent = 0; m_rightIndent = 0; - - m_fontSize = 12; - m_fontStyle = wxFONTSTYLE_NORMAL; - m_fontWeight = wxFONTWEIGHT_NORMAL; - m_fontUnderlined = false; - m_fontStrikethrough = false; - m_fontEncoding = wxFONTENCODING_DEFAULT; - m_fontFamily = wxFONTFAMILY_DEFAULT; - - m_paragraphSpacingAfter = 0; - m_paragraphSpacingBefore = 0; - m_lineSpacing = 0; - m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE; - m_textEffects = wxTEXT_ATTR_EFFECT_NONE; - m_textEffectFlags = wxTEXT_ATTR_EFFECT_NONE; - m_outlineLevel = 0; - m_bulletNumber = 0; -} - -// Copy -void wxTextAttr::Copy(const wxTextAttr& attr) -{ - m_colText = attr.m_colText; - m_colBack = attr.m_colBack; - m_textAlignment = attr.m_textAlignment; - m_leftIndent = attr.m_leftIndent; - m_leftSubIndent = attr.m_leftSubIndent; - m_rightIndent = attr.m_rightIndent; - m_tabs = attr.m_tabs; - m_flags = attr.m_flags; - - m_fontSize = attr.m_fontSize; - m_fontStyle = attr.m_fontStyle; - m_fontWeight = attr.m_fontWeight; - m_fontUnderlined = attr.m_fontUnderlined; - m_fontStrikethrough = attr.m_fontStrikethrough; - m_fontFaceName = attr.m_fontFaceName; - m_fontEncoding = attr.m_fontEncoding; - m_fontFamily = attr.m_fontFamily; - m_textEffects = attr.m_textEffects; - m_textEffectFlags = attr.m_textEffectFlags; - - m_paragraphSpacingAfter = attr.m_paragraphSpacingAfter; - m_paragraphSpacingBefore = attr.m_paragraphSpacingBefore; - m_lineSpacing = attr.m_lineSpacing; - m_characterStyleName = attr.m_characterStyleName; - m_paragraphStyleName = attr.m_paragraphStyleName; - m_listStyleName = attr.m_listStyleName; - m_bulletStyle = attr.m_bulletStyle; - m_bulletNumber = attr.m_bulletNumber; - m_bulletText = attr.m_bulletText; - m_bulletFont = attr.m_bulletFont; - m_bulletName = attr.m_bulletName; - m_outlineLevel = attr.m_outlineLevel; - - m_urlTarget = attr.m_urlTarget; -} - -// operators -void wxTextAttr::operator= (const wxTextAttr& attr) -{ - Copy(attr); -} - -// Equality test -bool wxTextAttr::operator== (const wxTextAttr& attr) const -{ - return GetFlags() == attr.GetFlags() && - - (!HasTextColour() || (GetTextColour() == attr.GetTextColour())) && - (!HasBackgroundColour() || (GetBackgroundColour() == attr.GetBackgroundColour())) && - - (!HasAlignment() || (GetAlignment() == attr.GetAlignment())) && - (!HasLeftIndent() || (GetLeftIndent() == attr.GetLeftIndent() && - GetLeftSubIndent() == attr.GetLeftSubIndent())) && - (!HasRightIndent() || (GetRightIndent() == attr.GetRightIndent())) && - (!HasTabs() || (TabsEq(GetTabs(), attr.GetTabs()))) && - - (!HasParagraphSpacingAfter() || (GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter())) && - (!HasParagraphSpacingBefore() || (GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore())) && - (!HasLineSpacing() || (GetLineSpacing() == attr.GetLineSpacing())) && - (!HasCharacterStyleName() || (GetCharacterStyleName() == attr.GetCharacterStyleName())) && - (!HasParagraphStyleName() || (GetParagraphStyleName() == attr.GetParagraphStyleName())) && - (!HasListStyleName() || (GetListStyleName() == attr.GetListStyleName())) && - - (!HasBulletStyle() || (GetBulletStyle() == attr.GetBulletStyle())) && - (!HasBulletText() || (GetBulletText() == attr.GetBulletText())) && - (!HasBulletNumber() || (GetBulletNumber() == attr.GetBulletNumber())) && - (GetBulletFont() == attr.GetBulletFont()) && - (!HasBulletName() || (GetBulletName() == attr.GetBulletName())) && - - (!HasTextEffects() || (GetTextEffects() == attr.GetTextEffects() && - GetTextEffectFlags() == attr.GetTextEffectFlags())) && - - (!HasOutlineLevel() || (GetOutlineLevel() == attr.GetOutlineLevel())) && - - (!HasFontSize() || (GetFontSize() == attr.GetFontSize())) && - (!HasFontItalic() || (GetFontStyle() == attr.GetFontStyle())) && - (!HasFontWeight() || (GetFontWeight() == attr.GetFontWeight())) && - (!HasFontUnderlined() || (GetFontUnderlined() == attr.GetFontUnderlined())) && - (!HasFontStrikethrough() || (GetFontStrikethrough() == attr.GetFontStrikethrough())) && - (!HasFontFaceName() || (GetFontFaceName() == attr.GetFontFaceName())) && - (!HasFontEncoding() || (GetFontEncoding() == attr.GetFontEncoding())) && - (!HasFontFamily() || (GetFontFamily() == attr.GetFontFamily())) && - - (!HasURL() || (GetURL() == attr.GetURL())); -} - -// Partial equality test. Only returns false if an attribute doesn't match. -bool wxTextAttr::EqPartial(const wxTextAttr& attr, bool weakTest) const -{ - int flags = attr.GetFlags(); - - if (!weakTest && - ((!HasTextColour() && attr.HasTextColour()) || - (!HasBackgroundColour() && attr.HasBackgroundColour()) || - (!HasFontFaceName() && attr.HasFontFaceName()) || - (!HasFontSize() && attr.HasFontSize()) || - (!HasFontWeight() && attr.HasFontWeight()) || - (!HasFontItalic() && attr.HasFontItalic()) || - (!HasFontUnderlined() && attr.HasFontUnderlined()) || - (!HasFontStrikethrough() && attr.HasFontStrikethrough()) || - (!HasFontEncoding() && attr.HasFontEncoding()) || - (!HasFontFamily() && attr.HasFontFamily()) || - (!HasURL() && attr.HasURL()) || - (!HasAlignment() && attr.HasAlignment()) || - (!HasLeftIndent() && attr.HasLeftIndent()) || - (!HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter()) || - (!HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore()) || - (!HasLineSpacing() && attr.HasLineSpacing()) || - (!HasCharacterStyleName() && attr.HasCharacterStyleName()) || - (!HasParagraphStyleName() && attr.HasParagraphStyleName()) || - (!HasListStyleName() && attr.HasListStyleName()) || - (!HasBulletStyle() && attr.HasBulletStyle()) || - (!HasBulletNumber() && attr.HasBulletNumber()) || - (!HasBulletText() && attr.HasBulletText()) || - (!HasBulletName() && attr.HasBulletName()) || - (!HasTabs() && attr.HasTabs()) || - (!HasTextEffects() && attr.HasTextEffects()) || - (!HasOutlineLevel() && attr.HasOutlineLevel()))) - { - return false; - } - - if (HasTextColour() && attr.HasTextColour() && GetTextColour() != attr.GetTextColour()) - return false; - - if (HasBackgroundColour() && attr.HasBackgroundColour() && GetBackgroundColour() != attr.GetBackgroundColour()) - return false; - - if (HasFontFaceName() && attr.HasFontFaceName() && GetFontFaceName() != attr.GetFontFaceName()) - return false; - - // This checks whether the two objects have the same font size dimension (px versus pt) - if (HasFontSize() && attr.HasFontSize() && (flags & wxTEXT_ATTR_FONT) != (GetFlags() & wxTEXT_ATTR_FONT)) - return false; - - if (HasFontPointSize() && attr.HasFontPointSize() && GetFontSize() != attr.GetFontSize()) - return false; - - if (HasFontPixelSize() && attr.HasFontPixelSize() && GetFontSize() != attr.GetFontSize()) - return false; - - if (HasFontWeight() && attr.HasFontWeight() && GetFontWeight() != attr.GetFontWeight()) - return false; - - if (HasFontItalic() && attr.HasFontItalic() && GetFontStyle() != attr.GetFontStyle()) - return false; - - if (HasFontUnderlined() && attr.HasFontUnderlined() && GetFontUnderlined() != attr.GetFontUnderlined()) - return false; - - if (HasFontStrikethrough() && attr.HasFontStrikethrough() && GetFontStrikethrough() != attr.GetFontStrikethrough()) - return false; - - if (HasFontEncoding() && attr.HasFontEncoding() && GetFontEncoding() != attr.GetFontEncoding()) - return false; - - if (HasFontFamily() && attr.HasFontFamily() && GetFontFamily() != attr.GetFontFamily()) - return false; - - if (HasURL() && attr.HasURL() && GetURL() != attr.GetURL()) - return false; - - if (HasAlignment() && attr.HasAlignment() && GetAlignment() != attr.GetAlignment()) - return false; - - if (HasLeftIndent() && attr.HasLeftIndent() && - ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) - return false; - - if (HasRightIndent() && attr.HasRightIndent() && (GetRightIndent() != attr.GetRightIndent())) - return false; - - if (HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter() && - (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) - return false; - - if (HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore() && - (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) - return false; - - if (HasLineSpacing() && attr.HasLineSpacing() && (GetLineSpacing() != attr.GetLineSpacing())) - return false; - - if (HasCharacterStyleName() && attr.HasCharacterStyleName() && (GetCharacterStyleName() != attr.GetCharacterStyleName())) - return false; - - if (HasParagraphStyleName() && attr.HasParagraphStyleName() && (GetParagraphStyleName() != attr.GetParagraphStyleName())) - return false; - - if (HasListStyleName() && attr.HasListStyleName() && (GetListStyleName() != attr.GetListStyleName())) - return false; - - if (HasBulletStyle() && attr.HasBulletStyle() && (GetBulletStyle() != attr.GetBulletStyle())) - return false; - - if (HasBulletNumber() && attr.HasBulletNumber() && (GetBulletNumber() != attr.GetBulletNumber())) - return false; - - if (HasBulletText() && attr.HasBulletText() && - (GetBulletText() != attr.GetBulletText()) && - (GetBulletFont() != attr.GetBulletFont())) - return false; - - if (HasBulletName() && attr.HasBulletName() && (GetBulletName() != attr.GetBulletName())) - return false; - - if (HasTabs() && attr.HasTabs() && !TabsEq(GetTabs(), attr.GetTabs())) - return false; - - if ((HasPageBreak() != attr.HasPageBreak())) - return false; - - if (HasTextEffects() && attr.HasTextEffects()) - { - if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), GetTextEffectFlags())) - return false; - } - - if (HasOutlineLevel() && attr.HasOutlineLevel() && (GetOutlineLevel() != attr.GetOutlineLevel())) - return false; - - return true; -} - -// Create font from font attributes. -wxFont wxTextAttr::GetFont() const -{ - if ( !HasFont() ) - return wxNullFont; - - int fontSize = 10; - if (HasFontSize()) - fontSize = GetFontSize(); - - wxFontStyle fontStyle = wxFONTSTYLE_NORMAL; - if (HasFontItalic()) - fontStyle = GetFontStyle(); - - wxFontWeight fontWeight = wxFONTWEIGHT_NORMAL; - if (HasFontWeight()) - fontWeight = GetFontWeight(); - - bool underlined = false; - if (HasFontUnderlined()) - underlined = GetFontUnderlined(); - - bool strikethrough = false; - if (HasFontStrikethrough()) - strikethrough = GetFontStrikethrough(); - - wxString fontFaceName; - if (HasFontFaceName()) - fontFaceName = GetFontFaceName(); - - wxFontEncoding encoding = wxFONTENCODING_DEFAULT; - if (HasFontEncoding()) - encoding = GetFontEncoding(); - - wxFontFamily fontFamily = wxFONTFAMILY_DEFAULT; - if (HasFontFamily()) - fontFamily = GetFontFamily(); - - if (HasFontPixelSize()) - { - wxFont font(wxSize(0, fontSize), fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding); - if (strikethrough) - font.SetStrikethrough(true); - return font; - } - else - { - wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding); - if (strikethrough) - font.SetStrikethrough(true); - return font; - } -} - -// Get attributes from font. -bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags) -{ - if (!font.IsOk()) - return false; - - // If we pass both pixel and point size attributes, this is an indication - // to choose the most appropriate units. - if ((flags & wxTEXT_ATTR_FONT) == wxTEXT_ATTR_FONT) - { - if (font.IsUsingSizeInPixels()) - { - m_fontSize = font.GetPixelSize().y; - flags &= ~wxTEXT_ATTR_FONT_POINT_SIZE; - } - else - { - m_fontSize = font.GetPointSize(); - flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE; - } - } - else if (flags & wxTEXT_ATTR_FONT_POINT_SIZE) - { - m_fontSize = font.GetPointSize(); - flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE; - } - else if (flags & wxTEXT_ATTR_FONT_PIXEL_SIZE) - { - m_fontSize = font.GetPixelSize().y; - } - - if (flags & wxTEXT_ATTR_FONT_ITALIC) - m_fontStyle = font.GetStyle(); - - if (flags & wxTEXT_ATTR_FONT_WEIGHT) - m_fontWeight = font.GetWeight(); - - if (flags & wxTEXT_ATTR_FONT_UNDERLINE) - m_fontUnderlined = font.GetUnderlined(); - - if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH) - m_fontStrikethrough = font.GetStrikethrough(); - - if (flags & wxTEXT_ATTR_FONT_FACE) - m_fontFaceName = font.GetFaceName(); - - if (flags & wxTEXT_ATTR_FONT_ENCODING) - m_fontEncoding = font.GetEncoding(); - - if (flags & wxTEXT_ATTR_FONT_FAMILY) - { - // wxFont might not know its family, avoid setting m_fontFamily to an - // invalid value and rather pretend that we don't have any font family - // information at all in this case - const wxFontFamily fontFamily = font.GetFamily(); - if ( fontFamily == wxFONTFAMILY_UNKNOWN ) - flags &= ~wxTEXT_ATTR_FONT_FAMILY; - else - m_fontFamily = fontFamily; - } - - m_flags |= flags; - - return true; -} - -// Resets bits in destination so new attributes aren't merged with mutually exclusive ones -static bool wxResetIncompatibleBits(const int mask, const int srcFlags, int& destFlags, int& destBits) -{ - if ((srcFlags & mask) && (destFlags & mask)) - { - destBits &= ~mask; - destFlags &= ~mask; - } - - return true; -} - -bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith) -{ - wxTextAttr& destStyle = (*this); - - if (style.HasFontWeight()) - { - if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())) - destStyle.SetFontWeight(style.GetFontWeight()); - } - - if (style.HasFontPointSize()) - { - if (!(compareWith && compareWith->HasFontPointSize() && compareWith->GetFontSize() == style.GetFontSize())) - destStyle.SetFontPointSize(style.GetFontSize()); - } - else if (style.HasFontPixelSize()) - { - if (!(compareWith && compareWith->HasFontPixelSize() && compareWith->GetFontSize() == style.GetFontSize())) - destStyle.SetFontPixelSize(style.GetFontSize()); - } - - if (style.HasFontItalic()) - { - if (!(compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle())) - destStyle.SetFontStyle(style.GetFontStyle()); - } - - if (style.HasFontUnderlined()) - { - if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined())) - destStyle.SetFontUnderlined(style.GetFontUnderlined()); - } - - if (style.HasFontStrikethrough()) - { - if (!(compareWith && compareWith->HasFontStrikethrough() && compareWith->GetFontStrikethrough() == style.GetFontStrikethrough())) - destStyle.SetFontStrikethrough(style.GetFontStrikethrough()); - } - - if (style.HasFontFaceName()) - { - if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName())) - destStyle.SetFontFaceName(style.GetFontFaceName()); - } - - if (style.HasFontEncoding()) - { - if (!(compareWith && compareWith->HasFontEncoding() && compareWith->GetFontEncoding() == style.GetFontEncoding())) - destStyle.SetFontEncoding(style.GetFontEncoding()); - } - - if (style.HasFontFamily()) - { - if (!(compareWith && compareWith->HasFontFamily() && compareWith->GetFontFamily() == style.GetFontFamily())) - destStyle.SetFontFamily(style.GetFontFamily()); - } - - if (style.GetTextColour().IsOk() && style.HasTextColour()) - { - if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour())) - destStyle.SetTextColour(style.GetTextColour()); - } - - if (style.GetBackgroundColour().IsOk() && style.HasBackgroundColour()) - { - if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour())) - destStyle.SetBackgroundColour(style.GetBackgroundColour()); - } - - if (style.HasAlignment()) - { - if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment())) - destStyle.SetAlignment(style.GetAlignment()); - } - - if (style.HasTabs()) - { - if (!(compareWith && compareWith->HasTabs() && TabsEq(compareWith->GetTabs(), style.GetTabs()))) - destStyle.SetTabs(style.GetTabs()); - } - - if (style.HasLeftIndent()) - { - if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent() - && compareWith->GetLeftSubIndent() == style.GetLeftSubIndent())) - destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); - } - - if (style.HasRightIndent()) - { - if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent())) - destStyle.SetRightIndent(style.GetRightIndent()); - } - - if (style.HasParagraphSpacingAfter()) - { - if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter())) - destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); - } - - if (style.HasParagraphSpacingBefore()) - { - if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore())) - destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); - } - - if (style.HasLineSpacing()) - { - if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing())) - destStyle.SetLineSpacing(style.GetLineSpacing()); - } - - if (style.HasCharacterStyleName()) - { - if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName())) - destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); - } - - if (style.HasParagraphStyleName()) - { - if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName())) - destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); - } - - if (style.HasListStyleName()) - { - if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName())) - destStyle.SetListStyleName(style.GetListStyleName()); - } - - if (style.HasBulletStyle()) - { - if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle())) - destStyle.SetBulletStyle(style.GetBulletStyle()); - } - - if (style.HasBulletText()) - { - if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText())) - { - destStyle.SetBulletText(style.GetBulletText()); - destStyle.SetBulletFont(style.GetBulletFont()); - } - } - - if (style.HasBulletNumber()) - { - if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber())) - destStyle.SetBulletNumber(style.GetBulletNumber()); - } - - if (style.HasBulletName()) - { - if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName())) - destStyle.SetBulletName(style.GetBulletName()); - } - - if (style.HasURL()) - { - if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL())) - destStyle.SetURL(style.GetURL()); - } - - if (style.HasPageBreak()) - { - if (!(compareWith && compareWith->HasPageBreak())) - destStyle.SetPageBreak(); - } - - if (style.HasTextEffects()) - { - if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects())) - { - int destBits = destStyle.GetTextEffects(); - int destFlags = destStyle.GetTextEffectFlags(); - - int srcBits = style.GetTextEffects(); - int srcFlags = style.GetTextEffectFlags(); - - // Reset incompatible bits in the destination - wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_SUPERSCRIPT|wxTEXT_ATTR_EFFECT_SUBSCRIPT), srcFlags, destFlags, destBits); - wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_CAPITALS|wxTEXT_ATTR_EFFECT_SMALL_CAPITALS), srcFlags, destFlags, destBits); - wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_STRIKETHROUGH|wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH), srcFlags, destFlags, destBits); - - CombineBitlists(destBits, srcBits, destFlags, srcFlags); - - destStyle.SetTextEffects(destBits); - destStyle.SetTextEffectFlags(destFlags); - } - } - - if (style.HasOutlineLevel()) - { - if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel())) - destStyle.SetOutlineLevel(style.GetOutlineLevel()); - } - - return true; } /* static */ @@ -741,34 +91,30 @@ wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr, const wxTextAttr& attrDef, const wxTextCtrlBase *text) { - wxFont font; - if (attr.HasFont()) - font = attr.GetFont(); - - if ( !font.IsOk() ) + wxFont font = attr.GetFont(); + if ( !font.Ok() ) { - if (attrDef.HasFont()) - font = attrDef.GetFont(); + font = attrDef.GetFont(); - if ( text && !font.IsOk() ) + if ( text && !font.Ok() ) font = text->GetFont(); } wxColour colFg = attr.GetTextColour(); - if ( !colFg.IsOk() ) + if ( !colFg.Ok() ) { colFg = attrDef.GetTextColour(); - if ( text && !colFg.IsOk() ) + if ( text && !colFg.Ok() ) colFg = text->GetForegroundColour(); } wxColour colBg = attr.GetBackgroundColour(); - if ( !colBg.IsOk() ) + if ( !colBg.Ok() ) { colBg = attrDef.GetBackgroundColour(); - if ( text && !colBg.IsOk() ) + if ( text && !colBg.Ok() ) colBg = text->GetBackgroundColour(); } @@ -797,99 +143,32 @@ wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr, return newAttr; } -/// Compare tabs -bool wxTextAttr::TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) +void wxTextAttr::operator= (const wxTextAttr& attr) { - if (tabs1.GetCount() != tabs2.GetCount()) - return false; - - size_t i; - for (i = 0; i < tabs1.GetCount(); i++) - { - if (tabs1[i] != tabs2[i]) - return false; - } - return true; + m_font = attr.m_font; + m_colText = attr.m_colText; + m_colBack = attr.m_colBack; + m_textAlignment = attr.m_textAlignment; + m_leftIndent = attr.m_leftIndent; + m_leftSubIndent = attr.m_leftSubIndent; + m_rightIndent = attr.m_rightIndent; + m_tabs = attr.m_tabs; + m_flags = attr.m_flags; } -// Remove attributes -bool wxTextAttr::RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style) -{ - int flags = style.GetFlags(); - int destFlags = destStyle.GetFlags(); - - // We must treat text effects specially, since we must remove only some. - if (style.HasTextEffects() && (style.GetTextEffectFlags() != 0)) - { - int newTextEffectFlags = destStyle.GetTextEffectFlags() & ~style.GetTextEffectFlags(); - int newTextEffects = destStyle.GetTextEffects() & ~style.GetTextEffectFlags(); - destStyle.SetTextEffects(newTextEffects); - destStyle.SetTextEffectFlags(newTextEffectFlags); - - // Don't remove wxTEXT_ATTR_EFFECTS unless the resulting flags are zero - if (newTextEffectFlags != 0) - flags &= ~wxTEXT_ATTR_EFFECTS; - } - - destStyle.SetFlags(destFlags & ~flags); - - return true; -} - -/// Combine two bitlists, specifying the bits of interest with separate flags. -bool wxTextAttr::CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB) -{ - // We want to apply B's bits to A, taking into account each's flags which indicate which bits - // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags - // indicate it. - - // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero - // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant. - int valueA2 = ~(~valueB & flagsB) & valueA; - - // Now combine the 1 bits. - int valueA3 = (valueB & flagsB) | valueA2; - - valueA = valueA3; - flagsA = (flagsA | flagsB); - - return true; -} - -/// Compare two bitlists -bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags) -{ - int relevantBitsA = valueA & flags; - int relevantBitsB = valueB & flags; - return relevantBitsA == relevantBitsB; -} - -/// Split into paragraph and character styles -bool wxTextAttr::SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle) -{ - wxTextAttr defaultCharStyle1(style); - wxTextAttr defaultParaStyle1(style); - defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER); - defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH); - - charStyle.Apply(defaultCharStyle1); - parStyle.Apply(defaultParaStyle1); - - return true; -} // apply styling to text range bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end), const wxTextAttr& WXUNUSED(style)) { - // to be implemented in derived classes + // to be implemented in derived TextCtrl classes return false; } // get the styling at the given position bool wxTextCtrlBase::GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style)) { - // to be implemented in derived classes + // to be implemented in derived TextCtrl classes return false; } @@ -907,11 +186,17 @@ bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr& style) return true; } +// get default text attributes +const wxTextAttr& wxTextCtrlBase::GetDefaultStyle() const +{ + return m_defaultStyle; +} + // ---------------------------------------------------------------------------- // file IO functions // ---------------------------------------------------------------------------- -bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) +bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) { #if wxUSE_FFILE wxFFile file(filename); @@ -923,42 +208,20 @@ bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType) SetValue(text); DiscardEdits(); + m_filename = filename; return true; } } -#else - (void)filename; // avoid compiler warning about unreferenced parameter -#endif // wxUSE_FFILE wxLogError(_("File couldn't be loaded.")); - - return false; -} - -bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) -{ -#if wxUSE_FFILE - wxFFile file(filename, wxT("w")); - if ( file.IsOpened() && file.Write(GetValue()) ) - { - // if it worked, save for future calls - m_filename = filename; - - // it's not modified any longer - DiscardEdits(); - - return true; - } -#else - (void)filename; // avoid compiler warning about unreferenced parameter #endif // wxUSE_FFILE return false; } -bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType) +bool wxTextCtrlBase::SaveFile(const wxString& filename, int fileType) { wxString filenameToUse = filename.empty() ? m_filename : filename; if ( filenameToUse.empty() ) @@ -972,6 +235,27 @@ bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType) return DoSaveFile(filenameToUse, fileType); } +bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) +{ +#if wxUSE_FFILE + wxFFile file(filename, _T("w")); + if ( file.IsOpened() && file.Write(GetValue()) ) + { + // if it worked, save for future calls + m_filename = filename; + + // it's not modified any longer + DiscardEdits(); + + return true; + } +#endif // wxUSE_FFILE + + wxLogError(_("The text couldn't be saved.")); + + return false; +} + // ---------------------------------------------------------------------------- // stream-like insertion operator // ---------------------------------------------------------------------------- @@ -982,19 +266,41 @@ wxTextCtrl& wxTextCtrlBase::operator<<(const wxString& s) return *TEXTCTRL(this); } +wxTextCtrl& wxTextCtrlBase::operator<<(float f) +{ + wxString str; + str.Printf(wxT("%.2f"), f); + AppendText(str); + return *TEXTCTRL(this); +} + wxTextCtrl& wxTextCtrlBase::operator<<(double d) { - return *this << wxString::Format("%.2f", d); + wxString str; + str.Printf(wxT("%.2f"), d); + AppendText(str); + return *TEXTCTRL(this); } wxTextCtrl& wxTextCtrlBase::operator<<(int i) { - return *this << wxString::Format("%d", i); + wxString str; + str.Printf(wxT("%d"), i); + AppendText(str); + return *TEXTCTRL(this); } -wxTextCtrl& wxTextCtrlBase::operator<<(long l) +wxTextCtrl& wxTextCtrlBase::operator<<(long i) { - return *this << wxString::Format("%ld", l); + wxString str; + str.Printf(wxT("%ld"), i); + AppendText(str); + return *TEXTCTRL(this); +} + +wxTextCtrl& wxTextCtrlBase::operator<<(const wxChar c) +{ + return operator<<(wxString(c)); } // ---------------------------------------------------------------------------- @@ -1013,53 +319,47 @@ int wxTextCtrlBase::overflow(int c) #endif // wxHAS_TEXT_WINDOW_STREAM +// ---------------------------------------------------------------------------- +// clipboard stuff +// ---------------------------------------------------------------------------- + +bool wxTextCtrlBase::CanCopy() const +{ + // can copy if there's a selection + long from, to; + GetSelection(&from, &to); + return from != to; +} + +bool wxTextCtrlBase::CanCut() const +{ + // can cut if there's a selection and if we're not read only + return CanCopy() && IsEditable(); +} + +bool wxTextCtrlBase::CanPaste() const +{ + // can paste if we are not read only + return IsEditable(); +} + // ---------------------------------------------------------------------------- // emulating key presses // ---------------------------------------------------------------------------- +#ifdef __WIN32__ +// the generic version is unused in wxMSW +bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& WXUNUSED(event)) +{ + return false; +} +#else // !__WIN32__ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) { - bool handled = false; - // we have a native implementation for Win32 and so don't need this one -#ifndef __WIN32__ wxChar ch = 0; int keycode = event.GetKeyCode(); - - long from, to; - GetSelection(&from,&to); - long insert = GetInsertionPoint(); - long last = GetLastPosition(); - - // catch arrow left and right - switch ( keycode ) { - case WXK_LEFT: - if ( event.ShiftDown() ) - SetSelection( (from > 0 ? from - 1 : 0) , to ); - else - { - if ( from != to ) - insert = from; - else if ( insert > 0 ) - insert -= 1; - SetInsertionPoint( insert ); - } - handled = true; - break; - case WXK_RIGHT: - if ( event.ShiftDown() ) - SetSelection( from, (to < last ? to + 1 : last) ); - else - { - if ( from != to ) - insert = to; - else if ( insert < last ) - insert += 1; - SetInsertionPoint( insert ); - } - handled = true; - break; case WXK_NUMPAD0: case WXK_NUMPAD1: case WXK_NUMPAD2: @@ -1070,32 +370,32 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) case WXK_NUMPAD7: case WXK_NUMPAD8: case WXK_NUMPAD9: - ch = (wxChar)(wxT('0') + keycode - WXK_NUMPAD0); + ch = (wxChar)(_T('0') + keycode - WXK_NUMPAD0); break; case WXK_MULTIPLY: case WXK_NUMPAD_MULTIPLY: - ch = wxT('*'); + ch = _T('*'); break; case WXK_ADD: case WXK_NUMPAD_ADD: - ch = wxT('+'); + ch = _T('+'); break; case WXK_SUBTRACT: case WXK_NUMPAD_SUBTRACT: - ch = wxT('-'); + ch = _T('-'); break; case WXK_DECIMAL: case WXK_NUMPAD_DECIMAL: - ch = wxT('.'); + ch = _T('.'); break; case WXK_DIVIDE: case WXK_NUMPAD_DIVIDE: - ch = wxT('/'); + ch = _T('/'); break; case WXK_DELETE: @@ -1105,7 +405,6 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) const long pos = GetInsertionPoint(); if ( pos < GetLastPosition() ) Remove(pos, pos + 1); - handled = true; } break; @@ -1115,7 +414,6 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) const long pos = GetInsertionPoint(); if ( pos > 0 ) Remove(pos - 1, pos); - handled = true; } break; @@ -1139,7 +437,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) } else { - ch = wxT('\0'); + ch = _T('\0'); } } @@ -1147,25 +445,39 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) { WriteText(ch); - handled = true; + return true; } -#else // __WIN32__ - wxUnusedVar(event); -#endif // !__WIN32__/__WIN32__ - return handled; + return false; +} +#endif // !__WIN32__ + +// ---------------------------------------------------------------------------- +// selection and ranges +// ---------------------------------------------------------------------------- + +void wxTextCtrlBase::SelectAll() +{ + SetSelection(0, GetLastPosition()); } -// ---------------------------------------------------------------------------- -// Other miscellaneous stuff -// ---------------------------------------------------------------------------- - -bool wxTextCtrlBase::SetHint(const wxString& hint) +wxString wxTextCtrlBase::GetStringSelection() const { - wxCHECK_MSG( IsSingleLine(), false, - wxS("Hints can only be set for single line text controls") ); + long from, to; + GetSelection(&from, &to); - return wxTextEntry::SetHint(hint); + return GetRange(from, to); +} + +wxString wxTextCtrlBase::GetRange(long from, long to) const +{ + wxString sel; + if ( from < to ) + { + sel = GetValue().Mid(from, to - from); + } + + return sel; } // do the window-specific processing after processing the update event @@ -1189,7 +501,7 @@ void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event) // ---------------------------------------------------------------------------- wxTextCtrlHitTestResult -wxTextAreaBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const +wxTextCtrlBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const { // implement in terms of the other overload as the native ports typically // can get the position and not (x, y) pair directly (although wxUniv @@ -1206,23 +518,29 @@ wxTextAreaBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const } wxTextCtrlHitTestResult -wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const +wxTextCtrlBase::HitTest(const wxPoint& WXUNUSED(pt), + long * WXUNUSED(pos)) const { // not implemented return wxTE_HT_UNKNOWN; } -wxPoint wxTextAreaBase::PositionToCoords(long pos) const -{ - wxCHECK_MSG( IsValidPosition(pos), wxDefaultPosition, - wxS("Position argument out of range.") ); +// ---------------------------------------------------------------------------- +// events +// ---------------------------------------------------------------------------- - return DoPositionToCoords(pos); -} - -wxPoint wxTextAreaBase::DoPositionToCoords(long WXUNUSED(pos)) const +void wxTextCtrlBase::SendTextUpdatedEvent() { - return wxDefaultPosition; + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId()); + + // do not do this as it could be very inefficient if the text control + // contains a lot of text and we're not using ref-counted wxString + // implementation -- instead, event.GetString() will query the control for + // its current text if needed + //event.SetString(GetValue()); + + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); } #else // !wxUSE_TEXTCTRL @@ -1230,6 +548,6 @@ wxPoint wxTextAreaBase::DoPositionToCoords(long WXUNUSED(pos)) const // define this one even if !wxUSE_TEXTCTRL because it is also used by other // controls (wxComboBox and wxSpinCtrl) -wxDEFINE_EVENT( wxEVT_TEXT, wxCommandEvent ); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED) #endif // wxUSE_TEXTCTRL/!wxUSE_TEXTCTRL diff --git a/Source/3rd Party/wx/src/common/textentrycmn.cpp b/Source/3rd Party/wx/src/common/textentrycmn.cpp deleted file mode 100644 index b1480e322..000000000 --- a/Source/3rd Party/wx/src/common/textentrycmn.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/textentrycmn.cpp -// Purpose: wxTextEntryBase implementation -// Author: Vadim Zeitlin -// Created: 2007-09-26 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_TEXTCTRL || wxUSE_COMBOBOX - -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/dataobj.h" -#endif //WX_PRECOMP - -#include "wx/textentry.h" -#include "wx/textcompleter.h" -#include "wx/clipbrd.h" - -// ---------------------------------------------------------------------------- -// wxTextEntryHintData -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxTextEntryHintData wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS -{ -public: - wxTextEntryHintData(wxTextEntryBase *entry, wxWindow *win) - : m_entry(entry), - m_win(win), - m_text(m_entry->GetValue()) - { - wxBIND_OR_CONNECT_HACK(win, wxEVT_SET_FOCUS, wxFocusEventHandler, - wxTextEntryHintData::OnSetFocus, this); - wxBIND_OR_CONNECT_HACK(win, wxEVT_KILL_FOCUS, wxFocusEventHandler, - wxTextEntryHintData::OnKillFocus, this); - wxBIND_OR_CONNECT_HACK(win, wxEVT_TEXT, - wxCommandEventHandler, - wxTextEntryHintData::OnTextChanged, this); - } - - // default dtor is ok - - // Get the real text of the control such as it was before we replaced it - // with the hint. - const wxString& GetText() const { return m_text; } - - // Set the hint to show, shouldn't be empty normally. - // - // This should be called after creating a new wxTextEntryHintData object - // and may be called more times in the future. - void SetHintString(const wxString& hint) - { - m_hint = hint; - - if ( !m_win->HasFocus() ) - ShowHintIfAppropriate(); - //else: The new hint will be shown later when we lose focus. - } - - const wxString& GetHintString() const { return m_hint; } - - // This is called whenever the text control contents changes. - // - // We call it ourselves when this change generates an event but it's also - // necessary to call it explicitly from wxTextEntry::ChangeValue() as it, - // by design, does not generate any events. - void HandleTextUpdate(const wxString& text) - { - m_text = text; - - // If we're called because of a call to Set or ChangeValue(), the - // control may still have the hint text colour, reset it in this case. - RestoreTextColourIfNecessary(); - } - -private: - // Show the hint in the window if we should do it, i.e. if the window - // doesn't have any text of its own. - void ShowHintIfAppropriate() - { - // Never overwrite existing window text. - if ( !m_text.empty() ) - return; - - // Save the old text colour and set a more inconspicuous one for the - // hint. - m_colFg = m_win->GetForegroundColour(); - m_win->SetForegroundColour(*wxLIGHT_GREY); - - m_entry->DoSetValue(m_hint, wxTextEntryBase::SetValue_NoEvent); - } - - // Restore the original text colour if we had changed it to show the hint - // and not restored it yet. - void RestoreTextColourIfNecessary() - { - if ( m_colFg.IsOk() ) - { - m_win->SetForegroundColour(m_colFg); - m_colFg = wxColour(); - } - } - - void OnSetFocus(wxFocusEvent& event) - { - // If we had been showing the hint before, remove it now and restore - // the normal colour. - if ( m_text.empty() ) - { - RestoreTextColourIfNecessary(); - - m_entry->DoSetValue(wxString(), wxTextEntryBase::SetValue_NoEvent); - } - - event.Skip(); - } - - void OnKillFocus(wxFocusEvent& event) - { - // Restore the hint if the user didn't enter anything. - ShowHintIfAppropriate(); - - event.Skip(); - } - - void OnTextChanged(wxCommandEvent& event) - { - // Update the stored window text. - // - // Notice that we can't use GetValue() nor wxCommandEvent::GetString() - // which uses it internally because this would just forward back to us - // so go directly to the private method which returns the real control - // contents. - HandleTextUpdate(m_entry->DoGetValue()); - - event.Skip(); - } - - - // the text control we're associated with (as its interface and its window) - wxTextEntryBase * const m_entry; - wxWindow * const m_win; - - // the original foreground colour of m_win before we changed it - wxColour m_colFg; - - // The hint passed to wxTextEntry::SetHint(), never empty. - wxString m_hint; - - // The real text of the window. - wxString m_text; - - - wxDECLARE_NO_COPY_CLASS(wxTextEntryHintData); -}; - -// ============================================================================ -// wxTextEntryBase implementation -// ============================================================================ - -wxTextEntryBase::~wxTextEntryBase() -{ - delete m_hintData; -} - -// ---------------------------------------------------------------------------- -// text accessors -// ---------------------------------------------------------------------------- - -wxString wxTextEntryBase::GetValue() const -{ - return m_hintData ? m_hintData->GetText() : DoGetValue(); -} - -wxString wxTextEntryBase::GetRange(long from, long to) const -{ - wxString sel; - wxString value = GetValue(); - - if ( from < to && (long)value.length() >= to ) - { - sel = value.substr(from, to - from); - } - - return sel; -} - -// ---------------------------------------------------------------------------- -// text operations -// ---------------------------------------------------------------------------- - -void wxTextEntryBase::ChangeValue(const wxString& value) -{ - DoSetValue(value, SetValue_NoEvent); - - // As we didn't generate any events for wxTextEntryHintData to catch, - // notify it explicitly about our changed contents. - if ( m_hintData ) - m_hintData->HandleTextUpdate(value); -} - -void wxTextEntryBase::AppendText(const wxString& text) -{ - SetInsertionPointEnd(); - WriteText(text); -} - -void wxTextEntryBase::DoSetValue(const wxString& value, int flags) -{ - if ( value != DoGetValue() ) - { - EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent)); - - SelectAll(); - WriteText(value); - - SetInsertionPoint(0); - } - else // Same value, no need to do anything. - { - // Except that we still need to generate the event for consistency with - // the normal case when the text does change. - if ( flags & SetValue_SendEvent ) - SendTextUpdatedEvent(GetEditableWindow()); - } -} - -void wxTextEntryBase::Replace(long from, long to, const wxString& value) -{ - { - EventsSuppressor noevents(this); - Remove(from, to); - } - - SetInsertionPoint(from); - WriteText(value); -} - -// ---------------------------------------------------------------------------- -// selection -// ---------------------------------------------------------------------------- - -bool wxTextEntryBase::HasSelection() const -{ - long from, to; - GetSelection(&from, &to); - - return from < to; -} - -void wxTextEntryBase::RemoveSelection() -{ - long from, to; - GetSelection(& from, & to); - if (from != -1 && to != -1) - Remove(from, to); -} - -wxString wxTextEntryBase::GetStringSelection() const -{ - long from, to; - GetSelection(&from, &to); - - return GetRange(from, to); -} - -// ---------------------------------------------------------------------------- -// clipboard -// ---------------------------------------------------------------------------- - -bool wxTextEntryBase::CanCopy() const -{ - return HasSelection(); -} - -bool wxTextEntryBase::CanCut() const -{ - return CanCopy() && IsEditable(); -} - -bool wxTextEntryBase::CanPaste() const -{ - if ( IsEditable() ) - { -#if wxUSE_CLIPBOARD - // check if there is any text on the clipboard - if ( wxTheClipboard->IsSupported(wxDF_TEXT) -#if wxUSE_UNICODE - || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) -#endif // wxUSE_UNICODE - ) - { - return true; - } -#endif // wxUSE_CLIPBOARD - } - - return false; -} - -// ---------------------------------------------------------------------------- -// hints support -// ---------------------------------------------------------------------------- - -bool wxTextEntryBase::SetHint(const wxString& hint) -{ - if ( !hint.empty() ) - { - if ( !m_hintData ) - m_hintData = new wxTextEntryHintData(this, GetEditableWindow()); - - m_hintData->SetHintString(hint); - } - else if ( m_hintData ) - { - // Setting empty hint removes any currently set one. - delete m_hintData; - m_hintData = NULL; - } - //else: Setting empty hint when we don't have any doesn't do anything. - - return true; -} - -wxString wxTextEntryBase::GetHint() const -{ - return m_hintData ? m_hintData->GetHintString() : wxString(); -} - -// ---------------------------------------------------------------------------- -// margins support -// ---------------------------------------------------------------------------- - -bool wxTextEntryBase::DoSetMargins(const wxPoint& WXUNUSED(pt)) -{ - return false; -} - -wxPoint wxTextEntryBase::DoGetMargins() const -{ - return wxPoint(-1, -1); -} - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -/* static */ -bool wxTextEntryBase::SendTextUpdatedEvent(wxWindow *win) -{ - wxCHECK_MSG( win, false, "can't send an event without a window" ); - - wxCommandEvent event(wxEVT_TEXT, win->GetId()); - - // do not do this as it could be very inefficient if the text control - // contains a lot of text and we're not using ref-counted wxString - // implementation -- instead, event.GetString() will query the control for - // its current text if needed - //event.SetString(win->GetValue()); - - event.SetEventObject(win); - return win->HandleWindowEvent(event); -} - -// ---------------------------------------------------------------------------- -// auto-completion stubs -// ---------------------------------------------------------------------------- - -wxTextCompleter::~wxTextCompleter() -{ -} - -bool wxTextCompleterSimple::Start(const wxString& prefix) -{ - m_index = 0; - m_completions.clear(); - GetCompletions(prefix, m_completions); - - return !m_completions.empty(); -} - -wxString wxTextCompleterSimple::GetNext() -{ - if ( m_index == m_completions.size() ) - return wxString(); - - return m_completions[m_index++]; -} - -bool wxTextEntryBase::DoAutoCompleteCustom(wxTextCompleter *completer) -{ - // We don't do anything here but we still need to delete the completer for - // consistency with the ports that do implement this method and take - // ownership of the pointer. - delete completer; - - return false; -} - -#endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX diff --git a/Source/3rd Party/wx/src/common/textfile.cpp b/Source/3rd Party/wx/src/common/textfile.cpp index 6cb4e6878..d873e1d97 100644 --- a/Source/3rd Party/wx/src/common/textfile.cpp +++ b/Source/3rd Party/wx/src/common/textfile.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 03.04.98 +// RCS-ID: $Id: textfile.cpp 49298 2007-10-21 18:05:49Z SC $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -63,7 +64,7 @@ bool wxTextFile::OnOpen(const wxString &strBufferName, wxTextBufferOpenMode Open switch ( OpenMode ) { default: - wxFAIL_MSG( wxT("unknown open mode in wxTextFile::Open") ); + wxFAIL_MSG( _T("unknown open mode in wxTextFile::Open") ); // fall through case ReadAccess : @@ -88,20 +89,18 @@ bool wxTextFile::OnClose() bool wxTextFile::OnRead(const wxMBConv& conv) { // file should be opened - wxASSERT_MSG( m_file.IsOpened(), wxT("can't read closed file") ); + wxASSERT_MSG( m_file.IsOpened(), _T("can't read closed file") ); // read the entire file in memory: this is not the most efficient thing to - // do it but there is no good way to avoid it in Unicode build because if - // we read the file block by block we can't convert each block to Unicode + // do but there is no good way to avoid it in Unicode build because if we + // read the file block by block we can't convert each block to Unicode // separately (the last multibyte char in the block might be only partially // read and so the conversion would fail) and, as the file contents is kept // in memory by wxTextFile anyhow, it shouldn't be a big problem to read // the file entirely - size_t bufSize = 0; - - // number of bytes to (try to) read from disk at once - static const size_t BLOCK_SIZE = 4096; - + size_t bufSize = 0, + bufPos = 0; + char block[1024]; wxCharBuffer buf; // first determine if the file is seekable or not and so whether we can @@ -119,79 +118,57 @@ bool wxTextFile::OnRead(const wxMBConv& conv) { // we know the required length, so set the buffer size in advance bufSize = fileLength; - if ( !buf.extend(bufSize) ) + if ( !buf.extend(bufSize - 1 /* it adds 1 internally */) ) return false; // if the file is seekable, also check that we're at its beginning - wxASSERT_MSG( m_file.Tell() == 0, wxT("should be at start of file") ); - - char *dst = buf.data(); - for ( size_t nRemaining = bufSize; nRemaining > 0; ) - { - size_t nToRead = BLOCK_SIZE; - - // the file size could have changed, avoid overflowing the buffer - // even if it did - if ( nToRead > nRemaining ) - nToRead = nRemaining; - - ssize_t nRead = m_file.Read(dst, nToRead); - - if ( nRead == wxInvalidOffset ) - { - // read error (error message already given in wxFile::Read) - return false; - } - - if ( nRead == 0 ) - { - // this file can't be empty because we checked for this above - // so this must be the end of file - break; - } - - dst += nRead; - nRemaining -= nRead; - } - - wxASSERT_MSG( dst - buf.data() == (wxFileOffset)bufSize, - wxT("logic error") ); + wxASSERT_MSG( m_file.Tell() == 0, _T("should be at start of file") ); } - else // file is not seekable + + for ( ;; ) { - char block[BLOCK_SIZE]; - for ( ;; ) + ssize_t nRead = m_file.Read(block, WXSIZEOF(block)); + + if ( nRead == wxInvalidOffset ) { - ssize_t nRead = m_file.Read(block, WXSIZEOF(block)); - - if ( nRead == wxInvalidOffset ) - { - // read error (error message already given in wxFile::Read) - return false; - } - - if ( nRead == 0 ) - { - // if no bytes have been read, presumably this is a - // valid-but-empty file - if ( bufSize == 0 ) - return true; - - // otherwise we've finished reading the file - break; - } - - // extend the buffer for new data - if ( !buf.extend(bufSize + nRead) ) - return false; - - // and append it to the buffer - memcpy(buf.data() + bufSize, block, nRead); - bufSize += nRead; + // read error (error message already given in wxFile::Read) + return false; } + + if ( nRead == 0 ) + { + // if no bytes have been read, presumably this is a valid-but-empty file + if ( bufPos == 0 ) + return true; + + // otherwise we've finished reading the file + break; + } + + if ( seekable ) + { + // this shouldn't happen but don't overwrite the buffer if it does + wxCHECK_MSG( bufPos + nRead <= bufSize, false, + _T("read more than file length?") ); + } + else // !seekable + { + // for non-seekable files we have to allocate more memory on the go + if ( !buf.extend(bufPos + nRead - 1 /* it adds 1 internally */) ) + return false; + } + + // append to the buffer + memcpy(buf.data() + bufPos, block, nRead); + bufPos += nRead; } - const wxString str(buf, conv, bufSize); + if ( !seekable ) + { + bufSize = bufPos; + } + + const wxString str(buf, conv, bufPos); // there's no risk of this happening in ANSI build #if wxUSE_UNICODE @@ -202,52 +179,84 @@ bool wxTextFile::OnRead(const wxMBConv& conv) } #endif // wxUSE_UNICODE - // we don't need this memory any more - buf.reset(); + free(buf.release()); // we don't need this memory any more // now break the buffer in lines + // last processed character, we need to know if it was a CR or not + wxChar chLast = '\0'; + // the beginning of the current line, changes inside the loop wxString::const_iterator lineStart = str.begin(); const wxString::const_iterator end = str.end(); for ( wxString::const_iterator p = lineStart; p != end; p++ ) { const wxChar ch = *p; - if ( ch == '\r' || ch == '\n' ) + switch ( ch ) { - // Determine the kind of line ending this is. - wxTextFileType lineType = wxTextFileType_None; - if ( ch == '\r' ) - { - wxString::const_iterator next = p + 1; - if ( next != end && *next == '\n' ) - lineType = wxTextFileType_Dos; - else - lineType = wxTextFileType_Mac; - } - else // ch == '\n' - { - lineType = wxTextFileType_Unix; - } + case '\n': + // could be a DOS or Unix EOL + if ( chLast == '\r' ) + { + if ( p - 1 >= lineStart ) + { + AddLine(wxString(lineStart, p - 1), wxTextFileType_Dos); + } + else + { + // there were two line endings, so add an empty line: + AddLine(wxEmptyString, wxTextFileType_Dos); + } + } + else // bare '\n', Unix style + { + AddLine(wxString(lineStart, p), wxTextFileType_Unix); + } - AddLine(wxString(lineStart, p), lineType); + lineStart = p + 1; + break; - // DOS EOL is the only one consisting of two chars, not one. - if ( lineType == wxTextFileType_Dos ) - p++; + case '\r': + if ( chLast == '\r' ) + { + if ( p - 1 >= lineStart ) + { + AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac); + } + // Mac empty line + AddLine(wxEmptyString, wxTextFileType_Mac); + lineStart = p + 1; + } + //else: we don't know what this is yet -- could be a Mac EOL or + // start of DOS EOL so wait for next char + break; - lineStart = p + 1; + default: + if ( chLast == '\r' ) + { + // Mac line termination + if ( p - 1 >= lineStart ) + { + AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac); + } + else + { + // there were two line endings, so add an empty line: + AddLine(wxEmptyString, wxTextFileType_Mac); + } + lineStart = p; + } } + + chLast = ch; } // anything in the last line? if ( lineStart != end ) { - // Add the last line; notice that it is certainly not terminated with a - // newline, otherwise it would be handled above. - wxString lastLine(lineStart, end); - AddLine(lastLine, wxTextFileType_None); + // add unterminated last line + AddLine(wxString(lineStart, end), wxTextFileType_None); } return true; diff --git a/Source/3rd Party/wx/src/common/textmeasurecmn.cpp b/Source/3rd Party/wx/src/common/textmeasurecmn.cpp deleted file mode 100644 index 8d828d4b7..000000000 --- a/Source/3rd Party/wx/src/common/textmeasurecmn.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/textmeasurecmn.cpp -// Purpose: wxTextMeasureBase implementation -// Author: Manuel Martin -// Created: 2012-10-05 -// Copyright: (c) 1997-2012 wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifndef WX_PRECOMP - #include "wx/dc.h" - #include "wx/window.h" -#endif //WX_PRECOMP - -#include "wx/private/textmeasure.h" - -// ============================================================================ -// wxTextMeasureBase implementation -// ============================================================================ - -wxTextMeasureBase::wxTextMeasureBase(const wxDC *dc, const wxFont *theFont) - : m_dc(dc), - m_win(NULL), - m_font(theFont) -{ - wxASSERT_MSG( dc, wxS("wxTextMeasure needs a valid wxDC") ); - - // By default, use wxDC version, we'll explicitly reset this to false in - // the derived classes if the DC is of native variety. - m_useDCImpl = true; -} - -wxTextMeasureBase::wxTextMeasureBase(const wxWindow *win, const wxFont *theFont) - : m_dc(NULL), - m_win(win), - m_font(theFont) -{ - wxASSERT_MSG( win, wxS("wxTextMeasure needs a valid wxWindow") ); - - // We don't have any wxDC so we can't forward to it. - m_useDCImpl = false; -} - -wxFont wxTextMeasureBase::GetFont() const -{ - return m_font ? *m_font - : m_win ? m_win->GetFont() - : m_dc->GetFont(); -} - -void wxTextMeasureBase::CallGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent, - wxCoord *externalLeading) -{ - if ( m_useDCImpl ) - m_dc->GetTextExtent(string, width, height, descent, externalLeading); - else - DoGetTextExtent(string, width, height, descent, externalLeading); -} - -void wxTextMeasureBase::GetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent, - wxCoord *externalLeading) -{ - // To make the code simpler, make sure that the width and height pointers - // are always valid, even if they point to dummy variables. - int unusedWidth, unusedHeight; - if ( !width ) - width = &unusedWidth; - if ( !height ) - height = &unusedHeight; - - // Avoid even setting up the DC for measuring if we don't actually need to - // measure anything. - if ( string.empty() && !descent && !externalLeading ) - { - *width = - *height = 0; - - return; - } - - MeasuringGuard guard(*this); - - CallGetTextExtent(string, width, height, descent, externalLeading); -} - -void wxTextMeasureBase::GetMultiLineTextExtent(const wxString& text, - wxCoord *width, - wxCoord *height, - wxCoord *heightOneLine) -{ - MeasuringGuard guard(*this); - - wxCoord widthTextMax = 0, widthLine, - heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; - - wxString curLine; - for ( wxString::const_iterator pc = text.begin(); ; ++pc ) - { - if ( pc == text.end() || *pc == wxS('\n') ) - { - if ( curLine.empty() ) - { - // we can't use GetTextExtent - it will return 0 for both width - // and height and an empty line should count in height - // calculation - - // assume that this line has the same height as the previous - // one - if ( !heightLineDefault ) - heightLineDefault = heightLine; - - if ( !heightLineDefault ) - { - // but we don't know it yet - choose something reasonable - int dummy; - CallGetTextExtent(wxS("W"), &dummy, &heightLineDefault); - } - - heightTextTotal += heightLineDefault; - } - else - { - CallGetTextExtent(curLine, &widthLine, &heightLine); - if ( widthLine > widthTextMax ) - widthTextMax = widthLine; - heightTextTotal += heightLine; - } - - if ( pc == text.end() ) - { - break; - } - else // '\n' - { - curLine.clear(); - } - } - else - { - curLine += *pc; - } - } - - if ( width ) - *width = widthTextMax; - if ( height ) - *height = heightTextTotal; - if ( heightOneLine ) - *heightOneLine = heightLine; -} - -wxSize wxTextMeasureBase::GetLargestStringExtent(size_t n, - const wxString* strings) -{ - MeasuringGuard guard(*this); - - wxCoord w, h, widthMax = 0, heightMax = 0; - for ( size_t i = 0; i < n; ++i ) - { - CallGetTextExtent(strings[i], &w, &h); - - if ( w > widthMax ) - widthMax = w; - if ( h > heightMax ) - heightMax = h; - } - - return wxSize(widthMax, heightMax); -} - -bool wxTextMeasureBase::GetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX) -{ - widths.Empty(); - if ( text.empty() ) - return true; - - MeasuringGuard guard(*this); - - widths.Add(0, text.length()); - - return DoGetPartialTextExtents(text, widths, scaleX); -} - -// ---------------------------------------------------------------------------- -// Generic and inefficient DoGetPartialTextExtents() implementation. -// ---------------------------------------------------------------------------- - -// Each element of the widths array will be the width of the string up to and -// including the corresponding character in text. This is the generic -// implementation, the port-specific classes should do this with native APIs -// if available and if faster. Note: pango_layout_index_to_pos is much slower -// than calling GetTextExtent!! - -#define FWC_SIZE 256 - -class FontWidthCache -{ -public: - FontWidthCache() : m_scaleX(1), m_widths(NULL) { } - ~FontWidthCache() { delete []m_widths; } - - void Reset() - { - if ( !m_widths ) - m_widths = new int[FWC_SIZE]; - - memset(m_widths, 0, sizeof(int)*FWC_SIZE); - } - - wxFont m_font; - double m_scaleX; - int *m_widths; -}; - -static FontWidthCache s_fontWidthCache; - -bool wxTextMeasureBase::DoGetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX) -{ - int totalWidth = 0; - - // reset the cache if font or horizontal scale have changed - if ( !s_fontWidthCache.m_widths || - !wxIsSameDouble(s_fontWidthCache.m_scaleX, scaleX) || - (s_fontWidthCache.m_font != *m_font) ) - { - s_fontWidthCache.Reset(); - s_fontWidthCache.m_font = *m_font; - s_fontWidthCache.m_scaleX = scaleX; - } - - // Calculate the position of each character based on the widths of - // the previous characters. This is inexact for not fixed fonts. - int n = 0; - for ( wxString::const_iterator it = text.begin(); - it != text.end(); - ++it ) - { - const wxChar c = *it; - unsigned int c_int = (unsigned int)c; - - int w; - if ((c_int < FWC_SIZE) && (s_fontWidthCache.m_widths[c_int] != 0)) - { - w = s_fontWidthCache.m_widths[c_int]; - } - else - { - DoGetTextExtent(c, &w, NULL); - if (c_int < FWC_SIZE) - s_fontWidthCache.m_widths[c_int] = w; - } - - totalWidth += w; - widths[n++] = totalWidth; - } - - return true; -} - diff --git a/Source/3rd Party/wx/src/common/threadinfo.cpp b/Source/3rd Party/wx/src/common/threadinfo.cpp deleted file mode 100644 index e77682db1..000000000 --- a/Source/3rd Party/wx/src/common/threadinfo.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/threadinfo.cpp -// Purpose: declaration of wxThreadSpecificInfo: thread-specific information -// Author: Vaclav Slavik -// Created: 2013-09-14 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#include "wx/private/threadinfo.h" - -#if wxUSE_THREADS - -#include "wx/tls.h" -#include "wx/thread.h" -#include "wx/sharedptr.h" -#include "wx/vector.h" - -namespace -{ - -// All thread info objects are stored in a global list so that they are -// freed when global objects are destroyed and no memory leaks are reported. - -// Notice that we must be using accessor functions instead of simple global -// variables here as this code could be executed during global initialization -// time, i.e. before any globals in this module were initialzied. -inline wxCriticalSection& GetAllThreadInfosCS() -{ - static wxCriticalSection s_csAllThreadInfos; - - return s_csAllThreadInfos; -} - -typedef wxVector< wxSharedPtr > wxAllThreadInfos; -inline wxAllThreadInfos& GetAllThreadInfos() -{ - static wxAllThreadInfos s_allThreadInfos; - - return s_allThreadInfos; -} - -// Pointer to the current thread's instance -inline wxTLS_TYPE_REF(wxThreadSpecificInfo*) GetThisThreadInfo() -{ - static wxTLS_TYPE(wxThreadSpecificInfo*) s_thisThreadInfo; - - return s_thisThreadInfo; -} - -#define wxTHIS_THREAD_INFO wxTLS_VALUE(GetThisThreadInfo()) - -} // anonymous namespace - - -wxThreadSpecificInfo& wxThreadSpecificInfo::Get() -{ - if ( !wxTHIS_THREAD_INFO ) - { - wxTHIS_THREAD_INFO = new wxThreadSpecificInfo; - wxCriticalSectionLocker lock(GetAllThreadInfosCS()); - GetAllThreadInfos().push_back( - wxSharedPtr(wxTHIS_THREAD_INFO)); - } - return *wxTHIS_THREAD_INFO; -} - -void wxThreadSpecificInfo::ThreadCleanUp() -{ - if ( !wxTHIS_THREAD_INFO ) - return; // nothing to do, not used by this thread at all - - // find this thread's instance in GetAllThreadInfos() and destroy it - wxCriticalSectionLocker lock(GetAllThreadInfosCS()); - for ( wxAllThreadInfos::iterator i = GetAllThreadInfos().begin(); - i != GetAllThreadInfos().end(); - ++i ) - { - if ( i->get() == wxTHIS_THREAD_INFO ) - { - GetAllThreadInfos().erase(i); - wxTHIS_THREAD_INFO = NULL; - break; - } - } -} - -#else // !wxUSE_THREADS - -wxThreadSpecificInfo& wxThreadSpecificInfo::Get() -{ - static wxThreadSpecificInfo s_instance; - return s_instance; -} - -#endif // wxUSE_THREADS/wxUSE_THREADS diff --git a/Source/3rd Party/wx/src/common/time.cpp b/Source/3rd Party/wx/src/common/time.cpp deleted file mode 100644 index 011b60149..000000000 --- a/Source/3rd Party/wx/src/common/time.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/time.cpp -// Purpose: Implementation of time-related functions. -// Author: Vadim Zeitlin -// Created: 2011-11-26 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/time.h" - -#ifndef WX_PRECOMP - #ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" - #endif - #include "wx/intl.h" - #include "wx/log.h" -#endif - -#ifndef WX_GMTOFF_IN_TM - // Define it for some systems which don't (always) use configure but are - // known to have tm_gmtoff field. - #if defined(__DARWIN__) - #define WX_GMTOFF_IN_TM - #endif -#endif - -#if defined(__VISAGECPP__) && !defined(HAVE_FTIME) - #define HAVE_FTIME -# if __IBMCPP__ >= 400 - # define ftime(x) _ftime(x) -# endif -#endif - -#ifndef __WXWINCE__ -#include -#else -#include "wx/msw/private.h" -#include "wx/msw/wince/time.h" -#endif - - -#if !defined(__WXMAC__) && !defined(__WXWINCE__) - #include // for time_t -#endif - -#if defined(HAVE_GETTIMEOFDAY) - #include - #include -#elif defined(HAVE_FTIME) - #include -#endif - -#if defined(__DJGPP__) || defined(__WINE__) - #include - #include -#endif - -namespace -{ - -const int MILLISECONDS_PER_SECOND = 1000; -const int MICROSECONDS_PER_MILLISECOND = 1000; -const int MICROSECONDS_PER_SECOND = 1000*1000; - -} // anonymous namespace - -// ============================================================================ -// implementation -// ============================================================================ - -// NB: VC8 safe time functions could/should be used for wxMSW as well probably -#if defined(__WXWINCE__) && defined(__VISUALC8__) - -struct tm *wxLocaltime_r(const time_t *t, struct tm* tm) -{ - __time64_t t64 = *t; - return _localtime64_s(tm, &t64) == 0 ? tm : NULL; -} - -struct tm *wxGmtime_r(const time_t* t, struct tm* tm) -{ - __time64_t t64 = *t; - return _gmtime64_s(tm, &t64) == 0 ? tm : NULL; -} - -#else // !wxWinCE with VC8 - -#if (!defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)) && wxUSE_THREADS && !defined(__WINDOWS__) -static wxMutex timeLock; -#endif - -#ifndef HAVE_LOCALTIME_R -struct tm *wxLocaltime_r(const time_t* ticks, struct tm* temp) -{ -#if wxUSE_THREADS && !defined(__WINDOWS__) - // No need to waste time with a mutex on windows since it's using - // thread local storage for localtime anyway. - wxMutexLocker locker(timeLock); -#endif - - // Borland CRT crashes when passed 0 ticks for some reason, see SF bug 1704438 -#ifdef __BORLANDC__ - if ( !*ticks ) - return NULL; -#endif - - const tm * const t = localtime(ticks); - if ( !t ) - return NULL; - - memcpy(temp, t, sizeof(struct tm)); - return temp; -} -#endif // !HAVE_LOCALTIME_R - -#ifndef HAVE_GMTIME_R -struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp) -{ -#if wxUSE_THREADS && !defined(__WINDOWS__) - // No need to waste time with a mutex on windows since it's - // using thread local storage for gmtime anyway. - wxMutexLocker locker(timeLock); -#endif - -#ifdef __BORLANDC__ - if ( !*ticks ) - return NULL; -#endif - - const tm * const t = gmtime(ticks); - if ( !t ) - return NULL; - - memcpy(temp, gmtime(ticks), sizeof(struct tm)); - return temp; -} -#endif // !HAVE_GMTIME_R - -#endif // wxWinCE with VC8/other platforms - -// returns the time zone in the C sense, i.e. the difference UTC - local -// (in seconds) -int wxGetTimeZone() -{ -#ifdef WX_GMTOFF_IN_TM - // set to true when the timezone is set - static bool s_timezoneSet = false; - static long gmtoffset = LONG_MAX; // invalid timezone - - // ensure that the timezone variable is set by calling wxLocaltime_r - if ( !s_timezoneSet ) - { - // just call wxLocaltime_r() instead of figuring out whether this - // system supports tzset(), _tzset() or something else - time_t t = time(NULL); - struct tm tm; - - wxLocaltime_r(&t, &tm); - s_timezoneSet = true; - - // note that GMT offset is the opposite of time zone and so to return - // consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM - // cases we have to negate it - gmtoffset = -tm.tm_gmtoff; - - // this function is supposed to return the same value whether DST is - // enabled or not, so we need to use an additional offset if DST is on - // as tm_gmtoff already does include it - if ( tm.tm_isdst ) - gmtoffset += 3600; - } - return (int)gmtoffset; -#elif defined(__DJGPP__) || defined(__WINE__) - struct timeb tb; - ftime(&tb); - return tb.timezone*60; -#elif defined(__VISUALC__) - // We must initialize the time zone information before using it (this will - // be done only once internally). - _tzset(); - - // Starting with VC++ 8 timezone variable is deprecated and is not even - // available in some standard library version so use the new function for - // accessing it instead. - #if wxCHECK_VISUALC_VERSION(8) - long t; - _get_timezone(&t); - return t; - #else // VC++ < 8 - return timezone; - #endif -#else // Use some kind of time zone variable. - // In any case we must initialize the time zone before using it. - tzset(); - - #if defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it. - return WX_TIMEZONE; - #elif defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__) - return _timezone; - #else // unknown platform -- assume it has timezone - return timezone; - #endif // different time zone variables -#endif // different ways to determine time zone -} - -// Get local time as seconds since 00:00:00, Jan 1st 1970 -long wxGetLocalTime() -{ - struct tm tm; - time_t t0, t1; - - // This cannot be made static because mktime can overwrite it. - // - memset(&tm, 0, sizeof(tm)); - tm.tm_year = 70; - tm.tm_mon = 0; - tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature' - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; // let mktime guess - - // Note that mktime assumes that the struct tm contains local time. - // - t1 = time(&t1); // now - t0 = mktime(&tm); // origin - - // Return the difference in seconds. - // - if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 )) - return (long)difftime(t1, t0) + (60 * 60 * 24 * 4); - - wxLogSysError(_("Failed to get the local system time")); - return -1; -} - -// Get UTC time as seconds since 00:00:00, Jan 1st 1970 -long wxGetUTCTime() -{ - return (long)time(NULL); -} - -#if wxUSE_LONGLONG - -wxLongLong wxGetUTCTimeUSec() -{ -#if defined(__WINDOWS__) - FILETIME ft; - ::GetSystemTimeAsFileTime(&ft); - - // FILETIME is in 100ns or 0.1us since 1601-01-01, transform to us since - // 1970-01-01. - wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime); - t /= 10; - t -= wxLL(11644473600000000); // Unix - Windows epochs difference in us. - return t; -#else // non-MSW - -#ifdef HAVE_GETTIMEOFDAY - timeval tv; - if ( wxGetTimeOfDay(&tv) != -1 ) - { - wxLongLong val(tv.tv_sec); - val *= MICROSECONDS_PER_SECOND; - val += tv.tv_usec; - return val; - } -#endif // HAVE_GETTIMEOFDAY - - // Fall back to lesser precision function. - return wxGetUTCTimeMillis()*MICROSECONDS_PER_MILLISECOND; -#endif // MSW/!MSW -} - -// Get local time as milliseconds since 00:00:00, Jan 1st 1970 -wxLongLong wxGetUTCTimeMillis() -{ - // If possible, use a function which avoids conversions from - // broken-up time structures to milliseconds -#if defined(__WINDOWS__) - FILETIME ft; - ::GetSystemTimeAsFileTime(&ft); - - // FILETIME is expressed in 100ns (or 0.1us) units since 1601-01-01, - // transform them to ms since 1970-01-01. - wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime); - t /= 10000; - t -= wxLL(11644473600000); // Unix - Windows epochs difference in ms. - return t; -#else // !__WINDOWS__ - wxLongLong val = MILLISECONDS_PER_SECOND; - -#if defined(HAVE_GETTIMEOFDAY) - struct timeval tp; - if ( wxGetTimeOfDay(&tp) != -1 ) - { - val *= tp.tv_sec; - return (val + (tp.tv_usec / MICROSECONDS_PER_MILLISECOND)); - } - else - { - wxLogError(_("wxGetTimeOfDay failed.")); - return 0; - } -#elif defined(HAVE_FTIME) - struct timeb tp; - - // ftime() is void and not int in some mingw32 headers, so don't - // test the return code (well, it shouldn't fail anyhow...) - (void)::ftime(&tp); - val *= tp.time; - return (val + tp.millitm); -#else // no gettimeofday() nor ftime() - // If your platform/compiler does not support ms resolution please - // do NOT just shut off these warnings, drop me a line instead at - // - - #if defined(__VISUALC__) || defined (__WATCOMC__) - #pragma message("wxStopWatch will be up to second resolution!") - #elif defined(__BORLANDC__) - #pragma message "wxStopWatch will be up to second resolution!" - #else - #warning "wxStopWatch will be up to second resolution!" - #endif // compiler - - val *= wxGetUTCTime(); - return val; -#endif // time functions - -#endif // __WINDOWS__/!__WINDOWS__ -} - -wxLongLong wxGetLocalTimeMillis() -{ - return wxGetUTCTimeMillis() - wxGetTimeZone()*MILLISECONDS_PER_SECOND; -} - -#else // !wxUSE_LONGLONG - -double wxGetLocalTimeMillis(void) -{ - return (double(clock()) / double(CLOCKS_PER_SEC)) * 1000.0; -} - -#endif // wxUSE_LONGLONG/!wxUSE_LONGLONG diff --git a/Source/3rd Party/wx/src/common/timercmn.cpp b/Source/3rd Party/wx/src/common/timercmn.cpp index f117f9aaf..43062b46d 100644 --- a/Source/3rd Party/wx/src/common/timercmn.cpp +++ b/Source/3rd Party/wx/src/common/timercmn.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/timercmn.cpp +// Name: common/timercmn.cpp // Purpose: wxTimerBase implementation // Author: Julian Smart, Guillermo Rodriguez, Vadim Zeitlin // Modified by: VZ: extracted all non-wxTimer stuff in stopwatch.cpp (20.06.03) // Created: 04/01/98 +// RCS-ID: $Id: timercmn.cpp 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) Julian Smart // (c) 1999 Guillermo Rodriguez // Licence: wxWindows licence @@ -27,111 +28,60 @@ #if wxUSE_TIMER #ifndef WX_PRECOMP - #include "wx/app.h" + #include "wx/timer.h" #endif -#include "wx/timer.h" -#include "wx/apptrait.h" -#include "wx/private/timer.h" - // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent) -wxDEFINE_EVENT(wxEVT_TIMER, wxTimerEvent); - // ============================================================================ // wxTimerBase implementation // ============================================================================ -wxTimer::~wxTimer() +wxTimerBase::~wxTimerBase() { - Stop(); - - delete m_impl; + // this destructor is required for Darwin } -void wxTimer::Init() -{ - wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - m_impl = traits ? traits->CreateTimerImpl(this) : NULL; - if ( !m_impl ) - { - wxFAIL_MSG( wxT("No timer implementation for this platform") ); - - } -} - -// ============================================================================ -// rest of wxTimer implementation forwarded to wxTimerImpl -// ============================================================================ - -void wxTimer::SetOwner(wxEvtHandler *owner, int timerid) -{ - wxCHECK_RET( m_impl, wxT("uninitialized timer") ); - - m_impl->SetOwner(owner, timerid); -} - -wxEvtHandler *wxTimer::GetOwner() const -{ - wxCHECK_MSG( m_impl, NULL, wxT("uninitialized timer") ); - - return m_impl->GetOwner(); -} - -bool wxTimer::Start(int milliseconds, bool oneShot) -{ - wxCHECK_MSG( m_impl, false, wxT("uninitialized timer") ); - - return m_impl->Start(milliseconds, oneShot); -} - -void wxTimer::Stop() -{ - wxCHECK_RET( m_impl, wxT("uninitialized timer") ); - - if ( m_impl->IsRunning() ) - m_impl->Stop(); -} - -void wxTimer::Notify() +void wxTimerBase::Notify() { // the base class version generates an event if it has owner - which it // should because otherwise nobody can process timer events - wxCHECK_RET( GetOwner(), wxT("wxTimer::Notify() should be overridden.") ); + wxCHECK_RET( m_owner, _T("wxTimer::Notify() should be overridden.") ); - m_impl->SendEvent(); + wxTimerEvent event(m_idTimer, m_milli); + event.SetEventObject(this); + (void)m_owner->ProcessEvent(event); } -bool wxTimer::IsRunning() const +bool wxTimerBase::Start(int milliseconds, bool oneShot) { - wxCHECK_MSG( m_impl, false, wxT("uninitialized timer") ); + // under MSW timers only work when they're started from the main thread so + // let the caller know about it +#if wxUSE_THREADS + wxASSERT_MSG( wxThread::IsMain(), + _T("timer can only be started from the main thread") ); +#endif // wxUSE_THREADS - return m_impl->IsRunning(); -} + if ( IsRunning() ) + { + // not stopping the already running timer might work for some + // platforms (no problems under MSW) but leads to mysterious crashes + // on the others (GTK), so to be on the safe side do it here + Stop(); + } -int wxTimer::GetId() const -{ - wxCHECK_MSG( m_impl, wxID_ANY, wxT("uninitialized timer") ); + if ( milliseconds != -1 ) + { + m_milli = milliseconds; + } - return m_impl->GetId(); -} + m_oneShot = oneShot; -int wxTimer::GetInterval() const -{ - wxCHECK_MSG( m_impl, -1, wxT("uninitialized timer") ); - - return m_impl->GetInterval(); -} - -bool wxTimer::IsOneShot() const -{ - wxCHECK_MSG( m_impl, false, wxT("uninitialized timer") ); - - return m_impl->IsOneShot(); + return true; } #endif // wxUSE_TIMER diff --git a/Source/3rd Party/wx/src/common/timerimpl.cpp b/Source/3rd Party/wx/src/common/timerimpl.cpp deleted file mode 100644 index d4d800d47..000000000 --- a/Source/3rd Party/wx/src/common/timerimpl.cpp +++ /dev/null @@ -1,83 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/timerimpl.cpp -// Purpose: wxTimerBase implementation -// Author: Julian Smart, Guillermo Rodriguez, Vadim Zeitlin -// Modified by: VZ: extracted all non-wxTimer stuff in stopwatch.cpp (20.06.03) -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// (c) 1999 Guillermo Rodriguez -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxWin headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_TIMER - -#include "wx/private/timer.h" -#include "wx/utils.h" // for wxNewId() -#include "wx/thread.h" - -wxTimerImpl::wxTimerImpl(wxTimer *timer) -{ - m_timer = timer; - m_owner = NULL; - m_idTimer = wxID_ANY; - m_milli = 0; - m_oneShot = false; -} - -void wxTimerImpl::SetOwner(wxEvtHandler *owner, int timerid) -{ - m_owner = owner; - m_idTimer = timerid == wxID_ANY ? wxNewId() : timerid; -} - -void wxTimerImpl::SendEvent() -{ - wxTimerEvent event(*m_timer); - (void)m_owner->SafelyProcessEvent(event); -} - -bool wxTimerImpl::Start(int milliseconds, bool oneShot) -{ - // under MSW timers only work when they're started from the main thread so - // let the caller know about it -#if wxUSE_THREADS - wxASSERT_MSG( wxThread::IsMain(), - wxT("timer can only be started from the main thread") ); -#endif // wxUSE_THREADS - - if ( IsRunning() ) - { - // not stopping the already running timer might work for some - // platforms (no problems under MSW) but leads to mysterious crashes - // on the others (GTK), so to be on the safe side do it here - Stop(); - } - - if ( milliseconds != -1 ) - { - m_milli = milliseconds; - } - - m_oneShot = oneShot; - - return true; -} - - -#endif // wxUSE_TIMER - diff --git a/Source/3rd Party/wx/src/common/tokenzr.cpp b/Source/3rd Party/wx/src/common/tokenzr.cpp index 9d7926919..b539458f8 100644 --- a/Source/3rd Party/wx/src/common/tokenzr.cpp +++ b/Source/3rd Party/wx/src/common/tokenzr.cpp @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: Vadim Zeitlin (almost full rewrite) // Created: 04/22/98 +// RCS-ID: $Id: tokenzr.cpp 39694 2006-06-13 11:30:40Z ABX $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,7 +28,6 @@ #ifndef WX_PRECOMP #include "wx/arrstr.h" - #include "wx/crt.h" #endif // Required for wxIs... functions @@ -37,42 +37,6 @@ // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// helpers -// ---------------------------------------------------------------------------- - -static wxString::const_iterator -find_first_of(const wxChar *delims, size_t len, - const wxString::const_iterator& from, - const wxString::const_iterator& end) -{ - wxASSERT_MSG( from <= end, wxT("invalid index") ); - - for ( wxString::const_iterator i = from; i != end; ++i ) - { - if ( wxTmemchr(delims, *i, len) ) - return i; - } - - return end; -} - -static wxString::const_iterator -find_first_not_of(const wxChar *delims, size_t len, - const wxString::const_iterator& from, - const wxString::const_iterator& end) -{ - wxASSERT_MSG( from <= end, wxT("invalid index") ); - - for ( wxString::const_iterator i = from; i != end; ++i ) - { - if ( !wxTmemchr(delims, *i, len) ) - return i; - } - - return end; -} - // ---------------------------------------------------------------------------- // wxStringTokenizer construction // ---------------------------------------------------------------------------- @@ -94,14 +58,14 @@ void wxStringTokenizer::SetString(const wxString& str, // whitespace characters and as wxTOKEN_RET_EMPTY otherwise (for // whitespace delimiters, strtok() behaviour is better because we want // to count consecutive spaces as one delimiter) - wxString::const_iterator p; - for ( p = delims.begin(); p != delims.end(); ++p ) + const wxChar *p; + for ( p = delims.c_str(); *p; p++ ) { if ( !wxIsspace(*p) ) break; } - if ( p != delims.end() ) + if ( *p ) { // not whitespace char in delims mode = wxTOKEN_RET_EMPTY; @@ -113,13 +77,7 @@ void wxStringTokenizer::SetString(const wxString& str, } } -#if wxUSE_UNICODE // FIXME-UTF8: only wc_str() - m_delims = delims.wc_str(); -#else - m_delims = delims.mb_str(); -#endif - m_delimsLen = delims.length(); - + m_delims = delims; m_mode = mode; Reinit(str); @@ -127,13 +85,11 @@ void wxStringTokenizer::SetString(const wxString& str, void wxStringTokenizer::Reinit(const wxString& str) { - wxASSERT_MSG( IsOk(), wxT("you should call SetString() first") ); + wxASSERT_MSG( IsOk(), _T("you should call SetString() first") ); m_string = str; - m_stringEnd = m_string.end(); - m_pos = m_string.begin(); - m_lastDelim = wxT('\0'); - m_hasMoreTokens = MoreTokens_Unknown; + m_pos = 0; + m_lastDelim = _T('\0'); } // ---------------------------------------------------------------------------- @@ -143,28 +99,9 @@ void wxStringTokenizer::Reinit(const wxString& str) // do we have more of them? bool wxStringTokenizer::HasMoreTokens() const { - // GetNextToken() calls HasMoreTokens() and so HasMoreTokens() is called - // twice in every interation in the following common usage patten: - // while ( HasMoreTokens() ) - // GetNextToken(); - // We optimize this case by caching HasMoreTokens() return value here: - if ( m_hasMoreTokens == MoreTokens_Unknown ) - { - bool r = DoHasMoreTokens(); - wxConstCast(this, wxStringTokenizer)->m_hasMoreTokens = - r ? MoreTokens_Yes : MoreTokens_No; - return r; - } - else - return m_hasMoreTokens == MoreTokens_Yes; -} + wxCHECK_MSG( IsOk(), false, _T("you should call SetString() first") ); -bool wxStringTokenizer::DoHasMoreTokens() const -{ - wxCHECK_MSG( IsOk(), false, wxT("you should call SetString() first") ); - - if ( find_first_not_of(m_delims, m_delimsLen, m_pos, m_stringEnd) - != m_stringEnd ) + if ( m_string.find_first_not_of(m_delims, m_pos) != wxString::npos ) { // there are non delimiter characters left, so we do have more tokens return true; @@ -176,7 +113,7 @@ bool wxStringTokenizer::DoHasMoreTokens() const case wxTOKEN_RET_DELIMS: // special hack for wxTOKEN_RET_EMPTY: we should return the initial // empty token even if there are only delimiters after it - return !m_string.empty() && m_pos == m_string.begin(); + return m_pos == 0 && !m_string.empty(); case wxTOKEN_RET_EMPTY_ALL: // special hack for wxTOKEN_RET_EMPTY_ALL: we can know if we had @@ -185,11 +122,11 @@ bool wxStringTokenizer::DoHasMoreTokens() const // up to the end of the string in GetNextToken(), but if it is not // NUL yet we still have this last token to return even if m_pos is // already at m_string.length() - return m_pos < m_stringEnd || m_lastDelim != wxT('\0'); + return m_pos < m_string.length() || m_lastDelim != _T('\0'); case wxTOKEN_INVALID: case wxTOKEN_DEFAULT: - wxFAIL_MSG( wxT("unexpected tokenizer mode") ); + wxFAIL_MSG( _T("unexpected tokenizer mode") ); // fall through case wxTOKEN_STRTOK: @@ -203,13 +140,13 @@ bool wxStringTokenizer::DoHasMoreTokens() const // count the number of (remaining) tokens in the string size_t wxStringTokenizer::CountTokens() const { - wxCHECK_MSG( IsOk(), 0, wxT("you should call SetString() first") ); + wxCHECK_MSG( IsOk(), 0, _T("you should call SetString() first") ); // VZ: this function is IMHO not very useful, so it's probably not very // important if its implementation here is not as efficient as it // could be -- but OTOH like this we're sure to get the correct answer // in all modes - wxStringTokenizer tkz(wxString(m_pos, m_stringEnd), m_delims, m_mode); + wxStringTokenizer tkz(m_string.c_str() + m_pos, m_delims, m_mode); size_t count = 0; while ( tkz.HasMoreTokens() ) @@ -236,39 +173,36 @@ wxString wxStringTokenizer::GetNextToken() break; } - m_hasMoreTokens = MoreTokens_Unknown; - // find the end of this token - wxString::const_iterator pos = - find_first_of(m_delims, m_delimsLen, m_pos, m_stringEnd); + size_t pos = m_string.find_first_of(m_delims, m_pos); // and the start of the next one - if ( pos == m_stringEnd ) + if ( pos == wxString::npos ) { // no more delimiters, the token is everything till the end of // string - token.assign(m_pos, m_stringEnd); + token.assign(m_string, m_pos, wxString::npos); // skip the token - m_pos = m_stringEnd; + m_pos = m_string.length(); // it wasn't terminated - m_lastDelim = wxT('\0'); + m_lastDelim = _T('\0'); } else // we found a delimiter at pos { // in wxTOKEN_RET_DELIMS mode we return the delimiter character // with token, otherwise leave it out - wxString::const_iterator tokenEnd(pos); + size_t len = pos - m_pos; if ( m_mode == wxTOKEN_RET_DELIMS ) - ++tokenEnd; + len++; - token.assign(m_pos, tokenEnd); + token.assign(m_string, m_pos, len); // skip the token and the trailing delimiter m_pos = pos + 1; - m_lastDelim = (pos == m_stringEnd) ? wxT('\0') : (wxChar)*pos; + m_lastDelim = m_string[pos]; } } while ( !AllowEmpty() && token.empty() ); diff --git a/Source/3rd Party/wx/src/common/toplvcmn.cpp b/Source/3rd Party/wx/src/common/toplvcmn.cpp index ef693690c..304dd3ca7 100644 --- a/Source/3rd Party/wx/src/common/toplvcmn.cpp +++ b/Source/3rd Party/wx/src/common/toplvcmn.cpp @@ -3,6 +3,7 @@ // Purpose: common (for all platforms) wxTopLevelWindow functions // Author: Julian Smart, Vadim Zeitlin // Created: 01/02/97 +// Id: $Id: toplvcmn.cpp 53617 2008-05-17 12:56:18Z VZ $ // Copyright: (c) 1998 Robert Roebling and Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -54,6 +55,8 @@ wxTopLevelWindowBase::wxTopLevelWindowBase() { // Unlike windows, top level windows are created hidden by default. m_isShown = false; + m_winDefault = NULL; + m_winTmpDefault = NULL; } wxTopLevelWindowBase::~wxTopLevelWindowBase() @@ -64,34 +67,6 @@ wxTopLevelWindowBase::~wxTopLevelWindowBase() wxTopLevelWindows.DeleteObject(this); - // delete any our top level children which are still pending for deletion - // immediately: this could happen if a child (e.g. a temporary dialog - // created with this window as parent) was Destroy()'d) while this window - // was deleted directly (with delete, or maybe just because it was created - // on the stack) immediately afterwards and before the child TLW was really - // destroyed -- not destroying it now would leave it alive with a dangling - // parent pointer and result in a crash later - for ( wxObjectList::iterator i = wxPendingDelete.begin(); - i != wxPendingDelete.end(); - ) - { - wxWindow * const win = wxDynamicCast(*i, wxWindow); - if ( win && wxGetTopLevelParent(win->GetParent()) == this ) - { - wxPendingDelete.erase(i); - - delete win; - - // deleting it invalidated the list (and not only one node because - // it could have resulted in deletion of other objects to) - i = wxPendingDelete.begin(); - } - else - { - ++i; - } - } - if ( IsLastBeforeExit() ) { // no other (important) windows left, quit the app @@ -101,21 +76,17 @@ wxTopLevelWindowBase::~wxTopLevelWindowBase() bool wxTopLevelWindowBase::Destroy() { - // We can't delay the destruction if our parent is being already destroyed - // as we will be deleted anyhow during its destruction and the pointer - // stored in wxPendingDelete would become invalid, so just delete ourselves - // immediately in this case. - if ( wxWindow* parent = GetParent() ) - { - if ( parent->IsBeingDeleted() ) - return wxNonOwnedWindow::Destroy(); - } - // delayed destruction: the frame will be deleted during the next idle // loop iteration if ( !wxPendingDelete.Member(this) ) wxPendingDelete.Append(this); +#ifdef __WXMAC__ + // on mac we know that objects will always be deleted after this event + // has been handled, using Hide we avoid erratic redraws during window + // tear down + Hide(); +#else // !__WXMAC__ // normally we want to hide the window immediately so that it doesn't get // stuck on the screen while it's being destroyed, however we shouldn't // hide the last visible window as then we might not get any idle events @@ -127,7 +98,7 @@ bool wxTopLevelWindowBase::Destroy() i != end; ++i ) { - wxTopLevelWindow * const win = static_cast(*i); + wxTopLevelWindow * const win = wx_static_cast(wxTopLevelWindow *, *i); if ( win != this && win->IsShown() ) { // there remains at least one other visible TLW, we can hide this @@ -137,6 +108,7 @@ bool wxTopLevelWindowBase::Destroy() break; } } +#endif // __WXMAC__/!__WXMAC__ return true; } @@ -148,21 +120,13 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const if ( !wxTheApp || !wxTheApp->GetExitOnFrameDelete() ) return false; - // second, never terminate the application after closing a child TLW - // because this would close its parent unexpectedly -- notice that this - // check is not redundant with the loop below, as the parent might return - // false from its ShouldPreventAppExit() -- except if the child is being - // deleted as part of the parent destruction - if ( GetParent() && !GetParent()->IsBeingDeleted() ) - return false; - wxWindowList::const_iterator i; const wxWindowList::const_iterator end = wxTopLevelWindows.end(); // then decide whether we should exit at all for ( i = wxTopLevelWindows.begin(); i != end; ++i ) { - wxTopLevelWindow * const win = static_cast(*i); + wxTopLevelWindow * const win = wx_static_cast(wxTopLevelWindow *, *i); if ( win->ShouldPreventAppExit() ) { // there remains at least one important TLW, don't exit @@ -174,7 +138,7 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const for ( i = wxTopLevelWindows.begin(); i != end; ++i ) { // don't close twice the windows which are already marked for deletion - wxTopLevelWindow * const win = static_cast(*i); + wxTopLevelWindow * const win = wx_static_cast(wxTopLevelWindow *, *i); if ( !wxPendingDelete.Member(win) && !win->Close() ) { // one of the windows refused to close, don't exit @@ -196,12 +160,29 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const void wxTopLevelWindowBase::SetMinSize(const wxSize& minSize) { - SetSizeHints(minSize, GetMaxSize()); + SetSizeHints( minSize.x, minSize.y, GetMaxWidth(), GetMaxHeight() ); } void wxTopLevelWindowBase::SetMaxSize(const wxSize& maxSize) { - SetSizeHints(GetMinSize(), maxSize); + SetSizeHints( GetMinWidth(), GetMinHeight(), maxSize.x, maxSize.y ); +} + +// set the min/max size of the window +void wxTopLevelWindowBase::DoSetSizeHints(int minW, int minH, + int maxW, int maxH, + int WXUNUSED(incW), int WXUNUSED(incH)) +{ + // setting min width greater than max width leads to infinite loops under + // X11 and generally doesn't make any sense, so don't allow it + wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) && + (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH), + _T("min width/height must be less than max width/height!") ); + + m_minWidth = minW; + m_maxWidth = maxW; + m_minHeight = minH; + m_maxHeight = maxH; } void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) @@ -214,7 +195,7 @@ void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, in wxSize wxTopLevelWindowBase::GetDefaultSize() { wxSize size = wxGetClientDisplayRect().GetSize(); -#ifndef __WXOSX_IPHONE__ + // create proportionally bigger windows on small screens if ( size.x >= 1024 ) size.x = 400; @@ -230,7 +211,7 @@ wxSize wxTopLevelWindowBase::GetDefaultSize() size.y *= 2; size.y /= 3; } -#endif + return size; } @@ -238,10 +219,7 @@ void wxTopLevelWindowBase::DoCentre(int dir) { // on some platforms centering top level windows is impossible // because they are always maximized by guidelines or limitations - // - // and centering a maximized window doesn't make sense as its position - // can't change - if ( IsAlwaysMaximized() || IsMaximized() ) + if(IsAlwaysMaximized()) return; // we need the display rect anyhow so store it first: notice that we should @@ -263,19 +241,25 @@ void wxTopLevelWindowBase::DoCentre(int dir) // parent frame under Mac but could happen elsewhere too if the frame // was hidden/moved away for some reason), don't use it as otherwise // this window wouldn't be visible at all - if ( !rectParent.Intersects(rectDisplay) ) + if ( !rectDisplay.Contains(rectParent.GetTopLeft()) && + !rectParent.Contains(rectParent.GetBottomRight()) ) { - // just centre on screen then - rectParent = rectDisplay; + // this is enough to make IsEmpty() test below pass + rectParent.width = 0; } } - else + + if ( rectParent.IsEmpty() ) { - // we were explicitly asked to centre this window on the entire screen + // we were explicitely asked to centre this window on the entire screen // or if we have no parent anyhow and so can't centre on it rectParent = rectDisplay; } + // centering maximized window on screen is no-op + if((rectParent == rectDisplay) && IsMaximized()) + return; + if ( !(dir & wxBOTH) ) dir |= wxBOTH; // if neither is specified, center in both directions @@ -350,26 +334,6 @@ bool wxTopLevelWindowBase::IsAlwaysMaximized() const #endif } -// ---------------------------------------------------------------------------- -// icons -// ---------------------------------------------------------------------------- - -wxIcon wxTopLevelWindowBase::GetIcon() const -{ - return m_icons.IsEmpty() ? wxIcon() : m_icons.GetIcon( -1 ); -} - -void wxTopLevelWindowBase::SetIcon(const wxIcon& icon) -{ - // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't - // have any icon), but adding an invalid icon to wxIconBundle is not - wxIconBundle icons; - if ( icon.IsOk() ) - icons.AddIcon(icon); - - SetIcons(icons); -} - // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- @@ -378,14 +342,6 @@ void wxTopLevelWindowBase::SetIcon(const wxIcon& icon) // whole client area void wxTopLevelWindowBase::DoLayout() { - // We are called during the window destruction several times, e.g. as - // wxFrame tries to adjust to its tool/status bars disappearing. But - // actually doing the layout is pretty useless in this case as the window - // will disappear anyhow -- so just don't bother. - if ( IsBeingDeleted() ) - return; - - // if we're using constraints or sizers - do use them if ( GetAutoLayout() ) { @@ -394,7 +350,7 @@ void wxTopLevelWindowBase::DoLayout() else { // do we have _exactly_ one child? - wxWindow *child = NULL; + wxWindow *child = (wxWindow *)NULL; for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) @@ -462,3 +418,14 @@ void wxTopLevelWindowBase::RequestUserAttention(int WXUNUSED(flags)) // it's probably better than do nothing, isn't it? Raise(); } + +void wxTopLevelWindowBase::RemoveChild(wxWindowBase *child) +{ + if ( child == m_winDefault ) + m_winDefault = NULL; + + if ( child == m_winTmpDefault ) + m_winTmpDefault = NULL; + + wxWindow::RemoveChild(child); +} diff --git a/Source/3rd Party/wx/src/common/translation.cpp b/Source/3rd Party/wx/src/common/translation.cpp deleted file mode 100644 index b5b33de9f..000000000 --- a/Source/3rd Party/wx/src/common/translation.cpp +++ /dev/null @@ -1,2064 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/translation.cpp -// Purpose: Internationalization and localisation for wxWidgets -// Author: Vadim Zeitlin, Vaclav Slavik, -// Michael N. Filippov -// (2003/09/30 - PluralForms support) -// Created: 2010-04-23 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declaration -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_INTL - -#ifndef WX_PRECOMP - #include "wx/dynarray.h" - #include "wx/string.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/utils.h" - #include "wx/hashmap.h" - #include "wx/module.h" -#endif // WX_PRECOMP - -// standard headers -#include -#include - -#include "wx/arrstr.h" -#include "wx/dir.h" -#include "wx/file.h" -#include "wx/filename.h" -#include "wx/tokenzr.h" -#include "wx/fontmap.h" -#include "wx/stdpaths.h" -#include "wx/private/threadinfo.h" - -#ifdef __WINDOWS__ - #include "wx/dynlib.h" - #include "wx/scopedarray.h" - #include "wx/msw/wrapwin.h" - #include "wx/msw/missing.h" -#endif -#ifdef __WXOSX__ - #include "wx/osx/core/cfstring.h" - #include - #include -#endif - -// ---------------------------------------------------------------------------- -// simple types -// ---------------------------------------------------------------------------- - -typedef wxUint32 size_t32; - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// magic number identifying the .mo format file -const size_t32 MSGCATALOG_MAGIC = 0x950412de; -const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495; - -#define TRACE_I18N wxS("i18n") - -// ============================================================================ -// implementation -// ============================================================================ - -namespace -{ - -#if !wxUSE_UNICODE -// We need to keep track of (char*) msgids in non-Unicode legacy builds. Instead -// of making the public wxMsgCatalog and wxTranslationsLoader APIs ugly, we -// store them in this global map. -wxStringToStringHashMap gs_msgIdCharset; -#endif - -// ---------------------------------------------------------------------------- -// Platform specific helpers -// ---------------------------------------------------------------------------- - -#if wxUSE_LOG_TRACE - -void LogTraceArray(const char *prefix, const wxArrayString& arr) -{ - wxLogTrace(TRACE_I18N, "%s: [%s]", prefix, wxJoin(arr, ',')); -} - -void LogTraceLargeArray(const wxString& prefix, const wxArrayString& arr) -{ - wxLogTrace(TRACE_I18N, "%s:", prefix); - for ( wxArrayString::const_iterator i = arr.begin(); i != arr.end(); ++i ) - wxLogTrace(TRACE_I18N, " %s", *i); -} - -#else // !wxUSE_LOG_TRACE - -#define LogTraceArray(prefix, arr) -#define LogTraceLargeArray(prefix, arr) - -#endif // wxUSE_LOG_TRACE/!wxUSE_LOG_TRACE - -// Use locale-based detection as a fallback -wxString GetPreferredUILanguageFallback(const wxArrayString& WXUNUSED(available)) -{ - const wxString lang = wxLocale::GetLanguageCanonicalName(wxLocale::GetSystemLanguage()); - wxLogTrace(TRACE_I18N, " - obtained best language from locale: %s", lang); - return lang; -} - -#ifdef __WINDOWS__ - -wxString GetPreferredUILanguage(const wxArrayString& available) -{ - typedef BOOL (WINAPI *GetUserPreferredUILanguages_t)(DWORD, PULONG, PWSTR, PULONG); - static GetUserPreferredUILanguages_t s_pfnGetUserPreferredUILanguages = NULL; - static bool s_initDone = false; - if ( !s_initDone ) - { - wxLoadedDLL dllKernel32("kernel32.dll"); - wxDL_INIT_FUNC(s_pfn, GetUserPreferredUILanguages, dllKernel32); - s_initDone = true; - } - - if ( s_pfnGetUserPreferredUILanguages ) - { - ULONG numLangs; - ULONG bufferSize = 0; - if ( (*s_pfnGetUserPreferredUILanguages)(MUI_LANGUAGE_NAME, - &numLangs, - NULL, - &bufferSize) ) - { - wxScopedArray langs(new WCHAR[bufferSize]); - if ( (*s_pfnGetUserPreferredUILanguages)(MUI_LANGUAGE_NAME, - &numLangs, - langs.get(), - &bufferSize) ) - { - wxArrayString preferred; - - WCHAR *buf = langs.get(); - for ( unsigned i = 0; i < numLangs; i++ ) - { - const wxString lang(buf); - preferred.push_back(lang); - buf += lang.length() + 1; - } - LogTraceArray(" - system preferred languages", preferred); - - for ( wxArrayString::const_iterator j = preferred.begin(); - j != preferred.end(); - ++j ) - { - wxString lang(*j); - lang.Replace("-", "_"); - if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; - size_t pos = lang.find('_'); - if ( pos != wxString::npos ) - { - lang = lang.substr(0, pos); - if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; - } - } - } - } - } - - return GetPreferredUILanguageFallback(available); -} - -#elif defined(__WXOSX__) - -#if wxUSE_LOG_TRACE - -void LogTraceArray(const char *prefix, CFArrayRef arr) -{ - wxString s; - const unsigned count = CFArrayGetCount(arr); - if ( count ) - { - s += wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(arr, 0)); - for ( unsigned i = 1 ; i < count; i++ ) - s += "," + wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(arr, i)); - } - wxLogTrace(TRACE_I18N, "%s: [%s]", prefix, s); -} - -#endif // wxUSE_LOG_TRACE - -wxString GetPreferredUILanguage(const wxArrayString& available) -{ - wxStringToStringHashMap availableNormalized; - wxCFRef availableArr( - CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); - - for ( wxArrayString::const_iterator i = available.begin(); - i != available.end(); - ++i ) - { - wxString lang(*i); - wxCFStringRef code_wx(*i); - wxCFStringRef code_norm( - CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorDefault, code_wx)); - CFArrayAppendValue(availableArr, code_norm); - availableNormalized[code_norm.AsString()] = *i; - } - LogTraceArray(" - normalized available list", availableArr); - - wxCFRef prefArr( - CFBundleCopyLocalizationsForPreferences(availableArr, NULL)); - LogTraceArray(" - system preferred languages", prefArr); - - unsigned prefArrLength = CFArrayGetCount(prefArr); - if ( prefArrLength > 0 ) - { - // Lookup the name in 'available' by index -- we need to get the - // original value corresponding to the normalized one chosen. - wxString lang(wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(prefArr, 0))); - wxStringToStringHashMap::const_iterator i = availableNormalized.find(lang); - if ( i == availableNormalized.end() ) - return lang; - else - return i->second; - } - - return GetPreferredUILanguageFallback(available); -} - -#else - -// On Unix, there's just one language=locale setting, so we should always -// use that. -#define GetPreferredUILanguage GetPreferredUILanguageFallback - -#endif - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// Plural forms parser -// ---------------------------------------------------------------------------- - -/* - Simplified Grammar - -Expression: - LogicalOrExpression '?' Expression ':' Expression - LogicalOrExpression - -LogicalOrExpression: - LogicalAndExpression "||" LogicalOrExpression // to (a || b) || c - LogicalAndExpression - -LogicalAndExpression: - EqualityExpression "&&" LogicalAndExpression // to (a && b) && c - EqualityExpression - -EqualityExpression: - RelationalExpression "==" RelationalExperession - RelationalExpression "!=" RelationalExperession - RelationalExpression - -RelationalExpression: - MultiplicativeExpression '>' MultiplicativeExpression - MultiplicativeExpression '<' MultiplicativeExpression - MultiplicativeExpression ">=" MultiplicativeExpression - MultiplicativeExpression "<=" MultiplicativeExpression - MultiplicativeExpression - -MultiplicativeExpression: - PmExpression '%' PmExpression - PmExpression - -PmExpression: - N - Number - '(' Expression ')' -*/ - -class wxPluralFormsToken -{ -public: - enum Type - { - T_ERROR, T_EOF, T_NUMBER, T_N, T_PLURAL, T_NPLURALS, T_EQUAL, T_ASSIGN, - T_GREATER, T_GREATER_OR_EQUAL, T_LESS, T_LESS_OR_EQUAL, - T_REMINDER, T_NOT_EQUAL, - T_LOGICAL_AND, T_LOGICAL_OR, T_QUESTION, T_COLON, T_SEMICOLON, - T_LEFT_BRACKET, T_RIGHT_BRACKET - }; - Type type() const { return m_type; } - void setType(Type t) { m_type = t; } - // for T_NUMBER only - typedef int Number; - Number number() const { return m_number; } - void setNumber(Number num) { m_number = num; } -private: - Type m_type; - Number m_number; -}; - - -class wxPluralFormsScanner -{ -public: - wxPluralFormsScanner(const char* s); - const wxPluralFormsToken& token() const { return m_token; } - bool nextToken(); // returns false if error -private: - const char* m_s; - wxPluralFormsToken m_token; -}; - -wxPluralFormsScanner::wxPluralFormsScanner(const char* s) : m_s(s) -{ - nextToken(); -} - -bool wxPluralFormsScanner::nextToken() -{ - wxPluralFormsToken::Type type = wxPluralFormsToken::T_ERROR; - while (isspace((unsigned char) *m_s)) - { - ++m_s; - } - if (*m_s == 0) - { - type = wxPluralFormsToken::T_EOF; - } - else if (isdigit((unsigned char) *m_s)) - { - wxPluralFormsToken::Number number = *m_s++ - '0'; - while (isdigit((unsigned char) *m_s)) - { - number = number * 10 + (*m_s++ - '0'); - } - m_token.setNumber(number); - type = wxPluralFormsToken::T_NUMBER; - } - else if (isalpha((unsigned char) *m_s)) - { - const char* begin = m_s++; - while (isalnum((unsigned char) *m_s)) - { - ++m_s; - } - size_t size = m_s - begin; - if (size == 1 && memcmp(begin, "n", size) == 0) - { - type = wxPluralFormsToken::T_N; - } - else if (size == 6 && memcmp(begin, "plural", size) == 0) - { - type = wxPluralFormsToken::T_PLURAL; - } - else if (size == 8 && memcmp(begin, "nplurals", size) == 0) - { - type = wxPluralFormsToken::T_NPLURALS; - } - } - else if (*m_s == '=') - { - ++m_s; - if (*m_s == '=') - { - ++m_s; - type = wxPluralFormsToken::T_EQUAL; - } - else - { - type = wxPluralFormsToken::T_ASSIGN; - } - } - else if (*m_s == '>') - { - ++m_s; - if (*m_s == '=') - { - ++m_s; - type = wxPluralFormsToken::T_GREATER_OR_EQUAL; - } - else - { - type = wxPluralFormsToken::T_GREATER; - } - } - else if (*m_s == '<') - { - ++m_s; - if (*m_s == '=') - { - ++m_s; - type = wxPluralFormsToken::T_LESS_OR_EQUAL; - } - else - { - type = wxPluralFormsToken::T_LESS; - } - } - else if (*m_s == '%') - { - ++m_s; - type = wxPluralFormsToken::T_REMINDER; - } - else if (*m_s == '!' && m_s[1] == '=') - { - m_s += 2; - type = wxPluralFormsToken::T_NOT_EQUAL; - } - else if (*m_s == '&' && m_s[1] == '&') - { - m_s += 2; - type = wxPluralFormsToken::T_LOGICAL_AND; - } - else if (*m_s == '|' && m_s[1] == '|') - { - m_s += 2; - type = wxPluralFormsToken::T_LOGICAL_OR; - } - else if (*m_s == '?') - { - ++m_s; - type = wxPluralFormsToken::T_QUESTION; - } - else if (*m_s == ':') - { - ++m_s; - type = wxPluralFormsToken::T_COLON; - } else if (*m_s == ';') { - ++m_s; - type = wxPluralFormsToken::T_SEMICOLON; - } - else if (*m_s == '(') - { - ++m_s; - type = wxPluralFormsToken::T_LEFT_BRACKET; - } - else if (*m_s == ')') - { - ++m_s; - type = wxPluralFormsToken::T_RIGHT_BRACKET; - } - m_token.setType(type); - return type != wxPluralFormsToken::T_ERROR; -} - -class wxPluralFormsNode; - -// NB: Can't use wxDEFINE_SCOPED_PTR_TYPE because wxPluralFormsNode is not -// fully defined yet: -class wxPluralFormsNodePtr -{ -public: - wxPluralFormsNodePtr(wxPluralFormsNode *p = NULL) : m_p(p) {} - ~wxPluralFormsNodePtr(); - wxPluralFormsNode& operator*() const { return *m_p; } - wxPluralFormsNode* operator->() const { return m_p; } - wxPluralFormsNode* get() const { return m_p; } - wxPluralFormsNode* release(); - void reset(wxPluralFormsNode *p); - -private: - wxPluralFormsNode *m_p; -}; - -class wxPluralFormsNode -{ -public: - wxPluralFormsNode(const wxPluralFormsToken& t) : m_token(t) {} - const wxPluralFormsToken& token() const { return m_token; } - const wxPluralFormsNode* node(unsigned i) const - { return m_nodes[i].get(); } - void setNode(unsigned i, wxPluralFormsNode* n); - wxPluralFormsNode* releaseNode(unsigned i); - wxPluralFormsToken::Number evaluate(wxPluralFormsToken::Number n) const; - -private: - wxPluralFormsToken m_token; - wxPluralFormsNodePtr m_nodes[3]; -}; - -wxPluralFormsNodePtr::~wxPluralFormsNodePtr() -{ - delete m_p; -} -wxPluralFormsNode* wxPluralFormsNodePtr::release() -{ - wxPluralFormsNode *p = m_p; - m_p = NULL; - return p; -} -void wxPluralFormsNodePtr::reset(wxPluralFormsNode *p) -{ - if (p != m_p) - { - delete m_p; - m_p = p; - } -} - - -void wxPluralFormsNode::setNode(unsigned i, wxPluralFormsNode* n) -{ - m_nodes[i].reset(n); -} - -wxPluralFormsNode* wxPluralFormsNode::releaseNode(unsigned i) -{ - return m_nodes[i].release(); -} - -wxPluralFormsToken::Number -wxPluralFormsNode::evaluate(wxPluralFormsToken::Number n) const -{ - switch (token().type()) - { - // leaf - case wxPluralFormsToken::T_NUMBER: - return token().number(); - case wxPluralFormsToken::T_N: - return n; - // 2 args - case wxPluralFormsToken::T_EQUAL: - return node(0)->evaluate(n) == node(1)->evaluate(n); - case wxPluralFormsToken::T_NOT_EQUAL: - return node(0)->evaluate(n) != node(1)->evaluate(n); - case wxPluralFormsToken::T_GREATER: - return node(0)->evaluate(n) > node(1)->evaluate(n); - case wxPluralFormsToken::T_GREATER_OR_EQUAL: - return node(0)->evaluate(n) >= node(1)->evaluate(n); - case wxPluralFormsToken::T_LESS: - return node(0)->evaluate(n) < node(1)->evaluate(n); - case wxPluralFormsToken::T_LESS_OR_EQUAL: - return node(0)->evaluate(n) <= node(1)->evaluate(n); - case wxPluralFormsToken::T_REMINDER: - { - wxPluralFormsToken::Number number = node(1)->evaluate(n); - if (number != 0) - { - return node(0)->evaluate(n) % number; - } - else - { - return 0; - } - } - case wxPluralFormsToken::T_LOGICAL_AND: - return node(0)->evaluate(n) && node(1)->evaluate(n); - case wxPluralFormsToken::T_LOGICAL_OR: - return node(0)->evaluate(n) || node(1)->evaluate(n); - // 3 args - case wxPluralFormsToken::T_QUESTION: - return node(0)->evaluate(n) - ? node(1)->evaluate(n) - : node(2)->evaluate(n); - default: - return 0; - } -} - - -class wxPluralFormsCalculator -{ -public: - wxPluralFormsCalculator() : m_nplurals(0), m_plural(0) {} - - // input: number, returns msgstr index - int evaluate(int n) const; - - // input: text after "Plural-Forms:" (e.g. "nplurals=2; plural=(n != 1);"), - // if s == 0, creates default handler - // returns 0 if error - static wxPluralFormsCalculator* make(const char* s = 0); - - ~wxPluralFormsCalculator() {} - - void init(wxPluralFormsToken::Number nplurals, wxPluralFormsNode* plural); - -private: - wxPluralFormsToken::Number m_nplurals; - wxPluralFormsNodePtr m_plural; -}; - -wxDEFINE_SCOPED_PTR(wxPluralFormsCalculator, wxPluralFormsCalculatorPtr) - -void wxPluralFormsCalculator::init(wxPluralFormsToken::Number nplurals, - wxPluralFormsNode* plural) -{ - m_nplurals = nplurals; - m_plural.reset(plural); -} - -int wxPluralFormsCalculator::evaluate(int n) const -{ - if (m_plural.get() == 0) - { - return 0; - } - wxPluralFormsToken::Number number = m_plural->evaluate(n); - if (number < 0 || number > m_nplurals) - { - return 0; - } - return number; -} - - -class wxPluralFormsParser -{ -public: - wxPluralFormsParser(wxPluralFormsScanner& scanner) : m_scanner(scanner) {} - bool parse(wxPluralFormsCalculator& rCalculator); - -private: - wxPluralFormsNode* parsePlural(); - // stops at T_SEMICOLON, returns 0 if error - wxPluralFormsScanner& m_scanner; - const wxPluralFormsToken& token() const; - bool nextToken(); - - wxPluralFormsNode* expression(); - wxPluralFormsNode* logicalOrExpression(); - wxPluralFormsNode* logicalAndExpression(); - wxPluralFormsNode* equalityExpression(); - wxPluralFormsNode* multiplicativeExpression(); - wxPluralFormsNode* relationalExpression(); - wxPluralFormsNode* pmExpression(); -}; - -bool wxPluralFormsParser::parse(wxPluralFormsCalculator& rCalculator) -{ - if (token().type() != wxPluralFormsToken::T_NPLURALS) - return false; - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_ASSIGN) - return false; - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_NUMBER) - return false; - wxPluralFormsToken::Number nplurals = token().number(); - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_SEMICOLON) - return false; - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_PLURAL) - return false; - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_ASSIGN) - return false; - if (!nextToken()) - return false; - wxPluralFormsNode* plural = parsePlural(); - if (plural == 0) - return false; - if (token().type() != wxPluralFormsToken::T_SEMICOLON) - return false; - if (!nextToken()) - return false; - if (token().type() != wxPluralFormsToken::T_EOF) - return false; - rCalculator.init(nplurals, plural); - return true; -} - -wxPluralFormsNode* wxPluralFormsParser::parsePlural() -{ - wxPluralFormsNode* p = expression(); - if (p == NULL) - { - return NULL; - } - wxPluralFormsNodePtr n(p); - if (token().type() != wxPluralFormsToken::T_SEMICOLON) - { - return NULL; - } - return n.release(); -} - -const wxPluralFormsToken& wxPluralFormsParser::token() const -{ - return m_scanner.token(); -} - -bool wxPluralFormsParser::nextToken() -{ - if (!m_scanner.nextToken()) - return false; - return true; -} - -wxPluralFormsNode* wxPluralFormsParser::expression() -{ - wxPluralFormsNode* p = logicalOrExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr n(p); - if (token().type() == wxPluralFormsToken::T_QUESTION) - { - wxPluralFormsNodePtr qn(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return 0; - } - p = expression(); - if (p == 0) - { - return 0; - } - qn->setNode(1, p); - if (token().type() != wxPluralFormsToken::T_COLON) - { - return 0; - } - if (!nextToken()) - { - return 0; - } - p = expression(); - if (p == 0) - { - return 0; - } - qn->setNode(2, p); - qn->setNode(0, n.release()); - return qn.release(); - } - return n.release(); -} - -wxPluralFormsNode*wxPluralFormsParser::logicalOrExpression() -{ - wxPluralFormsNode* p = logicalAndExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr ln(p); - if (token().type() == wxPluralFormsToken::T_LOGICAL_OR) - { - wxPluralFormsNodePtr un(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return 0; - } - p = logicalOrExpression(); - if (p == 0) - { - return 0; - } - wxPluralFormsNodePtr rn(p); // right - if (rn->token().type() == wxPluralFormsToken::T_LOGICAL_OR) - { - // see logicalAndExpression comment - un->setNode(0, ln.release()); - un->setNode(1, rn->releaseNode(0)); - rn->setNode(0, un.release()); - return rn.release(); - } - - - un->setNode(0, ln.release()); - un->setNode(1, rn.release()); - return un.release(); - } - return ln.release(); -} - -wxPluralFormsNode* wxPluralFormsParser::logicalAndExpression() -{ - wxPluralFormsNode* p = equalityExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr ln(p); // left - if (token().type() == wxPluralFormsToken::T_LOGICAL_AND) - { - wxPluralFormsNodePtr un(new wxPluralFormsNode(token())); // up - if (!nextToken()) - { - return NULL; - } - p = logicalAndExpression(); - if (p == 0) - { - return NULL; - } - wxPluralFormsNodePtr rn(p); // right - if (rn->token().type() == wxPluralFormsToken::T_LOGICAL_AND) - { -// transform 1 && (2 && 3) -> (1 && 2) && 3 -// u r -// l r -> u 3 -// 2 3 l 2 - un->setNode(0, ln.release()); - un->setNode(1, rn->releaseNode(0)); - rn->setNode(0, un.release()); - return rn.release(); - } - - un->setNode(0, ln.release()); - un->setNode(1, rn.release()); - return un.release(); - } - return ln.release(); -} - -wxPluralFormsNode* wxPluralFormsParser::equalityExpression() -{ - wxPluralFormsNode* p = relationalExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr n(p); - if (token().type() == wxPluralFormsToken::T_EQUAL - || token().type() == wxPluralFormsToken::T_NOT_EQUAL) - { - wxPluralFormsNodePtr qn(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return NULL; - } - p = relationalExpression(); - if (p == NULL) - { - return NULL; - } - qn->setNode(1, p); - qn->setNode(0, n.release()); - return qn.release(); - } - return n.release(); -} - -wxPluralFormsNode* wxPluralFormsParser::relationalExpression() -{ - wxPluralFormsNode* p = multiplicativeExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr n(p); - if (token().type() == wxPluralFormsToken::T_GREATER - || token().type() == wxPluralFormsToken::T_LESS - || token().type() == wxPluralFormsToken::T_GREATER_OR_EQUAL - || token().type() == wxPluralFormsToken::T_LESS_OR_EQUAL) - { - wxPluralFormsNodePtr qn(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return NULL; - } - p = multiplicativeExpression(); - if (p == NULL) - { - return NULL; - } - qn->setNode(1, p); - qn->setNode(0, n.release()); - return qn.release(); - } - return n.release(); -} - -wxPluralFormsNode* wxPluralFormsParser::multiplicativeExpression() -{ - wxPluralFormsNode* p = pmExpression(); - if (p == NULL) - return NULL; - wxPluralFormsNodePtr n(p); - if (token().type() == wxPluralFormsToken::T_REMINDER) - { - wxPluralFormsNodePtr qn(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return NULL; - } - p = pmExpression(); - if (p == NULL) - { - return NULL; - } - qn->setNode(1, p); - qn->setNode(0, n.release()); - return qn.release(); - } - return n.release(); -} - -wxPluralFormsNode* wxPluralFormsParser::pmExpression() -{ - wxPluralFormsNodePtr n; - if (token().type() == wxPluralFormsToken::T_N - || token().type() == wxPluralFormsToken::T_NUMBER) - { - n.reset(new wxPluralFormsNode(token())); - if (!nextToken()) - { - return NULL; - } - } - else if (token().type() == wxPluralFormsToken::T_LEFT_BRACKET) { - if (!nextToken()) - { - return NULL; - } - wxPluralFormsNode* p = expression(); - if (p == NULL) - { - return NULL; - } - n.reset(p); - if (token().type() != wxPluralFormsToken::T_RIGHT_BRACKET) - { - return NULL; - } - if (!nextToken()) - { - return NULL; - } - } - else - { - return NULL; - } - return n.release(); -} - -wxPluralFormsCalculator* wxPluralFormsCalculator::make(const char* s) -{ - wxPluralFormsCalculatorPtr calculator(new wxPluralFormsCalculator); - if (s != NULL) - { - wxPluralFormsScanner scanner(s); - wxPluralFormsParser p(scanner); - if (!p.parse(*calculator)) - { - return NULL; - } - } - return calculator.release(); -} - - - - -// ---------------------------------------------------------------------------- -// wxMsgCatalogFile corresponds to one disk-file message catalog. -// -// This is a "low-level" class and is used only by wxMsgCatalog -// NOTE: for the documentation of the binary catalog (.MO) files refer to -// the GNU gettext manual: -// http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html -// ---------------------------------------------------------------------------- - -class wxMsgCatalogFile -{ -public: - typedef wxScopedCharBuffer DataBuffer; - - // ctor & dtor - wxMsgCatalogFile(); - ~wxMsgCatalogFile(); - - // load the catalog from disk - bool LoadFile(const wxString& filename, - wxPluralFormsCalculatorPtr& rPluralFormsCalculator); - bool LoadData(const DataBuffer& data, - wxPluralFormsCalculatorPtr& rPluralFormsCalculator); - - // fills the hash with string-translation pairs - bool FillHash(wxStringToStringHashMap& hash, const wxString& domain) const; - - // return the charset of the strings in this catalog or empty string if - // none/unknown - wxString GetCharset() const { return m_charset; } - -private: - // this implementation is binary compatible with GNU gettext() version 0.10 - - // an entry in the string table - struct wxMsgTableEntry - { - size_t32 nLen; // length of the string - size_t32 ofsString; // pointer to the string - }; - - // header of a .mo file - struct wxMsgCatalogHeader - { - size_t32 magic, // offset +00: magic id - revision, // +04: revision - numStrings; // +08: number of strings in the file - size_t32 ofsOrigTable, // +0C: start of original string table - ofsTransTable; // +10: start of translated string table - size_t32 nHashSize, // +14: hash table size - ofsHashTable; // +18: offset of hash table start - }; - - // all data is stored here - DataBuffer m_data; - - // data description - size_t32 m_numStrings; // number of strings in this domain - wxMsgTableEntry *m_pOrigTable, // pointer to original strings - *m_pTransTable; // translated - - wxString m_charset; // from the message catalog header - - - // swap the 2 halves of 32 bit integer if needed - size_t32 Swap(size_t32 ui) const - { - return m_bSwapped ? (ui << 24) | ((ui & 0xff00) << 8) | - ((ui >> 8) & 0xff00) | (ui >> 24) - : ui; - } - - const char *StringAtOfs(wxMsgTableEntry *pTable, size_t32 n) const - { - const wxMsgTableEntry * const ent = pTable + n; - - // this check could fail for a corrupt message catalog - size_t32 ofsString = Swap(ent->ofsString); - if ( ofsString + Swap(ent->nLen) > m_data.length()) - { - return NULL; - } - - return m_data.data() + ofsString; - } - - bool m_bSwapped; // wrong endianness? - - wxDECLARE_NO_COPY_CLASS(wxMsgCatalogFile); -}; - -// ---------------------------------------------------------------------------- -// wxMsgCatalogFile class -// ---------------------------------------------------------------------------- - -wxMsgCatalogFile::wxMsgCatalogFile() -{ -} - -wxMsgCatalogFile::~wxMsgCatalogFile() -{ -} - -// open disk file and read in it's contents -bool wxMsgCatalogFile::LoadFile(const wxString& filename, - wxPluralFormsCalculatorPtr& rPluralFormsCalculator) -{ - wxFile fileMsg(filename); - if ( !fileMsg.IsOpened() ) - return false; - - // get the file size (assume it is less than 4GB...) - wxFileOffset lenFile = fileMsg.Length(); - if ( lenFile == wxInvalidOffset ) - return false; - - size_t nSize = wx_truncate_cast(size_t, lenFile); - wxASSERT_MSG( nSize == lenFile + size_t(0), wxS("message catalog bigger than 4GB?") ); - - wxMemoryBuffer filedata; - - // read the whole file in memory - if ( fileMsg.Read(filedata.GetWriteBuf(nSize), nSize) != lenFile ) - return false; - - filedata.UngetWriteBuf(nSize); - - bool ok = LoadData - ( - DataBuffer::CreateOwned((char*)filedata.release(), nSize), - rPluralFormsCalculator - ); - if ( !ok ) - { - wxLogWarning(_("'%s' is not a valid message catalog."), filename.c_str()); - return false; - } - - return true; -} - - -bool wxMsgCatalogFile::LoadData(const DataBuffer& data, - wxPluralFormsCalculatorPtr& rPluralFormsCalculator) -{ - // examine header - bool bValid = data.length() > sizeof(wxMsgCatalogHeader); - - const wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)data.data(); - if ( bValid ) { - // we'll have to swap all the integers if it's true - m_bSwapped = pHeader->magic == MSGCATALOG_MAGIC_SW; - - // check the magic number - bValid = m_bSwapped || pHeader->magic == MSGCATALOG_MAGIC; - } - - if ( !bValid ) { - // it's either too short or has incorrect magic number - wxLogWarning(_("Invalid message catalog.")); - return false; - } - - m_data = data; - - // initialize - m_numStrings = Swap(pHeader->numStrings); - m_pOrigTable = (wxMsgTableEntry *)(data.data() + - Swap(pHeader->ofsOrigTable)); - m_pTransTable = (wxMsgTableEntry *)(data.data() + - Swap(pHeader->ofsTransTable)); - - // now parse catalog's header and try to extract catalog charset and - // plural forms formula from it: - - const char* headerData = StringAtOfs(m_pOrigTable, 0); - if ( headerData && headerData[0] == '\0' ) - { - // Extract the charset: - const char * const header = StringAtOfs(m_pTransTable, 0); - const char * - cset = strstr(header, "Content-Type: text/plain; charset="); - if ( cset ) - { - cset += 34; // strlen("Content-Type: text/plain; charset=") - - const char * const csetEnd = strchr(cset, '\n'); - if ( csetEnd ) - { - m_charset = wxString(cset, csetEnd - cset); - if ( m_charset == wxS("CHARSET") ) - { - // "CHARSET" is not valid charset, but lazy translator - m_charset.clear(); - } - } - } - // else: incorrectly filled Content-Type header - - // Extract plural forms: - const char * plurals = strstr(header, "Plural-Forms:"); - if ( plurals ) - { - plurals += 13; // strlen("Plural-Forms:") - const char * const pluralsEnd = strchr(plurals, '\n'); - if ( pluralsEnd ) - { - const size_t pluralsLen = pluralsEnd - plurals; - wxCharBuffer buf(pluralsLen); - strncpy(buf.data(), plurals, pluralsLen); - wxPluralFormsCalculator * const - pCalculator = wxPluralFormsCalculator::make(buf); - if ( pCalculator ) - { - rPluralFormsCalculator.reset(pCalculator); - } - else - { - wxLogVerbose(_("Failed to parse Plural-Forms: '%s'"), - buf.data()); - } - } - } - - if ( !rPluralFormsCalculator.get() ) - rPluralFormsCalculator.reset(wxPluralFormsCalculator::make()); - } - - // everything is fine - return true; -} - -bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, - const wxString& domain) const -{ - wxUnusedVar(domain); // silence warning in Unicode build - - // conversion to use to convert catalog strings to the GUI encoding - wxMBConv *inputConv = NULL; - wxMBConv *inputConvPtr = NULL; // same as inputConv but safely deleteable - - if ( !m_charset.empty() ) - { -#if !wxUSE_UNICODE && wxUSE_FONTMAP - // determine if we need any conversion at all - wxFontEncoding encCat = wxFontMapperBase::GetEncodingFromName(m_charset); - if ( encCat != wxLocale::GetSystemEncoding() ) -#endif - { - inputConvPtr = - inputConv = new wxCSConv(m_charset); - } - } - else // no need or not possible to convert the encoding - { -#if wxUSE_UNICODE - // we must somehow convert the narrow strings in the message catalog to - // wide strings, so use the default conversion if we have no charset - inputConv = wxConvCurrent; -#endif - } - -#if !wxUSE_UNICODE - wxString msgIdCharset = gs_msgIdCharset[domain]; - - // conversion to apply to msgid strings before looking them up: we only - // need it if the msgids are neither in 7 bit ASCII nor in the same - // encoding as the catalog - wxCSConv *sourceConv = msgIdCharset.empty() || (msgIdCharset == m_charset) - ? NULL - : new wxCSConv(msgIdCharset); -#endif // !wxUSE_UNICODE - - for (size_t32 i = 0; i < m_numStrings; i++) - { - const char *data = StringAtOfs(m_pOrigTable, i); - if (!data) - return false; // may happen for invalid MO files - - wxString msgid; -#if wxUSE_UNICODE - msgid = wxString(data, *inputConv); -#else // ASCII - if ( inputConv && sourceConv ) - msgid = wxString(inputConv->cMB2WC(data), *sourceConv); - else - msgid = data; -#endif // wxUSE_UNICODE - - data = StringAtOfs(m_pTransTable, i); - if (!data) - return false; // may happen for invalid MO files - - size_t length = Swap(m_pTransTable[i].nLen); - size_t offset = 0; - size_t index = 0; - while (offset < length) - { - const char * const str = data + offset; - - wxString msgstr; -#if wxUSE_UNICODE - msgstr = wxString(str, *inputConv); -#else - if ( inputConv ) - msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI); - else - msgstr = str; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE - - if ( !msgstr.empty() ) - { - hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr; - } - - // skip this string - // IMPORTANT: accesses to the 'data' pointer are valid only for - // the first 'length+1' bytes (GNU specs says that the - // final NUL is not counted in length); using wxStrnlen() - // we make sure we don't access memory beyond the valid range - // (which otherwise may happen for invalid MO files): - offset += wxStrnlen(str, length - offset) + 1; - ++index; - } - } - -#if !wxUSE_UNICODE - delete sourceConv; -#endif - delete inputConvPtr; - - return true; -} - - -// ---------------------------------------------------------------------------- -// wxMsgCatalog class -// ---------------------------------------------------------------------------- - -#if !wxUSE_UNICODE -wxMsgCatalog::~wxMsgCatalog() -{ - if ( m_conv ) - { - if ( wxConvUI == m_conv ) - { - // we only change wxConvUI if it points to wxConvLocal so we reset - // it back to it too - wxConvUI = &wxConvLocal; - } - - delete m_conv; - } -} -#endif // !wxUSE_UNICODE - -/* static */ -wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename, - const wxString& domain) -{ - wxScopedPtr cat(new wxMsgCatalog(domain)); - - wxMsgCatalogFile file; - - if ( !file.LoadFile(filename, cat->m_pluralFormsCalculator) ) - return NULL; - - if ( !file.FillHash(cat->m_messages, domain) ) - return NULL; - - return cat.release(); -} - -/* static */ -wxMsgCatalog *wxMsgCatalog::CreateFromData(const wxScopedCharBuffer& data, - const wxString& domain) -{ - wxScopedPtr cat(new wxMsgCatalog(domain)); - - wxMsgCatalogFile file; - - if ( !file.LoadData(data, cat->m_pluralFormsCalculator) ) - return NULL; - - if ( !file.FillHash(cat->m_messages, domain) ) - return NULL; - - return cat.release(); -} - -const wxString *wxMsgCatalog::GetString(const wxString& str, unsigned n) const -{ - int index = 0; - if (n != UINT_MAX) - { - index = m_pluralFormsCalculator->evaluate(n); - } - wxStringToStringHashMap::const_iterator i; - if (index != 0) - { - i = m_messages.find(wxString(str) + wxChar(index)); // plural - } - else - { - i = m_messages.find(str); - } - - if ( i != m_messages.end() ) - { - return &i->second; - } - else - return NULL; -} - - -// ---------------------------------------------------------------------------- -// wxTranslations -// ---------------------------------------------------------------------------- - -namespace -{ - -wxTranslations *gs_translations = NULL; -bool gs_translationsOwned = false; - -} // anonymous namespace - - -/*static*/ -wxTranslations *wxTranslations::Get() -{ - return gs_translations; -} - -/*static*/ -void wxTranslations::Set(wxTranslations *t) -{ - if ( gs_translationsOwned ) - delete gs_translations; - gs_translations = t; - gs_translationsOwned = true; -} - -/*static*/ -void wxTranslations::SetNonOwned(wxTranslations *t) -{ - if ( gs_translationsOwned ) - delete gs_translations; - gs_translations = t; - gs_translationsOwned = false; -} - - -wxTranslations::wxTranslations() -{ - m_pMsgCat = NULL; - m_loader = new wxFileTranslationsLoader; -} - - -wxTranslations::~wxTranslations() -{ - delete m_loader; - - // free catalogs memory - wxMsgCatalog *pTmpCat; - while ( m_pMsgCat != NULL ) - { - pTmpCat = m_pMsgCat; - m_pMsgCat = m_pMsgCat->m_pNext; - delete pTmpCat; - } -} - - -void wxTranslations::SetLoader(wxTranslationsLoader *loader) -{ - wxCHECK_RET( loader, "loader can't be NULL" ); - - delete m_loader; - m_loader = loader; -} - - -void wxTranslations::SetLanguage(wxLanguage lang) -{ - if ( lang == wxLANGUAGE_DEFAULT ) - SetLanguage(""); - else - SetLanguage(wxLocale::GetLanguageCanonicalName(lang)); -} - -void wxTranslations::SetLanguage(const wxString& lang) -{ - m_lang = lang; -} - - -wxArrayString wxTranslations::GetAvailableTranslations(const wxString& domain) const -{ - wxCHECK_MSG( m_loader, wxArrayString(), "loader can't be NULL" ); - - return m_loader->GetAvailableTranslations(domain); -} - - -bool wxTranslations::AddStdCatalog() -{ - if ( !AddCatalog(wxS("wxstd")) ) - return false; - - // there may be a catalog with toolkit specific overrides, it is not - // an error if this does not exist - wxString port(wxPlatformInfo::Get().GetPortIdName()); - if ( !port.empty() ) - { - AddCatalog(port.BeforeFirst(wxS('/')).MakeLower()); - } - - return true; -} - - -bool wxTranslations::AddCatalog(const wxString& domain) -{ - return AddCatalog(domain, wxLANGUAGE_ENGLISH_US); -} - -#if !wxUSE_UNICODE -bool wxTranslations::AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage, - const wxString& msgIdCharset) -{ - gs_msgIdCharset[domain] = msgIdCharset; - return AddCatalog(domain, msgIdLanguage); -} -#endif // !wxUSE_UNICODE - -bool wxTranslations::AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage) -{ - const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - const wxString domain_lang = GetBestTranslation(domain, msgIdLang); - - if ( domain_lang.empty() ) - { - wxLogTrace(TRACE_I18N, - wxS("no suitable translation for domain '%s' found"), - domain); - return false; - } - - wxLogTrace(TRACE_I18N, - wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), - domain_lang, domain, msgIdLang); - - return LoadCatalog(domain, domain_lang, msgIdLang); -} - - -bool wxTranslations::LoadCatalog(const wxString& domain, const wxString& lang, const wxString& msgIdLang) -{ - wxCHECK_MSG( m_loader, false, "loader can't be NULL" ); - - wxMsgCatalog *cat = NULL; - -#if wxUSE_FONTMAP - // first look for the catalog for this language and the current locale: - // notice that we don't use the system name for the locale as this would - // force us to install catalogs in different locations depending on the - // system but always use the canonical name - wxFontEncoding encSys = wxLocale::GetSystemEncoding(); - if ( encSys != wxFONTENCODING_SYSTEM ) - { - wxString fullname(lang); - fullname << wxS('.') << wxFontMapperBase::GetEncodingName(encSys); - - cat = m_loader->LoadCatalog(domain, fullname); - } -#endif // wxUSE_FONTMAP - - if ( !cat ) - { - // Next try: use the provided name language name: - cat = m_loader->LoadCatalog(domain, lang); - } - - if ( !cat ) - { - // Also try just base locale name: for things like "fr_BE" (Belgium - // French) we should use fall back on plain "fr" if no Belgium-specific - // message catalogs exist - wxString baselang = lang.BeforeFirst('_'); - if ( lang != baselang ) - cat = m_loader->LoadCatalog(domain, baselang); - } - - if ( !cat ) - { - // It is OK to not load catalog if the msgid language and m_language match, - // in which case we can directly display the texts embedded in program's - // source code: - if ( msgIdLang == lang ) - return true; - } - - if ( cat ) - { - // add it to the head of the list so that in GetString it will - // be searched before the catalogs added earlier - cat->m_pNext = m_pMsgCat; - m_pMsgCat = cat; - - return true; - } - else - { - // Nothing worked, the catalog just isn't there - wxLogTrace(TRACE_I18N, - "Catalog \"%s.mo\" not found for language \"%s\".", - domain, lang); - return false; - } -} - -// check if the given catalog is loaded -bool wxTranslations::IsLoaded(const wxString& domain) const -{ - return FindCatalog(domain) != NULL; -} - -wxString wxTranslations::GetBestTranslation(const wxString& domain, - wxLanguage msgIdLanguage) -{ - const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - return GetBestTranslation(domain, lang); -} - -wxString wxTranslations::GetBestTranslation(const wxString& domain, - const wxString& msgIdLanguage) -{ - // explicitly set language should always be respected - if ( !m_lang.empty() ) - return m_lang; - - wxArrayString available(GetAvailableTranslations(domain)); - // it's OK to have duplicates, so just add msgid language - available.push_back(msgIdLanguage); - available.push_back(msgIdLanguage.BeforeFirst('_')); - - wxLogTrace(TRACE_I18N, "choosing best language for domain '%s'", domain); - LogTraceArray(" - available translations", available); - const wxString lang = GetPreferredUILanguage(available); - wxLogTrace(TRACE_I18N, " => using language '%s'", lang); - return lang; -} - - -/* static */ -const wxString& wxTranslations::GetUntranslatedString(const wxString& str) -{ - wxLocaleUntranslatedStrings& strings = wxThreadInfo.untranslatedStrings; - - wxLocaleUntranslatedStrings::iterator i = strings.find(str); - if ( i == strings.end() ) - return *strings.insert(str).first; - - return *i; -} - - -const wxString *wxTranslations::GetTranslatedString(const wxString& origString, - const wxString& domain) const -{ - return GetTranslatedString(origString, UINT_MAX, domain); -} - -const wxString *wxTranslations::GetTranslatedString(const wxString& origString, - unsigned n, - const wxString& domain) const -{ - if ( origString.empty() ) - return NULL; - - const wxString *trans = NULL; - wxMsgCatalog *pMsgCat; - - if ( !domain.empty() ) - { - pMsgCat = FindCatalog(domain); - - // does the catalog exist? - if ( pMsgCat != NULL ) - trans = pMsgCat->GetString(origString, n); - } - else - { - // search in all domains - for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) - { - trans = pMsgCat->GetString(origString, n); - if ( trans != NULL ) // take the first found - break; - } - } - - if ( trans == NULL ) - { - wxLogTrace - ( - TRACE_I18N, - "string \"%s\"%s not found in %slocale '%s'.", - origString, - (n != UINT_MAX ? wxString::Format("[%ld]", (long)n) : wxString()), - (!domain.empty() ? wxString::Format("domain '%s' ", domain) : wxString()), - m_lang - ); - } - - return trans; -} - - -wxString wxTranslations::GetHeaderValue(const wxString& header, - const wxString& domain) const -{ - if ( header.empty() ) - return wxEmptyString; - - const wxString *trans = NULL; - wxMsgCatalog *pMsgCat; - - if ( !domain.empty() ) - { - pMsgCat = FindCatalog(domain); - - // does the catalog exist? - if ( pMsgCat == NULL ) - return wxEmptyString; - - trans = pMsgCat->GetString(wxEmptyString, UINT_MAX); - } - else - { - // search in all domains - for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) - { - trans = pMsgCat->GetString(wxEmptyString, UINT_MAX); - if ( trans != NULL ) // take the first found - break; - } - } - - if ( !trans || trans->empty() ) - return wxEmptyString; - - size_t found = trans->find(header); - if ( found == wxString::npos ) - return wxEmptyString; - - found += header.length() + 2 /* ': ' */; - - // Every header is separated by \n - - size_t endLine = trans->find(wxS('\n'), found); - size_t len = (endLine == wxString::npos) ? - wxString::npos : (endLine - found); - - return trans->substr(found, len); -} - - -// find catalog by name in a linked list, return NULL if !found -wxMsgCatalog *wxTranslations::FindCatalog(const wxString& domain) const -{ - // linear search in the linked list - wxMsgCatalog *pMsgCat; - for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) - { - if ( pMsgCat->GetDomain() == domain ) - return pMsgCat; - } - - return NULL; -} - -// ---------------------------------------------------------------------------- -// wxFileTranslationsLoader -// ---------------------------------------------------------------------------- - -namespace -{ - -// the list of the directories to search for message catalog files -wxArrayString gs_searchPrefixes; - -// return the directories to search for message catalogs under the given -// prefix, separated by wxPATH_SEP -wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang) -{ - // Search first in Unix-standard prefix/lang/LC_MESSAGES, then in - // prefix/lang. - // - // Note that we use LC_MESSAGES on all platforms and not just Unix, because - // it doesn't cost much to look into one more directory and doing it this - // way has two important benefits: - // a) we don't break compatibility with wx-2.6 and older by stopping to - // look in a directory where the catalogs used to be and thus silently - // breaking apps after they are recompiled against the latest wx - // b) it makes it possible to package app's support files in the same - // way on all target platforms - const wxString prefixAndLang = wxFileName(prefix, lang).GetFullPath(); - - wxString searchPath; - searchPath.reserve(4*prefixAndLang.length()); - - searchPath -#ifdef __WXOSX__ - << prefixAndLang << ".lproj/LC_MESSAGES" << wxPATH_SEP - << prefixAndLang << ".lproj" << wxPATH_SEP -#endif - << prefixAndLang << wxFILE_SEP_PATH << "LC_MESSAGES" << wxPATH_SEP - << prefixAndLang << wxPATH_SEP - ; - - return searchPath; -} - -bool HasMsgCatalogInDir(const wxString& dir, const wxString& domain) -{ - return wxFileName(dir, domain, "mo").FileExists() || - wxFileName(dir + wxFILE_SEP_PATH + "LC_MESSAGES", domain, "mo").FileExists(); -} - -// get prefixes to locale directories; if lang is empty, don't point to -// OSX's .lproj bundles -wxArrayString GetSearchPrefixes() -{ - wxArrayString paths; - - // first take the entries explicitly added by the program - paths = gs_searchPrefixes; - -#if wxUSE_STDPATHS - // then look in the standard location - wxString stdp; - stdp = wxStandardPaths::Get().GetResourcesDir(); - if ( paths.Index(stdp) == wxNOT_FOUND ) - paths.Add(stdp); -#endif // wxUSE_STDPATHS - - // last look in default locations -#ifdef __UNIX__ - // LC_PATH is a standard env var containing the search path for the .mo - // files - const char *pszLcPath = wxGetenv("LC_PATH"); - if ( pszLcPath ) - { - const wxString lcp = pszLcPath; - if ( paths.Index(lcp) == wxNOT_FOUND ) - paths.Add(lcp); - } - - // also add the one from where wxWin was installed: - wxString wxp = wxGetInstallPrefix(); - if ( !wxp.empty() ) - { - wxp += wxS("/share/locale"); - if ( paths.Index(wxp) == wxNOT_FOUND ) - paths.Add(wxp); - } -#endif // __UNIX__ - - return paths; -} - -// construct the search path for the given language -wxString GetFullSearchPath(const wxString& lang) -{ - wxString searchPath; - searchPath.reserve(500); - - const wxArrayString prefixes = GetSearchPrefixes(); - - for ( wxArrayString::const_iterator i = prefixes.begin(); - i != prefixes.end(); - ++i ) - { - const wxString p = GetMsgCatalogSubdirs(*i, lang); - - if ( !searchPath.empty() ) - searchPath += wxPATH_SEP; - searchPath += p; - } - - return searchPath; -} - -} // anonymous namespace - - -void wxFileTranslationsLoader::AddCatalogLookupPathPrefix(const wxString& prefix) -{ - if ( gs_searchPrefixes.Index(prefix) == wxNOT_FOUND ) - { - gs_searchPrefixes.Add(prefix); - } - //else: already have it -} - - -wxMsgCatalog *wxFileTranslationsLoader::LoadCatalog(const wxString& domain, - const wxString& lang) -{ - wxString searchPath = GetFullSearchPath(lang); - - LogTraceLargeArray - ( - wxString::Format("looking for \"%s.mo\" in search path", domain), - wxSplit(searchPath, wxPATH_SEP[0]) - ); - - wxFileName fn(domain); - fn.SetExt(wxS("mo")); - - wxString strFullName; - if ( !wxFindFileInPath(&strFullName, searchPath, fn.GetFullPath()) ) - return NULL; - - // open file and read its data - wxLogVerbose(_("using catalog '%s' from '%s'."), domain, strFullName.c_str()); - wxLogTrace(TRACE_I18N, wxS("Using catalog \"%s\"."), strFullName.c_str()); - - return wxMsgCatalog::CreateFromFile(strFullName, domain); -} - - -wxArrayString wxFileTranslationsLoader::GetAvailableTranslations(const wxString& domain) const -{ - wxArrayString langs; - const wxArrayString prefixes = GetSearchPrefixes(); - - LogTraceLargeArray - ( - wxString::Format("looking for available translations of \"%s\" in search path", domain), - prefixes - ); - - for ( wxArrayString::const_iterator i = prefixes.begin(); - i != prefixes.end(); - ++i ) - { - if ( i->empty() ) - continue; - wxDir dir; - if ( !dir.Open(*i) ) - continue; - - wxString lang; - for ( bool ok = dir.GetFirst(&lang, "", wxDIR_DIRS); - ok; - ok = dir.GetNext(&lang) ) - { - const wxString langdir = *i + wxFILE_SEP_PATH + lang; - if ( HasMsgCatalogInDir(langdir, domain) ) - { -#ifdef __WXOSX__ - wxString rest; - if ( lang.EndsWith(".lproj", &rest) ) - lang = rest; -#endif // __WXOSX__ - - wxLogTrace(TRACE_I18N, - "found %s translation of \"%s\" in %s", - lang, domain, langdir); - langs.push_back(lang); - } - } - } - - return langs; -} - - -// ---------------------------------------------------------------------------- -// wxResourceTranslationsLoader -// ---------------------------------------------------------------------------- - -#ifdef __WINDOWS__ - -wxMsgCatalog *wxResourceTranslationsLoader::LoadCatalog(const wxString& domain, - const wxString& lang) -{ - const void *mo_data = NULL; - size_t mo_size = 0; - - const wxString resname = wxString::Format("%s_%s", domain, lang); - - if ( !wxLoadUserResource(&mo_data, &mo_size, - resname, - GetResourceType().t_str(), - GetModule()) ) - return NULL; - - wxLogTrace(TRACE_I18N, - "Using catalog from Windows resource \"%s\".", resname); - - wxMsgCatalog *cat = wxMsgCatalog::CreateFromData( - wxCharBuffer::CreateNonOwned(static_cast(mo_data), mo_size), - domain); - - if ( !cat ) - { - wxLogWarning(_("Resource '%s' is not a valid message catalog."), resname); - } - - return cat; -} - -namespace -{ - -struct EnumCallbackData -{ - wxString prefix; - wxArrayString langs; -}; - -BOOL CALLBACK EnumTranslations(HMODULE WXUNUSED(hModule), - LPCTSTR WXUNUSED(lpszType), - LPTSTR lpszName, - LONG_PTR lParam) -{ - wxString name(lpszName); - name.MakeLower(); // resource names are case insensitive - - EnumCallbackData *data = reinterpret_cast(lParam); - - wxString lang; - if ( name.StartsWith(data->prefix, &lang) && !lang.empty() ) - data->langs.push_back(lang); - - return TRUE; // continue enumeration -} - -} // anonymous namespace - - -wxArrayString wxResourceTranslationsLoader::GetAvailableTranslations(const wxString& domain) const -{ - EnumCallbackData data; - data.prefix = domain + "_"; - data.prefix.MakeLower(); // resource names are case insensitive - - if ( !EnumResourceNames(GetModule(), - GetResourceType().t_str(), - EnumTranslations, - reinterpret_cast(&data)) ) - { - const DWORD err = GetLastError(); - if ( err != NO_ERROR && err != ERROR_RESOURCE_TYPE_NOT_FOUND ) - { - wxLogSysError(_("Couldn't enumerate translations")); - } - } - - return data.langs; -} - -#endif // __WINDOWS__ - - -// ---------------------------------------------------------------------------- -// wxTranslationsModule module (for destruction of gs_translations) -// ---------------------------------------------------------------------------- - -class wxTranslationsModule: public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxTranslationsModule) - public: - wxTranslationsModule() {} - - bool OnInit() - { - return true; - } - - void OnExit() - { - if ( gs_translationsOwned ) - delete gs_translations; - gs_translations = NULL; - gs_translationsOwned = true; - } -}; - -IMPLEMENT_DYNAMIC_CLASS(wxTranslationsModule, wxModule) - -#endif // wxUSE_INTL diff --git a/Source/3rd Party/wx/src/common/treebase.cpp b/Source/3rd Party/wx/src/common/treebase.cpp index 7283ea398..8613ab1d3 100644 --- a/Source/3rd Party/wx/src/common/treebase.cpp +++ b/Source/3rd Party/wx/src/common/treebase.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/treebase.cpp +// Name: treebase.cpp // Purpose: Base wxTreeCtrl classes // Author: Julian Smart // Created: 01/02/97 // Modified: +// Id: $Id: treebase.cpp 51356 2008-01-24 11:23:30Z VZ $ // Copyright: (c) 1998 Robert Roebling, Julian Smart et al // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,107 +29,38 @@ #include "wx/treectrl.h" #include "wx/imaglist.h" -extern WXDLLEXPORT_DATA(const char) wxTreeCtrlNameStr[] = "treeCtrl"; - // ---------------------------------------------------------------------------- // events // ---------------------------------------------------------------------------- -wxDEFINE_EVENT( wxEVT_TREE_BEGIN_DRAG, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_BEGIN_RDRAG, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_BEGIN_LABEL_EDIT, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_END_LABEL_EDIT, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_DELETE_ITEM, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_GET_INFO, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_SET_INFO, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_EXPANDED, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_EXPANDING, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_COLLAPSED, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_COLLAPSING, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_SEL_CHANGED, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_SEL_CHANGING, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_KEY_DOWN, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_ACTIVATED, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_RIGHT_CLICK, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_MIDDLE_CLICK, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_END_DRAG, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_STATE_IMAGE_CLICK, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_GETTOOLTIP, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_TREE_ITEM_MENU, wxTreeEvent ); - -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -wxDEFINE_FLAGS( wxTreeCtrlStyle ) -wxBEGIN_FLAGS( wxTreeCtrlStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxTR_EDIT_LABELS) -wxFLAGS_MEMBER(wxTR_NO_BUTTONS) -wxFLAGS_MEMBER(wxTR_HAS_BUTTONS) -wxFLAGS_MEMBER(wxTR_TWIST_BUTTONS) -wxFLAGS_MEMBER(wxTR_NO_LINES) -wxFLAGS_MEMBER(wxTR_FULL_ROW_HIGHLIGHT) -wxFLAGS_MEMBER(wxTR_LINES_AT_ROOT) -wxFLAGS_MEMBER(wxTR_HIDE_ROOT) -wxFLAGS_MEMBER(wxTR_ROW_LINES) -wxFLAGS_MEMBER(wxTR_HAS_VARIABLE_ROW_HEIGHT) -wxFLAGS_MEMBER(wxTR_SINGLE) -wxFLAGS_MEMBER(wxTR_MULTIPLE) -#if WXWIN_COMPATIBILITY_2_8 -wxFLAGS_MEMBER(wxTR_EXTENDED) -#endif -wxFLAGS_MEMBER(wxTR_DEFAULT_STYLE) -wxEND_FLAGS( wxTreeCtrlStyle ) - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxTreeCtrl, wxControl, "wx/treectrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxTreeCtrl) -wxEVENT_PROPERTY( TextUpdated, wxEVT_TEXT, wxCommandEvent ) -wxEVENT_RANGE_PROPERTY( TreeEvent, wxEVT_TREE_BEGIN_DRAG, \ - wxEVT_TREE_STATE_IMAGE_CLICK, wxTreeEvent ) - -wxPROPERTY_FLAGS( WindowStyle, wxTreeCtrlStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxTreeCtrl) - -wxCONSTRUCTOR_5( wxTreeCtrl, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle ) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_DRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_RDRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_LABEL_EDIT) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_DELETE_ITEM) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_GET_INFO) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_SET_INFO) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_EXPANDING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_COLLAPSING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_SEL_CHANGING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_KEY_DOWN) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_END_DRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_ITEM_MENU) // ---------------------------------------------------------------------------- // Tree event // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent) +IMPLEMENT_ABSTRACT_CLASS(wxTreeEvent, wxNotifyEvent) + wxTreeEvent::wxTreeEvent(wxEventType commandType, wxTreeCtrlBase *tree, @@ -166,22 +98,6 @@ wxTreeEvent::wxTreeEvent(const wxTreeEvent & event) // wxTreeCtrlBase // ---------------------------------------------------------------------------- -wxTreeCtrlBase::wxTreeCtrlBase() -{ - m_imageListNormal = - m_imageListState = NULL; - m_ownsImageListNormal = - m_ownsImageListState = false; - - // arbitrary default - m_spacing = 18; - - // quick DoGetBestSize calculation - m_quickBestSize = true; - - Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(wxTreeCtrlBase::OnCharHook)); -} - wxTreeCtrlBase::~wxTreeCtrlBase() { if (m_ownsImageListNormal) @@ -190,31 +106,6 @@ wxTreeCtrlBase::~wxTreeCtrlBase() delete m_imageListState; } -void wxTreeCtrlBase::SetItemState(const wxTreeItemId& item, int state) -{ - if ( state == wxTREE_ITEMSTATE_NEXT ) - { - int current = GetItemState(item); - if ( current == wxTREE_ITEMSTATE_NONE ) - return; - state = current + 1; - if ( m_imageListState && state >= m_imageListState->GetImageCount() ) - state = 0; - } - else if ( state == wxTREE_ITEMSTATE_PREV ) - { - int current = GetItemState(item); - if ( current == wxTREE_ITEMSTATE_NONE ) - return; - state = current - 1; - if ( state == -1 ) - state = m_imageListState ? m_imageListState->GetImageCount() - 1 : 0; - } - // else: wxTREE_ITEMSTATE_NONE depending on platform - - DoSetItemState(item, state); -} - static void wxGetBestTreeSize(const wxTreeCtrlBase* treeCtrl, wxTreeItemId id, wxSize& size) { @@ -300,7 +191,6 @@ void wxTreeCtrlBase::ExpandAll() void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item) { - Freeze(); // expand this item first, this might result in its children being added on // the fly if ( item != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT) ) @@ -315,7 +205,6 @@ void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item) { ExpandAllChildren(idCurr); } - Thaw(); } void wxTreeCtrlBase::CollapseAll() @@ -328,7 +217,6 @@ void wxTreeCtrlBase::CollapseAll() void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item) { - Freeze(); // first (recursively) collapse all the children wxTreeItemIdValue cookie; for ( wxTreeItemId idCurr = GetFirstChild(item, cookie); @@ -338,11 +226,8 @@ void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item) CollapseAllChildren(idCurr); } - // then collapse this element too unless it's the hidden root which can't - // be collapsed - if ( item != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT) ) - Collapse(item); - Thaw(); + // then collapse this element too + Collapse(item); } bool wxTreeCtrlBase::IsEmpty() const @@ -350,26 +235,5 @@ bool wxTreeCtrlBase::IsEmpty() const return !GetRootItem().IsOk(); } -void wxTreeCtrlBase::OnCharHook(wxKeyEvent& event) -{ - if ( GetEditControl() ) - { - bool discardChanges = false; - switch ( event.GetKeyCode() ) - { - case WXK_ESCAPE: - discardChanges = true; - // fall through - - case WXK_RETURN: - EndEditLabel(GetFocusedItem(), discardChanges); - - // Do not call Skip() below. - return; - } - } - - event.Skip(); -} - #endif // wxUSE_TREECTRL + diff --git a/Source/3rd Party/wx/src/common/txtstrm.cpp b/Source/3rd Party/wx/src/common/txtstrm.cpp index 9e3fa8a79..3dad17012 100644 --- a/Source/3rd Party/wx/src/common/txtstrm.cpp +++ b/Source/3rd Party/wx/src/common/txtstrm.cpp @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: // Created: 28/06/98 +// RCS-ID: $Id: txtstrm.cpp 48920 2007-09-24 13:11:36Z JS $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,13 +19,17 @@ #if wxUSE_STREAMS #include "wx/txtstrm.h" - -#ifndef WX_PRECOMP - #include "wx/crt.h" -#endif - #include + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// Unix: "\n" +// Dos: "\r\n" +// Mac: "\r" + // ---------------------------------------------------------------------------- // wxTextInputStream // ---------------------------------------------------------------------------- @@ -74,35 +79,11 @@ wxChar wxTextInputStream::NextChar() if(m_input.LastRead() <= 0) return wxEOT; - switch ( m_conv->ToWChar(wbuf, WXSIZEOF(wbuf), m_lastBytes, inlen + 1) ) - { - case 0: - // this is a bug in converter object as it should either fail - // or decode non-empty string to something non-empty - wxFAIL_MSG("ToWChar() can't return 0 for non-empty input"); - break; - - case wxCONV_FAILED: - // the buffer probably doesn't contain enough bytes to decode - // as a complete character, try with more bytes - break; - - default: - // if we couldn't decode a single character during the last - // loop iteration we shouldn't be able to decode 2 or more of - // them with an extra single byte, something fishy is going on - wxFAIL_MSG("unexpected decoding result"); - // fall through nevertheless and return at least something - - case 1: - // we finally decoded a character - return wbuf[0]; - } + if ( m_conv->ToWChar(wbuf, WXSIZEOF(wbuf), m_lastBytes, inlen + 1) + != wxCONV_FAILED ) + return wbuf[0]; } - - // there should be no encoding which requires more than nine bytes for one - // character so something must be wrong with our conversion but we have no - // way to signal it from here + // there should be no encoding which requires more than nine bytes for one character... return wxEOT; #else m_lastBytes[0] = m_input.GetC(); @@ -124,7 +105,7 @@ wxChar wxTextInputStream::NextNonSeparators() if (c != wxT('\n') && c != wxT('\r') && - m_separators.Find(c) < 0) + !m_separators.Contains(c)) return c; } @@ -148,7 +129,7 @@ bool wxTextInputStream::EatEOL(const wxChar &c) wxUint32 wxTextInputStream::Read32(int base) { - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); + wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); if(!m_input) return 0; wxString word = ReadWord(); @@ -169,7 +150,7 @@ wxUint8 wxTextInputStream::Read8(int base) wxInt32 wxTextInputStream::Read32S(int base) { - wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); + wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); if(!m_input) return 0; wxString word = ReadWord(); @@ -244,7 +225,7 @@ wxString wxTextInputStream::ReadWord() if(c == wxEOT) break; - if (m_separators.Find(c) >= 0) + if (m_separators.Contains(c)) break; if (EatEOL(c)) @@ -335,8 +316,10 @@ wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode) m_mode = mode; if (m_mode == wxEOL_NATIVE) { -#if defined(__WINDOWS__) || defined(__WXPM__) +#if defined(__WXMSW__) || defined(__WXPM__) m_mode = wxEOL_DOS; +#elif defined(__WXMAC__) && !defined(__DARWIN__) + m_mode = wxEOL_MAC; #else m_mode = wxEOL_UNIX; #endif @@ -355,8 +338,10 @@ void wxTextOutputStream::SetMode(wxEOL mode) m_mode = mode; if (m_mode == wxEOL_NATIVE) { -#if defined(__WINDOWS__) || defined(__WXPM__) +#if defined(__WXMSW__) || defined(__WXPM__) m_mode = wxEOL_DOS; +#elif defined(__WXMAC__) && !defined(__DARWIN__) + m_mode = wxEOL_MAC; #else m_mode = wxEOL_UNIX; #endif @@ -410,15 +395,15 @@ void wxTextOutputStream::WriteString(const wxString& string) switch ( m_mode ) { case wxEOL_DOS: - out << wxT("\r\n"); + out << _T("\r\n"); continue; case wxEOL_MAC: - out << wxT('\r'); + out << _T('\r'); continue; default: - wxFAIL_MSG( wxT("unknown EOL mode in wxTextOutputStream") ); + wxFAIL_MSG( _T("unknown EOL mode in wxTextOutputStream") ); // fall through case wxEOL_UNIX: @@ -431,8 +416,7 @@ void wxTextOutputStream::WriteString(const wxString& string) } #if wxUSE_UNICODE - // FIXME-UTF8: use wxCharBufferWithLength if/when we have it - wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len); + wxCharBuffer buffer = m_conv->cWC2MB(out, out.length(), &len); m_output.Write(buffer, len); #else m_output.Write(out.c_str(), out.length() ); @@ -449,17 +433,10 @@ wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c) return *this; } -void wxTextOutputStream::Flush() +wxTextOutputStream& wxTextOutputStream::operator<<(const wxChar *string) { -#if wxUSE_UNICODE - const size_t len = m_conv->FromWChar(NULL, 0, L"", 1); - if ( len > m_conv->GetMBNulLen() ) - { - wxCharBuffer buf(len); - m_conv->FromWChar(buf.data(), len, L"", 1); - m_output.Write(buf, len - m_conv->GetMBNulLen()); - } -#endif // wxUSE_UNICODE + WriteString( wxString(string) ); + return *this; } wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string) diff --git a/Source/3rd Party/wx/src/common/uiactioncmn.cpp b/Source/3rd Party/wx/src/common/uiactioncmn.cpp deleted file mode 100644 index 32a8d2f2d..000000000 --- a/Source/3rd Party/wx/src/common/uiactioncmn.cpp +++ /dev/null @@ -1,148 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/uiactioncmn.cpp -// Purpose: wxUIActionSimulator common implementation -// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin -// Modified by: -// Created: 2010-03-06 -// Copyright: (c) Kevin Ollivier -// (c) 2010 Steven Lamerton -// (c) 2010 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#if wxUSE_UIACTIONSIMULATOR - -#include "wx/uiaction.h" - -bool wxUIActionSimulator::MouseClick(int button) -{ - MouseDown(button); - MouseUp(button); - - return true; -} - -#ifndef __WXOSX__ - -bool wxUIActionSimulator::MouseDblClick(int button) -{ - MouseDown(button); - MouseUp(button); - MouseDown(button); - MouseUp(button); - - return true; -} - -bool wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2, - int button) -{ - MouseMove(x1, y1); - MouseDown(button); - MouseMove(x2, y2); - MouseUp(button); - - return true; -} - -#endif - -bool -wxUIActionSimulator::Key(int keycode, int modifiers, bool isDown) -{ - wxASSERT_MSG( (modifiers & wxMOD_ALTGR) != wxMOD_ALTGR, - "wxMOD_ALTGR is not implemented" ); - wxASSERT_MSG( !(modifiers & wxMOD_META ), - "wxMOD_META is not implemented" ); - wxASSERT_MSG( !(modifiers & wxMOD_WIN ), - "wxMOD_WIN is not implemented" ); - - if ( isDown ) - SimulateModifiers(modifiers, true); - - bool rc = DoKey(keycode, modifiers, isDown); - - if ( !isDown ) - SimulateModifiers(modifiers, false); - - return rc; -} - -void wxUIActionSimulator::SimulateModifiers(int modifiers, bool isDown) -{ - if ( modifiers & wxMOD_SHIFT ) - DoKey(WXK_SHIFT, modifiers, isDown); - if ( modifiers & wxMOD_ALT ) - DoKey(WXK_ALT, modifiers, isDown); - if ( modifiers & wxMOD_CONTROL ) - DoKey(WXK_CONTROL, modifiers, isDown); -} - -bool wxUIActionSimulator::Char(int keycode, int modifiers) -{ - switch(keycode) - { - case '0': - keycode = '0'; - break; - case '1': - keycode = '1'; - break; - case '2': - keycode = '2'; - break; - case '3': - keycode = '3'; - break; - case '4': - keycode = '4'; - break; - case '5': - keycode = '5'; - break; - case '6': - keycode = '6'; - break; - case '7': - keycode = '7'; - break; - case '8': - keycode = '8'; - break; - case '9': - keycode = '9'; - break; - case '+': - keycode = '+'; - break; - case '-': - keycode = '-'; - break; - case '.': - keycode = '.'; - break; - default: - break; - }; - - Key(keycode, modifiers, true); - Key(keycode, modifiers, false); - - return true; -} - -bool wxUIActionSimulator::Text(const char *s) -{ - while ( *s != '\0' ) - { - const char ch = *s++; - if ( !Char(ch, isupper(ch) ? wxMOD_SHIFT : 0) ) - return false; - } - - return true; -} - -#endif // wxUSE_UIACTIONSIMULATOR diff --git a/Source/3rd Party/wx/src/common/unichar.cpp b/Source/3rd Party/wx/src/common/unichar.cpp deleted file mode 100644 index de95fcd00..000000000 --- a/Source/3rd Party/wx/src/common/unichar.cpp +++ /dev/null @@ -1,183 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/unichar.cpp -// Purpose: wxUniChar and wxUniCharRef classes -// Author: Vaclav Slavik -// Created: 2007-03-19 -// Copyright: (c) 2007 REA Elektronik GmbH -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// headers -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/strconv.h" // wxConvLibc - #include "wx/log.h" -#endif - -#include "wx/unichar.h" -#include "wx/string.h" - -// =========================================================================== -// implementation -// =========================================================================== - -// --------------------------------------------------------------------------- -// wxUniChar -// --------------------------------------------------------------------------- - -/* static */ -wxUniChar::value_type wxUniChar::FromHi8bit(char c) -{ -#if wxUSE_UTF8_LOCALE_ONLY - wxFAIL_MSG( "invalid UTF-8 character" ); - wxUnusedVar(c); - - return wxT('?'); // FIXME-UTF8: what to use as failure character? -#else - char cbuf[2]; - cbuf[0] = c; - cbuf[1] = '\0'; - wchar_t wbuf[2]; - if ( wxConvLibc.ToWChar(wbuf, 2, cbuf, 2) != 2 ) - { - wxFAIL_MSG( "invalid multibyte character" ); - return wxT('?'); // FIXME-UTF8: what to use as failure character? - } - return wbuf[0]; -#endif -} - -/* static */ -char wxUniChar::ToHi8bit(wxUniChar::value_type v) -{ - char c; - if ( !GetAsHi8bit(v, &c) ) - { - wxFAIL_MSG( "character cannot be converted to single byte" ); - c = '?'; // FIXME-UTF8: what to use as failure character? - } - - return c; -} - -/* static */ -bool wxUniChar::GetAsHi8bit(value_type v, char *c) -{ - wchar_t wbuf[2]; - wbuf[0] = v; - wbuf[1] = L'\0'; - char cbuf[2]; - if ( wxConvLibc.FromWChar(cbuf, 2, wbuf, 2) != 2 ) - return false; - - *c = cbuf[0]; - return true; -} - -// --------------------------------------------------------------------------- -// wxUniCharRef -// --------------------------------------------------------------------------- - -#if wxUSE_UNICODE_UTF8 -wxUniChar wxUniCharRef::UniChar() const -{ - return wxStringOperations::DecodeChar(m_pos); -} - -wxUniCharRef& wxUniCharRef::operator=(const wxUniChar& c) -{ - wxStringOperations::Utf8CharBuffer utf(wxStringOperations::EncodeChar(c)); - size_t lenOld = wxStringOperations::GetUtf8CharLength(*m_pos); - size_t lenNew = wxStringOperations::GetUtf8CharLength(utf[0]); - - if ( lenNew == lenOld ) - { - // this is the simpler case: if the new value's UTF-8 code has the - // same length, we can just replace it: - - iterator pos(m_pos); - for ( size_t i = 0; i < lenNew; ++i, ++pos ) - *pos = utf[i]; - } - else // length of character encoding in UTF-8 changed - { - // the worse case is when the new value has either longer or shorter - // code -- in that case, we have to use wxStringImpl::replace() and - // this invalidates all iterators, so we have to update them too: - - wxStringImpl& strimpl = m_str.m_impl; - - int iterDiff = lenNew - lenOld; - size_t posIdx = m_pos - strimpl.begin(); - - // compute positions of outstanding iterators for this string after the - // replacement is done (there is only a small number of iterators at - // any time, so we use an array on the stack to avoid unneeded - // allocation): - static const size_t STATIC_SIZE = 32; - size_t indexes_a[STATIC_SIZE]; - size_t *indexes = indexes_a; - size_t iterNum = 0; - wxStringIteratorNode *it; - for ( it = m_str.m_iterators.ptr; it; it = it->m_next, ++iterNum ) - { - wxASSERT( it->m_iter || it->m_citer ); - - if ( iterNum == STATIC_SIZE ) - { - wxLogTrace( wxT("utf8"), wxT("unexpectedly many iterators") ); - - size_t total = iterNum + 1; - for ( wxStringIteratorNode *it2 = it; it2; it2 = it2->m_next ) - total++; - indexes = new size_t[total]; - memcpy(indexes, indexes_a, sizeof(size_t) * STATIC_SIZE); - } - - size_t idx = it->m_iter - ? (*it->m_iter - strimpl.begin()) - : (*it->m_citer - strimpl.begin()); - - if ( idx > posIdx ) - idx += iterDiff; - - indexes[iterNum] = idx; - } - - // update the string: - strimpl.replace(m_pos, m_pos + lenOld, utf, lenNew); - -#if wxUSE_STRING_POS_CACHE - m_str.InvalidateCache(); -#endif // wxUSE_STRING_POS_CACHE - - // finally, set the iterators to valid values again (note that this - // updates m_pos as well): - size_t i; - for ( i = 0, it = m_str.m_iterators.ptr; it; it = it->m_next, ++i ) - { - wxASSERT( i < iterNum ); - wxASSERT( it->m_iter || it->m_citer ); - - if ( it->m_iter ) - *it->m_iter = strimpl.begin() + indexes[i]; - else // it->m_citer - *it->m_citer = strimpl.begin() + indexes[i]; - } - - if ( indexes != indexes_a ) - delete[] indexes; - } - - return *this; -} -#endif // wxUSE_UNICODE_UTF8 diff --git a/Source/3rd Party/wx/src/common/unictabl.inc b/Source/3rd Party/wx/src/common/unictabl.inc index 2993424ab..d75491642 100644 --- a/Source/3rd Party/wx/src/common/unictabl.inc +++ b/Source/3rd Party/wx/src/common/unictabl.inc @@ -3,6 +3,7 @@ /* * This file is #included by encconv.cpp * + * CVS-ID: $Id: unictabl.inc 40398 2006-07-31 16:28:43Z VS $ * * *** *** CAUTION! *** *** * Do not modify this file by hand! It is generated by shell @@ -560,31 +561,6 @@ static const wxUint16 encoding_table__CP1257[128] = { }; -/* - * CP866 to Unicode recoding table - * based on file mappings/CP866.TXT by Unicode Consortium - */ - -static const wxUint16 encoding_table__CP866[128] = { - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, - 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, - 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, - 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, - 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, - 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, - 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, - 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, - 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 - }; - - /* * KOI8 to Unicode recoding table * based on file mappings/KOI8-R.TXT by Unicode Consortium @@ -892,6 +868,5 @@ static const struct { { wxFONTENCODING_CP1257, encoding_table__CP1257}, { wxFONTENCODING_KOI8, encoding_table__KOI8}, { wxFONTENCODING_KOI8_U, encoding_table__KOI8_U}, - { wxFONTENCODING_CP866, encoding_table__CP866}, {wxFONTENCODING_MAX /*anything*/, NULL} }; diff --git a/Source/3rd Party/wx/src/common/uri.cpp b/Source/3rd Party/wx/src/common/uri.cpp index d6279eed2..9ff50a0cc 100644 --- a/Source/3rd Party/wx/src/common/uri.cpp +++ b/Source/3rd Party/wx/src/common/uri.cpp @@ -1,12 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/uri.cpp -// Purpose: Implementation of a URI parser -// Author: Ryan Norton, -// Vadim Zeitlin (UTF-8 URI support, many other changes) +// Name: uri.cpp +// Purpose: Implementation of a uri parser +// Author: Ryan Norton // Created: 10/26/04 -// Copyright: (c) 2004 Ryan Norton, -// 2008 Vadim Zeitlin -// Licence: wxWindows licence +// RCS-ID: $Id: uri.cpp 58728 2009-02-07 22:03:30Z VZ $ +// Copyright: (c) 2004 Ryan Norton +// Licence: wxWindows ///////////////////////////////////////////////////////////////////////////// // =========================================================================== @@ -24,10 +23,6 @@ #pragma hdrstop #endif -#ifndef WX_PRECOMP - #include "wx/crt.h" -#endif - #include "wx/uri.h" // --------------------------------------------------------------------------- @@ -37,43 +32,50 @@ IMPLEMENT_CLASS(wxURI, wxObject) // =========================================================================== -// wxURI implementation +// implementation // =========================================================================== // --------------------------------------------------------------------------- -// Constructors and cleanup +// utilities // --------------------------------------------------------------------------- -wxURI::wxURI() - : m_hostType(wxURI_REGNAME), - m_fields(0) +// --------------------------------------------------------------------------- +// +// wxURI +// +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- +// Constructors +// --------------------------------------------------------------------------- + +wxURI::wxURI() : m_hostType(wxURI_REGNAME), m_fields(0) { } -wxURI::wxURI(const wxString& uri) - : m_hostType(wxURI_REGNAME), - m_fields(0) +wxURI::wxURI(const wxString& uri) : m_hostType(wxURI_REGNAME), m_fields(0) { Create(uri); } -bool wxURI::Create(const wxString& uri) +wxURI::wxURI(const wxURI& uri) : wxObject(), m_hostType(wxURI_REGNAME), m_fields(0) { - if (m_fields) - Clear(); + Assign(uri); +} - return Parse(uri.utf8_str()); +// --------------------------------------------------------------------------- +// Destructor and cleanup +// --------------------------------------------------------------------------- + +wxURI::~wxURI() +{ + Clear(); } void wxURI::Clear() { - m_scheme = - m_userinfo = - m_server = - m_port = - m_path = - m_query = - m_fragment = wxEmptyString; + m_scheme = m_userinfo = m_server = m_port = m_path = + m_query = m_fragment = wxEmptyString; m_hostType = wxURI_REGNAME; @@ -81,98 +83,72 @@ void wxURI::Clear() } // --------------------------------------------------------------------------- -// Escaped characters handling +// Create +// +// This creates the URI - all we do here is call the main parsing method // --------------------------------------------------------------------------- -// Converts a character into a numeric hexadecimal value, or -1 if the passed -// in character is not a valid hex character - -/* static */ -int wxURI::CharToHex(char c) +const wxChar* wxURI::Create(const wxString& uri) { - if ((c >= 'A') && (c <= 'Z')) - return c - 'A' + 10; - if ((c >= 'a') && (c <= 'z')) - return c - 'a' + 10; - if ((c >= '0') && (c <= '9')) - return c - '0'; + if (m_fields) + Clear(); - return -1; + return Parse(uri); } -int wxURI::DecodeEscape(wxString::const_iterator& i) +// --------------------------------------------------------------------------- +// Escape Methods +// +// TranslateEscape unencodes a 3 character URL escape sequence +// +// Escape encodes an invalid URI character into a 3 character sequence +// +// IsEscape determines if the input string contains an escape sequence, +// if it does, then it moves the input string past the escape sequence +// +// Unescape unencodes all 3 character URL escape sequences in a wxString +// --------------------------------------------------------------------------- + +wxChar wxURI::TranslateEscape(const wxChar* s) { - int hi = CharToHex(*++i); - if ( hi == -1 ) - return -1; + wxASSERT_MSG( IsHex(s[0]) && IsHex(s[1]), wxT("Invalid escape sequence!")); - int lo = CharToHex(*++i); - if ( lo == -1 ) - return -1; - - return (hi << 4) | lo; + return wx_truncate_cast(wxChar, (CharToHex(s[0]) << 4 ) | CharToHex(s[1])); } -/* static */ wxString wxURI::Unescape(const wxString& uri) { - // the unescaped version can't be longer than the original one - wxCharBuffer buf(uri.length()); - char *p = buf.data(); + wxString new_uri; - for ( wxString::const_iterator i = uri.begin(); i != uri.end(); ++i, ++p ) + for(size_t i = 0; i < uri.length(); ++i) { - char c = *i; - if ( c == '%' ) + if (uri[i] == wxT('%')) { - int n = wxURI::DecodeEscape(i); - if ( n == -1 ) - return wxString(); - - wxASSERT_MSG( n >= 0 && n <= 0xff, "unexpected character value" ); - - c = static_cast(n); + new_uri += wxURI::TranslateEscape( &(uri.c_str()[i+1]) ); + i += 2; } - - *p = c; + else + new_uri += uri[i]; } - *p = '\0'; - - // by default assume that the URI is in UTF-8, this is the most common - // practice - wxString s = wxString::FromUTF8(buf); - if ( s.empty() ) - { - // if it isn't, use latin-1 as a fallback -- at least this always - // succeeds - s = wxCSConv(wxFONTENCODING_ISO8859_1).cMB2WC(buf); - } - - return s; + return new_uri; } -void wxURI::AppendNextEscaped(wxString& s, const char *& p) +void wxURI::Escape(wxString& s, const wxChar& c) +{ + const wxChar* hdig = wxT("0123456789abcdef"); + s += wxT('%'); + s += hdig[(c >> 4) & 15]; + s += hdig[c & 15]; +} + +bool wxURI::IsEscape(const wxChar*& uri) { - // check for an already encoded character: - // // pct-encoded = "%" HEXDIG HEXDIG - if ( p[0] == '%' && IsHex(p[1]) && IsHex(p[2]) ) - { - s += *p++; - s += *p++; - s += *p++; - } - else // really needs escaping - { - static const char* hexDigits = "0123456789abcdef"; - - const char c = *p++; - - s += '%'; - s += hexDigits[(c >> 4) & 15]; - s += hexDigits[c & 15]; - } + if(*uri == wxT('%') && IsHex(*(uri+1)) && IsHex(*(uri+2))) + return true; + else + return false; } // --------------------------------------------------------------------------- @@ -193,52 +169,124 @@ wxString wxURI::GetPassword() const size_t posColon = m_userinfo.find(':'); if ( posColon == wxString::npos ) - return ""; + return wxT(""); return m_userinfo(posColon + 1, wxString::npos); } -// combine all URI fields in a single string, applying funcDecode to each -// component which it may make sense to decode (i.e. "unescape") -wxString wxURI::DoBuildURI(wxString (*funcDecode)(const wxString&)) const +// --------------------------------------------------------------------------- +// BuildURI +// +// BuildURI() builds the entire URI into a useable +// representation, including proper identification characters such as slashes +// +// BuildUnescapedURI() does the same thing as BuildURI(), only it unescapes +// the components that accept escape sequences +// --------------------------------------------------------------------------- + +wxString wxURI::BuildURI() const { wxString ret; if (HasScheme()) - ret += m_scheme + ":"; + ret = ret + m_scheme + wxT(":"); if (HasServer()) { - ret += "//"; + ret += wxT("//"); if (HasUserInfo()) - ret += funcDecode(m_userinfo) + "@"; + ret = ret + m_userinfo + wxT("@"); + + ret += m_server; + + if (HasPort()) + ret = ret + wxT(":") + m_port; + } + + ret += m_path; + + if (HasQuery()) + ret = ret + wxT("?") + m_query; + + if (HasFragment()) + ret = ret + wxT("#") + m_fragment; + + return ret; +} + +wxString wxURI::BuildUnescapedURI() const +{ + wxString ret; + + if (HasScheme()) + ret = ret + m_scheme + wxT(":"); + + if (HasServer()) + { + ret += wxT("//"); + + if (HasUserInfo()) + ret = ret + wxURI::Unescape(m_userinfo) + wxT("@"); if (m_hostType == wxURI_REGNAME) - ret += funcDecode(m_server); + ret += wxURI::Unescape(m_server); else ret += m_server; if (HasPort()) - ret += ":" + m_port; + ret = ret + wxT(":") + m_port; } - ret += funcDecode(m_path); + ret += wxURI::Unescape(m_path); if (HasQuery()) - ret += "?" + funcDecode(m_query); + ret = ret + wxT("?") + wxURI::Unescape(m_query); if (HasFragment()) - ret += "#" + funcDecode(m_fragment); + ret = ret + wxT("#") + wxURI::Unescape(m_fragment); return ret; } +// --------------------------------------------------------------------------- +// Assignment +// --------------------------------------------------------------------------- + +wxURI& wxURI::Assign(const wxURI& uri) +{ + //assign fields + m_fields = uri.m_fields; + + //ref over components + m_scheme = uri.m_scheme; + m_userinfo = uri.m_userinfo; + m_server = uri.m_server; + m_hostType = uri.m_hostType; + m_port = uri.m_port; + m_path = uri.m_path; + m_query = uri.m_query; + m_fragment = uri.m_fragment; + + return *this; +} + +wxURI& wxURI::operator = (const wxURI& uri) +{ + return Assign(uri); +} + +wxURI& wxURI::operator = (const wxString& string) +{ + Create(string); + return *this; +} + // --------------------------------------------------------------------------- // Comparison // --------------------------------------------------------------------------- -bool wxURI::operator==(const wxURI& uri) const +bool wxURI::operator == (const wxURI& uri) const { if (HasScheme()) { @@ -309,9 +357,7 @@ bool wxURI::operator==(const wxURI& uri) const // --------------------------------------------------------------------------- bool wxURI::IsReference() const -{ - return !HasScheme() || !HasServer(); -} +{ return !HasScheme() || !HasServer(); } // --------------------------------------------------------------------------- // Parse @@ -322,194 +368,229 @@ bool wxURI::IsReference() const // URI-reference = URI / relative // --------------------------------------------------------------------------- -bool wxURI::Parse(const char *uri) +const wxChar* wxURI::Parse(const wxChar* uri) { uri = ParseScheme(uri); - if ( uri ) - uri = ParseAuthority(uri); - if ( uri ) - uri = ParsePath(uri); - if ( uri ) - uri = ParseQuery(uri); - if ( uri ) - uri = ParseFragment(uri); - - // we only succeed if we parsed the entire string - return uri && *uri == '\0'; + uri = ParseAuthority(uri); + uri = ParsePath(uri); + uri = ParseQuery(uri); + return ParseFragment(uri); } -const char* wxURI::ParseScheme(const char *uri) -{ - const char * const start = uri; +// --------------------------------------------------------------------------- +// ParseXXX +// +// Individual parsers for each URI component +// --------------------------------------------------------------------------- - // assume that we have a scheme if we have the valid start of it - if ( IsAlpha(*uri) ) +const wxChar* wxURI::ParseScheme(const wxChar* uri) +{ + wxASSERT(uri != NULL); + + //copy of the uri - used for figuring out + //length of each component + const wxChar* uricopy = uri; + + //Does the uri have a scheme (first character alpha)? + if (IsAlpha(*uri)) { m_scheme += *uri++; //scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) while (IsAlpha(*uri) || IsDigit(*uri) || - *uri == '+' || - *uri == '-' || - *uri == '.') + *uri == wxT('+') || + *uri == wxT('-') || + *uri == wxT('.')) { m_scheme += *uri++; } //valid scheme? - if (*uri == ':') + if (*uri == wxT(':')) { //mark the scheme as valid m_fields |= wxURI_SCHEME; //move reference point up to input buffer - ++uri; - } - else // no valid scheme finally - { - uri = start; // rewind - m_scheme.clear(); + uricopy = ++uri; } + else + //relative uri with relative path reference + m_scheme = wxEmptyString; } - //else: can't have schema, possible a relative URI +// else + //relative uri with _possible_ relative path reference - return uri; + return uricopy; } -const char* wxURI::ParseAuthority(const char* uri) +const wxChar* wxURI::ParseAuthority(const wxChar* uri) { // authority = [ userinfo "@" ] host [ ":" port ] - if ( uri[0] == '/' && uri[1] == '/' ) + if (*uri == wxT('/') && *(uri+1) == wxT('/')) { //skip past the two slashes uri += 2; // ############# DEVIATION FROM RFC ######################### // Don't parse the server component for file URIs - if(m_scheme != "file") + if(m_scheme != wxT("file")) { //normal way - uri = ParseUserInfo(uri); - uri = ParseServer(uri); - return ParsePort(uri); + uri = ParseUserInfo(uri); + uri = ParseServer(uri); + return ParsePort(uri); } } return uri; } -const char* wxURI::ParseUserInfo(const char* uri) +const wxChar* wxURI::ParseUserInfo(const wxChar* uri) { - const char * const start = uri; + wxASSERT(uri != NULL); + + //copy of the uri - used for figuring out + //length of each component + const wxChar* uricopy = uri; // userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) - while ( *uri && *uri != '@' && *uri != '/' && *uri != '#' && *uri != '?' ) + while(*uri && *uri != wxT('@') && *uri != wxT('/') && *uri != wxT('#') && *uri != wxT('?')) { - if ( IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == ':' ) + if(IsUnreserved(*uri) || + IsSubDelim(*uri) || *uri == wxT(':')) m_userinfo += *uri++; + else if (IsEscape(uri)) + { + m_userinfo += *uri++; + m_userinfo += *uri++; + m_userinfo += *uri++; + } else - AppendNextEscaped(m_userinfo, uri); + Escape(m_userinfo, *uri++); } - if ( *uri++ == '@' ) + if(*uri == wxT('@')) { - // valid userinfo + //valid userinfo m_fields |= wxURI_USERINFO; + + uricopy = ++uri; } else - { - uri = start; // rewind - m_userinfo.clear(); - } + m_userinfo = wxEmptyString; - return uri; + return uricopy; } -const char* wxURI::ParseServer(const char* uri) +const wxChar* wxURI::ParseServer(const wxChar* uri) { - const char * const start = uri; + wxASSERT(uri != NULL); + + //copy of the uri - used for figuring out + //length of each component + const wxChar* uricopy = uri; // host = IP-literal / IPv4address / reg-name // IP-literal = "[" ( IPv6address / IPvFuture ) "]" - if (*uri == '[') + if (*uri == wxT('[')) { - ++uri; - if (ParseIPv6address(uri) && *uri == ']') + ++uri; //some compilers don't support *&ing a ++* + if (ParseIPv6address(uri) && *uri == wxT(']')) { + ++uri; m_hostType = wxURI_IPV6ADDRESS; - m_server.assign(start + 1, uri - start - 1); - ++uri; + wxStringBufferLength theBuffer(m_server, uri - uricopy); + wxTmemcpy(theBuffer, uricopy, uri-uricopy); + theBuffer.SetLength(uri-uricopy); } else { - uri = start + 1; // skip the leading '[' again + uri = uricopy; - if (ParseIPvFuture(uri) && *uri == ']') + ++uri; //some compilers don't support *&ing a ++* + if (ParseIPvFuture(uri) && *uri == wxT(']')) { + ++uri; m_hostType = wxURI_IPVFUTURE; - m_server.assign(start + 1, uri - start - 1); - ++uri; - } - else // unrecognized IP literal - { - uri = start; + wxStringBufferLength theBuffer(m_server, uri - uricopy); + wxTmemcpy(theBuffer, uricopy, uri-uricopy); + theBuffer.SetLength(uri-uricopy); } + else + uri = uricopy; } } - else // IPv4 or a reg-name + else { if (ParseIPv4address(uri)) { m_hostType = wxURI_IPV4ADDRESS; - m_server.assign(start, uri - start); + wxStringBufferLength theBuffer(m_server, uri - uricopy); + wxTmemcpy(theBuffer, uricopy, uri-uricopy); + theBuffer.SetLength(uri-uricopy); } else - { - uri = start; - } + uri = uricopy; } - if ( m_hostType == wxURI_REGNAME ) + if(m_hostType == wxURI_REGNAME) { - uri = start; + uri = uricopy; // reg-name = *( unreserved / pct-encoded / sub-delims ) - while ( *uri && *uri != '/' && *uri != ':' && *uri != '#' && *uri != '?' ) + while(*uri && *uri != wxT('/') && *uri != wxT(':') && *uri != wxT('#') && *uri != wxT('?')) { - if ( IsUnreserved(*uri) || IsSubDelim(*uri) ) + if(IsUnreserved(*uri) || IsSubDelim(*uri)) m_server += *uri++; + else if (IsEscape(uri)) + { + m_server += *uri++; + m_server += *uri++; + m_server += *uri++; + } else - AppendNextEscaped(m_server, uri); + Escape(m_server, *uri++); } } + //mark the server as valid m_fields |= wxURI_SERVER; return uri; } -const char* wxURI::ParsePort(const char* uri) +const wxChar* wxURI::ParsePort(const wxChar* uri) { + wxASSERT(uri != NULL); + // port = *DIGIT - if( *uri == ':' ) + if(*uri == wxT(':')) { ++uri; - while ( IsDigit(*uri) ) + while(IsDigit(*uri)) { m_port += *uri++; } + //mark the port as valid m_fields |= wxURI_PORT; } return uri; } -const char* wxURI::ParsePath(const char* uri) +const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormalize) { + wxASSERT(uri != NULL); + + //copy of the uri - used for figuring out + //length of each component + const wxChar* uricopy = uri; + /// hier-part = "//" authority path-abempty /// / path-absolute /// / path-rootless @@ -532,77 +613,120 @@ const char* wxURI::ParsePath(const char* uri) /// ; non-zero-length segment without any colon ":" /// /// pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - - if ( IsEndPath(*uri) ) - return uri; - - const bool isAbs = *uri == '/'; - if ( isAbs ) + if (*uri == wxT('/')) + { m_path += *uri++; - wxArrayString segments; - wxString segment; - for ( ;; ) - { - const bool endPath = IsEndPath(*uri); - if ( endPath || *uri == '/' ) + while(*uri && *uri != wxT('#') && *uri != wxT('?')) { - // end of a segment, look at what we got - if ( segment == ".." ) + if( IsUnreserved(*uri) || IsSubDelim(*uri) || + *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/')) + m_path += *uri++; + else if (IsEscape(uri)) { - if ( !segments.empty() && *segments.rbegin() != ".." ) - segments.pop_back(); - else if ( !isAbs ) - segments.push_back(".."); + m_path += *uri++; + m_path += *uri++; + m_path += *uri++; } - else if ( segment == "." ) - { - // normally we ignore "." but the last one should be taken into - // account as "path/." is the same as "path/" and not just "path" - if ( endPath ) - segments.push_back(""); - } - else // normal segment - { - segments.push_back(segment); - } - - if ( endPath ) - break; - - segment.clear(); - ++uri; - continue; + else + Escape(m_path, *uri++); } - if ( IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == ':' || *uri == '@' ) - segment += *uri++; - else - AppendNextEscaped(segment, uri); + if (bNormalize) + { + wxStringBufferLength theBuffer(m_path, m_path.length() + 1); +#if wxUSE_STL + wxTmemcpy(theBuffer, m_path.c_str(), m_path.length()+1); +#endif + Normalize(theBuffer, true); + theBuffer.SetLength(wxStrlen(theBuffer)); + } + //mark the path as valid + m_fields |= wxURI_PATH; } + else if(*uri) //Relative path + { + if (bReference) + { + //no colon allowed + while(*uri && *uri != wxT('#') && *uri != wxT('?')) + { + if(IsUnreserved(*uri) || IsSubDelim(*uri) || + *uri == wxT('@') || *uri == wxT('/')) + m_path += *uri++; + else if (IsEscape(uri)) + { + m_path += *uri++; + m_path += *uri++; + m_path += *uri++; + } + else + Escape(m_path, *uri++); + } + } + else + { + while(*uri && *uri != wxT('#') && *uri != wxT('?')) + { + if(IsUnreserved(*uri) || IsSubDelim(*uri) || + *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/')) + m_path += *uri++; + else if (IsEscape(uri)) + { + m_path += *uri++; + m_path += *uri++; + m_path += *uri++; + } + else + Escape(m_path, *uri++); + } + } - m_path += wxJoin(segments, '/', '\0'); - m_fields |= wxURI_PATH; + if (uri != uricopy) + { + if (bNormalize) + { + wxStringBufferLength theBuffer(m_path, m_path.length() + 1); +#if wxUSE_STL + wxTmemcpy(theBuffer, m_path.c_str(), m_path.length()+1); +#endif + Normalize(theBuffer); + theBuffer.SetLength(wxStrlen(theBuffer)); + } + + //mark the path as valid + m_fields |= wxURI_PATH; + } + } return uri; } -const char* wxURI::ParseQuery(const char* uri) +const wxChar* wxURI::ParseQuery(const wxChar* uri) { + wxASSERT(uri != NULL); + // query = *( pchar / "/" / "?" ) - if ( *uri == '?' ) + if (*uri == wxT('?')) { ++uri; - while ( *uri && *uri != '#' ) + while(*uri && *uri != wxT('#')) { - if ( IsUnreserved(*uri) || IsSubDelim(*uri) || - *uri == ':' || *uri == '@' || *uri == '/' || *uri == '?' ) - m_query += *uri++; + if (IsUnreserved(*uri) || IsSubDelim(*uri) || + *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/') || *uri == wxT('?')) + m_query += *uri++; + else if (IsEscape(uri)) + { + m_query += *uri++; + m_query += *uri++; + m_query += *uri++; + } else - AppendNextEscaped(m_query, uri); + Escape(m_query, *uri++); } + //mark the server as valid m_fields |= wxURI_QUERY; } @@ -610,21 +734,30 @@ const char* wxURI::ParseQuery(const char* uri) } -const char* wxURI::ParseFragment(const char* uri) +const wxChar* wxURI::ParseFragment(const wxChar* uri) { + wxASSERT(uri != NULL); + // fragment = *( pchar / "/" / "?" ) - if ( *uri == '#' ) + if (*uri == wxT('#')) { ++uri; - while ( *uri ) + while(*uri) { - if ( IsUnreserved(*uri) || IsSubDelim(*uri) || - *uri == ':' || *uri == '@' || *uri == '/' || *uri == '?') - m_fragment += *uri++; + if (IsUnreserved(*uri) || IsSubDelim(*uri) || + *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/') || *uri == wxT('?')) + m_fragment += *uri++; + else if (IsEscape(uri)) + { + m_fragment += *uri++; + m_fragment += *uri++; + m_fragment += *uri++; + } else - AppendNextEscaped(m_fragment, uri); + Escape(m_fragment, *uri++); } + //mark the server as valid m_fields |= wxURI_FRAGMENT; } @@ -642,20 +775,15 @@ const char* wxURI::ParseFragment(const char* uri) // Note that an empty URI inherits all components // --------------------------------------------------------------------------- -/* static */ -wxArrayString wxURI::SplitInSegments(const wxString& path) -{ - return wxSplit(path, '/', '\0' /* no escape character */); -} - void wxURI::Resolve(const wxURI& base, int flags) { wxASSERT_MSG(!base.IsReference(), - "wxURI to inherit from must not be a reference!"); + wxT("wxURI to inherit from must not be a reference!")); - // If we aren't being strict, enable the older (pre-RFC2396) loophole that - // allows this uri to inherit other properties from the base uri - even if - // the scheme is defined + // If we arn't being strict, enable the older (pre-RFC2396) + // loophole that allows this uri to inherit other + // properties from the base uri - even if the scheme + // is defined if ( !(flags & wxURI_STRICT) && HasScheme() && base.HasScheme() && m_scheme == base.m_scheme ) @@ -671,7 +799,9 @@ void wxURI::Resolve(const wxURI& base, int flags) // T.path = remove_dot_segments(R.path); // T.query = R.query; if (HasScheme()) + { return; + } //No scheme - inherit m_scheme = base.m_scheme; @@ -684,7 +814,9 @@ void wxURI::Resolve(const wxURI& base, int flags) // T.path = remove_dot_segments(R.path); // T.query = R.query; if (HasServer()) + { return; + } //No authority - inherit if (base.HasUserInfo()) @@ -723,7 +855,7 @@ void wxURI::Resolve(const wxURI& base, int flags) m_fields |= wxURI_QUERY; } } - else if ( m_path.empty() || m_path[0u] != '/' ) + else { // if (R.path starts-with "/") then // T.path = remove_dot_segments(R.path); @@ -732,74 +864,144 @@ void wxURI::Resolve(const wxURI& base, int flags) // T.path = remove_dot_segments(T.path); // endif; // T.query = R.query; - // - // So we don't do anything for absolute paths and implement merge for - // the relative ones - - wxArrayString our(SplitInSegments(m_path)), - result(SplitInSegments(base.m_path)); - - if ( !result.empty() ) - result.pop_back(); - - if ( our.empty() ) + if (m_path.empty() || m_path[0u] != wxT('/')) { - // if we have an empty path it means we were constructed from a "." - // string or something similar (e.g. "././././"), it should count - // as (empty) segment - our.push_back(""); + //Merge paths + const wxChar* op = m_path.c_str(); + const wxChar* bp = base.m_path.c_str() + base.m_path.Length(); + + //not a ending directory? move up + if (base.m_path[0] && *(bp-1) != wxT('/')) + UpTree(base.m_path, bp); + + //normalize directories + while(*op == wxT('.') && *(op+1) == wxT('.') && + (*(op+2) == '\0' || *(op+2) == wxT('/')) ) + { + UpTree(base.m_path, bp); + + if (*(op+2) == '\0') + op += 2; + else + op += 3; + } + + m_path = base.m_path.substr(0, bp - base.m_path.c_str()) + + m_path.substr((op - m_path.c_str()), m_path.Length()); } - - const wxArrayString::const_iterator end = our.end(); - for ( wxArrayString::const_iterator i = our.begin(); i != end; ++i ) - { - if ( i->empty() || *i == "." ) - { - // as in ParsePath(), while normally we ignore the empty - // segments, we need to take account of them at the end - if ( i == end - 1 ) - result.push_back(""); - continue; - } - - if ( *i == ".." ) - { - if ( !result.empty() ) - { - result.pop_back(); - - if ( i == end - 1 ) - result.push_back(""); - } - //else: just ignore, extra ".." don't accumulate - } - else - { - if ( result.empty() ) - { - // ensure that the resulting path will always be absolute - result.push_back(""); - } - - result.push_back(*i); - } - } - - m_path = wxJoin(result, '/', '\0'); } //T.fragment = R.fragment; } +// --------------------------------------------------------------------------- +// UpTree +// +// Moves a URI path up a directory +// --------------------------------------------------------------------------- + +//static +void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri) +{ + if (uri != uristart && *(uri-1) == wxT('/')) + { + uri -= 2; + } + + for(;uri != uristart; --uri) + { + if (*uri == wxT('/')) + { + ++uri; + break; + } + } + + //!!!TODO:HACK!!!// + if (uri == uristart && *uri == wxT('/')) + ++uri; + //!!!// +} + +// --------------------------------------------------------------------------- +// Normalize +// +// Normalizes directories in-place +// +// I.E. ./ and . are ignored +// +// ../ and .. are removed if a directory is before it, along +// with that directory (leading .. and ../ are kept) +// --------------------------------------------------------------------------- + +//static +void wxURI::Normalize(wxChar* s, bool bIgnoreLeads) +{ + wxChar* cp = s; + wxChar* bp = s; + + if(s[0] == wxT('/')) + ++bp; + + while(*cp) + { + if (*cp == wxT('.') && (*(cp+1) == wxT('/') || *(cp+1) == '\0') + && (bp == cp || *(cp-1) == wxT('/'))) + { + //. _or_ ./ - ignore + if (*(cp+1) == '\0') + cp += 1; + else + cp += 2; + } + else if (*cp == wxT('.') && *(cp+1) == wxT('.') && + (*(cp+2) == wxT('/') || *(cp+2) == '\0') + && (bp == cp || *(cp-1) == wxT('/'))) + { + //.. _or_ ../ - go up the tree + if (s != bp) + { + UpTree((const wxChar*)bp, (const wxChar*&)s); + + if (*(cp+2) == '\0') + cp += 2; + else + cp += 3; + } + else if (!bIgnoreLeads) + + { + *bp++ = *cp++; + *bp++ = *cp++; + if (*cp) + *bp++ = *cp++; + + s = bp; + } + else + { + if (*(cp+2) == '\0') + cp += 2; + else + cp += 3; + } + } + else + *s++ = *cp++; + } + + *s = '\0'; +} + // --------------------------------------------------------------------------- // ParseH16 // // Parses 1 to 4 hex values. Returns true if the first character of the input -// string is a valid hex character. It is the caller's responsibility to move +// string is a valid hex character. It is the caller's responsability to move // the input string back to its original position on failure. // --------------------------------------------------------------------------- -bool wxURI::ParseH16(const char*& uri) +bool wxURI::ParseH16(const wxChar*& uri) { // h16 = 1*4HEXDIG if(!IsHex(*++uri)) @@ -816,11 +1018,11 @@ bool wxURI::ParseH16(const char*& uri) // // Parses a certain version of an IP address and moves the input string past // it. Returns true if the input string contains the proper version of an ip -// address. It is the caller's responsibility to move the input string back +// address. It is the caller's responsability to move the input string back // to its original position on failure. // --------------------------------------------------------------------------- -bool wxURI::ParseIPv4address(const char*& uri) +bool wxURI::ParseIPv4address(const wxChar*& uri) { //IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet // @@ -838,10 +1040,10 @@ bool wxURI::ParseIPv4address(const char*& uri) //each ip part must be between 0-255 (dupe of version in for loop) if( IsDigit(*++uri) && IsDigit(*++uri) && //100 or less (note !) - !( (*(uri-2) < '2') || + !( (*(uri-2) < wxT('2')) || //240 or less - (*(uri-2) == '2' && - (*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5')) + (*(uri-2) == wxT('2') && + (*(uri-1) < wxT('5') || (*(uri-1) == wxT('5') && *uri <= wxT('5'))) ) ) ) @@ -854,16 +1056,16 @@ bool wxURI::ParseIPv4address(const char*& uri) //compilers should unroll this loop for(; iIPv4 < 4; ++iIPv4) { - if (*uri != '.' || !IsDigit(*++uri)) + if (*uri != wxT('.') || !IsDigit(*++uri)) break; //each ip part must be between 0-255 if( IsDigit(*++uri) && IsDigit(*++uri) && //100 or less (note !) - !( (*(uri-2) < '2') || + !( (*(uri-2) < wxT('2')) || //240 or less - (*(uri-2) == '2' && - (*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5')) + (*(uri-2) == wxT('2') && + (*(uri-1) < wxT('5') || (*(uri-1) == wxT('5') && *uri <= wxT('5'))) ) ) ) @@ -876,7 +1078,7 @@ bool wxURI::ParseIPv4address(const char*& uri) return iIPv4 == 4; } -bool wxURI::ParseIPv6address(const char*& uri) +bool wxURI::ParseIPv6address(const wxChar*& uri) { // IPv6address = 6( h16 ":" ) ls32 // / "::" 5( h16 ":" ) ls32 @@ -902,7 +1104,7 @@ bool wxURI::ParseIPv6address(const char*& uri) break; } - if(*uri != ':') + if(*uri != wxT(':')) { break; } @@ -915,9 +1117,9 @@ bool wxURI::ParseIPv6address(const char*& uri) if (numPrefix) return false; - if (*uri == ':') + if (*uri == wxT(':')) { - if (*++uri != ':') + if (*++uri != wxT(':')) return false; maxPostfix = 5; @@ -927,21 +1129,21 @@ bool wxURI::ParseIPv6address(const char*& uri) } else { - if (*uri != ':' || *(uri+1) != ':') + if (*uri != wxT(':') || *(uri+1) != wxT(':')) { if (numPrefix != 6) return false; - while (*--uri != ':') {} + while (*--uri != wxT(':')) {} ++uri; - const char * const start = uri; + const wxChar* uristart = uri; //parse ls32 // ls32 = ( h16 ":" h16 ) / IPv4address - if (ParseH16(uri) && *uri == ':' && ParseH16(uri)) + if (ParseH16(uri) && *uri == wxT(':') && ParseH16(uri)) return true; - uri = start; + uri = uristart; if (ParseIPv4address(uri)) return true; @@ -963,24 +1165,24 @@ bool wxURI::ParseIPv6address(const char*& uri) for(; maxPostfix != 0; --maxPostfix) { - if(!ParseH16(uri) || *uri != ':') + if(!ParseH16(uri) || *uri != wxT(':')) return false; } if(numPrefix <= 4) { - const char * const start = uri; + const wxChar* uristart = uri; //parse ls32 // ls32 = ( h16 ":" h16 ) / IPv4address - if (ParseH16(uri) && *uri == ':' && ParseH16(uri)) + if (ParseH16(uri) && *uri == wxT(':') && ParseH16(uri)) return true; - uri = start; + uri = uristart; if (ParseIPv4address(uri)) return true; - uri = start; + uri = uristart; if (!bAllowAltEnding) return false; @@ -992,96 +1194,102 @@ bool wxURI::ParseIPv6address(const char*& uri) return true; } -bool wxURI::ParseIPvFuture(const char*& uri) +bool wxURI::ParseIPvFuture(const wxChar*& uri) { // IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) - if (*++uri != 'v' || !IsHex(*++uri)) + if (*++uri != wxT('v') || !IsHex(*++uri)) return false; - while (IsHex(*++uri)) - ; + while (IsHex(*++uri)) {} - if (*uri != '.' || !(IsUnreserved(*++uri) || IsSubDelim(*uri) || *uri == ':')) + if (*uri != wxT('.') || !(IsUnreserved(*++uri) || IsSubDelim(*uri) || *uri == wxT(':'))) return false; - while(IsUnreserved(*++uri) || IsSubDelim(*uri) || *uri == ':') {} + while(IsUnreserved(*++uri) || IsSubDelim(*uri) || *uri == wxT(':')) {} return true; } +// --------------------------------------------------------------------------- +// CharToHex +// +// Converts a character into a numeric hexidecimal value, or 0 if the +// passed in character is not a valid hex character +// --------------------------------------------------------------------------- + +//static +wxChar wxURI::CharToHex(const wxChar& c) +{ + if ((c >= wxT('A')) && (c <= wxT('Z'))) return wxChar(c - wxT('A') + 0x0A); + if ((c >= wxT('a')) && (c <= wxT('z'))) return wxChar(c - wxT('a') + 0x0a); + if ((c >= wxT('0')) && (c <= wxT('9'))) return wxChar(c - wxT('0') + 0x00); + + return 0; +} + // --------------------------------------------------------------------------- // IsXXX // // Returns true if the passed in character meets the criteria of the method // --------------------------------------------------------------------------- -// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" -bool wxURI::IsUnreserved(char c) -{ - return IsAlpha(c) || - IsDigit(c) || - c == '-' || - c == '.' || - c == '_' || - c == '~' +//! unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" +bool wxURI::IsUnreserved (const wxChar& c) +{ return IsAlpha(c) || IsDigit(c) || + c == wxT('-') || + c == wxT('.') || + c == wxT('_') || + c == wxT('~') //tilde ; } -bool wxURI::IsReserved(char c) +bool wxURI::IsReserved (const wxChar& c) { return IsGenDelim(c) || IsSubDelim(c); } -// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" -bool wxURI::IsGenDelim(char c) +//! gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" +bool wxURI::IsGenDelim (const wxChar& c) { - return c == ':' || - c == '/' || - c == '?' || - c == '#' || - c == '[' || - c == ']' || - c == '@'; + return c == wxT(':') || + c == wxT('/') || + c == wxT('?') || + c == wxT('#') || + c == wxT('[') || + c == wxT(']') || + c == wxT('@'); } -// sub-delims = "!" / "$" / "&" / "'" / "(" / ")" -// / "*" / "+" / "," / ";" / "=" -bool wxURI::IsSubDelim(char c) +//! sub-delims = "!" / "$" / "&" / "'" / "(" / ")" +//! / "*" / "+" / "," / ";" / "=" +bool wxURI::IsSubDelim (const wxChar& c) { - return c == '!' || - c == '$' || - c == '&' || - c == '\'' || - c == '(' || - c == ')' || - c == '*' || - c == '+' || - c == ',' || - c == ';' || - c == '=' + return c == wxT('!') || + c == wxT('$') || + c == wxT('&') || + c == wxT('\'') || + c == wxT('(') || + c == wxT(')') || + c == wxT('*') || + c == wxT('+') || + c == wxT(',') || + c == wxT(';') || + c == wxT('=') ; } -bool wxURI::IsHex(char c) -{ - return IsDigit(c) || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F'); -} +bool wxURI::IsHex(const wxChar& c) +{ return IsDigit(c) || (c >= wxT('a') && c <= wxT('f')) || (c >= wxT('A') && c <= wxT('F')); } -bool wxURI::IsAlpha(char c) -{ - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); -} +bool wxURI::IsAlpha(const wxChar& c) +{ return (c >= wxT('a') && c <= wxT('z')) || (c >= wxT('A') && c <= wxT('Z')); } + +bool wxURI::IsDigit(const wxChar& c) +{ return c >= wxT('0') && c <= wxT('9'); } + + +//end of uri.cpp -bool wxURI::IsDigit(char c) -{ - return c >= '0' && c <= '9'; -} -bool wxURI::IsEndPath(char c) -{ - return c == '\0' || c == '#' || c == '?'; -} diff --git a/Source/3rd Party/wx/src/common/url.cpp b/Source/3rd Party/wx/src/common/url.cpp deleted file mode 100644 index 8d6eb49aa..000000000 --- a/Source/3rd Party/wx/src/common/url.cpp +++ /dev/null @@ -1,495 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/url.cpp -// Purpose: URL parser -// Author: Guilhem Lavaux -// Modified by: -// Created: 20/07/1997 -// Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_URL - -#include "wx/url.h" - -#ifndef WX_PRECOMP - #include "wx/list.h" - #include "wx/string.h" - #include "wx/utils.h" - #include "wx/module.h" -#endif - -#include -#include - -IMPLEMENT_CLASS(wxURL, wxURI) - -// Protocols list -wxProtoInfo *wxURL::ms_protocols = NULL; - -// Enforce linking of protocol classes: -USE_PROTOCOL(wxFileProto) - -#if wxUSE_PROTOCOL_HTTP -USE_PROTOCOL(wxHTTP) - - wxHTTP *wxURL::ms_proxyDefault = NULL; - bool wxURL::ms_useDefaultProxy = false; -#endif - -#if wxUSE_PROTOCOL_FTP -USE_PROTOCOL(wxFTP) -#endif - -// -------------------------------------------------------------- -// -// wxURL -// -// -------------------------------------------------------------- - -// -------------------------------------------------------------- -// Construction -// -------------------------------------------------------------- - -wxURL::wxURL(const wxString& url) : wxURI(url) -{ - Init(url); - ParseURL(); -} - -wxURL::wxURL(const wxURI& uri) : wxURI(uri) -{ - Init(uri.BuildURI()); - ParseURL(); -} - -wxURL::wxURL(const wxURL& url) : wxURI(url) -{ - Init(url.GetURL()); - ParseURL(); -} - -void wxURL::Init(const wxString& url) -{ - m_protocol = NULL; - m_error = wxURL_NOERR; - m_url = url; -#if wxUSE_URL_NATIVE - m_nativeImp = CreateNativeImpObject(); -#endif - -#if wxUSE_PROTOCOL_HTTP - if ( ms_useDefaultProxy && !ms_proxyDefault ) - { - SetDefaultProxy( wxGetenv(wxT("HTTP_PROXY")) ); - - if ( !ms_proxyDefault ) - { - // don't try again - ms_useDefaultProxy = false; - } - } - - m_useProxy = ms_proxyDefault != NULL; - m_proxy = ms_proxyDefault; -#endif // wxUSE_PROTOCOL_HTTP - -} - -// -------------------------------------------------------------- -// Assignment -// -------------------------------------------------------------- - -wxURL& wxURL::operator = (const wxString& url) -{ - wxURI::operator = (url); - Free(); - Init(url); - ParseURL(); - - return *this; -} - -wxURL& wxURL::operator = (const wxURI& uri) -{ - if (&uri != this) - { - wxURI::operator = (uri); - Free(); - Init(uri.BuildURI()); - ParseURL(); - } - - return *this; -} - -wxURL& wxURL::operator = (const wxURL& url) -{ - if (&url != this) - { - wxURI::operator = (url); - Free(); - Init(url.GetURL()); - ParseURL(); - } - - return *this; -} - -// -------------------------------------------------------------- -// ParseURL -// -// Builds the URL and takes care of the old protocol stuff -// -------------------------------------------------------------- - -bool wxURL::ParseURL() -{ - // If the URL was already parsed (m_protocol != NULL), pass this section. - if (!m_protocol) - { - // Clean up - CleanData(); - - // Make sure we have a protocol/scheme - if (!HasScheme()) - { - m_error = wxURL_SNTXERR; - return false; - } - - // Find and create the protocol object - if (!FetchProtocol()) - { - m_error = wxURL_NOPROTO; - return false; - } - - // Do we need a host name ? - if (m_protoinfo->m_needhost) - { - // Make sure we have one, then - if (!HasServer()) - { - m_error = wxURL_SNTXERR; - return false; - } - } - } - -#if wxUSE_PROTOCOL_HTTP - if (m_useProxy) - { - // Third, we rebuild the URL. - m_url = m_scheme + wxT(":"); - if (m_protoinfo->m_needhost) - m_url = m_url + wxT("//") + m_server; - - // We initialize specific variables. - if (m_protocol) - m_protocol->Destroy(); - m_protocol = m_proxy; // FIXME: we should clone the protocol - } -#endif // wxUSE_PROTOCOL_HTTP - - m_error = wxURL_NOERR; - return true; -} - -// -------------------------------------------------------------- -// Destruction/Cleanup -// -------------------------------------------------------------- - -void wxURL::CleanData() -{ -#if wxUSE_PROTOCOL_HTTP - if (!m_useProxy) -#endif // wxUSE_PROTOCOL_HTTP - { - if (m_protocol) - { - // Need to safely delete the socket (pending events) - m_protocol->Destroy(); - m_protocol = NULL; - } - } -} - -void wxURL::Free() -{ - CleanData(); -#if wxUSE_PROTOCOL_HTTP - if (m_proxy && m_proxy != ms_proxyDefault) - delete m_proxy; -#endif // wxUSE_PROTOCOL_HTTP -#if wxUSE_URL_NATIVE - delete m_nativeImp; -#endif -} - -wxURL::~wxURL() -{ - Free(); -} - -// -------------------------------------------------------------- -// FetchProtocol -// -------------------------------------------------------------- - -bool wxURL::FetchProtocol() -{ - wxProtoInfo *info = ms_protocols; - - while (info) - { - if (m_scheme == info->m_protoname) - { - if ( m_port.empty() ) - m_port = info->m_servname; - m_protoinfo = info; - m_protocol = (wxProtocol *)m_protoinfo->m_cinfo->CreateObject(); - return true; - } - info = info->next; - } - return false; -} - -// -------------------------------------------------------------- -// GetInputStream -// -------------------------------------------------------------- - -wxInputStream *wxURL::GetInputStream() -{ - if (!m_protocol) - { - m_error = wxURL_NOPROTO; - return NULL; - } - - m_error = wxURL_NOERR; - if (HasUserInfo()) - { - size_t dwPasswordPos = m_userinfo.find(':'); - - if (dwPasswordPos == wxString::npos) - m_protocol->SetUser(Unescape(m_userinfo)); - else - { - m_protocol->SetUser(Unescape(m_userinfo(0, dwPasswordPos))); - m_protocol->SetPassword(Unescape(m_userinfo(dwPasswordPos+1, m_userinfo.length() + 1))); - } - } - -#if wxUSE_URL_NATIVE - // give the native implementation to return a better stream - // such as the native WinINet functionality under MS-Windows - if (m_nativeImp) - { - wxInputStream *rc; - rc = m_nativeImp->GetInputStream(this); - if (rc != 0) - return rc; - } - // else use the standard behaviour -#endif // wxUSE_URL_NATIVE - -#if wxUSE_SOCKETS - wxIPV4address addr; - - // m_protoinfo is NULL when we use a proxy - if ( -#if wxUSE_PROTOCOL_HTTP - !m_useProxy && -#endif // wxUSE_PROTOCOL_HTTP - m_protoinfo->m_needhost ) - { - if (!addr.Hostname(m_server)) - { - m_error = wxURL_NOHOST; - return NULL; - } - - addr.Service(m_port); - - if (!m_protocol->Connect(addr, true)) // Watcom needs the 2nd arg for some reason - { - m_error = wxURL_CONNERR; - return NULL; - } - } -#endif // wxUSE_SOCKETS - - wxString fullPath; - -#if wxUSE_PROTOCOL_HTTP - // When we use a proxy, we have to pass the whole URL to it. - if (m_useProxy) - fullPath += m_url; -#endif // wxUSE_PROTOCOL_HTTP - - if(m_path.empty()) - fullPath += wxT("/"); - else - fullPath += m_path; - - if (HasQuery()) - fullPath += wxT("?") + m_query; - - if (HasFragment()) - fullPath += wxT("#") + m_fragment; - - wxInputStream *the_i_stream = m_protocol->GetInputStream(fullPath); - - if (!the_i_stream) - { - m_error = wxURL_PROTOERR; - return NULL; - } - - return the_i_stream; -} - -#if wxUSE_PROTOCOL_HTTP -void wxURL::SetDefaultProxy(const wxString& url_proxy) -{ - if ( !url_proxy ) - { - if ( ms_proxyDefault ) - { - ms_proxyDefault->Close(); - wxDELETE(ms_proxyDefault); - } - } - else - { - wxString tmp_str = url_proxy; - int pos = tmp_str.Find(wxT(':')); - if (pos == wxNOT_FOUND) - return; - - wxString hostname = tmp_str(0, pos), - port = tmp_str(pos+1, tmp_str.length()-pos); - wxIPV4address addr; - - if (!addr.Hostname(hostname)) - return; - if (!addr.Service(port)) - return; - - if (ms_proxyDefault) - // Finally, when all is right, we connect the new proxy. - ms_proxyDefault->Close(); - else - ms_proxyDefault = new wxHTTP(); - ms_proxyDefault->Connect(addr, true); // Watcom needs the 2nd arg for some reason - } -} - -void wxURL::SetProxy(const wxString& url_proxy) -{ - if ( !url_proxy ) - { - if ( m_proxy && m_proxy != ms_proxyDefault ) - { - m_proxy->Close(); - delete m_proxy; - } - - m_useProxy = false; - } - else - { - wxString tmp_str; - wxString hostname, port; - int pos; - wxIPV4address addr; - - tmp_str = url_proxy; - pos = tmp_str.Find(wxT(':')); - // This is an invalid proxy name. - if (pos == wxNOT_FOUND) - return; - - hostname = tmp_str(0, pos); - port = tmp_str(pos+1, tmp_str.length()-pos); - - addr.Hostname(hostname); - addr.Service(port); - - // Finally, create the whole stuff. - if (m_proxy && m_proxy != ms_proxyDefault) - delete m_proxy; - m_proxy = new wxHTTP(); - m_proxy->Connect(addr, true); // Watcom needs the 2nd arg for some reason - - CleanData(); - // Reparse url. - m_useProxy = true; - ParseURL(); - } -} -#endif // wxUSE_PROTOCOL_HTTP - -// ---------------------------------------------------------------------- -// wxURLModule -// -// A module which deletes the default proxy if we created it -// ---------------------------------------------------------------------- - -#if wxUSE_SOCKETS - -class wxURLModule : public wxModule -{ -public: - wxURLModule(); - - virtual bool OnInit(); - virtual void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxURLModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxURLModule, wxModule) - -wxURLModule::wxURLModule() -{ - // we must be cleaned up before wxSocketModule as otherwise deleting - // ms_proxyDefault from our OnExit() won't work (and can actually crash) - AddDependency(wxClassInfo::FindClass(wxT("wxSocketModule"))); -} - -bool wxURLModule::OnInit() -{ -#if wxUSE_PROTOCOL_HTTP - // env var HTTP_PROXY contains the address of the default proxy to use if - // set, but don't try to create this proxy right now because it will slow - // down the program startup (especially if there is no DNS server - // available, in which case it may take up to 1 minute) - - if ( wxGetenv(wxT("HTTP_PROXY")) ) - { - wxURL::ms_useDefaultProxy = true; - } -#endif // wxUSE_PROTOCOL_HTTP - return true; -} - -void wxURLModule::OnExit() -{ -#if wxUSE_PROTOCOL_HTTP - wxDELETE(wxURL::ms_proxyDefault); -#endif // wxUSE_PROTOCOL_HTTP -} - -#endif // wxUSE_SOCKETS - - -#endif // wxUSE_URL diff --git a/Source/3rd Party/wx/src/common/ustring.cpp b/Source/3rd Party/wx/src/common/ustring.cpp deleted file mode 100644 index ab70ce5ae..000000000 --- a/Source/3rd Party/wx/src/common/ustring.cpp +++ /dev/null @@ -1,537 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/ustring.cpp -// Purpose: wxUString class -// Author: Robert Roebling -// Created: 2008-07-25 -// Copyright: (c) 2008 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/ustring.h" - -#ifndef WX_PRECOMP - #include "wx/crt.h" - #include "wx/log.h" -#endif - -wxUString &wxUString::assignFromAscii( const char *str ) -{ - size_type len = wxStrlen( str ); - - wxU32CharBuffer buffer( len ); - wxChar32 *ptr = buffer.data(); - - size_type i; - for (i = 0; i < len; i++) - { - *ptr = *str; - ptr++; - str++; - } - - return assign( buffer ); -} - -wxUString &wxUString::assignFromAscii( const char *str, size_type n ) -{ - size_type len = 0; - const char *s = str; - while (len < n && *s) - { - len++; - s++; - } - - wxU32CharBuffer buffer( len ); - wxChar32 *ptr = buffer.data(); - - size_type i; - for (i = 0; i < len; i++) - { - *ptr = *str; - ptr++; - str++; - } - - return *this; -} - -// ---------------------------------------------------------------------------- -// UTF-8 -// ---------------------------------------------------------------------------- - -// this table gives the length of the UTF-8 encoding from its first character: -const unsigned char tableUtf8Lengths[256] = { - // single-byte sequences (ASCII): - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00..0F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10..1F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20..2F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30..3F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40..4F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50..5F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60..6F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70..7F - - // these are invalid: - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80..8F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90..9F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A0..AF - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B0..BF - 0, 0, // C0,C1 - - // two-byte sequences: - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C2..CF - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0..DF - - // three-byte sequences: - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0..EF - - // four-byte sequences: - 4, 4, 4, 4, 4, // F0..F4 - - // these are invalid again (5- or 6-byte - // sequences and sequences for code points - // above U+10FFFF, as restricted by RFC 3629): - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // F5..FF -}; - -wxUString &wxUString::assignFromUTF8( const char *str ) -{ - if (!str) - return assign( wxUString() ); - - size_type ucs4_len = 0; - const char *p = str; - while (*p) - { - unsigned char c = *p; - size_type len = tableUtf8Lengths[c]; - if (!len) - return assign( wxUString() ); // don't try to convert invalid UTF-8 - ucs4_len++; - p += len; - } - - wxU32CharBuffer buffer( ucs4_len ); - wxChar32 *out = buffer.data(); - - p = str; - while (*p) - { - unsigned char c = *p; - if (c < 0x80) - { - *out = c; - p++; - } - else - { - size_type len = tableUtf8Lengths[c]; // len == 0 is caught above - - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // ----------------------+---------------------------------------- - // 0000 0000 - 0000 007F | 0xxxxxxx - // 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Code point value is stored in bits marked with 'x', - // lowest-order bit of the value on the right side in the diagram - // above. (from RFC 3629) - - // mask to extract lead byte's value ('x' bits above), by sequence - // length: - static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 }; - - // mask and value of lead byte's most significant bits, by length: - static const unsigned char leadMarkerMask[] = { 0x80, 0xE0, 0xF0, 0xF8 }; - static const unsigned char leadMarkerVal[] = { 0x00, 0xC0, 0xE0, 0xF0 }; - - len--; // it's more convenient to work with 0-based length here - - // extract the lead byte's value bits: - if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] ) - break; - - wxChar32 code = c & leadValueMask[len]; - - // all remaining bytes, if any, are handled in the same way - // regardless of sequence's length: - for ( ; len; --len ) - { - c = *++p; - if ( (c & 0xC0) != 0x80 ) - return assign( wxUString() ); // don't try to convert invalid UTF-8 - - code <<= 6; - code |= c & 0x3F; - } - - *out = code; - p++; - } - out++; - } - - return assign( buffer.data() ); -} - -wxUString &wxUString::assignFromUTF8( const char *str, size_type n ) -{ - if (!str) - return assign( wxUString() ); - - size_type ucs4_len = 0; - size_type utf8_pos = 0; - const char *p = str; - while (*p) - { - unsigned char c = *p; - size_type len = tableUtf8Lengths[c]; - if (!len) - return assign( wxUString() ); // don't try to convert invalid UTF-8 - if (utf8_pos + len > n) - break; - utf8_pos += len; - ucs4_len ++; - p += len; - } - - wxU32CharBuffer buffer( ucs4_len ); - wxChar32 *out = buffer.data(); - - utf8_pos = 0; - p = str; - while (*p) - { - unsigned char c = *p; - if (c < 0x80) - { - if (utf8_pos + 1 > n) - break; - utf8_pos++; - - *out = c; - p++; - } - else - { - size_type len = tableUtf8Lengths[c]; // len == 0 is caught above - if (utf8_pos + len > n) - break; - utf8_pos += len; - - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // ----------------------+---------------------------------------- - // 0000 0000 - 0000 007F | 0xxxxxxx - // 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Code point value is stored in bits marked with 'x', - // lowest-order bit of the value on the right side in the diagram - // above. (from RFC 3629) - - // mask to extract lead byte's value ('x' bits above), by sequence - // length: - static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 }; - - // mask and value of lead byte's most significant bits, by length: - static const unsigned char leadMarkerMask[] = { 0x80, 0xE0, 0xF0, 0xF8 }; - static const unsigned char leadMarkerVal[] = { 0x00, 0xC0, 0xE0, 0xF0 }; - - len--; // it's more convenient to work with 0-based length here - - // extract the lead byte's value bits: - if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] ) - break; - - wxChar32 code = c & leadValueMask[len]; - - // all remaining bytes, if any, are handled in the same way - // regardless of sequence's length: - for ( ; len; --len ) - { - c = *++p; - if ( (c & 0xC0) != 0x80 ) - return assign( wxUString() ); // don't try to convert invalid UTF-8 - - code <<= 6; - code |= c & 0x3F; - } - - *out = code; - p++; - } - out++; - } - - *out = 0; - - return assign( buffer.data() ); -} - -wxUString &wxUString::assignFromUTF16( const wxChar16* str, size_type n ) -{ - if (!str) - return assign( wxUString() ); - - size_type ucs4_len = 0; - size_type utf16_pos = 0; - const wxChar16 *p = str; - while (*p) - { - size_type len; - if ((*p < 0xd800) || (*p > 0xdfff)) - { - len = 1; - } - else if ((p[1] < 0xdc00) || (p[1] > 0xdfff)) - { - return assign( wxUString() ); // don't try to convert invalid UTF-16 - } - else - { - len = 2; - } - - if (utf16_pos + len > n) - break; - - ucs4_len++; - p += len; - utf16_pos += len; - } - - wxU32CharBuffer buffer( ucs4_len ); - wxChar32 *out = buffer.data(); - - utf16_pos = 0; - - p = str; - while (*p) - { - if ((*p < 0xd800) || (*p > 0xdfff)) - { - if (utf16_pos + 1 > n) - break; - - *out = *p; - p++; - utf16_pos++; - } - else - { - if (utf16_pos + 2 > n) - break; - - *out = ((p[0] - 0xd7c0) << 10) + (p[1] - 0xdc00); - p += 2; - utf16_pos += 2; - } - out++; - } - - return assign( buffer.data() ); -} - -wxUString &wxUString::assignFromUTF16( const wxChar16* str ) -{ - if (!str) - return assign( wxUString() ); - - size_type ucs4_len = 0; - const wxChar16 *p = str; - while (*p) - { - size_type len; - if ((*p < 0xd800) || (*p > 0xdfff)) - { - len = 1; - } - else if ((p[1] < 0xdc00) || (p[1] > 0xdfff)) - { - return assign( wxUString() ); // don't try to convert invalid UTF-16 - } - else - { - len = 2; - } - - ucs4_len++; - p += len; - } - - wxU32CharBuffer buffer( ucs4_len ); - wxChar32 *out = buffer.data(); - - p = str; - while (*p) - { - if ((*p < 0xd800) || (*p > 0xdfff)) - { - *out = *p; - p++; - } - else - { - *out = ((p[0] - 0xd7c0) << 10) + (p[1] - 0xdc00); - p += 2; - } - out++; - } - - return assign( buffer.data() ); -} - -wxUString &wxUString::assignFromCString( const char* str ) -{ - if (!str) - return assign( wxUString() ); - - wxScopedWCharBuffer buffer = wxConvLibc.cMB2WC( str ); - - return assign( buffer ); -} - -wxUString &wxUString::assignFromCString( const char* str, const wxMBConv &conv ) -{ - if (!str) - return assign( wxUString() ); - - wxScopedWCharBuffer buffer = conv.cMB2WC( str ); - - return assign( buffer ); -} - -wxScopedCharBuffer wxUString::utf8_str() const -{ - size_type utf8_length = 0; - const wxChar32 *ptr = data(); - - while (*ptr) - { - wxChar32 code = *ptr; - ptr++; - - if ( code <= 0x7F ) - { - utf8_length++; - } - else if ( code <= 0x07FF ) - { - utf8_length += 2; - } - else if ( code < 0xFFFF ) - { - utf8_length += 3; - } - else if ( code <= 0x10FFFF ) - { - utf8_length += 4; - } - else - { - // invalid range, skip - } - } - - wxCharBuffer result( utf8_length ); - - char *out = result.data(); - - ptr = data(); - while (*ptr) - { - wxChar32 code = *ptr; - ptr++; - - if ( code <= 0x7F ) - { - out[0] = (char)code; - out++; - } - else if ( code <= 0x07FF ) - { - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xC0 | code; - out += 2; - } - else if ( code < 0xFFFF ) - { - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xE0 | code; - out += 3; - } - else if ( code <= 0x10FFFF ) - { - out[3] = 0x80 | (code & 0x3F); code >>= 6; - out[2] = 0x80 | (code & 0x3F); code >>= 6; - out[1] = 0x80 | (code & 0x3F); code >>= 6; - out[0] = 0xF0 | code; - out += 4; - } - else - { - // invalid range, skip - } - } - - return result; -} - -wxScopedU16CharBuffer wxUString::utf16_str() const -{ - size_type utf16_length = 0; - const wxChar32 *ptr = data(); - - while (*ptr) - { - wxChar32 code = *ptr; - ptr++; - - // TODO: error range checks - - if (code < 0x10000) - utf16_length++; - else - utf16_length += 2; - } - - wxU16CharBuffer result( utf16_length ); - wxChar16 *out = result.data(); - - ptr = data(); - - while (*ptr) - { - wxChar32 code = *ptr; - ptr++; - - // TODO: error range checks - - if (code < 0x10000) - { - out[0] = code; - out++; - } - else - { - out[0] = (code - 0x10000) / 0x400 + 0xd800; - out[1] = (code - 0x10000) % 0x400 + 0xdc00; - out += 2; - } - } - - return result; -} diff --git a/Source/3rd Party/wx/src/common/utilscmn.cpp b/Source/3rd Party/wx/src/common/utilscmn.cpp index 6c7d0c351..e2835b7d7 100644 --- a/Source/3rd Party/wx/src/common/utilscmn.cpp +++ b/Source/3rd Party/wx/src/common/utilscmn.cpp @@ -1,9 +1,9 @@ -///////////////////////////////////////////////////////////////////////////// // Name: src/common/utilscmn.cpp // Purpose: Miscellaneous utility functions and classes // Author: Julian Smart // Modified by: // Created: 29/01/98 +// RCS-ID: $Id: utilscmn.cpp 66917 2011-02-16 21:51:31Z JS $ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -51,10 +51,9 @@ #include "wx/uri.h" #include "wx/mimetype.h" #include "wx/config.h" -#include "wx/versioninfo.h" #if defined(__WXWINCE__) && wxUSE_DATETIME - #include "wx/datetime.h" +#include "wx/datetime.h" #endif #include @@ -69,50 +68,156 @@ #endif #if wxUSE_GUI + #include "wx/colordlg.h" + #include "wx/fontdlg.h" #include "wx/notebook.h" #include "wx/statusbr.h" #endif // wxUSE_GUI #ifndef __WXWINCE__ - #include +#include #else - #include "wx/msw/wince/time.h" +#include "wx/msw/wince/time.h" #endif #ifdef __WXMAC__ - #include "wx/osx/private.h" +#include "wx/mac/private.h" +#ifndef __DARWIN__ +#include "InternetConfig.h" +#endif #endif -#if !defined(__WXWINCE__) +#if !defined(__MWERKS__) && !defined(__WXWINCE__) #include #include #endif -#if defined(__WINDOWS__) +#if defined(__WXMSW__) #include "wx/msw/private.h" - #include "wx/filesys.h" -#endif - -#if wxUSE_GUI && defined(__WXGTK__) - #include // for GTK_XXX_VERSION constants + #include "wx/msw/registry.h" + #include // needed for SHELLEXECUTEINFO #endif #if wxUSE_BASE +// ---------------------------------------------------------------------------- +// common data +// ---------------------------------------------------------------------------- + // ============================================================================ // implementation // ============================================================================ +#if WXWIN_COMPATIBILITY_2_4 + +wxChar * +copystring (const wxChar *s) +{ + if (s == NULL) s = wxEmptyString; + size_t len = wxStrlen (s) + 1; + + wxChar *news = new wxChar[len]; + memcpy (news, s, len * sizeof(wxChar)); // Should be the fastest + + return news; +} + +#endif // WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// String <-> Number conversions (deprecated) +// ---------------------------------------------------------------------------- + +#if WXWIN_COMPATIBILITY_2_4 + +WXDLLIMPEXP_DATA_BASE(const wxChar *) wxFloatToStringStr = wxT("%.2f"); +WXDLLIMPEXP_DATA_BASE(const wxChar *) wxDoubleToStringStr = wxT("%.2f"); + +void +StringToFloat (const wxChar *s, float *number) +{ + if (s && *s && number) + *number = (float) wxStrtod (s, (wxChar **) NULL); +} + +void +StringToDouble (const wxChar *s, double *number) +{ + if (s && *s && number) + *number = wxStrtod (s, (wxChar **) NULL); +} + +wxChar * +FloatToString (float number, const wxChar *fmt) +{ + static wxChar buf[256]; + + wxSprintf (buf, fmt, number); + return buf; +} + +wxChar * +DoubleToString (double number, const wxChar *fmt) +{ + static wxChar buf[256]; + + wxSprintf (buf, fmt, number); + return buf; +} + +void +StringToInt (const wxChar *s, int *number) +{ + if (s && *s && number) + *number = (int) wxStrtol (s, (wxChar **) NULL, 10); +} + +void +StringToLong (const wxChar *s, long *number) +{ + if (s && *s && number) + *number = wxStrtol (s, (wxChar **) NULL, 10); +} + +wxChar * +IntToString (int number) +{ + static wxChar buf[20]; + + wxSprintf (buf, wxT("%d"), number); + return buf; +} + +wxChar * +LongToString (long number) +{ + static wxChar buf[20]; + + wxSprintf (buf, wxT("%ld"), number); + return buf; +} + +#endif // WXWIN_COMPATIBILITY_2_4 + // Array used in DecToHex conversion routine. -static const wxChar hexArray[] = wxT("0123456789ABCDEF"); +static wxChar hexArray[] = wxT("0123456789ABCDEF"); // Convert 2-digit hex number to decimal -int wxHexToDec(const wxString& str) +int wxHexToDec(const wxString& buf) { - char buf[2]; - buf[0] = str.GetChar(0); - buf[1] = str.GetChar(1); - return wxHexToDec((const char*) buf); + int firstDigit, secondDigit; + + if (buf.GetChar(0) >= wxT('A')) + firstDigit = buf.GetChar(0) - wxT('A') + 10; + else + firstDigit = buf.GetChar(0) - wxT('0'); + + if (buf.GetChar(1) >= wxT('A')) + secondDigit = buf.GetChar(1) - wxT('A') + 10; + else + secondDigit = buf.GetChar(1) - wxT('0'); + + return (firstDigit & 0xF) * 16 + (secondDigit & 0xF ); } // Convert decimal integer to 2-character hex string @@ -125,15 +230,6 @@ void wxDecToHex(int dec, wxChar *buf) buf[2] = 0; } -// Convert decimal integer to 2 characters -void wxDecToHex(int dec, char* ch1, char* ch2) -{ - int firstDigit = (int)(dec/16.0); - int secondDigit = (int)(dec - (firstDigit*16.0)); - (*ch1) = (char) hexArray[firstDigit]; - (*ch2) = (char) hexArray[secondDigit]; -} - // Convert decimal integer to 2-character hex string wxString wxDecToHex(int dec) { @@ -157,19 +253,17 @@ wxString wxNow() return wxEmptyString; #endif #else - time_t now = time(NULL); + time_t now = time((time_t *) NULL); char *date = ctime(&now); date[24] = '\0'; return wxString::FromAscii(date); #endif } -#if WXWIN_COMPATIBILITY_2_8 void wxUsleep(unsigned long milliseconds) { wxMilliSleep(milliseconds); } -#endif const wxChar *wxGetInstallPrefix() { @@ -206,10 +300,6 @@ bool wxIsPlatformLittleEndian() } -// ---------------------------------------------------------------------------- -// wxPlatform -// ---------------------------------------------------------------------------- - /* * Class to make it easier to specify platform-dependent values */ @@ -340,14 +430,15 @@ void wxPlatform::AddPlatform(int platform) void wxPlatform::ClearPlatforms() { - wxDELETE(sm_customPlatforms); + delete sm_customPlatforms; + sm_customPlatforms = NULL; } /// Function for testing current platform bool wxPlatform::Is(int platform) { -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if (platform == wxOS_WINDOWS) return true; #endif @@ -387,6 +478,10 @@ bool wxPlatform::Is(int platform) if (platform == wxOS_UNIX) return true; #endif +#ifdef __WXMGL__ + if (platform == wxPORT_MGL) + return true; +#endif #ifdef __OS2__ if (platform == wxOS_OS2) return true; @@ -417,7 +512,8 @@ bool wxGetEmailAddress(wxChar *address, int maxSize) if ( !email ) return false; - wxStrlcpy(address, email.t_str(), maxSize); + wxStrncpy(address, email, maxSize - 1); + address[maxSize - 1] = wxT('\0'); return true; } @@ -515,7 +611,7 @@ wxString wxGetCurrentDir() { if ( errno != ERANGE ) { - wxLogSysError(wxT("Failed to get current directory")); + wxLogSysError(_T("Failed to get current directory")); return wxEmptyString; } @@ -533,111 +629,22 @@ wxString wxGetCurrentDir() #endif // 0 -// ---------------------------------------------------------------------------- -// Environment -// ---------------------------------------------------------------------------- - -#ifdef __WXOSX__ -#if wxOSX_USE_COCOA_OR_CARBON - #include -#endif -#endif - -bool wxGetEnvMap(wxEnvVariableHashMap *map) -{ - wxCHECK_MSG( map, false, wxS("output pointer can't be NULL") ); - -#if defined(__VISUALC__) - // This variable only exists to force the CRT to fill the wide char array, - // it might only have it in narrow char version until now as we use main() - // (and not _wmain()) as our entry point. - static wxChar* s_dummyEnvVar = _tgetenv(wxT("TEMP")); - - wxChar **env = _tenviron; -#elif defined(__VMS) - // Now this routine wil give false for OpenVMS - // TODO : should we do something with logicals? - char **env=NULL; -#elif defined(__DARWIN__) -#if wxOSX_USE_COCOA_OR_CARBON - // Under Mac shared libraries don't have access to the global environ - // variable so use this Mac-specific function instead as advised by - // environ(7) under Darwin - char ***penv = _NSGetEnviron(); - if ( !penv ) - return false; - char **env = *penv; -#else - char **env=NULL; - // todo translate NSProcessInfo environment into map -#endif -#else // non-MSVC non-Mac - // Not sure if other compilers have _tenviron so use the (more standard) - // ANSI version only for them. - - // Both POSIX and Single UNIX Specification say that this variable must - // exist but not that it must be declared anywhere and, indeed, it's not - // declared in several common systems (some BSDs, Solaris with native CC) - // so we (re)declare it ourselves to deal with these cases. However we do - // not do this under MSW where there can be DLL-related complications, i.e. - // the variable might be DLL-imported or not. Luckily we don't have to - // worry about this as all MSW compilers do seem to define it in their - // standard headers anyhow so we can just rely on already having the - // correct declaration. And if this turns out to be wrong, we can always - // add a configure test checking whether it is declared later. -#ifndef __WINDOWS__ - extern char **environ; -#endif // !__WINDOWS__ - - char **env = environ; -#endif - - if ( env ) - { - wxString name, - value; - while ( *env ) - { - const wxString var(*env); - - name = var.BeforeFirst(wxS('='), &value); - - (*map)[name] = value; - - env++; - } - - return true; - } - - return false; -} - // ---------------------------------------------------------------------------- // wxExecute // ---------------------------------------------------------------------------- -// wxDoExecuteWithCapture() helper: reads an entire stream into one array if -// the stream is non-NULL (it doesn't do anything if it's NULL). +// wxDoExecuteWithCapture() helper: reads an entire stream into one array // // returns true if ok, false if error #if wxUSE_STREAMS static bool ReadAll(wxInputStream *is, wxArrayString& output) { - if ( !is ) - return true; + wxCHECK_MSG( is, false, _T("NULL stream in wxExecute()?") ); // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state is->Reset(); - // Notice that wxTextInputStream doesn't work correctly with wxConvAuto - // currently, see #14720, so use the current locale conversion explicitly - // under assumption that any external program should be using it too. - wxTextInputStream tis(*is, " \t" -#if wxUSE_UNICODE - , wxConvLibc -#endif - ); + wxTextInputStream tis(*is); for ( ;; ) { @@ -669,26 +676,26 @@ static bool ReadAll(wxInputStream *is, wxArrayString& output) static long wxDoExecuteWithCapture(const wxString& command, wxArrayString& output, wxArrayString* error, - int flags, - const wxExecuteEnv *env) + int flags) { // create a wxProcess which will capture the output wxProcess *process = new wxProcess; process->Redirect(); - long rc = wxExecute(command, wxEXEC_SYNC | flags, process, env); + long rc = wxExecute(command, wxEXEC_SYNC | flags, process); #if wxUSE_STREAMS - // Notice that while -1 indicates an error exit code for us, a program - // exiting with this code could still have written something to its stdout - // and, especially, stderr, so we still need to read from them. - if ( !ReadAll(process->GetInputStream(), output) ) - rc = -1; - - if ( error ) + if ( rc != -1 ) { - if ( !ReadAll(process->GetErrorStream(), *error) ) + if ( !ReadAll(process->GetInputStream(), output) ) rc = -1; + + if ( error ) + { + if ( !ReadAll(process->GetErrorStream(), *error) ) + rc = -1; + } + } #else wxUnusedVar(output); @@ -700,337 +707,215 @@ static long wxDoExecuteWithCapture(const wxString& command, return rc; } -long wxExecute(const wxString& command, wxArrayString& output, int flags, - const wxExecuteEnv *env) +long wxExecute(const wxString& command, wxArrayString& output, int flags) { - return wxDoExecuteWithCapture(command, output, NULL, flags, env); + return wxDoExecuteWithCapture(command, output, NULL, flags); } long wxExecute(const wxString& command, wxArrayString& output, wxArrayString& error, - int flags, - const wxExecuteEnv *env) + int flags) { - return wxDoExecuteWithCapture(command, output, &error, flags, env); + return wxDoExecuteWithCapture(command, output, &error, flags); } -// ---------------------------------------------------------------------------- -// Id functions -// ---------------------------------------------------------------------------- - -// Id generation -static int wxCurrentId = 100; - -int wxNewId() -{ - // skip the part of IDs space that contains hard-coded values: - if (wxCurrentId == wxID_LOWEST) - wxCurrentId = wxID_HIGHEST + 1; - - return wxCurrentId++; -} - -int -wxGetCurrentId(void) { return wxCurrentId; } - -void -wxRegisterId (int id) -{ - if (id >= wxCurrentId) - wxCurrentId = id + 1; -} - -// ---------------------------------------------------------------------------- -// wxQsort, adapted by RR to allow user_data -// ---------------------------------------------------------------------------- - -/* This file is part of the GNU C Library. - Written by Douglas C. Schmidt (schmidt@ics.uci.edu). - - Douglas Schmidt kindly gave permission to relicence the - code under the wxWindows licence: - -From: "Douglas C. Schmidt" -To: Robert Roebling -Subject: Re: qsort licence -Date: Mon, 23 Jul 2007 03:44:25 -0500 -Sender: schmidt@dre.vanderbilt.edu -Message-Id: <20070723084426.64F511000A8@tango.dre.vanderbilt.edu> - -Hi Robert, - -> [...] I'm asking if you'd be willing to relicence your code -> under the wxWindows licence. [...] - -That's fine with me [...] - -Thanks, - - Doug */ - - -/* Byte-wise swap two items of size SIZE. */ -#define SWAP(a, b, size) \ - do \ - { \ - size_t __size = (size); \ - char *__a = (a), *__b = (b); \ - do \ - { \ - char __tmp = *__a; \ - *__a++ = *__b; \ - *__b++ = __tmp; \ - } while (--__size > 0); \ - } while (0) - -/* Discontinue quicksort algorithm when partition gets below this size. - This particular magic number was chosen to work best on a Sun 4/260. */ -#define MAX_THRESH 4 - -/* Stack node declarations used to store unfulfilled partition obligations. */ -typedef struct - { - char *lo; - char *hi; - } stack_node; - -/* The next 4 #defines implement a very fast in-line stack abstraction. */ -#define STACK_SIZE (8 * sizeof(unsigned long int)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) - - -/* Order size using quicksort. This implementation incorporates - four optimizations discussed in Sedgewick: - - 1. Non-recursive, using an explicit stack of pointer that store the - next array partition to sort. To save time, this maximum amount - of space required to store an array of MAX_INT is allocated on the - stack. Assuming a 32-bit integer, this needs only 32 * - sizeof(stack_node) == 136 bits. Pretty cheap, actually. - - 2. Chose the pivot element using a median-of-three decision tree. - This reduces the probability of selecting a bad pivot value and - eliminates certain extraneous comparisons. - - 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving - insertion sort to order the MAX_THRESH items within each partition. - This is a big win, since insertion sort is faster for small, mostly - sorted array segments. - - 4. The larger of the two sub-partitions is always pushed onto the - stack first, with the algorithm then concentrating on the - smaller partition. This *guarantees* no more than log (n) - stack size is needed (actually O(1) in this case)! */ - -void wxQsort(void* pbase, size_t total_elems, - size_t size, wxSortCallback cmp, const void* user_data) -{ - char *base_ptr = (char *) pbase; - const size_t max_thresh = MAX_THRESH * size; - - if (total_elems == 0) - /* Avoid lossage with unsigned arithmetic below. */ - return; - - if (total_elems > MAX_THRESH) - { - char *lo = base_ptr; - char *hi = &lo[size * (total_elems - 1)]; - stack_node stack[STACK_SIZE]; - stack_node *top = stack; - - PUSH (NULL, NULL); - - while (STACK_NOT_EMPTY) - { - char *left_ptr; - char *right_ptr; - - /* Select median value from among LO, MID, and HI. Rearrange - LO and HI so the three values are sorted. This lowers the - probability of picking a pathological pivot value and - skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ - - char *mid = lo + size * ((hi - lo) / size >> 1); - - if ((*cmp) ((void *) mid, (void *) lo, user_data) < 0) - SWAP (mid, lo, size); - if ((*cmp) ((void *) hi, (void *) mid, user_data) < 0) - SWAP (mid, hi, size); - else - goto jump_over; - if ((*cmp) ((void *) mid, (void *) lo, user_data) < 0) - SWAP (mid, lo, size); - jump_over:; - left_ptr = lo + size; - right_ptr = hi - size; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do - { - while ((*cmp) ((void *) left_ptr, (void *) mid, user_data) < 0) - left_ptr += size; - - while ((*cmp) ((void *) mid, (void *) right_ptr, user_data) < 0) - right_ptr -= size; - - if (left_ptr < right_ptr) - { - SWAP (left_ptr, right_ptr, size); - if (mid == left_ptr) - mid = right_ptr; - else if (mid == right_ptr) - mid = left_ptr; - left_ptr += size; - right_ptr -= size; - } - else if (left_ptr == right_ptr) - { - left_ptr += size; - right_ptr -= size; - break; - } - } - while (left_ptr <= right_ptr); - - /* Set up pointers for next iteration. First determine whether - left and right partitions are below the threshold size. If so, - ignore one or both. Otherwise, push the larger partition's - bounds on the stack and continue sorting the smaller one. */ - - if ((size_t) (right_ptr - lo) <= max_thresh) - { - if ((size_t) (hi - left_ptr) <= max_thresh) - /* Ignore both small partitions. */ - POP (lo, hi); - else - /* Ignore small left partition. */ - lo = left_ptr; - } - else if ((size_t) (hi - left_ptr) <= max_thresh) - /* Ignore small right partition. */ - hi = right_ptr; - else if ((right_ptr - lo) > (hi - left_ptr)) - { - /* Push larger left partition indices. */ - PUSH (lo, right_ptr); - lo = left_ptr; - } - else - { - /* Push larger right partition indices. */ - PUSH (left_ptr, hi); - hi = right_ptr; - } - } - } - - /* Once the BASE_PTR array is partially sorted by quicksort the rest - is completely sorted using insertion sort, since this is efficient - for partitions below MAX_THRESH size. BASE_PTR points to the beginning - of the array to sort, and END_PTR points at the very last element in - the array (*not* one beyond it!). */ - - { - char *const end_ptr = &base_ptr[size * (total_elems - 1)]; - char *tmp_ptr = base_ptr; - char *thresh = base_ptr + max_thresh; - if ( thresh > end_ptr ) - thresh = end_ptr; - char *run_ptr; - - /* Find smallest element in first threshold and place it at the - array's beginning. This is the smallest array element, - and the operation speeds up insertion sort's inner loop. */ - - for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) - if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, user_data) < 0) - tmp_ptr = run_ptr; - - if (tmp_ptr != base_ptr) - SWAP (tmp_ptr, base_ptr, size); - - /* Insertion sort, running from left-hand-side up to right-hand-side. */ - - run_ptr = base_ptr + size; - while ((run_ptr += size) <= end_ptr) - { - tmp_ptr = run_ptr - size; - while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, user_data) < 0) - tmp_ptr -= size; - - tmp_ptr += size; - if (tmp_ptr != run_ptr) - { - char *trav; - - trav = run_ptr + size; - while (--trav >= run_ptr) - { - char c = *trav; - char *hi, *lo; - - for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) - *hi = *lo; - *hi = c; - } - } - } - } -} - -#endif // wxUSE_BASE - - - -// ============================================================================ -// GUI-only functions from now on -// ============================================================================ - -#if wxUSE_GUI - -// this function is only really implemented for X11-based ports, including GTK1 -// (GTK2 sets detectable auto-repeat automatically anyhow) -#if !(defined(__WXX11__) || defined(__WXMOTIF__) || \ - (defined(__WXGTK__) && !defined(__WXGTK20__))) -bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) -{ - return true; -} -#endif // !X11-based port - // ---------------------------------------------------------------------------- // Launch default browser // ---------------------------------------------------------------------------- -#if defined(__WINDOWS__) +#include "wx/private/browserhack28.h" -// implemented in a port-specific utils source file: -bool wxDoLaunchDefaultBrowser(const wxString& url, const wxString& scheme, int flags); +static bool wxLaunchDefaultBrowserBaseImpl(const wxString& url, int flags); -#elif defined(__WXX11__) || defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXCOCOA__) || \ - (defined(__WXOSX__) ) +// Use wxLaunchDefaultBrowserBaseImpl by default +static wxLaunchDefaultBrowserImpl_t s_launchBrowserImpl = &wxLaunchDefaultBrowserBaseImpl; -// implemented in a port-specific utils source file: -bool wxDoLaunchDefaultBrowser(const wxString& url, int flags); - -#else - -// a "generic" implementation: -bool wxDoLaunchDefaultBrowser(const wxString& url, int flags) +// Function the GUI library can call to provide a better implementation +WXDLLIMPEXP_BASE void wxSetLaunchDefaultBrowserImpl(wxLaunchDefaultBrowserImpl_t newImpl) { - // on other platforms try to use mime types or wxExecute... + s_launchBrowserImpl = newImpl!=NULL ? newImpl : &wxLaunchDefaultBrowserBaseImpl; +} + +static bool wxLaunchDefaultBrowserBaseImpl(const wxString& url, int flags) +{ + wxUnusedVar(flags); + +#if defined(__WXMSW__) + +#if wxUSE_IPC + if ( flags & wxBROWSER_NEW_WINDOW ) + { + // ShellExecuteEx() opens the URL in an existing window by default so + // we can't use it if we need a new window + wxURI uri(url); + wxRegKey key(wxRegKey::HKCR, uri.GetScheme() + _T("\\shell\\open")); + if ( !key.Exists() ) + { + // try default browser, it must be registered at least for http URLs + key.SetName(wxRegKey::HKCR, _T("http\\shell\\open")); + } + + if ( key.Exists() ) + { + wxRegKey keyDDE(key, wxT("DDEExec")); + if ( keyDDE.Exists() ) + { + // we only know the syntax of WWW_OpenURL DDE request for IE, + // optimistically assume that all other browsers are compatible + // with it + static const wxString TOPIC_OPEN_URL = wxT("WWW_OpenURL"); + wxString ddeCmd; + wxRegKey keyTopic(keyDDE, wxT("topic")); + bool ok = keyTopic.Exists() && (keyTopic.QueryDefaultValue() = TOPIC_OPEN_URL); + if ( ok ) + { + ddeCmd = keyDDE.QueryDefaultValue(); + ok = !ddeCmd.empty(); + } + + if ( ok ) + { + // for WWW_OpenURL, the index of the window to open the URL + // in is -1 (meaning "current") by default, replace it with + // 0 which means "new" (see KB article 160957) + ok = ddeCmd.Replace(wxT("-1"), wxT("0"), + false /* only first occurence */) == 1; + } + + if ( ok ) + { + // and also replace the parameters: the topic should + // contain a placeholder for the URL + ok = ddeCmd.Replace(wxT("%1"), url, false) == 1; + } + + if ( ok ) + { + // try to send it the DDE request now but ignore the errors + wxLogNull noLog; + + const wxString ddeServer = wxRegKey(keyDDE, wxT("application")).QueryDefaultValue(); + if ( wxExecuteDDE(ddeServer, TOPIC_OPEN_URL, ddeCmd) ) + return true; + + // this is not necessarily an error: maybe browser is + // simply not running, but no matter, in any case we're + // going to launch it using ShellExecuteEx() below now and + // we shouldn't try to open a new window if we open a new + // browser anyhow + } + } + } + } +#endif // wxUSE_IPC + + WinStruct sei; + sei.lpFile = url.c_str(); + sei.lpVerb = _T("open"); + sei.nShow = SW_SHOWNORMAL; + sei.fMask = SEE_MASK_FLAG_NO_UI; // we give error message ourselves + + BOOL nExecResult = ::ShellExecuteEx(&sei); + + //From MSDN for wince + //hInstApp member is only valid if the function fails, in which case it + //receives one of the following error values, which are less than or + //equal to 32. + const int nResult = (int) sei.hInstApp; + + // Firefox returns file not found for some reason, so make an exception + // for it + if ( nResult > 32 || nResult == SE_ERR_FNF || nExecResult == TRUE ) + { +#ifdef __WXDEBUG__ + // Log something if SE_ERR_FNF happens + if ( nResult == SE_ERR_FNF || nExecResult == FALSE ) + wxLogDebug(wxT("SE_ERR_FNF from ShellExecute -- maybe FireFox?")); +#endif // __WXDEBUG__ + return true; + } +#elif defined(__WXMAC__) + OSStatus err; + ICInstance inst; + long int startSel; + long int endSel; + + err = ICStart(&inst, 'STKA'); // put your app creator code here + if (err == noErr) + { +#if !TARGET_CARBON + err = ICFindConfigFile(inst, 0, NULL); +#endif + if (err == noErr) + { + ConstStr255Param hint = 0; + startSel = 0; + endSel = url.length(); + err = ICLaunchURL(inst, hint, url.fn_str(), endSel, &startSel, &endSel); + if (err != noErr) + wxLogDebug(wxT("ICLaunchURL error %d"), (int) err); + } + ICStop(inst); + return true; + } + else + { + wxLogDebug(wxT("ICStart error %d"), (int) err); + return false; + } +#else + // (non-Mac, non-MSW) + +#ifdef __UNIX__ + + // Our best best is to use xdg-open from freedesktop.org cross-desktop + // compatibility suite xdg-utils + // (see http://portland.freedesktop.org/wiki/) -- this is installed on + // most modern distributions and may be tweaked by them to handle + // distribution specifics. Only if that fails, try to find the right + // browser ourselves. + wxString path, xdg_open; + if ( wxGetEnv(_T("PATH"), &path) && + wxFindFileInPath(&xdg_open, path, _T("xdg-open")) ) + { + if ( wxExecute(xdg_open + _T(" ") + url) ) + return true; + } + + wxString desktop = wxTheApp->GetTraits()->GetDesktopEnvironment(); + + // GNOME and KDE desktops have some applications which should be always installed + // together with their main parts, which give us the + if (desktop == wxT("GNOME")) + { + wxArrayString errors; + wxArrayString output; + + // gconf will tell us the path of the application to use as browser + long res = wxExecute( wxT("gconftool-2 --get /desktop/gnome/applications/browser/exec"), + output, errors, wxEXEC_NODISABLE ); + if (res >= 0 && errors.GetCount() == 0) + { + wxString cmd = output[0]; + cmd << _T(' ') << url; + if (wxExecute(cmd)) + return true; + } + } + else if (desktop == wxT("KDE")) + { + // kfmclient directly opens the given URL + if (wxExecute(wxT("kfmclient openURL ") + url)) + return true; + } +#endif bool ok = false; wxString cmd; #if wxUSE_MIMETYPE - wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html")); + wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html")); if ( ft ) { wxString mt; @@ -1044,8 +929,9 @@ bool wxDoLaunchDefaultBrowser(const wxString& url, int flags) if ( !ok || cmd.empty() ) { // fallback to checking for the BROWSER environment variable - if ( !wxGetEnv(wxT("BROWSER"), &cmd) || cmd.empty() ) - cmd << wxT(' ') << url; + cmd = wxGetenv(wxT("BROWSER")); + if ( !cmd.empty() ) + cmd << _T(' ') << url; } ok = ( !cmd.empty() && wxExecute(cmd) ); @@ -1053,119 +939,87 @@ bool wxDoLaunchDefaultBrowser(const wxString& url, int flags) return ok; // no file type for HTML extension - wxLogError(_("No default application configured for HTML files.")); + wxLogError(_T("No default application configured for HTML files.")); +#endif // !wxUSE_MIMETYPE && !__WXMSW__ return false; } -#endif -static bool DoLaunchDefaultBrowserHelper(const wxString& urlOrig, int flags) +bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) { - // NOTE: we don't have to care about the wxBROWSER_NOBUSYCURSOR flag - // as it was already handled by wxLaunchDefaultBrowser - - wxUnusedVar(flags); - - wxString url(urlOrig), scheme; + // set the scheme of url to http if it does not have one + // RR: This doesn't work if the url is just a local path + wxString url(urlOrig); wxURI uri(url); - - // this check is useful to avoid that wxURI recognizes as scheme parts of - // the filename, in case urlOrig is a local filename - // (e.g. "C:\\test.txt" when parsed by wxURI reports a scheme == "C") - bool hasValidScheme = uri.HasScheme() && uri.GetScheme().length() > 1; - -#if defined(__WINDOWS__) - - // NOTE: when testing wxMSW's wxLaunchDefaultBrowser all possible forms - // of the URL/flags should be tested; e.g.: - // - // for (int i=0; i<2; i++) - // { - // // test arguments without a valid URL scheme: - // wxLaunchDefaultBrowser("C:\\test.txt", i==0 ? 0 : wxBROWSER_NEW_WINDOW); - // wxLaunchDefaultBrowser("wxwidgets.org", i==0 ? 0 : wxBROWSER_NEW_WINDOW); - // - // // test arguments with different valid schemes: - // wxLaunchDefaultBrowser("file:/C%3A/test.txt", i==0 ? 0 : wxBROWSER_NEW_WINDOW); - // wxLaunchDefaultBrowser("http://wxwidgets.org", i==0 ? 0 : wxBROWSER_NEW_WINDOW); - // wxLaunchDefaultBrowser("mailto:user@host.org", i==0 ? 0 : wxBROWSER_NEW_WINDOW); - // } - // (assuming you have a C:\test.txt file) - - if ( !hasValidScheme ) + if ( !uri.HasScheme() ) { - if (wxFileExists(urlOrig) || wxDirExists(urlOrig)) - { - scheme = "file"; - // do not prepend the file scheme to the URL as ShellExecuteEx() doesn't like it - } + if (wxFileExists(urlOrig)) + url.Prepend( wxT("file://") ); else - { - url.Prepend(wxS("http://")); - scheme = "http"; - } - } - else if ( hasValidScheme ) - { - scheme = uri.GetScheme(); - - if ( uri.GetScheme() == "file" ) - { - // TODO: extract URLToFileName() to some always compiled in - // function -#if wxUSE_FILESYSTEM - // ShellExecuteEx() doesn't like the "file" scheme when opening local files; - // remove it - url = wxFileSystem::URLToFileName(url).GetFullPath(); -#endif // wxUSE_FILESYSTEM - } + url.Prepend(wxT("http://")); } - if (wxDoLaunchDefaultBrowser(url, scheme, flags)) + if(s_launchBrowserImpl(url, flags)) return true; - //else: call wxLogSysError -#else - if ( !hasValidScheme ) - { - // set the scheme of url to "http" or "file" if it does not have one - if (wxFileExists(urlOrig) || wxDirExists(urlOrig)) - url.Prepend(wxS("file://")); - else - url.Prepend(wxS("http://")); - } - if (wxDoLaunchDefaultBrowser(url, flags)) - return true; - //else: call wxLogSysError -#endif - - wxLogSysError(_("Failed to open URL \"%s\" in default browser."), + wxLogSysError(_T("Failed to open URL \"%s\" in default browser."), url.c_str()); return false; } -bool wxLaunchDefaultBrowser(const wxString& url, int flags) +// ---------------------------------------------------------------------------- +// wxApp::Yield() wrappers for backwards compatibility +// ---------------------------------------------------------------------------- + +bool wxYield() { - // NOTE: as documented, "url" may be both a real well-formed URL - // and a local file name + return wxTheApp && wxTheApp->Yield(); +} - if ( flags & wxBROWSER_NOBUSYCURSOR ) - return DoLaunchDefaultBrowserHelper(url, flags); +bool wxYieldIfNeeded() +{ + return wxTheApp && wxTheApp->Yield(true); +} - wxBusyCursor bc; - return DoLaunchDefaultBrowserHelper(url, flags); +#endif // wxUSE_BASE + +// ============================================================================ +// GUI-only functions from now on +// ============================================================================ + +#if wxUSE_GUI + +// Id generation +static long wxCurrentId = 100; + +long wxNewId() +{ + // skip the part of IDs space that contains hard-coded values: + if (wxCurrentId == wxID_LOWEST) + wxCurrentId = wxID_HIGHEST + 1; + + return wxCurrentId++; +} + +long +wxGetCurrentId(void) { return wxCurrentId; } + +void +wxRegisterId (long id) +{ + if (id >= wxCurrentId) + wxCurrentId = id + 1; } // ---------------------------------------------------------------------------- // Menu accelerators related functions // ---------------------------------------------------------------------------- -#if WXWIN_COMPATIBILITY_2_6 wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out) { #if wxUSE_MENUS - wxString s = wxMenuItem::GetLabelText(in); + wxString s = wxMenuItem::GetLabelFromText(in); #else wxString str(in); wxString s = wxStripMenuCodes(str); @@ -1177,43 +1031,42 @@ wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out) } else { + // MYcopystring - for easier search... out = new wxChar[s.length() + 1]; wxStrcpy(out, s.c_str()); } return out; } -#endif wxString wxStripMenuCodes(const wxString& in, int flags) { - wxASSERT_MSG( flags, wxT("this is useless to call without any flags") ); + wxASSERT_MSG( flags, _T("this is useless to call without any flags") ); wxString out; size_t len = in.length(); out.reserve(len); - for ( wxString::const_iterator it = in.begin(); it != in.end(); ++it ) + for ( size_t n = 0; n < len; n++ ) { - wxChar ch = *it; - if ( (flags & wxStrip_Mnemonics) && ch == wxT('&') ) + wxChar ch = in[n]; + if ( (flags & wxStrip_Mnemonics) && ch == _T('&') ) { // skip it, it is used to introduce the accel char (or to quote // itself in which case it should still be skipped): note that it // can't be the last character of the string - if ( ++it == in.end() ) + if ( ++n == len ) { - wxLogDebug(wxT("Invalid menu string '%s'"), in.c_str()); - break; + wxLogDebug(_T("Invalid menu string '%s'"), in.c_str()); } else { // use the next char instead - ch = *it; + ch = in[n]; } } - else if ( (flags & wxStrip_Accel) && ch == wxT('\t') ) + else if ( (flags & wxStrip_Accel) && ch == _T('\t') ) { // everything after TAB is accel string, exit the loop break; @@ -1256,19 +1109,13 @@ wxFindWindowByName (const wxString& name, wxWindow * parent) // Returns menu item id or wxNOT_FOUND if none. int -wxFindMenuItemId(wxFrame *frame, - const wxString& menuString, - const wxString& itemString) +wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString) { #if wxUSE_MENUS wxMenuBar *menuBar = frame->GetMenuBar (); if ( menuBar ) return menuBar->FindMenuItem (menuString, itemString); -#else // !wxUSE_MENUS - wxUnusedVar(frame); - wxUnusedVar(menuString); - wxUnusedVar(itemString); -#endif // wxUSE_MENUS/!wxUSE_MENUS +#endif // wxUSE_MENUS return wxNOT_FOUND; } @@ -1286,7 +1133,7 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt) // Hack for wxNotebook case: at least in wxGTK, all pages // claim to be shown, so we must only deal with the selected one. #if wxUSE_NOTEBOOK - if (wxDynamicCast(win, wxNotebook)) + if (win->IsKindOf(CLASSINFO(wxNotebook))) { wxNotebook* nb = (wxNotebook*) win; int sel = nb->GetSelection(); @@ -1355,14 +1202,14 @@ wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt) int wxMessageBox(const wxString& message, const wxString& caption, long style, wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) ) { - // add the appropriate icon unless this was explicitly disabled by use of - // wxICON_NONE - if ( !(style & wxICON_NONE) && !(style & wxICON_MASK) ) + long decorated_style = style; + + if ( ( style & ( wxICON_EXCLAMATION | wxICON_HAND | wxICON_INFORMATION | wxICON_QUESTION ) ) == 0 ) { - style |= style & wxYES ? wxICON_QUESTION : wxICON_INFORMATION; + decorated_style |= ( style & wxYES ) ? wxICON_QUESTION : wxICON_INFORMATION ; } - wxMessageDialog dialog(parent, message, caption, style); + wxMessageDialog dialog(parent, message, caption, decorated_style); int ans = dialog.ShowModal(); switch ( ans ) @@ -1375,68 +1222,13 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style, return wxNO; case wxID_CANCEL: return wxCANCEL; - case wxID_HELP: - return wxHELP; } - wxFAIL_MSG( wxT("unexpected return code from wxMessageDialog") ); + wxFAIL_MSG( _T("unexpected return code from wxMessageDialog") ); return wxCANCEL; } -wxVersionInfo wxGetLibraryVersionInfo() -{ - // don't translate these strings, they're for diagnostics purposes only - wxString msg; - msg.Printf(wxS("wxWidgets Library (%s port)\n") - wxS("Version %d.%d.%d (Unicode: %s, debug level: %d),\n") - wxS("compiled at %s %s\n\n") - wxS("Runtime version of toolkit used is %d.%d.\n"), - wxPlatformInfo::Get().GetPortIdName(), - wxMAJOR_VERSION, - wxMINOR_VERSION, - wxRELEASE_NUMBER, -#if wxUSE_UNICODE_UTF8 - "UTF-8", -#elif wxUSE_UNICODE - "wchar_t", -#else - "none", -#endif - wxDEBUG_LEVEL, - __TDATE__, - __TTIME__, - wxPlatformInfo::Get().GetToolkitMajorVersion(), - wxPlatformInfo::Get().GetToolkitMinorVersion() - ); - -#ifdef __WXGTK__ - msg += wxString::Format("Compile-time GTK+ version is %d.%d.%d.\n", - GTK_MAJOR_VERSION, - GTK_MINOR_VERSION, - GTK_MICRO_VERSION); -#endif // __WXGTK__ - - return wxVersionInfo(wxS("wxWidgets"), - wxMAJOR_VERSION, - wxMINOR_VERSION, - wxRELEASE_NUMBER, - msg, - wxS("Copyright (c) 1995-2013 wxWidgets team")); -} - -void wxInfoMessageBox(wxWindow* parent) -{ - wxVersionInfo info = wxGetLibraryVersionInfo(); - wxString msg = info.ToString(); - - msg << wxS("\n") << info.GetCopyright(); - - wxMessageBox(msg, wxT("wxWidgets information"), - wxICON_INFORMATION | wxOK, - parent); -} - #endif // wxUSE_MSGDLG #if wxUSE_TEXTDLG @@ -1489,6 +1281,57 @@ wxString wxGetPasswordFromUser(const wxString& message, #endif // wxUSE_TEXTDLG +#if wxUSE_COLOURDLG + +wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit, const wxString& caption) +{ + static wxColourData data; + data.SetChooseFull(true); + if ( colInit.Ok() ) + { + data.SetColour((wxColour &)colInit); // const_cast + } + + wxColour colRet; + wxColourDialog dialog(parent, &data); + if (!caption.empty()) + dialog.SetTitle(caption); + if ( dialog.ShowModal() == wxID_OK ) + { + colRet = dialog.GetColourData().GetColour(); + } + //else: leave it invalid + + return colRet; +} + +#endif // wxUSE_COLOURDLG + +#if wxUSE_FONTDLG + +wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit, const wxString& caption) +{ + wxFontData data; + if ( fontInit.Ok() ) + { + data.SetInitialFont(fontInit); + } + + wxFont fontRet; + wxFontDialog dialog(parent, data); + if (!caption.empty()) + dialog.SetTitle(caption); + if ( dialog.ShowModal() == wxID_OK ) + { + fontRet = dialog.GetFontData().GetChosenFont(); + } + //else: leave it invalid + + return fontRet; +} + +#endif // wxUSE_FONTDLG + // ---------------------------------------------------------------------------- // wxSafeYield and supporting functions // ---------------------------------------------------------------------------- @@ -1500,26 +1343,7 @@ void wxEnableTopLevelWindows(bool enable) node->GetData()->Enable(enable); } -#if defined(__WXOSX__) && wxOSX_USE_COCOA - -// defined in evtloop.mm - -#else - -wxWindowDisabler::wxWindowDisabler(bool disable) -{ - m_disabled = disable; - if ( disable ) - DoDisable(); -} - wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip) -{ - m_disabled = true; - DoDisable(winToSkip); -} - -void wxWindowDisabler::DoDisable(wxWindow *winToSkip) { // remember the top level windows which were already disabled, so that we // don't reenable them later @@ -1551,9 +1375,6 @@ void wxWindowDisabler::DoDisable(wxWindow *winToSkip) wxWindowDisabler::~wxWindowDisabler() { - if ( !m_disabled ) - return; - wxWindowList::compatibility_iterator node; for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { @@ -1568,8 +1389,6 @@ wxWindowDisabler::~wxWindowDisabler() delete m_winDisabled; } -#endif - // Yield to other apps/messages and disable user input to all windows except // the given one bool wxSafeYield(wxWindow *win, bool onlyIfNeeded) @@ -1585,18 +1404,14 @@ bool wxSafeYield(wxWindow *win, bool onlyIfNeeded) return rc; } -// ---------------------------------------------------------------------------- -// wxApp::Yield() wrappers for backwards compatibility -// ---------------------------------------------------------------------------- - -bool wxYield() +// Don't synthesize KeyUp events holding down a key and producing KeyDown +// events with autorepeat. On by default and always on in wxMSW. wxGTK version +// in utilsgtk.cpp. +#ifndef __WXGTK__ +bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) { - return wxTheApp && wxTheApp->Yield(); -} - -bool wxYieldIfNeeded() -{ - return wxTheApp && wxTheApp->Yield(true); + return true; // detectable auto-repeat is the only mode MSW supports } +#endif // !wxGTK #endif // wxUSE_GUI diff --git a/Source/3rd Party/wx/src/common/valgen.cpp b/Source/3rd Party/wx/src/common/valgen.cpp index 19c26df51..b010537ce 100644 --- a/Source/3rd Party/wx/src/common/valgen.cpp +++ b/Source/3rd Party/wx/src/common/valgen.cpp @@ -4,6 +4,7 @@ // Author: Kevin Smith // Modified by: // Created: Jan 22 1999 +// RCS-ID: $Id: valgen.cpp 39463 2006-05-29 21:26:35Z ABX $ // Copyright: (c) 1999 Kevin Smith // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,7 +38,6 @@ #endif #include "wx/spinctrl.h" -// #include "wx/datectrl.h" -- can't use it in this (core) file for now #if wxUSE_SPINBTN #include "wx/spinbutt.h" @@ -45,7 +45,6 @@ #if wxUSE_TOGGLEBTN #include "wx/tglbtn.h" #endif -#include "wx/filename.h" #include "wx/valgen.h" @@ -75,34 +74,6 @@ wxGenericValidator::wxGenericValidator(wxArrayInt *val) m_pArrayInt = val; } -#if wxUSE_DATETIME - -wxGenericValidator::wxGenericValidator(wxDateTime *val) -{ - Initialize(); - m_pDateTime = val; -} - -#endif // wxUSE_DATETIME - -wxGenericValidator::wxGenericValidator(wxFileName *val) -{ - Initialize(); - m_pFileName = val; -} - -wxGenericValidator::wxGenericValidator(float *val) -{ - Initialize(); - m_pFloat = val; -} - -wxGenericValidator::wxGenericValidator(double *val) -{ - Initialize(); - m_pDouble = val; -} - wxGenericValidator::wxGenericValidator(const wxGenericValidator& val) : wxValidator() { @@ -117,12 +88,6 @@ bool wxGenericValidator::Copy(const wxGenericValidator& val) m_pInt = val.m_pInt; m_pString = val.m_pString; m_pArrayInt = val.m_pArrayInt; -#if wxUSE_DATETIME - m_pDateTime = val.m_pDateTime; -#endif // wxUSE_DATETIME - m_pFileName = val.m_pFileName; - m_pFloat = val.m_pFloat; - m_pDouble = val.m_pDouble; return true; } @@ -135,7 +100,7 @@ bool wxGenericValidator::TransferToWindow(void) // bool controls #if wxUSE_CHECKBOX - if (wxDynamicCast(m_validatorWindow, wxCheckBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) ) { wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; if (m_pBool) @@ -146,7 +111,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_RADIOBTN - if (wxDynamicCast(m_validatorWindow, wxRadioButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) { wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; if (m_pBool) @@ -156,9 +121,8 @@ bool wxGenericValidator::TransferToWindow(void) } } else #endif - #if wxUSE_TOGGLEBTN - if (wxDynamicCast(m_validatorWindow, wxToggleButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxToggleButton)) ) { wxToggleButton * pControl = (wxToggleButton *) m_validatorWindow; if (m_pBool) @@ -167,22 +131,11 @@ bool wxGenericValidator::TransferToWindow(void) return true; } } else -#if (defined(__WXMAC__) || defined(__WXMSW__) || defined(__WXGTK20__)) && !defined(__WXUNIVERSAL__) - if (wxDynamicCast(m_validatorWindow, wxBitmapToggleButton)) - { - wxBitmapToggleButton * pControl = (wxBitmapToggleButton *) m_validatorWindow; - if (m_pBool) - { - pControl->SetValue(*m_pBool); - return true; - } - } else -#endif #endif // int controls #if wxUSE_GAUGE - if (wxDynamicCast(m_validatorWindow, wxGauge)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) { wxGauge* pControl = (wxGauge*) m_validatorWindow; if (m_pInt) @@ -193,7 +146,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_RADIOBOX - if (wxDynamicCast(m_validatorWindow, wxRadioBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) { wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; if (m_pInt) @@ -204,7 +157,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_SCROLLBAR - if (wxDynamicCast(m_validatorWindow, wxScrollBar)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) { wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; if (m_pInt) @@ -215,7 +168,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_SPINCTRL && !defined(__WXMOTIF__) - if (wxDynamicCast(m_validatorWindow, wxSpinCtrl)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) ) { wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow; if (m_pInt) @@ -226,7 +179,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_SPINBTN - if (wxDynamicCast(m_validatorWindow, wxSpinButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) { wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; if (m_pInt) @@ -237,7 +190,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_SLIDER - if (wxDynamicCast(m_validatorWindow, wxSlider)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) ) { wxSlider* pControl = (wxSlider*) m_validatorWindow; if (m_pInt) @@ -248,22 +201,9 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif - // date time controls -#if 0 // wxUSE_DATEPICKCTRL -- temporary fix for shared build linking - if (wxDynamicCast(m_validatorWindow, wxDatePickerCtrl)) - { - wxDatePickerCtrl* pControl = (wxDatePickerCtrl*) m_validatorWindow; - if (m_pDateTime) - { - pControl->SetValue(*m_pDateTime) ; - return true; - } - } else -#endif - // string controls #if wxUSE_BUTTON - if (wxDynamicCast(m_validatorWindow, wxButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) { wxButton* pControl = (wxButton*) m_validatorWindow; if (m_pString) @@ -274,7 +214,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_COMBOBOX - if (wxDynamicCast(m_validatorWindow, wxComboBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) { wxComboBox* pControl = (wxComboBox*) m_validatorWindow; if (m_pInt) @@ -297,7 +237,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_CHOICE - if (wxDynamicCast(m_validatorWindow, wxChoice)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) { wxChoice* pControl = (wxChoice*) m_validatorWindow; if (m_pInt) @@ -316,7 +256,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_STATTEXT - if (wxDynamicCast(m_validatorWindow, wxStaticText)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) { wxStaticText* pControl = (wxStaticText*) m_validatorWindow; if (m_pString) @@ -327,7 +267,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_TEXTCTRL - if (wxDynamicCast(m_validatorWindow, wxTextCtrl)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) { wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow; if (m_pString) @@ -342,28 +282,13 @@ bool wxGenericValidator::TransferToWindow(void) pControl->SetValue(str); return true; } - else if (m_pFileName) - { - pControl->SetValue(m_pFileName->GetFullPath()); - return true; - } - else if (m_pFloat) - { - pControl->SetValue(wxString::Format(wxT("%g"), *m_pFloat)); - return true; - } - else if (m_pDouble) - { - pControl->SetValue(wxString::Format(wxT("%g"), *m_pDouble)); - return true; - } } else #endif // array controls #if wxUSE_CHECKLISTBOX // NOTE: wxCheckListBox is a wxListBox, so wxCheckListBox MUST come first: - if (wxDynamicCast(m_validatorWindow, wxCheckListBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) { wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; if (m_pArrayInt) @@ -386,7 +311,7 @@ bool wxGenericValidator::TransferToWindow(void) } else #endif #if wxUSE_LISTBOX - if (wxDynamicCast(m_validatorWindow, wxListBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) { wxListBox* pControl = (wxListBox*) m_validatorWindow; if (m_pArrayInt) @@ -406,8 +331,7 @@ bool wxGenericValidator::TransferToWindow(void) } } else #endif - { // to match the last 'else' above - } + ; // to match the last 'else' above // unrecognized control, or bad pointer return false; @@ -421,7 +345,7 @@ bool wxGenericValidator::TransferFromWindow(void) // BOOL CONTROLS ************************************** #if wxUSE_CHECKBOX - if (wxDynamicCast(m_validatorWindow, wxCheckBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) ) { wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; if (m_pBool) @@ -432,7 +356,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_RADIOBTN - if (wxDynamicCast(m_validatorWindow, wxRadioButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) { wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; if (m_pBool) @@ -443,7 +367,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_TOGGLEBTN - if (wxDynamicCast(m_validatorWindow, wxToggleButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxToggleButton)) ) { wxToggleButton *pControl = (wxToggleButton *) m_validatorWindow; if (m_pBool) @@ -452,22 +376,11 @@ bool wxGenericValidator::TransferFromWindow(void) return true; } } else -#if (defined(__WXMAC__) || defined(__WXMSW__) || defined(__WXGTK20__)) && !defined(__WXUNIVERSAL__) - if (wxDynamicCast(m_validatorWindow, wxBitmapToggleButton)) - { - wxBitmapToggleButton *pControl = (wxBitmapToggleButton *) m_validatorWindow; - if (m_pBool) - { - *m_pBool = pControl->GetValue() ; - return true; - } - } else -#endif #endif // INT CONTROLS *************************************** #if wxUSE_GAUGE - if (wxDynamicCast(m_validatorWindow, wxGauge)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) { wxGauge* pControl = (wxGauge*) m_validatorWindow; if (m_pInt) @@ -478,7 +391,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_RADIOBOX - if (wxDynamicCast(m_validatorWindow, wxRadioBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) { wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; if (m_pInt) @@ -489,7 +402,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_SCROLLBAR - if (wxDynamicCast(m_validatorWindow, wxScrollBar)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) { wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; if (m_pInt) @@ -500,7 +413,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_SPINCTRL && !defined(__WXMOTIF__) - if (wxDynamicCast(m_validatorWindow, wxSpinCtrl)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) ) { wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow; if (m_pInt) @@ -511,7 +424,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_SPINBTN - if (wxDynamicCast(m_validatorWindow, wxSpinButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) { wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; if (m_pInt) @@ -522,7 +435,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_SLIDER - if (wxDynamicCast(m_validatorWindow, wxSlider)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) ) { wxSlider* pControl = (wxSlider*) m_validatorWindow; if (m_pInt) @@ -533,22 +446,9 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif - // DATE TIME CONTROLS ************************************ -#if 0 // wxUSE_DATEPICKCTRL -- temporary fix for shared build linking - if (wxDynamicCast(m_validatorWindow, wxDatePickerCtrl)) - { - wxDatePickerCtrl* pControl = (wxDatePickerCtrl*) m_validatorWindow; - if (m_pDateTime) - { - *m_pDateTime = pControl->GetValue() ; - return true; - } - } else -#endif - // STRING CONTROLS ************************************ #if wxUSE_BUTTON - if (wxDynamicCast(m_validatorWindow, wxButton)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) { wxButton* pControl = (wxButton*) m_validatorWindow; if (m_pString) @@ -559,7 +459,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_COMBOBOX - if (wxDynamicCast(m_validatorWindow, wxComboBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) { wxComboBox* pControl = (wxComboBox*) m_validatorWindow; if (m_pInt) @@ -578,7 +478,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_CHOICE - if (wxDynamicCast(m_validatorWindow, wxChoice)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) { wxChoice* pControl = (wxChoice*) m_validatorWindow; if (m_pInt) @@ -594,7 +494,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_STATTEXT - if (wxDynamicCast(m_validatorWindow, wxStaticText)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) { wxStaticText* pControl = (wxStaticText*) m_validatorWindow; if (m_pString) @@ -605,7 +505,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_TEXTCTRL - if (wxDynamicCast(m_validatorWindow, wxTextCtrl)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) { wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow; if (m_pString) @@ -618,28 +518,13 @@ bool wxGenericValidator::TransferFromWindow(void) *m_pInt = wxAtoi(pControl->GetValue()); return true; } - else if (m_pFileName) - { - m_pFileName->Assign(pControl->GetValue()); - return true; - } - else if (m_pFloat) - { - *m_pFloat = (float)wxAtof(pControl->GetValue()); - return true; - } - else if (m_pDouble) - { - *m_pDouble = wxAtof(pControl->GetValue()); - return true; - } } else #endif // ARRAY CONTROLS ************************************* #if wxUSE_CHECKLISTBOX // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox MUST come first: - if (wxDynamicCast(m_validatorWindow, wxCheckListBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) { wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; if (m_pArrayInt) @@ -663,7 +548,7 @@ bool wxGenericValidator::TransferFromWindow(void) } else #endif #if wxUSE_LISTBOX - if (wxDynamicCast(m_validatorWindow, wxListBox)) + if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) { wxListBox* pControl = (wxListBox*) m_validatorWindow; if (m_pArrayInt) @@ -696,16 +581,11 @@ bool wxGenericValidator::TransferFromWindow(void) */ void wxGenericValidator::Initialize() { - m_pBool = NULL; - m_pInt = NULL; - m_pString = NULL; - m_pArrayInt = NULL; -#if wxUSE_DATETIME - m_pDateTime = NULL; -#endif // wxUSE_DATETIME - m_pFileName = NULL; - m_pFloat = NULL; - m_pDouble = NULL; + m_pBool = 0; + m_pInt = 0; + m_pString = 0; + m_pArrayInt = 0; } -#endif // wxUSE_VALIDATORS +#endif + // wxUSE_VALIDATORS diff --git a/Source/3rd Party/wx/src/common/validate.cpp b/Source/3rd Party/wx/src/common/validate.cpp index 306cac028..e01711bae 100644 --- a/Source/3rd Party/wx/src/common/validate.cpp +++ b/Source/3rd Party/wx/src/common/validate.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: validate.cpp 39656 2006-06-09 21:21:53Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -33,7 +34,7 @@ bool wxValidator::ms_isSilent = false; wxValidator::wxValidator() { - m_validatorWindow = NULL; + m_validatorWindow = (wxWindow *) NULL; } wxValidator::~wxValidator() diff --git a/Source/3rd Party/wx/src/common/valnum.cpp b/Source/3rd Party/wx/src/common/valnum.cpp deleted file mode 100644 index 4b12bbf53..000000000 --- a/Source/3rd Party/wx/src/common/valnum.cpp +++ /dev/null @@ -1,299 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/valnum.cpp -// Purpose: Numeric validator classes implementation -// Author: Vadim Zeitlin based on the submission of Fulvio Senore -// Created: 2010-11-06 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// Declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" - #include "wx/combobox.h" -#endif - -#include "wx/valnum.h" -#include "wx/numformatter.h" - -// ============================================================================ -// wxNumValidatorBase implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxNumValidatorBase, wxValidator) - EVT_CHAR(wxNumValidatorBase::OnChar) - EVT_KILL_FOCUS(wxNumValidatorBase::OnKillFocus) -END_EVENT_TABLE() - -int wxNumValidatorBase::GetFormatFlags() const -{ - int flags = wxNumberFormatter::Style_None; - if ( m_style & wxNUM_VAL_THOUSANDS_SEPARATOR ) - flags |= wxNumberFormatter::Style_WithThousandsSep; - if ( m_style & wxNUM_VAL_NO_TRAILING_ZEROES ) - flags |= wxNumberFormatter::Style_NoTrailingZeroes; - - return flags; -} - -wxTextEntry *wxNumValidatorBase::GetTextEntry() const -{ -#if wxUSE_TEXTCTRL - if ( wxTextCtrl *text = wxDynamicCast(m_validatorWindow, wxTextCtrl) ) - return text; -#endif // wxUSE_TEXTCTRL - -#if wxUSE_COMBOBOX - if ( wxComboBox *combo = wxDynamicCast(m_validatorWindow, wxComboBox) ) - return combo; -#endif // wxUSE_COMBOBOX - - wxFAIL_MSG("Can only be used with wxTextCtrl or wxComboBox"); - - return NULL; -} - -void -wxNumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val, - int& pos) const -{ - wxTextEntry * const control = GetTextEntry(); - if ( !control ) - return; - - val = control->GetValue(); - pos = control->GetInsertionPoint(); - - long selFrom, selTo; - control->GetSelection(&selFrom, &selTo); - - const long selLen = selTo - selFrom; - if ( selLen ) - { - // Remove selected text because pressing a key would make it disappear. - val.erase(selFrom, selLen); - - // And adjust the insertion point to have correct position in the new - // string. - if ( pos > selFrom ) - { - if ( pos >= selTo ) - pos -= selLen; - else - pos = selFrom; - } - } -} - -bool wxNumValidatorBase::IsMinusOk(const wxString& val, int pos) const -{ - // Minus is only ever accepted in the beginning of the string. - if ( pos != 0 ) - return false; - - // And then only if there is no existing minus sign there. - if ( !val.empty() && val[0] == '-' ) - return false; - - return true; -} - -void wxNumValidatorBase::OnChar(wxKeyEvent& event) -{ - // By default we just validate this key so don't prevent the normal - // handling from taking place. - event.Skip(); - - if ( !m_validatorWindow ) - return; - -#if wxUSE_UNICODE - const int ch = event.GetUnicodeKey(); - if ( ch == WXK_NONE ) - { - // It's a character without any Unicode equivalent at all, e.g. cursor - // arrow or function key, we never filter those. - return; - } -#else // !wxUSE_UNICODE - const int ch = event.GetKeyCode(); - if ( ch > WXK_DELETE ) - { - // Not a character neither. - return; - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE - - if ( ch < WXK_SPACE || ch == WXK_DELETE ) - { - // Allow ASCII control characters and Delete. - return; - } - - // Check if this character is allowed in the current state. - wxString val; - int pos; - GetCurrentValueAndInsertionPoint(val, pos); - - if ( !IsCharOk(val, pos, ch) ) - { - if ( !wxValidator::IsSilent() ) - wxBell(); - - // Do not skip the event in this case, stop handling it here. - event.Skip(false); - } -} - -void wxNumValidatorBase::OnKillFocus(wxFocusEvent& event) -{ - wxTextEntry * const control = GetTextEntry(); - if ( !control ) - return; - - // When we change the control value below, its "modified" status is reset - // so we need to explicitly keep it marked as modified if it was so in the - // first place. - // - // Notice that only wxTextCtrl (and not wxTextEntry) has - // IsModified()/MarkDirty() methods hence the need for dynamic cast. - wxTextCtrl * const text = wxDynamicCast(m_validatorWindow, wxTextCtrl); - const bool wasModified = text ? text->IsModified() : false; - - control->ChangeValue(NormalizeString(control->GetValue())); - - if ( wasModified ) - text->MarkDirty(); - - event.Skip(); -} - -// ============================================================================ -// wxIntegerValidatorBase implementation -// ============================================================================ - -wxString wxIntegerValidatorBase::ToString(LongestValueType value) const -{ - return wxNumberFormatter::ToString(value, GetFormatFlags()); -} - -bool -wxIntegerValidatorBase::FromString(const wxString& s, LongestValueType *value) -{ - return wxNumberFormatter::FromString(s, value); -} - -bool -wxIntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const -{ - // We may accept minus sign if we can represent negative numbers at all. - if ( ch == '-' ) - { - // Notice that entering '-' can make our value invalid, for example if - // we're limited to -5..15 range and the current value is 12, then the - // new value would be (invalid) -12. We consider it better to let the - // user do this because perhaps he is going to press Delete key next to - // make it -2 and forcing him to delete 1 first would be unnatural. - // - // TODO: It would be nice to indicate that the current control contents - // is invalid (if it's indeed going to be the case) once - // wxValidator supports doing this non-intrusively. - return m_min < 0 && IsMinusOk(val, pos); - } - - // We only accept digits here (remember that '-' is taken care of by the - // base class already). - if ( ch < '0' || ch > '9' ) - return false; - - // And the value after insertion needs to be in the defined range. - LongestValueType value; - if ( !FromString(GetValueAfterInsertingChar(val, pos, ch), &value) ) - return false; - - return IsInRange(value); -} - -// ============================================================================ -// wxFloatingPointValidatorBase implementation -// ============================================================================ - -wxString wxFloatingPointValidatorBase::ToString(LongestValueType value) const -{ - return wxNumberFormatter::ToString(value, m_precision, GetFormatFlags()); -} - -bool -wxFloatingPointValidatorBase::FromString(const wxString& s, - LongestValueType *value) -{ - return wxNumberFormatter::FromString(s, value); -} - -bool -wxFloatingPointValidatorBase::IsCharOk(const wxString& val, - int pos, - wxChar ch) const -{ - // We may accept minus sign if we can represent negative numbers at all. - if ( ch == '-' ) - return m_min < 0 && IsMinusOk(val, pos); - - const wxChar separator = wxNumberFormatter::GetDecimalSeparator(); - if ( ch == separator ) - { - if ( val.find(separator) != wxString::npos ) - { - // There is already a decimal separator, can't insert another one. - return false; - } - - // Prepending a separator before the minus sign isn't allowed. - if ( pos == 0 && !val.empty() && val[0] == '-' ) - return false; - - // Otherwise always accept it, adding a decimal separator doesn't - // change the number value and, in particular, can't make it invalid. - // OTOH the checks below might not pass because strings like "." or - // "-." are not valid numbers so parsing them would fail, hence we need - // to treat it specially here. - return true; - } - - // Must be a digit then. - if ( ch < '0' || ch > '9' ) - return false; - - // Check whether the value we'd obtain if we accepted this key is correct. - const wxString newval(GetValueAfterInsertingChar(val, pos, ch)); - - LongestValueType value; - if ( !FromString(newval, &value) ) - return false; - - // Also check that it doesn't have too many decimal digits. - const size_t posSep = newval.find(separator); - if ( posSep != wxString::npos && newval.length() - posSep - 1 > m_precision ) - return false; - - // Finally check whether it is in the range. - return IsInRange(value); -} - -#endif // wxUSE_VALIDATORS && wxUSE_TEXTCTRL diff --git a/Source/3rd Party/wx/src/common/valtext.cpp b/Source/3rd Party/wx/src/common/valtext.cpp index 4a89f4f1e..6f3d8b560 100644 --- a/Source/3rd Party/wx/src/common/valtext.cpp +++ b/Source/3rd Party/wx/src/common/valtext.cpp @@ -2,8 +2,9 @@ // Name: src/common/valtext.cpp // Purpose: wxTextValidator // Author: Julian Smart -// Modified by: Francesco Montorsi +// Modified by: // Created: 04/01/98 +// RCS-ID: $Id: valtext.cpp 39656 2006-06-09 21:21:53Z ABX $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,14 +16,13 @@ #pragma hdrstop #endif -#if wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX) +#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL #include "wx/valtext.h" #ifndef WX_PRECOMP #include #include "wx/textctrl.h" - #include "wx/combobox.h" #include "wx/utils.h" #include "wx/msgdlg.h" #include "wx/intl.h" @@ -32,39 +32,28 @@ #include #include -#include "wx/combo.h" - -// ---------------------------------------------------------------------------- -// global helpers -// ---------------------------------------------------------------------------- - -static bool wxIsNumeric(const wxString& val) -{ - for ( wxString::const_iterator i = val.begin(); i != val.end(); ++i ) - { - // Allow for "," (French) as well as "." -- in future we should - // use wxSystemSettings or other to do better localisation - if ((!wxIsdigit(*i)) && - (*i != wxS('.')) && (*i != wxS(',')) && (*i != wxS('e')) && - (*i != wxS('E')) && (*i != wxS('+')) && (*i != wxS('-'))) - return false; - } - return true; -} - -// ---------------------------------------------------------------------------- -// wxTextValidator -// ---------------------------------------------------------------------------- +#ifdef __SALFORDC__ + #include +#endif IMPLEMENT_DYNAMIC_CLASS(wxTextValidator, wxValidator) + BEGIN_EVENT_TABLE(wxTextValidator, wxValidator) EVT_CHAR(wxTextValidator::OnChar) END_EVENT_TABLE() +static bool wxIsNumeric(const wxString& val); + wxTextValidator::wxTextValidator(long style, wxString *val) { + m_validatorStyle = style; m_stringValue = val; - SetStyle(style); +/* + m_refData = new wxVTextRefData; + + M_VTEXTDATA->m_validatorStyle = style; + M_VTEXTDATA->m_stringValue = val; +*/ } wxTextValidator::wxTextValidator(const wxTextValidator& val) @@ -73,30 +62,6 @@ wxTextValidator::wxTextValidator(const wxTextValidator& val) Copy(val); } -void wxTextValidator::SetStyle(long style) -{ - m_validatorStyle = style; - -#if wxDEBUG_LEVEL - int check; - check = (int)HasFlag(wxFILTER_ALPHA) + (int)HasFlag(wxFILTER_ALPHANUMERIC) + - (int)HasFlag(wxFILTER_DIGITS) + (int)HasFlag(wxFILTER_NUMERIC); - wxASSERT_MSG(check <= 1, - "It makes sense to use only one of the wxFILTER_ALPHA/wxFILTER_ALPHANUMERIC/" - "wxFILTER_SIMPLE_NUMBER/wxFILTER_NUMERIC styles"); - - wxASSERT_MSG(((int)HasFlag(wxFILTER_INCLUDE_LIST) + (int)HasFlag(wxFILTER_INCLUDE_CHAR_LIST) <= 1) && - ((int)HasFlag(wxFILTER_EXCLUDE_LIST) + (int)HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) <= 1), - "Using both wxFILTER_[IN|EX]CLUDE_LIST _and_ wxFILTER_[IN|EX]CLUDE_CHAR_LIST " - "doesn't work since wxTextValidator internally uses the same array for both"); - - check = (int)HasFlag(wxFILTER_INCLUDE_LIST) + (int)HasFlag(wxFILTER_INCLUDE_CHAR_LIST) + - (int)HasFlag(wxFILTER_EXCLUDE_LIST) + (int)HasFlag(wxFILTER_EXCLUDE_CHAR_LIST); - wxASSERT_MSG(check <= 1, - "Using both an include/exclude list may lead to unexpected results"); -#endif // wxDEBUG_LEVEL -} - bool wxTextValidator::Copy(const wxTextValidator& val) { wxValidator::Copy(val); @@ -110,226 +75,270 @@ bool wxTextValidator::Copy(const wxTextValidator& val) return true; } -wxTextEntry *wxTextValidator::GetTextEntry() +static bool wxIsAlpha(const wxString& val) { -#if wxUSE_TEXTCTRL - if (wxDynamicCast(m_validatorWindow, wxTextCtrl)) + int i; + for ( i = 0; i < (int)val.length(); i++) { - return (wxTextCtrl*)m_validatorWindow; + if (!wxIsalpha(val[i])) + return false; } -#endif + return true; +} -#if wxUSE_COMBOBOX - if (wxDynamicCast(m_validatorWindow, wxComboBox)) +static bool wxIsAlphaNumeric(const wxString& val) +{ + int i; + for ( i = 0; i < (int)val.length(); i++) { - return (wxComboBox*)m_validatorWindow; + if (!wxIsalnum(val[i])) + return false; } -#endif - -#if wxUSE_COMBOCTRL - if (wxDynamicCast(m_validatorWindow, wxComboCtrl)) - { - return (wxComboCtrl*)m_validatorWindow; - } -#endif - - wxFAIL_MSG( - "wxTextValidator can only be used with wxTextCtrl, wxComboBox, " - "or wxComboCtrl" - ); - - return NULL; + return true; } // Called when the value in the window must be validated. // This function can pop up an error message. bool wxTextValidator::Validate(wxWindow *parent) { + if( !CheckValidator() ) + return false; + + wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow; + // If window is disabled, simply return - if ( !m_validatorWindow->IsEnabled() ) + if ( !control->IsEnabled() ) return true; - wxTextEntry * const text = GetTextEntry(); - if ( !text ) - return false; + wxString val(control->GetValue()); - wxString val(text->GetValue()); + bool ok = true; + // NB: this format string should contian exactly one '%s' wxString errormsg; - // We can only do some kinds of validation once the input is complete, so - // check for them here: - if ( HasFlag(wxFILTER_EMPTY) && val.empty() ) - errormsg = _("Required information entry is empty."); - else if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND ) - errormsg = wxString::Format(_("'%s' is invalid"), val); - else if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND ) - errormsg = wxString::Format(_("'%s' is invalid"), val); - else if ( !(errormsg = IsValid(val)).empty() ) + bool includes = (m_validatorStyle & wxFILTER_INCLUDE_LIST) != 0; + if ( includes || (m_validatorStyle & wxFILTER_EXCLUDE_LIST) ) { - // NB: this format string should always contain exactly one '%s' + // if includes, it's only ok to have the members of the list, + // otherwise it's only ok to have non-members + ok = includes == (m_includes.Index(val) != wxNOT_FOUND); + if ( !ok ) + { + errormsg = _("'%s' is invalid"); + } + } + else if ( (m_validatorStyle & wxFILTER_ASCII) && !val.IsAscii() ) + { + ok = false; + + errormsg = _("'%s' should only contain ASCII characters."); + } + else if ( (m_validatorStyle & wxFILTER_ALPHA) && !wxIsAlpha(val) ) + { + ok = false; + + errormsg = _("'%s' should only contain alphabetic characters."); + } + else if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsAlphaNumeric(val)) + { + ok = false; + + errormsg = _("'%s' should only contain alphabetic or numeric characters."); + } + else if ( (m_validatorStyle & wxFILTER_NUMERIC) && !wxIsNumeric(val)) + { + ok = false; + + errormsg = _("'%s' should be numeric."); + } + else if ( (m_validatorStyle & wxFILTER_INCLUDE_CHAR_LIST) && !IsInCharIncludes(val)) + { + //it's only ok to have the members of the list + errormsg = _("'%s' is invalid"); + ok = false; + } + else if ( (m_validatorStyle & wxFILTER_EXCLUDE_CHAR_LIST) && !IsNotInCharExcludes(val)) + { + // it's only ok to have non-members of the list + errormsg = _("'%s' is invalid"); + ok = false; + } + + if ( !ok ) + { + wxASSERT_MSG( !errormsg.empty(), _T("you forgot to set errormsg") ); + + m_validatorWindow->SetFocus(); + wxString buf; buf.Printf(errormsg, val.c_str()); - errormsg = buf; - } - if ( !errormsg.empty() ) - { - m_validatorWindow->SetFocus(); - wxMessageBox(errormsg, _("Validation conflict"), + wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); + } + return ok; +} + +// Called to transfer data to the window +bool wxTextValidator::TransferToWindow(void) +{ + if( !CheckValidator() ) return false; + + if ( m_stringValue ) + { + wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow; + control->SetValue(* m_stringValue); } return true; } // Called to transfer data to the window -bool wxTextValidator::TransferToWindow() +bool wxTextValidator::TransferFromWindow(void) { + if( !CheckValidator() ) + return false; + if ( m_stringValue ) { - wxTextEntry * const text = GetTextEntry(); - if ( !text ) - return false; - - text->SetValue(*m_stringValue); + wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow; + *m_stringValue = control->GetValue(); } return true; } -// Called to transfer data to the window -bool wxTextValidator::TransferFromWindow() +#if WXWIN_COMPATIBILITY_2_4 + +inline void wxCopyStringListToArrayString(wxArrayString& to, const wxStringList& from) { - if ( m_stringValue ) + to.Clear(); + + for ( wxStringList::compatibility_iterator pNode = from.GetFirst(); + pNode; + pNode = pNode->GetNext() ) { - wxTextEntry * const text = GetTextEntry(); - if ( !text ) - return false; - - *m_stringValue = text->GetValue(); + to.Add(pNode->GetData()); } - - return true; } -// IRIX mipsPro refuses to compile wxStringCheck() if func is inline so -// let's work around this by using this non-template function instead of -// wxStringCheck(). And while this might be fractionally less efficient because -// the function call won't be inlined like this, we don't care enough about -// this to add extra #ifs for non-IRIX case. -namespace +inline void wxCopyArrayStringToStringList(wxStringList& to, const wxArrayString& from) { + to.Clear(); -bool CheckString(bool (*func)(const wxUniChar&), const wxString& str) + for(size_t i = 0; i < from.GetCount(); ++i) + to.Add(from[i]); +} + +wxStringList& wxTextValidator::GetIncludeList() { - for ( wxString::const_iterator i = str.begin(); i != str.end(); ++i ) + wxCopyArrayStringToStringList(m_includeList, m_includes); + return m_includeList; +} + +wxStringList& wxTextValidator::GetExcludeList() +{ + wxCopyArrayStringToStringList(m_excludeList, m_excludes); + return m_excludeList; +} + +void wxTextValidator::SetIncludeList(const wxStringList& list) +{ + wxCopyStringListToArrayString(m_includes, list); +} + +void wxTextValidator::SetExcludeList(const wxStringList& list) +{ + wxCopyStringListToArrayString(m_excludes, list); +} + +bool wxTextValidator::IsInCharIncludeList(const wxString& val) +{ + return IsInCharIncludes(val); +} + +bool wxTextValidator::IsNotInCharExcludeList(const wxString& val) +{ + return IsNotInCharExcludes(val); +} + +#endif //compat 2.4 + + +bool wxTextValidator::IsInCharIncludes(const wxString& val) +{ + size_t i; + for ( i = 0; i < val.length(); i++) { - if ( !func(*i) ) + if (m_includes.Index((wxString) val[i]) == wxNOT_FOUND) return false; } - return true; } -} // anonymous namespace - -wxString wxTextValidator::IsValid(const wxString& val) const +bool wxTextValidator::IsNotInCharExcludes(const wxString& val) { - // wxFILTER_EMPTY is checked for in wxTextValidator::Validate - - if ( HasFlag(wxFILTER_ASCII) && !val.IsAscii() ) - return _("'%s' should only contain ASCII characters."); - if ( HasFlag(wxFILTER_ALPHA) && !CheckString(wxIsalpha, val) ) - return _("'%s' should only contain alphabetic characters."); - if ( HasFlag(wxFILTER_ALPHANUMERIC) && !CheckString(wxIsalnum, val) ) - return _("'%s' should only contain alphabetic or numeric characters."); - if ( HasFlag(wxFILTER_DIGITS) && !CheckString(wxIsdigit, val) ) - return _("'%s' should only contain digits."); - if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) ) - return _("'%s' should be numeric."); - if ( HasFlag(wxFILTER_INCLUDE_CHAR_LIST) && !ContainsOnlyIncludedCharacters(val) ) - return _("'%s' is invalid"); - if ( HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) && ContainsExcludedCharacters(val) ) - return _("'%s' is invalid"); - - return wxEmptyString; -} - -bool wxTextValidator::ContainsOnlyIncludedCharacters(const wxString& val) const -{ - for ( wxString::const_iterator i = val.begin(); i != val.end(); ++i ) - if (m_includes.Index((wxString) *i) == wxNOT_FOUND) - // one character of 'val' is NOT present in m_includes... + size_t i; + for ( i = 0; i < val.length(); i++) + { + if (m_excludes.Index((wxString) val[i]) != wxNOT_FOUND) return false; - - // all characters of 'val' are present in m_includes + } return true; } -bool wxTextValidator::ContainsExcludedCharacters(const wxString& val) const -{ - for ( wxString::const_iterator i = val.begin(); i != val.end(); ++i ) - if (m_excludes.Index((wxString) *i) != wxNOT_FOUND) - // one character of 'val' is present in m_excludes... - return true; - - // all characters of 'val' are NOT present in m_excludes - return false; -} - -void wxTextValidator::SetCharIncludes(const wxString& chars) -{ - wxArrayString arr; - - for ( wxString::const_iterator i = chars.begin(); i != chars.end(); ++i ) - arr.Add(*i); - - SetIncludes(arr); -} - -void wxTextValidator::SetCharExcludes(const wxString& chars) -{ - wxArrayString arr; - - for ( wxString::const_iterator i = chars.begin(); i != chars.end(); ++i ) - arr.Add(*i); - - SetExcludes(arr); -} - void wxTextValidator::OnChar(wxKeyEvent& event) { - if (!m_validatorWindow) - { - event.Skip(); +/* + if ( !M_VTEXTDATA ) return; +*/ + + if ( m_validatorWindow ) + { + int keyCode = event.GetKeyCode(); + + // we don't filter special keys and Delete + if ( + !(keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode > WXK_START) && + ( + ((m_validatorStyle & wxFILTER_INCLUDE_CHAR_LIST) && !IsInCharIncludes(wxString((wxChar) keyCode, 1))) || + ((m_validatorStyle & wxFILTER_EXCLUDE_CHAR_LIST) && !IsNotInCharExcludes(wxString((wxChar) keyCode, 1))) || + ((m_validatorStyle & wxFILTER_ASCII) && !isascii(keyCode)) || + ((m_validatorStyle & wxFILTER_ALPHA) && !wxIsalpha(keyCode)) || + ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsalnum(keyCode)) || + ((m_validatorStyle & wxFILTER_NUMERIC) && !wxIsdigit(keyCode) + && keyCode != wxT('.') && keyCode != wxT(',') && keyCode != wxT('-') && keyCode != wxT('+') && keyCode != wxT('e') && keyCode != wxT('E')) + ) + ) + { + if ( !wxValidator::IsSilent() ) + wxBell(); + + // eat message + return; + } } - int keyCode = event.GetKeyCode(); + event.Skip(); +} - // we don't filter special keys and delete - if (keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode >= WXK_START) +static bool wxIsNumeric(const wxString& val) +{ + int i; + for ( i = 0; i < (int)val.length(); i++) { - event.Skip(); - return; + // Allow for "," (French) as well as "." -- in future we should + // use wxSystemSettings or other to do better localisation + if ((!wxIsdigit(val[i])) && (val[i] != wxT('.')) && (val[i] != wxT(',')) && (val[i] != wxT('e')) && (val[i] != wxT('E')) && (val[i] != wxT('+')) && (val[i] != wxT('-'))) + return false; } - - wxString str((wxUniChar)keyCode, 1); - if (!IsValid(str).empty()) - { - if ( !wxValidator::IsSilent() ) - wxBell(); - - // eat message - return; - } - else - event.Skip(); + return true; } #endif - // wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX) + // wxUSE_VALIDATORS && wxUSE_TEXTCTRL diff --git a/Source/3rd Party/wx/src/common/variant.cpp b/Source/3rd Party/wx/src/common/variant.cpp index 5fc1931bb..eb653c0ff 100644 --- a/Source/3rd Party/wx/src/common/variant.cpp +++ b/Source/3rd Party/wx/src/common/variant.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 10/09/98 +// RCS-ID: $Id: variant.cpp 58054 2009-01-12 17:27:53Z JMS $ // Copyright: (c) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,7 +23,6 @@ #ifndef WX_PRECOMP #include "wx/string.h" #include "wx/math.h" - #include "wx/crt.h" #if wxUSE_STREAMS #include "wx/stream.h" #endif @@ -36,6 +36,11 @@ #endif #endif +#if defined(__MWERKS__) && __MSL__ >= 0x6000 +namespace std {} +using namespace std ; +#endif + #if wxUSE_STREAMS #include "wx/txtstrm.h" #endif @@ -43,12 +48,11 @@ #include "wx/string.h" #include "wx/tokenzr.h" +IMPLEMENT_ABSTRACT_CLASS(wxVariantData, wxObject) + wxVariant WXDLLIMPEXP_BASE wxNullVariant; -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxVariantList) - /* * wxVariant */ @@ -56,13 +60,13 @@ WX_DEFINE_LIST(wxVariantList) IMPLEMENT_DYNAMIC_CLASS(wxVariant, wxObject) wxVariant::wxVariant() - : wxObject() { + m_data = (wxVariantData*) NULL; } bool wxVariant::IsNull() const { - return (m_refData == NULL); + return (m_data == (wxVariantData*) NULL); } void wxVariant::MakeNull() @@ -78,6 +82,8 @@ void wxVariant::Clear() wxVariant::wxVariant(const wxVariant& variant) : wxObject() { + m_data = (wxVariantData*) NULL; + if (!variant.IsNull()) Ref(variant); @@ -85,26 +91,14 @@ wxVariant::wxVariant(const wxVariant& variant) } wxVariant::wxVariant(wxVariantData* data, const wxString& name) // User-defined data - : wxObject() { - m_refData = data; + m_data = data; m_name = name; } wxVariant::~wxVariant() { -} - -wxObjectRefData *wxVariant::CreateRefData() const -{ - // We cannot create any particular wxVariantData. - wxFAIL_MSG("wxVariant::CreateRefData() cannot be implemented"); - return NULL; -} - -wxObjectRefData *wxVariant::CloneRefData(const wxObjectRefData *data) const -{ - return ((wxVariantData*) data)->Clone(); + UnRef(); } // Assignment @@ -118,7 +112,7 @@ void wxVariant::operator= (const wxVariant& variant) void wxVariant::operator= (wxVariantData* variantData) { UnRef(); - m_refData = variantData; + m_data = variantData; } bool wxVariant::operator== (const wxVariant& variant) const @@ -126,9 +120,6 @@ bool wxVariant::operator== (const wxVariant& variant) const if (IsNull() || variant.IsNull()) return (IsNull() == variant.IsNull()); - if (GetType() != variant.GetType()) - return false; - return (GetData()->Eq(* variant.GetData())); } @@ -137,6 +128,7 @@ bool wxVariant::operator!= (const wxVariant& variant) const return (!(*this == variant)); } + wxString wxVariant::MakeString() const { if (!IsNull()) @@ -151,17 +143,36 @@ wxString wxVariant::MakeString() const void wxVariant::SetData(wxVariantData* data) { UnRef(); - m_refData = data; + m_data = data; } -bool wxVariant::Unshare() +void wxVariant::Ref(const wxVariant& clone) { - if ( !m_refData || m_refData->GetRefCount() == 1 ) - return true; + // nothing to be done + if (m_data == clone.m_data) + return; - wxObject::UnShare(); + // delete reference to old data + UnRef(); - return (m_refData && m_refData->GetRefCount() == 1); + // reference new data + if ( clone.m_data ) + { + m_data = clone.m_data; + m_data->m_count++; + } +} + + +void wxVariant::UnRef() +{ + if ( m_data ) + { + wxASSERT_MSG( m_data->m_count > 0, _T("invalid ref data count") ); + + m_data->DecRef(); + m_data = NULL; + } } @@ -187,52 +198,6 @@ bool wxVariant::IsValueKindOf(const wxClassInfo* type) const return info ? info->IsKindOf(type) : false ; } -// ----------------------------------------------------------------- -// wxVariant <-> wxAny conversion code -// ----------------------------------------------------------------- - -#if wxUSE_ANY - -wxAnyToVariantRegistration:: - wxAnyToVariantRegistration(wxVariantDataFactory factory) - : m_factory(factory) -{ - wxPreRegisterAnyToVariant(this); -} - -wxAnyToVariantRegistration::~wxAnyToVariantRegistration() -{ -} - -wxVariant::wxVariant(const wxAny& any) - : wxObject() -{ - wxVariant variant; - if ( !any.GetAs(&variant) ) - { - wxFAIL_MSG("wxAny of this type cannot be converted to wxVariant"); - return; - } - - *this = variant; -} - -wxAny wxVariant::GetAny() const -{ - if ( IsNull() ) - return wxAny(); - - wxAny any; - wxVariantData* data = GetData(); - - if ( data->GetAsAny(&any) ) - return any; - - // If everything else fails, wrap the whole wxVariantData - return wxAny(data); -} - -#endif // wxUSE_ANY // ----------------------------------------------------------------- // wxVariantDataLong @@ -240,6 +205,7 @@ wxAny wxVariant::GetAny() const class WXDLLIMPEXP_BASE wxVariantDataLong: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataLong) public: wxVariantDataLong() { m_value = 0; } wxVariantDataLong(long value) { m_value = value; } @@ -260,32 +226,13 @@ public: virtual bool Write(wxOutputStream &str) const; #endif // wxUSE_STREAMS - wxVariantData* Clone() const { return new wxVariantDataLong(m_value); } - virtual wxString GetType() const { return wxT("long"); } -#if wxUSE_ANY - // Since wxAny does not have separate type for integers shorter than - // longlong, we do not usually implement wxVariant->wxAny conversion - // here (but in wxVariantDataLongLong instead). - #ifndef wxLongLong_t - DECLARE_WXANY_CONVERSION() - #else - bool GetAsAny(wxAny* any) const - { - *any = m_value; - return true; - } - #endif -#endif // wxUSE_ANY - protected: long m_value; }; -#ifndef wxLongLong_t -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(long, wxVariantDataLong) -#endif +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataLong, wxVariantData) bool wxVariantDataLong::Eq(wxVariantData& data) const { @@ -339,7 +286,7 @@ bool wxVariantDataLong::Read(wxInputStream& str) bool wxVariantDataLong::Read(wxString& str) { - m_value = wxAtol(str); + m_value = wxAtol((const wxChar*) str); return true; } @@ -347,19 +294,19 @@ bool wxVariantDataLong::Read(wxString& str) wxVariant::wxVariant(long val, const wxString& name) { - m_refData = new wxVariantDataLong(val); + m_data = new wxVariantDataLong(val); m_name = name; } wxVariant::wxVariant(int val, const wxString& name) { - m_refData = new wxVariantDataLong((long)val); + m_data = new wxVariantDataLong((long)val); m_name = name; } wxVariant::wxVariant(short val, const wxString& name) { - m_refData = new wxVariantDataLong((long)val); + m_data = new wxVariantDataLong((long)val); m_name = name; } @@ -380,14 +327,14 @@ bool wxVariant::operator!= (long value) const void wxVariant::operator= (long value) { if (GetType() == wxT("long") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataLong*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataLong(value); + m_data = new wxVariantDataLong(value); } } @@ -409,6 +356,7 @@ long wxVariant::GetLong() const class WXDLLIMPEXP_BASE wxVariantDoubleData: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDoubleData) public: wxVariantDoubleData() { m_value = 0.0; } wxVariantDoubleData(double value) { m_value = value; } @@ -431,14 +379,11 @@ public: #endif // wxUSE_STREAMS virtual wxString GetType() const { return wxT("double"); } - wxVariantData* Clone() const { return new wxVariantDoubleData(m_value); } - - DECLARE_WXANY_CONVERSION() protected: double m_value; }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(double, wxVariantDoubleData) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDoubleData, wxVariantData) bool wxVariantDoubleData::Eq(wxVariantData& data) const { @@ -491,7 +436,7 @@ bool wxVariantDoubleData::Read(wxInputStream& str) bool wxVariantDoubleData::Read(wxString& str) { - m_value = wxAtof(str); + m_value = wxAtof((const wxChar*) str); return true; } @@ -499,7 +444,7 @@ bool wxVariantDoubleData::Read(wxString& str) wxVariant::wxVariant(double val, const wxString& name) { - m_refData = new wxVariantDoubleData(val); + m_data = new wxVariantDoubleData(val); m_name = name; } @@ -520,14 +465,14 @@ bool wxVariant::operator!= (double value) const void wxVariant::operator= (double value) { if (GetType() == wxT("double") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDoubleData*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDoubleData(value); + m_data = new wxVariantDoubleData(value); } } @@ -547,8 +492,11 @@ double wxVariant::GetDouble() const // wxVariantBoolData // ----------------------------------------------------------------- +#ifdef HAVE_BOOL + class WXDLLIMPEXP_BASE wxVariantDataBool: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataBool) public: wxVariantDataBool() { m_value = 0; } wxVariantDataBool(bool value) { m_value = value; } @@ -571,14 +519,11 @@ public: #endif // wxUSE_STREAMS virtual wxString GetType() const { return wxT("bool"); } - wxVariantData* Clone() const { return new wxVariantDataBool(m_value); } - - DECLARE_WXANY_CONVERSION() protected: bool m_value; }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(bool, wxVariantDataBool) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataBool, wxVariantData) bool wxVariantDataBool::Eq(wxVariantData& data) const { @@ -634,7 +579,7 @@ bool wxVariantDataBool::Read(wxInputStream& str) bool wxVariantDataBool::Read(wxString& str) { - m_value = (wxAtol(str) != 0); + m_value = (wxAtol((const wxChar*) str) != 0); return true; } @@ -642,7 +587,7 @@ bool wxVariantDataBool::Read(wxString& str) wxVariant::wxVariant(bool val, const wxString& name) { - m_refData = new wxVariantDataBool(val); + m_data = new wxVariantDataBool(val); m_name = name; } @@ -663,14 +608,14 @@ bool wxVariant::operator!= (bool value) const void wxVariant::operator= (bool value) { if (GetType() == wxT("bool") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataBool*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataBool(value); + m_data = new wxVariantDataBool(value); } } @@ -686,18 +631,21 @@ bool wxVariant::GetBool() const } } +#endif // HAVE_BOOL + // ----------------------------------------------------------------- // wxVariantDataChar // ----------------------------------------------------------------- class WXDLLIMPEXP_BASE wxVariantDataChar: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataChar) public: wxVariantDataChar() { m_value = 0; } - wxVariantDataChar(const wxUniChar& value) { m_value = value; } + wxVariantDataChar(wxChar value) { m_value = value; } - inline wxUniChar GetValue() const { return m_value; } - inline void SetValue(const wxUniChar& value) { m_value = value; } + inline wxChar GetValue() const { return m_value; } + inline void SetValue(wxChar value) { m_value = value; } virtual bool Eq(wxVariantData& data) const; #if wxUSE_STD_IOSTREAM @@ -711,14 +659,12 @@ public: virtual bool Write(wxOutputStream& str) const; #endif // wxUSE_STREAMS virtual wxString GetType() const { return wxT("char"); } - wxVariantData* Clone() const { return new wxVariantDataChar(m_value); } - DECLARE_WXANY_CONVERSION() protected: - wxUniChar m_value; + wxChar m_value; }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxUniChar, wxVariantDataChar) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataChar, wxVariantData) bool wxVariantDataChar::Eq(wxVariantData& data) const { @@ -732,14 +678,16 @@ bool wxVariantDataChar::Eq(wxVariantData& data) const #if wxUSE_STD_IOSTREAM bool wxVariantDataChar::Write(wxSTD ostream& str) const { - str << wxString(m_value); + wxString s; + Write(s); + str << (const char*) s.mb_str(); return true; } #endif bool wxVariantDataChar::Write(wxString& str) const { - str = m_value; + str.Printf(wxT("%c"), m_value); return true; } @@ -757,9 +705,7 @@ bool wxVariantDataChar::Write(wxOutputStream& str) const { wxTextOutputStream s(str); - // FIXME-UTF8: this should be just "s << m_value;" after removal of - // ANSI build and addition of wxUniChar to wxTextOutputStream: - s << (wxChar)m_value; + s << m_value; return true; } @@ -768,11 +714,7 @@ bool wxVariantDataChar::Read(wxInputStream& str) { wxTextInputStream s(str); - // FIXME-UTF8: this should be just "s >> m_value;" after removal of - // ANSI build and addition of wxUniChar to wxTextInputStream: - wxChar ch; - s >> ch; - m_value = ch; + s >> m_value; return true; } @@ -780,62 +722,53 @@ bool wxVariantDataChar::Read(wxInputStream& str) bool wxVariantDataChar::Read(wxString& str) { - m_value = str[0u]; + m_value = str[size_t(0)]; return true; } -wxVariant::wxVariant(const wxUniChar& val, const wxString& name) +wxVariant::wxVariant(wxChar val, const wxString& name) { - m_refData = new wxVariantDataChar(val); + m_data = new wxVariantDataChar(val); m_name = name; } -wxVariant::wxVariant(char val, const wxString& name) +bool wxVariant::operator== (wxChar value) const { - m_refData = new wxVariantDataChar(val); - m_name = name; -} - -wxVariant::wxVariant(wchar_t val, const wxString& name) -{ - m_refData = new wxVariantDataChar(val); - m_name = name; -} - -bool wxVariant::operator==(const wxUniChar& value) const -{ - wxUniChar thisValue; + wxChar thisValue; if (!Convert(&thisValue)) return false; else return (value == thisValue); } -wxVariant& wxVariant::operator=(const wxUniChar& value) +bool wxVariant::operator!= (wxChar value) const +{ + return (!((*this) == value)); +} + +void wxVariant::operator= (wxChar value) { if (GetType() == wxT("char") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataChar*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataChar(value); + m_data = new wxVariantDataChar(value); } - - return *this; } -wxUniChar wxVariant::GetChar() const +wxChar wxVariant::GetChar() const { - wxUniChar value; + wxChar value; if (Convert(& value)) return value; else { wxFAIL_MSG(wxT("Could not convert to a char")); - return wxUniChar(0); + return 0; } } @@ -845,6 +778,7 @@ wxUniChar wxVariant::GetChar() const class WXDLLIMPEXP_BASE wxVariantDataString: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataString) public: wxVariantDataString() { } wxVariantDataString(const wxString& value) { m_value = value; } @@ -866,35 +800,11 @@ public: virtual bool Write(wxOutputStream& str) const; #endif // wxUSE_STREAMS virtual wxString GetType() const { return wxT("string"); } - wxVariantData* Clone() const { return new wxVariantDataString(m_value); } - DECLARE_WXANY_CONVERSION() protected: wxString m_value; }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxString, wxVariantDataString) - -#if wxUSE_ANY -// This allows converting string literal wxAnys to string variants -wxVariantData* wxVariantDataFromConstCharPAny(const wxAny& any) -{ - return new wxVariantDataString(wxANY_AS(any, const char*)); -} - -wxVariantData* wxVariantDataFromConstWchar_tPAny(const wxAny& any) -{ - return new wxVariantDataString(wxANY_AS(any, const wchar_t*)); -} - -_REGISTER_WXANY_CONVERSION(const char*, - ConstCharP, - wxVariantDataFromConstCharPAny) -_REGISTER_WXANY_CONVERSION(const wchar_t*, - ConstWchar_tP, - wxVariantDataFromConstWchar_tPAny) -#endif - bool wxVariantDataString::Eq(wxVariantData& data) const { wxASSERT_MSG( (data.GetType() == wxT("string")), wxT("wxVariantDataString::Eq: argument mismatch") ); @@ -942,58 +852,22 @@ bool wxVariantDataString::Read(wxString& str) return true; } +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData) + // wxVariant **** wxVariant::wxVariant(const wxString& val, const wxString& name) { - m_refData = new wxVariantDataString(val); + m_data = new wxVariantDataString(val); m_name = name; } -wxVariant::wxVariant(const char* val, const wxString& name) +wxVariant::wxVariant(const wxChar* val, const wxString& name) { - m_refData = new wxVariantDataString(wxString(val)); + m_data = new wxVariantDataString(wxString(val)); m_name = name; } -wxVariant::wxVariant(const wchar_t* val, const wxString& name) -{ - m_refData = new wxVariantDataString(wxString(val)); - m_name = name; -} - -wxVariant::wxVariant(const wxCStrData& val, const wxString& name) -{ - m_refData = new wxVariantDataString(val.AsString()); - m_name = name; -} - -wxVariant::wxVariant(const wxScopedCharBuffer& val, const wxString& name) -{ - m_refData = new wxVariantDataString(wxString(val)); - m_name = name; -} - -wxVariant::wxVariant(const wxScopedWCharBuffer& val, const wxString& name) -{ - m_refData = new wxVariantDataString(wxString(val)); - m_name = name; -} - -#if wxUSE_STD_STRING -wxVariant::wxVariant(const std::string& val, const wxString& name) -{ - m_refData = new wxVariantDataString(wxString(val)); - m_name = name; -} - -wxVariant::wxVariant(const wxStdWideString& val, const wxString& name) -{ - m_refData = new wxVariantDataString(wxString(val)); - m_name = name; -} -#endif // wxUSE_STD_STRING - bool wxVariant::operator== (const wxString& value) const { wxString thisValue; @@ -1008,19 +882,32 @@ bool wxVariant::operator!= (const wxString& value) const return (!((*this) == value)); } -wxVariant& wxVariant::operator= (const wxString& value) +void wxVariant::operator= (const wxString& value) { if (GetType() == wxT("string") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataString*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataString(value); + m_data = new wxVariantDataString(value); + } +} + +void wxVariant::operator= (const wxChar* value) +{ + if (GetType() == wxT("string") && + m_data->GetRefCount() == 1) + { + ((wxVariantDataString*)GetData())->SetValue(wxString(value)); + } + else + { + UnRef(); + m_data = new wxVariantDataString(wxString(value)); } - return *this; } wxString wxVariant::GetString() const @@ -1040,6 +927,7 @@ wxString wxVariant::GetString() const class wxVariantDataWxObjectPtr: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataWxObjectPtr) public: wxVariantDataWxObjectPtr() { } wxVariantDataWxObjectPtr(wxObject* value) { m_value = value; } @@ -1057,20 +945,20 @@ public: #endif virtual bool Read(wxString& str); virtual wxString GetType() const ; - virtual wxVariantData* Clone() const { return new wxVariantDataWxObjectPtr(m_value); } + virtual wxVariantData* Clone() { return new wxVariantDataWxObjectPtr; } - virtual wxClassInfo* GetValueClassInfo(); - - DECLARE_WXANY_CONVERSION() + virtual wxClassInfo* GetValueClassInfo() ; protected: wxObject* m_value; + + DECLARE_NO_COPY_CLASS(wxVariantDataWxObjectPtr) }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxObject*, wxVariantDataWxObjectPtr) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataWxObjectPtr, wxVariantData) bool wxVariantDataWxObjectPtr::Eq(wxVariantData& data) const { - wxASSERT_MSG( data.GetType() == GetType(), wxT("wxVariantDataWxObjectPtr::Eq: argument mismatch") ); + wxASSERT_MSG( wxIsKindOf((&data), wxVariantDataWxObjectPtr), wxT("wxVariantDataWxObjectPtr::Eq: argument mismatch") ); wxVariantDataWxObjectPtr& otherData = (wxVariantDataWxObjectPtr&) data; @@ -1079,14 +967,10 @@ bool wxVariantDataWxObjectPtr::Eq(wxVariantData& data) const wxString wxVariantDataWxObjectPtr::GetType() const { - wxString returnVal(wxT("wxObject*")); - - if (m_value) - { + wxString returnVal(wxT("wxObject")); + if (m_value) { returnVal = m_value->GetClassInfo()->GetClassName(); - returnVal += wxT("*"); } - return returnVal; } @@ -1111,7 +995,7 @@ bool wxVariantDataWxObjectPtr::Write(wxSTD ostream& str) const bool wxVariantDataWxObjectPtr::Write(wxString& str) const { - str.Printf(wxT("%s(%p)"), GetType().c_str(), static_cast(m_value)); + str.Printf(wxT("%s(%p)"), GetType().c_str(), wx_static_cast(void*, m_value)); return true; } @@ -1133,7 +1017,7 @@ bool wxVariantDataWxObjectPtr::Read(wxString& WXUNUSED(str)) wxVariant::wxVariant( wxObject* val, const wxString& name) { - m_refData = new wxVariantDataWxObjectPtr(val); + m_data = new wxVariantDataWxObjectPtr(val); m_name = name; } @@ -1150,12 +1034,13 @@ bool wxVariant::operator!= (wxObject* value) const void wxVariant::operator= (wxObject* value) { UnRef(); - m_refData = new wxVariantDataWxObjectPtr(value); + m_data = new wxVariantDataWxObjectPtr(value); } wxObject* wxVariant::GetWxObjectPtr() const { - return (wxObject*) ((wxVariantDataWxObjectPtr*) m_refData)->GetValue(); + wxASSERT(wxIsKindOf(GetData(), wxVariantDataWxObjectPtr)); + return (wxObject*) ((wxVariantDataWxObjectPtr*) m_data)->GetValue(); } // ---------------------------------------------------------------------------- @@ -1164,6 +1049,7 @@ wxObject* wxVariant::GetWxObjectPtr() const class wxVariantDataVoidPtr: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataVoidPtr) public: wxVariantDataVoidPtr() { } wxVariantDataVoidPtr(void* value) { m_value = value; } @@ -1181,18 +1067,19 @@ public: #endif virtual bool Read(wxString& str); virtual wxString GetType() const { return wxT("void*"); } - virtual wxVariantData* Clone() const { return new wxVariantDataVoidPtr(m_value); } + virtual wxVariantData* Clone() { return new wxVariantDataVoidPtr; } - DECLARE_WXANY_CONVERSION() protected: void* m_value; + + DECLARE_NO_COPY_CLASS(wxVariantDataVoidPtr) }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(void*, wxVariantDataVoidPtr) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataVoidPtr, wxVariantData) bool wxVariantDataVoidPtr::Eq(wxVariantData& data) const { - wxASSERT_MSG( data.GetType() == wxT("void*"), wxT("wxVariantDataVoidPtr::Eq: argument mismatch") ); + wxASSERT_MSG( (data.GetType() == wxT("void*")), wxT("wxVariantDataVoidPtr::Eq: argument mismatch") ); wxVariantDataVoidPtr& otherData = (wxVariantDataVoidPtr&) data; @@ -1233,7 +1120,7 @@ bool wxVariantDataVoidPtr::Read(wxString& WXUNUSED(str)) wxVariant::wxVariant( void* val, const wxString& name) { - m_refData = new wxVariantDataVoidPtr(val); + m_data = new wxVariantDataVoidPtr(val); m_name = name; } @@ -1249,26 +1136,23 @@ bool wxVariant::operator!= (void* value) const void wxVariant::operator= (void* value) { - if (GetType() == wxT("void*") && (m_refData->GetRefCount() == 1)) + if (GetType() == wxT("void*") && + m_data->GetRefCount() == 1) { ((wxVariantDataVoidPtr*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataVoidPtr(value); + m_data = new wxVariantDataVoidPtr(value); } } void* wxVariant::GetVoidPtr() const { - // handling this specially is convenient when working with COM, see #9873 - if ( IsNull() ) - return NULL; + wxASSERT( (GetType() == wxT("void*")) ); - wxASSERT( GetType() == wxT("void*") ); - - return (void*) ((wxVariantDataVoidPtr*) m_refData)->GetValue(); + return (void*) ((wxVariantDataVoidPtr*) m_data)->GetValue(); } // ---------------------------------------------------------------------------- @@ -1279,9 +1163,20 @@ void* wxVariant::GetVoidPtr() const class wxVariantDataDateTime: public wxVariantData { + DECLARE_DYNAMIC_CLASS(wxVariantDataDateTime) + public: wxVariantDataDateTime() { } wxVariantDataDateTime(const wxDateTime& value) { m_value = value; } +#if wxUSE_ODBC + wxVariantDataDateTime(const TIME_STRUCT* valptr) + { m_value = wxDateTime(valptr->hour, valptr->minute, valptr->second); } + wxVariantDataDateTime(const DATE_STRUCT* valptr) + { m_value = wxDateTime(valptr->day, (wxDateTime::Month) (valptr->month - 1),valptr->year); } + wxVariantDataDateTime(const TIMESTAMP_STRUCT* valptr) + { m_value = wxDateTime(valptr->day, (wxDateTime::Month) (valptr->month - 1), valptr->year, + valptr->hour, valptr->minute, valptr->second, (wxDateTime::wxDateTime_t)valptr->fraction ); } +#endif //ODBC inline wxDateTime GetValue() const { return m_value; } inline void SetValue(const wxDateTime& value) { m_value = value; } @@ -1296,14 +1191,14 @@ public: #endif virtual bool Read(wxString& str); virtual wxString GetType() const { return wxT("datetime"); } - virtual wxVariantData* Clone() const { return new wxVariantDataDateTime(m_value); } + virtual wxVariantData* Clone() { return new wxVariantDataDateTime; } - DECLARE_WXANY_CONVERSION() protected: wxDateTime m_value; }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxDateTime, wxVariantDataDateTime) + +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataDateTime, wxVariantData) bool wxVariantDataDateTime::Eq(wxVariantData& data) const { @@ -1331,7 +1226,8 @@ bool wxVariantDataDateTime::Write(wxString& str) const if ( m_value.IsValid() ) str = m_value.Format(); else - str = wxS("Invalid"); + str = wxT("Invalid"); + return true; } @@ -1347,24 +1243,45 @@ bool wxVariantDataDateTime::Read(wxSTD istream& WXUNUSED(str)) bool wxVariantDataDateTime::Read(wxString& str) { - if ( str == wxS("Invalid") ) + if ( str == wxT("Invalid") ) { m_value = wxInvalidDateTime; return true; } - wxString::const_iterator end; - return m_value.ParseDateTime(str, &end) && end == str.end(); + if(! m_value.ParseDateTime(str)) + return false; + return true; } // wxVariant wxVariant::wxVariant(const wxDateTime& val, const wxString& name) // Date { - m_refData = new wxVariantDataDateTime(val); + m_data = new wxVariantDataDateTime(val); m_name = name; } +#if wxUSE_ODBC +wxVariant::wxVariant(const TIME_STRUCT* valptr, const wxString& name) // Date +{ + m_data = new wxVariantDataDateTime(valptr); + m_name = name; +} + +wxVariant::wxVariant(const TIMESTAMP_STRUCT* valptr, const wxString& name) // Date +{ + m_data = new wxVariantDataDateTime(valptr); + m_name = name; +} + +wxVariant::wxVariant(const DATE_STRUCT* valptr, const wxString& name) // Date +{ + m_data = new wxVariantDataDateTime(valptr); + m_name = name; +} +#endif // wxUSE_ODBC + bool wxVariant::operator== (const wxDateTime& value) const { wxDateTime thisValue; @@ -1382,17 +1299,38 @@ bool wxVariant::operator!= (const wxDateTime& value) const void wxVariant::operator= (const wxDateTime& value) { if (GetType() == wxT("datetime") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataDateTime*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataDateTime(value); + m_data = new wxVariantDataDateTime(value); } } +#if wxUSE_ODBC +void wxVariant::operator= (const DATE_STRUCT* value) +{ + UnRef(); + m_data = new wxVariantDataDateTime(value); +} + +void wxVariant::operator= (const TIME_STRUCT* value) +{ + UnRef(); + m_data = new wxVariantDataDateTime(value); +} + +void wxVariant::operator= (const TIMESTAMP_STRUCT* value) +{ + UnRef(); + m_data = new wxVariantDataDateTime(value); +} + +#endif // wxUSE_ODBC + wxDateTime wxVariant::GetDateTime() const { wxDateTime value; @@ -1429,14 +1367,15 @@ public: #endif virtual bool Read(wxString& str); virtual wxString GetType() const { return wxT("arrstring"); } - virtual wxVariantData* Clone() const { return new wxVariantDataArrayString(m_value); } + virtual wxVariantData* Clone() { return new wxVariantDataArrayString; } - DECLARE_WXANY_CONVERSION() protected: wxArrayString m_value; + + DECLARE_DYNAMIC_CLASS(wxVariantDataArrayString) }; -IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxArrayString, wxVariantDataArrayString) +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataArrayString, wxVariantData) bool wxVariantDataArrayString::Eq(wxVariantData& data) const { @@ -1461,7 +1400,7 @@ bool wxVariantDataArrayString::Write(wxString& str) const for ( size_t n = 0; n < count; n++ ) { if ( n ) - str += wxT(';'); + str += _T(';'); str += m_value[n]; } @@ -1481,7 +1420,7 @@ bool wxVariantDataArrayString::Read(wxSTD istream& WXUNUSED(str)) bool wxVariantDataArrayString::Read(wxString& str) { - wxStringTokenizer tk(str, wxT(";")); + wxStringTokenizer tk(str, _T(";")); while ( tk.HasMoreTokens() ) { m_value.Add(tk.GetNextToken()); @@ -1494,13 +1433,13 @@ bool wxVariantDataArrayString::Read(wxString& str) wxVariant::wxVariant(const wxArrayString& val, const wxString& name) // Strings { - m_refData = new wxVariantDataArrayString(val); + m_data = new wxVariantDataArrayString(val); m_name = name; } bool wxVariant::operator==(const wxArrayString& WXUNUSED(value)) const { - wxFAIL_MSG( wxT("TODO") ); + wxFAIL_MSG( _T("TODO") ); return false; } @@ -1513,14 +1452,14 @@ bool wxVariant::operator!=(const wxArrayString& value) const void wxVariant::operator=(const wxArrayString& value) { if (GetType() == wxT("arrstring") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataArrayString *)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataArrayString(value); + m_data = new wxVariantDataArrayString(value); } } @@ -1532,418 +1471,20 @@ wxArrayString wxVariant::GetArrayString() const return wxArrayString(); } -// ---------------------------------------------------------------------------- -// wxVariantDataLongLong -// ---------------------------------------------------------------------------- - -#if wxUSE_LONGLONG - -class WXDLLIMPEXP_BASE wxVariantDataLongLong : public wxVariantData -{ -public: - wxVariantDataLongLong() { m_value = 0; } - wxVariantDataLongLong(wxLongLong value) { m_value = value; } - - wxLongLong GetValue() const { return m_value; } - void SetValue(wxLongLong value) { m_value = value; } - - virtual bool Eq(wxVariantData& data) const; - - virtual bool Read(wxString& str); - virtual bool Write(wxString& str) const; -#if wxUSE_STD_IOSTREAM - virtual bool Read(wxSTD istream& str); - virtual bool Write(wxSTD ostream& str) const; -#endif -#if wxUSE_STREAMS - virtual bool Read(wxInputStream& str); - virtual bool Write(wxOutputStream &str) const; -#endif // wxUSE_STREAMS - - wxVariantData* Clone() const - { - return new wxVariantDataLongLong(m_value); - } - - virtual wxString GetType() const { return wxS("longlong"); } - - DECLARE_WXANY_CONVERSION() -protected: - wxLongLong m_value; -}; - -// -// wxLongLong type requires customized wxAny conversion code -// -#if wxUSE_ANY -#ifdef wxLongLong_t - -bool wxVariantDataLongLong::GetAsAny(wxAny* any) const -{ - *any = m_value.GetValue(); - return true; -} - -wxVariantData* wxVariantDataLongLong::VariantDataFactory(const wxAny& any) -{ - return new wxVariantDataLongLong(wxANY_AS(any, wxLongLong_t)); -} - -REGISTER_WXANY_CONVERSION(wxLongLong_t, wxVariantDataLongLong) - -#else // if !defined(wxLongLong_t) - -bool wxVariantDataLongLong::GetAsAny(wxAny* any) const -{ - *any = m_value; - return true; -} - -wxVariantData* wxVariantDataLongLong::VariantDataFactory(const wxAny& any) -{ - return new wxVariantDataLongLong(wxANY_AS(any, wxLongLong)); -} - -REGISTER_WXANY_CONVERSION(wxLongLong, wxVariantDataLongLong) - -#endif // defined(wxLongLong_t)/!defined(wxLongLong_t) -#endif // wxUSE_ANY - -bool wxVariantDataLongLong::Eq(wxVariantData& data) const -{ - wxASSERT_MSG( (data.GetType() == wxS("longlong")), - "wxVariantDataLongLong::Eq: argument mismatch" ); - - wxVariantDataLongLong& otherData = (wxVariantDataLongLong&) data; - - return (otherData.m_value == m_value); -} - -#if wxUSE_STD_IOSTREAM -bool wxVariantDataLongLong::Write(wxSTD ostream& str) const -{ - wxString s; - Write(s); - str << (const char*) s.mb_str(); - return true; -} -#endif - -bool wxVariantDataLongLong::Write(wxString& str) const -{ -#ifdef wxLongLong_t - str.Printf(wxS("%lld"), m_value.GetValue()); - return true; -#else - return false; -#endif -} - -#if wxUSE_STD_IOSTREAM -bool wxVariantDataLongLong::Read(wxSTD istream& WXUNUSED(str)) -{ - wxFAIL_MSG(wxS("Unimplemented")); - return false; -} -#endif - -#if wxUSE_STREAMS -bool wxVariantDataLongLong::Write(wxOutputStream& str) const -{ - wxTextOutputStream s(str); - s.Write32(m_value.GetLo()); - s.Write32(m_value.GetHi()); - return true; -} - -bool wxVariantDataLongLong::Read(wxInputStream& str) -{ - wxTextInputStream s(str); - unsigned long lo = s.Read32(); - long hi = s.Read32(); - m_value = wxLongLong(hi, lo); - return true; -} -#endif // wxUSE_STREAMS - -bool wxVariantDataLongLong::Read(wxString& str) -{ -#ifdef wxLongLong_t - wxLongLong_t value_t; - if ( !str.ToLongLong(&value_t) ) - return false; - m_value = value_t; - return true; -#else - return false; -#endif -} - -// wxVariant - -wxVariant::wxVariant(wxLongLong val, const wxString& name) -{ - m_refData = new wxVariantDataLongLong(val); - m_name = name; -} - -bool wxVariant::operator==(wxLongLong value) const -{ - wxLongLong thisValue; - if ( !Convert(&thisValue) ) - return false; - else - return (value == thisValue); -} - -bool wxVariant::operator!=(wxLongLong value) const -{ - return (!((*this) == value)); -} - -void wxVariant::operator=(wxLongLong value) -{ - if ( GetType() == wxS("longlong") && - m_refData->GetRefCount() == 1 ) - { - ((wxVariantDataLongLong*)GetData())->SetValue(value); - } - else - { - UnRef(); - m_refData = new wxVariantDataLongLong(value); - } -} - -wxLongLong wxVariant::GetLongLong() const -{ - wxLongLong value; - if ( Convert(&value) ) - { - return value; - } - else - { - wxFAIL_MSG(wxT("Could not convert to a long long")); - return 0; - } -} - -#endif // wxUSE_LONGLONG - -// ---------------------------------------------------------------------------- -// wxVariantDataULongLong -// ---------------------------------------------------------------------------- - -#if wxUSE_LONGLONG - -class WXDLLIMPEXP_BASE wxVariantDataULongLong : public wxVariantData -{ -public: - wxVariantDataULongLong() { m_value = 0; } - wxVariantDataULongLong(wxULongLong value) { m_value = value; } - - wxULongLong GetValue() const { return m_value; } - void SetValue(wxULongLong value) { m_value = value; } - - virtual bool Eq(wxVariantData& data) const; - - virtual bool Read(wxString& str); - virtual bool Write(wxString& str) const; -#if wxUSE_STD_IOSTREAM - virtual bool Read(wxSTD istream& str); - virtual bool Write(wxSTD ostream& str) const; -#endif -#if wxUSE_STREAMS - virtual bool Read(wxInputStream& str); - virtual bool Write(wxOutputStream &str) const; -#endif // wxUSE_STREAMS - - wxVariantData* Clone() const - { - return new wxVariantDataULongLong(m_value); - } - - virtual wxString GetType() const { return wxS("ulonglong"); } - - DECLARE_WXANY_CONVERSION() -protected: - wxULongLong m_value; -}; - -// -// wxULongLong type requires customized wxAny conversion code -// -#if wxUSE_ANY -#ifdef wxLongLong_t - -bool wxVariantDataULongLong::GetAsAny(wxAny* any) const -{ - *any = m_value.GetValue(); - return true; -} - -wxVariantData* wxVariantDataULongLong::VariantDataFactory(const wxAny& any) -{ - return new wxVariantDataULongLong(wxANY_AS(any, wxULongLong_t)); -} - -REGISTER_WXANY_CONVERSION(wxULongLong_t, wxVariantDataULongLong) - -#else // if !defined(wxLongLong_t) - -bool wxVariantDataULongLong::GetAsAny(wxAny* any) const -{ - *any = m_value; - return true; -} - -wxVariantData* wxVariantDataULongLong::VariantDataFactory(const wxAny& any) -{ - return new wxVariantDataULongLong(wxANY_AS(any, wxULongLong)); -} - -REGISTER_WXANY_CONVERSION(wxULongLong, wxVariantDataULongLong) - -#endif // defined(wxLongLong_t)/!defined(wxLongLong_t) -#endif // wxUSE_ANY - - -bool wxVariantDataULongLong::Eq(wxVariantData& data) const -{ - wxASSERT_MSG( (data.GetType() == wxS("ulonglong")), - "wxVariantDataULongLong::Eq: argument mismatch" ); - - wxVariantDataULongLong& otherData = (wxVariantDataULongLong&) data; - - return (otherData.m_value == m_value); -} - -#if wxUSE_STD_IOSTREAM -bool wxVariantDataULongLong::Write(wxSTD ostream& str) const -{ - wxString s; - Write(s); - str << (const char*) s.mb_str(); - return true; -} -#endif - -bool wxVariantDataULongLong::Write(wxString& str) const -{ -#ifdef wxLongLong_t - str.Printf(wxS("%llu"), m_value.GetValue()); - return true; -#else - return false; -#endif -} - -#if wxUSE_STD_IOSTREAM -bool wxVariantDataULongLong::Read(wxSTD istream& WXUNUSED(str)) -{ - wxFAIL_MSG(wxS("Unimplemented")); - return false; -} -#endif - -#if wxUSE_STREAMS -bool wxVariantDataULongLong::Write(wxOutputStream& str) const -{ - wxTextOutputStream s(str); - s.Write32(m_value.GetLo()); - s.Write32(m_value.GetHi()); - return true; -} - -bool wxVariantDataULongLong::Read(wxInputStream& str) -{ - wxTextInputStream s(str); - unsigned long lo = s.Read32(); - long hi = s.Read32(); - m_value = wxULongLong(hi, lo); - return true; -} -#endif // wxUSE_STREAMS - -bool wxVariantDataULongLong::Read(wxString& str) -{ -#ifdef wxLongLong_t - wxULongLong_t value_t; - if ( !str.ToULongLong(&value_t) ) - return false; - m_value = value_t; - return true; -#else - return false; -#endif -} - -// wxVariant - -wxVariant::wxVariant(wxULongLong val, const wxString& name) -{ - m_refData = new wxVariantDataULongLong(val); - m_name = name; -} - -bool wxVariant::operator==(wxULongLong value) const -{ - wxULongLong thisValue; - if ( !Convert(&thisValue) ) - return false; - else - return (value == thisValue); -} - -bool wxVariant::operator!=(wxULongLong value) const -{ - return (!((*this) == value)); -} - -void wxVariant::operator=(wxULongLong value) -{ - if ( GetType() == wxS("ulonglong") && - m_refData->GetRefCount() == 1 ) - { - ((wxVariantDataULongLong*)GetData())->SetValue(value); - } - else - { - UnRef(); - m_refData = new wxVariantDataULongLong(value); - } -} - -wxULongLong wxVariant::GetULongLong() const -{ - wxULongLong value; - if ( Convert(&value) ) - { - return value; - } - else - { - wxFAIL_MSG(wxT("Could not convert to a long long")); - return 0; - } -} - -#endif // wxUSE_LONGLONG - // ---------------------------------------------------------------------------- // wxVariantDataList // ---------------------------------------------------------------------------- class WXDLLIMPEXP_BASE wxVariantDataList: public wxVariantData { +DECLARE_DYNAMIC_CLASS(wxVariantDataList) public: wxVariantDataList() {} - wxVariantDataList(const wxVariantList& list); + wxVariantDataList(const wxList& list); virtual ~wxVariantDataList(); - wxVariantList& GetValue() { return m_value; } - void SetValue(const wxVariantList& value) ; + wxList& GetValue() { return m_value; } + void SetValue(const wxList& value) ; virtual bool Eq(wxVariantData& data) const; #if wxUSE_STD_IOSTREAM @@ -1958,54 +1499,13 @@ public: void Clear(); - wxVariantData* Clone() const { return new wxVariantDataList(m_value); } - - DECLARE_WXANY_CONVERSION() protected: - wxVariantList m_value; + wxList m_value; }; -#if wxUSE_ANY +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataList, wxVariantData) -// -// Convert to/from list of wxAnys -// - -bool wxVariantDataList::GetAsAny(wxAny* any) const -{ - wxAnyList dst; - wxVariantList::compatibility_iterator node = m_value.GetFirst(); - while (node) - { - wxVariant* pVar = node->GetData(); - dst.push_back(new wxAny(((const wxVariant&)*pVar))); - node = node->GetNext(); - } - - *any = dst; - return true; -} - -wxVariantData* wxVariantDataList::VariantDataFactory(const wxAny& any) -{ - wxAnyList src = wxANY_AS(any, wxAnyList); - wxVariantList dst; - wxAnyList::compatibility_iterator node = src.GetFirst(); - while (node) - { - wxAny* pAny = node->GetData(); - dst.push_back(new wxVariant(*pAny)); - node = node->GetNext(); - } - - return new wxVariantDataList(dst); -} - -REGISTER_WXANY_CONVERSION(wxAnyList, wxVariantDataList) - -#endif // wxUSE_ANY - -wxVariantDataList::wxVariantDataList(const wxVariantList& list) +wxVariantDataList::wxVariantDataList(const wxList& list) { SetValue(list); } @@ -2015,13 +1515,13 @@ wxVariantDataList::~wxVariantDataList() Clear(); } -void wxVariantDataList::SetValue(const wxVariantList& value) +void wxVariantDataList::SetValue(const wxList& value) { Clear(); - wxVariantList::compatibility_iterator node = value.GetFirst(); + wxList::compatibility_iterator node = value.GetFirst(); while (node) { - wxVariant* var = node->GetData(); + wxVariant* var = (wxVariant*) node->GetData(); m_value.Append(new wxVariant(*var)); node = node->GetNext(); } @@ -2029,10 +1529,10 @@ void wxVariantDataList::SetValue(const wxVariantList& value) void wxVariantDataList::Clear() { - wxVariantList::compatibility_iterator node = m_value.GetFirst(); + wxList::compatibility_iterator node = m_value.GetFirst(); while (node) { - wxVariant* var = node->GetData(); + wxVariant* var = (wxVariant*) node->GetData(); delete var; node = node->GetNext(); } @@ -2044,12 +1544,12 @@ bool wxVariantDataList::Eq(wxVariantData& data) const wxASSERT_MSG( (data.GetType() == wxT("list")), wxT("wxVariantDataList::Eq: argument mismatch") ); wxVariantDataList& listData = (wxVariantDataList&) data; - wxVariantList::compatibility_iterator node1 = m_value.GetFirst(); - wxVariantList::compatibility_iterator node2 = listData.GetValue().GetFirst(); + wxList::compatibility_iterator node1 = m_value.GetFirst(); + wxList::compatibility_iterator node2 = listData.GetValue().GetFirst(); while (node1 && node2) { - wxVariant* var1 = node1->GetData(); - wxVariant* var2 = node2->GetData(); + wxVariant* var1 = (wxVariant*) node1->GetData(); + wxVariant* var2 = (wxVariant*) node2->GetData(); if ((*var1) != (*var2)) return false; node1 = node1->GetNext(); @@ -2072,10 +1572,10 @@ bool wxVariantDataList::Write(wxSTD ostream& str) const bool wxVariantDataList::Write(wxString& str) const { str = wxEmptyString; - wxVariantList::compatibility_iterator node = m_value.GetFirst(); + wxList::compatibility_iterator node = m_value.GetFirst(); while (node) { - wxVariant* var = node->GetData(); + wxVariant* var = (wxVariant*) node->GetData(); if (node != m_value.GetFirst()) str += wxT(" "); wxString str1; @@ -2104,13 +1604,13 @@ bool wxVariantDataList::Read(wxString& WXUNUSED(str)) // wxVariant -wxVariant::wxVariant(const wxVariantList& val, const wxString& name) // List of variants +wxVariant::wxVariant(const wxList& val, const wxString& name) // List of variants { - m_refData = new wxVariantDataList(val); + m_data = new wxVariantDataList(val); m_name = name; } -bool wxVariant::operator== (const wxVariantList& value) const +bool wxVariant::operator== (const wxList& value) const { wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for == operator") ); @@ -2118,30 +1618,30 @@ bool wxVariant::operator== (const wxVariantList& value) const return (GetData()->Eq(other)); } -bool wxVariant::operator!= (const wxVariantList& value) const +bool wxVariant::operator!= (const wxList& value) const { return (!((*this) == value)); } -void wxVariant::operator= (const wxVariantList& value) +void wxVariant::operator= (const wxList& value) { if (GetType() == wxT("list") && - m_refData->GetRefCount() == 1) + m_data->GetRefCount() == 1) { ((wxVariantDataList*)GetData())->SetValue(value); } else { UnRef(); - m_refData = new wxVariantDataList(value); + m_data = new wxVariantDataList(value); } } -wxVariantList& wxVariant::GetList() const +wxList& wxVariant::GetList() const { wxASSERT( (GetType() == wxT("list")) ); - return (wxVariantList&) ((wxVariantDataList*) m_refData)->GetValue(); + return (wxList&) ((wxVariantDataList*) m_data)->GetValue(); } // Make empty list @@ -2153,7 +1653,7 @@ void wxVariant::NullList() // Append to list void wxVariant::Append(const wxVariant& value) { - wxVariantList& list = GetList(); + wxList& list = GetList(); list.Append(new wxVariant(value)); } @@ -2161,7 +1661,7 @@ void wxVariant::Append(const wxVariant& value) // Insert at front of list void wxVariant::Insert(const wxVariant& value) { - wxVariantList& list = GetList(); + wxList& list = GetList(); list.Insert(new wxVariant(value)); } @@ -2169,12 +1669,12 @@ void wxVariant::Insert(const wxVariant& value) // Returns true if the variant is a member of the list bool wxVariant::Member(const wxVariant& value) const { - wxVariantList& list = GetList(); + wxList& list = GetList(); - wxVariantList::compatibility_iterator node = list.GetFirst(); + wxList::compatibility_iterator node = list.GetFirst(); while (node) { - wxVariant* other = node->GetData(); + wxVariant* other = (wxVariant*) node->GetData(); if (value == *other) return true; node = node->GetNext(); @@ -2185,11 +1685,11 @@ bool wxVariant::Member(const wxVariant& value) const // Deletes the nth element of the list bool wxVariant::Delete(size_t item) { - wxVariantList& list = GetList(); + wxList& list = GetList(); wxASSERT_MSG( (item < list.GetCount()), wxT("Invalid index to Delete") ); - wxVariantList::compatibility_iterator node = list.Item(item); - wxVariant* variant = node->GetData(); + wxList::compatibility_iterator node = list.Item(item); + wxVariant* variant = (wxVariant*) node->GetData(); delete variant; list.Erase(node); return true; @@ -2200,28 +1700,194 @@ void wxVariant::ClearList() { if (!IsNull() && (GetType() == wxT("list"))) { - ((wxVariantDataList*) m_refData)->Clear(); + ((wxVariantDataList*) m_data)->Clear(); } else { if (!GetType().IsSameAs(wxT("list"))) UnRef(); - m_refData = new wxVariantDataList; + m_data = new wxVariantDataList; } } +#if WXWIN_COMPATIBILITY_2_4 + +// ---------------------------------------------------------------------------- +// wxVariantDataStringList +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_BASE wxVariantDataStringList: public wxVariantData +{ +DECLARE_DYNAMIC_CLASS(wxVariantDataStringList) +public: + wxVariantDataStringList() {} + wxVariantDataStringList(const wxStringList& list) { m_value = list; } + + wxStringList& GetValue() const { return (wxStringList&) m_value; } + void SetValue(const wxStringList& value); + + virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM + virtual bool Write(wxSTD ostream& str) const; +#endif + virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM + virtual bool Read(wxSTD istream& str); +#endif + virtual bool Read(wxString& str); + virtual wxString GetType() const { return wxT("stringlist"); }; + +protected: + wxStringList m_value; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxVariantDataStringList, wxVariantData) + +void wxVariantDataStringList::SetValue(const wxStringList& value) +{ + m_value = value; +} + +bool wxVariantDataStringList::Eq(wxVariantData& data) const +{ + wxASSERT_MSG( (data.GetType() == wxT("stringlist")), wxT("wxVariantDataStringList::Eq: argument mismatch") ); + + wxVariantDataStringList& listData = (wxVariantDataStringList&) data; + wxStringList::compatibility_iterator node1 = m_value.GetFirst(); + wxStringList::compatibility_iterator node2 = listData.GetValue().GetFirst(); + while (node1 && node2) + { + wxString str1 ( node1->GetData() ); + wxString str2 ( node2->GetData() ); + if (str1 != str2) + return false; + node1 = node1->GetNext(); + node2 = node2->GetNext(); + } + if (node1 || node2) return false; + return true; +} + +#if wxUSE_STD_IOSTREAM +bool wxVariantDataStringList::Write(wxSTD ostream& str) const +{ + wxString s; + Write(s); + str << (const char*) s.mb_str(); + return true; +} +#endif + +bool wxVariantDataStringList::Write(wxString& str) const +{ + str.Empty(); + wxStringList::compatibility_iterator node = m_value.GetFirst(); + while (node) + { + const wxChar* s = node->GetData(); + if (node != m_value.GetFirst()) + str += wxT(" "); + str += s; + node = node->GetNext(); + } + + return true; +} + +#if wxUSE_STD_IOSTREAM +bool wxVariantDataStringList::Read(wxSTD istream& WXUNUSED(str)) +{ + wxFAIL_MSG(wxT("Unimplemented")); + // TODO + return false; +} +#endif + +bool wxVariantDataStringList::Read(wxString& WXUNUSED(str)) +{ + wxFAIL_MSG(wxT("Unimplemented")); + // TODO + return false; +} + +#endif //2.4 compat + +#if WXWIN_COMPATIBILITY_2_4 + +wxVariant::wxVariant(const wxStringList& val, const wxString& name) +{ + m_data = new wxVariantDataStringList(val); + m_name = name; +} + +bool wxVariant::operator== (const wxStringList& value) const +{ + wxASSERT_MSG( (GetType() == wxT("stringlist")), wxT("Invalid type for == operator") ); + + wxVariantDataStringList other(value); + return (GetData()->Eq(other)); +} + +bool wxVariant::operator!= (const wxStringList& value) const +{ + wxASSERT_MSG( (GetType() == wxT("stringlist")), wxT("Invalid type for == operator") ); + + wxVariantDataStringList other(value); + return !(GetData()->Eq(other)); +} + +void wxVariant::operator= (const wxStringList& value) +{ + if (GetType() == wxT("stringlist") && + m_data->GetRefCount() == 1) + { + ((wxVariantDataStringList*)GetData())->SetValue(value); + } + else + { + UnRef(); + m_data = new wxVariantDataStringList(value); + } +} + +// wxVariant + +wxStringList& wxVariant::GetStringList() const +{ + wxASSERT( (GetType() == wxT("stringlist")) ); + + return (wxStringList&) ((wxVariantDataStringList*) m_data)->GetValue(); +} + +#endif + // Treat a list variant as an array wxVariant wxVariant::operator[] (size_t idx) const { +#if WXWIN_COMPATIBILITY_2_4 + wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for array operator") ); +#else wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for array operator") ); +#endif if (GetType() == wxT("list")) { - wxVariantDataList* data = (wxVariantDataList*) m_refData; + wxVariantDataList* data = (wxVariantDataList*) m_data; wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") ); - return *(data->GetValue().Item(idx)->GetData()); + return * (wxVariant*) (data->GetValue().Item(idx)->GetData()); } +#if WXWIN_COMPATIBILITY_2_4 + else if (GetType() == wxT("stringlist")) + { + wxVariantDataStringList* data = (wxVariantDataStringList*) m_data; + wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") ); + + wxString str( (const wxChar*) (data->GetValue().Item(idx)->GetData()) ); + wxVariant variant( str ); + return variant; + } +#endif return wxNullVariant; } @@ -2232,22 +1898,33 @@ wxVariant& wxVariant::operator[] (size_t idx) wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for array operator") ); - wxVariantDataList* data = (wxVariantDataList*) m_refData; + wxVariantDataList* data = (wxVariantDataList*) m_data; wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") ); - return * (data->GetValue().Item(idx)->GetData()); + return * (wxVariant*) (data->GetValue().Item(idx)->GetData()); } // Return the number of elements in a list size_t wxVariant::GetCount() const { +#if WXWIN_COMPATIBILITY_2_4 + wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for GetCount()") ); +#else wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for GetCount()") ); +#endif if (GetType() == wxT("list")) { - wxVariantDataList* data = (wxVariantDataList*) m_refData; + wxVariantDataList* data = (wxVariantDataList*) m_data; return data->GetValue().GetCount(); } +#if WXWIN_COMPATIBILITY_2_4 + else if (GetType() == wxT("stringlist")) + { + wxVariantDataStringList* data = (wxVariantDataStringList*) m_data; + return data->GetValue().GetCount(); + } +#endif return 0; } @@ -2258,32 +1935,16 @@ size_t wxVariant::GetCount() const bool wxVariant::Convert(long* value) const { wxString type(GetType()); - if (type == wxS("double")) + if (type == wxT("double")) *value = (long) (((wxVariantDoubleData*)GetData())->GetValue()); - else if (type == wxS("long")) + else if (type == wxT("long")) *value = ((wxVariantDataLong*)GetData())->GetValue(); - else if (type == wxS("bool")) +#ifdef HAVE_BOOL + else if (type == wxT("bool")) *value = (long) (((wxVariantDataBool*)GetData())->GetValue()); - else if (type == wxS("string")) - *value = wxAtol(((wxVariantDataString*)GetData())->GetValue()); -#if wxUSE_LONGLONG - else if (type == wxS("longlong")) - { - wxLongLong v = ((wxVariantDataLongLong*)GetData())->GetValue(); - // Don't convert if return value would be vague - if ( v < LONG_MIN || v > LONG_MAX ) - return false; - *value = v.ToLong(); - } - else if (type == wxS("ulonglong")) - { - wxULongLong v = ((wxVariantDataULongLong*)GetData())->GetValue(); - // Don't convert if return value would be vague - if ( v.GetHi() ) - return false; - *value = (long) v.ToULong(); - } #endif + else if (type == wxT("string")) + *value = wxAtol((const wxChar*) ((wxVariantDataString*)GetData())->GetValue()); else return false; @@ -2297,8 +1958,10 @@ bool wxVariant::Convert(bool* value) const *value = ((int) (((wxVariantDoubleData*)GetData())->GetValue()) != 0); else if (type == wxT("long")) *value = (((wxVariantDataLong*)GetData())->GetValue() != 0); +#ifdef HAVE_BOOL else if (type == wxT("bool")) *value = ((wxVariantDataBool*)GetData())->GetValue(); +#endif else if (type == wxT("string")) { wxString val(((wxVariantDataString*)GetData())->GetValue()); @@ -2323,159 +1986,41 @@ bool wxVariant::Convert(double* value) const *value = ((wxVariantDoubleData*)GetData())->GetValue(); else if (type == wxT("long")) *value = (double) (((wxVariantDataLong*)GetData())->GetValue()); +#ifdef HAVE_BOOL else if (type == wxT("bool")) *value = (double) (((wxVariantDataBool*)GetData())->GetValue()); - else if (type == wxT("string")) - *value = (double) wxAtof(((wxVariantDataString*)GetData())->GetValue()); -#if wxUSE_LONGLONG - else if (type == wxS("longlong")) - { - *value = ((wxVariantDataLongLong*)GetData())->GetValue().ToDouble(); - } - else if (type == wxS("ulonglong")) - { - *value = ((wxVariantDataULongLong*)GetData())->GetValue().ToDouble(); - } #endif + else if (type == wxT("string")) + *value = (double) wxAtof((const wxChar*) ((wxVariantDataString*)GetData())->GetValue()); else return false; return true; } -bool wxVariant::Convert(wxUniChar* value) const +bool wxVariant::Convert(wxChar* value) const { wxString type(GetType()); if (type == wxT("char")) *value = ((wxVariantDataChar*)GetData())->GetValue(); else if (type == wxT("long")) *value = (char) (((wxVariantDataLong*)GetData())->GetValue()); +#ifdef HAVE_BOOL else if (type == wxT("bool")) *value = (char) (((wxVariantDataBool*)GetData())->GetValue()); - else if (type == wxS("string")) - { - // Also accept strings of length 1 - const wxString& str = (((wxVariantDataString*)GetData())->GetValue()); - if ( str.length() == 1 ) - *value = str[0]; - else - return false; - } +#endif else return false; return true; } -bool wxVariant::Convert(char* value) const -{ - wxUniChar ch; - if ( !Convert(&ch) ) - return false; - *value = ch; - return true; -} - -bool wxVariant::Convert(wchar_t* value) const -{ - wxUniChar ch; - if ( !Convert(&ch) ) - return false; - *value = ch; - return true; -} - bool wxVariant::Convert(wxString* value) const { *value = MakeString(); return true; } -#if wxUSE_LONGLONG -bool wxVariant::Convert(wxLongLong* value) const -{ - wxString type(GetType()); - if (type == wxS("longlong")) - *value = ((wxVariantDataLongLong*)GetData())->GetValue(); - else if (type == wxS("long")) - *value = ((wxVariantDataLong*)GetData())->GetValue(); - else if (type == wxS("string")) - { - wxString s = ((wxVariantDataString*)GetData())->GetValue(); -#ifdef wxLongLong_t - wxLongLong_t value_t; - if ( !s.ToLongLong(&value_t) ) - return false; - *value = value_t; -#else - long l_value; - if ( !s.ToLong(&l_value) ) - return false; - *value = l_value; -#endif - } - else if (type == wxS("bool")) - *value = (long) (((wxVariantDataBool*)GetData())->GetValue()); - else if (type == wxS("double")) - { - value->Assign(((wxVariantDoubleData*)GetData())->GetValue()); - } - else if (type == wxS("ulonglong")) - *value = ((wxVariantDataULongLong*)GetData())->GetValue(); - else - return false; - - return true; -} - -bool wxVariant::Convert(wxULongLong* value) const -{ - wxString type(GetType()); - if (type == wxS("ulonglong")) - *value = ((wxVariantDataULongLong*)GetData())->GetValue(); - else if (type == wxS("long")) - *value = ((wxVariantDataLong*)GetData())->GetValue(); - else if (type == wxS("string")) - { - wxString s = ((wxVariantDataString*)GetData())->GetValue(); -#ifdef wxLongLong_t - wxULongLong_t value_t; - if ( !s.ToULongLong(&value_t) ) - return false; - *value = value_t; -#else - unsigned long l_value; - if ( !s.ToULong(&l_value) ) - return false; - *value = l_value; -#endif - } - else if (type == wxS("bool")) - *value = (long) (((wxVariantDataBool*)GetData())->GetValue()); - else if (type == wxS("double")) - { - double value_d = ((wxVariantDoubleData*)GetData())->GetValue(); - - if ( value_d < 0.0 ) - return false; - -#ifdef wxLongLong_t - *value = (wxULongLong_t) value_d; -#else - wxLongLong temp; - temp.Assign(value_d); - *value = temp; -#endif - } - else if (type == wxS("longlong")) - *value = ((wxVariantDataLongLong*)GetData())->GetValue(); - else - return false; - - return true; -} -#endif // wxUSE_LONGLONG - #if wxUSE_DATETIME bool wxVariant::Convert(wxDateTime* value) const { @@ -2485,25 +2030,10 @@ bool wxVariant::Convert(wxDateTime* value) const *value = ((wxVariantDataDateTime*)GetData())->GetValue(); return true; } - // Fallback to string conversion wxString val; - if ( !Convert(&val) ) - return false; - - // Try to parse this as either date and time, only date or only time - // checking that the entire string was parsed - wxString::const_iterator end; - if ( value->ParseDateTime(val, &end) && end == val.end() ) - return true; - - if ( value->ParseDate(val, &end) && end == val.end() ) - return true; - - if ( value->ParseTime(val, &end) && end == val.end() ) - return true; - - return false; + return Convert(&val) && + (value->ParseDateTime(val) || value->ParseDate(val) || value->ParseTime(val)); } #endif // wxUSE_DATETIME diff --git a/Source/3rd Party/wx/src/common/webview.cpp b/Source/3rd Party/wx/src/common/webview.cpp deleted file mode 100644 index afaf3ffd0..000000000 --- a/Source/3rd Party/wx/src/common/webview.cpp +++ /dev/null @@ -1,111 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webview.cpp -// Purpose: Common interface and events for web view component -// Author: Marianne Gagnon -// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if wxUSE_WEBVIEW - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#include "wx/webview.h" - -#if defined(__WXOSX_COCOA__) || defined(__WXOSX_CARBON__) -#include "wx/osx/webview_webkit.h" -#elif defined(__WXGTK__) -#include "wx/gtk/webview_webkit.h" -#elif defined(__WXMSW__) -#include "wx/msw/webview_ie.h" -#endif - -// DLL options compatibility check: -#include "wx/app.h" -WX_CHECK_BUILD_OPTIONS("wxWEBVIEW") - -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[] = "wxWebView"; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr[] = "about:blank"; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE[] = "wxWebViewIE"; -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[] = "wxWebViewWebKit"; - -#ifdef __WXMSW__ -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewIE"; -#else -extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewWebKit"; -#endif - -wxIMPLEMENT_ABSTRACT_CLASS(wxWebView, wxControl); -wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEvent, wxCommandEvent); - -wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATING, wxWebViewEvent ); -wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATED, wxWebViewEvent ); -wxDEFINE_EVENT( wxEVT_WEBVIEW_LOADED, wxWebViewEvent ); -wxDEFINE_EVENT( wxEVT_WEBVIEW_ERROR, wxWebViewEvent ); -wxDEFINE_EVENT( wxEVT_WEBVIEW_NEWWINDOW, wxWebViewEvent ); -wxDEFINE_EVENT( wxEVT_WEBVIEW_TITLE_CHANGED, wxWebViewEvent ); - -wxStringWebViewFactoryMap wxWebView::m_factoryMap; - -// static -wxWebView* wxWebView::New(const wxString& backend) -{ - wxStringWebViewFactoryMap::iterator iter = FindFactory(backend); - - if(iter == m_factoryMap.end()) - return NULL; - else - return (*iter).second->Create(); -} - -// static -wxWebView* wxWebView::New(wxWindow* parent, wxWindowID id, const wxString& url, - const wxPoint& pos, const wxSize& size, - const wxString& backend, long style, - const wxString& name) -{ - wxStringWebViewFactoryMap::iterator iter = FindFactory(backend); - - if(iter == m_factoryMap.end()) - return NULL; - else - return (*iter).second->Create(parent, id, url, pos, size, style, name); - -} - -// static -void wxWebView::RegisterFactory(const wxString& backend, - wxSharedPtr factory) -{ - m_factoryMap[backend] = factory; -} - -// static -wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backend) -{ - // Initialise the map, it checks internally for existing factories - InitFactoryMap(); - - return m_factoryMap.find(backend); -} - -// static -void wxWebView::InitFactoryMap() -{ -#ifdef __WXMSW__ - if(m_factoryMap.find(wxWebViewBackendIE) == m_factoryMap.end()) - RegisterFactory(wxWebViewBackendIE, wxSharedPtr - (new wxWebViewFactoryIE)); -#else - if(m_factoryMap.find(wxWebViewBackendWebKit) == m_factoryMap.end()) - RegisterFactory(wxWebViewBackendWebKit, wxSharedPtr - (new wxWebViewFactoryWebKit)); -#endif -} - -#endif // wxUSE_WEBVIEW diff --git a/Source/3rd Party/wx/src/common/webviewarchivehandler.cpp b/Source/3rd Party/wx/src/common/webviewarchivehandler.cpp deleted file mode 100644 index cb8f608a2..000000000 --- a/Source/3rd Party/wx/src/common/webviewarchivehandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webviewfilehandler.cpp -// Purpose: Custom webview handler to allow archive browsing -// Author: Steven Lamerton -// Copyright: (c) 2011 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if wxUSE_WEBVIEW - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#include "wx/webviewarchivehandler.h" -#include "wx/filesys.h" - -//Taken from wx/filesys.cpp -static wxString EscapeFileNameCharsInURL(const char *in) -{ - wxString s; - - for ( const unsigned char *p = (const unsigned char*)in; *p; ++p ) - { - const unsigned char c = *p; - - if ( c == '/' || c == '-' || c == '.' || c == '_' || c == '~' || - (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') ) - { - s << c; - } - else - { - s << wxString::Format("%%%02x", c); - } - } - - return s; -} - -wxWebViewArchiveHandler::wxWebViewArchiveHandler(const wxString& scheme) : - wxWebViewHandler(scheme) -{ - m_fileSystem = new wxFileSystem(); -} - -wxWebViewArchiveHandler::~wxWebViewArchiveHandler() -{ - wxDELETE(m_fileSystem); -} - -wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri) -{ - //If there is a fragment at the end of the path then we need to strip it - //off as not all backends do this for us - wxString path = uri; - size_t hashloc = uri.find('#'); - if(hashloc != wxString::npos) - { - path = uri.substr(0, hashloc); - } - - //We iterate through the string to see if there is a protocol description - size_t start = wxString::npos; - for(size_t i = 0; i < path.length(); i++) - { - if(path[i] == ';' && path.substr(i, 10) == ";protocol=") - { - start = i; - break; - } - } - - //We do not have a protocol string so we just pass the path withouth the - if(start == wxString::npos) - { - size_t doubleslash = path.find("//"); - //The path is incorrectly formed without // after the scheme - if(doubleslash == wxString::npos) - return NULL; - - wxString fspath = "file:" + - EscapeFileNameCharsInURL(path.substr(doubleslash + 2).c_str()); - return m_fileSystem->OpenFile(fspath); - } - //Otherwise we need to extract the protocol - else - { - size_t end = path.find('/', start); - //For the path to be valid there must to a path after the protocol - if(end == wxString::npos) - { - return NULL; - } - wxString mainpath = path.substr(0, start); - wxString archivepath = path.substr(end); - wxString protstring = path.substr(start, end - start); - wxString protocol = protstring.substr(10); - //We can now construct the correct path - size_t doubleslash = path.find("//"); - //The path is incorrectly formed without // after the first protocol - if(doubleslash == wxString::npos) - return NULL; - - wxString fspath = "file:" + - EscapeFileNameCharsInURL(mainpath.substr(doubleslash + 2).c_str()) - + "#" + protocol +":" + archivepath; - return m_fileSystem->OpenFile(fspath); - } -} - -#endif // wxUSE_WEBVIEW diff --git a/Source/3rd Party/wx/src/common/webviewfshandler.cpp b/Source/3rd Party/wx/src/common/webviewfshandler.cpp deleted file mode 100644 index 3b62dcfe4..000000000 --- a/Source/3rd Party/wx/src/common/webviewfshandler.cpp +++ /dev/null @@ -1,37 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: webviewfshandler.cpp -// Purpose: Custom webview handler for virtual file system -// Author: Nick Matthews -// Copyright: (c) 2012 Steven Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if wxUSE_WEBVIEW - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#include "wx/webviewfshandler.h" -#include "wx/filesys.h" - -wxWebViewFSHandler::wxWebViewFSHandler(const wxString& scheme) : - wxWebViewHandler(scheme) -{ - m_fileSystem = new wxFileSystem(); -} - -wxWebViewFSHandler::~wxWebViewFSHandler() -{ - wxDELETE(m_fileSystem); -} - -wxFSFile* wxWebViewFSHandler::GetFile(const wxString &uri) -{ - return m_fileSystem->OpenFile(uri); -} - -#endif // wxUSE_WEBVIEW diff --git a/Source/3rd Party/wx/src/common/wfstream.cpp b/Source/3rd Party/wx/src/common/wfstream.cpp index 362b1861d..c5fe73be6 100644 --- a/Source/3rd Party/wx/src/common/wfstream.cpp +++ b/Source/3rd Party/wx/src/common/wfstream.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/wfstream.cpp +// Name: src/common/fstream.cpp // Purpose: "File stream" classes // Author: Julian Smart // Modified by: // Created: 11/07/98 +// RCS-ID: $Id: wfstream.cpp 54418 2008-06-29 01:28:43Z VZ $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -108,7 +109,7 @@ wxFileOffset wxFileInputStream::OnSysTell() const bool wxFileInputStream::IsOk() const { - return wxInputStream::IsOk() && m_file->IsOpened(); + return (wxStreamBase::IsOk() && m_file->IsOpened()); } // ---------------------------------------------------------------------------- @@ -184,7 +185,7 @@ wxFileOffset wxFileOutputStream::GetLength() const bool wxFileOutputStream::IsOk() const { - return wxOutputStream::IsOk() && m_file->IsOpened(); + return (wxStreamBase::IsOk() && m_file->IsOpened()); } // ---------------------------------------------------------------------------- @@ -231,12 +232,7 @@ wxFileStream::wxFileStream(const wxString& fileName) wxFileInputStream::m_file_destroy = true; } -bool wxFileStream::IsOk() const -{ - return wxFileOutputStream::IsOk() && wxFileInputStream::IsOk(); -} - -#endif // wxUSE_FILE +#endif //wxUSE_FILE #if wxUSE_FFILE @@ -245,7 +241,7 @@ bool wxFileStream::IsOk() const // ---------------------------------------------------------------------------- wxFFileInputStream::wxFFileInputStream(const wxString& fileName, - const wxString& mode) + const wxChar *mode) : wxInputStream() { m_file = new wxFFile(fileName, mode); @@ -313,7 +309,7 @@ wxFileOffset wxFFileInputStream::OnSysTell() const bool wxFFileInputStream::IsOk() const { - return wxStreamBase::IsOk() && m_file->IsOpened(); + return (wxStreamBase::IsOk() && m_file->IsOpened()); } // ---------------------------------------------------------------------------- @@ -321,7 +317,7 @@ bool wxFFileInputStream::IsOk() const // ---------------------------------------------------------------------------- wxFFileOutputStream::wxFFileOutputStream(const wxString& fileName, - const wxString& mode) + const wxChar *mode) { m_file = new wxFFile(fileName, mode); m_file_destroy = true; @@ -399,32 +395,24 @@ wxFileOffset wxFFileOutputStream::GetLength() const bool wxFFileOutputStream::IsOk() const { - return wxStreamBase::IsOk() && m_file->IsOpened(); + return (wxStreamBase::IsOk() && m_file->IsOpened()); } // ---------------------------------------------------------------------------- // wxFFileStream // ---------------------------------------------------------------------------- -wxFFileStream::wxFFileStream(const wxString& fileName, const wxString& mode) +wxFFileStream::wxFFileStream(const wxString& fileName) : wxFFileInputStream(), wxFFileOutputStream() { - wxASSERT_MSG( mode.find_first_of('+') != wxString::npos, - "must be opened in read-write mode for this class to work" ); - wxFFileOutputStream::m_file = - wxFFileInputStream::m_file = new wxFFile(fileName, mode); + wxFFileInputStream::m_file = new wxFFile(fileName, _T("w+b")); // see comment in wxFileStream ctor wxFFileInputStream::m_file_destroy = true; } -bool wxFFileStream::IsOk() const -{ - return wxFFileOutputStream::IsOk() && wxFFileInputStream::IsOk(); -} - #endif //wxUSE_FFILE #endif // wxUSE_STREAMS diff --git a/Source/3rd Party/wx/src/common/wincmn.cpp b/Source/3rd Party/wx/src/common/wincmn.cpp index ad4887093..03394bf2b 100644 --- a/Source/3rd Party/wx/src/common/wincmn.cpp +++ b/Source/3rd Party/wx/src/common/wincmn.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/wincmn.cpp +// Name: src/common/window.cpp // Purpose: common (to all ports) wxWindow functions // Author: Julian Smart, Vadim Zeitlin // Modified by: // Created: 13/07/98 +// RCS-ID: $Id: wincmn.cpp 63032 2009-12-31 13:37:24Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,14 +38,12 @@ #include "wx/settings.h" #include "wx/dialog.h" #include "wx/msgdlg.h" - #include "wx/msgout.h" #include "wx/statusbr.h" #include "wx/toolbar.h" #include "wx/dcclient.h" #include "wx/scrolbar.h" #include "wx/layout.h" #include "wx/sizer.h" - #include "wx/menu.h" #endif //WX_PRECOMP #if wxUSE_DRAG_AND_DROP @@ -71,36 +70,35 @@ #include "wx/sysopt.h" #endif -#include "wx/platinfo.h" -#include "wx/recguard.h" -#include "wx/private/window.h" - -#ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" +// For reporting compile- and runtime version of GTK+ in the ctrl+alt+mclick dialog. +// The gtk includes don't pull any other headers in, at least not on my system - MR +#ifdef __WXGTK__ + #ifdef __WXGTK20__ + #include + #else + #include + #endif + extern const unsigned int gtk_major_version; + extern const unsigned int gtk_minor_version; + extern const unsigned int gtk_micro_version; #endif +#include "wx/platinfo.h" + // Windows List WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows; -// globals -#if wxUSE_MENUS -wxMenu *wxCurrentPopupMenu = NULL; -#endif // wxUSE_MENUS - -extern WXDLLEXPORT_DATA(const char) wxPanelNameStr[] = "panel"; - -namespace wxMouseCapture -{ - -// Check if the given window is in the capture stack. -bool IsInCaptureStack(wxWindowBase* win); - -} // wxMouseCapture - // ---------------------------------------------------------------------------- // static data // ---------------------------------------------------------------------------- +#if defined(__WXPALMOS__) +int wxWindowBase::ms_lastControlId = 32767; +#elif defined(__WXPM__) +int wxWindowBase::ms_lastControlId = 2000; +#else +int wxWindowBase::ms_lastControlId = -200; +#endif IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler) @@ -117,145 +115,12 @@ BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler) EVT_HELP(wxID_ANY, wxWindowBase::OnHelp) #endif // wxUSE_HELP - EVT_SIZE(wxWindowBase::InternalOnSize) END_EVENT_TABLE() // ============================================================================ // implementation of the common functionality of the wxWindow class // ============================================================================ -// ---------------------------------------------------------------------------- -// XTI -// ---------------------------------------------------------------------------- - -#if wxUSE_EXTENDED_RTTI - -// windows that are created from a parent window during its Create method, -// eg. spin controls in a calendar controls must never been streamed out -// separately otherwise chaos occurs. Right now easiest is to test for negative ids, -// as windows with negative ids never can be recreated anyway - - -bool wxWindowStreamingCallback( const wxObject *object, wxObjectWriter *, - wxObjectWriterCallback *, const wxStringToAnyHashMap & ) -{ - const wxWindow * win = wx_dynamic_cast(const wxWindow*, object); - if ( win && win->GetId() < 0 ) - return false; - return true; -} - -wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxWindow, wxWindowBase, "wx/window.h", \ - wxWindowStreamingCallback) - -// make wxWindowList known before the property is used - -wxCOLLECTION_TYPE_INFO( wxWindow*, wxWindowList ); - -template<> void wxCollectionToVariantArray( wxWindowList const &theList, - wxAnyList &value) -{ - wxListCollectionToAnyList( theList, value ); -} - -wxDEFINE_FLAGS( wxWindowStyle ) - -wxBEGIN_FLAGS( wxWindowStyle ) -// new style border flags, we put them first to -// use them for streaming out - -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxEND_FLAGS( wxWindowStyle ) - -wxBEGIN_PROPERTIES_TABLE(wxWindow) -wxEVENT_PROPERTY( Close, wxEVT_CLOSE_WINDOW, wxCloseEvent) -wxEVENT_PROPERTY( Create, wxEVT_CREATE, wxWindowCreateEvent ) -wxEVENT_PROPERTY( Destroy, wxEVT_DESTROY, wxWindowDestroyEvent ) -// Always constructor Properties first - -wxREADONLY_PROPERTY( Parent,wxWindow*, GetParent, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) -wxPROPERTY( Id,wxWindowID, SetId, GetId, -1 /*wxID_ANY*/, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group") ) -wxPROPERTY( Position,wxPoint, SetPosition, GetPosition, wxDefaultPosition, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) // pos -wxPROPERTY( Size,wxSize, SetSize, GetSize, wxDefaultSize, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // size -wxPROPERTY( WindowStyle, long, SetWindowStyleFlag, GetWindowStyleFlag, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // style -wxPROPERTY( Name,wxString, SetName, GetName, wxEmptyString, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group") ) - -// Then all relations of the object graph - -wxREADONLY_PROPERTY_COLLECTION( Children, wxWindowList, wxWindowBase*, \ - GetWindowChildren, wxPROP_OBJECT_GRAPH /*flags*/, \ - wxT("Helpstring"), wxT("group")) - -// and finally all other properties - -wxPROPERTY( ExtraStyle, long, SetExtraStyle, GetExtraStyle, wxEMPTY_PARAMETER_VALUE, \ - 0 /*flags*/, wxT("Helpstring"), wxT("group")) // extstyle -wxPROPERTY( BackgroundColour, wxColour, SetBackgroundColour, GetBackgroundColour, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // bg -wxPROPERTY( ForegroundColour, wxColour, SetForegroundColour, GetForegroundColour, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // fg -wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxAny((bool)true), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) -wxPROPERTY( Shown, bool, Show, IsShown, wxAny((bool)true), 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) - -#if 0 -// possible property candidates (not in xrc) or not valid in all subclasses -wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxEmptyString ) -wxPROPERTY( Font, wxFont, SetFont, GetWindowFont , ) -wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString ) -// MaxHeight, Width, MinHeight, Width -// TODO switch label to control and title to toplevels - -wxPROPERTY( ThemeEnabled, bool, SetThemeEnabled, GetThemeEnabled, ) -//wxPROPERTY( Cursor, wxCursor, SetCursor, GetCursor, ) -// wxPROPERTY( ToolTip, wxString, SetToolTip, GetToolTipText, ) -wxPROPERTY( AutoLayout, bool, SetAutoLayout, GetAutoLayout, ) -#endif -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxWindow) - -wxCONSTRUCTOR_DUMMY(wxWindow) - -#else - -#ifndef __WXUNIVERSAL__ -IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -#endif - -#endif - // ---------------------------------------------------------------------------- // initialization // ---------------------------------------------------------------------------- @@ -264,7 +129,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) wxWindowBase::wxWindowBase() { // no window yet, no parent nor children - m_parent = NULL; + m_parent = (wxWindow *)NULL; m_windowId = wxID_ANY; // no constraints on the minimal window size @@ -285,7 +150,7 @@ wxWindowBase::wxWindowBase() #if wxUSE_VALIDATORS // no validator - m_windowValidator = NULL; + m_windowValidator = (wxValidator *) NULL; #endif // wxUSE_VALIDATORS // the colours/fonts are default for now, so leave m_font, @@ -301,28 +166,28 @@ wxWindowBase::wxWindowBase() m_exStyle = m_windowStyle = 0; - m_backgroundStyle = wxBG_STYLE_ERASE; + m_backgroundStyle = wxBG_STYLE_SYSTEM; #if wxUSE_CONSTRAINTS // no constraints whatsoever - m_constraints = NULL; - m_constraintsInvolvedIn = NULL; + m_constraints = (wxLayoutConstraints *) NULL; + m_constraintsInvolvedIn = (wxWindowList *) NULL; #endif // wxUSE_CONSTRAINTS - m_windowSizer = NULL; - m_containingSizer = NULL; + m_windowSizer = (wxSizer *) NULL; + m_containingSizer = (wxSizer *) NULL; m_autoLayout = false; #if wxUSE_DRAG_AND_DROP - m_dropTarget = NULL; + m_dropTarget = (wxDropTarget *)NULL; #endif // wxUSE_DRAG_AND_DROP #if wxUSE_TOOLTIPS - m_tooltip = NULL; + m_tooltip = (wxToolTip *)NULL; #endif // wxUSE_TOOLTIPS #if wxUSE_CARET - m_caret = NULL; + m_caret = (wxCaret *)NULL; #endif // wxUSE_CARET #if wxUSE_PALETTE @@ -335,7 +200,12 @@ wxWindowBase::wxWindowBase() m_virtualSize = wxDefaultSize; - m_scrollHelper = NULL; + m_scrollHelper = (wxScrollHelper *) NULL; + + m_minVirtualWidth = + m_maxVirtualWidth = wxDefaultCoord; + m_minVirtualHeight = + m_maxVirtualHeight = wxDefaultCoord; m_windowVariant = wxWINDOW_VARIANT_NORMAL; #if wxUSE_SYSTEM_OPTIONS @@ -348,70 +218,47 @@ wxWindowBase::wxWindowBase() // Whether we're using the current theme for this window (wxGTK only for now) m_themeEnabled = false; - // This is set to true by SendDestroyEvent() which should be called by the - // most derived class to ensure that the destruction event is sent as soon - // as possible to allow its handlers to still see the undestroyed window + // VZ: this one shouldn't exist... m_isBeingDeleted = false; - - m_freezeCount = 0; } // common part of window creation process bool wxWindowBase::CreateBase(wxWindowBase *parent, wxWindowID id, const wxPoint& WXUNUSED(pos), - const wxSize& size, + const wxSize& WXUNUSED(size), long style, + const wxValidator& wxVALIDATOR_PARAM(validator), const wxString& name) { +#if wxUSE_STATBOX + // wxGTK doesn't allow to create controls with static box as the parent so + // this will result in a crash when the program is ported to wxGTK so warn + // the user about it + + // if you get this assert, the correct solution is to create the controls + // as siblings of the static box + wxASSERT_MSG( !parent || !wxDynamicCast(parent, wxStaticBox), + _T("wxStaticBox can't be used as a window parent!") ); +#endif // wxUSE_STATBOX + // ids are limited to 16 bits under MSW so if you care about portability, // it's not a good idea to use ids out of this range (and negative ids are // reserved for wxWidgets own usage) - wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767) || - (id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST), - wxT("invalid id value") ); + wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767), + _T("invalid id value") ); // generate a new id if the user doesn't care about it - if ( id == wxID_ANY ) - { - m_windowId = NewControlId(); - } - else // valid id specified - { - m_windowId = id; - } + m_windowId = id == wxID_ANY ? NewControlId() : id; // don't use SetWindowStyleFlag() here, this function should only be called // to change the flag after creation as it tries to reflect the changes in // flags by updating the window dynamically and we don't need this here m_windowStyle = style; - // assume the user doesn't want this window to shrink beneath its initial - // size, this worked like this in wxWidgets 2.8 and before and generally - // often makes sense for child windows (for top level ones it definitely - // does not as the user should be able to resize the window) - // - // note that we can't use IsTopLevel() from ctor - if ( size != wxDefaultSize && !wxTopLevelWindows.Find((wxWindow *)this) ) - SetMinSize(size); - SetName(name); SetParent(parent); - return true; -} - -bool wxWindowBase::CreateBase(wxWindowBase *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& wxVALIDATOR_PARAM(validator), - const wxString& name) -{ - if ( !CreateBase(parent, id, pos, size, style, name) ) - return false; - #if wxUSE_VALIDATORS SetValidator(validator); #endif // wxUSE_VALIDATORS @@ -429,7 +276,7 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, bool wxWindowBase::ToggleWindowStyle(int flag) { - wxASSERT_MSG( flag, wxT("flags with 0 value can't be toggled") ); + wxASSERT_MSG( flag, _T("flags with 0 value can't be toggled") ); bool rc; long style = GetWindowStyleFlag(); @@ -456,9 +303,7 @@ bool wxWindowBase::ToggleWindowStyle(int flag) // common clean up wxWindowBase::~wxWindowBase() { - wxASSERT_MSG( !wxMouseCapture::IsInCaptureStack(this), - "Destroying window before releasing mouse capture: this " - "will result in a crash later." ); + wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") ); // FIXME if these 2 cases result from programming errors in the user code // we should probably assert here instead of silently fixing them @@ -471,24 +316,42 @@ wxWindowBase::~wxWindowBase() // we weren't a dialog class wxTopLevelWindows.DeleteObject((wxWindow*)this); - // Any additional event handlers should be popped before the window is - // deleted as otherwise the last handler will be left with a dangling - // pointer to this window result in a difficult to diagnose crash later on. - wxASSERT_MSG( GetEventHandler() == this, - wxT("any pushed event handlers must have been removed") ); - -#if wxUSE_MENUS - // The associated popup menu can still be alive, disassociate from it in - // this case - if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetInvokingWindow() == this ) - wxCurrentPopupMenu->SetInvokingWindow(NULL); -#endif // wxUSE_MENUS - wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") ); - // notify the parent about this window destruction + // reset the top-level parent's default item if it is this widget if ( m_parent ) + { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this), + wxTopLevelWindow); + + if ( tlw ) + { + wxWindow* tmpDefaultItem = tlw->GetTmpDefaultItem(); + if ( tmpDefaultItem == this ) + tlw->SetTmpDefaultItem(NULL); + else if ( tmpDefaultItem ) + { + // A temporary default item masks the real default item, so + // temporarily unset the temporary default item so we can access the + // real default item. + tlw->SetTmpDefaultItem(NULL); + + if ( tlw->GetDefaultItem() == this ) + tlw->SetDefaultItem(NULL); + + // Set the temporary default item back. + tlw->SetTmpDefaultItem(tmpDefaultItem); + } + else if ( tlw->GetDefaultItem() == this ) + tlw->SetDefaultItem(NULL); + } + } + + // reset the dangling pointer our parent window may keep to us + if ( m_parent ) + { m_parent->RemoveChild(this); + } #if wxUSE_CARET delete m_caret; @@ -508,7 +371,8 @@ wxWindowBase::~wxWindowBase() // This removes any dangling pointers to this window in other windows' // constraintsInvolvedIn lists. UnsetConstraints(m_constraints); - wxDELETE(m_constraints); + delete m_constraints; + m_constraints = NULL; } #endif // wxUSE_CONSTRAINTS @@ -530,32 +394,16 @@ wxWindowBase::~wxWindowBase() #endif #if wxUSE_HELP - // NB: this has to be called unconditionally, because we don't know - // whether this window has associated help text or not + // NB: this has to be called unconditionally, because we don't + // know whether this window has associated help text or not wxHelpProvider *helpProvider = wxHelpProvider::Get(); if ( helpProvider ) helpProvider->RemoveHelp(this); #endif } -bool wxWindowBase::IsBeingDeleted() const -{ - return m_isBeingDeleted || - (!IsTopLevel() && m_parent && m_parent->IsBeingDeleted()); -} - void wxWindowBase::SendDestroyEvent() { - if ( m_isBeingDeleted ) - { - // we could have been already called from a more derived class dtor, - // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call - // should be simply ignored - return; - } - - m_isBeingDeleted = true; - wxWindowDestroyEvent event; event.SetEventObject(this); event.SetId(GetId()); @@ -564,15 +412,6 @@ void wxWindowBase::SendDestroyEvent() bool wxWindowBase::Destroy() { - // If our handle is invalid, it means that this window has never been - // created, either because creating it failed or, more typically, because - // this wxWindow object was default-constructed and its Create() method had - // never been called. As we didn't send wxWindowCreateEvent in this case - // (which is sent after successful creation), don't send the matching - // wxWindowDestroyEvent neither. - if ( GetHandle() ) - SendDestroyEvent(); - delete this; return true; @@ -586,7 +425,7 @@ bool wxWindowBase::Close(bool force) // return false if window wasn't closed because the application vetoed the // close event - return HandleWindowEvent(event) && !event.GetVeto(); + return GetEventHandler()->ProcessEvent(event) && !event.GetVeto(); } bool wxWindowBase::DestroyChildren() @@ -601,11 +440,11 @@ bool wxWindowBase::DestroyChildren() wxWindow *child = node->GetData(); - // note that we really want to delete it immediately so don't call the - // possible overridden Destroy() version which might not delete the - // child immediately resulting in problems with our (top level) child - // outliving its parent - child->wxWindowBase::Destroy(); + // note that we really want to call delete and not ->Destroy() here + // because we want to delete the child immediately, before we are + // deleted, and delayed deletion would result in problems as our (top + // level) child could outlive its parent + delete child; wxASSERT_MSG( !GetChildren().Find(child), wxT("child didn't remove itself using RemoveChild()") ); @@ -622,7 +461,7 @@ bool wxWindowBase::DestroyChildren() void wxWindowBase::DoCentre(int dir) { wxCHECK_RET( !(dir & wxCENTRE_ON_SCREEN) && GetParent(), - wxT("this method only implements centering child windows") ); + _T("this method only implements centering child windows") ); SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir)); } @@ -630,17 +469,24 @@ void wxWindowBase::DoCentre(int dir) // fits the window around the children void wxWindowBase::Fit() { - SetSize(GetBestSize()); + if ( !GetChildren().empty() ) + { + SetSize(GetBestSize()); + } + //else: do nothing if we have no children } // fits virtual size (ie. scrolled area etc.) around children void wxWindowBase::FitInside() { - SetVirtualSize( GetBestVirtualSize() ); + if ( GetChildren().GetCount() > 0 ) + { + SetVirtualSize( GetBestVirtualSize() ); + } } // On Mac, scrollbars are explicitly children. -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) +#ifdef __WXMAC__ static bool wxHasRealChildren(const wxWindowBase* win) { int realChildCount = 0; @@ -650,11 +496,7 @@ static bool wxHasRealChildren(const wxWindowBase* win) node = node->GetNext() ) { wxWindow *win = node->GetData(); - if ( !win->IsTopLevel() && win->IsShown() -#if wxUSE_SCROLLBAR - && !wxDynamicCast(win, wxScrollBar) -#endif - ) + if ( !win->IsTopLevel() && win->IsShown() && !win->IsKindOf(CLASSINFO(wxScrollBar))) realChildCount ++; } return (realChildCount > 0); @@ -680,7 +522,18 @@ wxSize wxWindowBase::DoGetBestSize() const if ( m_windowSizer ) { - best = m_windowSizer->GetMinSize(); + // Adjust to window size, since the return value of GetWindowSizeForVirtualSize is + // expressed in window and not client size + wxSize minSize = m_windowSizer->GetMinSize(); + wxSize size(GetSize()); + wxSize clientSize(GetClientSize()); + + wxSize minWindowSize(minSize.x + size.x - clientSize.x, + minSize.y + size.y - clientSize.y); + + best = GetWindowSizeForVirtualSize(minWindowSize); + + return best; } #if wxUSE_CONSTRAINTS else if ( m_constraints ) @@ -720,7 +573,7 @@ wxSize wxWindowBase::DoGetBestSize() const } #endif // wxUSE_CONSTRAINTS else if ( !GetChildren().empty() -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) +#ifdef __WXMAC__ && wxHasRealChildren(this) #endif ) @@ -769,14 +622,19 @@ wxSize wxWindowBase::DoGetBestSize() const } else // ! has children { + // for a generic window there is no natural best size so, if the + // minimal size is not set, use the current size but take care to + // remember it as minimal size for the next time because our best size + // should be constant: otherwise we could get into a situation when the + // window is initially at some size, then expanded to a larger size and + // then, when the containing window is shrunk back (because our initial + // best size had been used for computing the parent min size), we can't + // be shrunk back any more because our best size is now bigger wxSize size = GetMinSize(); if ( !size.IsFullySpecified() ) { - // if the window doesn't define its best size we assume that it can - // be arbitrarily small -- usually this is not the case, of course, - // but we have no way to know what the limit is, it should really - // override DoGetBestClientSize() itself to tell us - size.SetDefaults(wxSize(1, 1)); + size.SetDefaults(GetSize()); + wxConstCast(this, wxWindowBase)->SetMinSize(size); } // return as-is, unadjusted by the client size difference. @@ -794,10 +652,9 @@ wxSize wxWindowBase::DoGetBestSize() const // helper of GetWindowBorderSize(): as many ports don't implement support for // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded // fallbacks in this case -static int wxGetMetricOrDefault(wxSystemMetric what, const wxWindowBase* win) +static int wxGetMetricOrDefault(wxSystemMetric what) { - int rc = wxSystemSettings::GetMetric( - what, static_cast(const_cast(win))); + int rc = wxSystemSettings::GetMetric(what); if ( rc == -1 ) { switch ( what ) @@ -815,7 +672,7 @@ static int wxGetMetricOrDefault(wxSystemMetric what, const wxWindowBase* win) break; default: - wxFAIL_MSG( wxT("unexpected wxGetMetricOrDefault() argument") ); + wxFAIL_MSG( _T("unexpected wxGetMetricOrDefault() argument") ); rc = 0; } } @@ -835,27 +692,27 @@ wxSize wxWindowBase::GetWindowBorderSize() const case wxBORDER_SIMPLE: case wxBORDER_STATIC: - size.x = wxGetMetricOrDefault(wxSYS_BORDER_X, this); - size.y = wxGetMetricOrDefault(wxSYS_BORDER_Y, this); + size.x = wxGetMetricOrDefault(wxSYS_BORDER_X); + size.y = wxGetMetricOrDefault(wxSYS_BORDER_Y); break; case wxBORDER_SUNKEN: case wxBORDER_RAISED: - size.x = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X, this), - wxGetMetricOrDefault(wxSYS_BORDER_X, this)); - size.y = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y, this), - wxGetMetricOrDefault(wxSYS_BORDER_Y, this)); + size.x = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X), + wxGetMetricOrDefault(wxSYS_BORDER_X)); + size.y = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y), + wxGetMetricOrDefault(wxSYS_BORDER_Y)); break; case wxBORDER_DOUBLE: - size.x = wxGetMetricOrDefault(wxSYS_EDGE_X, this) + - wxGetMetricOrDefault(wxSYS_BORDER_X, this); - size.y = wxGetMetricOrDefault(wxSYS_EDGE_Y, this) + - wxGetMetricOrDefault(wxSYS_BORDER_Y, this); + size.x = wxGetMetricOrDefault(wxSYS_EDGE_X) + + wxGetMetricOrDefault(wxSYS_BORDER_X); + size.y = wxGetMetricOrDefault(wxSYS_EDGE_Y) + + wxGetMetricOrDefault(wxSYS_BORDER_Y); break; default: - wxFAIL_MSG(wxT("Unknown border style.")); + wxFAIL_MSG(_T("Unknown border style.")); break; } @@ -863,100 +720,19 @@ wxSize wxWindowBase::GetWindowBorderSize() const return size*2; } -bool -wxWindowBase::InformFirstDirection(int direction, - int size, - int availableOtherDir) -{ - return GetSizer() && GetSizer()->InformFirstDirection(direction, - size, - availableOtherDir); -} - wxSize wxWindowBase::GetEffectiveMinSize() const { // merge the best size with the min size, giving priority to the min size wxSize min = GetMinSize(); - if (min.x == wxDefaultCoord || min.y == wxDefaultCoord) { wxSize best = GetBestSize(); if (min.x == wxDefaultCoord) min.x = best.x; if (min.y == wxDefaultCoord) min.y = best.y; } - return min; } -wxSize wxWindowBase::DoGetBorderSize() const -{ - // there is one case in which we can implement it for all ports easily - if ( GetBorder() == wxBORDER_NONE ) - return wxSize(0, 0); - - // otherwise use the difference between the real size and the client size - // as a fallback: notice that this is incorrect in general as client size - // also doesn't take the scrollbars into account - return GetSize() - GetClientSize(); -} - -wxSize wxWindowBase::GetBestSize() const -{ - if ( !m_windowSizer && m_bestSizeCache.IsFullySpecified() ) - return m_bestSizeCache; - - // call DoGetBestClientSize() first, if a derived class overrides it wants - // it to be used - wxSize size = DoGetBestClientSize(); - if ( size != wxDefaultSize ) - size += DoGetBorderSize(); - else - size = DoGetBestSize(); - - // Ensure that the best size is at least as large as min size. - size.IncTo(GetMinSize()); - - // And not larger than max size. - size.DecToIfSpecified(GetMaxSize()); - - // Finally cache result and return. - CacheBestSize(size); - return size; -} - -int wxWindowBase::GetBestHeight(int width) const -{ - const int height = DoGetBestClientHeight(width); - - return height == wxDefaultCoord - ? GetBestSize().y - : height + DoGetBorderSize().y; -} - -int wxWindowBase::GetBestWidth(int height) const -{ - const int width = DoGetBestClientWidth(height); - - return width == wxDefaultCoord - ? GetBestSize().x - : width + DoGetBorderSize().x; -} - -void wxWindowBase::SetMinSize(const wxSize& minSize) -{ - m_minWidth = minSize.x; - m_minHeight = minSize.y; - - InvalidateBestSize(); -} - -void wxWindowBase::SetMaxSize(const wxSize& maxSize) -{ - m_maxWidth = maxSize.x; - m_maxHeight = maxSize.y; - - InvalidateBestSize(); -} void wxWindowBase::SetInitialSize(const wxSize& size) { @@ -1017,19 +793,22 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant ) break; case wxWINDOW_VARIANT_SMALL: - size = wxRound(size * 3.0 / 4.0); + size *= 3; + size /= 4; break; case wxWINDOW_VARIANT_MINI: - size = wxRound(size * 2.0 / 3.0); + size *= 2; + size /= 3; break; case wxWINDOW_VARIANT_LARGE: - size = wxRound(size * 5.0 / 4.0); + size *= 5; + size /= 4; break; default: - wxFAIL_MSG(wxT("unexpected window variant")); + wxFAIL_MSG(_T("unexpected window variant")); break; } @@ -1043,7 +822,7 @@ void wxWindowBase::DoSetSizeHints( int minW, int minH, { wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) && (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH), - wxT("min width/height must be less than max width/height!") ); + _T("min width/height must be less than max width/height!") ); m_minWidth = minW; m_maxWidth = maxW; @@ -1052,20 +831,26 @@ void wxWindowBase::DoSetSizeHints( int minW, int minH, } -#if WXWIN_COMPATIBILITY_2_8 -void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), - int WXUNUSED(maxW), int WXUNUSED(maxH)) +void wxWindowBase::SetVirtualSizeHints( int minW, int minH, + int maxW, int maxH ) { + m_minVirtualWidth = minW; + m_maxVirtualWidth = maxW; + m_minVirtualHeight = minH; + m_maxVirtualHeight = maxH; } -void wxWindowBase::SetVirtualSizeHints(const wxSize& WXUNUSED(minsize), - const wxSize& WXUNUSED(maxsize)) -{ -} -#endif // WXWIN_COMPATIBILITY_2_8 - void wxWindowBase::DoSetVirtualSize( int x, int y ) { + if ( m_minVirtualWidth != wxDefaultCoord && m_minVirtualWidth > x ) + x = m_minVirtualWidth; + if ( m_maxVirtualWidth != wxDefaultCoord && m_maxVirtualWidth < x ) + x = m_maxVirtualWidth; + if ( m_minVirtualHeight != wxDefaultCoord && m_minVirtualHeight > y ) + y = m_minVirtualHeight; + if ( m_maxVirtualHeight != wxDefaultCoord && m_maxVirtualHeight < y ) + y = m_maxVirtualHeight; + m_virtualSize = wxSize(x, y); } @@ -1096,43 +881,6 @@ void wxWindowBase::DoGetScreenPosition(int *x, int *y) const ClientToScreen(x, y); } -void wxWindowBase::SendSizeEvent(int flags) -{ - wxSizeEvent event(GetSize(), GetId()); - event.SetEventObject(this); - if ( flags & wxSEND_EVENT_POST ) - wxPostEvent(GetEventHandler(), event); - else - HandleWindowEvent(event); -} - -void wxWindowBase::SendSizeEventToParent(int flags) -{ - wxWindow * const parent = GetParent(); - if ( parent && !parent->IsBeingDeleted() ) - parent->SendSizeEvent(flags); -} - -bool wxWindowBase::CanScroll(int orient) const -{ - return (m_windowStyle & - (orient == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL)) != 0; -} - -bool wxWindowBase::HasScrollbar(int orient) const -{ - // if scrolling in the given direction is disabled, we can't have the - // corresponding scrollbar no matter what - if ( !CanScroll(orient) ) - return false; - - const wxSize sizeVirt = GetVirtualSize(); - const wxSize sizeClient = GetClientSize(); - - return orient == wxHORIZONTAL ? sizeVirt.x > sizeClient.x - : sizeVirt.y > sizeClient.y; -} - // ---------------------------------------------------------------------------- // show/hide/enable/disable the window // ---------------------------------------------------------------------------- @@ -1151,63 +899,18 @@ bool wxWindowBase::Show(bool show) } } -bool wxWindowBase::IsEnabled() const -{ - return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled()); -} - -void wxWindowBase::NotifyWindowOnEnableChange(bool enabled) -{ - // Under some platforms there is no need to update the window state - // explicitly, it will become disabled when its parent is. On other ones we - // do need to disable all windows recursively though. -#ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT - DoEnable(enabled); -#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT) - - // Disabling a top level window is typically done when showing a modal - // dialog and we don't need to disable its children in this case, they will - // be logically disabled anyhow (i.e. their IsEnabled() will return false) - // and the TLW won't accept any input for them. Moreover, explicitly - // disabling them would look ugly as the entire TLW would be greyed out - // whenever a modal dialog is shown and no native applications under any - // platform behave like this. - if ( IsTopLevel() && !enabled ) - return; - - // When disabling (or enabling back) a non-TLW window we need to - // recursively propagate the change of the state to its children, otherwise - // they would still show as enabled even though they wouldn't actually - // accept any input (at least under MSW where children don't accept input - // if any of the windows in their parent chain is enabled). -#ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT - for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindowBase * const child = node->GetData(); - if ( !child->IsTopLevel() && child->IsThisEnabled() ) - child->NotifyWindowOnEnableChange(enabled); - } -#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT) -} - bool wxWindowBase::Enable(bool enable) { - if ( enable == IsThisEnabled() ) + if ( enable != m_isEnabled ) + { + m_isEnabled = enable; + + return true; + } + else + { return false; - - m_isEnabled = enable; - - // If we call DoEnable() from NotifyWindowOnEnableChange(), we don't need - // to do it from here. -#ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT - DoEnable(enable); -#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT) - - NotifyWindowOnEnableChange(enable); - - return true; + } } bool wxWindowBase::IsShownOnScreen() const @@ -1216,7 +919,7 @@ bool wxWindowBase::IsShownOnScreen() const // parents. But if a window is toplevel one, then its always visible on // screen if IsShown() returns true, even if it has a hidden parent. return IsShown() && - (IsTopLevel() || GetParent() == NULL || GetParent()->IsShownOnScreen()); + (IsTopLevel() || !GetParent() || GetParent()->IsShownOnScreen()); } // ---------------------------------------------------------------------------- @@ -1229,73 +932,9 @@ bool wxWindowBase::IsTopLevel() const } // ---------------------------------------------------------------------------- -// Freeze/Thaw +// reparenting the window // ---------------------------------------------------------------------------- -void wxWindowBase::Freeze() -{ - if ( !m_freezeCount++ ) - { - // physically freeze this window: - DoFreeze(); - - // and recursively freeze all children: - for ( wxWindowList::iterator i = GetChildren().begin(); - i != GetChildren().end(); ++i ) - { - wxWindow *child = *i; - if ( child->IsTopLevel() ) - continue; - - child->Freeze(); - } - } -} - -void wxWindowBase::Thaw() -{ - wxASSERT_MSG( m_freezeCount, "Thaw() without matching Freeze()" ); - - if ( !--m_freezeCount ) - { - // recursively thaw all children: - for ( wxWindowList::iterator i = GetChildren().begin(); - i != GetChildren().end(); ++i ) - { - wxWindow *child = *i; - if ( child->IsTopLevel() ) - continue; - - child->Thaw(); - } - - // physically thaw this window: - DoThaw(); - } -} - -// ---------------------------------------------------------------------------- -// Dealing with parents and children. -// ---------------------------------------------------------------------------- - -bool wxWindowBase::IsDescendant(wxWindowBase* win) const -{ - // Iterate until we find this window in the parent chain or exhaust it. - while ( win ) - { - if ( win == this ) - return true; - - // Stop iterating on reaching the top level window boundary. - if ( win->IsTopLevel() ) - break; - - win = win->GetParent(); - } - - return false; -} - void wxWindowBase::AddChild(wxWindowBase *child) { wxCHECK_RET( child, wxT("can't add a NULL child") ); @@ -1303,47 +942,20 @@ void wxWindowBase::AddChild(wxWindowBase *child) // this should never happen and it will lead to a crash later if it does // because RemoveChild() will remove only one node from the children list // and the other(s) one(s) will be left with dangling pointers in them - wxASSERT_MSG( !GetChildren().Find((wxWindow*)child), wxT("AddChild() called twice") ); + wxASSERT_MSG( !GetChildren().Find((wxWindow*)child), _T("AddChild() called twice") ); GetChildren().Append((wxWindow*)child); child->SetParent(this); - - // adding a child while frozen will assert when thawed, so freeze it as if - // it had been already present when we were frozen - if ( IsFrozen() && !child->IsTopLevel() ) - child->Freeze(); } void wxWindowBase::RemoveChild(wxWindowBase *child) { wxCHECK_RET( child, wxT("can't remove a NULL child") ); - // removing a child while frozen may result in permanently frozen window - // if used e.g. from Reparent(), so thaw it - // - // NB: IsTopLevel() doesn't return true any more when a TLW child is being - // removed from its ~wxWindowBase, so check for IsBeingDeleted() too - if ( IsFrozen() && !child->IsBeingDeleted() && !child->IsTopLevel() ) - child->Thaw(); - GetChildren().DeleteObject((wxWindow *)child); child->SetParent(NULL); } -void wxWindowBase::SetParent(wxWindowBase *parent) -{ - // This assert catches typos which may result in using "this" instead of - // "parent" when creating the window. This doesn't happen often but when it - // does the results are unpleasant because the program typically just - // crashes when due to a stack overflow or something similar and this - // assert doesn't cost much (OTOH doing a more general check that the - // parent is not one of our children would be more expensive and probably - // not worth it). - wxASSERT_MSG( parent != this, wxS("Can't use window as its own parent") ); - - m_parent = (wxWindow *)parent; -} - bool wxWindowBase::Reparent(wxWindowBase *newParent) { wxWindow *oldParent = GetParent(); @@ -1353,8 +965,6 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) return false; } - const bool oldEnabledState = IsEnabled(); - // unlink this window from the existing parent. if ( oldParent ) { @@ -1375,14 +985,6 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) wxTopLevelWindows.Append((wxWindow *)this); } - // We need to notify window (and its subwindows) if by changing the parent - // we also change our enabled/disabled status. - const bool newEnabledState = IsEnabled(); - if ( newEnabledState != oldEnabledState ) - { - NotifyWindowOnEnableChange(newEnabledState); - } - return true; } @@ -1390,141 +992,81 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) // event handler stuff // ---------------------------------------------------------------------------- -void wxWindowBase::SetEventHandler(wxEvtHandler *handler) +void wxWindowBase::PushEventHandler(wxEvtHandler *handler) { - wxCHECK_RET(handler != NULL, "SetEventHandler(NULL) called"); - - m_eventHandler = handler; -} - -void wxWindowBase::SetNextHandler(wxEvtHandler *WXUNUSED(handler)) -{ - // disable wxEvtHandler chain mechanism for wxWindows: - // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one - - wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain"); -} -void wxWindowBase::SetPreviousHandler(wxEvtHandler *WXUNUSED(handler)) -{ - // we can't simply wxFAIL here as in SetNextHandler: in fact the last - // handler of our stack when is destroyed will be Unlink()ed and thus - // will call this function to update the pointer of this window... - - //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain"); -} - -void wxWindowBase::PushEventHandler(wxEvtHandler *handlerToPush) -{ - wxCHECK_RET( handlerToPush != NULL, "PushEventHandler(NULL) called" ); - - // the new handler is going to be part of the wxWindow stack of event handlers: - // it can't be part also of an event handler double-linked chain: - wxASSERT_MSG(handlerToPush->IsUnlinked(), - "The handler being pushed in the wxWindow stack shouldn't be part of " - "a wxEvtHandler chain; call Unlink() on it first"); - wxEvtHandler *handlerOld = GetEventHandler(); - wxCHECK_RET( handlerOld, "an old event handler is NULL?" ); - // now use wxEvtHandler double-linked list to implement a stack: - handlerToPush->SetNextHandler(handlerOld); + handler->SetNextHandler(handlerOld); - if (handlerOld != this) - handlerOld->SetPreviousHandler(handlerToPush); + if ( handlerOld ) + GetEventHandler()->SetPreviousHandler(handler); - SetEventHandler(handlerToPush); - -#if wxDEBUG_LEVEL - // final checks of the operations done above: - wxASSERT_MSG( handlerToPush->GetPreviousHandler() == NULL, - "the first handler of the wxWindow stack should " - "have no previous handlers set" ); - wxASSERT_MSG( handlerToPush->GetNextHandler() != NULL, - "the first handler of the wxWindow stack should " - "have non-NULL next handler" ); - - wxEvtHandler* pLast = handlerToPush; - while ( pLast && pLast != this ) - pLast = pLast->GetNextHandler(); - wxASSERT_MSG( pLast->GetNextHandler() == NULL, - "the last handler of the wxWindow stack should " - "have this window as next handler" ); -#endif // wxDEBUG_LEVEL + SetEventHandler(handler); } wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) { - // we need to pop the wxWindow stack, i.e. we need to remove the first handler - - wxEvtHandler *firstHandler = GetEventHandler(); - wxCHECK_MSG( firstHandler != NULL, NULL, "wxWindow cannot have a NULL event handler" ); - wxCHECK_MSG( firstHandler != this, NULL, "cannot pop the wxWindow itself" ); - wxCHECK_MSG( firstHandler->GetPreviousHandler() == NULL, NULL, - "the first handler of the wxWindow stack should have no previous handlers set" ); - - wxEvtHandler *secondHandler = firstHandler->GetNextHandler(); - wxCHECK_MSG( secondHandler != NULL, NULL, - "the first handler of the wxWindow stack should have non-NULL next handler" ); - - firstHandler->SetNextHandler(NULL); - - // It is harmless but useless to unset the previous handler of the window - // itself as it's always NULL anyhow, so don't do this. - if ( secondHandler != this ) - secondHandler->SetPreviousHandler(NULL); - - // now firstHandler is completely unlinked; set secondHandler as the new window event handler - SetEventHandler(secondHandler); - - if ( deleteHandler ) + wxEvtHandler *handlerA = GetEventHandler(); + if ( handlerA ) { - wxDELETE(firstHandler); + wxEvtHandler *handlerB = handlerA->GetNextHandler(); + handlerA->SetNextHandler((wxEvtHandler *)NULL); + + if ( handlerB ) + handlerB->SetPreviousHandler((wxEvtHandler *)NULL); + SetEventHandler(handlerB); + + if ( deleteHandler ) + { + delete handlerA; + handlerA = (wxEvtHandler *)NULL; + } } - return firstHandler; + return handlerA; } -bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handlerToRemove) +bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) { - wxCHECK_MSG( handlerToRemove != NULL, false, "RemoveEventHandler(NULL) called" ); - wxCHECK_MSG( handlerToRemove != this, false, "Cannot remove the window itself" ); + wxCHECK_MSG( handler, false, _T("RemoveEventHandler(NULL) called") ); - if (handlerToRemove == GetEventHandler()) - { - // removing the first event handler is equivalent to "popping" the stack - PopEventHandler(false); - return true; - } - - // NOTE: the wxWindow event handler list is always terminated with "this" handler - wxEvtHandler *handlerCur = GetEventHandler()->GetNextHandler(); - while ( handlerCur != this && handlerCur ) + wxEvtHandler *handlerPrev = NULL, + *handlerCur = GetEventHandler(); + while ( handlerCur ) { wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); - if ( handlerCur == handlerToRemove ) + if ( handlerCur == handler ) { - handlerCur->Unlink(); + if ( handlerPrev ) + { + handlerPrev->SetNextHandler(handlerNext); + } + else + { + SetEventHandler(handlerNext); + } + + if ( handlerNext ) + { + handlerNext->SetPreviousHandler ( handlerPrev ); + } + + handler->SetNextHandler(NULL); + handler->SetPreviousHandler(NULL); - wxASSERT_MSG( handlerCur != GetEventHandler(), - "the case Remove == Pop should was already handled" ); return true; } + handlerPrev = handlerCur; handlerCur = handlerNext; } - wxFAIL_MSG( wxT("where has the event handler gone?") ); + wxFAIL_MSG( _T("where has the event handler gone?") ); return false; } -bool wxWindowBase::HandleWindowEvent(wxEvent& event) const -{ - // SafelyProcessEvent() will handle exceptions nicely - return GetEventHandler()->SafelyProcessEvent(event); -} - // ---------------------------------------------------------------------------- // colours, fonts &c // ---------------------------------------------------------------------------- @@ -1585,19 +1127,19 @@ wxWindowBase::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) wxColour wxWindowBase::GetBackgroundColour() const { - if ( !m_backgroundColour.IsOk() ) + if ( !m_backgroundColour.Ok() ) { - wxASSERT_MSG( !m_hasBgCol, wxT("we have invalid explicit bg colour?") ); + wxASSERT_MSG( !m_hasBgCol, _T("we have invalid explicit bg colour?") ); // get our default background colour wxColour colBg = GetDefaultAttributes().colBg; // we must return some valid colour to avoid redoing this every time - // and also to avoid surprising the applications written for older + // and also to avoid surprizing the applications written for older // wxWidgets versions where GetBackgroundColour() always returned // something -- so give them something even if it doesn't make sense // for this window (e.g. it has a themed background) - if ( !colBg.IsOk() ) + if ( !colBg.Ok() ) colBg = GetClassDefaultAttributes().colBg; return colBg; @@ -1609,11 +1151,13 @@ wxColour wxWindowBase::GetBackgroundColour() const wxColour wxWindowBase::GetForegroundColour() const { // logic is the same as above - if ( !m_hasFgCol && !m_foregroundColour.IsOk() ) + if ( !m_hasFgCol && !m_foregroundColour.Ok() ) { + wxASSERT_MSG( !m_hasFgCol, _T("we have invalid explicit fg colour?") ); + wxColour colFg = GetDefaultAttributes().colFg; - if ( !colFg.IsOk() ) + if ( !colFg.Ok() ) colFg = GetClassDefaultAttributes().colFg; return colFg; @@ -1622,49 +1166,18 @@ wxColour wxWindowBase::GetForegroundColour() const return m_foregroundColour; } -bool wxWindowBase::SetBackgroundStyle(wxBackgroundStyle style) -{ - // The checks below shouldn't be triggered if we're not really changing the - // style. - if ( style == m_backgroundStyle ) - return true; - - // Transparent background style can be only set before creation because of - // wxGTK limitation. - wxCHECK_MSG( (style != wxBG_STYLE_TRANSPARENT) || !GetHandle(), - false, - "wxBG_STYLE_TRANSPARENT style can only be set before " - "Create()-ing the window." ); - - // And once it is set, wxBG_STYLE_TRANSPARENT can't be unset. - wxCHECK_MSG( (m_backgroundStyle != wxBG_STYLE_TRANSPARENT) || - (style == wxBG_STYLE_TRANSPARENT), - false, - "wxBG_STYLE_TRANSPARENT can't be unset once it was set." ); - - m_backgroundStyle = style; - - return true; -} - -bool wxWindowBase::IsTransparentBackgroundSupported(wxString *reason) const -{ - if ( reason ) - *reason = _("This platform does not support background transparency."); - - return false; -} - bool wxWindowBase::SetBackgroundColour( const wxColour &colour ) { if ( colour == m_backgroundColour ) return false; - m_hasBgCol = colour.IsOk(); + m_hasBgCol = colour.Ok(); + if ( m_backgroundStyle != wxBG_STYLE_CUSTOM ) + m_backgroundStyle = m_hasBgCol ? wxBG_STYLE_COLOUR : wxBG_STYLE_SYSTEM; m_inheritBgCol = m_hasBgCol; m_backgroundColour = colour; - SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.IsOk() ); + SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() ); return true; } @@ -1673,10 +1186,10 @@ bool wxWindowBase::SetForegroundColour( const wxColour &colour ) if (colour == m_foregroundColour ) return false; - m_hasFgCol = colour.IsOk(); + m_hasFgCol = colour.Ok(); m_inheritFgCol = m_hasFgCol; m_foregroundColour = colour; - SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.IsOk() ); + SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() ); return true; } @@ -1698,12 +1211,12 @@ bool wxWindowBase::SetCursor(const wxCursor& cursor) wxFont wxWindowBase::GetFont() const { // logic is the same as in GetBackgroundColour() - if ( !m_font.IsOk() ) + if ( !m_font.Ok() ) { - wxASSERT_MSG( !m_hasFont, wxT("we have invalid explicit font?") ); + wxASSERT_MSG( !m_hasFont, _T("we have invalid explicit font?") ); wxFont font = GetDefaultAttributes().font; - if ( !font.IsOk() ) + if ( !font.Ok() ) font = GetClassDefaultAttributes().font; return font; @@ -1721,7 +1234,7 @@ bool wxWindowBase::SetFont(const wxFont& font) } m_font = font; - m_hasFont = font.IsOk(); + m_hasFont = font.Ok(); m_inheritFont = m_hasFont; InvalidateBestSize(); @@ -1820,7 +1333,7 @@ void wxWindowBase::ClearBackground() // wxGTK uses its own version, no need to add never used code #ifndef __WXGTK__ wxClientDC dc((wxWindow *)this); - wxBrush brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID); + wxBrush brush(GetBackgroundColour(), wxSOLID); dc.SetBackground(brush); dc.Clear(); #endif // __WXGTK__ @@ -1835,17 +1348,11 @@ wxWindow *wxWindowBase::FindWindow(long id) const if ( id == m_windowId ) return (wxWindow *)this; - wxWindowBase *res = NULL; + wxWindowBase *res = (wxWindow *)NULL; wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindowBase *child = node->GetData(); - - // As usual, don't recurse into child dialogs, finding a button in a - // child dialog when looking in this window would be unexpected. - if ( child->IsTopLevel() ) - continue; - res = child->FindWindow( id ); } @@ -1857,16 +1364,11 @@ wxWindow *wxWindowBase::FindWindow(const wxString& name) const if ( name == m_windowName ) return (wxWindow *)this; - wxWindowBase *res = NULL; + wxWindowBase *res = (wxWindow *)NULL; wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindow *child = node->GetData(); - - // As in FindWindow() overload above, never recurse into child dialogs. - if ( child->IsTopLevel() ) - continue; - res = child->FindWindow(name); } @@ -1996,7 +1498,6 @@ wxWindowBase::FindWindowById( long id, const wxWindow* parent ) // dialog oriented functions // ---------------------------------------------------------------------------- -#if WXWIN_COMPATIBILITY_2_8 void wxWindowBase::MakeModal(bool modal) { // Disable all other windows @@ -2013,170 +1514,96 @@ void wxWindowBase::MakeModal(bool modal) } } } -#endif // WXWIN_COMPATIBILITY_2_8 - -#if wxUSE_VALIDATORS - -namespace -{ - -// This class encapsulates possibly recursive iteration on window children done -// by Validate() and TransferData{To,From}Window() and allows to avoid code -// duplication in all three functions. -class ValidationTraverserBase -{ -public: - wxEXPLICIT ValidationTraverserBase(wxWindowBase* win) - : m_win(static_cast(win)) - { - } - - // Traverse all the direct children calling OnDo() on them and also all - // grandchildren if wxWS_EX_VALIDATE_RECURSIVELY is used, calling - // OnRecurse() for them. - bool DoForAllChildren() - { - const bool recurse = m_win->HasExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); - - wxWindowList& children = m_win->GetChildren(); - for ( wxWindowList::iterator i = children.begin(); - i != children.end(); - ++i ) - { - wxWindow* const child = static_cast(*i); - wxValidator* const validator = child->GetValidator(); - if ( validator && !OnDo(validator) ) - { - return false; - } - - // Notice that validation should never recurse into top level - // children, e.g. some other dialog which might happen to be - // currently shown. - if ( recurse && !child->IsTopLevel() && !OnRecurse(child) ) - { - return false; - } - } - - return true; - } - - // Give it a virtual dtor just to suppress gcc warnings about a class with - // virtual methods but non-virtual dtor -- even if this is completely safe - // here as we never use the objects of this class polymorphically. - virtual ~ValidationTraverserBase() { } - -protected: - // Called for each child, validator is guaranteed to be non-NULL. - virtual bool OnDo(wxValidator* validator) = 0; - - // Called for each child if we need to recurse into its children. - virtual bool OnRecurse(wxWindow* child) = 0; - - - // The window whose children we're traversing. - wxWindow* const m_win; - - wxDECLARE_NO_COPY_CLASS(ValidationTraverserBase); -}; - -} // anonymous namespace - -#endif // wxUSE_VALIDATORS bool wxWindowBase::Validate() { #if wxUSE_VALIDATORS - class ValidateTraverser : public ValidationTraverserBase + bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; + + wxWindowList::compatibility_iterator node; + for ( node = m_children.GetFirst(); node; node = node->GetNext() ) { - public: - wxEXPLICIT ValidateTraverser(wxWindowBase* win) - : ValidationTraverserBase(win) + wxWindowBase *child = node->GetData(); + wxValidator *validator = child->GetValidator(); + if ( validator && !validator->Validate((wxWindow *)this) ) { + return false; } - virtual bool OnDo(wxValidator* validator) + if ( recurse && !child->Validate() ) { - return validator->Validate(m_win); + return false; } + } +#endif // wxUSE_VALIDATORS - virtual bool OnRecurse(wxWindow* child) - { - return child->Validate(); - } - }; - - return ValidateTraverser(this).DoForAllChildren(); -#else // !wxUSE_VALIDATORS return true; -#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS } bool wxWindowBase::TransferDataToWindow() { #if wxUSE_VALIDATORS - class DataToWindowTraverser : public ValidationTraverserBase - { - public: - wxEXPLICIT DataToWindowTraverser(wxWindowBase* win) - : ValidationTraverserBase(win) - { - } + bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; - virtual bool OnDo(wxValidator* validator) + wxWindowList::compatibility_iterator node; + for ( node = m_children.GetFirst(); node; node = node->GetNext() ) + { + wxWindowBase *child = node->GetData(); + wxValidator *validator = child->GetValidator(); + if ( validator && !validator->TransferToWindow() ) { - if ( !validator->TransferToWindow() ) - { - wxLogWarning(_("Could not transfer data to window")); + wxLogWarning(_("Could not transfer data to window")); #if wxUSE_LOG - wxLog::FlushActive(); + wxLog::FlushActive(); #endif // wxUSE_LOG + return false; + } + + if ( recurse ) + { + if ( !child->TransferDataToWindow() ) + { + // warning already given return false; } - - return true; } + } +#endif // wxUSE_VALIDATORS - virtual bool OnRecurse(wxWindow* child) - { - return child->TransferDataToWindow(); - } - }; - - return DataToWindowTraverser(this).DoForAllChildren(); -#else // !wxUSE_VALIDATORS return true; -#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS } bool wxWindowBase::TransferDataFromWindow() { #if wxUSE_VALIDATORS - class DataFromWindowTraverser : public ValidationTraverserBase + bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; + + wxWindowList::compatibility_iterator node; + for ( node = m_children.GetFirst(); node; node = node->GetNext() ) { - public: - DataFromWindowTraverser(wxWindowBase* win) - : ValidationTraverserBase(win) + wxWindow *child = node->GetData(); + wxValidator *validator = child->GetValidator(); + if ( validator && !validator->TransferFromWindow() ) { + // nop warning here because the application is supposed to give + // one itself - we don't know here what might have gone wrongly + + return false; } - virtual bool OnDo(wxValidator* validator) + if ( recurse ) { - return validator->TransferFromWindow(); + if ( !child->TransferDataFromWindow() ) + { + // warning already given + return false; + } } + } +#endif // wxUSE_VALIDATORS - virtual bool OnRecurse(wxWindow* child) - { - return child->TransferDataFromWindow(); - } - }; - - return DataFromWindowTraverser(this).DoForAllChildren(); -#else // !wxUSE_VALIDATORS return true; -#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS } void wxWindowBase::InitDialog() @@ -2202,7 +1629,6 @@ void wxWindowBase::SetHelpText(const wxString& text) } } -#if WXWIN_COMPATIBILITY_2_8 // associate this help text with all windows with the same id as this // one void wxWindowBase::SetHelpTextForId(const wxString& text) @@ -2213,7 +1639,6 @@ void wxWindowBase::SetHelpTextForId(const wxString& text) helpProvider->AddHelp(GetId(), text); } } -#endif // WXWIN_COMPATIBILITY_2_8 // get the help string associated with this window (may be empty) // default implementation forwards calls to the help provider @@ -2277,11 +1702,6 @@ void wxWindowBase::OnHelp(wxHelpEvent& event) #if wxUSE_TOOLTIPS -wxString wxWindowBase::GetToolTipText() const -{ - return m_tooltip ? m_tooltip->GetTip() : wxString(); -} - void wxWindowBase::SetToolTip( const wxString &tip ) { // don't create the new tooltip if we already have one @@ -2295,7 +1715,7 @@ void wxWindowBase::SetToolTip( const wxString &tip ) } // setting empty tooltip text does not remove the tooltip any more - use - // SetToolTip(NULL) for this + // SetToolTip((wxToolTip *)NULL) for this } void wxWindowBase::DoSetToolTip(wxToolTip *tooltip) @@ -2309,13 +1729,6 @@ void wxWindowBase::DoSetToolTip(wxToolTip *tooltip) } } -bool wxWindowBase::CopyToolTip(wxToolTip *tip) -{ - SetToolTip(tip ? new wxToolTip(tip->GetTip()) : NULL); - - return tip != NULL; -} - #endif // wxUSE_TOOLTIPS // ---------------------------------------------------------------------------- @@ -2360,7 +1773,7 @@ void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c) { if ( c ) { - if ( c->left.GetOtherWindow() && (c->left.GetOtherWindow() != this) ) + if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) c->left.GetOtherWindow()->RemoveConstraintReference(this); if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) c->top.GetOtherWindow()->RemoveConstraintReference(this); @@ -2425,7 +1838,8 @@ void wxWindowBase::DeleteRelatedConstraints() node = next; } - wxDELETE(m_constraintsInvolvedIn); + delete m_constraintsInvolvedIn; + m_constraintsInvolvedIn = (wxWindowList *) NULL; } } @@ -2467,7 +1881,7 @@ void wxWindowBase::SetContainingSizer(wxSizer* sizer) // associated wxSizerItem we're going to dereference a dangling // pointer; so try to detect this as early as possible wxASSERT_MSG( !sizer || m_containingSizer != sizer, - wxT("Adding a window to the same sizer twice?") ); + _T("Adding a window to the same sizer twice?") ); m_containingSizer = sizer; } @@ -2519,14 +1933,6 @@ bool wxWindowBase::Layout() return true; } -void wxWindowBase::InternalOnSize(wxSizeEvent& event) -{ - if ( GetAutoLayout() ) - Layout(); - - event.Skip(); -} - #if wxUSE_CONSTRAINTS // first phase of the constraints evaluation: set our own constraints @@ -2637,8 +2043,6 @@ void wxWindowBase::SetConstraintSizes(bool recurse) wxLayoutConstraints *constr = GetConstraints(); if ( constr && constr->AreSatisfied() ) { - ChildrenRepositioningGuard repositionGuard(this); - int x = constr->left.GetValue(); int y = constr->top.GetValue(); int w = constr->width.GetValue(); @@ -2647,9 +2051,7 @@ void wxWindowBase::SetConstraintSizes(bool recurse) if ( (constr->width.GetRelationship() != wxAsIs ) || (constr->height.GetRelationship() != wxAsIs) ) { - // We really shouldn't set negative sizes for the windows so make - // them at least of 1*1 size - SetSize(x, y, w > 0 ? w : 1, h > 0 ? h : 1); + SetSize(x, y, w, h); } else { @@ -2764,12 +2166,17 @@ void wxWindowBase::GetPositionConstraint(int *x, int *y) const void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) const { - wxWindow *parent = GetParent(); - if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent ) + // don't do it for the dialogs/frames - they float independently of their + // parent + if ( !IsTopLevel() ) { - wxPoint pt(parent->GetClientAreaOrigin()); - x += pt.x; - y += pt.y; + wxWindow *parent = GetParent(); + if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent ) + { + wxPoint pt(parent->GetClientAreaOrigin()); + x += pt.x; + y += pt.y; + } } } @@ -2809,101 +2216,32 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) Show(event.GetShown()); } -// ---------------------------------------------------------------------------- -// Idle processing -// ---------------------------------------------------------------------------- - -// Send idle event to window and all subwindows -bool wxWindowBase::SendIdleEvents(wxIdleEvent& event) -{ - bool needMore = false; - - OnInternalIdle(); - - // should we send idle event to this window? - if (wxIdleEvent::GetMode() == wxIDLE_PROCESS_ALL || - HasExtraStyle(wxWS_EX_PROCESS_IDLE)) - { - event.SetEventObject(this); - HandleWindowEvent(event); - - if (event.MoreRequested()) - needMore = true; - } - wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); - for (; node; node = node->GetNext()) - { - wxWindow* child = node->GetData(); - if (child->SendIdleEvents(event)) - needMore = true; - } - - return needMore; -} - -void wxWindowBase::OnInternalIdle() -{ - if ( wxUpdateUIEvent::CanUpdate(this) ) - UpdateWindowUI(wxUPDATE_UI_FROMIDLE); -} - // ---------------------------------------------------------------------------- // dialog units translations // ---------------------------------------------------------------------------- -// Windows' computes dialog units using average character width over upper- -// and lower-case ASCII alphabet and not using the average character width -// metadata stored in the font; see -// http://support.microsoft.com/default.aspx/kb/145994 for detailed discussion. -// It's important that we perform the conversion in identical way, because -// dialog units natively exist only on Windows and Windows HIG is expressed -// using them. -wxSize wxWindowBase::GetDlgUnitBase() const +wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt) { - const wxWindowBase * const parent = wxGetTopLevelParent((wxWindow*)this); - - wxCHECK_MSG( parent, wxDefaultSize, wxS("Must have TLW parent") ); - - if ( !parent->m_font.IsOk() ) - { - // Default GUI font is used. This is the most common case, so - // cache the results. - static wxSize s_defFontSize; - if ( s_defFontSize.x == 0 ) - s_defFontSize = wxPrivate::GetAverageASCIILetterSize(*parent); - return s_defFontSize; - } - else - { - // Custom font, we always need to compute the result - return wxPrivate::GetAverageASCIILetterSize(*parent); - } -} - -wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt) const -{ - const wxSize base = GetDlgUnitBase(); - - // NB: wxMulDivInt32() is used, because it correctly rounds the result - + int charWidth = GetCharWidth(); + int charHeight = GetCharHeight(); wxPoint pt2 = wxDefaultPosition; if (pt.x != wxDefaultCoord) - pt2.x = wxMulDivInt32(pt.x, 4, base.x); + pt2.x = (int) ((pt.x * 4) / charWidth); if (pt.y != wxDefaultCoord) - pt2.y = wxMulDivInt32(pt.y, 8, base.y); + pt2.y = (int) ((pt.y * 8) / charHeight); return pt2; } -wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) const +wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) { - const wxSize base = GetDlgUnitBase(); - + int charWidth = GetCharWidth(); + int charHeight = GetCharHeight(); wxPoint pt2 = wxDefaultPosition; if (pt.x != wxDefaultCoord) - pt2.x = wxMulDivInt32(pt.x, base.x, 4); + pt2.x = (int) ((pt.x * charWidth) / 4); if (pt.y != wxDefaultCoord) - pt2.y = wxMulDivInt32(pt.y, base.y, 8); + pt2.y = (int) ((pt.y * charHeight) / 8); return pt2; } @@ -2913,7 +2251,7 @@ wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) const // ---------------------------------------------------------------------------- // propagate the colour change event to the subwindows -void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) +void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event) { wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) @@ -2923,7 +2261,7 @@ void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) if ( !win->IsTopLevel() ) { wxSysColourChangedEvent event2; - event2.SetEventObject(win); + event.SetEventObject(win); win->GetEventHandler()->ProcessEvent(event2); } @@ -2944,96 +2282,16 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) ) UpdateWindowUI(wxUPDATE_UI_RECURSE); } -// ---------------------------------------------------------------------------- -// menu-related functions -// ---------------------------------------------------------------------------- - -#if wxUSE_MENUS - -bool wxWindowBase::PopupMenu(wxMenu *menu, int x, int y) -{ - wxCHECK_MSG( menu, false, "can't popup NULL menu" ); - - wxMenuInvokingWindowSetter - setInvokingWin(*menu, static_cast(this)); - - wxCurrentPopupMenu = menu; - const bool rc = DoPopupMenu(menu, x, y); - wxCurrentPopupMenu = NULL; - - return rc; -} - -// this is used to pass the id of the selected item from the menu event handler -// to the main function itself -// -// it's ok to use a global here as there can be at most one popup menu shown at -// any time -static int gs_popupMenuSelection = wxID_NONE; - -void wxWindowBase::InternalOnPopupMenu(wxCommandEvent& event) -{ - // store the id in a global variable where we'll retrieve it from later - gs_popupMenuSelection = event.GetId(); -} - -void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent& WXUNUSED(event)) -{ - // nothing to do but do not skip it -} - -int -wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y) -{ - gs_popupMenuSelection = wxID_NONE; - - Connect(wxEVT_MENU, - wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu), - NULL, - this); - - // it is common to construct the menu passed to this function dynamically - // using some fixed range of ids which could clash with the ids used - // elsewhere in the program, which could result in some menu items being - // unintentionally disabled or otherwise modified by update UI handlers - // elsewhere in the program code and this is difficult to avoid in the - // program itself, so instead we just temporarily suspend UI updating while - // this menu is shown - Connect(wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate), - NULL, - this); - - PopupMenu(&menu, x, y); - - Disconnect(wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate), - NULL, - this); - Disconnect(wxEVT_MENU, - wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu), - NULL, - this); - - return gs_popupMenuSelection; -} - -#endif // wxUSE_MENUS - -// methods for drawing the sizers in a visible way: this is currently only -// enabled for "full debug" builds with wxDEBUG_LEVEL==2 as it doesn't work -// that well and also because we don't want to leave it enabled in default -// builds used for production -#if wxDEBUG_LEVEL > 1 +// methods for drawing the sizers in a visible way +#ifdef __WXDEBUG__ static void DrawSizers(wxWindowBase *win); -static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill, const wxPen* pen) +static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill = false) { wxClientDC dc((wxWindow *)win); - dc.SetPen(*pen); - dc.SetBrush(fill ? wxBrush(pen->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH) : - *wxTRANSPARENT_BRUSH); + dc.SetPen(*wxRED_PEN); + dc.SetBrush(fill ? wxBrush(*wxRED, wxCROSSDIAG_HATCH): *wxTRANSPARENT_BRUSH); dc.DrawRectangle(rect.Deflate(1, 1)); } @@ -3048,29 +2306,26 @@ static void DrawSizer(wxWindowBase *win, wxSizer *sizer) wxSizerItem *item = *i; if ( item->IsSizer() ) { - DrawBorder(win, item->GetRect().Deflate(2), false, wxRED_PEN); + DrawBorder(win, item->GetRect().Deflate(2)); DrawSizer(win, item->GetSizer()); } else if ( item->IsSpacer() ) { - DrawBorder(win, item->GetRect().Deflate(2), true, wxBLUE_PEN); + DrawBorder(win, item->GetRect().Deflate(2), true); } else if ( item->IsWindow() ) { DrawSizers(item->GetWindow()); } - else - wxFAIL_MSG("inconsistent wxSizerItem status!"); } } static void DrawSizers(wxWindowBase *win) { - DrawBorder(win, win->GetClientSize(), false, wxGREEN_PEN); - wxSizer *sizer = win->GetSizer(); if ( sizer ) { + DrawBorder(win, win->GetClientSize()); DrawSizer(win, sizer); } else // no sizer, still recurse into the children @@ -3083,52 +2338,63 @@ static void DrawSizers(wxWindowBase *win) { DrawSizers(*i); } - - // show all kind of sizes of this window; see the "window sizing" topic - // overview for more info about the various differences: - wxSize fullSz = win->GetSize(); - wxSize clientSz = win->GetClientSize(); - wxSize bestSz = win->GetBestSize(); - wxSize minSz = win->GetMinSize(); - wxSize maxSz = win->GetMaxSize(); - wxSize virtualSz = win->GetVirtualSize(); - - wxMessageOutputDebug dbgout; - dbgout.Printf( - "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n", - win->GetName(), - fullSz.x, fullSz.y, - clientSz.x, clientSz.y, - bestSz.x, bestSz.y, - minSz.x, minSz.y, - maxSz.x, maxSz.y, - virtualSz.x, virtualSz.y); } } -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ // process special middle clicks void wxWindowBase::OnMiddleClick( wxMouseEvent& event ) { if ( event.ControlDown() && event.AltDown() ) { -#if wxDEBUG_LEVEL > 1 +#ifdef __WXDEBUG__ // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds if ( event.ShiftDown() ) { DrawSizers(this); + return; } - else #endif // __WXDEBUG__ - { + #if wxUSE_MSGDLG - // just Ctrl-Alt-middle click shows information about wx version - ::wxInfoMessageBox((wxWindow*)this); -#endif // wxUSE_MSGDLG - } + // don't translate these strings, they're for diagnostics purposes only + wxString msg; + msg.Printf(_T("wxWidgets Library (%s port)\n") + _T("Version %d.%d.%d%s%s, compiled at %s %s\n") + _T("Runtime version of toolkit used is %d.%d.%s\n") + _T("Copyright (c) 1995-2010 wxWidgets team"), + wxPlatformInfo::Get().GetPortIdName().c_str(), + wxMAJOR_VERSION, + wxMINOR_VERSION, + wxRELEASE_NUMBER, +#if wxUSE_UNICODE + L" (Unicode)", +#else + wxEmptyString, +#endif +#ifdef __WXDEBUG__ + _T(" Debug build"), +#else + wxEmptyString, +#endif + __TDATE__, + __TTIME__, + wxPlatformInfo::Get().GetToolkitMajorVersion(), + wxPlatformInfo::Get().GetToolkitMinorVersion(), +#ifdef __WXGTK__ + wxString::Format(_T("\nThe compile-time GTK+ version is %d.%d.%d."), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION).c_str() +#else + wxEmptyString +#endif + ); + + wxMessageBox(msg, _T("wxWidgets information"), + wxICON_INFORMATION | wxOK, + (wxWindow *)this); } else +#endif // wxUSE_MSGDLG { event.Skip(); } @@ -3168,19 +2434,19 @@ wxAccessible* wxWindowBase::CreateAccessible() // list classes implementation // ---------------------------------------------------------------------------- -#if wxUSE_STD_CONTAINERS +#if wxUSE_STL #include "wx/listimpl.cpp" WX_DEFINE_LIST(wxWindowList) -#else // !wxUSE_STD_CONTAINERS +#else // !wxUSE_STL void wxWindowListNode::DeleteData() { delete (wxWindow *)GetData(); } -#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS +#endif // wxUSE_STL/!wxUSE_STL // ---------------------------------------------------------------------------- // borders @@ -3193,10 +2459,6 @@ wxBorder wxWindowBase::GetBorder(long flags) const { border = GetDefaultBorder(); } - else if ( border == wxBORDER_THEME ) - { - border = GetDefaultBorderForControl(); - } return border; } @@ -3230,107 +2492,70 @@ wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const // mouse capture // ---------------------------------------------------------------------------- -// Private data used for mouse capture tracking. -namespace wxMouseCapture +struct WXDLLEXPORT wxWindowNext { - -// Stack of the windows which previously had the capture, the top most element -// is the window that has the mouse capture now. -// -// NB: We use wxVector and not wxStack to be able to examine all of the stack -// elements for debug checks, but only the stack operations should be -// performed with this vector. -wxVector stack; - -// Flag preventing reentrancy in {Capture,Release}Mouse(). -wxRecursionGuardFlag changing; - -bool IsInCaptureStack(wxWindowBase* win) -{ - for ( wxVector::const_iterator it = stack.begin(); - it != stack.end(); - ++it ) - { - if ( *it == win ) - return true; - } - - return false; -} - -} // wxMouseCapture + wxWindow *win; + wxWindowNext *next; +} *wxWindowBase::ms_winCaptureNext = NULL; +wxWindow *wxWindowBase::ms_winCaptureCurrent = NULL; +bool wxWindowBase::ms_winCaptureChanging = false; void wxWindowBase::CaptureMouse() { - wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast(this)); + wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), wx_static_cast(void*, this)); - wxRecursionGuard guard(wxMouseCapture::changing); - wxASSERT_MSG( !guard.IsInside(), wxT("recursive CaptureMouse call?") ); + wxASSERT_MSG( !ms_winCaptureChanging, _T("recursive CaptureMouse call?") ); - wxASSERT_MSG( !wxMouseCapture::IsInCaptureStack(this), - "Recapturing the mouse in the same window?" ); + ms_winCaptureChanging = true; wxWindow *winOld = GetCapture(); if ( winOld ) + { ((wxWindowBase*) winOld)->DoReleaseMouse(); - DoCaptureMouse(); + // save it on stack + wxWindowNext *item = new wxWindowNext; + item->win = winOld; + item->next = ms_winCaptureNext; + ms_winCaptureNext = item; + } + //else: no mouse capture to save - wxMouseCapture::stack.push_back(static_cast(this)); + DoCaptureMouse(); + ms_winCaptureCurrent = (wxWindow*)this; + + ms_winCaptureChanging = false; } void wxWindowBase::ReleaseMouse() { - wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast(this)); + wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), wx_static_cast(void*, this)); - wxRecursionGuard guard(wxMouseCapture::changing); - wxASSERT_MSG( !guard.IsInside(), wxT("recursive ReleaseMouse call?") ); + wxASSERT_MSG( !ms_winCaptureChanging, _T("recursive ReleaseMouse call?") ); -#if wxDEBUG_LEVEL - wxWindow* const winCapture = GetCapture(); - if ( !winCapture ) - { - wxFAIL_MSG - ( - wxString::Format - ( - "Releasing mouse in %p(%s) but it is not captured", - this, GetClassInfo()->GetClassName() - ) - ); - } - else if ( winCapture != this ) - { - wxFAIL_MSG - ( - wxString::Format - ( - "Releasing mouse in %p(%s) but it is captured by %p(%s)", - this, GetClassInfo()->GetClassName(), - winCapture, winCapture->GetClassInfo()->GetClassName() - ) - ); - } -#endif // wxDEBUG_LEVEL + wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") ); + + ms_winCaptureChanging = true; DoReleaseMouse(); + ms_winCaptureCurrent = NULL; - wxCHECK_RET( !wxMouseCapture::stack.empty(), - "Releasing mouse capture but capture stack empty?" ); - wxCHECK_RET( wxMouseCapture::stack.back() == this, - "Window releasing mouse capture not top of capture stack?" ); - - wxMouseCapture::stack.pop_back(); - - // Restore the capture to the previous window, if any. - if ( !wxMouseCapture::stack.empty() ) + if ( ms_winCaptureNext ) { - ((wxWindowBase*)wxMouseCapture::stack.back())->DoCaptureMouse(); - } + ((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse(); + ms_winCaptureCurrent = ms_winCaptureNext->win; - wxLogTrace(wxT("mousecapture"), - wxT("After ReleaseMouse() mouse is captured by %p"), - static_cast(GetCapture())); + wxWindowNext *item = ms_winCaptureNext; + ms_winCaptureNext = item->next; + delete item; + } + //else: stack is empty, no previous capture + + ms_winCaptureChanging = false; + + wxLogTrace(_T("mousecapture"), + (const wxChar *) _T("After ReleaseMouse() mouse is captured by %p"), + wx_static_cast(void*, GetCapture())); } static void DoNotifyWindowAboutCaptureLost(wxWindow *win) @@ -3343,7 +2568,7 @@ static void DoNotifyWindowAboutCaptureLost(wxWindow *win) // correctly if it loses capture unexpectedly; see the discussion here: // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376 - wxFAIL_MSG( wxT("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") ); + wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") ); } } @@ -3352,17 +2577,26 @@ void wxWindowBase::NotifyCaptureLost() { // don't do anything if capture lost was expected, i.e. resulted from // a wx call to ReleaseMouse or CaptureMouse: - wxRecursionGuard guard(wxMouseCapture::changing); - if ( guard.IsInside() ) + if ( ms_winCaptureChanging ) return; // if the capture was lost unexpectedly, notify every window that has // capture (on stack or current) about it and clear the stack: - while ( !wxMouseCapture::stack.empty() ) - { - DoNotifyWindowAboutCaptureLost(wxMouseCapture::stack.back()); - wxMouseCapture::stack.pop_back(); + if ( ms_winCaptureCurrent ) + { + DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent); + ms_winCaptureCurrent = NULL; + } + + while ( ms_winCaptureNext ) + { + wxWindowNext *item = ms_winCaptureNext; + ms_winCaptureNext = item->next; + + DoNotifyWindowAboutCaptureLost(item->win); + + delete item; } } @@ -3389,25 +2623,25 @@ bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId)) // event processing // ---------------------------------------------------------------------------- -bool wxWindowBase::TryBefore(wxEvent& event) +bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event)) { #if wxUSE_VALIDATORS // Can only use the validator of the window which // is receiving the event if ( event.GetEventObject() == this ) { - wxValidator * const validator = GetValidator(); - if ( validator && validator->ProcessEventLocally(event) ) + wxValidator *validator = GetValidator(); + if ( validator && validator->ProcessEvent(event) ) { return true; } } #endif // wxUSE_VALIDATORS - return wxEvtHandler::TryBefore(event); + return false; } -bool wxWindowBase::TryAfter(wxEvent& event) +bool wxWindowBase::TryParent(wxEvent& event) { // carry on up the parent-child hierarchy if the propagation count hasn't // reached zero yet @@ -3422,32 +2656,32 @@ bool wxWindowBase::TryAfter(wxEvent& event) wxWindow *parent = GetParent(); if ( parent && !parent->IsBeingDeleted() ) { - wxPropagateOnce propagateOnce(event, this); + wxPropagateOnce propagateOnce(event); return parent->GetEventHandler()->ProcessEvent(event); } } } - return wxEvtHandler::TryAfter(event); + return wxEvtHandler::TryParent(event); } // ---------------------------------------------------------------------------- // window relationships // ---------------------------------------------------------------------------- -wxWindow *wxWindowBase::DoGetSibling(WindowOrder order) const +wxWindow *wxWindowBase::DoGetSibling(MoveKind order) const { wxCHECK_MSG( GetParent(), NULL, - wxT("GetPrev/NextSibling() don't work for TLWs!") ); + _T("GetPrev/NextSibling() don't work for TLWs!") ); wxWindowList& siblings = GetParent()->GetChildren(); wxWindowList::compatibility_iterator i = siblings.Find((wxWindow *)this); - wxCHECK_MSG( i, NULL, wxT("window not a child of its parent?") ); + wxCHECK_MSG( i, NULL, _T("window not a child of its parent?") ); - if ( order == OrderBefore ) + if ( order == MoveBefore ) i = i->GetPrevious(); - else // OrderAfter + else // MoveAfter i = i->GetNext(); return i ? i->GetData() : NULL; @@ -3457,47 +2691,24 @@ wxWindow *wxWindowBase::DoGetSibling(WindowOrder order) const // keyboard navigation // ---------------------------------------------------------------------------- -// Navigates in the specified direction inside this window -bool wxWindowBase::DoNavigateIn(int flags) +// Navigates in the specified direction. +bool wxWindowBase::Navigate(int flags) { -#ifdef wxHAS_NATIVE_TAB_TRAVERSAL - // native code doesn't process our wxNavigationKeyEvents anyhow - wxUnusedVar(flags); - return false; -#else // !wxHAS_NATIVE_TAB_TRAVERSAL wxNavigationKeyEvent eventNav; - wxWindow *focused = FindFocus(); - eventNav.SetCurrentFocus(focused); - eventNav.SetEventObject(focused); eventNav.SetFlags(flags); - return GetEventHandler()->ProcessEvent(eventNav); -#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL + eventNav.SetEventObject(this); + if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) ) + { + return true; + } + return false; } -bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent& event) -{ - if ( event.GetKeyCode() != WXK_TAB ) - return false; - - int flags = wxNavigationKeyEvent::FromTab; - - if ( event.ShiftDown() ) - flags |= wxNavigationKeyEvent::IsBackward; - else - flags |= wxNavigationKeyEvent::IsForward; - - if ( event.ControlDown() ) - flags |= wxNavigationKeyEvent::WinChange; - - Navigate(flags); - return true; -} - -void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move) +void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move) { // check that we're not a top level window wxCHECK_RET( GetParent(), - wxT("MoveBefore/AfterInTabOrder() don't work for TLWs!") ); + _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") ); // detect the special case when we have nothing to do anyhow and when the // code below wouldn't work @@ -3507,13 +2718,13 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move) // find the target window in the siblings list wxWindowList& siblings = GetParent()->GetChildren(); wxWindowList::compatibility_iterator i = siblings.Find(win); - wxCHECK_RET( i, wxT("MoveBefore/AfterInTabOrder(): win is not a sibling") ); + wxCHECK_RET( i, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") ); - // unfortunately, when wxUSE_STD_CONTAINERS == 1 DetachNode() is not - // implemented so we can't just move the node around + // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we + // can't just move the node around wxWindow *self = (wxWindow *)this; siblings.DeleteObject(self); - if ( move == OrderAfter ) + if ( move == MoveAfter ) { i = i->GetNext(); } @@ -3522,7 +2733,7 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move) { siblings.Insert(i, self); } - else // OrderAfter and win was the last sibling + else // MoveAfter and win was the last sibling { siblings.Append(self); } @@ -3538,26 +2749,16 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move) return win ? win->GetMainWindowOfCompositeControl() : NULL; } -bool wxWindowBase::HasFocus() const -{ - wxWindowBase* const win = DoFindFocus(); - return win && - (this == win || this == win->GetMainWindowOfCompositeControl()); -} - // ---------------------------------------------------------------------------- // drag and drop // ---------------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__) -namespace -{ - -class DragAcceptFilesTarget : public wxFileDropTarget +class wxDragAcceptFilesImplTarget : public wxFileDropTarget { public: - DragAcceptFilesTarget(wxWindowBase *win) : m_win(win) {} + wxDragAcceptFilesImplTarget(wxWindowBase *win) : m_win(win) {} virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) @@ -3569,18 +2770,16 @@ public: event.m_pos.x = x; event.m_pos.y = y; - return m_win->HandleWindowEvent(event); + return m_win->GetEventHandler()->ProcessEvent(event); } private: wxWindowBase * const m_win; - wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget); + DECLARE_NO_COPY_CLASS(wxDragAcceptFilesImplTarget) }; -} // anonymous namespace - // Generic version of DragAcceptFiles(). It works by installing a simple // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used // together with explicit SetDropTarget() calls. @@ -3589,8 +2788,8 @@ void wxWindowBase::DragAcceptFiles(bool accept) if ( accept ) { wxASSERT_MSG( !GetDropTarget(), - "cannot use DragAcceptFiles() and SetDropTarget() together" ); - SetDropTarget(new DragAcceptFilesTarget(this)); + _T("cannot use DragAcceptFiles() and SetDropTarget() together") ); + SetDropTarget(new wxDragAcceptFilesImplTarget(this)); } else { @@ -3652,7 +2851,7 @@ wxAccStatus wxWindowAccessible::GetLocation(wxRect& rect, int elementId) if (win) { rect = win->GetRect(); - if (win->GetParent() && !wxDynamicCast(win, wxTopLevelWindow)) + if (win->GetParent() && !win->IsKindOf(CLASSINFO(wxTopLevelWindow))) rect.SetPosition(win->GetParent()->ClientToScreen(rect.GetPosition())); return wxACC_OK; } @@ -3771,7 +2970,7 @@ wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name) // accessible classes, one for each kind of wxWidgets // control or window. #if wxUSE_BUTTON - if (wxDynamicCast(GetWindow(), wxButton)) + if (GetWindow()->IsKindOf(CLASSINFO(wxButton))) title = ((wxButton*) GetWindow())->GetLabel(); else #endif @@ -3930,14 +3129,14 @@ wxAccStatus wxWindowAccessible::GetRole(int childId, wxAccRole* role) if (childId > 0) return wxACC_NOT_IMPLEMENTED; - if (wxDynamicCast(GetWindow(), wxControl)) + if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) return wxACC_NOT_IMPLEMENTED; #if wxUSE_STATUSBAR - if (wxDynamicCast(GetWindow(), wxStatusBar)) + if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) return wxACC_NOT_IMPLEMENTED; #endif #if wxUSE_TOOLBAR - if (wxDynamicCast(GetWindow(), wxToolBar)) + if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) return wxACC_NOT_IMPLEMENTED; #endif @@ -3962,15 +3161,15 @@ wxAccStatus wxWindowAccessible::GetState(int childId, long* state) if (childId > 0) return wxACC_NOT_IMPLEMENTED; - if (wxDynamicCast(GetWindow(), wxControl)) + if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) return wxACC_NOT_IMPLEMENTED; #if wxUSE_STATUSBAR - if (wxDynamicCast(GetWindow(), wxStatusBar)) + if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) return wxACC_NOT_IMPLEMENTED; #endif #if wxUSE_TOOLBAR - if (wxDynamicCast(GetWindow(), wxToolBar)) + if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) return wxACC_NOT_IMPLEMENTED; #endif @@ -4054,4 +3253,3 @@ wxWindowBase::AdjustForLayoutDirection(wxCoord x, return x; } - diff --git a/Source/3rd Party/wx/src/common/windowid.cpp b/Source/3rd Party/wx/src/common/windowid.cpp deleted file mode 100644 index d0ee64ff5..000000000 --- a/Source/3rd Party/wx/src/common/windowid.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/common/windowid.cpp -// Purpose: wxWindowID class - a class for managing window ids -// Author: Brian Vanderburg II -// Created: 2007-09-21 -// Copyright: (c) 2007 Brian Vanderburg II -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// Needed headers -// ---------------------------------------------------------------------------- -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/intl.h" -#endif //WX_PRECOMP - -#include "wx/hashmap.h" - -// Not needed, included in defs.h -// #include "wx/windowid.h" - -#define wxTRACE_WINDOWID wxT("windowid") - -namespace -{ - -#if wxUSE_AUTOID_MANAGEMENT - - -// initially no ids are in use and we allocate them consecutively, but after we -// exhaust the entire range, we wrap around and reuse the ids freed in the -// meanwhile -static const wxUint8 ID_FREE = 0; -static const wxUint8 ID_STARTCOUNT = 1; -static const wxUint8 ID_COUNTTOOLARGE = 254; -static const wxUint8 ID_RESERVED = 255; - -// we use a two level count, most IDs will be used less than ID_COUNTTOOLARGE-1 -// thus we store their count directly in this array, however when the same ID -// is reused a great number of times (more than or equal to ID_COUNTTOOLARGE), -// the hash map stores the actual count -wxUint8 gs_autoIdsRefCount[wxID_AUTO_HIGHEST - wxID_AUTO_LOWEST + 1] = { 0 }; - -// NB: this variable is allocated (again) only when an ID gets at least -// ID_COUNTTOOLARGE refs, and is freed when the latest entry in the map gets -// freed. The cell storing the count for an ID is freed only when its count -// gets to zero (not when it goes below ID_COUNTTOOLARGE, so as to avoid -// degenerate cases) -wxLongToLongHashMap *gs_autoIdsLargeRefCount = NULL; - -// this is an optimization used until we wrap around wxID_AUTO_HIGHEST: if this -// value is < wxID_AUTO_HIGHEST we know that we haven't wrapped yet and so can -// allocate the ids simply by incrementing it -wxWindowID gs_nextAutoId = wxID_AUTO_LOWEST; - -// Reserve an ID -void ReserveIdRefCount(wxWindowID winid) -{ - wxCHECK_RET(winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST, - wxT("invalid id range")); - - winid -= wxID_AUTO_LOWEST; - - wxCHECK_RET(gs_autoIdsRefCount[winid] == ID_FREE, - wxT("id already in use or already reserved")); - gs_autoIdsRefCount[winid] = ID_RESERVED; -} - -// Unreserve and id -void UnreserveIdRefCount(wxWindowID winid) -{ - wxCHECK_RET(winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST, - wxT("invalid id range")); - - winid -= wxID_AUTO_LOWEST; - - wxCHECK_RET(gs_autoIdsRefCount[winid] == ID_RESERVED, - wxT("id already in use or not reserved")); - gs_autoIdsRefCount[winid] = ID_FREE; -} - -// Get the usage count of an id -int GetIdRefCount(wxWindowID winid) -{ - wxCHECK_MSG(winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST, 0, - wxT("invalid id range")); - - winid -= wxID_AUTO_LOWEST; - int refCount = gs_autoIdsRefCount[winid]; - if (refCount == ID_COUNTTOOLARGE) - refCount = (*gs_autoIdsLargeRefCount)[winid]; - return refCount; -} - -// Increase the count for an id -void IncIdRefCount(wxWindowID winid) -{ - wxCHECK_RET(winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST, - wxT("invalid id range")); - - winid -= wxID_AUTO_LOWEST; - - wxCHECK_RET(gs_autoIdsRefCount[winid] != ID_FREE, wxT("id should first be reserved")); - - if(gs_autoIdsRefCount[winid] == ID_RESERVED) - { - gs_autoIdsRefCount[winid] = ID_STARTCOUNT; - } - else if (gs_autoIdsRefCount[winid] >= ID_COUNTTOOLARGE-1) - { - if (gs_autoIdsRefCount[winid] == ID_COUNTTOOLARGE-1) - { - // we need to allocate a cell, and maybe the hash map itself - if (!gs_autoIdsLargeRefCount) - gs_autoIdsLargeRefCount = new wxLongToLongHashMap; - (*gs_autoIdsLargeRefCount)[winid] = ID_COUNTTOOLARGE-1; - - gs_autoIdsRefCount[winid] = ID_COUNTTOOLARGE; - } - ++(*gs_autoIdsLargeRefCount)[winid]; - } - else - { - gs_autoIdsRefCount[winid]++; - } - - wxLogTrace(wxTRACE_WINDOWID, wxT("Increasing ref count of ID %d to %d"), - winid + wxID_AUTO_LOWEST, GetIdRefCount(winid + wxID_AUTO_LOWEST)); -} - -// Decrease the count for an id -void DecIdRefCount(wxWindowID winid) -{ - wxCHECK_RET(winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST, - wxT("invalid id range")); - - winid -= wxID_AUTO_LOWEST; - - wxCHECK_RET(gs_autoIdsRefCount[winid] != ID_FREE, wxT("id count already 0")); - - // DecIdRefCount is only called on an ID that has been IncIdRefCount'ed' - // so it should never be reserved, but test anyway - if(gs_autoIdsRefCount[winid] == ID_RESERVED) - { - wxFAIL_MSG(wxT("reserve id being decreased")); - gs_autoIdsRefCount[winid] = ID_FREE; - } - else if(gs_autoIdsRefCount[winid] == ID_COUNTTOOLARGE) - { - long &largeCount = (*gs_autoIdsLargeRefCount)[winid]; - --largeCount; - if (largeCount == 0) - { - gs_autoIdsLargeRefCount->erase (winid); - gs_autoIdsRefCount[winid] = ID_FREE; - - if (gs_autoIdsLargeRefCount->empty()) - wxDELETE (gs_autoIdsLargeRefCount); - } - } - else - gs_autoIdsRefCount[winid]--; - - wxLogTrace(wxTRACE_WINDOWID, wxT("Decreasing ref count of ID %d to %d"), - winid + wxID_AUTO_LOWEST, GetIdRefCount(winid + wxID_AUTO_LOWEST)); -} - -#else // wxUSE_AUTOID_MANAGEMENT - -static wxWindowID gs_nextAutoId = wxID_AUTO_HIGHEST; - -#endif - -} // anonymous namespace - - -#if wxUSE_AUTOID_MANAGEMENT - -void wxWindowIDRef::Assign(wxWindowID winid) -{ - if ( winid != m_id ) - { - // decrease count if it is in the managed range - if ( m_id >= wxID_AUTO_LOWEST && m_id <= wxID_AUTO_HIGHEST ) - DecIdRefCount(m_id); - - m_id = winid; - - // increase count if it is in the managed range - if ( m_id >= wxID_AUTO_LOWEST && m_id <= wxID_AUTO_HIGHEST ) - IncIdRefCount(m_id); - } -} - -#endif // wxUSE_AUTOID_MANAGEMENT - - - -wxWindowID wxIdManager::ReserveId(int count) -{ - wxASSERT_MSG(count > 0, wxT("can't allocate less than 1 id")); - - -#if wxUSE_AUTOID_MANAGEMENT - if ( gs_nextAutoId + count - 1 <= wxID_AUTO_HIGHEST ) - { - wxWindowID winid = gs_nextAutoId; - - while(count--) - { - ReserveIdRefCount(gs_nextAutoId++); - } - - return winid; - } - else - { - int found = 0; - - for(wxWindowID winid = wxID_AUTO_LOWEST; winid <= wxID_AUTO_HIGHEST; winid++) - { - if(GetIdRefCount(winid) == 0) - { - found++; - if(found == count) - { - // Imagine this: 100 free IDs left. Then NewId(50) takes 50 - // so 50 left. Then, the 25 before that last 50 are freed, but - // gs_nextAutoId does not decrement and stays where it is at - // with 50 free. Then NewId(75) gets called, and since there - // are only 50 left according to gs_nextAutoId, it does a - // search and finds the 75 at the end. Then NewId(10) gets - // called, and accorind to gs_nextAutoId, their are still - // 50 at the end so it returns them without testing the ref - // To fix this, the next ID is also updated here as needed - if(winid >= gs_nextAutoId) - gs_nextAutoId = winid + 1; - - while(count--) - ReserveIdRefCount(winid--); - - return winid + 1; - } - } - else - { - found = 0; - } - } - } - - wxLogError(_("Out of window IDs. Recommend shutting down application.")); - return wxID_NONE; -#else // !wxUSE_AUTOID_MANAGEMENT - // Make sure enough in the range - wxWindowID winid; - - winid = gs_nextAutoId - count + 1; - - if ( winid >= wxID_AUTO_LOWEST && winid <= wxID_AUTO_HIGHEST ) - { - // There is enough, but it may be time to wrap - if(winid == wxID_AUTO_LOWEST) - gs_nextAutoId = wxID_AUTO_HIGHEST; - else - gs_nextAutoId = winid - 1; - - return winid; - } - else - { - // There is not enough at the low end of the range or - // count was big enough to wrap around to the positive - // Surely 'count' is not so big to take up much of the range - gs_nextAutoId = wxID_AUTO_HIGHEST - count; - return gs_nextAutoId + 1; - } -#endif // wxUSE_AUTOID_MANAGEMENT/!wxUSE_AUTOID_MANAGEMENT -} - -void wxIdManager::UnreserveId(wxWindowID winid, int count) -{ - wxASSERT_MSG(count > 0, wxT("can't unreserve less than 1 id")); - -#if wxUSE_AUTOID_MANAGEMENT - while (count--) - UnreserveIdRefCount(winid++); -#else - wxUnusedVar(winid); - wxUnusedVar(count); -#endif -} - diff --git a/Source/3rd Party/wx/src/common/wrapsizer.cpp b/Source/3rd Party/wx/src/common/wrapsizer.cpp deleted file mode 100644 index e1b112bed..000000000 --- a/Source/3rd Party/wx/src/common/wrapsizer.cpp +++ /dev/null @@ -1,589 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/wrapsizer.cpp -// Purpose: provides wxWrapSizer class for layout -// Author: Arne Steinarson -// Created: 2008-05-08 -// Copyright: (c) Arne Steinarson -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/wrapsizer.h" -#include "wx/vector.h" - -namespace -{ - -// ---------------------------------------------------------------------------- -// helper local classes -// ---------------------------------------------------------------------------- - -// This object changes the item proportion to INT_MAX in its ctor and restores -// it back in the dtor. -class wxPropChanger : public wxObject -{ -public: - wxPropChanger(wxSizer& sizer, wxSizerItem& item) - : m_sizer(sizer), - m_item(item), - m_propOld(item.GetProportion()) - { - // ensure that this item expands more than all the other ones - item.SetProportion(INT_MAX); - } - - ~wxPropChanger() - { - // check if the sizer still has this item, it could have been removed - if ( m_sizer.GetChildren().Find(&m_item) ) - m_item.SetProportion(m_propOld); - } - -private: - wxSizer& m_sizer; - wxSizerItem& m_item; - const int m_propOld; - - wxDECLARE_NO_COPY_CLASS(wxPropChanger); -}; - -} // anonymous namespace - -// ============================================================================ -// wxWrapSizer implementation -// ============================================================================ - -IMPLEMENT_DYNAMIC_CLASS(wxWrapSizer, wxBoxSizer) - -wxWrapSizer::wxWrapSizer(int orient, int flags) - : wxBoxSizer(orient), - m_flags(flags), - m_dirInform(0), - m_availSize(-1), - m_availableOtherDir(0), - m_lastUsed(true), - m_minSizeMinor(0), - m_maxSizeMajor(0), - m_minItemMajor(INT_MAX), - m_rows(orient ^ wxBOTH) -{ -} - -wxWrapSizer::~wxWrapSizer() -{ - ClearRows(); -} - -void wxWrapSizer::ClearRows() -{ - // all elements of the row sizers are also elements of this one (we - // directly add pointers to elements of our own m_children list to the row - // sizers in RecalcSizes()), so we need to detach them from the row sizer - // to avoid double deletion - wxSizerItemList& rows = m_rows.GetChildren(); - for ( wxSizerItemList::iterator i = rows.begin(), - end = rows.end(); - i != end; - ++i ) - { - wxSizerItem * const item = *i; - wxSizer * const row = item->GetSizer(); - if ( !row ) - { - wxFAIL_MSG( "all elements of m_rows must be sizers" ); - continue; - } - - row->GetChildren().clear(); - - wxPropChanger * const - propChanger = static_cast(item->GetUserData()); - if ( propChanger ) - { - // this deletes propChanger and so restores the old proportion - item->SetUserData(NULL); - } - } -} - -wxSizer *wxWrapSizer::GetRowSizer(size_t n) -{ - const wxSizerItemList& rows = m_rows.GetChildren(); - if ( n < rows.size() ) - return rows[n]->GetSizer(); - - wxSizer * const sizer = new wxBoxSizer(GetOrientation()); - m_rows.Add(sizer, wxSizerFlags().Expand()); - return sizer; -} - -bool wxWrapSizer::InformFirstDirection(int direction, - int size, - int availableOtherDir) -{ - if ( !direction ) - return false; - - // Store the values for later use - m_availSize = size; - m_availableOtherDir = availableOtherDir + - (direction == wxHORIZONTAL ? m_minSize.y - : m_minSize.x); - m_dirInform = direction; - m_lastUsed = false; - return true; -} - - -void wxWrapSizer::AdjustLastRowItemProp(size_t n, wxSizerItem *itemLast) -{ - if ( !itemLast || !(m_flags & wxEXTEND_LAST_ON_EACH_LINE) ) - { - // nothing to do - return; - } - - wxSizerItem * const item = m_rows.GetItem(n); - wxCHECK_RET( item, "invalid sizer item" ); - - // store the item we modified and its original proportion - item->SetUserData(new wxPropChanger(*this, *itemLast)); -} - -wxSize wxWrapSizer::CalcMin() -{ - if ( m_children.empty() ) - return wxSize(); - - // We come here to calculate min size in two different situations: - // 1 - Immediately after InformFirstDirection, then we find a min size that - // uses one dimension maximally and the other direction minimally. - // 2 - Ordinary case, get a sensible min size value using the current line - // layout, trying to maintain the possibility to re-arrange lines by - // sizing - - if ( !m_lastUsed ) - { - // Case 1 above: InformFirstDirection() has just been called - m_lastUsed = true; - - // There are two different algorithms for finding a useful min size for - // a wrap sizer, depending on whether the first reported size component - // is the opposite as our own orientation (the simpler case) or the same - // one (more complicated). - if ( m_dirInform == m_orient ) - CalcMinFromMajor(m_availSize); - else - CalcMinFromMinor(m_availSize); - } - else // Case 2 above: not immediately after InformFirstDirection() - { - if ( m_availSize > 0 ) - { - wxSize szAvail; // Keep track of boundary so we don't overflow - if ( m_dirInform == m_orient ) - szAvail = SizeFromMajorMinor(m_availSize, m_availableOtherDir); - else - szAvail = SizeFromMajorMinor(m_availableOtherDir, m_availSize); - - CalcMinFittingSize(szAvail); - } - else // Initial calculation, before we have size available to us - { - CalcMaxSingleItemSize(); - } - } - - return m_minSize; -} - -void wxWrapSizer::CalcMinFittingSize(const wxSize& szBoundary) -{ - // Min size based on current line layout. It is important to - // provide a smaller size when possible to allow for resizing with - // the help of re-arranging the lines. - wxSize sizeMin = SizeFromMajorMinor(m_maxSizeMajor, m_minSizeMinor); - if ( m_minSizeMinor < SizeInMinorDir(m_size) && - m_maxSizeMajor < SizeInMajorDir(m_size) ) - { - m_minSize = sizeMin; - } - else - { - // Try making it a bit more narrow - bool done = false; - if ( m_minItemMajor != INT_MAX && m_maxSizeMajor > 0 ) - { - // We try to present a lower min value by removing an item in - // the major direction (and preserving current minor min size). - CalcMinFromMajor(m_maxSizeMajor - m_minItemMajor); - if ( m_minSize.x <= szBoundary.x && m_minSize.y <= szBoundary.y ) - { - SizeInMinorDir(m_minSize) = SizeInMinorDir(sizeMin); - done = true; - } - } - - if ( !done ) - { - // If failed finding little smaller area, go back to what we had - m_minSize = sizeMin; - } - } -} - -void wxWrapSizer::CalcMaxSingleItemSize() -{ - // Find max item size in each direction - int maxMajor = 0; // Widest item - int maxMinor = 0; // Line height - for ( wxSizerItemList::const_iterator i = m_children.begin(); - i != m_children.end(); - ++i ) - { - wxSizerItem * const item = *i; - if ( item->IsShown() ) - { - wxSize sz = item->CalcMin(); - if ( SizeInMajorDir(sz) > maxMajor ) - maxMajor = SizeInMajorDir(sz); - if ( SizeInMinorDir(sz) > maxMinor ) - maxMinor = SizeInMinorDir(sz); - } - } - - // This is, of course, not our real minimal size but if we return more - // than this it would be impossible to shrink us to one row/column so - // we have to pretend that this is all we need for now. - m_minSize = SizeFromMajorMinor(maxMajor, maxMinor); -} - -void wxWrapSizer::CalcMinFromMajor(int totMajor) -{ - // Algorithm for calculating min size: (assuming horizontal orientation) - // This is the simpler case (known major size) - // X: Given, totMajor - // Y: Based on X, calculate how many lines needed - - int maxTotalMajor = 0; // max of rowTotalMajor over all rows - int minorSum = 0; // sum of sizes of all rows in minor direction - int maxRowMinor = 0; // max of item minor sizes in this row - int rowTotalMajor = 0; // sum of major sizes of items in this row - - // pack the items in each row until we reach totMajor, then start a new row - for ( wxSizerItemList::const_iterator i = m_children.begin(); - i != m_children.end(); - ++i ) - { - wxSizerItem * const item = *i; - if ( !item->IsShown() ) - continue; - - wxSize minItemSize = item->CalcMin(); - const int itemMajor = SizeInMajorDir(minItemSize); - const int itemMinor = SizeInMinorDir(minItemSize); - - // check if this is the first item in a new row: if so, we have to put - // it in it, whether it fits or not, as it would never fit better - // anyhow - // - // otherwise check if we have enough space left for this item here - if ( !rowTotalMajor || rowTotalMajor + itemMajor <= totMajor ) - { - // continue this row - rowTotalMajor += itemMajor; - if ( itemMinor > maxRowMinor ) - maxRowMinor = itemMinor; - } - else // start a new row - { - // minor size of the row is the max of minor sizes of its items - minorSum += maxRowMinor; - if ( rowTotalMajor > maxTotalMajor ) - maxTotalMajor = rowTotalMajor; - maxRowMinor = itemMinor; - rowTotalMajor = itemMajor; - } - } - - // account for the last (unfinished) row too - minorSum += maxRowMinor; - if ( rowTotalMajor > maxTotalMajor ) - maxTotalMajor = rowTotalMajor; - - m_minSize = SizeFromMajorMinor(maxTotalMajor, minorSum); -} - -// Helper struct for CalcMinFromMinor -struct wxWrapLine -{ - wxWrapLine() : m_first(NULL), m_width(0) { } - wxSizerItem *m_first; - int m_width; // Width of line -}; - -void wxWrapSizer::CalcMinFromMinor(int totMinor) -{ - // Algorithm for calculating min size: - // This is the more complex case (known minor size) - - // First step, find total sum of all items in primary direction - // and max item size in secondary direction, that gives initial - // estimate of the minimum number of lines. - - int totMajor = 0; // Sum of widths - int maxMinor = 0; // Line height - int maxMajor = 0; // Widest item - int itemCount = 0; - wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); - wxSize sz; - while (node) - { - wxSizerItem *item = node->GetData(); - if ( item->IsShown() ) - { - sz = item->CalcMin(); - totMajor += SizeInMajorDir(sz); - if ( SizeInMinorDir(sz)>maxMinor ) - maxMinor = SizeInMinorDir(sz); - if ( SizeInMajorDir(sz)>maxMinor ) - maxMajor = SizeInMajorDir(sz); - itemCount++; - } - node = node->GetNext(); - } - - // The trivial case - if ( !itemCount || totMajor==0 || maxMinor==0 ) - { - m_minSize = wxSize(0,0); - return; - } - - // First attempt, use lines of average size: - int nrLines = totMinor / maxMinor; // Rounding down is right here - if ( nrLines<=1 ) - { - // Another simple case, everything fits on one line - m_minSize = SizeFromMajorMinor(totMajor,maxMinor); - return; - } - - int lineSize = totMajor / nrLines; - if ( lineSize lines; - - int sumMinor; // Sum of all minor sizes (height of all lines) - - // While we still have items 'spilling over' extend the tested line width - for ( ;; ) - { - wxWrapLine *line = new wxWrapLine; - lines.push_back( line ); - - int tailSize = 0; // Width of what exceeds nrLines - maxMinor = 0; - sumMinor = 0; - for ( node=m_children.GetFirst(); node; node=node->GetNext() ) - { - wxSizerItem *item = node->GetData(); - if ( item->IsShown() ) - { - sz = item->GetMinSizeWithBorder(); - if ( line->m_width+SizeInMajorDir(sz)>lineSize ) - { - line = new wxWrapLine; - lines.push_back(line); - sumMinor += maxMinor; - maxMinor = 0; - } - line->m_width += SizeInMajorDir(sz); - if ( line->m_width && !line->m_first ) - line->m_first = item; - if ( SizeInMinorDir(sz)>maxMinor ) - maxMinor = SizeInMinorDir(sz); - if ( sumMinor+maxMinor>totMinor ) - { - // Keep track of widest tail item - if ( SizeInMajorDir(sz)>tailSize ) - tailSize = SizeInMajorDir(sz); - } - } - } - - if ( tailSize ) - { - // Now look how much we need to extend our size - // We know we must have at least one more line than nrLines - // (otherwise no tail size). - int bestExtSize = 0; // Minimum extension width for current tailSize - for ( int ix=0; ixm_width; // Left over at end of this line - int extSize = GetSizeInMajorDir(lines[ix+1]->m_first->GetMinSizeWithBorder()) - size; - if ( (extSize>=tailSize && (extSizebestExtSize && bestExtSize::iterator it=lines.begin(); it m_maxSizeMajor ) - m_maxSizeMajor = rowMajor; - - // And adjust proportion of its last item if necessary. - AdjustLastRowItemProp(n, itemLast); -} - -void wxWrapSizer::RecalcSizes() -{ - // First restore any proportions we may have changed and remove the old rows - ClearRows(); - - if ( m_children.empty() ) - return; - - // Put all our items into as many row box sizers as needed. - const int majorSize = SizeInMajorDir(m_size); // max size of each row - int rowTotalMajor = 0; // running row major size - int maxRowMinor = 0; - - m_minSizeMinor = 0; - m_minItemMajor = INT_MAX; - m_maxSizeMajor = 0; - - // We need at least one row - size_t nRow = 0; - wxSizer *sizer = GetRowSizer(nRow); - - wxSizerItem *itemLast = NULL, // last item processed in this row - *itemSpace = NULL; // spacer which we delayed adding - - // Now put our child items into child sizers instead - for ( wxSizerItemList::iterator i = m_children.begin(); - i != m_children.end(); - ++i ) - { - wxSizerItem * const item = *i; - if ( !item->IsShown() ) - continue; - - wxSize minItemSize = item->GetMinSizeWithBorder(); - const int itemMajor = SizeInMajorDir(minItemSize); - const int itemMinor = SizeInMinorDir(minItemSize); - if ( itemMajor > 0 && itemMajor < m_minItemMajor ) - m_minItemMajor = itemMajor; - - // Is there more space on this line? Notice that if this is the first - // item we add it unconditionally as it wouldn't fit in the next line - // any better than in this one. - if ( !rowTotalMajor || rowTotalMajor + itemMajor <= majorSize ) - { - // There is enough space here - rowTotalMajor += itemMajor; - if ( itemMinor > maxRowMinor ) - maxRowMinor = itemMinor; - } - else // Start a new row - { - FinishRow(nRow, rowTotalMajor, maxRowMinor, itemLast); - - rowTotalMajor = itemMajor; - maxRowMinor = itemMinor; - - // Get a new empty sizer to insert into - sizer = GetRowSizer(++nRow); - - itemLast = - itemSpace = NULL; - } - - // Only remove first/last spaces if that flag is set - if ( (m_flags & wxREMOVE_LEADING_SPACES) && IsSpaceItem(item) ) - { - // Remember space only if we have a first item - if ( itemLast ) - itemSpace = item; - } - else // not a space - { - if ( itemLast && itemSpace ) - { - // We had a spacer after a real item and now that we add - // another real item to the same row we need to add the spacer - // between them two. - sizer->Add(itemSpace); - } - - // Notice that we reuse a pointer to our own sizer item here, so we - // must remember to remove it by calling ClearRows() to avoid - // double deletion later - sizer->Add(item); - - itemLast = item; - itemSpace = NULL; - } - - // If item is a window, it now has a pointer to the child sizer, - // which is wrong. Set it to point to us. - if ( wxWindow *win = item->GetWindow() ) - win->SetContainingSizer(this); - } - - FinishRow(nRow, rowTotalMajor, maxRowMinor, itemLast); - - // Now do layout on row sizer - m_rows.SetDimension(m_position, m_size); -} - - diff --git a/Source/3rd Party/wx/src/common/wxchar.cpp b/Source/3rd Party/wx/src/common/wxchar.cpp new file mode 100644 index 000000000..068a1a09e --- /dev/null +++ b/Source/3rd Party/wx/src/common/wxchar.cpp @@ -0,0 +1,2293 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/common/wxchar.cpp +// Purpose: wxChar implementation +// Author: Ove Kaven +// Modified by: Ron Lee, Francesco Montorsi +// Created: 09/04/99 +// RCS-ID: $Id: wxchar.cpp 58994 2009-02-18 15:49:09Z FM $ +// Copyright: (c) wxWidgets copyright +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// =========================================================================== +// headers, declarations, constants +// =========================================================================== + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/wxchar.h" + +#define _ISOC9X_SOURCE 1 // to get vsscanf() +#define _BSD_SOURCE 1 // to still get strdup() + +#include +#include +#include + +#ifndef __WXWINCE__ + #include + #include +#else + #include "wx/msw/wince/time.h" +#endif + +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/hash.h" + #include "wx/utils.h" // for wxMin and wxMax + #include "wx/log.h" +#endif + +#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H) + #include + #include + #include + #include +#endif + +#if defined(__MWERKS__) && __MSL__ >= 0x6000 +namespace std {} +using namespace std ; +#endif + +#if wxUSE_WCHAR_T +size_t WXDLLEXPORT wxMB2WC(wchar_t *buf, const char *psz, size_t n) +{ + // assume that we have mbsrtowcs() too if we have wcsrtombs() +#ifdef HAVE_WCSRTOMBS + mbstate_t mbstate; + memset(&mbstate, 0, sizeof(mbstate_t)); +#endif + + if (buf) { + if (!n || !*psz) { + if (n) *buf = wxT('\0'); + return 0; + } +#ifdef HAVE_WCSRTOMBS + return mbsrtowcs(buf, &psz, n, &mbstate); +#else + return wxMbstowcs(buf, psz, n); +#endif + } + + // note that we rely on common (and required by Unix98 but unfortunately not + // C99) extension which allows to call mbs(r)towcs() with NULL output pointer + // to just get the size of the needed buffer -- this is needed as otherwise + // we have no idea about how much space we need and if the CRT doesn't + // support it (the only currently known example being Metrowerks, see + // wx/wxchar.h) we don't use its mbstowcs() at all +#ifdef HAVE_WCSRTOMBS + return mbsrtowcs((wchar_t *) NULL, &psz, 0, &mbstate); +#else + return wxMbstowcs((wchar_t *) NULL, psz, 0); +#endif +} + +size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *pwz, size_t n) +{ +#ifdef HAVE_WCSRTOMBS + mbstate_t mbstate; + memset(&mbstate, 0, sizeof(mbstate_t)); +#endif + + if (buf) { + if (!n || !*pwz) { + // glibc2.1 chokes on null input + if (n) *buf = '\0'; + return 0; + } +#ifdef HAVE_WCSRTOMBS + return wcsrtombs(buf, &pwz, n, &mbstate); +#else + return wxWcstombs(buf, pwz, n); +#endif + } + +#ifdef HAVE_WCSRTOMBS + return wcsrtombs((char *) NULL, &pwz, 0, &mbstate); +#else + return wxWcstombs((char *) NULL, pwz, 0); +#endif +} +#endif // wxUSE_WCHAR_T + +bool WXDLLEXPORT wxOKlibc() +{ +#if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__) && !defined(__WINE__) + // glibc 2.0 uses UTF-8 even when it shouldn't + wchar_t res = 0; + if ((MB_CUR_MAX == 2) && + (wxMB2WC(&res, "\xdd\xa5", 1) == 1) && + (res==0x765)) { + // this is UTF-8 allright, check whether that's what we want + char *cur_locale = setlocale(LC_CTYPE, NULL); + if ((strlen(cur_locale) < 4) || + (strcasecmp(cur_locale + strlen(cur_locale) - 4, "utf8")) || + (strcasecmp(cur_locale + strlen(cur_locale) - 5, "utf-8"))) { + // nope, don't use libc conversion + return false; + } + } +#endif + return true; +} + +// ============================================================================ +// printf() functions business +// ============================================================================ + +// special test mode: define all functions below even if we don't really need +// them to be able to test them +#ifdef wxTEST_PRINTF + #undef wxFprintf + #undef wxPrintf + #undef wxSprintf + #undef wxVfprintf + #undef wxVsprintf + #undef wxVprintf + #undef wxVsnprintf_ + #undef wxSnprintf_ + + #define wxNEED_WPRINTF + + int wxVfprintf( FILE *stream, const wxChar *format, va_list argptr ); +#endif + +// ---------------------------------------------------------------------------- +// implement [v]snprintf() if the system doesn't provide a safe one +// or if the system's one does not support positional parameters +// (very useful for i18n purposes) +// ---------------------------------------------------------------------------- + +#if !defined(wxVsnprintf_) + +#if !wxUSE_WXVSNPRINTF + #error wxUSE_WXVSNPRINTF must be 1 if our wxVsnprintf_ is used +#endif + +// wxUSE_STRUTILS says our wxVsnprintf_ implementation to use or not to +// use wxStrlen and wxStrncpy functions over one-char processing loops. +// +// Some benchmarking revealed that wxUSE_STRUTILS == 1 has the following +// effects: +// -> on Windows: +// when in ANSI mode, this setting does not change almost anything +// when in Unicode mode, it gives ~ 50% of slowdown ! +// -> on Linux: +// both in ANSI and Unicode mode it gives ~ 60% of speedup ! +// +#if defined(WIN32) && wxUSE_UNICODE +#define wxUSE_STRUTILS 0 +#else +#define wxUSE_STRUTILS 1 +#endif + +// some limits of our implementation +#define wxMAX_SVNPRINTF_ARGUMENTS 64 +#define wxMAX_SVNPRINTF_FLAGBUFFER_LEN 32 +#define wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN 512 + +// prefer snprintf over sprintf +#if defined(__VISUALC__) || \ + (defined(__BORLANDC__) && __BORLANDC__ >= 0x540) + #define system_sprintf(buff, max, flags, data) \ + ::_snprintf(buff, max, flags, data) +#elif defined(HAVE_SNPRINTF) + #define system_sprintf(buff, max, flags, data) \ + ::snprintf(buff, max, flags, data) +#else // NB: at least sprintf() should always be available + // since 'max' is not used in this case, wxVsnprintf() should always + // ensure that 'buff' is big enough for all common needs + // (see wxMAX_SVNPRINTF_FLAGBUFFER_LEN and wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN) + #define system_sprintf(buff, max, flags, data) \ + ::sprintf(buff, flags, data) + + #define SYSTEM_SPRINTF_IS_UNSAFE +#endif + +// the conversion specifiers accepted by wxVsnprintf_ +enum wxPrintfArgType { + wxPAT_INVALID = -1, + + wxPAT_INT, // %d, %i, %o, %u, %x, %X + wxPAT_LONGINT, // %ld, etc +#ifdef wxLongLong_t + wxPAT_LONGLONGINT, // %Ld, etc +#endif + wxPAT_SIZET, // %Zd, etc + + wxPAT_DOUBLE, // %e, %E, %f, %g, %G + wxPAT_LONGDOUBLE, // %le, etc + + wxPAT_POINTER, // %p + + wxPAT_CHAR, // %hc (in ANSI mode: %c, too) + wxPAT_WCHAR, // %lc (in Unicode mode: %c, too) + + wxPAT_PCHAR, // %s (related to a char *) + wxPAT_PWCHAR, // %s (related to a wchar_t *) + + wxPAT_NINT, // %n + wxPAT_NSHORTINT, // %hn + wxPAT_NLONGINT // %ln +}; + +// an argument passed to wxVsnprintf_ +typedef union { + int pad_int; // %d, %i, %o, %u, %x, %X + long int pad_longint; // %ld, etc +#ifdef wxLongLong_t + wxLongLong_t pad_longlongint; // %Ld, etc +#endif + size_t pad_sizet; // %Zd, etc + + double pad_double; // %e, %E, %f, %g, %G + long double pad_longdouble; // %le, etc + + void *pad_pointer; // %p + + char pad_char; // %hc (in ANSI mode: %c, too) + wchar_t pad_wchar; // %lc (in Unicode mode: %c, too) + + char *pad_pchar; // %s (related to a char *) + wchar_t *pad_pwchar; // %s (related to a wchar_t *) + + int *pad_nint; // %n + short int *pad_nshortint; // %hn + long int *pad_nlongint; // %ln +} wxPrintfArg; + + +// Contains parsed data relative to a conversion specifier given to +// wxVsnprintf_ and parsed from the format string +// NOTE: in C++ there is almost no difference between struct & classes thus +// there is no performance gain by using a struct here... +class wxPrintfConvSpec +{ +public: + + // the position of the argument relative to this conversion specifier + size_t m_pos; + + // the type of this conversion specifier + wxPrintfArgType m_type; + + // the minimum and maximum width + // when one of this var is set to -1 it means: use the following argument + // in the stack as minimum/maximum width for this conversion specifier + int m_nMinWidth, m_nMaxWidth; + + // does the argument need to the be aligned to left ? + bool m_bAlignLeft; + + // pointer to the '%' of this conversion specifier in the format string + // NOTE: this points somewhere in the string given to the Parse() function - + // it's task of the caller ensure that memory is still valid ! + const wxChar *m_pArgPos; + + // pointer to the last character of this conversion specifier in the + // format string + // NOTE: this points somewhere in the string given to the Parse() function - + // it's task of the caller ensure that memory is still valid ! + const wxChar *m_pArgEnd; + + // a little buffer where formatting flags like #+\.hlqLZ are stored by Parse() + // for use in Process() + // NB: even if this buffer is used only for numeric conversion specifiers and + // thus could be safely declared as a char[] buffer, we want it to be wxChar + // so that in Unicode builds we can avoid to convert its contents to Unicode + // chars when copying it in user's buffer. + char m_szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN]; + + +public: + + // we don't declare this as a constructor otherwise it would be called + // automatically and we don't want this: to be optimized, wxVsnprintf_ + // calls this function only on really-used instances of this class. + void Init(); + + // Parses the first conversion specifier in the given string, which must + // begin with a '%'. Returns false if the first '%' does not introduce a + // (valid) conversion specifier and thus should be ignored. + bool Parse(const wxChar *format); + + // Process this conversion specifier and puts the result in the given + // buffer. Returns the number of characters written in 'buf' or -1 if + // there's not enough space. + int Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t written); + + // Loads the argument of this conversion specifier from given va_list. + bool LoadArg(wxPrintfArg *p, va_list &argptr); + +private: + // An helper function of LoadArg() which is used to handle the '*' flag + void ReplaceAsteriskWith(int w); +}; + +void wxPrintfConvSpec::Init() +{ + m_nMinWidth = 0; + m_nMaxWidth = 0xFFFF; + m_pos = 0; + m_bAlignLeft = false; + m_pArgPos = m_pArgEnd = NULL; + m_type = wxPAT_INVALID; + + // this character will never be removed from m_szFlags array and + // is important when calling sprintf() in wxPrintfConvSpec::Process() ! + m_szFlags[0] = '%'; +} + +bool wxPrintfConvSpec::Parse(const wxChar *format) +{ + bool done = false; + + // temporary parse data + size_t flagofs = 1; + bool in_prec, // true if we found the dot in some previous iteration + prec_dot; // true if the dot has been already added to m_szFlags + int ilen = 0; + + m_bAlignLeft = in_prec = prec_dot = false; + m_pArgPos = m_pArgEnd = format; + do + { +#define CHECK_PREC \ + if (in_prec && !prec_dot) \ + { \ + m_szFlags[flagofs++] = '.'; \ + prec_dot = true; \ + } + + // what follows '%'? + const wxChar ch = *(++m_pArgEnd); + switch ( ch ) + { + case wxT('\0'): + return false; // not really an argument + + case wxT('%'): + return false; // not really an argument + + case wxT('#'): + case wxT('0'): + case wxT(' '): + case wxT('+'): + case wxT('\''): + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('-'): + CHECK_PREC + m_bAlignLeft = true; + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('.'): + CHECK_PREC + in_prec = true; + prec_dot = false; + m_nMaxWidth = 0; + // dot will be auto-added to m_szFlags if non-negative + // number follows + break; + + case wxT('h'): + ilen = -1; + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('l'): + // NB: it's safe to use flagofs-1 as flagofs always start from 1 + if (m_szFlags[flagofs-1] == 'l') // 'll' modifier is the same as 'L' or 'q' + ilen = 2; + else + ilen = 1; + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('q'): + case wxT('L'): + ilen = 2; + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + break; +#ifdef __WXMSW__ + // under Windows we support the special '%I64' notation as longlong + // integer conversion specifier for MSVC compatibility + // (it behaves exactly as '%lli' or '%Li' or '%qi') + case wxT('I'): + if (*(m_pArgEnd+1) != wxT('6') || + *(m_pArgEnd+2) != wxT('4')) + return false; // bad format + + m_pArgEnd++; + m_pArgEnd++; + + ilen = 2; + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs++] = '6'; + m_szFlags[flagofs++] = '4'; + break; +#endif // __WXMSW__ + + case wxT('Z'): + ilen = 3; + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('*'): + if (in_prec) + { + CHECK_PREC + + // tell Process() to use the next argument + // in the stack as maxwidth... + m_nMaxWidth = -1; + } + else + { + // tell Process() to use the next argument + // in the stack as minwidth... + m_nMinWidth = -1; + } + + // save the * in our formatting buffer... + // will be replaced later by Process() + m_szFlags[flagofs++] = char(ch); + break; + + case wxT('1'): case wxT('2'): case wxT('3'): + case wxT('4'): case wxT('5'): case wxT('6'): + case wxT('7'): case wxT('8'): case wxT('9'): + { + int len = 0; + CHECK_PREC + while ( (*m_pArgEnd >= wxT('0')) && + (*m_pArgEnd <= wxT('9')) ) + { + m_szFlags[flagofs++] = char(*m_pArgEnd); + len = len*10 + (*m_pArgEnd - wxT('0')); + m_pArgEnd++; + } + + if (in_prec) + m_nMaxWidth = len; + else + m_nMinWidth = len; + + m_pArgEnd--; // the main loop pre-increments n again + } + break; + + case wxT('$'): // a positional parameter (e.g. %2$s) ? + { + if (m_nMinWidth <= 0) + break; // ignore this formatting flag as no + // numbers are preceding it + + // remove from m_szFlags all digits previously added + do { + flagofs--; + } while (m_szFlags[flagofs] >= '1' && + m_szFlags[flagofs] <= '9'); + + // re-adjust the offset making it point to the + // next free char of m_szFlags + flagofs++; + + m_pos = m_nMinWidth; + m_nMinWidth = 0; + } + break; + + case wxT('d'): + case wxT('i'): + case wxT('o'): + case wxT('u'): + case wxT('x'): + case wxT('X'): + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + if (ilen == 0) + m_type = wxPAT_INT; + else if (ilen == -1) + // NB: 'short int' value passed through '...' + // is promoted to 'int', so we have to get + // an int from stack even if we need a short + m_type = wxPAT_INT; + else if (ilen == 1) + m_type = wxPAT_LONGINT; + else if (ilen == 2) +#ifdef wxLongLong_t + m_type = wxPAT_LONGLONGINT; +#else // !wxLongLong_t + m_type = wxPAT_LONGINT; +#endif // wxLongLong_t/!wxLongLong_t + else if (ilen == 3) + m_type = wxPAT_SIZET; + done = true; + break; + + case wxT('e'): + case wxT('E'): + case wxT('f'): + case wxT('g'): + case wxT('G'): + CHECK_PREC + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + if (ilen == 2) + m_type = wxPAT_LONGDOUBLE; + else + m_type = wxPAT_DOUBLE; + done = true; + break; + + case wxT('p'): + m_type = wxPAT_POINTER; + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + done = true; + break; + + case wxT('c'): + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + if (ilen == -1) + { + // in Unicode mode %hc == ANSI character + // and in ANSI mode, %hc == %c == ANSI... + m_type = wxPAT_CHAR; + } + else if (ilen == 1) + { + // in ANSI mode %lc == Unicode character + // and in Unicode mode, %lc == %c == Unicode... + m_type = wxPAT_WCHAR; + } + else + { +#if wxUSE_UNICODE + // in Unicode mode, %c == Unicode character + m_type = wxPAT_WCHAR; +#else + // in ANSI mode, %c == ANSI character + m_type = wxPAT_CHAR; +#endif + } + done = true; + break; + + case wxT('s'): + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + if (ilen == -1) + { + // Unicode mode wx extension: we'll let %hs mean non-Unicode + // strings (when in ANSI mode, %s == %hs == ANSI string) + m_type = wxPAT_PCHAR; + } + else if (ilen == 1) + { + // in Unicode mode, %ls == %s == Unicode string + // in ANSI mode, %ls == Unicode string + m_type = wxPAT_PWCHAR; + } + else + { +#if wxUSE_UNICODE + m_type = wxPAT_PWCHAR; +#else + m_type = wxPAT_PCHAR; +#endif + } + done = true; + break; + + case wxT('n'): + m_szFlags[flagofs++] = char(ch); + m_szFlags[flagofs] = '\0'; + if (ilen == 0) + m_type = wxPAT_NINT; + else if (ilen == -1) + m_type = wxPAT_NSHORTINT; + else if (ilen >= 1) + m_type = wxPAT_NLONGINT; + done = true; + break; + + default: + // bad format, don't consider this an argument; + // leave it unchanged + return false; + } + + if (flagofs == wxMAX_SVNPRINTF_FLAGBUFFER_LEN) + { + wxLogDebug(wxT("Too many flags specified for a single conversion specifier!")); + return false; + } + } + while (!done); + + return true; // parsing was successful +} + + +void wxPrintfConvSpec::ReplaceAsteriskWith(int width) +{ + char temp[wxMAX_SVNPRINTF_FLAGBUFFER_LEN]; + + // find the first * in our flag buffer + char *pwidth = strchr(m_szFlags, '*'); + wxCHECK_RET(pwidth, _T("field width must be specified")); + + // save what follows the * (the +1 is to skip the asterisk itself!) + strcpy(temp, pwidth+1); + if (width < 0) + { + pwidth[0] = wxT('-'); + pwidth++; + } + + // replace * with the actual integer given as width +#ifndef SYSTEM_SPRINTF_IS_UNSAFE + int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) / + sizeof(*m_szFlags); +#endif + int offset = system_sprintf(pwidth, maxlen, "%d", abs(width)); + + // restore after the expanded * what was following it + strcpy(pwidth+offset, temp); +} + +bool wxPrintfConvSpec::LoadArg(wxPrintfArg *p, va_list &argptr) +{ + // was the '*' width/precision specifier used ? + if (m_nMaxWidth == -1) + { + // take the maxwidth specifier from the stack + m_nMaxWidth = va_arg(argptr, int); + if (m_nMaxWidth < 0) + m_nMaxWidth = 0; + else + ReplaceAsteriskWith(m_nMaxWidth); + } + + if (m_nMinWidth == -1) + { + // take the minwidth specifier from the stack + m_nMinWidth = va_arg(argptr, int); + + ReplaceAsteriskWith(m_nMinWidth); + if (m_nMinWidth < 0) + { + m_bAlignLeft = !m_bAlignLeft; + m_nMinWidth = -m_nMinWidth; + } + } + + switch (m_type) { + case wxPAT_INT: + p->pad_int = va_arg(argptr, int); + break; + case wxPAT_LONGINT: + p->pad_longint = va_arg(argptr, long int); + break; +#ifdef wxLongLong_t + case wxPAT_LONGLONGINT: + p->pad_longlongint = va_arg(argptr, wxLongLong_t); + break; +#endif // wxLongLong_t + case wxPAT_SIZET: + p->pad_sizet = va_arg(argptr, size_t); + break; + case wxPAT_DOUBLE: + p->pad_double = va_arg(argptr, double); + break; + case wxPAT_LONGDOUBLE: + p->pad_longdouble = va_arg(argptr, long double); + break; + case wxPAT_POINTER: + p->pad_pointer = va_arg(argptr, void *); + break; + + case wxPAT_CHAR: + p->pad_char = (char)va_arg(argptr, int); // char is promoted to int when passed through '...' + break; + case wxPAT_WCHAR: + p->pad_wchar = (wchar_t)va_arg(argptr, int); // char is promoted to int when passed through '...' + break; + + case wxPAT_PCHAR: + p->pad_pchar = va_arg(argptr, char *); + break; + case wxPAT_PWCHAR: + p->pad_pwchar = va_arg(argptr, wchar_t *); + break; + + case wxPAT_NINT: + p->pad_nint = va_arg(argptr, int *); + break; + case wxPAT_NSHORTINT: + p->pad_nshortint = va_arg(argptr, short int *); + break; + case wxPAT_NLONGINT: + p->pad_nlongint = va_arg(argptr, long int *); + break; + + case wxPAT_INVALID: + default: + return false; + } + + return true; // loading was successful +} + +int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t written) +{ + // buffer to avoid dynamic memory allocation each time for small strings; + // note that this buffer is used only to hold results of number formatting, + // %s directly writes user's string in buf, without using szScratch + char szScratch[wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN]; + size_t lenScratch = 0, lenCur = 0; + +#define APPEND_CH(ch) \ + { \ + if ( lenCur == lenMax ) \ + return -1; \ + \ + buf[lenCur++] = ch; \ + } + +#define APPEND_STR(s) \ + { \ + for ( const wxChar *p = s; *p; p++ ) \ + { \ + APPEND_CH(*p); \ + } \ + } + + switch ( m_type ) + { + case wxPAT_INT: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_int); + break; + + case wxPAT_LONGINT: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longint); + break; + +#ifdef wxLongLong_t + case wxPAT_LONGLONGINT: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longlongint); + break; +#endif // SIZEOF_LONG_LONG + + case wxPAT_SIZET: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_sizet); + break; + + case wxPAT_LONGDOUBLE: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longdouble); + break; + + case wxPAT_DOUBLE: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_double); + break; + + case wxPAT_POINTER: + lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_pointer); + break; + + case wxPAT_CHAR: + case wxPAT_WCHAR: + { + wxChar val = +#if wxUSE_UNICODE + p->pad_wchar; + + if (m_type == wxPAT_CHAR) + { + // user passed a character explicitely indicated as ANSI... + const char buf[2] = { p->pad_char, 0 }; + val = wxString(buf, wxConvLibc)[0u]; + + //wprintf(L"converting ANSI=>Unicode"); // for debug + } +#else + p->pad_char; + +#if wxUSE_WCHAR_T + if (m_type == wxPAT_WCHAR) + { + // user passed a character explicitely indicated as Unicode... + const wchar_t buf[2] = { p->pad_wchar, 0 }; + val = wxString(buf, wxConvLibc)[0u]; + + //printf("converting Unicode=>ANSI"); // for debug + } +#endif +#endif + + size_t i; + + if (!m_bAlignLeft) + for (i = 1; i < (size_t)m_nMinWidth; i++) + APPEND_CH(_T(' ')); + + APPEND_CH(val); + + if (m_bAlignLeft) + for (i = 1; i < (size_t)m_nMinWidth; i++) + APPEND_CH(_T(' ')); + } + break; + + case wxPAT_PCHAR: + case wxPAT_PWCHAR: + { + wxString s; + const wxChar *val = +#if wxUSE_UNICODE + p->pad_pwchar; + + if (m_type == wxPAT_PCHAR) + { + // user passed a string explicitely indicated as ANSI... + val = s = wxString(p->pad_pchar, wxConvLibc); + + //wprintf(L"converting ANSI=>Unicode"); // for debug + } +#else + p->pad_pchar; + +#if wxUSE_WCHAR_T + if (m_type == wxPAT_PWCHAR) + { + // user passed a string explicitely indicated as Unicode... + val = s = wxString(p->pad_pwchar, wxConvLibc); + + //printf("converting Unicode=>ANSI"); // for debug + } +#endif +#endif + int len; + + if (val) + { +#if wxUSE_STRUTILS + // at this point we are sure that m_nMaxWidth is positive or null + // (see top of wxPrintfConvSpec::LoadArg) + len = wxMin((unsigned int)m_nMaxWidth, wxStrlen(val)); +#else + for ( len = 0; val[len] && (len < m_nMaxWidth); len++ ) + ; +#endif + } + else if (m_nMaxWidth >= 6) + { + val = wxT("(null)"); + len = 6; + } + else + { + val = wxEmptyString; + len = 0; + } + + int i; + + if (!m_bAlignLeft) + { + for (i = len; i < m_nMinWidth; i++) + APPEND_CH(_T(' ')); + } + +#if wxUSE_STRUTILS + len = wxMin((unsigned int)len, lenMax-lenCur); + wxStrncpy(buf+lenCur, val, len); + lenCur += len; +#else + for (i = 0; i < len; i++) + APPEND_CH(val[i]); +#endif + + if (m_bAlignLeft) + { + for (i = len; i < m_nMinWidth; i++) + APPEND_CH(_T(' ')); + } + } + break; + + case wxPAT_NINT: + *p->pad_nint = written; + break; + + case wxPAT_NSHORTINT: + *p->pad_nshortint = (short int)written; + break; + + case wxPAT_NLONGINT: + *p->pad_nlongint = written; + break; + + case wxPAT_INVALID: + default: + return -1; + } + + // if we used system's sprintf() then we now need to append the s_szScratch + // buffer to the given one... + switch (m_type) + { + case wxPAT_INT: + case wxPAT_LONGINT: +#ifdef wxLongLong_t + case wxPAT_LONGLONGINT: +#endif + case wxPAT_SIZET: + case wxPAT_LONGDOUBLE: + case wxPAT_DOUBLE: + case wxPAT_POINTER: + wxASSERT(lenScratch < wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN); +#if !wxUSE_UNICODE + { + if (lenMax < lenScratch) + { + // fill output buffer and then return -1 + wxStrncpy(buf, szScratch, lenMax); + return -1; + } + wxStrncpy(buf, szScratch, lenScratch); + lenCur += lenScratch; + } +#else + { + // Copy the char scratch to the wide output. This requires + // conversion, but we can optimise by making use of the fact + // that we are formatting numbers, this should mean only 7-bit + // ascii characters are involved. + wxChar *bufptr = buf; + const wxChar *bufend = buf + lenMax; + const char *scratchptr = szScratch; + + // Simply copy each char to a wxChar, stopping on the first + // null or non-ascii byte. Checking '(signed char)*scratchptr + // > 0' is an extra optimisation over '*scratchptr != 0 && + // isascii(*scratchptr)', though it assumes signed char is + // 8-bit 2 complement. + while ((signed char)*scratchptr > 0 && bufptr != bufend) + *bufptr++ = *scratchptr++; + + if (bufptr == bufend) + return -1; + + lenCur += bufptr - buf; + + // check if the loop stopped on a non-ascii char, if yes then + // fall back to wxMB2WX + if (*scratchptr) + { + size_t len = wxMB2WX(bufptr, scratchptr, bufend - bufptr); + + if (len && len != (size_t)(-1)) + if (bufptr[len - 1]) + return -1; + else + lenCur += len; + } + } +#endif + break; + + default: + break; // all other cases were completed previously + } + + return lenCur; +} + +// Copy chars from source to dest converting '%%' to '%'. Takes at most maxIn +// chars from source and write at most outMax chars to dest, returns the +// number of chars actually written. Does not treat null specially. +// +static int wxCopyStrWithPercents( + size_t maxOut, + wxChar *dest, + size_t maxIn, + const wxChar *source) +{ + size_t written = 0; + + if (maxIn == 0) + return 0; + + size_t i; + for ( i = 0; i < maxIn-1 && written < maxOut; source++, i++) + { + dest[written++] = *source; + if (*(source+1) == wxT('%')) + { + // skip this additional '%' character + source++; + i++; + } + } + + if (i < maxIn && written < maxOut) + // copy last character inconditionally + dest[written++] = *source; + + return written; +} + +int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax, + const wxChar *format, va_list argptr) +{ + // useful for debugging, to understand if we are really using this function + // rather than the system implementation +#if 0 + wprintf(L"Using wxVsnprintf_\n"); +#endif + + // required memory: + wxPrintfConvSpec arg[wxMAX_SVNPRINTF_ARGUMENTS]; + wxPrintfArg argdata[wxMAX_SVNPRINTF_ARGUMENTS]; + wxPrintfConvSpec *pspec[wxMAX_SVNPRINTF_ARGUMENTS] = { NULL }; + + size_t i; + + // number of characters in the buffer so far, must be less than lenMax + size_t lenCur = 0; + + size_t nargs = 0; + const wxChar *toparse = format; + + // parse the format string + bool posarg_present = false, nonposarg_present = false; + for (; *toparse != wxT('\0'); toparse++) + { + if (*toparse == wxT('%') ) + { + arg[nargs].Init(); + + // let's see if this is a (valid) conversion specifier... + if (arg[nargs].Parse(toparse)) + { + // ...yes it is + wxPrintfConvSpec *current = &arg[nargs]; + + // make toparse point to the end of this specifier + toparse = current->m_pArgEnd; + + if (current->m_pos > 0) + { + // the positionals start from number 1... adjust the index + current->m_pos--; + posarg_present = true; + } + else + { + // not a positional argument... + current->m_pos = nargs; + nonposarg_present = true; + } + + // this conversion specifier is tied to the pos-th argument... + pspec[current->m_pos] = current; + nargs++; + + if (nargs == wxMAX_SVNPRINTF_ARGUMENTS) + { + wxLogDebug(wxT("A single call to wxVsnprintf() has more than %d arguments; ") + wxT("ignoring all remaining arguments."), wxMAX_SVNPRINTF_ARGUMENTS); + break; // cannot handle any additional conv spec + } + } + else + { + // it's safe to look in the next character of toparse as at worst + // we'll hit its \0 + if (*(toparse+1) == wxT('%')) + toparse++; // the Parse() returned false because we've found a %% + } + } + } + + if (posarg_present && nonposarg_present) + { + buf[0] = 0; + return -1; // format strings with both positional and + } // non-positional conversion specifier are unsupported !! + + // on platforms where va_list is an array type, it is necessary to make a + // copy to be able to pass it to LoadArg as a reference. + bool ok = true; + va_list ap; + wxVaCopy(ap, argptr); + + // now load arguments from stack + for (i=0; i < nargs && ok; i++) + { + // !pspec[i] means that the user forgot a positional parameter (e.g. %$1s %$3s); + // LoadArg == false means that wxPrintfConvSpec::Parse failed to set the + // conversion specifier 'type' to a valid value... + ok = pspec[i] && pspec[i]->LoadArg(&argdata[i], ap); + } + + va_end(ap); + + // something failed while loading arguments from the variable list... + // (e.g. the user repeated twice the same positional argument) + if (!ok) + { + buf[0] = 0; + return -1; + } + + // finally, process each conversion specifier with its own argument + toparse = format; + for (i=0; i < nargs; i++) + { + // copy in the output buffer the portion of the format string between + // last specifier and the current one + size_t tocopy = ( arg[i].m_pArgPos - toparse ); + + lenCur += wxCopyStrWithPercents(lenMax - lenCur, buf + lenCur, + tocopy, toparse); + if (lenCur == lenMax) + { + buf[lenMax - 1] = 0; + return lenMax+1; // not enough space in the output buffer ! + } + + // process this specifier directly in the output buffer + int n = arg[i].Process(buf+lenCur, lenMax - lenCur, &argdata[arg[i].m_pos], lenCur); + if (n == -1) + { + buf[lenMax-1] = wxT('\0'); // be sure to always NUL-terminate the string + return lenMax+1; // not enough space in the output buffer ! + } + lenCur += n; + + // the +1 is because wxPrintfConvSpec::m_pArgEnd points to the last character + // of the format specifier, but we are not interested to it... + toparse = arg[i].m_pArgEnd + 1; + } + + // copy portion of the format string after last specifier + // NOTE: toparse is pointing to the character just after the last processed + // conversion specifier + // NOTE2: the +1 is because we want to copy also the '\0' + size_t tocopy = wxStrlen(format) + 1 - ( toparse - format ) ; + + lenCur += wxCopyStrWithPercents(lenMax - lenCur, buf + lenCur, + tocopy, toparse) - 1; + if (buf[lenCur]) + { + buf[lenCur] = 0; + return lenMax+1; // not enough space in the output buffer ! + } + + // Don't do: + // wxASSERT(lenCur == wxStrlen(buf)); + // in fact if we embedded NULLs in the output buffer (using %c with a '\0') + // such check would fail + + return lenCur; +} + +#undef APPEND_CH +#undef APPEND_STR +#undef CHECK_PREC + +#else // wxVsnprintf_ is defined + +#if wxUSE_WXVSNPRINTF + #error wxUSE_WXVSNPRINTF must be 0 if our wxVsnprintf_ is not used +#endif + +#endif // !wxVsnprintf_ + +#if !defined(wxSnprintf_) +int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) +{ + va_list argptr; + va_start(argptr, format); + + int iLen = wxVsnprintf_(buf, len, format, argptr); + + va_end(argptr); + + return iLen; +} +#endif // wxSnprintf_ + +#if defined(__DMC__) + /* Digital Mars adds count to _stprintf (C99) so convert */ + #if wxUSE_UNICODE + int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) + { + va_list arglist; + + va_start( arglist, format ); + int iLen = swprintf ( s, -1, format, arglist ); + va_end( arglist ); + return iLen ; + } + + #endif // wxUSE_UNICODE + +#endif //__DMC__ + +#if defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) + /* MinGW with STLPort 5.1 has clashing defines for _stprintf so use swprintf */ + /* STLPort 5.1 defines standard (C99) vswprintf() and swprintf() that takes count. */ + int wxSprintf (wchar_t * s, const wchar_t * format, ... ) + { + va_list arglist; + + va_start( arglist, format ); + int iLen = swprintf ( s, -1, format, arglist ); + va_end( arglist ); + return iLen ; + } +#endif // MINGW32 _STLPORT_VERSION >= 0x510 + +// ---------------------------------------------------------------------------- +// implement the standard IO functions for wide char if libc doesn't have them +// ---------------------------------------------------------------------------- + +#ifdef wxNEED_FPUTS +int wxFputs(const wchar_t *ws, FILE *stream) +{ + wxCharBuffer buf(wxConvLibc.cWC2MB(ws)); + if ( !buf ) + return -1; + + // counting the number of wide characters written isn't worth the trouble, + // simply distinguish between ok and error + return fputs(buf, stream) == -1 ? -1 : 0; +} +#endif // wxNEED_FPUTS + +#ifdef wxNEED_PUTS +int wxPuts(const wxChar *ws) +{ + int rc = wxFputs(ws, stdout); + if ( rc != -1 ) + { + if ( wxFputs(L"\n", stdout) == -1 ) + return -1; + + rc++; + } + + return rc; +} +#endif // wxNEED_PUTS + +#ifdef wxNEED_PUTC +int /* not wint_t */ wxPutc(wchar_t wc, FILE *stream) +{ + wchar_t ws[2] = { wc, L'\0' }; + + return wxFputs(ws, stream); +} +#endif // wxNEED_PUTC + +// NB: we only implement va_list functions here, the ones taking ... are +// defined below for wxNEED_PRINTF_CONVERSION case anyhow and we reuse +// the definitions there to avoid duplicating them here +#ifdef wxNEED_WPRINTF + +// TODO: implement the scanf() functions +int vwscanf(const wxChar *format, va_list argptr) +{ + wxFAIL_MSG( _T("TODO") ); + + return -1; +} + +int vswscanf(const wxChar *ws, const wxChar *format, va_list argptr) +{ + // The best we can do without proper Unicode support in glibc is to + // convert the strings into MB representation and run ANSI version + // of the function. This doesn't work with %c and %s because of difference + // in size of char and wchar_t, though. + + wxCHECK_MSG( wxStrstr(format, _T("%s")) == NULL, -1, + _T("incomplete vswscanf implementation doesn't allow %s") ); + wxCHECK_MSG( wxStrstr(format, _T("%c")) == NULL, -1, + _T("incomplete vswscanf implementation doesn't allow %c") ); + + va_list argcopy; + wxVaCopy(argcopy, argptr); + return vsscanf(wxConvLibc.cWX2MB(ws), wxConvLibc.cWX2MB(format), argcopy); +} + +int vfwscanf(FILE *stream, const wxChar *format, va_list argptr) +{ + wxFAIL_MSG( _T("TODO") ); + + return -1; +} + +#define vswprintf wxVsnprintf_ + +int vfwprintf(FILE *stream, const wxChar *format, va_list argptr) +{ + wxString s; + int rc = s.PrintfV(format, argptr); + + if ( rc != -1 ) + { + // we can't do much better without Unicode support in libc... + if ( fprintf(stream, "%s", (const char*)s.mb_str() ) == -1 ) + return -1; + } + + return rc; +} + +int vwprintf(const wxChar *format, va_list argptr) +{ + return wxVfprintf(stdout, format, argptr); +} + +#endif // wxNEED_WPRINTF + +#ifdef wxNEED_PRINTF_CONVERSION + +// ---------------------------------------------------------------------------- +// wxFormatConverter: class doing the "%s" -> "%ls" conversion +// ---------------------------------------------------------------------------- + +/* + Here are the gory details. We want to follow the Windows/MS conventions, + that is to have + + In ANSI mode: + + format specifier results in + ----------------------------------- + %c, %hc, %hC char + %lc, %C, %lC wchar_t + + In Unicode mode: + + format specifier results in + ----------------------------------- + %hc, %C, %hC char + %c, %lc, %lC wchar_t + + + while on POSIX systems we have %C identical to %lc and %c always means char + (in any mode) while %lc always means wchar_t, + + So to use native functions in order to get our semantics we must do the + following translations in Unicode mode (nothing to do in ANSI mode): + + wxWidgets specifier POSIX specifier + ---------------------------------------- + + %hc, %C, %hC %c + %c %lc + + + And, of course, the same should be done for %s as well. +*/ + +class wxFormatConverter +{ +public: + wxFormatConverter(const wxChar *format); + + // notice that we only translated the string if m_fmtOrig == NULL (as set + // by CopyAllBefore()), otherwise we should simply use the original format + operator const wxChar *() const + { return m_fmtOrig ? m_fmtOrig : m_fmt.c_str(); } + +private: + // copy another character to the translated format: this function does the + // copy if we are translating but doesn't do anything at all if we don't, + // so we don't create the translated format string at all unless we really + // need to (i.e. InsertFmtChar() is called) + wxChar CopyFmtChar(wxChar ch) + { + if ( !m_fmtOrig ) + { + // we're translating, do copy + m_fmt += ch; + } + else + { + // simply increase the count which should be copied by + // CopyAllBefore() later if needed + m_nCopied++; + } + + return ch; + } + + // insert an extra character + void InsertFmtChar(wxChar ch) + { + if ( m_fmtOrig ) + { + // so far we haven't translated anything yet + CopyAllBefore(); + } + + m_fmt += ch; + } + + void CopyAllBefore() + { + wxASSERT_MSG( m_fmtOrig && m_fmt.empty(), _T("logic error") ); + + m_fmt = wxString(m_fmtOrig, m_nCopied); + + // we won't need it any longer + m_fmtOrig = NULL; + } + + static bool IsFlagChar(wxChar ch) + { + return ch == _T('-') || ch == _T('+') || + ch == _T('0') || ch == _T(' ') || ch == _T('#'); + } + + void SkipDigits(const wxChar **ptpc) + { + while ( **ptpc >= _T('0') && **ptpc <= _T('9') ) + CopyFmtChar(*(*ptpc)++); + } + + // the translated format + wxString m_fmt; + + // the original format + const wxChar *m_fmtOrig; + + // the number of characters already copied + size_t m_nCopied; +}; + +wxFormatConverter::wxFormatConverter(const wxChar *format) +{ + m_fmtOrig = format; + m_nCopied = 0; + + while ( *format ) + { + if ( CopyFmtChar(*format++) == _T('%') ) + { + // skip any flags + while ( IsFlagChar(*format) ) + CopyFmtChar(*format++); + + // and possible width + if ( *format == _T('*') ) + CopyFmtChar(*format++); + else + SkipDigits(&format); + + // precision? + if ( *format == _T('.') ) + { + CopyFmtChar(*format++); + if ( *format == _T('*') ) + CopyFmtChar(*format++); + else + SkipDigits(&format); + } + + // next we can have a size modifier + enum + { + Default, + Short, + Long + } size; + + switch ( *format ) + { + case _T('h'): + size = Short; + format++; + break; + + case _T('l'): + // "ll" has a different meaning! + if ( format[1] != _T('l') ) + { + size = Long; + format++; + break; + } + //else: fall through + + default: + size = Default; + } + + // and finally we should have the type + switch ( *format ) + { + case _T('C'): + case _T('S'): + // %C and %hC -> %c and %lC -> %lc + if ( size == Long ) + CopyFmtChar(_T('l')); + + InsertFmtChar(*format++ == _T('C') ? _T('c') : _T('s')); + break; + + case _T('c'): + case _T('s'): + // %c -> %lc but %hc stays %hc and %lc is still %lc + if ( size == Default) + InsertFmtChar(_T('l')); + // fall through + + default: + // nothing special to do + if ( size != Default ) + CopyFmtChar(*(format - 1)); + CopyFmtChar(*format++); + } + } + } +} + +#else // !wxNEED_PRINTF_CONVERSION + // no conversion necessary + #define wxFormatConverter(x) (x) +#endif // wxNEED_PRINTF_CONVERSION/!wxNEED_PRINTF_CONVERSION + +#ifdef __WXDEBUG__ +// For testing the format converter +wxString wxConvertFormat(const wxChar *format) +{ + return wxString(wxFormatConverter(format)); +} +#endif + +// ---------------------------------------------------------------------------- +// wxPrintf(), wxScanf() and relatives +// ---------------------------------------------------------------------------- + +#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF) + +int wxScanf( const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + + int ret = vwscanf(wxFormatConverter(format), argptr ); + + va_end(argptr); + + return ret; +} + +int wxSscanf( const wxChar *str, const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + + int ret = vswscanf( str, wxFormatConverter(format), argptr ); + + va_end(argptr); + + return ret; +} + +int wxFscanf( FILE *stream, const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + int ret = vfwscanf(stream, wxFormatConverter(format), argptr); + + va_end(argptr); + + return ret; +} + +int wxPrintf( const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + + int ret = vwprintf( wxFormatConverter(format), argptr ); + + va_end(argptr); + + return ret; +} + +#ifndef wxSnprintf +int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + + int ret = vswprintf( str, size, wxFormatConverter(format), argptr ); + + // VsnprintfTestCase reveals that glibc's implementation of vswprintf + // doesn't nul terminate on truncation. + str[size - 1] = 0; + + va_end(argptr); + + return ret; +} +#endif // wxSnprintf + +int wxSprintf( wxChar *str, const wxChar *format, ... ) +{ + va_list argptr; + va_start(argptr, format); + + // note that wxString::FormatV() uses wxVsnprintf(), not wxSprintf(), so + // it's safe to implement this one in terms of it + wxString s(wxString::FormatV(format, argptr)); + wxStrcpy(str, s); + + va_end(argptr); + + return s.length(); +} + +int wxFprintf( FILE *stream, const wxChar *format, ... ) +{ + va_list argptr; + va_start( argptr, format ); + + int ret = vfwprintf( stream, wxFormatConverter(format), argptr ); + + va_end(argptr); + + return ret; +} + +int wxVsscanf( const wxChar *str, const wxChar *format, va_list argptr ) +{ + return vswscanf( str, wxFormatConverter(format), argptr ); +} + +int wxVfprintf( FILE *stream, const wxChar *format, va_list argptr ) +{ + return vfwprintf( stream, wxFormatConverter(format), argptr ); +} + +int wxVprintf( const wxChar *format, va_list argptr ) +{ + return vwprintf( wxFormatConverter(format), argptr ); +} + +#ifndef wxVsnprintf +int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list argptr ) +{ + return vswprintf( str, size, wxFormatConverter(format), argptr ); +} +#endif // wxVsnprintf + +int wxVsprintf( wxChar *str, const wxChar *format, va_list argptr ) +{ + // same as for wxSprintf() + return vswprintf(str, INT_MAX / 4, wxFormatConverter(format), argptr); +} + +#endif // wxNEED_PRINTF_CONVERSION + +#if wxUSE_WCHAR_T + +// ---------------------------------------------------------------------------- +// ctype.h stuff (currently unused) +// ---------------------------------------------------------------------------- + +#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H) +inline WORD wxMSW_ctype(wxChar ch) +{ + WORD ret; + GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, &ch, 1, &ret); + return ret; +} + +WXDLLEXPORT int wxIsalnum(wxChar ch) { return IsCharAlphaNumeric(ch); } +WXDLLEXPORT int wxIsalpha(wxChar ch) { return IsCharAlpha(ch); } +WXDLLEXPORT int wxIscntrl(wxChar ch) { return wxMSW_ctype(ch) & C1_CNTRL; } +WXDLLEXPORT int wxIsdigit(wxChar ch) { return wxMSW_ctype(ch) & C1_DIGIT; } +WXDLLEXPORT int wxIsgraph(wxChar ch) { return wxMSW_ctype(ch) & (C1_DIGIT|C1_PUNCT|C1_ALPHA); } +WXDLLEXPORT int wxIslower(wxChar ch) { return IsCharLower(ch); } +WXDLLEXPORT int wxIsprint(wxChar ch) { return wxMSW_ctype(ch) & (C1_DIGIT|C1_SPACE|C1_PUNCT|C1_ALPHA); } +WXDLLEXPORT int wxIspunct(wxChar ch) { return wxMSW_ctype(ch) & C1_PUNCT; } +WXDLLEXPORT int wxIsspace(wxChar ch) { return wxMSW_ctype(ch) & C1_SPACE; } +WXDLLEXPORT int wxIsupper(wxChar ch) { return IsCharUpper(ch); } +WXDLLEXPORT int wxIsxdigit(wxChar ch) { return wxMSW_ctype(ch) & C1_XDIGIT; } +WXDLLEXPORT int wxTolower(wxChar ch) { return (wxChar)CharLower((LPTSTR)(ch)); } +WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); } +#endif + +#ifdef wxNEED_WX_MBSTOWCS + +WXDLLEXPORT size_t wxMbstowcs (wchar_t * out, const char * in, size_t outlen) +{ + if (!out) + { + size_t outsize = 0; + while(*in++) + outsize++; + return outsize; + } + + const char* origin = in; + + while (outlen-- && *in) + { + *out++ = (wchar_t) *in++; + } + + *out = '\0'; + + return in - origin; +} + +WXDLLEXPORT size_t wxWcstombs (char * out, const wchar_t * in, size_t outlen) +{ + if (!out) + { + size_t outsize = 0; + while(*in++) + outsize++; + return outsize; + } + + const wchar_t* origin = in; + + while (outlen-- && *in) + { + *out++ = (char) *in++; + } + + *out = '\0'; + + return in - origin; +} + +#endif // wxNEED_WX_MBSTOWCS + +#if defined(wxNEED_WX_CTYPE_H) + +#include + +#define cfalnumset CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric) +#define cfalphaset CFCharacterSetGetPredefined(kCFCharacterSetLetter) +#define cfcntrlset CFCharacterSetGetPredefined(kCFCharacterSetControl) +#define cfdigitset CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit) +//CFCharacterSetRef cfgraphset = kCFCharacterSetControl && !' ' +#define cflowerset CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter) +//CFCharacterSetRef cfprintset = !kCFCharacterSetControl +#define cfpunctset CFCharacterSetGetPredefined(kCFCharacterSetPunctuation) +#define cfspaceset CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline) +#define cfupperset CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter) + +WXDLLEXPORT int wxIsalnum(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalnumset, ch); } +WXDLLEXPORT int wxIsalpha(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalphaset, ch); } +WXDLLEXPORT int wxIscntrl(wxChar ch) { return CFCharacterSetIsCharacterMember(cfcntrlset, ch); } +WXDLLEXPORT int wxIsdigit(wxChar ch) { return CFCharacterSetIsCharacterMember(cfdigitset, ch); } +WXDLLEXPORT int wxIsgraph(wxChar ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch) && ch != ' '; } +WXDLLEXPORT int wxIslower(wxChar ch) { return CFCharacterSetIsCharacterMember(cflowerset, ch); } +WXDLLEXPORT int wxIsprint(wxChar ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch); } +WXDLLEXPORT int wxIspunct(wxChar ch) { return CFCharacterSetIsCharacterMember(cfpunctset, ch); } +WXDLLEXPORT int wxIsspace(wxChar ch) { return CFCharacterSetIsCharacterMember(cfspaceset, ch); } +WXDLLEXPORT int wxIsupper(wxChar ch) { return CFCharacterSetIsCharacterMember(cfupperset, ch); } +WXDLLEXPORT int wxIsxdigit(wxChar ch) { return wxIsdigit(ch) || (ch>='a' && ch<='f') || (ch>='A' && ch<='F'); } +WXDLLEXPORT int wxTolower(wxChar ch) { return (wxChar)tolower((char)(ch)); } +WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)toupper((char)(ch)); } + +#endif // wxNEED_WX_CTYPE_H + +#ifndef wxStrdupA + +WXDLLEXPORT char *wxStrdupA(const char *s) +{ + return strcpy((char *)malloc(strlen(s) + 1), s); +} + +#endif // wxStrdupA + +#ifndef wxStrdupW + +WXDLLEXPORT wchar_t * wxStrdupW(const wchar_t *pwz) +{ + size_t size = (wxWcslen(pwz) + 1) * sizeof(wchar_t); + wchar_t *ret = (wchar_t *) malloc(size); + memcpy(ret, pwz, size); + return ret; +} + +#endif // wxStrdupW + +#ifndef wxStricmp +int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2) +{ + register wxChar c1, c2; + do { + c1 = wxTolower(*psz1++); + c2 = wxTolower(*psz2++); + } while ( c1 && (c1 == c2) ); + return c1 - c2; +} +#endif + +#ifndef wxStricmp +int WXDLLEXPORT wxStrnicmp(const wxChar *s1, const wxChar *s2, size_t n) +{ + // initialize the variables just to suppress stupid gcc warning + register wxChar c1 = 0, c2 = 0; + while (n && ((c1 = wxTolower(*s1)) == (c2 = wxTolower(*s2)) ) && c1) n--, s1++, s2++; + if (n) { + if (c1 < c2) return -1; + if (c1 > c2) return 1; + } + return 0; +} +#endif + +#ifndef wxSetlocale +WXDLLEXPORT wxWCharBuffer wxSetlocale(int category, const wxChar *locale) +{ + char *localeOld = setlocale(category, wxConvLibc.cWX2MB(locale)); + + return wxWCharBuffer(wxConvLibc.cMB2WC(localeOld)); +} +#endif + +#if wxUSE_WCHAR_T && !defined(HAVE_WCSLEN) +WXDLLEXPORT size_t wxWcslen(const wchar_t *s) +{ + size_t n = 0; + while ( *s++ ) + n++; + + return n; +} +#endif + +// ---------------------------------------------------------------------------- +// string.h functions +// ---------------------------------------------------------------------------- + +#ifdef wxNEED_WX_STRING_H + +// RN: These need to be c externed for the regex lib +#ifdef __cplusplus +extern "C" { +#endif + +WXDLLEXPORT wxChar * wxStrcat(wxChar *dest, const wxChar *src) +{ + wxChar *ret = dest; + while (*dest) dest++; + while ((*dest++ = *src++)); + return ret; +} + +WXDLLEXPORT const wxChar * wxStrchr(const wxChar *s, wxChar c) +{ + // be careful here as the terminating NUL makes part of the string + while ( *s != c ) + { + if ( !*s++ ) + return NULL; + } + + return s; +} + +WXDLLEXPORT int wxStrcmp(const wxChar *s1, const wxChar *s2) +{ + while ((*s1 == *s2) && *s1) s1++, s2++; + if ((wxUChar)*s1 < (wxUChar)*s2) return -1; + if ((wxUChar)*s1 > (wxUChar)*s2) return 1; + return 0; +} + +WXDLLEXPORT wxChar * wxStrcpy(wxChar *dest, const wxChar *src) +{ + wxChar *ret = dest; + while ((*dest++ = *src++)); + return ret; +} + +WXDLLEXPORT size_t wxStrlen_(const wxChar *s) +{ + size_t n = 0; + while ( *s++ ) + n++; + + return n; +} + + +WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n) +{ + wxChar *ret = dest; + while (*dest) dest++; + while (n && (*dest++ = *src++)) n--; + return ret; +} + +WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n) +{ + while (n && (*s1 == *s2) && *s1) n--, s1++, s2++; + if (n) { + if ((wxUChar)*s1 < (wxUChar)*s2) return -1; + if ((wxUChar)*s1 > (wxUChar)*s2) return 1; + } + return 0; +} + +WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n) +{ + wxChar *ret = dest; + while (n && (*dest++ = *src++)) n--; + while (n) *dest++=0, n--; // the docs specify padding with zeroes + return ret; +} + +WXDLLEXPORT const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept) +{ + while (*s && !wxStrchr(accept, *s)) + s++; + + return *s ? s : NULL; +} + +WXDLLEXPORT const wxChar * wxStrrchr(const wxChar *s, wxChar c) +{ + const wxChar *ret = NULL; + do + { + if ( *s == c ) + ret = s; + s++; + } + while ( *s ); + + return ret; +} + +WXDLLEXPORT size_t wxStrspn(const wxChar *s, const wxChar *accept) +{ + size_t len = 0; + while (wxStrchr(accept, *s++)) len++; + return len; +} + +WXDLLEXPORT const wxChar *wxStrstr(const wxChar *haystack, const wxChar *needle) +{ + wxASSERT_MSG( needle != NULL, _T("NULL argument in wxStrstr") ); + + // VZ: this is not exactly the most efficient string search algorithm... + + const size_t len = wxStrlen(needle); + + while ( const wxChar *fnd = wxStrchr(haystack, *needle) ) + { + if ( !wxStrncmp(fnd, needle, len) ) + return fnd; + + haystack = fnd + 1; + } + + return NULL; +} + +#ifdef __cplusplus +} +#endif + +WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr) +{ + const wxChar decSep( +#if wxUSE_INTL + wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER)[0] +#else + _T('.') +#endif + ); + const wxChar *start = nptr; + + while (wxIsspace(*nptr)) nptr++; + if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++; + while (wxIsdigit(*nptr)) nptr++; + if (*nptr == decSep) { + nptr++; + while (wxIsdigit(*nptr)) nptr++; + } + if (*nptr == wxT('E') || *nptr == wxT('e')) { + nptr++; + if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++; + while (wxIsdigit(*nptr)) nptr++; + } + + wxString data(start, nptr-start); + const wxWX2MBbuf dat = data.mb_str(wxConvLibc); + char *rdat = wxMBSTRINGCAST dat; + double ret = strtod(dat, &rdat); + + if (endptr) *endptr = (wxChar *)(start + (rdat - (const char *)dat)); + + return ret; +} + +WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base) +{ + const wxChar *start = nptr; + + while (wxIsspace(*nptr)) nptr++; + if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++; + if (((base == 0) || (base == 16)) && + (nptr[0] == wxT('0') && nptr[1] == wxT('x'))) { + nptr += 2; + base = 16; + } + else if ((base == 0) && (nptr[0] == wxT('0'))) base = 8; + else if (base == 0) base = 10; + + while ((wxIsdigit(*nptr) && (*nptr - wxT('0') < base)) || + (wxIsalpha(*nptr) && (wxToupper(*nptr) - wxT('A') + 10 < base))) nptr++; + + wxString data(start, nptr-start); + wxWX2MBbuf dat = data.mb_str(wxConvLibc); + char *rdat = wxMBSTRINGCAST dat; + long int ret = strtol(dat, &rdat, base); + + if (endptr) *endptr = (wxChar *)(start + (rdat - (const char *)dat)); + + return ret; +} + +WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base) +{ + return (unsigned long int) wxStrtol(nptr, endptr, base); +} + +#endif // wxNEED_WX_STRING_H + +#ifdef wxNEED_WX_STDIO_H +WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode) +{ + char mode_buffer[10]; + for (size_t i = 0; i < wxStrlen(mode)+1; i++) + mode_buffer[i] = (char) mode[i]; + + return fopen( wxConvFile.cWX2MB(path), mode_buffer ); +} + +WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream) +{ + char mode_buffer[10]; + for (size_t i = 0; i < wxStrlen(mode)+1; i++) + mode_buffer[i] = (char) mode[i]; + + return freopen( wxConvFile.cWX2MB(path), mode_buffer, stream ); +} + +WXDLLEXPORT int wxRemove(const wxChar *path) +{ + return remove( wxConvFile.cWX2MB(path) ); +} + +WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath) +{ + return rename( wxConvFile.cWX2MB(oldpath), wxConvFile.cWX2MB(newpath) ); +} +#endif + +#ifndef wxAtof +double WXDLLEXPORT wxAtof(const wxChar *psz) +{ +#ifdef __WXWINCE__ + double d; + wxString str(psz); + if (str.ToDouble(& d)) + return d; + + return 0.0; +#else + return atof(wxConvLibc.cWX2MB(psz)); +#endif +} +#endif + +#ifdef wxNEED_WX_STDLIB_H +int WXDLLEXPORT wxAtoi(const wxChar *psz) +{ + return atoi(wxConvLibc.cWX2MB(psz)); +} + +long WXDLLEXPORT wxAtol(const wxChar *psz) +{ + return atol(wxConvLibc.cWX2MB(psz)); +} + +wxChar * WXDLLEXPORT wxGetenv(const wxChar *name) +{ +#if wxUSE_UNICODE + // NB: buffer returned by getenv() is allowed to be overwritten next + // time getenv() is called, so it is OK to use static string + // buffer to hold the data. + static wxWCharBuffer value((wxChar*)NULL); + value = wxConvLibc.cMB2WX(getenv(wxConvLibc.cWX2MB(name))); + return value.data(); +#else + return getenv(name); +#endif +} +#endif // wxNEED_WX_STDLIB_H + +#ifdef wxNEED_WXSYSTEM +int WXDLLEXPORT wxSystem(const wxChar *psz) +{ + return system(wxConvLibc.cWX2MB(psz)); +} +#endif // wxNEED_WXSYSTEM + +#ifdef wxNEED_WX_TIME_H +WXDLLEXPORT size_t +wxStrftime(wxChar *s, size_t maxsize, const wxChar *fmt, const struct tm *tm) +{ + if ( !maxsize ) + return 0; + + wxCharBuffer buf(maxsize); + + wxCharBuffer bufFmt(wxConvLibc.cWX2MB(fmt)); + if ( !bufFmt ) + return 0; + + size_t ret = strftime(buf.data(), maxsize, bufFmt, tm); + if ( !ret ) + return 0; + + wxWCharBuffer wbuf = wxConvLibc.cMB2WX(buf); + if ( !wbuf ) + return 0; + + wxStrncpy(s, wbuf, maxsize); + return wxStrlen(s); +} +#endif // wxNEED_WX_TIME_H + +#ifndef wxCtime +WXDLLEXPORT wxChar *wxCtime(const time_t *timep) +{ + // normally the string is 26 chars but give one more in case some broken + // DOS compiler decides to use "\r\n" instead of "\n" at the end + static wxChar buf[27]; + + // ctime() is guaranteed to return a string containing only ASCII + // characters, as its format is always the same for any locale + wxStrncpy(buf, wxString::FromAscii(ctime(timep)), WXSIZEOF(buf)); + buf[WXSIZEOF(buf) - 1] = _T('\0'); + + return buf; +} +#endif // wxCtime + +#endif // wxUSE_WCHAR_T + +// ---------------------------------------------------------------------------- +// functions which we may need even if !wxUSE_WCHAR_T +// ---------------------------------------------------------------------------- + +#ifndef wxStrtok + +WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr) +{ + if (!psz) + { + psz = *save_ptr; + if ( !psz ) + return NULL; + } + + psz += wxStrspn(psz, delim); + if (!*psz) + { + *save_ptr = (wxChar *)NULL; + return (wxChar *)NULL; + } + + wxChar *ret = psz; + psz = wxStrpbrk(psz, delim); + if (!psz) + { + *save_ptr = (wxChar*)NULL; + } + else + { + *psz = wxT('\0'); + *save_ptr = psz + 1; + } + + return ret; +} + +#endif // wxStrtok + +// ---------------------------------------------------------------------------- +// missing C RTL functions +// ---------------------------------------------------------------------------- + +#ifdef wxNEED_STRDUP + +char *strdup(const char *s) +{ + char *dest = (char*) malloc( strlen( s ) + 1 ) ; + if ( dest ) + strcpy( dest , s ) ; + return dest ; +} +#endif // wxNEED_STRDUP + +#if defined(__WXWINCE__) && (_WIN32_WCE <= 211) + +void *calloc( size_t num, size_t size ) +{ + void** ptr = (void **)malloc(num * size); + memset( ptr, 0, num * size); + return ptr; +} + +#endif // __WXWINCE__ <= 211 + +#ifdef __WXWINCE__ + +int wxRemove(const wxChar *path) +{ + return ::DeleteFile(path) == 0; +} + +#endif diff --git a/Source/3rd Party/wx/src/common/wxcrt.cpp b/Source/3rd Party/wx/src/common/wxcrt.cpp deleted file mode 100644 index 29ecbaa55..000000000 --- a/Source/3rd Party/wx/src/common/wxcrt.cpp +++ /dev/null @@ -1,1296 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/wxcrt.cpp -// Purpose: wxChar CRT wrappers implementation -// Author: Ove Kaven -// Modified by: Ron Lee, Francesco Montorsi -// Created: 09/04/99 -// Copyright: (c) wxWidgets copyright -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// headers, declarations, constants -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/crt.h" -#include "wx/strconv.h" // wxMBConv::cWC2MB() - -#define _ISOC9X_SOURCE 1 // to get vsscanf() -#define _BSD_SOURCE 1 // to still get strdup() - -#include -#include -#include -#include - -#ifdef __SGI__ - // wide character functions are declared in std namespace under IRIX - using namespace std; - - // and this one is only declared if __c99 is defined which is not the case - // for C++ builds, so declare it ourselves - extern "C" int vswscanf(const wchar_t *, const wchar_t *, va_list); -#endif - -#ifndef __WXWINCE__ - #include - #include -#else - #include "wx/msw/wince/time.h" -#endif - -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/hash.h" - #include "wx/utils.h" // for wxMin and wxMax - #include "wx/log.h" -#endif - -#ifdef HAVE_LANGINFO_H - #include -#endif - -#ifdef __WXWINCE__ - // there is no errno.h under CE apparently - #define wxSET_ERRNO(value) -#else - #include - - #define wxSET_ERRNO(value) errno = value -#endif - -#if defined(__DARWIN__) - #include "wx/osx/core/cfref.h" - #include - #include "wx/osx/core/cfstring.h" - #include -#endif - -WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) -{ - // assume that we have mbsrtowcs() too if we have wcsrtombs() -#ifdef HAVE_WCSRTOMBS - mbstate_t mbstate; - memset(&mbstate, 0, sizeof(mbstate_t)); -#endif - - if (buf) { - if (!n || !*psz) { - if (n) *buf = wxT('\0'); - return 0; - } -#ifdef HAVE_WCSRTOMBS - return mbsrtowcs(buf, &psz, n, &mbstate); -#else - return mbstowcs(buf, psz, n); -#endif - } - - // Note that we rely on common (and required by Unix98 but unfortunately not - // C99) extension which allows to call mbs(r)towcs() with NULL output pointer - // to just get the size of the needed buffer -- this is needed as otherwise - // we have no idea about how much space we need. Currently all supported - // compilers do provide it and if they don't, HAVE_WCSRTOMBS shouldn't be - // defined at all. -#ifdef HAVE_WCSRTOMBS - return mbsrtowcs(NULL, &psz, 0, &mbstate); -#else - return mbstowcs(NULL, psz, 0); -#endif -} - -WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n) -{ -#ifdef HAVE_WCSRTOMBS - mbstate_t mbstate; - memset(&mbstate, 0, sizeof(mbstate_t)); -#endif - - if (buf) { - if (!n || !*pwz) { - // glibc2.1 chokes on null input - if (n) *buf = '\0'; - return 0; - } -#ifdef HAVE_WCSRTOMBS - return wcsrtombs(buf, &pwz, n, &mbstate); -#else - return wcstombs(buf, pwz, n); -#endif - } - -#ifdef HAVE_WCSRTOMBS - return wcsrtombs(NULL, &pwz, 0, &mbstate); -#else - return wcstombs(NULL, pwz, 0); -#endif -} - -char* wxSetlocale(int category, const char *locale) -{ -#ifdef __WXWINCE__ - // FIXME-CE: there is no setlocale() in CE CRT, use SetThreadLocale()? - wxUnusedVar(category); - wxUnusedVar(locale); - - return NULL; -#else // !__WXWINCE__ -#ifdef __WXMAC__ - char *rv = NULL ; - if ( locale != NULL && locale[0] == 0 ) - { - // the attempt to use newlocale(LC_ALL_MASK, "", NULL); - // here in order to deduce the language along the environment vars rules - // lead to strange crashes later... - - // we have to emulate the behaviour under OS X - wxCFRef userLocaleRef(CFLocaleCopyCurrent()); - wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode))); - wxString langFull = str.AsString()+"_"; - str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode))); - langFull += str.AsString(); - rv = setlocale(category, langFull.c_str()); - } - else - rv = setlocale(category, locale); -#else - char *rv = setlocale(category, locale); -#endif - if ( locale != NULL /* setting locale, not querying */ && - rv /* call was successful */ ) - { - wxUpdateLocaleIsUtf8(); - } - return rv; -#endif // __WXWINCE__/!__WXWINCE__ -} - -// ============================================================================ -// printf() functions business -// ============================================================================ - -// special test mode: define all functions below even if we don't really need -// them to be able to test them -#ifdef wxTEST_PRINTF - #undef wxFprintf - #undef wxPrintf - #undef wxSprintf - #undef wxVfprintf - #undef wxVsprintf - #undef wxVprintf - #undef wxVsnprintf_ - - #define wxNEED_WPRINTF - - int wxCRT_VfprintfW( FILE *stream, const wchar_t *format, va_list argptr ); -#endif - -#if defined(__DMC__) -/* Digital Mars adds count to _stprintf (C99) so convert */ -int wxCRT_SprintfW (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) -{ - va_list arglist; - - va_start( arglist, format ); - int iLen = swprintf ( s, -1, format, arglist ); - va_end( arglist ); - return iLen ; -} -#endif //__DMC__ - -// ---------------------------------------------------------------------------- -// implement the standard IO functions for wide char if libc doesn't have them -// ---------------------------------------------------------------------------- - -#ifndef wxCRT_FputsW -int wxCRT_FputsW(const wchar_t *ws, FILE *stream) -{ - wxCharBuffer buf(wxConvLibc.cWC2MB(ws)); - if ( !buf ) - return -1; - - // counting the number of wide characters written isn't worth the trouble, - // simply distinguish between ok and error - return wxCRT_FputsA(buf, stream) == -1 ? -1 : 0; -} -#endif // !wxCRT_FputsW - -#ifndef wxCRT_PutsW -int wxCRT_PutsW(const wchar_t *ws) -{ - int rc = wxCRT_FputsW(ws, stdout); - if ( rc != -1 ) - { - if ( wxCRT_FputsW(L"\n", stdout) == -1 ) - return -1; - - rc++; - } - - return rc; -} -#endif // !wxCRT_PutsW - -#ifndef wxCRT_FputcW -int /* not wint_t */ wxCRT_FputcW(wchar_t wc, FILE *stream) -{ - wchar_t ws[2] = { wc, L'\0' }; - - return wxCRT_FputsW(ws, stream); -} -#endif // !wxCRT_FputcW - -// NB: we only implement va_list functions here, the ones taking ... are -// defined below for wxNEED_PRINTF_CONVERSION case anyhow and we reuse -// the definitions there to avoid duplicating them here -#ifdef wxNEED_WPRINTF - -// TODO: implement the scanf() functions -static int vwscanf(const wchar_t *format, va_list argptr) -{ - wxFAIL_MSG( wxT("TODO") ); - - return -1; -} - -static int vfwscanf(FILE *stream, const wchar_t *format, va_list argptr) -{ - wxFAIL_MSG( wxT("TODO") ); - - return -1; -} - -#define vswprintf wxCRT_VsnprintfW - -static int vfwprintf(FILE *stream, const wchar_t *format, va_list argptr) -{ - wxString s; - int rc = s.PrintfV(format, argptr); - - if ( rc != -1 ) - { - // we can't do much better without Unicode support in libc... - if ( fprintf(stream, "%s", (const char*)s.mb_str() ) == -1 ) - return -1; - } - - return rc; -} - -static int vwprintf(const wchar_t *format, va_list argptr) -{ - return wxCRT_VfprintfW(stdout, format, argptr); -} - -#endif // wxNEED_WPRINTF - -#ifdef wxNEED_VSWSCANF -static int vswscanf(const wchar_t *ws, const wchar_t *format, va_list argptr) -{ - // The best we can do without proper Unicode support in glibc is to - // convert the strings into MB representation and run ANSI version - // of the function. This doesn't work with %c and %s because of difference - // in size of char and wchar_t, though. - - wxCHECK_MSG( wxStrstr(format, L"%s") == NULL, -1, - wxT("incomplete vswscanf implementation doesn't allow %s") ); - wxCHECK_MSG( wxStrstr(format, L"%c") == NULL, -1, - wxT("incomplete vswscanf implementation doesn't allow %c") ); - - return wxCRT_VsscanfA(static_cast(wxConvLibc.cWC2MB(ws)), - wxConvLibc.cWC2MB(format), argptr); -} -#endif - -// ---------------------------------------------------------------------------- -// wxPrintf(), wxScanf() and relatives -// ---------------------------------------------------------------------------- - -// FIXME-UTF8: do format conversion using (modified) wxFormatConverter in -// template wrappers, not here; note that it will needed to -// translate all forms of string specifiers to %(l)s for wxPrintf(), -// but it only should do what it did in 2.8 for wxScanf()! - -#ifndef wxCRT_PrintfW -int wxCRT_PrintfW( const wchar_t *format, ... ) -{ - va_list argptr; - va_start(argptr, format); - - int ret = vwprintf( format, argptr ); - - va_end(argptr); - - return ret; -} -#endif - -#ifndef wxCRT_FprintfW -int wxCRT_FprintfW( FILE *stream, const wchar_t *format, ... ) -{ - va_list argptr; - va_start( argptr, format ); - - int ret = vfwprintf( stream, format, argptr ); - - va_end(argptr); - - return ret; -} -#endif - -#ifndef wxCRT_VfprintfW -int wxCRT_VfprintfW( FILE *stream, const wchar_t *format, va_list argptr ) -{ - return vfwprintf( stream, format, argptr ); -} -#endif - -#ifndef wxCRT_VprintfW -int wxCRT_VprintfW( const wchar_t *format, va_list argptr ) -{ - return vwprintf( format, argptr ); -} -#endif - -#ifndef wxCRT_VsprintfW -int wxCRT_VsprintfW( wchar_t *str, const wchar_t *format, va_list argptr ) -{ - // same as for wxSprintf() - return vswprintf(str, INT_MAX / 4, format, argptr); -} -#endif - -#ifndef wxCRT_ScanfW -int wxCRT_ScanfW(const wchar_t *format, ...) -{ - va_list argptr; - va_start(argptr, format); - -#ifdef __VMS -#if (__DECCXX_VER >= 70100000) && !defined(__STD_CFRONT) && !defined( __NONAMESPACE_STD ) - int ret = std::vwscanf(format, argptr); -#else - int ret = vwscanf(format, argptr); -#endif -#else - int ret = vwscanf(format, argptr); -#endif - - va_end(argptr); - - return ret; -} -#endif - -#ifndef wxCRT_SscanfW -int wxCRT_SscanfW(const wchar_t *str, const wchar_t *format, ...) -{ - va_list argptr; - va_start(argptr, format); - -#ifdef __VMS -#if (__DECCXX_VER >= 70100000) && !defined(__STD_CFRONT) && !defined( __NONAMESPACE_STD ) - int ret = std::vswscanf(str, format, argptr); -#else - int ret = vswscanf(str, format, argptr); -#endif -#else - int ret = vswscanf(str, format, argptr); -#endif - - va_end(argptr); - - return ret; -} -#endif - -#ifndef wxCRT_FscanfW -int wxCRT_FscanfW(FILE *stream, const wchar_t *format, ...) -{ - va_list argptr; - va_start(argptr, format); -#ifdef __VMS -#if (__DECCXX_VER >= 70100000) && !defined(__STD_CFRONT) && !defined( __NONAMESPACE_STD ) - int ret = std::vfwscanf(stream, format, argptr); -#else - int ret = vfwscanf(stream, format, argptr); -#endif -#else - int ret = vfwscanf(stream, format, argptr); -#endif - - va_end(argptr); - - return ret; -} -#endif - -#ifndef wxCRT_VsscanfW -int wxCRT_VsscanfW(const wchar_t *str, const wchar_t *format, va_list argptr) -{ -#ifdef __VMS -#if (__DECCXX_VER >= 70100000) && !defined(__STD_CFRONT) && !defined( __NONAMESPACE_STD ) - return std::vswscanf(str, format, argptr); -#else - return vswscanf(str, format, argptr); -#endif -#else - return vswscanf(str, format, argptr); -#endif -} -#endif - - -// ---------------------------------------------------------------------------- -// wrappers to printf and scanf function families -// ---------------------------------------------------------------------------- - -#if !wxUSE_UTF8_LOCALE_ONLY -int wxDoSprintfWchar(char *str, const wxChar *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsprintf(str, format, argptr); - - va_end(argptr); - return rv; -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int wxDoSprintfUtf8(char *str, const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsprintf(str, format, argptr); - - va_end(argptr); - return rv; -} -#endif // wxUSE_UNICODE_UTF8 - -#if wxUSE_UNICODE - -#if !wxUSE_UTF8_LOCALE_ONLY -int wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsprintf(str, format, argptr); - - va_end(argptr); - return rv; -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int wxDoSprintfUtf8(wchar_t *str, const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsprintf(str, format, argptr); - - va_end(argptr); - return rv; -} -#endif // wxUSE_UNICODE_UTF8 - -#endif // wxUSE_UNICODE - -#if !wxUSE_UTF8_LOCALE_ONLY -int wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsnprintf(str, size, format, argptr); - - va_end(argptr); - return rv; -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int wxDoSnprintfUtf8(char *str, size_t size, const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsnprintf(str, size, format, argptr); - - va_end(argptr); - return rv; -} -#endif // wxUSE_UNICODE_UTF8 - -#if wxUSE_UNICODE - -#if !wxUSE_UTF8_LOCALE_ONLY -int wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsnprintf(str, size, format, argptr); - - va_end(argptr); - return rv; -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...) -{ - va_list argptr; - va_start(argptr, format); - - int rv = wxVsnprintf(str, size, format, argptr); - - va_end(argptr); - return rv; -} -#endif // wxUSE_UNICODE_UTF8 - -#endif // wxUSE_UNICODE - - -#ifdef HAVE_BROKEN_VSNPRINTF_DECL - #define vsnprintf wx_fixed_vsnprintf -#endif - -#if wxUSE_UNICODE - -namespace -{ - -#if !wxUSE_UTF8_LOCALE_ONLY -int ConvertStringToBuf(const wxString& s, char *out, size_t outsize) -{ - const wxCharBuffer buf(s.mb_str()); - - const size_t len = buf.length(); - if ( outsize > len ) - { - memcpy(out, buf, len+1); - } - else // not enough space - { - memcpy(out, buf, outsize-1); - out[outsize-1] = '\0'; - } - - return len; -} -#endif // !wxUSE_UTF8_LOCALE_ONLY - -#if wxUSE_UNICODE_UTF8 -int ConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize) -{ - const wxWX2WCbuf buf(s.wc_str()); - size_t len = s.length(); // same as buf length for wchar_t* - if ( outsize > len ) - { - memcpy(out, buf, (len+1) * sizeof(wchar_t)); - } - else // not enough space - { - memcpy(out, buf, (outsize-1) * sizeof(wchar_t)); - out[outsize-1] = 0; - } - return len; -} -#endif // wxUSE_UNICODE_UTF8 - -} // anonymous namespace - -template -static size_t PrintfViaString(T *out, size_t outsize, - const wxString& format, va_list argptr) -{ - wxString s; - s.PrintfV(format, argptr); - - return ConvertStringToBuf(s, out, outsize); -} -#endif // wxUSE_UNICODE - -int wxVsprintf(char *str, const wxString& format, va_list argptr) -{ -#if wxUSE_UTF8_LOCALE_ONLY - return wxCRT_VsprintfA(str, format.wx_str(), argptr); -#else - #if wxUSE_UNICODE_UTF8 - if ( wxLocaleIsUtf8 ) - return wxCRT_VsprintfA(str, format.wx_str(), argptr); - else - #endif - #if wxUSE_UNICODE - return PrintfViaString(str, wxNO_LEN, format, argptr); - #else - return wxCRT_VsprintfA(str, format.mb_str(), argptr); - #endif -#endif -} - -#if wxUSE_UNICODE -int wxVsprintf(wchar_t *str, const wxString& format, va_list argptr) -{ -#if wxUSE_UNICODE_WCHAR -#ifdef __DMC__ -/* -This fails with a bug similar to -http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=c++.beta&artnum=680 -in DMC 8.49 and 8.50 -I don't see it being used in the wxWidgets sources at present (oct 2007) CE -*/ -#pragma message ( "warning ::::: wxVsprintf(wchar_t *str, const wxString& format, va_list argptr) not yet implemented" ) - wxFAIL_MSG( wxT("TODO") ); - - return -1; -#else - return wxCRT_VsprintfW(str, format.wc_str(), argptr); -#endif //DMC -#else // wxUSE_UNICODE_UTF8 - #if !wxUSE_UTF8_LOCALE_ONLY - if ( !wxLocaleIsUtf8 ) - return wxCRT_VsprintfW(str, format.wc_str(), argptr); - else - #endif - return PrintfViaString(str, wxNO_LEN, format, argptr); -#endif // wxUSE_UNICODE_UTF8 -} -#endif // wxUSE_UNICODE - -int wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr) -{ - int rv; -#if wxUSE_UTF8_LOCALE_ONLY - rv = wxCRT_VsnprintfA(str, size, format.wx_str(), argptr); -#else - #if wxUSE_UNICODE_UTF8 - if ( wxLocaleIsUtf8 ) - rv = wxCRT_VsnprintfA(str, size, format.wx_str(), argptr); - else - #endif - #if wxUSE_UNICODE - { - // NB: if this code is called, then wxString::PrintV() would use the - // wchar_t* version of wxVsnprintf(), so it's safe to use PrintV() - // from here - rv = PrintfViaString(str, size, format, argptr); - } - #else - rv = wxCRT_VsnprintfA(str, size, format.mb_str(), argptr); - #endif -#endif - - // VsnprintfTestCase reveals that glibc's implementation of vswprintf - // doesn't nul terminate on truncation. - str[size - 1] = 0; - - return rv; -} - -#if wxUSE_UNICODE -int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr) -{ - int rv; - -#if wxUSE_UNICODE_WCHAR - rv = wxCRT_VsnprintfW(str, size, format.wc_str(), argptr); -#else // wxUSE_UNICODE_UTF8 - #if !wxUSE_UTF8_LOCALE_ONLY - if ( !wxLocaleIsUtf8 ) - rv = wxCRT_VsnprintfW(str, size, format.wc_str(), argptr); - else - #endif - { - // NB: if this code is called, then wxString::PrintV() would use the - // char* version of wxVsnprintf(), so it's safe to use PrintV() - // from here - rv = PrintfViaString(str, size, format, argptr); - } -#endif // wxUSE_UNICODE_UTF8 - - // VsnprintfTestCase reveals that glibc's implementation of vswprintf - // doesn't nul terminate on truncation. - str[size - 1] = 0; - - return rv; -} -#endif // wxUSE_UNICODE - - -// ---------------------------------------------------------------------------- -// ctype.h stuff (currently unused) -// ---------------------------------------------------------------------------- - -#ifndef wxCRT_StrdupA -WXDLLIMPEXP_BASE char *wxCRT_StrdupA(const char *s) -{ - return strcpy((char *)malloc(strlen(s) + 1), s); -} -#endif // wxCRT_StrdupA - -#ifndef wxCRT_StrdupW -WXDLLIMPEXP_BASE wchar_t * wxCRT_StrdupW(const wchar_t *pwz) -{ - size_t size = (wxWcslen(pwz) + 1) * sizeof(wchar_t); - wchar_t *ret = (wchar_t *) malloc(size); - memcpy(ret, pwz, size); - return ret; -} -#endif // wxCRT_StrdupW - -#ifndef wxWCHAR_T_IS_WXCHAR16 -size_t wxStrlen(const wxChar16 *s ) -{ - if (!s) return 0; - size_t i=0; - while (*s!=0) { ++i; ++s; }; - return i; -} - -wxChar16* wxStrdup(const wxChar16* s) -{ - size_t size = (wxStrlen(s) + 1) * sizeof(wxChar16); - wxChar16 *ret = (wxChar16*) malloc(size); - memcpy(ret, s, size); - return ret; -} -#endif - -#ifndef wxWCHAR_T_IS_WXCHAR32 -size_t wxStrlen(const wxChar32 *s ) -{ - if (!s) return 0; - size_t i=0; - while (*s!=0) { ++i; ++s; }; - return i; -} - -wxChar32* wxStrdup(const wxChar32* s) -{ - size_t size = (wxStrlen(s) + 1) * sizeof(wxChar32); - wxChar32 *ret = (wxChar32*) malloc(size); - if ( ret ) - memcpy(ret, s, size); - return ret; -} -#endif - -#ifndef wxCRT_StricmpA -WXDLLIMPEXP_BASE int wxCRT_StricmpA(const char *psz1, const char *psz2) -{ - char c1, c2; - do { - c1 = wxTolower(*psz1++); - c2 = wxTolower(*psz2++); - } while ( c1 && (c1 == c2) ); - return c1 - c2; -} -#endif // !defined(wxCRT_StricmpA) - -#ifndef wxCRT_StricmpW -WXDLLIMPEXP_BASE int wxCRT_StricmpW(const wchar_t *psz1, const wchar_t *psz2) -{ - wchar_t c1, c2; - do { - c1 = wxTolower(*psz1++); - c2 = wxTolower(*psz2++); - } while ( c1 && (c1 == c2) ); - return c1 - c2; -} -#endif // !defined(wxCRT_StricmpW) - -#ifndef wxCRT_StrnicmpA -WXDLLIMPEXP_BASE int wxCRT_StrnicmpA(const char *s1, const char *s2, size_t n) -{ - // initialize the variables just to suppress stupid gcc warning - char c1 = 0, c2 = 0; - while (n && ((c1 = wxTolower(*s1)) == (c2 = wxTolower(*s2)) ) && c1) n--, s1++, s2++; - if (n) { - if (c1 < c2) return -1; - if (c1 > c2) return 1; - } - return 0; -} -#endif // !defined(wxCRT_StrnicmpA) - -#ifndef wxCRT_StrnicmpW -WXDLLIMPEXP_BASE int wxCRT_StrnicmpW(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - // initialize the variables just to suppress stupid gcc warning - wchar_t c1 = 0, c2 = 0; - while (n && ((c1 = wxTolower(*s1)) == (c2 = wxTolower(*s2)) ) && c1) n--, s1++, s2++; - if (n) { - if (c1 < c2) return -1; - if (c1 > c2) return 1; - } - return 0; -} -#endif // !defined(wxCRT_StrnicmpW) - -// ---------------------------------------------------------------------------- -// string.h functions -// ---------------------------------------------------------------------------- - -// this (and wxCRT_StrncmpW below) are extern "C" because they are needed -// by regex code, the rest isn't needed, so it's not declared as extern "C" -#ifndef wxCRT_StrlenW -extern "C" WXDLLIMPEXP_BASE size_t wxCRT_StrlenW(const wchar_t *s) -{ - size_t n = 0; - while ( *s++ ) - n++; - - return n; -} -#endif - -// ---------------------------------------------------------------------------- -// stdlib.h functions -// ---------------------------------------------------------------------------- - -#ifndef wxCRT_GetenvW -WXDLLIMPEXP_BASE wchar_t* wxCRT_GetenvW(const wchar_t *name) -{ - // NB: buffer returned by getenv() is allowed to be overwritten next - // time getenv() is called, so it is OK to use static string - // buffer to hold the data. - static wxWCharBuffer value; - value = wxConvLibc.cMB2WC(getenv(wxConvLibc.cWC2MB(name))); - return value.data(); -} -#endif // !wxCRT_GetenvW - -#ifndef wxCRT_StrftimeW -WXDLLIMPEXP_BASE size_t -wxCRT_StrftimeW(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm *tm) -{ - if ( !maxsize ) - return 0; - - wxCharBuffer buf(maxsize); - - wxCharBuffer bufFmt(wxConvLibc.cWX2MB(fmt)); - if ( !bufFmt ) - return 0; - - size_t ret = strftime(buf.data(), maxsize, bufFmt, tm); - if ( !ret ) - return 0; - - wxWCharBuffer wbuf = wxConvLibc.cMB2WX(buf); - if ( !wbuf ) - return 0; - - wxCRT_StrncpyW(s, wbuf, maxsize); - return wxCRT_StrlenW(s); -} -#endif // !wxCRT_StrftimeW - -#ifdef wxLongLong_t -template -static wxULongLong_t -wxCRT_StrtoullBase(const T* nptr, T** endptr, int base, T* sign) -{ - wxULongLong_t sum = 0; - wxString wxstr(nptr); - wxString::const_iterator i = wxstr.begin(); - wxString::const_iterator end = wxstr.end(); - - // Skip spaces - while ( i != end && wxIsspace(*i) ) ++i; - - // Starts with sign? - *sign = wxT(' '); - if ( i != end ) - { - T c = *i; - if ( c == wxT('+') || c == wxT('-') ) - { - *sign = c; - ++i; - } - } - - // Starts with octal or hexadecimal prefix? - if ( i != end && *i == wxT('0') ) - { - ++i; - if ( i != end ) - { - if ( (*i == wxT('x')) || (*i == wxT('X')) ) - { - // Hexadecimal prefix: use base 16 if auto-detecting. - if ( base == 0 ) - base = 16; - - // If we do use base 16, just skip "x" as well. - if ( base == 16 ) - { - ++i; - } - else // Not using base 16 - { - // Then it's an error. - if ( endptr ) - *endptr = (T*) nptr; - wxSET_ERRNO(EINVAL); - return sum; - } - } - else if ( base == 0 ) - { - base = 8; - } - } - else - --i; - } - - if ( base == 0 ) - base = 10; - - for ( ; i != end; ++i ) - { - unsigned int n; - - T c = *i; - if ( c >= '0' ) - { - if ( c <= '9' ) - n = c - wxT('0'); - else - n = wxTolower(c) - wxT('a') + 10; - } - else - break; - - if ( n >= (unsigned int)base ) - // Invalid character (for this base) - break; - - wxULongLong_t prevsum = sum; - sum = (sum * base) + n; - - if ( sum < prevsum ) - { - wxSET_ERRNO(ERANGE); - break; - } - } - - if ( endptr ) - { - *endptr = (T*)(nptr + (i - wxstr.begin())); - } - - return sum; -} - -template -static wxULongLong_t wxCRT_DoStrtoull(const T* nptr, T** endptr, int base) -{ - T sign; - wxULongLong_t uval = ::wxCRT_StrtoullBase(nptr, endptr, base, &sign); - - if ( sign == wxT('-') ) - { - wxSET_ERRNO(ERANGE); - uval = 0; - } - - return uval; -} - -template -static wxLongLong_t wxCRT_DoStrtoll(const T* nptr, T** endptr, int base) -{ - T sign; - wxULongLong_t uval = ::wxCRT_StrtoullBase(nptr, endptr, base, &sign); - wxLongLong_t val = 0; - - if ( sign == wxT('-') ) - { - if (uval <= (wxULongLong_t)wxINT64_MAX + 1) - { - val = -(wxLongLong_t)uval; - } - else - { - wxSET_ERRNO(ERANGE); - } - } - else if ( uval <= wxINT64_MAX ) - { - val = uval; - } - else - { - wxSET_ERRNO(ERANGE); - } - - return val; -} - -#ifndef wxCRT_StrtollA -wxLongLong_t wxCRT_StrtollA(const char* nptr, char** endptr, int base) - { return wxCRT_DoStrtoll(nptr, endptr, base); } -#endif -#ifndef wxCRT_StrtollW -wxLongLong_t wxCRT_StrtollW(const wchar_t* nptr, wchar_t** endptr, int base) - { return wxCRT_DoStrtoll(nptr, endptr, base); } -#endif - -#ifndef wxCRT_StrtoullA -wxULongLong_t wxCRT_StrtoullA(const char* nptr, char** endptr, int base) - { return wxCRT_DoStrtoull(nptr, endptr, base); } -#endif -#ifndef wxCRT_StrtoullW -wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr, wchar_t** endptr, int base) - { return wxCRT_DoStrtoull(nptr, endptr, base); } -#endif - -#endif // wxLongLong_t - -// ---------------------------------------------------------------------------- -// strtok() functions -// ---------------------------------------------------------------------------- - -template -static T *wxCRT_DoStrtok(T *psz, const T *delim, T **save_ptr) -{ - if (!psz) - { - psz = *save_ptr; - if ( !psz ) - return NULL; - } - - psz += wxStrspn(psz, delim); - if (!*psz) - { - *save_ptr = NULL; - return NULL; - } - - T *ret = psz; - psz = wxStrpbrk(psz, delim); - if (!psz) - { - *save_ptr = NULL; - } - else - { - *psz = wxT('\0'); - *save_ptr = psz + 1; - } - - return ret; -} - -#ifndef wxCRT_StrtokA -char *wxCRT_StrtokA(char *psz, const char *delim, char **save_ptr) - { return wxCRT_DoStrtok(psz, delim, save_ptr); } -#endif -#ifndef wxCRT_StrtokW -wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wchar_t **save_ptr) - { return wxCRT_DoStrtok(psz, delim, save_ptr); } -#endif - -// ---------------------------------------------------------------------------- -// missing C RTL functions -// ---------------------------------------------------------------------------- - -#ifdef wxNEED_STRDUP - -char *strdup(const char *s) -{ - char *dest = (char*) malloc( strlen( s ) + 1 ) ; - if ( dest ) - strcpy( dest , s ) ; - return dest ; -} -#endif // wxNEED_STRDUP - -#if defined(__WXWINCE__) && (_WIN32_WCE <= 211) - -void *calloc( size_t num, size_t size ) -{ - void** ptr = (void **)malloc(num * size); - memset( ptr, 0, num * size); - return ptr; -} - -#endif // __WXWINCE__ <= 211 - -// ============================================================================ -// wxLocaleIsUtf8 -// ============================================================================ - -#if wxUSE_UNICODE_UTF8 - -#if !wxUSE_UTF8_LOCALE_ONLY -bool wxLocaleIsUtf8 = false; // the safer setting if not known -#endif - -static bool wxIsLocaleUtf8() -{ - // NB: we intentionally don't use wxLocale::GetSystemEncodingName(), - // because a) it may be unavailable in some builds and b) has slightly - // different semantics (default locale instead of current) - -#if defined(HAVE_LANGINFO_H) && defined(CODESET) - // GNU libc provides current character set this way (this conforms to - // Unix98) - const char *charset = nl_langinfo(CODESET); - if ( charset ) - { - // "UTF-8" is used by modern glibc versions, but test other variants - // as well, just in case: - if ( strcmp(charset, "UTF-8") == 0 || - strcmp(charset, "utf-8") == 0 || - strcmp(charset, "UTF8") == 0 || - strcmp(charset, "utf8") == 0 ) - { - return true; - } - } -#endif // HAVE_LANGINFO_H - - // check if we're running under the "C" locale: it is 7bit subset - // of UTF-8, so it can be safely used with the UTF-8 build: - const char *lc_ctype = setlocale(LC_CTYPE, NULL); - if ( lc_ctype && - (strcmp(lc_ctype, "C") == 0 || strcmp(lc_ctype, "POSIX") == 0) ) - { - return true; - } - - // we don't know what charset libc is using, so assume the worst - // to be safe: - return false; -} - -void wxUpdateLocaleIsUtf8() -{ -#if wxUSE_UTF8_LOCALE_ONLY - if ( !wxIsLocaleUtf8() ) - { - wxLogFatalError(wxT("This program requires UTF-8 locale to run.")); - } -#else // !wxUSE_UTF8_LOCALE_ONLY - wxLocaleIsUtf8 = wxIsLocaleUtf8(); -#endif -} - -#endif // wxUSE_UNICODE_UTF8 - -// ============================================================================ -// wx wrappers for CRT functions -// ============================================================================ - -#if wxUSE_UNICODE_WCHAR - #define CALL_ANSI_OR_UNICODE(return_kw, callA, callW) return_kw callW -#elif wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY - #define CALL_ANSI_OR_UNICODE(return_kw, callA, callW) \ - return_kw wxLocaleIsUtf8 ? callA : callW -#else // ANSI or UTF8 only - #define CALL_ANSI_OR_UNICODE(return_kw, callA, callW) return_kw callA -#endif - -int wxPuts(const wxString& s) -{ - // under IRIX putws() takes a non-const argument so use wchar_str() instead - // of wc_str() - CALL_ANSI_OR_UNICODE(return, - wxCRT_PutsA(s.mb_str()), - wxCRT_PutsW(s.wchar_str())); -} - -int wxFputs(const wxString& s, FILE *stream) -{ - CALL_ANSI_OR_UNICODE(return, - wxCRT_FputsA(s.mb_str(), stream), - wxCRT_FputsW(s.wc_str(), stream)); -} - -int wxFputc(const wxUniChar& c, FILE *stream) -{ -#if !wxUSE_UNICODE // FIXME-UTF8: temporary, remove this with ANSI build - return wxCRT_FputcA((char)c, stream); -#else - CALL_ANSI_OR_UNICODE(return, - wxCRT_FputsA(c.AsUTF8(), stream), - wxCRT_FputcW((wchar_t)c, stream)); -#endif -} - -#ifdef wxCRT_PerrorA - -void wxPerror(const wxString& s) -{ -#ifdef wxCRT_PerrorW - CALL_ANSI_OR_UNICODE(wxEMPTY_PARAMETER_VALUE, - wxCRT_PerrorA(s.mb_str()), - wxCRT_PerrorW(s.wc_str())); -#else - wxCRT_PerrorA(s.mb_str()); -#endif -} - -#endif // wxCRT_PerrorA - -wchar_t *wxFgets(wchar_t *s, int size, FILE *stream) -{ - wxCHECK_MSG( s, NULL, "empty buffer passed to wxFgets()" ); - - wxCharBuffer buf(size - 1); - // FIXME: this reads too little data if wxConvLibc uses UTF-8 ('size' wide - // characters may be encoded by up to 'size'*4 bytes), but what - // else can we do? - if ( wxFgets(buf.data(), size, stream) == NULL ) - return NULL; - - if ( wxConvLibc.ToWChar(s, size, buf, wxNO_LEN) == wxCONV_FAILED ) - return NULL; - - return s; -} - -// ---------------------------------------------------------------------------- -// wxScanf() and friends -// ---------------------------------------------------------------------------- - -#ifdef HAVE_VSSCANF // __VISUALC__ and __DMC__ see wx/crt.h -int wxVsscanf(const char *str, const char *format, va_list ap) - { return wxCRT_VsscanfA(str, format, ap); } -int wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap) - { return wxCRT_VsscanfW(str, format, ap); } -int wxVsscanf(const wxCharBuffer& str, const char *format, va_list ap) - { return wxCRT_VsscanfA(static_cast(str), format, ap); } -int wxVsscanf(const wxWCharBuffer& str, const wchar_t *format, va_list ap) - { return wxCRT_VsscanfW(str, format, ap); } -int wxVsscanf(const wxString& str, const char *format, va_list ap) - { return wxCRT_VsscanfA(static_cast(str.mb_str()), format, ap); } -int wxVsscanf(const wxString& str, const wchar_t *format, va_list ap) - { return wxCRT_VsscanfW(str.wc_str(), format, ap); } -int wxVsscanf(const wxCStrData& str, const char *format, va_list ap) - { return wxCRT_VsscanfA(static_cast(str.AsCharBuf()), format, ap); } -int wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap) - { return wxCRT_VsscanfW(str.AsWCharBuf(), format, ap); } -#endif // HAVE_NO_VSSCANF diff --git a/Source/3rd Party/wx/src/common/wxprintf.cpp b/Source/3rd Party/wx/src/common/wxprintf.cpp deleted file mode 100644 index 69cb20cba..000000000 --- a/Source/3rd Party/wx/src/common/wxprintf.cpp +++ /dev/null @@ -1,248 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/wxprintf.cpp -// Purpose: wxWidgets wxPrintf() implementation -// Author: Ove Kaven -// Modified by: Ron Lee, Francesco Montorsi -// Created: 09/04/99 -// Copyright: (c) wxWidgets copyright -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// headers, declarations, constants -// =========================================================================== - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/hash.h" - #include "wx/utils.h" // for wxMin and wxMax - #include "wx/log.h" -#endif - -#include "wx/private/wxprintf.h" - - -// ============================================================================ -// printf() implementation -// ============================================================================ - -// special test mode: define all functions below even if we don't really need -// them to be able to test them -#ifdef wxTEST_PRINTF - #undef wxCRT_VsnprintfW - #undef wxCRT_VsnprintfA -#endif - -// ---------------------------------------------------------------------------- -// implement [v]snprintf() if the system doesn't provide a safe one -// or if the system's one does not support positional parameters -// (very useful for i18n purposes) -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// common code for both ANSI and Unicode versions -// ---------------------------------------------------------------------------- - -#if !defined(wxCRT_VsnprintfW) || !defined(wxCRT_VsnprintfA) - - -// Copy chars from source to dest converting '%%' to '%'. Takes at most maxIn -// chars from source and write at most outMax chars to dest, returns the -// number of chars actually written. Does not treat null specially. -template -static int wxCopyStrWithPercents( - size_t maxOut, - CharType *dest, - size_t maxIn, - const CharType *source) -{ - size_t written = 0; - - if (maxIn == 0) - return 0; - - size_t i; - for ( i = 0; i < maxIn-1 && written < maxOut; source++, i++) - { - dest[written++] = *source; - if (*(source+1) == wxT('%')) - { - // skip this additional '%' character - source++; - i++; - } - } - - if (i < maxIn && written < maxOut) - // copy last character inconditionally - dest[written++] = *source; - - return written; -} - -template -static int wxDoVsnprintf(CharType *buf, size_t lenMax, - const CharType *format, va_list argptr) -{ - // useful for debugging, to understand if we are really using this function - // rather than the system implementation -#if 0 - wprintf(L"Using wxCRT_VsnprintfW\n"); -#endif - - wxPrintfConvSpecParser parser(format); - - wxPrintfArg argdata[wxMAX_SVNPRINTF_ARGUMENTS]; - - size_t i; - - // number of characters in the buffer so far, must be less than lenMax - size_t lenCur = 0; - - if (parser.posarg_present && parser.nonposarg_present) - { - buf[0] = 0; - return -1; // format strings with both positional and - } // non-positional conversion specifier are unsupported !! - - // on platforms where va_list is an array type, it is necessary to make a - // copy to be able to pass it to LoadArg as a reference. - bool ok = true; - va_list ap; - wxVaCopy(ap, argptr); - - // now load arguments from stack - for (i=0; i < parser.nargs && ok; i++) - { - // !pspec[i] means that the user forgot a positional parameter (e.g. %$1s %$3s); - // LoadArg == false means that wxPrintfConvSpec::Parse failed to set the - // conversion specifier 'type' to a valid value... - ok = parser.pspec[i] && parser.pspec[i]->LoadArg(&argdata[i], ap); - } - - va_end(ap); - - // something failed while loading arguments from the variable list... - // (e.g. the user repeated twice the same positional argument) - if (!ok) - { - buf[0] = 0; - return -1; - } - - // finally, process each conversion specifier with its own argument - const CharType *toparse = format; - for (i=0; i < parser.nargs; i++) - { - wxPrintfConvSpec& spec = parser.specs[i]; - - // skip any asterisks, they're processed as part of the conversion they - // apply to - if ( spec.m_type == wxPAT_STAR ) - continue; - - // copy in the output buffer the portion of the format string between - // last specifier and the current one - size_t tocopy = ( spec.m_pArgPos - toparse ); - - lenCur += wxCopyStrWithPercents(lenMax - lenCur, buf + lenCur, - tocopy, toparse); - if (lenCur == lenMax) - { - buf[lenMax - 1] = 0; - return lenMax+1; // not enough space in the output buffer ! - } - - // process this specifier directly in the output buffer - int n = spec.Process(buf+lenCur, lenMax - lenCur, - &argdata[spec.m_pos], lenCur); - if (n == -1) - { - buf[lenMax-1] = wxT('\0'); // be sure to always NUL-terminate the string - return lenMax+1; // not enough space in the output buffer ! - } - lenCur += n; - - // the +1 is because wxPrintfConvSpec::m_pArgEnd points to the last character - // of the format specifier, but we are not interested to it... - toparse = spec.m_pArgEnd + 1; - } - - // copy portion of the format string after last specifier - // NOTE: toparse is pointing to the character just after the last processed - // conversion specifier - // NOTE2: the +1 is because we want to copy also the '\0' - size_t tocopy = wxStrlen(format) + 1 - ( toparse - format ) ; - - lenCur += wxCopyStrWithPercents(lenMax - lenCur, buf + lenCur, - tocopy, toparse) - 1; - if (buf[lenCur]) - { - buf[lenCur] = 0; - return lenMax+1; // not enough space in the output buffer ! - } - - // Don't do: - // wxASSERT(lenCur == wxStrlen(buf)); - // in fact if we embedded NULLs in the output buffer (using %c with a '\0') - // such check would fail - - return lenCur; -} - -#endif // !defined(wxCRT_VsnprintfW) || !defined(wxCRT_VsnprintfA) - -// ---------------------------------------------------------------------------- -// wxCRT_VsnprintfW -// ---------------------------------------------------------------------------- - -#if !defined(wxCRT_VsnprintfW) - -#if !wxUSE_WXVSNPRINTFW - #error "wxUSE_WXVSNPRINTFW must be 1 if our wxCRT_VsnprintfW is used" -#endif - -int wxCRT_VsnprintfW(wchar_t *buf, size_t len, - const wchar_t *format, va_list argptr) -{ - return wxDoVsnprintf(buf, len, format, argptr); -} - -#else // wxCRT_VsnprintfW is defined - -#if wxUSE_WXVSNPRINTFW - #error "wxUSE_WXVSNPRINTFW must be 0 if our wxCRT_VsnprintfW is not used" -#endif - -#endif // !wxCRT_VsnprintfW - -// ---------------------------------------------------------------------------- -// wxCRT_VsnprintfA -// ---------------------------------------------------------------------------- - -#ifndef wxCRT_VsnprintfA - -#if !wxUSE_WXVSNPRINTFA - #error "wxUSE_WXVSNPRINTFA must be 1 if our wxCRT_VsnprintfA is used" -#endif - -int wxCRT_VsnprintfA(char *buf, size_t len, - const char *format, va_list argptr) -{ - return wxDoVsnprintf(buf, len, format, argptr); -} - -#else // wxCRT_VsnprintfA is defined - -#if wxUSE_WXVSNPRINTFA - #error "wxUSE_WXVSNPRINTFA must be 0 if our wxCRT_VsnprintfA is not used" -#endif - -#endif // !wxCRT_VsnprintfA diff --git a/Source/3rd Party/wx/src/common/xlocale.cpp b/Source/3rd Party/wx/src/common/xlocale.cpp deleted file mode 100644 index 26ac4df2a..000000000 --- a/Source/3rd Party/wx/src/common/xlocale.cpp +++ /dev/null @@ -1,370 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Name: src/common/xlocale.cpp -// Purpose: xlocale wrappers/impl to provide some xlocale wrappers -// Author: Brian Vanderburg II, Vadim Zeitlin -// Created: 2008-01-07 -// Copyright: (c) 2008 Brian Vanderburg II -// 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XLOCALE - -#ifndef WX_PRECOMP - #include "wx/module.h" -#endif - -#include "wx/xlocale.h" - -#include -#include - -// ---------------------------------------------------------------------------- -// module globals -// ---------------------------------------------------------------------------- - -// This is the C locale object, it is created on demand -static wxXLocale *gs_cLocale = NULL; - -wxXLocale wxNullXLocale; - - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Module for gs_cLocale cleanup -// ---------------------------------------------------------------------------- - -class wxXLocaleModule : public wxModule -{ -public: - virtual bool OnInit() { return true; } - virtual void OnExit() { wxDELETE(gs_cLocale); } - - DECLARE_DYNAMIC_CLASS(wxXLocaleModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxXLocaleModule, wxModule) - - -// ============================================================================ -// wxXLocale implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// common parts -// ---------------------------------------------------------------------------- - -// Get the C locale -wxXLocale& wxXLocale::GetCLocale() -{ - if ( !gs_cLocale ) - { - // Notice that we need a separate variable because clang 3.1 refuses to - // cast nullptr (which is how NULL is defined in it) to anything. - static wxXLocaleCTag* const tag = NULL; - gs_cLocale = new wxXLocale(tag); - } - - return *gs_cLocale; -} - -#ifdef wxHAS_XLOCALE_SUPPORT - -wxXLocale::wxXLocale(wxLanguage lang) -{ - const wxLanguageInfo * const info = wxLocale::GetLanguageInfo(lang); - if ( !info ) - { - m_locale = NULL; - } - else - { - Init(info->GetLocaleName().c_str()); - } -} - -#if wxCHECK_VISUALC_VERSION(8) - -// ---------------------------------------------------------------------------- -// implementation using MSVC locale API -// ---------------------------------------------------------------------------- - -void wxXLocale::Init(const char *loc) -{ - if (!loc || *loc == '\0') - return; - - m_locale = _create_locale(LC_ALL, loc); -} - -void wxXLocale::Free() -{ - if ( m_locale ) - _free_locale(m_locale); -} - -#elif defined(HAVE_LOCALE_T) - -// ---------------------------------------------------------------------------- -// implementation using xlocale API -// ---------------------------------------------------------------------------- - -void wxXLocale::Init(const char *loc) -{ - if (!loc || *loc == '\0') - return; - - m_locale = newlocale(LC_ALL_MASK, loc, NULL); - if (!m_locale) - { - // NOTE: here we do something similar to what wxSetLocaleTryUTF8() does - // in wxLocale code (but with newlocale() calls instead of wxSetlocale()) - wxString buf(loc); - wxString buf2; - buf2 = buf + wxS(".UTF-8"); - m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL); - if ( !m_locale ) - { - buf2 = buf + wxS(".utf-8"); - m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL); - } - if ( !m_locale ) - { - buf2 = buf + wxS(".UTF8"); - m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL); - } - if ( !m_locale ) - { - buf2 = buf + wxS(".utf8"); - m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL); - } - } - - // TODO: wxLocale performs many more manipulations of the given locale - // string in the attempt to set a valid locale; reusing that code - // (changing it to take a generic wxTryLocale callback) would be nice -} - -void wxXLocale::Free() -{ - if ( m_locale ) - freelocale(m_locale); -} - -#else - #error "Unknown xlocale support." -#endif - -#endif // wxHAS_XLOCALE_SUPPORT - -#ifndef wxHAS_XLOCALE_SUPPORT - -// ============================================================================ -// Implementation of wxFoo_l() functions for "C" locale without xlocale support -// ============================================================================ - -// ---------------------------------------------------------------------------- -// character classification and transformation functions -// ---------------------------------------------------------------------------- - -// lookup table and macros for character type functions -#define CTYPE_ALNUM 0x0001 -#define CTYPE_ALPHA 0x0002 -#define CTYPE_CNTRL 0x0004 -#define CTYPE_DIGIT 0x0008 -#define CTYPE_GRAPH 0x0010 -#define CTYPE_LOWER 0x0020 -#define CTYPE_PRINT 0x0040 -#define CTYPE_PUNCT 0x0080 -#define CTYPE_SPACE 0x0100 -#define CTYPE_UPPER 0x0200 -#define CTYPE_XDIGIT 0x0400 - -static const unsigned int gs_lookup[] = -{ - 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0004, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0004, 0x0004, - 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0140, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, - 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, - 0x0459, 0x0459, 0x0459, 0x0459, 0x0459, 0x0459, 0x0459, 0x0459, - 0x0459, 0x0459, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, - 0x00D0, 0x0653, 0x0653, 0x0653, 0x0653, 0x0653, 0x0653, 0x0253, - 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, - 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, - 0x0253, 0x0253, 0x0253, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x00D0, - 0x00D0, 0x0473, 0x0473, 0x0473, 0x0473, 0x0473, 0x0473, 0x0073, - 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, - 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, 0x0073, - 0x0073, 0x0073, 0x0073, 0x00D0, 0x00D0, 0x00D0, 0x00D0, 0x0004 -}; - - -#define CTYPE_TEST(c, t) ( (c) <= 127 && (gs_lookup[(c)] & (t)) ) - - -// ctype functions -#define GEN_ISFUNC(name, test) \ -int name(const wxUniChar& c, const wxXLocale& loc) \ -{ \ - wxCHECK(loc.IsOk(), false); \ - return CTYPE_TEST(c.GetValue(), test); \ -} - -GEN_ISFUNC(wxIsalnum_l, CTYPE_ALNUM) -GEN_ISFUNC(wxIsalpha_l, CTYPE_ALPHA) -GEN_ISFUNC(wxIscntrl_l, CTYPE_CNTRL) -GEN_ISFUNC(wxIsdigit_l, CTYPE_DIGIT) -GEN_ISFUNC(wxIsgraph_l, CTYPE_GRAPH) -GEN_ISFUNC(wxIslower_l, CTYPE_LOWER) -GEN_ISFUNC(wxIsprint_l, CTYPE_PRINT) -GEN_ISFUNC(wxIspunct_l, CTYPE_PUNCT) -GEN_ISFUNC(wxIsspace_l, CTYPE_SPACE) -GEN_ISFUNC(wxIsupper_l, CTYPE_UPPER) -GEN_ISFUNC(wxIsxdigit_l, CTYPE_XDIGIT) - -int wxTolower_l(const wxUniChar& c, const wxXLocale& loc) -{ - wxCHECK(loc.IsOk(), false); - - if(CTYPE_TEST(c.GetValue(), CTYPE_UPPER)) - { - return c - 'A' + 'a'; - } - - return c; -} - -int wxToupper_l(const wxUniChar& c, const wxXLocale& loc) -{ - wxCHECK(loc.IsOk(), false); - - if(CTYPE_TEST(c.GetValue(), CTYPE_LOWER)) - { - return c - 'a' + 'A'; - } - - return c; -} - - -// ---------------------------------------------------------------------------- -// string --> number conversion functions -// ---------------------------------------------------------------------------- - -/* - WARNING: the implementation of the wxStrtoX_l() functions below is unsafe - in a multi-threaded environment as we temporary change the locale - and if in the meanwhile an other thread performs some locale-dependent - operation, it may get unexpected results... - However this is the best we can do without reinventing the wheel in the - case !wxHAS_XLOCALE_SUPPORT... -*/ - -namespace -{ - -// Helper class that changes LC_NUMERIC facet of the global locale in its ctor -// to "C" locale and restores it in its dtor later. -class CNumericLocaleSetter -{ -public: - CNumericLocaleSetter() - : m_oldLocale(wxStrdupA(setlocale(LC_NUMERIC, NULL))) - { - if ( !wxSetlocale(LC_NUMERIC, "C") ) - { - // Setting locale to "C" should really always work. - wxFAIL_MSG( wxS("Couldn't set LC_NUMERIC to \"C\"") ); - } - } - - ~CNumericLocaleSetter() - { - wxSetlocale(LC_NUMERIC, m_oldLocale); - free(m_oldLocale); - } - -private: - char * const m_oldLocale; - - wxDECLARE_NO_COPY_CLASS(CNumericLocaleSetter); -}; - -} // anonymous namespace - -double wxStrtod_l(const wchar_t* str, wchar_t **endptr, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0. ); - - CNumericLocaleSetter locSetter; - - return wxStrtod(str, endptr); -} - -double wxStrtod_l(const char* str, char **endptr, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0. ); - - CNumericLocaleSetter locSetter; - - return wxStrtod(str, endptr); -} - -long wxStrtol_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0 ); - - CNumericLocaleSetter locSetter; - - return wxStrtol(str, endptr, base); -} - -long wxStrtol_l(const char* str, char **endptr, int base, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0 ); - - CNumericLocaleSetter locSetter; - - return wxStrtol(str, endptr, base); -} - -unsigned long wxStrtoul_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0 ); - - CNumericLocaleSetter locSetter; - - return wxStrtoul(str, endptr, base); -} - -unsigned long wxStrtoul_l(const char* str, char **endptr, int base, const wxXLocale& loc) -{ - wxCHECK( loc.IsOk(), 0 ); - - CNumericLocaleSetter locSetter; - - return wxStrtoul(str, endptr, base); -} - -#endif // !defined(wxHAS_XLOCALE_SUPPORT) - -#endif // wxUSE_XLOCALE diff --git a/Source/3rd Party/wx/src/common/xpmdecod.cpp b/Source/3rd Party/wx/src/common/xpmdecod.cpp index f76418958..3b01094c6 100644 --- a/Source/3rd Party/wx/src/common/xpmdecod.cpp +++ b/Source/3rd Party/wx/src/common/xpmdecod.cpp @@ -2,6 +2,7 @@ // Name: src/common/xpmdecod.cpp // Purpose: wxXPMDecoder // Author: John Cristy, Vaclav Slavik +// RCS-ID: $Id: xpmdecod.cpp 54948 2008-08-03 10:54:33Z VZ $ // Copyright: (c) John Cristy, Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -121,6 +122,8 @@ bool wxXPMDecoder::CanRead(wxInputStream& stream) if ( !stream.Read(buf, WXSIZEOF(buf)) ) return false; + stream.SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); + return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0; } @@ -263,7 +266,7 @@ typedef struct #define myRGB(r,g,b) ((wxUint32)r<<16|(wxUint32)g<<8|(wxUint32)b) -static const rgbRecord theRGBRecords[] = +static rgbRecord theRGBRecords[] = { {"aliceblue", myRGB(240, 248, 255)}, {"antiquewhite", myRGB(250, 235, 215)}, @@ -502,7 +505,7 @@ static const rgbRecord theRGBRecords[] = {"yellowgreen", myRGB(50, 216, 56)}, {NULL, myRGB(0, 0, 0)} }; -static const int numTheRGBRecords = 235; +static int numTheRGBRecords = 235; static unsigned char ParseHexadecimal(char digit1, char digit2) { @@ -617,7 +620,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone, static const char *ParseColor(const char *data) { - static const char *const targets[] = + static const char *targets[] = {"c ", "g ", "g4 ", "m ", "b ", "s ", NULL}; const char *p, *r; @@ -662,12 +665,12 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) int count; unsigned width, height, colors_cnt, chars_per_pixel; size_t i, j, i_key; - char key[64]; + wxChar key[64]; const char *clr_def; + bool hasMask; wxXPMColourMap clr_tbl; wxXPMColourMap::iterator it; wxString maskKey; - wxString keyString; /* * Read hints and initialize structures: @@ -686,10 +689,12 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) // 8bit RGB... wxCHECK_MSG(chars_per_pixel < 64, wxNullImage, wxT("XPM colormaps this large not supported.")); - if (!img.Create(width, height, false)) + if ( !img.Create(width, height) ) return wxNullImage; - key[chars_per_pixel] = '\0'; + img.SetMask(false); + key[chars_per_pixel] = wxT('\0'); + hasMask = false; /* * Create colour map: @@ -708,7 +713,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) } for (i_key = 0; i_key < chars_per_pixel; i_key++) - key[i_key] = xmpColLine[i_key]; + key[i_key] = (wxChar)xmpColLine[i_key]; clr_def = ParseColor(xmpColLine + chars_per_pixel); if ( clr_def == NULL ) @@ -727,41 +732,36 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) return wxNullImage; } - keyString = key; if ( isNone ) - maskKey = keyString; + { + img.SetMask(true); + img.SetMaskColour(255, 0, 255); + clr_data.R = + clr_data.B = 255; + clr_data.G = 0; + hasMask = true; + maskKey = key; + } - clr_tbl[keyString] = clr_data; + clr_tbl[key] = clr_data; } - // deal with the mask: we must replace pseudo-colour "None" with the mask - // colour (which can be any colour not otherwise used in the image) - if (!maskKey.empty()) + /* + * Modify colour entries with RGB = (255,0,255) to (255,0,254) if + * mask colour is present (so that existing pixels with (255,0,255) + * magenta colour are not incorrectly made transparent): + */ + if (hasMask) { - wxLongToLongHashMap rgb_table; - long rgb; - const size_t n = clr_tbl.size(); - wxXPMColourMap::const_iterator iter = clr_tbl.begin(); - for (i = 0; i < n; ++i, ++iter) + for (it = clr_tbl.begin(); it != clr_tbl.end(); ++it) { - const wxXPMColourMapData& data = iter->second; - rgb = (data.R << 16) + (data.G << 8) + data.B; - rgb_table[rgb]; + if (it->second.R == 255 && it->second.G == 0 && + it->second.B == 255 && + it->first != maskKey) + { + it->second.B = 254; + } } - for (rgb = 0; rgb <= 0xffffff && rgb_table.count(rgb); ++rgb) - ; - if (rgb > 0xffffff) - { - wxLogError(_("XPM: no colors left to use for mask!")); - return wxNullImage; - } - - wxXPMColourMapData& maskData = clr_tbl[maskKey]; - maskData.R = wxByte(rgb >> 16); - maskData.G = wxByte(rgb >> 8); - maskData.B = wxByte(rgb); - - img.SetMaskColour(maskData.R, maskData.G, maskData.B); } /* @@ -786,11 +786,10 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) for (i_key = 0; i_key < chars_per_pixel; i_key++) { - key[i_key] = xpmImgLine[chars_per_pixel * i + i_key]; + key[i_key] = (wxChar)xpmImgLine[chars_per_pixel * i + i_key]; } - keyString = key; - entry = clr_tbl.find(keyString); + entry = clr_tbl.find(key); if ( entry == end ) { wxLogError(_("XPM: Malformed pixel data!")); @@ -801,12 +800,15 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) // each remaining pixel if we don't bail out return wxNullImage; } - - img_data[0] = entry->second.R; - img_data[1] = entry->second.G; - img_data[2] = entry->second.B; + else + { + img_data[0] = entry->second.R; + img_data[1] = entry->second.G; + img_data[2] = entry->second.B; + } } } + #if wxUSE_PALETTE unsigned char* r = new unsigned char[colors_cnt]; unsigned char* g = new unsigned char[colors_cnt]; @@ -824,6 +826,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) delete[] g; delete[] b; #endif // wxUSE_PALETTE + return img; } diff --git a/Source/3rd Party/wx/src/common/xti.cpp b/Source/3rd Party/wx/src/common/xti.cpp index e7dc6d1ee..9542896f7 100644 --- a/Source/3rd Party/wx/src/common/xti.cpp +++ b/Source/3rd Party/wx/src/common/xti.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/common/xti.cpp -// Purpose: runtime metadata information (extended class info) +// Purpose: runtime metadata information (extended class info // Author: Stefan Csomor // Modified by: // Created: 27/07/03 +// RCS-ID: $Id: xti.cpp 38857 2006-04-20 07:31:44Z ABX $ // Copyright: (c) 1997 Julian Smart // (c) 2003 Stefan Csomor // Licence: wxWindows licence @@ -27,8 +28,6 @@ #include "wx/xti.h" #include "wx/xml/xml.h" #include "wx/tokenzr.h" -#include "wx/range.h" - #include #include "wx/beforestd.h" @@ -37,73 +36,72 @@ #include #include "wx/afterstd.h" -using namespace std; +using namespace std ; // ---------------------------------------------------------------------------- -// wxEnumData +// Enum Support // ---------------------------------------------------------------------------- wxEnumData::wxEnumData( wxEnumMemberData* data ) { - m_members = data; - for ( m_count = 0; m_members[m_count].m_name; m_count++) - {}; + m_members = data ; + for ( m_count = 0; m_members[m_count].m_name ; m_count++) + {} ; } bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value) const { int i; - for (i = 0; m_members[i].m_name; i++ ) + for (i = 0; m_members[i].m_name ; i++ ) { if (!wxStrcmp(name, m_members[i].m_name)) { if ( value ) *value = m_members[i].m_value; - return true; + return true ; } } - return false; + return false ; } int wxEnumData::GetEnumMemberValue(const wxChar *name) const { int i; - for (i = 0; m_members[i].m_name; i++ ) + for (i = 0; m_members[i].m_name ; i++ ) { if (!wxStrcmp(name, m_members[i].m_name)) { return m_members[i].m_value; } } - return 0; + return 0 ; } const wxChar *wxEnumData::GetEnumMemberName(int value) const { int i; - for (i = 0; m_members[i].m_name; i++) + for (i = 0; m_members[i].m_name ; i++) if (value == m_members[i].m_value) return m_members[i].m_name; - return wxEmptyString; + return wxEmptyString ; } int wxEnumData::GetEnumMemberValueByIndex( int idx ) const { // we should cache the count in order to avoid out-of-bounds errors - return m_members[idx].m_value; + return m_members[idx].m_value ; } const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const { // we should cache the count in order to avoid out-of-bounds errors - return m_members[idx].m_name; + return m_members[idx].m_name ; } // ---------------------------------------------------------------------------- // Type Information // ---------------------------------------------------------------------------- - // ---------------------------------------------------------------------------- // value streaming // ---------------------------------------------------------------------------- @@ -113,190 +111,159 @@ const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const // bool -template<> void wxStringReadValue(const wxString &s, bool &data ) +template<> void wxStringReadValue(const wxString &s , bool &data ) { - int intdata; - wxSscanf(s, wxT("%d"), &intdata ); - data = (bool)(intdata != 0); + int intdata ; + wxSscanf(s, _T("%d"), &intdata ) ; + data = (bool)intdata ; } -template<> void wxStringWriteValue(wxString &s, const bool &data ) +template<> void wxStringWriteValue(wxString &s , const bool &data ) { - s = wxString::Format(wxT("%d"), data ); + s = wxString::Format(_T("%d"), data ) ; } // char -template<> void wxStringReadValue(const wxString &s, char &data ) +template<> void wxStringReadValue(const wxString &s , char &data ) { - int intdata; - wxSscanf(s, wxT("%d"), &intdata ); - data = char(intdata); + int intdata ; + wxSscanf(s, _T("%d"), &intdata ) ; + data = char(intdata) ; } -template<> void wxStringWriteValue(wxString &s, const char &data ) +template<> void wxStringWriteValue(wxString &s , const char &data ) { - s = wxString::Format(wxT("%d"), data ); + s = wxString::Format(_T("%d"), data ) ; } // unsigned char -template<> void wxStringReadValue(const wxString &s, unsigned char &data ) +template<> void wxStringReadValue(const wxString &s , unsigned char &data ) { - int intdata; - wxSscanf(s, wxT("%d"), &intdata ); - data = (unsigned char)(intdata); + int intdata ; + wxSscanf(s, _T("%d"), &intdata ) ; + data = (unsigned char)(intdata) ; } -template<> void wxStringWriteValue(wxString &s, const unsigned char &data ) +template<> void wxStringWriteValue(wxString &s , const unsigned char &data ) { - s = wxString::Format(wxT("%d"), data ); + s = wxString::Format(_T("%d"), data ) ; } // int -template<> void wxStringReadValue(const wxString &s, int &data ) +template<> void wxStringReadValue(const wxString &s , int &data ) { - wxSscanf(s, wxT("%d"), &data ); + wxSscanf(s, _T("%d"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const int &data ) +template<> void wxStringWriteValue(wxString &s , const int &data ) { - s = wxString::Format(wxT("%d"), data ); + s = wxString::Format(_T("%d"), data ) ; } // unsigned int -template<> void wxStringReadValue(const wxString &s, unsigned int &data ) +template<> void wxStringReadValue(const wxString &s , unsigned int &data ) { - wxSscanf(s, wxT("%d"), &data ); + wxSscanf(s, _T("%d"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const unsigned int &data ) +template<> void wxStringWriteValue(wxString &s , const unsigned int &data ) { - s = wxString::Format(wxT("%d"), data ); + s = wxString::Format(_T("%d"), data ) ; } // long -template<> void wxStringReadValue(const wxString &s, long &data ) +template<> void wxStringReadValue(const wxString &s , long &data ) { - wxSscanf(s, wxT("%ld"), &data ); + wxSscanf(s, _T("%ld"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const long &data ) +template<> void wxStringWriteValue(wxString &s , const long &data ) { - s = wxString::Format(wxT("%ld"), data ); + s = wxString::Format(_T("%ld"), data ) ; } // unsigned long -template<> void wxStringReadValue(const wxString &s, unsigned long &data ) +template<> void wxStringReadValue(const wxString &s , unsigned long &data ) { - wxSscanf(s, wxT("%ld"), &data ); + wxSscanf(s, _T("%ld"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const unsigned long &data ) +template<> void wxStringWriteValue(wxString &s , const unsigned long &data ) { - s = wxString::Format(wxT("%ld"), data ); + s = wxString::Format(_T("%ld"), data ) ; } -#ifdef wxLongLong_t -template<> void wxStringReadValue(const wxString &s, wxLongLong_t &data ) -{ - wxSscanf(s, wxT("%lld"), &data ); -} - -template<> void wxStringWriteValue(wxString &s, const wxLongLong_t &data ) -{ - s = wxString::Format(wxT("%lld"), data ); -} - -template<> void wxStringReadValue(const wxString &s, wxULongLong_t &data ) -{ - wxSscanf(s, wxT("%lld"), &data ); -} - -template<> void wxStringWriteValue(wxString &s, const wxULongLong_t &data ) -{ - s = wxString::Format(wxT("%lld"), data ); -} -#endif // float -template<> void wxStringReadValue(const wxString &s, float &data ) +template<> void wxStringReadValue(const wxString &s , float &data ) { - wxSscanf(s, wxT("%f"), &data ); + wxSscanf(s, _T("%f"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const float &data ) +template<> void wxStringWriteValue(wxString &s , const float &data ) { - s = wxString::Format(wxT("%f"), data ); + s = wxString::Format(_T("%f"), data ) ; } // double -template<> void wxStringReadValue(const wxString &s, double &data ) +template<> void wxStringReadValue(const wxString &s , double &data ) { - wxSscanf(s, wxT("%lf"), &data ); + wxSscanf(s, _T("%lf"), &data ) ; } -template<> void wxStringWriteValue(wxString &s, const double &data ) +template<> void wxStringWriteValue(wxString &s , const double &data ) { - s = wxString::Format(wxT("%lf"), data ); + s = wxString::Format(_T("%lf"), data ) ; } // wxString -template<> void wxStringReadValue(const wxString &s, wxString &data ) +template<> void wxStringReadValue(const wxString &s , wxString &data ) { - data = s; + data = s ; } -template<> void wxStringWriteValue(wxString &s, const wxString &data ) +template<> void wxStringWriteValue(wxString &s , const wxString &data ) { - s = data; + s = data ; } - // built-ins // #if wxUSE_FUNC_TEMPLATE_POINTER - #define wxBUILTIN_TYPE_INFO( element, type ) \ - wxBuiltInTypeInfo \ - s_typeInfo##type(element, &wxToStringConverter, \ - &wxFromStringConverter, typeid(type).name()); +#define wxBUILTIN_TYPE_INFO( element , type ) \ + wxBuiltInTypeInfo s_typeInfo##type(element , &wxToStringConverter , &wxFromStringConverter , typeid(type).name()) ; #else - #define wxBUILTIN_TYPE_INFO( element, type ) \ - void _toString##element( const wxAny& data, wxString &result ) \ - { wxToStringConverter(data, result); } \ + void _fromString##element( const wxString& data , wxxVariant &result ) { wxFromStringConverter(data, result); } \ + wxBuiltInTypeInfo s_typeInfo##type(element , &_toString##element , &_fromString##element , typeid(type).name()) ; #endif typedef unsigned char unsigned_char; typedef unsigned int unsigned_int; typedef unsigned long unsigned_long; -wxBuiltInTypeInfo s_typeInfovoid( wxT_VOID, NULL, NULL, typeid(void).name()); -wxBUILTIN_TYPE_INFO( wxT_BOOL, bool); -wxBUILTIN_TYPE_INFO( wxT_CHAR, char); -wxBUILTIN_TYPE_INFO( wxT_UCHAR, unsigned_char); -wxBUILTIN_TYPE_INFO( wxT_INT, int); -wxBUILTIN_TYPE_INFO( wxT_UINT, unsigned_int); -wxBUILTIN_TYPE_INFO( wxT_LONG, long); -wxBUILTIN_TYPE_INFO( wxT_ULONG, unsigned_long); -wxBUILTIN_TYPE_INFO( wxT_FLOAT, float); -wxBUILTIN_TYPE_INFO( wxT_DOUBLE, double); -wxBUILTIN_TYPE_INFO( wxT_STRING, wxString); +wxBuiltInTypeInfo s_typeInfovoid( wxT_VOID , NULL , NULL , typeid(void).name()); +wxBUILTIN_TYPE_INFO( wxT_BOOL , bool); +wxBUILTIN_TYPE_INFO( wxT_CHAR , char); +wxBUILTIN_TYPE_INFO( wxT_UCHAR , unsigned_char); +wxBUILTIN_TYPE_INFO( wxT_INT , int); +wxBUILTIN_TYPE_INFO( wxT_UINT , unsigned_int); +wxBUILTIN_TYPE_INFO( wxT_LONG , long); +wxBUILTIN_TYPE_INFO( wxT_ULONG , unsigned_long); +wxBUILTIN_TYPE_INFO( wxT_FLOAT , float); +wxBUILTIN_TYPE_INFO( wxT_DOUBLE , double); +wxBUILTIN_TYPE_INFO( wxT_STRING , wxString); -#ifdef wxLongLong_t -wxBUILTIN_TYPE_INFO(wxT_LONGLONG, wxLongLong_t) -wxBUILTIN_TYPE_INFO(wxT_ULONGLONG, wxULongLong_t) -#endif // this are compiler induced specialization which are never used anywhere @@ -308,82 +275,47 @@ wxILLEGAL_TYPE_SPECIALIZATION( bool * ) wxILLEGAL_TYPE_SPECIALIZATION( long * ) wxILLEGAL_TYPE_SPECIALIZATION( wxString * ) -// wxRange +wxCOLLECTION_TYPE_INFO( wxString , wxArrayString ) ; -template<> void wxStringReadValue(const wxString &s , wxRange &data) +template<> void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value) { - int minValue, maxValue; - wxSscanf(s, wxT("%d,%d"), &minValue , &maxValue); - data = wxRange(minValue, maxValue); + wxArrayCollectionToVariantArray( theArray , value ) ; } -template<> void wxStringWriteValue(wxString &s , const wxRange &data) +wxTypeInfoMap *wxTypeInfo::ms_typeTable = NULL ; + +wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName) { - s = wxString::Format(wxT("%d,%d"), data.GetMin() , data.GetMax()); -} - -wxCUSTOM_TYPE_INFO(wxRange, wxToStringConverter , wxFromStringConverter) - -// other types - -wxCOLLECTION_TYPE_INFO( wxString, wxArrayString ); - -template<> void wxCollectionToVariantArray( wxArrayString const &theArray, - wxAnyList &value) -{ - wxArrayCollectionToVariantArray( theArray, value ); -} - -wxTypeInfoMap *wxTypeInfo::ms_typeTable = NULL; - -wxTypeInfo *wxTypeInfo::FindType(const wxString& typeName) -{ - wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName); - - if (iter == ms_typeTable->end()) - return NULL; - + wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName) ; + wxASSERT_MSG( iter != ms_typeTable->end() , wxT("lookup for a non-existent type-info") ) ; return (wxTypeInfo *)iter->second; } -wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind, wxClassInfo* classInfo, - wxVariant2StringFnc to, - wxString2VariantFnc from, - const wxString &name) : - wxTypeInfo( kind, to, from, name) -{ - wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT, - wxT("Illegal Kind for Enum Type")); m_classInfo = classInfo; -} +#if wxUSE_UNICODE +wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name) : +wxTypeInfo( kind , to , from , name) +{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;} +#endif -wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType, wxClassInfo* eventClass, - wxVariant2StringFnc to, - wxString2VariantFnc from ) : - wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString ) -{ - m_eventClass = eventClass; - m_eventType = eventType; - m_lastEventType = -1; -} +wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const wxString &name) : +wxTypeInfo( kind , to , from , name) +{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;} -wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType, int lastEventType, - wxClassInfo* eventClass, - wxVariant2StringFnc to, - wxString2VariantFnc from ) : - wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString ) -{ - m_eventClass = eventClass; - m_eventType = eventType; - m_lastEventType = lastEventType; -} +wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) : +wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString ) +{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = -1 ;} + +wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , int lastEventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) : +wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString ) +{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = lastEventType; } void wxTypeInfo::Register() { if ( ms_typeTable == NULL ) - ms_typeTable = new wxTypeInfoMap(); + ms_typeTable = new wxTypeInfoMap() ; if( !m_name.empty() ) - (*ms_typeTable)[m_name] = this; + (*ms_typeTable)[m_name] = this ; } void wxTypeInfo::Unregister() @@ -392,39 +324,24 @@ void wxTypeInfo::Unregister() ms_typeTable->erase(m_name); } -// removing header dependency on string tokenizer +// removing header dependancy on string tokenizer -void wxSetStringToArray( const wxString &s, wxArrayString &array ) +void wxSetStringToArray( const wxString &s , wxArrayString &array ) { wxStringTokenizer tokenizer(s, wxT("| \t\n"), wxTOKEN_STRTOK); wxString flag; - array.Clear(); + array.Clear() ; while (tokenizer.HasMoreTokens()) { - array.Add(tokenizer.GetNextToken()); + array.Add(tokenizer.GetNextToken()) ; } } // ---------------------------------------------------------------------------- -// wxPropertyInfo +// wxClassInfo // ---------------------------------------------------------------------------- -void wxPropertyInfo::Insert(wxPropertyInfo* &iter) -{ - m_next = NULL; - if ( iter == NULL ) - iter = this; - else - { - wxPropertyInfo* i = iter; - while( i->m_next ) - i = i->m_next; - - i->m_next = this; - } -} - -void wxPropertyInfo::Remove() +wxPropertyInfo::~wxPropertyInfo() { if ( this == m_itsClass->m_firstProperty ) { @@ -444,29 +361,9 @@ void wxPropertyInfo::Remove() info = info->m_next; } } - } -// ---------------------------------------------------------------------------- -// wxHandlerInfo -// ---------------------------------------------------------------------------- - -void wxHandlerInfo::Insert(wxHandlerInfo* &iter) -{ - m_next = NULL; - if ( iter == NULL ) - iter = this; - else - { - wxHandlerInfo* i = iter; - while( i->m_next ) - i = i->m_next; - - i->m_next = this; - } -} - -void wxHandlerInfo::Remove() +wxHandlerInfo::~wxHandlerInfo() { if ( this == m_itsClass->m_firstHandler ) { @@ -488,73 +385,25 @@ void wxHandlerInfo::Remove() } } - -// ---------------------------------------------------------------------------- -// wxClassInfo -// ---------------------------------------------------------------------------- - -bool wxClassInfo::Create(wxObject *object, int ParamCount, wxAny *Params) const -{ - if ( ParamCount != m_constructorPropertiesCount ) - { - // FIXME: shouldn't we just return false and let the caller handle it? - wxLogError( _("Illegal Parameter Count for Create Method") ); - return false; - } - - return m_constructor->Create( object, Params ); -} - -wxObject *wxClassInfo::ConstructObject(int ParamCount, wxAny *Params) const -{ - if ( ParamCount != m_constructorPropertiesCount ) - { - // FIXME: shouldn't we just return NULL and let the caller handle this case? - wxLogError( _("Illegal Parameter Count for ConstructObject Method") ); - return NULL; - } - - wxObject *object = NULL; - if (!m_constructor->Create( object, Params )) - return NULL; - return object; -} - -bool wxClassInfo::IsKindOf(const wxClassInfo *info) const -{ - if ( info != 0 ) - { - if ( info == this ) - return true; - - for ( int i = 0; m_parents[i]; ++ i ) - { - if ( m_parents[i]->IsKindOf( info ) ) - return true; - } - } - return false; -} - const wxPropertyAccessor *wxClassInfo::FindAccessor(const wxChar *PropertyName) const { - const wxPropertyInfo* info = FindPropertyInfo( PropertyName ); + const wxPropertyInfo* info = FindPropertyInfo( PropertyName ) ; if ( info ) - return info->GetAccessor(); + return info->GetAccessor() ; - return NULL; + return NULL ; } wxPropertyInfo *wxClassInfo::FindPropertyInfoInThisClass (const wxChar *PropertyName) const { - wxPropertyInfo* info = GetFirstProperty(); + wxPropertyInfo* info = m_firstProperty ; while( info ) { - if ( wxStrcmp( info->GetName(), PropertyName ) == 0 ) - return info; - info = info->GetNext(); + if ( wxStrcmp( info->GetName() , PropertyName ) == 0 ) + return info ; + info = info->GetNext() ; } return 0; @@ -562,15 +411,15 @@ wxPropertyInfo *wxClassInfo::FindPropertyInfoInThisClass (const wxChar *Property const wxPropertyInfo *wxClassInfo::FindPropertyInfo (const wxChar *PropertyName) const { - const wxPropertyInfo* info = FindPropertyInfoInThisClass( PropertyName ); + const wxPropertyInfo* info = FindPropertyInfoInThisClass( PropertyName ) ; if ( info ) - return info; + return info ; - const wxClassInfo** parents = GetParents(); - for ( int i = 0; parents[i]; ++ i ) + const wxClassInfo** parents = GetParents() ; + for ( int i = 0 ; parents[i] ; ++ i ) { if ( ( info = parents[i]->FindPropertyInfo( PropertyName ) ) != NULL ) - return info; + return info ; } return 0; @@ -578,13 +427,13 @@ const wxPropertyInfo *wxClassInfo::FindPropertyInfo (const wxChar *PropertyName) wxHandlerInfo *wxClassInfo::FindHandlerInfoInThisClass (const wxChar *PropertyName) const { - wxHandlerInfo* info = GetFirstHandler(); + wxHandlerInfo* info = m_firstHandler ; while( info ) { - if ( wxStrcmp( info->GetName(), PropertyName ) == 0 ) - return info; - info = info->GetNext(); + if ( wxStrcmp( info->GetName() , PropertyName ) == 0 ) + return info ; + info = info->GetNext() ; } return 0; @@ -592,16 +441,16 @@ wxHandlerInfo *wxClassInfo::FindHandlerInfoInThisClass (const wxChar *PropertyNa const wxHandlerInfo *wxClassInfo::FindHandlerInfo (const wxChar *PropertyName) const { - const wxHandlerInfo* info = FindHandlerInfoInThisClass( PropertyName ); + const wxHandlerInfo* info = FindHandlerInfoInThisClass( PropertyName ) ; if ( info ) - return info; + return info ; - const wxClassInfo** parents = GetParents(); - for ( int i = 0; parents[i]; ++ i ) + const wxClassInfo** parents = GetParents() ; + for ( int i = 0 ; parents[i] ; ++ i ) { if ( ( info = parents[i]->FindHandlerInfo( PropertyName ) ) != NULL ) - return info; + return info ; } return 0; @@ -610,68 +459,64 @@ const wxHandlerInfo *wxClassInfo::FindHandlerInfo (const wxChar *PropertyName) c wxObjectStreamingCallback wxClassInfo::GetStreamingCallback() const { if ( m_streamingCallback ) - return m_streamingCallback; + return m_streamingCallback ; - wxObjectStreamingCallback retval = NULL; - const wxClassInfo** parents = GetParents(); - for ( int i = 0; parents[i] && retval == NULL; ++ i ) + wxObjectStreamingCallback retval = NULL ; + const wxClassInfo** parents = GetParents() ; + for ( int i = 0 ; parents[i] && retval == NULL ; ++ i ) { - retval = parents[i]->GetStreamingCallback(); + retval = parents[i]->GetStreamingCallback() ; } - return retval; + return retval ; } -bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxObjectWriter *streamer, - wxObjectWriterCallback *writercallback, const wxStringToAnyHashMap &metadata) const +bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxWriter *streamer , wxPersister *persister , wxxVariantArray &metadata) const { - wxObjectStreamingCallback sb = GetStreamingCallback(); + wxObjectStreamingCallback sb = GetStreamingCallback() ; if ( sb ) - return (*sb)(obj, streamer, writercallback, metadata ); + return (*sb)(obj , streamer , persister , metadata ) ; - return true; + return true ; } -void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, - const wxAny &value) const +void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const { const wxPropertyAccessor *accessor; accessor = FindAccessor(propertyName); wxASSERT(accessor->HasSetter()); - accessor->SetProperty( object, value ); + accessor->SetProperty( object , value ) ; } -wxAny wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const +wxxVariant wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const { const wxPropertyAccessor *accessor; accessor = FindAccessor(propertyName); wxASSERT(accessor->HasGetter()); - wxAny result; + wxxVariant result ; accessor->GetProperty(object,result); - return result; + return result ; } -wxAnyList wxClassInfo::GetPropertyCollection(wxObject *object, - const wxChar *propertyName) const +wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxChar *propertyName) const { const wxPropertyAccessor *accessor; accessor = FindAccessor(propertyName); wxASSERT(accessor->HasGetter()); - wxAnyList result; + wxxVariantArray result ; accessor->GetPropertyCollection(object,result); - return result; + return result ; } -void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName, - const wxAny& value) const +void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const { const wxPropertyAccessor *accessor; accessor = FindAccessor(propertyName); wxASSERT(accessor->HasAdder()); - accessor->AddToPropertyCollection( object, value ); + accessor->AddToPropertyCollection( object , value ) ; } // void wxClassInfo::GetProperties( wxPropertyInfoMap &map ) const @@ -679,49 +524,39 @@ void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *proper // to MSVC and so we use a other name. void wxClassInfo::GetProperties( wxPropertyInfoMap &infomap ) const { - const wxPropertyInfo *pi = GetFirstProperty(); + const wxPropertyInfo *pi = GetFirstProperty() ; while( pi ) { if ( infomap.find( pi->GetName() ) == infomap.end() ) - infomap[pi->GetName()] = (wxPropertyInfo*) pi; + infomap[pi->GetName()] = (wxPropertyInfo*) pi ; - pi = pi->GetNext(); + pi = pi->GetNext() ; } - const wxClassInfo** parents = GetParents(); - for ( int i = 0; parents[i]; ++ i ) + const wxClassInfo** parents = GetParents() ; + for ( int i = 0 ; parents[i] ; ++ i ) { - parents[i]->GetProperties( infomap ); + parents[i]->GetProperties( infomap ) ; } } -wxObject* wxClassInfo::AnyToObjectPtr( const wxAny &data) const -{ - return m_variantOfPtrToObjectConverter(data); -} +/* +VARIANT TO OBJECT +*/ -void wxClassInfo::CallOnAny( const wxAny &data, wxObjectFunctor* functor ) const +wxObject* wxxVariant::GetAsObject() { - if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT ) - return m_variantToObjectConverter(data, functor); + const wxClassTypeInfo *ti = dynamic_cast( m_data->GetTypeInfo() ) ; + if ( ti ) + return ti->GetClassInfo()->VariantToInstance(*this) ; else - return (*functor)(m_variantOfPtrToObjectConverter(data)); -} - -wxAny wxClassInfo::ObjectPtrToAny( wxObject* obj) const -{ - return m_objectToVariantConverter(obj); -} - -bool wxClassInfo::NeedsDirectConstruction() const -{ - return wx_dynamic_cast(wxObjectAllocator*, m_constructor) != NULL; + return NULL ; } // ---------------------------------------------------------------------------- // wxDynamicObject support // ---------------------------------------------------------------------------- - +// // Dynamic Objects are objects that have a real superclass instance and carry their // own attributes in a hash map. Like this it is possible to create the objects and // stream them, as if their class information was already available from compiled data @@ -730,177 +565,167 @@ struct wxDynamicObject::wxDynamicObjectInternal { wxDynamicObjectInternal() {} - wxStringToAnyHashMap m_properties; -}; +#if wxUSE_UNICODE + map m_properties ; +#else + map m_properties ; +#endif +} ; -typedef list< wxDynamicObject* > wxDynamicObjectList; +typedef list< wxDynamicObject* > wxDynamicObjectList ; struct wxDynamicClassInfo::wxDynamicClassInfoInternal { - wxDynamicObjectList m_dynamicObjects; -}; + wxDynamicObjectList m_dynamicObjects ; +} ; // instantiates this object with an instance of its superclass wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) { - m_superClassInstance = superClassInstance; - m_classInfo = info; - m_data = new wxDynamicObjectInternal; + m_superClassInstance = superClassInstance ; + m_classInfo = info ; + m_data = new wxDynamicObjectInternal ; } wxDynamicObject::~wxDynamicObject() { - wx_dynamic_cast(const wxDynamicClassInfo*, m_classInfo)-> - m_data->m_dynamicObjects.remove( this ); - delete m_data; - delete m_superClassInstance; + dynamic_cast(m_classInfo)->m_data->m_dynamicObjects.remove( this ) ; + delete m_data ; + delete m_superClassInstance ; } -void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxAny &value) +void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value) { - wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName), - wxT("Accessing Unknown Property in a Dynamic Object") ); - m_data->m_properties[propertyName] = value; + wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ; + m_data->m_properties[propertyName] = value ; } -wxAny wxDynamicObject::GetProperty (const wxChar *propertyName) const +wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const { - wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName), - wxT("Accessing Unknown Property in a Dynamic Object") ); - return m_data->m_properties[propertyName]; + wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ; + return m_data->m_properties[propertyName] ; } void wxDynamicObject::RemoveProperty( const wxChar *propertyName ) { - wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName), - wxT("Removing Unknown Property in a Dynamic Object") ); - m_data->m_properties.erase( propertyName ); + wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Removing Unknown Property in a Dynamic Object") ) ; + m_data->m_properties.erase( propertyName ) ; } -void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName, - const wxChar *newPropertyName ) +void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) { - wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName), - wxT("Renaming Unknown Property in a Dynamic Object") ); - - wxAny value = m_data->m_properties[oldPropertyName]; - m_data->m_properties.erase( oldPropertyName ); - m_data->m_properties[newPropertyName] = value; + wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),wxT("Renaming Unknown Property in a Dynamic Object") ) ; + wxxVariant value = m_data->m_properties[oldPropertyName] ; + m_data->m_properties.erase( oldPropertyName ) ; + m_data->m_properties[newPropertyName] = value ; } // ---------------------------------------------------------------------------- -// wxDynamicClassInfo +// wxDynamiClassInfo // ---------------------------------------------------------------------------- -wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName, - const wxChar *className, - const wxClassInfo* superClass ) : - wxClassInfo( unitName, className, new const wxClassInfo*[2]) +wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName, const wxChar *className , const wxClassInfo* superClass ) : +wxClassInfo( unitName, className , new const wxClassInfo*[2]) { - GetParents()[0] = superClass; - GetParents()[1] = NULL; - m_data = new wxDynamicClassInfoInternal; + GetParents()[0] = superClass ; + GetParents()[1] = NULL ; + m_data = new wxDynamicClassInfoInternal ; } wxDynamicClassInfo::~wxDynamicClassInfo() { - delete[] GetParents(); - delete m_data; + delete[] GetParents() ; + delete m_data ; } wxObject *wxDynamicClassInfo::AllocateObject() const { - wxObject* parent = GetParents()[0]->AllocateObject(); - wxDynamicObject *obj = new wxDynamicObject( parent, this ); - m_data->m_dynamicObjects.push_back( obj ); - return obj; + wxObject* parent = GetParents()[0]->AllocateObject() ; + wxDynamicObject *obj = new wxDynamicObject( parent , this ) ; + m_data->m_dynamicObjects.push_back( obj ) ; + return obj ; } -bool wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxAny *params) const +void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const { - wxDynamicObject *dynobj = wx_dynamic_cast( wxDynamicObject *, object ); - wxASSERT_MSG( dynobj, - wxT("cannot call wxDynamicClassInfo::Create on ") - wxT("an object other than wxDynamicObject") ); - - return GetParents()[0]->Create( dynobj->GetSuperClassInstance(), paramCount, params ); + wxDynamicObject *dynobj = dynamic_cast< wxDynamicObject *>( object ) ; + wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::Create on an object other than wxDynamicObject") ) ; + GetParents()[0]->Create( dynobj->GetSuperClassInstance() , paramCount , params ) ; } // get number of parameters for constructor int wxDynamicClassInfo::GetCreateParamCount() const { - return GetParents()[0]->GetCreateParamCount(); + return GetParents()[0]->GetCreateParamCount() ; } // get i-th constructor parameter const wxChar* wxDynamicClassInfo::GetCreateParamName(int i) const { - return GetParents()[0]->GetCreateParamName( i ); + return GetParents()[0]->GetCreateParamName( i ) ; } -void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxAny &value) const +void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const { - wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object); - wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ); + wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ; + wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; if ( FindPropertyInfoInThisClass(propertyName) ) - dynobj->SetProperty( propertyName, value ); + dynobj->SetProperty( propertyName , value ) ; else - GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance(), propertyName, value ); + GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance() , propertyName , value ) ; } -wxAny wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const +wxxVariant wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const { - wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object); - wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ); + wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ; + wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; if ( FindPropertyInfoInThisClass(propertyName) ) - return dynobj->GetProperty( propertyName ); + return dynobj->GetProperty( propertyName ) ; else - return GetParents()[0]->GetProperty( dynobj->GetSuperClassInstance(), propertyName ); + return GetParents()[0]->GetProperty( dynobj->GetSuperClassInstance() , propertyName ) ; } -void wxDynamicClassInfo::AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo ) +void wxDynamicClassInfo::AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo ) { - EnsureInfosInited(); - new wxPropertyInfo( m_firstProperty, this, propertyName, typeInfo->GetTypeName(), new wxGenericPropertyAccessor( propertyName ), wxAny() ); + new wxPropertyInfo( m_firstProperty , this , propertyName , typeInfo->GetTypeName() , new wxGenericPropertyAccessor( propertyName ) , wxxVariant() ) ; } -void wxDynamicClassInfo::AddHandler( const wxChar *handlerName, wxObjectEventFunction address, const wxClassInfo* eventClassInfo ) +void wxDynamicClassInfo::AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) { - EnsureInfosInited(); - new wxHandlerInfo( m_firstHandler, this, handlerName, address, eventClassInfo ); + new wxHandlerInfo( m_firstHandler , this , handlerName , address , eventClassInfo ) ; } // removes an existing runtime-property void wxDynamicClassInfo::RemoveProperty( const wxChar *propertyName ) { - for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin(); iter != m_data->m_dynamicObjects.end(); ++iter ) - (*iter)->RemoveProperty( propertyName ); - delete FindPropertyInfoInThisClass(propertyName); + for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter ) + (*iter)->RemoveProperty( propertyName ) ; + delete FindPropertyInfoInThisClass(propertyName) ; } // removes an existing runtime-handler void wxDynamicClassInfo::RemoveHandler( const wxChar *handlerName ) { - delete FindHandlerInfoInThisClass(handlerName); + delete FindHandlerInfoInThisClass(handlerName) ; } // renames an existing runtime-property -void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName, const wxChar *newPropertyName ) +void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) { - wxPropertyInfo* pi = FindPropertyInfoInThisClass(oldPropertyName); - wxASSERT_MSG( pi,wxT("not existing property") ); - pi->m_name = newPropertyName; - wx_dynamic_cast(wxGenericPropertyAccessor*, pi->GetAccessor())->RenameProperty( oldPropertyName, newPropertyName ); - for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin(); iter != m_data->m_dynamicObjects.end(); ++iter ) - (*iter)->RenameProperty( oldPropertyName, newPropertyName ); + wxPropertyInfo* pi = FindPropertyInfoInThisClass(oldPropertyName) ; + wxASSERT_MSG( pi ,wxT("not existing property") ) ; + pi->m_name = newPropertyName ; + dynamic_cast(pi->GetAccessor())->RenameProperty( oldPropertyName , newPropertyName ) ; + for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter ) + (*iter)->RenameProperty( oldPropertyName , newPropertyName ) ; } // renames an existing runtime-handler -void wxDynamicClassInfo::RenameHandler( const wxChar *oldHandlerName, const wxChar *newHandlerName ) +void wxDynamicClassInfo::RenameHandler( const wxChar *oldHandlerName , const wxChar *newHandlerName ) { - wxASSERT_MSG(FindHandlerInfoInThisClass(oldHandlerName),wxT("not existing handler") ); - FindHandlerInfoInThisClass(oldHandlerName)->m_name = newHandlerName; + wxASSERT_MSG(FindHandlerInfoInThisClass(oldHandlerName),wxT("not existing handler") ) ; + FindHandlerInfoInThisClass(oldHandlerName)->m_name = newHandlerName ; } // ---------------------------------------------------------------------------- @@ -909,63 +734,34 @@ void wxDynamicClassInfo::RenameHandler( const wxChar *oldHandlerName, const wxCh struct wxGenericPropertyAccessor::wxGenericPropertyAccessorInternal { - char filler; -}; + char filler ; +} ; wxGenericPropertyAccessor::wxGenericPropertyAccessor( const wxString& propertyName ) -: wxPropertyAccessor( NULL, NULL, NULL, NULL ) +: wxPropertyAccessor( NULL , NULL , NULL , NULL ) { - m_data = new wxGenericPropertyAccessorInternal; - m_propertyName = propertyName; - m_getterName = wxT("Get")+propertyName; - m_setterName = wxT("Set")+propertyName; + m_data = new wxGenericPropertyAccessorInternal ; + m_propertyName = propertyName ; + m_getterName = wxT("Get")+propertyName ; + m_setterName = wxT("Set")+propertyName ; } wxGenericPropertyAccessor::~wxGenericPropertyAccessor() { - delete m_data; + delete m_data ; } - -void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxAny &value) const +void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxxVariant &value) const { - wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object); - wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ); - dynobj->SetProperty(m_propertyName.c_str(), value ); + wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ; + wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; + dynobj->SetProperty(m_propertyName , value ) ; } -void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxAny& value) const +void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxxVariant& value) const { - const wxDynamicObject* dynobj = wx_dynamic_cast( const wxDynamicObject * , object ); - wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ); - value = dynobj->GetProperty( m_propertyName.c_str() ); + const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject * >( object ) ; + wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; + value = dynobj->GetProperty( m_propertyName ) ; } -// ---------------------------------------------------------------------------- -// wxGenericPropertyAccessor -// ---------------------------------------------------------------------------- - -wxString wxAnyGetAsString( const wxAny& data) -{ - if ( data.IsNull() || data.GetTypeInfo()==NULL ) - return wxEmptyString; - - wxString s; - data.GetTypeInfo()->ConvertToString(data,s); - return s; -} - -const wxObject* wxAnyGetAsObjectPtr( const wxAny& data) -{ - if ( !data.IsNull() ) - { - const wxClassTypeInfo* ti = wx_dynamic_cast(const wxClassTypeInfo*, data.GetTypeInfo()); - if( ti ) - return ti->GetClassInfo()->AnyToObjectPtr(data); - } - return NULL; -} - -wxObjectFunctor::~wxObjectFunctor() -{}; - #endif // wxUSE_EXTENDED_RTTI diff --git a/Source/3rd Party/wx/src/common/xtistrm.cpp b/Source/3rd Party/wx/src/common/xtistrm.cpp index d96db65eb..eeb0cf4d5 100644 --- a/Source/3rd Party/wx/src/common/xtistrm.cpp +++ b/Source/3rd Party/wx/src/common/xtistrm.cpp @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 27/07/03 +// RCS-ID: $Id: xtistrm.cpp 38939 2006-04-27 12:47:14Z ABX $ // Copyright: (c) 2003 Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,418 +29,369 @@ #include "wx/tokenzr.h" #include "wx/txtstrm.h" -// STL headers: - #include "wx/beforestd.h" #include #include #include #include "wx/afterstd.h" -using namespace std; +using namespace std ; -// ---------------------------------------------------------------------------- -// wxObjectWriter -// ---------------------------------------------------------------------------- - -struct wxObjectWriter::wxObjectWriterInternal +struct wxWriter::wxWriterInternal { - map< const wxObject*, int > m_writtenObjects; - int m_nextId; -}; + map< const wxObject* , int > m_writtenObjects ; + int m_nextId ; +} ; -wxObjectWriter::wxObjectWriter() +wxWriter::wxWriter() { - m_data = new wxObjectWriterInternal; - m_data->m_nextId = 0; + m_data = new wxWriterInternal ; + m_data->m_nextId = 0 ; } -wxObjectWriter::~wxObjectWriter() +wxWriter::~wxWriter() { - delete m_data; + delete m_data ; } -struct wxObjectWriter::wxObjectWriterInternalPropertiesData +struct wxWriter::wxWriterInternalPropertiesData { - char nothing; -}; + char nothing ; +} ; -void wxObjectWriter::ClearObjectContext() +void wxWriter::ClearObjectContext() { - delete m_data; - m_data = new wxObjectWriterInternal(); - m_data->m_nextId = 0; + delete m_data ; + m_data = new wxWriterInternal() ; + m_data->m_nextId = 0 ; } -void wxObjectWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo, - wxObjectWriterCallback *writercallback, const wxString &name, - const wxStringToAnyHashMap &metadata ) +void wxWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , const wxString &name , wxxVariantArray &metadata ) { - DoBeginWriteTopLevelEntry( name ); - WriteObject( object, classInfo, writercallback, false, metadata); - DoEndWriteTopLevelEntry( name ); + DoBeginWriteTopLevelEntry( name ) ; + WriteObject( object , classInfo , persister , false , metadata) ; + DoEndWriteTopLevelEntry( name ) ; } -void wxObjectWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo, - wxObjectWriterCallback *writercallback, bool isEmbedded, - const wxStringToAnyHashMap &metadata ) +void wxWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , bool isEmbedded, wxxVariantArray &metadata ) { - if ( !classInfo->BeforeWriteObject( object, this, writercallback, metadata) ) - return; + if ( !classInfo->BeforeWriteObject( object , this , persister , metadata) ) + return ; - if ( writercallback->BeforeWriteObject( this, object, classInfo, metadata) ) + if ( persister->BeforeWriteObject( this , object , classInfo , metadata) ) { if ( object == NULL ) - DoWriteNullObject(); + DoWriteNullObject() ; else if ( IsObjectKnown( object ) ) - DoWriteRepeatedObject( GetObjectID(object) ); + DoWriteRepeatedObject( GetObjectID(object) ) ; else { - int oid = m_data->m_nextId++; + int oid = m_data->m_nextId++ ; if ( !isEmbedded ) - m_data->m_writtenObjects[object] = oid; + m_data->m_writtenObjects[object] = oid ; // in case this object is a wxDynamicObject we also have to insert is superclass // instance with the same id, so that object relations are streamed out correctly - const wxDynamicObject* dynobj = wx_dynamic_cast(const wxDynamicObject*, object); + const wxDynamicObject* dynobj = dynamic_cast( object ) ; if ( !isEmbedded && dynobj ) - m_data->m_writtenObjects[dynobj->GetSuperClassInstance()] = oid; + m_data->m_writtenObjects[dynobj->GetSuperClassInstance()] = oid ; - DoBeginWriteObject( object, classInfo, oid, metadata ); - wxObjectWriterInternalPropertiesData data; - WriteAllProperties( object, classInfo, writercallback, &data ); - DoEndWriteObject( object, classInfo, oid ); + DoBeginWriteObject( object , classInfo , oid , metadata ) ; + wxWriterInternalPropertiesData data ; + WriteAllProperties( object , classInfo , persister , &data ) ; + DoEndWriteObject( object , classInfo , oid ) ; } - writercallback->AfterWriteObject( this,object, classInfo ); + persister->AfterWriteObject( this ,object , classInfo ) ; } } -void wxObjectWriter::FindConnectEntry(const wxEvtHandler * evSource, - const wxEventSourceTypeInfo* dti, - const wxObject* &sink, - const wxHandlerInfo *&handler) +void wxWriter::FindConnectEntry(const wxEvtHandler * evSource,const wxDelegateTypeInfo* dti, const wxObject* &sink , const wxHandlerInfo *&handler) { - wxList *dynamicEvents = evSource->GetDynamicEventTable(); + wxList *dynamicEvents = evSource->GetDynamicEventTable() ; if ( dynamicEvents ) { - for ( wxList::const_iterator node = dynamicEvents->begin(); node != dynamicEvents->end(); ++node ) + wxList::compatibility_iterator node = dynamicEvents->GetFirst(); + while (node) { - wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)(*node); + wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); // find the match if ( entry->m_fn && (dti->GetEventType() == entry->m_eventType) && (entry->m_id == -1 ) && - (entry->m_fn->GetEvtHandler() != NULL ) ) + (entry->m_eventSink != NULL ) ) { - sink = entry->m_fn->GetEvtHandler(); - const wxClassInfo* sinkClassInfo = sink->GetClassInfo(); - const wxHandlerInfo* sinkHandler = sinkClassInfo->GetFirstHandler(); + sink = entry->m_eventSink ; + const wxClassInfo* sinkClassInfo = sink->GetClassInfo() ; + const wxHandlerInfo* sinkHandler = sinkClassInfo->GetFirstHandler() ; while ( sinkHandler ) { - if ( sinkHandler->GetEventFunction() == entry->m_fn->GetEvtMethod() ) + if ( sinkHandler->GetEventFunction() == entry->m_fn ) { - handler = sinkHandler; - break; + handler = sinkHandler ; + break ; } - sinkHandler = sinkHandler->GetNext(); + sinkHandler = sinkHandler->GetNext() ; } - break; + break ; } + node = node->GetNext(); } } } -void wxObjectWriter::WriteAllProperties( const wxObject * obj, const wxClassInfo* ci, - wxObjectWriterCallback *writercallback, - wxObjectWriterInternalPropertiesData * data ) +void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data ) { - wxPropertyInfoMap map; - ci->GetProperties( map ); - for ( int i = 0; i < ci->GetCreateParamCount(); ++i ) + wxPropertyInfoMap map ; + ci->GetProperties( map ) ; + for ( int i = 0 ; i < ci->GetCreateParamCount() ; ++i ) { - wxString name = ci->GetCreateParamName(i); - wxPropertyInfoMap::const_iterator iter = map.find(name); - const wxPropertyInfo* prop = iter == map.end() ? NULL : iter->second; + wxString name = ci->GetCreateParamName(i) ; + const wxPropertyInfo* prop = map.find(name)->second ; if ( prop ) { - WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data ); + WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ; } else { - wxLogError( _("Create Parameter %s not found in declared RTTI Parameters"), name.c_str() ); + wxLogError( _("Create Parameter not found in declared RTTI Parameters") ) ; } - map.erase( name ); + map.erase( name ) ; } { // Extra block for broken compilers - for( wxPropertyInfoMap::iterator iter = map.begin(); iter != map.end(); ++iter ) + for( wxPropertyInfoMap::iterator iter = map.begin() ; iter != map.end() ; ++iter ) { - const wxPropertyInfo* prop = iter->second; + const wxPropertyInfo* prop = iter->second ; if ( prop->GetFlags() & wxPROP_OBJECT_GRAPH ) { - WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data ); + WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ; } } } { // Extra block for broken compilers - for( wxPropertyInfoMap::iterator iter = map.begin(); iter != map.end(); ++iter ) + for( wxPropertyInfoMap::iterator iter = map.begin() ; iter != map.end() ; ++iter ) { - const wxPropertyInfo* prop = iter->second; + const wxPropertyInfo* prop = iter->second ; if ( !(prop->GetFlags() & wxPROP_OBJECT_GRAPH) ) { - WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data ); + WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ; } } } } -class WXDLLIMPEXP_BASE wxObjectPropertyWriter: public wxObjectWriterFunctor -{ -public: - wxObjectPropertyWriter(const wxClassTypeInfo* cti, - wxObjectWriterCallback *writercallback, - wxObjectWriter* writer, - wxStringToAnyHashMap &props) : - m_cti(cti),m_persister(writercallback),m_writer(writer),m_props(props) - {} - - virtual void operator()(const wxObject *vobj) - { - m_writer->WriteObject( vobj, (vobj ? vobj->GetClassInfo() : m_cti->GetClassInfo() ), - m_persister, m_cti->GetKind()== wxT_OBJECT, m_props ); - } -private: - const wxClassTypeInfo* m_cti; - wxObjectWriterCallback *m_persister; - wxObjectWriter* m_writer; - wxStringToAnyHashMap& m_props; -}; - -void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* ci, - const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback, - wxObjectWriterInternalPropertiesData *WXUNUSED(data) ) +void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , const wxPropertyInfo* pi , wxPersister *persister , wxWriterInternalPropertiesData *WXUNUSED(data) ) { if ( pi->GetFlags() & wxPROP_DONT_STREAM ) - return; + return ; // make sure that we are picking the correct object for accessing the property - const wxDynamicObject* dynobj = wx_dynamic_cast(const wxDynamicObject*, obj ); - if ( dynobj && (wx_dynamic_cast(const wxDynamicClassInfo*, ci) == NULL) ) - obj = dynobj->GetSuperClassInstance(); + const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject* > (obj ) ; + if ( dynobj && (dynamic_cast(ci) == NULL) ) + obj = dynobj->GetSuperClassInstance() ; if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION ) { - wxAnyList data; - pi->GetAccessor()->GetPropertyCollection(obj, data); - const wxTypeInfo * elementType = - wx_dynamic_cast( const wxCollectionTypeInfo*, pi->GetTypeInfo() )->GetElementType(); - if ( !data.empty() ) + wxxVariantArray data ; + pi->GetAccessor()->GetPropertyCollection(obj, data) ; + const wxTypeInfo * elementType = dynamic_cast< const wxCollectionTypeInfo* >( pi->GetTypeInfo() )->GetElementType() ; + for ( size_t i = 0 ; i < data.GetCount() ; ++i ) { - DoBeginWriteProperty( pi ); - for ( wxAnyList::const_iterator iter = data.begin(); iter != data.end(); ++iter ) - { - DoBeginWriteElement(); - const wxAny* valptr = *iter; - if ( writercallback->BeforeWriteProperty( this, obj, pi, *valptr ) ) - { - const wxClassTypeInfo* cti = - wx_dynamic_cast( const wxClassTypeInfo*, elementType ); - if ( cti ) - { - wxStringToAnyHashMap md; - wxObjectPropertyWriter pw(cti,writercallback,this, md); + if ( i == 0 ) + DoBeginWriteProperty( pi ) ; - const wxClassInfo* pci = cti->GetClassInfo(); - pci->CallOnAny( *valptr, &pw); - } - else - { - DoWriteSimpleType( *valptr ); - } + DoBeginWriteElement() ; + wxxVariant value = data[i] ; + if ( persister->BeforeWriteProperty( this , obj, pi , value ) ) + { + const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( elementType ) ; + if ( cti ) + { + const wxClassInfo* pci = cti->GetClassInfo() ; + wxObject *vobj = pci->VariantToInstance( value ) ; + wxxVariantArray md ; + WriteObject( vobj , (vobj ? vobj->GetClassInfo() : pci ) , persister , cti->GetKind()== wxT_OBJECT , md ) ; + } + else + { + DoWriteSimpleType( value ) ; } - DoEndWriteElement(); } - DoEndWriteProperty( pi ); - } - } + DoEndWriteElement() ; + if ( i == data.GetCount() - 1 ) + DoEndWriteProperty( pi ) ; + } + } else { - const wxEventSourceTypeInfo* dti = - wx_dynamic_cast( const wxEventSourceTypeInfo* , pi->GetTypeInfo() ); + const wxDelegateTypeInfo* dti = dynamic_cast< const wxDelegateTypeInfo* > ( pi->GetTypeInfo() ) ; if ( dti ) { - const wxObject* sink = NULL; - const wxHandlerInfo *handler = NULL; + const wxObject* sink = NULL ; + const wxHandlerInfo *handler = NULL ; - const wxEvtHandler * evSource = wx_dynamic_cast(const wxEvtHandler *, obj); + const wxEvtHandler * evSource = dynamic_cast(obj) ; if ( evSource ) { - FindConnectEntry( evSource, dti, sink, handler ); - if ( writercallback->BeforeWriteDelegate( this, obj, ci, pi, sink, handler ) ) + FindConnectEntry( evSource , dti , sink , handler ) ; + if ( persister->BeforeWriteDelegate( this , obj , ci , pi , sink , handler ) ) { if ( sink != NULL && handler != NULL ) { - DoBeginWriteProperty( pi ); + DoBeginWriteProperty( pi ) ; if ( IsObjectKnown( sink ) ) { - DoWriteDelegate( obj, ci, pi, sink, GetObjectID( sink ), - sink->GetClassInfo(), handler ); - DoEndWriteProperty( pi ); + DoWriteDelegate( obj , ci , pi , sink , GetObjectID( sink ) , sink->GetClassInfo() , handler ) ; + DoEndWriteProperty( pi ) ; } else { - wxLogError( wxT("Streaming delegates for not already ") - wxT("streamed objects not yet supported") ); + wxLogError( _("Streaming delegates for not already streamed objects not yet supported") ) ; } } } } else { - wxLogError(_("Illegal Object Class (Non-wxEvtHandler) as Event Source") ); + wxLogError(_("Illegal Object Class (Non-wxEvtHandler) as Event Source") ) ; } } else { - wxAny value; - pi->GetAccessor()->GetProperty(obj, value); + wxxVariant value ; + pi->GetAccessor()->GetProperty(obj, value) ; // avoid streaming out void objects - // TODO Verify - if( value.IsNull() ) - return; + if( value.IsEmpty() ) + return ; if ( pi->GetFlags() & wxPROP_ENUM_STORE_LONG ) { - const wxEnumTypeInfo *eti = - wx_dynamic_cast(const wxEnumTypeInfo*, pi->GetTypeInfo() ); + const wxEnumTypeInfo *eti = dynamic_cast( pi->GetTypeInfo() ) ; if ( eti ) { - eti->ConvertFromLong( wxANY_AS(value, long ), value ); + eti->ConvertFromLong( value.wxTEMPLATED_MEMBER_CALL(Get , long) , value ) ; } else { - wxLogError( _("Type must have enum - long conversion") ); + wxLogError( _("Type must have enum - long conversion") ) ; } } // avoid streaming out default values - if ( pi->GetTypeInfo()->HasStringConverters() && - !pi->GetDefaultValue().IsNull() ) // TODO Verify + if ( pi->GetTypeInfo()->HasStringConverters() && !pi->GetDefaultValue().IsEmpty() ) { - if ( wxAnyGetAsString(value) == wxAnyGetAsString(pi->GetDefaultValue()) ) - return; + if ( value.GetAsString() == pi->GetDefaultValue().GetAsString() ) + return ; } // avoid streaming out null objects - const wxClassTypeInfo* cti = - wx_dynamic_cast( const wxClassTypeInfo* , pi->GetTypeInfo() ); + const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( pi->GetTypeInfo() ) ; - if ( cti && cti->GetKind() == wxT_OBJECT_PTR && wxAnyGetAsObjectPtr(value) == NULL ) - return; + if ( cti && value.GetAsObject() == NULL ) + return ; - if ( writercallback->BeforeWriteProperty( this, obj, pi, value ) ) + if ( persister->BeforeWriteProperty( this , obj, pi , value ) ) { - DoBeginWriteProperty( pi ); + DoBeginWriteProperty( pi ) ; if ( cti ) { - if ( cti->HasStringConverters() ) + const wxClassInfo* pci = cti->GetClassInfo() ; + wxObject *vobj = pci->VariantToInstance( value ) ; + if ( vobj && pi->GetTypeInfo()->HasStringConverters() ) { - wxString stringValue; - cti->ConvertToString( value, stringValue ); - wxAny convertedValue(stringValue); - DoWriteSimpleType( convertedValue ); + wxString stringValue ; + cti->ConvertToString( value , stringValue ) ; + wxxVariant convertedValue(stringValue) ; + DoWriteSimpleType( convertedValue ) ; } else { - wxStringToAnyHashMap md; - wxObjectPropertyWriter pw(cti,writercallback,this, md); - - const wxClassInfo* pci = cti->GetClassInfo(); - pci->CallOnAny(value, &pw); + wxxVariantArray md ; + WriteObject( vobj , (vobj ? vobj->GetClassInfo() : pci ) , persister , cti->GetKind()== wxT_OBJECT , md) ; } } else { - DoWriteSimpleType( value ); + DoWriteSimpleType( value ) ; } - DoEndWriteProperty( pi ); + DoEndWriteProperty( pi ) ; } } } } -int wxObjectWriter::GetObjectID(const wxObject *obj) +int wxWriter::GetObjectID(const wxObject *obj) { if ( !IsObjectKnown( obj ) ) - return wxInvalidObjectID; + return wxInvalidObjectID ; - return m_data->m_writtenObjects[obj]; + return m_data->m_writtenObjects[obj] ; } -bool wxObjectWriter::IsObjectKnown( const wxObject *obj ) +bool wxWriter::IsObjectKnown( const wxObject *obj ) { - return m_data->m_writtenObjects.find( obj ) != m_data->m_writtenObjects.end(); + return m_data->m_writtenObjects.find( obj ) != m_data->m_writtenObjects.end() ; } // ---------------------------------------------------------------------------- -// wxObjectReader +// reading objects in // ---------------------------------------------------------------------------- -struct wxObjectReader::wxObjectReaderInternal +struct wxReader::wxReaderInternal { map m_classInfos; }; -wxObjectReader::wxObjectReader() +wxReader::wxReader() { - m_data = new wxObjectReaderInternal; + m_data = new wxReaderInternal; } -wxObjectReader::~wxObjectReader() +wxReader::~wxReader() { delete m_data; } -wxClassInfo* wxObjectReader::GetObjectClassInfo(int objectID) +wxClassInfo* wxReader::GetObjectClassInfo(int objectID) { if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID ) { - wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ); - return NULL; + wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ) ; + return NULL ; } if ( m_data->m_classInfos.find(objectID) == m_data->m_classInfos.end() ) { - wxLogError( _("Unknown Object passed to GetObjectClassInfo" ) ); - return NULL; + wxLogError( _("Unknown Object passed to GetObjectClassInfo" ) ) ; + return NULL ; } - return m_data->m_classInfos[objectID]; + return m_data->m_classInfos[objectID] ; } -void wxObjectReader::SetObjectClassInfo(int objectID, wxClassInfo *classInfo ) +void wxReader::SetObjectClassInfo(int objectID, wxClassInfo *classInfo ) { if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID ) { - wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ); - return; + wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ) ; + return ; } if ( m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() ) { - wxLogError( _("Already Registered Object passed to SetObjectClassInfo" ) ); - return; + wxLogError( _("Already Registered Object passed to SetObjectClassInfo" ) ) ; + return ; } - m_data->m_classInfos[objectID] = classInfo; + m_data->m_classInfos[objectID] = classInfo ; } -bool wxObjectReader::HasObjectClassInfo( int objectID ) +bool wxReader::HasObjectClassInfo( int objectID ) { if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID ) { - wxLogError( _("Invalid or Null Object ID passed to HasObjectClassInfo" ) ); - return false; + wxLogError( _("Invalid or Null Object ID passed to HasObjectClassInfo" ) ) ; + return NULL ; } - return m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end(); + return m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() ; } @@ -455,10 +407,10 @@ and create params are always toplevel class only // ---------------------------------------------------------------------------- -// wxObjectRuntimeReaderCallback - depersisting to memory +// depersisting to memory // ---------------------------------------------------------------------------- -struct wxObjectRuntimeReaderCallback::wxObjectRuntimeReaderCallbackInternal +struct wxRuntimeDepersister::wxRuntimeDepersisterInternal { map m_objects; @@ -466,54 +418,54 @@ struct wxObjectRuntimeReaderCallback::wxObjectRuntimeReaderCallbackInternal { if ( m_objects.find(objectID) != m_objects.end() ) { - wxLogError( _("Passing a already registered object to SetObject") ); - return ; + wxLogError( _("Passing a already registered object to SetObject") ) ; + return ; } - m_objects[objectID] = obj; + m_objects[objectID] = obj ; } wxObject* GetObject( int objectID ) { if ( objectID == wxNullObjectID ) - return NULL; + return NULL ; if ( m_objects.find(objectID) == m_objects.end() ) { - wxLogError( _("Passing an unknown object to GetObject") ); - return NULL; + wxLogError( _("Passing an unkown object to GetObject") ) ; + return NULL ; } - return m_objects[objectID]; + return m_objects[objectID] ; } -}; +} ; -wxObjectRuntimeReaderCallback::wxObjectRuntimeReaderCallback() +wxRuntimeDepersister::wxRuntimeDepersister() { - m_data = new wxObjectRuntimeReaderCallbackInternal(); + m_data = new wxRuntimeDepersisterInternal() ; } -wxObjectRuntimeReaderCallback::~wxObjectRuntimeReaderCallback() +wxRuntimeDepersister::~wxRuntimeDepersister() { - delete m_data; + delete m_data ; } -void wxObjectRuntimeReaderCallback::AllocateObject(int objectID, wxClassInfo *classInfo, - wxStringToAnyHashMap &WXUNUSED(metadata)) +void wxRuntimeDepersister::AllocateObject(int objectID, wxClassInfo *classInfo , + wxxVariantArray &WXUNUSED(metadata)) { wxObject *O; O = classInfo->CreateObject(); m_data->SetObject(objectID, O); } -void wxObjectRuntimeReaderCallback::CreateObject(int objectID, +void wxRuntimeDepersister::CreateObject(int objectID, const wxClassInfo *classInfo, int paramCount, - wxAny *params, + wxxVariant *params, int *objectIdValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &WXUNUSED(metadata)) + const wxClassInfo **objectClassInfos , + wxxVariantArray &WXUNUSED(metadata)) { wxObject *o; o = m_data->GetObject(objectID); - for ( int i = 0; i < paramCount; ++i ) + for ( int i = 0 ; i < paramCount ; ++i ) { if ( objectIdValues[i] != wxInvalidObjectID ) { @@ -521,27 +473,27 @@ void wxObjectRuntimeReaderCallback::CreateObject(int objectID, o = m_data->GetObject(objectIdValues[i]); // if this is a dynamic object and we are asked for another class // than wxDynamicObject we cast it down manually. - wxDynamicObject *dyno = wx_dynamic_cast( wxDynamicObject *, o); + wxDynamicObject *dyno = dynamic_cast< wxDynamicObject * > (o) ; if ( dyno!=NULL && (objectClassInfos[i] != dyno->GetClassInfo()) ) { - o = dyno->GetSuperClassInstance(); + o = dyno->GetSuperClassInstance() ; } - params[i] = objectClassInfos[i]->ObjectPtrToAny(o); + params[i] = objectClassInfos[i]->InstanceToVariant(o) ; } } classInfo->Create(o, paramCount, params); } -void wxObjectRuntimeReaderCallback::ConstructObject(int objectID, +void wxRuntimeDepersister::ConstructObject(int objectID, const wxClassInfo *classInfo, int paramCount, - wxAny *params, + wxxVariant *params, int *objectIdValues, - const wxClassInfo **objectClassInfos, - wxStringToAnyHashMap &WXUNUSED(metadata)) + const wxClassInfo **objectClassInfos , + wxxVariantArray &WXUNUSED(metadata)) { wxObject *o; - for ( int i = 0; i < paramCount; ++i ) + for ( int i = 0 ; i < paramCount ; ++i ) { if ( objectIdValues[i] != wxInvalidObjectID ) { @@ -549,12 +501,12 @@ void wxObjectRuntimeReaderCallback::ConstructObject(int objectID, o = m_data->GetObject(objectIdValues[i]); // if this is a dynamic object and we are asked for another class // than wxDynamicObject we cast it down manually. - wxDynamicObject *dyno = wx_dynamic_cast( wxDynamicObject *, o); + wxDynamicObject *dyno = dynamic_cast< wxDynamicObject * > (o) ; if ( dyno!=NULL && (objectClassInfos[i] != dyno->GetClassInfo()) ) { - o = dyno->GetSuperClassInstance(); + o = dyno->GetSuperClassInstance() ; } - params[i] = objectClassInfos[i]->ObjectPtrToAny(o); + params[i] = objectClassInfos[i]->InstanceToVariant(o) ; } } o = classInfo->ConstructObject(paramCount, params); @@ -562,24 +514,24 @@ void wxObjectRuntimeReaderCallback::ConstructObject(int objectID, } -void wxObjectRuntimeReaderCallback::DestroyObject(int objectID, wxClassInfo *WXUNUSED(classInfo)) +void wxRuntimeDepersister::DestroyObject(int objectID, wxClassInfo *WXUNUSED(classInfo)) { wxObject *o; o = m_data->GetObject(objectID); - delete o; + delete o ; } -void wxObjectRuntimeReaderCallback::SetProperty(int objectID, +void wxRuntimeDepersister::SetProperty(int objectID, const wxClassInfo *classInfo, const wxPropertyInfo* propertyInfo, - const wxAny &value) + const wxxVariant &value) { wxObject *o; o = m_data->GetObject(objectID); - classInfo->SetProperty( o, propertyInfo->GetName().c_str(), value ); + classInfo->SetProperty( o , propertyInfo->GetName() , value ) ; } -void wxObjectRuntimeReaderCallback::SetPropertyAsObject(int objectID, +void wxRuntimeDepersister::SetPropertyAsObject(int objectID, const wxClassInfo *classInfo, const wxPropertyInfo* propertyInfo, int valueObjectId) @@ -587,94 +539,309 @@ void wxObjectRuntimeReaderCallback::SetPropertyAsObject(int objectID, wxObject *o, *valo; o = m_data->GetObject(objectID); valo = m_data->GetObject(valueObjectId); - const wxClassInfo* valClassInfo = - (wx_dynamic_cast(const wxClassTypeInfo*,propertyInfo->GetTypeInfo()))->GetClassInfo(); - + const wxClassInfo* valClassInfo = (dynamic_cast(propertyInfo->GetTypeInfo()))->GetClassInfo() ; // if this is a dynamic object and we are asked for another class // than wxDynamicObject we cast it down manually. - wxDynamicObject *dynvalo = wx_dynamic_cast( wxDynamicObject *, valo); + wxDynamicObject *dynvalo = dynamic_cast< wxDynamicObject * > (valo) ; if ( dynvalo!=NULL && (valClassInfo != dynvalo->GetClassInfo()) ) { - valo = dynvalo->GetSuperClassInstance(); + valo = dynvalo->GetSuperClassInstance() ; } - classInfo->SetProperty( o, propertyInfo->GetName().c_str(), - valClassInfo->ObjectPtrToAny(valo) ); + classInfo->SetProperty( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ; } -void wxObjectRuntimeReaderCallback::SetConnect(int eventSourceObjectID, +void wxRuntimeDepersister::SetConnect(int eventSourceObjectID, const wxClassInfo *WXUNUSED(eventSourceClassInfo), - const wxPropertyInfo *delegateInfo, - const wxClassInfo *WXUNUSED(eventSinkClassInfo), - const wxHandlerInfo* handlerInfo, + const wxPropertyInfo *delegateInfo , + const wxClassInfo *WXUNUSED(eventSinkClassInfo) , + const wxHandlerInfo* handlerInfo , int eventSinkObjectID ) { - wxEvtHandler *ehsource = - wx_dynamic_cast( wxEvtHandler* , m_data->GetObject( eventSourceObjectID ) ); - wxEvtHandler *ehsink = - wx_dynamic_cast( wxEvtHandler *,m_data->GetObject(eventSinkObjectID) ); + wxEvtHandler *ehsource = dynamic_cast< wxEvtHandler* >( m_data->GetObject( eventSourceObjectID ) ) ; + wxEvtHandler *ehsink = dynamic_cast< wxEvtHandler *>(m_data->GetObject(eventSinkObjectID) ) ; if ( ehsource && ehsink ) { - const wxEventSourceTypeInfo *delegateTypeInfo = - wx_dynamic_cast(const wxEventSourceTypeInfo*,delegateInfo->GetTypeInfo()); + const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast(delegateInfo->GetTypeInfo()); if( delegateTypeInfo && delegateTypeInfo->GetLastEventType() == -1 ) { - ehsource->Connect( -1, delegateTypeInfo->GetEventType(), - handlerInfo->GetEventFunction(), NULL /*user data*/, - ehsink ); + ehsource->Connect( -1 , delegateTypeInfo->GetEventType() , + handlerInfo->GetEventFunction() , NULL /*user data*/ , + ehsink ) ; } else { - for ( wxEventType iter = delegateTypeInfo->GetEventType(); - iter <= delegateTypeInfo->GetLastEventType(); ++iter ) + for ( wxEventType iter = delegateTypeInfo->GetEventType() ; iter <= delegateTypeInfo->GetLastEventType() ; ++iter ) { - ehsource->Connect( -1, iter, - handlerInfo->GetEventFunction(), NULL /*user data*/, - ehsink ); + ehsource->Connect( -1 , iter , + handlerInfo->GetEventFunction() , NULL /*user data*/ , + ehsink ) ; } } } } -wxObject *wxObjectRuntimeReaderCallback::GetObject(int objectID) +wxObject *wxRuntimeDepersister::GetObject(int objectID) { - return m_data->GetObject( objectID ); + return m_data->GetObject( objectID ) ; } -void wxObjectRuntimeReaderCallback::AddToPropertyCollection( int objectID, +// adds an element to a property collection +void wxRuntimeDepersister::AddToPropertyCollection( int objectID , const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, - const wxAny &value) + const wxPropertyInfo* propertyInfo , + const wxxVariant &value) { wxObject *o; o = m_data->GetObject(objectID); - classInfo->AddToPropertyCollection( o, propertyInfo->GetName().c_str(), value ); + classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , value ) ; } -void wxObjectRuntimeReaderCallback::AddToPropertyCollectionAsObject(int objectID, +// sets the corresponding property (value is an object) +void wxRuntimeDepersister::AddToPropertyCollectionAsObject(int objectID, const wxClassInfo *classInfo, - const wxPropertyInfo* propertyInfo, + const wxPropertyInfo* propertyInfo , int valueObjectId) { wxObject *o, *valo; o = m_data->GetObject(objectID); valo = m_data->GetObject(valueObjectId); - const wxCollectionTypeInfo * collectionTypeInfo = - wx_dynamic_cast( const wxCollectionTypeInfo *, propertyInfo->GetTypeInfo() ); - const wxClassInfo* valClassInfo = - (wx_dynamic_cast(const wxClassTypeInfo*,collectionTypeInfo->GetElementType()))->GetClassInfo(); - + const wxCollectionTypeInfo * collectionTypeInfo = dynamic_cast< const wxCollectionTypeInfo * >(propertyInfo->GetTypeInfo() ) ; + const wxClassInfo* valClassInfo = (dynamic_cast(collectionTypeInfo->GetElementType()))->GetClassInfo() ; // if this is a dynamic object and we are asked for another class // than wxDynamicObject we cast it down manually. - wxDynamicObject *dynvalo = wx_dynamic_cast( wxDynamicObject *, valo); + wxDynamicObject *dynvalo = dynamic_cast< wxDynamicObject * > (valo) ; if ( dynvalo!=NULL && (valClassInfo != dynvalo->GetClassInfo()) ) { - valo = dynvalo->GetSuperClassInstance(); + valo = dynvalo->GetSuperClassInstance() ; } - classInfo->AddToPropertyCollection( o, propertyInfo->GetName().c_str(), - valClassInfo->ObjectPtrToAny(valo) ); + classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ; } +// ---------------------------------------------------------------------------- +// depersisting to code +// ---------------------------------------------------------------------------- + +struct wxCodeDepersister::wxCodeDepersisterInternal +{ +#if wxUSE_UNICODE + map m_objectNames ; +#else + map m_objectNames ; +#endif + + void SetObjectName(int objectID, const wxString &name ) + { + if ( m_objectNames.find(objectID) != m_objectNames.end() ) + { + wxLogError( _("Passing a already registered object to SetObjectName") ) ; + return ; + } + m_objectNames[objectID] = (const wxChar *)name; + } + + wxString GetObjectName( int objectID ) + { + if ( objectID == wxNullObjectID ) + return wxT("NULL") ; + + if ( m_objectNames.find(objectID) == m_objectNames.end() ) + { + wxLogError( _("Passing an unkown object to GetObject") ) ; + return wxEmptyString ; + } + return wxString( m_objectNames[objectID].c_str() ) ; + } +} ; + +wxCodeDepersister::wxCodeDepersister(wxTextOutputStream *out) +: m_fp(out) +{ + m_data = new wxCodeDepersisterInternal ; +} + +wxCodeDepersister::~wxCodeDepersister() +{ + delete m_data ; +} + +void wxCodeDepersister::AllocateObject(int objectID, wxClassInfo *classInfo , + wxxVariantArray &WXUNUSED(metadata)) +{ + wxString objectName = wxString::Format( wxT("LocalObject_%d") , objectID ) ; + m_fp->WriteString( wxString::Format( wxT("\t%s *%s = new %s;\n"), + classInfo->GetClassName(), + objectName.c_str(), + classInfo->GetClassName()) ); + m_data->SetObjectName( objectID , objectName ) ; +} + +void wxCodeDepersister::DestroyObject(int objectID, wxClassInfo *WXUNUSED(classInfo)) +{ + m_fp->WriteString( wxString::Format( wxT("\tdelete %s;\n"), + m_data->GetObjectName( objectID).c_str() ) ); +} + +wxString wxCodeDepersister::ValueAsCode( const wxxVariant ¶m ) +{ + wxString value ; + const wxTypeInfo* type = param.GetTypeInfo() ; + if ( type->GetKind() == wxT_CUSTOM ) + { + const wxCustomTypeInfo* cti = dynamic_cast(type) ; + if ( cti ) + { + value.Printf( wxT("%s(%s)"), cti->GetTypeName().c_str(),param.GetAsString().c_str() ); + } + else + { + wxLogError ( _("Internal error, illegal wxCustomTypeInfo") ) ; + } + } + else if ( type->GetKind() == wxT_STRING ) + { + value.Printf( wxT("\"%s\""),param.GetAsString().c_str() ); + } + else + { + value.Printf( wxT("%s"), param.GetAsString().c_str() ); + } + return value ; +} + +void wxCodeDepersister::CreateObject(int objectID, + const wxClassInfo *WXUNUSED(classInfo), + int paramCount, + wxxVariant *params, + int *objectIDValues, + const wxClassInfo **WXUNUSED(objectClassInfos) , + wxxVariantArray &WXUNUSED(metadata) + ) +{ + int i; + m_fp->WriteString( wxString::Format( wxT("\t%s->Create("), m_data->GetObjectName(objectID).c_str() ) ); + for (i = 0; i < paramCount; i++) + { + if ( objectIDValues[i] != wxInvalidObjectID ) + m_fp->WriteString( wxString::Format( wxT("%s"), m_data->GetObjectName( objectIDValues[i] ).c_str() ) ); + else + { + m_fp->WriteString( wxString::Format( wxT("%s"), ValueAsCode(params[i]).c_str() ) ); + } + if (i < paramCount - 1) + m_fp->WriteString( wxT(", ")); + } + m_fp->WriteString( wxT(");\n") ); +} + +void wxCodeDepersister::ConstructObject(int objectID, + const wxClassInfo *classInfo, + int paramCount, + wxxVariant *params, + int *objectIDValues, + const wxClassInfo **WXUNUSED(objectClassInfos) , + wxxVariantArray &WXUNUSED(metadata) + ) +{ + wxString objectName = wxString::Format( wxT("LocalObject_%d") , objectID ) ; + m_fp->WriteString( wxString::Format( wxT("\t%s *%s = new %s("), + classInfo->GetClassName(), + objectName.c_str(), + classInfo->GetClassName()) ); + m_data->SetObjectName( objectID , objectName ) ; + + int i; + for (i = 0; i < paramCount; i++) + { + if ( objectIDValues[i] != wxInvalidObjectID ) + m_fp->WriteString( wxString::Format( wxT("%s"), m_data->GetObjectName( objectIDValues[i] ).c_str() ) ); + else + { + m_fp->WriteString( wxString::Format( wxT("%s"), ValueAsCode(params[i]).c_str() ) ); + } + if (i < paramCount - 1) + m_fp->WriteString( wxT(", ") ); + } + m_fp->WriteString( wxT(");\n") ); +} + +void wxCodeDepersister::SetProperty(int objectID, + const wxClassInfo *WXUNUSED(classInfo), + const wxPropertyInfo* propertyInfo, + const wxxVariant &value) +{ + m_fp->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"), + m_data->GetObjectName(objectID).c_str(), + propertyInfo->GetAccessor()->GetSetterName().c_str(), + ValueAsCode(value).c_str()) ); +} + +void wxCodeDepersister::SetPropertyAsObject(int objectID, + const wxClassInfo *WXUNUSED(classInfo), + const wxPropertyInfo* propertyInfo, + int valueObjectId) +{ + if ( propertyInfo->GetTypeInfo()->GetKind() == wxT_OBJECT ) + m_fp->WriteString( wxString::Format( wxT("\t%s->%s(*%s);\n"), + m_data->GetObjectName(objectID).c_str(), + propertyInfo->GetAccessor()->GetSetterName().c_str(), + m_data->GetObjectName( valueObjectId).c_str() ) ); + else + m_fp->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"), + m_data->GetObjectName(objectID).c_str(), + propertyInfo->GetAccessor()->GetSetterName().c_str(), + m_data->GetObjectName( valueObjectId).c_str() ) ); +} + +void wxCodeDepersister::AddToPropertyCollection( int objectID , + const wxClassInfo *WXUNUSED(classInfo), + const wxPropertyInfo* propertyInfo , + const wxxVariant &value) +{ + m_fp->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"), + m_data->GetObjectName(objectID).c_str(), + propertyInfo->GetAccessor()->GetAdderName().c_str(), + ValueAsCode(value).c_str()) ); +} + +// sets the corresponding property (value is an object) +void wxCodeDepersister::AddToPropertyCollectionAsObject(int WXUNUSED(objectID), + const wxClassInfo *WXUNUSED(classInfo), + const wxPropertyInfo* WXUNUSED(propertyInfo) , + int WXUNUSED(valueObjectId)) +{ + // TODO +} + +void wxCodeDepersister::SetConnect(int eventSourceObjectID, + const wxClassInfo *WXUNUSED(eventSourceClassInfo), + const wxPropertyInfo *delegateInfo , + const wxClassInfo *eventSinkClassInfo , + const wxHandlerInfo* handlerInfo , + int eventSinkObjectID ) +{ + wxString ehsource = m_data->GetObjectName( eventSourceObjectID ) ; + wxString ehsink = m_data->GetObjectName(eventSinkObjectID) ; + wxString ehsinkClass = eventSinkClassInfo->GetClassName() ; + const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast(delegateInfo->GetTypeInfo()); + if ( delegateTypeInfo ) + { + int eventType = delegateTypeInfo->GetEventType() ; + wxString handlerName = handlerInfo->GetName() ; + + m_fp->WriteString( wxString::Format( wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") , + ehsource.c_str() , ehsource.c_str() , eventType , ehsinkClass.c_str() , handlerName.c_str() , ehsink.c_str() ) ); + } + else + { + wxLogError(_("delegate has no type info")); + } +} + +#include "wx/arrimpl.cpp" + +WX_DEFINE_OBJARRAY(wxxVariantArray); + #endif // wxUSE_EXTENDED_RTTI diff --git a/Source/3rd Party/wx/src/common/xtixml.cpp b/Source/3rd Party/wx/src/common/xtixml.cpp deleted file mode 100644 index 4a37afe6b..000000000 --- a/Source/3rd Party/wx/src/common/xtixml.cpp +++ /dev/null @@ -1,552 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/common/xtixml.cpp -// Purpose: streaming runtime metadata information -// Author: Stefan Csomor -// Modified by: -// Created: 27/07/03 -// Copyright: (c) 2003 Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_EXTENDED_RTTI - -#include "wx/xtistrm.h" - -#ifndef WX_PRECOMP - #include "wx/object.h" - #include "wx/hash.h" - #include "wx/event.h" -#endif - -#include "wx/xml/xml.h" -#include "wx/tokenzr.h" -#include "wx/txtstrm.h" -#include "wx/xtistrm.h" -#include "wx/xtixml.h" - -// STL headers - -#include "wx/beforestd.h" -#include -#include -#include -#include "wx/afterstd.h" - -using namespace std; - - - - -// ---------------------------------------------------------------------------- -// wxObjectXmlWriter -// ---------------------------------------------------------------------------- - -// convenience functions - -void wxXmlAddContentToNode( wxXmlNode* node, const wxString& data ) -{ - node->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxT("value"), data ) ); -} - -wxString wxXmlGetContentFromNode( wxXmlNode *node ) -{ - if ( node->GetChildren() ) - return node->GetChildren()->GetContent(); - else - return wxEmptyString; -} - -struct wxObjectXmlWriter::wxObjectXmlWriterInternal -{ - wxXmlNode *m_root; - wxXmlNode *m_current; - vector< wxXmlNode * > m_objectStack; - - void Push( wxXmlNode *newCurrent ) - { - m_objectStack.push_back( m_current ); - m_current = newCurrent; - } - - void Pop() - { - m_current = m_objectStack.back(); - m_objectStack.pop_back(); - } -}; - -wxObjectXmlWriter::wxObjectXmlWriter( wxXmlNode * rootnode ) -{ - m_data = new wxObjectXmlWriterInternal(); - m_data->m_root = rootnode; - m_data->m_current = rootnode; -} - -wxObjectXmlWriter::~wxObjectXmlWriter() -{ - delete m_data; -} - -void wxObjectXmlWriter::DoBeginWriteTopLevelEntry( const wxString &name ) -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("entry")); - pnode->AddProperty(wxString(wxT("name")), name); - m_data->m_current->AddChild(pnode); - m_data->Push( pnode ); -} - -void wxObjectXmlWriter::DoEndWriteTopLevelEntry( const wxString &WXUNUSED(name) ) -{ - m_data->Pop(); -} - -void wxObjectXmlWriter::DoBeginWriteObject(const wxObject *WXUNUSED(object), - const wxClassInfo *classInfo, - int objectID, const wxStringToAnyHashMap &metadata ) -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object")); - pnode->AddProperty(wxT("class"), wxString(classInfo->GetClassName())); - pnode->AddProperty(wxT("id"), wxString::Format( wxT("%d"), objectID ) ); - - wxStringToAnyHashMap::const_iterator it, en; - for( it = metadata.begin(), en = metadata.end(); it != en; ++it ) - { - pnode->AddProperty( it->first, wxAnyGetAsString(it->second) ); - } - - m_data->m_current->AddChild(pnode); - m_data->Push( pnode ); -} - -void wxObjectXmlWriter::DoEndWriteObject(const wxObject *WXUNUSED(object), - const wxClassInfo *WXUNUSED(classInfo), - int WXUNUSED(objectID) ) -{ - m_data->Pop(); -} - -void wxObjectXmlWriter::DoWriteSimpleType( const wxAny &value ) -{ - wxXmlAddContentToNode( m_data->m_current,wxAnyGetAsString(value) ); -} - -void wxObjectXmlWriter::DoBeginWriteElement() -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("element") ); - m_data->m_current->AddChild(pnode); - m_data->Push( pnode ); -} - -void wxObjectXmlWriter::DoEndWriteElement() -{ - m_data->Pop(); -} - -void wxObjectXmlWriter::DoBeginWriteProperty(const wxPropertyInfo *pi ) -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("prop") ); - pnode->AddProperty(wxT("name"), pi->GetName() ); - m_data->m_current->AddChild(pnode); - m_data->Push( pnode ); -} - -void wxObjectXmlWriter::DoEndWriteProperty(const wxPropertyInfo *WXUNUSED(propInfo) ) -{ - m_data->Pop(); -} - -void wxObjectXmlWriter::DoWriteRepeatedObject( int objectID ) -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object")); - pnode->AddProperty(wxString(wxT("href")), wxString::Format( wxT("%d"), objectID ) ); - m_data->m_current->AddChild(pnode); -} - -void wxObjectXmlWriter::DoWriteNullObject() -{ - wxXmlNode *pnode; - pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object")); - m_data->m_current->AddChild(pnode); -} - -void wxObjectXmlWriter::DoWriteDelegate( const wxObject *WXUNUSED(object), - const wxClassInfo* WXUNUSED(classInfo), - const wxPropertyInfo *WXUNUSED(pi), - const wxObject *eventSink, int sinkObjectID, - const wxClassInfo* WXUNUSED(eventSinkClassInfo), - const wxHandlerInfo* handlerInfo ) -{ - if ( eventSink != NULL && handlerInfo != NULL ) - { - wxXmlAddContentToNode( m_data->m_current, - wxString::Format(wxT("%d.%s"), sinkObjectID, handlerInfo->GetName().c_str()) ); - } -} - - -// ---------------------------------------------------------------------------- -// wxObjectXmlReader -// ---------------------------------------------------------------------------- - -/* -Reading components has not to be extended for components -as properties are always sought by typeinfo over all levels -and create params are always toplevel class only -*/ - -int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *callbacks) -{ - wxASSERT_MSG( callbacks, wxT("Does not support reading without a Depersistor") ); - wxString className; - wxClassInfo *classInfo; - - wxAny *createParams; - int *createParamOids; - const wxClassInfo** createClassInfos; - wxXmlNode *children; - int objectID; - wxString ObjectIdString; - - children = node->GetChildren(); - if (!children) - { - // check for a null object or href - if (node->GetAttribute(wxT("href"), &ObjectIdString ) ) - { - objectID = atoi( ObjectIdString.ToAscii() ); - if ( HasObjectClassInfo( objectID ) ) - { - return objectID; - } - else - { - wxLogError( _("Forward hrefs are not supported") ); - return wxInvalidObjectID; - } - } - if ( !node->GetAttribute(wxT("id"), &ObjectIdString ) ) - { - return wxNullObjectID; - } - } - if (!node->GetAttribute(wxT("class"), &className)) - { - // No class name. Eek. FIXME: error handling - return wxInvalidObjectID; - } - - classInfo = wxClassInfo::FindClass(className); - if ( classInfo == NULL ) - { - wxLogError( wxString::Format(_("unknown class %s"),className ) ); - return wxInvalidObjectID; - } - - if ( children != NULL && children->GetType() == wxXML_TEXT_NODE ) - { - wxLogError(_("objects cannot have XML Text Nodes") ); - return wxInvalidObjectID; - } - if (!node->GetAttribute(wxT("id"), &ObjectIdString)) - { - wxLogError(_("Objects must have an id attribute") ); - // No object id. Eek. FIXME: error handling - return wxInvalidObjectID; - } - objectID = atoi( ObjectIdString.ToAscii() ); - - // is this object already has been streamed in, return it here - if ( HasObjectClassInfo( objectID ) ) - { - wxLogError ( wxString::Format(_("Doubly used id : %d"), objectID ) ); - return wxInvalidObjectID; - } - - // new object, start with allocation - // first make the object know to our internal registry - SetObjectClassInfo( objectID, classInfo ); - - wxStringToAnyHashMap metadata; - wxXmlProperty *xp = node->GetAttributes(); - while ( xp ) - { - if ( xp->GetName() != wxString(wxT("class")) && - xp->GetName() != wxString(wxT("id")) ) - { - metadata[xp->GetName()] = wxAny( xp->GetValue() ); - } - xp = xp->GetNext(); - } - if ( !classInfo->NeedsDirectConstruction() ) - callbacks->AllocateObject(objectID, classInfo, metadata); - - // - // stream back the Create parameters first - createParams = new wxAny[ classInfo->GetCreateParamCount() ]; - createParamOids = new int[classInfo->GetCreateParamCount() ]; - createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ]; - -#if wxUSE_UNICODE - typedef map PropertyNodes; - typedef vector PropertyNames; -#else - typedef map PropertyNodes; - typedef vector PropertyNames; -#endif - PropertyNodes propertyNodes; - PropertyNames propertyNames; - - while( children ) - { - wxString name; - children->GetAttribute( wxT("name"), &name ); - propertyNames.push_back( (const wxChar*)name.c_str() ); - propertyNodes[(const wxChar*)name.c_str()] = children->GetChildren(); - children = children->GetNext(); - } - - for ( int i = 0; i GetCreateParamCount(); ++i ) - { - const wxChar* paramName = classInfo->GetCreateParamName(i); - PropertyNodes::iterator propiter = propertyNodes.find( paramName ); - const wxPropertyInfo* pi = classInfo->FindPropertyInfo( paramName ); - if ( pi == 0 ) - { - wxLogError( wxString::Format(_("Unknown Property %s"),paramName) ); - } - // if we don't have the value of a create param set in the xml - // we use the default value - if ( propiter != propertyNodes.end() ) - { - wxXmlNode* prop = propiter->second; - if ( pi->GetTypeInfo()->IsObjectType() ) - { - createParamOids[i] = ReadComponent( prop, callbacks ); - createClassInfos[i] = - wx_dynamic_cast(const wxClassTypeInfo*, pi->GetTypeInfo())->GetClassInfo(); - } - else - { - createParamOids[i] = wxInvalidObjectID; - createParams[i] = ReadValue( prop, pi->GetTypeInfo() ); - if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG ) - { - const wxEnumTypeInfo *eti = - wx_dynamic_cast(const wxEnumTypeInfo*, pi->GetTypeInfo() ); - if ( eti ) - { - long realval; - eti->ConvertToLong( createParams[i], realval ); - createParams[i] = wxAny( realval ); - } - else - { - wxLogError( _("Type must have enum - long conversion") ); - } - } - createClassInfos[i] = NULL; - } - - for ( size_t j = 0; j < propertyNames.size(); ++j ) - { - if ( propertyNames[j] == paramName ) - { - propertyNames[j] = wxEmptyString; - break; - } - } - } - else - { - if ( pi->GetTypeInfo()->IsObjectType() ) - { - createParamOids[i] = wxNullObjectID; - createClassInfos[i] = - wx_dynamic_cast(const wxClassTypeInfo*, pi->GetTypeInfo())->GetClassInfo(); - } - else - { - createParams[i] = pi->GetDefaultValue(); - createParamOids[i] = wxInvalidObjectID; - } - } - } - - // got the parameters. Call the Create method - if ( classInfo->NeedsDirectConstruction() ) - callbacks->ConstructObject(objectID, classInfo, - classInfo->GetCreateParamCount(), - createParams, createParamOids, createClassInfos, metadata ); - else - callbacks->CreateObject(objectID, classInfo, - classInfo->GetCreateParamCount(), - createParams, createParamOids, createClassInfos, metadata ); - - // now stream in the rest of the properties, in the sequence their - // properties were written in the xml - for ( size_t j = 0; j < propertyNames.size(); ++j ) - { - if ( !propertyNames[j].empty() ) - { - PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] ); - if ( propiter != propertyNodes.end() ) - { - wxXmlNode* prop = propiter->second; - const wxPropertyInfo* pi = - classInfo->FindPropertyInfo( propertyNames[j].c_str() ); - if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION ) - { - const wxCollectionTypeInfo* collType = - wx_dynamic_cast( const wxCollectionTypeInfo*, pi->GetTypeInfo() ); - const wxTypeInfo * elementType = collType->GetElementType(); - while( prop ) - { - if ( prop->GetName() != wxT("element") ) - { - wxLogError( _("A non empty collection must consist of 'element' nodes" ) ); - break; - } - - wxXmlNode* elementContent = prop->GetChildren(); - if ( elementContent ) - { - // we skip empty elements - if ( elementType->IsObjectType() ) - { - int valueId = ReadComponent( elementContent, callbacks ); - if ( valueId != wxInvalidObjectID ) - { - if ( pi->GetAccessor()->HasAdder() ) - callbacks->AddToPropertyCollectionAsObject( objectID, classInfo, pi, valueId ); - // TODO for collections we must have a notation on taking over ownership or not - if ( elementType->GetKind() == wxT_OBJECT && valueId != wxNullObjectID ) - callbacks->DestroyObject( valueId, GetObjectClassInfo( valueId ) ); - } - } - else - { - wxAny elementValue = ReadValue( elementContent, elementType ); - if ( pi->GetAccessor()->HasAdder() ) - callbacks->AddToPropertyCollection( objectID, classInfo,pi, elementValue ); - } - } - prop = prop->GetNext(); - } - } - else if ( pi->GetTypeInfo()->IsObjectType() ) - { - // and object can either be streamed out a string or as an object - // in case we have no node, then the object's streaming out has been vetoed - if ( prop ) - { - if ( prop->GetName() == wxT("object") ) - { - int valueId = ReadComponent( prop, callbacks ); - if ( valueId != wxInvalidObjectID ) - { - callbacks->SetPropertyAsObject( objectID, classInfo, pi, valueId ); - if ( pi->GetTypeInfo()->GetKind() == wxT_OBJECT && valueId != wxNullObjectID ) - callbacks->DestroyObject( valueId, GetObjectClassInfo( valueId ) ); - } - } - else - { - wxASSERT( pi->GetTypeInfo()->HasStringConverters() ); - wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() ); - callbacks->SetProperty( objectID, classInfo,pi, nodeval ); - } - } - } - else if ( pi->GetTypeInfo()->IsDelegateType() ) - { - if ( prop ) - { - wxString resstring = prop->GetContent(); - wxInt32 pos = resstring.Find('.'); - if ( pos != wxNOT_FOUND ) - { - int sinkOid = atol(resstring.Left(pos).ToAscii()); - wxString handlerName = resstring.Mid(pos+1); - wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ); - - callbacks->SetConnect( objectID, classInfo, pi, sinkClassInfo, - sinkClassInfo->FindHandlerInfo(handlerName.c_str()), sinkOid ); - } - else - { - wxLogError( _("incorrect event handler string, missing dot") ); - } - } - - } - else - { - wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() ); - if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG ) - { - const wxEnumTypeInfo *eti = - wx_dynamic_cast(const wxEnumTypeInfo*, pi->GetTypeInfo() ); - if ( eti ) - { - long realval; - eti->ConvertToLong( nodeval, realval ); - nodeval = wxAny( realval ); - } - else - { - wxLogError( _("Type must have enum - long conversion") ); - } - } - callbacks->SetProperty( objectID, classInfo,pi, nodeval ); - } - } - } - } - - delete[] createParams; - delete[] createParamOids; - delete[] createClassInfos; - - return objectID; -} - -wxAny wxObjectXmlReader::ReadValue(wxXmlNode *node, - const wxTypeInfo *type ) -{ - wxString content; - if ( node ) - content = node->GetContent(); - wxAny result; - type->ConvertFromString( content, result ); - return result; -} - -int wxObjectXmlReader::ReadObject( const wxString &name, wxObjectReaderCallback *callbacks) -{ - wxXmlNode *iter = m_parent->GetChildren(); - while ( iter ) - { - wxString entryName; - if ( iter->GetAttribute(wxT("name"), &entryName) ) - { - if ( entryName == name ) - return ReadComponent( iter->GetChildren(), callbacks ); - } - iter = iter->GetNext(); - } - return wxInvalidObjectID; -} - -#endif // wxUSE_EXTENDED_RTTI diff --git a/Source/3rd Party/wx/src/common/zipstrm.cpp b/Source/3rd Party/wx/src/common/zipstrm.cpp index 07b526d15..a77df8dc8 100644 --- a/Source/3rd Party/wx/src/common/zipstrm.cpp +++ b/Source/3rd Party/wx/src/common/zipstrm.cpp @@ -2,6 +2,7 @@ // Name: src/common/zipstrm.cpp // Purpose: Streams for Zip files // Author: Mike Wetherell +// RCS-ID: $Id: zipstrm.cpp 51009 2008-01-03 17:11:45Z MW $ // Copyright: (c) Mike Wetherell // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -27,7 +28,7 @@ #include "wx/datstrm.h" #include "wx/zstream.h" #include "wx/mstream.h" -#include "wx/scopedptr.h" +#include "wx/ptr_scpd.h" #include "wx/wfstream.h" #include "zlib.h" @@ -124,7 +125,7 @@ static inline wxUint16 CrackUint16(const char *m) // static wxFileOffset QuietSeek(wxInputStream& stream, wxFileOffset pos) { -#if wxUSE_LOG +#if defined(__WXDEBUG__) && wxUSE_LOG wxLogLevel level = wxLog::GetLogLevel(); wxLog::SetLogLevel(wxLOG_Debug - 1); wxFileOffset result = stream.SeekI(pos); @@ -139,7 +140,7 @@ static wxFileOffset QuietSeek(wxInputStream& stream, wxFileOffset pos) ///////////////////////////////////////////////////////////////////////////// // Class factory -static wxZipClassFactory g_wxZipClassFactory; +wxZipClassFactory g_wxZipClassFactory; wxZipClassFactory::wxZipClassFactory() { @@ -150,9 +151,9 @@ wxZipClassFactory::wxZipClassFactory() const wxChar * const * wxZipClassFactory::GetProtocols(wxStreamProtocolType type) const { - static const wxChar *protocols[] = { wxT("zip"), NULL }; - static const wxChar *mimetypes[] = { wxT("application/zip"), NULL }; - static const wxChar *fileexts[] = { wxT(".zip"), wxT(".htb"), NULL }; + static const wxChar *protocols[] = { _T("zip"), NULL }; + static const wxChar *mimetypes[] = { _T("application/zip"), NULL }; + static const wxChar *fileexts[] = { _T(".zip"), _T(".htb"), NULL }; static const wxChar *empty[] = { NULL }; switch (type) { @@ -199,7 +200,7 @@ wxZipHeader::wxZipHeader(wxInputStream& stream, size_t size) m_pos(0), m_ok(false) { - wxCHECK_RET(size <= sizeof(m_data), wxT("buffer too small")); + wxCHECK_RET(size <= sizeof(m_data), _T("buffer too small")); m_size = stream.Read(m_data, size).LastRead(); m_ok = m_size == size; } @@ -250,7 +251,7 @@ private: wxFileOffset m_pos; wxFileOffset m_len; - wxDECLARE_NO_COPY_CLASS(wxStoredInputStream); + DECLARE_NO_COPY_CLASS(wxStoredInputStream) }; wxStoredInputStream::wxStoredInputStream(wxInputStream& stream) @@ -296,7 +297,7 @@ protected: private: wxFileOffset m_pos; - wxDECLARE_NO_COPY_CLASS(wxStoredOutputStream); + DECLARE_NO_COPY_CLASS(wxStoredOutputStream) }; size_t wxStoredOutputStream::OnSysWrite(const void *buffer, size_t size) @@ -358,7 +359,7 @@ private: size_t m_start; size_t m_end; - wxDECLARE_NO_COPY_CLASS(wxTeeInputStream); + DECLARE_NO_COPY_CLASS(wxTeeInputStream) }; wxTeeInputStream::wxTeeInputStream(wxInputStream& stream) @@ -454,7 +455,7 @@ private: enum { BUFSIZE = 8192 }; wxCharBuffer m_dummy; - wxDECLARE_NO_COPY_CLASS(wxRawInputStream); + DECLARE_NO_COPY_CLASS(wxRawInputStream) }; wxRawInputStream::wxRawInputStream(wxInputStream& stream) @@ -785,15 +786,15 @@ wxString wxZipEntry::GetName(wxPathFormat format /*=wxPATH_NATIVE*/) const switch (wxFileName::GetFormat(format)) { case wxPATH_DOS: { - wxString name(isDir ? m_Name + wxT("\\") : m_Name); + wxString name(isDir ? m_Name + _T("\\") : m_Name); for (size_t i = 0; i < name.length(); i++) - if (name[i] == wxT('/')) - name[i] = wxT('\\'); + if (name[i] == _T('/')) + name[i] = _T('\\'); return name; } case wxPATH_UNIX: - return isDir ? m_Name + wxT("/") : m_Name; + return isDir ? m_Name + _T("/") : m_Name; default: ; @@ -833,9 +834,9 @@ wxString wxZipEntry::GetInternalName(const wxString& name, while (!internal.empty() && *internal.begin() == '/') internal.erase(0, 1); - while (!internal.empty() && internal.compare(0, 2, wxT("./")) == 0) + while (!internal.empty() && internal.compare(0, 2, _T("./")) == 0) internal.erase(0, 2); - if (internal == wxT(".") || internal == wxT("..")) + if (internal == _T(".") || internal == _T("..")) internal = wxEmptyString; return internal; @@ -1003,7 +1004,7 @@ size_t wxZipEntry::ReadLocal(wxInputStream& stream, wxMBConv& conv) size_t wxZipEntry::WriteLocal(wxOutputStream& stream, wxMBConv& conv) const { wxString unixName = GetName(wxPATH_UNIX); - const wxWX2MBbuf name_buf = unixName.mb_str(conv); + const wxWX2MBbuf name_buf = conv.cWX2MB(unixName); const char *name = name_buf; if (!name) name = ""; wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name)); @@ -1079,12 +1080,12 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv) size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const { wxString unixName = GetName(wxPATH_UNIX); - const wxWX2MBbuf name_buf = unixName.mb_str(conv); + const wxWX2MBbuf name_buf = conv.cWX2MB(unixName); const char *name = name_buf; if (!name) name = ""; wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name)); - const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv); + const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment); const char *comment = comment_buf; if (!comment) comment = ""; wxUint16 commentLen = wx_truncate_cast(wxUint16, strlen(comment)); @@ -1234,7 +1235,7 @@ wxZipEndRec::wxZipEndRec() bool wxZipEndRec::Write(wxOutputStream& stream, wxMBConv& conv) const { - const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv); + const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment); const char *comment = comment_buf; if (!comment) comment = ""; wxUint16 commentLen = (wxUint16)strlen(comment); @@ -1268,9 +1269,7 @@ bool wxZipEndRec::Read(wxInputStream& stream, wxMBConv& conv) if (m_DiskNumber != 0 || m_StartDisk != 0 || m_EntriesHere != m_TotalEntries) - { wxLogWarning(_("assuming this is a multi-part zip concatenated")); - } return true; } @@ -1337,10 +1336,10 @@ void wxZipInputStream::Init(const wxString& file) Init(); m_allowSeeking = true; wxFFileInputStream *ffile; - ffile = static_cast(m_parent_i_stream); + ffile = wx_static_cast(wxFFileInputStream*, m_parent_i_stream); wxZipEntryPtr_ entry; - if (ffile->IsOk()) { + if (ffile->Ok()) { do { entry.reset(GetNextEntry()); } @@ -1464,13 +1463,11 @@ bool wxZipInputStream::LoadEndRecord() m_TotalEntries = endrec.GetTotalEntries(); m_Comment = endrec.GetComment(); - wxUint32 magic = m_TotalEntries ? CENTRAL_MAGIC : END_MAGIC; - // Now find the central-directory. we have the file offset of // the CD, so look there first. if (m_parent_i_stream->SeekI(endrec.GetOffset()) != wxInvalidOffset && - ReadSignature() == magic) { - m_signature = magic; + ReadSignature() == CENTRAL_MAGIC) { + m_signature = CENTRAL_MAGIC; m_position = endrec.GetOffset(); m_offsetAdjustment = 0; return true; @@ -1480,8 +1477,8 @@ bool wxZipInputStream::LoadEndRecord() // to a self extractor, so take the CD size (also in endrec), subtract // it from the file offset of the end-central-directory and look there. if (m_parent_i_stream->SeekI(endPos - endrec.GetSize()) - != wxInvalidOffset && ReadSignature() == magic) { - m_signature = magic; + != wxInvalidOffset && ReadSignature() == CENTRAL_MAGIC) { + m_signature = CENTRAL_MAGIC; m_position = endPos - endrec.GetSize(); m_offsetAdjustment = m_position - endrec.GetOffset(); return true; @@ -1772,7 +1769,7 @@ bool wxZipInputStream::OpenDecompressor(bool raw /*=false*/) return IsOk(); } -// Can be overridden to add support for additional decompression methods +// Can be overriden to add support for additional decompression methods // wxInputStream *wxZipInputStream::OpenDecompressor(wxInputStream& stream) { @@ -1873,19 +1870,13 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t size) m_lasterror = wxSTREAM_READ_ERROR; if (m_entry.GetSize() != TellI()) - { wxLogError(_("reading zip stream (entry %s): bad length"), m_entry.GetName().c_str()); - } else if (m_crcAccumulator != m_entry.GetCrc()) - { wxLogError(_("reading zip stream (entry %s): bad crc"), m_entry.GetName().c_str()); - } else - { m_lasterror = wxSTREAM_EOF; - } } } @@ -1997,7 +1988,6 @@ void wxZipOutputStream::Init(int level) m_comp = NULL; m_level = level; m_offsetAdjustment = wxInvalidOffset; - m_endrecWritten = false; } wxZipOutputStream::~wxZipOutputStream() @@ -2058,7 +2048,7 @@ bool wxZipOutputStream::CopyEntry(wxArchiveEntry *entry, return false; } - return CopyEntry(zipEntry, static_cast(stream)); + return CopyEntry(zipEntry, wx_static_cast(wxZipInputStream&, stream)); } bool wxZipOutputStream::CopyArchiveMetaData(wxZipInputStream& inputStream) @@ -2072,7 +2062,7 @@ bool wxZipOutputStream::CopyArchiveMetaData(wxZipInputStream& inputStream) bool wxZipOutputStream::CopyArchiveMetaData(wxArchiveInputStream& stream) { - return CopyArchiveMetaData(static_cast(stream)); + return CopyArchiveMetaData(wx_static_cast(wxZipInputStream&, stream)); } void wxZipOutputStream::SetLevel(int level) @@ -2127,7 +2117,7 @@ bool wxZipOutputStream::DoCreate(wxZipEntry *entry, bool raw /*=false*/) return true; } -// Can be overridden to add support for additional compression methods +// Can be overriden to add support for additional compression methods // wxOutputStream *wxZipOutputStream::OpenCompressor( wxOutputStream& stream, @@ -2297,9 +2287,7 @@ bool wxZipOutputStream::Close() { CloseEntry(); - if (m_lasterror == wxSTREAM_WRITE_ERROR - || (m_entries.size() == 0 && m_endrecWritten)) - { + if (m_lasterror == wxSTREAM_WRITE_ERROR || m_entries.size() == 0) { wxFilterOutputStream::Close(); return false; } @@ -2324,8 +2312,7 @@ bool wxZipOutputStream::Close() endrec.Write(*m_parent_o_stream, GetConv()); m_lasterror = m_parent_o_stream->GetLastError(); - m_endrecWritten = true; - + if (!wxFilterOutputStream::Close() || !IsOk()) return false; m_lasterror = wxSTREAM_EOF; diff --git a/Source/3rd Party/wx/src/common/zstream.cpp b/Source/3rd Party/wx/src/common/zstream.cpp index e10e3d774..8f66fce17 100644 --- a/Source/3rd Party/wx/src/common/zstream.cpp +++ b/Source/3rd Party/wx/src/common/zstream.cpp @@ -4,6 +4,7 @@ // Author: Guilhem Lavaux // Modified by: Mike Wetherell // Created: 11/07/98 +// RCS-ID: $Id: zstream.cpp 42621 2006-10-29 16:47:20Z MW $ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,7 +19,6 @@ #if wxUSE_ZLIB && wxUSE_STREAMS #include "wx/zstream.h" -#include "wx/versioninfo.h" #ifndef WX_PRECOMP #include "wx/intl.h" @@ -31,7 +31,7 @@ // apparently not the case for all MSW makefiles and so, unless we use // configure (which defines __WX_SETUP_H__) or it is explicitly overridden by // the user (who can define wxUSE_ZLIB_H_IN_PATH), we hardcode the path here -#if defined(__WINDOWS__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH) +#if defined(__WXMSW__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH) #include "../zlib/zlib.h" #else #include "zlib.h" @@ -44,22 +44,6 @@ enum { }; -wxVersionInfo wxGetZlibVersionInfo() -{ - int major, - minor, - build; - - if ( sscanf(zlibVersion(), "%d.%d.%d", &major, &minor, &build) != 3 ) - { - major = - minor = - build = 0; - } - - return wxVersionInfo("zlib", major, minor, build); -} - ///////////////////////////////////////////////////////////////////////////// // Zlib Class factory @@ -76,8 +60,8 @@ wxZlibClassFactory::wxZlibClassFactory() const wxChar * const * wxZlibClassFactory::GetProtocols(wxStreamProtocolType type) const { - static const wxChar *mimes[] = { wxT("application/x-deflate"), NULL }; - static const wxChar *encs[] = { wxT("deflate"), NULL }; + static const wxChar *mimes[] = { _T("application/x-deflate"), NULL }; + static const wxChar *encs[] = { _T("deflate"), NULL }; static const wxChar *empty[] = { NULL }; switch (type) { @@ -104,14 +88,14 @@ wxGzipClassFactory::wxGzipClassFactory() const wxChar * const * wxGzipClassFactory::GetProtocols(wxStreamProtocolType type) const { - static const wxChar *protos[] = - { wxT("gzip"), NULL }; - static const wxChar *mimes[] = - { wxT("application/gzip"), wxT("application/x-gzip"), NULL }; - static const wxChar *encs[] = - { wxT("gzip"), NULL }; - static const wxChar *exts[] = - { wxT(".gz"), wxT(".gzip"), NULL }; + static const wxChar *protos[] = + { _T("gzip"), NULL }; + static const wxChar *mimes[] = + { _T("application/gzip"), _T("application/x-gzip"), NULL }; + static const wxChar *encs[] = + { _T("gzip"), NULL }; + static const wxChar *exts[] = + { _T(".gz"), _T(".gzip"), NULL }; static const wxChar *empty[] = { NULL }; @@ -148,6 +132,13 @@ void wxZlibInputStream::Init(int flags) m_z_size = ZSTREAM_BUFFER_SIZE; m_pos = 0; +#if WXWIN_COMPATIBILITY_2_4 + // treat compatibility mode as auto + m_24compatibilty = flags == wxZLIB_24COMPATIBLE; + if (m_24compatibilty) + flags = wxZLIB_AUTO; +#endif + // if gzip is asked for but not supported... if ((flags == wxZLIB_GZIP || flags == wxZLIB_AUTO) && !CanHandleGZip()) { if (flags == wxZLIB_AUTO) { @@ -240,9 +231,12 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size) // by the parent strean, m_lasterror = wxSTREAM_READ_ERROR; if (m_parent_i_stream->Eof()) - { +#if WXWIN_COMPATIBILITY_2_4 + if (m_24compatibilty) + m_lasterror = wxSTREAM_EOF; + else +#endif wxLogError(_("Can't read inflate stream: unexpected EOF in underlying stream.")); - } break; default: @@ -266,16 +260,6 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size) return major > 1 || (major == 1 && minor >= 2); } -bool wxZlibInputStream::SetDictionary(const char *data, const size_t datalen) -{ - return (inflateSetDictionary(m_inflate, (Bytef*)data, datalen) == Z_OK); -} - -bool wxZlibInputStream::SetDictionary(const wxMemoryBuffer &buf) -{ - return SetDictionary((char*)buf.GetData(), buf.GetDataLen()); -} - ////////////////////// // wxZlibOutputStream @@ -351,8 +335,11 @@ bool wxZlibOutputStream::Close() { DoFlush(true); deflateEnd(m_deflate); - wxDELETE(m_deflate); - wxDELETEA(m_z_buffer); + delete m_deflate; + + m_deflate = NULL; + delete[] m_z_buffer; + m_z_buffer = NULL; return wxFilterOutputStream::Close() && IsOk(); } @@ -437,15 +424,5 @@ size_t wxZlibOutputStream::OnSysWrite(const void *buffer, size_t size) return wxZlibInputStream::CanHandleGZip(); } -bool wxZlibOutputStream::SetDictionary(const char *data, const size_t datalen) -{ - return (deflateSetDictionary(m_deflate, (Bytef*)data, datalen) == Z_OK); -} - -bool wxZlibOutputStream::SetDictionary(const wxMemoryBuffer &buf) -{ - return SetDictionary((char*)buf.GetData(), buf.GetDataLen()); -} - #endif // wxUSE_ZLIB && wxUSE_STREAMS diff --git a/Source/3rd Party/wx/src/generic/aboutdlgg.cpp b/Source/3rd Party/wx/src/generic/aboutdlgg.cpp deleted file mode 100644 index 9cb175334..000000000 --- a/Source/3rd Party/wx/src/generic/aboutdlgg.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/aboutdlgg.cpp -// Purpose: implements wxGenericAboutBox() function -// Author: Vadim Zeitlin -// Created: 2006-10-08 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ABOUTDLG - -#ifndef WX_PRECOMP - #include "wx/sizer.h" - #include "wx/statbmp.h" - #include "wx/stattext.h" - #include "wx/button.h" -#endif //WX_PRECOMP - -#include "wx/aboutdlg.h" -#include "wx/generic/aboutdlgg.h" - -#include "wx/hyperlink.h" -#include "wx/collpane.h" - -// ============================================================================ -// implementation -// ============================================================================ - -// helper function: returns all array elements in a single comma-separated and -// newline-terminated string -static wxString AllAsString(const wxArrayString& a) -{ - wxString s; - const size_t count = a.size(); - s.reserve(20*count); - for ( size_t n = 0; n < count; n++ ) - { - s << a[n] << (n == count - 1 ? wxT("\n") : wxT(", ")); - } - - return s; -} - -// ---------------------------------------------------------------------------- -// wxAboutDialogInfo -// ---------------------------------------------------------------------------- - -wxString wxAboutDialogInfo::GetDescriptionAndCredits() const -{ - wxString s = GetDescription(); - if ( !s.empty() ) - s << wxT('\n'); - - if ( HasDevelopers() ) - s << wxT('\n') << _("Developed by ") << AllAsString(GetDevelopers()); - - if ( HasDocWriters() ) - s << wxT('\n') << _("Documentation by ") << AllAsString(GetDocWriters()); - - if ( HasArtists() ) - s << wxT('\n') << _("Graphics art by ") << AllAsString(GetArtists()); - - if ( HasTranslators() ) - s << wxT('\n') << _("Translations by ") << AllAsString(GetTranslators()); - - return s; -} - -wxIcon wxAboutDialogInfo::GetIcon() const -{ - wxIcon icon = m_icon; - if ( !icon.IsOk() && wxTheApp ) - { - const wxTopLevelWindow * const - tlw = wxDynamicCast(wxTheApp->GetTopWindow(), wxTopLevelWindow); - if ( tlw ) - icon = tlw->GetIcon(); - } - - return icon; -} - -wxString wxAboutDialogInfo::GetCopyrightToDisplay() const -{ - wxString ret = m_copyright; - -#if wxUSE_UNICODE - const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9"); - ret.Replace("(c)", copyrightSign); - ret.Replace("(C)", copyrightSign); -#endif // wxUSE_UNICODE - - return ret; -} - -void wxAboutDialogInfo::SetVersion(const wxString& version, - const wxString& longVersion) -{ - if ( version.empty() ) - { - m_version.clear(); - - wxASSERT_MSG( longVersion.empty(), - "long version should be empty if version is"); - - m_longVersion.clear(); - } - else // setting valid version - { - m_version = version; - - if ( longVersion.empty() ) - m_longVersion = _("Version ") + m_version; - else - m_longVersion = longVersion; - } -} - -// ---------------------------------------------------------------------------- -// wxGenericAboutDialog -// ---------------------------------------------------------------------------- - -bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* parent) -{ - if ( !wxDialog::Create(parent, wxID_ANY, wxString::Format(_("About %s"), info.GetName()), - wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) ) - return false; - - m_sizerText = new wxBoxSizer(wxVERTICAL); - wxString nameAndVersion = info.GetName(); - if ( info.HasVersion() ) - nameAndVersion << wxT(' ') << info.GetVersion(); - wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion); - wxFont fontBig(*wxNORMAL_FONT); - fontBig.SetPointSize(fontBig.GetPointSize() + 2); - fontBig.SetWeight(wxFONTWEIGHT_BOLD); - label->SetFont(fontBig); - - m_sizerText->Add(label, wxSizerFlags().Centre().Border()); - m_sizerText->AddSpacer(5); - - AddText(info.GetCopyrightToDisplay()); - AddText(info.GetDescription()); - - if ( info.HasWebSite() ) - { -#if wxUSE_HYPERLINKCTRL - AddControl(new wxHyperlinkCtrl(this, wxID_ANY, - info.GetWebSiteDescription(), - info.GetWebSiteURL())); -#else - AddText(info.GetWebSiteURL()); -#endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL - } - -#if wxUSE_COLLPANE - if ( info.HasLicence() ) - AddCollapsiblePane(_("License"), info.GetLicence()); - - if ( info.HasDevelopers() ) - AddCollapsiblePane(_("Developers"), - AllAsString(info.GetDevelopers())); - - if ( info.HasDocWriters() ) - AddCollapsiblePane(_("Documentation writers"), - AllAsString(info.GetDocWriters())); - - if ( info.HasArtists() ) - AddCollapsiblePane(_("Artists"), - AllAsString(info.GetArtists())); - - if ( info.HasTranslators() ) - AddCollapsiblePane(_("Translators"), - AllAsString(info.GetTranslators())); -#endif // wxUSE_COLLPANE - - DoAddCustomControls(); - - - wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL); -#if wxUSE_STATBMP - wxIcon icon = info.GetIcon(); - if ( icon.IsOk() ) - { - sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon), - wxSizerFlags().Border(wxRIGHT)); - } -#endif // wxUSE_STATBMP - sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand()); - - wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); - sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border()); - -// Mac typically doesn't use OK buttons just for dismissing dialogs. -#if !defined(__WXMAC__) - wxSizer *sizerBtns = CreateButtonSizer(wxOK); - if ( sizerBtns ) - { - sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border()); - } -#endif - - SetSizerAndFit(sizerTop); - - CentreOnParent(); - -#if !wxUSE_MODAL_ABOUT_DIALOG - Connect(wxEVT_CLOSE_WINDOW, - wxCloseEventHandler(wxGenericAboutDialog::OnCloseWindow)); - Connect(wxID_OK, wxEVT_BUTTON, - wxCommandEventHandler(wxGenericAboutDialog::OnOK)); -#endif // !wxUSE_MODAL_ABOUT_DIALOG - - return true; -} - -void wxGenericAboutDialog::AddControl(wxWindow *win, const wxSizerFlags& flags) -{ - wxCHECK_RET( m_sizerText, wxT("can only be called after Create()") ); - wxASSERT_MSG( win, wxT("can't add NULL window to about dialog") ); - - m_sizerText->Add(win, flags); -} - -void wxGenericAboutDialog::AddControl(wxWindow *win) -{ - AddControl(win, wxSizerFlags().Border(wxDOWN).Centre()); -} - -void wxGenericAboutDialog::AddText(const wxString& text) -{ - if ( !text.empty() ) - AddControl(new wxStaticText(this, wxID_ANY, text)); -} - -#if wxUSE_COLLPANE -void wxGenericAboutDialog::AddCollapsiblePane(const wxString& title, - const wxString& text) -{ - wxCollapsiblePane *pane = new wxCollapsiblePane(this, wxID_ANY, title); - wxWindow * const paneContents = pane->GetPane(); - wxStaticText *txt = new wxStaticText(paneContents, wxID_ANY, text, - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); - - // don't make the text unreasonably wide - static const int maxWidth = wxGetDisplaySize().x/3; - txt->Wrap(maxWidth); - - - // we need a sizer to make this text expand to fill the entire pane area - wxSizer * const sizerPane = new wxBoxSizer(wxHORIZONTAL); - sizerPane->Add(txt, wxSizerFlags(1).Expand()); - paneContents->SetSizer(sizerPane); - - // NB: all the wxCollapsiblePanes must be added with a null proportion value - m_sizerText->Add(pane, wxSizerFlags(0).Expand().Border(wxBOTTOM)); -} -#endif - -#if !wxUSE_MODAL_ABOUT_DIALOG - -void wxGenericAboutDialog::OnCloseWindow(wxCloseEvent& event) -{ - // safeguards in case the window is still shown using ShowModal - if ( !IsModal() ) - Destroy(); - - event.Skip(); -} - -void wxGenericAboutDialog::OnOK(wxCommandEvent& event) -{ - // safeguards in case the window is still shown using ShowModal - if ( !IsModal() ) - { - // By default a modeless dialog would be just hidden, destroy this one - // instead. - Destroy(); - } - else - event.Skip(); -} - -#endif // !wxUSE_MODAL_ABOUT_DIALOG - -// ---------------------------------------------------------------------------- -// public functions -// ---------------------------------------------------------------------------- - -void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) -{ -#if wxUSE_MODAL_ABOUT_DIALOG - wxGenericAboutDialog dlg(info, parent); - dlg.ShowModal(); -#else - wxGenericAboutDialog* dlg = new wxGenericAboutDialog(info, parent); - dlg->Show(); -#endif -} - -// currently wxAboutBox is implemented natively only under these platforms, for -// the others we provide a generic fallback here -#if !defined(__WXMSW__) && !defined(__WXMAC__) && \ - (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__)) - -void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) -{ - wxGenericAboutBox(info, parent); -} - -#endif // platforms without native about dialog - - -#endif // wxUSE_ABOUTDLG diff --git a/Source/3rd Party/wx/src/generic/accel.cpp b/Source/3rd Party/wx/src/generic/accel.cpp deleted file mode 100644 index e540ec9c0..000000000 --- a/Source/3rd Party/wx/src/generic/accel.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/accel.cpp -// Purpose: generic implementation of wxAcceleratorTable class -// Author: Robert Roebling -// Modified: VZ pn 31.05.01: use typed lists, Unicode cleanup, Add/Remove -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ACCEL - -#ifndef WX_PRECOMP - #include "wx/list.h" - #include "wx/event.h" -#endif // WX_PRECOMP - -#include "wx/accel.h" - -#include - -// ---------------------------------------------------------------------------- -// 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 wxAccelRefData : public wxObjectRefData -{ -public: - wxAccelRefData() - { - } - - wxAccelRefData(const wxAccelRefData& data) - : wxObjectRefData() - { - m_accels = data.m_accels; - } - - virtual ~wxAccelRefData() - { - WX_CLEAR_LIST(wxAccelList, m_accels); - } - - wxAccelList m_accels; -}; - -// macro which can be used to access wxAccelRefData from wxAcceleratorTable -#define M_ACCELDATA ((wxAccelRefData *)m_refData) - - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxAcceleratorTable ctors -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) - -wxAcceleratorTable::wxAcceleratorTable() -{ -} - -wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) -{ - m_refData = new wxAccelRefData; - - for ( int i = 0; i < n; i++ ) - { - const wxAcceleratorEntry& entry = entries[i]; - - int keycode = entry.GetKeyCode(); - if ( wxIsascii(keycode) ) - keycode = wxToupper(keycode); - - M_ACCELDATA->m_accels.Append(new wxAcceleratorEntry(entry.GetFlags(), - keycode, - entry.GetCommand())); - } -} - -wxAcceleratorTable::~wxAcceleratorTable() -{ -} - -bool wxAcceleratorTable::IsOk() const -{ - return m_refData != NULL; -} - -// ---------------------------------------------------------------------------- -// wxAcceleratorTable updating -// ---------------------------------------------------------------------------- - -void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry) -{ - AllocExclusive(); - - if ( !m_refData ) - { - m_refData = new wxAccelRefData; - } - - M_ACCELDATA->m_accels.Append(new wxAcceleratorEntry(entry)); -} - -void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry) -{ - AllocExclusive(); - - wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); - while ( node ) - { - const wxAcceleratorEntry *entryCur = node->GetData(); - - // given entry contains only the information of the accelerator key - // because it was set that way during creation so do not use the - // comparison operator which also checks the command field - if ((entryCur->GetKeyCode() == entry.GetKeyCode()) && - (entryCur->GetFlags() == entry.GetFlags())) - { - delete node->GetData(); - M_ACCELDATA->m_accels.Erase(node); - - return; - } - - node = node->GetNext(); - } - - wxFAIL_MSG(wxT("deleting inexistent accel from wxAcceleratorTable")); -} - -// ---------------------------------------------------------------------------- -// wxAcceleratorTable: find a command for the given key press -// ---------------------------------------------------------------------------- - -const wxAcceleratorEntry * -wxAcceleratorTable::GetEntry(const wxKeyEvent& event) const -{ - if ( !IsOk() ) - { - // not an error, the accel table is just empty - return NULL; - } - - wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); - while ( node ) - { - const wxAcceleratorEntry *entry = node->GetData(); - - // is the key the same? - if ( event.m_keyCode == entry->GetKeyCode() ) - { - int flags = entry->GetFlags(); - - // now check flags - if ( (((flags & wxACCEL_CTRL) != 0) == event.ControlDown()) && - (((flags & wxACCEL_SHIFT) != 0) == event.ShiftDown()) && - (((flags & wxACCEL_ALT) != 0) == event.AltDown()) ) - { - return entry; - } - } - - node = node->GetNext(); - } - - return NULL; -} - -wxMenuItem *wxAcceleratorTable::GetMenuItem(const wxKeyEvent& event) const -{ - const wxAcceleratorEntry *entry = GetEntry(event); - - return entry ? entry->GetMenuItem() : NULL; -} - -int wxAcceleratorTable::GetCommand(const wxKeyEvent& event) const -{ - const wxAcceleratorEntry *entry = GetEntry(event); - - return entry ? entry->GetCommand() : -1; -} - -wxObjectRefData *wxAcceleratorTable::CreateRefData() const -{ - return new wxAccelRefData; -} - -wxObjectRefData *wxAcceleratorTable::CloneRefData(const wxObjectRefData *data) const -{ - return new wxAccelRefData(*(wxAccelRefData *)data); -} - -#endif // wxUSE_ACCEL diff --git a/Source/3rd Party/wx/src/generic/animateg.cpp b/Source/3rd Party/wx/src/generic/animateg.cpp deleted file mode 100644 index dd2adecff..000000000 --- a/Source/3rd Party/wx/src/generic/animateg.cpp +++ /dev/null @@ -1,696 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/animateg.cpp -// Purpose: wxAnimation and wxAnimationCtrl -// Author: Julian Smart and Guillermo Rodriguez Garcia -// Modified by: Francesco Montorsi -// Created: 13/8/99 -// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif //__BORLANDC__ - -#if wxUSE_ANIMATIONCTRL - -#include "wx/animate.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/image.h" - #include "wx/dcmemory.h" - #include "wx/dcclient.h" - #include "wx/module.h" -#endif - -#include "wx/wfstream.h" -#include "wx/gifdecod.h" -#include "wx/anidecod.h" - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxAnimationDecoderList) - -wxAnimationDecoderList wxAnimation::sm_handlers; - - -// ---------------------------------------------------------------------------- -// wxAnimation -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxAnimationBase) -#define M_ANIMDATA static_cast(m_refData) - -wxSize wxAnimation::GetSize() const -{ - wxCHECK_MSG( IsOk(), wxDefaultSize, wxT("invalid animation") ); - - return M_ANIMDATA->GetAnimationSize(); -} - -unsigned int wxAnimation::GetFrameCount() const -{ - wxCHECK_MSG( IsOk(), 0, wxT("invalid animation") ); - - return M_ANIMDATA->GetFrameCount(); -} - -wxImage wxAnimation::GetFrame(unsigned int i) const -{ - wxCHECK_MSG( IsOk(), wxNullImage, wxT("invalid animation") ); - - wxImage ret; - if (!M_ANIMDATA->ConvertToImage(i, &ret)) - return wxNullImage; - return ret; -} - -int wxAnimation::GetDelay(unsigned int i) const -{ - wxCHECK_MSG( IsOk(), 0, wxT("invalid animation") ); - - return M_ANIMDATA->GetDelay(i); -} - -wxPoint wxAnimation::GetFramePosition(unsigned int frame) const -{ - wxCHECK_MSG( IsOk(), wxDefaultPosition, wxT("invalid animation") ); - - return M_ANIMDATA->GetFramePosition(frame); -} - -wxSize wxAnimation::GetFrameSize(unsigned int frame) const -{ - wxCHECK_MSG( IsOk(), wxDefaultSize, wxT("invalid animation") ); - - return M_ANIMDATA->GetFrameSize(frame); -} - -wxAnimationDisposal wxAnimation::GetDisposalMethod(unsigned int frame) const -{ - wxCHECK_MSG( IsOk(), wxANIM_UNSPECIFIED, wxT("invalid animation") ); - - return M_ANIMDATA->GetDisposalMethod(frame); -} - -wxColour wxAnimation::GetTransparentColour(unsigned int frame) const -{ - wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid animation") ); - - return M_ANIMDATA->GetTransparentColour(frame); -} - -wxColour wxAnimation::GetBackgroundColour() const -{ - wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid animation") ); - - return M_ANIMDATA->GetBackgroundColour(); -} - -bool wxAnimation::LoadFile(const wxString& filename, wxAnimationType type) -{ - wxFileInputStream stream(filename); - if ( !stream.IsOk() ) - return false; - - return Load(stream, type); -} - -bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type) -{ - UnRef(); - - const wxAnimationDecoder *handler; - if ( type == wxANIMATION_TYPE_ANY ) - { - for ( wxAnimationDecoderList::compatibility_iterator node = sm_handlers.GetFirst(); - node; node = node->GetNext() ) - { - handler=(const wxAnimationDecoder*)node->GetData(); - - if ( handler->CanRead(stream) ) - { - // do a copy of the handler from the static list which we will own - // as our reference data - m_refData = handler->Clone(); - return M_ANIMDATA->Load(stream); - } - } - - wxLogWarning( _("No handler found for animation type.") ); - return false; - } - - handler = FindHandler(type); - - if (handler == NULL) - { - wxLogWarning( _("No animation handler for type %ld defined."), type ); - - return false; - } - - - // do a copy of the handler from the static list which we will own - // as our reference data - m_refData = handler->Clone(); - - if (stream.IsSeekable() && !M_ANIMDATA->CanRead(stream)) - { - wxLogError(_("Animation file is not of type %ld."), type); - return false; - } - else - return M_ANIMDATA->Load(stream); -} - - -// ---------------------------------------------------------------------------- -// animation decoders -// ---------------------------------------------------------------------------- - -void wxAnimation::AddHandler( wxAnimationDecoder *handler ) -{ - // Check for an existing handler of the type being added. - if (FindHandler( handler->GetType() ) == 0) - { - sm_handlers.Append( handler ); - } - else - { - // This is not documented behaviour, merely the simplest 'fix' - // for preventing duplicate additions. If someone ever has - // a good reason to add and remove duplicate handlers (and they - // may) we should probably refcount the duplicates. - - wxLogDebug( wxT("Adding duplicate animation handler for '%d' type"), - handler->GetType() ); - delete handler; - } -} - -void wxAnimation::InsertHandler( wxAnimationDecoder *handler ) -{ - // Check for an existing handler of the type being added. - if (FindHandler( handler->GetType() ) == 0) - { - sm_handlers.Insert( handler ); - } - else - { - // see AddHandler for additional comments. - wxLogDebug( wxT("Inserting duplicate animation handler for '%d' type"), - handler->GetType() ); - delete handler; - } -} - -const wxAnimationDecoder *wxAnimation::FindHandler( wxAnimationType animType ) -{ - wxAnimationDecoderList::compatibility_iterator node = sm_handlers.GetFirst(); - while (node) - { - const wxAnimationDecoder *handler = (const wxAnimationDecoder *)node->GetData(); - if (handler->GetType() == animType) return handler; - node = node->GetNext(); - } - return 0; -} - -void wxAnimation::InitStandardHandlers() -{ -#if wxUSE_GIF - AddHandler(new wxGIFDecoder); -#endif // wxUSE_GIF -#if wxUSE_ICO_CUR - AddHandler(new wxANIDecoder); -#endif // wxUSE_ICO_CUR -} - -void wxAnimation::CleanUpHandlers() -{ - wxAnimationDecoderList::compatibility_iterator node = sm_handlers.GetFirst(); - while (node) - { - wxAnimationDecoder *handler = (wxAnimationDecoder *)node->GetData(); - wxAnimationDecoderList::compatibility_iterator next = node->GetNext(); - delete handler; - node = next; - } - - sm_handlers.Clear(); -} - - -// A module to allow wxAnimation initialization/cleanup -// without calling these functions from app.cpp or from -// the user's application. - -class wxAnimationModule: public wxModule -{ -DECLARE_DYNAMIC_CLASS(wxAnimationModule) -public: - wxAnimationModule() {} - bool OnInit() { wxAnimation::InitStandardHandlers(); return true; } - void OnExit() { wxAnimation::CleanUpHandlers(); } -}; - -IMPLEMENT_DYNAMIC_CLASS(wxAnimationModule, wxModule) - - -// ---------------------------------------------------------------------------- -// wxAnimationCtrl -// ---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxAnimationCtrl, wxAnimationCtrlBase) -BEGIN_EVENT_TABLE(wxAnimationCtrl, wxAnimationCtrlBase) - EVT_PAINT(wxAnimationCtrl::OnPaint) - EVT_SIZE(wxAnimationCtrl::OnSize) - EVT_TIMER(wxID_ANY, wxAnimationCtrl::OnTimer) -END_EVENT_TABLE() - -void wxAnimationCtrl::Init() -{ - m_currentFrame = 0; - m_looped = false; - m_isPlaying = false; - - // use the window background colour by default to be consistent - // with the GTK+ native version - m_useWinBackgroundColour = true; -} - -bool wxAnimationCtrl::Create(wxWindow *parent, wxWindowID id, - const wxAnimation& animation, const wxPoint& pos, - const wxSize& size, long style, const wxString& name) -{ - m_timer.SetOwner(this); - - if (!base_type::Create(parent, id, pos, size, style, wxDefaultValidator, name)) - return false; - - // by default we get the same background colour of our parent - SetBackgroundColour(parent->GetBackgroundColour()); - - SetAnimation(animation); - - return true; -} - -wxAnimationCtrl::~wxAnimationCtrl() -{ - Stop(); -} - -bool wxAnimationCtrl::LoadFile(const wxString& filename, wxAnimationType type) -{ - wxFileInputStream fis(filename); - if (!fis.IsOk()) - return false; - return Load(fis, type); -} - -bool wxAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type) -{ - wxAnimation anim; - if ( !anim.Load(stream, type) || !anim.IsOk() ) - return false; - - SetAnimation(anim); - return true; -} - -wxSize wxAnimationCtrl::DoGetBestSize() const -{ - if (m_animation.IsOk() && !this->HasFlag(wxAC_NO_AUTORESIZE)) - return m_animation.GetSize(); - - return wxSize(100, 100); -} - -void wxAnimationCtrl::SetAnimation(const wxAnimation& animation) -{ - if (IsPlaying()) - Stop(); - - // set new animation even if it's wxNullAnimation - m_animation = animation; - if (!m_animation.IsOk()) - { - DisplayStaticImage(); - return; - } - - if (m_animation.GetBackgroundColour() == wxNullColour) - SetUseWindowBackgroundColour(); - if (!this->HasFlag(wxAC_NO_AUTORESIZE)) - FitToAnimation(); - - DisplayStaticImage(); -} - -void wxAnimationCtrl::SetInactiveBitmap(const wxBitmap &bmp) -{ - // if the bitmap has an associated mask, we need to set our background to - // the colour of our parent otherwise when calling DrawCurrentFrame() - // (which uses the bitmap's mask), our background colour would be used for - // transparent areas - and that's not what we want (at least for - // consistency with the GTK version) - if ( bmp.IsOk() && bmp.GetMask() != NULL && GetParent() != NULL ) - SetBackgroundColour(GetParent()->GetBackgroundColour()); - - wxAnimationCtrlBase::SetInactiveBitmap(bmp); -} - -void wxAnimationCtrl::FitToAnimation() -{ - SetSize(m_animation.GetSize()); -} - -bool wxAnimationCtrl::SetBackgroundColour(const wxColour& colour) -{ - if ( !wxWindow::SetBackgroundColour(colour) ) - return false; - - // if not playing, then this change must be seen immediately (unless - // there's an inactive bitmap set which has higher priority than bg colour) - if ( !IsPlaying() ) - DisplayStaticImage(); - - return true; -} - - -// ---------------------------------------------------------------------------- -// wxAnimationCtrl - stop/play methods -// ---------------------------------------------------------------------------- - -void wxAnimationCtrl::Stop() -{ - m_timer.Stop(); - m_isPlaying = false; - - // reset frame counter - m_currentFrame = 0; - - DisplayStaticImage(); -} - -bool wxAnimationCtrl::Play(bool looped) -{ - if (!m_animation.IsOk()) - return false; - - m_looped = looped; - m_currentFrame = 0; - - if (!RebuildBackingStoreUpToFrame(0)) - return false; - - m_isPlaying = true; - - // do a ClearBackground() to avoid that e.g. the custom static bitmap which - // was eventually shown previously remains partially drawn - ClearBackground(); - - // DrawCurrentFrame() will use our updated backing store - wxClientDC clientDC(this); - DrawCurrentFrame(clientDC); - - // start the timer - int delay = m_animation.GetDelay(0); - if (delay == 0) - delay = 1; // 0 is invalid timeout for wxTimer. - m_timer.Start(delay, true); - - return true; -} - - - -// ---------------------------------------------------------------------------- -// wxAnimationCtrl - rendering methods -// ---------------------------------------------------------------------------- - -bool wxAnimationCtrl::RebuildBackingStoreUpToFrame(unsigned int frame) -{ - // if we've not created the backing store yet or it's too - // small, then recreate it - wxSize sz = m_animation.GetSize(), - winsz = GetClientSize(); - int w = wxMin(sz.GetWidth(), winsz.GetWidth()); - int h = wxMin(sz.GetHeight(), winsz.GetHeight()); - - if ( !m_backingStore.IsOk() || - m_backingStore.GetWidth() < w || m_backingStore.GetHeight() < h ) - { - if (!m_backingStore.Create(w, h)) - return false; - } - - wxMemoryDC dc; - dc.SelectObject(m_backingStore); - - // Draw the background - DisposeToBackground(dc); - - // Draw all intermediate frames that haven't been removed from the animation - for (unsigned int i = 0; i < frame; i++) - { - if (m_animation.GetDisposalMethod(i) == wxANIM_DONOTREMOVE || - m_animation.GetDisposalMethod(i) == wxANIM_UNSPECIFIED) - { - DrawFrame(dc, i); - } - else if (m_animation.GetDisposalMethod(i) == wxANIM_TOBACKGROUND) - DisposeToBackground(dc, m_animation.GetFramePosition(i), - m_animation.GetFrameSize(i)); - } - - // finally draw this frame - DrawFrame(dc, frame); - dc.SelectObject(wxNullBitmap); - - return true; -} - -void wxAnimationCtrl::IncrementalUpdateBackingStore() -{ - wxMemoryDC dc; - dc.SelectObject(m_backingStore); - - // OPTIMIZATION: - // since wxAnimationCtrl can only play animations forward, without skipping - // frames, we can be sure that m_backingStore contains the m_currentFrame-1 - // frame and thus we just need to dispose the m_currentFrame-1 frame and - // render the m_currentFrame-th one. - - if (m_currentFrame == 0) - { - // before drawing the first frame always dispose to bg colour - DisposeToBackground(dc); - } - else - { - switch (m_animation.GetDisposalMethod(m_currentFrame-1)) - { - case wxANIM_TOBACKGROUND: - DisposeToBackground(dc, m_animation.GetFramePosition(m_currentFrame-1), - m_animation.GetFrameSize(m_currentFrame-1)); - break; - - case wxANIM_TOPREVIOUS: - // this disposal should never be used too often. - // E.g. GIF specification explicitly say to keep the usage of this - // disposal limited to the minimum. - // In fact it may require a lot of time to restore - if (m_currentFrame == 1) - { - // if 0-th frame disposal is to restore to previous frame, - // the best we can do is to restore to background - DisposeToBackground(dc); - } - else - if (!RebuildBackingStoreUpToFrame(m_currentFrame-2)) - Stop(); - break; - - case wxANIM_DONOTREMOVE: - case wxANIM_UNSPECIFIED: - break; - } - } - - // now just draw the current frame on the top of the backing store - DrawFrame(dc, m_currentFrame); - dc.SelectObject(wxNullBitmap); -} - -void wxAnimationCtrl::DisplayStaticImage() -{ - wxASSERT(!IsPlaying()); - - // m_bmpStaticReal will be updated only if necessary... - UpdateStaticImage(); - - if (m_bmpStaticReal.IsOk()) - { - // copy the inactive bitmap in the backing store - // eventually using the mask if the static bitmap has one - if ( m_bmpStaticReal.GetMask() ) - { - wxMemoryDC temp; - temp.SelectObject(m_backingStore); - DisposeToBackground(temp); - temp.DrawBitmap(m_bmpStaticReal, 0, 0, true /* use mask */); - } - else - m_backingStore = m_bmpStaticReal; - } - else - { - // put in the backing store the first frame of the animation - if (!m_animation.IsOk() || - !RebuildBackingStoreUpToFrame(0)) - { - m_animation = wxNullAnimation; - DisposeToBackground(); - } - } - - Refresh(); -} - -void wxAnimationCtrl::DrawFrame(wxDC &dc, unsigned int frame) -{ - // PERFORMANCE NOTE: - // this draw stuff is not as fast as possible: the wxAnimationDecoder - // needs first to convert from its internal format to wxImage RGB24; - // the wxImage is then converted as a wxBitmap and finally blitted. - // If wxAnimationDecoder had a function to convert directly from its - // internal format to a port-specific wxBitmap, it would be somewhat faster. - wxBitmap bmp(m_animation.GetFrame(frame)); - dc.DrawBitmap(bmp, m_animation.GetFramePosition(frame), - true /* use mask */); -} - -void wxAnimationCtrl::DrawCurrentFrame(wxDC& dc) -{ - wxASSERT( m_backingStore.IsOk() ); - - // m_backingStore always contains the current frame - dc.DrawBitmap(m_backingStore, 0, 0, true /* use mask in case it's present */); -} - -void wxAnimationCtrl::DisposeToBackground() -{ - // clear the backing store - wxMemoryDC dc; - dc.SelectObject(m_backingStore); - if ( dc.IsOk() ) - DisposeToBackground(dc); -} - -void wxAnimationCtrl::DisposeToBackground(wxDC& dc) -{ - wxColour col = IsUsingWindowBackgroundColour() - ? GetBackgroundColour() - : m_animation.GetBackgroundColour(); - - wxBrush brush(col); - dc.SetBackground(brush); - dc.Clear(); -} - -void wxAnimationCtrl::DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz) -{ - wxColour col = IsUsingWindowBackgroundColour() - ? GetBackgroundColour() - : m_animation.GetBackgroundColour(); - wxBrush brush(col); - dc.SetBrush(brush); // SetBrush and not SetBackground !! - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle(pos, sz); -} - -// ---------------------------------------------------------------------------- -// wxAnimationCtrl - event handlers -// ---------------------------------------------------------------------------- - -void wxAnimationCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - // VERY IMPORTANT: the wxPaintDC *must* be created in any case - wxPaintDC dc(this); - - if ( m_backingStore.IsOk() ) - { - // NOTE: we draw the bitmap explicitly ignoring the mask (if any); - // i.e. we don't want to combine the backing store with the - // possibly wrong preexisting contents of the window! - dc.DrawBitmap(m_backingStore, 0, 0, false /* no mask */); - } - else - { - // m_animation is not valid and thus we don't have a valid backing store... - // clear then our area to the background colour - DisposeToBackground(dc); - } -} - -void wxAnimationCtrl::OnTimer(wxTimerEvent &WXUNUSED(event)) -{ - m_currentFrame++; - if (m_currentFrame == m_animation.GetFrameCount()) - { - // Should a non-looped animation display the last frame? - if (!m_looped) - { - Stop(); - return; - } - else - m_currentFrame = 0; // let's restart - } - - IncrementalUpdateBackingStore(); - - wxClientDC dc(this); - DrawCurrentFrame(dc); - -#ifdef __WXMAC__ - // without this, the animation currently doesn't redraw under Mac - Refresh(); -#endif // __WXMAC__ - - // Set the timer for the next frame - int delay = m_animation.GetDelay(m_currentFrame); - if (delay == 0) - delay = 1; // 0 is invalid timeout for wxTimer. - m_timer.Start(delay, true); -} - -void wxAnimationCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) -{ - // NB: resizing an animation control may take a lot of time - // for big animations as the backing store must be - // extended and rebuilt. Try to avoid it e.g. using - // a null proportion value for your wxAnimationCtrls - // when using them inside sizers. - if (m_animation.IsOk()) - { - // be careful to change the backing store *only* if we are - // playing the animation as otherwise we may be displaying - // the inactive bitmap and overwriting the backing store - // with the last played frame is wrong in this case - if (IsPlaying()) - { - if (!RebuildBackingStoreUpToFrame(m_currentFrame)) - Stop(); // in case we are playing - } - } -} - -#endif // wxUSE_ANIMATIONCTRL - diff --git a/Source/3rd Party/wx/src/generic/bannerwindow.cpp b/Source/3rd Party/wx/src/generic/bannerwindow.cpp deleted file mode 100644 index f5452cd88..000000000 --- a/Source/3rd Party/wx/src/generic/bannerwindow.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/bannerwindow.h -// Purpose: wxBannerWindow class implementation -// Author: Vadim Zeitlin -// Created: 2011-08-16 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BANNERWINDOW - -#include "wx/bannerwindow.h" - -#ifndef WX_PRECOMP - #include "wx/bitmap.h" - #include "wx/colour.h" -#endif - -#include "wx/dcbuffer.h" - -namespace -{ - -// Some constants for banner layout, currently they're hard coded but we could -// easily make them configurable if needed later. -const int MARGIN_X = 5; -const int MARGIN_Y = 5; - -} // anonymous namespace - -const char wxBannerWindowNameStr[] = "bannerwindow"; - -BEGIN_EVENT_TABLE(wxBannerWindow, wxWindow) - EVT_SIZE(wxBannerWindow::OnSize) - EVT_PAINT(wxBannerWindow::OnPaint) -END_EVENT_TABLE() - -void wxBannerWindow::Init() -{ - m_direction = wxLEFT; - - m_colStart = *wxWHITE; - m_colEnd = *wxBLUE; -} - -bool -wxBannerWindow::Create(wxWindow* parent, - wxWindowID winid, - wxDirection dir, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( !wxWindow::Create(parent, winid, pos, size, style, name) ) - return false; - - wxASSERT_MSG - ( - dir == wxLEFT || dir == wxRIGHT || dir == wxTOP || dir == wxBOTTOM, - wxS("Invalid banner direction") - ); - - m_direction = dir; - - SetBackgroundStyle(wxBG_STYLE_PAINT); - - return true; -} - -void wxBannerWindow::SetBitmap(const wxBitmap& bmp) -{ - m_bitmap = bmp; - - m_colBitmapBg = wxColour(); - - InvalidateBestSize(); - - Refresh(); -} - -void wxBannerWindow::SetText(const wxString& title, const wxString& message) -{ - m_title = title; - m_message = message; - - InvalidateBestSize(); - - Refresh(); -} - -void wxBannerWindow::SetGradient(const wxColour& start, const wxColour& end) -{ - m_colStart = start; - m_colEnd = end; - - Refresh(); -} - -wxFont wxBannerWindow::GetTitleFont() const -{ - wxFont font = GetFont(); - font.MakeBold().MakeLarger(); - return font; -} - -wxSize wxBannerWindow::DoGetBestClientSize() const -{ - if ( m_bitmap.IsOk() ) - { - return m_bitmap.GetSize(); - } - else - { - wxClientDC dc(const_cast(this)); - const wxSize sizeText = dc.GetMultiLineTextExtent(m_message); - - dc.SetFont(GetTitleFont()); - - const wxSize sizeTitle = dc.GetTextExtent(m_title); - - wxSize sizeWin(wxMax(sizeTitle.x, sizeText.x), sizeTitle.y + sizeText.y); - - // If we draw the text vertically width and height are swapped. - if ( m_direction == wxLEFT || m_direction == wxRIGHT ) - wxSwap(sizeWin.x, sizeWin.y); - - sizeWin += 2*wxSize(MARGIN_X, MARGIN_Y); - - return sizeWin; - } -} - -void wxBannerWindow::OnSize(wxSizeEvent& event) -{ - Refresh(); - - event.Skip(); -} - -void wxBannerWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - if ( m_bitmap.IsOk() && m_title.empty() && m_message.empty() ) - { - // No need for buffering in this case. - wxPaintDC dc(this); - - DrawBitmapBackground(dc); - } - else // We need to compose our contents ourselves. - { - wxAutoBufferedPaintDC dc(this); - - // Deal with the background first. - if ( m_bitmap.IsOk() ) - { - DrawBitmapBackground(dc); - } - else // Draw gradient background. - { - wxDirection gradientDir; - if ( m_direction == wxLEFT ) - { - gradientDir = wxTOP; - } - else if ( m_direction == wxRIGHT ) - { - gradientDir = wxBOTTOM; - } - else // For both wxTOP and wxBOTTOM. - { - gradientDir = wxRIGHT; - } - - dc.GradientFillLinear(GetClientRect(), m_colStart, m_colEnd, - gradientDir); - } - - // Now draw the text on top of it. - dc.SetFont(GetTitleFont()); - - wxPoint pos(MARGIN_X, MARGIN_Y); - DrawBannerTextLine(dc, m_title, pos); - pos.y += dc.GetTextExtent(m_title).y; - - dc.SetFont(GetFont()); - - wxArrayString lines = wxSplit(m_message, '\n', '\0'); - const unsigned numLines = lines.size(); - for ( unsigned n = 0; n < numLines; n++ ) - { - const wxString& line = lines[n]; - - DrawBannerTextLine(dc, line, pos); - pos.y += dc.GetTextExtent(line).y; - } - } -} - -wxColour wxBannerWindow::GetBitmapBg() -{ - if ( m_colBitmapBg.IsOk() ) - return m_colBitmapBg; - - // Determine the colour to use to extend the bitmap. It's the colour of the - // bitmap pixels at the edge closest to the area where it can be extended. - wxImage image(m_bitmap.ConvertToImage()); - - // The point we get the colour from. The choice is arbitrary and in general - // the bitmap should have the same colour on the entire edge of this point - // for extending it to look good. - wxPoint p; - - wxSize size = image.GetSize(); - size.x--; - size.y--; - - switch ( m_direction ) - { - case wxTOP: - case wxBOTTOM: - // The bitmap will be extended to the right. - p.x = size.x; - p.y = 0; - break; - - case wxLEFT: - // The bitmap will be extended from the top. - p.x = 0; - p.y = 0; - break; - - case wxRIGHT: - // The bitmap will be extended to the bottom. - p.x = 0; - p.y = size.y; - break; - - // This case is there only to prevent g++ warnings about not handling - // some enum elements in the switch, it can't really happen. - case wxALL: - wxFAIL_MSG( wxS("Unreachable") ); - } - - m_colBitmapBg.Set(image.GetRed(p.x, p.y), - image.GetGreen(p.x, p.y), - image.GetBlue(p.x, p.y)); - - return m_colBitmapBg; -} - -void wxBannerWindow::DrawBitmapBackground(wxDC& dc) -{ - // We may need to fill the part of the background not covered by the bitmap - // with the solid colour extending the bitmap, this rectangle will hold the - // area to be filled (which could be empty if the bitmap is big enough). - wxRect rectSolid; - - const wxSize size = GetClientSize(); - - switch ( m_direction ) - { - case wxTOP: - case wxBOTTOM: - // Draw the bitmap at the origin, its rightmost could be truncated, - // as it's meant to be. - dc.DrawBitmap(m_bitmap, 0, 0); - - rectSolid.x = m_bitmap.GetWidth(); - rectSolid.width = size.x - rectSolid.x; - rectSolid.height = size.y; - break; - - case wxLEFT: - // The top most part of the bitmap may be truncated but its bottom - // must be always visible so intentionally draw it possibly partly - // outside of the window. - rectSolid.width = size.x; - rectSolid.height = size.y - m_bitmap.GetHeight(); - dc.DrawBitmap(m_bitmap, 0, rectSolid.height); - break; - - case wxRIGHT: - // Draw the bitmap at the origin, possibly truncating its - // bottommost part. - dc.DrawBitmap(m_bitmap, 0, 0); - - rectSolid.y = m_bitmap.GetHeight(); - rectSolid.height = size.y - rectSolid.y; - rectSolid.width = size.x; - break; - - // This case is there only to prevent g++ warnings about not handling - // some enum elements in the switch, it can't really happen. - case wxALL: - wxFAIL_MSG( wxS("Unreachable") ); - } - - if ( rectSolid.width > 0 && rectSolid.height > 0 ) - { - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(GetBitmapBg()); - dc.DrawRectangle(rectSolid); - } -} - -void -wxBannerWindow::DrawBannerTextLine(wxDC& dc, - const wxString& str, - const wxPoint& pos) -{ - switch ( m_direction ) - { - case wxTOP: - case wxBOTTOM: - // The simple case: we just draw the text normally. - dc.DrawText(str, pos); - break; - - case wxLEFT: - // We draw the text vertically and start from the lower left - // corner and not the upper left one as usual. - dc.DrawRotatedText(str, pos.y, GetClientSize().y - pos.x, 90); - break; - - case wxRIGHT: - // We also draw the text vertically but now we start from the upper - // right corner and draw it from top to bottom. - dc.DrawRotatedText(str, GetClientSize().x - pos.y, pos.x, -90); - break; - - case wxALL: - wxFAIL_MSG( wxS("Unreachable") ); - } -} - -#endif // wxUSE_BANNERWINDOW diff --git a/Source/3rd Party/wx/src/generic/bmpcboxg.cpp b/Source/3rd Party/wx/src/generic/bmpcboxg.cpp deleted file mode 100644 index 9a948eed8..000000000 --- a/Source/3rd Party/wx/src/generic/bmpcboxg.cpp +++ /dev/null @@ -1,358 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/bmpcboxg.cpp -// Purpose: wxBitmapComboBox -// Author: Jaakko Salli -// Modified by: -// Created: Aug-31-2006 -// Copyright: (c) 2005 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BITMAPCOMBOBOX - -#include "wx/bmpcbox.h" - -#if defined(wxGENERIC_BITMAPCOMBOBOX) - -#ifndef WX_PRECOMP - #include "wx/log.h" -#endif - -#include "wx/odcombo.h" -#include "wx/settings.h" -#include "wx/dc.h" - -#if wxUSE_IMAGE - #include "wx/image.h" -#endif - - -#define IMAGE_SPACING_CTRL_VERTICAL 7 // Spacing used in control size calculation - - -// ============================================================================ -// implementation -// ============================================================================ - - -BEGIN_EVENT_TABLE(wxBitmapComboBox, wxOwnerDrawnComboBox) - EVT_SIZE(wxBitmapComboBox::OnSize) -END_EVENT_TABLE() - - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBox, wxOwnerDrawnComboBox) - -void wxBitmapComboBox::Init() -{ - m_inResize = false; -} - -wxBitmapComboBox::wxBitmapComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) - : wxOwnerDrawnComboBox(), - wxBitmapComboBoxBase() -{ - Init(); - - Create(parent,id,value,pos,size,choices,style,validator,name); -} - -bool wxBitmapComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) -{ - if ( !wxOwnerDrawnComboBox::Create(parent, id, value, - pos, size, - choices, style, - validator, name) ) - { - return false; - } - - UpdateInternals(); - - return true; -} - -bool wxBitmapComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style, - const wxValidator& validator, - const wxString& name) -{ - if ( !wxOwnerDrawnComboBox::Create(parent, id, value, - pos, size, n, - choices, style, - validator, name) ) - { - return false; - } - - UpdateInternals(); - - return true; -} - -wxBitmapComboBox::~wxBitmapComboBox() -{ - DoClear(); -} - -// ---------------------------------------------------------------------------- -// Item manipulation -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) -{ - OnAddBitmap(bitmap); - DoSetItemBitmap(n, bitmap); - - if ( (int)n == GetSelection() ) - Refresh(); -} - -int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type) -{ - const unsigned int numItems = items.GetCount(); - const unsigned int countNew = GetCount() + numItems; - - wxASSERT( numItems == 1 || !HasFlag(wxCB_SORT) ); // Sanity check - - m_bitmaps.Alloc(countNew); - - for ( unsigned int i = 0; i < numItems; i++ ) - { - m_bitmaps.Insert(new wxBitmap(wxNullBitmap), pos + i); - } - - const int index = wxOwnerDrawnComboBox::DoInsertItems(items, pos, - clientData, type); - - if ( index == wxNOT_FOUND ) - { - for ( int i = numItems-1; i >= 0; i-- ) - BCBDoDeleteOneItem(pos + i); - } - else if ( ((unsigned int)index) != pos ) - { - // Move pre-inserted empty bitmap into correct position - // (usually happens when combo box has wxCB_SORT style) - wxBitmap* bmp = static_cast(m_bitmaps[pos]); - m_bitmaps.RemoveAt(pos); - m_bitmaps.Insert(bmp, index); - } - - return index; -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap) -{ - const int n = wxOwnerDrawnComboBox::Append(item); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, - void *clientData) -{ - const int n = wxOwnerDrawnComboBox::Append(item, clientData); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, - wxClientData *clientData) -{ - const int n = wxOwnerDrawnComboBox::Append(item, clientData); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, - const wxBitmap& bitmap, - unsigned int pos) -{ - const int n = wxOwnerDrawnComboBox::Insert(item, pos); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, void *clientData) -{ - const int n = wxOwnerDrawnComboBox::Insert(item, pos, clientData); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, wxClientData *clientData) -{ - const int n = wxOwnerDrawnComboBox::Insert(item, pos, clientData); - if(n != wxNOT_FOUND) - SetItemBitmap(n, bitmap); - return n; -} - -void wxBitmapComboBox::DoClear() -{ - wxOwnerDrawnComboBox::DoClear(); - wxBitmapComboBoxBase::BCBDoClear(); -} - -void wxBitmapComboBox::DoDeleteOneItem(unsigned int n) -{ - wxOwnerDrawnComboBox::DoDeleteOneItem(n); - wxBitmapComboBoxBase::BCBDoDeleteOneItem(n); -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox event handlers and such -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::OnSize(wxSizeEvent& event) -{ - // Prevent infinite looping - if ( !m_inResize ) - { - m_inResize = true; - DetermineIndent(); - m_inResize = false; - } - - event.Skip(); -} - -wxSize wxBitmapComboBox::DoGetBestSize() const -{ - wxSize sz = wxOwnerDrawnComboBox::DoGetBestSize(); - - if ( HasFlag(wxCB_READONLY) ) - { - // Scale control to match height of highest image. - int h2 = m_usedImgSize.y + IMAGE_SPACING_CTRL_VERTICAL; - - if ( h2 > sz.y ) - sz.y = h2; - - CacheBestSize(sz); - } - - return sz; -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox miscellaneous -// ---------------------------------------------------------------------------- - -bool wxBitmapComboBox::SetFont(const wxFont& font) -{ - bool res = wxOwnerDrawnComboBox::SetFont(font); - UpdateInternals(); - return res; -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox item drawing and measuring -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::OnDrawBackground(wxDC& dc, - const wxRect& rect, - int item, - int flags) const -{ - if ( GetCustomPaintWidth() == 0 || - !(flags & wxODCB_PAINTING_SELECTED) || - item < 0 || - ( (flags & wxODCB_PAINTING_CONTROL) && (GetInternalFlags() & wxCC_FULL_BUTTON)) ) - { - wxOwnerDrawnComboBox::OnDrawBackground(dc, rect, item, flags); - return; - } - - wxBitmapComboBoxBase::DrawBackground(dc, rect, item, flags); -} - -void wxBitmapComboBox::OnDrawItem(wxDC& dc, - const wxRect& rect, - int item, - int flags) const -{ - wxString text; - int imgAreaWidth = m_imgAreaWidth; - - if ( imgAreaWidth == 0 ) - { - wxOwnerDrawnComboBox::OnDrawItem(dc, rect, item, flags); - return; - } - - if ( flags & wxODCB_PAINTING_CONTROL ) - { - text = GetValue(); - if ( !HasFlag(wxCB_READONLY) ) - text.clear(); - } - else - { - text = GetString(item); - } - - wxBitmapComboBoxBase::DrawItem(dc, rect, item, text, flags); -} - -wxCoord wxBitmapComboBox::OnMeasureItem(size_t item) const -{ - return wxBitmapComboBoxBase::MeasureItem(item); -} - -wxCoord wxBitmapComboBox::OnMeasureItemWidth(size_t item) const -{ - wxCoord x, y; - GetTextExtent(GetString(item), &x, &y, 0, 0); - x += m_imgAreaWidth; - return x; -} - -#endif // defined(wxGENERIC_BITMAPCOMBOBOX) - -#endif // wxUSE_BITMAPCOMBOBOX diff --git a/Source/3rd Party/wx/src/generic/busyinfo.cpp b/Source/3rd Party/wx/src/generic/busyinfo.cpp index 31e5e637a..257c23366 100644 --- a/Source/3rd Party/wx/src/generic/busyinfo.cpp +++ b/Source/3rd Party/wx/src/generic/busyinfo.cpp @@ -3,6 +3,7 @@ // Purpose: Information window when app is busy // Author: Vaclav Slavik // Copyright: (c) 1999 Vaclav Slavik +// RCS-ID: $Id: busyinfo.cpp 44898 2007-03-18 20:39:13Z VZ $ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,7 +24,6 @@ #endif #include "wx/busyinfo.h" -#include "wx/generic/stattextg.h" class WXDLLEXPORT wxInfoFrame : public wxFrame { @@ -31,7 +31,7 @@ public: wxInfoFrame(wxWindow *parent, const wxString& message); private: - wxDECLARE_NO_COPY_CLASS(wxInfoFrame); + DECLARE_NO_COPY_CLASS(wxInfoFrame) }; @@ -43,14 +43,10 @@ wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message) #else wxSIMPLE_BORDER #endif - | wxFRAME_TOOL_WINDOW | wxSTAY_ON_TOP) + | wxFRAME_TOOL_WINDOW) { wxPanel *panel = new wxPanel( this ); -#ifdef __WXGTK__ - wxGenericStaticText *text = new wxGenericStaticText(panel, wxID_ANY, message); -#else wxStaticText *text = new wxStaticText(panel, wxID_ANY, message); -#endif panel->SetCursor(*wxHOURGLASS_CURSOR); text->SetCursor(*wxHOURGLASS_CURSOR); @@ -118,7 +114,13 @@ wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message) wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent) { - m_InfoFrame = new wxInfoFrame(parent, message); + m_InfoFrame = new wxInfoFrame( parent, message); + if ( parent && parent->HasFlag(wxSTAY_ON_TOP) ) + { + // we must have this flag to be in front of our parent if it has it + m_InfoFrame->SetWindowStyleFlag(wxSTAY_ON_TOP); + } + m_InfoFrame->Show(true); m_InfoFrame->Refresh(); m_InfoFrame->Update(); diff --git a/Source/3rd Party/wx/src/generic/buttonbar.cpp b/Source/3rd Party/wx/src/generic/buttonbar.cpp index 36ee251b2..b229d7275 100644 --- a/Source/3rd Party/wx/src/generic/buttonbar.cpp +++ b/Source/3rd Party/wx/src/generic/buttonbar.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech // Modified by: // Created: 2006-04-13 +// Id: $Id: buttonbar.cpp 42816 2006-10-31 08:50:17Z RD $ // Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin, // SciTech Software, Inc. // Licence: wxWindows licence @@ -65,10 +66,8 @@ public: m_button = NULL; } - wxButtonToolBarTool(wxButtonToolBar *tbar, - wxControl *control, - const wxString& label) - : wxToolBarToolBase(tbar, control, label) + wxButtonToolBarTool(wxButtonToolBar *tbar, wxControl *control) + : wxToolBarToolBase(tbar, control) { m_x = m_y = wxDefaultCoord; m_width = @@ -139,10 +138,7 @@ bool wxButtonToolBar::Create(wxWindow *parent, // wxColour lightBackground(244, 244, 244); - wxFont font(wxSMALL_FONT->GetPointSize(), - wxNORMAL_FONT->GetFamily(), - wxNORMAL_FONT->GetStyle(), - wxFONTWEIGHT_NORMAL); + wxFont font(wxSMALL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), wxNORMAL_FONT->GetStyle(), wxNORMAL); SetFont(font); // Calculate the label height if necessary @@ -209,7 +205,7 @@ void wxButtonToolBar::GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const { - wxCHECK_RET( start && end, wxT("NULL pointer in GetRectLimits") ); + wxCHECK_RET( start && end, _T("NULL pointer in GetRectLimits") ); if ( IsVertical() ) { @@ -228,7 +224,7 @@ void wxButtonToolBar::SetToolShortHelp(int id, const wxString& help) { wxToolBarToolBase *tool = FindById(id); - wxCHECK_RET( tool, wxT("SetToolShortHelp: no such tool") ); + wxCHECK_RET( tool, _T("SetToolShortHelp: no such tool") ); // TODO: set tooltip/short help tool->SetShortHelp(help); @@ -275,10 +271,9 @@ wxToolBarToolBase *wxButtonToolBar::CreateTool(int id, clientData, shortHelp, longHelp); } -wxToolBarToolBase *wxButtonToolBar::CreateTool(wxControl *control, - const wxString& label) +wxToolBarToolBase *wxButtonToolBar::CreateTool(wxControl *control) { - return new wxButtonToolBarTool(this, control, label); + return new wxButtonToolBarTool(this, control); } // ---------------------------------------------------------------------------- @@ -291,7 +286,7 @@ wxRect wxButtonToolBar::GetToolRect(wxToolBarToolBase *toolBase) const wxRect rect; - wxCHECK_MSG( tool, rect, wxT("GetToolRect: NULL tool") ); + wxCHECK_MSG( tool, rect, _T("GetToolRect: NULL tool") ); // ensure that we always have the valid tool position if ( m_needsLayout ) @@ -495,7 +490,7 @@ void wxButtonToolBar::OnCommand(wxCommandEvent& event) } // paints a border -void wxButtonToolBar::OnPaint(wxPaintEvent& WXUNUSED(event)) +void wxButtonToolBar::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); @@ -549,9 +544,9 @@ void wxButtonToolBar::OnLeftUp(wxMouseEvent& event) wxButtonToolBarTool* tool = (wxButtonToolBarTool*) FindToolForPosition(event.GetX(), event.GetY()); if (tool && tool->GetButton() && (event.GetY() > (tool->m_y + tool->GetButton()->GetSize().y))) { - wxCommandEvent event(wxEVT_BUTTON, tool->GetId()); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, tool->GetId()); event.SetEventObject(tool->GetButton()); - if (!GetEventHandler()->ProcessEvent(event)) + if (!ProcessEvent(event)) event.Skip(); } } diff --git a/Source/3rd Party/wx/src/generic/calctrlg.cpp b/Source/3rd Party/wx/src/generic/calctrlg.cpp deleted file mode 100644 index 40a549fbf..000000000 --- a/Source/3rd Party/wx/src/generic/calctrlg.cpp +++ /dev/null @@ -1,1724 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/calctrlg.cpp -// Purpose: implementation of the wxGenericCalendarCtrl -// Author: Vadim Zeitlin -// Modified by: -// Created: 29.12.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/brush.h" - #include "wx/combobox.h" - #include "wx/listbox.h" - #include "wx/stattext.h" - #include "wx/textctrl.h" -#endif //WX_PRECOMP - - -#if wxUSE_CALENDARCTRL - -#include "wx/spinctrl.h" -#include "wx/calctrl.h" -#include "wx/generic/calctrlg.h" - -#define DEBUG_PAINT 0 - -// ---------------------------------------------------------------------------- -// wxWin macros -// ---------------------------------------------------------------------------- - -#ifdef wxHAS_NATIVE_CALENDARCTRL - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGenericCalendarCtrl, wxControl,"wx/calctrl.h") - -#endif - -BEGIN_EVENT_TABLE(wxGenericCalendarCtrl, wxControl) - EVT_PAINT(wxGenericCalendarCtrl::OnPaint) - - EVT_CHAR(wxGenericCalendarCtrl::OnChar) - - EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick) - EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick) - - EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged) -END_EVENT_TABLE() - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -namespace -{ - -// add attributes that are set in attr -void AddAttr(wxCalendarDateAttr *self, const wxCalendarDateAttr& attr) -{ - if (attr.HasTextColour()) - self->SetTextColour(attr.GetTextColour()); - if (attr.HasBackgroundColour()) - self->SetBackgroundColour(attr.GetBackgroundColour()); - if (attr.HasBorderColour()) - self->SetBorderColour(attr.GetBorderColour()); - if (attr.HasFont()) - self->SetFont(attr.GetFont()); - if (attr.HasBorder()) - self->SetBorder(attr.GetBorder()); - if (attr.IsHoliday()) - self->SetHoliday(true); -} - -// remove attributes that are set in attr -void DelAttr(wxCalendarDateAttr *self, const wxCalendarDateAttr &attr) -{ - if (attr.HasTextColour()) - self->SetTextColour(wxNullColour); - if (attr.HasBackgroundColour()) - self->SetBackgroundColour(wxNullColour); - if (attr.HasBorderColour()) - self->SetBorderColour(wxNullColour); - if (attr.HasFont()) - self->SetFont(wxNullFont); - if (attr.HasBorder()) - self->SetBorder(wxCAL_BORDER_NONE); - if (attr.IsHoliday()) - self->SetHoliday(false); -} - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// wxGenericCalendarCtrl -// ---------------------------------------------------------------------------- - -wxGenericCalendarCtrl::wxGenericCalendarCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - Init(); - - (void)Create(parent, id, date, pos, size, style, name); -} - -void wxGenericCalendarCtrl::Init() -{ - m_comboMonth = NULL; - m_spinYear = NULL; - m_staticYear = NULL; - m_staticMonth = NULL; - - m_userChangedYear = false; - - m_widthCol = - m_heightRow = - m_calendarWeekWidth = 0; - - wxDateTime::WeekDay wd; - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) - { - m_weekdays[wd] = wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr); - } - - for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) - { - m_attrs[n] = NULL; - } - - InitColours(); -} - -void wxGenericCalendarCtrl::InitColours() -{ - m_colHighlightFg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - m_colHighlightBg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_colBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_colSurrounding = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - - m_colHolidayFg = *wxRED; - // don't set m_colHolidayBg - by default, same as our bg colour - - m_colHeaderFg = *wxBLUE; - m_colHeaderBg = *wxLIGHT_GREY; -} - -bool wxGenericCalendarCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( !wxControl::Create(parent, id, pos, size, - style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE, - wxDefaultValidator, name) ) - { - return false; - } - - // needed to get the arrow keys normally used for the dialog navigation - SetWindowStyle(style | wxWANTS_CHARS); - - m_date = date.IsValid() ? date : wxDateTime::Today(); - - m_lowdate = wxDefaultDateTime; - m_highdate = wxDefaultDateTime; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - CreateYearSpinCtrl(); - m_staticYear = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(wxT("%Y")), - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); - CreateMonthComboBox(); - m_staticMonth = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(wxT("%B")), - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); - } - - ShowCurrentControls(); - - // we need to set the position as well because the main control position - // is not the same as the one specified in pos if we have the controls - // above it - SetInitialSize(size); - SetPosition(pos); - - // Since we don't paint the whole background make sure that the platform - // will use the right one. - SetBackgroundColour(m_colBackground); - - SetHolidayAttrs(); - - return true; -} - -wxGenericCalendarCtrl::~wxGenericCalendarCtrl() -{ - for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) - { - delete m_attrs[n]; - } - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - delete m_comboMonth; - delete m_staticMonth; - delete m_spinYear; - delete m_staticYear; - } -} - -void wxGenericCalendarCtrl::SetWindowStyleFlag(long style) -{ - // changing this style doesn't work because the controls are not - // created/shown/hidden accordingly - wxASSERT_MSG( (style & wxCAL_SEQUENTIAL_MONTH_SELECTION) == - (m_windowStyle & wxCAL_SEQUENTIAL_MONTH_SELECTION), - wxT("wxCAL_SEQUENTIAL_MONTH_SELECTION can't be changed after creation") ); - - wxControl::SetWindowStyleFlag(style); -} - -// ---------------------------------------------------------------------------- -// Create the wxComboBox and wxSpinCtrl -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::CreateMonthComboBox() -{ - m_comboMonth = new wxComboBox(GetParent(), wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - 0, NULL, - wxCB_READONLY | wxCLIP_SIBLINGS); - - wxDateTime::Month m; - for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) ) - { - m_comboMonth->Append(wxDateTime::GetMonthName(m)); - } - - m_comboMonth->SetSelection(GetDate().GetMonth()); - m_comboMonth->SetSize(wxDefaultCoord, - wxDefaultCoord, - wxDefaultCoord, - wxDefaultCoord, - wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); - - m_comboMonth->Connect(m_comboMonth->GetId(), wxEVT_COMBOBOX, - wxCommandEventHandler(wxGenericCalendarCtrl::OnMonthChange), - NULL, this); -} - -void wxGenericCalendarCtrl::CreateYearSpinCtrl() -{ - m_spinYear = new wxSpinCtrl(GetParent(), wxID_ANY, - GetDate().Format(wxT("%Y")), - wxDefaultPosition, - wxDefaultSize, - wxSP_ARROW_KEYS | wxCLIP_SIBLINGS, - -4300, 10000, GetDate().GetYear()); - - m_spinYear->Connect(m_spinYear->GetId(), wxEVT_TEXT, - wxCommandEventHandler(wxGenericCalendarCtrl::OnYearTextChange), - NULL, this); - - m_spinYear->Connect(m_spinYear->GetId(), wxEVT_SPINCTRL, - wxSpinEventHandler(wxGenericCalendarCtrl::OnYearChange), - NULL, this); -} - -// ---------------------------------------------------------------------------- -// forward wxWin functions to subcontrols -// ---------------------------------------------------------------------------- - -bool wxGenericCalendarCtrl::Destroy() -{ - if ( m_staticYear ) - m_staticYear->Destroy(); - if ( m_spinYear ) - m_spinYear->Destroy(); - if ( m_comboMonth ) - m_comboMonth->Destroy(); - if ( m_staticMonth ) - m_staticMonth->Destroy(); - - m_staticYear = NULL; - m_spinYear = NULL; - m_comboMonth = NULL; - m_staticMonth = NULL; - - return wxControl::Destroy(); -} - -bool wxGenericCalendarCtrl::Show(bool show) -{ - if ( !wxControl::Show(show) ) - { - return false; - } - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - if ( GetMonthControl() ) - { - GetMonthControl()->Show(show); - GetYearControl()->Show(show); - } - } - - return true; -} - -bool wxGenericCalendarCtrl::Enable(bool enable) -{ - if ( !wxControl::Enable(enable) ) - { - return false; - } - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - GetMonthControl()->Enable(enable); - GetYearControl()->Enable(enable); - } - - return true; -} - -// ---------------------------------------------------------------------------- -// enable/disable month/year controls -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::ShowCurrentControls() -{ - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - if ( AllowMonthChange() ) - { - m_comboMonth->Show(); - m_staticMonth->Hide(); - - if ( AllowYearChange() ) - { - m_spinYear->Show(); - m_staticYear->Hide(); - - // skip the rest - return; - } - } - else - { - m_comboMonth->Hide(); - m_staticMonth->Show(); - } - - // year change not allowed here - m_spinYear->Hide(); - m_staticYear->Show(); - } - //else: these controls are not even created, don't show/hide them -} - -wxControl *wxGenericCalendarCtrl::GetMonthControl() const -{ - return AllowMonthChange() ? (wxControl *)m_comboMonth : (wxControl *)m_staticMonth; -} - -wxControl *wxGenericCalendarCtrl::GetYearControl() const -{ - return AllowYearChange() ? (wxControl *)m_spinYear : (wxControl *)m_staticYear; -} - -void wxGenericCalendarCtrl::EnableYearChange(bool enable) -{ - if ( enable != AllowYearChange() ) - { - long style = GetWindowStyle(); - if ( enable ) - style &= ~wxCAL_NO_YEAR_CHANGE; - else - style |= wxCAL_NO_YEAR_CHANGE; - SetWindowStyle(style); - - ShowCurrentControls(); - if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) - { - Refresh(); - } - } -} - -bool wxGenericCalendarCtrl::EnableMonthChange(bool enable) -{ - if ( !wxCalendarCtrlBase::EnableMonthChange(enable) ) - return false; - - ShowCurrentControls(); - if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) - Refresh(); - - return true; -} - -// ---------------------------------------------------------------------------- -// changing date -// ---------------------------------------------------------------------------- - -bool wxGenericCalendarCtrl::SetDate(const wxDateTime& date) -{ - bool retval = true; - - bool sameMonth = m_date.GetMonth() == date.GetMonth(), - sameYear = m_date.GetYear() == date.GetYear(); - - if ( IsDateInRange(date) ) - { - if ( sameMonth && sameYear ) - { - // just change the day - ChangeDay(date); - } - else - { - if ( AllowMonthChange() && (AllowYearChange() || sameYear) ) - { - // change everything - m_date = date; - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // update the controls - m_comboMonth->SetSelection(m_date.GetMonth()); - - if ( AllowYearChange() ) - { - if ( !m_userChangedYear ) - m_spinYear->SetValue(m_date.Format(wxT("%Y"))); - } - } - - // as the month changed, holidays did too - SetHolidayAttrs(); - - // update the calendar - Refresh(); - } - else - { - // forbidden - retval = false; - } - } - } - - m_userChangedYear = false; - - return retval; -} - -void wxGenericCalendarCtrl::ChangeDay(const wxDateTime& date) -{ - if ( m_date != date ) - { - // we need to refresh the row containing the old date and the one - // containing the new one - wxDateTime dateOld = m_date; - m_date = date; - - RefreshDate(dateOld); - - // if the date is in the same row, it was already drawn correctly - if ( GetWeek(m_date) != GetWeek(dateOld) ) - { - RefreshDate(m_date); - } - } -} - -void wxGenericCalendarCtrl::SetDateAndNotify(const wxDateTime& date) -{ - const wxDateTime dateOld = GetDate(); - if ( date != dateOld && SetDate(date) ) - { - GenerateAllChangeEvents(dateOld); - } -} - -// ---------------------------------------------------------------------------- -// date range -// ---------------------------------------------------------------------------- - -bool wxGenericCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ) - { - m_lowdate = date; - } - else - { - retval = false; - } - - return retval; -} - -bool wxGenericCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) ) - { - m_highdate = date; - } - else - { - retval = false; - } - - return retval; -} - -bool wxGenericCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( - ( !( lowerdate.IsValid() ) || ( ( upperdate.IsValid() ) ? ( lowerdate <= upperdate ) : true ) ) && - ( !( upperdate.IsValid() ) || ( ( lowerdate.IsValid() ) ? ( upperdate >= lowerdate ) : true ) ) ) - { - m_lowdate = lowerdate; - m_highdate = upperdate; - } - else - { - retval = false; - } - - return retval; -} - -bool wxGenericCalendarCtrl::GetDateRange(wxDateTime *lowerdate, - wxDateTime *upperdate) const -{ - if ( lowerdate ) - *lowerdate = m_lowdate; - if ( upperdate ) - *upperdate = m_highdate; - - return m_lowdate.IsValid() || m_highdate.IsValid(); -} - -// ---------------------------------------------------------------------------- -// date helpers -// ---------------------------------------------------------------------------- - -wxDateTime wxGenericCalendarCtrl::GetStartDate() const -{ - wxDateTime::Tm tm = m_date.GetTm(); - - wxDateTime date = wxDateTime(1, tm.mon, tm.year); - - // rewind back - date.SetToPrevWeekDay(GetWeekStart()); - - if ( GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS ) - { - // We want to offset the calendar if we start on the first.. - if ( date.GetDay() == 1 ) - { - date -= wxDateSpan::Week(); - } - } - - return date; -} - -bool wxGenericCalendarCtrl::IsDateShown(const wxDateTime& date) const -{ - if ( !(GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) - { - return date.GetMonth() == m_date.GetMonth(); - } - else - { - return true; - } -} - -bool wxGenericCalendarCtrl::IsDateInRange(const wxDateTime& date) const -{ - // Check if the given date is in the range specified - return ( ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) - && ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ); -} - -bool wxGenericCalendarCtrl::AdjustDateToRange(wxDateTime *date) const -{ - if ( m_lowdate.IsValid() && *date < m_lowdate ) - { - *date = m_lowdate; - return true; - } - - if ( m_highdate.IsValid() && *date > m_highdate ) - { - *date = m_highdate; - return true; - } - - return false; -} - -size_t wxGenericCalendarCtrl::GetWeek(const wxDateTime& date) const -{ - size_t retval = date.GetWeekOfMonth(HasFlag(wxCAL_MONDAY_FIRST) - ? wxDateTime::Monday_First - : wxDateTime::Sunday_First); - - if ( (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) - { - // we need to offset an extra week if we "start" on the 1st of the month - wxDateTime::Tm tm = date.GetTm(); - - wxDateTime datetest = wxDateTime(1, tm.mon, tm.year); - - // rewind back - datetest.SetToPrevWeekDay(GetWeekStart()); - - if ( datetest.GetDay() == 1 ) - { - retval += 1; - } - } - - return retval; -} - -// ---------------------------------------------------------------------------- -// size management -// ---------------------------------------------------------------------------- - -// this is a composite control and it must arrange its parts each time its -// size or position changes: the combobox and spinctrl are along the top of -// the available area and the calendar takes up the rest of the space - -// the static controls are supposed to be always smaller than combo/spin so we -// always use the latter for size calculations and position the static to take -// the same space - -// the constants used for the layout -#define VERT_MARGIN 5 // distance between combo and calendar -#define HORZ_MARGIN 5 // spin - -wxSize wxGenericCalendarCtrl::DoGetBestSize() const -{ - // calc the size of the calendar - const_cast(this)->RecalcGeometry(); - - wxCoord width = 7*m_widthCol + m_calendarWeekWidth, - height = 7*m_heightRow + m_rowOffset + VERT_MARGIN; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - const wxSize bestSizeCombo = m_comboMonth->GetBestSize(); - - height += wxMax(bestSizeCombo.y, m_spinYear->GetBestSize().y) - + VERT_MARGIN; - - wxCoord w2 = bestSizeCombo.x + HORZ_MARGIN + GetCharWidth()*8; - if ( width < w2 ) - width = w2; - } - - wxSize best(width, height); - if ( !HasFlag(wxBORDER_NONE) ) - { - best += GetWindowBorderSize(); - } - - CacheBestSize(best); - - return best; -} - -void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) -{ - int yDiff; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && m_staticMonth ) - { - wxSize sizeCombo = m_comboMonth->GetEffectiveMinSize(); - wxSize sizeStatic = m_staticMonth->GetSize(); - wxSize sizeSpin = m_spinYear->GetSize(); - - int maxHeight = wxMax(sizeSpin.y, sizeCombo.y); - int dy = (maxHeight - sizeStatic.y) / 2; - m_comboMonth->Move(x, y + (maxHeight - sizeCombo.y)/2); - m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1); - - int xDiff = sizeCombo.x + HORZ_MARGIN; - - m_spinYear->SetSize(x + xDiff, y + (maxHeight - sizeSpin.y)/2, width - xDiff, maxHeight); - m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y); - - yDiff = maxHeight + VERT_MARGIN; - } - else // no controls on the top - { - yDiff = 0; - } - - wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff); -} - -void wxGenericCalendarCtrl::DoGetSize(int *width, int *height) const -{ - wxControl::DoGetSize( width, height ); -} - -void wxGenericCalendarCtrl::RecalcGeometry() -{ - wxClientDC dc(this); - - dc.SetFont(GetFont()); - - // determine the column width (weekday names are not necessarily wider - // than the numbers (in some languages), so let's not assume that they are) - m_widthCol = 0; - for ( int day = 10; day <= 31; day++) - { - wxCoord width; - dc.GetTextExtent(wxString::Format(wxT("%d"), day), &width, &m_heightRow); - if ( width > m_widthCol ) - { - // 1.5 times the width gives nice margins even if the weekday - // names are short - m_widthCol = width+width/2; - } - } - wxDateTime::WeekDay wd; - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) - { - wxCoord width; - dc.GetTextExtent(m_weekdays[wd], &width, &m_heightRow); - if ( width > m_widthCol ) - { - m_widthCol = width; - } - } - - m_calendarWeekWidth = HasFlag( wxCAL_SHOW_WEEK_NUMBERS ) - ? dc.GetTextExtent( wxString::Format( wxT( "%d" ), 42 )).GetWidth() + 4 : 0; - - // leave some margins - m_widthCol += 2; - m_heightRow += 2; - - m_rowOffset = HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ? m_heightRow : 0; // conditional in relation to style -} - -// ---------------------------------------------------------------------------- -// drawing -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - dc.SetFont(GetFont()); - - RecalcGeometry(); - -#if DEBUG_PAINT - wxLogDebug("--- starting to paint, selection: %s, week %u\n", - m_date.Format("%a %d-%m-%Y %H:%M:%S").c_str(), - GetWeek(m_date)); -#endif - - wxCoord y = 0; - wxCoord x0 = m_calendarWeekWidth; - - if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // draw the sequential month-selector - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(*wxBLACK); - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); - dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); - - // Get extent of month-name + year - wxCoord monthw, monthh; - wxString headertext = m_date.Format(wxT("%B %Y")); - dc.GetTextExtent(headertext, &monthw, &monthh); - - // draw month-name centered above weekdays - wxCoord monthx = ((m_widthCol * 7) - monthw) / 2 + x0; - wxCoord monthy = ((m_heightRow - monthh) / 2) + y; - dc.DrawText(headertext, monthx, monthy); - - // calculate the "month-arrows" - wxPoint leftarrow[3]; - wxPoint rightarrow[3]; - - int arrowheight = monthh / 2; - - leftarrow[0] = wxPoint(0, arrowheight / 2); - leftarrow[1] = wxPoint(arrowheight / 2, 0); - leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1); - - rightarrow[0] = wxPoint(0,0); - rightarrow[1] = wxPoint(arrowheight / 2, arrowheight / 2); - rightarrow[2] = wxPoint(0, arrowheight - 1); - - // draw the "month-arrows" - - wxCoord arrowy = (m_heightRow - arrowheight) / 2; - wxCoord larrowx = (m_widthCol - (arrowheight / 2)) / 2 + x0; - wxCoord rarrowx = ((m_widthCol - (arrowheight / 2)) / 2) + m_widthCol*6 + x0; - m_leftArrowRect = m_rightArrowRect = wxRect(0,0,0,0); - - if ( AllowMonthChange() ) - { - wxDateTime ldpm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) - wxDateSpan::Day(); // last day prev month - // Check if range permits change - if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) - { - m_leftArrowRect = wxRect(larrowx - 3, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); - dc.SetBrush(*wxBLACK_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawPolygon(3, leftarrow, larrowx , arrowy, wxWINDING_RULE); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(m_leftArrowRect); - } - wxDateTime fdnm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) + wxDateSpan::Month(); // first day next month - if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) - { - m_rightArrowRect = wxRect(rarrowx - 4, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); - dc.SetBrush(*wxBLACK_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawPolygon(3, rightarrow, rarrowx , arrowy, wxWINDING_RULE); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(m_rightArrowRect); - } - } - - y += m_heightRow; - } - - // first draw the week days - if ( IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow) ) - { -#if DEBUG_PAINT - wxLogDebug("painting the header"); -#endif - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(m_colHeaderFg); - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); - dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); - - bool startOnMonday = HasFlag(wxCAL_MONDAY_FIRST); - for ( int wd = 0; wd < 7; wd++ ) - { - size_t n; - if ( startOnMonday ) - n = wd == 6 ? 0 : wd + 1; - else - n = wd; - wxCoord dayw, dayh; - dc.GetTextExtent(m_weekdays[n], &dayw, &dayh); - dc.DrawText(m_weekdays[n], x0 + (wd*m_widthCol) + ((m_widthCol- dayw) / 2), y); // center the day-name - } - } - - // then the calendar itself - dc.SetTextForeground(*wxBLACK); - //dc.SetFont(*wxNORMAL_FONT); - - y += m_heightRow; - - // draw column with calendar week nr - if ( HasFlag( wxCAL_SHOW_WEEK_NUMBERS ) && IsExposed( 0, y, m_calendarWeekWidth, m_heightRow * 6 )) - { - dc.SetBackgroundMode(wxTRANSPARENT); - dc.SetBrush(wxBrush(m_colHeaderBg, wxSOLID)); - dc.SetPen(wxPen(m_colHeaderBg, 1, wxSOLID)); - dc.DrawRectangle( 0, y, m_calendarWeekWidth, m_heightRow * 6 ); - wxDateTime date = GetStartDate(); - for ( size_t i = 0; i < 6; ++i ) - { - const int weekNr = date.GetWeekOfYear(); - wxString text = wxString::Format( wxT( "%d" ), weekNr ); - dc.DrawText( text, m_calendarWeekWidth - dc.GetTextExtent( text ).GetWidth() - 2, y + m_heightRow * i ); - date += wxDateSpan::Week(); - } - } - - wxDateTime date = GetStartDate(); - -#if DEBUG_PAINT - wxLogDebug("starting calendar from %s\n", - date.Format("%a %d-%m-%Y %H:%M:%S").c_str()); -#endif - - dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); - for ( size_t nWeek = 1; nWeek <= 6; nWeek++, y += m_heightRow ) - { - // if the update region doesn't intersect this row, don't paint it - if ( !IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow - 1) ) - { - date += wxDateSpan::Week(); - - continue; - } - -#if DEBUG_PAINT - wxLogDebug("painting week %d at y = %d\n", nWeek, y); -#endif - - for ( int wd = 0; wd < 7; wd++ ) - { - dc.SetTextBackground(m_colBackground); - if ( IsDateShown(date) ) - { - // don't use wxDate::Format() which prepends 0s - unsigned int day = date.GetDay(); - wxString dayStr = wxString::Format(wxT("%u"), day); - wxCoord width; - dc.GetTextExtent(dayStr, &width, NULL); - - bool changedColours = false, - changedFont = false; - - bool isSel = false; - wxCalendarDateAttr *attr = NULL; - - if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) ) - { - // draw the days of adjacent months in different colour - dc.SetTextForeground(m_colSurrounding); - changedColours = true; - } - else - { - isSel = date.IsSameDate(m_date); - attr = m_attrs[day - 1]; - - if ( isSel ) - { - dc.SetTextForeground(m_colHighlightFg); - dc.SetTextBackground(m_colHighlightBg); - - changedColours = true; - } - else if ( attr ) - { - wxColour colFg, colBg; - - if ( attr->IsHoliday() ) - { - colFg = m_colHolidayFg; - colBg = m_colHolidayBg; - } - else - { - colFg = attr->GetTextColour(); - colBg = attr->GetBackgroundColour(); - } - - if ( colFg.IsOk() ) - { - dc.SetTextForeground(colFg); - changedColours = true; - } - - if ( colBg.IsOk() ) - { - dc.SetTextBackground(colBg); - changedColours = true; - } - - if ( attr->HasFont() ) - { - dc.SetFont(attr->GetFont()); - changedFont = true; - } - } - } - - wxCoord x = wd*m_widthCol + (m_widthCol - width) / 2 + x0; - dc.DrawText(dayStr, x, y + 1); - - if ( !isSel && attr && attr->HasBorder() ) - { - wxColour colBorder; - if ( attr->HasBorderColour() ) - { - colBorder = attr->GetBorderColour(); - } - else - { - colBorder = GetForegroundColour(); - } - - wxPen pen(colBorder, 1, wxPENSTYLE_SOLID); - dc.SetPen(pen); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - switch ( attr->GetBorder() ) - { - case wxCAL_BORDER_SQUARE: - dc.DrawRectangle(x - 2, y, - width + 4, m_heightRow); - break; - - case wxCAL_BORDER_ROUND: - dc.DrawEllipse(x - 2, y, - width + 4, m_heightRow); - break; - - default: - wxFAIL_MSG(wxT("unknown border type")); - } - } - - if ( changedColours ) - { - dc.SetTextForeground(GetForegroundColour()); - dc.SetTextBackground(GetBackgroundColour()); - } - - if ( changedFont ) - { - dc.SetFont(GetFont()); - } - } - //else: just don't draw it - - date += wxDateSpan::Day(); - } - } - - // Greying out out-of-range background - bool showSurrounding = (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) != 0; - - date = ( showSurrounding ) ? GetStartDate() : wxDateTime(1, m_date.GetMonth(), m_date.GetYear()); - if ( !IsDateInRange(date) ) - { - wxDateTime firstOOR = GetLowerDateLimit() - wxDateSpan::Day(); // first out-of-range - - wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; - oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); - - HighlightRange(&dc, date, firstOOR, wxTRANSPARENT_PEN, &oorbrush); - } - - date = ( showSurrounding ) ? GetStartDate() + wxDateSpan::Weeks(6) - wxDateSpan::Day() : wxDateTime().SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()); - if ( !IsDateInRange(date) ) - { - wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range - - wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; - oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); - - HighlightRange(&dc, firstOOR, date, wxTRANSPARENT_PEN, &oorbrush); - } - -#if DEBUG_PAINT - wxLogDebug("+++ finished painting"); -#endif -} - -void wxGenericCalendarCtrl::RefreshDate(const wxDateTime& date) -{ - RecalcGeometry(); - - wxRect rect; - - // always refresh the whole row at once because our OnPaint() will draw - // the whole row anyhow - and this allows the small optimization in - // OnClick() below to work - rect.x = m_calendarWeekWidth; - - rect.y = (m_heightRow * GetWeek(date)) + m_rowOffset; - - rect.width = 7*m_widthCol; - rect.height = m_heightRow; - -#ifdef __WXMSW__ - // VZ: for some reason, the selected date seems to occupy more space under - // MSW - this is probably some bug in the font size calculations, but I - // don't know where exactly. This fix is ugly and leads to more - // refreshes than really needed, but without it the selected days - // leaves even more ugly underscores on screen. - rect.Inflate(0, 1); -#endif // MSW - -#if DEBUG_PAINT - wxLogDebug("*** refreshing week %d at (%d, %d)-(%d, %d)\n", - GetWeek(date), - rect.x, rect.y, - rect.x + rect.width, rect.y + rect.height); -#endif - - Refresh(true, &rect); -} - -void wxGenericCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pPen, const wxBrush* pBrush) -{ - // Highlights the given range using pen and brush - // Does nothing if todate < fromdate - - -#if DEBUG_PAINT - wxLogDebug("+++ HighlightRange: (%s) - (%s) +++", fromdate.Format("%d %m %Y"), todate.Format("%d %m %Y")); -#endif - - if ( todate >= fromdate ) - { - // do stuff - // date-coordinates - int fd, fw; - int td, tw; - - // implicit: both dates must be currently shown - checked by GetDateCoord - if ( GetDateCoord(fromdate, &fd, &fw) && GetDateCoord(todate, &td, &tw) ) - { -#if DEBUG_PAINT - wxLogDebug("Highlight range: (%i, %i) - (%i, %i)", fd, fw, td, tw); -#endif - if ( ( (tw - fw) == 1 ) && ( td < fd ) ) - { - // special case: interval 7 days or less not in same week - // split in two separate intervals - wxDateTime tfd = fromdate + wxDateSpan::Days(7-fd); - wxDateTime ftd = tfd + wxDateSpan::Day(); -#if DEBUG_PAINT - wxLogDebug("Highlight: Separate segments"); -#endif - // draw separately - HighlightRange(pDC, fromdate, tfd, pPen, pBrush); - HighlightRange(pDC, ftd, todate, pPen, pBrush); - } - else - { - int numpoints; - wxPoint corners[8]; // potentially 8 corners in polygon - wxCoord x0 = m_calendarWeekWidth; - - if ( fw == tw ) - { - // simple case: same week - numpoints = 4; - corners[0] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); - corners[1] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1 ) * m_heightRow) + m_rowOffset); - corners[2] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); - corners[3] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); - } - else - { - int cidx = 0; - // "complex" polygon - corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; - - if ( fd > 1 ) - { - corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; - } - - corners[cidx] = wxPoint(x0, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; - - if ( td < 7 ) - { - corners[cidx] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; - } - - corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; - - numpoints = cidx; - } - - // draw the polygon - pDC->SetBrush(*pBrush); - pDC->SetPen(*pPen); - pDC->DrawPolygon(numpoints, corners); - } - } - } - // else do nothing -#if DEBUG_PAINT - wxLogDebug("--- HighlightRange ---"); -#endif -} - -bool wxGenericCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const -{ - bool retval = true; - -#if DEBUG_PAINT - wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y")); -#endif - - if ( IsDateShown(date) ) - { - bool startOnMonday = HasFlag(wxCAL_MONDAY_FIRST); - - // Find day - *day = date.GetWeekDay(); - - if ( *day == 0 ) // sunday - { - *day = ( startOnMonday ) ? 7 : 1; - } - else - { - *day += ( startOnMonday ) ? 0 : 1; - } - - int targetmonth = date.GetMonth() + (12 * date.GetYear()); - int thismonth = m_date.GetMonth() + (12 * m_date.GetYear()); - - // Find week - if ( targetmonth == thismonth ) - { - *week = GetWeek(date); - } - else - { - if ( targetmonth < thismonth ) - { - *week = 1; // trivial - } - else // targetmonth > thismonth - { - wxDateTime ldcm; - int lastweek; - int lastday; - - // get the datecoord of the last day in the month currently shown -#if DEBUG_PAINT - wxLogDebug(" +++ LDOM +++"); -#endif - GetDateCoord(ldcm.SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()), &lastday, &lastweek); -#if DEBUG_PAINT - wxLogDebug(" --- LDOM ---"); -#endif - - wxTimeSpan span = date - ldcm; - - int daysfromlast = span.GetDays(); -#if DEBUG_PAINT - wxLogDebug("daysfromlast: %i", daysfromlast); -#endif - if ( daysfromlast + lastday > 7 ) // past week boundary - { - int wholeweeks = (daysfromlast / 7); - *week = wholeweeks + lastweek; - if ( (daysfromlast - (7 * wholeweeks) + lastday) > 7 ) - { - *week += 1; - } - } - else - { - *week = lastweek; - } - } - } - } - else - { - *day = -1; - *week = -1; - retval = false; - } - -#if DEBUG_PAINT - wxLogDebug("--- GetDateCoord: (%s) = (%i, %i) ---", date.Format("%d %m %Y"), *day, *week); -#endif - - return retval; -} - -// ---------------------------------------------------------------------------- -// mouse handling -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::OnDClick(wxMouseEvent& event) -{ - if ( HitTest(event.GetPosition()) != wxCAL_HITTEST_DAY ) - { - event.Skip(); - } - else - { - GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); - } -} - -void wxGenericCalendarCtrl::OnClick(wxMouseEvent& event) -{ - wxDateTime date; - wxDateTime::WeekDay wday; - switch ( HitTest(event.GetPosition(), &date, &wday) ) - { - case wxCAL_HITTEST_DAY: - if ( IsDateInRange(date) ) - { - ChangeDay(date); - - GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); - - // we know that the month/year never change when the user - // clicks on the control so there is no need to call - // GenerateAllChangeEvents() here, we know which event to send - GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); - } - break; - - case wxCAL_HITTEST_WEEK: - { - wxCalendarEvent send( this, date, wxEVT_CALENDAR_WEEK_CLICKED ); - HandleWindowEvent( send ); - } - break; - - case wxCAL_HITTEST_HEADER: - { - wxCalendarEvent eventWd(this, GetDate(), - wxEVT_CALENDAR_WEEKDAY_CLICKED); - eventWd.SetWeekDay(wday); - (void)GetEventHandler()->ProcessEvent(eventWd); - } - break; - - case wxCAL_HITTEST_DECMONTH: - case wxCAL_HITTEST_INCMONTH: - case wxCAL_HITTEST_SURROUNDING_WEEK: - SetDateAndNotify(date); // we probably only want to refresh the control. No notification.. (maybe as an option?) - break; - - default: - wxFAIL_MSG(wxT("unknown hittest code")); - // fall through - - case wxCAL_HITTEST_NOWHERE: - event.Skip(); - break; - } - - // as we don't (always) skip the message, we're not going to receive the - // focus on click by default if we don't do it ourselves - SetFocus(); -} - -wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos, - wxDateTime *date, - wxDateTime::WeekDay *wd) -{ - RecalcGeometry(); - - // the position where the calendar really begins - wxCoord x0 = m_calendarWeekWidth; - - if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // Header: month - - // we need to find out if the hit is on left arrow, on month or on right arrow - // left arrow? - if ( m_leftArrowRect.Contains(pos) ) - { - if ( date ) - { - if ( IsDateInRange(m_date - wxDateSpan::Month()) ) - { - *date = m_date - wxDateSpan::Month(); - } - else - { - *date = GetLowerDateLimit(); - } - } - - return wxCAL_HITTEST_DECMONTH; - } - - if ( m_rightArrowRect.Contains(pos) ) - { - if ( date ) - { - if ( IsDateInRange(m_date + wxDateSpan::Month()) ) - { - *date = m_date + wxDateSpan::Month(); - } - else - { - *date = GetUpperDateLimit(); - } - } - - return wxCAL_HITTEST_INCMONTH; - } - } - - if ( pos.x - x0 < 0 ) - { - if ( pos.x >= 0 && pos.y > m_rowOffset + m_heightRow && pos.y <= m_rowOffset + m_heightRow * 7 ) - { - if ( date ) - { - *date = GetStartDate(); - *date += wxDateSpan::Week() * (( pos.y - m_rowOffset ) / m_heightRow - 1 ); - } - if ( wd ) - *wd = GetWeekStart(); - return wxCAL_HITTEST_WEEK; - } - else // early exit -> the rest of the function checks for clicks on days - return wxCAL_HITTEST_NOWHERE; - } - - // header: week days - int wday = (pos.x - x0) / m_widthCol; - if ( wday > 6 ) - return wxCAL_HITTEST_NOWHERE; - if ( pos.y < (m_heightRow + m_rowOffset)) - { - if ( pos.y > m_rowOffset ) - { - if ( wd ) - { - if ( HasFlag(wxCAL_MONDAY_FIRST) ) - { - wday = wday == 6 ? 0 : wday + 1; - } - - *wd = (wxDateTime::WeekDay)wday; - } - - return wxCAL_HITTEST_HEADER; - } - else - { - return wxCAL_HITTEST_NOWHERE; - } - } - - int week = (pos.y - (m_heightRow + m_rowOffset)) / m_heightRow; - if ( week >= 6 || wday >= 7 ) - { - return wxCAL_HITTEST_NOWHERE; - } - - wxDateTime dt = GetStartDate() + wxDateSpan::Days(7*week + wday); - - if ( IsDateShown(dt) ) - { - if ( date ) - *date = dt; - - if ( dt.GetMonth() == m_date.GetMonth() ) - { - - return wxCAL_HITTEST_DAY; - } - else - { - return wxCAL_HITTEST_SURROUNDING_WEEK; - } - } - else - { - return wxCAL_HITTEST_NOWHERE; - } -} - -// ---------------------------------------------------------------------------- -// subcontrols events handling -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::OnMonthChange(wxCommandEvent& event) -{ - wxDateTime::Tm tm = m_date.GetTm(); - - wxDateTime::Month mon = (wxDateTime::Month)event.GetInt(); - if ( tm.mday > wxDateTime::GetNumberOfDays(mon, tm.year) ) - { - tm.mday = wxDateTime::GetNumberOfDays(mon, tm.year); - } - - wxDateTime dt(tm.mday, mon, tm.year); - if ( AdjustDateToRange(&dt) ) - { - // The date must have been changed to ensure it's in valid range, - // reflect this in the month choice control. - m_comboMonth->SetSelection(dt.GetMonth()); - } - - SetDateAndNotify(dt); -} - -void wxGenericCalendarCtrl::HandleYearChange(wxCommandEvent& event) -{ - int year = (int)event.GetInt(); - if ( year == INT_MIN ) - { - // invalid year in the spin control, ignore it - return; - } - - wxDateTime::Tm tm = m_date.GetTm(); - - if ( tm.mday > wxDateTime::GetNumberOfDays(tm.mon, year) ) - { - tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year); - } - - wxDateTime dt(tm.mday, tm.mon, year); - if ( AdjustDateToRange(&dt) ) - { - // As above, if the date was changed to keep it in valid range, its - // possibly changed year must be shown in the GUI. - m_spinYear->SetValue(dt.GetYear()); - } - - SetDateAndNotify(dt); -} - -void wxGenericCalendarCtrl::OnYearChange(wxSpinEvent& event) -{ - HandleYearChange( event ); -} - -void wxGenericCalendarCtrl::OnYearTextChange(wxCommandEvent& event) -{ - SetUserChangedYear(); - HandleYearChange(event); -} - -// Responds to colour changes, and passes event on to children. -void wxGenericCalendarCtrl::OnSysColourChanged(wxSysColourChangedEvent& event) -{ - // reinit colours - InitColours(); - - // Propagate the event to the children - wxControl::OnSysColourChanged(event); - - // Redraw control area - SetBackgroundColour(m_colBackground); - Refresh(); -} - -// ---------------------------------------------------------------------------- -// keyboard interface -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::OnChar(wxKeyEvent& event) -{ - switch ( event.GetKeyCode() ) - { - case wxT('+'): - case WXK_ADD: - SetDateAndNotify(m_date + wxDateSpan::Year()); - break; - - case wxT('-'): - case WXK_SUBTRACT: - SetDateAndNotify(m_date - wxDateSpan::Year()); - break; - - case WXK_PAGEUP: - SetDateAndNotify(m_date - wxDateSpan::Month()); - break; - - case WXK_PAGEDOWN: - SetDateAndNotify(m_date + wxDateSpan::Month()); - break; - - case WXK_RIGHT: - if ( event.ControlDown() ) - { - wxDateTime target = m_date.SetToNextWeekDay(GetWeekEnd()); - AdjustDateToRange(&target); - SetDateAndNotify(target); - } - else - SetDateAndNotify(m_date + wxDateSpan::Day()); - break; - - case WXK_LEFT: - if ( event.ControlDown() ) - { - wxDateTime target = m_date.SetToPrevWeekDay(GetWeekStart()); - AdjustDateToRange(&target); - SetDateAndNotify(target); - } - else - SetDateAndNotify(m_date - wxDateSpan::Day()); - break; - - case WXK_UP: - SetDateAndNotify(m_date - wxDateSpan::Week()); - break; - - case WXK_DOWN: - SetDateAndNotify(m_date + wxDateSpan::Week()); - break; - - case WXK_HOME: - if ( event.ControlDown() ) - SetDateAndNotify(wxDateTime::Today()); - else - SetDateAndNotify(wxDateTime(1, m_date.GetMonth(), m_date.GetYear())); - break; - - case WXK_END: - SetDateAndNotify(wxDateTime(m_date).SetToLastMonthDay()); - break; - - case WXK_RETURN: - GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); - break; - - default: - event.Skip(); - } -} - -// ---------------------------------------------------------------------------- -// holidays handling -// ---------------------------------------------------------------------------- - -void wxGenericCalendarCtrl::SetHoliday(size_t day) -{ - wxCHECK_RET( day > 0 && day < 32, wxT("invalid day in SetHoliday") ); - - wxCalendarDateAttr *attr = GetAttr(day); - if ( !attr ) - { - attr = new wxCalendarDateAttr; - } - - attr->SetHoliday(true); - - // can't use SetAttr() because it would delete this pointer - m_attrs[day - 1] = attr; -} - -void wxGenericCalendarCtrl::ResetHolidayAttrs() -{ - for ( size_t day = 0; day < 31; day++ ) - { - if ( m_attrs[day] ) - { - m_attrs[day]->SetHoliday(false); - } - } -} - -void wxGenericCalendarCtrl::Mark(size_t day, bool mark) -{ - wxCHECK_RET( day > 0 && day < 32, wxT("invalid day in Mark") ); - - const wxCalendarDateAttr& m = wxCalendarDateAttr::GetMark(); - if (mark) { - if ( m_attrs[day - 1] ) - AddAttr(m_attrs[day - 1], m); - else - SetAttr(day, new wxCalendarDateAttr(m)); - } - else { - if ( m_attrs[day - 1] ) - DelAttr(m_attrs[day - 1], m); - } -} - -//static -wxVisualAttributes -wxGenericCalendarCtrl::GetClassDefaultAttributes(wxWindowVariant variant) -{ - // Use the same color scheme as wxListBox - return wxListBox::GetClassDefaultAttributes(variant); -} - -#endif // wxUSE_CALENDARCTRL diff --git a/Source/3rd Party/wx/src/generic/caret.cpp b/Source/3rd Party/wx/src/generic/caret.cpp deleted file mode 100644 index 0f5aa7ac5..000000000 --- a/Source/3rd Party/wx/src/generic/caret.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/caret.cpp -// Purpose: generic wxCaret class implementation -// Author: Vadim Zeitlin (original code by Robert Roebling) -// Modified by: -// Created: 25.05.99 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CARET - -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/dcclient.h" - #include "wx/dcmemory.h" -#endif //WX_PRECOMP - -#include "wx/caret.h" - -// ---------------------------------------------------------------------------- -// global variables for this module -// ---------------------------------------------------------------------------- - -// the blink time (common to all carets for MSW compatibility) -static int gs_blinkTime = 500; // in milliseconds - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// timer stuff -// ---------------------------------------------------------------------------- - -wxCaretTimer::wxCaretTimer(wxCaret *caret) -{ - m_caret = caret; -} - -void wxCaretTimer::Notify() -{ - m_caret->OnTimer(); -} - -void wxCaret::OnTimer() -{ - // don't blink the caret when we don't have the focus - if ( m_hasFocus ) - Blink(); -} - -// ---------------------------------------------------------------------------- -// wxCaret static functions and data -// ---------------------------------------------------------------------------- - -int wxCaretBase::GetBlinkTime() -{ - return gs_blinkTime; -} - -void wxCaretBase::SetBlinkTime(int milliseconds) -{ - gs_blinkTime = milliseconds; - -#ifdef _WXGTK__ - GtkSettings *settings = gtk_settings_get_default(); - if (millseconds == 0) - { - gtk_settings_set_long_property(settings, "gtk-cursor-blink", gtk_false, NULL); - } - else - { - gtk_settings_set_long_property(settings, "gtk-cursor-blink", gtk_true, NULL); - gtk_settings_set_long_property(settings, "gtk-cursor-time", milliseconds, NULL); - } -#endif -} - -// ---------------------------------------------------------------------------- -// initialization and destruction -// ---------------------------------------------------------------------------- - -void wxCaret::InitGeneric() -{ - m_hasFocus = true; - m_blinkedOut = true; -#ifndef wxHAS_CARET_USING_OVERLAYS - m_xOld = - m_yOld = -1; - m_bmpUnderCaret.Create(m_width, m_height); -#endif -} - -wxCaret::~wxCaret() -{ - if ( IsVisible() ) - { - // stop blinking - if ( m_timer.IsRunning() ) - m_timer.Stop(); - } -} - -// ---------------------------------------------------------------------------- -// showing/hiding/moving the caret (base class interface) -// ---------------------------------------------------------------------------- - -void wxCaret::DoShow() -{ - int blinkTime = GetBlinkTime(); - if ( blinkTime ) - m_timer.Start(blinkTime); - - if ( m_blinkedOut ) - Blink(); -} - -void wxCaret::DoHide() -{ - m_timer.Stop(); - - if ( !m_blinkedOut ) - { - Blink(); - } -} - -void wxCaret::DoMove() -{ -#ifdef wxHAS_CARET_USING_OVERLAYS - m_overlay.Reset(); -#endif - if ( IsVisible() ) - { - if ( !m_blinkedOut ) - { - // hide it right now and it will be shown the next time it blinks - Blink(); - - // but if the caret is not blinking, we should blink it back into - // visibility manually - if ( !m_timer.IsRunning() ) - Blink(); - } - } - //else: will be shown at the correct location when it is shown -} - -void wxCaret::DoSize() -{ - int countVisible = m_countVisible; - if (countVisible > 0) - { - m_countVisible = 0; - DoHide(); - } -#ifdef wxHAS_CARET_USING_OVERLAYS - m_overlay.Reset(); -#else - // Change bitmap size - m_bmpUnderCaret = wxBitmap(m_width, m_height); -#endif - if (countVisible > 0) - { - m_countVisible = countVisible; - DoShow(); - } -} - -// ---------------------------------------------------------------------------- -// handling the focus -// ---------------------------------------------------------------------------- - -void wxCaret::OnSetFocus() -{ - m_hasFocus = true; - - if ( IsVisible() ) - Refresh(); -} - -void wxCaret::OnKillFocus() -{ - m_hasFocus = false; - - if ( IsVisible() ) - { - // the caret must be shown - otherwise, if it is hidden now, it will - // stay so until the focus doesn't return because it won't blink any - // more - - // hide it first if it isn't hidden ... - if ( !m_blinkedOut ) - Blink(); - - // .. and show it in the new style - Blink(); - } -} - -// ---------------------------------------------------------------------------- -// drawing the caret -// ---------------------------------------------------------------------------- - -void wxCaret::Blink() -{ - m_blinkedOut = !m_blinkedOut; - - Refresh(); -} - -void wxCaret::Refresh() -{ - wxClientDC dcWin(GetWindow()); -// this is the new code, switch to 0 if this gives problems -#ifdef wxHAS_CARET_USING_OVERLAYS - wxDCOverlay dcOverlay( m_overlay, &dcWin, m_x, m_y, m_width , m_height ); - if ( m_blinkedOut ) - { - dcOverlay.Clear(); - } - else - { - DoDraw( &dcWin, GetWindow() ); - } -#else - wxMemoryDC dcMem; - dcMem.SelectObject(m_bmpUnderCaret); - if ( m_blinkedOut ) - { - // restore the old image - dcWin.Blit(m_xOld, m_yOld, m_width, m_height, - &dcMem, 0, 0); - m_xOld = - m_yOld = -1; - } - else - { - if ( m_xOld == -1 && m_yOld == -1 ) - { - // save the part we're going to overdraw - dcMem.Blit(0, 0, m_width, m_height, - &dcWin, m_x, m_y); - - m_xOld = m_x; - m_yOld = m_y; - } - //else: we already saved the image below the caret, don't do it any - // more - - // and draw the caret there - DoDraw(&dcWin, GetWindow()); - } -#endif -} - -void wxCaret::DoDraw(wxDC *dc, wxWindow* win) -{ - wxPen pen(*wxBLACK_PEN); - wxBrush brush(*wxBLACK_BRUSH); - if (win) - { - wxColour backgroundColour(win->GetBackgroundColour()); - if (backgroundColour.Red() < 100 && - backgroundColour.Green() < 100 && - backgroundColour.Blue() < 100) - { - pen = *wxWHITE_PEN; - brush = *wxWHITE_BRUSH; - } - } - dc->SetPen( pen ); - dc->SetBrush(m_hasFocus ? brush : *wxTRANSPARENT_BRUSH); - - // VZ: unfortunately, the rectangle comes out a pixel smaller when this is - // done under wxGTK - no idea why - //dc->SetLogicalFunction(wxINVERT); - - dc->DrawRectangle(m_x, m_y, m_width, m_height); -} - -#endif // wxUSE_CARET diff --git a/Source/3rd Party/wx/src/generic/choicbkg.cpp b/Source/3rd Party/wx/src/generic/choicbkg.cpp index 8186ae94c..a5df5f1e4 100644 --- a/Source/3rd Party/wx/src/generic/choicbkg.cpp +++ b/Source/3rd Party/wx/src/generic/choicbkg.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: Wlodzimierz ABX Skiba from generic/listbkg.cpp // Created: 15.09.04 +// RCS-ID: $Id: choicbkg.cpp 58355 2009-01-24 14:12:59Z VZ $ // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -47,9 +48,12 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxChoicebook, wxBookCtrlBase) +IMPLEMENT_DYNAMIC_CLASS(wxChoicebookEvent, wxNotifyEvent) -wxDEFINE_EVENT( wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); +#if !WXWIN_COMPATIBILITY_EVENT_TYPES +const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING = wxNewEventType(); +const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED = wxNewEventType(); +#endif BEGIN_EVENT_TABLE(wxChoicebook, wxBookCtrlBase) EVT_CHOICE(wxID_ANY, wxChoicebook::OnChoiceSelected) @@ -63,6 +67,11 @@ END_EVENT_TABLE() // wxChoicebook creation // ---------------------------------------------------------------------------- +void wxChoicebook::Init() +{ + m_selection = wxNOT_FOUND; +} + bool wxChoicebook::Create(wxWindow *parent, wxWindowID id, @@ -105,6 +114,53 @@ wxChoicebook::Create(wxWindow *parent, return true; } +// ---------------------------------------------------------------------------- +// wxChoicebook geometry management +// ---------------------------------------------------------------------------- + +wxSize wxChoicebook::GetControllerSize() const +{ + const wxSize sizeClient = GetClientSize(), + sizeChoice = m_controlSizer->CalcMin(); + + wxSize size; + if ( IsVertical() ) + { + size.x = sizeClient.x; + size.y = sizeChoice.y; + } + else // left/right aligned + { + size.x = sizeChoice.x; + size.y = sizeClient.y; + } + + return size; +} + +wxSize wxChoicebook::CalcSizeFromPage(const wxSize& sizePage) const +{ + // we need to add the size of the choice control and the border between + const wxSize sizeChoice = GetControllerSize(); + + wxSize size = sizePage; + if ( IsVertical() ) + { + if ( sizeChoice.x > sizePage.x ) + size.x = sizeChoice.x; + size.y += sizeChoice.y + GetInternalBorder(); + } + else // left/right aligned + { + size.x += sizeChoice.x + GetInternalBorder(); + if ( sizeChoice.y > sizePage.y ) + size.y = sizeChoice.y; + } + + return size; +} + + // ---------------------------------------------------------------------------- // accessing the pages // ---------------------------------------------------------------------------- @@ -123,31 +179,22 @@ wxString wxChoicebook::GetPageText(size_t n) const int wxChoicebook::GetPageImage(size_t WXUNUSED(n)) const { + wxFAIL_MSG( _T("wxChoicebook::GetPageImage() not implemented") ); + return wxNOT_FOUND; } bool wxChoicebook::SetPageImage(size_t WXUNUSED(n), int WXUNUSED(imageId)) { - // fail silently, the code may be written to use one of several book - // classes and call SetPageImage() unconditionally, it's better to just - // ignore it (which is the best we can do short of rewriting this class to - // use wxBitmapComboBox anyhow) than complain loudly about a rather - // harmless problem + wxFAIL_MSG( _T("wxChoicebook::SetPageImage() not implemented") ); return false; } // ---------------------------------------------------------------------------- -// miscellaneous other stuff +// image list stuff // ---------------------------------------------------------------------------- -void wxChoicebook::DoSetWindowVariant(wxWindowVariant variant) -{ - wxBookCtrlBase::DoSetWindowVariant(variant); - if (m_bookctrl) - m_bookctrl->SetWindowVariant(variant); -} - void wxChoicebook::SetImageList(wxImageList *imageList) { // TODO: can be implemented in form of static bitmap near choice control @@ -159,14 +206,19 @@ void wxChoicebook::SetImageList(wxImageList *imageList) // selection // ---------------------------------------------------------------------------- -wxBookCtrlEvent* wxChoicebook::CreatePageChangingEvent() const +int wxChoicebook::GetSelection() const { - return new wxBookCtrlEvent(wxEVT_CHOICEBOOK_PAGE_CHANGING, m_windowId); + return m_selection; } -void wxChoicebook::MakeChangedEvent(wxBookCtrlEvent &event) +wxBookCtrlBaseEvent* wxChoicebook::CreatePageChangingEvent() const { - event.SetEventType(wxEVT_CHOICEBOOK_PAGE_CHANGED); + return new wxChoicebookEvent(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, m_windowId); +} + +void wxChoicebook::MakeChangedEvent(wxBookCtrlBaseEvent &event) +{ + event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED); } // ---------------------------------------------------------------------------- @@ -194,21 +246,47 @@ wxChoicebook::InsertPage(size_t n, GetChoiceCtrl()->Select(m_selection); } - if ( !DoSetSelectionAfterInsertion(n, bSelect) ) + // some page should be selected: either this one or the first one if there + // is still no selection + int selNew = wxNOT_FOUND; + if ( bSelect ) + selNew = n; + else if ( m_selection == wxNOT_FOUND ) + selNew = 0; + + if ( selNew != m_selection ) page->Hide(); + if ( selNew != wxNOT_FOUND ) + SetSelection(selNew); + return true; } wxWindow *wxChoicebook::DoRemovePage(size_t page) { + const size_t page_count = GetPageCount(); wxWindow *win = wxBookCtrlBase::DoRemovePage(page); if ( win ) { GetChoiceCtrl()->Delete(page); - DoSetSelectionAfterRemoval(page); + if (m_selection >= (int)page) + { + // force new sel valid if possible + int sel = m_selection - 1; + if (page_count == 1) + sel = wxNOT_FOUND; + else if ((page_count == 2) || (sel == -1)) + sel = 0; + + // force sel invalid if deleting current page - don't try to hide it + m_selection = (m_selection == (int)page) ? wxNOT_FOUND : m_selection - 1; + + if ((sel != wxNOT_FOUND) && (sel != m_selection)) + SetSelection(sel); + } } return win; @@ -217,6 +295,7 @@ wxWindow *wxChoicebook::DoRemovePage(size_t page) bool wxChoicebook::DeleteAllPages() { + m_selection = wxNOT_FOUND; GetChoiceCtrl()->Clear(); return wxBookCtrlBase::DeleteAllPages(); } diff --git a/Source/3rd Party/wx/src/generic/choicdgg.cpp b/Source/3rd Party/wx/src/generic/choicdgg.cpp index 7d6efd7ab..1caf90aa3 100644 --- a/Source/3rd Party/wx/src/generic/choicdgg.cpp +++ b/Source/3rd Party/wx/src/generic/choicdgg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions // Created: 04/01/98 +// RCS-ID: $Id: choicdgg.cpp 44620 2007-03-06 09:56:43Z JS $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -86,13 +87,9 @@ wxString wxGetSingleChoice( const wxString& message, wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height), - int initialSelection) + int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - - dialog.SetSelection(initialSelection); - wxString choice; if ( dialog.ShowModal() == wxID_OK ) choice = dialog.GetStringSelection(); @@ -106,56 +103,26 @@ wxString wxGetSingleChoice( const wxString& message, wxWindow *parent, int x, int y, bool centre, - int width, int height, - int initialSelection) + int width, int height) { wxString *choices; int n = ConvertWXArrayToC(aChoices, &choices); wxString res = wxGetSingleChoice(message, caption, n, choices, parent, - x, y, centre, width, height, - initialSelection); + x, y, centre, width, height); delete [] choices; return res; } -wxString wxGetSingleChoice( const wxString& message, - const wxString& caption, - const wxArrayString& choices, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoice(message, caption, choices, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - -wxString wxGetSingleChoice( const wxString& message, - const wxString& caption, - int n, const wxString *choices, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoice(message, caption, n, choices, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n, const wxString *choices, wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height), - int initialSelection) + int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - - dialog.SetSelection(initialSelection); - int choice; if ( dialog.ShowModal() == wxID_OK ) choice = dialog.GetSelection(); @@ -171,45 +138,17 @@ int wxGetSingleChoiceIndex( const wxString& message, wxWindow *parent, int x, int y, bool centre, - int width, int height, - int initialSelection) + int width, int height) { wxString *choices; int n = ConvertWXArrayToC(aChoices, &choices); int res = wxGetSingleChoiceIndex(message, caption, n, choices, parent, - x, y, centre, width, height, - initialSelection); + x, y, centre, width, height); delete [] choices; return res; } -int wxGetSingleChoiceIndex( const wxString& message, - const wxString& caption, - const wxArrayString& choices, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoiceIndex(message, caption, choices, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - - -int wxGetSingleChoiceIndex( const wxString& message, - const wxString& caption, - int n, const wxString *choices, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoiceIndex(message, caption, n, choices, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - - void *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n, const wxString *choices, @@ -217,17 +156,13 @@ void *wxGetSingleChoiceData( const wxString& message, wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height), - int initialSelection) + int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices, - client_data); - - dialog.SetSelection(initialSelection); - + (char **)client_data); void *data; if ( dialog.ShowModal() == wxID_OK ) - data = dialog.GetSelectionData(); + data = dialog.GetSelectionClientData(); else data = NULL; @@ -241,50 +176,19 @@ void *wxGetSingleChoiceData( const wxString& message, wxWindow *parent, int x, int y, bool centre, - int width, int height, - int initialSelection) + int width, int height) { wxString *choices; int n = ConvertWXArrayToC(aChoices, &choices); void *res = wxGetSingleChoiceData(message, caption, n, choices, client_data, parent, - x, y, centre, width, height, - initialSelection); + x, y, centre, width, height); delete [] choices; return res; } -void* wxGetSingleChoiceData( const wxString& message, - const wxString& caption, - const wxArrayString& choices, - void **client_data, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoiceData(message, caption, choices, - client_data, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - -void* wxGetSingleChoiceData( const wxString& message, - const wxString& caption, - int n, const wxString *choices, - void **client_data, - int initialSelection, - wxWindow *parent) -{ - return wxGetSingleChoiceData(message, caption, n, choices, - client_data, parent, - wxDefaultCoord, wxDefaultCoord, - true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT, - initialSelection); -} - - -int wxGetSelectedChoices(wxArrayInt& selections, +size_t wxGetMultipleChoices(wxArrayInt& selections, const wxString& message, const wxString& caption, int n, const wxString *choices, @@ -299,19 +203,15 @@ int wxGetSelectedChoices(wxArrayInt& selections, // deselects the first item which is selected by default dialog.SetSelections(selections); - if ( dialog.ShowModal() != wxID_OK ) - { - // NB: intentionally do not clear the selections array here, the caller - // might want to preserve its original contents if the dialog was - // cancelled - return -1; - } + if ( dialog.ShowModal() == wxID_OK ) + selections = dialog.GetSelections(); + else + selections.Empty(); - selections = dialog.GetSelections(); return selections.GetCount(); } -int wxGetSelectedChoices(wxArrayInt& selections, +size_t wxGetMultipleChoices(wxArrayInt& selections, const wxString& message, const wxString& caption, const wxArrayString& aChoices, @@ -322,7 +222,7 @@ int wxGetSelectedChoices(wxArrayInt& selections, { wxString *choices; int n = ConvertWXArrayToC(aChoices, &choices); - int res = wxGetSelectedChoices(selections, message, caption, + size_t res = wxGetMultipleChoices(selections, message, caption, n, choices, parent, x, y, centre, width, height); delete [] choices; @@ -330,50 +230,6 @@ int wxGetSelectedChoices(wxArrayInt& selections, return res; } -#if WXWIN_COMPATIBILITY_2_8 -size_t wxGetMultipleChoices(wxArrayInt& selections, - const wxString& message, - const wxString& caption, - int n, const wxString *choices, - wxWindow *parent, - int x, int y, - bool centre, - int width, int height) -{ - int rc = wxGetSelectedChoices(selections, message, caption, - n, choices, - parent, x, y, centre, width, height); - if ( rc == -1 ) - { - selections.clear(); - return 0; - } - - return rc; -} - -size_t wxGetMultipleChoices(wxArrayInt& selections, - const wxString& message, - const wxString& caption, - const wxArrayString& aChoices, - wxWindow *parent, - int x, int y, - bool centre, - int width, int height) -{ - int rc = wxGetSelectedChoices(selections, message, caption, - aChoices, - parent, x, y, centre, width, height); - if ( rc == -1 ) - { - selections.clear(); - return 0; - } - - return rc; -} -#endif // WXWIN_COMPATIBILITY_2_8 - // ---------------------------------------------------------------------------- // wxAnyChoiceDialog // ---------------------------------------------------------------------------- @@ -386,12 +242,14 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, const wxPoint& pos, long styleLbox) { - // extract the buttons styles from the dialog one and remove them from it - const long styleBtns = styleDlg & (wxOK | wxCANCEL); - styleDlg &= ~styleBtns; - +#ifdef __WXMAC__ + // FIXME: why?? + if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg & (~wxCANCEL) ) ) + return false; +#else if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg) ) return false; +#endif wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); @@ -410,7 +268,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, // 3) buttons if any wxSizer * - buttonSizer = CreateSeparatedButtonSizer(styleBtns); + buttonSizer = CreateSeparatedButtonSizer(styleDlg & ButtonSizerFlags); if ( buttonSizer ) { topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder()); @@ -444,8 +302,11 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, wxListBoxBase *wxAnyChoiceDialog::CreateList(int n, const wxString *choices, long styleLbox) { + wxSize size = wxDefaultSize; + if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA) + size = wxSize(300, 200); return new wxListBox( this, wxID_LISTBOX, - wxDefaultPosition, wxDefaultSize, + wxDefaultPosition, size, n, choices, styleLbox ); } @@ -466,12 +327,35 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxSingleChoiceDialog, wxDialog) +wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, + const wxString& message, + const wxString& caption, + int n, + const wxString *choices, + char **clientData, + long style, + const wxPoint& WXUNUSED(pos)) +{ + Create(parent, message, caption, n, choices, clientData, style); +} + +wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, + const wxString& message, + const wxString& caption, + const wxArrayString& choices, + char **clientData, + long style, + const wxPoint& WXUNUSED(pos)) +{ + Create(parent, message, caption, choices, clientData, style); +} + bool wxSingleChoiceDialog::Create( wxWindow *parent, const wxString& message, const wxString& caption, int n, const wxString *choices, - void **clientData, + char **clientData, long style, const wxPoint& pos ) { @@ -495,7 +379,7 @@ bool wxSingleChoiceDialog::Create( wxWindow *parent, const wxString& message, const wxString& caption, const wxArrayString& choices, - void **clientData, + char **clientData, long style, const wxPoint& pos ) { @@ -507,9 +391,6 @@ bool wxSingleChoiceDialog::Create( wxWindow *parent, // Set the selection void wxSingleChoiceDialog::SetSelection(int sel) { - wxCHECK_RET( sel >= 0 && (unsigned)sel < m_listbox->GetCount(), - "Invalid initial selection" ); - m_listbox->SetSelection(sel); m_selection = sel; } @@ -660,8 +541,12 @@ bool wxMultiChoiceDialog::TransferDataFromWindow() wxListBoxBase *wxMultiChoiceDialog::CreateList(int n, const wxString *choices, long styleLbox) { + wxSize size = wxDefaultSize; + if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA) + size = wxSize(300, 200); + return new wxCheckListBox( this, wxID_LISTBOX, - wxDefaultPosition, wxDefaultSize, + wxDefaultPosition, size, n, choices, styleLbox ); } diff --git a/Source/3rd Party/wx/src/generic/clrpickerg.cpp b/Source/3rd Party/wx/src/generic/clrpickerg.cpp index 45ad61482..a02d2accd 100644 --- a/Source/3rd Party/wx/src/generic/clrpickerg.cpp +++ b/Source/3rd Party/wx/src/generic/clrpickerg.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi (readapted code written by Vadim Zeitlin) // Modified by: // Created: 15/04/2006 +// RCS-ID: $Id: clrpickerg.cpp 58967 2009-02-17 13:31:28Z SC $ // Copyright: (c) Vadim Zeitlin, Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -26,8 +27,8 @@ #if wxUSE_COLOURPICKERCTRL #include "wx/clrpicker.h" + #include "wx/colordlg.h" -#include "wx/dcmemory.h" // ============================================================================ @@ -35,7 +36,7 @@ // ============================================================================ wxColourData wxGenericColourButton::ms_data; -IMPLEMENT_DYNAMIC_CLASS(wxGenericColourButton, wxBitmapButton) +IMPLEMENT_DYNAMIC_CLASS(wxGenericColourButton, wxCLRBTN_BASE_CLASS) // ---------------------------------------------------------------------------- // wxGenericColourButton @@ -46,18 +47,22 @@ bool wxGenericColourButton::Create( wxWindow *parent, wxWindowID id, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { - m_bitmap = wxBitmap( 60, 13 ); - // create this button - if (!wxBitmapButton::Create( parent, id, m_bitmap, pos, - size, style | wxBU_AUTODRAW, validator, name )) +#if wxCLRBTN_USES_BMP_BUTTON + wxBitmap empty(1,1); + if (!wxBitmapButton::Create( parent, id, empty, pos, + size, style, validator, name )) +#else + if (!wxButton::Create( parent, id, wxEmptyString, pos, + size, style, validator, name )) +#endif { wxFAIL_MSG( wxT("wxGenericColourButton creation failed") ); return false; } // and handle user clicks on it - Connect(GetId(), wxEVT_BUTTON, + Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxGenericColourButton::OnButtonClick), NULL, this); @@ -82,7 +87,7 @@ void wxGenericColourButton::InitColourData() void wxGenericColourButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) { - // update the wxColouData to be shown in the dialog + // update the wxColouData to be shown in the the dialog ms_data.SetColour(m_colour); // create the colour dialog and display it @@ -100,38 +105,83 @@ void wxGenericColourButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) void wxGenericColourButton::UpdateColour() { - wxMemoryDC dc(m_bitmap); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.SetBrush( wxBrush(m_colour) ); - dc.DrawRectangle( 0,0,m_bitmap.GetWidth(),m_bitmap.GetHeight() ); - - if ( HasFlag(wxCLRP_SHOW_LABEL) ) + if ( !m_colour.Ok() ) { - wxColour col( ~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue() ); - dc.SetTextForeground( col ); - dc.SetFont( GetFont() ); - dc.DrawText( m_colour.GetAsString(wxC2S_HTML_SYNTAX), 0, 0 ); +#if wxCLRBTN_USES_BMP_BUTTON + wxBitmap empty(1,1); + SetBitmapLabel(empty); +#else + if ( HasFlag(wxCLRP_SHOW_LABEL) ) + SetLabel(wxEmptyString); +#endif + return; } - dc.SelectObject( wxNullBitmap ); - SetBitmapLabel( m_bitmap ); + // some combinations of the fg/bg colours may be unreadable, so we invert + // the colour to make sure fg colour is different enough from m_colour + wxColour colFg(~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue()); + +#if wxCLRBTN_USES_BMP_BUTTON + wxSize sz = GetSize(); + sz.x -= 2*GetMarginX(); + sz.y -= 2*GetMarginY(); + + wxPoint topleft; + + if ( sz.x < 1 ) + sz.x = 1; + else + if ( sz.y < 1 ) + sz.y = 1; + + wxBitmap bmp(sz.x, sz.y); + { + wxMemoryDC memdc(bmp); + memdc.SetPen(colFg); + memdc.SetBrush(m_colour); + memdc.DrawRectangle(topleft,sz); + if ( HasFlag(wxCLRP_SHOW_LABEL) ) + { + int x, y, leading, desc; + wxString label = m_colour.GetAsString(wxC2S_HTML_SYNTAX); + memdc.GetTextExtent(label,&x,&y,&desc,&leading); + if ( x <= sz.x && y <= sz.y ) + { + topleft.x += (sz.x-x)/2; + topleft.y += (sz.y-y)/2; + memdc.SetTextForeground(colFg); + memdc.DrawText(label,topleft); + } + } + } + SetBitmapLabel(bmp); +#else + SetForegroundColour(colFg); + SetBackgroundColour(m_colour); + + if ( HasFlag(wxCLRP_SHOW_LABEL) ) + SetLabel(m_colour.GetAsString(wxC2S_HTML_SYNTAX)); +#endif } wxSize wxGenericColourButton::DoGetBestSize() const { - wxSize sz(wxBitmapButton::DoGetBestSize()); -#ifdef __WXMAC__ - sz.y += 6; -#else - sz.y += 2; -#endif - sz.x += 30; + wxSize sz(wxButton::DoGetBestSize()); if ( HasFlag(wxCLRP_SHOW_LABEL) ) + { +#if wxCLRBTN_USES_BMP_BUTTON + int x, y, leading, desc; + wxString label = m_colour.GetAsString(wxC2S_HTML_SYNTAX); + wxClientDC dc(const_cast(this)); + dc.GetTextExtent(label,&x,&y,&desc,&leading); + sz.x = sz.y+x; +#endif return sz; + } // if we have no label, then make this button a square - // (like e.g. native GTK version of this control) ??? - // sz.SetWidth(sz.GetHeight()); + // (like e.g. native GTK version of this control) + sz.SetWidth(sz.GetHeight()); return sz; } diff --git a/Source/3rd Party/wx/src/generic/collpaneg.cpp b/Source/3rd Party/wx/src/generic/collpaneg.cpp index 0342a441f..7f8848f4b 100644 --- a/Source/3rd Party/wx/src/generic/collpaneg.cpp +++ b/Source/3rd Party/wx/src/generic/collpaneg.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified By: // Created: 8/10/2006 +// Id: $Id: collpaneg.cpp 43371 2006-11-12 21:38:49Z VZ $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,11 +16,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - #include "wx/defs.h" #if wxUSE_COLLPANE && wxUSE_BUTTON && wxUSE_STATLINE @@ -43,13 +39,13 @@ // implementation // ============================================================================ -const char wxCollapsiblePaneNameStr[] = "collapsiblePane"; +const wxChar wxCollapsiblePaneNameStr[] = wxT("collapsiblePane"); //----------------------------------------------------------------------------- // wxGenericCollapsiblePane //----------------------------------------------------------------------------- -wxDEFINE_EVENT( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEvent ); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_COLLPANE_CHANGED) IMPLEMENT_DYNAMIC_CLASS(wxGenericCollapsiblePane, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneEvent, wxCommandEvent) @@ -58,13 +54,6 @@ BEGIN_EVENT_TABLE(wxGenericCollapsiblePane, wxControl) EVT_SIZE(wxGenericCollapsiblePane::OnSize) END_EVENT_TABLE() -void wxGenericCollapsiblePane::Init() -{ - m_pButton = NULL; - m_pPane = NULL; - m_pStaticLine = NULL; - m_sz = NULL; -} bool wxGenericCollapsiblePane::Create(wxWindow *parent, wxWindowID id, @@ -80,35 +69,32 @@ bool wxGenericCollapsiblePane::Create(wxWindow *parent, m_strLabel = label; - // sizer containing the expand button and possibly a static line - m_sz = new wxBoxSizer(wxHORIZONTAL); - -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) - // on Mac we use the special disclosure triangle button - m_pStaticLine = NULL; - m_pButton = new wxDisclosureTriangle(this, wxID_ANY, GetBtnLabel()); - m_sz->Add(m_pButton); -#else // create children and lay them out using a wxBoxSizer // (so that we automatically get RTL features) m_pButton = new wxButton(this, wxID_ANY, GetBtnLabel(), wxPoint(0, 0), wxDefaultSize, wxBU_EXACTFIT); m_pStaticLine = new wxStaticLine(this, wxID_ANY); - +#ifdef __WXMAC__ + // on Mac we put the static libe above the button + m_sz = new wxBoxSizer(wxVERTICAL); + m_sz->Add(m_pStaticLine, 0, wxALL|wxGROW, GetBorder()); + m_sz->Add(m_pButton, 0, wxLEFT|wxRIGHT|wxBOTTOM, GetBorder()); +#else // on other platforms we put the static line and the button horizontally + m_sz = new wxBoxSizer(wxHORIZONTAL); m_sz->Add(m_pButton, 0, wxLEFT|wxTOP|wxBOTTOM, GetBorder()); m_sz->Add(m_pStaticLine, 1, wxALIGN_CENTER|wxLEFT|wxRIGHT, GetBorder()); #endif // FIXME: at least under wxCE and wxGTK1 the background is black if we don't do // this, no idea why... -#if defined(__WXWINCE__) || defined(__WXGTK__) +#if defined(__WXWINCE__) || (defined(__WXGTK__) && !defined(__WXGTK20__)) SetBackgroundColour(parent->GetBackgroundColour()); #endif // do not set sz as our sizers since we handle the pane window without using sizers m_pPane = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxTAB_TRAVERSAL|wxNO_BORDER, wxT("wxCollapsiblePanePane") ); + wxTAB_TRAVERSAL|wxNO_BORDER); // start as collapsed: m_pPane->Hide(); @@ -118,14 +104,14 @@ bool wxGenericCollapsiblePane::Create(wxWindow *parent, wxGenericCollapsiblePane::~wxGenericCollapsiblePane() { - if (m_pButton) + if (m_pButton && m_pStaticLine && m_sz) + { m_pButton->SetContainingSizer(NULL); - - if (m_pStaticLine) m_pStaticLine->SetContainingSizer(NULL); - // our sizer is not deleted automatically since we didn't use SetSizer()! - wxDELETE(m_sz); + // our sizer is not deleted automatically since we didn't use SetSizer()! + wxDELETE(m_sz); + } } wxSize wxGenericCollapsiblePane::DoGetBestSize() const @@ -145,42 +131,78 @@ wxSize wxGenericCollapsiblePane::DoGetBestSize() const wxString wxGenericCollapsiblePane::GetBtnLabel() const { - // on mac the triangle indicates the state, no string change -#ifdef __WXMAC__ - return m_strLabel; -#else return m_strLabel + (IsCollapsed() ? wxT(" >>") : wxT(" <<")); -#endif } void wxGenericCollapsiblePane::OnStateChange(const wxSize& sz) { // minimal size has priority over the best size so set here our min size -// SetMinSize(sz); + SetMinSize(sz); SetSize(sz); if (this->HasFlag(wxCP_NO_TLW_RESIZE)) { - // the user asked to explicitly handle the resizing itself... + // the user asked to explicitely handle the resizing itself... return; } - wxTopLevelWindow *top = - wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); - if ( !top ) - return; + // + // NB: the following block of code has been accurately designed to + // as much flicker-free as possible; be careful when modifying it! + // - wxSizer *sizer = top->GetSizer(); - if ( !sizer ) - return; + wxTopLevelWindow * + top = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + if ( top ) + { + // NB: don't Layout() the 'top' window as its size has not been correctly + // updated yet and we don't want to do an initial Layout() with the old + // size immediately followed by a SetClientSize/Fit call for the new + // size; that would provoke flickering! - const wxSize newBestSize = sizer->ComputeFittingClientSize(top); - top->SetMinClientSize(newBestSize); + if (top->GetSizer()) +#ifdef __WXGTK__ + // FIXME: the SetSizeHints() call would be required also for GTK+ for + // the expanded->collapsed transition. Unfortunately if we + // enable this line, then the GTK+ top window won't always be + // resized by the SetClientSize() call below! As a side effect + // of this dirty fix, the minimal size for the pane window is + // not set in GTK+ and the user can hide it shrinking the "top" + // window... + if (IsCollapsed()) +#endif + top->GetSizer()->SetSizeHints(top); - // we shouldn't attempt to resize a maximized window, whatever happens - if ( !top->IsMaximized() ) - top->SetClientSize(newBestSize); + + // we shouldn't attempt to resize a maximized window, whatever happens + if ( !top->IsMaximized() ) + { + if ( IsCollapsed() ) + { + // expanded -> collapsed transition + if (top->GetSizer()) + { + // we have just set the size hints... + wxSize sz = top->GetSizer()->CalcMin(); + + // use SetClientSize() and not SetSize() otherwise the size for + // e.g. a wxFrame with a menubar wouldn't be correctly set + top->SetClientSize(sz); + } + else + top->Layout(); + } + else + { + // collapsed -> expanded transition + + // force our parent to "fit", i.e. expand so that it can honour + // our minimal size + top->Fit(); + } + } + } } void wxGenericCollapsiblePane::Collapse(bool collapse) @@ -189,19 +211,12 @@ void wxGenericCollapsiblePane::Collapse(bool collapse) if ( IsCollapsed() == collapse ) return; - InvalidateBestSize(); - // update our state m_pPane->Show(!collapse); // update button label -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) - m_pButton->SetOpen( !collapse ); -#else // NB: this must be done after updating our "state" m_pButton->SetLabel(GetBtnLabel()); -#endif - OnStateChange(GetBestSize()); } @@ -209,25 +224,16 @@ void wxGenericCollapsiblePane::Collapse(bool collapse) void wxGenericCollapsiblePane::SetLabel(const wxString &label) { m_strLabel = label; -#ifdef __WXMAC__ - m_pButton->SetLabel(GetBtnLabel()); -#else m_pButton->SetLabel(GetBtnLabel()); m_pButton->SetInitialSize(); -#endif Layout(); } bool wxGenericCollapsiblePane::Layout() { -#ifdef __WXMAC__ - if (!m_pButton || !m_pPane || !m_sz) - return false; // we need to complete the creation first! -#else if (!m_pButton || !m_pStaticLine || !m_pPane || !m_sz) return false; // we need to complete the creation first! -#endif wxSize oursz(GetSize()); @@ -253,6 +259,8 @@ int wxGenericCollapsiblePane::GetBorder() const { #if defined( __WXMAC__ ) return 6; +#elif defined(__WXGTK20__) + return 3; #elif defined(__WXMSW__) wxASSERT(m_pButton); return m_pButton->ConvertDialogToPixels(wxSize(2, 0)).x; diff --git a/Source/3rd Party/wx/src/generic/colour.cpp b/Source/3rd Party/wx/src/generic/colour.cpp deleted file mode 100644 index f16c13451..000000000 --- a/Source/3rd Party/wx/src/generic/colour.cpp +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/colour.cpp -// Purpose: wxColour class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/colour.h" - -#ifndef WX_PRECOMP - #include "wx/gdicmn.h" -#endif - -// Colour - -void wxColour::Init() -{ - m_red = - m_blue = - m_green = 0; - m_alpha = wxALPHA_OPAQUE; - m_isInit = false; -} - -void wxColour::InitRGBA(unsigned char r, - unsigned char g, - unsigned char b, - unsigned char a) -{ - m_red = r; - m_green = g; - m_blue = b; - m_alpha = a; - m_isInit = true; -} - -wxColour& wxColour::operator=(const wxColour& col) -{ - m_red = col.m_red; - m_green = col.m_green; - m_blue = col.m_blue; - m_alpha = col.m_alpha; - m_isInit = col.m_isInit; - return *this; -} - diff --git a/Source/3rd Party/wx/src/generic/colrdlgg.cpp b/Source/3rd Party/wx/src/generic/colrdlgg.cpp deleted file mode 100644 index 60bdf6a78..000000000 --- a/Source/3rd Party/wx/src/generic/colrdlgg.cpp +++ /dev/null @@ -1,578 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/colrdlgg.cpp -// Purpose: Choice dialogs -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_COLOURDLG - -#ifndef WX_PRECOMP - #include "wx/utils.h" - #include "wx/intl.h" - #include "wx/dialog.h" - #include "wx/listbox.h" - #include "wx/button.h" - #include "wx/stattext.h" - #include "wx/layout.h" - #include "wx/dcclient.h" - #include "wx/sizer.h" - #include "wx/slider.h" -#endif - -#if wxUSE_STATLINE - #include "wx/statline.h" -#endif - -#include "wx/colourdata.h" -#include "wx/generic/colrdlgg.h" - -IMPLEMENT_DYNAMIC_CLASS(wxGenericColourDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxGenericColourDialog, wxDialog) - EVT_BUTTON(wxID_ADD_CUSTOM, wxGenericColourDialog::OnAddCustom) -#if wxUSE_SLIDER - EVT_SLIDER(wxID_RED_SLIDER, wxGenericColourDialog::OnRedSlider) - EVT_SLIDER(wxID_GREEN_SLIDER, wxGenericColourDialog::OnGreenSlider) - EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider) -#endif - EVT_PAINT(wxGenericColourDialog::OnPaint) - EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent) - EVT_CLOSE(wxGenericColourDialog::OnCloseWindow) -END_EVENT_TABLE() - - -/* - * Generic wxColourDialog - */ - -// don't change the number of elements (48) in this array, the code below is -// hardcoded to use it -static const wxChar *const wxColourDialogNames[] = -{ - wxT("ORANGE"), - wxT("GOLDENROD"), - wxT("WHEAT"), - wxT("SPRING GREEN"), - wxT("SKY BLUE"), - wxT("SLATE BLUE"), - wxT("MEDIUM VIOLET RED"), - wxT("PURPLE"), - - wxT("RED"), - wxT("YELLOW"), - wxT("MEDIUM SPRING GREEN"), - wxT("PALE GREEN"), - wxT("CYAN"), - wxT("LIGHT STEEL BLUE"), - wxT("ORCHID"), - wxT("LIGHT MAGENTA"), - - wxT("BROWN"), - wxT("YELLOW"), - wxT("GREEN"), - wxT("CADET BLUE"), - wxT("MEDIUM BLUE"), - wxT("MAGENTA"), - wxT("MAROON"), - wxT("ORANGE RED"), - - wxT("FIREBRICK"), - wxT("CORAL"), - wxT("FOREST GREEN"), - wxT("AQUAMARINE"), - wxT("BLUE"), - wxT("NAVY"), - wxT("THISTLE"), - wxT("MEDIUM VIOLET RED"), - - wxT("INDIAN RED"), - wxT("GOLD"), - wxT("MEDIUM SEA GREEN"), - wxT("MEDIUM BLUE"), - wxT("MIDNIGHT BLUE"), - wxT("GREY"), - wxT("PURPLE"), - wxT("KHAKI"), - - wxT("BLACK"), - wxT("MEDIUM FOREST GREEN"), - wxT("KHAKI"), - wxT("DARK GREY"), - wxT("SEA GREEN"), - wxT("LIGHT GREY"), - wxT("MEDIUM SLATE BLUE"), - wxT("WHITE") -}; - -wxGenericColourDialog::wxGenericColourDialog() -{ - m_whichKind = 1; - m_colourSelection = -1; -} - -wxGenericColourDialog::wxGenericColourDialog(wxWindow *parent, - wxColourData *data) -{ - m_whichKind = 1; - m_colourSelection = -1; - Create(parent, data); -} - -wxGenericColourDialog::~wxGenericColourDialog() -{ -} - -void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - EndModal(wxID_CANCEL); -} - -bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data) -{ - if ( !wxDialog::Create(GetParentForModalDialog(parent, 0), wxID_ANY, - _("Choose colour"), - wxPoint(0, 0), wxSize(900, 900)) ) - return false; - - if (data) - m_colourData = *data; - - InitializeColours(); - CalculateMeasurements(); - CreateWidgets(); - - return true; -} - -int wxGenericColourDialog::ShowModal() -{ - return wxDialog::ShowModal(); -} - - -// Internal functions -void wxGenericColourDialog::OnMouseEvent(wxMouseEvent& event) -{ - if (event.ButtonDown(1)) - { - int x = (int)event.GetX(); - int y = (int)event.GetY(); - -#ifdef __WXPM__ - // Handle OS/2's reverse coordinate system and account for the dialog title - int nClientHeight; - - GetClientSize(NULL, &nClientHeight); - y = (nClientHeight - y) + 20; -#endif - if ((x >= m_standardColoursRect.x && x <= (m_standardColoursRect.x + m_standardColoursRect.width)) && - (y >= m_standardColoursRect.y && y <= (m_standardColoursRect.y + m_standardColoursRect.height))) - { - int selX = (int)(x - m_standardColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing); - int selY = (int)(y - m_standardColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing); - int ptr = (int)(selX + selY*8); - OnBasicColourClick(ptr); - } - else if ((x >= m_customColoursRect.x && x <= (m_customColoursRect.x + m_customColoursRect.width)) && - (y >= m_customColoursRect.y && y <= (m_customColoursRect.y + m_customColoursRect.height))) - { - int selX = (int)(x - m_customColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing); - int selY = (int)(y - m_customColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing); - int ptr = (int)(selX + selY*8); - OnCustomColourClick(ptr); - } - else - event.Skip(); - } - else - event.Skip(); -} - -void wxGenericColourDialog::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - PaintBasicColours(dc); - PaintCustomColours(dc); - PaintCustomColour(dc); - PaintHighlight(dc, true); -} - -void wxGenericColourDialog::CalculateMeasurements() -{ - m_smallRectangleSize.x = 18; - m_smallRectangleSize.y = 14; - m_customRectangleSize.x = 40; - m_customRectangleSize.y = 40; - - m_gridSpacing = 6; - m_sectionSpacing = 15; - - m_standardColoursRect.x = 10; -#ifdef __WXPM__ - m_standardColoursRect.y = 15 + 20; /* OS/2 needs to account for dialog titlebar */ -#else - m_standardColoursRect.y = 15; -#endif - m_standardColoursRect.width = (8*m_smallRectangleSize.x) + (7*m_gridSpacing); - m_standardColoursRect.height = (6*m_smallRectangleSize.y) + (5*m_gridSpacing); - - m_customColoursRect.x = m_standardColoursRect.x; - m_customColoursRect.y = m_standardColoursRect.y + m_standardColoursRect.height + 20; - m_customColoursRect.width = (8*m_smallRectangleSize.x) + (7*m_gridSpacing); - m_customColoursRect.height = (2*m_smallRectangleSize.y) + (1*m_gridSpacing); - - m_singleCustomColourRect.x = m_customColoursRect.width + m_customColoursRect.x + m_sectionSpacing; - m_singleCustomColourRect.y = 80; - m_singleCustomColourRect.width = m_customRectangleSize.x; - m_singleCustomColourRect.height = m_customRectangleSize.y; - - m_okButtonX = 10; - m_customButtonX = m_singleCustomColourRect.x ; - m_buttonY = m_customColoursRect.y + m_customColoursRect.height + 10; -} - -void wxGenericColourDialog::CreateWidgets() -{ - wxBeginBusyCursor(); - - wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); - - const int sliderHeight = 160; - - // first sliders -#if wxUSE_SLIDER - const int sliderX = m_singleCustomColourRect.x + m_singleCustomColourRect.width + m_sectionSpacing; - - m_redSlider = new wxSlider(this, wxID_RED_SLIDER, m_colourData.m_dataColour.Red(), 0, 255, - wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); - m_greenSlider = new wxSlider(this, wxID_GREEN_SLIDER, m_colourData.m_dataColour.Green(), 0, 255, - wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); - m_blueSlider = new wxSlider(this, wxID_BLUE_SLIDER, m_colourData.m_dataColour.Blue(), 0, 255, - wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); - - wxBoxSizer *sliderSizer = new wxBoxSizer( wxHORIZONTAL ); - - sliderSizer->Add(sliderX, sliderHeight ); - - wxSizerFlags flagsRight; - flagsRight.Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL).DoubleBorder(); - - sliderSizer->Add(m_redSlider, flagsRight); - sliderSizer->Add(m_greenSlider,flagsRight); - sliderSizer->Add(m_blueSlider,flagsRight); - - topSizer->Add(sliderSizer, wxSizerFlags().Centre().DoubleBorder()); -#else - topSizer->Add(1, sliderHeight, wxSizerFlags(1).Centre().TripleBorder()); -#endif // wxUSE_SLIDER - - // then the custom button - topSizer->Add(new wxButton(this, wxID_ADD_CUSTOM, - _("Add to custom colours") ), - wxSizerFlags().DoubleHorzBorder()); - - // then the standard buttons - wxSizer *buttonsizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if ( buttonsizer ) - { - topSizer->Add(buttonsizer, wxSizerFlags().Expand().DoubleBorder()); - } - - SetAutoLayout( true ); - SetSizer( topSizer ); - - topSizer->SetSizeHints( this ); - topSizer->Fit( this ); - - Centre( wxBOTH ); - - wxEndBusyCursor(); -} - -void wxGenericColourDialog::InitializeColours(void) -{ - size_t i; - - for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) - { - wxColour col = wxTheColourDatabase->Find(wxColourDialogNames[i]); - if (col.IsOk()) - m_standardColours[i].Set(col.Red(), col.Green(), col.Blue()); - else - m_standardColours[i].Set(0, 0, 0); - } - - for (i = 0; i < WXSIZEOF(m_customColours); i++) - { - wxColour c = m_colourData.GetCustomColour(i); - if (c.IsOk()) - m_customColours[i] = m_colourData.GetCustomColour(i); - else - m_customColours[i] = wxColour(255, 255, 255); - } - - wxColour curr = m_colourData.GetColour(); - if ( curr.IsOk() ) - { - bool m_initColourFound = false; - - for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) - { - if ( m_standardColours[i] == curr && !m_initColourFound ) - { - m_whichKind = 1; - m_colourSelection = i; - m_initColourFound = true; - break; - } - } - if ( !m_initColourFound ) - { - for ( i = 0; i < WXSIZEOF(m_customColours); i++ ) - { - if ( m_customColours[i] == curr ) - { - m_whichKind = 2; - m_colourSelection = i; - break; - } - } - } - m_colourData.m_dataColour.Set( curr.Red(), curr.Green(), curr.Blue() ); - } - else - { - m_whichKind = 1; - m_colourSelection = 0; - m_colourData.m_dataColour.Set( 0, 0, 0 ); - } -} - -void wxGenericColourDialog::PaintBasicColours(wxDC& dc) -{ - int i; - for (i = 0; i < 6; i++) - { - int j; - for (j = 0; j < 8; j++) - { - int ptr = i*8 + j; - - int x = (j*(m_smallRectangleSize.x+m_gridSpacing) + m_standardColoursRect.x); - int y = (i*(m_smallRectangleSize.y+m_gridSpacing) + m_standardColoursRect.y); - - dc.SetPen(*wxBLACK_PEN); - wxBrush brush(m_standardColours[ptr]); - dc.SetBrush(brush); - - dc.DrawRectangle( x, y, m_smallRectangleSize.x, m_smallRectangleSize.y); - } - } -} - -void wxGenericColourDialog::PaintCustomColours(wxDC& dc) -{ - int i; - for (i = 0; i < 2; i++) - { - int j; - for (j = 0; j < 8; j++) - { - int ptr = i*8 + j; - - int x = (j*(m_smallRectangleSize.x+m_gridSpacing)) + m_customColoursRect.x; - int y = (i*(m_smallRectangleSize.y+m_gridSpacing)) + m_customColoursRect.y; - - dc.SetPen(*wxBLACK_PEN); - - wxBrush brush(m_customColours[ptr]); - dc.SetBrush(brush); - - dc.DrawRectangle( x, y, m_smallRectangleSize.x, m_smallRectangleSize.y); - } - } -} - -void wxGenericColourDialog::PaintHighlight(wxDC& dc, bool draw) -{ - if ( m_colourSelection < 0 ) - return; - - // Number of pixels bigger than the standard rectangle size - // for drawing a highlight - int deltaX = 2; - int deltaY = 2; - - if (m_whichKind == 1) - { - // Standard colours - int y = (int)(m_colourSelection / 8); - int x = (int)(m_colourSelection - (y*8)); - - x = (x*(m_smallRectangleSize.x + m_gridSpacing) + m_standardColoursRect.x) - deltaX; - y = (y*(m_smallRectangleSize.y + m_gridSpacing) + m_standardColoursRect.y) - deltaY; - - if (draw) - dc.SetPen(*wxBLACK_PEN); - else - dc.SetPen(*wxLIGHT_GREY_PEN); - - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle( x, y, (m_smallRectangleSize.x + (2*deltaX)), (m_smallRectangleSize.y + (2*deltaY))); - } - else - { - // User-defined colours - int y = (int)(m_colourSelection / 8); - int x = (int)(m_colourSelection - (y*8)); - - x = (x*(m_smallRectangleSize.x + m_gridSpacing) + m_customColoursRect.x) - deltaX; - y = (y*(m_smallRectangleSize.y + m_gridSpacing) + m_customColoursRect.y) - deltaY; - - if (draw) - dc.SetPen(*wxBLACK_PEN); - else - dc.SetPen(*wxLIGHT_GREY_PEN); - - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle( x, y, (m_smallRectangleSize.x + (2*deltaX)), (m_smallRectangleSize.y + (2*deltaY))); - } -} - -void wxGenericColourDialog::PaintCustomColour(wxDC& dc) -{ - dc.SetPen(*wxBLACK_PEN); - - wxBrush *brush = new wxBrush(m_colourData.m_dataColour); - dc.SetBrush(*brush); - - dc.DrawRectangle( m_singleCustomColourRect.x, m_singleCustomColourRect.y, - m_customRectangleSize.x, m_customRectangleSize.y); - - dc.SetBrush(wxNullBrush); - delete brush; -} - -void wxGenericColourDialog::OnBasicColourClick(int which) -{ - wxClientDC dc(this); - - PaintHighlight(dc, false); - m_whichKind = 1; - m_colourSelection = which; - -#if wxUSE_SLIDER - m_redSlider->SetValue( m_standardColours[m_colourSelection].Red() ); - m_greenSlider->SetValue( m_standardColours[m_colourSelection].Green() ); - m_blueSlider->SetValue( m_standardColours[m_colourSelection].Blue() ); -#endif // wxUSE_SLIDER - - m_colourData.m_dataColour.Set(m_standardColours[m_colourSelection].Red(), - m_standardColours[m_colourSelection].Green(), - m_standardColours[m_colourSelection].Blue()); - - PaintCustomColour(dc); - PaintHighlight(dc, true); -} - -void wxGenericColourDialog::OnCustomColourClick(int which) -{ - wxClientDC dc(this); - PaintHighlight(dc, false); - m_whichKind = 2; - m_colourSelection = which; - -#if wxUSE_SLIDER - m_redSlider->SetValue( m_customColours[m_colourSelection].Red() ); - m_greenSlider->SetValue( m_customColours[m_colourSelection].Green() ); - m_blueSlider->SetValue( m_customColours[m_colourSelection].Blue() ); -#endif // wxUSE_SLIDER - - m_colourData.m_dataColour.Set(m_customColours[m_colourSelection].Red(), - m_customColours[m_colourSelection].Green(), - m_customColours[m_colourSelection].Blue()); - - PaintCustomColour(dc); - PaintHighlight(dc, true); -} - -/* -void wxGenericColourDialog::OnOk(void) -{ - Show(false); -} - -void wxGenericColourDialog::OnCancel(void) -{ - colourDialogCancelled = true; - Show(false); -} -*/ - -void wxGenericColourDialog::OnAddCustom(wxCommandEvent& WXUNUSED(event)) -{ - wxClientDC dc(this); - if (m_whichKind != 2) - { - PaintHighlight(dc, false); - m_whichKind = 2; - m_colourSelection = 0; - PaintHighlight(dc, true); - } - - m_customColours[m_colourSelection].Set(m_colourData.m_dataColour.Red(), - m_colourData.m_dataColour.Green(), - m_colourData.m_dataColour.Blue()); - - m_colourData.SetCustomColour(m_colourSelection, m_customColours[m_colourSelection]); - - PaintCustomColours(dc); -} - -#if wxUSE_SLIDER - -void wxGenericColourDialog::OnRedSlider(wxCommandEvent& WXUNUSED(event)) -{ - if (!m_redSlider) - return; - - wxClientDC dc(this); - m_colourData.m_dataColour.Set((unsigned char)m_redSlider->GetValue(), m_colourData.m_dataColour.Green(), m_colourData.m_dataColour.Blue()); - PaintCustomColour(dc); -} - -void wxGenericColourDialog::OnGreenSlider(wxCommandEvent& WXUNUSED(event)) -{ - if (!m_greenSlider) - return; - - wxClientDC dc(this); - m_colourData.m_dataColour.Set(m_colourData.m_dataColour.Red(), (unsigned char)m_greenSlider->GetValue(), m_colourData.m_dataColour.Blue()); - PaintCustomColour(dc); -} - -void wxGenericColourDialog::OnBlueSlider(wxCommandEvent& WXUNUSED(event)) -{ - if (!m_blueSlider) - return; - - wxClientDC dc(this); - m_colourData.m_dataColour.Set(m_colourData.m_dataColour.Red(), m_colourData.m_dataColour.Green(), (unsigned char)m_blueSlider->GetValue()); - PaintCustomColour(dc); -} - -#endif // wxUSE_SLIDER - -#endif // wxUSE_COLOURDLG diff --git a/Source/3rd Party/wx/src/generic/combog.cpp b/Source/3rd Party/wx/src/generic/combog.cpp index 062f3863c..798170e91 100644 --- a/Source/3rd Party/wx/src/generic/combog.cpp +++ b/Source/3rd Party/wx/src/generic/combog.cpp @@ -4,6 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 +// RCS-ID: $Id: combog.cpp 67178 2011-03-13 09:32:19Z JMS $ // Copyright: (c) 2005 Jaakko Salli // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,7 +32,6 @@ #include "wx/combobox.h" #include "wx/dcclient.h" #include "wx/settings.h" - #include "wx/textctrl.h" #endif #include "wx/dcbuffer.h" @@ -41,46 +41,36 @@ #if defined(__WXUNIVERSAL__) -// position adjustment for wxTextCtrl, to achieve zero left margin -// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp -#define TEXTCTRLXADJUST 0 - +#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent +#define TEXTCTRLYADJUST 0 #define TEXTXADJUST 0 // how much is read-only text's x adjusted #define DEFAULT_DROPBUTTON_WIDTH 19 #elif defined(__WXMSW__) -// position adjustment for wxTextCtrl, to achieve zero left margin -// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp -#define TEXTCTRLXADJUST 2 - +#define TEXTCTRLXADJUST 2 // position adjustment for wxTextCtrl, with zero indent +#define TEXTCTRLYADJUST 3 #define TEXTXADJUST 0 // how much is read-only text's x adjusted #define DEFAULT_DROPBUTTON_WIDTH 17 #elif defined(__WXGTK__) -// position adjustment for wxTextCtrl, to achieve zero left margin -// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp -#define TEXTCTRLXADJUST -1 - +#define TEXTCTRLXADJUST -1 // position adjustment for wxTextCtrl, with zero indent +#define TEXTCTRLYADJUST 0 #define TEXTXADJUST 1 // how much is read-only text's x adjusted #define DEFAULT_DROPBUTTON_WIDTH 23 #elif defined(__WXMAC__) -// position adjustment for wxTextCtrl, to achieve zero left margin -// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp -#define TEXTCTRLXADJUST 0 - +#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent +#define TEXTCTRLYADJUST 0 #define TEXTXADJUST 0 // how much is read-only text's x adjusted #define DEFAULT_DROPBUTTON_WIDTH 22 #else -// position adjustment for wxTextCtrl, to achieve zero left margin -// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp -#define TEXTCTRLXADJUST 0 - +#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent +#define TEXTCTRLYADJUST 0 #define TEXTXADJUST 0 // how much is read-only text's x adjusted #define DEFAULT_DROPBUTTON_WIDTH 19 @@ -169,8 +159,7 @@ bool wxGenericComboCtrl::Create(wxWindow *parent, border = wxBORDER_NONE; Customize( wxCC_BUTTON_OUTSIDE_BORDER | - wxCC_NO_TEXT_AUTO_SELECT | - wxCC_BUTTON_STAYS_DOWN ); + wxCC_NO_TEXT_AUTO_SELECT ); #endif @@ -185,20 +174,18 @@ bool wxGenericComboCtrl::Create(wxWindow *parent, pos, size, style | wxFULL_REPAINT_ON_RESIZE, - validator, + wxDefaultValidator, name) ) return false; // Create textctrl, if necessary - CreateTextCtrl( tcBorder ); + CreateTextCtrl( tcBorder, validator ); // Add keyboard input handlers for main control and textctrl InstallInputHandlers(); - // Set background style for double-buffering, when needed - // (cannot use when system draws background automatically) - if ( !HasTransparentBackground() ) - SetBackgroundStyle( wxBG_STYLE_PAINT ); + // Set background + SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // for double-buffering // SetInitialSize should be called last SetInitialSize(size); @@ -229,24 +216,16 @@ void wxGenericComboCtrl::OnResize() #endif // Move textctrl, if any, accordingly - PositionTextCtrl( TEXTCTRLXADJUST ); + PositionTextCtrl( TEXTCTRLXADJUST, TEXTCTRLYADJUST ); } void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { - // Determine wxDC to use based on need to double-buffer or - // use system-generated transparent background portions - wxDC* dcPtr; - if ( HasTransparentBackground() ) - dcPtr = new wxPaintDC(this); - else - dcPtr = new wxAutoBufferedPaintDC(this); - wxDC& dc = *dcPtr; - wxSize sz = GetClientSize(); - const wxRect& butRect = m_btnArea; - wxRect tcRect = m_tcArea; - wxRect fullRect(0, 0, sz.x, sz.y); + wxAutoBufferedPaintDC dc(this); + + const wxRect& rectb = m_btnArea; + wxRect rect = m_tcArea; // artificial simple border if ( m_widthCustomBorder ) @@ -254,22 +233,16 @@ void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) int customBorder = m_widthCustomBorder; // Set border colour -#ifdef __WXMAC__ - wxPen pen1( wxColour(133,133,133), - customBorder, - wxSOLID ); -#else wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), customBorder, - wxPENSTYLE_SOLID); -#endif + wxSOLID ); dc.SetPen( pen1 ); // area around both controls - wxRect rect2(fullRect); + wxRect rect2(0,0,sz.x,sz.y); if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) { - rect2 = tcRect; + rect2 = m_tcArea; if ( customBorder == 1 ) { rect2.Inflate(1); @@ -292,49 +265,50 @@ void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) dc.DrawRectangle(rect2); } - // Clear the main background if the system doesn't do it by itself - if ( !HasTransparentBackground() && - (tcRect.x > 0 || tcRect.y > 0) ) - { - wxColour winCol = GetParent()->GetBackgroundColour(); - dc.SetBrush(winCol); - dc.SetPen(winCol); +#if defined(__WXMAC__) || defined(__WXGTK__) // see note in OnThemeChange + wxColour winCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#else + wxColour winCol = GetBackgroundColour(); +#endif + dc.SetBrush(winCol); + dc.SetPen(winCol); - dc.DrawRectangle(fullRect); - } + //wxLogDebug(wxT("hei: %i tcy: %i tchei: %i"),GetClientSize().y,m_tcArea.y,m_tcArea.height); + //wxLogDebug(wxT("btnx: %i tcx: %i tcwid: %i"),m_btnArea.x,m_tcArea.x,m_tcArea.width); + // clear main background + dc.DrawRectangle(rect); + if ( !m_btn ) { + #ifdef __WXGTK__ + // Under GTK+ this avoids drawing the button background with wrong + // colour + DrawButton(dc,rectb,0); + #else // Standard button rendering - DrawButton(dc, butRect); + DrawButton(dc,rectb); + #endif } // paint required portion on the control - if ( !m_text || m_widthCustomPaint ) + if ( (!m_text || m_widthCustomPaint) ) { wxASSERT( m_widthCustomPaint >= 0 ); - // Clear the text-control area background - wxColour tcCol = GetBackgroundColour(); - dc.SetBrush(tcCol); - dc.SetPen(tcCol); - dc.DrawRectangle(tcRect); - // this is intentionally here to allow drawed rectangle's // right edge to be hidden if ( m_text ) - tcRect.width = m_widthCustomPaint; + rect.width = m_widthCustomPaint; dc.SetFont( GetFont() ); - dc.SetClippingRegion(tcRect); + dc.SetClippingRegion(rect); if ( m_popupInterface ) - m_popupInterface->PaintComboControl(dc, tcRect); + m_popupInterface->PaintComboControl(dc,rect); else - wxComboPopup::DefaultPaintComboControl(this, dc, tcRect); + wxComboPopup::DefaultPaintComboControl(this,dc,rect); } - - delete dcPtr; } void wxGenericComboCtrl::OnMouseEvent( wxMouseEvent& event ) @@ -423,7 +397,19 @@ void wxGenericComboCtrl::SetCustomPaintWidth( int width ) tc->RemoveEventHandler(m_textEvtHandler); delete m_textEvtHandler; - CreateTextCtrl( tcCreateStyle ); +#if wxUSE_VALIDATORS + wxValidator* pValidator = tc->GetValidator(); + if ( pValidator ) + { + pValidator = (wxValidator*) pValidator->Clone(); + CreateTextCtrl( tcCreateStyle, *pValidator ); + delete pValidator; + } + else +#endif + { + CreateTextCtrl( tcCreateStyle, wxDefaultValidator ); + } InstallInputHandlers(); } @@ -448,8 +434,7 @@ bool wxGenericComboCtrl::IsKeyPopupToggle(const wxKeyEvent& event) const } else { - if ( (keycode == WXK_DOWN && event.AltDown()) || - (keycode == WXK_F4) ) + if ( keycode == WXK_DOWN && event.AltDown() ) return true; } diff --git a/Source/3rd Party/wx/src/generic/commandlinkbuttong.cpp b/Source/3rd Party/wx/src/generic/commandlinkbuttong.cpp deleted file mode 100644 index 8a8d001c2..000000000 --- a/Source/3rd Party/wx/src/generic/commandlinkbuttong.cpp +++ /dev/null @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/commandlinkbuttong.cpp -// Purpose: wxGenericCommandLinkButton -// Author: Rickard Westerlund -// Created: 2010-06-23 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_COMMANDLINKBUTTON - -#include "wx/commandlinkbutton.h" -#include "wx/artprov.h" - -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxCommandLinkButton, wxButton, "wx/commandlinkbutton.h") - -wxDEFINE_FLAGS( wxCommandLinkButtonStyle ) -wxBEGIN_FLAGS( wxCommandLinkButtonStyle ) -// new style border flags, we put them first to -// use them for streaming out -wxFLAGS_MEMBER(wxBORDER_SIMPLE) -wxFLAGS_MEMBER(wxBORDER_SUNKEN) -wxFLAGS_MEMBER(wxBORDER_DOUBLE) -wxFLAGS_MEMBER(wxBORDER_RAISED) -wxFLAGS_MEMBER(wxBORDER_STATIC) -wxFLAGS_MEMBER(wxBORDER_NONE) - -// old style border flags -wxFLAGS_MEMBER(wxSIMPLE_BORDER) -wxFLAGS_MEMBER(wxSUNKEN_BORDER) -wxFLAGS_MEMBER(wxDOUBLE_BORDER) -wxFLAGS_MEMBER(wxRAISED_BORDER) -wxFLAGS_MEMBER(wxSTATIC_BORDER) -wxFLAGS_MEMBER(wxBORDER) - -// standard window styles -wxFLAGS_MEMBER(wxTAB_TRAVERSAL) -wxFLAGS_MEMBER(wxCLIP_CHILDREN) -wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) -wxFLAGS_MEMBER(wxWANTS_CHARS) -wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) -wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) -wxFLAGS_MEMBER(wxVSCROLL) -wxFLAGS_MEMBER(wxHSCROLL) - -wxFLAGS_MEMBER(wxBU_AUTODRAW) -wxFLAGS_MEMBER(wxBU_LEFT) -wxFLAGS_MEMBER(wxBU_RIGHT) -wxFLAGS_MEMBER(wxBU_TOP) -wxFLAGS_MEMBER(wxBU_BOTTOM) -wxEND_FLAGS( wxCommandLinkButtonStyle ) - -wxBEGIN_PROPERTIES_TABLE(wxCommandLinkButton) -wxPROPERTY( MainLabel, wxString, SetMainLabel, GetMainLabel, wxString(), \ - 0 /*flags*/, wxT("The main label"), wxT("group") ) - -wxPROPERTY( Note, wxString, SetNote, GetNote, wxString(), \ - 0 /*flags*/, wxT("The link URL"), wxT("group") ) -wxPROPERTY_FLAGS( WindowStyle, wxCommandLinkButtonStyle, long, SetWindowStyleFlag, \ - GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("The link style"), wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxEMPTY_HANDLERS_TABLE(wxCommandLinkButton) - -wxCONSTRUCTOR_7( wxCommandLinkButton, wxWindow*, Parent, wxWindowID, Id, wxString, \ - MainLabel, wxString, Note, wxPoint, Position, wxSize, Size, long, WindowStyle ) - -// ---------------------------------------------------------------------------- -// Generic command link button -// ---------------------------------------------------------------------------- - -bool wxGenericCommandLinkButton::Create(wxWindow *parent, - wxWindowID id, - const wxString& mainLabel, - const wxString& note, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) -{ - if ( !wxButton::Create(parent, - id, - mainLabel + '\n' + note, - pos, - size, - style, - validator, - name) ) - return false; - - if ( !HasNativeBitmap() ) - SetDefaultBitmap(); - - return true; - -} - -void wxGenericCommandLinkButton::SetDefaultBitmap() -{ - SetBitmap(wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_BUTTON)); -} - -#endif // wxUSE_COMMANDLINKBUTTON diff --git a/Source/3rd Party/wx/src/generic/datavgen.cpp b/Source/3rd Party/wx/src/generic/datavgen.cpp deleted file mode 100644 index 95ef21a99..000000000 --- a/Source/3rd Party/wx/src/generic/datavgen.cpp +++ /dev/null @@ -1,5330 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/datavgen.cpp -// Purpose: wxDataViewCtrl generic implementation -// Author: Robert Roebling -// Modified by: Francesco Montorsi, Guru Kathiresan, Bo Yang -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DATAVIEWCTRL - -#include "wx/dataview.h" - -#ifdef wxUSE_GENERICDATAVIEWCTRL - -#ifndef WX_PRECOMP - #ifdef __WXMSW__ - #include "wx/msw/private.h" - #include "wx/msw/wrapwin.h" - #include "wx/msw/wrapcctl.h" // include "properly" - #endif - #include "wx/sizer.h" - #include "wx/log.h" - #include "wx/dcclient.h" - #include "wx/timer.h" - #include "wx/settings.h" - #include "wx/msgdlg.h" - #include "wx/dcscreen.h" - #include "wx/frame.h" -#endif - -#include "wx/stockitem.h" -#include "wx/popupwin.h" -#include "wx/renderer.h" -#include "wx/dcbuffer.h" -#include "wx/icon.h" -#include "wx/list.h" -#include "wx/listimpl.cpp" -#include "wx/imaglist.h" -#include "wx/headerctrl.h" -#include "wx/dnd.h" -#include "wx/stopwatch.h" -#include "wx/weakref.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxDataViewColumn; -class wxDataViewHeaderWindow; -class wxDataViewCtrl; - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -static const int SCROLL_UNIT_X = 15; - -// the cell padding on the left/right -static const int PADDING_RIGHTLEFT = 3; - -// the expander space margin -static const int EXPANDER_MARGIN = 4; - -#ifdef __WXMSW__ -static const int EXPANDER_OFFSET = 4; -#else -static const int EXPANDER_OFFSET = 1; -#endif - -// Below is the compare stuff. -// For the generic implementation, both the leaf nodes and the nodes are sorted for -// fast search when needed -static wxDataViewModel* g_model; - -// The column is either the index of the column to be used for sorting or one -// of the special values in this enum: -enum -{ - // Sort when we're thawed later. - SortColumn_OnThaw = -3, - - // Don't sort at all. - SortColumn_None = -2, - - // Sort using the model default sort order. - SortColumn_Default = -1 -}; - -static int g_column = SortColumn_None; -static bool g_asending = true; - -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -namespace -{ - -// Return the expander column or, if it is not set, the first column and also -// set it as the expander one for the future. -wxDataViewColumn* GetExpanderColumnOrFirstOne(wxDataViewCtrl* dataview) -{ - wxDataViewColumn* expander = dataview->GetExpanderColumn(); - if (!expander) - { - // TODO-RTL: last column for RTL support - expander = dataview->GetColumnAt( 0 ); - dataview->SetExpanderColumn(expander); - } - - return expander; -} - -wxTextCtrl *CreateEditorTextCtrl(wxWindow *parent, const wxRect& labelRect, const wxString& value) -{ - wxTextCtrl* ctrl = new wxTextCtrl(parent, wxID_ANY, value, - wxPoint(labelRect.x,labelRect.y), - wxSize(labelRect.width,labelRect.height), - wxTE_PROCESS_ENTER); - - // Adjust size of wxTextCtrl editor to fit text, even if it means being - // wider than the corresponding column (this is how Explorer behaves). - const int fitting = ctrl->GetSizeFromTextSize(ctrl->GetTextExtent(ctrl->GetValue())).x; - const int current = ctrl->GetSize().x; - const int maxwidth = ctrl->GetParent()->GetSize().x - ctrl->GetPosition().x; - - // Adjust size so that it fits all content. Don't change anything if the - // allocated space is already larger than needed and don't extend wxDVC's - // boundaries. - int width = wxMin(wxMax(current, fitting), maxwidth); - - if ( width != current ) - ctrl->SetSize(wxSize(width, -1)); - - // select the text in the control an place the cursor at the end - ctrl->SetInsertionPointEnd(); - ctrl->SelectAll(); - - return ctrl; -} - -} // anonymous namespace - -//----------------------------------------------------------------------------- -// wxDataViewColumn -//----------------------------------------------------------------------------- - -void wxDataViewColumn::Init(int width, wxAlignment align, int flags) -{ - m_width = width; - m_minWidth = 0; - m_align = align; - m_flags = flags; - m_sort = false; - m_sortAscending = true; -} - -int wxDataViewColumn::GetWidth() const -{ - switch ( m_width ) - { - case wxCOL_WIDTH_DEFAULT: - return wxDVC_DEFAULT_WIDTH; - - case wxCOL_WIDTH_AUTOSIZE: - wxCHECK_MSG( m_owner, wxDVC_DEFAULT_WIDTH, "no owner control" ); - return m_owner->GetBestColumnWidth(m_owner->GetColumnIndex(this)); - - default: - return m_width; - } -} - -void wxDataViewColumn::UpdateDisplay() -{ - if (m_owner) - { - int idx = m_owner->GetColumnIndex( this ); - m_owner->OnColumnChange( idx ); - } -} - -void wxDataViewColumn::UnsetAsSortKey() -{ - m_sort = false; - - if ( m_owner ) - m_owner->SetSortingColumnIndex(wxNOT_FOUND); - - UpdateDisplay(); -} - -void wxDataViewColumn::SetSortOrder(bool ascending) -{ - if ( !m_owner ) - return; - - // First unset the old sort column if any. - int oldSortKey = m_owner->GetSortingColumnIndex(); - if ( oldSortKey != wxNOT_FOUND ) - { - m_owner->GetColumn(oldSortKey)->UnsetAsSortKey(); - } - - // Now set this one as the new sort column. - const int idx = m_owner->GetColumnIndex(this); - m_owner->SetSortingColumnIndex(idx); - - m_sort = true; - m_sortAscending = ascending; - - // Call this directly instead of using UpdateDisplay() as we already have - // the column index, no need to look it up again. - m_owner->OnColumnChange(idx); -} - -//----------------------------------------------------------------------------- -// wxDataViewHeaderWindow -//----------------------------------------------------------------------------- - -class wxDataViewHeaderWindow : public wxHeaderCtrl -{ -public: - wxDataViewHeaderWindow(wxDataViewCtrl *parent) - : wxHeaderCtrl(parent) - { - } - - wxDataViewCtrl *GetOwner() const - { return static_cast(GetParent()); } - -protected: - // implement/override wxHeaderCtrl functions by forwarding them to the main - // control - virtual const wxHeaderColumn& GetColumn(unsigned int idx) const - { - return *(GetOwner()->GetColumn(idx)); - } - - virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle) - { - wxDataViewCtrl * const owner = GetOwner(); - - int widthContents = owner->GetBestColumnWidth(idx); - owner->GetColumn(idx)->SetWidth(wxMax(widthTitle, widthContents)); - owner->OnColumnChange(idx); - - return true; - } - -private: - void FinishEditing(); - - bool SendEvent(wxEventType type, unsigned int n) - { - wxDataViewCtrl * const owner = GetOwner(); - wxDataViewEvent event(type, owner->GetId()); - - event.SetEventObject(owner); - event.SetColumn(n); - event.SetDataViewColumn(owner->GetColumn(n)); - event.SetModel(owner->GetModel()); - - // for events created by wxDataViewHeaderWindow the - // row / value fields are not valid - return owner->ProcessWindowEvent(event); - } - - void OnClick(wxHeaderCtrlEvent& event) - { - FinishEditing(); - - const unsigned idx = event.GetColumn(); - - if ( SendEvent(wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, idx) ) - return; - - // default handling for the column click is to sort by this column or - // toggle its sort order - wxDataViewCtrl * const owner = GetOwner(); - wxDataViewColumn * const col = owner->GetColumn(idx); - if ( !col->IsSortable() ) - { - // no default handling for non-sortable columns - event.Skip(); - return; - } - - if ( col->IsSortKey() ) - { - // already using this column for sorting, just change the order - col->ToggleSortOrder(); - } - else // not using this column for sorting yet - { - col->SetSortOrder(true); - } - - wxDataViewModel * const model = owner->GetModel(); - if ( model ) - model->Resort(); - - owner->OnColumnChange(idx); - - SendEvent(wxEVT_DATAVIEW_COLUMN_SORTED, idx); - } - - void OnRClick(wxHeaderCtrlEvent& event) - { - if ( !SendEvent(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, - event.GetColumn()) ) - event.Skip(); - } - - void OnResize(wxHeaderCtrlEvent& event) - { - FinishEditing(); - - wxDataViewCtrl * const owner = GetOwner(); - - const unsigned col = event.GetColumn(); - owner->GetColumn(col)->SetWidth(event.GetWidth()); - GetOwner()->OnColumnChange(col); - } - - void OnEndReorder(wxHeaderCtrlEvent& event) - { - FinishEditing(); - - wxDataViewCtrl * const owner = GetOwner(); - owner->ColumnMoved(owner->GetColumn(event.GetColumn()), - event.GetNewOrder()); - } - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxDataViewHeaderWindow); -}; - -BEGIN_EVENT_TABLE(wxDataViewHeaderWindow, wxHeaderCtrl) - EVT_HEADER_CLICK(wxID_ANY, wxDataViewHeaderWindow::OnClick) - EVT_HEADER_RIGHT_CLICK(wxID_ANY, wxDataViewHeaderWindow::OnRClick) - - EVT_HEADER_RESIZING(wxID_ANY, wxDataViewHeaderWindow::OnResize) - EVT_HEADER_END_RESIZE(wxID_ANY, wxDataViewHeaderWindow::OnResize) - - EVT_HEADER_END_REORDER(wxID_ANY, wxDataViewHeaderWindow::OnEndReorder) -END_EVENT_TABLE() - -//----------------------------------------------------------------------------- -// wxDataViewRenameTimer -//----------------------------------------------------------------------------- - -class wxDataViewRenameTimer: public wxTimer -{ -private: - wxDataViewMainWindow *m_owner; - -public: - wxDataViewRenameTimer( wxDataViewMainWindow *owner ); - void Notify(); -}; - -//----------------------------------------------------------------------------- -// wxDataViewTreeNode -//----------------------------------------------------------------------------- - -class wxDataViewTreeNode; -WX_DEFINE_ARRAY( wxDataViewTreeNode *, wxDataViewTreeNodes ); - -int LINKAGEMODE wxGenericTreeModelNodeCmp( wxDataViewTreeNode ** node1, - wxDataViewTreeNode ** node2); - -class wxDataViewTreeNode -{ -public: - wxDataViewTreeNode(wxDataViewTreeNode *parent, const wxDataViewItem& item) - : m_parent(parent), - m_item(item), - m_branchData(NULL) - { - } - - ~wxDataViewTreeNode() - { - if ( m_branchData ) - { - wxDataViewTreeNodes& nodes = m_branchData->children; - for ( wxDataViewTreeNodes::iterator i = nodes.begin(); - i != nodes.end(); - ++i ) - { - delete *i; - } - - delete m_branchData; - } - } - - static wxDataViewTreeNode* CreateRootNode() - { - wxDataViewTreeNode *n = new wxDataViewTreeNode(NULL, wxDataViewItem()); - n->m_branchData = new BranchNodeData; - n->m_branchData->open = true; - return n; - } - - wxDataViewTreeNode * GetParent() const { return m_parent; } - - const wxDataViewTreeNodes& GetChildNodes() const - { - wxASSERT( m_branchData != NULL ); - return m_branchData->children; - } - - void InsertChild(wxDataViewTreeNode *node, unsigned index) - { - if ( !m_branchData ) - m_branchData = new BranchNodeData; - - m_branchData->children.Insert(node, index); - - // TODO: insert into sorted array directly in O(log n) instead of resorting in O(n log n) - if (g_column >= -1) - m_branchData->children.Sort( &wxGenericTreeModelNodeCmp ); - } - - void RemoveChild(wxDataViewTreeNode *node) - { - wxCHECK_RET( m_branchData != NULL, "leaf node doesn't have children" ); - m_branchData->children.Remove(node); - } - - // returns position of child node for given item in children list or wxNOT_FOUND - int FindChildByItem(const wxDataViewItem& item) const - { - if ( !m_branchData ) - return wxNOT_FOUND; - - const wxDataViewTreeNodes& nodes = m_branchData->children; - const int len = nodes.size(); - for ( int i = 0; i < len; i++ ) - { - if ( nodes[i]->m_item == item ) - return i; - } - return wxNOT_FOUND; - } - - const wxDataViewItem & GetItem() const { return m_item; } - void SetItem( const wxDataViewItem & item ) { m_item = item; } - - int GetIndentLevel() const - { - int ret = 0; - const wxDataViewTreeNode * node = this; - while( node->GetParent()->GetParent() != NULL ) - { - node = node->GetParent(); - ret ++; - } - return ret; - } - - bool IsOpen() const - { - return m_branchData && m_branchData->open; - } - - void ToggleOpen() - { - // We do not allow the (invisible) root node to be collapsed because - // there is no way to expand it again. - if ( !m_parent ) - return; - - wxCHECK_RET( m_branchData != NULL, "can't open leaf node" ); - - int sum = 0; - - const wxDataViewTreeNodes& nodes = m_branchData->children; - const int len = nodes.GetCount(); - for ( int i = 0;i < len; i ++) - sum += 1 + nodes[i]->GetSubTreeCount(); - - if (m_branchData->open) - { - ChangeSubTreeCount(-sum); - m_branchData->open = !m_branchData->open; - } - else - { - m_branchData->open = !m_branchData->open; - ChangeSubTreeCount(+sum); - } - } - - // "HasChildren" property corresponds to model's IsContainer(). Note that it may be true - // even if GetChildNodes() is empty; see below. - bool HasChildren() const - { - return m_branchData != NULL; - } - - void SetHasChildren(bool has) - { - // The invisible root item always has children, so ignore any attempts - // to change this. - if ( !m_parent ) - return; - - if ( !has ) - { - wxDELETE(m_branchData); - } - else if ( m_branchData == NULL ) - { - m_branchData = new BranchNodeData; - } - } - - int GetSubTreeCount() const - { - return m_branchData ? m_branchData->subTreeCount : 0; - } - - void ChangeSubTreeCount( int num ) - { - wxASSERT( m_branchData != NULL ); - - if( !m_branchData->open ) - return; - - m_branchData->subTreeCount += num; - wxASSERT( m_branchData->subTreeCount >= 0 ); - - if( m_parent ) - m_parent->ChangeSubTreeCount(num); - } - - void Resort() - { - if ( !m_branchData ) - return; - - if (g_column >= -1) - { - wxDataViewTreeNodes& nodes = m_branchData->children; - - nodes.Sort( &wxGenericTreeModelNodeCmp ); - int len = nodes.GetCount(); - for (int i = 0; i < len; i ++) - { - if ( nodes[i]->HasChildren() ) - nodes[i]->Resort(); - } - } - } - - -private: - wxDataViewTreeNode *m_parent; - - // Corresponding model item. - wxDataViewItem m_item; - - // Data specific to non-leaf (branch, inner) nodes. They are kept in a - // separate struct in order to conserve memory. - struct BranchNodeData - { - BranchNodeData() - : open(false), - subTreeCount(0) - { - } - - // Child nodes. Note that this may be empty even if m_hasChildren in - // case this branch of the tree wasn't expanded and realized yet. - wxDataViewTreeNodes children; - - // Is the branch node currently open (expanded)? - bool open; - - // Total count of expanded (i.e. visible with the help of some - // scrolling) items in the subtree, but excluding this node. I.e. it is - // 0 for leaves and is the number of rows the subtree occupies for - // branch nodes. - int subTreeCount; - }; - - BranchNodeData *m_branchData; -}; - - -int LINKAGEMODE wxGenericTreeModelNodeCmp( wxDataViewTreeNode ** node1, - wxDataViewTreeNode ** node2) -{ - return g_model->Compare( (*node1)->GetItem(), (*node2)->GetItem(), g_column, g_asending ); -} - - -//----------------------------------------------------------------------------- -// wxDataViewMainWindow -//----------------------------------------------------------------------------- - -WX_DEFINE_SORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection); - -class wxDataViewMainWindow: public wxWindow -{ -public: - wxDataViewMainWindow( wxDataViewCtrl *parent, - wxWindowID id, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - const wxString &name = wxT("wxdataviewctrlmainwindow") ); - virtual ~wxDataViewMainWindow(); - - bool IsList() const { return GetModel()->IsListModel(); } - bool IsVirtualList() const { return m_root == NULL; } - - // notifications from wxDataViewModel - bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); - bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); - bool ItemChanged( const wxDataViewItem &item ); - bool ValueChanged( const wxDataViewItem &item, unsigned int model_column ); - bool Cleared(); - void Resort() - { - if (!IsVirtualList()) - { - SortPrepare(); - m_root->Resort(); - } - UpdateDisplay(); - } - - // Override the base class method to resort if needed, i.e. if - // SortPrepare() was called -- and ignored -- while we were frozen. - virtual void DoThaw() - { - if ( g_column == SortColumn_OnThaw ) - { - Resort(); - g_column = SortColumn_None; - } - - wxWindow::DoThaw(); - } - - void SortPrepare() - { - g_model = GetModel(); - - wxDataViewColumn* col = GetOwner()->GetSortingColumn(); - if( !col ) - { - if (g_model->HasDefaultCompare()) - { - // See below for the explanation of IsFrozen() test. - if ( IsFrozen() ) - g_column = SortColumn_OnThaw; - else - g_column = SortColumn_Default; - } - else - g_column = SortColumn_None; - - g_asending = true; - return; - } - - // Avoid sorting while the window is frozen, this allows to quickly add - // many items without resorting after each addition and only resort - // them all at once when the window is finally thawed, see above. - if ( IsFrozen() ) - { - g_column = SortColumn_OnThaw; - return; - } - - g_column = col->GetModelColumn(); - g_asending = col->IsSortOrderAscending(); - } - - void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; } - wxDataViewCtrl *GetOwner() { return m_owner; } - const wxDataViewCtrl *GetOwner() const { return m_owner; } - - wxDataViewModel* GetModel() { return GetOwner()->GetModel(); } - const wxDataViewModel* GetModel() const { return GetOwner()->GetModel(); } - -#if wxUSE_DRAG_AND_DROP - wxBitmap CreateItemBitmap( unsigned int row, int &indent ); -#endif // wxUSE_DRAG_AND_DROP - void OnPaint( wxPaintEvent &event ); - void OnCharHook( wxKeyEvent &event ); - void OnChar( wxKeyEvent &event ); - void OnVerticalNavigation(int delta, const wxKeyEvent& event); - void OnLeftKey(); - void OnRightKey(); - void OnMouse( wxMouseEvent &event ); - void OnSetFocus( wxFocusEvent &event ); - void OnKillFocus( wxFocusEvent &event ); - - void UpdateDisplay(); - void RecalculateDisplay(); - void OnInternalIdle(); - - void OnRenameTimer(); - - void ScrollWindow( int dx, int dy, const wxRect *rect = NULL ); - void ScrollTo( int rows, int column ); - - unsigned GetCurrentRow() const { return m_currentRow; } - bool HasCurrentRow() { return m_currentRow != (unsigned int)-1; } - void ChangeCurrentRow( unsigned int row ); - bool TryAdvanceCurrentColumn(wxDataViewTreeNode *node, bool forward); - - wxDataViewColumn *GetCurrentColumn() const { return m_currentCol; } - void ClearCurrentColumn() { m_currentCol = NULL; } - - bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE); } - bool IsEmpty() { return GetRowCount() == 0; } - - int GetCountPerPage() const; - int GetEndOfLastCol() const; - unsigned int GetFirstVisibleRow() const; - - // I change this method to un const because in the tree view, - // the displaying number of the tree are changing along with the - // expanding/collapsing of the tree nodes - unsigned int GetLastVisibleRow(); - unsigned int GetRowCount() const; - - const wxDataViewSelection& GetSelections() const { return m_selection; } - void SetSelections( const wxDataViewSelection & sel ) - { m_selection = sel; UpdateDisplay(); } - void Select( const wxArrayInt& aSelections ); - void SelectAllRows( bool on ); - void SelectRow( unsigned int row, bool on ); - void SelectRows( unsigned int from, unsigned int to, bool on ); - void ReverseRowSelection( unsigned int row ); - bool IsRowSelected( unsigned int row ); - void SendSelectionChangedEvent( const wxDataViewItem& item); - - void RefreshRow( unsigned int row ); - void RefreshRows( unsigned int from, unsigned int to ); - void RefreshRowsAfter( unsigned int firstRow ); - - // returns the colour to be used for drawing the rules - wxColour GetRuleColour() const - { - return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); - } - - wxRect GetLineRect( unsigned int row ) const; - - int GetLineStart( unsigned int row ) const; // row * m_lineHeight in fixed mode - int GetLineHeight( unsigned int row ) const; // m_lineHeight in fixed mode - int GetLineAt( unsigned int y ) const; // y / m_lineHeight in fixed mode - - void SetRowHeight( int lineHeight ) { m_lineHeight = lineHeight; } - int GetRowHeight() const { return m_lineHeight; } - int GetDefaultRowHeight() const; - - // Some useful functions for row and item mapping - wxDataViewItem GetItemByRow( unsigned int row ) const; - int GetRowByItem( const wxDataViewItem & item ) const; - - wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const; - // We did not need this temporarily - // wxDataViewTreeNode * GetTreeNodeByItem( const wxDataViewItem & item ); - - // Methods for building the mapping tree - void BuildTree( wxDataViewModel * model ); - void DestroyTree(); - void HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column ); - wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn* column ); - - void Expand( unsigned int row ); - void Collapse( unsigned int row ); - bool IsExpanded( unsigned int row ) const; - bool HasChildren( unsigned int row ) const; - -#if wxUSE_DRAG_AND_DROP - bool EnableDragSource( const wxDataFormat &format ); - bool EnableDropTarget( const wxDataFormat &format ); - - void RemoveDropHint(); - wxDragResult OnDragOver( wxDataFormat format, wxCoord x, wxCoord y, wxDragResult def ); - bool OnDrop( wxDataFormat format, wxCoord x, wxCoord y ); - wxDragResult OnData( wxDataFormat format, wxCoord x, wxCoord y, wxDragResult def ); - void OnLeave(); -#endif // wxUSE_DRAG_AND_DROP - - void OnColumnsCountChanged(); - - // Called by wxDataViewCtrl and our own OnRenameTimer() to start edit the - // specified item in the given column. - void StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col); - void FinishEditing(); - -private: - int RecalculateCount() const; - - // Return false only if the event was vetoed by its handler. - bool SendExpanderEvent(wxEventType type, const wxDataViewItem& item); - - wxDataViewTreeNode * FindNode( const wxDataViewItem & item ); - - wxDataViewColumn *FindColumnForEditing(const wxDataViewItem& item, wxDataViewCellMode mode); - - bool IsCellEditableInMode(const wxDataViewItem& item, const wxDataViewColumn *col, wxDataViewCellMode mode) const; - - void DrawCellBackground( wxDataViewRenderer* cell, wxDC& dc, const wxRect& rect ); - -private: - wxDataViewCtrl *m_owner; - int m_lineHeight; - bool m_dirty; - - wxDataViewColumn *m_currentCol; - unsigned int m_currentRow; - wxDataViewSelection m_selection; - - wxDataViewRenameTimer *m_renameTimer; - bool m_lastOnSame; - - bool m_hasFocus; - bool m_useCellFocus; - bool m_currentColSetByKeyboard; - -#if wxUSE_DRAG_AND_DROP - int m_dragCount; - wxPoint m_dragStart; - - bool m_dragEnabled; - wxDataFormat m_dragFormat; - - bool m_dropEnabled; - wxDataFormat m_dropFormat; - bool m_dropHint; - unsigned int m_dropHintLine; -#endif // wxUSE_DRAG_AND_DROP - - // for double click logic - unsigned int m_lineLastClicked, - m_lineBeforeLastClicked, - m_lineSelectSingleOnUp; - - // the pen used to draw horiz/vertical rules - wxPen m_penRule; - - // the pen used to draw the expander and the lines - wxPen m_penExpander; - - // This is the tree structure of the model - wxDataViewTreeNode * m_root; - int m_count; - - // This is the tree node under the cursor - wxDataViewTreeNode * m_underMouse; - - // The control used for editing or NULL. - wxWeakRef m_editorCtrl; - - // Id m_editorCtrl is non-NULL, pointer to the associated renderer. - wxDataViewRenderer* m_editorRenderer; - -private: - DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow) - DECLARE_EVENT_TABLE() -}; - -// --------------------------------------------------------- -// wxGenericDataViewModelNotifier -// --------------------------------------------------------- - -class wxGenericDataViewModelNotifier: public wxDataViewModelNotifier -{ -public: - wxGenericDataViewModelNotifier( wxDataViewMainWindow *mainWindow ) - { m_mainWindow = mainWindow; } - - virtual bool ItemAdded( const wxDataViewItem & parent, const wxDataViewItem & item ) - { return m_mainWindow->ItemAdded( parent , item ); } - virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) - { return m_mainWindow->ItemDeleted( parent, item ); } - virtual bool ItemChanged( const wxDataViewItem & item ) - { return m_mainWindow->ItemChanged(item); } - virtual bool ValueChanged( const wxDataViewItem & item , unsigned int col ) - { return m_mainWindow->ValueChanged( item, col ); } - virtual bool Cleared() - { return m_mainWindow->Cleared(); } - virtual void Resort() - { m_mainWindow->Resort(); } - - wxDataViewMainWindow *m_mainWindow; -}; - -// --------------------------------------------------------- -// wxDataViewRenderer -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer, wxDataViewRendererBase) - -wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype, - wxDataViewCellMode mode, - int align) : - wxDataViewCustomRendererBase( varianttype, mode, align ) -{ - m_align = align; - m_mode = mode; - m_ellipsizeMode = wxELLIPSIZE_MIDDLE; - m_dc = NULL; -} - -wxDataViewRenderer::~wxDataViewRenderer() -{ - delete m_dc; -} - -wxDC *wxDataViewRenderer::GetDC() -{ - if (m_dc == NULL) - { - if (GetOwner() == NULL) - return NULL; - if (GetOwner()->GetOwner() == NULL) - return NULL; - m_dc = new wxClientDC( GetOwner()->GetOwner() ); - } - - return m_dc; -} - -void wxDataViewRenderer::SetAlignment( int align ) -{ - m_align=align; -} - -int wxDataViewRenderer::GetAlignment() const -{ - return m_align; -} - -// --------------------------------------------------------- -// wxDataViewCustomRenderer -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer) - -wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype, - wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ -} - -// --------------------------------------------------------- -// wxDataViewTextRenderer -// --------------------------------------------------------- - -IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewRenderer) - -wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype, - wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ -} - -bool wxDataViewTextRenderer::SetValue( const wxVariant &value ) -{ - m_text = value.GetString(); - - return true; -} - -bool wxDataViewTextRenderer::GetValue( wxVariant& WXUNUSED(value) ) const -{ - return false; -} - -bool wxDataViewTextRenderer::HasEditorCtrl() const -{ - return true; -} - -wxWindow* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow *parent, - wxRect labelRect, const wxVariant &value ) -{ - return CreateEditorTextCtrl(parent, labelRect, value); -} - -bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxWindow *editor, wxVariant &value ) -{ - wxTextCtrl *text = (wxTextCtrl*) editor; - value = text->GetValue(); - return true; -} - -bool wxDataViewTextRenderer::Render(wxRect rect, wxDC *dc, int state) -{ - RenderText(m_text, 0, rect, dc, state); - return true; -} - -wxSize wxDataViewTextRenderer::GetSize() const -{ - if (!m_text.empty()) - return GetTextExtent(m_text); - else - return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE); -} - -// --------------------------------------------------------- -// wxDataViewBitmapRenderer -// --------------------------------------------------------- - -IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewRenderer) - -wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype, - wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ -} - -bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value ) -{ - if (value.GetType() == wxT("wxBitmap")) - m_bitmap << value; - if (value.GetType() == wxT("wxIcon")) - m_icon << value; - - return true; -} - -bool wxDataViewBitmapRenderer::GetValue( wxVariant& WXUNUSED(value) ) const -{ - return false; -} - -bool wxDataViewBitmapRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) -{ - if (m_bitmap.IsOk()) - dc->DrawBitmap( m_bitmap, cell.x, cell.y, true /* use mask */ ); - else if (m_icon.IsOk()) - dc->DrawIcon( m_icon, cell.x, cell.y ); - - return true; -} - -wxSize wxDataViewBitmapRenderer::GetSize() const -{ - if (m_bitmap.IsOk()) - return wxSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() ); - else if (m_icon.IsOk()) - return wxSize( m_icon.GetWidth(), m_icon.GetHeight() ); - - return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE); -} - -// --------------------------------------------------------- -// wxDataViewToggleRenderer -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer, wxDataViewRenderer) - -wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString &varianttype, - wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ - m_toggle = false; -} - -bool wxDataViewToggleRenderer::SetValue( const wxVariant &value ) -{ - m_toggle = value.GetBool(); - - return true; -} - -bool wxDataViewToggleRenderer::GetValue( wxVariant &WXUNUSED(value) ) const -{ - return false; -} - -bool wxDataViewToggleRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) -{ - int flags = 0; - if (m_toggle) - flags |= wxCONTROL_CHECKED; - if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE || - GetEnabled() == false) - flags |= wxCONTROL_DISABLED; - - // Ensure that the check boxes always have at least the minimal required - // size, otherwise DrawCheckBox() doesn't really work well. If this size is - // greater than the cell size, the checkbox will be truncated but this is a - // lesser evil. - wxSize size = cell.GetSize(); - size.IncTo(GetSize()); - cell.SetSize(size); - - wxRendererNative::Get().DrawCheckBox( - GetOwner()->GetOwner(), - *dc, - cell, - flags ); - - return true; -} - -bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cellRect), - wxDataViewModel *model, - const wxDataViewItem& item, - unsigned int col, - const wxMouseEvent *mouseEvent) -{ - if ( mouseEvent ) - { - // Only react to clicks directly on the checkbox, not elsewhere in the - // same cell. - if ( !wxRect(GetSize()).Contains(mouseEvent->GetPosition()) ) - return false; - } - - model->ChangeValue(!m_toggle, item, col); - return true; -} - -wxSize wxDataViewToggleRenderer::GetSize() const -{ - // the window parameter is not used by GetCheckBoxSize() so it's - // safe to pass NULL - return wxRendererNative::Get().GetCheckBoxSize(NULL); -} - -// --------------------------------------------------------- -// wxDataViewProgressRenderer -// --------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer, wxDataViewRenderer) - -wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label, - const wxString &varianttype, wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ - m_label = label; - m_value = 0; -} - -bool wxDataViewProgressRenderer::SetValue( const wxVariant &value ) -{ - m_value = (long) value; - - if (m_value < 0) m_value = 0; - if (m_value > 100) m_value = 100; - - return true; -} - -bool wxDataViewProgressRenderer::GetValue( wxVariant &value ) const -{ - value = (long) m_value; - return true; -} - -bool -wxDataViewProgressRenderer::Render(wxRect rect, wxDC *dc, int WXUNUSED(state)) -{ - // deflate the rect to leave a small border between bars in adjacent rows - wxRect bar = rect.Deflate(0, 1); - - dc->SetBrush( *wxTRANSPARENT_BRUSH ); - dc->SetPen( *wxBLACK_PEN ); - dc->DrawRectangle( bar ); - - bar.width = (int)(bar.width * m_value / 100.); - dc->SetPen( *wxTRANSPARENT_PEN ); - - const wxDataViewItemAttr& attr = GetAttr(); - dc->SetBrush( attr.HasColour() ? wxBrush(attr.GetColour()) - : *wxBLUE_BRUSH ); - dc->DrawRectangle( bar ); - - return true; -} - -wxSize wxDataViewProgressRenderer::GetSize() const -{ - // Return -1 width because a progress bar fits any width; unlike most - // renderers, it doesn't have a "good" width for the content. This makes it - // grow to the whole column, which is pretty much always the desired - // behaviour. Keep the height fixed so that the progress bar isn't too fat. - return wxSize(-1, 12); -} - -// --------------------------------------------------------- -// wxDataViewIconTextRenderer -// --------------------------------------------------------- - -IMPLEMENT_CLASS(wxDataViewIconTextRenderer, wxDataViewRenderer) - -wxDataViewIconTextRenderer::wxDataViewIconTextRenderer( -const wxString &varianttype, wxDataViewCellMode mode, int align ) : - wxDataViewRenderer( varianttype, mode, align ) -{ - SetMode(mode); - SetAlignment(align); -} - -bool wxDataViewIconTextRenderer::SetValue( const wxVariant &value ) -{ - m_value << value; - return true; -} - -bool wxDataViewIconTextRenderer::GetValue( wxVariant& WXUNUSED(value) ) const -{ - return false; -} - -bool wxDataViewIconTextRenderer::Render(wxRect rect, wxDC *dc, int state) -{ - int xoffset = 0; - - const wxIcon& icon = m_value.GetIcon(); - if ( icon.IsOk() ) - { - dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight())/2); - xoffset = icon.GetWidth()+4; - } - - RenderText(m_value.GetText(), xoffset, rect, dc, state); - - return true; -} - -wxSize wxDataViewIconTextRenderer::GetSize() const -{ - if (!m_value.GetText().empty()) - { - wxSize size = GetTextExtent(m_value.GetText()); - - if (m_value.GetIcon().IsOk()) - size.x += m_value.GetIcon().GetWidth() + 4; - return size; - } - return wxSize(80,20); -} - -wxWindow* wxDataViewIconTextRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value) -{ - wxDataViewIconText iconText; - iconText << value; - - wxString text = iconText.GetText(); - - // adjust the label rect to take the width of the icon into account - if (iconText.GetIcon().IsOk()) - { - int w = iconText.GetIcon().GetWidth() + 4; - labelRect.x += w; - labelRect.width -= w; - } - - return CreateEditorTextCtrl(parent, labelRect, text); -} - -bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxWindow *editor, wxVariant& value ) -{ - wxTextCtrl *text = (wxTextCtrl*) editor; - - // The icon can't be edited so get its old value and reuse it. - wxVariant valueOld; - wxDataViewColumn* const col = GetOwner(); - GetView()->GetModel()->GetValue(valueOld, m_item, col->GetModelColumn()); - - wxDataViewIconText iconText; - iconText << valueOld; - - // But replace the text with the value entered by user. - iconText.SetText(text->GetValue()); - - value << iconText; - return true; -} - -//----------------------------------------------------------------------------- -// wxDataViewDropTarget -//----------------------------------------------------------------------------- - -#if wxUSE_DRAG_AND_DROP - -class wxBitmapCanvas: public wxWindow -{ -public: - wxBitmapCanvas( wxWindow *parent, const wxBitmap &bitmap, const wxSize &size ) : - wxWindow( parent, wxID_ANY, wxPoint(0,0), size ) - { - m_bitmap = bitmap; - Connect( wxEVT_PAINT, wxPaintEventHandler(wxBitmapCanvas::OnPaint) ); - } - - void OnPaint( wxPaintEvent &WXUNUSED(event) ) - { - wxPaintDC dc(this); - dc.DrawBitmap( m_bitmap, 0, 0); - } - - wxBitmap m_bitmap; -}; - -class wxDataViewDropSource: public wxDropSource -{ -public: - wxDataViewDropSource( wxDataViewMainWindow *win, unsigned int row ) : - wxDropSource( win ) - { - m_win = win; - m_row = row; - m_hint = NULL; - } - - ~wxDataViewDropSource() - { - delete m_hint; - } - - virtual bool GiveFeedback( wxDragResult WXUNUSED(effect) ) - { - wxPoint pos = wxGetMousePosition(); - - if (!m_hint) - { - int liney = m_win->GetLineStart( m_row ); - int linex = 0; - m_win->GetOwner()->CalcUnscrolledPosition( 0, liney, NULL, &liney ); - m_win->ClientToScreen( &linex, &liney ); - m_dist_x = pos.x - linex; - m_dist_y = pos.y - liney; - - int indent = 0; - wxBitmap ib = m_win->CreateItemBitmap( m_row, indent ); - m_dist_x -= indent; - m_hint = new wxFrame( m_win->GetParent(), wxID_ANY, wxEmptyString, - wxPoint(pos.x - m_dist_x, pos.y + 5 ), - ib.GetSize(), - wxFRAME_TOOL_WINDOW | - wxFRAME_FLOAT_ON_PARENT | - wxFRAME_NO_TASKBAR | - wxNO_BORDER ); - new wxBitmapCanvas( m_hint, ib, ib.GetSize() ); - m_hint->Show(); - } - else - { - m_hint->Move( pos.x - m_dist_x, pos.y + 5 ); - m_hint->SetTransparent( 128 ); - } - - return false; - } - - wxDataViewMainWindow *m_win; - unsigned int m_row; - wxFrame *m_hint; - int m_dist_x,m_dist_y; -}; - - -class wxDataViewDropTarget: public wxDropTarget -{ -public: - wxDataViewDropTarget( wxDataObject *obj, wxDataViewMainWindow *win ) : - wxDropTarget( obj ) - { - m_win = win; - } - - virtual wxDragResult OnDragOver( wxCoord x, wxCoord y, wxDragResult def ) - { - wxDataFormat format = GetMatchingPair(); - if (format == wxDF_INVALID) - return wxDragNone; - return m_win->OnDragOver( format, x, y, def); - } - - virtual bool OnDrop( wxCoord x, wxCoord y ) - { - wxDataFormat format = GetMatchingPair(); - if (format == wxDF_INVALID) - return false; - return m_win->OnDrop( format, x, y ); - } - - virtual wxDragResult OnData( wxCoord x, wxCoord y, wxDragResult def ) - { - wxDataFormat format = GetMatchingPair(); - if (format == wxDF_INVALID) - return wxDragNone; - if (!GetData()) - return wxDragNone; - return m_win->OnData( format, x, y, def ); - } - - virtual void OnLeave() - { m_win->OnLeave(); } - - wxDataViewMainWindow *m_win; -}; - -#endif // wxUSE_DRAG_AND_DROP - -//----------------------------------------------------------------------------- -// wxDataViewRenameTimer -//----------------------------------------------------------------------------- - -wxDataViewRenameTimer::wxDataViewRenameTimer( wxDataViewMainWindow *owner ) -{ - m_owner = owner; -} - -void wxDataViewRenameTimer::Notify() -{ - m_owner->OnRenameTimer(); -} - -//----------------------------------------------------------------------------- -// wxDataViewMainWindow -//----------------------------------------------------------------------------- - -// The tree building helper, declared firstly -static void BuildTreeHelper( const wxDataViewModel * model, const wxDataViewItem & item, - wxDataViewTreeNode * node); - -int LINKAGEMODE wxDataViewSelectionCmp( unsigned int row1, unsigned int row2 ) -{ - if (row1 > row2) return 1; - if (row1 == row2) return 0; - return -1; -} - -IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow, wxWindow) - -BEGIN_EVENT_TABLE(wxDataViewMainWindow,wxWindow) - EVT_PAINT (wxDataViewMainWindow::OnPaint) - EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse) - EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus) - EVT_KILL_FOCUS (wxDataViewMainWindow::OnKillFocus) - EVT_CHAR_HOOK (wxDataViewMainWindow::OnCharHook) - EVT_CHAR (wxDataViewMainWindow::OnChar) -END_EVENT_TABLE() - -wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, const wxString &name ) : - wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE, name ), - m_selection( wxDataViewSelectionCmp ) - -{ - SetOwner( parent ); - - m_editorRenderer = NULL; - - m_lastOnSame = false; - m_renameTimer = new wxDataViewRenameTimer( this ); - - // TODO: user better initial values/nothing selected - m_currentCol = NULL; - m_currentColSetByKeyboard = false; - m_useCellFocus = false; - m_currentRow = (unsigned)-1; - m_lineHeight = GetDefaultRowHeight(); - -#if wxUSE_DRAG_AND_DROP - m_dragCount = 0; - m_dragStart = wxPoint(0,0); - - m_dragEnabled = false; - m_dropEnabled = false; - m_dropHint = false; - m_dropHintLine = (unsigned int) -1; -#endif // wxUSE_DRAG_AND_DROP - - m_lineLastClicked = (unsigned int) -1; - m_lineBeforeLastClicked = (unsigned int) -1; - m_lineSelectSingleOnUp = (unsigned int) -1; - - m_hasFocus = false; - - SetBackgroundColour( *wxWHITE ); - - SetBackgroundStyle(wxBG_STYLE_CUSTOM); - - m_penRule = wxPen(GetRuleColour()); - - // compose a pen whichcan draw black lines - // TODO: maybe there is something system colour to use - m_penExpander = wxPen(wxColour(0,0,0)); - - m_root = wxDataViewTreeNode::CreateRootNode(); - - // Make m_count = -1 will cause the class recaculate the real displaying number of rows. - m_count = -1; - m_underMouse = NULL; - UpdateDisplay(); -} - -wxDataViewMainWindow::~wxDataViewMainWindow() -{ - DestroyTree(); - delete m_renameTimer; -} - - -int wxDataViewMainWindow::GetDefaultRowHeight() const -{ -#ifdef __WXMSW__ - // We would like to use the same line height that Explorer uses. This is - // different from standard ListView control since Vista. - if ( wxGetWinVersion() >= wxWinVersion_Vista ) - return wxMax(16, GetCharHeight()) + 6; // 16 = mini icon height - else -#endif // __WXMSW__ - return wxMax(16, GetCharHeight()) + 1; // 16 = mini icon height -} - - - -#if wxUSE_DRAG_AND_DROP -bool wxDataViewMainWindow::EnableDragSource( const wxDataFormat &format ) -{ - m_dragFormat = format; - m_dragEnabled = format != wxDF_INVALID; - - return true; -} - -bool wxDataViewMainWindow::EnableDropTarget( const wxDataFormat &format ) -{ - m_dropFormat = format; - m_dropEnabled = format != wxDF_INVALID; - - if (m_dropEnabled) - SetDropTarget( new wxDataViewDropTarget( new wxCustomDataObject( format ), this ) ); - - return true; -} - -void wxDataViewMainWindow::RemoveDropHint() -{ - if (m_dropHint) - { - m_dropHint = false; - RefreshRow( m_dropHintLine ); - m_dropHintLine = (unsigned int) -1; - } -} - -wxDragResult wxDataViewMainWindow::OnDragOver( wxDataFormat format, wxCoord x, - wxCoord y, wxDragResult def ) -{ - int xx = x; - int yy = y; - m_owner->CalcUnscrolledPosition( xx, yy, &xx, &yy ); - unsigned int row = GetLineAt( yy ); - - if ((row >= GetRowCount()) || (xx > GetEndOfLastCol())) - { - RemoveDropHint(); - return wxDragNone; - } - - wxDataViewItem item = GetItemByRow( row ); - - wxDataViewModel *model = GetModel(); - - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() ); - event.SetEventObject( m_owner ); - event.SetItem( item ); - event.SetModel( model ); - event.SetDataFormat( format ); - event.SetDropEffect( def ); - if (!m_owner->HandleWindowEvent( event )) - { - RemoveDropHint(); - return wxDragNone; - } - - if (!event.IsAllowed()) - { - RemoveDropHint(); - return wxDragNone; - } - - - if (m_dropHint && (row != m_dropHintLine)) - RefreshRow( m_dropHintLine ); - m_dropHint = true; - m_dropHintLine = row; - RefreshRow( row ); - - return def; -} - -bool wxDataViewMainWindow::OnDrop( wxDataFormat format, wxCoord x, wxCoord y ) -{ - RemoveDropHint(); - - int xx = x; - int yy = y; - m_owner->CalcUnscrolledPosition( xx, yy, &xx, &yy ); - unsigned int row = GetLineAt( yy ); - - if ((row >= GetRowCount()) || (xx > GetEndOfLastCol())) - return false; - - wxDataViewItem item = GetItemByRow( row ); - - wxDataViewModel *model = GetModel(); - - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() ); - event.SetEventObject( m_owner ); - event.SetItem( item ); - event.SetModel( model ); - event.SetDataFormat( format ); - if (!m_owner->HandleWindowEvent( event )) - return false; - - if (!event.IsAllowed()) - return false; - - return true; -} - -wxDragResult wxDataViewMainWindow::OnData( wxDataFormat format, wxCoord x, wxCoord y, - wxDragResult def ) -{ - int xx = x; - int yy = y; - m_owner->CalcUnscrolledPosition( xx, yy, &xx, &yy ); - unsigned int row = GetLineAt( yy ); - - if ((row >= GetRowCount()) || (xx > GetEndOfLastCol())) - return wxDragNone; - - wxDataViewItem item = GetItemByRow( row ); - - wxDataViewModel *model = GetModel(); - - wxCustomDataObject *obj = (wxCustomDataObject *) GetDropTarget()->GetDataObject(); - - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP, m_owner->GetId() ); - event.SetEventObject( m_owner ); - event.SetItem( item ); - event.SetModel( model ); - event.SetDataFormat( format ); - event.SetDataSize( obj->GetSize() ); - event.SetDataBuffer( obj->GetData() ); - event.SetDropEffect( def ); - if (!m_owner->HandleWindowEvent( event )) - return wxDragNone; - - if (!event.IsAllowed()) - return wxDragNone; - - return def; -} - -void wxDataViewMainWindow::OnLeave() -{ - RemoveDropHint(); -} - -wxBitmap wxDataViewMainWindow::CreateItemBitmap( unsigned int row, int &indent ) -{ - int height = GetLineHeight( row ); - int width = 0; - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int col; - for (col = 0; col < cols; col++) - { - wxDataViewColumn *column = GetOwner()->GetColumnAt(col); - if (column->IsHidden()) - continue; // skip it! - width += column->GetWidth(); - } - - indent = 0; - if (!IsList()) - { - wxDataViewTreeNode *node = GetTreeNodeByRow(row); - indent = GetOwner()->GetIndent() * node->GetIndentLevel(); - indent = indent + m_lineHeight; - // try to use the m_lineHeight as the expander space - } - width -= indent; - - wxBitmap bitmap( width, height ); - wxMemoryDC dc( bitmap ); - dc.SetFont( GetFont() ); - dc.SetPen( *wxBLACK_PEN ); - dc.SetBrush( *wxWHITE_BRUSH ); - dc.DrawRectangle( 0,0,width,height ); - - wxDataViewModel *model = m_owner->GetModel(); - - wxDataViewColumn * const - expander = GetExpanderColumnOrFirstOne(GetOwner()); - - int x = 0; - for (col = 0; col < cols; col++) - { - wxDataViewColumn *column = GetOwner()->GetColumnAt( col ); - wxDataViewRenderer *cell = column->GetRenderer(); - - if (column->IsHidden()) - continue; // skip it! - - width = column->GetWidth(); - - if (column == expander) - width -= indent; - - wxDataViewItem item = GetItemByRow( row ); - cell->PrepareForItem(model, item, column->GetModelColumn()); - - wxRect item_rect(x, 0, width, height); - item_rect.Deflate(PADDING_RIGHTLEFT, 0); - - // dc.SetClippingRegion( item_rect ); - cell->WXCallRender(item_rect, &dc, 0); - // dc.DestroyClippingRegion(); - - x += width; - } - - return bitmap; -} - -#endif // wxUSE_DRAG_AND_DROP - - -// Draw focus rect for individual cell. Unlike native focus rect, we render -// this in foreground text color (typically white) to enhance contrast and -// make it visible. -static void DrawSelectedCellFocusRect(wxDC& dc, const wxRect& rect) -{ - // (This code is based on wxRendererGeneric::DrawFocusRect and modified.) - - // draw the pixels manually because the "dots" in wxPen with wxDOT style - // may be short traits and not really dots - // - // note that to behave in the same manner as DrawRect(), we must exclude - // the bottom and right borders from the rectangle - wxCoord x1 = rect.GetLeft(), - y1 = rect.GetTop(), - x2 = rect.GetRight(), - y2 = rect.GetBottom(); - - wxDCPenChanger pen(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); - - wxCoord z; - for ( z = x1 + 1; z < x2; z += 2 ) - dc.DrawPoint(z, rect.GetTop()); - - wxCoord shift = z == x2 ? 0 : 1; - for ( z = y1 + shift; z < y2; z += 2 ) - dc.DrawPoint(x2, z); - - shift = z == y2 ? 0 : 1; - for ( z = x2 - shift; z > x1; z -= 2 ) - dc.DrawPoint(z, y2); - - shift = z == x1 ? 0 : 1; - for ( z = y2 - shift; z > y1; z -= 2 ) - dc.DrawPoint(x1, z); -} - - -void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) -{ - wxDataViewModel *model = GetModel(); - wxAutoBufferedPaintDC dc( this ); - - dc.SetBrush(GetOwner()->GetBackgroundColour()); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle(GetClientSize()); - - if ( IsEmpty() ) - { - // No items to draw. - return; - } - - // prepare the DC - GetOwner()->PrepareDC( dc ); - dc.SetFont( GetFont() ); - - wxRect update = GetUpdateRegion().GetBox(); - m_owner->CalcUnscrolledPosition( update.x, update.y, &update.x, &update.y ); - - // compute which items needs to be redrawn - unsigned int item_start = GetLineAt( wxMax(0,update.y) ); - unsigned int item_count = - wxMin( (int)( GetLineAt( wxMax(0,update.y+update.height) ) - item_start + 1), - (int)(GetRowCount( ) - item_start)); - unsigned int item_last = item_start + item_count; - - // Send the event to wxDataViewCtrl itself. - wxWindow * const parent = GetParent(); - wxDataViewEvent cache_event(wxEVT_DATAVIEW_CACHE_HINT, parent->GetId()); - cache_event.SetEventObject(parent); - cache_event.SetCache(item_start, item_last - 1); - parent->ProcessWindowEvent(cache_event); - - // compute which columns needs to be redrawn - unsigned int cols = GetOwner()->GetColumnCount(); - if ( !cols ) - { - // we assume that we have at least one column below and painting an - // empty control is unnecessary anyhow - return; - } - - unsigned int col_start = 0; - unsigned int x_start; - for (x_start = 0; col_start < cols; col_start++) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt(col_start); - if (col->IsHidden()) - continue; // skip it! - - unsigned int w = col->GetWidth(); - if (x_start+w >= (unsigned int)update.x) - break; - - x_start += w; - } - - unsigned int col_last = col_start; - unsigned int x_last = x_start; - for (; col_last < cols; col_last++) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt(col_last); - if (col->IsHidden()) - continue; // skip it! - - if (x_last > (unsigned int)update.GetRight()) - break; - - x_last += col->GetWidth(); - } - - // Draw background of alternate rows specially if required - if ( m_owner->HasFlag(wxDV_ROW_LINES) ) - { - wxColour altRowColour = m_owner->m_alternateRowColour; - if ( !altRowColour.IsOk() ) - { - // Determine the alternate rows colour automatically from the - // background colour. - const wxColour bgColour = m_owner->GetBackgroundColour(); - - // Depending on the background, alternate row color - // will be 3% more dark or 50% brighter. - int alpha = bgColour.GetRGB() > 0x808080 ? 97 : 150; - altRowColour = bgColour.ChangeLightness(alpha); - } - - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(wxBrush(altRowColour)); - - for (unsigned int item = item_start; item < item_last; item++) - { - if ( item % 2 ) - { - dc.DrawRectangle(x_start, - GetLineStart(item), - GetClientSize().GetWidth(), - GetLineHeight(item)); - } - } - } - - // Draw horizontal rules if required - if ( m_owner->HasFlag(wxDV_HORIZ_RULES) ) - { - dc.SetPen(m_penRule); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - for (unsigned int i = item_start; i <= item_last; i++) - { - int y = GetLineStart( i ); - dc.DrawLine(x_start, y, x_last, y); - } - } - - // Draw vertical rules if required - if ( m_owner->HasFlag(wxDV_VERT_RULES) ) - { - dc.SetPen(m_penRule); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - // NB: Vertical rules are drawn in the last pixel of a column so that - // they align perfectly with native MSW wxHeaderCtrl as well as for - // consistency with MSW native list control. There's no vertical - // rule at the most-left side of the control. - - int x = x_start - 1; - for (unsigned int i = col_start; i < col_last; i++) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt(i); - if (col->IsHidden()) - continue; // skip it - - x += col->GetWidth(); - - dc.DrawLine(x, GetLineStart( item_start ), - x, GetLineStart( item_last ) ); - } - } - - // redraw the background for the items which are selected/current - for (unsigned int item = item_start; item < item_last; item++) - { - bool selected = m_selection.Index( item ) != wxNOT_FOUND; - - if (selected || item == m_currentRow) - { - wxRect rect( x_start, GetLineStart( item ), - x_last - x_start, GetLineHeight( item ) ); - - // draw selection and whole-item focus: - if ( selected ) - { - int flags = wxCONTROL_SELECTED; - if (m_hasFocus) - flags |= wxCONTROL_FOCUSED; - - wxRendererNative::Get().DrawItemSelectionRect - ( - this, - dc, - rect, - flags - ); - } - - // draw keyboard focus rect if applicable - if ( item == m_currentRow && m_hasFocus ) - { - bool renderColumnFocus = false; - - if ( m_useCellFocus && m_currentCol && m_currentColSetByKeyboard ) - { - renderColumnFocus = true; - - // If this is container node without columns, render full-row focus: - if ( !IsList() ) - { - wxDataViewTreeNode *node = GetTreeNodeByRow(item); - if ( node->HasChildren() && !model->HasContainerColumns(node->GetItem()) ) - renderColumnFocus = false; - } - } - - if ( renderColumnFocus ) - { - for ( unsigned int i = col_start; i < col_last; i++ ) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt(i); - if ( col->IsHidden() ) - continue; - - rect.width = col->GetWidth(); - - if ( col == m_currentCol ) - { - // make the rect more visible by adding a small - // margin around it: - rect.Deflate(1, 1); - - if ( selected ) - { - // DrawFocusRect() uses XOR and is all but - // invisible against dark-blue background. Use - // the same color used for selected text. - DrawSelectedCellFocusRect(dc, rect); - } - else - { - wxRendererNative::Get().DrawFocusRect - ( - this, - dc, - rect, - 0 - ); - } - break; - } - - rect.x += rect.width; - } - } - else - { - // render focus rectangle for the whole row - wxRendererNative::Get().DrawFocusRect - ( - this, - dc, - rect, - selected ? (int)wxCONTROL_SELECTED : 0 - ); - } - } - } - } - -#if wxUSE_DRAG_AND_DROP - if (m_dropHint) - { - wxRect rect( x_start, GetLineStart( m_dropHintLine ), - x_last - x_start, GetLineHeight( m_dropHintLine ) ); - dc.SetPen( *wxBLACK_PEN ); - dc.SetBrush( *wxTRANSPARENT_BRUSH ); - dc.DrawRectangle( rect ); - } -#endif // wxUSE_DRAG_AND_DROP - - wxDataViewColumn * const - expander = GetExpanderColumnOrFirstOne(GetOwner()); - - // redraw all cells for all rows which must be repainted and all columns - wxRect cell_rect; - cell_rect.x = x_start; - for (unsigned int i = col_start; i < col_last; i++) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt( i ); - wxDataViewRenderer *cell = col->GetRenderer(); - cell_rect.width = col->GetWidth(); - - if ( col->IsHidden() || cell_rect.width <= 0 ) - continue; // skip it! - - for (unsigned int item = item_start; item < item_last; item++) - { - // get the cell value and set it into the renderer - wxDataViewTreeNode *node = NULL; - wxDataViewItem dataitem; - - if (!IsVirtualList()) - { - node = GetTreeNodeByRow(item); - if( node == NULL ) - continue; - - dataitem = node->GetItem(); - - // Skip all columns of "container" rows except the expander - // column itself unless HasContainerColumns() overrides this. - if ( col != expander && - model->IsContainer(dataitem) && - !model->HasContainerColumns(dataitem) ) - continue; - } - else - { - dataitem = wxDataViewItem( wxUIntToPtr(item+1) ); - } - - // update cell_rect - cell_rect.y = GetLineStart( item ); - cell_rect.height = GetLineHeight( item ); - - cell->PrepareForItem(model, dataitem, col->GetModelColumn()); - - // draw the background - bool selected = m_selection.Index( item ) != wxNOT_FOUND; - if ( !selected ) - DrawCellBackground( cell, dc, cell_rect ); - - // deal with the expander - int indent = 0; - if ((!IsList()) && (col == expander)) - { - // Calculate the indent first - indent = GetOwner()->GetIndent() * node->GetIndentLevel(); - - // we reserve m_lineHeight of horizontal space for the expander - // but leave EXPANDER_MARGIN around the expander itself - int exp_x = cell_rect.x + indent + EXPANDER_MARGIN; - - indent += m_lineHeight; - - // draw expander if needed and visible - if ( node->HasChildren() && exp_x < cell_rect.GetRight() ) - { - dc.SetPen( m_penExpander ); - dc.SetBrush( wxNullBrush ); - - int exp_size = m_lineHeight - 2*EXPANDER_MARGIN; - int exp_y = cell_rect.y + (cell_rect.height - exp_size)/2 - + EXPANDER_MARGIN - EXPANDER_OFFSET; - - const wxRect rect(exp_x, exp_y, exp_size, exp_size); - - int flag = 0; - if ( m_underMouse == node ) - flag |= wxCONTROL_CURRENT; - if ( node->IsOpen() ) - flag |= wxCONTROL_EXPANDED; - - // ensure that we don't overflow the cell (which might - // happen if the column is very narrow) - wxDCClipper clip(dc, cell_rect); - - wxRendererNative::Get().DrawTreeItemButton( this, dc, rect, flag); - } - - // force the expander column to left-center align - cell->SetAlignment( wxALIGN_CENTER_VERTICAL ); - } - - wxRect item_rect = cell_rect; - item_rect.Deflate(PADDING_RIGHTLEFT, 0); - - // account for the tree indent (harmless if we're not indented) - item_rect.x += indent; - item_rect.width -= indent; - - if ( item_rect.width <= 0 ) - continue; - - int state = 0; - if (m_hasFocus && selected) - state |= wxDATAVIEW_CELL_SELECTED; - - // TODO: it would be much more efficient to create a clipping - // region for the entire column being rendered (in the OnPaint - // of wxDataViewMainWindow) instead of a single clip region for - // each cell. However it would mean that each renderer should - // respect the given wxRect's top & bottom coords, eventually - // violating only the left & right coords - however the user can - // make its own renderer and thus we cannot be sure of that. - wxDCClipper clip(dc, item_rect); - - cell->WXCallRender(item_rect, &dc, state); - } - - cell_rect.x += cell_rect.width; - } -} - - -void wxDataViewMainWindow::DrawCellBackground( wxDataViewRenderer* cell, wxDC& dc, const wxRect& rect ) -{ - wxRect rectBg( rect ); - - // don't overlap the horizontal rules - if ( m_owner->HasFlag(wxDV_HORIZ_RULES) ) - { - rectBg.x++; - rectBg.width--; - } - - // don't overlap the vertical rules - if ( m_owner->HasFlag(wxDV_VERT_RULES) ) - { - rectBg.y++; - rectBg.height--; - } - - cell->RenderBackground(&dc, rectBg); -} - -void wxDataViewMainWindow::OnRenameTimer() -{ - // We have to call this here because changes may just have - // been made and no screen update taken place. - if ( m_dirty ) - { - // TODO: use wxTheApp->SafeYieldFor(NULL, wxEVT_CATEGORY_UI) instead - // (needs to be tested!) - wxSafeYield(); - } - - wxDataViewItem item = GetItemByRow( m_currentRow ); - - StartEditing( item, m_currentCol ); -} - -void -wxDataViewMainWindow::StartEditing(const wxDataViewItem& item, - const wxDataViewColumn* col) -{ - wxDataViewRenderer* renderer = col->GetRenderer(); - if ( !IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) ) - return; - - const wxRect itemRect = GetItemRect(item, col); - if ( renderer->StartEditing(item, itemRect) ) - { - // Save the renderer to be able to finish/cancel editing it later and - // save the control to be able to detect if we're still editing it. - m_editorRenderer = renderer; - m_editorCtrl = renderer->GetEditorCtrl(); - } -} - -void wxDataViewMainWindow::FinishEditing() -{ - if ( m_editorCtrl ) - { - m_editorRenderer->FinishEditing(); - } -} - -void wxDataViewHeaderWindow::FinishEditing() -{ - wxDataViewMainWindow *win = static_cast(GetOwner()->GetMainWindow()); - win->FinishEditing(); -} - -//----------------------------------------------------------------------------- -// Helper class for do operation on the tree node -//----------------------------------------------------------------------------- -class DoJob -{ -public: - DoJob() { } - virtual ~DoJob() { } - - // The return value control how the tree-walker tranverse the tree - enum - { - DONE, // Job done, stop traversing and return - SKIP_SUBTREE, // Ignore the current node's subtree and continue - CONTINUE // Job not done, continue - }; - - virtual int operator() ( wxDataViewTreeNode * node ) = 0; -}; - -bool Walker( wxDataViewTreeNode * node, DoJob & func ) -{ - wxCHECK_MSG( node, false, "can't walk NULL node" ); - - switch( func( node ) ) - { - case DoJob::DONE: - return true; - case DoJob::SKIP_SUBTREE: - return false; - case DoJob::CONTINUE: - break; - } - - if ( node->HasChildren() ) - { - const wxDataViewTreeNodes& nodes = node->GetChildNodes(); - - for ( wxDataViewTreeNodes::const_iterator i = nodes.begin(); - i != nodes.end(); - ++i ) - { - if ( Walker(*i, func) ) - return true; - } - } - - return false; -} - -bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item) -{ - if (IsVirtualList()) - { - wxDataViewVirtualListModel *list_model = - (wxDataViewVirtualListModel*) GetModel(); - m_count = list_model->GetCount(); - } - else - { - SortPrepare(); - - wxDataViewTreeNode *parentNode = FindNode(parent); - - if ( !parentNode ) - return false; - - wxDataViewItemArray modelSiblings; - GetModel()->GetChildren(parent, modelSiblings); - const int modelSiblingsSize = modelSiblings.size(); - - int posInModel = modelSiblings.Index(item, /*fromEnd=*/true); - wxCHECK_MSG( posInModel != wxNOT_FOUND, false, "adding non-existent item?" ); - - wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item); - itemNode->SetHasChildren(GetModel()->IsContainer(item)); - - parentNode->SetHasChildren(true); - - const wxDataViewTreeNodes& nodeSiblings = parentNode->GetChildNodes(); - const int nodeSiblingsSize = nodeSiblings.size(); - - int nodePos = 0; - - if ( posInModel == modelSiblingsSize - 1 ) - { - nodePos = nodeSiblingsSize; - } - else if ( modelSiblingsSize == nodeSiblingsSize + 1 ) - { - // This is the simple case when our node tree already matches the - // model and only this one item is missing. - nodePos = posInModel; - } - else - { - // It's possible that a larger discrepancy between the model and - // our realization exists. This can happen e.g. when adding a bunch - // of items to the model and then calling ItemsAdded() just once - // afterwards. In this case, we must find the right position by - // looking at sibling items. - - // append to the end if we won't find a better position: - nodePos = nodeSiblingsSize; - - for ( int nextItemPos = posInModel + 1; - nextItemPos < modelSiblingsSize; - nextItemPos++ ) - { - int nextNodePos = parentNode->FindChildByItem(modelSiblings[nextItemPos]); - if ( nextNodePos != wxNOT_FOUND ) - { - nodePos = nextNodePos; - break; - } - } - } - - parentNode->ChangeSubTreeCount(+1); - parentNode->InsertChild(itemNode, nodePos); - - m_count = -1; - } - - GetOwner()->InvalidateColBestWidths(); - UpdateDisplay(); - - return true; -} - -bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, - const wxDataViewItem& item) -{ - if (IsVirtualList()) - { - wxDataViewVirtualListModel *list_model = - (wxDataViewVirtualListModel*) GetModel(); - m_count = list_model->GetCount(); - - if ( !m_selection.empty() ) - { - const int row = GetRowByItem(item); - - int rowIndexInSelection = wxNOT_FOUND; - - const size_t selCount = m_selection.size(); - for ( size_t i = 0; i < selCount; i++ ) - { - if ( m_selection[i] == (unsigned)row ) - rowIndexInSelection = i; - else if ( m_selection[i] > (unsigned)row ) - m_selection[i]--; - } - - if ( rowIndexInSelection != wxNOT_FOUND ) - m_selection.RemoveAt(rowIndexInSelection); - } - - } - else // general case - { - wxDataViewTreeNode *parentNode = FindNode(parent); - - // Notice that it is possible that the item being deleted is not in the - // tree at all, for example we could be deleting a never shown (because - // collapsed) item in a tree model. So it's not an error if we don't know - // about this item, just return without doing anything then. - if ( !parentNode ) - return true; - - wxCHECK_MSG( parentNode->HasChildren(), false, "parent node doesn't have children?" ); - const wxDataViewTreeNodes& parentsChildren = parentNode->GetChildNodes(); - - // We can't use FindNode() to find 'item', because it was already - // removed from the model by the time ItemDeleted() is called, so we - // have to do it manually. We keep track of its position as well for - // later use. - int itemPosInNode = 0; - wxDataViewTreeNode *itemNode = NULL; - for ( wxDataViewTreeNodes::const_iterator i = parentsChildren.begin(); - i != parentsChildren.end(); - ++i, ++itemPosInNode ) - { - if( (*i)->GetItem() == item ) - { - itemNode = *i; - break; - } - } - - // If the parent wasn't expanded, it's possible that we didn't have a - // node corresponding to 'item' and so there's nothing left to do. - if ( !itemNode ) - { - // If this was the last child to be removed, it's possible the parent - // node became a leaf. Let's ask the model about it. - if ( parentNode->GetChildNodes().empty() ) - parentNode->SetHasChildren(GetModel()->IsContainer(parent)); - - return true; - } - - // Delete the item from wxDataViewTreeNode representation: - const int itemsDeleted = 1 + itemNode->GetSubTreeCount(); - - parentNode->RemoveChild(itemNode); - delete itemNode; - parentNode->ChangeSubTreeCount(-itemsDeleted); - - // Make the row number invalid and get a new valid one when user call GetRowCount - m_count = -1; - - // If this was the last child to be removed, it's possible the parent - // node became a leaf. Let's ask the model about it. - if ( parentNode->GetChildNodes().empty() ) - { - bool isContainer = GetModel()->IsContainer(parent); - parentNode->SetHasChildren(isContainer); - if ( isContainer ) - { - // If it's still a container, make sure we show "+" icon for it - // and not "-" one as there is nothing to collapse any more. - if ( parentNode->IsOpen() ) - parentNode->ToggleOpen(); - } - } - - // Update selection by removing 'item' and its entire children tree from the selection. - if ( !m_selection.empty() ) - { - // we can't call GetRowByItem() on 'item', as it's already deleted, so compute it from - // the parent ('parentNode') and position in its list of children - int itemRow; - if ( itemPosInNode == 0 ) - { - // 1st child, row number is that of the parent parentNode + 1 - itemRow = GetRowByItem(parentNode->GetItem()) + 1; - } - else - { - // row number is that of the sibling above 'item' + its subtree if any + 1 - const wxDataViewTreeNode *siblingNode = parentNode->GetChildNodes()[itemPosInNode - 1]; - - itemRow = GetRowByItem(siblingNode->GetItem()) + - siblingNode->GetSubTreeCount() + - 1; - } - - wxDataViewSelection newsel(wxDataViewSelectionCmp); - - const size_t numSelections = m_selection.size(); - for ( size_t i = 0; i < numSelections; ++i ) - { - const int s = m_selection[i]; - if ( s < itemRow ) - newsel.push_back(s); - else if ( s >= itemRow + itemsDeleted ) - newsel.push_back(s - itemsDeleted); - // else: deleted item, remove from selection - } - - m_selection = newsel; - } - } - - // Change the current row to the last row if the current exceed the max row number - if ( m_currentRow >= GetRowCount() ) - ChangeCurrentRow(m_count - 1); - - GetOwner()->InvalidateColBestWidths(); - UpdateDisplay(); - - return true; -} - -bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item) -{ - SortPrepare(); - g_model->Resort(); - - GetOwner()->InvalidateColBestWidths(); - - // Send event - wxWindow *parent = GetParent(); - wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId()); - le.SetEventObject(parent); - le.SetModel(GetModel()); - le.SetItem(item); - parent->ProcessWindowEvent(le); - - return true; -} - -bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int model_column ) -{ - int view_column = m_owner->GetModelColumnIndex(model_column); - if ( view_column == wxNOT_FOUND ) - return false; - - // NOTE: to be valid, we cannot use e.g. INT_MAX - 1 -/*#define MAX_VIRTUAL_WIDTH 100000 - - wxRect rect( 0, row*m_lineHeight, MAX_VIRTUAL_WIDTH, m_lineHeight ); - m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - Refresh( true, &rect ); - - return true; -*/ - SortPrepare(); - g_model->Resort(); - - GetOwner()->InvalidateColBestWidth(view_column); - - // Send event - wxWindow *parent = GetParent(); - wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId()); - le.SetEventObject(parent); - le.SetModel(GetModel()); - le.SetItem(item); - le.SetColumn(view_column); - le.SetDataViewColumn(GetOwner()->GetColumn(view_column)); - parent->ProcessWindowEvent(le); - - return true; -} - -bool wxDataViewMainWindow::Cleared() -{ - DestroyTree(); - m_selection.Clear(); - m_currentRow = (unsigned)-1; - - if (GetModel()) - { - SortPrepare(); - BuildTree( GetModel() ); - } - else - { - m_count = 0; - } - - GetOwner()->InvalidateColBestWidths(); - UpdateDisplay(); - - return true; -} - -void wxDataViewMainWindow::UpdateDisplay() -{ - m_dirty = true; - m_underMouse = NULL; -} - -void wxDataViewMainWindow::OnInternalIdle() -{ - wxWindow::OnInternalIdle(); - - if (m_dirty) - { - RecalculateDisplay(); - m_dirty = false; - } -} - -void wxDataViewMainWindow::RecalculateDisplay() -{ - wxDataViewModel *model = GetModel(); - if (!model) - { - Refresh(); - return; - } - - int width = GetEndOfLastCol(); - int height = GetLineStart( GetRowCount() ); - - SetVirtualSize( width, height ); - GetOwner()->SetScrollRate( 10, m_lineHeight ); - - Refresh(); -} - -void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) -{ - m_underMouse = NULL; - - wxWindow::ScrollWindow( dx, dy, rect ); - - if (GetOwner()->m_headerArea) - GetOwner()->m_headerArea->ScrollWindow( dx, 0 ); -} - -void wxDataViewMainWindow::ScrollTo( int rows, int column ) -{ - m_underMouse = NULL; - - int x, y; - m_owner->GetScrollPixelsPerUnit( &x, &y ); - int sy = GetLineStart( rows )/y; - int sx = -1; - if( column != -1 ) - { - wxRect rect = GetClientRect(); - int colnum = 0; - int x_start, w = 0; - int xx, yy, xe; - m_owner->CalcUnscrolledPosition( rect.x, rect.y, &xx, &yy ); - for (x_start = 0; colnum < column; colnum++) - { - wxDataViewColumn *col = GetOwner()->GetColumnAt(colnum); - if (col->IsHidden()) - continue; // skip it! - - w = col->GetWidth(); - x_start += w; - } - - int x_end = x_start + w; - xe = xx + rect.width; - if( x_end > xe ) - { - sx = ( xx + x_end - xe )/x; - } - if( x_start < xx ) - { - sx = x_start/x; - } - } - m_owner->Scroll( sx, sy ); -} - -int wxDataViewMainWindow::GetCountPerPage() const -{ - wxSize size = GetClientSize(); - return size.y / m_lineHeight; -} - -int wxDataViewMainWindow::GetEndOfLastCol() const -{ - int width = 0; - unsigned int i; - for (i = 0; i < GetOwner()->GetColumnCount(); i++) - { - const wxDataViewColumn *c = - const_cast(GetOwner())->GetColumnAt( i ); - - if (!c->IsHidden()) - width += c->GetWidth(); - } - return width; -} - -unsigned int wxDataViewMainWindow::GetFirstVisibleRow() const -{ - int x = 0; - int y = 0; - m_owner->CalcUnscrolledPosition( x, y, &x, &y ); - - return GetLineAt( y ); -} - -unsigned int wxDataViewMainWindow::GetLastVisibleRow() -{ - wxSize client_size = GetClientSize(); - m_owner->CalcUnscrolledPosition( client_size.x, client_size.y, - &client_size.x, &client_size.y ); - - // we should deal with the pixel here - unsigned int row = GetLineAt(client_size.y) - 1; - - return wxMin( GetRowCount()-1, row ); -} - -unsigned int wxDataViewMainWindow::GetRowCount() const -{ - if ( m_count == -1 ) - { - wxDataViewMainWindow* const - self = const_cast(this); - self->m_count = RecalculateCount(); - self->UpdateDisplay(); - } - return m_count; -} - -void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row ) -{ - m_currentRow = row; - - // send event -} - -void wxDataViewMainWindow::SelectAllRows( bool on ) -{ - if (IsEmpty()) - return; - - if (on) - { - m_selection.Clear(); - for (unsigned int i = 0; i < GetRowCount(); i++) - m_selection.Add( i ); - Refresh(); - } - else - { - unsigned int first_visible = GetFirstVisibleRow(); - unsigned int last_visible = GetLastVisibleRow(); - unsigned int i; - for (i = 0; i < m_selection.GetCount(); i++) - { - unsigned int row = m_selection[i]; - if ((row >= first_visible) && (row <= last_visible)) - RefreshRow( row ); - } - m_selection.Clear(); - } -} - -void wxDataViewMainWindow::SelectRow( unsigned int row, bool on ) -{ - if (m_selection.Index( row ) == wxNOT_FOUND) - { - if (on) - { - m_selection.Add( row ); - RefreshRow( row ); - } - } - else - { - if (!on) - { - m_selection.Remove( row ); - RefreshRow( row ); - } - } -} - -void wxDataViewMainWindow::SelectRows( unsigned int from, unsigned int to, bool on ) -{ - if (from > to) - { - unsigned int tmp = from; - from = to; - to = tmp; - } - - unsigned int i; - for (i = from; i <= to; i++) - { - if (m_selection.Index( i ) == wxNOT_FOUND) - { - if (on) - m_selection.Add( i ); - } - else - { - if (!on) - m_selection.Remove( i ); - } - } - RefreshRows( from, to ); -} - -void wxDataViewMainWindow::Select( const wxArrayInt& aSelections ) -{ - for (size_t i=0; i < aSelections.GetCount(); i++) - { - int n = aSelections[i]; - - m_selection.Add( n ); - RefreshRow( n ); - } -} - -void wxDataViewMainWindow::ReverseRowSelection( unsigned int row ) -{ - if (m_selection.Index( row ) == wxNOT_FOUND) - m_selection.Add( row ); - else - m_selection.Remove( row ); - RefreshRow( row ); -} - -bool wxDataViewMainWindow::IsRowSelected( unsigned int row ) -{ - return (m_selection.Index( row ) != wxNOT_FOUND); -} - -void wxDataViewMainWindow::SendSelectionChangedEvent( const wxDataViewItem& item) -{ - wxWindow *parent = GetParent(); - wxDataViewEvent le(wxEVT_DATAVIEW_SELECTION_CHANGED, parent->GetId()); - - le.SetEventObject(parent); - le.SetModel(GetModel()); - le.SetItem( item ); - - parent->ProcessWindowEvent(le); -} - -void wxDataViewMainWindow::RefreshRow( unsigned int row ) -{ - wxRect rect( 0, GetLineStart( row ), GetEndOfLastCol(), GetLineHeight( row ) ); - m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - - wxSize client_size = GetClientSize(); - wxRect client_rect( 0, 0, client_size.x, client_size.y ); - wxRect intersect_rect = client_rect.Intersect( rect ); - if (intersect_rect.width > 0) - Refresh( true, &intersect_rect ); -} - -void wxDataViewMainWindow::RefreshRows( unsigned int from, unsigned int to ) -{ - if (from > to) - { - unsigned int tmp = to; - to = from; - from = tmp; - } - - wxRect rect( 0, GetLineStart( from ), GetEndOfLastCol(), GetLineStart( (to-from+1) ) ); - m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - - wxSize client_size = GetClientSize(); - wxRect client_rect( 0, 0, client_size.x, client_size.y ); - wxRect intersect_rect = client_rect.Intersect( rect ); - if (intersect_rect.width > 0) - Refresh( true, &intersect_rect ); -} - -void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow ) -{ - wxSize client_size = GetClientSize(); - int start = GetLineStart( firstRow ); - m_owner->CalcScrolledPosition( start, 0, &start, NULL ); - if (start > client_size.y) return; - - wxRect rect( 0, start, client_size.x, client_size.y - start ); - - Refresh( true, &rect ); -} - -wxRect wxDataViewMainWindow::GetLineRect( unsigned int row ) const -{ - wxRect rect; - rect.x = 0; - rect.y = GetLineStart( row ); - rect.width = GetEndOfLastCol(); - rect.height = GetLineHeight( row ); - - return rect; -} - -int wxDataViewMainWindow::GetLineStart( unsigned int row ) const -{ - const wxDataViewModel *model = GetModel(); - - if (GetOwner()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) - { - // TODO make more efficient - - int start = 0; - - unsigned int r; - for (r = 0; r < row; r++) - { - const wxDataViewTreeNode* node = GetTreeNodeByRow(r); - if (!node) return start; - - wxDataViewItem item = node->GetItem(); - - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int col; - int height = m_lineHeight; - for (col = 0; col < cols; col++) - { - const wxDataViewColumn *column = GetOwner()->GetColumn(col); - if (column->IsHidden()) - continue; // skip it! - - if ((col != 0) && - model->IsContainer(item) && - !model->HasContainerColumns(item)) - continue; // skip it! - - wxDataViewRenderer *renderer = - const_cast(column->GetRenderer()); - renderer->PrepareForItem(model, item, column->GetModelColumn()); - - height = wxMax( height, renderer->GetSize().y ); - } - - start += height; - } - - return start; - } - else - { - return row * m_lineHeight; - } -} - -int wxDataViewMainWindow::GetLineAt( unsigned int y ) const -{ - const wxDataViewModel *model = GetModel(); - - // check for the easy case first - if ( !GetOwner()->HasFlag(wxDV_VARIABLE_LINE_HEIGHT) ) - return y / m_lineHeight; - - // TODO make more efficient - unsigned int row = 0; - unsigned int yy = 0; - for (;;) - { - const wxDataViewTreeNode* node = GetTreeNodeByRow(row); - if (!node) - { - // not really correct... - return row + ((y-yy) / m_lineHeight); - } - - wxDataViewItem item = node->GetItem(); - - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int col; - int height = m_lineHeight; - for (col = 0; col < cols; col++) - { - const wxDataViewColumn *column = GetOwner()->GetColumn(col); - if (column->IsHidden()) - continue; // skip it! - - if ((col != 0) && - model->IsContainer(item) && - !model->HasContainerColumns(item)) - continue; // skip it! - - wxDataViewRenderer *renderer = - const_cast(column->GetRenderer()); - renderer->PrepareForItem(model, item, column->GetModelColumn()); - - height = wxMax( height, renderer->GetSize().y ); - } - - yy += height; - if (y < yy) - return row; - - row++; - } -} - -int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const -{ - const wxDataViewModel *model = GetModel(); - - if (GetOwner()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) - { - wxASSERT( !IsVirtualList() ); - - const wxDataViewTreeNode* node = GetTreeNodeByRow(row); - // wxASSERT( node ); - if (!node) return m_lineHeight; - - wxDataViewItem item = node->GetItem(); - - int height = m_lineHeight; - - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int col; - for (col = 0; col < cols; col++) - { - const wxDataViewColumn *column = GetOwner()->GetColumn(col); - if (column->IsHidden()) - continue; // skip it! - - if ((col != 0) && - model->IsContainer(item) && - !model->HasContainerColumns(item)) - continue; // skip it! - - wxDataViewRenderer *renderer = - const_cast(column->GetRenderer()); - renderer->PrepareForItem(model, item, column->GetModelColumn()); - - height = wxMax( height, renderer->GetSize().y ); - } - - return height; - } - else - { - return m_lineHeight; - } -} - - -class RowToTreeNodeJob: public DoJob -{ -public: - RowToTreeNodeJob( unsigned int row , int current, wxDataViewTreeNode * node ) - { - this->row = row; - this->current = current; - ret = NULL; - parent = node; - } - - virtual int operator() ( wxDataViewTreeNode * node ) - { - current ++; - if( current == static_cast(row)) - { - ret = node; - return DoJob::DONE; - } - - if( node->GetSubTreeCount() + current < static_cast(row) ) - { - current += node->GetSubTreeCount(); - return DoJob::SKIP_SUBTREE; - } - else - { - parent = node; - - // If the current node has only leaf children, we can find the - // desired node directly. This can speed up finding the node - // in some cases, and will have a very good effect for list views. - if ( node->HasChildren() && - (int)node->GetChildNodes().size() == node->GetSubTreeCount() ) - { - const int index = static_cast(row) - current - 1; - ret = node->GetChildNodes()[index]; - return DoJob::DONE; - } - - return DoJob::CONTINUE; - } - } - - wxDataViewTreeNode * GetResult() const - { return ret; } - -private: - unsigned int row; - int current; - wxDataViewTreeNode * ret; - wxDataViewTreeNode * parent; -}; - -wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) const -{ - wxASSERT( !IsVirtualList() ); - - if ( row == (unsigned)-1 ) - return NULL; - - RowToTreeNodeJob job( row , -2, m_root ); - Walker( m_root , job ); - return job.GetResult(); -} - -wxDataViewItem wxDataViewMainWindow::GetItemByRow(unsigned int row) const -{ - wxDataViewItem item; - if (IsVirtualList()) - { - if ( row < GetRowCount() ) - item = wxDataViewItem(wxUIntToPtr(row+1)); - } - else - { - wxDataViewTreeNode *node = GetTreeNodeByRow(row); - if ( node ) - item = node->GetItem(); - } - - return item; -} - -bool -wxDataViewMainWindow::SendExpanderEvent(wxEventType type, - const wxDataViewItem& item) -{ - wxWindow *parent = GetParent(); - wxDataViewEvent le(type, parent->GetId()); - - le.SetEventObject(parent); - le.SetModel(GetModel()); - le.SetItem( item ); - - return !parent->ProcessWindowEvent(le) || le.IsAllowed(); -} - -bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const -{ - if (IsList()) - return false; - - wxDataViewTreeNode * node = GetTreeNodeByRow(row); - if (!node) - return false; - - if (!node->HasChildren()) - return false; - - return node->IsOpen(); -} - -bool wxDataViewMainWindow::HasChildren( unsigned int row ) const -{ - if (IsList()) - return false; - - wxDataViewTreeNode * node = GetTreeNodeByRow(row); - if (!node) - return false; - - if (!node->HasChildren()) - return false; - - return true; -} - -void wxDataViewMainWindow::Expand( unsigned int row ) -{ - if (IsList()) - return; - - wxDataViewTreeNode * node = GetTreeNodeByRow(row); - if (!node) - return; - - if (!node->HasChildren()) - return; - - if (!node->IsOpen()) - { - if ( !SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDING, node->GetItem()) ) - { - // Vetoed by the event handler. - return; - } - - node->ToggleOpen(); - - // build the children of current node - if( node->GetChildNodes().empty() ) - { - SortPrepare(); - ::BuildTreeHelper(GetModel(), node->GetItem(), node); - } - - // By expanding the node all row indices that are currently in the selection list - // and are greater than our node have become invalid. So we have to correct that now. - const unsigned rowAdjustment = node->GetSubTreeCount(); - for(unsigned i=0; i row) - ChangeCurrentRow(m_currentRow + rowAdjustment); - - m_count = -1; - UpdateDisplay(); - // Send the expanded event - SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem()); - } -} - -void wxDataViewMainWindow::Collapse(unsigned int row) -{ - if (IsList()) - return; - - wxDataViewTreeNode *node = GetTreeNodeByRow(row); - if (!node) - return; - - if (!node->HasChildren()) - return; - - if (node->IsOpen()) - { - if ( !SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSING,node->GetItem()) ) - { - // Vetoed by the event handler. - return; - } - - // Find out if there are selected items below the current node. - bool selectCollapsingRow = false; - const unsigned rowAdjustment = node->GetSubTreeCount(); - unsigned maxRowToBeTested = row + rowAdjustment; - for(unsigned i=0; i row && testRow <= maxRowToBeTested) - { - selectCollapsingRow = true; - // get out as soon as we have found a node that is selected - break; - } - } - - node->ToggleOpen(); - - // If the node to be closed has selected items the user won't see those any longer. - // We select the collapsing node in this case. - if(selectCollapsingRow) - { - SelectAllRows(false); - ChangeCurrentRow(row); - SelectRow(row, true); - SendSelectionChangedEvent(GetItemByRow(row)); - } - else - { - // if there were no selected items below our node we still need to "fix" the - // selection list to adjust for the changing of the row indices. - // We actually do the opposite of what we are doing in Expand(). - for(unsigned i=0; i row && m_currentRow <= maxRowToBeTested) - ChangeCurrentRow(row); - else if(m_currentRow > row) - ChangeCurrentRow(m_currentRow - rowAdjustment); - } - - m_count = -1; - UpdateDisplay(); - SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem()); - } -} - -wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item ) -{ - const wxDataViewModel * model = GetModel(); - if( model == NULL ) - return NULL; - - if (!item.IsOk()) - return m_root; - - // Compose the parent-chain for the item we are looking for - wxVector parentChain; - wxDataViewItem it( item ); - while( it.IsOk() ) - { - parentChain.push_back(it); - it = model->GetParent(it); - } - - // Find the item along the parent-chain. - // This algorithm is designed to speed up the node-finding method - wxDataViewTreeNode* node = m_root; - for( unsigned iter = parentChain.size()-1; ; --iter ) - { - if( node->HasChildren() ) - { - if( node->GetChildNodes().empty() ) - { - // Even though the item is a container, it doesn't have any - // child nodes in the control's representation yet. We have - // to realize its subtree now. - SortPrepare(); - ::BuildTreeHelper(model, node->GetItem(), node); - } - - const wxDataViewTreeNodes& nodes = node->GetChildNodes(); - bool found = false; - - for (unsigned i = 0; i < nodes.GetCount(); ++i) - { - wxDataViewTreeNode* currentNode = nodes[i]; - if (currentNode->GetItem() == parentChain[iter]) - { - if (currentNode->GetItem() == item) - return currentNode; - - node = currentNode; - found = true; - break; - } - } - if (!found) - return NULL; - } - else - return NULL; - - if ( !iter ) - break; - } - return NULL; -} - -void wxDataViewMainWindow::HitTest( const wxPoint & point, wxDataViewItem & item, - wxDataViewColumn* &column ) -{ - wxDataViewColumn *col = NULL; - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int colnum = 0; - int x, y; - m_owner->CalcUnscrolledPosition( point.x, point.y, &x, &y ); - for (unsigned x_start = 0; colnum < cols; colnum++) - { - col = GetOwner()->GetColumnAt(colnum); - if (col->IsHidden()) - continue; // skip it! - - unsigned int w = col->GetWidth(); - if (x_start+w >= (unsigned int)x) - break; - - x_start += w; - } - - column = col; - item = GetItemByRow( GetLineAt( y ) ); -} - -wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, - const wxDataViewColumn* column ) -{ - int xpos = 0; - int width = 0; - - unsigned int cols = GetOwner()->GetColumnCount(); - // If column is null the loop will compute the combined width of all columns. - // Otherwise, it will compute the x position of the column we are looking for. - for (unsigned int i = 0; i < cols; i++) - { - wxDataViewColumn* col = GetOwner()->GetColumnAt( i ); - - if (col == column) - break; - - if (col->IsHidden()) - continue; // skip it! - - xpos += col->GetWidth(); - width += col->GetWidth(); - } - - if(column != 0) - { - // If we have a column, we need can get its width directly. - if(column->IsHidden()) - width = 0; - else - width = column->GetWidth(); - - } - else - { - // If we have no column, we reset the x position back to zero. - xpos = 0; - } - - // we have to take an expander column into account and compute its indentation - // to get the correct x position where the actual text is - int indent = 0; - int row = GetRowByItem(item); - if (!IsList() && - (column == 0 || GetExpanderColumnOrFirstOne(GetOwner()) == column) ) - { - wxDataViewTreeNode* node = GetTreeNodeByRow(row); - indent = GetOwner()->GetIndent() * node->GetIndentLevel(); - indent = indent + m_lineHeight; // use m_lineHeight as the width of the expander - } - - wxRect itemRect( xpos + indent, - GetLineStart( row ), - width - indent, - GetLineHeight( row ) ); - - GetOwner()->CalcScrolledPosition( itemRect.x, itemRect.y, - &itemRect.x, &itemRect.y ); - - return itemRect; -} - -int wxDataViewMainWindow::RecalculateCount() const -{ - if (IsVirtualList()) - { - wxDataViewVirtualListModel *list_model = - (wxDataViewVirtualListModel*) GetModel(); - - return list_model->GetCount(); - } - else - { - return m_root->GetSubTreeCount(); - } -} - -class ItemToRowJob : public DoJob -{ -public: - ItemToRowJob(const wxDataViewItem& item_, wxVector::reverse_iterator iter) - : m_iter(iter), - item(item_) - { - ret = -1; - } - - // Maybe binary search will help to speed up this process - virtual int operator() ( wxDataViewTreeNode * node) - { - ret ++; - if( node->GetItem() == item ) - { - return DoJob::DONE; - } - - if( node->GetItem() == *m_iter ) - { - m_iter++; - return DoJob::CONTINUE; - } - else - { - ret += node->GetSubTreeCount(); - return DoJob::SKIP_SUBTREE; - } - - } - - // the row number is begin from zero - int GetResult() const - { return ret -1; } - -private: - wxVector::reverse_iterator m_iter; - wxDataViewItem item; - int ret; - -}; - -int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const -{ - const wxDataViewModel * model = GetModel(); - if( model == NULL ) - return -1; - - if (IsVirtualList()) - { - return wxPtrToUInt( item.GetID() ) -1; - } - else - { - if( !item.IsOk() ) - return -1; - - // Compose the parent-chain of the item we are looking for - wxVector parentChain; - wxDataViewItem it( item ); - while( it.IsOk() ) - { - parentChain.push_back(it); - it = model->GetParent(it); - } - - // add an 'invalid' item to represent our 'invisible' root node - parentChain.push_back(wxDataViewItem()); - - // the parent chain was created by adding the deepest parent first. - // so if we want to start at the root node, we have to iterate backwards through the vector - ItemToRowJob job( item, parentChain.rbegin() ); - Walker( m_root, job ); - return job.GetResult(); - } -} - -static void BuildTreeHelper( const wxDataViewModel * model, const wxDataViewItem & item, - wxDataViewTreeNode * node) -{ - if( !model->IsContainer( item ) ) - return; - - wxDataViewItemArray children; - unsigned int num = model->GetChildren( item, children); - - for ( unsigned int index = 0; index < num; index++ ) - { - wxDataViewTreeNode *n = new wxDataViewTreeNode(node, children[index]); - - if( model->IsContainer(children[index]) ) - n->SetHasChildren( true ); - - node->InsertChild(n, index); - } - - wxASSERT( node->IsOpen() ); - node->ChangeSubTreeCount(+num); -} - -void wxDataViewMainWindow::BuildTree(wxDataViewModel * model) -{ - DestroyTree(); - - if (GetModel()->IsVirtualListModel()) - { - m_count = -1; - return; - } - - m_root = wxDataViewTreeNode::CreateRootNode(); - - // First we define a invalid item to fetch the top-level elements - wxDataViewItem item; - SortPrepare(); - BuildTreeHelper( model, item, m_root); - m_count = -1; -} - -void wxDataViewMainWindow::DestroyTree() -{ - if (!IsVirtualList()) - { - wxDELETE(m_root); - m_count = 0; - } -} - -wxDataViewColumn* -wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataViewCellMode mode) -{ - // Edit the current column editable in 'mode'. If no column is focused - // (typically because the user has full row selected), try to find the - // first editable column (this would typically be a checkbox for - // wxDATAVIEW_CELL_ACTIVATABLE and we don't want to force the user to set - // focus on the checkbox column; or on the only editable text column). - - wxDataViewColumn *candidate = m_currentCol; - - if ( candidate && - !IsCellEditableInMode(item, candidate, mode) && - !m_currentColSetByKeyboard ) - { - // If current column was set by mouse to something not editable (in - // 'mode') and the user pressed Space/F2 to edit it, treat the - // situation as if there was whole-row focus, because that's what is - // visually indicated and the mouse click could very well be targeted - // on the row rather than on an individual cell. - // - // But if it was done by keyboard, respect that even if the column - // isn't editable, because focus is visually on that column and editing - // something else would be surprising. - candidate = NULL; - } - - if ( !candidate ) - { - const unsigned cols = GetOwner()->GetColumnCount(); - for ( unsigned i = 0; i < cols; i++ ) - { - wxDataViewColumn *c = GetOwner()->GetColumnAt(i); - if ( c->IsHidden() ) - continue; - - if ( IsCellEditableInMode(item, c, mode) ) - { - candidate = c; - break; - } - } - } - - // If on container item without columns, only the expander column - // may be directly editable: - if ( candidate && - GetOwner()->GetExpanderColumn() != candidate && - GetModel()->IsContainer(item) && - !GetModel()->HasContainerColumns(item) ) - { - candidate = GetOwner()->GetExpanderColumn(); - } - - if ( !candidate ) - return NULL; - - if ( !IsCellEditableInMode(item, candidate, mode) ) - return NULL; - - return candidate; -} - -bool wxDataViewMainWindow::IsCellEditableInMode(const wxDataViewItem& item, - const wxDataViewColumn *col, - wxDataViewCellMode mode) const -{ - if ( col->GetRenderer()->GetMode() != mode ) - return false; - - if ( !GetModel()->IsEnabled(item, col->GetModelColumn()) ) - return false; - - return true; -} - -void wxDataViewMainWindow::OnCharHook(wxKeyEvent& event) -{ - if ( m_editorCtrl ) - { - // Handle any keys special for the in-place editor and return without - // calling Skip() below. - switch ( event.GetKeyCode() ) - { - case WXK_ESCAPE: - m_editorRenderer->CancelEditing(); - return; - - case WXK_RETURN: - m_editorRenderer->FinishEditing(); - return; - } - } - - event.Skip(); -} - -void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) -{ - wxWindow * const parent = GetParent(); - - // propagate the char event upwards - wxKeyEvent eventForParent(event); - eventForParent.SetEventObject(parent); - if ( parent->ProcessWindowEvent(eventForParent) ) - return; - - if ( parent->HandleAsNavigationKey(event) ) - return; - - // no item -> nothing to do - if (!HasCurrentRow()) - { - event.Skip(); - return; - } - - // don't use m_linesPerPage directly as it might not be computed yet - const int pageSize = GetCountPerPage(); - wxCHECK_RET( pageSize, wxT("should have non zero page size") ); - - switch ( event.GetKeyCode() ) - { - case WXK_RETURN: - if ( event.HasModifiers() ) - { - event.Skip(); - break; - } - else - { - // Enter activates the item, i.e. sends wxEVT_DATAVIEW_ITEM_ACTIVATED to - // it. Only if that event is not handled do we activate column renderer (which - // is normally done by Space) or even inline editing. - - const wxDataViewItem item = GetItemByRow(m_currentRow); - - wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, - parent->GetId()); - le.SetItem(item); - le.SetEventObject(parent); - le.SetModel(GetModel()); - - if ( parent->ProcessWindowEvent(le) ) - break; - // else: fall through to WXK_SPACE handling - } - - case WXK_SPACE: - if ( event.HasModifiers() ) - { - event.Skip(); - break; - } - else - { - // Space toggles activatable items or -- if not activatable -- - // starts inline editing (this is normally done using F2 on - // Windows, but Space is common everywhere else, so use it too - // for greater cross-platform compatibility). - - const wxDataViewItem item = GetItemByRow(m_currentRow); - - // Activate the current activatable column. If not column is focused (typically - // because the user has full row selected), try to find the first activatable - // column (this would typically be a checkbox and we don't want to force the user - // to set focus on the checkbox column). - wxDataViewColumn *activatableCol = FindColumnForEditing(item, wxDATAVIEW_CELL_ACTIVATABLE); - - if ( activatableCol ) - { - const unsigned colIdx = activatableCol->GetModelColumn(); - const wxRect cell_rect = GetOwner()->GetItemRect(item, activatableCol); - - wxDataViewRenderer *cell = activatableCol->GetRenderer(); - cell->PrepareForItem(GetModel(), item, colIdx); - cell->WXActivateCell(cell_rect, GetModel(), item, colIdx, NULL); - - break; - } - // else: fall through to WXK_F2 handling - } - - case WXK_F2: - if ( event.HasModifiers() ) - { - event.Skip(); - break; - } - else - { - if( !m_selection.empty() ) - { - // Mimic Windows 7 behavior: edit the item that has focus - // if it is selected and the first selected item if focus - // is out of selection. - int sel; - if ( m_selection.Index(m_currentRow) != wxNOT_FOUND ) - sel = m_currentRow; - else - sel = m_selection[0]; - - - const wxDataViewItem item = GetItemByRow(sel); - - // Edit the current column. If no column is focused - // (typically because the user has full row selected), try - // to find the first editable column. - wxDataViewColumn *editableCol = FindColumnForEditing(item, wxDATAVIEW_CELL_EDITABLE); - - if ( editableCol ) - GetOwner()->EditItem(item, editableCol); - } - } - break; - - case WXK_UP: - OnVerticalNavigation( -1, event ); - break; - - case WXK_DOWN: - OnVerticalNavigation( +1, event ); - break; - // Add the process for tree expanding/collapsing - case WXK_LEFT: - OnLeftKey(); - break; - - case WXK_RIGHT: - OnRightKey(); - break; - - case WXK_END: - OnVerticalNavigation( +(int)GetRowCount(), event ); - break; - - case WXK_HOME: - OnVerticalNavigation( -(int)GetRowCount(), event ); - break; - - case WXK_PAGEUP: - OnVerticalNavigation( -(pageSize - 1), event ); - break; - - case WXK_PAGEDOWN: - OnVerticalNavigation( +(pageSize - 1), event ); - break; - - default: - event.Skip(); - } -} - -void wxDataViewMainWindow::OnVerticalNavigation(int delta, const wxKeyEvent& event) -{ - // if there is no selection, we cannot move it anywhere - if (!HasCurrentRow() || IsEmpty()) - return; - - int newRow = (int)m_currentRow + delta; - - // let's keep the new row inside the allowed range - if ( newRow < 0 ) - newRow = 0; - - const int rowCount = (int)GetRowCount(); - if ( newRow >= rowCount ) - newRow = rowCount - 1; - - unsigned int oldCurrent = m_currentRow; - unsigned int newCurrent = (unsigned int)newRow; - - // in single selection we just ignore Shift as we can't select several - // items anyhow - if ( event.ShiftDown() && !IsSingleSel() ) - { - RefreshRow( oldCurrent ); - - ChangeCurrentRow( newCurrent ); - - // select all the items between the old and the new one - if ( oldCurrent > newCurrent ) - { - newCurrent = oldCurrent; - oldCurrent = m_currentRow; - } - - SelectRows( oldCurrent, newCurrent, true ); - if (oldCurrent!=newCurrent) - SendSelectionChangedEvent(GetItemByRow(m_selection[0])); - } - else // !shift - { - RefreshRow( oldCurrent ); - - // all previously selected items are unselected unless ctrl is held - if ( !event.ControlDown() ) - SelectAllRows(false); - - ChangeCurrentRow( newCurrent ); - - if ( !event.ControlDown() ) - { - SelectRow( m_currentRow, true ); - SendSelectionChangedEvent(GetItemByRow(m_currentRow)); - } - else - RefreshRow( m_currentRow ); - } - - GetOwner()->EnsureVisible( m_currentRow, -1 ); -} - -void wxDataViewMainWindow::OnLeftKey() -{ - if ( IsList() ) - { - TryAdvanceCurrentColumn(NULL, /*forward=*/false); - } - else - { - wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow); - if ( !node ) - return; - - if ( TryAdvanceCurrentColumn(node, /*forward=*/false) ) - return; - - // Because TryAdvanceCurrentColumn() return false, we are at the first - // column or using whole-row selection. In this situation, we can use - // the standard TreeView handling of the left key. - if (node->HasChildren() && node->IsOpen()) - { - Collapse(m_currentRow); - } - else - { - // if the node is already closed, we move the selection to its parent - wxDataViewTreeNode *parent_node = node->GetParent(); - - if (parent_node) - { - int parent = GetRowByItem( parent_node->GetItem() ); - if ( parent >= 0 ) - { - unsigned int row = m_currentRow; - SelectRow( row, false); - SelectRow( parent, true ); - ChangeCurrentRow( parent ); - GetOwner()->EnsureVisible( parent, -1 ); - SendSelectionChangedEvent( parent_node->GetItem() ); - } - } - } - } -} - -void wxDataViewMainWindow::OnRightKey() -{ - if ( IsList() ) - { - TryAdvanceCurrentColumn(NULL, /*forward=*/true); - } - else - { - wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow); - if ( !node ) - return; - - if ( node->HasChildren() ) - { - if ( !node->IsOpen() ) - { - Expand( m_currentRow ); - } - else - { - // if the node is already open, we move the selection to the first child - unsigned int row = m_currentRow; - SelectRow( row, false ); - SelectRow( row + 1, true ); - ChangeCurrentRow( row + 1 ); - GetOwner()->EnsureVisible( row + 1, -1 ); - SendSelectionChangedEvent( GetItemByRow(row+1) ); - } - } - else - { - TryAdvanceCurrentColumn(node, /*forward=*/true); - } - } -} - -bool wxDataViewMainWindow::TryAdvanceCurrentColumn(wxDataViewTreeNode *node, bool forward) -{ - if ( GetOwner()->GetColumnCount() == 0 ) - return false; - - if ( !m_useCellFocus ) - return false; - - if ( node ) - { - // navigation shouldn't work in branch nodes without other columns: - if ( node->HasChildren() && !GetModel()->HasContainerColumns(node->GetItem()) ) - return false; - } - - if ( m_currentCol == NULL || !m_currentColSetByKeyboard ) - { - if ( forward ) - { - m_currentCol = GetOwner()->GetColumnAt(1); - m_currentColSetByKeyboard = true; - RefreshRow(m_currentRow); - return true; - } - else - return false; - } - - int idx = GetOwner()->GetColumnIndex(m_currentCol) + (forward ? +1 : -1); - - if ( idx >= (int)GetOwner()->GetColumnCount() ) - return false; - - GetOwner()->EnsureVisible(m_currentRow, idx); - - if ( idx < 1 ) - { - // We are going to the left of the second column. Reset to whole-row - // focus (which means first column would be edited). - m_currentCol = NULL; - RefreshRow(m_currentRow); - return true; - } - - m_currentCol = GetOwner()->GetColumnAt(idx); - m_currentColSetByKeyboard = true; - RefreshRow(m_currentRow); - return true; -} - -void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) -{ - if (event.GetEventType() == wxEVT_MOUSEWHEEL) - { - // let the base handle mouse wheel events. - event.Skip(); - return; - } - - if(event.ButtonDown()) - { - // Not skipping button down events would prevent the system from - // setting focus to this window as most (all?) of them do by default, - // so skip it to enable default handling. - event.Skip(); - } - - int x = event.GetX(); - int y = event.GetY(); - m_owner->CalcUnscrolledPosition( x, y, &x, &y ); - wxDataViewColumn *col = NULL; - - int xpos = 0; - unsigned int cols = GetOwner()->GetColumnCount(); - unsigned int i; - for (i = 0; i < cols; i++) - { - wxDataViewColumn *c = GetOwner()->GetColumnAt( i ); - if (c->IsHidden()) - continue; // skip it! - - if (x < xpos + c->GetWidth()) - { - col = c; - break; - } - xpos += c->GetWidth(); - } - - wxDataViewModel* const model = GetModel(); - - const unsigned int current = GetLineAt( y ); - const wxDataViewItem item = GetItemByRow(current); - - // Handle right clicking here, before everything else as context menu - // events should be sent even when we click outside of any item, unlike all - // the other ones. - if (event.RightUp()) - { - wxWindow *parent = GetParent(); - wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, parent->GetId()); - le.SetEventObject(parent); - le.SetModel(model); - - if ( item.IsOk() && col ) - { - le.SetItem( item ); - le.SetColumn( col->GetModelColumn() ); - le.SetDataViewColumn( col ); - } - - parent->ProcessWindowEvent(le); - return; - } - -#if wxUSE_DRAG_AND_DROP - if (event.Dragging() || ((m_dragCount > 0) && event.Leaving())) - { - if (m_dragCount == 0) - { - // we have to report the raw, physical coords as we want to be - // able to call HitTest(event.m_pointDrag) from the user code to - // get the item being dragged - m_dragStart = event.GetPosition(); - } - - m_dragCount++; - if ((m_dragCount < 3) && (event.Leaving())) - m_dragCount = 3; - else if (m_dragCount != 3) - return; - - if (event.LeftIsDown()) - { - m_owner->CalcUnscrolledPosition( m_dragStart.x, m_dragStart.y, - &m_dragStart.x, &m_dragStart.y ); - unsigned int drag_item_row = GetLineAt( m_dragStart.y ); - wxDataViewItem itemDragged = GetItemByRow( drag_item_row ); - - // Notify cell about drag - wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() ); - event.SetEventObject( m_owner ); - event.SetItem( itemDragged ); - event.SetModel( model ); - if (!m_owner->HandleWindowEvent( event )) - return; - - if (!event.IsAllowed()) - return; - - wxDataObject *obj = event.GetDataObject(); - if (!obj) - return; - - wxDataViewDropSource drag( this, drag_item_row ); - drag.SetData( *obj ); - /* wxDragResult res = */ drag.DoDragDrop(event.GetDragFlags()); - delete obj; - } - return; - } - else - { - m_dragCount = 0; - } -#endif // wxUSE_DRAG_AND_DROP - - // Check if we clicked outside the item area. - if ((current >= GetRowCount()) || !col) - { - // Follow Windows convention here: clicking either left or right (but - // not middle) button clears the existing selection. - if (m_owner && (event.LeftDown() || event.RightDown())) - { - if (!GetSelections().empty()) - { - m_owner->UnselectAll(); - SendSelectionChangedEvent(wxDataViewItem()); - } - } - event.Skip(); - return; - } - - wxDataViewRenderer *cell = col->GetRenderer(); - wxDataViewColumn* const - expander = GetExpanderColumnOrFirstOne(GetOwner()); - - // Test whether the mouse is hovering over the expander (a.k.a tree "+" - // button) and also determine the offset of the real cell start, skipping - // the indentation and the expander itself. - bool hoverOverExpander = false; - int itemOffset = 0; - if ((!IsList()) && (expander == col)) - { - wxDataViewTreeNode * node = GetTreeNodeByRow(current); - - int indent = node->GetIndentLevel(); - itemOffset = GetOwner()->GetIndent()*indent; - - if ( node->HasChildren() ) - { - // we make the rectangle we are looking in a bit bigger than the actual - // visual expander so the user can hit that little thing reliably - wxRect rect(xpos + itemOffset, - GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2, - m_lineHeight, m_lineHeight); - - if( rect.Contains(x, y) ) - { - // So the mouse is over the expander - hoverOverExpander = true; - if (m_underMouse && m_underMouse != node) - { - // wxLogMessage("Undo the row: %d", GetRowByItem(m_underMouse->GetItem())); - RefreshRow(GetRowByItem(m_underMouse->GetItem())); - } - if (m_underMouse != node) - { - // wxLogMessage("Do the row: %d", current); - RefreshRow(current); - } - m_underMouse = node; - } - } - - // Account for the expander as well, even if this item doesn't have it, - // its parent does so it still counts for the offset. - itemOffset += m_lineHeight; - } - if (!hoverOverExpander) - { - if (m_underMouse != NULL) - { - // wxLogMessage("Undo the row: %d", GetRowByItem(m_underMouse->GetItem())); - RefreshRow(GetRowByItem(m_underMouse->GetItem())); - m_underMouse = NULL; - } - } - - bool simulateClick = false; - - if (event.ButtonDClick()) - { - m_renameTimer->Stop(); - m_lastOnSame = false; - } - - bool ignore_other_columns = - ((expander != col) && - (model->IsContainer(item)) && - (!model->HasContainerColumns(item))); - - if (event.LeftDClick()) - { - if(hoverOverExpander) - { - // a double click on the expander will be converted into a "simulated" normal click - simulateClick = true; - } - else if ( current == m_lineLastClicked ) - { - wxWindow *parent = GetParent(); - wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, parent->GetId()); - le.SetItem( item ); - le.SetColumn( col->GetModelColumn() ); - le.SetDataViewColumn( col ); - le.SetEventObject(parent); - le.SetModel(GetModel()); - - parent->ProcessWindowEvent(le); - return; - } - else - { - // The first click was on another item, so don't interpret this as - // a double click, but as a simple click instead - simulateClick = true; - } - } - - if (event.LeftUp() && !hoverOverExpander) - { - if (m_lineSelectSingleOnUp != (unsigned int)-1) - { - // select single line - SelectAllRows( false ); - SelectRow( m_lineSelectSingleOnUp, true ); - SendSelectionChangedEvent( GetItemByRow(m_lineSelectSingleOnUp) ); - } - - // If the user click the expander, we do not do editing even if the column - // with expander are editable - if (m_lastOnSame && !ignore_other_columns) - { - if ((col == m_currentCol) && (current == m_currentRow) && - IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) ) - { - m_renameTimer->Start( 100, true ); - } - } - - m_lastOnSame = false; - m_lineSelectSingleOnUp = (unsigned int)-1; - } - else if(!event.LeftUp()) - { - // This is necessary, because after a DnD operation in - // from and to ourself, the up event is swallowed by the - // DnD code. So on next non-up event (which means here and - // now) m_lineSelectSingleOnUp should be reset. - m_lineSelectSingleOnUp = (unsigned int)-1; - } - - if (event.RightDown()) - { - m_lineBeforeLastClicked = m_lineLastClicked; - m_lineLastClicked = current; - - // If the item is already selected, do not update the selection. - // Multi-selections should not be cleared if a selected item is clicked. - if (!IsRowSelected(current)) - { - SelectAllRows(false); - const unsigned oldCurrent = m_currentRow; - ChangeCurrentRow(current); - SelectRow(m_currentRow,true); - RefreshRow(oldCurrent); - SendSelectionChangedEvent(GetItemByRow( m_currentRow ) ); - } - } - else if (event.MiddleDown()) - { - } - - if((event.LeftDown() || simulateClick) && hoverOverExpander) - { - wxDataViewTreeNode* node = GetTreeNodeByRow(current); - - // hoverOverExpander being true tells us that our node must be - // valid and have children. - // So we don't need any extra checks. - if( node->IsOpen() ) - Collapse(current); - else - Expand(current); - } - else if ((event.LeftDown() || simulateClick) && !hoverOverExpander) - { - m_lineBeforeLastClicked = m_lineLastClicked; - m_lineLastClicked = current; - - unsigned int oldCurrentRow = m_currentRow; - bool oldWasSelected = IsRowSelected(m_currentRow); - - bool cmdModifierDown = event.CmdDown(); - if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) ) - { - if ( IsSingleSel() || !IsRowSelected(current) ) - { - SelectAllRows( false ); - ChangeCurrentRow(current); - SelectRow(m_currentRow,true); - SendSelectionChangedEvent(GetItemByRow( m_currentRow ) ); - } - else // multi sel & current is highlighted & no mod keys - { - m_lineSelectSingleOnUp = current; - ChangeCurrentRow(current); // change focus - } - } - else // multi sel & either ctrl or shift is down - { - if (cmdModifierDown) - { - ChangeCurrentRow(current); - ReverseRowSelection(m_currentRow); - SendSelectionChangedEvent(GetItemByRow(m_currentRow)); - } - else if (event.ShiftDown()) - { - ChangeCurrentRow(current); - - unsigned int lineFrom = oldCurrentRow, - lineTo = current; - - if ( lineFrom == static_cast(-1) ) - { - // If we hadn't had any current row before, treat this as a - // simple click and select the new row only. - lineFrom = current; - } - - if ( lineTo < lineFrom ) - { - lineTo = lineFrom; - lineFrom = m_currentRow; - } - - SelectRows(lineFrom, lineTo, true); - SendSelectionChangedEvent(GetItemByRow(m_selection[0]) ); - } - else // !ctrl, !shift - { - // test in the enclosing if should make it impossible - wxFAIL_MSG( wxT("how did we get here?") ); - } - } - - if (m_currentRow != oldCurrentRow) - RefreshRow( oldCurrentRow ); - - wxDataViewColumn *oldCurrentCol = m_currentCol; - - // Update selection here... - m_currentCol = col; - m_currentColSetByKeyboard = false; - - // This flag is used to decide whether we should start editing the item - // label. We do it if the user clicks twice (but not double clicks, - // i.e. simulateClick is false) on the same item but not if the click - // was used for something else already, e.g. selecting the item (so it - // must have been already selected) or giving the focus to the control - // (so it must have had focus already). - m_lastOnSame = !simulateClick && ((col == oldCurrentCol) && - (current == oldCurrentRow)) && oldWasSelected && - HasFocus(); - - // Call ActivateCell() after everything else as under GTK+ - if ( IsCellEditableInMode(item, col, wxDATAVIEW_CELL_ACTIVATABLE) ) - { - // notify cell about click - - wxRect cell_rect( xpos + itemOffset, - GetLineStart( current ), - col->GetWidth() - itemOffset, - GetLineHeight( current ) ); - - // Note that PrepareForItem() should be called after GetLineStart() - // call in cell_rect initialization above as GetLineStart() calls - // PrepareForItem() for other items from inside it. - cell->PrepareForItem(model, item, col->GetModelColumn()); - - // Report position relative to the cell's custom area, i.e. - // not the entire space as given by the control but the one - // used by the renderer after calculation of alignment etc. - // - // Notice that this results in negative coordinates when clicking - // in the upper left corner of a centre-aligned cell which doesn't - // fill its column entirely so this is somewhat surprising, but we - // do it like this for compatibility with the native GTK+ version, - // see #12270. - - // adjust the rectangle ourselves to account for the alignment - int align = cell->GetAlignment(); - if ( align == wxDVR_DEFAULT_ALIGNMENT ) - align = cell->GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL; - - wxRect rectItem = cell_rect; - const wxSize size = cell->GetSize(); - if ( size.x >= 0 && size.x < cell_rect.width ) - { - if ( align & wxALIGN_CENTER_HORIZONTAL ) - rectItem.x += (cell_rect.width - size.x)/2; - else if ( align & wxALIGN_RIGHT ) - rectItem.x += cell_rect.width - size.x; - // else: wxALIGN_LEFT is the default - } - - if ( size.y >= 0 && size.y < cell_rect.height ) - { - if ( align & wxALIGN_CENTER_VERTICAL ) - rectItem.y += (cell_rect.height - size.y)/2; - else if ( align & wxALIGN_BOTTOM ) - rectItem.y += cell_rect.height - size.y; - // else: wxALIGN_TOP is the default - } - - wxMouseEvent event2(event); - event2.m_x -= rectItem.x; - event2.m_y -= rectItem.y; - m_owner->CalcUnscrolledPosition(event2.m_x, event2.m_y, &event2.m_x, &event2.m_y); - - /* ignore ret */ cell->WXActivateCell - ( - cell_rect, - model, - item, - col->GetModelColumn(), - &event2 - ); - } - } -} - -void wxDataViewMainWindow::OnSetFocus( wxFocusEvent &event ) -{ - m_hasFocus = true; - - if (HasCurrentRow()) - Refresh(); - - event.Skip(); -} - -void wxDataViewMainWindow::OnKillFocus( wxFocusEvent &event ) -{ - m_hasFocus = false; - - if (HasCurrentRow()) - Refresh(); - - event.Skip(); -} - -void wxDataViewMainWindow::OnColumnsCountChanged() -{ - int editableCount = 0; - - const unsigned cols = GetOwner()->GetColumnCount(); - for ( unsigned i = 0; i < cols; i++ ) - { - wxDataViewColumn *c = GetOwner()->GetColumnAt(i); - if ( c->IsHidden() ) - continue; - if ( c->GetRenderer()->GetMode() != wxDATAVIEW_CELL_INERT ) - editableCount++; - } - - m_useCellFocus = (editableCount > 0); - - UpdateDisplay(); -} - -//----------------------------------------------------------------------------- -// wxDataViewCtrl -//----------------------------------------------------------------------------- - -WX_DEFINE_LIST(wxDataViewColumnList) - -IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase) -BEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase) - EVT_SIZE(wxDataViewCtrl::OnSize) -END_EVENT_TABLE() - -wxDataViewCtrl::~wxDataViewCtrl() -{ - if (m_notifier) - GetModel()->RemoveNotifier( m_notifier ); - - m_cols.Clear(); - m_colsBestWidths.clear(); -} - -void wxDataViewCtrl::Init() -{ - m_cols.DeleteContents(true); - m_notifier = NULL; - - // No sorting column at start - m_sortingColumnIdx = wxNOT_FOUND; - - m_headerArea = NULL; - m_clientArea = NULL; - - m_colsDirty = false; -} - -bool wxDataViewCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) -{ -// if ( (style & wxBORDER_MASK) == 0) -// style |= wxBORDER_SUNKEN; - - Init(); - - if (!wxControl::Create( parent, id, pos, size, - style | wxScrolledWindowStyle, validator, name)) - return false; - - SetInitialSize(size); - -#ifdef __WXMAC__ - MacSetClipChildren( true ); -#endif - - m_clientArea = new wxDataViewMainWindow( this, wxID_ANY ); - - // We use the cursor keys for moving the selection, not scrolling, so call - // this method to ensure wxScrollHelperEvtHandler doesn't catch all - // keyboard events forwarded to us from wxListMainWindow. - DisableKeyboardScrolling(); - - if (HasFlag(wxDV_NO_HEADER)) - m_headerArea = NULL; - else - m_headerArea = new wxDataViewHeaderWindow(this); - - SetTargetWindow( m_clientArea ); - - wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); - if (m_headerArea) - sizer->Add( m_headerArea, 0, wxGROW ); - sizer->Add( m_clientArea, 1, wxGROW ); - SetSizer( sizer ); - - return true; -} - -wxBorder wxDataViewCtrl::GetDefaultBorder() const -{ - return wxBORDER_THEME; -} - -#ifdef __WXMSW__ -WXLRESULT wxDataViewCtrl::MSWWindowProc(WXUINT nMsg, - WXWPARAM wParam, - WXLPARAM lParam) -{ - WXLRESULT rc = wxDataViewCtrlBase::MSWWindowProc(nMsg, wParam, lParam); - -#ifndef __WXWINCE__ - // we need to process arrows ourselves for scrolling - if ( nMsg == WM_GETDLGCODE ) - { - rc |= DLGC_WANTARROWS; - } -#endif - - return rc; -} -#endif - -wxSize wxDataViewCtrl::GetSizeAvailableForScrollTarget(const wxSize& size) -{ - wxSize newsize = size; - if (!HasFlag(wxDV_NO_HEADER) && (m_headerArea)) - newsize.y -= m_headerArea->GetSize().y; - - return newsize; -} - -void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - // We need to override OnSize so that our scrolled - // window a) does call Layout() to use sizers for - // positioning the controls but b) does not query - // the sizer for their size and use that for setting - // the scrollable area as set that ourselves by - // calling SetScrollbar() further down. - - Layout(); - - AdjustScrollbars(); - - // We must redraw the headers if their height changed. Normally this - // shouldn't happen as the control shouldn't let itself be resized beneath - // its minimal height but avoid the display artefacts that appear if it - // does happen, e.g. because there is really not enough vertical space. - if ( !HasFlag(wxDV_NO_HEADER) && m_headerArea && - m_headerArea->GetSize().y <= m_headerArea->GetBestSize(). y ) - { - m_headerArea->Refresh(); - } -} - -void wxDataViewCtrl::SetFocus() -{ - if (m_clientArea) - m_clientArea->SetFocus(); -} - -bool wxDataViewCtrl::SetFont(const wxFont & font) -{ - if (!wxControl::SetFont(font)) - return false; - - if (m_headerArea) - m_headerArea->SetFont(font); - - if (m_clientArea) - { - m_clientArea->SetFont(font); - m_clientArea->SetRowHeight(m_clientArea->GetDefaultRowHeight()); - } - - if (m_headerArea || m_clientArea) - { - InvalidateColBestWidths(); - Layout(); - } - - return true; -} - - - -bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model ) -{ - if (!wxDataViewCtrlBase::AssociateModel( model )) - return false; - - if (model) - { - m_notifier = new wxGenericDataViewModelNotifier( m_clientArea ); - model->AddNotifier( m_notifier ); - } - else if (m_notifier) - { - m_notifier->Cleared(); - m_notifier = NULL; - } - - m_clientArea->DestroyTree(); - - if (model) - { - m_clientArea->BuildTree(model); - } - - m_clientArea->UpdateDisplay(); - - return true; -} - -#if wxUSE_DRAG_AND_DROP - -bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format ) -{ - return m_clientArea->EnableDragSource( format ); -} - -bool wxDataViewCtrl::EnableDropTarget( const wxDataFormat &format ) -{ - return m_clientArea->EnableDropTarget( format ); -} - -#endif // wxUSE_DRAG_AND_DROP - -bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col ) -{ - if (!wxDataViewCtrlBase::AppendColumn(col)) - return false; - - m_cols.Append( col ); - m_colsBestWidths.push_back(CachedColWidthInfo()); - OnColumnsCountChanged(); - return true; -} - -bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col ) -{ - if (!wxDataViewCtrlBase::PrependColumn(col)) - return false; - - m_cols.Insert( col ); - m_colsBestWidths.insert(m_colsBestWidths.begin(), CachedColWidthInfo()); - OnColumnsCountChanged(); - return true; -} - -bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col ) -{ - if (!wxDataViewCtrlBase::InsertColumn(pos,col)) - return false; - - m_cols.Insert( pos, col ); - m_colsBestWidths.insert(m_colsBestWidths.begin() + pos, CachedColWidthInfo()); - OnColumnsCountChanged(); - return true; -} - -void wxDataViewCtrl::OnColumnChange(unsigned int idx) -{ - if ( m_headerArea ) - m_headerArea->UpdateColumn(idx); - - m_clientArea->UpdateDisplay(); -} - -void wxDataViewCtrl::OnColumnsCountChanged() -{ - if (m_headerArea) - m_headerArea->SetColumnCount(GetColumnCount()); - - m_clientArea->OnColumnsCountChanged(); -} - -void wxDataViewCtrl::DoSetExpanderColumn() -{ - wxDataViewColumn* column = GetExpanderColumn(); - if ( column ) - { - int index = GetColumnIndex(column); - if ( index != wxNOT_FOUND ) - InvalidateColBestWidth(index); - } - - m_clientArea->UpdateDisplay(); -} - -void wxDataViewCtrl::DoSetIndent() -{ - m_clientArea->UpdateDisplay(); -} - -unsigned int wxDataViewCtrl::GetColumnCount() const -{ - return m_cols.GetCount(); -} - -bool wxDataViewCtrl::SetRowHeight( int lineHeight ) -{ - if ( !m_clientArea ) - return false; - - m_clientArea->SetRowHeight(lineHeight); - - return true; -} - -wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int idx ) const -{ - return m_cols[idx]; -} - -wxDataViewColumn *wxDataViewCtrl::GetColumnAt(unsigned int pos) const -{ - // columns can't be reordered if there is no header window which allows - // to do this - const unsigned idx = m_headerArea ? m_headerArea->GetColumnsOrder()[pos] - : pos; - - return GetColumn(idx); -} - -int wxDataViewCtrl::GetColumnIndex(const wxDataViewColumn *column) const -{ - const unsigned count = m_cols.size(); - for ( unsigned n = 0; n < count; n++ ) - { - if ( m_cols[n] == column ) - return n; - } - - return wxNOT_FOUND; -} - -int wxDataViewCtrl::GetModelColumnIndex( unsigned int model_column ) const -{ - const int count = GetColumnCount(); - for ( int index = 0; index < count; index++ ) - { - wxDataViewColumn* column = GetColumn(index); - if ( column->GetModelColumn() == model_column ) - return index; - } - return wxNOT_FOUND; -} - -unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const -{ - if ( m_colsBestWidths[idx].width != 0 ) - return m_colsBestWidths[idx].width; - - const int count = m_clientArea->GetRowCount(); - wxDataViewColumn *column = GetColumn(idx); - wxDataViewRenderer *renderer = - const_cast(column->GetRenderer()); - - class MaxWidthCalculator - { - public: - MaxWidthCalculator(const wxDataViewCtrl *dvc, - wxDataViewMainWindow *clientArea, - wxDataViewRenderer *renderer, - const wxDataViewModel *model, - unsigned int model_column, - int expanderSize) - : m_width(0), - m_dvc(dvc), - m_clientArea(clientArea), - m_renderer(renderer), - m_model(model), - m_model_column(model_column), - m_expanderSize(expanderSize) - - { - int index = dvc->GetModelColumnIndex( model_column ); - wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index); - m_isExpanderCol = - !clientArea->IsList() && - (column == 0 || - GetExpanderColumnOrFirstOne(const_cast(dvc)) == column ); - } - - void UpdateWithWidth(int width) - { - m_width = wxMax(m_width, width); - } - - void UpdateWithRow(int row) - { - int indent = 0; - wxDataViewItem item; - - if ( m_isExpanderCol ) - { - wxDataViewTreeNode *node = m_clientArea->GetTreeNodeByRow(row); - item = node->GetItem(); - indent = m_dvc->GetIndent() * node->GetIndentLevel() + m_expanderSize; - } - else - { - item = m_clientArea->GetItemByRow(row); - } - - m_renderer->PrepareForItem(m_model, item, m_model_column); - m_width = wxMax(m_width, m_renderer->GetSize().x + indent); - } - - int GetMaxWidth() const { return m_width; } - - private: - int m_width; - const wxDataViewCtrl *m_dvc; - wxDataViewMainWindow *m_clientArea; - wxDataViewRenderer *m_renderer; - const wxDataViewModel *m_model; - unsigned m_model_column; - bool m_isExpanderCol; - int m_expanderSize; - }; - - MaxWidthCalculator calculator(this, m_clientArea, renderer, - GetModel(), column->GetModelColumn(), - m_clientArea->GetRowHeight()); - - calculator.UpdateWithWidth(column->GetMinWidth()); - - if ( m_headerArea ) - calculator.UpdateWithWidth(m_headerArea->GetColumnTitleWidth(*column)); - - // The code below deserves some explanation. For very large controls, we - // simply can't afford to calculate sizes for all items, it takes too - // long. So the best we can do is to check the first and the last N/2 - // items in the control for some sufficiently large N and calculate best - // sizes from that. That can result in the calculated best width being too - // small for some outliers, but it's better to get slightly imperfect - // result than to wait several seconds after every update. To avoid highly - // visible miscalculations, we also include all currently visible items - // no matter what. Finally, the value of N is determined dynamically by - // measuring how much time we spent on the determining item widths so far. - -#if wxUSE_STOPWATCH - int top_part_end = count; - static const long CALC_TIMEOUT = 20/*ms*/; - // don't call wxStopWatch::Time() too often - static const unsigned CALC_CHECK_FREQ = 100; - wxStopWatch timer; -#else - // use some hard-coded limit, that's the best we can do without timer - int top_part_end = wxMin(500, count); -#endif // wxUSE_STOPWATCH/!wxUSE_STOPWATCH - - int row = 0; - - for ( row = 0; row < top_part_end; row++ ) - { -#if wxUSE_STOPWATCH - if ( row % CALC_CHECK_FREQ == CALC_CHECK_FREQ-1 && - timer.Time() > CALC_TIMEOUT ) - break; -#endif // wxUSE_STOPWATCH - calculator.UpdateWithRow(row); - } - - // row is the first unmeasured item now; that's our value of N/2 - - if ( row < count ) - { - top_part_end = row; - - // add bottom N/2 items now: - const int bottom_part_start = wxMax(row, count - row); - for ( row = bottom_part_start; row < count; row++ ) - { - calculator.UpdateWithRow(row); - } - - // finally, include currently visible items in the calculation: - const wxPoint origin = CalcUnscrolledPosition(wxPoint(0, 0)); - int first_visible = m_clientArea->GetLineAt(origin.y); - int last_visible = m_clientArea->GetLineAt(origin.y + GetClientSize().y); - - first_visible = wxMax(first_visible, top_part_end); - last_visible = wxMin(bottom_part_start, last_visible); - - for ( row = first_visible; row < last_visible; row++ ) - { - calculator.UpdateWithRow(row); - } - - wxLogTrace("dataview", - "determined best size from %d top, %d bottom plus %d more visible items out of %d total", - top_part_end, - count - bottom_part_start, - wxMax(0, last_visible - first_visible), - count); - } - - int max_width = calculator.GetMaxWidth(); - if ( max_width > 0 ) - max_width += 2 * PADDING_RIGHTLEFT; - - const_cast(this)->m_colsBestWidths[idx].width = max_width; - return max_width; -} - -void wxDataViewCtrl::ColumnMoved(wxDataViewColumn * WXUNUSED(col), - unsigned int WXUNUSED(new_pos)) -{ - // do _not_ reorder m_cols elements here, they should always be in the - // order in which columns were added, we only display the columns in - // different order - m_clientArea->UpdateDisplay(); -} - -bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) -{ - wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column ); - if (!ret) - return false; - - m_colsBestWidths.erase(m_colsBestWidths.begin() + GetColumnIndex(column)); - m_cols.Erase(ret); - - if ( m_clientArea->GetCurrentColumn() == column ) - m_clientArea->ClearCurrentColumn(); - - OnColumnsCountChanged(); - - return true; -} - -bool wxDataViewCtrl::ClearColumns() -{ - SetExpanderColumn(NULL); - m_cols.Clear(); - m_sortingColumnIdx = wxNOT_FOUND; - m_colsBestWidths.clear(); - - m_clientArea->ClearCurrentColumn(); - - OnColumnsCountChanged(); - - return true; -} - -void wxDataViewCtrl::InvalidateColBestWidth(int idx) -{ - m_colsBestWidths[idx].width = 0; - m_colsBestWidths[idx].dirty = true; - m_colsDirty = true; -} - -void wxDataViewCtrl::InvalidateColBestWidths() -{ - // mark all columns as dirty: - m_colsBestWidths.clear(); - m_colsBestWidths.resize(m_cols.size()); - m_colsDirty = true; -} - -void wxDataViewCtrl::UpdateColWidths() -{ - m_colsDirty = false; - - if ( !m_headerArea ) - return; - - const unsigned len = m_colsBestWidths.size(); - for ( unsigned i = 0; i < len; i++ ) - { - // Note that we have to have an explicit 'dirty' flag here instead of - // checking if the width==0, as is done in GetBestColumnWidth(). - // - // Testing width==0 wouldn't work correctly if some code called - // GetWidth() after col. width invalidation but before - // wxDataViewCtrl::UpdateColWidths() was called at idle time. This - // would result in the header's column width getting out of sync with - // the control itself. - if ( m_colsBestWidths[i].dirty ) - { - m_headerArea->UpdateColumn(i); - m_colsBestWidths[i].dirty = false; - } - } -} - -void wxDataViewCtrl::OnInternalIdle() -{ - wxDataViewCtrlBase::OnInternalIdle(); - - if ( m_colsDirty ) - UpdateColWidths(); -} - -int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const -{ - unsigned int len = GetColumnCount(); - for ( unsigned int i = 0; i < len; i++ ) - { - wxDataViewColumn * col = GetColumnAt(i); - if (column==col) - return i; - } - - return wxNOT_FOUND; -} - -wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const -{ - return m_sortingColumnIdx == wxNOT_FOUND ? NULL - : GetColumn(m_sortingColumnIdx); -} - -wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const -{ - return GetItemByRow(m_clientArea->GetCurrentRow()); -} - -void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item) -{ - const int row = m_clientArea->GetRowByItem(item); - - const unsigned oldCurrent = m_clientArea->GetCurrentRow(); - if ( static_cast(row) != oldCurrent ) - { - m_clientArea->ChangeCurrentRow(row); - m_clientArea->RefreshRow(oldCurrent); - m_clientArea->RefreshRow(row); - } -} - -wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const -{ - return m_clientArea->GetCurrentColumn(); -} - -int wxDataViewCtrl::GetSelectedItemsCount() const -{ - return m_clientArea->GetSelections().size(); -} - -int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const -{ - sel.Empty(); - const wxDataViewSelection& selections = m_clientArea->GetSelections(); - - const size_t len = selections.size(); - for ( size_t i = 0; i < len; i++ ) - { - wxDataViewItem item = m_clientArea->GetItemByRow(selections[i]); - if ( item.IsOk() ) - { - sel.Add(item); - } - else - { - wxFAIL_MSG( "invalid item in selection - bad internal state" ); - } - } - - return sel.size(); -} - -void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) -{ - wxDataViewSelection selection(wxDataViewSelectionCmp); - - wxDataViewItem last_parent; - - int len = sel.GetCount(); - for( int i = 0; i < len; i ++ ) - { - wxDataViewItem item = sel[i]; - wxDataViewItem parent = GetModel()->GetParent( item ); - if (parent) - { - if (parent != last_parent) - ExpandAncestors(item); - } - - last_parent = parent; - int row = m_clientArea->GetRowByItem( item ); - if( row >= 0 ) - selection.Add( static_cast(row) ); - } - - m_clientArea->SetSelections( selection ); -} - -void wxDataViewCtrl::Select( const wxDataViewItem & item ) -{ - ExpandAncestors( item ); - - int row = m_clientArea->GetRowByItem( item ); - if( row >= 0 ) - { - // Unselect all rows before select another in the single select mode - if (m_clientArea->IsSingleSel()) - m_clientArea->SelectAllRows(false); - - m_clientArea->SelectRow(row, true); - - // Also set focus to the selected item - m_clientArea->ChangeCurrentRow( row ); - } -} - -void wxDataViewCtrl::Unselect( const wxDataViewItem & item ) -{ - int row = m_clientArea->GetRowByItem( item ); - if( row >= 0 ) - m_clientArea->SelectRow(row, false); -} - -bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const -{ - int row = m_clientArea->GetRowByItem( item ); - if( row >= 0 ) - { - return m_clientArea->IsRowSelected(row); - } - return false; -} - -void wxDataViewCtrl::SetAlternateRowColour(const wxColour& colour) -{ - m_alternateRowColour = colour; -} - -void wxDataViewCtrl::SelectAll() -{ - m_clientArea->SelectAllRows(true); -} - -void wxDataViewCtrl::UnselectAll() -{ - m_clientArea->SelectAllRows(false); -} - -void wxDataViewCtrl::EnsureVisible( int row, int column ) -{ - if( row < 0 ) - row = 0; - if( row > (int) m_clientArea->GetRowCount() ) - row = m_clientArea->GetRowCount(); - - int first = m_clientArea->GetFirstVisibleRow(); - int last = m_clientArea->GetLastVisibleRow(); - if( row < first ) - m_clientArea->ScrollTo( row, column ); - else if( row > last ) - m_clientArea->ScrollTo( row - last + first, column ); - else - m_clientArea->ScrollTo( first, column ); -} - -void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column ) -{ - ExpandAncestors( item ); - - m_clientArea->RecalculateDisplay(); - - int row = m_clientArea->GetRowByItem(item); - if( row >= 0 ) - { - if( column == NULL ) - EnsureVisible(row, -1); - else - EnsureVisible( row, GetColumnIndex(column) ); - } - -} - -void wxDataViewCtrl::HitTest( const wxPoint & point, wxDataViewItem & item, - wxDataViewColumn* &column ) const -{ - m_clientArea->HitTest(point, item, column); -} - -wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item, - const wxDataViewColumn* column ) const -{ - return m_clientArea->GetItemRect(item, column); -} - -wxDataViewItem wxDataViewCtrl::GetItemByRow( unsigned int row ) const -{ - return m_clientArea->GetItemByRow( row ); -} - -int wxDataViewCtrl::GetRowByItem( const wxDataViewItem & item ) const -{ - return m_clientArea->GetRowByItem( item ); -} - -void wxDataViewCtrl::Expand( const wxDataViewItem & item ) -{ - ExpandAncestors( item ); - - int row = m_clientArea->GetRowByItem( item ); - if (row != -1) - { - m_clientArea->Expand(row); - InvalidateColBestWidths(); - } -} - -void wxDataViewCtrl::Collapse( const wxDataViewItem & item ) -{ - int row = m_clientArea->GetRowByItem( item ); - if (row != -1) - { - m_clientArea->Collapse(row); - InvalidateColBestWidths(); - } -} - -bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const -{ - int row = m_clientArea->GetRowByItem( item ); - if (row != -1) - return m_clientArea->IsExpanded(row); - return false; -} - -void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) -{ - wxCHECK_RET( item.IsOk(), "invalid item" ); - wxCHECK_RET( column, "no column provided" ); - - m_clientArea->StartEditing(item, column); -} - -#endif // !wxUSE_GENERICDATAVIEWCTRL - -#endif // wxUSE_DATAVIEWCTRL diff --git a/Source/3rd Party/wx/src/generic/datectlg.cpp b/Source/3rd Party/wx/src/generic/datectlg.cpp deleted file mode 100644 index 6ea3d01c4..000000000 --- a/Source/3rd Party/wx/src/generic/datectlg.cpp +++ /dev/null @@ -1,484 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/datectlg.cpp -// Purpose: generic wxDatePickerCtrlGeneric implementation -// Author: Andreas Pflug -// Modified by: -// Created: 2005-01-19 -// Copyright: (c) 2005 Andreas Pflug -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DATEPICKCTRL - -#ifndef WX_PRECOMP - #include "wx/dialog.h" - #include "wx/dcmemory.h" - #include "wx/intl.h" - #include "wx/panel.h" - #include "wx/textctrl.h" - #include "wx/valtext.h" -#endif - -#include "wx/calctrl.h" -#include "wx/combo.h" - -#include "wx/datectrl.h" -#include "wx/generic/datectrl.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - - -// ---------------------------------------------------------------------------- -// global variables -// ---------------------------------------------------------------------------- - - -// ---------------------------------------------------------------------------- -// local classes -// ---------------------------------------------------------------------------- - -class wxCalendarComboPopup : public wxCalendarCtrl, - public wxComboPopup -{ -public: - - wxCalendarComboPopup() : wxCalendarCtrl(), - wxComboPopup() - { - } - - virtual void Init() - { - } - - // NB: Don't create lazily since it didn't work that way before - // wxComboCtrl was used, and changing behaviour would almost - // certainly introduce new bugs. - virtual bool Create(wxWindow* parent) - { - if ( !wxCalendarCtrl::Create(parent, wxID_ANY, wxDefaultDateTime, - wxPoint(0, 0), wxDefaultSize, - wxCAL_SEQUENTIAL_MONTH_SELECTION - | wxCAL_SHOW_HOLIDAYS | wxBORDER_SUNKEN) ) - return false; - - SetFormat(GetLocaleDateFormat()); - - m_useSize = wxCalendarCtrl::GetBestSize(); - - wxWindow* tx = m_combo->GetTextCtrl(); - if ( !tx ) - tx = m_combo; - - tx->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(wxCalendarComboPopup::OnKillTextFocus), - NULL, this); - - return true; - } - - virtual wxSize GetAdjustedSize(int WXUNUSED(minWidth), - int WXUNUSED(prefHeight), - int WXUNUSED(maxHeight)) - { - return m_useSize; - } - - virtual wxWindow *GetControl() { return this; } - - void SetDateValue(const wxDateTime& date) - { - if ( date.IsValid() ) - { - m_combo->SetText(date.Format(m_format)); - SetDate(date); - } - else // invalid date - { - wxASSERT_MSG( HasDPFlag(wxDP_ALLOWNONE), - wxT("this control must have a valid date") ); - - m_combo->SetText(wxEmptyString); - } - } - - bool IsTextEmpty() const - { - return m_combo->GetTextCtrl()->IsEmpty(); - } - - bool ParseDateTime(const wxString& s, wxDateTime* pDt) - { - wxASSERT(pDt); - - if ( !s.empty() ) - { - pDt->ParseFormat(s, m_format); - if ( !pDt->IsValid() ) - return false; - } - - return true; - } - - void SendDateEvent(const wxDateTime& dt) - { - // Sends both wxCalendarEvent and wxDateEvent - wxWindow* datePicker = m_combo->GetParent(); - - wxCalendarEvent cev(datePicker, dt, wxEVT_CALENDAR_SEL_CHANGED); - datePicker->GetEventHandler()->ProcessEvent(cev); - - wxDateEvent event(datePicker, dt, wxEVT_DATE_CHANGED); - datePicker->GetEventHandler()->ProcessEvent(event); - } - -private: - - void OnCalKey(wxKeyEvent & ev) - { - if (ev.GetKeyCode() == WXK_ESCAPE && !ev.HasModifiers()) - Dismiss(); - else - ev.Skip(); - } - - void OnSelChange(wxCalendarEvent &ev) - { - m_combo->SetText(GetDate().Format(m_format)); - - if ( ev.GetEventType() == wxEVT_CALENDAR_DOUBLECLICKED ) - { - Dismiss(); - } - - SendDateEvent(GetDate()); - } - - void OnKillTextFocus(wxFocusEvent &ev) - { - ev.Skip(); - - const wxDateTime& dtOld = GetDate(); - - wxDateTime dt; - wxString value = m_combo->GetValue(); - if ( !ParseDateTime(value, &dt) ) - { - if ( !HasDPFlag(wxDP_ALLOWNONE) ) - dt = dtOld; - } - - m_combo->SetText(GetStringValueFor(dt)); - - if ( !dt.IsValid() && HasDPFlag(wxDP_ALLOWNONE) ) - return; - - // notify that we had to change the date after validation - if ( (dt.IsValid() && (!dtOld.IsValid() || dt != dtOld)) || - (!dt.IsValid() && dtOld.IsValid()) ) - { - SetDate(dt); - SendDateEvent(dt); - } - } - - bool HasDPFlag(int flag) const - { - return m_combo->GetParent()->HasFlag(flag); - } - - // Return the format to be used for the dates shown by the control. This - // functions honours wxDP_SHOWCENTURY flag. - wxString GetLocaleDateFormat() const - { -#if wxUSE_INTL - wxString fmt = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT); - if ( HasDPFlag(wxDP_SHOWCENTURY) ) - fmt.Replace("%y", "%Y"); - - return fmt; -#else // !wxUSE_INTL - return wxT("x"); -#endif // wxUSE_INTL/!wxUSE_INTL - } - - bool SetFormat(const wxString& fmt) - { - m_format = fmt; - - if ( m_combo ) - { - wxArrayString allowedChars; - for ( wxChar c = wxT('0'); c <= wxT('9'); c++ ) - allowedChars.Add(wxString(c, 1)); - - const wxChar *p2 = m_format.c_str(); - while ( *p2 ) - { - if ( *p2 == '%') - p2 += 2; - else - allowedChars.Add(wxString(*p2++, 1)); - } - - #if wxUSE_VALIDATORS - wxTextValidator tv(wxFILTER_INCLUDE_CHAR_LIST); - tv.SetIncludes(allowedChars); - m_combo->SetValidator(tv); - #endif - - if ( GetDate().IsValid() ) - m_combo->SetText(GetDate().Format(m_format)); - } - - return true; - } - - virtual void SetStringValue(const wxString& s) - { - wxDateTime dt; - if ( !s.empty() && ParseDateTime(s, &dt) ) - SetDate(dt); - //else: keep the old value - } - - virtual wxString GetStringValue() const - { - return GetStringValueFor(GetDate()); - } - -private: - // returns either the given date representation using the current format or - // an empty string if it's invalid - wxString GetStringValueFor(const wxDateTime& dt) const - { - wxString val; - if ( dt.IsValid() ) - val = dt.Format(m_format); - - return val; - } - - wxSize m_useSize; - wxString m_format; - - DECLARE_EVENT_TABLE() -}; - - -BEGIN_EVENT_TABLE(wxCalendarComboPopup, wxCalendarCtrl) - EVT_KEY_DOWN(wxCalendarComboPopup::OnCalKey) - EVT_CALENDAR_SEL_CHANGED(wxID_ANY, wxCalendarComboPopup::OnSelChange) - EVT_CALENDAR_PAGE_CHANGED(wxID_ANY, wxCalendarComboPopup::OnSelChange) - EVT_CALENDAR(wxID_ANY, wxCalendarComboPopup::OnSelChange) -END_EVENT_TABLE() - - -// ============================================================================ -// wxDatePickerCtrlGeneric implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase) - EVT_TEXT(wxID_ANY, wxDatePickerCtrlGeneric::OnText) - EVT_SIZE(wxDatePickerCtrlGeneric::OnSize) - EVT_SET_FOCUS(wxDatePickerCtrlGeneric::OnFocus) -END_EVENT_TABLE() - -#ifndef wxHAS_NATIVE_DATEPICKCTRL - IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxControl) -#endif - -// ---------------------------------------------------------------------------- -// creation -// ---------------------------------------------------------------------------- - -bool wxDatePickerCtrlGeneric::Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) -{ - wxASSERT_MSG( !(style & wxDP_SPIN), - wxT("wxDP_SPIN style not supported, use wxDP_DEFAULT") ); - - if ( !wxControl::Create(parent, id, pos, size, - style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxBORDER_NONE, - validator, name) ) - { - return false; - } - - InheritAttributes(); - - m_combo = new wxComboCtrl(this, -1, wxEmptyString, - wxDefaultPosition, wxDefaultSize); - - m_combo->SetCtrlMainWnd(this); - - m_popup = new wxCalendarComboPopup(); - -#if defined(__WXMSW__) - // without this keyboard navigation in month control doesn't work - m_combo->UseAltPopupWindow(); -#endif - m_combo->SetPopupControl(m_popup); - - m_popup->SetDateValue(date.IsValid() ? date : wxDateTime::Today()); - - SetInitialSize(size); - - return true; -} - - -void wxDatePickerCtrlGeneric::Init() -{ - m_combo = NULL; - m_popup = NULL; -} - -wxDatePickerCtrlGeneric::~wxDatePickerCtrlGeneric() -{ -} - -bool wxDatePickerCtrlGeneric::Destroy() -{ - if ( m_combo ) - m_combo->Destroy(); - - m_combo = NULL; - m_popup = NULL; - - return wxControl::Destroy(); -} - -// ---------------------------------------------------------------------------- -// overridden base class methods -// ---------------------------------------------------------------------------- - -wxSize wxDatePickerCtrlGeneric::DoGetBestSize() const -{ - // A better solution would be to use a custom text control that would have - // the best size determined by the current date format and let m_combo take - // care of the best size computation, but this isn't easily possible with - // wxComboCtrl currently, so we compute our own best size here instead even - // if this means adding some extra margins to account for text control - // borders, space between it and the button and so on. - wxSize size = m_combo->GetButtonSize(); - - wxTextCtrl* const text = m_combo->GetTextCtrl(); - size.x += text->GetTextExtent(text->GetValue()).x; - size.x += 2*text->GetCharWidth(); // This is the margin mentioned above. - - return size; -} - -wxWindowList wxDatePickerCtrlGeneric::GetCompositeWindowParts() const -{ - wxWindowList parts; - parts.push_back(m_combo); - parts.push_back(m_popup); - return parts; -} - -// ---------------------------------------------------------------------------- -// wxDatePickerCtrlGeneric API -// ---------------------------------------------------------------------------- - -bool -wxDatePickerCtrlGeneric::SetDateRange(const wxDateTime& lowerdate, - const wxDateTime& upperdate) -{ - return m_popup->SetDateRange(lowerdate, upperdate); -} - - -wxDateTime wxDatePickerCtrlGeneric::GetValue() const -{ - if ( HasFlag(wxDP_ALLOWNONE) && m_popup->IsTextEmpty() ) - return wxInvalidDateTime; - return m_popup->GetDate(); -} - - -void wxDatePickerCtrlGeneric::SetValue(const wxDateTime& date) -{ - m_popup->SetDateValue(date); -} - - -bool wxDatePickerCtrlGeneric::GetRange(wxDateTime *dt1, wxDateTime *dt2) const -{ - return m_popup->GetDateRange(dt1, dt2); -} - - -void -wxDatePickerCtrlGeneric::SetRange(const wxDateTime &dt1, const wxDateTime &dt2) -{ - m_popup->SetDateRange(dt1, dt2); -} - -wxCalendarCtrl *wxDatePickerCtrlGeneric::GetCalendar() const -{ - return m_popup; -} - -// ---------------------------------------------------------------------------- -// event handlers -// ---------------------------------------------------------------------------- - - -void wxDatePickerCtrlGeneric::OnSize(wxSizeEvent& event) -{ - if ( m_combo ) - m_combo->SetSize(GetClientSize()); - - event.Skip(); -} - - -void wxDatePickerCtrlGeneric::OnText(wxCommandEvent &ev) -{ - ev.SetEventObject(this); - ev.SetId(GetId()); - GetParent()->GetEventHandler()->ProcessEvent(ev); - - // We'll create an additional event if the date is valid. - // If the date isn't valid, the user's probably in the middle of typing - wxDateTime dt; - if ( !m_popup || !m_popup->ParseDateTime(m_combo->GetValue(), &dt) ) - return; - - m_popup->SendDateEvent(dt); -} - - -void wxDatePickerCtrlGeneric::OnFocus(wxFocusEvent& WXUNUSED(event)) -{ - m_combo->SetFocus(); -} - - -#endif // wxUSE_DATEPICKCTRL - diff --git a/Source/3rd Party/wx/src/generic/dbgrptg.cpp b/Source/3rd Party/wx/src/generic/dbgrptg.cpp deleted file mode 100644 index 99416162c..000000000 --- a/Source/3rd Party/wx/src/generic/dbgrptg.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/dbgrptg.cpp -// Purpose: implementation of wxDebugReportPreviewStd -// Author: Vadim Zeitlin, Andrej Putrin -// Modified by: -// Created: 2005-01-21 -// Copyright: (c) 2005 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DEBUGREPORT && wxUSE_XML - -#include "wx/debugrpt.h" - -#ifndef WX_PRECOMP - #include "wx/sizer.h" - #include "wx/checklst.h" - #include "wx/textctrl.h" - #include "wx/intl.h" - #include "wx/stattext.h" - #include "wx/filedlg.h" - #include "wx/valtext.h" - #include "wx/button.h" -#endif // WX_PRECOMP - -#include "wx/filename.h" -#ifdef wxUSE_FFILE - #include "wx/ffile.h" -#else - #include "wx/file.h" -#endif -#include "wx/mimetype.h" - -#include "wx/statline.h" - -#ifdef __WXMSW__ - #include "wx/evtloop.h" // for SetCriticalWindow() - #include "wx/scopeguard.h" -#endif // __WXMSW__ - -// ---------------------------------------------------------------------------- -// wxDumpPreviewDlg: simple class for showing ASCII preview of dump files -// ---------------------------------------------------------------------------- - -class wxDumpPreviewDlg : public wxDialog -{ -public: - wxDumpPreviewDlg(wxWindow *parent, - const wxString& title, - const wxString& text); - -private: - // the text we show - wxTextCtrl *m_text; - - wxDECLARE_NO_COPY_CLASS(wxDumpPreviewDlg); -}; - -wxDumpPreviewDlg::wxDumpPreviewDlg(wxWindow *parent, - const wxString& title, - const wxString& text) - : wxDialog(parent, wxID_ANY, title, - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) -{ - // create controls - // --------------- - - // use wxTE_RICH2 style to avoid 64kB limit under MSW and display big files - // faster than with wxTE_RICH - m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, - wxPoint(0, 0), wxDefaultSize, - wxTE_MULTILINE | - wxTE_READONLY | - wxTE_NOHIDESEL | - wxTE_RICH2); - m_text->SetValue(text); - - // use fixed-width font - m_text->SetFont(wxFont(12, wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); - - wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("Close")); - - - // layout them - // ----------- - - wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL), - *sizerBtns = new wxBoxSizer(wxHORIZONTAL); - - sizerBtns->Add(btnClose, 0, 0, 1); - - sizerTop->Add(m_text, 1, wxEXPAND); - sizerTop->Add(sizerBtns, 0, wxALIGN_RIGHT | wxTOP | wxBOTTOM | wxRIGHT, 1); - - // set the sizer &c - // ---------------- - - // make the text window bigger to show more contents of the file - sizerTop->SetItemMinSize(m_text, 600, 300); - SetSizer(sizerTop); - - Layout(); - Fit(); - - m_text->SetFocus(); -} - -// ---------------------------------------------------------------------------- -// wxDumpOpenExternalDlg: choose a command for opening the given file -// ---------------------------------------------------------------------------- - -class wxDumpOpenExternalDlg : public wxDialog -{ -public: - wxDumpOpenExternalDlg(wxWindow *parent, const wxFileName& filename); - - // return the command chosed by user to open this file - const wxString& GetCommand() const { return m_command; } - - wxString m_command; - -private: - -#if wxUSE_FILEDLG - void OnBrowse(wxCommandEvent& event); -#endif // wxUSE_FILEDLG - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxDumpOpenExternalDlg); -}; - -BEGIN_EVENT_TABLE(wxDumpOpenExternalDlg, wxDialog) - -#if wxUSE_FILEDLG - EVT_BUTTON(wxID_MORE, wxDumpOpenExternalDlg::OnBrowse) -#endif - -END_EVENT_TABLE() - - -wxDumpOpenExternalDlg::wxDumpOpenExternalDlg(wxWindow *parent, - const wxFileName& filename) - : wxDialog(parent, - wxID_ANY, - wxString::Format - ( - _("Open file \"%s\""), - filename.GetFullPath().c_str() - )) -{ - // create controls - // --------------- - - wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); - sizerTop->Add(new wxStaticText(this, wxID_ANY, - wxString::Format - ( - _("Enter command to open file \"%s\":"), - filename.GetFullName().c_str() - )), - wxSizerFlags().Border()); - - wxSizer *sizerH = new wxBoxSizer(wxHORIZONTAL); - - wxTextCtrl *command = new wxTextCtrl - ( - this, - wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxSize(250, wxDefaultCoord), - 0 -#if wxUSE_VALIDATORS - ,wxTextValidator(wxFILTER_NONE, &m_command) -#endif - ); - sizerH->Add(command, - wxSizerFlags(1).Align(wxALIGN_CENTER_VERTICAL)); - -#if wxUSE_FILEDLG - - wxButton *browse = new wxButton(this, wxID_MORE, wxT(">>"), - wxDefaultPosition, wxDefaultSize, - wxBU_EXACTFIT); - sizerH->Add(browse, - wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL). Border(wxLEFT)); - -#endif // wxUSE_FILEDLG - - sizerTop->Add(sizerH, wxSizerFlags(0).Expand().Border()); - - sizerTop->Add(new wxStaticLine(this), wxSizerFlags().Expand().Border()); - - sizerTop->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), - wxSizerFlags().Align(wxALIGN_RIGHT).Border()); - - // set the sizer &c - // ---------------- - - SetSizer(sizerTop); - - Layout(); - Fit(); - - command->SetFocus(); -} - -#if wxUSE_FILEDLG - -void wxDumpOpenExternalDlg::OnBrowse(wxCommandEvent& ) -{ - wxFileName fname(m_command); - wxFileDialog dlg(this, - wxFileSelectorPromptStr, - fname.GetPathWithSep(), - fname.GetFullName() -#ifdef __WXMSW__ - , _("Executable files (*.exe)|*.exe|") + wxALL_FILES -#endif // __WXMSW__ - ); - if ( dlg.ShowModal() == wxID_OK ) - { - m_command = dlg.GetPath(); - TransferDataToWindow(); - } -} - -#endif // wxUSE_FILEDLG - -// ---------------------------------------------------------------------------- -// wxDebugReportDialog: class showing debug report to the user -// ---------------------------------------------------------------------------- - -class wxDebugReportDialog : public wxDialog -{ -public: - wxDebugReportDialog(wxDebugReport& dbgrpt); - - virtual bool TransferDataToWindow(); - virtual bool TransferDataFromWindow(); - -private: - void OnView(wxCommandEvent& ); - void OnViewUpdate(wxUpdateUIEvent& ); - void OnOpen(wxCommandEvent& ); - - - // small helper: add wxEXPAND and wxALL flags - static wxSizerFlags SizerFlags(int proportion) - { - return wxSizerFlags(proportion).Expand().Border(); - } - - - wxDebugReport& m_dbgrpt; - - wxCheckListBox *m_checklst; - wxTextCtrl *m_notes; - - wxArrayString m_files; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxDebugReportDialog); -}; - -// ============================================================================ -// wxDebugReportDialog implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxDebugReportDialog, wxDialog) - EVT_BUTTON(wxID_VIEW_DETAILS, wxDebugReportDialog::OnView) - EVT_UPDATE_UI(wxID_VIEW_DETAILS, wxDebugReportDialog::OnViewUpdate) - EVT_BUTTON(wxID_OPEN, wxDebugReportDialog::OnOpen) - EVT_UPDATE_UI(wxID_OPEN, wxDebugReportDialog::OnViewUpdate) -END_EVENT_TABLE() - - -// ---------------------------------------------------------------------------- -// construction -// ---------------------------------------------------------------------------- - -wxDebugReportDialog::wxDebugReportDialog(wxDebugReport& dbgrpt) - : wxDialog(NULL, wxID_ANY, - wxString::Format(_("Debug report \"%s\""), - dbgrpt.GetReportName().c_str()), - wxDefaultPosition, - wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), - m_dbgrpt(dbgrpt) -{ - // upper part of the dialog: explanatory message - wxString msg; - wxString debugDir = dbgrpt.GetDirectory(); - - // The temporary directory can be the short form on Windows; - // normalize it for the benefit of users. -#ifdef __WXMSW__ - wxFileName debugDirFilename(debugDir, wxEmptyString); - debugDirFilename.Normalize(wxPATH_NORM_LONG); - debugDir = debugDirFilename.GetPath(); -#endif - msg << _("A debug report has been generated in the directory\n") - << wxT('\n') - << wxT(" \"") << debugDir << wxT("\"\n") - << wxT('\n') - << _("The report contains the files listed below. If any of these files contain private information,\nplease uncheck them and they will be removed from the report.\n") - << wxT('\n') - << _("If you wish to suppress this debug report completely, please choose the \"Cancel\" button,\nbut be warned that it may hinder improving the program, so if\nat all possible please do continue with the report generation.\n") - << wxT('\n') - << _(" Thank you and we're sorry for the inconvenience!\n") - << wxT("\n\n"); // just some white space to separate from other stuff - - const wxSizerFlags flagsFixed(SizerFlags(0)); - const wxSizerFlags flagsExpand(SizerFlags(1)); - const wxSizerFlags flagsExpand2(SizerFlags(2)); - - wxSizer *sizerPreview = - new wxStaticBoxSizer(wxVERTICAL, this, _("&Debug report preview:")); - sizerPreview->Add(CreateTextSizer(msg), SizerFlags(0).Centre()); - - // ... and the list of files in this debug report with buttons to view them - wxSizer *sizerFileBtns = new wxBoxSizer(wxVERTICAL); - sizerFileBtns->AddStretchSpacer(1); - sizerFileBtns->Add(new wxButton(this, wxID_VIEW_DETAILS, _("&View...")), - wxSizerFlags().Border(wxBOTTOM)); - sizerFileBtns->Add(new wxButton(this, wxID_OPEN, _("&Open...")), - wxSizerFlags().Border(wxTOP)); - sizerFileBtns->AddStretchSpacer(1); - - m_checklst = new wxCheckListBox(this, wxID_ANY); - - wxSizer *sizerFiles = new wxBoxSizer(wxHORIZONTAL); - sizerFiles->Add(m_checklst, flagsExpand); - sizerFiles->Add(sizerFileBtns, flagsFixed); - - sizerPreview->Add(sizerFiles, flagsExpand2); - - - // lower part of the dialog: notes field - wxSizer *sizerNotes = new wxStaticBoxSizer(wxVERTICAL, this, _("&Notes:")); - - msg = _("If you have any additional information pertaining to this bug\nreport, please enter it here and it will be joined to it:"); - - m_notes = new wxTextCtrl(this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE); - - sizerNotes->Add(CreateTextSizer(msg), flagsFixed); - sizerNotes->Add(m_notes, flagsExpand); - - - wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); - sizerTop->Add(sizerPreview, flagsExpand2); - sizerTop->AddSpacer(5); - sizerTop->Add(sizerNotes, flagsExpand); - sizerTop->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), flagsFixed); - - SetSizerAndFit(sizerTop); - Layout(); - CentreOnScreen(); -} - -// ---------------------------------------------------------------------------- -// data exchange -// ---------------------------------------------------------------------------- - -bool wxDebugReportDialog::TransferDataToWindow() -{ - // all files are included in the report by default - const size_t count = m_dbgrpt.GetFilesCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxString name, - desc; - if ( m_dbgrpt.GetFile(n, &name, &desc) ) - { - m_checklst->Append(name + wxT(" (") + desc + wxT(')')); - m_checklst->Check(n); - - m_files.Add(name); - } - } - - return true; -} - -bool wxDebugReportDialog::TransferDataFromWindow() -{ - // any unchecked files should be removed from the report - const size_t count = m_checklst->GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - if ( !m_checklst->IsChecked(n) ) - { - m_dbgrpt.RemoveFile(m_files[n]); - } - } - - // if the user entered any notes, add them to the report - const wxString notes = m_notes->GetValue(); - if ( !notes.empty() ) - { - // for now filename fixed, could make it configurable in the future... - m_dbgrpt.AddText(wxT("notes.txt"), notes, wxT("user notes")); - } - - return true; -} - -// ---------------------------------------------------------------------------- -// event handlers -// ---------------------------------------------------------------------------- - -void wxDebugReportDialog::OnView(wxCommandEvent& ) -{ - const int sel = m_checklst->GetSelection(); - wxCHECK_RET( sel != wxNOT_FOUND, wxT("invalid selection in OnView()") ); - - wxFileName fn(m_dbgrpt.GetDirectory(), m_files[sel]); - wxString str; - - const wxString& fullPath = fn.GetFullPath(); -#if wxUSE_FFILE - wxFFile file(fullPath); -#elif wxUSE_FILE - wxFile file(fullPath); -#endif - if ( file.IsOpened() && file.ReadAll(&str) ) - { - wxDumpPreviewDlg dlg(this, m_files[sel], str); - dlg.ShowModal(); - } -} - -void wxDebugReportDialog::OnOpen(wxCommandEvent& ) -{ - const int sel = m_checklst->GetSelection(); - wxCHECK_RET( sel != wxNOT_FOUND, wxT("invalid selection in OnOpen()") ); - - wxFileName fn(m_dbgrpt.GetDirectory(), m_files[sel]); - - // try to get the command to open this kind of files ourselves - wxString command; -#if wxUSE_MIMETYPE - wxFileType * - ft = wxTheMimeTypesManager->GetFileTypeFromExtension(fn.GetExt()); - if ( ft ) - { - command = ft->GetOpenCommand(fn.GetFullPath()); - delete ft; - } -#endif // wxUSE_MIMETYPE - - // if we couldn't, ask the user - if ( command.empty() ) - { - wxDumpOpenExternalDlg dlg(this, fn); - if ( dlg.ShowModal() == wxID_OK ) - { - // get the command chosen by the user and append file name to it - - // if we don't have place marker for file name in the command... - wxString cmd = dlg.GetCommand(); - if ( !cmd.empty() ) - { -#if wxUSE_MIMETYPE - if ( cmd.find(wxT('%')) != wxString::npos ) - { - command = wxFileType::ExpandCommand(cmd, fn.GetFullPath()); - } - else // no %s nor %1 -#endif // wxUSE_MIMETYPE - { - // append the file name to the end - command << cmd << wxT(" \"") << fn.GetFullPath() << wxT('"'); - } - } - } - } - - if ( !command.empty() ) - ::wxExecute(command); -} - -void wxDebugReportDialog::OnViewUpdate(wxUpdateUIEvent& event) -{ - int sel = m_checklst->GetSelection(); - if (sel >= 0) - { - wxFileName fn(m_dbgrpt.GetDirectory(), m_files[sel]); - event.Enable(fn.FileExists()); - } - else - event.Enable(false); -} - - -// ============================================================================ -// wxDebugReportPreviewStd implementation -// ============================================================================ - -bool wxDebugReportPreviewStd::Show(wxDebugReport& dbgrpt) const -{ - if ( !dbgrpt.GetFilesCount() ) - return false; - - wxDebugReportDialog dlg(dbgrpt); - -#ifdef __WXMSW__ - // before entering the event loop (from ShowModal()), block the event - // handling for all other windows as this could result in more crashes - wxEventLoop::SetCriticalWindow(&dlg); - - wxON_BLOCK_EXIT1( wxEventLoop::SetCriticalWindow, - static_cast(NULL) ); -#endif // __WXMSW__ - - return dlg.ShowModal() == wxID_OK && dbgrpt.GetFilesCount() != 0; -} - -#endif // wxUSE_DEBUGREPORT && wxUSE_XML diff --git a/Source/3rd Party/wx/src/generic/dcpsg.cpp b/Source/3rd Party/wx/src/generic/dcpsg.cpp index 2ac80da99..f19e75d66 100644 --- a/Source/3rd Party/wx/src/generic/dcpsg.cpp +++ b/Source/3rd Party/wx/src/generic/dcpsg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart, Robert Roebling, Markus Holzhem // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: dcpsg.cpp 55927 2008-09-28 09:12:16Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,9 +32,11 @@ #include "wx/prntbase.h" #include "wx/generic/prntdlgg.h" #include "wx/paper.h" -#include "wx/filename.h" +#include "wx/filefn.h" #include "wx/stdpaths.h" +WXDLLIMPEXP_DATA_CORE(int) wxPageNumber; + #ifdef __WXMSW__ #ifdef DrawText @@ -189,7 +192,7 @@ static const char *wxPostScriptHeaderColourImage = "\ } ifelse % end of 'false' case\n\ "; -static const char wxPostScriptHeaderReencodeISO1[] = +static char wxPostScriptHeaderReencodeISO1[] = "\n/reencodeISO {\n" "dup dup findfont dup length dict begin\n" "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n" @@ -213,7 +216,7 @@ static const char wxPostScriptHeaderReencodeISO1[] = "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n" "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n"; -static const char wxPostScriptHeaderReencodeISO2[] = +static char wxPostScriptHeaderReencodeISO2[] = "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n" "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n" "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n" @@ -234,85 +237,25 @@ static const char wxPostScriptHeaderReencodeISO2[] = // wxPostScriptDC //------------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC) -wxPostScriptDC::wxPostScriptDC() - : wxDC(new wxPostScriptDCImpl(this)) +float wxPostScriptDC::ms_PSScaleFactor = 1.0; + +void wxPostScriptDC::SetResolution(int ppi) { + ms_PSScaleFactor = (float)ppi / 72.0; } -wxPostScriptDC::wxPostScriptDC(const wxPrintData& printData) - : wxDC(new wxPostScriptDCImpl(this, printData)) +int wxPostScriptDC::GetResolution() { + return (int)(ms_PSScaleFactor * 72.0); } -// conversion -static const double RAD2DEG = 180.0 / M_PI; - -// we don't want to use only 72 dpi from PS print -static const int DPI = 600; -static const double PS2DEV = 600.0 / 72.0; -static const double DEV2PS = 72.0 / 600.0; - -#define XLOG2DEV(x) ((double)(LogicalToDeviceX(x)) * DEV2PS) -#define XLOG2DEVREL(x) ((double)(LogicalToDeviceXRel(x)) * DEV2PS) -#define YLOG2DEV(x) ((m_pageHeight - (double)LogicalToDeviceY(x)) * DEV2PS) -#define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS) - - -IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDCImpl, wxDCImpl) - //------------------------------------------------------------------------------- -wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC *owner ) : - wxDCImpl( owner ) +wxPostScriptDC::wxPostScriptDC () { - Init(); - - m_pageHeight = 842 * PS2DEV; - - m_ok = true; -} - -wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data ) : - wxDCImpl( owner ) -{ - Init(); - - // this calculates m_pageHeight required for - // taking the inverted Y axis into account - SetPrintData( data ); - - m_ok = true; -} - - -wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC *owner ) : - wxDCImpl( owner ) -{ - Init(); - - m_pageHeight = 842 * PS2DEV; - - m_ok = true; -} - -wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data ) : - wxDCImpl( owner ) -{ - Init(); - - // this calculates m_pageHeight required for - // taking the inverted Y axis into account - SetPrintData( data ); - - m_ok = true; -} - -void wxPostScriptDCImpl::Init() -{ - m_pstream = NULL; + m_pstream = (FILE*) NULL; m_currentRed = 0; m_currentGreen = 0; @@ -325,67 +268,71 @@ void wxPostScriptDCImpl::Init() m_underlinePosition = 0.0; m_underlineThickness = 0.0; + m_signX = 1; // default x-axis left to right + m_signY = -1; // default y-axis bottom up -> top down } -wxPostScriptDCImpl::~wxPostScriptDCImpl () +wxPostScriptDC::wxPostScriptDC (const wxPrintData& printData) +{ + m_pstream = (FILE*) NULL; + + m_currentRed = 0; + m_currentGreen = 0; + m_currentBlue = 0; + + m_pageNumber = 0; + + m_clipping = false; + + m_underlinePosition = 0.0; + m_underlineThickness = 0.0; + + m_signX = 1; // default x-axis left to right + m_signY = -1; // default y-axis bottom up -> top down + + m_printData = printData; + + m_ok = true; +} + +wxPostScriptDC::~wxPostScriptDC () { if (m_pstream) { fclose( m_pstream ); - m_pstream = NULL; + m_pstream = (FILE*) NULL; } } -bool wxPostScriptDCImpl::IsOk() const +bool wxPostScriptDC::IsOk() const { return m_ok; } -wxRect wxPostScriptDCImpl::GetPaperRect() const -{ - int w = 0; - int h = 0; - DoGetSize( &w, &h ); - return wxRect(0,0,w,h); -} - -int wxPostScriptDCImpl::GetResolution() const -{ - return DPI; -} - -void wxPostScriptDCImpl::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxPostScriptDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h) { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); - if (m_clipping) - DestroyClippingRegion(); + if (m_clipping) DestroyClippingRegion(); - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + w; - m_clipY2 = y + h; + wxDC::DoSetClippingRegion(x, y, w, h); m_clipping = true; - wxString buffer; - buffer.Printf( "gsave\n" - "newpath\n" - "%f %f moveto\n" - "%f %f lineto\n" - "%f %f lineto\n" - "%f %f lineto\n" - "closepath clip newpath\n", - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+w), YLOG2DEV(y), - XLOG2DEV(x+w), YLOG2DEV(y+h), - XLOG2DEV(x), YLOG2DEV(y+h) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("gsave\n newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("closepath clip newpath\n"), + LogicalToDeviceX(x), LogicalToDeviceY(y), + LogicalToDeviceX(x+w), LogicalToDeviceY(y), + LogicalToDeviceX(x+w), LogicalToDeviceY(y+h), + LogicalToDeviceX(x), LogicalToDeviceY(y+h) ); } -void wxPostScriptDCImpl::DestroyClippingRegion() +void wxPostScriptDC::DestroyClippingRegion() { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); @@ -395,63 +342,61 @@ void wxPostScriptDCImpl::DestroyClippingRegion() PsPrint( "grestore\n" ); } - wxDCImpl::DestroyClippingRegion(); + wxDC::DestroyClippingRegion(); } -void wxPostScriptDCImpl::Clear() +void wxPostScriptDC::Clear() { // This should fail silently to avoid unnecessary // asserts - // wxFAIL_MSG( wxT("wxPostScriptDCImpl::Clear not implemented.") ); + // wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") ); } -bool wxPostScriptDCImpl::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), wxFloodFillStyle WXUNUSED(style)) +bool wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { - wxFAIL_MSG( wxT("wxPostScriptDCImpl::FloodFill not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") ); return false; } -bool wxPostScriptDCImpl::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const +bool wxPostScriptDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const { - wxFAIL_MSG( wxT("wxPostScriptDCImpl::GetPixel not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDC::GetPixel not implemented.") ); return false; } -void wxPostScriptDCImpl::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) +void wxPostScriptDC::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - wxFAIL_MSG( wxT("wxPostScriptDCImpl::CrossHair not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDC::CrossHair not implemented.") ); } -void wxPostScriptDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxPostScriptDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - if ( m_pen.IsTransparent() ) - return; + if (m_pen.GetStyle() == wxTRANSPARENT) return; SetPen( m_pen ); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f moveto\n" - "%f %f lineto\n" - "stroke\n", - XLOG2DEV(x1), YLOG2DEV(y1), - XLOG2DEV(x2), YLOG2DEV(y2) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("stroke\n"), + LogicalToDeviceX(x1), LogicalToDeviceY(y1), + LogicalToDeviceX(x2), LogicalToDeviceY (y2) ); CalcBoundingBox( x1, y1 ); CalcBoundingBox( x2, y2 ); } -void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) +#define RAD2DEG 57.29577951308 + +void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); wxCoord dx = x1 - xc; wxCoord dy = y1 - yc; - double radius = sqrt( (double)(dx*dx+dy*dy) ); + wxCoord radius = (wxCoord) sqrt( (double)(dx*dx+dy*dy) ); double alpha1, alpha2; if (x1 == x2 && y1 == y2) @@ -478,49 +423,40 @@ void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree while (alpha2 > 360) alpha2 -= 360; - int i_radius = wxRound( radius ); - - if ( m_brush.IsNonTransparent() ) + if (m_brush.GetStyle() != wxTRANSPARENT) { SetBrush( m_brush ); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f %f %f %f %f ellipse\n" - "%f %f lineto\n" - "closepath\n" - "fill\n", - XLOG2DEV(xc), YLOG2DEV(yc), - XLOG2DEVREL(i_radius), YLOG2DEVREL(i_radius), - alpha1, alpha2, - XLOG2DEV(xc), YLOG2DEV(yc) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d ellipse\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("fill\n"), + LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, + LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); - CalcBoundingBox( xc-i_radius, yc-i_radius ); - CalcBoundingBox( xc+i_radius, yc+i_radius ); + CalcBoundingBox( xc-radius, yc-radius ); + CalcBoundingBox( xc+radius, yc+radius ); } - if ( m_pen.IsNonTransparent() ) + if (m_pen.GetStyle() != wxTRANSPARENT) { SetPen( m_pen ); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f %f %f %f %f ellipse\n" - "stroke\n", - XLOG2DEV(xc), YLOG2DEV(yc), - XLOG2DEVREL(i_radius), YLOG2DEVREL(i_radius), - alpha1, alpha2 ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d ellipse\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("stroke\n"), + LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, + LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); - CalcBoundingBox( xc-i_radius, yc-i_radius ); - CalcBoundingBox( xc+i_radius, yc+i_radius ); + CalcBoundingBox( xc-radius, yc-radius ); + CalcBoundingBox( xc+radius, yc+radius ); } } -void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -535,97 +471,82 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord if ( wxIsSameDouble(sa, ea) ) { - DoDrawEllipse(x,y,w,h); + DrawEllipse(x,y,w,h); return; } - if ( m_brush.IsNonTransparent() ) + if (m_brush.GetStyle () != wxTRANSPARENT) { SetBrush( m_brush ); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f %f %f %f %f true ellipticarc\n", - XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), - XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), - sa, ea ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d true ellipticarc\n"), + LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), + LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), + (wxCoord)sa, (wxCoord)ea ); CalcBoundingBox( x ,y ); CalcBoundingBox( x+w, y+h ); } - if ( m_pen.IsNonTransparent() ) + if (m_pen.GetStyle () != wxTRANSPARENT) { SetPen( m_pen ); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f %f %f %f %f false ellipticarc\n", - XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), - XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), - sa, ea ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d false ellipticarc\n"), + LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), + LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), + (wxCoord)sa, (wxCoord)ea ); CalcBoundingBox( x ,y ); CalcBoundingBox( x+w, y+h ); } } -void wxPostScriptDCImpl::DoDrawPoint (wxCoord x, wxCoord y) +void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - if ( m_pen.IsTransparent() ) - return; + if (m_pen.GetStyle() == wxTRANSPARENT) return; SetPen (m_pen); - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f moveto\n" - "%f %f lineto\n" - "stroke\n", - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+1), YLOG2DEV(y) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("stroke\n"), + LogicalToDeviceX(x), LogicalToDeviceY(y), + LogicalToDeviceX(x+1), LogicalToDeviceY(y) ); CalcBoundingBox( x, y ); } -void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) +void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); if (n <= 0) return; - if ( m_brush.IsNonTransparent() ) + if (m_brush.GetStyle () != wxTRANSPARENT) { SetBrush( m_brush ); PsPrint( "newpath\n" ); - double xx = XLOG2DEV(points[0].x + xoffset); - double yy = YLOG2DEV(points[0].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[0].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[0].y + yoffset); - wxString buffer; - buffer.Printf( "%f %f moveto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), xx, yy ); CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset ); for (int i = 1; i < n; i++) { - xx = XLOG2DEV(points[i].x + xoffset); - yy = YLOG2DEV(points[i].y + yoffset); + xx = LogicalToDeviceX(points[i].x + xoffset); + yy = LogicalToDeviceY(points[i].y + yoffset); - buffer.Printf( "%f %f lineto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d lineto\n"), xx, yy ); CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset); } @@ -633,30 +554,25 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") ); } - if ( m_pen.IsNonTransparent() ) + if (m_pen.GetStyle () != wxTRANSPARENT) { SetPen( m_pen ); PsPrint( "newpath\n" ); - double xx = XLOG2DEV(points[0].x + xoffset); - double yy = YLOG2DEV(points[0].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[0].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[0].y + yoffset); - wxString buffer; - buffer.Printf( "%f %f moveto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), xx, yy ); CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset ); for (int i = 1; i < n; i++) { - xx = XLOG2DEV(points[i].x + xoffset); - yy = YLOG2DEV(points[i].y + yoffset); + xx = LogicalToDeviceX(points[i].x + xoffset); + yy = LogicalToDeviceY(points[i].y + yoffset); - buffer.Printf( "%f %f lineto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d lineto\n"), xx, yy ); CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset); } @@ -666,13 +582,13 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x } } -void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) +void wxPostScriptDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); if (n <= 0) return; - if ( m_brush.IsNonTransparent() ) + if (m_brush.GetStyle () != wxTRANSPARENT) { SetBrush( m_brush ); @@ -681,24 +597,19 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo int ofs = 0; for (int i = 0; i < n; ofs += count[i++]) { - double xx = XLOG2DEV(points[ofs].x + xoffset); - double yy = YLOG2DEV(points[ofs].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); - wxString buffer; - buffer.Printf( "%f %f moveto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), xx, yy ); CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); for (int j = 1; j < count[i]; j++) { - xx = XLOG2DEV(points[ofs+j].x + xoffset); - yy = YLOG2DEV(points[ofs+j].y + yoffset); + xx = LogicalToDeviceX(points[ofs+j].x + xoffset); + yy = LogicalToDeviceY(points[ofs+j].y + yoffset); - buffer.Printf( "%f %f lineto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d lineto\n"), xx, yy ); CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset); } @@ -706,7 +617,7 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") ); } - if ( m_pen.IsNonTransparent() ) + if (m_pen.GetStyle () != wxTRANSPARENT) { SetPen( m_pen ); @@ -715,24 +626,19 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo int ofs = 0; for (int i = 0; i < n; ofs += count[i++]) { - double xx = XLOG2DEV(points[ofs].x + xoffset); - double yy = YLOG2DEV(points[ofs].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); - wxString buffer; - buffer.Printf( "%f %f moveto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), xx, yy ); CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); for (int j = 1; j < count[i]; j++) { - xx = XLOG2DEV(points[ofs+j].x + xoffset); - yy = YLOG2DEV(points[ofs+j].y + yoffset); + xx = LogicalToDeviceX(points[ofs+j].x + xoffset); + yy = LogicalToDeviceY(points[ofs+j].y + yoffset); - buffer.Printf( "%f %f lineto\n", xx, yy ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d lineto\n"), xx, yy ); CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset); } @@ -742,12 +648,11 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo } } -void wxPostScriptDCImpl::DoDrawLines (int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - if ( m_pen.IsTransparent() ) - return; + if (m_pen.GetStyle() == wxTRANSPARENT) return; if (n <= 0) return; @@ -755,89 +660,74 @@ void wxPostScriptDCImpl::DoDrawLines (int n, const wxPoint points[], wxCoord xof int i; for ( i =0; iGetTextExtent(text, &text_w, &text_h, &text_descent); + GetTextExtent(text, &text_w, &text_h, &text_descent); + + // VZ: this seems to be unnecessary, so taking it out for now, if it + // doesn't create any problems, remove this comment entirely + //SetFont( m_font ); + int size = m_font.GetPointSize(); @@ -1368,30 +1213,29 @@ void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y // - note that there is still rounding error in text_descent! wxCoord by = y + size - text_descent; // baseline - wxString buffer; - buffer.Printf( "%f %f moveto\n", XLOG2DEV(x), YLOG2DEV(by) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), LogicalToDeviceX(x), LogicalToDeviceY(by) ); PsPrint( "(" ); - for ( const char *p = textbuf; *p != '\0'; p++ ) + const wxWX2MBbuf textbuf = text.mb_str(); + size_t len = strlen(textbuf); + size_t i; + for (i = 0; i < len; i++) { - int c = (unsigned char)*p; + int c = (unsigned char) textbuf[i]; if (c == ')' || c == '(' || c == '\\') { /* Cope with special characters */ PsPrint( "\\" ); - PsPrint( (char) c ); + PsPrint(c); } else if ( c >= 128 ) { /* Cope with character codes > 127 */ - buffer.Printf( "\\%o", c ); - PsPrint( buffer ); + PsPrintf( wxT("\\%o"), c); } else { - PsPrint( (char) c ); + PsPrint(c); } } @@ -1400,17 +1244,20 @@ void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y if (m_font.GetUnderlined()) { wxCoord uy = (wxCoord)(y + size - m_underlinePosition); + char buffer[100]; - buffer.Printf( "gsave\n" - "%f %f moveto\n" - "%f setlinewidth\n" - "%f %f lineto\n" - "stroke\n" - "grestore\n", - XLOG2DEV(x), YLOG2DEV(uy), + sprintf( buffer, + "gsave\n" + "%d %d moveto\n" + "%f setlinewidth\n" + "%d %d lineto\n" + "stroke\n" + "grestore\n", + LogicalToDeviceX(x), LogicalToDeviceY(uy), m_underlineThickness, - XLOG2DEV(x + text_w), YLOG2DEV(uy) ); - buffer.Replace( ",", "." ); + LogicalToDeviceX(x + text_w), LogicalToDeviceY(uy) ); + for (i = 0; i < 100; i++) + if (buffer[i] == ',') buffer[i] = '.'; PsPrint( buffer ); } @@ -1418,7 +1265,7 @@ void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y CalcBoundingBox( x + size * text.length() * 2/3 , y ); } -void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) +void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) { if ( wxIsNullDouble(angle) ) { @@ -1430,7 +1277,7 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC SetFont( m_font ); - if (m_textForegroundColour.IsOk()) + if (m_textForegroundColour.Ok()) { unsigned char red = m_textForegroundColour.Red(); unsigned char blue = m_textForegroundColour.Blue(); @@ -1456,9 +1303,12 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC double bluePS = (double)(blue) / 255.0; double greenPS = (double)(green) / 255.0; - wxString buffer; - buffer.Printf( "%f %f %f setrgbcolor\n", redPS, greenPS, bluePS ); - buffer.Replace( ",", "." ); + char buffer[100]; + sprintf( buffer, + "%.8f %.8f %.8f setrgbcolor\n", + redPS, greenPS, bluePS ); + for (int i = 0; i < 100; i++) + if (buffer[i] == ',') buffer[i] = '.'; PsPrint( buffer ); m_currentRed = red; @@ -1469,64 +1319,70 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC int size = m_font.GetPointSize(); - wxString buffer; - buffer.Printf( "%f %f moveto\n", XLOG2DEV(x), YLOG2DEV(y)); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d moveto\n"), + LogicalToDeviceX(x), LogicalToDeviceY(y)); - buffer.Printf( "%f rotate\n", angle ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + char buffer[100]; + sprintf(buffer, "%.8f rotate\n", angle); + size_t i; + for (i = 0; i < 100; i++) + { + if (buffer[i] == ',') buffer[i] = '.'; + } + PsPrint( buffer); PsPrint( "(" ); const wxWX2MBbuf textbuf = text.mb_str(); - if ( textbuf ) + size_t len = strlen(textbuf); + for (i = 0; i < len; i++) { - for ( const char *p = textbuf; *p != '\0'; p++ ) + int c = (unsigned char) textbuf[i]; + if (c == ')' || c == '(' || c == '\\') { - int c = (unsigned char)*p; - if (c == ')' || c == '(' || c == '\\') - { - /* Cope with special characters */ - PsPrint( "\\" ); - PsPrint( (char) c ); - } - else if ( c >= 128 ) - { - /* Cope with character codes > 127 */ - buffer.Printf( "\\%o", c); - PsPrint( buffer ); - } - else - { - PsPrint( (char) c ); - } + /* Cope with special characters */ + PsPrint( "\\" ); + PsPrint(c); + } + else if ( c >= 128 ) + { + /* Cope with character codes > 127 */ + PsPrintf( wxT("\\%o"), c); + } + else + { + PsPrint(c); } } PsPrint( ") show\n" ); - buffer.Printf( "%f rotate\n", -angle ); - buffer.Replace( ",", "." ); + sprintf( buffer, "%.8f rotate\n", -angle ); + for (i = 0; i < 100; i++) + { + if (buffer[i] == ',') buffer[i] = '.'; + } PsPrint( buffer ); if (m_font.GetUnderlined()) { wxCoord uy = (wxCoord)(y + size - m_underlinePosition); wxCoord w, h; - GetOwner()->GetTextExtent(text, &w, &h); + GetTextExtent(text, &w, &h); - buffer.Printf( + sprintf( buffer, "gsave\n" - "%f %f moveto\n" + "%d %d moveto\n" "%f setlinewidth\n" - "%f %f lineto\n" + "%d %d lineto\n" "stroke\n" "grestore\n", - XLOG2DEV(x), YLOG2DEV(uy), + LogicalToDeviceX(x), LogicalToDeviceY(uy), m_underlineThickness, - XLOG2DEV(x + w), YLOG2DEV(uy) ); - buffer.Replace( ",", "." ); + LogicalToDeviceX(x + w), LogicalToDeviceY(uy) ); + for (i = 0; i < 100; i++) + { + if (buffer[i] == ',') buffer[i] = '.'; + } PsPrint( buffer ); } @@ -1534,18 +1390,18 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC CalcBoundingBox( x + size * text.length() * 2/3 , y ); } -void wxPostScriptDCImpl::SetBackground (const wxBrush& brush) +void wxPostScriptDC::SetBackground (const wxBrush& brush) { m_backgroundBrush = brush; } -void wxPostScriptDCImpl::SetLogicalFunction(wxRasterOperationMode WXUNUSED(function)) +void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function)) { - wxFAIL_MSG( wxT("wxPostScriptDCImpl::SetLogicalFunction not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDC::SetLogicalFunction not implemented.") ); } #if wxUSE_SPLINES -void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) +void wxPostScriptDC::DoDrawSpline( wxList *points ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1556,13 +1412,13 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) double c, d, x1, y1, x2, y2, x3, y3; wxPoint *p, *q; - wxPointList::compatibility_iterator node = points->GetFirst(); - p = node->GetData(); + wxList::compatibility_iterator node = points->GetFirst(); + p = (wxPoint *)node->GetData(); x1 = p->x; y1 = p->y; node = node->GetNext(); - p = node->GetData(); + p = (wxPoint *)node->GetData(); c = p->x; d = p->y; x3 = @@ -1576,14 +1432,11 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) #endif (double)(y1 + d) / 2; - wxString buffer; - buffer.Printf( "newpath\n" - "%f %f moveto\n" - "%f %f lineto\n", - XLOG2DEV(wxRound(x1)), YLOG2DEV(wxRound(y1)), - XLOG2DEV(wxRound(x3)), YLOG2DEV(wxRound(y3)) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n"), + LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1), + LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) ); CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); @@ -1591,7 +1444,7 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) node = node->GetNext(); while (node) { - q = node->GetData(); + q = (wxPoint *)node->GetData(); x1 = x3; y1 = y3; @@ -1602,12 +1455,10 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) x3 = (double)(x2 + c) / 2; y3 = (double)(y2 + d) / 2; - buffer.Printf( "%f %f %f %f %f %f DrawSplineSection\n", - XLOG2DEV(wxRound(x1)), YLOG2DEV(wxRound(y1)), - XLOG2DEV(wxRound(x2)), YLOG2DEV(wxRound(y2)), - XLOG2DEV(wxRound(x3)), YLOG2DEV(wxRound(y3)) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d %d %d %d %d DrawSplineSection\n"), + LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1), + LogicalToDeviceX((wxCoord)x2), LogicalToDeviceY((wxCoord)y2), + LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) ); CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); @@ -1620,55 +1471,41 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) next-to-last and last point respectively, in the point list */ - buffer.Printf( "%f %f lineto\nstroke\n", XLOG2DEV(wxRound(c)), YLOG2DEV(wxRound(d)) ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); + PsPrintf( wxT("%d %d lineto\n") + wxT("stroke\n"), + LogicalToDeviceX((wxCoord)c), LogicalToDeviceY((wxCoord)d) ); } #endif // wxUSE_SPLINES -wxCoord wxPostScriptDCImpl::GetCharWidth() const +wxCoord wxPostScriptDC::GetCharWidth() const { // Chris Breeze: reasonable approximation using wxMODERN/Courier return (wxCoord) (GetCharHeight() * 72.0 / 120.0); } -void wxPostScriptDCImpl::SetPrintData(const wxPrintData& data) + +void wxPostScriptDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { - m_printData = data; + wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - wxPaperSize id = m_printData.GetPaperId(); - wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(id); - if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); - int w = 595; - int h = 842; - if (paper) - { - w = paper->GetSizeDeviceUnits().x; - h = paper->GetSizeDeviceUnits().y; - } + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? 1 : -1); - if (m_printData.GetOrientation() == wxLANDSCAPE) - m_pageHeight = w * PS2DEV; - else - m_pageHeight = h * PS2DEV; + ComputeScaleAndOrigin(); } -void wxPostScriptDCImpl::ComputeScaleAndOrigin() +void wxPostScriptDC::SetDeviceOrigin( wxCoord x, wxCoord y ) { - const wxRealPoint origScale(m_scaleX, m_scaleY); + wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - wxDCImpl::ComputeScaleAndOrigin(); + int h = 0; + int w = 0; + GetSize( &w, &h ); - // If scale has changed call SetPen to recalculate the line width - // and SetFont to recalculate font size - if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.IsOk() ) - { - SetPen( m_pen ); - SetFont( m_font ); - } + wxDC::SetDeviceOrigin( x, h-y ); } -void wxPostScriptDCImpl::DoGetSize(int* width, int* height) const +void wxPostScriptDC::DoGetSize(int* width, int* height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1691,14 +1528,11 @@ void wxPostScriptDCImpl::DoGetSize(int* width, int* height) const h = tmp; } - if (width) - *width = wxRound( w * PS2DEV ); - - if (height) - *height = wxRound( h * PS2DEV ); + if (width) *width = (int)(w * ms_PSScaleFactor); + if (height) *height = (int)(h * ms_PSScaleFactor); } -void wxPostScriptDCImpl::DoGetSizeMM(int *width, int *height) const +void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1726,13 +1560,14 @@ void wxPostScriptDCImpl::DoGetSizeMM(int *width, int *height) const } // Resolution in pixels per logical inch -wxSize wxPostScriptDCImpl::GetPPI(void) const +wxSize wxPostScriptDC::GetPPI(void) const { - return wxSize( DPI, DPI ); + return wxSize((int)(72 * ms_PSScaleFactor), + (int)(72 * ms_PSScaleFactor)); } -bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) +bool wxPostScriptDC::StartDoc( const wxString& message ) { wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") ); @@ -1740,7 +1575,7 @@ bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) { if (m_printData.GetFilename() == wxEmptyString) { - wxString filename = wxFileName::CreateTempFileName( wxT("ps") ); + wxString filename = wxGetTempFileName( wxT("ps") ); m_printData.SetFilename(filename); } @@ -1755,21 +1590,18 @@ bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) } m_ok = true; - - wxString buffer; + m_title = message; PsPrint( "%!PS-Adobe-2.0\n" ); - PsPrint( "%%Creator: wxWidgets PostScript renderer\n" ); - - buffer.Printf( "%%%%CreationDate: %s\n", wxNow() ); - PsPrint( buffer ); - + PsPrintf( wxT("%%%%CreationDate: %s\n"), wxNow().c_str() ); if (m_printData.GetOrientation() == wxLANDSCAPE) PsPrint( "%%Orientation: Landscape\n" ); else PsPrint( "%%Orientation: Portrait\n" ); + // PsPrintf( wxT("%%%%Pages: %d\n"), (wxPageNumber - 1) ); + const wxChar *paper; switch (m_printData.GetPaperId()) { @@ -1789,10 +1621,7 @@ bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) case wxPAPER_10X14: paper = wxT("10x14"); break; // 10-by-14-inch sheet default: paper = wxT("A4"); } - - buffer.Printf( "%%%%DocumentPaperSizes: %s\n", paper ); - PsPrint( buffer ); - + PsPrintf( wxT("%%%%DocumentPaperSizes: %s\n"), paper ); PsPrint( "%%EndComments\n\n" ); PsPrint( "%%BeginProlog\n" ); @@ -1814,11 +1643,12 @@ bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) // set origin according to paper size SetDeviceOrigin( 0,0 ); + wxPageNumber = 1; m_pageNumber = 1; return true; } -void wxPostScriptDCImpl::EndDoc () +void wxPostScriptDC::EndDoc () { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1830,7 +1660,7 @@ void wxPostScriptDCImpl::EndDoc () if ( m_pstream ) { fclose( m_pstream ); - m_pstream = NULL; + m_pstream = (FILE *) NULL; } #if 0 @@ -1846,10 +1676,10 @@ void wxPostScriptDCImpl::EndDoc () // Compute the bounding box. Note that it is in the default user // coordinate system, thus we have to convert the values. - wxCoord minX = (wxCoord) XLOG2DEV(m_minX); - wxCoord minY = (wxCoord) YLOG2DEV(m_minY); - wxCoord maxX = (wxCoord) XLOG2DEV(m_maxX); - wxCoord maxY = (wxCoord) YLOG2DEV(m_maxY); + wxCoord minX = (wxCoord) LogicalToDeviceX(m_minX); + wxCoord minY = (wxCoord) LogicalToDeviceY(m_minY); + wxCoord maxX = (wxCoord) LogicalToDeviceX(m_maxX); + wxCoord maxY = (wxCoord) LogicalToDeviceY(m_maxY); // LOG2DEV may have changed the minimum to maximum vice versa if ( minX > maxX ) { wxCoord tmp = minX; minX = maxX; maxX = tmp; } @@ -1918,118 +1748,100 @@ void wxPostScriptDCImpl::EndDoc () #endif } -void wxPostScriptDCImpl::StartPage() +void wxPostScriptDC::StartPage() { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - wxString buffer; - buffer.Printf( wxT("%%%%Page: %d\n"), m_pageNumber++ ); - PsPrint( buffer ); + PsPrintf( wxT("%%%%Page: %d\n"), wxPageNumber++ ); + + // What is this one supposed to do? RR. +// *m_pstream << "matrix currentmatrix\n"; + + // Added by Chris Breeze + + // Each page starts with an "initgraphics" which resets the + // transformation and so we need to reset the origin + // (and rotate the page for landscape printing) + + // Output scaling + wxCoord translate_x, translate_y; + double scale_x, scale_y; -#if 0 wxPostScriptPrintNativeData *data = (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); - wxCoord translate_x = (wxCoord)data->GetPrinterTranslateX(); - wxCoord translate_y = (wxCoord)data->GetPrinterTranslateY(); + translate_x = (wxCoord)data->GetPrinterTranslateX(); + translate_y = (wxCoord)data->GetPrinterTranslateY(); - buffer.Printf( "%d %d translate\n", translate_x, translate_y ); - PsPrint( buffer ); - - double scale_x = data->GetPrinterScaleX(); - double scale_y = data->GetPrinterScaleY(); - - buffer.Printf( "%f %f scale\n", scale_x, scale_y ); - buffer.Replace( ",", "." ); - PsPrint( buffer ); - -#endif - - // Each page starts with an "initgraphics" which resets the - // transformation and so we need to rotate the page for - // landscape printing) - - // I copied this one from a PostScript tutorial, but to no avail. RR. - // PsPrint( "90 rotate llx neg ury nef translate\n" ); + scale_x = data->GetPrinterScaleX(); + scale_y = data->GetPrinterScaleY(); if (m_printData.GetOrientation() == wxLANDSCAPE) + { + int h; + GetSize( (int*) NULL, &h ); + translate_y -= h; PsPrint( "90 rotate\n" ); + // I copied this one from a PostScript tutorial, but to no avail. RR. + // PsPrint( "90 rotate llx neg ury nef translate\n" ); + } + + char buffer[100]; + sprintf( buffer, "%.8f %.8f scale\n", scale_x / ms_PSScaleFactor, + scale_y / ms_PSScaleFactor); + for (int i = 0; i < 100; i++) + if (buffer[i] == ',') buffer[i] = '.'; + PsPrint( buffer ); + + PsPrintf( wxT("%d %d translate\n"), translate_x, translate_y ); } -void wxPostScriptDCImpl::EndPage () +void wxPostScriptDC::EndPage () { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); PsPrint( "showpage\n" ); } -bool wxPostScriptDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, +bool wxPostScriptDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord fwidth, wxCoord fheight, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop, - bool WXUNUSED(useMask), wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask) ) + int rop, bool WXUNUSED(useMask), wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask) ) { wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") ); wxCHECK_MSG( source, false, wxT("invalid source dc") ); - // blit into a bitmap + /* blit into a bitmap */ wxBitmap bitmap( (int)fwidth, (int)fheight ); wxMemoryDC memDC; memDC.SelectObject(bitmap); memDC.Blit(0, 0, fwidth, fheight, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */ memDC.SelectObject(wxNullBitmap); - //draw bitmap. scaling and positioning is done there - GetOwner()->DrawBitmap( bitmap, xdest, ydest ); + /* draw bitmap. scaling and positioning is done there */ + DrawBitmap( bitmap, xdest, ydest ); return true; } -wxCoord wxPostScriptDCImpl::GetCharHeight() const +wxCoord wxPostScriptDC::GetCharHeight() const { - if (m_font.IsOk()) + if (m_font.Ok()) return m_font.GetPointSize(); else return 12; } -void wxPostScriptDCImpl::PsPrint( const wxString& str ) -{ - const wxCharBuffer psdata(str.utf8_str()); - - wxPostScriptPrintNativeData *data = - (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); - - switch (m_printData.GetPrintMode()) - { -#if wxUSE_STREAMS - // append to output stream - case wxPRINT_MODE_STREAM: - { - wxOutputStream* outputstream = data->GetOutputStream(); - wxCHECK_RET( outputstream, wxT("invalid outputstream") ); - outputstream->Write( psdata, strlen( psdata ) ); - } - break; -#endif // wxUSE_STREAMS - - // save data into file - default: - wxCHECK_RET( m_pstream, wxT("invalid postscript dc") ); - fwrite( psdata, 1, strlen( psdata ), m_pstream ); - } -} - -void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, +void wxPostScriptDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, - const wxFont *theFont ) const + wxFont *theFont ) const { - const wxFont *fontToUse = theFont; + wxFont *fontToUse = theFont; - if (!fontToUse) fontToUse = &m_font; + if (!fontToUse) fontToUse = (wxFont*) &m_font; const float fontSize = fontToUse->GetPointSize() * GetFontPointSizeAdjustment(72.0); @@ -2047,10 +1859,6 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, const wxWX2MBbuf strbuf = string.mb_str(); - // conversion failed (non e.g. ISO characters) - if ( !strbuf ) - return; - #if !wxUSE_AFM_FOR_POSTSCRIPT /* Provide a VERY rough estimate (avoid using it). * Produces accurate results for mono-spaced font @@ -2081,13 +1889,13 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, / in 'points' (1/72 of an inch). this should later on be / changed to depend on the mapping mode. / CAVE: the path to the AFM files must be set before calling this - / fun3B3Bction. this is usually done by a call like the following: + / function. this is usually done by a call like the following: / wxSetAFMPath("d:\\wxw161\\afm\\"); / / example: / / wxPostScriptDC dc(NULL, true); - / if (dc.IsOk()){ + / if (dc.Ok()){ / wxSetAFMPath("d:\\wxw161\\afm\\"); / dc.StartDoc("Test"); / dc.StartPage(); @@ -2326,9 +2134,9 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, // VS: dirty, but is there any better solution? double *pt; pt = (double*) &m_underlinePosition; - *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontSize)) / 1000.0f; + *pt = LogicalToDeviceYRel((wxCoord)(UnderlinePosition * fontSize)) / 1000.0f; pt = (double*) &m_underlineThickness; - *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontSize)) / 1000.0f; + *pt = LogicalToDeviceYRel((wxCoord)(UnderlineThickness * fontSize)) / 1000.0f; } @@ -2339,20 +2147,8 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, long sum=0; float height=fontSize; /* by default */ - unsigned char *p=(unsigned char *)wxMBSTRINGCAST strbuf; - if(!p) - { - // String couldn't be converted which used to SEGV as reported here: - // http://bugs.debian.org/702378 - // http://trac.wxwidgets.org/ticket/15300 - // Upstream suggests "just return if the conversion failed". - if (x) (*x) = 0; - if (y) (*y) = 0; - if (descent) (*descent) = 0; - if (externalLeading) (*externalLeading) = 0; - return; - } - for(; *p; p++) + unsigned char *p; + for(p=(unsigned char *)wxMBSTRINGCAST strbuf; *p; p++) { if(lastWidths[*p]== INT_MIN) { @@ -2402,6 +2198,64 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, // Use AFM } +// print postscript datas via required method (file, stream) +void wxPostScriptDC::PsPrintf( const wxChar* fmt, ... ) +{ + va_list argptr; + va_start(argptr, fmt); + + PsPrint( wxString::FormatV( fmt, argptr ).c_str() ); +} + +void wxPostScriptDC::PsPrint( const char* psdata ) +{ + wxPostScriptPrintNativeData *data = + (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); + + switch (m_printData.GetPrintMode()) + { +#if wxUSE_STREAMS + // append to output stream + case wxPRINT_MODE_STREAM: + { + wxOutputStream* outputstream = data->GetOutputStream(); + wxCHECK_RET( outputstream, wxT("invalid outputstream") ); + outputstream->Write( psdata, strlen( psdata ) ); + } + break; +#endif // wxUSE_STREAMS + + // save data into file + default: + wxCHECK_RET( m_pstream, wxT("invalid postscript dc") ); + fwrite( psdata, 1, strlen( psdata ), m_pstream ); + } +} + +void wxPostScriptDC::PsPrint( int ch ) +{ + wxPostScriptPrintNativeData *data = + (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); + + switch (m_printData.GetPrintMode()) + { +#if wxUSE_STREAMS + // append to output stream + case wxPRINT_MODE_STREAM: + { + wxOutputStream* outputstream = data->GetOutputStream(); + wxCHECK_RET( outputstream, wxT("invalid outputstream") ); + outputstream->PutC( (char)ch ); + } + break; +#endif // wxUSE_STREAMS + + // save data into file + default: + wxCHECK_RET( m_pstream, wxT("invalid postscript dc") ); + fputc( ch, m_pstream ); + } +} #endif // wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT diff --git a/Source/3rd Party/wx/src/generic/dirctrlg.cpp b/Source/3rd Party/wx/src/generic/dirctrlg.cpp index 1cabc21f3..9edf105f6 100644 --- a/Source/3rd Party/wx/src/generic/dirctrlg.cpp +++ b/Source/3rd Party/wx/src/generic/dirctrlg.cpp @@ -4,6 +4,7 @@ // Author: Harm van der Heijden, Robert Roebling, Julian Smart // Modified by: // Created: 12/12/98 +// RCS-ID: $Id: dirctrlg.cpp 62093 2009-09-24 17:04:10Z JS $ // Copyright: (c) Harm van der Heijden, Robert Roebling and Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -28,6 +29,7 @@ #include "wx/icon.h" #include "wx/settings.h" #include "wx/msgdlg.h" + #include "wx/cmndata.h" #include "wx/choice.h" #include "wx/textctrl.h" #include "wx/layout.h" @@ -38,7 +40,6 @@ #include "wx/module.h" #endif -#include "wx/filename.h" #include "wx/filefn.h" #include "wx/imaglist.h" #include "wx/tokenzr.h" @@ -51,24 +52,25 @@ #endif #if defined(__WXMAC__) - #include "wx/osx/private.h" // includes mac headers + #include "wx/mac/private.h" // includes mac headers #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include #include "wx/msw/winundef.h" -#include "wx/volume.h" -// MinGW has _getdrive() and _chdrive(), Cygwin doesn't. -#if defined(__GNUWIN32__) && !defined(__CYGWIN__) - #define wxHAS_DRIVE_FUNCTIONS -#endif - -#ifdef wxHAS_DRIVE_FUNCTIONS +// FIXME - Mingw32 1.0 has both _getdrive() and _chdrive(). For now, let's assume +// older releases don't, but it should be verified and the checks modified +// accordingly. +#if !defined(__GNUWIN32__) || (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) +#if !defined(__WXWINCE__) #include #endif + #include + #include +#endif -#endif // __WINDOWS__ +#endif #if defined(__OS2__) || defined(__DOS__) #ifdef __OS2__ @@ -80,81 +82,77 @@ #include #include #endif + extern bool wxIsDriveAvailable(const wxString& dirName); #endif // __OS2__ #if defined(__WXMAC__) -// #include "MoreFilesX.h" + #include "MoreFilesX.h" #endif #ifdef __BORLANDC__ #include "dos.h" #endif -extern WXDLLEXPORT_DATA(const char) wxFileSelectorDefaultWildcardStr[]; - // If compiled under Windows, this macro can cause problems #ifdef GetFirstChild #undef GetFirstChild #endif -bool wxIsDriveAvailable(const wxString& dirName); - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -wxDEFINE_EVENT( wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent ); -wxDEFINE_EVENT( wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent ); - // ---------------------------------------------------------------------------- // wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/") // ---------------------------------------------------------------------------- size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids) { -#ifdef wxHAS_FILESYSTEM_VOLUMES +#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__) #ifdef __WXWINCE__ // No logical drives; return "\" paths.Add(wxT("\\")); names.Add(wxT("\\")); icon_ids.Add(wxFileIconsTable::computer); -#elif defined(__WIN32__) && wxUSE_FSVOLUME - // TODO: this code (using wxFSVolumeBase) should be used for all platforms - // but unfortunately wxFSVolumeBase is not implemented everywhere - const wxArrayString as = wxFSVolumeBase::GetVolumes(); - - for (size_t i = 0; i < as.GetCount(); i++) +#elif defined(__WIN32__) + wxChar driveBuffer[256]; + size_t n = (size_t) GetLogicalDriveStrings(255, driveBuffer); + size_t i = 0; + while (i < n) { - wxString path = as[i]; - wxFSVolume vol(path); + wxString path, name; + path.Printf(wxT("%c:\\"), driveBuffer[i]); + name.Printf(wxT("%c:"), driveBuffer[i]); + + // Do not use GetVolumeInformation to further decorate the + // name, since it can cause severe delays on network drives. + int imageId; - switch (vol.GetKind()) + int driveType = ::GetDriveType(path); + switch (driveType) { - case wxFS_VOL_FLOPPY: - if ( (path == wxT("a:\\")) || (path == wxT("b:\\")) ) + case DRIVE_REMOVABLE: + if (path == wxT("a:\\") || path == wxT("b:\\")) imageId = wxFileIconsTable::floppy; else imageId = wxFileIconsTable::removeable; break; - case wxFS_VOL_DVDROM: - case wxFS_VOL_CDROM: + case DRIVE_CDROM: imageId = wxFileIconsTable::cdrom; break; - case wxFS_VOL_NETWORK: - if (path[0] == wxT('\\')) - continue; // skip "\\computer\folder" - imageId = wxFileIconsTable::drive; - break; - case wxFS_VOL_DISK: - case wxFS_VOL_OTHER: + case DRIVE_REMOTE: + case DRIVE_FIXED: default: imageId = wxFileIconsTable::drive; break; } + paths.Add(path); - names.Add(vol.GetDisplayName()); + names.Add(name); icon_ids.Add(imageId); + + while (driveBuffer[i] != wxT('\0')) + i ++; + i ++; + if (driveBuffer[i] == wxT('\0')) + break; } #elif defined(__OS2__) APIRET rc; @@ -168,10 +166,9 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI { if (ulDriveMap & ( 1 << i )) { - const wxString path = wxFileName::GetVolumeString( - 'A' + i, wxPATH_GET_SEPARATOR); - const wxString name = wxFileName::GetVolumeString( - 'A' + i, wxPATH_NO_SEPARATOR); + wxString path, name; + path.Printf(wxT("%c:\\"), 'A' + i); + name.Printf(wxT("%c:"), 'A' + i); // Note: If _filesys is unsupported by some compilers, // we can always replace it by DosQueryFSAttach @@ -206,23 +203,25 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI } } #else // !__WIN32__, !__OS2__ + int drive; + /* If we can switch to the drive, it exists. */ - for ( char drive = 'A'; drive <= 'Z'; drive++ ) + for( drive = 1; drive <= 26; drive++ ) { - const wxString - path = wxFileName::GetVolumeString(drive, wxPATH_GET_SEPARATOR); + wxString path, name; + path.Printf(wxT("%c:\\"), (char) (drive + 'a' - 1)); + name.Printf(wxT("%c:"), (char) (drive + 'A' - 1)); if (wxIsDriveAvailable(path)) { paths.Add(path); - names.Add(wxFileName::GetVolumeString(drive, wxPATH_NO_SEPARATOR)); - icon_ids.Add(drive <= 2 ? wxFileIconsTable::floppy - : wxFileIconsTable::drive); + names.Add(name); + icon_ids.Add((drive <= 2) ? wxFileIconsTable::floppy : wxFileIconsTable::drive); } } #endif // __WIN32__/!__WIN32__ -#elif defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON +#elif defined(__WXMAC__) ItemCount volumeIndex = 1; OSErr err = noErr ; @@ -274,7 +273,7 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI bool wxIsDriveAvailable(const wxString& dirName) { - // FIXME: this method leads to hang up under Watcom for some reason + // FIXME_MGL - this method leads to hang up under Watcom for some reason #ifdef __WATCOMC__ wxUnusedVar(dirName); #else @@ -298,7 +297,8 @@ int setdrive(int WXUNUSED_IN_WINCE(drive)) { #ifdef __WXWINCE__ return 0; -#elif defined(wxHAS_DRIVE_FUNCTIONS) +#elif defined(__GNUWIN32__) && \ + (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) return _chdrive(drive); #else wxChar newdrive[4]; @@ -313,7 +313,7 @@ int setdrive(int WXUNUSED_IN_WINCE(drive)) #else newdrive[2] = wxT('\0'); #endif -#if defined(__WINDOWS__) +#if defined(__WXMSW__) if (::SetCurrentDirectory(newdrive)) #else // VA doesn't know what LPSTR is and has its own set @@ -340,7 +340,7 @@ bool wxIsDriveAvailable(const wxString& WXUNUSED_IN_WINCE(dirName)) if (dirName.length() == 3 && dirName[(size_t)1] == wxT(':')) { wxString dirNameLower(dirName.Lower()); -#ifndef wxHAS_DRIVE_FUNCTIONS +#if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) success = wxDirExists(dirNameLower); #else #if defined(__OS2__) @@ -439,13 +439,69 @@ bool wxDirItemData::HasFiles(const wxString& WXUNUSED(spec)) const // wxGenericDirCtrl //----------------------------------------------------------------------------- + +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxGenericDirCtrlStyle ) + +wxBEGIN_FLAGS( wxGenericDirCtrlStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxDIRCTRL_DIR_ONLY) + wxFLAGS_MEMBER(wxDIRCTRL_3D_INTERNAL) + wxFLAGS_MEMBER(wxDIRCTRL_SELECT_FIRST) + wxFLAGS_MEMBER(wxDIRCTRL_SHOW_FILTERS) + +wxEND_FLAGS( wxGenericDirCtrlStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxGenericDirCtrl, wxControl,"wx/dirctrl.h") + +wxBEGIN_PROPERTIES_TABLE(wxGenericDirCtrl) + wxHIDE_PROPERTY( Children ) + wxPROPERTY( DefaultPath , wxString , SetDefaultPath , GetDefaultPath , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Filter , wxString , SetFilter , GetFilter , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + wxPROPERTY( DefaultFilter , int , SetFilterIndex, GetFilterIndex, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + wxPROPERTY_FLAGS( WindowStyle, wxGenericDirCtrlStyle, long, SetWindowStyleFlag, GetWindowStyleFlag, EMPTY_MACROVALUE , 0, wxT("Helpstring"), wxT("group") ) +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxGenericDirCtrl) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_8( wxGenericDirCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , DefaultPath , + wxPoint , Position , wxSize , Size , long , WindowStyle , wxString , Filter , int , DefaultFilter ) +#else +IMPLEMENT_DYNAMIC_CLASS(wxGenericDirCtrl, wxControl) +#endif + BEGIN_EVENT_TABLE(wxGenericDirCtrl, wxControl) EVT_TREE_ITEM_EXPANDING (wxID_TREECTRL, wxGenericDirCtrl::OnExpandItem) EVT_TREE_ITEM_COLLAPSED (wxID_TREECTRL, wxGenericDirCtrl::OnCollapseItem) EVT_TREE_BEGIN_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnBeginEditItem) EVT_TREE_END_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnEndEditItem) - EVT_TREE_SEL_CHANGED (wxID_TREECTRL, wxGenericDirCtrl::OnTreeSelChange) - EVT_TREE_ITEM_ACTIVATED (wxID_TREECTRL, wxGenericDirCtrl::OnItemActivated) EVT_SIZE (wxGenericDirCtrl::OnSize) END_EVENT_TABLE() @@ -475,7 +531,7 @@ void wxGenericDirCtrl::ExpandRoot() } bool wxGenericDirCtrl::Create(wxWindow *parent, - const wxWindowID treeid, + const wxWindowID id, const wxString& dir, const wxPoint& pos, const wxSize& size, @@ -484,7 +540,7 @@ bool wxGenericDirCtrl::Create(wxWindow *parent, int defaultFilter, const wxString& name) { - if (!wxControl::Create(parent, treeid, pos, size, style, wxDefaultValidator, name)) + if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name)) return false; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); @@ -507,23 +563,32 @@ bool wxGenericDirCtrl::Create(wxWindow *parent, if (style & wxDIRCTRL_EDIT_LABELS) treeStyle |= wxTR_EDIT_LABELS; - if (style & wxDIRCTRL_MULTIPLE) - treeStyle |= wxTR_MULTIPLE; - if ((style & wxDIRCTRL_3D_INTERNAL) == 0) treeStyle |= wxNO_BORDER; + else + treeStyle |= wxBORDER_SUNKEN; + + long filterStyle = 0; + if ((style & wxDIRCTRL_3D_INTERNAL) == 0) + filterStyle |= wxNO_BORDER; + else + filterStyle |= wxBORDER_SUNKEN; m_treeCtrl = CreateTreeCtrl(this, wxID_TREECTRL, wxPoint(0,0), GetClientSize(), treeStyle); if (!filter.empty() && (style & wxDIRCTRL_SHOW_FILTERS)) - m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL); + m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL, wxDefaultPosition, wxDefaultSize, filterStyle); m_defaultPath = dir; m_filter = filter; if (m_filter.empty()) - m_filter = wxFileSelectorDefaultWildcardStr; +#ifdef __UNIX__ + m_filter = wxT("*"); +#else + m_filter = wxT("*.*"); +#endif SetFilterIndex(defaultFilter); @@ -567,34 +632,18 @@ void wxGenericDirCtrl::Init() m_filterListCtrl = NULL; } -wxTreeCtrl* wxGenericDirCtrl::CreateTreeCtrl(wxWindow *parent, wxWindowID treeid, const wxPoint& pos, const wxSize& size, long treeStyle) +wxTreeCtrl* wxGenericDirCtrl::CreateTreeCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long treeStyle) { - return new wxTreeCtrl(parent, treeid, pos, size, treeStyle); + return new wxTreeCtrl(parent, id, pos, size, treeStyle); } void wxGenericDirCtrl::ShowHidden( bool show ) { - if ( m_showHidden == show ) - return; - m_showHidden = show; - if ( HasFlag(wxDIRCTRL_MULTIPLE) ) - { - wxArrayString paths; - GetPaths(paths); - ReCreateTree(); - for ( unsigned n = 0; n < paths.size(); n++ ) - { - ExpandPath(paths[n]); - } - } - else - { - wxString path = GetPath(); - ReCreateTree(); - SetPath(path); - } + wxString path = GetPath(); + ReCreateTree(); + SetPath(path); } const wxTreeItemId @@ -602,11 +651,11 @@ wxGenericDirCtrl::AddSection(const wxString& path, const wxString& name, int ima { wxDirItemData *dir_item = new wxDirItemData(path,name,true); - wxTreeItemId treeid = AppendItem( m_rootId, name, imageId, -1, dir_item); + wxTreeItemId id = AppendItem( m_rootId, name, imageId, -1, dir_item); - m_treeCtrl->SetItemHasChildren(treeid); + m_treeCtrl->SetItemHasChildren(id); - return treeid; + return id; } void wxGenericDirCtrl::SetupSections() @@ -627,14 +676,6 @@ void wxGenericDirCtrl::SetupSections() AddSection(paths[n], names[n], icons[n]); } -void wxGenericDirCtrl::SetFocus() -{ - // we don't need focus ourselves, give it to the tree so that the user - // could navigate it - if (m_treeCtrl) - m_treeCtrl->SetFocus(); -} - void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent &event) { // don't rename the main entry "Sections" @@ -670,8 +711,8 @@ void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event) return; } - wxTreeItemId treeid = event.GetItem(); - wxDirItemData *data = GetItemData( treeid ); + wxTreeItemId id = event.GetItem(); + wxDirItemData *data = (wxDirItemData*)m_treeCtrl->GetItemData( id ); wxASSERT( data ); wxString new_name( wxPathOnly( data->m_path ) ); @@ -699,46 +740,6 @@ void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event) } } -void wxGenericDirCtrl::OnTreeSelChange(wxTreeEvent &event) -{ - wxTreeEvent changedEvent(wxEVT_DIRCTRL_SELECTIONCHANGED, GetId()); - - changedEvent.SetEventObject(this); - changedEvent.SetItem(event.GetItem()); - changedEvent.SetClientObject(m_treeCtrl->GetItemData(event.GetItem())); - - if (GetEventHandler()->SafelyProcessEvent(changedEvent) && !changedEvent.IsAllowed()) - event.Veto(); - else - event.Skip(); -} - -void wxGenericDirCtrl::OnItemActivated(wxTreeEvent &event) -{ - wxTreeItemId treeid = event.GetItem(); - const wxDirItemData *data = GetItemData(treeid); - - if (data->m_isDir) - { - // is dir - event.Skip(); - } - else - { - // is file - wxTreeEvent changedEvent(wxEVT_DIRCTRL_FILEACTIVATED, GetId()); - - changedEvent.SetEventObject(this); - changedEvent.SetItem(treeid); - changedEvent.SetClientObject(m_treeCtrl->GetItemData(treeid)); - - if (GetEventHandler()->SafelyProcessEvent(changedEvent) && !changedEvent.IsAllowed()) - event.Veto(); - else - event.Skip(); - } -} - void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event) { wxTreeItemId parentId = event.GetItem(); @@ -747,6 +748,7 @@ void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event) // ctor when wxTR_HIDE_ROOT was specified if (!m_rootId.IsOk()) + m_rootId = m_treeCtrl->GetRootItem(); ExpandDir(parentId); @@ -761,7 +763,7 @@ void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId) { wxTreeItemId child; - wxDirItemData *data = GetItemData(parentId); + wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(parentId); if (!data->m_isExpanded) return; @@ -774,9 +776,9 @@ void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId) m_treeCtrl->Thaw(); } -void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) +void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) { - wxDirItemData *data = GetItemData(parentId); + wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(parentId); if (data->m_isExpanded) return; @@ -797,7 +799,7 @@ void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) #if (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__DOS__) || defined(__OS2__) // Check if this is a root directory and if so, - // whether the drive is available. + // whether the drive is avaiable. if (!wxIsDriveAvailable(dirName)) { data->m_isExpanded = false; @@ -842,7 +844,7 @@ void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) dirs.Sort(wxDirCtrlStringCompareFunction); // Now do the filenames -- but only if we're allowed to - if (!HasFlag(wxDIRCTRL_DIR_ONLY)) + if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) { d.Open(dirName); @@ -873,13 +875,9 @@ void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) filenames.Sort(wxDirCtrlStringCompareFunction); } - // Now we really know whether we have any children so tell the tree control - // about it. - m_treeCtrl->SetItemHasChildren(parentId, !dirs.empty() || !filenames.empty()); - // Add the sorted dirs size_t i; - for (i = 0; i < dirs.GetCount(); i++) + for (i = 0; i < dirs.Count(); i++) { eachFilename = dirs[i]; path = dirName; @@ -888,23 +886,27 @@ void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) path += eachFilename; wxDirItemData *dir_item = new wxDirItemData(path,eachFilename,true); - wxTreeItemId treeid = AppendItem( parentId, eachFilename, + wxTreeItemId id = AppendItem( parentId, eachFilename, wxFileIconsTable::folder, -1, dir_item); - m_treeCtrl->SetItemImage( treeid, wxFileIconsTable::folder_open, + m_treeCtrl->SetItemImage( id, wxFileIconsTable::folder_open, wxTreeItemIcon_Expanded ); - // assume that it does have children by default as it can take a long - // time to really check for this (think remote drives...) - // - // and if we're wrong, we'll correct the icon later if - // the user really tries to open this item - m_treeCtrl->SetItemHasChildren(treeid); + // Has this got any children? If so, make it expandable. + // (There are two situations when a dir has children: either it + // has subdirectories or it contains files that weren't filtered + // out. The latter only applies to dirctrl with files.) + if ( dir_item->HasSubDirs() || + (((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) && + dir_item->HasFiles(m_currentFilterStr)) ) + { + m_treeCtrl->SetItemHasChildren(id); + } } // Add the sorted filenames - if (!HasFlag(wxDIRCTRL_DIR_ONLY)) + if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) { - for (i = 0; i < filenames.GetCount(); i++) + for (i = 0; i < filenames.Count(); i++) { eachFilename = filenames[i]; path = dirName; @@ -921,12 +923,6 @@ void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId) } } -void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) -{ - // ExpandDir() will not actually expand the tree node, just populate it - PopulateNode(parentId); -} - void wxGenericDirCtrl::ReCreateTree() { CollapseDir(m_treeCtrl->GetRootItem()); @@ -967,7 +963,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie); while (childId.IsOk()) { - wxDirItemData* data = GetItemData(childId); + wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(childId); if (data && !data->m_path.empty()) { @@ -1005,25 +1001,25 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& bool wxGenericDirCtrl::ExpandPath(const wxString& path) { bool done = false; - wxTreeItemId treeid = FindChild(m_rootId, path, done); - wxTreeItemId lastId = treeid; // The last non-zero treeid - while (treeid.IsOk() && !done) + wxTreeItemId id = FindChild(m_rootId, path, done); + wxTreeItemId lastId = id; // The last non-zero id + while (id.IsOk() && !done) { - ExpandDir(treeid); + ExpandDir(id); - treeid = FindChild(treeid, path, done); - if (treeid.IsOk()) - lastId = treeid; + id = FindChild(id, path, done); + if (id.IsOk()) + lastId = id; } if (!lastId.IsOk()) return false; - wxDirItemData *data = GetItemData(lastId); + wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(lastId); if (data->m_isDir) { m_treeCtrl->Expand(lastId); } - if (HasFlag(wxDIRCTRL_SELECT_FIRST) && data->m_isDir) + if ((GetWindowStyle() & wxDIRCTRL_SELECT_FIRST) && data->m_isDir) { // Find the first file in this directory wxTreeItemIdValue cookie; @@ -1031,7 +1027,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path) bool selectedChild = false; while (childId.IsOk()) { - data = GetItemData(childId); + data = (wxDirItemData*) m_treeCtrl->GetItemData(childId); if (data && data->m_path != wxEmptyString && !data->m_isDir) { @@ -1061,17 +1057,17 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path) bool wxGenericDirCtrl::CollapsePath(const wxString& path) { bool done = false; - wxTreeItemId treeid = FindChild(m_rootId, path, done); - wxTreeItemId lastId = treeid; // The last non-zero treeid + wxTreeItemId id = FindChild(m_rootId, path, done); + wxTreeItemId lastId = id; // The last non-zero id - while ( treeid.IsOk() && !done ) + while ( id.IsOk() && !done ) { - CollapseDir(treeid); + CollapseDir(id); - treeid = FindChild(treeid, path, done); + id = FindChild(id, path, done); - if ( treeid.IsOk() ) - lastId = treeid; + if ( id.IsOk() ) + lastId = id; } if ( !lastId.IsOk() ) @@ -1083,64 +1079,25 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path) return true; } -wxDirItemData* wxGenericDirCtrl::GetItemData(wxTreeItemId itemId) -{ - return static_cast(m_treeCtrl->GetItemData(itemId)); -} - -wxString wxGenericDirCtrl::GetPath(wxTreeItemId itemId) const -{ - const wxDirItemData* - data = static_cast(m_treeCtrl->GetItemData(itemId)); - - return data->m_path; -} wxString wxGenericDirCtrl::GetPath() const { - // Allow calling GetPath() in multiple selection from OnSelFilter - if (m_treeCtrl->HasFlag(wxTR_MULTIPLE)) + wxTreeItemId id = m_treeCtrl->GetSelection(); + if (id) { - wxArrayTreeItemIds items; - m_treeCtrl->GetSelections(items); - if (items.size() > 0) - { - // return first string only - wxTreeItemId treeid = items[0]; - return GetPath(treeid); - } - - return wxEmptyString; - } - - wxTreeItemId treeid = m_treeCtrl->GetSelection(); - if (treeid) - { - return GetPath(treeid); + wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(id); + return data->m_path; } else return wxEmptyString; } -void wxGenericDirCtrl::GetPaths(wxArrayString& paths) const -{ - paths.clear(); - - wxArrayTreeItemIds items; - m_treeCtrl->GetSelections(items); - for ( unsigned n = 0; n < items.size(); n++ ) - { - wxTreeItemId treeid = items[n]; - paths.push_back(GetPath(treeid)); - } -} - wxString wxGenericDirCtrl::GetFilePath() const { - wxTreeItemId treeid = m_treeCtrl->GetSelection(); - if (treeid) + wxTreeItemId id = m_treeCtrl->GetSelection(); + if (id) { - wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); + wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(id); if (data->m_isDir) return wxEmptyString; else @@ -1150,21 +1107,6 @@ wxString wxGenericDirCtrl::GetFilePath() const return wxEmptyString; } -void wxGenericDirCtrl::GetFilePaths(wxArrayString& paths) const -{ - paths.clear(); - - wxArrayTreeItemIds items; - m_treeCtrl->GetSelections(items); - for ( unsigned n = 0; n < items.size(); n++ ) - { - wxTreeItemId treeid = items[n]; - wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); - if ( !data->m_isDir ) - paths.Add(data->m_path); - } -} - void wxGenericDirCtrl::SetPath(const wxString& path) { m_defaultPath = path; @@ -1172,48 +1114,11 @@ void wxGenericDirCtrl::SetPath(const wxString& path) ExpandPath(path); } -void wxGenericDirCtrl::SelectPath(const wxString& path, bool select) -{ - bool done = false; - wxTreeItemId treeid = FindChild(m_rootId, path, done); - wxTreeItemId lastId = treeid; // The last non-zero treeid - while ( treeid.IsOk() && !done ) - { - treeid = FindChild(treeid, path, done); - if ( treeid.IsOk() ) - lastId = treeid; - } - if ( !lastId.IsOk() ) - return; - - if ( done ) - { - m_treeCtrl->SelectItem(treeid, select); - } -} - -void wxGenericDirCtrl::SelectPaths(const wxArrayString& paths) -{ - if ( HasFlag(wxDIRCTRL_MULTIPLE) ) - { - UnselectAll(); - for ( unsigned n = 0; n < paths.size(); n++ ) - { - SelectPath(paths[n]); - } - } -} - -void wxGenericDirCtrl::UnselectAll() -{ - m_treeCtrl->UnselectAll(); -} - // Not used #if 0 -void wxGenericDirCtrl::FindChildFiles(wxTreeItemId treeid, int dirFlags, wxArrayString& filenames) +void wxGenericDirCtrl::FindChildFiles(wxTreeItemId id, int dirFlags, wxArrayString& filenames) { - wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(treeid); + wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(id); // This may take a longish time. Go to busy cursor wxBusyCursor busy; @@ -1224,7 +1129,7 @@ void wxGenericDirCtrl::FindChildFiles(wxTreeItemId treeid, int dirFlags, wxArray wxString dirName(data->m_path); -#if defined(__WINDOWS__) || defined(__OS2__) +#if defined(__WXMSW__) || defined(__OS2__) if (dirName.Last() == ':') dirName += wxString(wxFILE_SEP_PATH); #endif @@ -1271,14 +1176,6 @@ void wxGenericDirCtrl::SetFilter(const wxString& filter) { m_filter = filter; - if (!filter.empty() && !m_filterListCtrl && HasFlag(wxDIRCTRL_SHOW_FILTERS)) - m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL); - else if (filter.empty() && m_filterListCtrl) - { - m_filterListCtrl->Destroy(); - m_filterListCtrl = NULL; - } - wxString f, d; if (ExtractWildcard(m_filter, m_currentFilter, f, d)) m_currentFilterStr = f; @@ -1288,6 +1185,7 @@ void wxGenericDirCtrl::SetFilter(const wxString& filter) #else m_currentFilterStr = wxT("*.*"); #endif + // current filter index is meaningless after filter change, set it to zero SetFilterIndex(0); if (m_filterListCtrl) @@ -1309,6 +1207,15 @@ bool wxGenericDirCtrl::ExtractWildcard(const wxString& filterStr, int n, wxStrin return false; } +#if WXWIN_COMPATIBILITY_2_4 +// Parses the global filter, returning the number of filters. +// Returns 0 if none or if there's a problem. +// filterStr is in the form: "All files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpg" +int wxGenericDirCtrl::ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions) +{ + return wxParseCommonDialogsFilter(filterStr, descriptions, filters ); +} +#endif // WXWIN_COMPATIBILITY_2_4 void wxGenericDirCtrl::DoResize() { @@ -1368,22 +1275,13 @@ BEGIN_EVENT_TABLE(wxDirFilterListCtrl, wxChoice) EVT_CHOICE(wxID_ANY, wxDirFilterListCtrl::OnSelFilter) END_EVENT_TABLE() -bool wxDirFilterListCtrl::Create(wxGenericDirCtrl* parent, - const wxWindowID treeid, - const wxPoint& pos, - const wxSize& size, - long style) +bool wxDirFilterListCtrl::Create(wxGenericDirCtrl* parent, const wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style) { m_dirCtrl = parent; - - // by default our border style is determined by the style of our parent - if ( !(style & wxBORDER_MASK) ) - { - style |= parent->HasFlag(wxDIRCTRL_3D_INTERNAL) ? wxBORDER_SUNKEN - : wxBORDER_NONE; - } - - return wxChoice::Create(parent, treeid, pos, size, 0, NULL, style); + return wxChoice::Create(parent, id, pos, size, 0, NULL, style); } void wxDirFilterListCtrl::Init() @@ -1395,33 +1293,16 @@ void wxDirFilterListCtrl::OnSelFilter(wxCommandEvent& WXUNUSED(event)) { int sel = GetSelection(); - if (m_dirCtrl->HasFlag(wxDIRCTRL_MULTIPLE)) - { - wxArrayString paths; - m_dirCtrl->GetPaths(paths); + wxString currentPath = m_dirCtrl->GetPath(); - m_dirCtrl->SetFilterIndex(sel); + m_dirCtrl->SetFilterIndex(sel); - // If the filter has changed, the view is out of date, so - // collapse the tree. - m_dirCtrl->ReCreateTree(); + // If the filter has changed, the view is out of date, so + // collapse the tree. + m_dirCtrl->ReCreateTree(); - // Expand and select the previously selected paths - for (unsigned int i = 0; i < paths.GetCount(); i++) - { - m_dirCtrl->ExpandPath(paths.Item(i)); - } - } - else - { - wxString currentPath = m_dirCtrl->GetPath(); - - m_dirCtrl->SetFilterIndex(sel); - m_dirCtrl->ReCreateTree(); - - // Try to restore the selection, or at least the directory - m_dirCtrl->ExpandPath(currentPath); - } + // Try to restore the selection, or at least the directory + m_dirCtrl->ExpandPath(currentPath); } void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilter) @@ -1445,9 +1326,9 @@ void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilt // wxFileIconsTable icons // ---------------------------------------------------------------------------- -#ifndef __WXGTK20__ +#ifndef __WXGTK24__ /* Computer (c) Julian Smart */ -static const char* const file_icons_tbl_computer_xpm[] = { +static const char * file_icons_tbl_computer_xpm[] = { /* columns rows colors chars-per-pixel */ "16 16 42 1", "r c #4E7FD0", @@ -1510,14 +1391,14 @@ static const char* const file_icons_tbl_computer_xpm[] = { " dfffffffffffffd", " " }; -#endif // !GTK+ 2 +#endif // GTK+ < 2.4 // ---------------------------------------------------------------------------- // wxFileIconsTable & friends // ---------------------------------------------------------------------------- // global instance of a wxFileIconsTable -wxFileIconsTable* wxTheFileIconsTable = NULL; +wxFileIconsTable* wxTheFileIconsTable = (wxFileIconsTable *)NULL; // A module to allow icons table cleanup @@ -1529,7 +1410,11 @@ public: bool OnInit() { wxTheFileIconsTable = new wxFileIconsTable; return true; } void OnExit() { - wxDELETE(wxTheFileIconsTable); + if (wxTheFileIconsTable) + { + delete wxTheFileIconsTable; + wxTheFileIconsTable = NULL; + } } }; @@ -1538,9 +1423,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileIconsTableModule, wxModule) class wxFileIconEntry : public wxObject { public: - wxFileIconEntry(int i) { iconid = i; } + wxFileIconEntry(int i) { id = i; } - int iconid; + int id; }; wxFileIconsTable::wxFileIconsTable() @@ -1575,7 +1460,7 @@ void wxFileIconsTable::Create() wxART_CMN_DIALOG, wxSize(16, 16))); // computer -#ifdef __WXGTK20__ +#ifdef __WXGTK24__ // GTK24 uses this icon in the file open dialog m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_HARDDISK, wxART_CMN_DIALOG, @@ -1604,14 +1489,14 @@ void wxFileIconsTable::Create() wxART_CMN_DIALOG, wxSize(16, 16))); // executable - if (GetIconID(wxEmptyString, wxT("application/x-executable")) == file) + if (GetIconID(wxEmptyString, _T("application/x-executable")) == file) { m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE, wxART_CMN_DIALOG, wxSize(16, 16))); - delete m_HashTable->Get(wxT("exe")); - m_HashTable->Delete(wxT("exe")); - m_HashTable->Put(wxT("exe"), new wxFileIconEntry(executable)); + delete m_HashTable->Get(_T("exe")); + m_HashTable->Delete(_T("exe")); + m_HashTable->Put(_T("exe"), new wxFileIconEntry(executable)); } /* else put into list by GetIconID (KDE defines application/x-executable for *.exe and has nice icon) @@ -1626,7 +1511,7 @@ wxImageList *wxFileIconsTable::GetSmallImageList() return m_smallImageList; } -#if wxUSE_MIMETYPE && wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB) +#if wxUSE_MIMETYPE && wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB) // VS: we don't need this function w/o wxMimeTypesManager because we'll only have // one icon and we won't resize it @@ -1742,7 +1627,7 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) if (!extension.empty()) { wxFileIconEntry *entry = (wxFileIconEntry*) m_HashTable->Get(extension); - if (entry) return (entry -> iconid); + if (entry) return (entry -> id); } wxFileType *ft = (mime.empty()) ? @@ -1762,7 +1647,7 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) delete ft; - if ( !ic.IsOk() ) + if ( !ic.Ok() ) { int newid = file; m_HashTable->Put(extension, new wxFileIconEntry(newid)); @@ -1772,7 +1657,7 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) wxBitmap bmp; bmp.CopyFromIcon(ic); - if ( !bmp.IsOk() ) + if ( !bmp.Ok() ) { int newid = file; m_HashTable->Put(extension, new wxFileIconEntry(newid)); @@ -1781,12 +1666,12 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) const unsigned int size = 16; - int treeid = m_smallImageList->GetImageCount(); + int id = m_smallImageList->GetImageCount(); if ((bmp.GetWidth() == (int) size) && (bmp.GetHeight() == (int) size)) { m_smallImageList->Add(bmp); } -#if wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB) +#if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB) else { wxImage img = bmp.ConvertToImage(); @@ -1799,8 +1684,8 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) } #endif // wxUSE_IMAGE - m_HashTable->Put(extension, new wxFileIconEntry(treeid)); - return treeid; + m_HashTable->Put(extension, new wxFileIconEntry(id)); + return id; #else // !wxUSE_MIMETYPE diff --git a/Source/3rd Party/wx/src/generic/dirdlgg.cpp b/Source/3rd Party/wx/src/generic/dirdlgg.cpp deleted file mode 100644 index 80ddf5ca5..000000000 --- a/Source/3rd Party/wx/src/generic/dirdlgg.cpp +++ /dev/null @@ -1,371 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/dirdlgg.cpp -// Purpose: wxDirDialog -// Author: Harm van der Heijden, Robert Roebling & Julian Smart -// Modified by: -// Created: 12/12/98 -// Copyright: (c) Harm van der Heijden, Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DIRDLG - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" - #include "wx/button.h" - #include "wx/checkbox.h" - #include "wx/sizer.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/msgdlg.h" - #include "wx/bmpbuttn.h" -#endif - -#include "wx/statline.h" -#include "wx/dirctrl.h" -#include "wx/generic/dirdlgg.h" -#include "wx/artprov.h" -#include "wx/menu.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -static const int ID_DIRCTRL = 1000; -static const int ID_TEXTCTRL = 1001; -static const int ID_NEW = 1004; -static const int ID_SHOW_HIDDEN = 1005; -static const int ID_GO_HOME = 1006; - -//----------------------------------------------------------------------------- -// wxGenericDirDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericDirDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxGenericDirDialog, wxDialog) - EVT_CLOSE (wxGenericDirDialog::OnCloseWindow) - EVT_BUTTON (wxID_OK, wxGenericDirDialog::OnOK) - EVT_BUTTON (ID_NEW, wxGenericDirDialog::OnNew) - EVT_BUTTON (ID_GO_HOME, wxGenericDirDialog::OnGoHome) - EVT_TREE_KEY_DOWN (wxID_ANY, wxGenericDirDialog::OnTreeKeyDown) - EVT_TREE_SEL_CHANGED (wxID_ANY, wxGenericDirDialog::OnTreeSelected) - EVT_TEXT_ENTER (ID_TEXTCTRL, wxGenericDirDialog::OnOK) - EVT_CHECKBOX (ID_SHOW_HIDDEN, wxGenericDirDialog::OnShowHidden) -END_EVENT_TABLE() - -wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title, - const wxString& defaultPath, long style, - const wxPoint& pos, const wxSize& sz, - const wxString& name) -{ - Create(parent, title, defaultPath, style, pos, sz, name); -} - -bool wxGenericDirDialog::Create(wxWindow* parent, - const wxString& title, - const wxString& defaultPath, long style, - const wxPoint& pos, - const wxSize& sz, - const wxString& name) -{ - wxBusyCursor cursor; - - parent = GetParentForModalDialog(parent, style); - - if (!wxDirDialogBase::Create(parent, title, defaultPath, style, pos, sz, name)) - return false; - - m_path = defaultPath; - if (m_path == wxT("~")) - wxGetHomeDir(&m_path); - if (m_path == wxT(".")) - m_path = wxGetCwd(); - - wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - - // smartphones does not support or do not waste space for wxButtons -#if defined(__SMARTPHONE__) - - wxMenu *dirMenu = new wxMenu; - dirMenu->Append(ID_GO_HOME, _("Home")); - - if (!HasFlag(wxDD_DIR_MUST_EXIST)) - { - dirMenu->Append(ID_NEW, _("New directory")); - } - - dirMenu->AppendCheckItem(ID_SHOW_HIDDEN, _("Show hidden directories")); - dirMenu->AppendSeparator(); - dirMenu->Append(wxID_CANCEL, _("Cancel")); - -#else - - // 0) 'New' and 'Home' Buttons - wxSizer* buttonsizer = new wxBoxSizer( wxHORIZONTAL ); - - // VS: 'Home directory' concept is unknown to MS-DOS -#if !defined(__DOS__) - wxBitmapButton* homeButton = - new wxBitmapButton(this, ID_GO_HOME, - wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON)); - buttonsizer->Add( homeButton, 0, wxLEFT|wxRIGHT, 10 ); -#endif - - // I'm not convinced we need a New button, and we tend to get annoying - // accidental-editing with label editing enabled. - if (!HasFlag(wxDD_DIR_MUST_EXIST)) - { - wxBitmapButton* newButton = - new wxBitmapButton(this, ID_NEW, - wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON)); - buttonsizer->Add( newButton, 0, wxRIGHT, 10 ); -#if wxUSE_TOOLTIPS - newButton->SetToolTip(_("Create new directory")); -#endif - } - -#if wxUSE_TOOLTIPS - homeButton->SetToolTip(_("Go to home directory")); -#endif - - topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 ); - -#endif // __SMARTPHONE__/!__SMARTPHONE__ - - // 1) dir ctrl - m_dirCtrl = NULL; // this is necessary, event handler called from - // wxGenericDirCtrl would crash otherwise! - long dirStyle = wxDIRCTRL_DIR_ONLY | wxDEFAULT_CONTROL_BORDER; - -#ifdef __WXMSW__ - if (!HasFlag(wxDD_DIR_MUST_EXIST)) - { - // Only under Windows do we need the wxTR_EDIT_LABEL tree control style - // before we can call EditLabel (required for "New directory") - dirStyle |= wxDIRCTRL_EDIT_LABELS; - } -#endif - - m_dirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL, - m_path, wxDefaultPosition, - wxSize(300, 200), - dirStyle); - - wxSizerFlags flagsBorder2; - flagsBorder2.DoubleBorder(wxTOP | wxLEFT | wxRIGHT); - - topsizer->Add(m_dirCtrl, wxSizerFlags(flagsBorder2).Proportion(1).Expand()); - -#ifndef __SMARTPHONE__ - // TODO: Make this an option depending on a flag? - wxCheckBox * - check = new wxCheckBox(this, ID_SHOW_HIDDEN, _("Show &hidden directories")); - topsizer->Add(check, wxSizerFlags(flagsBorder2).Right()); -#endif // !__SMARTPHONE__ - - // 2) text ctrl - m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition ); - topsizer->Add(m_input, wxSizerFlags(flagsBorder2).Expand()); - - // 3) buttons if any - wxSizer *buttonSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if ( buttonSizer ) - { - topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder()); - } - -#ifdef __SMARTPHONE__ - // overwrite menu set by CreateSeparatedButtonSizer() call above - SetRightMenu(wxID_ANY, _("Options"), dirMenu); -#endif - - m_input->SetFocus(); - - SetAutoLayout( true ); - SetSizer( topsizer ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - - Centre( wxBOTH ); - - return true; -} - -void wxGenericDirDialog::EndModal(int retCode) -{ - // before proceeding, change the current working directory if user asked so - if (retCode == wxID_OK && HasFlag(wxDD_CHANGE_DIR)) - wxSetWorkingDirectory(m_path); - - wxDialog::EndModal(retCode); -} - -void wxGenericDirDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - EndModal(wxID_CANCEL); -} - -void wxGenericDirDialog::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - m_path = m_input->GetValue(); - - // Does the path exist? (User may have typed anything in m_input) - if (wxDirExists(m_path)) - { - // OK, path exists, we're done. - EndModal(wxID_OK); - return; - } - - // Interact with user, find out if the dir is a typo or to be created - wxString msg; - msg.Printf(_("The directory '%s' does not exist\nCreate it now?"), - m_path.c_str()); - wxMessageDialog dialog(this, msg, _("Directory does not exist"), - wxYES_NO | wxICON_WARNING); - - if ( dialog.ShowModal() == wxID_YES ) - { - // Okay, let's make it - wxLogNull log; - if (wxMkdir(m_path)) - { - // The new dir was created okay. - EndModal(wxID_OK); - return; - } - else - { - // Trouble... - msg.Printf(_("Failed to create directory '%s'\n(Do you have the required permissions?)"), - m_path.c_str()); - wxMessageDialog errmsg(this, msg, _("Error creating directory"), wxOK | wxICON_ERROR); - errmsg.ShowModal(); - // We still don't have a valid dir. Back to the main dialog. - } - } - // User has answered NO to create dir. -} - -void wxGenericDirDialog::SetPath(const wxString& path) -{ - m_dirCtrl->SetPath(path); - m_path = path; -} - -wxString wxGenericDirDialog::GetPath(void) const -{ - return m_path; -} - -int wxGenericDirDialog::ShowModal() -{ - m_input->SetValue( m_path ); - return wxDialog::ShowModal(); -} - -void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event ) -{ - if (!m_dirCtrl) - return; - - wxTreeItemId item = event.GetItem(); - - wxDirItemData *data = NULL; - - if(item.IsOk()) - data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(item); - - if (data) - m_input->SetValue( data->m_path ); -} - -void wxGenericDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) ) -{ - if (!m_dirCtrl) - return; - - wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(m_dirCtrl->GetTreeCtrl()->GetSelection()); - if (data) - m_input->SetValue( data->m_path ); -} - -void wxGenericDirDialog::OnShowHidden( wxCommandEvent& event ) -{ - if (!m_dirCtrl) - return; - - m_dirCtrl->ShowHidden( event.GetInt() != 0 ); -} - -void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) ) -{ - wxTreeItemId id = m_dirCtrl->GetTreeCtrl()->GetSelection(); - if ((id == m_dirCtrl->GetTreeCtrl()->GetRootItem()) || - (m_dirCtrl->GetTreeCtrl()->GetItemParent(id) == m_dirCtrl->GetTreeCtrl()->GetRootItem())) - { - wxMessageDialog msg(this, _("You cannot add a new directory to this section."), - _("Create directory"), wxOK | wxICON_INFORMATION ); - msg.ShowModal(); - return; - } - - wxTreeItemId parent = id ; // m_dirCtrl->GetTreeCtrl()->GetItemParent( id ); - wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData( parent ); - wxASSERT( data ); - - wxString new_name( _("NewName") ); - wxString path( data->m_path ); - if (!wxEndsWithPathSeparator(path)) - path += wxFILE_SEP_PATH; - path += new_name; - if (wxDirExists(path)) - { - // try NewName0, NewName1 etc. - int i = 0; - do { - new_name = _("NewName"); - wxString num; - num.Printf( wxT("%d"), i ); - new_name += num; - - path = data->m_path; - if (!wxEndsWithPathSeparator(path)) - path += wxFILE_SEP_PATH; - path += new_name; - i++; - } while (wxDirExists(path)); - } - - wxLogNull log; - if (!wxMkdir(path)) - { - wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR ); - dialog.ShowModal(); - return; - } - - wxDirItemData *new_data = new wxDirItemData( path, new_name, true ); - - // TODO: THIS CODE DOESN'T WORK YET. We need to avoid duplication of the first child - // of the parent. - wxTreeItemId new_id = m_dirCtrl->GetTreeCtrl()->AppendItem( parent, new_name, 0, 0, new_data ); - m_dirCtrl->GetTreeCtrl()->EnsureVisible( new_id ); - m_dirCtrl->GetTreeCtrl()->EditLabel( new_id ); -} - -void wxGenericDirDialog::OnGoHome(wxCommandEvent& WXUNUSED(event)) -{ - SetPath(wxGetUserHome()); -} - -#endif // wxUSE_DIRDLG diff --git a/Source/3rd Party/wx/src/generic/dragimgg.cpp b/Source/3rd Party/wx/src/generic/dragimgg.cpp index d391603ea..d3c8ac474 100644 --- a/Source/3rd Party/wx/src/generic/dragimgg.cpp +++ b/Source/3rd Party/wx/src/generic/dragimgg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 29/2/2000 +// RCS-ID: $Id: dragimgg.cpp 42397 2006-10-25 12:12:56Z VS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -68,13 +69,13 @@ void wxGenericDragImage::Init() { m_isDirty = false; m_isShown = false; - m_windowDC = NULL; - m_window = NULL; + m_windowDC = (wxDC*) NULL; + m_window = (wxWindow*) NULL; m_fullScreen = false; #ifdef wxHAS_NATIVE_OVERLAY m_dcOverlay = NULL; #else - m_pBackingBitmap = NULL; + m_pBackingBitmap = (wxBitmap*) NULL; #endif } @@ -171,7 +172,7 @@ bool wxGenericDragImage::Create(const wxString& str, const wxCursor& cursor) { wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - wxCoord w = 0, h = 0; + long w = 0, h = 0; wxScreenDC dc; dc.SetFont(font); dc.GetTextExtent(str, & w, & h); @@ -186,7 +187,7 @@ bool wxGenericDragImage::Create(const wxString& str, const wxCursor& cursor) dc2.SetFont(font); dc2.SetBackground(* wxWHITE_BRUSH); dc2.Clear(); - dc2.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); + dc2.SetBackgroundMode(wxTRANSPARENT); dc2.SetTextForeground(* wxLIGHT_GREY); dc2.DrawText(str, 0, 0); dc2.DrawText(str, 1, 0); @@ -235,7 +236,7 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot, bool fullScreen, wxRect* rect) { - wxCHECK_MSG( window, false, wxT("Window must not be null in BeginDrag.")); + wxASSERT_MSG( (window != 0), wxT("Window must not be null in BeginDrag.")); // The image should be offset by this amount m_offset = hotspot; @@ -246,15 +247,18 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot, m_boundingRect = * rect; m_isDirty = false; - m_isShown = false; + m_isDirty = false; - if (m_cursor.IsOk()) + if (window) { - m_oldCursor = window->GetCursor(); - window->SetCursor(m_cursor); - } + window->CaptureMouse(); - window->CaptureMouse(); + if (m_cursor.Ok()) + { + m_oldCursor = window->GetCursor(); + window->SetCursor(m_cursor); + } + } // Make a copy of the window so we can repair damage done as the image is // dragged. @@ -287,7 +291,7 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot, #ifndef wxHAS_NATIVE_OVERLAY wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); - if (!backing->IsOk() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y)) + if (!backing->Ok() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y)) (*backing) = wxBitmap(clientSize.x, clientSize.y); #endif // !wxHAS_NATIVE_OVERLAY @@ -323,7 +327,7 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window, wxW wxSize sz = fullScreenRect->GetSize(); - if (fullScreenRect->GetParent() && !wxDynamicCast(fullScreenRect, wxFrame)) + if (fullScreenRect->GetParent() && !fullScreenRect->IsKindOf(CLASSINFO(wxFrame))) fullScreenRect->GetParent()->ClientToScreen(& x, & y); rect.x = x; rect.y = y; @@ -344,7 +348,7 @@ bool wxGenericDragImage::EndDrag() #endif m_window->ReleaseMouse(); - if (m_cursor.IsOk() && m_oldCursor.IsOk()) + if (m_cursor.Ok() && m_oldCursor.Ok()) { m_window->SetCursor(m_oldCursor); } @@ -357,7 +361,8 @@ bool wxGenericDragImage::EndDrag() #else m_windowDC->DestroyClippingRegion(); #endif - wxDELETE(m_windowDC); + delete m_windowDC; + m_windowDC = (wxDC*) NULL; } #ifndef wxHAS_NATIVE_OVERLAY @@ -371,7 +376,7 @@ bool wxGenericDragImage::EndDrag() // is non-NULL, or in screen coordinates if NULL. bool wxGenericDragImage::Move(const wxPoint& pt) { - wxASSERT_MSG( (m_windowDC != NULL), wxT("No window DC in wxGenericDragImage::Move()") ); + wxASSERT_MSG( (m_windowDC != (wxDC*) NULL), wxT("No window DC in wxGenericDragImage::Move()") ); wxPoint pt2(pt); if (m_fullScreen) @@ -395,7 +400,7 @@ bool wxGenericDragImage::Move(const wxPoint& pt) bool wxGenericDragImage::Show() { - wxASSERT_MSG( (m_windowDC != NULL), wxT("No window DC in wxGenericDragImage::Show()") ); + wxASSERT_MSG( (m_windowDC != (wxDC*) NULL), wxT("No window DC in wxGenericDragImage::Show()") ); // Show at the current position @@ -433,7 +438,7 @@ bool wxGenericDragImage::UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& des bool wxGenericDragImage::Hide() { - wxASSERT_MSG( (m_windowDC != NULL), wxT("No window DC in wxGenericDragImage::Hide()") ); + wxASSERT_MSG( (m_windowDC != (wxDC*) NULL), wxT("No window DC in wxGenericDragImage::Hide()") ); // Repair the old position @@ -449,16 +454,13 @@ bool wxGenericDragImage::Hide() } // More efficient: erase and redraw simultaneously if possible -bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, - const wxPoint& newPos, +bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, bool eraseOld, bool drawNew) { if (!m_windowDC) return false; #ifdef wxHAS_NATIVE_OVERLAY - wxUnusedVar(oldPos); - wxDCOverlay dcoverlay( m_overlay, (wxWindowDC*) m_windowDC ) ; if ( eraseOld ) dcoverlay.Clear() ; @@ -466,7 +468,7 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, DoDrawImage(*m_windowDC, newPos); #else // !wxHAS_NATIVE_OVERLAY wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); - if (!backing->IsOk()) + if (!backing->Ok()) return false; wxRect oldRect(GetImageRect(oldPos)); @@ -498,7 +500,7 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, // keep reallocating all the time. int excess = 50; - if (!m_repairBitmap.IsOk() || (m_repairBitmap.GetWidth() < fullRect.GetWidth() || m_repairBitmap.GetHeight() < fullRect.GetHeight())) + if (!m_repairBitmap.Ok() || (m_repairBitmap.GetWidth() < fullRect.GetWidth() || m_repairBitmap.GetHeight() < fullRect.GetHeight())) { m_repairBitmap = wxBitmap(fullRect.GetWidth() + excess, fullRect.GetHeight() + excess); } @@ -538,12 +540,12 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, // Override this if you are using a virtual image (drawing your own image) bool wxGenericDragImage::DoDrawImage(wxDC& dc, const wxPoint& pos) const { - if (m_bitmap.IsOk()) + if (m_bitmap.Ok()) { dc.DrawBitmap(m_bitmap, pos.x, pos.y, (m_bitmap.GetMask() != 0)); return true; } - else if (m_icon.IsOk()) + else if (m_icon.Ok()) { dc.DrawIcon(m_icon, pos.x, pos.y); return true; @@ -555,11 +557,11 @@ bool wxGenericDragImage::DoDrawImage(wxDC& dc, const wxPoint& pos) const // Override this if you are using a virtual image (drawing your own image) wxRect wxGenericDragImage::GetImageRect(const wxPoint& pos) const { - if (m_bitmap.IsOk()) + if (m_bitmap.Ok()) { return wxRect(pos.x, pos.y, m_bitmap.GetWidth(), m_bitmap.GetHeight()); } - else if (m_icon.IsOk()) + else if (m_icon.Ok()) { return wxRect(pos.x, pos.y, m_icon.GetWidth(), m_icon.GetHeight()); } diff --git a/Source/3rd Party/wx/src/generic/editlbox.cpp b/Source/3rd Party/wx/src/generic/editlbox.cpp deleted file mode 100644 index a236e62f5..000000000 --- a/Source/3rd Party/wx/src/generic/editlbox.cpp +++ /dev/null @@ -1,402 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/editlbox.cpp -// Purpose: ListBox with editable items -// Author: Vaclav Slavik -// Copyright: (c) Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_EDITABLELISTBOX - -// for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWidgets headers) -#ifndef WX_PRECOMP - #include "wx/wx.h" -#endif - -#include "wx/editlbox.h" -#include "wx/sizer.h" -#include "wx/listctrl.h" - -// ============================================================================ -// implementation -// ============================================================================ - -const char wxEditableListBoxNameStr[] = "editableListBox"; - -static const char* const eledit_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #00007F", -" ", -" ", -" .. .. ", -" . ", -" . ", -" ++++ . ++++ ", -" ++ . ++ ++", -" +++++ . ++++++", -" ++ ++ . ++ ", -" ++ ++ . ++ ++", -" +++++ . ++++ ", -" . ", -" . ", -" .. .. ", -" ", -" "}; - -static const char* const elnew_xpm[] = { -"16 16 5 1", -" c None", -". c #7F7F7F", -"+ c #FFFFFF", -"@ c #FFFF00", -"# c #000000", -" ", -" ", -" . .+ .@ ", -" . .@.@# # # ", -" @.@+.... # ", -" ... @@ ", -" @ . @. # ", -" .# .@ ", -" . # ", -" # ", -" # ", -" # ", -" # ", -" # # # # # # ", -" ", -" "}; - -static const char* const eldel_xpm[] = { -"16 16 3 1", -" c None", -". c #7F0000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ..+ ..+ ", -" ....+ ..+ ", -" ....+ ..+ ", -" ...+ .+ ", -" .....+ ", -" ...+ ", -" .....+ ", -" ...+ ..+ ", -" ...+ ..+ ", -" ...+ .+ ", -" ...+ .+ ", -" . . ", -" "}; - -static const char* const eldown_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ... ", -" ... ", -" ... ", -" ... ", -" ... ", -" ... ", -" ........... ", -" ......... ", -" ....... ", -" ..... ", -" ... ", -" . ", -" ", -" "}; - -static const char* const elup_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" . ", -" ... ", -" ..... ", -" ....... ", -" ......... ", -" ........... ", -" ... ", -" ... ", -" ... ", -" ... ", -" ... ", -" ... ", -" ", -" ", -" "}; - -// list control with auto-resizable column: -class CleverListCtrl : public wxListCtrl -{ -public: - CleverListCtrl(wxWindow *parent, - wxWindowID id = wxID_ANY, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxLC_ICON, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr) - : wxListCtrl(parent, id, pos, size, style, validator, name) - { - CreateColumns(); - } - - void CreateColumns() - { - InsertColumn(0, wxT("item")); - SizeColumns(); - } - - void SizeColumns() - { - int w = GetSize().x; -#ifdef __WXMSW__ - w -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 6; -#else - w -= 2*wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); -#endif - if (w < 0) w = 0; - SetColumnWidth(0, w); - } - -private: - DECLARE_EVENT_TABLE() - void OnSize(wxSizeEvent& event) - { - SizeColumns(); - event.Skip(); - } -}; - -BEGIN_EVENT_TABLE(CleverListCtrl, wxListCtrl) - EVT_SIZE(CleverListCtrl::OnSize) -END_EVENT_TABLE() - - -// ---------------------------------------------------------------------------- -// wxEditableListBox -// ---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxEditableListBox, wxPanel) - -// NB: generate the IDs at runtime to avoid conflict with XRCID values, -// they could cause XRCCTRL() failures in XRC-based dialogs -const wxWindowIDRef wxID_ELB_DELETE = wxWindow::NewControlId(); -const wxWindowIDRef wxID_ELB_EDIT = wxWindow::NewControlId(); -const wxWindowIDRef wxID_ELB_NEW = wxWindow::NewControlId(); -const wxWindowIDRef wxID_ELB_UP = wxWindow::NewControlId(); -const wxWindowIDRef wxID_ELB_DOWN = wxWindow::NewControlId(); -const wxWindowIDRef wxID_ELB_LISTCTRL = wxWindow::NewControlId(); - -BEGIN_EVENT_TABLE(wxEditableListBox, wxPanel) - EVT_LIST_ITEM_SELECTED(wxID_ELB_LISTCTRL, wxEditableListBox::OnItemSelected) - EVT_LIST_END_LABEL_EDIT(wxID_ELB_LISTCTRL, wxEditableListBox::OnEndLabelEdit) - EVT_BUTTON(wxID_ELB_NEW, wxEditableListBox::OnNewItem) - EVT_BUTTON(wxID_ELB_UP, wxEditableListBox::OnUpItem) - EVT_BUTTON(wxID_ELB_DOWN, wxEditableListBox::OnDownItem) - EVT_BUTTON(wxID_ELB_EDIT, wxEditableListBox::OnEditItem) - EVT_BUTTON(wxID_ELB_DELETE, wxEditableListBox::OnDelItem) -END_EVENT_TABLE() - -bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos, const wxSize& size, - long style, - const wxString& name) -{ - if (!wxPanel::Create(parent, id, pos, size, wxTAB_TRAVERSAL, name)) - return false; - - m_style = style; - - wxSizer *sizer = new wxBoxSizer(wxVERTICAL); - - wxPanel *subp = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxSUNKEN_BORDER | wxTAB_TRAVERSAL); - wxSizer *subsizer = new wxBoxSizer(wxHORIZONTAL); - subsizer->Add(new wxStaticText(subp, wxID_ANY, label), 1, wxALIGN_CENTRE_VERTICAL | wxLEFT, 4); - -#ifdef __WXMSW__ - #define BTN_BORDER 4 - // FIXME - why is this needed? There's some reason why sunken border is - // ignored by sizers in wxMSW but not in wxGTK that I can't - // figure out... -#else - #define BTN_BORDER 0 -#endif - - if ( m_style & wxEL_ALLOW_EDIT ) - { - m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxBitmap(eledit_xpm)); - subsizer->Add(m_bEdit, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); - } - - if ( m_style & wxEL_ALLOW_NEW ) - { - m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxBitmap(elnew_xpm)); - subsizer->Add(m_bNew, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); - } - - if ( m_style & wxEL_ALLOW_DELETE ) - { - m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxBitmap(eldel_xpm)); - subsizer->Add(m_bDel, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); - } - - if (!(m_style & wxEL_NO_REORDER)) - { - m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxBitmap(elup_xpm)); - subsizer->Add(m_bUp, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); - - m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxBitmap(eldown_xpm)); - subsizer->Add(m_bDown, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); - } - -#if wxUSE_TOOLTIPS - if ( m_bEdit ) m_bEdit->SetToolTip(_("Edit item")); - if ( m_bNew ) m_bNew->SetToolTip(_("New item")); - if ( m_bDel ) m_bDel->SetToolTip(_("Delete item")); - if ( m_bUp ) m_bUp->SetToolTip(_("Move up")); - if ( m_bDown ) m_bDown->SetToolTip(_("Move down")); -#endif - - subp->SetSizer(subsizer); - subsizer->Fit(subp); - - sizer->Add(subp, 0, wxEXPAND); - - long st = wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxSUNKEN_BORDER; - if ( style & wxEL_ALLOW_EDIT ) - st |= wxLC_EDIT_LABELS; - m_listCtrl = new CleverListCtrl(this, wxID_ELB_LISTCTRL, - wxDefaultPosition, wxDefaultSize, st); - wxArrayString empty_ar; - SetStrings(empty_ar); - - sizer->Add(m_listCtrl, 1, wxEXPAND); - - SetSizer(sizer); - Layout(); - - return true; -} - -void wxEditableListBox::SetStrings(const wxArrayString& strings) -{ - m_listCtrl->DeleteAllItems(); - size_t i; - - for (i = 0; i < strings.GetCount(); i++) - m_listCtrl->InsertItem(i, strings[i]); - - m_listCtrl->InsertItem(strings.GetCount(), wxEmptyString); - m_listCtrl->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); -} - -void wxEditableListBox::GetStrings(wxArrayString& strings) const -{ - strings.Clear(); - - for (int i = 0; i < m_listCtrl->GetItemCount()-1; i++) - strings.Add(m_listCtrl->GetItemText(i)); -} - -void wxEditableListBox::OnItemSelected(wxListEvent& event) -{ - m_selection = event.GetIndex(); - if (!(m_style & wxEL_NO_REORDER)) - { - m_bUp->Enable(m_selection != 0 && m_selection < m_listCtrl->GetItemCount()-1); - m_bDown->Enable(m_selection < m_listCtrl->GetItemCount()-2); - } - - if (m_style & wxEL_ALLOW_EDIT) - m_bEdit->Enable(m_selection < m_listCtrl->GetItemCount()-1); - if (m_style & wxEL_ALLOW_DELETE) - m_bDel->Enable(m_selection < m_listCtrl->GetItemCount()-1); -} - -void wxEditableListBox::OnNewItem(wxCommandEvent& WXUNUSED(event)) -{ - m_listCtrl->SetItemState(m_listCtrl->GetItemCount()-1, - wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - m_listCtrl->EditLabel(m_selection); -} - -void wxEditableListBox::OnEndLabelEdit(wxListEvent& event) -{ - if ( event.GetIndex() == m_listCtrl->GetItemCount()-1 && - !event.GetText().empty() ) - { - // The user edited last (empty) line, i.e. added new entry. We have to - // add new empty line here so that adding one more line is still - // possible: - m_listCtrl->InsertItem(m_listCtrl->GetItemCount(), wxEmptyString); - - // Simulate a wxEVT_LIST_ITEM_SELECTED event for the new item, - // so that the buttons are enabled/disabled properly - wxListEvent selectionEvent(wxEVT_LIST_ITEM_SELECTED, m_listCtrl->GetId()); - selectionEvent.m_itemIndex = event.GetIndex(); - m_listCtrl->GetEventHandler()->ProcessEvent(selectionEvent); - } -} - -void wxEditableListBox::OnDelItem(wxCommandEvent& WXUNUSED(event)) -{ - m_listCtrl->DeleteItem(m_selection); - m_listCtrl->SetItemState(m_selection, - wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); -} - -void wxEditableListBox::OnEditItem(wxCommandEvent& WXUNUSED(event)) -{ - m_listCtrl->EditLabel(m_selection); -} - -void wxEditableListBox::SwapItems(long i1, long i2) -{ - // swap the text - wxString t1 = m_listCtrl->GetItemText(i1); - wxString t2 = m_listCtrl->GetItemText(i2); - m_listCtrl->SetItemText(i1, t2); - m_listCtrl->SetItemText(i2, t1); - - // swap the item data - wxUIntPtr d1 = m_listCtrl->GetItemData(i1); - wxUIntPtr d2 = m_listCtrl->GetItemData(i2); - m_listCtrl->SetItemPtrData(i1, d2); - m_listCtrl->SetItemPtrData(i2, d1); -} - - -void wxEditableListBox::OnUpItem(wxCommandEvent& WXUNUSED(event)) -{ - SwapItems(m_selection - 1, m_selection); - m_listCtrl->SetItemState(m_selection - 1, - wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); -} - -void wxEditableListBox::OnDownItem(wxCommandEvent& WXUNUSED(event)) -{ - SwapItems(m_selection + 1, m_selection); - m_listCtrl->SetItemState(m_selection + 1, - wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); -} - -#endif // wxUSE_EDITABLELISTBOX diff --git a/Source/3rd Party/wx/src/generic/fdrepdlg.cpp b/Source/3rd Party/wx/src/generic/fdrepdlg.cpp deleted file mode 100644 index af1ebb03e..000000000 --- a/Source/3rd Party/wx/src/generic/fdrepdlg.cpp +++ /dev/null @@ -1,292 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/fdrepdlg.cpp -// Purpose: Find/Replace dialogs -// Author: Markus Greither and Vadim Zeitlin -// Modified by: -// Created: 05/25/01 -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_FINDREPLDLG - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" - - #include "wx/sizer.h" - - #include "wx/button.h" - #include "wx/checkbox.h" - #include "wx/radiobox.h" - #include "wx/stattext.h" - #include "wx/textctrl.h" - #include "wx/settings.h" -#endif - -#include "wx/fdrepdlg.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// ============================================================================ -// implementation -// ============================================================================ - -IMPLEMENT_DYNAMIC_CLASS(wxGenericFindReplaceDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxGenericFindReplaceDialog, wxDialog) - EVT_BUTTON(wxID_FIND, wxGenericFindReplaceDialog::OnFind) - EVT_BUTTON(wxID_REPLACE, wxGenericFindReplaceDialog::OnReplace) - EVT_BUTTON(wxID_REPLACE_ALL, wxGenericFindReplaceDialog::OnReplaceAll) - EVT_BUTTON(wxID_CANCEL, wxGenericFindReplaceDialog::OnCancel) - - EVT_UPDATE_UI(wxID_FIND, wxGenericFindReplaceDialog::OnUpdateFindUI) - EVT_UPDATE_UI(wxID_REPLACE, wxGenericFindReplaceDialog::OnUpdateFindUI) - EVT_UPDATE_UI(wxID_REPLACE_ALL, wxGenericFindReplaceDialog::OnUpdateFindUI) - - EVT_CLOSE(wxGenericFindReplaceDialog::OnCloseWindow) -END_EVENT_TABLE() - -// ---------------------------------------------------------------------------- -// wxGenericFindReplaceDialog -// ---------------------------------------------------------------------------- - -void wxGenericFindReplaceDialog::Init() -{ - m_FindReplaceData = NULL; - - m_chkWord = - m_chkCase = NULL; - - m_radioDir = NULL; - - m_textFind = - m_textRepl = NULL; -} - -bool wxGenericFindReplaceDialog::Create(wxWindow *parent, - wxFindReplaceData *data, - const wxString& title, - int style) -{ - parent = GetParentForModalDialog(parent, style); - - if ( !wxDialog::Create(parent, wxID_ANY, title, - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER - | style) ) - { - return false; - } - - SetData(data); - - wxCHECK_MSG( m_FindReplaceData, false, - wxT("can't create dialog without data") ); - - bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - - wxBoxSizer *leftsizer = new wxBoxSizer( wxVERTICAL ); - - // 3 columns because there is a spacer in the middle - wxFlexGridSizer *sizer2Col = new wxFlexGridSizer(3); - sizer2Col->AddGrowableCol(2); - - sizer2Col->Add(new wxStaticText(this, wxID_ANY, _("Search for:"), - wxDefaultPosition, wxSize(80, wxDefaultCoord)), - 0, - wxALIGN_CENTRE_VERTICAL | wxALIGN_RIGHT); - - sizer2Col->Add(10, 0); - - m_textFind = new wxTextCtrl(this, wxID_ANY, m_FindReplaceData->GetFindString()); - sizer2Col->Add(m_textFind, 1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); - - if ( style & wxFR_REPLACEDIALOG ) - { - sizer2Col->Add(new wxStaticText(this, wxID_ANY, _("Replace with:"), - wxDefaultPosition, wxSize(80, wxDefaultCoord)), - 0, - wxALIGN_CENTRE_VERTICAL | - wxALIGN_RIGHT | wxTOP, 5); - - sizer2Col->Add(isPda ? 2 : 10, 0); - - m_textRepl = new wxTextCtrl(this, wxID_ANY, - m_FindReplaceData->GetReplaceString()); - sizer2Col->Add(m_textRepl, 1, - wxALIGN_CENTRE_VERTICAL | wxEXPAND | wxTOP, 5); - } - - leftsizer->Add(sizer2Col, 0, wxEXPAND | wxALL, 5); - - wxBoxSizer *optsizer = new wxBoxSizer( isPda ? wxVERTICAL : wxHORIZONTAL ); - - wxBoxSizer *chksizer = new wxBoxSizer( wxVERTICAL); - - m_chkWord = new wxCheckBox(this, wxID_ANY, _("Whole word")); - chksizer->Add(m_chkWord, 0, wxALL, 3); - - m_chkCase = new wxCheckBox(this, wxID_ANY, _("Match case")); - chksizer->Add(m_chkCase, 0, wxALL, 3); - - optsizer->Add(chksizer, 0, wxALL, 10); - - static const wxString searchDirections[] = {_("Up"), _("Down")}; - int majorDimension = 0; - int rbStyle ; - if (isPda) - rbStyle = wxRA_SPECIFY_ROWS; - else - rbStyle = wxRA_SPECIFY_COLS; - - m_radioDir = new wxRadioBox(this, wxID_ANY, _("Search direction"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(searchDirections), searchDirections, - majorDimension, rbStyle); - - optsizer->Add(m_radioDir, 0, wxALL, isPda ? 5 : 10); - - leftsizer->Add(optsizer); - - wxBoxSizer *bttnsizer = new wxBoxSizer(wxVERTICAL); - - wxButton* btn = new wxButton(this, wxID_FIND); - btn->SetDefault(); - bttnsizer->Add(btn, 0, wxALL, 3); - - bttnsizer->Add(new wxButton(this, wxID_CANCEL), 0, wxALL, 3); - - if ( style & wxFR_REPLACEDIALOG ) - { - bttnsizer->Add(new wxButton(this, wxID_REPLACE, _("&Replace")), - 0, wxALL, 3); - - bttnsizer->Add(new wxButton(this, wxID_REPLACE_ALL, _("Replace &all")), - 0, wxALL, 3); - } - - wxBoxSizer *topsizer = new wxBoxSizer( wxHORIZONTAL ); - - topsizer->Add(leftsizer, 1, wxALL, isPda ? 0 : 5); - topsizer->Add(bttnsizer, 0, wxALL, isPda ? 0 : 5); - - int flags = m_FindReplaceData->GetFlags(); - - if ( flags & wxFR_MATCHCASE ) - m_chkCase->SetValue(true); - - if ( flags & wxFR_WHOLEWORD ) - m_chkWord->SetValue(true); - - m_radioDir->SetSelection( flags & wxFR_DOWN ); - - if ( style & wxFR_NOMATCHCASE ) - m_chkCase->Enable(false); - - if ( style & wxFR_NOWHOLEWORD ) - m_chkWord->Enable(false); - - if ( style & wxFR_NOUPDOWN) - m_radioDir->Enable(false); - - SetAutoLayout( true ); - SetSizer( topsizer ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - - Centre( wxBOTH ); - - m_textFind->SetFocus(); - - return true; -} - -// ---------------------------------------------------------------------------- -// send the notification event -// ---------------------------------------------------------------------------- - -void wxGenericFindReplaceDialog::SendEvent(const wxEventType& evtType) -{ - wxFindDialogEvent event(evtType, GetId()); - event.SetEventObject(this); - event.SetFindString(m_textFind->GetValue()); - if ( HasFlag(wxFR_REPLACEDIALOG) ) - { - event.SetReplaceString(m_textRepl->GetValue()); - } - - int flags = 0; - - if ( m_chkCase->GetValue() ) - flags |= wxFR_MATCHCASE; - - if ( m_chkWord->GetValue() ) - flags |= wxFR_WHOLEWORD; - - if ( !m_radioDir || m_radioDir->GetSelection() == 1 ) - { - flags |= wxFR_DOWN; - } - - event.SetFlags(flags); - - wxFindReplaceDialogBase::Send(event); -} - -// ---------------------------------------------------------------------------- -// event handlers -// ---------------------------------------------------------------------------- - -void wxGenericFindReplaceDialog::OnFind(wxCommandEvent& WXUNUSED(event)) -{ - SendEvent(wxEVT_FIND_NEXT); -} - -void wxGenericFindReplaceDialog::OnReplace(wxCommandEvent& WXUNUSED(event)) -{ - SendEvent(wxEVT_FIND_REPLACE); -} - -void wxGenericFindReplaceDialog::OnReplaceAll(wxCommandEvent& WXUNUSED(event)) -{ - SendEvent(wxEVT_FIND_REPLACE_ALL); -} - -void wxGenericFindReplaceDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ - SendEvent(wxEVT_FIND_CLOSE); - - Show(false); -} - -void wxGenericFindReplaceDialog::OnUpdateFindUI(wxUpdateUIEvent &event) -{ - // we can't search for empty strings - event.Enable( !m_textFind->GetValue().empty() ); -} - -void wxGenericFindReplaceDialog::OnCloseWindow(wxCloseEvent &) -{ - SendEvent(wxEVT_FIND_CLOSE); -} - -#endif // wxUSE_FINDREPLDLG diff --git a/Source/3rd Party/wx/src/generic/filectrlg.cpp b/Source/3rd Party/wx/src/generic/filectrlg.cpp deleted file mode 100644 index 1dfba4421..000000000 --- a/Source/3rd Party/wx/src/generic/filectrlg.cpp +++ /dev/null @@ -1,1479 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/filectrlg.cpp -// Purpose: wxGenericFileCtrl Implementation -// Author: Diaa M. Sami -// Created: 2007-07-07 -// Copyright: (c) Diaa M. Sami -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_FILECTRL - -#include "wx/generic/filectrlg.h" - -#ifndef WX_PRECOMP - #include "wx/settings.h" - #include "wx/sizer.h" - #include "wx/stattext.h" - #include "wx/checkbox.h" - #include "wx/msgdlg.h" - #include "wx/log.h" - #include "wx/filedlg.h" -#endif - -#include "wx/clntdata.h" -#include "wx/file.h" // for wxS_IXXX constants only -#include "wx/generic/dirctrlg.h" // for wxFileIconsTable -#include "wx/dir.h" -#include "wx/tokenzr.h" -#include "wx/imaglist.h" - -#ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" -#endif - -#if defined(__WXWINCE__) -#define IsTopMostDir(dir) (dir == wxT("\\") || dir == wxT("/")) -#elif (defined(__DOS__) || defined(__WINDOWS__) || defined (__OS2__)) -#define IsTopMostDir(dir) (dir.empty()) -#else -#define IsTopMostDir(dir) (dir == wxT("/")) -#endif - - -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -static -int wxCALLBACK wxFileDataNameCompare( wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) -{ - wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); - wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); - - if (fd1->GetFileName() == wxT("..")) - return -sortOrder; - if (fd2->GetFileName() == wxT("..")) - return sortOrder; - if (fd1->IsDir() && !fd2->IsDir()) - return -sortOrder; - if (fd2->IsDir() && !fd1->IsDir()) - return sortOrder; - - return sortOrder*wxStrcmp( fd1->GetFileName(), fd2->GetFileName() ); -} - -static -int wxCALLBACK wxFileDataSizeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) -{ - wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); - wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); - - if (fd1->GetFileName() == wxT("..")) - return -sortOrder; - if (fd2->GetFileName() == wxT("..")) - return sortOrder; - if (fd1->IsDir() && !fd2->IsDir()) - return -sortOrder; - if (fd2->IsDir() && !fd1->IsDir()) - return sortOrder; - if (fd1->IsLink() && !fd2->IsLink()) - return -sortOrder; - if (fd2->IsLink() && !fd1->IsLink()) - return sortOrder; - - return fd1->GetSize() > fd2->GetSize() ? sortOrder : -sortOrder; -} - -static -int wxCALLBACK wxFileDataTypeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) -{ - wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); - wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); - - if (fd1->GetFileName() == wxT("..")) - return -sortOrder; - if (fd2->GetFileName() == wxT("..")) - return sortOrder; - if (fd1->IsDir() && !fd2->IsDir()) - return -sortOrder; - if (fd2->IsDir() && !fd1->IsDir()) - return sortOrder; - if (fd1->IsLink() && !fd2->IsLink()) - return -sortOrder; - if (fd2->IsLink() && !fd1->IsLink()) - return sortOrder; - - return sortOrder*wxStrcmp( fd1->GetFileType(), fd2->GetFileType() ); -} - -static -int wxCALLBACK wxFileDataTimeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) -{ - wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); - wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); - - if (fd1->GetFileName() == wxT("..")) - return -sortOrder; - if (fd2->GetFileName() == wxT("..")) - return sortOrder; - if (fd1->IsDir() && !fd2->IsDir()) - return -sortOrder; - if (fd2->IsDir() && !fd1->IsDir()) - return sortOrder; - - return fd1->GetDateTime().IsLaterThan(fd2->GetDateTime()) ? sortOrder : -sortOrder; -} - -// defined in src/generic/dirctrlg.cpp -extern size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids); - -//----------------------------------------------------------------------------- -// wxFileData -//----------------------------------------------------------------------------- - -wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, fileType type, int image_id ) -{ - Init(); - m_fileName = fileName; - m_filePath = filePath; - m_type = type; - m_image = image_id; - - ReadData(); -} - -void wxFileData::Init() -{ - m_size = 0; - m_type = wxFileData::is_file; - m_image = wxFileIconsTable::file; -} - -void wxFileData::Copy( const wxFileData& fileData ) -{ - m_fileName = fileData.GetFileName(); - m_filePath = fileData.GetFilePath(); - m_size = fileData.GetSize(); - m_dateTime = fileData.GetDateTime(); - m_permissions = fileData.GetPermissions(); - m_type = fileData.GetType(); - m_image = fileData.GetImageId(); -} - -void wxFileData::ReadData() -{ - if (IsDrive()) - { - m_size = 0; - return; - } - -#if defined(__DOS__) || (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__OS2__) - // c:\.. is a drive don't stat it - if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5)) - { - m_type = is_drive; - m_size = 0; - return; - } -#endif // __DOS__ || __WINDOWS__ - -#ifdef __WXWINCE__ - - // WinCE - - DWORD fileAttribs = GetFileAttributes(m_filePath.fn_str()); - m_type |= (fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0 ? is_dir : 0; - - wxString p, f, ext; - wxFileName::SplitPath(m_filePath, & p, & f, & ext); - if (wxStricmp(ext, wxT("exe")) == 0) - m_type |= is_exe; - - // Find out size - m_size = 0; - HANDLE fileHandle = CreateFile(m_filePath.fn_str(), - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (fileHandle != INVALID_HANDLE_VALUE) - { - m_size = GetFileSize(fileHandle, 0); - CloseHandle(fileHandle); - } - - m_dateTime = wxFileModificationTime(m_filePath); - -#else - - // OTHER PLATFORMS - - wxStructStat buff; - -#if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS)) - const bool hasStat = lstat( m_filePath.fn_str(), &buff ) == 0; - if ( hasStat ) - m_type |= S_ISLNK(buff.st_mode) ? is_link : 0; -#else // no lstat() - const bool hasStat = wxStat( m_filePath, &buff ) == 0; -#endif - - if ( hasStat ) - { - m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0; - m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0; - - m_size = buff.st_size; - - m_dateTime = buff.st_mtime; - } -#endif - // __WXWINCE__ - -#if defined(__UNIX__) - if ( hasStat ) - { - m_permissions.Printf(wxT("%c%c%c%c%c%c%c%c%c"), - buff.st_mode & wxS_IRUSR ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWUSR ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXUSR ? wxT('x') : wxT('-'), - buff.st_mode & wxS_IRGRP ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWGRP ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXGRP ? wxT('x') : wxT('-'), - buff.st_mode & wxS_IROTH ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWOTH ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXOTH ? wxT('x') : wxT('-')); - } -#elif defined(__WIN32__) - DWORD attribs = ::GetFileAttributes(m_filePath.c_str()); - if (attribs != (DWORD)-1) - { - m_permissions.Printf(wxT("%c%c%c%c"), - attribs & FILE_ATTRIBUTE_ARCHIVE ? wxT('A') : wxT(' '), - attribs & FILE_ATTRIBUTE_READONLY ? wxT('R') : wxT(' '), - attribs & FILE_ATTRIBUTE_HIDDEN ? wxT('H') : wxT(' '), - attribs & FILE_ATTRIBUTE_SYSTEM ? wxT('S') : wxT(' ')); - } -#endif - - // try to get a better icon - if (m_image == wxFileIconsTable::file) - { - if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND) - { - m_image = wxTheFileIconsTable->GetIconID( m_fileName.AfterLast(wxT('.'))); - } else if (IsExe()) - { - m_image = wxFileIconsTable::executable; - } - } -} - -wxString wxFileData::GetFileType() const -{ - if (IsDir()) - return _(""); - else if (IsLink()) - return _(""); - else if (IsDrive()) - return _(""); - else if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND) - return m_fileName.AfterLast(wxT('.')); - - return wxEmptyString; -} - -wxString wxFileData::GetModificationTime() const -{ - // want time as 01:02 so they line up nicely, no %r in WIN32 - return m_dateTime.FormatDate() + wxT(" ") + m_dateTime.Format(wxT("%I:%M:%S %p")); -} - -wxString wxFileData::GetHint() const -{ - wxString s = m_filePath; - s += wxT(" "); - - if (IsDir()) - s += _(""); - else if (IsLink()) - s += _(""); - else if (IsDrive()) - s += _(""); - else // plain file - s += wxString::Format(wxPLURAL("%ld byte", "%ld bytes", m_size), - wxLongLong(m_size).ToString().c_str()); - - s += wxT(' '); - - if ( !IsDrive() ) - { - s << GetModificationTime() - << wxT(" ") - << m_permissions; - } - - return s; -} - -wxString wxFileData::GetEntry( fileListFieldType num ) const -{ - wxString s; - switch ( num ) - { - case FileList_Name: - s = m_fileName; - break; - - case FileList_Size: - if (!IsDir() && !IsLink() && !IsDrive()) - s = wxLongLong(m_size).ToString(); - break; - - case FileList_Type: - s = GetFileType(); - break; - - case FileList_Time: - if (!IsDrive()) - s = GetModificationTime(); - break; - -#if defined(__UNIX__) || defined(__WIN32__) - case FileList_Perm: - s = m_permissions; - break; -#endif // defined(__UNIX__) || defined(__WIN32__) - - default: - wxFAIL_MSG( wxT("unexpected field in wxFileData::GetEntry()") ); - } - - return s; -} - -void wxFileData::SetNewName( const wxString &filePath, const wxString &fileName ) -{ - m_fileName = fileName; - m_filePath = filePath; -} - -void wxFileData::MakeItem( wxListItem &item ) -{ - item.m_text = m_fileName; - item.ClearAttributes(); - if (IsExe()) - item.SetTextColour(*wxRED); - if (IsDir()) - item.SetTextColour(*wxBLUE); - - item.m_image = m_image; - - if (IsLink()) - { - wxColour dg = wxTheColourDatabase->Find( wxT("MEDIUM GREY") ); - if ( dg.IsOk() ) - item.SetTextColour(dg); - } - item.m_data = wxPtrToUInt(this); -} - -//----------------------------------------------------------------------------- -// wxFileListCtrl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFileListCtrl,wxListCtrl) - -BEGIN_EVENT_TABLE(wxFileListCtrl,wxListCtrl) - EVT_LIST_DELETE_ITEM(wxID_ANY, wxFileListCtrl::OnListDeleteItem) - EVT_LIST_DELETE_ALL_ITEMS(wxID_ANY, wxFileListCtrl::OnListDeleteAllItems) - EVT_LIST_END_LABEL_EDIT(wxID_ANY, wxFileListCtrl::OnListEndLabelEdit) - EVT_LIST_COL_CLICK(wxID_ANY, wxFileListCtrl::OnListColClick) -END_EVENT_TABLE() - - -wxFileListCtrl::wxFileListCtrl() -{ - m_showHidden = false; - m_sort_forward = true; - m_sort_field = wxFileData::FileList_Name; -} - -wxFileListCtrl::wxFileListCtrl(wxWindow *win, - wxWindowID id, - const wxString& wild, - bool showHidden, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator &validator, - const wxString &name) - : wxListCtrl(win, id, pos, size, style, validator, name), - m_wild(wild) -{ - wxImageList *imageList = wxTheFileIconsTable->GetSmallImageList(); - - SetImageList( imageList, wxIMAGE_LIST_SMALL ); - - m_showHidden = showHidden; - - m_sort_forward = true; - m_sort_field = wxFileData::FileList_Name; - - m_dirName = wxT("*"); - - if (style & wxLC_REPORT) - ChangeToReportMode(); -} - -void wxFileListCtrl::ChangeToListMode() -{ - ClearAll(); - SetSingleStyle( wxLC_LIST ); - UpdateFiles(); -} - -void wxFileListCtrl::ChangeToReportMode() -{ - ClearAll(); - SetSingleStyle( wxLC_REPORT ); - - // do this since WIN32 does mm/dd/yy UNIX does mm/dd/yyyy - // don't hardcode since mm/dd is dd/mm elsewhere - int w, h; - wxDateTime dt(22, wxDateTime::Dec, 2002, 22, 22, 22); - wxString txt = dt.FormatDate() + wxT("22") + dt.Format(wxT("%I:%M:%S %p")); - GetTextExtent(txt, &w, &h); - - InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT, w ); - InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT, w/2 ); - InsertColumn( 2, _("Type"), wxLIST_FORMAT_LEFT, w/2 ); - InsertColumn( 3, _("Modified"), wxLIST_FORMAT_LEFT, w ); -#if defined(__UNIX__) - GetTextExtent(wxT("Permissions 2"), &w, &h); - InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT, w ); -#elif defined(__WIN32__) - GetTextExtent(wxT("Attributes 2"), &w, &h); - InsertColumn( 4, _("Attributes"), wxLIST_FORMAT_LEFT, w ); -#endif - - UpdateFiles(); -} - -void wxFileListCtrl::ChangeToSmallIconMode() -{ - ClearAll(); - SetSingleStyle( wxLC_SMALL_ICON ); - UpdateFiles(); -} - -void wxFileListCtrl::ShowHidden( bool show ) -{ - m_showHidden = show; - UpdateFiles(); -} - -long wxFileListCtrl::Add( wxFileData *fd, wxListItem &item ) -{ - long ret = -1; - item.m_mask = wxLIST_MASK_TEXT + wxLIST_MASK_DATA + wxLIST_MASK_IMAGE; - fd->MakeItem( item ); - long my_style = GetWindowStyleFlag(); - if (my_style & wxLC_REPORT) - { - ret = InsertItem( item ); - for (int i = 1; i < wxFileData::FileList_Max; i++) - SetItem( item.m_itemId, i, fd->GetEntry((wxFileData::fileListFieldType)i) ); - } - else if ((my_style & wxLC_LIST) || (my_style & wxLC_SMALL_ICON)) - { - ret = InsertItem( item ); - } - return ret; -} - -void wxFileListCtrl::UpdateItem(const wxListItem &item) -{ - wxFileData *fd = (wxFileData*)GetItemData(item); - wxCHECK_RET(fd, wxT("invalid filedata")); - - fd->ReadData(); - - SetItemText(item, fd->GetFileName()); - SetItemImage(item, fd->GetImageId()); - - if (GetWindowStyleFlag() & wxLC_REPORT) - { - for (int i = 1; i < wxFileData::FileList_Max; i++) - SetItem( item.m_itemId, i, fd->GetEntry((wxFileData::fileListFieldType)i) ); - } -} - -void wxFileListCtrl::UpdateFiles() -{ - // don't do anything before ShowModal() call which sets m_dirName - if ( m_dirName == wxT("*") ) - return; - - wxBusyCursor bcur; // this may take a while... - - DeleteAllItems(); - - wxListItem item; - item.m_itemId = 0; - item.m_col = 0; - -#if (defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__)) && !defined(__WXWINCE__) - if ( IsTopMostDir(m_dirName) ) - { - wxArrayString names, paths; - wxArrayInt icons; - const size_t count = wxGetAvailableDrives(paths, names, icons); - - for ( size_t n = 0; n < count; n++ ) - { - // use paths[n] as the drive name too as our HandleAction() can't - // deal with the drive names (of the form "System (C:)") currently - // as it mistakenly treats them as file names - // - // it would be preferable to show names, and not paths, in the - // dialog just as the native dialog does but for this we must: - // a) store the item type as item data and modify HandleAction() - // to use it instead of wxDirExists() to check whether the item - // is a directory - // b) store the drives by their drive letters and not their - // descriptions as otherwise it's pretty confusing to the user - wxFileData *fd = new wxFileData(paths[n], paths[n], - wxFileData::is_drive, icons[n]); - if (Add(fd, item) != -1) - item.m_itemId++; - else - delete fd; - } - } - else -#endif // defined(__DOS__) || defined(__WINDOWS__) - { - // Real directory... - if ( !IsTopMostDir(m_dirName) && !m_dirName.empty() ) - { - wxString p(wxPathOnly(m_dirName)); -#if (defined(__UNIX__) || defined(__WXWINCE__)) && !defined(__OS2__) - if (p.empty()) p = wxT("/"); -#endif // __UNIX__ - wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder); - if (Add(fd, item) != -1) - item.m_itemId++; - else - delete fd; - } - - wxString dirname(m_dirName); -#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) - if (dirname.length() == 2 && dirname[1u] == wxT(':')) - dirname << wxT('\\'); -#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) - - if (dirname.empty()) - dirname = wxFILE_SEP_PATH; - - wxLogNull logNull; - wxDir dir(dirname); - - if ( dir.IsOpened() ) - { - wxString dirPrefix(dirname); - if (dirPrefix.Last() != wxFILE_SEP_PATH) - dirPrefix += wxFILE_SEP_PATH; - - int hiddenFlag = m_showHidden ? wxDIR_HIDDEN : 0; - - bool cont; - wxString f; - - // Get the directories first (not matched against wildcards): - cont = dir.GetFirst(&f, wxEmptyString, wxDIR_DIRS | hiddenFlag); - while (cont) - { - wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder); - if (Add(fd, item) != -1) - item.m_itemId++; - else - delete fd; - - cont = dir.GetNext(&f); - } - - // Tokenize the wildcard string, so we can handle more than 1 - // search pattern in a wildcard. - wxStringTokenizer tokenWild(m_wild, wxT(";")); - while ( tokenWild.HasMoreTokens() ) - { - cont = dir.GetFirst(&f, tokenWild.GetNextToken(), - wxDIR_FILES | hiddenFlag); - while (cont) - { - wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file); - if (Add(fd, item) != -1) - item.m_itemId++; - else - delete fd; - - cont = dir.GetNext(&f); - } - } - } - } - - SortItems(m_sort_field, m_sort_forward); -} - -void wxFileListCtrl::SetWild( const wxString &wild ) -{ - if (wild.Find(wxT('|')) != wxNOT_FOUND) - return; - - m_wild = wild; - UpdateFiles(); -} - -void wxFileListCtrl::MakeDir() -{ - wxString new_name( _("NewName") ); - wxString path( m_dirName ); - path += wxFILE_SEP_PATH; - path += new_name; - if (wxFileExists(path)) - { - // try NewName0, NewName1 etc. - int i = 0; - do { - new_name = _("NewName"); - wxString num; - num.Printf( wxT("%d"), i ); - new_name += num; - - path = m_dirName; - path += wxFILE_SEP_PATH; - path += new_name; - i++; - } while (wxFileExists(path)); - } - - wxLogNull log; - if (!wxMkdir(path)) - { - wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR ); - dialog.ShowModal(); - return; - } - - wxFileData *fd = new wxFileData( path, new_name, wxFileData::is_dir, wxFileIconsTable::folder ); - wxListItem item; - item.m_itemId = 0; - item.m_col = 0; - long itemid = Add( fd, item ); - - if (itemid != -1) - { - SortItems(m_sort_field, m_sort_forward); - itemid = FindItem( 0, wxPtrToUInt(fd) ); - EnsureVisible( itemid ); - EditLabel( itemid ); - } - else - delete fd; -} - -void wxFileListCtrl::GoToParentDir() -{ - if (!IsTopMostDir(m_dirName)) - { - size_t len = m_dirName.length(); - if (wxEndsWithPathSeparator(m_dirName)) - m_dirName.Remove( len-1, 1 ); - wxString fname( wxFileNameFromPath(m_dirName) ); - m_dirName = wxPathOnly( m_dirName ); -#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) - if (!m_dirName.empty()) - { - if (m_dirName.Last() == wxT('.')) - m_dirName = wxEmptyString; - } -#elif defined(__UNIX__) - if (m_dirName.empty()) - m_dirName = wxT("/"); -#endif - UpdateFiles(); - long id = FindItem( 0, fname ); - if (id != wxNOT_FOUND) - { - SetItemState( id, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - EnsureVisible( id ); - } - } -} - -void wxFileListCtrl::GoToHomeDir() -{ - wxString s = wxGetUserHome( wxString() ); - GoToDir(s); -} - -void wxFileListCtrl::GoToDir( const wxString &dir ) -{ - if (!wxDirExists(dir)) return; - - m_dirName = dir; - UpdateFiles(); - - SetItemState( 0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - - EnsureVisible( 0 ); -} - -void wxFileListCtrl::FreeItemData(wxListItem& item) -{ - if ( item.m_data ) - { - wxFileData *fd = (wxFileData*)item.m_data; - delete fd; - - item.m_data = 0; - } -} - -void wxFileListCtrl::OnListDeleteItem( wxListEvent &event ) -{ - FreeItemData(event.m_item); -} - -void wxFileListCtrl::OnListDeleteAllItems( wxListEvent & WXUNUSED(event) ) -{ - FreeAllItemsData(); -} - -void wxFileListCtrl::FreeAllItemsData() -{ - wxListItem item; - item.m_mask = wxLIST_MASK_DATA; - - item.m_itemId = GetNextItem( -1, wxLIST_NEXT_ALL ); - while ( item.m_itemId != -1 ) - { - GetItem( item ); - FreeItemData(item); - item.m_itemId = GetNextItem( item.m_itemId, wxLIST_NEXT_ALL ); - } -} - -void wxFileListCtrl::OnListEndLabelEdit( wxListEvent &event ) -{ - wxFileData *fd = (wxFileData*)event.m_item.m_data; - wxASSERT( fd ); - - if ((event.GetLabel().empty()) || - (event.GetLabel() == wxT(".")) || - (event.GetLabel() == wxT("..")) || - (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND)) - { - wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR ); - dialog.ShowModal(); - event.Veto(); - return; - } - - wxString new_name( wxPathOnly( fd->GetFilePath() ) ); - new_name += wxFILE_SEP_PATH; - new_name += event.GetLabel(); - - wxLogNull log; - - if (wxFileExists(new_name)) - { - wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR ); - dialog.ShowModal(); - event.Veto(); - } - - if (wxRenameFile(fd->GetFilePath(),new_name)) - { - fd->SetNewName( new_name, event.GetLabel() ); - - SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - - UpdateItem( event.GetItem() ); - EnsureVisible( event.GetItem() ); - } - else - { - wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR ); - dialog.ShowModal(); - event.Veto(); - } -} - -void wxFileListCtrl::OnListColClick( wxListEvent &event ) -{ - int col = event.GetColumn(); - - switch (col) - { - case wxFileData::FileList_Name : - case wxFileData::FileList_Size : - case wxFileData::FileList_Type : - case wxFileData::FileList_Time : break; - default : return; - } - - if ((wxFileData::fileListFieldType)col == m_sort_field) - m_sort_forward = !m_sort_forward; - else - m_sort_field = (wxFileData::fileListFieldType)col; - - SortItems(m_sort_field, m_sort_forward); -} - -void wxFileListCtrl::SortItems(wxFileData::fileListFieldType field, bool forward) -{ - m_sort_field = field; - m_sort_forward = forward; - const long sort_dir = forward ? 1 : -1; - - switch (m_sort_field) - { - case wxFileData::FileList_Size : - wxListCtrl::SortItems(wxFileDataSizeCompare, sort_dir); - break; - - case wxFileData::FileList_Type : - wxListCtrl::SortItems(wxFileDataTypeCompare, sort_dir); - break; - - case wxFileData::FileList_Time : - wxListCtrl::SortItems(wxFileDataTimeCompare, sort_dir); - break; - - case wxFileData::FileList_Name : - default : - wxListCtrl::SortItems(wxFileDataNameCompare, sort_dir); - break; - } -} - -wxFileListCtrl::~wxFileListCtrl() -{ - // Normally the data are freed via an EVT_LIST_DELETE_ALL_ITEMS event and - // wxFileListCtrl::OnListDeleteAllItems. But if the event is generated after - // the destruction of the wxFileListCtrl we need to free any data here: - FreeAllItemsData(); -} - -#define ID_CHOICE (wxID_FILECTRL + 1) -#define ID_TEXT (wxID_FILECTRL + 2) -#define ID_FILELIST_CTRL (wxID_FILECTRL + 3) -#define ID_CHECK (wxID_FILECTRL + 4) - -/////////////////////////////////////////////////////////////////////////////// -// wxGenericFileCtrl implementation -/////////////////////////////////////////////////////////////////////////////// - -IMPLEMENT_DYNAMIC_CLASS( wxGenericFileCtrl, wxNavigationEnabled ) - -BEGIN_EVENT_TABLE( wxGenericFileCtrl, wxNavigationEnabled ) - EVT_LIST_ITEM_SELECTED( ID_FILELIST_CTRL, wxGenericFileCtrl::OnSelected ) - EVT_LIST_ITEM_ACTIVATED( ID_FILELIST_CTRL, wxGenericFileCtrl::OnActivated ) - EVT_CHOICE( ID_CHOICE, wxGenericFileCtrl::OnChoiceFilter ) - EVT_TEXT_ENTER( ID_TEXT, wxGenericFileCtrl::OnTextEnter ) - EVT_TEXT( ID_TEXT, wxGenericFileCtrl::OnTextChange ) - EVT_CHECKBOX( ID_CHECK, wxGenericFileCtrl::OnCheck ) -END_EVENT_TABLE() - -bool wxGenericFileCtrl::Create( wxWindow *parent, - wxWindowID id, - const wxString& defaultDirectory, - const wxString& defaultFileName, - const wxString& wildCard, - long style, - const wxPoint& pos, - const wxSize& size, - const wxString& name ) -{ - this->m_style = style; - m_inSelected = false; - m_noSelChgEvent = false; - m_check = NULL; - - // check that the styles are not contradictory - wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_OPEN ) ), - wxT( "can't specify both wxFC_SAVE and wxFC_OPEN at once" ) ); - - wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_MULTIPLE ) ), - wxT( "wxFC_MULTIPLE can't be used with wxFC_SAVE" ) ); - - wxNavigationEnabled::Create( parent, id, - pos, size, - wxTAB_TRAVERSAL, - wxDefaultValidator, - name ); - - m_dir = defaultDirectory; - - m_ignoreChanges = true; - - if ( ( m_dir.empty() ) || ( m_dir == wxT( "." ) ) ) - { - m_dir = wxGetCwd(); - if ( m_dir.empty() ) - m_dir = wxFILE_SEP_PATH; - } - - const size_t len = m_dir.length(); - if ( ( len > 1 ) && ( wxEndsWithPathSeparator( m_dir ) ) ) - m_dir.Remove( len - 1, 1 ); - - m_filterExtension = wxEmptyString; - - // layout - - const bool is_pda = ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA ); - - wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer *staticsizer = new wxBoxSizer( wxHORIZONTAL ); - if ( is_pda ) - staticsizer->Add( new wxStaticText( this, wxID_ANY, _( "Current directory:" ) ), - wxSizerFlags().DoubleBorder(wxRIGHT) ); - m_static = new wxStaticText( this, wxID_ANY, m_dir ); - staticsizer->Add( m_static, 1 ); - mainsizer->Add( staticsizer, wxSizerFlags().Expand().Border()); - - long style2 = wxLC_LIST; - if ( !( m_style & wxFC_MULTIPLE ) ) - style2 |= wxLC_SINGLE_SEL; - -#ifdef __WXWINCE__ - style2 |= wxSIMPLE_BORDER; -#else - style2 |= wxSUNKEN_BORDER; -#endif - - m_list = new wxFileListCtrl( this, ID_FILELIST_CTRL, - wxEmptyString, false, - wxDefaultPosition, wxSize( 400, 140 ), - style2 ); - - m_text = new wxTextCtrl( this, ID_TEXT, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxTE_PROCESS_ENTER ); - m_choice = new wxChoice( this, ID_CHOICE ); - - if ( is_pda ) - { - // PDAs have a different screen layout - mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().HorzBorder() ); - - wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL ); - textsizer->Add( m_text, wxSizerFlags( 1 ).Centre().Border() ); - textsizer->Add( m_choice, wxSizerFlags( 1 ).Centre().Border() ); - mainsizer->Add( textsizer, wxSizerFlags().Expand() ); - - } - else // !is_pda - { - mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().Border() ); - mainsizer->Add( m_text, wxSizerFlags().Expand().Border() ); - - wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL ); - choicesizer->Add( m_choice, wxSizerFlags( 1 ).Centre() ); - - if ( !( m_style & wxFC_NOSHOWHIDDEN ) ) - { - m_check = new wxCheckBox( this, ID_CHECK, _( "Show &hidden files" ) ); - choicesizer->Add( m_check, wxSizerFlags().Centre().DoubleBorder(wxLEFT) ); - } - - mainsizer->Add( choicesizer, wxSizerFlags().Expand().Border() ); - } - - SetWildcard( wildCard ); - - SetAutoLayout( true ); - SetSizer( mainsizer ); - - if ( !is_pda ) - { - mainsizer->Fit( this ); - } - - m_list->GoToDir( m_dir ); - UpdateControls(); - m_text->SetValue( m_fileName ); - - m_ignoreChanges = false; - - // must be after m_ignoreChanges = false - SetFilename( defaultFileName ); - - return true; -} - -// NB: there is an unfortunate mismatch between wxFileName and wxFileDialog -// method names but our GetDirectory() does correspond to wxFileName:: -// GetPath() while our GetPath() is wxFileName::GetFullPath() -wxString wxGenericFileCtrl::GetPath() const -{ - wxASSERT_MSG ( !(m_style & wxFC_MULTIPLE), "use GetPaths() instead" ); - - return DoGetFileName().GetFullPath(); -} - -wxString wxGenericFileCtrl::GetFilename() const -{ - wxASSERT_MSG ( !(m_style & wxFC_MULTIPLE), "use GetFilenames() instead" ); - - return DoGetFileName().GetFullName(); -} - -wxString wxGenericFileCtrl::GetDirectory() const -{ - // don't check for wxFC_MULTIPLE here, this one is probably safe to call in - // any case as it can be always taken to mean "current directory" - return DoGetFileName().GetPath(); -} - -wxFileName wxGenericFileCtrl::DoGetFileName() const -{ - wxFileName fn; - - wxString value = m_text->GetValue(); - if ( value.empty() ) - { - // nothing in the text control, get the selected file from the list - wxListItem item; - item.m_itemId = m_list->GetNextItem(-1, wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED); - m_list->GetItem(item); - - fn.Assign(m_list->GetDir(), item.m_text); - } - else // user entered the value - { - // the path can be either absolute or relative - fn.Assign(value); - if ( fn.IsRelative() ) - fn.MakeAbsolute(m_list->GetDir()); - } - - return fn; -} - -// helper used in DoGetFilenames() and needed because Borland can't compile -// operator?: inline -static inline wxString GetFileNameOrPath(const wxFileName& fn, bool fullPath) -{ - return fullPath ? fn.GetFullPath() : fn.GetFullName(); -} - -void -wxGenericFileCtrl::DoGetFilenames(wxArrayString& filenames, bool fullPath) const -{ - filenames.clear(); - - const wxString dir = m_list->GetDir(); - - const wxString value = m_text->GetValue(); - if ( !value.empty() ) - { - wxFileName fn(value); - if ( fn.IsRelative() ) - fn.MakeAbsolute(dir); - - filenames.push_back(GetFileNameOrPath(fn, fullPath)); - return; - } - - const int numSel = m_list->GetSelectedItemCount(); - if ( !numSel ) - return; - - filenames.reserve(numSel); - - wxListItem item; - item.m_mask = wxLIST_MASK_TEXT; - item.m_itemId = -1; - for ( ;; ) - { - item.m_itemId = m_list->GetNextItem(item.m_itemId, wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED); - - if ( item.m_itemId == -1 ) - break; - - m_list->GetItem(item); - - const wxFileName fn(dir, item.m_text); - filenames.push_back(GetFileNameOrPath(fn, fullPath)); - } -} - -bool wxGenericFileCtrl::SetDirectory( const wxString& dir ) -{ - m_ignoreChanges = true; - m_list->GoToDir( dir ); - UpdateControls(); - m_ignoreChanges = false; - - return wxFileName( dir ).SameAs( m_list->GetDir() ); -} - -bool wxGenericFileCtrl::SetFilename( const wxString& name ) -{ - const long item = m_list->FindItem( -1, name ); - - if ( item == -1 ) // file not found either because it doesn't exist or the - // current filter doesn't show it. - return false; - - m_noSelChgEvent = true; - - // Deselect selected items - { - const int numSelectedItems = m_list->GetSelectedItemCount(); - - if ( numSelectedItems > 0 ) - { - long itemIndex = -1; - - for ( ;; ) - { - itemIndex = m_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); - if ( itemIndex == -1 ) - break; - - m_list->SetItemState( itemIndex, 0, wxLIST_STATE_SELECTED ); - } - } - } - - m_list->SetItemState( item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - m_list->EnsureVisible( item ); - - m_noSelChgEvent = false; - - return true; -} - -void wxGenericFileCtrl::DoSetFilterIndex( int filterindex ) -{ - wxClientData *pcd = m_choice->GetClientObject( filterindex ); - if ( !pcd ) - return; - - const wxString& str = ((static_cast(pcd))->GetData()); - m_list->SetWild( str ); - m_filterIndex = filterindex; - if ( str.Left( 2 ) == wxT( "*." ) ) - { - m_filterExtension = str.Mid( 1 ); - if ( m_filterExtension == wxT( ".*" ) ) - m_filterExtension.clear(); - } - else - { - m_filterExtension.clear(); - } - - GenerateFilterChangedEvent( this, this ); -} - -void wxGenericFileCtrl::SetWildcard( const wxString& wildCard ) -{ - if ( wildCard.empty() || wildCard == wxFileSelectorDefaultWildcardStr ) - { - m_wildCard = wxString::Format( _( "All files (%s)|%s" ), - wxFileSelectorDefaultWildcardStr, - wxFileSelectorDefaultWildcardStr ); - } - else - m_wildCard = wildCard; - - wxArrayString wildDescriptions, wildFilters; - const size_t count = wxParseCommonDialogsFilter( m_wildCard, - wildDescriptions, - wildFilters ); - wxCHECK_RET( count, wxT( "wxFileDialog: bad wildcard string" ) ); - - m_choice->Clear(); - - for ( size_t n = 0; n < count; n++ ) - { - m_choice->Append(wildDescriptions[n], new wxStringClientData(wildFilters[n])); - } - - SetFilterIndex( 0 ); -} - -void wxGenericFileCtrl::SetFilterIndex( int filterindex ) -{ - m_choice->SetSelection( filterindex ); - - DoSetFilterIndex( filterindex ); -} - -void wxGenericFileCtrl::OnChoiceFilter( wxCommandEvent &event ) -{ - DoSetFilterIndex( ( int )event.GetInt() ); -} - -void wxGenericFileCtrl::OnCheck( wxCommandEvent &event ) -{ - m_list->ShowHidden( event.GetInt() != 0 ); -} - -void wxGenericFileCtrl::OnActivated( wxListEvent &event ) -{ - HandleAction( event.m_item.m_text ); -} - -void wxGenericFileCtrl::OnTextEnter( wxCommandEvent &WXUNUSED( event ) ) -{ - HandleAction( m_text->GetValue() ); -} - -void wxGenericFileCtrl::OnTextChange( wxCommandEvent &WXUNUSED( event ) ) -{ - if ( !m_ignoreChanges ) - { - // Clear selections. Otherwise when the user types in a value they may - // not get the file whose name they typed. - if ( m_list->GetSelectedItemCount() > 0 ) - { - long item = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED ); - while ( item != -1 ) - { - m_list->SetItemState( item, 0, wxLIST_STATE_SELECTED ); - item = m_list->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); - } - } - } -} - -void wxGenericFileCtrl::OnSelected( wxListEvent &event ) -{ - if ( m_ignoreChanges ) - return; - - if ( m_inSelected ) - return; - - m_inSelected = true; - const wxString filename( event.m_item.m_text ); - -#ifdef __WXWINCE__ - // No double-click on most WinCE devices, so do action immediately. - HandleAction( filename ); -#else - if ( filename == wxT( ".." ) ) - { - m_inSelected = false; - return; - } - - wxString dir = m_list->GetDir(); - if ( !IsTopMostDir( dir ) ) - dir += wxFILE_SEP_PATH; - dir += filename; - if ( wxDirExists( dir ) ) - { - m_inSelected = false; - - return; - } - - - m_ignoreChanges = true; - m_text->SetValue( filename ); - - if ( m_list->GetSelectedItemCount() > 1 ) - { - m_text->Clear(); - } - - if ( !m_noSelChgEvent ) - GenerateSelectionChangedEvent( this, this ); - - m_ignoreChanges = false; -#endif - m_inSelected = false; -} - -void wxGenericFileCtrl::HandleAction( const wxString &fn ) -{ - if ( m_ignoreChanges ) - return; - - wxString filename( fn ); - if ( filename.empty() ) - { - return; - } - if ( filename == wxT( "." ) ) return; - - wxString dir = m_list->GetDir(); - - // "some/place/" means they want to chdir not try to load "place" - const bool want_dir = filename.Last() == wxFILE_SEP_PATH; - if ( want_dir ) - filename = filename.RemoveLast(); - - if ( filename == wxT( ".." ) ) - { - m_ignoreChanges = true; - m_list->GoToParentDir(); - - GenerateFolderChangedEvent( this, this ); - - UpdateControls(); - m_ignoreChanges = false; - return; - } - -#ifdef __UNIX__ - if ( filename == wxT( "~" ) ) - { - m_ignoreChanges = true; - m_list->GoToHomeDir(); - - GenerateFolderChangedEvent( this, this ); - - UpdateControls(); - m_ignoreChanges = false; - return; - } - - if ( filename.BeforeFirst( wxT( '/' ) ) == wxT( "~" ) ) - { - filename = wxString( wxGetUserHome() ) + filename.Remove( 0, 1 ); - } -#endif // __UNIX__ - - if ( !( m_style & wxFC_SAVE ) ) - { - if ( ( filename.Find( wxT( '*' ) ) != wxNOT_FOUND ) || - ( filename.Find( wxT( '?' ) ) != wxNOT_FOUND ) ) - { - if ( filename.Find( wxFILE_SEP_PATH ) != wxNOT_FOUND ) - { - wxMessageBox( _( "Illegal file specification." ), - _( "Error" ), wxOK | wxICON_ERROR, this ); - return; - } - m_list->SetWild( filename ); - return; - } - } - - if ( !IsTopMostDir( dir ) ) - dir += wxFILE_SEP_PATH; - if ( !wxIsAbsolutePath( filename ) ) - { - dir += filename; - filename = dir; - } - - if ( wxDirExists( filename ) ) - { - m_ignoreChanges = true; - m_list->GoToDir( filename ); - UpdateControls(); - - GenerateFolderChangedEvent( this, this ); - - m_ignoreChanges = false; - return; - } - - // they really wanted a dir, but it doesn't exist - if ( want_dir ) - { - wxMessageBox( _( "Directory doesn't exist." ), _( "Error" ), - wxOK | wxICON_ERROR, this ); - return; - } - - // append the default extension to the filename if it doesn't have any - // - // VZ: the logic of testing for !wxFileExists() only for the open file - // dialog is not entirely clear to me, why don't we allow saving to a - // file without extension as well? - if ( !( m_style & wxFC_OPEN ) || !wxFileExists( filename ) ) - { - filename = wxFileDialogBase::AppendExtension( filename, m_filterExtension ); - GenerateFileActivatedEvent( this, this, wxFileName( filename ).GetFullName() ); - return; - } - - GenerateFileActivatedEvent( this, this ); -} - -bool wxGenericFileCtrl::SetPath( const wxString& path ) -{ - if ( !wxFileName::FileExists( ( path ) ) ) - return false; - - wxString ext; - wxFileName::SplitPath( path, &m_dir, &m_fileName, &ext ); - if ( !ext.empty() ) - { - m_fileName += wxT( "." ); - m_fileName += ext; - } - - SetDirectory( m_dir ); - SetFilename( m_fileName ); - - return true; -} - -void wxGenericFileCtrl::GetPaths( wxArrayString& paths ) const -{ - DoGetFilenames( paths, true ); -} - -void wxGenericFileCtrl::GetFilenames( wxArrayString& files ) const -{ - DoGetFilenames( files, false ); -} - -void wxGenericFileCtrl::UpdateControls() -{ - const wxString dir = m_list->GetDir(); - m_static->SetLabel( dir ); -} - -void wxGenericFileCtrl::GoToParentDir() -{ - m_list->GoToParentDir(); - UpdateControls(); -} - -void wxGenericFileCtrl::GoToHomeDir() -{ - m_list->GoToHomeDir(); - UpdateControls(); -} - -#endif // wxUSE_FILECTRL diff --git a/Source/3rd Party/wx/src/generic/filedlgg.cpp b/Source/3rd Party/wx/src/generic/filedlgg.cpp deleted file mode 100644 index 9ec0842c6..000000000 --- a/Source/3rd Party/wx/src/generic/filedlgg.cpp +++ /dev/null @@ -1,406 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/filedlgg.cpp -// Purpose: wxGenericFileDialog -// Author: Robert Roebling -// Modified by: -// Created: 12/12/98 -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_FILEDLG - -// NOTE : it probably also supports MAC, untested -#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__) -#error wxGenericFileDialog currently only supports Unix, win32 and DOS -#endif - -#ifndef WX_PRECOMP - #ifdef __WXMSW__ - #include "wx/msw/wrapwin.h" - #endif - #include "wx/hash.h" - #include "wx/intl.h" - #include "wx/settings.h" - #include "wx/log.h" - #include "wx/msgdlg.h" - #include "wx/bmpbuttn.h" - #include "wx/checkbox.h" - #include "wx/choice.h" - #include "wx/stattext.h" - #include "wx/textctrl.h" - #include "wx/sizer.h" - #include "wx/filedlg.h" // wxFD_OPEN, wxFD_SAVE... -#endif - -#include "wx/longlong.h" -#include "wx/config.h" -#include "wx/imaglist.h" -#include "wx/artprov.h" -#include "wx/filefn.h" -#include "wx/filectrl.h" -#include "wx/generic/filedlgg.h" -#include "wx/debug.h" -#include "wx/modalhook.h" - -#if wxUSE_TOOLTIPS - #include "wx/tooltip.h" -#endif -#if wxUSE_CONFIG - #include "wx/config.h" -#endif - -#ifndef __WXWINCE__ - #include - #include -#endif - -#ifdef __UNIX__ - #include - #include - #ifndef __VMS - # include - #endif -#endif - -#ifdef __WINDOWS__ - #include "wx/msw/mslu.h" -#endif - -#ifdef __WATCOMC__ - #include -#endif - -#ifndef __WXWINCE__ -#include -#endif - -#if defined(__UNIX__) || defined(__DOS__) -#include -#endif - -#if defined(__WXWINCE__) -#define IsTopMostDir(dir) (dir == wxT("\\") || dir == wxT("/")) -#elif (defined(__DOS__) || defined(__WINDOWS__) || defined (__OS2__)) -#define IsTopMostDir(dir) (dir.empty()) -#else -#define IsTopMostDir(dir) (dir == wxT("/")) -#endif - -//----------------------------------------------------------------------------- -// wxGenericFileDialog -//----------------------------------------------------------------------------- - -#define ID_LIST_MODE (wxID_FILEDLGG ) -#define ID_REPORT_MODE (wxID_FILEDLGG + 1) -#define ID_UP_DIR (wxID_FILEDLGG + 2) -#define ID_HOME_DIR (wxID_FILEDLGG + 3) -#define ID_NEW_DIR (wxID_FILEDLGG + 4) -#define ID_FILE_CTRL (wxID_FILEDLGG + 5) - -IMPLEMENT_DYNAMIC_CLASS(wxGenericFileDialog, wxFileDialogBase) - -BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog) - EVT_BUTTON(ID_LIST_MODE, wxGenericFileDialog::OnList) - EVT_BUTTON(ID_REPORT_MODE, wxGenericFileDialog::OnReport) - EVT_BUTTON(ID_UP_DIR, wxGenericFileDialog::OnUp) - EVT_BUTTON(ID_HOME_DIR, wxGenericFileDialog::OnHome) - EVT_BUTTON(ID_NEW_DIR, wxGenericFileDialog::OnNew) - EVT_BUTTON(wxID_OK, wxGenericFileDialog::OnOk) - EVT_FILECTRL_FILEACTIVATED(ID_FILE_CTRL, wxGenericFileDialog::OnFileActivated) - - EVT_UPDATE_UI(ID_UP_DIR, wxGenericFileDialog::OnUpdateButtonsUI) -#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) - EVT_UPDATE_UI(ID_NEW_DIR, wxGenericFileDialog::OnUpdateButtonsUI) -#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) -END_EVENT_TABLE() - -long wxGenericFileDialog::ms_lastViewStyle = wxLC_LIST; -bool wxGenericFileDialog::ms_lastShowHidden = false; - -void wxGenericFileDialog::Init() -{ - m_bypassGenericImpl = false; - - m_filectrl = NULL; - m_upDirButton = NULL; - m_newDirButton = NULL; -} - -wxGenericFileDialog::wxGenericFileDialog(wxWindow *parent, - const wxString& message, - const wxString& defaultDir, - const wxString& defaultFile, - const wxString& wildCard, - long style, - const wxPoint& pos, - const wxSize& sz, - const wxString& name, - bool bypassGenericImpl ) : wxFileDialogBase() -{ - Init(); - Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name, bypassGenericImpl ); -} - -bool wxGenericFileDialog::Create( wxWindow *parent, - const wxString& message, - const wxString& defaultDir, - const wxString& defaultFile, - const wxString& wildCard, - long style, - const wxPoint& pos, - const wxSize& sz, - const wxString& name, - bool bypassGenericImpl ) -{ - m_bypassGenericImpl = bypassGenericImpl; - - parent = GetParentForModalDialog(parent, style); - - if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile, - wildCard, style, pos, sz, name)) - { - return false; - } - - if (m_bypassGenericImpl) - return true; - - if (!wxDialog::Create( parent, wxID_ANY, message, pos, sz, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | style, name - )) - { - return false; - } - -#if wxUSE_CONFIG - if (wxConfig::Get(false)) - { - wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"), - &ms_lastViewStyle); - wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"), - &ms_lastShowHidden); - } -#endif - - if ((m_dir.empty()) || (m_dir == wxT("."))) - { - m_dir = wxGetCwd(); - if (m_dir.empty()) - m_dir = wxFILE_SEP_PATH; - } - - const size_t len = m_dir.length(); - if ((len > 1) && (wxEndsWithPathSeparator(m_dir))) - m_dir.Remove( len-1, 1 ); - - m_filterExtension = wxEmptyString; - - // layout - - const bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - - wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer *buttonsizer = new wxBoxSizer( wxHORIZONTAL ); - AddBitmapButton( ID_LIST_MODE, wxART_LIST_VIEW, - _("View files as a list view"), buttonsizer ); - AddBitmapButton( ID_REPORT_MODE, wxART_REPORT_VIEW, - _("View files as a detailed view"), buttonsizer ); - buttonsizer->Add( 30, 5, 1 ); - m_upDirButton = AddBitmapButton( ID_UP_DIR, wxART_GO_DIR_UP, - _("Go to parent directory"), buttonsizer ); - -#ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS... - AddBitmapButton( ID_HOME_DIR, wxART_GO_HOME, - _("Go to home directory"), buttonsizer ); - buttonsizer->Add( 20, 20 ); -#endif //!__DOS__ - - m_newDirButton = AddBitmapButton( ID_NEW_DIR, wxART_NEW_DIR, - _("Create new directory"), buttonsizer ); - - if (is_pda) - mainsizer->Add( buttonsizer, wxSizerFlags().Expand() ); - else - mainsizer->Add( buttonsizer, wxSizerFlags().Expand() - .Border( wxLEFT | wxRIGHT | wxTOP ) ); - - long style2 = 0; - if ( HasFdFlag(wxFD_MULTIPLE) ) - style2 |= wxFC_MULTIPLE; - - m_filectrl = new wxGenericFileCtrl( this, ID_FILE_CTRL, - m_dir, defaultFile, - wildCard, - style2, - wxDefaultPosition, wxSize(540,200) - ); - - m_filectrl->ShowHidden( ms_lastShowHidden ); - - if (ms_lastViewStyle == wxLC_LIST) - { - m_filectrl->ChangeToListMode(); - } - else if (ms_lastViewStyle == wxLC_REPORT) - { - m_filectrl->ChangeToReportMode(); - } - - mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().HorzBorder()); - - wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL); - if ( bsizer ) - { - if (is_pda) - mainsizer->Add(bsizer, wxSizerFlags().Expand().Border()); - else - mainsizer->Add(bsizer, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer( mainsizer ); - - if (!is_pda) - { - mainsizer->SetSizeHints( this ); - - Centre( wxBOTH ); - } - - return true; -} - -wxGenericFileDialog::~wxGenericFileDialog() -{ - if (!m_bypassGenericImpl) - { -#if wxUSE_CONFIG - if (wxConfig::Get(false)) - { - wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"), - ms_lastViewStyle); - wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"), - ms_lastShowHidden); - } -#endif - } -} - -wxBitmapButton* wxGenericFileDialog::AddBitmapButton( wxWindowID winId, - const wxArtID& artId, - const wxString& tip, - wxSizer *sizer) -{ - wxBitmapButton *but = new wxBitmapButton(this, winId, - wxArtProvider::GetBitmap(artId, wxART_BUTTON)); - but->SetToolTip(tip); - sizer->Add(but, wxSizerFlags().Border()); - return but; -} - -int wxGenericFileDialog::ShowModal() -{ - WX_HOOK_MODAL_DIALOG(); - - if (CreateExtraControl()) - { - wxSizer *sizer = GetSizer(); - sizer->Insert(2 /* after m_filectrl */, m_extraControl, - wxSizerFlags().Expand().HorzBorder()); - sizer->Fit(this); - } - - m_filectrl->SetDirectory(m_dir); - - return wxDialog::ShowModal(); -} - -bool wxGenericFileDialog::Show( bool show ) -{ - // Called by ShowModal, so don't repeate the update -#ifndef __WIN32__ - if (show) - { - m_filectrl->SetDirectory(m_dir); - } -#endif - - return wxDialog::Show( show ); -} - -void wxGenericFileDialog::OnOk( wxCommandEvent &WXUNUSED(event) ) -{ - wxArrayString selectedFiles; - m_filectrl->GetFilenames(selectedFiles); - - if (selectedFiles.Count() == 0) - return; - - if (selectedFiles.Count() == 1) - { - SetPath( selectedFiles[0] ); - } - - EndModal(wxID_OK); -} - -void wxGenericFileDialog::OnList( wxCommandEvent &WXUNUSED(event) ) -{ - m_filectrl->ChangeToListMode(); - ms_lastViewStyle = wxLC_LIST; - m_filectrl->GetFileList()->SetFocus(); -} - -void wxGenericFileDialog::OnReport( wxCommandEvent &WXUNUSED(event) ) -{ - m_filectrl->ChangeToReportMode(); - ms_lastViewStyle = wxLC_REPORT; - m_filectrl->GetFileList()->SetFocus(); -} - -void wxGenericFileDialog::OnUp( wxCommandEvent &WXUNUSED(event) ) -{ - m_filectrl->GoToParentDir(); - m_filectrl->GetFileList()->SetFocus(); -} - -void wxGenericFileDialog::OnHome( wxCommandEvent &WXUNUSED(event) ) -{ - m_filectrl->GoToHomeDir(); - m_filectrl->SetFocus(); -} - -void wxGenericFileDialog::OnNew( wxCommandEvent &WXUNUSED(event) ) -{ - m_filectrl->GetFileList()->MakeDir(); -} - -void wxGenericFileDialog::OnFileActivated( wxFileCtrlEvent &WXUNUSED(event) ) -{ - wxCommandEvent dummy; - OnOk( dummy ); -} - -void wxGenericFileDialog::OnUpdateButtonsUI(wxUpdateUIEvent& event) -{ - // surprisingly, we can be called before m_filectrl is set in Create() as - // wxFileCtrl ctor itself can generate idle events, so we need this test - if ( m_filectrl ) - event.Enable( !IsTopMostDir(m_filectrl->GetShownDirectory()) ); -} - -#ifdef wxHAS_GENERIC_FILEDIALOG - -IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog) - -#endif // wxHAS_GENERIC_FILEDIALOG - -#endif // wxUSE_FILEDLG diff --git a/Source/3rd Party/wx/src/generic/filepickerg.cpp b/Source/3rd Party/wx/src/generic/filepickerg.cpp index 53a9f1faa..96eb79916 100644 --- a/Source/3rd Party/wx/src/generic/filepickerg.cpp +++ b/Source/3rd Party/wx/src/generic/filepickerg.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 15/04/2006 +// RCS-ID: $Id: filepickerg.cpp 52835 2008-03-26 15:49:08Z JS $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -25,11 +26,8 @@ #if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL -#include "wx/filename.h" #include "wx/filepicker.h" -#include "wx/scopedptr.h" - // ============================================================================ // implementation @@ -42,45 +40,22 @@ IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton, wxButton) // wxGenericFileButton // ---------------------------------------------------------------------------- -bool wxGenericFileDirButton::Create(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxString& path, - const wxString& message, - const wxString& wildcard, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) +bool wxGenericFileDirButton::Create( wxWindow *parent, wxWindowID id, + const wxString &label, const wxString &path, + const wxString &message, const wxString &wildcard, + const wxPoint &pos, const wxSize &size, long style, + const wxValidator& validator, const wxString &name) { - m_pickerStyle = style; - - // If the special wxPB_SMALL flag is used, ignore the provided label and - // use the shortest possible label and the smallest possible button fitting - // it. - long styleButton = 0; - wxString labelButton; - if ( m_pickerStyle & wxPB_SMALL ) - { - labelButton = _("..."); - styleButton = wxBU_EXACTFIT; - } - else - { - labelButton = label; - } - // create this button - if ( !wxButton::Create(parent, id, labelButton, - pos, size, styleButton, validator, name) ) + if (!wxButton::Create(parent, id, label, pos, size, style, + validator, name)) { wxFAIL_MSG( wxT("wxGenericFileButton creation failed") ); return false; } // and handle user clicks on it - Connect(GetId(), wxEVT_BUTTON, + Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick), NULL, this); @@ -94,62 +69,18 @@ bool wxGenericFileDirButton::Create(wxWindow *parent, void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) { - wxScopedPtr p(CreateDialog()); + wxDialog *p = CreateDialog(); if (p->ShowModal() == wxID_OK) { // save updated path in m_path - UpdatePathFromDialog(p.get()); + UpdatePathFromDialog(p); // fire an event wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path); GetEventHandler()->ProcessEvent(event); } -} -void wxGenericFileDirButton::SetInitialDirectory(const wxString& dir) -{ - m_initialDir = dir; -} - -// ---------------------------------------------------------------------------- -// wxGenericFileButton -// ---------------------------------------------------------------------------- - -wxDialog *wxGenericFileButton::CreateDialog() -{ - // Determine the initial directory for the dialog: it comes either from the - // default path, if it has it, or from the separately specified initial - // directory that can be set even if the path is e.g. empty. - wxFileName fn(m_path); - wxString initialDir = fn.GetPath(); - if ( initialDir.empty() ) - initialDir = m_initialDir; - - return new wxFileDialog - ( - GetDialogParent(), - m_message, - initialDir, - fn.GetFullName(), - m_wildcard, - GetDialogStyle() - ); -} - -// ---------------------------------------------------------------------------- -// wxGenericDirButton -// ---------------------------------------------------------------------------- - -wxDialog *wxGenericDirButton::CreateDialog() -{ - wxDirDialog* const dialog = new wxDirDialog - ( - GetDialogParent(), - m_message, - m_path.empty() ? m_initialDir : m_path, - GetDialogStyle() - ); - return dialog; + wxDELETE(p); } #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL diff --git a/Source/3rd Party/wx/src/generic/fontdlgg.cpp b/Source/3rd Party/wx/src/generic/fontdlgg.cpp deleted file mode 100644 index 58a7835c9..000000000 --- a/Source/3rd Party/wx/src/generic/fontdlgg.cpp +++ /dev/null @@ -1,626 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/fontdlgg.cpp -// Purpose: Generic font dialog -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_FONTDLG && (!defined(__WXGTK__) || defined(__WXGPE__) || defined(__WXUNIVERSAL__)) - -#ifndef WX_PRECOMP - #include - #include "wx/crt.h" - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/listbox.h" - #include "wx/button.h" - #include "wx/stattext.h" - #include "wx/layout.h" - #include "wx/dcclient.h" - #include "wx/choice.h" - #include "wx/checkbox.h" - #include "wx/intl.h" - #include "wx/settings.h" - #include "wx/sizer.h" -#endif - -#include -#include - -#include "wx/fontdlg.h" -#include "wx/generic/fontdlgg.h" - -#if USE_SPINCTRL_FOR_POINT_SIZE -#include "wx/spinctrl.h" -#endif - -//----------------------------------------------------------------------------- -// helper class - wxFontPreviewer -//----------------------------------------------------------------------------- - -class WXDLLEXPORT wxFontPreviewer : public wxWindow -{ -public: - wxFontPreviewer(wxWindow *parent, const wxSize& sz = wxDefaultSize) : wxWindow(parent, wxID_ANY, wxDefaultPosition, sz) - { - } - -private: - void OnPaint(wxPaintEvent& event); - DECLARE_EVENT_TABLE() -}; - -BEGIN_EVENT_TABLE(wxFontPreviewer, wxWindow) - EVT_PAINT(wxFontPreviewer::OnPaint) -END_EVENT_TABLE() - -void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - wxSize size = GetSize(); - wxFont font = GetFont(); - - dc.SetPen(*wxBLACK_PEN); - dc.SetBrush(*wxWHITE_BRUSH); - dc.DrawRectangle(0, 0, size.x, size.y); - - if ( font.IsOk() ) - { - dc.SetFont(font); - dc.SetTextForeground(GetForegroundColour()); - dc.SetClippingRegion(2, 2, size.x-4, size.y-4); - dc.DrawText(_("ABCDEFGabcdefg12345"), - 10, (size.y - dc.GetTextExtent(wxT("X")).y)/2); - dc.DestroyClippingRegion(); - } -} - -//----------------------------------------------------------------------------- -// helper functions -//----------------------------------------------------------------------------- - -static const wxChar *wxFontWeightIntToString(int weight) -{ - switch (weight) - { - case wxLIGHT: - return wxT("Light"); - case wxBOLD: - return wxT("Bold"); - case wxNORMAL: - default: - return wxT("Normal"); - } -} - -static const wxChar *wxFontStyleIntToString(int style) -{ - switch (style) - { - case wxITALIC: - return wxT("Italic"); - case wxSLANT: - return wxT("Slant"); - case wxNORMAL: - default: - return wxT("Normal"); - } -} - -static const wxChar *wxFontFamilyIntToString(int family) -{ - switch (family) - { - case wxROMAN: - return wxT("Roman"); - case wxDECORATIVE: - return wxT("Decorative"); - case wxMODERN: - return wxT("Modern"); - case wxSCRIPT: - return wxT("Script"); - case wxTELETYPE: - return wxT("Teletype"); - case wxSWISS: - default: - return wxT("Swiss"); - } -} - -static int wxFontFamilyStringToInt(const wxString& family) -{ - if (family.empty()) - return wxSWISS; - - if (wxStrcmp(family, wxT("Roman")) == 0) - return wxROMAN; - else if (wxStrcmp(family, wxT("Decorative")) == 0) - return wxDECORATIVE; - else if (wxStrcmp(family, wxT("Modern")) == 0) - return wxMODERN; - else if (wxStrcmp(family, wxT("Script")) == 0) - return wxSCRIPT; - else if (wxStrcmp(family, wxT("Teletype")) == 0) - return wxTELETYPE; - else return wxSWISS; -} - -static int wxFontStyleStringToInt(const wxString& style) -{ - if (style.empty()) - return wxNORMAL; - if (wxStrcmp(style, wxT("Italic")) == 0) - return wxITALIC; - else if (wxStrcmp(style, wxT("Slant")) == 0) - return wxSLANT; - else - return wxNORMAL; -} - -static int wxFontWeightStringToInt(const wxString& weight) -{ - if (weight.empty()) - return wxNORMAL; - if (wxStrcmp(weight, wxT("Bold")) == 0) - return wxBOLD; - else if (wxStrcmp(weight, wxT("Light")) == 0) - return wxLIGHT; - else - return wxNORMAL; -} - -//----------------------------------------------------------------------------- -// wxGenericFontDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericFontDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog) - EVT_CHECKBOX(wxID_FONT_UNDERLINE, wxGenericFontDialog::OnChangeFont) - EVT_CHOICE(wxID_FONT_STYLE, wxGenericFontDialog::OnChangeFont) - EVT_CHOICE(wxID_FONT_WEIGHT, wxGenericFontDialog::OnChangeFont) - EVT_CHOICE(wxID_FONT_FAMILY, wxGenericFontDialog::OnChangeFont) - EVT_CHOICE(wxID_FONT_COLOUR, wxGenericFontDialog::OnChangeFont) -#if USE_SPINCTRL_FOR_POINT_SIZE - EVT_SPINCTRL(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeSize) - EVT_TEXT(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont) -#else - EVT_CHOICE(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont) -#endif - EVT_CLOSE(wxGenericFontDialog::OnCloseWindow) -END_EVENT_TABLE() - - -#define NUM_COLS 48 -static wxString wxColourDialogNames[NUM_COLS]={wxT("ORANGE"), - wxT("GOLDENROD"), - wxT("WHEAT"), - wxT("SPRING GREEN"), - wxT("SKY BLUE"), - wxT("SLATE BLUE"), - wxT("MEDIUM VIOLET RED"), - wxT("PURPLE"), - - wxT("RED"), - wxT("YELLOW"), - wxT("MEDIUM SPRING GREEN"), - wxT("PALE GREEN"), - wxT("CYAN"), - wxT("LIGHT STEEL BLUE"), - wxT("ORCHID"), - wxT("LIGHT MAGENTA"), - - wxT("BROWN"), - wxT("YELLOW"), - wxT("GREEN"), - wxT("CADET BLUE"), - wxT("MEDIUM BLUE"), - wxT("MAGENTA"), - wxT("MAROON"), - wxT("ORANGE RED"), - - wxT("FIREBRICK"), - wxT("CORAL"), - wxT("FOREST GREEN"), - wxT("AQUARAMINE"), - wxT("BLUE"), - wxT("NAVY"), - wxT("THISTLE"), - wxT("MEDIUM VIOLET RED"), - - wxT("INDIAN RED"), - wxT("GOLD"), - wxT("MEDIUM SEA GREEN"), - wxT("MEDIUM BLUE"), - wxT("MIDNIGHT BLUE"), - wxT("GREY"), - wxT("PURPLE"), - wxT("KHAKI"), - - wxT("BLACK"), - wxT("MEDIUM FOREST GREEN"), - wxT("KHAKI"), - wxT("DARK GREY"), - wxT("SEA GREEN"), - wxT("LIGHT GREY"), - wxT("MEDIUM SLATE BLUE"), - wxT("WHITE") - }; - -/* - * Generic wxFontDialog - */ - -void wxGenericFontDialog::Init() -{ - m_useEvents = false; - m_previewer = NULL; - Create( m_parent ) ; -} - -wxGenericFontDialog::~wxGenericFontDialog() -{ -} - -void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - EndModal(wxID_CANCEL); -} - -bool wxGenericFontDialog::DoCreate(wxWindow *parent) -{ - parent = GetParentForModalDialog(parent, 0); - - if ( !wxDialog::Create( parent , wxID_ANY , wxT("Choose Font") , - wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, - wxT("fontdialog") ) ) - { - wxFAIL_MSG( wxT("wxFontDialog creation failed") ); - return false; - } - - InitializeFont(); - CreateWidgets(); - - // sets initial font in preview area - DoChangeFont(); - - return true; -} - -int wxGenericFontDialog::ShowModal() -{ - int ret = wxDialog::ShowModal(); - - if (ret != wxID_CANCEL) - { - m_fontData.m_chosenFont = m_dialogFont; - } - - return ret; -} - -// This should be application-settable -static bool ShowToolTips() { return false; } - -void wxGenericFontDialog::CreateWidgets() -{ - wxString *families = new wxString[6], - *styles = new wxString[3], - *weights = new wxString[3]; - families[0] = _("Roman"); - families[1] = _("Decorative"); - families[2] = _("Modern"); - families[3] = _("Script"); - families[4] = _("Swiss" ); - families[5] = _("Teletype" ); - styles[0] = _("Normal"); - styles[1] = _("Italic"); - styles[2] = _("Slant"); - weights[0] = _("Normal"); - weights[1] = _("Light"); - weights[2] = _("Bold"); - -#if !USE_SPINCTRL_FOR_POINT_SIZE - wxString *pointSizes = new wxString[40]; - int i; - for ( i = 0; i < 40; i++) - { - wxChar buf[5]; - wxSprintf(buf, wxT("%d"), i + 1); - pointSizes[i] = buf; - } -#endif - - // layout - - bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - int noCols, noRows; - if (is_pda) - { - noCols = 2; noRows = 3; - } - else - { - noCols = 3; noRows = 2; - } - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); - this->SetSizer(itemBoxSizer2); - this->SetAutoLayout(true); - - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5); - - wxFlexGridSizer* itemGridSizer4 = new wxFlexGridSizer(noRows, noCols, 0, 0); - itemBoxSizer3->Add(itemGridSizer4, 0, wxGROW, 5); - - wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - wxStaticText* itemStaticText6 = new wxStaticText( this, wxID_STATIC, _("&Font family:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - wxChoice* itemChoice7 = new wxChoice( this, wxID_FONT_FAMILY, wxDefaultPosition, wxDefaultSize, 5, families, 0 ); - itemChoice7->SetHelpText(_("The font family.")); - if (ShowToolTips()) - itemChoice7->SetToolTip(_("The font family.")); - itemBoxSizer5->Add(itemChoice7, 0, wxALIGN_LEFT|wxALL, 5); - - wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - wxStaticText* itemStaticText9 = new wxStaticText( this, wxID_STATIC, _("&Style:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - wxChoice* itemChoice10 = new wxChoice( this, wxID_FONT_STYLE, wxDefaultPosition, wxDefaultSize, 3, styles, 0 ); - itemChoice10->SetHelpText(_("The font style.")); - if (ShowToolTips()) - itemChoice10->SetToolTip(_("The font style.")); - itemBoxSizer8->Add(itemChoice10, 0, wxALIGN_LEFT|wxALL, 5); - - wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - wxStaticText* itemStaticText12 = new wxStaticText( this, wxID_STATIC, _("&Weight:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - wxChoice* itemChoice13 = new wxChoice( this, wxID_FONT_WEIGHT, wxDefaultPosition, wxDefaultSize, 3, weights, 0 ); - itemChoice13->SetHelpText(_("The font weight.")); - if (ShowToolTips()) - itemChoice13->SetToolTip(_("The font weight.")); - itemBoxSizer11->Add(itemChoice13, 0, wxALIGN_LEFT|wxALL, 5); - - wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - if (m_fontData.GetEnableEffects()) - { - wxStaticText* itemStaticText15 = new wxStaticText( this, wxID_STATIC, _("C&olour:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - wxSize colourSize = wxDefaultSize; - if (is_pda) - colourSize.x = 100; - - wxChoice* itemChoice16 = new wxChoice( this, wxID_FONT_COLOUR, wxDefaultPosition, colourSize, NUM_COLS, wxColourDialogNames, 0 ); - itemChoice16->SetHelpText(_("The font colour.")); - if (ShowToolTips()) - itemChoice16->SetToolTip(_("The font colour.")); - itemBoxSizer14->Add(itemChoice16, 0, wxALIGN_LEFT|wxALL, 5); - } - - wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - wxStaticText* itemStaticText18 = new wxStaticText( this, wxID_STATIC, _("&Point size:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - -#if USE_SPINCTRL_FOR_POINT_SIZE - wxSpinCtrl* spinCtrl = new wxSpinCtrl(this, wxID_FONT_SIZE, wxT("12"), wxDefaultPosition, wxSize(80, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 500, 12); - spinCtrl->SetHelpText(_("The font point size.")); - if (ShowToolTips()) - spinCtrl->SetToolTip(_("The font point size.")); - - itemBoxSizer17->Add(spinCtrl, 0, wxALIGN_LEFT|wxALL, 5); -#else - wxChoice* itemChoice19 = new wxChoice( this, wxID_FONT_SIZE, wxDefaultPosition, wxDefaultSize, 40, pointSizes, 0 ); - itemChoice19->SetHelpText(_("The font point size.")); - if (ShowToolTips()) - itemChoice19->SetToolTip(_("The font point size.")); - itemBoxSizer17->Add(itemChoice19, 0, wxALIGN_LEFT|wxALL, 5); -#endif - - if (m_fontData.GetEnableEffects()) - { - wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); - wxCheckBox* itemCheckBox21 = new wxCheckBox( this, wxID_FONT_UNDERLINE, _("&Underline"), wxDefaultPosition, wxDefaultSize, 0 ); - itemCheckBox21->SetValue(false); - itemCheckBox21->SetHelpText(_("Whether the font is underlined.")); - if (ShowToolTips()) - itemCheckBox21->SetToolTip(_("Whether the font is underlined.")); - itemBoxSizer20->Add(itemCheckBox21, 0, wxALIGN_LEFT|wxALL, 5); - } - - if (!is_pda) - itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - - wxStaticText* itemStaticText23 = new wxStaticText( this, wxID_STATIC, _("Preview:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer3->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - wxFontPreviewer* itemWindow24 = new wxFontPreviewer( this ); - m_previewer = itemWindow24; - itemWindow24->SetHelpText(_("Shows the font preview.")); - if (ShowToolTips()) - itemWindow24->SetToolTip(_("Shows the font preview.")); - itemBoxSizer3->Add(itemWindow24, 1, wxGROW|wxALL, 5); - - wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer3->Add(itemBoxSizer25, 0, wxGROW, 5); - itemBoxSizer25->Add(5, 5, 1, wxGROW|wxALL, 5); - -#ifdef __WXMAC__ - wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - if (ShowToolTips()) - itemButton28->SetToolTip(_("Click to cancel the font selection.")); - itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton27->SetDefault(); - itemButton27->SetHelpText(_("Click to confirm the font selection.")); - if (ShowToolTips()) - itemButton27->SetToolTip(_("Click to confirm the font selection.")); - itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#else - wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton27->SetDefault(); - itemButton27->SetHelpText(_("Click to confirm the font selection.")); - if (ShowToolTips()) - itemButton27->SetToolTip(_("Click to confirm the font selection.")); - itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - if (ShowToolTips()) - itemButton28->SetToolTip(_("Click to cancel the font selection.")); - itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#endif - - m_familyChoice = (wxChoice*) FindWindow(wxID_FONT_FAMILY); - m_styleChoice = (wxChoice*) FindWindow(wxID_FONT_STYLE); - m_weightChoice = (wxChoice*) FindWindow(wxID_FONT_WEIGHT); - m_colourChoice = (wxChoice*) FindWindow(wxID_FONT_COLOUR); - m_underLineCheckBox = (wxCheckBox*) FindWindow(wxID_FONT_UNDERLINE); - - m_familyChoice->SetStringSelection( wxFontFamilyIntToString(m_dialogFont.GetFamily()) ); - m_styleChoice->SetStringSelection(wxFontStyleIntToString(m_dialogFont.GetStyle())); - m_weightChoice->SetStringSelection(wxFontWeightIntToString(m_dialogFont.GetWeight())); - - if (m_colourChoice) - { - wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour())); - if ( name.empty() ) - m_colourChoice->SetStringSelection(wxT("BLACK")); - else - m_colourChoice->SetStringSelection(name); - } - - if (m_underLineCheckBox) - { - m_underLineCheckBox->SetValue(m_dialogFont.GetUnderlined()); - } - -#if USE_SPINCTRL_FOR_POINT_SIZE - spinCtrl->SetValue(m_dialogFont.GetPointSize()); -#else - m_pointSizeChoice = (wxChoice*) FindWindow(wxID_FONT_SIZE); - m_pointSizeChoice->SetSelection(m_dialogFont.GetPointSize()-1); -#endif - - GetSizer()->SetItemMinSize(m_previewer, is_pda ? 100 : 430, is_pda ? 40 : 100); - GetSizer()->SetSizeHints(this); - GetSizer()->Fit(this); - - Centre(wxBOTH); - - delete[] families; - delete[] styles; - delete[] weights; -#if !USE_SPINCTRL_FOR_POINT_SIZE - delete[] pointSizes; -#endif - - // Don't block events any more - m_useEvents = true; - -} - -void wxGenericFontDialog::InitializeFont() -{ - int fontFamily = wxSWISS; - int fontWeight = wxNORMAL; - int fontStyle = wxNORMAL; - int fontSize = 12; - bool fontUnderline = false; - - if (m_fontData.m_initialFont.IsOk()) - { - fontFamily = m_fontData.m_initialFont.GetFamily(); - fontWeight = m_fontData.m_initialFont.GetWeight(); - fontStyle = m_fontData.m_initialFont.GetStyle(); - fontSize = m_fontData.m_initialFont.GetPointSize(); - fontUnderline = m_fontData.m_initialFont.GetUnderlined(); - } - - m_dialogFont = wxFont(fontSize, fontFamily, fontStyle, - fontWeight, fontUnderline); - - if (m_previewer) - m_previewer->SetFont(m_dialogFont); -} - -void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event)) -{ - DoChangeFont(); -} - -void wxGenericFontDialog::DoChangeFont() -{ - if (!m_useEvents) return; - - int fontFamily = wxFontFamilyStringToInt(m_familyChoice->GetStringSelection()); - int fontWeight = wxFontWeightStringToInt(m_weightChoice->GetStringSelection()); - int fontStyle = wxFontStyleStringToInt(m_styleChoice->GetStringSelection()); -#if USE_SPINCTRL_FOR_POINT_SIZE - wxSpinCtrl* fontSizeCtrl = wxDynamicCast(FindWindow(wxID_FONT_SIZE), wxSpinCtrl); - int fontSize = fontSizeCtrl->GetValue(); -#else - int fontSize = wxAtoi(m_pointSizeChoice->GetStringSelection()); -#endif - - // Start with previous underline setting, we want to retain it even if we can't edit it - // m_dialogFont is always initialized because of the call to InitializeFont - int fontUnderline = m_dialogFont.GetUnderlined(); - - if (m_underLineCheckBox) - { - fontUnderline = m_underLineCheckBox->GetValue(); - } - - m_dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0)); - m_previewer->SetFont(m_dialogFont); - - if ( m_colourChoice ) - { - if ( !m_colourChoice->GetStringSelection().empty() ) - { - wxColour col = wxTheColourDatabase->Find(m_colourChoice->GetStringSelection()); - if (col.IsOk()) - { - m_fontData.m_fontColour = col; - } - } - } - // Update color here so that we can also use the color originally passed in - // (EnableEffects may be false) - if (m_fontData.m_fontColour.IsOk()) - m_previewer->SetForegroundColour(m_fontData.m_fontColour); - - m_previewer->Refresh(); -} - -#if USE_SPINCTRL_FOR_POINT_SIZE -void wxGenericFontDialog::OnChangeSize(wxSpinEvent& WXUNUSED(event)) -{ - DoChangeFont(); -} -#endif - -#endif - // wxUSE_FONTDLG diff --git a/Source/3rd Party/wx/src/generic/fontpickerg.cpp b/Source/3rd Party/wx/src/generic/fontpickerg.cpp index ccdea0d43..e01bcd544 100644 --- a/Source/3rd Party/wx/src/generic/fontpickerg.cpp +++ b/Source/3rd Party/wx/src/generic/fontpickerg.cpp @@ -4,6 +4,7 @@ // Author: Francesco Montorsi // Modified by: // Created: 15/04/2006 +// RCS-ID: $Id: fontpickerg.cpp 52835 2008-03-26 15:49:08Z JS $ // Copyright: (c) Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,6 +35,7 @@ // implementation // ============================================================================ +wxFontData wxGenericFontButton::ms_data; IMPLEMENT_DYNAMIC_CLASS(wxGenericFontButton, wxButton) // ---------------------------------------------------------------------------- @@ -46,8 +48,8 @@ bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString &name) { wxString label = (style & wxFNTP_FONTDESC_AS_LABEL) ? - wxString() : // label will be updated by UpdateFont - _("Choose font"); + wxEmptyString : // label will be updated by UpdateFont + wxT("Choose font"); // create this button if (!wxButton::Create( parent, id, label, pos, @@ -58,7 +60,7 @@ bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id, } // and handle user clicks on it - Connect(GetId(), wxEVT_BUTTON, + Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxGenericFontButton::OnButtonClick), NULL, this); @@ -71,22 +73,22 @@ bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id, void wxGenericFontButton::InitFontData() { - m_data.SetAllowSymbols(true); - m_data.SetColour(*wxBLACK); - m_data.EnableEffects(true); + ms_data.SetAllowSymbols(true); + ms_data.SetColour(*wxBLACK); + ms_data.EnableEffects(true); } void wxGenericFontButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) { - // update the wxFontData to be shown in the dialog - m_data.SetInitialFont(m_selectedFont); + // update the wxFontData to be shown in the the dialog + ms_data.SetInitialFont(m_selectedFont); // create the font dialog and display it - wxFontDialog dlg(this, m_data); + wxFontDialog dlg(this, ms_data); if (dlg.ShowModal() == wxID_OK) { - m_data = dlg.GetFontData(); - SetSelectedFont(m_data.GetChosenFont()); + ms_data = dlg.GetFontData(); + SetSelectedFont(ms_data.GetChosenFont()); // fire an event wxFontPickerEvent event(this, GetId(), m_selectedFont); @@ -96,10 +98,10 @@ void wxGenericFontButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) void wxGenericFontButton::UpdateFont() { - if ( !m_selectedFont.IsOk() ) + if ( !m_selectedFont.Ok() ) return; - SetForegroundColour(m_data.GetColour()); + SetForegroundColour(ms_data.GetColour()); if (HasFlag(wxFNTP_USEFONT_FOR_LABEL)) { diff --git a/Source/3rd Party/wx/src/generic/fswatcherg.cpp b/Source/3rd Party/wx/src/generic/fswatcherg.cpp deleted file mode 100644 index a188a3095..000000000 --- a/Source/3rd Party/wx/src/generic/fswatcherg.cpp +++ /dev/null @@ -1,21 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/fswatcherg.cpp -// Purpose: wxPollingFileSystemWatcher -// Author: Bartosz Bekier -// Created: 2009-05-26 -// Copyright: (c) 2009 Bartosz Bekier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_FSWATCHER - -#include "wx/fswatcher.h" - -#endif // wxUSE_FSWATCHER diff --git a/Source/3rd Party/wx/src/generic/graphicc.cpp b/Source/3rd Party/wx/src/generic/graphicc.cpp index 28dcd51f0..75744b086 100644 --- a/Source/3rd Party/wx/src/generic/graphicc.cpp +++ b/Source/3rd Party/wx/src/generic/graphicc.cpp @@ -4,6 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 2006-10-03 +// RCS-ID: $Id: graphicc.cpp 66928 2011-02-16 23:31:13Z JS $ // Copyright: (c) 2006 Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,37 +12,62 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ - #pragma hdrstop +#pragma hdrstop #endif #if wxUSE_GRAPHICS_CONTEXT +#ifndef WX_PRECOMP +#include "wx/image.h" +#include "wx/window.h" +#include "wx/dc.h" +#include "wx/utils.h" +#include "wx/dialog.h" +#include "wx/app.h" +#include "wx/bitmap.h" +#include "wx/dcmemory.h" +#include "wx/log.h" +#include "wx/icon.h" +#include "wx/dcprint.h" +#include "wx/module.h" +#endif + +#ifdef __WXGTK__ +#include "wx/gtk/win_gtk.h" +#endif + #include "wx/graphics.h" +#include "wx/rawbmp.h" #if wxUSE_CAIRO -// keep cairo.h from defining dllimport as we're defining the symbols inside -// the wx dll in order to load them dynamically. -#define cairo_public +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- -#include +const double RAD2DEG = 180.0 / M_PI; -bool wxCairoInit(); +//----------------------------------------------------------------------------- +// Local functions +//----------------------------------------------------------------------------- -#ifndef WX_PRECOMP - #include "wx/bitmap.h" - #include "wx/icon.h" - #include "wx/dcclient.h" - #include "wx/dcmemory.h" - #include "wx/dcprint.h" - #include "wx/window.h" -#endif +static inline double dmin(double a, double b) +{ + return a < b ? a : b; +} +static inline double dmax(double a, double b) +{ + return a > b ? a : b; +} -#include "wx/private/graphics.h" -#include "wx/rawbmp.h" -#include "wx/vector.h" - -using namespace std; +static inline double DegToRad(double deg) +{ + return (deg * M_PI) / 180.0; +} +static inline double RadToDeg(double deg) +{ + return (deg * 180.0) / M_PI; +} //----------------------------------------------------------------------------- // device context implementation @@ -72,24 +98,10 @@ using namespace std; #include #ifdef __WXMSW__ #include -// Notice that the order is important: cairo-win32.h includes windows.h which -// pollutes the global name space with macros so include our own header which -// #undefines them after it. -#include "wx/msw/private.h" #endif #ifdef __WXGTK__ #include -#include "wx/fontutil.h" -#ifndef __WXGTK3__ -#include "wx/gtk/dc.h" -#endif -#endif - -#ifdef __WXMAC__ -#include "wx/osx/private.h" -#include -#include #endif class WXDLLIMPEXP_CORE wxCairoPathData : public wxGraphicsPathData @@ -133,7 +145,7 @@ public : /* - // appends a rectangle as a new closed subpath + // appends a rectangle as a new closed subpath virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) ; // appends an ellipsis as a new closed subpath fitting the passed rectangle virtual void AddEllipsis( wxDouble x, wxDouble y, wxDouble w , wxDouble h ) ; @@ -154,7 +166,7 @@ public : // gets the bounding box enclosing all points (possibly including control points) virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const; - virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxWINDING_RULE) const; + virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxWINDING_RULE) const; private : cairo_t* m_pathContext; @@ -172,13 +184,13 @@ public : virtual void Concat( const wxGraphicsMatrixData *t ); // sets the matrix to the respective values - virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, + virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, wxDouble tx=0.0, wxDouble ty=0.0); // gets the component valuess of the matrix virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL, wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const; - + // makes this the inverse matrix virtual void Invert(); @@ -217,44 +229,7 @@ private: cairo_matrix_t m_matrix ; } ; -// Common base class for pens and brushes. -class wxCairoPenBrushBaseData : public wxGraphicsObjectRefData -{ -public: - wxCairoPenBrushBaseData(wxGraphicsRenderer* renderer, - const wxColour& col, - bool isTransparent); - virtual ~wxCairoPenBrushBaseData(); - - virtual void Apply( wxGraphicsContext* context ); - -protected: - // Call this to use the given bitmap as stipple. Bitmap must be non-null - // and valid. - void InitStipple(wxBitmap* bmp); - - // Call this to use the given hatch style. Hatch style must be valid. - void InitHatch(wxHatchStyle hatchStyle); - - - double m_red; - double m_green; - double m_blue; - double m_alpha; - - cairo_pattern_t* m_pattern; - class wxCairoBitmapData* m_bmpdata; - -private: - // Called once to allocate m_pattern if needed. - void InitHatchPattern(cairo_t* ctext); - - wxHatchStyle m_hatchStyle; - - wxDECLARE_NO_COPY_CLASS(wxCairoPenBrushBaseData); -}; - -class WXDLLIMPEXP_CORE wxCairoPenData : public wxCairoPenBrushBaseData +class WXDLLIMPEXP_CORE wxCairoPenData : public wxGraphicsObjectRefData { public: wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ); @@ -267,7 +242,12 @@ public: private : double m_width; - + + double m_red; + double m_green; + double m_blue; + double m_alpha; + cairo_line_cap_t m_cap; cairo_line_join_t m_join; @@ -275,106 +255,62 @@ private : const double *m_lengths; double *m_userLengths; - wxDECLARE_NO_COPY_CLASS(wxCairoPenData); + wxPen m_pen; }; -class WXDLLIMPEXP_CORE wxCairoBrushData : public wxCairoPenBrushBaseData +class WXDLLIMPEXP_CORE wxCairoBrushData : public wxGraphicsObjectRefData { public: wxCairoBrushData( wxGraphicsRenderer* renderer ); wxCairoBrushData( wxGraphicsRenderer* renderer, const wxBrush &brush ); + ~wxCairoBrushData (); - void CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops); - void CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, wxDouble radius, - const wxGraphicsGradientStops& stops); + virtual void Apply( wxGraphicsContext* context ); + void CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2 ); + void CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor ); protected: virtual void Init(); - // common part of Create{Linear,Radial}GradientBrush() - void AddGradientStops(const wxGraphicsGradientStops& stops); +private : + double m_red; + double m_green; + double m_blue; + double m_alpha; + + cairo_pattern_t* m_brushPattern; }; class wxCairoFontData : public wxGraphicsObjectRefData { public: wxCairoFontData( wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col ); - wxCairoFontData(wxGraphicsRenderer* renderer, - double sizeInPixels, - const wxString& facename, - int flags, - const wxColour& col); ~wxCairoFontData(); - virtual bool Apply( wxGraphicsContext* context ); -#ifdef __WXGTK__ - const wxFont& GetFont() const { return m_wxfont; } -#endif + virtual void Apply( wxGraphicsContext* context ); private : - void InitColour(const wxColour& col); - void InitFontComponents(const wxString& facename, - cairo_font_slant_t slant, - cairo_font_weight_t weight); - + wxCharBuffer m_fontName; double m_size; + cairo_font_slant_t m_slant; + cairo_font_weight_t m_weight; double m_red; double m_green; double m_blue; double m_alpha; -#ifdef __WXMAC__ - cairo_font_face_t *m_font; -#elif defined(__WXGTK__) - wxFont m_wxfont; -#endif - - // These members are used when the font is created from its face name and - // flags (and not from wxFont) and also even when creating it from wxFont - // on the platforms not covered above. - // - // Notice that we can't use cairo_font_face_t instead of storing those, - // even though it would be simpler and need less #ifdefs, because - // cairo_toy_font_face_create() that we'd need to create it is only - // available in Cairo 1.8 and we require just 1.2 currently. If we do drop - // support for < 1.8 versions in the future it would be definitely better - // to use cairo_toy_font_face_create() instead. - wxCharBuffer m_fontName; - cairo_font_slant_t m_slant; - cairo_font_weight_t m_weight; }; -class wxCairoBitmapData : public wxGraphicsBitmapData +class wxCairoBitmapData : public wxGraphicsObjectRefData { public: wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ); -#if wxUSE_IMAGE - wxCairoBitmapData(wxGraphicsRenderer* renderer, const wxImage& image); -#endif // wxUSE_IMAGE - wxCairoBitmapData( wxGraphicsRenderer* renderer, cairo_surface_t* bitmap ); ~wxCairoBitmapData(); virtual cairo_surface_t* GetCairoSurface() { return m_surface; } virtual cairo_pattern_t* GetCairoPattern() { return m_pattern; } - virtual void* GetNativeBitmap() const { return m_surface; } virtual wxSize GetSize() { return wxSize(m_width, m_height); } - -#if wxUSE_IMAGE - wxImage ConvertToImage() const; -#endif // wxUSE_IMAGE - private : - // Allocate m_buffer for the bitmap of the given size in the given format. - // - // Returns the stride used for the buffer. - int InitBuffer(int width, int height, cairo_format_t format); - - // Really create the surface using the buffer (which was supposed to be - // filled since InitBuffer() call). - void InitSurface(cairo_format_t format, int stride); - - cairo_surface_t* m_surface; cairo_pattern_t* m_pattern; int m_width; @@ -384,46 +320,22 @@ private : class WXDLLIMPEXP_CORE wxCairoContext : public wxGraphicsContext { + DECLARE_NO_COPY_CLASS(wxCairoContext) + public: wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ); - wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ); -#if wxUSE_PRINTING_ARCHITECTURE - wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& dc ); -#endif -#ifdef __WXGTK__ - wxCairoContext( wxGraphicsRenderer* renderer, GdkWindow *window ); -#endif #ifdef __WXMSW__ wxCairoContext( wxGraphicsRenderer* renderer, HDC context ); +#endif +#ifdef __WXGTK__ + wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ); #endif wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context ); wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window); - - // If this ctor is used, Init() must be called by the derived class later. - wxCairoContext( wxGraphicsRenderer* renderer ); - + wxCairoContext(); virtual ~wxCairoContext(); - virtual bool ShouldOffset() const - { - if ( !m_enableOffset ) - return false; - - int penwidth = 0 ; - if ( !m_pen.IsNull() ) - { - penwidth = (int)((wxCairoPenData*)m_pen.GetRefData())->GetWidth(); - if ( penwidth == 0 ) - penwidth = 1; - } - return ( penwidth % 2 ) == 1; - } - virtual void Clip( const wxRegion ®ion ); -#ifdef __WXMSW__ - cairo_surface_t* m_mswSurface; - WindowHDC m_mswWindowHDC; -#endif // clips drawings to the rect virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); @@ -433,18 +345,8 @@ public: virtual void * GetNativeContext(); - virtual bool SetAntialiasMode(wxAntialiasMode antialias); - - virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation); - - virtual bool SetCompositionMode(wxCompositionMode op); - - virtual void BeginLayer(wxDouble opacity); - - virtual void EndLayer(); - virtual void StrokePath( const wxGraphicsPath& p ); - virtual void FillPath( const wxGraphicsPath& p , wxPolygonFillMode fillStyle = wxWINDING_RULE ); + virtual void FillPath( const wxGraphicsPath& p , int fillStyle = wxWINDING_RULE ); virtual void Translate( wxDouble dx , wxDouble dy ); virtual void Scale( wxDouble xScale , wxDouble yScale ); @@ -459,191 +361,24 @@ public: // gets the matrix of this context virtual wxGraphicsMatrix GetTransform() const; - virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + void DrawGraphicsBitmapInternal( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); virtual void DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); virtual void PushState(); virtual void PopState(); + virtual void DrawText( const wxString &str, wxDouble x, wxDouble y); virtual void GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, wxDouble *descent, wxDouble *externalLeading ) const; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const; -protected: - virtual void DoDrawText( const wxString &str, wxDouble x, wxDouble y ); - - void Init(cairo_t *context); - private: cairo_t* m_context; - - wxVector m_layerOpacities; - - wxDECLARE_NO_COPY_CLASS(wxCairoContext); +#ifdef __WXMSW__ + cairo_surface_t* m_mswSurface; +#endif }; -#if wxUSE_IMAGE -// ---------------------------------------------------------------------------- -// wxCairoImageContext: context associated with a wxImage. -// ---------------------------------------------------------------------------- - -class wxCairoImageContext : public wxCairoContext -{ -public: - wxCairoImageContext(wxGraphicsRenderer* renderer, wxImage& image) : - wxCairoContext(renderer), - m_image(image), - m_data(renderer, image) - { - Init(cairo_create(m_data.GetCairoSurface())); - } - - virtual ~wxCairoImageContext() - { - m_image = m_data.ConvertToImage(); - } - -private: - wxImage& m_image; - wxCairoBitmapData m_data; - - wxDECLARE_NO_COPY_CLASS(wxCairoImageContext); -}; -#endif // wxUSE_IMAGE - -// ---------------------------------------------------------------------------- -// wxCairoPenBrushBaseData implementation -//----------------------------------------------------------------------------- - -wxCairoPenBrushBaseData::wxCairoPenBrushBaseData(wxGraphicsRenderer* renderer, - const wxColour& col, - bool isTransparent) - : wxGraphicsObjectRefData(renderer) -{ - m_hatchStyle = wxHATCHSTYLE_INVALID; - m_pattern = NULL; - m_bmpdata = NULL; - - if ( isTransparent ) - { - m_red = - m_green = - m_blue = - m_alpha = 0; - } - else // non-transparent - { - m_red = col.Red()/255.0; - m_green = col.Green()/255.0; - m_blue = col.Blue()/255.0; - m_alpha = col.Alpha()/255.0; - } -} - -wxCairoPenBrushBaseData::~wxCairoPenBrushBaseData() -{ - if (m_bmpdata) - { - // Deleting the bitmap data also deletes the pattern referenced by - // m_pattern, so set it to NULL to avoid deleting it twice. - delete m_bmpdata; - m_pattern = NULL; - } - if (m_pattern) - cairo_pattern_destroy(m_pattern); -} - -void wxCairoPenBrushBaseData::InitHatchPattern(cairo_t* ctext) -{ - cairo_surface_t* const - surface = cairo_surface_create_similar( - cairo_get_target(ctext), CAIRO_CONTENT_COLOR_ALPHA, 10, 10 - ); - - cairo_t* const cr = cairo_create(surface); - cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE); - cairo_set_line_width(cr, 1); - cairo_set_line_join(cr,CAIRO_LINE_JOIN_MITER); - - switch ( m_hatchStyle ) - { - case wxHATCHSTYLE_CROSS: - cairo_move_to(cr, 5, 0); - cairo_line_to(cr, 5, 10); - cairo_move_to(cr, 0, 5); - cairo_line_to(cr, 10, 5); - break; - - case wxHATCHSTYLE_BDIAGONAL: - cairo_move_to(cr, 0, 10); - cairo_line_to(cr, 10, 0); - break; - - case wxHATCHSTYLE_FDIAGONAL: - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 10, 10); - break; - - case wxHATCHSTYLE_CROSSDIAG: - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 10, 10); - cairo_move_to(cr, 10, 0); - cairo_line_to(cr, 0, 10); - break; - - case wxHATCHSTYLE_HORIZONTAL: - cairo_move_to(cr, 0, 5); - cairo_line_to(cr, 10, 5); - break; - - case wxHATCHSTYLE_VERTICAL: - cairo_move_to(cr, 5, 0); - cairo_line_to(cr, 5, 10); - break; - - default: - wxFAIL_MSG(wxS("Invalid hatch pattern style.")); - } - - cairo_set_source_rgba(cr, m_red, m_green, m_blue, m_alpha); - cairo_stroke(cr); - - cairo_destroy(cr); - - m_pattern = cairo_pattern_create_for_surface(surface); - cairo_surface_destroy(surface); - cairo_pattern_set_extend(m_pattern, CAIRO_EXTEND_REPEAT); -} - -void wxCairoPenBrushBaseData::InitStipple(wxBitmap* bmp) -{ - wxCHECK_RET( bmp && bmp->IsOk(), wxS("Invalid stippled bitmap") ); - - m_bmpdata = new wxCairoBitmapData(GetRenderer(), *bmp); - m_pattern = m_bmpdata->GetCairoPattern(); - cairo_pattern_set_extend(m_pattern, CAIRO_EXTEND_REPEAT); -} - -void wxCairoPenBrushBaseData::InitHatch(wxHatchStyle hatchStyle) -{ - // We can't create m_pattern right now as we don't have the Cairo context - // needed for it, so just remember that we need to do it. - m_hatchStyle = hatchStyle; -} - -void wxCairoPenBrushBaseData::Apply( wxGraphicsContext* context ) -{ - cairo_t* const ctext = (cairo_t*) context->GetNativeContext(); - - if ( m_hatchStyle != wxHATCHSTYLE_INVALID && !m_pattern ) - InitHatchPattern(ctext); - - if ( m_pattern ) - cairo_set_source(ctext, m_pattern); - else - cairo_set_source_rgba(ctext, m_red, m_green, m_blue, m_alpha); -} - //----------------------------------------------------------------------------- // wxCairoPenData implementation //----------------------------------------------------------------------------- @@ -662,14 +397,20 @@ void wxCairoPenData::Init() } wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) - : wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent()) -{ +: wxGraphicsObjectRefData(renderer) +{ Init(); - m_width = pen.GetWidth(); + m_pen = pen; + m_width = m_pen.GetWidth(); if (m_width <= 0.0) m_width = 0.1; - switch ( pen.GetCap() ) + m_red = m_pen.GetColour().Red()/255.0; + m_green = m_pen.GetColour().Green()/255.0; + m_blue = m_pen.GetColour().Blue()/255.0; + m_alpha = m_pen.GetColour().Alpha()/255.0; + + switch ( m_pen.GetCap() ) { case wxCAP_ROUND : m_cap = CAIRO_LINE_CAP_ROUND; @@ -688,7 +429,7 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) break; } - switch ( pen.GetJoin() ) + switch ( m_pen.GetJoin() ) { case wxJOIN_BEVEL : m_join = CAIRO_LINE_JOIN_BEVEL; @@ -725,37 +466,37 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) 9.0 , 6.0 , 3.0 , 3.0 }; - switch ( pen.GetStyle() ) + switch ( m_pen.GetStyle() ) { - case wxPENSTYLE_SOLID : + case wxSOLID : break; - case wxPENSTYLE_DOT : + case wxDOT : m_count = WXSIZEOF(dotted); m_userLengths = new double[ m_count ] ; memcpy( m_userLengths, dotted, sizeof(dotted) ); m_lengths = m_userLengths; break; - case wxPENSTYLE_LONG_DASH : - m_lengths = dashed ; + case wxLONG_DASH : + m_lengths = dotted ; m_count = WXSIZEOF(dashed); break; - case wxPENSTYLE_SHORT_DASH : - m_lengths = short_dashed ; + case wxSHORT_DASH : + m_lengths = dotted ; m_count = WXSIZEOF(short_dashed); break; - case wxPENSTYLE_DOT_DASH : - m_lengths = dotted_dashed ; + case wxDOT_DASH : + m_lengths = dotted ; m_count = WXSIZEOF(dotted_dashed); break; - case wxPENSTYLE_USER_DASH : + case wxUSER_DASH : { wxDash *wxdashes ; - m_count = pen.GetDashes( &wxdashes ) ; + m_count = m_pen.GetDashes( &wxdashes ) ; if ((wxdashes != NULL) && (m_count > 0)) { m_userLengths = new double[m_count] ; @@ -772,18 +513,53 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) m_lengths = m_userLengths ; } break; - - case wxPENSTYLE_STIPPLE : - case wxPENSTYLE_STIPPLE_MASK : - case wxPENSTYLE_STIPPLE_MASK_OPAQUE : - InitStipple(pen.GetStipple()); - break; - - default : - if ( pen.GetStyle() >= wxPENSTYLE_FIRST_HATCH - && pen.GetStyle() <= wxPENSTYLE_LAST_HATCH ) + case wxSTIPPLE : { - InitHatch(static_cast(pen.GetStyle())); + /* + wxBitmap* bmp = pen.GetStipple(); + if ( bmp && bmp->Ok() ) + { + wxDELETE( m_penImage ); + wxDELETE( m_penBrush ); + m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),(HPALETTE)bmp->GetPalette()->GetHPALETTE()); + m_penBrush = new TextureBrush(m_penImage); + m_pen->SetBrush( m_penBrush ); + } + */ + } + break; + default : + if ( m_pen.GetStyle() >= wxFIRST_HATCH && m_pen.GetStyle() <= wxLAST_HATCH ) + { + /* + wxDELETE( m_penBrush ); + HatchStyle style = HatchStyleHorizontal; + switch( pen.GetStyle() ) + { + case wxBDIAGONAL_HATCH : + style = HatchStyleBackwardDiagonal; + break ; + case wxCROSSDIAG_HATCH : + style = HatchStyleDiagonalCross; + break ; + case wxFDIAGONAL_HATCH : + style = HatchStyleForwardDiagonal; + break ; + case wxCROSS_HATCH : + style = HatchStyleCross; + break ; + case wxHORIZONTAL_HATCH : + style = HatchStyleHorizontal; + break ; + case wxVERTICAL_HATCH : + style = HatchStyleVertical; + break ; + + } + m_penBrush = new HatchBrush(style,Color( pen.GetColour().Alpha() , pen.GetColour().Red() , + pen.GetColour().Green() , pen.GetColour().Blue() ), Color.Transparent ); + m_pen->SetBrush( m_penBrush ) + */ } break; } @@ -791,10 +567,9 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) void wxCairoPenData::Apply( wxGraphicsContext* context ) { - wxCairoPenBrushBaseData::Apply(context); - cairo_t * ctext = (cairo_t*) context->GetNativeContext(); cairo_set_line_width(ctext,m_width); + cairo_set_source_rgba(ctext,m_red,m_green, m_blue,m_alpha); cairo_set_line_cap(ctext,m_cap); cairo_set_line_join(ctext,m_join); cairo_set_dash(ctext,(double*)m_lengths,m_count,0.0); @@ -805,199 +580,143 @@ void wxCairoPenData::Apply( wxGraphicsContext* context ) //----------------------------------------------------------------------------- wxCairoBrushData::wxCairoBrushData( wxGraphicsRenderer* renderer ) - : wxCairoPenBrushBaseData(renderer, wxColour(), true /* transparent */) + : wxGraphicsObjectRefData( renderer ) { Init(); } -wxCairoBrushData::wxCairoBrushData( wxGraphicsRenderer* renderer, - const wxBrush &brush ) - : wxCairoPenBrushBaseData(renderer, brush.GetColour(), brush.IsTransparent()) +wxCairoBrushData::wxCairoBrushData( wxGraphicsRenderer* renderer, const wxBrush &brush ) + : wxGraphicsObjectRefData(renderer) { Init(); - - switch ( brush.GetStyle() ) + + m_red = brush.GetColour().Red()/255.0; + m_green = brush.GetColour().Green()/255.0; + m_blue = brush.GetColour().Blue()/255.0; + m_alpha = brush.GetColour().Alpha()/255.0; + /* + if ( brush.GetStyle() == wxSOLID) { - case wxBRUSHSTYLE_STIPPLE: - case wxBRUSHSTYLE_STIPPLE_MASK: - case wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE: - InitStipple(brush.GetStipple()); - break; + m_brush = new SolidBrush( Color( brush.GetColour().Alpha() , brush.GetColour().Red() , + brush.GetColour().Green() , brush.GetColour().Blue() ) ); + } + else if ( brush.IsHatch() ) + { + HatchStyle style = HatchStyleHorizontal; + switch( brush.GetStyle() ) + { + case wxBDIAGONAL_HATCH : + style = HatchStyleBackwardDiagonal; + break ; + case wxCROSSDIAG_HATCH : + style = HatchStyleDiagonalCross; + break ; + case wxFDIAGONAL_HATCH : + style = HatchStyleForwardDiagonal; + break ; + case wxCROSS_HATCH : + style = HatchStyleCross; + break ; + case wxHORIZONTAL_HATCH : + style = HatchStyleHorizontal; + break ; + case wxVERTICAL_HATCH : + style = HatchStyleVertical; + break ; - default: - if ( brush.IsHatch() ) - InitHatch(static_cast(brush.GetStyle())); - break; + } + m_brush = new HatchBrush(style,Color( brush.GetColour().Alpha() , brush.GetColour().Red() , + brush.GetColour().Green() , brush.GetColour().Blue() ), Color.Transparent ); + } + else + { + wxBitmap* bmp = brush.GetStipple(); + if ( bmp && bmp->Ok() ) + { + wxDELETE( m_brushImage ); + m_brushImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),(HPALETTE)bmp->GetPalette()->GetHPALETTE()); + m_brush = new TextureBrush(m_brushImage); + } + } + */ +} + +wxCairoBrushData::~wxCairoBrushData () +{ + if (m_brushPattern) + cairo_pattern_destroy(m_brushPattern); +} + +void wxCairoBrushData::Apply( wxGraphicsContext* context ) +{ + cairo_t * ctext = (cairo_t*) context->GetNativeContext(); + if ( m_brushPattern ) + { + cairo_set_source(ctext,m_brushPattern); + } + else + { + cairo_set_source_rgba(ctext,m_red,m_green, m_blue,m_alpha); } } -void wxCairoBrushData::AddGradientStops(const wxGraphicsGradientStops& stops) +void wxCairoBrushData::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2 ) { - // loop over all the stops, they include the beginning and ending ones - const unsigned numStops = stops.GetCount(); - for ( unsigned n = 0; n < numStops; n++ ) - { - const wxGraphicsGradientStop stop = stops.Item(n); - - const wxColour col = stop.GetColour(); - - cairo_pattern_add_color_stop_rgba - ( - m_pattern, - stop.GetPosition(), - col.Red()/255.0, - col.Green()/255.0, - col.Blue()/255.0, - col.Alpha()/255.0 - ); - } - - wxASSERT_MSG(cairo_pattern_status(m_pattern) == CAIRO_STATUS_SUCCESS, - wxT("Couldn't create cairo pattern")); + m_brushPattern = cairo_pattern_create_linear(x1,y1,x2,y2); + cairo_pattern_add_color_stop_rgba(m_brushPattern,0.0,c1.Red()/255.0, + c1.Green()/255.0, c1.Blue()/255.0,c1.Alpha()/255.0); + cairo_pattern_add_color_stop_rgba(m_brushPattern,1.0,c2.Red()/255.0, + c2.Green()/255.0, c2.Blue()/255.0,c2.Alpha()/255.0); + wxASSERT_MSG(cairo_pattern_status(m_brushPattern) == CAIRO_STATUS_SUCCESS, wxT("Couldn't create cairo pattern")); } -void -wxCairoBrushData::CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops) +void wxCairoBrushData::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor ) { - m_pattern = cairo_pattern_create_linear(x1,y1,x2,y2); - - AddGradientStops(stops); -} - -void -wxCairoBrushData::CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, - wxDouble radius, - const wxGraphicsGradientStops& stops) -{ - m_pattern = cairo_pattern_create_radial(xo,yo,0.0,xc,yc,radius); - - AddGradientStops(stops); + m_brushPattern = cairo_pattern_create_radial(xo,yo,0.0,xc,yc,radius); + cairo_pattern_add_color_stop_rgba(m_brushPattern,0.0,oColor.Red()/255.0, + oColor.Green()/255.0, oColor.Blue()/255.0,oColor.Alpha()/255.0); + cairo_pattern_add_color_stop_rgba(m_brushPattern,1.0,cColor.Red()/255.0, + cColor.Green()/255.0, cColor.Blue()/255.0,cColor.Alpha()/255.0); + wxASSERT_MSG(cairo_pattern_status(m_brushPattern) == CAIRO_STATUS_SUCCESS, wxT("Couldn't create cairo pattern")); } void wxCairoBrushData::Init() { - m_pattern = NULL; - m_bmpdata = NULL; + m_brushPattern = NULL; } //----------------------------------------------------------------------------- // wxCairoFontData implementation //----------------------------------------------------------------------------- -void wxCairoFontData::InitColour(const wxColour& col) +wxCairoFontData::wxCairoFontData( wxGraphicsRenderer* renderer, const wxFont &font, + const wxColour& col ) : wxGraphicsObjectRefData(renderer) { m_red = col.Red()/255.0; - m_green = col.Green()/255.0; + m_green = col.Green()/255.0; m_blue = col.Blue()/255.0; m_alpha = col.Alpha()/255.0; -} - -void -wxCairoFontData::InitFontComponents(const wxString& facename, - cairo_font_slant_t slant, - cairo_font_weight_t weight) -{ - m_fontName = facename.mb_str(wxConvUTF8); - m_slant = slant; - m_weight = weight; -} - -wxCairoFontData::wxCairoFontData( wxGraphicsRenderer* renderer, const wxFont &font, - const wxColour& col ) - : wxGraphicsObjectRefData(renderer) -#ifdef __WXGTK__ - , m_wxfont(font) -#endif -{ - InitColour(col); m_size = font.GetPointSize(); - -#ifdef __WXMAC__ - m_font = cairo_quartz_font_face_create_for_cgfont( font.OSXGetCGFont() ); -#elif defined(__WXGTK__) -#else - InitFontComponents - ( - font.GetFaceName(), - font.GetStyle() == wxFONTSTYLE_ITALIC ? CAIRO_FONT_SLANT_ITALIC - : CAIRO_FONT_SLANT_NORMAL, - font.GetWeight() == wxFONTWEIGHT_BOLD ? CAIRO_FONT_WEIGHT_BOLD - : CAIRO_FONT_WEIGHT_NORMAL - ); -#endif -} - -wxCairoFontData::wxCairoFontData(wxGraphicsRenderer* renderer, - double sizeInPixels, - const wxString& facename, - int flags, - const wxColour& col) : - wxGraphicsObjectRefData(renderer) -{ - InitColour(col); - - // Resolution for Cairo image surfaces is 72 DPI meaning that the sizes in - // points and pixels are identical, so we can just pass the size in pixels - // directly to cairo_set_font_size(). - m_size = sizeInPixels; - -#if defined(__WXMAC__) - m_font = NULL; -#endif - - // There is no need to set m_underlined under wxGTK in this case, it can - // only be used if m_font != NULL. - - InitFontComponents - ( - facename, - flags & wxFONTFLAG_ITALIC ? CAIRO_FONT_SLANT_ITALIC - : CAIRO_FONT_SLANT_NORMAL, - flags & wxFONTFLAG_BOLD ? CAIRO_FONT_WEIGHT_BOLD - : CAIRO_FONT_WEIGHT_NORMAL - ); + m_fontName = font.GetFaceName().mb_str(wxConvUTF8); + m_slant = font.GetStyle() == wxFONTSTYLE_ITALIC ? CAIRO_FONT_SLANT_ITALIC:CAIRO_FONT_SLANT_NORMAL; + m_weight = font.GetWeight() == wxFONTWEIGHT_BOLD ? CAIRO_FONT_WEIGHT_BOLD:CAIRO_FONT_WEIGHT_NORMAL; } wxCairoFontData::~wxCairoFontData() { -#ifdef __WXMAC__ - if ( m_font ) - cairo_font_face_destroy( m_font ); -#endif } -bool wxCairoFontData::Apply( wxGraphicsContext* context ) +void wxCairoFontData::Apply( wxGraphicsContext* context ) { cairo_t * ctext = (cairo_t*) context->GetNativeContext(); cairo_set_source_rgba(ctext,m_red,m_green, m_blue,m_alpha); -#ifdef __WXGTK__ - if (m_wxfont.IsOk()) - { - // Nothing to do, the caller uses Pango layout functions to do - // everything. - return true; - } -#elif defined(__WXMAC__) - if ( m_font ) - { - cairo_set_font_face(ctext, m_font); - cairo_set_font_size(ctext, m_size ); - return true; - } -#endif - - // If we get here, we must be on a platform without native font support or - // we're using toy Cairo API even under wxGTK/wxMac. - cairo_select_font_face(ctext, m_fontName, m_slant, m_weight ); - cairo_set_font_size(ctext, m_size ); - - // Indicate that we don't use native fonts for the platforms which care - // about this (currently only wxGTK). - return false; + cairo_select_font_face(ctext,m_fontName,m_slant,m_weight); + cairo_set_font_size(ctext,m_size); + // TODO UNDERLINE + // TODO FIX SIZE } //----------------------------------------------------------------------------- @@ -1091,7 +810,7 @@ void wxCairoPathData::GetCurrentPoint( wxDouble* x, wxDouble* y) const void wxCairoPathData::AddArc( wxDouble x, wxDouble y, wxDouble r, double startAngle, double endAngle, bool clockwise ) { - // as clockwise means positive in our system (y pointing downwards) + // as clockwise means positive in our system (y pointing downwards) // TODO make this interpretation dependent of the // real device trans if ( clockwise||(endAngle-startAngle)>=2*M_PI) @@ -1101,14 +820,14 @@ void wxCairoPathData::AddArc( wxDouble x, wxDouble y, wxDouble r, double startAn } // transforms each point of this path by the matrix -void wxCairoPathData::Transform( const wxGraphicsMatrixData* matrix ) +void wxCairoPathData::Transform( const wxGraphicsMatrixData* matrix ) { // as we don't have a true path object, we have to apply the inverse // matrix to the context cairo_matrix_t m = *((cairo_matrix_t*) matrix->GetNativeMatrix()); cairo_matrix_invert( &m ); cairo_transform(m_pathContext,&m); -} +} // gets the bounding box enclosing all points (possibly including control points) void wxCairoPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const @@ -1126,7 +845,7 @@ void wxCairoPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) *x = x1; *w = x2-x1; } - + if( y2 < y1 ) { *y = y2; @@ -1139,10 +858,9 @@ void wxCairoPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) } } -bool wxCairoPathData::Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle ) const +bool wxCairoPathData::Contains( wxDouble x, wxDouble y, int fillStyle ) const { - cairo_set_fill_rule(m_pathContext,fillStyle==wxODDEVEN_RULE ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); - return cairo_in_fill( m_pathContext, x, y) != 0; + return cairo_in_stroke( m_pathContext, x, y) != 0; } //----------------------------------------------------------------------------- @@ -1156,25 +874,25 @@ wxCairoMatrixData::wxCairoMatrixData(wxGraphicsRenderer* renderer, const cairo_m m_matrix = *matrix; } -wxCairoMatrixData::~wxCairoMatrixData() +wxCairoMatrixData::~wxCairoMatrixData() { // nothing to do } -wxGraphicsObjectRefData *wxCairoMatrixData::Clone() const +wxGraphicsObjectRefData *wxCairoMatrixData::Clone() const { return new wxCairoMatrixData(GetRenderer(),&m_matrix); } // concatenates the matrix -void wxCairoMatrixData::Concat( const wxGraphicsMatrixData *t ) +void wxCairoMatrixData::Concat( const wxGraphicsMatrixData *t ) { - cairo_matrix_multiply( &m_matrix, &m_matrix, (cairo_matrix_t*) t->GetNativeMatrix()); + cairo_matrix_multiply( &m_matrix, &m_matrix, (cairo_matrix_t*) t->GetNativeMatrix()); } // sets the matrix to the respective values -void wxCairoMatrixData::Set(wxDouble a, wxDouble b, wxDouble c, wxDouble d, - wxDouble tx, wxDouble ty) +void wxCairoMatrixData::Set(wxDouble a, wxDouble b, wxDouble c, wxDouble d, + wxDouble tx, wxDouble ty) { cairo_matrix_init( &m_matrix, a, b, c, d, tx, ty); } @@ -1192,21 +910,21 @@ void wxCairoMatrixData::Get(wxDouble* a, wxDouble* b, wxDouble* c, } // makes this the inverse matrix -void wxCairoMatrixData::Invert() +void wxCairoMatrixData::Invert() { cairo_matrix_invert( &m_matrix ); } // returns true if the elements of the transformation matrix are equal ? -bool wxCairoMatrixData::IsEqual( const wxGraphicsMatrixData* t) const +bool wxCairoMatrixData::IsEqual( const wxGraphicsMatrixData* t) const { const cairo_matrix_t* tm = (cairo_matrix_t*) t->GetNativeMatrix(); - return ( - m_matrix.xx == tm->xx && - m_matrix.yx == tm->yx && - m_matrix.xy == tm->xy && - m_matrix.yy == tm->yy && - m_matrix.x0 == tm->x0 && + return ( + m_matrix.xx == tm->xx && + m_matrix.yx == tm->yx && + m_matrix.xy == tm->xy && + m_matrix.yy == tm->yy && + m_matrix.x0 == tm->x0 && m_matrix.y0 == tm->y0 ) ; } @@ -1234,7 +952,7 @@ void wxCairoMatrixData::Scale( wxDouble xScale , wxDouble yScale ) } // add the rotation to this matrix (radians) -void wxCairoMatrixData::Rotate( wxDouble angle ) +void wxCairoMatrixData::Rotate( wxDouble angle ) { cairo_matrix_rotate( &m_matrix, angle) ; } @@ -1267,94 +985,35 @@ void * wxCairoMatrixData::GetNativeMatrix() const return (void*) &m_matrix; } -// ---------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // wxCairoBitmap implementation -// ---------------------------------------------------------------------------- +//----------------------------------------------------------------------------- -int wxCairoBitmapData::InitBuffer(int width, int height, cairo_format_t format) -{ - wxUnusedVar(format); // Only really unused with Cairo < 1.6. - - // Determine the stride: use cairo_format_stride_for_width() if available - // but fall back to 4*width for the earlier versions as this is what that - // function always returns, even in latest Cairo, anyhow. - int stride; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0) - if ( cairo_version() >= CAIRO_VERSION_ENCODE(1, 6, 0) ) - { - stride = cairo_format_stride_for_width(format, width); - - // All our code would totally break if stride were not a multiple of 4 - // so ensure this is the case. - if ( stride % 4 ) - { - wxFAIL_MSG("Unexpected Cairo image surface stride."); - - stride += 4 - stride % 4; - } - } - else -#endif - stride = 4*width; - - m_width = width; - m_height = height; - m_buffer = new unsigned char[height*stride]; - - return stride; -} - -void wxCairoBitmapData::InitSurface(cairo_format_t format, int stride) -{ - m_surface = cairo_image_surface_create_for_data( - m_buffer, format, m_width, m_height, stride); - m_pattern = cairo_pattern_create_for_surface(m_surface); -} - -wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, cairo_surface_t* bitmap ) : - wxGraphicsBitmapData( renderer ) -{ - m_surface = bitmap; - m_pattern = cairo_pattern_create_for_surface(m_surface); - - m_width = cairo_image_surface_get_width(m_surface); - m_height = cairo_image_surface_get_height(m_surface); - m_buffer = NULL; -} - -wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ) : wxGraphicsBitmapData( renderer ) +wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ) : wxGraphicsObjectRefData( renderer ) { wxCHECK_RET( bmp.IsOk(), wxT("Invalid bitmap in wxCairoContext::DrawBitmap")); -#ifdef wxHAS_RAW_BITMAP + int bw = m_width = bmp.GetWidth(); + int bh = m_height = bmp.GetHeight(); + wxBitmap bmpSource = bmp; // we need a non-const instance + m_buffer = new unsigned char[bw*bh*4]; + wxUint32* data = (wxUint32*)m_buffer; + // Create a surface object and copy the bitmap pixel data to it. if the // image has alpha (or a mask represented as alpha) then we'll use a // different format and iterator than if it doesn't... - cairo_format_t bufferFormat = bmp.GetDepth() == 32 -#if defined(__WXGTK__) && !defined(__WXGTK3__) - || bmp.GetMask() -#endif - ? CAIRO_FORMAT_ARGB32 - : CAIRO_FORMAT_RGB24; - - int stride = InitBuffer(bmp.GetWidth(), bmp.GetHeight(), bufferFormat); - - wxBitmap bmpSource = bmp; // we need a non-const instance - wxUint32* data = (wxUint32*)m_buffer; - - if ( bufferFormat == CAIRO_FORMAT_ARGB32 ) + if (bmpSource.HasAlpha() || bmpSource.GetMask()) { - // use the bitmap's alpha - wxAlphaPixelData - pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height)); + m_surface = cairo_image_surface_create_for_data( + m_buffer, CAIRO_FORMAT_ARGB32, bw, bh, bw*4); + wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh)); wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data.")); - + wxAlphaPixelData::Iterator p(pixData); - for (int y=0; yGetBitmap(); - bufferFormat = CAIRO_FORMAT_ARGB32; - data = (wxUint32*)m_buffer; - wxNativePixelData - pixData(bmpMask, wxPoint(0, 0), wxSize(m_width, m_height)); - wxCHECK_RET( pixData, wxT("Failed to gain raw access to mask data.")); - - wxNativePixelData::Iterator p(pixData); - for (int y=0; y(m_buffer); - const unsigned char* src = image.GetData(); - - if ( bufferFormat == CAIRO_FORMAT_ARGB32 ) - { - const unsigned char* alpha = image.GetAlpha(); - - for ( int y = 0; y < m_height; y++ ) - { - wxUint32* const rowStartDst = dst; - - for ( int x = 0; x < m_width; x++ ) - { - const unsigned char a = *alpha++; - - *dst++ = a << 24 | - Premultiply(a, src[0]) << 16 | - Premultiply(a, src[1]) << 8 | - Premultiply(a, src[2]); - src += 3; - } - - dst = rowStartDst + stride / 4; - } - } - else // RGB - { - for ( int y = 0; y < m_height; y++ ) - { - wxUint32* const rowStartDst = dst; - - for ( int x = 0; x < m_width; x++ ) - { - *dst++ = src[0] << 16 | - src[1] << 8 | - src[2]; - src += 3; - } - - dst = rowStartDst + stride / 4; - } - } - - InitSurface(bufferFormat, stride); -} - -wxImage wxCairoBitmapData::ConvertToImage() const -{ - wxImage image(m_width, m_height, false /* don't clear */); - - // Get the surface type and format. - wxCHECK_MSG( cairo_surface_get_type(m_surface) == CAIRO_SURFACE_TYPE_IMAGE, - wxNullImage, - wxS("Can't convert non-image surface to image.") ); - - switch ( cairo_image_surface_get_format(m_surface) ) - { - case CAIRO_FORMAT_ARGB32: - image.SetAlpha(); - break; - - case CAIRO_FORMAT_RGB24: - // Nothing to do, we don't use alpha by default. - break; - - case CAIRO_FORMAT_A8: - case CAIRO_FORMAT_A1: - wxFAIL_MSG(wxS("Unsupported Cairo image surface type.")); - return wxNullImage; - - default: - wxFAIL_MSG(wxS("Unknown Cairo image surface type.")); - return wxNullImage; - } - - // Prepare for copying data. - const wxUint32* src = (wxUint32*)cairo_image_surface_get_data(m_surface); - wxCHECK_MSG( src, wxNullImage, wxS("Failed to get Cairo surface data.") ); - - int stride = cairo_image_surface_get_stride(m_surface); - wxCHECK_MSG( stride > 0, wxNullImage, - wxS("Failed to get Cairo surface stride.") ); - - // As we work with wxUint32 pointers and not char ones, we need to adjust - // the stride accordingly. This should be lossless as the stride must be a - // multiple of pixel size. - wxASSERT_MSG( !(stride % sizeof(wxUint32)), wxS("Unexpected stride.") ); - stride /= sizeof(wxUint32); - - unsigned char* dst = image.GetData(); - unsigned char *alpha = image.GetAlpha(); - if ( alpha ) - { - // We need to also copy alpha and undo the pre-multiplication as Cairo - // stores pre-multiplied values in this format while wxImage does not. - for ( int y = 0; y < m_height; y++ ) - { - const wxUint32* const rowStart = src; - for ( int x = 0; x < m_width; x++ ) - { - const wxUint32 argb = *src++; - - const unsigned char a = argb >> 24; - *alpha++ = a; - - // Copy the RGB data undoing the pre-multiplication. - *dst++ = Unpremultiply(a, argb >> 16); - *dst++ = Unpremultiply(a, argb >> 8); - *dst++ = Unpremultiply(a, argb); - } - - src = rowStart + stride; - } - } - else // RGB - { - // Things are pretty simple in this case, just copy RGB bytes. - for ( int y = 0; y < m_height; y++ ) - { - const wxUint32* const rowStart = src; - for ( int x = 0; x < m_width; x++ ) - { - const wxUint32 argb = *src++; - - *dst++ = (argb & 0x00ff0000) >> 16; - *dst++ = (argb & 0x0000ff00) >> 8; - *dst++ = (argb & 0x000000ff); - } - - src = rowStart + stride; - } - } - - return image; -} - -#endif // wxUSE_IMAGE - wxCairoBitmapData::~wxCairoBitmapData() { - if (m_pattern) - cairo_pattern_destroy(m_pattern); - - if (m_surface) - cairo_surface_destroy(m_surface); - + cairo_pattern_destroy(m_pattern); + cairo_surface_destroy(m_surface); delete [] m_buffer; } @@ -1626,211 +1073,23 @@ wxCairoBitmapData::~wxCairoBitmapData() // wxCairoContext implementation //----------------------------------------------------------------------------- -class wxCairoOffsetHelper -{ -public : - wxCairoOffsetHelper( cairo_t* ctx , bool offset ) - { - m_ctx = ctx; - m_offset = offset; - if ( m_offset ) - cairo_translate( m_ctx, 0.5, 0.5 ); - } - ~wxCairoOffsetHelper( ) - { - if ( m_offset ) - cairo_translate( m_ctx, -0.5, -0.5 ); - } -public : - cairo_t* m_ctx; - bool m_offset; -} ; - -#if wxUSE_PRINTING_ARCHITECTURE -wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& dc ) -: wxGraphicsContext(renderer) -{ -#ifdef __WXMSW__ - // wxMSW contexts always use MM_ANISOTROPIC, which messes up - // text rendering when printing using Cairo. Switch it to MM_TEXT - // map mode to avoid this problem. - HDC hdc = (HDC)dc.GetHDC(); - ::SetMapMode(hdc, MM_TEXT); - m_mswSurface = cairo_win32_printing_surface_create(hdc); - Init( cairo_create(m_mswSurface) ); -#endif - -#ifdef __WXGTK20__ - const wxDCImpl *impl = dc.GetImpl(); - cairo_t* cr = static_cast(impl->GetCairoContext()); - if (cr) - Init(cairo_reference(cr)); -#endif - wxSize sz = dc.GetSize(); - m_width = sz.x; - m_height = sz.y; - - wxPoint org = dc.GetDeviceOrigin(); - cairo_translate( m_context, org.x, org.y ); - - double sx,sy; - dc.GetUserScale( &sx, &sy ); - -// TODO: Determine if these fixes are needed on other platforms too. -// On MSW, without this the printer context will not respect wxDC SetMapMode calls. -// For example, using dc.SetMapMode(wxMM_POINTS) can let us share printer and screen -// drawing code -#ifdef __WXMSW__ - double lsx,lsy; - dc.GetLogicalScale( &lsx, &lsy ); - sx *= lsx; - sy *= lsy; -#endif - cairo_scale( m_context, sx, sy ); - - org = dc.GetLogicalOrigin(); - cairo_translate( m_context, -org.x, -org.y ); -} -#endif - wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ) : wxGraphicsContext(renderer) { - int width, height; - dc.GetSize( &width, &height ); - m_width = width; - m_height = height; - - m_enableOffset = true; - -#ifdef __WXMSW__ - m_mswSurface = cairo_win32_surface_create((HDC)dc.GetHDC()); - Init( cairo_create(m_mswSurface) ); -#endif - -#ifdef __WXGTK3__ - cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); - if (cr) - Init(cairo_reference(cr)); -#elif defined __WXGTK20__ - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); - Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); - -#if 0 - wxGraphicsMatrix matrix = CreateMatrix(); - - wxPoint org = dc.GetDeviceOrigin(); - matrix.Translate( org.x, org.y ); - - org = dc.GetLogicalOrigin(); - matrix.Translate( -org.x, -org.y ); - - double sx,sy; - dc.GetUserScale( &sx, &sy ); - matrix.Scale( sx, sy ); - - ConcatTransform( matrix ); -#endif -#endif - -#ifdef __WXMAC__ - CGContextRef cgcontext = (CGContextRef)dc.GetWindow()->MacGetCGContextRef(); - cairo_surface_t* surface = cairo_quartz_surface_create_for_cg_context(cgcontext, width, height); - Init( cairo_create( surface ) ); - cairo_surface_destroy( surface ); +#ifdef __WXGTK__ + m_context = gdk_cairo_create( dc.m_window ) ; #endif + PushState(); + PushState(); } -wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ) +#ifdef __WXGTK__ +wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ) : wxGraphicsContext(renderer) { - int width, height; - dc.GetSize( &width, &height ); - m_width = width; - m_height = height; - - m_enableOffset = true; - -#ifdef __WXMSW__ - - HDC hdc = (HDC)dc.GetHDC(); - - HBITMAP bitmap = (HBITMAP)GetCurrentObject(hdc, OBJ_BITMAP); - - BITMAP info; - bool hasBitmap = false; - - // cairo_win32_surface_create creates a 24-bit bitmap, - // so if we have alpha, we need to create a 32-bit surface instead. - if (!GetObject(bitmap, sizeof(info), &info) || info.bmBitsPixel < 32) - m_mswSurface = cairo_win32_surface_create(hdc); - else { - hasBitmap = true; - m_mswSurface = cairo_image_surface_create_for_data((unsigned char*)info.bmBits, - CAIRO_FORMAT_ARGB32, - info.bmWidth, - info.bmHeight, - info.bmWidthBytes); - } - - Init( cairo_create(m_mswSurface) ); - // If we've created a image surface, we need to flip the Y axis so that - // all drawing will appear right side up. - if (hasBitmap) { - cairo_matrix_t matrix; - cairo_matrix_init(&matrix, 1.0, 0.0, 0.0, -1.0, 0.0, height); - cairo_set_matrix(m_context, &matrix); - } -#endif - -#ifdef __WXGTK3__ - cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); - if (cr) - Init(cairo_reference(cr)); -#elif defined __WXGTK20__ - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); - Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); - -#if 0 - wxGraphicsMatrix matrix = CreateMatrix(); - - wxPoint org = dc.GetDeviceOrigin(); - matrix.Translate( org.x, org.y ); - - org = dc.GetLogicalOrigin(); - matrix.Translate( -org.x, -org.y ); - - double sx,sy; - dc.GetUserScale( &sx, &sy ); - matrix.Scale( sx, sy ); - - ConcatTransform( matrix ); -#endif -#endif - -#ifdef __WXMAC__ - CGContextRef cgcontext = (CGContextRef)dc.GetWindow()->MacGetCGContextRef(); - cairo_surface_t* surface = cairo_quartz_surface_create_for_cg_context(cgcontext, width, height); - Init( cairo_create( surface ) ); - cairo_surface_destroy( surface ); -#endif -} - -#ifdef __WXGTK20__ -wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkWindow *window ) -: wxGraphicsContext(renderer) -{ - Init( gdk_cairo_create( window ) ); - -#ifdef __WXGTK3__ - m_width = gdk_window_get_width(window); - m_height = gdk_window_get_height(window); -#else - int width, height; - gdk_drawable_get_size(window, &width, &height); - m_width = width; - m_height = height; -#endif + m_context = gdk_cairo_create( drawable ) ; + PushState(); + PushState(); } #endif @@ -1839,9 +1098,9 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, HDC handle ) : wxGraphicsContext(renderer) { m_mswSurface = cairo_win32_surface_create(handle); - Init( cairo_create(m_mswSurface) ); - m_width = - m_height = 0; + m_context = cairo_create(m_mswSurface); + PushState(); + PushState(); } #endif @@ -1849,49 +1108,40 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, HDC handle ) wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context ) : wxGraphicsContext(renderer) { - Init( context ); - m_width = - m_height = 0; + m_context = context ; + PushState(); + PushState(); } wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window) - : wxGraphicsContext(renderer) -#ifdef __WXMSW__ - , m_mswWindowHDC(GetHwndOf(window)) -#endif +: wxGraphicsContext(renderer) { - m_enableOffset = true; #ifdef __WXGTK__ // something along these lines (copied from dcclient) + GtkWidget *widget = window->m_wxwindow; + // Some controls don't have m_wxwindow - like wxStaticBox, but the user // code should still be able to create wxClientDCs for them, so we will // use the parent window here then. - if (window->m_wxwindow == NULL) + if ( !widget ) { window = window->GetParent(); + widget = window->m_wxwindow; } - wxASSERT_MSG( window->m_wxwindow, wxT("wxCairoContext needs a widget") ); + wxASSERT_MSG( widget, wxT("wxCairoContext needs a widget") ); - Init(gdk_cairo_create(window->GTKGetDrawingWindow())); - - wxSize sz = window->GetSize(); - m_width = sz.x; - m_height = sz.y; + GtkPizza *pizza = GTK_PIZZA( widget ); + GdkDrawable* drawable = pizza->bin_window; + m_context = gdk_cairo_create( drawable ) ; #endif - #ifdef __WXMSW__ - m_mswSurface = cairo_win32_surface_create((HDC)m_mswWindowHDC); - Init(cairo_create(m_mswSurface)); + m_mswSurface = cairo_win32_surface_create((HDC)window->GetHandle()); + m_context = cairo_create(m_mswSurface); #endif - -} - -wxCairoContext::wxCairoContext(wxGraphicsRenderer* renderer) : - wxGraphicsContext(renderer) -{ - m_context = NULL; + PushState(); + PushState(); } wxCairoContext::~wxCairoContext() @@ -1908,13 +1158,6 @@ wxCairoContext::~wxCairoContext() #endif } -void wxCairoContext::Init(cairo_t *context) -{ - m_context = context ; - PushState(); - PushState(); -} - void wxCairoContext::Clip( const wxRegion& region ) { @@ -1924,16 +1167,16 @@ void wxCairoContext::Clip( const wxRegion& region ) while (ri) { path.AddRectangle(ri.GetX(), ri.GetY(), ri.GetW(), ri.GetH()); - ++ri; + ri++; } - + // Put it in the context cairo_path_t* cp = (cairo_path_t*) path.GetNativePath() ; cairo_append_path(m_context, cp); // clip to that path cairo_clip(m_context); - path.UnGetNativePath(cp); + path.UnGetNativePath(cp); } void wxCairoContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) @@ -1948,7 +1191,7 @@ void wxCairoContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) // clip to that path cairo_clip(m_context); - path.UnGetNativePath(cp); + path.UnGetNativePath(cp); } void wxCairoContext::ResetClip() @@ -1960,8 +1203,7 @@ void wxCairoContext::ResetClip() void wxCairoContext::StrokePath( const wxGraphicsPath& path ) { if ( !m_pen.IsNull() ) - { - wxCairoOffsetHelper helper( m_context, ShouldOffset() ) ; + { cairo_path_t* cp = (cairo_path_t*) path.GetNativePath() ; cairo_append_path(m_context,cp); ((wxCairoPenData*)m_pen.GetRefData())->Apply(this); @@ -1970,11 +1212,10 @@ void wxCairoContext::StrokePath( const wxGraphicsPath& path ) } } -void wxCairoContext::FillPath( const wxGraphicsPath& path , wxPolygonFillMode fillStyle ) +void wxCairoContext::FillPath( const wxGraphicsPath& path , int fillStyle ) { if ( !m_brush.IsNull() ) { - wxCairoOffsetHelper helper( m_context, ShouldOffset() ) ; cairo_path_t* cp = (cairo_path_t*) path.GetNativePath() ; cairo_append_path(m_context,cp); ((wxCairoBrushData*)m_brush.GetRefData())->Apply(this); @@ -2031,29 +1272,31 @@ void wxCairoContext::PopState() cairo_restore(m_context); } +void wxGraphicsContext::DrawGraphicsBitmap(const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h) +{ + static_cast(this)->DrawGraphicsBitmapInternal(bmp, x, y, w, h); +} + void wxCairoContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) { wxGraphicsBitmap bitmap = GetRenderer()->CreateBitmap(bmp); - DrawBitmap(bitmap, x, y, w, h); - + DrawGraphicsBitmapInternal(bitmap, x, y, w, h); } -void wxCairoContext::DrawBitmap(const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) +void wxCairoContext::DrawGraphicsBitmapInternal(const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) { - PushState(); - - // In case we're scaling the image by using a width and height different - // than the bitmap's size create a pattern transformation on the surface and - // draw the transformed pattern. wxCairoBitmapData* data = static_cast(bmp.GetRefData()); cairo_pattern_t* pattern = data->GetCairoPattern(); wxSize size = data->GetSize(); - - wxDouble scaleX = w / size.GetWidth(); - wxDouble scaleY = h / size.GetHeight(); - + PushState(); + // prepare to draw the image cairo_translate(m_context, x, y); + // In case we're scaling the image by using a width and height different + // than the bitmap's size create a pattern transformation on the surface and + // draw the transformed pattern. + wxDouble scaleX = w / size.GetWidth(); + wxDouble scaleY = h / size.GetHeight(); cairo_scale(m_context, scaleX, scaleY); cairo_set_source(m_context, pattern); // use the original size here since the context is scaled already... @@ -2061,6 +1304,7 @@ void wxCairoContext::DrawBitmap(const wxGraphicsBitmap &bmp, wxDouble x, wxDoubl // fill the rectangle using the pattern cairo_fill(m_context); + // clean up PopState(); } @@ -2073,44 +1317,23 @@ void wxCairoContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDou } -void wxCairoContext::DoDrawText(const wxString& str, wxDouble x, wxDouble y) +void wxCairoContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) { - wxCHECK_RET( !m_font.IsNull(), - wxT("wxCairoContext::DrawText - no valid font set") ); + wxCHECK_RET( !m_font.IsNull(), wxT("wxCairoContext::DrawText - no valid font set") ); if ( str.empty()) return; - - const wxCharBuffer data = str.utf8_str(); - if ( !data ) - return; - - if ( ((wxCairoFontData*)m_font.GetRefData())->Apply(this) ) - { -#ifdef __WXGTK__ - PangoLayout *layout = pango_cairo_create_layout (m_context); - const wxFont& font = static_cast(m_font.GetRefData())->GetFont(); - pango_layout_set_font_description(layout, font.GetNativeFontInfo()->description); - pango_layout_set_text(layout, data, data.length()); - font.GTKSetPangoAttrs(layout); - - cairo_move_to(m_context, x, y); - pango_cairo_show_layout (m_context, layout); - - g_object_unref (layout); - - // Don't use Cairo text API, we already did everything. - return; -#endif - } + + ((wxCairoFontData*)m_font.GetRefData())->Apply(this); // Cairo's x,y for drawing text is at the baseline, so we need to adjust // the position we move to by the ascent. cairo_font_extents_t fe; cairo_font_extents(m_context, &fe); cairo_move_to(m_context, x, y+fe.ascent); - - cairo_show_text(m_context, data); + + const wxWX2MBbuf buf(str.mb_str(wxConvUTF8)); + cairo_show_text(m_context,buf); } void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, @@ -2118,48 +1341,10 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub { wxCHECK_RET( !m_font.IsNull(), wxT("wxCairoContext::GetTextExtent - no valid font set") ); - if ( width ) - *width = 0; - if ( height ) - *height = 0; - if ( descent ) - *descent = 0; - if ( externalLeading ) - *externalLeading = 0; - if ( str.empty()) return; - if ( ((wxCairoFontData*)m_font.GetRefData())->Apply((wxCairoContext*)this) ) - { -#ifdef __WXGTK__ - int w, h; - - PangoLayout *layout = pango_cairo_create_layout (m_context); - const wxFont& font = static_cast(m_font.GetRefData())->GetFont(); - pango_layout_set_font_description(layout, font.GetNativeFontInfo()->description); - const wxCharBuffer data = str.utf8_str(); - if ( !data ) - { - return; - } - pango_layout_set_text(layout, data, data.length()); - pango_layout_get_pixel_size (layout, &w, &h); - if ( width ) - *width = w; - if ( height ) - *height = h; - if (descent) - { - PangoLayoutIter *iter = pango_layout_get_iter(layout); - int baseline = pango_layout_iter_get_baseline(iter); - pango_layout_iter_free(iter); - *descent = h - PANGO_PIXELS(baseline); - } - g_object_unref (layout); - return; -#endif - } + ((wxCairoFontData*)m_font.GetRefData())->Apply((wxCairoContext*)this); if (width) { @@ -2173,18 +1358,7 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub { cairo_font_extents_t fe; cairo_font_extents(m_context, &fe); - - // some backends have negative descents - - if ( fe.descent < 0 ) - fe.descent = -fe.descent; - - if ( fe.height < (fe.ascent + fe.descent ) ) - { - // some backends are broken re height ... (eg currently ATSUI) - fe.height = fe.ascent + fe.descent; - } - + if (height) *height = fe.height; if ( descent ) @@ -2197,138 +1371,21 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub void wxCairoContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const { widths.Empty(); + widths.Add(0, text.length()); + wxCHECK_RET( !m_font.IsNull(), wxT("wxCairoContext::GetPartialTextExtents - no valid font set") ); -#ifdef __WXGTK__ - const wxCharBuffer data = text.utf8_str(); - int w = 0; - if (data.length()) - { - PangoLayout* layout = pango_cairo_create_layout(m_context); - const wxFont& font = static_cast(m_font.GetRefData())->GetFont(); - pango_layout_set_font_description(layout, font.GetNativeFontInfo()->description); - pango_layout_set_text(layout, data, data.length()); - PangoLayoutIter* iter = pango_layout_get_iter(layout); - PangoRectangle rect; - do { - pango_layout_iter_get_cluster_extents(iter, NULL, &rect); - w += rect.width; - widths.Add(PANGO_PIXELS(w)); - } while (pango_layout_iter_next_cluster(iter)); - pango_layout_iter_free(iter); - g_object_unref(layout); - } - size_t i = widths.GetCount(); - const size_t len = text.length(); - while (i++ < len) - widths.Add(PANGO_PIXELS(w)); -#else + + if (text.empty()) + return; + // TODO -#endif } -void * wxCairoContext::GetNativeContext() +void * wxCairoContext::GetNativeContext() { return m_context; } -bool wxCairoContext::SetAntialiasMode(wxAntialiasMode antialias) -{ - if (m_antialias == antialias) - return true; - - m_antialias = antialias; - - cairo_antialias_t antialiasMode; - switch (antialias) - { - case wxANTIALIAS_DEFAULT: - antialiasMode = CAIRO_ANTIALIAS_DEFAULT; - break; - case wxANTIALIAS_NONE: - antialiasMode = CAIRO_ANTIALIAS_NONE; - break; - default: - return false; - } - cairo_set_antialias(m_context, antialiasMode); - return true; -} - -bool wxCairoContext::SetInterpolationQuality(wxInterpolationQuality WXUNUSED(interpolation)) -{ - // placeholder - return false; -} - -bool wxCairoContext::SetCompositionMode(wxCompositionMode op) -{ - if ( m_composition == op ) - return true; - - m_composition = op; - cairo_operator_t cop; - switch (op) - { - case wxCOMPOSITION_CLEAR: - cop = CAIRO_OPERATOR_CLEAR; - break; - case wxCOMPOSITION_SOURCE: - cop = CAIRO_OPERATOR_SOURCE; - break; - case wxCOMPOSITION_OVER: - cop = CAIRO_OPERATOR_OVER; - break; - case wxCOMPOSITION_IN: - cop = CAIRO_OPERATOR_IN; - break; - case wxCOMPOSITION_OUT: - cop = CAIRO_OPERATOR_OUT; - break; - case wxCOMPOSITION_ATOP: - cop = CAIRO_OPERATOR_ATOP; - break; - case wxCOMPOSITION_DEST: - cop = CAIRO_OPERATOR_DEST; - break; - case wxCOMPOSITION_DEST_OVER: - cop = CAIRO_OPERATOR_DEST_OVER; - break; - case wxCOMPOSITION_DEST_IN: - cop = CAIRO_OPERATOR_DEST_IN; - break; - case wxCOMPOSITION_DEST_OUT: - cop = CAIRO_OPERATOR_DEST_OUT; - break; - case wxCOMPOSITION_DEST_ATOP: - cop = CAIRO_OPERATOR_DEST_ATOP; - break; - case wxCOMPOSITION_XOR: - cop = CAIRO_OPERATOR_XOR; - break; - case wxCOMPOSITION_ADD: - cop = CAIRO_OPERATOR_ADD; - break; - default: - return false; - } - cairo_set_operator(m_context, cop); - return true; -} - -void wxCairoContext::BeginLayer(wxDouble opacity) -{ - m_layerOpacities.push_back(opacity); - cairo_push_group(m_context); -} - -void wxCairoContext::EndLayer() -{ - float opacity = m_layerOpacities.back(); - m_layerOpacities.pop_back(); - cairo_pop_group_to_source(m_context); - cairo_paint_with_alpha(m_context,opacity); -} - //----------------------------------------------------------------------------- // wxCairoRenderer declaration //----------------------------------------------------------------------------- @@ -2343,33 +1400,26 @@ public : // Context virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc); + +#ifdef __WXMSW__ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc); -#if wxUSE_PRINTING_ARCHITECTURE - virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc); #endif virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ); -#if wxUSE_IMAGE - virtual wxGraphicsContext * CreateContextFromImage(wxImage& image); -#endif // wxUSE_IMAGE virtual wxGraphicsContext * CreateContext( wxWindow* window ); virtual wxGraphicsContext * CreateMeasuringContext(); -#ifdef __WXMSW__ -#if wxUSE_ENH_METAFILE - virtual wxGraphicsContext * CreateContext( const wxEnhMetaFileDC& dc); -#endif -#endif + // Path virtual wxGraphicsPath CreatePath(); // Matrix - virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, + virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, wxDouble tx=0.0, wxDouble ty=0.0); @@ -2377,37 +1427,21 @@ public : virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ; - virtual wxGraphicsBrush - CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops); + // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 + virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2) ; - virtual wxGraphicsBrush - CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, - wxDouble radius, - const wxGraphicsGradientStops& stops); + // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) + // with radius r and color cColor + virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor) ; // sets the font virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) ; - virtual wxGraphicsFont CreateFont(double sizeInPixels, - const wxString& facename, - int flags = wxFONTFLAG_DEFAULT, - const wxColour& col = *wxBLACK); - - // create a native bitmap representation - virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ); -#if wxUSE_IMAGE - virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image); - virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp); -#endif // wxUSE_IMAGE - - // create a graphics bitmap from a native bitmap - virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap ); - - // create a subimage from a native image representation - virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + + wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) ; +private : DECLARE_DYNAMIC_CLASS_NO_COPY(wxCairoRenderer) } ; @@ -2420,48 +1454,30 @@ IMPLEMENT_DYNAMIC_CLASS(wxCairoRenderer,wxGraphicsRenderer) static wxCairoRenderer gs_cairoGraphicsRenderer; #ifdef __WXGTK__ - #define ENSURE_LOADED_OR_RETURN(returnOnFail) -#else - #define ENSURE_LOADED_OR_RETURN(returnOnFail) \ - if (!wxCairoInit()) \ - return returnOnFail +wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer() +{ + return &gs_cairoGraphicsRenderer; +} #endif wxGraphicsContext * wxCairoRenderer::CreateContext( const wxWindowDC& dc) { - ENSURE_LOADED_OR_RETURN(NULL); return new wxCairoContext(this,dc); } -wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc) -{ - ENSURE_LOADED_OR_RETURN(NULL); - return new wxCairoContext(this,dc); -} - -#if wxUSE_PRINTING_ARCHITECTURE -wxGraphicsContext * wxCairoRenderer::CreateContext( const wxPrinterDC& dc) -{ - ENSURE_LOADED_OR_RETURN(NULL); - return new wxCairoContext(this, dc); -} -#endif - #ifdef __WXMSW__ -#if wxUSE_ENH_METAFILE -wxGraphicsContext * wxCairoRenderer::CreateContext( const wxEnhMetaFileDC& WXUNUSED(dc) ) +wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc) { return NULL; } #endif -#endif wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context ) { - ENSURE_LOADED_OR_RETURN(NULL); -#ifdef __WXMSW__ +#if __WXMSW__ return new wxCairoContext(this,(HDC)context); -#else +#endif +#if __WXGTK__ return new wxCairoContext(this,(cairo_t*)context); #endif } @@ -2470,34 +1486,23 @@ wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * cont wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeWindow( void * window ) { #ifdef __WXGTK__ - return new wxCairoContext(this, static_cast(window)); + return new wxCairoContext(this,(GdkDrawable*)window); #else - wxUnusedVar(window); return NULL; #endif } -#if wxUSE_IMAGE -wxGraphicsContext * wxCairoRenderer::CreateContextFromImage(wxImage& image) -{ - ENSURE_LOADED_OR_RETURN(NULL); - return new wxCairoImageContext(this, image); -} -#endif // wxUSE_IMAGE - wxGraphicsContext * wxCairoRenderer::CreateMeasuringContext() { #ifdef __WXGTK__ return CreateContextFromNativeWindow(gdk_get_default_root_window()); -#else +#endif return NULL; // TODO -#endif } wxGraphicsContext * wxCairoRenderer::CreateContext( wxWindow* window ) { - ENSURE_LOADED_OR_RETURN(NULL); return new wxCairoContext(this, window ); } @@ -2506,7 +1511,6 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( wxWindow* window ) wxGraphicsPath wxCairoRenderer::CreatePath() { wxGraphicsPath path; - ENSURE_LOADED_OR_RETURN(path); path.SetRefData( new wxCairoPathData(this) ); return path; } @@ -2514,176 +1518,98 @@ wxGraphicsPath wxCairoRenderer::CreatePath() // Matrix -wxGraphicsMatrix wxCairoRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble c, wxDouble d, +wxGraphicsMatrix wxCairoRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble c, wxDouble d, wxDouble tx, wxDouble ty) { wxGraphicsMatrix m; - ENSURE_LOADED_OR_RETURN(m); wxCairoMatrixData* data = new wxCairoMatrixData( this ); data->Set( a,b,c,d,tx,ty ) ; m.SetRefData(data); return m; } -wxGraphicsPen wxCairoRenderer::CreatePen(const wxPen& pen) +wxGraphicsPen wxCairoRenderer::CreatePen(const wxPen& pen) { - wxGraphicsPen p; - ENSURE_LOADED_OR_RETURN(p); - if (pen.IsOk() && pen.GetStyle() != wxPENSTYLE_TRANSPARENT) + if ( !pen.Ok() || pen.GetStyle() == wxTRANSPARENT ) + return wxNullGraphicsPen; + else { + wxGraphicsPen p; p.SetRefData(new wxCairoPenData( this, pen )); + return p; } - return p; } -wxGraphicsBrush wxCairoRenderer::CreateBrush(const wxBrush& brush ) +wxGraphicsBrush wxCairoRenderer::CreateBrush(const wxBrush& brush ) { - wxGraphicsBrush p; - ENSURE_LOADED_OR_RETURN(p); - if (brush.IsOk() && brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) + if ( !brush.Ok() || brush.GetStyle() == wxTRANSPARENT ) + return wxNullGraphicsBrush; + else { + wxGraphicsBrush p; p.SetRefData(new wxCairoBrushData( this, brush )); + return p; } - return p; } -wxGraphicsBrush -wxCairoRenderer::CreateLinearGradientBrush(wxDouble x1, wxDouble y1, - wxDouble x2, wxDouble y2, - const wxGraphicsGradientStops& stops) +// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 +wxGraphicsBrush wxCairoRenderer::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2) { wxGraphicsBrush p; - ENSURE_LOADED_OR_RETURN(p); wxCairoBrushData* d = new wxCairoBrushData( this ); - d->CreateLinearGradientBrush(x1, y1, x2, y2, stops); + d->CreateLinearGradientBrush(x1, y1, x2, y2, c1, c2); p.SetRefData(d); return p; } -wxGraphicsBrush -wxCairoRenderer::CreateRadialGradientBrush(wxDouble xo, wxDouble yo, - wxDouble xc, wxDouble yc, wxDouble r, - const wxGraphicsGradientStops& stops) +// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) +// with radius r and color cColor +wxGraphicsBrush wxCairoRenderer::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor) { wxGraphicsBrush p; - ENSURE_LOADED_OR_RETURN(p); wxCairoBrushData* d = new wxCairoBrushData( this ); - d->CreateRadialGradientBrush(xo, yo, xc, yc, r, stops); + d->CreateRadialGradientBrush(xo,yo,xc,yc,radius,oColor,cColor); p.SetRefData(d); return p; } -wxGraphicsFont wxCairoRenderer::CreateFont( const wxFont &font , const wxColour &col ) +// sets the font +wxGraphicsFont wxCairoRenderer::CreateFont( const wxFont &font , const wxColour &col ) { - wxGraphicsFont p; - ENSURE_LOADED_OR_RETURN(p); - if ( font.IsOk() ) - { + if ( font.Ok() ) + { + wxGraphicsFont p; p.SetRefData(new wxCairoFontData( this , font, col )); + return p; } - return p; + else + return wxNullGraphicsFont; } -wxGraphicsFont -wxCairoRenderer::CreateFont(double sizeInPixels, - const wxString& facename, - int flags, - const wxColour& col) +wxGraphicsBitmap wxGraphicsRenderer::CreateBitmap( const wxBitmap& bmp ) { - wxGraphicsFont font; - ENSURE_LOADED_OR_RETURN(font); - font.SetRefData(new wxCairoFontData(this, sizeInPixels, facename, flags, col)); - return font; -} - -wxGraphicsBitmap wxCairoRenderer::CreateBitmap( const wxBitmap& bmp ) -{ - wxGraphicsBitmap p; - ENSURE_LOADED_OR_RETURN(p); - if ( bmp.IsOk() ) + if ( bmp.Ok() ) { + wxGraphicsBitmap p; p.SetRefData(new wxCairoBitmapData( this , bmp )); + return p; } - return p; + else + return wxNullGraphicsBitmap; } -#if wxUSE_IMAGE - -wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromImage(const wxImage& image) -{ - wxGraphicsBitmap bmp; - - ENSURE_LOADED_OR_RETURN(bmp); - - if ( image.IsOk() ) - { - bmp.SetRefData(new wxCairoBitmapData(this, image)); - } - - return bmp; -} - -wxImage wxCairoRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp) -{ - wxImage image; - ENSURE_LOADED_OR_RETURN(image); - - const wxCairoBitmapData* const - data = static_cast(bmp.GetGraphicsData()); - if (data) - image = data->ConvertToImage(); - - return image; -} - -#endif // wxUSE_IMAGE - - -wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromNativeBitmap( void* bitmap ) -{ - wxGraphicsBitmap p; - ENSURE_LOADED_OR_RETURN(p); - if ( bitmap != NULL ) - { - p.SetRefData(new wxCairoBitmapData( this , (cairo_surface_t*) bitmap )); - } - return p; -} - -wxGraphicsBitmap -wxCairoRenderer::CreateSubBitmap(const wxGraphicsBitmap& WXUNUSED(bitmap), - wxDouble WXUNUSED(x), - wxDouble WXUNUSED(y), - wxDouble WXUNUSED(w), - wxDouble WXUNUSED(h)) -{ - wxGraphicsBitmap p; - wxFAIL_MSG("wxCairoRenderer::CreateSubBitmap is not implemented."); - return p; -} +#endif // wxUSE_CAIRO wxGraphicsRenderer* wxGraphicsRenderer::GetCairoRenderer() { +#if wxUSE_CAIRO return &gs_cairoGraphicsRenderer; -} - -#else // !wxUSE_CAIRO - -wxGraphicsRenderer* wxGraphicsRenderer::GetCairoRenderer() -{ +#else return NULL; +#endif } -#endif // wxUSE_CAIRO/!wxUSE_CAIRO - -// MSW and OS X have their own native default renderers, but the other ports -// use Cairo by default -#if !(defined(__WXMSW__) || defined(__WXOSX__)) -wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer() -{ - return GetCairoRenderer(); -} -#endif // !(__WXMSW__ || __WXOSX__) - #endif // wxUSE_GRAPHICS_CONTEXT diff --git a/Source/3rd Party/wx/src/generic/grid.cpp b/Source/3rd Party/wx/src/generic/grid.cpp deleted file mode 100644 index 6d7815a3a..000000000 --- a/Source/3rd Party/wx/src/generic/grid.cpp +++ /dev/null @@ -1,9333 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Name: src/generic/grid.cpp -// Purpose: wxGrid and related classes -// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) -// Modified by: Robin Dunn, Vadim Zeitlin, Santiago Palacios -// Created: 1/08/1999 -// Copyright: (c) Michael Bedward (mbedward@ozemail.com.au) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -/* - TODO: - - - Replace use of wxINVERT with wxOverlay - - Make Begin/EndBatch() the same as the generic Freeze/Thaw() - - Review the column reordering code, it's a mess. - - Implement row reordering after dealing with the columns. - */ - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_GRID - -#include "wx/grid.h" - -#ifndef WX_PRECOMP - #include "wx/utils.h" - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/log.h" - #include "wx/textctrl.h" - #include "wx/checkbox.h" - #include "wx/combobox.h" - #include "wx/valtext.h" - #include "wx/intl.h" - #include "wx/math.h" - #include "wx/listbox.h" -#endif - -#include "wx/textfile.h" -#include "wx/spinctrl.h" -#include "wx/tokenzr.h" -#include "wx/renderer.h" -#include "wx/headerctrl.h" -#include "wx/hashset.h" - -#include "wx/generic/gridsel.h" -#include "wx/generic/gridctrl.h" -#include "wx/generic/grideditors.h" -#include "wx/generic/private/grid.h" - -const char wxGridNameStr[] = "grid"; - -#if defined(__WXMOTIF__) - #define WXUNUSED_MOTIF(identifier) WXUNUSED(identifier) -#else - #define WXUNUSED_MOTIF(identifier) identifier -#endif - -#if defined(__WXGTK__) - #define WXUNUSED_GTK(identifier) WXUNUSED(identifier) -#else - #define WXUNUSED_GTK(identifier) identifier -#endif - -// Required for wxIs... functions -#include - -WX_DECLARE_HASH_SET_WITH_DECL_PTR(int, wxIntegerHash, wxIntegerEqual, - wxGridFixedIndicesSet, class WXDLLIMPEXP_ADV); - - -// ---------------------------------------------------------------------------- -// globals -// ---------------------------------------------------------------------------- - -namespace -{ - -//#define DEBUG_ATTR_CACHE -#ifdef DEBUG_ATTR_CACHE - static size_t gs_nAttrCacheHits = 0; - static size_t gs_nAttrCacheMisses = 0; -#endif - -// this struct simply combines together the default header renderers -// -// as the renderers ctors are trivial, there is no problem with making them -// globals -struct DefaultHeaderRenderers -{ - wxGridColumnHeaderRendererDefault colRenderer; - wxGridRowHeaderRendererDefault rowRenderer; - wxGridCornerHeaderRendererDefault cornerRenderer; -} gs_defaultHeaderRenderers; - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -wxGridCellCoords wxGridNoCellCoords( -1, -1 ); -wxRect wxGridNoCellRect( -1, -1, -1, -1 ); - -namespace -{ - -// scroll line size -const size_t GRID_SCROLL_LINE_X = 15; -const size_t GRID_SCROLL_LINE_Y = GRID_SCROLL_LINE_X; - -// the size of hash tables used a bit everywhere (the max number of elements -// in these hash tables is the number of rows/columns) -const int GRID_HASH_SIZE = 100; - -// the minimal distance in pixels the mouse needs to move to start a drag -// operation -const int DRAG_SENSITIVITY = 3; - -} // anonymous namespace - -#include "wx/arrimpl.cpp" - -WX_DEFINE_OBJARRAY(wxGridCellCoordsArray) -WX_DEFINE_OBJARRAY(wxGridCellWithAttrArray) - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_ROW_SIZE, wxGridSizeEvent ); -wxDEFINE_EVENT( wxEVT_GRID_COL_SIZE, wxGridSizeEvent ); -wxDEFINE_EVENT( wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent ); -wxDEFINE_EVENT( wxEVT_GRID_COL_MOVE, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_COL_SORT, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGING, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGED, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_SELECT_CELL, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_EDITOR_SHOWN, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent ); -wxDEFINE_EVENT( wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent ); -wxDEFINE_EVENT( wxEVT_GRID_TABBING, wxGridEvent ); - -// ---------------------------------------------------------------------------- -// private helpers -// ---------------------------------------------------------------------------- - -namespace -{ - - // ensure that first is less or equal to second, swapping the values if - // necessary - void EnsureFirstLessThanSecond(int& first, int& second) - { - if ( first > second ) - wxSwap(first, second); - } - -} // anonymous namespace - -// ============================================================================ -// implementation -// ============================================================================ - -IMPLEMENT_ABSTRACT_CLASS(wxGridCellEditorEvtHandler, wxEvtHandler) - -BEGIN_EVENT_TABLE( wxGridCellEditorEvtHandler, wxEvtHandler ) - EVT_KILL_FOCUS( wxGridCellEditorEvtHandler::OnKillFocus ) - EVT_KEY_DOWN( wxGridCellEditorEvtHandler::OnKeyDown ) - EVT_CHAR( wxGridCellEditorEvtHandler::OnChar ) -END_EVENT_TABLE() - -BEGIN_EVENT_TABLE(wxGridHeaderCtrl, wxHeaderCtrl) - EVT_HEADER_CLICK(wxID_ANY, wxGridHeaderCtrl::OnClick) - EVT_HEADER_DCLICK(wxID_ANY, wxGridHeaderCtrl::OnDoubleClick) - EVT_HEADER_RIGHT_CLICK(wxID_ANY, wxGridHeaderCtrl::OnRightClick) - - EVT_HEADER_BEGIN_RESIZE(wxID_ANY, wxGridHeaderCtrl::OnBeginResize) - EVT_HEADER_RESIZING(wxID_ANY, wxGridHeaderCtrl::OnResizing) - EVT_HEADER_END_RESIZE(wxID_ANY, wxGridHeaderCtrl::OnEndResize) - - EVT_HEADER_BEGIN_REORDER(wxID_ANY, wxGridHeaderCtrl::OnBeginReorder) - EVT_HEADER_END_REORDER(wxID_ANY, wxGridHeaderCtrl::OnEndReorder) -END_EVENT_TABLE() - -wxGridOperations& wxGridRowOperations::Dual() const -{ - static wxGridColumnOperations s_colOper; - - return s_colOper; -} - -wxGridOperations& wxGridColumnOperations::Dual() const -{ - static wxGridRowOperations s_rowOper; - - return s_rowOper; -} - -// ---------------------------------------------------------------------------- -// wxGridCellWorker is an (almost) empty common base class for -// wxGridCellRenderer and wxGridCellEditor managing ref counting -// ---------------------------------------------------------------------------- - -void wxGridCellWorker::SetParameters(const wxString& WXUNUSED(params)) -{ - // nothing to do -} - -wxGridCellWorker::~wxGridCellWorker() -{ -} - -// ---------------------------------------------------------------------------- -// wxGridHeaderLabelsRenderer and related classes -// ---------------------------------------------------------------------------- - -void wxGridHeaderLabelsRenderer::DrawLabel(const wxGrid& grid, - wxDC& dc, - const wxString& value, - const wxRect& rect, - int horizAlign, - int vertAlign, - int textOrientation) const -{ - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(grid.GetLabelTextColour()); - dc.SetFont(grid.GetLabelFont()); - grid.DrawTextRectangle(dc, value, rect, horizAlign, vertAlign, textOrientation); -} - - -void wxGridRowHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), - wxDC& dc, - wxRect& rect) const -{ - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW))); - dc.DrawLine(rect.GetRight(), rect.GetTop(), - rect.GetRight(), rect.GetBottom()); - dc.DrawLine(rect.GetLeft(), rect.GetTop(), - rect.GetLeft(), rect.GetBottom()); - dc.DrawLine(rect.GetLeft(), rect.GetBottom(), - rect.GetRight() + 1, rect.GetBottom()); - - dc.SetPen(*wxWHITE_PEN); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), - rect.GetLeft() + 1, rect.GetBottom()); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), - rect.GetRight(), rect.GetTop()); - - rect.Deflate(2); -} - -void wxGridColumnHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), - wxDC& dc, - wxRect& rect) const -{ - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW))); - dc.DrawLine(rect.GetRight(), rect.GetTop(), - rect.GetRight(), rect.GetBottom()); - dc.DrawLine(rect.GetLeft(), rect.GetTop(), - rect.GetRight(), rect.GetTop()); - dc.DrawLine(rect.GetLeft(), rect.GetBottom(), - rect.GetRight() + 1, rect.GetBottom()); - - dc.SetPen(*wxWHITE_PEN); - dc.DrawLine(rect.GetLeft(), rect.GetTop() + 1, - rect.GetLeft(), rect.GetBottom()); - dc.DrawLine(rect.GetLeft(), rect.GetTop() + 1, - rect.GetRight(), rect.GetTop() + 1); - - rect.Deflate(2); -} - -void wxGridCornerHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), - wxDC& dc, - wxRect& rect) const -{ - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW))); - dc.DrawLine(rect.GetRight() - 1, rect.GetBottom() - 1, - rect.GetRight() - 1, rect.GetTop()); - dc.DrawLine(rect.GetRight() - 1, rect.GetBottom() - 1, - rect.GetLeft(), rect.GetBottom() - 1); - dc.DrawLine(rect.GetLeft(), rect.GetTop(), - rect.GetRight(), rect.GetTop()); - dc.DrawLine(rect.GetLeft(), rect.GetTop(), - rect.GetLeft(), rect.GetBottom()); - - dc.SetPen(*wxWHITE_PEN); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop() + 1, - rect.GetRight() - 1, rect.GetTop() + 1); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop() + 1, - rect.GetLeft() + 1, rect.GetBottom() - 1); - - rect.Deflate(2); -} - -// ---------------------------------------------------------------------------- -// wxGridCellAttr -// ---------------------------------------------------------------------------- - -void wxGridCellAttr::Init(wxGridCellAttr *attrDefault) -{ - m_isReadOnly = Unset; - - m_renderer = NULL; - m_editor = NULL; - - m_attrkind = wxGridCellAttr::Cell; - - m_sizeRows = m_sizeCols = 1; - m_overflow = UnsetOverflow; - - SetDefAttr(attrDefault); -} - -wxGridCellAttr *wxGridCellAttr::Clone() const -{ - wxGridCellAttr *attr = new wxGridCellAttr(m_defGridAttr); - - if ( HasTextColour() ) - attr->SetTextColour(GetTextColour()); - if ( HasBackgroundColour() ) - attr->SetBackgroundColour(GetBackgroundColour()); - if ( HasFont() ) - attr->SetFont(GetFont()); - if ( HasAlignment() ) - attr->SetAlignment(m_hAlign, m_vAlign); - - attr->SetSize( m_sizeRows, m_sizeCols ); - - if ( m_renderer ) - { - attr->SetRenderer(m_renderer); - m_renderer->IncRef(); - } - if ( m_editor ) - { - attr->SetEditor(m_editor); - m_editor->IncRef(); - } - - if ( IsReadOnly() ) - attr->SetReadOnly(); - - attr->SetOverflow( m_overflow == Overflow ); - attr->SetKind( m_attrkind ); - - return attr; -} - -void wxGridCellAttr::MergeWith(wxGridCellAttr *mergefrom) -{ - if ( !HasTextColour() && mergefrom->HasTextColour() ) - SetTextColour(mergefrom->GetTextColour()); - if ( !HasBackgroundColour() && mergefrom->HasBackgroundColour() ) - SetBackgroundColour(mergefrom->GetBackgroundColour()); - if ( !HasFont() && mergefrom->HasFont() ) - SetFont(mergefrom->GetFont()); - if ( !HasAlignment() && mergefrom->HasAlignment() ) - { - int hAlign, vAlign; - mergefrom->GetAlignment( &hAlign, &vAlign); - SetAlignment(hAlign, vAlign); - } - if ( !HasSize() && mergefrom->HasSize() ) - mergefrom->GetSize( &m_sizeRows, &m_sizeCols ); - - // Directly access member functions as GetRender/Editor don't just return - // m_renderer/m_editor - // - // Maybe add support for merge of Render and Editor? - if (!HasRenderer() && mergefrom->HasRenderer() ) - { - m_renderer = mergefrom->m_renderer; - m_renderer->IncRef(); - } - if ( !HasEditor() && mergefrom->HasEditor() ) - { - m_editor = mergefrom->m_editor; - m_editor->IncRef(); - } - if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() ) - SetReadOnly(mergefrom->IsReadOnly()); - - if (!HasOverflowMode() && mergefrom->HasOverflowMode() ) - SetOverflow(mergefrom->GetOverflow()); - - SetDefAttr(mergefrom->m_defGridAttr); -} - -void wxGridCellAttr::SetSize(int num_rows, int num_cols) -{ - // The size of a cell is normally 1,1 - - // If this cell is larger (2,2) then this is the top left cell - // the other cells that will be covered (lower right cells) must be - // set to negative or zero values such that - // row + num_rows of the covered cell points to the larger cell (this cell) - // same goes for the col + num_cols. - - // Size of 0,0 is NOT valid, neither is <=0 and any positive value - - wxASSERT_MSG( (!((num_rows > 0) && (num_cols <= 0)) || - !((num_rows <= 0) && (num_cols > 0)) || - !((num_rows == 0) && (num_cols == 0))), - wxT("wxGridCellAttr::SetSize only takes two positive values or negative/zero values")); - - m_sizeRows = num_rows; - m_sizeCols = num_cols; -} - -const wxColour& wxGridCellAttr::GetTextColour() const -{ - if (HasTextColour()) - { - return m_colText; - } - else if (m_defGridAttr && m_defGridAttr != this) - { - return m_defGridAttr->GetTextColour(); - } - else - { - wxFAIL_MSG(wxT("Missing default cell attribute")); - return wxNullColour; - } -} - -const wxColour& wxGridCellAttr::GetBackgroundColour() const -{ - if (HasBackgroundColour()) - { - return m_colBack; - } - else if (m_defGridAttr && m_defGridAttr != this) - { - return m_defGridAttr->GetBackgroundColour(); - } - else - { - wxFAIL_MSG(wxT("Missing default cell attribute")); - return wxNullColour; - } -} - -const wxFont& wxGridCellAttr::GetFont() const -{ - if (HasFont()) - { - return m_font; - } - else if (m_defGridAttr && m_defGridAttr != this) - { - return m_defGridAttr->GetFont(); - } - else - { - wxFAIL_MSG(wxT("Missing default cell attribute")); - return wxNullFont; - } -} - -void wxGridCellAttr::GetAlignment(int *hAlign, int *vAlign) const -{ - if (HasAlignment()) - { - if ( hAlign ) - *hAlign = m_hAlign; - if ( vAlign ) - *vAlign = m_vAlign; - } - else if (m_defGridAttr && m_defGridAttr != this) - { - m_defGridAttr->GetAlignment(hAlign, vAlign); - } - else - { - wxFAIL_MSG(wxT("Missing default cell attribute")); - } -} - -void wxGridCellAttr::GetNonDefaultAlignment(int *hAlign, int *vAlign) const -{ - if ( hAlign && m_hAlign != wxALIGN_INVALID ) - *hAlign = m_hAlign; - - if ( vAlign && m_vAlign != wxALIGN_INVALID ) - *vAlign = m_vAlign; -} - -void wxGridCellAttr::GetSize( int *num_rows, int *num_cols ) const -{ - if ( num_rows ) - *num_rows = m_sizeRows; - if ( num_cols ) - *num_cols = m_sizeCols; -} - -// GetRenderer and GetEditor use a slightly different decision path about -// which attribute to use. If a non-default attr object has one then it is -// used, otherwise the default editor or renderer is fetched from the grid and -// used. It should be the default for the data type of the cell. If it is -// NULL (because the table has a type that the grid does not have in its -// registry), then the grid's default editor or renderer is used. - -wxGridCellRenderer* wxGridCellAttr::GetRenderer(const wxGrid* grid, int row, int col) const -{ - wxGridCellRenderer *renderer = NULL; - - if ( m_renderer && this != m_defGridAttr ) - { - // use the cells renderer if it has one - renderer = m_renderer; - renderer->IncRef(); - } - else // no non-default cell renderer - { - // get default renderer for the data type - if ( grid ) - { - // GetDefaultRendererForCell() will do IncRef() for us - renderer = grid->GetDefaultRendererForCell(row, col); - } - - if ( renderer == NULL ) - { - if ( (m_defGridAttr != NULL) && (m_defGridAttr != this) ) - { - // if we still don't have one then use the grid default - // (no need for IncRef() here neither) - renderer = m_defGridAttr->GetRenderer(NULL, 0, 0); - } - else // default grid attr - { - // use m_renderer which we had decided not to use initially - renderer = m_renderer; - if ( renderer ) - renderer->IncRef(); - } - } - } - - // we're supposed to always find something - wxASSERT_MSG(renderer, wxT("Missing default cell renderer")); - - return renderer; -} - -// same as above, except for s/renderer/editor/g -wxGridCellEditor* wxGridCellAttr::GetEditor(const wxGrid* grid, int row, int col) const -{ - wxGridCellEditor *editor = NULL; - - if ( m_editor && this != m_defGridAttr ) - { - // use the cells editor if it has one - editor = m_editor; - editor->IncRef(); - } - else // no non default cell editor - { - // get default editor for the data type - if ( grid ) - { - // GetDefaultEditorForCell() will do IncRef() for us - editor = grid->GetDefaultEditorForCell(row, col); - } - - if ( editor == NULL ) - { - if ( (m_defGridAttr != NULL) && (m_defGridAttr != this) ) - { - // if we still don't have one then use the grid default - // (no need for IncRef() here neither) - editor = m_defGridAttr->GetEditor(NULL, 0, 0); - } - else // default grid attr - { - // use m_editor which we had decided not to use initially - editor = m_editor; - if ( editor ) - editor->IncRef(); - } - } - } - - // we're supposed to always find something - wxASSERT_MSG(editor, wxT("Missing default cell editor")); - - return editor; -} - -// ---------------------------------------------------------------------------- -// wxGridCellAttrData -// ---------------------------------------------------------------------------- - -void wxGridCellAttrData::SetAttr(wxGridCellAttr *attr, int row, int col) -{ - // Note: contrary to wxGridRowOrColAttrData::SetAttr, we must not - // touch attribute's reference counting explicitly, since this - // is managed by class wxGridCellWithAttr - int n = FindIndex(row, col); - if ( n == wxNOT_FOUND ) - { - if ( attr ) - { - // add the attribute - m_attrs.Add(new wxGridCellWithAttr(row, col, attr)); - } - //else: nothing to do - } - else // we already have an attribute for this cell - { - if ( attr ) - { - // change the attribute - m_attrs[(size_t)n].ChangeAttr(attr); - } - else - { - // remove this attribute - m_attrs.RemoveAt((size_t)n); - } - } -} - -wxGridCellAttr *wxGridCellAttrData::GetAttr(int row, int col) const -{ - wxGridCellAttr *attr = NULL; - - int n = FindIndex(row, col); - if ( n != wxNOT_FOUND ) - { - attr = m_attrs[(size_t)n].attr; - attr->IncRef(); - } - - return attr; -} - -void wxGridCellAttrData::UpdateAttrRows( size_t pos, int numRows ) -{ - size_t count = m_attrs.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_attrs[n].coords; - wxCoord row = coords.GetRow(); - if ((size_t)row >= pos) - { - if (numRows > 0) - { - // If rows inserted, include row counter where necessary - coords.SetRow(row + numRows); - } - else if (numRows < 0) - { - // If rows deleted ... - if ((size_t)row >= pos - numRows) - { - // ...either decrement row counter (if row still exists)... - coords.SetRow(row + numRows); - } - else - { - // ...or remove the attribute - m_attrs.RemoveAt(n); - n--; - count--; - } - } - } - } -} - -void wxGridCellAttrData::UpdateAttrCols( size_t pos, int numCols ) -{ - size_t count = m_attrs.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_attrs[n].coords; - wxCoord col = coords.GetCol(); - if ( (size_t)col >= pos ) - { - if ( numCols > 0 ) - { - // If rows inserted, include row counter where necessary - coords.SetCol(col + numCols); - } - else if (numCols < 0) - { - // If rows deleted ... - if ((size_t)col >= pos - numCols) - { - // ...either decrement row counter (if row still exists)... - coords.SetCol(col + numCols); - } - else - { - // ...or remove the attribute - m_attrs.RemoveAt(n); - n--; - count--; - } - } - } - } -} - -int wxGridCellAttrData::FindIndex(int row, int col) const -{ - size_t count = m_attrs.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - const wxGridCellCoords& coords = m_attrs[n].coords; - if ( (coords.GetRow() == row) && (coords.GetCol() == col) ) - { - return n; - } - } - - return wxNOT_FOUND; -} - -// ---------------------------------------------------------------------------- -// wxGridRowOrColAttrData -// ---------------------------------------------------------------------------- - -wxGridRowOrColAttrData::~wxGridRowOrColAttrData() -{ - size_t count = m_attrs.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - m_attrs[n]->DecRef(); - } -} - -wxGridCellAttr *wxGridRowOrColAttrData::GetAttr(int rowOrCol) const -{ - wxGridCellAttr *attr = NULL; - - int n = m_rowsOrCols.Index(rowOrCol); - if ( n != wxNOT_FOUND ) - { - attr = m_attrs[(size_t)n]; - attr->IncRef(); - } - - return attr; -} - -void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol) -{ - int i = m_rowsOrCols.Index(rowOrCol); - if ( i == wxNOT_FOUND ) - { - if ( attr ) - { - // store the new attribute, taking its ownership - m_rowsOrCols.Add(rowOrCol); - m_attrs.Add(attr); - } - // nothing to remove - } - else // we have an attribute for this row or column - { - size_t n = (size_t)i; - - // notice that this code works correctly even when the old attribute is - // the same as the new one: as we own of it, we must call DecRef() on - // it in any case and this won't result in destruction of the new - // attribute if it's the same as old one because it must have ref count - // of at least 2 to be passed to us while we keep a reference to it too - m_attrs[n]->DecRef(); - - if ( attr ) - { - // replace the attribute with the new one - m_attrs[n] = attr; - } - else // remove the attribute - { - m_rowsOrCols.RemoveAt(n); - m_attrs.RemoveAt(n); - } - } -} - -void wxGridRowOrColAttrData::UpdateAttrRowsOrCols( size_t pos, int numRowsOrCols ) -{ - size_t count = m_attrs.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - int & rowOrCol = m_rowsOrCols[n]; - if ( (size_t)rowOrCol >= pos ) - { - if ( numRowsOrCols > 0 ) - { - // If rows inserted, include row counter where necessary - rowOrCol += numRowsOrCols; - } - else if ( numRowsOrCols < 0) - { - // If rows deleted, either decrement row counter (if row still exists) - if ((size_t)rowOrCol >= pos - numRowsOrCols) - rowOrCol += numRowsOrCols; - else - { - m_rowsOrCols.RemoveAt(n); - m_attrs[n]->DecRef(); - m_attrs.RemoveAt(n); - n--; - count--; - } - } - } - } -} - -// ---------------------------------------------------------------------------- -// wxGridCellAttrProvider -// ---------------------------------------------------------------------------- - -wxGridCellAttrProvider::wxGridCellAttrProvider() -{ - m_data = NULL; -} - -wxGridCellAttrProvider::~wxGridCellAttrProvider() -{ - delete m_data; -} - -void wxGridCellAttrProvider::InitData() -{ - m_data = new wxGridCellAttrProviderData; -} - -wxGridCellAttr *wxGridCellAttrProvider::GetAttr(int row, int col, - wxGridCellAttr::wxAttrKind kind ) const -{ - wxGridCellAttr *attr = NULL; - if ( m_data ) - { - switch (kind) - { - case (wxGridCellAttr::Any): - // Get cached merge attributes. - // Currently not used as no cache implemented as not mutable - // attr = m_data->m_mergeAttr.GetAttr(row, col); - if (!attr) - { - // Basically implement old version. - // Also check merge cache, so we don't have to re-merge every time.. - wxGridCellAttr *attrcell = m_data->m_cellAttrs.GetAttr(row, col); - wxGridCellAttr *attrrow = m_data->m_rowAttrs.GetAttr(row); - wxGridCellAttr *attrcol = m_data->m_colAttrs.GetAttr(col); - - if ((attrcell != attrrow) && (attrrow != attrcol) && (attrcell != attrcol)) - { - // Two or more are non NULL - attr = new wxGridCellAttr; - attr->SetKind(wxGridCellAttr::Merged); - - // Order is important.. - if (attrcell) - { - attr->MergeWith(attrcell); - attrcell->DecRef(); - } - if (attrcol) - { - attr->MergeWith(attrcol); - attrcol->DecRef(); - } - if (attrrow) - { - attr->MergeWith(attrrow); - attrrow->DecRef(); - } - - // store merge attr if cache implemented - //attr->IncRef(); - //m_data->m_mergeAttr.SetAttr(attr, row, col); - } - else - { - // one or none is non null return it or null. - if (attrrow) - attr = attrrow; - if (attrcol) - { - if (attr) - attr->DecRef(); - attr = attrcol; - } - if (attrcell) - { - if (attr) - attr->DecRef(); - attr = attrcell; - } - } - } - break; - - case (wxGridCellAttr::Cell): - attr = m_data->m_cellAttrs.GetAttr(row, col); - break; - - case (wxGridCellAttr::Col): - attr = m_data->m_colAttrs.GetAttr(col); - break; - - case (wxGridCellAttr::Row): - attr = m_data->m_rowAttrs.GetAttr(row); - break; - - default: - // unused as yet... - // (wxGridCellAttr::Default): - // (wxGridCellAttr::Merged): - break; - } - } - - return attr; -} - -void wxGridCellAttrProvider::SetAttr(wxGridCellAttr *attr, - int row, int col) -{ - if ( !m_data ) - InitData(); - - m_data->m_cellAttrs.SetAttr(attr, row, col); -} - -void wxGridCellAttrProvider::SetRowAttr(wxGridCellAttr *attr, int row) -{ - if ( !m_data ) - InitData(); - - m_data->m_rowAttrs.SetAttr(attr, row); -} - -void wxGridCellAttrProvider::SetColAttr(wxGridCellAttr *attr, int col) -{ - if ( !m_data ) - InitData(); - - m_data->m_colAttrs.SetAttr(attr, col); -} - -void wxGridCellAttrProvider::UpdateAttrRows( size_t pos, int numRows ) -{ - if ( m_data ) - { - m_data->m_cellAttrs.UpdateAttrRows( pos, numRows ); - - m_data->m_rowAttrs.UpdateAttrRowsOrCols( pos, numRows ); - } -} - -void wxGridCellAttrProvider::UpdateAttrCols( size_t pos, int numCols ) -{ - if ( m_data ) - { - m_data->m_cellAttrs.UpdateAttrCols( pos, numCols ); - - m_data->m_colAttrs.UpdateAttrRowsOrCols( pos, numCols ); - } -} - -const wxGridColumnHeaderRenderer& -wxGridCellAttrProvider::GetColumnHeaderRenderer(int WXUNUSED(col)) -{ - return gs_defaultHeaderRenderers.colRenderer; -} - -const wxGridRowHeaderRenderer& -wxGridCellAttrProvider::GetRowHeaderRenderer(int WXUNUSED(row)) -{ - return gs_defaultHeaderRenderers.rowRenderer; -} - -const wxGridCornerHeaderRenderer& wxGridCellAttrProvider::GetCornerRenderer() -{ - return gs_defaultHeaderRenderers.cornerRenderer; -} - -// ---------------------------------------------------------------------------- -// wxGridTableBase -// ---------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS( wxGridTableBase, wxObject ) - -wxGridTableBase::wxGridTableBase() -{ - m_view = NULL; - m_attrProvider = NULL; -} - -wxGridTableBase::~wxGridTableBase() -{ - delete m_attrProvider; -} - -void wxGridTableBase::SetAttrProvider(wxGridCellAttrProvider *attrProvider) -{ - delete m_attrProvider; - m_attrProvider = attrProvider; -} - -bool wxGridTableBase::CanHaveAttributes() -{ - if ( ! GetAttrProvider() ) - { - // use the default attr provider by default - SetAttrProvider(new wxGridCellAttrProvider); - } - - return true; -} - -wxGridCellAttr *wxGridTableBase::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) -{ - if ( m_attrProvider ) - return m_attrProvider->GetAttr(row, col, kind); - else - return NULL; -} - -void wxGridTableBase::SetAttr(wxGridCellAttr* attr, int row, int col) -{ - if ( m_attrProvider ) - { - if ( attr ) - attr->SetKind(wxGridCellAttr::Cell); - m_attrProvider->SetAttr(attr, row, col); - } - else - { - // as we take ownership of the pointer and don't store it, we must - // free it now - wxSafeDecRef(attr); - } -} - -void wxGridTableBase::SetRowAttr(wxGridCellAttr *attr, int row) -{ - if ( m_attrProvider ) - { - attr->SetKind(wxGridCellAttr::Row); - m_attrProvider->SetRowAttr(attr, row); - } - else - { - // as we take ownership of the pointer and don't store it, we must - // free it now - wxSafeDecRef(attr); - } -} - -void wxGridTableBase::SetColAttr(wxGridCellAttr *attr, int col) -{ - if ( m_attrProvider ) - { - attr->SetKind(wxGridCellAttr::Col); - m_attrProvider->SetColAttr(attr, col); - } - else - { - // as we take ownership of the pointer and don't store it, we must - // free it now - wxSafeDecRef(attr); - } -} - -bool wxGridTableBase::InsertRows( size_t WXUNUSED(pos), - size_t WXUNUSED(numRows) ) -{ - wxFAIL_MSG( wxT("Called grid table class function InsertRows\nbut your derived table class does not override this function") ); - - return false; -} - -bool wxGridTableBase::AppendRows( size_t WXUNUSED(numRows) ) -{ - wxFAIL_MSG( wxT("Called grid table class function AppendRows\nbut your derived table class does not override this function")); - - return false; -} - -bool wxGridTableBase::DeleteRows( size_t WXUNUSED(pos), - size_t WXUNUSED(numRows) ) -{ - wxFAIL_MSG( wxT("Called grid table class function DeleteRows\nbut your derived table class does not override this function")); - - return false; -} - -bool wxGridTableBase::InsertCols( size_t WXUNUSED(pos), - size_t WXUNUSED(numCols) ) -{ - wxFAIL_MSG( wxT("Called grid table class function InsertCols\nbut your derived table class does not override this function")); - - return false; -} - -bool wxGridTableBase::AppendCols( size_t WXUNUSED(numCols) ) -{ - wxFAIL_MSG(wxT("Called grid table class function AppendCols\nbut your derived table class does not override this function")); - - return false; -} - -bool wxGridTableBase::DeleteCols( size_t WXUNUSED(pos), - size_t WXUNUSED(numCols) ) -{ - wxFAIL_MSG( wxT("Called grid table class function DeleteCols\nbut your derived table class does not override this function")); - - return false; -} - -wxString wxGridTableBase::GetRowLabelValue( int row ) -{ - wxString s; - - // RD: Starting the rows at zero confuses users, - // no matter how much it makes sense to us geeks. - s << row + 1; - - return s; -} - -wxString wxGridTableBase::GetColLabelValue( int col ) -{ - // default col labels are: - // cols 0 to 25 : A-Z - // cols 26 to 675 : AA-ZZ - // etc. - - wxString s; - unsigned int i, n; - for ( n = 1; ; n++ ) - { - s += (wxChar) (wxT('A') + (wxChar)(col % 26)); - col = col / 26 - 1; - if ( col < 0 ) - break; - } - - // reverse the string... - wxString s2; - for ( i = 0; i < n; i++ ) - { - s2 += s[n - i - 1]; - } - - return s2; -} - -wxString wxGridTableBase::GetTypeName( int WXUNUSED(row), int WXUNUSED(col) ) -{ - return wxGRID_VALUE_STRING; -} - -bool wxGridTableBase::CanGetValueAs( int WXUNUSED(row), int WXUNUSED(col), - const wxString& typeName ) -{ - return typeName == wxGRID_VALUE_STRING; -} - -bool wxGridTableBase::CanSetValueAs( int row, int col, const wxString& typeName ) -{ - return CanGetValueAs(row, col, typeName); -} - -long wxGridTableBase::GetValueAsLong( int WXUNUSED(row), int WXUNUSED(col) ) -{ - return 0; -} - -double wxGridTableBase::GetValueAsDouble( int WXUNUSED(row), int WXUNUSED(col) ) -{ - return 0.0; -} - -bool wxGridTableBase::GetValueAsBool( int WXUNUSED(row), int WXUNUSED(col) ) -{ - return false; -} - -void wxGridTableBase::SetValueAsLong( int WXUNUSED(row), int WXUNUSED(col), - long WXUNUSED(value) ) -{ -} - -void wxGridTableBase::SetValueAsDouble( int WXUNUSED(row), int WXUNUSED(col), - double WXUNUSED(value) ) -{ -} - -void wxGridTableBase::SetValueAsBool( int WXUNUSED(row), int WXUNUSED(col), - bool WXUNUSED(value) ) -{ -} - -void* wxGridTableBase::GetValueAsCustom( int WXUNUSED(row), int WXUNUSED(col), - const wxString& WXUNUSED(typeName) ) -{ - return NULL; -} - -void wxGridTableBase::SetValueAsCustom( int WXUNUSED(row), int WXUNUSED(col), - const wxString& WXUNUSED(typeName), - void* WXUNUSED(value) ) -{ -} - -////////////////////////////////////////////////////////////////////// -// -// Message class for the grid table to send requests and notifications -// to the grid view -// - -wxGridTableMessage::wxGridTableMessage() -{ - m_table = NULL; - m_id = -1; - m_comInt1 = -1; - m_comInt2 = -1; -} - -wxGridTableMessage::wxGridTableMessage( wxGridTableBase *table, int id, - int commandInt1, int commandInt2 ) -{ - m_table = table; - m_id = id; - m_comInt1 = commandInt1; - m_comInt2 = commandInt2; -} - -////////////////////////////////////////////////////////////////////// -// -// A basic grid table for string data. An object of this class will -// created by wxGrid if you don't specify an alternative table class. -// - -WX_DEFINE_OBJARRAY(wxGridStringArray) - -IMPLEMENT_DYNAMIC_CLASS( wxGridStringTable, wxGridTableBase ) - -wxGridStringTable::wxGridStringTable() - : wxGridTableBase() -{ - m_numCols = 0; -} - -wxGridStringTable::wxGridStringTable( int numRows, int numCols ) - : wxGridTableBase() -{ - m_numCols = numCols; - - m_data.Alloc( numRows ); - - wxArrayString sa; - sa.Alloc( numCols ); - sa.Add( wxEmptyString, numCols ); - - m_data.Add( sa, numRows ); -} - -wxString wxGridStringTable::GetValue( int row, int col ) -{ - wxCHECK_MSG( (row >= 0 && row < GetNumberRows()) && - (col >= 0 && col < GetNumberCols()), - wxEmptyString, - wxT("invalid row or column index in wxGridStringTable") ); - - return m_data[row][col]; -} - -void wxGridStringTable::SetValue( int row, int col, const wxString& value ) -{ - wxCHECK_RET( (row >= 0 && row < GetNumberRows()) && - (col >= 0 && col < GetNumberCols()), - wxT("invalid row or column index in wxGridStringTable") ); - - m_data[row][col] = value; -} - -void wxGridStringTable::Clear() -{ - int row, col; - int numRows, numCols; - - numRows = m_data.GetCount(); - if ( numRows > 0 ) - { - numCols = m_data[0].GetCount(); - - for ( row = 0; row < numRows; row++ ) - { - for ( col = 0; col < numCols; col++ ) - { - m_data[row][col] = wxEmptyString; - } - } - } -} - -bool wxGridStringTable::InsertRows( size_t pos, size_t numRows ) -{ - if ( pos >= m_data.size() ) - { - return AppendRows( numRows ); - } - - wxArrayString sa; - sa.Alloc( m_numCols ); - sa.Add( wxEmptyString, m_numCols ); - m_data.Insert( sa, pos, numRows ); - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_ROWS_INSERTED, - pos, - numRows ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -bool wxGridStringTable::AppendRows( size_t numRows ) -{ - wxArrayString sa; - if ( m_numCols > 0 ) - { - sa.Alloc( m_numCols ); - sa.Add( wxEmptyString, m_numCols ); - } - - m_data.Add( sa, numRows ); - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_ROWS_APPENDED, - numRows ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -bool wxGridStringTable::DeleteRows( size_t pos, size_t numRows ) -{ - size_t curNumRows = m_data.GetCount(); - - if ( pos >= curNumRows ) - { - wxFAIL_MSG( wxString::Format - ( - wxT("Called wxGridStringTable::DeleteRows(pos=%lu, N=%lu)\nPos value is invalid for present table with %lu rows"), - (unsigned long)pos, - (unsigned long)numRows, - (unsigned long)curNumRows - ) ); - - return false; - } - - if ( numRows > curNumRows - pos ) - { - numRows = curNumRows - pos; - } - - if ( numRows >= curNumRows ) - { - m_data.Clear(); - } - else - { - m_data.RemoveAt( pos, numRows ); - } - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_ROWS_DELETED, - pos, - numRows ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -bool wxGridStringTable::InsertCols( size_t pos, size_t numCols ) -{ - if ( pos >= static_cast(m_numCols) ) - { - return AppendCols( numCols ); - } - - if ( !m_colLabels.IsEmpty() ) - { - m_colLabels.Insert( wxEmptyString, pos, numCols ); - - for ( size_t i = pos; i < pos + numCols; i++ ) - m_colLabels[i] = wxGridTableBase::GetColLabelValue( i ); - } - - for ( size_t row = 0; row < m_data.size(); row++ ) - { - for ( size_t col = pos; col < pos + numCols; col++ ) - { - m_data[row].Insert( wxEmptyString, col ); - } - } - - m_numCols += numCols; - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_COLS_INSERTED, - pos, - numCols ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -bool wxGridStringTable::AppendCols( size_t numCols ) -{ - for ( size_t row = 0; row < m_data.size(); row++ ) - { - m_data[row].Add( wxEmptyString, numCols ); - } - - m_numCols += numCols; - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_COLS_APPENDED, - numCols ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols ) -{ - size_t row; - - size_t curNumRows = m_data.GetCount(); - size_t curNumCols = m_numCols; - - if ( pos >= curNumCols ) - { - wxFAIL_MSG( wxString::Format - ( - wxT("Called wxGridStringTable::DeleteCols(pos=%lu, N=%lu)\nPos value is invalid for present table with %lu cols"), - (unsigned long)pos, - (unsigned long)numCols, - (unsigned long)curNumCols - ) ); - return false; - } - - int colID; - if ( GetView() ) - colID = GetView()->GetColAt( pos ); - else - colID = pos; - - if ( numCols > curNumCols - colID ) - { - numCols = curNumCols - colID; - } - - if ( !m_colLabels.IsEmpty() ) - { - // m_colLabels stores just as many elements as it needs, e.g. if only - // the label of the first column had been set it would have only one - // element and not numCols, so account for it - int numRemaining = m_colLabels.size() - colID; - if (numRemaining > 0) - m_colLabels.RemoveAt( colID, wxMin(numCols, numRemaining) ); - } - - if ( numCols >= curNumCols ) - { - for ( row = 0; row < curNumRows; row++ ) - { - m_data[row].Clear(); - } - - m_numCols = 0; - } - else // something will be left - { - for ( row = 0; row < curNumRows; row++ ) - { - m_data[row].RemoveAt( colID, numCols ); - } - - m_numCols -= numCols; - } - - if ( GetView() ) - { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_COLS_DELETED, - pos, - numCols ); - - GetView()->ProcessTableMessage( msg ); - } - - return true; -} - -wxString wxGridStringTable::GetRowLabelValue( int row ) -{ - if ( row > (int)(m_rowLabels.GetCount()) - 1 ) - { - // using default label - // - return wxGridTableBase::GetRowLabelValue( row ); - } - else - { - return m_rowLabels[row]; - } -} - -wxString wxGridStringTable::GetColLabelValue( int col ) -{ - if ( col > (int)(m_colLabels.GetCount()) - 1 ) - { - // using default label - // - return wxGridTableBase::GetColLabelValue( col ); - } - else - { - return m_colLabels[col]; - } -} - -void wxGridStringTable::SetRowLabelValue( int row, const wxString& value ) -{ - if ( row > (int)(m_rowLabels.GetCount()) - 1 ) - { - int n = m_rowLabels.GetCount(); - int i; - - for ( i = n; i <= row; i++ ) - { - m_rowLabels.Add( wxGridTableBase::GetRowLabelValue(i) ); - } - } - - m_rowLabels[row] = value; -} - -void wxGridStringTable::SetColLabelValue( int col, const wxString& value ) -{ - if ( col > (int)(m_colLabels.GetCount()) - 1 ) - { - int n = m_colLabels.GetCount(); - int i; - - for ( i = n; i <= col; i++ ) - { - m_colLabels.Add( wxGridTableBase::GetColLabelValue(i) ); - } - } - - m_colLabels[col] = value; -} - - -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE(wxGridSubwindow, wxWindow) - EVT_MOUSE_CAPTURE_LOST(wxGridSubwindow::OnMouseCaptureLost) -END_EVENT_TABLE() - -void wxGridSubwindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) -{ - m_owner->CancelMouseCapture(); -} - -BEGIN_EVENT_TABLE( wxGridRowLabelWindow, wxGridSubwindow ) - EVT_PAINT( wxGridRowLabelWindow::OnPaint ) - EVT_MOUSEWHEEL( wxGridRowLabelWindow::OnMouseWheel ) - EVT_MOUSE_EVENTS( wxGridRowLabelWindow::OnMouseEvent ) -END_EVENT_TABLE() - -void wxGridRowLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - - // NO - don't do this because it will set both the x and y origin - // coords to match the parent scrolled window and we just want to - // set the y coord - MB - // - // m_owner->PrepareDC( dc ); - - int x, y; - m_owner->CalcUnscrolledPosition( 0, 0, &x, &y ); - wxPoint pt = dc.GetDeviceOrigin(); - dc.SetDeviceOrigin( pt.x, pt.y-y ); - - wxArrayInt rows = m_owner->CalcRowLabelsExposed( GetUpdateRegion() ); - m_owner->DrawRowLabels( dc, rows ); -} - -void wxGridRowLabelWindow::OnMouseEvent( wxMouseEvent& event ) -{ - m_owner->ProcessRowLabelMouseEvent( event ); -} - -void wxGridRowLabelWindow::OnMouseWheel( wxMouseEvent& event ) -{ - if (!m_owner->GetEventHandler()->ProcessEvent( event )) - event.Skip(); -} - -////////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE( wxGridColLabelWindow, wxGridSubwindow ) - EVT_PAINT( wxGridColLabelWindow::OnPaint ) - EVT_MOUSEWHEEL( wxGridColLabelWindow::OnMouseWheel ) - EVT_MOUSE_EVENTS( wxGridColLabelWindow::OnMouseEvent ) -END_EVENT_TABLE() - -void wxGridColLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - - // NO - don't do this because it will set both the x and y origin - // coords to match the parent scrolled window and we just want to - // set the x coord - MB - // - // m_owner->PrepareDC( dc ); - - int x, y; - m_owner->CalcUnscrolledPosition( 0, 0, &x, &y ); - wxPoint pt = dc.GetDeviceOrigin(); - dc.SetDeviceOrigin( pt.x-x, pt.y ); - - wxArrayInt cols = m_owner->CalcColLabelsExposed( GetUpdateRegion() ); - m_owner->DrawColLabels( dc, cols ); -} - -void wxGridColLabelWindow::OnMouseEvent( wxMouseEvent& event ) -{ - m_owner->ProcessColLabelMouseEvent( event ); -} - -void wxGridColLabelWindow::OnMouseWheel( wxMouseEvent& event ) -{ - if (!m_owner->GetEventHandler()->ProcessEvent( event )) - event.Skip(); -} - -////////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE( wxGridCornerLabelWindow, wxGridSubwindow ) - EVT_MOUSEWHEEL( wxGridCornerLabelWindow::OnMouseWheel ) - EVT_MOUSE_EVENTS( wxGridCornerLabelWindow::OnMouseEvent ) - EVT_PAINT( wxGridCornerLabelWindow::OnPaint ) -END_EVENT_TABLE() - -void wxGridCornerLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - - m_owner->DrawCornerLabel(dc); -} - -void wxGridCornerLabelWindow::OnMouseEvent( wxMouseEvent& event ) -{ - m_owner->ProcessCornerLabelMouseEvent( event ); -} - -void wxGridCornerLabelWindow::OnMouseWheel( wxMouseEvent& event ) -{ - if (!m_owner->GetEventHandler()->ProcessEvent(event)) - event.Skip(); -} - -////////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE( wxGridWindow, wxGridSubwindow ) - EVT_PAINT( wxGridWindow::OnPaint ) - EVT_MOUSEWHEEL( wxGridWindow::OnMouseWheel ) - EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent ) - EVT_KEY_DOWN( wxGridWindow::OnKeyDown ) - EVT_KEY_UP( wxGridWindow::OnKeyUp ) - EVT_CHAR( wxGridWindow::OnChar ) - EVT_SET_FOCUS( wxGridWindow::OnFocus ) - EVT_KILL_FOCUS( wxGridWindow::OnFocus ) - EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground ) -END_EVENT_TABLE() - -void wxGridWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) -{ - wxPaintDC dc( this ); - m_owner->PrepareDC( dc ); - wxRegion reg = GetUpdateRegion(); - wxGridCellCoordsArray dirtyCells = m_owner->CalcCellsExposed( reg ); - m_owner->DrawGridCellArea( dc, dirtyCells ); - - m_owner->DrawGridSpace( dc ); - - m_owner->DrawAllGridLines( dc, reg ); - - m_owner->DrawHighlight( dc, dirtyCells ); -} - -void wxGrid::Render( wxDC& dc, - const wxPoint& position, - const wxSize& size, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - int style ) -{ - wxCHECK_RET( bottomRight.GetCol() < GetNumberCols(), - "Invalid right column" ); - wxCHECK_RET( bottomRight.GetRow() < GetNumberRows(), - "Invalid bottom row" ); - - // store user settings and reset later - - // remove grid selection, don't paint selection colour - // unless we have wxGRID_DRAW_SELECTION - // block selections are the only ones catered for here - wxGridCellCoordsArray selectedCells; - bool hasSelection = IsSelection(); - if ( hasSelection && !( style & wxGRID_DRAW_SELECTION ) ) - { - selectedCells = GetSelectionBlockTopLeft(); - // non block selections may not have a bottom right - if ( GetSelectionBlockBottomRight().size() ) - selectedCells.Add( GetSelectionBlockBottomRight()[ 0 ] ); - - ClearSelection(); - } - - // store user device origin - wxCoord userOriginX, userOriginY; - dc.GetDeviceOrigin( &userOriginX, &userOriginY ); - - // store user scale - double scaleUserX, scaleUserY; - dc.GetUserScale( &scaleUserX, &scaleUserY ); - - // set defaults if necessary - wxGridCellCoords leftTop( topLeft ), rightBottom( bottomRight ); - if ( leftTop.GetCol() < 0 ) - leftTop.SetCol(0); - if ( leftTop.GetRow() < 0 ) - leftTop.SetRow(0); - if ( rightBottom.GetCol() < 0 ) - rightBottom.SetCol(GetNumberCols() - 1); - if ( rightBottom.GetRow() < 0 ) - rightBottom.SetRow(GetNumberRows() - 1); - - // get grid offset, size and cell parameters - wxPoint pointOffSet; - wxSize sizeGrid; - wxGridCellCoordsArray renderCells; - wxArrayInt arrayCols; - wxArrayInt arrayRows; - - GetRenderSizes( leftTop, rightBottom, - pointOffSet, sizeGrid, - renderCells, - arrayCols, arrayRows ); - - // add headers/labels to dimensions - if ( style & wxGRID_DRAW_ROWS_HEADER ) - sizeGrid.x += GetRowLabelSize(); - if ( style & wxGRID_DRAW_COLS_HEADER ) - sizeGrid.y += GetColLabelSize(); - - // get render start position in logical units - wxPoint positionRender = GetRenderPosition( dc, position ); - - wxCoord originX = dc.LogicalToDeviceX( positionRender.x ); - wxCoord originY = dc.LogicalToDeviceY( positionRender.y ); - - dc.SetDeviceOrigin( originX, originY ); - - SetRenderScale( dc, positionRender, size, sizeGrid ); - - // draw row headers at specified origin - if ( GetRowLabelSize() > 0 && ( style & wxGRID_DRAW_ROWS_HEADER ) ) - { - if ( style & wxGRID_DRAW_COLS_HEADER ) - { - DrawCornerLabel( dc ); // do only if both col and row labels drawn - originY += dc.LogicalToDeviceYRel( GetColLabelSize() ); - } - - originY -= dc.LogicalToDeviceYRel( pointOffSet.y ); - dc.SetDeviceOrigin( originX, originY ); - - DrawRowLabels( dc, arrayRows ); - - // reset for columns - if ( style & wxGRID_DRAW_COLS_HEADER ) - originY -= dc.LogicalToDeviceYRel( GetColLabelSize() ); - - originY += dc.LogicalToDeviceYRel( pointOffSet.y ); - // X offset so we don't overwrite row labels - originX += dc.LogicalToDeviceXRel( GetRowLabelSize() ); - } - - // subtract col offset where startcol > 0 - originX -= dc.LogicalToDeviceXRel( pointOffSet.x ); - // no y offset for col labels, they are at the Y origin - - // draw column labels - if ( style & wxGRID_DRAW_COLS_HEADER ) - { - dc.SetDeviceOrigin( originX, originY ); - DrawColLabels( dc, arrayCols ); - // don't overwrite the labels, increment originY - originY += dc.LogicalToDeviceYRel( GetColLabelSize() ); - } - - // set device origin to draw grid cells and lines - originY -= dc.LogicalToDeviceYRel( pointOffSet.y ); - dc.SetDeviceOrigin( originX, originY ); - - // draw cell area background - dc.SetBrush( GetDefaultCellBackgroundColour() ); - dc.SetPen( *wxTRANSPARENT_PEN ); - // subtract headers from grid area dimensions - wxSize sizeCells( sizeGrid ); - if ( style & wxGRID_DRAW_ROWS_HEADER ) - sizeCells.x -= GetRowLabelSize(); - if ( style & wxGRID_DRAW_COLS_HEADER ) - sizeCells.y -= GetColLabelSize(); - - dc.DrawRectangle( pointOffSet, sizeCells ); - - // draw cells - DrawGridCellArea( dc, renderCells ); - - // draw grid lines - if ( style & wxGRID_DRAW_CELL_LINES ) - { - wxRegion regionClip( pointOffSet.x, pointOffSet.y, - sizeCells.x, sizeCells.y ); - - DrawRangeGridLines(dc, regionClip, renderCells[0], renderCells.Last()); - } - - // draw render rectangle bounding lines - DoRenderBox( dc, style, - pointOffSet, sizeCells, - leftTop, rightBottom ); - - // restore user setings - dc.SetDeviceOrigin( userOriginX, userOriginY ); - dc.SetUserScale( scaleUserX, scaleUserY ); - - if ( selectedCells.size() && !( style & wxGRID_DRAW_SELECTION ) ) - { - SelectBlock( selectedCells[ 0 ].GetRow(), - selectedCells[ 0 ].GetCol(), - selectedCells[ selectedCells.size() -1 ].GetRow(), - selectedCells[ selectedCells.size() -1 ].GetCol() ); - } -} - -void -wxGrid::SetRenderScale(wxDC& dc, - const wxPoint& pos, const wxSize& size, - const wxSize& sizeGrid ) -{ - double scaleX, scaleY; - wxSize sizeTemp; - - if ( size.GetWidth() != wxDefaultSize.GetWidth() ) // size.x was specified - sizeTemp.SetWidth( size.GetWidth() ); - else - sizeTemp.SetWidth( dc.DeviceToLogicalXRel( dc.GetSize().GetWidth() ) - - pos.x ); - - if ( size.GetHeight() != wxDefaultSize.GetHeight() ) // size.y was specified - sizeTemp.SetHeight( size.GetHeight() ); - else - sizeTemp.SetHeight( dc.DeviceToLogicalYRel( dc.GetSize().GetHeight() ) - - pos.y ); - - scaleX = (double)( (double) sizeTemp.GetWidth() / (double) sizeGrid.GetWidth() ); - scaleY = (double)( (double) sizeTemp.GetHeight() / (double) sizeGrid.GetHeight() ); - - dc.SetUserScale( wxMin( scaleX, scaleY), wxMin( scaleX, scaleY ) ); -} - -// get grid rendered size, origin offset and fill cell arrays -void wxGrid::GetRenderSizes( const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - wxPoint& pointOffSet, wxSize& sizeGrid, - wxGridCellCoordsArray& renderCells, - wxArrayInt& arrayCols, wxArrayInt& arrayRows ) -{ - pointOffSet.x = 0; - pointOffSet.y = 0; - sizeGrid.SetWidth( 0 ); - sizeGrid.SetHeight( 0 ); - - int col, row; - - wxGridSizesInfo sizeinfo = GetColSizes(); - for ( col = 0; col <= bottomRight.GetCol(); col++ ) - { - if ( col < topLeft.GetCol() ) - { - pointOffSet.x += sizeinfo.GetSize( col ); - } - else - { - for ( row = topLeft.GetRow(); row <= bottomRight.GetRow(); row++ ) - { - renderCells.Add( wxGridCellCoords( row, col )); - arrayRows.Add( row ); // column labels rendered in DrawColLabels - } - arrayCols.Add( col ); // row labels rendered in DrawRowLabels - sizeGrid.x += sizeinfo.GetSize( col ); - } - } - - sizeinfo = GetRowSizes(); - for ( row = 0; row <= bottomRight.GetRow(); row++ ) - { - if ( row < topLeft.GetRow() ) - pointOffSet.y += sizeinfo.GetSize( row ); - else - sizeGrid.y += sizeinfo.GetSize( row ); - } -} - -// get render start position -// if position not specified use dc draw extents MaxX and MaxY -wxPoint wxGrid::GetRenderPosition( wxDC& dc, const wxPoint& position ) -{ - wxPoint positionRender( position ); - - if ( !positionRender.IsFullySpecified() ) - { - if ( positionRender.x == wxDefaultPosition.x ) - positionRender.x = dc.MaxX(); - - if ( positionRender.y == wxDefaultPosition.y ) - positionRender.y = dc.MaxY(); - } - - return positionRender; -} - -// draw render rectangle bounding lines -// useful where there is multi cell row or col clipping and no cell border -void wxGrid::DoRenderBox( wxDC& dc, const int& style, - const wxPoint& pointOffSet, - const wxSize& sizeCells, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight ) -{ - if ( !( style & wxGRID_DRAW_BOX_RECT ) ) - return; - - int bottom = pointOffSet.y + sizeCells.GetY(), - right = pointOffSet.x + sizeCells.GetX() - 1; - - // horiz top line if we are not drawing column header/labels - if ( !( style & wxGRID_DRAW_COLS_HEADER ) ) - { - int left = pointOffSet.x; - left += ( style & wxGRID_DRAW_COLS_HEADER ) - ? - GetRowLabelSize() : 0; - dc.SetPen( GetRowGridLinePen( topLeft.GetRow() ) ); - dc.DrawLine( left, - pointOffSet.y, - right, - pointOffSet.y ); - } - - // horiz bottom line - dc.SetPen( GetRowGridLinePen( bottomRight.GetRow() ) ); - dc.DrawLine( pointOffSet.x, bottom - 1, right, bottom - 1 ); - - // left vertical line if we are not drawing row header/labels - if ( !( style & wxGRID_DRAW_ROWS_HEADER ) ) - { - int top = pointOffSet.y; - top += ( style & wxGRID_DRAW_COLS_HEADER ) - ? - GetColLabelSize() : 0; - dc.SetPen( GetColGridLinePen( topLeft.GetCol() ) ); - dc.DrawLine( pointOffSet.x -1, - top, - pointOffSet.x - 1, - bottom - 1 ); - } - - // right vertical line - dc.SetPen( GetColGridLinePen( bottomRight.GetCol() ) ); - dc.DrawLine( right, pointOffSet.y, right, bottom - 1 ); -} - -void wxGridWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) -{ - wxWindow::ScrollWindow( dx, dy, rect ); - m_owner->GetGridRowLabelWindow()->ScrollWindow( 0, dy, rect ); - m_owner->GetGridColLabelWindow()->ScrollWindow( dx, 0, rect ); -} - -void wxGridWindow::OnMouseEvent( wxMouseEvent& event ) -{ - if (event.ButtonDown(wxMOUSE_BTN_LEFT) && FindFocus() != this) - SetFocus(); - - m_owner->ProcessGridCellMouseEvent( event ); -} - -void wxGridWindow::OnMouseWheel( wxMouseEvent& event ) -{ - if (!m_owner->GetEventHandler()->ProcessEvent( event )) - event.Skip(); -} - -// This seems to be required for wxMotif/wxGTK otherwise the mouse -// cursor must be in the cell edit control to get key events -// -void wxGridWindow::OnKeyDown( wxKeyEvent& event ) -{ - if ( !m_owner->GetEventHandler()->ProcessEvent( event ) ) - event.Skip(); -} - -void wxGridWindow::OnKeyUp( wxKeyEvent& event ) -{ - if ( !m_owner->GetEventHandler()->ProcessEvent( event ) ) - event.Skip(); -} - -void wxGridWindow::OnChar( wxKeyEvent& event ) -{ - if ( !m_owner->GetEventHandler()->ProcessEvent( event ) ) - event.Skip(); -} - -void wxGridWindow::OnEraseBackground( wxEraseEvent& WXUNUSED(event) ) -{ -} - -void wxGridWindow::OnFocus(wxFocusEvent& event) -{ - // and if we have any selection, it has to be repainted, because it - // uses different colour when the grid is not focused: - if ( m_owner->IsSelection() ) - { - Refresh(); - } - else - { - // NB: Note that this code is in "else" branch only because the other - // branch refreshes everything and so there's no point in calling - // Refresh() again, *not* because it should only be done if - // !IsSelection(). If the above code is ever optimized to refresh - // only selected area, this needs to be moved out of the "else" - // branch so that it's always executed. - - // current cell cursor {dis,re}appears on focus change: - const wxGridCellCoords cursorCoords(m_owner->GetGridCursorRow(), - m_owner->GetGridCursorCol()); - const wxRect cursor = - m_owner->BlockToDeviceRect(cursorCoords, cursorCoords); - Refresh(true, &cursor); - } - - if ( !m_owner->GetEventHandler()->ProcessEvent( event ) ) - event.Skip(); -} - -#define internalXToCol(x) XToCol(x, true) -#define internalYToRow(y) YToRow(y, true) - -///////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow ) - EVT_PAINT( wxGrid::OnPaint ) - EVT_SIZE( wxGrid::OnSize ) - EVT_KEY_DOWN( wxGrid::OnKeyDown ) - EVT_KEY_UP( wxGrid::OnKeyUp ) - EVT_CHAR ( wxGrid::OnChar ) - EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground ) - EVT_COMMAND(wxID_ANY, wxEVT_GRID_HIDE_EDITOR, wxGrid::OnHideEditor ) -END_EVENT_TABLE() - -bool wxGrid::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name) -{ - if (!wxScrolledWindow::Create(parent, id, pos, size, - style | wxWANTS_CHARS, name)) - return false; - - m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE); - m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE); - - Create(); - SetInitialSize(size); - CalcDimensions(); - - return true; -} - -wxGrid::~wxGrid() -{ - if ( m_winCapture ) - m_winCapture->ReleaseMouse(); - - // Ensure that the editor control is destroyed before the grid is, - // otherwise we crash later when the editor tries to do something with the - // half destroyed grid - HideCellEditControl(); - - // Must do this or ~wxScrollHelper will pop the wrong event handler - SetTargetWindow(this); - ClearAttrCache(); - wxSafeDecRef(m_defaultCellAttr); - -#ifdef DEBUG_ATTR_CACHE - size_t total = gs_nAttrCacheHits + gs_nAttrCacheMisses; - wxPrintf(wxT("wxGrid attribute cache statistics: " - "total: %u, hits: %u (%u%%)\n"), - total, gs_nAttrCacheHits, - total ? (gs_nAttrCacheHits*100) / total : 0); -#endif - - // if we own the table, just delete it, otherwise at least don't leave it - // with dangling view pointer - if ( m_ownTable ) - delete m_table; - else if ( m_table && m_table->GetView() == this ) - m_table->SetView(NULL); - - delete m_typeRegistry; - delete m_selection; - - delete m_setFixedRows; - delete m_setFixedCols; -} - -// -// ----- internal init and update functions -// - -// NOTE: If using the default visual attributes works everywhere then this can -// be removed as well as the #else cases below. -#define _USE_VISATTR 0 - -void wxGrid::Create() -{ - // create the type registry - m_typeRegistry = new wxGridTypeRegistry; - - m_cellEditCtrlEnabled = false; - - m_defaultCellAttr = new wxGridCellAttr(); - - // Set default cell attributes - m_defaultCellAttr->SetDefAttr(m_defaultCellAttr); - m_defaultCellAttr->SetKind(wxGridCellAttr::Default); - m_defaultCellAttr->SetFont(GetFont()); - m_defaultCellAttr->SetAlignment(wxALIGN_LEFT, wxALIGN_TOP); - m_defaultCellAttr->SetRenderer(new wxGridCellStringRenderer); - m_defaultCellAttr->SetEditor(new wxGridCellTextEditor); - -#if _USE_VISATTR - wxVisualAttributes gva = wxListBox::GetClassDefaultAttributes(); - wxVisualAttributes lva = wxPanel::GetClassDefaultAttributes(); - - m_defaultCellAttr->SetTextColour(gva.colFg); - m_defaultCellAttr->SetBackgroundColour(gva.colBg); - -#else - m_defaultCellAttr->SetTextColour( - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - m_defaultCellAttr->SetBackgroundColour( - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -#endif - - m_numRows = 0; - m_numCols = 0; - m_currentCellCoords = wxGridNoCellCoords; - - // subwindow components that make up the wxGrid - m_rowLabelWin = new wxGridRowLabelWindow(this); - CreateColumnWindow(); - m_cornerLabelWin = new wxGridCornerLabelWindow(this); - m_gridWin = new wxGridWindow( this ); - - SetTargetWindow( m_gridWin ); - -#if _USE_VISATTR - wxColour gfg = gva.colFg; - wxColour gbg = gva.colBg; - wxColour lfg = lva.colFg; - wxColour lbg = lva.colBg; -#else - wxColour gfg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); - wxColour gbg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); - wxColour lfg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); - wxColour lbg = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ); -#endif - - m_cornerLabelWin->SetOwnForegroundColour(lfg); - m_cornerLabelWin->SetOwnBackgroundColour(lbg); - m_rowLabelWin->SetOwnForegroundColour(lfg); - m_rowLabelWin->SetOwnBackgroundColour(lbg); - m_colWindow->SetOwnForegroundColour(lfg); - m_colWindow->SetOwnBackgroundColour(lbg); - - m_gridWin->SetOwnForegroundColour(gfg); - m_gridWin->SetOwnBackgroundColour(gbg); - - m_labelBackgroundColour = m_rowLabelWin->GetBackgroundColour(); - m_labelTextColour = m_rowLabelWin->GetForegroundColour(); - - // now that we have the grid window, use its font to compute the default - // row height - m_defaultRowHeight = m_gridWin->GetCharHeight(); -#if defined(__WXMOTIF__) || defined(__WXGTK__) // see also text ctrl sizing in ShowCellEditControl() - m_defaultRowHeight += 8; -#else - m_defaultRowHeight += 4; -#endif - -} - -void wxGrid::CreateColumnWindow() -{ - if ( m_useNativeHeader ) - { - m_colWindow = new wxGridHeaderCtrl(this); - m_colLabelHeight = m_colWindow->GetBestSize().y; - } - else // draw labels ourselves - { - m_colWindow = new wxGridColLabelWindow(this); - m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT; - } -} - -bool wxGrid::CreateGrid( int numRows, int numCols, - wxGridSelectionModes selmode ) -{ - wxCHECK_MSG( !m_created, - false, - wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") ); - - return SetTable(new wxGridStringTable(numRows, numCols), true, selmode); -} - -void wxGrid::SetSelectionMode(wxGridSelectionModes selmode) -{ - wxCHECK_RET( m_created, - wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") ); - - m_selection->SetSelectionMode( selmode ); -} - -wxGrid::wxGridSelectionModes wxGrid::GetSelectionMode() const -{ - wxCHECK_MSG( m_created, wxGridSelectCells, - wxT("Called wxGrid::GetSelectionMode() before calling CreateGrid()") ); - - return m_selection->GetSelectionMode(); -} - -bool -wxGrid::SetTable(wxGridTableBase *table, - bool takeOwnership, - wxGrid::wxGridSelectionModes selmode ) -{ - bool checkSelection = false; - if ( m_created ) - { - // stop all processing - m_created = false; - - if (m_table) - { - m_table->SetView(0); - if( m_ownTable ) - delete m_table; - m_table = NULL; - } - - wxDELETE(m_selection); - - m_ownTable = false; - m_numRows = 0; - m_numCols = 0; - checkSelection = true; - - // kill row and column size arrays - m_colWidths.Empty(); - m_colRights.Empty(); - m_rowHeights.Empty(); - m_rowBottoms.Empty(); - } - - if (table) - { - m_numRows = table->GetNumberRows(); - m_numCols = table->GetNumberCols(); - - m_table = table; - m_table->SetView( this ); - m_ownTable = takeOwnership; - - // Notice that this must be called after setting m_table as it uses it - // indirectly, via wxGrid::GetColLabelValue(). - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - - m_selection = new wxGridSelection( this, selmode ); - if (checkSelection) - { - // If the newly set table is smaller than the - // original one current cell and selection regions - // might be invalid, - m_selectedBlockCorner = wxGridNoCellCoords; - m_currentCellCoords = - wxGridCellCoords(wxMin(m_numRows, m_currentCellCoords.GetRow()), - wxMin(m_numCols, m_currentCellCoords.GetCol())); - if (m_selectedBlockTopLeft.GetRow() >= m_numRows || - m_selectedBlockTopLeft.GetCol() >= m_numCols) - { - m_selectedBlockTopLeft = wxGridNoCellCoords; - m_selectedBlockBottomRight = wxGridNoCellCoords; - } - else - m_selectedBlockBottomRight = - wxGridCellCoords(wxMin(m_numRows, - m_selectedBlockBottomRight.GetRow()), - wxMin(m_numCols, - m_selectedBlockBottomRight.GetCol())); - } - CalcDimensions(); - - m_created = true; - } - - InvalidateBestSize(); - - return m_created; -} - -void wxGrid::Init() -{ - m_created = false; - - m_cornerLabelWin = NULL; - m_rowLabelWin = NULL; - m_colWindow = NULL; - m_gridWin = NULL; - - m_table = NULL; - m_ownTable = false; - - m_selection = NULL; - m_defaultCellAttr = NULL; - m_typeRegistry = NULL; - m_winCapture = NULL; - - m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH; - m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT; - - m_setFixedRows = - m_setFixedCols = NULL; - - // init attr cache - m_attrCache.row = -1; - m_attrCache.col = -1; - m_attrCache.attr = NULL; - - m_labelFont = GetFont(); - m_labelFont.SetWeight( wxBOLD ); - - m_rowLabelHorizAlign = wxALIGN_CENTRE; - m_rowLabelVertAlign = wxALIGN_CENTRE; - - m_colLabelHorizAlign = wxALIGN_CENTRE; - m_colLabelVertAlign = wxALIGN_CENTRE; - m_colLabelTextOrientation = wxHORIZONTAL; - - m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH; - m_defaultRowHeight = 0; // this will be initialized after creation - - m_minAcceptableColWidth = WXGRID_MIN_COL_WIDTH; - m_minAcceptableRowHeight = WXGRID_MIN_ROW_HEIGHT; - - m_gridLineColour = wxColour( 192,192,192 ); - m_gridLinesEnabled = true; - m_gridLinesClipHorz = - m_gridLinesClipVert = true; - m_cellHighlightColour = *wxBLACK; - m_cellHighlightPenWidth = 2; - m_cellHighlightROPenWidth = 1; - - m_canDragColMove = false; - - m_cursorMode = WXGRID_CURSOR_SELECT_CELL; - m_winCapture = NULL; - m_canDragRowSize = true; - m_canDragColSize = true; - m_canDragGridSize = true; - m_canDragCell = false; - m_dragLastPos = -1; - m_dragRowOrCol = -1; - m_isDragging = false; - m_startDragPos = wxDefaultPosition; - - m_sortCol = wxNOT_FOUND; - m_sortIsAscending = true; - - m_useNativeHeader = - m_nativeColumnLabels = false; - - m_waitForSlowClick = false; - - m_rowResizeCursor = wxCursor( wxCURSOR_SIZENS ); - m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE ); - - m_currentCellCoords = wxGridNoCellCoords; - - m_selectedBlockTopLeft = - m_selectedBlockBottomRight = - m_selectedBlockCorner = wxGridNoCellCoords; - - m_selectionBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_selectionForeground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - - m_editable = true; // default for whole grid - - m_inOnKeyDown = false; - m_batchCount = 0; - - m_extraWidth = - m_extraHeight = 0; - - // we can't call SetScrollRate() as the window isn't created yet but OTOH - // we don't need to call it neither as the scroll position is (0, 0) right - // now anyhow, so just set the parameters directly - m_xScrollPixelsPerLine = GRID_SCROLL_LINE_X; - m_yScrollPixelsPerLine = GRID_SCROLL_LINE_Y; - - m_tabBehaviour = Tab_Stop; -} - -// ---------------------------------------------------------------------------- -// the idea is to call these functions only when necessary because they create -// quite big arrays which eat memory mostly unnecessary - in particular, if -// default widths/heights are used for all rows/columns, we may not use these -// arrays at all -// -// with some extra code, it should be possible to only store the widths/heights -// different from default ones (resulting in space savings for huge grids) but -// this is not done currently -// ---------------------------------------------------------------------------- - -void wxGrid::InitRowHeights() -{ - m_rowHeights.Empty(); - m_rowBottoms.Empty(); - - m_rowHeights.Alloc( m_numRows ); - m_rowBottoms.Alloc( m_numRows ); - - m_rowHeights.Add( m_defaultRowHeight, m_numRows ); - - int rowBottom = 0; - for ( int i = 0; i < m_numRows; i++ ) - { - rowBottom += m_defaultRowHeight; - m_rowBottoms.Add( rowBottom ); - } -} - -void wxGrid::InitColWidths() -{ - m_colWidths.Empty(); - m_colRights.Empty(); - - m_colWidths.Alloc( m_numCols ); - m_colRights.Alloc( m_numCols ); - - m_colWidths.Add( m_defaultColWidth, m_numCols ); - - for ( int i = 0; i < m_numCols; i++ ) - { - int colRight = ( GetColPos( i ) + 1 ) * m_defaultColWidth; - m_colRights.Add( colRight ); - } -} - -int wxGrid::GetColWidth(int col) const -{ - if ( m_colWidths.IsEmpty() ) - return m_defaultColWidth; - - // a negative width indicates a hidden column - return m_colWidths[col] > 0 ? m_colWidths[col] : 0; -} - -int wxGrid::GetColLeft(int col) const -{ - if ( m_colRights.IsEmpty() ) - return GetColPos( col ) * m_defaultColWidth; - - return m_colRights[col] - GetColWidth(col); -} - -int wxGrid::GetColRight(int col) const -{ - return m_colRights.IsEmpty() ? (GetColPos( col ) + 1) * m_defaultColWidth - : m_colRights[col]; -} - -int wxGrid::GetRowHeight(int row) const -{ - // no custom heights / hidden rows - if ( m_rowHeights.IsEmpty() ) - return m_defaultRowHeight; - - // a negative height indicates a hidden row - return m_rowHeights[row] > 0 ? m_rowHeights[row] : 0; -} - -int wxGrid::GetRowTop(int row) const -{ - if ( m_rowBottoms.IsEmpty() ) - return row * m_defaultRowHeight; - - return m_rowBottoms[row] - GetRowHeight(row); -} - -int wxGrid::GetRowBottom(int row) const -{ - return m_rowBottoms.IsEmpty() ? (row + 1) * m_defaultRowHeight - : m_rowBottoms[row]; -} - -void wxGrid::CalcDimensions() -{ - // compute the size of the scrollable area - int w = m_numCols > 0 ? GetColRight(GetColAt(m_numCols - 1)) : 0; - int h = m_numRows > 0 ? GetRowBottom(m_numRows - 1) : 0; - - w += m_extraWidth; - h += m_extraHeight; - - // take into account editor if shown - if ( IsCellEditControlShown() ) - { - int w2, h2; - int r = m_currentCellCoords.GetRow(); - int c = m_currentCellCoords.GetCol(); - int x = GetColLeft(c); - int y = GetRowTop(r); - - // how big is the editor - wxGridCellAttr* attr = GetCellAttr(r, c); - wxGridCellEditor* editor = attr->GetEditor(this, r, c); - editor->GetControl()->GetSize(&w2, &h2); - w2 += x; - h2 += y; - if ( w2 > w ) - w = w2; - if ( h2 > h ) - h = h2; - editor->DecRef(); - attr->DecRef(); - } - - // preserve (more or less) the previous position - int x, y; - GetViewStart( &x, &y ); - - // ensure the position is valid for the new scroll ranges - if ( x >= w ) - x = wxMax( w - 1, 0 ); - if ( y >= h ) - y = wxMax( h - 1, 0 ); - - // update the virtual size and refresh the scrollbars to reflect it - m_gridWin->SetVirtualSize(w, h); - Scroll(x, y); - AdjustScrollbars(); - - // if our OnSize() hadn't been called (it would if we have scrollbars), we - // still must reposition the children - CalcWindowSizes(); -} - -wxSize wxGrid::GetSizeAvailableForScrollTarget(const wxSize& size) -{ - wxSize sizeGridWin(size); - sizeGridWin.x -= m_rowLabelWidth; - sizeGridWin.y -= m_colLabelHeight; - - return sizeGridWin; -} - -void wxGrid::CalcWindowSizes() -{ - // escape if the window is has not been fully created yet - - if ( m_cornerLabelWin == NULL ) - return; - - int cw, ch; - GetClientSize( &cw, &ch ); - - // the grid may be too small to have enough space for the labels yet, don't - // size the windows to negative sizes in this case - int gw = cw - m_rowLabelWidth; - int gh = ch - m_colLabelHeight; - if (gw < 0) - gw = 0; - if (gh < 0) - gh = 0; - - if ( m_cornerLabelWin && m_cornerLabelWin->IsShown() ) - m_cornerLabelWin->SetSize( 0, 0, m_rowLabelWidth, m_colLabelHeight ); - - if ( m_colWindow && m_colWindow->IsShown() ) - m_colWindow->SetSize( m_rowLabelWidth, 0, gw, m_colLabelHeight ); - - if ( m_rowLabelWin && m_rowLabelWin->IsShown() ) - m_rowLabelWin->SetSize( 0, m_colLabelHeight, m_rowLabelWidth, gh ); - - if ( m_gridWin && m_gridWin->IsShown() ) - m_gridWin->SetSize( m_rowLabelWidth, m_colLabelHeight, gw, gh ); -} - -// this is called when the grid table sends a message -// to indicate that it has been redimensioned -// -bool wxGrid::Redimension( wxGridTableMessage& msg ) -{ - int i; - bool result = false; - - // Clear the attribute cache as the attribute might refer to a different - // cell than stored in the cache after adding/removing rows/columns. - ClearAttrCache(); - - // By the same reasoning, the editor should be dismissed if columns are - // added or removed. And for consistency, it should IMHO always be - // removed, not only if the cell "underneath" it actually changes. - // For now, I intentionally do not save the editor's content as the - // cell it might want to save that stuff to might no longer exist. - HideCellEditControl(); - - switch ( msg.GetId() ) - { - case wxGRIDTABLE_NOTIFY_ROWS_INSERTED: - { - size_t pos = msg.GetCommandInt(); - int numRows = msg.GetCommandInt2(); - - m_numRows += numRows; - - if ( !m_rowHeights.IsEmpty() ) - { - m_rowHeights.Insert( m_defaultRowHeight, pos, numRows ); - m_rowBottoms.Insert( 0, pos, numRows ); - - int bottom = 0; - if ( pos > 0 ) - bottom = m_rowBottoms[pos - 1]; - - for ( i = pos; i < m_numRows; i++ ) - { - bottom += m_rowHeights[i]; - m_rowBottoms[i] = bottom; - } - } - - if ( m_currentCellCoords == wxGridNoCellCoords ) - { - // if we have just inserted cols into an empty grid the current - // cell will be undefined... - // - SetCurrentCell( 0, 0 ); - } - - if ( m_selection ) - m_selection->UpdateRows( pos, numRows ); - wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider(); - if (attrProvider) - attrProvider->UpdateAttrRows( pos, numRows ); - - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_rowLabelWin->Refresh(); - } - } - result = true; - break; - - case wxGRIDTABLE_NOTIFY_ROWS_APPENDED: - { - int numRows = msg.GetCommandInt(); - int oldNumRows = m_numRows; - m_numRows += numRows; - - if ( !m_rowHeights.IsEmpty() ) - { - m_rowHeights.Add( m_defaultRowHeight, numRows ); - m_rowBottoms.Add( 0, numRows ); - - int bottom = 0; - if ( oldNumRows > 0 ) - bottom = m_rowBottoms[oldNumRows - 1]; - - for ( i = oldNumRows; i < m_numRows; i++ ) - { - bottom += m_rowHeights[i]; - m_rowBottoms[i] = bottom; - } - } - - if ( m_currentCellCoords == wxGridNoCellCoords ) - { - // if we have just inserted cols into an empty grid the current - // cell will be undefined... - // - SetCurrentCell( 0, 0 ); - } - - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_rowLabelWin->Refresh(); - } - } - result = true; - break; - - case wxGRIDTABLE_NOTIFY_ROWS_DELETED: - { - size_t pos = msg.GetCommandInt(); - int numRows = msg.GetCommandInt2(); - m_numRows -= numRows; - - if ( !m_rowHeights.IsEmpty() ) - { - m_rowHeights.RemoveAt( pos, numRows ); - m_rowBottoms.RemoveAt( pos, numRows ); - - int h = 0; - for ( i = 0; i < m_numRows; i++ ) - { - h += m_rowHeights[i]; - m_rowBottoms[i] = h; - } - } - - if ( !m_numRows ) - { - m_currentCellCoords = wxGridNoCellCoords; - } - else - { - if ( m_currentCellCoords.GetRow() >= m_numRows ) - m_currentCellCoords.Set( 0, 0 ); - } - - if ( m_selection ) - m_selection->UpdateRows( pos, -((int)numRows) ); - wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider(); - if (attrProvider) - { - attrProvider->UpdateAttrRows( pos, -((int)numRows) ); - -// ifdef'd out following patch from Paul Gammans -#if 0 - // No need to touch column attributes, unless we - // removed _all_ rows, in this case, we remove - // all column attributes. - // I hate to do this here, but the - // needed data is not available inside UpdateAttrRows. - if ( !GetNumberRows() ) - attrProvider->UpdateAttrCols( 0, -GetNumberCols() ); -#endif - } - - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_rowLabelWin->Refresh(); - } - } - result = true; - break; - - case wxGRIDTABLE_NOTIFY_COLS_INSERTED: - { - size_t pos = msg.GetCommandInt(); - int numCols = msg.GetCommandInt2(); - m_numCols += numCols; - - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - - if ( !m_colAt.IsEmpty() ) - { - //Shift the column IDs - for ( i = 0; i < m_numCols - numCols; i++ ) - { - if ( m_colAt[i] >= (int)pos ) - m_colAt[i] += numCols; - } - - m_colAt.Insert( pos, pos, numCols ); - - //Set the new columns' positions - for ( i = pos + 1; i < (int)pos + numCols; i++ ) - { - m_colAt[i] = i; - } - } - - if ( !m_colWidths.IsEmpty() ) - { - m_colWidths.Insert( m_defaultColWidth, pos, numCols ); - m_colRights.Insert( 0, pos, numCols ); - - int right = 0; - if ( pos > 0 ) - right = m_colRights[GetColAt( pos - 1 )]; - - int colPos; - for ( colPos = pos; colPos < m_numCols; colPos++ ) - { - i = GetColAt( colPos ); - - right += m_colWidths[i]; - m_colRights[i] = right; - } - } - - if ( m_currentCellCoords == wxGridNoCellCoords ) - { - // if we have just inserted cols into an empty grid the current - // cell will be undefined... - // - SetCurrentCell( 0, 0 ); - } - - if ( m_selection ) - m_selection->UpdateCols( pos, numCols ); - wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider(); - if (attrProvider) - attrProvider->UpdateAttrCols( pos, numCols ); - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_colWindow->Refresh(); - } - } - result = true; - break; - - case wxGRIDTABLE_NOTIFY_COLS_APPENDED: - { - int numCols = msg.GetCommandInt(); - int oldNumCols = m_numCols; - m_numCols += numCols; - - if ( !m_colAt.IsEmpty() ) - { - m_colAt.Add( 0, numCols ); - - //Set the new columns' positions - for ( i = oldNumCols; i < m_numCols; i++ ) - { - m_colAt[i] = i; - } - } - - if ( !m_colWidths.IsEmpty() ) - { - m_colWidths.Add( m_defaultColWidth, numCols ); - m_colRights.Add( 0, numCols ); - - int right = 0; - if ( oldNumCols > 0 ) - right = m_colRights[GetColAt( oldNumCols - 1 )]; - - int colPos; - for ( colPos = oldNumCols; colPos < m_numCols; colPos++ ) - { - i = GetColAt( colPos ); - - right += m_colWidths[i]; - m_colRights[i] = right; - } - } - - // Notice that this must be called after updating m_colWidths above - // as the native grid control will check whether the new columns - // are shown which results in accessing m_colWidths array. - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - - if ( m_currentCellCoords == wxGridNoCellCoords ) - { - // if we have just inserted cols into an empty grid the current - // cell will be undefined... - // - SetCurrentCell( 0, 0 ); - } - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_colWindow->Refresh(); - } - } - result = true; - break; - - case wxGRIDTABLE_NOTIFY_COLS_DELETED: - { - size_t pos = msg.GetCommandInt(); - int numCols = msg.GetCommandInt2(); - m_numCols -= numCols; - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - - if ( !m_colAt.IsEmpty() ) - { - int colID = GetColAt( pos ); - - m_colAt.RemoveAt( pos, numCols ); - - //Shift the column IDs - int colPos; - for ( colPos = 0; colPos < m_numCols; colPos++ ) - { - if ( m_colAt[colPos] > colID ) - m_colAt[colPos] -= numCols; - } - } - - if ( !m_colWidths.IsEmpty() ) - { - m_colWidths.RemoveAt( pos, numCols ); - m_colRights.RemoveAt( pos, numCols ); - - int w = 0; - int colPos; - for ( colPos = 0; colPos < m_numCols; colPos++ ) - { - i = GetColAt( colPos ); - - w += m_colWidths[i]; - m_colRights[i] = w; - } - } - - if ( !m_numCols ) - { - m_currentCellCoords = wxGridNoCellCoords; - } - else - { - if ( m_currentCellCoords.GetCol() >= m_numCols ) - m_currentCellCoords.Set( 0, 0 ); - } - - if ( m_selection ) - m_selection->UpdateCols( pos, -((int)numCols) ); - wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider(); - if (attrProvider) - { - attrProvider->UpdateAttrCols( pos, -((int)numCols) ); - -// ifdef'd out following patch from Paul Gammans -#if 0 - // No need to touch row attributes, unless we - // removed _all_ columns, in this case, we remove - // all row attributes. - // I hate to do this here, but the - // needed data is not available inside UpdateAttrCols. - if ( !GetNumberCols() ) - attrProvider->UpdateAttrRows( 0, -GetNumberRows() ); -#endif - } - - if ( !GetBatchCount() ) - { - CalcDimensions(); - m_colWindow->Refresh(); - } - } - result = true; - break; - } - - InvalidateBestSize(); - - if (result && !GetBatchCount() ) - m_gridWin->Refresh(); - - return result; -} - -wxArrayInt wxGrid::CalcRowLabelsExposed( const wxRegion& reg ) const -{ - wxRegionIterator iter( reg ); - wxRect r; - - wxArrayInt rowlabels; - - int top, bottom; - while ( iter ) - { - r = iter.GetRect(); - - // TODO: remove this when we can... - // There is a bug in wxMotif that gives garbage update - // rectangles if you jump-scroll a long way by clicking the - // scrollbar with middle button. This is a work-around - // -#if defined(__WXMOTIF__) - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - if ( r.GetTop() > ch ) - r.SetTop( 0 ); - r.SetBottom( wxMin( r.GetBottom(), ch ) ); -#endif - - // logical bounds of update region - // - int dummy; - CalcUnscrolledPosition( 0, r.GetTop(), &dummy, &top ); - CalcUnscrolledPosition( 0, r.GetBottom(), &dummy, &bottom ); - - // find the row labels within these bounds - // - int row; - for ( row = internalYToRow(top); row < m_numRows; row++ ) - { - if ( GetRowBottom(row) < top ) - continue; - - if ( GetRowTop(row) > bottom ) - break; - - rowlabels.Add( row ); - } - - ++iter; - } - - return rowlabels; -} - -wxArrayInt wxGrid::CalcColLabelsExposed( const wxRegion& reg ) const -{ - wxRegionIterator iter( reg ); - wxRect r; - - wxArrayInt colLabels; - - int left, right; - while ( iter ) - { - r = iter.GetRect(); - - // TODO: remove this when we can... - // There is a bug in wxMotif that gives garbage update - // rectangles if you jump-scroll a long way by clicking the - // scrollbar with middle button. This is a work-around - // -#if defined(__WXMOTIF__) - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - if ( r.GetLeft() > cw ) - r.SetLeft( 0 ); - r.SetRight( wxMin( r.GetRight(), cw ) ); -#endif - - // logical bounds of update region - // - int dummy; - CalcUnscrolledPosition( r.GetLeft(), 0, &left, &dummy ); - CalcUnscrolledPosition( r.GetRight(), 0, &right, &dummy ); - - // find the cells within these bounds - // - int col; - int colPos; - for ( colPos = GetColPos( internalXToCol(left) ); colPos < m_numCols; colPos++ ) - { - col = GetColAt( colPos ); - - if ( GetColRight(col) < left ) - continue; - - if ( GetColLeft(col) > right ) - break; - - colLabels.Add( col ); - } - - ++iter; - } - - return colLabels; -} - -wxGridCellCoordsArray wxGrid::CalcCellsExposed( const wxRegion& reg ) const -{ - wxRect r; - - wxGridCellCoordsArray cellsExposed; - - int left, top, right, bottom; - for ( wxRegionIterator iter(reg); iter; ++iter ) - { - r = iter.GetRect(); - - // Skip 0-height cells, they're invisible anyhow, don't waste time - // getting their rectangles and so on. - if ( !r.GetHeight() ) - continue; - - // TODO: remove this when we can... - // There is a bug in wxMotif that gives garbage update - // rectangles if you jump-scroll a long way by clicking the - // scrollbar with middle button. This is a work-around - // -#if defined(__WXMOTIF__) - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - if ( r.GetTop() > ch ) r.SetTop( 0 ); - if ( r.GetLeft() > cw ) r.SetLeft( 0 ); - r.SetRight( wxMin( r.GetRight(), cw ) ); - r.SetBottom( wxMin( r.GetBottom(), ch ) ); -#endif - - // logical bounds of update region - // - CalcUnscrolledPosition( r.GetLeft(), r.GetTop(), &left, &top ); - CalcUnscrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom ); - - // find the cells within these bounds - wxArrayInt cols; - for ( int row = internalYToRow(top); row < m_numRows; row++ ) - { - if ( GetRowBottom(row) <= top ) - continue; - - if ( GetRowTop(row) > bottom ) - break; - - // add all dirty cells in this row: notice that the columns which - // are dirty don't depend on the row so we compute them only once - // for the first dirty row and then reuse for all the next ones - if ( cols.empty() ) - { - // do determine the dirty columns - for ( int pos = XToPos(left); pos <= XToPos(right); pos++ ) - cols.push_back(GetColAt(pos)); - - // if there are no dirty columns at all, nothing to do - if ( cols.empty() ) - break; - } - - const size_t count = cols.size(); - for ( size_t n = 0; n < count; n++ ) - cellsExposed.Add(wxGridCellCoords(row, cols[n])); - } - } - - return cellsExposed; -} - - -void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) -{ - int x, y, row; - wxPoint pos( event.GetPosition() ); - CalcUnscrolledPosition( pos.x, pos.y, &x, &y ); - - if ( event.Dragging() ) - { - if (!m_isDragging) - m_isDragging = true; - - if ( event.LeftIsDown() ) - { - switch ( m_cursorMode ) - { - case WXGRID_CURSOR_RESIZE_ROW: - { - int cw, ch, left, dummy; - m_gridWin->GetClientSize( &cw, &ch ); - CalcUnscrolledPosition( 0, 0, &left, &dummy ); - - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); - y = wxMax( y, - GetRowTop(m_dragRowOrCol) + - GetRowMinimalHeight(m_dragRowOrCol) ); - dc.SetLogicalFunction(wxINVERT); - if ( m_dragLastPos >= 0 ) - { - dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos ); - } - dc.DrawLine( left, y, left+cw, y ); - m_dragLastPos = y; - } - break; - - case WXGRID_CURSOR_SELECT_ROW: - { - if ( (row = YToRow( y )) >= 0 ) - { - if ( m_selection ) - m_selection->SelectRow(row, event); - } - } - break; - - // default label to suppress warnings about "enumeration value - // 'xxx' not handled in switch - default: - break; - } - } - return; - } - - if ( m_isDragging && (event.Entering() || event.Leaving()) ) - return; - - if (m_isDragging) - m_isDragging = false; - - // ------------ Entering or leaving the window - // - if ( event.Entering() || event.Leaving() ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin); - } - - // ------------ Left button pressed - // - else if ( event.LeftDown() ) - { - row = YToEdgeOfRow(y); - if ( row != wxNOT_FOUND && CanDragRowSize(row) ) - { - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin); - } - else // not a request to start resizing - { - row = YToRow(y); - if ( row >= 0 && - !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) ) - { - if ( !event.ShiftDown() && !event.CmdDown() ) - ClearSelection(); - if ( m_selection ) - { - if ( event.ShiftDown() ) - { - m_selection->SelectBlock - ( - m_currentCellCoords.GetRow(), 0, - row, GetNumberCols() - 1, - event - ); - } - else - { - m_selection->SelectRow(row, event); - } - } - - ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin); - } - } - } - - // ------------ Left double click - // - else if (event.LeftDClick() ) - { - row = YToEdgeOfRow(y); - if ( row != wxNOT_FOUND && CanDragRowSize(row) ) - { - // adjust row height depending on label text - // - // TODO: generate RESIZING event, see #10754 - AutoSizeRowLabelSize( row ); - - SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, row, -1, event); - - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow()); - m_dragLastPos = -1; - } - else // not on row separator or it's not resizable - { - row = YToRow(y); - if ( row >=0 && - !SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, row, -1, event ) ) - { - // no default action at the moment - } - } - } - - // ------------ Left button released - // - else if ( event.LeftUp() ) - { - if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW ) - DoEndDragResizeRow(event); - - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin); - m_dragLastPos = -1; - } - - // ------------ Right button down - // - else if ( event.RightDown() ) - { - row = YToRow(y); - if ( row >=0 && - !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) ) - { - // no default action at the moment - } - } - - // ------------ Right double click - // - else if ( event.RightDClick() ) - { - row = YToRow(y); - if ( row >= 0 && - !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, row, -1, event ) ) - { - // no default action at the moment - } - } - - // ------------ No buttons down and mouse moving - // - else if ( event.Moving() ) - { - m_dragRowOrCol = YToEdgeOfRow( y ); - if ( m_dragRowOrCol != wxNOT_FOUND ) - { - if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) - { - if ( CanDragRowSize(m_dragRowOrCol) ) - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin, false); - } - } - else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin, false); - } - } -} - -void wxGrid::UpdateColumnSortingIndicator(int col) -{ - wxCHECK_RET( col != wxNOT_FOUND, "invalid column index" ); - - if ( m_useNativeHeader ) - GetGridColHeader()->UpdateColumn(col); - else if ( m_nativeColumnLabels ) - m_colWindow->Refresh(); - //else: sorting indicator display not yet implemented in grid version -} - -void wxGrid::SetSortingColumn(int col, bool ascending) -{ - if ( col == m_sortCol ) - { - // we are already using this column for sorting (or not sorting at all) - // but we might still change the sorting order, check for it - if ( m_sortCol != wxNOT_FOUND && ascending != m_sortIsAscending ) - { - m_sortIsAscending = ascending; - - UpdateColumnSortingIndicator(m_sortCol); - } - } - else // we're changing the column used for sorting - { - const int sortColOld = m_sortCol; - - // change it before updating the column as we want GetSortingColumn() - // to return the correct new value - m_sortCol = col; - - if ( sortColOld != wxNOT_FOUND ) - UpdateColumnSortingIndicator(sortColOld); - - if ( m_sortCol != wxNOT_FOUND ) - { - m_sortIsAscending = ascending; - UpdateColumnSortingIndicator(m_sortCol); - } - } -} - -void wxGrid::DoColHeaderClick(int col) -{ - // we consider that the grid was resorted if this event is processed and - // not vetoed - if ( SendEvent(wxEVT_GRID_COL_SORT, -1, col) == 1 ) - { - SetSortingColumn(col, IsSortingBy(col) ? !m_sortIsAscending : true); - Refresh(); - } -} - -void wxGrid::DoStartResizeCol(int col) -{ - m_dragRowOrCol = col; - m_dragLastPos = -1; - DoUpdateResizeColWidth(GetColWidth(m_dragRowOrCol)); -} - -void wxGrid::DoUpdateResizeCol(int x) -{ - int cw, ch, dummy, top; - m_gridWin->GetClientSize( &cw, &ch ); - CalcUnscrolledPosition( 0, 0, &dummy, &top ); - - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); - - x = wxMax( x, GetColLeft(m_dragRowOrCol) + GetColMinimalWidth(m_dragRowOrCol)); - dc.SetLogicalFunction(wxINVERT); - if ( m_dragLastPos >= 0 ) - { - dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top + ch ); - } - dc.DrawLine( x, top, x, top + ch ); - m_dragLastPos = x; -} - -void wxGrid::DoUpdateResizeColWidth(int w) -{ - DoUpdateResizeCol(GetColLeft(m_dragRowOrCol) + w); -} - -void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) -{ - int x; - CalcUnscrolledPosition( event.GetPosition().x, 0, &x, NULL ); - - int col = XToCol(x); - if ( event.Dragging() ) - { - if (!m_isDragging) - { - m_isDragging = true; - - if ( m_cursorMode == WXGRID_CURSOR_MOVE_COL && col != -1 ) - DoStartMoveCol(col); - } - - if ( event.LeftIsDown() ) - { - switch ( m_cursorMode ) - { - case WXGRID_CURSOR_RESIZE_COL: - DoUpdateResizeCol(x); - break; - - case WXGRID_CURSOR_SELECT_COL: - { - if ( col != -1 ) - { - if ( m_selection ) - m_selection->SelectCol(col, event); - } - } - break; - - case WXGRID_CURSOR_MOVE_COL: - { - int posNew = XToPos(x); - int colNew = GetColAt(posNew); - - // determine the position of the drop marker - int markerX; - if ( x >= GetColLeft(colNew) + (GetColWidth(colNew) / 2) ) - markerX = GetColRight(colNew); - else - markerX = GetColLeft(colNew); - - if ( markerX != m_dragLastPos ) - { - wxClientDC dc( GetColLabelWindow() ); - DoPrepareDC(dc); - - int cw, ch; - GetColLabelWindow()->GetClientSize( &cw, &ch ); - - markerX++; - - //Clean up the last indicator - if ( m_dragLastPos >= 0 ) - { - wxPen pen( GetColLabelWindow()->GetBackgroundColour(), 2 ); - dc.SetPen(pen); - dc.DrawLine( m_dragLastPos + 1, 0, m_dragLastPos + 1, ch ); - dc.SetPen(wxNullPen); - - if ( XToCol( m_dragLastPos ) != -1 ) - DrawColLabel( dc, XToCol( m_dragLastPos ) ); - } - - const wxColour *color; - //Moving to the same place? Don't draw a marker - if ( colNew == m_dragRowOrCol ) - color = wxLIGHT_GREY; - else - color = wxBLUE; - - //Draw the marker - wxPen pen( *color, 2 ); - dc.SetPen(pen); - - dc.DrawLine( markerX, 0, markerX, ch ); - - dc.SetPen(wxNullPen); - - m_dragLastPos = markerX - 1; - } - } - break; - - // default label to suppress warnings about "enumeration value - // 'xxx' not handled in switch - default: - break; - } - } - return; - } - - if ( m_isDragging && (event.Entering() || event.Leaving()) ) - return; - - if (m_isDragging) - m_isDragging = false; - - // ------------ Entering or leaving the window - // - if ( event.Entering() || event.Leaving() ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow()); - } - - // ------------ Left button pressed - // - else if ( event.LeftDown() ) - { - int colEdge = XToEdgeOfCol(x); - if ( colEdge != wxNOT_FOUND && CanDragColSize(colEdge) ) - { - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, GetColLabelWindow()); - } - else // not a request to start resizing - { - if ( col >= 0 && - !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) ) - { - if ( m_canDragColMove ) - { - //Show button as pressed - wxClientDC dc( GetColLabelWindow() ); - int colLeft = GetColLeft( col ); - int colRight = GetColRight( col ) - 1; - dc.SetPen( wxPen( GetColLabelWindow()->GetBackgroundColour(), 1 ) ); - dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 ); - dc.DrawLine( colLeft, 1, colRight, 1 ); - - ChangeCursorMode(WXGRID_CURSOR_MOVE_COL, GetColLabelWindow()); - } - else - { - if ( !event.ShiftDown() && !event.CmdDown() ) - ClearSelection(); - if ( m_selection ) - { - if ( event.ShiftDown() ) - { - m_selection->SelectBlock - ( - 0, m_currentCellCoords.GetCol(), - GetNumberRows() - 1, col, - event - ); - } - else - { - m_selection->SelectCol(col, event); - } - } - - ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, GetColLabelWindow()); - } - } - } - } - - // ------------ Left double click - // - if ( event.LeftDClick() ) - { - const int colEdge = XToEdgeOfCol(x); - if ( colEdge == -1 ) - { - if ( col >= 0 && - ! SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, col, event ) ) - { - // no default action at the moment - } - } - else - { - // adjust column width depending on label text - // - // TODO: generate RESIZING event, see #10754 - if ( !SendGridSizeEvent(wxEVT_GRID_COL_AUTO_SIZE, -1, colEdge, event) ) - AutoSizeColLabelSize( colEdge ); - - SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, colEdge, event); - - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow()); - m_dragLastPos = -1; - } - } - - // ------------ Left button released - // - else if ( event.LeftUp() ) - { - switch ( m_cursorMode ) - { - case WXGRID_CURSOR_RESIZE_COL: - DoEndDragResizeCol(event); - break; - - case WXGRID_CURSOR_MOVE_COL: - if ( m_dragLastPos == -1 || col == m_dragRowOrCol ) - { - // the column didn't actually move anywhere - if ( col != -1 ) - DoColHeaderClick(col); - m_colWindow->Refresh(); // "unpress" the column - } - else - { - // get the position of the column we're over - int pos = XToPos(x); - - // insert the column being dragged either before or after - // it, depending on where exactly it was dropped, so - // find the index of the column we're over: notice - // that the existing "col" variable may be invalid but - // we need a valid one here - const int colValid = GetColAt(pos); - - // and check if we're on the "near" (usually left but right - // in RTL case) part of the column - const int middle = GetColLeft(colValid) + - GetColWidth(colValid)/2; - const bool onNearPart = (x <= middle); - - // adjust for the column being dragged itself - if ( pos < GetColPos(m_dragRowOrCol) ) - pos++; - - // and if it's on the near part of the target column, - // insert it before it, not after - if ( onNearPart ) - pos--; - - DoEndMoveCol(pos); - } - break; - - case WXGRID_CURSOR_SELECT_COL: - case WXGRID_CURSOR_SELECT_CELL: - case WXGRID_CURSOR_RESIZE_ROW: - case WXGRID_CURSOR_SELECT_ROW: - if ( col != -1 ) - DoColHeaderClick(col); - break; - } - - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow()); - m_dragLastPos = -1; - } - - // ------------ Right button down - // - else if ( event.RightDown() ) - { - if ( col >= 0 && - !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, col, event ) ) - { - // no default action at the moment - } - } - - // ------------ Right double click - // - else if ( event.RightDClick() ) - { - if ( col >= 0 && - !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, col, event ) ) - { - // no default action at the moment - } - } - - // ------------ No buttons down and mouse moving - // - else if ( event.Moving() ) - { - m_dragRowOrCol = XToEdgeOfCol( x ); - if ( m_dragRowOrCol >= 0 ) - { - if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) - { - if ( CanDragColSize(m_dragRowOrCol) ) - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, GetColLabelWindow(), false); - } - } - else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow(), false); - } - } -} - -void wxGrid::ProcessCornerLabelMouseEvent( wxMouseEvent& event ) -{ - if ( event.LeftDown() ) - { - // indicate corner label by having both row and - // col args == -1 - // - if ( !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, event ) ) - { - SelectAll(); - } - } - else if ( event.LeftDClick() ) - { - SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, event ); - } - else if ( event.RightDown() ) - { - if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, event ) ) - { - // no default action at the moment - } - } - else if ( event.RightDClick() ) - { - if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, event ) ) - { - // no default action at the moment - } - } -} - -void wxGrid::CancelMouseCapture() -{ - // cancel operation currently in progress, whatever it is - if ( m_winCapture ) - { - m_isDragging = false; - m_startDragPos = wxDefaultPosition; - - m_cursorMode = WXGRID_CURSOR_SELECT_CELL; - m_winCapture->SetCursor( *wxSTANDARD_CURSOR ); - m_winCapture = NULL; - - // remove traces of whatever we drew on screen - Refresh(); - } -} - -void wxGrid::ChangeCursorMode(CursorMode mode, - wxWindow *win, - bool captureMouse) -{ -#if wxUSE_LOG_TRACE - static const wxChar *const cursorModes[] = - { - wxT("SELECT_CELL"), - wxT("RESIZE_ROW"), - wxT("RESIZE_COL"), - wxT("SELECT_ROW"), - wxT("SELECT_COL"), - wxT("MOVE_COL"), - }; - - wxLogTrace(wxT("grid"), - wxT("wxGrid cursor mode (mouse capture for %s): %s -> %s"), - win == m_colWindow ? wxT("colLabelWin") - : win ? wxT("rowLabelWin") - : wxT("gridWin"), - cursorModes[m_cursorMode], cursorModes[mode]); -#endif // wxUSE_LOG_TRACE - - if ( mode == m_cursorMode && - win == m_winCapture && - captureMouse == (m_winCapture != NULL)) - return; - - if ( !win ) - { - // by default use the grid itself - win = m_gridWin; - } - - if ( m_winCapture ) - { - m_winCapture->ReleaseMouse(); - m_winCapture = NULL; - } - - m_cursorMode = mode; - - switch ( m_cursorMode ) - { - case WXGRID_CURSOR_RESIZE_ROW: - win->SetCursor( m_rowResizeCursor ); - break; - - case WXGRID_CURSOR_RESIZE_COL: - win->SetCursor( m_colResizeCursor ); - break; - - case WXGRID_CURSOR_MOVE_COL: - win->SetCursor( wxCursor(wxCURSOR_HAND) ); - break; - - default: - win->SetCursor( *wxSTANDARD_CURSOR ); - break; - } - - // we need to capture mouse when resizing - bool resize = m_cursorMode == WXGRID_CURSOR_RESIZE_ROW || - m_cursorMode == WXGRID_CURSOR_RESIZE_COL; - - if ( captureMouse && resize ) - { - win->CaptureMouse(); - m_winCapture = win; - } -} - -// ---------------------------------------------------------------------------- -// grid mouse event processing -// ---------------------------------------------------------------------------- - -bool -wxGrid::DoGridCellDrag(wxMouseEvent& event, - const wxGridCellCoords& coords, - bool isFirstDrag) -{ - bool performDefault = true ; - - if ( coords == wxGridNoCellCoords ) - return performDefault; // we're outside any valid cell - - // Hide the edit control, so it won't interfere with drag-shrinking. - if ( IsCellEditControlShown() ) - { - HideCellEditControl(); - SaveEditControlValue(); - } - - switch ( event.GetModifiers() ) - { - case wxMOD_CONTROL: - if ( m_selectedBlockCorner == wxGridNoCellCoords) - m_selectedBlockCorner = coords; - UpdateBlockBeingSelected(m_selectedBlockCorner, coords); - break; - - case wxMOD_NONE: - if ( CanDragCell() ) - { - if ( isFirstDrag ) - { - if ( m_selectedBlockCorner == wxGridNoCellCoords) - m_selectedBlockCorner = coords; - - // if event is handled by user code, no further processing - if ( SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) != 0 ) - performDefault = false; - - return performDefault; - } - } - - UpdateBlockBeingSelected(m_currentCellCoords, coords); - break; - - default: - // we don't handle the other key modifiers - event.Skip(); - } - - return performDefault; -} - -void wxGrid::DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper) -{ - wxClientDC dc(m_gridWin); - PrepareDC(dc); - dc.SetLogicalFunction(wxINVERT); - - const wxRect rectWin(CalcUnscrolledPosition(wxPoint(0, 0)), - m_gridWin->GetClientSize()); - - // erase the previously drawn line, if any - if ( m_dragLastPos >= 0 ) - oper.DrawParallelLineInRect(dc, rectWin, m_dragLastPos); - - // we need the vertical position for rows and horizontal for columns here - m_dragLastPos = oper.Dual().Select(CalcUnscrolledPosition(event.GetPosition())); - - // don't allow resizing beneath the minimal size - const int posMin = oper.GetLineStartPos(this, m_dragRowOrCol) + - oper.GetMinimalLineSize(this, m_dragRowOrCol); - if ( m_dragLastPos < posMin ) - m_dragLastPos = posMin; - - // and draw it at the new position - oper.DrawParallelLineInRect(dc, rectWin, m_dragLastPos); -} - -void wxGrid::DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords) -{ - if ( !m_isDragging ) - { - // Don't start doing anything until the mouse has been dragged far - // enough - const wxPoint& pt = event.GetPosition(); - if ( m_startDragPos == wxDefaultPosition ) - { - m_startDragPos = pt; - return; - } - - if ( abs(m_startDragPos.x - pt.x) <= DRAG_SENSITIVITY && - abs(m_startDragPos.y - pt.y) <= DRAG_SENSITIVITY ) - return; - } - - const bool isFirstDrag = !m_isDragging; - m_isDragging = true; - - switch ( m_cursorMode ) - { - case WXGRID_CURSOR_SELECT_CELL: - // no further handling if handled by user - if ( DoGridCellDrag(event, coords, isFirstDrag) == false ) - return; - break; - - case WXGRID_CURSOR_RESIZE_ROW: - DoGridLineDrag(event, wxGridRowOperations()); - break; - - case WXGRID_CURSOR_RESIZE_COL: - DoGridLineDrag(event, wxGridColumnOperations()); - break; - - default: - event.Skip(); - } - - if ( isFirstDrag ) - { - wxASSERT_MSG( !m_winCapture, "shouldn't capture the mouse twice" ); - - m_winCapture = m_gridWin; - m_winCapture->CaptureMouse(); - } -} - -void -wxGrid::DoGridCellLeftDown(wxMouseEvent& event, - const wxGridCellCoords& coords, - const wxPoint& pos) -{ - if ( SendEvent(wxEVT_GRID_CELL_LEFT_CLICK, coords, event) ) - { - // event handled by user code, no need to do anything here - return; - } - - if ( !event.CmdDown() ) - ClearSelection(); - - if ( event.ShiftDown() ) - { - if ( m_selection ) - { - m_selection->SelectBlock(m_currentCellCoords, coords, event); - m_selectedBlockCorner = coords; - } - } - else if ( XToEdgeOfCol(pos.x) < 0 && YToEdgeOfRow(pos.y) < 0 ) - { - DisableCellEditControl(); - MakeCellVisible( coords ); - - if ( event.CmdDown() ) - { - if ( m_selection ) - { - m_selection->ToggleCellSelection(coords, event); - } - - m_selectedBlockTopLeft = wxGridNoCellCoords; - m_selectedBlockBottomRight = wxGridNoCellCoords; - m_selectedBlockCorner = coords; - } - else - { - if ( m_selection ) - { - // In row or column selection mode just clicking on the cell - // should select the row or column containing it: this is more - // convenient for the kinds of controls that use such selection - // mode and is compatible with 2.8 behaviour (see #12062). - switch ( m_selection->GetSelectionMode() ) - { - case wxGridSelectCells: - case wxGridSelectRowsOrColumns: - // nothing to do in these cases - break; - - case wxGridSelectRows: - m_selection->SelectRow(coords.GetRow()); - break; - - case wxGridSelectColumns: - m_selection->SelectCol(coords.GetCol()); - break; - } - } - - m_waitForSlowClick = m_currentCellCoords == coords && - coords != wxGridNoCellCoords; - SetCurrentCell( coords ); - } - } -} - -void -wxGrid::DoGridCellLeftDClick(wxMouseEvent& event, - const wxGridCellCoords& coords, - const wxPoint& pos) -{ - if ( XToEdgeOfCol(pos.x) < 0 && YToEdgeOfRow(pos.y) < 0 ) - { - if ( !SendEvent(wxEVT_GRID_CELL_LEFT_DCLICK, coords, event) ) - { - // we want double click to select a cell and start editing - // (i.e. to behave in same way as sequence of two slow clicks): - m_waitForSlowClick = true; - } - } -} - -void -wxGrid::DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords) -{ - if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) - { - if (m_winCapture) - { - m_winCapture->ReleaseMouse(); - m_winCapture = NULL; - } - - if ( coords == m_currentCellCoords && m_waitForSlowClick && CanEnableCellControl() ) - { - ClearSelection(); - EnableCellEditControl(); - - wxGridCellAttr *attr = GetCellAttr(coords); - wxGridCellEditor *editor = attr->GetEditor(this, coords.GetRow(), coords.GetCol()); - editor->StartingClick(); - editor->DecRef(); - attr->DecRef(); - - m_waitForSlowClick = false; - } - else if ( m_selectedBlockTopLeft != wxGridNoCellCoords && - m_selectedBlockBottomRight != wxGridNoCellCoords ) - { - if ( m_selection ) - { - m_selection->SelectBlock( m_selectedBlockTopLeft, - m_selectedBlockBottomRight, - event ); - } - - m_selectedBlockTopLeft = wxGridNoCellCoords; - m_selectedBlockBottomRight = wxGridNoCellCoords; - - // Show the edit control, if it has been hidden for - // drag-shrinking. - ShowCellEditControl(); - } - } - else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); - DoEndDragResizeRow(event); - } - else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); - DoEndDragResizeCol(event); - } - - m_dragLastPos = -1; -} - -void -wxGrid::DoGridMouseMoveEvent(wxMouseEvent& WXUNUSED(event), - const wxGridCellCoords& coords, - const wxPoint& pos) -{ - if ( coords.GetRow() < 0 || coords.GetCol() < 0 ) - { - // out of grid cell area - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); - return; - } - - int dragRow = YToEdgeOfRow( pos.y ); - int dragCol = XToEdgeOfCol( pos.x ); - - // Dragging on the corner of a cell to resize in both - // directions is not implemented yet... - // - if ( dragRow >= 0 && dragCol >= 0 ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); - return; - } - - if ( dragRow >= 0 && CanDragGridSize() && CanDragRowSize(dragRow) ) - { - if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) - { - m_dragRowOrCol = dragRow; - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, NULL, false); - } - } - // When using the native header window we can only resize the columns by - // dragging the dividers in it because we can't make it enter into the - // column resizing mode programmatically - else if ( dragCol >= 0 && !m_useNativeHeader && - CanDragGridSize() && CanDragColSize(dragCol) ) - { - if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) - { - m_dragRowOrCol = dragCol; - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, NULL, false); - } - } - else // Neither on a row or col edge - { - if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL ) - { - ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); - } - } -} - -void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event) -{ - if ( event.Entering() || event.Leaving() ) - { - // we don't care about these events but we must not reset m_isDragging - // if they happen so return before anything else is done - event.Skip(); - return; - } - - const wxPoint pos = CalcUnscrolledPosition(event.GetPosition()); - - // coordinates of the cell under mouse - wxGridCellCoords coords = XYToCell(pos); - - int cell_rows, cell_cols; - GetCellSize( coords.GetRow(), coords.GetCol(), &cell_rows, &cell_cols ); - if ( (cell_rows < 0) || (cell_cols < 0) ) - { - coords.SetRow(coords.GetRow() + cell_rows); - coords.SetCol(coords.GetCol() + cell_cols); - } - - if ( event.Dragging() ) - { - if ( event.LeftIsDown() ) - DoGridDragEvent(event, coords); - else - event.Skip(); - return; - } - - m_isDragging = false; - m_startDragPos = wxDefaultPosition; - - // deal with various button presses - if ( event.IsButton() ) - { - if ( coords != wxGridNoCellCoords ) - { - DisableCellEditControl(); - - if ( event.LeftDown() ) - DoGridCellLeftDown(event, coords, pos); - else if ( event.LeftDClick() ) - DoGridCellLeftDClick(event, coords, pos); - else if ( event.RightDown() ) - SendEvent(wxEVT_GRID_CELL_RIGHT_CLICK, coords, event); - else if ( event.RightDClick() ) - SendEvent(wxEVT_GRID_CELL_RIGHT_DCLICK, coords, event); - } - - // this one should be called even if we're not over any cell - if ( event.LeftUp() ) - { - DoGridCellLeftUp(event, coords); - } - } - else if ( event.Moving() ) - { - DoGridMouseMoveEvent(event, coords, pos); - } - else // unknown mouse event? - { - event.Skip(); - } -} - -// this function returns true only if the size really changed -bool wxGrid::DoEndDragResizeLine(const wxGridOperations& oper) -{ - if ( m_dragLastPos == -1 ) - return false; - - const wxGridOperations& doper = oper.Dual(); - - const wxSize size = m_gridWin->GetClientSize(); - - const wxPoint ptOrigin = CalcUnscrolledPosition(wxPoint(0, 0)); - - // erase the last line we drew - wxClientDC dc(m_gridWin); - PrepareDC(dc); - dc.SetLogicalFunction(wxINVERT); - - const int posLineStart = oper.Select(ptOrigin); - const int posLineEnd = oper.Select(ptOrigin) + oper.Select(size); - - oper.DrawParallelLine(dc, posLineStart, posLineEnd, m_dragLastPos); - - // temporarily hide the edit control before resizing - HideCellEditControl(); - SaveEditControlValue(); - - // do resize the line - const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol); - const int lineSizeOld = oper.GetLineSize(this, m_dragRowOrCol); - oper.SetLineSize(this, m_dragRowOrCol, - wxMax(m_dragLastPos - lineStart, - oper.GetMinimalLineSize(this, m_dragRowOrCol))); - const bool - sizeChanged = oper.GetLineSize(this, m_dragRowOrCol) != lineSizeOld; - - m_dragLastPos = -1; - - // refresh now if we're not frozen - if ( !GetBatchCount() ) - { - // we need to refresh everything beyond the resized line in the header - // window - - // get the position from which to refresh in the other direction - wxRect rect(CellToRect(oper.MakeCoords(m_dragRowOrCol, 0))); - rect.SetPosition(CalcScrolledPosition(rect.GetPosition())); - - // we only need the ordinate (for rows) or abscissa (for columns) here, - // and need to cover the entire window in the other direction - oper.Select(rect) = 0; - - wxRect rectHeader(rect.GetPosition(), - oper.MakeSize - ( - oper.GetHeaderWindowSize(this), - doper.Select(size) - doper.Select(rect) - )); - - oper.GetHeaderWindow(this)->Refresh(true, &rectHeader); - - - // also refresh the grid window: extend the rectangle - if ( m_table ) - { - oper.SelectSize(rect) = oper.Select(size); - - int subtractLines = 0; - int line = doper.PosToLine(this, posLineStart); - if ( line >= 0 ) - { - // ensure that if we have a multi-cell block we redraw all of - // it by increasing the refresh area to cover it entirely if a - // part of it is affected - const int lineEnd = doper.PosToLine(this, posLineEnd, true); - for ( ; line < lineEnd; line++ ) - { - int cellLines = oper.Select( - GetCellSize(oper.MakeCoords(m_dragRowOrCol, line))); - if ( cellLines < subtractLines ) - subtractLines = cellLines; - } - } - - int startPos = - oper.GetLineStartPos(this, m_dragRowOrCol + subtractLines); - startPos = doper.CalcScrolledPosition(this, startPos); - - doper.Select(rect) = startPos; - doper.SelectSize(rect) = doper.Select(size) - startPos; - - m_gridWin->Refresh(false, &rect); - } - } - - // show the edit control back again - ShowCellEditControl(); - - return sizeChanged; -} - -void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event) -{ - // TODO: generate RESIZING event, see #10754 - - if ( DoEndDragResizeLine(wxGridRowOperations()) ) - SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event); -} - -void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event) -{ - // TODO: generate RESIZING event, see #10754 - - if ( DoEndDragResizeLine(wxGridColumnOperations()) ) - SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event); -} - -void wxGrid::DoStartMoveCol(int col) -{ - m_dragRowOrCol = col; -} - -void wxGrid::DoEndMoveCol(int pos) -{ - wxASSERT_MSG( m_dragRowOrCol != -1, "no matching DoStartMoveCol?" ); - - if ( SendEvent(wxEVT_GRID_COL_MOVE, -1, m_dragRowOrCol) != -1 ) - SetColPos(m_dragRowOrCol, pos); - //else: vetoed by user - - m_dragRowOrCol = -1; -} - -void wxGrid::RefreshAfterColPosChange() -{ - // recalculate the column rights as the column positions have changed, - // unless we calculate them dynamically because all columns widths are the - // same and it's easy to do - if ( !m_colWidths.empty() ) - { - int colRight = 0; - for ( int colPos = 0; colPos < m_numCols; colPos++ ) - { - int colID = GetColAt( colPos ); - - // Ignore the currently hidden columns. - const int width = m_colWidths[colID]; - if ( width > 0 ) - colRight += width; - - m_colRights[colID] = colRight; - } - } - - // and make the changes visible - if ( m_useNativeHeader ) - { - if ( m_colAt.empty() ) - GetGridColHeader()->ResetColumnsOrder(); - else - GetGridColHeader()->SetColumnsOrder(m_colAt); - } - else - { - m_colWindow->Refresh(); - } - m_gridWin->Refresh(); -} - -void wxGrid::SetColumnsOrder(const wxArrayInt& order) -{ - m_colAt = order; - - RefreshAfterColPosChange(); -} - -void wxGrid::SetColPos(int idx, int pos) -{ - // we're going to need m_colAt now, initialize it if needed - if ( m_colAt.empty() ) - { - m_colAt.reserve(m_numCols); - for ( int i = 0; i < m_numCols; i++ ) - m_colAt.push_back(i); - } - - wxHeaderCtrl::MoveColumnInOrderArray(m_colAt, idx, pos); - - RefreshAfterColPosChange(); -} - -void wxGrid::ResetColPos() -{ - m_colAt.clear(); - - RefreshAfterColPosChange(); -} - -void wxGrid::EnableDragColMove( bool enable ) -{ - if ( m_canDragColMove == enable ) - return; - - if ( m_useNativeHeader ) - { - // update all columns to make them [not] reorderable - GetGridColHeader()->SetColumnCount(m_numCols); - } - - m_canDragColMove = enable; - - // we use to call ResetColPos() from here if !enable but this doesn't seem - // right as it would mean there would be no way to "freeze" the current - // columns order by disabling moving them after putting them in the desired - // order, whereas now you can always call ResetColPos() manually if needed -} - - -// -// ------ interaction with data model -// -bool wxGrid::ProcessTableMessage( wxGridTableMessage& msg ) -{ - switch ( msg.GetId() ) - { - case wxGRIDTABLE_REQUEST_VIEW_GET_VALUES: - return GetModelValues(); - - case wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES: - return SetModelValues(); - - case wxGRIDTABLE_NOTIFY_ROWS_INSERTED: - case wxGRIDTABLE_NOTIFY_ROWS_APPENDED: - case wxGRIDTABLE_NOTIFY_ROWS_DELETED: - case wxGRIDTABLE_NOTIFY_COLS_INSERTED: - case wxGRIDTABLE_NOTIFY_COLS_APPENDED: - case wxGRIDTABLE_NOTIFY_COLS_DELETED: - return Redimension( msg ); - - default: - return false; - } -} - -// The behaviour of this function depends on the grid table class -// Clear() function. For the default wxGridStringTable class the -// behaviour is to replace all cell contents with wxEmptyString but -// not to change the number of rows or cols. -// -void wxGrid::ClearGrid() -{ - if ( m_table ) - { - if (IsCellEditControlEnabled()) - DisableCellEditControl(); - - m_table->Clear(); - if (!GetBatchCount()) - m_gridWin->Refresh(); - } -} - -bool -wxGrid::DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t), - int pos, int num, bool WXUNUSED(updateLabels) ) -{ - wxCHECK_MSG( m_created, false, "must finish creating the grid first" ); - - if ( !m_table ) - return false; - - if ( IsCellEditControlEnabled() ) - DisableCellEditControl(); - - return (m_table->*funcModify)(pos, num); - - // the table will have sent the results of the insert row - // operation to this view object as a grid table message -} - -bool -wxGrid::DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t), - int num, bool WXUNUSED(updateLabels)) -{ - wxCHECK_MSG( m_created, false, "must finish creating the grid first" ); - - if ( !m_table ) - return false; - - return (m_table->*funcAppend)(num); -} - -// ---------------------------------------------------------------------------- -// event generation helpers -// ---------------------------------------------------------------------------- - -bool -wxGrid::SendGridSizeEvent(wxEventType type, - int row, int col, - const wxMouseEvent& mouseEv) -{ - int rowOrCol = row == -1 ? col : row; - - wxGridSizeEvent gridEvt( GetId(), - type, - this, - rowOrCol, - mouseEv.GetX() + GetRowLabelSize(), - mouseEv.GetY() + GetColLabelSize(), - mouseEv); - - return GetEventHandler()->ProcessEvent(gridEvt); -} - -// Generate a grid event based on a mouse event and return: -// -1 if the event was vetoed -// +1 if the event was processed (but not vetoed) -// 0 if the event wasn't handled -int -wxGrid::SendEvent(const wxEventType type, - int row, int col, - const wxMouseEvent& mouseEv) -{ - bool claimed, vetoed; - - if ( type == wxEVT_GRID_RANGE_SELECT ) - { - // Right now, it should _never_ end up here! - wxGridRangeSelectEvent gridEvt( GetId(), - type, - this, - m_selectedBlockTopLeft, - m_selectedBlockBottomRight, - true, - mouseEv); - - claimed = GetEventHandler()->ProcessEvent(gridEvt); - vetoed = !gridEvt.IsAllowed(); - } - else if ( type == wxEVT_GRID_LABEL_LEFT_CLICK || - type == wxEVT_GRID_LABEL_LEFT_DCLICK || - type == wxEVT_GRID_LABEL_RIGHT_CLICK || - type == wxEVT_GRID_LABEL_RIGHT_DCLICK ) - { - wxPoint pos = mouseEv.GetPosition(); - - if ( mouseEv.GetEventObject() == GetGridRowLabelWindow() ) - pos.y += GetColLabelSize(); - if ( mouseEv.GetEventObject() == GetGridColLabelWindow() ) - pos.x += GetRowLabelSize(); - - wxGridEvent gridEvt( GetId(), - type, - this, - row, col, - pos.x, - pos.y, - false, - mouseEv); - claimed = GetEventHandler()->ProcessEvent(gridEvt); - vetoed = !gridEvt.IsAllowed(); - } - else - { - wxGridEvent gridEvt( GetId(), - type, - this, - row, col, - mouseEv.GetX() + GetRowLabelSize(), - mouseEv.GetY() + GetColLabelSize(), - false, - mouseEv); - - if ( type == wxEVT_GRID_CELL_BEGIN_DRAG ) - { - // by default the dragging is not supported, the user code must - // explicitly allow the event for it to take place - gridEvt.Veto(); - } - - claimed = GetEventHandler()->ProcessEvent(gridEvt); - vetoed = !gridEvt.IsAllowed(); - } - - // A Veto'd event may not be `claimed' so test this first - if (vetoed) - return -1; - - return claimed ? 1 : 0; -} - -// Generate a grid event of specified type, return value same as above -// -int -wxGrid::SendEvent(const wxEventType type, int row, int col, const wxString& s) -{ - wxGridEvent gridEvt( GetId(), type, this, row, col ); - gridEvt.SetString(s); - - const bool claimed = GetEventHandler()->ProcessEvent(gridEvt); - - // A Veto'd event may not be `claimed' so test this first - if ( !gridEvt.IsAllowed() ) - return -1; - - return claimed ? 1 : 0; -} - -void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) ) -{ - // needed to prevent zillions of paint events on MSW - wxPaintDC dc(this); -} - -void wxGrid::Refresh(bool eraseb, const wxRect* rect) -{ - // Don't do anything if between Begin/EndBatch... - // EndBatch() will do all this on the last nested one anyway. - if ( m_created && !GetBatchCount() ) - { - // Refresh to get correct scrolled position: - wxScrolledWindow::Refresh(eraseb, rect); - - if (rect) - { - int rect_x, rect_y, rectWidth, rectHeight; - int width_label, width_cell, height_label, height_cell; - int x, y; - - // Copy rectangle can get scroll offsets.. - rect_x = rect->GetX(); - rect_y = rect->GetY(); - rectWidth = rect->GetWidth(); - rectHeight = rect->GetHeight(); - - width_label = m_rowLabelWidth - rect_x; - if (width_label > rectWidth) - width_label = rectWidth; - - height_label = m_colLabelHeight - rect_y; - if (height_label > rectHeight) - height_label = rectHeight; - - if (rect_x > m_rowLabelWidth) - { - x = rect_x - m_rowLabelWidth; - width_cell = rectWidth; - } - else - { - x = 0; - width_cell = rectWidth - (m_rowLabelWidth - rect_x); - } - - if (rect_y > m_colLabelHeight) - { - y = rect_y - m_colLabelHeight; - height_cell = rectHeight; - } - else - { - y = 0; - height_cell = rectHeight - (m_colLabelHeight - rect_y); - } - - // Paint corner label part intersecting rect. - if ( width_label > 0 && height_label > 0 ) - { - wxRect anotherrect(rect_x, rect_y, width_label, height_label); - m_cornerLabelWin->Refresh(eraseb, &anotherrect); - } - - // Paint col labels part intersecting rect. - if ( width_cell > 0 && height_label > 0 ) - { - wxRect anotherrect(x, rect_y, width_cell, height_label); - m_colWindow->Refresh(eraseb, &anotherrect); - } - - // Paint row labels part intersecting rect. - if ( width_label > 0 && height_cell > 0 ) - { - wxRect anotherrect(rect_x, y, width_label, height_cell); - m_rowLabelWin->Refresh(eraseb, &anotherrect); - } - - // Paint cell area part intersecting rect. - if ( width_cell > 0 && height_cell > 0 ) - { - wxRect anotherrect(x, y, width_cell, height_cell); - m_gridWin->Refresh(eraseb, &anotherrect); - } - } - else - { - m_cornerLabelWin->Refresh(eraseb, NULL); - m_colWindow->Refresh(eraseb, NULL); - m_rowLabelWin->Refresh(eraseb, NULL); - m_gridWin->Refresh(eraseb, NULL); - } - } -} - -void wxGrid::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - if (m_targetWindow != this) // check whether initialisation has been done - { - // reposition our children windows - CalcWindowSizes(); - } -} - -void wxGrid::OnKeyDown( wxKeyEvent& event ) -{ - if ( m_inOnKeyDown ) - { - // shouldn't be here - we are going round in circles... - // - wxFAIL_MSG( wxT("wxGrid::OnKeyDown called while already active") ); - } - - m_inOnKeyDown = true; - - // propagate the event up and see if it gets processed - wxWindow *parent = GetParent(); - wxKeyEvent keyEvt( event ); - keyEvt.SetEventObject( parent ); - - if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) ) - { - if (GetLayoutDirection() == wxLayout_RightToLeft) - { - if (event.GetKeyCode() == WXK_RIGHT) - event.m_keyCode = WXK_LEFT; - else if (event.GetKeyCode() == WXK_LEFT) - event.m_keyCode = WXK_RIGHT; - } - - // try local handlers - switch ( event.GetKeyCode() ) - { - case WXK_UP: - if ( event.ControlDown() ) - MoveCursorUpBlock( event.ShiftDown() ); - else - MoveCursorUp( event.ShiftDown() ); - break; - - case WXK_DOWN: - if ( event.ControlDown() ) - MoveCursorDownBlock( event.ShiftDown() ); - else - MoveCursorDown( event.ShiftDown() ); - break; - - case WXK_LEFT: - if ( event.ControlDown() ) - MoveCursorLeftBlock( event.ShiftDown() ); - else - MoveCursorLeft( event.ShiftDown() ); - break; - - case WXK_RIGHT: - if ( event.ControlDown() ) - MoveCursorRightBlock( event.ShiftDown() ); - else - MoveCursorRight( event.ShiftDown() ); - break; - - case WXK_RETURN: - case WXK_NUMPAD_ENTER: - if ( event.ControlDown() ) - { - event.Skip(); // to let the edit control have the return - } - else - { - if ( GetGridCursorRow() < GetNumberRows()-1 ) - { - MoveCursorDown( event.ShiftDown() ); - } - else - { - // at the bottom of a column - DisableCellEditControl(); - } - } - break; - - case WXK_ESCAPE: - ClearSelection(); - break; - - case WXK_TAB: - { - // send an event to the grid's parents for custom handling - wxGridEvent gridEvt(GetId(), wxEVT_GRID_TABBING, this, - GetGridCursorRow(), GetGridCursorCol(), - -1, -1, false, event); - if ( ProcessWindowEvent(gridEvt) ) - { - // the event has been handled so no need for more processing - break; - } - } - DoGridProcessTab( event ); - break; - - case WXK_HOME: - GoToCell(event.ControlDown() ? 0 - : m_currentCellCoords.GetRow(), - 0); - break; - - case WXK_END: - GoToCell(event.ControlDown() ? m_numRows - 1 - : m_currentCellCoords.GetRow(), - m_numCols - 1); - break; - - case WXK_PAGEUP: - MovePageUp(); - break; - - case WXK_PAGEDOWN: - MovePageDown(); - break; - - case WXK_SPACE: - // Ctrl-Space selects the current column, Shift-Space -- the - // current row and Ctrl-Shift-Space -- everything - switch ( m_selection ? event.GetModifiers() : wxMOD_NONE ) - { - case wxMOD_CONTROL: - m_selection->SelectCol(m_currentCellCoords.GetCol()); - break; - - case wxMOD_SHIFT: - m_selection->SelectRow(m_currentCellCoords.GetRow()); - break; - - case wxMOD_CONTROL | wxMOD_SHIFT: - m_selection->SelectBlock(0, 0, - m_numRows - 1, m_numCols - 1); - break; - - case wxMOD_NONE: - if ( !IsEditable() ) - { - MoveCursorRight(false); - break; - } - //else: fall through - - default: - event.Skip(); - } - break; - - default: - event.Skip(); - break; - } - } - - m_inOnKeyDown = false; -} - -void wxGrid::OnKeyUp( wxKeyEvent& event ) -{ - // try local handlers - // - if ( event.GetKeyCode() == WXK_SHIFT ) - { - if ( m_selectedBlockTopLeft != wxGridNoCellCoords && - m_selectedBlockBottomRight != wxGridNoCellCoords ) - { - if ( m_selection ) - { - m_selection->SelectBlock( - m_selectedBlockTopLeft, - m_selectedBlockBottomRight, - event); - } - } - - m_selectedBlockTopLeft = wxGridNoCellCoords; - m_selectedBlockBottomRight = wxGridNoCellCoords; - m_selectedBlockCorner = wxGridNoCellCoords; - } -} - -void wxGrid::OnChar( wxKeyEvent& event ) -{ - // is it possible to edit the current cell at all? - if ( !IsCellEditControlEnabled() && CanEnableCellControl() ) - { - // yes, now check whether the cells editor accepts the key - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - wxGridCellAttr *attr = GetCellAttr(row, col); - wxGridCellEditor *editor = attr->GetEditor(this, row, col); - - // is special and will always start editing, for - // other keys - ask the editor itself - if ( (event.GetKeyCode() == WXK_F2 && !event.HasModifiers()) - || editor->IsAcceptedKey(event) ) - { - // ensure cell is visble - MakeCellVisible(row, col); - EnableCellEditControl(); - - // a problem can arise if the cell is not completely - // visible (even after calling MakeCellVisible the - // control is not created and calling StartingKey will - // crash the app - if ( event.GetKeyCode() != WXK_F2 && editor->IsCreated() && m_cellEditCtrlEnabled ) - editor->StartingKey(event); - } - else - { - event.Skip(); - } - - editor->DecRef(); - attr->DecRef(); - } - else - { - event.Skip(); - } -} - -void wxGrid::OnEraseBackground(wxEraseEvent&) -{ -} - -void wxGrid::DoGridProcessTab(wxKeyboardState& kbdState) -{ - const bool isForwardTab = !kbdState.ShiftDown(); - - // TAB processing only changes when we are at the borders of the grid, so - // let's first handle the common behaviour when we are not at the border. - if ( isForwardTab ) - { - if ( GetGridCursorCol() < GetNumberCols() - 1 ) - { - MoveCursorRight( false ); - return; - } - } - else // going back - { - if ( GetGridCursorCol() ) - { - MoveCursorLeft( false ); - return; - } - } - - - // We only get here if the cursor is at the border of the grid, apply the - // configured behaviour. - switch ( m_tabBehaviour ) - { - case Tab_Stop: - // Nothing special to do, we remain at the current cell. - break; - - case Tab_Wrap: - // Go to the beginning of the next or the end of the previous row. - if ( isForwardTab ) - { - if ( GetGridCursorRow() < GetNumberRows() - 1 ) - { - GoToCell( GetGridCursorRow() + 1, 0 ); - return; - } - } - else - { - if ( GetGridCursorRow() > 0 ) - { - GoToCell( GetGridCursorRow() - 1, GetNumberCols() - 1 ); - return; - } - } - break; - - case Tab_Leave: - if ( Navigate( isForwardTab ? wxNavigationKeyEvent::IsForward - : wxNavigationKeyEvent::IsBackward ) ) - return; - break; - } - - // If we remain in this cell, stop editing it if we were doing so. - DisableCellEditControl(); -} - -bool wxGrid::SetCurrentCell( const wxGridCellCoords& coords ) -{ - if ( SendEvent(wxEVT_GRID_SELECT_CELL, coords) == -1 ) - { - // the event has been vetoed - do nothing - return false; - } - -#if !defined(__WXMAC__) - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); -#endif - - if ( m_currentCellCoords != wxGridNoCellCoords ) - { - DisableCellEditControl(); - - if ( IsVisible( m_currentCellCoords, false ) ) - { - wxRect r; - r = BlockToDeviceRect( m_currentCellCoords, m_currentCellCoords ); - if ( !m_gridLinesEnabled ) - { - r.x--; - r.y--; - r.width++; - r.height++; - } - - wxGridCellCoordsArray cells = CalcCellsExposed( r ); - - // Otherwise refresh redraws the highlight! - m_currentCellCoords = coords; - -#if defined(__WXMAC__) - m_gridWin->Refresh(true /*, & r */); -#else - DrawGridCellArea( dc, cells ); - DrawAllGridLines( dc, r ); -#endif - } - } - - m_currentCellCoords = coords; - - wxGridCellAttr *attr = GetCellAttr( coords ); -#if !defined(__WXMAC__) - DrawCellHighlight( dc, attr ); -#endif - attr->DecRef(); - - return true; -} - -void -wxGrid::UpdateBlockBeingSelected(int topRow, int leftCol, - int bottomRow, int rightCol) -{ - MakeCellVisible(m_selectedBlockCorner); - m_selectedBlockCorner = wxGridCellCoords(bottomRow, rightCol); - - if ( m_selection ) - { - switch ( m_selection->GetSelectionMode() ) - { - default: - wxFAIL_MSG( "unknown selection mode" ); - // fall through - - case wxGridSelectCells: - // arbitrary blocks selection allowed so just use the cell - // coordinates as is - break; - - case wxGridSelectRows: - // only full rows selection allowd, ensure that we do select - // full rows - leftCol = 0; - rightCol = GetNumberCols() - 1; - break; - - case wxGridSelectColumns: - // same as above but for columns - topRow = 0; - bottomRow = GetNumberRows() - 1; - break; - - case wxGridSelectRowsOrColumns: - // in this mode we can select only full rows or full columns so - // it doesn't make sense to select blocks at all (and we can't - // extend the block because there is no preferred direction, we - // could only extend it to cover the entire grid but this is - // not useful) - return; - } - } - - EnsureFirstLessThanSecond(topRow, bottomRow); - EnsureFirstLessThanSecond(leftCol, rightCol); - - wxGridCellCoords updateTopLeft = wxGridCellCoords(topRow, leftCol), - updateBottomRight = wxGridCellCoords(bottomRow, rightCol); - - // First the case that we selected a completely new area - if ( m_selectedBlockTopLeft == wxGridNoCellCoords || - m_selectedBlockBottomRight == wxGridNoCellCoords ) - { - wxRect rect; - rect = BlockToDeviceRect( wxGridCellCoords ( topRow, leftCol ), - wxGridCellCoords ( bottomRow, rightCol ) ); - m_gridWin->Refresh( false, &rect ); - } - - // Now handle changing an existing selection area. - else if ( m_selectedBlockTopLeft != updateTopLeft || - m_selectedBlockBottomRight != updateBottomRight ) - { - // Compute two optimal update rectangles: - // Either one rectangle is a real subset of the - // other, or they are (almost) disjoint! - wxRect rect[4]; - bool need_refresh[4]; - need_refresh[0] = - need_refresh[1] = - need_refresh[2] = - need_refresh[3] = false; - int i; - - // Store intermediate values - wxCoord oldLeft = m_selectedBlockTopLeft.GetCol(); - wxCoord oldTop = m_selectedBlockTopLeft.GetRow(); - wxCoord oldRight = m_selectedBlockBottomRight.GetCol(); - wxCoord oldBottom = m_selectedBlockBottomRight.GetRow(); - - // Determine the outer/inner coordinates. - EnsureFirstLessThanSecond(oldLeft, leftCol); - EnsureFirstLessThanSecond(oldTop, topRow); - EnsureFirstLessThanSecond(rightCol, oldRight); - EnsureFirstLessThanSecond(bottomRow, oldBottom); - - // Now, either the stuff marked old is the outer - // rectangle or we don't have a situation where one - // is contained in the other. - - if ( oldLeft < leftCol ) - { - // Refresh the newly selected or deselected - // area to the left of the old or new selection. - need_refresh[0] = true; - rect[0] = BlockToDeviceRect( - wxGridCellCoords( oldTop, oldLeft ), - wxGridCellCoords( oldBottom, leftCol - 1 ) ); - } - - if ( oldTop < topRow ) - { - // Refresh the newly selected or deselected - // area above the old or new selection. - need_refresh[1] = true; - rect[1] = BlockToDeviceRect( - wxGridCellCoords( oldTop, leftCol ), - wxGridCellCoords( topRow - 1, rightCol ) ); - } - - if ( oldRight > rightCol ) - { - // Refresh the newly selected or deselected - // area to the right of the old or new selection. - need_refresh[2] = true; - rect[2] = BlockToDeviceRect( - wxGridCellCoords( oldTop, rightCol + 1 ), - wxGridCellCoords( oldBottom, oldRight ) ); - } - - if ( oldBottom > bottomRow ) - { - // Refresh the newly selected or deselected - // area below the old or new selection. - need_refresh[3] = true; - rect[3] = BlockToDeviceRect( - wxGridCellCoords( bottomRow + 1, leftCol ), - wxGridCellCoords( oldBottom, rightCol ) ); - } - - // various Refresh() calls - for (i = 0; i < 4; i++ ) - if ( need_refresh[i] && rect[i] != wxGridNoCellRect ) - m_gridWin->Refresh( false, &(rect[i]) ); - } - - // change selection - m_selectedBlockTopLeft = updateTopLeft; - m_selectedBlockBottomRight = updateBottomRight; -} - -// -// ------ functions to get/send data (see also public functions) -// - -bool wxGrid::GetModelValues() -{ - // Hide the editor, so it won't hide a changed value. - HideCellEditControl(); - - if ( m_table ) - { - // all we need to do is repaint the grid - // - m_gridWin->Refresh(); - return true; - } - - return false; -} - -bool wxGrid::SetModelValues() -{ - int row, col; - - // Disable the editor, so it won't hide a changed value. - // Do we also want to save the current value of the editor first? - // I think so ... - DisableCellEditControl(); - - if ( m_table ) - { - for ( row = 0; row < m_numRows; row++ ) - { - for ( col = 0; col < m_numCols; col++ ) - { - m_table->SetValue( row, col, GetCellValue(row, col) ); - } - } - - return true; - } - - return false; -} - -// Note - this function only draws cells that are in the list of -// exposed cells (usually set from the update region by -// CalcExposedCells) -// -void wxGrid::DrawGridCellArea( wxDC& dc, const wxGridCellCoordsArray& cells ) -{ - if ( !m_numRows || !m_numCols ) - return; - - int i, numCells = cells.GetCount(); - int row, col, cell_rows, cell_cols; - wxGridCellCoordsArray redrawCells; - - for ( i = numCells - 1; i >= 0; i-- ) - { - row = cells[i].GetRow(); - col = cells[i].GetCol(); - GetCellSize( row, col, &cell_rows, &cell_cols ); - - // If this cell is part of a multicell block, find owner for repaint - if ( cell_rows <= 0 || cell_cols <= 0 ) - { - wxGridCellCoords cell( row + cell_rows, col + cell_cols ); - bool marked = false; - for ( int j = 0; j < numCells; j++ ) - { - if ( cell == cells[j] ) - { - marked = true; - break; - } - } - - if (!marked) - { - int count = redrawCells.GetCount(); - for (int j = 0; j < count; j++) - { - if ( cell == redrawCells[j] ) - { - marked = true; - break; - } - } - - if (!marked) - redrawCells.Add( cell ); - } - - // don't bother drawing this cell - continue; - } - - // If this cell is empty, find cell to left that might want to overflow - if (m_table && m_table->IsEmptyCell(row, col)) - { - for ( int l = 0; l < cell_rows; l++ ) - { - // find a cell in this row to leave already marked for repaint - int left = col; - for (int k = 0; k < int(redrawCells.GetCount()); k++) - if ((redrawCells[k].GetCol() < left) && - (redrawCells[k].GetRow() == row)) - { - left = redrawCells[k].GetCol(); - } - - if (left == col) - left = 0; // oh well - - for (int j = col - 1; j >= left; j--) - { - if (!m_table->IsEmptyCell(row + l, j)) - { - if (GetCellOverflow(row + l, j)) - { - wxGridCellCoords cell(row + l, j); - bool marked = false; - - for (int k = 0; k < numCells; k++) - { - if ( cell == cells[k] ) - { - marked = true; - break; - } - } - - if (!marked) - { - int count = redrawCells.GetCount(); - for (int k = 0; k < count; k++) - { - if ( cell == redrawCells[k] ) - { - marked = true; - break; - } - } - if (!marked) - redrawCells.Add( cell ); - } - } - break; - } - } - } - } - - DrawCell( dc, cells[i] ); - } - - numCells = redrawCells.GetCount(); - - for ( i = numCells - 1; i >= 0; i-- ) - { - DrawCell( dc, redrawCells[i] ); - } -} - -void wxGrid::DrawGridSpace( wxDC& dc ) -{ - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - - int right, bottom; - CalcUnscrolledPosition( cw, ch, &right, &bottom ); - - int rightCol = m_numCols > 0 ? GetColRight(GetColAt( m_numCols - 1 )) : 0; - int bottomRow = m_numRows > 0 ? GetRowBottom(m_numRows - 1) : 0; - - if ( right > rightCol || bottom > bottomRow ) - { - int left, top; - CalcUnscrolledPosition( 0, 0, &left, &top ); - - dc.SetBrush(GetDefaultCellBackgroundColour()); - dc.SetPen( *wxTRANSPARENT_PEN ); - - if ( right > rightCol ) - { - dc.DrawRectangle( rightCol, top, right - rightCol, ch ); - } - - if ( bottom > bottomRow ) - { - dc.DrawRectangle( left, bottomRow, cw, bottom - bottomRow ); - } - } -} - -void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords ) -{ - int row = coords.GetRow(); - int col = coords.GetCol(); - - if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) - return; - - // we draw the cell border ourselves - wxGridCellAttr* attr = GetCellAttr(row, col); - - bool isCurrent = coords == m_currentCellCoords; - - wxRect rect = CellToRect( row, col ); - - // if the editor is shown, we should use it and not the renderer - // Note: However, only if it is really _shown_, i.e. not hidden! - if ( isCurrent && IsCellEditControlShown() ) - { - // NB: this "#if..." is temporary and fixes a problem where the - // edit control is erased by this code after being rendered. - // On wxMac (QD build only), the cell editor is a wxTextCntl and is rendered - // implicitly, causing this out-of order render. -#if !defined(__WXMAC__) - wxGridCellEditor *editor = attr->GetEditor(this, row, col); - editor->PaintBackground(dc, rect, *attr); - editor->DecRef(); -#endif - } - else - { - // but all the rest is drawn by the cell renderer and hence may be customized - wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col); - renderer->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords)); - renderer->DecRef(); - } - - attr->DecRef(); -} - -void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ) -{ - // don't show highlight when the grid doesn't have focus - if ( !HasFocus() ) - return; - - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - - if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) - return; - - wxRect rect = CellToRect(row, col); - - // hmmm... what could we do here to show that the cell is disabled? - // for now, I just draw a thinner border than for the other ones, but - // it doesn't look really good - - int penWidth = attr->IsReadOnly() ? m_cellHighlightROPenWidth : m_cellHighlightPenWidth; - - if (penWidth > 0) - { - // The center of the drawn line is where the position/width/height of - // the rectangle is actually at (on wxMSW at least), so the - // size of the rectangle is reduced to compensate for the thickness of - // the line. If this is too strange on non-wxMSW platforms then - // please #ifdef this appropriately. - rect.x += penWidth / 2; - rect.y += penWidth / 2; - rect.width -= penWidth - 1; - rect.height -= penWidth - 1; - - // Now draw the rectangle - // use the cellHighlightColour if the cell is inside a selection, this - // will ensure the cell is always visible. - dc.SetPen(wxPen(IsInSelection(row,col) ? m_selectionForeground - : m_cellHighlightColour, - penWidth)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(rect); - } -} - -wxPen wxGrid::GetDefaultGridLinePen() -{ - return wxPen(GetGridLineColour()); -} - -wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row)) -{ - return GetDefaultGridLinePen(); -} - -wxPen wxGrid::GetColGridLinePen(int WXUNUSED(col)) -{ - return GetDefaultGridLinePen(); -} - -void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords ) -{ - int row = coords.GetRow(); - int col = coords.GetCol(); - if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) - return; - - - wxRect rect = CellToRect( row, col ); - - // right hand border - dc.SetPen( GetColGridLinePen(col) ); - dc.DrawLine( rect.x + rect.width, rect.y, - rect.x + rect.width, rect.y + rect.height + 1 ); - - // bottom border - dc.SetPen( GetRowGridLinePen(row) ); - dc.DrawLine( rect.x, rect.y + rect.height, - rect.x + rect.width, rect.y + rect.height); -} - -void wxGrid::DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells) -{ - // This if block was previously in wxGrid::OnPaint but that doesn't - // seem to get called under wxGTK - MB - // - if ( m_currentCellCoords == wxGridNoCellCoords && - m_numRows && m_numCols ) - { - m_currentCellCoords.Set(0, 0); - } - - if ( IsCellEditControlShown() ) - { - // don't show highlight when the edit control is shown - return; - } - - // if the active cell was repainted, repaint its highlight too because it - // might have been damaged by the grid lines - size_t count = cells.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxGridCellCoords cell = cells[n]; - - // If we are using attributes, then we may have just exposed another - // cell in a partially-visible merged cluster of cells. If the "anchor" - // (upper left) cell of this merged cluster is the cell indicated by - // m_currentCellCoords, then we need to refresh the cell highlight even - // though the "anchor" itself is not part of our update segment. - if ( CanHaveAttributes() ) - { - int rows = 0, - cols = 0; - GetCellSize(cell.GetRow(), cell.GetCol(), &rows, &cols); - - if ( rows < 0 ) - cell.SetRow(cell.GetRow() + rows); - - if ( cols < 0 ) - cell.SetCol(cell.GetCol() + cols); - } - - if ( cell == m_currentCellCoords ) - { - wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords); - DrawCellHighlight(dc, attr); - attr->DecRef(); - - break; - } - } -} - -// Used by wxGrid::Render() to draw the grid lines only for the cells in the -// specified range. -void -wxGrid::DrawRangeGridLines(wxDC& dc, - const wxRegion& reg, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight) -{ - if ( !m_gridLinesEnabled ) - return; - - int top, left, width, height; - reg.GetBox( left, top, width, height ); - - // create a clipping region - wxRegion clippedcells( dc.LogicalToDeviceX( left ), - dc.LogicalToDeviceY( top ), - dc.LogicalToDeviceXRel( width ), - dc.LogicalToDeviceYRel( height ) ); - - // subtract multi cell span area from clipping region for lines - wxRect rect; - for ( int row = topLeft.GetRow(); row <= bottomRight.GetRow(); row++ ) - { - for ( int col = topLeft.GetCol(); col <= bottomRight.GetCol(); col++ ) - { - int cell_rows, cell_cols; - GetCellSize( row, col, &cell_rows, &cell_cols ); - if ( cell_rows > 1 || cell_cols > 1 ) // multi cell - { - rect = CellToRect( row, col ); - // cater for scaling - // device origin already set in ::Render() for x, y - rect.x = dc.LogicalToDeviceX( rect.x ); - rect.y = dc.LogicalToDeviceY( rect.y ); - rect.width = dc.LogicalToDeviceXRel( rect.width ); - rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1; - clippedcells.Subtract( rect ); - } - else if ( cell_rows < 0 || cell_cols < 0 ) // part of multicell - { - rect = CellToRect( row + cell_rows, col + cell_cols ); - rect.x = dc.LogicalToDeviceX( rect.x ); - rect.y = dc.LogicalToDeviceY( rect.y ); - rect.width = dc.LogicalToDeviceXRel( rect.width ); - rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1; - clippedcells.Subtract( rect ); - } - } - } - - dc.SetDeviceClippingRegion( clippedcells ); - - DoDrawGridLines(dc, - top, left, top + height, left + width, - topLeft.GetRow(), topLeft.GetCol(), - bottomRight.GetRow(), bottomRight.GetCol()); - - dc.DestroyClippingRegion(); -} - -// This is used to redraw all grid lines e.g. when the grid line colour -// has been changed -// -void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) ) -{ - if ( !m_gridLinesEnabled ) - return; - - int top, bottom, left, right; - - int cw, ch; - m_gridWin->GetClientSize(&cw, &ch); - CalcUnscrolledPosition( 0, 0, &left, &top ); - CalcUnscrolledPosition( cw, ch, &right, &bottom ); - - // avoid drawing grid lines past the last row and col - if ( m_gridLinesClipHorz ) - { - if ( !m_numCols ) - return; - - const int lastColRight = GetColRight(GetColAt(m_numCols - 1)); - if ( right > lastColRight ) - right = lastColRight; - } - - if ( m_gridLinesClipVert ) - { - if ( !m_numRows ) - return; - - const int lastRowBottom = GetRowBottom(m_numRows - 1); - if ( bottom > lastRowBottom ) - bottom = lastRowBottom; - } - - // no gridlines inside multicells, clip them out - int leftCol = GetColPos( internalXToCol(left) ); - int topRow = internalYToRow(top); - int rightCol = GetColPos( internalXToCol(right) ); - int bottomRow = internalYToRow(bottom); - - wxRegion clippedcells(0, 0, cw, ch); - - int cell_rows, cell_cols; - wxRect rect; - - for ( int j = topRow; j <= bottomRow; j++ ) - { - for ( int colPos = leftCol; colPos <= rightCol; colPos++ ) - { - int i = GetColAt( colPos ); - - GetCellSize( j, i, &cell_rows, &cell_cols ); - if ((cell_rows > 1) || (cell_cols > 1)) - { - rect = CellToRect(j,i); - CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - clippedcells.Subtract(rect); - } - else if ((cell_rows < 0) || (cell_cols < 0)) - { - rect = CellToRect(j + cell_rows, i + cell_cols); - CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - clippedcells.Subtract(rect); - } - } - } - - dc.SetDeviceClippingRegion( clippedcells ); - - DoDrawGridLines(dc, - top, left, bottom, right, - topRow, leftCol, m_numRows, m_numCols); - - dc.DestroyClippingRegion(); -} - -void -wxGrid::DoDrawGridLines(wxDC& dc, - int top, int left, - int bottom, int right, - int topRow, int leftCol, - int bottomRow, int rightCol) -{ - // horizontal grid lines - for ( int i = topRow; i < bottomRow; i++ ) - { - int bot = GetRowBottom(i) - 1; - - if ( bot > bottom ) - break; - - if ( bot >= top ) - { - dc.SetPen( GetRowGridLinePen(i) ); - dc.DrawLine( left, bot, right, bot ); - } - } - - // vertical grid lines - for ( int colPos = leftCol; colPos < rightCol; colPos++ ) - { - int i = GetColAt( colPos ); - - int colRight = GetColRight(i); -#ifdef __WXGTK__ - if (GetLayoutDirection() != wxLayout_RightToLeft) -#endif - colRight--; - - if ( colRight > right ) - break; - - if ( colRight >= left ) - { - dc.SetPen( GetColGridLinePen(i) ); - dc.DrawLine( colRight, top, colRight, bottom ); - } - } -} - -void wxGrid::DrawRowLabels( wxDC& dc, const wxArrayInt& rows) -{ - if ( !m_numRows ) - return; - - const size_t numLabels = rows.GetCount(); - for ( size_t i = 0; i < numLabels; i++ ) - { - DrawRowLabel( dc, rows[i] ); - } -} - -void wxGrid::DrawRowLabel( wxDC& dc, int row ) -{ - if ( GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0 ) - return; - - wxGridCellAttrProvider * const - attrProvider = m_table ? m_table->GetAttrProvider() : NULL; - - // notice that an explicit static_cast is needed to avoid a compilation - // error with VC7.1 which, for some reason, tries to instantiate (abstract) - // wxGridRowHeaderRenderer class without it - const wxGridRowHeaderRenderer& - rend = attrProvider ? attrProvider->GetRowHeaderRenderer(row) - : static_cast - (gs_defaultHeaderRenderers.rowRenderer); - - wxRect rect(0, GetRowTop(row), m_rowLabelWidth, GetRowHeight(row)); - rend.DrawBorder(*this, dc, rect); - - int hAlign, vAlign; - GetRowLabelAlignment(&hAlign, &vAlign); - - rend.DrawLabel(*this, dc, GetRowLabelValue(row), - rect, hAlign, vAlign, wxHORIZONTAL); -} - -void wxGrid::UseNativeColHeader(bool native) -{ - if ( native == m_useNativeHeader ) - return; - - delete m_colWindow; - m_useNativeHeader = native; - - CreateColumnWindow(); - - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - CalcWindowSizes(); -} - -void wxGrid::SetUseNativeColLabels( bool native ) -{ - wxASSERT_MSG( !m_useNativeHeader, - "doesn't make sense when using native header" ); - - m_nativeColumnLabels = native; - if (native) - { - int height = wxRendererNative::Get().GetHeaderButtonHeight( this ); - SetColLabelSize( height ); - } - - GetColLabelWindow()->Refresh(); - m_cornerLabelWin->Refresh(); -} - -void wxGrid::DrawColLabels( wxDC& dc,const wxArrayInt& cols ) -{ - if ( !m_numCols ) - return; - - const size_t numLabels = cols.GetCount(); - for ( size_t i = 0; i < numLabels; i++ ) - { - DrawColLabel( dc, cols[i] ); - } -} - -void wxGrid::DrawCornerLabel(wxDC& dc) -{ - wxRect rect(wxSize(m_rowLabelWidth, m_colLabelHeight)); - - if ( m_nativeColumnLabels ) - { - rect.Deflate(1); - - wxRendererNative::Get().DrawHeaderButton(m_cornerLabelWin, dc, rect, 0); - } - else - { - rect.width++; - rect.height++; - - wxGridCellAttrProvider * const - attrProvider = m_table ? m_table->GetAttrProvider() : NULL; - const wxGridCornerHeaderRenderer& - rend = attrProvider ? attrProvider->GetCornerRenderer() - : static_cast - (gs_defaultHeaderRenderers.cornerRenderer); - - rend.DrawBorder(*this, dc, rect); - } -} - -void wxGrid::DrawColLabel(wxDC& dc, int col) -{ - if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 ) - return; - - int colLeft = GetColLeft(col); - - wxRect rect(colLeft, 0, GetColWidth(col), m_colLabelHeight); - wxGridCellAttrProvider * const - attrProvider = m_table ? m_table->GetAttrProvider() : NULL; - const wxGridColumnHeaderRenderer& - rend = attrProvider ? attrProvider->GetColumnHeaderRenderer(col) - : static_cast - (gs_defaultHeaderRenderers.colRenderer); - - if ( m_nativeColumnLabels ) - { - wxRendererNative::Get().DrawHeaderButton - ( - GetColLabelWindow(), - dc, - rect, - 0, - IsSortingBy(col) - ? IsSortOrderAscending() - ? wxHDR_SORT_ICON_UP - : wxHDR_SORT_ICON_DOWN - : wxHDR_SORT_ICON_NONE - ); - rect.Deflate(2); - } - else - { - // It is reported that we need to erase the background to avoid display - // artefacts, see #12055. - wxDCBrushChanger setBrush(dc, m_colWindow->GetBackgroundColour()); - dc.DrawRectangle(rect); - - rend.DrawBorder(*this, dc, rect); - } - - int hAlign, vAlign; - GetColLabelAlignment(&hAlign, &vAlign); - const int orient = GetColLabelTextOrientation(); - - rend.DrawLabel(*this, dc, GetColLabelValue(col), rect, hAlign, vAlign, orient); -} - -// TODO: these 2 functions should be replaced with wxDC::DrawLabel() to which -// we just have to add textOrientation support -void wxGrid::DrawTextRectangle( wxDC& dc, - const wxString& value, - const wxRect& rect, - int horizAlign, - int vertAlign, - int textOrientation ) const -{ - wxArrayString lines; - - StringToLines( value, lines ); - - DrawTextRectangle(dc, lines, rect, horizAlign, vertAlign, textOrientation); -} - -void wxGrid::DrawTextRectangle(wxDC& dc, - const wxArrayString& lines, - const wxRect& rect, - int horizAlign, - int vertAlign, - int textOrientation) const -{ - if ( lines.empty() ) - return; - - wxDCClipper clip(dc, rect); - - long textWidth, - textHeight; - - if ( textOrientation == wxHORIZONTAL ) - GetTextBoxSize( dc, lines, &textWidth, &textHeight ); - else - GetTextBoxSize( dc, lines, &textHeight, &textWidth ); - - int x = 0, - y = 0; - switch ( vertAlign ) - { - case wxALIGN_BOTTOM: - if ( textOrientation == wxHORIZONTAL ) - y = rect.y + (rect.height - textHeight - 1); - else - x = rect.x + rect.width - textWidth; - break; - - case wxALIGN_CENTRE: - if ( textOrientation == wxHORIZONTAL ) - y = rect.y + ((rect.height - textHeight) / 2); - else - x = rect.x + ((rect.width - textWidth) / 2); - break; - - case wxALIGN_TOP: - default: - if ( textOrientation == wxHORIZONTAL ) - y = rect.y + 1; - else - x = rect.x + 1; - break; - } - - // Align each line of a multi-line label - size_t nLines = lines.GetCount(); - for ( size_t l = 0; l < nLines; l++ ) - { - const wxString& line = lines[l]; - - if ( line.empty() ) - { - *(textOrientation == wxHORIZONTAL ? &y : &x) += dc.GetCharHeight(); - continue; - } - - wxCoord lineWidth = 0, - lineHeight = 0; - dc.GetTextExtent(line, &lineWidth, &lineHeight); - - switch ( horizAlign ) - { - case wxALIGN_RIGHT: - if ( textOrientation == wxHORIZONTAL ) - x = rect.x + (rect.width - lineWidth - 1); - else - y = rect.y + lineWidth + 1; - break; - - case wxALIGN_CENTRE: - if ( textOrientation == wxHORIZONTAL ) - x = rect.x + ((rect.width - lineWidth) / 2); - else - y = rect.y + rect.height - ((rect.height - lineWidth) / 2); - break; - - case wxALIGN_LEFT: - default: - if ( textOrientation == wxHORIZONTAL ) - x = rect.x + 1; - else - y = rect.y + rect.height - 1; - break; - } - - if ( textOrientation == wxHORIZONTAL ) - { - dc.DrawText( line, x, y ); - y += lineHeight; - } - else - { - dc.DrawRotatedText( line, x, y, 90.0 ); - x += lineHeight; - } - } -} - -// Split multi-line text up into an array of strings. -// Any existing contents of the string array are preserved. -// -// TODO: refactor wxTextFile::Read() and reuse the same code from here -void wxGrid::StringToLines( const wxString& value, wxArrayString& lines ) const -{ - int startPos = 0; - int pos; - wxString eol = wxTextFile::GetEOL( wxTextFileType_Unix ); - wxString tVal = wxTextFile::Translate( value, wxTextFileType_Unix ); - - while ( startPos < (int)tVal.length() ) - { - pos = tVal.Mid(startPos).Find( eol ); - if ( pos < 0 ) - { - break; - } - else if ( pos == 0 ) - { - lines.Add( wxEmptyString ); - } - else - { - lines.Add( tVal.Mid(startPos, pos) ); - } - - startPos += pos + 1; - } - - if ( startPos < (int)tVal.length() ) - { - lines.Add( tVal.Mid( startPos ) ); - } -} - -void wxGrid::GetTextBoxSize( const wxDC& dc, - const wxArrayString& lines, - long *width, long *height ) const -{ - wxCoord w = 0; - wxCoord h = 0; - wxCoord lineW = 0, lineH = 0; - - size_t i; - for ( i = 0; i < lines.GetCount(); i++ ) - { - dc.GetTextExtent( lines[i], &lineW, &lineH ); - w = wxMax( w, lineW ); - h += lineH; - } - - *width = w; - *height = h; -} - -// -// ------ Batch processing. -// -void wxGrid::EndBatch() -{ - if ( m_batchCount > 0 ) - { - m_batchCount--; - if ( !m_batchCount ) - { - CalcDimensions(); - m_rowLabelWin->Refresh(); - m_colWindow->Refresh(); - m_cornerLabelWin->Refresh(); - m_gridWin->Refresh(); - } - } -} - -// Use this, rather than wxWindow::Refresh(), to force an immediate -// repainting of the grid. Has no effect if you are already inside a -// BeginBatch / EndBatch block. -// -void wxGrid::ForceRefresh() -{ - BeginBatch(); - EndBatch(); -} - -bool wxGrid::Enable(bool enable) -{ - if ( !wxScrolledWindow::Enable(enable) ) - return false; - - // redraw in the new state - m_gridWin->Refresh(); - - return true; -} - -// -// ------ Edit control functions -// - -void wxGrid::EnableEditing( bool edit ) -{ - if ( edit != m_editable ) - { - if (!edit) - EnableCellEditControl(edit); - m_editable = edit; - } -} - -void wxGrid::EnableCellEditControl( bool enable ) -{ - if (! m_editable) - return; - - if ( enable != m_cellEditCtrlEnabled ) - { - if ( enable ) - { - if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 ) - return; - - // this should be checked by the caller! - wxASSERT_MSG( CanEnableCellControl(), wxT("can't enable editing for this cell!") ); - - // do it before ShowCellEditControl() - m_cellEditCtrlEnabled = enable; - - ShowCellEditControl(); - } - else - { - SendEvent(wxEVT_GRID_EDITOR_HIDDEN); - - HideCellEditControl(); - SaveEditControlValue(); - - // do it after HideCellEditControl() - m_cellEditCtrlEnabled = enable; - } - } -} - -bool wxGrid::IsCurrentCellReadOnly() const -{ - wxGridCellAttr* - attr = const_cast(this)->GetCellAttr(m_currentCellCoords); - bool readonly = attr->IsReadOnly(); - attr->DecRef(); - - return readonly; -} - -bool wxGrid::CanEnableCellControl() const -{ - return m_editable && (m_currentCellCoords != wxGridNoCellCoords) && - !IsCurrentCellReadOnly(); -} - -bool wxGrid::IsCellEditControlEnabled() const -{ - // the cell edit control might be disable for all cells or just for the - // current one if it's read only - return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : false; -} - -bool wxGrid::IsCellEditControlShown() const -{ - bool isShown = false; - - if ( m_cellEditCtrlEnabled ) - { - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - wxGridCellAttr* attr = GetCellAttr(row, col); - wxGridCellEditor* editor = attr->GetEditor((wxGrid*) this, row, col); - attr->DecRef(); - - if ( editor ) - { - if ( editor->IsCreated() ) - { - isShown = editor->GetControl()->IsShown(); - } - - editor->DecRef(); - } - } - - return isShown; -} - -void wxGrid::ShowCellEditControl() -{ - if ( IsCellEditControlEnabled() ) - { - if ( !IsVisible( m_currentCellCoords, false ) ) - { - m_cellEditCtrlEnabled = false; - return; - } - else - { - wxRect rect = CellToRect( m_currentCellCoords ); - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - - // if this is part of a multicell, find owner (topleft) - int cell_rows, cell_cols; - GetCellSize( row, col, &cell_rows, &cell_cols ); - if ( cell_rows <= 0 || cell_cols <= 0 ) - { - row += cell_rows; - col += cell_cols; - m_currentCellCoords.SetRow( row ); - m_currentCellCoords.SetCol( col ); - } - - // erase the highlight and the cell contents because the editor - // might not cover the entire cell - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); - wxGridCellAttr* attr = GetCellAttr(row, col); - dc.SetBrush(wxBrush(attr->GetBackgroundColour())); - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle(rect); - - // convert to scrolled coords - CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - - int nXMove = 0; - if (rect.x < 0) - nXMove = rect.x; - - // cell is shifted by one pixel - // However, don't allow x or y to become negative - // since the SetSize() method interprets that as - // "don't change." - if (rect.x > 0) - rect.x--; - if (rect.y > 0) - rect.y--; - - wxGridCellEditor* editor = attr->GetEditor(this, row, col); - if ( !editor->IsCreated() ) - { - editor->Create(m_gridWin, wxID_ANY, - new wxGridCellEditorEvtHandler(this, editor)); - - wxGridEditorCreatedEvent evt(GetId(), - wxEVT_GRID_EDITOR_CREATED, - this, - row, - col, - editor->GetControl()); - GetEventHandler()->ProcessEvent(evt); - } - - // resize editor to overflow into righthand cells if allowed - int maxWidth = rect.width; - wxString value = GetCellValue(row, col); - if ( (value != wxEmptyString) && (attr->GetOverflow()) ) - { - int y; - GetTextExtent(value, &maxWidth, &y, NULL, NULL, &attr->GetFont()); - if (maxWidth < rect.width) - maxWidth = rect.width; - } - - int client_right = m_gridWin->GetClientSize().GetWidth(); - if (rect.x + maxWidth > client_right) - maxWidth = client_right - rect.x; - - if ((maxWidth > rect.width) && (col < m_numCols) && m_table) - { - GetCellSize( row, col, &cell_rows, &cell_cols ); - // may have changed earlier - for (int i = col + cell_cols; i < m_numCols; i++) - { - int c_rows, c_cols; - GetCellSize( row, i, &c_rows, &c_cols ); - - // looks weird going over a multicell - if (m_table->IsEmptyCell( row, i ) && - (rect.width < maxWidth) && (c_rows == 1)) - { - rect.width += GetColWidth( i ); - } - else - break; - } - - if (rect.GetRight() > client_right) - rect.SetRight( client_right - 1 ); - } - - editor->SetCellAttr( attr ); - editor->SetSize( rect ); - if (nXMove != 0) - editor->GetControl()->Move( - editor->GetControl()->GetPosition().x + nXMove, - editor->GetControl()->GetPosition().y ); - editor->Show( true, attr ); - - // recalc dimensions in case we need to - // expand the scrolled window to account for editor - CalcDimensions(); - - editor->BeginEdit(row, col, this); - editor->SetCellAttr(NULL); - - editor->DecRef(); - attr->DecRef(); - } - } -} - -void wxGrid::HideCellEditControl() -{ - if ( IsCellEditControlEnabled() ) - { - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - - wxGridCellAttr *attr = GetCellAttr(row, col); - wxGridCellEditor *editor = attr->GetEditor(this, row, col); - const bool editorHadFocus = editor->GetControl()->HasFocus(); - editor->Show( false ); - editor->DecRef(); - attr->DecRef(); - - // return the focus to the grid itself if the editor had it - // - // note that we must not do this unconditionally to avoid stealing - // focus from the window which just received it if we are hiding the - // editor precisely because we lost focus - if ( editorHadFocus ) - m_gridWin->SetFocus(); - - // refresh whole row to the right - wxRect rect( CellToRect(row, col) ); - CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y ); - rect.width = m_gridWin->GetClientSize().GetWidth() - rect.x; - -#ifdef __WXMAC__ - // ensure that the pixels under the focus ring get refreshed as well - rect.Inflate(10, 10); -#endif - - m_gridWin->Refresh( false, &rect ); - } -} - -void wxGrid::SaveEditControlValue() -{ - if ( IsCellEditControlEnabled() ) - { - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - - wxString oldval = GetCellValue(row, col); - - wxGridCellAttr* attr = GetCellAttr(row, col); - wxGridCellEditor* editor = attr->GetEditor(this, row, col); - - wxString newval; - bool changed = editor->EndEdit(row, col, this, oldval, &newval); - - if ( changed && SendEvent(wxEVT_GRID_CELL_CHANGING, newval) != -1 ) - { - editor->ApplyEdit(row, col, this); - - // for compatibility reasons dating back to wx 2.8 when this event - // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING - // didn't exist we allow vetoing this one too - if ( SendEvent(wxEVT_GRID_CELL_CHANGED, oldval) == -1 ) - { - // Event has been vetoed, set the data back. - SetCellValue(row, col, oldval); - } - } - - editor->DecRef(); - attr->DecRef(); - } -} - -void wxGrid::OnHideEditor(wxCommandEvent& WXUNUSED(event)) -{ - DisableCellEditControl(); -} - -// -// ------ Grid location functions -// Note that all of these functions work with the logical coordinates of -// grid cells and labels so you will need to convert from device -// coordinates for mouse events etc. -// - -wxGridCellCoords wxGrid::XYToCell(int x, int y) const -{ - int row = YToRow(y); - int col = XToCol(x); - - return row == -1 || col == -1 ? wxGridNoCellCoords - : wxGridCellCoords(row, col); -} - -// compute row or column from some (unscrolled) coordinate value, using either -// m_defaultRowHeight/m_defaultColWidth or binary search on array of -// m_rowBottoms/m_colRights to do it quickly in O(log n) time. -// NOTE: This may not work correctly for reordered columns. -int wxGrid::PosToLinePos(int coord, - bool clipToMinMax, - const wxGridOperations& oper) const -{ - const int numLines = oper.GetNumberOfLines(this); - - if ( coord < 0 ) - return clipToMinMax && numLines > 0 ? 0 : wxNOT_FOUND; - - const int defaultLineSize = oper.GetDefaultLineSize(this); - wxCHECK_MSG( defaultLineSize, -1, "can't have 0 default line size" ); - - int maxPos = coord / defaultLineSize, - minPos = 0; - - // check for the simplest case: if we have no explicit line sizes - // configured, then we already know the line this position falls in - const wxArrayInt& lineEnds = oper.GetLineEnds(this); - if ( lineEnds.empty() ) - { - if ( maxPos < numLines ) - return maxPos; - - return clipToMinMax ? numLines - 1 : -1; - } - - - // binary search is quite efficient and we can't really make any assumptions - // on where to start here since row and columns could be of size 0 if they are - // hidden. While this could be made more efficient, some profiling will be - // necessary to determine if it really is a performance bottleneck - maxPos = numLines - 1; - - // check if the position is beyond the last column - const int lineAtMaxPos = oper.GetLineAt(this, maxPos); - if ( coord >= lineEnds[lineAtMaxPos] ) - return clipToMinMax ? maxPos : -1; - - // or before the first one - const int lineAt0 = oper.GetLineAt(this, 0); - if ( coord < lineEnds[lineAt0] ) - return 0; - - - // finally do perform the binary search - while ( minPos < maxPos ) - { - wxCHECK_MSG( lineEnds[oper.GetLineAt(this, minPos)] <= coord && - coord < lineEnds[oper.GetLineAt(this, maxPos)], - -1, - "wxGrid: internal error in PosToLinePos()" ); - - if ( coord >= lineEnds[oper.GetLineAt(this, maxPos - 1)] ) - return maxPos; - else - maxPos--; - - const int median = minPos + (maxPos - minPos + 1) / 2; - if ( coord < lineEnds[oper.GetLineAt(this, median)] ) - maxPos = median; - else - minPos = median; - } - - return maxPos; -} - -int -wxGrid::PosToLine(int coord, - bool clipToMinMax, - const wxGridOperations& oper) const -{ - int pos = PosToLinePos(coord, clipToMinMax, oper); - - return pos == wxNOT_FOUND ? wxNOT_FOUND : oper.GetLineAt(this, pos); -} - -int wxGrid::YToRow(int y, bool clipToMinMax) const -{ - return PosToLine(y, clipToMinMax, wxGridRowOperations()); -} - -int wxGrid::XToCol(int x, bool clipToMinMax) const -{ - return PosToLine(x, clipToMinMax, wxGridColumnOperations()); -} - -int wxGrid::XToPos(int x) const -{ - return PosToLinePos(x, true /* clip */, wxGridColumnOperations()); -} - -// return the row/col number such that the pos is near the edge of, or -1 if -// not near an edge. -// -// notice that position can only possibly be near an edge if the row/column is -// large enough to still allow for an "inner" area that is _not_ near the edge -// (i.e., if the height/width is smaller than WXGRID_LABEL_EDGE_ZONE, pos will -// _never_ be considered to be near the edge). -int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const -{ - // Get the bottom or rightmost line that could match. - int line = oper.PosToLine(this, pos, true); - - if ( oper.GetLineSize(this, line) > WXGRID_LABEL_EDGE_ZONE ) - { - // We know that we are in this line, test whether we are close enough - // to start or end border, respectively. - if ( abs(oper.GetLineEndPos(this, line) - pos) < WXGRID_LABEL_EDGE_ZONE ) - return line; - else if ( line > 0 && - pos - oper.GetLineStartPos(this, - line) < WXGRID_LABEL_EDGE_ZONE ) - { - // We need to find the previous visible line, so skip all the - // hidden (of size 0) ones. - do - { - line = oper.GetLineBefore(this, line); - } - while ( line >= 0 && oper.GetLineSize(this, line) == 0 ); - - // It can possibly be -1 here. - return line; - } - } - - return -1; -} - -int wxGrid::YToEdgeOfRow(int y) const -{ - return PosToEdgeOfLine(y, wxGridRowOperations()); -} - -int wxGrid::XToEdgeOfCol(int x) const -{ - return PosToEdgeOfLine(x, wxGridColumnOperations()); -} - -wxRect wxGrid::CellToRect( int row, int col ) const -{ - wxRect rect( -1, -1, -1, -1 ); - - if ( row >= 0 && row < m_numRows && - col >= 0 && col < m_numCols ) - { - int i, cell_rows, cell_cols; - rect.width = rect.height = 0; - GetCellSize( row, col, &cell_rows, &cell_cols ); - // if negative then find multicell owner - if (cell_rows < 0) - row += cell_rows; - if (cell_cols < 0) - col += cell_cols; - GetCellSize( row, col, &cell_rows, &cell_cols ); - - rect.x = GetColLeft(col); - rect.y = GetRowTop(row); - for (i=col; i < col + cell_cols; i++) - rect.width += GetColWidth(i); - for (i=row; i < row + cell_rows; i++) - rect.height += GetRowHeight(i); - - // if grid lines are enabled, then the area of the cell is a bit smaller - if (m_gridLinesEnabled) - { - rect.width -= 1; - rect.height -= 1; - } - } - - return rect; -} - -bool wxGrid::IsVisible( int row, int col, bool wholeCellVisible ) const -{ - // get the cell rectangle in logical coords - // - wxRect r( CellToRect( row, col ) ); - - // convert to device coords - // - int left, top, right, bottom; - CalcScrolledPosition( r.GetLeft(), r.GetTop(), &left, &top ); - CalcScrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom ); - - // check against the client area of the grid window - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - - if ( wholeCellVisible ) - { - // is the cell wholly visible ? - return ( left >= 0 && right <= cw && - top >= 0 && bottom <= ch ); - } - else - { - // is the cell partly visible ? - // - return ( ((left >= 0 && left < cw) || (right > 0 && right <= cw)) && - ((top >= 0 && top < ch) || (bottom > 0 && bottom <= ch)) ); - } -} - -// make the specified cell location visible by doing a minimal amount -// of scrolling -// -void wxGrid::MakeCellVisible( int row, int col ) -{ - int i; - int xpos = -1, ypos = -1; - - if ( row >= 0 && row < m_numRows && - col >= 0 && col < m_numCols ) - { - // get the cell rectangle in logical coords - wxRect r( CellToRect( row, col ) ); - - // convert to device coords - int left, top, right, bottom; - CalcScrolledPosition( r.GetLeft(), r.GetTop(), &left, &top ); - CalcScrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom ); - - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - - if ( top < 0 ) - { - ypos = r.GetTop(); - } - else if ( bottom > ch ) - { - int h = r.GetHeight(); - ypos = r.GetTop(); - for ( i = row - 1; i >= 0; i-- ) - { - int rowHeight = GetRowHeight(i); - if ( h + rowHeight > ch ) - break; - - h += rowHeight; - ypos -= rowHeight; - } - - // we divide it later by GRID_SCROLL_LINE, make sure that we don't - // have rounding errors (this is important, because if we do, - // we might not scroll at all and some cells won't be redrawn) - // - // Sometimes GRID_SCROLL_LINE / 2 is not enough, - // so just add a full scroll unit... - ypos += m_yScrollPixelsPerLine; - } - - // special handling for wide cells - show always left part of the cell! - // Otherwise, e.g. when stepping from row to row, it would jump between - // left and right part of the cell on every step! -// if ( left < 0 ) - if ( left < 0 || (right - left) >= cw ) - { - xpos = r.GetLeft(); - } - else if ( right > cw ) - { - // position the view so that the cell is on the right - int x0, y0; - CalcUnscrolledPosition(0, 0, &x0, &y0); - xpos = x0 + (right - cw); - - // see comment for ypos above - xpos += m_xScrollPixelsPerLine; - } - - if ( xpos != -1 || ypos != -1 ) - { - if ( xpos != -1 ) - xpos /= m_xScrollPixelsPerLine; - if ( ypos != -1 ) - ypos /= m_yScrollPixelsPerLine; - Scroll( xpos, ypos ); - AdjustScrollbars(); - } - } -} - -// -// ------ Grid cursor movement functions -// - -bool -wxGrid::DoMoveCursor(bool expandSelection, - const wxGridDirectionOperations& diroper) -{ - if ( m_currentCellCoords == wxGridNoCellCoords ) - return false; - - if ( expandSelection ) - { - wxGridCellCoords coords = m_selectedBlockCorner; - if ( coords == wxGridNoCellCoords ) - coords = m_currentCellCoords; - - if ( diroper.IsAtBoundary(coords) ) - return false; - - diroper.Advance(coords); - - UpdateBlockBeingSelected(m_currentCellCoords, coords); - } - else // don't expand selection - { - ClearSelection(); - - if ( diroper.IsAtBoundary(m_currentCellCoords) ) - return false; - - wxGridCellCoords coords = m_currentCellCoords; - diroper.Advance(coords); - - GoToCell(coords); - } - - return true; -} - -bool wxGrid::MoveCursorUp(bool expandSelection) -{ - return DoMoveCursor(expandSelection, - wxGridBackwardOperations(this, wxGridRowOperations())); -} - -bool wxGrid::MoveCursorDown(bool expandSelection) -{ - return DoMoveCursor(expandSelection, - wxGridForwardOperations(this, wxGridRowOperations())); -} - -bool wxGrid::MoveCursorLeft(bool expandSelection) -{ - return DoMoveCursor(expandSelection, - wxGridBackwardOperations(this, wxGridColumnOperations())); -} - -bool wxGrid::MoveCursorRight(bool expandSelection) -{ - return DoMoveCursor(expandSelection, - wxGridForwardOperations(this, wxGridColumnOperations())); -} - -bool wxGrid::DoMoveCursorByPage(const wxGridDirectionOperations& diroper) -{ - if ( m_currentCellCoords == wxGridNoCellCoords ) - return false; - - if ( diroper.IsAtBoundary(m_currentCellCoords) ) - return false; - - const int oldRow = m_currentCellCoords.GetRow(); - int newRow = diroper.MoveByPixelDistance(oldRow, m_gridWin->GetClientSize().y); - if ( newRow == oldRow ) - { - wxGridCellCoords coords(m_currentCellCoords); - diroper.Advance(coords); - newRow = coords.GetRow(); - } - - GoToCell(newRow, m_currentCellCoords.GetCol()); - - return true; -} - -bool wxGrid::MovePageUp() -{ - return DoMoveCursorByPage( - wxGridBackwardOperations(this, wxGridRowOperations())); -} - -bool wxGrid::MovePageDown() -{ - return DoMoveCursorByPage( - wxGridForwardOperations(this, wxGridRowOperations())); -} - -// helper of DoMoveCursorByBlock(): advance the cell coordinates using diroper -// until we find a non-empty cell or reach the grid end -void -wxGrid::AdvanceToNextNonEmpty(wxGridCellCoords& coords, - const wxGridDirectionOperations& diroper) -{ - while ( !diroper.IsAtBoundary(coords) ) - { - diroper.Advance(coords); - if ( !m_table->IsEmpty(coords) ) - break; - } -} - -bool -wxGrid::DoMoveCursorByBlock(bool expandSelection, - const wxGridDirectionOperations& diroper) -{ - if ( !m_table || m_currentCellCoords == wxGridNoCellCoords ) - return false; - - if ( diroper.IsAtBoundary(m_currentCellCoords) ) - return false; - - wxGridCellCoords coords(m_currentCellCoords); - if ( m_table->IsEmpty(coords) ) - { - // we are in an empty cell: find the next block of non-empty cells - AdvanceToNextNonEmpty(coords, diroper); - } - else // current cell is not empty - { - diroper.Advance(coords); - if ( m_table->IsEmpty(coords) ) - { - // we started at the end of a block, find the next one - AdvanceToNextNonEmpty(coords, diroper); - } - else // we're in a middle of a block - { - // go to the end of it, i.e. find the last cell before the next - // empty one - while ( !diroper.IsAtBoundary(coords) ) - { - wxGridCellCoords coordsNext(coords); - diroper.Advance(coordsNext); - if ( m_table->IsEmpty(coordsNext) ) - break; - - coords = coordsNext; - } - } - } - - if ( expandSelection ) - { - UpdateBlockBeingSelected(m_currentCellCoords, coords); - } - else - { - ClearSelection(); - GoToCell(coords); - } - - return true; -} - -bool wxGrid::MoveCursorUpBlock(bool expandSelection) -{ - return DoMoveCursorByBlock( - expandSelection, - wxGridBackwardOperations(this, wxGridRowOperations()) - ); -} - -bool wxGrid::MoveCursorDownBlock( bool expandSelection ) -{ - return DoMoveCursorByBlock( - expandSelection, - wxGridForwardOperations(this, wxGridRowOperations()) - ); -} - -bool wxGrid::MoveCursorLeftBlock( bool expandSelection ) -{ - return DoMoveCursorByBlock( - expandSelection, - wxGridBackwardOperations(this, wxGridColumnOperations()) - ); -} - -bool wxGrid::MoveCursorRightBlock( bool expandSelection ) -{ - return DoMoveCursorByBlock( - expandSelection, - wxGridForwardOperations(this, wxGridColumnOperations()) - ); -} - -// -// ------ Label values and formatting -// - -void wxGrid::GetRowLabelAlignment( int *horiz, int *vert ) const -{ - if ( horiz ) - *horiz = m_rowLabelHorizAlign; - if ( vert ) - *vert = m_rowLabelVertAlign; -} - -void wxGrid::GetColLabelAlignment( int *horiz, int *vert ) const -{ - if ( horiz ) - *horiz = m_colLabelHorizAlign; - if ( vert ) - *vert = m_colLabelVertAlign; -} - -int wxGrid::GetColLabelTextOrientation() const -{ - return m_colLabelTextOrientation; -} - -wxString wxGrid::GetRowLabelValue( int row ) const -{ - if ( m_table ) - { - return m_table->GetRowLabelValue( row ); - } - else - { - wxString s; - s << row; - return s; - } -} - -wxString wxGrid::GetColLabelValue( int col ) const -{ - if ( m_table ) - { - return m_table->GetColLabelValue( col ); - } - else - { - wxString s; - s << col; - return s; - } -} - -void wxGrid::SetRowLabelSize( int width ) -{ - wxASSERT( width >= 0 || width == wxGRID_AUTOSIZE ); - - if ( width == wxGRID_AUTOSIZE ) - { - width = CalcColOrRowLabelAreaMinSize(wxGRID_ROW); - } - - if ( width != m_rowLabelWidth ) - { - if ( width == 0 ) - { - m_rowLabelWin->Show( false ); - m_cornerLabelWin->Show( false ); - } - else if ( m_rowLabelWidth == 0 ) - { - m_rowLabelWin->Show( true ); - if ( m_colLabelHeight > 0 ) - m_cornerLabelWin->Show( true ); - } - - m_rowLabelWidth = width; - InvalidateBestSize(); - CalcWindowSizes(); - wxScrolledWindow::Refresh( true ); - } -} - -void wxGrid::SetColLabelSize( int height ) -{ - wxASSERT( height >=0 || height == wxGRID_AUTOSIZE ); - - if ( height == wxGRID_AUTOSIZE ) - { - height = CalcColOrRowLabelAreaMinSize(wxGRID_COLUMN); - } - - if ( height != m_colLabelHeight ) - { - if ( height == 0 ) - { - m_colWindow->Show( false ); - m_cornerLabelWin->Show( false ); - } - else if ( m_colLabelHeight == 0 ) - { - m_colWindow->Show( true ); - if ( m_rowLabelWidth > 0 ) - m_cornerLabelWin->Show( true ); - } - - m_colLabelHeight = height; - InvalidateBestSize(); - CalcWindowSizes(); - wxScrolledWindow::Refresh( true ); - } -} - -void wxGrid::SetLabelBackgroundColour( const wxColour& colour ) -{ - if ( m_labelBackgroundColour != colour ) - { - m_labelBackgroundColour = colour; - m_rowLabelWin->SetBackgroundColour( colour ); - m_colWindow->SetBackgroundColour( colour ); - m_cornerLabelWin->SetBackgroundColour( colour ); - - if ( !GetBatchCount() ) - { - m_rowLabelWin->Refresh(); - m_colWindow->Refresh(); - m_cornerLabelWin->Refresh(); - } - } -} - -void wxGrid::SetLabelTextColour( const wxColour& colour ) -{ - if ( m_labelTextColour != colour ) - { - m_labelTextColour = colour; - if ( !GetBatchCount() ) - { - m_rowLabelWin->Refresh(); - m_colWindow->Refresh(); - } - } -} - -void wxGrid::SetLabelFont( const wxFont& font ) -{ - m_labelFont = font; - if ( !GetBatchCount() ) - { - m_rowLabelWin->Refresh(); - m_colWindow->Refresh(); - } -} - -void wxGrid::SetRowLabelAlignment( int horiz, int vert ) -{ - // allow old (incorrect) defs to be used - switch ( horiz ) - { - case wxLEFT: horiz = wxALIGN_LEFT; break; - case wxRIGHT: horiz = wxALIGN_RIGHT; break; - case wxCENTRE: horiz = wxALIGN_CENTRE; break; - } - - switch ( vert ) - { - case wxTOP: vert = wxALIGN_TOP; break; - case wxBOTTOM: vert = wxALIGN_BOTTOM; break; - case wxCENTRE: vert = wxALIGN_CENTRE; break; - } - - if ( horiz == wxALIGN_LEFT || horiz == wxALIGN_CENTRE || horiz == wxALIGN_RIGHT ) - { - m_rowLabelHorizAlign = horiz; - } - - if ( vert == wxALIGN_TOP || vert == wxALIGN_CENTRE || vert == wxALIGN_BOTTOM ) - { - m_rowLabelVertAlign = vert; - } - - if ( !GetBatchCount() ) - { - m_rowLabelWin->Refresh(); - } -} - -void wxGrid::SetColLabelAlignment( int horiz, int vert ) -{ - // allow old (incorrect) defs to be used - switch ( horiz ) - { - case wxLEFT: horiz = wxALIGN_LEFT; break; - case wxRIGHT: horiz = wxALIGN_RIGHT; break; - case wxCENTRE: horiz = wxALIGN_CENTRE; break; - } - - switch ( vert ) - { - case wxTOP: vert = wxALIGN_TOP; break; - case wxBOTTOM: vert = wxALIGN_BOTTOM; break; - case wxCENTRE: vert = wxALIGN_CENTRE; break; - } - - if ( horiz == wxALIGN_LEFT || horiz == wxALIGN_CENTRE || horiz == wxALIGN_RIGHT ) - { - m_colLabelHorizAlign = horiz; - } - - if ( vert == wxALIGN_TOP || vert == wxALIGN_CENTRE || vert == wxALIGN_BOTTOM ) - { - m_colLabelVertAlign = vert; - } - - if ( !GetBatchCount() ) - { - m_colWindow->Refresh(); - } -} - -// Note: under MSW, the default column label font must be changed because it -// does not support vertical printing -// -// Example: wxFont font(9, wxSWISS, wxNORMAL, wxBOLD); -// pGrid->SetLabelFont(font); -// pGrid->SetColLabelTextOrientation(wxVERTICAL); -// -void wxGrid::SetColLabelTextOrientation( int textOrientation ) -{ - if ( textOrientation == wxHORIZONTAL || textOrientation == wxVERTICAL ) - m_colLabelTextOrientation = textOrientation; - - if ( !GetBatchCount() ) - m_colWindow->Refresh(); -} - -void wxGrid::SetRowLabelValue( int row, const wxString& s ) -{ - if ( m_table ) - { - m_table->SetRowLabelValue( row, s ); - if ( !GetBatchCount() ) - { - wxRect rect = CellToRect( row, 0 ); - if ( rect.height > 0 ) - { - CalcScrolledPosition(0, rect.y, &rect.x, &rect.y); - rect.x = 0; - rect.width = m_rowLabelWidth; - m_rowLabelWin->Refresh( true, &rect ); - } - } - } -} - -void wxGrid::SetColLabelValue( int col, const wxString& s ) -{ - if ( m_table ) - { - m_table->SetColLabelValue( col, s ); - if ( !GetBatchCount() ) - { - if ( m_useNativeHeader ) - { - GetGridColHeader()->UpdateColumn(col); - } - else - { - wxRect rect = CellToRect( 0, col ); - if ( rect.width > 0 ) - { - CalcScrolledPosition(rect.x, 0, &rect.x, &rect.y); - rect.y = 0; - rect.height = m_colLabelHeight; - GetColLabelWindow()->Refresh( true, &rect ); - } - } - } - } -} - -void wxGrid::SetGridLineColour( const wxColour& colour ) -{ - if ( m_gridLineColour != colour ) - { - m_gridLineColour = colour; - - if ( GridLinesEnabled() ) - RedrawGridLines(); - } -} - -void wxGrid::SetCellHighlightColour( const wxColour& colour ) -{ - if ( m_cellHighlightColour != colour ) - { - m_cellHighlightColour = colour; - - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); - wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords); - DrawCellHighlight(dc, attr); - attr->DecRef(); - } -} - -void wxGrid::SetCellHighlightPenWidth(int width) -{ - if (m_cellHighlightPenWidth != width) - { - m_cellHighlightPenWidth = width; - - // Just redrawing the cell highlight is not enough since that won't - // make any visible change if the thickness is getting smaller. - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - if ( row == -1 || col == -1 || GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) - return; - - wxRect rect = CellToRect(row, col); - m_gridWin->Refresh(true, &rect); - } -} - -void wxGrid::SetCellHighlightROPenWidth(int width) -{ - if (m_cellHighlightROPenWidth != width) - { - m_cellHighlightROPenWidth = width; - - // Just redrawing the cell highlight is not enough since that won't - // make any visible change if the thickness is getting smaller. - int row = m_currentCellCoords.GetRow(); - int col = m_currentCellCoords.GetCol(); - if ( row == -1 || col == -1 || - GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) - return; - - wxRect rect = CellToRect(row, col); - m_gridWin->Refresh(true, &rect); - } -} - -void wxGrid::RedrawGridLines() -{ - // the lines will be redrawn when the window is thawn - if ( GetBatchCount() ) - return; - - if ( GridLinesEnabled() ) - { - wxClientDC dc( m_gridWin ); - PrepareDC( dc ); - DrawAllGridLines( dc, wxRegion() ); - } - else // remove the grid lines - { - m_gridWin->Refresh(); - } -} - -void wxGrid::EnableGridLines( bool enable ) -{ - if ( enable != m_gridLinesEnabled ) - { - m_gridLinesEnabled = enable; - - RedrawGridLines(); - } -} - -void wxGrid::DoClipGridLines(bool& var, bool clip) -{ - if ( clip != var ) - { - var = clip; - - if ( GridLinesEnabled() ) - RedrawGridLines(); - } -} - -int wxGrid::GetDefaultRowSize() const -{ - return m_defaultRowHeight; -} - -int wxGrid::GetRowSize( int row ) const -{ - wxCHECK_MSG( row >= 0 && row < m_numRows, 0, wxT("invalid row index") ); - - return GetRowHeight(row); -} - -int wxGrid::GetDefaultColSize() const -{ - return m_defaultColWidth; -} - -int wxGrid::GetColSize( int col ) const -{ - wxCHECK_MSG( col >= 0 && col < m_numCols, 0, wxT("invalid column index") ); - - return GetColWidth(col); -} - -// ============================================================================ -// access to the grid attributes: each of them has a default value in the grid -// itself and may be overidden on a per-cell basis -// ============================================================================ - -// ---------------------------------------------------------------------------- -// setting default attributes -// ---------------------------------------------------------------------------- - -void wxGrid::SetDefaultCellBackgroundColour( const wxColour& col ) -{ - m_defaultCellAttr->SetBackgroundColour(col); -#ifdef __WXGTK__ - m_gridWin->SetBackgroundColour(col); -#endif -} - -void wxGrid::SetDefaultCellTextColour( const wxColour& col ) -{ - m_defaultCellAttr->SetTextColour(col); -} - -void wxGrid::SetDefaultCellAlignment( int horiz, int vert ) -{ - m_defaultCellAttr->SetAlignment(horiz, vert); -} - -void wxGrid::SetDefaultCellOverflow( bool allow ) -{ - m_defaultCellAttr->SetOverflow(allow); -} - -void wxGrid::SetDefaultCellFont( const wxFont& font ) -{ - m_defaultCellAttr->SetFont(font); -} - -// For editors and renderers the type registry takes precedence over the -// default attr, so we need to register the new editor/renderer for the string -// data type in order to make setting a default editor/renderer appear to -// work correctly. - -void wxGrid::SetDefaultRenderer(wxGridCellRenderer *renderer) -{ - RegisterDataType(wxGRID_VALUE_STRING, - renderer, - GetDefaultEditorForType(wxGRID_VALUE_STRING)); -} - -void wxGrid::SetDefaultEditor(wxGridCellEditor *editor) -{ - RegisterDataType(wxGRID_VALUE_STRING, - GetDefaultRendererForType(wxGRID_VALUE_STRING), - editor); -} - -// ---------------------------------------------------------------------------- -// access to the default attributes -// ---------------------------------------------------------------------------- - -wxColour wxGrid::GetDefaultCellBackgroundColour() const -{ - return m_defaultCellAttr->GetBackgroundColour(); -} - -wxColour wxGrid::GetDefaultCellTextColour() const -{ - return m_defaultCellAttr->GetTextColour(); -} - -wxFont wxGrid::GetDefaultCellFont() const -{ - return m_defaultCellAttr->GetFont(); -} - -void wxGrid::GetDefaultCellAlignment( int *horiz, int *vert ) const -{ - m_defaultCellAttr->GetAlignment(horiz, vert); -} - -bool wxGrid::GetDefaultCellOverflow() const -{ - return m_defaultCellAttr->GetOverflow(); -} - -wxGridCellRenderer *wxGrid::GetDefaultRenderer() const -{ - return m_defaultCellAttr->GetRenderer(NULL, 0, 0); -} - -wxGridCellEditor *wxGrid::GetDefaultEditor() const -{ - return m_defaultCellAttr->GetEditor(NULL, 0, 0); -} - -// ---------------------------------------------------------------------------- -// access to cell attributes -// ---------------------------------------------------------------------------- - -wxColour wxGrid::GetCellBackgroundColour(int row, int col) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - wxColour colour = attr->GetBackgroundColour(); - attr->DecRef(); - - return colour; -} - -wxColour wxGrid::GetCellTextColour( int row, int col ) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - wxColour colour = attr->GetTextColour(); - attr->DecRef(); - - return colour; -} - -wxFont wxGrid::GetCellFont( int row, int col ) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - wxFont font = attr->GetFont(); - attr->DecRef(); - - return font; -} - -void wxGrid::GetCellAlignment( int row, int col, int *horiz, int *vert ) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - attr->GetAlignment(horiz, vert); - attr->DecRef(); -} - -bool wxGrid::GetCellOverflow( int row, int col ) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - bool allow = attr->GetOverflow(); - attr->DecRef(); - - return allow; -} - -wxGrid::CellSpan -wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const -{ - wxGridCellAttr *attr = GetCellAttr(row, col); - attr->GetSize( num_rows, num_cols ); - attr->DecRef(); - - if ( *num_rows == 1 && *num_cols == 1 ) - return CellSpan_None; // just a normal cell - - if ( *num_rows < 0 || *num_cols < 0 ) - return CellSpan_Inside; // covered by a multi-span cell - - // this cell spans multiple cells to its right/bottom - return CellSpan_Main; -} - -wxGridCellRenderer* wxGrid::GetCellRenderer(int row, int col) const -{ - wxGridCellAttr* attr = GetCellAttr(row, col); - wxGridCellRenderer* renderer = attr->GetRenderer(this, row, col); - attr->DecRef(); - - return renderer; -} - -wxGridCellEditor* wxGrid::GetCellEditor(int row, int col) const -{ - wxGridCellAttr* attr = GetCellAttr(row, col); - wxGridCellEditor* editor = attr->GetEditor(this, row, col); - attr->DecRef(); - - return editor; -} - -bool wxGrid::IsReadOnly(int row, int col) const -{ - wxGridCellAttr* attr = GetCellAttr(row, col); - bool isReadOnly = attr->IsReadOnly(); - attr->DecRef(); - - return isReadOnly; -} - -// ---------------------------------------------------------------------------- -// attribute support: cache, automatic provider creation, ... -// ---------------------------------------------------------------------------- - -bool wxGrid::CanHaveAttributes() const -{ - if ( !m_table ) - { - return false; - } - - return m_table->CanHaveAttributes(); -} - -void wxGrid::ClearAttrCache() -{ - if ( m_attrCache.row != -1 ) - { - wxGridCellAttr *oldAttr = m_attrCache.attr; - m_attrCache.attr = NULL; - m_attrCache.row = -1; - // wxSafeDecRec(...) might cause event processing that accesses - // the cached attribute, if one exists (e.g. by deleting the - // editor stored within the attribute). Therefore it is important - // to invalidate the cache before calling wxSafeDecRef! - wxSafeDecRef(oldAttr); - } -} - -void wxGrid::RefreshAttr(int row, int col) -{ - if ( m_attrCache.row == row && m_attrCache.col == col ) - ClearAttrCache(); -} - - -void wxGrid::CacheAttr(int row, int col, wxGridCellAttr *attr) const -{ - if ( attr != NULL ) - { - wxGrid * const self = const_cast(this); - - self->ClearAttrCache(); - self->m_attrCache.row = row; - self->m_attrCache.col = col; - self->m_attrCache.attr = attr; - wxSafeIncRef(attr); - } -} - -bool wxGrid::LookupAttr(int row, int col, wxGridCellAttr **attr) const -{ - if ( row == m_attrCache.row && col == m_attrCache.col ) - { - *attr = m_attrCache.attr; - wxSafeIncRef(m_attrCache.attr); - -#ifdef DEBUG_ATTR_CACHE - gs_nAttrCacheHits++; -#endif - - return true; - } - else - { -#ifdef DEBUG_ATTR_CACHE - gs_nAttrCacheMisses++; -#endif - - return false; - } -} - -wxGridCellAttr *wxGrid::GetCellAttr(int row, int col) const -{ - wxGridCellAttr *attr = NULL; - // Additional test to avoid looking at the cache e.g. for - // wxNoCellCoords, as this will confuse memory management. - if ( row >= 0 ) - { - if ( !LookupAttr(row, col, &attr) ) - { - attr = m_table ? m_table->GetAttr(row, col, wxGridCellAttr::Any) - : NULL; - CacheAttr(row, col, attr); - } - } - - if (attr) - { - attr->SetDefAttr(m_defaultCellAttr); - } - else - { - attr = m_defaultCellAttr; - attr->IncRef(); - } - - return attr; -} - -wxGridCellAttr *wxGrid::GetOrCreateCellAttr(int row, int col) const -{ - wxGridCellAttr *attr = NULL; - bool canHave = ((wxGrid*)this)->CanHaveAttributes(); - - wxCHECK_MSG( canHave, attr, wxT("Cell attributes not allowed")); - wxCHECK_MSG( m_table, attr, wxT("must have a table") ); - - attr = m_table->GetAttr(row, col, wxGridCellAttr::Cell); - if ( !attr ) - { - attr = new wxGridCellAttr(m_defaultCellAttr); - - // artificially inc the ref count to match DecRef() in caller - attr->IncRef(); - m_table->SetAttr(attr, row, col); - } - - return attr; -} - -// ---------------------------------------------------------------------------- -// setting column attributes (wrappers around SetColAttr) -// ---------------------------------------------------------------------------- - -void wxGrid::SetColFormatBool(int col) -{ - SetColFormatCustom(col, wxGRID_VALUE_BOOL); -} - -void wxGrid::SetColFormatNumber(int col) -{ - SetColFormatCustom(col, wxGRID_VALUE_NUMBER); -} - -void wxGrid::SetColFormatFloat(int col, int width, int precision) -{ - wxString typeName = wxGRID_VALUE_FLOAT; - if ( (width != -1) || (precision != -1) ) - { - typeName << wxT(':') << width << wxT(',') << precision; - } - - SetColFormatCustom(col, typeName); -} - -void wxGrid::SetColFormatCustom(int col, const wxString& typeName) -{ - wxGridCellAttr *attr = m_table->GetAttr(-1, col, wxGridCellAttr::Col ); - if (!attr) - attr = new wxGridCellAttr; - wxGridCellRenderer *renderer = GetDefaultRendererForType(typeName); - attr->SetRenderer(renderer); - wxGridCellEditor *editor = GetDefaultEditorForType(typeName); - attr->SetEditor(editor); - - SetColAttr(col, attr); - -} - -// ---------------------------------------------------------------------------- -// setting cell attributes: this is forwarded to the table -// ---------------------------------------------------------------------------- - -void wxGrid::SetAttr(int row, int col, wxGridCellAttr *attr) -{ - if ( CanHaveAttributes() ) - { - m_table->SetAttr(attr, row, col); - ClearAttrCache(); - } - else - { - wxSafeDecRef(attr); - } -} - -void wxGrid::SetRowAttr(int row, wxGridCellAttr *attr) -{ - if ( CanHaveAttributes() ) - { - m_table->SetRowAttr(attr, row); - ClearAttrCache(); - } - else - { - wxSafeDecRef(attr); - } -} - -void wxGrid::SetColAttr(int col, wxGridCellAttr *attr) -{ - if ( CanHaveAttributes() ) - { - m_table->SetColAttr(attr, col); - ClearAttrCache(); - } - else - { - wxSafeDecRef(attr); - } -} - -void wxGrid::SetCellBackgroundColour( int row, int col, const wxColour& colour ) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetBackgroundColour(colour); - attr->DecRef(); - } -} - -void wxGrid::SetCellTextColour( int row, int col, const wxColour& colour ) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetTextColour(colour); - attr->DecRef(); - } -} - -void wxGrid::SetCellFont( int row, int col, const wxFont& font ) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetFont(font); - attr->DecRef(); - } -} - -void wxGrid::SetCellAlignment( int row, int col, int horiz, int vert ) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetAlignment(horiz, vert); - attr->DecRef(); - } -} - -void wxGrid::SetCellOverflow( int row, int col, bool allow ) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetOverflow(allow); - attr->DecRef(); - } -} - -void wxGrid::SetCellSize( int row, int col, int num_rows, int num_cols ) -{ - if ( CanHaveAttributes() ) - { - int cell_rows, cell_cols; - - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->GetSize(&cell_rows, &cell_cols); - attr->SetSize(num_rows, num_cols); - attr->DecRef(); - - // Cannot set the size of a cell to 0 or negative values - // While it is perfectly legal to do that, this function cannot - // handle all the possibilies, do it by hand by getting the CellAttr. - // You can only set the size of a cell to 1,1 or greater with this fn - wxASSERT_MSG( !((cell_rows < 1) || (cell_cols < 1)), - wxT("wxGrid::SetCellSize setting cell size that is already part of another cell")); - wxASSERT_MSG( !((num_rows < 1) || (num_cols < 1)), - wxT("wxGrid::SetCellSize setting cell size to < 1")); - - // if this was already a multicell then "turn off" the other cells first - if ((cell_rows > 1) || (cell_cols > 1)) - { - int i, j; - for (j=row; j < row + cell_rows; j++) - { - for (i=col; i < col + cell_cols; i++) - { - if ((i != col) || (j != row)) - { - wxGridCellAttr *attr_stub = GetOrCreateCellAttr(j, i); - attr_stub->SetSize( 1, 1 ); - attr_stub->DecRef(); - } - } - } - } - - // mark the cells that will be covered by this cell to - // negative or zero values to point back at this cell - if (((num_rows > 1) || (num_cols > 1)) && (num_rows >= 1) && (num_cols >= 1)) - { - int i, j; - for (j=row; j < row + num_rows; j++) - { - for (i=col; i < col + num_cols; i++) - { - if ((i != col) || (j != row)) - { - wxGridCellAttr *attr_stub = GetOrCreateCellAttr(j, i); - attr_stub->SetSize( row - j, col - i ); - attr_stub->DecRef(); - } - } - } - } - } -} - -void wxGrid::SetCellRenderer(int row, int col, wxGridCellRenderer *renderer) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetRenderer(renderer); - attr->DecRef(); - } -} - -void wxGrid::SetCellEditor(int row, int col, wxGridCellEditor* editor) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetEditor(editor); - attr->DecRef(); - } -} - -void wxGrid::SetReadOnly(int row, int col, bool isReadOnly) -{ - if ( CanHaveAttributes() ) - { - wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); - attr->SetReadOnly(isReadOnly); - attr->DecRef(); - } -} - -// ---------------------------------------------------------------------------- -// Data type registration -// ---------------------------------------------------------------------------- - -void wxGrid::RegisterDataType(const wxString& typeName, - wxGridCellRenderer* renderer, - wxGridCellEditor* editor) -{ - m_typeRegistry->RegisterDataType(typeName, renderer, editor); -} - - -wxGridCellEditor * wxGrid::GetDefaultEditorForCell(int row, int col) const -{ - wxString typeName = m_table->GetTypeName(row, col); - return GetDefaultEditorForType(typeName); -} - -wxGridCellRenderer * wxGrid::GetDefaultRendererForCell(int row, int col) const -{ - wxString typeName = m_table->GetTypeName(row, col); - return GetDefaultRendererForType(typeName); -} - -wxGridCellEditor * wxGrid::GetDefaultEditorForType(const wxString& typeName) const -{ - int index = m_typeRegistry->FindOrCloneDataType(typeName); - if ( index == wxNOT_FOUND ) - { - wxFAIL_MSG(wxString::Format(wxT("Unknown data type name [%s]"), typeName.c_str())); - - return NULL; - } - - return m_typeRegistry->GetEditor(index); -} - -wxGridCellRenderer * wxGrid::GetDefaultRendererForType(const wxString& typeName) const -{ - int index = m_typeRegistry->FindOrCloneDataType(typeName); - if ( index == wxNOT_FOUND ) - { - wxFAIL_MSG(wxString::Format(wxT("Unknown data type name [%s]"), typeName.c_str())); - - return NULL; - } - - return m_typeRegistry->GetRenderer(index); -} - -// ---------------------------------------------------------------------------- -// row/col size -// ---------------------------------------------------------------------------- - -void wxGrid::DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed) -{ - if ( !setFixed ) - { - setFixed = new wxGridFixedIndicesSet; - } - - setFixed->insert(line); -} - -bool -wxGrid::DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const -{ - return !setFixed || !setFixed->count(line); -} - -void wxGrid::EnableDragRowSize( bool enable ) -{ - m_canDragRowSize = enable; -} - -void wxGrid::EnableDragColSize( bool enable ) -{ - m_canDragColSize = enable; -} - -void wxGrid::EnableDragGridSize( bool enable ) -{ - m_canDragGridSize = enable; -} - -void wxGrid::EnableDragCell( bool enable ) -{ - m_canDragCell = enable; -} - -void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows ) -{ - m_defaultRowHeight = wxMax( height, m_minAcceptableRowHeight ); - - if ( resizeExistingRows ) - { - // since we are resizing all rows to the default row size, - // we can simply clear the row heights and row bottoms - // arrays (which also allows us to take advantage of - // some speed optimisations) - m_rowHeights.Empty(); - m_rowBottoms.Empty(); - if ( !GetBatchCount() ) - CalcDimensions(); - } -} - -namespace -{ - -// This is a common part of SetRowSize() and SetColSize() which takes care of -// updating the height/width of a row/column depending on its current value and -// the new one. -// -// Returns the difference between the new and the old size. -int UpdateRowOrColSize(int& sizeCurrent, int sizeNew) -{ - // On input here sizeCurrent can be negative if it's currently hidden (the - // real size is its absolute value then). And sizeNew can be 0 to indicate - // that the row/column should be hidden or -1 to indicate that it should be - // shown again. - - if ( sizeNew < 0 ) - { - // We're showing back a previously hidden row/column. - wxASSERT_MSG( sizeNew == -1, wxS("New size must be positive or -1.") ); - - // If it's already visible, simply do nothing. - if ( sizeCurrent >= 0 ) - return 0; - - // Otherwise show it by restoring its old size. - sizeCurrent = -sizeCurrent; - - // This is positive which is correct. - return sizeCurrent; - } - else if ( sizeNew == 0 ) - { - // We're hiding a row/column. - - // If it's already hidden, simply do nothing. - if ( sizeCurrent <= 0 ) - return 0; - - // Otherwise hide it and also remember the shown size to be able to - // restore it later. - sizeCurrent = -sizeCurrent; - - // This is negative which is correct. - return sizeCurrent; - } - else // We're just changing the row/column size. - { - // Here it could have been hidden or not previously. - const int sizeOld = sizeCurrent < 0 ? 0 : sizeCurrent; - - sizeCurrent = sizeNew; - - return sizeCurrent - sizeOld; - } -} - -} // anonymous namespace - -void wxGrid::SetRowSize( int row, int height ) -{ - // See comment in SetColSize - if ( height > 0 && height < GetRowMinimalAcceptableHeight()) - return; - - // The value of -1 is special and means to fit the height to the row label. - // As with the columns, ignore attempts to auto-size the hidden rows. - if ( height == -1 && GetRowHeight(row) != 0 ) - { - long w, h; - wxArrayString lines; - wxClientDC dc(m_rowLabelWin); - dc.SetFont(GetLabelFont()); - StringToLines(GetRowLabelValue( row ), lines); - GetTextBoxSize( dc, lines, &w, &h ); - - // As with the columns, don't make the row smaller than minimal height. - height = wxMax(h, GetRowMinimalHeight(row)); - } - - DoSetRowSize(row, height); -} - -void wxGrid::DoSetRowSize( int row, int height ) -{ - wxCHECK_RET( row >= 0 && row < m_numRows, wxT("invalid row index") ); - - if ( m_rowHeights.IsEmpty() ) - { - // need to really create the array - InitRowHeights(); - } - - const int diff = UpdateRowOrColSize(m_rowHeights[row], height); - if ( !diff ) - return; - - for ( int i = row; i < m_numRows; i++ ) - { - m_rowBottoms[i] += diff; - } - - InvalidateBestSize(); - - if ( !GetBatchCount() ) - { - CalcDimensions(); - Refresh(); - } -} - -void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols ) -{ - // we dont allow zero default column width - m_defaultColWidth = wxMax( wxMax( width, m_minAcceptableColWidth ), 1 ); - - if ( resizeExistingCols ) - { - // since we are resizing all columns to the default column size, - // we can simply clear the col widths and col rights - // arrays (which also allows us to take advantage of - // some speed optimisations) - m_colWidths.Empty(); - m_colRights.Empty(); - if ( !GetBatchCount() ) - CalcDimensions(); - } -} - -void wxGrid::SetColSize( int col, int width ) -{ - // we intentionally don't test whether the width is less than - // GetColMinimalWidth() here but we do compare it with - // GetColMinimalAcceptableWidth() as otherwise things currently break (see - // #651) -- and we also always allow the width of 0 as it has the special - // sense of hiding the column - if ( width > 0 && width < GetColMinimalAcceptableWidth() ) - return; - - // The value of -1 is special and means to fit the width to the column label. - // - // Notice that we currently don't support auto-sizing hidden columns (we - // could, but it's not clear whether this is really needed and it would - // make the code more complex), and for them passing -1 simply means to - // show the column back using its old size. - if ( width == -1 && GetColWidth(col) != 0 ) - { - long w, h; - wxArrayString lines; - wxClientDC dc(m_colWindow); - dc.SetFont(GetLabelFont()); - StringToLines(GetColLabelValue(col), lines); - if ( GetColLabelTextOrientation() == wxHORIZONTAL ) - GetTextBoxSize( dc, lines, &w, &h ); - else - GetTextBoxSize( dc, lines, &h, &w ); - width = w + 6; - - // Check that it is not less than the minimal width and do use the - // possibly greater than minimal-acceptable-width minimal-width itself - // here as we shouldn't become too small when auto-sizing, otherwise - // the column could be resized to be too small by double clicking its - // divider line (which ends up in a call to this function) even though - // it couldn't be resized to this size by dragging it. - width = wxMax(width, GetColMinimalWidth(col)); - } - - DoSetColSize(col, width); -} - -void wxGrid::DoSetColSize( int col, int width ) -{ - wxCHECK_RET( col >= 0 && col < m_numCols, wxT("invalid column index") ); - - if ( m_colWidths.IsEmpty() ) - { - // need to really create the array - InitColWidths(); - } - - const int diff = UpdateRowOrColSize(m_colWidths[col], width); - if ( !diff ) - return; - - if ( m_useNativeHeader ) - GetGridColHeader()->UpdateColumn(col); - //else: will be refreshed when the header is redrawn - - for ( int colPos = GetColPos(col); colPos < m_numCols; colPos++ ) - { - m_colRights[GetColAt(colPos)] += diff; - } - - InvalidateBestSize(); - - if ( !GetBatchCount() ) - { - CalcDimensions(); - Refresh(); - } -} - -void wxGrid::SetColMinimalWidth( int col, int width ) -{ - if (width > GetColMinimalAcceptableWidth()) - { - wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)col; - m_colMinWidths[key] = width; - } -} - -void wxGrid::SetRowMinimalHeight( int row, int width ) -{ - if (width > GetRowMinimalAcceptableHeight()) - { - wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)row; - m_rowMinHeights[key] = width; - } -} - -int wxGrid::GetColMinimalWidth(int col) const -{ - wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)col; - wxLongToLongHashMap::const_iterator it = m_colMinWidths.find(key); - - return it != m_colMinWidths.end() ? (int)it->second : m_minAcceptableColWidth; -} - -int wxGrid::GetRowMinimalHeight(int row) const -{ - wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)row; - wxLongToLongHashMap::const_iterator it = m_rowMinHeights.find(key); - - return it != m_rowMinHeights.end() ? (int)it->second : m_minAcceptableRowHeight; -} - -void wxGrid::SetColMinimalAcceptableWidth( int width ) -{ - // We do allow a width of 0 since this gives us - // an easy way to temporarily hiding columns. - if ( width >= 0 ) - m_minAcceptableColWidth = width; -} - -void wxGrid::SetRowMinimalAcceptableHeight( int height ) -{ - // We do allow a height of 0 since this gives us - // an easy way to temporarily hiding rows. - if ( height >= 0 ) - m_minAcceptableRowHeight = height; -} - -int wxGrid::GetColMinimalAcceptableWidth() const -{ - return m_minAcceptableColWidth; -} - -int wxGrid::GetRowMinimalAcceptableHeight() const -{ - return m_minAcceptableRowHeight; -} - -// ---------------------------------------------------------------------------- -// auto sizing -// ---------------------------------------------------------------------------- - -void -wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) -{ - const bool column = direction == wxGRID_COLUMN; - - // We don't support auto-sizing hidden rows or columns, this doesn't seem - // to make much sense. - if ( column ) - { - if ( GetColWidth(colOrRow) == 0 ) - return; - } - else - { - if ( GetRowHeight(colOrRow) == 0 ) - return; - } - - wxClientDC dc(m_gridWin); - - // cancel editing of cell - HideCellEditControl(); - SaveEditControlValue(); - - // initialize both of them just to avoid compiler warnings even if only - // really needs to be initialized here - int row, - col; - if ( column ) - { - row = -1; - col = colOrRow; - } - else - { - row = colOrRow; - col = -1; - } - - wxCoord extent, extentMax = 0; - int max = column ? m_numRows : m_numCols; - for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ ) - { - if ( column ) - { - if ( !IsRowShown(rowOrCol) ) - continue; - - row = rowOrCol; - col = colOrRow; - } - else - { - if ( !IsColShown(rowOrCol) ) - continue; - - row = colOrRow; - col = rowOrCol; - } - - // we need to account for the cells spanning multiple columns/rows: - // while they may need a lot of space, they don't need all of it in - // this column/row - int numRows, numCols; - const CellSpan span = GetCellSize(row, col, &numRows, &numCols); - if ( span == CellSpan_Inside ) - { - // we need to get the size of the main cell, not of a cell hidden - // by it - row += numRows; - col += numCols; - - // get the size of the main cell too - GetCellSize(row, col, &numRows, &numCols); - } - - // get cell ( main cell if CellSpan_Inside ) renderer best size - wxGridCellAttr *attr = GetCellAttr(row, col); - wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col); - if ( renderer ) - { - wxSize size = renderer->GetBestSize(*this, *attr, dc, row, col); - extent = column ? size.x : size.y; - - if ( span != CellSpan_None ) - { - // we spread the size of a spanning cell over all the cells it - // covers evenly -- this is probably not ideal but we can't - // really do much better here - // - // notice that numCols and numRows are never 0 as they - // correspond to the size of the main cell of the span and not - // of the cell inside it - extent /= column ? numCols : numRows; - } - - if ( extent > extentMax ) - extentMax = extent; - - renderer->DecRef(); - } - - attr->DecRef(); - } - - // now also compare with the column label extent - wxCoord w, h; - dc.SetFont( GetLabelFont() ); - - if ( column ) - { - dc.GetMultiLineTextExtent( GetColLabelValue(colOrRow), &w, &h ); - if ( GetColLabelTextOrientation() == wxVERTICAL ) - w = h; - } - else - dc.GetMultiLineTextExtent( GetRowLabelValue(colOrRow), &w, &h ); - - extent = column ? w : h; - if ( extent > extentMax ) - extentMax = extent; - - if ( !extentMax ) - { - // empty column - give default extent (notice that if extentMax is less - // than default extent but != 0, it's OK) - extentMax = column ? m_defaultColWidth : m_defaultRowHeight; - } - else - { - if ( column ) - // leave some space around text - extentMax += 10; - else - extentMax += 6; - } - - if ( column ) - { - // Ensure automatic width is not less than minimal width. See the - // comment in SetColSize() for explanation of why this isn't done - // in SetColSize(). - if ( !setAsMin ) - extentMax = wxMax(extentMax, GetColMinimalWidth(colOrRow)); - - SetColSize( colOrRow, extentMax ); - if ( !GetBatchCount() ) - { - if ( m_useNativeHeader ) - { - GetGridColHeader()->UpdateColumn(colOrRow); - } - else - { - int cw, ch, dummy; - m_gridWin->GetClientSize( &cw, &ch ); - wxRect rect ( CellToRect( 0, colOrRow ) ); - rect.y = 0; - CalcScrolledPosition(rect.x, 0, &rect.x, &dummy); - rect.width = cw - rect.x; - rect.height = m_colLabelHeight; - GetColLabelWindow()->Refresh( true, &rect ); - } - } - } - else - { - // Ensure automatic width is not less than minimal height. See the - // comment in SetColSize() for explanation of why this isn't done - // in SetRowSize(). - if ( !setAsMin ) - extentMax = wxMax(extentMax, GetRowMinimalHeight(colOrRow)); - - SetRowSize(colOrRow, extentMax); - if ( !GetBatchCount() ) - { - int cw, ch, dummy; - m_gridWin->GetClientSize( &cw, &ch ); - wxRect rect( CellToRect( colOrRow, 0 ) ); - rect.x = 0; - CalcScrolledPosition(0, rect.y, &dummy, &rect.y); - rect.width = m_rowLabelWidth; - rect.height = ch - rect.y; - m_rowLabelWin->Refresh( true, &rect ); - } - } - - if ( setAsMin ) - { - if ( column ) - SetColMinimalWidth(colOrRow, extentMax); - else - SetRowMinimalHeight(colOrRow, extentMax); - } -} - -wxCoord wxGrid::CalcColOrRowLabelAreaMinSize(wxGridDirection direction) -{ - // calculate size for the rows or columns? - const bool calcRows = direction == wxGRID_ROW; - - wxClientDC dc(calcRows ? GetGridRowLabelWindow() - : GetGridColLabelWindow()); - dc.SetFont(GetLabelFont()); - - // which dimension should we take into account for calculations? - // - // for columns, the text can be only horizontal so it's easy but for rows - // we also have to take into account the text orientation - const bool - useWidth = calcRows || (GetColLabelTextOrientation() == wxVERTICAL); - - wxArrayString lines; - wxCoord extentMax = 0; - - const int numRowsOrCols = calcRows ? m_numRows : m_numCols; - for ( int rowOrCol = 0; rowOrCol < numRowsOrCols; rowOrCol++ ) - { - lines.Clear(); - - wxString label = calcRows ? GetRowLabelValue(rowOrCol) - : GetColLabelValue(rowOrCol); - StringToLines(label, lines); - - long w, h; - GetTextBoxSize(dc, lines, &w, &h); - - const wxCoord extent = useWidth ? w : h; - if ( extent > extentMax ) - extentMax = extent; - } - - if ( !extentMax ) - { - // empty column - give default extent (notice that if extentMax is less - // than default extent but != 0, it's OK) - extentMax = calcRows ? GetDefaultRowLabelSize() - : GetDefaultColLabelSize(); - } - - // leave some space around text (taken from AutoSizeColOrRow) - if ( calcRows ) - extentMax += 10; - else - extentMax += 6; - - return extentMax; -} - -int wxGrid::SetOrCalcColumnSizes(bool calcOnly, bool setAsMin) -{ - int width = m_rowLabelWidth; - - wxGridUpdateLocker locker; - if(!calcOnly) - locker.Create(this); - - for ( int col = 0; col < m_numCols; col++ ) - { - if ( !calcOnly ) - AutoSizeColumn(col, setAsMin); - - width += GetColWidth(col); - } - - return width; -} - -int wxGrid::SetOrCalcRowSizes(bool calcOnly, bool setAsMin) -{ - int height = m_colLabelHeight; - - wxGridUpdateLocker locker; - if(!calcOnly) - locker.Create(this); - - for ( int row = 0; row < m_numRows; row++ ) - { - if ( !calcOnly ) - AutoSizeRow(row, setAsMin); - - height += GetRowHeight(row); - } - - return height; -} - -void wxGrid::AutoSize() -{ - wxGridUpdateLocker locker(this); - - wxSize size(SetOrCalcColumnSizes(false) - m_rowLabelWidth + m_extraWidth, - SetOrCalcRowSizes(false) - m_colLabelHeight + m_extraHeight); - - // we know that we're not going to have scrollbars so disable them now to - // avoid trouble in SetClientSize() which can otherwise set the correct - // client size but also leave space for (not needed any more) scrollbars - SetScrollbars(m_xScrollPixelsPerLine, m_yScrollPixelsPerLine, - 0, 0, 0, 0, true); - - SetClientSize(size.x + m_rowLabelWidth, size.y + m_colLabelHeight); -} - -void wxGrid::AutoSizeRowLabelSize( int row ) -{ - // Hide the edit control, so it - // won't interfere with drag-shrinking. - if ( IsCellEditControlShown() ) - { - HideCellEditControl(); - SaveEditControlValue(); - } - - // autosize row height depending on label text - SetRowSize(row, -1); - - ForceRefresh(); -} - -void wxGrid::AutoSizeColLabelSize( int col ) -{ - // Hide the edit control, so it - // won't interfere with drag-shrinking. - if ( IsCellEditControlShown() ) - { - HideCellEditControl(); - SaveEditControlValue(); - } - - // autosize column width depending on label text - SetColSize(col, -1); - - ForceRefresh(); -} - -wxSize wxGrid::DoGetBestSize() const -{ - wxGrid * const self = const_cast(this); - - // we do the same as in AutoSize() here with the exception that we don't - // change the column/row sizes, only calculate them - wxSize size(self->SetOrCalcColumnSizes(true) - m_rowLabelWidth + m_extraWidth, - self->SetOrCalcRowSizes(true) - m_colLabelHeight + m_extraHeight); - - return wxSize(size.x + m_rowLabelWidth, size.y + m_colLabelHeight) - + GetWindowBorderSize(); -} - -void wxGrid::Fit() -{ - AutoSize(); -} - -#if WXWIN_COMPATIBILITY_2_8 -wxPen& wxGrid::GetDividerPen() const -{ - return wxNullPen; -} -#endif // WXWIN_COMPATIBILITY_2_8 - -// ---------------------------------------------------------------------------- -// cell value accessor functions -// ---------------------------------------------------------------------------- - -void wxGrid::SetCellValue( int row, int col, const wxString& s ) -{ - if ( m_table ) - { - m_table->SetValue( row, col, s ); - if ( !GetBatchCount() ) - { - int dummy; - wxRect rect( CellToRect( row, col ) ); - rect.x = 0; - rect.width = m_gridWin->GetClientSize().GetWidth(); - CalcScrolledPosition(0, rect.y, &dummy, &rect.y); - m_gridWin->Refresh( false, &rect ); - } - - if ( m_currentCellCoords.GetRow() == row && - m_currentCellCoords.GetCol() == col && - IsCellEditControlShown()) - // Note: If we are using IsCellEditControlEnabled, - // this interacts badly with calling SetCellValue from - // an EVT_GRID_CELL_CHANGE handler. - { - HideCellEditControl(); - ShowCellEditControl(); // will reread data from table - } - } -} - -// ---------------------------------------------------------------------------- -// block, row and column selection -// ---------------------------------------------------------------------------- - -void wxGrid::SelectRow( int row, bool addToSelected ) -{ - if ( !m_selection ) - return; - - if ( !addToSelected ) - ClearSelection(); - - m_selection->SelectRow(row); -} - -void wxGrid::SelectCol( int col, bool addToSelected ) -{ - if ( !m_selection ) - return; - - if ( !addToSelected ) - ClearSelection(); - - m_selection->SelectCol(col); -} - -void wxGrid::SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, - bool addToSelected) -{ - if ( !m_selection ) - return; - - if ( !addToSelected ) - ClearSelection(); - - m_selection->SelectBlock(topRow, leftCol, bottomRow, rightCol); -} - -void wxGrid::SelectAll() -{ - if ( m_numRows > 0 && m_numCols > 0 ) - { - if ( m_selection ) - m_selection->SelectBlock( 0, 0, m_numRows - 1, m_numCols - 1 ); - } -} - -// ---------------------------------------------------------------------------- -// cell, row and col deselection -// ---------------------------------------------------------------------------- - -void wxGrid::DeselectLine(int line, const wxGridOperations& oper) -{ - if ( !m_selection ) - return; - - const wxGridSelectionModes mode = m_selection->GetSelectionMode(); - if ( mode == oper.GetSelectionMode() || - mode == wxGrid::wxGridSelectRowsOrColumns ) - { - const wxGridCellCoords c(oper.MakeCoords(line, 0)); - if ( m_selection->IsInSelection(c) ) - m_selection->ToggleCellSelection(c); - } - else if ( mode != oper.Dual().GetSelectionMode() ) - { - const int nOther = oper.Dual().GetNumberOfLines(this); - for ( int i = 0; i < nOther; i++ ) - { - const wxGridCellCoords c(oper.MakeCoords(line, i)); - if ( m_selection->IsInSelection(c) ) - m_selection->ToggleCellSelection(c); - } - } - //else: can only select orthogonal lines so no lines in this direction - // could have been selected anyhow -} - -void wxGrid::DeselectRow(int row) -{ - DeselectLine(row, wxGridRowOperations()); -} - -void wxGrid::DeselectCol(int col) -{ - DeselectLine(col, wxGridColumnOperations()); -} - -void wxGrid::DeselectCell( int row, int col ) -{ - if ( m_selection && m_selection->IsInSelection(row, col) ) - m_selection->ToggleCellSelection(row, col); -} - -bool wxGrid::IsSelection() const -{ - return ( m_selection && (m_selection->IsSelection() || - ( m_selectedBlockTopLeft != wxGridNoCellCoords && - m_selectedBlockBottomRight != wxGridNoCellCoords) ) ); -} - -bool wxGrid::IsInSelection( int row, int col ) const -{ - return ( m_selection && (m_selection->IsInSelection( row, col ) || - ( row >= m_selectedBlockTopLeft.GetRow() && - col >= m_selectedBlockTopLeft.GetCol() && - row <= m_selectedBlockBottomRight.GetRow() && - col <= m_selectedBlockBottomRight.GetCol() )) ); -} - -wxGridCellCoordsArray wxGrid::GetSelectedCells() const -{ - if (!m_selection) - { - wxGridCellCoordsArray a; - return a; - } - - return m_selection->m_cellSelection; -} - -wxGridCellCoordsArray wxGrid::GetSelectionBlockTopLeft() const -{ - if (!m_selection) - { - wxGridCellCoordsArray a; - return a; - } - - return m_selection->m_blockSelectionTopLeft; -} - -wxGridCellCoordsArray wxGrid::GetSelectionBlockBottomRight() const -{ - if (!m_selection) - { - wxGridCellCoordsArray a; - return a; - } - - return m_selection->m_blockSelectionBottomRight; -} - -wxArrayInt wxGrid::GetSelectedRows() const -{ - if (!m_selection) - { - wxArrayInt a; - return a; - } - - return m_selection->m_rowSelection; -} - -wxArrayInt wxGrid::GetSelectedCols() const -{ - if (!m_selection) - { - wxArrayInt a; - return a; - } - - return m_selection->m_colSelection; -} - -void wxGrid::ClearSelection() -{ - wxRect r1 = BlockToDeviceRect(m_selectedBlockTopLeft, - m_selectedBlockBottomRight); - wxRect r2 = BlockToDeviceRect(m_currentCellCoords, - m_selectedBlockCorner); - - m_selectedBlockTopLeft = - m_selectedBlockBottomRight = - m_selectedBlockCorner = wxGridNoCellCoords; - - if ( !r1.IsEmpty() ) - RefreshRect(r1, false); - if ( !r2.IsEmpty() ) - RefreshRect(r2, false); - - if ( m_selection ) - m_selection->ClearSelection(); -} - -// This function returns the rectangle that encloses the given block -// in device coords clipped to the client size of the grid window. -// -wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight ) const -{ - wxRect resultRect; - wxRect tempCellRect = CellToRect(topLeft); - if ( tempCellRect != wxGridNoCellRect ) - { - resultRect = tempCellRect; - } - else - { - resultRect = wxRect(0, 0, 0, 0); - } - - tempCellRect = CellToRect(bottomRight); - if ( tempCellRect != wxGridNoCellRect ) - { - resultRect += tempCellRect; - } - else - { - // If both inputs were "wxGridNoCellRect," then there's nothing to do. - return wxGridNoCellRect; - } - - // Ensure that left/right and top/bottom pairs are in order. - int left = resultRect.GetLeft(); - int top = resultRect.GetTop(); - int right = resultRect.GetRight(); - int bottom = resultRect.GetBottom(); - - int leftCol = topLeft.GetCol(); - int topRow = topLeft.GetRow(); - int rightCol = bottomRight.GetCol(); - int bottomRow = bottomRight.GetRow(); - - if (left > right) - { - int tmp = left; - left = right; - right = tmp; - - tmp = leftCol; - leftCol = rightCol; - rightCol = tmp; - } - - if (top > bottom) - { - int tmp = top; - top = bottom; - bottom = tmp; - - tmp = topRow; - topRow = bottomRow; - bottomRow = tmp; - } - - // The following loop is ONLY necessary to detect and handle merged cells. - int cw, ch; - m_gridWin->GetClientSize( &cw, &ch ); - - // Get the origin coordinates: notice that they will be negative if the - // grid is scrolled downwards/to the right. - int gridOriginX = 0; - int gridOriginY = 0; - CalcScrolledPosition(gridOriginX, gridOriginY, &gridOriginX, &gridOriginY); - - int onScreenLeftmostCol = internalXToCol(-gridOriginX); - int onScreenUppermostRow = internalYToRow(-gridOriginY); - - int onScreenRightmostCol = internalXToCol(-gridOriginX + cw); - int onScreenBottommostRow = internalYToRow(-gridOriginY + ch); - - // Bound our loop so that we only examine the portion of the selected block - // that is shown on screen. Therefore, we compare the Top-Left block values - // to the Top-Left screen values, and the Bottom-Right block values to the - // Bottom-Right screen values, choosing appropriately. - const int visibleTopRow = wxMax(topRow, onScreenUppermostRow); - const int visibleBottomRow = wxMin(bottomRow, onScreenBottommostRow); - const int visibleLeftCol = wxMax(leftCol, onScreenLeftmostCol); - const int visibleRightCol = wxMin(rightCol, onScreenRightmostCol); - - for ( int j = visibleTopRow; j <= visibleBottomRow; j++ ) - { - for ( int i = visibleLeftCol; i <= visibleRightCol; i++ ) - { - if ( (j == visibleTopRow) || (j == visibleBottomRow) || - (i == visibleLeftCol) || (i == visibleRightCol) ) - { - tempCellRect = CellToRect( j, i ); - - if (tempCellRect.x < left) - left = tempCellRect.x; - if (tempCellRect.y < top) - top = tempCellRect.y; - if (tempCellRect.x + tempCellRect.width > right) - right = tempCellRect.x + tempCellRect.width; - if (tempCellRect.y + tempCellRect.height > bottom) - bottom = tempCellRect.y + tempCellRect.height; - } - else - { - i = visibleRightCol; // jump over inner cells. - } - } - } - - // Convert to scrolled coords - CalcScrolledPosition( left, top, &left, &top ); - CalcScrolledPosition( right, bottom, &right, &bottom ); - - if (right < 0 || bottom < 0 || left > cw || top > ch) - return wxRect(0,0,0,0); - - resultRect.SetLeft( wxMax(0, left) ); - resultRect.SetTop( wxMax(0, top) ); - resultRect.SetRight( wxMin(cw, right) ); - resultRect.SetBottom( wxMin(ch, bottom) ); - - return resultRect; -} - -void wxGrid::DoSetSizes(const wxGridSizesInfo& sizeInfo, - const wxGridOperations& oper) -{ - BeginBatch(); - oper.SetDefaultLineSize(this, sizeInfo.m_sizeDefault, true); - const int numLines = oper.GetNumberOfLines(this); - for ( int i = 0; i < numLines; i++ ) - { - int size = sizeInfo.GetSize(i); - if ( size != sizeInfo.m_sizeDefault) - oper.SetLineSize(this, i, size); - } - EndBatch(); -} - -void wxGrid::SetColSizes(const wxGridSizesInfo& sizeInfo) -{ - DoSetSizes(sizeInfo, wxGridColumnOperations()); -} - -void wxGrid::SetRowSizes(const wxGridSizesInfo& sizeInfo) -{ - DoSetSizes(sizeInfo, wxGridRowOperations()); -} - -wxGridSizesInfo::wxGridSizesInfo(int defSize, const wxArrayInt& allSizes) -{ - m_sizeDefault = defSize; - for ( size_t i = 0; i < allSizes.size(); i++ ) - { - if ( allSizes[i] != defSize ) - m_customSizes[i] = allSizes[i]; - } -} - -int wxGridSizesInfo::GetSize(unsigned pos) const -{ - wxUnsignedToIntHashMap::const_iterator it = m_customSizes.find(pos); - - // if it's not found return the default - if ( it == m_customSizes.end() ) - return m_sizeDefault; - - // otherwise return 0 if it's hidden, currently there is no way to get - // its size before it had been hidden - if ( it->second < 0 ) - return 0; - - return it->second; -} - -// ---------------------------------------------------------------------------- -// drop target -// ---------------------------------------------------------------------------- - -#if wxUSE_DRAG_AND_DROP - -// this allow setting drop target directly on wxGrid -void wxGrid::SetDropTarget(wxDropTarget *dropTarget) -{ - GetGridWindow()->SetDropTarget(dropTarget); -} - -#endif // wxUSE_DRAG_AND_DROP - -// ---------------------------------------------------------------------------- -// grid event classes -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxNotifyEvent ) - -wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj, - int row, int col, int x, int y, bool sel, - bool control, bool shift, bool alt, bool meta ) - : wxNotifyEvent( type, id ), - wxKeyboardState(control, shift, alt, meta) -{ - Init(row, col, x, y, sel); - - SetEventObject(obj); -} - -IMPLEMENT_DYNAMIC_CLASS( wxGridSizeEvent, wxNotifyEvent ) - -wxGridSizeEvent::wxGridSizeEvent( int id, wxEventType type, wxObject* obj, - int rowOrCol, int x, int y, - bool control, bool shift, bool alt, bool meta ) - : wxNotifyEvent( type, id ), - wxKeyboardState(control, shift, alt, meta) -{ - Init(rowOrCol, x, y); - - SetEventObject(obj); -} - - -IMPLEMENT_DYNAMIC_CLASS( wxGridRangeSelectEvent, wxNotifyEvent ) - -wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, - const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight, - bool sel, bool control, - bool shift, bool alt, bool meta ) - : wxNotifyEvent( type, id ), - wxKeyboardState(control, shift, alt, meta) -{ - Init(topLeft, bottomRight, sel); - - SetEventObject(obj); -} - - -IMPLEMENT_DYNAMIC_CLASS(wxGridEditorCreatedEvent, wxCommandEvent) - -wxGridEditorCreatedEvent::wxGridEditorCreatedEvent(int id, wxEventType type, - wxObject* obj, int row, - int col, wxControl* ctrl) - : wxCommandEvent(type, id) -{ - SetEventObject(obj); - m_row = row; - m_col = col; - m_ctrl = ctrl; -} - - -// ---------------------------------------------------------------------------- -// wxGridTypeRegistry -// ---------------------------------------------------------------------------- - -wxGridTypeRegistry::~wxGridTypeRegistry() -{ - size_t count = m_typeinfo.GetCount(); - for ( size_t i = 0; i < count; i++ ) - delete m_typeinfo[i]; -} - -void wxGridTypeRegistry::RegisterDataType(const wxString& typeName, - wxGridCellRenderer* renderer, - wxGridCellEditor* editor) -{ - wxGridDataTypeInfo* info = new wxGridDataTypeInfo(typeName, renderer, editor); - - // is it already registered? - int loc = FindRegisteredDataType(typeName); - if ( loc != wxNOT_FOUND ) - { - delete m_typeinfo[loc]; - m_typeinfo[loc] = info; - } - else - { - m_typeinfo.Add(info); - } -} - -int wxGridTypeRegistry::FindRegisteredDataType(const wxString& typeName) -{ - size_t count = m_typeinfo.GetCount(); - for ( size_t i = 0; i < count; i++ ) - { - if ( typeName == m_typeinfo[i]->m_typeName ) - { - return i; - } - } - - return wxNOT_FOUND; -} - -int wxGridTypeRegistry::FindDataType(const wxString& typeName) -{ - int index = FindRegisteredDataType(typeName); - if ( index == wxNOT_FOUND ) - { - // check whether this is one of the standard ones, in which case - // register it "on the fly" -#if wxUSE_TEXTCTRL - if ( typeName == wxGRID_VALUE_STRING ) - { - RegisterDataType(wxGRID_VALUE_STRING, - new wxGridCellStringRenderer, - new wxGridCellTextEditor); - } - else -#endif // wxUSE_TEXTCTRL -#if wxUSE_CHECKBOX - if ( typeName == wxGRID_VALUE_BOOL ) - { - RegisterDataType(wxGRID_VALUE_BOOL, - new wxGridCellBoolRenderer, - new wxGridCellBoolEditor); - } - else -#endif // wxUSE_CHECKBOX -#if wxUSE_TEXTCTRL - if ( typeName == wxGRID_VALUE_NUMBER ) - { - RegisterDataType(wxGRID_VALUE_NUMBER, - new wxGridCellNumberRenderer, - new wxGridCellNumberEditor); - } - else if ( typeName == wxGRID_VALUE_FLOAT ) - { - RegisterDataType(wxGRID_VALUE_FLOAT, - new wxGridCellFloatRenderer, - new wxGridCellFloatEditor); - } - else -#endif // wxUSE_TEXTCTRL -#if wxUSE_COMBOBOX - if ( typeName == wxGRID_VALUE_CHOICE ) - { - RegisterDataType(wxGRID_VALUE_CHOICE, - new wxGridCellStringRenderer, - new wxGridCellChoiceEditor); - } - else -#endif // wxUSE_COMBOBOX - { - return wxNOT_FOUND; - } - - // we get here only if just added the entry for this type, so return - // the last index - index = m_typeinfo.GetCount() - 1; - } - - return index; -} - -int wxGridTypeRegistry::FindOrCloneDataType(const wxString& typeName) -{ - int index = FindDataType(typeName); - if ( index == wxNOT_FOUND ) - { - // the first part of the typename is the "real" type, anything after ':' - // are the parameters for the renderer - index = FindDataType(typeName.BeforeFirst(wxT(':'))); - if ( index == wxNOT_FOUND ) - { - return wxNOT_FOUND; - } - - wxGridCellRenderer *renderer = GetRenderer(index); - wxGridCellRenderer *rendererOld = renderer; - renderer = renderer->Clone(); - rendererOld->DecRef(); - - wxGridCellEditor *editor = GetEditor(index); - wxGridCellEditor *editorOld = editor; - editor = editor->Clone(); - editorOld->DecRef(); - - // do it even if there are no parameters to reset them to defaults - wxString params = typeName.AfterFirst(wxT(':')); - renderer->SetParameters(params); - editor->SetParameters(params); - - // register the new typename - RegisterDataType(typeName, renderer, editor); - - // we just registered it, it's the last one - index = m_typeinfo.GetCount() - 1; - } - - return index; -} - -wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index) -{ - wxGridCellRenderer* renderer = m_typeinfo[index]->m_renderer; - if (renderer) - renderer->IncRef(); - - return renderer; -} - -wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index) -{ - wxGridCellEditor* editor = m_typeinfo[index]->m_editor; - if (editor) - editor->IncRef(); - - return editor; -} - -#endif // wxUSE_GRID diff --git a/Source/3rd Party/wx/src/generic/gridctrl.cpp b/Source/3rd Party/wx/src/generic/gridctrl.cpp deleted file mode 100644 index 25c3359d3..000000000 --- a/Source/3rd Party/wx/src/generic/gridctrl.cpp +++ /dev/null @@ -1,952 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Name: src/generic/gridctrl.cpp -// Purpose: wxGrid controls -// Author: Paul Gammans, Roger Gammans -// Modified by: -// Created: 11/04/2001 -// Copyright: (c) The Computer Surgery (paul@compsurg.co.uk) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_GRID - -#include "wx/generic/gridctrl.h" -#include "wx/generic/grideditors.h" - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" - #include "wx/dc.h" - #include "wx/combobox.h" - #include "wx/settings.h" - #include "wx/log.h" - #include "wx/checkbox.h" -#endif // WX_PRECOMP - -#include "wx/tokenzr.h" -#include "wx/renderer.h" - - -// ---------------------------------------------------------------------------- -// wxGridCellRenderer -// ---------------------------------------------------------------------------- - -void wxGridCellRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int WXUNUSED(row), int WXUNUSED(col), - bool isSelected) -{ - dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID ); - - wxColour clr; - if ( grid.IsThisEnabled() ) - { - if ( isSelected ) - { - if ( grid.HasFocus() ) - clr = grid.GetSelectionBackground(); - else - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); - } - else - { - clr = attr.GetBackgroundColour(); - } - } - else // grey out fields if the grid is disabled - { - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); - } - - dc.SetBrush(clr); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle(rect); -} - - -// ---------------------------------------------------------------------------- -// wxGridCellDateTimeRenderer -// ---------------------------------------------------------------------------- - -#if wxUSE_DATETIME - -// Enables a grid cell to display a formatted date and or time - -wxGridCellDateTimeRenderer::wxGridCellDateTimeRenderer(const wxString& outformat, const wxString& informat) -{ - m_iformat = informat; - m_oformat = outformat; - m_tz = wxDateTime::Local; - m_dateDef = wxDefaultDateTime; -} - -wxGridCellRenderer *wxGridCellDateTimeRenderer::Clone() const -{ - wxGridCellDateTimeRenderer *renderer = new wxGridCellDateTimeRenderer; - renderer->m_iformat = m_iformat; - renderer->m_oformat = m_oformat; - renderer->m_dateDef = m_dateDef; - renderer->m_tz = m_tz; - - return renderer; -} - -wxString wxGridCellDateTimeRenderer::GetString(const wxGrid& grid, int row, int col) -{ - wxGridTableBase *table = grid.GetTable(); - - bool hasDatetime = false; - wxDateTime val; - wxString text; - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_DATETIME) ) - { - void * tempval = table->GetValueAsCustom(row, col,wxGRID_VALUE_DATETIME); - - if (tempval) - { - val = *((wxDateTime *)tempval); - hasDatetime = true; - delete (wxDateTime *)tempval; - } - - } - - if (!hasDatetime ) - { - text = table->GetValue(row, col); - const char * const end = val.ParseFormat(text, m_iformat, m_dateDef); - hasDatetime = end && !*end; - } - - if ( hasDatetime ) - text = val.Format(m_oformat, m_tz ); - - // If we failed to parse string just show what we where given? - return text; -} - -void wxGridCellDateTimeRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) -{ - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - SetTextColoursAndFont(grid, attr, dc, isSelected); - - // draw the text right aligned by default - int hAlign = wxALIGN_RIGHT, - vAlign = wxALIGN_INVALID; - attr.GetNonDefaultAlignment(&hAlign, &vAlign); - - wxRect rect = rectCell; - rect.Inflate(-1); - - grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign); -} - -wxSize wxGridCellDateTimeRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - return DoGetBestSize(attr, dc, GetString(grid, row, col)); -} - -void wxGridCellDateTimeRenderer::SetParameters(const wxString& params) -{ - if (!params.empty()) - m_oformat=params; -} - -#endif // wxUSE_DATETIME - -// ---------------------------------------------------------------------------- -// wxGridCellEnumRenderer -// ---------------------------------------------------------------------------- -// Renders a number as a textual equivalent. -// eg data in cell is 0,1,2 ... n the cell could be rendered as "John","Fred"..."Bob" - - -wxGridCellEnumRenderer::wxGridCellEnumRenderer(const wxString& choices) -{ - if (!choices.empty()) - SetParameters(choices); -} - -wxGridCellRenderer *wxGridCellEnumRenderer::Clone() const -{ - wxGridCellEnumRenderer *renderer = new wxGridCellEnumRenderer; - renderer->m_choices = m_choices; - return renderer; -} - -wxString wxGridCellEnumRenderer::GetString(const wxGrid& grid, int row, int col) -{ - wxGridTableBase *table = grid.GetTable(); - wxString text; - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - { - int choiceno = table->GetValueAsLong(row, col); - text.Printf(wxT("%s"), m_choices[ choiceno ].c_str() ); - } - else - { - text = table->GetValue(row, col); - } - - - //If we faild to parse string just show what we where given? - return text; -} - -void wxGridCellEnumRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) -{ - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - SetTextColoursAndFont(grid, attr, dc, isSelected); - - // draw the text right aligned by default - int hAlign = wxALIGN_RIGHT, - vAlign = wxALIGN_INVALID; - attr.GetNonDefaultAlignment(&hAlign, &vAlign); - - wxRect rect = rectCell; - rect.Inflate(-1); - - grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign); -} - -wxSize wxGridCellEnumRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - return DoGetBestSize(attr, dc, GetString(grid, row, col)); -} - -void wxGridCellEnumRenderer::SetParameters(const wxString& params) -{ - if ( !params ) - { - // what can we do? - return; - } - - m_choices.Empty(); - - wxStringTokenizer tk(params, wxT(',')); - while ( tk.HasMoreTokens() ) - { - m_choices.Add(tk.GetNextToken()); - } -} - - -// ---------------------------------------------------------------------------- -// wxGridCellAutoWrapStringRenderer -// ---------------------------------------------------------------------------- - - -void -wxGridCellAutoWrapStringRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) { - - - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - // now we only have to draw the text - SetTextColoursAndFont(grid, attr, dc, isSelected); - - int horizAlign, vertAlign; - attr.GetAlignment(&horizAlign, &vertAlign); - - wxRect rect = rectCell; - rect.Inflate(-1); - - grid.DrawTextRectangle(dc, GetTextLines(grid,dc,attr,rect,row,col), - rect, horizAlign, vertAlign); -} - - -wxArrayString -wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid, - wxDC& dc, - const wxGridCellAttr& attr, - const wxRect& rect, - int row, int col) -{ - dc.SetFont(attr.GetFont()); - const wxCoord maxWidth = rect.GetWidth(); - - // Transform logical lines into physical ones, wrapping the longer ones. - const wxArrayString - logicalLines = wxSplit(grid.GetCellValue(row, col), '\n', '\0'); - - // Trying to do anything if the column is hidden anyhow doesn't make sense - // and we run into problems in BreakLine() in this case. - if ( maxWidth <= 0 ) - return logicalLines; - - wxArrayString physicalLines; - for ( wxArrayString::const_iterator it = logicalLines.begin(); - it != logicalLines.end(); - ++it ) - { - const wxString& line = *it; - - if ( dc.GetTextExtent(line).x > maxWidth ) - { - // Line does not fit, break it up. - BreakLine(dc, line, maxWidth, physicalLines); - } - else // The entire line fits as is - { - physicalLines.push_back(line); - } - } - - return physicalLines; -} - -void -wxGridCellAutoWrapStringRenderer::BreakLine(wxDC& dc, - const wxString& logicalLine, - wxCoord maxWidth, - wxArrayString& lines) -{ - wxCoord lineWidth = 0; - wxString line; - - // For each word - wxStringTokenizer wordTokenizer(logicalLine, wxS(" \t"), wxTOKEN_RET_DELIMS); - while ( wordTokenizer.HasMoreTokens() ) - { - const wxString word = wordTokenizer.GetNextToken(); - const wxCoord wordWidth = dc.GetTextExtent(word).x; - if ( lineWidth + wordWidth < maxWidth ) - { - // Word fits, just add it to this line. - line += word; - lineWidth += wordWidth; - } - else - { - // Word does not fit, check whether the word is itself wider that - // available width - if ( wordWidth < maxWidth ) - { - // Word can fit in a new line, put it at the beginning - // of the new line. - lines.push_back(line); - line = word; - lineWidth = wordWidth; - } - else // Word cannot fit in available width at all. - { - if ( !line.empty() ) - { - lines.push_back(line); - line.clear(); - lineWidth = 0; - } - - // Break it up in several lines. - lineWidth = BreakWord(dc, word, maxWidth, lines, line); - } - } - } - - if ( !line.empty() ) - lines.push_back(line); -} - - -wxCoord -wxGridCellAutoWrapStringRenderer::BreakWord(wxDC& dc, - const wxString& word, - wxCoord maxWidth, - wxArrayString& lines, - wxString& line) -{ - wxArrayInt widths; - dc.GetPartialTextExtents(word, widths); - - // TODO: Use binary search to find the first element > maxWidth. - const unsigned count = widths.size(); - unsigned n; - for ( n = 0; n < count; n++ ) - { - if ( widths[n] > maxWidth ) - break; - } - - if ( n == 0 ) - { - // This is a degenerate case: the first character of the word is - // already wider than the available space, so we just can't show it - // completely and have to put the first character in this line. - n = 1; - } - - lines.push_back(word.substr(0, n)); - - // Check if the remainder of the string fits in one line. - // - // Unfortunately we can't use the existing partial text extents as the - // extent of the remainder may be different when it's rendered in a - // separate line instead of as part of the same one, so we have to - // recompute it. - const wxString rest = word.substr(n); - const wxCoord restWidth = dc.GetTextExtent(rest).x; - if ( restWidth <= maxWidth ) - { - line = rest; - return restWidth; - } - - // Break the rest of the word into lines. - // - // TODO: Perhaps avoid recursion? The code is simpler like this but using a - // loop in this function would probably be more efficient. - return BreakWord(dc, rest, maxWidth, lines, line); -} - -wxSize -wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - const int lineHeight = dc.GetCharHeight(); - - // Search for a shape no taller than the golden ratio. - wxSize size; - for ( size.x = 10; ; size.x += 10 ) - { - const size_t - numLines = GetTextLines(grid, dc, attr, size, row, col).size(); - size.y = numLines * lineHeight; - if ( size.x >= size.y*1.68 ) - break; - } - - return size; -} - -// ---------------------------------------------------------------------------- -// wxGridCellStringRenderer -// ---------------------------------------------------------------------------- - -void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid, - const wxGridCellAttr& attr, - wxDC& dc, - bool isSelected) -{ - dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT ); - - // TODO some special colours for attr.IsReadOnly() case? - - // different coloured text when the grid is disabled - if ( grid.IsThisEnabled() ) - { - if ( isSelected ) - { - wxColour clr; - if ( grid.HasFocus() ) - clr = grid.GetSelectionBackground(); - else - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); - dc.SetTextBackground( clr ); - dc.SetTextForeground( grid.GetSelectionForeground() ); - } - else - { - dc.SetTextBackground( attr.GetBackgroundColour() ); - dc.SetTextForeground( attr.GetTextColour() ); - } - } - else - { - dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); - } - - dc.SetFont( attr.GetFont() ); -} - -wxSize wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr& attr, - wxDC& dc, - const wxString& text) -{ - wxCoord x = 0, y = 0, max_x = 0; - dc.SetFont(attr.GetFont()); - wxStringTokenizer tk(text, wxT('\n')); - while ( tk.HasMoreTokens() ) - { - dc.GetTextExtent(tk.GetNextToken(), &x, &y); - max_x = wxMax(max_x, x); - } - - y *= 1 + text.Freq(wxT('\n')); // multiply by the number of lines. - - return wxSize(max_x, y); -} - -wxSize wxGridCellStringRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - return DoGetBestSize(attr, dc, grid.GetCellValue(row, col)); -} - -void wxGridCellStringRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) -{ - wxRect rect = rectCell; - rect.Inflate(-1); - - // erase only this cells background, overflow cells should have been erased - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - int hAlign, vAlign; - attr.GetAlignment(&hAlign, &vAlign); - - int overflowCols = 0; - - if (attr.GetOverflow()) - { - int cols = grid.GetNumberCols(); - int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth(); - int cell_rows, cell_cols; - attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <= 0 - if ((best_width > rectCell.width) && (col < cols) && grid.GetTable()) - { - int i, c_cols, c_rows; - for (i = col+cell_cols; i < cols; i++) - { - bool is_empty = true; - for (int j=row; j < row + cell_rows; j++) - { - // check w/ anchor cell for multicell block - grid.GetCellSize(j, i, &c_rows, &c_cols); - if (c_rows > 0) - c_rows = 0; - if (!grid.GetTable()->IsEmptyCell(j + c_rows, i)) - { - is_empty = false; - break; - } - } - - if (is_empty) - { - rect.width += grid.GetColSize(i); - } - else - { - i--; - break; - } - - if (rect.width >= best_width) - break; - } - - overflowCols = i - col - cell_cols + 1; - if (overflowCols >= cols) - overflowCols = cols - 1; - } - - if (overflowCols > 0) // redraw overflow cells w/ proper hilight - { - hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned - wxRect clip = rect; - clip.x += rectCell.width; - // draw each overflow cell individually - int col_end = col + cell_cols + overflowCols; - if (col_end >= grid.GetNumberCols()) - col_end = grid.GetNumberCols() - 1; - for (int i = col + cell_cols; i <= col_end; i++) - { - clip.width = grid.GetColSize(i) - 1; - dc.DestroyClippingRegion(); - dc.SetClippingRegion(clip); - - SetTextColoursAndFont(grid, attr, dc, - grid.IsInSelection(row,i)); - - grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), - rect, hAlign, vAlign); - clip.x += grid.GetColSize(i) - 1; - } - - rect = rectCell; - rect.Inflate(-1); - rect.width++; - dc.DestroyClippingRegion(); - } - } - - // now we only have to draw the text - SetTextColoursAndFont(grid, attr, dc, isSelected); - - grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), - rect, hAlign, vAlign); -} - -// ---------------------------------------------------------------------------- -// wxGridCellNumberRenderer -// ---------------------------------------------------------------------------- - -wxString wxGridCellNumberRenderer::GetString(const wxGrid& grid, int row, int col) -{ - wxGridTableBase *table = grid.GetTable(); - wxString text; - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - { - text.Printf(wxT("%ld"), table->GetValueAsLong(row, col)); - } - else - { - text = table->GetValue(row, col); - } - - return text; -} - -void wxGridCellNumberRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) -{ - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - SetTextColoursAndFont(grid, attr, dc, isSelected); - - // draw the text right aligned by default - int hAlign = wxALIGN_RIGHT, - vAlign = wxALIGN_INVALID; - attr.GetNonDefaultAlignment(&hAlign, &vAlign); - - wxRect rect = rectCell; - rect.Inflate(-1); - - grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign); -} - -wxSize wxGridCellNumberRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - return DoGetBestSize(attr, dc, GetString(grid, row, col)); -} - -// ---------------------------------------------------------------------------- -// wxGridCellFloatRenderer -// ---------------------------------------------------------------------------- - -wxGridCellFloatRenderer::wxGridCellFloatRenderer(int width, - int precision, - int format) -{ - SetWidth(width); - SetPrecision(precision); - SetFormat(format); -} - -wxGridCellRenderer *wxGridCellFloatRenderer::Clone() const -{ - wxGridCellFloatRenderer *renderer = new wxGridCellFloatRenderer; - renderer->m_width = m_width; - renderer->m_precision = m_precision; - renderer->m_style = m_style; - renderer->m_format = m_format; - - return renderer; -} - -wxString wxGridCellFloatRenderer::GetString(const wxGrid& grid, int row, int col) -{ - wxGridTableBase *table = grid.GetTable(); - - bool hasDouble; - double val; - wxString text; - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_FLOAT) ) - { - val = table->GetValueAsDouble(row, col); - hasDouble = true; - } - else - { - text = table->GetValue(row, col); - hasDouble = text.ToDouble(&val); - } - - if ( hasDouble ) - { - if ( !m_format ) - { - if ( m_width == -1 ) - { - if ( m_precision == -1 ) - { - // default width/precision - m_format = wxT("%"); - } - else - { - m_format.Printf(wxT("%%.%d"), m_precision); - } - } - else if ( m_precision == -1 ) - { - // default precision - m_format.Printf(wxT("%%%d."), m_width); - } - else - { - m_format.Printf(wxT("%%%d.%d"), m_width, m_precision); - } - - bool isUpper = ( ( m_style & wxGRID_FLOAT_FORMAT_UPPER ) == wxGRID_FLOAT_FORMAT_UPPER); - if ( ( m_style & wxGRID_FLOAT_FORMAT_SCIENTIFIC ) == wxGRID_FLOAT_FORMAT_SCIENTIFIC) - m_format += isUpper ? wxT('E') : wxT('e'); - else if ( ( m_style & wxGRID_FLOAT_FORMAT_COMPACT ) == wxGRID_FLOAT_FORMAT_COMPACT) - m_format += isUpper ? wxT('G') : wxT('g'); - else - m_format += wxT('f'); - } - - text.Printf(m_format, val); - - } - //else: text already contains the string - - return text; -} - -void wxGridCellFloatRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) -{ - wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - - SetTextColoursAndFont(grid, attr, dc, isSelected); - - // draw the text right aligned by default - int hAlign = wxALIGN_RIGHT, - vAlign = wxALIGN_INVALID; - attr.GetNonDefaultAlignment(&hAlign, &vAlign); - - wxRect rect = rectCell; - rect.Inflate(-1); - - grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign); -} - -wxSize wxGridCellFloatRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - int row, int col) -{ - return DoGetBestSize(attr, dc, GetString(grid, row, col)); -} - -void wxGridCellFloatRenderer::SetParameters(const wxString& params) -{ - if ( !params ) - { - // reset to defaults - SetWidth(-1); - SetPrecision(-1); - SetFormat(wxGRID_FLOAT_FORMAT_DEFAULT); - } - else - { - wxString rest; - wxString tmp = params.BeforeFirst(wxT(','), &rest); - if ( !tmp.empty() ) - { - long width; - if ( tmp.ToLong(&width) ) - { - SetWidth((int)width); - } - else - { - wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params.c_str()); - } - } - - tmp = rest.BeforeFirst(wxT(',')); - if ( !tmp.empty() ) - { - long precision; - if ( tmp.ToLong(&precision) ) - { - SetPrecision((int)precision); - } - else - { - wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params.c_str()); - } - } - - tmp = rest.AfterFirst(wxT(',')); - if ( !tmp.empty() ) - { - if ( tmp[0] == wxT('f') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_FIXED); - } - else if ( tmp[0] == wxT('e') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC); - } - else if ( tmp[0] == wxT('g') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_COMPACT); - } - else if ( tmp[0] == wxT('E') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC | - wxGRID_FLOAT_FORMAT_UPPER); - } - else if ( tmp[0] == wxT('F') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_FIXED | - wxGRID_FLOAT_FORMAT_UPPER); - } - else if ( tmp[0] == wxT('G') ) - { - SetFormat(wxGRID_FLOAT_FORMAT_COMPACT | - wxGRID_FLOAT_FORMAT_UPPER); - } - else - { - wxLogDebug("Invalid wxGridCellFloatRenderer format " - "parameter string '%s ignored", params); - } - } - } -} - -// ---------------------------------------------------------------------------- -// wxGridCellBoolRenderer -// ---------------------------------------------------------------------------- - -wxSize wxGridCellBoolRenderer::ms_sizeCheckMark; - -wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid, - wxGridCellAttr& WXUNUSED(attr), - wxDC& WXUNUSED(dc), - int WXUNUSED(row), - int WXUNUSED(col)) -{ - // compute it only once (no locks for MT safeness in GUI thread...) - if ( !ms_sizeCheckMark.x ) - { - ms_sizeCheckMark = wxRendererNative::Get().GetCheckBoxSize(&grid); - } - - return ms_sizeCheckMark; -} - -void wxGridCellBoolRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int row, int col, - bool isSelected) -{ - wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); - - // draw a check mark in the centre (ignoring alignment - TODO) - wxSize size = GetBestSize(grid, attr, dc, row, col); - - // don't draw outside the cell - wxCoord minSize = wxMin(rect.width, rect.height); - if ( size.x >= minSize || size.y >= minSize ) - { - // and even leave (at least) 1 pixel margin - size.x = size.y = minSize; - } - - // draw a border around checkmark - int vAlign, hAlign; - attr.GetAlignment(&hAlign, &vAlign); - - wxRect rectBorder; - if (hAlign == wxALIGN_CENTRE) - { - rectBorder.x = rect.x + rect.width / 2 - size.x / 2; - rectBorder.y = rect.y + rect.height / 2 - size.y / 2; - rectBorder.width = size.x; - rectBorder.height = size.y; - } - else if (hAlign == wxALIGN_LEFT) - { - rectBorder.x = rect.x + 2; - rectBorder.y = rect.y + rect.height / 2 - size.y / 2; - rectBorder.width = size.x; - rectBorder.height = size.y; - } - else if (hAlign == wxALIGN_RIGHT) - { - rectBorder.x = rect.x + rect.width - size.x - 2; - rectBorder.y = rect.y + rect.height / 2 - size.y / 2; - rectBorder.width = size.x; - rectBorder.height = size.y; - } - - bool value; - if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) ) - { - value = grid.GetTable()->GetValueAsBool(row, col); - } - else - { - wxString cellval( grid.GetTable()->GetValue(row, col) ); - value = wxGridCellBoolEditor::IsTrueValue(cellval); - } - - int flags = 0; - if (value) - flags |= wxCONTROL_CHECKED; - - wxRendererNative::Get().DrawCheckBox( &grid, dc, rectBorder, flags ); -} - -#endif // wxUSE_GRID - diff --git a/Source/3rd Party/wx/src/generic/grideditors.cpp b/Source/3rd Party/wx/src/generic/grideditors.cpp deleted file mode 100644 index 4cc103ca7..000000000 --- a/Source/3rd Party/wx/src/generic/grideditors.cpp +++ /dev/null @@ -1,1714 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Name: src/generic/grideditors.cpp -// Purpose: wxGridCellEditorEvtHandler and wxGrid editors -// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) -// Modified by: Robin Dunn, Vadim Zeitlin, Santiago Palacios -// Created: 1/08/1999 -// Copyright: (c) Michael Bedward (mbedward@ozemail.com.au) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_GRID - -#include "wx/grid.h" - -#ifndef WX_PRECOMP - #include "wx/utils.h" - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/log.h" - #include "wx/textctrl.h" - #include "wx/checkbox.h" - #include "wx/combobox.h" - #include "wx/intl.h" - #include "wx/math.h" - #include "wx/listbox.h" -#endif - -#include "wx/valnum.h" -#include "wx/textfile.h" -#include "wx/spinctrl.h" -#include "wx/tokenzr.h" -#include "wx/renderer.h" -#include "wx/headerctrl.h" - -#include "wx/generic/gridsel.h" -#include "wx/generic/grideditors.h" -#include "wx/generic/private/grid.h" - -#if defined(__WXMOTIF__) - #define WXUNUSED_MOTIF(identifier) WXUNUSED(identifier) -#else - #define WXUNUSED_MOTIF(identifier) identifier -#endif - -#if defined(__WXGTK__) - #define WXUNUSED_GTK(identifier) WXUNUSED(identifier) -#else - #define WXUNUSED_GTK(identifier) identifier -#endif - -#ifdef __WXOSX__ -#include "wx/osx/private.h" -#endif - -// Required for wxIs... functions -#include - -// ============================================================================ -// implementation -// ============================================================================ - -wxDEFINE_EVENT( wxEVT_GRID_HIDE_EDITOR, wxCommandEvent ); - -// ---------------------------------------------------------------------------- -// wxGridCellEditorEvtHandler -// ---------------------------------------------------------------------------- - -void wxGridCellEditorEvtHandler::OnKillFocus(wxFocusEvent& event) -{ - // We must let the native control have this event so in any case don't mark - // it as handled, otherwise various weird problems can happen (see #11681). - event.Skip(); - - // Don't disable the cell if we're just starting to edit it - if (m_inSetFocus) - return; - - // Tell the grid to dismiss the control but don't do it immediately as it - // could result in the editor being destroyed right now and a crash in the - // code searching for the next event handler, so post an event asking the - // grid to do it slightly later instead. - - // FIXME-VC6: Once we drop support for VC6, we should use a simpler - // m_grid->CallAfter(&wxGrid::DisableCellEditControl) and get - // rid of wxEVT_GRID_HIDE_EDITOR entirely. - m_grid->GetEventHandler()-> - AddPendingEvent(wxCommandEvent(wxEVT_GRID_HIDE_EDITOR)); -} - -void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event) -{ - switch ( event.GetKeyCode() ) - { - case WXK_ESCAPE: - m_editor->Reset(); - m_grid->DisableCellEditControl(); - break; - - case WXK_TAB: - m_grid->GetEventHandler()->ProcessEvent( event ); - break; - - case WXK_RETURN: - case WXK_NUMPAD_ENTER: - if (!m_grid->GetEventHandler()->ProcessEvent(event)) - m_editor->HandleReturn(event); - break; - - default: - event.Skip(); - break; - } -} - -void wxGridCellEditorEvtHandler::OnChar(wxKeyEvent& event) -{ - int row = m_grid->GetGridCursorRow(); - int col = m_grid->GetGridCursorCol(); - wxRect rect = m_grid->CellToRect( row, col ); - int cw, ch; - m_grid->GetGridWindow()->GetClientSize( &cw, &ch ); - - // if cell width is smaller than grid client area, cell is wholly visible - bool wholeCellVisible = (rect.GetWidth() < cw); - - switch ( event.GetKeyCode() ) - { - case WXK_ESCAPE: - case WXK_TAB: - case WXK_RETURN: - case WXK_NUMPAD_ENTER: - break; - - case WXK_HOME: - { - if ( wholeCellVisible ) - { - // no special processing needed... - event.Skip(); - break; - } - - // do special processing for partly visible cell... - - // get the widths of all cells previous to this one - int colXPos = 0; - for ( int i = 0; i < col; i++ ) - { - colXPos += m_grid->GetColSize(i); - } - - int xUnit = 1, yUnit = 1; - m_grid->GetScrollPixelsPerUnit(&xUnit, &yUnit); - if (col != 0) - { - m_grid->Scroll(colXPos / xUnit - 1, m_grid->GetScrollPos(wxVERTICAL)); - } - else - { - m_grid->Scroll(colXPos / xUnit, m_grid->GetScrollPos(wxVERTICAL)); - } - event.Skip(); - break; - } - - case WXK_END: - { - if ( wholeCellVisible ) - { - // no special processing needed... - event.Skip(); - break; - } - - // do special processing for partly visible cell... - - int textWidth = 0; - wxString value = m_grid->GetCellValue(row, col); - if ( wxEmptyString != value ) - { - // get width of cell CONTENTS (text) - int y; - wxFont font = m_grid->GetCellFont(row, col); - m_grid->GetTextExtent(value, &textWidth, &y, NULL, NULL, &font); - - // try to RIGHT align the text by scrolling - int client_right = m_grid->GetGridWindow()->GetClientSize().GetWidth(); - - // (m_grid->GetScrollLineX()*2) is a factor for not scrolling to far, - // otherwise the last part of the cell content might be hidden below the scroll bar - // FIXME: maybe there is a more suitable correction? - textWidth -= (client_right - (m_grid->GetScrollLineX() * 2)); - if ( textWidth < 0 ) - { - textWidth = 0; - } - } - - // get the widths of all cells previous to this one - int colXPos = 0; - for ( int i = 0; i < col; i++ ) - { - colXPos += m_grid->GetColSize(i); - } - - // and add the (modified) text width of the cell contents - // as we'd like to see the last part of the cell contents - colXPos += textWidth; - - int xUnit = 1, yUnit = 1; - m_grid->GetScrollPixelsPerUnit(&xUnit, &yUnit); - m_grid->Scroll(colXPos / xUnit - 1, m_grid->GetScrollPos(wxVERTICAL)); - event.Skip(); - break; - } - - default: - event.Skip(); - break; - } -} - -// ---------------------------------------------------------------------------- -// wxGridCellEditor -// ---------------------------------------------------------------------------- - -wxGridCellEditor::wxGridCellEditor() -{ - m_control = NULL; - m_attr = NULL; -} - -wxGridCellEditor::~wxGridCellEditor() -{ - Destroy(); -} - -void wxGridCellEditor::Create(wxWindow* WXUNUSED(parent), - wxWindowID WXUNUSED(id), - wxEvtHandler* evtHandler) -{ - if ( evtHandler ) - m_control->PushEventHandler(evtHandler); -} - -void wxGridCellEditor::PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr) -{ - // erase the background because we might not fill the cell - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(wxBrush(attr.GetBackgroundColour())); - dc.DrawRectangle(rectCell); -} - -void wxGridCellEditor::Destroy() -{ - if (m_control) - { - m_control->PopEventHandler( true /* delete it*/ ); - - m_control->Destroy(); - m_control = NULL; - } -} - -void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr) -{ - wxASSERT_MSG(m_control, wxT("The wxGridCellEditor must be created first!")); - - m_control->Show(show); - - if ( show ) - { - // set the colours/fonts if we have any - if ( attr ) - { - m_colFgOld = m_control->GetForegroundColour(); - m_control->SetForegroundColour(attr->GetTextColour()); - - m_colBgOld = m_control->GetBackgroundColour(); - m_control->SetBackgroundColour(attr->GetBackgroundColour()); - -// Workaround for GTK+1 font setting problem on some platforms -#if !defined(__WXGTK__) || defined(__WXGTK20__) - m_fontOld = m_control->GetFont(); - m_control->SetFont(attr->GetFont()); -#endif - - // can't do anything more in the base class version, the other - // attributes may only be used by the derived classes - } - } - else - { - // restore the standard colours fonts - if ( m_colFgOld.IsOk() ) - { - m_control->SetForegroundColour(m_colFgOld); - m_colFgOld = wxNullColour; - } - - if ( m_colBgOld.IsOk() ) - { - m_control->SetBackgroundColour(m_colBgOld); - m_colBgOld = wxNullColour; - } - -// Workaround for GTK+1 font setting problem on some platforms -#if !defined(__WXGTK__) || defined(__WXGTK20__) - if ( m_fontOld.IsOk() ) - { - m_control->SetFont(m_fontOld); - m_fontOld = wxNullFont; - } -#endif - } -} - -void wxGridCellEditor::SetSize(const wxRect& rect) -{ - wxASSERT_MSG(m_control, wxT("The wxGridCellEditor must be created first!")); - - m_control->SetSize(rect, wxSIZE_ALLOW_MINUS_ONE); -} - -void wxGridCellEditor::HandleReturn(wxKeyEvent& event) -{ - event.Skip(); -} - -bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event) -{ - bool ctrl = event.ControlDown(); - bool alt; - -#ifdef __WXMAC__ - // On the Mac the Alt key is more like shift and is used for entry of - // valid characters, so check for Ctrl and Meta instead. - alt = event.MetaDown(); -#else // !__WXMAC__ - alt = event.AltDown(); -#endif // __WXMAC__/!__WXMAC__ - - // Assume it's not a valid char if ctrl or alt is down, but if both are - // down then it may be because of an AltGr key combination, so let them - // through in that case. - if ((ctrl || alt) && !(ctrl && alt)) - return false; - -#if wxUSE_UNICODE - if ( static_cast(event.GetUnicodeKey()) == WXK_NONE ) - return false; -#else - if ( event.GetKeyCode() > WXK_START ) - return false; -#endif - - return true; -} - -void wxGridCellEditor::StartingKey(wxKeyEvent& event) -{ - event.Skip(); -} - -void wxGridCellEditor::StartingClick() -{ -} - -#if wxUSE_TEXTCTRL - -// ---------------------------------------------------------------------------- -// wxGridCellTextEditor -// ---------------------------------------------------------------------------- - -wxGridCellTextEditor::wxGridCellTextEditor(size_t maxChars) -{ - m_maxChars = maxChars; -} - -void wxGridCellTextEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ - DoCreate(parent, id, evtHandler); -} - -void wxGridCellTextEditor::DoCreate(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler, - long style) -{ - style |= wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxNO_BORDER; - - wxTextCtrl* const text = new wxTextCtrl(parent, id, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - style); - text->SetMargins(0, 0); - m_control = text; - -#ifdef __WXOSX__ - wxWidgetImpl* impl = m_control->GetPeer(); - impl->SetNeedsFocusRect(false); -#endif - // set max length allowed in the textctrl, if the parameter was set - if ( m_maxChars != 0 ) - { - Text()->SetMaxLength(m_maxChars); - } -#if wxUSE_VALIDATORS - // validate text in textctrl, if validator is set - if ( m_validator ) - { - Text()->SetValidator(*m_validator); - } -#endif - - wxGridCellEditor::Create(parent, id, evtHandler); -} - -void wxGridCellTextEditor::PaintBackground(wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rectCell), - const wxGridCellAttr& WXUNUSED(attr)) -{ - // as we fill the entire client area, - // don't do anything here to minimize flicker -} - -void wxGridCellTextEditor::SetSize(const wxRect& rectOrig) -{ - wxRect rect(rectOrig); - - // Make the edit control large enough to allow for internal margins - // - // TODO: remove this if the text ctrl sizing is improved esp. for unix - // -#if defined(__WXGTK__) - if (rect.x != 0) - { - rect.x += 1; - rect.y += 1; - rect.width -= 1; - rect.height -= 1; - } -#elif defined(__WXMSW__) - if ( rect.x == 0 ) - rect.x += 2; - else - rect.x += 3; - - if ( rect.y == 0 ) - rect.y += 2; - else - rect.y += 3; - - rect.width -= 2; - rect.height -= 2; -#elif defined(__WXOSX__) - rect.x += 1; - rect.y += 1; - - rect.width -= 1; - rect.height -= 1; -#else - int extra_x = ( rect.x > 2 ) ? 2 : 1; - int extra_y = ( rect.y > 2 ) ? 2 : 1; - - #if defined(__WXMOTIF__) - extra_x *= 2; - extra_y *= 2; - #endif - - rect.SetLeft( wxMax(0, rect.x - extra_x) ); - rect.SetTop( wxMax(0, rect.y - extra_y) ); - rect.SetRight( rect.GetRight() + 2 * extra_x ); - rect.SetBottom( rect.GetBottom() + 2 * extra_y ); -#endif - - wxGridCellEditor::SetSize(rect); -} - -void wxGridCellTextEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - wxASSERT_MSG(m_control, wxT("The wxGridCellEditor must be created first!")); - - m_value = grid->GetTable()->GetValue(row, col); - - DoBeginEdit(m_value); -} - -void wxGridCellTextEditor::DoBeginEdit(const wxString& startValue) -{ - Text()->SetValue(startValue); - Text()->SetInsertionPointEnd(); - Text()->SelectAll(); - Text()->SetFocus(); -} - -bool wxGridCellTextEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& WXUNUSED(oldval), - wxString *newval) -{ - wxCHECK_MSG( m_control, false, - "wxGridCellTextEditor must be created first!" ); - - const wxString value = Text()->GetValue(); - if ( value == m_value ) - return false; - - m_value = value; - - if ( newval ) - *newval = m_value; - - return true; -} - -void wxGridCellTextEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - grid->GetTable()->SetValue(row, col, m_value); - m_value.clear(); -} - -void wxGridCellTextEditor::Reset() -{ - wxASSERT_MSG( m_control, "wxGridCellTextEditor must be created first!" ); - - DoReset(m_value); -} - -void wxGridCellTextEditor::DoReset(const wxString& startValue) -{ - Text()->SetValue(startValue); - Text()->SetInsertionPointEnd(); -} - -bool wxGridCellTextEditor::IsAcceptedKey(wxKeyEvent& event) -{ - switch ( event.GetKeyCode() ) - { - case WXK_DELETE: - case WXK_BACK: - return true; - - default: - return wxGridCellEditor::IsAcceptedKey(event); - } -} - -void wxGridCellTextEditor::StartingKey(wxKeyEvent& event) -{ - // Since this is now happening in the EVT_CHAR event EmulateKeyPress is no - // longer an appropriate way to get the character into the text control. - // Do it ourselves instead. We know that if we get this far that we have - // a valid character, so not a whole lot of testing needs to be done. - - wxTextCtrl* tc = Text(); - int ch; - - bool isPrintable; - -#if wxUSE_UNICODE - ch = event.GetUnicodeKey(); - if ( ch != WXK_NONE ) - isPrintable = true; - else -#endif // wxUSE_UNICODE - { - ch = event.GetKeyCode(); - isPrintable = ch >= WXK_SPACE && ch < WXK_START; - } - - switch (ch) - { - case WXK_DELETE: - // Delete the initial character when starting to edit with DELETE. - tc->Remove(0, 1); - break; - - case WXK_BACK: - // Delete the last character when starting to edit with BACKSPACE. - { - const long pos = tc->GetLastPosition(); - tc->Remove(pos - 1, pos); - } - break; - - default: - if ( isPrintable ) - tc->WriteText(static_cast(ch)); - break; - } -} - -void wxGridCellTextEditor::HandleReturn( wxKeyEvent& - WXUNUSED_GTK(WXUNUSED_MOTIF(event)) ) -{ -#if defined(__WXMOTIF__) || defined(__WXGTK__) - // wxMotif needs a little extra help... - size_t pos = (size_t)( Text()->GetInsertionPoint() ); - wxString s( Text()->GetValue() ); - s = s.Left(pos) + wxT("\n") + s.Mid(pos); - Text()->SetValue(s); - Text()->SetInsertionPoint( pos ); -#else - // the other ports can handle a Return key press - // - event.Skip(); -#endif -} - -void wxGridCellTextEditor::SetParameters(const wxString& params) -{ - if ( !params ) - { - // reset to default - m_maxChars = 0; - } - else - { - long tmp; - if ( params.ToLong(&tmp) ) - { - m_maxChars = (size_t)tmp; - } - else - { - wxLogDebug( wxT("Invalid wxGridCellTextEditor parameter string '%s' ignored"), params.c_str() ); - } - } -} - -#if wxUSE_VALIDATORS -void wxGridCellTextEditor::SetValidator(const wxValidator& validator) -{ - m_validator.reset(static_cast(validator.Clone())); -} -#endif - -wxGridCellEditor *wxGridCellTextEditor::Clone() const -{ - wxGridCellTextEditor* editor = new wxGridCellTextEditor(m_maxChars); -#if wxUSE_VALIDATORS - if ( m_validator ) - { - editor->SetValidator(*m_validator); - } -#endif - return editor; -} - -// return the value in the text control -wxString wxGridCellTextEditor::GetValue() const -{ - return Text()->GetValue(); -} - -// ---------------------------------------------------------------------------- -// wxGridCellNumberEditor -// ---------------------------------------------------------------------------- - -wxGridCellNumberEditor::wxGridCellNumberEditor(int min, int max) -{ - m_min = min; - m_max = max; -} - -void wxGridCellNumberEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ -#if wxUSE_SPINCTRL - if ( HasRange() ) - { - // create a spin ctrl - m_control = new wxSpinCtrl(parent, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxSP_ARROW_KEYS, - m_min, m_max); - - wxGridCellEditor::Create(parent, id, evtHandler); - } - else -#endif - { - // just a text control - wxGridCellTextEditor::Create(parent, id, evtHandler); - -#if wxUSE_VALIDATORS - Text()->SetValidator(wxIntegerValidator()); -#endif - } -} - -void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - // first get the value - wxGridTableBase *table = grid->GetTable(); - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - { - m_value = table->GetValueAsLong(row, col); - } - else - { - m_value = 0; - wxString sValue = table->GetValue(row, col); - if (! sValue.ToLong(&m_value) && ! sValue.empty()) - { - wxFAIL_MSG( wxT("this cell doesn't have numeric value") ); - return; - } - } - -#if wxUSE_SPINCTRL - if ( HasRange() ) - { - Spin()->SetValue((int)m_value); - Spin()->SetFocus(); - } - else -#endif - { - DoBeginEdit(GetString()); - } -} - -bool wxGridCellNumberEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& oldval, wxString *newval) -{ - long value = 0; - wxString text; - -#if wxUSE_SPINCTRL - if ( HasRange() ) - { - value = Spin()->GetValue(); - if ( value == m_value ) - return false; - - text.Printf(wxT("%ld"), value); - } - else // using unconstrained input -#endif // wxUSE_SPINCTRL - { - text = Text()->GetValue(); - if ( text.empty() ) - { - if ( oldval.empty() ) - return false; - } - else // non-empty text now (maybe 0) - { - if ( !text.ToLong(&value) ) - return false; - - // if value == m_value == 0 but old text was "" and new one is - // "0" something still did change - if ( value == m_value && (value || !oldval.empty()) ) - return false; - } - } - - m_value = value; - - if ( newval ) - *newval = text; - - return true; -} - -void wxGridCellNumberEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - wxGridTableBase * const table = grid->GetTable(); - if ( table->CanSetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - table->SetValueAsLong(row, col, m_value); - else - table->SetValue(row, col, wxString::Format("%ld", m_value)); -} - -void wxGridCellNumberEditor::Reset() -{ -#if wxUSE_SPINCTRL - if ( HasRange() ) - { - Spin()->SetValue((int)m_value); - } - else -#endif - { - DoReset(GetString()); - } -} - -bool wxGridCellNumberEditor::IsAcceptedKey(wxKeyEvent& event) -{ - if ( wxGridCellEditor::IsAcceptedKey(event) ) - { - int keycode = event.GetKeyCode(); - if ( (keycode < 128) && - (wxIsdigit(keycode) || keycode == '+' || keycode == '-')) - { - return true; - } - } - - return false; -} - -void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event) -{ - int keycode = event.GetKeyCode(); - if ( !HasRange() ) - { - if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-') - { - wxGridCellTextEditor::StartingKey(event); - - // skip Skip() below - return; - } - } -#if wxUSE_SPINCTRL - else - { - if ( wxIsdigit(keycode) ) - { - wxSpinCtrl* spin = (wxSpinCtrl*)m_control; - spin->SetValue(keycode - '0'); - spin->SetSelection(1,1); - return; - } - } -#endif - - event.Skip(); -} - -void wxGridCellNumberEditor::SetParameters(const wxString& params) -{ - if ( !params ) - { - // reset to default - m_min = - m_max = -1; - } - else - { - long tmp; - if ( params.BeforeFirst(wxT(',')).ToLong(&tmp) ) - { - m_min = (int)tmp; - - if ( params.AfterFirst(wxT(',')).ToLong(&tmp) ) - { - m_max = (int)tmp; - - // skip the error message below - return; - } - } - - wxLogDebug(wxT("Invalid wxGridCellNumberEditor parameter string '%s' ignored"), params.c_str()); - } -} - -// return the value in the spin control if it is there (the text control otherwise) -wxString wxGridCellNumberEditor::GetValue() const -{ - wxString s; - -#if wxUSE_SPINCTRL - if ( HasRange() ) - { - long value = Spin()->GetValue(); - s.Printf(wxT("%ld"), value); - } - else -#endif - { - s = Text()->GetValue(); - } - - return s; -} - -// ---------------------------------------------------------------------------- -// wxGridCellFloatEditor -// ---------------------------------------------------------------------------- - -wxGridCellFloatEditor::wxGridCellFloatEditor(int width, - int precision, - int format) -{ - m_width = width; - m_precision = precision; - m_style = format; -} - -void wxGridCellFloatEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ - wxGridCellTextEditor::Create(parent, id, evtHandler); - -#if wxUSE_VALIDATORS - Text()->SetValidator(wxFloatingPointValidator(m_precision)); -#endif -} - -void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - // first get the value - wxGridTableBase * const table = grid->GetTable(); - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_FLOAT) ) - { - m_value = table->GetValueAsDouble(row, col); - } - else - { - m_value = 0.0; - - const wxString value = table->GetValue(row, col); - if ( !value.empty() ) - { - if ( !value.ToDouble(&m_value) ) - { - wxFAIL_MSG( wxT("this cell doesn't have float value") ); - return; - } - } - } - - DoBeginEdit(GetString()); -} - -bool wxGridCellFloatEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& oldval, wxString *newval) -{ - const wxString text(Text()->GetValue()); - - double value; - if ( !text.empty() ) - { - if ( !text.ToDouble(&value) ) - return false; - } - else // new value is empty string - { - if ( oldval.empty() ) - return false; // nothing changed - - value = 0.; - } - - // the test for empty strings ensures that we don't skip the value setting - // when "" is replaced by "0" or vice versa as "" numeric value is also 0. - if ( wxIsSameDouble(value, m_value) && !text.empty() && !oldval.empty() ) - return false; // nothing changed - - m_value = value; - - if ( newval ) - *newval = text; - - return true; -} - -void wxGridCellFloatEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - wxGridTableBase * const table = grid->GetTable(); - - if ( table->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT) ) - table->SetValueAsDouble(row, col, m_value); - else - table->SetValue(row, col, Text()->GetValue()); -} - -void wxGridCellFloatEditor::Reset() -{ - DoReset(GetString()); -} - -void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event) -{ - int keycode = event.GetKeyCode(); - char tmpbuf[2]; - tmpbuf[0] = (char) keycode; - tmpbuf[1] = '\0'; - wxString strbuf(tmpbuf, *wxConvCurrent); - -#if wxUSE_INTL - bool is_decimal_point = ( strbuf == - wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) ); -#else - bool is_decimal_point = ( strbuf == wxT(".") ); -#endif - - if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-' - || is_decimal_point ) - { - wxGridCellTextEditor::StartingKey(event); - - // skip Skip() below - return; - } - - event.Skip(); -} - -void wxGridCellFloatEditor::SetParameters(const wxString& params) -{ - if ( !params ) - { - // reset to default - m_width = - m_precision = -1; - m_style = wxGRID_FLOAT_FORMAT_DEFAULT; - m_format.clear(); - } - else - { - wxString rest; - wxString tmp = params.BeforeFirst(wxT(','), &rest); - if ( !tmp.empty() ) - { - long width; - if ( tmp.ToLong(&width) ) - { - m_width = (int)width; - } - else - { - wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params.c_str()); - } - } - - tmp = rest.BeforeFirst(wxT(',')); - if ( !tmp.empty() ) - { - long precision; - if ( tmp.ToLong(&precision) ) - { - m_precision = (int)precision; - } - else - { - wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params.c_str()); - } - } - - tmp = rest.AfterFirst(wxT(',')); - if ( !tmp.empty() ) - { - if ( tmp[0] == wxT('f') ) - { - m_style = wxGRID_FLOAT_FORMAT_FIXED; - } - else if ( tmp[0] == wxT('e') ) - { - m_style = wxGRID_FLOAT_FORMAT_SCIENTIFIC; - } - else if ( tmp[0] == wxT('g') ) - { - m_style = wxGRID_FLOAT_FORMAT_COMPACT; - } - else if ( tmp[0] == wxT('E') ) - { - m_style = wxGRID_FLOAT_FORMAT_SCIENTIFIC | - wxGRID_FLOAT_FORMAT_UPPER; - } - else if ( tmp[0] == wxT('F') ) - { - m_style = wxGRID_FLOAT_FORMAT_FIXED | - wxGRID_FLOAT_FORMAT_UPPER; - } - else if ( tmp[0] == wxT('G') ) - { - m_style = wxGRID_FLOAT_FORMAT_COMPACT | - wxGRID_FLOAT_FORMAT_UPPER; - } - else - { - wxLogDebug("Invalid wxGridCellFloatRenderer format " - "parameter string '%s ignored", params); - } - } - } -} - -wxString wxGridCellFloatEditor::GetString() -{ - if ( !m_format ) - { - if ( m_precision == -1 && m_width != -1) - { - // default precision - m_format.Printf(wxT("%%%d."), m_width); - } - else if ( m_precision != -1 && m_width == -1) - { - // default width - m_format.Printf(wxT("%%.%d"), m_precision); - } - else if ( m_precision != -1 && m_width != -1 ) - { - m_format.Printf(wxT("%%%d.%d"), m_width, m_precision); - } - else - { - // default width/precision - m_format = wxT("%"); - } - - bool isUpper = (m_style & wxGRID_FLOAT_FORMAT_UPPER) != 0; - if ( m_style & wxGRID_FLOAT_FORMAT_SCIENTIFIC ) - m_format += isUpper ? wxT('E') : wxT('e'); - else if ( m_style & wxGRID_FLOAT_FORMAT_COMPACT ) - m_format += isUpper ? wxT('G') : wxT('g'); - else - m_format += wxT('f'); - } - - return wxString::Format(m_format, m_value); -} - -bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event) -{ - if ( wxGridCellEditor::IsAcceptedKey(event) ) - { - const int keycode = event.GetKeyCode(); - if ( wxIsascii(keycode) ) - { -#if wxUSE_INTL - const wxString decimalPoint = - wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); -#else - const wxString decimalPoint(wxT('.')); -#endif - - // accept digits, 'e' as in '1e+6', also '-', '+', and '.' - if ( wxIsdigit(keycode) || - tolower(keycode) == 'e' || - keycode == decimalPoint || - keycode == '+' || - keycode == '-' ) - { - return true; - } - } - } - - return false; -} - -#endif // wxUSE_TEXTCTRL - -#if wxUSE_CHECKBOX - -// ---------------------------------------------------------------------------- -// wxGridCellBoolEditor -// ---------------------------------------------------------------------------- - -// the default values for GetValue() -wxString wxGridCellBoolEditor::ms_stringValues[2] = { wxT(""), wxT("1") }; - -void wxGridCellBoolEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ - m_control = new wxCheckBox(parent, id, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxNO_BORDER); - - wxGridCellEditor::Create(parent, id, evtHandler); -} - -void wxGridCellBoolEditor::SetSize(const wxRect& r) -{ - bool resize = false; - wxSize size = m_control->GetSize(); - wxCoord minSize = wxMin(r.width, r.height); - - // check if the checkbox is not too big/small for this cell - wxSize sizeBest = m_control->GetBestSize(); - if ( !(size == sizeBest) ) - { - // reset to default size if it had been made smaller - size = sizeBest; - - resize = true; - } - - if ( size.x >= minSize || size.y >= minSize ) - { - // leave 1 pixel margin - size.x = size.y = minSize - 2; - - resize = true; - } - - if ( resize ) - { - m_control->SetSize(size); - } - - // position it in the centre of the rectangle (TODO: support alignment?) - -#if defined(__WXGTK__) || defined (__WXMOTIF__) - // the checkbox without label still has some space to the right in wxGTK, - // so shift it to the right - size.x -= 8; -#elif defined(__WXMSW__) - // here too, but in other way - size.x += 1; - size.y -= 2; -#endif - - int hAlign = wxALIGN_CENTRE; - int vAlign = wxALIGN_CENTRE; - if (GetCellAttr()) - GetCellAttr()->GetAlignment(& hAlign, & vAlign); - - int x = 0, y = 0; - if (hAlign == wxALIGN_LEFT) - { - x = r.x + 2; - -#ifdef __WXMSW__ - x += 2; -#endif - - y = r.y + r.height / 2 - size.y / 2; - } - else if (hAlign == wxALIGN_RIGHT) - { - x = r.x + r.width - size.x - 2; - y = r.y + r.height / 2 - size.y / 2; - } - else if (hAlign == wxALIGN_CENTRE) - { - x = r.x + r.width / 2 - size.x / 2; - y = r.y + r.height / 2 - size.y / 2; - } - - m_control->Move(x, y); -} - -void wxGridCellBoolEditor::Show(bool show, wxGridCellAttr *attr) -{ - m_control->Show(show); - - if ( show ) - { - wxColour colBg = attr ? attr->GetBackgroundColour() : *wxLIGHT_GREY; - CBox()->SetBackgroundColour(colBg); - } -} - -void wxGridCellBoolEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - wxASSERT_MSG(m_control, - wxT("The wxGridCellEditor must be created first!")); - - if (grid->GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL)) - { - m_value = grid->GetTable()->GetValueAsBool(row, col); - } - else - { - wxString cellval( grid->GetTable()->GetValue(row, col) ); - - if ( cellval == ms_stringValues[false] ) - m_value = false; - else if ( cellval == ms_stringValues[true] ) - m_value = true; - else - { - // do not try to be smart here and convert it to true or false - // because we'll still overwrite it with something different and - // this risks to be very surprising for the user code, let them - // know about it - wxFAIL_MSG( wxT("invalid value for a cell with bool editor!") ); - } - } - - CBox()->SetValue(m_value); - CBox()->SetFocus(); -} - -bool wxGridCellBoolEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& WXUNUSED(oldval), - wxString *newval) -{ - bool value = CBox()->GetValue(); - if ( value == m_value ) - return false; - - m_value = value; - - if ( newval ) - *newval = GetValue(); - - return true; -} - -void wxGridCellBoolEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - wxGridTableBase * const table = grid->GetTable(); - if ( table->CanSetValueAs(row, col, wxGRID_VALUE_BOOL) ) - table->SetValueAsBool(row, col, m_value); - else - table->SetValue(row, col, GetValue()); -} - -void wxGridCellBoolEditor::Reset() -{ - wxASSERT_MSG(m_control, - wxT("The wxGridCellEditor must be created first!")); - - CBox()->SetValue(m_value); -} - -void wxGridCellBoolEditor::StartingClick() -{ - CBox()->SetValue(!CBox()->GetValue()); -} - -bool wxGridCellBoolEditor::IsAcceptedKey(wxKeyEvent& event) -{ - if ( wxGridCellEditor::IsAcceptedKey(event) ) - { - int keycode = event.GetKeyCode(); - switch ( keycode ) - { - case WXK_SPACE: - case '+': - case '-': - return true; - } - } - - return false; -} - -void wxGridCellBoolEditor::StartingKey(wxKeyEvent& event) -{ - int keycode = event.GetKeyCode(); - switch ( keycode ) - { - case WXK_SPACE: - CBox()->SetValue(!CBox()->GetValue()); - break; - - case '+': - CBox()->SetValue(true); - break; - - case '-': - CBox()->SetValue(false); - break; - } -} - -wxString wxGridCellBoolEditor::GetValue() const -{ - return ms_stringValues[CBox()->GetValue()]; -} - -/* static */ void -wxGridCellBoolEditor::UseStringValues(const wxString& valueTrue, - const wxString& valueFalse) -{ - ms_stringValues[false] = valueFalse; - ms_stringValues[true] = valueTrue; -} - -/* static */ bool -wxGridCellBoolEditor::IsTrueValue(const wxString& value) -{ - return value == ms_stringValues[true]; -} - -#endif // wxUSE_CHECKBOX - -#if wxUSE_COMBOBOX - -// ---------------------------------------------------------------------------- -// wxGridCellChoiceEditor -// ---------------------------------------------------------------------------- - -wxGridCellChoiceEditor::wxGridCellChoiceEditor(const wxArrayString& choices, - bool allowOthers) - : m_choices(choices), - m_allowOthers(allowOthers) { } - -wxGridCellChoiceEditor::wxGridCellChoiceEditor(size_t count, - const wxString choices[], - bool allowOthers) - : m_allowOthers(allowOthers) -{ - if ( count ) - { - m_choices.Alloc(count); - for ( size_t n = 0; n < count; n++ ) - { - m_choices.Add(choices[n]); - } - } -} - -wxGridCellEditor *wxGridCellChoiceEditor::Clone() const -{ - wxGridCellChoiceEditor *editor = new wxGridCellChoiceEditor; - editor->m_allowOthers = m_allowOthers; - editor->m_choices = m_choices; - - return editor; -} - -void wxGridCellChoiceEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ - int style = wxTE_PROCESS_ENTER | - wxTE_PROCESS_TAB | - wxBORDER_NONE; - - if ( !m_allowOthers ) - style |= wxCB_READONLY; - m_control = new wxComboBox(parent, id, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - m_choices, - style); - - wxGridCellEditor::Create(parent, id, evtHandler); -} - -void wxGridCellChoiceEditor::SetSize(const wxRect& rect) -{ - wxASSERT_MSG(m_control, - wxT("The wxGridCellChoiceEditor must be created first!")); - - // Check that the height is not too small to fit the combobox. - wxRect rectTallEnough = rect; - const wxSize bestSize = m_control->GetBestSize(); - const wxCoord diffY = bestSize.GetHeight() - rectTallEnough.GetHeight(); - if ( diffY > 0 ) - { - // Do make it tall enough. - rectTallEnough.height += diffY; - - // Also centre the effective rectangle vertically with respect to the - // original one. - rectTallEnough.y -= diffY/2; - } - //else: The rectangle provided is already tall enough. - - wxGridCellEditor::SetSize(rectTallEnough); -} - -void wxGridCellChoiceEditor::PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr) -{ - // as we fill the entire client area, don't do anything here to minimize - // flicker - - // TODO: It doesn't actually fill the client area since the height of a - // combo always defaults to the standard. Until someone has time to - // figure out the right rectangle to paint, just do it the normal way. - wxGridCellEditor::PaintBackground(dc, rectCell, attr); -} - -void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - wxASSERT_MSG(m_control, - wxT("The wxGridCellEditor must be created first!")); - - wxGridCellEditorEvtHandler* evtHandler = NULL; - if (m_control) - evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler); - - // Don't immediately end if we get a kill focus event within BeginEdit - if (evtHandler) - evtHandler->SetInSetFocus(true); - - m_value = grid->GetTable()->GetValue(row, col); - - Reset(); // this updates combo box to correspond to m_value - - Combo()->SetFocus(); - -#ifdef __WXOSX_COCOA__ - // This is a work around for the combobox being simply dismissed when a - // choice is made in it under OS X. The bug is almost certainly due to a - // problem in focus events generation logic but it's not obvious to fix and - // for now this at least allows to use wxGrid. - Combo()->Popup(); -#endif - - if (evtHandler) - { - // When dropping down the menu, a kill focus event - // happens after this point, so we can't reset the flag yet. -#if !defined(__WXGTK20__) - evtHandler->SetInSetFocus(false); -#endif - } -} - -bool wxGridCellChoiceEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& WXUNUSED(oldval), - wxString *newval) -{ - const wxString value = Combo()->GetValue(); - if ( value == m_value ) - return false; - - m_value = value; - - if ( newval ) - *newval = value; - - return true; -} - -void wxGridCellChoiceEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - grid->GetTable()->SetValue(row, col, m_value); -} - -void wxGridCellChoiceEditor::Reset() -{ - if (m_allowOthers) - { - Combo()->SetValue(m_value); - Combo()->SetInsertionPointEnd(); - } - else // the combobox is read-only - { - // find the right position, or default to the first if not found - int pos = Combo()->FindString(m_value); - if (pos == wxNOT_FOUND) - pos = 0; - Combo()->SetSelection(pos); - } -} - -void wxGridCellChoiceEditor::SetParameters(const wxString& params) -{ - if ( !params ) - { - // what can we do? - return; - } - - m_choices.Empty(); - - wxStringTokenizer tk(params, wxT(',')); - while ( tk.HasMoreTokens() ) - { - m_choices.Add(tk.GetNextToken()); - } -} - -// return the value in the text control -wxString wxGridCellChoiceEditor::GetValue() const -{ - return Combo()->GetValue(); -} - -#endif // wxUSE_COMBOBOX - -#if wxUSE_COMBOBOX - -// ---------------------------------------------------------------------------- -// wxGridCellEnumEditor -// ---------------------------------------------------------------------------- - -// A cell editor which displays an enum number as a textual equivalent. eg -// data in cell is 0,1,2 ... n the cell could be displayed as -// "John","Fred"..."Bob" in the combo choice box - -wxGridCellEnumEditor::wxGridCellEnumEditor(const wxString& choices) - :wxGridCellChoiceEditor() -{ - m_index = -1; - - if (!choices.empty()) - SetParameters(choices); -} - -wxGridCellEditor *wxGridCellEnumEditor::Clone() const -{ - wxGridCellEnumEditor *editor = new wxGridCellEnumEditor(); - editor->m_index = m_index; - return editor; -} - -void wxGridCellEnumEditor::BeginEdit(int row, int col, wxGrid* grid) -{ - wxASSERT_MSG(m_control, - wxT("The wxGridCellEnumEditor must be Created first!")); - - wxGridCellEditorEvtHandler* evtHandler = NULL; - if (m_control) - evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler); - - // Don't immediately end if we get a kill focus event within BeginEdit - if (evtHandler) - evtHandler->SetInSetFocus(true); - - wxGridTableBase *table = grid->GetTable(); - - if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - { - m_index = table->GetValueAsLong(row, col); - } - else - { - wxString startValue = table->GetValue(row, col); - if (startValue.IsNumber() && !startValue.empty()) - { - startValue.ToLong(&m_index); - } - else - { - m_index = -1; - } - } - - Combo()->SetSelection(m_index); - Combo()->SetFocus(); - -#ifdef __WXOSX_COCOA__ - // This is a work around for the combobox being simply dismissed when a - // choice is made in it under OS X. The bug is almost certainly due to a - // problem in focus events generation logic but it's not obvious to fix and - // for now this at least allows to use wxGrid. - Combo()->Popup(); -#endif - - if (evtHandler) - { - // When dropping down the menu, a kill focus event - // happens after this point, so we can't reset the flag yet. -#if !defined(__WXGTK20__) - evtHandler->SetInSetFocus(false); -#endif - } -} - -bool wxGridCellEnumEditor::EndEdit(int WXUNUSED(row), - int WXUNUSED(col), - const wxGrid* WXUNUSED(grid), - const wxString& WXUNUSED(oldval), - wxString *newval) -{ - long idx = Combo()->GetSelection(); - if ( idx == m_index ) - return false; - - m_index = idx; - - if ( newval ) - newval->Printf("%ld", m_index); - - return true; -} - -void wxGridCellEnumEditor::ApplyEdit(int row, int col, wxGrid* grid) -{ - wxGridTableBase * const table = grid->GetTable(); - if ( table->CanSetValueAs(row, col, wxGRID_VALUE_NUMBER) ) - table->SetValueAsLong(row, col, m_index); - else - table->SetValue(row, col, wxString::Format("%ld", m_index)); -} - -#endif // wxUSE_COMBOBOX - -// ---------------------------------------------------------------------------- -// wxGridCellAutoWrapStringEditor -// ---------------------------------------------------------------------------- - -void -wxGridCellAutoWrapStringEditor::Create(wxWindow* parent, - wxWindowID id, - wxEvtHandler* evtHandler) -{ - wxGridCellTextEditor::DoCreate(parent, id, evtHandler, - wxTE_MULTILINE | wxTE_RICH); -} - - -#endif // wxUSE_GRID diff --git a/Source/3rd Party/wx/src/generic/gridsel.cpp b/Source/3rd Party/wx/src/generic/gridsel.cpp deleted file mode 100644 index e79f7f203..000000000 --- a/Source/3rd Party/wx/src/generic/gridsel.cpp +++ /dev/null @@ -1,1238 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Name: src/generic/gridsel.cpp -// Purpose: wxGridSelection -// Author: Stefan Neis -// Modified by: -// Created: 20/02/1999 -// Copyright: (c) Stefan Neis (Stefan.Neis@t-online.de) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#if wxUSE_GRID - -#include "wx/generic/gridsel.h" - - -// Some explanation for the members of the class: -// m_cellSelection stores individual selected cells -// -- this is only used if m_selectionMode == wxGridSelectCells -// m_blockSelectionTopLeft and m_blockSelectionBottomRight -// store the upper left and lower right corner of selected Blocks -// m_rowSelection and m_colSelection store individual selected -// rows and columns; maybe those are superfluous and should be -// treated as blocks? - -wxGridSelection::wxGridSelection( wxGrid * grid, - wxGrid::wxGridSelectionModes sel ) -{ - m_grid = grid; - m_selectionMode = sel; -} - -bool wxGridSelection::IsSelection() -{ - return ( m_cellSelection.GetCount() || m_blockSelectionTopLeft.GetCount() || - m_rowSelection.GetCount() || m_colSelection.GetCount() ); -} - -bool wxGridSelection::IsInSelection( int row, int col ) -{ - size_t count; - - // First check whether the given cell is individually selected - // (if m_selectionMode is wxGridSelectCells). - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - count = m_cellSelection.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - if ( row == coords.GetRow() && col == coords.GetCol() ) - return true; - } - } - - // Now check whether the given cell is - // contained in one of the selected blocks. - count = m_blockSelectionTopLeft.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - if ( BlockContainsCell(coords1.GetRow(), coords1.GetCol(), - coords2.GetRow(), coords2.GetCol(), - row, col ) ) - return true; - } - - // Now check whether the given cell is - // contained in one of the selected rows - // (unless we are in column selection mode). - if ( m_selectionMode != wxGrid::wxGridSelectColumns ) - { - count = m_rowSelection.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - if ( row == m_rowSelection[n] ) - return true; - } - } - - // Now check whether the given cell is - // contained in one of the selected columns - // (unless we are in row selection mode). - if ( m_selectionMode != wxGrid::wxGridSelectRows ) - { - count = m_colSelection.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - if ( col == m_colSelection[n] ) - return true; - } - } - - return false; -} - -// Change the selection mode -void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode ) -{ - // if selection mode is unchanged return immediately - if (selmode == m_selectionMode) - return; - - if ( m_selectionMode != wxGrid::wxGridSelectCells ) - { - // if changing form row to column selection - // or vice versa, clear the selection. - if ( selmode != wxGrid::wxGridSelectCells ) - ClearSelection(); - - m_selectionMode = selmode; - } - else - { - // if changing from cell selection to something else, - // promote selected cells/blocks to whole rows/columns. - size_t n; - while ( ( n = m_cellSelection.GetCount() ) > 0 ) - { - n--; - wxGridCellCoords& coords = m_cellSelection[n]; - int row = coords.GetRow(); - int col = coords.GetCol(); - m_cellSelection.RemoveAt(n); - if (selmode == wxGrid::wxGridSelectRows) - SelectRow( row ); - else // selmode == wxGridSelectColumns) - SelectCol( col ); - } - - // Note that m_blockSelectionTopLeft's size may be changing! - for (n = 0; n < m_blockSelectionTopLeft.GetCount(); n++) - { - wxGridCellCoords& coords = m_blockSelectionTopLeft[n]; - int topRow = coords.GetRow(); - int leftCol = coords.GetCol(); - coords = m_blockSelectionBottomRight[n]; - int bottomRow = coords.GetRow(); - int rightCol = coords.GetCol(); - - if (selmode == wxGrid::wxGridSelectRows) - { - if (leftCol != 0 || rightCol != m_grid->GetNumberCols() - 1 ) - { - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - SelectBlockNoEvent( topRow, 0, - bottomRow, m_grid->GetNumberCols() - 1); - } - } - else // selmode == wxGridSelectColumns) - { - if (topRow != 0 || bottomRow != m_grid->GetNumberRows() - 1 ) - { - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - SelectBlockNoEvent(0, leftCol, - m_grid->GetNumberRows() - 1, rightCol); - } - } - } - - m_selectionMode = selmode; - } -} - -void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd) -{ - if ( m_selectionMode == wxGrid::wxGridSelectColumns ) - return; - - size_t count, n; - - // Remove single cells contained in newly selected block. - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - count = m_cellSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - if ( BlockContainsCell( row, 0, row, m_grid->GetNumberCols() - 1, - coords.GetRow(), coords.GetCol() ) ) - { - m_cellSelection.RemoveAt(n); - n--; - count--; - } - } - } - - // Simplify list of selected blocks (if possible) - count = m_blockSelectionTopLeft.GetCount(); - bool done = false; - - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - - // Remove block if it is a subset of the row - if ( coords1.GetRow() == row && row == coords2.GetRow() ) - { - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - } - else if ( coords1.GetCol() == 0 && - coords2.GetCol() == m_grid->GetNumberCols() - 1 ) - { - // silently return, if row is contained in block - if ( coords1.GetRow() <= row && row <= coords2.GetRow() ) - return; - // expand block, if it touched row - else if ( coords1.GetRow() == row + 1) - { - coords1.SetRow(row); - done = true; - } - else if ( coords2.GetRow() == row - 1) - { - coords2.SetRow(row); - done = true; - } - } - } - - // Unless we successfully handled the row, - // check whether row is already selected. - if ( !done ) - { - count = m_rowSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - if ( row == m_rowSelection[n] ) - return; - } - - // Add row to selection - m_rowSelection.Add(row); - } - - // Update View: - if ( !m_grid->GetBatchCount() ) - { - wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ), - wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - // Send Event - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( row, 0 ), - wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ), - true, - kbd); - - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); -} - -void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd) -{ - if ( m_selectionMode == wxGrid::wxGridSelectRows ) - return; - size_t count, n; - - // Remove single cells contained in newly selected block. - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - count = m_cellSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - if ( BlockContainsCell( 0, col, m_grid->GetNumberRows() - 1, col, - coords.GetRow(), coords.GetCol() ) ) - { - m_cellSelection.RemoveAt(n); - n--; - count--; - } - } - } - - // Simplify list of selected blocks (if possible) - count = m_blockSelectionTopLeft.GetCount(); - bool done = false; - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - - // Remove block if it is a subset of the column - if ( coords1.GetCol() == col && col == coords2.GetCol() ) - { - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - } - else if ( coords1.GetRow() == 0 && - coords2.GetRow() == m_grid->GetNumberRows() - 1 ) - { - // silently return, if row is contained in block - if ( coords1.GetCol() <= col && col <= coords2.GetCol() ) - return; - // expand block, if it touched col - else if ( coords1.GetCol() == col + 1) - { - coords1.SetCol(col); - done = true; - } - else if ( coords2.GetCol() == col - 1) - { - coords2.SetCol(col); - done = true; - } - } - } - - // Unless we successfully handled the column, - // Check whether col is already selected. - if ( !done ) - { - count = m_colSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - if ( col == m_colSelection[n] ) - return; - } - - // Add col to selection - m_colSelection.Add(col); - } - - // Update View: - if ( !m_grid->GetBatchCount() ) - { - wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ), - wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - // Send Event - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( 0, col ), - wxGridCellCoords( m_grid->GetNumberRows() - 1, col ), - true, - kbd ); - - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); -} - -void wxGridSelection::SelectBlock( int topRow, int leftCol, - int bottomRow, int rightCol, - const wxKeyboardState& kbd, - bool sendEvent ) -{ - // Fix the coordinates of the block if needed. - switch ( m_selectionMode ) - { - default: - wxFAIL_MSG( "unknown selection mode" ); - // fall through - - case wxGrid::wxGridSelectCells: - // nothing to do -- in this mode arbitrary blocks can be selected - break; - - case wxGrid::wxGridSelectRows: - leftCol = 0; - rightCol = m_grid->GetNumberCols() - 1; - break; - - case wxGrid::wxGridSelectColumns: - topRow = 0; - bottomRow = m_grid->GetNumberRows() - 1; - break; - - case wxGrid::wxGridSelectRowsOrColumns: - // block selection doesn't make sense for this mode, we could only - // select the entire grid but this wouldn't be useful - return; - } - - if ( topRow > bottomRow ) - { - int temp = topRow; - topRow = bottomRow; - bottomRow = temp; - } - - if ( leftCol > rightCol ) - { - int temp = leftCol; - leftCol = rightCol; - rightCol = temp; - } - - // Handle single cell selection in SelectCell. - // (MB: added check for selection mode here to prevent - // crashes if, for example, we are select rows and the - // grid only has 1 col) - if ( m_selectionMode == wxGrid::wxGridSelectCells && - topRow == bottomRow && leftCol == rightCol ) - { - SelectCell( topRow, leftCol, kbd, sendEvent ); - } - - size_t count, n; - - if ( m_selectionMode == wxGrid::wxGridSelectRows ) - { - // find out which rows are already selected: - wxArrayInt alreadyselected; - alreadyselected.Add(0,bottomRow-topRow+1); - for( n = 0; n < m_rowSelection.GetCount(); n++) - { - int row = m_rowSelection[n]; - if( (row >= topRow) && (row <= bottomRow) ) - { - alreadyselected[ row - topRow ]=1; - } - } - - // add the newly selected rows: - for ( int row = topRow; row <= bottomRow; row++ ) - { - if ( alreadyselected[ row - topRow ] == 0 ) - { - m_rowSelection.Add( row ); - } - } - } - else if ( m_selectionMode == wxGrid::wxGridSelectColumns ) - { - // find out which columns are already selected: - wxArrayInt alreadyselected; - alreadyselected.Add(0,rightCol-leftCol+1); - for( n = 0; n < m_colSelection.GetCount(); n++) - { - int col = m_colSelection[n]; - if( (col >= leftCol) && (col <= rightCol) ) - { - alreadyselected[ col - leftCol ]=1; - } - } - - // add the newly selected columns: - for ( int col = leftCol; col <= rightCol; col++ ) - { - if ( alreadyselected[ col - leftCol ] == 0 ) - { - m_colSelection.Add( col ); - } - } - } - else - { - // Remove single cells contained in newly selected block. - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - count = m_cellSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - if ( BlockContainsCell( topRow, leftCol, bottomRow, rightCol, - coords.GetRow(), coords.GetCol() ) ) - { - m_cellSelection.RemoveAt(n); - n--; - count--; - } - } - } - - // If a block containing the selection is already selected, return, - // if a block contained in the selection is found, remove it. - - count = m_blockSelectionTopLeft.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - - switch ( BlockContain( coords1.GetRow(), coords1.GetCol(), - coords2.GetRow(), coords2.GetCol(), - topRow, leftCol, bottomRow, rightCol ) ) - { - case 1: - return; - - case -1: - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - break; - - default: - break; - } - } - - // If a row containing the selection is already selected, return, - // if a row contained in newly selected block is found, remove it. - count = m_rowSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - switch ( BlockContain( m_rowSelection[n], 0, - m_rowSelection[n], m_grid->GetNumberCols() - 1, - topRow, leftCol, bottomRow, rightCol ) ) - { - case 1: - return; - - case -1: - m_rowSelection.RemoveAt(n); - n--; - count--; - break; - - default: - break; - } - } - - // Same for columns. - count = m_colSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - switch ( BlockContain( 0, m_colSelection[n], - m_grid->GetNumberRows() - 1, m_colSelection[n], - topRow, leftCol, bottomRow, rightCol ) ) - { - case 1: - return; - - case -1: - m_colSelection.RemoveAt(n); - n--; - count--; - break; - - default: - break; - } - } - - m_blockSelectionTopLeft.Add( wxGridCellCoords( topRow, leftCol ) ); - m_blockSelectionBottomRight.Add( wxGridCellCoords( bottomRow, rightCol ) ); - } - // Update View: - if ( !m_grid->GetBatchCount() ) - { - wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( topRow, leftCol ), - wxGridCellCoords( bottomRow, rightCol ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - // Send Event, if not disabled. - if ( sendEvent ) - { - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( topRow, leftCol ), - wxGridCellCoords( bottomRow, rightCol ), - true, - kbd); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - } -} - -void wxGridSelection::SelectCell( int row, int col, - const wxKeyboardState& kbd, - bool sendEvent ) -{ - if ( IsInSelection ( row, col ) ) - return; - - wxGridCellCoords selectedTopLeft, selectedBottomRight; - if ( m_selectionMode == wxGrid::wxGridSelectRows ) - { - m_rowSelection.Add( row ); - selectedTopLeft = wxGridCellCoords( row, 0 ); - selectedBottomRight = wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ); - } - else if ( m_selectionMode == wxGrid::wxGridSelectColumns ) - { - m_colSelection.Add( col ); - selectedTopLeft = wxGridCellCoords( 0, col ); - selectedBottomRight = wxGridCellCoords( m_grid->GetNumberRows() - 1, col ); - } - else - { - m_cellSelection.Add( wxGridCellCoords( row, col ) ); - selectedTopLeft = wxGridCellCoords( row, col ); - selectedBottomRight = wxGridCellCoords( row, col ); - } - - // Update View: - if ( !m_grid->GetBatchCount() ) - { - wxRect r = m_grid->BlockToDeviceRect( - selectedTopLeft, - selectedBottomRight ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - // Send event - if (sendEvent) - { - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - selectedTopLeft, - selectedBottomRight, - true, - kbd); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - } -} - -void -wxGridSelection::ToggleCellSelection(int row, int col, - const wxKeyboardState& kbd) -{ - // if the cell is not selected, select it - if ( !IsInSelection ( row, col ) ) - { - SelectCell(row, col, kbd); - - return; - } - - // otherwise deselect it. This can be simple or more or - // less difficult, depending on how the cell is selected. - size_t count, n; - - // The simplest case: The cell is contained in m_cellSelection - // Then it can't be contained in rows/cols/block (since those - // would remove the cell from m_cellSelection on creation), so - // we just have to remove it from m_cellSelection. - - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - count = m_cellSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - const wxGridCellCoords& sel = m_cellSelection[n]; - if ( row == sel.GetRow() && col == sel.GetCol() ) - { - wxGridCellCoords coords = m_cellSelection[n]; - m_cellSelection.RemoveAt(n); - if ( !m_grid->GetBatchCount() ) - { - wxRect r = m_grid->BlockToDeviceRect( coords, coords ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - // Send event - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( row, col ), - wxGridCellCoords( row, col ), - false, - kbd ); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - - return; - } - } - } - - // The most difficult case: The cell is member of one or even several - // blocks. Split each such block in up to 4 new parts, that don't - // contain the cell to be selected, like this: - // |---------------------------| - // | | - // | part 1 | - // | | - // |---------------------------| - // | part 3 |x| part 4 | - // |---------------------------| - // | | - // | part 2 | - // | | - // |---------------------------| - // (The x marks the newly deselected cell). - // Note: in row selection mode, we only need part1 and part2; - // in column selection mode, we only need part 3 and part4, - // which are expanded to whole columns automatically! - - count = m_blockSelectionTopLeft.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - int topRow = coords1.GetRow(); - int leftCol = coords1.GetCol(); - int bottomRow = coords2.GetRow(); - int rightCol = coords2.GetCol(); - - if ( BlockContainsCell( topRow, leftCol, bottomRow, rightCol, row, col ) ) - { - // remove the block - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - - // add up to 4 smaller blocks and set update region - if ( m_selectionMode != wxGrid::wxGridSelectColumns ) - { - if ( topRow < row ) - SelectBlockNoEvent(topRow, leftCol, row - 1, rightCol); - if ( bottomRow > row ) - SelectBlockNoEvent(row + 1, leftCol, bottomRow, rightCol); - } - - if ( m_selectionMode != wxGrid::wxGridSelectRows ) - { - if ( leftCol < col ) - SelectBlockNoEvent(row, leftCol, row, col - 1); - if ( rightCol > col ) - SelectBlockNoEvent(row, col + 1, row, rightCol); - } - } - } - - bool rowSelectionWasChanged = false; - // remove a cell from a row, adding up to two new blocks - if ( m_selectionMode != wxGrid::wxGridSelectColumns ) - { - count = m_rowSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - if ( m_rowSelection[n] == row ) - { - m_rowSelection.RemoveAt(n); - n--; - count--; - - rowSelectionWasChanged = true; - - if (m_selectionMode == wxGrid::wxGridSelectCells) - { - if ( col > 0 ) - SelectBlockNoEvent(row, 0, row, col - 1); - if ( col < m_grid->GetNumberCols() - 1 ) - SelectBlockNoEvent( row, col + 1, - row, m_grid->GetNumberCols() - 1); - } - } - } - } - - bool colSelectionWasChanged = false; - // remove a cell from a column, adding up to two new blocks - if ( m_selectionMode != wxGrid::wxGridSelectRows ) - { - count = m_colSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - if ( m_colSelection[n] == col ) - { - m_colSelection.RemoveAt(n); - n--; - count--; - - colSelectionWasChanged = true; - - if (m_selectionMode == wxGrid::wxGridSelectCells) - { - if ( row > 0 ) - SelectBlockNoEvent(0, col, row - 1, col); - if ( row < m_grid->GetNumberRows() - 1 ) - SelectBlockNoEvent(row + 1, col, - m_grid->GetNumberRows() - 1, col); - } - } - } - } - - // Refresh the screen and send the event; according to m_selectionMode, - // we need to either update only the cell, or the whole row/column. - wxRect r; - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( - wxGridCellCoords( row, col ), - wxGridCellCoords( row, col ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( row, col ), - wxGridCellCoords( row, col ), - false, - kbd ); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - } - else // rows/columns selection mode - { - if ( m_selectionMode != wxGrid::wxGridSelectColumns && - rowSelectionWasChanged ) - { - int numCols = m_grid->GetNumberCols(); - for ( int colFrom = 0, colTo = 0; colTo <= numCols; ++colTo ) - { - if ( m_colSelection.Index(colTo) >= 0 || colTo == numCols ) - { - if ( colFrom < colTo ) - { - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( - wxGridCellCoords( row, colFrom ), - wxGridCellCoords( row, colTo-1 ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( row, colFrom ), - wxGridCellCoords( row, colTo - 1 ), - false, - kbd ); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - } - - colFrom = colTo + 1; - } - } - } - - if ( m_selectionMode != wxGrid::wxGridSelectRows && - colSelectionWasChanged ) - { - int numRows = m_grid->GetNumberRows(); - for ( int rowFrom = 0, rowTo = 0; rowTo <= numRows; ++rowTo ) - { - if ( m_rowSelection.Index(rowTo) >= 0 || rowTo == numRows ) - { - if (rowFrom < rowTo) - { - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( - wxGridCellCoords( rowFrom, col ), - wxGridCellCoords( rowTo - 1, col ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - } - - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( rowFrom, col ), - wxGridCellCoords( rowTo - 1, col ), - false, - kbd ); - m_grid->GetEventHandler()->ProcessEvent( gridEvt ); - } - - rowFrom = rowTo + 1; - } - } - } - } -} - -void wxGridSelection::ClearSelection() -{ - size_t n; - wxRect r; - wxGridCellCoords coords1, coords2; - - // deselect all individual cells and update the screen - if ( m_selectionMode == wxGrid::wxGridSelectCells ) - { - while ( ( n = m_cellSelection.GetCount() ) > 0) - { - n--; - coords1 = m_cellSelection[n]; - m_cellSelection.RemoveAt(n); - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( coords1, coords1 ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - -#ifdef __WXMAC__ - ((wxWindow *)m_grid->m_gridWin)->Update(); -#endif - } - } - } - - // deselect all blocks and update the screen - while ( ( n = m_blockSelectionTopLeft.GetCount() ) > 0) - { - n--; - coords1 = m_blockSelectionTopLeft[n]; - coords2 = m_blockSelectionBottomRight[n]; - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( coords1, coords2 ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - -#ifdef __WXMAC__ - ((wxWindow *)m_grid->m_gridWin)->Update(); -#endif - } - } - - // deselect all rows and update the screen - if ( m_selectionMode != wxGrid::wxGridSelectColumns ) - { - while ( ( n = m_rowSelection.GetCount() ) > 0) - { - n--; - int row = m_rowSelection[n]; - m_rowSelection.RemoveAt(n); - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ), - wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - -#ifdef __WXMAC__ - ((wxWindow *)m_grid->m_gridWin)->Update(); -#endif - } - } - } - - // deselect all columns and update the screen - if ( m_selectionMode != wxGrid::wxGridSelectRows ) - { - while ( ( n = m_colSelection.GetCount() ) > 0) - { - n--; - int col = m_colSelection[n]; - m_colSelection.RemoveAt(n); - if ( !m_grid->GetBatchCount() ) - { - r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ), - wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) ); - ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); - -#ifdef __WXMAC__ - ((wxWindow *)m_grid->m_gridWin)->Update(); -#endif - } - } - } - - // One deselection event, indicating deselection of _all_ cells. - // (No finer grained events for each of the smaller regions - // deselected above!) - wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECT, - m_grid, - wxGridCellCoords( 0, 0 ), - wxGridCellCoords( - m_grid->GetNumberRows() - 1, - m_grid->GetNumberCols() - 1 ), - false ); - - m_grid->GetEventHandler()->ProcessEvent(gridEvt); -} - - -void wxGridSelection::UpdateRows( size_t pos, int numRows ) -{ - size_t count = m_cellSelection.GetCount(); - size_t n; - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - wxCoord row = coords.GetRow(); - if ((size_t)row >= pos) - { - if (numRows > 0) - { - // If rows inserted, increase row counter where necessary - coords.SetRow(row + numRows); - } - else if (numRows < 0) - { - // If rows deleted ... - if ((size_t)row >= pos - numRows) - { - // ...either decrement row counter (if row still exists)... - coords.SetRow(row + numRows); - } - else - { - // ...or remove the attribute - m_cellSelection.RemoveAt(n); - n--; - count--; - } - } - } - } - - count = m_blockSelectionTopLeft.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - wxCoord row1 = coords1.GetRow(); - wxCoord row2 = coords2.GetRow(); - - if ((size_t)row2 >= pos) - { - if (numRows > 0) - { - // If rows inserted, increase row counter where necessary - coords2.SetRow( row2 + numRows ); - if ((size_t)row1 >= pos) - coords1.SetRow( row1 + numRows ); - } - else if (numRows < 0) - { - // If rows deleted ... - if ((size_t)row2 >= pos - numRows) - { - // ...either decrement row counter (if row still exists)... - coords2.SetRow( row2 + numRows ); - if ((size_t)row1 >= pos) - coords1.SetRow( wxMax(row1 + numRows, (int)pos) ); - - } - else - { - if ((size_t)row1 >= pos) - { - // ...or remove the attribute - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - } - else - coords2.SetRow( pos ); - } - } - } - } - - count = m_rowSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - int rowOrCol_ = m_rowSelection[n]; - - if ((size_t) rowOrCol_ >= pos) - { - if ( numRows > 0 ) - { - m_rowSelection[n] += numRows; - } - else if ( numRows < 0 ) - { - if ((size_t)rowOrCol_ >= (pos - numRows)) - m_rowSelection[n] += numRows; - else - { - m_rowSelection.RemoveAt( n ); - n--; - count--; - } - } - } - } - // No need to touch selected columns, unless we removed _all_ - // rows, in this case, we remove all columns from the selection. - - if ( !m_grid->GetNumberRows() ) - m_colSelection.Clear(); -} - - -void wxGridSelection::UpdateCols( size_t pos, int numCols ) -{ - size_t count = m_cellSelection.GetCount(); - size_t n; - - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords = m_cellSelection[n]; - wxCoord col = coords.GetCol(); - if ((size_t)col >= pos) - { - if (numCols > 0) - { - // If rows inserted, increase row counter where necessary - coords.SetCol(col + numCols); - } - else if (numCols < 0) - { - // If rows deleted ... - if ((size_t)col >= pos - numCols) - { - // ...either decrement row counter (if row still exists)... - coords.SetCol(col + numCols); - } - else - { - // ...or remove the attribute - m_cellSelection.RemoveAt(n); - n--; - count--; - } - } - } - } - - count = m_blockSelectionTopLeft.GetCount(); - for ( n = 0; n < count; n++ ) - { - wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; - wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; - wxCoord col1 = coords1.GetCol(); - wxCoord col2 = coords2.GetCol(); - - if ((size_t)col2 >= pos) - { - if (numCols > 0) - { - // If rows inserted, increase row counter where necessary - coords2.SetCol(col2 + numCols); - if ((size_t)col1 >= pos) - coords1.SetCol(col1 + numCols); - } - else if (numCols < 0) - { - // If cols deleted ... - if ((size_t)col2 >= pos - numCols) - { - // ...either decrement col counter (if col still exists)... - coords2.SetCol(col2 + numCols); - if ( (size_t) col1 >= pos) - coords1.SetCol( wxMax(col1 + numCols, (int)pos) ); - - } - else - { - if ((size_t)col1 >= pos) - { - // ...or remove the attribute - m_blockSelectionTopLeft.RemoveAt(n); - m_blockSelectionBottomRight.RemoveAt(n); - n--; - count--; - } - else - coords2.SetCol(pos); - } - } - } - } - - count = m_colSelection.GetCount(); - for ( n = 0; n < count; n++ ) - { - int rowOrCol = m_colSelection[n]; - - if ((size_t)rowOrCol >= pos) - { - if ( numCols > 0 ) - m_colSelection[n] += numCols; - else if ( numCols < 0 ) - { - if ((size_t)rowOrCol >= (pos - numCols)) - m_colSelection[n] += numCols; - else - { - m_colSelection.RemoveAt( n ); - n--; - count--; - } - } - } - } - - // No need to touch selected rows, unless we removed _all_ - // columns, in this case, we remove all rows from the selection. - if ( !m_grid->GetNumberCols() ) - m_rowSelection.Clear(); -} - -int wxGridSelection::BlockContain( int topRow1, int leftCol1, - int bottomRow1, int rightCol1, - int topRow2, int leftCol2, - int bottomRow2, int rightCol2 ) -// returns 1, if Block1 contains Block2, -// -1, if Block2 contains Block1, -// 0, otherwise -{ - if ( topRow1 <= topRow2 && bottomRow2 <= bottomRow1 && - leftCol1 <= leftCol2 && rightCol2 <= rightCol1 ) - return 1; - else if ( topRow2 <= topRow1 && bottomRow1 <= bottomRow2 && - leftCol2 <= leftCol1 && rightCol1 <= rightCol2 ) - return -1; - - return 0; -} - -#endif diff --git a/Source/3rd Party/wx/src/generic/headerctrlg.cpp b/Source/3rd Party/wx/src/generic/headerctrlg.cpp deleted file mode 100644 index 6dcccfdce..000000000 --- a/Source/3rd Party/wx/src/generic/headerctrlg.cpp +++ /dev/null @@ -1,720 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/headerctrlg.cpp -// Purpose: generic wxHeaderCtrl implementation -// Author: Vadim Zeitlin -// Created: 2008-12-03 -// Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_HEADERCTRL - -#include "wx/headerctrl.h" - -#ifdef wxHAS_GENERIC_HEADERCTRL - -#include "wx/dcbuffer.h" -#include "wx/renderer.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -namespace -{ - -const unsigned COL_NONE = (unsigned)-1; - -} // anonymous namespace - -// ============================================================================ -// wxHeaderCtrl implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl creation -// ---------------------------------------------------------------------------- - -void wxHeaderCtrl::Init() -{ - m_numColumns = 0; - m_hover = - m_colBeingResized = - m_colBeingReordered = COL_NONE; - m_dragOffset = 0; - m_scrollOffset = 0; -} - -bool wxHeaderCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( !wxHeaderCtrlBase::Create(parent, id, pos, size, - style, wxDefaultValidator, name) ) - return false; - - // tell the system to not paint the background at all to avoid flicker as - // we paint the entire window area in our OnPaint() - SetBackgroundStyle(wxBG_STYLE_CUSTOM); - - return true; -} - -wxHeaderCtrl::~wxHeaderCtrl() -{ -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl columns manipulation -// ---------------------------------------------------------------------------- - -void wxHeaderCtrl::DoSetCount(unsigned int count) -{ - // update the column indices order array before changing m_numColumns - DoResizeColumnIndices(m_colIndices, count); - - m_numColumns = count; - - InvalidateBestSize(); - Refresh(); -} - -unsigned int wxHeaderCtrl::DoGetCount() const -{ - return m_numColumns; -} - -void wxHeaderCtrl::DoUpdate(unsigned int idx) -{ - InvalidateBestSize(); - - // we need to refresh not only this column but also the ones after it in - // case it was shown or hidden or its width changed -- it would be nice to - // avoid doing this unnecessary by storing the old column width (TODO) - RefreshColsAfter(idx); -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl scrolling -// ---------------------------------------------------------------------------- - -void wxHeaderCtrl::DoScrollHorz(int dx) -{ - m_scrollOffset += dx; - - // don't call our own version which calls this function! - wxControl::ScrollWindow(dx, 0); -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl geometry -// ---------------------------------------------------------------------------- - -wxSize wxHeaderCtrl::DoGetBestSize() const -{ - wxWindow *win = GetParent(); - int height = wxRendererNative::Get().GetHeaderButtonHeight( win ); - - // the vertical size is rather arbitrary but it looks better if we leave - // some space around the text - const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x - : GetColEnd(GetColumnCount() - 1), - height ); // (7*GetCharHeight())/4); - CacheBestSize(size); - return size; -} - -int wxHeaderCtrl::GetColStart(unsigned int idx) const -{ - int pos = m_scrollOffset; - for ( unsigned n = 0; ; n++ ) - { - const unsigned i = m_colIndices[n]; - if ( i == idx ) - break; - - const wxHeaderColumn& col = GetColumn(i); - if ( col.IsShown() ) - pos += col.GetWidth(); - } - - return pos; -} - -int wxHeaderCtrl::GetColEnd(unsigned int idx) const -{ - int x = GetColStart(idx); - - return x + GetColumn(idx).GetWidth(); -} - -unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const -{ - int pos = 0; - const unsigned count = GetColumnCount(); - for ( unsigned n = 0; n < count; n++ ) - { - const unsigned idx = m_colIndices[n]; - const wxHeaderColumn& col = GetColumn(idx); - if ( col.IsHidden() ) - continue; - - pos += col.GetWidth(); - - // if the column is resizable, check if we're approximatively over the - // line separating it from the next column - // - // TODO: don't hardcode sensitivity - if ( col.IsResizeable() && abs(x - pos) < 8 ) - { - if ( onSeparator ) - *onSeparator = true; - return idx; - } - - // inside this column? - if ( x < pos ) - { - if ( onSeparator ) - *onSeparator = false; - return idx; - } - } - - if ( onSeparator ) - *onSeparator = false; - return COL_NONE; -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl repainting -// ---------------------------------------------------------------------------- - -void wxHeaderCtrl::RefreshCol(unsigned int idx) -{ - wxRect rect = GetClientRect(); - rect.x += GetColStart(idx); - rect.width = GetColumn(idx).GetWidth(); - - RefreshRect(rect); -} - -void wxHeaderCtrl::RefreshColIfNotNone(unsigned int idx) -{ - if ( idx != COL_NONE ) - RefreshCol(idx); -} - -void wxHeaderCtrl::RefreshColsAfter(unsigned int idx) -{ - wxRect rect = GetClientRect(); - const int ofs = GetColStart(idx); - rect.x += ofs; - rect.width -= ofs; - - RefreshRect(rect); -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl dragging/resizing/reordering -// ---------------------------------------------------------------------------- - -bool wxHeaderCtrl::IsResizing() const -{ - return m_colBeingResized != COL_NONE; -} - -bool wxHeaderCtrl::IsReordering() const -{ - return m_colBeingReordered != COL_NONE; -} - -void wxHeaderCtrl::ClearMarkers() -{ - wxClientDC dc(this); - - wxDCOverlay dcover(m_overlay, &dc); - dcover.Clear(); -} - -void wxHeaderCtrl::EndDragging() -{ - // We currently only use markers for reordering, not for resizing - if (IsReordering()) - { - ClearMarkers(); - m_overlay.Reset(); - } - - // don't use the special dragging cursor any more - SetCursor(wxNullCursor); -} - -void wxHeaderCtrl::CancelDragging() -{ - wxASSERT_MSG( IsDragging(), - "shouldn't be called if we're not dragging anything" ); - - EndDragging(); - - unsigned int& col = IsResizing() ? m_colBeingResized : m_colBeingReordered; - - wxHeaderCtrlEvent event(wxEVT_HEADER_DRAGGING_CANCELLED, GetId()); - event.SetEventObject(this); - event.SetColumn(col); - - GetEventHandler()->ProcessEvent(event); - - col = COL_NONE; -} - -int wxHeaderCtrl::ConstrainByMinWidth(unsigned int col, int& xPhysical) -{ - const int xStart = GetColStart(col); - - // notice that GetMinWidth() returns 0 if there is no minimal width so it - // still makes sense to use it even in this case - const int xMinEnd = xStart + GetColumn(col).GetMinWidth(); - - if ( xPhysical < xMinEnd ) - xPhysical = xMinEnd; - - return xPhysical - xStart; -} - -void wxHeaderCtrl::StartOrContinueResizing(unsigned int col, int xPhysical) -{ - wxHeaderCtrlEvent event(IsResizing() ? wxEVT_HEADER_RESIZING - : wxEVT_HEADER_BEGIN_RESIZE, - GetId()); - event.SetEventObject(this); - event.SetColumn(col); - - event.SetWidth(ConstrainByMinWidth(col, xPhysical)); - - if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) - { - if ( IsResizing() ) - { - ReleaseMouse(); - CancelDragging(); - } - //else: nothing to do -- we just don't start to resize - } - else // go ahead with resizing - { - if ( !IsResizing() ) - { - m_colBeingResized = col; - SetCursor(wxCursor(wxCURSOR_SIZEWE)); - CaptureMouse(); - } - //else: we had already done the above when we started - - } -} - -void wxHeaderCtrl::EndResizing(int xPhysical) -{ - wxASSERT_MSG( IsResizing(), "shouldn't be called if we're not resizing" ); - - EndDragging(); - - ReleaseMouse(); - - wxHeaderCtrlEvent event(wxEVT_HEADER_END_RESIZE, GetId()); - event.SetEventObject(this); - event.SetColumn(m_colBeingResized); - event.SetWidth(ConstrainByMinWidth(m_colBeingResized, xPhysical)); - - GetEventHandler()->ProcessEvent(event); - - m_colBeingResized = COL_NONE; -} - -void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical) -{ - wxClientDC dc(this); - - wxDCOverlay dcover(m_overlay, &dc); - dcover.Clear(); - - dc.SetPen(*wxBLUE); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - // draw the phantom position of the column being dragged - int x = xPhysical - m_dragOffset; - int y = GetClientSize().y; - dc.DrawRectangle(x, 0, - GetColumn(m_colBeingReordered).GetWidth(), y); - - // and also a hint indicating where it is going to be inserted if it's - // dropped now - unsigned int col = FindColumnAtPoint(xPhysical); - if ( col != COL_NONE ) - { - static const int DROP_MARKER_WIDTH = 4; - - dc.SetBrush(*wxBLUE); - dc.DrawRectangle(GetColEnd(col) - DROP_MARKER_WIDTH/2, 0, - DROP_MARKER_WIDTH, y); - } -} - -void wxHeaderCtrl::StartReordering(unsigned int col, int xPhysical) -{ - wxHeaderCtrlEvent event(wxEVT_HEADER_BEGIN_REORDER, GetId()); - event.SetEventObject(this); - event.SetColumn(col); - - if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) - { - // don't start dragging it, nothing to do otherwise - return; - } - - m_dragOffset = xPhysical - GetColStart(col); - - m_colBeingReordered = col; - SetCursor(wxCursor(wxCURSOR_HAND)); - CaptureMouse(); - - // do not call UpdateReorderingMarker() here: we don't want to give - // feedback for reordering until the user starts to really move the mouse - // as he might want to just click on the column and not move it at all -} - -bool wxHeaderCtrl::EndReordering(int xPhysical) -{ - wxASSERT_MSG( IsReordering(), "shouldn't be called if we're not reordering" ); - - EndDragging(); - - ReleaseMouse(); - - const int colOld = m_colBeingReordered, - colNew = FindColumnAtPoint(xPhysical); - - m_colBeingReordered = COL_NONE; - - if ( xPhysical - GetColStart(colOld) == m_dragOffset ) - return false; - - if ( colNew != colOld ) - { - wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId()); - event.SetEventObject(this); - event.SetColumn(colOld); - - const unsigned pos = GetColumnPos(FindColumnAtPoint(xPhysical)); - event.SetNewOrder(pos); - - if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) - { - // do reorder the columns - DoMoveCol(colOld, pos); - } - } - - // whether we moved the column or not, the user did move the mouse and so - // did try to do it so return true - return true; -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl column reordering -// ---------------------------------------------------------------------------- - -void wxHeaderCtrl::DoSetColumnsOrder(const wxArrayInt& order) -{ - m_colIndices = order; - Refresh(); -} - -wxArrayInt wxHeaderCtrl::DoGetColumnsOrder() const -{ - return m_colIndices; -} - -void wxHeaderCtrl::DoMoveCol(unsigned int idx, unsigned int pos) -{ - MoveColumnInOrderArray(m_colIndices, idx, pos); - - Refresh(); -} - -// ---------------------------------------------------------------------------- -// wxHeaderCtrl event handlers -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxHeaderCtrl, wxHeaderCtrlBase) - EVT_PAINT(wxHeaderCtrl::OnPaint) - - EVT_MOUSE_EVENTS(wxHeaderCtrl::OnMouse) - - EVT_MOUSE_CAPTURE_LOST(wxHeaderCtrl::OnCaptureLost) - - EVT_KEY_DOWN(wxHeaderCtrl::OnKeyDown) -END_EVENT_TABLE() - -void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - int w, h; - GetClientSize(&w, &h); - -#ifdef __WXGTK__ -// int vw; -// GetVirtualSize(&vw, NULL); -#endif - - wxAutoBufferedPaintDC dc(this); - - dc.SetBackground(GetBackgroundColour()); - dc.Clear(); - - // account for the horizontal scrollbar offset in the parent window - dc.SetDeviceOrigin(m_scrollOffset, 0); - - const unsigned int count = m_numColumns; - int xpos = 0; - for ( unsigned int i = 0; i < count; i++ ) - { - const unsigned idx = m_colIndices[i]; - const wxHeaderColumn& col = GetColumn(idx); - if ( col.IsHidden() ) - continue; - - int colWidth = col.GetWidth(); - - wxHeaderSortIconType sortArrow; - if ( col.IsSortKey() ) - { - sortArrow = col.IsSortOrderAscending() ? wxHDR_SORT_ICON_UP - : wxHDR_SORT_ICON_DOWN; - } - else // not sorting by this column - { - sortArrow = wxHDR_SORT_ICON_NONE; - } - - int state = 0; - if ( IsEnabled() ) - { - if ( idx == m_hover ) - state = wxCONTROL_CURRENT; - } - else // disabled - { - state = wxCONTROL_DISABLED; - } - - if (i == 0) - state |= wxCONTROL_SPECIAL; - - wxHeaderButtonParams params; - params.m_labelText = col.GetTitle(); - params.m_labelBitmap = col.GetBitmap(); - params.m_labelAlignment = col.GetAlignment(); - -#ifdef __WXGTK__ - if (i == count-1) - { -// colWidth = wxMax( colWidth, vw - xpos ); - state |= wxCONTROL_DIRTY; - } -#endif - - wxRendererNative::Get().DrawHeaderButton - ( - this, - dc, - wxRect(xpos, 0, colWidth, h), - state, - sortArrow, - ¶ms - ); - - xpos += colWidth; - } -} - -void wxHeaderCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) -{ - if ( IsDragging() ) - CancelDragging(); -} - -void wxHeaderCtrl::OnKeyDown(wxKeyEvent& event) -{ - if ( event.GetKeyCode() == WXK_ESCAPE ) - { - if ( IsDragging() ) - { - ReleaseMouse(); - CancelDragging(); - - return; - } - } - - event.Skip(); -} - -void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent) -{ - // do this in advance to allow simply returning if we're not interested, - // we'll undo it if we do handle the event below - mevent.Skip(); - - - // account for the control displacement - const int xPhysical = mevent.GetX(); - const int xLogical = xPhysical - m_scrollOffset; - - // first deal with the [continuation of any] dragging operations in - // progress - if ( IsResizing() ) - { - if ( mevent.LeftUp() ) - EndResizing(xPhysical); - else // update the live separator position - StartOrContinueResizing(m_colBeingResized, xPhysical); - - return; - } - - if ( IsReordering() ) - { - if ( !mevent.LeftUp() ) - { - // update the column position - UpdateReorderingMarker(xPhysical); - - return; - } - - // finish reordering and continue to generate a click event below if we - // didn't really reorder anything - if ( EndReordering(xPhysical) ) - return; - } - - - // find if the event is over a column at all - bool onSeparator; - const unsigned col = mevent.Leaving() - ? (onSeparator = false, COL_NONE) - : FindColumnAtPoint(xLogical, &onSeparator); - - - // update the highlighted column if it changed - if ( col != m_hover ) - { - const unsigned hoverOld = m_hover; - m_hover = col; - - RefreshColIfNotNone(hoverOld); - RefreshColIfNotNone(m_hover); - } - - // update mouse cursor as it moves around - if ( mevent.Moving() ) - { - SetCursor(onSeparator ? wxCursor(wxCURSOR_SIZEWE) : wxNullCursor); - return; - } - - // all the other events only make sense when they happen over a column - if ( col == COL_NONE ) - return; - - - // enter various dragging modes on left mouse press - if ( mevent.LeftDown() ) - { - if ( onSeparator ) - { - // start resizing the column - wxASSERT_MSG( !IsResizing(), "reentering column resize mode?" ); - StartOrContinueResizing(col, xPhysical); - } - else // on column itself - { - // start dragging the column - wxASSERT_MSG( !IsReordering(), "reentering column move mode?" ); - - StartReordering(col, xPhysical); - } - - return; - } - - // determine the type of header event corresponding to click events - wxEventType evtType = wxEVT_NULL; - const bool click = mevent.ButtonUp(), - dblclk = mevent.ButtonDClick(); - if ( click || dblclk ) - { - switch ( mevent.GetButton() ) - { - case wxMOUSE_BTN_LEFT: - // treat left double clicks on separator specially - if ( onSeparator && dblclk ) - { - evtType = wxEVT_HEADER_SEPARATOR_DCLICK; - } - else // not double click on separator - { - evtType = click ? wxEVT_HEADER_CLICK - : wxEVT_HEADER_DCLICK; - } - break; - - case wxMOUSE_BTN_RIGHT: - evtType = click ? wxEVT_HEADER_RIGHT_CLICK - : wxEVT_HEADER_RIGHT_DCLICK; - break; - - case wxMOUSE_BTN_MIDDLE: - evtType = click ? wxEVT_HEADER_MIDDLE_CLICK - : wxEVT_HEADER_MIDDLE_DCLICK; - break; - - default: - // ignore clicks from other mouse buttons - ; - } - } - - if ( evtType == wxEVT_NULL ) - return; - - wxHeaderCtrlEvent event(evtType, GetId()); - event.SetEventObject(this); - event.SetColumn(col); - - if ( GetEventHandler()->ProcessEvent(event) ) - mevent.Skip(false); -} - -#endif // wxHAS_GENERIC_HEADERCTRL - -#endif // wxUSE_HEADERCTRL diff --git a/Source/3rd Party/wx/src/generic/helpext.cpp b/Source/3rd Party/wx/src/generic/helpext.cpp deleted file mode 100644 index af4644ad8..000000000 --- a/Source/3rd Party/wx/src/generic/helpext.cpp +++ /dev/null @@ -1,487 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/helpext.cpp -// Purpose: an external help controller for wxWidgets -// Author: Karsten Ballueder -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Karsten Ballueder -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_HELP && !defined(__WXWINCE__) - -#ifndef WX_PRECOMP - #include "wx/list.h" - #include "wx/string.h" - #include "wx/utils.h" - #include "wx/intl.h" - #include "wx/msgdlg.h" - #include "wx/choicdlg.h" - #include "wx/log.h" -#endif - -#include "wx/filename.h" -#include "wx/textfile.h" -#include "wx/generic/helpext.h" - -#include -#include -#include - -#if !defined(__WINDOWS__) && !defined(__OS2__) - #include -#endif - -#ifdef __WINDOWS__ -#include "wx/msw/mslu.h" -#endif - -#ifdef __WXMSW__ -#include -#include "wx/msw/winundef.h" -#endif - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// Name for map file. -#define WXEXTHELP_MAPFILE wxT("wxhelp.map") - -// Character introducing comments/documentation field in map file. -#define WXEXTHELP_COMMENTCHAR ';' - -// The ID of the Contents section -#define WXEXTHELP_CONTENTS_ID 0 - -// Name of environment variable to set help browser. -#define WXEXTHELP_ENVVAR_BROWSER wxT("WX_HELPBROWSER") - -// Is browser a netscape browser? -#define WXEXTHELP_ENVVAR_BROWSERISNETSCAPE wxT("WX_HELPBROWSER_NS") - -IMPLEMENT_CLASS(wxExtHelpController, wxHelpControllerBase) - -wxExtHelpController::wxExtHelpController(wxWindow* parentWindow) - : wxHelpControllerBase(parentWindow) -{ - m_MapList = NULL; - m_NumOfEntries = 0; - m_BrowserIsNetscape = false; - - wxChar *browser = wxGetenv(WXEXTHELP_ENVVAR_BROWSER); - if (browser) - { - m_BrowserName = browser; - browser = wxGetenv(WXEXTHELP_ENVVAR_BROWSERISNETSCAPE); - m_BrowserIsNetscape = browser && (wxAtoi(browser) != 0); - } -} - -wxExtHelpController::~wxExtHelpController() -{ - DeleteList(); -} - -#if WXWIN_COMPATIBILITY_2_8 -void wxExtHelpController::SetBrowser(const wxString& browsername, bool isNetscape) -{ - m_BrowserName = browsername; - m_BrowserIsNetscape = isNetscape; -} -#endif - -void wxExtHelpController::SetViewer(const wxString& viewer, long flags) -{ - m_BrowserName = viewer; - m_BrowserIsNetscape = (flags & wxHELP_NETSCAPE) != 0; -} - -bool wxExtHelpController::DisplayHelp(const wxString &relativeURL) -{ - // construct hte URL to open -- it's just a file - wxString url(wxT("file://") + m_helpDir); - url << wxFILE_SEP_PATH << relativeURL; - - // use the explicit browser program if specified - if ( !m_BrowserName.empty() ) - { - if ( m_BrowserIsNetscape ) - { - wxString command; - command << m_BrowserName - << wxT(" -remote openURL(") << url << wxT(')'); - if ( wxExecute(command, wxEXEC_SYNC) != -1 ) - return true; - } - - if ( wxExecute(m_BrowserName + wxT(' ') + url, wxEXEC_SYNC) != -1 ) - return true; - } - //else: either no browser explicitly specified or we failed to open it - - // just use default browser - return wxLaunchDefaultBrowser(url); -} - -class wxExtHelpMapEntry : public wxObject -{ -public: - int entryid; - wxString url; - wxString doc; - - wxExtHelpMapEntry(int iid, wxString const &iurl, wxString const &idoc) - { entryid = iid; url = iurl; doc = idoc; } -}; - -void wxExtHelpController::DeleteList() -{ - if (m_MapList) - { - wxList::compatibility_iterator node = m_MapList->GetFirst(); - while (node) - { - delete (wxExtHelpMapEntry *)node->GetData(); - m_MapList->Erase(node); - node = m_MapList->GetFirst(); - } - - wxDELETE(m_MapList); - } -} - -// This must be called to tell the controller where to find the documentation. -// @param file - NOT a filename, but a directory name. -// @return true on success -bool wxExtHelpController::Initialize(const wxString& file) -{ - return LoadFile(file); -} - -bool wxExtHelpController::ParseMapFileLine(const wxString& line) -{ - const wxChar *p = line.c_str(); - - // skip whitespace - while ( isascii(*p) && wxIsspace(*p) ) - p++; - - // skip empty lines and comments - if ( *p == wxT('\0') || *p == WXEXTHELP_COMMENTCHAR ) - return true; - - // the line is of the form "num url" so we must have an integer now - wxChar *end; - const unsigned long id = wxStrtoul(p, &end, 0); - - if ( end == p ) - return false; - - p = end; - while ( isascii(*p) && wxIsspace(*p) ) - p++; - - // next should be the URL - wxString url; - url.reserve(line.length()); - while ( isascii(*p) && !wxIsspace(*p) ) - url += *p++; - - while ( isascii(*p) && wxIsspace(*p) ) - p++; - - // and finally the optional description of the entry after comment - wxString doc; - if ( *p == WXEXTHELP_COMMENTCHAR ) - { - p++; - while ( isascii(*p) && wxIsspace(*p) ) - p++; - doc = p; - } - - m_MapList->Append(new wxExtHelpMapEntry(id, url, doc)); - m_NumOfEntries++; - - return true; -} - -// file is a misnomer as it's the name of the base help directory -bool wxExtHelpController::LoadFile(const wxString& file) -{ - wxFileName helpDir(wxFileName::DirName(file)); - helpDir.MakeAbsolute(); - - bool dirExists = false; - -#if wxUSE_INTL - // If a locale is set, look in file/localename, i.e. If passed - // "/usr/local/myapp/help" and the current wxLocale is set to be "de", then - // look in "/usr/local/myapp/help/de/" first and fall back to - // "/usr/local/myapp/help" if that doesn't exist. - const wxLocale * const loc = wxGetLocale(); - if ( loc ) - { - wxString locName = loc->GetName(); - - // the locale is in general of the form xx_YY.zzzz, try the full firm - // first and then also more general ones - wxFileName helpDirLoc(helpDir); - helpDirLoc.AppendDir(locName); - dirExists = helpDirLoc.DirExists(); - - if ( ! dirExists ) - { - // try without encoding - const wxString locNameWithoutEncoding = locName.BeforeLast(wxT('.')); - if ( !locNameWithoutEncoding.empty() ) - { - helpDirLoc = helpDir; - helpDirLoc.AppendDir(locNameWithoutEncoding); - dirExists = helpDirLoc.DirExists(); - } - } - - if ( !dirExists ) - { - // try without country part - wxString locNameWithoutCountry = locName.BeforeLast(wxT('_')); - if ( !locNameWithoutCountry.empty() ) - { - helpDirLoc = helpDir; - helpDirLoc.AppendDir(locNameWithoutCountry); - dirExists = helpDirLoc.DirExists(); - } - } - - if ( dirExists ) - helpDir = helpDirLoc; - } -#endif // wxUSE_INTL - - if ( ! dirExists && !helpDir.DirExists() ) - { - wxLogError(_("Help directory \"%s\" not found."), - helpDir.GetFullPath().c_str()); - return false; - } - - const wxFileName mapFile(helpDir.GetFullPath(), WXEXTHELP_MAPFILE); - if ( ! mapFile.FileExists() ) - { - wxLogError(_("Help file \"%s\" not found."), - mapFile.GetFullPath().c_str()); - return false; - } - - DeleteList(); - m_MapList = new wxList; - m_NumOfEntries = 0; - - wxTextFile input; - if ( !input.Open(mapFile.GetFullPath()) ) - return false; - - for ( wxString& line = input.GetFirstLine(); - !input.Eof(); - line = input.GetNextLine() ) - { - if ( !ParseMapFileLine(line) ) - { - wxLogWarning(_("Line %lu of map file \"%s\" has invalid syntax, skipped."), - (unsigned long)input.GetCurrentLine(), - mapFile.GetFullPath().c_str()); - } - } - - if ( !m_NumOfEntries ) - { - wxLogError(_("No valid mappings found in the file \"%s\"."), - mapFile.GetFullPath().c_str()); - return false; - } - - m_helpDir = helpDir.GetFullPath(); // now it's valid - return true; -} - - -bool wxExtHelpController::DisplayContents() -{ - if (! m_NumOfEntries) - return false; - - wxString contents; - wxList::compatibility_iterator node = m_MapList->GetFirst(); - wxExtHelpMapEntry *entry; - while (node) - { - entry = (wxExtHelpMapEntry *)node->GetData(); - if (entry->entryid == WXEXTHELP_CONTENTS_ID) - { - contents = entry->url; - break; - } - - node = node->GetNext(); - } - - bool rc = false; - wxString file; - file << m_helpDir << wxFILE_SEP_PATH << contents; - if (file.Contains(wxT('#'))) - file = file.BeforeLast(wxT('#')); - if ( wxFileExists(file) ) - rc = DisplaySection(WXEXTHELP_CONTENTS_ID); - - // if not found, open homemade toc: - return rc ? true : KeywordSearch(wxEmptyString); -} - -bool wxExtHelpController::DisplaySection(int sectionNo) -{ - if (! m_NumOfEntries) - return false; - - wxBusyCursor b; // display a busy cursor - wxList::compatibility_iterator node = m_MapList->GetFirst(); - wxExtHelpMapEntry *entry; - while (node) - { - entry = (wxExtHelpMapEntry *)node->GetData(); - if (entry->entryid == sectionNo) - return DisplayHelp(entry->url); - node = node->GetNext(); - } - - return false; -} - -bool wxExtHelpController::DisplaySection(const wxString& section) -{ - bool isFilename = (section.Find(wxT(".htm")) != -1); - - if (isFilename) - return DisplayHelp(section); - else - return KeywordSearch(section); -} - -bool wxExtHelpController::DisplayBlock(long blockNo) -{ - return DisplaySection((int)blockNo); -} - -bool wxExtHelpController::KeywordSearch(const wxString& k, - wxHelpSearchMode WXUNUSED(mode)) -{ - if (! m_NumOfEntries) - return false; - - wxString *choices = new wxString[m_NumOfEntries]; - wxString *urls = new wxString[m_NumOfEntries]; - - int idx = 0; - bool rc = false; - bool showAll = k.empty(); - - wxList::compatibility_iterator node = m_MapList->GetFirst(); - - { - // display a busy cursor - wxBusyCursor b; - wxString compA, compB; - wxExtHelpMapEntry *entry; - - // we compare case insensitive - if (! showAll) - { - compA = k; - compA.LowerCase(); - } - - while (node) - { - entry = (wxExtHelpMapEntry *)node->GetData(); - compB = entry->doc; - - bool testTarget = ! compB.empty(); - if (testTarget && ! showAll) - { - compB.LowerCase(); - testTarget = compB.Contains(compA); - } - - if (testTarget) - { - urls[idx] = entry->url; - // doesn't work: - // choices[idx] = (**i).doc.Contains((**i).doc.Before(WXEXTHELP_COMMENTCHAR)); - //if (choices[idx].empty()) // didn't contain the ';' - // choices[idx] = (**i).doc; - choices[idx] = wxEmptyString; - for (int j=0; ; j++) - { - wxChar targetChar = entry->doc.c_str()[j]; - if ((targetChar == 0) || (targetChar == WXEXTHELP_COMMENTCHAR)) - break; - - choices[idx] << targetChar; - } - - idx++; - } - - node = node->GetNext(); - } - } - - switch (idx) - { - case 0: - wxMessageBox(_("No entries found.")); - break; - - case 1: - rc = DisplayHelp(urls[0]); - break; - - default: - if (showAll) - idx = wxGetSingleChoiceIndex(_("Help Index"), - _("Help Index"), - idx, choices); - else - idx = wxGetSingleChoiceIndex(_("Relevant entries:"), - _("Entries found"), - idx, choices); - - if (idx >= 0) - rc = DisplayHelp(urls[idx]); - break; - } - - delete [] urls; - delete [] choices; - - return rc; -} - - -bool wxExtHelpController::Quit() -{ - return true; -} - -void wxExtHelpController::OnQuit() -{ -} - -#endif // wxUSE_HELP diff --git a/Source/3rd Party/wx/src/generic/htmllbox.cpp b/Source/3rd Party/wx/src/generic/htmllbox.cpp deleted file mode 100644 index 1018e1bad..000000000 --- a/Source/3rd Party/wx/src/generic/htmllbox.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/htmllbox.cpp -// Purpose: implementation of wxHtmlListBox -// Author: Vadim Zeitlin -// Modified by: -// Created: 31.05.03 -// Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/dcclient.h" -#endif //WX_PRECOMP - -#if wxUSE_HTML - -#include "wx/htmllbox.h" - -#include "wx/html/htmlcell.h" -#include "wx/html/winpars.h" - -// this hack forces the linker to always link in m_* files -#include "wx/html/forcelnk.h" -FORCE_WXHTML_MODULES() - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// small border always added to the cells: -static const wxCoord CELL_BORDER = 2; - -const char wxHtmlListBoxNameStr[] = "htmlListBox"; -const char wxSimpleHtmlListBoxNameStr[] = "simpleHtmlListBox"; - -// ============================================================================ -// private classes -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxHtmlListBoxCache -// ---------------------------------------------------------------------------- - -// this class is used by wxHtmlListBox to cache the parsed representation of -// the items to avoid doing it anew each time an item must be drawn -class wxHtmlListBoxCache -{ -private: - // invalidate a single item, used by Clear() and InvalidateRange() - void InvalidateItem(size_t n) - { - m_items[n] = (size_t)-1; - wxDELETE(m_cells[n]); - } - -public: - wxHtmlListBoxCache() - { - for ( size_t n = 0; n < SIZE; n++ ) - { - m_items[n] = (size_t)-1; - m_cells[n] = NULL; - } - - m_next = 0; - } - - ~wxHtmlListBoxCache() - { - for ( size_t n = 0; n < SIZE; n++ ) - { - delete m_cells[n]; - } - } - - // completely invalidate the cache - void Clear() - { - for ( size_t n = 0; n < SIZE; n++ ) - { - InvalidateItem(n); - } - } - - // return the cached cell for this index or NULL if none - wxHtmlCell *Get(size_t item) const - { - for ( size_t n = 0; n < SIZE; n++ ) - { - if ( m_items[n] == item ) - return m_cells[n]; - } - - return NULL; - } - - // returns true if we already have this item cached - bool Has(size_t item) const { return Get(item) != NULL; } - - // ensure that the item is cached - void Store(size_t item, wxHtmlCell *cell) - { - delete m_cells[m_next]; - m_cells[m_next] = cell; - m_items[m_next] = item; - - // advance to the next item wrapping around if there are no more - if ( ++m_next == SIZE ) - m_next = 0; - } - - // forget the cached value of the item(s) between the given ones (inclusive) - void InvalidateRange(size_t from, size_t to) - { - for ( size_t n = 0; n < SIZE; n++ ) - { - if ( m_items[n] >= from && m_items[n] <= to ) - { - InvalidateItem(n); - } - } - } - -private: - // the max number of the items we cache - enum { SIZE = 50 }; - - // the index of the LRU (oldest) cell - size_t m_next; - - // the parsed representation of the cached item or NULL - wxHtmlCell *m_cells[SIZE]; - - // the index of the currently cached item (only valid if m_cells != NULL) - size_t m_items[SIZE]; -}; - -// ---------------------------------------------------------------------------- -// wxHtmlListBoxStyle -// ---------------------------------------------------------------------------- - -// just forward wxDefaultHtmlRenderingStyle callbacks to the main class so that -// they could be overridden by the user code -class wxHtmlListBoxStyle : public wxDefaultHtmlRenderingStyle -{ -public: - wxHtmlListBoxStyle(const wxHtmlListBox& hlbox) : m_hlbox(hlbox) { } - - virtual wxColour GetSelectedTextColour(const wxColour& colFg) - { - // by default wxHtmlListBox doesn't implement GetSelectedTextColour() - // and returns wxNullColour from it, so use the default HTML colour for - // selection - wxColour col = m_hlbox.GetSelectedTextColour(colFg); - if ( !col.IsOk() ) - { - col = wxDefaultHtmlRenderingStyle::GetSelectedTextColour(colFg); - } - - return col; - } - - virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) - { - wxColour col = m_hlbox.GetSelectedTextBgColour(colBg); - if ( !col.IsOk() ) - { - col = wxDefaultHtmlRenderingStyle::GetSelectedTextBgColour(colBg); - } - - return col; - } - -private: - const wxHtmlListBox& m_hlbox; - - wxDECLARE_NO_COPY_CLASS(wxHtmlListBoxStyle); -}; - -// ---------------------------------------------------------------------------- -// event tables -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxHtmlListBox, wxVListBox) - EVT_SIZE(wxHtmlListBox::OnSize) - EVT_MOTION(wxHtmlListBox::OnMouseMove) - EVT_LEFT_DOWN(wxHtmlListBox::OnLeftDown) -END_EVENT_TABLE() - -// ============================================================================ -// implementation -// ============================================================================ - -IMPLEMENT_ABSTRACT_CLASS(wxHtmlListBox, wxVListBox) - - -// ---------------------------------------------------------------------------- -// wxHtmlListBox creation -// ---------------------------------------------------------------------------- - -wxHtmlListBox::wxHtmlListBox() - : wxHtmlWindowMouseHelper(this) -{ - Init(); -} - -// normal constructor which calls Create() internally -wxHtmlListBox::wxHtmlListBox(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) - : wxHtmlWindowMouseHelper(this) -{ - Init(); - - (void)Create(parent, id, pos, size, style, name); -} - -void wxHtmlListBox::Init() -{ - m_htmlParser = NULL; - m_htmlRendStyle = new wxHtmlListBoxStyle(*this); - m_cache = new wxHtmlListBoxCache; -} - -bool wxHtmlListBox::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - return wxVListBox::Create(parent, id, pos, size, style, name); -} - -wxHtmlListBox::~wxHtmlListBox() -{ - delete m_cache; - - if ( m_htmlParser ) - { - delete m_htmlParser->GetDC(); - delete m_htmlParser; - } - - delete m_htmlRendStyle; -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox appearance -// ---------------------------------------------------------------------------- - -wxColour -wxHtmlListBox::GetSelectedTextColour(const wxColour& WXUNUSED(colFg)) const -{ - return wxNullColour; -} - -wxColour -wxHtmlListBox::GetSelectedTextBgColour(const wxColour& WXUNUSED(colBg)) const -{ - return GetSelectionBackground(); -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox items markup -// ---------------------------------------------------------------------------- - -wxString wxHtmlListBox::OnGetItemMarkup(size_t n) const -{ - // we don't even need to wrap the value returned by OnGetItem() inside - // "" and "" because wxHTML can parse it even - // without these tags - return OnGetItem(n); -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox cache handling -// ---------------------------------------------------------------------------- - -void wxHtmlListBox::CacheItem(size_t n) const -{ - if ( !m_cache->Has(n) ) - { - if ( !m_htmlParser ) - { - wxHtmlListBox *self = wxConstCast(this, wxHtmlListBox); - - self->m_htmlParser = new wxHtmlWinParser(self); - m_htmlParser->SetDC(new wxClientDC(self)); - m_htmlParser->SetFS(&self->m_filesystem); -#if !wxUSE_UNICODE - if (GetFont().IsOk()) - m_htmlParser->SetInputEncoding(GetFont().GetEncoding()); -#endif - // use system's default GUI font by default: - m_htmlParser->SetStandardFonts(); - } - - wxHtmlContainerCell *cell = (wxHtmlContainerCell *)m_htmlParser-> - Parse(OnGetItemMarkup(n)); - wxCHECK_RET( cell, wxT("wxHtmlParser::Parse() returned NULL?") ); - - // set the cell's ID to item's index so that CellCoordsToPhysical() - // can quickly find the item: - cell->SetId(wxString::Format(wxT("%lu"), (unsigned long)n)); - - cell->Layout(GetClientSize().x - 2*GetMargins().x); - - m_cache->Store(n, cell); - } -} - -void wxHtmlListBox::OnSize(wxSizeEvent& event) -{ - // we need to relayout all the cached cells - m_cache->Clear(); - - event.Skip(); -} - -void wxHtmlListBox::RefreshRow(size_t line) -{ - m_cache->InvalidateRange(line, line); - - wxVListBox::RefreshRow(line); -} - -void wxHtmlListBox::RefreshRows(size_t from, size_t to) -{ - m_cache->InvalidateRange(from, to); - - wxVListBox::RefreshRows(from, to); -} - -void wxHtmlListBox::RefreshAll() -{ - m_cache->Clear(); - - wxVListBox::RefreshAll(); -} - -void wxHtmlListBox::SetItemCount(size_t count) -{ - // the items are going to change, forget the old ones - m_cache->Clear(); - - wxVListBox::SetItemCount(count); -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox implementation of wxVListBox pure virtuals -// ---------------------------------------------------------------------------- - -void -wxHtmlListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const -{ - if ( IsSelected(n) ) - { - if ( DoDrawSolidBackground - ( - GetSelectedTextBgColour(GetBackgroundColour()), - dc, - rect, - n - ) ) - { - return; - } - //else: no custom selection background colour, use base class version - } - - wxVListBox::OnDrawBackground(dc, rect, n); -} - -void wxHtmlListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const -{ - CacheItem(n); - - wxHtmlCell *cell = m_cache->Get(n); - wxCHECK_RET( cell, wxT("this cell should be cached!") ); - - wxHtmlRenderingInfo htmlRendInfo; - - // draw the selected cell in selected state ourselves if we're using custom - // colours (to test for this, check the callbacks by passing them any dummy - // (but valid, to avoid asserts) colour): - if ( IsSelected(n) && - (GetSelectedTextColour(*wxBLACK).IsOk() || - GetSelectedTextBgColour(*wxWHITE).IsOk()) ) - { - wxHtmlSelection htmlSel; - htmlSel.Set(wxPoint(0,0), cell, wxPoint(INT_MAX, INT_MAX), cell); - htmlRendInfo.SetSelection(&htmlSel); - htmlRendInfo.SetStyle(m_htmlRendStyle); - htmlRendInfo.GetState().SetSelectionState(wxHTML_SEL_IN); - } - //else: normal item or selected item with default colours, its background - // was already taken care of in the base class - - // note that we can't stop drawing exactly at the window boundary as then - // even the visible cells part could be not drawn, so always draw the - // entire cell - cell->Draw(dc, - rect.x + CELL_BORDER, rect.y + CELL_BORDER, - 0, INT_MAX, htmlRendInfo); -} - -wxCoord wxHtmlListBox::OnMeasureItem(size_t n) const -{ - CacheItem(n); - - wxHtmlCell *cell = m_cache->Get(n); - wxCHECK_MSG( cell, 0, wxT("this cell should be cached!") ); - - return cell->GetHeight() + cell->GetDescent() + 4; -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox implementation of wxHtmlListBoxWinInterface -// ---------------------------------------------------------------------------- - -void wxHtmlListBox::SetHTMLWindowTitle(const wxString& WXUNUSED(title)) -{ - // nothing to do -} - -void wxHtmlListBox::OnHTMLLinkClicked(const wxHtmlLinkInfo& link) -{ - OnLinkClicked(GetItemForCell(link.GetHtmlCell()), link); -} - -void wxHtmlListBox::OnLinkClicked(size_t WXUNUSED(n), - const wxHtmlLinkInfo& link) -{ - wxHtmlLinkEvent event(GetId(), link); - GetEventHandler()->ProcessEvent(event); -} - -wxHtmlOpeningStatus -wxHtmlListBox::OnHTMLOpeningURL(wxHtmlURLType WXUNUSED(type), - const wxString& WXUNUSED(url), - wxString *WXUNUSED(redirect)) const -{ - return wxHTML_OPEN; -} - -wxPoint wxHtmlListBox::HTMLCoordsToWindow(wxHtmlCell *cell, - const wxPoint& pos) const -{ - return CellCoordsToPhysical(pos, cell); -} - -wxWindow* wxHtmlListBox::GetHTMLWindow() { return this; } - -wxColour wxHtmlListBox::GetHTMLBackgroundColour() const -{ - return GetBackgroundColour(); -} - -void wxHtmlListBox::SetHTMLBackgroundColour(const wxColour& WXUNUSED(clr)) -{ - // nothing to do -} - -void wxHtmlListBox::SetHTMLBackgroundImage(const wxBitmap& WXUNUSED(bmpBg)) -{ - // nothing to do -} - -void wxHtmlListBox::SetHTMLStatusText(const wxString& WXUNUSED(text)) -{ - // nothing to do -} - -wxCursor wxHtmlListBox::GetHTMLCursor(HTMLCursor type) const -{ - // we don't want to show text selection cursor in listboxes - if (type == HTMLCursor_Text) - return wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor_Default); - - // in all other cases, use the same cursor as wxHtmlWindow: - return wxHtmlWindow::GetDefaultHTMLCursor(type); -} - -// ---------------------------------------------------------------------------- -// wxHtmlListBox handling of HTML links -// ---------------------------------------------------------------------------- - -wxPoint wxHtmlListBox::GetRootCellCoords(size_t n) const -{ - wxPoint pos(CELL_BORDER, CELL_BORDER); - pos += GetMargins(); - pos.y += GetRowsHeight(GetVisibleBegin(), n); - return pos; -} - -bool wxHtmlListBox::PhysicalCoordsToCell(wxPoint& pos, wxHtmlCell*& cell) const -{ - int n = VirtualHitTest(pos.y); - if ( n == wxNOT_FOUND ) - return false; - - // convert mouse coordinates to coords relative to item's wxHtmlCell: - pos -= GetRootCellCoords(n); - - CacheItem(n); - cell = m_cache->Get(n); - - return true; -} - -size_t wxHtmlListBox::GetItemForCell(const wxHtmlCell *cell) const -{ - wxCHECK_MSG( cell, 0, wxT("no cell") ); - - cell = cell->GetRootCell(); - - wxCHECK_MSG( cell, 0, wxT("no root cell") ); - - // the cell's ID contains item index, see CacheItem(): - unsigned long n; - if ( !cell->GetId().ToULong(&n) ) - { - wxFAIL_MSG( wxT("unexpected root cell's ID") ); - return 0; - } - - return n; -} - -wxPoint -wxHtmlListBox::CellCoordsToPhysical(const wxPoint& pos, wxHtmlCell *cell) const -{ - return pos + GetRootCellCoords(GetItemForCell(cell)); -} - -void wxHtmlListBox::OnInternalIdle() -{ - wxVListBox::OnInternalIdle(); - - if ( wxHtmlWindowMouseHelper::DidMouseMove() ) - { - wxPoint pos = ScreenToClient(wxGetMousePosition()); - wxHtmlCell *cell; - - if ( !PhysicalCoordsToCell(pos, cell) ) - return; - - wxHtmlWindowMouseHelper::HandleIdle(cell, pos); - } -} - -void wxHtmlListBox::OnMouseMove(wxMouseEvent& event) -{ - wxHtmlWindowMouseHelper::HandleMouseMoved(); - event.Skip(); -} - -void wxHtmlListBox::OnLeftDown(wxMouseEvent& event) -{ - wxPoint pos = event.GetPosition(); - wxHtmlCell *cell; - - if ( !PhysicalCoordsToCell(pos, cell) ) - { - event.Skip(); - return; - } - - if ( !wxHtmlWindowMouseHelper::HandleMouseClick(cell, pos, event) ) - { - // no link was clicked, so let the listbox code handle the click (e.g. - // by selecting another item in the list): - event.Skip(); - } -} - - -// ---------------------------------------------------------------------------- -// wxSimpleHtmlListBox -// ---------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxSimpleHtmlListBox, wxHtmlListBox) - - -bool wxSimpleHtmlListBox::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - int n, const wxString choices[], - long style, - const wxValidator& wxVALIDATOR_PARAM(validator), - const wxString& name) -{ - if (!wxHtmlListBox::Create(parent, id, pos, size, style, name)) - return false; - -#if wxUSE_VALIDATORS - SetValidator(validator); -#endif - - Append(n, choices); - - return true; -} - -bool wxSimpleHtmlListBox::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& wxVALIDATOR_PARAM(validator), - const wxString& name) -{ - if (!wxHtmlListBox::Create(parent, id, pos, size, style, name)) - return false; - -#if wxUSE_VALIDATORS - SetValidator(validator); -#endif - - Append(choices); - - return true; -} - -wxSimpleHtmlListBox::~wxSimpleHtmlListBox() -{ - wxItemContainer::Clear(); -} - -void wxSimpleHtmlListBox::DoClear() -{ - wxASSERT(m_items.GetCount() == m_HTMLclientData.GetCount()); - - m_items.Clear(); - m_HTMLclientData.Clear(); - - UpdateCount(); -} - -void wxSimpleHtmlListBox::Clear() -{ - DoClear(); -} - -void wxSimpleHtmlListBox::DoDeleteOneItem(unsigned int n) -{ - m_items.RemoveAt(n); - - m_HTMLclientData.RemoveAt(n); - - UpdateCount(); -} - -int wxSimpleHtmlListBox::DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) -{ - const unsigned int count = items.GetCount(); - - m_items.Insert(wxEmptyString, pos, count); - m_HTMLclientData.Insert(NULL, pos, count); - - for ( unsigned int i = 0; i < count; ++i, ++pos ) - { - m_items[pos] = items[i]; - AssignNewItemClientData(pos, clientData, i, type); - } - - UpdateCount(); - - return pos - 1; -} - -void wxSimpleHtmlListBox::SetString(unsigned int n, const wxString& s) -{ - wxCHECK_RET( IsValid(n), - wxT("invalid index in wxSimpleHtmlListBox::SetString") ); - - m_items[n]=s; - RefreshRow(n); -} - -wxString wxSimpleHtmlListBox::GetString(unsigned int n) const -{ - wxCHECK_MSG( IsValid(n), wxEmptyString, - wxT("invalid index in wxSimpleHtmlListBox::GetString") ); - - return m_items[n]; -} - -void wxSimpleHtmlListBox::UpdateCount() -{ - wxASSERT(m_items.GetCount() == m_HTMLclientData.GetCount()); - wxHtmlListBox::SetItemCount(m_items.GetCount()); - - // very small optimization: if you need to add lot of items to - // a wxSimpleHtmlListBox be sure to use the - // wxSimpleHtmlListBox::Append(const wxArrayString&) method instead! - if (!this->IsFrozen()) - RefreshAll(); -} - -#endif // wxUSE_HTML diff --git a/Source/3rd Party/wx/src/generic/hyperlinkg.cpp b/Source/3rd Party/wx/src/generic/hyperlinkg.cpp deleted file mode 100644 index eb8485955..000000000 --- a/Source/3rd Party/wx/src/generic/hyperlinkg.cpp +++ /dev/null @@ -1,296 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/hyperlinkg.cpp -// Purpose: Hyperlink control -// Author: David Norris , Otto Wyss -// Modified by: Ryan Norton, Francesco Montorsi -// Created: 04/02/2005 -// Copyright: (c) 2005 David Norris -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -//--------------------------------------------------------------------------- -// Pre-compiled header stuff -//--------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_HYPERLINKCTRL - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- - -#include "wx/hyperlink.h" - -#ifndef WX_PRECOMP - #include "wx/utils.h" // for wxLaunchDefaultBrowser - #include "wx/dcclient.h" - #include "wx/menu.h" - #include "wx/log.h" - #include "wx/dataobj.h" -#endif - -#include "wx/clipbrd.h" -#include "wx/renderer.h" - -// ============================================================================ -// implementation -// ============================================================================ - -// reserved for internal use only -#define wxHYPERLINK_POPUP_COPY_ID 16384 - -// ---------------------------------------------------------------------------- -// wxGenericHyperlinkCtrl -// ---------------------------------------------------------------------------- - -bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, - const wxString& label, const wxString& url, const wxPoint& pos, - const wxSize& size, long style, const wxString& name) -{ - // do validation checks: - CheckParams(label, url, style); - - if ((style & wxHL_ALIGN_LEFT) == 0) - style |= wxFULL_REPAINT_ON_RESIZE; - - if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name)) - return false; - - // set to non empty strings both the url and the label - SetURL(url.empty() ? label : url); - SetLabel(label.empty() ? url : label); - - Init(); - SetForegroundColour(m_normalColour); - - // by default the font of an hyperlink control is underlined - wxFont f = GetFont(); - f.SetUnderlined(true); - SetFont(f); - - SetInitialSize(size); - - - // connect our event handlers: - // NOTE: since this class is the base class of the GTK+'s native implementation - // of wxHyperlinkCtrl, we cannot use the static macros in BEGIN/END_EVENT_TABLE - // blocks, otherwise the GTK+'s native impl of wxHyperlinkCtrl would not - // behave correctly (as we intercept events doing things which interfere - // with GTK+'s native handling): - - Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) ); - Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) ); - Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) ); - Connect( wxEVT_CHAR, wxKeyEventHandler(wxGenericHyperlinkCtrl::OnChar) ); - Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) ); - - Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) ); - Connect( wxEVT_LEFT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftUp) ); - Connect( wxEVT_MOTION, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnMotion) ); - - ConnectMenuHandlers(); - - return true; -} - -void wxGenericHyperlinkCtrl::Init() -{ - m_rollover = false; - m_clicking = false; - m_visited = false; - - // colours - m_normalColour = *wxBLUE; - m_hoverColour = *wxRED; - m_visitedColour = wxColour("#551a8b"); -} - -void wxGenericHyperlinkCtrl::ConnectMenuHandlers() -{ - // Connect the event handlers for the context menu. - Connect( wxEVT_RIGHT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnRightUp) ); - Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_MENU, - wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) ); -} - -wxSize wxGenericHyperlinkCtrl::DoGetBestClientSize() const -{ - wxClientDC dc((wxWindow *)this); - return dc.GetTextExtent(GetLabel()); -} - - -void wxGenericHyperlinkCtrl::SetNormalColour(const wxColour &colour) -{ - m_normalColour = colour; - if (!m_visited) - { - SetForegroundColour(m_normalColour); - Refresh(); - } -} - -void wxGenericHyperlinkCtrl::SetVisitedColour(const wxColour &colour) -{ - m_visitedColour = colour; - if (m_visited) - { - SetForegroundColour(m_visitedColour); - Refresh(); - } -} - -void wxGenericHyperlinkCtrl::DoContextMenu(const wxPoint &pos) -{ - wxMenu *menuPopUp = new wxMenu(wxEmptyString, wxMENU_TEAROFF); - menuPopUp->Append(wxHYPERLINK_POPUP_COPY_ID, _("&Copy URL")); - PopupMenu( menuPopUp, pos ); - delete menuPopUp; -} - -wxRect wxGenericHyperlinkCtrl::GetLabelRect() const -{ - // our best size is always the size of the label without borders - wxSize c(GetClientSize()), b(GetBestSize()); - wxPoint offset; - - // the label is always centered vertically - offset.y = (c.GetHeight()-b.GetHeight())/2; - - if (HasFlag(wxHL_ALIGN_CENTRE)) - offset.x = (c.GetWidth()-b.GetWidth())/2; - else if (HasFlag(wxHL_ALIGN_RIGHT)) - offset.x = c.GetWidth()-b.GetWidth(); - else if (HasFlag(wxHL_ALIGN_LEFT)) - offset.x = 0; - return wxRect(offset, b); -} - - - -// ---------------------------------------------------------------------------- -// wxGenericHyperlinkCtrl - event handlers -// ---------------------------------------------------------------------------- - -void wxGenericHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - dc.SetFont(GetFont()); - dc.SetTextForeground(GetForegroundColour()); - dc.SetTextBackground(GetBackgroundColour()); - - dc.DrawText(GetLabel(), GetLabelRect().GetTopLeft()); - if (HasFocus()) - { - wxRendererNative::Get().DrawFocusRect(this, dc, GetClientRect(), wxCONTROL_SELECTED); - } -} - -void wxGenericHyperlinkCtrl::OnFocus(wxFocusEvent& event) -{ - Refresh(); - event.Skip(); -} - -void wxGenericHyperlinkCtrl::OnChar(wxKeyEvent& event) -{ - switch (event.m_keyCode) - { - default: - event.Skip(); - break; - case WXK_SPACE: - case WXK_NUMPAD_SPACE: - SetForegroundColour(m_visitedColour); - m_visited = true; - SendEvent(); - break; - } -} - -void wxGenericHyperlinkCtrl::OnLeftDown(wxMouseEvent& event) -{ - // the left click must start from the hyperlink rect - m_clicking = GetLabelRect().Contains(event.GetPosition()); -} - -void wxGenericHyperlinkCtrl::OnLeftUp(wxMouseEvent& event) -{ - // the click must be started and ended in the hyperlink rect - if (!m_clicking || !GetLabelRect().Contains(event.GetPosition())) - return; - - SetForegroundColour(m_visitedColour); - m_visited = true; - m_clicking = false; - - // send the event - SendEvent(); -} - -void wxGenericHyperlinkCtrl::OnRightUp(wxMouseEvent& event) -{ - if( GetWindowStyle() & wxHL_CONTEXTMENU ) - if ( GetLabelRect().Contains(event.GetPosition()) ) - DoContextMenu(wxPoint(event.m_x, event.m_y)); -} - -void wxGenericHyperlinkCtrl::OnMotion(wxMouseEvent& event) -{ - wxRect textrc = GetLabelRect(); - - if (textrc.Contains(event.GetPosition())) - { - SetCursor(wxCursor(wxCURSOR_HAND)); - SetForegroundColour(m_hoverColour); - m_rollover = true; - Refresh(); - } - else if (m_rollover) - { - SetCursor(*wxSTANDARD_CURSOR); - SetForegroundColour(!m_visited ? m_normalColour : m_visitedColour); - m_rollover = false; - Refresh(); - } -} - -void wxGenericHyperlinkCtrl::OnLeaveWindow(wxMouseEvent& WXUNUSED(event) ) -{ - // NB: when the label rect and the client size rect have the same - // height this function is indispensable to remove the "rollover" - // effect as the OnMotion() event handler could not be called - // in that case moving the mouse out of the label vertically... - - if (m_rollover) - { - SetCursor(*wxSTANDARD_CURSOR); - SetForegroundColour(!m_visited ? m_normalColour : m_visitedColour); - m_rollover = false; - Refresh(); - } -} - -void wxGenericHyperlinkCtrl::OnPopUpCopy( wxCommandEvent& WXUNUSED(event) ) -{ -#if wxUSE_CLIPBOARD - if (!wxTheClipboard->Open()) - return; - - wxTextDataObject *data = new wxTextDataObject( m_url ); - wxTheClipboard->SetData( data ); - wxTheClipboard->Close(); -#endif // wxUSE_CLIPBOARD -} - -#endif // wxUSE_HYPERLINKCTRL diff --git a/Source/3rd Party/wx/src/generic/icon.cpp b/Source/3rd Party/wx/src/generic/icon.cpp deleted file mode 100644 index ffe0335ad..000000000 --- a/Source/3rd Party/wx/src/generic/icon.cpp +++ /dev/null @@ -1,46 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/icon.cpp -// Purpose: wxIcon implementation for ports where it's same as wxBitmap -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/icon.h" - -//----------------------------------------------------------------------------- -// wxIcon -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) - -wxIcon::wxIcon(const char* const* bits) : - wxBitmap( bits ) -{ -} - -#ifdef wxNEEDS_CHARPP -wxIcon::wxIcon(char **bits) : - wxBitmap( bits ) -{ -} -#endif - -wxIcon::wxIcon() : wxBitmap() -{ -} - -void wxIcon::CopyFromBitmap(const wxBitmap& bmp) -{ - wxIcon *icon = (wxIcon*)(&bmp); - *this = *icon; -} diff --git a/Source/3rd Party/wx/src/generic/imaglist.cpp b/Source/3rd Party/wx/src/generic/imaglist.cpp deleted file mode 100644 index ba98cc400..000000000 --- a/Source/3rd Party/wx/src/generic/imaglist.cpp +++ /dev/null @@ -1,273 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/imaglist.cpp -// Purpose: -// Author: Robert Roebling -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_IMAGLIST && !defined(wxHAS_NATIVE_IMAGELIST) - -#include "wx/imaglist.h" - -#ifndef WX_PRECOMP - #include "wx/dc.h" - #include "wx/icon.h" - #include "wx/image.h" -#endif - -//----------------------------------------------------------------------------- -// wxImageList -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericImageList, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxGenericImageList) - -wxGenericImageList::wxGenericImageList( int width, int height, bool mask, int initialCount ) -{ - (void)Create(width, height, mask, initialCount); -} - -wxGenericImageList::~wxGenericImageList() -{ - (void)RemoveAll(); -} - -int wxGenericImageList::GetImageCount() const -{ - return m_images.GetCount(); -} - -bool wxGenericImageList::Create( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) ) -{ - m_width = width; - m_height = height; - - return Create(); -} - -bool wxGenericImageList::Create() -{ - return true; -} - -int wxGenericImageList::Add( const wxBitmap &bitmap ) -{ - wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height) - || (m_width == 0 && m_height == 0), - wxT("invalid bitmap size in wxImageList: this might work ") - wxT("on this platform but definitely won't under Windows.") ); - - const int index = int(m_images.GetCount()); - - if (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) - { - m_images.Append( new wxIcon( (const wxIcon&) bitmap ) ); - } - else - { - // Mimic behaviour 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 index; -} - -int wxGenericImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) -{ - wxBitmap bmp(bitmap); - if (mask.IsOk()) - bmp.SetMask(new wxMask(mask)); - return Add(bmp); -} - -int wxGenericImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour ) -{ - wxImage img = bitmap.ConvertToImage(); - img.SetMaskColour(maskColour.Red(), maskColour.Green(), maskColour.Blue()); - return Add(wxBitmap(img)); -} - -const wxBitmap *wxGenericImageList::GetBitmapPtr( int index ) const -{ - wxObjectList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, NULL, wxT("wrong index in image list") ); - - return (wxBitmap*)node->GetData(); -} - -// Get the bitmap -wxBitmap wxGenericImageList::GetBitmap(int index) const -{ - const wxBitmap* bmp = GetBitmapPtr(index); - if (bmp) - return *bmp; - else - return wxNullBitmap; -} - -// Get the icon -wxIcon wxGenericImageList::GetIcon(int index) const -{ - const wxBitmap* bmp = GetBitmapPtr(index); - if (bmp) - { - wxIcon icon; - icon.CopyFromBitmap(*bmp); - return icon; - } - else - return wxNullIcon; -} - -bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) -{ - wxObjectList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap* newBitmap = (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) ? - #if defined(__VISAGECPP__) - //just can't do this in VisualAge now, with all this new Bitmap-Icon stuff - //so construct it from a bitmap object until I can figure this nonsense out. (DW) - new wxBitmap(bitmap) - #else - new wxBitmap( (const wxIcon&) bitmap ) - #endif - : new wxBitmap(bitmap) ; - - if (index == (int) m_images.GetCount() - 1) - { - delete node->GetData(); - m_images.Erase( node ); - m_images.Append( newBitmap ); - } - else - { - wxObjectList::compatibility_iterator next = node->GetNext(); - delete node->GetData(); - m_images.Erase( node ); - m_images.Insert( next, newBitmap ); - } - - return true; -} - -bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask ) -{ - wxObjectList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap* newBitmap = (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) ? - #if defined(__VISAGECPP__) - //just can't do this in VisualAge now, with all this new Bitmap-Icon stuff - //so construct it from a bitmap object until I can figure this nonsense out. (DW) - new wxBitmap(bitmap) - #else - new wxBitmap( (const wxIcon&) bitmap ) - #endif - : new wxBitmap(bitmap) ; - - if (index == (int) m_images.GetCount() - 1) - { - delete node->GetData(); - m_images.Erase( node ); - m_images.Append( newBitmap ); - } - else - { - wxObjectList::compatibility_iterator next = node->GetNext(); - delete node->GetData(); - m_images.Erase( node ); - m_images.Insert( next, newBitmap ); - } - - if (mask.IsOk()) - newBitmap->SetMask(new wxMask(mask)); - - return true; -} - -bool wxGenericImageList::Remove( int index ) -{ - wxObjectList::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 wxGenericImageList::RemoveAll() -{ - WX_CLEAR_LIST(wxObjectList, m_images); - m_images.Clear(); - - return true; -} - -bool wxGenericImageList::GetSize( int index, int &width, int &height ) const -{ - width = 0; - height = 0; - - wxObjectList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap *bm = (wxBitmap*)node->GetData(); - width = bm->GetWidth(); - height = bm->GetHeight(); - - return true; -} - -bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, - int flags, bool WXUNUSED(solidBackground) ) -{ - wxObjectList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap *bm = (wxBitmap*)node->GetData(); - - if (bm->IsKindOf(wxCLASSINFO(wxIcon))) - dc.DrawIcon( * ((wxIcon*) bm), x, y); - else - dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); - - return true; -} - -#endif // wxUSE_IMAGLIST diff --git a/Source/3rd Party/wx/src/generic/infobar.cpp b/Source/3rd Party/wx/src/generic/infobar.cpp deleted file mode 100644 index 3ae926223..000000000 --- a/Source/3rd Party/wx/src/generic/infobar.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/infobar.cpp -// Purpose: generic wxInfoBar implementation -// Author: Vadim Zeitlin -// Created: 2009-07-28 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_INFOBAR - -#include "wx/infobar.h" - -#ifndef WX_PRECOMP - #include "wx/bmpbuttn.h" - #include "wx/button.h" - #include "wx/dcmemory.h" - #include "wx/settings.h" - #include "wx/statbmp.h" - #include "wx/stattext.h" - #include "wx/sizer.h" -#endif // WX_PRECOMP - -#include "wx/artprov.h" -#include "wx/scopeguard.h" - -BEGIN_EVENT_TABLE(wxInfoBarGeneric, wxInfoBarBase) - EVT_BUTTON(wxID_ANY, wxInfoBarGeneric::OnButton) -END_EVENT_TABLE() - -// ============================================================================ -// implementation -// ============================================================================ - -void wxInfoBarGeneric::Init() -{ - m_icon = NULL; - m_text = NULL; - m_button = NULL; - - m_showEffect = - m_hideEffect = wxSHOW_EFFECT_MAX; - - // use default effect duration - m_effectDuration = 0; -} - -bool wxInfoBarGeneric::Create(wxWindow *parent, wxWindowID winid) -{ - // calling Hide() before Create() ensures that we're created initially - // hidden - Hide(); - if ( !wxWindow::Create(parent, winid) ) - return false; - - // use special, easy to notice, colours - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK)); - - // create the controls: icon, text and the button to dismiss the - // message. - - // the icon is not shown unless it's assigned a valid bitmap - m_icon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap); - - m_text = new wxStaticText(this, wxID_ANY, ""); - m_text->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT)); - - m_button = wxBitmapButton::NewCloseButton(this, wxID_ANY); - m_button->SetToolTip(_("Hide this notification message.")); - - // center the text inside the sizer with an icon to the left of it and a - // button at the very right - // - // NB: AddButton() relies on the button being the last control in the sizer - // and being preceded by a spacer - wxSizer * const sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(m_icon, wxSizerFlags().Centre().Border()); - sizer->Add(m_text, wxSizerFlags().Centre()); - sizer->AddStretchSpacer(); - sizer->Add(m_button, wxSizerFlags().Centre().Border()); - SetSizer(sizer); - - return true; -} - -bool wxInfoBarGeneric::SetFont(const wxFont& font) -{ - if ( !wxInfoBarBase::SetFont(font) ) - return false; - - // check that we're not called before Create() - if ( m_text ) - m_text->SetFont(font); - - return true; -} - -bool wxInfoBarGeneric::SetForegroundColour(const wxColor& colour) -{ - if ( !wxInfoBarBase::SetForegroundColour(colour) ) - return false; - - if ( m_text ) - m_text->SetForegroundColour(colour); - - return true; -} - -wxInfoBarGeneric::BarPlacement wxInfoBarGeneric::GetBarPlacement() const -{ - wxSizer * const sizer = GetContainingSizer(); - if ( !sizer ) - return BarPlacement_Unknown; - - // FIXME-VC6: can't compare "const wxInfoBarGeneric *" and "wxWindow *", - // so need this workaround - wxWindow * const self = const_cast(this); - const wxSizerItemList& siblings = sizer->GetChildren(); - if ( siblings.GetFirst()->GetData()->GetWindow() == self ) - return BarPlacement_Top; - else if ( siblings.GetLast()->GetData()->GetWindow() == self ) - return BarPlacement_Bottom; - else - return BarPlacement_Unknown; -} - -wxShowEffect wxInfoBarGeneric::GetShowEffect() const -{ - if ( m_showEffect != wxSHOW_EFFECT_MAX ) - return m_showEffect; - - switch ( GetBarPlacement() ) - { - case BarPlacement_Top: - return wxSHOW_EFFECT_SLIDE_TO_BOTTOM; - - case BarPlacement_Bottom: - return wxSHOW_EFFECT_SLIDE_TO_TOP; - - default: - wxFAIL_MSG( "unknown info bar placement" ); - // fall through - - case BarPlacement_Unknown: - return wxSHOW_EFFECT_NONE; - } -} - -wxShowEffect wxInfoBarGeneric::GetHideEffect() const -{ - if ( m_hideEffect != wxSHOW_EFFECT_MAX ) - return m_hideEffect; - - switch ( GetBarPlacement() ) - { - case BarPlacement_Top: - return wxSHOW_EFFECT_SLIDE_TO_TOP; - - case BarPlacement_Bottom: - return wxSHOW_EFFECT_SLIDE_TO_BOTTOM; - - default: - wxFAIL_MSG( "unknown info bar placement" ); - // fall through - - case BarPlacement_Unknown: - return wxSHOW_EFFECT_NONE; - } -} - -void wxInfoBarGeneric::UpdateParent() -{ - wxWindow * const parent = GetParent(); - parent->Layout(); -} - -void wxInfoBarGeneric::DoHide() -{ - HideWithEffect(GetHideEffect(), GetEffectDuration()); - - UpdateParent(); -} - -void wxInfoBarGeneric::DoShow() -{ - // re-layout the parent first so that the window expands into an already - // unoccupied by the other controls area: for this we need to change our - // internal visibility flag to force Layout() to take us into account (an - // alternative solution to this hack would be to temporarily set - // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag but it's not really batter) - - // just change the internal flag indicating that the window is visible, - // without really showing it - wxWindowBase::Show(); - - // adjust the parent layout to account for us - UpdateParent(); - - // reset the flag back before really showing the window or it wouldn't be - // shown at all because it would believe itself already visible - wxWindowBase::Show(false); - - - // finally do really show the window. - ShowWithEffect(GetShowEffect(), GetEffectDuration()); -} - -void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags) -{ - // first update the controls - const int icon = flags & wxICON_MASK; - if ( !icon || (icon == wxICON_NONE) ) - { - m_icon->Hide(); - } - else // do show an icon - { - m_icon->SetBitmap(wxArtProvider::GetBitmap( - wxArtProvider::GetMessageBoxIconId(flags), - wxART_BUTTON)); - m_icon->Show(); - } - - // notice the use of EscapeMnemonics() to ensure that "&" come through - // correctly - m_text->SetLabel(wxControl::EscapeMnemonics(msg)); - - - // then show this entire window if not done yet - if ( !IsShown() ) - { - DoShow(); - } - else // we're already shown - { - // just update the layout to correspond to the new message - Layout(); - } -} - -void wxInfoBarGeneric::Dismiss() -{ - DoHide(); -} - -void wxInfoBarGeneric::AddButton(wxWindowID btnid, const wxString& label) -{ - wxSizer * const sizer = GetSizer(); - wxCHECK_RET( sizer, "must be created first" ); - - // user-added buttons replace the standard close button so remove it if we - // hadn't done it yet - if ( sizer->Detach(m_button) ) - { - m_button->Hide(); - } - - wxButton * const button = new wxButton(this, btnid, label); - -#ifdef __WXMAC__ - // smaller buttons look better in the (narrow) info bar under OS X - button->SetWindowVariant(wxWINDOW_VARIANT_SMALL); -#endif // __WXMAC__ - - sizer->Add(button, wxSizerFlags().Centre().DoubleBorder()); -} - -void wxInfoBarGeneric::RemoveButton(wxWindowID btnid) -{ - wxSizer * const sizer = GetSizer(); - wxCHECK_RET( sizer, "must be created first" ); - - // iterate over the sizer items in reverse order to find the last added - // button with this id (ids of all buttons should be unique anyhow but if - // they are repeated removing the last added one probably makes more sense) - const wxSizerItemList& items = sizer->GetChildren(); - for ( wxSizerItemList::compatibility_iterator node = items.GetLast(); - node != items.GetFirst(); - node = node->GetPrevious() ) - { - const wxSizerItem * const item = node->GetData(); - - // if we reached the spacer separating the buttons from the text - // preceding them without finding our button, it must mean it's not - // there at all - if ( item->IsSpacer() ) - { - wxFAIL_MSG( wxString::Format("button with id %d not found", btnid) ); - return; - } - - // check if we found our button - if ( item->GetWindow()->GetId() == btnid ) - { - delete item->GetWindow(); - break; - } - } - - // check if there are any custom buttons left - if ( sizer->GetChildren().GetLast()->GetData()->IsSpacer() ) - { - // if the last item is the spacer, none are left so restore the - // standard close button - sizer->Add(m_button, wxSizerFlags().Centre().DoubleBorder()); - m_button->Show(); - } -} - -void wxInfoBarGeneric::OnButton(wxCommandEvent& WXUNUSED(event)) -{ - DoHide(); -} - -#endif // wxUSE_INFOBAR diff --git a/Source/3rd Party/wx/src/generic/laywin.cpp b/Source/3rd Party/wx/src/generic/laywin.cpp deleted file mode 100644 index 5cb58f3f6..000000000 --- a/Source/3rd Party/wx/src/generic/laywin.cpp +++ /dev/null @@ -1,346 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/laywin.cpp -// Purpose: Implements a simple layout algorithm, plus -// wxSashLayoutWindow which is an example of a window with -// layout-awareness (via event handlers). This is suited to -// IDE-style window layout. -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/frame.h" -#endif - -#include "wx/laywin.h" -#include "wx/mdi.h" - - -IMPLEMENT_DYNAMIC_CLASS(wxQueryLayoutInfoEvent, wxEvent) -IMPLEMENT_DYNAMIC_CLASS(wxCalculateLayoutEvent, wxEvent) - -wxDEFINE_EVENT( wxEVT_QUERY_LAYOUT_INFO, wxQueryLayoutInfoEvent ); -wxDEFINE_EVENT( wxEVT_CALCULATE_LAYOUT, wxCalculateLayoutEvent ); - - -// ---------------------------------------------------------------------------- -// wxSashLayoutWindow -// ---------------------------------------------------------------------------- - -#if wxUSE_SASH -IMPLEMENT_CLASS(wxSashLayoutWindow, wxSashWindow) -BEGIN_EVENT_TABLE(wxSashLayoutWindow, wxSashWindow) - EVT_CALCULATE_LAYOUT(wxSashLayoutWindow::OnCalculateLayout) - EVT_QUERY_LAYOUT_INFO(wxSashLayoutWindow::OnQueryLayoutInfo) -END_EVENT_TABLE() - -bool wxSashLayoutWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, const wxString& name) -{ - return wxSashWindow::Create(parent, id, pos, size, style, name); -} - -void wxSashLayoutWindow::Init() -{ - m_orientation = wxLAYOUT_HORIZONTAL; - m_alignment = wxLAYOUT_TOP; -#ifdef __WXMAC__ - MacSetClipChildren( true ) ; -#endif -} - -// This is the function that wxLayoutAlgorithm calls to ascertain the window -// dimensions. -void wxSashLayoutWindow::OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event) -{ - // int flags = event.GetFlags(); - int requestedLength = event.GetRequestedLength(); - - event.SetOrientation(m_orientation); - event.SetAlignment(m_alignment); - - if (m_orientation == wxLAYOUT_HORIZONTAL) - event.SetSize(wxSize(requestedLength, m_defaultSize.y)); - else - event.SetSize(wxSize(m_defaultSize.x, requestedLength)); -} - -// Called by parent to allow window to take a bit out of the -// client rectangle, and size itself if not in wxLAYOUT_QUERY mode. - -void wxSashLayoutWindow::OnCalculateLayout(wxCalculateLayoutEvent& event) -{ - wxRect clientSize(event.GetRect()); - - int flags = event.GetFlags(); - - if (!IsShown()) - return; - - // Let's assume that all windows stretch the full extent of the window in - // the direction of that window orientation. This will work for non-docking toolbars, - // and the status bar. Note that the windows have to have been created in a certain - // order to work, else you might get a left-aligned window going to the bottom - // of the window, and the status bar appearing to the right of it. The - // status bar would have to be created after or before the toolbar(s). - - wxRect thisRect; - - // Try to stretch - int length = (GetOrientation() == wxLAYOUT_HORIZONTAL) ? clientSize.width : clientSize.height; - wxLayoutOrientation orient = GetOrientation(); - - // We assume that a window that says it's horizontal, wants to be stretched in that - // direction. Is this distinction too fine? Do we assume that any horizontal - // window needs to be stretched in that direction? Possibly. - int whichDimension = (GetOrientation() == wxLAYOUT_HORIZONTAL) ? wxLAYOUT_LENGTH_X : wxLAYOUT_LENGTH_Y; - - wxQueryLayoutInfoEvent infoEvent(GetId()); - infoEvent.SetEventObject(this); - infoEvent.SetRequestedLength(length); - infoEvent.SetFlags(orient | whichDimension); - - if (!GetEventHandler()->ProcessEvent(infoEvent)) - return; - - wxSize sz = infoEvent.GetSize(); - - if (sz.x == 0 && sz.y == 0) // Assume it's invisible - return; - - // Now we know the size it wants to be. We wish to decide where to place it, i.e. - // how it's aligned. - switch (GetAlignment()) - { - case wxLAYOUT_TOP: - { - thisRect.x = clientSize.x; thisRect.y = clientSize.y; - thisRect.width = sz.x; thisRect.height = sz.y; - clientSize.y += thisRect.height; - clientSize.height -= thisRect.height; - break; - } - case wxLAYOUT_LEFT: - { - thisRect.x = clientSize.x; thisRect.y = clientSize.y; - thisRect.width = sz.x; thisRect.height = sz.y; - clientSize.x += thisRect.width; - clientSize.width -= thisRect.width; - break; - } - case wxLAYOUT_RIGHT: - { - thisRect.x = clientSize.x + (clientSize.width - sz.x); thisRect.y = clientSize.y; - thisRect.width = sz.x; thisRect.height = sz.y; - clientSize.width -= thisRect.width; - break; - } - case wxLAYOUT_BOTTOM: - { - thisRect.x = clientSize.x; thisRect.y = clientSize.y + (clientSize.height - sz.y); - thisRect.width = sz.x; thisRect.height = sz.y; - clientSize.height -= thisRect.height; - break; - } - case wxLAYOUT_NONE: - { - break; - } - - } - - if ((flags & wxLAYOUT_QUERY) == 0) - { - // If not in query mode, resize the window. - // TODO: add wxRect& form to wxWindow::SetSize - wxSize sz2 = GetSize(); - wxPoint pos = GetPosition(); - SetSize(thisRect.x, thisRect.y, thisRect.width, thisRect.height); - - // Make sure the sash is erased when the window is resized - if ((pos.x != thisRect.x || pos.y != thisRect.y || sz2.x != thisRect.width || sz2.y != thisRect.height) && - (GetSashVisible(wxSASH_TOP) || GetSashVisible(wxSASH_RIGHT) || GetSashVisible(wxSASH_BOTTOM) || GetSashVisible(wxSASH_LEFT))) - Refresh(true); - - } - - event.SetRect(clientSize); -} -#endif // wxUSE_SASH - - -// ---------------------------------------------------------------------------- -// wxLayoutAlgorithm -// ---------------------------------------------------------------------------- - -#if wxUSE_MDI_ARCHITECTURE - -// Lays out windows for an MDI frame. The MDI client area gets what's left -// over. -bool wxLayoutAlgorithm::LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* r) -{ - int cw, ch; - frame->GetClientSize(& cw, & ch); - - wxRect rect(0, 0, cw, ch); - if (r) - rect = * r; - - wxCalculateLayoutEvent event; - event.SetRect(rect); - - wxWindowList::compatibility_iterator node = frame->GetChildren().GetFirst(); - while (node) - { - wxWindow* win = node->GetData(); - - event.SetId(win->GetId()); - event.SetEventObject(win); - event.SetFlags(0); // ?? - - win->GetEventHandler()->ProcessEvent(event); - - node = node->GetNext(); - } - - wxWindow* clientWindow = frame->GetClientWindow(); - - rect = event.GetRect(); - - clientWindow->SetSize(rect.x, rect.y, rect.width, rect.height); - - return true; -} - -#endif // wxUSE_MDI_ARCHITECTURE - -bool wxLayoutAlgorithm::LayoutFrame(wxFrame* frame, wxWindow* mainWindow) -{ - return LayoutWindow(frame, mainWindow); -} - -// Layout algorithm for any window. mainWindow gets what's left over. -bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow) -{ - // Test if the parent is a sash window, and if so, - // reduce the available space to allow space for any active edges. - - int leftMargin = 0, rightMargin = 0, topMargin = 0, bottomMargin = 0; -#if wxUSE_SASH - if (wxDynamicCast(parent, wxSashWindow)) - { - wxSashWindow* sashWindow = (wxSashWindow*) parent; - - leftMargin = sashWindow->GetExtraBorderSize(); - rightMargin = sashWindow->GetExtraBorderSize(); - topMargin = sashWindow->GetExtraBorderSize(); - bottomMargin = sashWindow->GetExtraBorderSize(); - - if (sashWindow->GetSashVisible(wxSASH_LEFT)) - leftMargin += sashWindow->GetDefaultBorderSize(); - if (sashWindow->GetSashVisible(wxSASH_RIGHT)) - rightMargin += sashWindow->GetDefaultBorderSize(); - if (sashWindow->GetSashVisible(wxSASH_TOP)) - topMargin += sashWindow->GetDefaultBorderSize(); - if (sashWindow->GetSashVisible(wxSASH_BOTTOM)) - bottomMargin += sashWindow->GetDefaultBorderSize(); - } -#endif // wxUSE_SASH - - int cw, ch; - parent->GetClientSize(& cw, & ch); - - wxRect rect(leftMargin, topMargin, cw - leftMargin - rightMargin, ch - topMargin - bottomMargin); - - wxCalculateLayoutEvent event; - event.SetRect(rect); - - // Find the last layout-aware window, so we can make it fill all remaining - // space. - wxWindow *lastAwareWindow = NULL; - wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); - - while (node) - { - wxWindow* win = node->GetData(); - - if (win->IsShown()) - { - wxCalculateLayoutEvent tempEvent(win->GetId()); - tempEvent.SetEventObject(win); - tempEvent.SetFlags(wxLAYOUT_QUERY); - tempEvent.SetRect(event.GetRect()); - if (win->GetEventHandler()->ProcessEvent(tempEvent)) - lastAwareWindow = win; - } - - node = node->GetNext(); - } - - // Now do a dummy run to see if we have any space left for the final window (fail if not) - node = parent->GetChildren().GetFirst(); - while (node) - { - wxWindow* win = node->GetData(); - - // If mainWindow is NULL and we're at the last window, - // skip this, because we'll simply make it fit the remaining space. - if (win->IsShown() && (win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow)) - { - event.SetId(win->GetId()); - event.SetEventObject(win); - event.SetFlags(wxLAYOUT_QUERY); - - win->GetEventHandler()->ProcessEvent(event); - } - - node = node->GetNext(); - } - - if (event.GetRect().GetWidth() < 0 || event.GetRect().GetHeight() < 0) - return false; - - event.SetRect(rect); - - node = parent->GetChildren().GetFirst(); - while (node) - { - wxWindow* win = node->GetData(); - - // If mainWindow is NULL and we're at the last window, - // skip this, because we'll simply make it fit the remaining space. - if (win->IsShown() && (win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow)) - { - event.SetId(win->GetId()); - event.SetEventObject(win); - event.SetFlags(0); // ?? - - win->GetEventHandler()->ProcessEvent(event); - } - - node = node->GetNext(); - } - - rect = event.GetRect(); - - if (mainWindow) - mainWindow->SetSize(rect.x, rect.y, wxMax(0, rect.width), wxMax(0, rect.height)); - else if (lastAwareWindow) - { - // Fit the remaining space - lastAwareWindow->SetSize(rect.x, rect.y, wxMax(0, rect.width), wxMax(0, rect.height)); - } - - return true; -} - diff --git a/Source/3rd Party/wx/src/generic/listbkg.cpp b/Source/3rd Party/wx/src/generic/listbkg.cpp index 649a06221..50a6ea40e 100644 --- a/Source/3rd Party/wx/src/generic/listbkg.cpp +++ b/Source/3rd Party/wx/src/generic/listbkg.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 19.08.03 +// RCS-ID: $Id: listbkg.cpp 48783 2007-09-19 11:24:38Z RR $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -47,9 +48,12 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxListbook, wxBookCtrlBase) +IMPLEMENT_DYNAMIC_CLASS(wxListbookEvent, wxNotifyEvent) -wxDEFINE_EVENT( wxEVT_LISTBOOK_PAGE_CHANGING, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_LISTBOOK_PAGE_CHANGED, wxBookCtrlEvent ); +#if !WXWIN_COMPATIBILITY_EVENT_TYPES +const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wxNewEventType(); +const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED = wxNewEventType(); +#endif BEGIN_EVENT_TABLE(wxListbook, wxBookCtrlBase) EVT_SIZE(wxListbook::OnSize) @@ -64,6 +68,11 @@ END_EVENT_TABLE() // wxListbook creation // ---------------------------------------------------------------------------- +void wxListbook::Init() +{ + m_selection = wxNOT_FOUND; +} + bool wxListbook::Create(wxWindow *parent, wxWindowID id, @@ -96,12 +105,10 @@ wxListbook::Create(wxWindow *parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - GetListCtrlFlags() + wxLC_ICON | wxLC_SINGLE_SEL | + (IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP) ); - if ( GetListView()->InReportView() ) - GetListView()->InsertColumn(0, wxS("Pages")); - #ifdef __WXMSW__ // On XP with themes enabled the GetViewRect used in GetControllerSize() to // determine the space needed for the list view will incorrectly return @@ -115,50 +122,32 @@ wxListbook::Create(wxWindow *parent, return true; } -// ---------------------------------------------------------------------------- -// wxListCtrl flags -// ---------------------------------------------------------------------------- - -long wxListbook::GetListCtrlFlags() const -{ - // We'd like to always use wxLC_ICON mode but it doesn't work with the - // native wxListCtrl under MSW unless we do have icons for all the items, - // so we can't use it if we have no image list. In this case we'd like to - // use wxLC_LIST mode because it works correctly for both horizontally and - // vertically laid out controls, but MSW native wxListCtrl insists on - // creating multiple columns if there are too many items and there doesn't - // seem anything to do about it, so we have to use wxLC_REPORT mode in this - // case there. - - long flags = IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP; - if ( GetImageList() ) - { - flags |= wxLC_ICON; - } - else // No images. - { -#ifdef __WXMSW__ - if ( !IsVertical() ) - { - // Notice that we intentionally overwrite the alignment flags here - // by not using "|=", alignment isn't used for report view. - flags = wxLC_REPORT | wxLC_NO_HEADER; - } - else -#endif // __WXMSW__ - { - flags |= wxLC_LIST; - } - } - - // Use single selection in any case. - return flags | wxLC_SINGLE_SEL; -} - // ---------------------------------------------------------------------------- // wxListbook geometry management // ---------------------------------------------------------------------------- +wxSize wxListbook::GetControllerSize() const +{ + const wxSize sizeClient = GetClientSize(), + sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(), + sizeList = GetListView()->GetViewRect().GetSize() + sizeBorder; + + wxSize size; + + if ( IsVertical() ) + { + size.x = sizeClient.x; + size.y = sizeList.y; + } + else // left/right aligned + { + size.x = sizeList.x; + size.y = sizeClient.y; + } + + return size; +} + void wxListbook::OnSize(wxSizeEvent& event) { // arrange the icons before calling SetClientSize(), otherwise it wouldn't @@ -166,11 +155,9 @@ void wxListbook::OnSize(wxSizeEvent& event) // under MSW, we'd finish with an ugly looking list control with both // vertical and horizontal scrollbar (with one of them being added because // the other one is not accounted for in client size computations) - wxListView * const list = GetListView(); - if ( list ) - list->Arrange(); - - event.Skip(); + wxListView *list = GetListView(); + if (list) list->Arrange(); + wxBookCtrlBase::OnSize(event); } int wxListbook::HitTest(const wxPoint& pt, long *flags) const @@ -212,14 +199,25 @@ int wxListbook::HitTest(const wxPoint& pt, long *flags) const return pagePos; } -void wxListbook::UpdateSize() +wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const { - // we should find a more elegant way to force a layout than generating this - // dummy event - wxSizeEvent sz(GetSize(), GetId()); - GetEventHandler()->ProcessEvent(sz); + // we need to add the size of the list control and the border between + const wxSize sizeList = GetControllerSize(); + + wxSize size = sizePage; + if ( IsVertical() ) + { + size.y += sizeList.y + GetInternalBorder(); + } + else // left/right aligned + { + size.x += sizeList.x + GetInternalBorder(); + } + + return size; } + // ---------------------------------------------------------------------------- // accessing the pages // ---------------------------------------------------------------------------- @@ -236,19 +234,11 @@ wxString wxListbook::GetPageText(size_t n) const return GetListView()->GetItemText(n); } -int wxListbook::GetPageImage(size_t n) const +int wxListbook::GetPageImage(size_t WXUNUSED(n)) const { - wxListItem item; - item.SetId(n); + wxFAIL_MSG( _T("wxListbook::GetPageImage() not implemented") ); - if (GetListView()->GetItem(item)) - { - return item.GetImage(); - } - else - { - return wxNOT_FOUND; - } + return wxNOT_FOUND; } bool wxListbook::SetPageImage(size_t n, int imageId) @@ -262,31 +252,9 @@ bool wxListbook::SetPageImage(size_t n, int imageId) void wxListbook::SetImageList(wxImageList *imageList) { - const long flagsOld = GetListCtrlFlags(); + GetListView()->SetImageList(imageList, wxIMAGE_LIST_NORMAL); wxBookCtrlBase::SetImageList(imageList); - - const long flagsNew = GetListCtrlFlags(); - - wxListView * const list = GetListView(); - - // We may need to change the list control mode if the image list presence - // has changed. - if ( flagsNew != flagsOld ) - { - // Preserve the selection which is lost when changing the mode - const int oldSel = GetSelection(); - - list->SetWindowStyleFlag(flagsNew); - if ( list->InReportView() ) - list->InsertColumn(0, wxS("Pages")); - - // Restore selection - if ( oldSel != wxNOT_FOUND ) - SetSelection(oldSel); - } - - list->SetImageList(imageList, wxIMAGE_LIST_NORMAL); } // ---------------------------------------------------------------------------- @@ -300,14 +268,19 @@ void wxListbook::UpdateSelectedPage(size_t newsel) GetListView()->Focus(newsel); } -wxBookCtrlEvent* wxListbook::CreatePageChangingEvent() const +int wxListbook::GetSelection() const { - return new wxBookCtrlEvent(wxEVT_LISTBOOK_PAGE_CHANGING, m_windowId); + return m_selection; } -void wxListbook::MakeChangedEvent(wxBookCtrlEvent &event) +wxBookCtrlBaseEvent* wxListbook::CreatePageChangingEvent() const { - event.SetEventType(wxEVT_LISTBOOK_PAGE_CHANGED); + return new wxListbookEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId); +} + +void wxListbook::MakeChangedEvent(wxBookCtrlBaseEvent &event) +{ + event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED); } @@ -337,26 +310,57 @@ wxListbook::InsertPage(size_t n, GetListView()->Focus(m_selection); } - if ( !DoSetSelectionAfterInsertion(n, bSelect) ) + // some page should be selected: either this one or the first one if there + // is still no selection + int selNew = -1; + if ( bSelect ) + selNew = n; + else if ( m_selection == -1 ) + selNew = 0; + + if ( selNew != m_selection ) page->Hide(); - UpdateSize(); + if ( selNew != -1 ) + SetSelection(selNew); + + wxSizeEvent sz(GetSize(), GetId()); + GetEventHandler()->ProcessEvent(sz); return true; } wxWindow *wxListbook::DoRemovePage(size_t page) { + const size_t page_count = GetPageCount(); wxWindow *win = wxBookCtrlBase::DoRemovePage(page); if ( win ) { GetListView()->DeleteItem(page); - DoSetSelectionAfterRemoval(page); + if (m_selection >= (int)page) + { + // force new sel valid if possible + int sel = m_selection - 1; + if (page_count == 1) + sel = wxNOT_FOUND; + else if ((page_count == 2) || (sel == -1)) + sel = 0; + + // force sel invalid if deleting current page - don't try to hide it + m_selection = (m_selection == (int)page) ? wxNOT_FOUND : m_selection - 1; + + if ((sel != wxNOT_FOUND) && (sel != m_selection)) + SetSelection(sel); + } GetListView()->Arrange(); - UpdateSize(); + if (GetPageCount() == 0) + { + wxSizeEvent sz(GetSize(), GetId()); + ProcessEvent(sz); + } } return win; @@ -369,7 +373,10 @@ bool wxListbook::DeleteAllPages() if (!wxBookCtrlBase::DeleteAllPages()) return false; - UpdateSize(); + m_selection = -1; + + wxSizeEvent sz(GetSize(), GetId()); + ProcessEvent(sz); return true; } diff --git a/Source/3rd Party/wx/src/generic/listctrl.cpp b/Source/3rd Party/wx/src/generic/listctrl.cpp deleted file mode 100644 index 771c400bb..000000000 --- a/Source/3rd Party/wx/src/generic/listctrl.cpp +++ /dev/null @@ -1,5503 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/listctrl.cpp -// Purpose: generic implementation of wxListCtrl -// Author: Robert Roebling -// Vadim Zeitlin (virtual list control support) -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// TODO -// -// 1. we need to implement searching/sorting for virtual controls somehow -// 2. when changing selection the lines are refreshed twice - - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_LISTCTRL - -#include "wx/listctrl.h" - -#ifndef WX_PRECOMP - #include "wx/scrolwin.h" - #include "wx/timer.h" - #include "wx/settings.h" - #include "wx/dynarray.h" - #include "wx/dcclient.h" - #include "wx/dcscreen.h" - #include "wx/math.h" - #include "wx/settings.h" - #include "wx/sizer.h" -#endif - -#include "wx/imaglist.h" -#include "wx/renderer.h" -#include "wx/generic/private/listctrl.h" - -#ifdef __WXMAC__ - #include "wx/osx/private.h" -#endif - -#if defined(__WXMSW__) && !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__) - #define "wx/msw/wrapwin.h" -#endif - -// NOTE: If using the wxListBox visual attributes works everywhere then this can -// be removed, as well as the #else case below. -#define _USE_VISATTR 0 - - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// // the height of the header window (FIXME: should depend on its font!) -// static const int HEADER_HEIGHT = 23; - -static const int SCROLL_UNIT_X = 15; - -// the spacing between the lines (in report mode) -static const int LINE_SPACING = 0; - -// extra margins around the text label -#ifdef __WXGTK__ -static const int EXTRA_WIDTH = 6; -#else -static const int EXTRA_WIDTH = 4; -#endif - -#ifdef __WXGTK__ -static const int EXTRA_HEIGHT = 6; -#else -static const int EXTRA_HEIGHT = 4; -#endif - -// margin between the window and the items -static const int EXTRA_BORDER_X = 2; -static const int EXTRA_BORDER_Y = 2; - -// offset for the header window -static const int HEADER_OFFSET_X = 0; -static const int HEADER_OFFSET_Y = 0; - -// margin between rows of icons in [small] icon view -static const int MARGIN_BETWEEN_ROWS = 6; - -// when autosizing the columns, add some slack -static const int AUTOSIZE_COL_MARGIN = 10; - -// default width for the header columns -static const int WIDTH_COL_DEFAULT = 80; - -// the space between the image and the text in the report mode -static const int IMAGE_MARGIN_IN_REPORT_MODE = 5; - -// the space between the image and the text in the report mode in header -static const int HEADER_IMAGE_MARGIN_IN_REPORT_MODE = 2; - - - -// ---------------------------------------------------------------------------- -// arrays/list implementations -// ---------------------------------------------------------------------------- - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxListItemDataList) - -#include "wx/arrimpl.cpp" -WX_DEFINE_OBJARRAY(wxListLineDataArray) - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxListHeaderDataList) - - -// ---------------------------------------------------------------------------- -// wxListItemData -// ---------------------------------------------------------------------------- - -wxListItemData::~wxListItemData() -{ - // in the virtual list control the attributes are managed by the main - // program, so don't delete them - if ( !m_owner->IsVirtual() ) - delete m_attr; - - delete m_rect; -} - -void wxListItemData::Init() -{ - m_image = -1; - m_data = 0; - - m_attr = NULL; -} - -wxListItemData::wxListItemData(wxListMainWindow *owner) -{ - Init(); - - m_owner = owner; - - if ( owner->InReportView() ) - m_rect = NULL; - else - m_rect = new wxRect; -} - -void wxListItemData::SetItem( const wxListItem &info ) -{ - if ( info.m_mask & wxLIST_MASK_TEXT ) - SetText(info.m_text); - if ( info.m_mask & wxLIST_MASK_IMAGE ) - m_image = info.m_image; - if ( info.m_mask & wxLIST_MASK_DATA ) - m_data = info.m_data; - - if ( info.HasAttributes() ) - { - if ( m_attr ) - m_attr->AssignFrom(*info.GetAttributes()); - else - m_attr = new wxListItemAttr(*info.GetAttributes()); - } - - if ( m_rect ) - { - m_rect->x = - m_rect->y = - m_rect->height = 0; - m_rect->width = info.m_width; - } -} - -void wxListItemData::SetPosition( int x, int y ) -{ - wxCHECK_RET( m_rect, wxT("unexpected SetPosition() call") ); - - m_rect->x = x; - m_rect->y = y; -} - -void wxListItemData::SetSize( int width, int height ) -{ - wxCHECK_RET( m_rect, wxT("unexpected SetSize() call") ); - - if ( width != -1 ) - m_rect->width = width; - if ( height != -1 ) - m_rect->height = height; -} - -bool wxListItemData::IsHit( int x, int y ) const -{ - wxCHECK_MSG( m_rect, false, wxT("can't be called in this mode") ); - - return wxRect(GetX(), GetY(), GetWidth(), GetHeight()).Contains(x, y); -} - -int wxListItemData::GetX() const -{ - wxCHECK_MSG( m_rect, 0, wxT("can't be called in this mode") ); - - return m_rect->x; -} - -int wxListItemData::GetY() const -{ - wxCHECK_MSG( m_rect, 0, wxT("can't be called in this mode") ); - - return m_rect->y; -} - -int wxListItemData::GetWidth() const -{ - wxCHECK_MSG( m_rect, 0, wxT("can't be called in this mode") ); - - return m_rect->width; -} - -int wxListItemData::GetHeight() const -{ - wxCHECK_MSG( m_rect, 0, wxT("can't be called in this mode") ); - - return m_rect->height; -} - -void wxListItemData::GetItem( wxListItem &info ) const -{ - long mask = info.m_mask; - if ( !mask ) - // by default, get everything for backwards compatibility - mask = -1; - - if ( mask & wxLIST_MASK_TEXT ) - info.m_text = m_text; - if ( mask & wxLIST_MASK_IMAGE ) - info.m_image = m_image; - if ( mask & wxLIST_MASK_DATA ) - info.m_data = m_data; - - if ( m_attr ) - { - if ( m_attr->HasTextColour() ) - info.SetTextColour(m_attr->GetTextColour()); - if ( m_attr->HasBackgroundColour() ) - info.SetBackgroundColour(m_attr->GetBackgroundColour()); - if ( m_attr->HasFont() ) - info.SetFont(m_attr->GetFont()); - } -} - -//----------------------------------------------------------------------------- -// wxListHeaderData -//----------------------------------------------------------------------------- - -void wxListHeaderData::Init() -{ - m_mask = 0; - m_image = -1; - m_format = 0; - m_width = 0; - m_xpos = 0; - m_ypos = 0; - m_height = 0; - m_state = 0; -} - -wxListHeaderData::wxListHeaderData() -{ - Init(); -} - -wxListHeaderData::wxListHeaderData( const wxListItem &item ) -{ - Init(); - - SetItem( item ); -} - -void wxListHeaderData::SetItem( const wxListItem &item ) -{ - m_mask = item.m_mask; - - if ( m_mask & wxLIST_MASK_TEXT ) - m_text = item.m_text; - - if ( m_mask & wxLIST_MASK_IMAGE ) - m_image = item.m_image; - - if ( m_mask & wxLIST_MASK_FORMAT ) - m_format = item.m_format; - - if ( m_mask & wxLIST_MASK_WIDTH ) - SetWidth(item.m_width); - - if ( m_mask & wxLIST_MASK_STATE ) - SetState(item.m_state); -} - -void wxListHeaderData::SetPosition( int x, int y ) -{ - m_xpos = x; - m_ypos = y; -} - -void wxListHeaderData::SetHeight( int h ) -{ - m_height = h; -} - -void wxListHeaderData::SetWidth( int w ) -{ - m_width = w < 0 ? WIDTH_COL_DEFAULT : w; -} - -void wxListHeaderData::SetState( int flag ) -{ - m_state = flag; -} - -void wxListHeaderData::SetFormat( int format ) -{ - m_format = format; -} - -bool wxListHeaderData::HasImage() const -{ - return m_image != -1; -} - -bool wxListHeaderData::IsHit( int x, int y ) const -{ - return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); -} - -void wxListHeaderData::GetItem( wxListItem& item ) -{ - long mask = item.m_mask; - if ( !mask ) - { - // by default, get everything for backwards compatibility - mask = -1; - } - - if ( mask & wxLIST_MASK_STATE ) - item.m_state = m_state; - if ( mask & wxLIST_MASK_TEXT ) - item.m_text = m_text; - if ( mask & wxLIST_MASK_IMAGE ) - item.m_image = m_image; - if ( mask & wxLIST_MASK_WIDTH ) - item.m_width = m_width; - if ( mask & wxLIST_MASK_FORMAT ) - item.m_format = m_format; -} - -int wxListHeaderData::GetImage() const -{ - return m_image; -} - -int wxListHeaderData::GetWidth() const -{ - return m_width; -} - -int wxListHeaderData::GetFormat() const -{ - return m_format; -} - -int wxListHeaderData::GetState() const -{ - return m_state; -} - -//----------------------------------------------------------------------------- -// wxListLineData -//----------------------------------------------------------------------------- - -inline int wxListLineData::GetMode() const -{ - return m_owner->GetListCtrl()->GetWindowStyleFlag() & wxLC_MASK_TYPE; -} - -inline bool wxListLineData::InReportView() const -{ - return m_owner->HasFlag(wxLC_REPORT); -} - -inline bool wxListLineData::IsVirtual() const -{ - return m_owner->IsVirtual(); -} - -wxListLineData::wxListLineData( wxListMainWindow *owner ) -{ - m_owner = owner; - - if ( InReportView() ) - m_gi = NULL; - else // !report - m_gi = new GeometryInfo; - - m_highlighted = false; - - InitItems( GetMode() == wxLC_REPORT ? m_owner->GetColumnCount() : 1 ); -} - -void wxListLineData::CalculateSize( wxDC *dc, int spacing ) -{ - wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - wxCHECK_RET( node, wxT("no subitems at all??") ); - - wxListItemData *item = node->GetData(); - - wxString s; - wxCoord lw, lh; - - switch ( GetMode() ) - { - case wxLC_ICON: - case wxLC_SMALL_ICON: - m_gi->m_rectAll.width = spacing; - - s = item->GetText(); - - if ( s.empty() ) - { - lh = - m_gi->m_rectLabel.width = - m_gi->m_rectLabel.height = 0; - } - else // has label - { - dc->GetTextExtent( s, &lw, &lh ); - lw += EXTRA_WIDTH; - lh += EXTRA_HEIGHT; - - m_gi->m_rectAll.height = spacing + lh; - if (lw > spacing) - m_gi->m_rectAll.width = lw; - - m_gi->m_rectLabel.width = lw; - m_gi->m_rectLabel.height = lh; - } - - if (item->HasImage()) - { - int w, h; - m_owner->GetImageSize( item->GetImage(), w, h ); - m_gi->m_rectIcon.width = w + 8; - m_gi->m_rectIcon.height = h + 8; - - if ( m_gi->m_rectIcon.width > m_gi->m_rectAll.width ) - m_gi->m_rectAll.width = m_gi->m_rectIcon.width; - if ( m_gi->m_rectIcon.height + lh > m_gi->m_rectAll.height - 4 ) - m_gi->m_rectAll.height = m_gi->m_rectIcon.height + lh + 4; - } - - if ( item->HasText() ) - { - m_gi->m_rectHighlight.width = m_gi->m_rectLabel.width; - m_gi->m_rectHighlight.height = m_gi->m_rectLabel.height; - } - else // no text, highlight the icon - { - m_gi->m_rectHighlight.width = m_gi->m_rectIcon.width; - m_gi->m_rectHighlight.height = m_gi->m_rectIcon.height; - } - break; - - case wxLC_LIST: - s = item->GetTextForMeasuring(); - - dc->GetTextExtent( s, &lw, &lh ); - lw += EXTRA_WIDTH; - lh += EXTRA_HEIGHT; - - m_gi->m_rectLabel.width = lw; - m_gi->m_rectLabel.height = lh; - - m_gi->m_rectAll.width = lw; - m_gi->m_rectAll.height = lh; - - if (item->HasImage()) - { - int w, h; - m_owner->GetImageSize( item->GetImage(), w, h ); - m_gi->m_rectIcon.width = w; - m_gi->m_rectIcon.height = h; - - m_gi->m_rectAll.width += 4 + w; - if (h > m_gi->m_rectAll.height) - m_gi->m_rectAll.height = h; - } - - m_gi->m_rectHighlight.width = m_gi->m_rectAll.width; - m_gi->m_rectHighlight.height = m_gi->m_rectAll.height; - break; - - case wxLC_REPORT: - wxFAIL_MSG( wxT("unexpected call to SetSize") ); - break; - - default: - wxFAIL_MSG( wxT("unknown mode") ); - break; - } -} - -void wxListLineData::SetPosition( int x, int y, int spacing ) -{ - wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - wxCHECK_RET( node, wxT("no subitems at all??") ); - - wxListItemData *item = node->GetData(); - - switch ( GetMode() ) - { - case wxLC_ICON: - case wxLC_SMALL_ICON: - m_gi->m_rectAll.x = x; - m_gi->m_rectAll.y = y; - - if ( item->HasImage() ) - { - m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 4 + - (m_gi->m_rectAll.width - m_gi->m_rectIcon.width) / 2; - m_gi->m_rectIcon.y = m_gi->m_rectAll.y + 4; - } - - if ( item->HasText() ) - { - if (m_gi->m_rectAll.width > spacing) - m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2); - else - m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2) + (spacing / 2) - (m_gi->m_rectLabel.width / 2); - m_gi->m_rectLabel.y = m_gi->m_rectAll.y + m_gi->m_rectAll.height + 2 - m_gi->m_rectLabel.height; - m_gi->m_rectHighlight.x = m_gi->m_rectLabel.x - 2; - m_gi->m_rectHighlight.y = m_gi->m_rectLabel.y - 2; - } - else // no text, highlight the icon - { - m_gi->m_rectHighlight.x = m_gi->m_rectIcon.x - 4; - m_gi->m_rectHighlight.y = m_gi->m_rectIcon.y - 4; - } - break; - - case wxLC_LIST: - m_gi->m_rectAll.x = x; - m_gi->m_rectAll.y = y; - - m_gi->m_rectHighlight.x = m_gi->m_rectAll.x; - m_gi->m_rectHighlight.y = m_gi->m_rectAll.y; - m_gi->m_rectLabel.y = m_gi->m_rectAll.y + 2; - - if (item->HasImage()) - { - m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 2; - m_gi->m_rectIcon.y = m_gi->m_rectAll.y + 2; - m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 4 + (EXTRA_WIDTH/2) + m_gi->m_rectIcon.width; - } - else - { - m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2); - } - break; - - case wxLC_REPORT: - wxFAIL_MSG( wxT("unexpected call to SetPosition") ); - break; - - default: - wxFAIL_MSG( wxT("unknown mode") ); - break; - } -} - -void wxListLineData::InitItems( int num ) -{ - for (int i = 0; i < num; i++) - m_items.Append( new wxListItemData(m_owner) ); -} - -void wxListLineData::SetItem( int index, const wxListItem &info ) -{ - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - wxCHECK_RET( node, wxT("invalid column index in SetItem") ); - - wxListItemData *item = node->GetData(); - item->SetItem( info ); -} - -void wxListLineData::GetItem( int index, wxListItem &info ) -{ - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - if (node) - { - wxListItemData *item = node->GetData(); - item->GetItem( info ); - } -} - -wxString wxListLineData::GetText(int index) const -{ - wxString s; - - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - if (node) - { - wxListItemData *item = node->GetData(); - s = item->GetText(); - } - - return s; -} - -void wxListLineData::SetText( int index, const wxString& s ) -{ - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - if (node) - { - wxListItemData *item = node->GetData(); - item->SetText( s ); - } -} - -void wxListLineData::SetImage( int index, int image ) -{ - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - wxCHECK_RET( node, wxT("invalid column index in SetImage()") ); - - wxListItemData *item = node->GetData(); - item->SetImage(image); -} - -int wxListLineData::GetImage( int index ) const -{ - wxListItemDataList::compatibility_iterator node = m_items.Item( index ); - wxCHECK_MSG( node, -1, wxT("invalid column index in GetImage()") ); - - wxListItemData *item = node->GetData(); - return item->GetImage(); -} - -wxListItemAttr *wxListLineData::GetAttr() const -{ - wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - wxCHECK_MSG( node, NULL, wxT("invalid column index in GetAttr()") ); - - wxListItemData *item = node->GetData(); - return item->GetAttr(); -} - -void wxListLineData::SetAttr(wxListItemAttr *attr) -{ - wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - wxCHECK_RET( node, wxT("invalid column index in SetAttr()") ); - - wxListItemData *item = node->GetData(); - item->SetAttr(attr); -} - -void wxListLineData::ApplyAttributes(wxDC *dc, - const wxRect& rectHL, - bool highlighted, - bool current) -{ - const wxListItemAttr * const attr = GetAttr(); - - wxWindow * const listctrl = m_owner->GetParent(); - - const bool hasFocus = listctrl->HasFocus() -#if defined(__WXMAC__) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON - && IsControlActive( (ControlRef)listctrl->GetHandle() ) -#endif - ; - - // fg colour - - // don't use foreground colour for drawing highlighted items - this might - // make them completely invisible (and there is no way to do bit - // arithmetics on wxColour, unfortunately) - wxColour colText; - if ( highlighted ) - { -#ifdef __WXMAC__ - if ( hasFocus ) - colText = *wxWHITE; - else - colText = *wxBLACK; -#else - if ( hasFocus ) - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - else - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); -#endif - } - else if ( attr && attr->HasTextColour() ) - colText = attr->GetTextColour(); - else - colText = listctrl->GetForegroundColour(); - - dc->SetTextForeground(colText); - - // font - wxFont font; - if ( attr && attr->HasFont() ) - font = attr->GetFont(); - else - font = listctrl->GetFont(); - - dc->SetFont(font); - - // background - if ( highlighted ) - { - // Use the renderer method to ensure that the selected items use the - // native look. - int flags = wxCONTROL_SELECTED; - if ( hasFocus ) - flags |= wxCONTROL_FOCUSED; - if (current) - flags |= wxCONTROL_CURRENT; - wxRendererNative::Get(). - DrawItemSelectionRect( m_owner, *dc, rectHL, flags ); - } - else if ( attr && attr->HasBackgroundColour() ) - { - // Draw the background using the items custom background colour. - dc->SetBrush(attr->GetBackgroundColour()); - dc->SetPen(*wxTRANSPARENT_PEN); - dc->DrawRectangle(rectHL); - } - - // just for debugging to better see where the items are -#if 0 - dc->SetPen(*wxRED_PEN); - dc->SetBrush(*wxTRANSPARENT_BRUSH); - dc->DrawRectangle( m_gi->m_rectAll ); - dc->SetPen(*wxGREEN_PEN); - dc->DrawRectangle( m_gi->m_rectIcon ); -#endif -} - -void wxListLineData::Draw(wxDC *dc, bool current) -{ - wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - wxCHECK_RET( node, wxT("no subitems at all??") ); - - ApplyAttributes(dc, m_gi->m_rectHighlight, IsHighlighted(), current); - - wxListItemData *item = node->GetData(); - if (item->HasImage()) - { - // centre the image inside our rectangle, this looks nicer when items - // ae aligned in a row - const wxRect& rectIcon = m_gi->m_rectIcon; - - m_owner->DrawImage(item->GetImage(), dc, rectIcon.x, rectIcon.y); - } - - if (item->HasText()) - { - const wxRect& rectLabel = m_gi->m_rectLabel; - - wxDCClipper clipper(*dc, rectLabel); - dc->DrawText(item->GetText(), rectLabel.x, rectLabel.y); - } -} - -void wxListLineData::DrawInReportMode( wxDC *dc, - const wxRect& rect, - const wxRect& rectHL, - bool highlighted, - bool current ) -{ - // TODO: later we should support setting different attributes for - // different columns - to do it, just add "col" argument to - // GetAttr() and move these lines into the loop below - - ApplyAttributes(dc, rectHL, highlighted, current); - - wxCoord x = rect.x + HEADER_OFFSET_X, - yMid = rect.y + rect.height/2; -#ifdef __WXGTK__ - // This probably needs to be done - // on all platforms as the icons - // otherwise nearly touch the border - x += 2; -#endif - - size_t col = 0; - for ( wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); - node; - node = node->GetNext(), col++ ) - { - wxListItemData *item = node->GetData(); - - int width = m_owner->GetColumnWidth(col); - int xOld = x; - x += width; - - width -= 8; - const int wText = width; - wxDCClipper clipper(*dc, xOld, rect.y, wText, rect.height); - - if ( item->HasImage() ) - { - int ix, iy; - m_owner->GetImageSize( item->GetImage(), ix, iy ); - m_owner->DrawImage( item->GetImage(), dc, xOld, yMid - iy/2 ); - - ix += IMAGE_MARGIN_IN_REPORT_MODE; - - xOld += ix; - width -= ix; - } - - if ( item->HasText() ) - DrawTextFormatted(dc, item->GetText(), col, xOld, yMid, width); - } -} - -void wxListLineData::DrawTextFormatted(wxDC *dc, - const wxString& textOrig, - int col, - int x, - int yMid, - int width) -{ - // we don't support displaying multiple lines currently (and neither does - // wxMSW FWIW) so just merge all the lines - wxString text(textOrig); - text.Replace(wxT("\n"), wxT(" ")); - - wxCoord w, h; - dc->GetTextExtent(text, &w, &h); - - const wxCoord y = yMid - (h + 1)/2; - - wxDCClipper clipper(*dc, x, y, width, h); - - // determine if the string can fit inside the current width - if (w <= width) - { - // it can, draw it using the items alignment - wxListItem item; - m_owner->GetColumn(col, item); - switch ( item.GetAlign() ) - { - case wxLIST_FORMAT_LEFT: - // nothing to do - break; - - case wxLIST_FORMAT_RIGHT: - x += width - w; - break; - - case wxLIST_FORMAT_CENTER: - x += (width - w) / 2; - break; - - default: - wxFAIL_MSG( wxT("unknown list item format") ); - break; - } - - dc->DrawText(text, x, y); - } - else // otherwise, truncate and add an ellipsis if possible - { - // determine the base width - wxString ellipsis(wxT("...")); - wxCoord base_w; - dc->GetTextExtent(ellipsis, &base_w, &h); - - // continue until we have enough space or only one character left - wxCoord w_c, h_c; - size_t len = text.length(); - wxString drawntext = text.Left(len); - while (len > 1) - { - dc->GetTextExtent(drawntext.Last(), &w_c, &h_c); - drawntext.RemoveLast(); - len--; - w -= w_c; - if (w + base_w <= width) - break; - } - - // if still not enough space, remove ellipsis characters - while (ellipsis.length() > 0 && w + base_w > width) - { - ellipsis = ellipsis.Left(ellipsis.length() - 1); - dc->GetTextExtent(ellipsis, &base_w, &h); - } - - // now draw the text - dc->DrawText(drawntext, x, y); - dc->DrawText(ellipsis, x + w, y); - } -} - -bool wxListLineData::Highlight( bool on ) -{ - wxCHECK_MSG( !IsVirtual(), false, wxT("unexpected call to Highlight") ); - - if ( on == m_highlighted ) - return false; - - m_highlighted = on; - - return true; -} - -void wxListLineData::ReverseHighlight( void ) -{ - Highlight(!IsHighlighted()); -} - -//----------------------------------------------------------------------------- -// wxListHeaderWindow -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxListHeaderWindow,wxWindow) - EVT_PAINT (wxListHeaderWindow::OnPaint) - EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse) -END_EVENT_TABLE() - -void wxListHeaderWindow::Init() -{ - m_currentCursor = NULL; - m_isDragging = false; - m_dirty = false; - m_sendSetColumnWidth = false; -} - -wxListHeaderWindow::wxListHeaderWindow() -{ - Init(); - - m_owner = NULL; - m_resizeCursor = NULL; -} - -bool wxListHeaderWindow::Create( wxWindow *win, - wxWindowID id, - wxListMainWindow *owner, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString &name ) -{ - if ( !wxWindow::Create(win, id, pos, size, style, name) ) - return false; - - Init(); - - m_owner = owner; - m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE ); - -#if _USE_VISATTR - wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes(); - SetOwnForegroundColour( attr.colFg ); - SetOwnBackgroundColour( attr.colBg ); - if (!m_hasFont) - SetOwnFont( attr.font ); -#else - SetOwnForegroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - SetOwnBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - if (!m_hasFont) - SetOwnFont( wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT )); -#endif - - return true; -} - -wxListHeaderWindow::~wxListHeaderWindow() -{ - delete m_resizeCursor; -} - -#ifdef __WXUNIVERSAL__ -#include "wx/univ/renderer.h" -#include "wx/univ/theme.h" -#endif - -// shift the DC origin to match the position of the main window horz -// scrollbar: this allows us to always use logical coords -void wxListHeaderWindow::AdjustDC(wxDC& dc) -{ - wxGenericListCtrl *parent = m_owner->GetListCtrl(); - - int xpix; - parent->GetScrollPixelsPerUnit( &xpix, NULL ); - - int view_start; - parent->GetViewStart( &view_start, NULL ); - - - int org_x = 0; - int org_y = 0; - dc.GetDeviceOrigin( &org_x, &org_y ); - - // account for the horz scrollbar offset -#ifdef __WXGTK__ - if (GetLayoutDirection() == wxLayout_RightToLeft) - { - // Maybe we just have to check for m_signX - // in the DC, but I leave the #ifdef __WXGTK__ - // for now - dc.SetDeviceOrigin( org_x + (view_start * xpix), org_y ); - } - else -#endif - dc.SetDeviceOrigin( org_x - (view_start * xpix), org_y ); -} - -void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) -{ - wxGenericListCtrl *parent = m_owner->GetListCtrl(); - - wxPaintDC dc( this ); - - AdjustDC( dc ); - - dc.SetFont( GetFont() ); - - // width and height of the entire header window - int w, h; - GetClientSize( &w, &h ); - parent->CalcUnscrolledPosition(w, 0, &w, NULL); - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(GetForegroundColour()); - - int x = HEADER_OFFSET_X; - int numColumns = m_owner->GetColumnCount(); - wxListItem item; - for ( int i = 0; i < numColumns && x < w; i++ ) - { - m_owner->GetColumn( i, item ); - int wCol = item.m_width; - - int cw = wCol; - int ch = h; - - int flags = 0; - if (!m_parent->IsEnabled()) - flags |= wxCONTROL_DISABLED; - -// NB: The code below is not really Mac-specific, but since we are close -// to 2.8 release and I don't have time to test on other platforms, I -// defined this only for wxMac. If this behaviour is desired on -// other platforms, please go ahead and revise or remove the #ifdef. -#ifdef __WXMAC__ - if ( !m_owner->IsVirtual() && (item.m_mask & wxLIST_MASK_STATE) && - (item.m_state & wxLIST_STATE_SELECTED) ) - flags |= wxCONTROL_SELECTED; -#endif - - if (i == 0) - flags |= wxCONTROL_SPECIAL; // mark as first column - - wxRendererNative::Get().DrawHeaderButton - ( - this, - dc, - wxRect(x, HEADER_OFFSET_Y, cw, ch), - flags - ); - - // see if we have enough space for the column label - - // for this we need the width of the text - wxCoord wLabel; - wxCoord hLabel; - dc.GetTextExtent(item.GetText(), &wLabel, &hLabel); - wLabel += 2 * EXTRA_WIDTH; - - // and the width of the icon, if any - int ix = 0, iy = 0; // init them just to suppress the compiler warnings - const int image = item.m_image; - wxImageList *imageList; - if ( image != -1 ) - { - imageList = m_owner->GetSmallImageList(); - if ( imageList ) - { - imageList->GetSize(image, ix, iy); - wLabel += ix + HEADER_IMAGE_MARGIN_IN_REPORT_MODE; - } - } - else - { - imageList = NULL; - } - - // ignore alignment if there is not enough space anyhow - int xAligned; - switch ( wLabel < cw ? item.GetAlign() : wxLIST_FORMAT_LEFT ) - { - default: - wxFAIL_MSG( wxT("unknown list item format") ); - // fall through - - case wxLIST_FORMAT_LEFT: - xAligned = x; - break; - - case wxLIST_FORMAT_RIGHT: - xAligned = x + cw - wLabel; - break; - - case wxLIST_FORMAT_CENTER: - xAligned = x + (cw - wLabel) / 2; - break; - } - - // draw the text and image clipping them so that they - // don't overwrite the column boundary - wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h); - - // if we have an image, draw it on the right of the label - if ( imageList ) - { - imageList->Draw - ( - image, - dc, - xAligned + wLabel - ix - HEADER_IMAGE_MARGIN_IN_REPORT_MODE, - HEADER_OFFSET_Y + (h - iy)/2, - wxIMAGELIST_DRAW_TRANSPARENT - ); - } - - dc.DrawText( item.GetText(), - xAligned + EXTRA_WIDTH, (h - hLabel) / 2 ); - - x += wCol; - } - - // Fill in what's missing to the right of the columns, otherwise we will - // leave an unpainted area when columns are removed (and it looks better) - if ( x < w ) - { - wxRendererNative::Get().DrawHeaderButton - ( - this, - dc, - wxRect(x, HEADER_OFFSET_Y, w - x, h), - wxCONTROL_DIRTY // mark as last column - ); - } -} - -void wxListHeaderWindow::OnInternalIdle() -{ - wxWindow::OnInternalIdle(); - - if (m_sendSetColumnWidth) - { - m_owner->SetColumnWidth( m_colToSend, m_widthToSend ); - m_sendSetColumnWidth = false; - } -} - -void wxListHeaderWindow::DrawCurrent() -{ -#if 1 - // m_owner->SetColumnWidth( m_column, m_currentX - m_minX ); - m_sendSetColumnWidth = true; - m_colToSend = m_column; - m_widthToSend = m_currentX - m_minX; -#else - int x1 = m_currentX; - int y1 = 0; - m_owner->ClientToScreen( &x1, &y1 ); - - int x2 = m_currentX; - int y2 = 0; - m_owner->GetClientSize( NULL, &y2 ); - m_owner->ClientToScreen( &x2, &y2 ); - - wxScreenDC dc; - dc.SetLogicalFunction( wxINVERT ); - dc.SetPen( wxPen(*wxBLACK, 2) ); - dc.SetBrush( *wxTRANSPARENT_BRUSH ); - - AdjustDC(dc); - - dc.DrawLine( x1, y1, x2, y2 ); - - dc.SetLogicalFunction( wxCOPY ); - - dc.SetPen( wxNullPen ); - dc.SetBrush( wxNullBrush ); -#endif -} - -void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) -{ - wxGenericListCtrl *parent = m_owner->GetListCtrl(); - - // we want to work with logical coords - int x; - parent->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL); - int y = event.GetY(); - - if (m_isDragging) - { - SendListEvent(wxEVT_LIST_COL_DRAGGING, event.GetPosition()); - - // we don't draw the line beyond our window, but we allow dragging it - // there - int w = 0; - GetClientSize( &w, NULL ); - parent->CalcUnscrolledPosition(w, 0, &w, NULL); - w -= 6; - - // erase the line if it was drawn - if ( m_currentX < w ) - DrawCurrent(); - - if (event.ButtonUp()) - { - ReleaseMouse(); - m_isDragging = false; - m_dirty = true; - m_owner->SetColumnWidth( m_column, m_currentX - m_minX ); - SendListEvent(wxEVT_LIST_COL_END_DRAG, event.GetPosition()); - } - else - { - if (x > m_minX + 7) - m_currentX = x; - else - m_currentX = m_minX + 7; - - // draw in the new location - if ( m_currentX < w ) - DrawCurrent(); - } - } - else // not dragging - { - m_minX = 0; - bool hit_border = false; - - // end of the current column - int xpos = 0; - - // find the column where this event occurred - int col, - countCol = m_owner->GetColumnCount(); - for (col = 0; col < countCol; col++) - { - xpos += m_owner->GetColumnWidth( col ); - m_column = col; - - if ( (abs(x-xpos) < 3) && (y < 22) ) - { - // near the column border - hit_border = true; - break; - } - - if ( x < xpos ) - { - // inside the column - break; - } - - m_minX = xpos; - } - - if ( col == countCol ) - m_column = -1; - - if (event.LeftDown() || event.RightUp()) - { - if (hit_border && event.LeftDown()) - { - if ( SendListEvent(wxEVT_LIST_COL_BEGIN_DRAG, - event.GetPosition()) ) - { - m_isDragging = true; - m_currentX = x; - CaptureMouse(); - DrawCurrent(); - } - //else: column resizing was vetoed by the user code - } - else // click on a column - { - // record the selected state of the columns - if (event.LeftDown()) - { - for (int i=0; i < m_owner->GetColumnCount(); i++) - { - wxListItem colItem; - m_owner->GetColumn(i, colItem); - long state = colItem.GetState(); - if (i == m_column) - colItem.SetState(state | wxLIST_STATE_SELECTED); - else - colItem.SetState(state & ~wxLIST_STATE_SELECTED); - m_owner->SetColumn(i, colItem); - } - } - - SendListEvent( event.LeftDown() - ? wxEVT_LIST_COL_CLICK - : wxEVT_LIST_COL_RIGHT_CLICK, - event.GetPosition()); - } - } - else if (event.Moving()) - { - bool setCursor; - if (hit_border) - { - setCursor = m_currentCursor == wxSTANDARD_CURSOR; - m_currentCursor = m_resizeCursor; - } - else - { - setCursor = m_currentCursor != wxSTANDARD_CURSOR; - m_currentCursor = wxSTANDARD_CURSOR; - } - - if ( setCursor ) - SetCursor(*m_currentCursor); - } - } -} - -bool wxListHeaderWindow::SendListEvent(wxEventType type, const wxPoint& pos) -{ - wxWindow *parent = GetParent(); - wxListEvent le( type, parent->GetId() ); - le.SetEventObject( parent ); - le.m_pointDrag = pos; - - // the position should be relative to the parent window, not - // this one for compatibility with MSW and common sense: the - // user code doesn't know anything at all about this header - // window, so why should it get positions relative to it? - le.m_pointDrag.y -= GetSize().y; - - le.m_col = m_column; - return !parent->GetEventHandler()->ProcessEvent( le ) || le.IsAllowed(); -} - -//----------------------------------------------------------------------------- -// wxListRenameTimer (internal) -//----------------------------------------------------------------------------- - -wxListRenameTimer::wxListRenameTimer( wxListMainWindow *owner ) -{ - m_owner = owner; -} - -void wxListRenameTimer::Notify() -{ - m_owner->OnRenameTimer(); -} - -//----------------------------------------------------------------------------- -// wxListFindTimer (internal) -//----------------------------------------------------------------------------- - -void wxListFindTimer::Notify() -{ - m_owner->OnFindTimer(); -} - -//----------------------------------------------------------------------------- -// wxListTextCtrlWrapper (internal) -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxListTextCtrlWrapper, wxEvtHandler) - EVT_CHAR (wxListTextCtrlWrapper::OnChar) - EVT_KEY_UP (wxListTextCtrlWrapper::OnKeyUp) - EVT_KILL_FOCUS (wxListTextCtrlWrapper::OnKillFocus) -END_EVENT_TABLE() - -wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner, - wxTextCtrl *text, - size_t itemEdit) - : m_startValue(owner->GetItemText(itemEdit)), - m_itemEdited(itemEdit) -{ - m_owner = owner; - m_text = text; - m_aboutToFinish = false; - - wxGenericListCtrl *parent = m_owner->GetListCtrl(); - - wxRect rectLabel = owner->GetLineLabelRect(itemEdit); - - parent->CalcScrolledPosition(rectLabel.x, rectLabel.y, - &rectLabel.x, &rectLabel.y); - - m_text->Create(owner, wxID_ANY, m_startValue, - wxPoint(rectLabel.x-4,rectLabel.y-4), - wxSize(rectLabel.width+11,rectLabel.height+8)); - m_text->SetFocus(); - - m_text->PushEventHandler(this); -} - -void wxListTextCtrlWrapper::EndEdit(EndReason reason) -{ - if( m_aboutToFinish ) - { - // We already called Finish which cannot be called - // more than once. - return; - } - - m_aboutToFinish = true; - - switch ( reason ) - { - case End_Accept: - // Notify the owner about the changes - AcceptChanges(); - - // Even if vetoed, close the control (consistent with MSW) - Finish( true ); - break; - - case End_Discard: - m_owner->OnRenameCancelled(m_itemEdited); - - Finish( true ); - break; - - case End_Destroy: - // Don't generate any notifications for the control being destroyed - // and don't set focus to it neither. - Finish(false); - break; - } -} - -void wxListTextCtrlWrapper::Finish( bool setfocus ) -{ - m_text->RemoveEventHandler(this); - m_owner->ResetTextControl( m_text ); - - wxPendingDelete.Append( this ); - - if (setfocus) - m_owner->SetFocus(); -} - -bool wxListTextCtrlWrapper::AcceptChanges() -{ - const wxString value = m_text->GetValue(); - - // notice that we should always call OnRenameAccept() to generate the "end - // label editing" event, even if the user hasn't really changed anything - if ( !m_owner->OnRenameAccept(m_itemEdited, value) ) - { - // vetoed by the user - return false; - } - - // accepted, do rename the item (unless nothing changed) - if ( value != m_startValue ) - m_owner->SetItemText(m_itemEdited, value); - - return true; -} - -void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event ) -{ - if ( !CheckForEndEditKey(event) ) - event.Skip(); -} - -bool wxListTextCtrlWrapper::CheckForEndEditKey(const wxKeyEvent& event) -{ - switch ( event.m_keyCode ) - { - case WXK_RETURN: - EndEdit( End_Accept ); - break; - - case WXK_ESCAPE: - EndEdit( End_Discard ); - break; - - default: - return false; - } - - return true; -} - -void wxListTextCtrlWrapper::OnKeyUp( wxKeyEvent &event ) -{ - if (m_aboutToFinish) - { - // auto-grow the textctrl: - wxSize parentSize = m_owner->GetSize(); - wxPoint myPos = m_text->GetPosition(); - wxSize mySize = m_text->GetSize(); - int sx, sy; - m_text->GetTextExtent(m_text->GetValue() + wxT("MM"), &sx, &sy); - if (myPos.x + sx > parentSize.x) - sx = parentSize.x - myPos.x; - if (mySize.x > sx) - sx = mySize.x; - m_text->SetSize(sx, wxDefaultCoord); - } - - event.Skip(); -} - -void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event ) -{ - if ( !m_aboutToFinish ) - { - m_aboutToFinish = true; - if ( !AcceptChanges() ) - m_owner->OnRenameCancelled( m_itemEdited ); - - Finish( false ); - } - - // We must let the native text control handle focus - event.Skip(); -} - -//----------------------------------------------------------------------------- -// wxListMainWindow -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxListMainWindow, wxWindow) - EVT_PAINT (wxListMainWindow::OnPaint) - EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse) - EVT_CHAR_HOOK (wxListMainWindow::OnCharHook) - EVT_CHAR (wxListMainWindow::OnChar) - EVT_KEY_DOWN (wxListMainWindow::OnKeyDown) - EVT_KEY_UP (wxListMainWindow::OnKeyUp) - EVT_SET_FOCUS (wxListMainWindow::OnSetFocus) - EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus) - EVT_SCROLLWIN (wxListMainWindow::OnScroll) - EVT_CHILD_FOCUS (wxListMainWindow::OnChildFocus) -END_EVENT_TABLE() - -void wxListMainWindow::Init() -{ - m_dirty = true; - m_countVirt = 0; - m_lineFrom = - m_lineTo = (size_t)-1; - m_linesPerPage = 0; - - m_headerWidth = - m_lineHeight = 0; - - m_small_image_list = NULL; - m_normal_image_list = NULL; - - m_small_spacing = 30; - m_normal_spacing = 40; - - m_hasFocus = false; - m_dragCount = 0; - m_isCreated = false; - - m_lastOnSame = false; - m_renameTimer = new wxListRenameTimer( this ); - m_findTimer = NULL; - m_findBell = 0; // default is to not ring bell at all - m_textctrlWrapper = NULL; - - m_current = - m_lineLastClicked = - m_lineSelectSingleOnUp = - m_lineBeforeLastClicked = (size_t)-1; -} - -wxListMainWindow::wxListMainWindow() -{ - Init(); - - m_highlightBrush = - m_highlightUnfocusedBrush = NULL; -} - -wxListMainWindow::wxListMainWindow( wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size ) - : wxWindow( parent, id, pos, size, - wxWANTS_CHARS | wxBORDER_NONE ) -{ - Init(); - - m_highlightBrush = new wxBrush - ( - wxSystemSettings::GetColour - ( - wxSYS_COLOUR_HIGHLIGHT - ), - wxBRUSHSTYLE_SOLID - ); - - m_highlightUnfocusedBrush = new wxBrush - ( - wxSystemSettings::GetColour - ( - wxSYS_COLOUR_BTNSHADOW - ), - wxBRUSHSTYLE_SOLID - ); - - wxVisualAttributes attr = wxGenericListCtrl::GetClassDefaultAttributes(); - SetOwnForegroundColour( attr.colFg ); - SetOwnBackgroundColour( attr.colBg ); - if (!m_hasFont) - SetOwnFont( attr.font ); -} - -wxListMainWindow::~wxListMainWindow() -{ - if ( m_textctrlWrapper ) - m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Destroy); - - DoDeleteAllItems(); - WX_CLEAR_LIST(wxListHeaderDataList, m_columns); - WX_CLEAR_ARRAY(m_aColWidths); - - delete m_highlightBrush; - delete m_highlightUnfocusedBrush; - delete m_renameTimer; - delete m_findTimer; -} - -void wxListMainWindow::SetReportView(bool inReportView) -{ - const size_t count = m_lines.size(); - for ( size_t n = 0; n < count; n++ ) - { - m_lines[n].SetReportView(inReportView); - } -} - -void wxListMainWindow::CacheLineData(size_t line) -{ - wxGenericListCtrl *listctrl = GetListCtrl(); - - wxListLineData *ld = GetDummyLine(); - - size_t countCol = GetColumnCount(); - for ( size_t col = 0; col < countCol; col++ ) - { - ld->SetText(col, listctrl->OnGetItemText(line, col)); - ld->SetImage(col, listctrl->OnGetItemColumnImage(line, col)); - } - - ld->SetAttr(listctrl->OnGetItemAttr(line)); -} - -wxListLineData *wxListMainWindow::GetDummyLine() const -{ - wxASSERT_MSG( !IsEmpty(), wxT("invalid line index") ); - wxASSERT_MSG( IsVirtual(), wxT("GetDummyLine() shouldn't be called") ); - - wxListMainWindow *self = wxConstCast(this, wxListMainWindow); - - // we need to recreate the dummy line if the number of columns in the - // control changed as it would have the incorrect number of fields - // otherwise - if ( !m_lines.IsEmpty() && - m_lines[0].m_items.GetCount() != (size_t)GetColumnCount() ) - { - self->m_lines.Clear(); - } - - if ( m_lines.IsEmpty() ) - { - wxListLineData *line = new wxListLineData(self); - self->m_lines.Add(line); - - // don't waste extra memory -- there never going to be anything - // else/more in this array - self->m_lines.Shrink(); - } - - return &m_lines[0]; -} - -// ---------------------------------------------------------------------------- -// line geometry (report mode only) -// ---------------------------------------------------------------------------- - -wxCoord wxListMainWindow::GetLineHeight() const -{ - // we cache the line height as calling GetTextExtent() is slow - if ( !m_lineHeight ) - { - wxListMainWindow *self = wxConstCast(this, wxListMainWindow); - - wxClientDC dc( self ); - dc.SetFont( GetFont() ); - - wxCoord y; - dc.GetTextExtent(wxT("H"), NULL, &y); - - if ( m_small_image_list && m_small_image_list->GetImageCount() ) - { - int iw = 0, ih = 0; - m_small_image_list->GetSize(0, iw, ih); - y = wxMax(y, ih); - } - - y += EXTRA_HEIGHT; - self->m_lineHeight = y + LINE_SPACING; - } - - return m_lineHeight; -} - -wxCoord wxListMainWindow::GetLineY(size_t line) const -{ - wxASSERT_MSG( InReportView(), wxT("only works in report mode") ); - - return LINE_SPACING + line * GetLineHeight(); -} - -wxRect wxListMainWindow::GetLineRect(size_t line) const -{ - if ( !InReportView() ) - return GetLine(line)->m_gi->m_rectAll; - - wxRect rect; - rect.x = HEADER_OFFSET_X; - rect.y = GetLineY(line); - rect.width = GetHeaderWidth(); - rect.height = GetLineHeight(); - - return rect; -} - -wxRect wxListMainWindow::GetLineLabelRect(size_t line) const -{ - if ( !InReportView() ) - return GetLine(line)->m_gi->m_rectLabel; - - int image_x = 0; - wxListLineData *data = GetLine(line); - wxListItemDataList::compatibility_iterator node = data->m_items.GetFirst(); - if (node) - { - wxListItemData *item = node->GetData(); - if ( item->HasImage() ) - { - int ix, iy; - GetImageSize( item->GetImage(), ix, iy ); - image_x = 3 + ix + IMAGE_MARGIN_IN_REPORT_MODE; - } - } - - wxRect rect; - rect.x = image_x + HEADER_OFFSET_X; - rect.y = GetLineY(line); - rect.width = GetColumnWidth(0) - image_x; - rect.height = GetLineHeight(); - - return rect; -} - -wxRect wxListMainWindow::GetLineIconRect(size_t line) const -{ - if ( !InReportView() ) - return GetLine(line)->m_gi->m_rectIcon; - - wxListLineData *ld = GetLine(line); - wxASSERT_MSG( ld->HasImage(), wxT("should have an image") ); - - wxRect rect; - rect.x = HEADER_OFFSET_X; - rect.y = GetLineY(line); - GetImageSize(ld->GetImage(), rect.width, rect.height); - - return rect; -} - -wxRect wxListMainWindow::GetLineHighlightRect(size_t line) const -{ - return InReportView() ? GetLineRect(line) - : GetLine(line)->m_gi->m_rectHighlight; -} - -long wxListMainWindow::HitTestLine(size_t line, int x, int y) const -{ - wxASSERT_MSG( line < GetItemCount(), wxT("invalid line in HitTestLine") ); - - wxListLineData *ld = GetLine(line); - - if ( ld->HasImage() && GetLineIconRect(line).Contains(x, y) ) - return wxLIST_HITTEST_ONITEMICON; - - // VS: Testing for "ld->HasText() || InReportView()" instead of - // "ld->HasText()" is needed to make empty lines in report view - // possible - if ( ld->HasText() || InReportView() ) - { - wxRect rect = InReportView() ? GetLineRect(line) - : GetLineLabelRect(line); - - if ( rect.Contains(x, y) ) - return wxLIST_HITTEST_ONITEMLABEL; - } - - return 0; -} - -// ---------------------------------------------------------------------------- -// highlight (selection) handling -// ---------------------------------------------------------------------------- - -bool wxListMainWindow::IsHighlighted(size_t line) const -{ - if ( IsVirtual() ) - { - return m_selStore.IsSelected(line); - } - else // !virtual - { - wxListLineData *ld = GetLine(line); - wxCHECK_MSG( ld, false, wxT("invalid index in IsHighlighted") ); - - return ld->IsHighlighted(); - } -} - -void wxListMainWindow::HighlightLines( size_t lineFrom, - size_t lineTo, - bool highlight ) -{ - if ( IsVirtual() ) - { - wxArrayInt linesChanged; - if ( !m_selStore.SelectRange(lineFrom, lineTo, highlight, - &linesChanged) ) - { - // meny items changed state, refresh everything - RefreshLines(lineFrom, lineTo); - } - else // only a few items changed state, refresh only them - { - size_t count = linesChanged.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - RefreshLine(linesChanged[n]); - } - } - } - else // iterate over all items in non report view - { - for ( size_t line = lineFrom; line <= lineTo; line++ ) - { - if ( HighlightLine(line, highlight) ) - RefreshLine(line); - } - } -} - -bool wxListMainWindow::HighlightLine( size_t line, bool highlight ) -{ - bool changed; - - if ( IsVirtual() ) - { - changed = m_selStore.SelectItem(line, highlight); - } - else // !virtual - { - wxListLineData *ld = GetLine(line); - wxCHECK_MSG( ld, false, wxT("invalid index in HighlightLine") ); - - changed = ld->Highlight(highlight); - } - - if ( changed ) - { - SendNotify( line, highlight ? wxEVT_LIST_ITEM_SELECTED - : wxEVT_LIST_ITEM_DESELECTED ); - } - - return changed; -} - -void wxListMainWindow::RefreshLine( size_t line ) -{ - if ( InReportView() ) - { - size_t visibleFrom, visibleTo; - GetVisibleLinesRange(&visibleFrom, &visibleTo); - - if ( line < visibleFrom || line > visibleTo ) - return; - } - - wxRect rect = GetLineRect(line); - - GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - RefreshRect( rect ); -} - -void wxListMainWindow::RefreshLines( size_t lineFrom, size_t lineTo ) -{ - // we suppose that they are ordered by caller - wxASSERT_MSG( lineFrom <= lineTo, wxT("indices in disorder") ); - - wxASSERT_MSG( lineTo < GetItemCount(), wxT("invalid line range") ); - - if ( InReportView() ) - { - size_t visibleFrom, visibleTo; - GetVisibleLinesRange(&visibleFrom, &visibleTo); - - if ( lineFrom < visibleFrom ) - lineFrom = visibleFrom; - if ( lineTo > visibleTo ) - lineTo = visibleTo; - - wxRect rect; - rect.x = 0; - rect.y = GetLineY(lineFrom); - rect.width = GetClientSize().x; - rect.height = GetLineY(lineTo) - rect.y + GetLineHeight(); - - GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - RefreshRect( rect ); - } - else // !report - { - // TODO: this should be optimized... - for ( size_t line = lineFrom; line <= lineTo; line++ ) - { - RefreshLine(line); - } - } -} - -void wxListMainWindow::RefreshAfter( size_t lineFrom ) -{ - if ( InReportView() ) - { - size_t visibleFrom, visibleTo; - GetVisibleLinesRange(&visibleFrom, &visibleTo); - - if ( lineFrom < visibleFrom ) - lineFrom = visibleFrom; - else if ( lineFrom > visibleTo ) - return; - - wxRect rect; - rect.x = 0; - rect.y = GetLineY(lineFrom); - GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - - wxSize size = GetClientSize(); - rect.width = size.x; - - // refresh till the bottom of the window - rect.height = size.y - rect.y; - - RefreshRect( rect ); - } - else // !report - { - // TODO: how to do it more efficiently? - m_dirty = true; - } -} - -void wxListMainWindow::RefreshSelected() -{ - if ( IsEmpty() ) - return; - - size_t from, to; - if ( InReportView() ) - { - GetVisibleLinesRange(&from, &to); - } - else // !virtual - { - from = 0; - to = GetItemCount() - 1; - } - - if ( HasCurrent() && m_current >= from && m_current <= to ) - RefreshLine(m_current); - - for ( size_t line = from; line <= to; line++ ) - { - // NB: the test works as expected even if m_current == -1 - if ( line != m_current && IsHighlighted(line) ) - RefreshLine(line); - } -} - -void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) -{ - // Note: a wxPaintDC must be constructed even if no drawing is - // done (a Windows requirement). - wxPaintDC dc( this ); - - if ( IsEmpty() ) - { - // nothing to draw or not the moment to draw it - return; - } - - if ( m_dirty ) - RecalculatePositions( false ); - - GetListCtrl()->PrepareDC( dc ); - - int dev_x, dev_y; - GetListCtrl()->CalcScrolledPosition( 0, 0, &dev_x, &dev_y ); - - dc.SetFont( GetFont() ); - - if ( InReportView() ) - { - int lineHeight = GetLineHeight(); - - size_t visibleFrom, visibleTo; - GetVisibleLinesRange(&visibleFrom, &visibleTo); - - wxRect rectLine; - int xOrig = dc.LogicalToDeviceX( 0 ); - int yOrig = dc.LogicalToDeviceY( 0 ); - - // tell the caller cache to cache the data - if ( IsVirtual() ) - { - wxListEvent evCache(wxEVT_LIST_CACHE_HINT, - GetParent()->GetId()); - evCache.SetEventObject( GetParent() ); - evCache.m_oldItemIndex = visibleFrom; - evCache.m_item.m_itemId = - evCache.m_itemIndex = visibleTo; - GetParent()->GetEventHandler()->ProcessEvent( evCache ); - } - - for ( size_t line = visibleFrom; line <= visibleTo; line++ ) - { - rectLine = GetLineRect(line); - - - if ( !IsExposed(rectLine.x + xOrig, rectLine.y + yOrig, - rectLine.width, rectLine.height) ) - { - // don't redraw unaffected lines to avoid flicker - continue; - } - - GetLine(line)->DrawInReportMode( &dc, - rectLine, - GetLineHighlightRect(line), - IsHighlighted(line), - line == m_current ); - } - - if ( HasFlag(wxLC_HRULES) ) - { - wxPen pen(GetRuleColour(), 1, wxPENSTYLE_SOLID); - wxSize clientSize = GetClientSize(); - - size_t i = visibleFrom; - if (i == 0) i = 1; // Don't draw the first one - for ( ; i <= visibleTo; i++ ) - { - dc.SetPen(pen); - dc.SetBrush( *wxTRANSPARENT_BRUSH ); - dc.DrawLine(0 - dev_x, i * lineHeight, - clientSize.x - dev_x, i * lineHeight); - } - - // Draw last horizontal rule - if ( visibleTo == GetItemCount() - 1 ) - { - dc.SetPen( pen ); - dc.SetBrush( *wxTRANSPARENT_BRUSH ); - dc.DrawLine(0 - dev_x, (m_lineTo + 1) * lineHeight, - clientSize.x - dev_x , (m_lineTo + 1) * lineHeight ); - } - } - - // Draw vertical rules if required - if ( HasFlag(wxLC_VRULES) && !IsEmpty() ) - { - wxPen pen(GetRuleColour(), 1, wxPENSTYLE_SOLID); - wxRect firstItemRect, lastItemRect; - - GetItemRect(visibleFrom, firstItemRect); - GetItemRect(visibleTo, lastItemRect); - int x = firstItemRect.GetX(); - dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); - - for (int col = 0; col < GetColumnCount(); col++) - { - int colWidth = GetColumnWidth(col); - x += colWidth; - int x_pos = x - dev_x; - if (col < GetColumnCount()-1) x_pos -= 2; - dc.DrawLine(x_pos, firstItemRect.GetY() - 1 - dev_y, - x_pos, lastItemRect.GetBottom() + 1 - dev_y); - } - } - } - else // !report - { - size_t count = GetItemCount(); - for ( size_t i = 0; i < count; i++ ) - { - GetLine(i)->Draw( &dc, i == m_current ); - } - } - - // DrawFocusRect() is unusable under Mac, it draws outside of the highlight - // rectangle somehow and so leaves traces when the item is not selected any - // more, see #12229. -#ifndef __WXMAC__ - if ( HasCurrent() ) - { - int flags = 0; - if ( IsHighlighted(m_current) ) - flags |= wxCONTROL_SELECTED; - - wxRendererNative::Get(). - DrawFocusRect(this, dc, GetLineHighlightRect(m_current), flags); - } -#endif // !__WXMAC__ -} - -void wxListMainWindow::HighlightAll( bool on ) -{ - if ( IsSingleSel() ) - { - wxASSERT_MSG( !on, wxT("can't do this in a single selection control") ); - - // we just have one item to turn off - if ( HasCurrent() && IsHighlighted(m_current) ) - { - HighlightLine(m_current, false); - RefreshLine(m_current); - } - } - else // multi selection - { - if ( !IsEmpty() ) - HighlightLines(0, GetItemCount() - 1, on); - } -} - -void wxListMainWindow::OnChildFocus(wxChildFocusEvent& WXUNUSED(event)) -{ - // Do nothing here. This prevents the default handler in wxScrolledWindow - // from needlessly scrolling the window when the edit control is - // dismissed. See ticket #9563. -} - -void wxListMainWindow::SendNotify( size_t line, - wxEventType command, - const wxPoint& point ) -{ - wxListEvent le( command, GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - - le.m_item.m_itemId = - le.m_itemIndex = line; - - // set only for events which have position - if ( point != wxDefaultPosition ) - le.m_pointDrag = point; - - // don't try to get the line info for virtual list controls: the main - // program has it anyhow and if we did it would result in accessing all - // the lines, even those which are not visible now and this is precisely - // what we're trying to avoid - if ( !IsVirtual() ) - { - if ( line != (size_t)-1 ) - { - GetLine(line)->GetItem( 0, le.m_item ); - } - //else: this happens for wxEVT_LIST_ITEM_FOCUSED event - } - //else: there may be no more such item - - GetParent()->GetEventHandler()->ProcessEvent( le ); -} - -void wxListMainWindow::ChangeCurrent(size_t current) -{ - m_current = current; - - // as the current item changed, we shouldn't start editing it when the - // "slow click" timer expires as the click happened on another item - if ( m_renameTimer->IsRunning() ) - m_renameTimer->Stop(); - - SendNotify(current, wxEVT_LIST_ITEM_FOCUSED); -} - -wxTextCtrl *wxListMainWindow::EditLabel(long item, wxClassInfo* textControlClass) -{ - wxCHECK_MSG( (item >= 0) && ((size_t)item < GetItemCount()), NULL, - wxT("wrong index in wxGenericListCtrl::EditLabel()") ); - - wxASSERT_MSG( textControlClass->IsKindOf(wxCLASSINFO(wxTextCtrl)), - wxT("EditLabel() needs a text control") ); - - size_t itemEdit = (size_t)item; - - wxListEvent le( wxEVT_LIST_BEGIN_LABEL_EDIT, GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - le.m_item.m_itemId = - le.m_itemIndex = item; - wxListLineData *data = GetLine(itemEdit); - wxCHECK_MSG( data, NULL, wxT("invalid index in EditLabel()") ); - data->GetItem( 0, le.m_item ); - - if ( GetParent()->GetEventHandler()->ProcessEvent( le ) && !le.IsAllowed() ) - { - // vetoed by user code - return NULL; - } - - if ( m_dirty ) - { - // Ensure the display is updated before we start editing. - Update(); - } - - wxTextCtrl * const text = (wxTextCtrl *)textControlClass->CreateObject(); - m_textctrlWrapper = new wxListTextCtrlWrapper(this, text, item); - return m_textctrlWrapper->GetText(); -} - -bool wxListMainWindow::EndEditLabel(bool cancel) -{ - if (!m_textctrlWrapper) - { - return false; - } - - m_textctrlWrapper->EndEdit(cancel ? wxListTextCtrlWrapper::End_Discard : wxListTextCtrlWrapper::End_Accept); - return true; -} - -void wxListMainWindow::OnRenameTimer() -{ - wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") ); - - EditLabel( m_current ); -} - -bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value) -{ - wxListEvent le( wxEVT_LIST_END_LABEL_EDIT, GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - le.m_item.m_itemId = - le.m_itemIndex = itemEdit; - - wxListLineData *data = GetLine(itemEdit); - - wxCHECK_MSG( data, false, wxT("invalid index in OnRenameAccept()") ); - - data->GetItem( 0, le.m_item ); - le.m_item.m_text = value; - return !GetParent()->GetEventHandler()->ProcessEvent( le ) || - le.IsAllowed(); -} - -void wxListMainWindow::OnRenameCancelled(size_t itemEdit) -{ - // let owner know that the edit was cancelled - wxListEvent le( wxEVT_LIST_END_LABEL_EDIT, GetParent()->GetId() ); - - le.SetEditCanceled(true); - - le.SetEventObject( GetParent() ); - le.m_item.m_itemId = - le.m_itemIndex = itemEdit; - - wxListLineData *data = GetLine(itemEdit); - wxCHECK_RET( data, wxT("invalid index in OnRenameCancelled()") ); - - data->GetItem( 0, le.m_item ); - GetEventHandler()->ProcessEvent( le ); -} - -void wxListMainWindow::OnFindTimer() -{ - m_findPrefix.clear(); - if ( m_findBell ) - m_findBell = 1; -} - -void wxListMainWindow::EnableBellOnNoMatch( bool on ) -{ - m_findBell = on; -} - -void wxListMainWindow::OnMouse( wxMouseEvent &event ) -{ -#ifdef __WXMAC__ - // On wxMac we can't depend on the EVT_KILL_FOCUS event to properly - // shutdown the edit control when the mouse is clicked elsewhere on the - // listctrl because the order of events is different (or something like - // that), so explicitly end the edit if it is active. - if ( event.LeftDown() && m_textctrlWrapper ) - m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Accept); -#endif // __WXMAC__ - - if ( event.LeftDown() ) - { - // Ensure we skip the event to let the system set focus to this window. - event.Skip(); - } - - // Pretend that the event happened in wxListCtrl itself. - wxMouseEvent me(event); - me.SetEventObject( GetParent() ); - me.SetId(GetParent()->GetId()); - if ( GetParent()->GetEventHandler()->ProcessEvent( me )) - return; - - if (event.GetEventType() == wxEVT_MOUSEWHEEL) - { - // let the base class handle mouse wheel events. - event.Skip(); - return; - } - - if ( !HasCurrent() || IsEmpty() ) - { - if (event.RightDown()) - { - SendNotify( (size_t)-1, wxEVT_LIST_ITEM_RIGHT_CLICK, event.GetPosition() ); - - wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, - GetParent()->GetId(), - ClientToScreen(event.GetPosition())); - evtCtx.SetEventObject(GetParent()); - GetParent()->GetEventHandler()->ProcessEvent(evtCtx); - } - return; - } - - if (m_dirty) - return; - - if ( !(event.Dragging() || event.ButtonDown() || event.LeftUp() || - event.ButtonDClick()) ) - return; - - int x = event.GetX(); - int y = event.GetY(); - GetListCtrl()->CalcUnscrolledPosition( x, y, &x, &y ); - - // where did we hit it (if we did)? - long hitResult = 0; - - size_t count = GetItemCount(), - current; - - if ( InReportView() ) - { - current = y / GetLineHeight(); - if ( current < count ) - hitResult = HitTestLine(current, x, y); - } - else // !report - { - // TODO: optimize it too! this is less simple than for report view but - // enumerating all items is still not a way to do it!! - for ( current = 0; current < count; current++ ) - { - hitResult = HitTestLine(current, x, y); - if ( hitResult ) - break; - } - } - - // Update drag events counter first as we must do it even if the mouse is - // not on any item right now as we must keep count in case we started - // dragging from the empty control area but continued to do it over a valid - // item -- in this situation we must not start dragging this item. - if (event.Dragging()) - m_dragCount++; - else - m_dragCount = 0; - - // The only mouse event that can be generated without any valid item is - // wxEVT_LIST_ITEM_RIGHT_CLICK as it can be useful to have a global - // popup menu for the list control itself which should be shown even when - // the user clicks outside of any item. - if ( !hitResult ) - { - // outside of any item - if (event.RightDown()) - { - SendNotify( (size_t) -1, wxEVT_LIST_ITEM_RIGHT_CLICK, event.GetPosition() ); - - wxContextMenuEvent evtCtx( - wxEVT_CONTEXT_MENU, - GetParent()->GetId(), - ClientToScreen(event.GetPosition())); - evtCtx.SetEventObject(GetParent()); - GetParent()->GetEventHandler()->ProcessEvent(evtCtx); - } - else - { - // reset the selection and bail out - HighlightAll(false); - } - - return; - } - - if ( event.Dragging() ) - { - if (m_dragCount == 1) - { - // we have to report the raw, physical coords as we want to be - // able to call HitTest(event.m_pointDrag) from the user code to - // get the item being dragged - m_dragStart = event.GetPosition(); - } - - if (m_dragCount != 3) - return; - - int command = event.RightIsDown() ? wxEVT_LIST_BEGIN_RDRAG - : wxEVT_LIST_BEGIN_DRAG; - - SendNotify( m_lineLastClicked, command, m_dragStart ); - - return; - } - - bool forceClick = false; - if (event.ButtonDClick()) - { - if ( m_renameTimer->IsRunning() ) - m_renameTimer->Stop(); - - m_lastOnSame = false; - - if ( current == m_lineLastClicked ) - { - SendNotify( current, wxEVT_LIST_ITEM_ACTIVATED ); - - return; - } - else - { - // The first click was on another item, so don't interpret this as - // a double click, but as a simple click instead - forceClick = true; - } - } - - if (event.LeftUp()) - { - if (m_lineSelectSingleOnUp != (size_t)-1) - { - // select single line - HighlightAll( false ); - ReverseHighlight(m_lineSelectSingleOnUp); - } - - if (m_lastOnSame) - { - if ((current == m_current) && - (hitResult == wxLIST_HITTEST_ONITEMLABEL) && - HasFlag(wxLC_EDIT_LABELS) ) - { - if ( !InReportView() || - GetLineLabelRect(current).Contains(x, y) ) - { - int dclick = wxSystemSettings::GetMetric(wxSYS_DCLICK_MSEC); - m_renameTimer->Start(dclick > 0 ? dclick : 250, true); - } - } - - m_lastOnSame = false; - } - - m_lineSelectSingleOnUp = (size_t)-1; - } - else - { - // This is necessary, because after a DnD operation in - // from and to ourself, the up event is swallowed by the - // DnD code. So on next non-up event (which means here and - // now) m_lineSelectSingleOnUp should be reset. - m_lineSelectSingleOnUp = (size_t)-1; - } - if (event.RightDown()) - { - m_lineBeforeLastClicked = m_lineLastClicked; - m_lineLastClicked = current; - - // If the item is already selected, do not update the selection. - // Multi-selections should not be cleared if a selected item is clicked. - if (!IsHighlighted(current)) - { - HighlightAll(false); - ChangeCurrent(current); - ReverseHighlight(m_current); - } - - SendNotify( current, wxEVT_LIST_ITEM_RIGHT_CLICK, event.GetPosition() ); - - // Allow generation of context menu event - event.Skip(); - } - else if (event.MiddleDown()) - { - SendNotify( current, wxEVT_LIST_ITEM_MIDDLE_CLICK ); - } - else if ( event.LeftDown() || forceClick ) - { - m_lineBeforeLastClicked = m_lineLastClicked; - m_lineLastClicked = current; - - size_t oldCurrent = m_current; - bool oldWasSelected = IsHighlighted(m_current); - - bool cmdModifierDown = event.CmdDown(); - if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) ) - { - if ( IsSingleSel() || !IsHighlighted(current) ) - { - HighlightAll( false ); - - ChangeCurrent(current); - - ReverseHighlight(m_current); - } - else // multi sel & current is highlighted & no mod keys - { - m_lineSelectSingleOnUp = current; - ChangeCurrent(current); // change focus - } - } - else // multi sel & either ctrl or shift is down - { - if (cmdModifierDown) - { - ChangeCurrent(current); - - ReverseHighlight(m_current); - } - else if (event.ShiftDown()) - { - ChangeCurrent(current); - - size_t lineFrom = oldCurrent, - lineTo = current; - - if ( lineTo < lineFrom ) - { - lineTo = lineFrom; - lineFrom = m_current; - } - - HighlightLines(lineFrom, lineTo); - } - else // !ctrl, !shift - { - // test in the enclosing if should make it impossible - wxFAIL_MSG( wxT("how did we get here?") ); - } - } - - if (m_current != oldCurrent) - RefreshLine( oldCurrent ); - - // Set the flag telling us whether the next click on this item should - // start editing its label. This should happen if we clicked on the - // current item and it was already selected, i.e. if this click was not - // done to select it. - // - // It should not happen if this was a double click (forceClick is true) - // nor if we hadn't had the focus before as then this click was used to - // give focus to the control. - m_lastOnSame = (m_current == oldCurrent) && oldWasSelected && - !forceClick && HasFocus(); - } -} - -void wxListMainWindow::MoveToItem(size_t item) -{ - if ( item == (size_t)-1 ) - return; - - wxRect rect = GetLineRect(item); - - int client_w, client_h; - GetClientSize( &client_w, &client_h ); - - const int hLine = GetLineHeight(); - - int view_x = SCROLL_UNIT_X * GetListCtrl()->GetScrollPos( wxHORIZONTAL ); - int view_y = hLine * GetListCtrl()->GetScrollPos( wxVERTICAL ); - - if ( InReportView() ) - { - // the next we need the range of lines shown it might be different, - // so recalculate it - ResetVisibleLinesRange(); - - if (rect.y < view_y) - GetListCtrl()->Scroll( -1, rect.y / hLine ); - if (rect.y + rect.height + 5 > view_y + client_h) - GetListCtrl()->Scroll( -1, (rect.y + rect.height - client_h + hLine) / hLine ); - -#ifdef __WXMAC__ - // At least on Mac the visible lines value will get reset inside of - // Scroll *before* it actually scrolls the window because of the - // Update() that happens there, so it will still have the wrong value. - // So let's reset it again and wait for it to be recalculated in the - // next paint event. I would expect this problem to show up in wxGTK - // too but couldn't duplicate it there. Perhaps the order of events - // is different... --Robin - ResetVisibleLinesRange(); -#endif - } - else // !report - { - int sx = -1, - sy = -1; - - if (rect.x-view_x < 5) - sx = (rect.x - 5) / SCROLL_UNIT_X; - if (rect.x + rect.width - 5 > view_x + client_w) - sx = (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X; - - if (rect.y-view_y < 5) - sy = (rect.y - 5) / hLine; - if (rect.y + rect.height - 5 > view_y + client_h) - sy = (rect.y + rect.height - client_h + hLine) / hLine; - - GetListCtrl()->Scroll(sx, sy); - } -} - -bool wxListMainWindow::ScrollList(int WXUNUSED(dx), int dy) -{ - if ( !InReportView() ) - { - // TODO: this should work in all views but is not implemented now - return false; - } - - size_t top, bottom; - GetVisibleLinesRange(&top, &bottom); - - if ( bottom == (size_t)-1 ) - return 0; - - ResetVisibleLinesRange(); - - int hLine = GetLineHeight(); - - GetListCtrl()->Scroll(-1, top + dy / hLine); - -#ifdef __WXMAC__ - // see comment in MoveToItem() for why we do this - ResetVisibleLinesRange(); -#endif - - return true; -} - -// ---------------------------------------------------------------------------- -// keyboard handling -// ---------------------------------------------------------------------------- - -void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event) -{ - wxCHECK_RET( newCurrent < (size_t)GetItemCount(), - wxT("invalid item index in OnArrowChar()") ); - - size_t oldCurrent = m_current; - - // in single selection we just ignore Shift as we can't select several - // items anyhow - if ( event.ShiftDown() && !IsSingleSel() ) - { - ChangeCurrent(newCurrent); - - // refresh the old focus to remove it - RefreshLine( oldCurrent ); - - // select all the items between the old and the new one - if ( oldCurrent > newCurrent ) - { - newCurrent = oldCurrent; - oldCurrent = m_current; - } - - HighlightLines(oldCurrent, newCurrent); - } - else // !shift - { - // all previously selected items are unselected unless ctrl is held - // in a multiselection control - if ( !event.ControlDown() || IsSingleSel() ) - HighlightAll(false); - - ChangeCurrent(newCurrent); - - // refresh the old focus to remove it - RefreshLine( oldCurrent ); - - // in single selection mode we must always have a selected item - if ( !event.ControlDown() || IsSingleSel() ) - HighlightLine( m_current, true ); - } - - RefreshLine( m_current ); - - MoveToFocus(); -} - -void wxListMainWindow::OnKeyDown( wxKeyEvent &event ) -{ - wxWindow *parent = GetParent(); - - // propagate the key event upwards - wxKeyEvent ke(event); - ke.SetEventObject( parent ); - ke.SetId(GetParent()->GetId()); - if (parent->GetEventHandler()->ProcessEvent( ke )) - return; - - // send a list event - wxListEvent le( wxEVT_LIST_KEY_DOWN, parent->GetId() ); - le.m_item.m_itemId = - le.m_itemIndex = m_current; - if (HasCurrent()) - GetLine(m_current)->GetItem( 0, le.m_item ); - le.m_code = event.GetKeyCode(); - le.SetEventObject( parent ); - if (parent->GetEventHandler()->ProcessEvent( le )) - return; - - event.Skip(); -} - -void wxListMainWindow::OnKeyUp( wxKeyEvent &event ) -{ - wxWindow *parent = GetParent(); - - // propagate the key event upwards - wxKeyEvent ke(event); - ke.SetEventObject( parent ); - ke.SetId(GetParent()->GetId()); - if (parent->GetEventHandler()->ProcessEvent( ke )) - return; - - event.Skip(); -} - -void wxListMainWindow::OnCharHook( wxKeyEvent &event ) -{ - if ( m_textctrlWrapper ) - { - // When an in-place editor is active we should ensure that it always - // gets the key events that are special to it. - if ( m_textctrlWrapper->CheckForEndEditKey(event) ) - { - // Skip the call to wxEvent::Skip() below. - return; - } - } - - event.Skip(); -} - -void wxListMainWindow::OnChar( wxKeyEvent &event ) -{ - wxWindow *parent = GetParent(); - - // propagate the char event upwards - wxKeyEvent ke(event); - ke.SetEventObject( parent ); - ke.SetId(GetParent()->GetId()); - if (parent->GetEventHandler()->ProcessEvent( ke )) - return; - - if ( HandleAsNavigationKey(event) ) - return; - - // no item -> nothing to do - if (!HasCurrent()) - { - event.Skip(); - return; - } - - // don't use m_linesPerPage directly as it might not be computed yet - const int pageSize = GetCountPerPage(); - wxCHECK_RET( pageSize, wxT("should have non zero page size") ); - - if (GetLayoutDirection() == wxLayout_RightToLeft) - { - if (event.GetKeyCode() == WXK_RIGHT) - event.m_keyCode = WXK_LEFT; - else if (event.GetKeyCode() == WXK_LEFT) - event.m_keyCode = WXK_RIGHT; - } - - int keyCode = event.GetKeyCode(); - switch ( keyCode ) - { - case WXK_UP: - if ( m_current > 0 ) - OnArrowChar( m_current - 1, event ); - break; - - case WXK_DOWN: - if ( m_current < (size_t)GetItemCount() - 1 ) - OnArrowChar( m_current + 1, event ); - break; - - case WXK_END: - if (!IsEmpty()) - OnArrowChar( GetItemCount() - 1, event ); - break; - - case WXK_HOME: - if (!IsEmpty()) - OnArrowChar( 0, event ); - break; - - case WXK_PAGEUP: - { - int steps = InReportView() ? pageSize - 1 - : m_current % pageSize; - - int index = m_current - steps; - if (index < 0) - index = 0; - - OnArrowChar( index, event ); - } - break; - - case WXK_PAGEDOWN: - { - int steps = InReportView() - ? pageSize - 1 - : pageSize - (m_current % pageSize) - 1; - - size_t index = m_current + steps; - size_t count = GetItemCount(); - if ( index >= count ) - index = count - 1; - - OnArrowChar( index, event ); - } - break; - - case WXK_LEFT: - if ( !InReportView() ) - { - int index = m_current - pageSize; - if (index < 0) - index = 0; - - OnArrowChar( index, event ); - } - break; - - case WXK_RIGHT: - if ( !InReportView() ) - { - size_t index = m_current + pageSize; - - size_t count = GetItemCount(); - if ( index >= count ) - index = count - 1; - - OnArrowChar( index, event ); - } - break; - - case WXK_SPACE: - if ( IsSingleSel() ) - { - if ( event.ControlDown() ) - { - ReverseHighlight(m_current); - } - else // normal space press - { - SendNotify( m_current, wxEVT_LIST_ITEM_ACTIVATED ); - } - } - else // multiple selection - { - ReverseHighlight(m_current); - } - break; - - case WXK_RETURN: - case WXK_EXECUTE: - SendNotify( m_current, wxEVT_LIST_ITEM_ACTIVATED ); - break; - - default: - if ( !event.HasModifiers() && - ((keyCode >= '0' && keyCode <= '9') || - (keyCode >= 'a' && keyCode <= 'z') || - (keyCode >= 'A' && keyCode <= 'Z') || - (keyCode == '_') || - (keyCode == '+') || - (keyCode == '*') || - (keyCode == '-'))) - { - // find the next item starting with the given prefix - wxChar ch = (wxChar)keyCode; - size_t item; - - // if the same character is typed multiple times then go to the - // next entry starting with that character instead of searching - // for an item starting with multiple copies of this character, - // this is more useful and is how it works under Windows. - if ( m_findPrefix.length() == 1 && m_findPrefix[0] == ch ) - { - item = PrefixFindItem(m_current, ch); - } - else - { - const wxString newPrefix(m_findPrefix + ch); - item = PrefixFindItem(m_current, newPrefix); - if ( item != (size_t)-1 ) - m_findPrefix = newPrefix; - } - - // also start the timer to reset the current prefix if the user - // doesn't press any more alnum keys soon -- we wouldn't want - // to use this prefix for a new item search - if ( !m_findTimer ) - { - m_findTimer = new wxListFindTimer( this ); - } - - // Notice that we should start the timer even if we didn't find - // anything to make sure we reset the search state later. - m_findTimer->Start(wxListFindTimer::DELAY, wxTIMER_ONE_SHOT); - - // restart timer even when there's no match so bell get's reset - if ( item != (size_t)-1 ) - { - // Select the found item and go to it. - HighlightAll(false); - SetItemState(item, - wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, - wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED); - - // Reset the bell flag if it had been temporarily disabled - // before. - if ( m_findBell ) - m_findBell = 1; - } - else // No such item - { - // Signal it with a bell if enabled. - if ( m_findBell == 1 ) - { - ::wxBell(); - - // Disable it for the next unsuccessful match, we only - // beep once, this is usually enough and continuing to - // do it would be annoying. - m_findBell = -1; - } - } - } - else - { - event.Skip(); - } - } -} - -// ---------------------------------------------------------------------------- -// focus handling -// ---------------------------------------------------------------------------- - -void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) -{ - if ( GetParent() ) - { - wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() ); - event.SetEventObject( GetParent() ); - if ( GetParent()->GetEventHandler()->ProcessEvent( event) ) - return; - } - - // wxGTK sends us EVT_SET_FOCUS events even if we had never got - // EVT_KILL_FOCUS before which means that we finish by redrawing the items - // which are already drawn correctly resulting in horrible flicker - avoid - // it - if ( !m_hasFocus ) - { - m_hasFocus = true; - - RefreshSelected(); - } -} - -void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) -{ - if ( GetParent() ) - { - wxFocusEvent event( wxEVT_KILL_FOCUS, GetParent()->GetId() ); - event.SetEventObject( GetParent() ); - if ( GetParent()->GetEventHandler()->ProcessEvent( event) ) - return; - } - - m_hasFocus = false; - RefreshSelected(); -} - -void wxListMainWindow::DrawImage( int index, wxDC *dc, int x, int y ) -{ - if ( HasFlag(wxLC_ICON) && (m_normal_image_list)) - { - m_normal_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); - } - else if ( HasFlag(wxLC_SMALL_ICON) && (m_small_image_list)) - { - m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); - } - else if ( HasFlag(wxLC_LIST) && (m_small_image_list)) - { - m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); - } - else if ( InReportView() && (m_small_image_list)) - { - m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); - } -} - -void wxListMainWindow::GetImageSize( int index, int &width, int &height ) const -{ - if ( HasFlag(wxLC_ICON) && m_normal_image_list ) - { - m_normal_image_list->GetSize( index, width, height ); - } - else if ( HasFlag(wxLC_SMALL_ICON) && m_small_image_list ) - { - m_small_image_list->GetSize( index, width, height ); - } - else if ( HasFlag(wxLC_LIST) && m_small_image_list ) - { - m_small_image_list->GetSize( index, width, height ); - } - else if ( InReportView() && m_small_image_list ) - { - m_small_image_list->GetSize( index, width, height ); - } - else - { - width = - height = 0; - } -} - -void wxListMainWindow::SetImageList( wxImageList *imageList, int which ) -{ - m_dirty = true; - - // calc the spacing from the icon size - int width = 0, height = 0; - - if ((imageList) && (imageList->GetImageCount()) ) - imageList->GetSize(0, width, height); - - if (which == wxIMAGE_LIST_NORMAL) - { - m_normal_image_list = imageList; - m_normal_spacing = width + 8; - } - - if (which == wxIMAGE_LIST_SMALL) - { - m_small_image_list = imageList; - m_small_spacing = width + 14; - m_lineHeight = 0; // ensure that the line height will be recalc'd - } -} - -void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall ) -{ - m_dirty = true; - if (isSmall) - m_small_spacing = spacing; - else - m_normal_spacing = spacing; -} - -int wxListMainWindow::GetItemSpacing( bool isSmall ) -{ - return isSmall ? m_small_spacing : m_normal_spacing; -} - -// ---------------------------------------------------------------------------- -// columns -// ---------------------------------------------------------------------------- - -int -wxListMainWindow::ComputeMinHeaderWidth(const wxListHeaderData* column) const -{ - wxClientDC dc(const_cast(this)); - - int width = dc.GetTextExtent(column->GetText()).x + AUTOSIZE_COL_MARGIN; - - width += 2*EXTRA_WIDTH; - - // check for column header's image availability - const int image = column->GetImage(); - if ( image != -1 ) - { - if ( m_small_image_list ) - { - int ix = 0, iy = 0; - m_small_image_list->GetSize(image, ix, iy); - width += ix + HEADER_IMAGE_MARGIN_IN_REPORT_MODE; - } - } - - return width; -} - -void wxListMainWindow::SetColumn( int col, const wxListItem &item ) -{ - wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); - - wxCHECK_RET( node, wxT("invalid column index in SetColumn") ); - - wxListHeaderData *column = node->GetData(); - column->SetItem( item ); - - if ( item.m_width == wxLIST_AUTOSIZE_USEHEADER ) - column->SetWidth(ComputeMinHeaderWidth(column)); - - wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin; - if ( headerWin ) - headerWin->m_dirty = true; - - m_dirty = true; - - // invalidate it as it has to be recalculated - m_headerWidth = 0; -} - -void wxListMainWindow::SetColumnWidth( int col, int width ) -{ - wxCHECK_RET( col >= 0 && col < GetColumnCount(), - wxT("invalid column index") ); - - wxCHECK_RET( InReportView(), - wxT("SetColumnWidth() can only be called in report mode.") ); - - m_dirty = true; - - wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin; - if ( headerWin ) - headerWin->m_dirty = true; - - wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); - wxCHECK_RET( node, wxT("no column?") ); - - wxListHeaderData *column = node->GetData(); - - size_t count = GetItemCount(); - - if (width == wxLIST_AUTOSIZE_USEHEADER) - { - width = ComputeMinHeaderWidth(column); - } - else if ( width == wxLIST_AUTOSIZE ) - { - width = ComputeMinHeaderWidth(column); - - if ( !IsVirtual() ) - { - wxClientDC dc(this); - dc.SetFont( GetFont() ); - - int max = AUTOSIZE_COL_MARGIN; - - // if the cached column width isn't valid then recalculate it - if (m_aColWidths.Item(col)->bNeedsUpdate) - { - for (size_t i = 0; i < count; i++) - { - wxListLineData *line = GetLine( i ); - wxListItemDataList::compatibility_iterator n = line->m_items.Item( col ); - - wxCHECK_RET( n, wxT("no subitem?") ); - - wxListItemData *itemData = n->GetData(); - wxListItem item; - - itemData->GetItem(item); - int itemWidth = GetItemWidthWithImage(&item); - if (itemWidth > max) - max = itemWidth; - } - - m_aColWidths.Item(col)->bNeedsUpdate = false; - m_aColWidths.Item(col)->nMaxWidth = max; - } - - max = m_aColWidths.Item(col)->nMaxWidth + AUTOSIZE_COL_MARGIN; - if ( width < max ) - width = max; - } - } - - column->SetWidth( width ); - - // invalidate it as it has to be recalculated - m_headerWidth = 0; -} - -int wxListMainWindow::GetHeaderWidth() const -{ - if ( !m_headerWidth ) - { - wxListMainWindow *self = wxConstCast(this, wxListMainWindow); - - size_t count = GetColumnCount(); - for ( size_t col = 0; col < count; col++ ) - { - self->m_headerWidth += GetColumnWidth(col); - } - } - - return m_headerWidth; -} - -void wxListMainWindow::GetColumn( int col, wxListItem &item ) const -{ - wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); - wxCHECK_RET( node, wxT("invalid column index in GetColumn") ); - - wxListHeaderData *column = node->GetData(); - column->GetItem( item ); -} - -int wxListMainWindow::GetColumnWidth( int col ) const -{ - wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); - wxCHECK_MSG( node, 0, wxT("invalid column index") ); - - wxListHeaderData *column = node->GetData(); - return column->GetWidth(); -} - -// ---------------------------------------------------------------------------- -// item state -// ---------------------------------------------------------------------------- - -void wxListMainWindow::SetItem( wxListItem &item ) -{ - long id = item.m_itemId; - wxCHECK_RET( id >= 0 && (size_t)id < GetItemCount(), - wxT("invalid item index in SetItem") ); - - if ( !IsVirtual() ) - { - wxListLineData *line = GetLine((size_t)id); - line->SetItem( item.m_col, item ); - - // Set item state if user wants - if ( item.m_mask & wxLIST_MASK_STATE ) - SetItemState( item.m_itemId, item.m_state, item.m_state ); - - if (InReportView()) - { - // update the Max Width Cache if needed - int width = GetItemWidthWithImage(&item); - - if (width > m_aColWidths.Item(item.m_col)->nMaxWidth) - m_aColWidths.Item(item.m_col)->nMaxWidth = width; - } - } - - // update the item on screen unless we're going to update everything soon - // anyhow - if ( !m_dirty ) - { - wxRect rectItem; - GetItemRect(id, rectItem); - RefreshRect(rectItem); - } -} - -void wxListMainWindow::SetItemStateAll(long state, long stateMask) -{ - if ( IsEmpty() ) - return; - - // first deal with selection - if ( stateMask & wxLIST_STATE_SELECTED ) - { - // set/clear select state - if ( IsVirtual() ) - { - // optimized version for virtual listctrl. - m_selStore.SelectRange(0, GetItemCount() - 1, state == wxLIST_STATE_SELECTED); - Refresh(); - } - else if ( state & wxLIST_STATE_SELECTED ) - { - const long count = GetItemCount(); - for( long i = 0; i < count; i++ ) - { - SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - } - - } - else - { - // clear for non virtual (somewhat optimized by using GetNextItem()) - long i = -1; - while ( (i = GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1 ) - { - SetItemState( i, 0, wxLIST_STATE_SELECTED ); - } - } - } - - if ( HasCurrent() && (state == 0) && (stateMask & wxLIST_STATE_FOCUSED) ) - { - // unfocus all: only one item can be focussed, so clearing focus for - // all items is simply clearing focus of the focussed item. - SetItemState(m_current, state, stateMask); - } - //(setting focus to all items makes no sense, so it is not handled here.) -} - -void wxListMainWindow::SetItemState( long litem, long state, long stateMask ) -{ - if ( litem == -1 ) - { - SetItemStateAll(state, stateMask); - return; - } - - wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(), - wxT("invalid list ctrl item index in SetItem") ); - - size_t oldCurrent = m_current; - size_t item = (size_t)litem; // safe because of the check above - - // do we need to change the focus? - if ( stateMask & wxLIST_STATE_FOCUSED ) - { - if ( state & wxLIST_STATE_FOCUSED ) - { - // don't do anything if this item is already focused - if ( item != m_current ) - { - ChangeCurrent(item); - - if ( oldCurrent != (size_t)-1 ) - { - if ( IsSingleSel() ) - { - HighlightLine(oldCurrent, false); - } - - RefreshLine(oldCurrent); - } - - RefreshLine( m_current ); - } - } - else // unfocus - { - // don't do anything if this item is not focused - if ( item == m_current ) - { - ResetCurrent(); - - if ( IsSingleSel() ) - { - // we must unselect the old current item as well or we - // might end up with more than one selected item in a - // single selection control - HighlightLine(oldCurrent, false); - } - - RefreshLine( oldCurrent ); - } - } - } - - // do we need to change the selection state? - if ( stateMask & wxLIST_STATE_SELECTED ) - { - bool on = (state & wxLIST_STATE_SELECTED) != 0; - - if ( IsSingleSel() ) - { - if ( on ) - { - // selecting the item also makes it the focused one in the - // single sel mode - if ( m_current != item ) - { - ChangeCurrent(item); - - if ( oldCurrent != (size_t)-1 ) - { - HighlightLine( oldCurrent, false ); - RefreshLine( oldCurrent ); - } - } - } - else // off - { - // only the current item may be selected anyhow - if ( item != m_current ) - return; - } - } - - if ( HighlightLine(item, on) ) - { - RefreshLine(item); - } - } -} - -int wxListMainWindow::GetItemState( long item, long stateMask ) const -{ - wxCHECK_MSG( item >= 0 && (size_t)item < GetItemCount(), 0, - wxT("invalid list ctrl item index in GetItemState()") ); - - int ret = wxLIST_STATE_DONTCARE; - - if ( stateMask & wxLIST_STATE_FOCUSED ) - { - if ( (size_t)item == m_current ) - ret |= wxLIST_STATE_FOCUSED; - } - - if ( stateMask & wxLIST_STATE_SELECTED ) - { - if ( IsHighlighted(item) ) - ret |= wxLIST_STATE_SELECTED; - } - - return ret; -} - -void wxListMainWindow::GetItem( wxListItem &item ) const -{ - wxCHECK_RET( item.m_itemId >= 0 && (size_t)item.m_itemId < GetItemCount(), - wxT("invalid item index in GetItem") ); - - wxListLineData *line = GetLine((size_t)item.m_itemId); - line->GetItem( item.m_col, item ); - - // Get item state if user wants it - if ( item.m_mask & wxLIST_MASK_STATE ) - item.m_state = GetItemState( item.m_itemId, wxLIST_STATE_SELECTED | - wxLIST_STATE_FOCUSED ); -} - -// ---------------------------------------------------------------------------- -// item count -// ---------------------------------------------------------------------------- - -size_t wxListMainWindow::GetItemCount() const -{ - return IsVirtual() ? m_countVirt : m_lines.GetCount(); -} - -void wxListMainWindow::SetItemCount(long count) -{ - // Update the current item if it's not valid any longer (notice that this - // invalidates it completely if the control is becoming empty, which is the - // right thing to do). - if ( HasCurrent() && m_current >= (size_t)count ) - ChangeCurrent(count - 1); - - m_selStore.SetItemCount(count); - m_countVirt = count; - - ResetVisibleLinesRange(); - - // scrollbars must be reset - m_dirty = true; -} - -int wxListMainWindow::GetSelectedItemCount() const -{ - // deal with the quick case first - if ( IsSingleSel() ) - return HasCurrent() ? IsHighlighted(m_current) : false; - - // virtual controls remmebers all its selections itself - if ( IsVirtual() ) - return m_selStore.GetSelectedCount(); - - // TODO: we probably should maintain the number of items selected even for - // non virtual controls as enumerating all lines is really slow... - size_t countSel = 0; - size_t count = GetItemCount(); - for ( size_t line = 0; line < count; line++ ) - { - if ( GetLine(line)->IsHighlighted() ) - countSel++; - } - - return countSel; -} - -// ---------------------------------------------------------------------------- -// item position/size -// ---------------------------------------------------------------------------- - -wxRect wxListMainWindow::GetViewRect() const -{ - wxASSERT_MSG( !HasFlag(wxLC_LIST), "not implemented for list view" ); - - // we need to find the longest/tallest label - wxCoord xMax = 0, yMax = 0; - const int count = GetItemCount(); - if ( count ) - { - for ( int i = 0; i < count; i++ ) - { - // we need logical, not physical, coordinates here, so use - // GetLineRect() instead of GetItemRect() - wxRect r = GetLineRect(i); - - wxCoord x = r.GetRight(), - y = r.GetBottom(); - - if ( x > xMax ) - xMax = x; - if ( y > yMax ) - yMax = y; - } - } - - // some fudge needed to make it look prettier - xMax += 2 * EXTRA_BORDER_X; - yMax += 2 * EXTRA_BORDER_Y; - - // account for the scrollbars if necessary - const wxSize sizeAll = GetClientSize(); - if ( xMax > sizeAll.x ) - yMax += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); - if ( yMax > sizeAll.y ) - xMax += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - - return wxRect(0, 0, xMax, yMax); -} - -bool -wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect) const -{ - wxCHECK_MSG( subItem == wxLIST_GETSUBITEMRECT_WHOLEITEM || InReportView(), - false, - wxT("GetSubItemRect only meaningful in report view") ); - wxCHECK_MSG( item >= 0 && (size_t)item < GetItemCount(), false, - wxT("invalid item in GetSubItemRect") ); - - // ensure that we're laid out, otherwise we could return nonsense - if ( m_dirty ) - { - wxConstCast(this, wxListMainWindow)-> - RecalculatePositions(true /* no refresh */); - } - - rect = GetLineRect((size_t)item); - - // Adjust rect to specified column - if ( subItem != wxLIST_GETSUBITEMRECT_WHOLEITEM ) - { - wxCHECK_MSG( subItem >= 0 && subItem < GetColumnCount(), false, - wxT("invalid subItem in GetSubItemRect") ); - - for (int i = 0; i < subItem; i++) - { - rect.x += GetColumnWidth(i); - } - rect.width = GetColumnWidth(subItem); - } - - GetListCtrl()->CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y); - - return true; -} - -bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) const -{ - wxRect rect; - GetItemRect(item, rect); - - pos.x = rect.x; - pos.y = rect.y; - - return true; -} - -// ---------------------------------------------------------------------------- -// geometry calculation -// ---------------------------------------------------------------------------- - -void wxListMainWindow::RecalculatePositions(bool noRefresh) -{ - const int lineHeight = GetLineHeight(); - - wxClientDC dc( this ); - dc.SetFont( GetFont() ); - - const size_t count = GetItemCount(); - - int iconSpacing; - if ( HasFlag(wxLC_ICON) && m_normal_image_list ) - iconSpacing = m_normal_spacing; - else if ( HasFlag(wxLC_SMALL_ICON) && m_small_image_list ) - iconSpacing = m_small_spacing; - else - iconSpacing = 0; - - // Note that we do not call GetClientSize() here but - // GetSize() and subtract the border size for sunken - // borders manually. This is technically incorrect, - // but we need to know the client area's size WITHOUT - // scrollbars here. Since we don't know if there are - // any scrollbars, we use GetSize() instead. Another - // solution would be to call SetScrollbars() here to - // remove the scrollbars and call GetClientSize() then, - // but this might result in flicker and - worse - will - // reset the scrollbars to 0 which is not good at all - // if you resize a dialog/window, but don't want to - // reset the window scrolling. RR. - // Furthermore, we actually do NOT subtract the border - // width as 2 pixels is just the extra space which we - // need around the actual content in the window. Other- - // wise the text would e.g. touch the upper border. RR. - int clientWidth, - clientHeight; - GetSize( &clientWidth, &clientHeight ); - - if ( InReportView() ) - { - // all lines have the same height and we scroll one line per step - int entireHeight = count * lineHeight + LINE_SPACING; - - m_linesPerPage = clientHeight / lineHeight; - - ResetVisibleLinesRange(); - - GetListCtrl()->SetScrollbars( SCROLL_UNIT_X, lineHeight, - GetHeaderWidth() / SCROLL_UNIT_X, - (entireHeight + lineHeight - 1) / lineHeight, - GetListCtrl()->GetScrollPos(wxHORIZONTAL), - GetListCtrl()->GetScrollPos(wxVERTICAL), - true ); - } - else // !report - { - // we have 3 different layout strategies: either layout all items - // horizontally/vertically (wxLC_ALIGN_XXX styles explicitly given) or - // to arrange them in top to bottom, left to right (don't ask me why - // not the other way round...) order - if ( HasFlag(wxLC_ALIGN_LEFT | wxLC_ALIGN_TOP) ) - { - int x = EXTRA_BORDER_X; - int y = EXTRA_BORDER_Y; - - wxCoord widthMax = 0; - - size_t i; - for ( i = 0; i < count; i++ ) - { - wxListLineData *line = GetLine(i); - line->CalculateSize( &dc, iconSpacing ); - line->SetPosition( x, y, iconSpacing ); - - wxSize sizeLine = GetLineSize(i); - - if ( HasFlag(wxLC_ALIGN_TOP) ) - { - if ( sizeLine.x > widthMax ) - widthMax = sizeLine.x; - - y += sizeLine.y; - } - else // wxLC_ALIGN_LEFT - { - x += sizeLine.x + MARGIN_BETWEEN_ROWS; - } - } - - if ( HasFlag(wxLC_ALIGN_TOP) ) - { - // traverse the items again and tweak their sizes so that they are - // all the same in a row - for ( i = 0; i < count; i++ ) - { - wxListLineData *line = GetLine(i); - line->m_gi->ExtendWidth(widthMax); - } - } - - GetListCtrl()->SetScrollbars - ( - SCROLL_UNIT_X, - lineHeight, - (x + SCROLL_UNIT_X) / SCROLL_UNIT_X, - (y + lineHeight) / lineHeight, - GetListCtrl()->GetScrollPos( wxHORIZONTAL ), - GetListCtrl()->GetScrollPos( wxVERTICAL ), - true - ); - } - else // "flowed" arrangement, the most complicated case - { - // at first we try without any scrollbars, if the items don't fit into - // the window, we recalculate after subtracting the space taken by the - // scrollbar - - int entireWidth = 0; - - for (int tries = 0; tries < 2; tries++) - { - entireWidth = 2 * EXTRA_BORDER_X; - - if (tries == 1) - { - // Now we have decided that the items do not fit into the - // client area, so we need a scrollbar - entireWidth += SCROLL_UNIT_X; - } - - int x = EXTRA_BORDER_X; - int y = EXTRA_BORDER_Y; - - // Note that "row" here is vertical, i.e. what is called - // "column" in many other places in wxWidgets. - int maxWidthInThisRow = 0; - - m_linesPerPage = 0; - int currentlyVisibleLines = 0; - - for (size_t i = 0; i < count; i++) - { - currentlyVisibleLines++; - wxListLineData *line = GetLine( i ); - line->CalculateSize( &dc, iconSpacing ); - line->SetPosition( x, y, iconSpacing ); - - wxSize sizeLine = GetLineSize( i ); - - if ( maxWidthInThisRow < sizeLine.x ) - maxWidthInThisRow = sizeLine.x; - - y += sizeLine.y; - if (currentlyVisibleLines > m_linesPerPage) - m_linesPerPage = currentlyVisibleLines; - - // Have we reached the end of the row either because no - // more items would fit or because there are simply no more - // items? - if ( y + sizeLine.y >= clientHeight - || i == count - 1) - { - // Adjust all items in this row to have the same - // width to ensure that they all align horizontally in - // icon view. - if ( HasFlag(wxLC_ICON) || HasFlag(wxLC_SMALL_ICON) ) - { - size_t firstRowLine = i - currentlyVisibleLines + 1; - for (size_t j = firstRowLine; j <= i; j++) - { - GetLine(j)->m_gi->ExtendWidth(maxWidthInThisRow); - } - } - - currentlyVisibleLines = 0; - y = EXTRA_BORDER_Y; - maxWidthInThisRow += MARGIN_BETWEEN_ROWS; - x += maxWidthInThisRow; - entireWidth += maxWidthInThisRow; - maxWidthInThisRow = 0; - } - - if ( (tries == 0) && - (entireWidth + SCROLL_UNIT_X > clientWidth) ) - { - clientHeight -= wxSystemSettings:: - GetMetric(wxSYS_HSCROLL_Y); - m_linesPerPage = 0; - break; - } - - if ( i == count - 1 ) - tries = 1; // Everything fits, no second try required. - } - } - - GetListCtrl()->SetScrollbars - ( - SCROLL_UNIT_X, - lineHeight, - (entireWidth + SCROLL_UNIT_X) / SCROLL_UNIT_X, - 0, - GetListCtrl()->GetScrollPos( wxHORIZONTAL ), - 0, - true - ); - } - } - - if ( !noRefresh ) - { - // FIXME: why should we call it from here? - UpdateCurrent(); - - RefreshAll(); - } -} - -void wxListMainWindow::RefreshAll() -{ - m_dirty = false; - Refresh(); - - wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin; - if ( headerWin && headerWin->m_dirty ) - { - headerWin->m_dirty = false; - headerWin->Refresh(); - } -} - -void wxListMainWindow::UpdateCurrent() -{ - if ( !HasCurrent() && !IsEmpty() ) - ChangeCurrent(0); -} - -long wxListMainWindow::GetNextItem( long item, - int WXUNUSED(geometry), - int state ) const -{ - long ret = item, - max = GetItemCount(); - wxCHECK_MSG( (ret == -1) || (ret < max), -1, - wxT("invalid listctrl index in GetNextItem()") ); - - // notice that we start with the next item (or the first one if item == -1) - // and this is intentional to allow writing a simple loop to iterate over - // all selected items - ret++; - if ( ret == max ) - // this is not an error because the index was OK initially, - // just no such item - return -1; - - if ( !state ) - // any will do - return (size_t)ret; - - size_t count = GetItemCount(); - for ( size_t line = (size_t)ret; line < count; line++ ) - { - if ( (state & wxLIST_STATE_FOCUSED) && (line == m_current) ) - return line; - - if ( (state & wxLIST_STATE_SELECTED) && IsHighlighted(line) ) - return line; - } - - return -1; -} - -// ---------------------------------------------------------------------------- -// deleting stuff -// ---------------------------------------------------------------------------- - -void wxListMainWindow::DeleteItem( long lindex ) -{ - size_t count = GetItemCount(); - - wxCHECK_RET( (lindex >= 0) && ((size_t)lindex < count), - wxT("invalid item index in DeleteItem") ); - - size_t index = (size_t)lindex; - - // we don't need to adjust the index for the previous items - if ( HasCurrent() && m_current >= index ) - { - // if the current item is being deleted, we want the next one to - // become selected - unless there is no next one - so don't adjust - // m_current in this case - if ( m_current != index || m_current == count - 1 ) - m_current--; - } - - if ( InReportView() ) - { - // mark the Column Max Width cache as dirty if the items in the line - // we're deleting contain the Max Column Width - wxListLineData * const line = GetLine(index); - wxListItemDataList::compatibility_iterator n; - wxListItemData *itemData; - wxListItem item; - int itemWidth; - - for (size_t i = 0; i < m_columns.GetCount(); i++) - { - n = line->m_items.Item( i ); - itemData = n->GetData(); - itemData->GetItem(item); - - itemWidth = GetItemWidthWithImage(&item); - - if (itemWidth >= m_aColWidths.Item(i)->nMaxWidth) - m_aColWidths.Item(i)->bNeedsUpdate = true; - } - - ResetVisibleLinesRange(); - } - - SendNotify( index, wxEVT_LIST_DELETE_ITEM, wxDefaultPosition ); - - if ( IsVirtual() ) - { - m_countVirt--; - m_selStore.OnItemDelete(index); - } - else - { - m_lines.RemoveAt( index ); - } - - // we need to refresh the (vert) scrollbar as the number of items changed - m_dirty = true; - - RefreshAfter(index); -} - -void wxListMainWindow::DeleteColumn( int col ) -{ - wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); - - wxCHECK_RET( node, wxT("invalid column index in DeleteColumn()") ); - - m_dirty = true; - delete node->GetData(); - m_columns.Erase( node ); - - if ( !IsVirtual() ) - { - // update all the items - for ( size_t i = 0; i < m_lines.GetCount(); i++ ) - { - wxListLineData * const line = GetLine(i); - - // In the following atypical but possible scenario it can be - // legal to call DeleteColumn() but the items may not have any - // values for it: - // 1. In report view, insert a second column. - // 2. Still in report view, add an item with 2 values. - // 3. Switch to an icon (or list) view. - // 4. Add an item -- necessarily with 1 value only. - // 5. Switch back to report view. - // 6. Call DeleteColumn(). - // So we need to check for this as otherwise we would simply crash - // if this happens. - if ( line->m_items.GetCount() <= static_cast(col) ) - continue; - - wxListItemDataList::compatibility_iterator n = line->m_items.Item( col ); - delete n->GetData(); - line->m_items.Erase(n); - } - } - - if ( InReportView() ) // we only cache max widths when in Report View - { - delete m_aColWidths.Item(col); - m_aColWidths.RemoveAt(col); - } - - // invalidate it as it has to be recalculated - m_headerWidth = 0; -} - -void wxListMainWindow::DoDeleteAllItems() -{ - if ( IsEmpty() ) - // nothing to do - in particular, don't send the event - return; - - ResetCurrent(); - - // to make the deletion of all items faster, we don't send the - // notifications for each item deletion in this case but only one event - // for all of them: this is compatible with wxMSW and documented in - // DeleteAllItems() description - - wxListEvent event( wxEVT_LIST_DELETE_ALL_ITEMS, GetParent()->GetId() ); - event.SetEventObject( GetParent() ); - GetParent()->GetEventHandler()->ProcessEvent( event ); - - if ( IsVirtual() ) - { - m_countVirt = 0; - m_selStore.Clear(); - } - - if ( InReportView() ) - { - ResetVisibleLinesRange(); - for (size_t i = 0; i < m_aColWidths.GetCount(); i++) - { - m_aColWidths.Item(i)->bNeedsUpdate = true; - } - } - - m_lines.Clear(); -} - -void wxListMainWindow::DeleteAllItems() -{ - DoDeleteAllItems(); - - RecalculatePositions(); -} - -void wxListMainWindow::DeleteEverything() -{ - WX_CLEAR_LIST(wxListHeaderDataList, m_columns); - WX_CLEAR_ARRAY(m_aColWidths); - - DeleteAllItems(); -} - -// ---------------------------------------------------------------------------- -// scanning for an item -// ---------------------------------------------------------------------------- - -void wxListMainWindow::EnsureVisible( long index ) -{ - wxCHECK_RET( index >= 0 && (size_t)index < GetItemCount(), - wxT("invalid index in EnsureVisible") ); - - // We have to call this here because the label in question might just have - // been added and its position is not known yet - if ( m_dirty ) - RecalculatePositions(true /* no refresh */); - - MoveToItem((size_t)index); -} - -long wxListMainWindow::FindItem(long start, const wxString& str, bool partial ) -{ - if (str.empty()) - return wxNOT_FOUND; - - long pos = start; - wxString str_upper = str.Upper(); - if (pos < 0) - pos = 0; - - size_t count = GetItemCount(); - for ( size_t i = (size_t)pos; i < count; i++ ) - { - wxListLineData *line = GetLine(i); - wxString line_upper = line->GetText(0).Upper(); - if (!partial) - { - if (line_upper == str_upper ) - return i; - } - else - { - if (line_upper.find(str_upper) == 0) - return i; - } - } - - return wxNOT_FOUND; -} - -long wxListMainWindow::FindItem(long start, wxUIntPtr data) -{ - long pos = start; - if (pos < 0) - pos = 0; - - size_t count = GetItemCount(); - for (size_t i = (size_t)pos; i < count; i++) - { - wxListLineData *line = GetLine(i); - wxListItem item; - line->GetItem( 0, item ); - if (item.m_data == data) - return i; - } - - return wxNOT_FOUND; -} - -long wxListMainWindow::FindItem( const wxPoint& pt ) -{ - size_t topItem; - GetVisibleLinesRange( &topItem, NULL ); - - wxPoint p; - GetItemPosition( GetItemCount() - 1, p ); - if ( p.y == 0 ) - return topItem; - - long id = (long)floor( pt.y * double(GetItemCount() - topItem - 1) / p.y + topItem ); - if ( id >= 0 && id < (long)GetItemCount() ) - return id; - - return wxNOT_FOUND; -} - -long wxListMainWindow::HitTest( int x, int y, int &flags ) const -{ - GetListCtrl()->CalcUnscrolledPosition( x, y, &x, &y ); - - size_t count = GetItemCount(); - - if ( InReportView() ) - { - size_t current = y / GetLineHeight(); - if ( current < count ) - { - flags = HitTestLine(current, x, y); - if ( flags ) - return current; - } - } - else // !report - { - // TODO: optimize it too! this is less simple than for report view but - // enumerating all items is still not a way to do it!! - for ( size_t current = 0; current < count; current++ ) - { - flags = HitTestLine(current, x, y); - if ( flags ) - return current; - } - } - - return wxNOT_FOUND; -} - -// ---------------------------------------------------------------------------- -// adding stuff -// ---------------------------------------------------------------------------- - -void wxListMainWindow::InsertItem( wxListItem &item ) -{ - wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual control") ); - - int count = GetItemCount(); - wxCHECK_RET( item.m_itemId >= 0, wxT("invalid item index") ); - - if (item.m_itemId > count) - item.m_itemId = count; - - size_t id = item.m_itemId; - - m_dirty = true; - - if ( InReportView() ) - { - ResetVisibleLinesRange(); - - const unsigned col = item.GetColumn(); - wxCHECK_RET( col < m_aColWidths.size(), "invalid item column" ); - - // calculate the width of the item and adjust the max column width - wxColWidthInfo *pWidthInfo = m_aColWidths.Item(col); - int width = GetItemWidthWithImage(&item); - item.SetWidth(width); - if (width > pWidthInfo->nMaxWidth) - pWidthInfo->nMaxWidth = width; - } - - wxListLineData *line = new wxListLineData(this); - - line->SetItem( item.m_col, item ); - if ( item.m_mask & wxLIST_MASK_IMAGE ) - { - // Reset the buffered height if it's not big enough for the new image. - int image = item.GetImage(); - if ( m_small_image_list && image != -1 && InReportView() ) - { - int imageWidth, imageHeight; - m_small_image_list->GetSize(image, imageWidth, imageHeight); - - if ( imageHeight > m_lineHeight ) - m_lineHeight = 0; - } - } - - m_lines.Insert( line, id ); - - m_dirty = true; - - // If an item is selected at or below the point of insertion, we need to - // increment the member variables because the current row's index has gone - // up by one - if ( HasCurrent() && m_current >= id ) - m_current++; - - SendNotify(id, wxEVT_LIST_INSERT_ITEM); - - RefreshLines(id, GetItemCount() - 1); -} - -long wxListMainWindow::InsertColumn( long col, const wxListItem &item ) -{ - long idx = -1; - - m_dirty = true; - if ( InReportView() ) - { - wxListHeaderData *column = new wxListHeaderData( item ); - if (item.m_width == wxLIST_AUTOSIZE_USEHEADER) - column->SetWidth(ComputeMinHeaderWidth(column)); - - wxColWidthInfo *colWidthInfo = new wxColWidthInfo(); - - bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount()); - if ( insert ) - { - wxListHeaderDataList::compatibility_iterator - node = m_columns.Item( col ); - m_columns.Insert( node, column ); - m_aColWidths.Insert( colWidthInfo, col ); - idx = col; - } - else - { - idx = m_aColWidths.GetCount(); - m_columns.Append( column ); - m_aColWidths.Add( colWidthInfo ); - } - - if ( !IsVirtual() ) - { - // update all the items - for ( size_t i = 0; i < m_lines.GetCount(); i++ ) - { - wxListLineData * const line = GetLine(i); - wxListItemData * const data = new wxListItemData(this); - if ( insert ) - line->m_items.Insert(col, data); - else - line->m_items.Append(data); - } - } - - // invalidate it as it has to be recalculated - m_headerWidth = 0; - } - return idx; -} - -int wxListMainWindow::GetItemWidthWithImage(wxListItem * item) -{ - int width = 0; - wxClientDC dc(this); - - dc.SetFont( GetFont() ); - - if (item->GetImage() != -1) - { - int ix, iy; - GetImageSize( item->GetImage(), ix, iy ); - width += ix + 5; - } - - if (!item->GetText().empty()) - { - wxCoord w; - dc.GetTextExtent( item->GetText(), &w, NULL ); - width += w; - } - - return width; -} - -// ---------------------------------------------------------------------------- -// sorting -// ---------------------------------------------------------------------------- - -static wxListCtrlCompare list_ctrl_compare_func_2; -static wxIntPtr list_ctrl_compare_data; - -int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData **arg2 ) -{ - wxListLineData *line1 = *arg1; - wxListLineData *line2 = *arg2; - wxListItem item; - line1->GetItem( 0, item ); - wxUIntPtr data1 = item.m_data; - line2->GetItem( 0, item ); - wxUIntPtr data2 = item.m_data; - return list_ctrl_compare_func_2( data1, data2, list_ctrl_compare_data ); -} - -void wxListMainWindow::SortItems( wxListCtrlCompare fn, wxIntPtr data ) -{ - // selections won't make sense any more after sorting the items so reset - // them - HighlightAll(false); - ResetCurrent(); - - list_ctrl_compare_func_2 = fn; - list_ctrl_compare_data = data; - m_lines.Sort( list_ctrl_compare_func_1 ); - m_dirty = true; -} - -// ---------------------------------------------------------------------------- -// scrolling -// ---------------------------------------------------------------------------- - -void wxListMainWindow::OnScroll(wxScrollWinEvent& event) -{ - // update our idea of which lines are shown when we redraw the window the - // next time - ResetVisibleLinesRange(); - - if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() ) - { - wxGenericListCtrl* lc = GetListCtrl(); - wxCHECK_RET( lc, wxT("no listctrl window?") ); - - if (lc->m_headerWin) // when we use wxLC_NO_HEADER, m_headerWin==NULL - { - lc->m_headerWin->Refresh(); - lc->m_headerWin->Update(); - } - } -} - -int wxListMainWindow::GetCountPerPage() const -{ - if ( !m_linesPerPage ) - { - wxConstCast(this, wxListMainWindow)-> - m_linesPerPage = GetClientSize().y / GetLineHeight(); - } - - return m_linesPerPage; -} - -void wxListMainWindow::GetVisibleLinesRange(size_t *from, size_t *to) -{ - wxASSERT_MSG( InReportView(), wxT("this is for report mode only") ); - - if ( m_lineFrom == (size_t)-1 ) - { - size_t count = GetItemCount(); - if ( count ) - { - m_lineFrom = GetListCtrl()->GetScrollPos(wxVERTICAL); - - // this may happen if SetScrollbars() hadn't been called yet - if ( m_lineFrom >= count ) - m_lineFrom = count - 1; - - // we redraw one extra line but this is needed to make the redrawing - // logic work when there is a fractional number of lines on screen - m_lineTo = m_lineFrom + m_linesPerPage; - if ( m_lineTo >= count ) - m_lineTo = count - 1; - } - else // empty control - { - m_lineFrom = 0; - m_lineTo = (size_t)-1; - } - } - - wxASSERT_MSG( IsEmpty() || - (m_lineFrom <= m_lineTo && m_lineTo < GetItemCount()), - wxT("GetVisibleLinesRange() returns incorrect result") ); - - if ( from ) - *from = m_lineFrom; - if ( to ) - *to = m_lineTo; -} - -size_t -wxListMainWindow::PrefixFindItem(size_t idParent, - const wxString& prefixOrig) const -{ - // if no items then just return - if ( idParent == (size_t)-1 ) - return idParent; - - // match is case insensitive as this is more convenient to the user: having - // to press Shift-letter to go to the item starting with a capital letter - // would be too bothersome - wxString prefix = prefixOrig.Lower(); - - // determine the starting point: we shouldn't take the current item (this - // allows to switch between two items starting with the same letter just by - // pressing it) but we shouldn't jump to the next one if the user is - // continuing to type as otherwise he might easily skip the item he wanted - size_t itemid = idParent; - if ( prefix.length() == 1 ) - { - itemid += 1; - } - - // look for the item starting with the given prefix after it - while ( ( itemid < (size_t)GetItemCount() ) && - !GetLine(itemid)->GetText(0).Lower().StartsWith(prefix) ) - { - itemid += 1; - } - - // if we haven't found anything... - if ( !( itemid < (size_t)GetItemCount() ) ) - { - // ... wrap to the beginning - itemid = 0; - - // and try all the items (stop when we get to the one we started from) - while ( ( itemid < (size_t)GetItemCount() ) && itemid != idParent && - !GetLine(itemid)->GetText(0).Lower().StartsWith(prefix) ) - { - itemid += 1; - } - // If we haven't found the item, id will be (size_t)-1, as per - // documentation - if ( !( itemid < (size_t)GetItemCount() ) || - ( ( itemid == idParent ) && - !GetLine(itemid)->GetText(0).Lower().StartsWith(prefix) ) ) - { - itemid = (size_t)-1; - } - } - - return itemid; -} - -// ------------------------------------------------------------------------------------- -// wxGenericListCtrl -// ------------------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericListCtrl, wxControl) - -BEGIN_EVENT_TABLE(wxGenericListCtrl,wxListCtrlBase) - EVT_SIZE(wxGenericListCtrl::OnSize) - EVT_SCROLLWIN(wxGenericListCtrl::OnScroll) -END_EVENT_TABLE() - -void wxGenericListCtrl::Init() -{ - m_imageListNormal = NULL; - m_imageListSmall = NULL; - m_imageListState = NULL; - - m_ownsImageListNormal = - m_ownsImageListSmall = - m_ownsImageListState = false; - - m_mainWin = NULL; - m_headerWin = NULL; -} - -wxGenericListCtrl::~wxGenericListCtrl() -{ - if (m_ownsImageListNormal) - delete m_imageListNormal; - if (m_ownsImageListSmall) - delete m_imageListSmall; - if (m_ownsImageListState) - delete m_imageListState; -} - -void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded() -{ - bool needs_header = HasHeader(); - bool has_header = (m_headerWin != NULL); - - if (needs_header == has_header) - return; - - if (needs_header) - { - // Notice that we must initialize m_headerWin first, and create the - // real window only later, so that the test in the beginning of the - // function blocks repeated creation of the header as it could happen - // before via wxNavigationEnabled::AddChild() -> ToggleWindowStyle() -> - // SetWindowStyleFlag(). - m_headerWin = new wxListHeaderWindow(); - m_headerWin->Create - ( - this, wxID_ANY, m_mainWin, - wxPoint(0,0), - wxSize - ( - GetClientSize().x, - wxRendererNative::Get().GetHeaderButtonHeight(this) - ), - wxTAB_TRAVERSAL - ); - -#if defined( __WXMAC__ ) - static wxFont font( wxOSX_SYSTEM_FONT_SMALL ); - m_headerWin->SetFont( font ); -#endif - - GetSizer()->Prepend( m_headerWin, 0, wxGROW ); - } - else - { - GetSizer()->Detach( m_headerWin ); - - wxDELETE(m_headerWin); - } -} - -bool wxGenericListCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxPoint &pos, - const wxSize &size, - long style, - const wxValidator &validator, - const wxString &name) -{ - Init(); - - // just like in other ports, an assert will fail if the user doesn't give any type style: - wxASSERT_MSG( (style & wxLC_MASK_TYPE), - wxT("wxListCtrl style should have exactly one mode bit set") ); - - if ( !wxListCtrlBase::Create( parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL, - validator, name ) ) - return false; - - m_mainWin = new wxListMainWindow(this, wxID_ANY, wxPoint(0, 0), size); - - SetTargetWindow( m_mainWin ); - - // We use the cursor keys for moving the selection, not scrolling, so call - // this method to ensure wxScrollHelperEvtHandler doesn't catch all - // keyboard events forwarded to us from wxListMainWindow. - DisableKeyboardScrolling(); - - wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); - sizer->Add( m_mainWin, 1, wxGROW ); - SetSizer( sizer ); - - CreateOrDestroyHeaderWindowAsNeeded(); - - SetInitialSize(size); - - return true; -} - -wxBorder wxGenericListCtrl::GetDefaultBorder() const -{ - return wxBORDER_THEME; -} - -#if defined(__WXMSW__) && !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__) -WXLRESULT wxGenericListCtrl::MSWWindowProc(WXUINT nMsg, - WXWPARAM wParam, - WXLPARAM lParam) -{ - WXLRESULT rc = wxListCtrlBase::MSWWindowProc(nMsg, wParam, lParam); - - // we need to process arrows ourselves for scrolling - if ( nMsg == WM_GETDLGCODE ) - { - rc |= DLGC_WANTARROWS; - } - - return rc; -} -#endif // __WXMSW__ - -wxSize wxGenericListCtrl::GetSizeAvailableForScrollTarget(const wxSize& size) -{ - wxSize newsize = size; - if (m_headerWin) - newsize.y -= m_headerWin->GetSize().y; - - return newsize; -} - -void wxGenericListCtrl::OnScroll(wxScrollWinEvent& event) -{ - // update our idea of which lines are shown when we redraw - // the window the next time - m_mainWin->ResetVisibleLinesRange(); - - if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() ) - { - m_headerWin->Refresh(); - m_headerWin->Update(); - } - - // Let the window be scrolled as usual by the default handler. - event.Skip(); -} - -void wxGenericListCtrl::SetSingleStyle( long style, bool add ) -{ - wxASSERT_MSG( !(style & wxLC_VIRTUAL), - wxT("wxLC_VIRTUAL can't be [un]set") ); - - long flag = GetWindowStyle(); - - if (add) - { - if (style & wxLC_MASK_TYPE) - flag &= ~(wxLC_MASK_TYPE | wxLC_VIRTUAL); - if (style & wxLC_MASK_ALIGN) - flag &= ~wxLC_MASK_ALIGN; - if (style & wxLC_MASK_SORT) - flag &= ~wxLC_MASK_SORT; - } - - if (add) - flag |= style; - else - flag &= ~style; - - // some styles can be set without recreating everything (as happens in - // SetWindowStyleFlag() which calls wxListMainWindow::DeleteEverything()) - if ( !(style & ~(wxLC_HRULES | wxLC_VRULES)) ) - { - Refresh(); - wxWindow::SetWindowStyleFlag(flag); - } - else - { - SetWindowStyleFlag( flag ); - } -} - -void wxGenericListCtrl::SetWindowStyleFlag( long flag ) -{ - // we add wxHSCROLL and wxVSCROLL in ctor unconditionally and it never - // makes sense to remove them as we'll always add scrollbars anyhow when - // needed - flag |= wxHSCROLL | wxVSCROLL; - - const bool wasInReportView = HasFlag(wxLC_REPORT); - - // update the window style first so that the header is created or destroyed - // corresponding to the new style - wxWindow::SetWindowStyleFlag( flag ); - - if (m_mainWin) - { - const bool inReportView = (flag & wxLC_REPORT) != 0; - if ( inReportView != wasInReportView ) - { - // we need to notify the main window about this change as it must - // update its data structures - m_mainWin->SetReportView(inReportView); - } - - // m_mainWin->DeleteEverything(); wxMSW doesn't do that - - CreateOrDestroyHeaderWindowAsNeeded(); - - GetSizer()->Layout(); - } -} - -bool wxGenericListCtrl::GetColumn(int col, wxListItem &item) const -{ - m_mainWin->GetColumn( col, item ); - return true; -} - -bool wxGenericListCtrl::SetColumn( int col, const wxListItem& item ) -{ - m_mainWin->SetColumn( col, item ); - return true; -} - -int wxGenericListCtrl::GetColumnWidth( int col ) const -{ - return m_mainWin->GetColumnWidth( col ); -} - -bool wxGenericListCtrl::SetColumnWidth( int col, int width ) -{ - m_mainWin->SetColumnWidth( col, width ); - return true; -} - -int wxGenericListCtrl::GetCountPerPage() const -{ - return m_mainWin->GetCountPerPage(); // different from Windows ? -} - -bool wxGenericListCtrl::GetItem( wxListItem &info ) const -{ - m_mainWin->GetItem( info ); - return true; -} - -bool wxGenericListCtrl::SetItem( wxListItem &info ) -{ - m_mainWin->SetItem( info ); - return true; -} - -long wxGenericListCtrl::SetItem( long index, int col, const wxString& label, int imageId ) -{ - wxListItem info; - info.m_text = label; - info.m_mask = wxLIST_MASK_TEXT; - info.m_itemId = index; - info.m_col = col; - if ( imageId > -1 ) - { - info.m_image = imageId; - info.m_mask |= wxLIST_MASK_IMAGE; - } - - m_mainWin->SetItem(info); - return true; -} - -int wxGenericListCtrl::GetItemState( long item, long stateMask ) const -{ - return m_mainWin->GetItemState( item, stateMask ); -} - -bool wxGenericListCtrl::SetItemState( long item, long state, long stateMask ) -{ - m_mainWin->SetItemState( item, state, stateMask ); - return true; -} - -bool -wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) ) -{ - return SetItemColumnImage(item, 0, image); -} - -bool -wxGenericListCtrl::SetItemColumnImage( long item, long column, int image ) -{ - wxListItem info; - info.m_image = image; - info.m_mask = wxLIST_MASK_IMAGE; - info.m_itemId = item; - info.m_col = column; - m_mainWin->SetItem( info ); - return true; -} - -wxString wxGenericListCtrl::GetItemText( long item, int col ) const -{ - return m_mainWin->GetItemText(item, col); -} - -void wxGenericListCtrl::SetItemText( long item, const wxString& str ) -{ - m_mainWin->SetItemText(item, str); -} - -wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const -{ - wxListItem info; - info.m_mask = wxLIST_MASK_DATA; - info.m_itemId = item; - m_mainWin->GetItem( info ); - return info.m_data; -} - -bool wxGenericListCtrl::SetItemPtrData( long item, wxUIntPtr data ) -{ - wxListItem info; - info.m_mask = wxLIST_MASK_DATA; - info.m_itemId = item; - info.m_data = data; - m_mainWin->SetItem( info ); - return true; -} - -wxRect wxGenericListCtrl::GetViewRect() const -{ - return m_mainWin->GetViewRect(); -} - -bool wxGenericListCtrl::GetItemRect(long item, wxRect& rect, int code) const -{ - return GetSubItemRect(item, wxLIST_GETSUBITEMRECT_WHOLEITEM, rect, code); -} - -bool wxGenericListCtrl::GetSubItemRect(long item, - long subItem, - wxRect& rect, - int WXUNUSED(code)) const -{ - if ( !m_mainWin->GetSubItemRect( item, subItem, rect ) ) - return false; - - if ( m_mainWin->HasHeader() ) - rect.y += m_headerWin->GetSize().y + 1; - - return true; -} - -bool wxGenericListCtrl::GetItemPosition( long item, wxPoint& pos ) const -{ - m_mainWin->GetItemPosition( item, pos ); - return true; -} - -bool wxGenericListCtrl::SetItemPosition( long WXUNUSED(item), const wxPoint& WXUNUSED(pos) ) -{ - return false; -} - -int wxGenericListCtrl::GetItemCount() const -{ - return m_mainWin->GetItemCount(); -} - -int wxGenericListCtrl::GetColumnCount() const -{ - return m_mainWin->GetColumnCount(); -} - -void wxGenericListCtrl::SetItemSpacing( int spacing, bool isSmall ) -{ - m_mainWin->SetItemSpacing( spacing, isSmall ); -} - -wxSize wxGenericListCtrl::GetItemSpacing() const -{ - const int spacing = m_mainWin->GetItemSpacing(HasFlag(wxLC_SMALL_ICON)); - - return wxSize(spacing, spacing); -} - -#if WXWIN_COMPATIBILITY_2_6 -int wxGenericListCtrl::GetItemSpacing( bool isSmall ) const -{ - return m_mainWin->GetItemSpacing( isSmall ); -} -#endif // WXWIN_COMPATIBILITY_2_6 - -void wxGenericListCtrl::SetItemTextColour( long item, const wxColour &col ) -{ - wxListItem info; - info.m_itemId = item; - info.SetTextColour( col ); - m_mainWin->SetItem( info ); -} - -wxColour wxGenericListCtrl::GetItemTextColour( long item ) const -{ - wxListItem info; - info.m_itemId = item; - m_mainWin->GetItem( info ); - return info.GetTextColour(); -} - -void wxGenericListCtrl::SetItemBackgroundColour( long item, const wxColour &col ) -{ - wxListItem info; - info.m_itemId = item; - info.SetBackgroundColour( col ); - m_mainWin->SetItem( info ); -} - -wxColour wxGenericListCtrl::GetItemBackgroundColour( long item ) const -{ - wxListItem info; - info.m_itemId = item; - m_mainWin->GetItem( info ); - return info.GetBackgroundColour(); -} - -void wxGenericListCtrl::SetItemFont( long item, const wxFont &f ) -{ - wxListItem info; - info.m_itemId = item; - info.SetFont( f ); - m_mainWin->SetItem( info ); -} - -wxFont wxGenericListCtrl::GetItemFont( long item ) const -{ - wxListItem info; - info.m_itemId = item; - m_mainWin->GetItem( info ); - return info.GetFont(); -} - -int wxGenericListCtrl::GetSelectedItemCount() const -{ - return m_mainWin->GetSelectedItemCount(); -} - -wxColour wxGenericListCtrl::GetTextColour() const -{ - return GetForegroundColour(); -} - -void wxGenericListCtrl::SetTextColour(const wxColour& col) -{ - SetForegroundColour(col); -} - -long wxGenericListCtrl::GetTopItem() const -{ - size_t top; - m_mainWin->GetVisibleLinesRange(&top, NULL); - return (long)top; -} - -long wxGenericListCtrl::GetNextItem( long item, int geom, int state ) const -{ - return m_mainWin->GetNextItem( item, geom, state ); -} - -wxImageList *wxGenericListCtrl::GetImageList(int which) const -{ - if (which == wxIMAGE_LIST_NORMAL) - return m_imageListNormal; - else if (which == wxIMAGE_LIST_SMALL) - return m_imageListSmall; - else if (which == wxIMAGE_LIST_STATE) - return m_imageListState; - - return NULL; -} - -void wxGenericListCtrl::SetImageList( wxImageList *imageList, int which ) -{ - if ( which == wxIMAGE_LIST_NORMAL ) - { - if (m_ownsImageListNormal) - delete m_imageListNormal; - m_imageListNormal = imageList; - m_ownsImageListNormal = false; - } - else if ( which == wxIMAGE_LIST_SMALL ) - { - if (m_ownsImageListSmall) - delete m_imageListSmall; - m_imageListSmall = imageList; - m_ownsImageListSmall = false; - } - else if ( which == wxIMAGE_LIST_STATE ) - { - if (m_ownsImageListState) - delete m_imageListState; - m_imageListState = imageList; - m_ownsImageListState = false; - } - - m_mainWin->SetImageList( imageList, which ); -} - -void wxGenericListCtrl::AssignImageList(wxImageList *imageList, int which) -{ - SetImageList(imageList, which); - if ( which == wxIMAGE_LIST_NORMAL ) - m_ownsImageListNormal = true; - else if ( which == wxIMAGE_LIST_SMALL ) - m_ownsImageListSmall = true; - else if ( which == wxIMAGE_LIST_STATE ) - m_ownsImageListState = true; -} - -bool wxGenericListCtrl::Arrange( int WXUNUSED(flag) ) -{ - return 0; -} - -bool wxGenericListCtrl::DeleteItem( long item ) -{ - m_mainWin->DeleteItem( item ); - return true; -} - -bool wxGenericListCtrl::DeleteAllItems() -{ - m_mainWin->DeleteAllItems(); - return true; -} - -bool wxGenericListCtrl::DeleteAllColumns() -{ - size_t count = m_mainWin->m_columns.GetCount(); - for ( size_t n = 0; n < count; n++ ) - DeleteColumn( 0 ); - return true; -} - -void wxGenericListCtrl::ClearAll() -{ - m_mainWin->DeleteEverything(); -} - -bool wxGenericListCtrl::DeleteColumn( int col ) -{ - m_mainWin->DeleteColumn( col ); - - // if we don't have the header any longer, we need to relayout the window - // if ( !GetColumnCount() ) - - - // Ensure that the non-existent columns are really removed from display. - Refresh(); - - return true; -} - -wxTextCtrl *wxGenericListCtrl::EditLabel(long item, - wxClassInfo* textControlClass) -{ - return m_mainWin->EditLabel( item, textControlClass ); -} - -#if wxABI_VERSION >= 30002 -bool wxGenericListCtrl::EndEditLabel(bool cancel) -{ - return m_mainWin->EndEditLabel(cancel); -} -#endif - -wxTextCtrl *wxGenericListCtrl::GetEditControl() const -{ - return m_mainWin->GetEditControl(); -} - -bool wxGenericListCtrl::EnsureVisible( long item ) -{ - m_mainWin->EnsureVisible( item ); - return true; -} - -long wxGenericListCtrl::FindItem( long start, const wxString& str, bool partial ) -{ - return m_mainWin->FindItem( start, str, partial ); -} - -long wxGenericListCtrl::FindItem( long start, wxUIntPtr data ) -{ - return m_mainWin->FindItem( start, data ); -} - -long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& pt, - int WXUNUSED(direction)) -{ - return m_mainWin->FindItem( pt ); -} - -// TODO: sub item hit testing -long wxGenericListCtrl::HitTest(const wxPoint& point, int& flags, long *) const -{ - return m_mainWin->HitTest( (int)point.x, (int)point.y, flags ); -} - -long wxGenericListCtrl::InsertItem( wxListItem& info ) -{ - m_mainWin->InsertItem( info ); - return info.m_itemId; -} - -long wxGenericListCtrl::InsertItem( long index, const wxString &label ) -{ - wxListItem info; - info.m_text = label; - info.m_mask = wxLIST_MASK_TEXT; - info.m_itemId = index; - return InsertItem( info ); -} - -long wxGenericListCtrl::InsertItem( long index, int imageIndex ) -{ - wxListItem info; - info.m_mask = wxLIST_MASK_IMAGE; - info.m_image = imageIndex; - info.m_itemId = index; - return InsertItem( info ); -} - -long wxGenericListCtrl::InsertItem( long index, const wxString &label, int imageIndex ) -{ - wxListItem info; - info.m_text = label; - info.m_image = imageIndex; - info.m_mask = wxLIST_MASK_TEXT; - if (imageIndex > -1) - info.m_mask |= wxLIST_MASK_IMAGE; - info.m_itemId = index; - return InsertItem( info ); -} - -long wxGenericListCtrl::DoInsertColumn( long col, const wxListItem &item ) -{ - wxCHECK_MSG( InReportView(), -1, wxT("can't add column in non report mode") ); - - long idx = m_mainWin->InsertColumn( col, item ); - - // NOTE: if wxLC_NO_HEADER was given, then we are in report view mode but - // still have m_headerWin==NULL - if (m_headerWin) - m_headerWin->Refresh(); - - return idx; -} - -bool wxGenericListCtrl::ScrollList( int dx, int dy ) -{ - return m_mainWin->ScrollList(dx, dy); -} - -// Sort items. -// fn is a function which takes 3 long arguments: item1, item2, data. -// item1 is the long data associated with a first item (NOT the index). -// item2 is the long data associated with a second item (NOT the index). -// data is the same value as passed to SortItems. -// The return value is a negative number if the first item should precede the second -// item, a positive number of the second item should precede the first, -// or zero if the two items are equivalent. -// data is arbitrary data to be passed to the sort function. - -bool wxGenericListCtrl::SortItems( wxListCtrlCompare fn, wxIntPtr data ) -{ - m_mainWin->SortItems( fn, data ); - return true; -} - -// ---------------------------------------------------------------------------- -// event handlers -// ---------------------------------------------------------------------------- - -void wxGenericListCtrl::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - if (!m_mainWin) return; - - // We need to override OnSize so that our scrolled - // window a) does call Layout() to use sizers for - // positioning the controls but b) does not query - // the sizer for their size and use that for setting - // the scrollable area as set that ourselves by - // calling SetScrollbar() further down. - - Layout(); - - m_mainWin->RecalculatePositions(); - - AdjustScrollbars(); -} - -void wxGenericListCtrl::OnInternalIdle() -{ - wxWindow::OnInternalIdle(); - - if (m_mainWin->m_dirty) - m_mainWin->RecalculatePositions(); -} - -// ---------------------------------------------------------------------------- -// font/colours -// ---------------------------------------------------------------------------- - -bool wxGenericListCtrl::SetBackgroundColour( const wxColour &colour ) -{ - if (m_mainWin) - { - m_mainWin->SetBackgroundColour( colour ); - m_mainWin->m_dirty = true; - } - - return true; -} - -bool wxGenericListCtrl::SetForegroundColour( const wxColour &colour ) -{ - if ( !wxWindow::SetForegroundColour( colour ) ) - return false; - - if (m_mainWin) - { - m_mainWin->SetForegroundColour( colour ); - m_mainWin->m_dirty = true; - } - - return true; -} - -bool wxGenericListCtrl::SetFont( const wxFont &font ) -{ - if ( !wxWindow::SetFont( font ) ) - return false; - - if (m_mainWin) - { - m_mainWin->SetFont( font ); - m_mainWin->m_dirty = true; - } - - if (m_headerWin) - { - m_headerWin->SetFont( font ); - // CalculateAndSetHeaderHeight(); - } - - Refresh(); - - return true; -} - -// static -wxVisualAttributes -wxGenericListCtrl::GetClassDefaultAttributes(wxWindowVariant variant) -{ -#if _USE_VISATTR - // Use the same color scheme as wxListBox - return wxListBox::GetClassDefaultAttributes(variant); -#else - wxUnusedVar(variant); - wxVisualAttributes attr; - attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); - attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); - attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - return attr; -#endif -} - -// ---------------------------------------------------------------------------- -// methods forwarded to m_mainWin -// ---------------------------------------------------------------------------- - -#if wxUSE_DRAG_AND_DROP - -void wxGenericListCtrl::SetDropTarget( wxDropTarget *dropTarget ) -{ - m_mainWin->SetDropTarget( dropTarget ); -} - -wxDropTarget *wxGenericListCtrl::GetDropTarget() const -{ - return m_mainWin->GetDropTarget(); -} - -#endif - -bool wxGenericListCtrl::SetCursor( const wxCursor &cursor ) -{ - return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : false; -} - -wxColour wxGenericListCtrl::GetBackgroundColour() const -{ - return m_mainWin ? m_mainWin->GetBackgroundColour() : wxColour(); -} - -wxColour wxGenericListCtrl::GetForegroundColour() const -{ - return m_mainWin ? m_mainWin->GetForegroundColour() : wxColour(); -} - -bool wxGenericListCtrl::DoPopupMenu( wxMenu *menu, int x, int y ) -{ -#if wxUSE_MENUS - return m_mainWin->PopupMenu( menu, x, y ); -#else - return false; -#endif -} - -wxSize wxGenericListCtrl::DoGetBestClientSize() const -{ - // The base class version can compute the best size in report view only. - wxSize sizeBest = wxListCtrlBase::DoGetBestClientSize(); - - if ( !InReportView() ) - { - // Ensure that our minimal width is at least big enough to show all our - // items. This is important for wxListbook to size itself correctly. - - // Remember the offset of the first item: this corresponds to the - // margins around the item so we will add it to the minimal size below - // to ensure that we have equal margins on all sides. - wxPoint ofs; - - // We can iterate over all items as there shouldn't be too many of them - // in non-report view. If it ever becomes a problem, we could examine - // just the first few items probably, the determination of the best - // size is less important if we will need scrollbars anyhow. - for ( int n = 0; n < GetItemCount(); n++ ) - { - const wxRect itemRect = m_mainWin->GetLineRect(n); - if ( !n ) - { - // Remember the position of the first item as all the rest are - // offset by at least this number of pixels too. - ofs = itemRect.GetPosition(); - } - - sizeBest.IncTo(itemRect.GetSize()); - } - - sizeBest.IncBy(2*ofs); - - - // If we have the scrollbars we need to account for them too. And to - // make sure the scrollbars status is up to date we need to call this - // function to set them. - m_mainWin->RecalculatePositions(true /* no refresh */); - - // Unfortunately we can't use wxWindow::HasScrollbar() here as we need - // to use m_mainWin client/virtual size for determination of whether we - // use scrollbars and not the size of this window itself. Maybe that - // function should be extended to work correctly in the case when our - // scrollbars manage a different window from this one but currently it - // doesn't work. - const wxSize sizeClient = m_mainWin->GetClientSize(); - const wxSize sizeVirt = m_mainWin->GetVirtualSize(); - - if ( sizeVirt.x > sizeClient.x /* HasScrollbar(wxHORIZONTAL) */ ) - sizeBest.y += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); - - if ( sizeVirt.y > sizeClient.y /* HasScrollbar(wxVERTICAL) */ ) - sizeBest.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - } - - return sizeBest; -} - -// ---------------------------------------------------------------------------- -// virtual list control support -// ---------------------------------------------------------------------------- - -wxString wxGenericListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const -{ - // this is a pure virtual function, in fact - which is not really pure - // because the controls which are not virtual don't need to implement it - wxFAIL_MSG( wxT("wxGenericListCtrl::OnGetItemText not supposed to be called") ); - - return wxEmptyString; -} - -int wxGenericListCtrl::OnGetItemImage(long WXUNUSED(item)) const -{ - wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL), - -1, - wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden.")); - return -1; -} - -int wxGenericListCtrl::OnGetItemColumnImage(long item, long column) const -{ - if (!column) - return OnGetItemImage(item); - - return -1; -} - -void wxGenericListCtrl::SetItemCount(long count) -{ - wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") ); - - m_mainWin->SetItemCount(count); -} - -void wxGenericListCtrl::RefreshItem(long item) -{ - m_mainWin->RefreshLine(item); -} - -void wxGenericListCtrl::RefreshItems(long itemFrom, long itemTo) -{ - m_mainWin->RefreshLines(itemFrom, itemTo); -} - -void wxGenericListCtrl::EnableBellOnNoMatch( bool on ) -{ - m_mainWin->EnableBellOnNoMatch(on); -} - -// Generic wxListCtrl is more or less a container for two other -// windows which drawings are done upon. These are namely -// 'm_headerWin' and 'm_mainWin'. -// Here we override 'virtual wxWindow::Refresh()' to mimic the -// behaviour wxListCtrl has under wxMSW. -// -void wxGenericListCtrl::Refresh(bool eraseBackground, const wxRect *rect) -{ - if (!rect) - { - // The easy case, no rectangle specified. - if (m_headerWin) - m_headerWin->Refresh(eraseBackground); - - if (m_mainWin) - m_mainWin->Refresh(eraseBackground); - } - else - { - // Refresh the header window - if (m_headerWin) - { - wxRect rectHeader = m_headerWin->GetRect(); - rectHeader.Intersect(*rect); - if (rectHeader.GetWidth() && rectHeader.GetHeight()) - { - int x, y; - m_headerWin->GetPosition(&x, &y); - rectHeader.Offset(-x, -y); - m_headerWin->Refresh(eraseBackground, &rectHeader); - } - } - - // Refresh the main window - if (m_mainWin) - { - wxRect rectMain = m_mainWin->GetRect(); - rectMain.Intersect(*rect); - if (rectMain.GetWidth() && rectMain.GetHeight()) - { - int x, y; - m_mainWin->GetPosition(&x, &y); - rectMain.Offset(-x, -y); - m_mainWin->Refresh(eraseBackground, &rectMain); - } - } - } -} - -void wxGenericListCtrl::Update() -{ - if ( m_mainWin ) - { - if ( m_mainWin->m_dirty ) - m_mainWin->RecalculatePositions(); - - m_mainWin->Update(); - } - - if ( m_headerWin ) - m_headerWin->Update(); -} - -#endif // wxUSE_LISTCTRL diff --git a/Source/3rd Party/wx/src/generic/logg.cpp b/Source/3rd Party/wx/src/generic/logg.cpp index b54a9daf6..e370dc4ea 100644 --- a/Source/3rd Party/wx/src/generic/logg.cpp +++ b/Source/3rd Party/wx/src/generic/logg.cpp @@ -5,6 +5,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.09.99 (extracted from src/common/log.cpp) +// RCS-ID: $Id: logg.cpp 43078 2006-11-04 23:46:02Z VZ $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,27 +38,20 @@ #include "wx/sizer.h" #include "wx/statbmp.h" #include "wx/settings.h" - #include "wx/wxcrtvararg.h" #endif // WX_PRECOMP #if wxUSE_LOGGUI || wxUSE_LOGWINDOW #include "wx/file.h" -#include "wx/clipbrd.h" -#include "wx/dataobj.h" #include "wx/textfile.h" #include "wx/statline.h" #include "wx/artprov.h" -#include "wx/collpane.h" -#include "wx/arrstr.h" -#include "wx/msgout.h" #ifdef __WXMSW__ // for OutputDebugString() #include "wx/msw/private.h" #endif // Windows - #ifdef __WXPM__ #include #endif @@ -68,12 +62,14 @@ #include "wx/image.h" #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG -#include "wx/time.h" +#if defined(__MWERKS__) && wxUSE_UNICODE + #include +#endif + +#include "wx/datetime.h" // the suffix we add to the button to show that the dialog can be expanded -#define EXPAND_SUFFIX wxT(" >>") - -#define CAN_SAVE_FILES (wxUSE_FILE && wxUSE_FILEDLG) +#define EXPAND_SUFFIX _T(" >>") // ---------------------------------------------------------------------------- // private classes @@ -83,16 +79,20 @@ // this function is a wrapper around strftime(3) // allows to exclude the usage of wxDateTime -static wxString TimeStamp(const wxString& format, time_t t) +static wxString TimeStamp(const wxChar *format, time_t t) { +#if wxUSE_DATETIME wxChar buf[4096]; struct tm tm; if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) ) { // buffer is too small? - wxFAIL_MSG(wxT("strftime() failed")); + wxFAIL_MSG(_T("strftime() failed")); } return wxString(buf); +#else // !wxUSE_DATETIME + return wxEmptyString; +#endif // wxUSE_DATETIME/!wxUSE_DATETIME } @@ -109,67 +109,53 @@ public: // event handlers void OnOk(wxCommandEvent& event); -#if wxUSE_CLIPBOARD - void OnCopy(wxCommandEvent& event); -#endif // wxUSE_CLIPBOARD -#if CAN_SAVE_FILES + void OnDetails(wxCommandEvent& event); +#if wxUSE_FILE void OnSave(wxCommandEvent& event); -#endif // CAN_SAVE_FILES - void OnListItemActivated(wxListEvent& event); +#endif // wxUSE_FILE + void OnListSelect(wxListEvent& event); private: // create controls needed for the details display - void CreateDetailsControls(wxWindow *); - - // if necessary truncates the given string and adds an ellipsis - wxString EllipsizeString(const wxString &text) - { - if (ms_maxLength > 0 && - text.length() > ms_maxLength) - { - wxString ret(text); - ret.Truncate(ms_maxLength); - ret << "..."; - return ret; - } - - return text; - } - -#if CAN_SAVE_FILES || wxUSE_CLIPBOARD - // return the contents of the dialog as a multiline string - wxString GetLogMessages() const; -#endif // CAN_SAVE_FILES || wxUSE_CLIPBOARD - + void CreateDetailsControls(); // the data for the listctrl wxArrayString m_messages; wxArrayInt m_severity; wxArrayLong m_times; + // the "toggle" button and its state +#ifndef __SMARTPHONE__ + wxButton *m_btnDetails; +#endif + bool m_showingDetails; + // the controls which are not shown initially (but only when details // button is pressed) wxListCtrl *m_listctrl; +#ifndef __SMARTPHONE__ +#if wxUSE_STATLINE + wxStaticLine *m_statline; +#endif // wxUSE_STATLINE +#if wxUSE_FILE + wxButton *m_btnSave; +#endif // wxUSE_FILE +#endif // __SMARTPHONE__ // the translated "Details" string static wxString ms_details; - // the maximum length of the log message - static size_t ms_maxLength; - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxLogDialog); + DECLARE_NO_COPY_CLASS(wxLogDialog) }; BEGIN_EVENT_TABLE(wxLogDialog, wxDialog) EVT_BUTTON(wxID_OK, wxLogDialog::OnOk) -#if wxUSE_CLIPBOARD - EVT_BUTTON(wxID_COPY, wxLogDialog::OnCopy) -#endif // wxUSE_CLIPBOARD -#if CAN_SAVE_FILES + EVT_BUTTON(wxID_MORE, wxLogDialog::OnDetails) +#if wxUSE_FILE EVT_BUTTON(wxID_SAVE, wxLogDialog::OnSave) -#endif // CAN_SAVE_FILES - EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxLogDialog::OnListItemActivated) +#endif // wxUSE_FILE + EVT_LIST_ITEM_SELECTED(wxID_ANY, wxLogDialog::OnListSelect) END_EVENT_TABLE() #endif // wxUSE_LOG_DIALOG @@ -178,7 +164,7 @@ END_EVENT_TABLE() // private functions // ---------------------------------------------------------------------------- -#if CAN_SAVE_FILES +#if wxUSE_FILE && wxUSE_FILEDLG // pass an uninitialized file object, the function will ask the user for the // filename and try to open it, returns true on success (file was opened), @@ -186,12 +172,53 @@ END_EVENT_TABLE() // dialog was cancelled static int OpenLogFile(wxFile& file, wxString *filename = NULL, wxWindow *parent = NULL); -#endif // CAN_SAVE_FILES +#endif // wxUSE_FILE + +// ---------------------------------------------------------------------------- +// global variables +// ---------------------------------------------------------------------------- + +// we use a global variable to store the frame pointer for wxLogStatus - bad, +// but it's the easiest way +static wxFrame *gs_pFrame = NULL; // FIXME MT-unsafe // ============================================================================ // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// global functions +// ---------------------------------------------------------------------------- + +// accepts an additional argument which tells to which frame the output should +// be directed +void wxVLogStatus(wxFrame *pFrame, const wxChar *szFormat, va_list argptr) +{ + wxString msg; + + wxLog *pLog = wxLog::GetActiveTarget(); + if ( pLog != NULL ) { + msg.PrintfV(szFormat, argptr); + + wxASSERT( gs_pFrame == NULL ); // should be reset! + gs_pFrame = pFrame; +#ifdef __WXWINCE__ + wxLog::OnLog(wxLOG_Status, msg, 0); +#else + wxLog::OnLog(wxLOG_Status, msg, time(NULL)); +#endif + gs_pFrame = (wxFrame *) NULL; + } +} + +void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogStatus(pFrame, szFormat, argptr); + va_end(argptr); +} + // ---------------------------------------------------------------------------- // wxLogGui implementation (FIXME MT-unsafe) // ---------------------------------------------------------------------------- @@ -214,124 +241,95 @@ void wxLogGui::Clear() m_aTimes.Empty(); } -int wxLogGui::GetSeverityIcon() const -{ - return m_bErrors ? wxICON_STOP - : m_bWarnings ? wxICON_EXCLAMATION - : wxICON_INFORMATION; -} - -wxString wxLogGui::GetTitle() const -{ - wxString titleFormat; - switch ( GetSeverityIcon() ) - { - case wxICON_STOP: - titleFormat = _("%s Error"); - break; - - case wxICON_EXCLAMATION: - titleFormat = _("%s Warning"); - break; - - default: - wxFAIL_MSG( "unexpected icon severity" ); - // fall through - - case wxICON_INFORMATION: - titleFormat = _("%s Information"); - } - - return wxString::Format(titleFormat, wxTheApp->GetAppDisplayName()); -} - -void -wxLogGui::DoShowSingleLogMessage(const wxString& message, - const wxString& title, - int style) -{ - wxMessageBox(message, title, wxOK | style); -} - -void -wxLogGui::DoShowMultipleLogMessages(const wxArrayString& messages, - const wxArrayInt& severities, - const wxArrayLong& times, - const wxString& title, - int style) -{ -#if wxUSE_LOG_DIALOG - wxLogDialog dlg(NULL, - messages, severities, times, - title, style); - - // clear the message list before showing the dialog because while it's - // shown some new messages may appear - Clear(); - - (void)dlg.ShowModal(); -#else // !wxUSE_LOG_DIALOG - // start from the most recent message - wxString message; - const size_t nMsgCount = messages.size(); - message.reserve(nMsgCount*100); - for ( size_t n = nMsgCount; n > 0; n-- ) { - message << m_aMessages[n - 1] << wxT("\n"); - } - - DoShowSingleLogMessage(message, title, style); -#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG -} - void wxLogGui::Flush() { - wxLog::Flush(); - if ( !m_bHasMessages ) return; // do it right now to block any new calls to Flush() while we're here m_bHasMessages = false; - // note that this must be done before examining m_aMessages as it may log - // yet another message - const unsigned repeatCount = LogLastRepeatIfNeeded(); - - const size_t nMsgCount = m_aMessages.size(); - - if ( repeatCount > 0 ) + unsigned repeatCount = 0; + if ( wxLog::GetRepetitionCounting() ) { - m_aMessages[nMsgCount - 1] << " (" << m_aMessages[nMsgCount - 2] << ")"; + repeatCount = wxLog::DoLogNumberOfRepeats(); } - const wxString title = GetTitle(); - const int style = GetSeverityIcon(); + wxString appName = wxTheApp->GetAppName(); + if ( !appName.empty() ) + appName[0u] = (wxChar)wxToupper(appName[0u]); + + long style; + wxString titleFormat; + if ( m_bErrors ) { + titleFormat = _("%s Error"); + style = wxICON_STOP; + } + else if ( m_bWarnings ) { + titleFormat = _("%s Warning"); + style = wxICON_EXCLAMATION; + } + else { + titleFormat = _("%s Information"); + style = wxICON_INFORMATION; + } + + wxString title; + title.Printf(titleFormat, appName.c_str()); + + size_t nMsgCount = m_aMessages.Count(); // avoid showing other log dialogs until we're done with the dialog we're // showing right now: nested modal dialogs make for really bad UI! Suspend(); + wxString str; if ( nMsgCount == 1 ) { - // make a copy before calling Clear() - const wxString message(m_aMessages[0]); - Clear(); - - DoShowSingleLogMessage(message, title, style); + str = m_aMessages[0]; } else // more than one message { - wxArrayString messages; - wxArrayInt severities; - wxArrayLong times; +#if wxUSE_LOG_DIALOG - messages.swap(m_aMessages); - severities.swap(m_aSeverity); - times.swap(m_aTimes); + if ( repeatCount > 0 ) + m_aMessages[nMsgCount-1] += wxString::Format(wxT(" (%s)"), m_aMessages[nMsgCount-2].c_str()); + wxLogDialog dlg(NULL, + m_aMessages, m_aSeverity, m_aTimes, + title, style); + // clear the message list before showing the dialog because while it's + // shown some new messages may appear Clear(); - DoShowMultipleLogMessages(messages, severities, times, title, style); + (void)dlg.ShowModal(); +#else // !wxUSE_LOG_DIALOG + // concatenate all strings (but not too many to not overfill the msg box) + size_t nLines = 0; + + // start from the most recent message + for ( size_t n = nMsgCount; n > 0; n-- ) { + // for Windows strings longer than this value are wrapped (NT 4.0) + const size_t nMsgLineWidth = 156; + + nLines += (m_aMessages[n - 1].Len() + nMsgLineWidth - 1) / nMsgLineWidth; + + if ( nLines > 25 ) // don't put too many lines in message box + break; + + str << m_aMessages[n - 1] << wxT("\n"); + } +#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG + } + + // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any + // situation without it + if ( !str.empty() ) + { + wxMessageBox(str, title, wxOK | style); + + // no undisplayed messages whatsoever + Clear(); } // allow flushing the logs again @@ -339,19 +337,16 @@ void wxLogGui::Flush() } // log all kinds of messages -void wxLogGui::DoLogRecord(wxLogLevel level, - const wxString& msg, - const wxLogRecordInfo& info) +void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { - switch ( level ) - { + switch ( level ) { case wxLOG_Info: if ( GetVerbose() ) case wxLOG_Message: { - m_aMessages.Add(msg); + m_aMessages.Add(szString); m_aSeverity.Add(wxLOG_Message); - m_aTimes.Add((long)info.timestamp); + m_aTimes.Add((long)t); m_bHasMessages = true; } break; @@ -359,29 +354,53 @@ void wxLogGui::DoLogRecord(wxLogLevel level, case wxLOG_Status: #if wxUSE_STATUSBAR { - wxFrame *pFrame = NULL; - - // check if the frame was passed to us explicitly - wxUIntPtr ptr = 0; - if ( info.GetNumValue(wxLOG_KEY_FRAME, &ptr) ) - { - pFrame = static_cast(wxUIntToPtr(ptr)); - } - // find the top window and set it's status text if it has any + wxFrame *pFrame = gs_pFrame; if ( pFrame == NULL ) { wxWindow *pWin = wxTheApp->GetTopWindow(); - if ( wxDynamicCast(pWin, wxFrame) ) { + if ( pWin != NULL && pWin->IsKindOf(CLASSINFO(wxFrame)) ) { pFrame = (wxFrame *)pWin; } } if ( pFrame && pFrame->GetStatusBar() ) - pFrame->SetStatusText(msg); + pFrame->SetStatusText(szString); } #endif // wxUSE_STATUSBAR break; + case wxLOG_Trace: + case wxLOG_Debug: + #ifdef __WXDEBUG__ + { + wxString str; + TimeStamp(&str); + str += szString; + + #if defined(__WXMSW__) && !defined(__WXMICROWIN__) + // don't prepend debug/trace here: it goes to the + // debug window anyhow + str += wxT("\r\n"); + OutputDebugString(str); + #else + // send them to stderr + wxFprintf(stderr, wxT("[%s] %s\n"), + level == wxLOG_Trace ? wxT("Trace") + : wxT("Debug"), + str.c_str()); + fflush(stderr); + #endif + } + #endif // __WXDEBUG__ + + break; + + case wxLOG_FatalError: + // show this one immediately + wxMessageBox(szString, _("Fatal error"), wxICON_HAND); + wxExit(); + break; + case wxLOG_Error: if ( !m_bErrors ) { #if !wxUSE_LOG_DIALOG @@ -402,31 +421,11 @@ void wxLogGui::DoLogRecord(wxLogLevel level, m_bWarnings = true; } - m_aMessages.Add(msg); + m_aMessages.Add(szString); m_aSeverity.Add((int)level); - m_aTimes.Add((long)info.timestamp); + m_aTimes.Add((long)t); m_bHasMessages = true; break; - - case wxLOG_Debug: - case wxLOG_Trace: - // let the base class deal with debug/trace messages - wxLog::DoLogRecord(level, msg, info); - break; - - case wxLOG_FatalError: - case wxLOG_Max: - // fatal errors are shown immediately and terminate the program so - // we should never see them here - wxFAIL_MSG("unexpected log level"); - break; - - case wxLOG_Progress: - case wxLOG_User: - // just ignore those: passing them to the base class would result - // in asserts from DoLogText() because DoLogTextAtLevel() would - // call it as it doesn't know how to handle these levels otherwise - break; } } @@ -444,25 +443,19 @@ class wxLogFrame : public wxFrame { public: // ctor & dtor - wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTitle); + wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxChar *szTitle); virtual ~wxLogFrame(); - // Don't prevent the application from exiting if just this frame remains. - virtual bool ShouldPreventAppExit() const { return false; } - // menu callbacks void OnClose(wxCommandEvent& event); void OnCloseWindow(wxCloseEvent& event); -#if CAN_SAVE_FILES - void OnSave(wxCommandEvent& event); -#endif // CAN_SAVE_FILES +#if wxUSE_FILE + void OnSave (wxCommandEvent& event); +#endif // wxUSE_FILE void OnClear(wxCommandEvent& event); - // do show the message in the text control - void ShowLogMessage(const wxString& message) - { - m_pTextCtrl->AppendText(message + wxS('\n')); - } + // accessors + wxTextCtrl *TextCtrl() const { return m_pTextCtrl; } private: // use standard ids for our commands! @@ -480,21 +473,21 @@ private: wxLogWindow *m_log; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxLogFrame); + DECLARE_NO_COPY_CLASS(wxLogFrame) }; BEGIN_EVENT_TABLE(wxLogFrame, wxFrame) // wxLogWindow menu events EVT_MENU(Menu_Close, wxLogFrame::OnClose) -#if CAN_SAVE_FILES +#if wxUSE_FILE EVT_MENU(Menu_Save, wxLogFrame::OnSave) -#endif // CAN_SAVE_FILES +#endif // wxUSE_FILE EVT_MENU(Menu_Clear, wxLogFrame::OnClear) EVT_CLOSE(wxLogFrame::OnCloseWindow) END_EVENT_TABLE() -wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTitle) +wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxChar *szTitle) : wxFrame(pParent, wxID_ANY, szTitle) { m_log = log; @@ -514,9 +507,9 @@ wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTi // create menu wxMenuBar *pMenuBar = new wxMenuBar; wxMenu *pMenu = new wxMenu; -#if CAN_SAVE_FILES - pMenu->Append(Menu_Save, _("Save &As..."), _("Save log contents to file")); -#endif // CAN_SAVE_FILES +#if wxUSE_FILE + pMenu->Append(Menu_Save, _("&Save..."), _("Save log contents to file")); +#endif // wxUSE_FILE pMenu->Append(Menu_Clear, _("C&lear"), _("Clear the log contents")); pMenu->AppendSeparator(); pMenu->Append(Menu_Close, _("&Close"), _("Close this window")); @@ -528,6 +521,8 @@ wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTi // status bar for menu prompts CreateStatusBar(); #endif // wxUSE_STATUSBAR + + m_log->OnFrameCreate(this); } void wxLogFrame::DoClose() @@ -550,9 +545,10 @@ void wxLogFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) DoClose(); } -#if CAN_SAVE_FILES +#if wxUSE_FILE void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxString filename; wxFile file; int rc = OpenLogFile(file, &filename, this); @@ -579,10 +575,11 @@ void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event)) wxLogError(_("Can't save log contents to file.")); } else { - wxLogStatus((wxFrame*)this, _("Log saved to the file '%s'."), filename.c_str()); + wxLogStatus(this, _("Log saved to the file '%s'."), filename.c_str()); } +#endif } -#endif // CAN_SAVE_FILES +#endif // wxUSE_FILE void wxLogFrame::OnClear(wxCommandEvent& WXUNUSED(event)) { @@ -598,15 +595,10 @@ wxLogFrame::~wxLogFrame() // ----------- wxLogWindow::wxLogWindow(wxWindow *pParent, - const wxString& szTitle, + const wxChar *szTitle, bool bShow, bool bDoPass) { - // Initialize it to NULL to ensure that we don't crash if any log messages - // are generated before the frame is fully created (while this doesn't - // happen normally, it might, in principle). - m_pLogFrame = NULL; - PassMessages(bDoPass); m_pLogFrame = new wxLogFrame(pParent, this, szTitle); @@ -620,20 +612,56 @@ void wxLogWindow::Show(bool bShow) m_pLogFrame->Show(bShow); } -void wxLogWindow::DoLogTextAtLevel(wxLogLevel level, const wxString& msg) +void wxLogWindow::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { - if ( !m_pLogFrame ) - return; + // first let the previous logger show it + wxLogPassThrough::DoLog(level, szString, t); - // don't put trace messages in the text window for 2 reasons: - // 1) there are too many of them - // 2) they may provoke other trace messages (e.g. wxMSW code uses - // wxLogTrace to log Windows messages and adding text to the control - // sends more of them) thus sending a program into an infinite loop - if ( level == wxLOG_Trace ) - return; + if ( m_pLogFrame ) { + switch ( level ) { + case wxLOG_Status: + // by default, these messages are ignored by wxLog, so process + // them ourselves + if ( !wxIsEmpty(szString) ) + { + wxString str; + str << _("Status: ") << szString; + DoLogString(str, t); + } + break; - m_pLogFrame->ShowLogMessage(msg); + // don't put trace messages in the text window for 2 reasons: + // 1) there are too many of them + // 2) they may provoke other trace messages thus sending a program + // into an infinite loop + case wxLOG_Trace: + break; + + default: + // and this will format it nicely and call our DoLogString() + wxLog::DoLog(level, szString, t); + } + } +} + +void wxLogWindow::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) +{ + // put the text into our window + wxTextCtrl *pText = m_pLogFrame->TextCtrl(); + + // remove selection (WriteText is in fact ReplaceSelection) +#ifdef __WXMSW__ + wxTextPos nLen = pText->GetLastPosition(); + pText->SetSelection(nLen, nLen); +#endif // Windows + + wxString msg; + TimeStamp(&msg); + msg << szString << wxT('\n'); + + pText->AppendText(msg); + + // TODO ensure that the line can be seen } wxFrame *wxLogWindow::GetFrame() const @@ -641,6 +669,10 @@ wxFrame *wxLogWindow::GetFrame() const return m_pLogFrame; } +void wxLogWindow::OnFrameCreate(wxFrame * WXUNUSED(frame)) +{ +} + bool wxLogWindow::OnFrameClose(wxFrame * WXUNUSED(frame)) { // allow to close @@ -649,7 +681,7 @@ bool wxLogWindow::OnFrameClose(wxFrame * WXUNUSED(frame)) void wxLogWindow::OnFrameDelete(wxFrame * WXUNUSED(frame)) { - m_pLogFrame = NULL; + m_pLogFrame = (wxLogFrame *)NULL; } wxLogWindow::~wxLogWindow() @@ -666,8 +698,13 @@ wxLogWindow::~wxLogWindow() #if wxUSE_LOG_DIALOG +#ifndef __SMARTPHONE__ +static const size_t MARGIN = 10; +#else +static const size_t MARGIN = 0; +#endif + wxString wxLogDialog::ms_details; -size_t wxLogDialog::ms_maxLength = 0; wxLogDialog::wxLogDialog(wxWindow *parent, const wxArrayString& messages, @@ -679,8 +716,6 @@ wxLogDialog::wxLogDialog(wxWindow *parent, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - // init the static variables: - if ( ms_details.empty() ) { // ensure that we won't loop here if wxGetTranslation() @@ -692,11 +727,6 @@ wxLogDialog::wxLogDialog(wxWindow *parent, #endif } - if ( ms_maxLength == 0 ) - { - ms_maxLength = (2 * wxGetDisplaySize().x/3) / GetCharWidth(); - } - size_t count = messages.GetCount(); m_messages.Alloc(count); m_severity.Alloc(count); @@ -704,89 +734,109 @@ wxLogDialog::wxLogDialog(wxWindow *parent, for ( size_t n = 0; n < count; n++ ) { - m_messages.Add(messages[n]); + wxString msg = messages[n]; + msg.Replace(wxT("\n"), wxT(" ")); + m_messages.Add(msg); m_severity.Add(severity[n]); m_times.Add(times[n]); } - m_listctrl = NULL; + m_showingDetails = false; // not initially + m_listctrl = (wxListCtrl *)NULL; + +#ifndef __SMARTPHONE__ + +#if wxUSE_STATLINE + m_statline = (wxStaticLine *)NULL; +#endif // wxUSE_STATLINE + +#if wxUSE_FILE + m_btnSave = (wxButton *)NULL; +#endif // wxUSE_FILE + +#endif // __SMARTPHONE__ bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); // create the controls which are always shown and layout them: we use - // sizers even though our window is not resizable to calculate the size of + // sizers even though our window is not resizeable to calculate the size of // the dialog properly wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); +#ifndef __SMARTPHONE__ + wxBoxSizer *sizerButtons = new wxBoxSizer(isPda ? wxHORIZONTAL : wxVERTICAL); +#endif wxBoxSizer *sizerAll = new wxBoxSizer(isPda ? wxVERTICAL : wxHORIZONTAL); - if (!isPda) - { - wxStaticBitmap *icon = new wxStaticBitmap - ( - this, - wxID_ANY, - wxArtProvider::GetMessageBoxIcon(style) - ); - sizerAll->Add(icon, wxSizerFlags().Centre()); - } - - // create the text sizer with a minimal size so that we are sure it won't be too small - wxString message = EllipsizeString(messages.Last()); - wxSizer *szText = CreateTextSizer(message); - szText->SetMinSize(wxMin(300, wxGetDisplaySize().x / 3), -1); - - sizerAll->Add(szText, wxSizerFlags(1).Centre().Border(wxLEFT | wxRIGHT)); - - wxButton *btnOk = new wxButton(this, wxID_OK); - sizerAll->Add(btnOk, wxSizerFlags().Centre()); - - sizerTop->Add(sizerAll, wxSizerFlags().Expand().Border()); - - - // add the details pane -#ifndef __SMARTPHONE__ - -#if wxUSE_COLLPANE - wxCollapsiblePane * const - collpane = new wxCollapsiblePane(this, wxID_ANY, ms_details); - sizerTop->Add(collpane, wxSizerFlags(1).Expand().Border()); - - wxWindow *win = collpane->GetPane(); -#else - wxPanel* win = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxBORDER_NONE); -#endif - wxSizer * const paneSz = new wxBoxSizer(wxVERTICAL); - - CreateDetailsControls(win); - - paneSz->Add(m_listctrl, wxSizerFlags(1).Expand().Border(wxTOP)); - -#if wxUSE_CLIPBOARD || CAN_SAVE_FILES - wxBoxSizer * const btnSizer = new wxBoxSizer(wxHORIZONTAL); - - wxSizerFlags flagsBtn; - flagsBtn.Border(wxLEFT); - -#if wxUSE_CLIPBOARD - btnSizer->Add(new wxButton(win, wxID_COPY), flagsBtn); -#endif // wxUSE_CLIPBOARD - -#if CAN_SAVE_FILES - btnSizer->Add(new wxButton(win, wxID_SAVE), flagsBtn); -#endif // CAN_SAVE_FILES - - paneSz->Add(btnSizer, wxSizerFlags().Right().Border(wxTOP|wxBOTTOM)); -#endif // wxUSE_CLIPBOARD || CAN_SAVE_FILES - - win->SetSizer(paneSz); - paneSz->SetSizeHints(win); -#else // __SMARTPHONE__ +#ifdef __SMARTPHONE__ SetLeftMenu(wxID_OK); SetRightMenu(wxID_MORE, ms_details + EXPAND_SUFFIX); -#endif // __SMARTPHONE__/!__SMARTPHONE__ +#else + wxButton *btnOk = new wxButton(this, wxID_OK); + sizerButtons->Add(btnOk, 0, isPda ? wxCENTRE : wxCENTRE|wxBOTTOM, MARGIN/2); + m_btnDetails = new wxButton(this, wxID_MORE, ms_details + EXPAND_SUFFIX); + sizerButtons->Add(m_btnDetails, 0, isPda ? wxCENTRE|wxLEFT : wxCENTRE | wxTOP, MARGIN/2 - 1); +#endif - SetSizerAndFit(sizerTop); + wxBitmap bitmap; + switch ( style & wxICON_MASK ) + { + case wxICON_ERROR: + bitmap = wxArtProvider::GetBitmap(wxART_ERROR, wxART_MESSAGE_BOX); +#ifdef __WXPM__ + bitmap.SetId(wxICON_SMALL_ERROR); +#endif + break; + + case wxICON_INFORMATION: + bitmap = wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MESSAGE_BOX); +#ifdef __WXPM__ + bitmap.SetId(wxICON_SMALL_INFO); +#endif + break; + + case wxICON_WARNING: + bitmap = wxArtProvider::GetBitmap(wxART_WARNING, wxART_MESSAGE_BOX); +#ifdef __WXPM__ + bitmap.SetId(wxICON_SMALL_WARNING); +#endif + break; + + default: + wxFAIL_MSG(_T("incorrect log style")); + } + + if (!isPda) + sizerAll->Add(new wxStaticBitmap(this, wxID_ANY, bitmap), 0, + wxALIGN_CENTRE_VERTICAL); + + const wxString& message = messages.Last(); + sizerAll->Add(CreateTextSizer(message), 1, + wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT, MARGIN); +#ifndef __SMARTPHONE__ + sizerAll->Add(sizerButtons, 0, isPda ? wxCENTRE|wxTOP|wxBOTTOM : (wxALIGN_RIGHT | wxLEFT), MARGIN); +#endif + + sizerTop->Add(sizerAll, 0, wxALL | wxEXPAND, MARGIN); + + SetSizer(sizerTop); + + // see comments in OnDetails() + // + // Note: Doing this, this way, triggered a nasty bug in + // wxTopLevelWindowGTK::GtkOnSize which took -1 literally once + // either of maxWidth or maxHeight was set. This symptom has been + // fixed there, but it is a problem that remains as long as we allow + // unchecked access to the internal size members. We really need to + // encapuslate window sizes more cleanly and make it clear when -1 will + // be substituted and when it will not. + + wxSize size = sizerTop->Fit(this); + m_maxHeight = size.y; + SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight); + +#ifndef __SMARTPHONE__ + btnOk->SetFocus(); +#endif Centre(); @@ -798,37 +848,44 @@ wxLogDialog::wxLogDialog(wxWindow *parent, } } -void wxLogDialog::CreateDetailsControls(wxWindow *parent) +void wxLogDialog::CreateDetailsControls() { - wxString fmt = wxLog::GetTimestamp(); - bool hasTimeStamp = !fmt.IsEmpty(); +#ifndef __SMARTPHONE__ + // create the save button and separator line if possible +#if wxUSE_FILE + m_btnSave = new wxButton(this, wxID_SAVE); +#endif // wxUSE_FILE + +#if wxUSE_STATLINE + m_statline = new wxStaticLine(this, wxID_ANY); +#endif // wxUSE_STATLINE + +#endif // __SMARTPHONE__ // create the list ctrl now - m_listctrl = new wxListCtrl(parent, wxID_ANY, + m_listctrl = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxBORDER_SIMPLE | + wxSUNKEN_BORDER | wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL); #ifdef __WXWINCE__ - // This makes a big aesthetic difference on WinCE but I + // This maks a big aesthetic difference on WinCE but I // don't want to risk problems on other platforms m_listctrl->Hide(); #endif // no need to translate these strings as they're not shown to the // user anyhow (we use wxLC_NO_HEADER style) - m_listctrl->InsertColumn(0, wxT("Message")); - - if (hasTimeStamp) - m_listctrl->InsertColumn(1, wxT("Time")); + m_listctrl->InsertColumn(0, _T("Message")); + m_listctrl->InsertColumn(1, _T("Time")); // prepare the imagelist static const int ICON_SIZE = 16; wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE); // order should be the same as in the switch below! - static const char* const icons[] = + static const wxChar* icons[] = { wxART_ERROR, wxART_WARNING, @@ -844,7 +901,7 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) // This may very well fail if there are insufficient colours available. // Degrade gracefully. - if ( !bmp.IsOk() ) + if ( !bmp.Ok() ) { loadedIcons = false; @@ -856,7 +913,14 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) m_listctrl->SetImageList(imageList, wxIMAGE_LIST_SMALL); - // fill the listctrl + // and fill it + wxString fmt = wxLog::GetTimestamp(); + if ( !fmt ) + { + // default format + fmt = _T("%c"); + } + size_t count = m_messages.GetCount(); for ( size_t n = 0; n < count; n++ ) { @@ -883,20 +947,13 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) image = -1; } - wxString msg = m_messages[n]; - msg.Replace(wxT("\n"), wxT(" ")); - msg = EllipsizeString(msg); - - m_listctrl->InsertItem(n, msg, image); - - if (hasTimeStamp) - m_listctrl->SetItem(n, 1, TimeStamp(fmt, (time_t)m_times[n])); + m_listctrl->InsertItem(n, m_messages[n], image); + m_listctrl->SetItem(n, 1, TimeStamp(fmt, (time_t)m_times[n])); } // let the columns size themselves m_listctrl->SetColumnWidth(0, wxLIST_AUTOSIZE); - if (hasTimeStamp) - m_listctrl->SetColumnWidth(1, wxLIST_AUTOSIZE); + m_listctrl->SetColumnWidth(1, wxLIST_AUTOSIZE); // calculate an approximately nice height for the listctrl int height = GetCharHeight()*(count + 4); @@ -915,21 +972,12 @@ void wxLogDialog::CreateDetailsControls(wxWindow *parent) m_listctrl->SetSize(wxDefaultCoord, wxMin(height, heightMax)); } -void wxLogDialog::OnListItemActivated(wxListEvent& event) +void wxLogDialog::OnListSelect(wxListEvent& event) { - // show the activated item in a message box - // This allow the user to correctly display the logs which are longer - // than the listctrl and thus gets truncated or those which contains - // newlines. - - // NB: don't do: - // wxString str = m_listctrl->GetItemText(event.GetIndex()); - // as there's a 260 chars limit on the items inside a wxListCtrl in wxMSW. - wxString str = m_messages[event.GetIndex()]; - - // wxMessageBox will nicely handle the '\n' in the string (if any) - // and supports long strings - wxMessageBox(str, wxT("Log message"), wxOK, this); + // we can't just disable the control because this looks ugly under Windows + // (wrong bg colour, no scrolling...), but we still want to disable + // selecting items - it makes no sense here + m_listctrl->SetItemState(event.GetIndex(), 0, wxLIST_STATE_SELECTED); } void wxLogDialog::OnOk(wxCommandEvent& WXUNUSED(event)) @@ -937,52 +985,11 @@ void wxLogDialog::OnOk(wxCommandEvent& WXUNUSED(event)) EndModal(wxID_OK); } -#if CAN_SAVE_FILES || wxUSE_CLIPBOARD - -wxString wxLogDialog::GetLogMessages() const -{ - wxString fmt = wxLog::GetTimestamp(); - if ( fmt.empty() ) - { - // use the default format - fmt = "%c"; - } - - const size_t count = m_messages.GetCount(); - - wxString text; - text.reserve(count*m_messages[0].length()); - for ( size_t n = 0; n < count; n++ ) - { - text << TimeStamp(fmt, (time_t)m_times[n]) - << ": " - << m_messages[n] - << wxTextFile::GetEOL(); - } - - return text; -} - -#endif // CAN_SAVE_FILES || wxUSE_CLIPBOARD - -#if wxUSE_CLIPBOARD - -void wxLogDialog::OnCopy(wxCommandEvent& WXUNUSED(event)) -{ - wxClipboardLocker clip; - if ( !clip || - !wxTheClipboard->AddData(new wxTextDataObject(GetLogMessages())) ) - { - wxLogError(_("Failed to copy dialog contents to the clipboard.")); - } -} - -#endif // wxUSE_CLIPBOARD - -#if CAN_SAVE_FILES +#if wxUSE_FILE void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxFile file; int rc = OpenLogFile(file, NULL, this); if ( rc == -1 ) @@ -991,13 +998,141 @@ void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event)) return; } - if ( !rc || !file.Write(GetLogMessages()) || !file.Close() ) + bool ok = rc != 0; + + wxString fmt = wxLog::GetTimestamp(); + if ( !fmt ) { - wxLogError(_("Can't save log contents to file.")); + // default format + fmt = _T("%c"); } + + size_t count = m_messages.GetCount(); + for ( size_t n = 0; ok && (n < count); n++ ) + { + wxString line; + line << TimeStamp(fmt, (time_t)m_times[n]) + << _T(": ") + << m_messages[n] + << wxTextFile::GetEOL(); + + ok = file.Write(line); + } + + if ( ok ) + ok = file.Close(); + + if ( !ok ) + wxLogError(_("Can't save log contents to file.")); +#endif // wxUSE_FILEDLG } -#endif // CAN_SAVE_FILES +#endif // wxUSE_FILE + +void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event)) +{ + wxSizer *sizer = GetSizer(); + + if ( m_showingDetails ) + { +#ifdef __SMARTPHONE__ + SetRightMenu(wxID_MORE, ms_details + EXPAND_SUFFIX); +#else + m_btnDetails->SetLabel(ms_details + EXPAND_SUFFIX); +#endif + + sizer->Detach( m_listctrl ); + +#ifndef __SMARTPHONE__ + +#if wxUSE_STATLINE + sizer->Detach( m_statline ); +#endif // wxUSE_STATLINE + +#if wxUSE_FILE + sizer->Detach( m_btnSave ); +#endif // wxUSE_FILE + +#endif // __SMARTPHONE__ + } + else // show details now + { +#ifdef __SMARTPHONE__ + SetRightMenu(wxID_MORE, wxString(_T("<< ")) + ms_details); +#else + m_btnDetails->SetLabel(wxString(_T("<< ")) + ms_details); +#endif + + if ( !m_listctrl ) + { + CreateDetailsControls(); + } + +#if wxUSE_STATLINE && !defined(__SMARTPHONE__) + bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); + if (!isPda) + sizer->Add(m_statline, 0, wxEXPAND | (wxALL & ~wxTOP), MARGIN); +#endif // wxUSE_STATLINE + + sizer->Add(m_listctrl, 1, wxEXPAND | (wxALL & ~wxTOP), MARGIN); + + // VZ: this doesn't work as this becomes the initial (and not only + // minimal) listctrl height as well - why? +#if 0 + // allow the user to make the dialog shorter than its initial height - + // without this it wouldn't work as the list ctrl would have been + // incompressible + sizer->SetItemMinSize(m_listctrl, 100, 3*GetCharHeight()); +#endif // 0 + +#if wxUSE_FILE && !defined(__SMARTPHONE__) + sizer->Add(m_btnSave, 0, wxALIGN_RIGHT | (wxALL & ~wxTOP), MARGIN); +#endif // wxUSE_FILE + } + + m_showingDetails = !m_showingDetails; + + // in any case, our size changed - relayout everything and set new hints + // --------------------------------------------------------------------- + + // we have to reset min size constraints or Fit() would never reduce the + // dialog size when collapsing it and we have to reset max constraint + // because it wouldn't expand it otherwise + + m_minHeight = + m_maxHeight = -1; + + // wxSizer::FitSize() is private, otherwise we might use it directly... + wxSize sizeTotal = GetSize(), + sizeClient = GetClientSize(); + + wxSize size = sizer->GetMinSize(); + size.x += sizeTotal.x - sizeClient.x; + size.y += sizeTotal.y - sizeClient.y; + + // we don't want to allow expanding the dialog in vertical direction as + // this would show the "hidden" details but we can resize the dialog + // vertically while the details are shown + if ( !m_showingDetails ) + m_maxHeight = size.y; + + SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight); + +#ifdef __WXWINCE__ + if (m_showingDetails) + m_listctrl->Show(); +#endif + + // don't change the width when expanding/collapsing + SetSize(wxDefaultCoord, size.y); + +#ifdef __WXGTK__ + // VS: this is necessary in order to force frame redraw under + // WindowMaker or fvwm2 (and probably other broken WMs). + // Otherwise, detailed list wouldn't be displayed. + Show(); +#endif // wxGTK +} wxLogDialog::~wxLogDialog() { @@ -1009,7 +1144,7 @@ wxLogDialog::~wxLogDialog() #endif // wxUSE_LOG_DIALOG -#if CAN_SAVE_FILES +#if wxUSE_FILE && wxUSE_FILEDLG // pass an uninitialized file object, the function will ask the user for the // filename and try to open it, returns true on success (file was opened), @@ -1027,7 +1162,7 @@ static int OpenLogFile(wxFile& file, wxString *pFilename, wxWindow *parent) // open file // --------- - bool bOk = true; // suppress warning about it being possible uninitialized + bool bOk wxDUMMY_INITIALIZE(false); if ( wxFile::Exists(filename) ) { bool bAppend = false; wxString strMsg; @@ -1067,7 +1202,7 @@ static int OpenLogFile(wxFile& file, wxString *pFilename, wxWindow *parent) return bOk; } -#endif // CAN_SAVE_FILES +#endif // wxUSE_FILE #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW) @@ -1082,9 +1217,13 @@ wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl) m_pTextCtrl = pTextCtrl; } -void wxLogTextCtrl::DoLogText(const wxString& msg) +void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) { - m_pTextCtrl->AppendText(msg + wxS('\n')); + wxString msg; + TimeStamp(&msg); + + msg << szString << wxT('\n'); + m_pTextCtrl->AppendText(msg); } #endif // wxUSE_LOG && wxUSE_TEXTCTRL diff --git a/Source/3rd Party/wx/src/generic/markuptext.cpp b/Source/3rd Party/wx/src/generic/markuptext.cpp deleted file mode 100644 index 03c587c91..000000000 --- a/Source/3rd Party/wx/src/generic/markuptext.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/markuptext.cpp -// Purpose: wxMarkupText implementation -// Author: Vadim Zeitlin -// Created: 2011-02-21 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_MARKUP - -#ifndef WX_PRECOMP - #include "wx/gdicmn.h" - #include "wx/control.h" - #include "wx/dc.h" -#endif // WX_PRECOMP - -#include "wx/generic/private/markuptext.h" - -#include "wx/private/markupparserattr.h" - -namespace -{ - -// ---------------------------------------------------------------------------- -// wxMarkupParserMeasureOutput: measure the extends of a markup string. -// ---------------------------------------------------------------------------- - -class wxMarkupParserMeasureOutput : public wxMarkupParserAttrOutput -{ -public: - // Initialize the base class with the font to use. As we don't care about - // colours (which don't affect the text measurements), don't bother to - // specify them at all. - wxMarkupParserMeasureOutput(wxDC& dc, int *visibleHeight) - : wxMarkupParserAttrOutput(dc.GetFont(), wxColour(), wxColour()), - m_dc(dc), - m_visibleHeight(visibleHeight) - { - if ( visibleHeight ) - *visibleHeight = 0; - } - - const wxSize& GetSize() const { return m_size; } - - - virtual void OnText(const wxString& text_) - { - const wxString text(wxControl::RemoveMnemonics(text_)); - - // TODO-MULTILINE-MARKUP: Must use GetMultiLineTextExtent(). - const wxSize size = m_dc.GetTextExtent(text); - - m_size.x += size.x; - if ( size.y > m_size.y ) - m_size.y = size.y; - - if ( m_visibleHeight ) - { - wxFontMetrics tm = m_dc.GetFontMetrics(); - int visibleHeight = tm.ascent - tm.internalLeading; - if ( *m_visibleHeight < visibleHeight ) - *m_visibleHeight = visibleHeight; - } - } - - virtual void OnAttrStart(const Attr& attr) - { - m_dc.SetFont(attr.font); - } - - virtual void OnAttrEnd(const Attr& WXUNUSED(attr)) - { - m_dc.SetFont(GetFont()); - } - -private: - wxDC& m_dc; - - // The values that we compute. - wxSize m_size; - int * const m_visibleHeight; // may be NULL - - wxDECLARE_NO_COPY_CLASS(wxMarkupParserMeasureOutput); -}; - -// ---------------------------------------------------------------------------- -// wxMarkupParserRenderOutput: render a markup string. -// ---------------------------------------------------------------------------- - -class wxMarkupParserRenderOutput : public wxMarkupParserAttrOutput -{ -public: - // Notice that the bottom of rectangle passed to our ctor is used as the - // baseline for the text we draw, i.e. it needs to be adjusted to exclude - // descent by the caller. - wxMarkupParserRenderOutput(wxDC& dc, - const wxRect& rect, - int flags) - : wxMarkupParserAttrOutput(dc.GetFont(), - dc.GetTextForeground(), - wxColour()), - m_dc(dc), - m_rect(rect), - m_flags(flags) - { - m_pos = m_rect.x; - - // We don't initialize the base class initial text background colour to - // the valid value because we want to be able to detect when we revert - // to the "absence of background colour" and set the background mode to - // be transparent in OnAttrStart() below. But do remember it to be able - // to restore it there later -- this doesn't affect us as the text - // background isn't used anyhow when the background mode is transparent - // but it might affect the caller if it sets the background mode to - // opaque and draws some text after using us. - m_origTextBackground = dc.GetTextBackground(); - } - - virtual void OnText(const wxString& text_) - { - wxString text; - int indexAccel = wxControl::FindAccelIndex(text_, &text); - if ( !(m_flags & wxMarkupText::Render_ShowAccels) ) - indexAccel = wxNOT_FOUND; - - // Adjust the position (unfortunately we need to do this manually as - // there is no notion of current text position in wx API) rectangle to - // ensure that all text segments use the same baseline (as there is - // nothing equivalent to Windows SetTextAlign(TA_BASELINE) neither). - wxRect rect(m_rect); - rect.x = m_pos; - - int descent; - m_dc.GetTextExtent(text, &rect.width, &rect.height, &descent); - rect.height -= descent; - rect.y += m_rect.height - rect.height; - - wxRect bounds; - m_dc.DrawLabel(text, wxBitmap(), - rect, wxALIGN_LEFT | wxALIGN_TOP, - indexAccel, - &bounds); - - // TODO-MULTILINE-MARKUP: Must update vertical position too. - m_pos += bounds.width; - } - - virtual void OnAttrStart(const Attr& attr) - { - m_dc.SetFont(attr.font); - if ( attr.foreground.IsOk() ) - m_dc.SetTextForeground(attr.foreground); - - if ( attr.background.IsOk() ) - { - // Setting the background colour is not enough, we must also change - // the mode to ensure that it is actually used. - m_dc.SetBackgroundMode(wxSOLID); - m_dc.SetTextBackground(attr.background); - } - } - - virtual void OnAttrEnd(const Attr& attr) - { - // We always restore the font because we always change it... - m_dc.SetFont(GetFont()); - - // ...but we only need to restore the colours if we had changed them. - if ( attr.foreground.IsOk() ) - m_dc.SetTextForeground(GetAttr().foreground); - - if ( attr.background.IsOk() ) - { - wxColour background = GetAttr().background; - if ( !background.IsOk() ) - { - // Invalid background colour indicates that the background - // should actually be made transparent and in this case the - // actual value of background colour doesn't matter but we also - // restore it just in case, see comment in the ctor. - m_dc.SetBackgroundMode(wxTRANSPARENT); - background = m_origTextBackground; - } - - m_dc.SetTextBackground(background); - } - } - -private: - wxDC& m_dc; - const wxRect m_rect; - const int m_flags; - - wxColour m_origTextBackground; - - // Current horizontal text output position. - // - // TODO-MULTILINE-MARKUP: Must keep vertical position too. - int m_pos; - - wxDECLARE_NO_COPY_CLASS(wxMarkupParserRenderOutput); -}; - -} // anonymous namespace - -// ============================================================================ -// wxMarkupText implementation -// ============================================================================ - -wxSize wxMarkupText::Measure(wxDC& dc, int *visibleHeight) const -{ - wxMarkupParserMeasureOutput out(dc, visibleHeight); - wxMarkupParser parser(out); - if ( !parser.Parse(m_markup) ) - { - wxFAIL_MSG( "Invalid markup" ); - return wxDefaultSize; - } - - return out.GetSize(); -} - -void wxMarkupText::Render(wxDC& dc, const wxRect& rect, int flags) -{ - // We want to center the above-baseline parts of the letter vertically, so - // we use the visible height and not the total height (which includes - // descent and internal leading) here. - int visibleHeight; - wxRect rectText(rect.GetPosition(), Measure(dc, &visibleHeight)); - rectText.height = visibleHeight; - - wxMarkupParserRenderOutput out(dc, rectText.CentreIn(rect), flags); - wxMarkupParser parser(out); - parser.Parse(m_markup); -} - -#endif // wxUSE_MARKUP diff --git a/Source/3rd Party/wx/src/generic/mask.cpp b/Source/3rd Party/wx/src/generic/mask.cpp deleted file mode 100644 index 504a46285..000000000 --- a/Source/3rd Party/wx/src/generic/mask.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/mask.cpp -// Purpose: generic wxMask implementation -// Author: Vadim Zeitlin -// Created: 2006-09-28 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/bitmap.h" - #include "wx/image.h" -#endif // WX_PRECOMP - -#if wxUSE_GENERIC_MASK - -// ============================================================================ -// wxMask implementation -// ============================================================================ - -IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) - -void wxMask::FreeData() -{ - m_bitmap = wxNullBitmap; -} - -bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour) -{ -#if wxUSE_IMAGE - const wxColour clr(bitmap.QuantizeColour(colour)); - - wxImage imgSrc(bitmap.ConvertToImage()); - imgSrc.SetMask(false); - wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue())); - if ( !image.IsOk() ) - return false; - - m_bitmap = wxBitmap(image, 1); - - return m_bitmap.IsOk(); -#else // !wxUSE_IMAGE - wxUnusedVar(bitmap); - wxUnusedVar(colour); - - return false; -#endif // wxUSE_IMAGE/!wxUSE_IMAGE -} - -bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap) -{ - wxCHECK_MSG( bitmap.IsOk(), false, wxT("Invalid bitmap") ); - wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") ); - - m_bitmap = bitmap; - - return true; -} - -#endif // wxUSE_GENERIC_MASK diff --git a/Source/3rd Party/wx/src/generic/mdig.cpp b/Source/3rd Party/wx/src/generic/mdig.cpp deleted file mode 100644 index c4a9a21f7..000000000 --- a/Source/3rd Party/wx/src/generic/mdig.cpp +++ /dev/null @@ -1,642 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/mdig.cpp -// Purpose: Generic MDI (Multiple Document Interface) classes -// Author: Hans Van Leemputten -// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes -// Created: 29/07/2002 -// Copyright: (c) 2002 Hans Van Leemputten -// (c) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// declarations -// =========================================================================== - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_MDI - -#ifndef WX_PRECOMP - #include "wx/menu.h" - #include "wx/intl.h" - #include "wx/log.h" -#endif //WX_PRECOMP - -#include "wx/mdi.h" -#include "wx/generic/mdig.h" -#include "wx/notebook.h" -#include "wx/scopeguard.h" - -#include "wx/stockitem.h" - -enum MDI_MENU_ID -{ - wxWINDOWCLOSE = 4001, - wxWINDOWCLOSEALL, - wxWINDOWNEXT, - wxWINDOWPREV -}; - -//----------------------------------------------------------------------------- -// wxGenericMDIParentFrame -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIParentFrame, wxFrame) - -BEGIN_EVENT_TABLE(wxGenericMDIParentFrame, wxFrame) - EVT_CLOSE(wxGenericMDIParentFrame::OnClose) -#if wxUSE_MENUS - EVT_MENU(wxID_ANY, wxGenericMDIParentFrame::OnWindowMenu) -#endif -END_EVENT_TABLE() - -void wxGenericMDIParentFrame::Init() -{ -#if wxUSE_MENUS - m_pMyMenuBar = NULL; -#endif // wxUSE_MENUS -} - -wxGenericMDIParentFrame::~wxGenericMDIParentFrame() -{ - // Make sure the client window is destructed before the menu bars are! - wxDELETE(m_clientWindow); - -#if wxUSE_MENUS - wxDELETE(m_pMyMenuBar); - - RemoveWindowMenu(GetMenuBar()); -#endif // wxUSE_MENUS -} - -bool wxGenericMDIParentFrame::Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - // this style can be used to prevent a window from having the standard MDI - // "Window" menu - if ( !(style & wxFRAME_NO_WINDOW_MENU) ) - { -#if wxUSE_MENUS - m_windowMenu = new wxMenu; - - m_windowMenu->Append(wxWINDOWCLOSE, _("Cl&ose")); - m_windowMenu->Append(wxWINDOWCLOSEALL, _("Close All")); - m_windowMenu->AppendSeparator(); - m_windowMenu->Append(wxWINDOWNEXT, _("&Next")); - m_windowMenu->Append(wxWINDOWPREV, _("&Previous")); -#endif // wxUSE_MENUS - } - - // the scrolling styles don't make sense neither for us nor for our client - // window (to which they're supposed to apply) - style &= ~(wxHSCROLL | wxVSCROLL); - - if ( !wxFrame::Create( parent, id, title, pos, size, style, name ) ) - return false; - - wxGenericMDIClientWindow * const client = OnCreateGenericClient(); - if ( !client->CreateGenericClient(this) ) - return false; - - m_clientWindow = client; - - return true; -} - -wxGenericMDIClientWindow *wxGenericMDIParentFrame::OnCreateGenericClient() -{ - return new wxGenericMDIClientWindow; -} - -bool wxGenericMDIParentFrame::CloseAll() -{ - wxGenericMDIClientWindow * const client = GetGenericClientWindow(); - if ( !client ) - return true; // none of the windows left - - wxBookCtrlBase * const book = client->GetBookCtrl(); - while ( book->GetPageCount() ) - { - wxGenericMDIChildFrame * const child = client->GetChild(0); - if ( !child->Close() ) - { - // it refused to close, don't close the remaining ones neither - return false; - } - } - - return true; -} - -#if wxUSE_MENUS -void wxGenericMDIParentFrame::SetWindowMenu(wxMenu* pMenu) -{ - // Replace the window menu from the currently loaded menu bar. - wxMenuBar *pMenuBar = GetMenuBar(); - - if (m_windowMenu) - { - RemoveWindowMenu(pMenuBar); - - wxDELETE(m_windowMenu); - } - - if (pMenu) - { - m_windowMenu = pMenu; - - AddWindowMenu(pMenuBar); - } -} - -void wxGenericMDIParentFrame::SetMenuBar(wxMenuBar *pMenuBar) -{ - // Remove the Window menu from the old menu bar - RemoveWindowMenu(GetMenuBar()); - // Add the Window menu to the new menu bar. - AddWindowMenu(pMenuBar); - - wxFrame::SetMenuBar(pMenuBar); -} -#endif // wxUSE_MENUS - -void wxGenericMDIParentFrame::WXSetChildMenuBar(wxGenericMDIChildFrame *pChild) -{ -#if wxUSE_MENUS - if (pChild == NULL) - { - // No Child, set Our menu bar back. - SetMenuBar(m_pMyMenuBar); - - // Make sure we know our menu bar is in use - m_pMyMenuBar = NULL; - } - else - { - if (pChild->GetMenuBar() == NULL) - return; - - // Do we need to save the current bar? - if (m_pMyMenuBar == NULL) - m_pMyMenuBar = GetMenuBar(); - - SetMenuBar(pChild->GetMenuBar()); - } -#endif // wxUSE_MENUS -} - -wxGenericMDIClientWindow * -wxGenericMDIParentFrame::GetGenericClientWindow() const -{ - return static_cast(m_clientWindow); -} - -wxBookCtrlBase *wxGenericMDIParentFrame::GetBookCtrl() const -{ - wxGenericMDIClientWindow * const client = GetGenericClientWindow(); - return client ? client->GetBookCtrl() : NULL; -} - -void wxGenericMDIParentFrame::AdvanceActive(bool forward) -{ - wxBookCtrlBase * const book = GetBookCtrl(); - if ( book ) - book->AdvanceSelection(forward); -} - -void wxGenericMDIParentFrame::WXUpdateChildTitle(wxGenericMDIChildFrame *child) -{ - wxGenericMDIClientWindow * const client = GetGenericClientWindow(); - - const int pos = client->FindChild(child); - if ( pos == wxNOT_FOUND ) - return; - - client->GetBookCtrl()->SetPageText(pos, child->GetTitle()); -} - -void wxGenericMDIParentFrame::WXActivateChild(wxGenericMDIChildFrame *child) -{ - wxGenericMDIClientWindow * const client = GetGenericClientWindow(); - - const int pos = client->FindChild(child); - if ( pos == wxNOT_FOUND ) - return; - - client->GetBookCtrl()->SetSelection(pos); -} - -void wxGenericMDIParentFrame::WXRemoveChild(wxGenericMDIChildFrame *child) -{ - const bool removingActive = WXIsActiveChild(child); - if ( removingActive ) - { - SetActiveChild(NULL); - WXSetChildMenuBar(NULL); - } - - wxGenericMDIClientWindow * const client = GetGenericClientWindow(); - wxCHECK_RET( client, "should have client window" ); - - wxBookCtrlBase * const book = client->GetBookCtrl(); - - // Remove page if still there - int pos = client->FindChild(child); - if ( pos != wxNOT_FOUND ) - { - if ( book->RemovePage(pos) ) - book->Refresh(); - } - - if ( removingActive ) - { - // Set the new selection to a remaining page - const size_t count = book->GetPageCount(); - if ( count > (size_t)pos ) - { - book->SetSelection(pos); - } - else - { - if ( count > 0 ) - book->SetSelection(count - 1); - } - } -} - -bool -wxGenericMDIParentFrame::WXIsActiveChild(wxGenericMDIChildFrame *child) const -{ - return static_cast(GetActiveChild()) == child; -} - -#if wxUSE_MENUS -void wxGenericMDIParentFrame::RemoveWindowMenu(wxMenuBar *pMenuBar) -{ - if (pMenuBar && m_windowMenu) - { - // Remove old window menu - int pos = pMenuBar->FindMenu(_("&Window")); - if (pos != wxNOT_FOUND) - { - wxASSERT(m_windowMenu == pMenuBar->GetMenu(pos)); // DBG:: We're going to delete the wrong menu!!! - pMenuBar->Remove(pos); - } - } -} - -void wxGenericMDIParentFrame::AddWindowMenu(wxMenuBar *pMenuBar) -{ - if (pMenuBar && m_windowMenu) - { - int pos = pMenuBar->FindMenu(wxGetStockLabel(wxID_HELP,false)); - if (pos == wxNOT_FOUND) - { - pMenuBar->Append(m_windowMenu, _("&Window")); - } - else - { - pMenuBar->Insert(pos, m_windowMenu, _("&Window")); - } - } -} - -void wxGenericMDIParentFrame::OnWindowMenu(wxCommandEvent &event) -{ - switch ( event.GetId() ) - { - case wxWINDOWCLOSE: - if ( m_currentChild ) - m_currentChild->Close(); - break; - - case wxWINDOWCLOSEALL: - CloseAll(); - break; - - case wxWINDOWNEXT: - ActivateNext(); - break; - - case wxWINDOWPREV: - ActivatePrevious(); - break; - - default: - event.Skip(); - } -} -#endif // wxUSE_MENUS - -void wxGenericMDIParentFrame::OnClose(wxCloseEvent& event) -{ - if ( !CloseAll() ) - event.Veto(); - else - event.Skip(); -} - -bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event) -{ - if ( m_currentChild ) - { - // the menu events should be given to the child as we show its menu bar - // as our own - const wxEventType eventType = event.GetEventType(); - if ( eventType == wxEVT_MENU || - eventType == wxEVT_UPDATE_UI ) - { - // set the flag indicating that this event was forwarded to the - // child from the parent and so shouldn't be propagated upwards if - // not processed to avoid infinite loop - m_childHandler = m_currentChild; - wxON_BLOCK_EXIT_NULL(m_childHandler); - - if ( m_currentChild->ProcessWindowEvent(event) ) - return true; - } - } - - return wxMDIParentFrameBase::ProcessEvent(event); -} - -// ---------------------------------------------------------------------------- -// wxGenericMDIChildFrame -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIChildFrame, wxFrame) - -BEGIN_EVENT_TABLE(wxGenericMDIChildFrame, wxFrame) - EVT_MENU_HIGHLIGHT_ALL(wxGenericMDIChildFrame::OnMenuHighlight) - - EVT_CLOSE(wxGenericMDIChildFrame::OnClose) -END_EVENT_TABLE() - -void wxGenericMDIChildFrame::Init() -{ -#if wxUSE_MENUS - m_pMenuBar = NULL; -#endif // wxUSE_MENUS - -#if !wxUSE_GENERIC_MDI_AS_NATIVE - m_mdiParentGeneric = NULL; -#endif -} - -wxGenericMDIChildFrame::~wxGenericMDIChildFrame() -{ - wxGenericMDIParentFrame * const parent = GetGenericMDIParent(); - - // it could happen that we don't have a valid parent if we hadn't been ever - // really created -- but in this case there is nothing else to do neither - if ( parent ) - parent->WXRemoveChild(this); - -#if wxUSE_MENUS - delete m_pMenuBar; -#endif // wxUSE_MENUS -} - -bool wxGenericMDIChildFrame::Create(wxGenericMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& WXUNUSED(pos), - const wxSize& size, - long WXUNUSED(style), - const wxString& name) -{ - // unfortunately we can't use the base class m_mdiParent field unless - // wxGenericMDIParentFrame is wxMDIParentFrame -#if wxUSE_GENERIC_MDI_AS_NATIVE - m_mdiParent = parent; -#else // generic != native - // leave m_mdiParent NULL, we don't have it - m_mdiParentGeneric = parent; -#endif - - wxBookCtrlBase * const book = parent->GetBookCtrl(); - - wxASSERT_MSG( book, "Missing MDI client window." ); - - // note that we ignore the styles, none of the usual TLW styles apply to - // this (child) window - if ( !wxWindow::Create(book, id, wxDefaultPosition, size, 0, name) ) - return false; - - m_title = title; - book->AddPage(this, title, true); - - return true; -} - -#if wxUSE_MENUS -void wxGenericMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) -{ - wxMenuBar *pOldMenuBar = m_pMenuBar; - m_pMenuBar = menu_bar; - - if (m_pMenuBar) - { - wxGenericMDIParentFrame *parent = GetGenericMDIParent(); - - if ( parent ) - { - m_pMenuBar->SetParent(parent); - - if ( parent->WXIsActiveChild(this) ) - { - // Replace current menu bars - if (pOldMenuBar) - parent->WXSetChildMenuBar(NULL); - parent->WXSetChildMenuBar(this); - } - } - } -} - -wxMenuBar *wxGenericMDIChildFrame::GetMenuBar() const -{ - return m_pMenuBar; -} -#endif // wxUSE_MENUS - -void wxGenericMDIChildFrame::SetTitle(const wxString& title) -{ - m_title = title; - - wxGenericMDIParentFrame * const parent = GetGenericMDIParent(); - if ( parent ) - parent->WXUpdateChildTitle(this); - //else: it's ok, we might be not created yet -} - -void wxGenericMDIChildFrame::Activate() -{ - wxGenericMDIParentFrame * const parent = GetGenericMDIParent(); - - wxCHECK_RET( parent, "can't activate MDI child without parent" ); - parent->WXActivateChild(this); -} - -void wxGenericMDIChildFrame::OnMenuHighlight(wxMenuEvent& event) -{ - wxGenericMDIParentFrame * const parent = GetGenericMDIParent(); - if ( parent) - { - // we don't have any help text for this item, - // but may be the MDI frame does? - parent->OnMenuHighlight(event); - } -} - -void wxGenericMDIChildFrame::OnClose(wxCloseEvent& WXUNUSED(event)) -{ - // we're not a TLW so don't delay the destruction of this window - delete this; -} - -bool wxGenericMDIChildFrame::TryAfter(wxEvent& event) -{ - // we shouldn't propagate the event to the parent if we received it from it - // in the first place - wxGenericMDIParentFrame * const parent = GetGenericMDIParent(); - if ( parent && parent->WXIsInsideChildHandler(this) ) - return false; - - return wxTDIChildFrame::TryAfter(event); -} - -// ---------------------------------------------------------------------------- -// wxGenericMDIClientWindow -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIClientWindow, wxWindow) - -bool -wxGenericMDIClientWindow::CreateGenericClient(wxWindow *parent) -{ - if ( !wxWindow::Create(parent, wxID_ANY) ) - return false; - - m_notebook = new wxNotebook(this, wxID_ANY); - m_notebook->Connect - ( - wxEVT_NOTEBOOK_PAGE_CHANGED, - wxNotebookEventHandler( - wxGenericMDIClientWindow::OnPageChanged), - NULL, - this - ); - - // now that we have a notebook to resize, hook up OnSize() too - Connect(wxEVT_SIZE, wxSizeEventHandler(wxGenericMDIClientWindow::OnSize)); - - return true; -} - -wxBookCtrlBase *wxGenericMDIClientWindow::GetBookCtrl() const -{ - return m_notebook; -} - -wxGenericMDIChildFrame *wxGenericMDIClientWindow::GetChild(size_t pos) const -{ - return static_cast(GetBookCtrl()->GetPage(pos)); -} - -int wxGenericMDIClientWindow::FindChild(wxGenericMDIChildFrame *child) const -{ - wxBookCtrlBase * const book = GetBookCtrl(); - const size_t count = book->GetPageCount(); - for ( size_t pos = 0; pos < count; pos++ ) - { - if ( book->GetPage(pos) == child ) - return pos; - } - - return wxNOT_FOUND; -} - -void wxGenericMDIClientWindow::PageChanged(int oldSelection, int newSelection) -{ - // Don't do anything if nothing changed - if (oldSelection == newSelection) - return; - - // Again check if we really need to do this... - if (newSelection != -1) - { - wxGenericMDIChildFrame * const child = GetChild(newSelection); - - if ( child->GetGenericMDIParent()->WXIsActiveChild(child) ) - return; - } - - // Notify old active child that it has been deactivated - if (oldSelection != -1) - { - wxGenericMDIChildFrame * const oldChild = GetChild(oldSelection); - if (oldChild) - { - wxActivateEvent event(wxEVT_ACTIVATE, false, oldChild->GetId()); - event.SetEventObject( oldChild ); - oldChild->GetEventHandler()->ProcessEvent(event); - } - } - - // Notify new active child that it has been activated - if (newSelection != -1) - { - wxGenericMDIChildFrame * const activeChild = GetChild(newSelection); - if ( activeChild ) - { - wxActivateEvent event(wxEVT_ACTIVATE, true, activeChild->GetId()); - event.SetEventObject( activeChild ); - activeChild->GetEventHandler()->ProcessEvent(event); - - wxGenericMDIParentFrame * const - parent = activeChild->GetGenericMDIParent(); - - if ( parent ) - { - // this is a dirty hack as activeChild is not really a - // wxMDIChildFrame at all but we still want to store it in the - // base class m_currentChild field and this will work as long - // as we only use as wxMDIChildFrameBase pointer (which it is) - parent->SetActiveChild( - reinterpret_cast(activeChild)); - parent->WXSetChildMenuBar(activeChild); - } - } - } -} - -void wxGenericMDIClientWindow::OnPageChanged(wxBookCtrlEvent& event) -{ - PageChanged(event.GetOldSelection(), event.GetSelection()); - - event.Skip(); -} - -void wxGenericMDIClientWindow::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - m_notebook->SetSize(GetClientSize()); -} - -#endif // wxUSE_MDI - diff --git a/Source/3rd Party/wx/src/generic/msgdlgg.cpp b/Source/3rd Party/wx/src/generic/msgdlgg.cpp index bc74245af..8887f131b 100644 --- a/Source/3rd Party/wx/src/generic/msgdlgg.cpp +++ b/Source/3rd Party/wx/src/generic/msgdlgg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart, Robert Roebling // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: msgdlgg.cpp 41838 2006-10-09 21:08:45Z VZ $ // Copyright: (c) Julian Smart and Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,7 +16,7 @@ #pragma hdrstop #endif -#if wxUSE_MSGDLG +#if wxUSE_MSGDLG && (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__) || defined(__WXGPE__)) #ifndef WX_PRECOMP #include "wx/utils.h" @@ -37,36 +38,11 @@ #define __WX_COMPILING_MSGDLGG_CPP__ 1 #include "wx/msgdlg.h" #include "wx/artprov.h" -#include "wx/textwrapper.h" -#include "wx/modalhook.h" #if wxUSE_STATLINE #include "wx/statline.h" #endif -// ---------------------------------------------------------------------------- -// wxTitleTextWrapper: simple class to create wrapped text in "title font" -// ---------------------------------------------------------------------------- - -class wxTitleTextWrapper : public wxTextSizerWrapper -{ -public: - wxTitleTextWrapper(wxWindow *win) - : wxTextSizerWrapper(win) - { - } - -protected: - virtual wxWindow *OnCreateLine(const wxString& s) - { - wxWindow * const win = wxTextSizerWrapper::OnCreateLine(s); - - win->SetFont(win->GetFont().Larger().MakeBold()); - - return win; - } -}; - // ---------------------------------------------------------------------------- // icons // ---------------------------------------------------------------------------- @@ -74,7 +50,6 @@ protected: BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog) EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes) EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo) - EVT_BUTTON(wxID_HELP, wxGenericMessageDialog::OnHelp) EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel) END_EVENT_TABLE() @@ -85,85 +60,11 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& caption, long style, const wxPoint& pos) - : wxMessageDialogBase(GetParentForModalDialog(parent, style), - message, - caption, - style), - m_pos(pos) + : wxDialog( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ) { - m_created = false; -} + SetMessageDialogStyle(style); -wxSizer *wxGenericMessageDialog::CreateMsgDlgButtonSizer() -{ -#ifndef __SMARTPHONE__ - if ( HasCustomLabels() ) - { - wxStdDialogButtonSizer * const sizerStd = new wxStdDialogButtonSizer; - - wxButton *btnDef = NULL; - - if ( m_dialogStyle & wxOK ) - { - btnDef = new wxButton(this, wxID_OK, GetCustomOKLabel()); - sizerStd->AddButton(btnDef); - } - - if ( m_dialogStyle & wxCANCEL ) - { - wxButton * const - cancel = new wxButton(this, wxID_CANCEL, GetCustomCancelLabel()); - sizerStd->AddButton(cancel); - - if ( m_dialogStyle & wxCANCEL_DEFAULT ) - btnDef = cancel; - } - - if ( m_dialogStyle & wxYES_NO ) - { - wxButton * const - yes = new wxButton(this, wxID_YES, GetCustomYesLabel()); - sizerStd->AddButton(yes); - - wxButton * const - no = new wxButton(this, wxID_NO, GetCustomNoLabel()); - sizerStd->AddButton(no); - if ( m_dialogStyle & wxNO_DEFAULT ) - btnDef = no; - else if ( !btnDef ) - btnDef = yes; - } - - if ( m_dialogStyle & wxHELP ) - { - wxButton * const - help = new wxButton(this, wxID_HELP, GetCustomHelpLabel()); - sizerStd->AddButton(help); - } - - if ( btnDef ) - { - btnDef->SetDefault(); - btnDef->SetFocus(); - } - - sizerStd->Realize(); - - return CreateSeparatedSizer(sizerStd); - } -#endif // !__SMARTPHONE__ - - // Use standard labels for all buttons - return CreateSeparatedButtonSizer - ( - m_dialogStyle & (wxOK | wxCANCEL | wxHELP | wxYES_NO | - wxNO_DEFAULT | wxCANCEL_DEFAULT) - ); -} - -void wxGenericMessageDialog::DoCreateMsgdialog() -{ - wxDialog::Create(m_parent, wxID_ANY, m_caption, m_pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE); + bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); @@ -171,57 +72,53 @@ void wxGenericMessageDialog::DoCreateMsgdialog() #if wxUSE_STATBMP // 1) icon - if (m_dialogStyle & wxICON_MASK) + if (style & wxICON_MASK) { - wxStaticBitmap *icon = new wxStaticBitmap - ( - this, - wxID_ANY, - wxArtProvider::GetMessageBoxIcon(m_dialogStyle) - ); - if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA ) + wxBitmap bitmap; + switch ( style & wxICON_MASK ) + { + default: + wxFAIL_MSG(_T("incorrect log style")); + // fall through + + case wxICON_ERROR: + bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX); + break; + + case wxICON_INFORMATION: + bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX); + break; + + case wxICON_WARNING: + bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX); + break; + + case wxICON_QUESTION: + bitmap = wxArtProvider::GetIcon(wxART_QUESTION, wxART_MESSAGE_BOX); + break; + } + wxStaticBitmap *icon = new wxStaticBitmap(this, wxID_ANY, bitmap); + if (is_pda) topsizer->Add( icon, 0, wxTOP|wxLEFT|wxRIGHT | wxALIGN_LEFT, 10 ); else - icon_text->Add(icon, wxSizerFlags().Top().Border(wxRIGHT, 20)); + icon_text->Add( icon, 0, wxCENTER ); } #endif // wxUSE_STATBMP #if wxUSE_STATTEXT // 2) text + icon_text->Add( CreateTextSizer( message ), 0, wxALIGN_CENTER | wxLEFT, 10 ); - wxBoxSizer * const textsizer = new wxBoxSizer(wxVERTICAL); - - // We want to show the main message in a different font to make it stand - // out if the extended message is used as well. This looks better and is - // more consistent with the native dialogs under MSW and GTK. - wxString lowerMessage; - if ( !m_extendedMessage.empty() ) - { - wxTitleTextWrapper titleWrapper(this); - textsizer->Add(CreateTextSizer(GetMessage(), titleWrapper), - wxSizerFlags().Border(wxBOTTOM, 20)); - - lowerMessage = GetExtendedMessage(); - } - else // no extended message - { - lowerMessage = GetMessage(); - } - - textsizer->Add(CreateTextSizer(lowerMessage)); - - icon_text->Add(textsizer, 0, wxALIGN_CENTER, 10); - topsizer->Add( icon_text, 1, wxLEFT|wxRIGHT|wxTOP, 10 ); + topsizer->Add( icon_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 ); #endif // wxUSE_STATTEXT - // 3) optional checkbox and detailed text - AddMessageDialogCheckBox( topsizer ); - AddMessageDialogDetails( topsizer ); - - // 4) buttons - wxSizer *sizerBtn = CreateMsgDlgButtonSizer(); + // 3) buttons + int center_flag = wxEXPAND; + if (style & wxYES_NO) + center_flag = wxALIGN_CENTRE; + wxSizer *sizerBtn = CreateSeparatedButtonSizer(style & ButtonSizerFlags); if ( sizerBtn ) - topsizer->Add(sizerBtn, 0, wxEXPAND | wxALL, 10 ); + topsizer->Add(sizerBtn, 0, center_flag | wxALL, 10 ); SetAutoLayout( true ); SetSizer( topsizer ); @@ -248,11 +145,6 @@ void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event)) EndModal( wxID_NO ); } -void wxGenericMessageDialog::OnHelp(wxCommandEvent& WXUNUSED(event)) -{ - EndModal( wxID_HELP ); -} - void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { // Allow cancellation via ESC/Close button except if @@ -264,17 +156,4 @@ void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) } } -int wxGenericMessageDialog::ShowModal() -{ - WX_HOOK_MODAL_DIALOG(); - - if ( !m_created ) - { - m_created = true; - DoCreateMsgdialog(); - } - - return wxMessageDialogBase::ShowModal(); -} - -#endif // wxUSE_MSGDLG +#endif // wxUSE_MSGDLG && !defined(__WXGTK20__) diff --git a/Source/3rd Party/wx/src/generic/notebook.cpp b/Source/3rd Party/wx/src/generic/notebook.cpp deleted file mode 100644 index 8caf0cda1..000000000 --- a/Source/3rd Party/wx/src/generic/notebook.cpp +++ /dev/null @@ -1,755 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/notebook.cpp -// Purpose: generic implementation of wxNotebook -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_NOTEBOOK - -#include "wx/notebook.h" - -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/log.h" - #include "wx/dcclient.h" - #include "wx/settings.h" -#endif - -#include "wx/imaglist.h" -#include "wx/generic/tabg.h" - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// check that the page index is valid -#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) - -// ---------------------------------------------------------------------------- -// event table -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase) - EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) - EVT_SIZE(wxNotebook::OnSize) - EVT_PAINT(wxNotebook::OnPaint) - EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent) - EVT_SET_FOCUS(wxNotebook::OnSetFocus) - EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) -END_EVENT_TABLE() - -// ============================================================================ -// implementation -// ============================================================================ - -// ============================================================================ -// Private class -// ============================================================================ - -WX_DECLARE_HASH_MAP(int, wxNotebookPage*, wxIntegerHash, wxIntegerEqual, - wxIntToNotebookPageHashMap); - -WX_DECLARE_HASH_MAP(wxNotebookPage*, int, wxPointerHash, wxPointerEqual, - wxNotebookPageToIntHashMap); - -// This reuses wxTabView to draw the tabs. -class WXDLLEXPORT wxNotebookTabView: public wxTabView -{ -DECLARE_DYNAMIC_CLASS(wxNotebookTabView) -public: - wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); - virtual ~wxNotebookTabView(void); - - // Called when a tab is activated - virtual void OnTabActivate(int activateId, int deactivateId); - // Allows vetoing - virtual bool OnTabPreActivate(int activateId, int deactivateId); - - // map integer ids used by wxTabView to wxNotebookPage pointers - int GetId(wxNotebookPage *page); - wxNotebookPage *GetPage(int id) { return m_idToPage[id]; } - -protected: - wxNotebook* m_notebook; - -private: - wxIntToNotebookPageHashMap m_idToPage; - wxNotebookPageToIntHashMap m_pageToId; - int m_nextid; -}; - -static int GetPageId(wxTabView *tabview, wxNotebookPage *page) -{ - return static_cast(tabview)->GetId(page); -} - -// ---------------------------------------------------------------------------- -// wxNotebook construction -// ---------------------------------------------------------------------------- - -// common part of all ctors -void wxNotebook::Init() -{ - m_tabView = NULL; - m_selection = -1; -} - -// default for dynamic class -wxNotebook::wxNotebook() -{ - Init(); -} - -// the same arguments as for wxControl -wxNotebook::wxNotebook(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - Init(); - - Create(parent, id, pos, size, style, name); -} - -// Create() function -bool wxNotebook::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - // base init - SetName(name); - - if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) - style |= wxBK_TOP; - - m_windowId = id == wxID_ANY ? NewControlId() : id; - - if (!wxControl::Create(parent, id, pos, size, style|wxNO_BORDER, wxDefaultValidator, name)) - return false; - - SetTabView(new wxNotebookTabView(this)); - - return true; -} - -// dtor -wxNotebook::~wxNotebook() -{ - delete m_tabView; -} - -// ---------------------------------------------------------------------------- -// wxNotebook accessors -// ---------------------------------------------------------------------------- -int wxNotebook::GetRowCount() const -{ - // TODO - return 0; -} - -int wxNotebook::SetSelection(size_t nPage) -{ - wxASSERT( IS_VALID_PAGE(nPage) ); - - wxNotebookPage* pPage = GetPage(nPage); - - m_tabView->SetTabSelection(GetPageId(m_tabView, pPage)); - - // TODO - return 0; -} - -int wxNotebook::ChangeSelection(size_t nPage) -{ - // FIXME: currently it does generate events too - return SetSelection(nPage); -} - -#if 0 -void wxNotebook::AdvanceSelection(bool bForward) -{ - int nSel = GetSelection(); - int nMax = GetPageCount() - 1; - if ( bForward ) - SetSelection(nSel == nMax ? 0 : nSel + 1); - else - SetSelection(nSel == 0 ? nMax : nSel - 1); -} -#endif - -bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) -{ - wxASSERT( IS_VALID_PAGE(nPage) ); - - wxNotebookPage* page = GetPage(nPage); - if (page) - { - m_tabView->SetTabText(GetPageId(m_tabView, page), strText); - Refresh(); - return true; - } - - return false; -} - -wxString wxNotebook::GetPageText(size_t nPage) const -{ - wxASSERT( IS_VALID_PAGE(nPage) ); - - wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage); - if (page) - return m_tabView->GetTabText(GetPageId(m_tabView, page)); - else - return wxEmptyString; -} - -int wxNotebook::GetPageImage(size_t WXUNUSED_UNLESS_DEBUG(nPage)) const -{ - wxASSERT( IS_VALID_PAGE(nPage) ); - - // TODO - return 0; -} - -bool wxNotebook::SetPageImage(size_t WXUNUSED_UNLESS_DEBUG(nPage), - int WXUNUSED(nImage)) -{ - wxASSERT( IS_VALID_PAGE(nPage) ); - - // TODO - return false; -} - -// set the size (the same for all pages) -void wxNotebook::SetPageSize(const wxSize& WXUNUSED(size)) -{ - // TODO -} - -// set the padding between tabs (in pixels) -void wxNotebook::SetPadding(const wxSize& WXUNUSED(padding)) -{ - // TODO -} - -// set the size of the tabs for wxNB_FIXEDWIDTH controls -void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz)) -{ - // TODO -} - -// ---------------------------------------------------------------------------- -// wxNotebook operations -// ---------------------------------------------------------------------------- - -// remove one page from the notebook and delete it -bool wxNotebook::DeletePage(size_t nPage) -{ - wxCHECK( IS_VALID_PAGE(nPage), false ); - - if (m_selection != -1) - { - m_pages[m_selection]->Show(false); - m_pages[m_selection]->Lower(); - } - - wxNotebookPage* pPage = GetPage(nPage); - - m_tabView->RemoveTab(GetPageId(m_tabView, pPage)); - - m_pages.Remove(pPage); - delete pPage; - - if (m_pages.GetCount() == 0) - { - m_selection = -1; - m_tabView->SetTabSelection(-1, false); - } - else if (m_selection > -1) - { - m_selection = -1; - - m_tabView->SetTabSelection(GetPageId(m_tabView, GetPage(0)), false); - - if (m_selection != 0) - ChangePage(-1, 0); - } - - RefreshLayout(false); - - return true; -} - -bool wxNotebook::DeletePage(wxNotebookPage* page) -{ - int pagePos = FindPagePosition(page); - if (pagePos > -1) - return DeletePage(pagePos); - else - return false; -} - -bool wxNotebook::RemovePage(size_t nPage) -{ - return DoRemovePage(nPage) != NULL; -} - -// remove one page from the notebook -wxWindow* wxNotebook::DoRemovePage(size_t nPage) -{ - wxCHECK( IS_VALID_PAGE(nPage), NULL ); - - m_pages[nPage]->Show(false); - // m_pages[nPage]->Lower(); - - wxNotebookPage* pPage = GetPage(nPage); - - m_tabView->RemoveTab(GetPageId(m_tabView, pPage)); - - m_pages.Remove(pPage); - - if (m_pages.GetCount() == 0) - { - m_selection = -1; - m_tabView->SetTabSelection(-1, true); - } - else if (m_selection > -1) - { - // Only change the selection if the page we - // deleted was the selection. - if (nPage == (size_t)m_selection) - { - m_selection = -1; - // Select the first tab. Generates a ChangePage. - m_tabView->SetTabSelection(0, true); - } - else - { - // We must adjust which tab we think is selected. - // If greater than the page we deleted, it must be moved down - // a notch. - if (size_t(m_selection) > nPage) - m_selection -- ; - } - } - - RefreshLayout(false); - - return pPage; -} - -bool wxNotebook::RemovePage(wxNotebookPage* page) -{ - int pagePos = FindPagePosition(page); - if (pagePos > -1) - return RemovePage(pagePos); - else - return false; -} - -// Find the position of the wxNotebookPage, -1 if not found. -int wxNotebook::FindPagePosition(wxNotebookPage* page) const -{ - size_t nPageCount = GetPageCount(); - size_t nPage; - for ( nPage = 0; nPage < nPageCount; nPage++ ) - if (m_pages[nPage] == page) - return nPage; - return -1; -} - -// remove all pages -bool wxNotebook::DeleteAllPages() -{ - m_tabView->ClearTabs(true); - - size_t nPageCount = GetPageCount(); - size_t nPage; - for ( nPage = 0; nPage < nPageCount; nPage++ ) - delete m_pages[nPage]; - - m_pages.Clear(); - - return true; -} - -// same as AddPage() but does it at given position -bool wxNotebook::InsertPage(size_t nPage, - wxNotebookPage *pPage, - const wxString& strText, - bool bSelect, - int WXUNUSED(imageId)) -{ - wxASSERT( pPage != NULL ); - wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false ); - - m_tabView->AddTab(GetPageId(m_tabView, pPage), strText); - - if (!bSelect) - pPage->Show(false); - - // save the pointer to the page - m_pages.Insert(pPage, nPage); - - if (bSelect) - { - // This will cause ChangePage to be called, via OnSelPage - - m_tabView->SetTabSelection(GetPageId(m_tabView, pPage), true); - } - - // some page must be selected: either this one or the first one if there is - // still no selection - if ( m_selection == -1 ) - ChangePage(-1, 0); - - RefreshLayout(false); - - return true; -} - -// ---------------------------------------------------------------------------- -// wxNotebook callbacks -// ---------------------------------------------------------------------------- - -// @@@ OnSize() is used for setting the font when it's called for the first -// time because doing it in ::Create() doesn't work (for unknown reasons) -void wxNotebook::OnSize(wxSizeEvent& event) -{ - static bool s_bFirstTime = true; - if ( s_bFirstTime ) { - // TODO: any first-time-size processing. - s_bFirstTime = false; - } - - RefreshLayout(); - - // Processing continues to next OnSize - event.Skip(); -} - -// This was supposed to cure the non-display of the notebook -// until the user resizes the window. -// What's going on? -void wxNotebook::OnInternalIdle() -{ - wxWindow::OnInternalIdle(); - -#if 0 - static bool s_bFirstTime = true; - if ( s_bFirstTime ) { - /* - wxSize sz(GetSize()); - sz.x ++; - SetSize(sz); - sz.x --; - SetSize(sz); - */ - - /* - wxSize sz(GetSize()); - wxSizeEvent sizeEvent(sz, GetId()); - sizeEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(sizeEvent); - Refresh(); - */ - s_bFirstTime = false; - } -#endif -} - -// Implementation: calculate the layout of the view rect -// and resize the children if required -bool wxNotebook::RefreshLayout(bool force) -{ - if (m_tabView) - { - wxRect oldRect = m_tabView->GetViewRect(); - - int cw, ch; - GetClientSize(& cw, & ch); - - int tabHeight = m_tabView->GetTotalTabHeight(); - wxRect rect; - rect.x = 4; - rect.y = tabHeight + 4; - rect.width = cw - 8; - rect.height = ch - 4 - rect.y ; - - m_tabView->SetViewRect(rect); - - m_tabView->LayoutTabs(); - - // Need to do it a 2nd time to get the tab height with - // the new view width, since changing the view width changes the - // tab layout. - tabHeight = m_tabView->GetTotalTabHeight(); - rect.x = 4; - rect.y = tabHeight + 4; - rect.width = cw - 8; - rect.height = ch - 4 - rect.y ; - - m_tabView->SetViewRect(rect); - - m_tabView->LayoutTabs(); - - if (!force && (rect == oldRect)) - return false; - - // fit the notebook page to the tab control's display area - - size_t nCount = m_pages.Count(); - for ( size_t nPage = 0; nPage < nCount; nPage++ ) { - wxNotebookPage *pPage = m_pages[nPage]; - wxRect clientRect = GetAvailableClientSize(); - if (pPage->IsShown()) - { - pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height); - if ( pPage->GetAutoLayout() ) - pPage->Layout(); - } - } - Refresh(); - } - return true; -} - -void wxNotebook::OnSelChange(wxBookCtrlEvent& event) -{ - // is it our tab control? - if ( event.GetEventObject() == this ) - { - if (event.GetSelection() != m_selection) - ChangePage(event.GetOldSelection(), event.GetSelection()); - } - - // we want to give others a chance to process this message as well - event.Skip(); -} - -void wxNotebook::OnSetFocus(wxFocusEvent& event) -{ - // set focus to the currently selected page if any - if ( m_selection != -1 ) - m_pages[m_selection]->SetFocus(); - - event.Skip(); -} - -void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) -{ - if ( event.IsWindowChange() ) - { - // change pages - AdvanceSelection(event.GetDirection()); - } - else { - // pass to the parent - if ( GetParent() ) - { - event.SetCurrentFocus(this); - GetParent()->ProcessWindowEvent(event); - } - } -} - -// ---------------------------------------------------------------------------- -// wxNotebook base class virtuals -// ---------------------------------------------------------------------------- - -// override these 2 functions to do nothing: everything is done in OnSize - -void wxNotebook::SetConstraintSizes(bool /* recurse */) -{ - // don't set the sizes of the pages - their correct size is not yet known - wxControl::SetConstraintSizes(false); -} - -bool wxNotebook::DoPhase(int /* nPhase */) -{ - return true; -} - -void wxNotebook::Command(wxCommandEvent& WXUNUSED(event)) -{ - wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); -} - -// ---------------------------------------------------------------------------- -// wxNotebook helper functions -// ---------------------------------------------------------------------------- - -// hide the currently active panel and show the new one -void wxNotebook::ChangePage(int nOldSel, int nSel) -{ - // cout << "ChangePage: " << nOldSel << ", " << nSel << "\n"; - wxASSERT( nOldSel != nSel ); // impossible - - if ( nOldSel != -1 ) { - m_pages[nOldSel]->Show(false); - m_pages[nOldSel]->Lower(); - } - - wxNotebookPage *pPage = m_pages[nSel]; - - wxRect clientRect = GetAvailableClientSize(); - pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height); - - Refresh(); - - pPage->Show(true); - pPage->Raise(); - pPage->SetFocus(); - - m_selection = nSel; -} - -void wxNotebook::OnMouseEvent(wxMouseEvent& event) -{ - if (m_tabView) - m_tabView->OnEvent(event); -} - -void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - if (m_tabView) - m_tabView->Draw(dc); -} - -wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const -{ - // MBN: since the total tab height is really a function of the - // width, this should really call - // GetTotalTabHeightPretendingWidthIs(), but the current - // implementation will suffice, provided the wxNotebook has been - // created with a sensible initial width. - return wxSize( sizePage.x + 12, - sizePage.y + m_tabView->GetTotalTabHeight() + 6 + 4 ); -} - -wxRect wxNotebook::GetAvailableClientSize() -{ - int cw, ch; - GetClientSize(& cw, & ch); - - int tabHeight = m_tabView->GetTotalTabHeight(); - - // TODO: these margins should be configurable. - wxRect rect; - rect.x = 6; - rect.y = tabHeight + 6; - rect.width = cw - 12; - rect.height = ch - 4 - rect.y ; - - return rect; -} - -/* - * wxNotebookTabView - */ - -IMPLEMENT_CLASS(wxNotebookTabView, wxTabView) - -wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style) - : wxTabView(style), m_nextid(1) -{ - m_notebook = notebook; - - m_notebook->SetTabView(this); - - SetWindow(m_notebook); -} - -wxNotebookTabView::~wxNotebookTabView(void) -{ -} - -int wxNotebookTabView::GetId(wxNotebookPage *page) -{ - int& id = m_pageToId[page]; - - if (!id) - { - id = m_nextid++; - m_idToPage[id] = page; - } - - return id; -} - -// Called when a tab is activated -void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId) -{ - if (!m_notebook) - return; - - wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId()); - - // Translate from wxTabView's ids (which aren't position-dependent) - // to wxNotebook's (which are). - wxNotebookPage* pActive = GetPage(activateId); - wxNotebookPage* pDeactive = GetPage(deactivateId); - - int activatePos = m_notebook->FindPagePosition(pActive); - int deactivatePos = m_notebook->FindPagePosition(pDeactive); - - event.SetEventObject(m_notebook); - event.SetSelection(activatePos); - event.SetOldSelection(deactivatePos); - m_notebook->GetEventHandler()->ProcessEvent(event); -} - -// Allows Vetoing -bool wxNotebookTabView::OnTabPreActivate(int activateId, int deactivateId) -{ - bool retval = true; - - if (m_notebook) - { - wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId()); - - // Translate from wxTabView's ids (which aren't position-dependent) - // to wxNotebook's (which are). - wxNotebookPage* pActive = GetPage(activateId); - wxNotebookPage* pDeactive = GetPage(deactivateId); - - int activatePos = m_notebook->FindPagePosition(pActive); - int deactivatePos = m_notebook->FindPagePosition(pDeactive); - - event.SetEventObject(m_notebook); - event.SetSelection(activatePos); - event.SetOldSelection(deactivatePos); - if (m_notebook->GetEventHandler()->ProcessEvent(event)) - { - retval = event.IsAllowed(); - } - } - return retval; -} - -#endif // wxUSE_NOTEBOOK diff --git a/Source/3rd Party/wx/src/generic/notifmsgg.cpp b/Source/3rd Party/wx/src/generic/notifmsgg.cpp deleted file mode 100644 index c941cfa39..000000000 --- a/Source/3rd Party/wx/src/generic/notifmsgg.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/notifmsgg.cpp -// Purpose: generic implementation of wxGenericNotificationMessage -// Author: Vadim Zeitlin -// Created: 2007-11-24 -// Copyright: (c) 2007 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef wxUSE_LIBHILDON - #define wxUSE_LIBHILDON 0 -#endif - -#ifndef wxUSE_LIBHILDON2 - #define wxUSE_LIBHILDON2 0 -#endif - -#if wxUSE_NOTIFICATION_MESSAGE && (!wxUSE_LIBHILDON || !wxUSE_LIBHILDON2) - -#ifndef WX_PRECOMP - #include "wx/dialog.h" - #include "wx/timer.h" - #include "wx/sizer.h" - #include "wx/statbmp.h" -#endif //WX_PRECOMP - -#include "wx/artprov.h" - -// even if the platform has the native implementation, we still normally want -// to use the generic one (unless it's totally unsuitable for the target UI as -// is the case of Hildon) because it may provide more features, so include -// wx/generic/notifmsg.h to get wxGenericNotificationMessage declaration even -// if wx/notifmsg.h only declares wxNotificationMessage itself (if it already -// uses the generic version, the second inclusion will do no harm) -#include "wx/notifmsg.h" -#include "wx/generic/notifmsg.h" - -// ---------------------------------------------------------------------------- -// wxNotificationMessageDialog -// ---------------------------------------------------------------------------- - -class wxNotificationMessageDialog : public wxDialog -{ -public: - wxNotificationMessageDialog(wxWindow *parent, - const wxString& text, - int timeout, - int flags); - - void Set(wxWindow *parent, - const wxString& text, - int timeout, - int flags); - - bool IsAutomatic() const { return m_timer.IsRunning(); } - void SetDeleteOnHide() { m_deleteOnHide = true; } - -private: - void OnClose(wxCloseEvent& event); - void OnTimer(wxTimerEvent& event); - - // if true, delete the dialog when it should disappear, otherwise just hide - // it (initially false) - bool m_deleteOnHide; - - // timer which will hide this dialog when it expires, if it's not running - // it means we were created without timeout - wxTimer m_timer; - - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxNotificationMessageDialog); -}; - -// ============================================================================ -// wxNotificationMessageDialog implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxNotificationMessageDialog, wxDialog) - EVT_CLOSE(wxNotificationMessageDialog::OnClose) - - EVT_TIMER(wxID_ANY, wxNotificationMessageDialog::OnTimer) -END_EVENT_TABLE() - -wxNotificationMessageDialog::wxNotificationMessageDialog(wxWindow *parent, - const wxString& text, - int timeout, - int flags) - : wxDialog(parent, wxID_ANY, _("Notice"), - wxDefaultPosition, wxDefaultSize, - 0 /* no caption, no border styles */), - m_timer(this) -{ - m_deleteOnHide = false; - - Set(parent, text, timeout, flags); -} - -void -wxNotificationMessageDialog::Set(wxWindow * WXUNUSED(parent), - const wxString& text, - int timeout, - int flags) -{ - wxSizer * const sizerTop = new wxBoxSizer(wxHORIZONTAL); - if ( flags & wxICON_MASK ) - { - sizerTop->Add(new wxStaticBitmap - ( - this, - wxID_ANY, - wxArtProvider::GetMessageBoxIcon(flags) - ), - wxSizerFlags().Centre().Border()); - } - - sizerTop->Add(CreateTextSizer(text), wxSizerFlags(1).Border()); - SetSizerAndFit(sizerTop); - - if ( timeout != wxGenericNotificationMessage::Timeout_Never ) - { - // wxTimer uses ms, timeout is in seconds - m_timer.Start(timeout*1000, true /* one shot only */); - } - else if ( m_timer.IsRunning() ) - { - m_timer.Stop(); - } -} - -void wxNotificationMessageDialog::OnClose(wxCloseEvent& event) -{ - if ( m_deleteOnHide ) - { - // we don't need to keep this dialog alive any more - Destroy(); - } - else // don't really close, just hide, as we can be shown again later - { - event.Veto(); - - Hide(); - } -} - -void wxNotificationMessageDialog::OnTimer(wxTimerEvent& WXUNUSED(event)) -{ - if ( m_deleteOnHide ) - Destroy(); - else - Hide(); -} - -// ============================================================================ -// wxGenericNotificationMessage implementation -// ============================================================================ - -int wxGenericNotificationMessage::ms_timeout = 10; - -/* static */ void wxGenericNotificationMessage::SetDefaultTimeout(int timeout) -{ - wxASSERT_MSG( timeout > 0, - "negative or zero default timeout doesn't make sense" ); - - ms_timeout = timeout; -} - -void wxGenericNotificationMessage::Init() -{ - m_dialog = NULL; -} - -wxGenericNotificationMessage::~wxGenericNotificationMessage() -{ - if ( m_dialog->IsAutomatic() ) - { - // we want to allow the user to create an automatically hidden - // notification just by creating a local wxGenericNotificationMessage object - // and so we shouldn't hide the notification when this object goes out - // of scope - m_dialog->SetDeleteOnHide(); - } - else // manual dialog, hide it immediately - { - // OTOH for permanently shown dialogs only the code can hide them and - // if the object is deleted, we must do it now as it won't be - // accessible programmatically any more - delete m_dialog; - } -} - -bool wxGenericNotificationMessage::Show(int timeout) -{ - if ( timeout == Timeout_Auto ) - { - timeout = GetDefaultTimeout(); - } - - if ( !m_dialog ) - { - m_dialog = new wxNotificationMessageDialog - ( - GetParent(), - GetFullMessage(), - timeout, - GetFlags() - ); - } - else // update the existing dialog - { - m_dialog->Set(GetParent(), GetFullMessage(), timeout, GetFlags()); - } - - m_dialog->Show(); - - return true; -} - -bool wxGenericNotificationMessage::Close() -{ - if ( !m_dialog ) - return false; - - m_dialog->Hide(); - - return true; -} - -#endif // wxUSE_NOTIFICATION_MESSAGE && (!wxUSE_LIBHILDON || !wxUSE_LIBHILDON2) diff --git a/Source/3rd Party/wx/src/generic/numdlgg.cpp b/Source/3rd Party/wx/src/generic/numdlgg.cpp index d3fb7be6a..38c1376d8 100644 --- a/Source/3rd Party/wx/src/generic/numdlgg.cpp +++ b/Source/3rd Party/wx/src/generic/numdlgg.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 23.07.99 +// RCS-ID: $Id: numdlgg.cpp 54861 2008-07-30 21:53:26Z VZ $ // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -76,8 +77,7 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent, long min, long max, const wxPoint& pos) - : wxDialog(GetParentForModalDialog(parent, 0), - wxID_ANY, caption, + : wxDialog(parent, wxID_ANY, caption, pos, wxDefaultSize) { m_value = value; @@ -134,7 +134,7 @@ void wxNumberEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { #if !wxUSE_SPINCTRL wxString tmp = m_spinctrl->GetValue(); - if ( wxSscanf(tmp, wxT("%ld"), &m_value) != 1 ) + if ( wxSscanf(tmp, _T("%ld"), &m_value) != 1 ) EndModal(wxID_CANCEL); else #else diff --git a/Source/3rd Party/wx/src/generic/odcombo.cpp b/Source/3rd Party/wx/src/generic/odcombo.cpp deleted file mode 100644 index d48bf5a08..000000000 --- a/Source/3rd Party/wx/src/generic/odcombo.cpp +++ /dev/null @@ -1,1208 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/odcombo.cpp -// Purpose: wxOwnerDrawnComboBox, wxVListBoxComboPopup -// Author: Jaakko Salli -// Modified by: -// Created: Apr-30-2006 -// Copyright: (c) 2005 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ODCOMBOBOX - -#include "wx/odcombo.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/combobox.h" - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/dialog.h" - #include "wx/textctrl.h" -#endif - -#include "wx/combo.h" - -// ============================================================================ -// implementation -// ============================================================================ - -// time in milliseconds before partial completion buffer drops -#define wxODCB_PARTIAL_COMPLETION_TIME 1000 - -// ---------------------------------------------------------------------------- -// wxVListBoxComboPopup is a wxVListBox customized to act as a popup control -// -// ---------------------------------------------------------------------------- - - -BEGIN_EVENT_TABLE(wxVListBoxComboPopup, wxVListBox) - EVT_MOTION(wxVListBoxComboPopup::OnMouseMove) - EVT_KEY_DOWN(wxVListBoxComboPopup::OnKey) - EVT_CHAR(wxVListBoxComboPopup::OnChar) - EVT_LEFT_UP(wxVListBoxComboPopup::OnLeftClick) -END_EVENT_TABLE() - - -void wxVListBoxComboPopup::Init() -{ - m_widestWidth = 0; - m_widestItem = -1; - m_widthsDirty = false; - m_findWidest = false; - m_itemHeight = 0; - m_value = -1; - m_itemHover = -1; - m_clientDataItemsType = wxClientData_None; - m_partialCompletionString = wxEmptyString; -} - -bool wxVListBoxComboPopup::Create(wxWindow* parent) -{ - if ( !wxVListBox::Create(parent, - wxID_ANY, - wxDefaultPosition, - wxDefaultSize, - wxBORDER_SIMPLE | wxLB_INT_HEIGHT | wxWANTS_CHARS) ) - return false; - - m_useFont = m_combo->GetFont(); - - wxVListBox::SetItemCount(m_strings.GetCount()); - - // TODO: Move this to SetFont - m_itemHeight = GetCharHeight() + 0; - - return true; -} - -wxVListBoxComboPopup::~wxVListBoxComboPopup() -{ - Clear(); -} - -void wxVListBoxComboPopup::SetFocus() -{ - // Suppress SetFocus() warning by simply not calling it. This combo popup - // has already been designed with the assumption that SetFocus() may not - // do anything useful, so it really doesn't need to be called. -#ifdef __WXMSW__ - // -#else - wxVListBox::SetFocus(); -#endif -} - -bool wxVListBoxComboPopup::LazyCreate() -{ - // NB: There is a bug with wxVListBox that can be avoided by creating - // it later (bug causes empty space to be shown if initial selection - // is at the end of a list longer than the control can show at once). - return true; -} - -// paint the control itself -void wxVListBoxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect ) -{ - if ( !(m_combo->GetWindowStyle() & wxODCB_STD_CONTROL_PAINT) ) - { - int flags = wxODCB_PAINTING_CONTROL; - - if ( m_combo->ShouldDrawFocus() ) - flags |= wxODCB_PAINTING_SELECTED; - - OnDrawBg(dc, rect, m_value, flags); - - if ( m_value >= 0 ) - { - OnDrawItem(dc,rect,m_value,flags); - return; - } - } - - wxComboPopup::PaintComboControl(dc,rect); -} - -void wxVListBoxComboPopup::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const -{ - // TODO: Maybe this code could be moved to wxVListBox::OnPaint? - dc.SetFont(m_useFont); - - int flags = 0; - - // Set correct text colour for selected items - if ( wxVListBox::GetSelection() == (int) n ) - { - dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) ); - flags |= wxODCB_PAINTING_SELECTED; - } - else - { - dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) ); - } - - OnDrawItem(dc,rect,(int)n,flags); -} - -wxCoord wxVListBoxComboPopup::OnMeasureItem(size_t n) const -{ - wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo; - - wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox), - wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") ); - - wxCoord h = combo->OnMeasureItem(n); - if ( h < 0 ) - h = m_itemHeight; - return h; -} - -wxCoord wxVListBoxComboPopup::OnMeasureItemWidth(size_t n) const -{ - wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo; - - wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox), - wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") ); - - return combo->OnMeasureItemWidth(n); -} - -void wxVListBoxComboPopup::OnDrawBg( wxDC& dc, - const wxRect& rect, - int item, - int flags ) const -{ - wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo; - - wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox), - wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") ); - - if ( IsCurrent((size_t)item) && !(flags & wxODCB_PAINTING_CONTROL) ) - flags |= wxODCB_PAINTING_SELECTED; - - combo->OnDrawBackground(dc,rect,item,flags); -} - -void wxVListBoxComboPopup::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const -{ - OnDrawBg(dc,rect,(int)n,0); -} - -// This is called from wxVListBoxComboPopup::OnDrawItem, with text colour and font prepared -void wxVListBoxComboPopup::OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const -{ - wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo; - - wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox), - wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") ); - - combo->OnDrawItem(dc,rect,item,flags); -} - -void wxVListBoxComboPopup::DismissWithEvent() -{ - StopPartialCompletion(); - - int selection = wxVListBox::GetSelection(); - - Dismiss(); - - if ( selection != wxNOT_FOUND ) - m_stringValue = m_strings[selection]; - else - m_stringValue = wxEmptyString; - - if ( m_stringValue != m_combo->GetValue() ) - m_combo->SetValueByUser(m_stringValue); - - m_value = selection; - - SendComboBoxEvent(selection); -} - -void wxVListBoxComboPopup::SendComboBoxEvent( int selection ) -{ - wxCommandEvent evt(wxEVT_COMBOBOX,m_combo->GetId()); - - evt.SetEventObject(m_combo); - - evt.SetInt(selection); - - // Set client data, if any - if ( selection >= 0 && (int)m_clientDatas.GetCount() > selection ) - { - void* clientData = m_clientDatas[selection]; - if ( m_clientDataItemsType == wxClientData_Object ) - evt.SetClientObject((wxClientData*)clientData); - else - evt.SetClientData(clientData); - } - - m_combo->GetEventHandler()->AddPendingEvent(evt); -} - -// returns true if key was consumed -bool wxVListBoxComboPopup::HandleKey( int keycode, bool saturate, wxChar keychar ) -{ - const int itemCount = GetCount(); - - // keys do nothing in the empty control and returning immediately avoids - // using invalid indices below - if ( !itemCount ) - return false; - - int value = m_value; - int comboStyle = m_combo->GetWindowStyle(); - - if ( keychar > 0 ) - { - // we have character equivalent of the keycode; filter out these that - // are not printable characters - if ( !wxIsprint(keychar) ) - keychar = 0; - } - - const bool readOnly = (comboStyle & wxCB_READONLY) != 0; - - if ( keycode == WXK_DOWN || keycode == WXK_NUMPAD_DOWN || ( keycode == WXK_RIGHT && readOnly ) ) - { - value++; - StopPartialCompletion(); - } - else if ( keycode == WXK_UP || keycode == WXK_NUMPAD_UP || ( keycode == WXK_LEFT && readOnly ) ) - { - value--; - StopPartialCompletion(); - } - else if ( keycode == WXK_PAGEDOWN || keycode == WXK_NUMPAD_PAGEDOWN ) - { - value+=10; - StopPartialCompletion(); - } - else if ( keycode == WXK_PAGEUP || keycode == WXK_NUMPAD_PAGEUP ) - { - value-=10; - StopPartialCompletion(); - } - else if ( ( keycode == WXK_HOME || keycode == WXK_NUMPAD_HOME ) && readOnly ) - { - value=0; - StopPartialCompletion(); - } - else if ( ( keycode == WXK_END || keycode == WXK_NUMPAD_END ) && readOnly ) - { - value=itemCount-1; - StopPartialCompletion(); - } - else if ( keychar && readOnly ) - { - // Try partial completion - - // find the new partial completion string -#if wxUSE_TIMER - if (m_partialCompletionTimer.IsRunning()) - m_partialCompletionString+=wxString(keychar); - else -#endif // wxUSE_TIMER - m_partialCompletionString=wxString(keychar); - - // now search through the values to see if this is found - int found = -1; - unsigned int length=m_partialCompletionString.length(); - int i; - for (i=0; i= length) && (! m_partialCompletionString.CmpNoCase(item.Left(length)))) - { - found=i; - break; - } - } - - if (found<0) - { - StopPartialCompletion(); - ::wxBell(); - return true; // to stop the first value being set - } - else - { - value=i; -#if wxUSE_TIMER - m_partialCompletionTimer.Start(wxODCB_PARTIAL_COMPLETION_TIME, true); -#endif // wxUSE_TIMER - } - } - else - return false; - - if ( saturate ) - { - if ( value >= itemCount ) - value = itemCount - 1; - else if ( value < 0 ) - value = 0; - } - else - { - if ( value >= itemCount ) - value -= itemCount; - else if ( value < 0 ) - value += itemCount; - } - - if ( value == m_value ) - // Even if value was same, don't skip the event - // (good for consistency) - return true; - - if ( value >= 0 ) - m_combo->ChangeValue(m_strings[value]); - - // The m_combo->SetValue() call above sets m_value to the index of this - // string. But if there are more identical string, the index is of the - // first occurrence, which may be wrong, so set the index explicitly here, - // _after_ the SetValue() call. - m_value = value; - - SendComboBoxEvent(m_value); - - return true; -} - -// stop partial completion -void wxVListBoxComboPopup::StopPartialCompletion() -{ - m_partialCompletionString = wxEmptyString; -#if wxUSE_TIMER - m_partialCompletionTimer.Stop(); -#endif // wxUSE_TIMER -} - -void wxVListBoxComboPopup::OnComboDoubleClick() -{ - // Cycle on dclick (disable saturation to allow true cycling). - if ( !::wxGetKeyState(WXK_SHIFT) ) - HandleKey(WXK_DOWN,false); - else - HandleKey(WXK_UP,false); -} - -void wxVListBoxComboPopup::OnComboKeyEvent( wxKeyEvent& event ) -{ - // Saturated key movement on - if ( !HandleKey(event.GetKeyCode(), true) ) - event.Skip(); -} - -void wxVListBoxComboPopup::OnComboCharEvent( wxKeyEvent& event ) -{ - // unlike in OnComboKeyEvent, wxEVT_CHAR contains meaningful - // printable character information, so pass it -#if wxUSE_UNICODE - const wxChar charcode = event.GetUnicodeKey(); -#else - const wxChar charcode = (wxChar)event.GetKeyCode(); -#endif - - if ( !HandleKey(event.GetKeyCode(), true, charcode) ) - event.Skip(); -} - -void wxVListBoxComboPopup::OnPopup() -{ - // *must* set value after size is set (this is because of a vlbox bug) - wxVListBox::SetSelection(m_value); -} - -void wxVListBoxComboPopup::OnMouseMove(wxMouseEvent& event) -{ - event.Skip(); - - // Move selection to cursor if it is inside the popup - - int y = event.GetPosition().y; - int fromBottom = GetClientSize().y - y; - - // Since in any case we need to find out if the last item is only - // partially visible, we might just as well replicate the HitTest - // loop here. - const size_t lineMax = GetVisibleEnd(); - for ( size_t line = GetVisibleBegin(); line < lineMax; line++ ) - { - y -= OnGetRowHeight(line); - if ( y < 0 ) - { - // Only change selection if item is fully visible - if ( (y + fromBottom) >= 0 ) - { - wxVListBox::SetSelection((int)line); - return; - } - } - } -} - -void wxVListBoxComboPopup::OnLeftClick(wxMouseEvent& WXUNUSED(event)) -{ - DismissWithEvent(); -} - -void wxVListBoxComboPopup::OnKey(wxKeyEvent& event) -{ - // Hide popup if certain key or key combination was pressed - if ( m_combo->IsKeyPopupToggle(event) ) - { - StopPartialCompletion(); - Dismiss(); - } - else if ( event.AltDown() ) - { - // On both wxGTK and wxMSW, pressing Alt down seems to - // completely freeze things in popup (ie. arrow keys and - // enter won't work). - return; - } - // Select item if ENTER is pressed - else if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER ) - { - DismissWithEvent(); - } - else - { - // completion is handled in OnChar() below - event.Skip(); - } -} - -void wxVListBoxComboPopup::OnChar(wxKeyEvent& event) -{ - if ( m_combo->GetWindowStyle() & wxCB_READONLY ) - { - // Process partial completion key codes here, but not the arrow keys as - // the base class will do that for us -#if wxUSE_UNICODE - const wxChar charcode = event.GetUnicodeKey(); -#else - const wxChar charcode = (wxChar)event.GetKeyCode(); -#endif - if ( wxIsprint(charcode) ) - { - OnComboCharEvent(event); - SetSelection(m_value); // ensure the highlight bar moves - return; // don't skip the event - } - } - - event.Skip(); -} - -void wxVListBoxComboPopup::Insert( const wxString& item, int pos ) -{ - // Need to change selection? - wxString strValue; - if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) && - m_combo->GetValue() == item ) - { - m_value = pos; - } - - m_strings.Insert(item,pos); - if ( (int)m_clientDatas.size() >= pos ) - m_clientDatas.Insert(NULL, pos); - - m_widths.Insert(-1,pos); - m_widthsDirty = true; - - if ( IsCreated() ) - wxVListBox::SetItemCount( wxVListBox::GetItemCount()+1 ); -} - -int wxVListBoxComboPopup::Append(const wxString& item) -{ - int pos = (int)m_strings.GetCount(); - - if ( m_combo->GetWindowStyle() & wxCB_SORT ) - { - // Find position - // TODO: Could be optimized with binary search - wxArrayString strings = m_strings; - unsigned int i; - - for ( i=0; i n ) - return m_clientDatas[n]; - - return NULL; -} - -void wxVListBoxComboPopup::Delete( unsigned int item ) -{ - // Remove client data, if set - if ( m_clientDatas.GetCount() ) - { - if ( m_clientDataItemsType == wxClientData_Object ) - delete (wxClientData*) m_clientDatas[item]; - - m_clientDatas.RemoveAt(item); - } - - m_strings.RemoveAt(item); - m_widths.RemoveAt(item); - - if ( (int)item == m_widestItem ) - m_findWidest = true; - - int sel = GetSelection(); - - if ( IsCreated() ) - wxVListBox::SetItemCount( wxVListBox::GetItemCount()-1 ); - - // Fix selection - if ( (int)item < sel ) - SetSelection(sel-1); - else if ( (int)item == sel ) - SetSelection(wxNOT_FOUND); -} - -int wxVListBoxComboPopup::FindString(const wxString& s, bool bCase) const -{ - return m_strings.Index(s, bCase); -} - -bool wxVListBoxComboPopup::FindItem(const wxString& item, wxString* trueItem) -{ - int idx = m_strings.Index(item, false); - if ( idx == wxNOT_FOUND ) - return false; - if ( trueItem != NULL ) - *trueItem = m_strings[idx]; - return true; -} - -unsigned int wxVListBoxComboPopup::GetCount() const -{ - return m_strings.GetCount(); -} - -wxString wxVListBoxComboPopup::GetString( int item ) const -{ - return m_strings[item]; -} - -void wxVListBoxComboPopup::SetString( int item, const wxString& str ) -{ - m_strings[item] = str; - ItemWidthChanged(item); -} - -wxString wxVListBoxComboPopup::GetStringValue() const -{ - return m_stringValue; -} - -void wxVListBoxComboPopup::SetSelection( int item ) -{ - wxCHECK_RET( item == wxNOT_FOUND || ((unsigned int)item < GetCount()), - wxT("invalid index in wxVListBoxComboPopup::SetSelection") ); - - m_value = item; - - if ( item >= 0 ) - m_stringValue = m_strings[item]; - else - m_stringValue = wxEmptyString; - - if ( IsCreated() ) - wxVListBox::SetSelection(item); -} - -int wxVListBoxComboPopup::GetSelection() const -{ - return m_value; -} - -void wxVListBoxComboPopup::SetStringValue( const wxString& value ) -{ - int index = m_strings.Index(value); - - m_stringValue = value; - - if ( index >= 0 && index < (int)wxVListBox::GetItemCount() ) - { - wxVListBox::SetSelection(index); - m_value = index; - } -} - -void wxVListBoxComboPopup::CalcWidths() -{ - bool doFindWidest = m_findWidest; - - // Measure items with dirty width. - if ( m_widthsDirty ) - { - unsigned int i; - unsigned int n = m_widths.GetCount(); - int dirtyHandled = 0; - wxArrayInt& widths = m_widths; - - // I think using wxDC::GetTextExtent is faster than - // wxWindow::GetTextExtent (assuming same dc is used - // for all calls, as we do here). - wxClientDC dc(m_combo); - if ( !m_useFont.IsOk() ) - m_useFont = m_combo->GetFont(); - dc.SetFont(m_useFont); - - for ( i=0; i= m_widestWidth ) - { - m_widestWidth = x; - m_widestItem = (int)i; - } - else if ( (int)i == m_widestItem ) - { - // Width of previously widest item has been decreased, so - // we'll have to check all to find current widest item. - doFindWidest = true; - } - - dirtyHandled++; - } - } - - m_widthsDirty = false; - } - - if ( doFindWidest ) - { - unsigned int i; - unsigned int n = m_widths.GetCount(); - - int bestWidth = -1; - int bestIndex = -1; - - for ( i=0; i bestWidth ) - { - bestIndex = (int)i; - bestWidth = w; - } - } - - m_widestWidth = bestWidth; - m_widestItem = bestIndex; - - m_findWidest = false; - } -} - -wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int maxHeight ) -{ - int height = 250; - - maxHeight -= 2; // Must take borders into account - - if ( m_strings.GetCount() ) - { - if ( prefHeight > 0 ) - height = prefHeight; - - if ( height > maxHeight ) - height = maxHeight; - - int totalHeight = GetTotalHeight(); // + 3; - - // Take borders into account on Mac or scrollbars always appear -#if defined(__WXMAC__) - totalHeight += 2; -#endif - if ( height >= totalHeight ) - { - height = totalHeight; - } - else - { - // Adjust height to a multiple of the height of the first item - // NB: Calculations that take variable height into account - // are unnecessary. - int fih = GetLineHeight(0); - height -= height % fih; - } - } - else - height = 50; - - CalcWidths(); - - // Take scrollbar into account in width calculations - int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - return wxSize(minWidth > widestWidth ? minWidth : widestWidth, - height+2); -} - -//void wxVListBoxComboPopup::Populate( int n, const wxString choices[] ) -void wxVListBoxComboPopup::Populate( const wxArrayString& choices ) -{ - int i; - - int n = choices.GetCount(); - - for ( i=0; iGetWindowStyle() & wxCB_SORT ) - m_strings.Sort(); - - // Find initial selection - wxString strValue = m_combo->GetValue(); - if ( !strValue.empty() ) - m_value = m_strings.Index(strValue); -} - -// ---------------------------------------------------------------------------- -// wxOwnerDrawnComboBox -// ---------------------------------------------------------------------------- - - -BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboCtrl) -END_EVENT_TABLE() - -void wxOwnerDrawnComboBox::Init() -{ -} - -bool wxOwnerDrawnComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) -{ - return wxComboCtrl::Create(parent,id,value,pos,size,style,validator,name); -} - -wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) -{ - Init(); - - Create(parent,id,value,pos,size,choices,style, validator, name); -} - -bool wxOwnerDrawnComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) -{ - m_initChs = choices; - //wxCArrayString chs(choices); - - //return Create(parent, id, value, pos, size, chs.GetCount(), - // chs.GetStrings(), style, validator, name); - return Create(parent, id, value, pos, size, 0, - NULL, style, validator, name); -} - -bool wxOwnerDrawnComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style, - const wxValidator& validator, - const wxString& name) -{ - - if ( !Create(parent, id, value, pos, size, style, - validator, name) ) - { - return false; - } - - int i; - for ( i=0; iClearClientDatas(); -} - -void wxOwnerDrawnComboBox::DoSetPopupControl(wxComboPopup* popup) -{ - if ( !popup ) - { - popup = new wxVListBoxComboPopup(); - } - - wxComboCtrl::DoSetPopupControl(popup); - - wxASSERT(popup); - - // Add initial choices to the wxVListBox - if ( !GetVListBoxComboPopup()->GetCount() ) - { - GetVListBoxComboPopup()->Populate(m_initChs); - m_initChs.Clear(); - } -} - -// ---------------------------------------------------------------------------- -// wxOwnerDrawnComboBox item manipulation methods -// ---------------------------------------------------------------------------- - -void wxOwnerDrawnComboBox::DoClear() -{ - EnsurePopupControl(); - - GetVListBoxComboPopup()->Clear(); - - // NB: This really needs to be SetValue() instead of ChangeValue(), - // as wxTextEntry API expects an event to be sent. - SetValue(wxEmptyString); -} - -void wxOwnerDrawnComboBox::Clear() -{ - DoClear(); -} - -void wxOwnerDrawnComboBox::DoDeleteOneItem(unsigned int n) -{ - wxCHECK_RET( IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::Delete") ); - - if ( GetSelection() == (int) n ) - ChangeValue(wxEmptyString); - - GetVListBoxComboPopup()->Delete(n); -} - -unsigned int wxOwnerDrawnComboBox::GetCount() const -{ - if ( !m_popupInterface ) - return m_initChs.GetCount(); - - return GetVListBoxComboPopup()->GetCount(); -} - -wxString wxOwnerDrawnComboBox::GetString(unsigned int n) const -{ - wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxOwnerDrawnComboBox::GetString") ); - - if ( !m_popupInterface ) - return m_initChs.Item(n); - - return GetVListBoxComboPopup()->GetString(n); -} - -void wxOwnerDrawnComboBox::SetString(unsigned int n, const wxString& s) -{ - EnsurePopupControl(); - - wxCHECK_RET( IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::SetString") ); - - GetVListBoxComboPopup()->SetString(n,s); -} - -int wxOwnerDrawnComboBox::FindString(const wxString& s, bool bCase) const -{ - if ( !m_popupInterface ) - return m_initChs.Index(s, bCase); - - return GetVListBoxComboPopup()->FindString(s, bCase); -} - -void wxOwnerDrawnComboBox::Select(int n) -{ - EnsurePopupControl(); - - wxCHECK_RET( (n == wxNOT_FOUND) || IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::Select") ); - - GetVListBoxComboPopup()->SetSelection(n); - - wxString str; - if ( n >= 0 ) - str = GetVListBoxComboPopup()->GetString(n); - - // Refresh text portion in control - if ( m_text ) - m_text->ChangeValue( str ); - else - m_valueString = str; - - Refresh(); -} - -int wxOwnerDrawnComboBox::GetSelection() const -{ - if ( !m_popupInterface ) - return m_initChs.Index(m_valueString); - - return GetVListBoxComboPopup()->GetSelection(); -} - -void wxOwnerDrawnComboBox::GetSelection(long *from, long *to) const -{ - wxComboCtrl::GetSelection(from, to); -} - -int wxOwnerDrawnComboBox::DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) -{ - EnsurePopupControl(); - - const unsigned int count = items.GetCount(); - - if ( HasFlag(wxCB_SORT) ) - { - int n = pos; - - for ( unsigned int i = 0; i < count; ++i ) - { - n = GetVListBoxComboPopup()->Append(items[i]); - AssignNewItemClientData(n, clientData, i, type); - } - - return n; - } - else - { - for ( unsigned int i = 0; i < count; ++i, ++pos ) - { - GetVListBoxComboPopup()->Insert(items[i], pos); - AssignNewItemClientData(pos, clientData, i, type); - } - - return pos - 1; - } -} - -void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData) -{ - EnsurePopupControl(); - - GetVListBoxComboPopup()->SetItemClientData(n, clientData, - GetClientDataType()); -} - -void* wxOwnerDrawnComboBox::DoGetItemClientData(unsigned int n) const -{ - if ( !m_popupInterface ) - return NULL; - - return GetVListBoxComboPopup()->GetItemClientData(n); -} - -// ---------------------------------------------------------------------------- -// wxOwnerDrawnComboBox item drawing and measuring default implementations -// ---------------------------------------------------------------------------- - -void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc, - const wxRect& rect, - int item, - int flags ) const -{ - if ( flags & wxODCB_PAINTING_CONTROL ) - { - wxString text; - - if ( !ShouldUseHintText() ) - { - text = GetValue(); - } - else - { - text = GetHint(); - wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - dc.SetTextForeground(col); - } - - dc.DrawText( text, - rect.x + GetMargins().x, - (rect.height-dc.GetCharHeight())/2 + rect.y ); - } - else - { - dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2, rect.y ); - } -} - -wxCoord wxOwnerDrawnComboBox::OnMeasureItem( size_t WXUNUSED(item) ) const -{ - return -1; -} - -wxCoord wxOwnerDrawnComboBox::OnMeasureItemWidth( size_t WXUNUSED(item) ) const -{ - return -1; -} - -wxSize wxOwnerDrawnComboBox::DoGetBestSize() const -{ - if ( GetCount() == 0 ) - return wxComboCtrlBase::DoGetBestSize(); - - wxOwnerDrawnComboBox* odc = const_cast(this); - // TODO: this class may also have GetHightestItemHeight() and - // GetHightestItem() methods, and so set the whole (edit part + arrow) - // control's height according with this max height, not only max width. - return GetSizeFromTextSize(odc->GetWidestItemWidth()); -} - -void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc, - const wxRect& rect, - int WXUNUSED(item), - int flags) const -{ - // We need only to explicitly draw background for items - // that should have selected background. Also, call PrepareBackground - // always when painting the control so that clipping is done properly. - - if ( (flags & wxODCB_PAINTING_SELECTED) || - ((flags & wxODCB_PAINTING_CONTROL) && HasFlag(wxCB_READONLY)) ) - { - int bgFlags = wxCONTROL_SELECTED; - - if ( !(flags & wxODCB_PAINTING_CONTROL) ) - bgFlags |= wxCONTROL_ISSUBMENU; - - PrepareBackground(dc, rect, bgFlags); - } -} - -#endif // wxUSE_ODCOMBOBOX diff --git a/Source/3rd Party/wx/src/generic/paletteg.cpp b/Source/3rd Party/wx/src/generic/paletteg.cpp deleted file mode 100644 index 746f3cedc..000000000 --- a/Source/3rd Party/wx/src/generic/paletteg.cpp +++ /dev/null @@ -1,157 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/paletteg.cpp -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Copyright: (c) 1998 Robert Roebling and Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#if wxUSE_PALETTE - -#include "wx/palette.h" - -//----------------------------------------------------------------------------- -// wxPalette -//----------------------------------------------------------------------------- - -struct wxPaletteEntry -{ - unsigned char red, green, blue; -}; - -class wxPaletteRefData : public wxGDIRefData -{ -public: - wxPaletteRefData(); - wxPaletteRefData(const wxPaletteRefData& palette); - virtual ~wxPaletteRefData(); - - int m_count; - wxPaletteEntry *m_entries; -}; - -wxPaletteRefData::wxPaletteRefData() -{ - m_count = 0; - m_entries = NULL; -} - -wxPaletteRefData::wxPaletteRefData(const wxPaletteRefData& palette) -{ - m_count = palette.m_count; - m_entries = new wxPaletteEntry[m_count]; - for ( int i = 0; i < m_count; i++ ) - m_entries[i] = palette.m_entries[i]; -} - -wxPaletteRefData::~wxPaletteRefData() -{ - delete[] m_entries; -} - -//----------------------------------------------------------------------------- - -#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) - -IMPLEMENT_DYNAMIC_CLASS(wxPalette,wxGDIObject) - -wxPalette::wxPalette() -{ - m_refData = NULL; -} - -wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) -{ - Create(n, red, green, blue); -} - -wxPalette::~wxPalette() -{ -} - -int wxPalette::GetColoursCount() const -{ - if (m_refData) - return M_PALETTEDATA->m_count; - - return 0; -} - -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_entries = new wxPaletteEntry[n]; - - wxPaletteEntry *e = M_PALETTEDATA->m_entries; - for (int i = 0; i < n; i++, e++) - { - e->red = red[i]; - e->green = green[i]; - e->blue = blue[i]; - } - - return true; -} - -int wxPalette::GetPixel( unsigned char red, - unsigned char green, - unsigned char blue ) const -{ - if (!m_refData) return wxNOT_FOUND; - - int closest = 0; - double d,distance = 1000.0; // max. dist is 256 - - wxPaletteEntry *e = M_PALETTEDATA->m_entries; - for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++) - { - if ((d = 0.299 * abs(red - e->red) + - 0.587 * abs(green - e->green) + - 0.114 * abs(blue - e->blue)) < distance) { - distance = d; - closest = i; - } - } - return closest; -} - -bool wxPalette::GetRGB(int pixel, - unsigned char *red, - unsigned char *green, - unsigned char *blue) const -{ - if (!m_refData) return false; - if (pixel >= M_PALETTEDATA->m_count) return false; - - wxPaletteEntry& p = M_PALETTEDATA->m_entries[pixel]; - if (red) *red = p.red; - if (green) *green = p.green; - if (blue) *blue = p.blue; - return true; -} - -wxGDIRefData *wxPalette::CreateGDIRefData() const -{ - return new wxPaletteRefData; -} - -wxGDIRefData *wxPalette::CloneGDIRefData(const wxGDIRefData *data) const -{ - return new wxPaletteRefData(*static_cast(data)); -} - -#endif // wxUSE_PALETTE diff --git a/Source/3rd Party/wx/src/common/panelcmn.cpp b/Source/3rd Party/wx/src/generic/panelg.cpp similarity index 56% rename from Source/3rd Party/wx/src/common/panelcmn.cpp rename to Source/3rd Party/wx/src/generic/panelg.cpp index c12e1950a..cd4dbee65 100644 --- a/Source/3rd Party/wx/src/common/panelcmn.cpp +++ b/Source/3rd Party/wx/src/generic/panelg.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/panelcmn.cpp -// Purpose: wxPanel common code +// Name: src/generic/panelg.cpp +// Purpose: wxPanel and the keyboard handling code // Author: Julian Smart, Robert Roebling, Vadim Zeitlin // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: panelg.cpp 40307 2006-07-25 01:31:13Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -34,10 +35,12 @@ #endif // ---------------------------------------------------------------------------- -// XTI +// wxWin macros // ---------------------------------------------------------------------------- -wxDEFINE_FLAGS( wxPanelStyle ) +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxPanelStyle ) + wxBEGIN_FLAGS( wxPanelStyle ) // new style border flags, we put them first to // use them for streaming out @@ -62,41 +65,54 @@ wxBEGIN_FLAGS( wxPanelStyle ) wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) wxFLAGS_MEMBER(wxWANTS_CHARS) wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) wxFLAGS_MEMBER(wxVSCROLL) wxFLAGS_MEMBER(wxHSCROLL) + wxEND_FLAGS( wxPanelStyle ) -wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow, "wx/panel.h") +IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h") wxBEGIN_PROPERTIES_TABLE(wxPanel) - wxPROPERTY_FLAGS( WindowStyle, wxPanelStyle, long, \ - SetWindowStyleFlag, GetWindowStyleFlag, \ - wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ - wxT("Helpstring"), wxT("group")) // style - // style wxTAB_TRAVERSAL + wxPROPERTY_FLAGS( WindowStyle , wxPanelStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +// style wxTAB_TRAVERSAL wxEND_PROPERTIES_TABLE() -wxEMPTY_HANDLERS_TABLE(wxPanel) +wxBEGIN_HANDLERS_TABLE(wxPanel) +wxEND_HANDLERS_TABLE() -wxCONSTRUCTOR_6( wxPanel, wxWindow*, Parent, wxWindowID, Id, \ - wxPoint, Position, wxSize, Size, long, WindowStyle, \ - wxString, Name) +wxCONSTRUCTOR_5( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) +#else +IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) +#endif + +BEGIN_EVENT_TABLE(wxPanel, wxWindow) + EVT_SIZE(wxPanel::OnSize) + + WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) +END_EVENT_TABLE() // ============================================================================ // implementation // ============================================================================ +WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, wxWindow) + // ---------------------------------------------------------------------------- -// wxPanelBase creation +// wxPanel creation // ---------------------------------------------------------------------------- -bool wxPanelBase::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) +void wxPanel::Init() +{ + m_container.SetContainerWindow(this); +} + +bool wxPanel::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) { if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; @@ -112,9 +128,53 @@ bool wxPanelBase::Create(wxWindow *parent, wxWindowID id, return true; } -void wxPanelBase::InitDialog() +wxPanel::~wxPanel() +{ +} + +void wxPanel::InitDialog() { wxInitDialogEvent event(GetId()); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); } + +// ---------------------------------------------------------------------------- +// event handlers +// ---------------------------------------------------------------------------- + +void wxPanel::OnSize(wxSizeEvent& event) +{ + if (GetAutoLayout()) + Layout(); +#if wxUSE_CONSTRAINTS +#if defined(__WXPM__) && 0 + else + { + // Need to properly move child windows under OS/2 + + PSWP pWinSwp = GetSwp(); + + if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0) + { + // Uninitialized + + ::WinQueryWindowPos(GetHWND(), pWinSwp); + } + else + { + SWP vSwp; + int nYDiff; + + ::WinQueryWindowPos(GetHWND(), &vSwp); + nYDiff = pWinSwp->cy - vSwp.cy; + MoveChildren(nYDiff); + pWinSwp->cx = vSwp.cx; + pWinSwp->cy = vSwp.cy; + } + } +#endif +#endif // wxUSE_CONSTRAINTS + + event.Skip(); +} diff --git a/Source/3rd Party/wx/src/generic/preferencesg.cpp b/Source/3rd Party/wx/src/generic/preferencesg.cpp deleted file mode 100644 index 45b311de6..000000000 --- a/Source/3rd Party/wx/src/generic/preferencesg.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/preferencesg.cpp -// Purpose: Implementation of wxPreferencesEditor. -// Author: Vaclav Slavik -// Created: 2013-02-19 -// Copyright: (c) 2013 Vaclav Slavik -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_PREFERENCES_EDITOR - -#include "wx/private/preferences.h" - -#ifndef wxHAS_PREF_EDITOR_NATIVE - -#include "wx/app.h" -#include "wx/dialog.h" -#include "wx/notebook.h" -#include "wx/sizer.h" -#include "wx/sharedptr.h" -#include "wx/scopedptr.h" -#include "wx/scopeguard.h" -#include "wx/vector.h" - -namespace -{ - -class wxGenericPrefsDialog : public wxDialog -{ -public: - wxGenericPrefsDialog(wxWindow *parent, const wxString& title) - : wxDialog(parent, wxID_ANY, title, - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)) - { - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); - - wxSizer *sizer = new wxBoxSizer(wxVERTICAL); - - m_notebook = new wxNotebook(this, wxID_ANY); - sizer->Add(m_notebook, wxSizerFlags(1).Expand().DoubleBorder()); - -#ifdef __WXGTK__ - SetEscapeId(wxID_CLOSE); - sizer->Add(CreateButtonSizer(wxCLOSE), wxSizerFlags().Expand().DoubleBorder(wxBOTTOM)); -#else - sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), - wxSizerFlags().Expand().DoubleBorder(wxLEFT|wxRIGHT|wxBOTTOM)); -#endif - SetSizer(sizer); - } - - void AddPage(wxPreferencesPage *page) - { - wxWindow *win = page->CreateWindow(m_notebook); - m_notebook->AddPage(win, page->GetName()); - } - - int GetSelectedPage() const - { - return m_notebook->GetSelection(); - } - - void SelectPage(int page) - { - m_notebook->ChangeSelection(page); - } - - bool ShouldPreventAppExit() const - { - return false; - } - -private: - wxNotebook *m_notebook; -}; - - -class wxGenericPreferencesEditorImplBase : public wxPreferencesEditorImpl -{ -public: - void SetTitle(const wxString& title) - { - m_title = title; - } - - virtual void AddPage(wxPreferencesPage* page) - { - m_pages.push_back(wxSharedPtr(page)); - } - -protected: - wxGenericPrefsDialog *CreateDialog(wxWindow *parent) - { - if ( m_title.empty() ) - { - // Use the default title, which should include the application name - // under both MSW and GTK (and OSX uses its own native - // implementation anyhow). - m_title.Printf(_("%s Preferences"), wxTheApp->GetAppDisplayName()); - } - - wxGenericPrefsDialog *dlg = new wxGenericPrefsDialog(parent, m_title); - - // TODO: Don't create all pages immediately like this, do it on demand - // when a page is selected in the notebook (as is done on OS X). - // - // Currently, creating all pages is necessary so that the notebook - // can determine its best size. We'll need to extend - // wxPreferencesPage with a GetBestSize() virtual method to make - // it possible to defer the creation. - for ( Pages::const_iterator i = m_pages.begin(); - i != m_pages.end(); - ++i ) - { - dlg->AddPage(i->get()); - } - - dlg->Fit(); - - return dlg; - } - - typedef wxVector< wxSharedPtr > Pages; - Pages m_pages; - -private: - wxString m_title; -}; - - -#ifdef wxHAS_PREF_EDITOR_MODELESS - -class wxModelessPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase -{ -public: - virtual ~wxModelessPreferencesEditorImpl() - { - // m_win may already be destroyed if this destructor is called from - // wxApp's destructor. In that case, all windows -- including this - // one -- would already be destroyed by now. - if ( m_win ) - m_win->Destroy(); - } - - virtual void Show(wxWindow* parent) - { - if ( !m_win ) - { - wxWindow *win = CreateDialog(parent); - win->Show(); - m_win = win; - } - else - { - // Ideally, we'd reparent the dialog under 'parent', but it's - // probably not worth the hassle. We know the old parent is still - // valid, because otherwise Dismiss() would have been called and - // m_win cleared. - m_win->Raise(); - } - } - - virtual void Dismiss() - { - if ( m_win ) - { - m_win->Close(/*force=*/true); - m_win = NULL; - } - } - -private: - wxWeakRef m_win; -}; - -inline -wxGenericPreferencesEditorImplBase* NewGenericImpl() -{ - return new wxModelessPreferencesEditorImpl; -} - -#else // !wxHAS_PREF_EDITOR_MODELESS - -class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase -{ -public: - wxModalPreferencesEditorImpl() - { - m_dlg = NULL; - m_currentPage = -1; - } - - virtual void Show(wxWindow* parent) - { - wxScopedPtr dlg(CreateDialog(parent)); - - // Store it for Dismiss() but ensure that the pointer is reset to NULL - // when the dialog is destroyed on leaving this function. - m_dlg = dlg.get(); - wxON_BLOCK_EXIT_NULL(m_dlg); - - // Restore the previously selected page, if any. - if ( m_currentPage != -1 ) - dlg->SelectPage(m_currentPage); - - // Don't remember the last selected page if the dialog was cancelled. - if ( dlg->ShowModal() != wxID_CANCEL ) - m_currentPage = dlg->GetSelectedPage(); - } - - virtual void Dismiss() - { - if ( m_dlg ) - { - m_dlg->EndModal(wxID_CANCEL); - m_dlg = NULL; - } - } - -private: - wxGenericPrefsDialog* m_dlg; - int m_currentPage; - - wxDECLARE_NO_COPY_CLASS(wxModalPreferencesEditorImpl); -}; - -inline -wxGenericPreferencesEditorImplBase* NewGenericImpl() -{ - return new wxModalPreferencesEditorImpl; -} - -#endif // !wxHAS_PREF_EDITOR_MODELESS - -} // anonymous namespace - -/*static*/ -wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create(const wxString& title) -{ - wxGenericPreferencesEditorImplBase* const impl = NewGenericImpl(); - - impl->SetTitle(title); - - return impl; -} - -#endif // !wxHAS_PREF_EDITOR_NATIVE - -#endif // wxUSE_PREFERENCES_EDITOR diff --git a/Source/3rd Party/wx/src/generic/printps.cpp b/Source/3rd Party/wx/src/generic/printps.cpp index 0f3b9aabc..fafc3d8f1 100644 --- a/Source/3rd Party/wx/src/generic/printps.cpp +++ b/Source/3rd Party/wx/src/generic/printps.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: printps.cpp 42522 2006-10-27 13:07:40Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -39,7 +40,7 @@ #include "wx/generic/printps.h" #include "wx/printdlg.h" #include "wx/generic/prntdlgg.h" -#include "wx/progdlg.h" +#include "wx/generic/progdlgg.h" #include "wx/paper.h" #include @@ -71,7 +72,7 @@ wxPostScriptPrinter::~wxPostScriptPrinter() bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; - sm_abortWindow = NULL; + sm_abortWindow = (wxWindow *) NULL; if (!printout) { @@ -79,6 +80,8 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro return false; } + printout->SetIsPreview(false); + if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) @@ -98,7 +101,7 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro } // May have pressed cancel. - if (!dc || !dc->IsOk()) + if (!dc || !dc->Ok()) { if (dc) delete dc; sm_lastError = wxPRINTER_ERROR; @@ -110,8 +113,8 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); - printout->SetPPIPrinter( dc->GetResolution(), - dc->GetResolution() ); + printout->SetPPIPrinter( wxPostScriptDC::GetResolution(), + wxPostScriptDC::GetResolution() ); // Set printout parameters printout->SetDC(dc); @@ -229,7 +232,7 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro wxDC* wxPostScriptPrinter::PrintDialog(wxWindow *parent) { - wxDC* dc = NULL; + wxDC* dc = (wxDC*) NULL; wxGenericPrintDialog dialog( parent, &m_printDialogData ); if (dialog.ShowModal() == wxID_OK) @@ -329,20 +332,16 @@ void wxPostScriptPrintPreview::DetermineScaling() if (paper) { - int resolution = 600; // TODO, this is correct, but get this from wxPSDC somehow + wxSize ScreenPixels = wxGetDisplaySize(); + wxSize ScreenMM = wxGetDisplaySizeMM(); - const wxSize screenPPI = wxGetDisplayPPI(); - int logPPIScreenX = screenPPI.GetWidth(); - int logPPIScreenY = screenPPI.GetHeight(); - int logPPIPrinterX = resolution; - int logPPIPrinterY = resolution; - - m_previewPrintout->SetPPIScreen( logPPIScreenX, logPPIScreenY ); - m_previewPrintout->SetPPIPrinter( logPPIPrinterX, logPPIPrinterY ); + m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), + (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); + m_previewPrintout->SetPPIPrinter(wxPostScriptDC::GetResolution(), wxPostScriptDC::GetResolution()); wxSize sizeDevUnits(paper->GetSizeDeviceUnits()); - sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * resolution / 72.0); - sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * resolution / 72.0); + sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * wxPostScriptDC::GetResolution() / 72.0); + sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * wxPostScriptDC::GetResolution() / 72.0); wxSize sizeTenthsMM(paper->GetSize()); wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10); @@ -363,8 +362,8 @@ void wxPostScriptPrintPreview::DetermineScaling() m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight)); // At 100%, the page should look about page-size on the screen. - m_previewScaleX = float(logPPIScreenX) / logPPIPrinterX; - m_previewScaleY = float(logPPIScreenY) / logPPIPrinterY; + m_previewScaleX = (float)0.8 * 72.0 / (float)wxPostScriptDC::GetResolution(); + m_previewScaleY = m_previewScaleX; } } diff --git a/Source/3rd Party/wx/src/generic/prntdlgg.cpp b/Source/3rd Party/wx/src/generic/prntdlgg.cpp index e43595a89..42658569c 100644 --- a/Source/3rd Party/wx/src/generic/prntdlgg.cpp +++ b/Source/3rd Party/wx/src/generic/prntdlgg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: prntdlgg.cpp 55256 2008-08-25 14:39:11Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -63,12 +64,12 @@ #ifndef __WXUNIVERSAL__ -#if wxUSE_GTKPRINT +#if wxUSE_LIBGNOMEPRINT #include "wx/link.h" - wxFORCE_LINK_MODULE(gtk_print) + wxFORCE_LINK_MODULE(gnome_print) #endif -#endif // !wxUniv +#endif // !__WXUNIVERSAL__ // ---------------------------------------------------------------------------- // global vars @@ -139,8 +140,7 @@ END_EVENT_TABLE() wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintDialogData* data) - : wxPrintDialogBase(GetParentForModalDialog(parent, 0), - wxID_ANY, _("Print"), + : wxPrintDialogBase(parent, wxID_ANY, _("Print"), wxPoint(0,0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) @@ -153,8 +153,7 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data) - : wxPrintDialogBase(GetParentForModalDialog(parent, 0), - wxID_ANY, _("Print"), + : wxPrintDialogBase(parent, wxID_ANY, _("Print"), wxPoint(0,0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) @@ -215,15 +214,16 @@ void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent)) choices[0] = _("All"); choices[1] = _("Pages"); - m_fromText = NULL; - m_toText = NULL; - m_rangeRadioBox = NULL; + m_fromText = (wxTextCtrl*)NULL; + m_toText = (wxTextCtrl*)NULL; + m_rangeRadioBox = (wxRadioBox *)NULL; if (m_printDialogData.GetFromPage() != 0) { m_rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"), wxDefaultPosition, wxDefaultSize, - 2, choices); + 2, choices, + 1, wxRA_VERTICAL); m_rangeRadioBox->SetSelection(1); mainsizer->Add( m_rangeRadioBox, 0, wxLEFT|wxTOP|wxRIGHT, 10 ); @@ -350,9 +350,9 @@ bool wxGenericPrintDialog::TransferDataToWindow() m_fromText->Enable(true); m_toText->Enable(true); if (m_printDialogData.GetFromPage() > 0) - m_fromText->SetValue(wxString::Format(wxT("%d"), m_printDialogData.GetFromPage())); + m_fromText->SetValue(wxString::Format(_T("%d"), m_printDialogData.GetFromPage())); if (m_printDialogData.GetToPage() > 0) - m_toText->SetValue(wxString::Format(wxT("%d"), m_printDialogData.GetToPage())); + m_toText->SetValue(wxString::Format(_T("%d"), m_printDialogData.GetToPage())); if(m_rangeRadioBox) { if (m_printDialogData.GetAllPages() || m_printDialogData.GetFromPage() == 0) @@ -374,7 +374,7 @@ bool wxGenericPrintDialog::TransferDataToWindow() } } m_noCopiesText->SetValue( - wxString::Format(wxT("%d"), m_printDialogData.GetNoCopies())); + wxString::Format(_T("%d"), m_printDialogData.GetNoCopies())); m_printToFileCheckBox->SetValue(m_printDialogData.GetPrintToFile()); m_printToFileCheckBox->Enable(m_printDialogData.GetEnablePrintToFile()); @@ -452,13 +452,13 @@ wxDialog(parent, wxID_ANY, _("Print Setup"), wxPoint(0,0), wxSize(600, 600), wxD } /* XPM */ -static const char* const check_xpm[] = { +static const char * check_xpm[] = { /* width height ncolors chars_per_pixel */ "16 16 3 1", /* colors */ -" s None c None", -"X c #000000", -". c #808080", +" s None c None", +"X c #000000", +". c #808080", /* pixels */ " ", " ", @@ -702,7 +702,7 @@ void wxGenericPrintSetupDialog::OnPrinter(wxListEvent& event) li.SetMask( wxLIST_MASK_TEXT ); li.SetId( event.GetIndex() ); m_printerListCtrl->GetItem( li ); - m_printerCommandText->SetValue( wxT("lpr -P") + li.GetText() ); + m_printerCommandText->SetValue( _T("lpr -P") + li.GetText() ); } } @@ -711,9 +711,9 @@ bool wxGenericPrintSetupDialog::TransferDataToWindow() wxPostScriptPrintNativeData *data = (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); - if (m_printerCommandText && !data->GetPrinterCommand().empty()) + if (m_printerCommandText && data->GetPrinterCommand()) m_printerCommandText->SetValue(data->GetPrinterCommand()); - if (m_printerOptionsText && !data->GetPrinterOptions().empty()) + if (m_printerOptionsText && data->GetPrinterOptions()) m_printerOptionsText->SetValue(data->GetPrinterOptions()); if (m_colourCheckBox) m_colourCheckBox->SetValue(m_printData.GetColour()); @@ -798,7 +798,7 @@ wxComboBox *wxGenericPrintSetupDialog::CreatePaperTypeChoice() wxComboBox *choice = new wxComboBox( this, wxPRINTID_PAPERSIZE, - _("Paper size"), + _("Paper Size"), wxDefaultPosition, wxSize(width, wxDefaultCoord), n, choices ); @@ -825,7 +825,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, wxPageSetupDialogData* data) : wxPageSetupDialogBase( parent, wxID_ANY, - _("Page setup"), + _("Page Setup"), wxPoint(0,0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL ) @@ -852,7 +852,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, m_paperTypeChoice = new wxComboBox( this, wxPRINTID_PAPERSIZE, - _("Paper size"), + _("Paper Size"), wxDefaultPosition, wxSize(300, wxDefaultCoord), n, choices ); @@ -1054,7 +1054,7 @@ wxComboBox *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y) wxComboBox *choice = new wxComboBox( this, wxPRINTID_PAPERSIZE, - _("Paper size"), + _("Paper Size"), wxPoint(*x, *y), wxSize(300, wxDefaultCoord), n, choices ); diff --git a/Source/3rd Party/wx/src/generic/progdlgg.cpp b/Source/3rd Party/wx/src/generic/progdlgg.cpp index f0d571867..3b63456cf 100644 --- a/Source/3rd Party/wx/src/generic/progdlgg.cpp +++ b/Source/3rd Party/wx/src/generic/progdlgg.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/generic/progdlgg.cpp -// Purpose: wxGenericProgressDialog class +// Purpose: wxProgressDialog class // Author: Karsten Ballueder // Modified by: // Created: 09.05.1999 +// RCS-ID: $Id: progdlgg.cpp 50711 2007-12-15 02:57:58Z VZ $ // Copyright: (c) Karsten Ballueder // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,11 +38,9 @@ #include "wx/dcclient.h" #include "wx/timer.h" #include "wx/settings.h" - #include "wx/app.h" #endif #include "wx/progdlg.h" -#include "wx/evtloop.h" // --------------------------------------------------------------------------- // macros @@ -65,127 +64,60 @@ static const int wxID_SKIP = 32000; // whatever +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +// update the label to show the given time (in seconds) +static void SetTimeLabel(unsigned long val, wxStaticText *label); + // ---------------------------------------------------------------------------- // event tables // ---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxGenericProgressDialog, wxDialog) - EVT_BUTTON(wxID_CANCEL, wxGenericProgressDialog::OnCancel) - EVT_BUTTON(wxID_SKIP, wxGenericProgressDialog::OnSkip) +BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog) + EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel) + EVT_BUTTON(wxID_SKIP, wxProgressDialog::OnSkip) - EVT_CLOSE(wxGenericProgressDialog::OnClose) + EVT_CLOSE(wxProgressDialog::OnClose) END_EVENT_TABLE() +IMPLEMENT_CLASS(wxProgressDialog, wxDialog) + // ============================================================================ -// wxGenericProgressDialog implementation +// wxProgressDialog implementation // ============================================================================ -wxIMPLEMENT_CLASS(wxProgressDialog, wxDialog) - // ---------------------------------------------------------------------------- -// wxGenericProgressDialog creation +// wxProgressDialog creation // ---------------------------------------------------------------------------- -void wxGenericProgressDialog::Init() +wxProgressDialog::wxProgressDialog(wxString const &title, + wxString const &message, + int maximum, + wxWindow *parent, + int style) + : wxDialog(parent, wxID_ANY, title), + m_skip(false), + m_delay(3), + m_hasAbortButton(false), + m_hasSkipButton(false) { // we may disappear at any moment, let the others know about it SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); + m_windowStyle |= style; - // Initialize all our members that we always use (even when we don't - // create a valid window in this class). + m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0; + m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0; - m_pdStyle = 0; - m_parentTop = NULL; - - m_gauge = NULL; - m_msg = NULL; - m_elapsed = - m_estimated = - m_remaining = NULL; - - m_state = Uncancelable; - m_maximum = 0; - - m_timeStart = wxGetCurrentTime(); - m_timeStop = (unsigned long)-1; - m_break = 0; - - m_skip = false; - -#if !defined(__SMARTPHONE__) - m_btnAbort = - m_btnSkip = NULL; -#endif - - m_display_estimated = - m_last_timeupdate = - m_ctdelay = 0; - - m_delay = 3; - - m_winDisabler = NULL; - m_tempEventLoop = NULL; -} - -wxGenericProgressDialog::wxGenericProgressDialog() - : wxDialog() -{ - Init(); -} - -wxGenericProgressDialog::wxGenericProgressDialog(const wxString& title, - const wxString& message, - int maximum, - wxWindow *parent, - int style) - : wxDialog() -{ - Init(); - - Create( title, message, maximum, parent, style ); -} - -void wxGenericProgressDialog::SetTopParent(wxWindow* parent) -{ - m_parentTop = GetParentForModalDialog(parent, GetWindowStyle()); -} - -bool wxGenericProgressDialog::Create( const wxString& title, - const wxString& message, - int maximum, - wxWindow *parent, - int style ) -{ - SetTopParent(parent); - - m_parentTop = wxGetTopLevelParent(parent); - m_pdStyle = style; - - wxWindow* const - realParent = GetParentForModalDialog(parent, GetWindowStyle()); - - if (!wxDialog::Create(realParent, wxID_ANY, title)) - return false; - - SetMaximum(maximum); - - // We need a running event loop in order to update the dialog and be able - // to process clicks on its buttons, so ensure that there is one running - // even if this means we have to start it ourselves (this happens most - // commonly during the program initialization, e.g. for the progress - // dialogs shown from overridden wxApp::OnInit()). - if ( !wxEventLoopBase::GetActive() ) - { - m_tempEventLoop = new wxEventLoop; - wxEventLoop::SetActive(m_tempEventLoop); - } + bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // we have to remove the "Close" button from the title bar then as it is // confusing to have it - it doesn't work anyhow // // FIXME: should probably have a (extended?) window style for this - if ( !HasPDFlag(wxPD_CAN_ABORT) ) + if ( !m_hasAbortButton ) { EnableCloseButton(false); } @@ -195,113 +127,156 @@ bool wxGenericProgressDialog::Create( const wxString& title, SetLeftMenu(); #endif - m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable; + m_state = m_hasAbortButton ? Continue : Uncancelable; + m_maximum = maximum; - // top-level sizerTop - wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL); +#if defined(__WXMSW__) || defined(__WXPM__) + // we can't have values > 65,536 in the progress control under Windows, so + // scale everything down + m_factor = m_maximum / 65536 + 1; + m_maximum /= m_factor; +#endif // __WXMSW__ + + m_parentTop = wxGetTopLevelParent(parent); + + wxClientDC dc(this); + dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + long widthText = 0; + dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL); + + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); m_msg = new wxStaticText(this, wxID_ANY, message); - sizerTop->Add(m_msg, 0, wxLEFT | wxRIGHT | wxTOP, 2*LAYOUT_MARGIN); + sizer->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN); - int gauge_style = wxGA_HORIZONTAL; - if ( style & wxPD_SMOOTH ) - gauge_style |= wxGA_SMOOTH; + wxSize sizeDlg, + sizeLabel = m_msg->GetSize(); + sizeDlg.y = 2*LAYOUT_MARGIN + sizeLabel.y; -#ifdef __WXMSW__ - maximum /= m_factor; -#endif + if ( maximum > 0 ) + { + int gauge_style = wxGA_HORIZONTAL; + if ( ( style & wxPD_SMOOTH ) == wxPD_SMOOTH ) + gauge_style |= wxGA_SMOOTH; + m_gauge = new wxGauge(this, wxID_ANY, m_maximum, + wxDefaultPosition, wxDefaultSize, + gauge_style ); - m_gauge = new wxGauge - ( - this, - wxID_ANY, - maximum, - wxDefaultPosition, - // make the progress bar sufficiently long - wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1), - gauge_style - ); + sizer->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN); + m_gauge->SetValue(0); - sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN); - m_gauge->SetValue(0); + wxSize sizeGauge = m_gauge->GetSize(); + sizeDlg.y += 2*LAYOUT_MARGIN + sizeGauge.y; + } + else + m_gauge = (wxGauge *)NULL; // create the estimated/remaining/total time zones if requested - m_elapsed = - m_estimated = - m_remaining = NULL; + m_elapsed = m_estimated = m_remaining = (wxStaticText*)NULL; + m_display_estimated = m_last_timeupdate = m_break = 0; + m_ctdelay = 0; + + // if we are going to have at least one label, remember it in this var + wxStaticText *label = NULL; // also count how many labels we really have size_t nTimeLabels = 0; - wxSizer * const sizerLabels = new wxFlexGridSizer(2); - if ( style & wxPD_ELAPSED_TIME ) { nTimeLabels++; - m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels); + label = + m_elapsed = CreateLabel(_("Elapsed time : "), sizer); } if ( style & wxPD_ESTIMATED_TIME ) { nTimeLabels++; - m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels); + label = + m_estimated = CreateLabel(_("Estimated time : "), sizer); } if ( style & wxPD_REMAINING_TIME ) { nTimeLabels++; - m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels); + label = + m_remaining = CreateLabel(_("Remaining time : "), sizer); + } + + if ( nTimeLabels > 0 ) + { + // set it to the current time + m_timeStart = wxGetCurrentTime(); + sizeDlg.y += nTimeLabels * (label->GetSize().y + LAYOUT_MARGIN); } - sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN); #if defined(__SMARTPHONE__) - if ( HasPDFlag(wxPD_CAN_SKIP) ) + if ( m_hasSkipButton ) SetRightMenu(wxID_SKIP, _("Skip")); - if ( HasPDFlag(wxPD_CAN_ABORT) ) + if ( m_hasAbortButton ) SetLeftMenu(wxID_CANCEL); #else - m_btnAbort = - m_btnSkip = NULL; - + m_btnAbort = m_btnSkip = (wxButton *)NULL; + bool sizeDlgModified = false; wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); - // Windows dialogs usually have buttons in the lower right corner const int sizerFlags = -#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXOSX__) +#if defined(__WXMSW__) || defined(__WXPM__) wxALIGN_RIGHT | wxALL #else // !MSW wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP #endif // MSW/!MSW ; - if ( HasPDFlag(wxPD_CAN_SKIP) ) + if ( m_hasSkipButton ) { - m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip")); + m_btnSkip = new wxButton(this, wxID_SKIP, _("Skip")); + // Windows dialogs usually have buttons in the lower right corner buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN); + sizeDlg.y += 2*LAYOUT_MARGIN + wxButton::GetDefaultSize().y; + sizeDlgModified = true; } - if ( HasPDFlag(wxPD_CAN_ABORT) ) + if ( m_hasAbortButton ) { m_btnAbort = new wxButton(this, wxID_CANCEL); + // Windows dialogs usually have buttons in the lower right corner buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN); + if(!sizeDlgModified) + sizeDlg.y += 2*LAYOUT_MARGIN + wxButton::GetDefaultSize().y; } - if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) ) - buttonSizer->AddSpacer(LAYOUT_MARGIN); - - sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN ); + sizer->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN ); #endif // __SMARTPHONE__/!__SMARTPHONE__ - SetSizerAndFit(sizerTop); + SetSizerAndFit(sizer); + + if (!isPda) + { + sizeDlg.y += 2*LAYOUT_MARGIN; + + // try to make the dialog not square but rectangular of reasonable width + sizeDlg.x = (wxCoord)wxMax(3*widthText/2, 4*sizeDlg.y/3); + SetClientSize(sizeDlg); + } Centre(wxCENTER_FRAME | wxBOTH); - DisableOtherWindows(); + if ( style & wxPD_APP_MODAL ) + { + m_winDisabler = new wxWindowDisabler(this); + } + else + { + if ( m_parentTop ) + m_parentTop->Disable(); + m_winDisabler = NULL; + } Show(); Enable(); @@ -315,118 +290,45 @@ bool wxGenericProgressDialog::Create( const wxString& title, } Update(); - return true; } -void wxGenericProgressDialog::UpdateTimeEstimates(int value, - unsigned long &elapsedTime, - unsigned long &estimatedTime, - unsigned long &remainingTime) +wxStaticText *wxProgressDialog::CreateLabel(const wxString& text, + wxSizer *sizer) { - unsigned long elapsed = wxGetCurrentTime() - m_timeStart; - if ( value != 0 && (m_last_timeupdate < elapsed || value == m_maximum) ) - { - m_last_timeupdate = elapsed; - unsigned long estimated = m_break + - (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ; - if ( estimated > m_display_estimated - && m_ctdelay >= 0 - ) - { - ++m_ctdelay; - } - else if ( estimated < m_display_estimated - && m_ctdelay <= 0 - ) - { - --m_ctdelay; - } - else - { - m_ctdelay = 0; - } - if ( m_ctdelay >= m_delay // enough confirmations for a higher value - || m_ctdelay <= (m_delay*-1) // enough confirmations for a lower value - || value == m_maximum // to stay consistent - || elapsed > m_display_estimated // to stay consistent - || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning - ) - { - m_display_estimated = estimated; - m_ctdelay = 0; - } - } + wxBoxSizer *locsizer = new wxBoxSizer(wxLARGESMALL(wxHORIZONTAL,wxVERTICAL)); - if ( value != 0 ) - { - long display_remaining = m_display_estimated - elapsed; - if ( display_remaining < 0 ) - { - display_remaining = 0; - } - - estimatedTime = m_display_estimated; - remainingTime = display_remaining; - } - - elapsedTime = elapsed; -} - -// static -wxString wxGenericProgressDialog::GetFormattedTime(unsigned long timeInSec) -{ - wxString timeAsHMS; - - if ( timeInSec == (unsigned long)-1 ) - { - timeAsHMS = _("Unknown"); - } - else - { - unsigned hours = timeInSec / 3600; - unsigned minutes = (timeInSec % 3600) / 60; - unsigned seconds = timeInSec % 60; - timeAsHMS.Printf("%u:%02u:%02u", hours, minutes, seconds); - } - - return timeAsHMS; -} - -wxStaticText * -wxGenericProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer) -{ - wxStaticText *label = new wxStaticText(this, wxID_ANY, text); - wxStaticText *value = new wxStaticText(this, wxID_ANY, _("unknown")); + wxStaticText *dummy = new wxStaticText(this, wxID_ANY, text); + wxStaticText *label = new wxStaticText(this, wxID_ANY, _("unknown")); // select placement most native or nice on target GUI #if defined(__SMARTPHONE__) - // value and time to the left in two rows - sizer->Add(label, 1, wxALIGN_LEFT); - sizer->Add(value, 1, wxALIGN_LEFT); + // label and time to the left in two rows + locsizer->Add(dummy, 1, wxALIGN_LEFT); + locsizer->Add(label, 1, wxALIGN_LEFT); + sizer->Add(locsizer, 0, wxALIGN_LEFT | wxTOP | wxLEFT, LAYOUT_MARGIN); #elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__) - // value and time centered in one row - sizer->Add(label, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT) | wxTOP | wxRIGHT, LAYOUT_MARGIN); - sizer->Add(value, 1, wxALIGN_LEFT | wxTOP, LAYOUT_MARGIN); + // label and time centered in one row + locsizer->Add(dummy, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT)); + locsizer->Add(label, 1, wxALIGN_LEFT | wxLEFT, LAYOUT_MARGIN); + sizer->Add(locsizer, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN); #else - // value and time to the right in one row - sizer->Add(label); - sizer->Add(value, 0, wxLEFT, LAYOUT_MARGIN); + // label and time to the right in one row + sizer->Add(locsizer, 0, wxALIGN_RIGHT | wxRIGHT | wxTOP, LAYOUT_MARGIN); + locsizer->Add(dummy); + locsizer->Add(label, 0, wxLEFT, LAYOUT_MARGIN); #endif - return value; + return label; } // ---------------------------------------------------------------------------- -// wxGenericProgressDialog operations +// wxProgressDialog operations // ---------------------------------------------------------------------------- bool -wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) +wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip) { - if ( !DoBeforeUpdate(skip) ) - return false; - - wxCHECK_MSG( m_gauge, false, "dialog should be fully created" ); + wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") ); #ifdef __WXMSW__ value /= m_factor; @@ -434,19 +336,54 @@ wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") ); - m_gauge->SetValue(value); + if ( m_gauge ) + m_gauge->SetValue(value); UpdateMessage(newmsg); if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) ) { - unsigned long elapsed; - unsigned long display_remaining; + unsigned long elapsed = wxGetCurrentTime() - m_timeStart; + if ( m_last_timeupdate < elapsed + || value == m_maximum + ) + { + m_last_timeupdate = elapsed; + unsigned long estimated = m_break + + (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ; + if ( estimated > m_display_estimated + && m_ctdelay >= 0 + ) + { + ++m_ctdelay; + } + else if ( estimated < m_display_estimated + && m_ctdelay <= 0 + ) + { + --m_ctdelay; + } + else + { + m_ctdelay = 0; + } + if ( m_ctdelay >= m_delay // enough confirmations for a higher value + || m_ctdelay <= (m_delay*-1) // enough confirmations for a lower value + || value == m_maximum // to stay consistent + || elapsed > m_display_estimated // to stay consistent + || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning + ) + { + m_display_estimated = estimated; + m_ctdelay = 0; + } + } - UpdateTimeEstimates( value, - elapsed, - m_display_estimated, - display_remaining ); + long display_remaining = m_display_estimated - elapsed; + if ( display_remaining < 0 ) + { + display_remaining = 0; + } SetTimeLabel(elapsed, m_elapsed); SetTimeLabel(m_display_estimated, m_estimated); @@ -467,7 +404,7 @@ wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) // so that we return true below and that out [Cancel] handler knew what // to do m_state = Finished; - if( !HasPDFlag(wxPD_AUTO_HIDE) ) + if( !(GetWindowStyle() & wxPD_AUTO_HIDE) ) { EnableClose(); DisableSkip(); @@ -481,14 +418,8 @@ wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) m_msg->SetLabel(_("Done.")); } - // allow the window to repaint: - // NOTE: since we yield only for UI events with this call, there - // should be no side-effects - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); + wxYieldIfNeeded() ; - // NOTE: this call results in a new event loop being created - // and to a call to ProcessPendingEvents() (which may generate - // unwanted re-entrancies). (void)ShowModal(); } else // auto hide @@ -503,7 +434,7 @@ wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) } else // not at maximum yet { - DoAfterUpdate(); + return DoAfterUpdate(skip); } // update the display in case yielding above didn't do it @@ -512,12 +443,9 @@ wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) return m_state != Canceled; } -bool wxGenericProgressDialog::Pulse(const wxString& newmsg, bool *skip) +bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip) { - if ( !DoBeforeUpdate(skip) ) - return false; - - wxCHECK_MSG( m_gauge, false, "dialog should be fully created" ); + wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") ); // show a bit of progress m_gauge->Pulse(); @@ -533,18 +461,14 @@ bool wxGenericProgressDialog::Pulse(const wxString& newmsg, bool *skip) SetTimeLabel((unsigned long)-1, m_remaining); } - DoAfterUpdate(); - - return m_state != Canceled; + return DoAfterUpdate(skip); } -bool wxGenericProgressDialog::DoBeforeUpdate(bool *skip) +bool wxProgressDialog::DoAfterUpdate(bool *skip) { // we have to yield because not only we want to update the display but // also to process the clicks on the cancel and skip buttons - // NOTE: using YieldFor() this call shouldn't give re-entrancy problems - // for event handlers not interested to UI/user-input events. - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT); + wxYieldIfNeeded(); Update(); @@ -558,15 +482,7 @@ bool wxGenericProgressDialog::DoBeforeUpdate(bool *skip) return m_state != Canceled; } -void wxGenericProgressDialog::DoAfterUpdate() -{ - // allow the window to repaint: - // NOTE: since we yield only for UI events with this call, there - // should be no side-effects - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); -} - -void wxGenericProgressDialog::Resume() +void wxProgressDialog::Resume() { m_state = Continue; m_ctdelay = m_delay; // force an update of the elapsed/estimated/remaining time @@ -577,7 +493,7 @@ void wxGenericProgressDialog::Resume() m_skip = false; } -bool wxGenericProgressDialog::Show( bool show ) +bool wxProgressDialog::Show( bool show ) { // reenable other windows before hiding this one because otherwise // Windows wouldn't give the focus back to the window which had @@ -588,83 +504,11 @@ bool wxGenericProgressDialog::Show( bool show ) return wxDialog::Show(show); } -int wxGenericProgressDialog::GetValue() const -{ - wxCHECK_MSG( m_gauge, -1, "dialog should be fully created" ); - - return m_gauge->GetValue(); -} - -int wxGenericProgressDialog::GetRange() const -{ - return m_maximum; -} - -wxString wxGenericProgressDialog::GetMessage() const -{ - return m_msg->GetLabel(); -} - -void wxGenericProgressDialog::SetRange(int maximum) -{ - wxCHECK_RET( m_gauge, "dialog should be fully created" ); - - wxCHECK_RET( maximum > 0, "Invalid range" ); - - m_gauge->SetRange(maximum); - - SetMaximum(maximum); -} - -void wxGenericProgressDialog::SetMaximum(int maximum) -{ - m_maximum = maximum; - -#if defined(__WXMSW__) || defined(__WXPM__) - // we can't have values > 65,536 in the progress control under Windows, so - // scale everything down - m_factor = m_maximum / 65536 + 1; -#endif // __WXMSW__ -} - - -bool wxGenericProgressDialog::WasCancelled() const -{ - return HasPDFlag(wxPD_CAN_ABORT) && m_state == Canceled; -} - -bool wxGenericProgressDialog::WasSkipped() const -{ - return HasPDFlag(wxPD_CAN_SKIP) && m_skip; -} - -// static -void wxGenericProgressDialog::SetTimeLabel(unsigned long val, - wxStaticText *label) -{ - if ( label ) - { - wxString s; - - if (val != (unsigned long)-1) - { - s = GetFormattedTime(val); - } - else - { - s = _("Unknown"); - } - - if ( s != label->GetLabel() ) - label->SetLabel(s); - } -} - // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- -void wxGenericProgressDialog::OnCancel(wxCommandEvent& event) +void wxProgressDialog::OnCancel(wxCommandEvent& event) { if ( m_state == Finished ) { @@ -688,13 +532,13 @@ void wxGenericProgressDialog::OnCancel(wxCommandEvent& event) } } -void wxGenericProgressDialog::OnSkip(wxCommandEvent& WXUNUSED(event)) +void wxProgressDialog::OnSkip(wxCommandEvent& WXUNUSED(event)) { DisableSkip(); m_skip = true; } -void wxGenericProgressDialog::OnClose(wxCloseEvent& event) +void wxProgressDialog::OnClose(wxCloseEvent& event) { if ( m_state == Uncancelable ) { @@ -721,37 +565,18 @@ void wxGenericProgressDialog::OnClose(wxCloseEvent& event) // destruction // ---------------------------------------------------------------------------- -wxGenericProgressDialog::~wxGenericProgressDialog() +wxProgressDialog::~wxProgressDialog() { // normally this should have been already done, but just in case ReenableOtherWindows(); - - if ( m_tempEventLoop ) - { - wxEventLoopBase::SetActive(NULL); - delete m_tempEventLoop; - } } -void wxGenericProgressDialog::DisableOtherWindows() +void wxProgressDialog::ReenableOtherWindows() { - if ( HasPDFlag(wxPD_APP_MODAL) ) + if ( GetWindowStyle() & wxPD_APP_MODAL ) { - m_winDisabler = new wxWindowDisabler(this); - } - else - { - if ( m_parentTop ) - m_parentTop->Disable(); - m_winDisabler = NULL; - } -} - -void wxGenericProgressDialog::ReenableOtherWindows() -{ - if ( HasPDFlag(wxPD_APP_MODAL) ) - { - wxDELETE(m_winDisabler); + delete m_winDisabler; + m_winDisabler = (wxWindowDisabler *)NULL; } else { @@ -764,9 +589,32 @@ void wxGenericProgressDialog::ReenableOtherWindows() // private functions // ---------------------------------------------------------------------------- -void wxGenericProgressDialog::EnableSkip(bool enable) +static void SetTimeLabel(unsigned long val, wxStaticText *label) { - if ( HasPDFlag(wxPD_CAN_SKIP) ) + if ( label ) + { + wxString s; + + if (val != (unsigned long)-1) + { + unsigned long hours = val / 3600; + unsigned long minutes = (val % 3600) / 60; + unsigned long seconds = val % 60; + s.Printf(wxT("%lu:%02lu:%02lu"), hours, minutes, seconds); + } + else + { + s = _("Unknown"); + } + + if ( s != label->GetLabel() ) + label->SetLabel(s); + } +} + +void wxProgressDialog::EnableSkip(bool enable) +{ + if(m_hasSkipButton) { #ifdef __SMARTPHONE__ if(enable) @@ -780,9 +628,9 @@ void wxGenericProgressDialog::EnableSkip(bool enable) } } -void wxGenericProgressDialog::EnableAbort(bool enable) +void wxProgressDialog::EnableAbort(bool enable) { - if( HasPDFlag(wxPD_CAN_ABORT) ) + if(m_hasAbortButton) { #ifdef __SMARTPHONE__ if(enable) @@ -796,9 +644,9 @@ void wxGenericProgressDialog::EnableAbort(bool enable) } } -void wxGenericProgressDialog::EnableClose() +void wxProgressDialog::EnableClose() { - if(HasPDFlag(wxPD_CAN_ABORT)) + if(m_hasAbortButton) { #ifdef __SMARTPHONE__ SetLeftMenu(wxID_CANCEL, _("Close")); @@ -812,16 +660,13 @@ void wxGenericProgressDialog::EnableClose() } } -void wxGenericProgressDialog::UpdateMessage(const wxString &newmsg) +void wxProgressDialog::UpdateMessage(const wxString &newmsg) { if ( !newmsg.empty() && newmsg != m_msg->GetLabel() ) { m_msg->SetLabel(newmsg); - // allow the window to repaint: - // NOTE: since we yield only for UI events with this call, there - // should be no side-effects - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); + wxYieldIfNeeded() ; } } diff --git a/Source/3rd Party/wx/src/generic/propdlg.cpp b/Source/3rd Party/wx/src/generic/propdlg.cpp deleted file mode 100644 index d33530a83..000000000 --- a/Source/3rd Party/wx/src/generic/propdlg.cpp +++ /dev/null @@ -1,233 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/propdlg.cpp -// Purpose: wxPropertySheetDialog -// Author: Julian Smart -// Modified by: -// Created: 2005-03-12 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BOOKCTRL - -#ifndef WX_PRECOMP - #include "wx/button.h" - #include "wx/sizer.h" - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/msgdlg.h" -#endif - -#include "wx/bookctrl.h" - -#if wxUSE_NOTEBOOK -#include "wx/notebook.h" -#endif -#if wxUSE_CHOICEBOOK -#include "wx/choicebk.h" -#endif -#if wxUSE_TOOLBOOK -#include "wx/toolbook.h" -#endif -#if wxUSE_LISTBOOK -#include "wx/listbook.h" -#endif -#if wxUSE_TREEBOOK -#include "wx/treebook.h" -#endif - -#include "wx/generic/propdlg.h" -#include "wx/sysopt.h" - -//----------------------------------------------------------------------------- -// wxPropertySheetDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxPropertySheetDialog, wxDialog) - EVT_ACTIVATE(wxPropertySheetDialog::OnActivate) - EVT_IDLE(wxPropertySheetDialog::OnIdle) -END_EVENT_TABLE() - -bool wxPropertySheetDialog::Create(wxWindow* parent, wxWindowID id, const wxString& title, - const wxPoint& pos, const wxSize& sz, long style, - const wxString& name) -{ - parent = GetParentForModalDialog(parent, style); - - if (!wxDialog::Create(parent, id, title, pos, sz, style|wxCLIP_CHILDREN, name)) - return false; - - wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); - SetSizer(topSizer); - - // This gives more space around the edges - m_innerSizer = new wxBoxSizer( wxVERTICAL ); - -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) - m_sheetOuterBorder = 0; -#endif - topSizer->Add(m_innerSizer, 1, wxGROW|wxALL, m_sheetOuterBorder); - - m_bookCtrl = CreateBookCtrl(); - AddBookCtrl(m_innerSizer); - - return true; -} - -void wxPropertySheetDialog::Init() -{ - m_sheetStyle = wxPROPSHEET_DEFAULT; - m_innerSizer = NULL; - m_bookCtrl = NULL; - m_sheetOuterBorder = 2; - m_sheetInnerBorder = 5; -} - -// Layout the dialog, to be called after pages have been created -void wxPropertySheetDialog::LayoutDialog(int centreFlags) -{ -#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); - if (centreFlags) - Centre(centreFlags); -#else - wxUnusedVar(centreFlags); -#endif -#if defined(__SMARTPHONE__) - if (m_bookCtrl) - m_bookCtrl->SetFocus(); -#endif -} - -// Creates the buttons, if any -void wxPropertySheetDialog::CreateButtons(int flags) -{ -#ifdef __POCKETPC__ - // keep system option status - const wxChar *optionName = wxT("wince.dialog.real-ok-cancel"); - const int status = wxSystemOptions::GetOptionInt(optionName); - wxSystemOptions::SetOption(optionName,0); -#endif - - wxSizer *buttonSizer = CreateButtonSizer(flags); - if( buttonSizer ) - { - m_innerSizer->Add( buttonSizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2); - m_innerSizer->AddSpacer(2); - } - -#ifdef __POCKETPC__ - // restore system option - wxSystemOptions::SetOption(optionName,status); -#endif -} - -// Creates the book control -wxBookCtrlBase* wxPropertySheetDialog::CreateBookCtrl() -{ - int style = wxCLIP_CHILDREN | wxBK_DEFAULT; - - wxBookCtrlBase* bookCtrl = NULL; - -#if wxUSE_NOTEBOOK - if (GetSheetStyle() & wxPROPSHEET_NOTEBOOK) - bookCtrl = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); -#endif -#if wxUSE_CHOICEBOOK - if (GetSheetStyle() & wxPROPSHEET_CHOICEBOOK) - bookCtrl = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); -#endif -#if wxUSE_TOOLBOOK -#if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON - if (GetSheetStyle() & wxPROPSHEET_BUTTONTOOLBOOK) - bookCtrl = new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style|wxTBK_BUTTONBAR ); - else -#endif - if ((GetSheetStyle() & wxPROPSHEET_TOOLBOOK) || (GetSheetStyle() & wxPROPSHEET_BUTTONTOOLBOOK)) - bookCtrl = new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); -#endif -#if wxUSE_LISTBOOK - if (GetSheetStyle() & wxPROPSHEET_LISTBOOK) - bookCtrl = new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); -#endif -#if wxUSE_TREEBOOK - if (GetSheetStyle() & wxPROPSHEET_TREEBOOK) - bookCtrl = new wxTreebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); -#endif - if (!bookCtrl) - bookCtrl = new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); - - if (GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT) - bookCtrl->SetFitToCurrentPage(true); - - return bookCtrl; -} - -// Adds the book control to the inner sizer. -void wxPropertySheetDialog::AddBookCtrl(wxSizer* sizer) -{ -#if defined(__POCKETPC__) && wxUSE_NOTEBOOK - // The book control has to be sized larger than the dialog because of a border bug - // in WinCE - int borderSize = -2; - sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxRIGHT, borderSize ); -#else - sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, m_sheetInnerBorder ); -#endif -} - -void wxPropertySheetDialog::OnActivate(wxActivateEvent& event) -{ -#if defined(__SMARTPHONE__) - // Attempt to focus the choice control: not yet working, but might - // be a step in the right direction. OnActivate overrides the default - // handler in toplevel.cpp that sets the focus for the first child of - // of the dialog (the choicebook). - if (event.GetActive()) - { - wxChoicebook* choiceBook = wxDynamicCast(GetBookCtrl(), wxChoicebook); - if (choiceBook) - choiceBook->SetFocus(); - } - else -#endif - event.Skip(); -} - -// Resize dialog if necessary -void wxPropertySheetDialog::OnIdle(wxIdleEvent& event) -{ - event.Skip(); - - if ((GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT) && GetBookCtrl()) - { - int sel = GetBookCtrl()->GetSelection(); - if (sel != -1 && sel != m_selectedPage) - { - GetBookCtrl()->InvalidateBestSize(); - InvalidateBestSize(); - SetSizeHints(-1, -1, -1, -1); - - m_selectedPage = sel; - LayoutDialog(0); - } - } -} - -// Override function in base -wxWindow* wxPropertySheetDialog::GetContentWindow() const -{ - return GetBookCtrl(); -} - -#endif // wxUSE_BOOKCTRL diff --git a/Source/3rd Party/wx/src/generic/regiong.cpp b/Source/3rd Party/wx/src/generic/regiong.cpp deleted file mode 100644 index e9d08aeb5..000000000 --- a/Source/3rd Party/wx/src/generic/regiong.cpp +++ /dev/null @@ -1,1933 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/regiong.cpp -// Purpose: generic wxRegion class -// Author: David Elliott -// Modified by: -// Created: 2004/04/12 -// Copyright: (c) 2004 David Elliott -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/region.h" - -#ifndef WX_PRECOMP - #include "wx/utils.h" -#endif - -// ======================================================================== -// Classes to interface with X.org code -// ======================================================================== - -typedef struct Box -{ - wxCoord x1, x2, y1, y2; -} Box, BOX, BoxRec, *BoxPtr; - -typedef struct REGION *Region; - -struct REGION -{ -public: - // Default constructor initializes nothing - REGION() {} - - REGION(const wxRect& rect) - { - rects = &extents; - numRects = 1; - extents.x1 = rect.x; - extents.y1 = rect.y; - extents.x2 = rect.x + rect.width; - extents.y2 = rect.y + rect.height; - size = 1; - } - - BoxPtr GetBox(int i) - { - return i < numRects ? rects + i : NULL; - } - - // X.org methods - static bool XClipBox( - Region r, - wxRect *rect); - static bool XOffsetRegion( - register Region pRegion, - register int x, - register int y); - static bool XIntersectRegion( - Region reg1, - Region reg2, /* source regions */ - register Region newReg); /* destination Region */ - static bool XUnionRegion( - Region reg1, - Region reg2, /* source regions */ - Region newReg); /* destination Region */ - static bool XSubtractRegion( - Region regM, - Region regS, - register Region regD); - static bool XXorRegion(Region sra, Region srb, Region dr); - static bool XEmptyRegion( - Region r); - static bool XEqualRegion(Region r1, Region r2); - static bool XPointInRegion( - Region pRegion, - int x, int y); - static wxRegionContain XRectInRegion( - register Region region, - int rx, int ry, - unsigned int rwidth, unsigned int rheight); - -protected: - static Region XCreateRegion(void); - static void miSetExtents ( - Region pReg); - static bool XDestroyRegion(Region r); - static int miIntersectO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - wxCoord y1, - wxCoord y2); - static void miRegionCopy( - register Region dstrgn, - register Region rgn); - static int miCoalesce( - register Region pReg, /* Region to coalesce */ - int prevStart, /* Index of start of previous band */ - int curStart); /* Index of start of current band */ - static void miRegionOp( - register Region newReg, /* Place to store result */ - Region reg1, /* First region in operation */ - Region reg2, /* 2d region in operation */ - int (*overlapFunc)( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - wxCoord y1, - wxCoord y2), /* Function to call for over- - * lapping bands */ - int (*nonOverlap1Func)( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2), /* Function to call for non- - * overlapping bands in region - * 1 */ - int (*nonOverlap2Func)( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2)); /* Function to call for non- - * overlapping bands in region - * 2 */ - static int miUnionNonO ( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2); - static int miUnionO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - register wxCoord y1, - register wxCoord y2); - static int miSubtractNonO1 ( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2); - static int miSubtractO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - register wxCoord y1, - register wxCoord y2); -protected: - long size; - long numRects; - Box *rects; - Box extents; -}; - -// ======================================================================== -// wxRegionRefData -// ======================================================================== - -class wxRegionRefData : public wxGDIRefData, - public REGION -{ -public: - wxRegionRefData() - : wxGDIRefData(), - REGION() - { - size = 1; - numRects = 0; - rects = ( BOX * )malloc( (unsigned) sizeof( BOX )); - extents.x1 = 0; - extents.x2 = 0; - extents.y1 = 0; - extents.y2 = 0; - } - - wxRegionRefData(const wxPoint& topLeft, const wxPoint& bottomRight) - : wxGDIRefData(), - REGION() - { - rects = (BOX*)malloc(sizeof(BOX)); - size = 1; - numRects = 1; - extents.x1 = topLeft.x; - extents.y1 = topLeft.y; - extents.x2 = bottomRight.x; - extents.y2 = bottomRight.y; - *rects = extents; - } - - wxRegionRefData(const wxRect& rect) - : wxGDIRefData(), - REGION(rect) - { - rects = (BOX*)malloc(sizeof(BOX)); - *rects = extents; - } - - wxRegionRefData(const wxRegionRefData& refData) - : wxGDIRefData(), - REGION() - { - size = refData.size; - numRects = refData.numRects; - rects = (Box*)malloc(numRects*sizeof(Box)); - memcpy(rects, refData.rects, numRects*sizeof(Box)); - extents = refData.extents; - } - - virtual ~wxRegionRefData() - { - free(rects); - } - -private: - // Don't allow this - wxRegionRefData(const REGION&); -}; - -// ======================================================================== -// wxRegionGeneric -// ======================================================================== -//IMPLEMENT_DYNAMIC_CLASS(wxRegionGeneric, wxGDIObject) - -#define M_REGIONDATA ((wxRegionRefData *)m_refData) -#define M_REGIONDATA_OF(rgn) ((wxRegionRefData *)(rgn.m_refData)) - -// ---------------------------------------------------------------------------- -// wxRegionGeneric construction -// ---------------------------------------------------------------------------- - -wxRegionGeneric::wxRegionGeneric() -{ -} - -wxRegionGeneric::~wxRegionGeneric() -{ -} - -wxRegionGeneric::wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h) -{ - m_refData = new wxRegionRefData(wxRect(x,y,w,h)); -} - -wxRegionGeneric::wxRegionGeneric(const wxRect& rect) -{ - m_refData = new wxRegionRefData(rect); -} - -wxRegionGeneric::wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight) -{ - m_refData = new wxRegionRefData(topLeft, bottomRight); -} - -wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp) -{ - wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp)"); -} - -wxRegionGeneric::wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle) -{ - wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle)"); -} - -wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance) -{ - wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance)"); -} - -void wxRegionGeneric::Clear() -{ - UnRef(); - if (!m_refData) - m_refData = new wxRegionRefData(wxRect(0,0,0,0)); -} - -wxGDIRefData *wxRegionGeneric::CreateGDIRefData() const -{ - return new wxRegionRefData; -} - -wxGDIRefData *wxRegionGeneric::CloneGDIRefData(const wxGDIRefData *data) const -{ - return new wxRegionRefData(*(wxRegionRefData *)data); -} - -bool wxRegionGeneric::DoIsEqual(const wxRegion& region) const -{ - return REGION::XEqualRegion(M_REGIONDATA,M_REGIONDATA_OF(region)); -} - -bool wxRegionGeneric::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const -{ - if ( !m_refData ) - return false; - - wxRect rect; - REGION::XClipBox(M_REGIONDATA,&rect); - x = rect.x; - y = rect.y; - w = rect.width; - h = rect.height; - return true; -} - -// ---------------------------------------------------------------------------- -// wxRegionGeneric operations -// ---------------------------------------------------------------------------- - -bool wxRegionGeneric::DoUnionWithRect(const wxRect& rect) -{ - if ( rect.IsEmpty() ) - { - // nothing to do - return true; - } - - AllocExclusive(); - REGION region(rect); - return REGION::XUnionRegion(®ion,M_REGIONDATA,M_REGIONDATA); -} - -bool wxRegionGeneric::DoUnionWithRegion(const wxRegion& region) -{ - AllocExclusive(); - return REGION::XUnionRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); -} - -bool wxRegionGeneric::DoIntersect(const wxRegion& region) -{ - AllocExclusive(); - return REGION::XIntersectRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); -} - -bool wxRegionGeneric::DoSubtract(const wxRegion& region) -{ - if ( region.IsEmpty() ) - { - // nothing to do - return true; - } - - return REGION::XSubtractRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); -} - -bool wxRegionGeneric::DoXor(const wxRegion& region) -{ - AllocExclusive(); - return REGION::XXorRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); -} - -bool wxRegionGeneric::DoOffset(wxCoord x, wxCoord y) -{ - AllocExclusive(); - return REGION::XOffsetRegion(M_REGIONDATA, x, y); -} - -// ---------------------------------------------------------------------------- -// wxRegionGeneric comparison -// ---------------------------------------------------------------------------- - -bool wxRegionGeneric::IsEmpty() const -{ - wxASSERT(m_refData); - return REGION::XEmptyRegion(M_REGIONDATA); -} - -// Does the region contain the point (x,y)? -wxRegionContain wxRegionGeneric::DoContainsPoint(wxCoord x, wxCoord y) const -{ - wxASSERT(m_refData); - return REGION::XPointInRegion(M_REGIONDATA,x,y) ? wxInRegion : wxOutRegion; -} - -// Does the region contain the rectangle rect? -wxRegionContain wxRegionGeneric::DoContainsRect(const wxRect& rect) const -{ - wxASSERT(m_refData); - return REGION::XRectInRegion(M_REGIONDATA,rect.x,rect.y,rect.width,rect.height); -} - -// ======================================================================== -// wxRegionIteratorGeneric -// ======================================================================== -//IMPLEMENT_DYNAMIC_CLASS(wxRegionIteratorGeneric,wxObject) - -wxRegionIteratorGeneric::wxRegionIteratorGeneric() -{ - m_current = 0; -} - -wxRegionIteratorGeneric::wxRegionIteratorGeneric(const wxRegionGeneric& region) -: m_region(region) -{ - m_current = 0; -} - -wxRegionIteratorGeneric::wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator) -: m_region(iterator.m_region) -{ - m_current = iterator.m_current; -} - -void wxRegionIteratorGeneric::Reset(const wxRegionGeneric& region) -{ - m_region = region; - m_current = 0; -} - -bool wxRegionIteratorGeneric::HaveRects() const -{ - return M_REGIONDATA_OF(m_region)->GetBox(m_current); -} - -wxRegionIteratorGeneric& wxRegionIteratorGeneric::operator++() -{ - ++m_current; - return *this; -} - -wxRegionIteratorGeneric wxRegionIteratorGeneric::operator++(int) -{ - wxRegionIteratorGeneric copy(*this); - ++*this; - return copy; -} - -wxRect wxRegionIteratorGeneric::GetRect() const -{ - wxASSERT(m_region.m_refData); - const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current); - wxASSERT(box); - return wxRect - ( box->x1 - , box->y1 - , box->x2 - box->x1 - , box->y2 - box->y1 - ); -} - -long wxRegionIteratorGeneric::GetX() const -{ - wxASSERT(m_region.m_refData); - const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current); - wxASSERT(box); - return box->x1; -} - -long wxRegionIteratorGeneric::GetY() const -{ - wxASSERT(m_region.m_refData); - const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current); - wxASSERT(box); - return box->y1; -} - -long wxRegionIteratorGeneric::GetW() const -{ - wxASSERT(m_region.m_refData); - const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current); - wxASSERT(box); - return box->x2 - box->x1; -} - -long wxRegionIteratorGeneric::GetH() const -{ - wxASSERT(m_region.m_refData); - const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current); - wxASSERT(box); - return box->y2 - box->y1; -} - -wxRegionIteratorGeneric::~wxRegionIteratorGeneric() -{ -} - - -// ======================================================================== -// The guts (from X.org) -// ======================================================================== - -/************************************************************************ - -Copyright 1987, 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ - -/* 1 if two BOXs overlap. - * 0 if two BOXs do not overlap. - * Remember, x2 and y2 are not in the region - */ -#define EXTENTCHECK(r1, r2) \ - ((r1)->x2 > (r2)->x1 && \ - (r1)->x1 < (r2)->x2 && \ - (r1)->y2 > (r2)->y1 && \ - (r1)->y1 < (r2)->y2) - -/* - * Check to see if there is enough memory in the present region. - */ -#define MEMCHECK(reg, rect, firstrect){\ - if ((reg)->numRects >= ((reg)->size - 1)){\ - (firstrect) = (BOX *) realloc \ - ((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\ - if ((firstrect) == 0)\ - return(0);\ - (reg)->size *= 2;\ - (rect) = &(firstrect)[(reg)->numRects];\ - }\ - } - -#define EMPTY_REGION(pReg) pReg->numRects = 0 - -#define REGION_NOT_EMPTY(pReg) pReg->numRects - -#define INBOX(r, x, y) \ - ( ( ((r).x2 > x)) && \ - ( ((r).x1 <= x)) && \ - ( ((r).y2 > y)) && \ - ( ((r).y1 <= y)) ) - -/* - * The functions in this file implement the Region abstraction, similar to one - * used in the X11 sample server. A Region is simply an area, as the name - * implies, and is implemented as a "y-x-banded" array of rectangles. To - * explain: Each Region is made up of a certain number of rectangles sorted - * by y coordinate first, and then by x coordinate. - * - * Furthermore, the rectangles are banded such that every rectangle with a - * given upper-left y coordinate (y1) will have the same lower-right y - * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it - * will span the entire vertical distance of the band. This means that some - * areas that could be merged into a taller rectangle will be represented as - * several shorter rectangles to account for shorter rectangles to its left - * or right but within its "vertical scope". - * - * An added constraint on the rectangles is that they must cover as much - * horizontal area as possible. E.g. no two rectangles in a band are allowed - * to touch. - * - * Whenever possible, bands will be merged together to cover a greater vertical - * distance (and thus reduce the number of rectangles). Two bands can be merged - * only if the bottom of one touches the top of the other and they have - * rectangles in the same places (of the same width, of course). This maintains - * the y-x-banding that's so nice to have... - */ - -/* Create a new empty region */ -Region REGION::XCreateRegion(void) -{ - Region temp = new REGION; - - if (!temp) - return (Region) NULL; - - temp->rects = ( BOX * )malloc( (unsigned) sizeof( BOX )); - - if (!temp->rects) - { - delete temp; - return (Region) NULL; - } - temp->numRects = 0; - temp->extents.x1 = 0; - temp->extents.y1 = 0; - temp->extents.x2 = 0; - temp->extents.y2 = 0; - temp->size = 1; - return( temp ); -} - -bool REGION::XClipBox(Region r, wxRect *rect) -{ - rect->x = r->extents.x1; - rect->y = r->extents.y1; - rect->width = r->extents.x2 - r->extents.x1; - rect->height = r->extents.y2 - r->extents.y1; - return true; -} - -/*- - *----------------------------------------------------------------------- - * miSetExtents -- - * Reset the extents of a region to what they should be. Called by - * miSubtract and miIntersect b/c they can't figure it out along the - * way or do so easily, as miUnion can. - * - * Results: - * None. - * - * Side Effects: - * The region's 'extents' structure is overwritten. - * - *----------------------------------------------------------------------- - */ -void REGION:: -miSetExtents (Region pReg) -{ - BoxPtr pBox, pBoxEnd, pExtents; - - if (pReg->numRects == 0) - { - pReg->extents.x1 = 0; - pReg->extents.y1 = 0; - pReg->extents.x2 = 0; - pReg->extents.y2 = 0; - return; - } - - pExtents = &pReg->extents; - pBox = pReg->rects; - pBoxEnd = &pBox[pReg->numRects - 1]; - - /* - * Since pBox is the first rectangle in the region, it must have the - * smallest y1 and since pBoxEnd is the last rectangle in the region, - * it must have the largest y2, because of banding. Initialize x1 and - * x2 from pBox and pBoxEnd, resp., as good things to initialize them - * to... - */ - pExtents->x1 = pBox->x1; - pExtents->y1 = pBox->y1; - pExtents->x2 = pBoxEnd->x2; - pExtents->y2 = pBoxEnd->y2; - - wxASSERT_LEVEL_2(pExtents->y1 < pExtents->y2); - while (pBox <= pBoxEnd) - { - if (pBox->x1 < pExtents->x1) - { - pExtents->x1 = pBox->x1; - } - if (pBox->x2 > pExtents->x2) - { - pExtents->x2 = pBox->x2; - } - pBox++; - } - wxASSERT_LEVEL_2(pExtents->x1 < pExtents->x2); -} - -bool REGION:: -XDestroyRegion( - Region r) -{ - free( (char *) r->rects ); - delete r; - return true; -} - -/* TranslateRegion(pRegion, x, y) - translates in place - added by raymond -*/ - -bool REGION:: -XOffsetRegion( - register Region pRegion, - register int x, - register int y) -{ - int nbox; - BOX *pbox; - - pbox = pRegion->rects; - nbox = pRegion->numRects; - - while(nbox--) - { - pbox->x1 += x; - pbox->x2 += x; - pbox->y1 += y; - pbox->y2 += y; - pbox++; - } - pRegion->extents.x1 += x; - pRegion->extents.x2 += x; - pRegion->extents.y1 += y; - pRegion->extents.y2 += y; - return 1; -} - -/*====================================================================== - * Region Intersection - *====================================================================*/ -/*- - *----------------------------------------------------------------------- - * miIntersectO -- - * Handle an overlapping band for miIntersect. - * - * Results: - * None. - * - * Side Effects: - * Rectangles may be added to the region. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -int REGION:: -miIntersectO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - wxCoord y1, - wxCoord y2) -{ - wxCoord x1; - wxCoord x2; - BoxPtr pNextRect; - - pNextRect = &pReg->rects[pReg->numRects]; - - while ((r1 != r1End) && (r2 != r2End)) - { - x1 = wxMax(r1->x1,r2->x1); - x2 = wxMin(r1->x2,r2->x2); - - /* - * If there's any overlap between the two rectangles, add that - * overlap to the new region. - * There's no need to check for subsumption because the only way - * such a need could arise is if some region has two rectangles - * right next to each other. Since that should never happen... - */ - if (x1 < x2) - { - wxASSERT_LEVEL_2(y1rects); - pNextRect->x1 = x1; - pNextRect->y1 = y1; - pNextRect->x2 = x2; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - wxASSERT_LEVEL_2(pReg->numRects <= pReg->size); - } - - /* - * Need to advance the pointers. Shift the one that extends - * to the right the least, since the other still has a chance to - * overlap with that region's next rectangle, if you see what I mean. - */ - if (r1->x2 < r2->x2) - { - r1++; - } - else if (r2->x2 < r1->x2) - { - r2++; - } - else - { - r1++; - r2++; - } - } - return 0; /* lint */ -} - -bool REGION:: -XIntersectRegion( - Region reg1, - Region reg2, /* source regions */ - register Region newReg) /* destination Region */ -{ - /* check for trivial reject */ - if ( (!(reg1->numRects)) || (!(reg2->numRects)) || - (!EXTENTCHECK(®1->extents, ®2->extents))) - newReg->numRects = 0; - else - miRegionOp (newReg, reg1, reg2, - miIntersectO, NULL, NULL); - - /* - * Can't alter newReg's extents before we call miRegionOp because - * it might be one of the source regions and miRegionOp depends - * on the extents of those regions being the same. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - miSetExtents(newReg); - return 1; -} - -void REGION:: -miRegionCopy( - register Region dstrgn, - register Region rgn) - -{ - if (dstrgn != rgn) /* don't want to copy to itself */ - { - if (dstrgn->size < rgn->numRects) - { - if (dstrgn->rects) - { - BOX *prevRects = dstrgn->rects; - - dstrgn->rects = (BOX *) - realloc((char *) dstrgn->rects, - (unsigned) rgn->numRects * (sizeof(BOX))); - if (!dstrgn->rects) - { - free(prevRects); - return; - } - } - dstrgn->size = rgn->numRects; - } - dstrgn->numRects = rgn->numRects; - dstrgn->extents.x1 = rgn->extents.x1; - dstrgn->extents.y1 = rgn->extents.y1; - dstrgn->extents.x2 = rgn->extents.x2; - dstrgn->extents.y2 = rgn->extents.y2; - - memcpy((char *) dstrgn->rects, (char *) rgn->rects, - (int) (rgn->numRects * sizeof(BOX))); - } -} - -/*====================================================================== - * Generic Region Operator - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miCoalesce -- - * Attempt to merge the boxes in the current band with those in the - * previous one. Used only by miRegionOp. - * - * Results: - * The new index for the previous band. - * - * Side Effects: - * If coalescing takes place: - * - rectangles in the previous band will have their y2 fields - * altered. - * - pReg->numRects will be decreased. - * - *----------------------------------------------------------------------- - */ -/* static int*/ -int REGION:: -miCoalesce( - register Region pReg, /* Region to coalesce */ - int prevStart, /* Index of start of previous band */ - int curStart) /* Index of start of current band */ -{ - BoxPtr pPrevBox; /* Current box in previous band */ - BoxPtr pCurBox; /* Current box in current band */ - BoxPtr pRegEnd; /* End of region */ - int curNumRects; /* Number of rectangles in current - * band */ - int prevNumRects; /* Number of rectangles in previous - * band */ - int bandY1; /* Y1 coordinate for current band */ - - pRegEnd = &pReg->rects[pReg->numRects]; - - pPrevBox = &pReg->rects[prevStart]; - prevNumRects = curStart - prevStart; - - /* - * Figure out how many rectangles are in the current band. Have to do - * this because multiple bands could have been added in miRegionOp - * at the end when one region has been exhausted. - */ - pCurBox = &pReg->rects[curStart]; - bandY1 = pCurBox->y1; - for (curNumRects = 0; - (pCurBox != pRegEnd) && (pCurBox->y1 == bandY1); - curNumRects++) - { - pCurBox++; - } - - if (pCurBox != pRegEnd) - { - /* - * If more than one band was added, we have to find the start - * of the last band added so the next coalescing job can start - * at the right place... (given when multiple bands are added, - * this may be pointless -- see above). - */ - pRegEnd--; - while (pRegEnd[-1].y1 == pRegEnd->y1) - { - pRegEnd--; - } - curStart = pRegEnd - pReg->rects; - pRegEnd = pReg->rects + pReg->numRects; - } - - if ((curNumRects == prevNumRects) && (curNumRects != 0)) - { - pCurBox -= curNumRects; - /* - * The bands may only be coalesced if the bottom of the previous - * matches the top scanline of the current. - */ - if (pPrevBox->y2 == pCurBox->y1) - { - /* - * Make sure the bands have boxes in the same places. This - * assumes that boxes have been added in such a way that they - * cover the most area possible. I.e. two boxes in a band must - * have some horizontal space between them. - */ - do - { - if ((pPrevBox->x1 != pCurBox->x1) || - (pPrevBox->x2 != pCurBox->x2)) - { - /* - * The bands don't line up so they can't be coalesced. - */ - return (curStart); - } - pPrevBox++; - pCurBox++; - prevNumRects -= 1; - } while (prevNumRects != 0); - - pReg->numRects -= curNumRects; - pCurBox -= curNumRects; - pPrevBox -= curNumRects; - - /* - * The bands may be merged, so set the bottom y of each box - * in the previous band to that of the corresponding box in - * the current band. - */ - do - { - pPrevBox->y2 = pCurBox->y2; - pPrevBox++; - pCurBox++; - curNumRects -= 1; - } while (curNumRects != 0); - - /* - * If only one band was added to the region, we have to backup - * curStart to the start of the previous band. - * - * If more than one band was added to the region, copy the - * other bands down. The assumption here is that the other bands - * came from the same region as the current one and no further - * coalescing can be done on them since it's all been done - * already... curStart is already in the right place. - */ - if (pCurBox == pRegEnd) - { - curStart = prevStart; - } - else - { - do - { - *pPrevBox++ = *pCurBox++; - } while (pCurBox != pRegEnd); - } - - } - } - return (curStart); -} - -/*- - *----------------------------------------------------------------------- - * miRegionOp -- - * Apply an operation to two regions. Called by miUnion, miInverse, - * miSubtract, miIntersect... - * - * Results: - * None. - * - * Side Effects: - * The new region is overwritten. - * - * Notes: - * The idea behind this function is to view the two regions as sets. - * Together they cover a rectangle of area that this function divides - * into horizontal bands where points are covered only by one region - * or by both. For the first case, the nonOverlapFunc is called with - * each the band and the band's upper and lower extents. For the - * second, the overlapFunc is called to process the entire band. It - * is responsible for clipping the rectangles in the band, though - * this function provides the boundaries. - * At the end of each band, the new region is coalesced, if possible, - * to reduce the number of rectangles in the region. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -void REGION:: -miRegionOp( - register Region newReg, /* Place to store result */ - Region reg1, /* First region in operation */ - Region reg2, /* 2d region in operation */ - int (*overlapFunc)( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - wxCoord y1, - wxCoord y2), /* Function to call for over- - * lapping bands */ - int (*nonOverlap1Func)( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2), /* Function to call for non- - * overlapping bands in region - * 1 */ - int (*nonOverlap2Func)( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2)) /* Function to call for non- - * overlapping bands in region - * 2 */ -{ - BoxPtr r1; /* Pointer into first region */ - BoxPtr r2; /* Pointer into 2d region */ - BoxPtr r1End; /* End of 1st region */ - BoxPtr r2End; /* End of 2d region */ - wxCoord ybot; /* Bottom of intersection */ - wxCoord ytop; /* Top of intersection */ - BoxPtr oldRects; /* Old rects for newReg */ - int prevBand; /* Index of start of - * previous band in newReg */ - int curBand; /* Index of start of current - * band in newReg */ - BoxPtr r1BandEnd; /* End of current band in r1 */ - BoxPtr r2BandEnd; /* End of current band in r2 */ - wxCoord top; /* Top of non-overlapping - * band */ - wxCoord bot; /* Bottom of non-overlapping - * band */ - - /* - * Initialization: - * set r1, r2, r1End and r2End appropriately, preserve the important - * parts of the destination region until the end in case it's one of - * the two source regions, then mark the "new" region empty, allocating - * another array of rectangles for it to use. - */ - r1 = reg1->rects; - r2 = reg2->rects; - r1End = r1 + reg1->numRects; - r2End = r2 + reg2->numRects; - - oldRects = newReg->rects; - - EMPTY_REGION(newReg); - - /* - * Allocate a reasonable number of rectangles for the new region. The idea - * is to allocate enough so the individual functions don't need to - * reallocate and copy the array, which is time consuming, yet we don't - * have to worry about using too much memory. I hope to be able to - * nuke the realloc() at the end of this function eventually. - */ - newReg->size = wxMax(reg1->numRects,reg2->numRects) * 2; - - newReg->rects = (BoxPtr)malloc((unsigned) (sizeof(BoxRec) * newReg->size)); - - if (!newReg->rects) - { - newReg->size = 0; - return; - } - - /* - * Initialize ybot and ytop. - * In the upcoming loop, ybot and ytop serve different functions depending - * on whether the band being handled is an overlapping or non-overlapping - * band. - * In the case of a non-overlapping band (only one of the regions - * has points in the band), ybot is the bottom of the most recent - * intersection and thus clips the top of the rectangles in that band. - * ytop is the top of the next intersection between the two regions and - * serves to clip the bottom of the rectangles in the current band. - * For an overlapping band (where the two regions intersect), ytop clips - * the top of the rectangles of both regions and ybot clips the bottoms. - */ - if (reg1->extents.y1 < reg2->extents.y1) - ybot = reg1->extents.y1; - else - ybot = reg2->extents.y1; - - /* - * prevBand serves to mark the start of the previous band so rectangles - * can be coalesced into larger rectangles. qv. miCoalesce, above. - * In the beginning, there is no previous band, so prevBand == curBand - * (curBand is set later on, of course, but the first band will always - * start at index 0). prevBand and curBand must be indices because of - * the possible expansion, and resultant moving, of the new region's - * array of rectangles. - */ - prevBand = 0; - - do - { - curBand = newReg->numRects; - - /* - * This algorithm proceeds one source-band (as opposed to a - * destination band, which is determined by where the two regions - * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the - * rectangle after the last one in the current band for their - * respective regions. - */ - r1BandEnd = r1; - while ((r1BandEnd != r1End) && (r1BandEnd->y1 == r1->y1)) - { - r1BandEnd++; - } - - r2BandEnd = r2; - while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1)) - { - r2BandEnd++; - } - - /* - * First handle the band that doesn't intersect, if any. - * - * Note that attention is restricted to one band in the - * non-intersecting region at once, so if a region has n - * bands between the current position and the next place it overlaps - * the other, this entire loop will be passed through n times. - */ - if (r1->y1 < r2->y1) - { - top = wxMax(r1->y1,ybot); - bot = wxMin(r1->y2,r2->y1); - - if ((top != bot) && (nonOverlap1Func != NULL)) - { - (* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot); - } - - ytop = r2->y1; - } - else if (r2->y1 < r1->y1) - { - top = wxMax(r2->y1,ybot); - bot = wxMin(r2->y2,r1->y1); - - if ((top != bot) && (nonOverlap2Func != NULL)) - { - (* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot); - } - - ytop = r1->y1; - } - else - { - ytop = r1->y1; - } - - /* - * If any rectangles got added to the region, try and coalesce them - * with rectangles from the previous band. Note we could just do - * this test in miCoalesce, but some machines incur a not - * inconsiderable cost for function calls, so... - */ - if (newReg->numRects != curBand) - { - prevBand = miCoalesce (newReg, prevBand, curBand); - } - - /* - * Now see if we've hit an intersecting band. The two bands only - * intersect if ybot > ytop - */ - ybot = wxMin(r1->y2, r2->y2); - curBand = newReg->numRects; - if (ybot > ytop) - { - (* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot); - - } - - if (newReg->numRects != curBand) - { - prevBand = miCoalesce (newReg, prevBand, curBand); - } - - /* - * If we've finished with a band (y2 == ybot) we skip forward - * in the region to the next band. - */ - if (r1->y2 == ybot) - { - r1 = r1BandEnd; - } - if (r2->y2 == ybot) - { - r2 = r2BandEnd; - } - } while ((r1 != r1End) && (r2 != r2End)); - - /* - * Deal with whichever region still has rectangles left. - */ - curBand = newReg->numRects; - if (r1 != r1End) - { - if (nonOverlap1Func != NULL) - { - do - { - r1BandEnd = r1; - while ((r1BandEnd < r1End) && (r1BandEnd->y1 == r1->y1)) - { - r1BandEnd++; - } - (* nonOverlap1Func) (newReg, r1, r1BandEnd, - wxMax(r1->y1,ybot), r1->y2); - r1 = r1BandEnd; - } while (r1 != r1End); - } - } - else if ((r2 != r2End) && (nonOverlap2Func != NULL)) - { - do - { - r2BandEnd = r2; - while ((r2BandEnd < r2End) && (r2BandEnd->y1 == r2->y1)) - { - r2BandEnd++; - } - (* nonOverlap2Func) (newReg, r2, r2BandEnd, - wxMax(r2->y1,ybot), r2->y2); - r2 = r2BandEnd; - } while (r2 != r2End); - } - - if (newReg->numRects != curBand) - { - (void) miCoalesce (newReg, prevBand, curBand); - } - - /* - * A bit of cleanup. To keep regions from growing without bound, - * we shrink the array of rectangles to match the new number of - * rectangles in the region. This never goes to 0, however... - * - * Only do this stuff if the number of rectangles allocated is more than - * twice the number of rectangles in the region (a simple optimization...). - */ - if (newReg->numRects < (newReg->size >> 1)) - { - if (REGION_NOT_EMPTY(newReg)) - { - BoxPtr prev_rects = newReg->rects; - newReg->size = newReg->numRects; - newReg->rects = (BoxPtr) realloc ((char *) newReg->rects, - (unsigned) (sizeof(BoxRec) * newReg->size)); - if (! newReg->rects) - newReg->rects = prev_rects; - } - else - { - /* - * No point in doing the extra work involved in an realloc if - * the region is empty - */ - newReg->size = 1; - free((char *) newReg->rects); - newReg->rects = (BoxPtr) malloc(sizeof(BoxRec)); - } - } - free ((char *) oldRects); - return; -} - -/*====================================================================== - * Region Union - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miUnionNonO -- - * Handle a non-overlapping band for the union operation. Just - * Adds the rectangles into the region. Doesn't have to check for - * subsumption or anything. - * - * Results: - * None. - * - * Side Effects: - * pReg->numRects is incremented and the final rectangles overwritten - * with the rectangles we're passed. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -int REGION:: -miUnionNonO ( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2) -{ - BoxPtr pNextRect; - - pNextRect = &pReg->rects[pReg->numRects]; - - wxASSERT_LEVEL_2(y1 < y2); - - while (r != rEnd) - { - wxASSERT_LEVEL_2(r->x1 < r->x2); - MEMCHECK(pReg, pNextRect, pReg->rects); - pNextRect->x1 = r->x1; - pNextRect->y1 = y1; - pNextRect->x2 = r->x2; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - - wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); - r++; - } - return 0; /* lint */ -} - - -/*- - *----------------------------------------------------------------------- - * miUnionO -- - * Handle an overlapping band for the union operation. Picks the - * left-most rectangle each time and merges it into the region. - * - * Results: - * None. - * - * Side Effects: - * Rectangles are overwritten in pReg->rects and pReg->numRects will - * be changed. - * - *----------------------------------------------------------------------- - */ - -/* static void*/ -int REGION:: -miUnionO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - register wxCoord y1, - register wxCoord y2) -{ - BoxPtr pNextRect; - - pNextRect = &pReg->rects[pReg->numRects]; - -#define MERGERECT(r) \ - if ((pReg->numRects != 0) && \ - (pNextRect[-1].y1 == y1) && \ - (pNextRect[-1].y2 == y2) && \ - (pNextRect[-1].x2 >= r->x1)) \ - { \ - if (pNextRect[-1].x2 < r->x2) \ - { \ - pNextRect[-1].x2 = r->x2; \ - wxASSERT_LEVEL_2(pNextRect[-1].x1rects); \ - pNextRect->y1 = y1; \ - pNextRect->y2 = y2; \ - pNextRect->x1 = r->x1; \ - pNextRect->x2 = r->x2; \ - pReg->numRects += 1; \ - pNextRect += 1; \ - } \ - wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);\ - r++; - - wxASSERT_LEVEL_2 (y1x1 < r2->x1) - { - MERGERECT(r1); - } - else - { - MERGERECT(r2); - } - } - - if (r1 != r1End) - { - do - { - MERGERECT(r1); - } while (r1 != r1End); - } - else while (r2 != r2End) - { - MERGERECT(r2); - } - return 0; /* lint */ -} - -bool REGION:: -XUnionRegion( - Region reg1, - Region reg2, /* source regions */ - Region newReg) /* destination Region */ -{ - /* checks all the simple cases */ - - /* - * Region 1 and 2 are the same or region 1 is empty - */ - if ( (reg1 == reg2) || (!(reg1->numRects)) ) - { - if (newReg != reg2) - miRegionCopy(newReg, reg2); - return 1; - } - - /* - * if nothing to union (region 2 empty) - */ - if (!(reg2->numRects)) - { - if (newReg != reg1) - miRegionCopy(newReg, reg1); - return 1; - } - - /* - * Region 1 completely subsumes region 2 - */ - if ((reg1->numRects == 1) && - (reg1->extents.x1 <= reg2->extents.x1) && - (reg1->extents.y1 <= reg2->extents.y1) && - (reg1->extents.x2 >= reg2->extents.x2) && - (reg1->extents.y2 >= reg2->extents.y2)) - { - if (newReg != reg1) - miRegionCopy(newReg, reg1); - return 1; - } - - /* - * Region 2 completely subsumes region 1 - */ - if ((reg2->numRects == 1) && - (reg2->extents.x1 <= reg1->extents.x1) && - (reg2->extents.y1 <= reg1->extents.y1) && - (reg2->extents.x2 >= reg1->extents.x2) && - (reg2->extents.y2 >= reg1->extents.y2)) - { - if (newReg != reg2) - miRegionCopy(newReg, reg2); - return 1; - } - - miRegionOp (newReg, reg1, reg2, miUnionO, - miUnionNonO, miUnionNonO); - - newReg->extents.x1 = wxMin(reg1->extents.x1, reg2->extents.x1); - newReg->extents.y1 = wxMin(reg1->extents.y1, reg2->extents.y1); - newReg->extents.x2 = wxMax(reg1->extents.x2, reg2->extents.x2); - newReg->extents.y2 = wxMax(reg1->extents.y2, reg2->extents.y2); - - return 1; -} - -/*====================================================================== - * Region Subtraction - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miSubtractNonO -- - * Deal with non-overlapping band for subtraction. Any parts from - * region 2 we discard. Anything from region 1 we add to the region. - * - * Results: - * None. - * - * Side Effects: - * pReg may be affected. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -int REGION:: -miSubtractNonO1 ( - register Region pReg, - register BoxPtr r, - BoxPtr rEnd, - register wxCoord y1, - register wxCoord y2) -{ - BoxPtr pNextRect; - - pNextRect = &pReg->rects[pReg->numRects]; - - wxASSERT_LEVEL_2(y1x1x2); - MEMCHECK(pReg, pNextRect, pReg->rects); - pNextRect->x1 = r->x1; - pNextRect->y1 = y1; - pNextRect->x2 = r->x2; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - - wxASSERT_LEVEL_2(pReg->numRects <= pReg->size); - - r++; - } - return 0; /* lint */ -} - -/*- - *----------------------------------------------------------------------- - * miSubtractO -- - * Overlapping band subtraction. x1 is the left-most point not yet - * checked. - * - * Results: - * None. - * - * Side Effects: - * pReg may have rectangles added to it. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -int REGION:: -miSubtractO ( - register Region pReg, - register BoxPtr r1, - BoxPtr r1End, - register BoxPtr r2, - BoxPtr r2End, - register wxCoord y1, - register wxCoord y2) -{ - BoxPtr pNextRect; - int x1; - - x1 = r1->x1; - - wxASSERT_LEVEL_2(y1rects[pReg->numRects]; - - while ((r1 != r1End) && (r2 != r2End)) - { - if (r2->x2 <= x1) - { - /* - * Subtrahend missed the boat: go to next subtrahend. - */ - r2++; - } - else if (r2->x1 <= x1) - { - /* - * Subtrahend precedes minuend: nuke left edge of minuend. - */ - x1 = r2->x2; - if (x1 >= r1->x2) - { - /* - * Minuend completely covered: advance to next minuend and - * reset left fence to edge of new minuend. - */ - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - else - { - /* - * Subtrahend now used up since it doesn't extend beyond - * minuend - */ - r2++; - } - } - else if (r2->x1 < r1->x2) - { - /* - * Left part of subtrahend covers part of minuend: add uncovered - * part of minuend to region and skip to next subtrahend. - */ - wxASSERT_LEVEL_2(x1x1); - MEMCHECK(pReg, pNextRect, pReg->rects); - pNextRect->x1 = x1; - pNextRect->y1 = y1; - pNextRect->x2 = r2->x1; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - - wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); - - x1 = r2->x2; - if (x1 >= r1->x2) - { - /* - * Minuend used up: advance to new... - */ - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - else - { - /* - * Subtrahend used up - */ - r2++; - } - } - else - { - /* - * Minuend used up: add any remaining piece before advancing. - */ - if (r1->x2 > x1) - { - MEMCHECK(pReg, pNextRect, pReg->rects); - pNextRect->x1 = x1; - pNextRect->y1 = y1; - pNextRect->x2 = r1->x2; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); - } - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - } - - /* - * Add remaining minuend rectangles to region. - */ - while (r1 != r1End) - { - wxASSERT_LEVEL_2(x1x2); - MEMCHECK(pReg, pNextRect, pReg->rects); - pNextRect->x1 = x1; - pNextRect->y1 = y1; - pNextRect->x2 = r1->x2; - pNextRect->y2 = y2; - pReg->numRects += 1; - pNextRect++; - - wxASSERT_LEVEL_2(pReg->numRects<=pReg->size); - - r1++; - if (r1 != r1End) - { - x1 = r1->x1; - } - } - return 0; /* lint */ -} - -/*- - *----------------------------------------------------------------------- - * miSubtract -- - * Subtract regS from regM and leave the result in regD. - * S stands for subtrahend, M for minuend and D for difference. - * - * Results: - * true. - * - * Side Effects: - * regD is overwritten. - * - *----------------------------------------------------------------------- - */ - -bool REGION::XSubtractRegion(Region regM, Region regS, register Region regD) -{ - /* check for trivial reject */ - if ( (!(regM->numRects)) || (!(regS->numRects)) || - (!EXTENTCHECK(®M->extents, ®S->extents)) ) - { - miRegionCopy(regD, regM); - return true; - } - - miRegionOp (regD, regM, regS, miSubtractO, - miSubtractNonO1, NULL); - - /* - * Can't alter newReg's extents before we call miRegionOp because - * it might be one of the source regions and miRegionOp depends - * on the extents of those regions being the unaltered. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - miSetExtents (regD); - return true; -} - -bool REGION::XXorRegion(Region sra, Region srb, Region dr) -{ - Region tra = XCreateRegion(); - - wxCHECK_MSG( tra, false, wxT("region not created") ); - - Region trb = XCreateRegion(); - - wxCHECK_MSG( trb, false, wxT("region not created") ); - - (void) XSubtractRegion(sra,srb,tra); - (void) XSubtractRegion(srb,sra,trb); - (void) XUnionRegion(tra,trb,dr); - XDestroyRegion(tra); - XDestroyRegion(trb); - return 0; -} - -/* - * Check to see if the region is empty. Assumes a region is passed - * as a parameter - */ -bool REGION::XEmptyRegion(Region r) -{ - if( r->numRects == 0 ) return true; - else return false; -} - -/* - * Check to see if two regions are equal - */ -bool REGION::XEqualRegion(Region r1, Region r2) -{ - int i; - - if( r1->numRects != r2->numRects ) return false; - else if( r1->numRects == 0 ) return true; - else if ( r1->extents.x1 != r2->extents.x1 ) return false; - else if ( r1->extents.x2 != r2->extents.x2 ) return false; - else if ( r1->extents.y1 != r2->extents.y1 ) return false; - else if ( r1->extents.y2 != r2->extents.y2 ) return false; - else for( i=0; i < r1->numRects; i++ ) { - if ( r1->rects[i].x1 != r2->rects[i].x1 ) return false; - else if ( r1->rects[i].x2 != r2->rects[i].x2 ) return false; - else if ( r1->rects[i].y1 != r2->rects[i].y1 ) return false; - else if ( r1->rects[i].y2 != r2->rects[i].y2 ) return false; - } - return true; -} - -bool REGION::XPointInRegion(Region pRegion, int x, int y) -{ - int i; - - if (pRegion->numRects == 0) - return false; - if (!INBOX(pRegion->extents, x, y)) - return false; - for (i=0; inumRects; i++) - { - if (INBOX (pRegion->rects[i], x, y)) - return true; - } - return false; -} - -wxRegionContain REGION::XRectInRegion(register Region region, - int rx, int ry, - unsigned int rwidth, - unsigned int rheight) -{ - BoxPtr pbox; - BoxPtr pboxEnd; - Box rect; - BoxPtr prect = ▭ - int partIn, partOut; - - prect->x1 = rx; - prect->y1 = ry; - prect->x2 = rwidth + rx; - prect->y2 = rheight + ry; - - /* this is (just) a useful optimization */ - if ((region->numRects == 0) || !EXTENTCHECK(®ion->extents, prect)) - return(wxOutRegion); - - partOut = false; - partIn = false; - - /* can stop when both partOut and partIn are true, or we reach prect->y2 */ - for (pbox = region->rects, pboxEnd = pbox + region->numRects; - pbox < pboxEnd; - pbox++) - { - - if (pbox->y2 <= ry) - continue; /* getting up to speed or skipping remainder of band */ - - if (pbox->y1 > ry) - { - partOut = true; /* missed part of rectangle above */ - if (partIn || (pbox->y1 >= prect->y2)) - break; - ry = pbox->y1; /* x guaranteed to be == prect->x1 */ - } - - if (pbox->x2 <= rx) - continue; /* not far enough over yet */ - - if (pbox->x1 > rx) - { - partOut = true; /* missed part of rectangle to left */ - if (partIn) - break; - } - - if (pbox->x1 < prect->x2) - { - partIn = true; /* definitely overlap */ - if (partOut) - break; - } - - if (pbox->x2 >= prect->x2) - { - ry = pbox->y2; /* finished with this band */ - if (ry >= prect->y2) - break; - rx = prect->x1; /* reset x out to left again */ - } else - { - /* - * Because boxes in a band are maximal width, if the first box - * to overlap the rectangle doesn't completely cover it in that - * band, the rectangle must be partially out, since some of it - * will be uncovered in that band. partIn will have been set true - * by now... - */ - break; - } - - } - - return(partIn ? ((ry < prect->y2) ? wxPartRegion : wxInRegion) : - wxOutRegion); -} diff --git a/Source/3rd Party/wx/src/generic/renderg.cpp b/Source/3rd Party/wx/src/generic/renderg.cpp index 34e728e52..8c36e31d1 100644 --- a/Source/3rd Party/wx/src/generic/renderg.cpp +++ b/Source/3rd Party/wx/src/generic/renderg.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 20.07.2003 +// RCS-ID: $Id: renderg.cpp 45498 2007-04-16 13:03:05Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -31,16 +32,11 @@ #include "wx/settings.h" #include "wx/gdicmn.h" #include "wx/module.h" - #include "wx/control.h" #endif //WX_PRECOMP #include "wx/splitter.h" #include "wx/dcmirror.h" -#ifdef __WXMAC__ - #include "wx/osx/private.h" -#endif - // ---------------------------------------------------------------------------- // wxRendererGeneric: our wxRendererNative implementation // ---------------------------------------------------------------------------- @@ -66,8 +62,6 @@ public: virtual int GetHeaderButtonHeight(wxWindow *win); - virtual int GetHeaderButtonMargin(wxWindow *win); - virtual void DrawTreeItemButton(wxWindow *win, wxDC& dc, const wxRect& rect, @@ -100,8 +94,6 @@ public: const wxRect& rect, int flags = 0); - virtual wxSize GetCheckBoxSize(wxWindow *win); - virtual void DrawPushButton(wxWindow *win, wxDC& dc, const wxRect& rect, @@ -112,24 +104,6 @@ public: const wxRect& rect, int flags = 0); - virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0); - - virtual void DrawChoice(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0); - - virtual void DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0); - - virtual void DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0); - - virtual void DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0); - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - virtual void DrawTitleBarBitmap(wxWindow *win, - wxDC& dc, - const wxRect& rect, - wxTitleBarButton button, - int flags = 0); -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); virtual wxRendererVersion GetVersion() const @@ -184,7 +158,10 @@ wxRendererNative& wxRendererNative::GetGeneric() void wxRendererGeneric::Cleanup() { - wxDELETE(sm_rendererGeneric); + if (sm_rendererGeneric) + delete sm_rendererGeneric; + + sm_rendererGeneric = NULL; } wxRendererGeneric* wxRendererGeneric::sm_rendererGeneric = NULL; @@ -235,6 +212,8 @@ wxRendererGeneric::DrawHeaderButton(wxWindow* win, wxHeaderSortIconType sortArrow, wxHeaderButtonParams* params) { + const int CORNER = 1; + const wxCoord x = rect.x, y = rect.y, w = rect.width, @@ -243,20 +222,22 @@ wxRendererGeneric::DrawHeaderButton(wxWindow* win, dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE))); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(rect); - + dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(m_penBlack); - dc.DrawLine( x+w-1, y, x+w-1, y+h ); // right (outer) - dc.DrawLine( x, y+h-1, x+w, y+h-1 ); // bottom (outer) + dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer) + dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer) dc.SetPen(m_penDarkGrey); - dc.DrawLine( x+w-2, y+1, x+w-2, y+h-1 ); // right (inner) - dc.DrawLine( x+1, y+h-2, x+w-1, y+h-2 ); // bottom (inner) + dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner) + dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner) dc.SetPen(m_penHighlight); - dc.DrawLine( x, y, x, y+h-1 ); // left (outer) - dc.DrawLine( x, y, x+w-1, y ); // top (outer) + dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer) + dc.DrawRectangle( x, y, 1, h ); // left (outer) + dc.DrawLine( x, y+h-1, x+1, y+h-1 ); + dc.DrawLine( x+w-1, y, x+w-1, y+1 ); return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params); } @@ -271,7 +252,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win, wxHeaderButtonParams* params) { int labelWidth = 0; - + // Mark this item as selected. For the generic version we'll just draw an // underline if ( flags & wxCONTROL_SELECTED ) @@ -280,7 +261,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win, // native hot-tracking line (on XP) const int penwidth = 3; int y = rect.y + rect.height + 1 - penwidth; - wxColour c = (params && params->m_selectionColour.IsOk()) ? + wxColour c = (params && params->m_selectionColour.Ok()) ? params->m_selectionColour : wxColour(0x66, 0x66, 0x66); wxPen pen(c, penwidth); pen.SetCap(wxCAP_BUTT); @@ -300,7 +281,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win, ar.y += (rect.height - ar.height)/2; ar.x = ar.x + rect.width - 3*ar.width/2; arrowSpace = 3*ar.width/2; // space to preserve when drawing the label - + wxPoint triPt[3]; if ( sortArrow & wxHDR_SORT_ICON_UP ) { @@ -321,116 +302,107 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win, triPt[2].y = ar.height; } - wxColour c = (params && params->m_arrowColour.IsOk()) ? + wxColour c = (params && params->m_arrowColour.Ok()) ? params->m_arrowColour : wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); - - wxDCPenChanger setPen(dc, c); - wxDCBrushChanger setBrush(dc, c); - - wxDCClipper clip(dc, rect); - dc.DrawPolygon( 3, triPt, ar.x, ar.y); + dc.SetPen(wxPen(c)); + dc.SetBrush(wxBrush(c)); + dc.DrawPolygon( 3, triPt, ar.x, ar.y); } labelWidth += arrowSpace; - + + const int margin = 5; // number of pixels to reserve on either side of the label int bmpWidth = 0; + int txtEnd = 0; + + if ( params && params->m_labelBitmap.Ok() ) + bmpWidth = params->m_labelBitmap.GetWidth() + 2; - // draw the bitmap if there is one - if ( params && params->m_labelBitmap.IsOk() ) - { - int w = params->m_labelBitmap.GetWidth(); - int h = params->m_labelBitmap.GetHeight(); - - const int margin = 1; // an extra pixel on either side of the bitmap - - bmpWidth = w + 2*margin; - labelWidth += bmpWidth; - - int x = rect.x + margin; - const int y = rect.y + wxMax(1, (rect.height - h) / 2); - - const int extraSpace = rect.width - labelWidth; - if ( params->m_labelText.empty() && extraSpace > 0 ) - { - // use the alignment flags - switch (params->m_labelAlignment) - { - default: - case wxALIGN_LEFT: - break; - - case wxALIGN_CENTER: - x += extraSpace/2; - break; - - case wxALIGN_RIGHT: - x += extraSpace; - break; - } - } - - wxDCClipper clip(dc, rect); - dc.DrawBitmap(params->m_labelBitmap, x, y, true); - } - + labelWidth += bmpWidth + 2*margin; + // Draw a label if one is given if ( params && !params->m_labelText.empty() ) { - const int margin = 5; // number of pixels to reserve on either side of the label - labelWidth += 2*margin; - - wxFont font = params->m_labelFont.IsOk() ? + wxFont font = params->m_labelFont.Ok() ? params->m_labelFont : win->GetFont(); - wxColour clr = params->m_labelColour.IsOk() ? + wxColour clr = params->m_labelColour.Ok() ? params->m_labelColour : win->GetForegroundColour(); wxString label( params->m_labelText ); - + dc.SetFont(font); dc.SetTextForeground(clr); - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); + dc.SetBackgroundMode(wxTRANSPARENT); - int tw, th, td; + int tw, th, td, x, y; dc.GetTextExtent( label, &tw, &th, &td); - - int x = rect.x + bmpWidth + margin; - const int y = rect.y + wxMax(0, (rect.height - (th+td)) / 2); - + labelWidth += tw; + y = rect.y + wxMax(0, (rect.height - (th+td)) / 2); + // truncate and add an ellipsis (...) if the text is too wide. - const int availWidth = rect.width - labelWidth; -#if wxUSE_CONTROLS - if ( tw > availWidth ) + int targetWidth = rect.width - arrowSpace - bmpWidth - 2*margin; + if ( tw > targetWidth ) { - label = wxControl::Ellipsize(label, - dc, - wxELLIPSIZE_END, - availWidth, - wxELLIPSIZE_FLAGS_NONE); - tw = dc.GetTextExtent(label).x; + int ellipsisWidth; + dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL); + do { + label.Truncate( label.length() - 1 ); + dc.GetTextExtent( label, &tw, &th); + } while (tw + ellipsisWidth > targetWidth && label.length() ); + label.append( wxT("...") ); + tw += ellipsisWidth; } - else // enough space, we can respect alignment -#endif // wxUSE_CONTROLS + + switch (params->m_labelAlignment) + { + default: + case wxALIGN_LEFT: + x = rect.x + margin; + break; + case wxALIGN_CENTER: + x = rect.x + wxMax(0, (rect.width - arrowSpace - tw - bmpWidth)/2); + break; + case wxALIGN_RIGHT: + x = rect.x + wxMax(0, rect.width - arrowSpace - margin - tw - bmpWidth); + break; + } + + dc.DrawText(label, x, y); + txtEnd = x + tw + 2; + } + + // draw the bitmap if there is one + if ( params && params->m_labelBitmap.Ok() ) + { + int w, h, x, y; + w = params->m_labelBitmap.GetWidth(); + h = params->m_labelBitmap.GetHeight(); + + y = rect.y + wxMax(1, (rect.height - h) / 2); + + // if there is a text label, then put the bitmap at the end of the label + if ( txtEnd != 0 ) + { + x = txtEnd; + } + // otherwise use the alignment flags + else { switch (params->m_labelAlignment) { default: case wxALIGN_LEFT: + x = rect.x + margin; break; - case wxALIGN_CENTER: - x += (availWidth - tw)/2; + x = rect.x + wxMax(1, (rect.width - arrowSpace - w)/2); break; - case wxALIGN_RIGHT: - x += availWidth - tw; + x = rect.x + wxMax(1, rect.width - arrowSpace - margin - w); break; } } - - dc.DrawText(label, x, y); - - labelWidth += tw; + dc.DrawBitmap(params->m_labelBitmap, x, y, true); } - return labelWidth; } @@ -448,11 +420,6 @@ int wxRendererGeneric::GetHeaderButtonHeight(wxWindow *win) return h + d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT; } -int wxRendererGeneric::GetHeaderButtonMargin(wxWindow *WXUNUSED(win)) -{ - return 5; -} - // draw the plus or minus sign void @@ -649,11 +616,6 @@ wxRendererGeneric::DrawCheckBox(wxWindow *WXUNUSED(win), } } -wxSize wxRendererGeneric::GetCheckBoxSize(wxWindow *WXUNUSED(win)) -{ - return wxSize(16, 16); -} - void wxRendererGeneric::DrawPushButton(wxWindow *win, wxDC& dc, @@ -671,7 +633,7 @@ wxRendererGeneric::DrawPushButton(wxWindow *win, } void -wxRendererGeneric::DrawItemSelectionRect(wxWindow * win, +wxRendererGeneric::DrawItemSelectionRect(wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) @@ -694,104 +656,11 @@ wxRendererGeneric::DrawItemSelectionRect(wxWindow * win, } dc.SetBrush(brush); - if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED) -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON - && IsControlActive( (ControlRef)win->GetHandle() ) -#endif - ) - dc.SetPen( *wxBLACK_PEN ); - else - dc.SetPen( *wxTRANSPARENT_PEN ); + dc.SetPen(flags & wxCONTROL_CURRENT ? *wxBLACK_PEN : *wxTRANSPARENT_PEN); dc.DrawRectangle( rect ); - - // it's unused everywhere except in wxOSX/Carbon - wxUnusedVar(win); } -void -wxRendererGeneric::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) -{ - // draw the pixels manually because the "dots" in wxPen with wxDOT style - // may be short traits and not really dots - // - // note that to behave in the same manner as DrawRect(), we must exclude - // the bottom and right borders from the rectangle - wxCoord x1 = rect.GetLeft(), - y1 = rect.GetTop(), - x2 = rect.GetRight(), - y2 = rect.GetBottom(); - - dc.SetPen(m_penBlack); - -#ifdef __WXMAC__ - dc.SetLogicalFunction(wxCOPY); -#else - // this seems to be closer than what Windows does than wxINVERT although - // I'm still not sure if it's correct - dc.SetLogicalFunction(wxAND_REVERSE); -#endif - - wxCoord z; - for ( z = x1 + 1; z < x2; z += 2 ) - dc.DrawPoint(z, rect.GetTop()); - - wxCoord shift = z == x2 ? 0 : 1; - for ( z = y1 + shift; z < y2; z += 2 ) - dc.DrawPoint(x2, z); - - shift = z == y2 ? 0 : 1; - for ( z = x2 - shift; z > x1; z -= 2 ) - dc.DrawPoint(z, y2); - - shift = z == x1 ? 0 : 1; - for ( z = y2 - shift; z > y1; z -= 2 ) - dc.DrawPoint(x1, z); - - dc.SetLogicalFunction(wxCOPY); -} - -void wxRendererGeneric::DrawChoice(wxWindow* WXUNUSED(win), wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), int WXUNUSED(flags)) -{ - wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawChoice"); -} - -void wxRendererGeneric::DrawComboBox(wxWindow* WXUNUSED(win), wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), int WXUNUSED(flags)) -{ - wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawComboBox"); -} - -void wxRendererGeneric::DrawRadioBitmap(wxWindow* WXUNUSED(win), wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), int WXUNUSED(flags)) -{ - wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawRadioBitmap"); -} - -void wxRendererGeneric::DrawTextCtrl(wxWindow* WXUNUSED(win), wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), int WXUNUSED(flags)) -{ - wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawTextCtrl"); -} - -#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP - -void wxRendererGeneric::DrawTitleBarBitmap(wxWindow * WXUNUSED(win), - wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), - wxTitleBarButton WXUNUSED(button), - int WXUNUSED(flags)) -{ - // no need to fail here, if wxHAS_DRAW_TITLE_BAR_BITMAP is defined this - // will be implemented in the native renderer and this version is never - // going to be used -- but we still need to define it to allow - // instantiation of this class (which would have been pure virtual - // otherwise) -} - -#endif // wxHAS_DRAW_TITLE_BAR_BITMAP - // ---------------------------------------------------------------------------- // A module to allow cleanup of generic renderer. diff --git a/Source/3rd Party/wx/src/generic/richmsgdlgg.cpp b/Source/3rd Party/wx/src/generic/richmsgdlgg.cpp deleted file mode 100644 index 397cfd051..000000000 --- a/Source/3rd Party/wx/src/generic/richmsgdlgg.cpp +++ /dev/null @@ -1,89 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/richmsgdlgg.cpp -// Purpose: wxGenericRichMessageDialog -// Author: Rickard Westerlund -// Created: 2010-07-04 -// Copyright: (c) 2010 wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_RICHMSGDLG - -#ifndef WX_PRECOMP - #include "wx/checkbox.h" - #include "wx/stattext.h" - #include "wx/sizer.h" -#endif - -#include "wx/collpane.h" -#include "wx/richmsgdlg.h" - -wxIMPLEMENT_CLASS(wxRichMessageDialog, wxDialog) - -// ---------------------------------------------------------------------------- -// Events and handlers -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxGenericRichMessageDialog, wxRichMessageDialogBase) - EVT_COLLAPSIBLEPANE_CHANGED(wxID_ANY, - wxGenericRichMessageDialog::OnPaneChanged) -END_EVENT_TABLE() - -void wxGenericRichMessageDialog::OnPaneChanged(wxCollapsiblePaneEvent& event) -{ - if ( event.GetCollapsed() ) - m_detailsPane->SetLabel( m_detailsExpanderCollapsedLabel ); - else - m_detailsPane->SetLabel( m_detailsExpanderExpandedLabel ); -} - -// ---------------------------------------------------------------------------- -// wxGenericRichMessageDialog -// ---------------------------------------------------------------------------- - -void wxGenericRichMessageDialog::AddMessageDialogCheckBox(wxSizer *sizer) -{ - if ( !m_checkBoxText.empty() ) - { - m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText); - m_checkBox->SetValue(m_checkBoxValue); - - sizer->Add(m_checkBox, wxSizerFlags().Left().Border(wxLEFT|wxTOP, 10)); - } -} - -void wxGenericRichMessageDialog::AddMessageDialogDetails(wxSizer *sizer) -{ - if ( !m_detailedText.empty() ) - { - wxSizer *sizerDetails = new wxBoxSizer( wxHORIZONTAL ); - - m_detailsPane = - new wxCollapsiblePane( this, -1, m_detailsExpanderCollapsedLabel ); - - // add the detailed text - wxWindow *windowPane = m_detailsPane->GetPane(); - wxSizer *sizerPane = new wxBoxSizer( wxHORIZONTAL ); - sizerPane->Add( new wxStaticText( windowPane, -1, m_detailedText ) ); - windowPane->SetSizer( sizerPane ); - - sizerDetails->Add( m_detailsPane, wxSizerFlags().Right().Expand() ); - sizer->Add( sizerDetails, 0, wxTOP|wxLEFT|wxRIGHT | wxALIGN_LEFT, 10 ); - } -} - -bool wxGenericRichMessageDialog::IsCheckBoxChecked() const -{ - // This function can be called before the dialog is shown and hence before - // the check box is created. - return m_checkBox ? m_checkBox->IsChecked() : m_checkBoxValue; -} - -#endif // wxUSE_RICHMSGDLG diff --git a/Source/3rd Party/wx/src/generic/richtooltipg.cpp b/Source/3rd Party/wx/src/generic/richtooltipg.cpp deleted file mode 100644 index 2986f9be3..000000000 --- a/Source/3rd Party/wx/src/generic/richtooltipg.cpp +++ /dev/null @@ -1,711 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/richtooltipg.cpp -// Purpose: Implementation of wxRichToolTip. -// Author: Vadim Zeitlin -// Created: 2011-10-07 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_RICHTOOLTIP - -#ifndef WX_PRECOMP - #include "wx/dcmemory.h" - #include "wx/icon.h" - #include "wx/region.h" - #include "wx/settings.h" - #include "wx/sizer.h" - #include "wx/statbmp.h" - #include "wx/stattext.h" - #include "wx/timer.h" - #include "wx/utils.h" -#endif // WX_PRECOMP - -#include "wx/private/richtooltip.h" -#include "wx/generic/private/richtooltip.h" - -#include "wx/artprov.h" -#include "wx/custombgwin.h" -#include "wx/display.h" -#include "wx/graphics.h" -#include "wx/popupwin.h" -#include "wx/textwrapper.h" - -#ifdef __WXMSW__ - #include "wx/msw/uxtheme.h" - - static const int TTP_BALLOONTITLE = 4; - - static const int TMT_TEXTCOLOR = 3803; - static const int TMT_GRADIENTCOLOR1 = 3810; - static const int TMT_GRADIENTCOLOR2 = 3811; -#endif - -// ---------------------------------------------------------------------------- -// wxRichToolTipPopup: the popup window used by wxRichToolTip. -// ---------------------------------------------------------------------------- - -class wxRichToolTipPopup : - public wxCustomBackgroundWindow -{ -public: - wxRichToolTipPopup(wxWindow* parent, - const wxString& title, - const wxString& message, - const wxIcon& icon, - wxTipKind tipKind, - const wxFont& titleFont_) : - m_timer(this) - { - Create(parent, wxFRAME_SHAPED); - - - wxBoxSizer* const sizerTitle = new wxBoxSizer(wxHORIZONTAL); - if ( icon.IsOk() ) - { - sizerTitle->Add(new wxStaticBitmap(this, wxID_ANY, icon), - wxSizerFlags().Centre().Border(wxRIGHT)); - } - //else: Simply don't show any icon. - - wxStaticText* const labelTitle = new wxStaticText(this, wxID_ANY, ""); - labelTitle->SetLabelText(title); - - wxFont titleFont(titleFont_); - if ( !titleFont.IsOk() ) - { - // Determine the appropriate title font for the current platform. - titleFont = labelTitle->GetFont(); - -#ifdef __WXMSW__ - // When using themes MSW tooltips use larger bluish version of the - // normal font. - wxUxThemeEngine* const theme = GetTooltipTheme(); - if ( theme ) - { - titleFont.MakeLarger(); - - COLORREF c; - if ( FAILED(theme->GetThemeColor - ( - wxUxThemeHandle(parent, L"TOOLTIP"), - TTP_BALLOONTITLE, - 0, - TMT_TEXTCOLOR, - &c - )) ) - { - // Use the standard value of this colour as fallback. - c = 0x993300; - } - - labelTitle->SetForegroundColour(wxRGBToColour(c)); - } - else -#endif // __WXMSW__ - { - // Everything else, including "classic" MSW look uses just the - // bold version of the base font. - titleFont.MakeBold(); - } - } - - labelTitle->SetFont(titleFont); - sizerTitle->Add(labelTitle, wxSizerFlags().Centre()); - - wxBoxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL); - sizerTop->Add(sizerTitle, - wxSizerFlags().DoubleBorder(wxLEFT|wxRIGHT|wxTOP)); - - // Use a spacer as we don't want to have a double border between the - // elements, just a simple one will do. - sizerTop->AddSpacer(wxSizerFlags::GetDefaultBorder()); - - wxTextSizerWrapper wrapper(this); - wxSizer* sizerText = wrapper.CreateSizer(message, -1 /* No wrapping */); - -#ifdef __WXMSW__ - if ( icon.IsOk() && GetTooltipTheme() ) - { - // Themed tooltips under MSW align the text with the title, not - // with the icon, so use a helper horizontal sizer in this case. - wxBoxSizer* const sizerTextIndent = new wxBoxSizer(wxHORIZONTAL); - sizerTextIndent->AddSpacer(icon.GetWidth()); - sizerTextIndent->Add(sizerText, - wxSizerFlags().Border(wxLEFT).Centre()); - - sizerText = sizerTextIndent; - } -#endif // !__WXMSW__ - sizerTop->Add(sizerText, - wxSizerFlags().DoubleBorder(wxLEFT|wxRIGHT|wxBOTTOM) - .Centre()); - - SetSizer(sizerTop); - - const int offsetY = SetTipShapeAndSize(tipKind, GetBestSize()); - if ( offsetY > 0 ) - { - // Offset our contents by the tip height to make it appear in the - // main rectangle. - sizerTop->PrependSpacer(offsetY); - } - - Layout(); - } - - void SetBackgroundColours(wxColour colStart, wxColour colEnd) - { - if ( !colStart.IsOk() ) - { - // Determine the best colour(s) to use on our own. -#ifdef __WXMSW__ - wxUxThemeEngine* const theme = GetTooltipTheme(); - if ( theme ) - { - wxUxThemeHandle hTheme(GetParent(), L"TOOLTIP"); - - COLORREF c1, c2; - if ( FAILED(theme->GetThemeColor - ( - hTheme, - TTP_BALLOONTITLE, - 0, - TMT_GRADIENTCOLOR1, - &c1 - )) || - FAILED(theme->GetThemeColor - ( - hTheme, - TTP_BALLOONTITLE, - 0, - TMT_GRADIENTCOLOR2, - &c2 - )) ) - { - c1 = 0xffffff; - c2 = 0xf0e5e4; - } - - colStart = wxRGBToColour(c1); - colEnd = wxRGBToColour(c2); - } - else -#endif // __WXMSW__ - { - colStart = wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK); - } - } - - if ( colEnd.IsOk() ) - { - // Use gradient-filled background bitmap. - const wxSize size = GetClientSize(); - wxBitmap bmp(size); - { - wxMemoryDC dc(bmp); - dc.Clear(); - dc.GradientFillLinear(size, colStart, colEnd, wxDOWN); - } - - SetBackgroundBitmap(bmp); - } - else // Use solid colour. - { - SetBackgroundColour(colStart); - } - } - - void SetPosition(const wxRect* rect) - { - wxPoint pos; - - if ( !rect || rect->IsEmpty() ) - pos = GetTipPoint(); - else - pos = GetParent()->ClientToScreen( wxPoint( rect->x + rect->width / 2, rect->y + rect->height / 2 ) ); - - // We want our anchor point to coincide with this position so offset - // the position of the top left corner passed to Move() accordingly. - pos -= m_anchorPos; - - Move(pos, wxSIZE_NO_ADJUSTMENTS); - } - - void DoShow() - { - Popup(); - } - - void SetTimeoutAndShow(unsigned timeout, unsigned delay) - { - if ( !timeout && !delay ) - { - DoShow(); - return; - } - - Connect(wxEVT_TIMER, wxTimerEventHandler(wxRichToolTipPopup::OnTimer)); - - m_timeout = timeout; // set for use in OnTimer if we have a delay - m_delayShow = delay != 0; - - if ( !m_delayShow ) - DoShow(); - - m_timer.Start((delay ? delay : timeout), true /* one shot */); - } - -protected: - virtual void OnDismiss() - { - Destroy(); - } - -private: -#ifdef __WXMSW__ - // Returns non-NULL theme only if we're using Win7-style tooltips. - static wxUxThemeEngine* GetTooltipTheme() - { - // Even themed applications under XP still use "classic" tooltips. - if ( wxGetWinVersion() <= wxWinVersion_XP ) - return NULL; - - return wxUxThemeEngine::GetIfActive(); - } -#endif // __WXMSW__ - - // For now we just hard code the tip height, would be nice to do something - // smarter in the future. - static int GetTipHeight() - { -#ifdef __WXMSW__ - if ( GetTooltipTheme() ) - return 20; -#endif // __WXMSW__ - - return 15; - } - - // Get the point to which our tip should point. - wxPoint GetTipPoint() const - { - // Currently we always use the middle of the window. It seems that MSW - // native tooltips use a different point but it's not really clear how - // do they determine it nor whether it's worth the trouble to emulate - // their behaviour. - const wxRect r = GetParent()->GetScreenRect(); - return wxPoint(r.x + r.width/2, r.y + r.height/2); - } - - // Choose the correct orientation depending on the window position. - // - // Also use the tip kind appropriate for the current environment. For MSW - // the right triangles are used and for Mac the equilateral ones as this is - // the prevailing kind under these systems. For everything else we go with - // right triangles as well but without any real rationale so this could be - // tweaked in the future. - wxTipKind GetBestTipKind() const - { - const wxPoint pos = GetTipPoint(); - - // Use GetFromWindow() and not GetFromPoint() here to try to get the - // correct display even if the tip point itself is not visible. - int dpy = wxDisplay::GetFromWindow(GetParent()); - if ( dpy == wxNOT_FOUND ) - dpy = 0; // What else can we do? - - const wxRect rectDpy = wxDisplay(dpy).GetClientArea(); - -#ifdef __WXMAC__ - return pos.y > rectDpy.height/2 ? wxTipKind_Bottom : wxTipKind_Top; -#else // !__WXMAC__ - return pos.y > rectDpy.height/2 - ? pos.x > rectDpy.width/2 - ? wxTipKind_BottomRight - : wxTipKind_BottomLeft - : pos.x > rectDpy.width/2 - ? wxTipKind_TopRight - : wxTipKind_TopLeft; -#endif // __WXMAC__/!__WXMAC__ - } - - // Set the size and shape of the tip window and returns the offset of its - // content area from the top (horizontal offset is always 0 currently). - int SetTipShapeAndSize(wxTipKind tipKind, const wxSize& contentSize) - { -#if wxUSE_GRAPHICS_CONTEXT - wxSize size = contentSize; - - // The size is the vertical size and the offset is the distance from - // edge for asymmetric tips, currently hard-coded to be the same as the - // size. - const int tipSize = GetTipHeight(); - const int tipOffset = tipSize; - - // The horizontal position of the tip. - int x = -1; - - // The vertical coordinates of the tip base and apex. - int yBase = -1, - yApex = -1; - - // The offset of the content part of the window. - int dy = -1; - - // Define symbolic names for the rectangle corners and mid-way points - // that we use below in an attempt to make the code more clear. Notice - // that these values must be consecutive as we iterate over them. - enum RectPoint - { - RectPoint_TopLeft, - RectPoint_Top, - RectPoint_TopRight, - RectPoint_Right, - RectPoint_BotRight, - RectPoint_Bot, - RectPoint_BotLeft, - RectPoint_Left, - RectPoint_Max - }; - - // The starting point for AddArcToPoint() calls below, we iterate over - // all RectPoints from it. - RectPoint pointStart = RectPoint_Max; - - - // Hard-coded radius of the round main rectangle corners. - const double RADIUS = 5; - - // Create a path defining the shape of the tooltip window. - wxGraphicsPath - path = wxGraphicsRenderer::GetDefaultRenderer()->CreatePath(); - - if ( tipKind == wxTipKind_Auto ) - tipKind = GetBestTipKind(); - - // Points defining the tip shape (in clockwise order as we must end at - // tipPoints[0] after drawing the rectangle outline in this order). - wxPoint2DDouble tipPoints[3]; - - switch ( tipKind ) - { - case wxTipKind_Auto: - wxFAIL_MSG( "Impossible kind value" ); - break; - - case wxTipKind_TopLeft: - x = tipOffset; - yApex = 0; - yBase = tipSize; - dy = tipSize; - - tipPoints[0] = wxPoint2DDouble(x, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x + tipSize, yBase); - - pointStart = RectPoint_TopRight; - break; - - case wxTipKind_TopRight: - x = size.x - tipOffset; - yApex = 0; - yBase = tipSize; - dy = tipSize; - - tipPoints[0] = wxPoint2DDouble(x - tipSize, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x, yBase); - - pointStart = RectPoint_TopRight; - break; - - case wxTipKind_BottomLeft: - x = tipOffset; - yApex = size.y + tipSize; - yBase = size.y; - dy = 0; - - tipPoints[0] = wxPoint2DDouble(x + tipSize, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x, yBase); - - pointStart = RectPoint_BotLeft; - break; - - case wxTipKind_BottomRight: - x = size.x - tipOffset; - yApex = size.y + tipSize; - yBase = size.y; - dy = 0; - - tipPoints[0] = wxPoint2DDouble(x, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x - tipSize, yBase); - - pointStart = RectPoint_BotLeft; - break; - - case wxTipKind_Top: - x = size.x/2; - yApex = 0; - yBase = tipSize; - dy = tipSize; - - { - // A half-side of an equilateral triangle is its altitude - // divided by sqrt(3) ~= 1.73. - const double halfside = tipSize/1.73; - - tipPoints[0] = wxPoint2DDouble(x - halfside, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x + halfside, yBase); - } - - pointStart = RectPoint_TopRight; - break; - - case wxTipKind_Bottom: - x = size.x/2; - yApex = size.y + tipSize; - yBase = size.y; - dy = 0; - - { - const double halfside = tipSize/1.73; - - tipPoints[0] = wxPoint2DDouble(x + halfside, yBase); - tipPoints[1] = wxPoint2DDouble(x, yApex); - tipPoints[2] = wxPoint2DDouble(x - halfside, yBase); - } - - pointStart = RectPoint_BotLeft; - break; - - case wxTipKind_None: - x = size.x/2; - dy = 0; - - path.AddRoundedRectangle(0, 0, size.x, size.y, RADIUS); - break; - } - - wxASSERT_MSG( dy != -1, wxS("Unknown tip kind?") ); - - size.y += tipSize; - SetSize(size); - - if ( tipKind != wxTipKind_None ) - { - path.MoveToPoint(tipPoints[0]); - path.AddLineToPoint(tipPoints[1]); - path.AddLineToPoint(tipPoints[2]); - - const double xLeft = 0.; - const double xMid = size.x/2.; - const double xRight = size.x; - - const double yTop = dy; - const double yMid = (dy + size.y)/2.; - const double yBot = dy + contentSize.y; - - wxPoint2DDouble rectPoints[RectPoint_Max]; - rectPoints[RectPoint_TopLeft] = wxPoint2DDouble(xLeft, yTop); - rectPoints[RectPoint_Top] = wxPoint2DDouble(xMid, yTop); - rectPoints[RectPoint_TopRight] = wxPoint2DDouble(xRight, yTop); - rectPoints[RectPoint_Right] = wxPoint2DDouble(xRight, yMid); - rectPoints[RectPoint_BotRight] = wxPoint2DDouble(xRight, yBot); - rectPoints[RectPoint_Bot] = wxPoint2DDouble(xMid, yBot); - rectPoints[RectPoint_BotLeft] = wxPoint2DDouble(xLeft, yBot); - rectPoints[RectPoint_Left] = wxPoint2DDouble(xLeft, yMid); - - // Iterate over all rectangle rectPoints for the first 3 corners. - unsigned n = pointStart; - for ( unsigned corner = 0; corner < 3; corner++ ) - { - const wxPoint2DDouble& pt1 = rectPoints[n]; - - n = (n + 1) % RectPoint_Max; - - const wxPoint2DDouble& pt2 = rectPoints[n]; - - path.AddArcToPoint(pt1.m_x, pt1.m_y, pt2.m_x, pt2.m_y, RADIUS); - - n = (n + 1) % RectPoint_Max; - } - - // Last one wraps to the first point of the tip. - const wxPoint2DDouble& pt1 = rectPoints[n]; - const wxPoint2DDouble& pt2 = tipPoints[0]; - - path.AddArcToPoint(pt1.m_x, pt1.m_y, pt2.m_x, pt2.m_y, RADIUS); - - path.CloseSubpath(); - } - - SetShape(path); -#else // !wxUSE_GRAPHICS_CONTEXT - wxUnusedVar(tipKind); - - int x = contentSize.x/2, - yApex = 0, - dy = 0; - - SetSize(contentSize); -#endif // wxUSE_GRAPHICS_CONTEXT/!wxUSE_GRAPHICS_CONTEXT - - m_anchorPos.x = x; - m_anchorPos.y = yApex; - - return dy; - } - - // Timer event handler hides the tooltip when the timeout expires. - void OnTimer(wxTimerEvent& WXUNUSED(event)) - { - if ( !m_delayShow ) - { - // Doing "Notify" here ensures that our OnDismiss() is called and so we - // also Destroy() ourselves. We could use Dismiss() and call Destroy() - // explicitly from here as well. - DismissAndNotify(); - - return; - } - - m_delayShow = false; - - if ( m_timeout ) - m_timer.Start(m_timeout, true); - - DoShow(); - } - - - // The anchor point offset if we show a tip or the middle of the top side - // otherwise. - wxPoint m_anchorPos; - - // The timer counting down the time until we're hidden. - wxTimer m_timer; - - // We will need to accesss the timeout period when delaying showing tooltip. - int m_timeout; - - // If true, delay showing the tooltip. - bool m_delayShow; - - wxDECLARE_NO_COPY_CLASS(wxRichToolTipPopup); -}; - -// ---------------------------------------------------------------------------- -// wxRichToolTipGenericImpl: generic implementation of wxRichToolTip. -// ---------------------------------------------------------------------------- - -void -wxRichToolTipGenericImpl::SetBackgroundColour(const wxColour& col, - const wxColour& colEnd) -{ - m_colStart = col; - m_colEnd = colEnd; -} - -void wxRichToolTipGenericImpl::SetCustomIcon(const wxIcon& icon) -{ - m_icon = icon; -} - -void wxRichToolTipGenericImpl::SetStandardIcon(int icon) -{ - switch ( icon & wxICON_MASK ) - { - case wxICON_WARNING: - case wxICON_ERROR: - case wxICON_INFORMATION: - // Although we don't use this icon in a list, we need a smallish - // icon here and not an icon of a typical message box size so use - // wxART_LIST to get it. - m_icon = wxArtProvider::GetIcon - ( - wxArtProvider::GetMessageBoxIconId(icon), - wxART_LIST - ); - break; - - case wxICON_QUESTION: - wxFAIL_MSG("Question icon doesn't make sense for a tooltip"); - break; - - case wxICON_NONE: - m_icon = wxNullIcon; - break; - } -} - -void wxRichToolTipGenericImpl::SetTimeout(unsigned millisecondsTimeout, - unsigned millisecondsDelay) -{ - m_delay = millisecondsDelay; - m_timeout = millisecondsTimeout; -} - -void wxRichToolTipGenericImpl::SetTipKind(wxTipKind tipKind) -{ - m_tipKind = tipKind; -} - -void wxRichToolTipGenericImpl::SetTitleFont(const wxFont& font) -{ - m_titleFont = font; -} - -void wxRichToolTipGenericImpl::ShowFor(wxWindow* win, const wxRect* rect) -{ - // Set the focus to the window the tooltip refers to to make it look active. - win->SetFocus(); - - wxRichToolTipPopup* const popup = new wxRichToolTipPopup - ( - win, - m_title, - m_message, - m_icon, - m_tipKind, - m_titleFont - ); - - popup->SetBackgroundColours(m_colStart, m_colEnd); - - popup->SetPosition(rect); - // show or start the timer to delay showing the popup - popup->SetTimeoutAndShow( m_timeout, m_delay ); -} - -// Currently only wxMSW provides a native implementation. -#ifndef __WXMSW__ - -/* static */ -wxRichToolTipImpl* -wxRichToolTipImpl::Create(const wxString& title, const wxString& message) -{ - return new wxRichToolTipGenericImpl(title, message); -} - -#endif // !__WXMSW__ - -#endif // wxUSE_RICHTOOLTIP diff --git a/Source/3rd Party/wx/src/generic/sashwin.cpp b/Source/3rd Party/wx/src/generic/sashwin.cpp deleted file mode 100644 index a26595a65..000000000 --- a/Source/3rd Party/wx/src/generic/sashwin.cpp +++ /dev/null @@ -1,707 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/sashwin.cpp -// Purpose: wxSashWindow implementation. A sash window has an optional -// sash on each edge, allowing it to be dragged. An event -// is generated when the sash is released. -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SASH - -#include "wx/sashwin.h" - -#ifndef WX_PRECOMP - #include "wx/dialog.h" - #include "wx/frame.h" - #include "wx/settings.h" - #include "wx/dcclient.h" - #include "wx/dcscreen.h" - #include "wx/math.h" -#endif - -#include - -#include "wx/laywin.h" - -wxDEFINE_EVENT( wxEVT_SASH_DRAGGED, wxSashEvent ); - -IMPLEMENT_DYNAMIC_CLASS(wxSashWindow, wxWindow) -IMPLEMENT_DYNAMIC_CLASS(wxSashEvent, wxCommandEvent) - -BEGIN_EVENT_TABLE(wxSashWindow, wxWindow) - EVT_PAINT(wxSashWindow::OnPaint) - EVT_SIZE(wxSashWindow::OnSize) - EVT_MOUSE_EVENTS(wxSashWindow::OnMouseEvent) -#if defined( __WXMSW__ ) || defined( __WXMAC__) - EVT_SET_CURSOR(wxSashWindow::OnSetCursor) -#endif // __WXMSW__ || __WXMAC__ - -END_EVENT_TABLE() - -bool wxSashWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, const wxString& name) -{ - return wxWindow::Create(parent, id, pos, size, style, name); -} - -wxSashWindow::~wxSashWindow() -{ - delete m_sashCursorWE; - delete m_sashCursorNS; -} - -void wxSashWindow::Init() -{ - m_draggingEdge = wxSASH_NONE; - m_dragMode = wxSASH_DRAG_NONE; - m_oldX = 0; - m_oldY = 0; - m_firstX = 0; - m_firstY = 0; - m_borderSize = 3; - m_extraBorderSize = 0; - m_minimumPaneSizeX = 0; - m_minimumPaneSizeY = 0; - m_maximumPaneSizeX = 10000; - m_maximumPaneSizeY = 10000; - m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE); - m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS); - m_mouseCaptured = false; - m_currentCursor = NULL; - - // Eventually, we'll respond to colour change messages - InitColours(); -} - -void wxSashWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - DrawBorders(dc); - DrawSashes(dc); -} - -void wxSashWindow::OnMouseEvent(wxMouseEvent& event) -{ - wxCoord x = 0, y = 0; - event.GetPosition(&x, &y); - - wxSashEdgePosition sashHit = SashHitTest(x, y); - - if (event.LeftDown()) - { - CaptureMouse(); - m_mouseCaptured = true; - - if ( sashHit != wxSASH_NONE ) - { - // Required for X to specify that - // that we wish to draw on top of all windows - // - and we optimise by specifying the area - // for creating the overlap window. - // Find the first frame or dialog and use this to specify - // the area to draw on. - wxWindow* parent = this; - - while (parent && !wxDynamicCast(parent, wxDialog) && - !wxDynamicCast(parent, wxFrame)) - parent = parent->GetParent(); - - wxScreenDC::StartDrawingOnTop(parent); - - // We don't say we're dragging yet; we leave that - // decision for the Dragging() branch, to ensure - // the user has dragged a little bit. - m_dragMode = wxSASH_DRAG_LEFT_DOWN; - m_draggingEdge = sashHit; - m_firstX = x; - m_firstY = y; - - if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) ) - { - if (m_currentCursor != m_sashCursorWE) - { - SetCursor(*m_sashCursorWE); - } - m_currentCursor = m_sashCursorWE; - } - else - { - if (m_currentCursor != m_sashCursorNS) - { - SetCursor(*m_sashCursorNS); - } - m_currentCursor = m_sashCursorNS; - } - } - } - else if ( event.LeftUp() && m_dragMode == wxSASH_DRAG_LEFT_DOWN ) - { - // Wasn't a proper drag - if (m_mouseCaptured) - ReleaseMouse(); - m_mouseCaptured = false; - - wxScreenDC::EndDrawingOnTop(); - m_dragMode = wxSASH_DRAG_NONE; - m_draggingEdge = wxSASH_NONE; - } - else if (event.LeftUp() && m_dragMode == wxSASH_DRAG_DRAGGING) - { - // We can stop dragging now and see what we've got. - m_dragMode = wxSASH_DRAG_NONE; - if (m_mouseCaptured) - ReleaseMouse(); - m_mouseCaptured = false; - - // Erase old tracker - DrawSashTracker(m_draggingEdge, m_oldX, m_oldY); - - // End drawing on top (frees the window used for drawing - // over the screen) - wxScreenDC::EndDrawingOnTop(); - - int w, h; - GetSize(&w, &h); - int xp, yp; - GetPosition(&xp, &yp); - - wxSashEdgePosition edge = m_draggingEdge; - m_draggingEdge = wxSASH_NONE; - - wxRect dragRect; - wxSashDragStatus status = wxSASH_STATUS_OK; - - // the new height and width of the window - if -1, it didn't change - int newHeight = wxDefaultCoord, - newWidth = wxDefaultCoord; - - // NB: x and y may be negative and they're relative to the sash window - // upper left corner, while xp and yp are expressed in the parent - // window system of coordinates, so adjust them! After this - // adjustment, all coordinates are relative to the parent window. - y += yp; - x += xp; - - switch (edge) - { - case wxSASH_TOP: - if ( y > yp + h ) - { - // top sash shouldn't get below the bottom one - status = wxSASH_STATUS_OUT_OF_RANGE; - } - else - { - newHeight = h - (y - yp); - } - break; - - case wxSASH_BOTTOM: - if ( y < yp ) - { - // bottom sash shouldn't get above the top one - status = wxSASH_STATUS_OUT_OF_RANGE; - } - else - { - newHeight = y - yp; - } - break; - - case wxSASH_LEFT: - if ( x > xp + w ) - { - // left sash shouldn't get beyond the right one - status = wxSASH_STATUS_OUT_OF_RANGE; - } - else - { - newWidth = w - (x - xp); - } - break; - - case wxSASH_RIGHT: - if ( x < xp ) - { - // and the right sash, finally, shouldn't be beyond the - // left one - status = wxSASH_STATUS_OUT_OF_RANGE; - } - else - { - newWidth = x - xp; - } - break; - - case wxSASH_NONE: - // can this happen at all? - break; - } - - if ( newHeight == wxDefaultCoord ) - { - // didn't change - newHeight = h; - } - else - { - // make sure it's in m_minimumPaneSizeY..m_maximumPaneSizeY range - newHeight = wxMax(newHeight, m_minimumPaneSizeY); - newHeight = wxMin(newHeight, m_maximumPaneSizeY); - } - - if ( newWidth == wxDefaultCoord ) - { - // didn't change - newWidth = w; - } - else - { - // make sure it's in m_minimumPaneSizeY..m_maximumPaneSizeY range - newWidth = wxMax(newWidth, m_minimumPaneSizeX); - newWidth = wxMin(newWidth, m_maximumPaneSizeX); - } - - dragRect = wxRect(x, y, newWidth, newHeight); - - wxSashEvent eventSash(GetId(), edge); - eventSash.SetEventObject(this); - eventSash.SetDragStatus(status); - eventSash.SetDragRect(dragRect); - GetEventHandler()->ProcessEvent(eventSash); - } - else if ( event.LeftUp() ) - { - if (m_mouseCaptured) - ReleaseMouse(); - m_mouseCaptured = false; - } - else if ((event.Moving() || event.Leaving()) && !event.Dragging()) - { - // Just change the cursor if required - if ( sashHit != wxSASH_NONE ) - { - if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) ) - { - if (m_currentCursor != m_sashCursorWE) - { - SetCursor(*m_sashCursorWE); - } - m_currentCursor = m_sashCursorWE; - } - else - { - if (m_currentCursor != m_sashCursorNS) - { - SetCursor(*m_sashCursorNS); - } - m_currentCursor = m_sashCursorNS; - } - } - else - { - SetCursor(wxNullCursor); - m_currentCursor = NULL; - } - } - else if ( event.Dragging() && - ((m_dragMode == wxSASH_DRAG_DRAGGING) || - (m_dragMode == wxSASH_DRAG_LEFT_DOWN)) ) - { - if ( (m_draggingEdge == wxSASH_LEFT) || (m_draggingEdge == wxSASH_RIGHT) ) - { - if (m_currentCursor != m_sashCursorWE) - { - SetCursor(*m_sashCursorWE); - } - m_currentCursor = m_sashCursorWE; - } - else - { - if (m_currentCursor != m_sashCursorNS) - { - SetCursor(*m_sashCursorNS); - } - m_currentCursor = m_sashCursorNS; - } - - if (m_dragMode == wxSASH_DRAG_LEFT_DOWN) - { - m_dragMode = wxSASH_DRAG_DRAGGING; - DrawSashTracker(m_draggingEdge, x, y); - } - else - { - if ( m_dragMode == wxSASH_DRAG_DRAGGING ) - { - // Erase old tracker - DrawSashTracker(m_draggingEdge, m_oldX, m_oldY); - - // Draw new one - DrawSashTracker(m_draggingEdge, x, y); - } - } - m_oldX = x; - m_oldY = y; - } - else if ( event.LeftDClick() ) - { - // Nothing - } - else - { - } -} - -void wxSashWindow::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - SizeWindows(); -} - -wxSashEdgePosition wxSashWindow::SashHitTest(int x, int y, int WXUNUSED(tolerance)) -{ - int cx, cy; - GetClientSize(& cx, & cy); - - int i; - for (i = 0; i < 4; i++) - { - wxSashEdge& edge = m_sashes[i]; - wxSashEdgePosition position = (wxSashEdgePosition) i ; - - if (edge.m_show) - { - switch (position) - { - case wxSASH_TOP: - { - if (y >= 0 && y <= GetEdgeMargin(position)) - return wxSASH_TOP; - break; - } - case wxSASH_RIGHT: - { - if ((x >= cx - GetEdgeMargin(position)) && (x <= cx)) - return wxSASH_RIGHT; - break; - } - case wxSASH_BOTTOM: - { - if ((y >= cy - GetEdgeMargin(position)) && (y <= cy)) - return wxSASH_BOTTOM; - break; - } - case wxSASH_LEFT: - { - if ((x <= GetEdgeMargin(position)) && (x >= 0)) - return wxSASH_LEFT; - break; - } - case wxSASH_NONE: - { - break; - } - } - } - } - return wxSASH_NONE; -} - -// Draw 3D effect borders -void wxSashWindow::DrawBorders(wxDC& dc) -{ - int w, h; - GetClientSize(&w, &h); - - wxPen mediumShadowPen(m_mediumShadowColour, 1, wxPENSTYLE_SOLID); - wxPen darkShadowPen(m_darkShadowColour, 1, wxPENSTYLE_SOLID); - wxPen lightShadowPen(m_lightShadowColour, 1, wxPENSTYLE_SOLID); - wxPen hilightPen(m_hilightColour, 1, wxPENSTYLE_SOLID); - - if ( GetWindowStyleFlag() & wxSW_3DBORDER ) - { - dc.SetPen(mediumShadowPen); - dc.DrawLine(0, 0, w-1, 0); - dc.DrawLine(0, 0, 0, h - 1); - - dc.SetPen(darkShadowPen); - dc.DrawLine(1, 1, w-2, 1); - dc.DrawLine(1, 1, 1, h-2); - - dc.SetPen(hilightPen); - dc.DrawLine(0, h-1, w-1, h-1); - dc.DrawLine(w-1, 0, w-1, h); // Surely the maximum y pos. should be h - 1. - /// Anyway, h is required for MSW. - - dc.SetPen(lightShadowPen); - dc.DrawLine(w-2, 1, w-2, h-2); // Right hand side - dc.DrawLine(1, h-2, w-1, h-2); // Bottom - } - else if ( GetWindowStyleFlag() & wxSW_BORDER ) - { - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawRectangle(0, 0, w-1, h-1); - } - - dc.SetPen(wxNullPen); - dc.SetBrush(wxNullBrush); -} - -void wxSashWindow::DrawSashes(wxDC& dc) -{ - int i; - for (i = 0; i < 4; i++) - if (m_sashes[i].m_show) - DrawSash((wxSashEdgePosition) i, dc); -} - -// Draw the sash -void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc) -{ - int w, h; - GetClientSize(&w, &h); - - wxPen facePen(m_faceColour, 1, wxPENSTYLE_SOLID); - wxBrush faceBrush(m_faceColour, wxBRUSHSTYLE_SOLID); - wxPen mediumShadowPen(m_mediumShadowColour, 1, wxPENSTYLE_SOLID); - wxPen darkShadowPen(m_darkShadowColour, 1, wxPENSTYLE_SOLID); - wxPen lightShadowPen(m_lightShadowColour, 1, wxPENSTYLE_SOLID); - wxPen hilightPen(m_hilightColour, 1, wxPENSTYLE_SOLID); - wxColour blackClr(0, 0, 0); - wxColour whiteClr(255, 255, 255); - wxPen blackPen(blackClr, 1, wxPENSTYLE_SOLID); - wxPen whitePen(whiteClr, 1, wxPENSTYLE_SOLID); - - if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT ) - { - int sashPosition = (edge == wxSASH_LEFT) ? 0 : ( w - GetEdgeMargin(edge) ); - - dc.SetPen(facePen); - dc.SetBrush(faceBrush); - dc.DrawRectangle(sashPosition, 0, GetEdgeMargin(edge), h); - - if (GetWindowStyleFlag() & wxSW_3DSASH) - { - if (edge == wxSASH_LEFT) - { - // Draw a dark grey line on the left to indicate that the - // sash is raised - dc.SetPen(mediumShadowPen); - dc.DrawLine(GetEdgeMargin(edge), 0, GetEdgeMargin(edge), h); - } - else - { - // Draw a highlight line on the right to indicate that the - // sash is raised - dc.SetPen(hilightPen); - dc.DrawLine(w - GetEdgeMargin(edge), 0, w - GetEdgeMargin(edge), h); - } - } - } - else // top or bottom - { - int sashPosition = (edge == wxSASH_TOP) ? 0 : ( h - GetEdgeMargin(edge) ); - - dc.SetPen(facePen); - dc.SetBrush(faceBrush); - dc.DrawRectangle(0, sashPosition, w, GetEdgeMargin(edge)); - - if (GetWindowStyleFlag() & wxSW_3DSASH) - { - if (edge == wxSASH_BOTTOM) - { - // Draw a highlight line on the bottom to indicate that the - // sash is raised - dc.SetPen(hilightPen); - dc.DrawLine(0, h - GetEdgeMargin(edge), w, h - GetEdgeMargin(edge)); - } - else - { - // Draw a drak grey line on the top to indicate that the - // sash is raised - dc.SetPen(mediumShadowPen); - dc.DrawLine(1, GetEdgeMargin(edge), w-1, GetEdgeMargin(edge)); - } - } - } - - dc.SetPen(wxNullPen); - dc.SetBrush(wxNullBrush); -} - -// Draw the sash tracker (for whilst moving the sash) -void wxSashWindow::DrawSashTracker(wxSashEdgePosition edge, int x, int y) -{ - int w, h; - GetClientSize(&w, &h); - - wxScreenDC screenDC; - int x1, y1; - int x2, y2; - - if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT ) - { - x1 = x; y1 = 2; - x2 = x; y2 = h-2; - - if ( (edge == wxSASH_LEFT) && (x1 > w) ) - { - x1 = w; x2 = w; - } - else if ( (edge == wxSASH_RIGHT) && (x1 < 0) ) - { - x1 = 0; x2 = 0; - } - } - else - { - x1 = 2; y1 = y; - x2 = w-2; y2 = y; - - if ( (edge == wxSASH_TOP) && (y1 > h) ) - { - y1 = h; - y2 = h; - } - else if ( (edge == wxSASH_BOTTOM) && (y1 < 0) ) - { - y1 = 0; - y2 = 0; - } - } - - ClientToScreen(&x1, &y1); - ClientToScreen(&x2, &y2); - - wxPen sashTrackerPen(*wxBLACK, 2, wxPENSTYLE_SOLID); - - screenDC.SetLogicalFunction(wxINVERT); - screenDC.SetPen(sashTrackerPen); - screenDC.SetBrush(*wxTRANSPARENT_BRUSH); - - screenDC.DrawLine(x1, y1, x2, y2); - - screenDC.SetLogicalFunction(wxCOPY); - - screenDC.SetPen(wxNullPen); - screenDC.SetBrush(wxNullBrush); -} - -// Position and size subwindows. -// Note that the border size applies to each subwindow, not -// including the edges next to the sash. -void wxSashWindow::SizeWindows() -{ - int cw, ch; - GetClientSize(&cw, &ch); - - if (GetChildren().GetCount() == 1) - { - wxWindow* child = GetChildren().GetFirst()->GetData(); - - int x = 0; - int y = 0; - int width = cw; - int height = ch; - - // Top - if (m_sashes[0].m_show) - { - y = m_borderSize; - height -= m_borderSize; - } - y += m_extraBorderSize; - - // Left - if (m_sashes[3].m_show) - { - x = m_borderSize; - width -= m_borderSize; - } - x += m_extraBorderSize; - - // Right - if (m_sashes[1].m_show) - { - width -= m_borderSize; - } - width -= 2*m_extraBorderSize; - - // Bottom - if (m_sashes[2].m_show) - { - height -= m_borderSize; - } - height -= 2*m_extraBorderSize; - - child->SetSize(x, y, width, height); - } - else if (GetChildren().GetCount() > 1) - { - // Perhaps multiple children are themselves sash windows. - // TODO: this doesn't really work because the subwindows sizes/positions - // must be set to leave a gap for the parent's sash (hit-test and decorations). - // Perhaps we can allow for this within LayoutWindow, testing whether the parent - // is a sash window, and if so, allowing some space for the edges. - wxLayoutAlgorithm layout; - layout.LayoutWindow(this); - } - - wxClientDC dc(this); - DrawBorders(dc); - DrawSashes(dc); -} - -// Initialize colours -void wxSashWindow::InitColours() -{ - // Shadow colours - m_faceColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - m_mediumShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); - m_darkShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW); - m_lightShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); - m_hilightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT); -} - -void wxSashWindow::SetSashVisible(wxSashEdgePosition edge, bool sash) -{ - m_sashes[edge].m_show = sash; - if (sash) - m_sashes[edge].m_margin = m_borderSize; - else - m_sashes[edge].m_margin = 0; -} - -#if defined( __WXMSW__ ) || defined( __WXMAC__) - -// this is currently called (and needed) under MSW only... -void wxSashWindow::OnSetCursor(wxSetCursorEvent& event) -{ - // if we don't do it, the resizing cursor might be set for child window: - // and like this we explicitly say that our cursor should not be used for - // children windows which overlap us - - if ( SashHitTest(event.GetX(), event.GetY()) != wxSASH_NONE) - { - // default processing is ok - event.Skip(); - } - //else: do nothing, in particular, don't call Skip() -} - -#endif // __WXMSW__ || __WXMAC__ - -#endif // wxUSE_SASH diff --git a/Source/3rd Party/wx/src/generic/scrlwing.cpp b/Source/3rd Party/wx/src/generic/scrlwing.cpp index e6290a02a..4ee236b03 100644 --- a/Source/3rd Party/wx/src/generic/scrlwing.cpp +++ b/Source/3rd Party/wx/src/generic/scrlwing.cpp @@ -5,6 +5,7 @@ // Modified by: Vadim Zeitlin on 31.08.00: wxScrollHelper allows to implement. // Ron Lee on 10.4.02: virtual size / auto scrollbars et al. // Created: 01/02/97 +// RCS-ID: $Id: scrlwing.cpp 60600 2009-05-12 10:33:49Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,7 +31,9 @@ #include "wx/utils.h" #include "wx/panel.h" #include "wx/dcclient.h" - #include "wx/timer.h" + #if wxUSE_TIMER + #include "wx/timer.h" + #endif #include "wx/sizer.h" #include "wx/settings.h" #endif @@ -71,17 +74,21 @@ class WXDLLEXPORT wxScrollHelperEvtHandler : public wxEvtHandler { public: - wxScrollHelperEvtHandler(wxScrollHelperBase *scrollHelper) + wxScrollHelperEvtHandler(wxScrollHelper *scrollHelper) { m_scrollHelper = scrollHelper; } virtual bool ProcessEvent(wxEvent& event); -private: - wxScrollHelperBase *m_scrollHelper; + void ResetDrawnFlag() { m_hasDrawnWindow = false; } - wxDECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler); +private: + wxScrollHelper *m_scrollHelper; + + bool m_hasDrawnWindow; + + DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler) }; #if wxUSE_TIMER @@ -93,8 +100,7 @@ private: class wxAutoScrollTimer : public wxTimer { public: - wxAutoScrollTimer(wxWindow *winToScroll, - wxScrollHelperBase *scroll, + wxAutoScrollTimer(wxWindow *winToScroll, wxScrollHelper *scroll, wxEventType eventTypeToSend, int pos, int orient); @@ -102,12 +108,12 @@ public: private: wxWindow *m_win; - wxScrollHelperBase *m_scrollHelper; + wxScrollHelper *m_scrollHelper; wxEventType m_eventType; int m_pos, m_orient; - wxDECLARE_NO_COPY_CLASS(wxAutoScrollTimer); + DECLARE_NO_COPY_CLASS(wxAutoScrollTimer) }; // ============================================================================ @@ -119,7 +125,7 @@ private: // ---------------------------------------------------------------------------- wxAutoScrollTimer::wxAutoScrollTimer(wxWindow *winToScroll, - wxScrollHelperBase *scroll, + wxScrollHelper *scroll, wxEventType eventTypeToSend, int pos, int orient) { @@ -142,13 +148,12 @@ void wxAutoScrollTimer::Notify() // first scroll the window if we are allowed to do it wxScrollWinEvent event1(m_eventType, m_pos, m_orient); event1.SetEventObject(m_win); - event1.SetId(m_win->GetId()); if ( m_scrollHelper->SendAutoScrollEvents(event1) && m_win->GetEventHandler()->ProcessEvent(event1) ) { // and then send a pseudo mouse-move event to refresh the selection wxMouseEvent event2(wxEVT_MOTION); - event2.SetPosition(wxGetMousePosition()); + wxGetMousePosition(&event2.m_x, &event2.m_y); // the mouse event coordinates should be client, not screen as // returned by wxGetMousePosition @@ -161,16 +166,7 @@ void wxAutoScrollTimer::Notify() event2.SetEventObject(m_win); - wxMouseState mouseState = wxGetMouseState(); - - event2.m_leftDown = mouseState.LeftIsDown(); - event2.m_middleDown = mouseState.MiddleIsDown(); - event2.m_rightDown = mouseState.RightIsDown(); - - event2.m_shiftDown = mouseState.ShiftDown(); - event2.m_controlDown = mouseState.ControlDown(); - event2.m_altDown = mouseState.AltDown(); - event2.m_metaDown = mouseState.MetaDown(); + // FIXME: we don't fill in the other members - ok? m_win->GetEventHandler()->ProcessEvent(event2); } @@ -186,20 +182,30 @@ void wxAutoScrollTimer::Notify() // wxScrollHelperEvtHandler // ---------------------------------------------------------------------------- -// Notice that this method is currently duplicated in the method with the same -// name in wxVarScrollHelperEvtHandler class, until this is fixed, the other -// copy of the method needs to be modified every time this version is. bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) { wxEventType evType = event.GetEventType(); - // Pass it on to the real handler: notice that we must not call - // ProcessEvent() on this object itself as it wouldn't pass it to the next - // handler (i.e. the real window) if we're called from a previous handler - // (as indicated by "process here only" flag being set) and we do want to - // execute the handler defined in the window we're associated with right - // now, without waiting until TryAfter() is called from wxEvtHandler. - bool processed = m_nextHandler->ProcessEvent(event); + // the explanation of wxEVT_PAINT processing hack: for historic reasons + // there are 2 ways to process this event in classes deriving from + // wxScrolledWindow. The user code may + // + // 1. override wxScrolledWindow::OnDraw(dc) + // 2. define its own OnPaint() handler + // + // In addition, in wxUniversal wxWindow defines OnPaint() itself and + // always processes the draw event, so we can't just try the window + // OnPaint() first and call our HandleOnPaint() if it doesn't process it + // (the latter would never be called in wxUniversal). + // + // So the solution is to have a flag telling us whether the user code drew + // anything in the window. We set it to true here but reset it to false in + // wxScrolledWindow::OnPaint() handler (which wouldn't be called if the + // user code defined OnPaint() in the derived class) + m_hasDrawnWindow = true; + + // pass it on to the real handler + bool processed = wxEvtHandler::ProcessEvent(event); // always process the size events ourselves, even if the user code handles // them as well, as we need to AdjustScrollbars() @@ -211,25 +217,26 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) if ( evType == wxEVT_SIZE ) { m_scrollHelper->HandleOnSize((wxSizeEvent &)event); + return true; } - if ( processed && event.IsCommandEvent()) - return true; + if ( processed ) + { + // normally, nothing more to do here - except if it was a paint event + // which wasn't really processed, then we'll try to call our + // OnDraw() below (from HandleOnPaint) + if ( m_hasDrawnWindow || event.IsCommandEvent() ) + { + return true; + } + } - // For wxEVT_PAINT the user code can either handle this event as usual or - // override virtual OnDraw(), so if the event hasn't been handled we need - // to call this virtual function ourselves. - if ( -#ifndef __WXUNIVERSAL__ - // in wxUniversal "processed" will always be true, because - // all windows use the paint event to draw themselves. - // In this case we can't use this flag to determine if a custom - // paint event handler already drew our window and we just - // call OnDraw() anyway. - !processed && -#endif // !__WXUNIVERSAL__ - evType == wxEVT_PAINT ) + // reset the skipped flag to false as it might have been set to true in + // ProcessEvent() above + event.Skip(false); + + if ( evType == wxEVT_PAINT ) { m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); return true; @@ -241,12 +248,6 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) return true; } - // reset the skipped flag (which might have been set to true in - // ProcessEvent() above) to be able to test it below - bool wasSkipped = event.GetSkipped(); - if ( wasSkipped ) - event.Skip(false); - if ( evType == wxEVT_SCROLLWIN_TOP || evType == wxEVT_SCROLLWIN_BOTTOM || evType == wxEVT_SCROLLWIN_LINEUP || @@ -256,16 +257,8 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) evType == wxEVT_SCROLLWIN_THUMBTRACK || evType == wxEVT_SCROLLWIN_THUMBRELEASE ) { - m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); - if ( !event.GetSkipped() ) - { - // it makes sense to indicate that we processed the message as we - // did scroll the window (and also notice that wxAutoScrollTimer - // relies on our return value to stop scrolling when we are at top - // or bottom already) - processed = true; - wasSkipped = false; - } + m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); + return !event.GetSkipped(); } if ( evType == wxEVT_ENTER_WINDOW ) @@ -277,66 +270,29 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event); } #if wxUSE_MOUSEWHEEL - // Use GTK's own scroll wheel handling in GtkScrolledWindow -#ifndef __WXGTK20__ else if ( evType == wxEVT_MOUSEWHEEL ) { m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event); return true; } -#endif #endif // wxUSE_MOUSEWHEEL else if ( evType == wxEVT_CHAR ) { m_scrollHelper->HandleOnChar((wxKeyEvent &)event); - if ( !event.GetSkipped() ) - { - processed = true; - wasSkipped = false; - } + return !event.GetSkipped(); } - event.Skip(wasSkipped); - - // We called ProcessEvent() on the next handler, meaning that we explicitly - // worked around the request to process the event in this handler only. As - // explained above, this is unfortunately really necessary but the trouble - // is that the event will continue to be post-processed by the previous - // handler resulting in duplicate calls to event handlers. Call the special - // function below to prevent this from happening, base class DoTryChain() - // will check for it and behave accordingly. - // - // And if we're not called from DoTryChain(), this won't do anything anyhow. - event.DidntHonourProcessOnlyIn(); - - return processed; -} - -// ============================================================================ -// wxAnyScrollHelperBase and wxScrollHelperBase implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxAnyScrollHelperBase -// ---------------------------------------------------------------------------- - -wxAnyScrollHelperBase::wxAnyScrollHelperBase(wxWindow* win) -{ - wxASSERT_MSG( win, wxT("associated window can't be NULL in wxScrollHelper") ); - - m_win = win; - m_targetWindow = NULL; - - m_kbdScrollingEnabled = true; + return false; } // ---------------------------------------------------------------------------- -// wxScrollHelperBase construction +// wxScrollHelper construction // ---------------------------------------------------------------------------- -wxScrollHelperBase::wxScrollHelperBase(wxWindow *win) - : wxAnyScrollHelperBase(win) +wxScrollHelper::wxScrollHelper(wxWindow *win) { + wxASSERT_MSG( win, _T("associated window can't be NULL in wxScrollHelper") ); + m_xScrollPixelsPerLine = m_yScrollPixelsPerLine = m_xScrollPosition = @@ -355,17 +311,22 @@ wxScrollHelperBase::wxScrollHelperBase(wxWindow *win) m_wheelRotation = 0; #endif - m_timerAutoScroll = NULL; + m_win = + m_targetWindow = (wxWindow *)NULL; + + m_timerAutoScroll = (wxTimer *)NULL; m_handler = NULL; - m_win->SetScrollHelper(static_cast(this)); + m_win = win; + + m_win->SetScrollHelper( this ); // by default, the associated window is also the target window DoSetTargetWindow(win); } -wxScrollHelperBase::~wxScrollHelperBase() +wxScrollHelper::~wxScrollHelper() { StopAutoScrolling(); @@ -376,25 +337,24 @@ wxScrollHelperBase::~wxScrollHelperBase() // setting scrolling parameters // ---------------------------------------------------------------------------- -void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX, - int pixelsPerUnitY, - int noUnitsX, - int noUnitsY, - int xPos, - int yPos, - bool noRefresh) +void wxScrollHelper::SetScrollbars(int pixelsPerUnitX, + int pixelsPerUnitY, + int noUnitsX, + int noUnitsY, + int xPos, + int yPos, + bool noRefresh) { - // Convert positions expressed in scroll units to positions in pixels. - int xPosInPixels = (xPos + m_xScrollPosition)*m_xScrollPixelsPerLine, - yPosInPixels = (yPos + m_yScrollPosition)*m_yScrollPixelsPerLine; + int xpos, ypos; + CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos); bool do_refresh = ( (noUnitsX != 0 && m_xScrollLines == 0) || - (noUnitsX < m_xScrollLines && xPosInPixels > pixelsPerUnitX * noUnitsX) || + (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) || (noUnitsY != 0 && m_yScrollLines == 0) || - (noUnitsY < m_yScrollLines && yPosInPixels > pixelsPerUnitY * noUnitsY) || + (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) || (xPos != m_xScrollPosition) || (yPos != m_yScrollPosition) ); @@ -444,7 +404,7 @@ void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX, // [target] window handling // ---------------------------------------------------------------------------- -void wxScrollHelperBase::DeleteEvtHandler() +void wxScrollHelper::DeleteEvtHandler() { // search for m_handler in the handler list if ( m_win && m_handler ) @@ -460,7 +420,7 @@ void wxScrollHelperBase::DeleteEvtHandler() } } -void wxScrollHelperBase::DoSetTargetWindow(wxWindow *target) +void wxScrollHelper::DoSetTargetWindow(wxWindow *target) { m_targetWindow = target; #ifdef __WXMAC__ @@ -480,7 +440,7 @@ void wxScrollHelperBase::DoSetTargetWindow(wxWindow *target) } } -void wxScrollHelperBase::SetTargetWindow(wxWindow *target) +void wxScrollHelper::SetTargetWindow(wxWindow *target) { wxCHECK_RET( target, wxT("target window must not be NULL") ); @@ -490,11 +450,16 @@ void wxScrollHelperBase::SetTargetWindow(wxWindow *target) DoSetTargetWindow(target); } +wxWindow *wxScrollHelper::GetTargetWindow() const +{ + return m_targetWindow; +} + // ---------------------------------------------------------------------------- // scrolling implementation itself // ---------------------------------------------------------------------------- -void wxScrollHelperBase::HandleOnScroll(wxScrollWinEvent& event) +void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event) { int nScrollInc = CalcScrollInc(event); if ( nScrollInc == 0 ) @@ -506,6 +471,7 @@ void wxScrollHelperBase::HandleOnScroll(wxScrollWinEvent& event) } bool needsRefresh = false; + int dx = 0, dy = 0; int orient = event.GetOrientation(); @@ -566,7 +532,7 @@ void wxScrollHelperBase::HandleOnScroll(wxScrollWinEvent& event) } } -int wxScrollHelperBase::CalcScrollInc(wxScrollWinEvent& event) +int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event) { int pos = event.GetPosition(); int orient = event.GetOrientation(); @@ -619,48 +585,261 @@ int wxScrollHelperBase::CalcScrollInc(wxScrollWinEvent& event) if (orient == wxHORIZONTAL) { - if ( m_xScrollPosition + nScrollInc < 0 ) + if (m_xScrollPixelsPerLine > 0) { - // As -ve as we can go - nScrollInc = -m_xScrollPosition; - } - else // check for the other bound - { - const int posMax = m_xScrollLines - m_xScrollLinesPerPage; - if ( m_xScrollPosition + nScrollInc > posMax ) + if ( m_xScrollPosition + nScrollInc < 0 ) { - // As +ve as we can go - nScrollInc = posMax - m_xScrollPosition; + // As -ve as we can go + nScrollInc = -m_xScrollPosition; + } + else // check for the other bound + { + const int posMax = m_xScrollLines - m_xScrollLinesPerPage; + if ( m_xScrollPosition + nScrollInc > posMax ) + { + // As +ve as we can go + nScrollInc = posMax - m_xScrollPosition; + } } } + else + m_targetWindow->Refresh(true, GetScrollRect()); } - else // wxVERTICAL + else { - if ( m_yScrollPosition + nScrollInc < 0 ) + if ( m_yScrollPixelsPerLine > 0 ) { - // As -ve as we can go - nScrollInc = -m_yScrollPosition; - } - else // check for the other bound - { - const int posMax = m_yScrollLines - m_yScrollLinesPerPage; - if ( m_yScrollPosition + nScrollInc > posMax ) + if ( m_yScrollPosition + nScrollInc < 0 ) { - // As +ve as we can go - nScrollInc = posMax - m_yScrollPosition; + // As -ve as we can go + nScrollInc = -m_yScrollPosition; } + else // check for the other bound + { + const int posMax = m_yScrollLines - m_yScrollLinesPerPage; + if ( m_yScrollPosition + nScrollInc > posMax ) + { + // As +ve as we can go + nScrollInc = posMax - m_yScrollPosition; + } + } + } + else + { + // VZ: why do we do this? (FIXME) + m_targetWindow->Refresh(true, GetScrollRect()); } } return nScrollInc; } -void wxScrollHelperBase::DoPrepareDC(wxDC& dc) +// Adjust the scrollbars - new version. +void wxScrollHelper::AdjustScrollbars() +{ + static wxRecursionGuardFlag s_flagReentrancy; + wxRecursionGuard guard(s_flagReentrancy); + if ( guard.IsInside() ) + { + // don't reenter AdjustScrollbars() while another call to + // AdjustScrollbars() is in progress because this may lead to calling + // ScrollWindow() twice and this can really happen under MSW if + // SetScrollbar() call below adds or removes the scrollbar which + // changes the window size and hence results in another + // AdjustScrollbars() call + return; + } + + int w = 0, h = 0; + int oldw, oldh; + + int oldXScroll = m_xScrollPosition; + int oldYScroll = m_yScrollPosition; + + // VZ: at least under Windows this loop is useless because when scrollbars + // [dis]appear we get a WM_SIZE resulting in another call to + // AdjustScrollbars() anyhow. As it doesn't seem to do any harm I leave + // it here for now but it would be better to ensure that all ports + // generate EVT_SIZE when scrollbars [dis]appear, emulating it if + // necessary, and remove it later + // JACS: Stop potential infinite loop by limiting number of iterations + int iterationCount = 0; + const int iterationMax = 5; + do + { + iterationCount ++; + + GetTargetSize(&w, 0); + + // scroll lines per page: if 0, no scrolling is needed + int linesPerPage; + + if ( m_xScrollPixelsPerLine == 0 ) + { + // scrolling is disabled + m_xScrollLines = 0; + m_xScrollPosition = 0; + linesPerPage = 0; + } + else // might need scrolling + { + // Round up integer division to catch any "leftover" client space. + const int wVirt = m_targetWindow->GetVirtualSize().GetWidth(); + m_xScrollLines = (wVirt + m_xScrollPixelsPerLine - 1) / m_xScrollPixelsPerLine; + + // Calculate page size i.e. number of scroll units you get on the + // current client window. + linesPerPage = w / m_xScrollPixelsPerLine; + + // Special case. When client and virtual size are very close but + // the client is big enough, kill scrollbar. + if ((linesPerPage < m_xScrollLines) && (w >= wVirt)) ++linesPerPage; + + if (linesPerPage >= m_xScrollLines) + { + // we're big enough to not need scrolling + linesPerPage = + m_xScrollLines = + m_xScrollPosition = 0; + } + else // we do need a scrollbar + { + if ( linesPerPage < 1 ) + linesPerPage = 1; + + // Correct position if greater than extent of canvas minus + // the visible portion of it or if below zero + const int posMax = m_xScrollLines - linesPerPage; + if ( m_xScrollPosition > posMax ) + m_xScrollPosition = posMax; + else if ( m_xScrollPosition < 0 ) + m_xScrollPosition = 0; + } + } + + m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition, + linesPerPage, m_xScrollLines); + + // The amount by which we scroll when paging + SetScrollPageSize(wxHORIZONTAL, linesPerPage); + + GetTargetSize(0, &h); + + if ( m_yScrollPixelsPerLine == 0 ) + { + // scrolling is disabled + m_yScrollLines = 0; + m_yScrollPosition = 0; + linesPerPage = 0; + } + else // might need scrolling + { + // Round up integer division to catch any "leftover" client space. + const int hVirt = m_targetWindow->GetVirtualSize().GetHeight(); + m_yScrollLines = ( hVirt + m_yScrollPixelsPerLine - 1 ) / m_yScrollPixelsPerLine; + + // Calculate page size i.e. number of scroll units you get on the + // current client window. + linesPerPage = h / m_yScrollPixelsPerLine; + + // Special case. When client and virtual size are very close but + // the client is big enough, kill scrollbar. + if ((linesPerPage < m_yScrollLines) && (h >= hVirt)) ++linesPerPage; + + if (linesPerPage >= m_yScrollLines) + { + // we're big enough to not need scrolling + linesPerPage = + m_yScrollLines = + m_yScrollPosition = 0; + } + else // we do need a scrollbar + { + if ( linesPerPage < 1 ) + linesPerPage = 1; + + // Correct position if greater than extent of canvas minus + // the visible portion of it or if below zero + const int posMax = m_yScrollLines - linesPerPage; + if ( m_yScrollPosition > posMax ) + m_yScrollPosition = posMax; + else if ( m_yScrollPosition < 0 ) + m_yScrollPosition = 0; + } + } + + m_win->SetScrollbar(wxVERTICAL, m_yScrollPosition, + linesPerPage, m_yScrollLines); + + // The amount by which we scroll when paging + SetScrollPageSize(wxVERTICAL, linesPerPage); + + + // If a scrollbar (dis)appeared as a result of this, adjust them again. + oldw = w; + oldh = h; + + GetTargetSize( &w, &h ); + } while ( (w != oldw || h != oldh) && (iterationCount < iterationMax) ); + +#ifdef __WXMOTIF__ + // Sorry, some Motif-specific code to implement a backing pixmap + // for the wxRETAINED style. Implementing a backing store can't + // be entirely generic because it relies on the wxWindowDC implementation + // to duplicate X drawing calls for the backing pixmap. + + if ( m_targetWindow->GetWindowStyle() & wxRETAINED ) + { + Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget()); + + int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine; + int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine; + if (m_targetWindow->GetBackingPixmap() && + !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) && + (m_targetWindow->GetPixmapHeight() == totalPixelHeight))) + { + XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap()); + m_targetWindow->SetBackingPixmap((WXPixmap) 0); + } + + if (!m_targetWindow->GetBackingPixmap() && + (m_xScrollLines != 0) && (m_yScrollLines != 0)) + { + int depth = wxDisplayDepth(); + m_targetWindow->SetPixmapWidth(totalPixelWidth); + m_targetWindow->SetPixmapHeight(totalPixelHeight); + m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), + m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth)); + } + + } +#endif // Motif + + if (oldXScroll != m_xScrollPosition) + { + if (m_xScrollingEnabled) + m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0, + GetScrollRect() ); + else + m_targetWindow->Refresh(true, GetScrollRect()); + } + + if (oldYScroll != m_yScrollPosition) + { + if (m_yScrollingEnabled) + m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), + GetScrollRect() ); + else + m_targetWindow->Refresh(true, GetScrollRect()); + } +} + +void wxScrollHelper::DoPrepareDC(wxDC& dc) { wxPoint pt = dc.GetDeviceOrigin(); #ifdef __WXGTK__ // It may actually be correct to always query - // the m_sign from the DC here, but I leave the + // the m_sign from the DC here, but I leve the // #ifdef GTK for now. if (m_win->GetLayoutDirection() == wxLayout_RightToLeft) dc.SetDeviceOrigin( pt.x + m_xScrollPosition * m_xScrollPixelsPerLine, @@ -672,7 +851,7 @@ void wxScrollHelperBase::DoPrepareDC(wxDC& dc) dc.SetUserScale( m_scaleX, m_scaleY ); } -void wxScrollHelperBase::SetScrollRate( int xstep, int ystep ) +void wxScrollHelper::SetScrollRate( int xstep, int ystep ) { int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; @@ -690,7 +869,7 @@ void wxScrollHelperBase::SetScrollRate( int xstep, int ystep ) AdjustScrollbars(); } -void wxScrollHelperBase::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const +void wxScrollHelper::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const { if ( x_unit ) *x_unit = m_xScrollPixelsPerLine; @@ -699,7 +878,7 @@ void wxScrollHelperBase::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const } -int wxScrollHelperBase::GetScrollLines( int orient ) const +int wxScrollHelper::GetScrollLines( int orient ) const { if ( orient == wxHORIZONTAL ) return m_xScrollLines; @@ -707,7 +886,7 @@ int wxScrollHelperBase::GetScrollLines( int orient ) const return m_yScrollLines; } -int wxScrollHelperBase::GetScrollPageSize(int orient) const +int wxScrollHelper::GetScrollPageSize(int orient) const { if ( orient == wxHORIZONTAL ) return m_xScrollLinesPerPage; @@ -715,7 +894,7 @@ int wxScrollHelperBase::GetScrollPageSize(int orient) const return m_yScrollLinesPerPage; } -void wxScrollHelperBase::SetScrollPageSize(int orient, int pageSize) +void wxScrollHelper::SetScrollPageSize(int orient, int pageSize) { if ( orient == wxHORIZONTAL ) m_xScrollLinesPerPage = pageSize; @@ -723,14 +902,89 @@ void wxScrollHelperBase::SetScrollPageSize(int orient, int pageSize) m_yScrollLinesPerPage = pageSize; } -void wxScrollHelperBase::EnableScrolling (bool x_scroll, bool y_scroll) +/* + * Scroll to given position (scroll position, not pixel position) + */ +void wxScrollHelper::Scroll( int x_pos, int y_pos ) +{ + if (!m_targetWindow) + return; + + if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && + ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; + + int w = 0, h = 0; + GetTargetSize(&w, &h); + + // compute new position: + int new_x = m_xScrollPosition; + int new_y = m_yScrollPosition; + + if ((x_pos != -1) && (m_xScrollPixelsPerLine)) + { + new_x = x_pos; + + // Calculate page size i.e. number of scroll units you get on the + // current client window + int noPagePositions = w/m_xScrollPixelsPerLine; + if (noPagePositions < 1) noPagePositions = 1; + + // Correct position if greater than extent of canvas minus + // the visible portion of it or if below zero + new_x = wxMin( m_xScrollLines-noPagePositions, new_x ); + new_x = wxMax( 0, new_x ); + } + if ((y_pos != -1) && (m_yScrollPixelsPerLine)) + { + new_y = y_pos; + + // Calculate page size i.e. number of scroll units you get on the + // current client window + int noPagePositions = h/m_yScrollPixelsPerLine; + if (noPagePositions < 1) noPagePositions = 1; + + // Correct position if greater than extent of canvas minus + // the visible portion of it or if below zero + new_y = wxMin( m_yScrollLines-noPagePositions, new_y ); + new_y = wxMax( 0, new_y ); + } + + if ( new_x == m_xScrollPosition && new_y == m_yScrollPosition ) + return; // nothing to do, the position didn't change + + // flush all pending repaints before we change m_{x,y}ScrollPosition, as + // otherwise invalidated area could be updated incorrectly later when + // ScrollWindow() makes sure they're repainted before scrolling them + m_targetWindow->Update(); + + // update the position and scroll the window now: + if (m_xScrollPosition != new_x) + { + int old_x = m_xScrollPosition; + m_xScrollPosition = new_x; + m_win->SetScrollPos( wxHORIZONTAL, new_x ); + m_targetWindow->ScrollWindow( (old_x-new_x)*m_xScrollPixelsPerLine, 0, + GetScrollRect() ); + } + + if (m_yScrollPosition != new_y) + { + int old_y = m_yScrollPosition; + m_yScrollPosition = new_y; + m_win->SetScrollPos( wxVERTICAL, new_y ); + m_targetWindow->ScrollWindow( 0, (old_y-new_y)*m_yScrollPixelsPerLine, + GetScrollRect() ); + } +} + +void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll) { m_xScrollingEnabled = x_scroll; m_yScrollingEnabled = y_scroll; } // Where the current view starts from -void wxScrollHelperBase::DoGetViewStart (int *x, int *y) const +void wxScrollHelper::GetViewStart (int *x, int *y) const { if ( x ) *x = m_xScrollPosition; @@ -738,8 +992,7 @@ void wxScrollHelperBase::DoGetViewStart (int *x, int *y) const *y = m_yScrollPosition; } -void wxScrollHelperBase::DoCalcScrolledPosition(int x, int y, - int *xx, int *yy) const +void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; @@ -747,8 +1000,7 @@ void wxScrollHelperBase::DoCalcScrolledPosition(int x, int y, *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } -void wxScrollHelperBase::DoCalcUnscrolledPosition(int x, int y, - int *xx, int *yy) const +void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; @@ -760,7 +1012,7 @@ void wxScrollHelperBase::DoCalcUnscrolledPosition(int x, int y, // geometry // ---------------------------------------------------------------------------- -bool wxScrollHelperBase::ScrollLayout() +bool wxScrollHelper::ScrollLayout() { if ( m_win->GetSizer() && m_targetWindow == m_win ) { @@ -778,7 +1030,7 @@ bool wxScrollHelperBase::ScrollLayout() return m_win->wxWindow::Layout(); } -void wxScrollHelperBase::ScrollDoSetVirtualSize(int x, int y) +void wxScrollHelper::ScrollDoSetVirtualSize(int x, int y) { m_win->wxWindow::DoSetVirtualSize( x, y ); AdjustScrollbars(); @@ -789,7 +1041,7 @@ void wxScrollHelperBase::ScrollDoSetVirtualSize(int x, int y) // wxWindow's GetBestVirtualSize returns the actual window size, // whereas we want to return the virtual size -wxSize wxScrollHelperBase::ScrollGetBestVirtualSize() const +wxSize wxScrollHelper::ScrollGetBestVirtualSize() const { wxSize clientSize(m_win->GetClientSize()); if ( m_win->GetSizer() ) @@ -798,12 +1050,33 @@ wxSize wxScrollHelperBase::ScrollGetBestVirtualSize() const return clientSize; } +// return the window best size from the given best virtual size +wxSize +wxScrollHelper::ScrollGetWindowSizeForVirtualSize(const wxSize& size) const +{ + // Only use the content to set the window size in the direction + // where there's no scrolling; otherwise we're going to get a huge + // window in the direction in which scrolling is enabled + int ppuX, ppuY; + GetScrollPixelsPerUnit(&ppuX, &ppuY); + + wxSize minSize = m_win->GetMinSize(); + + wxSize best(size); + if (ppuX > 0) + best.x = minSize.x + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + if (ppuY > 0) + best.y = minSize.y + wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); + + return best; +} + // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- // Default OnSize resets scrollbars, if any -void wxScrollHelperBase::HandleOnSize(wxSizeEvent& WXUNUSED(event)) +void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) { if ( m_targetWindow->GetAutoLayout() ) { @@ -820,7 +1093,7 @@ void wxScrollHelperBase::HandleOnSize(wxSizeEvent& WXUNUSED(event)) // This calls OnDraw, having adjusted the origin according to the current // scroll position -void wxAnyScrollHelperBase::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) +void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) { // don't use m_targetWindow here, this is always called for ourselves wxPaintDC dc(m_win); @@ -833,79 +1106,95 @@ void wxAnyScrollHelperBase::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) // compatibility here - if we used OnKeyDown(), the programs which process // arrows themselves in their OnChar() would never get the message and like // this they always have the priority -void wxAnyScrollHelperBase::HandleOnChar(wxKeyEvent& event) +void wxScrollHelper::HandleOnChar(wxKeyEvent& event) { - if ( !m_kbdScrollingEnabled ) + int stx = 0, sty = 0, // view origin + szx = 0, szy = 0, // view size (total) + clix = 0, cliy = 0; // view size (on screen) + + GetViewStart(&stx, &sty); + GetTargetSize(&clix, &cliy); + m_targetWindow->GetVirtualSize(&szx, &szy); + + if( m_xScrollPixelsPerLine ) { - event.Skip(); - return; + clix /= m_xScrollPixelsPerLine; + szx /= m_xScrollPixelsPerLine; + } + else + { + clix = 0; + szx = -1; + } + if( m_yScrollPixelsPerLine ) + { + cliy /= m_yScrollPixelsPerLine; + szy /= m_yScrollPixelsPerLine; + } + else + { + cliy = 0; + szy = -1; } - // prepare the event this key press maps to - wxScrollWinEvent newEvent; - - newEvent.SetPosition(0); - newEvent.SetEventObject(m_win); - newEvent.SetId(m_win->GetId()); - - // this is the default, it's changed to wxHORIZONTAL below if needed - newEvent.SetOrientation(wxVERTICAL); - - // some key events result in scrolling in both horizontal and vertical - // direction, e.g. Ctrl-{Home,End}, if this flag is true we should generate - // a second event in horizontal direction in addition to the primary one - bool sendHorizontalToo = false; + int xScrollOld = m_xScrollPosition, + yScrollOld = m_yScrollPosition; + int dsty; switch ( event.GetKeyCode() ) { case WXK_PAGEUP: - newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP); + dsty = sty - (5 * cliy / 6); + Scroll(-1, (dsty == -1) ? 0 : dsty); break; case WXK_PAGEDOWN: - newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN); + Scroll(-1, sty + (5 * cliy / 6)); break; case WXK_HOME: - newEvent.SetEventType(wxEVT_SCROLLWIN_TOP); - - sendHorizontalToo = event.ControlDown(); + Scroll(0, event.ControlDown() ? 0 : -1); break; case WXK_END: - newEvent.SetEventType(wxEVT_SCROLLWIN_BOTTOM); + Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1); + break; - sendHorizontalToo = event.ControlDown(); + case WXK_UP: + Scroll(-1, sty - 1); + break; + + case WXK_DOWN: + Scroll(-1, sty + 1); break; case WXK_LEFT: - newEvent.SetOrientation(wxHORIZONTAL); - // fall through - - case WXK_UP: - newEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP); + Scroll(stx - 1, -1); break; case WXK_RIGHT: - newEvent.SetOrientation(wxHORIZONTAL); - // fall through - - case WXK_DOWN: - newEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN); + Scroll(stx + 1, -1); break; default: - // not a scrolling key + // not for us event.Skip(); - return; } - m_win->ProcessWindowEvent(newEvent); - - if ( sendHorizontalToo ) + if ( m_xScrollPosition != xScrollOld ) { - newEvent.SetOrientation(wxHORIZONTAL); - m_win->ProcessWindowEvent(newEvent); + wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_xScrollPosition, + wxHORIZONTAL); + event.SetEventObject(m_win); + m_win->GetEventHandler()->ProcessEvent(event); + } + + if ( m_yScrollPosition != yScrollOld ) + { + wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_yScrollPosition, + wxVERTICAL); + event.SetEventObject(m_win); + m_win->GetEventHandler()->ProcessEvent(event); } } @@ -914,28 +1203,32 @@ void wxAnyScrollHelperBase::HandleOnChar(wxKeyEvent& event) // a captured mouse is being held outside the window // ---------------------------------------------------------------------------- -bool wxScrollHelperBase::SendAutoScrollEvents(wxScrollWinEvent& event) const +bool wxScrollHelper::SendAutoScrollEvents(wxScrollWinEvent& event) const { // only send the event if the window is scrollable in this direction wxWindow *win = (wxWindow *)event.GetEventObject(); return win->HasScrollbar(event.GetOrientation()); } -void wxScrollHelperBase::StopAutoScrolling() +void wxScrollHelper::StopAutoScrolling() { #if wxUSE_TIMER - wxDELETE(m_timerAutoScroll); + if ( m_timerAutoScroll ) + { + delete m_timerAutoScroll; + m_timerAutoScroll = (wxTimer *)NULL; + } #endif } -void wxScrollHelperBase::HandleOnMouseEnter(wxMouseEvent& event) +void wxScrollHelper::HandleOnMouseEnter(wxMouseEvent& event) { StopAutoScrolling(); event.Skip(); } -void wxScrollHelperBase::HandleOnMouseLeave(wxMouseEvent& event) +void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event) { // don't prevent the usual processing of the event from taking place event.Skip(); @@ -976,7 +1269,7 @@ void wxScrollHelperBase::HandleOnMouseLeave(wxMouseEvent& event) // but seems to happen sometimes under wxMSW - maybe it's a bug // there but for now just ignore it - //wxFAIL_MSG( wxT("can't understand where has mouse gone") ); + //wxFAIL_MSG( _T("can't understand where has mouse gone") ); return; } @@ -1006,7 +1299,7 @@ void wxScrollHelperBase::HandleOnMouseLeave(wxMouseEvent& event) #if wxUSE_MOUSEWHEEL -void wxScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) +void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) { m_wheelRotation += event.GetWheelRotation(); int lines = m_wheelRotation / event.GetWheelDelta(); @@ -1018,12 +1311,9 @@ void wxScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) wxScrollWinEvent newEvent; newEvent.SetPosition(0); - newEvent.SetOrientation( event.GetWheelAxis() == 0 ? wxVERTICAL : wxHORIZONTAL); + newEvent.SetOrientation(wxVERTICAL); newEvent.SetEventObject(m_win); - if ( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL ) - lines = -lines; - if (event.IsPageScroll()) { if (lines > 0) @@ -1050,7 +1340,7 @@ void wxScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) #endif // wxUSE_MOUSEWHEEL -void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) +void wxScrollHelper::HandleOnChildFocus(wxChildFocusEvent& event) { // this event should be processed by all windows in parenthood chain, // e.g. so that nested wxScrolledWindows work correctly @@ -1062,7 +1352,7 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) if ( win == m_targetWindow ) return; // nothing to do -#if defined( __WXOSX__ ) && wxUSE_SCROLLBAR +#ifdef __WXMAC__ if (wxDynamicCast(win, wxScrollBar)) return; #endif @@ -1094,7 +1384,7 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) win->GetParent() == m_targetWindow) // if win is a wxPanel and receives the focus, it should not be // scrolled into view - return; + return; const wxRect viewRect(m_targetWindow->GetClientRect()); @@ -1104,7 +1394,7 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) // part of a wxComboCtrl visible and the button would still be outside the // scrolled area. But do so only if the parent fits *entirely* inside the // scrolled window. In other situations, such as nested wxPanel or - // wxScrolledWindows, the parent might be way too big to fit inside the + // wxScrolledWindows, the parent might be way to big to fit inside the // scrolled window. If that is the case, then make only the focused window // visible if ( win->GetParent() != m_targetWindow) @@ -1114,7 +1404,7 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) if (parent_size.GetWidth() <= viewRect.GetWidth() && parent_size.GetHeight() <= viewRect.GetHeight()) // make the immediate parent visible instead of the focused control - win=parent; + win=parent; } // make win position relative to the m_targetWindow viewing area instead of @@ -1191,367 +1481,53 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) Scroll(startx, starty); } - -#ifdef wxHAS_GENERIC_SCROLLWIN - // ---------------------------------------------------------------------------- -// wxScrollHelper implementation +// wxScrolledWindow implementation // ---------------------------------------------------------------------------- -wxScrollHelper::wxScrollHelper(wxWindow *winToScroll) - : wxScrollHelperBase(winToScroll) +IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel) + +BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel) + EVT_PAINT(wxScrolledWindow::OnPaint) +END_EVENT_TABLE() + +bool wxScrolledWindow::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) { - m_xVisibility = - m_yVisibility = wxSHOW_SB_DEFAULT; + m_targetWindow = this; +#ifdef __WXMAC__ + MacSetClipChildren( true ) ; +#endif + + bool ok = wxPanel::Create(parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name); + + return ok; } -bool wxScrollHelper::IsScrollbarShown(int orient) const +wxScrolledWindow::~wxScrolledWindow() { - wxScrollbarVisibility visibility = orient == wxHORIZONTAL ? m_xVisibility - : m_yVisibility; - - return visibility != wxSHOW_SB_NEVER; } -void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz, - wxScrollbarVisibility vert) +void wxScrolledWindow::OnPaint(wxPaintEvent& event) { - if ( horz != m_xVisibility || vert != m_yVisibility ) - { - m_xVisibility = horz; - m_yVisibility = vert; + // the user code didn't really draw the window if we got here, so set this + // flag to try to call OnDraw() later + m_handler->ResetDrawnFlag(); - AdjustScrollbars(); - } -} - -void -wxScrollHelper::DoAdjustScrollbar(int orient, - int clientSize, - int virtSize, - int pixelsPerUnit, - int& scrollUnits, - int& scrollPosition, - int& scrollLinesPerPage, - wxScrollbarVisibility visibility) -{ - // scroll lines per page: if 0, no scrolling is needed - // check if we need scrollbar in this direction at all - if ( pixelsPerUnit == 0 || clientSize >= virtSize ) - { - // scrolling is disabled or unnecessary - scrollUnits = - scrollPosition = 0; - scrollLinesPerPage = 0; - } - else // might need scrolling - { - // Round up integer division to catch any "leftover" client space. - scrollUnits = (virtSize + pixelsPerUnit - 1) / pixelsPerUnit; - - // Calculate the number of fully scroll units - scrollLinesPerPage = clientSize / pixelsPerUnit; - - if ( scrollLinesPerPage >= scrollUnits ) - { - // we're big enough to not need scrolling - scrollUnits = - scrollPosition = 0; - scrollLinesPerPage = 0; - } - else // we do need a scrollbar - { - if ( scrollLinesPerPage < 1 ) - scrollLinesPerPage = 1; - - // Correct position if greater than extent of canvas minus - // the visible portion of it or if below zero - const int posMax = scrollUnits - scrollLinesPerPage; - if ( scrollPosition > posMax ) - scrollPosition = posMax; - else if ( scrollPosition < 0 ) - scrollPosition = 0; - } - } - - // in wxSHOW_SB_NEVER case don't show the scrollbar even if it's needed, in - // wxSHOW_SB_ALWAYS case show the scrollbar even if it's not needed by - // passing a special range value to SetScrollbar() - int range; - switch ( visibility ) - { - case wxSHOW_SB_NEVER: - range = 0; - break; - - case wxSHOW_SB_ALWAYS: - range = scrollUnits ? scrollUnits : -1; - break; - - default: - wxFAIL_MSG( wxS("unknown scrollbar visibility") ); - // fall through - - case wxSHOW_SB_DEFAULT: - range = scrollUnits; - break; - - } - - m_win->SetScrollbar(orient, scrollPosition, scrollLinesPerPage, range); -} - -void wxScrollHelper::AdjustScrollbars() -{ - static wxRecursionGuardFlag s_flagReentrancy; - wxRecursionGuard guard(s_flagReentrancy); - if ( guard.IsInside() ) - { - // don't reenter AdjustScrollbars() while another call to - // AdjustScrollbars() is in progress because this may lead to calling - // ScrollWindow() twice and this can really happen under MSW if - // SetScrollbar() call below adds or removes the scrollbar which - // changes the window size and hence results in another - // AdjustScrollbars() call - return; - } - - int oldXScroll = m_xScrollPosition; - int oldYScroll = m_yScrollPosition; - - // we may need to readjust the scrollbars several times as enabling one of - // them reduces the area available for the window contents and so can make - // the other scrollbar necessary now although it wasn't necessary before - // - // VZ: normally this loop should be over in at most 2 iterations, I don't - // know why do we need 5 of them - for ( int iterationCount = 0; iterationCount < 5; iterationCount++ ) - { - wxSize clientSize = GetTargetSize(); - const wxSize virtSize = m_targetWindow->GetVirtualSize(); - - // this block of code tries to work around the following problem: the - // window could have been just resized to have enough space to show its - // full contents without the scrollbars, but its client size could be - // not big enough because it does have the scrollbars right now and so - // the scrollbars would remain even though we don't need them any more - // - // to prevent this from happening, check if we have enough space for - // everything without the scrollbars and explicitly disable them then - const wxSize availSize = GetSizeAvailableForScrollTarget( - m_win->GetSize() - m_win->GetWindowBorderSize()); - if ( availSize != clientSize ) - { - if ( availSize.x >= virtSize.x && availSize.y >= virtSize.y ) - { - // this will be enough to make the scrollbars disappear below - // and then the client size will indeed become equal to the - // full available size - clientSize = availSize; - } - } - - - DoAdjustScrollbar(wxHORIZONTAL, - clientSize.x, - virtSize.x, - m_xScrollPixelsPerLine, - m_xScrollLines, - m_xScrollPosition, - m_xScrollLinesPerPage, - m_xVisibility); - - DoAdjustScrollbar(wxVERTICAL, - clientSize.y, - virtSize.y, - m_yScrollPixelsPerLine, - m_yScrollLines, - m_yScrollPosition, - m_yScrollLinesPerPage, - m_yVisibility); - - - // If a scrollbar (dis)appeared as a result of this, we need to adjust - // them again but if the client size didn't change, then we're done - if ( GetTargetSize() == clientSize ) - break; - } - -#ifdef __WXMOTIF__ - // Sorry, some Motif-specific code to implement a backing pixmap - // for the wxRETAINED style. Implementing a backing store can't - // be entirely generic because it relies on the wxWindowDC implementation - // to duplicate X drawing calls for the backing pixmap. - - if ( m_targetWindow->GetWindowStyle() & wxRETAINED ) - { - Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget()); - - int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine; - int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine; - if (m_targetWindow->GetBackingPixmap() && - !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) && - (m_targetWindow->GetPixmapHeight() == totalPixelHeight))) - { - XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap()); - m_targetWindow->SetBackingPixmap((WXPixmap) 0); - } - - if (!m_targetWindow->GetBackingPixmap() && - (m_xScrollLines != 0) && (m_yScrollLines != 0)) - { - int depth = wxDisplayDepth(); - m_targetWindow->SetPixmapWidth(totalPixelWidth); - m_targetWindow->SetPixmapHeight(totalPixelHeight); - m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), - m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth)); - } - - } -#endif // Motif - - if (oldXScroll != m_xScrollPosition) - { - if (m_xScrollingEnabled) - m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0, - GetScrollRect() ); - else - m_targetWindow->Refresh(true, GetScrollRect()); - } - - if (oldYScroll != m_yScrollPosition) - { - if (m_yScrollingEnabled) - m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), - GetScrollRect() ); - else - m_targetWindow->Refresh(true, GetScrollRect()); - } -} - -void wxScrollHelper::DoScroll( int x_pos, int y_pos ) -{ - if (!m_targetWindow) - return; - - if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && - ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; - - int w = 0, h = 0; - GetTargetSize(&w, &h); - - // compute new position: - int new_x = m_xScrollPosition; - int new_y = m_yScrollPosition; - - if ((x_pos != -1) && (m_xScrollPixelsPerLine)) - { - new_x = x_pos; - - // Calculate page size i.e. number of scroll units you get on the - // current client window - int noPagePositions = w/m_xScrollPixelsPerLine; - if (noPagePositions < 1) noPagePositions = 1; - - // Correct position if greater than extent of canvas minus - // the visible portion of it or if below zero - new_x = wxMin( m_xScrollLines-noPagePositions, new_x ); - new_x = wxMax( 0, new_x ); - } - if ((y_pos != -1) && (m_yScrollPixelsPerLine)) - { - new_y = y_pos; - - // Calculate page size i.e. number of scroll units you get on the - // current client window - int noPagePositions = h/m_yScrollPixelsPerLine; - if (noPagePositions < 1) noPagePositions = 1; - - // Correct position if greater than extent of canvas minus - // the visible portion of it or if below zero - new_y = wxMin( m_yScrollLines-noPagePositions, new_y ); - new_y = wxMax( 0, new_y ); - } - - if ( new_x == m_xScrollPosition && new_y == m_yScrollPosition ) - return; // nothing to do, the position didn't change - - // flush all pending repaints before we change m_{x,y}ScrollPosition, as - // otherwise invalidated area could be updated incorrectly later when - // ScrollWindow() makes sure they're repainted before scrolling them - m_targetWindow->Update(); - - // update the position and scroll the window now: - if (m_xScrollPosition != new_x) - { - int old_x = m_xScrollPosition; - m_xScrollPosition = new_x; - m_win->SetScrollPos( wxHORIZONTAL, new_x ); - m_targetWindow->ScrollWindow( (old_x-new_x)*m_xScrollPixelsPerLine, 0, - GetScrollRect() ); - } - - if (m_yScrollPosition != new_y) - { - int old_y = m_yScrollPosition; - m_yScrollPosition = new_y; - m_win->SetScrollPos( wxVERTICAL, new_y ); - m_targetWindow->ScrollWindow( 0, (old_y-new_y)*m_yScrollPixelsPerLine, - GetScrollRect() ); - } -} - -#endif // wxHAS_GENERIC_SCROLLWIN - -// ---------------------------------------------------------------------------- -// wxScrolled and wxScrolledWindow implementation -// ---------------------------------------------------------------------------- - -wxSize wxScrolledT_Helper::FilterBestSize(const wxWindow *win, - const wxScrollHelper *helper, - const wxSize& origBest) -{ - // NB: We don't do this in WX_FORWARD_TO_SCROLL_HELPER, because not - // all scrollable windows should behave like this, only those that - // contain children controls within scrollable area - // (i.e., wxScrolledWindow) and other some scrollable windows may - // have different DoGetBestSize() implementation (e.g. wxTreeCtrl). - - wxSize best = origBest; - - if ( win->GetAutoLayout() ) - { - // Only use the content to set the window size in the direction - // where there's no scrolling; otherwise we're going to get a huge - // window in the direction in which scrolling is enabled - int ppuX, ppuY; - helper->GetScrollPixelsPerUnit(&ppuX, &ppuY); - - // NB: This code used to use *current* size if min size wasn't - // specified, presumably to get some reasonable (i.e., larger than - // minimal) size. But that's a wrong thing to do in GetBestSize(), - // so we use minimal size as specified. If the app needs some - // minimal size for its scrolled window, it should set it and put - // the window into sizer as expandable so that it can use all space - // available to it. - // - // See also http://svn.wxwidgets.org/viewvc/wx?view=rev&revision=45864 - - wxSize minSize = win->GetMinSize(); - - if ( ppuX > 0 ) - best.x = minSize.x + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - - if ( ppuY > 0 ) - best.y = minSize.y + wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); - } - - return best; + event.Skip(); } #ifdef __WXMSW__ -WXLRESULT wxScrolledT_Helper::FilterMSWWindowProc(WXUINT nMsg, WXLRESULT rc) +WXLRESULT wxScrolledWindow::MSWWindowProc(WXUINT nMsg, + WXWPARAM wParam, + WXLPARAM lParam) { + WXLRESULT rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam); + #ifndef __WXWINCE__ // we need to process arrows ourselves for scrolling if ( nMsg == WM_GETDLGCODE ) @@ -1559,10 +1535,8 @@ WXLRESULT wxScrolledT_Helper::FilterMSWWindowProc(WXUINT nMsg, WXLRESULT rc) rc |= DLGC_WANTARROWS; } #endif + return rc; } -#endif // __WXMSW__ -// NB: skipping wxScrolled in wxRTTI information because being a templte, -// it doesn't and can't implement wxRTTI support -IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel) +#endif // __WXMSW__ diff --git a/Source/3rd Party/wx/src/generic/selstore.cpp b/Source/3rd Party/wx/src/generic/selstore.cpp index a3efa331f..653de1511 100644 --- a/Source/3rd Party/wx/src/generic/selstore.cpp +++ b/Source/3rd Party/wx/src/generic/selstore.cpp @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/selstore.cpp +// Name: generic/selstore.cpp // Purpose: wxSelectionStore implementation // Author: Vadim Zeitlin // Modified by: // Created: 08.06.03 (extracted from src/generic/listctrl.cpp) +// RCS-ID: $Id: selstore.cpp 27853 2004-06-17 16:22:36Z ABX $ // Copyright: (c) 2000-2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -32,7 +33,7 @@ // tests // ---------------------------------------------------------------------------- -bool wxSelectionStore::IsSelected(unsigned item) const +bool wxSelectionStore::IsSelected(size_t item) const { bool isSel = m_itemsSel.Index(item) != wxNOT_FOUND; @@ -45,7 +46,7 @@ bool wxSelectionStore::IsSelected(unsigned item) const // Select*() // ---------------------------------------------------------------------------- -bool wxSelectionStore::SelectItem(unsigned item, bool select) +bool wxSelectionStore::SelectItem(size_t item, bool select) { // search for the item ourselves as like this we get the index where to // insert it later if needed, so we do only one search in the array instead @@ -74,16 +75,16 @@ bool wxSelectionStore::SelectItem(unsigned item, bool select) return false; } -bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, +bool wxSelectionStore::SelectRange(size_t itemFrom, size_t itemTo, bool select, wxArrayInt *itemsChanged) { // 100 is hardcoded but it shouldn't matter much: the important thing is // that we don't refresh everything when really few (e.g. 1 or 2) items // change state - static const unsigned MANY_ITEMS = 100; + static const size_t MANY_ITEMS = 100; - wxASSERT_MSG( itemFrom <= itemTo, wxT("should be in order") ); + wxASSERT_MSG( itemFrom <= itemTo, _T("should be in order") ); // are we going to have more [un]selected items than the other ones? if ( itemTo - itemFrom > m_count/2 ) @@ -101,7 +102,7 @@ bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, // TODO: it should be possible to optimize the searches a bit // knowing the possible range - unsigned item; + size_t item; for ( item = 0; item < itemFrom; item++ ) { if ( selOld.Index(item) == wxNOT_FOUND ) @@ -165,7 +166,7 @@ bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, } // just add the items to the selection - for ( unsigned item = itemFrom; item <= itemTo; item++ ) + for ( size_t item = itemFrom; item <= itemTo; item++ ) { if ( SelectItem(item, select) && itemsChanged ) { @@ -190,7 +191,7 @@ bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, // callbacks // ---------------------------------------------------------------------------- -void wxSelectionStore::OnItemDelete(unsigned item) +void wxSelectionStore::OnItemDelete(size_t item) { size_t count = m_itemsSel.GetCount(), i = m_itemsSel.IndexForInsert(item); @@ -207,25 +208,9 @@ void wxSelectionStore::OnItemDelete(unsigned item) while ( i < count ) { // all following elements must be greater than the one we deleted - wxASSERT_MSG( m_itemsSel[i] > item, wxT("logic error") ); + wxASSERT_MSG( m_itemsSel[i] > item, _T("logic error") ); m_itemsSel[i++]--; } } -void wxSelectionStore::SetItemCount(unsigned count) -{ - // forget about all items whose indices are now invalid if the size - // decreased - if ( count < m_count ) - { - for ( size_t i = m_itemsSel.GetCount(); i > 0; i-- ) - { - if ( m_itemsSel[i - 1] >= count ) - m_itemsSel.RemoveAt(i - 1); - } - } - - // remember the new number of items - m_count = count; -} diff --git a/Source/3rd Party/wx/src/generic/spinctlg.cpp b/Source/3rd Party/wx/src/generic/spinctlg.cpp index 9eb5f7011..92f3eeea4 100644 --- a/Source/3rd Party/wx/src/generic/spinctlg.cpp +++ b/Source/3rd Party/wx/src/generic/spinctlg.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 29.01.01 +// RCS-ID: $Id: spinctlg.cpp 52582 2008-03-17 13:46:31Z VZ $ // Copyright: (c) 2001 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -23,709 +24,368 @@ #pragma hdrstop #endif +// There are port-specific versions for MSW, GTK, OS/2 and Mac, so exclude the +// contents of this file in those cases +#if !(defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXPM__) || \ + defined(__WXMAC__)) || defined(__WXUNIVERSAL__) + #ifndef WX_PRECOMP #include "wx/textctrl.h" #endif //WX_PRECOMP -#include "wx/spinctrl.h" -#include "wx/tooltip.h" - #if wxUSE_SPINCTRL -IMPLEMENT_DYNAMIC_CLASS(wxSpinDoubleEvent, wxNotifyEvent) - -// There are port-specific versions for the wxSpinCtrl, so exclude the -// contents of this file in those cases -#if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE) - #include "wx/spinbutt.h" - -#if wxUSE_SPINBTN +#include "wx/spinctrl.h" // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- -// The margin between the text control and the spin: the value here is the same -// as the margin between the spin button and its "buddy" text control in wxMSW -// so the generic control looks similarly to the native one there, we might -// need to use different value for the other platforms (and maybe even -// determine it dynamically?). -static const wxCoord MARGIN = 1; - -#define SPINCTRLBUT_MAX 32000 // large to avoid wrap around trouble +// the margin between the text control and the spin +static const wxCoord MARGIN = 2; // ---------------------------------------------------------------------------- -// wxSpinCtrlTextGeneric: text control used by spin control +// wxSpinCtrlText: text control used by spin control // ---------------------------------------------------------------------------- -class wxSpinCtrlTextGeneric : public wxTextCtrl +class wxSpinCtrlText : public wxTextCtrl { public: - wxSpinCtrlTextGeneric(wxSpinCtrlGenericBase *spin, const wxString& value, long style=0) - : wxTextCtrl(spin, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, - // This is tricky: we want to honour any alignment flags - // but not wxALIGN_CENTER_VERTICAL because it's the same - // as wxTE_PASSWORD and we definitely don't want to show - // asterisks in spin control. - style & (wxALIGN_MASK | wxTE_PROCESS_ENTER) & ~wxTE_PASSWORD) + wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value) + : wxTextCtrl(spin->GetParent(), wxID_ANY, value) { m_spin = spin; // remove the default minsize, the spinctrl will have one instead - SetSizeHints(wxDefaultCoord, wxDefaultCoord); + SetSizeHints(wxDefaultCoord,wxDefaultCoord); } - virtual ~wxSpinCtrlTextGeneric() +protected: + void OnTextChange(wxCommandEvent& event) { - // MSW sends extra kill focus event on destroy - if (m_spin) - m_spin->m_textCtrl = NULL; - - m_spin = NULL; - } - - void OnChar( wxKeyEvent &event ) - { - if ( !m_spin->ProcessWindowEvent(event) ) - event.Skip(); - } - - void OnTextEvent(wxCommandEvent& event) - { - wxCommandEvent eventCopy(event); - eventCopy.SetEventObject(m_spin); - eventCopy.SetId(m_spin->GetId()); - m_spin->ProcessWindowEvent(eventCopy); - } - - void OnKillFocus(wxFocusEvent& event) - { - if (m_spin) - m_spin->ProcessWindowEvent(event); + int val; + if ( m_spin->GetTextValue(&val) ) + { + m_spin->GetSpinButton()->SetValue(val); + } event.Skip(); } - wxSpinCtrlGenericBase *m_spin; + bool ProcessEvent(wxEvent &event) + { + // Hand button down events to wxSpinCtrl. Doesn't work. + if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event )) + return true; + + return wxTextCtrl::ProcessEvent( event ); + } private: + wxSpinCtrl *m_spin; + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(wxSpinCtrlTextGeneric, wxTextCtrl) - EVT_CHAR(wxSpinCtrlTextGeneric::OnChar) - - // Forward the text events to wxSpinCtrl itself adjusting them slightly in - // the process. - EVT_TEXT(wxID_ANY, wxSpinCtrlTextGeneric::OnTextEvent) - - // And we need to forward this one too as wxSpinCtrl is supposed to - // generate it if wxTE_PROCESS_ENTER is used with it (and if it isn't, - // we're never going to get EVT_TEXT_ENTER in the first place). - EVT_TEXT_ENTER(wxID_ANY, wxSpinCtrlTextGeneric::OnTextEvent) - - EVT_KILL_FOCUS(wxSpinCtrlTextGeneric::OnKillFocus) +BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl) + EVT_TEXT(wxID_ANY, wxSpinCtrlText::OnTextChange) END_EVENT_TABLE() // ---------------------------------------------------------------------------- -// wxSpinCtrlButtonGeneric: spin button used by spin control +// wxSpinCtrlButton: spin button used by spin control // ---------------------------------------------------------------------------- -class wxSpinCtrlButtonGeneric : public wxSpinButton +class wxSpinCtrlButton : public wxSpinButton { public: - wxSpinCtrlButtonGeneric(wxSpinCtrlGenericBase *spin, int style) - : wxSpinButton(spin, wxID_ANY, wxDefaultPosition, - wxDefaultSize, style | wxSP_VERTICAL) + wxSpinCtrlButton(wxSpinCtrl *spin, int style) + : wxSpinButton(spin->GetParent()) { m_spin = spin; - SetRange(-SPINCTRLBUT_MAX, SPINCTRLBUT_MAX); + SetWindowStyle(style | wxSP_VERTICAL); // remove the default minsize, the spinctrl will have one instead - SetSizeHints(wxDefaultCoord, wxDefaultCoord); + SetSizeHints(wxDefaultCoord,wxDefaultCoord); } - void OnSpinButton(wxSpinEvent& event) +protected: + void OnSpinButton(wxSpinEvent& eventSpin) { - if (m_spin) - m_spin->OnSpinButton(event); - } + m_spin->SetTextValue(eventSpin.GetPosition()); - wxSpinCtrlGenericBase *m_spin; + wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, m_spin->GetId()); + event.SetEventObject(m_spin); + event.SetInt(eventSpin.GetPosition()); + + m_spin->GetEventHandler()->ProcessEvent(event); + + eventSpin.Skip(); + } private: + wxSpinCtrl *m_spin; + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(wxSpinCtrlButtonGeneric, wxSpinButton) - EVT_SPIN_UP( wxID_ANY, wxSpinCtrlButtonGeneric::OnSpinButton) - EVT_SPIN_DOWN(wxID_ANY, wxSpinCtrlButtonGeneric::OnSpinButton) +BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton) + EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton) END_EVENT_TABLE() +IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) + // ============================================================================ -// wxSpinCtrlGenericBase +// implementation // ============================================================================ // ---------------------------------------------------------------------------- -// wxSpinCtrlGenericBase creation +// wxSpinCtrl creation // ---------------------------------------------------------------------------- -void wxSpinCtrlGenericBase::Init() +void wxSpinCtrl::Init() { - m_value = 0; - m_min = 0; - m_max = 100; - m_increment = 1; - m_snap_to_ticks = false; - - m_spin_value = 0; - - m_textCtrl = NULL; - m_spinButton = NULL; + m_text = NULL; + m_btn = NULL; } -bool wxSpinCtrlGenericBase::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, const wxSize& size, - long style, - double min, double max, double initial, - double increment, - const wxString& name) +bool wxSpinCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + long style, + int min, + int max, + int initial, + const wxString& name) { - // don't use borders for this control itself, it wouldn't look good with - // the text control borders (but we might want to use style border bits to - // select the text control style) - if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, - (style & ~wxBORDER_MASK) | wxBORDER_NONE, + if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, name) ) { return false; } - m_value = initial; - m_min = min; - m_max = max; - m_increment = increment; - - m_textCtrl = new wxSpinCtrlTextGeneric(this, value, style); - m_spinButton = new wxSpinCtrlButtonGeneric(this, style); - -#if wxUSE_TOOLTIPS - m_textCtrl->SetToolTip(GetToolTipText()); - m_spinButton->SetToolTip(GetToolTipText()); -#endif // wxUSE_TOOLTIPS - - m_spin_value = m_spinButton->GetValue(); - // the string value overrides the numeric one (for backwards compatibility // reasons and also because it is simpler to satisfy the string value which // comes much sooner in the list of arguments and leave the initial // parameter unspecified) if ( !value.empty() ) { - double d; - if ( DoTextToValue(value, &d) ) - { - m_value = d; - m_textCtrl->ChangeValue(DoValueToText(m_value)); - } + long l; + if ( value.ToLong(&l) ) + initial = l; } + m_text = new wxSpinCtrlText(this, value); + m_btn = new wxSpinCtrlButton(this, style); + + m_btn->SetRange(min, max); + m_btn->SetValue(initial); SetInitialSize(size); Move(pos); + // have to disable this window to avoid interfering it with message + // processing to the text and the button... but pretend it is enabled to + // make IsEnabled() return true + wxControl::Enable(false); // don't use non virtual Disable() here! + m_isEnabled = true; + + // we don't even need to show this window itself - and not doing it avoids + // that it overwrites the text control + wxControl::Show(false); + m_isShown = true; return true; } -wxSpinCtrlGenericBase::~wxSpinCtrlGenericBase() +wxSpinCtrl::~wxSpinCtrl() { // delete the controls now, don't leave them alive even though they would // still be eventually deleted by our parent - but it will be too late, the // user code expects them to be gone now - - if (m_textCtrl) - { - // null this since MSW sends KILL_FOCUS on deletion, see ~wxSpinCtrlTextGeneric - wxDynamicCast(m_textCtrl, wxSpinCtrlTextGeneric)->m_spin = NULL; - - wxSpinCtrlTextGeneric *text = (wxSpinCtrlTextGeneric*)m_textCtrl; - m_textCtrl = NULL; - delete text; - } - - wxDELETE(m_spinButton); -} - -wxWindowList wxSpinCtrlGenericBase::GetCompositeWindowParts() const -{ - wxWindowList parts; - parts.push_back(m_textCtrl); - parts.push_back(m_spinButton); - return parts; + delete m_text; + m_text = NULL ; + delete m_btn; + m_btn = NULL ; } // ---------------------------------------------------------------------------- // geometry // ---------------------------------------------------------------------------- -wxSize wxSpinCtrlGenericBase::DoGetBestSize() const +wxSize wxSpinCtrl::DoGetBestSize() const { - return DoGetSizeFromTextSize(m_textCtrl->GetBestSize().x, -1); + wxSize sizeBtn = m_btn->GetBestSize(), + sizeText = m_text->GetBestSize(); + + return wxSize(sizeBtn.x + sizeText.x + MARGIN, sizeText.y); } -wxSize wxSpinCtrlGenericBase::DoGetSizeFromTextSize(int xlen, int ylen) const -{ - wxSize sizeBtn = m_spinButton->GetBestSize(); - wxSize totalS( m_textCtrl->GetBestSize() ); - - wxSize tsize(xlen + sizeBtn.x + MARGIN, totalS.y); -#if defined(__WXMSW__) - tsize.IncBy(4*totalS.y/10 + 4, 0); -#elif defined(__WXGTK__) - tsize.IncBy(totalS.y + 10, 0); -#endif // MSW GTK - - // Check if the user requested a non-standard height. - if ( ylen > 0 ) - tsize.IncBy(0, ylen - GetCharHeight()); - - return tsize; -} - -void wxSpinCtrlGenericBase::DoMoveWindow(int x, int y, int width, int height) +void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height) { wxControl::DoMoveWindow(x, y, width, height); // position the subcontrols inside the client area - wxSize sizeBtn = m_spinButton->GetSize(); + wxSize sizeBtn = m_btn->GetSize(); - wxCoord wText = width - sizeBtn.x - MARGIN; - m_textCtrl->SetSize(0, 0, wText, height); - m_spinButton->SetSize(0 + wText + MARGIN, 0, wxDefaultCoord, height); + wxCoord wText = width - sizeBtn.x; + m_text->SetSize(x, y, wText, height); + m_btn->SetSize(x + wText + MARGIN, y, wxDefaultCoord, height); } // ---------------------------------------------------------------------------- // operations forwarded to the subcontrols // ---------------------------------------------------------------------------- -void wxSpinCtrlGenericBase::SetFocus() +bool wxSpinCtrl::Enable(bool enable) { - if ( m_textCtrl ) - m_textCtrl->SetFocus(); -} - -#ifdef __WXMSW__ - -void wxSpinCtrlGenericBase::DoEnable(bool enable) -{ - wxSpinCtrlBase::DoEnable(enable); -} - -#endif // __WXMSW__ - -bool wxSpinCtrlGenericBase::Enable(bool enable) -{ - if ( !wxSpinCtrlBase::Enable(enable) ) + if ( !wxControl::Enable(enable) ) return false; - m_spinButton->Enable(enable); - m_textCtrl->Enable(enable); + m_btn->Enable(enable); + m_text->Enable(enable); return true; } -bool wxSpinCtrlGenericBase::Show(bool show) +bool wxSpinCtrl::Show(bool show) { if ( !wxControl::Show(show) ) return false; // under GTK Show() is called the first time before we are fully // constructed - if ( m_spinButton ) + if ( m_btn ) { - m_spinButton->Show(show); - m_textCtrl->Show(show); + m_btn->Show(show); + m_text->Show(show); } return true; } -#if wxUSE_TOOLTIPS -void wxSpinCtrlGenericBase::DoSetToolTip(wxToolTip *tip) +bool wxSpinCtrl::Reparent(wxWindow *newParent) { - // Notice that we must check for the subcontrols not being NULL (as they - // could be if we were created with the default ctor and this is called - // before Create() for some reason) and that we can't call SetToolTip(tip) - // because this would take ownership of the wxToolTip object (twice). - if ( m_textCtrl ) + if ( m_btn ) { - if ( tip ) - m_textCtrl->SetToolTip(tip->GetTip()); - else - m_textCtrl->SetToolTip(NULL); + m_btn->Reparent(newParent); + m_text->Reparent(newParent); } - if ( m_spinButton ) - { - if( tip ) - m_spinButton->SetToolTip(tip->GetTip()); - else - m_spinButton->SetToolTip(NULL); - } - - wxWindowBase::DoSetToolTip(tip); -} -#endif // wxUSE_TOOLTIPS - -bool wxSpinCtrlGenericBase::SetBackgroundColour(const wxColour& colour) -{ - // We need to provide this otherwise the entire composite window - // background and therefore the between component spaces - // will be changed. - if ( m_textCtrl ) - return m_textCtrl->SetBackgroundColour(colour); - return true; } // ---------------------------------------------------------------------------- -// Handle sub controls events +// value and range access // ---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxSpinCtrlGenericBase, wxSpinCtrlBase) - EVT_CHAR(wxSpinCtrlGenericBase::OnTextChar) - EVT_KILL_FOCUS(wxSpinCtrlGenericBase::OnTextLostFocus) -END_EVENT_TABLE() - -void wxSpinCtrlGenericBase::OnSpinButton(wxSpinEvent& event) +bool wxSpinCtrl::GetTextValue(int *val) const { - event.Skip(); - - // Sync the textctrl since the user expects that the button will modify - // what they see in the textctrl. - SyncSpinToText(SendEvent_None); - - int spin_value = event.GetPosition(); - double step = (event.GetEventType() == wxEVT_SCROLL_LINEUP) ? 1 : -1; - - // Use the spinbutton's acceleration, if any, but not if wrapping around - if (((spin_value >= 0) && (m_spin_value >= 0)) || ((spin_value <= 0) && (m_spin_value <= 0))) - step *= abs(spin_value - m_spin_value); - - double value = AdjustToFitInRange(m_value + step*m_increment); - - // Ignore the edges when it wraps since the up/down event may be opposite - // They are in GTK and Mac - if (abs(spin_value - m_spin_value) > SPINCTRLBUT_MAX) + long l; + if ( !m_text->GetValue().ToLong(&l) ) { - m_spin_value = spin_value; - return; - } - - m_spin_value = spin_value; - - // Notify about the change in wxTextCtrl too. - if ( DoSetValue(value, SendEvent_Text) ) - DoSendEvent(); -} - -void wxSpinCtrlGenericBase::OnTextLostFocus(wxFocusEvent& event) -{ - SyncSpinToText(SendEvent_Text); - DoSendEvent(); - - event.Skip(); -} - -void wxSpinCtrlGenericBase::OnTextChar(wxKeyEvent& event) -{ - if ( !HasFlag(wxSP_ARROW_KEYS) ) - { - event.Skip(); - return; - } - - double value = m_value; - switch ( event.GetKeyCode() ) - { - case WXK_UP : - value += m_increment; - break; - - case WXK_DOWN : - value -= m_increment; - break; - - case WXK_PAGEUP : - value += m_increment * 10.0; - break; - - case WXK_PAGEDOWN : - value -= m_increment * 10.0; - break; - - default: - event.Skip(); - return; - } - - value = AdjustToFitInRange(value); - - SyncSpinToText(SendEvent_None); - - // No need to send event, it was already generated by wxTextCtrl itself. - if ( DoSetValue(value, SendEvent_None) ) - DoSendEvent(); -} - -// ---------------------------------------------------------------------------- -// Textctrl functions -// ---------------------------------------------------------------------------- - -bool wxSpinCtrlGenericBase::SyncSpinToText(SendEvent sendEvent) -{ - if ( !m_textCtrl || !m_textCtrl->IsModified() ) + // not a number at all return false; - - double textValue; - if ( DoTextToValue(m_textCtrl->GetValue(), &textValue) ) - { - if (textValue > m_max) - textValue = m_max; - else if (textValue < m_min) - textValue = m_min; - } - else // text contents is not a valid number at all - { - // replace its contents with the last valid value - textValue = m_value; } - // we must always set the value here, even if it's equal to m_value, as - // otherwise we could be left with an out of range value when leaving the - // text control and the current value is already m_max for example - return DoSetValue(textValue, sendEvent); + if ( l < GetMin() || l > GetMax() ) + { + // out of range + return false; + } + + *val = l; + + return true; +} + +int wxSpinCtrl::GetValue() const +{ + return m_btn ? m_btn->GetValue() : 0; +} + +int wxSpinCtrl::GetMin() const +{ + return m_btn ? m_btn->GetMin() : 0; +} + +int wxSpinCtrl::GetMax() const +{ + return m_btn ? m_btn->GetMax() : 0; } // ---------------------------------------------------------------------------- // changing value and range // ---------------------------------------------------------------------------- -void wxSpinCtrlGenericBase::SetValue(const wxString& text) +void wxSpinCtrl::SetTextValue(int val) { - wxCHECK_RET( m_textCtrl, wxT("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetTextValue") ); - double val; - if ( DoTextToValue(text, &val) && InRange(val) ) + m_text->SetValue(wxString::Format(_T("%d"), val)); + + // select all text + m_text->SetSelection(0, -1); + + // and give focus to the control! + // m_text->SetFocus(); Why???? TODO. + +#ifdef __WXCOCOA__ + /* It's sort of a hack to do this from here but the idea is that if the + user has clicked on us, which is the main reason this method is called, + then focus probably ought to go to the text control since clicking on + a text control usually gives it focus. + + However, if the focus is already on us (i.e. the user has turned on + the ability to tab to controls) then we don't want to drop focus. + So we only set focus if we would steal it away from a different + control, not if we would steal it away from ourself. + */ + wxWindow *currentFocusedWindow = wxWindow::FindFocus(); + if(currentFocusedWindow != this && currentFocusedWindow != m_text) + m_text->SetFocus(); +#endif +} + +void wxSpinCtrl::SetValue(int val) +{ + wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetValue") ); + + SetTextValue(val); + + m_btn->SetValue(val); +} + +void wxSpinCtrl::SetValue(const wxString& text) +{ + wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetValue") ); + + long val; + if ( text.ToLong(&val) && ((val > INT_MIN) && (val < INT_MAX)) ) { - DoSetValue(val, SendEvent_None); + SetValue((int)val); } else // not a number at all or out of range { - m_textCtrl->ChangeValue(text); - m_textCtrl->SelectAll(); + m_text->SetValue(text); + m_text->SetSelection(0, -1); } } -bool wxSpinCtrlGenericBase::DoSetValue(double val, SendEvent sendEvent) +void wxSpinCtrl::SetRange(int min, int max) { - wxCHECK_MSG( m_textCtrl, false, wxT("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetRange") ); - if ( val < m_min ) - val = m_min; - if ( val > m_max ) - val = m_max; - - if ( m_snap_to_ticks && (m_increment != 0) ) - { - double snap_value = val / m_increment; - - if (wxFinite(snap_value)) // FIXME what to do about a failure? - { - if ((snap_value - floor(snap_value)) < (ceil(snap_value) - snap_value)) - val = floor(snap_value) * m_increment; - else - val = ceil(snap_value) * m_increment; - } - } - - wxString str(DoValueToText(val)); - - if ((val != m_value) || (str != m_textCtrl->GetValue())) - { - if ( !DoTextToValue(str, &m_value ) ) // wysiwyg for textctrl - m_value = val; - - switch ( sendEvent ) - { - case SendEvent_None: - m_textCtrl->ChangeValue(str); - break; - - case SendEvent_Text: - m_textCtrl->SetValue(str); - break; - } - - m_textCtrl->SelectAll(); - m_textCtrl->DiscardEdits(); - return true; - } - - return false; + m_btn->SetRange(min, max); } -double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const +void wxSpinCtrl::SetSelection(long from, long to) { - if (value < m_min) - value = HasFlag(wxSP_WRAP) ? m_max : m_min; - if (value > m_max) - value = HasFlag(wxSP_WRAP) ? m_min : m_max; + wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetSelection") ); - return value; + m_text->SetSelection(from, to); } -void wxSpinCtrlGenericBase::DoSetRange(double min, double max) -{ - m_min = min; - if ( m_value < m_min ) - DoSetValue(m_min, SendEvent_None); - m_max = max; - if ( m_value > m_max ) - DoSetValue(m_max, SendEvent_None); -} - -void wxSpinCtrlGenericBase::DoSetIncrement(double inc) -{ - m_increment = inc; -} - -void wxSpinCtrlGenericBase::SetSnapToTicks(bool snap_to_ticks) -{ - m_snap_to_ticks = snap_to_ticks; - DoSetValue(m_value, SendEvent_None); -} - -void wxSpinCtrlGenericBase::SetSelection(long from, long to) -{ - wxCHECK_RET( m_textCtrl, wxT("invalid call to wxSpinCtrl::SetSelection") ); - - m_textCtrl->SetSelection(from, to); -} - -#ifndef wxHAS_NATIVE_SPINCTRL - -//----------------------------------------------------------------------------- -// wxSpinCtrl -//----------------------------------------------------------------------------- - -bool wxSpinCtrl::SetBase(int base) -{ - // Currently we only support base 10 and 16. We could add support for base - // 8 quite easily but wxMSW doesn't support it natively so don't bother. - if ( base != 10 && base != 16 ) - return false; - - if ( base == m_base ) - return true; - - // Update the current control contents to show in the new base: be careful - // to call DoTextToValue() before changing the base... - double val; - const bool hasValidVal = DoTextToValue(m_textCtrl->GetValue(), &val); - - m_base = base; - - // ... but DoValueToText() after doing it. - if ( hasValidVal ) - m_textCtrl->ChangeValue(DoValueToText(val)); - - return true; -} - -void wxSpinCtrl::DoSendEvent() -{ - wxSpinEvent event( wxEVT_SPINCTRL, GetId()); - event.SetEventObject( this ); - event.SetPosition((int)(m_value + 0.5)); // FIXME should be SetValue - event.SetString(m_textCtrl->GetValue()); - GetEventHandler()->ProcessEvent( event ); -} - -bool wxSpinCtrl::DoTextToValue(const wxString& text, double *val) -{ - long lval; - if ( !text.ToLong(&lval, GetBase()) ) - return false; - - *val = static_cast(lval); - - return true; -} - -wxString wxSpinCtrl::DoValueToText(double val) -{ - switch ( GetBase() ) - { - case 16: - return wxPrivate::wxSpinCtrlFormatAsHex(static_cast(val), - GetMax()); - - default: - wxFAIL_MSG( wxS("Unsupported spin control base") ); - // Fall through - - case 10: - return wxString::Format("%ld", static_cast(val)); - } -} - -#endif // !wxHAS_NATIVE_SPINCTRL - -//----------------------------------------------------------------------------- -// wxSpinCtrlDouble -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlDouble, wxSpinCtrlGenericBase) - -void wxSpinCtrlDouble::DoSendEvent() -{ - wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, GetId()); - event.SetEventObject( this ); - event.SetValue(m_value); - event.SetString(m_textCtrl->GetValue()); - GetEventHandler()->ProcessEvent( event ); -} - -bool wxSpinCtrlDouble::DoTextToValue(const wxString& text, double *val) -{ - return text.ToDouble(val); -} - -wxString wxSpinCtrlDouble::DoValueToText(double val) -{ - return wxString::Format(m_format, val); -} - -void wxSpinCtrlDouble::SetDigits(unsigned digits) -{ - wxCHECK_RET( digits <= 20, "too many digits for wxSpinCtrlDouble" ); - - if ( digits == m_digits ) - return; - - m_digits = digits; - - m_format.Printf(wxT("%%0.%ulf"), digits); - - DoSetValue(m_value, SendEvent_None); -} - -#endif // wxUSE_SPINBTN - -#endif // !wxPort-with-native-spinctrl - #endif // wxUSE_SPINCTRL +#endif // !wxPort-with-native-spinctrl diff --git a/Source/3rd Party/wx/src/generic/splash.cpp b/Source/3rd Party/wx/src/generic/splash.cpp deleted file mode 100644 index 10f8b1044..000000000 --- a/Source/3rd Party/wx/src/generic/splash.cpp +++ /dev/null @@ -1,212 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/splash.cpp -// Purpose: wxSplashScreen class -// Author: Julian Smart -// Modified by: -// Created: 28/6/2000 -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SPLASH - -#ifdef __WXGTK20__ - #include -#endif - -#include "wx/splash.h" - -#ifndef WX_PRECOMP - #include "wx/dcmemory.h" - #include "wx/dcclient.h" -#endif - - -// ---------------------------------------------------------------------------- -// wxSplashScreen -// ---------------------------------------------------------------------------- - -#define wxSPLASH_TIMER_ID 9999 - -IMPLEMENT_DYNAMIC_CLASS(wxSplashScreen, wxFrame) -BEGIN_EVENT_TABLE(wxSplashScreen, wxFrame) - EVT_TIMER(wxSPLASH_TIMER_ID, wxSplashScreen::OnNotify) - EVT_CLOSE(wxSplashScreen::OnCloseWindow) -END_EVENT_TABLE() - -void wxSplashScreen::Init() -{ - m_window = NULL; - - wxEvtHandler::AddFilter(this); -} - -/* Note that unless we pass a non-default size to the frame, SetClientSize - * won't work properly under Windows, and the splash screen frame is sized - * slightly too small. - */ - -wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, - wxWindow* parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style) - : wxFrame(parent, id, wxEmptyString, wxPoint(0,0), wxSize(100, 100), - style | wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR) -{ - Init(); - - // splash screen must not be used as parent by the other windows because it - // is going to disappear soon, indicate it by giving it this special style - SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); - -#if defined(__WXGTK20__) - gtk_window_set_type_hint(GTK_WINDOW(m_widget), - GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); -#endif - - m_splashStyle = splashStyle; - m_milliseconds = milliseconds; - - m_window = new wxSplashScreenWindow(bitmap, this, wxID_ANY, pos, size, wxNO_BORDER); - - SetClientSize(bitmap.GetWidth(), bitmap.GetHeight()); - - if (m_splashStyle & wxSPLASH_CENTRE_ON_PARENT) - CentreOnParent(); - else if (m_splashStyle & wxSPLASH_CENTRE_ON_SCREEN) - CentreOnScreen(); - - if (m_splashStyle & wxSPLASH_TIMEOUT) - { - m_timer.SetOwner(this, wxSPLASH_TIMER_ID); - m_timer.Start(milliseconds, true); - } - - Show(true); - m_window->SetFocus(); -#if defined( __WXMSW__ ) || defined(__WXMAC__) - Update(); // Without this, you see a blank screen for an instant -#elif defined(__WXGTK20__) - // we don't need to do anything at least on wxGTK with GTK+ 2.12.9 -#else - wxYieldIfNeeded(); // Should eliminate this -#endif -} - -wxSplashScreen::~wxSplashScreen() -{ - m_timer.Stop(); - - wxEvtHandler::RemoveFilter(this); -} - -int wxSplashScreen::FilterEvent(wxEvent& event) -{ - const wxEventType t = event.GetEventType(); - if ( t == wxEVT_KEY_DOWN || - t == wxEVT_LEFT_DOWN || - t == wxEVT_RIGHT_DOWN || - t == wxEVT_MIDDLE_DOWN ) - Close(true); - - return -1; -} - -void wxSplashScreen::OnNotify(wxTimerEvent& WXUNUSED(event)) -{ - Close(true); -} - -void wxSplashScreen::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - m_timer.Stop(); - this->Destroy(); -} - -// ---------------------------------------------------------------------------- -// wxSplashScreenWindow -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxSplashScreenWindow, wxWindow) -#ifdef __WXGTK__ - EVT_PAINT(wxSplashScreenWindow::OnPaint) -#endif - EVT_ERASE_BACKGROUND(wxSplashScreenWindow::OnEraseBackground) -END_EVENT_TABLE() - -wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, - wxWindowID id, const wxPoint& pos, - const wxSize& size, long style) - : wxWindow(parent, id, pos, size, style) -{ - m_bitmap = bitmap; - -#if !defined(__WXGTK__) && wxUSE_PALETTE - bool hiColour = (wxDisplayDepth() >= 16) ; - - if (bitmap.GetPalette() && !hiColour) - { - SetPalette(* bitmap.GetPalette()); - } -#endif -} - -// VZ: why don't we do it under wxGTK? -#if !defined(__WXGTK__) && wxUSE_PALETTE - #define USE_PALETTE_IN_SPLASH -#endif - -static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y)) -{ - wxMemoryDC dcMem; - -#ifdef USE_PALETTE_IN_SPLASH - bool hiColour = (wxDisplayDepth() >= 16) ; - - if (bitmap.GetPalette() && !hiColour) - { - dcMem.SetPalette(* bitmap.GetPalette()); - } -#endif // USE_PALETTE_IN_SPLASH - - dcMem.SelectObjectAsSource(bitmap); - dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), &dcMem, 0, 0, wxCOPY, - true /* use mask */); - dcMem.SelectObject(wxNullBitmap); - -#ifdef USE_PALETTE_IN_SPLASH - if (bitmap.GetPalette() && !hiColour) - { - dcMem.SetPalette(wxNullPalette); - } -#endif // USE_PALETTE_IN_SPLASH -} - -void wxSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - if (m_bitmap.IsOk()) - wxDrawSplashBitmap(dc, m_bitmap, 0, 0); -} - -void wxSplashScreenWindow::OnEraseBackground(wxEraseEvent& event) -{ - if (event.GetDC() && m_bitmap.IsOk()) - { - wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0); - } - else - { - wxClientDC dc(this); - if (m_bitmap.IsOk()) - wxDrawSplashBitmap(dc, m_bitmap, 0, 0); - } -} - -#endif // wxUSE_SPLASH diff --git a/Source/3rd Party/wx/src/generic/splitter.cpp b/Source/3rd Party/wx/src/generic/splitter.cpp index 86002019c..ccad80b62 100644 --- a/Source/3rd Party/wx/src/generic/splitter.cpp +++ b/Source/3rd Party/wx/src/generic/splitter.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 +// RCS-ID: $Id: splitter.cpp 60837 2009-05-31 13:13:07Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -38,10 +39,10 @@ #include -wxDEFINE_EVENT( wxEVT_SPLITTER_SASH_POS_CHANGED, wxSplitterEvent ); -wxDEFINE_EVENT( wxEVT_SPLITTER_SASH_POS_CHANGING, wxSplitterEvent ); -wxDEFINE_EVENT( wxEVT_SPLITTER_DOUBLECLICKED, wxSplitterEvent ); -wxDEFINE_EVENT( wxEVT_SPLITTER_UNSPLIT, wxSplitterEvent ); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPLITTER_UNSPLIT) IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow, wxWindow) @@ -60,25 +61,15 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow) EVT_PAINT(wxSplitterWindow::OnPaint) EVT_SIZE(wxSplitterWindow::OnSize) EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent) - EVT_MOUSE_CAPTURE_LOST(wxSplitterWindow::OnMouseCaptureLost) #if defined( __WXMSW__ ) || defined( __WXMAC__) EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor) #endif // wxMSW + + WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow) END_EVENT_TABLE() -static bool IsLive(wxSplitterWindow* wnd) -{ - // with wxSP_LIVE_UPDATE style the splitter windows are always resized - // following the mouse movement while it drags the sash, without it we only - // draw the sash at the new position but only resize the windows when the - // dragging is finished -#if defined( __WXMAC__ ) && defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX == 1 - return true; // Mac can't paint outside paint event - always need live mode -#else - return wnd->HasFlag(wxSP_LIVE_UPDATE); -#endif -} +WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow, wxWindow) bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -89,10 +80,22 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, // allow TABbing from one window to the other style |= wxTAB_TRAVERSAL; + // we draw our border ourselves to blend the sash with it + style &= ~wxBORDER_MASK; + style |= wxBORDER_NONE; + +#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS + // CoreGraphics can't paint sash feedback + style |= wxSP_LIVE_UPDATE; +#endif + if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; - m_lastSize = GetClientSize(); + if (size.x >= 0) + m_lastSize.x = size.x; + if (size.y >= 0) + m_lastSize.y = size.y; m_permitUnsplitAlways = (style & wxSP_PERMIT_UNSPLIT) != 0; @@ -109,22 +112,26 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, void wxSplitterWindow::Init() { + m_container.SetContainerWindow(this); + m_splitMode = wxSPLIT_VERTICAL; m_permitUnsplitAlways = true; - m_windowOne = NULL; - m_windowTwo = NULL; + m_windowOne = (wxWindow *) NULL; + m_windowTwo = (wxWindow *) NULL; m_dragMode = wxSPLIT_DRAG_NONE; m_oldX = 0; m_oldY = 0; - m_sashStart = 0; - m_sashPosition = 0; - m_requestedSashPosition = INT_MAX; + m_firstX = 0; + m_firstY = 0; + m_sashPosition = m_requestedSashPosition = 0; m_sashGravity = 0.0; + m_sashSize = -1; // -1 means use the native sash size m_lastSize = wxSize(0,0); + m_checkRequestedSashPosition = false; m_minimumPaneSize = 0; m_sashCursorWE = wxCursor(wxCURSOR_SIZEWE); m_sashCursorNS = wxCursor(wxCURSOR_SIZENS); - m_sashTrackerPen = new wxPen(*wxBLACK, 2, wxPENSTYLE_SOLID); + m_sashTrackerPen = new wxPen(*wxBLACK, 2, wxSOLID); m_needUpdating = false; m_isHot = false; @@ -178,12 +185,6 @@ void wxSplitterWindow::SetResizeCursor() void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __WXOSX__ - // as subpanels might have a transparent background we must erase the background - // at least on OSX, otherwise traces of the sash will remain - // test with: splitter sample->replace right window - dc.Clear(); -#endif DrawSash(dc); } @@ -192,21 +193,17 @@ void wxSplitterWindow::OnInternalIdle() { wxWindow::OnInternalIdle(); - // We may need to update the children sizes in two cases: either because - // we're in the middle of a live update as indicated by m_needUpdating or - // because we have a requested but not yet set sash position as indicated - // by m_requestedSashPosition having a valid value. - if ( m_needUpdating ) + // if this is the first idle time after a sash position has potentially + // been set, allow SizeWindows to check for a requested size. + if (!m_checkRequestedSashPosition) { - m_needUpdating = false; - } - else if ( m_requestedSashPosition == INT_MAX ) - { - // We don't need to resize the children. - return; + m_checkRequestedSashPosition = true; + SizeWindows(); + return; // it won't needUpdating in this case } - SizeWindows(); + if (m_needUpdating) + SizeWindows(); } void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) @@ -220,8 +217,15 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) return; } - bool isLive = IsLive(this); - + // with wxSP_LIVE_UPDATE style the splitter windows are always resized + // following the mouse movement while it drags the sash, without it we only + // draw the sash at the new position but only resize the windows when the + // dragging is finished +#if defined( __WXMAC__ ) && defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX == 1 + bool isLive = true ; // FIXME: why? +#else + bool isLive = HasFlag(wxSP_LIVE_UPDATE); +#endif if (event.LeftDown()) { if ( SashHitTest(x, y) ) @@ -239,13 +243,13 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) // shadow sash m_sashPositionCurrent = m_sashPosition; - m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x); - m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y); - DrawSashTracker(m_oldX, m_oldY); + DrawSashTracker(x, y); } - m_ptStart = wxPoint(x,y); - m_sashStart = m_sashPosition; + m_oldX = x; + m_oldY = y; + + SetResizeCursor(); return; } } @@ -273,9 +277,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) // the position of the click doesn't exactly correspond to // m_sashPosition, rather it changes it by the distance by which the // mouse has moved - int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y; + int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; - int posSashNew = OnSashPositionChanging(m_sashStart + diff); + int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent; + int posSashNew = OnSashPositionChanging(posSashOld + diff); if ( posSashNew == -1 ) { // change not allowed @@ -290,9 +295,9 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) // We remove the first window from the view wxWindow *removedWindow = m_windowOne; m_windowOne = m_windowTwo; - m_windowTwo = NULL; + m_windowTwo = (wxWindow *) NULL; OnUnsplit(removedWindow); - wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this); + wxSplitterEvent eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT, this); eventUnsplit.m_data.win = removedWindow; (void)DoSendEvent(eventUnsplit); SetSashPositionAndNotify(0); @@ -301,9 +306,9 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) { // We remove the second window from the view wxWindow *removedWindow = m_windowTwo; - m_windowTwo = NULL; + m_windowTwo = (wxWindow *) NULL; OnUnsplit(removedWindow); - wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this); + wxSplitterEvent eventUnsplit(wxEVT_COMMAND_SPLITTER_UNSPLIT, this); eventUnsplit.m_data.win = removedWindow; (void)DoSendEvent(eventUnsplit); SetSashPositionAndNotify(0); @@ -329,53 +334,62 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) } else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING)) { - int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y; + int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; + if ( !diff ) + { + // nothing to do, mouse didn't really move far enough + return; + } - int posSashNew = OnSashPositionChanging(m_sashStart + diff); + int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent; + int posSashNew = OnSashPositionChanging(posSashOld + diff); if ( posSashNew == -1 ) { // change not allowed return; } + if ( posSashNew == m_sashPosition ) + return; + + // Erase old tracker if ( !isLive ) { - if ( posSashNew == m_sashPositionCurrent ) - return; - - m_sashPositionCurrent = posSashNew; - - // Erase old tracker DrawSashTracker(m_oldX, m_oldY); + } - m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x); - m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y); + if (m_splitMode == wxSPLIT_VERTICAL) + x = posSashNew; + else + y = posSashNew; + + // Remember old positions + m_oldX = x; + m_oldY = y; #ifdef __WXMSW__ - // As we captured the mouse, we may get the mouse events from outside - // our window - for example, negative values in x, y. This has a weird - // consequence under MSW where we use unsigned values sometimes and - // signed ones other times: the coordinates turn as big positive - // numbers and so the sash is drawn on the *right* side of the window - // instead of the left (or bottom instead of top). Correct this. - if ( (short)m_oldX < 0 ) - m_oldX = 0; - if ( (short)m_oldY < 0 ) - m_oldY = 0; + // As we captured the mouse, we may get the mouse events from outside + // our window - for example, negative values in x, y. This has a weird + // consequence under MSW where we use unsigned values sometimes and + // signed ones other times: the coordinates turn as big positive + // numbers and so the sash is drawn on the *right* side of the window + // instead of the left (or bottom instead of top). Correct this. + if ( (short)m_oldX < 0 ) + m_oldX = 0; + if ( (short)m_oldY < 0 ) + m_oldY = 0; #endif // __WXMSW__ - // Draw new one + // Draw new one + if ( !isLive ) + { + m_sashPositionCurrent = posSashNew; + DrawSashTracker(m_oldX, m_oldY); } else { - if ( posSashNew == m_sashPosition ) - return; - DoSetSashPosition(posSashNew); - - // in live mode, the new position is the actual sash position, clear requested position! - m_requestedSashPosition = INT_MAX; m_needUpdating = true; } } @@ -389,22 +403,6 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) } } -void wxSplitterWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) -{ - if (m_dragMode != wxSPLIT_DRAG_DRAGGING) - return; - - m_dragMode = wxSPLIT_DRAG_NONE; - - SetCursor(* wxSTANDARD_CURSOR); - - // Erase old tracker - if ( !IsLive(this) ) - { - DrawSashTracker(m_oldX, m_oldY); - } -} - void wxSplitterWindow::OnSize(wxSizeEvent& event) { // only process this message if we're not iconized - otherwise iconizing @@ -434,43 +432,30 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) return; } - const wxSize curSize = event.GetSize(); - - // Update the sash position if needed. - // - // Notice that we shouldn't do this if the sash position requested by user - // couldn't be set yet as it would never be taken into account at all if we - // modified it before this happens. - if ( m_windowTwo && m_requestedSashPosition == INT_MAX ) + if ( m_windowTwo ) { - int size = m_splitMode == wxSPLIT_VERTICAL ? curSize.x : curSize.y; + int w, h; + GetClientSize(&w, &h); + + int size = m_splitMode == wxSPLIT_VERTICAL ? w : h; int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y; - - // Don't do anything if the size didn't really change. - if ( size != old_size ) + if ( old_size != 0 ) { - int newPosition = -1; - - // Apply gravity if we use it. int delta = (int) ( (size - old_size)*m_sashGravity ); if ( delta != 0 ) { - newPosition = m_sashPosition + delta; + int newPosition = m_sashPosition + delta; if( newPosition < m_minimumPaneSize ) newPosition = m_minimumPaneSize; - } - - // Also check if the second window became too small. - newPosition = AdjustSashPosition(newPosition == -1 - ? m_sashPosition - : newPosition); - if ( newPosition != m_sashPosition ) SetSashPositionAndNotify(newPosition); + } } - } - m_lastSize = curSize; + if ( m_sashPosition >= size - 5 ) + SetSashPositionAndNotify(wxMax(10, size - 40)); + m_lastSize = wxSize(w,h); + } SizeWindows(); } @@ -478,36 +463,26 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) void wxSplitterWindow::SetSashGravity(double gravity) { wxCHECK_RET( gravity >= 0. && gravity <= 1., - wxT("invalid gravity value") ); + _T("invalid gravity value") ); m_sashGravity = gravity; } -bool wxSplitterWindow::SashHitTest(int x, int y) +bool wxSplitterWindow::SashHitTest(int x, int y, int tolerance) { if ( m_windowTwo == NULL || m_sashPosition == 0) return false; // No sash int z = m_splitMode == wxSPLIT_VERTICAL ? x : y; - int hitMax = m_sashPosition + GetSashSize() - 1; + int hitMin = m_sashPosition - tolerance; + int hitMax = m_sashPosition + GetSashSize() + tolerance; - return z >= m_sashPosition && z <= hitMax; -} - -void wxSplitterWindow::SetSashInvisible(bool invisible) -{ - if ( IsSashInvisible() != invisible ) - ToggleWindowStyle(wxSP_NOSASH); + return z >= hitMin && z <= hitMax; } int wxSplitterWindow::GetSashSize() const { - return IsSashInvisible() ? 0 : GetDefaultSashSize(); -} - -int wxSplitterWindow::GetDefaultSashSize() const -{ - return wxRendererNative::Get().GetSplitterParams(this).widthSash; + return m_sashSize > -1 ? m_sashSize : wxRendererNative::Get().GetSplitterParams(this).widthSash; } int wxSplitterWindow::GetBorderSize() const @@ -531,7 +506,7 @@ void wxSplitterWindow::DrawSash(wxDC& dc) return; // nor if we're configured to not show it - if ( IsSashInvisible() ) + if ( HasFlag(wxSP_NOSASH) ) return; wxRendererNative::Get().DrawSplitterSash @@ -558,15 +533,33 @@ void wxSplitterWindow::DrawSashTracker(int x, int y) if ( m_splitMode == wxSPLIT_VERTICAL ) { - x1 = x2 = wxClip(x, 0, w) + m_sashTrackerPen->GetWidth()/2; - y1 = 2; - y2 = h-2; + x1 = x; y1 = 2; + x2 = x; y2 = h-2; + + if ( x1 > w ) + { + x1 = w; x2 = w; + } + else if ( x1 < 0 ) + { + x1 = 0; x2 = 0; + } } else { - y1 = y2 = wxClip(y, 0, h) + m_sashTrackerPen->GetWidth()/2; - x1 = 2; - x2 = w-2; + x1 = 2; y1 = y; + x2 = w-2; y2 = y; + + if ( y1 > h ) + { + y1 = h; + y2 = h; + } + else if ( y1 < 0 ) + { + y1 = 0; + y2 = 0; + } } ClientToScreen(&x1, &y1); @@ -651,7 +644,7 @@ void wxSplitterWindow::SetSashPositionAndNotify(int sashPos) // must generate a CHANGED event at the end of resizing DoSetSashPosition(sashPos); - wxSplitterEvent event(wxEVT_SPLITTER_SASH_POS_CHANGED, this); + wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, this); event.m_data.pos = m_sashPosition; (void)DoSendEvent(event); @@ -663,7 +656,7 @@ void wxSplitterWindow::SetSashPositionAndNotify(int sashPos) void wxSplitterWindow::SizeWindows() { // check if we have delayed setting the real sash position - if ( m_requestedSashPosition != INT_MAX ) + if ( m_checkRequestedSashPosition && m_requestedSashPosition != INT_MAX ) { int newSashPosition = ConvertSashPosition(m_requestedSashPosition); if ( newSashPosition != m_sashPosition ) @@ -729,19 +722,21 @@ void wxSplitterWindow::SizeWindows() wxClientDC dc(this); DrawSash(dc); + + SetNeedUpdating(false); } // Set pane for unsplit window void wxSplitterWindow::Initialize(wxWindow *window) { - wxASSERT_MSG( (!window || window->GetParent() == this), - wxT("windows in the splitter should have it as parent!") ); + wxASSERT_MSG( (!window || (window && window->GetParent() == this)), + _T("windows in the splitter should have it as parent!") ); if (window && !window->IsShown()) window->Show(); m_windowOne = window; - m_windowTwo = NULL; + m_windowTwo = (wxWindow *) NULL; DoSetSashPosition(0); } @@ -756,10 +751,10 @@ bool wxSplitterWindow::DoSplit(wxSplitMode mode, return false; wxCHECK_MSG( window1 && window2, false, - wxT("cannot split with NULL window(s)") ); + _T("can not split with NULL window(s)") ); wxCHECK_MSG( window1->GetParent() == this && window2->GetParent() == this, false, - wxT("windows in the splitter should have it as parent!") ); + _T("windows in the splitter should have it as parent!") ); if (! window1->IsShown()) window1->Show(); @@ -770,8 +765,15 @@ bool wxSplitterWindow::DoSplit(wxSplitMode mode, m_windowOne = window1; m_windowTwo = window2; + // remember the sash position we want to set for later if we can't set it + // right now (e.g. because the window is too small) + m_requestedSashPosition = sashPosition; + m_checkRequestedSashPosition = false; + + DoSetSashPosition(ConvertSashPosition(sashPosition)); + + SizeWindows(); - SetSashPosition(sashPosition, true); return true; } @@ -804,13 +806,13 @@ bool wxSplitterWindow::Unsplit(wxWindow *toRemove) if ( toRemove == NULL || toRemove == m_windowTwo) { win = m_windowTwo ; - m_windowTwo = NULL; + m_windowTwo = (wxWindow *) NULL; } else if ( toRemove == m_windowOne ) { win = m_windowOne ; m_windowOne = m_windowTwo; - m_windowTwo = NULL; + m_windowTwo = (wxWindow *) NULL; } else { @@ -864,6 +866,7 @@ void wxSplitterWindow::SetSashPosition(int position, bool redraw) // remember the sash position we want to set for later if we can't set it // right now (e.g. because the window is too small) m_requestedSashPosition = position; + m_checkRequestedSashPosition = false; DoSetSashPosition(ConvertSashPosition(position)); @@ -878,7 +881,9 @@ void wxSplitterWindow::SetSashPosition(int position, bool redraw) // window is shown, if you know the overall size is correct. void wxSplitterWindow::UpdateSize() { + m_checkRequestedSashPosition = true; SizeWindows(); + m_checkRequestedSashPosition = false; } bool wxSplitterWindow::DoSendEvent(wxSplitterEvent& event) @@ -976,18 +981,18 @@ int wxSplitterWindow::OnSashPositionChanging(int newSashPosition) { // If resultant pane would be too small, enlarge it newSashPosition = AdjustSashPosition(newSashPosition); - - // If the result is out of bounds it means minimum size is too big, - // so split window in half as best compromise. - if ( newSashPosition < 0 || newSashPosition > window_size ) - newSashPosition = window_size / 2; } + // If the result is out of bounds it means minimum size is too big, + // so split window in half as best compromise. + if ( newSashPosition < 0 || newSashPosition > window_size ) + newSashPosition = window_size / 2; + // now let the event handler have it // // FIXME: shouldn't we do it before the adjustments above so as to ensure // that the sash position is always reasonable? - wxSplitterEvent event(wxEVT_SPLITTER_SASH_POS_CHANGING, this); + wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, this); event.m_data.pos = newSashPosition; if ( !DoSendEvent(event) ) @@ -1011,7 +1016,7 @@ void wxSplitterWindow::OnDoubleClickSash(int x, int y) wxCHECK_RET(m_windowTwo, wxT("splitter: no window to remove")); // new code should handle events instead of using the virtual functions - wxSplitterEvent event(wxEVT_SPLITTER_DOUBLECLICKED, this); + wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, this); event.m_data.pt.x = x; event.m_data.pt.y = y; if ( DoSendEvent(event) ) @@ -1021,7 +1026,7 @@ void wxSplitterWindow::OnDoubleClickSash(int x, int y) wxWindow* win = m_windowTwo; if ( Unsplit(win) ) { - wxSplitterEvent unsplitEvent(wxEVT_SPLITTER_UNSPLIT, this); + wxSplitterEvent unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT, this); unsplitEvent.m_data.win = win; (void)DoSendEvent(unsplitEvent); } @@ -1045,7 +1050,7 @@ void wxSplitterWindow::OnSetCursor(wxSetCursorEvent& event) // and like this we explicitly say that our cursor should not be used for // children windows which overlap us - if ( SashHitTest(event.GetX(), event.GetY()) ) + if ( SashHitTest(event.GetX(), event.GetY(), 0) ) { // default processing is ok event.Skip(); diff --git a/Source/3rd Party/wx/src/generic/srchctlg.cpp b/Source/3rd Party/wx/src/generic/srchctlg.cpp index 8241529d6..8b7edad0d 100644 --- a/Source/3rd Party/wx/src/generic/srchctlg.cpp +++ b/Source/3rd Party/wx/src/generic/srchctlg.cpp @@ -3,8 +3,9 @@ // Purpose: implements wxSearchCtrl as a composite control // Author: Vince Harron // Created: 2006-02-19 +// RCS-ID: $Id: srchctlg.cpp 47962 2007-08-08 12:38:13Z JS $ // Copyright: Vince Harron -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". @@ -38,6 +39,66 @@ // the margin between the text control and the search/cancel buttons static const wxCoord MARGIN = 2; +// border around all controls to compensate for wxSIMPLE_BORDER +#if defined(__WXMSW__) +static const wxCoord BORDER = 0; +static const wxCoord ICON_MARGIN = 2; +static const wxCoord ICON_OFFSET = 2; +#else +static const wxCoord BORDER = 2; +static const wxCoord ICON_MARGIN = 0; +static const wxCoord ICON_OFFSET = 0; +#endif + +// ---------------------------------------------------------------------------- +// TODO: These functions or something like them should probably be made +// public. There are similar functions in src/aui/dockart.cpp... + +static double wxBlendColour(double fg, double bg, double alpha) +{ + double result = bg + (alpha * (fg - bg)); + if (result < 0.0) + result = 0.0; + if (result > 255) + result = 255; + return result; +} + +static wxColor wxStepColour(const wxColor& c, int ialpha) +{ + if (ialpha == 100) + return c; + + double r = c.Red(), g = c.Green(), b = c.Blue(); + double bg; + + // ialpha is 0..200 where 0 is completely black + // and 200 is completely white and 100 is the same + // convert that to normal alpha 0.0 - 1.0 + ialpha = wxMin(ialpha, 200); + ialpha = wxMax(ialpha, 0); + double alpha = ((double)(ialpha - 100.0))/100.0; + + if (ialpha > 100) + { + // blend with white + bg = 255.0; + alpha = 1.0 - alpha; // 0 = transparent fg; 1 = opaque fg + } + else + { + // blend with black + bg = 0.0; + alpha = 1.0 + alpha; // 0 = transparent fg; 1 = opaque fg + } + + r = wxBlendColour(r, bg, alpha); + g = wxBlendColour(g, bg, alpha); + b = wxBlendColour(b, bg, alpha); + + return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b); +} + #define LIGHT_STEP 160 // ---------------------------------------------------------------------------- @@ -49,37 +110,28 @@ class wxSearchTextCtrl : public wxTextCtrl public: wxSearchTextCtrl(wxSearchCtrl *search, const wxString& value, int style) : wxTextCtrl(search, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, - (style & ~wxBORDER_MASK) | wxNO_BORDER) + style | wxNO_BORDER) { m_search = search; + m_defaultFG = GetForegroundColour(); - SetHint(_("Search")); - - // Ensure that our best size is recomputed using our overridden - // DoGetBestSize(). - InvalidateBestSize(); + // remove the default minsize, the searchctrl will have one instead + SetSizeHints(wxDefaultCoord,wxDefaultCoord); } - virtual wxWindow* GetMainWindowOfCompositeControl() + void SetDescriptiveText(const wxString& text) { - return m_search; + if ( GetValue() == m_descriptiveText ) + { + ChangeValue(wxEmptyString); + } + + m_descriptiveText = text; } - // provide access to the base class protected methods to wxSearchCtrl which - // needs to forward to them - void DoSetValue(const wxString& value, int flags) + wxString GetDescriptiveText() const { - wxTextCtrl::DoSetValue(value, flags); - } - - bool DoLoadFile(const wxString& file, int fileType) - { - return wxTextCtrl::DoLoadFile(file, fileType); - } - - bool DoSaveFile(const wxString& file, int fileType) - { - return wxTextCtrl::DoSaveFile(file, fileType); + return m_descriptiveText; } protected: @@ -107,34 +159,30 @@ protected: m_search->GetEventHandler()->ProcessEvent(event); } -#ifdef __WXMSW__ - // We increase the text control height to be the same as for the controls - // with border as this is what we actually need here because even though - // this control itself is borderless, it's inside wxSearchCtrl which does - // have the border and so should have the same height as the normal text - // entries with border. - // - // This is a bit ugly and it would arguably be better to use whatever size - // the base class version returns and just centre the text vertically in - // the search control but I failed to modify the code in DoLayoutControls() - // to do this easily and as there is much in that code I don't understand - // (notably what is the logic for buttons sizing?) I prefer to not touch it - // at all. - virtual wxSize DoGetBestSize() const + void OnIdle(wxIdleEvent& WXUNUSED(event)) { - const long flags = GetWindowStyleFlag(); - wxSearchTextCtrl* const self = const_cast(this); - - self->SetWindowStyleFlag((flags & ~wxBORDER_MASK) | wxBORDER_DEFAULT); - const wxSize size = wxTextCtrl::DoGetBestSize(); - self->SetWindowStyleFlag(flags); - - return size; + if ( IsEmpty() && !(wxWindow::FindFocus() == this) ) + { + ChangeValue(m_descriptiveText); + SetInsertionPoint(0); + SetForegroundColour(wxStepColour(m_defaultFG, LIGHT_STEP)); + } + } + + void OnFocus(wxFocusEvent& event) + { + event.Skip(); + if ( GetValue() == m_descriptiveText ) + { + ChangeValue(wxEmptyString); + SetForegroundColour(m_defaultFG); + } } -#endif // __WXMSW__ private: wxSearchCtrl* m_search; + wxString m_descriptiveText; + wxColour m_defaultFG; DECLARE_EVENT_TABLE() }; @@ -144,6 +192,8 @@ BEGIN_EVENT_TABLE(wxSearchTextCtrl, wxTextCtrl) EVT_TEXT_ENTER(wxID_ANY, wxSearchTextCtrl::OnText) EVT_TEXT_URL(wxID_ANY, wxSearchTextCtrl::OnTextUrl) EVT_TEXT_MAXLEN(wxID_ANY, wxSearchTextCtrl::OnText) + EVT_IDLE(wxSearchTextCtrl::OnIdle) + EVT_SET_FOCUS(wxSearchTextCtrl::OnFocus) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -160,24 +210,8 @@ public: m_bmp(bmp) { } - void SetBitmapLabel(const wxBitmap& label) - { - m_bmp = label; - InvalidateBestSize(); - } + void SetBitmapLabel(const wxBitmap& label) { m_bmp = label; } - // The buttons in wxSearchCtrl shouldn't accept focus from keyboard because - // this would interfere with the usual TAB processing: the user expects - // that pressing TAB in the search control should switch focus to the next - // control and not give it to the button inside the same control. Besides, - // the search button can be already activated by pressing "Enter" so there - // is really no reason for it to be able to get focus from keyboard. - virtual bool AcceptsFocusFromKeyboard() const { return false; } - - virtual wxWindow* GetMainWindowOfCompositeControl() - { - return m_search; - } protected: wxSize DoGetBestSize() const @@ -190,20 +224,12 @@ protected: wxCommandEvent event(m_eventType, m_search->GetId()); event.SetEventObject(m_search); - if ( m_eventType == wxEVT_SEARCHCTRL_SEARCH_BTN ) - { - // it's convenient to have the string to search for directly in the - // event instead of having to retrieve it from the control in the - // event handler code later, so provide it here - event.SetString(m_search->GetValue()); - } - GetEventHandler()->ProcessEvent(event); m_search->SetFocus(); #if wxUSE_MENUS - if ( m_eventType == wxEVT_SEARCHCTRL_SEARCH_BTN ) + if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN ) { // this happens automatically, just like on Mac OS X m_search->PopupSearchMenu(); @@ -232,7 +258,7 @@ BEGIN_EVENT_TABLE(wxSearchButton, wxControl) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase) - EVT_SEARCHCTRL_CANCEL_BTN(wxID_ANY, wxSearchCtrl::OnCancelButton) + EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, wxSearchCtrl::OnSearchButton) EVT_SET_FOCUS(wxSearchCtrl::OnSetFocus) EVT_SIZE(wxSearchCtrl::OnSize) END_EVENT_TABLE() @@ -295,35 +321,36 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - // force border style for more native appearance - style &= ~wxBORDER_MASK; -#ifdef __WXGTK__ - style |= wxBORDER_SUNKEN; -#elif defined(__WXMSW__) - // Don't set the style explicitly, let GetDefaultBorder() work it out, unless - // we will get a sunken border (e.g. on Windows 200) in which case we must - // override with a simple border. - if (GetDefaultBorder() == wxBORDER_SUNKEN) - style |= wxBORDER_SIMPLE; -#else - style |= wxBORDER_SIMPLE; + int borderStyle = wxBORDER_SIMPLE; + +#if defined(__WXMSW__) + borderStyle = GetThemedBorderStyle(); + if (borderStyle == wxBORDER_SUNKEN) + borderStyle = wxBORDER_SIMPLE; +#elif defined(__WXGTK__) + borderStyle = wxBORDER_SUNKEN; #endif - if ( !wxSearchCtrlBaseBaseClass::Create(parent, id, pos, size, - style, validator, name) ) + + if ( !wxTextCtrlBase::Create(parent, id, pos, size, borderStyle | (style & ~wxBORDER_MASK), validator, name) ) { return false; } - m_text = new wxSearchTextCtrl(this, value, style); + m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK); + m_text->SetDescriptiveText(_("Search")); - m_searchButton = new wxSearchButton(this, - wxEVT_SEARCHCTRL_SEARCH_BTN, - m_searchBitmap); - m_cancelButton = new wxSearchButton(this, - wxEVT_SEARCHCTRL_CANCEL_BTN, - m_cancelBitmap); + wxSize sizeText = m_text->GetBestSize(); + + m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,m_searchBitmap); + m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,m_cancelBitmap); + + SetForegroundColour( m_text->GetForegroundColour() ); + m_searchButton->SetForegroundColour( m_text->GetForegroundColour() ); + m_cancelButton->SetForegroundColour( m_text->GetForegroundColour() ); SetBackgroundColour( m_text->GetBackgroundColour() ); + m_searchButton->SetBackgroundColour( m_text->GetBackgroundColour() ); + m_cancelButton->SetBackgroundColour( m_text->GetBackgroundColour() ); RecalcBitmaps(); @@ -370,7 +397,8 @@ void wxSearchCtrl::SetMenu( wxMenu* menu ) m_searchButton->Refresh(); } } - DoLayoutControls(); + wxRect rect = GetRect(); + LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight()); } wxMenu* wxSearchCtrl::GetMenu() @@ -393,7 +421,8 @@ void wxSearchCtrl::ShowSearchButton( bool show ) RecalcBitmaps(); } - DoLayoutControls(); + wxRect rect = GetRect(); + LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight()); } bool wxSearchCtrl::IsSearchButtonVisible() const @@ -411,7 +440,8 @@ void wxSearchCtrl::ShowCancelButton( bool show ) } m_cancelButtonVisible = show; - DoLayoutControls(); + wxRect rect = GetRect(); + LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight()); } bool wxSearchCtrl::IsCancelButtonVisible() const @@ -421,12 +451,12 @@ bool wxSearchCtrl::IsCancelButtonVisible() const void wxSearchCtrl::SetDescriptiveText(const wxString& text) { - m_text->SetHint(text); + m_text->SetDescriptiveText(text); } wxString wxSearchCtrl::GetDescriptiveText() const { - return m_text->GetHint(); + return m_text->GetDescriptiveText(); } // ---------------------------------------------------------------------------- @@ -456,36 +486,28 @@ wxSize wxSearchCtrl::DoGetBestSize() const // buttons are square and equal to the height of the text control int height = sizeText.y; return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder, - height) + DoGetBorderSize(); + height + 2*BORDER); } void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height) { wxSearchCtrlBase::DoMoveWindow(x, y, width, height); - DoLayoutControls(); + LayoutControls(0, 0, width, height); } -void wxSearchCtrl::LayoutControls(int WXUNUSED(x), int WXUNUSED(y), - int WXUNUSED(width), int WXUNUSED(height)) -{ - DoLayoutControls(); -} - -void wxSearchCtrl::DoLayoutControls() +void wxSearchCtrl::LayoutControls(int x, int y, int width, int height) { if ( !m_text ) return; - const wxSize sizeTotal = GetClientSize(); - int width = sizeTotal.x, - height = sizeTotal.y; - wxSize sizeText = m_text->GetBestSize(); // make room for the search menu & clear button - int horizontalBorder = 1 + ( sizeText.y - sizeText.y * 14 / 21 ) / 2; - int x = horizontalBorder; + int horizontalBorder = ( sizeText.y - sizeText.y * 14 / 21 ) / 2; + x += horizontalBorder; + y += BORDER; width -= horizontalBorder*2; + height -= BORDER*2; wxSize sizeSearch(0,0); wxSize sizeCancel(0,0); @@ -512,39 +534,35 @@ void wxSearchCtrl::DoLayoutControls() cancelMargin = 0; } wxCoord textWidth = width - sizeSearch.x - sizeCancel.x - searchMargin - cancelMargin - 1; - if (textWidth < 0) textWidth = 0; // position the subcontrols inside the client area - m_searchButton->SetSize(x, (height - sizeSearch.y) / 2, - sizeSearch.x, height); - x += sizeSearch.x; - x += searchMargin; - - m_text->SetSize(x, 0, textWidth, height); - x += textWidth; - x += cancelMargin; - - m_cancelButton->SetSize(x, (height - sizeCancel.y) / 2, - sizeCancel.x, height); + m_searchButton->SetSize(x, y + ICON_OFFSET - 1, sizeSearch.x, height); + m_text->SetSize( x + sizeSearch.x + searchMargin, + y + ICON_OFFSET - BORDER, + textWidth, + height); + m_cancelButton->SetSize(x + sizeSearch.x + searchMargin + textWidth + cancelMargin, + y + ICON_OFFSET - 1, sizeCancel.x, height); } -wxWindowList wxSearchCtrl::GetCompositeWindowParts() const -{ - wxWindowList parts; - parts.push_back(m_text); - parts.push_back(m_searchButton); - parts.push_back(m_cancelButton); - return parts; -} // accessors // --------- -wxString wxSearchCtrl::DoGetValue() const +wxString wxSearchCtrl::GetValue() const { - return m_text->GetValue(); + wxString value = m_text->GetValue(); + if (value == m_text->GetDescriptiveText()) + return wxEmptyString; + else + return value; } +void wxSearchCtrl::SetValue(const wxString& value) +{ + m_text->SetValue(value); +} + wxString wxSearchCtrl::GetRange(long from, long to) const { return m_text->GetRange(from, to); @@ -766,7 +784,7 @@ long wxSearchCtrl::GetInsertionPoint() const { return m_text->GetInsertionPoint(); } -long wxSearchCtrl::GetLastPosition() const +wxTextPos wxSearchCtrl::GetLastPosition() const { return m_text->GetLastPosition(); } @@ -787,32 +805,20 @@ void wxSearchCtrl::SetEditable(bool editable) bool wxSearchCtrl::SetFont(const wxFont& font) { - if ( !wxSearchCtrlBase::SetFont(font) ) - return false; - - // Recreate the bitmaps as their size may have changed. + bool result = wxSearchCtrlBase::SetFont(font); + if ( result && m_text ) + { + result = m_text->SetFont(font); + } RecalcBitmaps(); - - return true; -} - -bool wxSearchCtrl::SetBackgroundColour(const wxColour& colour) -{ - if ( !wxSearchCtrlBase::SetBackgroundColour(colour) ) - return false; - - // When the background changes, re-render the bitmaps so that the correct - // colour shows in their "transparent" area. - RecalcBitmaps(); - - return true; + return result; } // search control generic only void wxSearchCtrl::SetSearchBitmap( const wxBitmap& bitmap ) { m_searchBitmap = bitmap; - m_searchBitmapUser = bitmap.IsOk(); + m_searchBitmapUser = bitmap.Ok(); if ( m_searchBitmapUser ) { if ( m_searchButton && !HasMenu() ) @@ -832,7 +838,7 @@ void wxSearchCtrl::SetSearchBitmap( const wxBitmap& bitmap ) void wxSearchCtrl::SetSearchMenuBitmap( const wxBitmap& bitmap ) { m_searchMenuBitmap = bitmap; - m_searchMenuBitmapUser = bitmap.IsOk(); + m_searchMenuBitmapUser = bitmap.Ok(); if ( m_searchMenuBitmapUser ) { if ( m_searchButton && m_menu ) @@ -852,7 +858,7 @@ void wxSearchCtrl::SetSearchMenuBitmap( const wxBitmap& bitmap ) void wxSearchCtrl::SetCancelBitmap( const wxBitmap& bitmap ) { m_cancelBitmap = bitmap; - m_cancelBitmapUser = bitmap.IsOk(); + m_cancelBitmapUser = bitmap.Ok(); if ( m_cancelBitmapUser ) { if ( m_cancelButton ) @@ -886,17 +892,9 @@ wxTextCtrl& operator<<(const wxChar c); void wxSearchCtrl::DoSetValue(const wxString& value, int flags) { - m_text->DoSetValue(value, flags); -} - -bool wxSearchCtrl::DoLoadFile(const wxString& file, int fileType) -{ - return m_text->DoLoadFile(file, fileType); -} - -bool wxSearchCtrl::DoSaveFile(const wxString& file, int fileType) -{ - return m_text->DoSaveFile(file, fileType); + m_text->ChangeValue( value ); + if ( flags & SetValue_SendEvent ) + SendTextUpdatedEvent(); } // do the window-specific processing after processing the update event @@ -931,7 +929,7 @@ static int GetMultiplier() wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop ) { wxColour bg = GetBackgroundColour(); - wxColour fg = GetForegroundColour().ChangeLightness(LIGHT_STEP-20); + wxColour fg = wxStepColour(GetForegroundColour(), LIGHT_STEP-20); //=============================================================================== // begin drawing code @@ -1036,7 +1034,7 @@ wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop ) wxBitmap wxSearchCtrl::RenderCancelBitmap( int x, int y ) { wxColour bg = GetBackgroundColour(); - wxColour fg = GetForegroundColour().ChangeLightness(LIGHT_STEP); + wxColour fg = wxStepColour(GetForegroundColour(), LIGHT_STEP); //=============================================================================== // begin drawing code @@ -1126,13 +1124,13 @@ void wxSearchCtrl::RecalcBitmaps() } wxSize sizeText = m_text->GetBestSize(); - int bitmapHeight = sizeText.y - 4; + int bitmapHeight = sizeText.y - 2 * ICON_MARGIN; int bitmapWidth = sizeText.y * 20 / 14; if ( !m_searchBitmapUser ) { if ( - !m_searchBitmap.IsOk() || + !m_searchBitmap.Ok() || m_searchBitmap.GetHeight() != bitmapHeight || m_searchBitmap.GetWidth() != bitmapWidth ) @@ -1150,7 +1148,7 @@ void wxSearchCtrl::RecalcBitmaps() if ( !m_searchMenuBitmapUser ) { if ( - !m_searchMenuBitmap.IsOk() || + !m_searchMenuBitmap.Ok() || m_searchMenuBitmap.GetHeight() != bitmapHeight || m_searchMenuBitmap.GetWidth() != bitmapWidth ) @@ -1168,21 +1166,20 @@ void wxSearchCtrl::RecalcBitmaps() if ( !m_cancelBitmapUser ) { if ( - !m_cancelBitmap.IsOk() || + !m_cancelBitmap.Ok() || m_cancelBitmap.GetHeight() != bitmapHeight || m_cancelBitmap.GetWidth() != bitmapHeight ) { - m_cancelBitmap = RenderCancelBitmap(bitmapHeight,bitmapHeight); // square + m_cancelBitmap = RenderCancelBitmap(bitmapHeight-BORDER-1,bitmapHeight-BORDER-1); // square m_cancelButton->SetBitmapLabel(m_cancelBitmap); } // else this bitmap was set by user, don't alter } } -void wxSearchCtrl::OnCancelButton( wxCommandEvent& event ) +void wxSearchCtrl::OnSearchButton( wxCommandEvent& event ) { - m_text->Clear(); event.Skip(); } @@ -1196,7 +1193,9 @@ void wxSearchCtrl::OnSetFocus( wxFocusEvent& /*event*/ ) void wxSearchCtrl::OnSize( wxSizeEvent& WXUNUSED(event) ) { - DoLayoutControls(); + int width, height; + GetSize(&width, &height); + LayoutControls(0, 0, width, height); } #if wxUSE_MENUS diff --git a/Source/3rd Party/wx/src/generic/statbmpg.cpp b/Source/3rd Party/wx/src/generic/statbmpg.cpp deleted file mode 100644 index a21ef57e0..000000000 --- a/Source/3rd Party/wx/src/generic/statbmpg.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/statbmpg.cpp -// Purpose: wxGenericStaticBitmap -// Author: Marcin Wojdyr, Stefan Csomor -// Created: 2008-06-16 -// Copyright: wxWidgets developers -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#if wxUSE_STATBMP - -#ifndef WX_PRECOMP - #include "wx/dcclient.h" -#endif - -#include "wx/generic/statbmpg.h" - -bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name) -{ - if (! wxControl::Create(parent, id, pos, size, style, - wxDefaultValidator, name)) - return false; - SetBitmap(bitmap); - Connect(wxEVT_PAINT, wxPaintEventHandler(wxGenericStaticBitmap::OnPaint)); - return true; -} - -void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - if (m_bitmap.IsOk()) - dc.DrawBitmap(m_bitmap, 0, 0, true); -} - -// under OSX_cocoa is a define, avoid duplicate info -#ifndef wxGenericStaticBitmap - -IMPLEMENT_DYNAMIC_CLASS(wxGenericStaticBitmap, wxStaticBitmapBase) - -#endif - -#endif // wxUSE_STATBMP - diff --git a/Source/3rd Party/wx/src/generic/statline.cpp b/Source/3rd Party/wx/src/generic/statline.cpp deleted file mode 100644 index a36445889..000000000 --- a/Source/3rd Party/wx/src/generic/statline.cpp +++ /dev/null @@ -1,85 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/statline.cpp -// Purpose: a generic wxStaticLine class -// Author: Vadim Zeitlin -// Created: 28.06.99 -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -// For compilers that support precompilation, includes "wx.h". - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STATLINE - -#include "wx/statline.h" - -#ifndef WX_PRECOMP - #include "wx/statbox.h" -#endif - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxStaticLine -// ---------------------------------------------------------------------------- - -bool wxStaticLine::Create( wxWindow *parent, - wxWindowID id, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name) -{ - m_statbox = NULL; - - if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) - return false; - - // ok, this is ugly but it's better than nothing: use a thin static box to - // emulate static line - - wxSize sizeReal = AdjustSize(size); - - m_statbox = new wxStaticBox(parent, id, wxEmptyString, pos, sizeReal, style, name); - - return true; -} - -wxStaticLine::~wxStaticLine() -{ - delete m_statbox; -} - -WXWidget wxStaticLine::GetMainWidget() const -{ - return m_statbox->GetMainWidget(); -} - -void wxStaticLine::DoSetSize(int x, int y, int width, int height, int sizeFlags) -{ - m_statbox->SetSize(x, y, width, height, sizeFlags); -} - -void wxStaticLine::DoMoveWindow(int x, int y, int width, int height) -{ - m_statbox->SetSize(x, y, width, height); -} - -#endif - // wxUSE_STATLINE diff --git a/Source/3rd Party/wx/src/generic/stattextg.cpp b/Source/3rd Party/wx/src/generic/stattextg.cpp deleted file mode 100644 index 74843fa21..000000000 --- a/Source/3rd Party/wx/src/generic/stattextg.cpp +++ /dev/null @@ -1,168 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/stattextg.cpp -// Purpose: wxGenericStaticText -// Author: Marcin Wojdyr -// Created: 2008-06-26 -// Copyright: Marcin Wojdyr -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STATTEXT - -#ifndef WX_PRECOMP - #include "wx/dcclient.h" - #include "wx/settings.h" - #include "wx/validate.h" -#endif - -#include "wx/generic/stattextg.h" - -#if wxUSE_MARKUP - #include "wx/generic/private/markuptext.h" -#endif // wxUSE_MARKUP - -IMPLEMENT_DYNAMIC_CLASS(wxGenericStaticText, wxStaticTextBase) - - -bool wxGenericStaticText::Create(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name) -{ - if ( !wxControl::Create(parent, id, pos, size, style, - wxDefaultValidator, name) ) - return false; - - SetLabel(label); - SetInitialSize(size); - Connect(wxEVT_PAINT, wxPaintEventHandler(wxGenericStaticText::OnPaint)); - return true; -} - -wxGenericStaticText::~wxGenericStaticText() -{ -#if wxUSE_MARKUP - delete m_markupText; -#endif // wxUSE_MARKUP -} - -void wxGenericStaticText::DoDrawLabel(wxDC& dc, const wxRect& rect) -{ -#if wxUSE_MARKUP - if ( m_markupText ) - m_markupText->Render(dc, rect, wxMarkupText::Render_ShowAccels); - else -#endif // wxUSE_MARKUP - dc.DrawLabel(m_label, rect, GetAlignment(), m_mnemonic); -} - -void wxGenericStaticText::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - wxRect rect = GetClientRect(); - if ( IsEnabled() ) - { - dc.SetTextForeground( - wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); - } - else // paint disabled text - { - // draw shadow of the text - dc.SetTextForeground( - wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); - wxRect rectShadow = rect; - rectShadow.Offset(1, 1); - DoDrawLabel(dc, rectShadow); - dc.SetTextForeground( - wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)); - } - DoDrawLabel(dc, rect); -} - - -wxSize wxGenericStaticText::DoGetBestClientSize() const -{ - wxClientDC dc(wxConstCast(this, wxGenericStaticText)); - -#if wxUSE_MARKUP - if ( m_markupText ) - return m_markupText->Measure(dc); -#endif // wxUSE_MARKUP - - return dc.GetMultiLineTextExtent(GetLabel()); -} - -void wxGenericStaticText::SetLabel(const wxString& label) -{ - wxControl::SetLabel(label); - DoSetLabel(GetEllipsizedLabel()); - if ( !HasFlag(wxST_NO_AUTORESIZE) && !IsEllipsized() ) - InvalidateBestSize(); - -#if wxUSE_MARKUP - if ( m_markupText ) - { - delete m_markupText; - m_markupText = NULL; - } -#endif // wxUSE_MARKUP - - Refresh(); -} - -void wxGenericStaticText::DoSetLabel(const wxString& label) -{ - m_mnemonic = FindAccelIndex(label, &m_label); -} - -#if wxUSE_MARKUP - -bool wxGenericStaticText::DoSetLabelMarkup(const wxString& markup) -{ - if ( !wxStaticTextBase::DoSetLabelMarkup(markup) ) - return false; - - if ( !m_markupText ) - m_markupText = new wxMarkupText(markup); - else - m_markupText->SetMarkup(markup); - - if ( !HasFlag(wxST_NO_AUTORESIZE) ) - InvalidateBestSize(); - - Refresh(); - - return true; -} - -#endif // wxUSE_MARKUP - -bool wxGenericStaticText::SetFont(const wxFont &font) -{ - if ( !wxControl::SetFont(font) ) - return false; - if ( !HasFlag(wxST_NO_AUTORESIZE) ) - InvalidateBestSize(); - Refresh(); - return true; -} - -void wxGenericStaticText::DoSetSize(int x, int y, int width, int height, - int sizeFlags) -{ - wxStaticTextBase::DoSetSize(x, y, width, height, sizeFlags); - UpdateLabel(); -} - - -#endif // wxUSE_STATTEXT diff --git a/Source/3rd Party/wx/src/generic/statusbr.cpp b/Source/3rd Party/wx/src/generic/statusbr.cpp index fd7455268..c392cefcd 100644 --- a/Source/3rd Party/wx/src/generic/statusbr.cpp +++ b/Source/3rd Party/wx/src/generic/statusbr.cpp @@ -2,8 +2,9 @@ // Name: src/generic/statusbr.cpp // Purpose: wxStatusBarGeneric class implementation // Author: Julian Smart -// Modified by: Francesco Montorsi +// Modified by: // Created: 01/02/97 +// RCS-ID: $Id: statusbr.cpp 57542 2008-12-25 13:03:24Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -22,14 +23,11 @@ #ifndef WX_PRECOMP #include "wx/settings.h" #include "wx/dcclient.h" - #include "wx/toplevel.h" - #include "wx/control.h" #endif #ifdef __WXGTK20__ #include - #include "wx/gtk/private.h" - #include "wx/gtk/private/gtk2-compat.h" + #include "wx/gtk/win_gtk.h" #endif // we only have to do it here when we use wxStatusBarGeneric in addition to the @@ -43,60 +41,16 @@ IMPLEMENT_DYNAMIC_CLASS(wxStatusBarGeneric, wxWindow) #endif // wxUSE_NATIVE_STATUSBAR -// Default status border dimensions -#define wxTHICK_LINE_BORDER 2 - -// Margin between the field text and the field rect -#define wxFIELD_TEXT_MARGIN 2 - -// ---------------------------------------------------------------------------- -// GTK+ signal handler -// ---------------------------------------------------------------------------- - -#if defined( __WXGTK20__ ) -#if GTK_CHECK_VERSION(2,12,0) -extern "C" { -static -gboolean statusbar_query_tooltip(GtkWidget* WXUNUSED(widget), - gint x, - gint y, - gboolean WXUNUSED(keyboard_mode), - GtkTooltip *tooltip, - wxStatusBar* statbar) -{ - int n = statbar->GetFieldFromPoint(wxPoint(x,y)); - if (n == wxNOT_FOUND) - return FALSE; - - // should we show the tooltip for the n-th pane of the statusbar? - if (!statbar->GetField(n).IsEllipsized()) - return FALSE; // no, it's not useful - - const wxString& str = statbar->GetStatusText(n); - if (str.empty()) - return FALSE; - - gtk_tooltip_set_text(tooltip, wxGTK_CONV_SYS(str)); - return TRUE; -} -} -#endif -#endif - -// ---------------------------------------------------------------------------- -// wxStatusBarGeneric -// ---------------------------------------------------------------------------- - BEGIN_EVENT_TABLE(wxStatusBarGeneric, wxWindow) EVT_PAINT(wxStatusBarGeneric::OnPaint) - EVT_SIZE(wxStatusBarGeneric::OnSize) -#ifdef __WXGTK20__ EVT_LEFT_DOWN(wxStatusBarGeneric::OnLeftDown) EVT_RIGHT_DOWN(wxStatusBarGeneric::OnRightDown) -#endif EVT_SYS_COLOUR_CHANGED(wxStatusBarGeneric::OnSysColourChanged) END_EVENT_TABLE() +// Default status border dimensions +#define wxTHICK_LINE_BORDER 2 + void wxStatusBarGeneric::Init() { m_borderX = wxTHICK_LINE_BORDER; @@ -127,179 +81,218 @@ bool wxStatusBarGeneric::Create(wxWindow *parent, SetFont(*wxSMALL_FONT); #endif - int height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); + wxCoord y; + { + // Set the height according to the font and the border size + wxClientDC dc(this); + dc.SetFont(GetFont()); + + dc.GetTextExtent(_T("X"), NULL, &y ); + } + int height = (int)( (11*y)/10 + 2*GetBorderY()); + SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height); SetFieldsCount(1); -#if defined( __WXGTK20__ ) -#if GTK_CHECK_VERSION(2,12,0) - if (HasFlag(wxSTB_SHOW_TIPS) -#ifndef __WXGTK3__ - && gtk_check_version(2,12,0) == NULL -#endif - ) - { - g_object_set(m_widget, "has-tooltip", TRUE, NULL); - g_signal_connect(m_widget, "query-tooltip", - G_CALLBACK(statusbar_query_tooltip), this); - } -#endif -#endif - return true; } + wxSize wxStatusBarGeneric::DoGetBestSize() const { int width, height; // best width is the width of the parent - if (GetParent()) - GetParent()->GetClientSize(&width, NULL); - else - width = 80; // a dummy value + GetParent()->GetClientSize(&width, NULL); - // best height is as calculated above in Create() - height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); + // best height is as calculated above in Create + wxClientDC dc((wxWindow*)this); + dc.SetFont(GetFont()); + wxCoord y; + dc.GetTextExtent(_T("X"), NULL, &y ); + height = (int)( (11*y)/10 + 2*GetBorderY()); return wxSize(width, height); } -void wxStatusBarGeneric::DoUpdateStatusText(int number) +void wxStatusBarGeneric::SetFieldsCount(int number, const int *widths) { - wxRect rect; - GetFieldRect(number, rect); + wxASSERT_MSG( number >= 0, _T("negative number of fields in wxStatusBar?") ); - Refresh(true, &rect); + int i; + for(i = m_nFields; i < number; ++i) + m_statusStrings.Add( wxEmptyString ); - // it's common to show some text in the status bar before starting a - // relatively lengthy operation, ensure that the text is shown to the - // user immediately and not after the lengthy operation end - Update(); + for (i = m_nFields - 1; i >= number; --i) + m_statusStrings.RemoveAt(i); + + // forget the old cached pixel widths + m_widthsAbs.Empty(); + + wxStatusBarBase::SetFieldsCount(number, widths); + + wxASSERT_MSG( m_nFields == (int)m_statusStrings.GetCount(), + _T("This really should never happen, can we do away with m_nFields here?") ); +} + +void wxStatusBarGeneric::SetStatusText(const wxString& text, int number) +{ + wxCHECK_RET( (number >= 0) && (number < m_nFields), + _T("invalid status bar field index") ); + + wxString oldText = m_statusStrings[number]; + if (oldText != text) + { + m_statusStrings[number] = text; + + wxRect rect; + GetFieldRect(number, rect); + + Refresh(true, &rect); + + // it's common to show some text in the status bar before starting a + // relatively lengthy operation, ensure that the text is shown to the + // user immediately and not after the lengthy operation end + Update(); + } +} + +wxString wxStatusBarGeneric::GetStatusText(int n) const +{ + wxCHECK_MSG( (n >= 0) && (n < m_nFields), wxEmptyString, + _T("invalid status bar field index") ); + + return m_statusStrings[n]; } void wxStatusBarGeneric::SetStatusWidths(int n, const int widths_field[]) { - // only set status widths when n == number of statuswindows - wxCHECK_RET( (size_t)n == m_panes.GetCount(), wxT("status bar field count mismatch") ); + // only set status widths, when n == number of statuswindows + wxCHECK_RET( n == m_nFields, _T("status bar field count mismatch") ); + + // delete the old widths in any case - this function may be used to reset + // the widths to the default (all equal) + // MBN: this is incompatible with at least wxMSW and wxMAC and not + // documented, but let's keep it for now + ReinitWidths(); + + // forget the old cached pixel widths + m_widthsAbs.Empty(); + + if ( !widths_field ) + { + // not an error, see the comment above + Refresh(); + return; + } wxStatusBarBase::SetStatusWidths(n, widths_field); - - // update cache - DoUpdateFieldWidths(); } -void wxStatusBarGeneric::DoUpdateFieldWidths() +void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) { - m_lastClientSize = GetClientSize(); + wxPaintDC dc(this); - // recompute the cache of the field widths if the status bar width has changed - m_widthsAbs = CalculateAbsWidths(m_lastClientSize.x); -} - -bool wxStatusBarGeneric::ShowsSizeGrip() const -{ - if ( !HasFlag(wxSTB_SIZEGRIP) ) - return false; - - wxTopLevelWindow * const - tlw = wxDynamicCast(wxGetTopLevelParent(GetParent()), wxTopLevelWindow); - return tlw && !tlw->IsMaximized() && tlw->HasFlag(wxRESIZE_BORDER); -} - -void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) -{ - wxString text(GetStatusText(i)); - if (text.empty()) - return; // optimization - - int xpos = rect.x + wxFIELD_TEXT_MARGIN, - maxWidth = rect.width - 2*wxFIELD_TEXT_MARGIN, - ypos = (int) (((rect.height - textHeight) / 2) + rect.y + 0.5); - - if (ShowsSizeGrip()) + dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); +#ifdef __WXGTK20__ + // Draw grip first + if (HasFlag( wxST_SIZEGRIP )) { - // don't write text over the size grip: - // NOTE: overloading DoGetClientSize() and GetClientAreaOrigin() wouldn't - // work because the adjustment needs to be done only when drawing - // the field text and not also when drawing the background, the - // size grip itself, etc - if ((GetLayoutDirection() == wxLayout_RightToLeft && i == 0) || - (GetLayoutDirection() != wxLayout_RightToLeft && - i == (int)m_panes.GetCount()-1)) + int width, height; + GetClientSize(&width, &height); + + if (GetLayoutDirection() == wxLayout_RightToLeft) { - const wxRect& gripRc = GetSizeGripRect(); - - // NOTE: we don't need any special treatment wrt to the layout direction - // since DrawText() will automatically adjust the origin of the - // text accordingly to the layout in use - - maxWidth -= gripRc.width; + gtk_paint_resize_grip( m_widget->style, + GTK_PIZZA(m_wxwindow)->bin_window, + (GtkStateType) GTK_WIDGET_STATE (m_widget), + NULL, + m_widget, + "statusbar", + GDK_WINDOW_EDGE_SOUTH_WEST, + 2, 2, height-2, height-4 ); + } + else + { + gtk_paint_resize_grip( m_widget->style, + GTK_PIZZA(m_wxwindow)->bin_window, + (GtkStateType) GTK_WIDGET_STATE (m_widget), + NULL, + m_widget, + "statusbar", + GDK_WINDOW_EDGE_SOUTH_EAST, + width-height-2, 2, height-2, height-4 ); } } +#endif - // eventually ellipsize the text so that it fits the field width + if (GetFont().Ok()) + dc.SetFont(GetFont()); - wxEllipsizeMode ellmode = (wxEllipsizeMode)-1; - if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START; - else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE; - else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END; + dc.SetBackgroundMode(wxTRANSPARENT); - if (ellmode == (wxEllipsizeMode)-1) - { - // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if - // we don't ellipsize the text but just truncate it - if (HasFlag(wxSTB_SHOW_TIPS)) - SetEllipsizedFlag(i, dc.GetTextExtent(text).GetWidth() > maxWidth); +#ifdef __WXPM__ + wxColour vColor; - dc.SetClippingRegion(rect); - } - else - { - text = wxControl::Ellipsize(text, dc, - ellmode, - maxWidth, - wxELLIPSIZE_FLAGS_EXPAND_TABS); - // Ellipsize() will do something only if necessary + vColor = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR); + ::WinFillRect(dc.m_hPS, &dc.m_vRclPaint, vColor.GetPixel()); +#endif - // update the ellipsization status for this pane; this is used later to - // decide whether a tooltip should be shown or not for this pane - // (if we have wxSTB_SHOW_TIPS) - SetEllipsizedFlag(i, text != GetStatusText(i)); - } + for (int i = 0; i < m_nFields; i ++) + DrawField(dc, i); +} + +void wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i) +{ + int leftMargin = 2; + + wxRect rect; + GetFieldRect(i, rect); + + wxString text(GetStatusText(i)); + + long x = 0, y = 0; + + dc.GetTextExtent(text, &x, &y); + + int xpos = rect.x + leftMargin; + int ypos = (int) (((rect.height - y) / 2 ) + rect.y + 0.5) ; #if defined( __WXGTK__ ) || defined(__WXMAC__) xpos++; ypos++; #endif - // draw the text + dc.SetClippingRegion(rect.x, rect.y, rect.width, rect.height); + dc.DrawText(text, xpos, ypos); - if (ellmode == (wxEllipsizeMode)-1) - dc.DestroyClippingRegion(); + dc.DestroyClippingRegion(); } -void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight) +void wxStatusBarGeneric::DrawField(wxDC& dc, int i) { wxRect rect; GetFieldRect(i, rect); - if (rect.GetWidth() <= 0) - return; // happens when the status bar is shrunk in a very small area! + int style = wxSB_NORMAL; + if (m_statusStyles) + style = m_statusStyles[i]; - int style = m_panes[i].GetStyle(); - if (style == wxSB_RAISED || style == wxSB_SUNKEN) + if (style != wxSB_FLAT) { // Draw border - // For wxSB_SUNKEN: paint a grey background, plus 3-d border (one black rectangle) - // Inside this, left and top sides (dark grey). Bottom and right (white). + // For wxSB_NORMAL: + // Have grey background, plus 3-d border - + // One black rectangle. + // Inside this, left and top sides - dark grey. Bottom and right - + // white. // Reverse it for wxSB_RAISED dc.SetPen((style == wxSB_RAISED) ? m_mediumShadowPen : m_hilightPen); -#ifndef __WXPM__ + #ifndef __WXPM__ // Right and bottom lines dc.DrawLine(rect.x + rect.width, rect.y, @@ -314,7 +307,7 @@ void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight) rect.x, rect.y); dc.DrawLine(rect.x, rect.y, rect.x + rect.width, rect.y); -#else + #else dc.DrawLine(rect.x + rect.width, rect.height + 2, rect.x, rect.height + 2); @@ -325,70 +318,59 @@ void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight) dc.DrawLine(rect.x, rect.y, rect.x + rect.width, rect.y); dc.DrawLine(rect.x, rect.y + rect.height, - rect.x, rect.y); + rect.x, rect.y); + #endif } - DrawFieldText(dc, rect, i, textHeight); + DrawFieldText(dc, i); } + // Get the position and size of the field's internal bounding rectangle bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const { - wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), false, - wxT("invalid status bar field index") ); + wxCHECK_MSG( (n >= 0) && (n < m_nFields), false, + _T("invalid status bar field index") ); - // We can be called from the user-defined EVT_SIZE handler in which case - // the widths haven't been updated yet and we need to do it now. This is - // not very efficient as we keep testing the size but there is no other way - // to make the code needing the up-to-date fields sizes in its EVT_SIZE to - // work. - if ( GetClientSize().x != m_lastClientSize.x ) + // FIXME: workarounds for OS/2 bugs have nothing to do here (VZ) + int width, height; +#ifdef __WXPM__ + GetSize(&width, &height); +#else + GetClientSize(&width, &height); +#endif + + // we cache m_widthsAbs between calls and recompute it if client + // width has changed (or when it is initially empty) + if ( m_widthsAbs.IsEmpty() || (m_lastClientWidth != width) ) { - const_cast(this)->DoUpdateFieldWidths(); + wxConstCast(this, wxStatusBarGeneric)-> + m_widthsAbs = CalculateAbsWidths(width); + // remember last width for which we have recomputed the widths in pixels + wxConstCast(this, wxStatusBarGeneric)-> + m_lastClientWidth = width; } - if (m_widthsAbs.IsEmpty()) - return false; - rect.x = 0; for ( int i = 0; i < n; i++ ) + { rect.x += m_widthsAbs[i]; - rect.x += m_borderX; + } + rect.x += m_borderX; rect.y = m_borderY; + rect.width = m_widthsAbs[n] - 2*m_borderX; - rect.height = m_lastClientSize.y - 2*m_borderY; + rect.height = height - 2*m_borderY; return true; } -int wxStatusBarGeneric::GetFieldFromPoint(const wxPoint& pt) const -{ - if (m_widthsAbs.IsEmpty()) - return wxNOT_FOUND; - - // NOTE: we explicitly don't take in count the borders since they are only - // useful when rendering the status text, not for hit-test computations - - if (pt.y <= 0 || pt.y >= m_lastClientSize.y) - return wxNOT_FOUND; - - int x = 0; - for ( size_t i = 0; i < m_panes.GetCount(); i++ ) - { - if (pt.x > x && pt.x < x+m_widthsAbs[i]) - return i; - - x += m_widthsAbs[i]; - } - - return wxNOT_FOUND; -} - +// Initialize colours void wxStatusBarGeneric::InitColours() { #if defined(__WXPM__) - m_mediumShadowPen = wxPen(wxColour(127, 127, 127)); + m_mediumShadowPen = wxPen(wxColour(127, 127, 127), 1, wxSOLID); m_hilightPen = *wxWHITE_PEN; SetBackgroundColour(*wxLIGHT_GREY); @@ -399,85 +381,7 @@ void wxStatusBarGeneric::InitColours() #endif // __WXPM__/!__WXPM__ } -void wxStatusBarGeneric::SetMinHeight(int height) -{ - // check that this min height is not less than minimal height for the - // current font (min height is as calculated above in Create() except for border) - int minHeight = (int)((11*GetCharHeight())/10); - - if ( height > minHeight ) - SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height + 2*m_borderY); -} - -wxRect wxStatusBarGeneric::GetSizeGripRect() const -{ - int width, height; - wxWindow::DoGetClientSize(&width, &height); - - if (GetLayoutDirection() == wxLayout_RightToLeft) - return wxRect(2, 2, height-2, height-4); - else - return wxRect(width-height-2, 2, height-2, height-4); -} - -// ---------------------------------------------------------------------------- -// wxStatusBarGeneric - event handlers -// ---------------------------------------------------------------------------- - -void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - -#ifdef __WXGTK20__ - // Draw grip first - if ( ShowsSizeGrip() ) - { - const wxRect& rc = GetSizeGripRect(); -#ifdef __WXGTK3__ - GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget); - GdkRectangle rect; - if (toplevel && (!gtk_window_get_resize_grip_area(GTK_WINDOW(toplevel), &rect) || - rect.width == 0 || rect.height == 0)) - { - GtkStyleContext* sc = gtk_widget_get_style_context(toplevel); - gtk_style_context_save(sc); - gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP); - GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT; - if (GetLayoutDirection() == wxLayout_RightToLeft) - sides = GTK_JUNCTION_CORNER_BOTTOMLEFT; - gtk_style_context_set_junction_sides(sc, sides); - gtk_render_handle(sc, - static_cast(dc.GetImpl()->GetCairoContext()), - rc.x, rc.y, rc.width, rc.height); - gtk_style_context_restore(sc); - } -#else - GdkWindowEdge edge = - GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : - GDK_WINDOW_EDGE_SOUTH_EAST; - gtk_paint_resize_grip(gtk_widget_get_style(m_widget), - GTKGetDrawingWindow(), - gtk_widget_get_state(m_widget), - NULL, - m_widget, - "statusbar", - edge, - rc.x, rc.y, rc.width, rc.height ); -#endif - } -#endif // __WXGTK20__ - - if (GetFont().IsOk()) - dc.SetFont(GetFont()); - - // compute char height only once for all panes: - int textHeight = dc.GetCharHeight(); - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - for (size_t i = 0; i < m_panes.GetCount(); i ++) - DrawField(dc, i, textHeight); -} - +// Responds to colour changes, and passes event on to children. void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event) { InitColours(); @@ -486,25 +390,34 @@ void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event) wxWindow::OnSysColourChanged(event); } -#ifdef __WXGTK20__ +void wxStatusBarGeneric::SetMinHeight(int height) +{ + // check that this min height is not less than minimal height for the + // current font + wxClientDC dc(this); + wxCoord y; + dc.GetTextExtent( wxT("X"), NULL, &y ); + + if ( height > (11*y)/10 ) + { + SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height + 2*m_borderY); + } +} + void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event) { +#ifdef __WXGTK20__ int width, height; GetClientSize(&width, &height); - GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget); -#ifdef __WXGTK3__ - GdkRectangle rect; - if (ancestor && gtk_window_get_resize_grip_area(GTK_WINDOW(ancestor), &rect) && - rect.width && rect.height) + if (HasFlag( wxST_SIZEGRIP ) && (event.GetX() > width-height)) { - ancestor = NULL; - } -#endif + GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget ); - if (ancestor && ShowsSizeGrip() && event.GetX() > width - height) - { - GdkWindow *source = GTKGetDrawingWindow(); + if (!GTK_IS_WINDOW (ancestor)) + return; + + GdkWindow *source = GTK_PIZZA(m_wxwindow)->bin_window; int org_x = 0; int org_y = 0; @@ -533,26 +446,25 @@ void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event) { event.Skip( true ); } +#else + event.Skip( true ); +#endif } void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event) { +#ifdef __WXGTK20__ int width, height; GetClientSize(&width, &height); - GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget); -#ifdef __WXGTK3__ - GdkRectangle rect; - if (ancestor && gtk_window_get_resize_grip_area(GTK_WINDOW(ancestor), &rect) && - rect.width && rect.height) + if (HasFlag( wxST_SIZEGRIP ) && (event.GetX() > width-height)) { - ancestor = NULL; - } -#endif + GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget ); - if (ancestor && ShowsSizeGrip() && event.GetX() > width - height) - { - GdkWindow *source = GTKGetDrawingWindow(); + if (!GTK_IS_WINDOW (ancestor)) + return; + + GdkWindow *source = GTK_PIZZA(m_wxwindow)->bin_window; int org_x = 0; int org_y = 0; @@ -568,14 +480,9 @@ void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event) { event.Skip( true ); } -} -#endif // __WXGTK20__ - -void wxStatusBarGeneric::OnSize(wxSizeEvent& event) -{ - DoUpdateFieldWidths(); - - event.Skip(); +#else + event.Skip( true ); +#endif } #endif // wxUSE_STATUSBAR diff --git a/Source/3rd Party/wx/src/generic/tabg.cpp b/Source/3rd Party/wx/src/generic/tabg.cpp deleted file mode 100644 index 7d4dbdf09..000000000 --- a/Source/3rd Party/wx/src/generic/tabg.cpp +++ /dev/null @@ -1,1288 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/generic/tabg.cpp -// Purpose: Generic tabbed dialogs; used by wxMotif's wxNotebook -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/settings.h" - #include "wx/intl.h" - #include "wx/dcclient.h" - #include "wx/math.h" -#endif - -#include -#include -#include - -#include "wx/generic/tabg.h" -#include "wx/listimpl.cpp" - -WX_DEFINE_LIST(wxTabLayerList) - -// not defined: use old, square tab implementation (fills in tabs) -// defined: use new, rounded tab implementation (doesn't colour in tabs) -// #define wxUSE_NEW_METHOD - -IMPLEMENT_DYNAMIC_CLASS(wxTabControl, wxObject) - -// IMPLEMENT_DYNAMIC_CLASS(wxTabLayer, wxList) - -wxTabControl::wxTabControl(wxTabView *v) -{ - m_view = v; - m_isSelected = false; - m_offsetX = 0; - m_offsetY = 0; - m_width = 0; - m_height = 0; - m_id = 0; - m_rowPosition = 0; - m_colPosition = 0; -} - -wxTabControl::~wxTabControl(void) -{ -} - -void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) -{ - // Old, but in some ways better (drawing opaque tabs) -#ifndef wxUSE_NEW_METHOD - if (!m_view) - return; - - // Top-left of tab view area - int viewX = m_view->GetViewRect().x; - int viewY = m_view->GetViewRect().y; - - // Top-left of tab control - int tabX = GetX() + viewX; - int tabY = GetY() + viewY; - int tabHeightInc = 0; - if (m_isSelected) - { - tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); - tabY -= tabHeightInc; - } - - dc.SetPen(*wxTRANSPARENT_PEN); - - // Draw grey background - if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) - { - if(m_view->GetBackgroundBrush()) - dc.SetBrush(*m_view->GetBackgroundBrush()); - - // Add 1 because the pen is transparent. Under Motif, may be different. -#ifdef __WXMOTIF__ - dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); -#else - dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); -#endif - } - - // Draw highlight and shadow - dc.SetPen(*m_view->GetHighlightPen()); - - // Calculate the top of the tab beneath. It's the height of the tab, MINUS - // a bit if the tab below happens to be selected. Check. - wxTabControl *tabBeneath = NULL; - int subtractThis = 0; - if (GetColPosition() > 0) - tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition()); - if (tabBeneath && tabBeneath->IsSelected()) - subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); - - // Vertical highlight: if first tab, draw to bottom of view - if (tabX == m_view->GetViewRect().x && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) - dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y + m_view->GetViewRect().height)); - else if (tabX == m_view->GetViewRect().x) - // Not box drawing, just to top of view. - dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y)); - else - dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis)); - - dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY); - dc.SetPen(*m_view->GetShadowPen()); - - // Test if we're outside the right-hand edge of the view area - if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) - { - int bottomY = m_view->GetViewRect().y + m_view->GetViewRect().height + GetY() + m_view->GetTabHeight() + m_view->GetTopMargin(); - // Add a tab height since we wish to draw to the bottom of the view. - dc.DrawLine((tabX + GetWidth()), tabY, - (tabX + GetWidth()), bottomY); - - // Calculate the far-right of the view, since we don't wish to - // draw inside that - int rightOfView = m_view->GetViewRect().x + m_view->GetViewRect().width + 1; - - // Draw the horizontal bit to connect to the view rectangle - dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY-1), - (tabX + GetWidth()), (bottomY-1)); - - // Draw black line to emphasize shadow - dc.SetPen(*wxBLACK_PEN); - dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), - (tabX + GetWidth() + 1), bottomY); - - // Draw the horizontal bit to connect to the view rectangle - dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY), - (tabX + GetWidth() + 1), (bottomY)); - } - else - { - if (lastInRow) - { - // 25/5/97 UNLESS it's less than the max number of positions in this row - - int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); - - int maxPositions = ((wxTabLayer *)m_view->GetLayers().Item(0)->GetData())->GetCount(); - - // Only down to the bottom of the tab, not to the top of the view - if ( GetRowPosition() < (maxPositions - 1) ) - topY = tabY + GetHeight() + tabHeightInc; - -#ifdef __WXMOTIF__ - topY -= 1; -#endif - - // Shadow - dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); - // Draw black line to emphasize shadow - dc.SetPen(*wxBLACK_PEN); - dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), - topY); - } - else - { - // Calculate the top of the tab beneath. It's the height of the tab, MINUS - // a bit if the tab below (and next col along) happens to be selected. Check. - wxTabControl *tabBeneath = NULL; - int subtractThis = 0; - if (GetColPosition() > 0) - tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition() + 1); - if (tabBeneath && tabBeneath->IsSelected()) - subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); - -#ifdef __WXMOTIF__ - subtractThis += 1; -#endif - - // Draw only to next tab down. - dc.DrawLine((tabX + GetWidth()), tabY, - (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); - - // Draw black line to emphasize shadow - dc.SetPen(*wxBLACK_PEN); - dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), - (tabY + GetHeight() + tabHeightInc - subtractThis)); - } - } - - // Draw centered text - int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; - - if (m_isSelected) - dc.SetFont(* m_view->GetSelectedTabFont()); - else - dc.SetFont(* GetFont()); - - wxColour col(m_view->GetTextColour()); - dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); - wxCoord textWidth, textHeight; - dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); - - int textX = (int)(tabX + (GetWidth() - textWidth)/2.0); - if (textX < (tabX + 2)) - textX = (tabX + 2); - - dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight()); - dc.DrawText(GetLabel(), textX, textY); - dc.DestroyClippingRegion(); - - if (m_isSelected) - { - dc.SetPen(*m_view->GetHighlightPen()); - - // Draw white highlight from the tab's left side to the left hand edge of the view - dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc), - tabX, (tabY + GetHeight() + tabHeightInc)); - - // Draw white highlight from the tab's right side to the right hand edge of the view - dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc), - m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc)); - } -#else - // New HEL version with rounder tabs - - if (!m_view) return; - - int tabInc = 0; - if (m_isSelected) - { - tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); - } - int tabLeft = GetX() + m_view->GetViewRect().x; - int tabTop = GetY() + m_view->GetViewRect().y - tabInc; - int tabRight = tabLeft + m_view->GetTabWidth(); - int left = m_view->GetViewRect().x; - int top = tabTop + m_view->GetTabHeight() + tabInc; - int right = left + m_view->GetViewRect().width; - int bottom = top + m_view->GetViewRect().height; - - if (m_isSelected) - { - // TAB is selected - draw TAB and the View's full outline - - dc.SetPen(*(m_view->GetHighlightPen())); - wxPoint pnts[10]; - int n = 0; - pnts[n].x = left; pnts[n++].y = bottom; - pnts[n].x = left; pnts[n++].y = top; - pnts[n].x = tabLeft; pnts[n++].y = top; - pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; - pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; - pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; - dc.DrawLines(n, pnts); - if (!lastInRow) - { - dc.DrawLine( - (tabRight + 2), - top, - right, - top - ); - } - - dc.SetPen(*(m_view->GetShadowPen())); - dc.DrawLine( - tabRight, - tabTop + 2, - tabRight, - top - ); - dc.DrawLine( - right, - top, - right, - bottom - ); - dc.DrawLine( - right, - bottom, - left, - bottom - ); - - dc.SetPen(*wxBLACK_PEN); - dc.DrawPoint( - tabRight, - tabTop + 1 - ); - dc.DrawPoint( - tabRight + 1, - tabTop + 2 - ); - if (lastInRow) - { - dc.DrawLine( - tabRight + 1, - bottom, - tabRight + 1, - tabTop + 1 - ); - } - else - { - dc.DrawLine( - tabRight + 1, - tabTop + 2, - tabRight + 1, - top - ); - dc.DrawLine( - right + 1, - top, - right + 1, - bottom + 1 - ); - } - dc.DrawLine( - right + 1, - bottom + 1, - left + 1, - bottom + 1 - ); - } - else - { - // TAB is not selected - just draw TAB outline and RH edge - // if the TAB is the last in the row - - int maxPositions = ((wxTabLayer*)m_view->GetLayers().Item(0)->GetData())->GetCount(); - wxTabControl* tabBelow = 0; - wxTabControl* tabBelowRight = 0; - if (GetColPosition() > 0) - { - tabBelow = m_view->FindTabControlForPosition( - GetColPosition() - 1, - GetRowPosition() - ); - } - if (!lastInRow && GetColPosition() > 0) - { - tabBelowRight = m_view->FindTabControlForPosition( - GetColPosition() - 1, - GetRowPosition() + 1 - ); - } - - float raisedTop = top - m_view->GetTabSelectionHeight() + - m_view->GetTabHeight(); - - dc.SetPen(*(m_view->GetHighlightPen())); - wxPoint pnts[10]; - int n = 0; - - pnts[n].x = tabLeft; - - if (tabBelow && tabBelow->IsSelected()) - { - pnts[n++].y = (long)raisedTop; - } - else - { - pnts[n++].y = top; - } - pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; - pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; - pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; - dc.DrawLines(n, pnts); - - dc.SetPen(*(m_view->GetShadowPen())); - if (GetRowPosition() >= maxPositions - 1) - { - dc.DrawLine( - tabRight, - (tabTop + 2), - tabRight, - bottom - ); - dc.DrawLine( - tabRight, - bottom, - (tabRight - m_view->GetHorizontalTabOffset()), - bottom - ); - } - else - { - if (tabBelowRight && tabBelowRight->IsSelected()) - { - dc.DrawLine( - tabRight, - (long)raisedTop, - tabRight, - tabTop + 1 - ); - } - else - { - dc.DrawLine( - tabRight, - top - 1, - tabRight, - tabTop + 1 - ); - } - } - - dc.SetPen(*wxBLACK_PEN); - dc.DrawPoint( - tabRight, - tabTop + 1 - ); - dc.DrawPoint( - tabRight + 1, - tabTop + 2 - ); - if (GetRowPosition() >= maxPositions - 1) - { - // draw right hand edge to bottom of view - dc.DrawLine( - tabRight + 1, - bottom + 1, - tabRight + 1, - tabTop + 2 - ); - dc.DrawLine( - tabRight + 1, - bottom + 1, - (tabRight - m_view->GetHorizontalTabOffset()), - bottom + 1 - ); - } - else - { - // draw right hand edge of TAB - if (tabBelowRight && tabBelowRight->IsSelected()) - { - dc.DrawLine( - tabRight + 1, - (long)(raisedTop - 1), - tabRight + 1, - tabTop + 2 - ); - } - else - { - dc.DrawLine( - tabRight + 1, - top - 1, - tabRight + 1, - tabTop + 2 - ); - } - } - } - - // Draw centered text - dc.SetPen(*wxBLACK_PEN); - if (m_isSelected) - { - dc.SetFont(*(m_view->GetSelectedTabFont())); - } - else - { - dc.SetFont(*(GetFont())); - } - - wxColour col(m_view->GetTextColour()); - dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); - long textWidth, textHeight; - dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); - - float textX = (tabLeft + tabRight - textWidth) / 2; - float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); - - dc.DrawText(GetLabel(), (long)textX, (long)textY); -#endif -} - -bool wxTabControl::HitTest(int x, int y) const -{ - // Top-left of tab control - int tabX1 = GetX() + m_view->GetViewRect().x; - int tabY1 = GetY() + m_view->GetViewRect().y; - - // Bottom-right - int tabX2 = tabX1 + GetWidth(); - int tabY2 = tabY1 + GetHeight(); - - if (x >= tabX1 && y >= tabY1 && x <= tabX2 && y <= tabY2) - return true; - else - return false; -} - -IMPLEMENT_DYNAMIC_CLASS(wxTabView, wxObject) - -wxTabView::wxTabView(long style) -{ - m_noTabs = 0; - m_tabStyle = style; - m_tabSelection = -1; - m_tabHeight = 20; - m_tabSelectionHeight = m_tabHeight + 2; - m_tabWidth = 80; - m_tabHorizontalOffset = 10; - m_tabHorizontalSpacing = 2; - m_tabVerticalTextSpacing = 3; - m_topMargin = 5; - m_tabViewRect.x = 20; - m_tabViewRect.y = 20; - m_tabViewRect.width = 300; - m_tabViewRect.x = 300; - m_highlightColour = *wxWHITE; - m_shadowColour = wxColour(128, 128, 128); - // m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); - m_textColour = *wxBLACK; - m_highlightPen = wxWHITE_PEN; - m_shadowPen = wxGREY_PEN; - // SetBackgroundColour(m_backgroundColour); - m_tabFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - m_tabSelectedFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - m_window = NULL; -} - -wxTabView::~wxTabView() -{ - ClearTabs(true); -} - -// Automatically positions tabs -// TODO: this should just add the tab to a list, and then -// a layout function (e.g. Realize) should be called when all tabs have been added. -// The view rect could easily change as the view window is resized. -wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *existingTab) -{ - // First, find which layer we should be adding to. - wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); - if (!node) - { - wxTabLayer *newLayer = new wxTabLayer; - node = m_layers.Append(newLayer); - } - // Check if adding another tab control would go off the - // right-hand edge of the layer. - wxTabLayer *tabLayer = (wxTabLayer *)node->GetData(); - wxList::compatibility_iterator lastTabNode = tabLayer->GetLast(); - if (lastTabNode) - { - wxTabControl *lastTab = (wxTabControl *)lastTabNode->GetData(); - // Start another layer (row). - // Tricky choice: can't just check if will be overlapping the edge, because - // this happens anyway for 2nd and subsequent rows. - // Should check this for 1st row, and then subsequent rows should not exceed 1st - // in length. - if (((tabLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) - > GetViewRect().width)) || - ((tabLayer != m_layers.GetFirst()->GetData()) && (tabLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) - { - tabLayer = new wxTabLayer; - m_layers.Append(tabLayer); - lastTabNode = wxList::compatibility_iterator(); - } - } - int layer = m_layers.GetCount() - 1; - - wxTabControl *tabControl = existingTab; - if (!existingTab) - tabControl = OnCreateTabControl(); - tabControl->SetRowPosition(tabLayer->GetCount()); - tabControl->SetColPosition(layer); - - wxTabControl *lastTab = NULL; - if (lastTabNode) - lastTab = (wxTabControl *)lastTabNode->GetData(); - - // Top of new tab - int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); - // Offset from view top-left - int horizontalOffset = 0; - if (!lastTab) - horizontalOffset = layer*GetHorizontalTabOffset(); - else - horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); - - tabControl->SetPosition(horizontalOffset, verticalOffset); - tabControl->SetSize(GetTabWidth(), GetTabHeight()); - tabControl->SetId(id); - tabControl->SetLabel(label); - tabControl->SetFont(* GetTabFont()); - - tabLayer->Append(tabControl); - m_noTabs ++; - - return tabControl; -} - -// Remove the tab without deleting the window -bool wxTabView::RemoveTab(int id) -{ - wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); - while (layerNode) - { - wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); - wxList::compatibility_iterator tabNode = layer->GetFirst(); - while (tabNode) - { - wxTabControl *tab = (wxTabControl *)tabNode->GetData(); - if (tab->GetId() == id) - { - if (id == m_tabSelection) - m_tabSelection = -1; - delete tab; - layer->Erase(tabNode); - m_noTabs --; - - // The layout has changed - LayoutTabs(); - return true; - } - tabNode = tabNode->GetNext(); - } - layerNode = layerNode->GetNext(); - } - return false; -} - -bool wxTabView::SetTabText(int id, const wxString& label) -{ - wxTabControl* control = FindTabControlForId(id); - if (!control) - return false; - control->SetLabel(label); - return true; -} - -wxString wxTabView::GetTabText(int id) const -{ - wxTabControl* control = FindTabControlForId(id); - if (!control) - return wxEmptyString; - else - return control->GetLabel(); -} - -// Returns the total height of the tabs component -- this may be several -// times the height of a tab, if there are several tab layers (rows). -int wxTabView::GetTotalTabHeight() -{ - int minY = 0; - - wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); - while (layerNode) - { - wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); - wxList::compatibility_iterator tabNode = layer->GetFirst(); - while (tabNode) - { - wxTabControl *tab = (wxTabControl *)tabNode->GetData(); - - if (tab->GetY() < minY) - minY = tab->GetY(); - - tabNode = tabNode->GetNext(); - } - layerNode = layerNode->GetNext(); - } - - return - minY; -} - -void wxTabView::ClearTabs(bool deleteTabs) -{ - wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); - while (layerNode) - { - wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); - wxList::compatibility_iterator tabNode = layer->GetFirst(); - while (tabNode) - { - wxTabControl *tab = (wxTabControl *)tabNode->GetData(); - if (deleteTabs) - delete tab; - wxList::compatibility_iterator next = tabNode->GetNext(); - layer->Erase(tabNode); - tabNode = next; - } - wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext(); - delete layer; - m_layers.Erase(layerNode); - layerNode = nextLayerNode; - } - m_noTabs = 0; - m_tabSelection = -1; -} - - -// Layout tabs (optional, e.g. if resizing window) -void wxTabView::LayoutTabs(void) -{ - // Make a list of the tab controls, deleting the wxTabLayers. - wxList controls; - - wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); - while (layerNode) - { - wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); - wxList::compatibility_iterator tabNode = layer->GetFirst(); - while (tabNode) - { - wxTabControl *tab = (wxTabControl *)tabNode->GetData(); - controls.Append(tab); - wxList::compatibility_iterator next = tabNode->GetNext(); - layer->Erase(tabNode); - tabNode = next; - } - wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext(); - delete layer; - m_layers.Erase(layerNode); - layerNode = nextLayerNode; - } - - wxTabControl *lastTab = NULL; - - wxTabLayer *currentLayer = new wxTabLayer; - m_layers.Append(currentLayer); - - wxList::compatibility_iterator node = controls.GetFirst(); - while (node) - { - wxTabControl *tabControl = (wxTabControl *)node->GetData(); - if (lastTab) - { - // Start another layer (row). - // Tricky choice: can't just check if will be overlapping the edge, because - // this happens anyway for 2nd and subsequent rows. - // Should check this for 1st row, and then subsequent rows should not exceed 1st - // in length. - if (((currentLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) - > GetViewRect().width)) || - ((currentLayer != m_layers.GetFirst()->GetData()) && (currentLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) - { - currentLayer = new wxTabLayer; - m_layers.Append(currentLayer); - lastTab = NULL; - } - } - - int layer = m_layers.GetCount() - 1; - - tabControl->SetRowPosition(currentLayer->GetCount()); - tabControl->SetColPosition(layer); - - // Top of new tab - int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); - // Offset from view top-left - int horizontalOffset = 0; - if (!lastTab) - horizontalOffset = layer*GetHorizontalTabOffset(); - else - horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); - - tabControl->SetPosition(horizontalOffset, verticalOffset); - tabControl->SetSize(GetTabWidth(), GetTabHeight()); - - currentLayer->Append(tabControl); - lastTab = tabControl; - - node = node->GetNext(); - } - - // Move the selected tab to the bottom - wxTabControl *control = FindTabControlForId(m_tabSelection); - if (control) - MoveSelectionTab(control); - -} - -// Draw all tabs -void wxTabView::Draw(wxDC& dc) -{ - // Don't draw anything if there are no tabs. - if (GetNumberOfTabs() == 0) - return; - - // Draw top margin area (beneath tabs and above view area) - if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) - { - dc.SetPen(*wxTRANSPARENT_PEN); - if(GetBackgroundBrush()) - dc.SetBrush(*GetBackgroundBrush()); - - // Add 1 because the pen is transparent. Under Motif, may be different. - dc.DrawRectangle( - m_tabViewRect.x, - (m_tabViewRect.y - m_topMargin), - (m_tabViewRect.width + 1), - (m_topMargin + 1) - ); - } - - // Draw layers in reverse order - wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); - while (node) - { - wxTabLayer *layer = (wxTabLayer *)node->GetData(); - wxList::compatibility_iterator node2 = layer->GetFirst(); - while (node2) - { - wxTabControl *control = (wxTabControl *)node2->GetData(); - control->OnDraw(dc, (!node2->GetNext())); - node2 = node2->GetNext(); - } - - node = node->GetPrevious(); - } - - -#ifndef wxUSE_NEW_METHOD - if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX) - { - dc.SetPen(* GetShadowPen()); - - // Draw bottom line - dc.DrawLine( - (GetViewRect().x + 1), - (GetViewRect().y + GetViewRect().height), - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y + GetViewRect().height) - ); - - // Draw right line - dc.DrawLine( - (GetViewRect().x + GetViewRect().width), - (GetViewRect().y - GetTopMargin() + 1), - (GetViewRect().x + GetViewRect().width), - (GetViewRect().y + GetViewRect().height) - ); - - dc.SetPen(* wxBLACK_PEN); - - // Draw bottom line - dc.DrawLine( - (GetViewRect().x), - (GetViewRect().y + GetViewRect().height + 1), -#if defined(__WXMOTIF__) - (GetViewRect().x + GetViewRect().width + 1), -#else - (GetViewRect().x + GetViewRect().width + 2), -#endif - - (GetViewRect().y + GetViewRect().height + 1) - ); - - // Draw right line - dc.DrawLine( - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y - GetTopMargin()), - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y + GetViewRect().height + 1) - ); - } -#endif -} - -// Process mouse event, return false if we didn't process it -bool wxTabView::OnEvent(wxMouseEvent& event) -{ - if (!event.LeftDown()) - return false; - - wxCoord x, y; - event.GetPosition(&x, &y); - - wxTabControl *hitControl = NULL; - - wxTabLayerList::compatibility_iterator node = m_layers.GetFirst(); - while (node) - { - wxTabLayer *layer = (wxTabLayer *)node->GetData(); - wxList::compatibility_iterator node2 = layer->GetFirst(); - while (node2) - { - wxTabControl *control = (wxTabControl *)node2->GetData(); - if (control->HitTest((int)x, (int)y)) - { - hitControl = control; - node = wxTabLayerList::compatibility_iterator(); - node2 = wxList::compatibility_iterator(); - } - else - node2 = node2->GetNext(); - } - - if (node) - node = node->GetNext(); - } - - if (!hitControl) - return false; - - wxTabControl *currentTab = FindTabControlForId(m_tabSelection); - - if (hitControl == currentTab) - return false; - - ChangeTab(hitControl); - - return true; -} - -bool wxTabView::ChangeTab(wxTabControl *control) -{ - wxTabControl *currentTab = FindTabControlForId(m_tabSelection); - int oldTab = -1; - if (currentTab) - oldTab = currentTab->GetId(); - - if (control == currentTab) - return true; - - if (m_layers.GetCount() == 0) - return false; - - if (!OnTabPreActivate(control->GetId(), oldTab)) - return false; - - // Move the tab to the bottom - MoveSelectionTab(control); - - if (currentTab) - currentTab->SetSelected(false); - - control->SetSelected(true); - m_tabSelection = control->GetId(); - - OnTabActivate(control->GetId(), oldTab); - - // Leave window refresh for the implementing window - - return true; -} - -// Move the selected tab to the bottom layer, if necessary, -// without calling app activation code -bool wxTabView::MoveSelectionTab(wxTabControl *control) -{ - if (m_layers.GetCount() == 0) - return false; - - wxTabLayer *firstLayer = (wxTabLayer *)m_layers.GetFirst()->GetData(); - - // Find what column this tab is at, so we can swap with the one at the bottom. - // If we're on the bottom layer, then no need to swap. - if (!firstLayer->Member(control)) - { - // Do a swap - int col = 0; - wxList::compatibility_iterator thisNode = FindTabNodeAndColumn(control, &col); - if (!thisNode) - return false; - wxList::compatibility_iterator otherNode = firstLayer->Item(col); - if (!otherNode) - return false; - - // If this is already in the bottom layer, return now - if (otherNode == thisNode) - return true; - - wxTabControl *otherTab = (wxTabControl *)otherNode->GetData(); - - // We now have pointers to the tab to be changed to, - // and the tab on the first layer. Swap tab structures and - // position details. - - int thisX = control->GetX(); - int thisY = control->GetY(); - int thisColPos = control->GetColPosition(); - int otherX = otherTab->GetX(); - int otherY = otherTab->GetY(); - int otherColPos = otherTab->GetColPosition(); - - control->SetPosition(otherX, otherY); - control->SetColPosition(otherColPos); - otherTab->SetPosition(thisX, thisY); - otherTab->SetColPosition(thisColPos); - - // Swap the data for the nodes - thisNode->SetData(otherTab); - otherNode->SetData(control); - } - return true; -} - -// Called when a tab is activated -void wxTabView::OnTabActivate(int /*activateId*/, int /*deactivateId*/) -{ -} - -void wxTabView::SetHighlightColour(const wxColour& col) -{ - m_highlightColour = col; - m_highlightPen = wxThePenList->FindOrCreatePen(col); -} - -void wxTabView::SetShadowColour(const wxColour& col) -{ - m_shadowColour = col; - m_shadowPen = wxThePenList->FindOrCreatePen(col); -} - -void wxTabView::SetBackgroundColour(const wxColour& col) -{ - m_backgroundColour = col; - m_backgroundPen = wxThePenList->FindOrCreatePen(col); - m_backgroundBrush = wxTheBrushList->FindOrCreateBrush(col); -} - -// this may be called with sel = zero (which doesn't match any page) -// when wxMotif deletes a page -// so return the first tab... - -void wxTabView::SetTabSelection(int sel, bool activateTool) -{ - if ( sel==m_tabSelection ) - return; - - int oldSel = m_tabSelection; - wxTabControl *control = FindTabControlForId(sel); - if (sel == 0) sel=control->GetId(); - wxTabControl *oldControl = FindTabControlForId(m_tabSelection); - - if (!OnTabPreActivate(sel, oldSel)) - return; - - if (control) - control->SetSelected((sel != -1)); // TODO ?? - else if (sel != -1) - { - wxFAIL_MSG(_("Could not find tab for id")); - return; - } - - if (oldControl) - oldControl->SetSelected(false); - - m_tabSelection = sel; - - if (control) - MoveSelectionTab(control); - - if (activateTool) - OnTabActivate(sel, oldSel); -} - -// Find tab control for id -// this may be called with zero (which doesn't match any page) -// so return the first control... -wxTabControl *wxTabView::FindTabControlForId(int id) const -{ - wxTabLayerList::compatibility_iterator node1 = m_layers.GetFirst(); - while (node1) - { - wxTabLayer *layer = (wxTabLayer *)node1->GetData(); - wxList::compatibility_iterator node2 = layer->GetFirst(); - while (node2) - { - wxTabControl *control = (wxTabControl *)node2->GetData(); - if (control->GetId() == id || id == 0) - return control; - node2 = node2->GetNext(); - } - node1 = node1->GetNext(); - } - return NULL; -} - -// Find tab control for layer, position (starting from zero) -wxTabControl *wxTabView::FindTabControlForPosition(int layer, int position) const -{ - wxTabLayerList::compatibility_iterator node1 = m_layers.Item(layer); - if (!node1) - return NULL; - wxTabLayer *tabLayer = (wxTabLayer *)node1->GetData(); - wxList::compatibility_iterator node2 = tabLayer->Item(position); - if (!node2) - return NULL; - return (wxTabControl *)node2->GetData(); -} - -// Find the node and the column at which this control is positioned. -wxList::compatibility_iterator wxTabView::FindTabNodeAndColumn(wxTabControl *control, int *col) const -{ - wxTabLayerList::compatibility_iterator node1 = m_layers.GetFirst(); - while (node1) - { - wxTabLayer *layer = (wxTabLayer *)node1->GetData(); - int c = 0; - wxList::compatibility_iterator node2 = layer->GetFirst(); - while (node2) - { - wxTabControl *cnt = (wxTabControl *)node2->GetData(); - if (cnt == control) - { - *col = c; - return node2; - } - node2 = node2->GetNext(); - c ++; - } - node1 = node1->GetNext(); - } - return wxList::compatibility_iterator(); -} - -int wxTabView::CalculateTabWidth(int noTabs, bool adjustView) -{ - m_tabWidth = (int)((m_tabViewRect.width - ((noTabs - 1)*GetHorizontalTabSpacing()))/noTabs); - if (adjustView) - { - m_tabViewRect.width = noTabs*m_tabWidth + ((noTabs-1)*GetHorizontalTabSpacing()); - } - return m_tabWidth; -} - -/* - * wxTabbedDialog - */ - -IMPLEMENT_CLASS(wxTabbedDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxTabbedDialog, wxDialog) - EVT_CLOSE(wxTabbedDialog::OnCloseWindow) - EVT_MOUSE_EVENTS(wxTabbedDialog::OnMouseEvent) - EVT_PAINT(wxTabbedDialog::OnPaint) -END_EVENT_TABLE() - -wxTabbedDialog::wxTabbedDialog(wxWindow *parent, wxWindowID id, - const wxString& title, - const wxPoint& pos, const wxSize& size, - long windowStyle, const wxString& name): - wxDialog(parent, id, title, pos, size, windowStyle, name) -{ - m_tabView = NULL; -} - -wxTabbedDialog::~wxTabbedDialog(void) -{ - if (m_tabView) - delete m_tabView; -} - -void wxTabbedDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) ) -{ - Destroy(); -} - -void wxTabbedDialog::OnMouseEvent(wxMouseEvent& event ) -{ - if (m_tabView) - m_tabView->OnEvent(event); -} - -void wxTabbedDialog::OnPaint(wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - if (m_tabView) - m_tabView->Draw(dc); -} - -/* - * wxTabbedPanel - */ - -IMPLEMENT_CLASS(wxTabbedPanel, wxPanel) - -BEGIN_EVENT_TABLE(wxTabbedPanel, wxPanel) - EVT_MOUSE_EVENTS(wxTabbedPanel::OnMouseEvent) - EVT_PAINT(wxTabbedPanel::OnPaint) -END_EVENT_TABLE() - -wxTabbedPanel::wxTabbedPanel(wxWindow *parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long windowStyle, const wxString& name): - wxPanel(parent, id, pos, size, windowStyle, name) -{ - m_tabView = NULL; -} - -wxTabbedPanel::~wxTabbedPanel(void) -{ - delete m_tabView; -} - -void wxTabbedPanel::OnMouseEvent(wxMouseEvent& event) -{ - if (m_tabView) - m_tabView->OnEvent(event); -} - -void wxTabbedPanel::OnPaint(wxPaintEvent& WXUNUSED(event) ) -{ - wxPaintDC dc(this); - if (m_tabView) - m_tabView->Draw(dc); -} - -/* - * wxPanelTabView - */ - -IMPLEMENT_CLASS(wxPanelTabView, wxTabView) - -wxPanelTabView::wxPanelTabView(wxPanel *pan, long style) - : wxTabView(style) -{ - m_panel = pan; - m_currentWindow = NULL; - - if (m_panel->IsKindOf(wxCLASSINFO(wxTabbedDialog))) - ((wxTabbedDialog *)m_panel)->SetTabView(this); - else if (m_panel->IsKindOf(wxCLASSINFO(wxTabbedPanel))) - ((wxTabbedPanel *)m_panel)->SetTabView(this); - - SetWindow(m_panel); -} - -wxPanelTabView::~wxPanelTabView(void) -{ - ClearWindows(true); -} - -// Called when a tab is activated -void wxPanelTabView::OnTabActivate(int activateId, int deactivateId) -{ - if (!m_panel) - return; - - wxWindow *oldWindow = ((deactivateId == -1) ? 0 : GetTabWindow(deactivateId)); - wxWindow *newWindow = GetTabWindow(activateId); - - if (oldWindow) - oldWindow->Show(false); - if (newWindow) - newWindow->Show(true); - - m_panel->Refresh(); -} - - -void wxPanelTabView::AddTabWindow(int id, wxWindow *window) -{ - wxASSERT(m_tabWindows.find(id) == m_tabWindows.end()); - m_tabWindows[id] = window; - window->Show(false); -} - -wxWindow *wxPanelTabView::GetTabWindow(int id) const -{ - wxIntToWindowHashMap::const_iterator it = m_tabWindows.find(id); - return it == m_tabWindows.end() ? NULL : it->second; -} - -void wxPanelTabView::ClearWindows(bool deleteWindows) -{ - if (deleteWindows) - WX_CLEAR_HASH_MAP(wxIntToWindowHashMap, m_tabWindows); - m_tabWindows.clear(); -} - -void wxPanelTabView::ShowWindowForTab(int id) -{ - wxWindow *newWindow = GetTabWindow(id); - if (newWindow == m_currentWindow) - return; - if (m_currentWindow) - m_currentWindow->Show(false); - newWindow->Show(true); - newWindow->Refresh(); -} - diff --git a/Source/3rd Party/wx/src/generic/textdlgg.cpp b/Source/3rd Party/wx/src/generic/textdlgg.cpp index 481b2b8bb..f1c8aa64b 100644 --- a/Source/3rd Party/wx/src/generic/textdlgg.cpp +++ b/Source/3rd Party/wx/src/generic/textdlgg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: textdlgg.cpp 41838 2006-10-09 21:08:45Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -41,8 +42,8 @@ #include "wx/statline.h" #endif -const char wxGetTextFromUserPromptStr[] = "Input Text"; -const char wxGetPasswordFromUserPromptStr[] = "Enter Password"; +const wxChar wxGetTextFromUserPromptStr[] = wxT("Input Text"); +const wxChar wxGetPasswordFromUserPromptStr[] = wxT("Enter Password"); // ---------------------------------------------------------------------------- // constants @@ -64,21 +65,16 @@ END_EVENT_TABLE() IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog) -bool wxTextEntryDialog::Create(wxWindow *parent, +wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption, const wxString& value, long style, const wxPoint& pos) + : wxDialog(parent, wxID_ANY, caption, pos, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE), + m_value(value) { - if ( !wxDialog::Create(GetParentForModalDialog(parent, style), - wxID_ANY, caption, - pos, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) ) - { - return false; - } - m_dialogStyle = style; m_value = value; @@ -104,8 +100,13 @@ bool wxTextEntryDialog::Create(wxWindow *parent, Expand(). TripleBorder(wxLEFT | wxRIGHT)); +#if wxUSE_VALIDATORS + wxTextValidator validator( wxFILTER_NONE, &m_value ); + m_textctrl->SetValidator( validator ); +#endif // wxUSE_VALIDATORS + // 3) buttons if any - wxSizer *buttonSizer = CreateSeparatedButtonSizer(style & (wxOK | wxCANCEL)); + wxSizer *buttonSizer = CreateSeparatedButtonSizer(style & ButtonSizerFlags); if ( buttonSizer ) { topsizer->Add(buttonSizer, wxSizerFlags(flagsBorder2).Expand()); @@ -120,39 +121,25 @@ bool wxTextEntryDialog::Create(wxWindow *parent, if ( style & wxCENTRE ) Centre( wxBOTH ); - m_textctrl->SelectAll(); + m_textctrl->SetSelection(-1, -1); m_textctrl->SetFocus(); wxEndBusyCursor(); - - return true; -} - -bool wxTextEntryDialog::TransferDataToWindow() -{ - m_textctrl->SetValue(m_value); - - return wxDialog::TransferDataToWindow(); -} - -bool wxTextEntryDialog::TransferDataFromWindow() -{ - m_value = m_textctrl->GetValue(); - - return wxDialog::TransferDataFromWindow(); } void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) { - if ( Validate() && TransferDataFromWindow() ) +#if wxUSE_VALIDATORS + if( Validate() && TransferDataFromWindow() ) { EndModal( wxID_OK ); } -} +#else + m_value = m_textctrl->GetValue(); -void wxTextEntryDialog::SetMaxLength(unsigned long len) -{ - m_textctrl->SetMaxLength(len); + EndModal(wxID_OK); +#endif + // wxUSE_VALIDATORS } void wxTextEntryDialog::SetValue(const wxString& val) @@ -163,17 +150,10 @@ void wxTextEntryDialog::SetValue(const wxString& val) } #if wxUSE_VALIDATORS - -#if WXWIN_COMPATIBILITY_2_8 void wxTextEntryDialog::SetTextValidator( long style ) { - SetTextValidator((wxTextValidatorStyle)style); -} -#endif - -void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style ) -{ - SetTextValidator(wxTextValidator(style)); + wxTextValidator validator( style, &m_value ); + m_textctrl->SetValidator( validator ); } void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator ) @@ -181,7 +161,8 @@ void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator ) m_textctrl->SetValidator( validator ); } -#endif // wxUSE_VALIDATORS +#endif + // wxUSE_VALIDATORS // ---------------------------------------------------------------------------- // wxPasswordEntryDialog diff --git a/Source/3rd Party/wx/src/generic/textmeasure.cpp b/Source/3rd Party/wx/src/generic/textmeasure.cpp deleted file mode 100644 index 55bb735d9..000000000 --- a/Source/3rd Party/wx/src/generic/textmeasure.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/textmeasure.cpp -// Purpose: -// Author: Vadim Zeitlin -// Created: 2012-10-17 -// Copyright: (c) 2012 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/dc.h" -#endif //WX_PRECOMP - -#include "wx/private/textmeasure.h" - -#if wxUSE_GENERIC_TEXTMEASURE - -// ============================================================================ -// wxTextMeasure generic implementation -// ============================================================================ - -// We assume that the ports not providing platform-specific wxTextMeasure -// implementation implement the corresponding functions in their wxDC and -// wxWindow classes, so forward back to them instead of using wxTextMeasure -// from there, as usual. -void wxTextMeasure::DoGetTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *descent, - wxCoord *externalLeading) -{ - if ( m_dc ) - { - m_dc->GetTextExtent(string, width, height, - descent, externalLeading, m_font); - } - else if ( m_win ) - { - m_win->GetTextExtent(string, width, height, - descent, externalLeading, m_font); - } - //else: we already asserted in the ctor, don't do it any more -} - -bool wxTextMeasure::DoGetPartialTextExtents(const wxString& text, - wxArrayInt& widths, - double scaleX) -{ - return wxTextMeasureBase::DoGetPartialTextExtents(text, widths, scaleX); -} - -#endif // wxUSE_GENERIC_TEXTMEASURE diff --git a/Source/3rd Party/wx/src/generic/timectrlg.cpp b/Source/3rd Party/wx/src/generic/timectrlg.cpp deleted file mode 100644 index 71867c2f3..000000000 --- a/Source/3rd Party/wx/src/generic/timectrlg.cpp +++ /dev/null @@ -1,679 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/timectrl.cpp -// Purpose: Generic implementation of wxTimePickerCtrl. -// Author: Paul Breen, Vadim Zeitlin -// Created: 2011-09-22 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_TIMEPICKCTRL - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" -#endif // WX_PRECOMP - -#include "wx/timectrl.h" - -// This class is only compiled if there is no native version or if we -// explicitly want to use both the native and generic one (this is useful for -// testing but not much otherwise and so by default we don't use the generic -// implementation if a native one is available). -#if !defined(wxHAS_NATIVE_TIMEPICKERCTRL) || wxUSE_TIMEPICKCTRL_GENERIC - -#include "wx/generic/timectrl.h" - -#include "wx/dateevt.h" -#include "wx/spinbutt.h" - -#ifndef wxHAS_NATIVE_TIMEPICKERCTRL - IMPLEMENT_DYNAMIC_CLASS(wxTimePickerCtrl, wxControl) -#endif - -// ---------------------------------------------------------------------------- -// Constants -// ---------------------------------------------------------------------------- - -enum -{ - // Horizontal margin between the text and spin control. - HMARGIN_TEXT_SPIN = 2 -}; - -// ---------------------------------------------------------------------------- -// wxTimePickerGenericImpl: used to implement wxTimePickerCtrlGeneric -// ---------------------------------------------------------------------------- - -class wxTimePickerGenericImpl : public wxEvtHandler -{ -public: - wxTimePickerGenericImpl(wxTimePickerCtrlGeneric* ctrl) - { - m_text = new wxTextCtrl(ctrl, wxID_ANY, wxString()); - - // As this text can't be edited, don't use the standard cursor for it - // to avoid misleading the user. Ideally we'd also hide the caret but - // this is not currently supported by wxTextCtrl. - m_text->SetCursor(wxCURSOR_ARROW); - - m_btn = new wxSpinButton(ctrl, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - wxSP_VERTICAL | wxSP_WRAP); - - m_currentField = Field_Hour; - m_isFirstDigit = true; - - // We don't support arbitrary formats currently as this requires - // significantly more work both here and also in wxLocale::GetInfo(). - // - // For now just use either "%H:%M:%S" or "%I:%M:%S %p". It would be - // nice to add support to "%k" and "%l" (hours with leading blanks - // instead of zeros) too as this is the most common unsupported case in - // practice. - m_useAMPM = wxLocale::GetInfo(wxLOCALE_TIME_FMT).Contains("%p"); - - m_text->Connect - ( - wxEVT_SET_FOCUS, - wxFocusEventHandler(wxTimePickerGenericImpl::OnTextSetFocus), - NULL, - this - ); - m_text->Connect - ( - wxEVT_KEY_DOWN, - wxKeyEventHandler(wxTimePickerGenericImpl::OnTextKeyDown), - NULL, - this - ); - m_text->Connect - ( - wxEVT_LEFT_DOWN, - wxMouseEventHandler(wxTimePickerGenericImpl::OnTextClick), - NULL, - this - ); - - m_btn->Connect - ( - wxEVT_SPIN_UP, - wxSpinEventHandler(wxTimePickerGenericImpl::OnArrowUp), - NULL, - this - ); - m_btn->Connect - ( - wxEVT_SPIN_DOWN, - wxSpinEventHandler(wxTimePickerGenericImpl::OnArrowDown), - NULL, - this - ); - } - - // Set the new value. - void SetValue(const wxDateTime& time) - { - m_time = time.IsValid() ? time : wxDateTime::Now(); - - // Ensure that the date part doesn't correspond to a DST change date as - // time is discontinuous then resulting in many problems, e.g. it's - // impossible to even enter 2:00:00 at the beginning of summer time - // date as this time doesn't exist. By using Jan 1, on which nobody - // changes DST, we avoid all such problems. - wxDateTime::Tm tm = m_time.GetTm(); - tm.mday = - tm.yday = 1; - tm.mon = wxDateTime::Jan; - m_time.Set(tm); - - UpdateTextWithoutEvent(); - } - - - // The text part of the control. - wxTextCtrl* m_text; - - // The spin button used to change the text fields. - wxSpinButton* m_btn; - - // The current time (date part is ignored). - wxDateTime m_time; - -private: - // The logical fields of the text control (AM/PM one may not be present). - enum Field - { - Field_Hour, - Field_Min, - Field_Sec, - Field_AMPM, - Field_Max - }; - - // Direction of change of time fields. - enum Direction - { - // Notice that the enum elements values matter. - Dir_Down = -1, - Dir_Up = +1 - }; - - // A range of character positions ("from" is inclusive, "to" -- exclusive). - struct CharRange - { - int from, - to; - }; - - // Event handlers for various events in our controls. - void OnTextSetFocus(wxFocusEvent& event) - { - HighlightCurrentField(); - - event.Skip(); - } - - // Keyboard interface here is modelled over MSW native control and may need - // adjustments for other platforms. - void OnTextKeyDown(wxKeyEvent& event) - { - const int key = event.GetKeyCode(); - - switch ( key ) - { - case WXK_DOWN: - ChangeCurrentFieldBy1(Dir_Down); - break; - - case WXK_UP: - ChangeCurrentFieldBy1(Dir_Up); - break; - - case WXK_LEFT: - CycleCurrentField(Dir_Down); - break; - - case WXK_RIGHT: - CycleCurrentField(Dir_Up); - break; - - case WXK_HOME: - ResetCurrentField(Dir_Down); - break; - - case WXK_END: - ResetCurrentField(Dir_Up); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - // The digits work in all keys except AM/PM. - if ( m_currentField != Field_AMPM ) - { - AppendDigitToCurrentField(key - '0'); - } - break; - - case 'A': - case 'P': - // These keys only work to toggle AM/PM field. - if ( m_currentField == Field_AMPM ) - { - unsigned hour = m_time.GetHour(); - if ( key == 'A' ) - { - if ( hour >= 12 ) - hour -= 12; - } - else // PM - { - if ( hour < 12 ) - hour += 12; - } - - if ( hour != m_time.GetHour() ) - { - m_time.SetHour(hour); - UpdateText(); - } - } - break; - - // Do not skip the other events, just consume them to prevent the - // user from editing the text directly. - } - } - - void OnTextClick(wxMouseEvent& event) - { - Field field = Field_Max; // Initialize just to suppress warnings. - long pos; - switch ( m_text->HitTest(event.GetPosition(), &pos) ) - { - case wxTE_HT_UNKNOWN: - // Don't do anything, it's better than doing something wrong. - return; - - case wxTE_HT_BEFORE: - // Select the first field. - field = Field_Hour; - break; - - case wxTE_HT_ON_TEXT: - // Find the field containing this position. - for ( field = Field_Hour; field <= GetLastField(); ) - { - const CharRange range = GetFieldRange(field); - - // Normally the "to" end is exclusive but we want to give - // focus to some field when the user clicks between them so - // count it as part of the preceding field here. - if ( range.from <= pos && pos <= range.to ) - break; - - field = static_cast(field + 1); - } - break; - - case wxTE_HT_BELOW: - // This shouldn't happen for single line control. - wxFAIL_MSG( "Unreachable" ); - // fall through - - case wxTE_HT_BEYOND: - // Select the last field. - field = GetLastField(); - break; - } - - ChangeCurrentField(field); - } - - void OnArrowUp(wxSpinEvent& WXUNUSED(event)) - { - ChangeCurrentFieldBy1(Dir_Up); - } - - void OnArrowDown(wxSpinEvent& WXUNUSED(event)) - { - ChangeCurrentFieldBy1(Dir_Down); - } - - - // Get the range of the given field in character positions ("from" is - // inclusive, "to" exclusive). - static CharRange GetFieldRange(Field field) - { - // Currently we can just hard code the ranges as they are the same for - // both supported formats, if we want to support arbitrary formats in - // the future, we'd need to determine them dynamically by examining the - // format here. - static const CharRange ranges[] = - { - { 0, 2 }, - { 3, 5 }, - { 6, 8 }, - { 9, 11}, - }; - - wxCOMPILE_TIME_ASSERT( WXSIZEOF(ranges) == Field_Max, - FieldRangesMismatch ); - - return ranges[field]; - } - - // Get the last field used depending on m_useAMPM. - Field GetLastField() const - { - return m_useAMPM ? Field_AMPM : Field_Sec; - } - - // Change the current field. For convenience, accept int field here as this - // allows us to use arithmetic operations in the caller. - void ChangeCurrentField(int field) - { - if ( field == m_currentField ) - return; - - wxCHECK_RET( field <= GetLastField(), "Invalid field" ); - - m_currentField = static_cast(field); - m_isFirstDigit = true; - - HighlightCurrentField(); - } - - // Go to the next (Dir_Up) or previous (Dir_Down) field, wrapping if - // necessary. - void CycleCurrentField(Direction dir) - { - const unsigned numFields = GetLastField() + 1; - - ChangeCurrentField((m_currentField + numFields + dir) % numFields); - } - - // Select the currently actively field. - void HighlightCurrentField() - { - m_text->SetFocus(); - - const CharRange range = GetFieldRange(m_currentField); - - m_text->SetSelection(range.from, range.to); - } - - // Decrement or increment the value of the current field (wrapping if - // necessary). - void ChangeCurrentFieldBy1(Direction dir) - { - switch ( m_currentField ) - { - case Field_Hour: - m_time.SetHour((m_time.GetHour() + 24 + dir) % 24); - break; - - case Field_Min: - m_time.SetMinute((m_time.GetMinute() + 60 + dir) % 60); - break; - - case Field_Sec: - m_time.SetSecond((m_time.GetSecond() + 60 + dir) % 60); - break; - - case Field_AMPM: - m_time.SetHour((m_time.GetHour() + 12) % 24); - break; - - case Field_Max: - wxFAIL_MSG( "Invalid field" ); - } - - UpdateText(); - } - - // Set the current field to its minimal or maximal value. - void ResetCurrentField(Direction dir) - { - switch ( m_currentField ) - { - case Field_Hour: - case Field_AMPM: - // In 12-hour mode setting the hour to the minimal value - // also changes the suffix to AM and, correspondingly, - // setting it to the maximal one changes the suffix to PM. - // And, for consistency with the native MSW behaviour, we - // also do the same thing when changing AM/PM field itself, - // so change hours in any case. - m_time.SetHour(dir == Dir_Down ? 0 : 23); - break; - - case Field_Min: - m_time.SetMinute(dir == Dir_Down ? 0 : 59); - break; - - case Field_Sec: - m_time.SetSecond(dir == Dir_Down ? 0 : 59); - break; - - case Field_Max: - wxFAIL_MSG( "Invalid field" ); - } - - UpdateText(); - } - - // Append the given digit (from 0 to 9) to the current value of the current - // field. - void AppendDigitToCurrentField(int n) - { - bool moveToNextField = false; - - if ( !m_isFirstDigit ) - { - // The first digit simply replaces the existing field contents, - // but the second one should be combined with the previous one, - // otherwise entering 2-digit numbers would be impossible. - int currentValue = 0, - maxValue = 0; - - switch ( m_currentField ) - { - case Field_Hour: - currentValue = m_time.GetHour(); - maxValue = 23; - break; - - case Field_Min: - currentValue = m_time.GetMinute(); - maxValue = 59; - break; - - case Field_Sec: - currentValue = m_time.GetSecond(); - maxValue = 59; - break; - - case Field_AMPM: - case Field_Max: - wxFAIL_MSG( "Invalid field" ); - return; - } - - // Check if the new value is acceptable. If not, we just handle - // this digit as if it were the first one. - int newValue = currentValue*10 + n; - if ( newValue < maxValue ) - { - n = newValue; - - // If we're not on the seconds field, advance to the next one. - // This makes it more convenient to enter times as you can just - // press all digits one after one without touching the cursor - // arrow keys at all. - // - // Notice that MSW native control doesn't do this but it seems - // so useful that we intentionally diverge from it here. - moveToNextField = true; - - // We entered both digits so the next one will be "first" again. - m_isFirstDigit = true; - } - } - else // First digit entered. - { - // The next one won't be first any more. - m_isFirstDigit = false; - } - - switch ( m_currentField ) - { - case Field_Hour: - m_time.SetHour(n); - break; - - case Field_Min: - m_time.SetMinute(n); - break; - - case Field_Sec: - m_time.SetSecond(n); - break; - - case Field_AMPM: - case Field_Max: - wxFAIL_MSG( "Invalid field" ); - } - - if ( moveToNextField && m_currentField < Field_Sec ) - CycleCurrentField(Dir_Up); - - UpdateText(); - } - - // Update the text value to correspond to the current time. By default also - // generate an event but this can be avoided by calling the "WithoutEvent" - // variant. - void UpdateText() - { - UpdateTextWithoutEvent(); - - wxWindow* const ctrl = m_text->GetParent(); - - wxDateEvent event(ctrl, m_time, wxEVT_TIME_CHANGED); - ctrl->HandleWindowEvent(event); - } - - void UpdateTextWithoutEvent() - { - m_text->SetValue(m_time.Format(m_useAMPM ? "%I:%M:%S %p" : "%H:%M:%S")); - - HighlightCurrentField(); - } - - - // The current field of the text control: this is the one affected by - // pressing arrow keys or spin button. - Field m_currentField; - - // Flag indicating whether we use AM/PM indicator or not. - bool m_useAMPM; - - // Flag indicating whether the next digit pressed by user will be the first - // digit of the current field or the second one. This is necessary because - // the first digit replaces the current field contents while the second one - // is appended to it (if possible, e.g. pressing '7' in a field already - // containing '8' will still replace it as "78" would be invalid). - bool m_isFirstDigit; - - wxDECLARE_NO_COPY_CLASS(wxTimePickerGenericImpl); -}; - -// ============================================================================ -// wxTimePickerCtrlGeneric implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxTimePickerCtrlGeneric creation -// ---------------------------------------------------------------------------- - -void wxTimePickerCtrlGeneric::Init() -{ - m_impl = NULL; -} - -bool -wxTimePickerCtrlGeneric::Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) -{ - // The text control we use already has a border, so we don't need one - // ourselves. - style &= ~wxBORDER_MASK; - style |= wxBORDER_NONE; - - if ( !Base::Create(parent, id, pos, size, style, validator, name) ) - return false; - - m_impl = new wxTimePickerGenericImpl(this); - m_impl->SetValue(date); - - InvalidateBestSize(); - SetInitialSize(size); - - return true; -} - -wxTimePickerCtrlGeneric::~wxTimePickerCtrlGeneric() -{ - delete m_impl; -} - -wxWindowList wxTimePickerCtrlGeneric::GetCompositeWindowParts() const -{ - wxWindowList parts; - if ( m_impl ) - { - parts.push_back(m_impl->m_text); - parts.push_back(m_impl->m_btn); - } - return parts; -} - -// ---------------------------------------------------------------------------- -// wxTimePickerCtrlGeneric value -// ---------------------------------------------------------------------------- - -void wxTimePickerCtrlGeneric::SetValue(const wxDateTime& date) -{ - wxCHECK_RET( m_impl, "Must create first" ); - - m_impl->SetValue(date); -} - -wxDateTime wxTimePickerCtrlGeneric::GetValue() const -{ - wxCHECK_MSG( m_impl, wxDateTime(), "Must create first" ); - - return m_impl->m_time; -} - -// ---------------------------------------------------------------------------- -// wxTimePickerCtrlGeneric geometry -// ---------------------------------------------------------------------------- - -void wxTimePickerCtrlGeneric::DoMoveWindow(int x, int y, int width, int height) -{ - Base::DoMoveWindow(x, y, width, height); - - if ( !m_impl ) - return; - - const int widthBtn = m_impl->m_btn->GetSize().x; - const int widthText = width - widthBtn - HMARGIN_TEXT_SPIN; - - m_impl->m_text->SetSize(0, 0, widthText, height); - m_impl->m_btn->SetSize(widthText + HMARGIN_TEXT_SPIN, 0, widthBtn, height); -} - -wxSize wxTimePickerCtrlGeneric::DoGetBestSize() const -{ - if ( !m_impl ) - return Base::DoGetBestSize(); - - wxSize size = m_impl->m_text->GetBestSize(); - size.x += m_impl->m_btn->GetBestSize().x + HMARGIN_TEXT_SPIN; - - return size; -} - -#endif // !wxHAS_NATIVE_TIMEPICKERCTRL || wxUSE_TIMEPICKCTRL_GENERIC - -#endif // wxUSE_TIMEPICKCTRL diff --git a/Source/3rd Party/wx/src/generic/timer.cpp b/Source/3rd Party/wx/src/generic/timer.cpp index a4dbf48e9..1fad2018b 100644 --- a/Source/3rd Party/wx/src/generic/timer.cpp +++ b/Source/3rd Party/wx/src/generic/timer.cpp @@ -2,6 +2,7 @@ // Name: src/generic/timer.cpp // Purpose: wxTimer implementation // Author: Vaclav Slavik +// Id: $Id: timer.cpp 40943 2006-08-31 19:31:43Z ABX $ // Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,34 +22,69 @@ #if wxUSE_TIMER +#include "wx/timer.h" + #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/module.h" #endif -#include "wx/apptrait.h" -#include "wx/generic/private/timer.h" - // ---------------------------------------------------------------------------- // Time input function // ---------------------------------------------------------------------------- -#define GetMillisecondsTime wxGetLocalTimeMillis +#ifdef __WXMGL__ + // We take advantage of wxMGL's _EVT_getTicks because it is faster + // (especially under MS-DOS!) and more precise than wxGetLocalTimeMillis + // if we are unlucky and the latter combines information from two sources. + #include "wx/mgl/private.h" + extern "C" ulong _EVT_getTicks(); + #define GetMillisecondsTime _EVT_getTicks -typedef wxLongLong wxTimerTick_t; + typedef ulong wxTimerTick_t; -#if wxUSE_LONGLONG_WX - #define wxTimerTickFmtSpec wxLongLongFmtSpec "d" - #define wxTimerTickPrintfArg(tt) (tt.GetValue()) -#else // using native wxLongLong - #define wxTimerTickFmtSpec wxT("s") - #define wxTimerTickPrintfArg(tt) (tt.ToString().c_str()) -#endif // wx/native long long + #define wxTimerTickFmtSpec _T("lu") + #define wxTimerTickPrintfArg(tt) (tt) -inline bool wxTickGreaterEqual(wxTimerTick_t x, wxTimerTick_t y) -{ - return x >= y; -} + #ifdef __DOS__ + // Under DOS the MGL timer has a 24hr period, so consider the 12 hours + // before y to be 'less' and the the 12 hours after 'greater' modulo + // 24 hours. + inline bool wxTickGreaterEqual(wxTimerTick_t x, wxTimerTick_t y) + { + // _EVT_getTicks wraps at 1573040 * 55 + const wxTimerTick_t modulus = 1573040 * 55; + return (2 * modulus + x - y) % modulus < modulus / 2; + } + #else + // If wxTimerTick_t is 32-bits then it'll wrap in around 50 days. So + // let the 25 days before y be 'less' and 25 days after be 'greater'. + inline bool wxTickGreaterEqual(wxTimerTick_t x, wxTimerTick_t y) + { + // This code assumes wxTimerTick_t is an unsigned type. + // Set half_modulus with top bit set and the rest zeros. + const wxTimerTick_t half_modulus = ~((~(wxTimerTick_t)0) >> 1); + return x - y < half_modulus; + } + #endif +#else // !__WXMGL__ + #define GetMillisecondsTime wxGetLocalTimeMillis + + typedef wxLongLong wxTimerTick_t; + + #if wxUSE_LONGLONG_WX + #define wxTimerTickFmtSpec wxLongLongFmtSpec _T("d") + #define wxTimerTickPrintfArg(tt) (tt.GetValue()) + #else // using native wxLongLong + #define wxTimerTickFmtSpec _T("s") + #define wxTimerTickPrintfArg(tt) (tt.ToString().c_str()) + #endif // wx/native long long + + inline bool wxTickGreaterEqual(wxTimerTick_t x, wxTimerTick_t y) + { + return x >= y; + } +#endif // __WXMGL__/!__WXMGL__ // ---------------------------------------------------------------------------- // helper structures and wxTimerScheduler @@ -57,15 +93,15 @@ inline bool wxTickGreaterEqual(wxTimerTick_t x, wxTimerTick_t y) class wxTimerDesc { public: - wxTimerDesc(wxGenericTimerImpl *t) : + wxTimerDesc(wxTimer *t) : timer(t), running(false), next(NULL), prev(NULL), shotTime(0), deleteFlag(NULL) {} - wxGenericTimerImpl *timer; - bool running; - wxTimerDesc *next, *prev; - wxTimerTick_t shotTime; - volatile bool *deleteFlag; // see comment in ~wxTimer + wxTimer *timer; + bool running; + wxTimerDesc *next, *prev; + wxTimerTick_t shotTime; + volatile bool *deleteFlag; // see comment in ~wxTimer }; class wxTimerScheduler @@ -171,16 +207,18 @@ void wxTimerScheduler::NotifyTimers() // wxTimer // ---------------------------------------------------------------------------- +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) + wxTimerScheduler *gs_scheduler = NULL; -void wxGenericTimerImpl::Init() +void wxTimer::Init() { if ( !gs_scheduler ) gs_scheduler = new wxTimerScheduler; m_desc = new wxTimerDesc(this); } -wxGenericTimerImpl::~wxGenericTimerImpl() +wxTimer::~wxTimer() { wxLogTrace( wxT("timer"), wxT("destroying timer %p..."), this); if ( IsRunning() ) @@ -197,31 +235,31 @@ wxGenericTimerImpl::~wxGenericTimerImpl() wxLogTrace( wxT("timer"), wxT(" ...done destroying timer %p..."), this); } -bool wxGenericTimerImpl::IsRunning() const +bool wxTimer::IsRunning() const { return m_desc->running; } -bool wxGenericTimerImpl::Start(int millisecs, bool oneShot) +bool wxTimer::Start(int millisecs, bool oneShot) { wxLogTrace( wxT("timer"), wxT("started timer %p: %i ms, oneshot=%i"), this, millisecs, oneShot); - if ( !wxTimerImpl::Start(millisecs, oneShot) ) - return false; + if ( !wxTimerBase::Start(millisecs, oneShot) ) + return false; gs_scheduler->QueueTimer(m_desc); return true; } -void wxGenericTimerImpl::Stop() +void wxTimer::Stop() { if ( !m_desc->running ) return; gs_scheduler->RemoveTimer(m_desc); } -/*static*/ void wxGenericTimerImpl::NotifyTimers() +/*static*/ void wxTimer::NotifyTimers() { if ( gs_scheduler ) gs_scheduler->NotifyTimers(); @@ -236,19 +274,10 @@ DECLARE_DYNAMIC_CLASS(wxTimerModule) public: wxTimerModule() {} bool OnInit() { return true; } - void OnExit() { wxDELETE(gs_scheduler); } + void OnExit() { delete gs_scheduler; gs_scheduler = NULL; } }; IMPLEMENT_DYNAMIC_CLASS(wxTimerModule, wxModule) -// ---------------------------------------------------------------------------- -// wxGUIAppTraits -// ---------------------------------------------------------------------------- - -wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) -{ - return new wxGenericTimerImpl(timer); -} - #endif //wxUSE_TIMER diff --git a/Source/3rd Party/wx/src/generic/tipdlg.cpp b/Source/3rd Party/wx/src/generic/tipdlg.cpp deleted file mode 100644 index 47d180962..000000000 --- a/Source/3rd Party/wx/src/generic/tipdlg.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/tipdlg.cpp -// Purpose: implementation of wxTipDialog -// Author: Vadim Zeitlin -// Modified by: -// Created: 28.06.99 -// Copyright: (c) Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_STARTUP_TIPS - -#ifndef WX_PRECOMP - #include "wx/button.h" - #include "wx/checkbox.h" - #include "wx/statbox.h" - #include "wx/dialog.h" - #include "wx/icon.h" - #include "wx/intl.h" - #include "wx/textctrl.h" - #include "wx/statbmp.h" - #include "wx/stattext.h" - #include "wx/sizer.h" - #include "wx/settings.h" -#endif // WX_PRECOMP - -#include "wx/statline.h" -#include "wx/artprov.h" - -#include "wx/tipdlg.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -static const int wxID_NEXT_TIP = 32000; // whatever - -// --------------------------------------------------------------------------- -// macros -// --------------------------------------------------------------------------- - -/* Macro for avoiding #ifdefs when value have to be different depending on size of - device we display on - take it from something like wxDesktopPolicy in the future - */ - -#if defined(__SMARTPHONE__) - #define wxLARGESMALL(large,small) small -#else - #define wxLARGESMALL(large,small) large -#endif - -// ---------------------------------------------------------------------------- -// private classes -// ---------------------------------------------------------------------------- - -// an implementation which takes the tips from the text file - each line -// represents a tip -#if wxUSE_TEXTFILE -class WXDLLIMPEXP_ADV wxFileTipProvider : public wxTipProvider -{ -public: - wxFileTipProvider(const wxString& filename, size_t currentTip); - - virtual wxString GetTip(); - -private: - wxTextFile m_textfile; - - wxDECLARE_NO_COPY_CLASS(wxFileTipProvider); -}; -#endif // wxUSE_TEXTFILE - -#ifdef __WIN32__ -// TODO an implementation which takes the tips from the given registry key -class WXDLLIMPEXP_ADV wxRegTipProvider : public wxTipProvider -{ -public: - wxRegTipProvider(const wxString& keyname); - - virtual wxString GetTip(); -}; - -// Empty implementation for now to keep the linker happy -wxString wxRegTipProvider::GetTip() -{ - return wxEmptyString; -} - -#endif // __WIN32__ - -// the dialog we show in wxShowTip() -class WXDLLIMPEXP_ADV wxTipDialog : public wxDialog -{ -public: - wxTipDialog(wxWindow *parent, - wxTipProvider *tipProvider, - bool showAtStartup); - - // the tip dialog has "Show tips on startup" checkbox - return true if it - // was checked (or wasn't unchecked) - bool ShowTipsOnStartup() const { return m_checkbox->GetValue(); } - - // sets the (next) tip text - void SetTipText() { m_text->SetValue(m_tipProvider->GetTip()); } - - // "Next" button handler - void OnNextTip(wxCommandEvent& WXUNUSED(event)) { SetTipText(); } - -private: - wxTipProvider *m_tipProvider; - - wxTextCtrl *m_text; - wxCheckBox *m_checkbox; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTipDialog); -}; - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxFileTipProvider -// ---------------------------------------------------------------------------- -#if wxUSE_TEXTFILE -wxFileTipProvider::wxFileTipProvider(const wxString& filename, - size_t currentTip) - : wxTipProvider(currentTip), m_textfile(filename) -{ - m_textfile.Open(); -} - -wxString wxFileTipProvider::GetTip() -{ - size_t count = m_textfile.GetLineCount(); - if ( !count ) - { - return _("Tips not available, sorry!"); - } - - wxString tip; - - // Comments start with a # symbol. - // Loop reading lines until get the first one that isn't a comment. - // The max number of loop executions is the number of lines in the - // textfile so that can't go into an eternal loop in the [oddball] - // case of a comment-only tips file, or the developer has vetoed - // them all via PreprecessTip(). - for ( size_t i=0; i < count; i++ ) - { - // The current tip may be at the last line of the textfile, (or - // past it, if the number of lines in the textfile changed, such - // as changing to a different textfile, with less tips). So check - // to see at last line of text file, (or past it)... - if ( m_currentTip >= count ) - { - // .. and if so, wrap back to line 0. - m_currentTip = 0; - } - - // Read the tip, and increment the current tip counter. - tip = m_textfile.GetLine(m_currentTip++); - - // Allow a derived class's overrided virtual to modify the tip - // now if so desired. - tip = PreprocessTip(tip); - - // Break if tip isn't a comment, and isn't an empty string - // (or only stray space characters). - if ( !tip.StartsWith(wxT("#")) && (tip.Trim() != wxEmptyString) ) - { - break; - } - } - - // If tip starts with '_(', then it is a gettext string of format - // _("My \"global\" tip text") so first strip off the leading '_("'... - if ( tip.StartsWith(wxT("_(\"" ), &tip)) - { - //...and strip off the trailing '")'... - tip = tip.BeforeLast(wxT('\"')); - // ...and replace escaped quotes - tip.Replace(wxT("\\\""), wxT("\"")); - - // and translate it as requested - tip = wxGetTranslation(tip); - } - - return tip; -} -#endif // wxUSE_TEXTFILE - -// ---------------------------------------------------------------------------- -// wxTipDialog -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxTipDialog, wxDialog) - EVT_BUTTON(wxID_NEXT_TIP, wxTipDialog::OnNextTip) -END_EVENT_TABLE() - -wxTipDialog::wxTipDialog(wxWindow *parent, - wxTipProvider *tipProvider, - bool showAtStartup) - : wxDialog(GetParentForModalDialog(parent, 0), wxID_ANY, _("Tip of the Day"), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER - ) -{ - m_tipProvider = tipProvider; - bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - - // 1) create all controls in tab order - - wxStaticText *text = new wxStaticText(this, wxID_ANY, _("Did you know...")); - - if (!isPda) - { - wxFont font = text->GetFont(); - font.SetPointSize(int(1.6 * font.GetPointSize())); - font.SetWeight(wxFONTWEIGHT_BOLD); - text->SetFont(font); - } - - m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxSize(200, 160), - wxTE_MULTILINE | - wxTE_READONLY | - wxTE_NO_VSCROLL | - wxTE_RICH2 | // a hack to get rid of vert scrollbar - wxDEFAULT_CONTROL_BORDER - ); -#if defined(__WXMSW__) - m_text->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL)); -#endif - -//#if defined(__WXPM__) - // - // The only way to get icons into an OS/2 static bitmap control - // -// wxBitmap vBitmap; - -// vBitmap.SetId(wxICON_TIP); // OS/2 specific bitmap method--OS/2 wxBitmaps all have an ID. -// // and for StatBmp's under OS/2 it MUST be a valid resource ID. -// -// wxStaticBitmap* bmp = new wxStaticBitmap(this, wxID_ANY, vBitmap); -// -//#else - - wxIcon icon = wxArtProvider::GetIcon(wxART_TIP, wxART_CMN_DIALOG); - wxStaticBitmap *bmp = new wxStaticBitmap(this, wxID_ANY, icon); - -//#endif - - m_checkbox = new wxCheckBox(this, wxID_ANY, _("&Show tips at startup")); - m_checkbox->SetValue(showAtStartup); - m_checkbox->SetFocus(); - - // smart phones does not support or do not waste space for wxButtons -#ifndef __SMARTPHONE__ - wxButton *btnNext = new wxButton(this, wxID_NEXT_TIP, _("&Next Tip")); -#endif - - // smart phones does not support or do not waste space for wxButtons -#ifndef __SMARTPHONE__ - wxButton *btnClose = new wxButton(this, wxID_CLOSE); - SetAffirmativeId(wxID_CLOSE); -#endif - - - // 2) put them in boxes - - wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL ); - icon_text->Add( bmp, 0, wxCENTER ); - icon_text->Add( text, 1, wxCENTER | wxLEFT, wxLARGESMALL(20,0) ); - topsizer->Add( icon_text, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) ); - - topsizer->Add( m_text, 1, wxEXPAND | wxLEFT|wxRIGHT, wxLARGESMALL(10,0) ); - - wxBoxSizer *bottom = new wxBoxSizer( wxHORIZONTAL ); - if (isPda) - topsizer->Add( m_checkbox, 0, wxCENTER|wxTOP ); - else - bottom->Add( m_checkbox, 0, wxCENTER ); - - // smart phones does not support or do not waste space for wxButtons -#ifdef __SMARTPHONE__ - SetRightMenu(wxID_NEXT_TIP, _("Next")); - SetLeftMenu(wxID_CLOSE); -#else - if (!isPda) - bottom->Add( 10,10,1 ); - bottom->Add( btnNext, 0, wxCENTER | wxLEFT, wxLARGESMALL(10,0) ); - bottom->Add( btnClose, 0, wxCENTER | wxLEFT, wxLARGESMALL(10,0) ); -#endif - - if (isPda) - topsizer->Add( bottom, 0, wxCENTER | wxALL, 5 ); - else - topsizer->Add( bottom, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) ); - - SetTipText(); - - SetSizer( topsizer ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - - Centre(wxBOTH | wxCENTER_FRAME); -} - -// ---------------------------------------------------------------------------- -// our public interface -// ---------------------------------------------------------------------------- - -#if wxUSE_TEXTFILE -wxTipProvider *wxCreateFileTipProvider(const wxString& filename, - size_t currentTip) -{ - return new wxFileTipProvider(filename, currentTip); -} -#endif // wxUSE_TEXTFILE - -bool wxShowTip(wxWindow *parent, - wxTipProvider *tipProvider, - bool showAtStartup) -{ - wxTipDialog dlg(parent, tipProvider, showAtStartup); - dlg.ShowModal(); - - return dlg.ShowTipsOnStartup(); -} - -#endif // wxUSE_STARTUP_TIPS diff --git a/Source/3rd Party/wx/src/generic/tipwin.cpp b/Source/3rd Party/wx/src/generic/tipwin.cpp index edcf1e5c1..0f2f2bb18 100644 --- a/Source/3rd Party/wx/src/generic/tipwin.cpp +++ b/Source/3rd Party/wx/src/generic/tipwin.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 10.09.00 +// RCS-ID: $Id: tipwin.cpp 43033 2006-11-04 13:31:10Z VZ $ // Copyright: (c) 2000 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -70,7 +71,7 @@ private: #endif // !wxUSE_POPUPWIN DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTipWindowView); + DECLARE_NO_COPY_CLASS(wxTipWindowView) }; // ============================================================================ @@ -166,7 +167,7 @@ wxTipWindow::~wxTipWindow() { *m_windowPtr = NULL; } - #if wxUSE_POPUPWIN + #ifdef wxUSE_POPUPWIN #ifdef __WXGTK__ if ( m_view->HasCapture() ) m_view->ReleaseMouse(); @@ -225,11 +226,7 @@ void wxTipWindow::Close() if ( m_view->HasCapture() ) m_view->ReleaseMouse(); #endif - // Under OS X we get destroyed because of wxEVT_KILL_FOCUS generated by - // Show(false). - #ifndef __WXOSX__ - Destroy(); - #endif + Destroy(); #else wxFrame::Close(); #endif @@ -270,7 +267,7 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength) bool breakLine = false; for ( const wxChar *p = text.c_str(); ; p++ ) { - if ( *p == wxT('\n') || *p == wxT('\0') ) + if ( *p == _T('\n') || *p == _T('\0') ) { dc.GetTextExtent(current, &width, &height); if ( width > widthMax ) @@ -290,7 +287,7 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength) current.clear(); breakLine = false; } - else if ( breakLine && (*p == wxT(' ') || *p == wxT('\t')) ) + else if ( breakLine && (*p == _T(' ') || *p == _T('\t')) ) { // word boundary - break the line here m_parent->m_textLines.Add(current); @@ -329,8 +326,8 @@ void wxTipWindowView::OnPaint(wxPaintEvent& WXUNUSED(event)) rect.height = size.y; // first filll the background - dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID)); - dc.SetPen(wxPen(GetForegroundColour(), 1, wxPENSTYLE_SOLID)); + dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); + dc.SetPen( wxPen(GetForegroundColour(), 1, wxSOLID) ); dc.DrawRectangle(rect); // and then draw the text line by line diff --git a/Source/3rd Party/wx/src/generic/toolbkg.cpp b/Source/3rd Party/wx/src/generic/toolbkg.cpp index 598904efe..fa3bbdf97 100644 --- a/Source/3rd Party/wx/src/generic/toolbkg.cpp +++ b/Source/3rd Party/wx/src/generic/toolbkg.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2006-01-29 +// RCS-ID: $Id: toolbkg.cpp 44271 2007-01-21 00:52:05Z VZ $ // Copyright: (c) 2006 Julian Smart // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -43,9 +44,12 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxToolbook, wxBookCtrlBase) +IMPLEMENT_DYNAMIC_CLASS(wxToolbookEvent, wxNotifyEvent) -wxDEFINE_EVENT( wxEVT_TOOLBOOK_PAGE_CHANGING, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent ); +#if !WXWIN_COMPATIBILITY_EVENT_TYPES +const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING = wxNewEventType(); +const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED = wxNewEventType(); +#endif BEGIN_EVENT_TABLE(wxToolbook, wxBookCtrlBase) EVT_SIZE(wxToolbook::OnSize) @@ -63,6 +67,7 @@ END_EVENT_TABLE() void wxToolbook::Init() { + m_selection = wxNOT_FOUND; m_needsRealizing = false; } @@ -84,19 +89,14 @@ bool wxToolbook::Create(wxWindow *parent, wxDefaultValidator, name) ) return false; - int tbFlags = wxTB_TEXT | wxTB_FLAT | wxBORDER_NONE; - if ( (style & (wxBK_LEFT | wxBK_RIGHT)) != 0 ) - tbFlags |= wxTB_VERTICAL; - else - tbFlags |= wxTB_HORIZONTAL; - - if ( style & wxTBK_HORZ_LAYOUT ) - tbFlags |= wxTB_HORZ_LAYOUT; + int orient = wxTB_HORIZONTAL; + if ( (style & (wxBK_LEFT | wxBK_RIGHT)) != 0) + orient = wxTB_VERTICAL; // TODO: make more configurable #if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON - if (style & wxTBK_BUTTONBAR) + if (style & wxBK_BUTTONBAR) { m_bookctrl = new wxButtonToolBar ( @@ -104,7 +104,7 @@ bool wxToolbook::Create(wxWindow *parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - tbFlags + orient|wxTB_TEXT|wxTB_FLAT|wxNO_BORDER ); } else @@ -116,7 +116,7 @@ bool wxToolbook::Create(wxWindow *parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - tbFlags | wxTB_NODIVIDER + orient|wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER|wxNO_BORDER ); } @@ -127,6 +127,28 @@ bool wxToolbook::Create(wxWindow *parent, // wxToolbook geometry management // ---------------------------------------------------------------------------- +wxSize wxToolbook::GetControllerSize() const +{ + const wxSize sizeClient = GetClientSize(), + sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(), + sizeToolBar = GetToolBar()->GetSize() + sizeBorder; + + wxSize size; + + if ( IsVertical() ) + { + size.x = sizeClient.x; + size.y = sizeToolBar.y; + } + else // left/right aligned + { + size.x = sizeToolBar.x; + size.y = sizeClient.y; + } + + return size; +} + void wxToolbook::OnSize(wxSizeEvent& event) { if (m_needsRealizing) @@ -135,6 +157,24 @@ void wxToolbook::OnSize(wxSizeEvent& event) wxBookCtrlBase::OnSize(event); } +wxSize wxToolbook::CalcSizeFromPage(const wxSize& sizePage) const +{ + // we need to add the size of the list control and the border between + const wxSize sizeToolBar = GetControllerSize(); + + wxSize size = sizePage; + if ( IsVertical() ) + { + size.y += sizeToolBar.y + GetInternalBorder(); + } + else // left/right aligned + { + size.x += sizeToolBar.x + GetInternalBorder(); + } + + return size; +} + // ---------------------------------------------------------------------------- // accessing the pages // ---------------------------------------------------------------------------- @@ -163,7 +203,7 @@ wxString wxToolbook::GetPageText(size_t n) const int wxToolbook::GetPageImage(size_t WXUNUSED(n)) const { - wxFAIL_MSG( wxT("wxToolbook::GetPageImage() not implemented") ); + wxFAIL_MSG( _T("wxToolbook::GetPageImage() not implemented") ); return wxNOT_FOUND; } @@ -199,14 +239,19 @@ void wxToolbook::SetImageList(wxImageList *imageList) // selection // ---------------------------------------------------------------------------- -wxBookCtrlEvent* wxToolbook::CreatePageChangingEvent() const +int wxToolbook::GetSelection() const { - return new wxBookCtrlEvent(wxEVT_TOOLBOOK_PAGE_CHANGING, m_windowId); + return m_selection; } -void wxToolbook::MakeChangedEvent(wxBookCtrlEvent &event) +wxBookCtrlBaseEvent* wxToolbook::CreatePageChangingEvent() const { - event.SetEventType(wxEVT_TOOLBOOK_PAGE_CHANGED); + return new wxToolbookEvent(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, m_windowId); +} + +void wxToolbook::MakeChangedEvent(wxBookCtrlBaseEvent &event) +{ + event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED); } void wxToolbook::UpdateSelectedPage(size_t newsel) @@ -221,20 +266,23 @@ void wxToolbook::Realize() { if (m_needsRealizing) { - m_needsRealizing = false; - GetToolBar()->SetToolBitmapSize(m_maxBitmapSize); + int remap = wxSystemOptions::GetOptionInt(wxT("msw.remap")); + wxSystemOptions::SetOption(wxT("msw.remap"), 0); GetToolBar()->Realize(); + wxSystemOptions::SetOption(wxT("msw.remap"), remap); } - if (m_selection == wxNOT_FOUND) + m_needsRealizing = false; + + if (m_selection == -1) m_selection = 0; if (GetPageCount() > 0) { int sel = m_selection; - m_selection = wxNOT_FOUND; + m_selection = -1; SetSelection(sel); } @@ -332,13 +380,28 @@ bool wxToolbook::InsertPage(size_t n, wxWindow *wxToolbook::DoRemovePage(size_t page) { + const size_t page_count = GetPageCount(); wxWindow *win = wxBookCtrlBase::DoRemovePage(page); if ( win ) { GetToolBar()->DeleteTool(page + 1); - DoSetSelectionAfterRemoval(page); + if (m_selection >= (int)page) + { + // force new sel valid if possible + int sel = m_selection - 1; + if (page_count == 1) + sel = wxNOT_FOUND; + else if ((page_count == 2) || (sel == -1)) + sel = 0; + + // force sel invalid if deleting current page - don't try to hide it + m_selection = (m_selection == (int)page) ? wxNOT_FOUND : m_selection - 1; + + if ((sel != wxNOT_FOUND) && (sel != m_selection)) + SetSelection(sel); + } } return win; diff --git a/Source/3rd Party/wx/src/generic/treebkg.cpp b/Source/3rd Party/wx/src/generic/treebkg.cpp index 075c692b0..23f09eccb 100644 --- a/Source/3rd Party/wx/src/generic/treebkg.cpp +++ b/Source/3rd Party/wx/src/generic/treebkg.cpp @@ -4,6 +4,7 @@ // Author: Evgeniy Tarassov, Vadim Zeitlin // Modified by: // Created: 2005-09-15 +// RCS-ID: $Id: treebkg.cpp 54645 2008-07-15 21:29:10Z JS $ // Copyright: (c) 2005 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -45,28 +46,37 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxTreebook, wxBookCtrlBase) +IMPLEMENT_DYNAMIC_CLASS(wxTreebookEvent, wxNotifyEvent) -wxDEFINE_EVENT( wxEVT_TREEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_TREEBOOK_NODE_COLLAPSED, wxBookCtrlEvent ); -wxDEFINE_EVENT( wxEVT_TREEBOOK_NODE_EXPANDED, wxBookCtrlEvent ); +#if !WXWIN_COMPATIBILITY_EVENT_TYPES +const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING = wxNewEventType(); +const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED = wxNewEventType(); +const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED = wxNewEventType(); +const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED = wxNewEventType(); +#endif BEGIN_EVENT_TABLE(wxTreebook, wxBookCtrlBase) EVT_TREE_SEL_CHANGED (wxID_ANY, wxTreebook::OnTreeSelectionChange) EVT_TREE_ITEM_EXPANDED (wxID_ANY, wxTreebook::OnTreeNodeExpandedCollapsed) EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxTreebook::OnTreeNodeExpandedCollapsed) + + WX_EVENT_TABLE_CONTROL_CONTAINER(wxTreebook) END_EVENT_TABLE() // ============================================================================ // wxTreebook implementation // ============================================================================ +WX_DELEGATE_TO_CONTROL_CONTAINER(wxTreebook, wxControl) + // ---------------------------------------------------------------------------- // wxTreebook creation // ---------------------------------------------------------------------------- void wxTreebook::Init() { + m_container.SetContainerWindow(this); + m_selection = m_actualSelection = wxNOT_FOUND; } @@ -94,13 +104,18 @@ wxTreebook::Create(wxWindow *parent, style, wxDefaultValidator, name) ) return false; +#ifdef __WXMSW__ + long treeStyle = GetThemedBorderStyle(); +#else + long treeStyle = wxBORDER_SUNKEN; +#endif m_bookctrl = new wxTreeCtrl ( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxBORDER_THEME | + treeStyle| wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_SINGLE @@ -216,7 +231,7 @@ bool wxTreebook::DoAddSubPage(wxWindow *page, const wxString& text, bool bSelect wxTreeItemId lastNodeId = tree->GetLastChild(rootId); wxCHECK_MSG( lastNodeId.IsOk(), false, - wxT("Can't insert sub page when there are no pages") ); + _T("Can't insert sub page when there are no pages") ); // now calculate its position (should we save/update it too?) size_t newPos = tree->GetCount() - @@ -555,6 +570,21 @@ bool wxTreebook::SetPageImage(size_t n, int imageId) return true; } +wxSize wxTreebook::CalcSizeFromPage(const wxSize& sizePage) const +{ + const wxSize sizeTree = GetControllerSize(); + + wxSize size = sizePage; + size.x += sizeTree.x; + + return size; +} + +int wxTreebook::GetSelection() const +{ + return m_selection; +} + int wxTreebook::DoSetSelection(size_t pagePos, int flags) { wxCHECK_MSG( IS_VALID_PAGE(pagePos), wxNOT_FOUND, @@ -562,7 +592,7 @@ int wxTreebook::DoSetSelection(size_t pagePos, int flags) wxASSERT_MSG( GetPageCount() == DoInternalGetPageCount(), wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!")); - wxBookCtrlEvent event(wxEVT_TREEBOOK_PAGE_CHANGING, m_windowId); + wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId); const int oldSel = m_selection; wxTreeCtrl *tree = GetTreeCtrl(); bool allowed = false; @@ -617,7 +647,7 @@ int wxTreebook::DoSetSelection(size_t pagePos, int flags) if (flags & SetSelection_SendEvent) { // notify about the (now completed) page change - event.SetEventType(wxEVT_TREEBOOK_PAGE_CHANGED); + event.SetEventType(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED); (void)GetEventHandler()->ProcessEvent(event); } } @@ -700,9 +730,9 @@ void wxTreebook::OnTreeNodeExpandedCollapsed(wxTreeEvent & event) int pagePos = DoInternalFindPageById(nodeId); wxCHECK_RET( pagePos != wxNOT_FOUND, wxT("Internal problem in wxTreebook!..") ); - wxBookCtrlEvent ev(GetTreeCtrl()->IsExpanded(nodeId) - ? wxEVT_TREEBOOK_NODE_EXPANDED - : wxEVT_TREEBOOK_NODE_COLLAPSED, + wxTreebookEvent ev(GetTreeCtrl()->IsExpanded(nodeId) + ? wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED + : wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, m_windowId); ev.SetSelection(pagePos); diff --git a/Source/3rd Party/wx/src/generic/treectlg.cpp b/Source/3rd Party/wx/src/generic/treectlg.cpp index 7f395cafb..e00ee5b1e 100644 --- a/Source/3rd Party/wx/src/generic/treectlg.cpp +++ b/Source/3rd Party/wx/src/generic/treectlg.cpp @@ -4,6 +4,7 @@ // Author: Robert Roebling // Created: 01/02/97 // Modified: 22/10/98 - almost total rewrite, simpler interface (VZ) +// Id: $Id: treectlg.cpp 67017 2011-02-25 09:37:28Z JS $ // Copyright: (c) 1998 Robert Roebling and Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -41,7 +42,7 @@ #include "wx/renderer.h" #ifdef __WXMAC__ - #include "wx/osx/private.h" + #include "wx/mac/private.h" #endif // ----------------------------------------------------------------------------- @@ -50,7 +51,7 @@ class WXDLLIMPEXP_FWD_CORE wxGenericTreeItem; -WX_DEFINE_ARRAY_PTR(wxGenericTreeItem *, wxArrayGenericTreeItems); +WX_DEFINE_EXPORTED_ARRAY_PTR(wxGenericTreeItem *, wxArrayGenericTreeItems); // ---------------------------------------------------------------------------- // constants @@ -60,9 +61,6 @@ static const int NO_IMAGE = -1; static const int PIXELS_PER_UNIT = 10; -// the margin between the item state image and the item normal image -static const int MARGIN_BETWEEN_STATE_AND_IMAGE = 2; - // the margin between the item image and the item text static const int MARGIN_BETWEEN_IMAGE_AND_TEXT = 4; @@ -76,7 +74,7 @@ class WXDLLEXPORT wxTreeRenameTimer: public wxTimer public: // start editing the current item after half a second (if the mouse hasn't // been clicked/moved) - enum { DELAY = 500 }; + enum { DELAY = 250 }; wxTreeRenameTimer( wxGenericTreeCtrl *owner ); @@ -85,7 +83,7 @@ public: private: wxGenericTreeCtrl *m_owner; - wxDECLARE_NO_COPY_CLASS(wxTreeRenameTimer); + DECLARE_NO_COPY_CLASS(wxTreeRenameTimer) }; // control used for in-place edit @@ -94,7 +92,7 @@ class WXDLLEXPORT wxTreeTextCtrl: public wxTextCtrl public: wxTreeTextCtrl(wxGenericTreeCtrl *owner, wxGenericTreeItem *item); - void EndEdit( bool discardChanges ); + void EndEdit(bool discardChanges); const wxGenericTreeItem* item() const { return m_itemEdited; } @@ -104,7 +102,7 @@ protected: void OnKillFocus( wxFocusEvent &event ); bool AcceptChanges(); - void Finish( bool setfocus ); + void Finish( bool setfocus = true ); private: wxGenericTreeCtrl *m_owner; @@ -113,7 +111,7 @@ private: bool m_aboutToFinish; DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(wxTreeTextCtrl); + DECLARE_NO_COPY_CLASS(wxTreeTextCtrl) }; // timer used to clear wxGenericTreeCtrl::m_findPrefix if no key was pressed @@ -126,12 +124,12 @@ public: wxTreeFindTimer( wxGenericTreeCtrl *owner ) { m_owner = owner; } - virtual void Notify() { m_owner->ResetFindState(); } + virtual void Notify() { m_owner->m_findPrefix.clear(); } private: wxGenericTreeCtrl *m_owner; - wxDECLARE_NO_COPY_CLASS(wxTreeFindTimer); + DECLARE_NO_COPY_CLASS(wxTreeFindTimer) }; // a tree item @@ -139,8 +137,7 @@ class WXDLLEXPORT wxGenericTreeItem { public: // ctors & dtor - wxGenericTreeItem() - { + wxGenericTreeItem() { m_data = NULL; m_widthText = m_heightText = -1; @@ -161,7 +158,6 @@ public: int GetImage(wxTreeItemIcon which = wxTreeItemIcon_Normal) const { return m_images[which]; } wxTreeItemData *GetData() const { return m_data; } - int GetState() const { return m_state; } // returns the current image for the item (depending on its // selected/expanded/whatever state) @@ -181,7 +177,6 @@ public: } void SetData(wxTreeItemData *data) { m_data = data; } - void SetState(int state) { m_state = state; m_width = 0; } void SetHasPlus(bool has = true) { m_hasPlus = has; } @@ -199,18 +194,18 @@ public: void SetY(int y) { m_y = y; } int GetHeight() const { return m_height; } - int GetWidth() const { return m_width; } + int GetWidth() const { return m_width; } int GetTextHeight() const { - wxASSERT_MSG( m_heightText != -1, "must call CalculateSize() first" ); + wxASSERT_MSG( m_heightText != -1, _T("must call CalculateSize() first") ); return m_heightText; } int GetTextWidth() const { - wxASSERT_MSG( m_widthText != -1, "must call CalculateSize() first" ); + wxASSERT_MSG( m_widthText != -1, _T("must call CalculateSize() first") ); return m_widthText; } @@ -260,9 +255,9 @@ public: void RecursiveResetSize(); void RecursiveResetTextSize(); - // return the item at given position (or NULL if no item), onButton is - // true if the point belongs to the item's button, otherwise it lies - // on the item's label + // return the item at given position (or NULL if no item), onButton is + // true if the point belongs to the item's button, otherwise it lies + // on the item's label wxGenericTreeItem *HitTest( const wxPoint& point, const wxGenericTreeCtrl *, int &flags, @@ -330,8 +325,6 @@ private: wxTreeItemData *m_data; // user-provided data - int m_state; // item state - wxArrayGenericTreeItems m_children; // list of children wxGenericTreeItem *m_parent; // parent of this item @@ -354,7 +347,7 @@ private: unsigned int m_isBold :1; // render the label in bold font unsigned int m_ownsAttr :1; // delete attribute when done - wxDECLARE_NO_COPY_CLASS(wxGenericTreeItem); + DECLARE_NO_COPY_CLASS(wxGenericTreeItem) }; // ============================================================================= @@ -380,8 +373,7 @@ static void EventFlagsToSelType(long style, } // check if the given item is under another one -static bool -IsDescendantOf(const wxGenericTreeItem *parent, const wxGenericTreeItem *item) +static bool IsDescendantOf(const wxGenericTreeItem *parent, const wxGenericTreeItem *item) { while ( item ) { @@ -422,56 +414,62 @@ BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl) END_EVENT_TABLE() wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner, - wxGenericTreeItem *itm) - : m_itemEdited(itm), m_startValue(itm->GetText()) + wxGenericTreeItem *item) + : m_itemEdited(item), m_startValue(item->GetText()) { m_owner = owner; m_aboutToFinish = false; - wxRect rect; - m_owner->GetBoundingRect(m_itemEdited, rect, true); + int w = m_itemEdited->GetWidth(), + h = m_itemEdited->GetHeight(); - // corrects position and size for better appearance -#ifdef __WXMSW__ - rect.x -= 5; - rect.width += 10; -#elif defined(__WXGTK__) - rect.x -= 5; - rect.y -= 2; - rect.width += 8; - rect.height += 4; -#elif defined(wxOSX_USE_CARBON) && wxOSX_USE_CARBON - int bestHeight = GetBestSize().y - 8; - if ( rect.height > bestHeight ) + int x, y; + m_owner->CalcScrolledPosition(item->GetX(), item->GetY(), &x, &y); + + int image_h = 0, + image_w = 0; + + int image = item->GetCurrentImage(); + if ( image != NO_IMAGE ) { - int diff = rect.height - bestHeight; - rect.height -= diff; - rect.y += diff / 2; + if ( m_owner->m_imageListNormal ) + { + m_owner->m_imageListNormal->GetSize( image, image_w, image_h ); + image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; + } + else + { + wxFAIL_MSG(_T("you must create an image list to use images!")); + } } -#endif // platforms + + // FIXME: what are all these hardcoded 4, 8 and 11s really? + x += image_w; + w -= image_w + 4; +#ifdef __WXMAC__ + wxSize bs = DoGetBestSize() ; + // edit control height + if ( h > bs.y - 8 ) + { + int diff = h - ( bs.y - 8 ) ; + h -= diff ; + y += diff / 2 ; + } +#endif (void)Create(m_owner, wxID_ANY, m_startValue, - rect.GetPosition(), rect.GetSize()); - - SelectAll(); + wxPoint(x - 4, y - 4), wxSize(w + 11, h + 8)); } void wxTreeTextCtrl::EndEdit(bool discardChanges) { - if ( m_aboutToFinish ) - { - // We already called Finish which cannot be called - // more than once. - return; - } - m_aboutToFinish = true; if ( discardChanges ) { m_owner->OnRenameCancelled(m_itemEdited); - Finish( true ); + Finish(); } else { @@ -479,7 +477,7 @@ void wxTreeTextCtrl::EndEdit(bool discardChanges) AcceptChanges(); // Even if vetoed, close the control (consistent with MSW) - Finish( true ); + Finish(); } } @@ -547,7 +545,7 @@ void wxTreeTextCtrl::OnKeyUp( wxKeyEvent &event ) wxPoint myPos = GetPosition(); wxSize mySize = GetSize(); int sx, sy; - GetTextExtent(GetValue() + wxT("M"), &sx, &sy); + GetTextExtent(GetValue() + _T("M"), &sx, &sy); if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x; if (mySize.x > sx) @@ -562,7 +560,6 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event ) { if ( !m_aboutToFinish ) { - m_aboutToFinish = true; if ( !AcceptChanges() ) m_owner->OnRenameCancelled( m_itemEdited ); @@ -589,7 +586,6 @@ wxGenericTreeItem::wxGenericTreeItem(wxGenericTreeItem *parent, m_images[wxTreeItemIcon_SelectedExpanded] = NO_IMAGE; m_data = data; - m_state = wxTREE_ITEMSTATE_NONE; m_x = m_y = 0; m_isCollapsed = true; @@ -599,7 +595,7 @@ wxGenericTreeItem::wxGenericTreeItem(wxGenericTreeItem *parent, m_parent = parent; - m_attr = NULL; + m_attr = (wxTreeItemAttr *)NULL; m_ownsAttr = false; // We don't know the height here yet. @@ -617,12 +613,12 @@ wxGenericTreeItem::~wxGenericTreeItem() if (m_ownsAttr) delete m_attr; wxASSERT_MSG( m_children.IsEmpty(), - "must call DeleteChildren() before deleting the item" ); + wxT("please call DeleteChildren() before deleting the item") ); } void wxGenericTreeItem::DeleteChildren(wxGenericTreeCtrl *tree) { - size_t count = m_children.GetCount(); + size_t count = m_children.Count(); for ( size_t n = 0; n < count; n++ ) { wxGenericTreeItem *child = m_children[n]; @@ -639,7 +635,7 @@ void wxGenericTreeItem::DeleteChildren(wxGenericTreeCtrl *tree) size_t wxGenericTreeItem::GetChildrenCount(bool recursively) const { - size_t count = m_children.GetCount(); + size_t count = m_children.Count(); if ( !recursively ) return count; @@ -662,7 +658,7 @@ void wxGenericTreeItem::GetSize( int &x, int &y, if (IsExpanded()) { - size_t count = m_children.GetCount(); + size_t count = m_children.Count(); for ( size_t n = 0; n < count; ++n ) { m_children[n]->GetSize( x, y, theButton ); @@ -713,29 +709,10 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest(const wxPoint& point, // assuming every image (normal and selected) has the same size! if ( (GetImage() != NO_IMAGE) && theCtrl->m_imageListNormal ) - { theCtrl->m_imageListNormal->GetSize(GetImage(), image_w, image_h); - } - int state_w = -1; - int state_h; - - if ( (GetState() != wxTREE_ITEMSTATE_NONE) && - theCtrl->m_imageListState ) - { - theCtrl->m_imageListState->GetSize(GetState(), - state_w, state_h); - } - - if ((state_w != -1) && (point.x <= m_x + state_w + 1)) - flags |= wxTREE_HITTEST_ONITEMSTATEICON; - else if ((image_w != -1) && - (point.x <= m_x + - (state_w != -1 ? state_w + - MARGIN_BETWEEN_STATE_AND_IMAGE - : 0) - + image_w + 1)) + if ((image_w != -1) && (point.x <= m_x + image_w + 1)) flags |= wxTREE_HITTEST_ONITEMICON; else flags |= wxTREE_HITTEST_ONITEMLABEL; @@ -752,11 +729,11 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest(const wxPoint& point, } // if children are expanded, fall through to evaluate them - if (m_isCollapsed) return NULL; + if (m_isCollapsed) return (wxGenericTreeItem*) NULL; } // evaluate children - size_t count = m_children.GetCount(); + size_t count = m_children.Count(); for ( size_t n = 0; n < count; n++ ) { wxGenericTreeItem *res = m_children[n]->HitTest( point, @@ -767,7 +744,7 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest(const wxPoint& point, return res; } - return NULL; + return (wxGenericTreeItem*) NULL; } int wxGenericTreeItem::GetCurrentImage() const @@ -847,27 +824,19 @@ wxGenericTreeItem::DoCalculateSize(wxGenericTreeCtrl* control, int text_h = m_heightText + 2; - int image_h = 0, image_w = 0; + int image_h = 0; + int image_w = 0; int image = GetCurrentImage(); - if ( image != NO_IMAGE && control->m_imageListNormal ) + if ( image != NO_IMAGE ) { - control->m_imageListNormal->GetSize(image, image_w, image_h); - image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; + if ( control->m_imageListNormal ) + { + control->m_imageListNormal->GetSize( image, image_w, image_h ); + image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; + } } - int state_h = 0, state_w = 0; - int state = GetState(); - if ( state != wxTREE_ITEMSTATE_NONE && control->m_imageListState ) - { - control->m_imageListState->GetSize(state, state_w, state_h); - if ( image_w != 0 ) - state_w += MARGIN_BETWEEN_STATE_AND_IMAGE; - else - state_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; - } - - int img_h = wxMax(state_h, image_h); - m_height = wxMax(img_h, text_h); + m_height = (image_h > text_h) ? image_h : text_h; if (m_height < 30) m_height += 2; // at least 2 pixels @@ -877,7 +846,7 @@ wxGenericTreeItem::DoCalculateSize(wxGenericTreeCtrl* control, if (m_height > control->m_lineHeight) control->m_lineHeight = m_height; - m_width = state_w + image_w + m_widthText + 2; + m_width = image_w + m_widthText + 2; } void wxGenericTreeItem::RecursiveResetSize() @@ -909,13 +878,21 @@ BEGIN_EVENT_TABLE(wxGenericTreeCtrl, wxTreeCtrlBase) EVT_PAINT (wxGenericTreeCtrl::OnPaint) EVT_SIZE (wxGenericTreeCtrl::OnSize) EVT_MOUSE_EVENTS (wxGenericTreeCtrl::OnMouse) - EVT_KEY_DOWN (wxGenericTreeCtrl::OnKeyDown) EVT_CHAR (wxGenericTreeCtrl::OnChar) EVT_SET_FOCUS (wxGenericTreeCtrl::OnSetFocus) EVT_KILL_FOCUS (wxGenericTreeCtrl::OnKillFocus) EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, wxGenericTreeCtrl::OnGetToolTip) END_EVENT_TABLE() +#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) +/* + * wxTreeCtrl has to be a real class or we have problems with + * the run-time information. + */ + +IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxGenericTreeCtrl) +#endif + // ----------------------------------------------------------------------------- // construction/destruction // ----------------------------------------------------------------------------- @@ -925,7 +902,7 @@ void wxGenericTreeCtrl::Init() m_current = m_key_current = m_anchor = - m_select_me = NULL; + m_select_me = (wxGenericTreeItem *) NULL; m_hasFocus = false; m_dirty = false; @@ -939,7 +916,7 @@ void wxGenericTreeCtrl::Init() ( wxSYS_COLOUR_HIGHLIGHT ), - wxBRUSHSTYLE_SOLID + wxSOLID ); m_hilightUnfocusedBrush = new wxBrush @@ -948,7 +925,7 @@ void wxGenericTreeCtrl::Init() ( wxSYS_COLOUR_BTNSHADOW ), - wxBRUSHSTYLE_SOLID + wxSOLID ); m_imageListButtons = NULL; @@ -961,23 +938,26 @@ void wxGenericTreeCtrl::Init() m_textCtrl = NULL; m_renameTimer = NULL; + m_freezeCount = 0; m_findTimer = NULL; - m_findBell = 0; // default is to not ring bell at all m_dropEffectAboveItem = false; - m_dndEffect = NoEffect; - m_dndEffectItem = NULL; - m_lastOnSame = false; -#if defined( __WXMAC__ ) - m_normalFont = wxFont(wxOSX_SYSTEM_FONT_VIEWS); +#ifdef __WXMAC_CARBON__ + m_normalFont.MacCreateThemeFont( kThemeViewsFont ) ; #else m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); #endif - m_boldFont = m_normalFont.Bold(); + m_boldFont = wxFont(m_normalFont.GetPointSize(), + m_normalFont.GetFamily(), + m_normalFont.GetStyle(), + wxBOLD, + m_normalFont.GetUnderlined(), + m_normalFont.GetFaceName(), + m_normalFont.GetEncoding()); } bool wxGenericTreeCtrl::Create(wxWindow *parent, @@ -989,23 +969,24 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, const wxString& name ) { #ifdef __WXMAC__ - int major, minor; - wxGetOsVersion(&major, &minor); + int major,minor; + wxGetOsVersion( &major, &minor ); + style &= ~wxTR_LINES_AT_ROOT; + style |= wxTR_NO_LINES; if (major < 10) style |= wxTR_ROW_LINES; - if (style & wxTR_HAS_BUTTONS) - style |= wxTR_NO_LINES; -#endif // __WXMAC__ + if (style == 0 || style & wxTR_DEFAULT_STYLE) + style |= wxTR_FULL_ROW_HIGHLIGHT; +#endif // __WXMAC__ #ifdef __WXGTK20__ - if (style & wxTR_HAS_BUTTONS) - style |= wxTR_NO_LINES; + style |= wxTR_NO_LINES; #endif if ( !wxControl::Create( parent, id, pos, size, - style|wxHSCROLL|wxVSCROLL|wxWANTS_CHARS, + style|wxHSCROLL|wxVSCROLL, validator, name ) ) return false; @@ -1025,14 +1006,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, if (!m_hasFont) SetOwnFont(attr.font); - // this is a misnomer: it's called "dotted pen" but uses (default) wxSOLID - // style because we apparently get performance problems when using dotted - // pen for drawing in some ports -- but under MSW it seems to work fine -#ifdef __WXMSW__ - m_dottedPen = wxPen(*wxLIGHT_GREY, 0, wxPENSTYLE_DOT); -#else - m_dottedPen = *wxGREY_PEN; -#endif + m_dottedPen = wxPen( wxT("grey"), 0, 0 ); SetInitialSize(size); @@ -1053,11 +1027,6 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl() delete m_imageListButtons; } -void wxGenericTreeCtrl::EnableBellOnNoMatch( bool on ) -{ - m_findBell = on; -} - // ----------------------------------------------------------------------------- // accessors // ----------------------------------------------------------------------------- @@ -1139,14 +1108,6 @@ wxTreeItemData *wxGenericTreeCtrl::GetItemData(const wxTreeItemId& item) const return ((wxGenericTreeItem*) item.m_pItem)->GetData(); } -int wxGenericTreeCtrl::DoGetItemState(const wxTreeItemId& item) const -{ - wxCHECK_MSG( item.IsOk(), wxTREE_ITEMSTATE_NONE, wxT("invalid tree item") ); - - wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem; - return pItem->GetState(); -} - wxColour wxGenericTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), wxNullColour, wxT("invalid tree item") ); @@ -1155,8 +1116,7 @@ wxColour wxGenericTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const return pItem->Attr().GetTextColour(); } -wxColour -wxGenericTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const +wxColour wxGenericTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), wxNullColour, wxT("invalid tree item") ); @@ -1172,8 +1132,7 @@ wxFont wxGenericTreeCtrl::GetItemFont(const wxTreeItemId& item) const return pItem->Attr().GetFont(); } -void -wxGenericTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) +void wxGenericTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) { wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); @@ -1195,8 +1154,7 @@ void wxGenericTreeCtrl::SetItemImage(const wxTreeItemId& item, RefreshLine(pItem); } -void -wxGenericTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) +void wxGenericTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) { wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); @@ -1206,16 +1164,6 @@ wxGenericTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) ((wxGenericTreeItem*) item.m_pItem)->SetData(data); } -void wxGenericTreeCtrl::DoSetItemState(const wxTreeItemId& item, int state) -{ - wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); - - wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem; - pItem->SetState(state); - pItem->CalculateSize(this); - RefreshLine(pItem); -} - void wxGenericTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has) { wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); @@ -1238,7 +1186,6 @@ void wxGenericTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold) // recalculate the item size as bold and non bold fonts have different // widths pItem->CalculateSize(this); - RefreshLine(pItem); } } @@ -1281,8 +1228,7 @@ void wxGenericTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item, RefreshLine(pItem); } -void -wxGenericTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) +void wxGenericTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) { wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); @@ -1297,8 +1243,14 @@ bool wxGenericTreeCtrl::SetFont( const wxFont &font ) { wxTreeCtrlBase::SetFont(font); - m_normalFont = font; - m_boldFont = m_normalFont.Bold(); + m_normalFont = font ; + m_boldFont = wxFont(m_normalFont.GetPointSize(), + m_normalFont.GetFamily(), + m_normalFont.GetStyle(), + wxBOLD, + m_normalFont.GetUnderlined(), + m_normalFont.GetFaceName(), + m_normalFont.GetEncoding()); if (m_anchor) m_anchor->RecursiveResetTextSize(); @@ -1315,10 +1267,6 @@ bool wxGenericTreeCtrl::IsVisible(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); - // Hidden root item is never visible. - if ( item == GetRootItem() && HasFlag(wxTR_HIDE_ROOT) ) - return false; - // An item is only visible if it's not a descendant of a collapsed item wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem; wxGenericTreeItem* parent = pItem->GetParent(); @@ -1405,13 +1353,12 @@ wxTreeItemId wxGenericTreeCtrl::GetNextChild(const wxTreeItemId& item, { wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); - wxArrayGenericTreeItems& - children = ((wxGenericTreeItem*) item.m_pItem)->GetChildren(); + wxArrayGenericTreeItems& children = ((wxGenericTreeItem*) item.m_pItem)->GetChildren(); // it's ok to cast cookie to size_t, we never have indices big enough to // overflow "void *" size_t *pIndex = (size_t *)&cookie; - if ( *pIndex < children.GetCount() ) + if ( *pIndex < children.Count() ) { return children.Item((*pIndex)++); } @@ -1422,13 +1369,42 @@ wxTreeItemId wxGenericTreeCtrl::GetNextChild(const wxTreeItemId& item, } } +#if WXWIN_COMPATIBILITY_2_4 + +wxTreeItemId wxGenericTreeCtrl::GetFirstChild(const wxTreeItemId& item, + long& cookie) const +{ + wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); + + cookie = 0; + return GetNextChild(item, cookie); +} + +wxTreeItemId wxGenericTreeCtrl::GetNextChild(const wxTreeItemId& item, + long& cookie) const +{ + wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); + + wxArrayGenericTreeItems& children = ((wxGenericTreeItem*) item.m_pItem)->GetChildren(); + if ( (size_t)cookie < children.Count() ) + { + return children.Item((size_t)cookie++); + } + else + { + // there are no more of them + return wxTreeItemId(); + } +} + +#endif // WXWIN_COMPATIBILITY_2_4 + wxTreeItemId wxGenericTreeCtrl::GetLastChild(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); - wxArrayGenericTreeItems& - children = ((wxGenericTreeItem*) item.m_pItem)->GetChildren(); - return children.IsEmpty() ? wxTreeItemId() : wxTreeItemId(children.Last()); + wxArrayGenericTreeItems& children = ((wxGenericTreeItem*) item.m_pItem)->GetChildren(); + return (children.IsEmpty() ? wxTreeItemId() : wxTreeItemId(children.Last())); } wxTreeItemId wxGenericTreeCtrl::GetNextSibling(const wxTreeItemId& item) const @@ -1448,8 +1424,7 @@ wxTreeItemId wxGenericTreeCtrl::GetNextSibling(const wxTreeItemId& item) const wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent? size_t n = (size_t)(index + 1); - return n == siblings.GetCount() ? wxTreeItemId() - : wxTreeItemId(siblings[n]); + return n == siblings.Count() ? wxTreeItemId() : wxTreeItemId(siblings[n]); } wxTreeItemId wxGenericTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const @@ -1501,16 +1476,16 @@ wxTreeItemId wxGenericTreeCtrl::GetNext(const wxTreeItemId& item) const wxTreeItemId wxGenericTreeCtrl::GetFirstVisibleItem() const { - wxTreeItemId itemid = GetRootItem(); - if (!itemid.IsOk()) - return itemid; + wxTreeItemId id = GetRootItem(); + if (!id.IsOk()) + return id; do { - if (IsVisible(itemid)) - return itemid; - itemid = GetNext(itemid); - } while (itemid.IsOk()); + if (IsVisible(id)) + return id; + id = GetNext(id); + } while (id.IsOk()); return wxTreeItemId(); } @@ -1518,7 +1493,6 @@ wxTreeItemId wxGenericTreeCtrl::GetFirstVisibleItem() const wxTreeItemId wxGenericTreeCtrl::GetNextVisible(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); - wxASSERT_MSG( IsVisible(item), wxT("this item itself should be visible") ); wxTreeItemId id = item; if (id.IsOk()) @@ -1535,37 +1509,10 @@ wxTreeItemId wxGenericTreeCtrl::GetNextVisible(const wxTreeItemId& item) const wxTreeItemId wxGenericTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); - wxASSERT_MSG( IsVisible(item), wxT("this item itself should be visible") ); - // find out the starting point - wxTreeItemId prevItem = GetPrevSibling(item); - if ( !prevItem.IsOk() ) - { - prevItem = GetItemParent(item); - } + wxFAIL_MSG(wxT("not implemented")); - // find the first visible item after it - while ( prevItem.IsOk() && !IsVisible(prevItem) ) - { - prevItem = GetNext(prevItem); - if ( !prevItem.IsOk() || prevItem == item ) - { - // there are no visible items before item - return wxTreeItemId(); - } - } - - // from there we must be able to navigate until this item - while ( prevItem.IsOk() ) - { - const wxTreeItemId nextItem = GetNextVisible(prevItem); - if ( !nextItem.IsOk() || nextItem == item ) - break; - - prevItem = nextItem; - } - - return prevItem; + return wxTreeItemId(); } // called by wxTextTreeCtrl when it marks itself for deletion @@ -1574,13 +1521,6 @@ void wxGenericTreeCtrl::ResetTextControl() m_textCtrl = NULL; } -void wxGenericTreeCtrl::ResetFindState() -{ - m_findPrefix.clear(); - if ( m_findBell ) - m_findBell = 1; -} - // find the first item starting with the given prefix after the given item wxTreeItemId wxGenericTreeCtrl::FindItem(const wxTreeItemId& idParent, const wxString& prefixOrig) const @@ -1594,44 +1534,39 @@ wxTreeItemId wxGenericTreeCtrl::FindItem(const wxTreeItemId& idParent, // allows to switch between two items starting with the same letter just by // pressing it) but we shouldn't jump to the next one if the user is // continuing to type as otherwise he might easily skip the item he wanted - wxTreeItemId itemid = idParent; + wxTreeItemId id = idParent; if ( prefix.length() == 1 ) { - itemid = GetNext(itemid); + id = GetNext(id); } // look for the item starting with the given prefix after it - while ( itemid.IsOk() && !GetItemText(itemid).Lower().StartsWith(prefix) ) + while ( id.IsOk() && !GetItemText(id).Lower().StartsWith(prefix) ) { - itemid = GetNext(itemid); + id = GetNext(id); } // if we haven't found anything... - if ( !itemid.IsOk() ) + if ( !id.IsOk() ) { // ... wrap to the beginning - itemid = GetRootItem(); + id = GetRootItem(); if ( HasFlag(wxTR_HIDE_ROOT) ) { // can't select virtual root - itemid = GetNext(itemid); + id = GetNext(id); } // and try all the items (stop when we get to the one we started from) - while ( itemid.IsOk() && itemid != idParent && - !GetItemText(itemid).Lower().StartsWith(prefix) ) + while (id.IsOk() && id != idParent && !GetItemText(id).Lower().StartsWith(prefix) ) { - itemid = GetNext(itemid); - } - // If we haven't found the item but wrapped back to the one we started - // from, id.IsOk() must be false - if ( itemid == idParent ) - { - itemid = wxTreeItemId(); + id = GetNext(id); } + // If we haven't found the item, id.IsOk() will be false, as per + // documentation } - return itemid; + return id; } // ----------------------------------------------------------------------------- @@ -1674,11 +1609,11 @@ wxTreeItemId wxGenericTreeCtrl::AddRoot(const wxString& text, int selImage, wxTreeItemData *data) { - wxCHECK_MSG( !m_anchor, wxTreeItemId(), "tree can have only one root" ); + wxCHECK_MSG( !m_anchor, wxTreeItemId(), wxT("tree can have only one root") ); m_dirty = true; // do this first so stuff below doesn't cause flicker - m_anchor = new wxGenericTreeItem(NULL, text, + m_anchor = new wxGenericTreeItem((wxGenericTreeItem *)NULL, text, image, selImage, data); if ( data != NULL ) { @@ -1691,8 +1626,8 @@ wxTreeItemId wxGenericTreeCtrl::AddRoot(const wxString& text, // into children m_anchor->SetHasPlus(); m_anchor->Expand(); - CalculatePositions(); } + CalculatePositions(); if (!HasFlag(wxTR_MULTIPLE)) { @@ -1720,11 +1655,9 @@ wxTreeItemId wxGenericTreeCtrl::DoInsertAfter(const wxTreeItemId& parentId, int index = -1; if (idPrevious.IsOk()) { - index = parent->GetChildren().Index( - (wxGenericTreeItem*) idPrevious.m_pItem); + index = parent->GetChildren().Index((wxGenericTreeItem*) idPrevious.m_pItem); wxASSERT_MSG( index != wxNOT_FOUND, - "previous item in wxGenericTreeCtrl::InsertItem() " - "is not a sibling" ); + wxT("previous item in wxGenericTreeCtrl::InsertItem() is not a sibling") ); } return DoInsertItem(parentId, (size_t)++index, text, image, selImage, data); @@ -1733,31 +1666,23 @@ wxTreeItemId wxGenericTreeCtrl::DoInsertAfter(const wxTreeItemId& parentId, void wxGenericTreeCtrl::SendDeleteEvent(wxGenericTreeItem *item) { - wxTreeEvent event(wxEVT_TREE_DELETE_ITEM, this, item); - GetEventHandler()->ProcessEvent( event ); + wxTreeEvent event(wxEVT_COMMAND_TREE_DELETE_ITEM, this, item); + ProcessEvent( event ); } // Don't leave edit or selection on a child which is about to disappear void wxGenericTreeCtrl::ChildrenClosing(wxGenericTreeItem* item) { - if ( m_textCtrl && item != m_textCtrl->item() && - IsDescendantOf(item, m_textCtrl->item()) ) - { + if (m_textCtrl != NULL && item != m_textCtrl->item() && IsDescendantOf(item, m_textCtrl->item())) { m_textCtrl->EndEdit( true ); } - - if ( item != m_key_current && IsDescendantOf(item, m_key_current) ) - { + if (item != m_key_current && IsDescendantOf(item, m_key_current)) { m_key_current = NULL; } - - if ( IsDescendantOf(item, m_select_me) ) - { + if (IsDescendantOf(item, m_select_me)) { m_select_me = item; } - - if ( item != m_current && IsDescendantOf(item, m_current) ) - { + if (item != m_current && IsDescendantOf(item, m_current)) { m_current->SetHilight( false ); m_current = NULL; m_select_me = item; @@ -1788,16 +1713,6 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) wxGenericTreeItem *parent = item->GetParent(); - // if the selected item will be deleted, select the parent ... - wxGenericTreeItem *to_be_selected = parent; - if (parent) - { - // .. unless there is a next sibling like wxMSW does it - int pos = parent->GetChildren().Index( item ); - if ((int)(parent->GetChildren().GetCount()) > pos+1) - to_be_selected = parent->GetChildren().Item( pos+1 ); - } - // don't keep stale pointers around! if ( IsDescendantOf(item, m_key_current) ) { @@ -1813,7 +1728,7 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) // a different item, in idle time. if ( m_select_me && IsDescendantOf(item, m_select_me) ) { - m_select_me = to_be_selected; + m_select_me = parent; } if ( IsDescendantOf(item, m_current) ) @@ -1824,7 +1739,7 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) // m_current = parent; m_current = NULL; - m_select_me = to_be_selected; + m_select_me = parent; } // remove the item from the tree @@ -1862,9 +1777,9 @@ void wxGenericTreeCtrl::Expand(const wxTreeItemId& itemId) { wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem; - wxCHECK_RET( item, wxT("invalid item in wxGenericTreeCtrl::Expand") ); + wxCHECK_RET( item, _T("invalid item in wxGenericTreeCtrl::Expand") ); wxCHECK_RET( !HasFlag(wxTR_HIDE_ROOT) || itemId != GetRootItem(), - wxT("can't expand hidden root") ); + _T("can't expand hidden root") ); if ( !item->HasPlus() ) return; @@ -1872,42 +1787,35 @@ void wxGenericTreeCtrl::Expand(const wxTreeItemId& itemId) if ( item->IsExpanded() ) return; - wxTreeEvent event(wxEVT_TREE_ITEM_EXPANDING, this, item); + wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, this, item); - if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) + if ( ProcessEvent( event ) && !event.IsAllowed() ) { // cancelled by program return; } item->Expand(); - if ( !IsFrozen() ) - { - CalculatePositions(); + CalculatePositions(); - RefreshSubtree(item); - } - else // frozen - { - m_dirty = true; - } + RefreshSubtree(item); - event.SetEventType(wxEVT_TREE_ITEM_EXPANDED); - GetEventHandler()->ProcessEvent( event ); + event.SetEventType(wxEVT_COMMAND_TREE_ITEM_EXPANDED); + ProcessEvent( event ); } void wxGenericTreeCtrl::Collapse(const wxTreeItemId& itemId) { wxCHECK_RET( !HasFlag(wxTR_HIDE_ROOT) || itemId != GetRootItem(), - wxT("can't collapse hidden root") ); + _T("can't collapse hidden root") ); wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem; if ( !item->IsExpanded() ) return; - wxTreeEvent event(wxEVT_TREE_ITEM_COLLAPSING, this, item); - if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) + wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, this, item); + if ( ProcessEvent( event ) && !event.IsAllowed() ) { // cancelled by program return; @@ -1918,7 +1826,7 @@ void wxGenericTreeCtrl::Collapse(const wxTreeItemId& itemId) #if 0 // TODO why should items be collapsed recursively? wxArrayGenericTreeItems& children = item->GetChildren(); - size_t count = children.GetCount(); + size_t count = children.Count(); for ( size_t n = 0; n < count; n++ ) { Collapse(children[n]); @@ -1929,8 +1837,8 @@ void wxGenericTreeCtrl::Collapse(const wxTreeItemId& itemId) RefreshSubtree(item); - event.SetEventType(wxEVT_TREE_ITEM_COLLAPSED); - GetEventHandler()->ProcessEvent( event ); + event.SetEventType(wxEVT_COMMAND_TREE_ITEM_COLLAPSED); + ProcessEvent( event ); } void wxGenericTreeCtrl::CollapseAndReset(const wxTreeItemId& item) @@ -1961,20 +1869,6 @@ void wxGenericTreeCtrl::Unselect() } } -void wxGenericTreeCtrl::ClearFocusedItem() -{ - wxTreeItemId item = GetFocusedItem(); - if ( item.IsOk() ) - SelectItem(item, false); -} - -void wxGenericTreeCtrl::SetFocusedItem(const wxTreeItemId& item) -{ - wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); - - SelectItem(item, true); -} - void wxGenericTreeCtrl::UnselectAllChildren(wxGenericTreeItem *item) { if (item->IsSelected()) @@ -1986,7 +1880,7 @@ void wxGenericTreeCtrl::UnselectAllChildren(wxGenericTreeItem *item) if (item->HasChildren()) { wxArrayGenericTreeItems& children = item->GetChildren(); - size_t count = children.GetCount(); + size_t count = children.Count(); for ( size_t n = 0; n < count; ++n ) { UnselectAllChildren(children[n]); @@ -2005,52 +1899,13 @@ void wxGenericTreeCtrl::UnselectAll() } } -void wxGenericTreeCtrl::SelectChildren(const wxTreeItemId& parent) -{ - wxCHECK_RET( HasFlag(wxTR_MULTIPLE), - "this only works with multiple selection controls" ); - - UnselectAll(); - - if ( !HasChildren(parent) ) - return; - - - wxArrayGenericTreeItems& - children = ((wxGenericTreeItem*) parent.m_pItem)->GetChildren(); - size_t count = children.GetCount(); - - wxGenericTreeItem * - item = (wxGenericTreeItem*) ((wxTreeItemId)children[0]).m_pItem; - wxTreeEvent event(wxEVT_TREE_SEL_CHANGING, this, item); - event.m_itemOld = m_current; - - if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) - return; - - for ( size_t n = 0; n < count; ++n ) - { - m_current = m_key_current = children[n]; - m_current->SetHilight(true); - RefreshSelected(); - } - - - event.SetEventType(wxEVT_TREE_SEL_CHANGED); - GetEventHandler()->ProcessEvent( event ); -} - - // Recursive function ! // To stop we must have crt_itemGetParent(); @@ -2061,20 +1916,16 @@ wxGenericTreeCtrl::TagNextChildren(wxGenericTreeItem *crt_item, int index = children.Index(crt_item); wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent? - size_t count = children.GetCount(); + size_t count = children.Count(); for (size_t n=(size_t)(index+1); nSetHilight(select); RefreshLine(crt_item); @@ -2082,11 +1933,10 @@ wxGenericTreeCtrl::TagAllChildrenUntilLast(wxGenericTreeItem *crt_item, if (crt_item==last_item) return true; - // We should leave the not shown children of collapsed items alone. - if (crt_item->HasChildren() && crt_item->IsExpanded()) + if (crt_item->HasChildren()) { wxArrayGenericTreeItems& children = crt_item->GetChildren(); - size_t count = children.GetCount(); + size_t count = children.Count(); for ( size_t n = 0; n < count; ++n ) { if (TagAllChildrenUntilLast(children[n], last_item, select)) @@ -2097,9 +1947,7 @@ wxGenericTreeCtrl::TagAllChildrenUntilLast(wxGenericTreeItem *crt_item, return false; } -void -wxGenericTreeCtrl::SelectItemRange(wxGenericTreeItem *item1, - wxGenericTreeItem *item2) +void wxGenericTreeCtrl::SelectItemRange(wxGenericTreeItem *item1, wxGenericTreeItem *item2) { m_select_me = NULL; @@ -2146,7 +1994,7 @@ void wxGenericTreeCtrl::DoSelectItem(const wxTreeItemId& itemId, return; } - wxTreeEvent event(wxEVT_TREE_SEL_CHANGING, this, item); + wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); event.m_itemOld = m_current; // TODO : Here we don't send any selection mode yet ! @@ -2174,8 +2022,7 @@ void wxGenericTreeCtrl::DoSelectItem(const wxTreeItemId& itemId, { if ( !m_current ) { - m_current = - m_key_current = (wxGenericTreeItem*) GetRootItem().m_pItem; + m_current = m_key_current = (wxGenericTreeItem*) GetRootItem().m_pItem; } // don't change the mark (m_current) @@ -2199,7 +2046,7 @@ void wxGenericTreeCtrl::DoSelectItem(const wxTreeItemId& itemId, // selection is set EnsureVisible( itemId ); - event.SetEventType(wxEVT_TREE_SEL_CHANGED); + event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED); GetEventHandler()->ProcessEvent( event ); } @@ -2210,19 +2057,19 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId, bool select) if ( select ) { - if ( !item->IsSelected() ) + if (!item->IsSelected()) DoSelectItem(itemId, !HasFlag(wxTR_MULTIPLE)); } else // deselect { - wxTreeEvent event(wxEVT_TREE_SEL_CHANGING, this, item); + wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) return; item->SetHilight(false); RefreshLine(item); - event.SetEventType(wxEVT_TREE_SEL_CHANGED); + event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED); GetEventHandler()->ProcessEvent( event ); } } @@ -2252,7 +2099,7 @@ size_t wxGenericTreeCtrl::GetSelections(wxArrayTreeItemIds &array) const } //else: the tree is empty, so no selections - return array.GetCount(); + return array.Count(); } void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item) @@ -2290,52 +2137,56 @@ void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item) void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) { - if (!item.IsOk()) - return; + if (!item.IsOk()) return; - // update the control before scrolling it + // We have to call this here because the label in + // question might just have been added and no screen + // update taken place. if (m_dirty) - { -#if defined( __WXMSW__ ) +#if defined( __WXMSW__ ) || defined(__WXMAC__) Update(); -#elif defined(__WXMAC__) - Update(); - DoDirtyProcessing(); #else DoDirtyProcessing(); #endif - } - wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; - int itemY = gitem->GetY(); + // now scroll to the item + int item_y = gitem->GetY(); int start_x = 0; int start_y = 0; GetViewStart( &start_x, &start_y ); + start_y *= PIXELS_PER_UNIT; - const int clientHeight = GetClientSize().y; + int client_h = 0; + int client_w = 0; + GetClientSize( &client_w, &client_h ); - const int itemHeight = GetLineHeight(gitem) + 2; - - if ( itemY + itemHeight > start_y*PIXELS_PER_UNIT + clientHeight ) + if (item_y < start_y+3) { - // need to scroll down by enough to show this item fully - itemY += itemHeight - clientHeight; - - // because itemY below will be divided by PIXELS_PER_UNIT it may - // be rounded down, with the result of the item still only being - // partially visible, so make sure we are rounding up - itemY += PIXELS_PER_UNIT - 1; + // going down + int x = 0; + int y = 0; + m_anchor->GetSize( x, y, this ); + y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + int x_pos = GetScrollPos( wxHORIZONTAL ); + // Item should appear at top + SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, item_y/PIXELS_PER_UNIT ); } - else if ( itemY > start_y*PIXELS_PER_UNIT ) + else if (item_y+GetLineHeight(gitem) > start_y+client_h) { - // item is already fully visible, don't do anything - return; + // going up + int x = 0; + int y = 0; + m_anchor->GetSize( x, y, this ); + y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + item_y += PIXELS_PER_UNIT+2; + int x_pos = GetScrollPos( wxHORIZONTAL ); + // Item should appear at bottom + SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, (item_y+GetLineHeight(gitem)-client_h)/PIXELS_PER_UNIT ); } - //else: scroll up to make this item the top one displayed - - Scroll(-1, itemY/PIXELS_PER_UNIT); } // FIXME: tree sorting functions are not reentrant and not MT-safe! @@ -2344,8 +2195,7 @@ static wxGenericTreeCtrl *s_treeBeingSorted = NULL; static int LINKAGEMODE tree_ctrl_compare_func(wxGenericTreeItem **item1, wxGenericTreeItem **item2) { - wxCHECK_MSG( s_treeBeingSorted, 0, - "bug in wxGenericTreeCtrl::SortChildren()" ); + wxCHECK_MSG( s_treeBeingSorted, 0, wxT("bug in wxGenericTreeCtrl::SortChildren()") ); return s_treeBeingSorted->OnCompareItems(*item1, *item2); } @@ -2360,7 +2210,7 @@ void wxGenericTreeCtrl::SortChildren(const wxTreeItemId& itemId) wxT("wxGenericTreeCtrl::SortChildren is not reentrant") ); wxArrayGenericTreeItems& children = item->GetChildren(); - if ( children.GetCount() > 1 ) + if ( children.Count() > 1 ) { m_dirty = true; @@ -2390,20 +2240,6 @@ void wxGenericTreeCtrl::CalculateLineHeight() } } - if ( m_imageListState ) - { - // Calculate a m_lineHeight value from the state Image sizes. - // May be toggle off. Then wxGenericTreeCtrl will spread when - // necessary (which might look ugly). - int n = m_imageListState->GetImageCount(); - for (int i = 0; i < n ; i++) - { - int width = 0, height = 0; - m_imageListState->GetSize(i, width, height); - if (height > m_lineHeight) m_lineHeight = height; - } - } - if (m_imageListButtons) { // Calculate a m_lineHeight value from the Button image sizes. @@ -2445,15 +2281,6 @@ void wxGenericTreeCtrl::SetStateImageList(wxImageList *imageList) if (m_ownsImageListState) delete m_imageListState; m_imageListState = imageList; m_ownsImageListState = false; - m_dirty = true; - - if (m_anchor) - m_anchor->RecursiveResetSize(); - - // Don't do any drawing if we're setting the list to NULL, - // since we may be in the process of deleting the tree control. - if (imageList) - CalculateLineHeight(); } void wxGenericTreeCtrl::SetButtonsImageList(wxImageList *imageList) @@ -2489,9 +2316,7 @@ void wxGenericTreeCtrl::AdjustMyScrollbars() x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels int x_pos = GetScrollPos( wxHORIZONTAL ); int y_pos = GetScrollPos( wxVERTICAL ); - SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, - x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, - x_pos, y_pos ); + SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, y_pos ); } else { @@ -2510,7 +2335,6 @@ int wxGenericTreeCtrl::GetLineHeight(wxGenericTreeItem *item) const void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { item->SetFont(this, dc); - item->CalculateSize(this, dc); wxCoord text_h = item->GetTextHeight(); @@ -2520,7 +2344,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { if ( m_imageListNormal ) { - m_imageListNormal->GetSize(image, image_w, image_h); + m_imageListNormal->GetSize( image, image_w, image_h ); image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; } else @@ -2529,24 +2353,6 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) } } - int state_h = 0, state_w = 0; - int state = item->GetState(); - if ( state != wxTREE_ITEMSTATE_NONE ) - { - if ( m_imageListState ) - { - m_imageListState->GetSize(state, state_w, state_h); - if ( image_w != 0 ) - state_w += MARGIN_BETWEEN_STATE_AND_IMAGE; - else - state_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; - } - else - { - state = wxTREE_ITEMSTATE_NONE; - } - } - int total_h = GetLineHeight(item); bool drawItemBackground = false, hasBgColour = false; @@ -2570,17 +2376,19 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { colBg = GetBackgroundColour(); } - dc.SetBrush(wxBrush(colBg, wxBRUSHSTYLE_SOLID)); + dc.SetBrush(wxBrush(colBg, wxSOLID)); } int offset = HasFlag(wxTR_ROW_LINES) ? 1 : 0; if ( HasFlag(wxTR_FULL_ROW_HIGHLIGHT) ) { - int x, w, h; - x=0; + int x = 0, w = 0, h = 0; GetVirtualSize(&w, &h); wxRect rect( x, item->GetY()+offset, w, total_h-offset); +#if !defined(__WXGTK20__) && !defined(__WXMAC__) + dc.DrawRectangle(rect); +#else if (!item->IsSelected()) { dc.DrawRectangle(rect); @@ -2589,30 +2397,26 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { int flags = wxCONTROL_SELECTED; if (m_hasFocus -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON // TODO CS +#ifdef __WXMAC__ && IsControlActive( (ControlRef)GetHandle() ) #endif ) flags |= wxCONTROL_FOCUSED; if ((item == m_current) && (m_hasFocus)) flags |= wxCONTROL_CURRENT; - - wxRendererNative::Get(). - DrawItemSelectionRect(this, dc, rect, flags); + wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags ); } +#endif } - else // no full row highlight + else { - if ( item->IsSelected() && - (state != wxTREE_ITEMSTATE_NONE || image != NO_IMAGE) ) + if ( item->IsSelected() && image != NO_IMAGE ) { - // If it's selected, and there's an state image or normal image, - // then we should take care to leave the area under the image - // painted in the background colour. - wxRect rect( item->GetX() + state_w + image_w - 2, - item->GetY() + offset, - item->GetWidth() - state_w - image_w + 2, - total_h - offset ); + // If it's selected, and there's an image, then we should + // take care to leave the area under the image painted in the + // background colour. + wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset, + item->GetWidth() - image_w + 2, total_h-offset ); #if !defined(__WXGTK20__) && !defined(__WXMAC__) dc.DrawRectangle( rect ); #else @@ -2624,8 +2428,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) flags |= wxCONTROL_FOCUSED; if ((item == m_current) && (m_hasFocus)) flags |= wxCONTROL_CURRENT; - wxRendererNative::Get(). - DrawItemSelectionRect(this, dc, rect, flags); + wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags ); #endif } // On GTK+ 2, drawing a 'normal' background is wrong for themes that @@ -2633,15 +2436,16 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) // except for custom item backgrounds, works for both kinds of theme. else if (drawItemBackground) { - wxRect rect( item->GetX() + state_w + image_w - 2, - item->GetY() + offset, - item->GetWidth() - state_w - image_w + 2, - total_h - offset ); + wxRect rect( item->GetX()-2, item->GetY()+offset, + item->GetWidth()+2, total_h-offset ); +#if !defined(__WXGTK20__) && !defined(__WXMAC__) + dc.DrawRectangle( rect ); +#else if ( hasBgColour ) { dc.DrawRectangle( rect ); } - else // no specific background colour + else { rect.x -= 1; rect.width += 2; @@ -2651,86 +2455,34 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) flags |= wxCONTROL_FOCUSED; if ((item == m_current) && (m_hasFocus)) flags |= wxCONTROL_CURRENT; - wxRendererNative::Get(). - DrawItemSelectionRect(this, dc, rect, flags); + wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags ); } +#endif } } - if ( state != wxTREE_ITEMSTATE_NONE ) - { - dc.SetClippingRegion( item->GetX(), item->GetY(), state_w, total_h ); - m_imageListState->Draw( state, dc, - item->GetX(), - item->GetY() + - (total_h > state_h ? (total_h-state_h)/2 - : 0), - wxIMAGELIST_DRAW_TRANSPARENT ); - dc.DestroyClippingRegion(); - } - if ( image != NO_IMAGE ) { - dc.SetClippingRegion(item->GetX() + state_w, item->GetY(), - image_w, total_h); + dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, total_h ); m_imageListNormal->Draw( image, dc, - item->GetX() + state_w, - item->GetY() + - (total_h > image_h ? (total_h-image_h)/2 - : 0), + item->GetX(), + item->GetY() +((total_h > image_h)?((total_h-image_h)/2):0), wxIMAGELIST_DRAW_TRANSPARENT ); dc.DestroyClippingRegion(); } - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); + dc.SetBackgroundMode(wxTRANSPARENT); int extraH = (total_h > text_h) ? (total_h - text_h)/2 : 0; dc.DrawText( item->GetText(), - (wxCoord)(state_w + image_w + item->GetX()), + (wxCoord)(image_w + item->GetX()), (wxCoord)(item->GetY() + extraH)); // restore normal font dc.SetFont( m_normalFont ); - - if (item == m_dndEffectItem) - { - dc.SetPen( *wxBLACK_PEN ); - // DnD visual effects - switch (m_dndEffect) - { - case BorderEffect: - { - dc.SetBrush(*wxTRANSPARENT_BRUSH); - int w = item->GetWidth() + 2; - int h = total_h + 2; - dc.DrawRectangle( item->GetX() - 1, item->GetY() - 1, w, h); - break; - } - case AboveEffect: - { - int x = item->GetX(), - y = item->GetY(); - dc.DrawLine( x, y, x + item->GetWidth(), y); - break; - } - case BelowEffect: - { - int x = item->GetX(), - y = item->GetY(); - y += total_h - 1; - dc.DrawLine( x, y, x + item->GetWidth(), y); - break; - } - case NoEffect: - break; - } - } } -void -wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, - wxDC &dc, - int level, - int &y) +// Now y stands for the top of the item, whereas it used to stand for middle ! +void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ) { int x = level*m_indent; if (!HasFlag(wxTR_HIDE_ROOT)) @@ -2742,7 +2494,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, // always expand hidden root int origY = y; wxArrayGenericTreeItems& children = item->GetChildren(); - int count = children.GetCount(); + int count = children.Count(); if (count > 0) { int n = 0, oldY; @@ -2751,8 +2503,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, PaintLevel(children[n], dc, 1, y); } while (++n < count); - if ( !HasFlag(wxTR_NO_LINES) && HasFlag(wxTR_LINES_AT_ROOT) - && count > 0 ) + if (!HasFlag(wxTR_NO_LINES) && HasFlag(wxTR_LINES_AT_ROOT) && count > 0) { // draw line down to last child origY += GetLineHeight(children[0])>>1; @@ -2786,7 +2537,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, wxColour colText; if ( item->IsSelected() -#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON // TODO CS +#ifdef __WXMAC__ // On wxMac, if the tree doesn't have the focus we draw an empty // rectangle, so we want to make sure that the text is visible // against the normal background, not the highlightbackground, so @@ -2798,10 +2549,10 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, #ifdef __WXMAC__ colText = *wxWHITE; #else - if (m_hasFocus) - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - else - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); + if (m_hasFocus) + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); + else + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); #endif } else @@ -2894,7 +2645,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, if (item->IsExpanded()) { wxArrayGenericTreeItems& children = item->GetChildren(); - int count = children.GetCount(); + int count = children.Count(); if (count > 0) { int n = 0, oldY; @@ -2910,21 +2661,20 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item, oldY += GetLineHeight(children[n-1])>>1; if (HasButtons()) y_mid += 5; - // Only draw the portion of the line that is visible, in case - // it is huge + // Only draw the portion of the line that is visible, in case it is huge wxCoord xOrigin=0, yOrigin=0, width, height; dc.GetDeviceOrigin(&xOrigin, &yOrigin); yOrigin = abs(yOrigin); GetClientSize(&width, &height); - // Move end points to the beginning/end of the view? + // Move end points to the begining/end of the view? if (y_mid < yOrigin) y_mid = yOrigin; if (oldY > yOrigin + height) oldY = yOrigin + height; - // after the adjustments if y_mid is larger than oldY then the - // line isn't visible at all so don't draw anything + // after the adjustments if y_mid is larger than oldY then the line + // isn't visible at all so don't draw anything if (y_mid < oldY) dc.DrawLine(x, y_mid, x, oldY); } @@ -2948,7 +2698,7 @@ void wxGenericTreeCtrl::DrawDropEffect(wxGenericTreeItem *item) DrawLine(item, !m_dropEffectAboveItem ); } - SetCursor(*wxSTANDARD_CURSOR); + SetCursor(wxCURSOR_BULLSEYE); } else { @@ -2959,49 +2709,39 @@ void wxGenericTreeCtrl::DrawDropEffect(wxGenericTreeItem *item) void wxGenericTreeCtrl::DrawBorder(const wxTreeItemId &item) { - wxCHECK_RET( item.IsOk(), "invalid item in wxGenericTreeCtrl::DrawLine" ); + wxCHECK_RET( item.IsOk(), _T("invalid item in wxGenericTreeCtrl::DrawLine") ); wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem; - if (m_dndEffect == NoEffect) - { - m_dndEffect = BorderEffect; - m_dndEffectItem = i; - } - else - { - m_dndEffect = NoEffect; - m_dndEffectItem = NULL; - } + wxClientDC dc(this); + PrepareDC( dc ); + dc.SetLogicalFunction(wxINVERT); + dc.SetBrush(*wxTRANSPARENT_BRUSH); - wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); - CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - RefreshRect( rect ); + int w = i->GetWidth() + 2; + int h = GetLineHeight(i) + 2; + + dc.DrawRectangle( i->GetX() - 1, i->GetY() - 1, w, h); } void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) { - wxCHECK_RET( item.IsOk(), "invalid item in wxGenericTreeCtrl::DrawLine" ); + wxCHECK_RET( item.IsOk(), _T("invalid item in wxGenericTreeCtrl::DrawLine") ); wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem; - if (m_dndEffect == NoEffect) + wxClientDC dc(this); + PrepareDC( dc ); + dc.SetLogicalFunction(wxINVERT); + + int x = i->GetX(), + y = i->GetY(); + if ( below ) { - if (below) - m_dndEffect = BelowEffect; - else - m_dndEffect = AboveEffect; - m_dndEffectItem = i; - } - else - { - m_dndEffect = NoEffect; - m_dndEffectItem = NULL; + y += GetLineHeight(i) - 1; } - wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); - CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); - RefreshRect( rect ); + dc.DrawLine( x, y, x + i->GetWidth(), y); } // ----------------------------------------------------------------------------- @@ -3055,19 +2795,16 @@ void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &event ) event.Skip(); } -void wxGenericTreeCtrl::OnKeyDown( wxKeyEvent &event ) -{ - // send a tree event - wxTreeEvent te( wxEVT_TREE_KEY_DOWN, this); - te.m_evtKey = event; - if ( GetEventHandler()->ProcessEvent( te ) ) - return; - - event.Skip(); -} - void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) { + wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, this); + te.m_evtKey = event; + if ( GetEventHandler()->ProcessEvent( te ) ) + { + // intercepted by the user code + return; + } + if ( (m_current == 0) || (m_key_current == 0) ) { event.Skip(); @@ -3101,21 +2838,6 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) // end : go to last item without opening parents // alnum : start or continue searching for the item with this prefix int keyCode = event.GetKeyCode(); - -#ifdef __WXOSX__ - // Make the keys work as they do in the native control: - // right => expand - // left => collapse if current item is expanded - if (keyCode == WXK_RIGHT) - { - keyCode = '+'; - } - else if (keyCode == WXK_LEFT && IsExpanded(m_current)) - { - keyCode = '-'; - } -#endif // __WXOSX__ - switch ( keyCode ) { case '+': @@ -3146,17 +2868,14 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) case WXK_MENU: { - // Use the item's bounding rectangle to determine position for - // the event + // Use the item's bounding rectangle to determine position for the event wxRect ItemRect; GetBoundingRect(m_current, ItemRect, true); - wxTreeEvent - eventMenu(wxEVT_TREE_ITEM_MENU, this, m_current); + wxTreeEvent eventMenu(wxEVT_COMMAND_TREE_ITEM_MENU, this, m_current); // Use the left edge, vertical middle eventMenu.m_pointDrag = wxPoint(ItemRect.GetX(), - ItemRect.GetY() + - ItemRect.GetHeight() / 2); + ItemRect.GetY() + ItemRect.GetHeight() / 2); GetEventHandler()->ProcessEvent( eventMenu ); } break; @@ -3165,8 +2884,7 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) case WXK_RETURN: if ( !event.HasModifiers() ) { - wxTreeEvent - eventAct(wxEVT_TREE_ITEM_ACTIVATED, this, m_current); + wxTreeEvent eventAct(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, this, m_current); GetEventHandler()->ProcessEvent( eventAct ); } @@ -3194,15 +2912,12 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) { wxTreeItemIdValue cookie; wxTreeItemId current = m_key_current; - // TODO: Huh? If we get here, we'd better be the first - // child of our parent. How else could it be? + // TODO: Huh? If we get here, we'd better be the first child of our parent. How else could it be? if (current == GetFirstChild( prev, cookie )) { // otherwise we return to where we came from - DoSelectItem(prev, - unselect_others, - extended_select); - m_key_current = (wxGenericTreeItem*) prev.m_pItem; + DoSelectItem( prev, unselect_others, extended_select ); + m_key_current= (wxGenericTreeItem*) prev.m_pItem; break; } } @@ -3332,29 +3047,22 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) if ( !event.HasModifiers() && ((keyCode >= '0' && keyCode <= '9') || (keyCode >= 'a' && keyCode <= 'z') || - (keyCode >= 'A' && keyCode <= 'Z') || - (keyCode == '_'))) + (keyCode >= 'A' && keyCode <= 'Z' ))) { // find the next item starting with the given prefix wxChar ch = (wxChar)keyCode; - wxTreeItemId id; - // if the same character is typed multiple times then go to the - // next entry starting with that character instead of searching - // for an item starting with multiple copies of this character, - // this is more useful and is how it works under Windows. - if ( m_findPrefix.length() == 1 && m_findPrefix[0] == ch ) + wxTreeItemId id = FindItem(m_current, m_findPrefix + ch); + if ( !id.IsOk() ) { - id = FindItem(m_current, ch); - } - else - { - const wxString newPrefix(m_findPrefix + ch); - id = FindItem(m_current, newPrefix); - if ( id.IsOk() ) - m_findPrefix = newPrefix; + // no such item + break; } + SelectItem(id); + + m_findPrefix += ch; + // also start the timer to reset the current prefix if the user // doesn't press any more alnum keys soon -- we wouldn't want // to use this prefix for a new item search @@ -3363,32 +3071,7 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) m_findTimer = new wxTreeFindTimer(this); } - // Notice that we should start the timer even if we didn't find - // anything to make sure we reset the search state later. m_findTimer->Start(wxTreeFindTimer::DELAY, wxTIMER_ONE_SHOT); - - if ( id.IsOk() ) - { - SelectItem(id); - - // Reset the bell flag if it had been temporarily disabled - // before. - if ( m_findBell ) - m_findBell = 1; - } - else // No such item - { - // Signal it with a bell if enabled. - if ( m_findBell == 1 ) - { - ::wxBell(); - - // Disable it for the next unsuccessful match, we only - // beep once, this is usually enough and continuing to - // do it would be annoying. - m_findBell = -1; - } - } } else { @@ -3430,35 +3113,25 @@ bool wxGenericTreeCtrl::GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly) const { - wxCHECK_MSG( item.IsOk(), false, - "invalid item in wxGenericTreeCtrl::GetBoundingRect" ); + wxCHECK_MSG( item.IsOk(), false, _T("invalid item in wxGenericTreeCtrl::GetBoundingRect") ); wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem; if ( textOnly ) { - int image_h = 0, image_w = 0; - int image = ((wxGenericTreeItem*) item.m_pItem)->GetCurrentImage(); - if ( image != NO_IMAGE && m_imageListNormal ) + rect.x = i->GetX(); + rect.width = i->GetWidth(); + + if ( m_imageListNormal ) { - m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; + int image = ((wxGenericTreeItem*) item.m_pItem)->GetCurrentImage(); + if ( image != NO_IMAGE ) + { + int image_w, image_h; + m_imageListNormal->GetSize( image, image_w, image_h ); + rect.width += image_w + MARGIN_BETWEEN_IMAGE_AND_TEXT; + } } - - int state_h = 0, state_w = 0; - int state = ((wxGenericTreeItem*) item.m_pItem)->GetState(); - if ( state != wxTREE_ITEMSTATE_NONE && m_imageListState ) - { - m_imageListState->GetSize( state, state_w, state_h ); - if ( image_w != 0 ) - state_w += MARGIN_BETWEEN_STATE_AND_IMAGE; - else - state_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; - } - - rect.x = i->GetX() + state_w + image_w; - rect.width = i->GetWidth() - state_w - image_w; - } else // the entire line { @@ -3478,11 +3151,11 @@ bool wxGenericTreeCtrl::GetBoundingRect(const wxTreeItemId& item, wxTextCtrl *wxGenericTreeCtrl::EditLabel(const wxTreeItemId& item, wxClassInfo * WXUNUSED(textCtrlClass)) { - wxCHECK_MSG( item.IsOk(), NULL, wxT("can't edit an invalid item") ); + wxCHECK_MSG( item.IsOk(), NULL, _T("can't edit an invalid item") ); wxGenericTreeItem *itemEdit = (wxGenericTreeItem *)item.m_pItem; - wxTreeEvent te(wxEVT_TREE_BEGIN_LABEL_EDIT, this, itemEdit); + wxTreeEvent te(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, this, itemEdit); if ( GetEventHandler()->ProcessEvent( te ) && !te.IsAllowed() ) { // vetoed by user @@ -3493,7 +3166,11 @@ wxTextCtrl *wxGenericTreeCtrl::EditLabel(const wxTreeItemId& item, // question might just have been added and no screen // update taken place. if ( m_dirty ) +#if defined( __WXMSW__ ) || defined(__WXMAC__) + Update(); +#else DoDirtyProcessing(); +#endif // TODO: use textCtrlClass here to create the control of correct class m_textCtrl = new wxTreeTextCtrl(this, itemEdit); @@ -3514,16 +3191,15 @@ wxTextCtrl* wxGenericTreeCtrl::GetEditControl() const void wxGenericTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges) { - if (m_textCtrl) - { - m_textCtrl->EndEdit(discardChanges); - } + wxCHECK_RET( m_textCtrl, _T("not editing label") ); + + m_textCtrl->EndEdit(discardChanges); } bool wxGenericTreeCtrl::OnRenameAccept(wxGenericTreeItem *item, const wxString& value) { - wxTreeEvent le(wxEVT_TREE_END_LABEL_EDIT, this, item); + wxTreeEvent le(wxEVT_COMMAND_TREE_END_LABEL_EDIT, this, item); le.m_label = value; le.m_editCancelled = false; @@ -3533,7 +3209,7 @@ bool wxGenericTreeCtrl::OnRenameAccept(wxGenericTreeItem *item, void wxGenericTreeCtrl::OnRenameCancelled(wxGenericTreeItem *item) { // let owner know that the edit was cancelled - wxTreeEvent le(wxEVT_TREE_END_LABEL_EDIT, this, item); + wxTreeEvent le(wxEVT_COMMAND_TREE_END_LABEL_EDIT, this, item); le.m_label = wxEmptyString; le.m_editCancelled = true; @@ -3590,32 +3266,15 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) // Determines what item we are hovering over and need a tooltip for wxTreeItemId hoverItem = thisItem; - // We do not want a tooltip if we are dragging, or if the rename timer is - // running - if ( underMouseChanged && - hoverItem.IsOk() && - !m_isDragging && - (!m_renameTimer || !m_renameTimer->IsRunning()) ) + // We do not want a tooltip if we are dragging, or if the rename timer is running + if (underMouseChanged && hoverItem.IsOk() && !m_isDragging && (!m_renameTimer || !m_renameTimer->IsRunning())) { // Ask the tree control what tooltip (if any) should be shown - wxTreeEvent - hevent(wxEVT_TREE_ITEM_GETTOOLTIP, this, hoverItem); + wxTreeEvent hevent(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, this, hoverItem); - // setting a tooltip upon leaving a view is getting the tooltip displayed - // on the neighbouring view ... -#ifdef __WXOSX__ - if ( event.Leaving() ) - SetToolTip(NULL); - else -#endif - if ( GetEventHandler()->ProcessEvent(hevent) ) + if ( GetEventHandler()->ProcessEvent(hevent) && hevent.IsAllowed() ) { - // If the user permitted the tooltip change, update it, otherwise - // remove any old tooltip we might have. - if ( hevent.IsAllowed() ) - SetToolTip(hevent.m_label); - else - SetToolTip(NULL); + SetToolTip(hevent.m_label); } } #endif @@ -3654,8 +3313,8 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) } wxEventType command = event.RightIsDown() - ? wxEVT_TREE_BEGIN_RDRAG - : wxEVT_TREE_BEGIN_DRAG; + ? wxEVT_COMMAND_TREE_BEGIN_RDRAG + : wxEVT_COMMAND_TREE_BEGIN_DRAG; wxTreeEvent nevent(command, this, m_current); nevent.SetPoint(CalcScrolledPosition(pt)); @@ -3703,8 +3362,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__) Update(); #else - // TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI) - // instead (needs to be tested!) wxYieldIfNeeded(); #endif } @@ -3720,38 +3377,34 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) { m_oldSelection->SetHilight(true); RefreshLine(m_oldSelection); - m_oldSelection = NULL; + m_oldSelection = (wxGenericTreeItem *)NULL; } // generate the drag end event - wxTreeEvent eventEndDrag(wxEVT_TREE_END_DRAG, this, item); + wxTreeEvent eventEndDrag(wxEVT_COMMAND_TREE_END_DRAG, this, item); eventEndDrag.m_pointDrag = CalcScrolledPosition(pt); (void)GetEventHandler()->ProcessEvent(eventEndDrag); m_isDragging = false; - m_dropTarget = NULL; + m_dropTarget = (wxGenericTreeItem *)NULL; SetCursor(m_oldCursor); -#if defined( __WXMSW__ ) || defined(__WXMAC__) || defined(__WXGTK20__) +#if defined( __WXMSW__ ) || defined(__WXMAC__) Update(); #else - // TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI) - // instead (needs to be tested!) wxYieldIfNeeded(); #endif } else { // If we got to this point, we are not dragging or moving the mouse. - // Because the code in carbon/toplevel.cpp will only set focus to the - // tree if we skip for EVT_LEFT_DOWN, we MUST skip this event here for - // focus to work. + // Because the code in carbon/toplevel.cpp will only set focus to the tree + // if we skip for EVT_LEFT_DOWN, we MUST skip this event here for focus to work. // We skip even if we didn't hit an item because we still should - // restore focus to the tree control even if we didn't exactly hit an - // item. + // restore focus to the tree control even if we didn't exactly hit an item. if ( event.LeftDown() ) { event.Skip(); @@ -3766,40 +3419,30 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) if ( event.RightDown() ) { // If the item is already selected, do not update the selection. - // Multi-selections should not be cleared if a selected item is - // clicked. + // Multi-selections should not be cleared if a selected item is clicked. if (!IsSelected(item)) { DoSelectItem(item, true, false); } - wxTreeEvent - nevent(wxEVT_TREE_ITEM_RIGHT_CLICK, this, item); + wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, this, item); nevent.m_pointDrag = CalcScrolledPosition(pt); event.Skip(!GetEventHandler()->ProcessEvent(nevent)); // Consistent with MSW (for now), send the ITEM_MENU *after* - // the RIGHT_CLICK event. TODO: This behaviour may change. - wxTreeEvent nevent2(wxEVT_TREE_ITEM_MENU, this, item); + // the RIGHT_CLICK event. TODO: This behavior may change. + wxTreeEvent nevent2(wxEVT_COMMAND_TREE_ITEM_MENU, this, item); nevent2.m_pointDrag = CalcScrolledPosition(pt); GetEventHandler()->ProcessEvent(nevent2); } else if ( event.MiddleDown() ) { - wxTreeEvent - nevent(wxEVT_TREE_ITEM_MIDDLE_CLICK, this, item); + wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, this, item); nevent.m_pointDrag = CalcScrolledPosition(pt); event.Skip(!GetEventHandler()->ProcessEvent(nevent)); } else if ( event.LeftUp() ) { - if (flags & wxTREE_HITTEST_ONITEMSTATEICON) - { - wxTreeEvent - nevent(wxEVT_TREE_STATE_IMAGE_CLICK, this, item); - GetEventHandler()->ProcessEvent(nevent); - } - // this facilitates multiple-item drag-and-drop if ( /* item && */ HasFlag(wxTR_MULTIPLE)) @@ -3837,19 +3480,11 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) m_lastOnSame = false; } } - else // !RightDown() && !MiddleDown() && !LeftUp() + else // !RightDown() && !MiddleDown() && !LeftUp() ==> LeftDown() || LeftDClick() { - // ==> LeftDown() || LeftDClick() if ( event.LeftDown() ) { - // If we click on an already selected item but do it to return - // the focus to the control, it shouldn't start editing the - // item label because it's too easy to start editing - // accidentally (and also because nobody else does it like - // this). So only set this flag, used to decide whether we - // should start editing the label later, if we already have - // focus. - m_lastOnSame = item == m_current && HasFocus(); + m_lastOnSame = item == m_current; } if ( flags & wxTREE_HITTEST_ONITEMBUTTON ) @@ -3878,9 +3513,7 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) EventFlagsToSelType(GetWindowStyleFlag(), event.ShiftDown(), event.CmdDown(), - is_multiple, - extended_select, - unselect_others); + is_multiple, extended_select, unselect_others); DoSelectItem(item, unselect_others, extended_select); } @@ -3897,8 +3530,7 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) m_lastOnSame = false; // send activate event first - wxTreeEvent - nevent(wxEVT_TREE_ITEM_ACTIVATED, this, item); + wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, this, item); nevent.m_pointDrag = CalcScrolledPosition(pt); if ( !GetEventHandler()->ProcessEvent( nevent ) ) { @@ -3937,11 +3569,15 @@ void wxGenericTreeCtrl::OnInternalIdle() DoDirtyProcessing(); } -void -wxGenericTreeCtrl::CalculateLevel(wxGenericTreeItem *item, - wxDC &dc, - int level, - int &y ) +void wxGenericTreeCtrl::CalculateSize( wxGenericTreeItem *WXUNUSED(item), wxDC &WXUNUSED(dc) ) +{ + // Should not be called anymore, keeping for ABI compatibility. +} + +// ----------------------------------------------------------------------------- +// for developper : y is now the top of the level +// not the middle of it ! +void wxGenericTreeCtrl::CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ) { int x = level*m_indent; if (!HasFlag(wxTR_HIDE_ROOT)) @@ -3970,7 +3606,7 @@ wxGenericTreeCtrl::CalculateLevel(wxGenericTreeItem *item, Recurse: wxArrayGenericTreeItems& children = item->GetChildren(); - size_t n, count = children.GetCount(); + size_t n, count = children.Count(); ++level; for (n = 0; n < count; ++n ) CalculateLevel( children[n], dc, level, y ); // recurse @@ -3986,8 +3622,8 @@ void wxGenericTreeCtrl::CalculatePositions() dc.SetFont( m_normalFont ); dc.SetPen( m_dottedPen ); - //if(GetImageList() == NULL) - // m_lineHeight = (int)(dc.GetCharHeight() + 4); + + m_anchor->CalculateSize(this, dc); int y = 2; CalculateLevel( m_anchor, dc, 0, y ); // start recursion @@ -3995,13 +3631,13 @@ void wxGenericTreeCtrl::CalculatePositions() void wxGenericTreeCtrl::Refresh(bool eraseBackground, const wxRect *rect) { - if ( !IsFrozen() ) + if ( !m_freezeCount ) wxTreeCtrlBase::Refresh(eraseBackground, rect); } void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) { - if (m_dirty || IsFrozen() ) + if (m_dirty || m_freezeCount) return; wxSize client = GetClientSize(); @@ -4018,7 +3654,7 @@ void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) void wxGenericTreeCtrl::RefreshLine( wxGenericTreeItem *item ) { - if (m_dirty || IsFrozen() ) + if (m_dirty || m_freezeCount) return; wxRect rect; @@ -4031,7 +3667,7 @@ void wxGenericTreeCtrl::RefreshLine( wxGenericTreeItem *item ) void wxGenericTreeCtrl::RefreshSelected() { - if (IsFrozen()) + if (m_freezeCount) return; // TODO: this is awfully inefficient, we should keep the list of all @@ -4042,7 +3678,7 @@ void wxGenericTreeCtrl::RefreshSelected() void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) { - if (IsFrozen()) + if (m_freezeCount) return; if ( item->IsSelected() ) @@ -4056,14 +3692,19 @@ void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) } } -void wxGenericTreeCtrl::DoThaw() +void wxGenericTreeCtrl::Freeze() { - wxTreeCtrlBase::DoThaw(); + m_freezeCount++; +} - if ( m_dirty ) - DoDirtyProcessing(); - else +void wxGenericTreeCtrl::Thaw() +{ + wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") ); + + if ( --m_freezeCount == 0 ) + { Refresh(); + } } // ---------------------------------------------------------------------------- @@ -4090,24 +3731,11 @@ bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour) return true; } +// Process the tooltip event, to speed up event processing. +// Doesn't actually get a tooltip. void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event ) { -#if wxUSE_TOOLTIPS - wxTreeItemId itemId = event.GetItem(); - const wxGenericTreeItem* const pItem = (wxGenericTreeItem*)itemId.m_pItem; - - // Check if the item fits into the client area: - if ( pItem->GetX() + pItem->GetWidth() > GetClientSize().x ) - { - // If it doesn't, show its full text in the tooltip. - event.SetLabel(pItem->GetText()); - } - else -#endif // wxUSE_TOOLTIPS - { - // veto processing the event, nixing any tooltip - event.Veto(); - } + event.Veto(); } @@ -4135,9 +3763,23 @@ wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) #endif } +#if WXWIN_COMPATIBILITY_2_4 + +int wxGenericTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const +{ + return GetItemImage(item, wxTreeItemIcon_Selected); +} + +void wxGenericTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image) +{ + SetItemImage(item, image, wxTreeItemIcon_Selected); +} + +#endif // WXWIN_COMPATIBILITY_2_4 + void wxGenericTreeCtrl::DoDirtyProcessing() { - if (IsFrozen()) + if (m_freezeCount) return; m_dirty = false; diff --git a/Source/3rd Party/wx/src/generic/treelist.cpp b/Source/3rd Party/wx/src/generic/treelist.cpp deleted file mode 100644 index 73fbe6c46..000000000 --- a/Source/3rd Party/wx/src/generic/treelist.cpp +++ /dev/null @@ -1,1680 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/treelist.cpp -// Purpose: Generic wxTreeListCtrl implementation. -// Author: Vadim Zeitlin -// Created: 2011-08-19 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// Declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_TREELISTCTRL - -#ifndef WX_PRECOMP - #include "wx/dc.h" -#endif // WX_PRECOMP - -#include "wx/treelist.h" - -#include "wx/dataview.h" -#include "wx/renderer.h" -#include "wx/scopedarray.h" -#include "wx/scopedptr.h" - -// ---------------------------------------------------------------------------- -// Constants -// ---------------------------------------------------------------------------- - -const char wxTreeListCtrlNameStr[] = "wxTreeListCtrl"; - -const wxTreeListItem wxTLI_FIRST(reinterpret_cast(-1)); -const wxTreeListItem wxTLI_LAST(reinterpret_cast(-2)); - -// ---------------------------------------------------------------------------- -// wxTreeListModelNode: a node in the internal tree representation. -// ---------------------------------------------------------------------------- - -class wxTreeListModelNode -{ -public: - wxTreeListModelNode(wxTreeListModelNode* parent, - const wxString& text = wxString(), - int imageClosed = wxWithImages::NO_IMAGE, - int imageOpened = wxWithImages::NO_IMAGE, - wxClientData* data = NULL) - : m_text(text), - m_parent(parent) - { - m_child = - m_next = NULL; - - m_imageClosed = imageClosed; - m_imageOpened = imageOpened; - - m_checkedState = wxCHK_UNCHECKED; - - m_data = data; - - m_columnsTexts = NULL; - } - - // Destroying the node also (recursively) destroys its children. - ~wxTreeListModelNode() - { - for ( wxTreeListModelNode* node = m_child; node; ) - { - wxTreeListModelNode* child = node; - node = node->m_next; - delete child; - } - - delete m_data; - - delete [] m_columnsTexts; - } - - - // Public fields for the first column text and other simple attributes: - // there is no need to have accessors/mutators for those as there is no - // encapsulation anyhow, all of those are exposed in our public API. - wxString m_text; - - int m_imageClosed, - m_imageOpened; - - wxCheckBoxState m_checkedState; - - - // Accessors for the fields that are not directly exposed. - - // Client data is owned by us so delete the old value when setting the new - // one. - wxClientData* GetClientData() const { return m_data; } - void SetClientData(wxClientData* data) { delete m_data; m_data = data; } - - // Setting or getting the non-first column text. Getting is simple but you - // need to call HasColumnsTexts() first as the column data is only - // allocated on demand. And when setting the text we require to be given - // the total number of columns as we allocate the entire array at once, - // this is more efficient than using dynamically-expandable wxVector that - // we know won't be needed as the number of columns is usually fixed. But - // if it does change, our OnInsertColumn() must be called. - // - // Notice the presence of -1 everywhere in these methods: this is because - // the text for the first column is always stored in m_text and so we don't - // store it in m_columnsTexts. - - bool HasColumnsTexts() const { return m_columnsTexts != NULL; } - const wxString& GetColumnText(unsigned col) const - { - return m_columnsTexts[col - 1]; - } - - void SetColumnText(const wxString& text, unsigned col, unsigned numColumns) - { - if ( !m_columnsTexts ) - m_columnsTexts = new wxString[numColumns - 1]; - - m_columnsTexts[col - 1] = text; - } - - void OnInsertColumn(unsigned col, unsigned numColumns) - { - wxASSERT_MSG( col, "Shouldn't be called for the first column" ); - - // Nothing to do if we don't have any text. - if ( !m_columnsTexts ) - return; - - wxScopedArray oldTexts(m_columnsTexts); - m_columnsTexts = new wxString[numColumns - 1]; - - // In the loop below n is the index in the new column texts array and m - // is the index in the old one. - for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ ) - { - if ( n == col ) - { - // Leave the new array text initially empty and just adjust the - // index (to compensate for "m++" done by the loop anyhow). - m--; - } - else // Not the newly inserted column. - { - // Copy the old text value. - m_columnsTexts[n - 1] = oldTexts[m - 1]; - } - } - } - - void OnDeleteColumn(unsigned col, unsigned numColumns) - { - wxASSERT_MSG( col, "Shouldn't be called for the first column" ); - - if ( !m_columnsTexts ) - return; - - wxScopedArray oldTexts(m_columnsTexts); - m_columnsTexts = new wxString[numColumns - 2]; - for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ ) - { - if ( n == col ) - { - n--; - } - else // Not the deleted column. - { - m_columnsTexts[n - 1] = oldTexts[m - 1]; - } - } - } - - void OnClearColumns() - { - if ( m_columnsTexts ) - { - delete [] m_columnsTexts; - m_columnsTexts = NULL; - } - } - - - // Functions for modifying the tree. - - // Insert the given item as the first child of this one. The parent pointer - // must have been already set correctly at creation and we take ownership - // of the pointer and will delete it later. - void InsertChild(wxTreeListModelNode* child) - { - wxASSERT( child->m_parent == this ); - - // Our previous first child becomes the next sibling of the new child. - child->m_next = m_child; - m_child = child; - } - - // Insert the given item as our next sibling. As above, the item must have - // the correct parent pointer and we take ownership of it. - void InsertNext(wxTreeListModelNode* next) - { - wxASSERT( next->m_parent == m_parent ); - - next->m_next = m_next; - m_next = next; - } - - // Remove the first child of this item from the tree and delete it. - void DeleteChild() - { - wxTreeListModelNode* const oldChild = m_child; - m_child = m_child->m_next; - delete oldChild; - } - - // Remove the next sibling of this item from the tree and deletes it. - void DeleteNext() - { - wxTreeListModelNode* const oldNext = m_next; - m_next = m_next->m_next; - delete oldNext; - } - - - // Functions for tree traversal. All of them can return NULL. - - // Only returns NULL when called on the root item. - wxTreeListModelNode* GetParent() const { return m_parent; } - - // Returns the first child of this item. - wxTreeListModelNode* GetChild() const { return m_child; } - - // Returns the next sibling of this item. - wxTreeListModelNode* GetNext() const { return m_next; } - - // Unlike the previous two functions, this one is not a simple accessor - // (hence it's not called "GetSomething") but computes the next node after - // this one in tree order. - wxTreeListModelNode* NextInTree() const - { - if ( m_child ) - return m_child; - - if ( m_next ) - return m_next; - - // Recurse upwards until we find the next sibling. - for ( wxTreeListModelNode* node = m_parent; node; node = node->m_parent ) - { - if ( node->m_next ) - return node->m_next; - } - - return NULL; - } - - -private: - // The (never changing after creation) parent of this node and the possibly - // NULL pointers to its first child and next sibling. - wxTreeListModelNode* const m_parent; - wxTreeListModelNode* m_child; - wxTreeListModelNode* m_next; - - // Client data pointer owned by the control. May be NULL. - wxClientData* m_data; - - // Array of column values for all the columns except the first one. May be - // NULL if no values had been set for them. - wxString* m_columnsTexts; -}; - -// ---------------------------------------------------------------------------- -// wxTreeListModel: wxDataViewModel implementation used by wxTreeListCtrl. -// ---------------------------------------------------------------------------- - -class wxTreeListModel : public wxDataViewModel -{ -public: - typedef wxTreeListModelNode Node; - - // Unlike a general wxDataViewModel, this model can only be used with a - // single control at once. The main reason for this is that we need to - // support different icons for opened and closed items and the item state - // is associated with the control, not the model, so our GetValue() is also - // bound to it (otherwise, what would it return for an item expanded in one - // associated control and collapsed in another one?). - wxTreeListModel(wxTreeListCtrl* treelist); - virtual ~wxTreeListModel(); - - - // Helpers for converting between wxDataViewItem and wxTreeListItem. These - // methods simply cast the pointer to/from wxDataViewItem except for the - // root node that we handle specially unless explicitly disabled. - // - // The advantage of using them is that they're greppable and stand out - // better, hopefully making the code more clear. - Node* FromNonRootDVI(wxDataViewItem dvi) const - { - return static_cast(dvi.GetID()); - } - - Node* FromDVI(wxDataViewItem dvi) const - { - if ( !dvi.IsOk() ) - return m_root; - - return FromNonRootDVI(dvi); - } - - wxDataViewItem ToNonRootDVI(Node* node) const - { - return wxDataViewItem(node); - } - - wxDataViewItem ToDVI(Node* node) const - { - // Our root item must be represented as NULL at wxDVC level to map to - // its own invisible root. - if ( !node->GetParent() ) - return wxDataViewItem(); - - return ToNonRootDVI(node); - } - - - // Methods called by wxTreeListCtrl. - void InsertColumn(unsigned col); - void DeleteColumn(unsigned col); - void ClearColumns(); - - Node* InsertItem(Node* parent, - Node* previous, - const wxString& text, - int imageClosed, - int imageOpened, - wxClientData* data); - void DeleteItem(Node* item); - void DeleteAllItems(); - - Node* GetRootItem() const { return m_root; } - - const wxString& GetItemText(Node* item, unsigned col) const; - void SetItemText(Node* item, unsigned col, const wxString& text); - void SetItemImage(Node* item, int closed, int opened); - wxClientData* GetItemData(Node* item) const; - void SetItemData(Node* item, wxClientData* data); - - void CheckItem(Node* item, wxCheckBoxState checkedState); - void ToggleItem(wxDataViewItem item); - - - // Implement the base class pure virtual methods. - virtual unsigned GetColumnCount() const; - virtual wxString GetColumnType(unsigned col) const; - virtual void GetValue(wxVariant& variant, - const wxDataViewItem& item, - unsigned col) const; - virtual bool SetValue(const wxVariant& variant, - const wxDataViewItem& item, - unsigned col); - virtual wxDataViewItem GetParent(const wxDataViewItem& item) const; - virtual bool IsContainer(const wxDataViewItem& item) const; - virtual bool HasContainerColumns(const wxDataViewItem& item) const; - virtual unsigned GetChildren(const wxDataViewItem& item, - wxDataViewItemArray& children) const; - virtual bool IsListModel() const { return m_isFlat; } - virtual int Compare(const wxDataViewItem& item1, - const wxDataViewItem& item2, - unsigned col, - bool ascending) const; - -private: - // The control we're associated with. - wxTreeListCtrl* const m_treelist; - - // The unique invisible root element. - Node* const m_root; - - // Number of columns we maintain. - unsigned m_numColumns; - - // Set to false as soon as we have more than one level, i.e. as soon as any - // items with non-root item as parent are added (and currently never reset - // after this). - bool m_isFlat; -}; - -// ============================================================================ -// wxDataViewCheckIconText[Renderer]: special renderer for our first column. -// ============================================================================ - -// Currently this class is private but it could be extracted and made part of -// public API later as could be used directly with wxDataViewCtrl as well. -namespace -{ - -const char* CHECK_ICON_TEXT_TYPE = "wxDataViewCheckIconText"; - -// The value used by wxDataViewCheckIconTextRenderer -class wxDataViewCheckIconText : public wxDataViewIconText -{ -public: - wxDataViewCheckIconText(const wxString& text = wxString(), - const wxIcon& icon = wxNullIcon, - wxCheckBoxState checkedState = wxCHK_UNDETERMINED) - : wxDataViewIconText(text, icon), - m_checkedState(checkedState) - { - } - - wxDataViewCheckIconText(const wxDataViewCheckIconText& other) - : wxDataViewIconText(other), - m_checkedState(other.m_checkedState) - { - } - - bool IsSameAs(const wxDataViewCheckIconText& other) const - { - return wxDataViewIconText::IsSameAs(other) && - m_checkedState == other.m_checkedState; - } - - // There is no encapsulation anyhow, so just expose this field directly. - wxCheckBoxState m_checkedState; - - -private: - wxDECLARE_DYNAMIC_CLASS(wxDataViewCheckIconText); -}; - -wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCheckIconText, wxDataViewIconText); - -DECLARE_VARIANT_OBJECT(wxDataViewCheckIconText) -IMPLEMENT_VARIANT_OBJECT(wxDataViewCheckIconText) - - -class wxDataViewCheckIconTextRenderer : public wxDataViewCustomRenderer -{ -public: - wxDataViewCheckIconTextRenderer() - : wxDataViewCustomRenderer(CHECK_ICON_TEXT_TYPE, - wxDATAVIEW_CELL_ACTIVATABLE) - { - } - - virtual bool SetValue(const wxVariant& value) - { - m_value << value; - return true; - } - - virtual bool GetValue(wxVariant& WXUNUSED(value)) const - { - return false; - } - - wxSize GetSize() const - { - wxSize size = GetCheckSize(); - size.x += MARGIN_CHECK_ICON; - - if ( m_value.GetIcon().IsOk() ) - { - const wxSize sizeIcon = m_value.GetIcon().GetSize(); - if ( sizeIcon.y > size.y ) - size.y = sizeIcon.y; - - size.x += sizeIcon.x + MARGIN_ICON_TEXT; - } - - wxString text = m_value.GetText(); - if ( text.empty() ) - text = "Dummy"; - - const wxSize sizeText = GetTextExtent(text); - if ( sizeText.y > size.y ) - size.y = sizeText.y; - - size.x += sizeText.x; - - return size; - } - - virtual bool Render(wxRect cell, wxDC* dc, int state) - { - // Draw the checkbox first. - int renderFlags = 0; - switch ( m_value.m_checkedState ) - { - case wxCHK_UNCHECKED: - break; - - case wxCHK_CHECKED: - renderFlags |= wxCONTROL_CHECKED; - break; - - case wxCHK_UNDETERMINED: - renderFlags |= wxCONTROL_UNDETERMINED; - break; - } - - if ( state & wxDATAVIEW_CELL_PRELIT ) - renderFlags |= wxCONTROL_CURRENT; - - const wxSize sizeCheck = GetCheckSize(); - - wxRect rectCheck(cell.GetPosition(), sizeCheck); - rectCheck = rectCheck.CentreIn(cell, wxVERTICAL); - - wxRendererNative::Get().DrawCheckBox - ( - GetView(), *dc, rectCheck, renderFlags - ); - - // Then the icon, if any. - int xoffset = sizeCheck.x + MARGIN_CHECK_ICON; - - const wxIcon& icon = m_value.GetIcon(); - if ( icon.IsOk() ) - { - const wxSize sizeIcon = icon.GetSize(); - wxRect rectIcon(cell.GetPosition(), sizeIcon); - rectIcon.x += xoffset; - rectIcon = rectIcon.CentreIn(cell, wxVERTICAL); - - dc->DrawIcon(icon, rectIcon.GetPosition()); - - xoffset += sizeIcon.x + MARGIN_ICON_TEXT; - } - - // Finally the text. - RenderText(m_value.GetText(), xoffset, cell, dc, state); - - return true; - } - - // Event handlers toggling the items checkbox if it was clicked. - virtual bool ActivateCell(const wxRect& WXUNUSED(cell), - wxDataViewModel *model, - const wxDataViewItem & item, - unsigned int WXUNUSED(col), - const wxMouseEvent *mouseEvent) - { - if ( mouseEvent ) - { - if ( !wxRect(GetCheckSize()).Contains(mouseEvent->GetPosition()) ) - return false; - } - - static_cast(model)->ToggleItem(item); - return true; - } - -protected: - wxSize GetCheckSize() const - { - return wxRendererNative::Get().GetCheckBoxSize(GetView()); - } - -private: - // Just some arbitrary constants defining margins, in pixels. - enum - { - MARGIN_CHECK_ICON = 3, - MARGIN_ICON_TEXT = 4 - }; - - wxDataViewCheckIconText m_value; -}; - -} // anonymous namespace - -// ============================================================================ -// wxTreeListModel implementation -// ============================================================================ - -wxTreeListModel::wxTreeListModel(wxTreeListCtrl* treelist) - : m_treelist(treelist), - m_root(new Node(NULL)) -{ - m_numColumns = 0; - m_isFlat = true; -} - -wxTreeListModel::~wxTreeListModel() -{ - delete m_root; -} - -void wxTreeListModel::InsertColumn(unsigned col) -{ - m_numColumns++; - - // There is no need to update anything when inserting the first column. - if ( m_numColumns == 1 ) - return; - - // Update all the items as they may have texts for the old columns. - for ( Node* node = m_root->GetChild(); node; node = node->NextInTree() ) - { - node->OnInsertColumn(col, m_numColumns); - } -} - -void wxTreeListModel::DeleteColumn(unsigned col) -{ - wxCHECK_RET( col < m_numColumns, "Invalid column index" ); - - // Update all the items to remove the text for the non first columns. - if ( col > 0 ) - { - for ( Node* node = m_root->GetChild(); node; node = node->NextInTree() ) - { - node->OnDeleteColumn(col, m_numColumns); - } - } - - m_numColumns--; -} - -void wxTreeListModel::ClearColumns() -{ - m_numColumns = 0; - - for ( Node* node = m_root->GetChild(); node; node = node->NextInTree() ) - { - node->OnClearColumns(); - } -} - -wxTreeListModelNode* -wxTreeListModel::InsertItem(Node* parent, - Node* previous, - const wxString& text, - int imageClosed, - int imageOpened, - wxClientData* data) -{ - wxCHECK_MSG( parent, NULL, - "Must have a valid parent (maybe GetRootItem()?)" ); - - wxCHECK_MSG( previous, NULL, - "Must have a valid previous item (maybe wxTLI_FIRST/LAST?)" ); - - if ( m_isFlat && parent != m_root ) - { - // Not flat any more, this is a second level child. - m_isFlat = false; - } - - wxScopedPtr - newItem(new Node(parent, text, imageClosed, imageOpened, data)); - - // FIXME-VC6: This compiler refuses to compare "Node* previous" with - // wxTLI_XXX without some help. - const wxTreeListItem previousItem(previous); - - // If we have no children at all, then inserting as last child is the same - // as inserting as the first one so check for it here too. - if ( previousItem == wxTLI_FIRST || - (previousItem == wxTLI_LAST && !parent->GetChild()) ) - { - parent->InsertChild(newItem.get()); - } - else // Not the first item, find the previous one. - { - if ( previousItem == wxTLI_LAST ) - { - previous = parent->GetChild(); - - // Find the last child. - for ( ;; ) - { - Node* const next = previous->GetNext(); - if ( !next ) - break; - - previous = next; - } - } - else // We already have the previous item. - { - // Just check it's under the correct parent. - wxCHECK_MSG( previous->GetParent() == parent, NULL, - "Previous item is not under the right parent" ); - } - - previous->InsertNext(newItem.get()); - } - - ItemAdded(ToDVI(parent), ToDVI(newItem.get())); - - // The item was successfully inserted in the tree and so will be deleted by - // it, we can detach it now. - return newItem.release(); -} - -void wxTreeListModel::DeleteItem(Node* item) -{ - wxCHECK_RET( item, "Invalid item" ); - - wxCHECK_RET( item != m_root, "Can't delete the root item" ); - - Node* const parent = item->GetParent(); - - Node* previous = parent->GetChild(); - if ( previous == item ) - { - parent->DeleteChild(); - } - else // Not the first child of its parent. - { - // Find the sibling just before it. - for ( ;; ) - { - Node* const next = previous->GetNext(); - if ( next == item ) - break; - - wxCHECK_RET( next, "Item not a child of its parent?" ); - - previous = next; - } - - previous->DeleteNext(); - } - - ItemDeleted(ToDVI(parent), ToDVI(item)); -} - -void wxTreeListModel::DeleteAllItems() -{ - while ( m_root->GetChild() ) - { - m_root->DeleteChild(); - } - - Cleared(); -} - -const wxString& wxTreeListModel::GetItemText(Node* item, unsigned col) const -{ - // Returning root item text here is bogus, it just happens to be an always - // empty string we can return reference to. - wxCHECK_MSG( item, m_root->m_text, "Invalid item" ); - - // Notice that asking for the text of a column of an item that doesn't have - // any column texts is not an error so we simply return an empty string in - // this case. - return col == 0 ? item->m_text - : item->HasColumnsTexts() ? item->GetColumnText(col) - : m_root->m_text; -} - -void wxTreeListModel::SetItemText(Node* item, unsigned col, const wxString& text) -{ - wxCHECK_RET( item, "Invalid item" ); - - if ( col == 0 ) - item->m_text = text; - else - item->SetColumnText(text, col, m_numColumns); - - ValueChanged(ToDVI(item), col); -} - -void wxTreeListModel::SetItemImage(Node* item, int closed, int opened) -{ - wxCHECK_RET( item, "Invalid item" ); - - item->m_imageClosed = closed; - item->m_imageOpened = opened; - - ValueChanged(ToDVI(item), 0); -} - -wxClientData* wxTreeListModel::GetItemData(Node* item) const -{ - wxCHECK_MSG( item, NULL, "Invalid item" ); - - return item->GetClientData(); -} - -void wxTreeListModel::SetItemData(Node* item, wxClientData* data) -{ - wxCHECK_RET( item, "Invalid item" ); - - item->SetClientData(data); -} - -void wxTreeListModel::CheckItem(Node* item, wxCheckBoxState checkedState) -{ - wxCHECK_RET( item, "Invalid item" ); - - item->m_checkedState = checkedState; - - ItemChanged(ToDVI(item)); -} - -void wxTreeListModel::ToggleItem(wxDataViewItem dvi) -{ - Node* const item = FromDVI(dvi); - - wxCHECK_RET( item, "Invalid item" ); - - const wxCheckBoxState stateOld = item->m_checkedState; - - // If the 3rd state is user-settable then the cycle is - // unchecked->checked->undetermined. - switch ( stateOld ) - { - case wxCHK_CHECKED: - item->m_checkedState = m_treelist->HasFlag(wxTL_USER_3STATE) - ? wxCHK_UNDETERMINED - : wxCHK_UNCHECKED; - break; - - case wxCHK_UNDETERMINED: - // Whether 3rd state is user-settable or not, the next state is - // unchecked. - item->m_checkedState = wxCHK_UNCHECKED; - break; - - case wxCHK_UNCHECKED: - item->m_checkedState = wxCHK_CHECKED; - break; - } - - ItemChanged(ToDVI(item)); - - m_treelist->OnItemToggled(item, stateOld); -} - -unsigned wxTreeListModel::GetColumnCount() const -{ - return m_numColumns; -} - -wxString wxTreeListModel::GetColumnType(unsigned col) const -{ - if ( col == 0 ) - { - return m_treelist->HasFlag(wxTL_CHECKBOX) - ? wxS("wxDataViewCheckIconText") - : wxS("wxDataViewIconText"); - } - else // All the other columns contain just text. - { - return wxS("string"); - } -} - -void -wxTreeListModel::GetValue(wxVariant& variant, - const wxDataViewItem& item, - unsigned col) const -{ - Node* const node = FromDVI(item); - - if ( col == 0 ) - { - // Determine the correct image to use depending on the item state. - int image = wxWithImages::NO_IMAGE; - if ( m_treelist->IsExpanded(node) ) - image = node->m_imageOpened; - - if ( image == wxWithImages::NO_IMAGE ) - image = node->m_imageClosed; - - wxIcon icon = m_treelist->GetImage(image); - - if ( m_treelist->HasFlag(wxTL_CHECKBOX) ) - variant << wxDataViewCheckIconText(node->m_text, icon, - node->m_checkedState); - else - variant << wxDataViewIconText(node->m_text, icon); - } - else - { - // Notice that we must still assign wxString to wxVariant to ensure - // that it at least has the correct type. - wxString text; - if ( node->HasColumnsTexts() ) - text = node->GetColumnText(col); - - variant = text; - } -} - -bool -wxTreeListModel::SetValue(const wxVariant& WXUNUSED(variant), - const wxDataViewItem& WXUNUSED(item), - unsigned WXUNUSED(col)) -{ - // We are not editable currently. - return false; -} - -wxDataViewItem wxTreeListModel::GetParent(const wxDataViewItem& item) const -{ - Node* const node = FromDVI(item); - - return ToDVI(node->GetParent()); -} - -bool wxTreeListModel::IsContainer(const wxDataViewItem& item) const -{ - // FIXME: In the generic (and native OS X) versions we implement this - // method normally, i.e. only items with children are containers. - // But for the native GTK version we must pretend that all items are - // containers because otherwise adding children to them later would - // fail because wxGTK code calls IsContainer() too early (when - // adding the item itself) and we can't know whether we're container - // or not by then. Luckily, always returning true doesn't have any - // serious drawbacks for us. -#ifdef __WXGTK__ - wxUnusedVar(item); - - return true; -#else - Node* const node = FromDVI(item); - - return node->GetChild() != NULL; -#endif -} - -bool -wxTreeListModel::HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const -{ - return true; -} - -unsigned -wxTreeListModel::GetChildren(const wxDataViewItem& item, - wxDataViewItemArray& children) const -{ - Node* const node = FromDVI(item); - - unsigned numChildren = 0; - for ( Node* child = node->GetChild(); child; child = child->GetNext() ) - { - children.push_back(ToDVI(child)); - numChildren++; - } - - return numChildren; -} - -int -wxTreeListModel::Compare(const wxDataViewItem& item1, - const wxDataViewItem& item2, - unsigned col, - bool ascending) const -{ - // Compare using default alphabetical order if no custom comparator. - wxTreeListItemComparator* const comp = m_treelist->m_comparator; - if ( !comp ) - return wxDataViewModel::Compare(item1, item2, col, ascending); - - // Forward comparison to the comparator: - int result = comp->Compare(m_treelist, col, FromDVI(item1), FromDVI(item2)); - - // And adjust by the sort order if necessary. - if ( !ascending ) - result = -result; - - return result; -} - -// ============================================================================ -// wxTreeListCtrl implementation -// ============================================================================ - -BEGIN_EVENT_TABLE(wxTreeListCtrl, wxWindow) - EVT_DATAVIEW_SELECTION_CHANGED(wxID_ANY, wxTreeListCtrl::OnSelectionChanged) - EVT_DATAVIEW_ITEM_EXPANDING(wxID_ANY, wxTreeListCtrl::OnItemExpanding) - EVT_DATAVIEW_ITEM_EXPANDED(wxID_ANY, wxTreeListCtrl::OnItemExpanded) - EVT_DATAVIEW_ITEM_ACTIVATED(wxID_ANY, wxTreeListCtrl::OnItemActivated) - EVT_DATAVIEW_ITEM_CONTEXT_MENU(wxID_ANY, wxTreeListCtrl::OnItemContextMenu) - EVT_DATAVIEW_COLUMN_SORTED(wxID_ANY, wxTreeListCtrl::OnColumnSorted) - - EVT_SIZE(wxTreeListCtrl::OnSize) -END_EVENT_TABLE() - -// ---------------------------------------------------------------------------- -// Creation -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::Init() -{ - m_view = NULL; - m_model = NULL; - m_comparator = NULL; -} - -bool wxTreeListCtrl::Create(wxWindow* parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( style & wxTL_USER_3STATE ) - style |= wxTL_3STATE; - - if ( style & wxTL_3STATE ) - style |= wxTL_CHECKBOX; - - // Create the window itself and wxDataViewCtrl used by it. - if ( !wxWindow::Create(parent, id, - pos, size, - style, name) ) - { - return false; - } - - m_view = new wxDataViewCtrl; - long styleDataView = HasFlag(wxTL_MULTIPLE) ? wxDV_MULTIPLE - : wxDV_SINGLE; - if ( HasFlag(wxTL_NO_HEADER) ) - styleDataView |= wxDV_NO_HEADER; - - if ( !m_view->Create(this, wxID_ANY, - wxPoint(0, 0), GetClientSize(), - styleDataView) ) - { - delete m_view; - m_view = NULL; - - return false; - } - - - // Set up the model for wxDataViewCtrl. - m_model = new wxTreeListModel(this); - m_view->AssociateModel(m_model); - - return true; -} - -wxTreeListCtrl::~wxTreeListCtrl() -{ - if ( m_model ) - m_model->DecRef(); -} - -wxWindowList wxTreeListCtrl::GetCompositeWindowParts() const -{ - wxWindowList parts; - parts.push_back(m_view); - return parts; -} - -// ---------------------------------------------------------------------------- -// Columns -// ---------------------------------------------------------------------------- - -int -wxTreeListCtrl::DoInsertColumn(const wxString& title, - int pos, - int width, - wxAlignment align, - int flags) -{ - wxCHECK_MSG( m_view, wxNOT_FOUND, "Must Create() first" ); - - const unsigned oldNumColumns = m_view->GetColumnCount(); - - if ( pos == wxNOT_FOUND ) - pos = oldNumColumns; - - wxDataViewRenderer* renderer; - if ( pos == 0 ) - { - // Inserting the first column which is special as it uses a different - // renderer. - - // Also, currently it can be done only once. - wxCHECK_MSG( !oldNumColumns, wxNOT_FOUND, - "Inserting column at position 0 currently not supported" ); - - if ( HasFlag(wxTL_CHECKBOX) ) - { - // Use our custom renderer to show the checkbox. - renderer = new wxDataViewCheckIconTextRenderer; - } - else // We still need a special renderer to show the icons. - { - renderer = new wxDataViewIconTextRenderer; - } - } - else // Not the first column. - { - // All the other ones use a simple text renderer. - renderer = new wxDataViewTextRenderer; - } - - wxDataViewColumn* - column = new wxDataViewColumn(title, renderer, pos, width, align, flags); - - m_model->InsertColumn(pos); - - m_view->InsertColumn(pos, column); - - return pos; -} - -unsigned wxTreeListCtrl::GetColumnCount() const -{ - return m_view ? m_view->GetColumnCount() : 0u; -} - -bool wxTreeListCtrl::DeleteColumn(unsigned col) -{ - wxCHECK_MSG( col < GetColumnCount(), false, "Invalid column index" ); - - if ( !m_view->DeleteColumn(m_view->GetColumn(col)) ) - return false; - - m_model->DeleteColumn(col); - - return true; -} - -void wxTreeListCtrl::ClearColumns() -{ - // Don't assert here, clearing columns of the control before it's created - // can be considered valid (just useless). - if ( !m_model ) - return; - - m_view->ClearColumns(); - - m_model->ClearColumns(); -} - -void wxTreeListCtrl::SetColumnWidth(unsigned col, int width) -{ - wxCHECK_RET( col < GetColumnCount(), "Invalid column index" ); - - wxDataViewColumn* const column = m_view->GetColumn(col); - wxCHECK_RET( column, "No such column?" ); - - column->SetWidth(width); -} - -int wxTreeListCtrl::GetColumnWidth(unsigned col) const -{ - wxCHECK_MSG( col < GetColumnCount(), -1, "Invalid column index" ); - - wxDataViewColumn* column = m_view->GetColumn(col); - wxCHECK_MSG( column, -1, "No such column?" ); - - return column->GetWidth(); -} - -int wxTreeListCtrl::WidthFor(const wxString& text) const -{ - return GetTextExtent(text).x; -} - -// ---------------------------------------------------------------------------- -// Items -// ---------------------------------------------------------------------------- - -wxTreeListItem -wxTreeListCtrl::DoInsertItem(wxTreeListItem parent, - wxTreeListItem previous, - const wxString& text, - int imageClosed, - int imageOpened, - wxClientData* data) -{ - wxCHECK_MSG( m_model, wxTreeListItem(), "Must create first" ); - - return wxTreeListItem(m_model->InsertItem(parent, previous, text, - imageClosed, imageOpened, data)); -} - -void wxTreeListCtrl::DeleteItem(wxTreeListItem item) -{ - wxCHECK_RET( m_model, "Must create first" ); - - m_model->DeleteItem(item); -} - -void wxTreeListCtrl::DeleteAllItems() -{ - if ( m_model ) - m_model->DeleteAllItems(); -} - -// ---------------------------------------------------------------------------- -// Tree navigation -// ---------------------------------------------------------------------------- - -// The simple accessors in this section are implemented directly using -// wxTreeListModelNode methods, without passing by the model. This is just a -// shortcut and avoids us the trouble of defining more trivial methods in -// wxTreeListModel. - -wxTreeListItem wxTreeListCtrl::GetRootItem() const -{ - wxCHECK_MSG( m_model, wxTreeListItem(), "Must create first" ); - - return m_model->GetRootItem(); -} - -wxTreeListItem wxTreeListCtrl::GetItemParent(wxTreeListItem item) const -{ - wxCHECK_MSG( item.IsOk(), wxTreeListItem(), "Invalid item" ); - - return item->GetParent(); -} - -wxTreeListItem wxTreeListCtrl::GetFirstChild(wxTreeListItem item) const -{ - wxCHECK_MSG( item.IsOk(), wxTreeListItem(), "Invalid item" ); - - return item->GetChild(); -} - -wxTreeListItem -wxTreeListCtrl::GetNextSibling(wxTreeListItem item) const -{ - wxCHECK_MSG( item.IsOk(), wxTreeListItem(), "Invalid item" ); - - return item->GetNext(); -} - -wxTreeListItem wxTreeListCtrl::GetNextItem(wxTreeListItem item) const -{ - wxCHECK_MSG( item.IsOk(), wxTreeListItem(), "Invalid item" ); - - return item->NextInTree(); -} - -// ---------------------------------------------------------------------------- -// Item attributes -// ---------------------------------------------------------------------------- - -const wxString& -wxTreeListCtrl::GetItemText(wxTreeListItem item, unsigned col) const -{ - // We can't use wxCHECK_MSG() here because we don't have any empty string - // reference to return so we use a static variable that exists just for the - // purpose of this check -- and so we put it in its own scope so that it's - // never even created during normal program execution. - if ( !m_model || col >= m_model->GetColumnCount() ) - { - static wxString s_empty; - - if ( !m_model ) - { - wxFAIL_MSG( "Must create first" ); - } - else if ( col >= m_model->GetColumnCount() ) - { - wxFAIL_MSG( "Invalid column index" ); - } - - return s_empty; - } - - return m_model->GetItemText(item, col); -} - -void -wxTreeListCtrl::SetItemText(wxTreeListItem item, - unsigned col, - const wxString& text) -{ - wxCHECK_RET( m_model, "Must create first" ); - wxCHECK_RET( col < m_model->GetColumnCount(), "Invalid column index" ); - - m_model->SetItemText(item, col, text); -} - -void wxTreeListCtrl::SetItemImage(wxTreeListItem item, int closed, int opened) -{ - wxCHECK_RET( m_model, "Must create first" ); - - if ( closed != NO_IMAGE || opened != NO_IMAGE ) - { - wxImageList* const imageList = GetImageList(); - wxCHECK_RET( imageList, "Can't set images without image list" ); - - const int imageCount = imageList->GetImageCount(); - - wxCHECK_RET( closed < imageCount, "Invalid image index" ); - wxCHECK_RET( opened < imageCount, "Invalid opened image index" ); - } - - m_model->SetItemImage(item, closed, opened); -} - -wxClientData* wxTreeListCtrl::GetItemData(wxTreeListItem item) const -{ - wxCHECK_MSG( m_model, NULL, "Must create first" ); - - return m_model->GetItemData(item); -} - -void wxTreeListCtrl::SetItemData(wxTreeListItem item, wxClientData* data) -{ - wxCHECK_RET( m_model, "Must create first" ); - - m_model->SetItemData(item, data); -} - -// ---------------------------------------------------------------------------- -// Expanding and collapsing -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::Expand(wxTreeListItem item) -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->Expand(m_model->ToDVI(item)); -} - -void wxTreeListCtrl::Collapse(wxTreeListItem item) -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->Collapse(m_model->ToDVI(item)); -} - -bool wxTreeListCtrl::IsExpanded(wxTreeListItem item) const -{ - wxCHECK_MSG( m_view, false, "Must create first" ); - - return m_view->IsExpanded(m_model->ToDVI(item)); -} - -// ---------------------------------------------------------------------------- -// Selection -// ---------------------------------------------------------------------------- - -wxTreeListItem wxTreeListCtrl::GetSelection() const -{ - wxCHECK_MSG( m_view, wxTreeListItem(), "Must create first" ); - - wxCHECK_MSG( !HasFlag(wxTL_MULTIPLE), wxTreeListItem(), - "Must use GetSelections() with multi-selection controls!" ); - - const wxDataViewItem dvi = m_view->GetSelection(); - - return m_model->FromNonRootDVI(dvi); -} - -unsigned wxTreeListCtrl::GetSelections(wxTreeListItems& selections) const -{ - wxCHECK_MSG( m_view, 0, "Must create first" ); - - wxDataViewItemArray selectionsDV; - const unsigned numSelected = m_view->GetSelections(selectionsDV); - selections.resize(numSelected); - for ( unsigned n = 0; n < numSelected; n++ ) - selections[n] = m_model->FromNonRootDVI(selectionsDV[n]); - - return numSelected; -} - -void wxTreeListCtrl::Select(wxTreeListItem item) -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->Select(m_model->ToNonRootDVI(item)); -} - -void wxTreeListCtrl::Unselect(wxTreeListItem item) -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->Unselect(m_model->ToNonRootDVI(item)); -} - -bool wxTreeListCtrl::IsSelected(wxTreeListItem item) const -{ - wxCHECK_MSG( m_view, false, "Must create first" ); - - return m_view->IsSelected(m_model->ToNonRootDVI(item)); -} - -void wxTreeListCtrl::SelectAll() -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->SelectAll(); -} - -void wxTreeListCtrl::UnselectAll() -{ - wxCHECK_RET( m_view, "Must create first" ); - - m_view->UnselectAll(); -} - -// ---------------------------------------------------------------------------- -// Checkbox handling -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::CheckItem(wxTreeListItem item, wxCheckBoxState state) -{ - wxCHECK_RET( m_model, "Must create first" ); - - m_model->CheckItem(item, state); -} - -void -wxTreeListCtrl::CheckItemRecursively(wxTreeListItem item, wxCheckBoxState state) -{ - wxCHECK_RET( m_model, "Must create first" ); - - m_model->CheckItem(item, state); - - for ( wxTreeListItem child = GetFirstChild(item); - child.IsOk(); - child = GetNextSibling(child) ) - { - CheckItemRecursively(child, state); - } -} - -void wxTreeListCtrl::UpdateItemParentStateRecursively(wxTreeListItem item) -{ - wxCHECK_RET( item.IsOk(), "Invalid item" ); - - wxASSERT_MSG( HasFlag(wxTL_3STATE), "Can only be used with wxTL_3STATE" ); - - for ( ;; ) - { - wxTreeListItem parent = GetItemParent(item); - if ( parent == GetRootItem() ) - { - // There is no checked state associated with the root item. - return; - } - - // Set parent state to the state of this item if all the other children - // have the same state too. Otherwise make it indeterminate. - const wxCheckBoxState stateItem = GetCheckedState(item); - CheckItem(parent, AreAllChildrenInState(parent, stateItem) - ? stateItem - : wxCHK_UNDETERMINED); - - // And do the same thing with the parent's parent too. - item = parent; - } -} - -wxCheckBoxState wxTreeListCtrl::GetCheckedState(wxTreeListItem item) const -{ - wxCHECK_MSG( item.IsOk(), wxCHK_UNDETERMINED, "Invalid item" ); - - return item->m_checkedState; -} - -bool -wxTreeListCtrl::AreAllChildrenInState(wxTreeListItem item, - wxCheckBoxState state) const -{ - wxCHECK_MSG( item.IsOk(), false, "Invalid item" ); - - for ( wxTreeListItem child = GetFirstChild(item); - child.IsOk(); - child = GetNextSibling(child) ) - { - if ( GetCheckedState(child) != state ) - return false; - } - - return true; -} - -// ---------------------------------------------------------------------------- -// Sorting -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::SetSortColumn(unsigned col, bool ascendingOrder) -{ - wxCHECK_RET( col < m_view->GetColumnCount(), "Invalid column index" ); - - m_view->GetColumn(col)->SetSortOrder(ascendingOrder); -} - -bool wxTreeListCtrl::GetSortColumn(unsigned* col, bool* ascendingOrder) -{ - const unsigned numColumns = m_view->GetColumnCount(); - for ( unsigned n = 0; n < numColumns; n++ ) - { - wxDataViewColumn* const column = m_view->GetColumn(n); - if ( column->IsSortKey() ) - { - if ( col ) - *col = n; - - if ( ascendingOrder ) - *ascendingOrder = column->IsSortOrderAscending(); - - return true; - } - } - - return false; -} - -void wxTreeListCtrl::SetItemComparator(wxTreeListItemComparator* comparator) -{ - m_comparator = comparator; -} - -// ---------------------------------------------------------------------------- -// Events -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::SendItemEvent(wxEventType evt, wxDataViewEvent& eventDV) -{ - wxTreeListEvent eventTL(evt, this, m_model->FromDVI(eventDV.GetItem())); - - if ( !ProcessWindowEvent(eventTL) ) - { - eventDV.Skip(); - return; - } - - if ( !eventTL.IsAllowed() ) - { - eventDV.Veto(); - } -} - -void wxTreeListCtrl::SendColumnEvent(wxEventType evt, wxDataViewEvent& eventDV) -{ - wxTreeListEvent eventTL(evt, this, wxTreeListItem()); - eventTL.SetColumn(eventDV.GetColumn()); - - if ( !ProcessWindowEvent(eventTL) ) - { - eventDV.Skip(); - return; - } - - if ( !eventTL.IsAllowed() ) - { - eventDV.Veto(); - } -} - -void -wxTreeListCtrl::OnItemToggled(wxTreeListItem item, wxCheckBoxState stateOld) -{ - wxTreeListEvent event(wxEVT_TREELIST_ITEM_CHECKED, this, item); - event.SetOldCheckedState(stateOld); - - ProcessWindowEvent(event); -} - -void wxTreeListCtrl::OnSelectionChanged(wxDataViewEvent& event) -{ - SendItemEvent(wxEVT_TREELIST_SELECTION_CHANGED, event); -} - -void wxTreeListCtrl::OnItemExpanding(wxDataViewEvent& event) -{ - SendItemEvent(wxEVT_TREELIST_ITEM_EXPANDING, event); -} - -void wxTreeListCtrl::OnItemExpanded(wxDataViewEvent& event) -{ - SendItemEvent(wxEVT_TREELIST_ITEM_EXPANDED, event); -} - -void wxTreeListCtrl::OnItemActivated(wxDataViewEvent& event) -{ - SendItemEvent(wxEVT_TREELIST_ITEM_ACTIVATED, event); -} - -void wxTreeListCtrl::OnItemContextMenu(wxDataViewEvent& event) -{ - SendItemEvent(wxEVT_TREELIST_ITEM_CONTEXT_MENU, event); -} - -void wxTreeListCtrl::OnColumnSorted(wxDataViewEvent& event) -{ - SendColumnEvent(wxEVT_TREELIST_COLUMN_SORTED, event); -} - -// ---------------------------------------------------------------------------- -// Geometry -// ---------------------------------------------------------------------------- - -void wxTreeListCtrl::OnSize(wxSizeEvent& event) -{ - event.Skip(); - - if ( m_view ) - { - // Resize the real control to cover our entire client area. - const wxRect rect = GetClientRect(); - m_view->SetSize(rect); - -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - // The generic implementation doesn't refresh itself immediately which - // is annoying during "live resizing", so do it forcefully here to - // ensure that the items are re-laid out and the focus rectangle is - // redrawn correctly (instead of leaving traces) while our size is - // being changed. - wxWindow* const view = GetView(); - view->Refresh(); - view->Update(); -#endif // wxHAS_GENERIC_DATAVIEWCTRL - - // Resize the first column to take the remaining available space. - const unsigned numColumns = GetColumnCount(); - if ( !numColumns ) - return; - - // There is a bug in generic wxDataViewCtrl: if the column width sums - // up to the total size, horizontal scrollbar (unnecessarily) appears, - // so subtract a bit to ensure this doesn't happen. - int remainingWidth = rect.width - 5; - for ( unsigned n = 1; n < GetColumnCount(); n++ ) - { - remainingWidth -= GetColumnWidth(n); - if ( remainingWidth <= 0 ) - { - // There is not enough space, as we're not going to give the - // first column negative width anyhow, just don't do anything. - return; - } - } - - SetColumnWidth(0, remainingWidth); - } -} - -wxWindow* wxTreeListCtrl::GetView() const -{ -#ifdef wxHAS_GENERIC_DATAVIEWCTRL - return m_view->GetMainWindow(); -#else - return m_view; -#endif -} - -// ============================================================================ -// wxTreeListEvent implementation -// ============================================================================ - -wxIMPLEMENT_DYNAMIC_CLASS(wxTreeListEvent, wxNotifyEvent) - -#define wxDEFINE_TREELIST_EVENT(name) \ - wxDEFINE_EVENT(wxEVT_TREELIST_##name, wxTreeListEvent) - -wxDEFINE_TREELIST_EVENT(SELECTION_CHANGED); -wxDEFINE_TREELIST_EVENT(ITEM_EXPANDING); -wxDEFINE_TREELIST_EVENT(ITEM_EXPANDED); -wxDEFINE_TREELIST_EVENT(ITEM_CHECKED); -wxDEFINE_TREELIST_EVENT(ITEM_ACTIVATED); -wxDEFINE_TREELIST_EVENT(ITEM_CONTEXT_MENU); -wxDEFINE_TREELIST_EVENT(COLUMN_SORTED); - -#undef wxDEFINE_TREELIST_EVENT - -#endif // wxUSE_TREELISTCTRL diff --git a/Source/3rd Party/wx/src/generic/vlbox.cpp b/Source/3rd Party/wx/src/generic/vlbox.cpp index 13c120fa0..70a5bc109 100644 --- a/Source/3rd Party/wx/src/generic/vlbox.cpp +++ b/Source/3rd Party/wx/src/generic/vlbox.cpp @@ -4,8 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 31.05.03 +// RCS-ID: $Id: vlbox.cpp 53998 2008-06-06 22:55:23Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -35,7 +36,6 @@ #include "wx/dcbuffer.h" #include "wx/selstore.h" -#include "wx/renderer.h" // ---------------------------------------------------------------------------- // event tables @@ -47,11 +47,6 @@ BEGIN_EVENT_TABLE(wxVListBox, wxVScrolledWindow) EVT_KEY_DOWN(wxVListBox::OnKeyDown) EVT_LEFT_DOWN(wxVListBox::OnLeftDown) EVT_LEFT_DCLICK(wxVListBox::OnLeftDClick) - - EVT_SET_FOCUS(wxVListBox::OnSetOrKillFocus) - EVT_KILL_FOCUS(wxVListBox::OnSetOrKillFocus) - - EVT_SIZE(wxVListBox::OnSize) END_EVENT_TABLE() // ============================================================================ @@ -59,7 +54,6 @@ END_EVENT_TABLE() // ============================================================================ IMPLEMENT_ABSTRACT_CLASS(wxVListBox, wxVScrolledWindow) -const char wxVListBoxNameStr[] = "wxVListBox"; // ---------------------------------------------------------------------------- // wxVListBox creation @@ -79,11 +73,6 @@ bool wxVListBox::Create(wxWindow *parent, long style, const wxString& name) { -#ifdef __WXMSW__ - if ( (style & wxBORDER_MASK) == wxDEFAULT ) - style |= wxBORDER_THEME; -#endif - style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE; if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) ) return false; @@ -94,10 +83,7 @@ bool wxVListBox::Create(wxWindow *parent, // make sure the native widget has the right colour since we do // transparent drawing by default SetBackgroundColour(GetBackgroundColour()); - - // leave m_colBgSel in an invalid state: it means for OnDrawBackground() - // to use wxRendererNative instead of painting selection bg ourselves - m_colBgSel = wxNullColour; + m_colBgSel = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); // flicker-free drawing requires this SetBackgroundStyle(wxBG_STYLE_CUSTOM); @@ -122,7 +108,7 @@ void wxVListBox::SetItemCount(size_t count) m_selStore->SetItemCount(count); } - SetRowCount(count); + SetLineCount(count); } // ---------------------------------------------------------------------------- @@ -137,16 +123,16 @@ bool wxVListBox::IsSelected(size_t line) const bool wxVListBox::Select(size_t item, bool select) { wxCHECK_MSG( m_selStore, false, - wxT("Select() may only be used with multiselection listbox") ); + _T("Select() may only be used with multiselection listbox") ); wxCHECK_MSG( item < GetItemCount(), false, - wxT("Select(): invalid item index") ); + _T("Select(): invalid item index") ); bool changed = m_selStore->SelectItem(item, select); if ( changed ) { // selection really changed - RefreshRow(item); + RefreshLine(item); } DoSetCurrent(item); @@ -157,7 +143,7 @@ bool wxVListBox::Select(size_t item, bool select) bool wxVListBox::SelectRange(size_t from, size_t to) { wxCHECK_MSG( m_selStore, false, - wxT("SelectRange() may only be used with multiselection listbox") ); + _T("SelectRange() may only be used with multiselection listbox") ); // make sure items are in correct order if ( from > to ) @@ -168,14 +154,14 @@ bool wxVListBox::SelectRange(size_t from, size_t to) } wxCHECK_MSG( to < GetItemCount(), false, - wxT("SelectRange(): invalid item index") ); + _T("SelectRange(): invalid item index") ); wxArrayInt changed; if ( !m_selStore->SelectRange(from, to, true, &changed) ) { // too many items have changed, we didn't record them in changed array // so we have no choice but to refresh everything between from and to - RefreshRows(from, to); + RefreshLines(from, to); } else // we've got the indices of the changed items { @@ -189,7 +175,7 @@ bool wxVListBox::SelectRange(size_t from, size_t to) // refresh just the lines which have really changed for ( size_t n = 0; n < count; n++ ) { - RefreshRow(changed[n]); + RefreshLine(changed[n]); } } @@ -200,7 +186,7 @@ bool wxVListBox::SelectRange(size_t from, size_t to) bool wxVListBox::DoSelectAll(bool select) { wxCHECK_MSG( m_selStore, false, - wxT("SelectAll may only be used with multiselection listbox") ); + _T("SelectAll may only be used with multiselection listbox") ); size_t count = GetItemCount(); if ( count ) @@ -223,7 +209,7 @@ bool wxVListBox::DoSetCurrent(int current) { wxASSERT_MSG( current == wxNOT_FOUND || (current >= 0 && (size_t)current < GetItemCount()), - wxT("wxVListBox::DoSetCurrent(): invalid item index") ); + _T("wxVListBox::DoSetCurrent(): invalid item index") ); if ( current == m_current ) { @@ -232,7 +218,7 @@ bool wxVListBox::DoSetCurrent(int current) } if ( m_current != wxNOT_FOUND ) - RefreshRow(m_current); + RefreshLine(m_current); m_current = current; @@ -242,40 +228,33 @@ bool wxVListBox::DoSetCurrent(int current) // don't need to refresh it -- it will be redrawn anyhow if ( !IsVisible(m_current) ) { - ScrollToRow(m_current); + ScrollToLine(m_current); } else // line is at least partly visible { // it is, indeed, only partly visible, so scroll it into view to // make it entirely visible - // BUT scrolling down when m_current is first visible makes it - // completely hidden, so that is even worse - while ( (size_t)m_current + 1 == GetVisibleRowsEnd() && - (size_t)m_current != GetVisibleRowsBegin() && - ScrollToRow(GetVisibleBegin() + 1) ) ; + while ( (size_t)m_current == GetLastVisibleLine() && + ScrollToLine(GetVisibleBegin()+1) ) ; // but in any case refresh it as even if it was only partly visible // before we need to redraw it entirely as its background changed - RefreshRow(m_current); + RefreshLine(m_current); } } return true; } -void wxVListBox::InitEvent(wxCommandEvent& event, int n) -{ - event.SetEventObject(this); - event.SetInt(n); -} - void wxVListBox::SendSelectedEvent() { wxASSERT_MSG( m_current != wxNOT_FOUND, - wxT("SendSelectedEvent() shouldn't be called") ); + _T("SendSelectedEvent() shouldn't be called") ); + + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, GetId()); + event.SetEventObject(this); + event.SetInt(m_current); - wxCommandEvent event(wxEVT_LISTBOX, GetId()); - InitEvent(event, m_current); (void)GetEventHandler()->ProcessEvent(event); } @@ -283,7 +262,7 @@ void wxVListBox::SetSelection(int selection) { wxCHECK_RET( selection == wxNOT_FOUND || (selection >= 0 && (size_t)selection < GetItemCount()), - wxT("wxVListBox::SetSelection(): invalid item index") ); + _T("wxVListBox::SetSelection(): invalid item index") ); if ( HasMultipleSelection() ) { @@ -313,7 +292,7 @@ int wxVListBox::GetFirstSelected(unsigned long& cookie) const int wxVListBox::GetNextSelected(unsigned long& cookie) const { wxCHECK_MSG( m_selStore, wxNOT_FOUND, - wxT("GetFirst/NextSelected() may only be used with multiselection listboxes") ); + _T("GetFirst/NextSelected() may only be used with multiselection listboxes") ); while ( cookie < GetItemCount() ) { @@ -324,41 +303,6 @@ int wxVListBox::GetNextSelected(unsigned long& cookie) const return wxNOT_FOUND; } -void wxVListBox::RefreshSelected() -{ - // only refresh those items which are currently visible and selected: - for ( size_t n = GetVisibleBegin(), end = GetVisibleEnd(); n < end; n++ ) - { - if ( IsSelected(n) ) - RefreshRow(n); - } -} - -wxRect wxVListBox::GetItemRect(size_t n) const -{ - wxRect itemrect; - - // check that this item is visible - const size_t lineMax = GetVisibleEnd(); - if ( n >= lineMax ) - return itemrect; - size_t line = GetVisibleBegin(); - if ( n < line ) - return itemrect; - - while ( line <= n ) - { - itemrect.y += itemrect.height; - itemrect.height = OnGetRowHeight(line); - - line++; - } - - itemrect.width = GetClientSize().x; - - return itemrect; -} - // ---------------------------------------------------------------------------- // wxVListBox appearance parameters // ---------------------------------------------------------------------------- @@ -382,7 +326,7 @@ void wxVListBox::SetSelectionBackground(const wxColour& col) // wxVListBox painting // ---------------------------------------------------------------------------- -wxCoord wxVListBox::OnGetRowHeight(size_t line) const +wxCoord wxVListBox::OnGetLineHeight(size_t line) const { return OnMeasureItem(line) + 2*m_ptMargins.y; } @@ -393,15 +337,8 @@ void wxVListBox::OnDrawSeparator(wxDC& WXUNUSED(dc), { } -bool -wxVListBox::DoDrawSolidBackground(const wxColour& col, - wxDC& dc, - const wxRect& rect, - size_t n) const +void wxVListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const { - if ( !col.IsOk() ) - return false; - // we need to render selected and current items differently const bool isSelected = IsSelected(n), isCurrent = IsCurrent(n); @@ -409,36 +346,18 @@ wxVListBox::DoDrawSolidBackground(const wxColour& col, { if ( isSelected ) { - dc.SetBrush(wxBrush(col, wxBRUSHSTYLE_SOLID)); + dc.SetBrush(wxBrush(m_colBgSel, wxSOLID)); } else // !selected { dc.SetBrush(*wxTRANSPARENT_BRUSH); } + dc.SetPen(*(isCurrent ? wxBLACK_PEN : wxTRANSPARENT_PEN)); + dc.DrawRectangle(rect); } //else: do nothing for the normal items - - return true; -} - -void wxVListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const -{ - // use wxRendererNative for more native look unless we use custom bg colour - if ( !DoDrawSolidBackground(m_colBgSel, dc, rect, n) ) - { - int flags = 0; - if ( IsSelected(n) ) - flags |= wxCONTROL_SELECTED; - if ( IsCurrent(n) ) - flags |= wxCONTROL_CURRENT; - if ( wxWindow::FindFocus() == const_cast(this) ) - flags |= wxCONTROL_FOCUSED; - - wxRendererNative::Get().DrawItemSelectionRect( - const_cast(this), dc, rect, flags); - } } void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) @@ -455,24 +374,24 @@ void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) dc.Clear(); // the bounding rectangle of the current line - wxRect rectRow; - rectRow.width = clientSize.x; + wxRect rectLine; + rectLine.width = clientSize.x; // iterate over all visible lines const size_t lineMax = GetVisibleEnd(); - for ( size_t line = GetVisibleBegin(); line < lineMax; line++ ) + for ( size_t line = GetFirstVisibleLine(); line < lineMax; line++ ) { - const wxCoord hRow = OnGetRowHeight(line); + const wxCoord hLine = OnGetLineHeight(line); - rectRow.height = hRow; + rectLine.height = hLine; // and draw the ones which intersect the update rect - if ( rectRow.Intersects(rectUpdate) ) + if ( rectLine.Intersects(rectUpdate) ) { // don't allow drawing outside of the lines rectangle - wxDCClipper clip(dc, rectRow); + wxDCClipper clip(dc, rectLine); - wxRect rect = rectRow; + wxRect rect = rectLine; OnDrawBackground(dc, rect, line); OnDrawSeparator(dc, rect, line); @@ -482,7 +401,7 @@ void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) } else // no intersection { - if ( rectRow.GetTop() > rectUpdate.GetBottom() ) + if ( rectLine.GetTop() > rectUpdate.GetBottom() ) { // we are already below the update rect, no need to continue // further @@ -491,24 +410,10 @@ void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) //else: the next line may intersect the update rect } - rectRow.y += hRow; + rectLine.y += hLine; } } -void wxVListBox::OnSetOrKillFocus(wxFocusEvent& WXUNUSED(event)) -{ - // we need to repaint the selection when we get the focus since - // wxRendererNative in general draws the focused selection differently - // from the unfocused selection (see OnDrawItem): - RefreshSelected(); -} - -void wxVListBox::OnSize(wxSizeEvent& event) -{ - UpdateScrollbar(); - event.Skip(); -} - // ============================================================================ // wxVListBox keyboard/mouse handling // ============================================================================ @@ -607,27 +512,23 @@ void wxVListBox::OnKeyDown(wxKeyEvent& event) switch ( event.GetKeyCode() ) { case WXK_HOME: - case WXK_NUMPAD_HOME: current = 0; break; case WXK_END: - case WXK_NUMPAD_END: - current = GetRowCount() - 1; + current = GetLineCount() - 1; break; case WXK_DOWN: - case WXK_NUMPAD_DOWN: - if ( m_current == (int)GetRowCount() - 1 ) + if ( m_current == (int)GetLineCount() - 1 ) return; current = m_current + 1; break; case WXK_UP: - case WXK_NUMPAD_UP: if ( m_current == wxNOT_FOUND ) - current = GetRowCount() - 1; + current = GetLineCount() - 1; else if ( m_current != 0 ) current = m_current - 1; else // m_current == 0 @@ -635,19 +536,17 @@ void wxVListBox::OnKeyDown(wxKeyEvent& event) break; case WXK_PAGEDOWN: - case WXK_NUMPAD_PAGEDOWN: PageDown(); - current = GetVisibleBegin(); + current = GetFirstVisibleLine(); break; case WXK_PAGEUP: - case WXK_NUMPAD_PAGEUP: - if ( m_current == (int)GetVisibleBegin() ) + if ( m_current == (int)GetFirstVisibleLine() ) { PageUp(); } - current = GetVisibleBegin(); + current = GetFirstVisibleLine(); break; case WXK_SPACE: @@ -662,7 +561,13 @@ void wxVListBox::OnKeyDown(wxKeyEvent& event) case WXK_TAB: // Since we are using wxWANTS_CHARS we need to send navigation // events for the tabs on MSW - HandleAsNavigationKey(event); + { + wxNavigationKeyEvent ne; + ne.SetDirection(!event.ShiftDown()); + ne.SetCurrentFocus(this); + ne.SetEventObject(this); + GetParent()->GetEventHandler()->ProcessEvent(ne); + } // fall through to default #endif default: @@ -688,7 +593,7 @@ void wxVListBox::OnLeftDown(wxMouseEvent& event) { SetFocus(); - int item = VirtualHitTest(event.GetPosition().y); + int item = HitTest(event.GetPosition()); if ( item != wxNOT_FOUND ) { @@ -711,7 +616,7 @@ void wxVListBox::OnLeftDown(wxMouseEvent& event) void wxVListBox::OnLeftDClick(wxMouseEvent& eventMouse) { - int item = VirtualHitTest(eventMouse.GetPosition().y); + int item = HitTest(eventMouse.GetPosition()); if ( item != wxNOT_FOUND ) { @@ -719,8 +624,10 @@ void wxVListBox::OnLeftDClick(wxMouseEvent& eventMouse) // this event as a left-click instead if ( item == m_current ) { - wxCommandEvent event(wxEVT_LISTBOX_DCLICK, GetId()); - InitEvent(event, item); + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, GetId()); + event.SetEventObject(this); + event.SetInt(item); + (void)GetEventHandler()->ProcessEvent(event); } else diff --git a/Source/3rd Party/wx/src/generic/vscroll.cpp b/Source/3rd Party/wx/src/generic/vscroll.cpp index 72fea6886..af47dca25 100644 --- a/Source/3rd Party/wx/src/generic/vscroll.cpp +++ b/Source/3rd Party/wx/src/generic/vscroll.cpp @@ -2,8 +2,9 @@ // Name: src/generic/vscroll.cpp // Purpose: wxVScrolledWindow implementation // Author: Vadim Zeitlin -// Modified by: Brad Anderson, David Warkentin +// Modified by: // Created: 30.05.03 +// RCS-ID: $Id: vscroll.cpp 57359 2008-12-15 19:09:31Z BP $ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,681 +25,405 @@ #endif #ifndef WX_PRECOMP - #include "wx/dc.h" #include "wx/sizer.h" #endif #include "wx/vscroll.h" -#include "wx/utils.h" // For wxMin/wxMax(). - -// ============================================================================ -// wxVarScrollHelperEvtHandler declaration -// ============================================================================ - // ---------------------------------------------------------------------------- -// wxScrollHelperEvtHandler: intercept the events from the window and forward -// them to wxVarScrollHelperBase +// event tables // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxVarScrollHelperEvtHandler : public wxEvtHandler -{ -public: - wxVarScrollHelperEvtHandler(wxVarScrollHelperBase *scrollHelper) - { - m_scrollHelper = scrollHelper; - } - - virtual bool ProcessEvent(wxEvent& event); - -private: - wxVarScrollHelperBase *m_scrollHelper; - - wxDECLARE_NO_COPY_CLASS(wxVarScrollHelperEvtHandler); -}; - -// ============================================================================ -// wxVarScrollHelperEvtHandler implementation -// ============================================================================ - -// FIXME: This method totally duplicates a method with the same name in -// wxScrollHelperEvtHandler, we really should merge them by reusing the -// common parts in wxAnyScrollHelperBase. -bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event) -{ - wxEventType evType = event.GetEventType(); - - // Pass it on to the real handler: notice that we must not call - // ProcessEvent() on this object itself as it wouldn't pass it to the next - // handler (i.e. the real window) if we're called from a previous handler - // (as indicated by "process here only" flag being set) and we do want to - // execute the handler defined in the window we're associated with right - // now, without waiting until TryAfter() is called from wxEvtHandler. - bool processed = m_nextHandler->ProcessEvent(event); - - // always process the size events ourselves, even if the user code handles - // them as well, as we need to AdjustScrollbars() - // - // NB: it is important to do it after processing the event in the normal - // way as HandleOnSize() may generate a wxEVT_SIZE itself if the - // scrollbar[s] (dis)appear and it should be seen by the user code - // after this one - if ( evType == wxEVT_SIZE ) - { - m_scrollHelper->HandleOnSize((wxSizeEvent &)event); - return true; - } - - if ( processed && event.IsCommandEvent()) - return true; - - // For wxEVT_PAINT the user code can either handle this event as usual or - // override virtual OnDraw(), so if the event hasn't been handled we need - // to call this virtual function ourselves. - if ( -#ifndef __WXUNIVERSAL__ - // in wxUniversal "processed" will always be true, because - // all windows use the paint event to draw themselves. - // In this case we can't use this flag to determine if a custom - // paint event handler already drew our window and we just - // call OnDraw() anyway. - !processed && -#endif // !__WXUNIVERSAL__ - evType == wxEVT_PAINT ) - { - m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); - return true; - } - - // reset the skipped flag (which might have been set to true in - // ProcessEvent() above) to be able to test it below - bool wasSkipped = event.GetSkipped(); - if ( wasSkipped ) - event.Skip(false); - - if ( evType == wxEVT_SCROLLWIN_TOP || - evType == wxEVT_SCROLLWIN_BOTTOM || - evType == wxEVT_SCROLLWIN_LINEUP || - evType == wxEVT_SCROLLWIN_LINEDOWN || - evType == wxEVT_SCROLLWIN_PAGEUP || - evType == wxEVT_SCROLLWIN_PAGEDOWN || - evType == wxEVT_SCROLLWIN_THUMBTRACK || - evType == wxEVT_SCROLLWIN_THUMBRELEASE ) - { - m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); - if ( !event.GetSkipped() ) - { - // it makes sense to indicate that we processed the message as we - // did scroll the window (and also notice that wxAutoScrollTimer - // relies on our return value to stop scrolling when we are at top - // or bottom already) - processed = true; - wasSkipped = false; - } - } +BEGIN_EVENT_TABLE(wxVScrolledWindow, wxPanel) + EVT_SIZE(wxVScrolledWindow::OnSize) + EVT_SCROLLWIN(wxVScrolledWindow::OnScroll) #if wxUSE_MOUSEWHEEL - // Use GTK's own scroll wheel handling in GtkScrolledWindow -#ifndef __WXGTK20__ - else if ( evType == wxEVT_MOUSEWHEEL ) - { - m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event); - return true; - } + EVT_MOUSEWHEEL(wxVScrolledWindow::OnMouseWheel) #endif -#endif // wxUSE_MOUSEWHEEL - else if ( evType == wxEVT_CHAR && - (m_scrollHelper->GetOrientation() == wxVERTICAL) ) - { - m_scrollHelper->HandleOnChar((wxKeyEvent &)event); - if ( !event.GetSkipped() ) - { - processed = true; - wasSkipped = false; - } - } - - event.Skip(wasSkipped); - - // We called ProcessEvent() on the next handler, meaning that we explicitly - // worked around the request to process the event in this handler only. As - // explained above, this is unfortunately really necessary but the trouble - // is that the event will continue to be post-processed by the previous - // handler resulting in duplicate calls to event handlers. Call the special - // function below to prevent this from happening, base class DoTryChain() - // will check for it and behave accordingly. - // - // And if we're not called from DoTryChain(), this won't do anything anyhow. - event.DidntHonourProcessOnlyIn(); - - return processed; -} +END_EVENT_TABLE() // ============================================================================ -// wxVarScrollHelperBase implementation +// implementation // ============================================================================ +IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow, wxPanel) + // ---------------------------------------------------------------------------- -// wxVarScrollHelperBase initialization +// initialization // ---------------------------------------------------------------------------- -wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow *win) - : wxAnyScrollHelperBase(win) +void wxVScrolledWindow::Init() { + // we're initially empty + m_lineMax = + m_lineFirst = 0; + + // this one should always be strictly positive + m_nVisible = 1; + + m_heightTotal = 0; + #if wxUSE_MOUSEWHEEL m_sumWheelRotation = 0; #endif - - m_unitMax = 0; - m_sizeTotal = 0; - m_unitFirst = 0; - - m_physicalScrolling = true; - m_handler = NULL; - - // by default, the associated window is also the target window - DoSetTargetWindow(win); -} - -wxVarScrollHelperBase::~wxVarScrollHelperBase() -{ - DeleteEvtHandler(); } // ---------------------------------------------------------------------------- -// wxVarScrollHelperBase various helpers +// various helpers // ---------------------------------------------------------------------------- -void -wxVarScrollHelperBase::AssignOrient(wxCoord& x, - wxCoord& y, - wxCoord first, - wxCoord second) -{ - if ( GetOrientation() == wxVERTICAL ) - { - x = first; - y = second; - } - else // horizontal - { - x = second; - y = first; - } -} - -void -wxVarScrollHelperBase::IncOrient(wxCoord& x, wxCoord& y, wxCoord inc) -{ - if ( GetOrientation() == wxVERTICAL ) - y += inc; - else - x += inc; -} - -wxCoord wxVarScrollHelperBase::DoEstimateTotalSize() const +wxCoord wxVScrolledWindow::EstimateTotalHeight() const { // estimate the total height: it is impossible to call - // OnGetUnitSize() for every unit because there may be too many of - // them, so we just make a guess using some units in the beginning, + // OnGetLineHeight() for every line because there may be too many of + // them, so we just make a guess using some lines in the beginning, // some in the end and some in the middle - static const size_t NUM_UNITS_TO_SAMPLE = 10; + static const size_t NUM_LINES_TO_SAMPLE = 10; - wxCoord sizeTotal; - if ( m_unitMax < 3*NUM_UNITS_TO_SAMPLE ) + wxCoord heightTotal; + if ( m_lineMax < 3*NUM_LINES_TO_SAMPLE ) { - // in this case, full calculations are faster and more correct than + // in this case calculating exactly is faster and more correct than // guessing - sizeTotal = GetUnitsSize(0, m_unitMax); + heightTotal = GetLinesHeight(0, m_lineMax); } - else // too many units to calculate exactly + else // too many lines to calculate exactly { - // look at some units in the beginning/middle/end - sizeTotal = - GetUnitsSize(0, NUM_UNITS_TO_SAMPLE) + - GetUnitsSize(m_unitMax - NUM_UNITS_TO_SAMPLE, - m_unitMax) + - GetUnitsSize(m_unitMax/2 - NUM_UNITS_TO_SAMPLE/2, - m_unitMax/2 + NUM_UNITS_TO_SAMPLE/2); + // look at some lines in the beginning/middle/end + heightTotal = + GetLinesHeight(0, NUM_LINES_TO_SAMPLE) + + GetLinesHeight(m_lineMax - NUM_LINES_TO_SAMPLE, m_lineMax) + + GetLinesHeight(m_lineMax/2 - NUM_LINES_TO_SAMPLE/2, + m_lineMax/2 + NUM_LINES_TO_SAMPLE/2); - // use the height of the units we looked as the average - sizeTotal = (wxCoord) - (((float)sizeTotal / (3*NUM_UNITS_TO_SAMPLE)) * m_unitMax); + // use the height of the lines we looked as the average + heightTotal = (wxCoord) + (((float)heightTotal / (3*NUM_LINES_TO_SAMPLE)) * m_lineMax); } - return sizeTotal; + return heightTotal; } -wxCoord wxVarScrollHelperBase::GetUnitsSize(size_t unitMin, size_t unitMax) const +wxCoord wxVScrolledWindow::GetLinesHeight(size_t lineMin, size_t lineMax) const { - if ( unitMin == unitMax ) + if ( lineMin == lineMax ) return 0; - else if ( unitMin > unitMax ) - return -GetUnitsSize(unitMax, unitMin); - //else: unitMin < unitMax + else if ( lineMin > lineMax ) + return -GetLinesHeight(lineMax, lineMin); + //else: lineMin < lineMax - // let the user code know that we're going to need all these units - OnGetUnitsSizeHint(unitMin, unitMax); + // let the user code know that we're going to need all these lines + OnGetLinesHint(lineMin, lineMax); - // sum up their sizes - wxCoord size = 0; - for ( size_t unit = unitMin; unit < unitMax; ++unit ) + // do sum up their heights + wxCoord height = 0; + for ( size_t line = lineMin; line < lineMax; line++ ) { - size += OnGetUnitSize(unit); + height += OnGetLineHeight(line); } - return size; + return height; } -size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast, bool full) const +size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full) { - const wxCoord sWindow = GetOrientationTargetSize(); + const wxCoord hWindow = GetClientSize().y; - // go upwards until we arrive at a unit such that unitLast is not visible + // go upwards until we arrive at a line such that lineLast is not visible // any more when it is shown - size_t unitFirst = unitLast; - wxCoord s = 0; + size_t lineFirst = lineLast; + wxCoord h = 0; for ( ;; ) { - s += OnGetUnitSize(unitFirst); + h += OnGetLineHeight(lineFirst); - if ( s > sWindow ) + if ( h > hWindow ) { - // for this unit to be fully visible we need to go one unit + // for this line to be fully visible we need to go one line // down, but if it is enough for it to be only partly visible then - // this unit will do as well + // this line will do as well if ( full ) { - ++unitFirst; + lineFirst++; } break; } - if ( !unitFirst ) + if ( !lineFirst ) break; - --unitFirst; + lineFirst--; } - return unitFirst; + return lineFirst; } -size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent& event) const +void wxVScrolledWindow::RemoveScrollbar() { - wxEventType evtType = event.GetEventType(); - - if ( evtType == wxEVT_SCROLLWIN_TOP ) - { - return 0; - } - else if ( evtType == wxEVT_SCROLLWIN_BOTTOM ) - { - return m_unitMax; - } - else if ( evtType == wxEVT_SCROLLWIN_LINEUP ) - { - return m_unitFirst ? m_unitFirst - 1 : 0; - } - else if ( evtType == wxEVT_SCROLLWIN_LINEDOWN ) - { - return m_unitFirst + 1; - } - else if ( evtType == wxEVT_SCROLLWIN_PAGEUP ) - { - // Page up should do at least as much as line up. - return wxMin(FindFirstVisibleFromLast(m_unitFirst), - m_unitFirst ? m_unitFirst - 1 : 0); - } - else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN ) - { - // And page down should do at least as much as line down. - if ( GetVisibleEnd() ) - return wxMax(GetVisibleEnd() - 1, m_unitFirst + 1); - else - return wxMax(GetVisibleEnd(), m_unitFirst + 1); - } - else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE ) - { - return event.GetPosition(); - } - else if ( evtType == wxEVT_SCROLLWIN_THUMBTRACK ) - { - return event.GetPosition(); - } - - // unknown scroll event? - wxFAIL_MSG( wxT("unknown scroll event type?") ); - return 0; + m_lineFirst = 0; + m_nVisible = m_lineMax; + SetScrollbar(wxVERTICAL, 0, 0, 0); } -void wxVarScrollHelperBase::UpdateScrollbar() +void wxVScrolledWindow::UpdateScrollbar() { - // if there is nothing to scroll, remove the scrollbar - if ( !m_unitMax ) - { - RemoveScrollbar(); - return; - } + // see how many lines can we fit on screen + const wxCoord hWindow = GetClientSize().y; - // see how many units can we fit on screen - const wxCoord sWindow = GetOrientationTargetSize(); - - // do vertical calculations - wxCoord s = 0; - size_t unit; - for ( unit = m_unitFirst; unit < m_unitMax; ++unit ) + wxCoord h = 0; + size_t line; + for ( line = m_lineFirst; line < m_lineMax; line++ ) { - if ( s > sWindow ) + if ( h > hWindow ) break; - s += OnGetUnitSize(unit); + h += OnGetLineHeight(line); } - m_nUnitsVisible = unit - m_unitFirst; - - int unitsPageSize = m_nUnitsVisible; - if ( s > sWindow ) + // if we still have remaining space below, maybe we can fit everything? + if ( h < hWindow ) { - // last unit is only partially visible, we still need the scrollbar and - // so we have to "fix" pageSize because if it is equal to m_unitMax - // the scrollbar is not shown at all under MSW - --unitsPageSize; + wxCoord hAll = h; + for ( size_t lineFirst = m_lineFirst; lineFirst > 0; lineFirst-- ) + { + hAll += OnGetLineHeight(m_lineFirst - 1); + if ( hAll > hWindow ) + break; + } + + if ( hAll < hWindow ) + { + // we don't need scrollbar at all + RemoveScrollbar(); + return; + } + } + + m_nVisible = line - m_lineFirst; + + int pageSize = m_nVisible; + if ( h > hWindow ) + { + // last line is only partially visible, we still need the scrollbar and + // so we have to "fix" pageSize because if it is equal to m_lineMax the + // scrollbar is not shown at all under MSW + pageSize--; } // set the scrollbar parameters to reflect this - m_win->SetScrollbar(GetOrientation(), m_unitFirst, unitsPageSize, m_unitMax); -} - -void wxVarScrollHelperBase::RemoveScrollbar() -{ - m_unitFirst = 0; - m_nUnitsVisible = m_unitMax; - m_win->SetScrollbar(GetOrientation(), 0, 0, 0); -} - -void wxVarScrollHelperBase::DeleteEvtHandler() -{ - // search for m_handler in the handler list - if ( m_win && m_handler ) - { - if ( m_win->RemoveEventHandler(m_handler) ) - { - delete m_handler; - } - //else: something is very wrong, so better [maybe] leak memory than - // risk a crash because of double deletion - - m_handler = NULL; - } -} - -void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow *target) -{ - m_targetWindow = target; -#ifdef __WXMAC__ - target->MacSetClipChildren( true ) ; -#endif - - // install the event handler which will intercept the events we're - // interested in (but only do it for our real window, not the target window - // which we scroll - we don't need to hijack its events) - if ( m_targetWindow == m_win ) - { - // if we already have a handler, delete it first - DeleteEvtHandler(); - - m_handler = new wxVarScrollHelperEvtHandler(this); - m_targetWindow->PushEventHandler(m_handler); - } + SetScrollbar(wxVERTICAL, m_lineFirst, pageSize, m_lineMax); } // ---------------------------------------------------------------------------- -// wxVarScrollHelperBase operations +// operations // ---------------------------------------------------------------------------- -void wxVarScrollHelperBase::SetTargetWindow(wxWindow *target) +void wxVScrolledWindow::SetLineCount(size_t count) { - wxCHECK_RET( target, wxT("target window must not be NULL") ); - - if ( target == m_targetWindow ) - return; - - DoSetTargetWindow(target); -} - -void wxVarScrollHelperBase::SetUnitCount(size_t count) -{ - // save the number of units - m_unitMax = count; + // save the number of lines + m_lineMax = count; // and our estimate for their total height - m_sizeTotal = EstimateTotalSize(); + m_heightTotal = EstimateTotalHeight(); - // ScrollToUnit() will update the scrollbar itself if it changes the unit - // we pass to it because it's out of [new] range - size_t oldScrollPos = m_unitFirst; - DoScrollToUnit(m_unitFirst); - if ( oldScrollPos == m_unitFirst ) + // recalculate the scrollbars parameters + if ( count ) { - // but if it didn't do it, we still need to update the scrollbar to - // reflect the changed number of units ourselves - UpdateScrollbar(); + m_lineFirst = 1; // make sure it is != 0 + ScrollToLine(0); + } + else // no items + { + RemoveScrollbar(); } } -void wxVarScrollHelperBase::RefreshUnit(size_t unit) +void wxVScrolledWindow::RefreshLine(size_t line) { - // is this unit visible? - if ( !IsVisible(unit) ) + // is this line visible? + if ( !IsVisible(line) ) { // no, it is useless to do anything return; } - // calculate the rect occupied by this unit on screen + // calculate the rect occupied by this line on screen wxRect rect; - AssignOrient(rect.width, rect.height, - GetNonOrientationTargetSize(), OnGetUnitSize(unit)); - - for ( size_t n = GetVisibleBegin(); n < unit; ++n ) + rect.width = GetClientSize().x; + rect.height = OnGetLineHeight(line); + for ( size_t n = GetVisibleBegin(); n < line; n++ ) { - IncOrient(rect.x, rect.y, OnGetUnitSize(n)); + rect.y += OnGetLineHeight(n); } // do refresh it - m_targetWindow->RefreshRect(rect); + RefreshRect(rect); } -void wxVarScrollHelperBase::RefreshUnits(size_t from, size_t to) +void wxVScrolledWindow::RefreshLines(size_t from, size_t to) { - wxASSERT_MSG( from <= to, wxT("RefreshUnits(): empty range") ); + wxASSERT_MSG( from <= to, _T("RefreshLines(): empty range") ); - // clump the range to just the visible units -- it is useless to refresh + // clump the range to just the visible lines -- it is useless to refresh // the other ones if ( from < GetVisibleBegin() ) from = GetVisibleBegin(); - if ( to > GetVisibleEnd() ) + if ( to >= GetVisibleEnd() ) to = GetVisibleEnd(); + else + to++; - // calculate the rect occupied by these units on screen - int orient_size = 0, - orient_pos = 0; - - int nonorient_size = GetNonOrientationTargetSize(); - - for ( size_t nBefore = GetVisibleBegin(); - nBefore < from; - nBefore++ ) - { - orient_pos += OnGetUnitSize(nBefore); - } - - for ( size_t nBetween = from; nBetween <= to; nBetween++ ) - { - orient_size += OnGetUnitSize(nBetween); - } - + // calculate the rect occupied by these lines on screen wxRect rect; - AssignOrient(rect.x, rect.y, 0, orient_pos); - AssignOrient(rect.width, rect.height, nonorient_size, orient_size); + rect.width = GetClientSize().x; + for ( size_t nBefore = GetVisibleBegin(); nBefore < from; nBefore++ ) + { + rect.y += OnGetLineHeight(nBefore); + } + + for ( size_t nBetween = from; nBetween < to; nBetween++ ) + { + rect.height += OnGetLineHeight(nBetween); + } // do refresh it - m_targetWindow->RefreshRect(rect); + RefreshRect(rect); } -void wxVarScrollHelperBase::RefreshAll() +void wxVScrolledWindow::RefreshAll() { UpdateScrollbar(); - m_targetWindow->Refresh(); + Refresh(); } -bool wxVarScrollHelperBase::ScrollLayout() +bool wxVScrolledWindow::Layout() { - if ( m_targetWindow->GetSizer() && m_physicalScrolling ) + if ( GetSizer() ) { // adjust the sizer dimensions/position taking into account the // virtual size and scrolled position of the window. - int x, y; - AssignOrient(x, y, 0, -GetScrollOffset()); + int w = 0, h = 0; + GetVirtualSize(&w, &h); - int w, h; - m_targetWindow->GetVirtualSize(&w, &h); + // x is always 0 so no variable needed + int y = -GetLinesHeight(0, GetFirstVisibleLine()); - m_targetWindow->GetSizer()->SetDimension(x, y, w, h); + GetSizer()->SetDimension(0, y, w, h); return true; } // fall back to default for LayoutConstraints - return m_targetWindow->wxWindow::Layout(); + return wxPanel::Layout(); } -int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord) const +int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const { - const size_t unitMax = GetVisibleEnd(); - for ( size_t unit = GetVisibleBegin(); unit < unitMax; ++unit ) + const size_t lineMax = GetVisibleEnd(); + for ( size_t line = GetVisibleBegin(); line < lineMax; line++ ) { - coord -= OnGetUnitSize(unit); - if ( coord < 0 ) - return unit; + y -= OnGetLineHeight(line); + if ( y < 0 ) + return line; } return wxNOT_FOUND; } // ---------------------------------------------------------------------------- -// wxVarScrollHelperBase scrolling +// scrolling // ---------------------------------------------------------------------------- -bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit) +bool wxVScrolledWindow::ScrollToLine(size_t line) { - if ( !m_unitMax ) + if ( !m_lineMax ) { // we're empty, code below doesn't make sense in this case return false; } - // determine the real first unit to scroll to: we shouldn't scroll beyond + // determine the real first line to scroll to: we shouldn't scroll beyond // the end - size_t unitFirstLast = FindFirstVisibleFromLast(m_unitMax - 1, true); - if ( unit > unitFirstLast ) - unit = unitFirstLast; + size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1, true); + if ( line > lineFirstLast ) + line = lineFirstLast; // anything to do? - if ( unit == m_unitFirst ) + if ( line == m_lineFirst ) { // no return false; } - // remember the currently shown units for the refresh code below - size_t unitFirstOld = GetVisibleBegin(), - unitLastOld = GetVisibleEnd(); + // remember the currently shown lines for the refresh code below + size_t lineFirstOld = GetVisibleBegin(), + lineLastOld = GetVisibleEnd(); - m_unitFirst = unit; + m_lineFirst = line; // the size of scrollbar thumb could have changed UpdateScrollbar(); - // finally refresh the display -- but only redraw as few units as possible - // to avoid flicker. We can't do this if we have children because they - // won't be scrolled - if ( m_targetWindow->GetChildren().empty() && - (GetVisibleBegin() >= unitLastOld || GetVisibleEnd() <= unitFirstOld) ) + + // finally refresh the display -- but only redraw as few lines as possible + // to avoid flicker + if ( GetChildren().empty() && + (GetVisibleBegin() >= lineLastOld || GetVisibleEnd() <= lineFirstOld ) ) { - // the simplest case: we don't have any old units left, just redraw + // the simplest case: we don't have any old lines left, just redraw // everything - m_targetWindow->Refresh(); + Refresh(); } - else // scroll the window + else // overlap between the lines we showed before and should show now { // Avoid scrolling visible parts of the screen on Mac #ifdef __WXMAC__ - if (m_physicalScrolling && m_targetWindow->IsShownOnScreen()) -#else - if ( m_physicalScrolling ) + if (!IsShownOnScreen()) + Refresh(); + else #endif - { - wxCoord dx = 0, - dy = GetUnitsSize(GetVisibleBegin(), unitFirstOld); - - if ( GetOrientation() == wxHORIZONTAL ) - { - wxCoord tmp = dx; - dx = dy; - dy = tmp; - } - - m_targetWindow->ScrollWindow(dx, dy); - } - else // !m_physicalScrolling - { - // we still need to invalidate but we can't use ScrollWindow - // because physical scrolling is disabled (the user either didn't - // want children scrolled and/or doesn't want pixels to be - // physically scrolled). - m_targetWindow->Refresh(); - } + ScrollWindow(0, GetLinesHeight(GetVisibleBegin(), lineFirstOld)); } return true; } -bool wxVarScrollHelperBase::DoScrollUnits(int units) +bool wxVScrolledWindow::ScrollLines(int lines) { - units += m_unitFirst; - if ( units < 0 ) - units = 0; + lines += m_lineFirst; + if ( lines < 0 ) + lines = 0; - return DoScrollToUnit(units); + return ScrollToLine(lines); } -bool wxVarScrollHelperBase::DoScrollPages(int pages) +bool wxVScrolledWindow::ScrollPages(int pages) { bool didSomething = false; while ( pages ) { - int unit; + int line; if ( pages > 0 ) { - unit = GetVisibleEnd(); - if ( unit ) - --unit; - --pages; + line = GetVisibleEnd(); + if ( line ) + line--; + pages--; } else // pages < 0 { - unit = FindFirstVisibleFromLast(GetVisibleEnd()); - ++pages; + line = FindFirstFromBottom(GetVisibleBegin()); + pages++; } - didSomething = DoScrollToUnit(unit); + didSomething = ScrollToLine(line); } return didSomething; @@ -708,94 +433,71 @@ bool wxVarScrollHelperBase::DoScrollPages(int pages) // event handling // ---------------------------------------------------------------------------- -void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent& event) +void wxVScrolledWindow::OnSize(wxSizeEvent& event) { - if ( m_unitMax ) - { - // sometimes change in varscrollable window's size can result in - // unused empty space after the last item. Fix it by decrementing - // first visible item position according to the available space. - - // determine free space - const wxCoord sWindow = GetOrientationTargetSize(); - wxCoord s = 0; - size_t unit; - for ( unit = m_unitFirst; unit < m_unitMax; ++unit ) - { - if ( s > sWindow ) - break; - - s += OnGetUnitSize(unit); - } - wxCoord freeSpace = sWindow - s; - - // decrement first visible item index as long as there is free space - size_t idealUnitFirst; - for ( idealUnitFirst = m_unitFirst; - idealUnitFirst > 0; - idealUnitFirst-- ) - { - wxCoord us = OnGetUnitSize(idealUnitFirst-1); - if ( freeSpace < us ) - break; - freeSpace -= us; - } - m_unitFirst = idealUnitFirst; - } - UpdateScrollbar(); event.Skip(); } -void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent& event) +void wxVScrolledWindow::OnScroll(wxScrollWinEvent& event) { - if (GetOrientation() != event.GetOrientation()) + size_t lineFirstNew; + + const wxEventType evtType = event.GetEventType(); + + if ( evtType == wxEVT_SCROLLWIN_TOP ) { - event.Skip(); + lineFirstNew = 0; + } + else if ( evtType == wxEVT_SCROLLWIN_BOTTOM ) + { + lineFirstNew = m_lineMax; + } + else if ( evtType == wxEVT_SCROLLWIN_LINEUP ) + { + lineFirstNew = m_lineFirst ? m_lineFirst - 1 : 0; + } + else if ( evtType == wxEVT_SCROLLWIN_LINEDOWN ) + { + lineFirstNew = m_lineFirst + 1; + } + else if ( evtType == wxEVT_SCROLLWIN_PAGEUP ) + { + lineFirstNew = FindFirstFromBottom(m_lineFirst); + } + else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN ) + { + lineFirstNew = GetVisibleEnd(); + if ( lineFirstNew ) + lineFirstNew--; + } + else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE ) + { + lineFirstNew = event.GetPosition(); + } + else if ( evtType == wxEVT_SCROLLWIN_THUMBTRACK ) + { + lineFirstNew = event.GetPosition(); + } + + else // unknown scroll event? + { + wxFAIL_MSG( _T("unknown scroll event type?") ); return; } - DoScrollToUnit(GetNewScrollPosition(event)); + ScrollToLine(lineFirstNew); #ifdef __WXMAC__ - UpdateMacScrollWindow(); + Update(); #endif // __WXMAC__ } -void wxVarScrollHelperBase::DoPrepareDC(wxDC& dc) -{ - if ( m_physicalScrolling ) - { - wxPoint pt = dc.GetDeviceOrigin(); - - IncOrient(pt.x, pt.y, -GetScrollOffset()); - - dc.SetDeviceOrigin(pt.x, pt.y); - } -} - -int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord) const -{ - return coord - GetScrollOffset(); -} - -int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord) const -{ - return coord + GetScrollOffset(); -} - #if wxUSE_MOUSEWHEEL -void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) +void wxVScrolledWindow::OnMouseWheel(wxMouseEvent& event) { - // we only want to process wheel events for vertical implementations. - // There is no way to determine wheel orientation (and on MSW horizontal - // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL - // event). - if ( GetOrientation() != wxVERTICAL ) - return; - m_sumWheelRotation += event.GetWheelRotation(); int delta = event.GetWheelDelta(); @@ -807,251 +509,11 @@ void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) m_sumWheelRotation += units_to_scroll*delta; if ( !event.IsPageScroll() ) - DoScrollUnits( units_to_scroll*event.GetLinesPerAction() ); - else // scroll pages instead of units - DoScrollPages( units_to_scroll ); + ScrollLines( units_to_scroll*event.GetLinesPerAction() ); + else + // scroll pages instead of lines + ScrollPages( units_to_scroll ); } #endif // wxUSE_MOUSEWHEEL - -// ============================================================================ -// wxVarHVScrollHelper implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxVarHVScrollHelper operations -// ---------------------------------------------------------------------------- - -void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount, size_t columnCount) -{ - SetRowCount(rowCount); - SetColumnCount(columnCount); -} - -bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row, size_t column) -{ - bool result = false; - result |= ScrollToRow(row); - result |= ScrollToColumn(column); - return result; -} - -void wxVarHVScrollHelper::RefreshRowColumn(size_t row, size_t column) -{ - // is this unit visible? - if ( !IsRowVisible(row) || !IsColumnVisible(column) ) - { - // no, it is useless to do anything - return; - } - - // calculate the rect occupied by this cell on screen - wxRect v_rect, h_rect; - v_rect.height = OnGetRowHeight(row); - h_rect.width = OnGetColumnWidth(column); - - size_t n; - - for ( n = GetVisibleRowsBegin(); n < row; n++ ) - { - v_rect.y += OnGetRowHeight(n); - } - - for ( n = GetVisibleColumnsBegin(); n < column; n++ ) - { - h_rect.x += OnGetColumnWidth(n); - } - - // refresh but specialize the behaviour if we have a single target window - if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() ) - { - v_rect.x = h_rect.x; - v_rect.width = h_rect.width; - wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect); - } - else - { - v_rect.x = 0; - v_rect.width = wxVarVScrollHelper::GetNonOrientationTargetSize(); - h_rect.y = 0; - h_rect.width = wxVarHScrollHelper::GetNonOrientationTargetSize(); - - wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect); - wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect); - } -} - -void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow, size_t toRow, - size_t fromColumn, size_t toColumn) -{ - wxASSERT_MSG( fromRow <= toRow || fromColumn <= toColumn, - wxT("RefreshRowsColumns(): empty range") ); - - // clump the range to just the visible units -- it is useless to refresh - // the other ones - if ( fromRow < GetVisibleRowsBegin() ) - fromRow = GetVisibleRowsBegin(); - - if ( toRow > GetVisibleRowsEnd() ) - toRow = GetVisibleRowsEnd(); - - if ( fromColumn < GetVisibleColumnsBegin() ) - fromColumn = GetVisibleColumnsBegin(); - - if ( toColumn > GetVisibleColumnsEnd() ) - toColumn = GetVisibleColumnsEnd(); - - // calculate the rect occupied by these units on screen - wxRect v_rect, h_rect; - size_t nBefore, nBetween; - - for ( nBefore = GetVisibleRowsBegin(); - nBefore < fromRow; - nBefore++ ) - { - v_rect.y += OnGetRowHeight(nBefore); - } - - for ( nBetween = fromRow; nBetween <= toRow; nBetween++ ) - { - v_rect.height += OnGetRowHeight(nBetween); - } - - for ( nBefore = GetVisibleColumnsBegin(); - nBefore < fromColumn; - nBefore++ ) - { - h_rect.x += OnGetColumnWidth(nBefore); - } - - for ( nBetween = fromColumn; nBetween <= toColumn; nBetween++ ) - { - h_rect.width += OnGetColumnWidth(nBetween); - } - - // refresh but specialize the behaviour if we have a single target window - if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() ) - { - v_rect.x = h_rect.x; - v_rect.width = h_rect.width; - wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect); - } - else - { - v_rect.x = 0; - v_rect.width = wxVarVScrollHelper::GetNonOrientationTargetSize(); - h_rect.y = 0; - h_rect.width = wxVarHScrollHelper::GetNonOrientationTargetSize(); - - wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect); - wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect); - } -} - -wxPosition wxVarHVScrollHelper::VirtualHitTest(wxCoord x, wxCoord y) const -{ - return wxPosition(wxVarVScrollHelper::VirtualHitTest(y), - wxVarHScrollHelper::VirtualHitTest(x)); -} - -void wxVarHVScrollHelper::DoPrepareDC(wxDC& dc) -{ - wxVarVScrollHelper::DoPrepareDC(dc); - wxVarHScrollHelper::DoPrepareDC(dc); -} - -bool wxVarHVScrollHelper::ScrollLayout() -{ - bool layout_result = false; - layout_result |= wxVarVScrollHelper::ScrollLayout(); - layout_result |= wxVarHScrollHelper::ScrollLayout(); - return layout_result; -} - -wxSize wxVarHVScrollHelper::GetRowColumnCount() const -{ - return wxSize(GetColumnCount(), GetRowCount()); -} - -wxPosition wxVarHVScrollHelper::GetVisibleBegin() const -{ - return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin()); -} - -wxPosition wxVarHVScrollHelper::GetVisibleEnd() const -{ - return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd()); -} - -bool wxVarHVScrollHelper::IsVisible(size_t row, size_t column) const -{ - return IsRowVisible(row) && IsColumnVisible(column); -} - - -// ============================================================================ -// wx[V/H/HV]ScrolledWindow implementations -// ============================================================================ - -IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow, wxPanel) -IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow, wxPanel) -IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow, wxPanel) - - -#if WXWIN_COMPATIBILITY_2_8 - -// =========================================================================== -// wxVarVScrollLegacyAdaptor -// =========================================================================== - -size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const -{ return GetVisibleRowsBegin(); } - -size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const -{ return GetVisibleRowsEnd() - 1; } - -size_t wxVarVScrollLegacyAdaptor::GetLineCount() const -{ return GetRowCount(); } - -void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count) -{ SetRowCount(count); } - -void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line) -{ RefreshRow(line); } - -void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from, size_t to) -{ RefreshRows(from, to); } - -bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line) -{ return ScrollToRow(line); } - -bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines) -{ return ScrollRows(lines); } - -bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages) -{ return ScrollRowPages(pages); } - -wxCoord wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n)) const -{ - wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") ); - return -1; -} - -void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin), - size_t WXUNUSED(lineMax)) const -{ -} - -wxCoord wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n) const -{ - return OnGetLineHeight(n); -} - -void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin, - size_t rowMax) const -{ - OnGetLinesHint(rowMin, rowMax); -} - -#endif // WXWIN_COMPATIBILITY_2_8 diff --git a/Source/3rd Party/wx/src/generic/wizard.cpp b/Source/3rd Party/wx/src/generic/wizard.cpp deleted file mode 100644 index 25d1a669d..000000000 --- a/Source/3rd Party/wx/src/generic/wizard.cpp +++ /dev/null @@ -1,1009 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/wizard.cpp -// Purpose: generic implementation of wxWizard class -// Author: Vadim Zeitlin -// Modified by: Robert Cavanaugh -// 1) Added capability for wxWizardPage to accept resources -// 2) Added "Help" button handler stub -// 3) Fixed ShowPage() bug on displaying bitmaps -// Robert Vazan (sizers) -// Created: 15.08.99 -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_WIZARDDLG - -#ifndef WX_PRECOMP - #include "wx/dynarray.h" - #include "wx/intl.h" - #include "wx/statbmp.h" - #include "wx/button.h" - #include "wx/settings.h" - #include "wx/sizer.h" -#endif //WX_PRECOMP - -#include "wx/statline.h" - -#include "wx/scrolwin.h" -#include "wx/wizard.h" -#include "wx/dcmemory.h" - -// ---------------------------------------------------------------------------- -// wxWizardSizer -// ---------------------------------------------------------------------------- - -class wxWizardSizer : public wxSizer -{ -public: - wxWizardSizer(wxWizard *owner); - - virtual wxSizerItem *Insert(size_t index, wxSizerItem *item); - - virtual void RecalcSizes(); - virtual wxSize CalcMin(); - - // get the max size of all wizard pages - wxSize GetMaxChildSize(); - - // return the border which can be either set using wxWizard::SetBorder() or - // have default value - int GetBorder() const; - - // hide the pages which we temporarily "show" when they're added to this - // sizer (see Insert()) - void HidePages(); - -private: - wxSize SiblingSize(wxSizerItem *child); - - wxWizard *m_owner; - wxSize m_childSize; -}; - -// ---------------------------------------------------------------------------- -// event tables and such -// ---------------------------------------------------------------------------- - -wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGED, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGING, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_BEFORE_PAGE_CHANGED, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_CANCEL, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_FINISHED, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_HELP, wxWizardEvent ); -wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_SHOWN, wxWizardEvent ); - -BEGIN_EVENT_TABLE(wxWizard, wxDialog) - EVT_BUTTON(wxID_CANCEL, wxWizard::OnCancel) - EVT_BUTTON(wxID_BACKWARD, wxWizard::OnBackOrNext) - EVT_BUTTON(wxID_FORWARD, wxWizard::OnBackOrNext) - EVT_BUTTON(wxID_HELP, wxWizard::OnHelp) - - EVT_WIZARD_PAGE_CHANGED(wxID_ANY, wxWizard::OnWizEvent) - EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxWizard::OnWizEvent) - EVT_WIZARD_CANCEL(wxID_ANY, wxWizard::OnWizEvent) - EVT_WIZARD_FINISHED(wxID_ANY, wxWizard::OnWizEvent) - EVT_WIZARD_HELP(wxID_ANY, wxWizard::OnWizEvent) -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxWizard, wxDialog) - -/* - TODO PROPERTIES : - wxWizard - extstyle - title -*/ - -IMPLEMENT_ABSTRACT_CLASS(wxWizardPage, wxPanel) -IMPLEMENT_DYNAMIC_CLASS(wxWizardPageSimple, wxWizardPage) -IMPLEMENT_DYNAMIC_CLASS(wxWizardEvent, wxNotifyEvent) - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxWizardPage -// ---------------------------------------------------------------------------- - -void wxWizardPage::Init() -{ - m_bitmap = wxNullBitmap; -} - -wxWizardPage::wxWizardPage(wxWizard *parent, - const wxBitmap& bitmap) -{ - Create(parent, bitmap); -} - -bool wxWizardPage::Create(wxWizard *parent, - const wxBitmap& bitmap) -{ - if ( !wxPanel::Create(parent, wxID_ANY) ) - return false; - - m_bitmap = bitmap; - - // initially the page is hidden, it's shown only when it becomes current - Hide(); - - return true; -} - -// ---------------------------------------------------------------------------- -// wxWizardPageSimple -// ---------------------------------------------------------------------------- - -wxWizardPage *wxWizardPageSimple::GetPrev() const -{ - return m_prev; -} - -wxWizardPage *wxWizardPageSimple::GetNext() const -{ - return m_next; -} - -// ---------------------------------------------------------------------------- -// wxWizardSizer -// ---------------------------------------------------------------------------- - -wxWizardSizer::wxWizardSizer(wxWizard *owner) - : m_owner(owner), - m_childSize(wxDefaultSize) -{ -} - -wxSizerItem *wxWizardSizer::Insert(size_t index, wxSizerItem *item) -{ - m_owner->m_usingSizer = true; - - if ( item->IsWindow() ) - { - // we must pretend that the window is shown as otherwise it wouldn't be - // taken into account for the layout -- but avoid really showing it, so - // just set the internal flag instead of calling wxWindow::Show() - item->GetWindow()->wxWindowBase::Show(); - } - - return wxSizer::Insert(index, item); -} - -void wxWizardSizer::HidePages() -{ - for ( wxSizerItemList::compatibility_iterator node = GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxSizerItem * const item = node->GetData(); - if ( item->IsWindow() ) - item->GetWindow()->wxWindowBase::Show(false); - } -} - -void wxWizardSizer::RecalcSizes() -{ - // Effect of this function depends on m_owner->m_page and - // it should be called whenever it changes (wxWizard::ShowPage) - if ( m_owner->m_page ) - { - m_owner->m_page->SetSize(wxRect(m_position, m_size)); - } -} - -wxSize wxWizardSizer::CalcMin() -{ - return m_owner->GetPageSize(); -} - -wxSize wxWizardSizer::GetMaxChildSize() -{ - wxSize maxOfMin; - - for ( wxSizerItemList::compatibility_iterator childNode = m_children.GetFirst(); - childNode; - childNode = childNode->GetNext() ) - { - wxSizerItem *child = childNode->GetData(); - maxOfMin.IncTo(child->CalcMin()); - maxOfMin.IncTo(SiblingSize(child)); - } - - if ( m_owner->m_started ) - { - m_childSize = maxOfMin; - } - - return maxOfMin; -} - -int wxWizardSizer::GetBorder() const -{ - return m_owner->m_border; -} - -wxSize wxWizardSizer::SiblingSize(wxSizerItem *child) -{ - wxSize maxSibling; - - if ( child->IsWindow() ) - { - wxWizardPage *page = wxDynamicCast(child->GetWindow(), wxWizardPage); - if ( page ) - { - for ( wxWizardPage *sibling = page->GetNext(); - sibling; - sibling = sibling->GetNext() ) - { - if ( sibling->GetSizer() ) - { - maxSibling.IncTo(sibling->GetSizer()->CalcMin()); - } - } - } - } - - return maxSibling; -} - -// ---------------------------------------------------------------------------- -// generic wxWizard implementation -// ---------------------------------------------------------------------------- - -void wxWizard::Init() -{ - m_posWizard = wxDefaultPosition; - m_page = NULL; - m_btnPrev = m_btnNext = NULL; - m_statbmp = NULL; - m_sizerBmpAndPage = NULL; - m_sizerPage = NULL; - m_border = 5; - m_started = false; - m_wasModal = false; - m_usingSizer = false; - m_bitmapBackgroundColour = *wxWHITE; - m_bitmapPlacement = 0; - m_bitmapMinimumWidth = 115; -} - -bool wxWizard::Create(wxWindow *parent, - int id, - const wxString& title, - const wxBitmap& bitmap, - const wxPoint& pos, - long style) -{ - bool result = wxDialog::Create(parent,id,title,pos,wxDefaultSize,style); - - m_posWizard = pos; - m_bitmap = bitmap ; - - DoCreateControls(); - - return result; -} - -wxWizard::~wxWizard() -{ - // normally we don't have to delete this sizer as it's deleted by the - // associated window but if we never used it or didn't set it as the window - // sizer yet, do delete it manually - if ( !m_usingSizer || !m_started ) - delete m_sizerPage; -} - -void wxWizard::AddBitmapRow(wxBoxSizer *mainColumn) -{ - m_sizerBmpAndPage = new wxBoxSizer(wxHORIZONTAL); - mainColumn->Add( - m_sizerBmpAndPage, - 1, // Vertically stretchable - wxEXPAND // Horizontal stretching, no border - ); - mainColumn->Add(0,5, - 0, // No vertical stretching - wxEXPAND // No border, (mostly useless) horizontal stretching - ); - -#if wxUSE_STATBMP - if ( m_bitmap.IsOk() ) - { - wxSize bitmapSize(wxDefaultSize); - if (GetBitmapPlacement()) - bitmapSize.x = GetMinimumBitmapWidth(); - - m_statbmp = new wxStaticBitmap(this, wxID_ANY, m_bitmap, wxDefaultPosition, bitmapSize); - m_sizerBmpAndPage->Add( - m_statbmp, - 0, // No horizontal stretching - wxALL, // Border all around, top alignment - 5 // Border width - ); - m_sizerBmpAndPage->Add( - 5,0, - 0, // No horizontal stretching - wxEXPAND // No border, (mostly useless) vertical stretching - ); - } -#endif - - // Added to m_sizerBmpAndPage later - m_sizerPage = new wxWizardSizer(this); -} - -void wxWizard::AddStaticLine(wxBoxSizer *mainColumn) -{ -#if wxUSE_STATLINE - mainColumn->Add( - new wxStaticLine(this, wxID_ANY), - 0, // Vertically unstretchable - wxEXPAND | wxALL, // Border all around, horizontally stretchable - 5 // Border width - ); - mainColumn->Add(0,5, - 0, // No vertical stretching - wxEXPAND // No border, (mostly useless) horizontal stretching - ); -#else - (void)mainColumn; -#endif // wxUSE_STATLINE -} - -void wxWizard::AddBackNextPair(wxBoxSizer *buttonRow) -{ - wxASSERT_MSG( m_btnNext && m_btnPrev, - wxT("You must create the buttons before calling ") - wxT("wxWizard::AddBackNextPair") ); - - wxBoxSizer *backNextPair = new wxBoxSizer(wxHORIZONTAL); - buttonRow->Add( - backNextPair, - 0, // No horizontal stretching - wxALL, // Border all around - 5 // Border width - ); - - backNextPair->Add(m_btnPrev); - backNextPair->Add(10, 0, - 0, // No horizontal stretching - wxEXPAND // No border, (mostly useless) vertical stretching - ); - backNextPair->Add(m_btnNext); -} - -void wxWizard::AddButtonRow(wxBoxSizer *mainColumn) -{ - // the order in which the buttons are created determines the TAB order - at least under MSWindows... - // although the 'back' button appears before the 'next' button, a more userfriendly tab order is - // to activate the 'next' button first (create the next button before the back button). - // The reason is: The user will repeatedly enter information in the wizard pages and then wants to - // press 'next'. If a user uses mostly the keyboard, he would have to skip the 'back' button - // every time. This is annoying. There is a second reason: RETURN acts as TAB. If the 'next' - // button comes first in the TAB order, the user can enter information very fast using the RETURN - // key to TAB to the next entry field and page. This would not be possible, if the 'back' button - // was created before the 'next' button. - - bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - int buttonStyle = isPda ? wxBU_EXACTFIT : 0; - - wxBoxSizer *buttonRow = new wxBoxSizer(wxHORIZONTAL); -#ifdef __WXMAC__ - if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) - mainColumn->Add( - buttonRow, - 0, // Vertically unstretchable - wxGROW|wxALIGN_CENTRE - ); - else -#endif - mainColumn->Add( - buttonRow, - 0, // Vertically unstretchable - wxALIGN_RIGHT // Right aligned, no border - ); - - // Desired TAB order is 'next', 'cancel', 'help', 'back'. This makes the 'back' button the last control on the page. - // Create the buttons in the right order... - wxButton *btnHelp=0; -#ifdef __WXMAC__ - if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) - btnHelp=new wxButton(this, wxID_HELP, wxEmptyString, wxDefaultPosition, wxDefaultSize, buttonStyle); -#endif - - m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >")); - wxButton *btnCancel=new wxButton(this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, buttonStyle); -#ifndef __WXMAC__ - if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) - btnHelp=new wxButton(this, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, buttonStyle); -#endif - m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"), wxDefaultPosition, wxDefaultSize, buttonStyle); - - if (btnHelp) - { - buttonRow->Add( - btnHelp, - 0, // Horizontally unstretchable - wxALL, // Border all around, top aligned - 5 // Border width - ); -#ifdef __WXMAC__ - // Put stretchable space between help button and others - buttonRow->Add(0, 0, 1, wxALIGN_CENTRE, 0); -#endif - } - - AddBackNextPair(buttonRow); - - buttonRow->Add( - btnCancel, - 0, // Horizontally unstretchable - wxALL, // Border all around, top aligned - 5 // Border width - ); -} - -void wxWizard::DoCreateControls() -{ - // do nothing if the controls were already created - if ( WasCreated() ) - return; - - bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); - - // Horizontal stretching, and if not PDA, border all around - int mainColumnSizerFlags = isPda ? wxEXPAND : wxALL|wxEXPAND ; - - // wxWindow::SetSizer will be called at end - wxBoxSizer *windowSizer = new wxBoxSizer(wxVERTICAL); - - wxBoxSizer *mainColumn = new wxBoxSizer(wxVERTICAL); - windowSizer->Add( - mainColumn, - 1, // Vertical stretching - mainColumnSizerFlags, - 5 // Border width - ); - - AddBitmapRow(mainColumn); - - if (!isPda) - AddStaticLine(mainColumn); - - AddButtonRow(mainColumn); - - SetSizer(windowSizer); -} - -void wxWizard::SetPageSize(const wxSize& size) -{ - wxCHECK_RET(!m_started, wxT("wxWizard::SetPageSize after RunWizard")); - m_sizePage = size; -} - -void wxWizard::FitToPage(const wxWizardPage *page) -{ - wxCHECK_RET(!m_started, wxT("wxWizard::FitToPage after RunWizard")); - - while ( page ) - { - wxSize size = page->GetBestSize(); - - m_sizePage.IncTo(size); - - page = page->GetNext(); - } -} - -bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward) -{ - wxASSERT_MSG( page != m_page, wxT("this is useless") ); - - wxSizerFlags flags(1); - flags.Border(wxALL, m_border).Expand(); - - if ( !m_started ) - { - if ( m_usingSizer ) - { - m_sizerBmpAndPage->Add(m_sizerPage, flags); - - // now that our layout is computed correctly, hide the pages - // artificially shown in wxWizardSizer::Insert() back again - m_sizerPage->HidePages(); - } - } - - - // remember the old bitmap (if any) to compare with the new one later - wxBitmap bmpPrev; - - // check for previous page - if ( m_page ) - { - // send the event to the old page - wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGING, GetId(), - goingForward, m_page); - if ( m_page->GetEventHandler()->ProcessEvent(event) && - !event.IsAllowed() ) - { - // vetoed by the page - return false; - } - - m_page->Hide(); - - bmpPrev = m_page->GetBitmap(); - - if ( !m_usingSizer ) - m_sizerBmpAndPage->Detach(m_page); - } - - // is this the end? - if ( !page ) - { - // terminate successfully - if ( IsModal() ) - { - EndModal(wxID_OK); - } - else - { - SetReturnCode(wxID_OK); - Hide(); - } - - // and notify the user code (this is especially useful for modeless - // wizards) - wxWizardEvent event(wxEVT_WIZARD_FINISHED, GetId(), false, m_page); - (void)GetEventHandler()->ProcessEvent(event); - - m_page = NULL; - - return true; - } - - // notice that we change m_page only here so that wxEVT_WIZARD_FINISHED - // event above could still use the correct (i.e. old) value of m_page - m_page = page; - - // position and show the new page - (void)m_page->TransferDataToWindow(); - - if ( m_usingSizer ) - { - // wxWizardSizer::RecalcSizes wants to be called when m_page changes - m_sizerPage->RecalcSizes(); - } - else // pages are not managed by the sizer - { - m_sizerBmpAndPage->Add(m_page, flags); - m_sizerBmpAndPage->SetItemMinSize(m_page, GetPageSize()); - } - -#if wxUSE_STATBMP - // update the bitmap if:it changed - wxBitmap bmp; - if ( m_statbmp ) - { - bmp = m_page->GetBitmap(); - if ( !bmp.IsOk() ) - bmp = m_bitmap; - - if ( !bmpPrev.IsOk() ) - bmpPrev = m_bitmap; - - if (!GetBitmapPlacement()) - { - if ( !bmp.IsSameAs(bmpPrev) ) - m_statbmp->SetBitmap(bmp); - } - } -#endif // wxUSE_STATBMP - - - // and update the buttons state - m_btnPrev->Enable(HasPrevPage(m_page)); - - const bool hasNext = HasNextPage(m_page); - const wxString label = hasNext ? _("&Next >") : _("&Finish"); - if ( label != m_btnNext->GetLabel() ) - m_btnNext->SetLabel(label); - - m_btnNext->SetDefault(); - - - // send the change event to the new page now - wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGED, GetId(), goingForward, m_page); - (void)m_page->GetEventHandler()->ProcessEvent(event); - - // and finally show it - m_page->Show(); - m_page->SetFocus(); - - if ( !m_usingSizer ) - m_sizerBmpAndPage->Layout(); - - if ( !m_started ) - { - m_started = true; - - DoWizardLayout(); - } - - if (GetBitmapPlacement() && m_statbmp) - { - ResizeBitmap(bmp); - - if ( !bmp.IsSameAs(bmpPrev) ) - m_statbmp->SetBitmap(bmp); - - if (m_usingSizer) - m_sizerPage->RecalcSizes(); - } - - wxWizardEvent pageShownEvent(wxEVT_WIZARD_PAGE_SHOWN, GetId(), - goingForward, m_page); - m_page->GetEventHandler()->ProcessEvent(pageShownEvent); - - return true; -} - -/// Do fit, and adjust to screen size if necessary -void wxWizard::DoWizardLayout() -{ - if ( wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA ) - { - if (CanDoLayoutAdaptation()) - DoLayoutAdaptation(); - else - GetSizer()->SetSizeHints(this); - - if ( m_posWizard == wxDefaultPosition ) - CentreOnScreen(); - } - - SetLayoutAdaptationDone(true); -} - -bool wxWizard::RunWizard(wxWizardPage *firstPage) -{ - wxCHECK_MSG( firstPage, false, wxT("can't run empty wizard") ); - - // can't return false here because there is no old page - (void)ShowPage(firstPage, true /* forward */); - - m_wasModal = true; - - return ShowModal() == wxID_OK; -} - -wxWizardPage *wxWizard::GetCurrentPage() const -{ - return m_page; -} - -wxSize wxWizard::GetPageSize() const -{ - // default width and height of the page - int DEFAULT_PAGE_WIDTH, - DEFAULT_PAGE_HEIGHT; - if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA ) - { - // Make the default page size small enough to fit on screen - DEFAULT_PAGE_WIDTH = wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2; - DEFAULT_PAGE_HEIGHT = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2; - } - else // !PDA - { - DEFAULT_PAGE_WIDTH = - DEFAULT_PAGE_HEIGHT = 270; - } - - // start with default minimal size - wxSize pageSize(DEFAULT_PAGE_WIDTH, DEFAULT_PAGE_HEIGHT); - - // make the page at least as big as specified by user - pageSize.IncTo(m_sizePage); - - if ( m_statbmp ) - { - // make the page at least as tall as the bitmap - pageSize.IncTo(wxSize(0, m_bitmap.GetHeight())); - } - - if ( m_usingSizer ) - { - // make it big enough to contain all pages added to the sizer - pageSize.IncTo(m_sizerPage->GetMaxChildSize()); - } - - return pageSize; -} - -wxSizer *wxWizard::GetPageAreaSizer() const -{ - return m_sizerPage; -} - -void wxWizard::SetBorder(int border) -{ - wxCHECK_RET(!m_started, wxT("wxWizard::SetBorder after RunWizard")); - - m_border = border; -} - -void wxWizard::OnCancel(wxCommandEvent& WXUNUSED(eventUnused)) -{ - // this function probably can never be called when we don't have an active - // page, but a small extra check won't hurt - wxWindow *win = m_page ? (wxWindow *)m_page : (wxWindow *)this; - - wxWizardEvent event(wxEVT_WIZARD_CANCEL, GetId(), false, m_page); - if ( !win->GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) - { - // no objections - close the dialog - if(IsModal()) - { - EndModal(wxID_CANCEL); - } - else - { - SetReturnCode(wxID_CANCEL); - Hide(); - } - } - //else: request to Cancel ignored -} - -void wxWizard::OnBackOrNext(wxCommandEvent& event) -{ - wxASSERT_MSG( (event.GetEventObject() == m_btnNext) || - (event.GetEventObject() == m_btnPrev), - wxT("unknown button") ); - - wxCHECK_RET( m_page, wxT("should have a valid current page") ); - - // ask the current page first: notice that we do it before calling - // GetNext/Prev() because the data transferred from the controls of the page - // may change the value returned by these methods - if ( !m_page->Validate() || !m_page->TransferDataFromWindow() ) - { - // the page data is incorrect, don't do anything - return; - } - - bool forward = event.GetEventObject() == m_btnNext; - - // Give the application a chance to set state which may influence GetNext()/GetPrev() - wxWizardEvent eventPreChanged(wxEVT_WIZARD_BEFORE_PAGE_CHANGED, GetId(), forward, m_page); - (void)m_page->GetEventHandler()->ProcessEvent(eventPreChanged); - - if (!eventPreChanged.IsAllowed()) - return; - - wxWizardPage *page; - if ( forward ) - { - page = m_page->GetNext(); - } - else // back - { - page = m_page->GetPrev(); - - wxASSERT_MSG( page, wxT("\"GetEventHandler()->ProcessEvent(eventHelp); - } -} - -void wxWizard::OnWizEvent(wxWizardEvent& event) -{ - // the dialogs have wxWS_EX_BLOCK_EVENTS style on by default but we want to - // propagate wxEVT_WIZARD_XXX to the parent (if any), so do it manually - if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) ) - { - // the event will be propagated anyhow - event.Skip(); - } - else - { - wxWindow *parent = GetParent(); - - if ( !parent || !parent->GetEventHandler()->ProcessEvent(event) ) - { - event.Skip(); - } - } - - if ( ( !m_wasModal ) && - event.IsAllowed() && - ( event.GetEventType() == wxEVT_WIZARD_FINISHED || - event.GetEventType() == wxEVT_WIZARD_CANCEL - ) - ) - { - Destroy(); - } -} - -void wxWizard::SetBitmap(const wxBitmap& bitmap) -{ - m_bitmap = bitmap; - if (m_statbmp) - m_statbmp->SetBitmap(m_bitmap); -} - -// ---------------------------------------------------------------------------- -// wxWizardEvent -// ---------------------------------------------------------------------------- - -wxWizardEvent::wxWizardEvent(wxEventType type, int id, bool direction, wxWizardPage* page) - : wxNotifyEvent(type, id) -{ - // Modified 10-20-2001 Robert Cavanaugh - // add the active page to the event data - m_direction = direction; - m_page = page; -} - -/// Do the adaptation -bool wxWizard::DoLayoutAdaptation() -{ - wxWindowList windows; - wxWindowList pages; - - // Make all the pages (that use sizers) scrollable - for ( wxSizerItemList::compatibility_iterator node = m_sizerPage->GetChildren().GetFirst(); node; node = node->GetNext() ) - { - wxSizerItem * const item = node->GetData(); - if ( item->IsWindow() ) - { - wxWizardPage* page = wxDynamicCast(item->GetWindow(), wxWizardPage); - if (page) - { - while (page) - { - if (!pages.Find(page) && page->GetSizer()) - { - // Create a scrolled window and reparent - wxScrolledWindow* scrolledWindow = new wxScrolledWindow(page, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxVSCROLL|wxHSCROLL|wxBORDER_NONE); - wxSizer* oldSizer = page->GetSizer(); - - wxSizer* newSizer = new wxBoxSizer(wxVERTICAL); - newSizer->Add(scrolledWindow,1, wxEXPAND, 0); - - page->SetSizer(newSizer, false /* don't delete the old sizer */); - - scrolledWindow->SetSizer(oldSizer); - - wxStandardDialogLayoutAdapter::DoReparentControls(page, scrolledWindow); - - pages.Append(page); - windows.Append(scrolledWindow); - } - page = page->GetNext(); - } - } - } - } - - wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows); - - // Size event doesn't get sent soon enough on wxGTK - DoLayout(); - - SetLayoutAdaptationDone(true); - - return true; -} - -bool wxWizard::ResizeBitmap(wxBitmap& bmp) -{ - if (!GetBitmapPlacement()) - return false; - - if (bmp.IsOk()) - { - wxSize pageSize = m_sizerPage->GetSize(); - if (pageSize == wxSize(0,0)) - pageSize = GetPageSize(); - int bitmapWidth = wxMax(bmp.GetWidth(), GetMinimumBitmapWidth()); - int bitmapHeight = pageSize.y; - - if (!m_statbmp->GetBitmap().IsOk() || m_statbmp->GetBitmap().GetHeight() != bitmapHeight) - { - wxBitmap bitmap(bitmapWidth, bitmapHeight); - { - wxMemoryDC dc; - dc.SelectObject(bitmap); - dc.SetBackground(wxBrush(m_bitmapBackgroundColour)); - dc.Clear(); - - if (GetBitmapPlacement() & wxWIZARD_TILE) - { - TileBitmap(wxRect(0, 0, bitmapWidth, bitmapHeight), dc, bmp); - } - else - { - int x, y; - - if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT) - x = 0; - else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT) - x = bitmapWidth - bmp.GetWidth(); - else - x = (bitmapWidth - bmp.GetWidth())/2; - - if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP) - y = 0; - else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM) - y = bitmapHeight - bmp.GetHeight(); - else - y = (bitmapHeight - bmp.GetHeight())/2; - - dc.DrawBitmap(bmp, x, y, true); - dc.SelectObject(wxNullBitmap); - } - } - - bmp = bitmap; - } - } - - return true; -} - -bool wxWizard::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap) -{ - int w = bitmap.GetWidth(); - int h = bitmap.GetHeight(); - - wxMemoryDC dcMem; - - dcMem.SelectObjectAsSource(bitmap); - - int i, j; - for (i = rect.x; i < rect.x + rect.width; i += w) - { - for (j = rect.y; j < rect.y + rect.height; j+= h) - dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0); - } - dcMem.SelectObject(wxNullBitmap); - - return true; -} - -#endif // wxUSE_WIZARDDLG diff --git a/Source/3rd Party/wx/src/msw/aboutdlg.cpp b/Source/3rd Party/wx/src/msw/aboutdlg.cpp deleted file mode 100644 index 5b100b81a..000000000 --- a/Source/3rd Party/wx/src/msw/aboutdlg.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/msw/aboutdlg.cpp -// Purpose: implementation of wxAboutBox() for wxMSW -// Author: Vadim Zeitlin -// Created: 2006-10-07 -// Copyright: (c) 2006 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_ABOUTDLG - -#ifndef WX_PRECOMP - #include "wx/msgdlg.h" -#endif //WX_PRECOMP - -#include "wx/aboutdlg.h" -#include "wx/generic/aboutdlgg.h" - -// ============================================================================ -// implementation -// ============================================================================ - -// our public entry point -void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) -{ - // we prefer to show a simple message box if we don't have any fields which - // can't be shown in it because as much as there is a standard about box - // under MSW at all, this is it - if ( info.IsSimple() ) - { - // build the text to show in the box - const wxString name = info.GetName(); - wxString msg; - msg << name; - if ( info.HasVersion() ) - { - msg << wxT('\n'); - msg << info.GetLongVersion(); - } - - msg << wxT("\n\n"); - - if ( info.HasCopyright() ) - msg << info.GetCopyrightToDisplay() << wxT('\n'); - - // add everything remaining - msg << info.GetDescriptionAndCredits(); - - wxMessageBox(msg, wxString::Format(_("About %s"), name), wxOK | wxCENTRE, parent); - } - else // simple "native" version is not enough - { - // we need to use the full-blown generic version - wxGenericAboutBox(info, parent); - } -} - -#endif // wxUSE_ABOUTDLG diff --git a/Source/3rd Party/wx/src/msw/accel.cpp b/Source/3rd Party/wx/src/msw/accel.cpp index 3b783d4e1..465ee8c30 100644 --- a/Source/3rd Party/wx/src/msw/accel.cpp +++ b/Source/3rd Party/wx/src/msw/accel.cpp @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/msw/accel.cpp +// Name: msw/accel.cpp // Purpose: wxAcceleratorTable // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: accel.cpp 56049 2008-10-03 12:13:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -32,7 +33,8 @@ #include "wx/accel.h" #include "wx/msw/private.h" -#include "wx/msw/private/keyboard.h" + +extern WXWORD wxCharCodeWXToMSW(int id, bool *isVirtual); IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) @@ -52,7 +54,7 @@ protected: HACCEL m_hAccel; bool m_ok; - wxDECLARE_NO_COPY_CLASS(wxAcceleratorRefData); + DECLARE_NO_COPY_CLASS(wxAcceleratorRefData) }; // ============================================================================ @@ -88,7 +90,7 @@ wxAcceleratorTable::wxAcceleratorTable(const wxString& resource) { m_refData = new wxAcceleratorRefData; - HACCEL hAccel = ::LoadAccelerators(wxGetInstance(), resource.t_str()); + HACCEL hAccel = ::LoadAccelerators(wxGetInstance(), resource); M_ACCELDATA->m_hAccel = hAccel; M_ACCELDATA->m_ok = hAccel != 0; } @@ -103,15 +105,19 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[] { int flags = entries[i].GetFlags(); - BYTE fVirt = FVIRTKEY; + BYTE fVirt = 0; if ( flags & wxACCEL_ALT ) - fVirt |= FALT; + fVirt |= FALT | FVIRTKEY; if ( flags & wxACCEL_SHIFT ) - fVirt |= FSHIFT; + fVirt |= FSHIFT | FVIRTKEY; if ( flags & wxACCEL_CTRL ) - fVirt |= FCONTROL; + fVirt |= FCONTROL | FVIRTKEY; - WORD key = wxMSWKeyboard::WXToVK(entries[i].GetKeyCode()); + bool isVirtual; + + WORD key = wxCharCodeWXToMSW(entries[i].GetKeyCode(), &isVirtual); + if (isVirtual) + fVirt |= FVIRTKEY; arr[i].fVirt = fVirt; arr[i].key = key; @@ -147,7 +153,7 @@ WXHACCEL wxAcceleratorTable::GetHACCEL() const bool wxAcceleratorTable::Translate(wxWindow *window, WXMSG *wxmsg) const { MSG *msg = (MSG *)wxmsg; - return IsOk() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg); + return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg); } #endif // wxUSE_ACCEL diff --git a/Source/3rd Party/wx/src/msw/anybutton.cpp b/Source/3rd Party/wx/src/msw/anybutton.cpp deleted file mode 100644 index b5d6dc84c..000000000 --- a/Source/3rd Party/wx/src/msw/anybutton.cpp +++ /dev/null @@ -1,1378 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/msw/anybutton.cpp -// Purpose: wxAnyButton -// Author: Julian Smart -// Created: 1998-01-04 (extracted from button.cpp) -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifdef wxHAS_ANY_BUTTON - -#include "wx/anybutton.h" - -#ifndef WX_PRECOMP - #include "wx/app.h" - #include "wx/brush.h" - #include "wx/panel.h" - #include "wx/bmpbuttn.h" - #include "wx/settings.h" - #include "wx/dcscreen.h" - #include "wx/dcclient.h" - #include "wx/toplevel.h" - #include "wx/msw/wrapcctl.h" - #include "wx/msw/private.h" - #include "wx/msw/missing.h" -#endif - -#include "wx/imaglist.h" -#include "wx/stockitem.h" -#include "wx/msw/private/button.h" -#include "wx/msw/private/dc.h" -#include "wx/private/window.h" - -#if wxUSE_MARKUP - #include "wx/generic/private/markuptext.h" -#endif // wxUSE_MARKUP - -using namespace wxMSWImpl; - -#if wxUSE_UXTHEME - #include "wx/msw/uxtheme.h" - - // no need to include tmschema.h - #ifndef BP_PUSHBUTTON - #define BP_PUSHBUTTON 1 - - #define PBS_NORMAL 1 - #define PBS_HOT 2 - #define PBS_PRESSED 3 - #define PBS_DISABLED 4 - #define PBS_DEFAULTED 5 - - #define TMT_CONTENTMARGINS 3602 - #endif - - // provide the necessary declarations ourselves if they're missing from - // headers - #ifndef BCM_SETIMAGELIST - #define BCM_SETIMAGELIST 0x1602 - #define BCM_SETTEXTMARGIN 0x1604 - - enum - { - BUTTON_IMAGELIST_ALIGN_LEFT, - BUTTON_IMAGELIST_ALIGN_RIGHT, - BUTTON_IMAGELIST_ALIGN_TOP, - BUTTON_IMAGELIST_ALIGN_BOTTOM - }; - - struct BUTTON_IMAGELIST - { - HIMAGELIST himl; - RECT margin; - UINT uAlign; - }; - #endif -#endif // wxUSE_UXTHEME - -#ifndef WM_THEMECHANGED - #define WM_THEMECHANGED 0x031A -#endif - -#ifndef ODS_NOACCEL - #define ODS_NOACCEL 0x0100 -#endif - -#ifndef ODS_NOFOCUSRECT - #define ODS_NOFOCUSRECT 0x0200 -#endif - -#if wxUSE_UXTHEME -extern wxWindowMSW *wxWindowBeingErased; // From src/msw/window.cpp -#endif // wxUSE_UXTHEME - -// ---------------------------------------------------------------------------- -// button image data -// ---------------------------------------------------------------------------- - -// we use different data classes for owner drawn buttons and for themed XP ones - -class wxButtonImageData -{ -public: - wxButtonImageData() { } - virtual ~wxButtonImageData() { } - - virtual wxBitmap GetBitmap(wxAnyButton::State which) const = 0; - virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which) = 0; - - virtual wxSize GetBitmapMargins() const = 0; - virtual void SetBitmapMargins(wxCoord x, wxCoord y) = 0; - - virtual wxDirection GetBitmapPosition() const = 0; - virtual void SetBitmapPosition(wxDirection dir) = 0; - -private: - wxDECLARE_NO_COPY_CLASS(wxButtonImageData); -}; - -namespace -{ - -// the gap between button edge and the interior area used by Windows for the -// standard buttons -const int OD_BUTTON_MARGIN = 4; - -class wxODButtonImageData : public wxButtonImageData -{ -public: - wxODButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap) - { - SetBitmap(bitmap, wxAnyButton::State_Normal); -#if wxUSE_IMAGE - SetBitmap(bitmap.ConvertToDisabled(), wxAnyButton::State_Disabled); -#endif - m_dir = wxLEFT; - - // we use margins when we have both bitmap and text, but when we have - // only the bitmap it should take up the entire button area - if ( btn->ShowsLabel() ) - { - m_margin.x = btn->GetCharWidth(); - m_margin.y = btn->GetCharHeight() / 2; - } - } - - virtual wxBitmap GetBitmap(wxAnyButton::State which) const - { - return m_bitmaps[which]; - } - - virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which) - { - m_bitmaps[which] = bitmap; - } - - virtual wxSize GetBitmapMargins() const - { - return m_margin; - } - - virtual void SetBitmapMargins(wxCoord x, wxCoord y) - { - m_margin = wxSize(x, y); - } - - virtual wxDirection GetBitmapPosition() const - { - return m_dir; - } - - virtual void SetBitmapPosition(wxDirection dir) - { - m_dir = dir; - } - -private: - // just store the values passed to us to be able to retrieve them later - // from the drawing code - wxBitmap m_bitmaps[wxAnyButton::State_Max]; - wxSize m_margin; - wxDirection m_dir; - - wxDECLARE_NO_COPY_CLASS(wxODButtonImageData); -}; - -#if wxUSE_UXTHEME - -// somehow the margin is one pixel greater than the value returned by -// GetThemeMargins() call -const int XP_BUTTON_EXTRA_MARGIN = 1; - -class wxXPButtonImageData : public wxButtonImageData -{ -public: - // we must be constructed with the size of our images as we need to create - // the image list - wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap) - : m_iml(bitmap.GetWidth(), bitmap.GetHeight(), - !bitmap.HasAlpha() /* use mask only if no alpha */, - wxAnyButton::State_Max + 1 /* see "pulse" comment below */), - m_hwndBtn(GetHwndOf(btn)) - { - // initialize all bitmaps except for the disabled one to normal state - for ( int n = 0; n < wxAnyButton::State_Max; n++ ) - { -#if wxUSE_IMAGE - m_iml.Add(n == wxAnyButton::State_Disabled ? bitmap.ConvertToDisabled() - : bitmap); -#else - m_iml.Add(bitmap); -#endif - } - - // In addition to the states supported by wxWidgets such as normal, - // hot, pressed, disabled and focused, we need to add bitmap for - // another state when running under Windows 7 -- the so called "stylus - // hot" state corresponding to PBS_STYLUSHOT constant. While it's - // documented in MSDN as being only used with tablets, it is a lie as - // a focused button actually alternates between the image list elements - // with PBS_DEFAULTED and PBS_STYLUSHOT indices and, in particular, - // just disappears during half of the time if the latter is not set so - // we absolutely must set it. - // - // This also explains why we need to allocate an extra slot in the - // image list ctor above, the slot State_Max is used for this one. - m_iml.Add(bitmap); - - m_data.himl = GetHimagelistOf(&m_iml); - - // no margins by default - m_data.margin.left = - m_data.margin.right = - m_data.margin.top = - m_data.margin.bottom = 0; - - // use default alignment - m_data.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT; - - UpdateImageInfo(); - } - - virtual wxBitmap GetBitmap(wxAnyButton::State which) const - { - return m_iml.GetBitmap(which); - } - - virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which) - { - m_iml.Replace(which, bitmap); - - // As we want the focused button to always show its bitmap, we need to - // update the "stylus hot" one to match it to avoid any pulsing. - if ( which == wxAnyButton::State_Focused ) - m_iml.Replace(wxAnyButton::State_Max, bitmap); - - UpdateImageInfo(); - } - - virtual wxSize GetBitmapMargins() const - { - return wxSize(m_data.margin.left, m_data.margin.top); - } - - virtual void SetBitmapMargins(wxCoord x, wxCoord y) - { - RECT& margin = m_data.margin; - margin.left = - margin.right = x; - margin.top = - margin.bottom = y; - - if ( !::SendMessage(m_hwndBtn, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin) ) - { - wxLogDebug("SendMessage(BCM_SETTEXTMARGIN) failed"); - } - } - - virtual wxDirection GetBitmapPosition() const - { - switch ( m_data.uAlign ) - { - default: - wxFAIL_MSG( "invalid image alignment" ); - // fall through - - case BUTTON_IMAGELIST_ALIGN_LEFT: - return wxLEFT; - - case BUTTON_IMAGELIST_ALIGN_RIGHT: - return wxRIGHT; - - case BUTTON_IMAGELIST_ALIGN_TOP: - return wxTOP; - - case BUTTON_IMAGELIST_ALIGN_BOTTOM: - return wxBOTTOM; - } - } - - virtual void SetBitmapPosition(wxDirection dir) - { - UINT alignNew; - switch ( dir ) - { - default: - wxFAIL_MSG( "invalid direction" ); - // fall through - - case wxLEFT: - alignNew = BUTTON_IMAGELIST_ALIGN_LEFT; - break; - - case wxRIGHT: - alignNew = BUTTON_IMAGELIST_ALIGN_RIGHT; - break; - - case wxTOP: - alignNew = BUTTON_IMAGELIST_ALIGN_TOP; - break; - - case wxBOTTOM: - alignNew = BUTTON_IMAGELIST_ALIGN_BOTTOM; - break; - } - - if ( alignNew != m_data.uAlign ) - { - m_data.uAlign = alignNew; - UpdateImageInfo(); - } - } - -private: - void UpdateImageInfo() - { - if ( !::SendMessage(m_hwndBtn, BCM_SETIMAGELIST, 0, (LPARAM)&m_data) ) - { - wxLogDebug("SendMessage(BCM_SETIMAGELIST) failed"); - } - } - - // we store image list separately to be able to use convenient wxImageList - // methods instead of working with raw HIMAGELIST - wxImageList m_iml; - - // store the rest of the data in BCM_SETIMAGELIST-friendly form - BUTTON_IMAGELIST m_data; - - // the button we're associated with - const HWND m_hwndBtn; - - - wxDECLARE_NO_COPY_CLASS(wxXPButtonImageData); -}; - -#endif // wxUSE_UXTHEME - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// helper functions from wx/msw/private/button.h -// ---------------------------------------------------------------------------- - -void wxMSWButton::UpdateMultilineStyle(HWND hwnd, const wxString& label) -{ - // update BS_MULTILINE style depending on the new label (resetting it - // doesn't seem to do anything very useful but it shouldn't hurt and we do - // have to set it whenever the label becomes multi line as otherwise it - // wouldn't be shown correctly as we don't use BS_MULTILINE when creating - // the control unless it already has new lines in its label) - long styleOld = ::GetWindowLong(hwnd, GWL_STYLE), - styleNew; - if ( label.find(wxT('\n')) != wxString::npos ) - styleNew = styleOld | BS_MULTILINE; - else - styleNew = styleOld & ~BS_MULTILINE; - - if ( styleNew != styleOld ) - ::SetWindowLong(hwnd, GWL_STYLE, styleNew); -} - -wxSize wxMSWButton::GetFittingSize(wxWindow *win, - const wxSize& sizeLabel, - int flags) -{ - wxSize sizeBtn = sizeLabel; - - // FIXME: The numbers here are pure guesswork, no idea how should the - // button margins be really calculated. - if ( flags & Size_ExactFit ) - { - // We still need some margin or the text would be overwritten, just - // make it as small as possible. - sizeBtn.x += (3*win->GetCharWidth()); - } - else - { - sizeBtn.x += 3*win->GetCharWidth(); - sizeBtn.y += win->GetCharHeight()/2; - } - - // account for the shield UAC icon if we have it - if ( flags & Size_AuthNeeded ) - sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X); - - return sizeBtn; -} - -wxSize wxMSWButton::ComputeBestFittingSize(wxControl *btn, int flags) -{ - wxClientDC dc(btn); - - wxSize sizeBtn; - dc.GetMultiLineTextExtent(btn->GetLabelText(), &sizeBtn.x, &sizeBtn.y); - - return GetFittingSize(btn, sizeBtn, flags); -} - -wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size) -{ - wxSize sizeBtn(size); - - // The 50x14 button size is documented in the "Recommended sizing and - // spacing" section of MSDN layout article. - // - // Note that we intentionally don't use GetDefaultSize() here, because - // it's inexact -- dialog units depend on this dialog's font. - const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); - - // All buttons should have at least the standard size, unless the user - // explicitly wants them to be as small as possible and used wxBU_EXACTFIT - // style to indicate this. - const bool incToStdSize = !btn->HasFlag(wxBU_EXACTFIT); - if ( incToStdSize ) - { - if ( sizeBtn.x < sizeDef.x ) - sizeBtn.x = sizeDef.x; - } - - // Notice that we really want to make all buttons with text label equally - // high, otherwise they look ugly and the existing code using wxBU_EXACTFIT - // only uses it to control width and not height. - if ( incToStdSize || !btn->GetLabel().empty() ) - { - if ( sizeBtn.y < sizeDef.y ) - sizeBtn.y = sizeDef.y; - } - - btn->CacheBestSize(sizeBtn); - - return sizeBtn; -} - -// ---------------------------------------------------------------------------- -// creation/destruction -// ---------------------------------------------------------------------------- - -wxAnyButton::~wxAnyButton() -{ - delete m_imageData; -#if wxUSE_MARKUP - delete m_markupText; -#endif // wxUSE_MARKUP -} - -void wxAnyButton::SetLabel(const wxString& label) -{ - wxMSWButton::UpdateMultilineStyle(GetHwnd(), label); - - wxAnyButtonBase::SetLabel(label); - -#if wxUSE_MARKUP - // If we have a plain text label, we shouldn't be using markup any longer. - if ( m_markupText ) - { - delete m_markupText; - m_markupText = NULL; - - // Unfortunately we don't really know whether we can reset the button - // to be non-owner-drawn or not: if we had made it owner-drawn just - // because of a call to SetLabelMarkup(), we could, but not if there - // were [also] calls to Set{Fore,Back}groundColour(). If it's really a - // problem to have button remain owner-drawn forever just because it - // had markup label once, we should record the reason for our current - // owner-drawnness and check it here. - } -#endif // wxUSE_MARKUP -} - -// ---------------------------------------------------------------------------- -// size management including autosizing -// ---------------------------------------------------------------------------- - -void wxAnyButton::AdjustForBitmapSize(wxSize &size) const -{ - wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") ); - - // account for the bitmap size - const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize(); - const wxDirection dirBmp = m_imageData->GetBitmapPosition(); - if ( dirBmp == wxLEFT || dirBmp == wxRIGHT ) - { - size.x += sizeBmp.x; - if ( sizeBmp.y > size.y ) - size.y = sizeBmp.y; - } - else // bitmap on top/below the text - { - size.y += sizeBmp.y; - if ( sizeBmp.x > size.x ) - size.x = sizeBmp.x; - } - - // account for the user-specified margins - size += 2*m_imageData->GetBitmapMargins(); - - // and also for the margins we always add internally (unless we have no - // border at all in which case the button has exactly the same size as - // bitmap and so no margins should be used) - if ( !HasFlag(wxBORDER_NONE) ) - { - int marginH = 0, - marginV = 0; -#if wxUSE_UXTHEME - if ( wxUxThemeEngine::GetIfActive() ) - { - wxUxThemeHandle theme(const_cast(this), L"BUTTON"); - - MARGINS margins; - wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL, - BP_PUSHBUTTON, - PBS_NORMAL, - TMT_CONTENTMARGINS, - NULL, - &margins); - - // XP doesn't draw themed buttons correctly when the client - // area is smaller than 8x8 - enforce this minimum size for - // small bitmaps - size.IncTo(wxSize(8, 8)); - - marginH = margins.cxLeftWidth + margins.cxRightWidth - + 2*XP_BUTTON_EXTRA_MARGIN; - marginV = margins.cyTopHeight + margins.cyBottomHeight - + 2*XP_BUTTON_EXTRA_MARGIN; - } - else -#endif // wxUSE_UXTHEME - { - marginH = - marginV = OD_BUTTON_MARGIN; - } - - size.IncBy(marginH, marginV); - } -} - -wxSize wxAnyButton::DoGetBestSize() const -{ - wxAnyButton * const self = const_cast(this); - - wxSize size; - - // Account for the text part if we have it. - if ( ShowsLabel() ) - { - int flags = 0; - if ( HasFlag(wxBU_EXACTFIT) ) - flags |= wxMSWButton::Size_ExactFit; - if ( DoGetAuthNeeded() ) - flags |= wxMSWButton::Size_AuthNeeded; - -#if wxUSE_MARKUP - if ( m_markupText ) - { - wxClientDC dc(self); - size = wxMSWButton::GetFittingSize(self, - m_markupText->Measure(dc), - flags); - } - else // Normal plain text (but possibly multiline) label. -#endif // wxUSE_MARKUP - { - size = wxMSWButton::ComputeBestFittingSize(self, flags); - } - } - - if ( m_imageData ) - AdjustForBitmapSize(size); - - return wxMSWButton::IncreaseToStdSizeAndCache(self, size); -} - -// ---------------------------------------------------------------------------- -// event/message handlers -// ---------------------------------------------------------------------------- - -WXLRESULT wxAnyButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) -{ - if ( nMsg == WM_LBUTTONDBLCLK ) - { - // emulate a click event to force an owner-drawn button to change its - // appearance - without this, it won't do it - (void)wxControl::MSWWindowProc(WM_LBUTTONDOWN, wParam, lParam); - - // and continue with processing the message normally as well - } -#if wxUSE_UXTHEME - else if ( nMsg == WM_THEMECHANGED ) - { - // need to recalculate the best size here - // as the theme size might have changed - InvalidateBestSize(); - } -#endif // wxUSE_UXTHEME - // must use m_mouseInWindow here instead of IsMouseInWindow() - // since we need to know the first time the mouse enters the window - // and IsMouseInWindow() would return true in this case - else if ( (nMsg == WM_MOUSEMOVE && !m_mouseInWindow) || - nMsg == WM_MOUSELEAVE ) - { - if ( - IsEnabled() && - ( -#if wxUSE_UXTHEME - wxUxThemeEngine::GetIfActive() || -#endif // wxUSE_UXTHEME - (m_imageData && m_imageData->GetBitmap(State_Current).IsOk()) - ) - ) - { - Refresh(); - } - } - - // let the base class do all real processing - return wxControl::MSWWindowProc(nMsg, wParam, lParam); -} - -// ---------------------------------------------------------------------------- -// button images -// ---------------------------------------------------------------------------- - -wxBitmap wxAnyButton::DoGetBitmap(State which) const -{ - return m_imageData ? m_imageData->GetBitmap(which) : wxBitmap(); -} - -void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which) -{ - if ( !bitmap.IsOk() ) - { - if ( m_imageData ) - { - // Normal image is special: setting it enables images for the - // button and resetting it to nothing disables all of them. - if ( which == State_Normal ) - { - delete m_imageData; - m_imageData = NULL; - } - else - { - // Replace the removed bitmap with the normal one. - wxBitmap bmpNormal = m_imageData->GetBitmap(State_Normal); - m_imageData->SetBitmap(which == State_Disabled - ? bmpNormal.ConvertToDisabled() - : bmpNormal, - which); - } - } - - return; - } - -#if wxUSE_UXTHEME - wxXPButtonImageData *oldData = NULL; -#endif // wxUSE_UXTHEME - - // Check if we already had bitmaps of different size. - if ( m_imageData && - bitmap.GetSize() != m_imageData->GetBitmap(State_Normal).GetSize() ) - { - wxASSERT_MSG( (which == State_Normal) || bitmap.IsNull(), - "Must set normal bitmap with the new size first" ); - -#if wxUSE_UXTHEME - if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() ) - { - // We can't change the size of the images stored in wxImageList - // in wxXPButtonImageData::m_iml so force recreating it below but - // keep the current data to copy its values into the new one. - oldData = static_cast(m_imageData); - m_imageData = NULL; - } -#endif // wxUSE_UXTHEME - //else: wxODButtonImageData doesn't require anything special - } - - // allocate the image data when the first bitmap is set - if ( !m_imageData ) - { -#if wxUSE_UXTHEME - // using image list doesn't work correctly if we don't have any label - // (even if we use BUTTON_IMAGELIST_ALIGN_CENTER alignment and - // BS_BITMAP style), at least under Windows 2003 so use owner drawn - // strategy for bitmap-only buttons - if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() ) - { - m_imageData = new wxXPButtonImageData(this, bitmap); - - if ( oldData ) - { - // Preserve the old values in case the user changed them. - m_imageData->SetBitmapPosition(oldData->GetBitmapPosition()); - - const wxSize oldMargins = oldData->GetBitmapMargins(); - m_imageData->SetBitmapMargins(oldMargins.x, oldMargins.y); - - // No need to preserve the bitmaps though as they were of wrong - // size anyhow. - - delete oldData; - } - } - else -#endif // wxUSE_UXTHEME - { - m_imageData = new wxODButtonImageData(this, bitmap); - MakeOwnerDrawn(); - } - } - else - { - m_imageData->SetBitmap(bitmap, which); - } - - // it should be enough to only invalidate the best size when the normal - // bitmap changes as all bitmaps assigned to the button should be of the - // same size anyhow - if ( which == State_Normal ) - InvalidateBestSize(); - - Refresh(); -} - -wxSize wxAnyButton::DoGetBitmapMargins() const -{ - return m_imageData ? m_imageData->GetBitmapMargins() : wxSize(0, 0); -} - -void wxAnyButton::DoSetBitmapMargins(wxCoord x, wxCoord y) -{ - wxCHECK_RET( m_imageData, "SetBitmap() must be called first" ); - - m_imageData->SetBitmapMargins(x, y); - InvalidateBestSize(); -} - -void wxAnyButton::DoSetBitmapPosition(wxDirection dir) -{ - if ( m_imageData ) - m_imageData->SetBitmapPosition(dir); - InvalidateBestSize(); -} - -// ---------------------------------------------------------------------------- -// markup support -// ---------------------------------------------------------------------------- - -#if wxUSE_MARKUP - -bool wxAnyButton::DoSetLabelMarkup(const wxString& markup) -{ - if ( !wxAnyButtonBase::DoSetLabelMarkup(markup) ) - return false; - - if ( !m_markupText ) - { - m_markupText = new wxMarkupText(markup); - MakeOwnerDrawn(); - } - else - { - // We are already owner-drawn so just update the text. - m_markupText->SetMarkup(markup); - } - - Refresh(); - - return true; -} - -#endif // wxUSE_MARKUP - -// ---------------------------------------------------------------------------- -// owner-drawn buttons support -// ---------------------------------------------------------------------------- - -// drawing helpers -namespace -{ - -// return the button state using both the ODS_XXX flags specified in state -// parameter and the current button state -wxAnyButton::State GetButtonState(wxAnyButton *btn, UINT state) -{ - if ( state & ODS_DISABLED ) - return wxAnyButton::State_Disabled; - - // We need to check for the pressed state of the button itself before the - // other checks because even if it is selected or current, it it still - // pressed first and foremost. - const wxAnyButton::State btnState = btn->GetNormalState(); - - if ( btnState == wxAnyButton::State_Pressed || state & ODS_SELECTED ) - return wxAnyButton::State_Pressed; - - if ( btn->HasCapture() || btn->IsMouseInWindow() ) - return wxAnyButton::State_Current; - - if ( state & ODS_FOCUS ) - return wxAnyButton::State_Focused; - - return btnState; -} - -void DrawButtonText(HDC hdc, - RECT *pRect, - wxAnyButton *btn, - int flags) -{ - const wxString text = btn->GetLabel(); - - // To get a native look for owner-drawn button in disabled state (without - // theming) we must use DrawState() to draw the text label. - if ( !wxUxThemeEngine::GetIfActive() && !btn->IsEnabled() ) - { - // However using DrawState() has some drawbacks: - // 1. It generally doesn't support alignment flags (except right - // alignment), so we need to align the text on our own. - // 2. It doesn't support multliline texts and there is necessary to - // draw/align multiline text line by line. - - // Compute bounding rect for the whole text. - RECT rc; - ::SetRectEmpty(&rc); - ::DrawText(hdc, text.t_str(), text.length(), &rc, DT_CALCRECT); - - const LONG h = rc.bottom - rc.top; - - // Based on wxButton flags determine bottom edge of the drawing rect - // inside the entire button area. - int y0; - if ( btn->HasFlag(wxBU_BOTTOM) ) - { - y0 = pRect->bottom - h; - } - else if ( !btn->HasFlag(wxBU_TOP) ) - { - // DT_VCENTER - y0 = pRect->top + (pRect->bottom - pRect->top)/2 - h/2; - } - else // DT_TOP is the default - { - y0 = pRect->top; - } - - UINT dsFlags = DSS_DISABLED; - if( flags & DT_HIDEPREFIX ) - dsFlags |= (DSS_HIDEPREFIX | DST_PREFIXTEXT); - else - dsFlags |= DST_TEXT; - - const wxArrayString lines = wxSplit(text, '\n', '\0'); - const int hLine = h / lines.size(); - for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) - { - // Each line must be aligned in horizontal direction individually. - ::SetRectEmpty(&rc); - ::DrawText(hdc, lines[lineNum].t_str(), lines[lineNum].length(), - &rc, DT_CALCRECT); - const LONG w = rc.right - rc.left; - - // Based on wxButton flags set horizontal position of the rect - // inside the entire button area. Text is always centered for - // multiline label. - if ( (!btn->HasFlag(wxBU_LEFT) && !btn->HasFlag(wxBU_RIGHT)) || - lines.size() > 1 ) - { - // DT_CENTER - rc.left = pRect->left + (pRect->right - pRect->left)/2 - w/2; - rc.right = rc.left + w; - } - else if ( btn->HasFlag(wxBU_RIGHT) ) - { - rc.right = pRect->right; - rc.left = rc.right - w; - } - else // DT_LEFT is the default - { - rc.left = pRect->left; - rc.right = rc.left + w; - } - - ::OffsetRect(&rc, 0, y0 + lineNum * hLine); - - ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(lines[lineNum]), - lines[lineNum].length(), - rc.left, rc.top, rc.right, rc.bottom, dsFlags); - } - } - else // Button is enabled or using themes. - { - if ( text.find(wxT('\n')) != wxString::npos ) - { - // draw multiline label - - // center text horizontally in any case - flags |= DT_CENTER; - - // first we need to compute its bounding rect - RECT rc; - ::CopyRect(&rc, pRect); - ::DrawText(hdc, text.t_str(), text.length(), &rc, - DT_CENTER | DT_CALCRECT); - - // now center this rect inside the entire button area - const LONG w = rc.right - rc.left; - const LONG h = rc.bottom - rc.top; - rc.left = pRect->left + (pRect->right - pRect->left)/2 - w/2; - rc.right = rc.left+w; - rc.top = pRect->top + (pRect->bottom - pRect->top)/2 - h/2; - rc.bottom = rc.top+h; - - ::DrawText(hdc, text.t_str(), text.length(), &rc, flags); - } - else // single line label - { - // translate wx button flags to alignment flags for DrawText() - if ( btn->HasFlag(wxBU_RIGHT) ) - { - flags |= DT_RIGHT; - } - else if ( !btn->HasFlag(wxBU_LEFT) ) - { - flags |= DT_CENTER; - } - //else: DT_LEFT is the default anyhow (and its value is 0 too) - - if ( btn->HasFlag(wxBU_BOTTOM) ) - { - flags |= DT_BOTTOM; - } - else if ( !btn->HasFlag(wxBU_TOP) ) - { - flags |= DT_VCENTER; - } - //else: as above, DT_TOP is the default - - // notice that we must have DT_SINGLELINE for vertical alignment - // flags to work - ::DrawText(hdc, text.t_str(), text.length(), pRect, - flags | DT_SINGLELINE ); - } - } -} - -void DrawRect(HDC hdc, const RECT& r) -{ - wxDrawLine(hdc, r.left, r.top, r.right, r.top); - wxDrawLine(hdc, r.right, r.top, r.right, r.bottom); - wxDrawLine(hdc, r.right, r.bottom, r.left, r.bottom); - wxDrawLine(hdc, r.left, r.bottom, r.left, r.top); -} - -/* - The button frame looks like this normally: - - WWWWWWWWWWWWWWWWWWB - WHHHHHHHHHHHHHHHHGB W = white (HILIGHT) - WH GB H = light grey (LIGHT) - WH GB G = dark grey (SHADOW) - WH GB B = black (DKSHADOW) - WH GB - WGGGGGGGGGGGGGGGGGB - BBBBBBBBBBBBBBBBBBB - - When the button is selected, the button becomes like this (the total button - size doesn't change): - - BBBBBBBBBBBBBBBBBBB - BWWWWWWWWWWWWWWWWBB - BWHHHHHHHHHHHHHHGBB - BWH GBB - BWH GBB - BWGGGGGGGGGGGGGGGBB - BBBBBBBBBBBBBBBBBBB - BBBBBBBBBBBBBBBBBBB - - When the button is pushed (while selected) it is like: - - BBBBBBBBBBBBBBBBBBB - BGGGGGGGGGGGGGGGGGB - BG GB - BG GB - BG GB - BG GB - BGGGGGGGGGGGGGGGGGB - BBBBBBBBBBBBBBBBBBB -*/ -void DrawButtonFrame(HDC hdc, RECT& rectBtn, - bool selected, bool pushed) -{ - RECT r; - CopyRect(&r, &rectBtn); - - AutoHPEN hpenBlack(GetSysColor(COLOR_3DDKSHADOW)), - hpenGrey(GetSysColor(COLOR_3DSHADOW)), - hpenLightGr(GetSysColor(COLOR_3DLIGHT)), - hpenWhite(GetSysColor(COLOR_3DHILIGHT)); - - SelectInHDC selectPen(hdc, hpenBlack); - - r.right--; - r.bottom--; - - if ( pushed ) - { - DrawRect(hdc, r); - - (void)SelectObject(hdc, hpenGrey); - ::InflateRect(&r, -1, -1); - - DrawRect(hdc, r); - } - else // !pushed - { - if ( selected ) - { - DrawRect(hdc, r); - - ::InflateRect(&r, -1, -1); - } - - wxDrawLine(hdc, r.left, r.bottom, r.right, r.bottom); - wxDrawLine(hdc, r.right, r.bottom, r.right, r.top - 1); - - (void)SelectObject(hdc, hpenWhite); - wxDrawLine(hdc, r.left, r.bottom - 1, r.left, r.top); - wxDrawLine(hdc, r.left, r.top, r.right, r.top); - - (void)SelectObject(hdc, hpenLightGr); - wxDrawLine(hdc, r.left + 1, r.bottom - 2, r.left + 1, r.top + 1); - wxDrawLine(hdc, r.left + 1, r.top + 1, r.right - 1, r.top + 1); - - (void)SelectObject(hdc, hpenGrey); - wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1); - wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top); - } - - InflateRect(&rectBtn, -OD_BUTTON_MARGIN, -OD_BUTTON_MARGIN); -} - -#if wxUSE_UXTHEME -void DrawXPBackground(wxAnyButton *button, HDC hdc, RECT& rectBtn, UINT state) -{ - wxUxThemeHandle theme(button, L"BUTTON"); - - // this array is indexed by wxAnyButton::State values and so must be kept in - // sync with it - static const int uxStates[] = - { - PBS_NORMAL, PBS_HOT, PBS_PRESSED, PBS_DISABLED, PBS_DEFAULTED - }; - - int iState = uxStates[GetButtonState(button, state)]; - - wxUxThemeEngine * const engine = wxUxThemeEngine::Get(); - - // draw parent background if needed - if ( engine->IsThemeBackgroundPartiallyTransparent - ( - theme, - BP_PUSHBUTTON, - iState - ) ) - { - // Set this button as the one whose background is being erased: this - // allows our WM_ERASEBKGND handler used by DrawThemeParentBackground() - // to correctly align the background brush with this window instead of - // the parent window to which WM_ERASEBKGND is sent. Notice that this - // doesn't work with custom user-defined EVT_ERASE_BACKGROUND handlers - // as they won't be aligned but unfortunately all the attempts to fix - // it by shifting DC origin before calling DrawThemeParentBackground() - // failed to work so we at least do this, even though this is far from - // being the perfect solution. - wxWindowBeingErased = button; - - engine->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn); - - wxWindowBeingErased = NULL; - } - - // draw background - engine->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, - &rectBtn, NULL); - - // calculate content area margins - MARGINS margins; - engine->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, - TMT_CONTENTMARGINS, &rectBtn, &margins); - ::InflateRect(&rectBtn, -margins.cxLeftWidth, -margins.cyTopHeight); - ::InflateRect(&rectBtn, -XP_BUTTON_EXTRA_MARGIN, -XP_BUTTON_EXTRA_MARGIN); - - if ( button->UseBgCol() ) - { - COLORREF colBg = wxColourToRGB(button->GetBackgroundColour()); - AutoHBRUSH hbrushBackground(colBg); - - // don't overwrite the focus rect - RECT rectClient; - ::CopyRect(&rectClient, &rectBtn); - ::InflateRect(&rectClient, -1, -1); - FillRect(hdc, &rectClient, hbrushBackground); - } -} -#endif // wxUSE_UXTHEME - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// owner drawn buttons support -// ---------------------------------------------------------------------------- - -void wxAnyButton::MakeOwnerDrawn() -{ - if ( !IsOwnerDrawn() ) - { - // make it so - // note that BS_OWNERDRAW is not independent from other style bits - long style = GetWindowLong(GetHwnd(), GWL_STYLE); - style &= ~(BS_3STATE | BS_AUTO3STATE | BS_AUTOCHECKBOX | BS_AUTORADIOBUTTON | BS_CHECKBOX | BS_DEFPUSHBUTTON | BS_GROUPBOX | BS_PUSHBUTTON | BS_RADIOBUTTON | BS_PUSHLIKE); - style |= BS_OWNERDRAW; - SetWindowLong(GetHwnd(), GWL_STYLE, style); - } -} - -bool wxAnyButton::IsOwnerDrawn() const -{ - long style = GetWindowLong(GetHwnd(), GWL_STYLE); - return ( (style & BS_OWNERDRAW) == BS_OWNERDRAW ); -} - -bool wxAnyButton::SetBackgroundColour(const wxColour &colour) -{ - if ( !wxControl::SetBackgroundColour(colour) ) - { - // nothing to do - return false; - } - - MakeOwnerDrawn(); - - Refresh(); - - return true; -} - -bool wxAnyButton::SetForegroundColour(const wxColour &colour) -{ - if ( !wxControl::SetForegroundColour(colour) ) - { - // nothing to do - return false; - } - - MakeOwnerDrawn(); - - Refresh(); - - return true; -} - -bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) -{ - LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; - HDC hdc = lpDIS->hDC; - - UINT state = lpDIS->itemState; - switch ( GetButtonState(this, state) ) - { - case State_Disabled: - state |= ODS_DISABLED; - break; - case State_Pressed: - state |= ODS_SELECTED; - break; - case State_Focused: - state |= ODS_FOCUS; - break; - default: - break; - } - - bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0; - - RECT rectBtn; - CopyRect(&rectBtn, &lpDIS->rcItem); - - // draw the button background - if ( !HasFlag(wxBORDER_NONE) ) - { -#if wxUSE_UXTHEME - if ( wxUxThemeEngine::GetIfActive() ) - { - DrawXPBackground(this, hdc, rectBtn, state); - } - else -#endif // wxUSE_UXTHEME - { - COLORREF colBg = wxColourToRGB(GetBackgroundColour()); - - // first, draw the background - AutoHBRUSH hbrushBackground(colBg); - FillRect(hdc, &rectBtn, hbrushBackground); - - // draw the border for the current state - bool selected = (state & ODS_SELECTED) != 0; - if ( !selected ) - { - wxTopLevelWindow * - tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); - if ( tlw ) - { - selected = tlw->GetDefaultItem() == this; - } - } - - DrawButtonFrame(hdc, rectBtn, selected, pushed); - } - - // draw the focus rectangle if we need it - if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) ) - { - DrawFocusRect(hdc, &rectBtn); - -#if wxUSE_UXTHEME - if ( !wxUxThemeEngine::GetIfActive() ) -#endif // wxUSE_UXTHEME - { - if ( pushed ) - { - // the label is shifted by 1 pixel to create "pushed" effect - OffsetRect(&rectBtn, 1, 1); - } - } - } - } - - - // draw the image, if any - if ( m_imageData ) - { - wxBitmap bmp = m_imageData->GetBitmap(GetButtonState(this, state)); - if ( !bmp.IsOk() ) - bmp = m_imageData->GetBitmap(State_Normal); - - const wxSize sizeBmp = bmp.GetSize(); - const wxSize margin = m_imageData->GetBitmapMargins(); - const wxSize sizeBmpWithMargins(sizeBmp + 2*margin); - wxRect rectButton(wxRectFromRECT(rectBtn)); - - // for simplicity, we start with centred rectangle and then move it to - // the appropriate edge - wxRect rectBitmap = wxRect(sizeBmp).CentreIn(rectButton); - - // move bitmap only if we have a label, otherwise keep it centered - if ( ShowsLabel() ) - { - switch ( m_imageData->GetBitmapPosition() ) - { - default: - wxFAIL_MSG( "invalid direction" ); - // fall through - - case wxLEFT: - rectBitmap.x = rectButton.x + margin.x; - rectButton.x += sizeBmpWithMargins.x; - rectButton.width -= sizeBmpWithMargins.x; - break; - - case wxRIGHT: - rectBitmap.x = rectButton.GetRight() - sizeBmp.x - margin.x; - rectButton.width -= sizeBmpWithMargins.x; - break; - - case wxTOP: - rectBitmap.y = rectButton.y + margin.y; - rectButton.y += sizeBmpWithMargins.y; - rectButton.height -= sizeBmpWithMargins.y; - break; - - case wxBOTTOM: - rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y; - rectButton.height -= sizeBmpWithMargins.y; - break; - } - } - - wxDCTemp dst((WXHDC)hdc); - dst.DrawBitmap(bmp, rectBitmap.GetPosition(), true); - - wxCopyRectToRECT(rectButton, rectBtn); - } - - - // finally draw the label - if ( ShowsLabel() ) - { - COLORREF colFg = state & ODS_DISABLED - ? ::GetSysColor(COLOR_GRAYTEXT) - : wxColourToRGB(GetForegroundColour()); - - wxTextColoursChanger changeFg(hdc, colFg, CLR_INVALID); - wxBkModeChanger changeBkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); - -#if wxUSE_MARKUP - if ( m_markupText ) - { - wxDCTemp dc((WXHDC)hdc); - dc.SetTextForeground(wxColour(colFg)); - dc.SetFont(GetFont()); - - m_markupText->Render(dc, wxRectFromRECT(rectBtn), - state & ODS_NOACCEL - ? wxMarkupText::Render_Default - : wxMarkupText::Render_ShowAccels); - } - else // Plain text label -#endif // wxUSE_MARKUP - { - // notice that DT_HIDEPREFIX doesn't work on old (pre-Windows 2000) - // systems but by happy coincidence ODS_NOACCEL is not used under - // them neither so DT_HIDEPREFIX should never be used there - DrawButtonText(hdc, &rectBtn, this, - state & ODS_NOACCEL ? DT_HIDEPREFIX : 0); - } - } - - return true; -} - -#endif // wxHAS_ANY_BUTTON diff --git a/Source/3rd Party/wx/src/msw/app.cpp b/Source/3rd Party/wx/src/msw/app.cpp index 28f4591f2..266ddc45c 100644 --- a/Source/3rd Party/wx/src/msw/app.cpp +++ b/Source/3rd Party/wx/src/msw/app.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: app.cpp 62085 2009-09-24 15:42:13Z JS $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -39,7 +40,7 @@ #include "wx/dialog.h" #include "wx/msgdlg.h" #include "wx/intl.h" - #include "wx/crt.h" + #include "wx/wxchar.h" #include "wx/log.h" #include "wx/module.h" #endif @@ -48,14 +49,9 @@ #include "wx/filename.h" #include "wx/dynlib.h" #include "wx/evtloop.h" -#include "wx/thread.h" -#include "wx/scopeguard.h" -#include "wx/vector.h" #include "wx/msw/private.h" -#include "wx/msw/dc.h" #include "wx/msw/ole/oleutils.h" -#include "wx/msw/private/timer.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" @@ -63,7 +59,7 @@ // OLE is used for drag-and-drop, clipboard, OLE Automation..., but some // compilers don't support it (missing headers, libs, ...) -#if defined(__GNUWIN32_OLD__) || defined(__SYMANTEC__) +#if defined(__GNUWIN32_OLD__) || defined(__SYMANTEC__) || defined(__SALFORDC__) #undef wxUSE_OLE #define wxUSE_OLE 0 @@ -81,7 +77,10 @@ #include #include -#include "wx/msw/missing.h" +// For MB_TASKMODAL +#ifdef __WXWINCE__ +#include "wx/msw/wince/missing.h" +#endif // instead of including which is not part of the core SDK and not // shipped at all with other compilers, we always define the parts of it we @@ -104,9 +103,6 @@ typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *); #endif // defined(DLLVERSIONINFO) -#ifndef ATTACH_PARENT_PROCESS - #define ATTACH_PARENT_PROCESS ((DWORD)-1) -#endif // --------------------------------------------------------------------------- // global variables @@ -116,27 +112,19 @@ extern void wxSetKeyboardHook(bool doIt); #endif -// because of mingw32 4.3 bug this struct can't be inside the namespace below: -// see http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/110282 -struct ClassRegInfo -{ - ClassRegInfo(const wxChar *name) - : regname(name), - regnameNR(regname + wxApp::GetNoRedrawClassSuffix()) - { - } - - // the name of the registered class with and without CS_[HV]REDRAW styles - wxString regname; - wxString regnameNR; -}; - -namespace -{ - -wxVector gs_regClassesInfo; - -} // anonymous namespace +// NB: all "NoRedraw" classes must have the same names as the "normal" classes +// with NR suffix - wxWindow::MSWCreate() supposes this +#ifdef __WXWINCE__ +WXDLLIMPEXP_CORE wxChar *wxCanvasClassName; +WXDLLIMPEXP_CORE wxChar *wxCanvasClassNameNR; +#else +WXDLLIMPEXP_CORE const wxChar *wxCanvasClassName = wxT("wxWindowClass"); +WXDLLIMPEXP_CORE const wxChar *wxCanvasClassNameNR = wxT("wxWindowClassNR"); +#endif +WXDLLIMPEXP_CORE const wxChar *wxMDIFrameClassName = wxT("wxMDIFrameClass"); +WXDLLIMPEXP_CORE const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR"); +WXDLLIMPEXP_CORE const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass"); +WXDLLIMPEXP_CORE const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR"); // ---------------------------------------------------------------------------- // private functions @@ -171,12 +159,12 @@ void *wxGUIAppTraits::BeforeChildWaitLoop() focus/activation entirely when the child process terminates which would happen if we simply disabled everything using wxWindowDisabler. Indeed, remember that Windows will never activate a disabled window and when the - last child's window is closed and Windows looks for a window to activate + last childs window is closed and Windows looks for a window to activate all our windows are still disabled. There is no way to enable them in - time because we don't know when the child's windows are going to be - closed, so the solution we use here is to keep one special tiny dialog + time because we don't know when the childs windows are going to be + closed, so the solution we use here is to keep one special tiny frame enabled all the time. Then when the child terminates it will get - activated and when we close it below -- after re-enabling all the other + activated and when we close it below -- after reenabling all the other windows! -- the previously active window becomes activated again and everything is ok. */ @@ -185,22 +173,27 @@ void *wxGUIAppTraits::BeforeChildWaitLoop() // first disable all existing windows wxWindowDisabler *wd = new wxWindowDisabler; - // then create an "invisible" dialog: it has minimal size, is positioned - // (hopefully) outside the screen and doesn't appear in the Alt-TAB list - // (unlike the frames, which is why we use a dialog here) - wxWindow *winActive = new wxDialog + // then create an "invisible" frame: it has minimal size, is positioned + // (hopefully) outside the screen and doesn't appear on the taskbar + wxWindow *winActive = new wxFrame ( wxTheApp->GetTopWindow(), wxID_ANY, wxEmptyString, wxPoint(32600, 32600), - wxSize(1, 1) + wxSize(1, 1), + wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR ); winActive->Show(); return new ChildWaitLoopData(wd, winActive); } +void wxGUIAppTraits::AlwaysYield() +{ + wxYield(); +} + void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig) { wxEndBusyCursor(); @@ -209,21 +202,20 @@ void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig) delete data->wd; - // finally delete the dummy dialog and, as wd has been already destroyed - // and the other windows reenabled, the activation is going to return to - // the window which had had it before + // finally delete the dummy frame and, as wd has been already destroyed and + // the other windows reenabled, the activation is going to return to the + // window which had had it before data->winActive->Destroy(); // also delete the temporary data object itself delete data; } -#if wxUSE_THREADS bool wxGUIAppTraits::DoMessageFromThreadWait() { // we should return false only if the app should exit, i.e. only if // Dispatch() determines that the main event loop should terminate - wxEventLoopBase * const evtLoop = wxEventLoop::GetActive(); + wxEventLoop *evtLoop = wxEventLoop::GetActive(); if ( !evtLoop || !evtLoop->Pending() ) { // no events means no quit event @@ -233,33 +225,6 @@ bool wxGUIAppTraits::DoMessageFromThreadWait() return evtLoop->Dispatch(); } -WXDWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread, int flags) -{ - // We only ever dispatch messages from the main thread and, additionally, - // even from the main thread we shouldn't wait for the message if we don't - // have a running event loop as we would never remove them from the message - // queue then and so we would enter an infinite loop as - // MsgWaitForMultipleObjects() keeps returning WAIT_OBJECT_0 + 1. - if ( flags == wxTHREAD_WAIT_BLOCK || - !wxIsMainThread() || - !wxEventLoop::GetActive() ) - { - // Simple blocking wait. - return DoSimpleWaitForThread(hThread); - } - - return ::MsgWaitForMultipleObjects - ( - 1, // number of objects to wait for - (HANDLE *)&hThread, // the objects - false, // wait for any objects, not all - INFINITE, // no timeout - QS_ALLINPUT | // return as soon as there are any events - QS_ALLPOSTMESSAGE - ); -} -#endif // wxUSE_THREADS - wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const { OSVERSIONINFO info; @@ -283,320 +248,6 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const #endif } -#if wxUSE_TIMER - -wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) -{ - return new wxMSWTimerImpl(timer); -} - -#endif // wxUSE_TIMER - -wxEventLoopBase* wxGUIAppTraits::CreateEventLoop() -{ - return new wxEventLoop; -} - -// --------------------------------------------------------------------------- -// Stuff for using console from the GUI applications -// --------------------------------------------------------------------------- - -#ifndef __WXWINCE__ - -#if wxUSE_DYNLIB_CLASS - -#include - -namespace -{ - -/* - Helper class to manipulate console from a GUI app. - - Notice that console output is available in the GUI app only if: - - AttachConsole() returns TRUE (which means it never works under pre-XP) - - we have a valid STD_ERROR_HANDLE - - command history hasn't been changed since our startup - - To check if all these conditions are verified, you need to simple call - IsOkToUse(). It will check the first two conditions above the first time it - is called (and if this fails, the subsequent calls will return immediately) - and also recheck the last one every time it is called. - */ -class wxConsoleStderr -{ -public: - // default ctor does nothing, call Init() before using this class - wxConsoleStderr() - { - m_hStderr = INVALID_HANDLE_VALUE; - m_historyLen = - m_dataLen = - m_dataLine = 0; - - m_ok = -1; - } - - ~wxConsoleStderr() - { - if ( m_hStderr != INVALID_HANDLE_VALUE ) - { - if ( !::FreeConsole() ) - { - wxLogLastError(wxT("FreeConsole")); - } - } - } - - // return true if we were successfully initialized and there had been no - // console activity which would interfere with our output since then - bool IsOkToUse() const - { - if ( m_ok == -1 ) - { - wxConsoleStderr * const self = const_cast(this); - self->m_ok = self->DoInit(); - - // no need to call IsHistoryUnchanged() as we just initialized - // m_history anyhow - return m_ok == 1; - } - - return m_ok && IsHistoryUnchanged(); - } - - - // output the provided text on the console, return true if ok - bool Write(const wxString& text); - -private: - // called by Init() once only to do the real initialization - bool DoInit(); - - // retrieve the command line history into the provided buffer and return - // its length - int GetCommandHistory(wxWxCharBuffer& buf) const; - - // check if the console history has changed - bool IsHistoryUnchanged() const; - - int m_ok; // initially -1, set to true or false by Init() - - wxDynamicLibrary m_dllKernel32; - - HANDLE m_hStderr; // console handle, if it's valid we must call - // FreeConsole() (even if m_ok != 1) - - wxWxCharBuffer m_history; // command history on startup - int m_historyLen; // length command history buffer - - wxCharBuffer m_data; // data between empty line and cursor position - int m_dataLen; // length data buffer - int m_dataLine; // line offset - - typedef DWORD (WINAPI *GetConsoleCommandHistory_t)(LPTSTR sCommands, - DWORD nBufferLength, - LPCTSTR sExeName); - typedef DWORD (WINAPI *GetConsoleCommandHistoryLength_t)(LPCTSTR sExeName); - - GetConsoleCommandHistory_t m_pfnGetConsoleCommandHistory; - GetConsoleCommandHistoryLength_t m_pfnGetConsoleCommandHistoryLength; - - wxDECLARE_NO_COPY_CLASS(wxConsoleStderr); -}; - -bool wxConsoleStderr::DoInit() -{ - HANDLE hStderr = ::GetStdHandle(STD_ERROR_HANDLE); - - if ( hStderr == INVALID_HANDLE_VALUE || !hStderr ) - return false; - - if ( !m_dllKernel32.Load(wxT("kernel32.dll")) ) - return false; - - typedef BOOL (WINAPI *AttachConsole_t)(DWORD dwProcessId); - AttachConsole_t wxDL_INIT_FUNC(pfn, AttachConsole, m_dllKernel32); - - if ( !pfnAttachConsole || !pfnAttachConsole(ATTACH_PARENT_PROCESS) ) - return false; - - // console attached, set m_hStderr now to ensure that we free it in the - // dtor - m_hStderr = hStderr; - - wxDL_INIT_FUNC_AW(m_pfn, GetConsoleCommandHistory, m_dllKernel32); - if ( !m_pfnGetConsoleCommandHistory ) - return false; - - wxDL_INIT_FUNC_AW(m_pfn, GetConsoleCommandHistoryLength, m_dllKernel32); - if ( !m_pfnGetConsoleCommandHistoryLength ) - return false; - - // remember the current command history to be able to compare with it later - // in IsHistoryUnchanged() - m_historyLen = GetCommandHistory(m_history); - if ( !m_history ) - return false; - - - // now find the first blank line above the current position - CONSOLE_SCREEN_BUFFER_INFO csbi; - - if ( !::GetConsoleScreenBufferInfo(m_hStderr, &csbi) ) - { - wxLogLastError(wxT("GetConsoleScreenBufferInfo")); - return false; - } - - COORD pos; - pos.X = 0; - pos.Y = csbi.dwCursorPosition.Y + 1; - - // we decide that a line is empty if first 4 characters are spaces - DWORD ret; - char buf[4]; - do - { - pos.Y--; - if ( !::ReadConsoleOutputCharacterA(m_hStderr, buf, WXSIZEOF(buf), - pos, &ret) ) - { - wxLogLastError(wxT("ReadConsoleOutputCharacterA")); - return false; - } - } while ( wxStrncmp(" ", buf, WXSIZEOF(buf)) != 0 ); - - // calculate line offset and length of data - m_dataLine = csbi.dwCursorPosition.Y - pos.Y; - m_dataLen = m_dataLine*csbi.dwMaximumWindowSize.X + csbi.dwCursorPosition.X; - - if ( m_dataLen > 0 ) - { - m_data.extend(m_dataLen); - if ( !::ReadConsoleOutputCharacterA(m_hStderr, m_data.data(), m_dataLen, - pos, &ret) ) - { - wxLogLastError(wxT("ReadConsoleOutputCharacterA")); - return false; - } - } - - return true; -} - -int wxConsoleStderr::GetCommandHistory(wxWxCharBuffer& buf) const -{ - // these functions are internal and may only be called by cmd.exe - static const wxChar *CMD_EXE = wxT("cmd.exe"); - - const int len = m_pfnGetConsoleCommandHistoryLength(CMD_EXE); - if ( len ) - { - buf.extend(len); - - int len2 = m_pfnGetConsoleCommandHistory(buf.data(), len, CMD_EXE); - -#if !wxUSE_UNICODE - // there seems to be a bug in the GetConsoleCommandHistoryA(), it - // returns the length of Unicode string and not ANSI one - len2 /= 2; -#endif // !wxUSE_UNICODE - - if ( len2 != len ) - { - wxFAIL_MSG( wxT("failed getting history?") ); - } - } - - return len; -} - -bool wxConsoleStderr::IsHistoryUnchanged() const -{ - wxASSERT_MSG( m_ok == 1, wxT("shouldn't be called if not initialized") ); - - // get (possibly changed) command history - wxWxCharBuffer history; - const int historyLen = GetCommandHistory(history); - - // and compare it with the original one - return historyLen == m_historyLen && history && - memcmp(m_history, history, historyLen) == 0; -} - -bool wxConsoleStderr::Write(const wxString& text) -{ - wxASSERT_MSG( m_hStderr != INVALID_HANDLE_VALUE, - wxT("should only be called if Init() returned true") ); - - // get current position - CONSOLE_SCREEN_BUFFER_INFO csbi; - if ( !::GetConsoleScreenBufferInfo(m_hStderr, &csbi) ) - { - wxLogLastError(wxT("GetConsoleScreenBufferInfo")); - return false; - } - - // and calculate new position (where is empty line) - csbi.dwCursorPosition.X = 0; - csbi.dwCursorPosition.Y -= m_dataLine; - - if ( !::SetConsoleCursorPosition(m_hStderr, csbi.dwCursorPosition) ) - { - wxLogLastError(wxT("SetConsoleCursorPosition")); - return false; - } - - DWORD ret; - if ( !::FillConsoleOutputCharacter(m_hStderr, wxT(' '), m_dataLen, - csbi.dwCursorPosition, &ret) ) - { - wxLogLastError(wxT("FillConsoleOutputCharacter")); - return false; - } - - if ( !::WriteConsole(m_hStderr, text.t_str(), text.length(), &ret, NULL) ) - { - wxLogLastError(wxT("WriteConsole")); - return false; - } - - WriteConsoleA(m_hStderr, m_data, m_dataLen, &ret, 0); - - return true; -} - -wxConsoleStderr s_consoleStderr; - -} // anonymous namespace - -bool wxGUIAppTraits::CanUseStderr() -{ - return s_consoleStderr.IsOkToUse(); -} - -bool wxGUIAppTraits::WriteToStderr(const wxString& text) -{ - return s_consoleStderr.IsOkToUse() && s_consoleStderr.Write(text); -} - -#else // !wxUSE_DYNLIB_CLASS - -bool wxGUIAppTraits::CanUseStderr() -{ - return false; -} - -bool wxGUIAppTraits::WriteToStderr(const wxString& WXUNUSED(text)) -{ - return false; -} - -#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS - -#endif // !__WXWINCE__ - // =========================================================================== // wxApp implementation // =========================================================================== @@ -638,6 +289,20 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // ensure that base cleanup is done if we return too early wxCallBaseCleanup callBaseCleanup(this); +#ifdef __WXWINCE__ + wxString tmp = GetAppName(); + tmp += wxT("ClassName"); + wxCanvasClassName = wxStrdup( tmp.c_str() ); + tmp += wxT("NR"); + wxCanvasClassNameNR = wxStrdup( tmp.c_str() ); + HWND hWnd = FindWindow( wxCanvasClassNameNR, NULL ); + if (hWnd) + { + SetForegroundWindow( (HWND)(((DWORD)hWnd)|0x01) ); + return false; + } +#endif + #if !defined(__WXMICROWIN__) InitCommonControls(); #endif // !defined(__WXMICROWIN__) @@ -646,8 +311,18 @@ bool wxApp::Initialize(int& argc, wxChar **argv) SHInitExtraControls(); #endif +#ifndef __WXWINCE__ + // Don't show a message box if a function such as SHGetFileInfo + // fails to find a device. + SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); +#endif + wxOleInitialize(); + RegisterWindowClasses(); + + wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100); + #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) wxSetKeyboardHook(true); #endif @@ -658,101 +333,153 @@ bool wxApp::Initialize(int& argc, wxChar **argv) } // --------------------------------------------------------------------------- -// Win32 window class registration +// RegisterWindowClasses // --------------------------------------------------------------------------- -/* static */ -const wxChar *wxApp::GetRegisteredClassName(const wxChar *name, - int bgBrushCol, - int extraStyles) +// TODO we should only register classes really used by the app. For this it +// would be enough to just delay the class registration until an attempt +// to create a window of this class is made. +bool wxApp::RegisterWindowClasses() { - const size_t count = gs_regClassesInfo.size(); - for ( size_t n = 0; n < count; n++ ) - { - if ( gs_regClassesInfo[n].regname == name ) - return gs_regClassesInfo[n].regname.c_str(); - } - - // we need to register this class WNDCLASS wndclass; wxZeroMemory(wndclass); + // for each class we register one with CS_(V|H)REDRAW style and one + // without for windows created with wxNO_FULL_REDRAW_ON_REPAINT flag + static const long styleNormal = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + static const long styleNoRedraw = CS_DBLCLKS; + + // the fields which are common to all classes wndclass.lpfnWndProc = (WNDPROC)wxWndProc; - wndclass.hInstance = wxGetInstance(); - wndclass.hCursor = ::LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)wxUIntToPtr(bgBrushCol + 1); - wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | extraStyles; + wndclass.hInstance = wxhInstance; + wndclass.hCursor = ::LoadCursor((HINSTANCE)NULL, IDC_ARROW); + // register the class for all normal windows + wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wndclass.lpszClassName = wxCanvasClassName; + wndclass.style = styleNormal; - ClassRegInfo regClass(name); - wndclass.lpszClassName = regClass.regname.t_str(); - if ( !::RegisterClass(&wndclass) ) + if ( !RegisterClass(&wndclass) ) { - wxLogLastError(wxString::Format(wxT("RegisterClass(%s)"), - regClass.regname)); - return NULL; + wxLogLastError(wxT("RegisterClass(frame)")); } - wndclass.style &= ~(CS_HREDRAW | CS_VREDRAW); - wndclass.lpszClassName = regClass.regnameNR.t_str(); - if ( !::RegisterClass(&wndclass) ) + // "no redraw" frame + wndclass.lpszClassName = wxCanvasClassNameNR; + wndclass.style = styleNoRedraw; + + if ( !RegisterClass(&wndclass) ) { - wxLogLastError(wxString::Format(wxT("RegisterClass(%s)"), - regClass.regname)); - ::UnregisterClass(regClass.regname.c_str(), wxGetInstance()); - return NULL; + wxLogLastError(wxT("RegisterClass(no redraw frame)")); } - gs_regClassesInfo.push_back(regClass); + // Register the MDI frame window class. + wndclass.hbrBackground = (HBRUSH)NULL; // paint MDI frame ourselves + wndclass.lpszClassName = wxMDIFrameClassName; + wndclass.style = styleNormal; - // take care to return the pointer which will remain valid after the - // function returns (it could be invalidated later if new elements are - // added to the vector and it's reallocated but this shouldn't matter as - // this pointer should be used right now, not stored) - return gs_regClassesInfo.back().regname.t_str(); + if ( !RegisterClass(&wndclass) ) + { + wxLogLastError(wxT("RegisterClass(MDI parent)")); + } + + // "no redraw" MDI frame + wndclass.lpszClassName = wxMDIFrameClassNameNoRedraw; + wndclass.style = styleNoRedraw; + + if ( !RegisterClass(&wndclass) ) + { + wxLogLastError(wxT("RegisterClass(no redraw MDI parent frame)")); + } + + // Register the MDI child frame window class. + wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wndclass.lpszClassName = wxMDIChildFrameClassName; + wndclass.style = styleNormal; + + if ( !RegisterClass(&wndclass) ) + { + wxLogLastError(wxT("RegisterClass(MDI child)")); + } + + // "no redraw" MDI child frame + wndclass.lpszClassName = wxMDIChildFrameClassNameNoRedraw; + wndclass.style = styleNoRedraw; + + if ( !RegisterClass(&wndclass) ) + { + wxLogLastError(wxT("RegisterClass(no redraw MDI child)")); + } + + return true; } -bool wxApp::IsRegisteredClassName(const wxString& name) +// --------------------------------------------------------------------------- +// UnregisterWindowClasses +// --------------------------------------------------------------------------- + +bool wxApp::UnregisterWindowClasses() { - const size_t count = gs_regClassesInfo.size(); - for ( size_t n = 0; n < count; n++ ) + bool retval = true; + +#ifndef __WXMICROWIN__ + // MDI frame window class. + if ( !::UnregisterClass(wxMDIFrameClassName, wxhInstance) ) { - if ( gs_regClassesInfo[n].regname == name || - gs_regClassesInfo[n].regnameNR == name ) - return true; + wxLogLastError(wxT("UnregisterClass(MDI parent)")); + + retval = false; } - return false; -} - -void wxApp::UnregisterWindowClasses() -{ - const size_t count = gs_regClassesInfo.size(); - for ( size_t n = 0; n < count; n++ ) + // "no redraw" MDI frame + if ( !::UnregisterClass(wxMDIFrameClassNameNoRedraw, wxhInstance) ) { - const ClassRegInfo& regClass = gs_regClassesInfo[n]; - if ( !::UnregisterClass(regClass.regname.c_str(), wxGetInstance()) ) - { - wxLogLastError(wxString::Format(wxT("UnregisterClass(%s)"), - regClass.regname)); - } + wxLogLastError(wxT("UnregisterClass(no redraw MDI parent frame)")); - if ( !::UnregisterClass(regClass.regnameNR.c_str(), wxGetInstance()) ) - { - wxLogLastError(wxString::Format(wxT("UnregisterClass(%s)"), - regClass.regnameNR)); - } + retval = false; } - gs_regClassesInfo.clear(); + // MDI child frame window class. + if ( !::UnregisterClass(wxMDIChildFrameClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(MDI child)")); + + retval = false; + } + + // "no redraw" MDI child frame + if ( !::UnregisterClass(wxMDIChildFrameClassNameNoRedraw, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw MDI child)")); + + retval = false; + } + + // canvas class name + if ( !::UnregisterClass(wxCanvasClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(canvas)")); + + retval = false; + } + + if ( !::UnregisterClass(wxCanvasClassNameNR, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw canvas)")); + + retval = false; + } +#endif // __WXMICROWIN__ + + return retval; } void wxApp::CleanUp() { - // all objects pending for deletion must be deleted first, otherwise - // UnregisterWindowClasses() call wouldn't succeed (because windows - // using the classes being unregistered still exist), so call the base - // class method first and only then do our clean up + // all objects pending for deletion must be deleted first, otherwise we + // would crash when they use wxWinHandleHash (and UnregisterWindowClasses() + // call wouldn't succeed as long as any windows still exist), so call the + // base class method first and only then do our clean up wxAppBase::CleanUp(); #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) @@ -766,6 +493,14 @@ void wxApp::CleanUp() // which case the registration will fail after the first time if we don't // unregister the classes now UnregisterWindowClasses(); + + delete wxWinHandleHash; + wxWinHandleHash = NULL; + +#ifdef __WXWINCE__ + free( wxCanvasClassName ); + free( wxCanvasClassNameNR ); +#endif } // ---------------------------------------------------------------------------- @@ -785,14 +520,16 @@ wxApp::~wxApp() // wxApp idle handling // ---------------------------------------------------------------------------- -void wxApp::OnIdle(wxIdleEvent& WXUNUSED(event)) +void wxApp::OnIdle(wxIdleEvent& event) { + wxAppBase::OnIdle(event); + #if wxUSE_DC_CACHEING // automated DC cache management: clear the cached DCs and bitmap // if it's likely that the app has finished with them, that is, we // get an idle event and we're not dragging anything. if (!::GetKeyState(MK_LBUTTON) && !::GetKeyState(MK_MBUTTON) && !::GetKeyState(MK_RBUTTON)) - wxMSWDCImpl::ClearCache(); + wxDC::ClearCache(); #endif // wxUSE_DC_CACHEING } @@ -819,15 +556,11 @@ void wxApp::WakeUpIdle() if ( !::PeekMessage(&msg, hwndTop, 0, 1, PM_NOREMOVE) || ::PeekMessage(&msg, hwndTop, 1, 1, PM_NOREMOVE) ) { - // If this fails too, there is really not much we can do, but then - // neither do we need to, as it normally indicates that the window - // queue is full to the brim with the messages and so the main loop - // is running and doesn't need to be woken up. - // - // Notice that we especially should not try use wxLogLastError() - // here as this would lead to another call to wxWakeUpIdle() from - // inside wxLog and stack overflow due to the resulting recursion. - ::PostMessage(hwndTop, WM_NULL, 0, 0); + if ( !::PostMessage(hwndTop, WM_NULL, 0, 0) ) + { + // should never happen + wxLogLastError(wxT("PostMessage(WM_NULL)")); + } } } #if wxUSE_THREADS @@ -842,24 +575,8 @@ void wxApp::WakeUpIdle() void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event)) { - // Windows will terminate the process soon after we return from - // WM_ENDSESSION handler or when we delete our last window, so make sure we - // at least execute our cleanup code before - - // prevent the window from being destroyed when the corresponding wxTLW is - // destroyed: this will result in a leak of a HWND, of course, but who - // cares when the process is being killed anyhow - if ( !wxTopLevelWindows.empty() ) - wxTopLevelWindows[0]->SetHWND(0); - - const int rc = OnExit(); - - wxEntryCleanup(); - - // calling exit() instead of ExitProcess() or not doing anything at all and - // being killed by Windows has the advantage of executing the dtors of - // global objects - exit(rc); + if (GetTopWindow()) + GetTopWindow()->Close(true); } // Default behaviour: close the application with prompts. The @@ -874,45 +591,15 @@ void wxApp::OnQueryEndSession(wxCloseEvent& event) } // ---------------------------------------------------------------------------- -// system DLL versions +// miscellaneous // ---------------------------------------------------------------------------- -// these functions have trivial inline implementations for CE -#ifndef __WXWINCE__ - -#if wxUSE_DYNLIB_CLASS - -namespace -{ - -// helper function: retrieve the DLL version by using DllGetVersion(), returns -// 0 if the DLL doesn't export such function -int CallDllGetVersion(wxDynamicLibrary& dll) -{ - // now check if the function is available during run-time - wxDYNLIB_FUNCTION( DLLGETVERSIONPROC, DllGetVersion, dll ); - if ( !pfnDllGetVersion ) - return 0; - - DLLVERSIONINFO dvi; - dvi.cbSize = sizeof(dvi); - - HRESULT hr = (*pfnDllGetVersion)(&dvi); - if ( FAILED(hr) ) - { - wxLogApiError(wxT("DllGetVersion"), hr); - - return 0; - } - - return 100*dvi.dwMajorVersion + dvi.dwMinorVersion; -} - -} // anonymous namespace - /* static */ int wxApp::GetComCtl32Version() { +#if defined(__WXMICROWIN__) || defined(__WXWINCE__) + return 0; +#else // cache the result // // NB: this is MT-ok as in the worst case we'd compute s_verComCtl32 twice, @@ -921,105 +608,138 @@ int wxApp::GetComCtl32Version() if ( s_verComCtl32 == -1 ) { + // initally assume no comctl32.dll at all + s_verComCtl32 = 0; + // we're prepared to handle the errors wxLogNull noLog; +#if wxUSE_DYNLIB_CLASS // we don't want to load comctl32.dll, it should be already loaded but, // depending on the OS version and the presence of the manifest, it can // be either v5 or v6 and instead of trying to guess it just get the // handle of the already loaded version - wxLoadedDLL dllComCtl32(wxT("comctl32.dll")); + wxLoadedDLL dllComCtl32(_T("comctl32.dll")); if ( !dllComCtl32.IsLoaded() ) { s_verComCtl32 = 0; return 0; } - // try DllGetVersion() for recent DLLs - s_verComCtl32 = CallDllGetVersion(dllComCtl32); - - // if DllGetVersion() is unavailable either during compile or - // run-time, try to guess the version otherwise - if ( !s_verComCtl32 ) + // if so, then we can check for the version + if ( dllComCtl32.IsLoaded() ) { - // InitCommonControlsEx is unique to 4.70 and later - void *pfn = dllComCtl32.GetSymbol(wxT("InitCommonControlsEx")); - if ( !pfn ) + // now check if the function is available during run-time + wxDYNLIB_FUNCTION( DLLGETVERSIONPROC, DllGetVersion, dllComCtl32 ); + if ( pfnDllGetVersion ) { - // not found, must be 4.00 - s_verComCtl32 = 400; - } - else // 4.70+ - { - // many symbols appeared in comctl32 4.71, could use any of - // them except may be DllInstall() - pfn = dllComCtl32.GetSymbol(wxT("InitializeFlatSB")); - if ( !pfn ) + DLLVERSIONINFO dvi; + dvi.cbSize = sizeof(dvi); + + HRESULT hr = (*pfnDllGetVersion)(&dvi); + if ( FAILED(hr) ) { - // not found, must be 4.70 - s_verComCtl32 = 470; + wxLogApiError(_T("DllGetVersion"), hr); } else { - // found, must be 4.71 or later - s_verComCtl32 = 471; + // this is incompatible with _WIN32_IE values, but + // compatible with the other values returned by + // GetComCtl32Version() + s_verComCtl32 = 100*dvi.dwMajorVersion + + dvi.dwMinorVersion; + } + } + + // if DllGetVersion() is unavailable either during compile or + // run-time, try to guess the version otherwise + if ( !s_verComCtl32 ) + { + // InitCommonControlsEx is unique to 4.70 and later + void *pfn = dllComCtl32.GetSymbol(_T("InitCommonControlsEx")); + if ( !pfn ) + { + // not found, must be 4.00 + s_verComCtl32 = 400; + } + else // 4.70+ + { + // many symbols appeared in comctl32 4.71, could use any of + // them except may be DllInstall() + pfn = dllComCtl32.GetSymbol(_T("InitializeFlatSB")); + if ( !pfn ) + { + // not found, must be 4.70 + s_verComCtl32 = 470; + } + else + { + // found, must be 4.71 or later + s_verComCtl32 = 471; + } } } } +#endif // wxUSE_DYNLIB_CLASS } return s_verComCtl32; +#endif // Microwin/!Microwin } -/* static */ -int wxApp::GetShell32Version() +// Yield to incoming messages + +bool wxApp::Yield(bool onlyIfNeeded) { - static int s_verShell32 = -1; - if ( s_verShell32 == -1 ) + // MT-FIXME + static bool s_inYield = false; + +#if wxUSE_LOG + // disable log flushing from here because a call to wxYield() shouldn't + // normally result in message boxes popping up &c + wxLog::Suspend(); +#endif // wxUSE_LOG + + if ( s_inYield ) { - // we're prepared to handle the errors - wxLogNull noLog; - - wxDynamicLibrary dllShell32(wxT("shell32.dll"), wxDL_VERBATIM); - if ( dllShell32.IsLoaded() ) + if ( !onlyIfNeeded ) { - s_verShell32 = CallDllGetVersion(dllShell32); + wxFAIL_MSG( wxT("wxYield called recursively" ) ); + } - if ( !s_verShell32 ) - { - // there doesn't seem to be any way to distinguish between 4.00 - // and 4.70 (starting from 4.71 we have DllGetVersion()) so - // just assume it is 4.0 - s_verShell32 = 400; - } - } - else // failed load the DLL? - { - s_verShell32 = 0; - } + return false; } - return s_verShell32; + s_inYield = true; + + // we don't want to process WM_QUIT from here - it should be processed in + // the main event loop in order to stop it + wxEventLoopGuarantor dummyLoopIfNeeded; + MSG msg; + while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) && + msg.message != WM_QUIT ) + { +#if wxUSE_THREADS + wxMutexGuiLeaveOrEnter(); +#endif // wxUSE_THREADS + + if ( !wxTheApp->Dispatch() ) + break; + } + + // if there are pending events, we must process them. + ProcessPendingEvents(); + +#if wxUSE_LOG + // let the logs be flashed again + wxLog::Resume(); +#endif // wxUSE_LOG + + s_inYield = false; + + return true; } -#else // !wxUSE_DYNLIB_CLASS - -/* static */ -int wxApp::GetComCtl32Version() -{ - return 0; -} - -/* static */ -int wxApp::GetShell32Version() -{ - return 0; -} - -#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS - -#endif // !__WXWINCE__ - #if wxUSE_EXCEPTIONS // ---------------------------------------------------------------------------- @@ -1034,10 +754,10 @@ bool wxApp::OnExceptionInMainLoop() ::MessageBox ( NULL, - wxT("An unhandled exception occurred. Press \"Abort\" to \ + _T("An unhandled exception occurred. Press \"Abort\" to \ terminate the program,\r\n\ \"Retry\" to exit the program normally and \"Ignore\" to try to continue."), - wxT("Unhandled exception"), + _T("Unhandled exception"), MB_ABORTRETRYIGNORE | MB_ICONERROR| MB_TASKMODAL @@ -1048,7 +768,7 @@ terminate the program,\r\n\ throw; default: - wxFAIL_MSG( wxT("unexpected MessageBox() return code") ); + wxFAIL_MSG( _T("unexpected MessageBox() return code") ); // fall through case IDRETRY: @@ -1060,3 +780,30 @@ terminate the program,\r\n\ } #endif // wxUSE_EXCEPTIONS + +// ---------------------------------------------------------------------------- +// deprecated event loop functions +// ---------------------------------------------------------------------------- + +#if WXWIN_COMPATIBILITY_2_4 + +void wxApp::DoMessage(WXMSG *pMsg) +{ + wxEventLoop *evtLoop = wxEventLoop::GetActive(); + if ( evtLoop ) + evtLoop->ProcessMessage(pMsg); +} + +bool wxApp::DoMessage() +{ + wxEventLoop *evtLoop = wxEventLoop::GetActive(); + return evtLoop ? evtLoop->Dispatch() : false; +} + +bool wxApp::ProcessMessage(WXMSG* pMsg) +{ + wxEventLoop *evtLoop = wxEventLoop::GetActive(); + return evtLoop && evtLoop->PreProcessMessage(pMsg); +} + +#endif // WXWIN_COMPATIBILITY_2_4 diff --git a/Source/3rd Party/wx/src/msw/artmsw.cpp b/Source/3rd Party/wx/src/msw/artmsw.cpp deleted file mode 100644 index 04885e3d6..000000000 --- a/Source/3rd Party/wx/src/msw/artmsw.cpp +++ /dev/null @@ -1,301 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/msw/artmsw.cpp -// Purpose: stock wxArtProvider instance with native MSW stock icons -// Author: Vaclav Slavik -// Modified by: -// Created: 2008-10-15 -// Copyright: (c) Vaclav Slavik, 2008 -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#include "wx/artprov.h" -#include "wx/image.h" -#include "wx/dynlib.h" -#include "wx/volume.h" -#include "wx/msw/private.h" -#include "wx/msw/wrapwin.h" - -#ifdef SHGSI_ICON - #define wxHAS_SHGetStockIconInfo -#endif - -namespace -{ - -#ifdef wxHAS_SHGetStockIconInfo - -SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id) -{ - // try to find an equivalent MSW stock icon id for wxArtID - if ( art_id == wxART_ERROR) return SIID_ERROR; - else if ( art_id == wxART_QUESTION ) return SIID_HELP; - else if ( art_id == wxART_WARNING ) return SIID_WARNING; - else if ( art_id == wxART_INFORMATION ) return SIID_INFO; - else if ( art_id == wxART_HELP ) return SIID_HELP; - else if ( art_id == wxART_FOLDER ) return SIID_FOLDER; - else if ( art_id == wxART_FOLDER_OPEN ) return SIID_FOLDEROPEN; - else if ( art_id == wxART_DELETE ) return SIID_DELETE; - else if ( art_id == wxART_FIND ) return SIID_FIND; - else if ( art_id == wxART_HARDDISK ) return SIID_DRIVEFIXED; - else if ( art_id == wxART_FLOPPY ) return SIID_DRIVE35; - else if ( art_id == wxART_CDROM ) return SIID_DRIVECD; - else if ( art_id == wxART_REMOVABLE ) return SIID_DRIVEREMOVE; - - return SIID_INVALID; -}; - - -// try to load SHGetStockIconInfo dynamically, so this code runs -// even on pre-Vista Windows versions -HRESULT -MSW_SHGetStockIconInfo(SHSTOCKICONID siid, - UINT uFlags, - SHSTOCKICONINFO *psii) -{ - typedef HRESULT (WINAPI *PSHGETSTOCKICONINFO)(SHSTOCKICONID, UINT, SHSTOCKICONINFO *); - static PSHGETSTOCKICONINFO pSHGetStockIconInfo = (PSHGETSTOCKICONINFO)-1; - - if ( pSHGetStockIconInfo == (PSHGETSTOCKICONINFO)-1 ) - { - wxDynamicLibrary shell32(wxT("shell32.dll")); - - pSHGetStockIconInfo = (PSHGETSTOCKICONINFO)shell32.RawGetSymbol( wxT("SHGetStockIconInfo") ); - } - - if ( !pSHGetStockIconInfo ) - return E_FAIL; - - return pSHGetStockIconInfo(siid, uFlags, psii); -} - -#endif // #ifdef wxHAS_SHGetStockIconInfo - -wxBitmap -MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) -{ - SHFILEINFO fi; - wxZeroMemory(fi); - - uFlags |= SHGFI_USEFILEATTRIBUTES | SHGFI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGFI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGFI_LARGEICON; - } - - if ( !SHGetFileInfo(path.t_str(), FILE_ATTRIBUTE_DIRECTORY, - &fi, sizeof(SHFILEINFO), uFlags) ) - return wxNullBitmap; - - wxIcon icon; - icon.CreateFromHICON((WXHICON)fi.hIcon); - - wxBitmap bitmap(icon); - ::DestroyIcon(fi.hIcon); - - return bitmap; -} - -#if wxUSE_FSVOLUME - -wxBitmap -GetDriveBitmapForVolumeType(const wxFSVolumeKind& volKind, const wxSize& size) -{ - // get all volumes and try to find one with a matching type - wxArrayString volumes = wxFSVolume::GetVolumes(); - for ( size_t i = 0; i < volumes.Count(); i++ ) - { - wxFSVolume vol( volumes[i] ); - if ( vol.GetKind() == volKind ) - { - return MSWGetBitmapForPath(volumes[i], size); - } - } - - return wxNullBitmap; -} - -#endif // wxUSE_FSVOLUME - -} // anonymous namespace - -// ---------------------------------------------------------------------------- -// wxWindowsArtProvider -// ---------------------------------------------------------------------------- - -class wxWindowsArtProvider : public wxArtProvider -{ -protected: - virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, - const wxSize& size); -}; - -static wxBitmap CreateFromStdIcon(const char *iconName, - const wxArtClient& client) -{ - wxIcon icon(iconName); - wxBitmap bmp; - bmp.CopyFromIcon(icon); - -#if wxUSE_IMAGE - // The standard native message box icons are in message box size (32x32). - // If they are requested in any size other than the default or message - // box size, they must be rescaled first. - if ( client != wxART_MESSAGE_BOX && client != wxART_OTHER ) - { - const wxSize size = wxArtProvider::GetNativeSizeHint(client); - if ( size != wxDefaultSize ) - { - wxImage img = bmp.ConvertToImage(); - img.Rescale(size.x, size.y); - bmp = wxBitmap(img); - } - } -#endif // wxUSE_IMAGE - - return bmp; -} - -wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, - const wxArtClient& client, - const wxSize& size) -{ - wxBitmap bitmap; - -#ifdef wxHAS_SHGetStockIconInfo - // first try to use SHGetStockIconInfo, available only on Vista and higher - SHSTOCKICONID stockIconId = MSWGetStockIconIdForArtProviderId( id ); - if ( stockIconId != SIID_INVALID ) - { - WinStruct sii; - - UINT uFlags = SHGSI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGSI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGSI_LARGEICON; - } - - HRESULT res = MSW_SHGetStockIconInfo(stockIconId, uFlags, &sii); - if ( res == S_OK ) - { - wxIcon icon; - icon.CreateFromHICON( (WXHICON)sii.hIcon ); - - wxBitmap bitmap( icon ); - ::DestroyIcon(sii.hIcon); - - if ( bitmap.IsOk() ) - return bitmap; - } - } -#endif // wxHAS_SHGetStockIconInfo - - -#if wxUSE_FSVOLUME - // now try SHGetFileInfo - wxFSVolumeKind volKind = wxFS_VOL_OTHER; - if ( id == wxART_HARDDISK ) - volKind = wxFS_VOL_DISK; - else if ( id == wxART_FLOPPY ) - volKind = wxFS_VOL_FLOPPY; - else if ( id == wxART_CDROM ) - volKind = wxFS_VOL_CDROM; - - if ( volKind != wxFS_VOL_OTHER ) - { - bitmap = GetDriveBitmapForVolumeType(volKind, size); - if ( bitmap.IsOk() ) - return bitmap; - } -#endif // wxUSE_FSVOLUME - - // notice that the directory used here doesn't need to exist - if ( id == wxART_FOLDER ) - bitmap = MSWGetBitmapForPath("C:\\wxdummydir\\", size ); - else if ( id == wxART_FOLDER_OPEN ) - bitmap = MSWGetBitmapForPath("C:\\wxdummydir\\", size, SHGFI_OPENICON ); - - if ( !bitmap.IsOk() ) - { - // handle message box icons specially (wxIcon ctor treat these names - // as special cases via wxICOResourceHandler::LoadIcon): - const char *name = NULL; - if ( id == wxART_ERROR ) - name = "wxICON_ERROR"; - else if ( id == wxART_INFORMATION ) - name = "wxICON_INFORMATION"; - else if ( id == wxART_WARNING ) - name = "wxICON_WARNING"; - else if ( id == wxART_QUESTION ) - name = "wxICON_QUESTION"; - - if ( name ) - return CreateFromStdIcon(name, client); - } - - // for anything else, fall back to generic provider: - return bitmap; -} - -// ---------------------------------------------------------------------------- -// wxArtProvider::InitNativeProvider() -// ---------------------------------------------------------------------------- - -/*static*/ void wxArtProvider::InitNativeProvider() -{ - PushBack(new wxWindowsArtProvider); -} - -// ---------------------------------------------------------------------------- -// wxArtProvider::GetNativeSizeHint() -// ---------------------------------------------------------------------------- - -/*static*/ -wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client) -{ - if ( client == wxART_TOOLBAR ) - { - return wxSize(24, 24); - } - else if ( client == wxART_MENU ) - { - return wxSize(16, 16); - } - else if ( client == wxART_FRAME_ICON ) - { - return wxSize(::GetSystemMetrics(SM_CXSMICON), - ::GetSystemMetrics(SM_CYSMICON)); - } - else if ( client == wxART_CMN_DIALOG || - client == wxART_MESSAGE_BOX ) - { - return wxSize(::GetSystemMetrics(SM_CXICON), - ::GetSystemMetrics(SM_CYICON)); - } - else if (client == wxART_BUTTON) - { - return wxSize(16, 16); - } - else if (client == wxART_LIST) - { - return wxSize(16, 16); - } - - return wxDefaultSize; -} diff --git a/Source/3rd Party/wx/src/msw/basemsw.cpp b/Source/3rd Party/wx/src/msw/basemsw.cpp index a2832ca6f..5c820d4de 100644 --- a/Source/3rd Party/wx/src/msw/basemsw.cpp +++ b/Source/3rd Party/wx/src/msw/basemsw.cpp @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/msw/basemsw.cpp +// Name: msw/basemsw.cpp // Purpose: misc stuff only used in console applications under MSW // Author: Vadim Zeitlin // Modified by: // Created: 22.06.2003 +// RCS-ID: $Id: basemsw.cpp 39831 2006-06-25 23:53:53Z VZ $ // Copyright: (c) 2003 Vadim Zeitlin -// Licence: wxWindows licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -24,35 +25,35 @@ #endif #ifndef WX_PRECOMP - #include "wx/event.h" #endif //WX_PRECOMP #include "wx/apptrait.h" -#include "wx/evtloop.h" -#include "wx/msw/private/timer.h" // MBN: this is a workaround for MSVC 5: if it is not #included in // some wxBase file, wxRecursionGuard methods won't be exported from // wxBase.dll, and MSVC 5 will give linker errors #include "wx/recguard.h" -#include "wx/crt.h" #include "wx/msw/private.h" -// ============================================================================ -// wxAppTraits implementation -// ============================================================================ - -#if wxUSE_THREADS -WXDWORD wxAppTraits::DoSimpleWaitForThread(WXHANDLE hThread) -{ - return ::WaitForSingleObject((HANDLE)hThread, INFINITE); -} -#endif // wxUSE_THREADS - // ============================================================================ // wxConsoleAppTraits implementation // ============================================================================ +void wxConsoleAppTraits::AlwaysYield() +{ + // we need to use special logic to deal with WM_PAINT: as this pseudo + // message is generated automatically as long as there are invalidated + // windows belonging to this thread, we'd never return if we waited here + // until we have no more of them left. OTOH, this message is always the + // last one in the queue, so we can safely return as soon as we detect it + MSG msg; + while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) + { + if ( msg.message == WM_PAINT ) + break; + } +} + void *wxConsoleAppTraits::BeforeChildWaitLoop() { // nothing to do here @@ -64,39 +65,9 @@ void wxConsoleAppTraits::AfterChildWaitLoop(void * WXUNUSED(data)) // nothing to do here } -#if wxUSE_THREADS bool wxConsoleAppTraits::DoMessageFromThreadWait() { // nothing to process here return true; } -WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread, int WXUNUSED(flags)) -{ - return DoSimpleWaitForThread(hThread); -} -#endif // wxUSE_THREADS - -#if wxUSE_TIMER - -wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer) -{ - return new wxMSWTimerImpl(timer); -} - -#endif // wxUSE_TIMER - -wxEventLoopBase *wxConsoleAppTraits::CreateEventLoop() -{ -#if wxUSE_CONSOLE_EVENTLOOP - return new wxEventLoop(); -#else // !wxUSE_CONSOLE_EVENTLOOP - return NULL; -#endif // wxUSE_CONSOLE_EVENTLOOP/!wxUSE_CONSOLE_EVENTLOOP -} - - -bool wxConsoleAppTraits::WriteToStderr(const wxString& text) -{ - return wxFprintf(stderr, "%s", text) != -1; -} diff --git a/Source/3rd Party/wx/src/msw/bitmap.cpp b/Source/3rd Party/wx/src/msw/bitmap.cpp index f3aa265cd..fec02d9fd 100644 --- a/Source/3rd Party/wx/src/msw/bitmap.cpp +++ b/Source/3rd Party/wx/src/msw/bitmap.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: bitmap.cpp 56488 2008-10-22 17:01:02Z RR $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -38,15 +39,13 @@ #include "wx/image.h" #endif -#include "wx/scopedptr.h" #include "wx/msw/private.h" -#include "wx/msw/dc.h" #if wxUSE_WXDIB #include "wx/msw/dib.h" #endif -#ifdef wxHAS_RAW_BITMAP +#ifdef wxHAVE_RAW_BITMAP #include "wx/rawbmp.h" #endif @@ -56,27 +55,18 @@ #endif // no CLR_INVALID // ---------------------------------------------------------------------------- -// wxBitmapRefData +// Bitmap data // ---------------------------------------------------------------------------- class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData { public: - wxBitmapRefData() { Init(); } + wxBitmapRefData(); wxBitmapRefData(const wxBitmapRefData& data); virtual ~wxBitmapRefData() { Free(); } virtual void Free(); - // Creates a new bitmap (DDB or DIB) from the contents of the given DIB. - void CopyFromDIB(const wxDIB& dib); - -#if wxUSE_WXDIB - // Takes ownership of the given DIB. - bool AssignDIB(wxDIB& dib); -#endif // wxUSE_WXDIB - - // set the mask object to use as the mask, we take ownership of it void SetMask(wxMask *mask) { @@ -101,12 +91,12 @@ public: // MSW-specific // ------------ -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ // this field is solely for error checking: we detect selecting a bitmap // into more than one DC at once or deleting a bitmap still selected into a // DC (both are serious programming errors under Windows) wxDC *m_selectedInto; -#endif // wxDEBUG_LEVEL +#endif // __WXDEBUG__ #if wxUSE_WXDIB // when GetRawData() is called for a DDB we need to convert it to a DIB @@ -123,16 +113,6 @@ public: bool m_isDIB; private: - void Init(); - - // Initialize using the given DIB but use (and take ownership of) the - // bitmap handle if it is valid, assuming it's a DDB. If it's not valid, - // use the DIB handle itself taking ownership of it (i.e. wxDIB will become - // invalid when this function returns even though we take it as const - // reference because this is how it's passed to us). - void InitFromDIB(const wxDIB& dib, HBITMAP hbitmap = NULL); - - // optional mask for transparent drawing wxMask *m_bitmapMask; @@ -202,9 +182,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) // wxBitmapRefData // ---------------------------------------------------------------------------- -void wxBitmapRefData::Init() +wxBitmapRefData::wxBitmapRefData() { -#if wxDEBUG_LEVEL +#ifdef __WXDEBUG__ m_selectedInto = NULL; #endif m_bitmapMask = NULL; @@ -221,25 +201,23 @@ void wxBitmapRefData::Init() wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data) : wxGDIImageRefData(data) { - Init(); +#ifdef __WXDEBUG__ + m_selectedInto = NULL; +#endif // (deep) copy the mask if present + m_bitmapMask = NULL; if (data.m_bitmapMask) m_bitmapMask = new wxMask(*data.m_bitmapMask); - wxASSERT_MSG( !data.m_dib, - wxT("can't copy bitmap locked for raw access!") ); + // FIXME: we don't copy m_hBitmap currently but we should, see wxBitmap:: + // CloneRefData() + + wxASSERT_MSG( !data.m_isDIB, + _T("can't copy bitmap locked for raw access!") ); + m_isDIB = false; m_hasAlpha = data.m_hasAlpha; - -#if wxUSE_WXDIB - // copy the other bitmap - if ( data.m_hBitmap ) - { - wxDIB dib((HBITMAP)(data.m_hBitmap)); - CopyFromDIB(dib); - } -#endif // wxUSE_WXDIB } void wxBitmapRefData::Free() @@ -248,7 +226,7 @@ void wxBitmapRefData::Free() wxT("deleting bitmap still selected into wxMemoryDC") ); #if wxUSE_WXDIB - wxASSERT_MSG( !m_dib, wxT("forgot to call wxBitmap::UngetRawData()!") ); + wxASSERT_MSG( !m_dib, _T("forgot to call wxBitmap::UngetRawData()!") ); #endif if ( m_hBitmap) @@ -259,72 +237,10 @@ void wxBitmapRefData::Free() } } - wxDELETE(m_bitmapMask); + delete m_bitmapMask; + m_bitmapMask = NULL; } -void wxBitmapRefData::InitFromDIB(const wxDIB& dib, HBITMAP hbitmap) -{ - m_width = dib.GetWidth(); - m_height = dib.GetHeight(); - m_depth = dib.GetDepth(); - -#if wxUSE_PALETTE - wxPalette *palette = dib.CreatePalette(); - if ( palette ) - m_bitmapPalette = *palette; - delete palette; -#endif // wxUSE_PALETTE - - if ( hbitmap ) - { - // We assume it's a DDB, otherwise there would be no point in passing - // it to us in addition to the DIB. - m_isDIB = false; - } - else // No valid DDB provided - { - // Just use DIB itself. - m_isDIB = true; - - // Notice that we must not try to use the DIB after calling Detach() on - // it, e.g. this must be done after calling CreatePalette() above. - hbitmap = const_cast(dib).Detach(); - } - - // In any case, take ownership of this bitmap. - m_hBitmap = (WXHBITMAP)hbitmap; -} - -void wxBitmapRefData::CopyFromDIB(const wxDIB& dib) -{ - wxCHECK_RET( !IsOk(), "bitmap already initialized" ); - wxCHECK_RET( dib.IsOk(), wxT("invalid DIB in CopyFromDIB") ); - - HBITMAP hbitmap; -#ifdef SOMETIMES_USE_DIB - hbitmap = dib.CreateDDB(); -#else // ALWAYS_USE_DIB - hbitmap = NULL; -#endif // SOMETIMES_USE_DIB/ALWAYS_USE_DIB - - InitFromDIB(dib, hbitmap); -} - -#if wxUSE_WXDIB - -bool wxBitmapRefData::AssignDIB(wxDIB& dib) -{ - if ( !dib.IsOk() ) - return false; - - Free(); - InitFromDIB(dib); - - return true; -} - -#endif // wxUSE_WXDIB - // ---------------------------------------------------------------------------- // wxBitmap creation // ---------------------------------------------------------------------------- @@ -334,67 +250,51 @@ wxGDIImageRefData *wxBitmap::CreateData() const return new wxBitmapRefData; } -wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *data) const +wxObjectRefData *wxBitmap::CloneRefData(const wxObjectRefData *dataOrig) const { - return new wxBitmapRefData(*static_cast(data)); -} + const wxBitmapRefData * + data = wx_static_cast(const wxBitmapRefData *, dataOrig); + if ( !data ) + return NULL; -// Premultiply the values of all RGBA pixels in the given range. -static void PremultiplyPixels(unsigned char* begin, unsigned char* end) -{ - for ( unsigned char* pixels = begin; pixels < end; pixels += 4 ) + // FIXME: this method is backwards, it should just create a new + // wxBitmapRefData using its copy ctor but instead it modifies this + // bitmap itself and then returns its m_refData -- which works, of + // course (except in !wxUSE_WXDIB), but is completely illogical + wxBitmap *self = wx_const_cast(wxBitmap *, this); + + wxBitmapRefData *selfdata; +#if wxUSE_WXDIB + // copy the other bitmap + if ( data->m_hBitmap ) { - const unsigned char a = pixels[3]; + wxDIB dib((HBITMAP)(data->m_hBitmap)); + self->CopyFromDIB(dib); - pixels[0] = ((pixels[0]*a) + 127)/255; - pixels[1] = ((pixels[1]*a) + 127)/255; - pixels[2] = ((pixels[2]*a) + 127)/255; + selfdata = wx_static_cast(wxBitmapRefData *, m_refData); + selfdata->m_hasAlpha = data->m_hasAlpha; } -} - -// Helper which examines the alpha channel for any non-0 values and also -// possibly returns the DIB with premultiplied values if it does have alpha -// (i.e. this DIB is only filled if the function returns true). -// -// The function semantics is complicated but necessary to avoid converting to -// DIB twice, which is expensive for large bitmaps, yet avoid code duplication -// between CopyFromIconOrCursor() and MSWUpdateAlpha(). -static bool CheckAlpha(HBITMAP hbmp, HBITMAP* hdib = NULL) -{ - BITMAP bm; - if ( !::GetObject(hbmp, sizeof(bm), &bm) || (bm.bmBitsPixel != 32) ) - return false; - - wxDIB dib(hbmp); - if ( !dib.IsOk() ) - return false; - - unsigned char* pixels = dib.GetData(); - unsigned char* const end = pixels + 4*dib.GetWidth()*dib.GetHeight(); - for ( ; pixels < end; pixels += 4 ) + else +#endif // wxUSE_WXDIB { - if ( pixels[3] != 0 ) - { - if ( hdib ) - { - // If we do have alpha, ensure we use premultiplied data for - // our pixels as this is what the bitmaps created in other ways - // do and this is necessary for e.g. AlphaBlend() to work with - // this bitmap. - PremultiplyPixels(dib.GetData(), end); - - *hdib = dib.Detach(); - } - - return true; - } + // copy the bitmap data + selfdata = new wxBitmapRefData(*data); + self->m_refData = selfdata; } - return false; + // copy also the mask + wxMask * const maskSrc = data->GetMask(); + if ( maskSrc ) + { + selfdata->SetMask(new wxMask(*maskSrc)); + } + + return selfdata; } -bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, - wxBitmapTransparency transp) +#ifdef __WIN32__ + +bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon) { #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) // it may be either HICON or HCURSOR @@ -414,56 +314,37 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, int w = icon.GetWidth(), h = icon.GetHeight(); - if ( iconInfo.hbmColor ) - { - refData->m_width = w; - refData->m_height = h; - refData->m_depth = wxDisplayDepth(); - refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor; - } - else // we only have monochrome icon/cursor - { - // Then we need to create our own empty bitmap, which will be modified - // by the mask below. - wxDIB dib(w, h, wxDisplayDepth()); - if ( dib.IsOk() ) - { - memset(dib.GetData(), 0, wxDIB::GetLineSize(w, dib.GetDepth())*h); - refData->AssignDIB(dib); - } - } + refData->m_width = w; + refData->m_height = h; + refData->m_depth = wxDisplayDepth(); - switch ( transp ) - { - default: - wxFAIL_MSG( wxT("unknown wxBitmapTransparency value") ); + refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor; - case wxBitmapTransparency_None: - // nothing to do, refData->m_hasAlpha is false by default - break; - - case wxBitmapTransparency_Auto: #if wxUSE_WXDIB - // If the icon is 32 bits per pixel then it may have alpha channel - // data, although there are some icons that are 32 bpp but have no - // alpha, so check for this. + // If the icon is 32 bits per pixel then it may have alpha channel data, + // although there are some icons that are 32 bpp but have no alpha... So + // convert to a DIB and manually check the 4th byte for each pixel. + BITMAP bm; + if ( ::GetObject(iconInfo.hbmColor, sizeof(BITMAP), (LPVOID)&bm) + && bm.bmBitsPixel == 32) + { + wxDIB dib(iconInfo.hbmColor); + if (dib.IsOk()) + { + unsigned char* pixels = dib.GetData(); + for (int idx=0; idxm_hasAlpha = true; - ::DeleteObject(refData->m_hBitmap); - refData->m_hBitmap = hdib; + break; } } - break; -#endif // wxUSE_WXDIB - - case wxBitmapTransparency_Always: - refData->m_hasAlpha = true; - break; + } } - +#endif if ( !refData->m_hasAlpha ) { // the mask returned by GetIconInfo() is inverted compared to the usual @@ -475,69 +356,73 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, ::DeleteObject(iconInfo.hbmMask); return true; -#else // __WXMICROWIN__ || __WXWINCE__ +#else wxUnusedVar(icon); - wxUnusedVar(transp); - return false; -#endif // !__WXWINCE__/__WXWINCE__ +#endif } -bool wxBitmap::CopyFromCursor(const wxCursor& cursor, wxBitmapTransparency transp) +#endif // Win32 + +bool wxBitmap::CopyFromCursor(const wxCursor& cursor) { UnRef(); - if ( !cursor.IsOk() ) + if ( !cursor.Ok() ) return false; - return CopyFromIconOrCursor(cursor, transp); + return CopyFromIconOrCursor(cursor); } -bool wxBitmap::CopyFromIcon(const wxIcon& icon, wxBitmapTransparency transp) +bool wxBitmap::CopyFromIcon(const wxIcon& icon) { UnRef(); - if ( !icon.IsOk() ) + if ( !icon.Ok() ) return false; - return CopyFromIconOrCursor(icon, transp); + return CopyFromIconOrCursor(icon); } -#if wxUSE_WXDIB +#ifndef NEVER_USE_DIB bool wxBitmap::CopyFromDIB(const wxDIB& dib) { - wxScopedPtr newData(new wxBitmapRefData); - newData->CopyFromDIB(dib); - if ( !newData->IsOk() ) + wxCHECK_MSG( dib.IsOk(), false, _T("invalid DIB in CopyFromDIB") ); + +#ifdef SOMETIMES_USE_DIB + HBITMAP hbitmap = dib.CreateDDB(); + if ( !hbitmap ) return false; +#else // ALWAYS_USE_DIB + HBITMAP hbitmap = ((wxDIB &)dib).Detach(); // const_cast +#endif // SOMETIMES_USE_DIB/ALWAYS_USE_DIB UnRef(); - m_refData = newData.release(); + + wxBitmapRefData *refData = new wxBitmapRefData; + m_refData = refData; + + refData->m_width = dib.GetWidth(); + refData->m_height = dib.GetHeight(); + refData->m_depth = dib.GetDepth(); + + refData->m_hBitmap = (WXHBITMAP)hbitmap; + +#if wxUSE_PALETTE + wxPalette *palette = dib.CreatePalette(); + if ( palette ) + { + refData->m_bitmapPalette = *palette; + } + + delete palette; +#endif // wxUSE_PALETTE + return true; } -bool wxBitmap::IsDIB() const -{ - return GetBitmapData() && GetBitmapData()->m_isDIB; -} - -bool wxBitmap::ConvertToDIB() -{ - if ( IsDIB() ) - return true; - - wxDIB dib(*this); - if ( !dib.IsOk() ) - return false; - - // It is important to reuse the current GetBitmapData() instead of creating - // a new one, as our object identity shouldn't change just because our - // internal representation did, but IsSameAs() compares data pointers. - return GetBitmapData()->AssignDIB(dib); -} - -#endif // wxUSE_WXDIB +#endif // NEVER_USE_DIB wxBitmap::~wxBitmap() { @@ -589,7 +474,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) else { // bits should already be in Windows standard format - data = const_cast(bits); + data = (char *)bits; // const_cast is harmless } HBITMAP hbmp = ::CreateBitmap(width, height, 1, depth, data); @@ -607,19 +492,24 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) #endif } +wxBitmap::wxBitmap(int w, int h, int d) +{ + (void)Create(w, h, d); +} + wxBitmap::wxBitmap(int w, int h, const wxDC& dc) { (void)Create(w, h, dc); } -wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) +wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) { (void)Create(data, type, width, height, depth); } wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) { - LoadFile(filename, type); + LoadFile(filename, (int)type); } bool wxBitmap::Create(int width, int height, int depth) @@ -629,14 +519,9 @@ bool wxBitmap::Create(int width, int height, int depth) bool wxBitmap::Create(int width, int height, const wxDC& dc) { - wxCHECK_MSG( dc.IsOk(), false, wxT("invalid HDC in wxBitmap::Create()") ); + wxCHECK_MSG( dc.Ok(), false, _T("invalid HDC in wxBitmap::Create()") ); - const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); - - if (impl) - return DoCreate(width, height, -1, impl->GetHDC()); - else - return false; + return DoCreate(width, height, -1, dc.GetHDC()); } bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) @@ -701,7 +586,7 @@ bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) SetHBITMAP((WXHBITMAP)hbmp); - return IsOk(); + return Ok(); } #if wxUSE_IMAGE @@ -835,7 +720,7 @@ wxImage wxBitmap::ConvertToImage() const // so the 'depth' argument is ignored. // TODO: transparency (create a mask image) - if (!IsOk()) + if (!Ok()) { wxFAIL_MSG( wxT("bitmap is invalid") ); return wxNullImage; @@ -843,7 +728,7 @@ wxImage wxBitmap::ConvertToImage() const wxImage image; - wxCHECK_MSG( IsOk(), wxNullImage, wxT("invalid bitmap") ); + wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); // create an wxImage object int width = GetWidth(); @@ -904,22 +789,17 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) { - wxCHECK_MSG( dc.IsOk(), false, - wxT("invalid HDC in wxBitmap::CreateFromImage()") ); + wxCHECK_MSG( dc.Ok(), false, + _T("invalid HDC in wxBitmap::CreateFromImage()") ); - const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); - - if (impl) - return CreateFromImage(image, -1, impl->GetHDC()); - else - return false; + return CreateFromImage(image, -1, dc.GetHDC()); } #if wxUSE_WXDIB bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) { - wxCHECK_MSG( image.IsOk(), false, wxT("invalid image") ); + wxCHECK_MSG( image.Ok(), false, wxT("invalid image") ); UnRef(); @@ -935,7 +815,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) if (depth == -1) depth = dib.GetDepth(); - + // store the bitmap parameters wxBitmapRefData * const refData = new wxBitmapRefData; refData->m_width = w; @@ -1000,7 +880,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) hbitmap = ::CreateBitmap(w, h, 1, 1, data); if ( !hbitmap ) { - wxLogLastError(wxT("CreateBitmap(mask)")); + wxLogLastError(_T("CreateBitmap(mask)")); } else { @@ -1025,7 +905,7 @@ wxImage wxBitmap::ConvertToImage() const // and then DIB to our wxImage wxImage image = dib.ConvertToImage(); - if ( !image.IsOk() ) + if ( !image.Ok() ) { return wxNullImage; } @@ -1119,7 +999,7 @@ wxImage wxBitmap::ConvertToImage() const // loading and saving bitmaps // ---------------------------------------------------------------------------- -bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) +bool wxBitmap::LoadFile(const wxString& filename, long type) { UnRef(); @@ -1135,7 +1015,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) else // no bitmap handler found { wxImage image; - if ( image.LoadFile( filename, type ) && image.IsOk() ) + if ( image.LoadFile( filename, type ) && image.Ok() ) { *this = wxBitmap(image); @@ -1147,7 +1027,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return false; } -bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) +bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) { UnRef(); @@ -1166,8 +1046,8 @@ bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height } bool wxBitmap::SaveFile(const wxString& filename, - wxBitmapType type, - const wxPalette *palette) const + int type, + const wxPalette *palette) { wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler); @@ -1180,7 +1060,7 @@ bool wxBitmap::SaveFile(const wxString& filename, { // FIXME what about palette? shouldn't we use it? wxImage image = ConvertToImage(); - if ( image.IsOk() ) + if ( image.Ok() ) { return image.SaveFile(filename, type); } @@ -1202,14 +1082,14 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect ) const wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const { - wxCHECK_MSG( IsOk() && + 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.IsOk(), wxT("GetSubBitmap error") ); + wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); #ifndef __WXMICROWIN__ // handle alpha channel, if any @@ -1222,16 +1102,16 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const { SelectInHDC selectDst(dcDst, GetHbitmapOf(ret)); - + if ( !selectDst ) { - wxLogLastError(wxT("SelectObject(destBitmap)")); + wxLogLastError(_T("SelectObject(destBitmap)")); } if ( !::BitBlt(dcDst, 0, 0, rect.width, rect.height, (HDC)hdc, rect.x, rect.y, SRCCOPY) ) { - wxLogLastError(wxT("BitBlt")); + wxLogLastError(_T("BitBlt")); } } @@ -1246,7 +1126,7 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const if ( !::BitBlt(dcDst, 0, 0, rect.width, rect.height, dcSrc, rect.x, rect.y, SRCCOPY) ) { - wxLogLastError(wxT("BitBlt")); + wxLogLastError(_T("BitBlt")); } wxMask *mask = new wxMask((WXHBITMAP) hbmpMask); @@ -1265,61 +1145,67 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const wxPalette* wxBitmap::GetPalette() const { return GetBitmapData() ? &GetBitmapData()->m_bitmapPalette - : NULL; + : (wxPalette *) NULL; } #endif wxMask *wxBitmap::GetMask() const { - return GetBitmapData() ? GetBitmapData()->GetMask() : NULL; + return GetBitmapData() ? GetBitmapData()->GetMask() : (wxMask *) NULL; } +wxBitmap wxBitmap::GetMaskBitmap() const +{ + wxBitmap bmp; + wxMask *mask = GetMask(); + if ( mask ) + bmp.SetHBITMAP(mask->GetMaskBitmap()); + return bmp; +} + +#ifdef __WXDEBUG__ + wxDC *wxBitmap::GetSelectedInto() const { -#if wxDEBUG_LEVEL - return GetBitmapData() ? GetBitmapData()->m_selectedInto : NULL; -#else - return NULL; -#endif + return GetBitmapData() ? GetBitmapData()->m_selectedInto : (wxDC *) NULL; } +#endif + +#if WXWIN_COMPATIBILITY_2_4 + +int wxBitmap::GetQuality() const +{ + return 0; +} + +#endif // WXWIN_COMPATIBILITY_2_4 + void wxBitmap::UseAlpha() { if ( GetBitmapData() ) GetBitmapData()->m_hasAlpha = true; } -void wxBitmap::ResetAlpha() -{ - if ( GetBitmapData() ) - GetBitmapData()->m_hasAlpha = false; -} - bool wxBitmap::HasAlpha() const { return GetBitmapData() && GetBitmapData()->m_hasAlpha; } -void wxBitmap::MSWUpdateAlpha() -{ - if ( CheckAlpha(GetHbitmap()) ) - GetBitmapData()->m_hasAlpha = true; -} - // ---------------------------------------------------------------------------- // wxBitmap setters // ---------------------------------------------------------------------------- +#ifdef __WXDEBUG__ + void wxBitmap::SetSelectedInto(wxDC *dc) { -#if wxDEBUG_LEVEL if ( GetBitmapData() ) GetBitmapData()->m_selectedInto = dc; -#else - wxUnusedVar(dc); -#endif } +#endif + #if wxUSE_PALETTE void wxBitmap::SetPalette(const wxPalette& palette) @@ -1338,16 +1224,23 @@ void wxBitmap::SetMask(wxMask *mask) GetBitmapData()->SetMask(mask); } +#if WXWIN_COMPATIBILITY_2_4 + +void wxBitmap::SetQuality(int WXUNUSED(quality)) +{ +} + +#endif // WXWIN_COMPATIBILITY_2_4 + // ---------------------------------------------------------------------------- // raw bitmap access support // ---------------------------------------------------------------------------- -#ifdef wxHAS_RAW_BITMAP - +#ifdef wxHAVE_RAW_BITMAP void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) { #if wxUSE_WXDIB - if ( !IsOk() ) + if ( !Ok() ) { // no bitmap, no data (raw or otherwise) return NULL; @@ -1360,7 +1253,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) if ( !GetBitmapData()->m_isDIB ) { wxCHECK_MSG( !GetBitmapData()->m_dib, NULL, - wxT("GetRawData() may be called only once") ); + _T("GetRawData() may be called only once") ); wxDIB *dib = new wxDIB(*this); if ( !dib->IsOk() ) @@ -1383,7 +1276,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) DIBSECTION ds; if ( ::GetObject(hDIB, sizeof(ds), &ds) != sizeof(DIBSECTION) ) { - wxFAIL_MSG( wxT("failed to get DIBSECTION from a DIB?") ); + wxFAIL_MSG( _T("failed to get DIBSECTION from a DIB?") ); return NULL; } @@ -1391,7 +1284,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) // check that the bitmap is in correct format if ( ds.dsBm.bmBitsPixel != bpp ) { - wxFAIL_MSG( wxT("incorrect bitmap type in wxBitmap::GetRawData()") ); + wxFAIL_MSG( _T("incorrect bitmap type in wxBitmap::GetRawData()") ); return NULL; } @@ -1425,7 +1318,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) void wxBitmap::UngetRawData(wxPixelDataBase& dataBase) { #if wxUSE_WXDIB - if ( !IsOk() ) + if ( !Ok() ) return; if ( !&dataBase ) @@ -1449,7 +1342,7 @@ void wxBitmap::UngetRawData(wxPixelDataBase& dataBase) } #endif // wxUSE_WXDIB } -#endif // wxHAS_RAW_BITMAP +#endif // #ifdef wxHAVE_RAW_BITMAP // ---------------------------------------------------------------------------- // wxMask @@ -1486,7 +1379,7 @@ wxMask::wxMask(const wxMask &mask) SelectObject(destDC, (HBITMAP) m_maskBitmap); BitBlt(destDC, 0, 0, w, h, srcDC, 0, 0, SRCCOPY); - + SelectObject(srcDC, 0); DeleteDC(srcDC); SelectObject(destDC, 0); @@ -1526,8 +1419,8 @@ wxMask::~wxMask() bool wxMask::Create(const wxBitmap& bitmap) { #ifndef __WXMICROWIN__ - wxCHECK_MSG( bitmap.IsOk() && bitmap.GetDepth() == 1, false, - wxT("can't create mask from invalid or not monochrome bitmap") ); + wxCHECK_MSG( bitmap.Ok() && bitmap.GetDepth() == 1, false, + _T("can't create mask from invalid or not monochrome bitmap") ); if ( m_maskBitmap ) { @@ -1567,7 +1460,7 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) } #if wxUSE_PALETTE - if (bitmap.IsOk() && bitmap.GetPalette()->IsOk()) + if (bitmap.Ok() && bitmap.GetPalette()->Ok()) { unsigned char red, green, blue; if (bitmap.GetPalette()->GetRGB(paletteIndex, &red, &green, &blue)) @@ -1586,7 +1479,7 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) { #ifndef __WXMICROWIN__ - wxCHECK_MSG( bitmap.IsOk(), false, wxT("invalid bitmap in wxMask::Create") ); + wxCHECK_MSG( bitmap.Ok(), false, _T("invalid bitmap in wxMask::Create") ); if ( m_maskBitmap ) { @@ -1613,7 +1506,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) // SelectObject() will fail wxASSERT_MSG( !bitmap.GetSelectedInto(), - wxT("bitmap can't be selected in another DC") ); + _T("bitmap can't be selected in another DC") ); HGDIOBJ hbmpSrcOld = ::SelectObject(srcDC, GetHbitmapOf(bitmap)); if ( !hbmpSrcOld ) @@ -1653,40 +1546,33 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) #endif // __WXMICROWIN__/!__WXMICROWIN__ } -wxBitmap wxMask::GetBitmap() const -{ - wxBitmap bmp; - bmp.SetHBITMAP(m_maskBitmap); - return bmp; -} - // ---------------------------------------------------------------------------- // wxBitmapHandler // ---------------------------------------------------------------------------- bool wxBitmapHandler::Create(wxGDIImage *image, const void* data, - wxBitmapType type, + long flags, int width, int height, int depth) { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); - return bitmap && Create(bitmap, data, type, width, height, depth); + return bitmap && Create(bitmap, data, flags, width, height, depth); } bool wxBitmapHandler::Load(wxGDIImage *image, const wxString& name, - wxBitmapType type, + long flags, int width, int height) { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); - return bitmap && LoadFile(bitmap, name, type, width, height); + return bitmap && LoadFile(bitmap, name, flags, width, height); } -bool wxBitmapHandler::Save(const wxGDIImage *image, +bool wxBitmapHandler::Save(wxGDIImage *image, const wxString& name, - wxBitmapType type) const + int type) { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); @@ -1695,7 +1581,7 @@ bool wxBitmapHandler::Save(const wxGDIImage *image, bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), const void* WXUNUSED(data), - wxBitmapType WXUNUSED(type), + long WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth)) @@ -1705,21 +1591,72 @@ bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), - wxBitmapType WXUNUSED(type), + long WXUNUSED(type), int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) { return false; } -bool wxBitmapHandler::SaveFile(const wxBitmap *WXUNUSED(bitmap), +bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), - wxBitmapType WXUNUSED(type), - const wxPalette *WXUNUSED(palette)) const + int WXUNUSED(type), + const wxPalette *WXUNUSED(palette)) { return false; } +// ---------------------------------------------------------------------------- +// DIB functions +// ---------------------------------------------------------------------------- + +#ifndef __WXMICROWIN__ +bool wxCreateDIB(long xSize, long ySize, long bitsPerPixel, + HPALETTE hPal, LPBITMAPINFO* lpDIBHeader) +{ + unsigned long i, headerSize; + + // Allocate space for a DIB header + headerSize = (sizeof(BITMAPINFOHEADER) + (256 * sizeof(PALETTEENTRY))); + LPBITMAPINFO lpDIBheader = (BITMAPINFO *) malloc(headerSize); + LPPALETTEENTRY lpPe = (PALETTEENTRY *)((BYTE*)lpDIBheader + sizeof(BITMAPINFOHEADER)); + + GetPaletteEntries(hPal, 0, 256, lpPe); + + memset(lpDIBheader, 0x00, sizeof(BITMAPINFOHEADER)); + + // Fill in the static parts of the DIB header + lpDIBheader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + lpDIBheader->bmiHeader.biWidth = xSize; + lpDIBheader->bmiHeader.biHeight = ySize; + lpDIBheader->bmiHeader.biPlanes = 1; + + // this value must be 1, 4, 8 or 24 so PixelDepth can only be + lpDIBheader->bmiHeader.biBitCount = (WORD)(bitsPerPixel); + lpDIBheader->bmiHeader.biCompression = BI_RGB; + lpDIBheader->bmiHeader.biSizeImage = (xSize * abs((int)ySize) * bitsPerPixel) >> 3; + lpDIBheader->bmiHeader.biClrUsed = 256; + + + // Initialize the DIB palette + for (i = 0; i < 256; i++) { + lpDIBheader->bmiColors[i].rgbReserved = lpPe[i].peFlags; + lpDIBheader->bmiColors[i].rgbRed = lpPe[i].peRed; + lpDIBheader->bmiColors[i].rgbGreen = lpPe[i].peGreen; + lpDIBheader->bmiColors[i].rgbBlue = lpPe[i].peBlue; + } + + *lpDIBHeader = lpDIBheader; + + return true; +} + +void wxFreeDIB(LPBITMAPINFO lpDIBHeader) +{ + free(lpDIBHeader); +} +#endif + // ---------------------------------------------------------------------------- // global helper functions implemented here // ---------------------------------------------------------------------------- @@ -1731,7 +1668,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, int hotSpotX, int hotSpotY) { - if ( !bmp.IsOk() ) + if ( !bmp.Ok() ) { // we can't create an icon/cursor form nothing return 0; @@ -1739,25 +1676,9 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, if ( bmp.HasAlpha() ) { - HBITMAP hbmp; - -#if wxUSE_WXDIB && wxUSE_IMAGE - // CreateIconIndirect() requires non-pre-multiplied pixel data on input - // as it does pre-multiplication internally itself so we need to create - // a special DIB in such format to pass to it. This is inefficient but - // better than creating an icon with wrong colours. - AutoHBITMAP hbmpRelease; - hbmp = wxDIB(bmp.ConvertToImage(), - wxDIB::PixelFormat_NotPreMultiplied).Detach(); - hbmpRelease.Init(hbmp); -#else // !(wxUSE_WXDIB && wxUSE_IMAGE) - hbmp = GetHbitmapOf(bmp); -#endif // wxUSE_WXDIB && wxUSE_IMAGE - // Create an empty mask bitmap. // it doesn't seem to work if we mess with the mask at all. - AutoHBITMAP - hMonoBitmap(CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL)); + HBITMAP hMonoBitmap = CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL); ICONINFO iconInfo; wxZeroMemory(iconInfo); @@ -1769,9 +1690,13 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, } iconInfo.hbmMask = hMonoBitmap; - iconInfo.hbmColor = hbmp; + iconInfo.hbmColor = GetHbitmapOf(bmp); - return ::CreateIconIndirect(&iconInfo); + HICON hicon = ::CreateIconIndirect(&iconInfo); + + ::DeleteObject(hMonoBitmap); + + return hicon; } wxMask* mask = bmp.GetMask(); @@ -1792,8 +1717,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, iconInfo.yHotspot = hotSpotY; } - AutoHBITMAP hbmpMask(wxInvertMask((HBITMAP)mask->GetMaskBitmap())); - iconInfo.hbmMask = hbmpMask; + iconInfo.hbmMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap()); iconInfo.hbmColor = GetHbitmapOf(bmp); // black out the transparent area to preserve background colour, because @@ -1807,7 +1731,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, if ( !::BitBlt(dcDst, 0, 0, bmp.GetWidth(), bmp.GetHeight(), dcSrc, 0, 0, SRCAND) ) { - wxLogLastError(wxT("BitBlt")); + wxLogLastError(_T("BitBlt")); } } @@ -1819,6 +1743,9 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, delete mask; } + // delete the inverted mask bitmap we created as well + ::DeleteObject(iconInfo.hbmMask); + return hicon; } @@ -1835,7 +1762,7 @@ HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY) HBITMAP wxInvertMask(HBITMAP hbmpMask, int w, int h) { #ifndef __WXMICROWIN__ - wxCHECK_MSG( hbmpMask, 0, wxT("invalid bitmap in wxInvertMask") ); + wxCHECK_MSG( hbmpMask, 0, _T("invalid bitmap in wxInvertMask") ); // get width/height from the bitmap if not given if ( !w || !h ) diff --git a/Source/3rd Party/wx/src/msw/bmpbuttn.cpp b/Source/3rd Party/wx/src/msw/bmpbuttn.cpp index c6ecebce5..679765910 100644 --- a/Source/3rd Party/wx/src/msw/bmpbuttn.cpp +++ b/Source/3rd Party/wx/src/msw/bmpbuttn.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: bmpbuttn.cpp 42816 2006-10-31 08:50:17Z RD $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -26,7 +27,6 @@ #endif #include "wx/msw/private.h" -#include "wx/msw/dc.h" // for wxDCTemp #include "wx/msw/uxtheme.h" @@ -53,8 +53,64 @@ // macros // ---------------------------------------------------------------------------- +#if wxUSE_EXTENDED_RTTI + +WX_DEFINE_FLAGS( wxBitmapButtonStyle ) + +wxBEGIN_FLAGS( wxBitmapButtonStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxBU_AUTODRAW) + wxFLAGS_MEMBER(wxBU_LEFT) + wxFLAGS_MEMBER(wxBU_RIGHT) + wxFLAGS_MEMBER(wxBU_TOP) + wxFLAGS_MEMBER(wxBU_BOTTOM) +wxEND_FLAGS( wxBitmapButtonStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton, wxButton,"wx/bmpbuttn.h") + +wxBEGIN_PROPERTIES_TABLE(wxBitmapButton) + wxPROPERTY_FLAGS( WindowStyle , wxBitmapButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxBitmapButton) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_5( wxBitmapButton , wxWindow* , Parent , wxWindowID , Id , wxBitmap , Bitmap , wxPoint , Position , wxSize , Size ) + +#else +IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton) +#endif + BEGIN_EVENT_TABLE(wxBitmapButton, wxBitmapButtonBase) EVT_SYS_COLOUR_CHANGED(wxBitmapButton::OnSysColourChanged) + EVT_ENTER_WINDOW(wxBitmapButton::OnMouseEnterOrLeave) + EVT_LEAVE_WINDOW(wxBitmapButton::OnMouseEnterOrLeave) END_EVENT_TABLE() /* @@ -67,29 +123,524 @@ bitmap "focus" , bitmap "disabled" , */ -bool wxBitmapButton::Create(wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) +bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, + const wxBitmap& bitmap, + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& wxVALIDATOR_PARAM(validator), + const wxString& name) { - if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style, - validator, name) ) + m_bmpNormal = bitmap; + SetName(name); + +#if wxUSE_VALIDATORS + SetValidator(validator); +#endif // wxUSE_VALIDATORS + + parent->AddChild(this); + + m_windowStyle = style; + + if ( style & wxBU_AUTODRAW ) + { + m_marginX = + m_marginY = 4; + } + + if (id == wxID_ANY) + m_windowId = NewControlId(); + else + m_windowId = id; + + long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD | BS_OWNERDRAW ; + + if ( m_windowStyle & wxCLIP_SIBLINGS ) + msStyle |= WS_CLIPSIBLINGS; + +#ifdef __WIN32__ + if(m_windowStyle & wxBU_LEFT) + msStyle |= BS_LEFT; + if(m_windowStyle & wxBU_RIGHT) + msStyle |= BS_RIGHT; + if(m_windowStyle & wxBU_TOP) + msStyle |= BS_TOP; + if(m_windowStyle & wxBU_BOTTOM) + msStyle |= BS_BOTTOM; +#endif + + m_hWnd = (WXHWND) CreateWindowEx( + 0, + wxT("BUTTON"), + wxEmptyString, + msStyle, + 0, 0, 0, 0, + GetWinHwnd(parent), + (HMENU)m_windowId, + wxGetInstance(), + NULL + ); + + // Subclass again for purposes of dialog editing mode + SubclassWin(m_hWnd); + + SetPosition(pos); + SetInitialSize(size); + + return true; +} + +bool wxBitmapButton::SetBackgroundColour(const wxColour& colour) +{ + if ( !wxBitmapButtonBase::SetBackgroundColour(colour) ) + { + // didn't change + return false; + } + + // invalidate the brush, it will be recreated the next time it's needed + m_brushDisabled = wxNullBrush; + + return true; +} + +void wxBitmapButton::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + m_brushDisabled = wxNullBrush; + + if ( !IsEnabled() ) + { + // this change affects our current state + Refresh(); + } + + event.Skip(); +} + +void wxBitmapButton::OnMouseEnterOrLeave(wxMouseEvent& event) +{ + if ( IsEnabled() && m_bmpHover.Ok() ) + Refresh(); + + event.Skip(); +} + +void wxBitmapButton::OnSetBitmap() +{ + // if the focus bitmap is specified but hover one isn't, use the focus + // bitmap for hovering as well if this is consistent with the current + // Windows version look and feel + // + // rationale: this is compatible with the old wxGTK behaviour and also + // makes it much easier to do "the right thing" for all platforms (some of + // them, such as Windows XP, have "hot" buttons while others don't) + if ( !m_bmpHover.Ok() && + m_bmpFocus.Ok() && + wxUxThemeEngine::GetIfActive() ) + { + m_bmpHover = m_bmpFocus; + } + + // this will redraw us + wxBitmapButtonBase::OnSetBitmap(); +} + +#if wxUSE_UXTHEME +static +void MSWDrawXPBackground(wxButton *button, WXDRAWITEMSTRUCT *wxdis) +{ + LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; + HDC hdc = lpDIS->hDC; + UINT state = lpDIS->itemState; + RECT rectBtn; + CopyRect(&rectBtn, &lpDIS->rcItem); + + wxUxThemeHandle theme(button, L"BUTTON"); + int iState; + + if ( state & ODS_SELECTED ) + { + iState = PBS_PRESSED; + } + else if ( button->HasCapture() || button->IsMouseInWindow() ) + { + iState = PBS_HOT; + } + else if ( state & ODS_FOCUS ) + { + iState = PBS_DEFAULTED; + } + else if ( state & ODS_DISABLED ) + { + iState = PBS_DISABLED; + } + else + { + iState = PBS_NORMAL; + } + + // draw parent background if needed + if ( wxUxThemeEngine::Get()->IsThemeBackgroundPartiallyTransparent(theme, + BP_PUSHBUTTON, + iState) ) + { + wxUxThemeEngine::Get()->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn); + } + + // draw background + wxUxThemeEngine::Get()->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, + &rectBtn, NULL); + + // calculate content area margins + MARGINS margins; + wxUxThemeEngine::Get()->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, + TMT_CONTENTMARGINS, &rectBtn, &margins); + RECT rectClient; + ::CopyRect(&rectClient, &rectBtn); + ::InflateRect(&rectClient, -margins.cxLeftWidth, -margins.cyTopHeight); + + // if focused and !nofocus rect + if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) ) + { + DrawFocusRect(hdc, &rectClient); + } + + if ( button->UseBgCol() ) + { + COLORREF colBg = wxColourToRGB(button->GetBackgroundColour()); + HBRUSH hbrushBackground = ::CreateSolidBrush(colBg); + + // don't overwrite the focus rect + ::InflateRect(&rectClient, -1, -1); + FillRect(hdc, &rectClient, hbrushBackground); + ::DeleteObject(hbrushBackground); + } +} +#endif // wxUSE_UXTHEME + +// VZ: should be at the very least less than wxDEFAULT_BUTTON_MARGIN +#define FOCUS_MARGIN 3 + +bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item) +{ +#ifndef __WXWINCE__ + long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE); + if (style & BS_BITMAP) + { + // Let default procedure draw the bitmap, which is defined + // in the Windows resource. + return false; + } +#endif + + LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item; + HDC hDC = lpDIS->hDC; + UINT state = lpDIS->itemState; + bool isSelected = (state & ODS_SELECTED) != 0; + bool autoDraw = (GetWindowStyleFlag() & wxBU_AUTODRAW) != 0; + + + // choose the bitmap to use depending on the button state + wxBitmap *bitmap; + + if ( isSelected && m_bmpSelected.Ok() ) + bitmap = &m_bmpSelected; + else if ( m_bmpHover.Ok() && IsMouseInWindow() ) + bitmap = &m_bmpHover; + else if ((state & ODS_FOCUS) && m_bmpFocus.Ok()) + bitmap = &m_bmpFocus; + else if ((state & ODS_DISABLED) && m_bmpDisabled.Ok()) + bitmap = &m_bmpDisabled; + else + bitmap = &m_bmpNormal; + + if ( !bitmap->Ok() ) return false; - if ( bitmap.IsOk() ) - SetBitmapLabel(bitmap); + // centre the bitmap in the control area + int x = lpDIS->rcItem.left; + int y = lpDIS->rcItem.top; + int width = lpDIS->rcItem.right - x; + int height = lpDIS->rcItem.bottom - y; + int wBmp = bitmap->GetWidth(); + int hBmp = bitmap->GetHeight(); - if ( !size.IsFullySpecified() ) +#if wxUSE_UXTHEME + if ( autoDraw && wxUxThemeEngine::GetIfActive() ) { - // As our bitmap has just changed, our best size has changed as well so - // reset the initial size using the new value. - SetInitialSize(size); + MSWDrawXPBackground(this, item); + wxUxThemeHandle theme(this, L"BUTTON"); + + // calculate content area margins + // assuming here that each state is the same size + MARGINS margins; + wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL, + BP_PUSHBUTTON, PBS_NORMAL, + TMT_CONTENTMARGINS, NULL, + &margins); + int marginX = margins.cxLeftWidth + 1; + int marginY = margins.cyTopHeight + 1; + int x1,y1; + + if ( m_windowStyle & wxBU_LEFT ) + { + x1 = x + marginX; + } + else if ( m_windowStyle & wxBU_RIGHT ) + { + x1 = x + (width - wBmp) - marginX; + } + else + { + x1 = x + (width - wBmp) / 2; + } + + if ( m_windowStyle & wxBU_TOP ) + { + y1 = y + marginY; + } + else if ( m_windowStyle & wxBU_BOTTOM ) + { + y1 = y + (height - hBmp) - marginY; + } + else + { + y1 = y + (height - hBmp) / 2; + } + + // draw the bitmap + wxDCTemp dst((WXHDC)hDC); + dst.DrawBitmap(*bitmap, x1, y1, true); + + return true; + } +#endif // wxUSE_UXTHEME + + int x1,y1; + + if(m_windowStyle & wxBU_LEFT) + x1 = x + (FOCUS_MARGIN+1); + else if(m_windowStyle & wxBU_RIGHT) + x1 = x + (width - wBmp) - (FOCUS_MARGIN+1); + else + x1 = x + (width - wBmp) / 2; + + if(m_windowStyle & wxBU_TOP) + y1 = y + (FOCUS_MARGIN+1); + else if(m_windowStyle & wxBU_BOTTOM) + y1 = y + (height - hBmp) - (FOCUS_MARGIN+1); + else + y1 = y + (height - hBmp) / 2; + + if ( isSelected && autoDraw ) + { + x1++; + y1++; + } + + // draw the face, if auto-drawing + if ( autoDraw ) + { + DrawFace((WXHDC) hDC, + lpDIS->rcItem.left, lpDIS->rcItem.top, + lpDIS->rcItem.right, lpDIS->rcItem.bottom, + isSelected); + } + + // draw the bitmap + wxDCTemp dst((WXHDC)hDC); + dst.DrawBitmap(*bitmap, x1, y1, true); + + // draw focus / disabled state, if auto-drawing + if ( (state & ODS_DISABLED) && autoDraw ) + { + DrawButtonDisable((WXHDC) hDC, + lpDIS->rcItem.left, lpDIS->rcItem.top, + lpDIS->rcItem.right, lpDIS->rcItem.bottom, + true); + } + else if ( (state & ODS_FOCUS) && autoDraw ) + { + DrawButtonFocus((WXHDC) hDC, + lpDIS->rcItem.left, + lpDIS->rcItem.top, + lpDIS->rcItem.right, + lpDIS->rcItem.bottom, + isSelected); } return true; } +// GRG Feb/2000, support for bmp buttons with Win95/98 standard LNF + +void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, + int right, int bottom, bool sel ) +{ + HPEN oldp; + HPEN penHiLight; + HPEN penLight; + HPEN penShadow; + HPEN penDkShadow; + HBRUSH brushFace; + + // create needed pens and brush + penHiLight = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT)); + penLight = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT)); + penShadow = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW)); + penDkShadow = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW)); + brushFace = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + + // draw the rectangle + RECT rect; + rect.left = left; + rect.right = right; + rect.top = top; + rect.bottom = bottom; + FillRect((HDC) dc, &rect, brushFace); + + // draw the border + oldp = (HPEN) SelectObject( (HDC) dc, sel? penDkShadow : penHiLight); + + wxDrawLine((HDC) dc, left, top, right-1, top); + wxDrawLine((HDC) dc, left, top+1, left, bottom-1); + + SelectObject( (HDC) dc, sel? penShadow : penLight); + wxDrawLine((HDC) dc, left+1, top+1, right-2, top+1); + wxDrawLine((HDC) dc, left+1, top+2, left+1, bottom-2); + + SelectObject( (HDC) dc, sel? penLight : penShadow); + wxDrawLine((HDC) dc, left+1, bottom-2, right-1, bottom-2); + wxDrawLine((HDC) dc, right-2, bottom-3, right-2, top); + + SelectObject( (HDC) dc, sel? penHiLight : penDkShadow); + wxDrawLine((HDC) dc, left, bottom-1, right+2, bottom-1); + wxDrawLine((HDC) dc, right-1, bottom-2, right-1, top-1); + + // delete allocated resources + SelectObject((HDC) dc,oldp); + DeleteObject(penHiLight); + DeleteObject(penLight); + DeleteObject(penShadow); + DeleteObject(penDkShadow); + DeleteObject(brushFace); +} + +void wxBitmapButton::DrawButtonFocus( WXHDC dc, int left, int top, int right, + int bottom, bool WXUNUSED(sel) ) +{ + RECT rect; + rect.left = left; + rect.top = top; + rect.right = right; + rect.bottom = bottom; + InflateRect( &rect, - FOCUS_MARGIN, - FOCUS_MARGIN ); + + // GRG: the focus rectangle should not move when the button is pushed! +/* + if ( sel ) + OffsetRect( &rect, 1, 1 ); +*/ + + DrawFocusRect( (HDC) dc, &rect ); +} + +void +wxBitmapButton::DrawButtonDisable( WXHDC dc, + int left, int top, int right, int bottom, + bool with_marg ) +{ + if ( !m_brushDisabled.Ok() ) + { + // draw a bitmap with two black and two background colour pixels + wxBitmap bmp(2, 2); + wxMemoryDC dc; + dc.SelectObject(bmp); + dc.SetPen(*wxBLACK_PEN); + dc.DrawPoint(0, 0); + dc.DrawPoint(1, 1); + dc.SetPen(GetBackgroundColour()); + dc.DrawPoint(0, 1); + dc.DrawPoint(1, 0); + + m_brushDisabled = wxBrush(bmp); + } + + SelectInHDC selectBrush((HDC)dc, GetHbrushOf(m_brushDisabled)); + + // ROP for "dest |= pattern" operation -- as it doesn't have a standard + // name, give it our own + static const DWORD PATTERNPAINT = 0xFA0089UL; + + if ( with_marg ) + { + left += m_marginX; + top += m_marginY; + right -= 2 * m_marginX; + bottom -= 2 * m_marginY; + } + + ::PatBlt( (HDC) dc, left, top, right, bottom, PATTERNPAINT); +} + +void wxBitmapButton::SetDefault() +{ + wxButton::SetDefault(); +} + +wxSize wxBitmapButton::DoGetBestSize() const +{ + if ( m_bmpNormal.Ok() ) + { + int width = m_bmpNormal.GetWidth(), + height = m_bmpNormal.GetHeight(); + int marginH = 0, + marginV = 0; + +#if wxUSE_UXTHEME + if ( wxUxThemeEngine::GetIfActive() ) + { + wxUxThemeHandle theme((wxBitmapButton *)this, L"BUTTON"); + + MARGINS margins; + wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL, + BP_PUSHBUTTON, PBS_NORMAL, + TMT_CONTENTMARGINS, NULL, + &margins); + + // XP doesn't draw themed buttons correctly when the client area is + // smaller than 8x8 - enforce this minimum size for small bitmaps + if ( width < 8 ) + width = 8; + if ( height < 8 ) + height = 8; + + // don't add margins for the borderless buttons, they don't need + // them and it just makes them appear larger than needed + if ( !HasFlag(wxBORDER_NONE) ) + { + // we need 2 extra pixels for the focus rectangle, without them + // it's overwritten by the bitmap itself + marginH = margins.cxLeftWidth + margins.cxRightWidth + 2; + marginV = margins.cyTopHeight + margins.cyBottomHeight + 2; + } + } + else +#endif // wxUSE_UXTHEME + { + if ( !HasFlag(wxBORDER_NONE) ) + { + marginH = 2*m_marginX; + marginV = 2*m_marginY; + } + } + + wxSize best(width + marginH, height + marginV); + CacheBestSize(best); + return best; + } + + // no idea what our best size should be, defer to the base class + return wxBitmapButtonBase::DoGetBestSize(); +} + #endif // wxUSE_BMPBUTTON diff --git a/Source/3rd Party/wx/src/msw/bmpcbox.cpp b/Source/3rd Party/wx/src/msw/bmpcbox.cpp deleted file mode 100644 index 469ddace6..000000000 --- a/Source/3rd Party/wx/src/msw/bmpcbox.cpp +++ /dev/null @@ -1,462 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/msw/bmpcbox.cpp -// Purpose: wxBitmapComboBox -// Author: Jaakko Salli -// Created: 2008-04-06 -// Copyright: (c) 2008 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_BITMAPCOMBOBOX - -#include "wx/bmpcbox.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" -#endif - -#include "wx/settings.h" -#include "wx/vector.h" - -#include "wx/msw/dcclient.h" -#include "wx/msw/private.h" - -// For wxODCB_XXX flags -#include "wx/odcombo.h" - - -#define IMAGE_SPACING_CTRL_VERTICAL 7 // Spacing used in control size calculation - - -// ============================================================================ -// implementation -// ============================================================================ - - -BEGIN_EVENT_TABLE(wxBitmapComboBox, wxComboBox) - EVT_SIZE(wxBitmapComboBox::OnSize) -END_EVENT_TABLE() - - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBox, wxComboBox) - - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox creation -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::Init() -{ - m_inResize = false; -} - -wxBitmapComboBox::wxBitmapComboBox(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) - : wxComboBox(), - wxBitmapComboBoxBase() -{ - Init(); - - Create(parent,id,value,pos,size,choices,style,validator,name); -} - -bool wxBitmapComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) -{ - wxCArrayString chs(choices); - return Create(parent, id, value, pos, size, chs.GetCount(), - chs.GetStrings(), style, validator, name); -} - -bool wxBitmapComboBox::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style, - const wxValidator& validator, - const wxString& name) -{ - if ( !wxComboBox::Create(parent, id, value, pos, size, - n, choices, style, validator, name) ) - return false; - - UpdateInternals(); - - return true; -} - -WXDWORD wxBitmapComboBox::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - return wxComboBox::MSWGetStyle(style, exstyle) | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS; -} - -void wxBitmapComboBox::RecreateControl() -{ - // - // Recreate control so that WM_MEASUREITEM gets called again. - // Can't use CBS_OWNERDRAWVARIABLE because it has odd - // mouse-wheel behaviour. - // - wxString value = GetValue(); - wxPoint pos = GetPosition(); - wxSize size = GetSize(); - size.y = GetBestSize().y; - const wxArrayString strings = GetStrings(); - const unsigned numItems = strings.size(); - unsigned i; - - // Save the client data pointers before clearing the control, if any. - const wxClientDataType clientDataType = GetClientDataType(); - wxVector objectClientData; - wxVector voidClientData; - switch ( clientDataType ) - { - case wxClientData_None: - break; - - case wxClientData_Object: - objectClientData.reserve(numItems); - for ( i = 0; i < numItems; ++i ) - objectClientData.push_back(GetClientObject(i)); - break; - - case wxClientData_Void: - voidClientData.reserve(numItems); - for ( i = 0; i < numItems; ++i ) - voidClientData.push_back(GetClientData(i)); - break; - } - - wxComboBox::DoClear(); - - HWND hwnd = GetHwnd(); - DissociateHandle(); - ::DestroyWindow(hwnd); - - if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) ) - return; - - // initialize the controls contents - for ( i = 0; i < numItems; i++ ) - { - wxComboBox::Append(strings[i]); - - if ( !objectClientData.empty() ) - SetClientObject(i, objectClientData[i]); - else if ( !voidClientData.empty() ) - SetClientData(i, voidClientData[i]); - } - - // and make sure it has the same attributes as before - if ( m_hasFont ) - { - // calling SetFont(m_font) would do nothing as the code would - // notice that the font didn't change, so force it to believe - // that it did - wxFont font = m_font; - m_font = wxNullFont; - SetFont(font); - } - - if ( m_hasFgCol ) - { - wxColour colFg = m_foregroundColour; - m_foregroundColour = wxNullColour; - SetForegroundColour(colFg); - } - - if ( m_hasBgCol ) - { - wxColour colBg = m_backgroundColour; - m_backgroundColour = wxNullColour; - SetBackgroundColour(colBg); - } - else - { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - } - - ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0)); - - // Revert the old string value - if ( !HasFlag(wxCB_READONLY) ) - ChangeValue(value); -} - -wxBitmapComboBox::~wxBitmapComboBox() -{ - Clear(); -} - -wxSize wxBitmapComboBox::DoGetBestSize() const -{ - wxSize best = wxComboBox::DoGetBestSize(); - wxSize bitmapSize = GetBitmapSize(); - - wxCoord useHeightBitmap = EDIT_HEIGHT_FROM_CHAR_HEIGHT(bitmapSize.y); - if ( best.y < useHeightBitmap ) - { - best.y = useHeightBitmap; - CacheBestSize(best); - } - return best; -} - -// ---------------------------------------------------------------------------- -// Item manipulation -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) -{ - OnAddBitmap(bitmap); - DoSetItemBitmap(n, bitmap); - - if ( (int)n == GetSelection() ) - Refresh(); -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Append(item); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, - void *clientData) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Append(item, clientData); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, - wxClientData *clientData) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Append(item, clientData); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, - const wxBitmap& bitmap, - unsigned int pos) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Insert(item, pos); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, void *clientData) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Insert(item, pos, clientData); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, - unsigned int pos, wxClientData *clientData) -{ - OnAddBitmap(bitmap); - const int n = wxComboBox::Insert(item, pos, clientData); - if ( n != wxNOT_FOUND ) - DoSetItemBitmap(n, bitmap); - return n; -} - -int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type) -{ - const unsigned int numItems = items.GetCount(); - const unsigned int countNew = GetCount() + numItems; - - wxASSERT( numItems == 1 || !HasFlag(wxCB_SORT) ); // Sanity check - - m_bitmaps.Alloc(countNew); - - for ( unsigned int i = 0; i < numItems; i++ ) - { - m_bitmaps.Insert(new wxBitmap(wxNullBitmap), pos + i); - } - - const int index = wxComboBox::DoInsertItems(items, pos, - clientData, type); - - if ( index == wxNOT_FOUND ) - { - for ( int i = numItems-1; i >= 0; i-- ) - BCBDoDeleteOneItem(pos + i); - } - else if ( ((unsigned int)index) != pos ) - { - // Move pre-inserted empty bitmap into correct position - // (usually happens when combo box has wxCB_SORT style) - wxBitmap* bmp = static_cast(m_bitmaps[pos]); - m_bitmaps.RemoveAt(pos); - m_bitmaps.Insert(bmp, index); - } - - return index; -} - -bool wxBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap) -{ - if ( wxBitmapComboBoxBase::OnAddBitmap(bitmap) ) - { - // Need to recreate control for a new measureitem call? - int prevItemHeight = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); - - if ( prevItemHeight != MeasureItem(0) ) - RecreateControl(); - - return true; - } - - return false; -} - -void wxBitmapComboBox::DoClear() -{ - wxComboBox::DoClear(); - wxBitmapComboBoxBase::BCBDoClear(); -} - -void wxBitmapComboBox::DoDeleteOneItem(unsigned int n) -{ - wxComboBox::DoDeleteOneItem(n); - wxBitmapComboBoxBase::BCBDoDeleteOneItem(n); -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox event handlers and such -// ---------------------------------------------------------------------------- - -void wxBitmapComboBox::OnSize(wxSizeEvent& event) -{ - // Prevent infinite looping - if ( !m_inResize ) - { - m_inResize = true; - DetermineIndent(); - m_inResize = false; - } - - event.Skip(); -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox miscellaneous -// ---------------------------------------------------------------------------- - -bool wxBitmapComboBox::SetFont(const wxFont& font) -{ - bool res = wxComboBox::SetFont(font); - UpdateInternals(); - return res; -} - -// ---------------------------------------------------------------------------- -// wxBitmapComboBox item drawing and measuring -// ---------------------------------------------------------------------------- - -bool wxBitmapComboBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) -{ - LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT) item; - int pos = lpDrawItem->itemID; - - // Draw default for item -1, which means 'focus rect only' - if ( pos == -1 ) - return FALSE; - - int flags = 0; - if ( lpDrawItem->itemState & ODS_COMBOBOXEDIT ) - flags |= wxODCB_PAINTING_CONTROL; - if ( lpDrawItem->itemState & ODS_SELECTED ) - flags |= wxODCB_PAINTING_SELECTED; - - wxString text; - - if ( flags & wxODCB_PAINTING_CONTROL ) - { - text = GetValue(); - if ( !HasFlag(wxCB_READONLY) ) - text.clear(); - } - else - { - text = GetString(pos); - } - - wxPaintDCEx dc(this, lpDrawItem->hDC); - wxRect rect = wxRectFromRECT(lpDrawItem->rcItem); - wxBitmapComboBoxBase::DrawBackground(dc, rect, pos, flags); - wxBitmapComboBoxBase::DrawItem(dc, rect, pos, text, flags); - - // If the item has the focus, draw focus rectangle. - // Commented out since regular combo box doesn't - // seem to do it either. - //if ( lpDrawItem->itemState & ODS_FOCUS ) - // DrawFocusRect(lpDrawItem->hDC, &lpDrawItem->rcItem); - - return true; -} - -bool wxBitmapComboBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) -{ - LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT) item; - int pos = lpMeasureItem->itemID; - - // Measure item height if item list is not empty, - // otherwise leave default system value. - if ( pos >= 0 ) - { - lpMeasureItem->itemHeight = wxBitmapComboBoxBase::MeasureItem(pos); - } - - return true; -} - -#endif // wxUSE_BITMAPCOMBOBOX diff --git a/Source/3rd Party/wx/src/msw/brush.cpp b/Source/3rd Party/wx/src/msw/brush.cpp index a44425913..ac03729cb 100644 --- a/Source/3rd Party/wx/src/msw/brush.cpp +++ b/Source/3rd Party/wx/src/msw/brush.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: brush.cpp 42776 2006-10-30 22:03:53Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,6 @@ #include "wx/list.h" #include "wx/utils.h" #include "wx/app.h" - #include "wx/bitmap.h" #endif // WX_PRECOMP #include "wx/msw/private.h" @@ -41,7 +41,7 @@ class WXDLLEXPORT wxBrushRefData: public wxGDIRefData { public: - wxBrushRefData(const wxColour& colour = wxNullColour, wxBrushStyle style = wxBRUSHSTYLE_SOLID); + wxBrushRefData(const wxColour& colour = wxNullColour, int style = wxSOLID); wxBrushRefData(const wxBitmap& stipple); wxBrushRefData(const wxBrushRefData& data); virtual ~wxBrushRefData(); @@ -52,17 +52,17 @@ public: void Free(); const wxColour& GetColour() const { return m_colour; } - wxBrushStyle GetStyle() const { return m_style; } + int GetStyle() const { return m_style; } wxBitmap *GetStipple() { return &m_stipple; } void SetColour(const wxColour& colour) { Free(); m_colour = colour; } - void SetStyle(wxBrushStyle style) { Free(); m_style = style; } + void SetStyle(int style) { Free(); m_style = style; } void SetStipple(const wxBitmap& stipple) { Free(); DoSetStipple(stipple); } private: void DoSetStipple(const wxBitmap& stipple); - wxBrushStyle m_style; + int m_style; wxBitmap m_stipple; wxColour m_colour; HBRUSH m_hBrush; @@ -84,7 +84,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) // wxBrushRefData ctors/dtor // ---------------------------------------------------------------------------- -wxBrushRefData::wxBrushRefData(const wxColour& colour, wxBrushStyle style) +wxBrushRefData::wxBrushRefData(const wxColour& colour, int style) : m_colour(colour) { m_style = style; @@ -130,8 +130,7 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const void wxBrushRefData::DoSetStipple(const wxBitmap& stipple) { m_stipple = stipple; - m_style = stipple.GetMask() ? wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE - : wxBRUSHSTYLE_STIPPLE; + m_style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE; } // ---------------------------------------------------------------------------- @@ -154,12 +153,12 @@ static int TranslateHatchStyle(int style) { switch ( style ) { - case wxBRUSHSTYLE_BDIAGONAL_HATCH: return HS_BDIAGONAL; - case wxBRUSHSTYLE_CROSSDIAG_HATCH: return HS_DIAGCROSS; - case wxBRUSHSTYLE_FDIAGONAL_HATCH: return HS_FDIAGONAL; - case wxBRUSHSTYLE_CROSS_HATCH: return HS_CROSS; - case wxBRUSHSTYLE_HORIZONTAL_HATCH:return HS_HORIZONTAL; - case wxBRUSHSTYLE_VERTICAL_HATCH: return HS_VERTICAL; + case wxBDIAGONAL_HATCH: return HS_BDIAGONAL; + case wxCROSSDIAG_HATCH: return HS_DIAGCROSS; + case wxFDIAGONAL_HATCH: return HS_FDIAGONAL; + case wxCROSS_HATCH: return HS_CROSS; + case wxHORIZONTAL_HATCH:return HS_HORIZONTAL; + case wxVERTICAL_HATCH: return HS_VERTICAL; default: return -1; } } @@ -177,24 +176,24 @@ HBRUSH wxBrushRefData::GetHBRUSH() { switch ( m_style ) { - case wxBRUSHSTYLE_TRANSPARENT: + case wxTRANSPARENT: m_hBrush = (HBRUSH)::GetStockObject(NULL_BRUSH); break; - case wxBRUSHSTYLE_STIPPLE: + case wxSTIPPLE: m_hBrush = ::CreatePatternBrush(GetHbitmapOf(m_stipple)); break; - case wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE: + case wxSTIPPLE_MASK_OPAQUE: m_hBrush = ::CreatePatternBrush((HBITMAP)m_stipple.GetMask() ->GetMaskBitmap()); break; default: - wxFAIL_MSG( wxT("unknown brush style") ); + wxFAIL_MSG( _T("unknown brush style") ); // fall through - case wxBRUSHSTYLE_SOLID: + case wxSOLID: m_hBrush = ::CreateSolidBrush(m_colour.GetPixel()); break; } @@ -208,7 +207,7 @@ HBRUSH wxBrushRefData::GetHBRUSH() if ( !m_hBrush ) { - wxLogLastError(wxT("CreateXXXBrush()")); + wxLogLastError(_T("CreateXXXBrush()")); } } @@ -227,18 +226,11 @@ wxBrush::wxBrush() { } -wxBrush::wxBrush(const wxColour& col, wxBrushStyle style) +wxBrush::wxBrush(const wxColour& col, int style) { m_refData = new wxBrushRefData(col, style); } -#if FUTURE_WXWIN_COMPATIBILITY_3_0 -wxBrush::wxBrush(const wxColour& col, int style) -{ - m_refData = new wxBrushRefData(col, (wxBrushStyle)style); -} -#endif - wxBrush::wxBrush(const wxBitmap& stipple) { m_refData = new wxBrushRefData(stipple); @@ -260,12 +252,12 @@ bool wxBrush::operator==(const wxBrush& brush) const return m_refData ? (brushData && *M_BRUSHDATA == *brushData) : !brushData; } -wxGDIRefData *wxBrush::CreateGDIRefData() const +wxObjectRefData *wxBrush::CreateRefData() const { return new wxBrushRefData; } -wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const +wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const { return new wxBrushRefData(*(const wxBrushRefData *)data); } @@ -276,28 +268,28 @@ wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const wxColour wxBrush::GetColour() const { - wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") ); + wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") ); return M_BRUSHDATA->GetColour(); } -wxBrushStyle wxBrush::GetStyle() const +int wxBrush::GetStyle() const { - wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") ); + wxCHECK_MSG( Ok(), 0, _T("invalid brush") ); return M_BRUSHDATA->GetStyle(); } wxBitmap *wxBrush::GetStipple() const { - wxCHECK_MSG( IsOk(), NULL, wxT("invalid brush") ); + wxCHECK_MSG( Ok(), NULL, _T("invalid brush") ); return M_BRUSHDATA->GetStipple(); } WXHANDLE wxBrush::GetResourceHandle() const { - wxCHECK_MSG( IsOk(), FALSE, wxT("invalid brush") ); + wxCHECK_MSG( Ok(), FALSE, _T("invalid brush") ); return (WXHANDLE)M_BRUSHDATA->GetHBRUSH(); } @@ -320,7 +312,7 @@ void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) M_BRUSHDATA->SetColour(wxColour(r, g, b)); } -void wxBrush::SetStyle(wxBrushStyle style) +void wxBrush::SetStyle(int style) { AllocExclusive(); diff --git a/Source/3rd Party/wx/src/msw/button.cpp b/Source/3rd Party/wx/src/msw/button.cpp index 766e1dccd..635e4b926 100644 --- a/Source/3rd Party/wx/src/msw/button.cpp +++ b/Source/3rd Party/wx/src/msw/button.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: button.cpp 51575 2008-02-06 19:58:30Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,34 +37,109 @@ #include "wx/dcscreen.h" #include "wx/dcclient.h" #include "wx/toplevel.h" - #include "wx/msw/wrapcctl.h" - #include "wx/msw/private.h" - #include "wx/msw/missing.h" #endif -#include "wx/imaglist.h" #include "wx/stockitem.h" -#include "wx/msw/private/button.h" -#include "wx/msw/private/dc.h" -#include "wx/private/window.h" +#include "wx/tokenzr.h" +#include "wx/msw/private.h" -#if wxUSE_MARKUP - #include "wx/generic/private/markuptext.h" -#endif // wxUSE_MARKUP +#if wxUSE_UXTHEME + #include "wx/msw/uxtheme.h" -// set the value for BCM_SETSHIELD (for the UAC shield) if it's not defined in -// the header -#ifndef BCM_SETSHIELD - #define BCM_SETSHIELD 0x160c + // no need to include tmschema.h + #ifndef BP_PUSHBUTTON + #define BP_PUSHBUTTON 1 + + #define PBS_NORMAL 1 + #define PBS_HOT 2 + #define PBS_PRESSED 3 + #define PBS_DISABLED 4 + #define PBS_DEFAULTED 5 + + #define TMT_CONTENTMARGINS 3602 + #endif +#endif // wxUSE_UXTHEME + +#ifndef WM_THEMECHANGED + #define WM_THEMECHANGED 0x031A +#endif + +#ifndef ODS_NOACCEL + #define ODS_NOACCEL 0x0100 +#endif + +#ifndef ODS_NOFOCUSRECT + #define ODS_NOFOCUSRECT 0x0200 #endif // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxButton, wxButtonBase) - EVT_CHAR_HOOK(wxButton::OnCharHook) -END_EVENT_TABLE() +#if wxUSE_EXTENDED_RTTI + +WX_DEFINE_FLAGS( wxButtonStyle ) + +wxBEGIN_FLAGS( wxButtonStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxBU_LEFT) + wxFLAGS_MEMBER(wxBU_RIGHT) + wxFLAGS_MEMBER(wxBU_TOP) + wxFLAGS_MEMBER(wxBU_BOTTOM) + wxFLAGS_MEMBER(wxBU_EXACTFIT) +wxEND_FLAGS( wxButtonStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxButton, wxControl,"wx/button.h") + +wxBEGIN_PROPERTIES_TABLE(wxButton) + wxEVENT_PROPERTY( Click , wxEVT_COMMAND_BUTTON_CLICKED , wxCommandEvent) + + wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Label, wxString , SetLabel, GetLabel, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + + wxPROPERTY_FLAGS( WindowStyle , wxButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style + +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxButton) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_6( wxButton , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle ) + + +#else +IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) +#endif + +// this macro tries to adjust the default button height to a reasonable value +// using the char height as the base +#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10) // ============================================================================ // implementation @@ -85,14 +161,16 @@ bool wxButton::Create(wxWindow *parent, wxString label(lbl); if (label.empty() && wxIsStockID(id)) { - // On Windows, some buttons aren't supposed to have mnemonics - label = wxGetStockLabel - ( - id, - id == wxID_OK || id == wxID_CANCEL || id == wxID_CLOSE - ? wxSTOCK_NOFLAGS - : wxSTOCK_WITH_MNEMONIC - ); + // On Windows, some buttons aren't supposed to have + // mnemonics, so strip them out. + + label = wxGetStockLabel(id +#if defined(__WXMSW__) || defined(__WXWINCE__) + , ( id != wxID_OK && + id != wxID_CANCEL && + id != wxID_CLOSE ) +#endif + ); } if ( !CreateControl(parent, id, pos, size, style, validator, name) ) @@ -101,15 +179,21 @@ bool wxButton::Create(wxWindow *parent, WXDWORD exstyle; WXDWORD msStyle = MSWGetStyle(style, &exstyle); +#ifdef __WIN32__ // if the label contains several lines we must explicitly tell the button // about it or it wouldn't draw it correctly ("\n"s would just appear as // black boxes) // // NB: we do it here and not in MSWGetStyle() because we need the label - // value and the label is not set yet when MSWGetStyle() is called - msStyle |= wxMSWButton::GetMultilineStyle(label); + // value and m_label is not set yet when MSWGetStyle() is called; + // besides changing BS_MULTILINE during run-time is pointless anyhow + if ( label.find(_T('\n')) != wxString::npos ) + { + msStyle |= BS_MULTILINE; + } +#endif // __WIN32__ - return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, exstyle); + return MSWCreateControl(_T("BUTTON"), msStyle, pos, size, label, exstyle); } wxButton::~wxButton() @@ -134,10 +218,11 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const ); // we must use WS_CLIPSIBLINGS with the buttons or they would draw over - // each other in any resizable dialog which has more than one button in + // each other in any resizeable dialog which has more than one button in // the bottom msStyle |= WS_CLIPSIBLINGS; +#ifdef __WIN32__ // don't use "else if" here: weird as it is, but you may combine wxBU_LEFT // and wxBU_RIGHT to get BS_CENTER! if ( style & wxBU_LEFT ) @@ -153,10 +238,47 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & wxNO_BORDER ) msStyle |= BS_FLAT; #endif // __WXWINCE__ +#endif // __WIN32__ return msStyle; } +// ---------------------------------------------------------------------------- +// size management including autosizing +// ---------------------------------------------------------------------------- + +wxSize wxButton::DoGetBestSize() const +{ + wxClientDC dc(wx_const_cast(wxButton *, this)); + dc.SetFont(GetFont()); + + wxCoord wBtn, + hBtn; + dc.GetMultiLineTextExtent(GetLabelText(), &wBtn, &hBtn); + + // add a margin -- the button is wider than just its label + wBtn += 3*GetCharWidth(); + hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hBtn); + + // all buttons have at least the standard size unless the user explicitly + // wants them to be of smaller size and used wxBU_EXACTFIT style when + // creating the button + if ( !HasFlag(wxBU_EXACTFIT) ) + { + wxSize sz = GetDefaultSize(); + if (wBtn > sz.x) + sz.x = wBtn; + if (hBtn > sz.y) + sz.y = hBtn; + + return sz; + } + + wxSize best(wBtn, hBtn); + CacheBestSize(best); + return best; +} + /* static */ wxSize wxButtonBase::GetDefaultSize() { @@ -167,20 +289,16 @@ wxSize wxButtonBase::GetDefaultSize() wxScreenDC dc; dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - // The size of a standard button in the dialog units is 50x14, - // translate this to pixels. - // - // Windows' computes dialog units using average character width over - // upper- and lower-case ASCII alphabet and not using the average - // character width metadata stored in the font; see - // http://support.microsoft.com/default.aspx/kb/145994 for detailed - // discussion. - // - // NB: wxMulDivInt32() is used, because it correctly rounds the result - - const wxSize base = wxPrivate::GetAverageASCIILetterSize(dc); - s_sizeBtn.x = wxMulDivInt32(50, base.x, 4); - s_sizeBtn.y = wxMulDivInt32(14, base.y, 8); + // the size of a standard button in the dialog units is 50x14, + // translate this to pixels + // NB1: the multipliers come from the Windows convention + // NB2: the extra +1/+2 were needed to get the size be the same as the + // size of the buttons in the standard dialog - I don't know how + // this happens, but on my system this size is 75x23 in pixels and + // 23*8 isn't even divisible by 14... Would be nice to understand + // why these constants are needed though! + s_sizeBtn.x = (50 * (dc.GetCharWidth() + 1))/4; + s_sizeBtn.y = ((14 * dc.GetCharHeight()) + 2)/8; } return s_sizeBtn; @@ -191,25 +309,8 @@ wxSize wxButtonBase::GetDefaultSize() // ---------------------------------------------------------------------------- /* - In normal Windows programs there is no need to handle default button - manually because this is taken care by the system provided you use - WM_NEXTDLGCTL and not just SetFocus() to switch focus betweeh the controls - (see http://blogs.msdn.com/oldnewthing/archive/2004/08/02/205624.aspx for - the full explanation why just calling SetFocus() is not enough). - - However this only works if the window is a dialog, i.e. uses DefDlgProc(), - but not with plain windows using DefWindowProc() and we do want to have - default buttons inside frames as well, so we're forced to reimplement all - this logic ourselves. It would be great to avoid having to do this but using - DefDlgProc() for all the windows would almost certainly result in more - problems, we'd need to carefully filter messages and pass some of them to - DefWindowProc() and some of them to DefDlgProc() which looks dangerous (what - if the handling of some message changes in some Windows version?), so doing - this ourselves is probably a lesser evil. - - Read the rest to learn everything you ever wanted to know about the default - buttons but were afraid to ask. - + "Everything you ever wanted to know about the default buttons" or "Why do we + have to do all this?" In MSW the default button should be activated when the user presses Enter and the current control doesn't process Enter itself somehow. This is @@ -231,19 +332,29 @@ wxSize wxButtonBase::GetDefaultSize() to it. When the button loses focus, it unsets the temporary default and so the default item will be the permanent default -- that is the default button if any had been set or none otherwise, which is just what we want. + + NB: all this is quite complicated by now and the worst is that normally + it shouldn't be necessary at all as for the normal Windows programs + DefWindowProc() and IsDialogMessage() take care of all this + automatically -- however in wxWidgets programs this doesn't work for + nested hierarchies (i.e. a notebook inside a notebook) for unknown + reason and so we have to reproduce all this code ourselves. It would be + very nice if we could avoid doing it. */ // set this button as the (permanently) default one in its panel -wxWindow *wxButton::SetDefault() +void wxButton::SetDefault() { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + + wxCHECK_RET( tlw, _T("button without top level window?") ); + // set this one as the default button both for wxWidgets ... - wxWindow *winOldDefault = wxButtonBase::SetDefault(); + wxWindow *winOldDefault = tlw->SetDefaultItem(this); // ... and Windows SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), false); SetDefaultStyle(this, true); - - return winOldDefault; } // return the top level parent window if it's not being deleted yet, otherwise @@ -266,10 +377,10 @@ static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win) win = parent; } - wxASSERT_MSG( win, wxT("button without top level parent?") ); + wxASSERT_MSG( win, _T("button without top level parent?") ); wxTopLevelWindow * const tlw = wxDynamicCast(win, wxTopLevelWindow); - wxASSERT_MSG( tlw, wxT("logic error in GetTLWParentIfNotBeingDeleted()") ); + wxASSERT_MSG( tlw, _T("logic error in GetTLWParentIfNotBeingDeleted()") ); return tlw; } @@ -277,24 +388,21 @@ static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win) // set this button as being currently default void wxButton::SetTmpDefault() { - wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this); + wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent()); if ( !tlw ) return; wxWindow *winOldDefault = tlw->GetDefaultItem(); tlw->SetTmpDefaultItem(this); - // Notice that the order of these statements is important, the old button - // is not reset if we do it the other way round, probably because of - // something done by the default DM_SETDEFID handler. - SetDefaultStyle(this, true); SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), false); + SetDefaultStyle(this, true); } // unset this button as currently default, it may still stay permanent default void wxButton::UnsetTmpDefault() { - wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this); + wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent()); if ( !tlw ) return; @@ -302,9 +410,8 @@ void wxButton::UnsetTmpDefault() wxWindow *winOldDefault = tlw->GetDefaultItem(); - // Just as in SetTmpDefault() above, the order is important here. - SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true); SetDefaultStyle(this, false); + SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true); } /* static */ @@ -325,7 +432,7 @@ wxButton::SetDefaultStyle(wxButton *btn, bool on) return; wxWindow * const tlw = wxGetTopLevelParent(btn); - wxCHECK_RET( tlw, wxT("button without top level window?") ); + wxCHECK_RET( tlw, _T("button without top level window?") ); ::SendMessage(GetHwndOf(tlw), DM_SETDEFID, btn->GetId(), 0L); @@ -363,7 +470,7 @@ wxButton::SetDefaultStyle(wxButton *btn, bool on) bool wxButton::SendClickEvent() { - wxCommandEvent event(wxEVT_BUTTON, GetId()); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); event.SetEventObject(this); return ProcessCommand(event); @@ -378,25 +485,6 @@ void wxButton::Command(wxCommandEvent & event) // event/message handlers // ---------------------------------------------------------------------------- -void wxButton::OnCharHook(wxKeyEvent& event) -{ - // We want to ensure that the button always processes Enter key events - // itself, even if it's inside some control that normally takes over them - // (this happens when the button is part of an in-place editor control for - // example). - if ( event.GetKeyCode() == WXK_RETURN ) - { - // We should ensure that subsequent key events are still generated even - // if we did handle EVT_CHAR_HOOK (normally this would suppress their - // generation). - event.DoAllowNextEvent(); - } - else - { - event.Skip(); - } -} - bool wxButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { bool processed = false; @@ -436,30 +524,367 @@ WXLRESULT wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { UnsetTmpDefault(); } + else if ( nMsg == WM_LBUTTONDBLCLK ) + { + // emulate a click event to force an owner-drawn button to change its + // appearance - without this, it won't do it + (void)wxControl::MSWWindowProc(WM_LBUTTONDOWN, wParam, lParam); + + // and continue with processing the message normally as well + } +#if wxUSE_UXTHEME + else if ( nMsg == WM_THEMECHANGED ) + { + // need to recalculate the best size here + // as the theme size might have changed + InvalidateBestSize(); + } + else if ( wxUxThemeEngine::GetIfActive() ) + { + // we need to Refresh() if mouse has entered or left window + // so we can update the hot tracking state + // must use m_mouseInWindow here instead of IsMouseInWindow() + // since we need to know the first time the mouse enters the window + // and IsMouseInWindow() would return true in this case + if ( ( nMsg == WM_MOUSEMOVE && !m_mouseInWindow ) || + nMsg == WM_MOUSELEAVE ) + { + Refresh(); + } + } +#endif // wxUSE_UXTHEME // let the base class do all real processing - return wxAnyButton::MSWWindowProc(nMsg, wParam, lParam); + return wxControl::MSWWindowProc(nMsg, wParam, lParam); } // ---------------------------------------------------------------------------- -// authentication needed handling +// owner-drawn buttons support // ---------------------------------------------------------------------------- -bool wxButton::DoGetAuthNeeded() const -{ - return m_authNeeded; -} +#ifdef __WIN32__ -void wxButton::DoSetAuthNeeded(bool show) +// drawing helpers + +static void DrawButtonText(HDC hdc, + RECT *pRect, + const wxString& text, + COLORREF col) { - // show/hide UAC symbol on Windows Vista and later - if ( wxGetWinVersion() >= wxWinVersion_6 ) + COLORREF colOld = SetTextColor(hdc, col); + int modeOld = SetBkMode(hdc, TRANSPARENT); + + if ( text.find(_T('\n')) != wxString::npos ) { - m_authNeeded = show; - ::SendMessage(GetHwnd(), BCM_SETSHIELD, 0, show); - InvalidateBestSize(); + // draw multiline label + + // first we need to compute its bounding rect + RECT rc; + ::CopyRect(&rc, pRect); + ::DrawText(hdc, text, text.length(), &rc, DT_CENTER | DT_CALCRECT); + + // now center this rect inside the entire button area + const LONG w = rc.right - rc.left; + const LONG h = rc.bottom - rc.top; + rc.left = (pRect->right - pRect->left)/2 - w/2; + rc.right = rc.left+w; + rc.top = (pRect->bottom - pRect->top)/2 - h/2; + rc.bottom = rc.top+h; + + ::DrawText(hdc, text, text.length(), &rc, DT_CENTER); + } + else // single line label + { + // Note: we must have DT_SINGLELINE for DT_VCENTER to work. + ::DrawText(hdc, text, text.length(), pRect, + DT_SINGLELINE | DT_CENTER | DT_VCENTER); + } + + SetBkMode(hdc, modeOld); + SetTextColor(hdc, colOld); +} + +static void DrawRect(HDC hdc, const RECT& r) +{ + wxDrawLine(hdc, r.left, r.top, r.right, r.top); + wxDrawLine(hdc, r.right, r.top, r.right, r.bottom); + wxDrawLine(hdc, r.right, r.bottom, r.left, r.bottom); + wxDrawLine(hdc, r.left, r.bottom, r.left, r.top); +} + +void wxButton::MakeOwnerDrawn() +{ + long style = GetWindowLong(GetHwnd(), GWL_STYLE); + if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW ) + { + // make it so + style |= BS_OWNERDRAW; + SetWindowLong(GetHwnd(), GWL_STYLE, style); } } -#endif // wxUSE_BUTTON +bool wxButton::SetBackgroundColour(const wxColour &colour) +{ + if ( !wxControl::SetBackgroundColour(colour) ) + { + // nothing to do + return false; + } + MakeOwnerDrawn(); + + Refresh(); + + return true; +} + +bool wxButton::SetForegroundColour(const wxColour &colour) +{ + if ( !wxControl::SetForegroundColour(colour) ) + { + // nothing to do + return false; + } + + MakeOwnerDrawn(); + + Refresh(); + + return true; +} + +/* + The button frame looks like this normally: + + WWWWWWWWWWWWWWWWWWB + WHHHHHHHHHHHHHHHHGB W = white (HILIGHT) + WH GB H = light grey (LIGHT) + WH GB G = dark grey (SHADOW) + WH GB B = black (DKSHADOW) + WH GB + WGGGGGGGGGGGGGGGGGB + BBBBBBBBBBBBBBBBBBB + + When the button is selected, the button becomes like this (the total button + size doesn't change): + + BBBBBBBBBBBBBBBBBBB + BWWWWWWWWWWWWWWWWBB + BWHHHHHHHHHHHHHHGBB + BWH GBB + BWH GBB + BWGGGGGGGGGGGGGGGBB + BBBBBBBBBBBBBBBBBBB + BBBBBBBBBBBBBBBBBBB + + When the button is pushed (while selected) it is like: + + BBBBBBBBBBBBBBBBBBB + BGGGGGGGGGGGGGGGGGB + BG GB + BG GB + BG GB + BG GB + BGGGGGGGGGGGGGGGGGB + BBBBBBBBBBBBBBBBBBB +*/ + +static void DrawButtonFrame(HDC hdc, const RECT& rectBtn, + bool selected, bool pushed) +{ + RECT r; + CopyRect(&r, &rectBtn); + + HPEN hpenBlack = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW)), + hpenGrey = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)), + hpenLightGr = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)), + hpenWhite = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT)); + + HPEN hpenOld = (HPEN)SelectObject(hdc, hpenBlack); + + r.right--; + r.bottom--; + + if ( pushed ) + { + DrawRect(hdc, r); + + (void)SelectObject(hdc, hpenGrey); + ::InflateRect(&r, -1, -1); + + DrawRect(hdc, r); + } + else // !pushed + { + if ( selected ) + { + DrawRect(hdc, r); + + ::InflateRect(&r, -1, -1); + } + + wxDrawLine(hdc, r.left, r.bottom, r.right, r.bottom); + wxDrawLine(hdc, r.right, r.bottom, r.right, r.top - 1); + + (void)SelectObject(hdc, hpenWhite); + wxDrawLine(hdc, r.left, r.bottom - 1, r.left, r.top); + wxDrawLine(hdc, r.left, r.top, r.right, r.top); + + (void)SelectObject(hdc, hpenLightGr); + wxDrawLine(hdc, r.left + 1, r.bottom - 2, r.left + 1, r.top + 1); + wxDrawLine(hdc, r.left + 1, r.top + 1, r.right - 1, r.top + 1); + + (void)SelectObject(hdc, hpenGrey); + wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1); + wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top); + } + + (void)SelectObject(hdc, hpenOld); + DeleteObject(hpenWhite); + DeleteObject(hpenLightGr); + DeleteObject(hpenGrey); + DeleteObject(hpenBlack); +} + +#if wxUSE_UXTHEME +static +void MSWDrawXPBackground(wxButton *button, WXDRAWITEMSTRUCT *wxdis) +{ + LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; + HDC hdc = lpDIS->hDC; + UINT state = lpDIS->itemState; + RECT rectBtn; + CopyRect(&rectBtn, &lpDIS->rcItem); + + wxUxThemeHandle theme(button, L"BUTTON"); + int iState; + + if ( state & ODS_SELECTED ) + { + iState = PBS_PRESSED; + } + else if ( button->HasCapture() || button->IsMouseInWindow() ) + { + iState = PBS_HOT; + } + else if ( state & ODS_FOCUS ) + { + iState = PBS_DEFAULTED; + } + else if ( state & ODS_DISABLED ) + { + iState = PBS_DISABLED; + } + else + { + iState = PBS_NORMAL; + } + + // draw parent background if needed + if ( wxUxThemeEngine::Get()->IsThemeBackgroundPartiallyTransparent(theme, + BP_PUSHBUTTON, + iState) ) + { + wxUxThemeEngine::Get()->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn); + } + + // draw background + wxUxThemeEngine::Get()->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, + &rectBtn, NULL); + + // calculate content area margins + MARGINS margins; + wxUxThemeEngine::Get()->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, + TMT_CONTENTMARGINS, &rectBtn, &margins); + RECT rectClient; + ::CopyRect(&rectClient, &rectBtn); + ::InflateRect(&rectClient, -margins.cxLeftWidth, -margins.cyTopHeight); + + // if focused and !nofocus rect + if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) ) + { + DrawFocusRect(hdc, &rectClient); + } + + if ( button->UseBgCol() ) + { + COLORREF colBg = wxColourToRGB(button->GetBackgroundColour()); + HBRUSH hbrushBackground = ::CreateSolidBrush(colBg); + + // don't overwrite the focus rect + ::InflateRect(&rectClient, -1, -1); + FillRect(hdc, &rectClient, hbrushBackground); + ::DeleteObject(hbrushBackground); + } +} +#endif // wxUSE_UXTHEME + +bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) +{ + LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; + HDC hdc = lpDIS->hDC; + UINT state = lpDIS->itemState; + RECT rectBtn; + CopyRect(&rectBtn, &lpDIS->rcItem); + +#if wxUSE_UXTHEME + if ( wxUxThemeEngine::GetIfActive() ) + { + MSWDrawXPBackground(this, wxdis); + } + else +#endif // wxUSE_UXTHEME + { + COLORREF colBg = wxColourToRGB(GetBackgroundColour()); + + // first, draw the background + HBRUSH hbrushBackground = ::CreateSolidBrush(colBg); + FillRect(hdc, &rectBtn, hbrushBackground); + ::DeleteObject(hbrushBackground); + + // draw the border for the current state + bool selected = (state & ODS_SELECTED) != 0; + if ( !selected ) + { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + if ( tlw ) + { + selected = tlw->GetDefaultItem() == this; + } + } + bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0; + + DrawButtonFrame(hdc, rectBtn, selected, pushed); + + // if focused and !nofocus rect + if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) ) + { + RECT rectFocus; + CopyRect(&rectFocus, &rectBtn); + + // I don't know where does this constant come from, but this is how + // Windows draws them + InflateRect(&rectFocus, -4, -4); + + DrawFocusRect(hdc, &rectFocus); + } + + if ( pushed ) + { + // the label is shifted by 1 pixel to create "pushed" effect + OffsetRect(&rectBtn, 1, 1); + } + } + + COLORREF colFg = wxColourToRGB(GetForegroundColour()); + if ( state & ODS_DISABLED ) colFg = GetSysColor(COLOR_GRAYTEXT) ; + wxString label = GetLabel(); + if ( state & ODS_NOACCEL ) label = GetLabelText() ; + DrawButtonText(hdc, &rectBtn, label, colFg); + + return true; +} + +#endif // __WIN32__ + +#endif // wxUSE_BUTTON diff --git a/Source/3rd Party/wx/src/msw/calctrl.cpp b/Source/3rd Party/wx/src/msw/calctrl.cpp deleted file mode 100644 index 8b6f359fa..000000000 --- a/Source/3rd Party/wx/src/msw/calctrl.cpp +++ /dev/null @@ -1,524 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/msw/calctrl.cpp -// Purpose: wxCalendarCtrl implementation -// Author: Vadim Zeitlin -// Created: 2008-04-04 -// Copyright: (C) 2008 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_CALENDARCTRL - -#ifndef WX_PRECOMP - #include "wx/msw/wrapwin.h" - #include "wx/msw/wrapcctl.h" // include "properly" - #include "wx/msw/private.h" -#endif - -#include "wx/calctrl.h" - -#include "wx/msw/private/datecontrols.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -namespace -{ - -// values of week days used by the native control -enum -{ - MonthCal_Monday, - MonthCal_Tuesday, - MonthCal_Wednesday, - MonthCal_Thursday, - MonthCal_Friday, - MonthCal_Saturday, - MonthCal_Sunday -}; - -} // anonymous namespace - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl creation -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::Init() -{ - m_marks = - m_holidays = 0; -} - -bool -wxCalendarCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& dt, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( !wxMSWDateControls::CheckInitialization() ) - return false; - - // we need the arrows for the navigation - style |= wxWANTS_CHARS; - - // initialize the base class - if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) - return false; - - // create the native control: this is a bit tricky as we want to receive - // double click events but the MONTHCAL_CLASS doesn't use CS_DBLCLKS style - // and so we create our own copy of it which does - static ClassRegistrar s_clsMonthCal; - if ( !s_clsMonthCal.IsInitialized() ) - { - // get a copy of standard class and modify it - WNDCLASS wc; - if ( ::GetClassInfo(NULL, MONTHCAL_CLASS, &wc) ) - { - wc.lpszClassName = wxT("_wx_SysMonthCtl32"); - wc.style |= CS_DBLCLKS; - s_clsMonthCal.Register(wc); - } - else - { - wxLogLastError(wxT("GetClassInfoEx(SysMonthCal32)")); - } - } - - const wxChar * const clsname = s_clsMonthCal.IsRegistered() - ? static_cast(s_clsMonthCal.GetName().t_str()) - : MONTHCAL_CLASS; - - if ( !MSWCreateControl(clsname, wxEmptyString, pos, size) ) - return false; - - // initialize the control - UpdateFirstDayOfWeek(); - - SetDate(dt.IsValid() ? dt : wxDateTime::Today()); - - SetHolidayAttrs(); - UpdateMarks(); - - Connect(wxEVT_LEFT_DOWN, - wxMouseEventHandler(wxCalendarCtrl::MSWOnClick)); - Connect(wxEVT_LEFT_DCLICK, - wxMouseEventHandler(wxCalendarCtrl::MSWOnDoubleClick)); - - return true; -} - -WXDWORD wxCalendarCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - WXDWORD styleMSW = wxCalendarCtrlBase::MSWGetStyle(style, exstyle); - - // right now we don't support all native styles but we should add wx styles - // corresponding to MCS_NOTODAY and MCS_NOTODAYCIRCLE probably (TODO) - - // for compatibility with the other versions, just turn off today display - // unconditionally for now - styleMSW |= MCS_NOTODAY; - - // we also need this style for Mark() to work - styleMSW |= MCS_DAYSTATE; - - if ( style & wxCAL_SHOW_WEEK_NUMBERS ) - styleMSW |= MCS_WEEKNUMBERS; - - return styleMSW; -} - -void wxCalendarCtrl::SetWindowStyleFlag(long style) -{ - const bool hadMondayFirst = HasFlag(wxCAL_MONDAY_FIRST); - - wxCalendarCtrlBase::SetWindowStyleFlag(style); - - if ( HasFlag(wxCAL_MONDAY_FIRST) != hadMondayFirst ) - UpdateFirstDayOfWeek(); -} - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl geometry -// ---------------------------------------------------------------------------- - -// TODO: handle WM_WININICHANGE -wxSize wxCalendarCtrl::DoGetBestSize() const -{ - RECT rc; - if ( !GetHwnd() || !MonthCal_GetMinReqRect(GetHwnd(), &rc) ) - { - return wxCalendarCtrlBase::DoGetBestSize(); - } - - const wxSize best = wxRectFromRECT(rc).GetSize() + GetWindowBorderSize(); - CacheBestSize(best); - return best; -} - -wxCalendarHitTestResult -wxCalendarCtrl::HitTest(const wxPoint& pos, - wxDateTime *date, - wxDateTime::WeekDay *wd) -{ - WinStruct hti; - - // Vista and later SDKs add a few extra fields to MCHITTESTINFO which are - // not supported by the previous versions, as we don't use them anyhow we - // should pretend that we always use the old struct format to make the call - // below work on pre-Vista systems (see #11057) -#ifdef MCHITTESTINFO_V1_SIZE - hti.cbSize = MCHITTESTINFO_V1_SIZE; -#endif - - hti.pt.x = pos.x; - hti.pt.y = pos.y; - switch ( MonthCal_HitTest(GetHwnd(), &hti) ) - { - default: - case MCHT_CALENDARWEEKNUM: - wxFAIL_MSG( "unexpected" ); - // fall through - - case MCHT_NOWHERE: - case MCHT_CALENDARBK: - case MCHT_TITLEBK: - case MCHT_TITLEMONTH: - case MCHT_TITLEYEAR: - return wxCAL_HITTEST_NOWHERE; - - case MCHT_CALENDARDATE: - if ( date ) - date->SetFromMSWSysDate(hti.st); - return wxCAL_HITTEST_DAY; - - case MCHT_CALENDARDAY: - if ( wd ) - { - int day = hti.st.wDayOfWeek; - - // the native control returns incorrect day of the week when - // the first day isn't Monday, i.e. the first column is always - // "Monday" even if its label is "Sunday", compensate for it - const int first = LOWORD(MonthCal_GetFirstDayOfWeek(GetHwnd())); - if ( first == MonthCal_Monday ) - { - // as MonthCal_Monday is 0 while wxDateTime::Mon is 1, - // normally we need to do this to transform from MSW - // convention to wx one - day++; - day %= 7; - } - //else: but when the first day is MonthCal_Sunday, the native - // control still returns 0 (i.e. MonthCal_Monday) for the - // first column which looks like a bug in it but to work - // around it it's enough to not apply the correction above - - *wd = static_cast(day); - } - return wxCAL_HITTEST_HEADER; - - case MCHT_TITLEBTNNEXT: - return wxCAL_HITTEST_INCMONTH; - - case MCHT_TITLEBTNPREV: - return wxCAL_HITTEST_DECMONTH; - - case MCHT_CALENDARDATENEXT: - case MCHT_CALENDARDATEPREV: - return wxCAL_HITTEST_SURROUNDING_WEEK; - } -} - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl operations -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::SetDate(const wxDateTime& dt) -{ - wxCHECK_MSG( dt.IsValid(), false, "invalid date" ); - - SYSTEMTIME st; - dt.GetAsMSWSysDate(&st); - if ( !MonthCal_SetCurSel(GetHwnd(), &st) ) - { - wxLogDebug(wxT("DateTime_SetSystemtime() failed")); - - return false; - } - - m_date = dt.GetDateOnly(); - - return true; -} - -wxDateTime wxCalendarCtrl::GetDate() const -{ -#if wxDEBUG_LEVEL - SYSTEMTIME st; - - if ( !MonthCal_GetCurSel(GetHwnd(), &st) ) - { - wxASSERT_MSG( !m_date.IsValid(), "mismatch between data and control" ); - - return wxDefaultDateTime; - } - - wxDateTime dt; - dt.SetFromMSWSysDate(st); - - // Windows XP and earlier didn't include the time component into the - // returned date but Windows 7 does, so we can't compare the full objects - // in the same way under all the Windows versions, just compare their date - // parts - wxASSERT_MSG( dt.IsSameDate(m_date), "mismatch between data and control" ); -#endif // wxDEBUG_LEVEL - - return m_date; -} - -bool wxCalendarCtrl::SetDateRange(const wxDateTime& dt1, const wxDateTime& dt2) -{ - SYSTEMTIME st[2]; - - DWORD flags = 0; - if ( dt1.IsValid() ) - { - dt1.GetAsMSWSysTime(st + 0); - flags |= GDTR_MIN; - } - - if ( dt2.IsValid() ) - { - dt2.GetAsMSWSysTime(st + 1); - flags |= GDTR_MAX; - } - - if ( !MonthCal_SetRange(GetHwnd(), flags, st) ) - { - wxLogDebug(wxT("MonthCal_SetRange() failed")); - } - - return flags != 0; -} - -bool wxCalendarCtrl::GetDateRange(wxDateTime *dt1, wxDateTime *dt2) const -{ - SYSTEMTIME st[2]; - - DWORD flags = MonthCal_GetRange(GetHwnd(), st); - if ( dt1 ) - { - if ( flags & GDTR_MIN ) - dt1->SetFromMSWSysDate(st[0]); - else - *dt1 = wxDefaultDateTime; - } - - if ( dt2 ) - { - if ( flags & GDTR_MAX ) - dt2->SetFromMSWSysDate(st[1]); - else - *dt2 = wxDefaultDateTime; - } - - return flags != 0; -} - -// ---------------------------------------------------------------------------- -// other wxCalendarCtrl operations -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::EnableMonthChange(bool enable) -{ - if ( !wxCalendarCtrlBase::EnableMonthChange(enable) ) - return false; - - wxDateTime dtStart, dtEnd; - if ( !enable ) - { - dtStart = GetDate(); - dtStart.SetDay(1); - - dtEnd = dtStart.GetLastMonthDay(); - } - //else: leave them invalid to remove the restriction - - SetDateRange(dtStart, dtEnd); - - return true; -} - -void wxCalendarCtrl::Mark(size_t day, bool mark) -{ - wxCHECK_RET( day > 0 && day < 32, "invalid day" ); - - int mask = 1 << (day - 1); - if ( mark ) - m_marks |= mask; - else - m_marks &= ~mask; - - // calling Refresh() here is not enough to change the day appearance - UpdateMarks(); -} - -void wxCalendarCtrl::SetHoliday(size_t day) -{ - wxCHECK_RET( day > 0 && day < 32, "invalid day" ); - - m_holidays |= 1 << (day - 1); -} - -void wxCalendarCtrl::UpdateMarks() -{ - // Currently the native control may show more than one month if its size is - // big enough. Ideal would be to prevent this from happening but there - // doesn't seem to be any obvious way to do it, so for now just handle the - // possibility that we can display several of them: one before the current - // one and up to 12 after it. - MONTHDAYSTATE states[14] = { 0 }; - const DWORD nMonths = MonthCal_GetMonthRange(GetHwnd(), GMR_DAYSTATE, NULL); - - // although in principle the calendar might not show any days from the - // preceding months, it seems like it always does, consider e.g. Feb 2010 - // which starts on Monday and ends on Sunday and so could fit on 4 lines - // without showing any subsequent months -- the standard control still - // shows it on 6 lines and the number of visible months is still 3 - // - // OTOH Windows 7 control can show all 12 months or even years or decades - // in its window if you "zoom out" of it by double clicking on free areas - // so the return value can be (much, in case of decades view) greater than - // 3 but in this case marks are not visible anyhow so simply ignore it - if ( nMonths >= 2 && nMonths <= WXSIZEOF(states) ) - { - // The current, fully visible month is always the second one. - states[1] = m_marks | m_holidays; - - if ( !MonthCal_SetDayState(GetHwnd(), nMonths, states) ) - { - wxLogLastError(wxT("MonthCal_SetDayState")); - } - } - //else: not a month view at all -} - -void wxCalendarCtrl::UpdateFirstDayOfWeek() -{ - MonthCal_SetFirstDayOfWeek(GetHwnd(), - HasFlag(wxCAL_MONDAY_FIRST) ? MonthCal_Monday - : MonthCal_Sunday); -} - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl events -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) -{ - NMHDR* hdr = (NMHDR *)lParam; - switch ( hdr->code ) - { - case MCN_SELCHANGE: - { - // we need to update m_date first, before calling the user code - // which expects GetDate() to return the new date - const wxDateTime dateOld = m_date; - const NMSELCHANGE * const sch = (NMSELCHANGE *)lParam; - m_date.SetFromMSWSysDate(sch->stSelStart); - - // changing the year or the month results in a second dummy - // MCN_SELCHANGE event on this system which doesn't really - // change anything -- filter it out - if ( m_date != dateOld ) - { - if ( GenerateAllChangeEvents(dateOld) ) - { - // month changed, need to update the holidays if we use - // them - SetHolidayAttrs(); - UpdateMarks(); - } - } - } - break; - - case MCN_GETDAYSTATE: - { - const NMDAYSTATE * const ds = (NMDAYSTATE *)lParam; - - wxDateTime startDate; - startDate.SetFromMSWSysDate(ds->stStart); - - // Ensure we have a valid date to work with. - wxDateTime currentDate = m_date.IsValid() ? m_date : startDate; - - // Set to the start of month for comparison with startDate to - // work correctly. - currentDate.SetDay(1); - - for ( int i = 0; i < ds->cDayState; i++ ) - { - // set holiday/marks only for the "current" month - if ( startDate == currentDate ) - ds->prgDayState[i] = m_marks | m_holidays; - else - ds->prgDayState[i] = 0; - - startDate += wxDateSpan::Month(); - } - } - break; - - default: - return wxCalendarCtrlBase::MSWOnNotify(idCtrl, lParam, result); - } - - *result = 0; - return true; -} - -void wxCalendarCtrl::MSWOnDoubleClick(wxMouseEvent& event) -{ - if ( HitTest(event.GetPosition()) == wxCAL_HITTEST_DAY ) - { - if ( GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED) ) - return; // skip event.Skip() below - } - - event.Skip(); -} - -void wxCalendarCtrl::MSWOnClick(wxMouseEvent& event) -{ - // for some reason, the control doesn't get focus on its own when the user - // clicks in it - SetFocus(); - - event.Skip(); -} - -#endif // wxUSE_CALENDARCTRL diff --git a/Source/3rd Party/wx/src/msw/caret.cpp b/Source/3rd Party/wx/src/msw/caret.cpp index 43e3ec715..9c43cdf61 100644 --- a/Source/3rd Party/wx/src/msw/caret.cpp +++ b/Source/3rd Party/wx/src/msw/caret.cpp @@ -1,9 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/msw/caret.cpp +// Name: msw/caret.cpp // Purpose: MSW implementation of wxCaret // Author: Vadim Zeitlin // Modified by: // Created: 23.05.99 +// RCS-ID: $Id: caret.cpp 35650 2005-09-23 12:56:45Z MR $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -38,11 +39,9 @@ // macros // --------------------------------------------------------------------------- -#define CALL_CARET_API(api, args) \ - if ( !api args ) \ - { \ - wxLogLastError(wxT(#api)); \ - } +#define CALL_CARET_API(api, args) \ + if ( !api args ) \ + wxLogLastError(_T(#api)) // =========================================================================== // implementation diff --git a/Source/3rd Party/wx/src/msw/checkbox.cpp b/Source/3rd Party/wx/src/msw/checkbox.cpp index fd3a4a882..550afd740 100644 --- a/Source/3rd Party/wx/src/msw/checkbox.cpp +++ b/Source/3rd Party/wx/src/msw/checkbox.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: checkbox.cpp 40331 2006-07-25 18:47:39Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,21 +30,37 @@ #ifndef WX_PRECOMP #include "wx/brush.h" - #include "wx/dcclient.h" #include "wx/dcscreen.h" #include "wx/settings.h" #endif -#include "wx/msw/dc.h" // for wxDCTemp -#include "wx/renderer.h" #include "wx/msw/uxtheme.h" -#include "wx/msw/private/button.h" -#include "wx/msw/missing.h" +#include "wx/msw/private.h" // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- +#ifndef BST_UNCHECKED + #define BST_UNCHECKED 0x0000 +#endif + +#ifndef BST_CHECKED + #define BST_CHECKED 0x0001 +#endif + +#ifndef BST_INDETERMINATE + #define BST_INDETERMINATE 0x0002 +#endif + +#ifndef DFCS_HOT + #define DFCS_HOT 0x1000 +#endif + +#ifndef DT_HIDEPREFIX + #define DT_HIDEPREFIX 0x00100000 +#endif + #ifndef BP_CHECKBOX #define BP_CHECKBOX 3 #endif @@ -78,6 +95,59 @@ enum // implementation // ============================================================================ +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxCheckBoxStyle ) + +wxBEGIN_FLAGS( wxCheckBoxStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxNO_BORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + +wxEND_FLAGS( wxCheckBoxStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckBox, wxControl,"wx/checkbox.h") + +wxBEGIN_PROPERTIES_TABLE(wxCheckBox) + wxEVENT_PROPERTY( Click , wxEVT_COMMAND_CHECKBOX_CLICKED , wxCommandEvent ) + + wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Value ,bool, SetValue, GetValue, EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY_FLAGS( WindowStyle , wxCheckBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxCheckBox) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_6( wxCheckBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle ) +#else +IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) +#endif + + // ---------------------------------------------------------------------------- // wxCheckBox creation // ---------------------------------------------------------------------------- @@ -99,41 +169,36 @@ bool wxCheckBox::Create(wxWindow *parent, { Init(); - WXValidateStyle(&style); if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; - WXDWORD exstyle; - WXDWORD msStyle = MSWGetStyle(style, &exstyle); - - msStyle |= wxMSWButton::GetMultilineStyle(label); - - return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, exstyle); -} - -WXDWORD wxCheckBox::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - // buttons never have an external border, they draw their own one - WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); + long msStyle = WS_TABSTOP; if ( style & wxCHK_3STATE ) + { msStyle |= BS_3STATE; + } else + { + wxASSERT_MSG( !Is3rdStateAllowedForUser(), + wxT("Using wxCH_ALLOW_3RD_STATE_FOR_USER") + wxT(" style flag for a 2-state checkbox is useless") ); msStyle |= BS_CHECKBOX; + } if ( style & wxALIGN_RIGHT ) { msStyle |= BS_LEFTTEXT | BS_RIGHT; } - return msStyle; + return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0); } // ---------------------------------------------------------------------------- // wxCheckBox geometry // ---------------------------------------------------------------------------- -wxSize wxCheckBox::DoGetBestClientSize() const +wxSize wxCheckBox::DoGetBestSize() const { static int s_checkSize = 0; @@ -150,24 +215,9 @@ wxSize wxCheckBox::DoGetBestClientSize() const int wCheckbox, hCheckbox; if ( !str.empty() ) { - wxClientDC dc(const_cast(this)); - dc.SetFont(GetFont()); - dc.GetMultiLineTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox); + GetTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox); wCheckbox += s_checkSize + GetCharWidth(); - if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & BS_MULTILINE ) - { - // We need to make the checkbox even wider in this case because - // otherwise it wraps lines automatically and not only on "\n"s as - // we need and this makes the size computed here wrong resulting in - // checkbox contents being truncated when it's actually displayed. - // Without this hack simple checkbox with "Some thing\n and more" - // label appears on 3 lines, not 2, under Windows 2003 using - // classic look and feel (although it works fine under Windows 7, - // with or without themes). - wCheckbox += s_checkSize; - } - if ( hCheckbox < s_checkSize ) hCheckbox = s_checkSize; } @@ -189,13 +239,6 @@ wxSize wxCheckBox::DoGetBestClientSize() const // wxCheckBox operations // ---------------------------------------------------------------------------- -void wxCheckBox::SetLabel(const wxString& label) -{ - wxMSWButton::UpdateMultilineStyle(GetHwnd(), label); - - wxCheckBoxBase::SetLabel(label); -} - void wxCheckBox::SetValue(bool val) { Set3StateValue(val ? wxCHK_CHECKED : wxCHK_UNCHECKED); @@ -260,7 +303,7 @@ bool wxCheckBox::MSWCommand(WXUINT cmd, WXWORD WXUNUSED(id)) // generate the event - wxCommandEvent event(wxEVT_CHECKBOX, m_windowId); + wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId); event.SetInt(state); event.SetEventObject(this); @@ -281,7 +324,7 @@ bool wxCheckBox::SetForegroundColour(const wxColour& colour) // the only way to change the checkbox foreground colour under Windows XP // is to owner draw it if ( wxUxThemeEngine::GetIfActive() ) - MSWMakeOwnerDrawn(colour.IsOk()); + MakeOwnerDrawn(colour.Ok()); return true; } @@ -292,7 +335,7 @@ bool wxCheckBox::IsOwnerDrawn() const (::GetWindowLong(GetHwnd(), GWL_STYLE) & BS_OWNERDRAW) == BS_OWNERDRAW; } -void wxCheckBox::MSWMakeOwnerDrawn(bool ownerDrawn) +void wxCheckBox::MakeOwnerDrawn(bool ownerDrawn) { long style = ::GetWindowLong(GetHwnd(), GWL_STYLE); @@ -377,56 +420,57 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) RECT& rect = dis->rcItem; RECT rectCheck, rectLabel; - rectLabel.top = rect.top + (rect.bottom - rect.top - GetBestSize().y) / 2; - rectLabel.bottom = rectLabel.top + GetBestSize().y; + rectCheck.top = + rectLabel.top = rect.top; + rectCheck.bottom = + rectLabel.bottom = rect.bottom; + const int checkSize = GetBestSize().y; const int MARGIN = 3; - const int CXMENUCHECK = ::GetSystemMetrics(SM_CXMENUCHECK); - // the space between the checkbox and the label is included in the - // check-mark bitmap - const int checkSize = wxMin(CXMENUCHECK - MARGIN, GetSize().y); - rectCheck.top = rect.top + (rect.bottom - rect.top - checkSize) / 2; - rectCheck.bottom = rectCheck.top + checkSize; const bool isRightAligned = HasFlag(wxALIGN_RIGHT); if ( isRightAligned ) { - rectLabel.right = rect.right - CXMENUCHECK; - rectLabel.left = rect.left; + rectCheck.right = rect.right; + rectCheck.left = rectCheck.right - checkSize; - rectCheck.left = rectLabel.right + ( CXMENUCHECK + MARGIN - checkSize ) / 2; - rectCheck.right = rectCheck.left + checkSize; + rectLabel.right = rectCheck.left - MARGIN; + rectLabel.left = rect.left; } else // normal, left-aligned checkbox { - rectCheck.left = rect.left + ( CXMENUCHECK - MARGIN - checkSize ) / 2; + rectCheck.left = rect.left; rectCheck.right = rectCheck.left + checkSize; - rectLabel.left = rect.left + CXMENUCHECK; + rectLabel.left = rectCheck.right + MARGIN; rectLabel.right = rect.right; } - // shall we draw a focus rect? + // show we draw a focus rect? const bool isFocused = m_isPressed || FindFocus() == this; - // draw the checkbox itself - wxDCTemp dc(hdc); + // draw the checkbox itself: note that this should really, really be in + // wxRendererNative but unfortunately we can't add a new virtual function + // to it without breaking backwards compatibility - int flags = 0; + // classic Win32 version -- this can be useful when we move this into + // wxRendererNative +#if defined(__WXWINCE__) || !wxUSE_UXTHEME + UINT state = DFCS_BUTTONCHECK; if ( !IsEnabled() ) - flags |= wxCONTROL_DISABLED; + state |= DFCS_INACTIVE; switch ( Get3StateValue() ) { case wxCHK_CHECKED: - flags |= wxCONTROL_CHECKED; + state |= DFCS_CHECKED; break; case wxCHK_UNDETERMINED: - flags |= wxCONTROL_PRESSED; + state |= DFCS_PUSHED; break; default: - wxFAIL_MSG( wxT("unexpected Get3StateValue() return value") ); + wxFAIL_MSG( _T("unexpected Get3StateValue() return value") ); // fall through case wxCHK_UNCHECKED: @@ -435,10 +479,62 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) } if ( wxFindWindowAtPoint(wxGetMousePosition()) == this ) - flags |= wxCONTROL_CURRENT; + state |= DFCS_HOT; - wxRendererNative::Get(). - DrawCheckBox(this, dc, wxRectFromRECT(rectCheck), flags); + if ( !::DrawFrameControl(hdc, &rectCheck, DFC_BUTTON, state) ) + { + wxLogLastError(_T("DrawFrameControl(DFC_BUTTON)")); + } +#else // XP version + wxUxThemeEngine *themeEngine = wxUxThemeEngine::GetIfActive(); + if ( !themeEngine ) + return false; + + wxUxThemeHandle theme(this, L"BUTTON"); + if ( !theme ) + return false; + + int state; + switch ( Get3StateValue() ) + { + case wxCHK_CHECKED: + state = CBS_CHECKEDNORMAL; + break; + + case wxCHK_UNDETERMINED: + state = CBS_MIXEDNORMAL; + break; + + default: + wxFAIL_MSG( _T("unexpected Get3StateValue() return value") ); + // fall through + + case wxCHK_UNCHECKED: + state = CBS_UNCHECKEDNORMAL; + break; + } + + if ( !IsEnabled() ) + state += CBS_DISABLED_OFFSET; + else if ( m_isPressed ) + state += CBS_PRESSED_OFFSET; + else if ( m_isHot ) + state += CBS_HOT_OFFSET; + + HRESULT hr = themeEngine->DrawThemeBackground + ( + theme, + hdc, + BP_CHECKBOX, + state, + &rectCheck, + NULL + ); + if ( FAILED(hr) ) + { + wxLogApiError(_T("DrawThemeBackground(BP_CHECKBOX)"), hr); + } +#endif // 0/1 // draw the text const wxString& label = GetLabel(); @@ -458,20 +554,10 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) // around it if ( isFocused ) { - RECT oldLabelRect = rectLabel; // needed if right aligned - - if ( !::DrawText(hdc, label.t_str(), label.length(), &rectLabel, + if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt | DT_CALCRECT) ) { - wxLogLastError(wxT("DrawText(DT_CALCRECT)")); - } - - if ( isRightAligned ) - { - // move the label rect to the right - const int labelWidth = rectLabel.right - rectLabel.left; - rectLabel.right = oldLabelRect.right; - rectLabel.left = rectLabel.right - labelWidth; + wxLogLastError(_T("DrawText(DT_CALCRECT)")); } } @@ -480,9 +566,9 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT)); } - if ( !::DrawText(hdc, label.t_str(), label.length(), &rectLabel, fmt) ) + if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt) ) { - wxLogLastError(wxT("DrawText()")); + wxLogLastError(_T("DrawText()")); } // finally draw the focus @@ -492,7 +578,7 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) rectLabel.right++; if ( !::DrawFocusRect(hdc, &rectLabel) ) { - wxLogLastError(wxT("DrawFocusRect()")); + wxLogLastError(_T("DrawFocusRect()")); } } diff --git a/Source/3rd Party/wx/src/msw/checklst.cpp b/Source/3rd Party/wx/src/msw/checklst.cpp index 19070e326..f01f5884d 100644 --- a/Source/3rd Party/wx/src/msw/checklst.cpp +++ b/Source/3rd Party/wx/src/msw/checklst.cpp @@ -4,6 +4,7 @@ // Author: Vadim Zeitlin // Modified by: // Created: 16.11.97 +// RCS-ID: $Id: checklst.cpp 62511 2009-10-30 14:11:03Z JMS $ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -28,7 +29,7 @@ #include "wx/checklst.h" #ifndef WX_PRECOMP - #include "wx/msw/wrapcctl.h" + #include "wx/msw/wrapwin.h" #include "wx/object.h" #include "wx/colour.h" #include "wx/font.h" @@ -44,9 +45,7 @@ #include -#include "wx/renderer.h" #include "wx/msw/private.h" -#include "wx/msw/dc.h" // ---------------------------------------------------------------------------- // private functions @@ -55,113 +54,233 @@ // get item (converted to right type) #define GetItem(n) ((wxCheckListBoxItem *)(GetItem(n))) -namespace -{ - // space around check mark bitmap in pixels - static const int CHECKMARK_EXTRA_SPACE = 1; - - // space between check bitmap and text label - static const int CHECKMARK_LABEL_SPACE = 2; - -} // anonymous namespace - // ============================================================================ // implementation // ============================================================================ + +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxCheckListBoxStyle ) + +wxBEGIN_FLAGS( wxCheckListBoxStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxLB_SINGLE) + wxFLAGS_MEMBER(wxLB_MULTIPLE) + wxFLAGS_MEMBER(wxLB_EXTENDED) + wxFLAGS_MEMBER(wxLB_HSCROLL) + wxFLAGS_MEMBER(wxLB_ALWAYS_SB) + wxFLAGS_MEMBER(wxLB_NEEDED_SB) + wxFLAGS_MEMBER(wxLB_SORT) + wxFLAGS_MEMBER(wxLB_OWNERDRAW) + +wxEND_FLAGS( wxCheckListBoxStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckListBox, wxListBox,"wx/checklst.h") + +wxBEGIN_PROPERTIES_TABLE(wxCheckListBox) + wxEVENT_PROPERTY( Toggle , wxEVT_COMMAND_CHECKLISTBOX_TOGGLED , wxCommandEvent ) + wxPROPERTY_FLAGS( WindowStyle , wxCheckListBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , wxLB_OWNERDRAW /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxCheckListBox) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_4( wxCheckListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) + +#else +IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) +#endif + // ---------------------------------------------------------------------------- // declaration and implementation of wxCheckListBoxItem class // ---------------------------------------------------------------------------- class wxCheckListBoxItem : public wxOwnerDrawn { +friend class WXDLLIMPEXP_FWD_CORE wxCheckListBox; public: // ctor - wxCheckListBoxItem(wxCheckListBox *parent); + wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex); // drawing functions virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); // simple accessors and operations - wxCheckListBox *GetParent() const - { return m_parent; } + bool IsChecked() const { return m_bChecked; } - int GetIndex() const - { return m_parent->GetItemIndex(const_cast(this)); } + void Check(bool bCheck); + void Toggle() { Check(!IsChecked()); } - wxString GetName() const - { return m_parent->GetString(GetIndex()); } - - - bool IsChecked() const - { return m_checked; } - - void Check(bool bCheck) - { m_checked = bCheck; } - - void Toggle() - { Check(!IsChecked()); } + void SendEvent(); private: - wxCheckListBox *m_parent; - bool m_checked; + bool m_bChecked; + wxCheckListBox *m_pParent; + size_t m_nIndex; - wxDECLARE_NO_COPY_CLASS(wxCheckListBoxItem); + DECLARE_NO_COPY_CLASS(wxCheckListBoxItem) }; -wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *parent) +wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) + : wxOwnerDrawn(wxEmptyString, true) // checkable { - m_parent = parent; - m_checked = false; + m_bChecked = false; + m_pParent = pParent; + m_nIndex = nIndex; - wxSize size = wxRendererNative::Get().GetCheckBoxSize(parent); - size.x += 2 * CHECKMARK_EXTRA_SPACE + CHECKMARK_LABEL_SPACE; + // we don't initialize m_nCheckHeight/Width vars because it's + // done in OnMeasure while they are used only in OnDraw and we + // know that there will always be OnMeasure before OnDraw - SetMarginWidth(size.GetWidth()); - SetBackgroundColour(parent->GetBackgroundColour()); + // fix appearance for check list boxes: they don't look quite the same as + // menu icons + SetOwnMarginWidth(::GetSystemMetrics(SM_CXMENUCHECK) - + 2*wxSystemSettings::GetMetric(wxSYS_EDGE_X) + 1); + + SetBackgroundColour(pParent->GetBackgroundColour()); } bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat) { // first draw the label + if ( IsChecked() ) + stat = (wxOwnerDrawn::wxODStatus)(stat | wxOwnerDrawn::wxODChecked); + if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) return false; + // now draw the check mark part - wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); - HDC hdc = GetHdcOf(*impl); + size_t nCheckWidth = GetDefaultMarginWidth(), + nCheckHeight = m_pParent->GetItemHeight(); - wxSize size = wxRendererNative::Get().GetCheckBoxSize(GetParent()); + int x = rc.GetX(), + y = rc.GetY(); - // first create bitmap in a memory DC - MemoryHDC hdcMem(hdc); - CompatibleBitmap hBmpCheck(hdc, size.GetWidth(), size.GetHeight()); + HDC hdc = (HDC)dc.GetHDC(); - // then draw a check mark into it + // create pens, brushes &c + COLORREF colBg = wxColourToRGB(GetBackgroundColour()); + AutoHPEN hpenBack(colBg), + hpenGray(RGB(0xc0, 0xc0, 0xc0)); + + SelectInHDC selPen(hdc, (HGDIOBJ)hpenBack); + AutoHBRUSH hbrBack(colBg); + SelectInHDC selBrush(hdc, hbrBack); + + // erase the background: it could have been filled with the selected colour + Rectangle(hdc, x, y, x + nCheckWidth + 1, rc.GetBottom() + 1); + + // shift check mark 1 pixel to the right, looks better like this + x++; + + if ( IsChecked() ) { - SelectInHDC selBmp(hdcMem, hBmpCheck); + // first create a monochrome bitmap in a memory DC + MemoryHDC hdcMem(hdc); + MonoBitmap hbmpCheck(nCheckWidth, nCheckHeight); + SelectInHDC selBmp(hdcMem, hbmpCheck); - int flags = wxCONTROL_FLAT; - if ( IsChecked() ) - flags |= wxCONTROL_CHECKED; + // then draw a check mark into it + RECT rect = { 0, 0, nCheckWidth, nCheckHeight }; + ::DrawFrameControl(hdcMem, &rect, +#ifdef __WXWINCE__ + DFC_BUTTON, DFCS_BUTTONCHECK +#else + DFC_MENU, DFCS_MENUCHECK +#endif + ); - wxDCTemp dcMem(hdcMem); - wxRendererNative::Get().DrawCheckBox(GetParent(), dcMem, wxRect(size), flags); - } // select hBmpCheck out of hdcMem + // finally copy it to screen DC + ::BitBlt(hdc, x, y, nCheckWidth, nCheckHeight, hdcMem, 0, 0, SRCCOPY); + } - // finally draw bitmap to screen + // now we draw the smaller rectangle + y++; + nCheckWidth -= 2; + nCheckHeight -= 2; - // position of check mark bitmap - int x = rc.GetX() + CHECKMARK_EXTRA_SPACE; - int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2; + // draw hollow gray rectangle + (void)::SelectObject(hdc, (HGDIOBJ)hpenGray); - UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL; - wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState); + SelectInHDC selBrush2(hdc, ::GetStockObject(NULL_BRUSH)); + Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight); + + if (stat & wxODHasFocus) + { + RECT rect; + wxCopyRectToRECT(rc, rect); + DrawFocusRect(hdc, &rect); + } return true; } +// change the state of the item and redraw it +void wxCheckListBoxItem::Check(bool check) +{ + m_bChecked = check; + + // index may be changed because new items were added/deleted + if ( m_pParent->GetItemIndex(this) != (int)m_nIndex ) + { + // update it + int index = m_pParent->GetItemIndex(this); + + wxASSERT_MSG( index != wxNOT_FOUND, wxT("what does this item do here?") ); + + m_nIndex = (size_t)index; + } + + HWND hwndListbox = (HWND)m_pParent->GetHWND(); + + RECT rcUpdate; + + if ( ::SendMessage(hwndListbox, LB_GETITEMRECT, + m_nIndex, (LPARAM)&rcUpdate) == LB_ERR ) + { + wxLogDebug(wxT("LB_GETITEMRECT failed")); + } + + ::InvalidateRect(hwndListbox, &rcUpdate, FALSE); +} + +// send an "item checked" event +void wxCheckListBoxItem::SendEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId()); + event.SetInt(m_nIndex); + event.SetEventObject(m_pParent); + m_pParent->ProcessCommand(event); +} + // ---------------------------------------------------------------------------- // implementation of wxCheckListBox class // ---------------------------------------------------------------------------- @@ -220,64 +339,77 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, style | wxLB_OWNERDRAW, validator, name); } +// misc overloaded methods +// ----------------------- + +void wxCheckListBox::Delete(unsigned int n) +{ + wxCHECK_RET( IsValid(n), + wxT("invalid index in wxListBox::Delete") ); + + wxListBox::Delete(n); + + // free memory + delete m_aItems[n]; + + m_aItems.RemoveAt(n); +} + +bool wxCheckListBox::SetFont( const wxFont &font ) +{ + unsigned int i; + for ( i = 0; i < m_aItems.GetCount(); i++ ) + m_aItems[i]->SetFont(font); + + wxListBox::SetFont(font); + + return true; +} + // create/retrieve item // -------------------- // create a check list box item -wxOwnerDrawn *wxCheckListBox::CreateLboxItem(size_t WXUNUSED(n)) +wxOwnerDrawn *wxCheckListBox::CreateLboxItem(size_t nIndex) { - wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this); - return pItem; + wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex); + return pItem; } // return item size // ---------------- bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) { - if ( wxListBox::MSWOnMeasure(item) ) - { - MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item; + if ( wxListBox::MSWOnMeasure(item) ) { + MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item; - wxSize size = wxRendererNative::Get().GetCheckBoxSize(this); - size.x += 2 * CHECKMARK_EXTRA_SPACE; - size.y += 2 * CHECKMARK_EXTRA_SPACE; + // save item height + m_nItemHeight = pStruct->itemHeight; - // add place for the check mark - pStruct->itemWidth += size.GetWidth(); + // add place for the check mark + pStruct->itemWidth += wxOwnerDrawn::GetDefaultMarginWidth(); - if ( pStruct->itemHeight < static_cast(size.GetHeight()) ) - pStruct->itemHeight = size.GetHeight(); - - return true; - } - - return false; + return true; } + return false; +} + // check items // ----------- bool wxCheckListBox::IsChecked(unsigned int uiIndex) const { - wxCHECK_MSG( IsValid(uiIndex), false, wxT("bad wxCheckListBox index") ); + wxCHECK_MSG( IsValid(uiIndex), false, _T("bad wxCheckListBox index") ); return GetItem(uiIndex)->IsChecked(); } void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck) { - wxCHECK_RET( IsValid(uiIndex), wxT("bad wxCheckListBox index") ); + wxCHECK_RET( IsValid(uiIndex), _T("bad wxCheckListBox index") ); GetItem(uiIndex)->Check(bCheck); - RefreshItem(uiIndex); -} - -void wxCheckListBox::Toggle(unsigned int uiIndex) -{ - wxCHECK_RET( IsValid(uiIndex), wxT("bad wxCheckListBox index") ); - - GetItem(uiIndex)->Toggle(); - RefreshItem(uiIndex); } // process events @@ -288,33 +420,33 @@ void wxCheckListBox::OnKeyDown(wxKeyEvent& event) // what do we do? enum { - NONE, - TOGGLE, - SET, - CLEAR + None, + Toggle, + Set, + Clear } oper; switch ( event.GetKeyCode() ) { case WXK_SPACE: - oper = TOGGLE; + oper = Toggle; break; case WXK_NUMPAD_ADD: case '+': - oper = SET; + oper = Set; break; case WXK_NUMPAD_SUBTRACT: case '-': - oper = CLEAR; + oper = Clear; break; default: - oper = NONE; + oper = None; } - if ( oper != NONE ) + if ( oper != None ) { wxArrayInt selections; int count = 0; @@ -334,26 +466,31 @@ void wxCheckListBox::OnKeyDown(wxKeyEvent& event) for ( int i = 0; i < count; i++ ) { - int nItem = selections[i]; + wxCheckListBoxItem *item = GetItem(selections[i]); + if ( !item ) + { + wxFAIL_MSG( _T("no wxCheckListBoxItem?") ); + continue; + } switch ( oper ) { - case TOGGLE: - Toggle(nItem); + case Toggle: + item->Toggle(); break; - case SET: - case CLEAR: - Check(nItem, oper == SET); + case Set: + case Clear: + item->Check( oper == Set ); break; default: - wxFAIL_MSG( wxT("what should this key do?") ); + wxFAIL_MSG( _T("what should this key do?") ); } // we should send an event as this has been done by the user and // not by the program - SendEvent(nItem); + item->SendEvent(); } } else // nothing to do @@ -365,70 +502,45 @@ void wxCheckListBox::OnKeyDown(wxKeyEvent& event) void wxCheckListBox::OnLeftClick(wxMouseEvent& event) { // clicking on the item selects it, clicking on the checkmark toggles - - int nItem = HitTest(event.GetX(), event.GetY()); - - if ( nItem != wxNOT_FOUND ) + if ( event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) { - wxRect rect; - GetItemRect(nItem, rect); + int nItem = HitTest(event.GetX(), event.GetY()); - // convert item rect to check mark rect - wxSize size = wxRendererNative::Get().GetCheckBoxSize(this); - rect.x += CHECKMARK_EXTRA_SPACE; - rect.y += (rect.GetHeight() - size.GetHeight()) / 2; - rect.SetSize(size); - - if ( rect.Contains(event.GetX(), event.GetY()) ) + if ( nItem != wxNOT_FOUND ) { - // people expect to get "kill focus" event for the currently - // focused control before getting events from the other controls - // and, equally importantly, they may prevent the focus change from - // taking place at all (e.g. because the old control contents is - // invalid and needs to be corrected) in which case we shouldn't - // generate this event at all - SetFocus(); - if ( FindFocus() == this ) - { - Toggle(nItem); - SendEvent(nItem); - - // scroll one item down if the item is the last one - // and isn't visible at all - int h; - GetClientSize(NULL, &h); - if ( rect.GetBottom() > h ) - ScrollLines(1); - } - } - else - { - // implement default behaviour: clicking on the item selects it - event.Skip(); + wxCheckListBoxItem *item = GetItem(nItem); + item->Toggle(); + item->SendEvent(); } + //else: it's not an error, just click outside of client zone } else { - // implement default behaviour on click outside of client zone + // implement default behaviour: clicking on the item selects it event.Skip(); } } -wxSize wxCheckListBox::DoGetBestClientSize() const +int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const { - wxSize best = wxListBox::DoGetBestClientSize(); + int nItem = (int)::SendMessage + ( + (HWND)GetHWND(), + LB_ITEMFROMPOINT, + 0, + MAKELPARAM(x, y) + ); - // add room for the checkbox - wxSize size = wxRendererNative::Get().GetCheckBoxSize(const_cast(this)); - size.x += 2 * CHECKMARK_EXTRA_SPACE; - size.y += 2 * CHECKMARK_EXTRA_SPACE; + return nItem >= (int)m_noItems ? wxNOT_FOUND : nItem; +} - best.x += size.GetWidth(); - if ( best.y < size.GetHeight() ) - best.y = size.GetHeight(); +wxSize wxCheckListBox::DoGetBestSize() const +{ + wxSize best = wxListBox::DoGetBestSize(); + best.x += wxOwnerDrawn::GetDefaultMarginWidth(); // add room for the checkbox CacheBestSize(best); return best; } -#endif // wxUSE_CHECKLISTBOX +#endif diff --git a/Source/3rd Party/wx/src/msw/choice.cpp b/Source/3rd Party/wx/src/msw/choice.cpp index b897995c5..d154a30e0 100644 --- a/Source/3rd Party/wx/src/msw/choice.cpp +++ b/Source/3rd Party/wx/src/msw/choice.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: Vadim Zeitlin to derive from wxChoiceBase // Created: 04/01/98 +// RCS-ID: $Id: choice.cpp 51616 2008-02-09 15:22:15Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,16 +30,71 @@ #ifndef WX_PRECOMP #include "wx/utils.h" - #include "wx/app.h" #include "wx/log.h" #include "wx/brush.h" #include "wx/settings.h" #endif -#include "wx/dynlib.h" - #include "wx/msw/private.h" +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxChoiceStyle ) + +wxBEGIN_FLAGS( wxChoiceStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + +wxEND_FLAGS( wxChoiceStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl,"wx/choice.h") + +wxBEGIN_PROPERTIES_TABLE(wxChoice) + wxEVENT_PROPERTY( Select , wxEVT_COMMAND_CHOICE_SELECTED , wxCommandEvent ) + + wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY_COLLECTION( Choices , wxArrayString , wxString , AppendString , GetStrings , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Selection ,int, SetSelection, GetSelection, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY_FLAGS( WindowStyle , wxChoiceStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxChoice) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_4( wxChoice , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) +#else +IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) +#endif +/* + TODO PROPERTIES + selection (long) + content (list) + item +*/ + // ============================================================================ // implementation // ============================================================================ @@ -61,8 +117,8 @@ bool wxChoice::Create(wxWindow *parent, wxASSERT_MSG( !(style & wxCB_DROPDOWN) && !(style & wxCB_READONLY) && !(style & wxCB_SIMPLE), - wxT("this style flag is ignored by wxChoice, you ") - wxT("probably want to use a wxComboBox") ); + _T("this style flag is ignored by wxChoice, you ") + _T("probably want to use a wxComboBox") ); return CreateAndInit(parent, id, pos, size, n, choices, style, validator, name); @@ -86,8 +142,15 @@ bool wxChoice::CreateAndInit(wxWindow *parent, return false; + // choice/combobox normally has "white" (depends on colour scheme, of + // course) background rather than inheriting the parent's background + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + // initialize the controls contents - Append(n, choices); + for ( int i = 0; i < n; i++ ) + { + Append(choices[i]); + } // and now we may finally size the control properly (if needed) SetInitialSize(size); @@ -95,6 +158,20 @@ bool wxChoice::CreateAndInit(wxWindow *parent, return true; } +bool wxChoice::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator, + const wxString& name) +{ + wxCArrayString chs(choices); + return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(), + style, validator, name); +} + void wxChoice::SetLabel(const wxString& label) { if ( FindString(label) == wxNOT_FOUND ) @@ -110,20 +187,6 @@ void wxChoice::SetLabel(const wxString& label) wxChoiceBase::SetLabel(label); } -bool wxChoice::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - const wxArrayString& choices, - long style, - const wxValidator& validator, - const wxString& name) -{ - wxCArrayString chs(choices); - return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(), - style, validator, name); -} - bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg) { MSG *msg = (MSG *) pMsg; @@ -161,131 +224,95 @@ WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const return msStyle; } -#ifndef EP_EDITTEXT - #define EP_EDITTEXT 1 - #define ETS_NORMAL 1 -#endif - -wxVisualAttributes -wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) -{ - // it is important to return valid values for all attributes from here, - // GetXXX() below rely on this - wxVisualAttributes attrs; - - // FIXME: Use better dummy window? - wxWindow* wnd = wxTheApp->GetTopWindow(); - if (!wnd) - return attrs; - - attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - - // there doesn't seem to be any way to get the text colour using themes - // API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX - attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); - - // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista) - attrs.colBg = wnd->MSWGetThemeColour(L"EDIT", - EP_EDITTEXT, - ETS_NORMAL, - ThemeColourBackground, - wxSYS_COLOUR_WINDOW); - - return attrs; -} - wxChoice::~wxChoice() { - Clear(); -} - -bool wxChoice::MSWGetComboBoxInfo(tagCOMBOBOXINFO* info) const -{ - // TODO-Win9x: Get rid of this once we officially drop support for Win9x - // and just call the function directly. -#if wxUSE_DYNLIB_CLASS - typedef BOOL (WINAPI *GetComboBoxInfo_t)(HWND, tagCOMBOBOXINFO*); - static GetComboBoxInfo_t s_pfnGetComboBoxInfo = NULL; - static bool s_triedToLoad = false; - if ( !s_triedToLoad ) - { - s_triedToLoad = true; - wxLoadedDLL dllUser32("user32.dll"); - wxDL_INIT_FUNC(s_pfn, GetComboBoxInfo, dllUser32); - } - - if ( s_pfnGetComboBoxInfo ) - return (*s_pfnGetComboBoxInfo)(GetHwnd(), info) != 0; -#endif // wxUSE_DYNLIB_CLASS - - return false; + Free(); } // ---------------------------------------------------------------------------- // adding/deleting items to/from the list // ---------------------------------------------------------------------------- -int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, wxClientDataType type) +int wxChoice::DoAppend(const wxString& item) { - MSWAllocStorage(items, CB_INITSTORAGE); - - const bool append = pos == GetCount(); - - // use CB_ADDSTRING when appending at the end to make sure the control is - // resorted if it has wxCB_SORT style - const unsigned msg = append ? CB_ADDSTRING : CB_INSERTSTRING; - - if ( append ) - pos = 0; - - int n = wxNOT_FOUND; - const unsigned numItems = items.GetCount(); - for ( unsigned i = 0; i < numItems; ++i ) + int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LPARAM)item.c_str()); + if ( n == CB_ERR ) { - n = MSWInsertOrAppendItem(pos, items[i], msg); - if ( n == wxNOT_FOUND ) - return n; - - if ( !append ) - pos++; - - AssignNewItemClientData(n, clientData, i, type); + wxLogLastError(wxT("SendMessage(CB_ADDSTRING)")); + } + else // ok + { + // we need to refresh our size in order to have enough space for the + // newly added items + if ( !IsFrozen() ) + UpdateVisibleHeight(); } - // we need to refresh our size in order to have enough space for the - // newly added items - if ( !IsFrozen() ) - MSWUpdateDropDownHeight(); - InvalidateBestSize(); - return n; } -void wxChoice::DoDeleteOneItem(unsigned int n) +int wxChoice::DoInsert(const wxString& item, unsigned int pos) +{ + wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); + wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index")); + + int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos, (LPARAM)item.c_str()); + if ( n == CB_ERR ) + { + wxLogLastError(wxT("SendMessage(CB_INSERTSTRING)")); + } + else // ok + { + if ( !IsFrozen() ) + UpdateVisibleHeight(); + } + + InvalidateBestSize(); + return n; +} + +void wxChoice::Delete(unsigned int n) { wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") ); + if ( HasClientObjectData() ) + { + delete GetClientObject(n); + } + SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); if ( !IsFrozen() ) - MSWUpdateDropDownHeight(); + UpdateVisibleHeight(); InvalidateBestSize(); } -void wxChoice::DoClear() +void wxChoice::Clear() { + Free(); + SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0); if ( !IsFrozen() ) - MSWUpdateDropDownHeight(); + UpdateVisibleHeight(); InvalidateBestSize(); } +void wxChoice::Free() +{ + if ( HasClientObjectData() ) + { + unsigned int count = GetCount(); + for ( unsigned int n = 0; n < count; n++ ) + { + delete GetClientObject(n); + } + } +} + // ---------------------------------------------------------------------------- // selection // ---------------------------------------------------------------------------- @@ -356,7 +383,7 @@ int wxChoice::FindString(const wxString& s, bool bCase) const else { int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT, - (WPARAM)-1, wxMSW_CONV_LPARAM(s)); + (WPARAM)-1, (LPARAM)s.c_str()); return pos == LB_ERR ? wxNOT_FOUND : pos; } @@ -370,32 +397,26 @@ void wxChoice::SetString(unsigned int n, const wxString& s) // we have to delete and add back the string as there is no way to change a // string in place - // we need to preserve the client data manually - void *oldData = NULL; - wxClientData *oldObjData = NULL; - if ( HasClientUntypedData() ) - oldData = GetClientData(n); - else if ( HasClientObjectData() ) - oldObjData = GetClientObject(n); - - // and also the selection if we're going to delete the item that was - // selected - const bool wasSelected = static_cast(n) == GetSelection(); + // we need to preserve the client data + void *data; + if ( m_clientDataItemsType != wxClientData_None ) + { + data = DoGetItemClientData(n); + } + else // no client data + { + data = NULL; + } ::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); - ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, wxMSW_CONV_LPARAM(s) ); + ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.c_str() ); - // restore the client data - if ( oldData ) - SetClientData(n, oldData); - else if ( oldObjData ) - SetClientObject(n, oldObjData); + if ( data ) + { + DoSetItemClientData(n, data); + } + //else: it's already NULL by default - // and the selection - if ( wasSelected ) - SetSelection(n); - - // the width could have changed so the best size needs to be recomputed InvalidateBestSize(); } @@ -436,17 +457,8 @@ void wxChoice::DoSetItemClientData(unsigned int n, void* clientData) void* wxChoice::DoGetItemClientData(unsigned int n) const { - // Before using GetLastError() below, ensure that we don't have a stale - // error code from a previous API call as CB_GETITEMDATA doesn't reset it - // in case of success, it only sets it if an error occurs. - SetLastError(ERROR_SUCCESS); - LPARAM rc = SendMessage(GetHwnd(), CB_GETITEMDATA, n, 0); - - // Notice that we must call GetLastError() to distinguish between a real - // error and successfully retrieving a previously stored client data value - // of CB_ERR (-1). - if ( rc == CB_ERR && GetLastError() != ERROR_SUCCESS ) + if ( rc == CB_ERR ) { wxLogLastError(wxT("CB_GETITEMDATA")); @@ -457,46 +469,24 @@ void* wxChoice::DoGetItemClientData(unsigned int n) const return (void *)rc; } -// ---------------------------------------------------------------------------- -// wxMSW-specific geometry management -// ---------------------------------------------------------------------------- - -namespace +void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData) { - -// there is a difference between the height passed to CB_SETITEMHEIGHT and the -// real height of the combobox; it is probably not constant for all Windows -// versions/settings but right now I don't know how to find what it is so it is -// temporarily hardcoded to its value under XP systems with normal fonts sizes -const int COMBO_HEIGHT_ADJ = 6; - -} // anonymous namespace - -void wxChoice::MSWUpdateVisibleHeight() -{ - if ( m_heightOwn != wxDefaultCoord ) - { - ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, - (WPARAM)-1, m_heightOwn - COMBO_HEIGHT_ADJ); - } + DoSetItemClientData(n, clientData); } -#if wxUSE_DEFERRED_SIZING -void wxChoice::MSWEndDeferWindowPos() +wxClientData* wxChoice::DoGetItemClientObject(unsigned int n) const { - // we can only set the height of the choice itself now as it is reset to - // default every time the control is resized - MSWUpdateVisibleHeight(); - - wxChoiceBase::MSWEndDeferWindowPos(); + return (wxClientData *)DoGetItemClientData(n); } -#endif // wxUSE_DEFERRED_SIZING -void wxChoice::MSWUpdateDropDownHeight() +// ---------------------------------------------------------------------------- +// wxMSW specific helpers +// ---------------------------------------------------------------------------- + +void wxChoice::UpdateVisibleHeight() { // be careful to not change the width here - DoSetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, GetSize().y, - wxSIZE_USE_EXISTING); + DoSetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, GetSize().y, wxSIZE_USE_EXISTING); } void wxChoice::DoMoveWindow(int x, int y, int width, int height) @@ -519,191 +509,155 @@ void wxChoice::DoMoveWindow(int x, int y, int width, int height) void wxChoice::DoGetSize(int *w, int *h) const { - wxControl::DoGetSize(w, h); - // this is weird: sometimes, the height returned by Windows is clearly the // total height of the control including the drop down list -- but only - // sometimes, and sometimes it isn't so work around this here by using our - // own stored value if we have it - if ( h && m_heightOwn != wxDefaultCoord ) - *h = m_heightOwn; + // sometimes, and normally it isn't... I have no idea about what to do with + // this + wxControl::DoGetSize(w, h); } void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - const int heightBest = GetBestSize().y; + int heightOrig = height; + + // the height which we must pass to Windows should be the total height of + // the control including the drop down list while the height given to us + // is, of course, just the height of the permanently visible part of it + if ( height != wxDefaultCoord ) + { + // don't make the drop down list too tall, arbitrarily limit it to 40 + // items max and also don't leave it empty + size_t nItems = GetCount(); + if ( !nItems ) + nItems = 9; + else if ( nItems > 24 ) + nItems = 24; - // we need the real height below so get the current one if it's not given - if ( height == wxDefaultCoord ) - { - // height not specified, use the same as before - DoGetSize(NULL, &height); + // add space for the drop down list + const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); + height += hItem*(nItems + 1); } - else if ( height == heightBest ) + else { - // we don't need to manually manage our height, let the system use the - // default one - m_heightOwn = wxDefaultCoord; - } - else // non-default height specified - { - // set our new own height but be careful not to make it too big: the - // native control apparently stores it as a single byte and so setting - // own height to 256 pixels results in default height being used (255 - // is still ok) - m_heightOwn = height; - - if ( m_heightOwn > UCHAR_MAX ) - m_heightOwn = UCHAR_MAX; - // nor too small: see MSWUpdateVisibleHeight() - else if ( m_heightOwn < COMBO_HEIGHT_ADJ ) - m_heightOwn = COMBO_HEIGHT_ADJ; + // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses + // wxGetWindowRect() to determine the current height of the combobox, + // and then again sets the combobox's height to that value. Unfortunately, + // wxGetWindowRect doesn't include the dropdown list's height (at least + // on Win2K), so this would result in a combobox with dropdown height of + // 1 pixel. We have to determine the default height ourselves and call + // wxControl with that value instead. + int w, h; + RECT r; + DoGetSize(&w, &h); + if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0) + { + height = h + r.bottom - r.top; + } } + wxControl::DoSetSize(x, y, width, height, sizeFlags); + + // If we're storing a pending size, make sure we store + // the original size for reporting back to the app. + if (m_pendingSize != wxDefaultSize) + m_pendingSize = wxSize(width, heightOrig); + + // This solution works on XP, but causes choice/combobox lists to be + // too short on W2K and earlier. +#if 0 + int widthCurrent, heightCurrent; + DoGetSize(&widthCurrent, &heightCurrent); // the height which we must pass to Windows should be the total height of // the control including the drop down list while the height given to us - // is, of course, just the height of the permanently visible part of it so - // add the drop down height to it - - // don't make the drop down list too tall, arbitrarily limit it to 30 - // items max and also don't make it too small if it's currently empty - size_t nItems = GetCount(); - if (!HasFlag(wxCB_SIMPLE)) + // is, of course, just the height of the permanently visible part of it + if ( height != wxDefaultCoord && height != heightCurrent ) { + // don't make the drop down list too tall, arbitrarily limit it to 40 + // items max and also don't leave it empty + unsigned int nItems = GetCount(); if ( !nItems ) nItems = 9; - else if ( nItems > 30 ) - nItems = 30; + else if ( nItems > 24 ) + nItems = 24; + + // add space for the drop down list + const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); + height += hItem*(nItems + 1); } - - const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); - int heightWithItems = 0; - if (!HasFlag(wxCB_SIMPLE)) - // The extra item (" + 1") is required to prevent a vertical - // scrollbar from appearing with comctl32.dll versions earlier - // than 6.0 (such as found in Win2k). - heightWithItems = height + hItem*(nItems + 1); - else - heightWithItems = SetHeightSimpleComboBox(nItems); - - - // do resize the native control - wxControl::DoSetSize(x, y, width, heightWithItems, sizeFlags); - - - // make the control itself of the requested height: notice that this - // must be done after changing its size or it has no effect (apparently - // the height is reset to default during the control layout) and that it's - // useless to do it when using the deferred sizing -- in this case it - // will be done from MSWEndDeferWindowPos() -#if wxUSE_DEFERRED_SIZING - if ( m_pendingSize == wxDefaultSize ) + else // keep the same height as now { - // not using deferred sizing, update it immediately - MSWUpdateVisibleHeight(); + // normally wxWindow::DoSetSize() checks if we set the same size as the + // window already has and does nothing in this case, but for us the + // check fails as the size we pass to it includes the dropdown while + // the size returned by our GetSize() does not, so test if the size + // didn't really change ourselves here + if ( width == wxDefaultCoord || width == widthCurrent ) + { + // size doesn't change, what about position? + int xCurrent, yCurrent; + DoGetPosition(&xCurrent, &yCurrent); + const bool defMeansUnchanged = !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE); + if ( ((x == wxDefaultCoord && defMeansUnchanged) || x == xCurrent) + && + ((y == wxDefaultCoord && defMeansUnchanged) || y == yCurrent) ) + { + // nothing changes, nothing to do + return; + } + } + + // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses + // wxGetWindowRect() to determine the current height of the combobox, + // and then again sets the combobox's height to that value. Unfortunately, + // wxGetWindowRect doesn't include the dropdown list's height (at least + // on Win2K), so this would result in a combobox with dropdown height of + // 1 pixel. We have to determine the default height ourselves and call + // wxControl with that value instead. + // + // Also notice that sometimes CB_GETDROPPEDCONTROLRECT seems to return + // wildly incorrect values (~32000) which looks like a bug in it, just + // ignore them in this case + RECT r; + if ( ::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) + && r.bottom < 30000 ) + { + height = heightCurrent + r.bottom - r.top; + } } - else // in the middle of deferred sizing - { - // we need to report the size of the visible part of the control back - // in GetSize() and not height stored by DoSetSize() in m_pendingSize - m_pendingSize = wxSize(width, height); - } -#else // !wxUSE_DEFERRED_SIZING - // always update the visible height immediately - MSWUpdateVisibleHeight(); -#endif // wxUSE_DEFERRED_SIZING + + wxControl::DoSetSize(x, y, width, height, sizeFlags); +#endif } wxSize wxChoice::DoGetBestSize() const { - // The base version returns the size of the largest string - return GetSizeFromTextSize(wxChoiceBase::DoGetBestSize().x); -} - -int wxChoice::SetHeightSimpleComboBox(int nItems) const -{ - int cx, cy; - wxGetCharSize( GetHWND(), &cx, &cy, GetFont() ); - int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0); - return EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * wxMin( wxMax( nItems, 3 ), 6 ) + hItem - 1; -} - -wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const -{ - int cHeight = GetCharHeight(); - - // We are interested in the difference of sizes between the whole control - // and its child part. I.e. arrow, separators, etc. - wxSize tsize(xlen, 0); - - // FIXME-VC6: Only VC6 needs this guard, see WINVER definition in - // include/wx/msw/wrapwin.h -#if defined(WINVER) && WINVER >= 0x0500 - WinStruct info; - if ( MSWGetComboBoxInfo(&info) ) + // find the widest string + int wChoice = 0; + const unsigned int nItems = GetCount(); + for ( unsigned int i = 0; i < nItems; i++ ) { - tsize.x += info.rcItem.left + info.rcButton.right - info.rcItem.right - + info.rcItem.left + 3; // right and extra margins - } - else // Just use some rough approximation. -#endif // WINVER >= 0x0500 - { - tsize.x += 4*cHeight; + int wLine; + GetTextExtent(GetString(i), &wLine, NULL); + if ( wLine > wChoice ) + wChoice = wLine; } - // set height on our own - if( HasFlag( wxCB_SIMPLE ) ) - tsize.y = SetHeightSimpleComboBox(GetCount()); - else - tsize.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cHeight); + // give it some reasonable default value if there are no strings in the + // list + if ( wChoice == 0 ) + wChoice = 100; - // Perhaps the user wants something different from CharHeight - if ( ylen > 0 ) - tsize.IncBy(0, ylen - cHeight); + // the combobox should be slightly larger than the widest string + wChoice += 5*GetCharWidth(); - return tsize; + wxSize best(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight())); + CacheBestSize(best); + return best; } -// ---------------------------------------------------------------------------- -// Popup operations -// ---------------------------------------------------------------------------- - -void wxChoice::MSWDoPopupOrDismiss(bool show) -{ - wxASSERT_MSG( !HasFlag(wxCB_SIMPLE), - wxT("can't popup/dismiss the list for simple combo box") ); - - // we *must* set focus to the combobox before showing or hiding the drop - // down as without this we get WM_LBUTTONDOWN messages with invalid HWND - // when hiding it (whether programmatically or manually) resulting in a - // crash when we pass them to IsDialogMessage() - // - // this can be seen in the combo page of the widgets sample under Windows 7 - SetFocus(); - - ::SendMessage(GetHwnd(), CB_SHOWDROPDOWN, show, 0); -} - -bool wxChoice::Show(bool show) -{ - if ( !wxChoiceBase::Show(show) ) - return false; - - // When hiding the combobox, we also need to hide its popup part as it - // doesn't happen automatically. - if ( !show && ::SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0) ) - MSWDoPopupOrDismiss(false); - - return true; -} - -// ---------------------------------------------------------------------------- -// MSW message handlers -// ---------------------------------------------------------------------------- - WXLRESULT wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch ( nMsg ) @@ -748,7 +702,9 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) /* The native control provides a great variety in the events it sends in the different selection scenarios (undoubtedly for greater amusement of - the programmers using it). Here are the different cases: + the programmers using it). For the reference, here are the cases when + the final selection is accepted (things are quite interesting when it + is cancelled too): A. Selecting with just the arrows without opening the dropdown: 1. CBN_SELENDOK @@ -770,12 +726,6 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) Admire the different order of messages in all of those cases, it must surely have taken a lot of effort to Microsoft developers to achieve such originality. - - Additionally, notice that CBN_SELENDCANCEL doesn't seem to actually - cancel anything, if we get CBN_SELCHANGE before it, as it happens in - the case (B), the selection is still accepted. This doesn't make much - sense and directly contradicts MSDN documentation but is how the native - comboboxes behave and so we do the same thing. */ switch ( param ) { @@ -785,44 +735,55 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) // need to reset the selection back to it if it's eventually // cancelled by user m_lastAcceptedSelection = GetCurrentSelection(); + if ( m_lastAcceptedSelection == -1 ) + { + // no current selection so no need to restore it later (this + // happens when opening a combobox containing text not from its + // list of items and we shouldn't erase this text) + m_lastAcceptedSelection = wxID_NONE; + } break; case CBN_CLOSEUP: - if ( m_pendingSelection != wxID_NONE ) + // if the selection was accepted by the user, it should have been + // reset to wxID_NONE by CBN_SELENDOK, otherwise the selection was + // cancelled and we must restore the old one + if ( m_lastAcceptedSelection != wxID_NONE ) { - // This can only happen in the case (B), so set the item - // selected in the drop down as our real selection. - SendSelectionChangedEvent(wxEVT_CHOICE); - m_pendingSelection = wxID_NONE; + SetSelection(m_lastAcceptedSelection); + m_lastAcceptedSelection = wxID_NONE; } break; case CBN_SELENDOK: - // Reset the variables to prevent CBN_CLOSEUP from doing anything, - // it's not needed if we do get CBN_SELENDOK. - m_lastAcceptedSelection = - m_pendingSelection = wxID_NONE; - - SendSelectionChangedEvent(wxEVT_CHOICE); - break; - - case CBN_SELCHANGE: - // If we get this event after CBN_SELENDOK, i.e. cases (A) or (C) - // above, we don't have anything to do. But in the case (B) we need - // to remember that the selection should really change once the - // drop down is closed. - if ( m_lastAcceptedSelection != wxID_NONE ) - m_pendingSelection = GetCurrentSelection(); - break; - - case CBN_SELENDCANCEL: - // Do not reset m_pendingSelection here -- it would make sense but, - // as described above, native controls keep the selection even when - // closing the drop down by pressing Escape or TAB, so conform to - // their behaviour. + // reset it to prevent CBN_CLOSEUP from undoing the selection (it's + // ok to reset it now as GetCurrentSelection() will now return the + // same thing anyhow) m_lastAcceptedSelection = wxID_NONE; + + { + const int n = GetSelection(); + + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId); + event.SetInt(n); + event.SetEventObject(this); + + if ( n > -1 ) + { + event.SetString(GetStringSelection()); + InitCommandEventWithItems(event, n); + } + + ProcessCommand(event); + } break; + // don't handle CBN_SELENDCANCEL: just leave m_lastAcceptedSelection + // valid and the selection will be undone in CBN_CLOSEUP above + + // don't handle CBN_SELCHANGE neither, we don't want to generate events + // while the dropdown is opened -- but do add it if we ever need this + default: return false; } @@ -832,7 +793,7 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) WXHBRUSH wxChoice::MSWControlColor(WXHDC hDC, WXHWND hWnd) { - if ( !IsThisEnabled() ) + if ( !IsEnabled() ) return MSWControlColorDisabled(hDC); return wxChoiceBase::MSWControlColor(hDC, hWnd); diff --git a/Source/3rd Party/wx/src/msw/clipbrd.cpp b/Source/3rd Party/wx/src/msw/clipbrd.cpp index 269d67355..8091f2dd6 100644 --- a/Source/3rd Party/wx/src/msw/clipbrd.cpp +++ b/Source/3rd Party/wx/src/msw/clipbrd.cpp @@ -4,6 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 +// RCS-ID: $Id: clipbrd.cpp 43884 2006-12-09 19:49:40Z PC $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -78,7 +79,6 @@ // --------------------------------------------------------------------------- static bool gs_wxClipboardIsOpen = false; -static int gs_htmlcfid = 0; bool wxOpenClipboard() { @@ -90,15 +90,13 @@ bool wxOpenClipboard() gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0; if ( !gs_wxClipboardIsOpen ) - { wxLogSysError(_("Failed to open the clipboard.")); - } return gs_wxClipboardIsOpen; } else { - wxLogDebug(wxT("Cannot open clipboard without a main window.")); + wxLogDebug(wxT("Can not open clipboard without a main window.")); return false; } @@ -139,9 +137,7 @@ bool wxIsClipboardOpened() bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) { - wxDataFormat::NativeFormat cf = dataFormat.GetFormatId(); - if (cf == wxDF_HTML) - cf = gs_htmlcfid; + wxDataFormat::NativeFormat cf = dataFormat.GetFormatId(); if ( ::IsClipboardFormatAvailable(cf) ) { @@ -216,7 +212,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, { wxBitmap *bitmap = (wxBitmap *)data; - if ( bitmap && bitmap->IsOk() ) + if ( bitmap && bitmap->Ok() ) { wxDIB dib(*bitmap); if ( dib.IsOk() ) @@ -296,7 +292,8 @@ bool wxSetClipboardData(wxDataFormat dataFormat, handle = SetClipboardData(dataFormat, hGlobalMemory); break; } - + // Only tested with Visual C++ 6.0 so far +#if defined(__VISUALC__) case wxDF_HTML: { char* html = (char *)data; @@ -305,6 +302,10 @@ bool wxSetClipboardData(wxDataFormat dataFormat, char *buf = new char [400 + strlen(html)]; if(!buf) return false; + // Get clipboard id for HTML format... + static int cfid = 0; + if(!cfid) cfid = RegisterClipboardFormat(wxT("HTML Format")); + // Create a template string for the HTML header... strcpy(buf, "Version:0.9\r\n" @@ -329,19 +330,19 @@ bool wxSetClipboardData(wxDataFormat dataFormat, // string when you overwrite it so you follow up with code to replace // the 0 appended at the end with a '\r'... char *ptr = strstr(buf, "StartHTML"); - sprintf(ptr+10, "%08u", (unsigned)(strstr(buf, "") - buf)); + sprintf(ptr+10, "%08u", strstr(buf, "") - buf); *(ptr+10+8) = '\r'; ptr = strstr(buf, "EndHTML"); - sprintf(ptr+8, "%08u", (unsigned)strlen(buf)); + sprintf(ptr+8, "%08u", strlen(buf)); *(ptr+8+8) = '\r'; ptr = strstr(buf, "StartFragment"); - sprintf(ptr+14, "%08u", (unsigned)(strstr(buf, " png_bytep) in libpng.3 and libpng.txt (Cosmin). - Clarified that png_zalloc() does not clear the allocated memory, - and png_zalloc() and png_zfree() cannot be PNGAPI (Cosmin). - Renamed png_mem_size_t to png_alloc_size_t, fixed its definition in - pngconf.h, and used it in all memory allocation functions (Cosmin). - Renamed pngintrn.h to pngpriv.h, added a comment at the top of the file - mentioning that the symbols declared in that file are private, and - updated the scripts and the Visual C++ projects accordingly (Cosmin). - Removed circular references between pngconf.h and pngconf.h.in in - scripts/makefile.vc*win32 (Cosmin). - Removing trailing '.' from the warning and error messages (Cosmin). - Added pngdefs.h that is built by makefile or configure, instead of - pngconf.h.in (Glenn). - Detect and fix attempt to write wrong iCCP profile length. - -Version 1.4.0beta12 [October 19, 2006] - Changed "logical" to "bitwise" in the documentation. - Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h - Add a typecast to stifle compiler warning in pngrutil.c - -Version 1.4.0beta13 [November 10, 2006] - Fix potential buffer overflow in sPLT chunk handler. - Fix Makefile.am to not try to link to noexistent files. - -Version 1.4.0beta14 [November 15, 2006] - Check all exported functions for NULL png_ptr. - -Version 1.4.0beta15 [November 17, 2006] - Relocated two misplaced tests for NULL png_ptr. - Built Makefile.in with automake-1.9.6 instead of 1.9.2. - Build configure with autoconf-2.60 instead of 2.59 - Add "install: all" in Makefile.am so "configure; make install" will work. - -Version 1.4.0beta16 [November 17, 2006] - Added a typecast in png_zalloc(). - -Version 1.4.0beta17 [December 4, 2006] - Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c - Add "png_bytep" typecast to profile while calculating length in pngwutil.c - -Version 1.4.0beta18 [December 7, 2006] - Added scripts/CMakeLists.txt - -Version 1.4.0beta19 [May 16, 2007] - Revised scripts/CMakeLists.txt - Rebuilt configure and Makefile.in with newer tools. - Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. - Added scripts/makefile.nommx - -Version 1.4.0beta20 [July 9, 2008] - Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications - calling set_unknown_chunk_location() need them. - Moved several macro definitions from pngpriv.h to pngconf.h - Merge with changes to the 1.2.X branch, as of 1.2.30beta04. - Deleted all use of the MMX assembler code and Intel-licensed optimizations. - Revised makefile.mingw - -Version 1.4.0beta21 [July 21, 2008] - Moved local array "chunkdata" from pngrutil.c to the png_struct, so - it will be freed by png_read_destroy() in case of a read error (Kurt - Christensen). - -Version 1.4.0beta22 [July 21, 2008] - Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. - -Version 1.4.0beta23 [July 22, 2008] - Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in - png_decompress_chunk(). - -Version 1.4.0beta24 [July 25, 2008] - Change all remaining "chunkdata" to "png_ptr->chunkdata" in - png_decompress_chunk(), and remove "chunkdata" from parameter list. - Put a call to png_check_chunk_name() in png_read_chunk_header(). - Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. - Removed two calls to png_check_chunk_name() occuring later in the process. - Define PNG_NO_ERROR_NUMBERS by default in pngconf.h - -Version 1.4.0beta25 [July 30, 2008] - Added a call to png_check_chunk_name() in pngpread.c - Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte. - Added png_push_have_buffer() function to pngpread.c - Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros. - Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS. - Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code. - Synced contrib directory and configure files with libpng-1.2.30beta06. - Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles) - Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c - -Version 1.4.0beta26 [August 4, 2008] - Removed png_push_have_buffer() function in pngpread.c. It increased the - compiled library size slightly. - Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) - Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. - Updated contrib/visupng/cexcept.h to version 2.0.1 - Added PNG_LITERAL_CHARACTER macros for #, [, and ]. - -Version 1.4.0beta27 [August 5, 2008] - Revised usage of PNG_LITERAL_SHARP in pngerror.c. - Moved newline character from individual png_debug messages into the - png_debug macros. - Allow user to #define their own png_debug, png_debug1, and png_debug2. - -Version 1.4.0beta28 [August 5, 2008] - Revised usage of PNG_LITERAL_SHARP in pngerror.c. - Added PNG_STRING_NEWLINE macro - -Version 1.4.0beta29 [August 9, 2008] - Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers. - Added PNG_STRING_COPYRIGHT macro. - Added non-ISO versions of png_debug macros. - -Version 1.4.0beta30 [August 14, 2008] - Added premultiplied alpha feature (Volker Wiendl). - -Version 1.4.0beta31 [August 18, 2008] - Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c - Removed extra crc check at the end of png_handle_cHRM(). Bug introduced - in libpng-1.4.0beta20. - -Version 1.4.0beta32 [August 19, 2008] - Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. - Revised PNG_NO_STDIO version of png_write_flush() - -Version 1.4.0beta33 [August 20, 2008] - Added png_get|set_chunk_cache_max() to limit the total number of sPLT, - text, and unknown chunks that can be stored. - -Version 1.4.0beta34 [September 6, 2008] - Shortened tIME_string to 29 bytes in pngtest.c - Fixed off-by-one error introduced in png_push_read_zTXt() function in - libpng-1.2.30beta04/pngpread.c (Harald van Dijk) - -Version 1.4.0beta35 [October 6, 2008] - Changed "trans_values" to "trans_color". - Changed so-number from 0 to 14. Some OS do not like 0. - Revised makefile.darwin to fix shared library numbering. - Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8() - in example.c (debian bug report) - -Version 1.4.0beta36 [October 25, 2008] - Sync with tEXt vulnerability fix in libpng-1.2.33rc02. - -Version 1.4.0beta37 [November 13, 2008] - Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c, - and pngwrite.c - -Version 1.4.0beta38 [November 22, 2008] - Added check for zero-area RGB cHRM triangle in png_check_cHRM() and - png_check_cHRM_fixed(). - -Version 1.4.0beta39 [November 23, 2008] - Revised png_warning() to write its message on standard output by default - when warning_fn is NULL. - -Version 1.4.0beta40 [November 24, 2008] - Eliminated png_check_cHRM(). Instead, always use png_check_cHRM_fixed(). - In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant - check for all-zero coordinates that is detected by the triangle check. - -Version 1.4.0beta41 [November 26, 2008] - Fixed string vs pointer-to-string error in png_check_keyword(). - Rearranged test expressions in png_check_cHRM_fixed() to avoid internal - overflows. - Added PNG_NO_CHECK_cHRM conditional. - -Version 1.4.0beta42, 43 [December 1, 2008] - Merge png_debug with version 1.2.34beta04. - -Version 1.4.0beta44 [December 6, 2008] - Removed redundant check for key==NULL before calling png_check_keyword() - to ensure that new_key gets initialized and removed extra warning - (Merge with version 1.2.34beta05 -- Arvan Pritchard). - -Version 1.4.0beta45 [December 9, 2008] - In png_write_png(), respect the placement of the filler bytes in an earlier - call to png_set_filler() (Jim Barry). - -Version 1.4.0beta46 [December 10, 2008] - Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and - PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated - PNG_TRANSFORM_STRIP_FILLER (Jim Barry). - -Version 1.4.0beta47 [December 15, 2008] - Support for dithering was disabled by default, because it has never - been well tested and doesn't work very well. The code has not - been removed, however, and can be enabled by building libpng with - PNG_READ_DITHER_SUPPORTED defined. - -Version 1.4.0beta48 [February 14, 2009] - Added new exported function png_calloc(). - Combined several instances of png_malloc(); png_memset() into png_calloc(). - Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 - but was never defined. - -Version 1.4.0beta49 [February 28, 2009] - Added png_fileno() macro to pngconf.h, used in pngwio.c - Corrected order of #ifdef's in png_debug definition in png.h - Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments - for pcal_params. - Fixed order of #ifdef directives in the png_debug defines in png.h - (bug introduced in libpng-1.2.34/1.4.0beta29). - Revised comments in png_set_read_fn() and png_set_write_fn(). - -Version 1.4.0beta50 [March 18, 2009] - Use png_calloc() instead of png_malloc() to allocate big_row_buf when - reading an interlaced file, to avoid a possible UMR. - Undid revision of PNG_NO_STDIO version of png_write_flush(). Users - having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined - or supply their own flush_fn() replacement. - Revised libpng*.txt and png.h documentation about use of png_write_flush() - and png_set_write_fn(). - Removed fflush() from pngtest.c. - Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h - -Version 1.4.0beta51 [March 21, 2009] - Removed new png_fileno() macro from pngconf.h . - -Version 1.4.0beta52 [March 27, 2009] - Relocated png_do_chop() ahead of building gamma tables in pngrtran.c - This avoids building 16-bit gamma tables unnecessarily. - Removed fflush() from pngtest.c. - Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h - Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt - -Version 1.4.0beta53 [April 1, 2009] - Removed some remaining MMX macros from pngpriv.h - Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) - -Version 1.4.0beta54 [April 13, 2009] - Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow - application code writers to bypass the check for multiple inclusion - of setjmp.h when they know that it is safe to ignore the situation. - Eliminated internal use of setjmp() in pngread.c and pngwrite.c - Reordered ancillary chunks in pngtest.png to be the same as what - pngtest now produces, and made some cosmetic changes to pngtest output. - Eliminated deprecated png_read_init_3() and png_write_init_3() functions. - -Version 1.4.0beta55 [April 15, 2009] - Simplified error handling in pngread.c and pngwrite.c by putting - the new png_read_cleanup() and png_write_cleanup() functions inline. - -Version 1.4.0beta56 [April 25, 2009] - Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress - "shadowed declaration" warning from gcc-4.3.3. - Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration" - warning about a global "gamma" variable in math.h on some platforms. - -Version 1.4.0beta57 [May 2, 2009] - Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 - but was never defined (again). - Rebuilt configure scripts with autoconf-2.63 instead of 2.62 - Removed pngprefs.h and MMX from makefiles - -Version 1.4.0beta58 [May 14, 2009] - Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced - in beta57). - Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) - -Version 1.4.0beta59 [May 15, 2009] - Reformated sources in libpng style (3-space intentation, comment format) - Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) - Added sections about the git repository and our coding style to the - documentation - Relocated misplaced #endif in pngwrite.c, sCAL chunk handler. - -Version 1.4.0beta60 [May 19, 2009] - Conditionally compile png_read_finish_row() which is not used by - progressive readers. - Added contrib/pngminim/preader to demonstrate building minimal progressive - decoder, based on contrib/gregbook with embedded libpng and zlib. - -Version 1.4.0beta61 [May 20, 2009] - In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there - is only one makefile in those directories, and revised the README files - accordingly. - More reformatting of comments, mostly to capitalize sentences. - -Version 1.4.0beta62 [June 2, 2009] - Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h - and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h - Reformatted several remaining "else statement" into two lines. - Added a section to the libpng documentation about using png_get_io_ptr() - in configure scripts to detect the presence of libpng. - -Version 1.4.0beta63 [June 15, 2009] - Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() - multiple times and to specify the sample order in the tRNS chunk, - because the ISO PNG specification has a typo in the tRNS table. - Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to - PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism - available for ignoring known chunks even when not saving unknown chunks. - Adopted preference for consistent use of "#ifdef" and "#ifndef" versus - "#if defined()" and "if !defined()" where possible. - -Version 1.4.0beta64 [June 24, 2009] - Eliminated PNG_LEGACY_SUPPORTED code. - Moved the various unknown chunk macro definitions outside of the - PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. - -Version 1.4.0beta65 [June 26, 2009] - Added a reference to the libpng license in each file. - -Version 1.4.0beta66 [June 27, 2009] - Refer to the libpng license instead of the libpng license in each file. - -Version 1.4.0beta67 [July 6, 2009] - Relocated INVERT_ALPHA within png_read_png() and png_write_png(). - Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB. - Added an "xcode" project to the projects directory (Alam Arias). - -Version 1.4.0beta68 [July 19, 2009] - Avoid some tests in filter selection in pngwutil.c - -Version 1.4.0beta69 [July 25, 2009] - Simplified the new filter-selection test. This runs faster in the - common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases. - Removed extraneous declaration from the new call to png_read_gray_to_rgb() - (bug introduced in libpng-1.4.0beta67). - Fixed up xcode project (Alam Arias) - Added a prototype for png_64bit_product() in png.c - -Version 1.4.0beta70 [July 27, 2009] - Avoid a possible NULL dereference in debug build, in png_set_text_2(). - (bug introduced in libpng-0.95, discovered by Evan Rouault) - -Version 1.4.0beta71 [July 29, 2009] - Rebuilt configure scripts with autoconf-2.64. - -Version 1.4.0beta72 [August 1, 2009] - Replaced *.tar.lzma with *.tar.xz in distribution. Get the xz codec - from . - -Version 1.4.0beta73 [August 1, 2009] - Reject attempt to write iCCP chunk with negative embedded profile length - (JD Chen) (CVE-2009-5063). - -Version 1.4.0beta74 [August 8, 2009] - Changed png_ptr and info_ptr member "trans" to "trans_alpha". - -Version 1.4.0beta75 [August 21, 2009] - Removed an extra png_debug() recently added to png_write_find_filter(). - Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. - -Version 1.4.0beta76 [August 22, 2009] - Moved an incorrectly located test in png_read_row() in pngread.c - -Version 1.4.0beta77 [August 27, 2009] - Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt, - and the "noconfig" files from the distribution. - Moved CMakeLists.txt from scripts into the main libpng directory. - Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) - -Version 1.4.0beta78 [August 31, 2009] - Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h - Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros. - Use png_malloc plus a loop instead of png_calloc() to initialize - row_pointers in png_read_png(). - -Version 1.4.0beta79 [September 1, 2009] - Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. - Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). - -Version 1.4.0beta80 [September 17, 2009] - Removed scripts/libpng.icc - Changed typecast of filler from png_byte to png_uint_16 in png_set_filler(). - (Dennis Gustafsson) - Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ") - -Version 1.4.0beta81 [September 23, 2009] - Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h - Expanded TAB characters in pngrtran.c - Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid - compiler complaints about doubly declaring things "const". - Changed all "#if [!]defined(X)" to "if[n]def X" where possible. - Eliminated unused png_ptr->row_buf_size - -Version 1.4.0beta82 [September 25, 2009] - Moved redundant IHDR checking into new png_check_IHDR() in png.c - and report all errors found in the IHDR data. - Eliminated useless call to png_check_cHRM() from pngset.c - -Version 1.4.0beta83 [September 25, 2009] - Revised png_check_IHDR() to eliminate bogus complaint about filter_type. - -Version 1.4.0beta84 [September 30, 2009] - Fixed some inconsistent indentation in pngconf.h - Revised png_check_IHDR() to add a test for width variable less than 32-bit. - -Version 1.4.0beta85 [October 1, 2009] - Revised png_check_IHDR() again, to check info_ptr members instead of - the contents of the returned parameters. - -Version 1.4.0beta86 [October 9, 2009] - Updated the "xcode" project (Alam Arias). - Eliminated a shadowed declaration of "pp" in png_handle_sPLT(). - -Version 1.4.0rc01 [October 19, 2009] - Trivial cosmetic changes. - -Version 1.4.0beta87 [October 30, 2009] - Moved version 1.4.0 back into beta. - -Version 1.4.0beta88 [October 30, 2009] - Revised libpng*.txt section about differences between 1.2.x and 1.4.0 - because most of the new features have now been ported back to 1.2.41 - -Version 1.4.0beta89 [November 1, 2009] - More bugfixes and improvements to CMakeLists.txt (Philip Lowman) - Removed a harmless extra png_set_invert_alpha() from pngwrite.c - Apply png_user_chunk_cache_max within png_decompress_chunk(). - Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. - -Version 1.4.0beta90 [November 2, 2009] - Removed all remaining WIN32_WCE #ifdefs except those involving the - time.h "tm" structure - -Version 1.4.0beta91 [November 3, 2009] - Updated scripts/pngw32.def and projects/wince/png32ce.def - Copied projects/wince/png32ce.def to the scripts directory. - Added scripts/makefile.wce - Patched ltmain.sh for wince support. - Added PNG_CONVERT_tIME_SUPPORTED macro. - -Version 1.4.0beta92 [November 4, 2009] - Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED - Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED - Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead - of differences from 1.2.41 to 1.4.0) - -Version 1.4.0beta93 [November 7, 2009] - Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and - PNG_ALLOCATED macros to detect deprecated direct access to the - png_struct or info_struct members and other deprecated usage in - applications (John Bowler). - Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS, - to prevent warnings about direct access to png structs by libpng - functions while building libpng. They need to be tested, especially - those using compilers other than gcc. - Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG". - They should work but still need to be updated to remove - references to pnggccrd.c or pngvcrd.c and ASM building. - Added README.txt to the beos, cbuilder5, netware, and xcode projects warning - that they need to be updated, to remove references to pnggccrd.c and - pngvcrd.c and to depend on pngpriv.h - Removed three direct references to read_info_ptr members in pngtest.c - that were detected by the new PNG_DEPSTRUCT macro. - Moved the png_debug macro definitions and the png_read_destroy(), - png_write_destroy() and png_far_to_near() prototypes from png.h - to pngpriv.h (John Bowler) - Moved the synopsis lines for png_read_destroy(), png_write_destroy() - png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3. - -Version 1.4.0beta94 [November 9, 2009] - Removed the obsolete, unused pnggccrd.c and pngvcrd.c files. - Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions. - Removed dependency of pngtest.o on pngpriv.h in the makefiles. - Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined. - -Version 1.4.0beta95 [November 10, 2009] - Changed png_check_sig() to !png_sig_cmp() in contrib programs. - Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile - Changed png_check_sig() to !png_sig_cmp() in contrib programs. - Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c - Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c - Added dependency on pngpriv.h in contrib/pngminim/*/makefile - -Version 1.4.0beta96 [November 12, 2009] - Renamed scripts/makefile.wce to scripts/makefile.cegcc - Revised Makefile.am to use libpng.sys while building libpng.so - so that only PNG_EXPORT functions are exported. - Removed the deprecated png_check_sig() function/macro. - Removed recently removed function names from scripts/*.def - Revised pngtest.png to put chunks in the same order written by pngtest - (evidently the same change made in libpng-1.0beta54 was lost). - Added PNG_PRIVATE macro definition in pngconf.h for possible future use. - -Version 1.4.0beta97 [November 13, 2009] - Restored pngtest.png to the libpng-1.4.0beta7 version. - Removed projects/beos and netware.txt; no one seems to be supporting them. - Revised Makefile.in - -Version 1.4.0beta98 [November 13, 2009] - Added the "xcode" project to zip distributions, - Fixed a typo in scripts/pngwin.def introduced in beta97. - -Version 1.4.0beta99 [November 14, 2009] - Moved libpng-config.in and libpng.pc-configure.in out of the scripts - directory, to libpng-config.in and libpng-pc.in, respectively, and - modified Makefile.am and configure.ac accordingly. Now "configure" - needs nothing from the "scripts" directory. - Avoid redefining PNG_CONST in pngconf.h - -Version 1.4.0beta100 [November 14, 2009] - Removed ASM builds from projects/visualc6 and projects/visualc71 - Removed scripts/makefile.nommx and makefile.vcawin32 - Revised CMakeLists.txt to account for new location of libpng-config.in - and libpng-pc.in - Updated INSTALL to reflect removal and relocation of files. - -Version 1.4.0beta101 [November 14, 2009] - Restored the binary files (*.jpg, *.png, some project files) that were - accidentally deleted from the zip and 7z distributions when the xcode - project was added. - -Version 1.4.0beta102 [November 18, 2009] - Added libpng-config.in and libpng-pc.in to the zip and 7z distributions. - Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100. - Moved descriptions of makefiles and other scripts out of INSTALL into - scripts/README.txt - Updated the copyright year in scripts/pngwin.rc from 2006 to 2009. - -Version 1.4.0beta103 [November 21, 2009] - Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt - Align row_buf on 16-byte boundary in memory. - Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call - to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 - changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone - needs this feature. - Make the 'png_jmpbuf' macro expand to a call that records the correct - longjmp function as well as returning a pointer to the setjmp - jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. - (John Bowler) - -Version 1.4.0beta104 [November 22, 2009] - Removed png_longjmp_ptr from scripts/*.def and libpng.3 - Rebuilt configure scripts with autoconf-2.65 - -Version 1.4.0beta105 [November 25, 2009] - Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535() - to accomplish alpha premultiplication when - PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined. - Changed "/255" to "/255.0" in background calculations to make it clear - that the 255 is used as a double. - -Version 1.4.0beta106 [November 27, 2009] - Removed premultiplied alpha feature. - -Version 1.4.0beta107 [December 4, 2009] - Updated README - Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files. - Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects. - Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco - to put png.h and pngconf.h in $prefix/include, like the other scripts, - instead of in $prefix/include/libpng. Also revised makefile.sco - to put them in $prefix/include/libpng15 instead of in - $prefix/include/libpng/libpng15. - -Version 1.4.0beta108 [December 11, 2009] - Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile - Relocated png_do_chop() to its original position in pngrtran.c; the - change in version 1.2.41beta08 caused transparency to be handled wrong - in some 16-bit datastreams (Yusaku Sugai). - -Version 1.4.0beta109 [December 13, 2009] - Added "bit_depth" parameter to the private png_build_gamma_table() function. - Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the - PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit - tables. - -Version 1.4.0rc02 [December 20, 2009] - Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c - -Version 1.4.0rc03 [December 22, 2009] - Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt - (revising the change in 1.4.0beta99) - -Version 1.4.0rc04 [December 25, 2009] - Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED - in pngset.c to be consistent with other changes in version 1.2.38. - -Version 1.4.0rc05 [December 25, 2009] - Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and - Makefile.in to be consistent with changes in libpng-1.4.0rc03 - -Version 1.4.0rc06 [December 29, 2009] - Reverted the gamma_table changes from libpng-1.4.0beta109. - Fixed some indentation errors. - -Version 1.4.0rc07 [January 1, 2010] - Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences. - Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c - Update copyright year to 2010. - -Version 1.4.0rc08 [January 2, 2010] - Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr - in pngtest.c - -Version 1.4.0 [January 3, 2010] - No changes. - -Version 1.4.1beta01 [January 8, 2010] - Updated CMakeLists.txt for consistent indentation and to avoid an - unclosed if-statement warning (Philip Lowman). - Revised Makefile.am and Makefile.in to remove references to Y2KINFO, - KNOWNBUG, and libpng.la (Robert Schwebel). - Revised the makefiles to install the same files and symbolic - links as configure, except for libpng.la and libpng14.la. - Make png_set|get_compression_buffer_size() available even when - PNG_WRITE_SUPPORTED is not enabled. - Revised Makefile.am and Makefile.in to simplify their maintenance. - Revised scripts/makefile.linux to install a link to libpng14.so.14.1 - -Version 1.4.1beta02 [January 9, 2010] - Revised the rest of the makefiles to install a link to libpng14.so.14.1 - -Version 1.4.1beta03 [January 10, 2010] - Removed png_set_premultiply_alpha() from scripts/*.def - -Version 1.4.1rc01 [January 16, 2010] - No changes. - -Version 1.4.1beta04 [January 23, 2010] - Revised png_decompress_chunk() to improve speed and memory usage when - decoding large chunks. - Added png_set|get_chunk_malloc_max() functions. - -Version 1.4.1beta05 [January 26, 2010] - Relocated "int k" declaration in pngtest.c to minimize its scope. - -Version 1.4.1beta06 [January 28, 2010] - Revised png_decompress_chunk() to use a two-pass method suggested by - John Bowler. - -Version 1.4.1beta07 [February 6, 2010] - Folded some long lines in the source files. - Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, - and a PNG_USER_LIMITS_SUPPORTED flag. - Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as - png_ptr->png_user_chunk_malloc_max. - Revised png_push_save_buffer() to do fewer but larger png_malloc() calls. - -Version 1.4.1beta08 [February 6, 2010] - Minor cleanup and updating of dates and copyright year. - -Version 1.5.0beta01 [February 7, 2010] - Moved declaration of png_struct into private pngstruct.h and png_info - into pnginfo.h - -Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010] - Reverted to original png_push_save_buffer() code. - -Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010] - Return allocated "old_buffer" in png_push_save_buffer() before - calling png_error(), to avoid a potential memory leak. - Updated configure script to use SO number 15. - -Version 1.5.0beta04 [February 9, 2010] - Removed malformed "incomplete struct declaration" of png_info from png.h - -Version 1.5.0beta05 [February 12, 2010] - Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the - linewrapping that it entailed. - Revised comments in pngstruct.h and pnginfo.h and added pointers to - the libpng license. - Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES - Removed the cbuilder5 project, which has not been updated to 1.4.0. - -Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010] - Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke - Nishikawa) - -Version 1.5.0beta07 [omitted] - -Version 1.5.0beta08 [February 19, 2010] - Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED - wherever png_snprintf() is used to construct error and warning messages. - Noted in scripts/makefile.mingw that it expects to be run under MSYS. - Removed obsolete unused MMX-querying support from contrib/gregbook - Added exported png_longjmp() function. - Removed the AIX redefinition of jmpbuf in png.h - Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt - when building on AIX. - -Version 1.5.0beta09 [February 19, 2010] - Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt. - Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h - -Version 1.5.0beta10 [February 25, 2010] - Removed unused gzio.c from contrib/pngminim gather and makefile scripts - Removed replacement error handlers from contrib/gregbook. Because of - the new png_longjmp() function they are no longer needed. - -Version 1.5.0beta11 [March 6, 2010] - Removed checking for already-included setjmp.h from pngconf.h - Fixed inconsistent indentations and made numerous cosmetic changes. - Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5 - -Version 1.5.0beta12 [March 9, 2010] - Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from - the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES" - and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler). - Created new pngdebug.h and moved debug definitions there. - -Version 1.5.0beta13 [March 10, 2010] - Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice. - Revise the "#ifdef" blocks in png_inflate() so it will compile when neither - PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED - is defined. - Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3 - Moved the 'config.h' support from pngconf.h to pngpriv.h - Removed PNGAPI from the png_longjmp_ptr typedef. - Eliminated dependence of pngtest.c on the private pngdebug.h file. - Make all png_debug macros into *unterminated* statements or - expressions (i.e. a trailing ';' must always be added) and correct - the format statements in various png_debug messages. - -Version 1.5.0beta14 [March 14, 2010] - Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c - Revised Makefile.am to account for recent additions and replacements. - Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and - added ordinal numbers to the Windows DEF file and corrected the duplicated - ordinal numbers on CE symbols that are commented out. - Added back in export symbols that can be present in the Windows build but - are disabled by default. - PNG_EXPORT changed to include an 'ordinal' field for DEF file generation. - PNG_CALLBACK added to make callback definitions uniform. PNGAPI split - into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks), - and appropriate changes made to all files. Cygwin builds re-hinged to - allow procedure call standard changes and to remove the need for the DEF - file (fixes build on Cygwin). - Enabled 'attribute' warnings that are relevant to library APIs and callbacks. - Changed rules for generation of the various symbol files and added a new - rule for a DEF file (which is also added to the distribution). - Updated the symbol file generation to stop it adding spurious spaces - to EOL (coming from preprocessor macro expansion). Added a facility - to join tokens in the output and rewrite *.dfn to use this. - Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 - and removed scripts/makefile.cygwin. - Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. - Removed the include of sys/types.h - apparently unnecessary now on the - platforms on which it happened (all but Mac OS and RISC OS). - Moved the Mac OS test into pngpriv.h (the only place it is used.) - -Version 1.5.0beta15 [March 17, 2010] - Added symbols.chk target to Makefile.am to validate the symbols in png.h - against the new DEF file scripts/symbols.def. - Changed the default DEF file back to pngwin.def. - Removed makefile.mingw. - Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN - -Version 1.5.0beta16 [April 1, 2010] - Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that - fields are initialized in all configurations. The READ/WRITE - macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as - before to disable code to actually read or write iTXt chunks - and iTXt_SUPPORTED can be used to detect presence of either - read or write support (but it is probably better to check for - the one actually required - read or write.) - Combined multiple png_warning() calls for a single error. - Restored the macro definition of png_check_sig(). - -Version 1.5.0beta17 [April 17, 2010] - Added some "(long)" typecasts to printf calls in png_handle_cHRM(). - Documented the fact that png_set_dither() was disabled since libpng-1.4.0. - Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect - more accurately what it actually does. At the same time, renamed - the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to - PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. - Added some "(long)" typecasts to printf calls in png_handle_cHRM(). - Freeze build-time only configuration in the build. - In all prior versions of libpng most configuration options - controlled by compiler #defines had to be repeated by the - application code that used libpng. This patch changes this - so that compilation options that can only be changed at build - time are frozen in the build. Options that are compiler - dependent (and those that are system dependent) are evaluated - each time - pngconf.h holds these. Options that can be changed - per-file in the application are in png.h. Frozen options are - in the new installed header file pnglibconf.h (John Bowler) - Removed the xcode project because it has not been updated to work - with libpng-1.5.0. - Removed the ability to include optional pngusr.h - -Version 1.5.0beta18 [April 17, 2010] - Restored the ability to include optional pngusr.h - Moved replacements for png_error() and png_warning() from the - contrib/pngminim project to pngerror.c, for use when warnings or - errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid - storing unneeded error/warning text. - Updated contrib/pngminim project to work with the new pnglibconf.h - Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space. - -Version 1.5.0beta19 [April 24, 2010] - Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the functions - to read and write ints to be disabled independently of PNG_USE_READ_MACROS, - which allows libpng to be built with the functions even though the default - is to use the macros - this allows applications to choose at app build - time whether or not to use macros (previously impossible because the - functions weren't in the default build.) - Changed Windows calling convention back to __cdecl for API functions. - For Windows/x86 platforms only: - __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses - __cdecl throughout (both API functions and callbacks) on Windows/x86 - platforms. - Replaced visualc6 and visualc71 projects with new vstudio project - Relaxed the overly-restrictive permissions of some files. - -Version 1.5.0beta20 [April 24, 2010] - Relaxed more overly-restrictive permissions of some files. - -Version 1.5.0beta21 [April 27, 2010] - Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new - vstudio project files, and some trivial editing of some files in the - scripts directory. - Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in - contrib/pngminim/decoder/pngusr.h to make a smaller decoder application. - -Version 1.5.0beta22 [April 28, 2010] - Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS - because it has a macro equivalent. - Improved the options.awk script; added an "everything off" option. - Revised contrib/pngminim to use the "everything off" option in pngusr.dfa. - -Version 1.5.0beta23 [April 29, 2010] - Corrected PNG_REMOVED macro to take five arguments. - The macro was documented with two arguments (name,ordinal), however - the symbol checking .dfn files assumed five arguments. The five - argument form seems more useful so it is changed to that. - Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED - in gregbook/readpng2.c - Corrected protection of png_get_user_transform_ptr. The API declaration in - png.h is removed if both READ and WRITE USER_TRANSFORM are turned off - but was left defined in pngtrans.c - Added logunsupported=1 to cause pnglibconf.h to document disabled options. - This makes the installed pnglibconf.h more readable but causes no - other change. The intention is that users of libpng will find it - easier to understand if an API they need is missing. - Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined. - Removed dummy_inflate.c from contrib/pngminim/encoder - Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile. - -Version 1.5.0beta24 [May 7, 2010] - Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the - offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf. - Added more blank lines for readability. - -Version 1.5.0beta25 [June 18, 2010] - In pngpread.c: png_push_have_row() add check for new_row > height - Removed the now-redundant check for out-of-bounds new_row from example.c - -Version 1.5.0beta26 [June 18, 2010] - In pngpread.c: png_push_process_row() add check for too many rows. - -Version 1.5.0beta27 [June 18, 2010] - Removed the check added in beta25 as it is now redundant. - -Version 1.5.0beta28 [June 20, 2010] - Rewrote png_process_IDAT_data to consistently treat extra data as warnings - and handle end conditions more cleanly. - Removed the new (beta26) check in png_push_process_row(). - -Version 1.5.0beta29 [June 21, 2010] - Revised scripts/options.awk to work on Sunos (but still doesn't work) - Added comment to options.awk and contrib/pngminim/*/makefile to try nawk. - -Version 1.5.0beta30 [June 22, 2010] - Stop memory leak when reading a malformed sCAL chunk. - -Version 1.5.0beta31 [June 26, 2010] - Revised pngpread.c patch of beta28 to avoid an endless loop. - Removed some trailing blanks. - -Version 1.5.0beta32 [June 26, 2010] - Removed leftover scripts/options.patch and scripts/options.rej - -Version 1.5.0beta33 [July 6, 3010] - Made FIXED and FLOATING options consistent in the APIs they enable and - disable. Corrected scripts/options.awk to handle both command line - options and options specified in the .dfa files. - Changed char *msg to PNG_CONST char *msg in pngrutil.c - Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or - floating point APIs, but not both. - Reversed patch to remove error handler when the jmp_buf is stored in the - main program structure, not the png_struct. - The error handler is needed because the default handler in libpng will - always use the jmp_buf in the library control structure; this is never - set. The gregbook code is a useful example because, even though it - uses setjmp/longjmp, it shows how error handling can be implemented - using control mechanisms not directly supported by libpng. The - technique will work correctly with mechanisms such as Microsoft - Structure Exceptions or C++ exceptions (compiler willing - note that gcc - does not by default support interworking of C and C++ error handling.) - Reverted changes to call png_longjmp in contrib/gregbook where it is not - appropriate. If mainprog->jmpbuf is used by setjmp, then png_longjmp - cannot be used. - Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans) - Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {') - -Version 1.5.0beta34 [July 12, 2010] - Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h - -Version 1.5.0beta35 [July 24, 2010] - Removed some newly-added TAB characters. - Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2 - Moved the definition of png_snprintf() outside of the enclosing - #ifdef blocks in pngconf.h - -Version 1.5.0beta36 [July 29, 2010] - Patches by John Bowler: - Fixed point APIs are now supported throughout (no missing APIs). - Internal fixed point arithmetic support exists for all internal floating - point operations. - sCAL validates the floating point strings it is passed. - Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2 - Two new APIs exist to get the number of passes without turning on the - PNG_INTERLACE transform and to get the number of rows in the current - pass. - A new test program, pngvalid.c, validates the gamma code. - Errors in the 16-bit gamma correction (overflows) have been corrected. - cHRM chunk testing is done consistently (previously the floating point - API bypassed it, because the test really didn't work on FP, now the test - is performed on the actual values to be stored in the PNG file so it - works in the FP case too.) - Most floating point APIs now simply call the fixed point APIs after - converting the values to the fixed point form used in the PNG file. - The standard headers no longer include zlib.h, which is currently only - required for pngstruct.h and can therefore be internal. - Revised png_get_int_32 to undo the PNG two's complement representation of - negative numbers. - -Version 1.5.0beta37 [July 30, 2010] - Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid - a compiler warning. - Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png - -Version 1.5.0beta38 [July 31, 2010] - Implemented remaining "_fixed" functions. - Corrected a number of recently introduced warnings mostly resulting from - safe but uncast assignments to shorter integers. Also added a zlib - VStudio release library project because the latest zlib Official Windows - build does not include such a thing. - Revised png_get_int_16() to be similar to png_get_int_32(). - Restored projects/visualc71. - -Version 1.5.0beta39 [August 2, 2010] - VisualC/GCC warning fixes, VisualC build fixes - The changes include support for function attributes in VC in addition to - those already present in GCC - necessary because without these some - warnings are unavoidable. Fixes include signed/unsigned fixes in - pngvalid and checks with gcc -Wall -Wextra -Wunused. - VC requires function attributes on function definitions as well as - declarations, PNG_FUNCTION has been added to enable this and the - relevant function definitions changed. - -Version 1.5.0beta40 [August 6, 2010] - Correct use of _WINDOWS_ in pngconf.h - Removed png_mem_ #defines; they are no longer used. - Added the sRGB chunk to pngtest.png - -Version 1.5.0beta41 [August 11, 2010] - Added the cHRM chunk to pngtest.png - Don't try to use version-script with cygwin/mingw. - Revised contrib/gregbook to work under cygwin/mingw. - -Version 1.5.0beta42 [August 18, 2010] - Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov) - Made all API functions that have const arguments and constant string - literal pointers declare them (John Bowler). - -Version 1.5.0beta43 [August 20, 2010] - Removed spurious tabs, shorten long lines (no source change) - Also added scripts/chkfmt to validate the format of all the files that can - reasonably be validated (it is suggested to run "make distclean" before - checking, because some machine generated files have long lines.) - Reformatted the CHANGES file to be more consistent throughout. - Made changes to address various issues identified by GCC, mostly - signed/unsigned and shortening problems on assignment but also a few - difficult to optimize (for GCC) loops. - Fixed non-GCC fixed point builds. In png.c a declaration was misplaced - in an earlier update. Fixed to declare the auto variables at the head. - Use cexcept.h in pngvalid.c. - -Version 1.5.0beta44 [August 24, 2010] - Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for - installing libpng in /usr/lib64 (Funda Wang). - Revised CMakeLists.txt to put the man pages in share/man/man* not man/man* - Revised CMakeLists.txt to make symlinks instead of copies when installing. - Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman) - Implemented memory checks within pngvalid - Reformatted/rearranged pngvalid.c to assist use of progressive reader. - Check interlaced images in pngvalid - Clarified pngusr.h comments in pnglibconf.dfa - Simplified the pngvalid error-handling code now that cexcept.h is in place. - Implemented progressive reader in pngvalid.c for standard tests - Implemented progressive read in pngvalid.c gamma tests - Turn on progressive reader in pngvalid.c by default and tidy code. - -Version 1.5.0beta45 [August 26, 2010] - Added an explicit make step to projects/vstudio for pnglibconf.h - Also corrected zlib.vcxproj into which Visual Studio had introduced - what it calls an "authoring error". The change to make pnglibconf.h - simply copies the file; in the future it may actually generate the - file from scripts/pnglibconf.dfa as the other build systems do. - Changed pngvalid to work when floating point APIs are disabled - Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt - Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX - in pngpriv.h in case the user neglected to define them in their pngusr.h - -Version 1.5.0beta46 [August 28, 2010] - Added new private header files to libpng_sources in CMakeLists.txt - Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options. - Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project. - -Version 1.5.0beta47 [September 11, 2010] - Fixed a number of problems with 64-bit compilation reported by Visual - Studio 2010 (John Bowler). - -Version 1.5.0beta48 [October 4, 2010] - Updated CMakeLists.txt (Philip Lowman). - Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER, - $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE - Fixed problem with symbols creation in Makefile.am which was assuming that - all versions of ccp write to standard output by default (Martin Banky). The - bug was introduced in libpng-1.2.9beta5. - Removed unused mkinstalldirs. - -Version 1.5.0beta49 [October 8, 2010] - Undid Makefile.am revision of 1.5.0beta48. - -Version 1.5.0beta50 [October 14, 2010] - Revised Makefile.in to account for mkinstalldirs being removed. - Added some "(unsigned long)" typecasts in printf statements in pngvalid.c. - Suppressed a compiler warning in png_handle_sPLT(). - Check for out-of-range text compression mode in png_set_text(). - -Version 1.5.0beta51 [October 15, 2010] - Changed embedded dates to "(PENDING RELEASE) in beta releases (and future - rc releases) to minimize the difference between releases. - -Version 1.5.0beta52 [October 16, 2010] - Restored some of the embedded dates (in png.h, png.c, documentation, etc.) - -Version 1.5.0beta53 [October 18, 2010] - Updated INSTALL to mention using "make maintainer-clean" and to remove - obsolete statement about a custom ltmain.sh - Disabled "color-tests" by default in Makefile.am so it will work with - automake versions earlier than 1.11.1 - Use document name "libpng-manual.txt" instead of "libpng-.txt" - to simplify version differences. - Removed obsolete remarks about setjmp handling from INSTALL. - Revised and renamed the typedef in png.h and png.c that was designed - to catch library and header mismatch. - -Version 1.5.0beta54 [November 10, 2010] - Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks. - Used a consistent structure for the pngget.c functions. - -Version 1.5.0beta55 [November 21, 2010] - Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin) - Moved reading of file signature into png_read_sig (Cosmin) - Fixed atomicity of chunk header serialization (Cosmin) - Added test for io_state in pngtest.c (Cosmin) - Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts. - Changes to remove gcc warnings (John Bowler) - Certain optional gcc warning flags resulted in warnings in libpng code. - With these changes only -Wconversion and -Wcast-qual cannot be turned on. - Changes are trivial rearrangements of code. -Wconversion is not possible - for pngrutil.c (because of the widespread use of += et al on variables - smaller than (int) or (unsigned int)) and -Wcast-qual is not possible - with pngwio.c and pngwutil.c because the 'write' callback and zlib - compression both fail to declare their input buffers with 'const'. - -Version 1.5.0beta56 [December 7, 2010] - Added the private PNG_UNUSED() macro definition in pngpriv.h. - Added some commentary about PNG_EXPORT in png.h and pngconf.h - Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the - objective of simplifying and improving the cosmetic appearance of png.h. - Fixed some incorrect "=" macro names in pnglibconf.dfa - Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt - -Version 1.5.0beta57 [December 9, 2010] - Documented the pngvalid gamma error summary with additional comments and - print statements. - Improved missing symbol handling in checksym.awk; symbols missing in both - the old and new files can now be optionally ignored, treated as errors - or warnings. - Removed references to pngvcrd.c and pnggccrd.c from the vstudio project. - Updated "libpng14" to "libpng15" in the visualc71 project. - Enabled the strip16 tests in pngvalid.` - Don't display test results (except PASS/FAIL) when running "make test". - Instead put them in pngtest-log.txt - Added "--with-zprefix=" to configure.ac - Updated the prebuilt configuration files to autoconf version 2.68 - -Version 1.5.0beta58 [December 19, 2010] - Fixed interlace image handling and add test cases (John Bowler) - Fixed the clean rule in Makefile.am to remove pngtest-log.txt - Made minor changes to work around warnings in gcc 3.4 - -Version 1.5.0rc01 [December 27, 2010] - No changes. - -Version 1.5.0rc02 [December 27, 2010] - Eliminated references to the scripts/*.def files in project/visualc71. - -Version 1.5.0rc03 [December 28, 2010] - Eliminated scripts/*.def and revised Makefile.am accordingly - -Version 1.5.0rc04 [December 29, 2010] - Fixed bug in background transformation handling in pngrtran.c (it was - looking for the flag in png_ptr->transformations instead of in - png_ptr->flags) (David Raymond). - -Version 1.5.0rc05 [December 31, 2010] - Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin) - -Version 1.5.0rc06 [January 4, 2011] - Changed the new configure option "zprefix=string" to "zlib-prefix=string" - -Version 1.5.0rc07 [January 4, 2011] - Updated copyright year. - -Version 1.5.0 [January 6, 2011] - No changes. - -version 1.5.1beta01 [January 8, 2011] - Added description of png_set_crc_action() to the manual. - Added a note in the manual that the type of the iCCP profile was changed - from png_charpp to png_bytepp in png_get_iCCP(). This change happened - in version 1.5.0beta36 but is not noted in the CHANGES. Similarly, - it was changed from png_charpp to png_const_bytepp in png_set_iCCP(). - Ensure that png_rgb_to_gray ignores palette mapped images, if libpng - internally happens to call it with one, and fixed a failure to handle - palette mapped images correctly. This fixes CVE-2690. - -Version 1.5.1beta02 [January 14, 2011] - Fixed a bug in handling of interlaced images (bero at arklinux.org). - Updated CMakeLists.txt (Clifford Yapp) - -Version 1.5.1beta03 [January 14, 2011] - Fixed typecasting of some png_debug() statements (Cosmin) - -Version 1.5.1beta04 [January 16, 2011] - Updated documentation of png_set|get_tRNS() (Thomas Klausner). - Mentioned in the documentation that applications must #include "zlib.h" - if they need access to anything in zlib.h, and that a number of - macros such as png_memset() are no longer accessible by applications. - Corrected pngvalid gamma test "sample" function to access all of the color - samples of each pixel, instead of sampling the red channel three times. - Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow" - warnings, and (mistakenly) changed png_exp() to exp(). - -Version 1.5.1beta05 [January 16, 2011] - Changed variable names png_index, png_div, png_exp, and png_gamma to - char_index, divisor, exp_b10, and gamma_val, respectively, and - changed exp() back to png_exp(). - -Version 1.5.1beta06 [January 20, 2011] - Prevent png_push_crc_skip() from hanging while reading an unknown chunk - or an over-large compressed zTXt chunk with the progressive reader. - Eliminated more GCC "shadow" warnings. - Revised png_fixed() in png.c to avoid compiler warning about reaching the - end without returning anything. - -Version 1.5.1beta07 [January 22, 2011] - In the manual, describe the png_get_IHDR() arguments in the correct order. - Added const_png_structp and const_png_infop types, and used them in - prototypes for most png_get_*() functions. - -Version 1.5.1beta08 [January 23, 2011] - Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name() - Added synopses for the IO_STATE functions and other missing synopses - to the manual. Removed the synopses from libpngpf.3 because they - were out of date and no longer useful. Better information can be - obtained by reading the prototypes and comments in pngpriv.h - Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build - Added a make macro DFNCPP that is a CPP that will accept the tokens in - a .dfn file and adds configure stuff to test for such a CPP. ./configure - should fail if one is not available. - Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace. - Added png_get_current_row_number and png_get_current_pass_number for the - benefit of the user transform callback. - Added png_process_data_pause and png_process_data_skip for the benefit of - progressive readers that need to stop data processing or want to optimize - skipping of unread data (e.g., if the reader marks a chunk to be skipped.) - -Version 1.5.1beta09 [January 24, 2011] - Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error. - pngvalid contains tests of transforms, which tests are currently disabled - because they are incompletely tested. gray_to_rgb was failing to expand - the bit depth for smaller bit depth images; this seems to be a long - standing error and resulted, apparently, in invalid output - (CVE-2011-0408, CERT VU#643140). The documentation did not accurately - describe what libpng really does when converting RGB to gray. - -Version 1.5.1beta10 [January 27, 2010] - Fixed incorrect examples of callback prototypes in the manual, that were - introduced in libpng-1.0.0. - In addition the order of the png_get_uint macros with respect to the - relevant function definitions has been reversed. This helps the - preprocessing of the symbol files be more robust. Furthermore, the - symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when - the library may actually be built with PNG_USE_READ_MACROS; this stops - the read macros interfering with the symbol file format. - Made the manual, synopses, and function prototypes use the function - argument names file_gamma, int_file_gamma, and srgb_intent consistently. - -Version 1.5.1beta11 [January 28, 2011] - Changed PNG_UNUSED from "param=param;" to "{if(param){}}". - Corrected local variable type in new API png_process_data_skip() - The type was self-evidently incorrect but only causes problems on 64-bit - architectures. - Added transform tests to pngvalid and simplified the arguments. - -Version 1.5.1rc01 [January 29, 2011] - No changes. - -Version 1.5.1rc02 [January 31, 2011] - Added a request in the manual that applications do not use "png_" or - "PNG_" to begin any of their own symbols. - Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h - -Version 1.5.1 [February 3, 2011] - No changes. - -Version 1.5.2beta01 [February 13, 2011] - More -Wshadow fixes for older gcc compilers. Older gcc versions apparently - check formal parameters names in function declarations (as well as - definitions) to see if they match a name in the global namespace. - Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the - old VisualC++ preprocessor. - Turned on interlace handling in png_read_png(). - Fixed gcc pendantic warnings. - Handle longjmp in Cygwin. - Fixed png_get_current_row_number() in the interlaced case. - Cleaned up ALPHA flags and transformations. - Implemented expansion to 16 bits. - -Version 1.5.2beta02 [February 19, 2011] - Fixed mistake in the descriptions of user read_transform and write_transform - function prototypes in the manual. The row_info struct is png_row_infop. - Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior. - Corrected png_get_current_row_number documentation - Fixed the read/write row callback documentation. - This documents the current behavior, where the callback is called after - every row with information pertaining to the next row. - -Version 1.5.2beta03 [March 3, 2011] - Fixed scripts/makefile.vcwin32 - Updated contrib/pngsuite/README to add the word "modify". - Define PNG_ALLOCATED to blank when _MSC_VER<1300. - -Version 1.5.2rc01 [March 19, 2011] - Define remaining attributes to blank when MSC_VER<1300. - ifdef out mask arrays in pngread.c when interlacing is not supported. - -Version 1.5.2rc02 [March 22, 2011] - Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak - and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip" - from the makefiles. - Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail - to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) - -Version 1.5.2rc03 [March 24, 2011] - Don't include standard header files in png.h while building the symbol table, - to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro). - -Version 1.5.2 [March 31, 2011] - No changes. - -Version 1.5.3beta01 [April 1, 2011] - Re-initialize the zlib compressor before compressing non-IDAT chunks. - Added API functions (png_set_text_compression_level() and four others) to - set parameters for zlib compression of non-IDAT chunks. - -Version 1.5.3beta02 [April 3, 2011] - Updated scripts/symbols.def with new API functions. - Only compile the new zlib re-initializing code when text or iCCP is - supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro. - Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). - Optimize the zlib CMF byte in non-IDAT compressed chunks - -Version 1.5.3beta03 [April 16, 2011] - Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have - snprintf, and the "__STRICT_ANSI__" detects that condition more reliably - than __STDC__ (John Bowler). - Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells - the compiler that a user supplied callback (the error handler) does not - return, yet there is no guarantee in practice that the application code - will correctly implement the error handler because the compiler only - issues a warning if there is a mistake (John Bowler). - Removed the no-longer-used PNG_DEPSTRUCT macro. - Updated the zlib version to 1.2.5 in the VStudio project. - Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in - pngwutil.c (John Bowler). - Fixed bug with stripping the filler or alpha channel when writing, that - was introduced in libpng-1.5.2beta01 (bug report by Andrew Church). - -Version 1.5.3beta04 [April 27, 2011] - Updated pngtest.png with the new zlib CMF optimization. - Cleaned up conditional compilation code and of background/gamma handling - Internal changes only except a new option to avoid compiling the - png_build_grayscale_palette API (which is not used at all internally.) - The main change is to move the transform tests (READ_TRANSFORMS, - WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids - calls to spurious functions if all transforms are disabled and slightly - simplifies those functions. Pngvalid modified to handle this. - A minor change is to stop the strip_16 and expand_16 interfaces from - disabling each other; this allows the future alpha premultiplication - code to use 16-bit intermediate values while still producing 8-bit output. - png_do_background and png_do_gamma have been simplified to take a single - pointer to the png_struct rather than pointers to every item required - from the png_struct. This makes no practical difference to the internal - code. - A serious bug in the pngvalid internal routine 'standard_display_init' has - been fixed - this failed to initialize the red channel and accidentally - initialized the alpha channel twice. - Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to - avoid a possible clash with the png_jmpbuf macro on some platforms. - -Version 1.5.3beta05 [May 6, 2011] - Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the - correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and - pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs. - Removed png_snprintf and added formatted warning messages. This change adds - internal APIs to allow png_warning messages to have parameters without - requiring the host OS to implement snprintf. As a side effect the - dependency of the tIME-supporting RFC1132 code on stdio is removed and - PNG_NO_WARNINGS does actually work now. - Pass "" instead of '\0' to png_default_error() in png_err(). This mistake - was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691. - Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte - optimization configureable. - IDAT compression failed if preceded by a compressed text chunk (bug - introduced in libpng-1.5.3beta01-02). This was because the attempt to - reset the zlib stream in png_write_IDAT happened after the first IDAT - chunk had been deflated - much too late. In this change internal - functions were added to claim/release the z_stream and, hopefully, make - the code more robust. Also deflateEnd checking is added - previously - libpng would ignore an error at the end of the stream. - -Version 1.5.3beta06 [May 8, 2011] - Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt - Implemented premultiplied alpha support: png_set_alpha_mode API - -Version 1.5.3beta07 [May 11, 2011] - Added expand_16 support to the high level interface. - Added named value and 'flag' gamma support to png_set_gamma. Made a minor - change from the previous (unreleased) ABI/API to hide the exact value used - for Macs - it's not a good idea to embed this in the ABI! - Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT - from pngpriv.h to png.h because they must be visible to applications - that call png_set_unknown_chunks(). - Check for up->location !PNG_AFTER_IDAT when writing unknown chunks - before IDAT. - -Version 1.5.3beta08 [May 16, 2011] - Improved "pngvalid --speed" to exclude more of pngvalid from the time. - Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt - The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative - parameters are supplied by the caller), while in the absence of cHRM - sRGB/Rec 709 values are still used. This introduced a divide-by-zero - bug in png_handle_cHRM(). - The bKGD chunk no longer overwrites the background value set by - png_set_background(), allowing the latter to be used before the file - header is read. It never performed any useful function to override - the default anyway. - Added memory overwrite and palette image checks to pngvalid.c - Previously palette image code was poorly checked. Since the transformation - code has a special palette path in most cases this was a severe weakness. - Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When - expanding an indexed image, always expand to RGBA if transparency is - present. - -Version 1.5.3beta09 [May 17, 2011] - Reversed earlier 1.5.3 change of transformation order; move png_expand_16 - back where it was. The change doesn't work because it requires 16-bit - gamma tables when the code only generates 8-bit ones. This fails - silently; the libpng code just doesn't do any gamma correction. Moving - the tests back leaves the old, inaccurate, 8-bit gamma calculations, but - these are clearly better than none! - -Version 1.5.3beta10 [May 20, 2011] - - png_set_background() and png_expand_16() did not work together correctly. - This problem is present in 1.5.2; if png_set_background is called with - need_expand false and the matching 16 bit color libpng erroneously just - treats it as an 8-bit color because of where png_do_expand_16 is in the - transform list. This simple fix reduces the supplied colour to 8-bits, - so it gets smashed, but this is better than the current behavior. - Added tests for expand16, more fixes for palette image tests to pngvalid. - Corrects the code for palette image tests and disables attempts to - validate palette colors. - -Version 1.5.3rc01 [June 3, 2011] - No changes. - -Version 1.5.3rc02 [June 8, 2011] - Fixed uninitialized memory read in png_format_buffer() (Bug report by - Frank Busse, CVE-2011-2501, related to CVE-2004-0421). - -Version 1.5.3beta11 [June 11, 2011] - Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692. - Added sCAL to pngtest.png - Revised documentation about png_set_user_limits() to say that it also affects - png writing. - Revised handling of png_set_user_limits() so that it can increase the - limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only - reduce it. - Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is - wrong (high by one) 25% of the time. Dividing by 257 with rounding is - wrong in 128 out of 65536 cases. Getting the right answer all the time - without division is easy. - Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro. - Added projects/owatcom, an IDE project for OpenWatcom to replace - scripts/makefile.watcom. This project works with OpenWatcom 1.9. The - IDE autogenerates appropriate makefiles (libpng.mk) for batch processing. - The project is configurable, unlike the Visual Studio project, so long - as the developer has an awk. - Changed png_set_gAMA to limit the gamma value range so that the inverse - of the stored value cannot overflow the fixed point representation, - and changed other things OpenWatcom warns about. - Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows - pngvalid to build when ALPHA_MODE is not supported, which is required if - it is to build on libpng 1.4. - Removed string/memory macros that are no longer used and are not - necessarily fully supportable, particularly png_strncpy and png_snprintf. - Added log option to pngvalid.c and attempted to improve gamma messages. - -Version 1.5.3 [omitted] - People found the presence of a beta release following an rc release - to be confusing; therefore we bump the version to libpng-1.5.4beta01 - and there will be no libpng-1.5.3 release. - -Version 1.5.4beta01 [June 14, 2011] - Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - to get the same (inaccurate) output as libpng-1.5.2 and earlier. - Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE - outside of an unknown-chunk block in png.h because they are also - needed for other uses. - -Version 1.5.4beta02 [June 14, 2011] - Fixed and clarified LEGACY 16-to-8 scaling code. - Added png_set_chop_16() API, to match inaccurate results from previous - libpng versions. - Removed the ACCURATE and LEGACY options (they are no longer useable) - Use the old scaling method for background if png_set_chop_16() was - called. - Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED - -Version 1.5.4beta03 [June 15, 2011] - Fixed a problem in png_do_expand_palette() exposed by optimization in - 1.5.3beta06 - Also removed a spurious and confusing "trans" member ("trans") from png_info. - The palette expand optimization prevented expansion to an intermediate RGBA - form if tRNS was present but alpha was marked to be stripped; this exposed - a check for tRNS in png_do_expand_palette() which is inconsistent with the - code elsewhere in libpng. - Correction to the expand_16 code; removed extra instance of - png_set_scale_16_to_8 from pngpriv.h - -Version 1.5.4beta04 [June 16, 2011] - Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c - Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms. - Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is - not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. - Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 - -Version 1.5.4beta05 [June 16, 2011] - Renamed png_set_strip_16() to png_set_scale_16() and renamed - png_set_chop_16() to png_set_strip(16) in an attempt to minimize the - behavior changes between libpng14 and libpng15. - -Version 1.5.4beta06 [June 18, 2011] - Fixed new bug that was causing both strip_16 and scale_16 to be applied. - -Version 1.5.4beta07 [June 19, 2011] - Fixed pngvalid, simplified macros, added checking for 0 in sCAL. - The ACCURATE scale macro is no longer defined in 1.5 - call the - png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined - if the png_strip_16_to_8 API is present. png_check_fp_number now - maintains some state so that positive, negative and zero values are - identified. sCAL uses these to be strictly spec conformant. - -Version 1.5.4beta08 [June 23, 2011] - Fixed pngvalid if ACCURATE_SCALE is defined. - Updated scripts/pnglibconf.h.prebuilt. - -Version 1.5.4rc01 [June 30, 2011] - Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400. - -Version 1.5.4 [July 7, 2011] - No changes. - -Version 1.5.5beta01 [July 13, 2011] - Fixed some typos and made other minor changes in the manual. - Updated contrib/pngminus/makefile.std (Samuli Souminen) - -Version 1.5.5beta02 [July 14, 2011] - Revised Makefile.am and Makefile.in to look in the right directory for - pnglibconf.h.prebuilt - -Version 1.5.5beta03 [July 27, 2011] - Enabled compilation with g++ compiler. This compiler does not recognize - the file extension, so it always compiles with C++ rules. Made minor - changes to pngrutil.c to cast results where C++ expects it but C does not. - Minor editing of libpng.3 and libpng-manual.txt. - -Version 1.5.5beta04 [July 29, 2011] - Revised CMakeLists.txt (Clifford Yapp) - Updated commentary about the png_rgb_to_gray() default coefficients - in the manual and in pngrtran.c - -Version 1.5.5beta05 [August 17, 2011] - Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" - is removed from the test of whether a DLL is being built (this erroneously - caused the libpng APIs to be marked as DLL exports in static builds under - Microsoft Visual Studio). Almost all of the libpng building configuration - is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in - pngconf.h, though, so that it is colocated with the import definition (it - is no longer used anywhere in the installed headers). The VStudio project - definitions have been cleaned up: "_USRDLL" has been removed from the - static library builds (this was incorrect), and PNG_USE_DLL has been added - to pngvalid to test the functionality (pngtest does not supply it, - deliberately). The spurious "_EXPORTS" has been removed from the - libpng build (all these errors were a result of copy/paste between project - configurations.) - Added new types and internal functions for CIE RGB end point handling to - pngpriv.h (functions yet to be implemented). - -Version 1.5.5beta06 [August 26, 2011] - Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt - (Clifford Yap) - Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler): - The rgb_to_gray code had errors when combined with gamma correction. - Some pixels were treated as true grey when they weren't and such pixels - and true grey ones were not gamma corrected (the original value of the - red component was used instead). APIs to get and set cHRM using color - space end points have been added and the rgb_to_gray code that defaults - based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT - VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected. - A considerable number of tests has been added to pngvalid for the - rgb_to_gray transform. - Arithmetic errors in rgb_to_gray whereby the calculated gray value was - truncated to the bit depth rather than rounded have been fixed except in - the 8-bit non-gamma-corrected case (where consistency seems more important - than correctness.) The code still has considerable inaccuracies in the - 8-bit case because 8-bit linear arithmetic is used. - -Version 1.5.5beta07 [September 7, 2011] - Added "$(ARCH)" option to makefile.darwin - Added SunOS support to configure.ac and Makefile.am - Changed png_chunk_benign_error() to png_warning() in png.c, in - png_XYZ_from_xy_checked(). - -Version 1.5.5beta08 [September 10, 2011] - Fixed 64-bit compilation errors (gcc). The errors fixed relate - to conditions where types that are 32 bits in the GCC 32-bit - world (uLong and png_size_t) become 64 bits in the 64-bit - world. This produces potential truncation errors which the - compiler correctly flags. - Relocated new HAVE_SOLARIS_LD definition in configure.ac - Constant changes for 64-bit compatibility (removal of L suffixes). The - 16-bit cases still use "L" as we don't have a 16-bit test system. - -Version 1.5.5rc01 [September 15, 2011] - Removed "L" suffixes in pngpriv.h - -Version 1.5.5 [September 22, 2011] - No changes. - -Version 1.5.6beta01 [September 22, 2011] - Fixed some 64-bit type conversion warnings in pngrtran.c - Moved row_info from png_struct to a local variable. - The various interlace mask arrays have been made into arrays of - bytes and made PNG_CONST and static (previously some arrays were - marked PNG_CONST and some weren't). - Additional checks have been added to the transform code to validate the - pixel depths after the transforms on both read and write. - Removed some redundant code from pngwrite.c, in png_destroy_write_struct(). - Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4]. - This removes the need to allocate temporary strings for chunk names on - the stack in the read/write code. Unknown chunk handling still uses the - string form because this is exposed in the API. - -Version 1.5.6beta02 [September 26, 2011] - Added a note in the manual the png_read_update_info() must be called only - once with a particular info_ptr. - Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro. - -Version 1.5.6beta03 [September 28, 2011] - Revised test-pngtest.sh to report FAIL when pngtest fails. - Added "--strict" option to pngtest, to report FAIL when the failure is - only because the resulting valid files are different. - Revised CMakeLists.txt to work with mingw and removed some material from - CMakeLists.txt that is no longer useful in libpng-1.5. - -Version 1.5.6beta04 [October 5, 2011] - Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")." - -Version 1.5.6beta05 [October 12, 2011] - Speed up png_combine_row() for interlaced images. This reduces the generality - of the code, allowing it to be optimized for Adam7 interlace. The masks - passed to png_combine_row() are now generated internally, avoiding - some code duplication and localizing the interlace handling somewhat. - Align png_struct::row_buf - previously it was always unaligned, caused by - a bug in the code that attempted to align it; the code needs to subtract - one from the pointer to take account of the filter byte prepended to - each row. - Optimized png_combine_row() when rows are aligned. This gains a small - percentage for 16-bit and 32-bit pixels in the typical case where the - output row buffers are appropriately aligned. The optimization was not - previously possible because the png_struct buffer was always misaligned. - Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01. - -Version 1.5.6beta06 [October 17, 2011] - Removed two redundant tests for unitialized row. - Fixed a relatively harmless memory overwrite in compressed text writing - with a 1 byte zlib buffer. - Add ability to call png_read_update_info multiple times to pngvalid.c. - Fixes for multiple calls to png_read_update_info. These fixes attend to - most of the errors revealed in pngvalid, however doing the gamma work - twice results in inaccuracies that can't be easily fixed. There is now - a warning in the code if this is going to happen. - Turned on multiple png_read_update_info in pngvalid transform tests. - Prevent libpng from overwriting unused bits at the end of the image when - it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would - overwrite the partial byte at the end of each row if the row width was not - an exact multiple of 8 bits and the image is not interlaced. - -Version 1.5.6beta07 [October 21, 2011] - Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row - (Mans Rullgard). - -Version 1.5.6rc01 [October 26, 2011] - Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM" - -Version 1.5.6rc02 [October 27, 2011] - Added LSR() macro to defend against buggy compilers that evaluate non-taken - code branches and complain about out-of-range shifts. - -Version 1.5.6rc03 [October 28, 2011] - Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. - Fixed compiler warnings with Intel and MSYS compilers. The logical shift - fix for Microsoft Visual C is required by other compilers, so this - enables that fix for all compilers when using compile-time constants. - Under MSYS 'byte' is a name declared in a system header file, so we - changed the name of a local variable to avoid the warnings that result. - Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h - -Version 1.5.6 [November 3, 2011] - No changes. - -Version 1.5.7beta01 [November 4, 2011] - Added support for ARM processor, when decoding all PNG up-filtered rows - and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard). - Fixed bug in pngvalid on early allocation failure; fixed type cast in - pngmem.c; pngvalid would attempt to call png_error() if the allocation - of a png_struct or png_info failed. This would probably have led to a - crash. The pngmem.c implementation of png_malloc() included a cast - to png_size_t which would fail on large allocations on 16-bit systems. - Fix for the preprocessor of the Intel C compiler. The preprocessor - splits adjacent @ signs with a space; this changes the concatentation - token from @-@-@ to PNG_JOIN; that should work with all compiler - preprocessors. - Paeth filter speed improvements from work by Siarhei Siamashka. This - changes the 'Paeth' reconstruction function to improve the GCC code - generation on x86. The changes are only part of the suggested ones; - just the changes that definitely improve speed and remain simple. - The changes also slightly increase the clarity of the code. - -Version 1.5.7beta02 [November 11, 2011] - Check compression_type parameter in png_get_iCCP and remove spurious - casts. The compression_type parameter is always assigned to, so must - be non-NULL. The cast of the profile length potentially truncated the - value unnecessarily on a 16-bit int system, so the cast of the (byte) - compression type to (int) is specified by ANSI-C anyway. - Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left - the sBIT fields in the test pixel as 0, which resulted in a floating - point division by zero which was irrelevant but causes systems where - FP exceptions cause a crash. Added code to pngvalid to turn on FP - exceptions if the appropriate glibc support is there to ensure this is - tested in the future. - Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the - new PNG_JOIN macro. - Added versioning to pnglibconf.h comments. - Simplified read/write API initial version; basic read/write tested on - a variety of images, limited documentation (in the header file.) - Installed more accurate linear to sRGB conversion tables. The slightly - modified tables reduce the number of 16-bit values that - convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used - to generate the tables is now in a contrib/sRGBtables sub-directory. - -Version 1.5.7beta03 [November 17, 2011] - Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c - Added run-time detection of NEON support. - Added contrib/libtests; includes simplified API test and timing test and - a color conversion utility for rapid checking of failed 'pngstest' results. - Multiple transform bug fixes plus a work-round for double gamma correction. - libpng does not support more than one transform that requires linear data - at once - if this is tried typically the results is double gamma - correction. Since the simplified APIs can need rgb to gray combined with - a compose operation it is necessary to do one of these outside the main - libpng transform code. This check-in also contains fixes to various bugs - in the simplified APIs themselves and to some bugs in compose and rgb to - gray (on palette) itself. - Fixes for C++ compilation using g++ When libpng source is compiled - using g++. The compiler imposes C++ rules on the C source; thus it - is desireable to make the source work with either C or C++ rules - without throwing away useful error information. This change adds - png_voidcast to allow C semantic (void*) cases or the corresponding - C++ static_cast operation, as appropriate. - Added --noexecstack to assembler file compilation. GCC does not set - this on assembler compilation, even though it does on C compilation. - This creates security issues if assembler code is enabled; the - work-around is to set it by default in the flags for $(CCAS) - Work around compilers that don't support declaration of const data. Some - compilers fault 'extern const' data declarations (because the data is - not initialized); this turns on const-ness only for compilers where - this is known to work. - -Version 1.5.7beta04 [November 17, 2011] - Since the gcc driver does not recognize the --noexecstack flag, we must - use the -Wa prefix to have it passed through to the assembler. - Also removed a duplicate setting of this flag. - Added files that were omitted from the libpng-1.5.7beta03 zip distribution. - -Version 1.5.7beta05 [November 25, 2011] - Removed "zTXt" from warning in generic chunk decompression function. - Validate time settings passed to pngset() and png_convert_to_rfc1123() - (Frank Busse). - Added MINGW support to CMakeLists.txt - Reject invalid compression flag or method when reading the iTXt chunk. - Backed out 'simplified' API changes. The API seems too complex and there - is a lack of consensus or enthusiasm for the proposals. The API also - reveals significant bugs inside libpng (double gamma correction and the - known bug of being unable to retrieve a corrected palette). It seems - better to wait until the bugs, at least, are corrected. - Moved pngvalid.c into contrib/libtests - Rebuilt Makefile.in, configure, etc., with autoconf-2.68 - -Version 1.5.7rc01 [December 1, 2011] - Replaced an "#if" with "#ifdef" in pngrtran.c - Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else) - -Version 1.5.7rc02 [December 5, 2011] - Revised project files and contrib/pngvalid/pngvalid.c to account for - the relocation of pngvalid into contrib/libtests. - Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400, - as in libpng-1.5.4. - Put CRLF line endings in the owatcom project files. - -Version 1.5.7rc03 [December 7, 2011] - Updated CMakeLists.txt to account for the relocation of pngvalid.c - -Version 1.5.7 [December 15, 2011] - Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings - reported by earlier versions. - Fixed minor memset/sizeof errors in pngvalid.c. - -Version 1.6.0beta01 [December 15, 2011] - Removed machine-generated configure files from the GIT repository (they will - continue to appear in the tarball distributions and in the libpng15 and - earlier GIT branches). - Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 - but later deleted from libpng-1.5.7beta05. - Added example programs for the new 'simplified' API. - Added ANSI-C (C90) headers and require them, and take advantage of the - change. Also fixed some of the projects/* and contrib/* files that needed - updates for libpng16 and the move of pngvalid.c. - With this change the required ANSI-C header files are assumed to exist: the - implementation must provide float.h, limits.h, stdarg.h and stddef.h and - libpng relies on limits.h and stddef.h existing and behaving as defined - (the other two required headers aren't used). Non-ANSI systems that don't - have stddef.h or limits.h will have to provide an appropriate fake - containing the relevant types and #defines. - The use of FAR/far has been eliminated and the definition of png_alloc_size_t - is now controlled by a flag so that 'small size_t' systems can select it - if necessary. Libpng 1.6 may not currently work on such systems -- it - seems likely that it will ask 'malloc' for more than 65535 bytes with any - image that has a sufficiently large row size (rather than simply failing - to read such images). - New tools directory containing tools used to generate libpng code. - Fixed race conditions in parallel make builds. With higher degrees of - parallelism during 'make' the use of the same temporary file names such - as 'dfn*' can result in a race where a temporary file from one arm of the - build is deleted or overwritten in another arm. This changes the - temporary files for suffix rules to always use $* and ensures that the - non-suffix rules use unique file names. - -Version 1.6.0beta02 [December 21, 2011] - Correct configure builds where build and source directories are separate. - The include path of 'config.h' was erroneously made relative in pngvalid.c - in libpng 1.5.7. - -Version 1.6.0beta03 [December 22, 2011] - Start-up code size improvements, error handler flexibility. These changes - alter how the tricky allocation of the initial png_struct and png_info - structures are handled. png_info is now handled in pretty much the same - way as everything else, except that the allocations handle NULL return - silently. png_struct is changed in a similar way on allocation and on - deallocation a 'safety' error handler is put in place (which should never - be required). The error handler itself is changed to permit mismatches - in the application and libpng error buffer size; however, this means a - silent change to the API to return the jmp_buf if the size doesn't match - the size from the libpng compilation; libpng now allocates the memory and - this may fail. Overall these changes result in slight code size - reductions; however, this is a reduction in code that is always executed - so is particularly valuable. Overall on a 64-bit system the libpng DLL - decreases in code size by 1733 bytes. pngerror.o increases in size by - about 465 bytes because of the new functionality. - Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() - to avoid including a spurious buffer in the png_struct. - -Version 1.6.0beta04 [December 30, 2011] - Regenerated configure scripts with automake-1.11.2 - Eliminated png_info_destroy(). It is now used only in png.c and only calls - one other internal function and memset(). - Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously - it was disabled whenever internal fixed point arithmetic was selected, - which meant it didn't exist even on systems where FP was available but not - preferred. - Added pngvalid.c compile time checks for const APIs. - Implemented 'restrict' for png_info and png_struct. Because of the way - libpng works both png_info and png_struct are always accessed via a - single pointer. This means adding C99 'restrict' to the pointer gives - the compiler some opportunity to optimize the code. This change allows - that. - Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper - location in configure.ac (Gilles Espinasse). - Changed png_memcpy to C assignment where appropriate. Changed all those - uses of png_memcpy that were doing a simple assignment to assignments - (all those cases where the thing being copied is a non-array C L-value). - Added some error checking to png_set_*() routines. - Removed the reference to the non-exported function png_memcpy() from - example.c. - Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but - it had become misaligned. - Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32 - and unsigned long are of different sizes. - -Version 1.6.0beta05 [January 15, 2012] - Updated manual with description of the simplified API (copied from png.h) - Fix bug in pngerror.c: some long warnings were being improperly truncated - (CVE-2011-3464, bug introduced in libpng-1.5.3beta05). - -Version 1.6.0beta06 [January 24, 2012] - Added palette support to the simplified APIs. This commit - changes some of the macro definitions in png.h, app code - may need corresponding changes. - Increased the formatted warning buffer to 192 bytes. - Added color-map support to simplified API. This is an initial version for - review; the documentation has not yet been updated. - Fixed Min/GW uninstall to remove libpng.dll.a - -Version 1.6.0beta07 [January 28, 2012] - Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) - compiler issues slightly different warnings from those issued by the - current vesions of GCC. This eliminates those warnings by - adding/removing casts and small code rewrites. - Updated configure.ac from autoupdate: added --enable-werror option. - Also some layout regularization and removal of introduced tab characters - (replaced with 3-character indentation). Obsolete macros identified by - autoupdate have been removed; the replacements are all in 2.59 so - the pre-req hasn't been changed. --enable-werror checks for support - for -Werror (or the given argument) in the compiler. This mimics the - gcc configure option by allowing -Werror to be turned on safely; without - the option the tests written in configure itself fail compilation because - they cause compiler warnings. - Rewrote autogen.sh to run autoreconf instead of running tools one-by-one. - Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and - set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp). - Freeze libtool files in the 'scripts' directory. This version of autogen.sh - attempts to dissuade people from running it when it is not, or should not, - be necessary. In fact, autogen.sh does not work when run in a libpng - directory extracted from a tar distribution anymore. You must run it in - a GIT clone instead. - Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), - and renamed three whose names were inconsistent with those in - pngsuite/README.txt. - -Version 1.6.0beta08 [February 1, 2012] - Fixed Image::colormap misalignment in pngstest.c - Check libtool/libtoolize version number (2.4.2) in configure.ac - Divide test-pngstest.sh into separate pngstest runs for basic and - transparent images. - Moved automake options to AM_INIT_AUTOMAKE in configure.ac - Added color-tests, silent-rules (Not yet implemented in Makefile.am) and - version checking to configure.ac - Improved pngstest speed by not doing redundant tests and add const to - the background parameter of png_image_finish_read. The --background - option is now done automagically only when required, so that commandline - option no longer exists. - Cleaned up pngpriv.h to consistently declare all functions and data. - Also eliminated PNG_CONST_DATA, which is apparently not needed but we - can't be sure until it is gone. - Added symbol prefixing that allows all the libpng external symbols - to be prefixed (suggested by Reuben Hawkins). - Updated "ftbb*.png" list in the owatcom and vstudio projects. - Fixed 'prefix' builds on clean systems. The generation of pngprefix.h - should not require itself. - Updated INSTALL to explain that autogen.sh must be run in a GIT clone, - not in a libpng directory extracted from a tar distribution. - -Version 1.6.0beta09 [February 1, 2012] - Reverted the prebuilt configure files to libpng-1.6.0beta05 condition. - -Version 1.6.0beta10 [February 3, 2012] - Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests - Updated list of test images in CMakeLists.txt - Updated the prebuilt configure files to current condition. - Revised INSTALL information about autogen.sh; it works in tar distributions. - -Version 1.6.0beta11 [February 16, 2012] - Fix character count in pngstest command in projects/owatcom/pngstest.tgt - Revised test-pngstest.sh to report PASS/FAIL for each image. - Updated documentation about the simplified API. - Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is - extremely inaccurate for sRGB conversions because it uses an 8-bit - intermediate linear value and it does not use the sRGB transform, so it - suffers from the known instability in gamma transforms for values close - to 0 (see Poynton). The net result is that the calculation has a maximum - error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the - permitted 8-bit error. This may still not be enough because of arithmetic - error. - Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). - Fixed a memory overwrite bug in simplified read of RGB PNG with - non-linear gamma Also bugs in the error checking in pngread.c and changed - quite a lot of the checks in pngstest.c to be correct; either correctly - written or not over-optimistic. The pngstest changes are insufficient to - allow all possible RGB transforms to be passed; pngstest cmppixel needs - to be rewritten to make it clearer which errors it allows and then changed - to permit known inaccuracies. - Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h - Fixed fixed/float API export conditionals. 1) If FIXED_POINT or - FLOATING_POINT options were switched off, png.h ended up with lone ';' - characters. This is not valid ANSI-C outside a function. The ';' - characters have been moved inside the definition of PNG_FP_EXPORT and - PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration - of the corresponding functions were completely omitted, even though some - of them are still used internally. The result is still valid, but - produces warnings from gcc with some warning options (including -Wall). The - fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION - when png.h is included from pngpriv.h. - Check for invalid palette index while reading paletted PNG. When one is - found, issue a warning and increase png_ptr->num_palette accordingly. - Apps are responsible for checking to see if that happened. - -Version 1.6.0beta12 [February 18, 2012] - Do not increase num_palette on invalid_index. - Relocated check for invalid palette index to pngrtran.c, after unpacking - the sub-8-bit pixels. - Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when - iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the - test on iCCP chunk length. Also removed spurious casts that may hide - problems on 16-bit systems. - -Version 1.6.0beta13 [February 24, 2012] - Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from - pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; - now that png_ptr->buffer is inaccessible to applications, the special - handling is no longer useful. - Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new - pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is - defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the - configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in - pnglibconf.h.prebuilt and pnglibconf.h. - -Version 1.6.0beta14 [February 27, 2012] - Added information about the new limits in the manual. - Updated Makefile.in - -Version 1.6.0beta15 [March 2, 2012] - Removed unused "current_text" members of png_struct and the png_free() - of png_ptr->current_text from pngread.c - Rewrote pngstest.c for substantial speed improvement. - Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a - spurious check in pngwrite.c - Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store - intermediate files, or intermediate in-memory data, while processing - image data with the simplified API. The option makes the files larger - but faster to write and read. pngstest now uses this by default; this - can be disabled with the --slow option. - Improved pngstest fine tuning of error numbers, new test file generator. - The generator generates images that test the full range of sample values, - allow the error numbers in pngstest to be tuned and checked. makepng - also allows generation of images with extra chunks, although this is - still work-in-progress. - Added check for invalid palette index while reading. - Fixed some bugs in ICC profile writing. The code should now accept - all potentially valid ICC profiles and reject obviously invalid ones. - It now uses png_error() to do so rather than casually writing a PNG - without the necessary color data. - Removed whitespace from the end of lines in all source files and scripts. - -Version 1.6.0beta16 [March 6, 2012] - Relocated palette-index checking function from pngrutil.c to pngtrans.c - Added palette-index checking while writing. - Changed png_inflate() and calling routines to avoid overflow problems. - This is an intermediate check-in that solves the immediate problems and - introduces one performance improvement (avoiding a copy via png_ptr->zbuf.) - Further changes will be made to make ICC profile handling more secure. - Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options - declares 'index' as a global, causing a warning if it is used as a local - variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit) - to an (int) (signed 32-bit). MSVC, however, warns about using the - unary '-' operator on an unsigned value (even though it is well defined - by ANSI-C to be ~x+1). The padding calculation was changed to use a - different method. Removed the tests on png_ptr->pass. - Added contrib/libtests/tarith.c to test internal arithmetic functions from - png.c. This is a libpng maintainer program used to validate changes to the - internal arithmetic functions. - Made read 'inflate' handling like write 'deflate' handling. The read - code now claims and releases png_ptr->zstream, like the write code. - The bug whereby the progressive reader failed to release the zstream - is now fixed, all initialization is delayed, and the code checks for - changed parameters on deflate rather than always calling - deflatedEnd/deflateInit. - Validate the zTXt strings in pngvalid. - Added code to validate the windowBits value passed to deflateInit2(). - If the call to deflateInit2() is wrong a png_warning will be issued - (in fact this is harmless, but the PNG data produced may be sub-optimal). - -Version 1.6.0beta17 [March 10, 2012] - Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. - Reject all iCCP chunks after the first, even if the first one is invalid. - Deflate/inflate was reworked to move common zlib calls into single - functions [rw]util.c. A new shared keyword check routine was also added - and the 'zbuf' is no longer allocated on progressive read. It is now - possible to call png_inflate() incrementally. - If benign errors are disabled use maximum window on ancilliary inflate. - This works round a bug introduced in 1.5.4 where compressed ancillary - chunks could end up with a too-small windowBits value in the deflate - header. - -Version 1.6.0beta18 [March 16, 2012] - Issue a png_benign_error() instead of png_warning() about bad palette index. - In pngtest, treat benign errors as errors if "-strict" is present. - Fixed an off-by-one error in the palette index checking function. - Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) - Revised example.c to put text strings in a temporary character array - instead of directly assigning string constants to png_textp members. - This avoids compiler warnings when -Wwrite-strings is enabled. - Added output flushing to aid debugging under Visual Studio. Unfortunately - this is necessary because the VS2010 output window otherwise simply loses - the error messages on error (they weren't flushed to the window before - the process exited, apparently!) - Added configuration support for benign errors and changed the read - default. Also changed some warnings in the iCCP and sRGB handling - from to benign errors. Configuration now makes read benign - errors warnings and write benign errors to errors by default (thus - changing the behavior on read). The simplified API always forces - read benign errors to warnings (regardless of the system default, unless - this is disabled in which case the simplified API can't be built.) - -Version 1.6.0beta19 [March 18, 2012] - Work around for duplicate row start calls; added warning messages. - This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that - fails to call one of the 'start' routines (not enabled in libpng-1.5 - because it is technically an API change, since it did normally work - before.) It also makes duplicate calls to png_read_start_row (an - internal function called at the start of the image read) benign, as - they were before changes to use png_inflate_claim. Somehow webkit is - causing this to happen; this is probably a mis-feature in the zlib - changes so this commit is only a work-round. - Removed erroneous setting of DETECT_UNINITIALIZED and added more - checks. The code now does a png_error if an attempt is made to do the - row initialization twice; this is an application error and it has - serious consequences because the transform data in png_struct is - changed by each call. - Added application error reporting and added chunk names to read - benign errors; also added --strict to pngstest - not enabled - yet because a warning is produced. - Avoid the double gamma correction warning in the simplified API. - This allows the --strict option to pass in the pngstest checks - -Version 1.6.0beta20 [March 29, 2012] - Changed chunk handler warnings into benign errors, incrementally load iCCP - Added checksum-icc.c to contrib/tools - Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. - Recognize known sRGB ICC profiles while reading; prefer writing the - iCCP profile over writing the sRGB chunk, controlled by the - PNG_sRGB_PROFILE_CHECKS option. - Revised png_set_text_2() to avoid potential memory corruption (fixes - CVE-2011-3048, also known as CVE-2012-3425). - -Version 1.6.0beta21 [April 27, 2012] - Revised scripts/makefile.darwin: use system zlib; remove quotes around - architecture list; add missing ppc architecture; add architecture options - to shared library link; don't try to create a shared lib based on missing - RELEASE variable. - Enable png_set_check_for_invalid_index() for both read and write. - Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around - declaration of png_handle_unknown(). - Added -lssp_nonshared in a comment in scripts/makefile.freebsd - and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. - -Version 1.6.0beta22 [May 23, 2012] - Removed need for -Wno-cast-align with clang. clang correctly warns on - alignment increasing pointer casts when -Wcast-align is passed. This - fixes the cases that clang warns about either by eliminating the - casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c - where the cast is previously verified or pngstest.c where it is OK, by - introducing new png_aligncast macros to do the cast in a way that clang - accepts. - -Version 1.6.0beta23 [June 6, 2012] - Revised CMakeLists.txt to not attempt to make a symlink under mingw. - Made fixes for new optimization warnings from gcc 4.7.0. The compiler - performs an optimization which is safe; however it then warns about it. - Changing the type of 'palette_number' in pngvalid.c removes the warning. - Do not depend upon a GCC feature macro being available for use in generating - the linker mapfile symbol prefix. - Improved performance of new do_check_palette_indexes() function (only - update the value when it actually increases, move test for whether - the check is wanted out of the function. - -Version 1.6.0beta24 [June 7, 2012] - Don't check palette indexes if num_palette is 0 (as it can be in MNG files). - -Version 1.6.0beta25 [June 16, 2012] - Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all - unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT, - and IEND. Previously it only meant ignore all unknown chunks, the - same as num_chunks == 0. Revised png_image_skip_unused_chunks() to - provide a list of chunks to be processed instead of a list of chunks to - ignore. Revised contrib/gregbook/readpng2.c accordingly. - -Version 1.6.0beta26 [July 10, 2012] - Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it - depends on configure, which is not included in those archives. - Moved scripts/chkfmt to contrib/tools. - Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. - -Version 1.6.0beta27 [August 11, 2012] - Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. - Do not use __restrict when GNUC is <= 3.1 - Removed references to png_zalloc() and png_zfree() from the manual. - Fixed configurations where floating point is completely disabled. Because - of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares - floating point APIs during libpng builds even if they are completely - disabled. This requires the png floating point types (png_double*) to be - declared even though the functions are never actually defined. This - change provides a dummy definition so that the declarations work, yet any - implementation will fail to compile because of an incomplete type. - Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of - strcpy() was accidentally re-introduced in libpng16; this change replaces - it with strncpy(). - Eliminated use of png_sizeof(); use sizeof() instead. - Use a consistent style for (sizeof type) and (sizeof (array)) - Cleanup of png_set_filler(). This function does very different things on - read and write. In libpng 1.6 the two cases can be distinguished and - considerable code cleanup, and extra error checking, is possible. This - makes calls on the write side that have no effect be ignored with a - png_app_error(), which can be disabled in the app using - png_set_benign_errors(), and removes the spurious use of usr_channels - on the read side. - Insist on autotools 1.12.1 for git builds because there are security issues - with 1.12 and insisting on anything less would allow 1.12 to be used. - Removed info_ptr->signature[8] from WRITE-only builds. - Add some conditions for compiling png_fixed(). This is a small function - but it requires "-lm" on some platforms. - Cause pngtest --strict to fail on any warning from libpng (not just errors) - and cause it not to fail at the comparison step if libpng lacks support - for writing chunks that it reads from the input (currently only implemented - for compressed text chunks). - Make all three "make check" test programs work without READ or WRITE support. - Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ - or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading - and writing of a PNG file is always tested by one or more of the tests. - Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the - png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros. - Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and - png_memcmp() macros. - Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object - to the split initialization of num_chunks. - -Version 1.6.0beta28 [August 29, 2012] - Unknown handling fixes and clean up. This adds more correct option - control of the unknown handling, corrects the pre-existing bug where - the per-chunk 'keep' setting is ignored and makes it possible to skip - IDAT chunks in the sequential reader (broken in earlier 1.6 versions). - There is a new test program, test-unknown.c, which is a work in progress - (not currently part of the test suite). Comments in the header files now - explain how the unknown handling works. - Allow fine grain control of unknown chunk APIs. This change allows - png_set_keep_unknown_chunks() to be turned off if not required and causes - both read and write to behave appropriately (on read this is only possible - if the user callback is used to handle unknown chunks). The change - also removes the support for storing unknown chunks in the info_struct - if the only unknown handling enabled is via the callback, allowing libpng - to be configured with callback reading and none of the unnecessary code. - Corrected fix for unknown handling in pngtest. This reinstates the - libpng handling of unknown chunks other than vpAg and sTER (including - unsafe-to-copy chunks which were dropped before) and eliminates the - repositioning of vpAg and sTER in pngtest.png by changing pngtest.png - (so the chunks are where libpng would put them). - Added "tunknown" test and corrected a logic error in png_handle_unknown() - when SAVE support is absent. Moved the shell test scripts for - contrib/libtests from the libpng top directory to contrib/libtests. - png_handle_unknown() must always read or skip the chunk, if - SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set - a user callback an unknown chunk will not be read, leading to a read - error, which was revealed by the "tunknown" test. - Cleaned up and corrected ICC profile handling. - contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error - messages could be truncated; made a correct buffer size calculation and - adjusted pngerror.c appropriately. png_icc_check_* checking improved; - changed the functions to receive the correct color type of the PNG on read - or write and check that it matches the color space of the profile (despite - what the comments said before, there is danger in assuming the app will - cope correctly with an RGB profile on a grayscale image and, since it - violates the PNG spec, allowing it is certain to produce inconsistent - app behavior and might even cause app crashes.) Check that profiles - contain the tags needed to process the PNG (tags all required by the ICC - spec). Removed unused PNG_STATIC from pngpriv.h. - -Version 1.6.0beta29 [September 4, 2012] - Fixed the simplified API example programs to add the *colormap parameter - to several of he API and improved the error message if the version field - is not set. - Added contrib/examples/* to the *.zip and *.7z distributions. - Updated simplified API synopses and description of the png_image structure - in the manual. - Made makepng and pngtest produce identical PNGs, add "--relaxed" option - to pngtest. The "--relaxed" option turns off the benign errors that are - enabled by default in pre-RC builds. makepng can now write ICC profiles - where the length has not been extended to a multiple of 4, and pngtest - now intercepts all libpng errors, allowing the previously-introduced - "--strict test" on no warnings to actually work. - Improved ICC profile handling including cHRM chunk generation and fixed - Cygwin+MSVC build errors. The ICC profile handling now includes more - checking. Several errors that caused rejection of the profile are now - handled with a warning in such a way that the invalid profiles will be - read by default in release (but not pre-RC) builds but will not be - written by default. The easy part of handling the cHRM chunk is written, - where the ICC profile contains the required data. The more difficult - part plus guessing a gAMA value requires code to pass selected RGB values - through the profile. - -Version 1.6.0beta30 [October 24, 2012] - Changed ICC profile matrix/vector types to not depend on array type rules. - By the ANSI-C standard the new types should be identical to the previous - versions, and all known versions of gcc tested with the previous versions - except for GCC-4.2.1 work with this version. The change makes the ANSI-C - rule that const applied to an array of elements applies instead to the - elements in the array moot by explicitly applying const to the base - elements of the png_icc_matrix and png_icc_vector types. The accidental - (harmless) 'const' previously applied to the parameters of two of the - functions have also been removed. - Added a work around for GCC 4.2 optimization bug. - Marked the broken (bad white point) original HP sRGB profiles correctly and - correct comments. - Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7 - Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio - builds, fixed build errors and corrected a minor exit code error in - pngvalid if the 'touch' file name is invalid. - Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio - Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in - pngrtran.c (Domani Hannes). - -Version 1.6.0beta31 [November 1, 2012] - Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30. - Made pngvalid so that it will build outside the libpng source tree. - Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail). - Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA. - Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the - interfaces that use it (specifically, png_do_background in 1.4 would - simply display composite for grayscale images but do composition - with the incorrect arithmetic for color ones). In 1.6 the semantic - of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that - depends on it; this obliges people who set it to consider whether they - really want it off if they happen to use any of the interfaces in - question (typically most users who disable it won't). - Fixed GUIDs in projects/vstudio. Some were duplicated or missing, - resulting in VS2010 having to update the files. - Removed non-working ICC profile support code that was mostly added to - libpng-1.6.0beta29 and beta30. There was too much code for too little - gain; implementing full ICC color correction may be desireable but is left - up to applications. - -Version 1.6.0beta32 [November 25, 2012] - Fixed an intermittent SEGV in pngstest due to an uninitialized array element. - Added the ability for contrib/libtests/makepng.c to make a PNG with just one - color. This is useful for debugging pngstest color inaccuracy reports. - Fixed error checking in the simplified write API (Olaf van der Spek) - Made png_user_version_check() ok to use with libpng version 1.10.x and later. - -Version 1.6.0beta33 [December 15, 2012] - Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX) - that causes the MALLOC_MAX limit not to work (John Bowler) - Change png_warning() to png_app_error() in pngwrite.c and comment the - fall-through condition. - Change png_warning() to png_app_warning() in png_write_tRNS(). - Rearranged the ARM-NEON optimizations: Isolated the machine specific code - to the hardware subdirectory and added comments to pngrutil.c so that - implementors of other optimizations know what to do. - Fixed cases of unquoted DESTDIR in Makefile.am - Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5. - -Version 1.6.0beta34 [December 19, 2012] - Cleaned up whitespace in the synopsis portion of the manpage "libpng.3" - Disassembled the version number in scripts/options.awk (necessary for - building on SunOs). - -Version 1.6.0beta35 [December 23, 2012] - Made default Zlib compression settings be configurable. This adds #defines to - pnglibconf.h to control the defaults. - Fixed Windows build issues, enabled ARM compilation. Various warnings issued - by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old - GCCs.) ARM support is enabled by default in zlib.props (unsupported by - Microsoft) and ARM compilation is made possible by deleting the check for - x86. The test programs cannot be run because they are not signed. - -Version 1.6.0beta36 [January 2, 2013] - Discontinued distributing libpng-1.x.x.tar.bz2. - Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar. - Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33) - Fixed 'make distcheck' on SUN OS - libpng.so was not being removed - -Version 1.6.0beta37 [January 10, 2013] - Fixed conceivable but difficult to repro overflow. Also added two test - programs to generate and test a PNG which should have the problem. - -Version 1.6.0beta39 [January 19, 2013] - Again corrected attempt at overflow detection in png_set_unknown_chunks(). - Added overflow detection in png_set_sPLT() and png_set_text_2(). - -Version 1.6.0beta40 [January 20, 2013] - Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs - -Version 1.6.0rc01 [January 26, 2013] - No changes. - -Version 1.6.0rc02 [February 4, 2013] - Added png_get_palette_max() function. - -Version 1.6.0rc03 [February 5, 2013] - Fixed the png_get_palette_max API. - -Version 1.6.0rc04 [February 7, 2013] - Turn serial tests back on (recently turned off by autotools upgrade). - -Version 1.6.0rc05 [February 8, 2013] - Update manual about png_get_palette_max(). - -Version 1.6.0rc06 [February 9, 2013] - Fixed missing dependency in --prefix builds The intermediate - internal 'prefix.h' file can only be generated correctly after - pnglibconf.h, however the dependency was not in Makefile.am. The - symptoms are unpredictable depending on the order make chooses to - build pngprefix.h and pnglibconf.h, often the error goes unnoticed - because there is a system pnglibconf.h to use instead. - -Version 1.6.0rc07 [February 10, 2013] - Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED - block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. - -Version 1.6.0rc08 [February 10, 2013] - Fix typo in png.h #ifdef - -Version 1.6.0 [February 14, 2013] - No changes. - -Version 1.6.1beta01 [February 16, 2013] - Made symbol prefixing work with the ARM neon optimizations. Also allow - pngpriv.h to be included for preprocessor definitions only, so it can - be used in non-C/C++ files. Back ported from libpng 1.7. - Made sRGB check numbers consistent. - Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. - Removed cc -E workround, corrected png_get_palette_max API Tested on - SUN OS cc 5.9, which demonstrates the tokenization problem previously - avoided by using /lib/cpp. Since all .dfn output is now protected in - double quotes unless it is to be macro substituted the fix should - work everywhere. - Enabled parallel tests - back ported from libpng-1.7. - scripts/pnglibconf.dfa formatting improvements back ported from libpng17. - Fixed a race condition in the creation of the build 'scripts' directory - while building with a parallel make. - Use approved/supported Android method to check for NEON, use Linux/POSIX - 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other - library calls (ported from libpng15). - -Version 1.6.1beta02 [February 19, 2013] - Use parentheses more consistently in "#if defined(MACRO)" tests. - Folded long lines. - Reenabled code to allow zero length PLTE chunks for MNG. - -Version 1.6.1beta03 [February 22, 2013] - Fixed ALIGNED_MEMORY support. - Allow run-time ARM NEON checking to be disabled. A new configure option: - --enable-arm-neon=always will stop the run-time checks. New checks - within arm/arm_init.c will cause the code not to be compiled unless - __ARM_NEON__ is set. This should make it fail safe (if someone asks - for it on then the build will fail if it can't be done.) - Updated the INSTALL document. - -Version 1.6.1beta04 [February 27, 2013] - Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. - Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. - Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble - with CRLF line endings. - -Version 1.6.1beta05 [March 1, 2013] - Avoid a possible memory leak in contrib/gregbook/readpng.c - -Version 1.6.1beta06 [March 4, 2013] - Better documentation of unknown handling API interactions. - Corrected Android builds and corrected libpng.vers with symbol - prefixing This adds an API to set optimization options externally, - providing an alternative and general solution for the non-portable - run-time tests used by the ARM Neon code. It also makes those tests - compile and link on Android. - The order of settings vs options in pnglibconf.h is reversed to allow - settings to depend on options and options can now set (or override) the - defaults for settings. - -Version 1.6.1beta07 [March 7, 2013] - Corrected simplified API default gamma for color-mapped output, added - a flag to change default. In 1.6.0 when the simplified API was used - to produce color-mapped output from an input image with no gamma - information the gamma assumed for the input could be different from - that assumed for non-color-mapped output. In particular 16-bit depth - input files were assumed to be sRGB encoded, whereas in the 'direct' - case they were assumed to have linear data. This was an error. The - fix makes the simplified API treat all input files the same way and - adds a new flag to the png_image::flags member to allow the - application/user to specify that 16-bit files contain sRGB data - rather than the default linear. - Fixed bugs in the pngpixel and makepng test programs. - -Version 1.6.1beta08 [March 7, 2013] - Fixed CMakelists.txt to allow building a single variant of the library - (Claudio Bley): - Introduced a PNG_LIB_TARGETS variable that lists all activated library - targets. It is an error if this variable ends up empty, ie. you have - to build at least one library variant. - Made the *_COPY targets only depend on library targets actually being build. - Use PNG_LIB_TARGETS to unify a code path. - Changed the CREATE_SYMLINK macro to expect the full path to a file as the - first argument. When symlinking the filename component of that path is - determined and used as the link target. - Use copy_if_different in the CREATE_SYMLINK macro. - -Version 1.6.1beta09 [March 13, 2013] - Eliminated two warnings from the Intel C compiler. The warnings are - technically valid, although a reasonable treatment of division would - show it to be incorrect. - -Version 1.6.1rc01 [March 21, 2013] - No changes. - -Version 1.6.1 [March 28, 2013] - No changes. - -Version 1.6.2beta01 [April 14, 2013] - Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. - Fixed incorrect warning of excess deflate data. End condition - the - warning would be produced if the end of the deflate stream wasn't read - in the last row. The warning is harmless. - Corrected the test on user transform changes on read. It was in the - png_set of the transform function, but that doesn't matter unless the - transform function changes the rowbuf size, and that is only valid if - transform_info is called. - Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c - (Flavio Medeiros). - Corrected length written to uncompressed iTXt chunks (Samuli Suominen). - -Version 1.6.2rc01 [April 18, 2013] - Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length - written by libpng-1.6.0 and 1.6.1. - Disallow storing sRGB information when the sRGB is not supported. - -Version 1.6.2rc02 [April 18, 2013] - Merge pngtest.c with libpng-1.7.0 - -Version 1.6.2rc03 [April 22, 2013] - Trivial spelling cleanup. - -Version 1.6.2rc04 and 1.6.2rc05 [omitted] - -Version 1.6.2rc06 [April 24, 2013] - Reverted to version 1.6.2rc03. Recent changes to arm/neon support - have been ported to libpng-1.7.0beta09 and will reappear in version - 1.6.3beta01. - -Version 1.6.2 [April 25, 2013] - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) -or to glennrp at users.sourceforge.net +Send comments/corrections/commendations to +png-implement@ccrc.wustl.edu (subscription required; write to +majordomo@ccrc.wustl.edu with "subscribe png-implement" in the message) +or to glennrp@users.sourceforge.net Glenn R-P -#endif diff --git a/Source/3rd Party/wx/src/png/README b/Source/3rd Party/wx/src/png/README index 26301a5aa..7109660f1 100644 --- a/Source/3rd Party/wx/src/png/README +++ b/Source/3rd Party/wx/src/png/README @@ -1,11 +1,11 @@ -README for libpng version 1.6.2 - April 25, 2013 (shared library 16.0) +README for libpng version 1.2.7 - September 12, 2004 (shared library 12.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. -Libpng comes in several distribution formats. Get libpng-*.tar.gz, -libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings -in the text files, or lpng*.zip if you want DOS-style line endings. +Libpng comes in several distribution formats. Get libpng-*.tar.gz +or libpng-*.tar.bz2 if you want UNIX-style line endings in the text +files, or lpng*.zip if you want DOS-style line endings. Version 0.89 was the first official release of libpng. Don't let the fact that it's the first release fool you. The libpng library has been in @@ -54,11 +54,11 @@ to set different actions based on whether the CRC error occurred in a critical or an ancillary chunk. The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list and not on material submitted -privately to Guy, Andreas, or Glenn. They will forward any good -suggestions to the list. +on the PNG-implement mailing list +and not on material submitted privately to Guy, Andreas, or Glenn. They will +forward any good suggestions to the list. -For a detailed description on using libpng, read libpng-manual.txt. For +For a detailed description on using libpng, read libpng.txt. For examples of libpng in a program, see example.c and pngtest.c. For usage information and restrictions (what little they are) on libpng, see png.h. For a description on using zlib (the compression library used by @@ -101,29 +101,30 @@ Finally, if you get any warning messages when compiling libpng fix. Please mention "libpng" somewhere in the subject line. Thanks. This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG -development group. +based in a large way on Guy's and Andreas' earlier work), and the PNG group. -Send comments/corrections/commendations to png-mng-implement at -lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net +glennrp@users.sourceforge.net +png-implement@ccrc.wustl.edu (subscription required; write to +majordomo@ccrc.wustl.edu with "subscribe png-implement" in the message). You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will -read mail addressed to the png-implement list, however. +given in previous versions of this document. He and Andreas will read mail +addressed to the png-implement list, however. Please do not send general questions about PNG. Send them to -png-mng-misc at lists.sf.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-misc to -subscribe). If you have a question about something +the (png-list@ccrc.wustl.edu, subscription required, write to +majordomo@ccrc.wustl.edu with "subscribe png-list" in your message). +On the other hand, +please do not send libpng questions to that address, send them to me +or to the png-implement list. I'll +get them in the end anyway. If you have a question about something in the PNG specification that is related to using libpng, send it to me. Send me any questions that start with "I was using libpng, and ...". If in doubt, send questions to me. I'll bounce them to others, if necessary. Please do not send suggestions on how to change PNG. We have -been discussing PNG for sixteen years now, and it is official and +been discussing PNG for nine years now, and it is official and finished. If you have suggestions for libpng, however, I'll gladly listen. Even if your suggestion is not used immediately, it may be used later. @@ -138,17 +139,14 @@ Files in this distribution: TODO => Things not implemented in the current library Y2KINFO => Statement of Y2K compliance example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng-manual.txt) - libpng-manual.txt => Description of libpng and its functions + libpng.3 => manual page for libpng (includes libpng.txt) + libpng.txt => Description of libpng and its functions libpngpf.3 => manual page for libpng's private functions png.5 => manual page for the PNG format png.c => Basic interface functions common to library - png.h => Library function and interface declarations (public) - pngpriv.h => Library function and interface declarations (private) - pngconf.h => System specific library configuration (public) - pngstruct.h => png_struct declaration (private) - pnginfo.h => png_info struct declaration (private) - pngdebug.h => debugging macros (private) + png.h => Library function and interface declarations + pngconf.h => System specific library configuration + pngasmrd.h => Header file for assembler-coded functions pngerror.c => Error/warning message I/O functions pngget.c => Functions for retrieving info from struct pngmem.c => Memory handling functions @@ -175,28 +173,88 @@ Files in this distribution: pngminus => Simple pnm2png and png2pnm programs pngsuite => Test images visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for - building a DLL - cbuilder5 => Contains a Borland workspace for building - libpng and zlib - visualc6 => Contains a Microsoft Visual C++ (MSVC) - workspace for building libpng and zlib - visualc71 => Contains a Microsoft Visual C++ (MSVC) - workspace for building libpng and zlib - xcode => Contains an Apple xcode - workspace for building libpng and zlib + projects => Contains project files and workspaces for building DLL + beos => Contains a Beos workspace for building libpng + c5builder => Contains a Borland workspace for building libpng + and zlib + visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace + for building libpng and zlib + netware.txt => Contains instructions for downloading a set of + project files for building libpng and zlib on + Netware. + wince.txt => Contains instructions for downloading a Microsoft + Visual C++ (Windows CD Toolkit) workspace for + building libpng and zlib on WindowsCE scripts => Directory containing scripts for building libpng: - (see scripts/README.txt for the list of scripts) + descrip.mms => VMS makefile for MMS or MMK + makefile.std => Generic UNIX makefile (cc, creates static libpng.a) + makefile.linux => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.7) + makefile.gcmmx => Linux/ELF makefile + (gcc, creates libpng12.so.0.1.2.7, + uses assembler code tuned for Intel MMX platform) + makefile.gcc => Generic makefile (gcc, creates static libpng.a) + makefile.knr => Archaic UNIX Makefile that converts files with + ansi2knr (Requires ansi2knr.c from + ftp://ftp.cs.wisc.edu/ghost) + makefile.aix => AIX makefile + makefile.cygwin => Cygwin/gcc makefile + makefile.darwin => Darwin makefile + makefile.dec => DEC Alpha UNIX makefile + makefile.freebsd => FreeBSD makefile + makefile.hpgcc => HPUX makefile using gcc + makefile.hpux => HPUX (10.20 and 11.00) makefile + makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit + makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) + makefile.intel => Intel C/C++ version 4.0 and later + libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later + makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. + makefile.ne12bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng12.so + makefile.openbsd => OpenBSD makefile + makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) + makefile.sggcc => Silicon Graphics + (gcc, creates libpng12.so.0.1.2.7) + makefile.sunos => Sun makefile + makefile.solaris => Solaris 2.X makefile + (gcc, creates libpng12.so.0.1.2.7) + makefile.so9 => Solaris 9 makefile + (gcc, creates libpng12.so.0.1.2.7) + makefile.32sunu => Sun Ultra 32-bit makefile + makefile.64sunu => Sun Ultra 64-bit makefile + makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc + makefile.mips => MIPS makefile + makefile.acorn => Acorn makefile + makefile.amiga => Amiga makefile + smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC + compiler (Requires SCOPTIONS, copied from + scripts/SCOPTIONS.ppc) + makefile.atari => Atari makefile + makefile.beos => BEOS makefile for X86 + makefile.bor => Borland makefile (uses bcc) + makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) + makefile.tc3 => Turbo C 3.0 makefile + makefile.dj2 => DJGPP 2 makefile + makefile.msc => Microsoft C makefile + makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and + later (uses assembler code tuned for Intel MMX + platform) + makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and + later (does not use assembler code) + makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + pngos2.def => OS/2 module definition file used by makefile.os2 + makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model + makevms.com => VMS build script + SCOPTIONS.ppc => Used with smakefile.ppc Good luck, and happy coding. --Glenn Randers-Pehrson (current maintainer, since 1998) - Internet: glennrp at users.sourceforge.net +-Glenn Randers-Pehrson (current maintainer) + Internet: glennrp@users.sourceforge.net -Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca + Internet: adilger@enel.ucalgary.ca Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ -Guy Eric Schalnat (original author and former maintainer, 1995-1996) (formerly of Group 42, Inc) - Internet: gschal at infinet.com + Internet: gschal@infinet.com diff --git a/Source/3rd Party/wx/src/png/TODO b/Source/3rd Party/wx/src/png/TODO index 6e1f028bd..a5f639577 100644 --- a/Source/3rd Party/wx/src/png/TODO +++ b/Source/3rd Party/wx/src/png/TODO @@ -1,11 +1,12 @@ -/* TODO - list of things to do for libpng: Final bug fixes. +Improve API by hiding the png_struct and png_info structs. +Finish work on the no-floating-point version (including gamma compensation) Better C++ wrapper/full C++ implementation? Fix problem with C++ and EXTERN "C". cHRM transformation. -Remove setjmp/longjmp usage in favor of returning error codes. +Improve setjmp/longjmp usage or remove it in favor of returning error codes. Add "grayscale->palette" transformation and "palette->grayscale" detection. Improved dithering. Multi-lingual error and warning message support. @@ -16,12 +17,8 @@ Better filter selection (counting huffman bits/precompression? filter inertia? filter costs?). Histogram creation. Text conversion between different code pages (Latin-1 -> Mac and DOS). -Avoid building gamma tables whenever possible. +Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? +Build gamma tables using fixed point (and do away with floating point entirely). Use greater precision when changing to linear gamma for compositing against background and doing rgb-to-gray transformation. Investigate pre-incremented loop counters and other loop constructions. -Add interpolated method of handling interlacing. -Switch to the simpler zlib (zlib/libpng) license if legally possible. -Extend pngvalid.c to validate more of the libpng transformations. - -*/ diff --git a/Source/3rd Party/wx/src/png/ansi2knr.c b/Source/3rd Party/wx/src/png/ansi2knr.c new file mode 100644 index 000000000..dfb29a244 --- /dev/null +++ b/Source/3rd Party/wx/src/png/ansi2knr.c @@ -0,0 +1,695 @@ +/* ansi2knr.c */ + +/* Convert ANSI C function definitions to K&R ("traditional C") syntax +Copyright (C) 1989 Aladdin Enterprises. All rights reserved. +Copyright (C) 1988 Richard M. Stallman + +ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY. No author or distributor accepts responsibility to anyone for the +consequences of using it or for whether it serves any particular purpose or +works at all, unless he says so in writing. Refer to the GNU General Public +License (the "GPL") for full details. + +Everyone is granted permission to copy, modify and redistribute ansi2knr, +but only under the conditions described in the GPL. A copy of this license +is supposed to have been given to you along with ansi2knr so you can know +your rights and responsibilities. It should be in a file named COPYLEFT. +[In the LIBPNG distribution, the GPL appears below, not in a separate file.] +Among other things, the copyright notice and this notice must be preserved +on all copies. + +We explicitly state here what we believe is already implied by the GPL: if +the ansi2knr program is distributed as a separate source file and a +separate executable file which are aggregated on a storage medium together +with another program, this in itself does not bring the other program under +the GPL, nor does the mere fact that such a program or the procedures for +constructing it invoke the ansi2knr executable bring any other part of the +program under the GPL. +*/ + +/* +---------- Here is the GNU GPL file COPYLEFT, referred to above ---------- +----- These terms do NOT apply to the LIBPNG software itself; see README ------ + + GHOSTSCRIPT GENERAL PUBLIC LICENSE + (Clarified 11 Feb 1988) + + Copyright (C) 1988 Richard M. Stallman + Everyone is permitted to copy and distribute verbatim copies of this + license, but changing it is not allowed. You can also use this wording + to make the terms for other programs. + + The license agreements of most software companies keep you at the +mercy of those companies. By contrast, our general public license is +intended to give everyone the right to share Ghostscript. To make sure +that you get the rights we want you to have, we need to make +restrictions that forbid anyone to deny you these rights or to ask you +to surrender the rights. Hence this license agreement. + + Specifically, we want to make sure that you have the right to give +away copies of Ghostscript, that you receive source code or else can get +it if you want it, that you can change Ghostscript or use pieces of it +in new free programs, and that you know you can do these things. + + To make sure that everyone has such rights, we have to forbid you to +deprive anyone else of these rights. For example, if you distribute +copies of Ghostscript, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + Also, for our own protection, we must make certain that everyone finds +out that there is no warranty for Ghostscript. If Ghostscript is +modified by someone else and passed on, we want its recipients to know +that what they have is not what we distributed, so that any problems +introduced by others will not reflect on our reputation. + + Therefore we (Richard M. Stallman and the Free Software Foundation, +Inc.) make the following terms which say what you must do to be allowed +to distribute or change Ghostscript. + + + COPYING POLICIES + + 1. You may copy and distribute verbatim copies of Ghostscript source +code as you receive it, in any medium, provided that you conspicuously +and appropriately publish on each copy a valid copyright and license +notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. +Distributed by Free Software Foundation, Inc." (or with whatever year is +appropriate); keep intact the notices on all files that refer to this +License Agreement and to the absence of any warranty; and give any other +recipients of the Ghostscript program a copy of this License Agreement +along with the program. You may charge a distribution fee for the +physical act of transferring a copy. + + 2. You may modify your copy or copies of Ghostscript or any portion of +it, and copy and distribute such modifications under the terms of +Paragraph 1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating + that you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, + that in whole or in part contains or is a derivative of Ghostscript + or any part thereof, to be licensed at no charge to all third + parties on terms identical to those contained in this License + Agreement (except that you may choose to grant more extensive + warranty protection to some or all third parties, at your option). + + c) You may charge a distribution fee for the physical act of + transferring a copy, and you may at your option offer warranty + protection in exchange for a fee. + +Mere aggregation of another unrelated program with this program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other program under the scope of these terms. + + 3. You may copy and distribute Ghostscript (or a portion or derivative +of it, under Paragraph 2) in object code or executable form under the +terms of Paragraphs 1 and 2 above provided that you also do one of the +following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal + shipping charge) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +For an executable file, complete source code means all the source code for +all modules it contains; but, as a special exception, it need not include +source code for modules which are standard libraries that accompany the +operating system on which the executable file runs. + + 4. You may not copy, sublicense, distribute or transfer Ghostscript +except as expressly provided under this License Agreement. Any attempt +otherwise to copy, sublicense, distribute or transfer Ghostscript is +void and your rights to use the program under this License agreement +shall be automatically terminated. However, parties who have received +computer software programs from you with this License Agreement will not +have their licenses terminated so long as such parties remain in full +compliance. + + 5. If you wish to incorporate parts of Ghostscript into other free +programs whose distribution conditions are different, write to the Free +Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not +yet worked out a simple rule that can be stated here, but we will often +permit this. We will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the +sharing and reuse of software. + +Your comments and suggestions about our licensing policies and our +software are welcome! Please contact the Free Software Foundation, +Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. + + NO WARRANTY + + BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY +NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT +WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD +M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES +PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH +YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. +STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN +ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE +GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING +ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU +HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM +BY ANY OTHER PARTY. + +-------------------- End of file COPYLEFT ------------------------------ +*/ + +/* + * Usage: + ansi2knr input_file [output_file] + * If no output_file is supplied, output goes to stdout. + * There are no error messages. + * + * ansi2knr recognizes function definitions by seeing a non-keyword + * identifier at the left margin, followed by a left parenthesis, + * with a right parenthesis as the last character on the line, + * and with a left brace as the first token on the following line + * (ignoring possible intervening comments). + * It will recognize a multi-line header provided that no intervening + * line ends with a left or right brace or a semicolon. + * These algorithms ignore whitespace and comments, except that + * the function name must be the first thing on the line. + * The following constructs will confuse it: + * - Any other construct that starts at the left margin and + * follows the above syntax (such as a macro or function call). + * - Some macros that tinker with the syntax of the function header. + */ + +/* + * The original and principal author of ansi2knr is L. Peter Deutsch + * . Other authors are noted in the change history + * that follows (in reverse chronological order): + lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with + compilers that don't understand void, as suggested by + Tom Lane + lpd 96-01-15 changed to require that the first non-comment token + on the line following a function header be a left brace, + to reduce sensitivity to macros, as suggested by Tom Lane + + lpd 95-06-22 removed #ifndefs whose sole purpose was to define + undefined preprocessor symbols as 0; changed all #ifdefs + for configuration symbols to #ifs + lpd 95-04-05 changed copyright notice to make it clear that + including ansi2knr in a program does not bring the entire + program under the GPL + lpd 94-12-18 added conditionals for systems where ctype macros + don't handle 8-bit characters properly, suggested by + Francois Pinard ; + removed --varargs switch (this is now the default) + lpd 94-10-10 removed CONFIG_BROKETS conditional + lpd 94-07-16 added some conditionals to help GNU `configure', + suggested by Francois Pinard ; + properly erase prototype args in function parameters, + contributed by Jim Avera ; + correct error in writeblanks (it shouldn't erase EOLs) + lpd 89-xx-xx original version + */ + +/* Most of the conditionals here are to make ansi2knr work with */ +/* or without the GNU configure machinery. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_CONFIG_H + +/* + For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). + This will define HAVE_CONFIG_H and so, activate the following lines. + */ + +# if STDC_HEADERS || HAVE_STRING_H +# include +# else +# include +# endif + +#else /* not HAVE_CONFIG_H */ + +/* Otherwise do it the hard way */ + +# ifdef BSD +# include +# else +# ifdef VMS + extern int strlen(), strncmp(); +# else +# include +# endif +# endif + +#endif /* not HAVE_CONFIG_H */ + +#if STDC_HEADERS +# include +#else +/* + malloc and free should be declared in stdlib.h, + but if you've got a K&R compiler, they probably aren't. + */ +# ifdef MSDOS +# include +# else +# ifdef VMS + extern char *malloc(); + extern void free(); +# else + extern char *malloc(); + extern int free(); +# endif +# endif + +#endif + +/* + * The ctype macros don't always handle 8-bit characters correctly. + * Compensate for this here. + */ +#ifdef isascii +# undef HAVE_ISASCII /* just in case */ +# define HAVE_ISASCII 1 +#else +#endif +#if STDC_HEADERS || !HAVE_ISASCII +# define is_ascii(c) 1 +#else +# define is_ascii(c) isascii(c) +#endif + +#define is_space(c) (is_ascii(c) && isspace(c)) +#define is_alpha(c) (is_ascii(c) && isalpha(c)) +#define is_alnum(c) (is_ascii(c) && isalnum(c)) + +/* Scanning macros */ +#define isidchar(ch) (is_alnum(ch) || (ch) == '_') +#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') + +/* Forward references */ +char *skipspace(); +int writeblanks(); +int test1(); +int convert1(); + +/* The main program */ +int +main(argc, argv) + int argc; + char *argv[]; +{ FILE *in, *out; +#define bufsize 5000 /* arbitrary size */ + char *buf; + char *line; + char *more; + /* + * In previous versions, ansi2knr recognized a --varargs switch. + * If this switch was supplied, ansi2knr would attempt to convert + * a ... argument to va_alist and va_dcl; if this switch was not + * supplied, ansi2knr would simply drop any such arguments. + * Now, ansi2knr always does this conversion, and we only + * check for this switch for backward compatibility. + */ + int convert_varargs = 1; + + if ( argc > 1 && argv[1][0] == '-' ) + { if ( !strcmp(argv[1], "--varargs") ) + { convert_varargs = 1; + argc--; + argv++; + } + else + { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); + exit(1); + } + } + switch ( argc ) + { + default: + printf("Usage: ansi2knr input_file [output_file]\n"); + exit(0); + case 2: + out = stdout; + break; + case 3: + out = fopen(argv[2], "w"); + if ( out == NULL ) + { fprintf(stderr, "Cannot open output file %s\n", argv[2]); + exit(1); + } + } + in = fopen(argv[1], "r"); + if ( in == NULL ) + { fprintf(stderr, "Cannot open input file %s\n", argv[1]); + exit(1); + } + fprintf(out, "#line 1 \"%s\"\n", argv[1]); + buf = malloc(bufsize); + line = buf; + while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) + { +test: line += strlen(line); + switch ( test1(buf) ) + { + case 2: /* a function header */ + convert1(buf, out, 1, convert_varargs); + break; + case 1: /* a function */ + /* Check for a { at the start of the next line. */ + more = ++line; +f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ + goto wl; + if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) + goto wl; + switch ( *skipspace(more, 1) ) + { + case '{': + /* Definitely a function header. */ + convert1(buf, out, 0, convert_varargs); + fputs(more, out); + break; + case 0: + /* The next line was blank or a comment: */ + /* keep scanning for a non-comment. */ + line += strlen(line); + goto f; + default: + /* buf isn't a function header, but */ + /* more might be. */ + fputs(buf, out); + strcpy(buf, more); + line = buf; + goto test; + } + break; + case -1: /* maybe the start of a function */ + if ( line != buf + (bufsize - 1) ) /* overflow check */ + continue; + /* falls through */ + default: /* not a function */ +wl: fputs(buf, out); + break; + } + line = buf; + } + if ( line != buf ) + fputs(buf, out); + free(buf); + fclose(out); + fclose(in); + return 0; +} + +/* Skip over space and comments, in either direction. */ +char * +skipspace(p, dir) + register char *p; + register int dir; /* 1 for forward, -1 for backward */ +{ for ( ; ; ) + { while ( is_space(*p) ) + p += dir; + if ( !(*p == '/' && p[dir] == '*') ) + break; + p += dir; p += dir; + while ( !(*p == '*' && p[dir] == '/') ) + { if ( *p == 0 ) + return p; /* multi-line comment?? */ + p += dir; + } + p += dir; p += dir; + } + return p; +} + +/* + * Write blanks over part of a string. + * Don't overwrite end-of-line characters. + */ +int +writeblanks(start, end) + char *start; + char *end; +{ char *p; + for ( p = start; p < end; p++ ) + if ( *p != '\r' && *p != '\n' ) + *p = ' '; + return 0; +} + +/* + * Test whether the string in buf is a function definition. + * The string may contain and/or end with a newline. + * Return as follows: + * 0 - definitely not a function definition; + * 1 - definitely a function definition; + * 2 - definitely a function prototype (NOT USED); + * -1 - may be the beginning of a function definition, + * append another line and look again. + * The reason we don't attempt to convert function prototypes is that + * Ghostscript's declaration-generating macros look too much like + * prototypes, and confuse the algorithms. + */ +int +test1(buf) + char *buf; +{ register char *p = buf; + char *bend; + char *endfn; + int contin; + + if ( !isidfirstchar(*p) ) + return 0; /* no name at left margin */ + bend = skipspace(buf + strlen(buf) - 1, -1); + switch ( *bend ) + { + case ';': contin = 0 /*2*/; break; + case ')': contin = 1; break; + case '{': return 0; /* not a function */ + case '}': return 0; /* not a function */ + default: contin = -1; + } + while ( isidchar(*p) ) + p++; + endfn = p; + p = skipspace(p, 1); + if ( *p++ != '(' ) + return 0; /* not a function */ + p = skipspace(p, 1); + if ( *p == ')' ) + return 0; /* no parameters */ + /* Check that the apparent function name isn't a keyword. */ + /* We only need to check for keywords that could be followed */ + /* by a left parenthesis (which, unfortunately, is most of them). */ + { static char *words[] = + { "asm", "auto", "case", "char", "const", "double", + "extern", "float", "for", "if", "int", "long", + "register", "return", "short", "signed", "sizeof", + "static", "switch", "typedef", "unsigned", + "void", "volatile", "while", 0 + }; + char **key = words; + char *kp; + int len = endfn - buf; + + while ( (kp = *key) != 0 ) + { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) + return 0; /* name is a keyword */ + key++; + } + } + return contin; +} + +/* Convert a recognized function definition or header to K&R syntax. */ +int +convert1(buf, out, header, convert_varargs) + char *buf; + FILE *out; + int header; /* Boolean */ + int convert_varargs; /* Boolean */ +{ char *endfn; + register char *p; + char **breaks; + unsigned num_breaks = 2; /* for testing */ + char **btop; + char **bp; + char **ap; + char *vararg = 0; + + /* Pre-ANSI implementations don't agree on whether strchr */ + /* is called strchr or index, so we open-code it here. */ + for ( endfn = buf; *(endfn++) != '('; ) + ; +top: p = endfn; + breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); + if ( breaks == 0 ) + { /* Couldn't allocate break table, give up */ + fprintf(stderr, "Unable to allocate break table!\n"); + fputs(buf, out); + return -1; + } + btop = breaks + num_breaks * 2 - 2; + bp = breaks; + /* Parse the argument list */ + do + { int level = 0; + char *lp = NULL; + char *rp; + char *end = NULL; + + if ( bp >= btop ) + { /* Filled up break table. */ + /* Allocate a bigger one and start over. */ + free((char *)breaks); + num_breaks <<= 1; + goto top; + } + *bp++ = p; + /* Find the end of the argument */ + for ( ; end == NULL; p++ ) + { switch(*p) + { + case ',': + if ( !level ) end = p; + break; + case '(': + if ( !level ) lp = p; + level++; + break; + case ')': + if ( --level < 0 ) end = p; + else rp = p; + break; + case '/': + p = skipspace(p, 1) - 1; + break; + default: + ; + } + } + /* Erase any embedded prototype parameters. */ + if ( lp ) + writeblanks(lp + 1, rp); + p--; /* back up over terminator */ + /* Find the name being declared. */ + /* This is complicated because of procedure and */ + /* array modifiers. */ + for ( ; ; ) + { p = skipspace(p - 1, -1); + switch ( *p ) + { + case ']': /* skip array dimension(s) */ + case ')': /* skip procedure args OR name */ + { int level = 1; + while ( level ) + switch ( *--p ) + { + case ']': case ')': level++; break; + case '[': case '(': level--; break; + case '/': p = skipspace(p, -1) + 1; break; + default: ; + } + } + if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) + { /* We found the name being declared */ + while ( !isidfirstchar(*p) ) + p = skipspace(p, 1) + 1; + goto found; + } + break; + default: + goto found; + } + } +found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) + { if ( convert_varargs ) + { *bp++ = "va_alist"; + vararg = p-2; + } + else + { p++; + if ( bp == breaks + 1 ) /* sole argument */ + writeblanks(breaks[0], p); + else + writeblanks(bp[-1] - 1, p); + bp--; + } + } + else + { while ( isidchar(*p) ) p--; + *bp++ = p+1; + } + p = end; + } + while ( *p++ == ',' ); + *bp = p; + /* Make a special check for 'void' arglist */ + if ( bp == breaks+2 ) + { p = skipspace(breaks[0], 1); + if ( !strncmp(p, "void", 4) ) + { p = skipspace(p+4, 1); + if ( p == breaks[2] - 1 ) + { bp = breaks; /* yup, pretend arglist is empty */ + writeblanks(breaks[0], p + 1); + } + } + } + /* Put out the function name and left parenthesis. */ + p = buf; + while ( p != endfn ) putc(*p, out), p++; + /* Put out the declaration. */ + if ( header ) + { fputs(");", out); + for ( p = breaks[0]; *p; p++ ) + if ( *p == '\r' || *p == '\n' ) + putc(*p, out); + } + else + { for ( ap = breaks+1; ap < bp; ap += 2 ) + { p = *ap; + while ( isidchar(*p) ) + putc(*p, out), p++; + if ( ap < bp - 1 ) + fputs(", ", out); + } + fputs(") ", out); + /* Put out the argument declarations */ + for ( ap = breaks+2; ap <= bp; ap += 2 ) + (*ap)[-1] = ';'; + if ( vararg != 0 ) + { *vararg = 0; + fputs(breaks[0], out); /* any prior args */ + fputs("va_dcl", out); /* the final arg */ + fputs(bp[0], out); + } + else + fputs(breaks[0], out); + } + free((char *)breaks); + return 0; +} diff --git a/Source/3rd Party/wx/src/png/png.c b/Source/3rd Party/wx/src/png/png.c index d429c527c..a0332b9ab 100644 --- a/Source/3rd Party/wx/src/png/png.c +++ b/Source/3rd Party/wx/src/png/png.c @@ -1,20 +1,86 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" +#define PNG_INTERNAL +#define PNG_NO_EXTERN +#include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_2 Your_png_h_is_not_version_1_6_2; +typedef version_1_2_7 Your_png_h_is_not_version_1_2_7; + +/* Version information for C files. This had better match the version + * string defined in png.h. */ + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* png_libpng_ver was changed to a function in version 1.0.5c */ +const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; + +/* png_sig was changed to a function in version 1.0.5c */ +/* Place to hold the signature string for a PNG file. */ +const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + +/* Invoke global declarations for constant strings for known chunk types */ +PNG_IHDR; +PNG_IDAT; +PNG_IEND; +PNG_PLTE; +PNG_bKGD; +PNG_cHRM; +PNG_gAMA; +PNG_hIST; +PNG_iCCP; +PNG_iTXt; +PNG_oFFs; +PNG_pCAL; +PNG_sCAL; +PNG_pHYs; +PNG_sBIT; +PNG_sPLT; +PNG_sRGB; +PNG_tEXt; +PNG_tIME; +PNG_tRNS; +PNG_zTXt; + +/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + +/* start of interlace block */ +const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + +/* offset to next interlace block */ +const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + +/* start of interlace block in the y direction */ +const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + +/* offset to next interlace block in the y direction */ +const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + +/* width of interlace block (used in assembler routines only) */ +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; +#endif + +/* Height of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h +const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; +*/ + +/* Mask to determine which pixels are valid in a pass */ +const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; + +/* Mask to determine which pixels to overwrite while displaying */ +const int FARDATA png_pass_dsp_mask[] + = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + +#endif /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -22,17 +88,12 @@ typedef png_libpng_version_1_6_2 Your_png_h_is_not_version_1_6_2; * or write any of the magic bytes before it starts on the IHDR. */ -#ifdef PNG_READ_SUPPORTED void PNGAPI -png_set_sig_bytes(png_structrp png_ptr, int num_bytes) +png_set_sig_bytes(png_structp png_ptr, int num_bytes) { - png_debug(1, "in png_set_sig_bytes"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_sig_bytes\n"); if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature"); + png_error(png_ptr, "Too many bytes for PNG signature."); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); } @@ -43,66 +104,96 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes) * can simply check the remaining bytes for extra assurance. Returns * an integer less than, equal to, or greater than zero if sig is found, * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behavior as strcmp, memcmp, etc). + * PNG signature (this is the same behaviour as strcmp, memcmp, etc). */ int PNGAPI -png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check) +png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) { png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) num_to_check = 8; - else if (num_to_check < 1) - return (-1); + return (0); if (start > 7) - return (-1); + return (0); if (start + num_to_check > 8) num_to_check = 8 - start; - return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check))); + return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); } -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib */ -PNG_FUNCTION(voidpf /* PRIVATE */, -png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) +/* (Obsolete) function to check signature bytes. It does not allow one + * to check a partial signature. This function might be removed in the + * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. + */ +int PNGAPI +png_check_sig(png_bytep sig, int num) { - png_alloc_size_t num_bytes = size; - - if (png_ptr == NULL) - return NULL; - - if (items >= (~(png_alloc_size_t)0)/size) - { - png_warning (png_voidcast(png_structrp, png_ptr), - "Potential overflow in png_zalloc()"); - return NULL; - } - - num_bytes *= items; - return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes); + return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); } -/* Function to free memory for zlib */ -void /* PRIVATE */ +/* Function to allocate memory for zlib and clear it to 0. */ +#ifdef PNG_1_0_X +voidpf PNGAPI +#else +voidpf /* private */ +#endif +png_zalloc(voidpf png_ptr, uInt items, uInt size) +{ + png_voidp ptr; + png_structp p=(png_struct*)png_ptr; + png_uint_32 save_flags=p->flags; + png_uint_32 num_bytes; + + if (items > PNG_UINT_32_MAX/size) + { + png_warning (png_ptr, "Potential overflow in png_zalloc()"); + return (NULL); + } + num_bytes = (png_uint_32)items * size; + + p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); + p->flags=save_flags; + +#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) + if (ptr == NULL) + return ((voidpf)ptr); + + if (num_bytes > (png_uint_32)0x8000L) + { + png_memset(ptr, 0, (png_size_t)0x8000L); + png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, + (png_size_t)(num_bytes - (png_uint_32)0x8000L)); + } + else + { + png_memset(ptr, 0, (png_size_t)num_bytes); + } +#endif + return ((voidpf)ptr); +} + +/* function to free memory for zlib */ +#ifdef PNG_1_0_X +void PNGAPI +#else +void /* private */ +#endif png_zfree(voidpf png_ptr, voidpf ptr) { - png_free(png_voidcast(png_const_structrp,png_ptr), ptr); + png_free((png_structp)png_ptr, (png_voidp)ptr); } /* Reset the CRC variable to 32 bits of 1's. Care must be taken * in case CRC is > 32 bits to leave the top bits 0. */ void /* PRIVATE */ -png_reset_crc(png_structrp png_ptr) +png_reset_crc(png_structp png_ptr) { - /* The cast is safe because the crc is a 32 bit value. */ - png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0); + png_ptr->crc = crc32(0, Z_NULL, 0); } /* Calculate the CRC over a section of data. We can only pass as @@ -111,675 +202,487 @@ png_reset_crc(png_structrp png_ptr) * trouble of calculating it. */ void /* PRIVATE */ -png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) +png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) { int need_crc = 1; - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)) + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } - - else /* critical */ + else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } - /* 'uLong' is defined in zlib.h as unsigned long; this means that on some - * systems it is a 64 bit value. crc32, however, returns 32 bits so the - * following cast is safe. 'uInt' may be no more than 16 bits, so it is - * necessary to perform a loop here. - */ - if (need_crc && length > 0) - { - uLong crc = png_ptr->crc; /* Should never issue a warning */ - - do - { - uInt safe_length = (uInt)length; - if (safe_length == 0) - safe_length = (uInt)-1; /* evil, but safe */ - - crc = crc32(crc, ptr, safe_length); - - /* The following should never issue compiler warnings; if they do the - * target system has characteristics that will probably violate other - * assumptions within the libpng code. - */ - ptr += safe_length; - length -= safe_length; - } - while (length > 0); - - /* And the following is always safe because the crc is only 32 bits. */ - png_ptr->crc = (png_uint_32)crc; - } + if (need_crc) + png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); } -/* Check a user supplied version number, called from both read and write - * functions that create a png_struct. +/* Allocate the memory for an info_struct for the application. We don't + * really need the png_ptr, but it could potentially be useful in the + * future. This should be used in favour of malloc(png_sizeof(png_info)) + * and png_info_init() so that applications that want to use a shared + * libpng don't have to be recompiled if png_info changes size. */ -int -png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) +png_infop PNGAPI +png_create_info_struct(png_structp png_ptr) { - if (user_png_ver) - { - int i = 0; + png_infop info_ptr; - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - } - - else - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first and third digits (note that when we reach version - * 1.10 we will need to check the fourth symbol, namely user_png_ver[3]). - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] || - user_png_ver[3] != png_libpng_ver[3])) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#ifdef PNG_WARNINGS_SUPPORTED - size_t pos = 0; - char m[128]; - - pos = png_safecat(m, (sizeof m), pos, - "Application built with libpng-"); - pos = png_safecat(m, (sizeof m), pos, user_png_ver); - pos = png_safecat(m, (sizeof m), pos, " but running with "); - pos = png_safecat(m, (sizeof m), pos, png_libpng_ver); - - png_warning(png_ptr, m); + png_debug(1, "in png_create_info_struct\n"); + if(png_ptr == NULL) return (NULL); +#ifdef PNG_USER_MEM_SUPPORTED + info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, + png_ptr->malloc_fn, png_ptr->mem_ptr); +#else + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); #endif - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags = 0; -#endif - - return 0; - } - } - - /* Success return. */ - return 1; -} - -/* Generic function to create a png_struct for either read or write - this - * contains the common initialization. - */ -PNG_FUNCTION(png_structp /* PRIVATE */, -png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) -{ - png_struct create_struct; -# ifdef PNG_SETJMP_SUPPORTED - jmp_buf create_jmp_buf; -# endif - - /* This temporary stack-allocated structure is used to provide a place to - * build enough context to allow the user provided memory allocator (if any) - * to be called. - */ - memset(&create_struct, 0, (sizeof create_struct)); - - /* Added at libpng-1.2.6 */ -# ifdef PNG_USER_LIMITS_SUPPORTED - create_struct.user_width_max = PNG_USER_WIDTH_MAX; - create_struct.user_height_max = PNG_USER_HEIGHT_MAX; - -# ifdef PNG_USER_CHUNK_CACHE_MAX - /* Added at libpng-1.2.43 and 1.4.0 */ - create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; -# endif - -# ifdef PNG_USER_CHUNK_MALLOC_MAX - /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists - * in png_struct regardless. - */ - create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; -# endif -# endif - - /* The following two API calls simply set fields in png_struct, so it is safe - * to do them now even though error handling is not yet set up. - */ -# ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn); -# endif - - /* (*error_fn) can return control to the caller after the error_ptr is set, - * this will result in a memory leak unless the error_fn does something - * extremely sophisticated. The design lacks merit but is implicit in the - * API. - */ - png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn); - -# ifdef PNG_SETJMP_SUPPORTED - if (!setjmp(create_jmp_buf)) - { - /* Temporarily fake out the longjmp information until we have - * successfully completed this function. This only works if we have - * setjmp() support compiled in, but it is safe - this stuff should - * never happen. - */ - create_struct.jmp_buf_ptr = &create_jmp_buf; - create_struct.jmp_buf_size = 0; /*stack allocation*/ - create_struct.longjmp_fn = longjmp; -# else - { -# endif - /* Call the general version checker (shared with read and write code): - */ - if (png_user_version_check(&create_struct, user_png_ver)) - { - png_structrp png_ptr = png_voidcast(png_structrp, - png_malloc_warn(&create_struct, (sizeof *png_ptr))); - - if (png_ptr != NULL) - { - /* png_ptr->zstream holds a back-pointer to the png_struct, so - * this can only be done now: - */ - create_struct.zstream.zalloc = png_zalloc; - create_struct.zstream.zfree = png_zfree; - create_struct.zstream.opaque = png_ptr; - -# ifdef PNG_SETJMP_SUPPORTED - /* Eliminate the local error handling: */ - create_struct.jmp_buf_ptr = NULL; - create_struct.jmp_buf_size = 0; - create_struct.longjmp_fn = 0; -# endif - - *png_ptr = create_struct; - - /* This is the successful return point */ - return png_ptr; - } - } - } - - /* A longjmp because of a bug in the application storage allocator or a - * simple failure to allocate the png_struct. - */ - return NULL; -} - -/* Allocate the memory for an info_struct for the application. */ -PNG_FUNCTION(png_infop,PNGAPI -png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) -{ - png_inforp info_ptr; - - png_debug(1, "in png_create_info_struct"); - - if (png_ptr == NULL) - return NULL; - - /* Use the internal API that does not (or at least should not) error out, so - * that this call always returns ok. The application typically sets up the - * error handling *after* creating the info_struct because this is the way it - * has always been done in 'example.c'. - */ - info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, - (sizeof *info_ptr))); - if (info_ptr != NULL) - memset(info_ptr, 0, (sizeof *info_ptr)); + png_info_init_3(&info_ptr, png_sizeof(png_info)); - return info_ptr; + return (info_ptr); } /* This function frees the memory associated with a single info struct. * Normally, one would use either png_destroy_read_struct() or * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. From libpng 1.6.0 this function is also used - * internally to implement the png_info release part of the 'struct' destroy - * APIs. This ensures that all possible approaches free the same data (all of - * it). + * useful for some applications. */ void PNGAPI -png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) +png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { - png_inforp info_ptr = NULL; - - png_debug(1, "in png_destroy_info_struct"); - - if (png_ptr == NULL) - return; + png_infop info_ptr = NULL; + png_debug(1, "in png_destroy_info_struct\n"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (info_ptr != NULL) { - /* Do this first in case of an error below; if the app implements its own - * memory management this can lead to png_free calling png_error, which - * will abort this routine and return control to the app error handler. - * An infinite loop may result if it then tries to free the same info - * ptr. - */ - *info_ptr_ptr = NULL; + png_info_destroy(png_ptr, info_ptr); - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - memset(info_ptr, 0, (sizeof *info_ptr)); - png_free(png_ptr, info_ptr); +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, + png_ptr->mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; } } /* Initialize the info structure. This is now an internal function (0.89) * and applications using it are urged to use png_create_info_struct() - * instead. Use deprecated in 1.6.0, internal use removed (used internally it - * is just a memset). - * - * NOTE: it is almost inconceivable that this API is used because it bypasses - * the user-memory mechanism and the user error handling/warning mechanisms in - * those cases where it does anything other than a memset. + * instead. */ -PNG_FUNCTION(void,PNGAPI -png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), - PNG_DEPRECATED) +#undef png_info_init +void PNGAPI +png_info_init(png_infop info_ptr) { - png_inforp info_ptr = *ptr_ptr; - - png_debug(1, "in png_info_init_3"); - - if (info_ptr == NULL) - return; - - if ((sizeof (png_info)) > png_info_struct_size) - { - *ptr_ptr = NULL; - /* The following line is why this API should not be used: */ - free(info_ptr); - info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, - (sizeof *info_ptr))); - *ptr_ptr = info_ptr; - } - - /* Set everything to 0 */ - memset(info_ptr, 0, (sizeof *info_ptr)); + /* We only come here via pre-1.0.12-compiled applications */ + png_info_init_3(&info_ptr, 0); } -/* The following API is not called internally */ void PNGAPI -png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, +png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) +{ + png_infop info_ptr = *ptr_ptr; + + png_debug(1, "in png_info_init_3\n"); + + if(png_sizeof(png_info) > png_info_struct_size) + { + png_destroy_struct(info_ptr); + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); + *ptr_ptr = info_ptr; + } + + /* set everything to 0 */ + png_memset(info_ptr, 0, png_sizeof (png_info)); +} + +#ifdef PNG_FREE_ME_SUPPORTED +void PNGAPI +png_data_freer(png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask) { - png_debug(1, "in png_data_freer"); - + png_debug(1, "in png_data_freer\n"); if (png_ptr == NULL || info_ptr == NULL) return; - - if (freer == PNG_DESTROY_WILL_FREE_DATA) + if(freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; - - else if (freer == PNG_USER_WILL_FREE_DATA) + else if(freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; - else - png_error(png_ptr, "Unknown freer parameter in png_data_freer"); + png_warning(png_ptr, + "Unknown freer parameter in png_data_freer."); } +#endif void PNGAPI -png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, +png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) { - png_debug(1, "in png_free_data"); - + png_debug(1, "in png_free_data\n"); if (png_ptr == NULL || info_ptr == NULL) return; -#ifdef PNG_TEXT_SUPPORTED - /* Free text item num or (if num == -1) all text items */ - if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) - { - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } - } +#if defined(PNG_TEXT_SUPPORTED) +/* free text item num or (if num == -1) all text items */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_TEXT) #endif - -#ifdef PNG_tRNS_SUPPORTED - /* Free any tRNS entry */ - if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->trans_alpha); - info_ptr->trans_alpha = NULL; - info_ptr->valid &= ~PNG_INFO_tRNS; - } -#endif - -#ifdef PNG_sCAL_SUPPORTED - /* Free any sCAL entry */ - if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; - info_ptr->valid &= ~PNG_INFO_sCAL; - } -#endif - -#ifdef PNG_pCAL_SUPPORTED - /* Free any pCAL entry */ - if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - unsigned int i; - for (i = 0; i < info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i] = NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; - } -#endif - -#ifdef PNG_iCCP_SUPPORTED - /* Free any profile entry */ - if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; - } -#endif - -#ifdef PNG_sPLT_SUPPORTED - /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ - if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) - { - if (num != -1) - { - if (info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - - else - { - if (info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, (int)i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } - } -#endif - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) - { - if (num != -1) - { - if (info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - - else - { - int i; - - if (info_ptr->unknown_chunks_num) - { - for (i = 0; i < info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, (int)i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } - } -#endif - -#ifdef PNG_hIST_SUPPORTED - /* Free any hIST entry */ - if ((mask & PNG_FREE_HIST) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; - } -#endif - - /* Free any PLTE entry that was internally allocated */ - if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) - { - png_free(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; - info_ptr->num_palette = 0; - } - -#ifdef PNG_INFO_IMAGE_SUPPORTED - /* Free any image bits attached to the info structure */ - if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) - { - if (info_ptr->row_pointers) - { - png_uint_32 row; - for (row = 0; row < info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row] = NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers = NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; - } -#endif - +{ if (num != -1) - mask &= ~PNG_FREE_MUL; - - info_ptr->free_me &= ~mask; + { + if (info_ptr->text && info_ptr->text[num].key) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + } + else + { + int i; + for (i = 0; i < info_ptr->num_text; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text=0; + } +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +/* free any tRNS entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) +#endif +{ + png_free(png_ptr, info_ptr->trans); + info_ptr->valid &= ~PNG_INFO_tRNS; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif + info_ptr->trans = NULL; +} +#endif + +#if defined(PNG_sCAL_SUPPORTED) +/* free any sCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SCAL) +#endif +{ +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; +#endif + info_ptr->valid &= ~PNG_INFO_sCAL; +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +/* free any pCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_PCAL) +#endif +{ + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + if (info_ptr->pcal_params != NULL) + { + int i; + for (i = 0; i < (int)info_ptr->pcal_nparams; i++) + { + png_free(png_ptr, info_ptr->pcal_params[i]); + info_ptr->pcal_params[i]=NULL; + } + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; +} +#endif + +#if defined(PNG_iCCP_SUPPORTED) +/* free any iCCP entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ICCP) +#endif +{ + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +/* free a given sPLT entry, or (if num == -1) all sPLT entries */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SPLT) +#endif +{ + if (num != -1) + { + if(info_ptr->splt_palettes) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } + } + else + { + if(info_ptr->splt_palettes_num) + { + int i; + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + } + info_ptr->valid &= ~PNG_INFO_sPLT; + } +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) +#else +if (mask & PNG_FREE_UNKN) +#endif +{ + if (num != -1) + { + if(info_ptr->unknown_chunks) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + } + else + { + int i; + + if(info_ptr->unknown_chunks_num) + { + for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +/* free any hIST entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_HIST) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) +#endif +{ + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +} +#endif + +/* free any PLTE entry that was internally allocated */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) +#endif +{ + png_zfree(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif + info_ptr->num_palette = 0; +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* free any image bits attached to the info structure */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ROWS) +#endif +{ + if(info_ptr->row_pointers) + { + int row; + for (row = 0; row < (int)info_ptr->height; row++) + { + png_free(png_ptr, info_ptr->row_pointers[row]); + info_ptr->row_pointers[row]=NULL; + } + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers=NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; +} +#endif + +#ifdef PNG_FREE_ME_SUPPORTED + if(num == -1) + info_ptr->free_me &= ~mask; + else + info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); +#endif +} + +/* This is an internal routine to free any memory that the info struct is + * pointing to before re-using it or freeing the struct itself. Recall + * that png_free() checks for NULL pointers for us. + */ +void /* PRIVATE */ +png_info_destroy(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_info_destroy\n"); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } +#endif + + png_info_init_3(&info_ptr, png_sizeof(png_info)); } -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ /* This function returns a pointer to the io_ptr associated with the user * functions. The application should free any memory associated with this * pointer before png_write_destroy() or png_read_destroy() are called. */ png_voidp PNGAPI -png_get_io_ptr(png_const_structrp png_ptr) +png_get_io_ptr(png_structp png_ptr) { - if (png_ptr == NULL) - return (NULL); - return (png_ptr->io_ptr); } -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -# ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) /* Initialize the default input/output functions for the PNG file. If you * use your own read or write routines, you can call either png_set_read_fn() * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a - * function of your own because "FILE *" isn't necessarily available. + * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't + * necessarily available. */ void PNGAPI -png_init_io(png_structrp png_ptr, png_FILE_p fp) +png_init_io(png_structp png_ptr, png_FILE_p fp) { - png_debug(1, "in png_init_io"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_init_io\n"); png_ptr->io_ptr = (png_voidp)fp; } -# endif - -#ifdef PNG_SAVE_INT_32_SUPPORTED -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. Note that, - * the following works correctly even if png_int_32 has more than 32 bits - * (compare the more complex code required on read for sign extension.) - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} #endif -# ifdef PNG_TIME_RFC1123_SUPPORTED +#if defined(PNG_TIME_RFC1123_SUPPORTED) /* Convert the supplied time into an RFC 1123 string suitable for use in * a "Creation Time" or other text-based time string. */ -int PNGAPI -png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) +png_charp PNGAPI +png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) { static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if (out == NULL) - return 0; - - if (ptime->year > 9999 /* RFC1123 limitation */ || - ptime->month == 0 || ptime->month > 12 || - ptime->day == 0 || ptime->day > 31 || - ptime->hour > 23 || ptime->minute > 59 || - ptime->second > 60) - return 0; - + if (png_ptr->time_buffer == NULL) { - size_t pos = 0; - char number_buf[5]; /* enough for a four-digit year */ - -# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string)) -# define APPEND_NUMBER(format, value)\ - APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value))) -# define APPEND(ch) if (pos < 28) out[pos++] = (ch) - - APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day); - APPEND(' '); - APPEND_STRING(short_months[(ptime->month - 1)]); - APPEND(' '); - APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year); - APPEND(' '); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour); - APPEND(':'); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute); - APPEND(':'); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second); - APPEND_STRING(" +0000"); /* This reliably terminates the buffer */ - -# undef APPEND -# undef APPEND_NUMBER -# undef APPEND_STRING + png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* + png_sizeof(char))); } - return 1; -} - -# if PNG_LIBPNG_VER < 10700 -/* To do: remove the following from libpng-1.7 */ -/* Original API that uses a private buffer in png_struct. - * Deprecated because it causes png_struct to carry a spurious temporary - * buffer (png_struct::time_buffer), better to have the caller pass this in. - */ -png_const_charp PNGAPI -png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) -{ - if (png_ptr != NULL) +#if defined(_WIN32_WCE) { - /* The only failure above if png_ptr != NULL is from an invalid ptime */ - if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime)) - png_warning(png_ptr, "Ignoring invalid time value"); - - else - return png_ptr->time_buffer; + wchar_t time_buf[29]; + wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, + NULL, NULL); } - - return NULL; -} -# endif -# endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -png_const_charp PNGAPI -png_get_copyright(png_const_structrp png_ptr) -{ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ -#ifdef PNG_STRING_COPYRIGHT - return PNG_STRING_COPYRIGHT #else -# ifdef __STDC__ - return PNG_STRING_NEWLINE \ - "libpng version 1.6.2 - April 25, 2013" PNG_STRING_NEWLINE \ - "Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ - "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ - "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ - PNG_STRING_NEWLINE; -# else - return "libpng version 1.6.2 - April 25, 2013\ - Copyright (c) 1998-2013 Glenn Randers-Pehrson\ - Copyright (c) 1996-1997 Andreas Dilger\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; -# endif +#ifdef USE_FAR_KEYWORD + { + char near_time_buf[29]; + sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + png_memcpy(png_ptr->time_buffer, near_time_buf, + 29*png_sizeof(char)); + } +#else + sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); #endif +#endif /* _WIN32_WCE */ + return ((png_charp)png_ptr->time_buffer); +} +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + +#if 0 +/* Signature string for a PNG file. */ +png_bytep PNGAPI +png_sig_bytes(void) +{ + return ((png_bytep)"\211\120\116\107\015\012\032\012"); +} +#endif + +png_charp PNGAPI +png_get_copyright(png_structp png_ptr) +{ + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) "\n libpng version 1.2.7 - September 12, 2004\n\ + Copyright (c) 1998-2004 Glenn Randers-Pehrson\n\ + Copyright (c) 1996-1997 Andreas Dilger\n\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); + return ((png_charp) ""); } /* The following return the library version as a short string in the @@ -790,3509 +693,134 @@ png_get_copyright(png_const_structrp png_ptr) * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, * it is guaranteed that png.c uses the correct version of png.h. */ -png_const_charp PNGAPI -png_get_libpng_ver(png_const_structrp png_ptr) +png_charp PNGAPI +png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ - return png_get_header_ver(png_ptr); + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); + return ((png_charp) ""); } -png_const_charp PNGAPI -png_get_header_ver(png_const_structrp png_ptr) +png_charp PNGAPI +png_get_header_ver(png_structp png_ptr) { /* Version of *.h files used when building libpng */ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ - return PNG_LIBPNG_VER_STRING; + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); + return ((png_charp) ""); } -png_const_charp PNGAPI -png_get_header_version(png_const_structrp png_ptr) +png_charp PNGAPI +png_get_header_version(png_structp png_ptr) { /* Returns longer string containing both version and date */ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ -#ifdef __STDC__ - return PNG_HEADER_VERSION_STRING -# ifndef PNG_READ_SUPPORTED - " (NO READ SUPPORT)" -# endif - PNG_STRING_NEWLINE; -#else - return PNG_HEADER_VERSION_STRING; -#endif + if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_HEADER_VERSION_STRING); + return ((png_charp) ""); } -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED int PNGAPI -png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name) +png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) { - /* Check chunk_name and return "keep" value if it's on the list, else 0 */ - png_const_bytep p, p_end; - - if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0) - return PNG_HANDLE_CHUNK_AS_DEFAULT; - - p_end = png_ptr->chunk_list; - p = p_end + png_ptr->num_chunk_list*5; /* beyond end */ - - /* The code is the fifth byte after each four byte string. Historically this - * code was always searched from the end of the list, this is no longer - * necessary because the 'set' routine handles duplicate entries correcty. - */ - do /* num_chunk_list > 0, so at least one */ - { - p -= 5; - - if (!memcmp(chunk_name, p, 4)) - return p[4]; - } - while (p > p_end); - - /* This means that known chunks should be processed and unknown chunks should - * be handled according to the value of png_ptr->unknown_default; this can be - * confusing because, as a result, there are two levels of defaulting for - * unknown chunks. - */ - return PNG_HANDLE_CHUNK_AS_DEFAULT; + /* check chunk_name and return "keep" value if it's on the list, else 0 */ + int i; + png_bytep p; + if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) + return 0; + p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; + for (i = png_ptr->num_chunk_list; i; i--, p-=5) + if (!png_memcmp(chunk_name, p, 4)) + return ((int)*(p+4)); + return 0; } +#endif -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -int /* PRIVATE */ -png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name) -{ - png_byte chunk_string[5]; - - PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name); - return png_handle_as_unknown(png_ptr, chunk_string); -} -#endif /* READ_UNKNOWN_CHUNKS */ -#endif /* SET_UNKNOWN_CHUNKS */ - -#ifdef PNG_READ_SUPPORTED /* This function, added to libpng-1.0.6g, is untested. */ int PNGAPI -png_reset_zstream(png_structrp png_ptr) +png_reset_zstream(png_structp png_ptr) { - if (png_ptr == NULL) - return Z_STREAM_ERROR; - - /* WARNING: this resets the window bits to the maximum! */ return (inflateReset(&png_ptr->zstream)); } -#endif /* PNG_READ_SUPPORTED */ /* This function was added to libpng-1.0.7 */ png_uint_32 PNGAPI png_access_version_number(void) { /* Version of *.c files used when building libpng */ - return((png_uint_32)PNG_LIBPNG_VER); + return((png_uint_32) PNG_LIBPNG_VER); } - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Ensure that png_ptr->zstream.msg holds some appropriate error message string. - * If it doesn't 'ret' is used to set it to something appropriate, even in cases - * like Z_OK or Z_STREAM_END where the error code is apparently a success code. - */ +#if !defined(PNG_1_0_X) +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ +/* this INTERNAL function was added to libpng 1.2.0 */ void /* PRIVATE */ -png_zstream_error(png_structrp png_ptr, int ret) +png_init_mmx_flags (png_structp png_ptr) { - /* Translate 'ret' into an appropriate error string, priority is given to the - * one in zstream if set. This always returns a string, even in cases like - * Z_OK or Z_STREAM_END where the error code is a success code. - */ - if (png_ptr->zstream.msg == NULL) switch (ret) - { - default: - case Z_OK: - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code"); - break; + png_ptr->mmx_rowbytes_threshold = 0; + png_ptr->mmx_bitdepth_threshold = 0; - case Z_STREAM_END: - /* Normal exit */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream"); - break; +# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) - case Z_NEED_DICT: - /* This means the deflate stream did not have a dictionary; this - * indicates a bogus PNG. - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary"); - break; + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; - case Z_ERRNO: - /* gz APIs only: should not happen */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error"); - break; + if (png_mmx_support() > 0) { + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU +# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW +# endif +# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + | PNG_ASM_FLAG_MMX_READ_INTERLACE +# endif +# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + ; +# else + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB + | PNG_ASM_FLAG_MMX_READ_FILTER_UP + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - case Z_STREAM_ERROR: - /* internal libpng error */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib"); - break; + png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; + png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; +# endif + } else { + png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU + | PNG_MMX_READ_FLAGS + | PNG_MMX_WRITE_FLAGS ); + } - case Z_DATA_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream"); - break; +# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */ - case Z_MEM_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory"); - break; + /* clear all MMX flags; no support is compiled in */ + png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - case Z_BUF_ERROR: - /* End of input or output; not a problem if the caller is doing - * incremental read or write. - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated"); - break; - - case Z_VERSION_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version"); - break; - - case PNG_UNEXPECTED_ZLIB_RETURN: - /* Compile errors here mean that zlib now uses the value co-opted in - * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above - * and change pngpriv.h. Note that this message is "... return", - * whereas the default/Z_OK one is "... return code". - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return"); - break; - } +# endif /* ?(PNGVCRD || PNGGCCRD) */ } -/* png_convert_size: a PNGAPI but no longer in png.h, so deleted - * at libpng 1.5.5! - */ +#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */ -/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ -#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ -static int -png_colorspace_check_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA, int from) - /* This is called to check a new gamma value against an existing one. The - * routine returns false if the new gamma value should not be written. - * - * 'from' says where the new gamma value comes from: - * - * 0: the new gamma value is the libpng estimate for an ICC profile - * 1: the new gamma value comes from a gAMA chunk - * 2: the new gamma value comes from an sRGB chunk - */ -{ - png_fixed_point gtest; - - if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - (!png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) || - png_gamma_significant(gtest))) - { - /* Either this is an sRGB image, in which case the calculated gamma - * approximation should match, or this is an image with a profile and the - * value libpng calculates for the gamma of the profile does not match the - * value recorded in the file. The former, sRGB, case is an error, the - * latter is just a warning. - */ - if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) - { - png_chunk_report(png_ptr, "gamma value does not match sRGB", - PNG_CHUNK_ERROR); - /* Do not overwrite an sRGB value */ - return from == 2; - } - - else /* sRGB tag not involved */ - { - png_chunk_report(png_ptr, "gamma value does not match libpng estimate", - PNG_CHUNK_WARNING); - return from == 1; - } - } - - return 1; -} - -void /* PRIVATE */ -png_colorspace_set_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA) -{ - /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't - * occur. Since the fixed point representation is assymetrical it is - * possible for 1/gamma to overflow the limit of 21474 and this means the - * gamma value must be at least 5/100000 and hence at most 20000.0. For - * safety the limits here are a little narrower. The values are 0.00016 to - * 6250.0, which are truly ridiculous gamma values (and will produce - * displays that are all black or all white.) - * - * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk - * handling code, which only required the value to be >0. - */ - png_const_charp errmsg; - - if (gAMA < 16 || gAMA > 625000000) - errmsg = "gamma value out of range"; - -# ifdef PNG_READ_gAMA_SUPPORTED - /* Allow the application to set the gamma value more than once */ - else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0) - errmsg = "duplicate"; -# endif - - /* Do nothing if the colorspace is already invalid */ - else if (colorspace->flags & PNG_COLORSPACE_INVALID) - return; - - else - { - if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, 1/*from gAMA*/)) - { - /* Store this gamma value. */ - colorspace->gamma = gAMA; - colorspace->flags |= - (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA); - } - - /* At present if the check_gamma test fails the gamma of the colorspace is - * not updated however the colorspace is not invalidated. This - * corresponds to the case where the existing gamma comes from an sRGB - * chunk or profile. An error message has already been output. - */ - return; - } - - /* Error exit - errmsg has been set. */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR); -} - -void /* PRIVATE */ -png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr) -{ - if (info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) - { - /* Everything is invalid */ - info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB| - PNG_INFO_iCCP); - -# ifdef PNG_COLORSPACE_SUPPORTED - /* Clean up the iCCP profile now if it won't be used. */ - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/); -# else - PNG_UNUSED(png_ptr) -# endif - } - - else - { -# ifdef PNG_COLORSPACE_SUPPORTED - /* Leave the INFO_iCCP flag set if the pngset.c code has already set - * it; this allows a PNG to contain a profile which matches sRGB and - * yet still have that profile retrievable by the application. - */ - if (info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) - info_ptr->valid |= PNG_INFO_sRGB; - - else - info_ptr->valid &= ~PNG_INFO_sRGB; - - if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) - info_ptr->valid |= PNG_INFO_cHRM; - - else - info_ptr->valid &= ~PNG_INFO_cHRM; -# endif - - if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) - info_ptr->valid |= PNG_INFO_gAMA; - - else - info_ptr->valid &= ~PNG_INFO_gAMA; - } -} - -#ifdef PNG_READ_SUPPORTED -void /* PRIVATE */ -png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) -{ - if (info_ptr == NULL) /* reduce code size; check here not in the caller */ - return; - - info_ptr->colorspace = png_ptr->colorspace; - png_colorspace_sync_info(png_ptr, info_ptr); -} -#endif -#endif - -#ifdef PNG_COLORSPACE_SUPPORTED -/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for - * cHRM, as opposed to using chromaticities. These internal APIs return - * non-zero on a parameter error. The X, Y and Z values are required to be - * positive and less than 1.0. - */ -static int -png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) -{ - png_int_32 d, dwhite, whiteX, whiteY; - - d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z; - if (!png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d)) return 1; - if (!png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d)) return 1; - dwhite = d; - whiteX = XYZ->red_X; - whiteY = XYZ->red_Y; - - d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z; - if (!png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d)) return 1; - if (!png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d)) return 1; - dwhite += d; - whiteX += XYZ->green_X; - whiteY += XYZ->green_Y; - - d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z; - if (!png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d)) return 1; - if (!png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d)) return 1; - dwhite += d; - whiteX += XYZ->blue_X; - whiteY += XYZ->blue_Y; - - /* The reference white is simply the sum of the end-point (X,Y,Z) vectors, - * thus: - */ - if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1; - if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1; - - return 0; -} - -static int -png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) -{ - png_fixed_point red_inverse, green_inverse, blue_scale; - png_fixed_point left, right, denominator; - - /* Check xy and, implicitly, z. Note that wide gamut color spaces typically - * have end points with 0 tristimulus values (these are impossible end - * points, but they are used to cover the possible colors.) - */ - if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; - if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; - if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; - if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; - if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; - if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; - if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; - if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1; - - /* The reverse calculation is more difficult because the original tristimulus - * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 - * derived values were recorded in the cHRM chunk; - * (red,green,blue,white)x(x,y). This loses one degree of freedom and - * therefore an arbitrary ninth value has to be introduced to undo the - * original transformations. - * - * Think of the original end-points as points in (X,Y,Z) space. The - * chromaticity values (c) have the property: - * - * C - * c = --------- - * X + Y + Z - * - * For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the - * three chromaticity values (x,y,z) for each end-point obey the - * relationship: - * - * x + y + z = 1 - * - * This describes the plane in (X,Y,Z) space that intersects each axis at the - * value 1.0; call this the chromaticity plane. Thus the chromaticity - * calculation has scaled each end-point so that it is on the x+y+z=1 plane - * and chromaticity is the intersection of the vector from the origin to the - * (X,Y,Z) value with the chromaticity plane. - * - * To fully invert the chromaticity calculation we would need the three - * end-point scale factors, (red-scale, green-scale, blue-scale), but these - * were not recorded. Instead we calculated the reference white (X,Y,Z) and - * recorded the chromaticity of this. The reference white (X,Y,Z) would have - * given all three of the scale factors since: - * - * color-C = color-c * color-scale - * white-C = red-C + green-C + blue-C - * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale - * - * But cHRM records only white-x and white-y, so we have lost the white scale - * factor: - * - * white-C = white-c*white-scale - * - * To handle this the inverse transformation makes an arbitrary assumption - * about white-scale: - * - * Assume: white-Y = 1.0 - * Hence: white-scale = 1/white-y - * Or: red-Y + green-Y + blue-Y = 1.0 - * - * Notice the last statement of the assumption gives an equation in three of - * the nine values we want to calculate. 8 more equations come from the - * above routine as summarised at the top above (the chromaticity - * calculation): - * - * Given: color-x = color-X / (color-X + color-Y + color-Z) - * Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0 - * - * This is 9 simultaneous equations in the 9 variables "color-C" and can be - * solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix - * determinants, however this is not as bad as it seems because only 28 of - * the total of 90 terms in the various matrices are non-zero. Nevertheless - * Cramer's rule is notoriously numerically unstable because the determinant - * calculation involves the difference of large, but similar, numbers. It is - * difficult to be sure that the calculation is stable for real world values - * and it is certain that it becomes unstable where the end points are close - * together. - * - * So this code uses the perhaps slightly less optimal but more - * understandable and totally obvious approach of calculating color-scale. - * - * This algorithm depends on the precision in white-scale and that is - * (1/white-y), so we can immediately see that as white-y approaches 0 the - * accuracy inherent in the cHRM chunk drops off substantially. - * - * libpng arithmetic: a simple invertion of the above equations - * ------------------------------------------------------------ - * - * white_scale = 1/white-y - * white-X = white-x * white-scale - * white-Y = 1.0 - * white-Z = (1 - white-x - white-y) * white_scale - * - * white-C = red-C + green-C + blue-C - * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale - * - * This gives us three equations in (red-scale,green-scale,blue-scale) where - * all the coefficients are now known: - * - * red-x*red-scale + green-x*green-scale + blue-x*blue-scale - * = white-x/white-y - * red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1 - * red-z*red-scale + green-z*green-scale + blue-z*blue-scale - * = (1 - white-x - white-y)/white-y - * - * In the last equation color-z is (1 - color-x - color-y) so we can add all - * three equations together to get an alternative third: - * - * red-scale + green-scale + blue-scale = 1/white-y = white-scale - * - * So now we have a Cramer's rule solution where the determinants are just - * 3x3 - far more tractible. Unfortunately 3x3 determinants still involve - * multiplication of three coefficients so we can't guarantee to avoid - * overflow in the libpng fixed point representation. Using Cramer's rule in - * floating point is probably a good choice here, but it's not an option for - * fixed point. Instead proceed to simplify the first two equations by - * eliminating what is likely to be the largest value, blue-scale: - * - * blue-scale = white-scale - red-scale - green-scale - * - * Hence: - * - * (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale = - * (white-x - blue-x)*white-scale - * - * (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale = - * 1 - blue-y*white-scale - * - * And now we can trivially solve for (red-scale,green-scale): - * - * green-scale = - * (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale - * ----------------------------------------------------------- - * green-x - blue-x - * - * red-scale = - * 1 - blue-y*white-scale - (green-y - blue-y) * green-scale - * --------------------------------------------------------- - * red-y - blue-y - * - * Hence: - * - * red-scale = - * ( (green-x - blue-x) * (white-y - blue-y) - - * (green-y - blue-y) * (white-x - blue-x) ) / white-y - * ------------------------------------------------------------------------- - * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) - * - * green-scale = - * ( (red-y - blue-y) * (white-x - blue-x) - - * (red-x - blue-x) * (white-y - blue-y) ) / white-y - * ------------------------------------------------------------------------- - * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) - * - * Accuracy: - * The input values have 5 decimal digits of accuracy. The values are all in - * the range 0 < value < 1, so simple products are in the same range but may - * need up to 10 decimal digits to preserve the original precision and avoid - * underflow. Because we are using a 32-bit signed representation we cannot - * match this; the best is a little over 9 decimal digits, less than 10. - * - * The approach used here is to preserve the maximum precision within the - * signed representation. Because the red-scale calculation above uses the - * difference between two products of values that must be in the range -1..+1 - * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The - * factor is irrelevant in the calculation because it is applied to both - * numerator and denominator. - * - * Note that the values of the differences of the products of the - * chromaticities in the above equations tend to be small, for example for - * the sRGB chromaticities they are: - * - * red numerator: -0.04751 - * green numerator: -0.08788 - * denominator: -0.2241 (without white-y multiplication) - * - * The resultant Y coefficients from the chromaticities of some widely used - * color space definitions are (to 15 decimal places): - * - * sRGB - * 0.212639005871510 0.715168678767756 0.072192315360734 - * Kodak ProPhoto - * 0.288071128229293 0.711843217810102 0.000085653960605 - * Adobe RGB - * 0.297344975250536 0.627363566255466 0.075291458493998 - * Adobe Wide Gamut RGB - * 0.258728243040113 0.724682314948566 0.016589442011321 - */ - /* By the argument, above overflow should be impossible here. The return - * value of 2 indicates an internal error to the caller. - */ - if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7)) - return 2; - if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7)) - return 2; - denominator = left - right; - - /* Now find the red numerator. */ - if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7)) - return 2; - if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7)) - return 2; - - /* Overflow is possible here and it indicates an extreme set of PNG cHRM - * chunk values. This calculation actually returns the reciprocal of the - * scale value because this allows us to delay the multiplication of white-y - * into the denominator, which tends to produce a small number. - */ - if (!png_muldiv(&red_inverse, xy->whitey, denominator, left-right) || - red_inverse <= xy->whitey /* r+g+b scales = white scale */) - return 1; - - /* Similarly for green_inverse: */ - if (!png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7)) - return 2; - if (!png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7)) - return 2; - if (!png_muldiv(&green_inverse, xy->whitey, denominator, left-right) || - green_inverse <= xy->whitey) - return 1; - - /* And the blue scale, the checks above guarantee this can't overflow but it - * can still produce 0 for extreme cHRM values. - */ - blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) - - png_reciprocal(green_inverse); - if (blue_scale <= 0) return 1; - - - /* And fill in the png_XYZ: */ - if (!png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse)) return 1; - if (!png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse)) return 1; - if (!png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1, - red_inverse)) - return 1; - - if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse)) - return 1; - if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse)) - return 1; - if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1, - green_inverse)) - return 1; - - if (!png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1)) return 1; - if (!png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1)) return 1; - if (!png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale, - PNG_FP_1)) - return 1; - - return 0; /*success*/ -} - -static int -png_XYZ_normalize(png_XYZ *XYZ) -{ - png_int_32 Y; - - if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 || - XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 || - XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0) - return 1; - - /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. - * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore - * relying on addition of two positive values producing a negative one is not - * safe. - */ - Y = XYZ->red_Y; - if (0x7fffffff - Y < XYZ->green_X) return 1; - Y += XYZ->green_Y; - if (0x7fffffff - Y < XYZ->blue_X) return 1; - Y += XYZ->blue_Y; - - if (Y != PNG_FP_1) - { - if (!png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y)) return 1; - - if (!png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y)) return 1; - - if (!png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y)) return 1; - if (!png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y)) return 1; - } - - return 0; -} - -static int -png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta) -{ - /* Allow an error of +/-0.01 (absolute value) on each chromaticity */ - return !(PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) || - PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) || - PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) || - PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) || - PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) || - PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) || - PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) || - PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta)); -} - -/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM - * chunk chromaticities. Earlier checks used to simply look for the overflow - * condition (where the determinant of the matrix to solve for XYZ ends up zero - * because the chromaticity values are not all distinct.) Despite this it is - * theoretically possible to produce chromaticities that are apparently valid - * but that rapidly degrade to invalid, potentially crashing, sets because of - * arithmetic inaccuracies when calculations are performed on them. The new - * check is to round-trip xy -> XYZ -> xy and then check that the result is - * within a small percentage of the original. - */ -static int -png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy) -{ - int result; - png_xy xy_test; - - /* As a side-effect this routine also returns the XYZ endpoints. */ - result = png_XYZ_from_xy(XYZ, xy); - if (result) return result; - - result = png_xy_from_XYZ(&xy_test, XYZ); - if (result) return result; - - if (png_colorspace_endpoints_match(xy, &xy_test, - 5/*actually, the math is pretty accurate*/)) - return 0; - - /* Too much slip */ - return 1; -} - -/* This is the check going the other way. The XYZ is modified to normalize it - * (another side-effect) and the xy chromaticities are returned. - */ -static int -png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ) -{ - int result; - png_XYZ XYZtemp; - - result = png_XYZ_normalize(XYZ); - if (result) return result; - - result = png_xy_from_XYZ(xy, XYZ); - if (result) return result; - - XYZtemp = *XYZ; - return png_colorspace_check_xy(&XYZtemp, xy); -} - -/* Used to check for an endpoint match against sRGB */ -static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ -{ - /* color x y */ - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000, - /* white */ 31270, 32900 -}; - -static int -png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, - int preferred) -{ - if (colorspace->flags & PNG_COLORSPACE_INVALID) - return 0; - - /* The consistency check is performed on the chromaticities; this factors out - * variations because of the normalization (or not) of the end point Y - * values. - */ - if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) - { - /* The end points must be reasonably close to any we already have. The - * following allows an error of up to +/-.001 - */ - if (!png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, 100)) - { - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "inconsistent chromaticities"); - return 0; /* failed */ - } - - /* Only overwrite with preferred values */ - if (!preferred) - return 1; /* ok, but no change */ - } - - colorspace->end_points_xy = *xy; - colorspace->end_points_XYZ = *XYZ; - colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS; - - /* The end points are normally quoted to two decimal digits, so allow +/-0.01 - * on this test. - */ - if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000)) - colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB; - - else - colorspace->flags &= PNG_COLORSPACE_CANCEL( - PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); - - return 2; /* ok and changed */ -} - -int /* PRIVATE */ -png_colorspace_set_chromaticities(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, int preferred) -{ - /* We must check the end points to ensure they are reasonable - in the past - * color management systems have crashed as a result of getting bogus - * colorant values, while this isn't the fault of libpng it is the - * responsibility of libpng because PNG carries the bomb and libpng is in a - * position to protect against it. - */ - png_XYZ XYZ; - - switch (png_colorspace_check_xy(&XYZ, xy)) - { - case 0: /* success */ - return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, - preferred); - - case 1: - /* We can't invert the chromaticities so we can't produce value XYZ - * values. Likely as not a color management system will fail too. - */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "invalid chromaticities"); - break; - - default: - /* libpng is broken; this should be a warning but if it happens we - * want error reports so for the moment it is an error. - */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_error(png_ptr, "internal error checking chromaticities"); - break; - } - - return 0; /* failed */ -} - -int /* PRIVATE */ -png_colorspace_set_endpoints(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) -{ - png_XYZ XYZ = *XYZ_in; - png_xy xy; - - switch (png_colorspace_check_XYZ(&xy, &XYZ)) - { - case 0: - return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, - preferred); - - case 1: - /* End points are invalid. */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "invalid end points"); - break; - - default: - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_error(png_ptr, "internal error checking chromaticities"); - break; - } - - return 0; /* failed */ -} - -#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED) -/* Error message generation */ -static char -png_icc_tag_char(png_uint_32 byte) -{ - byte &= 0xff; - if (byte >= 32 && byte <= 126) - return (char)byte; - else - return '?'; -} - -static void -png_icc_tag_name(char *name, png_uint_32 tag) -{ - name[0] = '\''; - name[1] = png_icc_tag_char(tag >> 24); - name[2] = png_icc_tag_char(tag >> 16); - name[3] = png_icc_tag_char(tag >> 8); - name[4] = png_icc_tag_char(tag ); - name[5] = '\''; -} - -static int -is_ICC_signature_char(png_alloc_size_t it) -{ - return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) || - (it >= 97 && it <= 122); -} - -static int is_ICC_signature(png_alloc_size_t it) -{ - return is_ICC_signature_char(it >> 24) /* checks all the top bits */ && - is_ICC_signature_char((it >> 16) & 0xff) && - is_ICC_signature_char((it >> 8) & 0xff) && - is_ICC_signature_char(it & 0xff); -} - -static int -png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_alloc_size_t value, png_const_charp reason) -{ - size_t pos; - char message[196]; /* see below for calculation */ - - if (colorspace != NULL) - colorspace->flags |= PNG_COLORSPACE_INVALID; - - pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */ - pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */ - pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */ - if (is_ICC_signature(value)) - { - /* So 'value' is at most 4 bytes and the following cast is safe */ - png_icc_tag_name(message+pos, (png_uint_32)value); - pos += 6; /* total +8; less than the else clause */ - message[pos++] = ':'; - message[pos++] = ' '; - } -# ifdef PNG_WARNINGS_SUPPORTED - else - { - char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ - - pos = png_safecat(message, (sizeof message), pos, - png_format_number(number, number+(sizeof number), - PNG_NUMBER_FORMAT_x, value)); - pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ - } -# endif - /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ - pos = png_safecat(message, (sizeof message), pos, reason); - - /* This is recoverable, but make it unconditionally an app_error on write to - * avoid writing invalid ICC profiles into PNG files. (I.e. we handle them - * on read, with a warning, but on write unless the app turns off - * application errors the PNG won't be written.) - */ - png_chunk_report(png_ptr, message, - (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); - - return 0; -} -#endif /* sRGB || iCCP */ - -#ifdef PNG_sRGB_SUPPORTED -int /* PRIVATE */ -png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, - int intent) -{ - /* sRGB sets known gamma, end points and (from the chunk) intent. */ - /* IMPORTANT: these are not necessarily the values found in an ICC profile - * because ICC profiles store values adapted to a D50 environment; it is - * expected that the ICC profile mediaWhitePointTag will be D50, see the - * checks and code elsewhere to understand this better. - * - * These XYZ values, which are accurate to 5dp, produce rgb to gray - * coefficients of (6968,23435,2366), which are reduced (because they add up - * to 32769 not 32768) to (6968,23434,2366). These are the values that - * libpng has traditionally used (and are the best values given the 15bit - * algorithm used by the rgb to gray code.) - */ - static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */ - { - /* color X Y Z */ - /* red */ 41239, 21264, 1933, - /* green */ 35758, 71517, 11919, - /* blue */ 18048, 7219, 95053 - }; - - /* Do nothing if the colorspace is already invalidated. */ - if (colorspace->flags & PNG_COLORSPACE_INVALID) - return 0; - - /* Check the intent, then check for existing settings. It is valid for the - * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must - * be consistent with the correct values. If, however, this function is - * called below because an iCCP chunk matches sRGB then it is quite - * conceivable that an older app recorded incorrect gAMA and cHRM because of - * an incorrect calculation based on the values in the profile - this does - * *not* invalidate the profile (though it still produces an error, which can - * be ignored.) - */ - if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) - return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "invalid sRGB rendering intent"); - - if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && - colorspace->rendering_intent != intent) - return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "inconsistent rendering intents"); - - if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0) - { - png_benign_error(png_ptr, "duplicate sRGB information ignored"); - return 0; - } - - /* If the standard sRGB cHRM chunk does not match the one from the PNG file - * warn but overwrite the value with the correct one. - */ - if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && - !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, - 100)) - png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", - PNG_CHUNK_ERROR); - - /* This check is just done for the error reporting - the routine always - * returns true when the 'from' argument corresponds to sRGB (2). - */ - (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, - 2/*from sRGB*/); - - /* intent: bugs in GCC force 'int' to be used as the parameter type. */ - colorspace->rendering_intent = (png_uint_16)intent; - colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT; - - /* endpoints */ - colorspace->end_points_xy = sRGB_xy; - colorspace->end_points_XYZ = sRGB_XYZ; - colorspace->flags |= - (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); - - /* gamma */ - colorspace->gamma = PNG_GAMMA_sRGB_INVERSE; - colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA; - - /* Finally record that we have an sRGB profile */ - colorspace->flags |= - (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB); - - return 1; /* set */ -} -#endif /* sRGB */ - -#ifdef PNG_iCCP_SUPPORTED -/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value - * is XYZ(0.9642,1.0,0.8249), which scales to: - * - * (63189.8112, 65536, 54060.6464) - */ -static const png_byte D50_nCIEXYZ[12] = - { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; - -int /* PRIVATE */ -png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length) -{ - if (profile_length < 132) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "too short"); - - if (profile_length & 3) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "invalid length"); - - return 1; -} - -int /* PRIVATE */ -png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile/* first 132 bytes only */, int color_type) -{ - png_uint_32 temp; - - /* Length check; this cannot be ignored in this code because profile_length - * is used later to check the tag table, so even if the profile seems over - * long profile_length from the caller must be correct. The caller can fix - * this up on read or write by just passing in the profile header length. - */ - temp = png_get_uint_32(profile); - if (temp != profile_length) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "length does not match profile"); - - temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ - if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */ - profile_length < 132+12*temp) /* truncated tag table */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "tag count too large"); - - /* The 'intent' must be valid or we can't store it, ICC limits the intent to - * 16 bits. - */ - temp = png_get_uint_32(profile+64); - if (temp >= 0xffff) /* The ICC limit */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid rendering intent"); - - /* This is just a warning because the profile may be valid in future - * versions. - */ - if (temp >= PNG_sRGB_INTENT_LAST) - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "intent outside defined range"); - - /* At this point the tag table can't be checked because it hasn't necessarily - * been loaded; however, various header fields can be checked. These checks - * are for values permitted by the PNG spec in an ICC profile; the PNG spec - * restricts the profiles that can be passed in an iCCP chunk (they must be - * appropriate to processing PNG data!) - */ - - /* Data checks (could be skipped). These checks must be independent of the - * version number; however, the version number doesn't accomodate changes in - * the header fields (just the known tags and the interpretation of the - * data.) - */ - temp = png_get_uint_32(profile+36); /* signature 'ascp' */ - if (temp != 0x61637370) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid signature"); - - /* Currently the PCS illuminant/adopted white point (the computational - * white point) are required to be D50, - * however the profile contains a record of the illuminant so perhaps ICC - * expects to be able to change this in the future (despite the rationale in - * the introduction for using a fixed PCS adopted white.) Consequently the - * following is just a warning. - */ - if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) - (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, - "PCS illuminant is not D50"); - - /* The PNG spec requires this: - * "If the iCCP chunk is present, the image samples conform to the colour - * space represented by the embedded ICC profile as defined by the - * International Color Consortium [ICC]. The colour space of the ICC profile - * shall be an RGB colour space for colour images (PNG colour types 2, 3, and - * 6), or a greyscale colour space for greyscale images (PNG colour types 0 - * and 4)." - * - * This checking code ensures the embedded profile (on either read or write) - * conforms to the specification requirements. Notice that an ICC 'gray' - * color-space profile contains the information to transform the monochrome - * data to XYZ or L*a*b (according to which PCS the profile uses) and this - * should be used in preference to the standard libpng K channel replication - * into R, G and B channels. - * - * Previously it was suggested that an RGB profile on grayscale data could be - * handled. However it it is clear that using an RGB profile in this context - * must be an error - there is no specification of what it means. Thus it is - * almost certainly more correct to ignore the profile. - */ - temp = png_get_uint_32(profile+16); /* data colour space field */ - switch (temp) - { - case 0x52474220: /* 'RGB ' */ - if (!(color_type & PNG_COLOR_MASK_COLOR)) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "RGB color space not permitted on grayscale PNG"); - break; - - case 0x47524159: /* 'GRAY' */ - if (color_type & PNG_COLOR_MASK_COLOR) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "Gray color space not permitted on RGB PNG"); - break; - - default: - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid ICC profile color space"); - } - - /* It is up to the application to check that the profile class matches the - * application requirements; the spec provides no guidance, but it's pretty - * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer - * ('prtr') or 'spac' (for generic color spaces). Issue a warning in these - * cases. Issue an error for device link or abstract profiles - these don't - * contain the records necessary to transform the color-space to anything - * other than the target device (and not even that for an abstract profile). - * Profiles of these classes may not be embedded in images. - */ - temp = png_get_uint_32(profile+12); /* profile/device class */ - switch (temp) - { - case 0x73636E72: /* 'scnr' */ - case 0x6D6E7472: /* 'mntr' */ - case 0x70727472: /* 'prtr' */ - case 0x73706163: /* 'spac' */ - /* All supported */ - break; - - case 0x61627374: /* 'abst' */ - /* May not be embedded in an image */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid embedded Abstract ICC profile"); - - case 0x6C696E6B: /* 'link' */ - /* DeviceLink profiles cannnot be interpreted in a non-device specific - * fashion, if an app uses the AToB0Tag in the profile the results are - * undefined unless the result is sent to the intended device, - * therefore a DeviceLink profile should not be found embedded in a - * PNG. - */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected DeviceLink ICC profile class"); - - case 0x6E6D636C: /* 'nmcl' */ - /* A NamedColor profile is also device specific, however it doesn't - * contain an AToB0 tag that is open to misintrepretation. Almost - * certainly it will fail the tests below. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unexpected NamedColor ICC profile class"); - break; - - default: - /* To allow for future enhancements to the profile accept unrecognized - * profile classes with a warning, these then hit the test below on the - * tag content to ensure they are backward compatible with one of the - * understood profiles. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unrecognized ICC profile class"); - break; - } - - /* For any profile other than a device link one the PCS must be encoded - * either in XYZ or Lab. - */ - temp = png_get_uint_32(profile+20); - switch (temp) - { - case 0x58595A20: /* 'XYZ ' */ - case 0x4C616220: /* 'Lab ' */ - break; - - default: - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected ICC PCS encoding"); - } - - return 1; -} - -int /* PRIVATE */ -png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */) -{ - png_uint_32 tag_count = png_get_uint_32(profile+128); - png_uint_32 itag; - png_const_bytep tag = profile+132; /* The first tag */ - - /* First scan all the tags in the table and add bits to the icc_info value - * (temporarily in 'tags'). - */ - for (itag=0; itag < tag_count; ++itag, tag += 12) - { - png_uint_32 tag_id = png_get_uint_32(tag+0); - png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */ - png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */ - - /* The ICC specification does not exclude zero length tags, therefore the - * start might actually be anywhere if there is no data, but this would be - * a clear abuse of the intent of the standard so the start is checked for - * being in range. All defined tag types have an 8 byte header - a 4 byte - * type signature then 0. - */ - if ((tag_start & 3) != 0) - { - /* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is - * only a warning here because libpng does not care about the - * alignment. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, - "ICC profile tag start not a multiple of 4"); - } - - /* This is a hard error; potentially it can cause read outside the - * profile. - */ - if (tag_start > profile_length || tag_length > profile_length - tag_start) - return png_icc_profile_error(png_ptr, colorspace, name, tag_id, - "ICC profile tag outside profile"); - } - - return 1; /* success, maybe with warnings */ -} - -#ifdef PNG_sRGB_SUPPORTED -/* Information about the known ICC sRGB profiles */ -static const struct -{ - png_uint_32 adler, crc, length; - png_uint_32 md5[4]; - png_byte have_md5; - png_byte is_broken; - png_uint_16 intent; - -# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0) -# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\ - { adler, crc, length, md5, broke, intent }, - -} png_sRGB_checks[] = -{ - /* This data comes from contrib/tools/checksum-icc run on downloads of - * all four ICC sRGB profiles from www.color.org. - */ - /* adler32, crc32, MD5[4], intent, date, length, file-name */ - PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, - PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, - "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") - - /* ICC sRGB v2 perceptual no black-compensation: */ - PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, - PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, - "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") - - PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, - PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, - "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") - - /* ICC sRGB v4 perceptual */ - PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, - PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, - "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") - - /* The following profiles have no known MD5 checksum. If there is a match - * on the (empty) MD5 the other fields are used to attempt a match and - * a warning is produced. The first two of these profiles have a 'cprt' tag - * which suggests that they were also made by Hewlett Packard. - */ - PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, - "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") - - /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not - * match the D50 PCS illuminant in the header (it is in fact the D65 values, - * so the white point is recorded as the un-adapted value.) The profiles - * below only differ in one byte - the intent - and are basically the same as - * the previous profile except for the mediaWhitePointTag error and a missing - * chromaticAdaptationTag. - */ - PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") - - PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") -}; - -static int -png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, - png_const_bytep profile, uLong adler) -{ - /* The quick check is to verify just the MD5 signature and trust the - * rest of the data. Because the profile has already been verified for - * correctness this is safe. png_colorspace_set_sRGB will check the 'intent' - * field too, so if the profile has been edited with an intent not defined - * by sRGB (but maybe defined by a later ICC specification) the read of - * the profile will fail at that point. - */ - png_uint_32 length = 0; - png_uint_32 intent = 0x10000; /* invalid */ -#if PNG_sRGB_PROFILE_CHECKS > 1 - uLong crc = 0; /* the value for 0 length data */ -#endif - unsigned int i; - - for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i) - { - if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] && - png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] && - png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] && - png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3]) - { - /* This may be one of the old HP profiles without an MD5, in that - * case we can only use the length and Adler32 (note that these - * are not used by default if there is an MD5!) - */ -# if PNG_sRGB_PROFILE_CHECKS == 0 - if (png_sRGB_checks[i].have_md5) - return 1+png_sRGB_checks[i].is_broken; -# endif - - /* Profile is unsigned or more checks have been configured in. */ - if (length == 0) - { - length = png_get_uint_32(profile); - intent = png_get_uint_32(profile+64); - } - - /* Length *and* intent must match */ - if (length == png_sRGB_checks[i].length && - intent == png_sRGB_checks[i].intent) - { - /* Now calculate the adler32 if not done already. */ - if (adler == 0) - { - adler = adler32(0, NULL, 0); - adler = adler32(adler, profile, length); - } - - if (adler == png_sRGB_checks[i].adler) - { - /* These basic checks suggest that the data has not been - * modified, but if the check level is more than 1 perform - * our own crc32 checksum on the data. - */ -# if PNG_sRGB_PROFILE_CHECKS > 1 - if (crc == 0) - { - crc = crc32(0, NULL, 0); - crc = crc32(crc, profile, length); - } - - /* So this check must pass for the 'return' below to happen. - */ - if (crc == png_sRGB_checks[i].crc) -# endif - { - if (png_sRGB_checks[i].is_broken) - { - /* These profiles are known to have bad data that may cause - * problems if they are used, therefore attempt to - * discourage their use, skip the 'have_md5' warning below, - * which is made irrelevant by this error. - */ - png_chunk_report(png_ptr, "known incorrect sRGB profile", - PNG_CHUNK_ERROR); - } - - /* Warn that this being done; this isn't even an error since - * the profile is perfectly valid, but it would be nice if - * people used the up-to-date ones. - */ - else if (!png_sRGB_checks[i].have_md5) - { - png_chunk_report(png_ptr, - "out-of-date sRGB profile with no signature", - PNG_CHUNK_WARNING); - } - - return 1+png_sRGB_checks[i].is_broken; - } - } - } - -# if PNG_sRGB_PROFILE_CHECKS > 0 - /* The signature matched, but the profile had been changed in some - * way. This is an apparent violation of the ICC terms of use and, - * anyway, probably indicates a data error or uninformed hacking. - */ - if (png_sRGB_checks[i].have_md5) - png_benign_error(png_ptr, - "copyright violation: edited ICC profile ignored"); -# endif - } - } - - return 0; /* no match */ -} -#endif - -#ifdef PNG_sRGB_SUPPORTED -void /* PRIVATE */ -png_icc_set_sRGB(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_bytep profile, uLong adler) -{ - /* Is this profile one of the known ICC sRGB profiles? If it is, just set - * the sRGB information. - */ - if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler)) - (void)png_colorspace_set_sRGB(png_ptr, colorspace, - (int)/*already checked*/png_get_uint_32(profile+64)); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -int /* PRIVATE */ -png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, - int color_type) -{ - if (colorspace->flags & PNG_COLORSPACE_INVALID) - return 0; - - if (png_icc_check_length(png_ptr, colorspace, name, profile_length) && - png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, - color_type) && - png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, - profile)) - { -# ifdef PNG_sRGB_SUPPORTED - /* If no sRGB support, don't try storing sRGB information */ - png_icc_set_sRGB(png_ptr, colorspace, profile, 0); -# endif - return 1; - } - - /* Failure case */ - return 0; -} -#endif /* iCCP */ - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -void /* PRIVATE */ -png_colorspace_set_rgb_coefficients(png_structrp png_ptr) -{ - /* Set the rgb_to_gray coefficients from the colorspace. */ - if (!png_ptr->rgb_to_gray_coefficients_set && - (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - /* png_set_background has not been called, get the coefficients from the Y - * values of the colorspace colorants. - */ - png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y; - png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y; - png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y; - png_fixed_point total = r+g+b; - - if (total > 0 && - r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 && - g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 && - b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 && - r+g+b <= 32769) - { - /* We allow 0 coefficients here. r+g+b may be 32769 if two or - * all of the coefficients were rounded up. Handle this by - * reducing the *largest* coefficient by 1; this matches the - * approach used for the default coefficients in pngrtran.c - */ - int add = 0; - - if (r+g+b > 32768) - add = -1; - else if (r+g+b < 32768) - add = 1; - - if (add != 0) - { - if (g >= r && g >= b) - g += add; - else if (r >= g && r >= b) - r += add; - else - b += add; - } - - /* Check for an internal error. */ - if (r+g+b != 32768) - png_error(png_ptr, - "internal error handling cHRM coefficients"); - - else - { - png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r; - png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g; - } - } - - /* This is a png_error at present even though it could be ignored - - * it should never happen, but it is important that if it does, the - * bug is fixed. - */ - else - png_error(png_ptr, "internal error handling cHRM->XYZ"); - } -} -#endif - -#endif /* COLORSPACE */ - -void /* PRIVATE */ -png_check_IHDR(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - int error = 0; - - /* Check for width and height valid values */ - if (width == 0) - { - png_warning(png_ptr, "Image width is zero in IHDR"); - error = 1; - } - - if (height == 0) - { - png_warning(png_ptr, "Image height is zero in IHDR"); - error = 1; - } - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max) - -# else - if (width > PNG_USER_WIDTH_MAX) -# endif - { - png_warning(png_ptr, "Image width exceeds user limit in IHDR"); - error = 1; - } - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (height > png_ptr->user_height_max) -# else - if (height > PNG_USER_HEIGHT_MAX) -# endif - { - png_warning(png_ptr, "Image height exceeds user limit in IHDR"); - error = 1; - } - - if (width > PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Invalid image width in IHDR"); - error = 1; - } - - if (height > PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Invalid image height in IHDR"); - error = 1; - } - - if (width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 48 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* Check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - { - png_warning(png_ptr, "Invalid bit depth in IHDR"); - error = 1; - } - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - { - png_warning(png_ptr, "Invalid color type in IHDR"); - error = 1; - } - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - { - png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR"); - error = 1; - } - - if (interlace_type >= PNG_INTERLACE_LAST) - { - png_warning(png_ptr, "Unknown interlace method in IHDR"); - error = 1; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Unknown compression method in IHDR"); - error = 1; - } - -# ifdef PNG_MNG_FEATURES_SUPPORTED - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) && - png_ptr->mng_features_permitted) - png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); - - if (filter_type != PNG_FILTER_TYPE_BASE) - { - if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - { - png_warning(png_ptr, "Unknown filter method in IHDR"); - error = 1; - } - - if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) - { - png_warning(png_ptr, "Invalid filter method in IHDR"); - error = 1; - } - } - -# else - if (filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Unknown filter method in IHDR"); - error = 1; - } -# endif - - if (error == 1) - png_error(png_ptr, "Invalid IHDR data"); -} - -#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) -/* ASCII to fp functions */ -/* Check an ASCII formated floating point value, see the more detailed - * comments in pngpriv.h - */ -/* The following is used internally to preserve the sticky flags */ -#define png_fp_add(state, flags) ((state) |= (flags)) -#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY)) - -int /* PRIVATE */ -png_check_fp_number(png_const_charp string, png_size_t size, int *statep, - png_size_tp whereami) -{ - int state = *statep; - png_size_t i = *whereami; - - while (i < size) - { - int type; - /* First find the type of the next character */ - switch (string[i]) - { - case 43: type = PNG_FP_SAW_SIGN; break; - case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break; - case 46: type = PNG_FP_SAW_DOT; break; - case 48: type = PNG_FP_SAW_DIGIT; break; - case 49: case 50: case 51: case 52: - case 53: case 54: case 55: case 56: - case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break; - case 69: - case 101: type = PNG_FP_SAW_E; break; - default: goto PNG_FP_End; - } - - /* Now deal with this type according to the current - * state, the type is arranged to not overlap the - * bits of the PNG_FP_STATE. - */ - switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY)) - { - case PNG_FP_INTEGER + PNG_FP_SAW_SIGN: - if (state & PNG_FP_SAW_ANY) - goto PNG_FP_End; /* not a part of the number */ - - png_fp_add(state, type); - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_DOT: - /* Ok as trailer, ok as lead of fraction. */ - if (state & PNG_FP_SAW_DOT) /* two dots */ - goto PNG_FP_End; - - else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */ - png_fp_add(state, type); - - else - png_fp_set(state, PNG_FP_FRACTION | type); - - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT: - if (state & PNG_FP_SAW_DOT) /* delayed fraction */ - png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); - - png_fp_add(state, type | PNG_FP_WAS_VALID); - - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_E: - if ((state & PNG_FP_SAW_DIGIT) == 0) - goto PNG_FP_End; - - png_fp_set(state, PNG_FP_EXPONENT); - - break; - - /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN: - goto PNG_FP_End; ** no sign in fraction */ - - /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT: - goto PNG_FP_End; ** Because SAW_DOT is always set */ - - case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT: - png_fp_add(state, type | PNG_FP_WAS_VALID); - break; - - case PNG_FP_FRACTION + PNG_FP_SAW_E: - /* This is correct because the trailing '.' on an - * integer is handled above - so we can only get here - * with the sequence ".E" (with no preceding digits). - */ - if ((state & PNG_FP_SAW_DIGIT) == 0) - goto PNG_FP_End; - - png_fp_set(state, PNG_FP_EXPONENT); - - break; - - case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN: - if (state & PNG_FP_SAW_ANY) - goto PNG_FP_End; /* not a part of the number */ - - png_fp_add(state, PNG_FP_SAW_SIGN); - - break; - - /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT: - goto PNG_FP_End; */ - - case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT: - png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID); - - break; - - /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E: - goto PNG_FP_End; */ - - default: goto PNG_FP_End; /* I.e. break 2 */ - } - - /* The character seems ok, continue. */ - ++i; - } - -PNG_FP_End: - /* Here at the end, update the state and return the correct - * return code. - */ - *statep = state; - *whereami = i; - - return (state & PNG_FP_SAW_DIGIT) != 0; -} - - -/* The same but for a complete string. */ -int -png_check_fp_string(png_const_charp string, png_size_t size) -{ - int state=0; - png_size_t char_index=0; - - if (png_check_fp_number(string, size, &state, &char_index) && - (char_index == size || string[char_index] == 0)) - return state /* must be non-zero - see above */; - - return 0; /* i.e. fail */ -} -#endif /* pCAL or sCAL */ - -#ifdef PNG_sCAL_SUPPORTED -# ifdef PNG_FLOATING_POINT_SUPPORTED -/* Utility used below - a simple accurate power of ten from an integral - * exponent. - */ -static double -png_pow10(int power) -{ - int recip = 0; - double d = 1; - - /* Handle negative exponent with a reciprocal at the end because - * 10 is exact whereas .1 is inexact in base 2 - */ - if (power < 0) - { - if (power < DBL_MIN_10_EXP) return 0; - recip = 1, power = -power; - } - - if (power > 0) - { - /* Decompose power bitwise. */ - double mult = 10; - do - { - if (power & 1) d *= mult; - mult *= mult; - power >>= 1; - } - while (power > 0); - - if (recip) d = 1/d; - } - /* else power is 0 and d is 1 */ - - return d; -} - -/* Function to format a floating point value in ASCII with a given - * precision. - */ -void /* PRIVATE */ -png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, - double fp, unsigned int precision) -{ - /* We use standard functions from math.h, but not printf because - * that would require stdio. The caller must supply a buffer of - * sufficient size or we will png_error. The tests on size and - * the space in ascii[] consumed are indicated below. - */ - if (precision < 1) - precision = DBL_DIG; - - /* Enforce the limit of the implementation precision too. */ - if (precision > DBL_DIG+1) - precision = DBL_DIG+1; - - /* Basic sanity checks */ - if (size >= precision+5) /* See the requirements below. */ - { - if (fp < 0) - { - fp = -fp; - *ascii++ = 45; /* '-' PLUS 1 TOTAL 1 */ - --size; - } - - if (fp >= DBL_MIN && fp <= DBL_MAX) - { - int exp_b10; /* A base 10 exponent */ - double base; /* 10^exp_b10 */ - - /* First extract a base 10 exponent of the number, - * the calculation below rounds down when converting - * from base 2 to base 10 (multiply by log10(2) - - * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to - * be increased. Note that the arithmetic shift - * performs a floor() unlike C arithmetic - using a - * C multiply would break the following for negative - * exponents. - */ - (void)frexp(fp, &exp_b10); /* exponent to base 2 */ - - exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */ - - /* Avoid underflow here. */ - base = png_pow10(exp_b10); /* May underflow */ - - while (base < DBL_MIN || base < fp) - { - /* And this may overflow. */ - double test = png_pow10(exp_b10+1); - - if (test <= DBL_MAX) - ++exp_b10, base = test; - - else - break; - } - - /* Normalize fp and correct exp_b10, after this fp is in the - * range [.1,1) and exp_b10 is both the exponent and the digit - * *before* which the decimal point should be inserted - * (starting with 0 for the first digit). Note that this - * works even if 10^exp_b10 is out of range because of the - * test on DBL_MAX above. - */ - fp /= base; - while (fp >= 1) fp /= 10, ++exp_b10; - - /* Because of the code above fp may, at this point, be - * less than .1, this is ok because the code below can - * handle the leading zeros this generates, so no attempt - * is made to correct that here. - */ - - { - int czero, clead, cdigits; - char exponent[10]; - - /* Allow up to two leading zeros - this will not lengthen - * the number compared to using E-n. - */ - if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ - { - czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ - exp_b10 = 0; /* Dot added below before first output. */ - } - else - czero = 0; /* No zeros to add */ - - /* Generate the digit list, stripping trailing zeros and - * inserting a '.' before a digit if the exponent is 0. - */ - clead = czero; /* Count of leading zeros */ - cdigits = 0; /* Count of digits in list. */ - - do - { - double d; - - fp *= 10; - /* Use modf here, not floor and subtract, so that - * the separation is done in one step. At the end - * of the loop don't break the number into parts so - * that the final digit is rounded. - */ - if (cdigits+czero-clead+1 < (int)precision) - fp = modf(fp, &d); - - else - { - d = floor(fp + .5); - - if (d > 9) - { - /* Rounding up to 10, handle that here. */ - if (czero > 0) - { - --czero, d = 1; - if (cdigits == 0) --clead; - } - else - { - while (cdigits > 0 && d > 9) - { - int ch = *--ascii; - - if (exp_b10 != (-1)) - ++exp_b10; - - else if (ch == 46) - { - ch = *--ascii, ++size; - /* Advance exp_b10 to '1', so that the - * decimal point happens after the - * previous digit. - */ - exp_b10 = 1; - } - - --cdigits; - d = ch - 47; /* I.e. 1+(ch-48) */ - } - - /* Did we reach the beginning? If so adjust the - * exponent but take into account the leading - * decimal point. - */ - if (d > 9) /* cdigits == 0 */ - { - if (exp_b10 == (-1)) - { - /* Leading decimal point (plus zeros?), if - * we lose the decimal point here it must - * be reentered below. - */ - int ch = *--ascii; - - if (ch == 46) - ++size, exp_b10 = 1; - - /* Else lost a leading zero, so 'exp_b10' is - * still ok at (-1) - */ - } - else - ++exp_b10; - - /* In all cases we output a '1' */ - d = 1; - } - } - } - fp = 0; /* Guarantees termination below. */ - } - - if (d == 0) - { - ++czero; - if (cdigits == 0) ++clead; - } - else - { - /* Included embedded zeros in the digit count. */ - cdigits += czero - clead; - clead = 0; - - while (czero > 0) - { - /* exp_b10 == (-1) means we just output the decimal - * place - after the DP don't adjust 'exp_b10' any - * more! - */ - if (exp_b10 != (-1)) - { - if (exp_b10 == 0) *ascii++ = 46, --size; - /* PLUS 1: TOTAL 4 */ - --exp_b10; - } - *ascii++ = 48, --czero; - } - - if (exp_b10 != (-1)) - { - if (exp_b10 == 0) *ascii++ = 46, --size; /* counted - above */ - --exp_b10; - } - *ascii++ = (char)(48 + (int)d), ++cdigits; - } - } - while (cdigits+czero-clead < (int)precision && fp > DBL_MIN); - - /* The total output count (max) is now 4+precision */ - - /* Check for an exponent, if we don't need one we are - * done and just need to terminate the string. At - * this point exp_b10==(-1) is effectively if flag - it got - * to '-1' because of the decrement after outputing - * the decimal point above (the exponent required is - * *not* -1!) - */ - if (exp_b10 >= (-1) && exp_b10 <= 2) - { - /* The following only happens if we didn't output the - * leading zeros above for negative exponent, so this - * doest add to the digit requirement. Note that the - * two zeros here can only be output if the two leading - * zeros were *not* output, so this doesn't increase - * the output count. - */ - while (--exp_b10 >= 0) *ascii++ = 48; - - *ascii = 0; - - /* Total buffer requirement (including the '\0') is - * 5+precision - see check at the start. - */ - return; - } - - /* Here if an exponent is required, adjust size for - * the digits we output but did not count. The total - * digit output here so far is at most 1+precision - no - * decimal point and no leading or trailing zeros have - * been output. - */ - size -= cdigits; - - *ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */ - - /* The following use of an unsigned temporary avoids ambiguities in - * the signed arithmetic on exp_b10 and permits GCC at least to do - * better optimization. - */ - { - unsigned int uexp_b10; - - if (exp_b10 < 0) - { - *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ - uexp_b10 = -exp_b10; - } - - else - uexp_b10 = exp_b10; - - cdigits = 0; - - while (uexp_b10 > 0) - { - exponent[cdigits++] = (char)(48 + uexp_b10 % 10); - uexp_b10 /= 10; - } - } - - /* Need another size check here for the exponent digits, so - * this need not be considered above. - */ - if ((int)size > cdigits) - { - while (cdigits > 0) *ascii++ = exponent[--cdigits]; - - *ascii = 0; - - return; - } - } - } - else if (!(fp >= DBL_MIN)) - { - *ascii++ = 48; /* '0' */ - *ascii = 0; - return; - } - else - { - *ascii++ = 105; /* 'i' */ - *ascii++ = 110; /* 'n' */ - *ascii++ = 102; /* 'f' */ - *ascii = 0; - return; - } - } - - /* Here on buffer too small. */ - png_error(png_ptr, "ASCII conversion buffer too small"); -} - -# endif /* FLOATING_POINT */ - -# ifdef PNG_FIXED_POINT_SUPPORTED -/* Function to format a fixed point value in ASCII. - */ -void /* PRIVATE */ -png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, - png_size_t size, png_fixed_point fp) -{ - /* Require space for 10 decimal digits, a decimal point, a minus sign and a - * trailing \0, 13 characters: - */ - if (size > 12) - { - png_uint_32 num; - - /* Avoid overflow here on the minimum integer. */ - if (fp < 0) - *ascii++ = 45, --size, num = -fp; - else - num = fp; - - if (num <= 0x80000000) /* else overflowed */ - { - unsigned int ndigits = 0, first = 16 /* flag value */; - char digits[10]; - - while (num) - { - /* Split the low digit off num: */ - unsigned int tmp = num/10; - num -= tmp*10; - digits[ndigits++] = (char)(48 + num); - /* Record the first non-zero digit, note that this is a number - * starting at 1, it's not actually the array index. - */ - if (first == 16 && num > 0) - first = ndigits; - num = tmp; - } - - if (ndigits > 0) - { - while (ndigits > 5) *ascii++ = digits[--ndigits]; - /* The remaining digits are fractional digits, ndigits is '5' or - * smaller at this point. It is certainly not zero. Check for a - * non-zero fractional digit: - */ - if (first <= 5) - { - unsigned int i; - *ascii++ = 46; /* decimal point */ - /* ndigits may be <5 for small numbers, output leading zeros - * then ndigits digits to first: - */ - i = 5; - while (ndigits < i) *ascii++ = 48, --i; - while (ndigits >= first) *ascii++ = digits[--ndigits]; - /* Don't output the trailing zeros! */ - } - } - else - *ascii++ = 48; - - /* And null terminate the string: */ - *ascii = 0; - return; - } - } - - /* Here on buffer too small. */ - png_error(png_ptr, "ASCII conversion buffer too small"); -} -# endif /* FIXED_POINT */ -#endif /* READ_SCAL */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ - (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ - defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ - (defined(PNG_sCAL_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) -png_fixed_point -png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) -{ - double r = floor(100000 * fp + .5); - - if (r > 2147483647. || r < -2147483648.) - png_fixed_error(png_ptr, text); - - return (png_fixed_point)r; -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || \ - defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) -/* muldiv functions */ -/* This API takes signed arguments and rounds the result to the nearest - * integer (or, for a fixed point number - the standard argument - to - * the nearest .00001). Overflow and divide by zero are signalled in - * the result, a boolean - true on success, false on overflow. - */ -int -png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, - png_int_32 divisor) -{ - /* Return a * times / divisor, rounded. */ - if (divisor != 0) - { - if (a == 0 || times == 0) - { - *res = 0; - return 1; - } - else - { -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = a; - r *= times; - r /= divisor; - r = floor(r+.5); - - /* A png_fixed_point is a 32-bit integer. */ - if (r <= 2147483647. && r >= -2147483648.) - { - *res = (png_fixed_point)r; - return 1; - } -#else - int negative = 0; - png_uint_32 A, T, D; - png_uint_32 s16, s32, s00; - - if (a < 0) - negative = 1, A = -a; - else - A = a; - - if (times < 0) - negative = !negative, T = -times; - else - T = times; - - if (divisor < 0) - negative = !negative, D = -divisor; - else - D = divisor; - - /* Following can't overflow because the arguments only - * have 31 bits each, however the result may be 32 bits. - */ - s16 = (A >> 16) * (T & 0xffff) + - (A & 0xffff) * (T >> 16); - /* Can't overflow because the a*times bit is only 30 - * bits at most. - */ - s32 = (A >> 16) * (T >> 16) + (s16 >> 16); - s00 = (A & 0xffff) * (T & 0xffff); - - s16 = (s16 & 0xffff) << 16; - s00 += s16; - - if (s00 < s16) - ++s32; /* carry */ - - if (s32 < D) /* else overflow */ - { - /* s32.s00 is now the 64-bit product, do a standard - * division, we know that s32 < D, so the maximum - * required shift is 31. - */ - int bitshift = 32; - png_fixed_point result = 0; /* NOTE: signed */ - - while (--bitshift >= 0) - { - png_uint_32 d32, d00; - - if (bitshift > 0) - d32 = D >> (32-bitshift), d00 = D << bitshift; - - else - d32 = 0, d00 = D; - - if (s32 > d32) - { - if (s00 < d00) --s32; /* carry */ - s32 -= d32, s00 -= d00, result += 1<= d00) - s32 = 0, s00 -= d00, result += 1<= (D >> 1)) - ++result; - - if (negative) - result = -result; - - /* Check for overflow. */ - if ((negative && result <= 0) || (!negative && result >= 0)) - { - *res = result; - return 1; - } - } -#endif - } - } - - return 0; -} -#endif /* READ_GAMMA || INCH_CONVERSIONS */ - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) -/* The following is for when the caller doesn't much care about the - * result. - */ -png_fixed_point -png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times, - png_int_32 divisor) -{ - png_fixed_point result; - - if (png_muldiv(&result, a, times, divisor)) - return result; - - png_warning(png_ptr, "fixed point overflow ignored"); - return 0; -} -#endif - -#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */ -/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ -png_fixed_point -png_reciprocal(png_fixed_point a) -{ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(1E10/a+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else - png_fixed_point res; - - if (png_muldiv(&res, 100000, 100000, a)) - return res; -#endif - - return 0; /* error/overflow */ -} - -/* This is the shared test on whether a gamma value is 'significant' - whether - * it is worth doing gamma correction. - */ -int /* PRIVATE */ -png_gamma_significant(png_fixed_point gamma_val) -{ - return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || - gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; -} -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* A local convenience routine. */ -static png_fixed_point -png_product2(png_fixed_point a, png_fixed_point b) -{ - /* The required result is 1/a * 1/b; the following preserves accuracy. */ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = a * 1E-5; - r *= b; - r = floor(r+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else - png_fixed_point res; - - if (png_muldiv(&res, a, b, 100000)) - return res; -#endif - - return 0; /* overflow */ -} - -/* The inverse of the above. */ -png_fixed_point -png_reciprocal2(png_fixed_point a, png_fixed_point b) -{ - /* The required result is 1/a * 1/b; the following preserves accuracy. */ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = 1E15/a; - r /= b; - r = floor(r+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else - /* This may overflow because the range of png_fixed_point isn't symmetric, - * but this API is only used for the product of file and screen gamma so it - * doesn't matter that the smallest number it can produce is 1/21474, not - * 1/100000 - */ - png_fixed_point res = png_product2(a, b); - - if (res != 0) - return png_reciprocal(res); -#endif - - return 0; /* overflow */ -} -#endif /* READ_GAMMA */ - -#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */ -#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED -/* Fixed point gamma. - * - * The code to calculate the tables used below can be found in the shell script - * contrib/tools/intgamma.sh - * - * To calculate gamma this code implements fast log() and exp() calls using only - * fixed point arithmetic. This code has sufficient precision for either 8-bit - * or 16-bit sample values. - * - * The tables used here were calculated using simple 'bc' programs, but C double - * precision floating point arithmetic would work fine. - * - * 8-bit log table - * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to - * 255, so it's the base 2 logarithm of a normalized 8-bit floating point - * mantissa. The numbers are 32-bit fractions. - */ -static const png_uint_32 -png_8bit_l2[128] = -{ - 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U, - 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U, - 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U, - 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U, - 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U, - 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U, - 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U, - 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U, - 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U, - 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U, - 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U, - 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U, - 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U, - 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U, - 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U, - 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U, - 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U, - 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U, - 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U, - 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U, - 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U, - 24347096U, 0U - -#if 0 - /* The following are the values for 16-bit tables - these work fine for the - * 8-bit conversions but produce very slightly larger errors in the 16-bit - * log (about 1.2 as opposed to 0.7 absolute error in the final value). To - * use these all the shifts below must be adjusted appropriately. - */ - 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054, - 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803, - 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068, - 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782, - 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887, - 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339, - 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098, - 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132, - 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415, - 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523, - 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495, - 1119, 744, 372 -#endif -}; - -static png_int_32 -png_log8bit(unsigned int x) -{ - unsigned int lg2 = 0; - /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, - * because the log is actually negate that means adding 1. The final - * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 - * input), return -1 for the overflow (log 0) case, - so the result is - * always at most 19 bits. - */ - if ((x &= 0xff) == 0) - return -1; - - if ((x & 0xf0) == 0) - lg2 = 4, x <<= 4; - - if ((x & 0xc0) == 0) - lg2 += 2, x <<= 2; - - if ((x & 0x80) == 0) - lg2 += 1, x <<= 1; - - /* result is at most 19 bits, so this cast is safe: */ - return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16)); -} - -/* The above gives exact (to 16 binary places) log2 values for 8-bit images, - * for 16-bit images we use the most significant 8 bits of the 16-bit value to - * get an approximation then multiply the approximation by a correction factor - * determined by the remaining up to 8 bits. This requires an additional step - * in the 16-bit case. - * - * We want log2(value/65535), we have log2(v'/255), where: - * - * value = v' * 256 + v'' - * = v' * f - * - * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128 - * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less - * than 258. The final factor also needs to correct for the fact that our 8-bit - * value is scaled by 255, whereas the 16-bit values must be scaled by 65535. - * - * This gives a final formula using a calculated value 'x' which is value/v' and - * scaling by 65536 to match the above table: - * - * log2(x/257) * 65536 - * - * Since these numbers are so close to '1' we can use simple linear - * interpolation between the two end values 256/257 (result -368.61) and 258/257 - * (result 367.179). The values used below are scaled by a further 64 to give - * 16-bit precision in the interpolation: - * - * Start (256): -23591 - * Zero (257): 0 - * End (258): 23499 - */ -static png_int_32 -png_log16bit(png_uint_32 x) -{ - unsigned int lg2 = 0; - - /* As above, but now the input has 16 bits. */ - if ((x &= 0xffff) == 0) - return -1; - - if ((x & 0xff00) == 0) - lg2 = 8, x <<= 8; - - if ((x & 0xf000) == 0) - lg2 += 4, x <<= 4; - - if ((x & 0xc000) == 0) - lg2 += 2, x <<= 2; - - if ((x & 0x8000) == 0) - lg2 += 1, x <<= 1; - - /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional - * value. - */ - lg2 <<= 28; - lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4; - - /* Now we need to interpolate the factor, this requires a division by the top - * 8 bits. Do this with maximum precision. - */ - x = ((x << 16) + (x >> 9)) / (x >> 8); - - /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, - * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly - * 16 bits to interpolate to get the low bits of the result. Round the - * answer. Note that the end point values are scaled by 64 to retain overall - * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust - * the overall scaling by 6-12. Round at every step. - */ - x -= 1U << 24; - - if (x <= 65536U) /* <= '257' */ - lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); - - else - lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); - - /* Safe, because the result can't have more than 20 bits: */ - return (png_int_32)((lg2 + 2048) >> 12); -} - -/* The 'exp()' case must invert the above, taking a 20-bit fixed point - * logarithmic value and returning a 16 or 8-bit number as appropriate. In - * each case only the low 16 bits are relevant - the fraction - since the - * integer bits (the top 4) simply determine a shift. - * - * The worst case is the 16-bit distinction between 65535 and 65534, this - * requires perhaps spurious accuracty in the decoding of the logarithm to - * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance - * of getting this accuracy in practice. - * - * To deal with this the following exp() function works out the exponent of the - * frational part of the logarithm by using an accurate 32-bit value from the - * top four fractional bits then multiplying in the remaining bits. - */ -static const png_uint_32 -png_32bit_exp[16] = -{ - /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */ - 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U, - 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U, - 2553802834U, 2445529972U, 2341847524U, 2242560872U -}; - -/* Adjustment table; provided to explain the numbers in the code below. */ -#if 0 -for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"} - 11 44937.64284865548751208448 - 10 45180.98734845585101160448 - 9 45303.31936980687359311872 - 8 45364.65110595323018870784 - 7 45395.35850361789624614912 - 6 45410.72259715102037508096 - 5 45418.40724413220722311168 - 4 45422.25021786898173001728 - 3 45424.17186732298419044352 - 2 45425.13273269940811464704 - 1 45425.61317555035558641664 - 0 45425.85339951654943850496 -#endif - -static png_uint_32 -png_exp(png_fixed_point x) -{ - if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */ - { - /* Obtain a 4-bit approximation */ - png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf]; - - /* Incorporate the low 12 bits - these decrease the returned value by - * multiplying by a number less than 1 if the bit is set. The multiplier - * is determined by the above table and the shift. Notice that the values - * converge on 45426 and this is used to allow linear interpolation of the - * low bits. - */ - if (x & 0x800) - e -= (((e >> 16) * 44938U) + 16U) >> 5; - - if (x & 0x400) - e -= (((e >> 16) * 45181U) + 32U) >> 6; - - if (x & 0x200) - e -= (((e >> 16) * 45303U) + 64U) >> 7; - - if (x & 0x100) - e -= (((e >> 16) * 45365U) + 128U) >> 8; - - if (x & 0x080) - e -= (((e >> 16) * 45395U) + 256U) >> 9; - - if (x & 0x040) - e -= (((e >> 16) * 45410U) + 512U) >> 10; - - /* And handle the low 6 bits in a single block. */ - e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; - - /* Handle the upper bits of x. */ - e >>= x >> 16; - return e; - } - - /* Check for overflow */ - if (x <= 0) - return png_32bit_exp[0]; - - /* Else underflow */ - return 0; -} - -static png_byte -png_exp8bit(png_fixed_point lg2) -{ - /* Get a 32-bit value: */ - png_uint_32 x = png_exp(lg2); - - /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the - * second, rounding, step can't overflow because of the first, subtraction, - * step. - */ - x -= x >> 8; - return (png_byte)((x + 0x7fffffU) >> 24); -} - -static png_uint_16 -png_exp16bit(png_fixed_point lg2) -{ - /* Get a 32-bit value: */ - png_uint_32 x = png_exp(lg2); - - /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */ - x -= x >> 16; - return (png_uint_16)((x + 32767U) >> 16); -} -#endif /* FLOATING_ARITHMETIC */ - -png_byte -png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) -{ - if (value > 0 && value < 255) - { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(255*pow(value/255.,gamma_val*.00001)+.5); - return (png_byte)r; -# else - png_int_32 lg2 = png_log8bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) - return png_exp8bit(res); - - /* Overflow. */ - value = 0; -# endif - } - - return (png_byte)value; -} - -png_uint_16 -png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) -{ - if (value > 0 && value < 65535) - { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5); - return (png_uint_16)r; -# else - png_int_32 lg2 = png_log16bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) - return png_exp16bit(res); - - /* Overflow. */ - value = 0; -# endif - } - - return (png_uint_16)value; -} - -/* This does the right thing based on the bit_depth field of the - * png_struct, interpreting values as 8-bit or 16-bit. While the result - * is nominally a 16-bit value if bit depth is 8 then the result is - * 8-bit (as are the arguments.) - */ -png_uint_16 /* PRIVATE */ -png_gamma_correct(png_structrp png_ptr, unsigned int value, - png_fixed_point gamma_val) -{ - if (png_ptr->bit_depth == 8) - return png_gamma_8bit_correct(value, gamma_val); - - else - return png_gamma_16bit_correct(value, gamma_val); -} - -/* Internal function to build a single 16-bit table - the table consists of - * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount - * to shift the input values right (or 16-number_of_signifiant_bits). - * - * The caller is responsible for ensuring that the table gets cleaned up on - * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument - * should be somewhere that will be cleaned. - */ -static void -png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) -{ - /* Various values derived from 'shift': */ - PNG_CONST unsigned int num = 1U << (8U - shift); - PNG_CONST unsigned int max = (1U << (16U - shift))-1U; - PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); - unsigned int i; - - png_uint_16pp table = *ptable = - (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_uint_16p sub_table = table[i] = - (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16))); - - /* The 'threshold' test is repeated here because it can arise for one of - * the 16-bit tables even if the others don't hit it. - */ - if (png_gamma_significant(gamma_val)) - { - /* The old code would overflow at the end and this would cause the - * 'pow' function to return a result >1, resulting in an - * arithmetic error. This code follows the spec exactly; ig is - * the recovered input sample, it always has 8-16 bits. - * - * We want input * 65535/max, rounded, the arithmetic fits in 32 - * bits (unsigned) so long as max <= 32767. - */ - unsigned int j; - for (j = 0; j < 256; j++) - { - png_uint_32 ig = (j << (8-shift)) + i; -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* Inline the 'max' scaling operation: */ - double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5); - sub_table[j] = (png_uint_16)d; -# else - if (shift) - ig = (ig * 65535U + max_by_2)/max; - - sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); -# endif - } - } - else - { - /* We must still build a table, but do it the fast way. */ - unsigned int j; - - for (j = 0; j < 256; j++) - { - png_uint_32 ig = (j << (8-shift)) + i; - - if (shift) - ig = (ig * 65535U + max_by_2)/max; - - sub_table[j] = (png_uint_16)ig; - } - } - } -} - -/* NOTE: this function expects the *inverse* of the overall gamma transformation - * required. - */ -static void -png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) -{ - PNG_CONST unsigned int num = 1U << (8U - shift); - PNG_CONST unsigned int max = (1U << (16U - shift))-1U; - unsigned int i; - png_uint_32 last; - - png_uint_16pp table = *ptable = - (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); - - /* 'num' is the number of tables and also the number of low bits of low - * bits of the input 16-bit value used to select a table. Each table is - * itself index by the high 8 bits of the value. - */ - for (i = 0; i < num; i++) - table[i] = (png_uint_16p)png_malloc(png_ptr, - 256 * (sizeof (png_uint_16))); - - /* 'gamma_val' is set to the reciprocal of the value calculated above, so - * pow(out,g) is an *input* value. 'last' is the last input value set. - * - * In the loop 'i' is used to find output values. Since the output is - * 8-bit there are only 256 possible values. The tables are set up to - * select the closest possible output value for each input by finding - * the input value at the boundary between each pair of output values - * and filling the table up to that boundary with the lower output - * value. - * - * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit - * values the code below uses a 16-bit value in i; the values start at - * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last - * entries are filled with 255). Start i at 128 and fill all 'last' - * table entries <= 'max' - */ - last = 0; - for (i = 0; i < 255; ++i) /* 8-bit output value */ - { - /* Find the corresponding maximum input value */ - png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */ - - /* Find the boundary value in 16 bits: */ - png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); - - /* Adjust (round) to (16-shift) bits: */ - bound = (bound * max + 32768U)/65535U + 1U; - - while (last < bound) - { - table[last & (0xffU >> shift)][last >> (8U - shift)] = out; - last++; - } - } - - /* And fill in the final entries. */ - while (last < (num << 8)) - { - table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; - last++; - } -} - -/* Build a single 8-bit table: same as the 16-bit case but much simpler (and - * typically much faster). Note that libpng currently does no sBIT processing - * (apparently contrary to the spec) so a 256 entry table is always generated. - */ -static void -png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, - PNG_CONST png_fixed_point gamma_val) -{ - unsigned int i; - png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); - - if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++) - table[i] = png_gamma_8bit_correct(i, gamma_val); - - else for (i=0; i<256; ++i) - table[i] = (png_byte)i; -} - -/* Used from png_read_destroy and below to release the memory used by the gamma - * tables. - */ -void /* PRIVATE */ -png_destroy_gamma_table(png_structrp png_ptr) -{ - png_free(png_ptr, png_ptr->gamma_table); - png_ptr->gamma_table = NULL; - - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - png_ptr->gamma_16_table = NULL; - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_ptr->gamma_from_1 = NULL; - png_free(png_ptr, png_ptr->gamma_to_1); - png_ptr->gamma_to_1 = NULL; - - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - png_ptr->gamma_16_from_1 = NULL; - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - png_ptr->gamma_16_to_1 = NULL; - } -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ -} - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structrp png_ptr, int bit_depth) -{ - png_debug(1, "in png_build_gamma_table"); - - /* Remove any existing table; this copes with multiple calls to - * png_read_update_info. The warning is because building the gamma tables - * multiple times is a performance hit - it's harmless but the ability to call - * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible - * to warn if the app introduces such a hit. - */ - if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) - { - png_warning(png_ptr, "gamma table being rebuilt"); - png_destroy_gamma_table(png_ptr); - } - - if (bit_depth <= 8) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_table, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, - png_reciprocal(png_ptr->colorspace.gamma)); - - png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } - else - { - png_byte shift, sig_bit; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = png_ptr->sig_bit.red; - - if (png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - - if (png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - sig_bit = png_ptr->sig_bit.gray; - - /* 16-bit gamma code uses this equation: - * - * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] - * - * Where 'iv' is the input color value and 'ov' is the output value - - * pow(iv, gamma). - * - * Thus the gamma table consists of up to 256 256 entry tables. The table - * is selected by the (8-gamma_shift) most significant of the low 8 bits of - * the color value then indexed by the upper 8 bits: - * - * table[low bits][high 8 bits] - * - * So the table 'n' corresponds to all those 'iv' of: - * - * ..<(n+1 << gamma_shift)-1> - * - */ - if (sig_bit > 0 && sig_bit < 16U) - shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */ - - else - shift = 0; /* keep all 16 bits */ - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) - { - /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively - * the significant bits in the *input* when the output will - * eventually be 8 bits. By default it is 11. - */ - if (shift < (16U - PNG_MAX_GAMMA_8)) - shift = (16U - PNG_MAX_GAMMA_8); - } - - if (shift > 8U) - shift = 8U; /* Guarantees at least one table! */ - - png_ptr->gamma_shift = shift; - -#ifdef PNG_16BIT_SUPPORTED - /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now - * PNG_COMPOSE). This effectively smashed the background calculation for - * 16-bit output because the 8-bit table assumes the result will be reduced - * to 8 bits. - */ - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) -#endif - png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - -#ifdef PNG_16BIT_SUPPORTED - else - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) - { - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, - png_reciprocal(png_ptr->colorspace.gamma)); - - /* Notice that the '16 from 1' table should be full precision, however - * the lookup on this table still uses gamma_shift, so it can't be. - * TODO: fix this. - */ - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } -} -#endif /* READ_GAMMA */ - -/* HARDWARE OPTION SUPPORT */ -#ifdef PNG_SET_OPTION_SUPPORTED +/* this function was added to libpng 1.2.0 */ +#if !defined(PNG_USE_PNGGCCRD) && \ + !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) int PNGAPI -png_set_option(png_structrp png_ptr, int option, int onoff) +png_mmx_support(void) { - if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && - (option & 1) == 0) - { - int mask = 3 << option; - int setting = (2 + (onoff != 0)) << option; - int current = png_ptr->options; - - png_ptr->options = (png_byte)((current & ~mask) | setting); - - return (current & mask) >> option; - } - - return PNG_OPTION_INVALID; + return -1; } #endif +#endif /* PNG_1_0_X */ -/* sRGB support */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -/* sRGB conversion tables; these are machine generated with the code in - * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the - * specification (see the article at http://en.wikipedia.org/wiki/SRGB) - * is used, not the gamma=1/2.2 approximation use elsewhere in libpng. - * The sRGB to linear table is exact (to the nearest 16 bit linear fraction). - * The inverse (linear to sRGB) table has accuracies as follows: - * - * For all possible (255*65535+1) input values: - * - * error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact - * - * For the input values corresponding to the 65536 16-bit values: - * - * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact - * - * In all cases the inexact readings are off by one. - */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* The convert-to-sRGB table is only currently required for read. */ -const png_uint_16 png_sRGB_table[256] = +#ifdef PNG_SIZE_T +/* Added at libpng version 1.2.6 */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); +png_size_t PNGAPI +png_convert_size(size_t size) { - 0,20,40,60,80,99,119,139, - 159,179,199,219,241,264,288,313, - 340,367,396,427,458,491,526,562, - 599,637,677,718,761,805,851,898, - 947,997,1048,1101,1156,1212,1270,1330, - 1391,1453,1517,1583,1651,1720,1790,1863, - 1937,2013,2090,2170,2250,2333,2418,2504, - 2592,2681,2773,2866,2961,3058,3157,3258, - 3360,3464,3570,3678,3788,3900,4014,4129, - 4247,4366,4488,4611,4736,4864,4993,5124, - 5257,5392,5530,5669,5810,5953,6099,6246, - 6395,6547,6700,6856,7014,7174,7335,7500, - 7666,7834,8004,8177,8352,8528,8708,8889, - 9072,9258,9445,9635,9828,10022,10219,10417, - 10619,10822,11028,11235,11446,11658,11873,12090, - 12309,12530,12754,12980,13209,13440,13673,13909, - 14146,14387,14629,14874,15122,15371,15623,15878, - 16135,16394,16656,16920,17187,17456,17727,18001, - 18277,18556,18837,19121,19407,19696,19987,20281, - 20577,20876,21177,21481,21787,22096,22407,22721, - 23038,23357,23678,24002,24329,24658,24990,25325, - 25662,26001,26344,26688,27036,27386,27739,28094, - 28452,28813,29176,29542,29911,30282,30656,31033, - 31412,31794,32179,32567,32957,33350,33745,34143, - 34544,34948,35355,35764,36176,36591,37008,37429, - 37852,38278,38706,39138,39572,40009,40449,40891, - 41337,41785,42236,42690,43147,43606,44069,44534, - 45002,45473,45947,46423,46903,47385,47871,48359, - 48850,49344,49841,50341,50844,51349,51858,52369, - 52884,53401,53921,54445,54971,55500,56032,56567, - 57105,57646,58190,58737,59287,59840,60396,60955, - 61517,62082,62650,63221,63795,64372,64952,65535 -}; - -#endif /* simplified read only */ - -/* The base/delta tables are required for both read and write (but currently - * only the simplified versions.) - */ -const png_uint_16 png_sRGB_base[512] = -{ - 128,1782,3383,4644,5675,6564,7357,8074, - 8732,9346,9921,10463,10977,11466,11935,12384, - 12816,13233,13634,14024,14402,14769,15125,15473, - 15812,16142,16466,16781,17090,17393,17690,17981, - 18266,18546,18822,19093,19359,19621,19879,20133, - 20383,20630,20873,21113,21349,21583,21813,22041, - 22265,22487,22707,22923,23138,23350,23559,23767, - 23972,24175,24376,24575,24772,24967,25160,25352, - 25542,25730,25916,26101,26284,26465,26645,26823, - 27000,27176,27350,27523,27695,27865,28034,28201, - 28368,28533,28697,28860,29021,29182,29341,29500, - 29657,29813,29969,30123,30276,30429,30580,30730, - 30880,31028,31176,31323,31469,31614,31758,31902, - 32045,32186,32327,32468,32607,32746,32884,33021, - 33158,33294,33429,33564,33697,33831,33963,34095, - 34226,34357,34486,34616,34744,34873,35000,35127, - 35253,35379,35504,35629,35753,35876,35999,36122, - 36244,36365,36486,36606,36726,36845,36964,37083, - 37201,37318,37435,37551,37668,37783,37898,38013, - 38127,38241,38354,38467,38580,38692,38803,38915, - 39026,39136,39246,39356,39465,39574,39682,39790, - 39898,40005,40112,40219,40325,40431,40537,40642, - 40747,40851,40955,41059,41163,41266,41369,41471, - 41573,41675,41777,41878,41979,42079,42179,42279, - 42379,42478,42577,42676,42775,42873,42971,43068, - 43165,43262,43359,43456,43552,43648,43743,43839, - 43934,44028,44123,44217,44311,44405,44499,44592, - 44685,44778,44870,44962,45054,45146,45238,45329, - 45420,45511,45601,45692,45782,45872,45961,46051, - 46140,46229,46318,46406,46494,46583,46670,46758, - 46846,46933,47020,47107,47193,47280,47366,47452, - 47538,47623,47709,47794,47879,47964,48048,48133, - 48217,48301,48385,48468,48552,48635,48718,48801, - 48884,48966,49048,49131,49213,49294,49376,49458, - 49539,49620,49701,49782,49862,49943,50023,50103, - 50183,50263,50342,50422,50501,50580,50659,50738, - 50816,50895,50973,51051,51129,51207,51285,51362, - 51439,51517,51594,51671,51747,51824,51900,51977, - 52053,52129,52205,52280,52356,52432,52507,52582, - 52657,52732,52807,52881,52956,53030,53104,53178, - 53252,53326,53400,53473,53546,53620,53693,53766, - 53839,53911,53984,54056,54129,54201,54273,54345, - 54417,54489,54560,54632,54703,54774,54845,54916, - 54987,55058,55129,55199,55269,55340,55410,55480, - 55550,55620,55689,55759,55828,55898,55967,56036, - 56105,56174,56243,56311,56380,56448,56517,56585, - 56653,56721,56789,56857,56924,56992,57059,57127, - 57194,57261,57328,57395,57462,57529,57595,57662, - 57728,57795,57861,57927,57993,58059,58125,58191, - 58256,58322,58387,58453,58518,58583,58648,58713, - 58778,58843,58908,58972,59037,59101,59165,59230, - 59294,59358,59422,59486,59549,59613,59677,59740, - 59804,59867,59930,59993,60056,60119,60182,60245, - 60308,60370,60433,60495,60558,60620,60682,60744, - 60806,60868,60930,60992,61054,61115,61177,61238, - 61300,61361,61422,61483,61544,61605,61666,61727, - 61788,61848,61909,61969,62030,62090,62150,62211, - 62271,62331,62391,62450,62510,62570,62630,62689, - 62749,62808,62867,62927,62986,63045,63104,63163, - 63222,63281,63340,63398,63457,63515,63574,63632, - 63691,63749,63807,63865,63923,63981,64039,64097, - 64155,64212,64270,64328,64385,64443,64500,64557, - 64614,64672,64729,64786,64843,64900,64956,65013, - 65070,65126,65183,65239,65296,65352,65409,65465 -}; - -const png_byte png_sRGB_delta[512] = -{ - 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54, - 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36, - 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28, - 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24, - 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21, - 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19, - 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17, - 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15, - 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; -#endif /* SIMPLIFIED READ/WRITE sRGB support */ - -/* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -static int -png_image_free_function(png_voidp argument) -{ - png_imagep image = png_voidcast(png_imagep, argument); - png_controlp cp = image->opaque; - png_control c; - - /* Double check that we have a png_ptr - it should be impossible to get here - * without one. - */ - if (cp->png_ptr == NULL) - return 0; - - /* First free any data held in the control structure. */ -# ifdef PNG_STDIO_SUPPORTED - if (cp->owned_file) - { - FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr); - cp->owned_file = 0; - - /* Ignore errors here. */ - if (fp != NULL) - { - cp->png_ptr->io_ptr = NULL; - (void)fclose(fp); - } - } -# endif - - /* Copy the control structure so that the original, allocated, version can be - * safely freed. Notice that a png_error here stops the remainder of the - * cleanup, but this is probably fine because that would indicate bad memory - * problems anyway. - */ - c = *cp; - image->opaque = &c; - png_free(c.png_ptr, cp); - - /* Then the structures, calling the correct API. */ - if (c.for_write) - { -# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED - png_destroy_write_struct(&c.png_ptr, &c.info_ptr); -# else - png_error(c.png_ptr, "simplified write not supported"); -# endif - } - else - { -# ifdef PNG_SIMPLIFIED_READ_SUPPORTED - png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL); -# else - png_error(c.png_ptr, "simplified read not supported"); -# endif - } - - /* Success. */ - return 1; + if (size > (png_size_t)-1) + PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ + return ((png_size_t)size); } - -void PNGAPI -png_image_free(png_imagep image) -{ - /* Safely call the real function, but only if doing so is safe at this point - * (if not inside an error handling context). Otherwise assume - * png_safe_execute will call this API after the return. - */ - if (image != NULL && image->opaque != NULL && - image->opaque->error_buf == NULL) - { - /* Ignore errors here: */ - (void)png_safe_execute(image, png_image_free_function, image); - image->opaque = NULL; - } -} - -int /* PRIVATE */ -png_image_error(png_imagep image, png_const_charp error_message) -{ - /* Utility to log an error. */ - png_safecat(image->message, (sizeof image->message), 0, error_message); - image->warning_or_error |= PNG_IMAGE_ERROR; - png_image_free(image); - return 0; -} - -#endif /* SIMPLIFIED READ/WRITE */ -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ +#endif /* PNG_SIZE_T */ diff --git a/Source/3rd Party/wx/src/png/png.h b/Source/3rd Party/wx/src/png/png.h index 0b5053fcf..b57acb414 100644 --- a/Source/3rd Party/wx/src/png/png.h +++ b/Source/3rd Party/wx/src/png/png.h @@ -1,26 +1,23 @@ - /* png.h - header file for PNG reference library * - * libpng version 1.6.2 - April 25, 2013 - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license (See LICENSE, below) - * * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.2 - April 25, 2013: Glenn - * See also "Contributing Authors", below. + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.7 - September 12, 2004: Glenn + * See also "Contributing Authors", below. * * Note about libpng version numbers: * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: * * source png.h png.h shared-lib * version string int version @@ -109,93 +106,27 @@ * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 12.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-7 13 10210 12.so.0.10[.0] - * 1.2.10rc1-2 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.4.0beta1-5 14 10400 14.so.0.0[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.4.0beta7-8 14 10400 14.so.0.0[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.4.0beta9-14 14 10400 14.so.0.0[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.4.0beta15-36 14 10400 14.so.0.0[.0] - * 1.4.0beta37-87 14 10400 14.so.14.0[.0] - * 1.4.0rc01 14 10400 14.so.14.0[.0] - * 1.4.0beta88-109 14 10400 14.so.14.0[.0] - * 1.4.0rc02-08 14 10400 14.so.14.0[.0] - * 1.4.0 14 10400 14.so.14.0[.0] - * 1.4.1beta01-03 14 10401 14.so.14.1[.0] - * 1.4.1rc01 14 10401 14.so.14.1[.0] - * 1.4.1beta04-12 14 10401 14.so.14.1[.0] - * 1.4.1 14 10401 14.so.14.1[.0] - * 1.4.2 14 10402 14.so.14.2[.0] - * 1.4.3 14 10403 14.so.14.3[.0] - * 1.4.4 14 10404 14.so.14.4[.0] - * 1.5.0beta01-58 15 10500 15.so.15.0[.0] - * 1.5.0rc01-07 15 10500 15.so.15.0[.0] - * 1.5.0 15 10500 15.so.15.0[.0] - * 1.5.1beta01-11 15 10501 15.so.15.1[.0] - * 1.5.1rc01-02 15 10501 15.so.15.1[.0] - * 1.5.1 15 10501 15.so.15.1[.0] - * 1.5.2beta01-03 15 10502 15.so.15.2[.0] - * 1.5.2rc01-03 15 10502 15.so.15.2[.0] - * 1.5.2 15 10502 15.so.15.2[.0] - * 1.5.3beta01-10 15 10503 15.so.15.3[.0] - * 1.5.3rc01-02 15 10503 15.so.15.3[.0] - * 1.5.3beta11 15 10503 15.so.15.3[.0] - * 1.5.3 [omitted] - * 1.5.4beta01-08 15 10504 15.so.15.4[.0] - * 1.5.4rc01 15 10504 15.so.15.4[.0] - * 1.5.4 15 10504 15.so.15.4[.0] - * 1.5.5beta01-08 15 10505 15.so.15.5[.0] - * 1.5.5rc01 15 10505 15.so.15.5[.0] - * 1.5.5 15 10505 15.so.15.5[.0] - * 1.5.6beta01-07 15 10506 15.so.15.6[.0] - * 1.5.6rc01-03 15 10506 15.so.15.6[.0] - * 1.5.6 15 10506 15.so.15.6[.0] - * 1.5.7beta01-05 15 10507 15.so.15.7[.0] - * 1.5.7rc01-03 15 10507 15.so.15.7[.0] - * 1.5.7 15 10507 15.so.15.7[.0] - * 1.6.0beta01-40 16 10600 16.so.16.0[.0] - * 1.6.0rc01-08 16 10600 16.so.16.0[.0] - * 1.6.0 16 10600 16.so.16.0[.0] - * 1.6.1beta01-09 16 10601 16.so.16.1[.0] - * 1.6.1rc01 16 10601 16.so.16.1[.0] - * 1.6.1 16 10601 16.so.16.1[.0] - * 1.6.2beta01 16 10602 16.so.16.2[.0] - * 1.6.2rc01-06 16 10602 16.so.16.2[.0] - * 1.6.2 16 10602 16.so.16.2[.0] * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcNN". + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcN". * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). * - * See libpng-manual.txt or libpng.3 for more information. The PNG - * specification is available as a W3C Recommendation and as an ISO - * Specification, , and the application - * must include this before png.h to obtain the definition of jmp_buf. The - * function is required to be PNG_NORETURN, but this is not checked. If the - * function does return the application will crash via an abort() or similar - * system level call. - * - * If you get a warning here while building the library you may need to make - * changes to ensure that pnglibconf.h records the calling convention used by - * your compiler. This may be very difficult - try using a different compiler - * to build the library! - */ -PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); #endif /* Transform masks for the high-level interface */ @@ -941,663 +1012,646 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ -/* Added to libpng-1.2.34 */ -#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER -#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ -/* Added to libpng-1.4.0 */ -#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ -/* Added to libpng-1.5.4 */ -#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ -#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 -/* NOTE: prior to 1.5 these functions had no 'API' style declaration, - * this allowed the zlib default functions to be used on Windows - * platforms. In 1.5 the zlib default malloc (which just calls malloc and - * ignores the first argument) should be completely compatible with the - * following. - */ -typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, - png_alloc_size_t)); -typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); -/* Section 3: exported functions - * Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng-manual.txt for the +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ +#ifdef PNG_1_0_X + png_byte mng_features_permitted; +#else + png_uint_32 mng_features_permitted; +#endif /* PNG_1_0_X */ +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; + png_uint_32 asm_flags; +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; +#endif + +}; + + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef png_structp version_1_2_7; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. - * - * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in - * pngconf.h and in the *.dfn files in the scripts directory. - * - * PNG_EXPORT(ordinal, type, name, (args)); - * - * ordinal: ordinal that is used while building - * *.def files. The ordinal value is only - * relevant when preprocessing png.h with - * the *.dfn files for building symbol table - * entries, and are removed by pngconf.h. - * type: return type of the function - * name: function name - * args: function arguments, with types - * - * When we wish to append attributes to a function prototype we use - * the PNG_EXPORTA() macro instead. - * - * PNG_EXPORTA(ordinal, type, name, (args), attributes); - * - * ordinal, type, name, and args: same as in PNG_EXPORT(). - * attributes: function attributes */ /* Returns the version number of the library */ -PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ -PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ -PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, - png_size_t num_to_check)); +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ -#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); /* Allocate and initialize png_ptr struct for reading, and any other memory. */ -PNG_EXPORTA(4, png_structp, png_create_read_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn), - PNG_ALLOCATED); +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); /* Allocate and initialize png_ptr struct for writing, and any other memory */ -PNG_EXPORTA(5, png_structp, png_create_write_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn), - PNG_ALLOCATED); +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); -PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, - (png_const_structrp png_ptr)); - -PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, - png_size_t size)); - -/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp - * match up. - */ -#ifdef PNG_SETJMP_SUPPORTED -/* This function returns the jmp_buf built in to *png_ptr. It must be - * supplied with an appropriate 'longjmp' function to use on that jmp_buf - * unless the default error function is overridden in which case NULL is - * acceptable. The size of the jmp_buf is checked against the actual size - * allocated by the library - the call will return NULL on a mismatch - * indicating an ABI mismatch. - */ -PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, - png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); -# define png_jmpbuf(png_ptr) \ - (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); #endif -/* This function should be used by libpng applications in place of - * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it - * will use it; otherwise it will call PNG_ABORT(). This function was - * added in libpng-1.5.0. - */ -PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), - PNG_NORETURN); -#ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ -PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); -#endif +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(11, png_structp, png_create_read_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -PNG_EXPORTA(12, png_structp, png_create_write_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); #endif -/* Write the PNG file signature. */ -PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); - /* Write a PNG chunk - size, type, (optional) data, CRC. */ -PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep - chunk_name, png_const_bytep data, png_size_t length)); +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ -PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, - png_const_bytep chunk_name, png_uint_32 length)); +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ -PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, - png_const_bytep data, png_size_t length)); +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); /* Allocate and initialize the info structure */ -PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), - PNG_ALLOCATED); +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); -/* DEPRECATED: this function allowed init structures to be created using the - * default allocation method (typically malloc). Use is deprecated in 1.6.0 and - * the API will be removed in the future. - */ -PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, - png_size_t png_info_struct_size), PNG_DEPRECATED); +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#undef png_info_init +#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ + png_sizeof(png_info)); +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); /* Writes all the PNG information before the image. */ -PNG_EXPORT(20, void, png_write_info_before_PLTE, - (png_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(21, void, png_write_info, - (png_structrp png_ptr, png_const_inforp info_ptr)); +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. */ -PNG_EXPORT(22, void, png_read_info, - (png_structrp png_ptr, png_inforp info_ptr)); +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); #endif -#ifdef PNG_TIME_RFC1123_SUPPORTED - /* Convert to a US string format: there is no localization support in this - * routine. The original implementation used a 29 character buffer in - * png_struct, this will be removed in future versions. - */ -#if PNG_LIBPNG_VER < 10700 -/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ -PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, - png_const_timep ptime),PNG_DEPRECATED); -#endif -PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], - png_const_timep ptime)); +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); #endif -#ifdef PNG_CONVERT_tIME_SUPPORTED -/* Convert from a struct tm to png_time */ -PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, - const struct tm * ttime)); +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); -/* Convert from time_t to png_time. Uses gmtime() */ -PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); -#endif /* PNG_CONVERT_tIME_SUPPORTED */ +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); -PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); -PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); -PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion - * of a tRNS chunk if present. - */ -PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ -PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); #endif -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* Expand the grayscale to 24-bit RGB if necessary. */ -PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) /* Reduce RGB to grayscale. */ -#define PNG_ERROR_ACTION_NONE 1 -#define PNG_ERROR_ACTION_WARN 2 -#define PNG_ERROR_ACTION_ERROR 3 -#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ - -PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, - int error_action, double red, double green)) -PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green)) - -PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp - png_ptr)); +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); #endif -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, - png_colorp palette)); -#endif +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* How the alpha channel is interpreted - this affects how the color channels of - * a PNG file are returned when an alpha channel, or tRNS chunk in a palette - * file, is present. - * - * This has no effect on the way pixels are written into a PNG output - * datastream. The color samples in a PNG datastream are never premultiplied - * with the alpha samples. - * - * The default is to return data according to the PNG specification: the alpha - * channel is a linear measure of the contribution of the pixel to the - * corresponding composited pixel. The gamma encoded color channels must be - * scaled according to the contribution and to do this it is necessary to undo - * the encoding, scale the color values, perform the composition and reencode - * the values. This is the 'PNG' mode. - * - * The alternative is to 'associate' the alpha with the color information by - * storing color channel values that have been scaled by the alpha. The - * advantage is that the color channels can be resampled (the image can be - * scaled) in this form. The disadvantage is that normal practice is to store - * linear, not (gamma) encoded, values and this requires 16-bit channels for - * still images rather than the 8-bit channels that are just about sufficient if - * gamma encoding is used. In addition all non-transparent pixel values, - * including completely opaque ones, must be gamma encoded to produce the final - * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the - * latter being the two common names for associated alpha color channels.) - * - * Since it is not necessary to perform arithmetic on opaque color values so - * long as they are not to be resampled and are in the final color space it is - * possible to optimize the handling of alpha by storing the opaque pixels in - * the PNG format (adjusted for the output color space) while storing partially - * opaque pixels in the standard, linear, format. The accuracy required for - * standard alpha composition is relatively low, because the pixels are - * isolated, therefore typically the accuracy loss in storing 8-bit linear - * values is acceptable. (This is not true if the alpha channel is used to - * simulate transparency over large areas - use 16 bits or the PNG mode in - * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is - * treated as opaque only if the alpha value is equal to the maximum value. - * - * The final choice is to gamma encode the alpha channel as well. This is - * broken because, in practice, no implementation that uses this choice - * correctly undoes the encoding before handling alpha composition. Use this - * choice only if other serious errors in the software or hardware you use - * mandate it; the typical serious error is for dark halos to appear around - * opaque areas of the composited PNG image because of arithmetic overflow. - * - * The API function png_set_alpha_mode specifies which of these choices to use - * with an enumerated 'mode' value and the gamma of the required output: - */ -#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ -#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ -#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ -#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ -#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ -#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ - -PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, - double output_gamma)) -PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, - int mode, png_fixed_point output_gamma)) -#endif - -#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) -/* The output_gamma value is a screen gamma in libpng terminology: it expresses - * how to decode the output values, not how they are encoded. The values used - * correspond to the normal numbers used to describe the overall gamma of a - * computer display system; for example 2.2 for an sRGB conformant system. The - * values are scaled by 100000 in the _fixed version of the API (so 220000 for - * sRGB.) - * - * The inverse of the value is always used to provide a default for the PNG file - * encoding if it has no gAMA chunk and if png_set_gamma() has not been called - * to override the PNG gamma information. - * - * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode - * opaque pixels however pixels with lower alpha values are not encoded, - * regardless of the output gamma setting. - * - * When the standard Porter Duff handling is requested with mode 1 the output - * encoding is set to be linear and the output_gamma value is only relevant - * as a default for input data that has no gamma information. The linear output - * encoding will be overridden if png_set_gamma() is called - the results may be - * highly unexpected! - * - * The following numbers are derived from the sRGB standard and the research - * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of - * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing - * correction required to take account of any differences in the color - * environment of the original scene and the intended display environment; the - * value expresses how to *decode* the image for display, not how the original - * data was *encoded*. - * - * sRGB provides a peg for the PNG standard by defining a viewing environment. - * sRGB itself, and earlier TV standards, actually use a more complex transform - * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is - * limited to simple power laws.) By saying that an image for direct display on - * an sRGB conformant system should be stored with a gAMA chunk value of 45455 - * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification - * makes it possible to derive values for other display systems and - * environments. - * - * The Mac value is deduced from the sRGB based on an assumption that the actual - * extra viewing correction used in early Mac display systems was implemented as - * a power 1.45 lookup table. - * - * Any system where a programmable lookup table is used or where the behavior of - * the final display device characteristics can be changed requires system - * specific code to obtain the current characteristic. However this can be - * difficult and most PNG gamma correction only requires an approximate value. - * - * By default, if png_set_alpha_mode() is not called, libpng assumes that all - * values are unencoded, linear, values and that the output device also has a - * linear characteristic. This is only very rarely correct - it is invariably - * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the - * default if you don't know what the right answer is! - * - * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS - * 10.6) which used a correction table to implement a somewhat lower gamma on an - * otherwise sRGB system. - * - * Both these values are reserved (not simple gamma values) in order to allow - * more precise correction internally in the future. - * - * NOTE: the following values can be passed to either the fixed or floating - * point APIs, but the floating point API will also accept floating point - * values. - */ -#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ -#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ -#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ -#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ -#endif - -/* The following are examples of calls to png_set_alpha_mode to achieve the - * required overall gamma correction and, where necessary, alpha - * premultiplication. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * This is the default libpng handling of the alpha channel - it is not - * pre-multiplied into the color components. In addition the call states - * that the output is for a sRGB system and causes all PNG files without gAMA - * chunks to be assumed to be encoded using sRGB. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * In this case the output is assumed to be something like an sRGB conformant - * display preceeded by a power-law lookup table of power 1.45. This is how - * early Mac systems behaved. - * - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); - * This is the classic Jim Blinn approach and will work in academic - * environments where everything is done by the book. It has the shortcoming - * of assuming that input PNG data with no gamma information is linear - this - * is unlikely to be correct unless the PNG files where generated locally. - * Most of the time the output precision will be so low as to show - * significant banding in dark areas of the image. - * - * png_set_expand_16(pp); - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); - * This is a somewhat more realistic Jim Blinn inspired approach. PNG files - * are assumed to have the sRGB encoding if not marked with a gamma value and - * the output is always 16 bits per component. This permits accurate scaling - * and processing of the data. If you know that your input PNG files were - * generated locally you might need to replace PNG_DEFAULT_sRGB with the - * correct value for your system. - * - * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); - * If you just need to composite the PNG image onto an existing background - * and if you control the code that does this you can use the optimization - * setting. In this case you just copy completely opaque pixels to the - * output. For pixels that are not completely transparent (you just skip - * those) you do the composition math using png_composite or png_composite_16 - * below then encode the resultant 8-bit or 16-bit values to match the output - * encoding. - * - * Other cases - * If neither the PNG nor the standard linear encoding work for you because - * of the software or hardware you use then you have a big problem. The PNG - * case will probably result in halos around the image. The linear encoding - * will probably result in a washed out, too bright, image (it's actually too - * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably - * substantially reduce the halos. Alternatively try: - * - * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); - * This option will also reduce the halos, but there will be slight dark - * halos round the opaque parts of the image where the background is light. - * In the OPTIMIZED mode the halos will be light halos where the background - * is dark. Take your pick - the halos are unavoidable unless you can get - * your hardware/software fixed! (The OPTIMIZED approach is slightly - * faster.) - * - * When the default gamma of PNG files doesn't match the output gamma. - * If you have PNG files with no gamma information png_set_alpha_mode allows - * you to provide a default gamma, but it also sets the ouput gamma to the - * matching value. If you know your PNG files have a gamma that doesn't - * match the output you can take advantage of the fact that - * png_set_alpha_mode always sets the output gamma but only sets the PNG - * default if it is not already set: - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * The first call sets both the default and the output gamma values, the - * second call overrides the output gamma without changing the default. This - * is easier than achieving the same effect with png_set_gamma. You must use - * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will - * fire if more than one call to png_set_alpha_mode and png_set_background is - * made in the same read operation, however multiple calls with PNG_ALPHA_PNG - * are ignored. - */ - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, - int flags)); +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ -# define PNG_FILLER_BEFORE 0 -# define PNG_FILLER_AFTER 1 +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, - png_uint_32 filler, int flags)); +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +#endif #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ -PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ -PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ -PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p - true_bits)); +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. - * MUST be called before png_read_update_info or png_start_read_image, - * otherwise it will not have the desired effect. Note that it is still - * necessary to call png_read_row or png_read_rows png_get_image_height - * times for each pass. -*/ -PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ -PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); #endif -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS by replacing with a background color. Prior to - * libpng-1.5.4 this API must not be called before the PNG file header has been - * read. Doing so will result in unexpected behavior and possible warnings or - * errors if the PNG file contains a bKGD chunk. - */ -PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)) -PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma)) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); #endif -#ifdef PNG_READ_BACKGROUND_SUPPORTED -# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -# define PNG_BACKGROUND_GAMMA_SCREEN 1 -# define PNG_BACKGROUND_GAMMA_FILE 2 -# define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale a 16-bit depth file down to 8-bit, accurately. */ -PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); #endif -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ -/* Strip the second byte of information from a 16-bit depth file. */ -PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); #endif -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Turn on quantizing, and reduce the palette to the number of colors - * available. - */ -PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_const_uint_16p histogram, int full_quantize)); +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif #endif -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The threshold on gamma processing is configurable but hard-wired into the - * library. The following is the floating point variant. - */ -#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) - -/* Handle gamma correction. Screen_gamma=(display_exponent). - * NOTE: this API simply sets the screen and file gamma values. It will - * therefore override the value for gamma in a PNG file if it is called after - * the file header has been read - use with care - call before reading the PNG - * file for best results! - * - * These routines accept the same gamma values as png_set_alpha_mode (described - * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either - * API (floating point or fixed.) Notice, however, that the 'file_gamma' value - * is the inverse of a 'screen gamma' value. - */ -PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, - double screen_gamma, double override_file_gamma)) -PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, - png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); #endif -#ifdef PNG_WRITE_FLUSH_SUPPORTED +#if defined(PNG_WRITE_FLUSH_SUPPORTED) /* Set how many lines between output flushes - 0 for no flushing */ -PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); /* Flush the current PNG output buffer */ -PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); #endif -/* Optional update palette with requested transformations */ -PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); -/* Optional call to update the users info structure */ -PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, - png_inforp info_ptr)); +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. */ -PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows)); +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read one or more rows of image data. */ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read a row of data. */ -PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, - png_bytep display_row)); +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read a row of data. */ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); #endif -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the whole image into memory at once. */ -PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); #endif -/* Write a row of image data */ -PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, - png_const_bytep row)); +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); -/* Write a few rows of image data: (*row) is not written; however, the type - * is declared as writeable to maintain compatibility with previous versions - * of libpng and to allow the 'display_row' array from read_rows to be passed - * unchanged to write_rows. - */ -PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, - png_uint_32 num_rows)); +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); -/* Write the image data */ -PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); -/* Write the end of the PNG file. */ -PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, - png_inforp info_ptr)); +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. */ -PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); #endif -/* Free any memory associated with the png_info_struct */ -PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, - png_infopp info_ptr_ptr)); +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr)); +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); -/* Set the libpng method of handling chunk CRC errors */ -PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, - int ancil_action)); +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); -/* Values for png_set_crc_action() say how to handle CRC errors in +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, @@ -1621,11 +1675,11 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, * header file (zlib.h) for an explination of the compression functions. */ -/* Set the filtering method(s) used by libpng. Currently, the only valid +/* set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ -PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, - int filters)); +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types @@ -1651,7 +1705,7 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). @@ -1680,13 +1734,11 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ -PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, - int heuristic_method, int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs)) -PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, - (png_structrp png_ptr, int heuristic_method, int num_weights, - png_const_fixed_point_p filter_weights, - png_const_fixed_point_p filter_costs)) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be @@ -1697,7 +1749,6 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ -#ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have @@ -1705,58 +1756,33 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ -PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, - int level)); +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); -PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, - int mem_level)); +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); -PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, - int strategy)); +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, - int window_bits)); +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); -PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, - int method)); -#endif - -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -/* Also set zlib parameters for compressing non-IDAT chunks */ -PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, - int level)); - -PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, - int mem_level)); - -PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(225, void, png_set_text_compression_window_bits, - (png_structrp png_ptr, int window_bits)); - -PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, - int method)); -#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng-manual.txt for + * different manner by calling png_set_???_fn(). See libpng.txt for * more information. */ -#ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) /* Initialize the input/output for the PNG file to the default functions. */ -PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user @@ -1767,181 +1793,128 @@ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); * default function will be used. */ -PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ -PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). - * It is probably a mistake to use NULL for output_flush_fn if - * write_data_fn is not also NULL unless you have built libpng with - * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's - * default flush function, which uses the standard *FILE structure, will - * be used. */ -PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ -PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn)); +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ -PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); -PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, - png_read_status_ptr read_row_fn)); +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); -PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, - png_write_status_ptr write_row_fn)); +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ -PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ -PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); #endif -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr read_user_transform_fn)); +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr write_user_transform_fn)); +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, - png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ -PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, - (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -/* Return information about the row currently being processed. Note that these - * APIs do not fail but will return unexpected results if called outside a user - * transform callback. Also note that when transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); -PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); -#endif - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* This callback is called only for *unknown* chunks. If - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known - * chunks to be treated as unknown, however in this case the callback must do - * any processing required by the chunk (e.g. by calling the appropriate - * png_set_ APIs.) - * - * There is no write support - on write, by default, all the chunks in the - * 'unknown' list are written in the specified position. - * - * The integer return from the callback function is interpreted thus: - * - * negative: An error occured, png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be saved. A critical - * chunk will cause an error at this point unless it is to be saved. - * positive: The chunk was handled, libpng will ignore/discard it. - * - * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about - * how this behavior will change in libpng 1.7 - */ -PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED -PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ -PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, - png_voidp progressive_ptr, png_progressive_info_ptr info_fn, - png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); -/* Returns the user pointer associated with the push read functions */ -PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, - (png_const_structrp png_ptr)); +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); -/* Function to be called when data becomes available */ -PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, - png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); -/* A function which may be called *only* within png_process_data to stop the - * processing of any more data. The function returns the number of bytes - * remaining, excluding any that libpng has cached internally. A subsequent - * call to png_process_data must supply these bytes again. If the argument - * 'save' is set to true the routine will first save all the pending data and - * will always return 0. +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? */ -PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); - -/* A function which may be called *only* outside (after) a call to - * png_process_data. It returns the number of bytes of data to skip in the - * input. Normally it will return 0, but if it returns a non-zero value the - * application must skip than number of bytes of input data and pass the - * following data to the next call to png_process_data. - */ -PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); - -#ifdef PNG_READ_INTERLACING_SUPPORTED -/* Function that combines rows. 'new_row' is a flag that should come from - * the callback and be non-NULL if anything needs to be done; the library - * stores its own version of the new data internally and ignores the passed - * in value. - */ -PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, - png_bytep old_row, png_const_bytep new_row)); -#endif /* PNG_READ_INTERLACING_SUPPORTED */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ -PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); -/* Added at libpng version 1.4.0 */ -PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else /* Added at libpng version 1.2.4 */ -PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); +extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#endif -/* Frees a pointer allocated by png_malloc() */ -PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +#if defined(PNG_1_0_X) +/* Function to allocate memory for zlib. */ +extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, + uInt size)); + +/* Function to free memory for zlib */ +extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); +#endif /* Free data that was allocated internally */ -PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 free_me, int num)); - +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED /* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application; this works on the png_info structure passed - * in, it does not change the state for other png_info structures. - * - * It is unlikely that this function works correctly as of 1.6.0 and using it - * may result either in memory leaks or double free of allocated data. - */ -PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, - png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); - -/* Assignments for png_data_freer */ + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 @@ -1952,10 +1925,8 @@ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_FREE_UNKN 0x0200 -#endif -/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 @@ -1963,59 +1934,38 @@ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); -PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, - png_voidp ptr), PNG_DEPRECATED); +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); #endif -#ifdef PNG_ERROR_TEXT_SUPPORTED +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + /* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); /* The same, but the chunk name is prepended to the error string. */ -PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); -#else -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); -#endif - -#ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ -PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ -PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Benign error in libpng. Can continue, but may have a problem. - * User can choose whether to handle as a fatal error or as a warning. */ -PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); - -#ifdef PNG_READ_SUPPORTED -/* Same, chunk name is prepended to message (only during read) */ -PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif - -PNG_EXPORT(109, void, png_set_benign_errors, - (png_structrp png_ptr, int allowed)); -#else -# ifdef PNG_ALLOW_BENIGN_ERRORS -# define png_benign_error png_warning -# define png_chunk_benign_error png_chunk_warning -# else -# define png_benign_error png_error -# define png_chunk_benign_error png_chunk_error -# endif -#endif +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the @@ -2030,495 +1980,422 @@ PNG_EXPORT(109, void, png_set_benign_errors, * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ -PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 flag)); +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ -PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); -#ifdef PNG_INFO_IMAGE_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) /* Returns row_pointers, which is an array of pointers to scanlines that was - * returned from png_read_png(). - */ -PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use - * by png_write_png(). - */ -PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytepp row_pointers)); +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ -PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ -PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image height in pixels. */ -PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image bit_depth. */ -PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image color_type. */ -PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image filter_type. */ -PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image interlace_type. */ -PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image compression_type. */ -PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ -PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ -PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ -#ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ -PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); #endif -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_16p *background)); +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); #endif -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_16p background)); +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif #endif -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)) -PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, - double *green_X, double *green_Y, double *green_Z, double *blue_X, - double *blue_Y, double *blue_Z)) -PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_white_x, png_fixed_point *int_white_y, - png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, - png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) -PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z)) +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif #endif -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, - double white_x, double white_y, double red_x, double red_y, double green_x, - double green_y, double blue_x, double blue_y)) -PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, - png_inforp info_ptr, double red_X, double red_Y, double red_Z, - double green_X, double green_Y, double green_Z, double blue_X, - double blue_Y, double blue_Z)) -PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_white_x, - png_fixed_point int_white_y, png_fixed_point int_red_x, - png_fixed_point int_red_y, png_fixed_point int_green_x, - png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)) -PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z)) +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); #endif -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *file_gamma)) -PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_file_gamma)) +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); #endif -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, - png_inforp info_ptr, double file_gamma)) -PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_file_gamma)) +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); #endif -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_16p *hist)); +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); #endif -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_uint_16p hist)); -#endif +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); -PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); -PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); #endif -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, - png_int_32 *X1, int *type, int *nparams, png_charp *units, - png_charpp *params)); +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); #endif -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_const_charp units, png_charpp params)); +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); #endif -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif -PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, - png_inforp info_ptr, png_colorp *palette, int *num_palette)); +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); -PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, - png_inforp info_ptr, png_const_colorp palette, int num_palette)); +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_8p *sig_bit)); +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); #endif -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_8p sig_bit)); +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); #endif -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *file_srgb_intent)); +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); #endif -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); -PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); #endif -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charpp name, int *compression_type, - png_bytepp profile, png_uint_32 *proflen)); +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ #endif -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp name, int compression_type, - png_const_bytep profile, png_uint_32 proflen)); +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ #endif -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_sPLT_tpp entries)); +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); #endif -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); #endif -#ifdef PNG_TEXT_SUPPORTED +#if defined(PNG_TEXT_SUPPORTED) /* png_get_text also returns the number of text chunks in *num_text */ -PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_textp *text_ptr, int *num_text)); +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); #endif -/* Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. */ -#ifdef PNG_TEXT_SUPPORTED -PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_textp text_ptr, int num_text)); +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); #endif -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_timep *mod_time)); +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); #endif -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_timep mod_time)); +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); #endif -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, - png_color_16p *trans_color)); +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); #endif -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, - png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, - png_const_color_16p trans_color)); +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); #endif -#ifdef PNG_sCAL_SUPPORTED -PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *unit, double *width, double *height)) -#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* NOTE: this API is currently implemented using floating point arithmetic, - * consequently it can only be used on systems with floating point support. - * In any case the range of values supported by png_fixed_point is small and it - * is highly recommended that png_get_sCAL_s be used instead. - */ -PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_fixed_point *width, png_fixed_point *height)) +#if defined(PNG_tRNS_SUPPORTED) #endif -PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_charpp swidth, png_charpp sheight)); -PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, double width, double height)) -PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, png_fixed_point width, - png_fixed_point height)) -PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, - png_const_charp swidth, png_const_charp sheight)); +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif #endif /* PNG_sCAL_SUPPORTED */ -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -/* Provide the default handling for all unknown chunks or, optionally, for - * specific unknown chunks. - * - * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was - * ignored and the default was used, the per-chunk setting only had an effect on - * write. If you wish to have chunk-specific handling on read in code that must - * work on earlier versions you must use a user chunk callback to specify the - * desired handling (keep or discard.) - * - * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The - * parameter is interpreted as follows: - * - * READ: - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Known chunks: do normal libpng processing, do not keep the chunk (but - * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) - * Unknown chunks: for a specific chunk use the global default, when used - * as the default discard the chunk data. - * PNG_HANDLE_CHUNK_NEVER: - * Discard the chunk data. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Keep the chunk data if the chunk is not critical else raise a chunk - * error. - * PNG_HANDLE_CHUNK_ALWAYS: - * Keep the chunk data. - * - * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, - * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent - * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks - * it simply resets the behavior to the libpng default. - * - * INTERACTION WTIH USER CHUNK CALLBACKS: - * The per-chunk handling is always used when there is a png_user_chunk_ptr - * callback and the callback returns 0; the chunk is then always stored *unless* - * it is critical and the per-chunk setting is other than ALWAYS. Notice that - * the global default is *not* used in this case. (In effect the per-chunk - * value is incremented to at least IF_SAFE.) - * - * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and - * per-chunk defaults will be honored. If you want to preserve the current - * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE - * as the default - if you don't do this libpng 1.6 will issue a warning. - * - * If you want unhandled unknown chunks to be discarded in libpng 1.6 and - * earlier simply return '1' (handled). - * - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: - * If this is *not* set known chunks will always be handled by libpng and - * will never be stored in the unknown chunk list. Known chunks listed to - * png_set_keep_unknown_chunks will have no effect. If it is set then known - * chunks listed with a keep other than AS_DEFAULT will *never* be processed - * by libpng, in addition critical chunks must either be processed by the - * callback or saved. - * - * The IHDR and IEND chunks must not be listed. Because this turns off the - * default handling for chunks that would otherwise be recognized the - * behavior of libpng transformations may well become incorrect! - * - * WRITE: - * When writing chunks the options only apply to the chunks specified by - * png_set_unknown_chunks (below), libpng will *always* write known chunks - * required by png_set_ calls and will always write the core critical chunks - * (as required for PLTE). - * - * Each chunk in the png_set_unknown_chunks list is looked up in the - * png_set_keep_unknown_chunks list to find the keep setting, this is then - * interpreted as follows: - * - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Write safe-to-copy chunks and write other chunks if the global - * default is set to _ALWAYS, otherwise don't write this chunk. - * PNG_HANDLE_CHUNK_NEVER: - * Do not write the chunk. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Write the chunk if it is safe-to-copy, otherwise do not write it. - * PNG_HANDLE_CHUNK_ALWAYS: - * Write the chunk. - * - * Note that the default behavior is effectively the opposite of the read case - - * in read unknown chunks are not stored by default, in write they are written - * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different - * - on write the safe-to-copy bit is checked, on read the critical bit is - * checked and on read if the chunk is critical an error will be raised. - * - * num_chunks: - * =========== - * If num_chunks is positive, then the "keep" parameter specifies the manner - * for handling only those chunks appearing in the chunk_list array, - * otherwise the chunk list array is ignored. - * - * If num_chunks is 0 the "keep" parameter specifies the default behavior for - * unknown chunks, as described above. - * - * If num_chunks is negative, then the "keep" parameter specifies the manner - * for handling all unknown chunks plus all chunks recognized by libpng - * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to - * be processed by libpng. - */ -PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, - int keep, png_const_bytep chunk_list, int num_chunks)); - -/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; - * the result is therefore true (non-zero) if special handling is required, - * false for the default handling. - */ -PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, - png_const_bytep chunk_name)); +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); #endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, - int num_unknowns)); - /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added - * unknowns to the location currently stored in the png_struct. This is - * invariably the wrong value on write. To fix this call the following API - * for each chunk in the list with the correct location. If you know your - * code won't be compiled on earlier versions you can rely on - * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing - * the correct thing. - */ - -PNG_EXPORT(175, void, png_set_unknown_chunk_location, - (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); - -PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_unknown_chunkpp entries)); +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behavour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. - * If you need to turn it off for a chunk that your application has freed, - * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); - */ -PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, - png_inforp info_ptr, int mask)); + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); -#ifdef PNG_INFO_IMAGE_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) /* The "params" pointer is currently not used and is for future expansion. */ -PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); -PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); #endif -PNG_EXPORT(180, png_const_charp, png_get_copyright, - (png_const_structrp png_ptr)); -PNG_EXPORT(181, png_const_charp, png_get_header_ver, - (png_const_structrp png_ptr)); -PNG_EXPORT(182, png_const_charp, png_get_header_version, - (png_const_structrp png_ptr)); -PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, - (png_const_structrp png_ptr)); +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#define png_debug(l,m) _RPT0(_CRT_WARN,m) +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ +#if (PNG_DEBUG > 1) +#define png_debug(l,m) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ +} +#define png_debug1(l,m,p1) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ +} +#define png_debug2(l,m,p1,p2) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ +} +#endif /* (PNG_DEBUG > 1) */ +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, - png_uint_32 mng_features_permitted)); +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ @@ -2526,151 +2403,92 @@ PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 -#define PNG_HANDLE_CHUNK_LAST 4 + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 + +#if !defined(PNG_1_0_X) +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_1_0_X */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +#if !defined(PNG_1_0_X) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); /* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. - */ + * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED -PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, - png_uint_32 strip_mode)); +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); #endif -/* Added in libpng-1.2.6 */ +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED -PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, - png_uint_32 user_width_max, png_uint_32 user_height_max)); -PNG_EXPORT(187, png_uint_32, png_get_user_width_max, - (png_const_structrp png_ptr)); -PNG_EXPORT(188, png_uint_32, png_get_user_height_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.0 */ -PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, - png_uint_32 user_chunk_cache_max)); -PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.1 */ -PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, - png_alloc_size_t user_chunk_cache_max)); -PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, - (png_const_structrp png_ptr)); +extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp + png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); +extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp + png_ptr)); +extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp + png_ptr)); #endif -#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) -PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_FP_EXPORT(196, float, png_get_x_offset_inches, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, - png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -# ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -# endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ - -/* Added in libpng-1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); - -/* Removed from libpng 1.6; use png_get_io_chunk_type. */ -PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), - PNG_DEPRECATED) - -PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, - (png_const_structrp png_ptr)); - -/* The flags returned by png_get_io_state() are the following: */ -# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ -# define PNG_IO_READING 0x0001 /* currently reading */ -# define PNG_IO_WRITING 0x0002 /* currently writing */ -# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ -# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ -# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ -# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ -# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ -# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ -#endif /* ?PNG_IO_STATE_SUPPORTED */ - -/* Interlace support. The following macros are always defined so that if - * libpng interlace handling is turned off the macros may be used to handle - * interlaced images within the application. - */ -#define PNG_INTERLACE_ADAM7_PASSES 7 - -/* Two macros to return the first row and first column of the original, - * full, image which appears in a given pass. 'pass' is in the range 0 - * to 6 and the result is in the range 0 to 7. - */ -#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) -#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) - -/* A macro to return the offset between pixels in the output row for a pair of - * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that - * follows. Note that ROW_OFFSET is the offset from one row to the next whereas - * COL_OFFSET is from one column to the next, within a row. - */ -#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) -#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) - -/* Two macros to help evaluate the number of rows or columns in each - * pass. This is expressed as a shift - effectively log2 of the number or - * rows or columns in each 8x8 tile of the original image. - */ -#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) -#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) - -/* Hence two macros to determine the number of rows or columns in a given - * pass of an image given its height or width. In fact these macros may - * return non-zero even though the sub-image is empty, because the other - * dimension may be empty for a small image. - */ -#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) -#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) - -/* For the reader row callbacks (both progressive and sequential) it is - * necessary to find the row in the output image given a row in an interlaced - * image, so two more macros: - */ -#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ - (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ - ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) - -#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ - ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) -#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ - ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2685,620 +2503,862 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } -#else /* Standard method using integer division */ +#else /* standard method using integer division */ -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255) +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535) + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); -PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); -PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +#if defined(PNG_INTERNAL) + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ +#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ + (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + ideal-delta..ideal+delta. Each argument is evaluated twice. + "ideal" and "delta" should be constants, normally simple + integers, "value" a variable. Added to libpng-1.2.6 JB */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#define png_sig png_sig_bytes(NULL) +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +# endif +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +#else +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); +# endif +PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); +PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ +/* RN: This define is blatent hack to get png to (hopefully) + link on OSX 10.2 and earlier versions of 10.3 due to an + Apple linking bug introduced in 10.2 */ +#define png_get_uint_31 wxpng_get_uint_31 +PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr, + png_bytep buf)); +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#undef png_read_init +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#undef png_write_init +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_1_0_X +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +#ifdef PNG_SIZE_T +/* Function to convert a sizeof an item to png_sizeof item */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); #endif -PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, - png_const_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); #endif -#ifdef PNG_SAVE_INT_32_SUPPORTED -PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif +#else /* PNG_1_0_X */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif +#endif /* PNG_1_0_X */ + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + * The only currently known PNG chunks that use signed numbers are + * the ancillary extension chunks, oFFs and pCAL. + */ +PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); + +#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ +PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif #endif -#ifdef PNG_USE_READ_MACROS -/* Inline macros to do direct reads of bytes from the input buffer. - * The png_get_int_32() routine assumes we are using two's complement - * format for negative values, which is almost certainly true. - */ -# define PNG_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif - /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the - * function) incorrectly returned a value of type png_uint_32. - */ -# define PNG_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif -# define PNG_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ - : (png_int_32)png_get_uint_32(buf))) +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif - /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, - * but defining a macro name prefixed with PNG_PREFIX. - */ -# ifndef PNG_PREFIX -# define png_get_uint_32(buf) PNG_get_uint_32(buf) -# define png_get_uint_16(buf) PNG_get_uint_16(buf) -# define png_get_int_32(buf) PNG_get_int_32(buf) -# endif +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); #else -# ifdef PNG_PREFIX - /* No macros; revert to the (redefined) function */ -# define PNG_get_uint_32 (png_get_uint_32) -# define PNG_get_uint_16 (png_get_uint_16) -# define PNG_get_int_32 (png_get_int_32) +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); # endif #endif -/******************************************************************************* - * SIMPLIFIED API - ******************************************************************************* - * - * Please read the documentation in libpng-manual.txt (TODO: write said - * documentation) if you don't understand what follows. - * - * The simplified API hides the details of both libpng and the PNG file format - * itself. It allows PNG files to be read into a very limited number of - * in-memory bitmap formats or to be written from the same formats. If these - * formats do not accomodate your needs then you can, and should, use the more - * sophisticated APIs above - these support a wide variety of in-memory formats - * and a wide variety of sophisticated transformations to those formats as well - * as a wide variety of APIs to manipulate ancillary information. - * - * To read a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure (see below) on the stack and set the - * version field to PNG_IMAGE_VERSION. - * 2) Call the appropriate png_image_begin_read... function. - * 3) Set the png_image 'format' member to the required sample format. - * 4) Allocate a buffer for the image and, if required, the color-map. - * 5) Call png_image_finish_read to read the image and, if required, the - * color-map into your buffers. - * - * There are no restrictions on the format of the PNG input itself; all valid - * color types, bit depths, and interlace methods are acceptable, and the - * input image is transformed as necessary to the requested in-memory format - * during the png_image_finish_read() step. The only caveat is that if you - * request a color-mapped image from a PNG that is full-color or makes - * complex use of an alpha channel the transformation is extremely lossy and the - * result may look terrible. - * - * To write a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. - * 2) Initialize the members of the structure that describe the image, setting - * the 'format' member to the format of the image samples. - * 3) Call the appropriate png_image_write... function with a pointer to the - * image and, if necessary, the color-map to write the PNG data. - * - * png_image is a structure that describes the in-memory format of an image - * when it is being read or defines the in-memory format of an image that you - * need to write: - */ -#define PNG_IMAGE_VERSION 1 - -typedef struct png_control *png_controlp; -typedef struct -{ - png_controlp opaque; /* Initialize to NULL, free with png_image_free */ - png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ - png_uint_32 width; /* Image width in pixels (columns) */ - png_uint_32 height; /* Image height in pixels (rows) */ - png_uint_32 format; /* Image format as defined below */ - png_uint_32 flags; /* A bit mask containing informational flags */ - png_uint_32 colormap_entries; - /* Number of entries in the color-map */ - - /* In the event of an error or warning the following field will be set to a - * non-zero value and the 'message' field will contain a '\0' terminated - * string with the libpng error or warning message. If both warnings and - * an error were encountered, only the error is recorded. If there - * are multiple warnings, only the first one is recorded. - * - * The upper 30 bits of this value are reserved, the low two bits contain - * a value as follows: - */ -# define PNG_IMAGE_WARNING 1 -# define PNG_IMAGE_ERROR 2 - /* - * The result is a two bit code such that a value more than 1 indicates - * a failure in the API just called: - * - * 0 - no warning or error - * 1 - warning - * 2 - error - * 3 - error preceded by warning - */ -# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) - - png_uint_32 warning_or_error; - - char message[64]; -} png_image, *png_imagep; - -/* The samples of the image have one to four channels whose components have - * original values in the range 0 to 1.0: - * - * 1: A single gray or luminance channel (G). - * 2: A gray/luminance channel and an alpha channel (GA). - * 3: Three red, green, blue color channels (RGB). - * 4: Three color channels and an alpha channel (RGBA). - * - * The components are encoded in one of two ways: - * - * a) As a small integer, value 0..255, contained in a single byte. For the - * alpha channel the original value is simply value/255. For the color or - * luminance channels the value is encoded according to the sRGB specification - * and matches the 8-bit format expected by typical display devices. - * - * The color/gray channels are not scaled (pre-multiplied) by the alpha - * channel and are suitable for passing to color management software. - * - * b) As a value in the range 0..65535, contained in a 2-byte integer. All - * channels can be converted to the original value by dividing by 65535; all - * channels are linear. Color channels use the RGB encoding (RGB end-points) of - * the sRGB specification. This encoding is identified by the - * PNG_FORMAT_FLAG_LINEAR flag below. - * - * When the simplified API needs to convert between sRGB and linear colorspaces, - * the actual sRGB transfer curve defined in the sRGB specification (see the - * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 - * approximation used elsewhere in libpng. - * - * When an alpha channel is present it is expected to denote pixel coverage - * of the color or luminance channels and is returned as an associated alpha - * channel: the color/gray channels are scaled (pre-multiplied) by the alpha - * value. - * - * The samples are either contained directly in the image data, between 1 and 8 - * bytes per pixel according to the encoding, or are held in a color-map indexed - * by bytes in the image data. In the case of a color-map the color-map entries - * are individual samples, encoded as above, and the image data has one byte per - * pixel to select the relevant sample from the color-map. - */ - -/* PNG_FORMAT_* - * - * #defines to be used in png_image::format. Each #define identifies a - * particular layout of sample data and, if present, alpha values. There are - * separate defines for each of the two component encodings. - * - * A format is built up using single bit flag values. All combinations are - * valid. Formats can be built up from the flag values or you can use one of - * the predefined values below. When testing formats always use the FORMAT_FLAG - * macros to test for individual features - future versions of the library may - * add new flags. - * - * When reading or writing color-mapped images the format should be set to the - * format of the entries in the color-map then png_image_{read,write}_colormap - * called to read or write the color-map and set the format correctly for the - * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! - * - * NOTE: libpng can be built with particular features disabled, if you see - * compiler errors because the definition of one of the following flags has been - * compiled out it is because libpng does not have the required support. It is - * possible, however, for the libpng configuration to enable the format on just - * read or just write; in that case you may see an error at run time. You can - * guard against this by checking for the definition of the appropriate - * "_SUPPORTED" macro, one of: - * - * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED - */ -#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ -#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ -#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ -#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ - -#ifdef PNG_FORMAT_BGR_SUPPORTED -# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); #endif -#ifdef PNG_FORMAT_AFIRST_SUPPORTED -# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); #endif -/* Commonly used formats have predefined macros. - * - * First the single byte (sRGB) formats: - */ -#define PNG_FORMAT_GRAY 0 -#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA -#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR -#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) -#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) - -/* Then the linear 2-byte formats. When naming these "Y" is used to - * indicate a luminance (gray) channel. - */ -#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR -#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) -#define PNG_FORMAT_LINEAR_RGB_ALPHA \ - (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) - -/* With color-mapped formats the image data is one byte for each pixel, the byte - * is an index into the color-map which is formatted as above. To obtain a - * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP - * to one of the above definitions, or you can use one of the definitions below. - */ -#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) - -/* PNG_IMAGE macros - * - * These are convenience macros to derive information from a png_image - * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the - * actual image sample values - either the entries in the color-map or the - * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values - * for the pixels and will always return 1 for color-mapped formats. The - * remaining macros return information about the rows in the image and the - * complete image. - * - * NOTE: All the macros that take a png_image::format parameter are compile time - * constants if the format parameter is, itself, a constant. Therefore these - * macros can be used in array declarations and case labels where required. - * Similarly the macros are also pre-processor constants (sizeof is not used) so - * they can be used in #if tests. - * - * First the information about the samples. - */ -#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ - (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) - /* Return the total number of channels in a given format: 1..4 */ - -#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ - ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) - /* Return the size in bytes of a single component of a pixel or color-map - * entry (as appropriate) in the image: 1 or 2. - */ - -#define PNG_IMAGE_SAMPLE_SIZE(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) - /* This is the size of the sample data for one sample. If the image is - * color-mapped it is the size of one color-map entry (and image pixels are - * one byte in size), otherwise it is the size of one image pixel. - */ - -#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) - /* The maximum size of the color-map required by the format expressed in a - * count of components. This can be used to compile-time allocate a - * color-map: - * - * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; - * - * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; - * - * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the - * information from one of the png_image_begin_read_ APIs and dynamically - * allocate the required memory. - */ - -/* Corresponding information about the pixels */ -#define PNG_IMAGE_PIXEL_(test,fmt)\ - (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) - -#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) - /* The number of separate channels (components) in a pixel; 1 for a - * color-mapped image. - */ - -#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) - /* The size, in bytes, of each component in a pixel; 1 for a color-mapped - * image. - */ - -#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) - /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ - -/* Information about the whole row, or whole image */ -#define PNG_IMAGE_ROW_STRIDE(image)\ - (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) - /* Return the total number of components in a single row of the image; this - * is the minimum 'row stride', the minimum count of components between each - * row. For a color-mapped image this is the minimum number of bytes in a - * row. - */ - -#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ - (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) - /* Return the size, in bytes, of an image buffer given a png_image and a row - * stride - the number of components to leave space for in each row. - */ - -#define PNG_IMAGE_SIZE(image)\ - PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) - /* Return the size, in bytes, of the image in memory given just a png_image; - * the row stride is the minimum stride required for the image. - */ - -#define PNG_IMAGE_COLORMAP_SIZE(image)\ - (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) - /* Return the size, in bytes, of the color-map of this image. If the image - * format is not a color-map format this will return a size sufficient for - * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if - * you don't want to allocate a color-map in this case. - */ - -/* PNG_IMAGE_FLAG_* - * - * Flags containing additional information about the image are held in the - * 'flags' field of png_image. - */ -#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 - /* This indicates the the RGB values of the in-memory bitmap do not - * correspond to the red, green and blue end-points defined by sRGB. - */ - -#define PNG_IMAGE_FLAG_FAST 0x02 - /* On write emphasise speed over compression; the resultant PNG file will be - * larger but will be produced significantly faster, particular for large - * images. Do not use this option for images which will be distributed, only - * used it when producing intermediate files that will be read back in - * repeatedly. For a typical 24-bit image the option will double the read - * speed at the cost of increasing the image size by 25%, however for many - * more compressible images the PNG file can be 10 times larger with only a - * slight speed gain. - */ - -#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 - /* On read if the image is a 16-bit per component image and there is no gAMA - * or sRGB chunk assume that the components are sRGB encoded. Notice that - * images output by the simplified API always have gamma information; setting - * this flag only affects the interpretation of 16-bit images from an - * external source. It is recommended that the application expose this flag - * to the user; the user can normally easily recognize the difference between - * linear and sRGB encoding. This flag has no effect on write - the data - * passed to the write APIs must have the correct encoding (as defined - * above.) - * - * If the flag is not set (the default) input 16-bit per component data is - * assumed to be linear. - * - * NOTE: the flag can only be set after the png_image_begin_read_ call, - * because that call initializes the 'flags' field. - */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* READ APIs - * --------- - * - * The png_image passed to the read APIs must have been initialized by setting - * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) - */ -#ifdef PNG_STDIO_SUPPORTED -PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, - const char *file_name)); - /* The named file is opened for read and the image header is filled in - * from the PNG header in the file. - */ - -PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, - FILE* file)); - /* The PNG header is read from the stdio FILE object. */ -#endif /* PNG_STDIO_SUPPORTED */ - -PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, - png_const_voidp memory, png_size_t size)); - /* The PNG header is read from the given memory buffer. */ - -PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, - png_const_colorp background, void *buffer, png_int_32 row_stride, - void *colormap)); - /* Finish reading the image into the supplied buffer and clean up the - * png_image structure. - * - * row_stride is the step, in byte or 2-byte units as appropriate, - * between adjacent rows. A positive stride indicates that the top-most row - * is first in the buffer - the normal top-down arrangement. A negative - * stride indicates that the bottom-most row is first in the buffer. - * - * background need only be supplied if an alpha channel must be removed from - * a png_byte format and the removal is to be done by compositing on a solid - * color; otherwise it may be NULL and any composition will be done directly - * onto the buffer. The value is an sRGB color to use for the background, - * for grayscale output the green channel is used. - * - * background must be supplied when an alpha channel must be removed from a - * single byte color-mapped output format, in other words if: - * - * 1) The original format from png_image_begin_read_from_* had - * PNG_FORMAT_FLAG_ALPHA set. - * 2) The format set by the application does not. - * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and - * PNG_FORMAT_FLAG_LINEAR *not* set. - * - * For linear output removing the alpha channel is always done by compositing - * on black and background is ignored. - * - * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must - * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. - * image->colormap_entries will be updated to the actual number of entries - * written to the colormap; this may be less than the original value. - */ - -PNG_EXPORT(238, void, png_image_free, (png_imagep image)); - /* Free any data allocated by libpng in image->opaque, setting the pointer to - * NULL. May be called at any time after the structure is initialized. - */ -#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ - -#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -/* WRITE APIS - * ---------- - * For write you must initialize a png_image structure to describe the image to - * be written. To do this use memset to set the whole structure to 0 then - * initialize fields describing your image. - * - * version: must be set to PNG_IMAGE_VERSION - * opaque: must be initialized to NULL - * width: image width in pixels - * height: image height in rows - * format: the format of the data (image and color-map) you wish to write - * flags: set to 0 unless one of the defined flags applies; set - * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB - * values do not correspond to the colors in sRGB. - * colormap_entries: set to the number of entries in the color-map (0 to 256) - */ -PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, - const char *file, int convert_to_8bit, const void *buffer, - png_int_32 row_stride, const void *colormap)); - /* Write the image to the named file. */ - -PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, - int convert_to_8_bit, const void *buffer, png_int_32 row_stride, - const void *colormap)); - /* Write the image to the given (FILE*). */ - -/* With both write APIs if image is in one of the linear formats with 16-bit - * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG - * gamma encoded according to the sRGB specification, otherwise a 16-bit linear - * encoded PNG file is written. - * - * With color-mapped data formats the colormap parameter point to a color-map - * with at least image->colormap_entries encoded in the specified format. If - * the format is linear the written PNG color-map will be converted to sRGB - * regardless of the convert_to_8_bit flag. - * - * With all APIs row_stride is handled as in the read APIs - it is the spacing - * from one row to the next in component sized units (1 or 2 bytes) and if - * negative indicates a bottom-up row layout in the buffer. - * - * Note that the write API does not support interlacing or sub-8-bit pixels. - */ -#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ -/******************************************************************************* - * END OF SIMPLIFIED API - ******************************************************************************/ - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -PNG_EXPORT(242, void, png_set_check_for_invalid_index, - (png_structrp png_ptr, int allowed)); -# ifdef PNG_GET_PALETTE_MAX_SUPPORTED -PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, - png_const_infop info_ptr)); -# endif -#endif /* CHECK_FOR_INVALID_INDEX */ - -/******************************************************************************* - * IMPLEMENTATION OPTIONS - ******************************************************************************* - * - * Support for arbitrary implementation-specific optimizations. The API allows - * particular options to be turned on or off. 'Option' is the number of the - * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given - * by the PNG_OPTION_ defines below. - * - * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, - * are detected at run time, however sometimes it may be impossible - * to do this in user mode, in which case it is necessary to discover - * the capabilities in an OS specific way. Such capabilities are - * listed here when libpng has support for them and must be turned - * ON by the application if present. - * - * SOFTWARE: sometimes software optimizations actually result in performance - * decrease on some architectures or systems, or with some sets of - * PNG images. 'Software' options allow such optimizations to be - * selected at run time. - */ -#ifdef PNG_SET_OPTION_SUPPORTED -#ifdef PNG_ARM_NEON_API_SUPPORTED -# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ -#endif -#define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ - -/* Return values: NOTE: there are four values and 'off' is *not* zero */ -#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ -#define PNG_OPTION_INVALID 1 /* Option number out of range */ -#define PNG_OPTION_OFF 2 -#define PNG_OPTION_ON 3 - -PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, - int onoff)); +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); #endif -/******************************************************************************* - * END OF HARDWARE OPTIONS - ******************************************************************************/ - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project - * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt - */ - -/* The last ordinal number (this is the *last* one already used; the next - * one to use is one more than this.) Maintainer, remember to add an entry to - * scripts/symbols.def as well. - */ -#ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(244); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); #endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ -/* Do not put anything past this line */ +/* do not put anything past this line */ #endif /* PNG_H */ diff --git a/Source/3rd Party/wx/src/png/pngasmrd.h b/Source/3rd Party/wx/src/png/pngasmrd.h new file mode 100644 index 000000000..050525826 --- /dev/null +++ b/Source/3rd Party/wx/src/png/pngasmrd.h @@ -0,0 +1,11 @@ +/* pngasmrd.h - assembler version of utilities to read a PNG file + * + * libpng 1.2.6 - August 15, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 2002-2004 Glenn Randers-Pehrson + * + */ + +/* This file is obsolete in libpng-1.0.9 and later; its contents now appear + * at the end of pngconf.h. + */ diff --git a/Source/3rd Party/wx/src/png/pngconf.h b/Source/3rd Party/wx/src/png/pngconf.h index 31f996757..867e0a866 100644 --- a/Source/3rd Party/wx/src/png/pngconf.h +++ b/Source/3rd Party/wx/src/png/pngconf.h @@ -1,16 +1,11 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.2 - April 25, 2013 - * - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * */ /* Any machine specific code is near the front of this file, so if you @@ -22,595 +17,1378 @@ #ifndef PNGCONF_H #define PNGCONF_H -/* To do: Do all of this in scripts/pnglibconf.dfa */ -#ifdef PNG_SAFE_LIMITS_SUPPORTED -# ifdef PNG_USER_WIDTH_MAX -# undef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -# endif -# ifdef PNG_USER_HEIGHT_MAX -# undef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -# endif -# ifdef PNG_USER_CHUNK_MALLOC_MAX -# undef PNG_USER_CHUNK_MALLOC_MAX -# define PNG_USER_CHUNK_MALLOC_MAX 4000000L -# endif -# ifdef PNG_USER_CHUNK_CACHE_MAX -# undef PNG_USER_CHUNK_CACHE_MAX -# define PNG_USER_CHUNK_CACHE_MAX 128 +#ifdef PNG_USER_CONFIG +#include "pngusr.h" +#endif + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED # endif #endif -#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif -/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C - * compiler for correct compilation. The following header files are required by - * the standard. If your compiler doesn't provide these header files, or they - * do not match the standard, you will need to provide/improve them. +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K */ -#include -#include +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif -/* Library header files. These header files are all defined by ISOC90; libpng - * expects conformant implementations, however, an ISOC90 conformant system need - * not provide these header files if the functionality cannot be implemented. - * In this case it will be necessary to disable the relevant parts of libpng in - * the build of pnglibconf.h. +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- (ignored) building the dll + * (no define) -- (ignored) building an application, linking to the dll + * PNG_STATIC -- (ignored) building the static lib, or building an + * application that links to the static lib. + * ALL_STATIC -- (ignored) building various static libs, or building an + * application that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. * - * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not - * include this unnecessary header file. + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + * + * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent + * of auto-import in binutils, we no longer need to worry about + * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, + * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes + * to __declspec() stuff. However, we DO need to worry about + * PNG_BUILD_DLL and PNG_STATIC because those change some defaults + * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO */ -#ifdef PNG_STDIO_SUPPORTED - /* Required for the definition of FILE: */ -# include +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || (defined(__SC__) && !defined(__DMC__))|| defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED #endif #ifdef PNG_SETJMP_SUPPORTED - /* Required for the definition of jmp_buf and the declaration of longjmp: */ +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + */ + +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + /* If you encounter a compiler error here, see the explanation + * near the end of INSTALL. + */ + __png.h__ already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ + + /* include setjmp.h for error handling */ # include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# define _BSD_SOURCE +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include #endif -#ifdef PNG_CONVERT_tIME_SUPPORTED - /* Required for struct tm: */ -# include -#endif +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL -#endif /* PNG_BUILDING_SYMBOL_TABLE */ +#include -/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using - * PNG_NO_CONST; this is no longer supported except for data declarations which - * apparently still cause problems in 2011 on some compilers. +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern */ -#define PNG_CONST const /* backward compatibility only */ +#define PNG_EXTERN -/* This controls optimization of the reading of 16 and 32 bit values - * from PNG files. It can be set on a per-app-file basis - it - * just changes whether a macro is used when the function is called. - * The library builder sets the default; if read functions are not - * built into the library the macro implementation is forced on. - */ -#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED -# define PNG_USE_READ_MACROS -#endif -#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) -# if PNG_DEFAULT_READ_MACROS -# define PNG_USE_READ_MACROS -# endif -#endif - -/* COMPILER SPECIFIC OPTIONS. - * - * These options are provided so that a variety of difficult compilers - * can be used. Some are fixed at build time (e.g. PNG_API_RULE - * below) but still have compiler specific implementations, others - * may be changed on a per-file basis when compiling against libpng. +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. */ -/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect - * against legacy (pre ISOC90) compilers that did not understand function - * prototypes. It is not required for modern C compilers. - */ -#ifndef PNGARG -# define PNGARG(arglist) arglist -#endif - -/* Function calling conventions. - * ============================= - * Normally it is not necessary to specify to the compiler how to call - * a function - it just does it - however on x86 systems derived from - * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems - * and some others) there are multiple ways to call a function and the - * default can be changed on the compiler command line. For this reason - * libpng specifies the calling convention of every exported function and - * every function called via a user supplied function pointer. This is - * done in this file by defining the following macros: - * - * PNGAPI Calling convention for exported functions. - * PNGCBAPI Calling convention for user provided (callback) functions. - * PNGCAPI Calling convention used by the ANSI-C library (required - * for longjmp callbacks and sometimes used internally to - * specify the calling convention for zlib). - * - * These macros should never be overridden. If it is necessary to - * change calling convention in a private build this can be done - * by setting PNG_API_RULE (which defaults to 0) to one of the values - * below to select the correct 'API' variants. - * - * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. - * This is correct in every known environment. - * PNG_API_RULE=1 Use the operating system convention for PNGAPI and - * the 'C' calling convention (from PNGCAPI) for - * callbacks (PNGCBAPI). This is no longer required - * in any known environment - if it has to be used - * please post an explanation of the problem to the - * libpng mailing list. - * - * These cases only differ if the operating system does not use the C - * calling convention, at present this just means the above cases - * (x86 DOS/Windows sytems) and, even then, this does not apply to - * Cygwin running on those systems. - * - * Note that the value must be defined in pnglibconf.h so that what - * the application uses to call the library matches the conventions - * set when building the library. - */ - -/* Symbol export - * ============= - * When building a shared library it is almost always necessary to tell - * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' - * is used to mark the symbols. On some systems these symbols can be - * extracted at link time and need no special processing by the compiler, - * on other systems the symbols are flagged by the compiler and just - * the declaration requires a special tag applied (unfortunately) in a - * compiler dependent way. Some systems can do either. - * - * A small number of older systems also require a symbol from a DLL to - * be flagged to the program that calls it. This is a problem because - * we do not know in the header file included by application code that - * the symbol will come from a shared library, as opposed to a statically - * linked one. For this reason the application must tell us by setting - * the magic flag PNG_USE_DLL to turn on the special processing before - * it includes png.h. - * - * Four additional macros are used to make this happen: - * - * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from - * the build or imported if PNG_USE_DLL is set - compiler - * and system specific. - * - * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to - * 'type', compiler specific. - * - * PNG_DLL_EXPORT Set to the magic to use during a libpng build to - * make a symbol exported from the DLL. Not used in the - * public header files; see pngpriv.h for how it is used - * in the libpng build. - * - * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come - * from a DLL - used to define PNG_IMPEXP when - * PNG_USE_DLL is set. - */ - -/* System specific discovery. - * ========================== - * This code is used at build time to find PNG_IMPEXP, the API settings - * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL - * import processing is possible. On Windows systems it also sets - * compiler-specific macros to the values required to change the calling - * conventions of the various functions. - */ -#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) - /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or - * MinGW on any architecture currently supported by Windows. Also includes - * Watcom builds but these need special treatment because they are not - * compatible with GCC or Visual C because of different calling conventions. - */ -# if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ -# define PNGCAPI __watcall -# endif - -# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) -# define PNGCAPI __cdecl -# if PNG_API_RULE == 1 - /* If this line results in an error __stdcall is not understood and - * PNG_API_RULE should not have been set to '1'. - */ -# define PNGAPI __stdcall +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include # endif # else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ -# ifndef PNGCAPI -# define PNGCAPI _cdecl -# endif -# if PNG_API_RULE == 1 && !defined(PNGAPI) -# define PNGAPI _stdcall -# endif -# endif /* compiler/api */ - /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ - -# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" +# include # endif - -# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ - (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ -# ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP -# endif -# define PNG_DLL_EXPORT __export -# else /* newer compiler */ -# define PNG_DLL_EXPORT __declspec(dllexport) -# ifndef PNG_DLL_IMPORT -# define PNG_DLL_IMPORT __declspec(dllimport) -# endif -# endif /* compiler */ - -#else /* !Windows */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ -# endif /* other system, !OS/2 */ -#endif /* !Windows/x86 */ - -/* Now do all the defaulting . */ -#ifndef PNGCAPI -# define PNGCAPI -#endif -#ifndef PNGCBAPI -# define PNGCBAPI PNGCAPI -#endif -#ifndef PNGAPI -# define PNGAPI PNGCAPI -#endif - -/* PNG_IMPEXP may be set on the compilation system command line or (if not set) - * then in an internal header file when building the library, otherwise (when - * using the library) it is set here. - */ -#ifndef PNG_IMPEXP -# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ -# define PNG_IMPEXP PNG_DLL_IMPORT -# endif - -# ifndef PNG_IMPEXP -# define PNG_IMPEXP +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include # endif #endif -/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat - * 'attributes' as a storage class - the attributes go at the start of the - * function definition, and attributes are always appended regardless of the - * compiler. This considerably simplifies these macros but may cause problems - * if any compilers both need function attributes and fail to handle them as - * a storage class (this is unlikely.) +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +/* I have no idea why is this necessary... */ +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. */ -#ifndef PNG_FUNCTION -# define PNG_FUNCTION(type, name, args, attributes) attributes type name args +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 #endif -#ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type -#endif - - /* The ordinal value is only relevant when preprocessing png.h for symbol - * table entries, so we discard it here. See the .dfn files in the - * scripts directory. - */ -#ifndef PNG_EXPORTA - -# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ - PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ - extern attributes) -#endif - -/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, - * so make something non-empty to satisfy the requirement: - */ -#define PNG_EMPTY /*empty list*/ - -#define PNG_EXPORT(ordinal, type, name, args)\ - PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) - -/* Use PNG_REMOVED to comment out a removed interface. */ -#ifndef PNG_REMOVED -# define PNG_REMOVED(ordinal, type, name, args, attributes) -#endif - -#ifndef PNG_CALLBACK -# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) -#endif - -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. - * - * Added at libpng-1.2.41. +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). */ -#ifndef PNG_NO_PEDANTIC_WARNINGS -# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED -# define PNG_PEDANTIC_WARNINGS_SUPPORTED +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt is supported. It is turned off by default, to support old apps + * that malloc the png_text structure instead of calling png_set_text() + * and letting libpng malloc it. It will be turned on by default in + * libpng-1.3.0. + */ + +#ifndef PNG_iTXt_SUPPORTED +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) +# define PNG_NO_READ_iTXt +# endif +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) +# define PNG_NO_WRITE_iTXt # endif #endif -#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED - /* Support for compiler specific function attributes. These are used - * so that where compiler support is available, incorrect use of API - * functions in png.h will generate compiler warnings. Added at libpng - * version 1.2.41. Disabling these removes the warnings but may also produce - * less efficient code. - */ -# if defined(__GNUC__) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# if __GNUC__ >= 3 -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_1_0_X +# ifndef PNG_NO_ERROR_NUMBERS +# define PNG_ERROR_NUMBERS_SUPPORTED +# endif +#endif /* PNG_1_0_X */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif +#endif + +/* If you are sure that you don't need thread safety and you are compiling + with PNG_USE_PNGCCRD for an MMX application, you can define this for + faster execution. See pnggccrd.c. +#define PNG_THREAD_UNSAFE_OK +*/ + +#if !defined(PNG_1_0_X) +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ +#if !defined(PNG_1_0_X) +#ifndef PNG_SET_USER_LIMITS_SUPPORTED +#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) +# define PNG_SET_USER_LIMITS_SUPPORTED +#endif +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter + * how large, set these limits to 0x7fffffffL + */ +#ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000L +#endif +#ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000L +#endif + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +#ifdef PNG_SIZE_T + typedef PNG_SIZE_T png_size_t; +# define png_sizeof(x) png_convert_size(sizeof (x)) +#else + typedef size_t png_size_t; +# define png_sizeof(x) sizeof (x) +#endif + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far # endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif -# endif -# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif /* __GNUC__ == 3.0 */ -# endif /* __GNUC__ >= 3 */ +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ -# elif defined(_MSC_VER) && (_MSC_VER >= 1300) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* not supported */ -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __declspec(noreturn) -# endif -# ifndef PNG_ALLOCATED -# if (_MSC_VER >= 1400) -# define PNG_ALLOCATED __declspec(restrict) -# endif -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __declspec(deprecated) -# endif -# ifndef PNG_PRIVATE -# define PNG_PRIVATE __declspec(deprecated) -# endif -# ifndef PNG_RESTRICT -# if (_MSC_VER >= 1400) -# define PNG_RESTRICT __restrict -# endif -# endif -# elif defined(__WATCOMC__) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif /* _MSC_VER */ -#endif /* PNG_PEDANTIC_WARNINGS */ +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED /* Use of this function is deprecated */ -#endif -#ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* The result of this function must be checked */ -#endif -#ifndef PNG_NORETURN -# define PNG_NORETURN /* This function does not return */ -#endif -#ifndef PNG_ALLOCATED -# define PNG_ALLOCATED /* The result of the function is new memory */ -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE /* This is a private libpng function */ -#endif -#ifndef PNG_RESTRICT -# define PNG_RESTRICT /* The C99 "restrict" feature */ -#endif -#ifndef PNG_FP_EXPORT /* A floating point API. */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No floating point APIs */ -# define PNG_FP_EXPORT(ordinal, type, name, args) -# endif -#endif -#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ -# ifdef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No fixed point APIs */ -# define PNG_FIXED_EXPORT(ordinal, type, name, args) +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include # endif #endif -#ifndef PNG_BUILDING_SYMBOL_TABLE -/* Some typedefs to get us started. These should be safe on most of the common - * platforms. - * - * png_uint_32 and png_int_32 may, currently, be larger than required to hold a - * 32-bit value however this is not normally advisable. - * - * png_uint_16 and png_int_16 should always be two bytes in size - this is - * verified at library build time. - * - * png_byte must always be one byte in size. - * - * The checks below use constants from limits.h, as defined by the ISOC90 - * standard. - */ -#if CHAR_BIT == 8 && UCHAR_MAX == 255 - typedef unsigned char png_byte; -#else -# error "libpng requires 8 bit bytes" +/* SJT: default case */ +#ifndef FAR +# define FAR #endif -#if INT_MIN == -32768 && INT_MAX == 32767 - typedef int png_int_16; -#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 - typedef short png_int_16; -#else -# error "libpng requires a signed 16 bit type" +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA #endif -#if UINT_MAX == 65535 - typedef unsigned int png_uint_16; -#elif USHRT_MAX == 65535 - typedef unsigned short png_uint_16; -#else -# error "libpng requires an unsigned 16 bit type" -#endif - -#if INT_MIN < -2147483646 && INT_MAX > 2147483646 - typedef int png_int_32; -#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 - typedef long int png_int_32; -#else -# error "libpng requires a signed 32 bit (or more) type" -#endif - -#if UINT_MAX > 4294967294 - typedef unsigned int png_uint_32; -#elif ULONG_MAX > 4294967294 - typedef unsigned long int png_uint_32; -#else -# error "libpng requires an unsigned 32 bit (or more) type" -#endif - -/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, - * requires an ISOC90 compiler and relies on consistent behavior of sizeof. - */ -typedef size_t png_size_t; -typedef ptrdiff_t png_ptrdiff_t; - -/* libpng needs to know the maximum value of 'size_t' and this controls the - * definition of png_alloc_size_t, below. This maximum value of size_t limits - * but does not control the maximum allocations the library makes - there is - * direct application control of this through png_set_user_limits(). - */ -#ifndef PNG_SMALL_SIZE_T - /* Compiler specific tests for systems where size_t is known to be less than - * 32 bits (some of these systems may no longer work because of the lack of - * 'far' support; see above.) - */ -# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ - (defined(_MSC_VER) && defined(MAXSEG_64K)) -# define PNG_SMALL_SIZE_T -# endif -#endif - -/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no - * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to - * png_alloc_size_t are not necessary; in fact, it is recommended not to use - * them at all so that the compiler can complain when something turns out to be - * problematic. - * - * Casts in the other direction (from png_alloc_size_t to png_size_t or - * png_uint_32) should be explicitly applied; however, we do not expect to - * encounter practical situations that require such conversions. - * - * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than - * 4294967295 - i.e. less than the maximum value of png_uint_32. - */ -#ifdef PNG_SMALL_SIZE_T - typedef png_uint_32 png_alloc_size_t; -#else - typedef png_size_t png_alloc_size_t; -#endif - -/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler - * implementations of Intel CPU specific support of user-mode segmented address - * spaces, where 16-bit pointers address more than 65536 bytes of memory using - * separate 'segment' registers. The implementation requires two different - * types of pointer (only one of which includes the segment value.) - * - * If required this support is available in version 1.2 of libpng and may be - * available in versions through 1.5, although the correctness of the code has - * not been verified recently. - */ - -/* Typedef for floating-point numbers that are converted to fixed-point with a - * multiple of 100,000, e.g., gamma - */ +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ -typedef void * png_voidp; -typedef const void * png_const_voidp; -typedef png_byte * png_bytep; -typedef const png_byte * png_const_bytep; -typedef png_uint_32 * png_uint_32p; -typedef const png_uint_32 * png_const_uint_32p; -typedef png_int_32 * png_int_32p; -typedef const png_int_32 * png_const_int_32p; -typedef png_uint_16 * png_uint_16p; -typedef const png_uint_16 * png_const_uint_16p; -typedef png_int_16 * png_int_16p; -typedef const png_int_16 * png_const_int_16p; -typedef char * png_charp; -typedef const char * png_const_charp; -typedef png_fixed_point * png_fixed_point_p; -typedef const png_fixed_point * png_const_fixed_point_p; -typedef png_size_t * png_size_tp; -typedef const png_size_t * png_const_size_tp; +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; -#ifdef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif #endif #ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * png_doublep; -typedef const double * png_const_doublep; +typedef double FAR * png_doublep; #endif /* Pointers to pointers; i.e. arrays */ -typedef png_byte * * png_bytepp; -typedef png_uint_32 * * png_uint_32pp; -typedef png_int_32 * * png_int_32pp; -typedef png_uint_16 * * png_uint_16pp; -typedef png_int_16 * * png_int_16pp; -typedef const char * * png_const_charpp; -typedef char * * png_charpp; -typedef png_fixed_point * * png_fixed_point_pp; +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * * png_doublepp; +typedef double FAR * FAR * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char * * * png_charppp; +typedef char FAR * FAR * FAR * png_charppp; -#endif /* PNG_BUILDING_SYMBOL_TABLE */ +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + +#if defined(__CYGWIN__) || defined(__WINE__) +# undef PNGAPI +# if defined(__WINE__) +# define PNGAPI +# else +# define PNGAPI __cdecl +# endif +# undef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", + * you may get warnings regarding the linkage of png_zalloc and png_zfree. + * Don't ignore those warnings; you must also reset the default calling + * convention in your compiler to match your PNGAPI, and you must build + * zlib and your applications the same way you build libpng. + */ + +#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) + +# ifndef PNGAPI +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in + VC++ */ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# ifndef PNGAPI +# define PNGAPI _System +# endif +# else +# if 0 /* ... other platforms, with other meanings */ +# endif +# endif +#endif + +#if defined(__VISAGECPP__) +/* I don't compile with this _System linkage for wxWidgets */ +# ifdef PNGAPI +# undef PNGAPI +# endif +# define PNGAPI _Optlink +# define PNG_IMPEXP +# define PNG_USE_LOCAL_ARRAYS +# ifdef PNG_USE_GLOBAL_ARRAYS +# undef PNG_USE_GLOBAL_ARRAYS +# endif +extern const char png_libpng_ver[18]; +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_strcpy _fstrcpy +# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strncpy strncpy /* Added to v 1.2.6 */ +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +#ifdef PNG_READ_SUPPORTED +/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ +#if defined(PNG_INTERNAL) + +/* These are the default thresholds before the MMX code kicks in; if either + * rowbytes or bitdepth is below the threshold, plain C code is used. These + * can be overridden at runtime via the png_set_mmx_thresholds() call in + * libpng 1.2.0 and later. The values below were chosen by Intel. + */ + +#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT +# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ +#endif +#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT +# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ +#endif + +/* Set this in the makefile for VC++ on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGVCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif + +/* Set this in the makefile for gcc/as on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGGCCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif +/* - see pnggccrd.c for info about what is currently enabled */ + +#endif /* PNG_INTERNAL */ +#endif /* PNG_READ_SUPPORTED */ #endif /* PNGCONF_H */ + diff --git a/Source/3rd Party/wx/src/png/pngdebug.h b/Source/3rd Party/wx/src/png/pngdebug.h deleted file mode 100644 index 16f81fdd1..000000000 --- a/Source/3rd Party/wx/src/png/pngdebug.h +++ /dev/null @@ -1,157 +0,0 @@ - -/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c - * - * Copyright (c) 1998-2011 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Last changed in libpng 1.5.0 [January 6, 2011] - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - * - * png_debug[1-2]?(level, message ,arg{0-2}) - * Expands to a statement (either a simple expression or a compound - * do..while(0) statement) that outputs a message with parameter - * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG - * is undefined, 0 or 1 every png_debug expands to a simple expression - * (actually ((void)0)). - * - * level: level of detail of message, starting at 0. A level 'n' - * message is preceded by 'n' tab characters (not implemented - * on Microsoft compilers unless PNG_DEBUG_FILE is also - * defined, to allow debug DLL compilation with no standard IO). - * message: a printf(3) style text string. A trailing '\n' is added - * to the message. - * arg: 0 to 2 arguments for printf(3) style substitution in message. - */ -#ifndef PNGDEBUG_H -#define PNGDEBUG_H -/* These settings control the formatting of messages in png.c and pngerror.c */ -/* Moved to pngdebug.h at 1.5.0 */ -# ifndef PNG_LITERAL_SHARP -# define PNG_LITERAL_SHARP 0x23 -# endif -# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET -# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b -# endif -# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET -# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d -# endif -# ifndef PNG_STRING_NEWLINE -# define PNG_STRING_NEWLINE "\n" -# endif - -#ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -# include -# if (PNG_DEBUG > 1) -# ifndef _DEBUG -# define _DEBUG -# endif -# ifndef png_debug -# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) -# endif -# endif -# else /* PNG_DEBUG_FILE || !_MSC_VER */ -# ifndef PNG_STDIO_SUPPORTED -# include /* not included yet */ -# endif -# ifndef PNG_DEBUG_FILE -# define PNG_DEBUG_FILE stderr -# endif /* PNG_DEBUG_FILE */ - -# if (PNG_DEBUG > 1) -/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on - * non-ISO compilers - */ -# ifdef __STDC__ -# ifndef png_debug -# define png_debug(l,m) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ - } while (0) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ - } while (0) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ - } while (0) -# endif -# else /* __STDC __ */ -# ifndef png_debug -# define png_debug(l,m) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format); \ - } while (0) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1); \ - } while (0) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1,p2); \ - } while (0) -# endif -# endif /* __STDC __ */ -# endif /* (PNG_DEBUG > 1) */ - -# endif /* _MSC_VER */ -# endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -# define png_debug(l, m) ((void)0) -#endif -#ifndef png_debug1 -# define png_debug1(l, m, p1) ((void)0) -#endif -#ifndef png_debug2 -# define png_debug2(l, m, p1, p2) ((void)0) -#endif -#endif /* PNGDEBUG_H */ diff --git a/Source/3rd Party/wx/src/png/pngerror.c b/Source/3rd Party/wx/src/png/pngerror.c index f469206ee..fda078ef5 100644 --- a/Source/3rd Party/wx/src/png/pngerror.c +++ b/Source/3rd Party/wx/src/png/pngerror.c @@ -1,408 +1,102 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.6.1 [March 28, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file provides a location for all error handling. Users who * need special error handling are expected to write replacement functions * and use png_set_error_fn() to use those functions. See the instructions * at each function. */ -#include "pngpriv.h" +#define PNG_INTERNAL +#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, - png_const_charp error_message)),PNG_NORETURN); - -#ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ -png_default_warning PNGARG((png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif /* PNG_WARNINGS_SUPPORTED */ +png_default_error PNGARG((png_structp png_ptr, + png_const_charp error_message)); +static void /* PRIVATE */ +png_default_warning PNGARG((png_structp png_ptr, + png_const_charp warning_message)); /* This function is called whenever there is a fatal error. This function * should not be changed. If there is a need to handle errors differently, * you should supply a replacement error function and use png_set_error_fn() * to replace the error function at run-time. */ -#ifdef PNG_ERROR_TEXT_SUPPORTED -PNG_FUNCTION(void,PNGAPI -png_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) +void PNGAPI +png_error(png_structp png_ptr, png_const_charp error_message) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; - if (png_ptr != NULL) + if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) { - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - if (*error_message == PNG_LITERAL_SHARP) - { - /* Strip "#nnnn " from beginning of error message. */ - int offset; - for (offset = 1; offset<15; offset++) - if (error_message[offset] == ' ') - break; - - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i = 0; i < offset - 1; i++) - msg[i] = error_message[i + 1]; - msg[i - 1] = '\0'; - error_message = msg; - } - - else - error_message += offset; - } - - else - { + if (*error_message == '#') + { + int offset; + for (offset=1; offset<15; offset++) + if (*(error_message+offset) == ' ') + break; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { - msg[0] = '0'; - msg[1] = '\0'; - error_message = msg; + int i; + for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) + { + msg[0]='0'; + msg[1]='\0'; + error_message=msg; } - } } } #endif if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), - error_message); + (*(png_ptr->error_fn))(png_ptr, error_message); /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ png_default_error(png_ptr, error_message); } -#else -PNG_FUNCTION(void,PNGAPI -png_err,(png_const_structrp png_ptr),PNG_NORETURN) -{ - /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed - * erroneously as '\0', instead of the empty string "". This was - * apparently an error, introduced in libpng-1.2.20, and png_default_error - * will crash in this case. - */ - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), ""); - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, ""); -} -#endif /* PNG_ERROR_TEXT_SUPPORTED */ - -/* Utility to safely appends strings to a buffer. This never errors out so - * error checking is not required in the caller. - */ -size_t -png_safecat(png_charp buffer, size_t bufsize, size_t pos, - png_const_charp string) -{ - if (buffer != NULL && pos < bufsize) - { - if (string != NULL) - while (*string != '\0' && pos < bufsize-1) - buffer[pos++] = *string++; - - buffer[pos] = '\0'; - } - - return pos; -} - -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) -/* Utility to dump an unsigned value into a buffer, given a start pointer and - * and end pointer (which should point just *beyond* the end of the buffer!) - * Returns the pointer to the start of the formatted string. - */ -png_charp -png_format_number(png_const_charp start, png_charp end, int format, - png_alloc_size_t number) -{ - int count = 0; /* number of digits output */ - int mincount = 1; /* minimum number required */ - int output = 0; /* digit output (for the fixed point format) */ - - *--end = '\0'; - - /* This is written so that the loop always runs at least once, even with - * number zero. - */ - while (end > start && (number != 0 || count < mincount)) - { - - static const char digits[] = "0123456789ABCDEF"; - - switch (format) - { - case PNG_NUMBER_FORMAT_fixed: - /* Needs five digits (the fraction) */ - mincount = 5; - if (output || number % 10 != 0) - { - *--end = digits[number % 10]; - output = 1; - } - number /= 10; - break; - - case PNG_NUMBER_FORMAT_02u: - /* Expects at least 2 digits. */ - mincount = 2; - /* FALL THROUGH */ - - case PNG_NUMBER_FORMAT_u: - *--end = digits[number % 10]; - number /= 10; - break; - - case PNG_NUMBER_FORMAT_02x: - /* This format expects at least two digits */ - mincount = 2; - /* FALL THROUGH */ - - case PNG_NUMBER_FORMAT_x: - *--end = digits[number & 0xf]; - number >>= 4; - break; - - default: /* an error */ - number = 0; - break; - } - - /* Keep track of the number of digits added */ - ++count; - - /* Float a fixed number here: */ - if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start) - { - /* End of the fraction, but maybe nothing was output? In that case - * drop the decimal point. If the number is a true zero handle that - * here. - */ - if (output) - *--end = '.'; - else if (number == 0) /* and !output */ - *--end = '0'; - } - } - - return end; -} -#endif - -#ifdef PNG_WARNINGS_SUPPORTED /* This function is called whenever there is a non-fatal error. This function * should not be changed. If there is a need to handle warnings differently, * you should supply a replacement warning function and use * png_set_error_fn() to replace the warning function at run-time. */ void PNGAPI -png_warning(png_const_structrp png_ptr, png_const_charp warning_message) +png_warning(png_structp png_ptr, png_const_charp warning_message) { int offset = 0; - if (png_ptr != NULL) - { #ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) + if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) #endif - { - if (*warning_message == PNG_LITERAL_SHARP) - { - for (offset = 1; offset < 15; offset++) - if (warning_message[offset] == ' ') - break; - } - } + { + if (*warning_message == '#') + { + for (offset=1; offset<15; offset++) + if (*(warning_message+offset) == ' ') + break; + } } if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), - warning_message + offset); + (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); else - png_default_warning(png_ptr, warning_message + offset); + png_default_warning(png_ptr, warning_message+offset); } -/* These functions support 'formatted' warning messages with up to - * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter - * is introduced by @, where 'number' starts at 1. This follows the - * standard established by X/Open for internationalizable error messages. - */ -void -png_warning_parameter(png_warning_parameters p, int number, - png_const_charp string) -{ - if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) - (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); -} - -void -png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, - png_alloc_size_t value) -{ - char buffer[PNG_NUMBER_BUFFER_SIZE]; - png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); -} - -void -png_warning_parameter_signed(png_warning_parameters p, int number, int format, - png_int_32 value) -{ - png_alloc_size_t u; - png_charp str; - char buffer[PNG_NUMBER_BUFFER_SIZE]; - - /* Avoid overflow by doing the negate in a png_alloc_size_t: */ - u = (png_alloc_size_t)value; - if (value < 0) - u = ~u + 1; - - str = PNG_FORMAT_NUMBER(buffer, format, u); - - if (value < 0 && str > buffer) - *--str = '-'; - - png_warning_parameter(p, number, str); -} - -void -png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, - png_const_charp message) -{ - /* The internal buffer is just 192 bytes - enough for all our messages, - * overflow doesn't happen because this code checks! If someone figures - * out how to send us a message longer than 192 bytes, all that will - * happen is that the message will be truncated appropriately. - */ - size_t i = 0; /* Index in the msg[] buffer: */ - char msg[192]; - - /* Each iteration through the following loop writes at most one character - * to msg[i++] then returns here to validate that there is still space for - * the trailing '\0'. It may (in the case of a parameter) read more than - * one character from message[]; it must check for '\0' and continue to the - * test if it finds the end of string. - */ - while (i<(sizeof msg)-1 && *message != '\0') - { - /* '@' at end of string is now just printed (previously it was skipped); - * it is an error in the calling code to terminate the string with @. - */ - if (p != NULL && *message == '@' && message[1] != '\0') - { - int parameter_char = *++message; /* Consume the '@' */ - static const char valid_parameters[] = "123456789"; - int parameter = 0; - - /* Search for the parameter digit, the index in the string is the - * parameter to use. - */ - while (valid_parameters[parameter] != parameter_char && - valid_parameters[parameter] != '\0') - ++parameter; - - /* If the parameter digit is out of range it will just get printed. */ - if (parameter < PNG_WARNING_PARAMETER_COUNT) - { - /* Append this parameter */ - png_const_charp parm = p[parameter]; - png_const_charp pend = p[parameter] + (sizeof p[parameter]); - - /* No need to copy the trailing '\0' here, but there is no guarantee - * that parm[] has been initialized, so there is no guarantee of a - * trailing '\0': - */ - while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend) - msg[i++] = *parm++; - - /* Consume the parameter digit too: */ - ++message; - continue; - } - - /* else not a parameter and there is a character after the @ sign; just - * copy that. This is known not to be '\0' because of the test above. - */ - } - - /* At this point *message can't be '\0', even in the bad parameter case - * above where there is a lone '@' at the end of the message string. - */ - msg[i++] = *message++; - } - - /* i is always less than (sizeof msg), so: */ - msg[i] = '\0'; - - /* And this is the formatted message. It may be larger than - * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these - * are not (currently) formatted. - */ - png_warning(png_ptr, msg); -} -#endif /* PNG_WARNINGS_SUPPORTED */ - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) -{ - if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) - { -# ifdef PNG_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - png_ptr->chunk_name != 0) - png_chunk_warning(png_ptr, error_message); - else -# endif - png_warning(png_ptr, error_message); - } - - else - { -# ifdef PNG_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - png_ptr->chunk_name != 0) - png_chunk_error(png_ptr, error_message); - else -# endif - png_error(png_ptr, error_message); - } -} - -void /* PRIVATE */ -png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) -{ - if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); -} - -void /* PRIVATE */ -png_app_error(png_const_structrp png_ptr, png_const_charp error_message) -{ - if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); -} -#endif /* BENIGN_ERRORS */ - /* These utilities are used internally to build an error message that relates * to the current chunk. The chunk name comes from png_ptr->chunk_name, * this is used to prefix the message. The message is limited in length @@ -415,405 +109,165 @@ static PNG_CONST char png_digit[16] = { 'A', 'B', 'C', 'D', 'E', 'F' }; -#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */ -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) static void /* PRIVATE */ -png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp - error_message) +png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp + error_message) { - png_uint_32 chunk_name = png_ptr->chunk_name; - int iout = 0, ishift = 24; + int iout = 0, iin = 0; - while (ishift >= 0) + while (iin < 4) { - int c = (int)(chunk_name >> ishift) & 0xff; - - ishift -= 8; + int c = png_ptr->chunk_name[iin++]; if (isnonalpha(c)) { - buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; + buffer[iout++] = '['; buffer[iout++] = png_digit[(c & 0xf0) >> 4]; buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; + buffer[iout++] = ']'; } - else { - buffer[iout++] = (char)c; + buffer[iout++] = (png_byte)c; } } if (error_message == NULL) - buffer[iout] = '\0'; - + buffer[iout] = 0; else { - int iin = 0; - buffer[iout++] = ':'; buffer[iout++] = ' '; - - while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') - buffer[iout++] = error_message[iin++]; - - /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ - buffer[iout] = '\0'; + png_strncpy(buffer+iout, error_message, 63); + buffer[iout+63] = 0; } } -#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) -PNG_FUNCTION(void,PNGAPI -png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) -{ - char msg[18+PNG_MAX_ERROR_TEXT]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} -#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */ - -#ifdef PNG_WARNINGS_SUPPORTED void PNGAPI -png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message) +png_chunk_error(png_structp png_ptr, png_const_charp error_message) { - char msg[18+PNG_MAX_ERROR_TEXT]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} -#endif /* PNG_WARNINGS_SUPPORTED */ - -#ifdef PNG_READ_SUPPORTED -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp - error_message) -{ - if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) - png_chunk_warning(png_ptr, error_message); - - else - png_chunk_error(png_ptr, error_message); -} -#endif -#endif /* PNG_READ_SUPPORTED */ - -void /* PRIVATE */ -png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) -{ - /* This is always supported, but for just read or just write it - * unconditionally does the right thing. - */ -# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) - if (png_ptr->mode & PNG_IS_READ_STRUCT) -# endif - -# ifdef PNG_READ_SUPPORTED - { - if (error < PNG_CHUNK_ERROR) - png_chunk_warning(png_ptr, message); - - else - png_chunk_benign_error(png_ptr, message); - } -# endif - -# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) - else if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) -# endif - -# ifdef PNG_WRITE_SUPPORTED - { - if (error < PNG_CHUNK_WRITE_ERROR) - png_app_warning(png_ptr, message); - - else - png_app_error(png_ptr, message); - } -# endif -} - -#ifdef PNG_ERROR_TEXT_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_FUNCTION(void, -png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) -{ -# define fixed_message "fixed point overflow in " -# define fixed_message_ln ((sizeof fixed_message)-1) - int iin; - char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; - memcpy(msg, fixed_message, fixed_message_ln); - iin = 0; - if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) - { - msg[fixed_message_ln + iin] = name[iin]; - ++iin; - } - msg[fixed_message_ln + iin] = 0; + char msg[18+64]; + png_format_buffer(png_ptr, msg, error_message); png_error(png_ptr, msg); } -#endif -#endif -#ifdef PNG_SETJMP_SUPPORTED -/* This API only exists if ANSI-C style error handling is used, - * otherwise it is necessary for png_default_error to be overridden. - */ -jmp_buf* PNGAPI -png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, - size_t jmp_buf_size) +void PNGAPI +png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) { - /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value - * and it must not change after that. Libpng doesn't care how big the - * buffer is, just that it doesn't change. - * - * If the buffer size is no *larger* than the size of jmp_buf when libpng is - * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0 - * semantics that this call will not fail. If the size is larger, however, - * the buffer is allocated and this may fail, causing the function to return - * NULL. - */ - if (png_ptr == NULL) - return NULL; - - if (png_ptr->jmp_buf_ptr == NULL) - { - png_ptr->jmp_buf_size = 0; /* not allocated */ - - if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local)) - png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; - - else - { - png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, - png_malloc_warn(png_ptr, jmp_buf_size)); - - if (png_ptr->jmp_buf_ptr == NULL) - return NULL; /* new NULL return on OOM */ - - png_ptr->jmp_buf_size = jmp_buf_size; - } - } - - else /* Already allocated: check the size */ - { - size_t size = png_ptr->jmp_buf_size; - - if (size == 0) - { - size = (sizeof png_ptr->jmp_buf_local); - if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local) - { - /* This is an internal error in libpng: somehow we have been left - * with a stack allocated jmp_buf when the application regained - * control. It's always possible to fix this up, but for the moment - * this is a png_error because that makes it easy to detect. - */ - png_error(png_ptr, "Libpng jmp_buf still allocated"); - /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */ - } - } - - if (size != jmp_buf_size) - { - png_warning(png_ptr, "Application jmp_buf size changed"); - return NULL; /* caller will probably crash: no choice here */ - } - } - - /* Finally fill in the function, now we have a satisfactory buffer. It is - * valid to change the function on every call. - */ - png_ptr->longjmp_fn = longjmp_fn; - return png_ptr->jmp_buf_ptr; + char msg[18+64]; + png_format_buffer(png_ptr, msg, warning_message); + png_warning(png_ptr, msg); } -void /* PRIVATE */ -png_free_jmpbuf(png_structrp png_ptr) -{ - if (png_ptr != NULL) - { - jmp_buf *jb = png_ptr->jmp_buf_ptr; - - /* A size of 0 is used to indicate a local, stack, allocation of the - * pointer; used here and in png.c - */ - if (jb != NULL && png_ptr->jmp_buf_size > 0) - { - - /* This stuff is so that a failure to free the error control structure - * does not leave libpng in a state with no valid error handling: the - * free always succeeds, if there is an error it gets ignored. - */ - if (jb != &png_ptr->jmp_buf_local) - { - /* Make an internal, libpng, jmp_buf to return here */ - jmp_buf free_jmp_buf; - - if (!setjmp(free_jmp_buf)) - { - png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */ - png_ptr->jmp_buf_size = 0; /* stack allocation */ - png_ptr->longjmp_fn = longjmp; - png_free(png_ptr, jb); /* Return to setjmp on error */ - } - } - } - - /* *Always* cancel everything out: */ - png_ptr->jmp_buf_size = 0; - png_ptr->jmp_buf_ptr = NULL; - png_ptr->longjmp_fn = 0; - } -} -#endif - /* This is the default error handling function. Note that replacements for * this function MUST NOT RETURN, or the program will likely crash. This * function is used by default, or if the program supplies NULL for the * error function pointer in png_set_error_fn(). */ -static PNG_FUNCTION(void /* PRIVATE */, -png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) +static void /* PRIVATE */ +png_default_error(png_structp png_ptr, png_const_charp error_message) { -#ifdef PNG_CONSOLE_IO_SUPPORTED +#ifndef PNG_NO_CONSOLE_IO #ifdef PNG_ERROR_NUMBERS_SUPPORTED - /* Check on NULL only added in 1.5.4 */ - if (error_message != NULL && *error_message == PNG_LITERAL_SHARP) + if (*error_message == '#') { - /* Strip "#nnnn " from beginning of error message. */ - int offset; - char error_number[16]; - for (offset = 0; offset<15; offset++) - { - error_number[offset] = error_message[offset + 1]; - if (error_message[offset] == ' ') - break; - } - - if ((offset > 1) && (offset < 15)) - { - error_number[offset - 1] = '\0'; - fprintf(stderr, "libpng error no. %s: %s", - error_number, error_message + offset + 1); - fprintf(stderr, PNG_STRING_NEWLINE); - } - - else - { - fprintf(stderr, "libpng error: %s, offset=%d", - error_message, offset); - fprintf(stderr, PNG_STRING_NEWLINE); - } + int offset; + char error_number[16]; + for (offset=0; offset<15; offset++) + { + error_number[offset] = *(error_message+offset+1); + if (*(error_message+offset) == ' ') + break; + } + if((offset > 1) && (offset < 15)) + { + error_number[offset-1]='\0'; + fprintf(stderr, "libpng error no. %s: %s\n", error_number, + error_message+offset); + } + else + fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); } else #endif - { - fprintf(stderr, "libpng error: %s", error_message ? error_message : - "undefined"); - fprintf(stderr, PNG_STRING_NEWLINE); - } -#else - PNG_UNUSED(error_message) /* Make compiler happy */ + fprintf(stderr, "libpng error: %s\n", error_message); #endif - png_longjmp(png_ptr, 1); -} -PNG_FUNCTION(void,PNGAPI -png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN) -{ #ifdef PNG_SETJMP_SUPPORTED - if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr) - png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val); -#endif - - /* Here if not setjmp support or if png_ptr is null. */ +# ifdef USE_FAR_KEYWORD + { + jmp_buf jmpbuf; + png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); + longjmp(jmpbuf, 1); + } +# else + longjmp(png_ptr->jmpbuf, 1); +# endif +#else + /* make compiler happy */ ; + if (png_ptr) PNG_ABORT(); +#endif +#ifdef PNG_NO_CONSOLE_IO + /* make compiler happy */ ; + if (&error_message != NULL) + return; +#endif } -#ifdef PNG_WARNINGS_SUPPORTED /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything * here if you don't want them to. In the default configuration, png_ptr is * not used, but it is passed in case it may be useful. */ static void /* PRIVATE */ -png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message) +png_default_warning(png_structp png_ptr, png_const_charp warning_message) { -#ifdef PNG_CONSOLE_IO_SUPPORTED +#ifndef PNG_NO_CONSOLE_IO # ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == PNG_LITERAL_SHARP) + if (*warning_message == '#') { - int offset; - char warning_number[16]; - for (offset = 0; offset < 15; offset++) - { - warning_number[offset] = warning_message[offset + 1]; - if (warning_message[offset] == ' ') + int offset; + char warning_number[16]; + for (offset=0; offset<15; offset++) + { + warning_number[offset]=*(warning_message+offset+1); + if (*(warning_message+offset) == ' ') break; - } - - if ((offset > 1) && (offset < 15)) - { - warning_number[offset + 1] = '\0'; - fprintf(stderr, "libpng warning no. %s: %s", - warning_number, warning_message + offset); - fprintf(stderr, PNG_STRING_NEWLINE); - } - - else - { - fprintf(stderr, "libpng warning: %s", - warning_message); - fprintf(stderr, PNG_STRING_NEWLINE); - } + } + if((offset > 1) && (offset < 15)) + { + warning_number[offset-1]='\0'; + fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, + warning_message+offset); + } + else + fprintf(stderr, "libpng warning: %s\n", warning_message); } else # endif - - { - fprintf(stderr, "libpng warning: %s", warning_message); - fprintf(stderr, PNG_STRING_NEWLINE); - } + fprintf(stderr, "libpng warning: %s\n", warning_message); #else - PNG_UNUSED(warning_message) /* Make compiler happy */ + /* make compiler happy */ ; + if (warning_message) + return; #endif - PNG_UNUSED(png_ptr) /* Make compiler happy */ + /* make compiler happy */ ; + if (png_ptr) + return; } -#endif /* PNG_WARNINGS_SUPPORTED */ /* This function is called when the application wants to use another method * of handling errors and warnings. Note that the error function MUST NOT * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1) + * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) */ void PNGAPI -png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) +png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn) { - if (png_ptr == NULL) - return; - png_ptr->error_ptr = error_ptr; png_ptr->error_fn = error_fn; -#ifdef PNG_WARNINGS_SUPPORTED png_ptr->warning_fn = warning_fn; -#else - PNG_UNUSED(warning_fn) -#endif } @@ -822,111 +276,20 @@ png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr, * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI -png_get_error_ptr(png_const_structrp png_ptr) +png_get_error_ptr(png_structp png_ptr) { - if (png_ptr == NULL) - return NULL; - return ((png_voidp)png_ptr->error_ptr); } #ifdef PNG_ERROR_NUMBERS_SUPPORTED void PNGAPI -png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) +png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) { - if (png_ptr != NULL) + if(png_ptr != NULL) { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | - PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + png_ptr->flags &= + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); } } #endif - -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) - /* Currently the above both depend on SETJMP_SUPPORTED, however it would be - * possible to implement without setjmp support just so long as there is some - * way to handle the error return here: - */ -PNG_FUNCTION(void /* PRIVATE */, -png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message), - PNG_NORETURN) -{ - const png_const_structrp png_ptr = png_nonconst_ptr; - png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); - - /* An error is always logged here, overwriting anything (typically a warning) - * that is already there: - */ - if (image != NULL) - { - png_safecat(image->message, (sizeof image->message), 0, error_message); - image->warning_or_error |= PNG_IMAGE_ERROR; - - /* Retrieve the jmp_buf from within the png_control, making this work for - * C++ compilation too is pretty tricky: C++ wants a pointer to the first - * element of a jmp_buf, but C doesn't tell us the type of that. - */ - if (image->opaque != NULL && image->opaque->error_buf != NULL) - longjmp(png_control_jmp_buf(image->opaque), 1); - - /* Missing longjmp buffer, the following is to help debugging: */ - { - size_t pos = png_safecat(image->message, (sizeof image->message), 0, - "bad longjmp: "); - png_safecat(image->message, (sizeof image->message), pos, - error_message); - } - } - - /* Here on an internal programming error. */ - abort(); -} - -#ifdef PNG_WARNINGS_SUPPORTED -void /* PRIVATE */ -png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message) -{ - const png_const_structrp png_ptr = png_nonconst_ptr; - png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); - - /* A warning is only logged if there is no prior warning or error. */ - if (image->warning_or_error == 0) - { - png_safecat(image->message, (sizeof image->message), 0, warning_message); - image->warning_or_error |= PNG_IMAGE_WARNING; - } -} -#endif - -int /* PRIVATE */ -png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) -{ - volatile png_imagep image = image_in; - volatile int result; - volatile png_voidp saved_error_buf; - jmp_buf safe_jmpbuf; - - /* Safely execute function(arg) with png_error returning to this function. */ - saved_error_buf = image->opaque->error_buf; - result = setjmp(safe_jmpbuf) == 0; - - if (result) - { - - image->opaque->error_buf = safe_jmpbuf; - result = function(arg); - } - - image->opaque->error_buf = saved_error_buf; - - /* And do the cleanup prior to any failure return. */ - if (!result) - png_image_free(image); - - return result; -} -#endif /* SIMPLIFIED READ/WRITE */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pnggccrd.c b/Source/3rd Party/wx/src/png/pnggccrd.c new file mode 100644 index 000000000..27c716a2c --- /dev/null +++ b/Source/3rd Party/wx/src/png/pnggccrd.c @@ -0,0 +1,5408 @@ +/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file + * + * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. + * + * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm + * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm + * for Intel's performance analysis of the MMX vs. non-MMX code. + * + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson + * Copyright (c) 1998, Intel Corporation + * + * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. + * Interface to libpng contributed by Gilles Vollant, 1999. + * GNU C port by Greg Roelofs, 1999-2001. + * + * Lines 2350-4300 converted in place with intel2gas 1.3.1: + * + * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c + * + * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . + * + * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) + * is required to assemble the newer MMX instructions such as movq. + * For djgpp, see + * + * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip + * + * (or a later version in the same directory). For Linux, check your + * distribution's web site(s) or try these links: + * + * http://rufus.w3.org/linux/RPM/binutils.html + * http://www.debian.org/Packages/stable/devel/binutils.html + * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ + * binutils.tgz + * + * For other platforms, see the main GNU site: + * + * ftp://ftp.gnu.org/pub/gnu/binutils/ + * + * Version 2.5.2l.15 is definitely too old... + */ + +/* + * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) + * ===================================== + * + * 19991006: + * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) + * + * 19991007: + * - additional optimizations (possible or definite): + * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] + * - write MMX code for 48-bit case (pixel_bytes == 6) + * - figure out what's up with 24-bit case (pixel_bytes == 3): + * why subtract 8 from width_mmx in the pass 4/5 case? + * (only width_mmx case) (near line 1606) + * x [DONE] replace pixel_bytes within each block with the true + * constant value (or are compilers smart enough to do that?) + * - rewrite all MMX interlacing code so it's aligned with + * the *beginning* of the row buffer, not the end. This + * would not only allow one to eliminate half of the memory + * writes for odd passes (that is, pass == odd), it may also + * eliminate some unaligned-data-access exceptions (assuming + * there's a penalty for not aligning 64-bit accesses on + * 64-bit boundaries). The only catch is that the "leftover" + * pixel(s) at the end of the row would have to be saved, + * but there are enough unused MMX registers in every case, + * so this is not a problem. A further benefit is that the + * post-MMX cleanup code (C code) in at least some of the + * cases could be done within the assembler block. + * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, + * inconsistent, and don't match the MMX Programmer's Reference + * Manual conventions anyway. They should be changed to + * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that + * was lowest in memory (e.g., corresponding to a left pixel) + * and b7 is the byte that was highest (e.g., a right pixel). + * + * 19991016: + * - Brennan's Guide notwithstanding, gcc under Linux does *not* + * want globals prefixed by underscores when referencing them-- + * i.e., if the variable is const4, then refer to it as const4, + * not _const4. This seems to be a djgpp-specific requirement. + * Also, such variables apparently *must* be declared outside + * of functions; neither static nor automatic variables work if + * defined within the scope of a single function, but both + * static and truly global (multi-module) variables work fine. + * + * 19991023: + * - fixed png_combine_row() non-MMX replication bug (odd passes only?) + * - switched from string-concatenation-with-macros to cleaner method of + * renaming global variables for djgpp--i.e., always use prefixes in + * inlined assembler code (== strings) and conditionally rename the + * variables, not the other way around. Hence _const4, _mask8_0, etc. + * + * 19991024: + * - fixed mmxsupport()/png_do_read_interlace() first-row bug + * This one was severely weird: even though mmxsupport() doesn't touch + * ebx (where "row" pointer was stored), it nevertheless managed to zero + * the register (even in static/non-fPIC code--see below), which in turn + * caused png_do_read_interlace() to return prematurely on the first row of + * interlaced images (i.e., without expanding the interlaced pixels). + * Inspection of the generated assembly code didn't turn up any clues, + * although it did point at a minor optimization (i.e., get rid of + * mmx_supported_local variable and just use eax). Possibly the CPUID + * instruction is more destructive than it looks? (Not yet checked.) + * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly + * listings... Apparently register spillage has to do with ebx, since + * it's used to index the global offset table. Commenting it out of the + * input-reg lists in png_combine_row() eliminated compiler barfage, so + * ifdef'd with __PIC__ macro: if defined, use a global for unmask + * + * 19991107: + * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", + * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. + * + * 19991120: + * - made "diff" variable (now "_dif") global to simplify conversion of + * filtering routines (running out of regs, sigh). "diff" is still used + * in interlacing routines, however. + * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX + * macro determines which is used); original not yet tested. + * + * 20000213: + * - when compiling with gcc, be sure to use -fomit-frame-pointer + * + * 20000319: + * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, + * pass == 4 or 5, that caused visible corruption of interlaced images + * + * 20000623: + * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, + * many of the form "forbidden register 0 (ax) was spilled for class AREG." + * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and + * Chuck Wilson supplied a patch involving dummy output registers. See + * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 + * for the original (anonymous) SourceForge bug report. + * + * 20000706: + * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: + * pnggccrd.c: In function `png_combine_row': + * pnggccrd.c:525: more than 10 operands in `asm' + * pnggccrd.c:669: more than 10 operands in `asm' + * pnggccrd.c:828: more than 10 operands in `asm' + * pnggccrd.c:994: more than 10 operands in `asm' + * pnggccrd.c:1177: more than 10 operands in `asm' + * They are all the same problem and can be worked around by using the + * global _unmask variable unconditionally, not just in the -fPIC case. + * Reportedly earlier versions of gcc also have the problem with more than + * 10 operands; they just don't report it. Much strangeness ensues, etc. + * + * 20000729: + * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted + * MMX routine); began converting png_read_filter_row_mmx_sub() + * - to finish remaining sections: + * - clean up indentation and comments + * - preload local variables + * - add output and input regs (order of former determines numerical + * mapping of latter) + * - avoid all usage of ebx (including bx, bh, bl) register [20000823] + * - remove "$" from addressing of Shift and Mask variables [20000823] + * + * 20000731: + * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? + * + * 20000822: + * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with + * shared-library (-fPIC) version! Code works just fine as part of static + * library. Damn damn damn damn damn, should have tested that sooner. + * ebx is getting clobbered again (explicitly this time); need to save it + * on stack or rewrite asm code to avoid using it altogether. Blargh! + * + * 20000823: + * - first section was trickiest; all remaining sections have ebx -> edx now. + * (-fPIC works again.) Also added missing underscores to various Shift* + * and *Mask* globals and got rid of leading "$" signs. + * + * 20000826: + * - added visual separators to help navigate microscopic printed copies + * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working + * on png_read_filter_row_mmx_avg() + * + * 20000828: + * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) + * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not + * cleaned up/shortened in either routine, but functionality is complete + * and seems to be working fine. + * + * 20000829: + * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed + * as an input reg (with dummy output variables, etc.), then it *cannot* + * also appear in the clobber list or gcc 2.95.2 will barf. The solution + * is simple enough... + * + * 20000914: + * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled + * correctly (but 48-bit RGB just fine) + * + * 20000916: + * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: + * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" + * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" + * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" + * + * 20010101: + * - added new png_init_mmx_flags() function (here only because it needs to + * call mmxsupport(), which should probably become global png_mmxsupport()); + * modified other MMX routines to run conditionally (png_ptr->asm_flags) + * + * 20010103: + * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, + * and made it public; moved png_init_mmx_flags() to png.c as internal func + * + * 20010104: + * - removed dependency on png_read_filter_row_c() (C code already duplicated + * within MMX version of png_read_filter_row()) so no longer necessary to + * compile it into pngrutil.o + * + * 20010310: + * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) + * + * 20020304: + * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case + * + * 20040724: + * - more tinkering with clobber list at lines 4529 and 5033, to get + * it to compile on gcc-3.4. + * + * STILL TO DO: + * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) + * - write MMX code for 48-bit case (pixel_bytes == 6) + * - figure out what's up with 24-bit case (pixel_bytes == 3): + * why subtract 8 from width_mmx in the pass 4/5 case? + * (only width_mmx case) (near line 1606) + * - rewrite all MMX interlacing code so it's aligned with beginning + * of the row buffer, not the end (see 19991007 for details) + * x pick one version of mmxsupport() and get rid of the other + * - add error messages to any remaining bogus default cases + * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) + * x add support for runtime enable/disable/query of various MMX routines + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_USE_PNGGCCRD) + +int PNGAPI png_mmx_support(void); + +#ifdef PNG_USE_LOCAL_ARRAYS +static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; +static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* djgpp, Win32, and Cygwin add their own underscores to global variables, + * so define them without: */ +#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) +# define _mmx_supported mmx_supported +# define _const4 const4 +# define _const6 const6 +# define _mask8_0 mask8_0 +# define _mask16_1 mask16_1 +# define _mask16_0 mask16_0 +# define _mask24_2 mask24_2 +# define _mask24_1 mask24_1 +# define _mask24_0 mask24_0 +# define _mask32_3 mask32_3 +# define _mask32_2 mask32_2 +# define _mask32_1 mask32_1 +# define _mask32_0 mask32_0 +# define _mask48_5 mask48_5 +# define _mask48_4 mask48_4 +# define _mask48_3 mask48_3 +# define _mask48_2 mask48_2 +# define _mask48_1 mask48_1 +# define _mask48_0 mask48_0 +# define _LBCarryMask LBCarryMask +# define _HBClearMask HBClearMask +# define _ActiveMask ActiveMask +# define _ActiveMask2 ActiveMask2 +# define _ActiveMaskEnd ActiveMaskEnd +# define _ShiftBpp ShiftBpp +# define _ShiftRem ShiftRem +#ifdef PNG_THREAD_UNSAFE_OK +# define _unmask unmask +# define _FullLength FullLength +# define _MMXLength MMXLength +# define _dif dif +# define _patemp patemp +# define _pbtemp pbtemp +# define _pctemp pctemp +#endif +#endif + + +/* These constants are used in the inlined MMX assembly code. + Ignore gcc's "At top level: defined but not used" warnings. */ + +/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, + * since that case uses the %ebx register for indexing the Global Offset Table + * and there were no other registers available. But gcc 2.95 and later emit + * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask + * in the non-PIC case, so we'll just use the global unconditionally now. + */ +#ifdef PNG_THREAD_UNSAFE_OK +static int _unmask; +#endif + +static unsigned long long _mask8_0 = 0x0102040810204080LL; + +static unsigned long long _mask16_1 = 0x0101020204040808LL; +static unsigned long long _mask16_0 = 0x1010202040408080LL; + +static unsigned long long _mask24_2 = 0x0101010202020404LL; +static unsigned long long _mask24_1 = 0x0408080810101020LL; +static unsigned long long _mask24_0 = 0x2020404040808080LL; + +static unsigned long long _mask32_3 = 0x0101010102020202LL; +static unsigned long long _mask32_2 = 0x0404040408080808LL; +static unsigned long long _mask32_1 = 0x1010101020202020LL; +static unsigned long long _mask32_0 = 0x4040404080808080LL; + +static unsigned long long _mask48_5 = 0x0101010101010202LL; +static unsigned long long _mask48_4 = 0x0202020204040404LL; +static unsigned long long _mask48_3 = 0x0404080808080808LL; +static unsigned long long _mask48_2 = 0x1010101010102020LL; +static unsigned long long _mask48_1 = 0x2020202040404040LL; +static unsigned long long _mask48_0 = 0x4040808080808080LL; + +static unsigned long long _const4 = 0x0000000000FFFFFFLL; +/* static unsigned long long _const5 = 0x000000FFFFFF0000LL; */ /* NOT USED */ +static unsigned long long _const6 = 0x00000000000000FFLL; + +/* These are used in the row-filter routines and should/would be local */ +/* variables if not for gcc addressing limitations. */ +/* WARNING: Their presence probably defeats the thread safety of libpng. */ + +#ifdef PNG_THREAD_UNSAFE_OK +static png_uint_32 _FullLength; +static png_uint_32 _MMXLength; +static int _dif; +static int _patemp; /* temp variables for Paeth routine */ +static int _pbtemp; +static int _pctemp; +#endif + +void /* PRIVATE */ +png_squelch_warnings(void) +{ +#ifdef PNG_THREAD_UNSAFE_OK + _dif = _dif; + _patemp = _patemp; + _pbtemp = _pbtemp; + _pctemp = _pctemp; + _MMXLength = _MMXLength; +#endif + _const4 = _const4; + _const6 = _const6; + _mask8_0 = _mask8_0; + _mask16_1 = _mask16_1; + _mask16_0 = _mask16_0; + _mask24_2 = _mask24_2; + _mask24_1 = _mask24_1; + _mask24_0 = _mask24_0; + _mask32_3 = _mask32_3; + _mask32_2 = _mask32_2; + _mask32_1 = _mask32_1; + _mask32_0 = _mask32_0; + _mask48_5 = _mask48_5; + _mask48_4 = _mask48_4; + _mask48_3 = _mask48_3; + _mask48_2 = _mask48_2; + _mask48_1 = _mask48_1; + _mask48_0 = _mask48_0; +} +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + + +static int _mmx_supported = 2; + +/*===========================================================================*/ +/* */ +/* P N G _ C O M B I N E _ R O W */ +/* */ +/*===========================================================================*/ + +#if defined(PNG_HAVE_ASSEMBLER_COMBINE_ROW) + +#define BPP2 2 +#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ +#define BPP4 4 +#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ +#define BPP8 8 + +/* Combines the row recently read in with the previous row. + This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined; a + zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. + If you want all pixels to be combined, pass 0xff (255) in mask. */ + +/* Use this routine for the x86 platform - it uses a faster MMX routine + if the machine supports MMX. */ + +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ + png_debug(1, "in png_combine_row (pnggccrd.c)\n"); + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + if (_mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif + + if (mask == 0xff) + { + png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width)); + } + else /* (png_combine_row() is never called with mask == 0) */ + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_inc, s_start, s_end; + int m; + int shift; + png_uint_32 i; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x1; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 2: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x3; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 4: /* png_ptr->row_info.pixel_depth */ + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 8: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; /* fix 'forbidden register spilled' error */ + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; /* global variable for -fPIC version */ + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; /* reduce to multiple of 8 */ + diff = (int) (png_ptr->width & 7); /* amount lost */ + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" /* load bit pattern */ + "psubb %%mm6, %%mm6 \n\t" /* zero mm6 */ + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" /* fill reg with 8 masks */ + + "movq _mask8_0, %%mm0 \n\t" + "pand %%mm7, %%mm0 \n\t" /* nonzero if keep byte */ + "pcmpeqb %%mm6, %%mm0 \n\t" /* zeros->1s, v versa */ + +/* preload "movl len, %%ecx \n\t" // load length of line */ +/* preload "movl srcptr, %%esi \n\t" // load source */ +/* preload "movl dstptr, %%edi \n\t" // load dest */ + + "cmpl $0, %%ecx \n\t" /* len == 0 ? */ + "je mainloop8end \n\t" + + "mainloop8: \n\t" + "movq (%%esi), %%mm4 \n\t" /* *srcptr */ + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "pandn (%%edi), %%mm6 \n\t" /* *dstptr */ + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + "addl $8, %%esi \n\t" /* inc by 8 bytes processed */ + "addl $8, %%edi \n\t" + "subl $8, %%ecx \n\t" /* dec by 8 pixels processed */ + "ja mainloop8 \n\t" + + "mainloop8end: \n\t" +/* preload "movl diff, %%ecx \n\t" // (diff is in eax) */ + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end8 \n\t" +/* preload "movl mask, %%edx \n\t" */ + "sall $24, %%edx \n\t" /* make low byte, high byte */ + + "secondloop8: \n\t" + "sall %%edx \n\t" /* move high bit to CF */ + "jnc skip8 \n\t" /* if CF = 0 */ + "movb (%%esi), %%al \n\t" + "movb %%al, (%%edi) \n\t" + + "skip8: \n\t" + "incl %%esi \n\t" + "incl %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop8 \n\t" + + "end8: \n\t" + "EMMS \n\t" /* DONE */ + + : "=a" (dummy_value_a), /* output regs (dummy) */ + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), /* esi // input regs */ + "4" (dstptr), /* edi */ + "0" (diff), /* eax */ +/* was (unmask) "b" RESERVED // ebx // Global Offset Table idx */ + "2" (len), /* ecx */ + "1" (mask) /* edx */ + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm4", "%mm6", "%mm7" /* clobber list */ +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff /* *BPP1 */ ; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + + } /* end of else (_mmx_supported) */ + + break; + } /* end 8 bpp */ + + case 16: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; /* fix 'forbidden register spilled' error */ + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; /* global variable for -fPIC version */ + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; /* reduce to multiple of 8 */ + diff = (int) (png_ptr->width & 7); /* amount lost // */ + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" /* load bit pattern */ + "psubb %%mm6, %%mm6 \n\t" /* zero mm6 */ + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" /* fill reg with 8 masks */ + + "movq _mask16_0, %%mm0 \n\t" + "movq _mask16_1, %%mm1 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + +/* preload "movl len, %%ecx \n\t" // load length of line */ +/* preload "movl srcptr, %%esi \n\t" // load source */ +/* preload "movl dstptr, %%edi \n\t" // load dest */ + + "cmpl $0, %%ecx \n\t" + "jz mainloop16end \n\t" + + "mainloop16: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "addl $16, %%esi \n\t" /* inc by 16 bytes processed */ + "addl $16, %%edi \n\t" + "subl $8, %%ecx \n\t" /* dec by 8 pixels processed */ + "ja mainloop16 \n\t" + + "mainloop16end: \n\t" +/* preload "movl diff, %%ecx \n\t" // (diff is in eax) */ + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end16 \n\t" +/* preload "movl mask, %%edx \n\t" */ + "sall $24, %%edx \n\t" /* make low byte, high byte */ + + "secondloop16: \n\t" + "sall %%edx \n\t" /* move high bit to CF */ + "jnc skip16 \n\t" /* if CF = 0 */ + "movw (%%esi), %%ax \n\t" + "movw %%ax, (%%edi) \n\t" + + "skip16: \n\t" + "addl $2, %%esi \n\t" + "addl $2, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop16 \n\t" + + "end16: \n\t" + "EMMS \n\t" /* DONE */ + + : "=a" (dummy_value_a), /* output regs (dummy) */ + "=c" (dummy_value_c), + "=d" (dummy_value_d), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (diff), /* eax // input regs */ +/* was (unmask) " " RESERVED // ebx // Global Offset Table idx */ + "1" (len), /* ecx */ + "2" (mask), /* edx */ + "3" (srcptr), /* esi */ + "4" (dstptr) /* edi */ + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm4" /* clobber list */ + , "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP2 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP2; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 16 bpp */ + + case 24: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; /* fix 'forbidden register spilled' error */ + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; /* global variable for -fPIC version */ + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; /* reduce to multiple of 8 */ + diff = (int) (png_ptr->width & 7); /* amount lost // */ + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" /* load bit pattern */ + "psubb %%mm6, %%mm6 \n\t" /* zero mm6 */ + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" /* fill reg with 8 masks */ + + "movq _mask24_0, %%mm0 \n\t" + "movq _mask24_1, %%mm1 \n\t" + "movq _mask24_2, %%mm2 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + +/* preload "movl len, %%ecx \n\t" // load length of line */ +/* preload "movl srcptr, %%esi \n\t" // load source */ +/* preload "movl dstptr, %%edi \n\t" // load dest */ + + "cmpl $0, %%ecx \n\t" + "jz mainloop24end \n\t" + + "mainloop24: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm4 \n\t" + "movq 16(%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm4 \n\t" + "por %%mm4, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "addl $24, %%esi \n\t" /* inc by 24 bytes processed */ + "addl $24, %%edi \n\t" + "subl $8, %%ecx \n\t" /* dec by 8 pixels processed */ + + "ja mainloop24 \n\t" + + "mainloop24end: \n\t" +/* preload "movl diff, %%ecx \n\t" // (diff is in eax) */ + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end24 \n\t" +/* preload "movl mask, %%edx \n\t" */ + "sall $24, %%edx \n\t" /* make low byte, high byte */ + + "secondloop24: \n\t" + "sall %%edx \n\t" /* move high bit to CF */ + "jnc skip24 \n\t" /* if CF = 0 */ + "movw (%%esi), %%ax \n\t" + "movw %%ax, (%%edi) \n\t" + "xorl %%eax, %%eax \n\t" + "movb 2(%%esi), %%al \n\t" + "movb %%al, 2(%%edi) \n\t" + + "skip24: \n\t" + "addl $3, %%esi \n\t" + "addl $3, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop24 \n\t" + + "end24: \n\t" + "EMMS \n\t" /* DONE */ + + : "=a" (dummy_value_a), /* output regs (dummy) */ + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), /* esi // input regs */ + "4" (dstptr), /* edi */ + "0" (diff), /* eax */ +/* was (unmask) "b" RESERVED // ebx // Global Offset Table idx */ + "2" (len), /* ecx */ + "1" (mask) /* edx */ + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" /* clobber list */ + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP3 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP3; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 24 bpp */ + + case 32: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; /* fix 'forbidden register spilled' error */ + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; /* global variable for -fPIC version */ + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; /* reduce to multiple of 8 */ + diff = (int) (png_ptr->width & 7); /* amount lost // */ + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" /* load bit pattern */ + "psubb %%mm6, %%mm6 \n\t" /* zero mm6 */ + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" /* fill reg with 8 masks */ + + "movq _mask32_0, %%mm0 \n\t" + "movq _mask32_1, %%mm1 \n\t" + "movq _mask32_2, %%mm2 \n\t" + "movq _mask32_3, %%mm3 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + "pand %%mm7, %%mm3 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + "pcmpeqb %%mm6, %%mm3 \n\t" + +/* preload "movl len, %%ecx \n\t" // load length of line */ +/* preload "movl srcptr, %%esi \n\t" // load source */ +/* preload "movl dstptr, %%edi \n\t" // load dest */ + + "cmpl $0, %%ecx \n\t" /* lcr */ + "jz mainloop32end \n\t" + + "mainloop32: \n\t" + "movq (%%esi), %%mm4 \n\t" + "pand %%mm0, %%mm4 \n\t" + "movq %%mm0, %%mm6 \n\t" + "movq (%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm6 \n\t" + "por %%mm6, %%mm4 \n\t" + "movq %%mm4, (%%edi) \n\t" + + "movq 8(%%esi), %%mm5 \n\t" + "pand %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "movq 8(%%edi), %%mm6 \n\t" + "pandn %%mm6, %%mm7 \n\t" + "por %%mm7, %%mm5 \n\t" + "movq %%mm5, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm4 \n\t" + "movq 16(%%edi), %%mm7 \n\t" + "pandn %%mm7, %%mm4 \n\t" + "por %%mm4, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "movq 24(%%esi), %%mm7 \n\t" + "pand %%mm3, %%mm7 \n\t" + "movq %%mm3, %%mm5 \n\t" + "movq 24(%%edi), %%mm4 \n\t" + "pandn %%mm4, %%mm5 \n\t" + "por %%mm5, %%mm7 \n\t" + "movq %%mm7, 24(%%edi) \n\t" + + "addl $32, %%esi \n\t" /* inc by 32 bytes processed */ + "addl $32, %%edi \n\t" + "subl $8, %%ecx \n\t" /* dec by 8 pixels processed */ + "ja mainloop32 \n\t" + + "mainloop32end: \n\t" +/* preload "movl diff, %%ecx \n\t" // (diff is in eax) */ + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end32 \n\t" +/* preload "movl mask, %%edx \n\t" */ + "sall $24, %%edx \n\t" /* low byte => high byte */ + + "secondloop32: \n\t" + "sall %%edx \n\t" /* move high bit to CF */ + "jnc skip32 \n\t" /* if CF = 0 */ + "movl (%%esi), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + "skip32: \n\t" + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop32 \n\t" + + "end32: \n\t" + "EMMS \n\t" /* DONE */ + + : "=a" (dummy_value_a), /* output regs (dummy) */ + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), /* esi // input regs */ + "4" (dstptr), /* edi */ + "0" (diff), /* eax */ +/* was (unmask) "b" RESERVED // ebx // Global Offset Table idx */ + "2" (len), /* ecx */ + "1" (mask) /* edx */ + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2", "%mm3" /* clobber list */ + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP4 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP4; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 32 bpp */ + + case 48: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + png_uint_32 len; + int diff; + int dummy_value_a; /* fix 'forbidden register spilled' error */ + int dummy_value_d; + int dummy_value_c; + int dummy_value_S; + int dummy_value_D; + _unmask = ~mask; /* global variable for -fPIC version */ + srcptr = png_ptr->row_buf + 1; + dstptr = row; + len = png_ptr->width &~7; /* reduce to multiple of 8 */ + diff = (int) (png_ptr->width & 7); /* amount lost // */ + + __asm__ __volatile__ ( + "movd _unmask, %%mm7 \n\t" /* load bit pattern */ + "psubb %%mm6, %%mm6 \n\t" /* zero mm6 */ + "punpcklbw %%mm7, %%mm7 \n\t" + "punpcklwd %%mm7, %%mm7 \n\t" + "punpckldq %%mm7, %%mm7 \n\t" /* fill reg with 8 masks */ + + "movq _mask48_0, %%mm0 \n\t" + "movq _mask48_1, %%mm1 \n\t" + "movq _mask48_2, %%mm2 \n\t" + "movq _mask48_3, %%mm3 \n\t" + "movq _mask48_4, %%mm4 \n\t" + "movq _mask48_5, %%mm5 \n\t" + + "pand %%mm7, %%mm0 \n\t" + "pand %%mm7, %%mm1 \n\t" + "pand %%mm7, %%mm2 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pand %%mm7, %%mm4 \n\t" + "pand %%mm7, %%mm5 \n\t" + + "pcmpeqb %%mm6, %%mm0 \n\t" + "pcmpeqb %%mm6, %%mm1 \n\t" + "pcmpeqb %%mm6, %%mm2 \n\t" + "pcmpeqb %%mm6, %%mm3 \n\t" + "pcmpeqb %%mm6, %%mm4 \n\t" + "pcmpeqb %%mm6, %%mm5 \n\t" + +/* preload "movl len, %%ecx \n\t" // load length of line */ +/* preload "movl srcptr, %%esi \n\t" // load source */ +/* preload "movl dstptr, %%edi \n\t" // load dest */ + + "cmpl $0, %%ecx \n\t" + "jz mainloop48end \n\t" + + "mainloop48: \n\t" + "movq (%%esi), %%mm7 \n\t" + "pand %%mm0, %%mm7 \n\t" + "movq %%mm0, %%mm6 \n\t" + "pandn (%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, (%%edi) \n\t" + + "movq 8(%%esi), %%mm6 \n\t" + "pand %%mm1, %%mm6 \n\t" + "movq %%mm1, %%mm7 \n\t" + "pandn 8(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 8(%%edi) \n\t" + + "movq 16(%%esi), %%mm6 \n\t" + "pand %%mm2, %%mm6 \n\t" + "movq %%mm2, %%mm7 \n\t" + "pandn 16(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 16(%%edi) \n\t" + + "movq 24(%%esi), %%mm7 \n\t" + "pand %%mm3, %%mm7 \n\t" + "movq %%mm3, %%mm6 \n\t" + "pandn 24(%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, 24(%%edi) \n\t" + + "movq 32(%%esi), %%mm6 \n\t" + "pand %%mm4, %%mm6 \n\t" + "movq %%mm4, %%mm7 \n\t" + "pandn 32(%%edi), %%mm7 \n\t" + "por %%mm7, %%mm6 \n\t" + "movq %%mm6, 32(%%edi) \n\t" + + "movq 40(%%esi), %%mm7 \n\t" + "pand %%mm5, %%mm7 \n\t" + "movq %%mm5, %%mm6 \n\t" + "pandn 40(%%edi), %%mm6 \n\t" + "por %%mm6, %%mm7 \n\t" + "movq %%mm7, 40(%%edi) \n\t" + + "addl $48, %%esi \n\t" /* inc by 48 bytes processed */ + "addl $48, %%edi \n\t" + "subl $8, %%ecx \n\t" /* dec by 8 pixels processed */ + + "ja mainloop48 \n\t" + + "mainloop48end: \n\t" +/* preload "movl diff, %%ecx \n\t" // (diff is in eax) */ + "movl %%eax, %%ecx \n\t" + "cmpl $0, %%ecx \n\t" + "jz end48 \n\t" +/* preload "movl mask, %%edx \n\t" */ + "sall $24, %%edx \n\t" /* make low byte, high byte */ + + "secondloop48: \n\t" + "sall %%edx \n\t" /* move high bit to CF */ + "jnc skip48 \n\t" /* if CF = 0 */ + "movl (%%esi), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + "skip48: \n\t" + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz secondloop48 \n\t" + + "end48: \n\t" + "EMMS \n\t" /* DONE */ + + : "=a" (dummy_value_a), /* output regs (dummy) */ + "=d" (dummy_value_d), + "=c" (dummy_value_c), + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "3" (srcptr), /* esi // input regs */ + "4" (dstptr), /* edi */ + "0" (diff), /* eax */ +/* was (unmask) "b" RESERVED // ebx // Global Offset Table idx */ + "2" (len), /* ecx */ + "1" (mask) /* edx */ + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2", "%mm3" /* clobber list */ + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + else /* mmx _not supported - Use modified C routine */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + register png_uint_32 i; + png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP6 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP6; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + } /* end of else (_mmx_supported) */ + + break; + } /* end 48 bpp */ + + case 64: /* png_ptr->row_info.pixel_depth */ + { + png_bytep srcptr; + png_bytep dstptr; + register png_uint_32 i; + png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; + /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ + register int stride = BPP8 * png_pass_inc[png_ptr->pass]; + /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; + /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ + png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ + int diff = (int) (png_ptr->width & 7); /* amount lost */ + register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ + + srcptr = png_ptr->row_buf + 1 + initial_val; + dstptr = row + initial_val; + + for (i = initial_val; i < final_val; i += stride) + { + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + if (diff) /* number of leftover pixels: 3 for pngtest */ + { + final_val+=diff*BPP8; + for (; i < final_val; i += stride) + { + if (rep_bytes > (int)(final_val-i)) + rep_bytes = (int)(final_val-i); + png_memcpy(dstptr, srcptr, rep_bytes); + srcptr += stride; + dstptr += stride; + } + } + + break; + } /* end 64 bpp */ + + default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ + { + /* this should never happen */ + png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); + break; + } + } /* end switch (png_ptr->row_info.pixel_depth) */ + + } /* end if (non-trivial mask) */ + +} /* end png_combine_row() */ + +#endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */ + + + + +/*===========================================================================*/ +/* */ +/* P N G _ D O _ R E A D _ I N T E R L A C E */ +/* */ +/*===========================================================================*/ + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +#if defined(PNG_HAVE_ASSEMBLER_READ_INTERLACE) + +/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion + * has taken place. [GRR: what other steps come before and/or after?] + */ + +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + png_uint_32 transformations = png_ptr->transformations; +#endif + + png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + if (_mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif + + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_byte v; + png_uint_32 i; + int j; + + sp = row + (png_size_t)((row_info->width - 1) >> 3); + dp = row + (png_size_t)((final_width - 1) >> 3); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 7); + dshift = (int)((final_width + 7) & 7); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 7); + dshift = 7 - (int)((final_width + 7) & 7); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = row_info->width; i; i--) + { + v = (png_byte)((*sp >> sshift) & 0x1); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 2: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 2); + dp = row + (png_size_t)((final_width - 1) >> 2); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); + dshift = (png_size_t)(((final_width + 3) & 3) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 4: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 1); + dp = row + (png_size_t)((final_width - 1) >> 1); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); + dshift = (png_size_t)(((final_width + 1) & 1) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0xf); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + /*====================================================================*/ + + default: /* 8-bit or larger (this is where the routine is modified) */ + { +#if 0 +/* static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good */ +/* static unsigned long long const4 = 0x0000000000FFFFFFLL; no good */ +/* unsigned long long _const4 = 0x0000000000FFFFFFLL; no good */ +/* unsigned long long const4 = 0x0000000000FFFFFFLL; no good */ +#endif + png_bytep sptr, dp; + png_uint_32 i; + png_size_t pixel_bytes; + int width = (int)row_info->width; + + pixel_bytes = (row_info->pixel_depth >> 3); + + /* point sptr at the last pixel in the pre-expanded row: */ + sptr = row + (width - 1) * pixel_bytes; + + /* point dp at the last pixel position in the expanded row: */ + dp = row + (final_width - 1) * pixel_bytes; + + /* New code by Nirav Chhatrapati - Intel Corporation */ + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && _mmx_supported */ ) +#else + if (_mmx_supported) +#endif + { + //-------------------------------------------------------------- + if (pixel_bytes == 3) + { + if (((pass == 0) || (pass == 1)) && width) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $21, %%edi \n\t" + /* (png_pass_inc[pass] - 1)*pixel_bytes */ + + ".loop3_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x x 2 1 0 */ + "pand _const4, %%mm0 \n\t" /* z z z z z 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* z z z z z 2 1 0 */ + "psllq $16, %%mm0 \n\t" /* z z z 2 1 0 z z */ + "movq %%mm0, %%mm2 \n\t" /* z z z 2 1 0 z z */ + "psllq $24, %%mm0 \n\t" /* 2 1 0 z z z z z */ + "psrlq $8, %%mm1 \n\t" /* z z z z z z 2 1 */ + "por %%mm2, %%mm0 \n\t" /* 2 1 0 2 1 0 z z */ + "por %%mm1, %%mm0 \n\t" /* 2 1 0 2 1 0 2 1 */ + "movq %%mm0, %%mm3 \n\t" /* 2 1 0 2 1 0 2 1 */ + "psllq $16, %%mm0 \n\t" /* 0 2 1 0 2 1 z z */ + "movq %%mm3, %%mm4 \n\t" /* 2 1 0 2 1 0 2 1 */ + "punpckhdq %%mm0, %%mm3 \n\t" /* 0 2 1 0 2 1 0 2 */ + "movq %%mm4, 16(%%edi) \n\t" + "psrlq $32, %%mm0 \n\t" /* z z z z 0 2 1 0 */ + "movq %%mm3, 8(%%edi) \n\t" + "punpckldq %%mm4, %%mm0 \n\t" /* 1 0 2 1 0 2 1 0 */ + "subl $3, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $24, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop3_pass0 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width), // ecx + "rim" (_const4) // %1(?) (0x0000000000FFFFFFLL) + +#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" /* clobber list */ + , "%mm3", "%mm4" +#endif + ); + } + else if (((pass == 2) || (pass == 3)) && width) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $9, %%edi \n\t" + /* (png_pass_inc[pass] - 1)*pixel_bytes */ + + ".loop3_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x x 2 1 0 */ + "pand _const4, %%mm0 \n\t" /* z z z z z 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* z z z z z 2 1 0 */ + "psllq $16, %%mm0 \n\t" /* z z z 2 1 0 z z */ + "movq %%mm0, %%mm2 \n\t" /* z z z 2 1 0 z z */ + "psllq $24, %%mm0 \n\t" /* 2 1 0 z z z z z */ + "psrlq $8, %%mm1 \n\t" /* z z z z z z 2 1 */ + "por %%mm2, %%mm0 \n\t" /* 2 1 0 2 1 0 z z */ + "por %%mm1, %%mm0 \n\t" /* 2 1 0 2 1 0 2 1 */ + "movq %%mm0, 4(%%edi) \n\t" + "psrlq $16, %%mm0 \n\t" /* z z 2 1 0 2 1 0 */ + "subl $3, %%esi \n\t" + "movd %%mm0, (%%edi) \n\t" + "subl $12, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop3_pass2 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width), // ecx + "rim" (_const4) // (0x0000000000FFFFFFLL) + +#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" /* clobber list */ +#endif + ); + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 1) << 1) - 8; /* GRR: huh? */ + if (width_mmx < 0) + width_mmx = 0; + width -= width_mmx; /* 8 or 9 pix, 24 or 27 bytes */ + if (width_mmx) + { + /* png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ + /* sptr points at last pixel in pre-expanded row */ + /* dp points at last pixel position in expanded row */ + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $9, %%edi \n\t" + /* (png_pass_inc[pass] + 1)*pixel_bytes */ + + ".loop3_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" /* x x 5 4 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* x x 5 4 3 2 1 0 */ + "movq %%mm0, %%mm2 \n\t" /* x x 5 4 3 2 1 0 */ + "psllq $24, %%mm0 \n\t" /* 4 3 2 1 0 z z z */ + "pand _const4, %%mm1 \n\t" /* z z z z z 2 1 0 */ + "psrlq $24, %%mm2 \n\t" /* z z z x x 5 4 3 */ + "por %%mm1, %%mm0 \n\t" /* 4 3 2 1 0 2 1 0 */ + "movq %%mm2, %%mm3 \n\t" /* z z z x x 5 4 3 */ + "psllq $8, %%mm2 \n\t" /* z z x x 5 4 3 z */ + "movq %%mm0, (%%edi) \n\t" + "psrlq $16, %%mm3 \n\t" /* z z z z z x x 5 */ + "pand _const6, %%mm3 \n\t" /* z z z z z z z 5 */ + "por %%mm3, %%mm2 \n\t" /* z z x x 5 4 3 5 */ + "subl $6, %%esi \n\t" + "movd %%mm2, 8(%%edi) \n\t" + "subl $12, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop3_pass4 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), // esi // input regs + "2" (dp), // edi + "0" (width_mmx), // ecx + "rim" (_const4), // 0x0000000000FFFFFFLL + "rim" (_const6) // 0x00000000000000FFLL + +#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ + , "%mm2", "%mm3" +#endif + ); + } + + sptr -= width_mmx*3; + dp -= width_mmx*6; + for (i = width; i; i--) + { + png_byte v[8]; + int j; + + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + } /* end of pixel_bytes == 3 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 1) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; /* 0-3 pixels => 0-3 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $31, %%edi \n\t" + + ".loop1_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* x x x x 3 2 1 0 */ + "punpcklbw %%mm0, %%mm0 \n\t" /* 3 3 2 2 1 1 0 0 */ + "movq %%mm0, %%mm2 \n\t" /* 3 3 2 2 1 1 0 0 */ + "punpcklwd %%mm0, %%mm0 \n\t" /* 1 1 1 1 0 0 0 0 */ + "movq %%mm0, %%mm3 \n\t" /* 1 1 1 1 0 0 0 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 0 0 0 0 0 0 0 0 */ + "punpckhdq %%mm3, %%mm3 \n\t" /* 1 1 1 1 1 1 1 1 */ + "movq %%mm0, (%%edi) \n\t" + "punpckhwd %%mm2, %%mm2 \n\t" /* 3 3 3 3 2 2 2 2 */ + "movq %%mm3, 8(%%edi) \n\t" + "movq %%mm2, %%mm4 \n\t" /* 3 3 3 3 2 2 2 2 */ + "punpckldq %%mm2, %%mm2 \n\t" /* 2 2 2 2 2 2 2 2 */ + "punpckhdq %%mm4, %%mm4 \n\t" /* 3 3 3 3 3 3 3 3 */ + "movq %%mm2, 16(%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm4, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "subl $4, %%ecx \n\t" + "jnz .loop1_pass0 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1", "%mm2" /* clobber list */ + , "%mm3", "%mm4" +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*8; + for (i = width; i; i--) + { + int j; + + /* I simplified this part in version 1.0.4e + * here and in several other instances where + * pixel_bytes == 1 -- GR-P + * + * Original code: + * + * png_byte v[8]; + * png_memcpy(v, sptr, pixel_bytes); + * for (j = 0; j < png_pass_inc[pass]; j++) + * { + * png_memcpy(dp, v, pixel_bytes); + * dp -= pixel_bytes; + * } + * sptr -= pixel_bytes; + * + * Replacement code is in the next three lines: + */ + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; /* 0-3 pixels => 0-3 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $3, %%esi \n\t" + "subl $15, %%edi \n\t" + + ".loop1_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x 3 2 1 0 */ + "punpcklbw %%mm0, %%mm0 \n\t" /* 3 3 2 2 1 1 0 0 */ + "movq %%mm0, %%mm1 \n\t" /* 3 3 2 2 1 1 0 0 */ + "punpcklwd %%mm0, %%mm0 \n\t" /* 1 1 1 1 0 0 0 0 */ + "punpckhwd %%mm1, %%mm1 \n\t" /* 3 3 3 3 2 2 2 2 */ + "movq %%mm0, (%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $4, %%ecx \n\t" + "jnz .loop1_pass2 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*4; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 3) << 3); + width -= width_mmx; /* 0-3 pixels => 0-3 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $7, %%esi \n\t" + "subl $15, %%edi \n\t" + + ".loop1_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 7 6 5 4 3 2 1 0 */ + "punpcklbw %%mm0, %%mm0 \n\t" /* 3 3 2 2 1 1 0 0 */ + "punpckhbw %%mm1, %%mm1 \n\t" /* 7 7 6 6 5 5 4 4 */ + "movq %%mm1, 8(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $8, %%ecx \n\t" + "jnz .loop1_pass4 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (none) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= width_mmx; + dp -= width_mmx*2; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + } /* end of pixel_bytes == 1 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 2) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; /* 0,1 pixels => 0,2 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $30, %%edi \n\t" + + ".loop2_pass0: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x 3 2 1 0 */ + "punpcklwd %%mm0, %%mm0 \n\t" /* 3 2 3 2 1 0 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 3 2 3 2 1 0 1 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 1 0 1 0 1 0 1 0 */ + "punpckhdq %%mm1, %%mm1 \n\t" /* 3 2 3 2 3 2 3 2 */ + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm1, 16(%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass0 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*16 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; /* 0,1 pixels => 0,2 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $14, %%edi \n\t" + + ".loop2_pass2: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x 3 2 1 0 */ + "punpcklwd %%mm0, %%mm0 \n\t" /* 3 2 3 2 1 0 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 3 2 3 2 1 0 1 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 1 0 1 0 1 0 1 0 */ + "punpckhdq %%mm1, %%mm1 \n\t" /* 3 2 3 2 3 2 3 2 */ + "movq %%mm0, (%%edi) \n\t" + "subl $4, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass2 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*8 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (width) /* pass == 4 or 5 */ + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; /* 0,1 pixels => 0,2 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $2, %%esi \n\t" + "subl $6, %%edi \n\t" + + ".loop2_pass4: \n\t" + "movd (%%esi), %%mm0 \n\t" /* x x x x 3 2 1 0 */ + "punpcklwd %%mm0, %%mm0 \n\t" /* 3 2 3 2 1 0 1 0 */ + "subl $4, %%esi \n\t" + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop2_pass4 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*4 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + } /* end of pixel_bytes == 2 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 4) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; /* 0,1 pixels => 0,4 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $60, %%edi \n\t" + + ".loop4_pass0: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 7 6 5 4 3 2 1 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 3 2 1 0 3 2 1 0 */ + "punpckhdq %%mm1, %%mm1 \n\t" /* 7 6 5 4 7 6 5 4 */ + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "movq %%mm1, 32(%%edi) \n\t" + "movq %%mm1, 40(%%edi) \n\t" + "movq %%mm1, 48(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm1, 56(%%edi) \n\t" + "subl $64, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass0 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*32 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; /* 0,1 pixels => 0,4 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $28, %%edi \n\t" + + ".loop4_pass2: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 7 6 5 4 3 2 1 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 3 2 1 0 3 2 1 0 */ + "punpckhdq %%mm1, %%mm1 \n\t" /* 7 6 5 4 7 6 5 4 */ + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm1, 16(%%edi) \n\t" + "movq %%mm1, 24(%%edi) \n\t" + "subl $8, %%esi \n\t" + "subl $32, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass2 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*16 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (width) /* pass == 4 or 5 */ + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; /* 0,1 pixels => 0,4 bytes */ + if (width_mmx) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $4, %%esi \n\t" + "subl $12, %%edi \n\t" + + ".loop4_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, %%mm1 \n\t" /* 7 6 5 4 3 2 1 0 */ + "punpckldq %%mm0, %%mm0 \n\t" /* 3 2 1 0 3 2 1 0 */ + "punpckhdq %%mm1, %%mm1 \n\t" /* 7 6 5 4 7 6 5 4 */ + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm1, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "subl $2, %%ecx \n\t" + "jnz .loop4_pass4 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width_mmx) /* ecx */ + +#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0", "%mm1" /* clobber list */ +#endif + ); + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*8 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + } /* end of pixel_bytes == 4 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 8) + { +/* GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) */ + /* GRR NOTE: no need to combine passes here! */ + if (((pass == 0) || (pass == 1)) && width) + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + /* source is 8-byte RRGGBBAA */ + /* dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... */ + __asm__ __volatile__ ( + "subl $56, %%edi \n\t" /* start of last block */ + + ".loop8_pass0: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "movq %%mm0, 32(%%edi) \n\t" + "movq %%mm0, 40(%%edi) \n\t" + "movq %%mm0, 48(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 56(%%edi) \n\t" + "subl $64, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass0 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width) /* ecx */ + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" /* clobber list */ +#endif + ); + } + else if (((pass == 2) || (pass == 3)) && width) + { + /* source is 8-byte RRGGBBAA */ + /* dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA */ + /* (recall that expansion is _in place_: sptr and dp */ + /* both point at locations within same row buffer) */ + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $24, %%edi \n\t" /* start of last block */ + + ".loop8_pass2: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, (%%edi) \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "movq %%mm0, 16(%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 24(%%edi) \n\t" + "subl $32, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass2 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width) /* ecx */ + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" /* clobber list */ +#endif + ); + } + } + else if (width) /* pass == 4 or 5 */ + { + /* source is 8-byte RRGGBBAA */ + /* dest is 16-byte RRGGBBAA RRGGBBAA */ + { + int dummy_value_c; /* fix 'forbidden register spilled' */ + int dummy_value_S; + int dummy_value_D; + + __asm__ __volatile__ ( + "subl $8, %%edi \n\t" /* start of last block */ + + ".loop8_pass4: \n\t" + "movq (%%esi), %%mm0 \n\t" /* 7 6 5 4 3 2 1 0 */ + "movq %%mm0, (%%edi) \n\t" + "subl $8, %%esi \n\t" + "movq %%mm0, 8(%%edi) \n\t" + "subl $16, %%edi \n\t" + "decl %%ecx \n\t" + "jnz .loop8_pass4 \n\t" + "EMMS \n\t" /* DONE */ + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "1" (sptr), /* esi // input regs */ + "2" (dp), /* edi */ + "0" (width) /* ecx */ + +#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ + : "%mm0" /* clobber list */ +#endif + ); + } + } + + } /* end of pixel_bytes == 8 */ + + //-------------------------------------------------------------- + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } /* end of pixel_bytes == 6 */ + + //-------------------------------------------------------------- + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr-= pixel_bytes; + } + } + } /* end of _mmx_supported ======================================== */ + + else /* MMX not supported: use modified C code - takes advantage + * of inlining of png_memcpy for a constant */ + /* GRR 19991007: does it? or should pixel_bytes in each + * block be replaced with immediate value (e.g., 1)? */ + /* GRR 19991017: replaced with constants in each case */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + if (pixel_bytes == 1) + { + for (i = width; i; i--) + { + int j; + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + --sptr; + } + } + else if (pixel_bytes == 3) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + else if (pixel_bytes == 2) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 2); + dp -= 2; + } + sptr -= 2; + } + } + else if (pixel_bytes == 4) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { +#ifdef PNG_DEBUG + if (dp < row || dp+3 > row+png_ptr->row_buf_size) + { + printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", + row, dp, row+png_ptr->row_buf_size); + printf("row_buf=%d\n",png_ptr->row_buf_size); + } +#endif + png_memcpy(dp, v, 4); + dp -= 4; + } + sptr -= 4; + } + } + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } + else if (pixel_bytes == 8) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 8); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 8); + dp -= 8; + } + sptr -= 8; + } + } + else /* GRR: should never be reached */ + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + + } /* end if (MMX not supported) */ + break; + } + } /* end switch (row_info->pixel_depth) */ + + row_info->width = final_width; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + } + +} /* end png_do_read_interlace() */ + +#endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + + +#if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW) +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + +/* These variables are utilized in the functions below. They are declared */ +/* globally here to ensure alignment on 8-byte boundaries. */ + +union uAll { + long long use; + double align; +} _LBCarryMask = {0x0101010101010101LL}, + _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, + _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; + +#ifdef PNG_THREAD_UNSAFE_OK +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G */ +/* */ +/*===========================================================================*/ + +/* Optimized code for PNG Average filter decoder */ + +static void /* PRIVATE */ +png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + int bpp; + int dummy_value_c; /* fix 'forbidden register 2 (cx) was spilled' error */ + int dummy_value_S; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; /* get # bytes per pixel */ + _FullLength = row_info->rowbytes; /* # of bytes to filter */ + + __asm__ __volatile__ ( + /* initialize address pointers and offset */ +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save index to Global Offset Table */ +#endif +/*pre "movl row, %%edi \n\t" */ /* edi: Avg(x) */ + "xorl %%ebx, %%ebx \n\t" /* ebx: x */ + "movl %%edi, %%edx \n\t" +/*pre "movl prev_row, %%esi \n\t" */ /* esi: Prior(x) */ +/*pre "subl bpp, %%edx \n\t" */ /* (bpp is preloaded into ecx) */ + "subl %%ecx, %%edx \n\t" /* edx: Raw(x-bpp) */ + + "xorl %%eax,%%eax \n\t" + + /* Compute the Raw value for the first bpp bytes */ + /* Raw(x) = Avg(x) + (Prior(x)/2) */ + "avg_rlp: \n\t" + "movb (%%esi,%%ebx,),%%al \n\t" /* load al with Prior(x) */ + "incl %%ebx \n\t" + "shrb %%al \n\t" /* divide by 2 */ + "addb -1(%%edi,%%ebx,),%%al \n\t" /* add Avg(x); -1 to offset inc ebx */ +/* pre "cmpl bpp, %%ebx \n\t" */ /* (bpp is preloaded into ecx) */ + "cmpl %%ecx, %%ebx \n\t" + "movb %%al,-1(%%edi,%%ebx,) \n\t" /* write Raw(x); -1 to offset inc ebx */ + "jb avg_rlp \n\t" /* mov does not affect flags */ + + /* get # of bytes to alignment */ + "movl %%edi, _dif \n\t" /* take start of row */ + "addl %%ebx, _dif \n\t" /* add bpp */ + "addl $0xf, _dif \n\t" /* add 7+8 to incr past alignment bdry */ + "andl $0xfffffff8, _dif \n\t" /* mask to alignment boundary */ + "subl %%edi, _dif \n\t" /* subtract from start => value ebx at */ + "jz avg_go \n\t" /* alignment */ + + /* fix alignment */ + /* Compute the Raw value for the bytes up to the alignment boundary */ + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + "xorl %%ecx, %%ecx \n\t" + + "avg_lp1: \n\t" + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" /* load cl with Prior(x) */ + "movb (%%edx,%%ebx,), %%al \n\t" /* load al with Raw(x-bpp) */ + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" /* divide by 2 */ + "addb -1(%%edi,%%ebx,), %%al \n\t" /* add Avg(x); -1 to offset inc ebx */ + "cmpl _dif, %%ebx \n\t" /* check if at alignment boundary */ + "movb %%al, -1(%%edi,%%ebx,) \n\t" /* write Raw(x); -1 to offset inc ebx */ + "jb avg_lp1 \n\t" /* repeat until at alignment boundary */ + + "avg_go: \n\t" + "movl _FullLength, %%eax \n\t" + "movl %%eax, %%ecx \n\t" + "subl %%ebx, %%eax \n\t" /* subtract alignment fix */ + "andl $0x00000007, %%eax \n\t" /* calc bytes over mult of 8 */ + "subl %%eax, %%ecx \n\t" /* drop over bytes from original length */ + "movl %%ecx, _MMXLength \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" /* restore index to Global Offset Table */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list */ +#ifndef __PIC__ + , "%ebx" +#endif + /* GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) */ + /* (seems to work fine without...) */ + ); + + /* now do the math for the rest of the row */ + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000000000ffffffLL; + _ShiftBpp.use = 24; /* == 3 * 8 */ + _ShiftRem.use = 40; /* == 64 - 24 */ + + __asm__ __volatile__ ( + /* re-init address pointers and offset */ + "movq _ActiveMask, %%mm7 \n\t" + "movl _dif, %%ecx \n\t" /* ecx: x = offset to */ + "movq _LBCarryMask, %%mm5 \n\t" /* alignment boundary */ +/* preload "movl row, %%edi \n\t" // edi: Avg(x) */ + "movq _HBClearMask, %%mm4 \n\t" +/* preload "movl prev_row, %%esi \n\t" // esi: Prior(x) */ + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" /* load previous aligned 8 bytes */ + /* (correct pos. in loop below) */ + "avg_3lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" /* load mm0 with Avg(x) */ + "movq %%mm5, %%mm3 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" /* correct position Raw(x-bpp) */ + /* data */ + "movq (%%esi,%%ecx,), %%mm1 \n\t" /* load mm1 with Prior(x) */ + "movq %%mm7, %%mm6 \n\t" + "pand %%mm1, %%mm3 \n\t" /* get lsb for each prev_row byte */ + "psrlq $1, %%mm1 \n\t" /* divide prev_row bytes by 2 */ + "pand %%mm4, %%mm1 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm0 \n\t" /* add (Prev_row/2) to Avg for */ + /* each byte */ + /* add 1st active group (Raw(x-bpp)/2) to average with LBCarry */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 1 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active */ + /* byte */ + /* add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry */ + "psllq _ShiftBpp, %%mm6 \n\t" /* shift the mm6 mask to cover */ + /* bytes 3-5 */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active */ + /* byte */ + + /* add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry */ + "psllq _ShiftBpp, %%mm6 \n\t" /* shift mm6 mask to cover last */ + /* two */ + /* bytes */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + /* Data only needs to be shifted once here to */ + /* get the correct x-bpp offset. */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "addl $8, %%ecx \n\t" + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active */ + /* byte */ + /* now ready to write back to memory */ + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + /* move updated Raw(x) to use as Raw(x-bpp) for next loop */ + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm0, %%mm2 \n\t" /* mov updated Raw(x) to mm2 */ + "jb avg_3lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 3 bpp */ + + case 6: + case 4: + //case 7: /* who wrote this? PNG doesn't support 5 or 7 bytes/pixel */ + //case 5: /* GRR BOGUS */ + { + _ActiveMask.use = 0xffffffffffffffffLL; /* use shift below to clear */ + /* appropriate inactive bytes */ + _ShiftBpp.use = bpp << 3; + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( + "movq _HBClearMask, %%mm4 \n\t" + + /* re-init address pointers and offset */ + "movl _dif, %%ecx \n\t" /* ecx: x = offset to */ + /* alignment boundary */ + + /* load _ActiveMask and clear all bytes except for 1st active group */ + "movq _ActiveMask, %%mm7 \n\t" +/* preload "movl row, %%edi \n\t" // edi: Avg(x) */ + "psrlq _ShiftRem, %%mm7 \n\t" +/* preload "movl prev_row, %%esi \n\t" // esi: Prior(x) */ + "movq %%mm7, %%mm6 \n\t" + "movq _LBCarryMask, %%mm5 \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" /* create mask for 2nd active */ + /* group */ + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" /* load previous aligned 8 bytes */ + /* (we correct pos. in loop below) */ + "avg_4lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" /* shift data to pos. correctly */ + "movq (%%esi,%%ecx,), %%mm1 \n\t" + /* add (Prev_row/2) to average */ + "movq %%mm5, %%mm3 \n\t" + "pand %%mm1, %%mm3 \n\t" /* get lsb for each prev_row byte */ + "psrlq $1, %%mm1 \n\t" /* divide prev_row bytes by 2 */ + "pand %%mm4, %%mm1 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm0 \n\t" /* add (Prev_row/2) to Avg for */ + /* each byte */ + /* add 1st active group (Raw(x-bpp)/2) to average with _LBCarry */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm7, %%mm2 \n\t" /* leave only Active Group 1 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to Avg */ + /* for each Active */ + /* byte */ + /* add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + "addl $8, %%ecx \n\t" + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active */ + /* byte */ + "cmpl _MMXLength, %%ecx \n\t" + /* now ready to write back to memory */ + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + /* prep Raw(x-bpp) for next loop */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "jb avg_4lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 4,6 bpp */ + + case 2: + { + _ActiveMask.use = 0x000000000000ffffLL; + _ShiftBpp.use = 16; /* == 2 * 8 */ + _ShiftRem.use = 48; /* == 64 - 16 */ + + __asm__ __volatile__ ( + /* load _ActiveMask */ + "movq _ActiveMask, %%mm7 \n\t" + /* re-init address pointers and offset */ + "movl _dif, %%ecx \n\t" /* ecx: x = offset to alignment */ + /* boundary */ + "movq _LBCarryMask, %%mm5 \n\t" +/* preload "movl row, %%edi \n\t" // edi: Avg(x) */ + "movq _HBClearMask, %%mm4 \n\t" +/* preload "movl prev_row, %%esi \n\t" // esi: Prior(x) */ + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" /* load previous aligned 8 bytes */ + /* (we correct pos. in loop below) */ + "avg_2lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "psrlq _ShiftRem, %%mm2 \n\t" /* shift data to pos. correctly */ + "movq (%%esi,%%ecx,), %%mm1 \n\t" /* (GRR BUGFIX: was psllq) */ + /* add (Prev_row/2) to average */ + "movq %%mm5, %%mm3 \n\t" + "pand %%mm1, %%mm3 \n\t" /* get lsb for each prev_row byte */ + "psrlq $1, %%mm1 \n\t" /* divide prev_row bytes by 2 */ + "pand %%mm4, %%mm1 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "movq %%mm7, %%mm6 \n\t" + "paddb %%mm1, %%mm0 \n\t" /* add (Prev_row/2) to Avg for */ + /* each byte */ + + /* add 1st active group (Raw(x-bpp)/2) to average with _LBCarry */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid */ + /* for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 1 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to Avg */ + /* for each Active byte */ + + /* add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry */ + "psllq _ShiftBpp, %%mm6 \n\t" /* shift the mm6 mask to cover */ + /* bytes 2 & 3 */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid */ + /* for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active byte */ + + /* add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry */ + "psllq _ShiftBpp, %%mm6 \n\t" /* shift the mm6 mask to cover */ + /* bytes 4 & 5 */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both lsb's were == 1 */ + /* (only valid for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active byte */ + + /* add 4th active group (Raw(x-bpp)/2) to average with _LBCarry */ + "psllq _ShiftBpp, %%mm6 \n\t" /* shift the mm6 mask to cover */ + /* bytes 6 & 7 */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "psllq _ShiftBpp, %%mm2 \n\t" /* shift data to pos. correctly */ + "addl $8, %%ecx \n\t" + "movq %%mm3, %%mm1 \n\t" /* now use mm1 for getting */ + /* LBCarrys */ + "pand %%mm2, %%mm1 \n\t" /* get LBCarrys for each byte */ + /* where both */ + /* lsb's were == 1 (only valid */ + /* for active group) */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm2 \n\t" /* add LBCarrys to (Raw(x-bpp)/2) */ + /* for each byte */ + "pand %%mm6, %%mm2 \n\t" /* leave only Active Group 2 */ + /* bytes to add to Avg */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) + LBCarrys to */ + /* Avg for each Active byte */ + + "cmpl _MMXLength, %%ecx \n\t" + /* now ready to write back to memory */ + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + /* prep Raw(x-bpp) for next loop */ + "movq %%mm0, %%mm2 \n\t" /* mov updated Raws to mm2 */ + "jb avg_2lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 2 bpp */ + + case 1: + { + __asm__ __volatile__ ( + /* re-init address pointers and offset */ +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save Global Offset Table index */ +#endif + "movl _dif, %%ebx \n\t" /* ebx: x = offset to alignment */ + /* boundary */ +/* preload "movl row, %%edi \n\t" // edi: Avg(x) */ + "cmpl _FullLength, %%ebx \n\t" /* test if offset at end of array */ + "jnb avg_1end \n\t" + /* do Paeth decode for remaining bytes */ +/* preload "movl prev_row, %%esi \n\t" // esi: Prior(x) */ + "movl %%edi, %%edx \n\t" +/* preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) */ + "subl %%ecx, %%edx \n\t" /* edx: Raw(x-bpp) */ + "xorl %%ecx, %%ecx \n\t" /* zero ecx before using cl & cx */ + /* in loop below */ + "avg_1lp: \n\t" + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" /* load cl with Prior(x) */ + "movb (%%edx,%%ebx,), %%al \n\t" /* load al with Raw(x-bpp) */ + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" /* divide by 2 */ + "addb -1(%%edi,%%ebx,), %%al \n\t" /* add Avg(x); -1 to offset */ + /* inc ebx */ + "cmpl _FullLength, %%ebx \n\t" /* check if at end of array */ + "movb %%al, -1(%%edi,%%ebx,) \n\t" /* write back Raw(x); */ + /* mov does not affect flags; -1 to offset inc ebx */ + "jb avg_1lp \n\t" + + "avg_1end: \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" /* Global Offset Table index */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list */ +#ifndef __PIC__ + , "%ebx" +#endif + ); + } + return; /* end 1 bpp */ + + case 8: + { + __asm__ __volatile__ ( + /* re-init address pointers and offset */ + "movl _dif, %%ecx \n\t" /* ecx: x == offset to alignment */ + "movq _LBCarryMask, %%mm5 \n\t" /* boundary */ +/* preload "movl row, %%edi \n\t" // edi: Avg(x) */ + "movq _HBClearMask, %%mm4 \n\t" +/* preload "movl prev_row, %%esi \n\t" // esi: Prior(x) */ + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm2 \n\t" /* load previous aligned 8 bytes */ + /* (NO NEED to correct pos. in loop below) */ + + "avg_8lp: \n\t" + "movq (%%edi,%%ecx,), %%mm0 \n\t" + "movq %%mm5, %%mm3 \n\t" + "movq (%%esi,%%ecx,), %%mm1 \n\t" + "addl $8, %%ecx \n\t" + "pand %%mm1, %%mm3 \n\t" /* get lsb for each prev_row byte */ + "psrlq $1, %%mm1 \n\t" /* divide prev_row bytes by 2 */ + "pand %%mm2, %%mm3 \n\t" /* get LBCarrys for each byte */ + /* where both lsb's were == 1 */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm1 \n\t" /* clear invalid bit 7, each byte */ + "paddb %%mm3, %%mm0 \n\t" /* add LBCarrys to Avg, each byte */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7, each byte */ + "paddb %%mm1, %%mm0 \n\t" /* add (Prev_row/2) to Avg, each */ + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) to Avg for each */ + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm0, -8(%%edi,%%ecx,) \n\t" + "movq %%mm0, %%mm2 \n\t" /* reuse as Raw(x-bpp) */ + "jb avg_8lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2" + , "%mm3", "%mm4", "%mm5" +#endif + ); + } + break; /* end 8 bpp */ + + default: /* bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) */ + { + +#ifdef PNG_DEBUG + /* GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED */ + png_debug(1, + "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); +#endif + +#if 0 + __asm__ __volatile__ ( + "movq _LBCarryMask, %%mm5 \n\t" + /* re-init address pointers and offset */ + "movl _dif, %%ebx \n\t" /* ebx: x = offset to */ + /* alignment boundary */ + "movl row, %%edi \n\t" /* edi: Avg(x) */ + "movq _HBClearMask, %%mm4 \n\t" + "movl %%edi, %%edx \n\t" + "movl prev_row, %%esi \n\t" /* esi: Prior(x) */ + "subl bpp, %%edx \n\t" /* edx: Raw(x-bpp) */ + "avg_Alp: \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "movq %%mm5, %%mm3 \n\t" + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "pand %%mm1, %%mm3 \n\t" /* get lsb for each prev_row byte */ + "movq (%%edx,%%ebx,), %%mm2 \n\t" + "psrlq $1, %%mm1 \n\t" /* divide prev_row bytes by 2 */ + "pand %%mm2, %%mm3 \n\t" /* get LBCarrys for each byte */ + /* where both lsb's were == 1 */ + "psrlq $1, %%mm2 \n\t" /* divide raw bytes by 2 */ + "pand %%mm4, %%mm1 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm3, %%mm0 \n\t" /* add LBCarrys to Avg for each */ + /* byte */ + "pand %%mm4, %%mm2 \n\t" /* clear invalid bit 7 of each */ + /* byte */ + "paddb %%mm1, %%mm0 \n\t" /* add (Prev_row/2) to Avg for */ + /* each byte */ + "addl $8, %%ebx \n\t" + "paddb %%mm2, %%mm0 \n\t" /* add (Raw/2) to Avg for each */ + /* byte */ + "cmpl _MMXLength, %%ebx \n\t" + "movq %%mm0, -8(%%edi,%%ebx,) \n\t" + "jb avg_Alp \n\t" + + : /* FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) */ + + : /* FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) */ + + : "%ebx", "%edx", "%edi", "%esi" /* CHECKASM: clobber list */ + ); +#endif /* 0 - NEVER REACHED */ + } + break; + + } /* end switch (bpp) */ + + __asm__ __volatile__ ( + /* MMX acceleration complete; now do clean-up */ + /* check if any remaining bytes left to decode */ +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save index to Global Offset Table */ +#endif + "movl _MMXLength, %%ebx \n\t" /* ebx: x == offset bytes after MMX */ +/* pre "movl row, %%edi \n\t" */ /* edi: Avg(x) */ + "cmpl _FullLength, %%ebx \n\t" /* test if offset at end of array */ + "jnb avg_end \n\t" + + /* do Avg decode for remaining bytes */ +/*pre "movl prev_row, %%esi \n\t" */ /* esi: Prior(x) */ + "movl %%edi, %%edx \n\t" +/*pre "subl bpp, %%edx \n\t" */ /* (bpp is preloaded into ecx) */ + "subl %%ecx, %%edx \n\t" /* edx: Raw(x-bpp) */ + "xorl %%ecx, %%ecx \n\t" /* zero ecx before using cl & cx below */ + + "avg_lp2: \n\t" + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + "xorl %%eax, %%eax \n\t" + "movb (%%esi,%%ebx,), %%cl \n\t" /* load cl with Prior(x) */ + "movb (%%edx,%%ebx,), %%al \n\t" /* load al with Raw(x-bpp) */ + "addw %%cx, %%ax \n\t" + "incl %%ebx \n\t" + "shrw %%ax \n\t" /* divide by 2 */ + "addb -1(%%edi,%%ebx,), %%al \n\t" /* add Avg(x); -1 to offset inc ebx */ + "cmpl _FullLength, %%ebx \n\t" /* check if at end of array */ + "movb %%al, -1(%%edi,%%ebx,) \n\t" /* write back Raw(x) [mov does not */ + "jb avg_lp2 \n\t" /* affect flags; -1 to offset inc ebx] */ + + "avg_end: \n\t" + "EMMS \n\t" /* end MMX; prep for poss. FP instrs. */ +#ifdef __PIC__ + "popl %%ebx \n\t" /* restore index to Global Offset Table */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list */ +#ifndef __PIC__ + , "%ebx" +#endif + ); + +} /* end png_read_filter_row_mmx_avg() */ +#endif + + + +#ifdef PNG_THREAD_UNSAFE_OK +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H */ +/* */ +/*===========================================================================*/ + +/* Optimized code for PNG Paeth filter decoder */ + +static void /* PRIVATE */ +png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + int bpp; + int dummy_value_c; /* fix 'forbidden register 2 (cx) was spilled' error */ + int dummy_value_S; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; /* Get # bytes per pixel */ + _FullLength = row_info->rowbytes; /* # of bytes to filter */ + + __asm__ __volatile__ ( +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save index to Global Offset Table */ +#endif + "xorl %%ebx, %%ebx \n\t" /* ebx: x offset */ +/*pre "movl row, %%edi \n\t" */ + "xorl %%edx, %%edx \n\t" /* edx: x-bpp offset */ +/*pre "movl prev_row, %%esi \n\t" */ + "xorl %%eax, %%eax \n\t" + + /* Compute the Raw value for the first bpp bytes */ + /* Note: the formula works out to be always */ + /* Paeth(x) = Raw(x) + Prior(x) where x < bpp */ + "paeth_rlp: \n\t" + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" +/*pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) */ + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" + "jb paeth_rlp \n\t" + /* get # of bytes to alignment */ + "movl %%edi, _dif \n\t" /* take start of row */ + "addl %%ebx, _dif \n\t" /* add bpp */ + "xorl %%ecx, %%ecx \n\t" + "addl $0xf, _dif \n\t" /* add 7 + 8 to incr past alignment */ + /* boundary */ + "andl $0xfffffff8, _dif \n\t" /* mask to alignment boundary */ + "subl %%edi, _dif \n\t" /* subtract from start ==> value ebx */ + /* at alignment */ + "jz paeth_go \n\t" + /* fix alignment */ + + "paeth_lp1: \n\t" + "xorl %%eax, %%eax \n\t" + /* pav = p - a = (a + b - c) - a = b - c */ + "movb (%%esi,%%ebx,), %%al \n\t" /* load Prior(x) into al */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, _patemp \n\t" /* Save pav for later use */ + "xorl %%eax, %%eax \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movb (%%edi,%%edx,), %%al \n\t" /* load Raw(x-bpp) into al */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, %%ecx \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "addl _patemp, %%eax \n\t" /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + "testl $0x80000000, %%eax \n\t" + "jz paeth_pca \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_pca: \n\t" + "movl %%eax, _pctemp \n\t" /* save pc for later use */ + /* pb = abs(pbv) */ + "testl $0x80000000, %%ecx \n\t" + "jz paeth_pba \n\t" + "negl %%ecx \n\t" /* reverse sign of neg values */ + + "paeth_pba: \n\t" + "movl %%ecx, _pbtemp \n\t" /* save pb for later use */ + /* pa = abs(pav) */ + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_paa \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_paa: \n\t" + "movl %%eax, _patemp \n\t" /* save pa for later use */ + /* test if pa <= pb */ + "cmpl %%ecx, %%eax \n\t" + "jna paeth_abb \n\t" + /* pa > pb; now test if pb <= pc */ + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_bbc \n\t" + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_paeth \n\t" + + "paeth_bbc: \n\t" + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + "movb (%%esi,%%ebx,), %%cl \n\t" /* load Prior(x) into cl */ + "jmp paeth_paeth \n\t" + + "paeth_abb: \n\t" + /* pa <= pb; now test if pa <= pc */ + "cmpl _pctemp, %%eax \n\t" + "jna paeth_abc \n\t" + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_paeth \n\t" + + "paeth_abc: \n\t" + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + "movb (%%edi,%%edx,), %%cl \n\t" /* load Raw(x-bpp) into cl */ + + "paeth_paeth: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _dif, %%ebx \n\t" + "jb paeth_lp1 \n\t" + + "paeth_go: \n\t" + "movl _FullLength, %%ecx \n\t" + "movl %%ecx, %%eax \n\t" + "subl %%ebx, %%eax \n\t" /* subtract alignment fix */ + "andl $0x00000007, %%eax \n\t" /* calc bytes over mult of 8 */ + "subl %%eax, %%ecx \n\t" /* drop over bytes from original length */ + "movl %%ecx, _MMXLength \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" /* restore index to Global Offset Table */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list */ +#ifndef __PIC__ + , "%ebx" +#endif + ); + + /* now do the math for the rest of the row */ + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000000000ffffffLL; + _ActiveMaskEnd.use = 0xffff000000000000LL; + _ShiftBpp.use = 24; /* == bpp(3) * 8 */ + _ShiftRem.use = 40; /* == 64 - 24 */ + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +/* preload "movl row, %%edi \n\t" */ +/* preload "movl prev_row, %%esi \n\t" */ + "pxor %%mm0, %%mm0 \n\t" + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "paeth_3lp: \n\t" + "psrlq _ShiftRem, %%mm1 \n\t" /* shift last 3 bytes to 1st */ + /* 3 bytes */ + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "punpcklbw %%mm0, %%mm1 \n\t" /* unpack High bytes of a */ + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* prep c=Prior(x-bpp) bytes */ + "punpcklbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + "psrlq _ShiftRem, %%mm3 \n\t" /* shift last 3 bytes to 1st */ + /* 3 bytes */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm3 \n\t" /* load c=Prior(x-bpp) */ + "pand _ActiveMask, %%mm7 \n\t" + "movq %%mm3, %%mm2 \n\t" /* load b=Prior(x) step 1 */ + "paddb (%%edi,%%ecx,), %%mm7 \n\t" /* add Paeth predictor with Raw(x) */ + "punpcklbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + "movq %%mm7, (%%edi,%%ecx,) \n\t" /* write back updated value */ + "movq %%mm7, %%mm1 \n\t" /* now mm1 will be used as */ + /* Raw(x-bpp) */ + /* now do Paeth for 2nd set of bytes (3-5) */ + "psrlq _ShiftBpp, %%mm2 \n\t" /* load b=Prior(x) step 2 */ + "punpcklbw %%mm0, %%mm1 \n\t" /* unpack High bytes of a */ + "pxor %%mm7, %%mm7 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "psubw %%mm3, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = */ + /* pav + pbv = pbv + pav */ + "movq %%mm5, %%mm6 \n\t" + "paddw %%mm4, %%mm6 \n\t" + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm5, %%mm0 \n\t" /* create mask pbv bytes < 0 */ + "pcmpgtw %%mm4, %%mm7 \n\t" /* create mask pav bytes < 0 */ + "pand %%mm5, %%mm0 \n\t" /* only pbv bytes < 0 in mm0 */ + "pand %%mm4, %%mm7 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm0, %%mm5 \n\t" + "psubw %%mm7, %%mm4 \n\t" + "psubw %%mm0, %%mm5 \n\t" + "psubw %%mm7, %%mm4 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq %%mm2, %%mm3 \n\t" /* load c=Prior(x-bpp) step 1 */ + "pand _ActiveMask, %%mm7 \n\t" + "punpckhbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + "psllq _ShiftBpp, %%mm7 \n\t" /* shift bytes to 2nd group of */ + /* 3 bytes */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "paddb (%%edi,%%ecx,), %%mm7 \n\t" /* add Paeth predictor with Raw(x) */ + "psllq _ShiftBpp, %%mm3 \n\t" /* load c=Prior(x-bpp) step 2 */ + "movq %%mm7, (%%edi,%%ecx,) \n\t" /* write back updated value */ + "movq %%mm7, %%mm1 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift bytes */ + /* now mm1 will be used as Raw(x-bpp) */ + /* now do Paeth for 3rd, and final, set of bytes (6-7) */ + "pxor %%mm7, %%mm7 \n\t" + "punpckhbw %%mm0, %%mm1 \n\t" /* unpack High bytes of a */ + "psubw %%mm3, %%mm4 \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "paddw %%mm5, %%mm6 \n\t" + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "packuswb %%mm7, %%mm1 \n\t" + /* step ecx to next set of 8 bytes and repeat loop til done */ + "addl $8, %%ecx \n\t" + "pand _ActiveMaskEnd, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" /* add Paeth predictor with */ + /* Raw(x) */ + + "cmpl _MMXLength, %%ecx \n\t" + "pxor %%mm0, %%mm0 \n\t" /* pxor does not affect flags */ + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + /* mm3 ready to be used as Prior(x-bpp) next loop */ + "jb paeth_3lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 3 bpp */ + + case 6: + //case 7: /* GRR BOGUS */ + //case 5: /* GRR BOGUS */ + { + _ActiveMask.use = 0x00000000ffffffffLL; + _ActiveMask2.use = 0xffffffff00000000LL; + _ShiftBpp.use = bpp << 3; /* == bpp * 8 */ + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +/* preload "movl row, %%edi \n\t" */ +/* preload "movl prev_row, %%esi \n\t" */ + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "pxor %%mm0, %%mm0 \n\t" + + "paeth_6lp: \n\t" + /* must shift to position Raw(x-bpp) data */ + "psrlq _ShiftRem, %%mm1 \n\t" + /* do first set of 4 bytes */ + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* read c=Prior(x-bpp) bytes */ + "punpcklbw %%mm0, %%mm1 \n\t" /* unpack Low bytes of a */ + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "punpcklbw %%mm0, %%mm2 \n\t" /* unpack Low bytes of b */ + /* must shift to position Prior(x-bpp) data */ + "psrlq _ShiftRem, %%mm3 \n\t" + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" /* unpack Low bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* load c=Prior(x-bpp) */ + "pand _ActiveMask, %%mm7 \n\t" + "psrlq _ShiftRem, %%mm3 \n\t" + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) step 1 */ + "paddb (%%edi,%%ecx,), %%mm7 \n\t" /* add Paeth predictor and Raw(x) */ + "movq %%mm2, %%mm6 \n\t" + "movq %%mm7, (%%edi,%%ecx,) \n\t" /* write back updated value */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" + "movq %%mm7, %%mm5 \n\t" + "psrlq _ShiftRem, %%mm1 \n\t" + "por %%mm6, %%mm3 \n\t" + "psllq _ShiftBpp, %%mm5 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + "por %%mm5, %%mm1 \n\t" + /* do second set of 4 bytes */ + "punpckhbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + "punpckhbw %%mm0, %%mm1 \n\t" /* unpack High bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + /* step ecx to next set of 8 bytes and repeat loop til done */ + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" /* add Paeth predictor with Raw(x) */ + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + "jb paeth_6lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 6 bpp */ + + case 4: + { + _ActiveMask.use = 0x00000000ffffffffLL; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +/* preload "movl row, %%edi \n\t" */ +/* preload "movl prev_row, %%esi \n\t" */ + "pxor %%mm0, %%mm0 \n\t" + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" /* only time should need to read */ + /* a=Raw(x-bpp) bytes */ + "paeth_4lp: \n\t" + /* do first set of 4 bytes */ + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* read c=Prior(x-bpp) bytes */ + "punpckhbw %%mm0, %%mm1 \n\t" /* unpack Low bytes of a */ + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "punpcklbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm3 \n\t" /* load c=Prior(x-bpp) */ + "pand _ActiveMask, %%mm7 \n\t" + "movq %%mm3, %%mm2 \n\t" /* load b=Prior(x) step 1 */ + "paddb (%%edi,%%ecx,), %%mm7 \n\t" /* add Paeth predictor with Raw(x) */ + "punpcklbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + "movq %%mm7, (%%edi,%%ecx,) \n\t" /* write back updated value */ + "movq %%mm7, %%mm1 \n\t" /* now mm1 will be used as Raw(x-bpp) */ + /* do second set of 4 bytes */ + "punpckhbw %%mm0, %%mm2 \n\t" /* unpack Low bytes of b */ + "punpcklbw %%mm0, %%mm1 \n\t" /* unpack Low bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + /* step ecx to next set of 8 bytes and repeat loop til done */ + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" /* add predictor with Raw(x) */ + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + "jb paeth_4lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 4 bpp */ + + case 8: /* bpp == 8 */ + { + _ActiveMask.use = 0x00000000ffffffffLL; + + __asm__ __volatile__ ( + "movl _dif, %%ecx \n\t" +/* preload "movl row, %%edi \n\t" */ +/* preload "movl prev_row, %%esi \n\t" */ + "pxor %%mm0, %%mm0 \n\t" + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" /* only time should need to read */ + /* a=Raw(x-bpp) bytes */ + "paeth_8lp: \n\t" + /* do first set of 4 bytes */ + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* read c=Prior(x-bpp) bytes */ + "punpcklbw %%mm0, %%mm1 \n\t" /* unpack Low bytes of a */ + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "punpcklbw %%mm0, %%mm2 \n\t" /* unpack Low bytes of b */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" /* unpack Low bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "packuswb %%mm1, %%mm7 \n\t" + "movq -8(%%esi,%%ecx,), %%mm3 \n\t" /* read c=Prior(x-bpp) bytes */ + "pand _ActiveMask, %%mm7 \n\t" + "movq (%%esi,%%ecx,), %%mm2 \n\t" /* load b=Prior(x) */ + "paddb (%%edi,%%ecx,), %%mm7 \n\t" /* add Paeth predictor with Raw(x) */ + "punpckhbw %%mm0, %%mm3 \n\t" /* unpack High bytes of c */ + "movq %%mm7, (%%edi,%%ecx,) \n\t" /* write back updated value */ + "movq -8(%%edi,%%ecx,), %%mm1 \n\t" /* read a=Raw(x-bpp) bytes */ + + /* do second set of 4 bytes */ + "punpckhbw %%mm0, %%mm2 \n\t" /* unpack High bytes of b */ + "punpckhbw %%mm0, %%mm1 \n\t" /* unpack High bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + "movq %%mm2, %%mm4 \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movq %%mm1, %%mm5 \n\t" + "psubw %%mm3, %%mm4 \n\t" + "pxor %%mm7, %%mm7 \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "movq %%mm4, %%mm6 \n\t" + "psubw %%mm3, %%mm5 \n\t" + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + "pcmpgtw %%mm4, %%mm0 \n\t" /* create mask pav bytes < 0 */ + "paddw %%mm5, %%mm6 \n\t" + "pand %%mm4, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "pcmpgtw %%mm5, %%mm7 \n\t" /* create mask pbv bytes < 0 */ + "psubw %%mm0, %%mm4 \n\t" + "pand %%mm5, %%mm7 \n\t" /* only pbv bytes < 0 in mm0 */ + "psubw %%mm0, %%mm4 \n\t" + "psubw %%mm7, %%mm5 \n\t" + "pxor %%mm0, %%mm0 \n\t" + "pcmpgtw %%mm6, %%mm0 \n\t" /* create mask pcv bytes < 0 */ + "pand %%mm6, %%mm0 \n\t" /* only pav bytes < 0 in mm7 */ + "psubw %%mm7, %%mm5 \n\t" + "psubw %%mm0, %%mm6 \n\t" + /* test pa <= pb */ + "movq %%mm4, %%mm7 \n\t" + "psubw %%mm0, %%mm6 \n\t" + "pcmpgtw %%mm5, %%mm7 \n\t" /* pa > pb? */ + "movq %%mm7, %%mm0 \n\t" + /* use mm7 mask to merge pa & pb */ + "pand %%mm7, %%mm5 \n\t" + /* use mm0 mask copy to merge a & b */ + "pand %%mm0, %%mm2 \n\t" + "pandn %%mm4, %%mm7 \n\t" + "pandn %%mm1, %%mm0 \n\t" + "paddw %%mm5, %%mm7 \n\t" + "paddw %%mm2, %%mm0 \n\t" + /* test ((pa <= pb)? pa:pb) <= pc */ + "pcmpgtw %%mm6, %%mm7 \n\t" /* pab > pc? */ + "pxor %%mm1, %%mm1 \n\t" + "pand %%mm7, %%mm3 \n\t" + "pandn %%mm0, %%mm7 \n\t" + "pxor %%mm1, %%mm1 \n\t" + "paddw %%mm3, %%mm7 \n\t" + "pxor %%mm0, %%mm0 \n\t" + /* step ecx to next set of 8 bytes and repeat loop til done */ + "addl $8, %%ecx \n\t" + "packuswb %%mm7, %%mm1 \n\t" + "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" /* add Paeth predictor with Raw(x) */ + "cmpl _MMXLength, %%ecx \n\t" + "movq %%mm1, -8(%%edi,%%ecx,) \n\t" /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + "jb paeth_8lp \n\t" + + : "=S" (dummy_value_S), /* output regs (dummy) */ + "=D" (dummy_value_D) + + : "0" (prev_row), /* esi // input regs */ + "1" (row) /* edi */ + + : "%ecx" /* clobber list */ +#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; /* end 8 bpp */ + + case 1: /* bpp = 1 */ + case 2: /* bpp = 2 */ + default: /* bpp > 8 */ + { + __asm__ __volatile__ ( +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save Global Offset Table index */ +#endif + "movl _dif, %%ebx \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jnb paeth_dend \n\t" + +/* preload "movl row, %%edi \n\t" */ +/* preload "movl prev_row, %%esi \n\t" */ + /* do Paeth decode for remaining bytes */ + "movl %%ebx, %%edx \n\t" +/* preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) */ + "subl %%ecx, %%edx \n\t" /* edx = ebx - bpp */ + "xorl %%ecx, %%ecx \n\t" /* zero ecx before using cl & cx */ + + "paeth_dlp: \n\t" + "xorl %%eax, %%eax \n\t" + /* pav = p - a = (a + b - c) - a = b - c */ + "movb (%%esi,%%ebx,), %%al \n\t" /* load Prior(x) into al */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, _patemp \n\t" /* Save pav for later use */ + "xorl %%eax, %%eax \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movb (%%edi,%%edx,), %%al \n\t" /* load Raw(x-bpp) into al */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, %%ecx \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "addl _patemp, %%eax \n\t" /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + "testl $0x80000000, %%eax \n\t" + "jz paeth_dpca \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_dpca: \n\t" + "movl %%eax, _pctemp \n\t" /* save pc for later use */ + /* pb = abs(pbv) */ + "testl $0x80000000, %%ecx \n\t" + "jz paeth_dpba \n\t" + "negl %%ecx \n\t" /* reverse sign of neg values */ + + "paeth_dpba: \n\t" + "movl %%ecx, _pbtemp \n\t" /* save pb for later use */ + /* pa = abs(pav) */ + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_dpaa \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_dpaa: \n\t" + "movl %%eax, _patemp \n\t" /* save pa for later use */ + /* test if pa <= pb */ + "cmpl %%ecx, %%eax \n\t" + "jna paeth_dabb \n\t" + /* pa > pb; now test if pb <= pc */ + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_dbbc \n\t" + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_dpaeth \n\t" + + "paeth_dbbc: \n\t" + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + "movb (%%esi,%%ebx,), %%cl \n\t" /* load Prior(x) into cl */ + "jmp paeth_dpaeth \n\t" + + "paeth_dabb: \n\t" + /* pa <= pb; now test if pa <= pc */ + "cmpl _pctemp, %%eax \n\t" + "jna paeth_dabc \n\t" + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_dpaeth \n\t" + + "paeth_dabc: \n\t" + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + "movb (%%edi,%%edx,), %%cl \n\t" /* load Raw(x-bpp) into cl */ + + "paeth_dpaeth: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jb paeth_dlp \n\t" + + "paeth_dend: \n\t" +#ifdef __PIC__ + "popl %%ebx \n\t" /* index to Global Offset Table */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list */ +#ifndef __PIC__ + , "%ebx" +#endif + ); + } + return; /* No need to go further with this one */ + + } /* end switch (bpp) */ + + __asm__ __volatile__ ( + /* MMX acceleration complete; now do clean-up */ + /* check if any remaining bytes left to decode */ +#ifdef __PIC__ + "pushl %%ebx \n\t" /* save index to Global Offset Table */ +#endif + "movl _MMXLength, %%ebx \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jnb paeth_end \n\t" +/*pre "movl row, %%edi \n\t" */ +/*pre "movl prev_row, %%esi \n\t" */ + /* do Paeth decode for remaining bytes */ + "movl %%ebx, %%edx \n\t" +/*pre "subl bpp, %%edx \n\t" */ /* (bpp is preloaded into ecx) */ + "subl %%ecx, %%edx \n\t" /* edx = ebx - bpp */ + "xorl %%ecx, %%ecx \n\t" /* zero ecx before using cl & cx below */ + + "paeth_lp2: \n\t" + "xorl %%eax, %%eax \n\t" + /* pav = p - a = (a + b - c) - a = b - c */ + "movb (%%esi,%%ebx,), %%al \n\t" /* load Prior(x) into al */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, _patemp \n\t" /* Save pav for later use */ + "xorl %%eax, %%eax \n\t" + /* pbv = p - b = (a + b - c) - b = a - c */ + "movb (%%edi,%%edx,), %%al \n\t" /* load Raw(x-bpp) into al */ + "subl %%ecx, %%eax \n\t" /* subtract Prior(x-bpp) */ + "movl %%eax, %%ecx \n\t" + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + "addl _patemp, %%eax \n\t" /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + "testl $0x80000000, %%eax \n\t" + "jz paeth_pca2 \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_pca2: \n\t" + "movl %%eax, _pctemp \n\t" /* save pc for later use */ + /* pb = abs(pbv) */ + "testl $0x80000000, %%ecx \n\t" + "jz paeth_pba2 \n\t" + "negl %%ecx \n\t" /* reverse sign of neg values */ + + "paeth_pba2: \n\t" + "movl %%ecx, _pbtemp \n\t" /* save pb for later use */ + /* pa = abs(pav) */ + "movl _patemp, %%eax \n\t" + "testl $0x80000000, %%eax \n\t" + "jz paeth_paa2 \n\t" + "negl %%eax \n\t" /* reverse sign of neg values */ + + "paeth_paa2: \n\t" + "movl %%eax, _patemp \n\t" /* save pa for later use */ + /* test if pa <= pb */ + "cmpl %%ecx, %%eax \n\t" + "jna paeth_abb2 \n\t" + /* pa > pb; now test if pb <= pc */ + "cmpl _pctemp, %%ecx \n\t" + "jna paeth_bbc2 \n\t" + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_paeth2 \n\t" + + "paeth_bbc2: \n\t" + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + "movb (%%esi,%%ebx,), %%cl \n\t" /* load Prior(x) into cl */ + "jmp paeth_paeth2 \n\t" + + "paeth_abb2: \n\t" + /* pa <= pb; now test if pa <= pc */ + "cmpl _pctemp, %%eax \n\t" + "jna paeth_abc2 \n\t" + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + "movb (%%esi,%%edx,), %%cl \n\t" /* load Prior(x-bpp) into cl */ + "jmp paeth_paeth2 \n\t" + + "paeth_abc2: \n\t" + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + "movb (%%edi,%%edx,), %%cl \n\t" /* load Raw(x-bpp) into cl */ + + "paeth_paeth2: \n\t" + "incl %%ebx \n\t" + "incl %%edx \n\t" + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + "addb %%cl, -1(%%edi,%%ebx,) \n\t" + "cmpl _FullLength, %%ebx \n\t" + "jb paeth_lp2 \n\t" + + "paeth_end: \n\t" + "EMMS \n\t" /* end MMX; prep for poss. FP instrs. */ +#ifdef __PIC__ + "popl %%ebx \n\t" /* restore index to Global Offset Table */ +#endif + + : "=c" (dummy_value_c), /* output regs (dummy) */ + "=S" (dummy_value_S), + "=D" (dummy_value_D) + + : "0" (bpp), /* ecx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%edx" /* clobber list (no input regs!) */ +#ifndef __PIC__ + , "%ebx" +#endif + ); + +} /* end png_read_filter_row_mmx_paeth() */ +#endif + + + + +#ifdef PNG_THREAD_UNSAFE_OK +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B */ +/* */ +/*===========================================================================*/ + +/* Optimized code for PNG Sub filter decoder */ + +static void /* PRIVATE */ +png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) +{ + int bpp; + int dummy_value_a; + int dummy_value_D; + + bpp = (row_info->pixel_depth + 7) >> 3; /* calc number of bytes per pixel */ + _FullLength = row_info->rowbytes - bpp; /* number of bytes to filter */ + + __asm__ __volatile__ ( +/*pre "movl row, %%edi \n\t" */ + "movl %%edi, %%esi \n\t" /* lp = row */ +/*pre "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ +/*irr "xorl %%eax, %%eax \n\t" */ + /* get # of bytes to alignment */ + "movl %%edi, _dif \n\t" /* take start of row */ + "addl $0xf, _dif \n\t" /* add 7 + 8 to incr past */ + /* alignment boundary */ + "xorl %%ecx, %%ecx \n\t" + "andl $0xfffffff8, _dif \n\t" /* mask to alignment boundary */ + "subl %%edi, _dif \n\t" /* subtract from start ==> value */ + "jz sub_go \n\t" /* ecx at alignment */ + + "sub_lp1: \n\t" /* fix alignment */ + "movb (%%esi,%%ecx,), %%al \n\t" + "addb %%al, (%%edi,%%ecx,) \n\t" + "incl %%ecx \n\t" + "cmpl _dif, %%ecx \n\t" + "jb sub_lp1 \n\t" + + "sub_go: \n\t" + "movl _FullLength, %%eax \n\t" + "movl %%eax, %%edx \n\t" + "subl %%ecx, %%edx \n\t" /* subtract alignment fix */ + "andl $0x00000007, %%edx \n\t" /* calc bytes over mult of 8 */ + "subl %%edx, %%eax \n\t" /* drop over bytes from length */ + "movl %%eax, _MMXLength \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%esi", "%ecx", "%edx" // clobber list + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + + /* now do the math for the rest of the row */ + switch (bpp) + { + case 3: + { + _ActiveMask.use = 0x0000ffffff000000LL; + _ShiftBpp.use = 24; /* == 3 * 8 */ + _ShiftRem.use = 40; /* == 64 - 24 */ + + __asm__ __volatile__ ( +/* preload "movl row, %%edi \n\t" */ + "movq _ActiveMask, %%mm7 \n\t" /* load _ActiveMask for 2nd */ + /* active byte group */ + "movl %%edi, %%esi \n\t" /* lp = row */ +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + "movq %%mm7, %%mm6 \n\t" + "movl _dif, %%edx \n\t" + "psllq _ShiftBpp, %%mm6 \n\t" /* move mask in mm6 to cover */ + /* 3rd active byte group */ + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_3lp: \n\t" /* shift data for adding first */ + "psrlq _ShiftRem, %%mm1 \n\t" /* bpp bytes (no need for mask; */ + /* shift clears inactive bytes) */ + /* add 1st active group */ + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + /* add 2nd active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "pand %%mm7, %%mm1 \n\t" /* mask to use 2nd active group */ + "paddb %%mm1, %%mm0 \n\t" + + /* add 3rd active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "pand %%mm6, %%mm1 \n\t" /* mask to use 3rd active group */ + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" /* write updated Raws to array */ + "movq %%mm0, %%mm1 \n\t" /* prep 1st add at top of loop */ + "jb sub_3lp \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm6", "%mm7" +#endif + ); + } + break; + + case 1: + { + __asm__ __volatile__ ( + "movl _dif, %%edx \n\t" +/* preload "movl row, %%edi \n\t" */ + "cmpl _FullLength, %%edx \n\t" + "jnb sub_1end \n\t" + "movl %%edi, %%esi \n\t" /* lp = row */ + "xorl %%eax, %%eax \n\t" +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + + "sub_1lp: \n\t" + "movb (%%esi,%%edx,), %%al \n\t" + "addb %%al, (%%edi,%%edx,) \n\t" + "incl %%edx \n\t" + "cmpl _FullLength, %%edx \n\t" + "jb sub_1lp \n\t" + + "sub_1end: \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ + ); + } + return; + + case 6: + case 4: + //case 7: /* GRR BOGUS */ + //case 5: /* GRR BOGUS */ + { + _ShiftBpp.use = bpp << 3; + _ShiftRem.use = 64 - _ShiftBpp.use; + + __asm__ __volatile__ ( +/* preload "movl row, %%edi \n\t" */ + "movl _dif, %%edx \n\t" + "movl %%edi, %%esi \n\t" /* lp = row */ +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_4lp: \n\t" /* shift data for adding first */ + "psrlq _ShiftRem, %%mm1 \n\t" /* bpp bytes (no need for mask; */ + /* shift clears inactive bytes) */ + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + /* add 2nd active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" + "movq %%mm0, %%mm1 \n\t" /* prep 1st add at top of loop */ + "jb sub_4lp \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1" +#endif + ); + } + break; + + case 2: + { + _ActiveMask.use = 0x00000000ffff0000LL; + _ShiftBpp.use = 16; /* == 2 * 8 */ + _ShiftRem.use = 48; /* == 64 - 16 */ + + __asm__ __volatile__ ( + "movq _ActiveMask, %%mm7 \n\t" /* load _ActiveMask for 2nd */ + /* active byte group */ + "movl _dif, %%edx \n\t" + "movq %%mm7, %%mm6 \n\t" +/* preload "movl row, %%edi \n\t" */ + "psllq _ShiftBpp, %%mm6 \n\t" /* move mask in mm6 to cover */ + /* 3rd active byte group */ + "movl %%edi, %%esi \n\t" /* lp = row */ + "movq %%mm6, %%mm5 \n\t" +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + "psllq _ShiftBpp, %%mm5 \n\t" /* move mask in mm5 to cover */ + /* 4th active byte group */ + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%edx,), %%mm1 \n\t" + + "sub_2lp: \n\t" /* shift data for adding first */ + "psrlq _ShiftRem, %%mm1 \n\t" /* bpp bytes (no need for mask; */ + /* shift clears inactive bytes) */ + /* add 1st active group */ + "movq (%%edi,%%edx,), %%mm0 \n\t" + "paddb %%mm1, %%mm0 \n\t" + + /* add 2nd active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "pand %%mm7, %%mm1 \n\t" /* mask to use 2nd active group */ + "paddb %%mm1, %%mm0 \n\t" + + /* add 3rd active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "pand %%mm6, %%mm1 \n\t" /* mask to use 3rd active group */ + "paddb %%mm1, %%mm0 \n\t" + + /* add 4th active group */ + "movq %%mm0, %%mm1 \n\t" /* mov updated Raws to mm1 */ + "psllq _ShiftBpp, %%mm1 \n\t" /* shift data to pos. correctly */ + "pand %%mm5, %%mm1 \n\t" /* mask to use 4th active group */ + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" /* write updated Raws to array */ + "movq %%mm0, %%mm1 \n\t" /* prep 1st add at top of loop */ + "jb sub_2lp \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; + + case 8: + { + __asm__ __volatile__ ( +/* preload "movl row, %%edi \n\t" */ + "movl _dif, %%edx \n\t" + "movl %%edi, %%esi \n\t" /* lp = row */ +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + "movl _MMXLength, %%ecx \n\t" + + /* prime the pump: load the first Raw(x-bpp) data set */ + "movq -8(%%edi,%%edx,), %%mm7 \n\t" + "andl $0x0000003f, %%ecx \n\t" /* calc bytes over mult of 64 */ + + "sub_8lp: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" /* load Sub(x) for 1st 8 bytes */ + "paddb %%mm7, %%mm0 \n\t" + "movq 8(%%edi,%%edx,), %%mm1 \n\t" /* load Sub(x) for 2nd 8 bytes */ + "movq %%mm0, (%%edi,%%edx,) \n\t" /* write Raw(x) for 1st 8 bytes */ + + /* Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. */ + /* This will be repeated for each group of 8 bytes with the 8th */ + /* group being used as the Raw(x-bpp) for the 1st group of the */ + /* next loop. */ + + "paddb %%mm0, %%mm1 \n\t" + "movq 16(%%edi,%%edx,), %%mm2 \n\t" /* load Sub(x) for 3rd 8 bytes */ + "movq %%mm1, 8(%%edi,%%edx,) \n\t" /* write Raw(x) for 2nd 8 bytes */ + "paddb %%mm1, %%mm2 \n\t" + "movq 24(%%edi,%%edx,), %%mm3 \n\t" /* load Sub(x) for 4th 8 bytes */ + "movq %%mm2, 16(%%edi,%%edx,) \n\t" /* write Raw(x) for 3rd 8 bytes */ + "paddb %%mm2, %%mm3 \n\t" + "movq 32(%%edi,%%edx,), %%mm4 \n\t" /* load Sub(x) for 5th 8 bytes */ + "movq %%mm3, 24(%%edi,%%edx,) \n\t" /* write Raw(x) for 4th 8 bytes */ + "paddb %%mm3, %%mm4 \n\t" + "movq 40(%%edi,%%edx,), %%mm5 \n\t" /* load Sub(x) for 6th 8 bytes */ + "movq %%mm4, 32(%%edi,%%edx,) \n\t" /* write Raw(x) for 5th 8 bytes */ + "paddb %%mm4, %%mm5 \n\t" + "movq 48(%%edi,%%edx,), %%mm6 \n\t" /* load Sub(x) for 7th 8 bytes */ + "movq %%mm5, 40(%%edi,%%edx,) \n\t" /* write Raw(x) for 6th 8 bytes */ + "paddb %%mm5, %%mm6 \n\t" + "movq 56(%%edi,%%edx,), %%mm7 \n\t" /* load Sub(x) for 8th 8 bytes */ + "movq %%mm6, 48(%%edi,%%edx,) \n\t" /* write Raw(x) for 7th 8 bytes */ + "addl $64, %%edx \n\t" + "paddb %%mm6, %%mm7 \n\t" + "cmpl %%ecx, %%edx \n\t" + "movq %%mm7, -8(%%edi,%%edx,) \n\t" /* write Raw(x) for 8th 8 bytes */ + "jb sub_8lp \n\t" + + "cmpl _MMXLength, %%edx \n\t" + "jnb sub_8lt8 \n\t" + + "sub_8lpA: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" + "addl $8, %%edx \n\t" + "paddb %%mm7, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" /* -8 to offset early addl edx */ + "movq %%mm0, %%mm7 \n\t" /* move calculated Raw(x) data */ + /* to mm1 to be new Raw(x-bpp) */ + /* for next loop */ + "jb sub_8lpA \n\t" + + "sub_8lt8: \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%ecx", "%edx", "%esi" /* clobber list */ +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + } + break; + + default: /* bpp greater than 8 bytes GRR BOGUS */ + { + __asm__ __volatile__ ( + "movl _dif, %%edx \n\t" +/* preload "movl row, %%edi \n\t" */ + "movl %%edi, %%esi \n\t" /* lp = row */ +/* preload "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + + "sub_Alp: \n\t" + "movq (%%edi,%%edx,), %%mm0 \n\t" + "movq (%%esi,%%edx,), %%mm1 \n\t" + "addl $8, %%edx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl _MMXLength, %%edx \n\t" + "movq %%mm0, -8(%%edi,%%edx,) \n\t" /* mov does not affect flags; */ + /* -8 to offset addl edx */ + "jb sub_Alp \n\t" + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1" +#endif + ); + } + break; + + } /* end switch (bpp) */ + + __asm__ __volatile__ ( + "movl _MMXLength, %%edx \n\t" +/* pre "movl row, %%edi \n\t" */ + "cmpl _FullLength, %%edx \n\t" + "jnb sub_end \n\t" + + "movl %%edi, %%esi \n\t" /* lp = row */ +/* pre "movl bpp, %%eax \n\t" */ + "addl %%eax, %%edi \n\t" /* rp = row + bpp */ + "xorl %%eax, %%eax \n\t" + + "sub_lp2: \n\t" + "movb (%%esi,%%edx,), %%al \n\t" + "addb %%al, (%%edi,%%edx,) \n\t" + "incl %%edx \n\t" + "cmpl _FullLength, %%edx \n\t" + "jb sub_lp2 \n\t" + + "sub_end: \n\t" + "EMMS \n\t" /* end MMX instructions */ + + : "=a" (dummy_value_a), /* 0 // output regs (dummy) */ + "=D" (dummy_value_D) /* 1 */ + + : "0" (bpp), /* eax // input regs */ + "1" (row) /* edi */ + + : "%edx", "%esi" /* clobber list */ + ); + +} /* end of png_read_filter_row_mmx_sub() */ +#endif + + + + +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P */ +/* */ +/*===========================================================================*/ + +/* Optimized code for PNG Up filter decoder */ + +static void /* PRIVATE */ +png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 len; + int dummy_value_d; /* fix 'forbidden register 3 (dx) was spilled' error */ + int dummy_value_S; + int dummy_value_D; + + len = row_info->rowbytes; /* number of bytes to filter */ + + __asm__ __volatile__ ( +/* pre "movl row, %%edi \n\t" */ + /* get # of bytes to alignment */ +#ifdef __PIC__ + "pushl %%ebx \n\t" +#endif + "movl %%edi, %%ecx \n\t" + "xorl %%ebx, %%ebx \n\t" + "addl $0x7, %%ecx \n\t" + "xorl %%eax, %%eax \n\t" + "andl $0xfffffff8, %%ecx \n\t" +/* pre "movl prev_row, %%esi \n\t" */ + "subl %%edi, %%ecx \n\t" + "jz up_go \n\t" + + "up_lp1: \n\t" /* fix alignment */ + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" /* mov does not affect flags; -1 to */ + "jb up_lp1 \n\t" /* offset incl ebx */ + + "up_go: \n\t" +/* pre "movl len, %%edx \n\t" */ + "movl %%edx, %%ecx \n\t" + "subl %%ebx, %%edx \n\t" /* subtract alignment fix */ + "andl $0x0000003f, %%edx \n\t" /* calc bytes over mult of 64 */ + "subl %%edx, %%ecx \n\t" /* drop over bytes from length */ + + /* unrolled loop - use all MMX registers and interleave to reduce */ + /* number of branch instructions (loops) and reduce partial stalls */ + "up_loop: \n\t" + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "movq 8(%%esi,%%ebx,), %%mm3 \n\t" + "paddb %%mm1, %%mm0 \n\t" + "movq 8(%%edi,%%ebx,), %%mm2 \n\t" + "movq %%mm0, (%%edi,%%ebx,) \n\t" + "paddb %%mm3, %%mm2 \n\t" + "movq 16(%%esi,%%ebx,), %%mm5 \n\t" + "movq %%mm2, 8(%%edi,%%ebx,) \n\t" + "movq 16(%%edi,%%ebx,), %%mm4 \n\t" + "movq 24(%%esi,%%ebx,), %%mm7 \n\t" + "paddb %%mm5, %%mm4 \n\t" + "movq 24(%%edi,%%ebx,), %%mm6 \n\t" + "movq %%mm4, 16(%%edi,%%ebx,) \n\t" + "paddb %%mm7, %%mm6 \n\t" + "movq 32(%%esi,%%ebx,), %%mm1 \n\t" + "movq %%mm6, 24(%%edi,%%ebx,) \n\t" + "movq 32(%%edi,%%ebx,), %%mm0 \n\t" + "movq 40(%%esi,%%ebx,), %%mm3 \n\t" + "paddb %%mm1, %%mm0 \n\t" + "movq 40(%%edi,%%ebx,), %%mm2 \n\t" + "movq %%mm0, 32(%%edi,%%ebx,) \n\t" + "paddb %%mm3, %%mm2 \n\t" + "movq 48(%%esi,%%ebx,), %%mm5 \n\t" + "movq %%mm2, 40(%%edi,%%ebx,) \n\t" + "movq 48(%%edi,%%ebx,), %%mm4 \n\t" + "movq 56(%%esi,%%ebx,), %%mm7 \n\t" + "paddb %%mm5, %%mm4 \n\t" + "movq 56(%%edi,%%ebx,), %%mm6 \n\t" + "movq %%mm4, 48(%%edi,%%ebx,) \n\t" + "addl $64, %%ebx \n\t" + "paddb %%mm7, %%mm6 \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movq %%mm6, -8(%%edi,%%ebx,) \n\t" /* (+56)movq does not affect flags; */ + "jb up_loop \n\t" /* -8 to offset addl ebx */ + + "cmpl $0, %%edx \n\t" /* test for bytes over mult of 64 */ + "jz up_end \n\t" + + "cmpl $8, %%edx \n\t" /* test for less than 8 bytes */ + "jb up_lt8 \n\t" /* [added by lcreeve@netins.net] */ + + "addl %%edx, %%ecx \n\t" + "andl $0x00000007, %%edx \n\t" /* calc bytes over mult of 8 */ + "subl %%edx, %%ecx \n\t" /* drop over bytes from length */ + "jz up_lt8 \n\t" + + "up_lpA: \n\t" /* use MMX regs to update 8 bytes sim. */ + "movq (%%esi,%%ebx,), %%mm1 \n\t" + "movq (%%edi,%%ebx,), %%mm0 \n\t" + "addl $8, %%ebx \n\t" + "paddb %%mm1, %%mm0 \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movq %%mm0, -8(%%edi,%%ebx,) \n\t" /* movq does not affect flags; -8 to */ + "jb up_lpA \n\t" /* offset add ebx */ + "cmpl $0, %%edx \n\t" /* test for bytes over mult of 8 */ + "jz up_end \n\t" + + "up_lt8: \n\t" + "xorl %%eax, %%eax \n\t" + "addl %%edx, %%ecx \n\t" /* move over byte count into counter */ + + "up_lp2: \n\t" /* use x86 regs for remaining bytes */ + "movb (%%edi,%%ebx,), %%al \n\t" + "addb (%%esi,%%ebx,), %%al \n\t" + "incl %%ebx \n\t" + "cmpl %%ecx, %%ebx \n\t" + "movb %%al, -1(%%edi,%%ebx,) \n\t" /* mov does not affect flags; -1 to */ + "jb up_lp2 \n\t" /* offset inc ebx */ + + "up_end: \n\t" + "EMMS \n\t" /* conversion of filtered row complete */ +#ifdef __PIC__ + "popl %%ebx \n\t" +#endif + + : "=d" (dummy_value_d), /* 0 // output regs (dummy) */ + "=S" (dummy_value_S), /* 1 */ + "=D" (dummy_value_D) /* 2 */ + + : "0" (len), /* edx // input regs */ + "1" (prev_row), /* esi */ + "2" (row) /* edi */ + + : "%eax", "%ecx" // clobber list (no input regs!) +#ifndef __PIC__ + , "%ebx" +#endif + +#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ + , "%mm0", "%mm1", "%mm2", "%mm3" + , "%mm4", "%mm5", "%mm6", "%mm7" +#endif + ); + +} /* end of png_read_filter_row_mmx_up() */ + +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + + + + +/*===========================================================================*/ +/* */ +/* P N G _ R E A D _ F I L T E R _ R O W */ +/* */ +/*===========================================================================*/ + + +/* Optimized png_read_filter_row routines */ + +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep + row, png_bytep prev_row, int filter) +{ +#ifdef PNG_DEBUG + char filnm[10]; +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* GRR: these are superseded by png_ptr->asm_flags: */ +#define UseMMX_sub 1 /* GRR: converted 20000730 */ +#define UseMMX_up 1 /* GRR: converted 20000729 */ +#define UseMMX_avg 1 /* GRR: converted 20000828 (+ 16-bit bugfix 20000916) */ +#define UseMMX_paeth 1 /* GRR: converted 20000828 */ + + if (_mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ +#if !defined(PNG_1_0_X) + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +#ifdef PNG_DEBUG + png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); + switch (filter) + { + case 0: sprintf(filnm, "none"); + break; + case 1: sprintf(filnm, "sub-%s", +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : +#endif +#endif +"x86"); + break; + case 2: sprintf(filnm, "up-%s", +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : +#endif +#endif + "x86"); + break; + case 3: sprintf(filnm, "avg-%s", +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : +#endif +#endif + "x86"); + break; + case 4: sprintf(filnm, "Paeth-%s", +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": +#endif +#endif +"x86"); + break; + default: sprintf(filnm, "unknw"); + break; + } + png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); + png_debug1(0, "row=0x%08lx, ", (unsigned long)row); + png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, + (int)((row_info->pixel_depth + 7) >> 3)); + png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); +#endif /* PNG_DEBUG */ + + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + + case PNG_FILTER_VALUE_SUB: +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_sub(row_info, row); + } + else +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + } /* end !UseMMX_sub */ + break; + + case PNG_FILTER_VALUE_UP: +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_up(row_info, row, prev_row); + } + else +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; ++i) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + } /* end !UseMMX_up */ + break; + + case PNG_FILTER_VALUE_AVG: +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_avg(row_info, row, prev_row); + } + else +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) >> 1)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++ + *lp++) >> 1)) & 0xff); + rp++; + } + } /* end !UseMMX_avg */ + break; + + case PNG_FILTER_VALUE_PAETH: +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (_mmx_supported) +#endif + { + png_read_filter_row_mmx_paeth(row_info, row, prev_row); + } + else +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + } /* end !UseMMX_paeth */ + break; + + default: + png_warning(png_ptr, "Ignoring bad row-filter type"); + *row=0; + break; + } +} + +#endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ + + +/*===========================================================================*/ +/* */ +/* P N G _ M M X _ S U P P O R T */ +/* */ +/*===========================================================================*/ + +/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) + * (2) all instructions compile with gcc 2.7.2.3 and later + * (3) the function is moved down here to prevent gcc from + * inlining it in multiple places and then barfing be- + * cause the ".NOT_SUPPORTED" label is multiply defined + * [is there a way to signal that a *single* function should + * not be inlined? is there a way to modify the label for + * each inlined instance, e.g., by appending _1, _2, etc.? + * maybe if don't use leading "." in label name? (nope...sigh)] + */ + +int PNGAPI +png_mmx_support(void) +{ +#if defined(PNG_MMX_CODE_SUPPORTED) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction + "pushl %%ecx \n\t" // so does ecx... + "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) +// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd +// "pushf \n\t" // 16-bit pushf + "pushfl \n\t" // save Eflag to stack + "popl %%eax \n\t" // get Eflag from stack into eax + "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx + "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) + "pushl %%eax \n\t" // save modified Eflag back to stack +// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd +// "popf \n\t" // 16-bit popf + "popfl \n\t" // restore modified value to Eflag reg + "pushfl \n\t" // save Eflag to stack + "popl %%eax \n\t" // get Eflag from stack + "pushl %%ecx \n\t" // save original Eflag to stack + "popfl \n\t" // restore original Eflag + "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag + "jz 0f \n\t" // if same, CPUID instr. is not supported + + "xorl %%eax, %%eax \n\t" // set eax to zero +// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) + "cpuid \n\t" // get the CPU identification info + "cmpl $1, %%eax \n\t" // make sure eax return non-zero value + "jl 0f \n\t" // if eax is zero, MMX is not supported + + "xorl %%eax, %%eax \n\t" // set eax to zero and... + "incl %%eax \n\t" // ...increment eax to 1. This pair is + // faster than the instruction "mov eax, 1" + "cpuid \n\t" // get the CPU identification info again + "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) + "cmpl $0, %%edx \n\t" // 0 = MMX not supported + "jz 0f \n\t" // non-zero = yes, MMX IS supported + + "movl $1, %%eax \n\t" // set return value to 1 + "jmp 1f \n\t" // DONE: have MMX support + + "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions + "movl $0, %%eax \n\t" // set return value to 0 + "1: \n\t" // .RETURN: target label for jump instructions + "movl %%eax, _mmx_supported \n\t" // save in global static variable, too + "popl %%edx \n\t" // restore edx + "popl %%ecx \n\t" // restore ecx + "popl %%ebx \n\t" // restore ebx + +// "ret \n\t" // DONE: no MMX support + // (fall through to standard C "ret") + + : // output list (none) + + : // any variables used on input (none) + + : "%eax" // clobber list +// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually +// , "memory" // if write to a variable gcc thought was in a reg +// , "cc" // "condition codes" (flag bits) + ); +#else + _mmx_supported = 0; +#endif /* PNG_MMX_CODE_SUPPORTED */ + + return _mmx_supported; +} + + +#endif /* PNG_USE_PNGGCCRD */ diff --git a/Source/3rd Party/wx/src/png/pngget.c b/Source/3rd Party/wx/src/png/pngget.c index aca63a958..1d1cc218b 100644 --- a/Source/3rd Party/wx/src/png/pngget.c +++ b/Source/3rd Party/wx/src/png/pngget.c @@ -1,833 +1,610 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.1 [March 28, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * */ -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#define PNG_INTERNAL +#include "png.h" png_uint_32 PNGAPI -png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 flag) +png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->valid & flag); - - return(0); + else + return(0); } -png_size_t PNGAPI -png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_uint_32 PNGAPI +png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->rowbytes); - - return(0); + else + return(0); } -#ifdef PNG_INFO_IMAGE_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) png_bytepp PNGAPI -png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_rows(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->row_pointers); - - return(0); + else + return(0); } #endif #ifdef PNG_EASY_ACCESS_SUPPORTED -/* Easy access to info, added in libpng-0.99 */ +/* easy access to info, added in libpng-0.99 */ png_uint_32 PNGAPI -png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_image_width(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->width; - + } return (0); } png_uint_32 PNGAPI -png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_image_height(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->height; - + } return (0); } png_byte PNGAPI -png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->bit_depth; - + } return (0); } png_byte PNGAPI -png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_color_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->color_type; - + } return (0); } png_byte PNGAPI -png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_filter_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->filter_type; - + } return (0); } png_byte PNGAPI -png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->interlace_type; - + } return (0); } png_byte PNGAPI -png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_compression_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + { return info_ptr->compression_type; - - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function", - "png_get_x_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) - return (info_ptr->x_pixels_per_unit); - } -#endif - - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function", - "png_get_y_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) - return (info_ptr->y_pixels_per_unit); } -#endif - return (0); } png_uint_32 PNGAPI -png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && - info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) - return (info_ptr->x_pixels_per_unit); + png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->x_pixels_per_unit); } +#else + return (0); #endif + return (0); +} +png_uint_32 PNGAPI +png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->y_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +png_uint_32 PNGAPI +png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || + info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) + return (0); + else return (info_ptr->x_pixels_per_unit); + } +#else + return (0); +#endif return (0); } #ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_READ_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) +png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) { - png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); - - if (info_ptr->x_pixels_per_unit != 0) + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); + if (info_ptr->x_pixels_per_unit == 0) + return ((float)0.0); + else return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); + /(float)info_ptr->x_pixels_per_unit)); } #else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) + return (0.0); #endif - return ((float)0.0); } #endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_fixed_point PNGAPI -png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) +png_int_32 PNGAPI +png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) { -#ifdef PNG_READ_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) - && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 - && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX - && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) { - png_fixed_point res; - - png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); - - /* The following casts work because a PNG 4 byte integer only has a valid - * range of 0..2^31-1; otherwise the cast might overflow. - */ - if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, - (png_int_32)info_ptr->x_pixels_per_unit)) - return res; + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->x_offset); } #else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) + return (0); #endif - - return 0; -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) - return (info_ptr->x_offset); - } -#endif - return (0); } png_int_32 PNGAPI -png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) { -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) - return (info_ptr->y_offset); + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->y_offset); } -#endif - - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) - return (info_ptr->x_offset); - } -#endif - - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) - return (info_ptr->y_offset); - } -#endif - - return (0); -} - -#ifdef PNG_INCH_CONVERSIONS_SUPPORTED -static png_uint_32 -ppi_from_ppm(png_uint_32 ppm) -{ -#if 0 - /* The conversion is *(2.54/100), in binary (32 digits): - * .00000110100000001001110101001001 - */ - png_uint_32 t1001, t1101; - ppm >>= 1; /* .1 */ - t1001 = ppm + (ppm >> 3); /* .1001 */ - t1101 = t1001 + (ppm >> 1); /* .1101 */ - ppm >>= 20; /* .000000000000000000001 */ - t1101 += t1101 >> 15; /* .1101000000000001101 */ - t1001 >>= 11; /* .000000000001001 */ - t1001 += t1001 >> 12; /* .000000000001001000000001001 */ - ppm += t1001; /* .000000000001001000001001001 */ - ppm += t1101; /* .110100000001001110101001001 */ - return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ #else - /* The argument is a PNG unsigned integer, so it is not permitted - * to be bigger than 2^31. - */ - png_fixed_point result; - if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, - 5000)) - return result; - - /* Overflow. */ - return 0; + return (0); #endif + return (0); +} + +png_int_32 PNGAPI +png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->x_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->y_offset); + } +#else + return (0); +#endif + return (0); +} + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +png_uint_32 PNGAPI +png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); } png_uint_32 PNGAPI -png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { - return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); + return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); } png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { - return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); + return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); } -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); -} - -#ifdef PNG_FIXED_POINT_SUPPORTED -static png_fixed_point -png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) -{ - /* Convert from metres * 1,000,000 to inches * 100,000, meters to - * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. - * Notice that this can overflow - a warning is output and 0 is - * returned. - */ - return png_muldiv_warn(png_ptr, microns, 500, 127); -} - -png_fixed_point PNGAPI -png_get_x_offset_inches_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) -{ - return png_fixed_inches_from_microns(png_ptr, - png_get_x_offset_microns(png_ptr, info_ptr)); -} -#endif - -#ifdef PNG_FIXED_POINT_SUPPORTED -png_fixed_point PNGAPI -png_get_y_offset_inches_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) -{ - return png_fixed_inches_from_microns(png_ptr, - png_get_y_offset_microns(png_ptr, info_ptr)); -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) { - /* To avoid the overflow do the conversion directly in floating - * point. - */ - return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); + return ((float)png_get_x_offset_microns(png_ptr, info_ptr) + *.00003937); } -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) { - /* To avoid the overflow do the conversion directly in floating - * point. - */ - return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); + return ((float)png_get_y_offset_microns(png_ptr, info_ptr) + *.00003937); } -#endif -#ifdef PNG_pHYs_SUPPORTED +#if defined(PNG_pHYs_SUPPORTED) png_uint_32 PNGAPI -png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function", "pHYs"); - + png_debug1(1, "in %s retrieval function\n", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } - if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } - if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; - - if (*unit_type == 1) + if(*unit_type == 1) { if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); } } } - return (retval); } #endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ /* png_get_channels really belongs in here, too, but it's been around longer */ #endif /* PNG_EASY_ACCESS_SUPPORTED */ - png_byte PNGAPI -png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_get_channels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->channels); - - return (0); + else + return (0); } -#ifdef PNG_READ_SUPPORTED -png_const_bytep PNGAPI -png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) +png_bytep PNGAPI +png_get_signature(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->signature); - - return (NULL); + else + return (NULL); } -#endif -#ifdef PNG_bKGD_SUPPORTED +#if defined(PNG_bKGD_SUPPORTED) png_uint_32 PNGAPI -png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, +png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) + && background != NULL) { - png_debug1(1, "in %s retrieval function", "bKGD"); - + png_debug1(1, "in %s retrieval function\n", "bKGD"); *background = &(info_ptr->background); return (PNG_INFO_bKGD); } - return (0); } #endif -#ifdef PNG_cHRM_SUPPORTED -/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the - * same time to correct the rgb grayscale coefficient defaults obtained from the - * cHRM chunk in 1.5.4 - */ -# ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) +png_get_cHRM(png_structp png_ptr, png_infop info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y) { - /* Quiet API change: this code used to only return the end points if a cHRM - * chunk was present, but the end points can also come from iCCP or sRGB - * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and - * the png_set_ APIs merely check that set end points are mutually - * consistent. - */ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function", "cHRM"); - + png_debug1(1, "in %s retrieval function\n", "cHRM"); if (white_x != NULL) - *white_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); + *white_x = (double)info_ptr->x_white; if (white_y != NULL) - *white_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); + *white_y = (double)info_ptr->y_white; if (red_x != NULL) - *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, - "cHRM red X"); + *red_x = (double)info_ptr->x_red; if (red_y != NULL) - *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, - "cHRM red Y"); + *red_y = (double)info_ptr->y_red; if (green_x != NULL) - *green_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); + *green_x = (double)info_ptr->x_green; if (green_y != NULL) - *green_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); + *green_y = (double)info_ptr->y_green; if (blue_x != NULL) - *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, - "cHRM blue X"); + *blue_x = (double)info_ptr->x_blue; if (blue_y != NULL) - *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, - "cHRM blue Y"); + *blue_y = (double)info_ptr->y_blue; return (PNG_INFO_cHRM); } - return (0); } - +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *red_X, double *red_Y, double *red_Z, double *green_X, - double *green_Y, double *green_Z, double *blue_X, double *blue_Y, - double *blue_Z) +png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, + png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y) { - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) - { - png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); - - if (red_X != NULL) - *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, - "cHRM red X"); - if (red_Y != NULL) - *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, - "cHRM red Y"); - if (red_Z != NULL) - *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, - "cHRM red Z"); - if (green_X != NULL) - *green_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); - if (green_Y != NULL) - *green_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); - if (green_Z != NULL) - *green_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); - if (blue_X != NULL) - *blue_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); - if (blue_Y != NULL) - *blue_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); - if (blue_Z != NULL) - *blue_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); - return (PNG_INFO_cHRM); - } - - return (0); -} -# endif - -# ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) - { - png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); - - if (int_red_X != NULL) - *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; - if (int_red_Y != NULL) - *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; - if (int_red_Z != NULL) - *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; - if (int_green_X != NULL) - *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; - if (int_green_Y != NULL) - *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; - if (int_green_Z != NULL) - *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; - if (int_blue_X != NULL) - *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; - if (int_blue_Y != NULL) - *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; - if (int_blue_Z != NULL) - *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; - return (PNG_INFO_cHRM); - } - - return (0); -} - -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - png_debug1(1, "in %s retrieval function", "cHRM"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { + png_debug1(1, "in %s retrieval function\n", "cHRM"); if (white_x != NULL) - *white_x = info_ptr->colorspace.end_points_xy.whitex; + *white_x = info_ptr->int_x_white; if (white_y != NULL) - *white_y = info_ptr->colorspace.end_points_xy.whitey; + *white_y = info_ptr->int_y_white; if (red_x != NULL) - *red_x = info_ptr->colorspace.end_points_xy.redx; + *red_x = info_ptr->int_x_red; if (red_y != NULL) - *red_y = info_ptr->colorspace.end_points_xy.redy; + *red_y = info_ptr->int_y_red; if (green_x != NULL) - *green_x = info_ptr->colorspace.end_points_xy.greenx; + *green_x = info_ptr->int_x_green; if (green_y != NULL) - *green_y = info_ptr->colorspace.end_points_xy.greeny; + *green_y = info_ptr->int_y_green; if (blue_x != NULL) - *blue_x = info_ptr->colorspace.end_points_xy.bluex; + *blue_x = info_ptr->int_x_blue; if (blue_y != NULL) - *blue_y = info_ptr->colorspace.end_points_xy.bluey; + *blue_y = info_ptr->int_y_blue; return (PNG_INFO_cHRM); } - return (0); } -# endif +#endif #endif -#ifdef PNG_gAMA_SUPPORTED -# ifdef PNG_FIXED_POINT_SUPPORTED +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *file_gamma) +png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) { - png_debug1(1, "in %s retrieval function", "gAMA"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && - file_gamma != NULL) + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && file_gamma != NULL) { - *file_gamma = info_ptr->colorspace.gamma; + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *file_gamma = (double)info_ptr->gamma; return (PNG_INFO_gAMA); } - return (0); } -# endif - -# ifdef PNG_FLOATING_POINT_SUPPORTED +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *file_gamma) +png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *int_file_gamma) { - png_debug1(1, "in %s retrieval function", "gAMA(float)"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && - file_gamma != NULL) + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && int_file_gamma != NULL) { - *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, - "png_get_gAMA"); + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *int_file_gamma = info_ptr->int_gamma; return (PNG_INFO_gAMA); } - return (0); } -# endif +#endif #endif -#ifdef PNG_sRGB_SUPPORTED +#if defined(PNG_sRGB_SUPPORTED) png_uint_32 PNGAPI -png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *file_srgb_intent) +png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) { - png_debug1(1, "in %s retrieval function", "sRGB"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) + && file_srgb_intent != NULL) { - *file_srgb_intent = info_ptr->colorspace.rendering_intent; + png_debug1(1, "in %s retrieval function\n", "sRGB"); + *file_srgb_intent = (int)info_ptr->srgb_intent; return (PNG_INFO_sRGB); } - return (0); } #endif -#ifdef PNG_iCCP_SUPPORTED +#if defined(PNG_iCCP_SUPPORTED) png_uint_32 PNGAPI -png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, - png_charpp name, int *compression_type, - png_bytepp profile, png_uint_32 *proflen) +png_get_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen) { - png_debug1(1, "in %s retrieval function", "iCCP"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && compression_type != NULL && profile != NULL && - proflen != NULL) + && name != NULL && profile != NULL && proflen != NULL) { + png_debug1(1, "in %s retrieval function\n", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; - *proflen = png_get_uint_32(info_ptr->iccp_profile); - /* This is somewhat irrelevant since the profile data returned has - * actually been uncompressed. - */ - *compression_type = PNG_COMPRESSION_TYPE_BASE; + /* compression_type is a dummy so the API won't have to change + if we introduce multiple compression types later. */ + *proflen = (int)info_ptr->iccp_proflen; + *compression_type = (int)info_ptr->iccp_compression; return (PNG_INFO_iCCP); } - return (0); } #endif -#ifdef PNG_sPLT_SUPPORTED -int PNGAPI -png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, - png_sPLT_tpp spalettes) +#if defined(PNG_sPLT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sPLT(png_structp png_ptr, png_infop info_ptr, + png_sPLT_tpp spalettes) { if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - { - *spalettes = info_ptr->splt_palettes; - return info_ptr->splt_palettes_num; - } - - return (0); + *spalettes = info_ptr->splt_palettes; + return ((png_uint_32)info_ptr->splt_palettes_num); } #endif -#ifdef PNG_hIST_SUPPORTED +#if defined(PNG_hIST_SUPPORTED) png_uint_32 PNGAPI -png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_16p *hist) +png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) { - png_debug1(1, "in %s retrieval function", "hIST"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) + && hist != NULL) { + png_debug1(1, "in %s retrieval function\n", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } - return (0); } #endif png_uint_32 PNGAPI -png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) +png_get_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, + int *color_type, int *interlace_type, int *compression_type, + int *filter_type) + { - png_debug1(1, "in %s retrieval function", "IHDR"); + if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && + bit_depth != NULL && color_type != NULL) + { + png_debug1(1, "in %s retrieval function\n", "IHDR"); + *width = info_ptr->width; + *height = info_ptr->height; + *bit_depth = info_ptr->bit_depth; + if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) + png_error(png_ptr, "Invalid bit depth"); + *color_type = info_ptr->color_type; + if (info_ptr->color_type > 6) + png_error(png_ptr, "Invalid color type"); + if (compression_type != NULL) + *compression_type = info_ptr->compression_type; + if (filter_type != NULL) + *filter_type = info_ptr->filter_type; + if (interlace_type != NULL) + *interlace_type = info_ptr->interlace_type; - if (png_ptr == NULL || info_ptr == NULL || width == NULL || - height == NULL || bit_depth == NULL || color_type == NULL) - return (0); - - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - *color_type = info_ptr->color_type; - - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* This is redundant if we can be sure that the info_ptr values were all - * assigned in png_set_IHDR(). We do the check anyhow in case an - * application has ignored our advice not to mess with the members - * of info_ptr directly. - */ - png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, - info_ptr->compression_type, info_ptr->filter_type); - - return (1); + /* check for potential overflow of rowbytes */ + if (width == 0 || *width > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image width"); + if (height == 0 || *height > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image height"); + if (info_ptr->width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + { + png_warning(png_ptr, + "Width too large for libpng to process image data."); + } + return (1); + } + return (0); } -#ifdef PNG_oFFs_SUPPORTED +#if defined(PNG_oFFs_SUPPORTED) png_uint_32 PNGAPI -png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) +png_get_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) { - png_debug1(1, "in %s retrieval function", "oFFs"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) + && offset_x != NULL && offset_y != NULL && unit_type != NULL) { + png_debug1(1, "in %s retrieval function\n", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; return (PNG_INFO_oFFs); } - return (0); } #endif -#ifdef PNG_pCAL_SUPPORTED +#if defined(PNG_pCAL_SUPPORTED) png_uint_32 PNGAPI -png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) +png_get_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, + png_charp *units, png_charpp *params) { - png_debug1(1, "in %s retrieval function", "pCAL"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) + && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) { + png_debug1(1, "in %s retrieval function\n", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; @@ -837,341 +614,321 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, *params = info_ptr->pcal_params; return (PNG_INFO_pCAL); } - return (0); } #endif -#ifdef PNG_sCAL_SUPPORTED -# ifdef PNG_FIXED_POINT_SUPPORTED -# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - defined(PNG_FLOATING_POINT_SUPPORTED) +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, png_fixed_point *width, png_fixed_point *height) +png_get_sCAL(png_structp png_ptr, png_infop info_ptr, + int *unit, double *width, double *height) { - if (png_ptr != NULL && info_ptr != NULL && + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - /*TODO: make this work without FP support; the API is currently eliminated - * if neither floating point APIs nor internal floating point arithmetic - * are enabled. - */ - *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); - *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), - "sCAL height"); - return (PNG_INFO_sCAL); - } - - return(0); + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_pixel_width; + *height = info_ptr->scal_pixel_height; + return (PNG_INFO_sCAL); + } + return(0); } -# endif /* FLOATING_ARITHMETIC */ -# endif /* FIXED_POINT */ -# ifdef PNG_FLOATING_POINT_SUPPORTED +#else +#ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, double *width, double *height) +png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int *unit, png_charpp width, png_charpp height) { - if (png_ptr != NULL && info_ptr != NULL && + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = atof(info_ptr->scal_s_width); - *height = atof(info_ptr->scal_s_height); - return (PNG_INFO_sCAL); - } - - return(0); + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_s_width; + *height = info_ptr->scal_s_height; + return (PNG_INFO_sCAL); + } + return(0); } -# endif /* FLOATING POINT */ -png_uint_32 PNGAPI -png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } +#endif +#endif +#endif - return(0); -} -#endif /* sCAL */ - -#ifdef PNG_pHYs_SUPPORTED +#if defined(PNG_pHYs_SUPPORTED) png_uint_32 PNGAPI -png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +png_get_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; - png_debug1(1, "in %s retrieval function", "pHYs"); - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) + (info_ptr->valid & PNG_INFO_pHYs)) { + png_debug1(1, "in %s retrieval function\n", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } - if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } - if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; } } - return (retval); } -#endif /* pHYs */ +#endif png_uint_32 PNGAPI -png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, - png_colorp *palette, int *num_palette) +png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, + int *num_palette) { - png_debug1(1, "in %s retrieval function", "PLTE"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { + png_debug1(1, "in %s retrieval function\n", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d", *num_palette); + png_debug1(3, "num_palette = %d\n", *num_palette); return (PNG_INFO_PLTE); } - return (0); } -#ifdef PNG_sBIT_SUPPORTED +#if defined(PNG_sBIT_SUPPORTED) png_uint_32 PNGAPI -png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, - png_color_8p *sig_bit) +png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) { - png_debug1(1, "in %s retrieval function", "sBIT"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) + && sig_bit != NULL) { + png_debug1(1, "in %s retrieval function\n", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } - return (0); } #endif -#ifdef PNG_TEXT_SUPPORTED -int PNGAPI -png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, - png_textp *text_ptr, int *num_text) +#if defined(PNG_TEXT_SUPPORTED) +png_uint_32 PNGAPI +png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, + int *num_text) { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { - png_debug1(1, "in 0x%lx retrieval function", - (unsigned long)png_ptr->chunk_name); - + png_debug1(1, "in %s retrieval function\n", + (png_ptr->chunk_name[0] == '\0' ? "text" + : (png_const_charp)png_ptr->chunk_name)); if (text_ptr != NULL) *text_ptr = info_ptr->text; - if (num_text != NULL) *num_text = info_ptr->num_text; - - return info_ptr->num_text; + return ((png_uint_32)info_ptr->num_text); } - if (num_text != NULL) - *num_text = 0; - + *num_text = 0; return(0); } #endif -#ifdef PNG_tIME_SUPPORTED +#if defined(PNG_tIME_SUPPORTED) png_uint_32 PNGAPI -png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, - png_timep *mod_time) +png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) { - png_debug1(1, "in %s retrieval function", "tIME"); - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { + png_debug1(1, "in %s retrieval function\n", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } - return (0); } #endif -#ifdef PNG_tRNS_SUPPORTED +#if defined(PNG_tRNS_SUPPORTED) png_uint_32 PNGAPI -png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) +png_get_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep *trans, int *num_trans, png_color_16p *trans_values) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { - png_debug1(1, "in %s retrieval function", "tRNS"); - + png_debug1(1, "in %s retrieval function\n", "tRNS"); if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - if (trans_alpha != NULL) - { - *trans_alpha = info_ptr->trans_alpha; - retval |= PNG_INFO_tRNS; - } - - if (trans_color != NULL) - *trans_color = &(info_ptr->trans_color); + if (trans != NULL) + { + *trans = info_ptr->trans; + retval |= PNG_INFO_tRNS; + } + if (trans_values != NULL) + *trans_values = &(info_ptr->trans_values); } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ { - if (trans_color != NULL) - { - *trans_color = &(info_ptr->trans_color); - retval |= PNG_INFO_tRNS; - } - - if (trans_alpha != NULL) - *trans_alpha = NULL; + if (trans_values != NULL) + { + *trans_values = &(info_ptr->trans_values); + retval |= PNG_INFO_tRNS; + } + if(trans != NULL) + *trans = NULL; } - - if (num_trans != NULL) + if(num_trans != NULL) { *num_trans = info_ptr->num_trans; retval |= PNG_INFO_tRNS; } } - return (retval); } #endif -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -int PNGAPI -png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, - png_unknown_chunkpp unknowns) +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +png_uint_32 PNGAPI +png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, + png_unknown_chunkpp unknowns) { if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - { - *unknowns = info_ptr->unknown_chunks; - return info_ptr->unknown_chunks_num; - } - - return (0); + *unknowns = info_ptr->unknown_chunks; + return ((png_uint_32)info_ptr->unknown_chunks_num); } #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) png_byte PNGAPI -png_get_rgb_to_gray_status (png_const_structrp png_ptr) +png_get_rgb_to_gray_status (png_structp png_ptr) { - return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); + return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); } #endif -#ifdef PNG_USER_CHUNKS_SUPPORTED +#if defined(PNG_USER_CHUNKS_SUPPORTED) png_voidp PNGAPI -png_get_user_chunk_ptr(png_const_structrp png_ptr) +png_get_user_chunk_ptr(png_structp png_ptr) { - return (png_ptr ? png_ptr->user_chunk_ptr : NULL); + return (png_ptr? png_ptr->user_chunk_ptr : NULL); } #endif -png_size_t PNGAPI -png_get_compression_buffer_size(png_const_structrp png_ptr) +#ifdef PNG_WRITE_SUPPORTED +png_uint_32 PNGAPI +png_get_compression_buffer_size(png_structp png_ptr) { - if (png_ptr == NULL) - return 0; - -# ifdef PNG_WRITE_SUPPORTED - if (png_ptr->mode & PNG_IS_READ_STRUCT) -# endif - { -# ifdef PNG_SEQUENTIAL_READ_SUPPORTED - return png_ptr->IDAT_read_size; -# else - return PNG_IDAT_READ_SIZE; -# endif - } - -# ifdef PNG_WRITE_SUPPORTED - else - return png_ptr->zbuffer_size; -# endif + return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); } +#endif + +#ifndef PNG_1_0_X +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flags (png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); +} + +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flagmask (int flag_select) +{ + png_uint_32 settable_asm_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + /* no non-MMX flags yet */ + +#if 0 + /* GRR: no write-flags yet, either, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + return settable_asm_flags; /* _theoretically_ settable capabilities only */ +} +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_flagmask (int flag_select, int *compilerID) +{ + png_uint_32 settable_mmx_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; +#if 0 + /* GRR: no MMX write support yet, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + if (compilerID != NULL) { +#ifdef PNG_USE_PNGVCRD + *compilerID = 1; /* MSVC */ +#else +#ifdef PNG_USE_PNGGCCRD + *compilerID = 2; /* gcc/gas */ +#else + *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ +#endif +#endif + } + + return settable_mmx_flags; /* _theoretically_ settable capabilities only */ +} + +/* this function was added to libpng 1.2.0 */ +png_byte PNGAPI +png_get_mmx_bitdepth_threshold (png_structp png_ptr) +{ + return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); +} + +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_rowbytes_threshold (png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* These functions were added to libpng 1.2.6 and were enabled - * by default in libpng-1.4.0 */ +/* these functions were added to libpng 1.2.6 */ png_uint_32 PNGAPI -png_get_user_width_max (png_const_structrp png_ptr) +png_get_user_width_max (png_structp png_ptr) { - return (png_ptr ? png_ptr->user_width_max : 0); + return (png_ptr? png_ptr->user_width_max : 0); } - png_uint_32 PNGAPI -png_get_user_height_max (png_const_structrp png_ptr) +png_get_user_height_max (png_structp png_ptr) { - return (png_ptr ? png_ptr->user_height_max : 0); -} - -/* This function was added to libpng 1.4.0 */ -png_uint_32 PNGAPI -png_get_chunk_cache_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_chunk_cache_max : 0); -} - -/* This function was added to libpng 1.4.1 */ -png_alloc_size_t PNGAPI -png_get_chunk_malloc_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); + return (png_ptr? png_ptr->user_height_max : 0); } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -/* These functions were added to libpng 1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -png_uint_32 PNGAPI -png_get_io_state (png_const_structrp png_ptr) -{ - return png_ptr->io_state; -} - -png_uint_32 PNGAPI -png_get_io_chunk_type (png_const_structrp png_ptr) -{ - return png_ptr->chunk_name; -} -#endif /* ?PNG_IO_STATE_SUPPORTED */ - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -# ifdef PNG_GET_PALETTE_MAX_SUPPORTED -int PNGAPI -png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return png_ptr->num_palette_max; - - return (-1); -} -# endif -#endif - -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ +#endif /* ?PNG_1_0_X */ diff --git a/Source/3rd Party/wx/src/png/pnginfo.h b/Source/3rd Party/wx/src/png/pnginfo.h deleted file mode 100644 index 26bf26502..000000000 --- a/Source/3rd Party/wx/src/png/pnginfo.h +++ /dev/null @@ -1,260 +0,0 @@ - -/* pnginfo.h - header file for PNG reference library - * - * Copyright (c) 1998-2013 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Last changed in libpng 1.6.1 [March 28, 2013] - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - - /* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, using png_set_*() functions, then - * call png_write_info(). - * - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. In libpng-1.5.0 this was moved into a separate private - * file that is not visible to applications. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -#ifndef PNGINFO_H -#define PNGINFO_H - -struct png_info_def -{ - /* The following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_size_t rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following are set by png_set_IHDR, called from the application on - * write, but the are never actually used by the write code. - */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - -#ifdef PNG_READ_SUPPORTED - /* This is never set during write */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ -#endif - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) - /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are - * defined. When COLORSPACE is switched on all the colorspace-defining - * chunks should be enabled, when GAMMA is switched on all the gamma-defining - * chunks should be enabled. If this is not done it becomes possible to read - * inconsistent PNG files and assign a probably incorrect interpretation to - * the information. (In other words, by carefully choosing which chunks to - * recognize the system configuration can select an interpretation for PNG - * files containing ambiguous data and this will result in inconsistent - * behavior between different libpng builds!) - */ - png_colorspace colorspace; -#endif - -#ifdef PNG_iCCP_SUPPORTED - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_bytep iccp_profile; /* International Color Consortium profile data */ - png_uint_32 iccp_proflen; /* ICC profile data length */ -#endif - -#ifdef PNG_TEXT_SUPPORTED - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read or comments to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read or comments to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#ifdef PNG_tIME_SUPPORTED - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#ifdef PNG_sBIT_SUPPORTED - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans_alpha; /* alpha values for paletted image */ - png_color_16 trans_color; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#ifdef PNG_oFFs_SUPPORTED - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#ifdef PNG_pHYs_SUPPORTED - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#ifdef PNG_hIST_SUPPORTED - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_pCAL_SUPPORTED - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - /* Storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - - /* The type of this field is limited by the type of - * png_struct::user_chunk_cache_max, else overflow can occur. - */ - int unknown_chunks_num; -#endif - -#ifdef PNG_sPLT_SUPPORTED - /* Data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - int splt_palettes_num; /* Match type returned by png_get API */ -#endif - -#ifdef PNG_sCAL_SUPPORTED - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is - * non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif - -#ifdef PNG_INFO_IMAGE_SUPPORTED - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) - non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -}; -#endif /* PNGINFO_H */ diff --git a/Source/3rd Party/wx/src/png/pnglibconf.h b/Source/3rd Party/wx/src/png/pnglibconf.h deleted file mode 100644 index 013533309..000000000 --- a/Source/3rd Party/wx/src/png/pnglibconf.h +++ /dev/null @@ -1,453 +0,0 @@ -/* pnglibconf.h - library build configuration */ - -/* libpng version 1.6.2 - April 25, 2013 */ - -/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ - -/* This code is released under the libpng license. */ -/* For conditions of distribution and use, see the disclaimer */ -/* and license in png.h */ - -/* pnglibconf.h */ -/* Machine generated file: DO NOT EDIT */ -/* Derived from: scripts/pnglibconf.dfa */ -#ifndef PNGLCONF_H -#define PNGLCONF_H -/* options */ -#define PNG_16BIT_SUPPORTED -#define PNG_ALIGNED_MEMORY_SUPPORTED -/*#undef PNG_ARM_NEON_API_SUPPORTED*/ -/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ -/*#undef PNG_ARM_NEON_SUPPORTED*/ -#define PNG_BENIGN_ERRORS_SUPPORTED -#define PNG_BENIGN_READ_ERRORS_SUPPORTED -/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ -#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_COLORSPACE_SUPPORTED -#define PNG_CONSOLE_IO_SUPPORTED -#define PNG_CONVERT_tIME_SUPPORTED -#define PNG_EASY_ACCESS_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ -#define PNG_ERROR_TEXT_SUPPORTED -#define PNG_FIXED_POINT_SUPPORTED -#define PNG_FLOATING_ARITHMETIC_SUPPORTED -#define PNG_FLOATING_POINT_SUPPORTED -#define PNG_FORMAT_AFIRST_SUPPORTED -#define PNG_FORMAT_BGR_SUPPORTED -#define PNG_GAMMA_SUPPORTED -#define PNG_GET_PALETTE_MAX_SUPPORTED -#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -#define PNG_INCH_CONVERSIONS_SUPPORTED -#define PNG_INFO_IMAGE_SUPPORTED -#define PNG_IO_STATE_SUPPORTED -#define PNG_MNG_FEATURES_SUPPORTED -#define PNG_POINTER_INDEXING_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED -#define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_ALPHA_MODE_SUPPORTED -#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_READ_BACKGROUND_SUPPORTED -#define PNG_READ_BGR_SUPPORTED -#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED -#define PNG_READ_EXPAND_16_SUPPORTED -#define PNG_READ_EXPAND_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED -#define PNG_READ_GAMMA_SUPPORTED -#define PNG_READ_GET_PALETTE_MAX_SUPPORTED -#define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_INTERLACING_SUPPORTED -#define PNG_READ_INT_FUNCTIONS_SUPPORTED -#define PNG_READ_INVERT_ALPHA_SUPPORTED -#define PNG_READ_INVERT_SUPPORTED -#define PNG_READ_OPT_PLTE_SUPPORTED -#define PNG_READ_PACKSWAP_SUPPORTED -#define PNG_READ_PACK_SUPPORTED -#define PNG_READ_QUANTIZE_SUPPORTED -#define PNG_READ_RGB_TO_GRAY_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_SHIFT_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_SUPPORTED -#define PNG_READ_SWAP_ALPHA_SUPPORTED -#define PNG_READ_SWAP_SUPPORTED -#define PNG_READ_TEXT_SUPPORTED -#define PNG_READ_TRANSFORMS_SUPPORTED -#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_READ_USER_CHUNKS_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_READ_bKGD_SUPPORTED -#define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_gAMA_SUPPORTED -#define PNG_READ_hIST_SUPPORTED -#define PNG_READ_iCCP_SUPPORTED -#define PNG_READ_iTXt_SUPPORTED -#define PNG_READ_oFFs_SUPPORTED -#define PNG_READ_pCAL_SUPPORTED -#define PNG_READ_pHYs_SUPPORTED -#define PNG_READ_sBIT_SUPPORTED -#define PNG_READ_sCAL_SUPPORTED -#define PNG_READ_sPLT_SUPPORTED -#define PNG_READ_sRGB_SUPPORTED -#define PNG_READ_tEXt_SUPPORTED -#define PNG_READ_tIME_SUPPORTED -#define PNG_READ_tRNS_SUPPORTED -#define PNG_READ_zTXt_SUPPORTED -/*#undef PNG_SAFE_LIMITS_SUPPORTED*/ -#define PNG_SAVE_INT_32_SUPPORTED -#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED -#define PNG_SETJMP_SUPPORTED -#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -/*#undef PNG_SET_OPTION_SUPPORTED*/ -#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SET_USER_LIMITS_SUPPORTED -#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED -#define PNG_SIMPLIFIED_READ_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_SUPPORTED -#define PNG_STDIO_SUPPORTED -#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_TEXT_SUPPORTED -#define PNG_TIME_RFC1123_SUPPORTED -#define PNG_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_USER_CHUNKS_SUPPORTED -#define PNG_USER_LIMITS_SUPPORTED -#define PNG_USER_MEM_SUPPORTED -#define PNG_USER_TRANSFORM_INFO_SUPPORTED -#define PNG_USER_TRANSFORM_PTR_SUPPORTED -#define PNG_WARNINGS_SUPPORTED -#define PNG_WRITE_16BIT_SUPPORTED -#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_WRITE_BGR_SUPPORTED -#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -#define PNG_WRITE_FILLER_SUPPORTED -#define PNG_WRITE_FILTER_SUPPORTED -#define PNG_WRITE_FLUSH_SUPPORTED -#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED -#define PNG_WRITE_INTERLACING_SUPPORTED -#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED -#define PNG_WRITE_INVERT_ALPHA_SUPPORTED -#define PNG_WRITE_INVERT_SUPPORTED -#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED -#define PNG_WRITE_PACKSWAP_SUPPORTED -#define PNG_WRITE_PACK_SUPPORTED -#define PNG_WRITE_SHIFT_SUPPORTED -#define PNG_WRITE_SUPPORTED -#define PNG_WRITE_SWAP_ALPHA_SUPPORTED -#define PNG_WRITE_SWAP_SUPPORTED -#define PNG_WRITE_TEXT_SUPPORTED -#define PNG_WRITE_TRANSFORMS_SUPPORTED -#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_WRITE_USER_TRANSFORM_SUPPORTED -#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#define PNG_WRITE_bKGD_SUPPORTED -#define PNG_WRITE_cHRM_SUPPORTED -#define PNG_WRITE_gAMA_SUPPORTED -#define PNG_WRITE_hIST_SUPPORTED -#define PNG_WRITE_iCCP_SUPPORTED -#define PNG_WRITE_iTXt_SUPPORTED -#define PNG_WRITE_oFFs_SUPPORTED -#define PNG_WRITE_pCAL_SUPPORTED -#define PNG_WRITE_pHYs_SUPPORTED -#define PNG_WRITE_sBIT_SUPPORTED -#define PNG_WRITE_sCAL_SUPPORTED -#define PNG_WRITE_sPLT_SUPPORTED -#define PNG_WRITE_sRGB_SUPPORTED -#define PNG_WRITE_tEXt_SUPPORTED -#define PNG_WRITE_tIME_SUPPORTED -#define PNG_WRITE_tRNS_SUPPORTED -#define PNG_WRITE_zTXt_SUPPORTED -#define PNG_bKGD_SUPPORTED -#define PNG_cHRM_SUPPORTED -#define PNG_gAMA_SUPPORTED -#define PNG_hIST_SUPPORTED -#define PNG_iCCP_SUPPORTED -#define PNG_iTXt_SUPPORTED -#define PNG_oFFs_SUPPORTED -#define PNG_pCAL_SUPPORTED -#define PNG_pHYs_SUPPORTED -#define PNG_sBIT_SUPPORTED -#define PNG_sCAL_SUPPORTED -#define PNG_sPLT_SUPPORTED -#define PNG_sRGB_SUPPORTED -#define PNG_tEXt_SUPPORTED -#define PNG_tIME_SUPPORTED -#define PNG_tRNS_SUPPORTED -#define PNG_zTXt_SUPPORTED -/* end of options */ -/* settings */ -#define PNG_API_RULE 0 -#define PNG_CALLOC_SUPPORTED -#define PNG_COST_SHIFT 3 -#define PNG_DEFAULT_READ_MACROS 1 -#define PNG_GAMMA_THRESHOLD_FIXED 5000 -#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE -#define PNG_INFLATE_BUF_SIZE 1024 -#define PNG_MAX_GAMMA_8 11 -#define PNG_PREFIX wx_ -#define PNG_QUANTIZE_BLUE_BITS 5 -#define PNG_QUANTIZE_GREEN_BITS 5 -#define PNG_QUANTIZE_RED_BITS 5 -#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) -#define PNG_TEXT_Z_DEFAULT_STRATEGY 0 -#define PNG_WEIGHT_SHIFT 8 -#define PNG_ZBUF_SIZE 8192 -#define PNG_Z_DEFAULT_COMPRESSION (-1) -#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 -#define PNG_Z_DEFAULT_STRATEGY 1 -#define PNG_sCAL_PRECISION 5 -#define PNG_sRGB_PROFILE_CHECKS 2 -/* end of settings */ -#define png_access_version_number wx_png_access_version_number -#define png_benign_error wx_png_benign_error -#define png_build_grayscale_palette wx_png_build_grayscale_palette -#define png_calloc wx_png_calloc -#define png_chunk_benign_error wx_png_chunk_benign_error -#define png_chunk_error wx_png_chunk_error -#define png_chunk_warning wx_png_chunk_warning -#define png_convert_from_struct_tm wx_png_convert_from_struct_tm -#define png_convert_from_time_t wx_png_convert_from_time_t -#define png_convert_to_rfc1123 wx_png_convert_to_rfc1123 -#define png_convert_to_rfc1123_buffer wx_png_convert_to_rfc1123_buffer -#define png_create_info_struct wx_png_create_info_struct -#define png_create_read_struct wx_png_create_read_struct -#define png_create_read_struct_2 wx_png_create_read_struct_2 -#define png_create_write_struct wx_png_create_write_struct -#define png_create_write_struct_2 wx_png_create_write_struct_2 -#define png_data_freer wx_png_data_freer -#define png_destroy_info_struct wx_png_destroy_info_struct -#define png_destroy_read_struct wx_png_destroy_read_struct -#define png_destroy_write_struct wx_png_destroy_write_struct -#define png_error wx_png_error -#define png_free wx_png_free -#define png_free_data wx_png_free_data -#define png_free_default wx_png_free_default -#define png_get_IHDR wx_png_get_IHDR -#define png_get_PLTE wx_png_get_PLTE -#define png_get_bKGD wx_png_get_bKGD -#define png_get_bit_depth wx_png_get_bit_depth -#define png_get_cHRM wx_png_get_cHRM -#define png_get_cHRM_XYZ wx_png_get_cHRM_XYZ -#define png_get_cHRM_XYZ_fixed wx_png_get_cHRM_XYZ_fixed -#define png_get_cHRM_fixed wx_png_get_cHRM_fixed -#define png_get_channels wx_png_get_channels -#define png_get_chunk_cache_max wx_png_get_chunk_cache_max -#define png_get_chunk_malloc_max wx_png_get_chunk_malloc_max -#define png_get_color_type wx_png_get_color_type -#define png_get_compression_buffer_size wx_png_get_compression_buffer_size -#define png_get_compression_type wx_png_get_compression_type -#define png_get_copyright wx_png_get_copyright -#define png_get_current_pass_number wx_png_get_current_pass_number -#define png_get_current_row_number wx_png_get_current_row_number -#define png_get_error_ptr wx_png_get_error_ptr -#define png_get_filter_type wx_png_get_filter_type -#define png_get_gAMA wx_png_get_gAMA -#define png_get_gAMA_fixed wx_png_get_gAMA_fixed -#define png_get_hIST wx_png_get_hIST -#define png_get_header_ver wx_png_get_header_ver -#define png_get_header_version wx_png_get_header_version -#define png_get_iCCP wx_png_get_iCCP -#define png_get_image_height wx_png_get_image_height -#define png_get_image_width wx_png_get_image_width -#define png_get_int_32 wx_png_get_int_32 -#define png_get_interlace_type wx_png_get_interlace_type -#define png_get_io_chunk_type wx_png_get_io_chunk_type -#define png_get_io_ptr wx_png_get_io_ptr -#define png_get_io_state wx_png_get_io_state -#define png_get_libpng_ver wx_png_get_libpng_ver -#define png_get_mem_ptr wx_png_get_mem_ptr -#define png_get_oFFs wx_png_get_oFFs -#define png_get_pCAL wx_png_get_pCAL -#define png_get_pHYs wx_png_get_pHYs -#define png_get_pHYs_dpi wx_png_get_pHYs_dpi -#define png_get_palette_max wx_png_get_palette_max -#define png_get_pixel_aspect_ratio wx_png_get_pixel_aspect_ratio -#define png_get_pixel_aspect_ratio_fixed wx_png_get_pixel_aspect_ratio_fixed -#define png_get_pixels_per_inch wx_png_get_pixels_per_inch -#define png_get_pixels_per_meter wx_png_get_pixels_per_meter -#define png_get_progressive_ptr wx_png_get_progressive_ptr -#define png_get_rgb_to_gray_status wx_png_get_rgb_to_gray_status -#define png_get_rowbytes wx_png_get_rowbytes -#define png_get_rows wx_png_get_rows -#define png_get_sBIT wx_png_get_sBIT -#define png_get_sCAL wx_png_get_sCAL -#define png_get_sCAL_fixed wx_png_get_sCAL_fixed -#define png_get_sCAL_s wx_png_get_sCAL_s -#define png_get_sPLT wx_png_get_sPLT -#define png_get_sRGB wx_png_get_sRGB -#define png_get_signature wx_png_get_signature -#define png_get_tIME wx_png_get_tIME -#define png_get_tRNS wx_png_get_tRNS -#define png_get_text wx_png_get_text -#define png_get_uint_16 wx_png_get_uint_16 -#define png_get_uint_31 wx_png_get_uint_31 -#define png_get_uint_32 wx_png_get_uint_32 -#define png_get_unknown_chunks wx_png_get_unknown_chunks -#define png_get_user_chunk_ptr wx_png_get_user_chunk_ptr -#define png_get_user_height_max wx_png_get_user_height_max -#define png_get_user_transform_ptr wx_png_get_user_transform_ptr -#define png_get_user_width_max wx_png_get_user_width_max -#define png_get_valid wx_png_get_valid -#define png_get_x_offset_inches wx_png_get_x_offset_inches -#define png_get_x_offset_inches_fixed wx_png_get_x_offset_inches_fixed -#define png_get_x_offset_microns wx_png_get_x_offset_microns -#define png_get_x_offset_pixels wx_png_get_x_offset_pixels -#define png_get_x_pixels_per_inch wx_png_get_x_pixels_per_inch -#define png_get_x_pixels_per_meter wx_png_get_x_pixels_per_meter -#define png_get_y_offset_inches wx_png_get_y_offset_inches -#define png_get_y_offset_inches_fixed wx_png_get_y_offset_inches_fixed -#define png_get_y_offset_microns wx_png_get_y_offset_microns -#define png_get_y_offset_pixels wx_png_get_y_offset_pixels -#define png_get_y_pixels_per_inch wx_png_get_y_pixels_per_inch -#define png_get_y_pixels_per_meter wx_png_get_y_pixels_per_meter -#define png_handle_as_unknown wx_png_handle_as_unknown -#define png_image_begin_read_from_file wx_png_image_begin_read_from_file -#define png_image_begin_read_from_memory wx_png_image_begin_read_from_memory -#define png_image_begin_read_from_stdio wx_png_image_begin_read_from_stdio -#define png_image_finish_read wx_png_image_finish_read -#define png_image_free wx_png_image_free -#define png_image_write_to_file wx_png_image_write_to_file -#define png_image_write_to_stdio wx_png_image_write_to_stdio -#define png_info_init_3 wx_png_info_init_3 -#define png_init_io wx_png_init_io -#define png_longjmp wx_png_longjmp -#define png_malloc wx_png_malloc -#define png_malloc_default wx_png_malloc_default -#define png_malloc_warn wx_png_malloc_warn -#define png_permit_mng_features wx_png_permit_mng_features -#define png_process_data wx_png_process_data -#define png_process_data_pause wx_png_process_data_pause -#define png_process_data_skip wx_png_process_data_skip -#define png_progressive_combine_row wx_png_progressive_combine_row -#define png_read_end wx_png_read_end -#define png_read_image wx_png_read_image -#define png_read_info wx_png_read_info -#define png_read_png wx_png_read_png -#define png_read_row wx_png_read_row -#define png_read_rows wx_png_read_rows -#define png_read_update_info wx_png_read_update_info -#define png_reset_zstream wx_png_reset_zstream -#define png_save_int_32 wx_png_save_int_32 -#define png_save_uint_16 wx_png_save_uint_16 -#define png_save_uint_32 wx_png_save_uint_32 -#define png_set_IHDR wx_png_set_IHDR -#define png_set_PLTE wx_png_set_PLTE -#define png_set_add_alpha wx_png_set_add_alpha -#define png_set_alpha_mode wx_png_set_alpha_mode -#define png_set_alpha_mode_fixed wx_png_set_alpha_mode_fixed -#define png_set_bKGD wx_png_set_bKGD -#define png_set_background wx_png_set_background -#define png_set_background_fixed wx_png_set_background_fixed -#define png_set_benign_errors wx_png_set_benign_errors -#define png_set_bgr wx_png_set_bgr -#define png_set_cHRM wx_png_set_cHRM -#define png_set_cHRM_XYZ wx_png_set_cHRM_XYZ -#define png_set_cHRM_XYZ_fixed wx_png_set_cHRM_XYZ_fixed -#define png_set_cHRM_fixed wx_png_set_cHRM_fixed -#define png_set_check_for_invalid_index wx_png_set_check_for_invalid_index -#define png_set_chunk_cache_max wx_png_set_chunk_cache_max -#define png_set_chunk_malloc_max wx_png_set_chunk_malloc_max -#define png_set_compression_buffer_size wx_png_set_compression_buffer_size -#define png_set_compression_level wx_png_set_compression_level -#define png_set_compression_mem_level wx_png_set_compression_mem_level -#define png_set_compression_method wx_png_set_compression_method -#define png_set_compression_strategy wx_png_set_compression_strategy -#define png_set_compression_window_bits wx_png_set_compression_window_bits -#define png_set_crc_action wx_png_set_crc_action -#define png_set_error_fn wx_png_set_error_fn -#define png_set_expand wx_png_set_expand -#define png_set_expand_16 wx_png_set_expand_16 -#define png_set_expand_gray_1_2_4_to_8 wx_png_set_expand_gray_1_2_4_to_8 -#define png_set_filler wx_png_set_filler -#define png_set_filter wx_png_set_filter -#define png_set_filter_heuristics wx_png_set_filter_heuristics -#define png_set_filter_heuristics_fixed wx_png_set_filter_heuristics_fixed -#define png_set_flush wx_png_set_flush -#define png_set_gAMA wx_png_set_gAMA -#define png_set_gAMA_fixed wx_png_set_gAMA_fixed -#define png_set_gamma wx_png_set_gamma -#define png_set_gamma_fixed wx_png_set_gamma_fixed -#define png_set_gray_to_rgb wx_png_set_gray_to_rgb -#define png_set_hIST wx_png_set_hIST -#define png_set_iCCP wx_png_set_iCCP -#define png_set_interlace_handling wx_png_set_interlace_handling -#define png_set_invalid wx_png_set_invalid -#define png_set_invert_alpha wx_png_set_invert_alpha -#define png_set_invert_mono wx_png_set_invert_mono -#define png_set_keep_unknown_chunks wx_png_set_keep_unknown_chunks -#define png_set_longjmp_fn wx_png_set_longjmp_fn -#define png_set_mem_fn wx_png_set_mem_fn -#define png_set_oFFs wx_png_set_oFFs -#define png_set_pCAL wx_png_set_pCAL -#define png_set_pHYs wx_png_set_pHYs -#define png_set_packing wx_png_set_packing -#define png_set_packswap wx_png_set_packswap -#define png_set_palette_to_rgb wx_png_set_palette_to_rgb -#define png_set_progressive_read_fn wx_png_set_progressive_read_fn -#define png_set_quantize wx_png_set_quantize -#define png_set_read_fn wx_png_set_read_fn -#define png_set_read_status_fn wx_png_set_read_status_fn -#define png_set_read_user_chunk_fn wx_png_set_read_user_chunk_fn -#define png_set_read_user_transform_fn wx_png_set_read_user_transform_fn -#define png_set_rgb_to_gray wx_png_set_rgb_to_gray -#define png_set_rgb_to_gray_fixed wx_png_set_rgb_to_gray_fixed -#define png_set_rows wx_png_set_rows -#define png_set_sBIT wx_png_set_sBIT -#define png_set_sCAL wx_png_set_sCAL -#define png_set_sCAL_fixed wx_png_set_sCAL_fixed -#define png_set_sCAL_s wx_png_set_sCAL_s -#define png_set_sPLT wx_png_set_sPLT -#define png_set_sRGB wx_png_set_sRGB -#define png_set_sRGB_gAMA_and_cHRM wx_png_set_sRGB_gAMA_and_cHRM -#define png_set_scale_16 wx_png_set_scale_16 -#define png_set_shift wx_png_set_shift -#define png_set_sig_bytes wx_png_set_sig_bytes -#define png_set_strip_16 wx_png_set_strip_16 -#define png_set_strip_alpha wx_png_set_strip_alpha -#define png_set_swap wx_png_set_swap -#define png_set_swap_alpha wx_png_set_swap_alpha -#define png_set_tIME wx_png_set_tIME -#define png_set_tRNS wx_png_set_tRNS -#define png_set_tRNS_to_alpha wx_png_set_tRNS_to_alpha -#define png_set_text wx_png_set_text -#define png_set_text_compression_level wx_png_set_text_compression_level -#define png_set_text_compression_mem_level wx_png_set_text_compression_mem_level -#define png_set_text_compression_method wx_png_set_text_compression_method -#define png_set_text_compression_strategy wx_png_set_text_compression_strategy -#define png_set_text_compression_window_bits wx_png_set_text_compression_window_bits -#define png_set_unknown_chunk_location wx_png_set_unknown_chunk_location -#define png_set_unknown_chunks wx_png_set_unknown_chunks -#define png_set_user_limits wx_png_set_user_limits -#define png_set_user_transform_info wx_png_set_user_transform_info -#define png_set_write_fn wx_png_set_write_fn -#define png_set_write_status_fn wx_png_set_write_status_fn -#define png_set_write_user_transform_fn wx_png_set_write_user_transform_fn -#define png_sig_cmp wx_png_sig_cmp -#define png_start_read_image wx_png_start_read_image -#define png_warning wx_png_warning -#define png_write_chunk wx_png_write_chunk -#define png_write_chunk_data wx_png_write_chunk_data -#define png_write_chunk_end wx_png_write_chunk_end -#define png_write_chunk_start wx_png_write_chunk_start -#define png_write_end wx_png_write_end -#define png_write_flush wx_png_write_flush -#define png_write_image wx_png_write_image -#define png_write_info wx_png_write_info -#define png_write_info_before_PLTE wx_png_write_info_before_PLTE -#define png_write_png wx_png_write_png -#define png_write_row wx_png_write_row -#define png_write_rows wx_png_write_rows -#define png_write_sig wx_png_write_sig -#define wx_png_get_uint_32(buf) PNG_get_uint_32(buf) -#define wx_png_get_uint_16(buf) PNG_get_uint_16(buf) -#define wx_png_get_int_32(buf) PNG_get_int_32(buf) -#endif /* PNGLCONF_H */ diff --git a/Source/3rd Party/wx/src/png/pngmem.c b/Source/3rd Party/wx/src/png/pngmem.c index b9b3efb44..2682394ab 100644 --- a/Source/3rd Party/wx/src/png/pngmem.c +++ b/Source/3rd Party/wx/src/png/pngmem.c @@ -1,15 +1,12 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file provides a location for all memory allocation. Users who * need special memory handling are expected to supply replacement * functions for png_malloc() and png_free(), and to use @@ -17,232 +14,560 @@ * identify the replacement functions. */ -#include "pngpriv.h" +#define PNG_INTERNAL +#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Free a png_struct */ -void /* PRIVATE */ -png_destroy_png_struct(png_structrp png_ptr) +/* Borland DOS special memory handler */ +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* if you change this, be sure to change the one in png.h also */ + +/* Allocate memory for a png_struct. The malloc and memset can be replaced + by a single call to calloc() if this is thought to improve performance. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) { - if (png_ptr != NULL) - { - /* png_free might call png_error and may certainly call - * png_get_mem_ptr, so fake a temporary png_struct to support this. - */ - png_struct dummy_struct = *png_ptr; - memset(png_ptr, 0, (sizeof *png_ptr)); - png_free(&dummy_struct, png_ptr); +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} -# ifdef PNG_SETJMP_SUPPORTED - /* We may have a jmp_buf left to deallocate. */ - png_free_jmpbuf(&dummy_struct); -# endif +/* Alternate version of png_create_struct, for use with user-defined malloc. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = png_sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = png_sizeof(png_struct); + else + return (png_get_copyright(NULL)); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); + } + else +#endif /* PNG_USER_MEM_SUPPORTED */ + struct_ptr = (png_voidp)farmalloc(size); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ + farfree (struct_ptr); } } /* Allocate memory. For reasonable files, size should never exceed * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does + * it not to. See zconf.h and png.h for more information. zlib does * need to allocate exactly 64K, so whatever you call here must * have the ability to do that. + * + * Borland seems to have a problem in DOS mode for exactly 64K. + * It gives you a segment with an offset of 8 (perhaps to store its + * memory stuff). zlib doesn't like this at all, so we have to + * detect and deal with it. This code should not be needed in + * Windows or OS/2 modes, and only in 16 bit mode. This code has + * been updated by Alexander Lehmann for version 0.89 to waste less + * memory. + * + * Note that we can't use png_size_t for the "size" declaration, + * since on some systems a png_size_t is a 16-bit quantity, and as a + * result, we would be truncating potentially larger memory requests + * (which should cause a fatal error) and introducing major problems. */ -PNG_FUNCTION(png_voidp,PNGAPI -png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) { png_voidp ret; - ret = png_malloc(png_ptr, size); + if (png_ptr == NULL || size == 0) + return (NULL); - if (ret != NULL) - memset(ret, 0, size); - - return ret; -} - -/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of - * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED. - * Checking and error handling must happen outside this routine; it returns NULL - * if the allocation cannot be done (for any reason.) - */ -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) -{ - /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS - * allocators have also been removed in 1.6.0, so any 16-bit system now has - * to implement a user memory handler. This checks to be sure it isn't - * called with big numbers. - */ #ifdef PNG_USER_MEM_SUPPORTED - PNG_UNUSED(png_ptr) -#endif - if (size > 0 && size <= PNG_SIZE_MAX -# ifdef PNG_MAX_MALLOC_64K - && size <= 65536U -# endif - ) - { -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr != NULL && png_ptr->malloc_fn != NULL) - return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size); - - else -#endif - return malloc((size_t)size); /* checked for truncation above */ - } - + if(png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else - return NULL; + ret = (png_malloc_default(png_ptr, size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory!"); + return (ret); } -/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 - * that arises because of the checks in png_realloc_array that are repeated in - * png_malloc_array. - */ -static png_voidp -png_malloc_array_checked(png_const_structrp png_ptr, int nelements, - size_t element_size) -{ - png_alloc_size_t req = nelements; /* known to be > 0 */ - - if (req <= PNG_SIZE_MAX/element_size) - return png_malloc_base(png_ptr, req * element_size); - - /* The failure case when the request is too large */ - return NULL; -} - -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_malloc_array,(png_const_structrp png_ptr, int nelements, - size_t element_size),PNG_ALLOCATED) -{ - if (nelements <= 0 || element_size == 0) - png_error(png_ptr, "internal error: array alloc"); - - return png_malloc_array_checked(png_ptr, nelements, element_size); -} - -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, - int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) -{ - /* These are internal errors: */ - if (add_elements <= 0 || element_size == 0 || old_elements < 0 || - (old_array == NULL && old_elements > 0)) - png_error(png_ptr, "internal error: array realloc"); - - /* Check for overflow on the elements count (so the caller does not have to - * check.) - */ - if (add_elements <= INT_MAX - old_elements) - { - png_voidp new_array = png_malloc_array_checked(png_ptr, - old_elements+add_elements, element_size); - - if (new_array != NULL) - { - /* Because png_malloc_array worked the size calculations below cannot - * overflow. - */ - if (old_elements > 0) - memcpy(new_array, old_array, element_size*(unsigned)old_elements); - - memset((char*)new_array + element_size*(unsigned)old_elements, 0, - element_size*(unsigned)add_elements); - - return new_array; - } - } - - return NULL; /* error */ -} - -/* Various functions that have different error handling are derived from this. - * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate - * function png_malloc_default is also provided. - */ -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) { png_voidp ret; - - if (png_ptr == NULL) - return NULL; - - ret = png_malloc_base(png_ptr, size); - - if (ret == NULL) - png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */ - - return ret; -} - -#ifdef PNG_USER_MEM_SUPPORTED -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED PNG_DEPRECATED) -{ - png_voidp ret; - - if (png_ptr == NULL) - return NULL; - - /* Passing 'NULL' here bypasses the application provided memory handler. */ - ret = png_malloc_base(NULL/*use malloc*/, size); - - if (ret == NULL) - png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */ - - return ret; -} #endif /* PNG_USER_MEM_SUPPORTED */ -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will issue a png_warning and return NULL instead of issuing a - * png_error, if it fails to allocate the requested memory. - */ -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) -{ - if (png_ptr != NULL) +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) { - png_voidp ret = png_malloc_base(png_ptr, size); - - if (ret != NULL) - return ret; - - png_warning(png_ptr, "Out of memory"); + png_warning(png_ptr, "Cannot Allocate > 64K"); + ret = NULL; } + else +#endif - return NULL; + if (size != (size_t)size) + ret = NULL; + else if (size == (png_uint_32)65536L) + { + if (png_ptr->offset_table == NULL) + { + /* try to see if we need to do any of this fancy stuff */ + ret = farmalloc(size); + if (ret == NULL || ((png_size_t)ret & 0xffff)) + { + int num_blocks; + png_uint_32 total_size; + png_bytep table; + int i; + png_byte huge * hptr; + + if (ret != NULL) + { + farfree(ret); + ret = NULL; + } + + if(png_ptr->zlib_window_bits > 14) + num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); + else + num_blocks = 1; + if (png_ptr->zlib_mem_level >= 7) + num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); + else + num_blocks++; + + total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; + + table = farmalloc(total_size); + + if (table == NULL) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of Memory."); +#endif + return (NULL); + } + + if ((png_size_t)table & 0xfff0) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, + "Farmalloc didn't return normalized pointer"); + else + png_warning(png_ptr, + "Farmalloc didn't return normalized pointer"); +#endif + return (NULL); + } + + png_ptr->offset_table = table; + png_ptr->offset_table_ptr = farmalloc(num_blocks * + png_sizeof (png_bytep)); + + if (png_ptr->offset_table_ptr == NULL) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of memory."); +#endif + return (NULL); + } + + hptr = (png_byte huge *)table; + if ((png_size_t)hptr & 0xf) + { + hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); + hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ + } + for (i = 0; i < num_blocks; i++) + { + png_ptr->offset_table_ptr[i] = (png_bytep)hptr; + hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ + } + + png_ptr->offset_table_number = num_blocks; + png_ptr->offset_table_count = 0; + png_ptr->offset_table_count_free = 0; + } + } + + if (png_ptr->offset_table_count >= png_ptr->offset_table_number) + { +#ifndef PNG_USER_MEM_SUPPORTED + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ + else + png_warning(png_ptr, "Out of Memory."); +#endif + return (NULL); + } + + ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; + } + else + ret = farmalloc(size); + +#ifndef PNG_USER_MEM_SUPPORTED + if (ret == NULL) + { + if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ + else + png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ + } +#endif + + return (ret); } -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - * without taking any action. - */ +/* free a pointer allocated by png_malloc(). In the default + configuration, png_ptr is not used, but is passed in case it + is needed. If ptr is NULL, return without taking any action. */ void PNGAPI -png_free(png_const_structrp png_ptr, png_voidp ptr) +png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr->free_fn != NULL) - png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr); - - else - png_free_default(png_ptr, ptr); + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); } -PNG_FUNCTION(void,PNGAPI -png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + + if (png_ptr->offset_table != NULL) + { + int i; + + for (i = 0; i < png_ptr->offset_table_count; i++) + { + if (ptr == png_ptr->offset_table_ptr[i]) + { + ptr = NULL; + png_ptr->offset_table_count_free++; + break; + } + } + if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) + { + farfree(png_ptr->offset_table); + farfree(png_ptr->offset_table_ptr); + png_ptr->offset_table = NULL; + png_ptr->offset_table_ptr = NULL; + } + } + + if (ptr != NULL) + { + farfree(ptr); + } +} + +#else /* Not the Borland DOS special memory handler */ + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = png_sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = png_sizeof(png_struct); + else + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, size); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); + } +#endif /* PNG_USER_MEM_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(__FLAT__) + struct_ptr = (png_voidp)farmalloc(size); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + struct_ptr = (png_voidp)halloc(size,1); +# else + struct_ptr = (png_voidp)malloc(size); +# endif +#endif + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + + return (struct_ptr); +} + + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(struct_ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(struct_ptr); +# else + free(struct_ptr); +# endif +#endif + } +} + +/* Allocate memory. For reasonable files, size should never exceed + 64K. However, zlib may allocate more then 64K if you don't tell + it not to. See zconf.h and png.h for more information. zlib does + need to allocate exactly 64K, so whatever you call here must + have the ability to do that. */ + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr == NULL || size == 0) + return (NULL); + + if(png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + else + ret = (png_malloc_default(png_ptr, size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory!"); + return (ret); +} + +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; +#endif /* PNG_USER_MEM_SUPPORTED */ + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) + { +#ifndef PNG_USER_MEM_SUPPORTED + if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Cannot Allocate > 64K"); + else +#endif + return NULL; + } +#endif + + /* Check for overflow */ +#if defined(__TURBOC__) && !defined(__FLAT__) + if (size != (unsigned long)size) + ret = NULL; + else + ret = farmalloc(size); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + if (size != (unsigned long)size) + ret = NULL; + else + ret = halloc(size, 1); +# else + if (size != (size_t)size) + ret = NULL; + else + ret = malloc((size_t)size); +# endif +#endif + +#ifndef PNG_USER_MEM_SUPPORTED + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory"); +#endif + + return (ret); +} + +/* Free a pointer allocated by png_malloc(). If ptr is NULL, return + without taking any action. */ +void PNGAPI +png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); +} +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + #endif /* PNG_USER_MEM_SUPPORTED */ +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(ptr); +# else free(ptr); +# endif +#endif +} + +#endif /* Not Borland DOS special memory handler */ + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* This function was added at libpng version 1.2.3. The png_malloc_warn() + * function will set up png_malloc() to issue a png_warning and return NULL + * instead of issuing a png_error, if it fails to allocate the requested + * memory. + */ +png_voidp PNGAPI +png_malloc_warn(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ptr; + png_uint_32 save_flags=png_ptr->flags; + + png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); + png_ptr->flags=save_flags; + return(ptr); +} +#endif + +png_voidp PNGAPI +png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memcpy_check."); + + return(png_memcpy (s1, s2, size)); +} + +png_voidp PNGAPI +png_memset_check (png_structp png_ptr, png_voidp s1, int value, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memset_check."); + + return (png_memset (s1, value, size)); + } #ifdef PNG_USER_MEM_SUPPORTED @@ -250,15 +575,12 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) * of allocating and freeing memory. */ void PNGAPI -png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr +png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - if (png_ptr != NULL) - { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; - } + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; } /* This function returns a pointer to the mem_ptr associated with the user @@ -266,12 +588,8 @@ png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI -png_get_mem_ptr(png_const_structrp png_ptr) +png_get_mem_ptr(png_structp png_ptr) { - if (png_ptr == NULL) - return NULL; - - return png_ptr->mem_ptr; + return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngpread.c b/Source/3rd Party/wx/src/png/pngpread.c index f132ce600..bbf2e14ad 100644 --- a/Source/3rd Party/wx/src/png/pngpread.c +++ b/Source/3rd Party/wx/src/png/pngpread.c @@ -1,21 +1,19 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" +#define PNG_INTERNAL +#include "png.h" #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Push model modes */ +/* push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 #define PNG_READ_IDAT_MODE 2 @@ -27,12 +25,9 @@ #define PNG_ERROR_MODE 8 void PNGAPI -png_process_data(png_structrp png_ptr, png_inforp info_ptr, - png_bytep buffer, png_size_t buffer_size) +png_process_data(png_structp png_ptr, png_infop info_ptr, + png_bytep buffer, png_size_t buffer_size) { - if (png_ptr == NULL || info_ptr == NULL) - return; - png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) @@ -41,73 +36,12 @@ png_process_data(png_structrp png_ptr, png_inforp info_ptr, } } -png_size_t PNGAPI -png_process_data_pause(png_structrp png_ptr, int save) -{ - if (png_ptr != NULL) - { - /* It's easiest for the caller if we do the save, then the caller doesn't - * have to supply the same data again: - */ - if (save) - png_push_save_buffer(png_ptr); - else - { - /* This includes any pending saved bytes: */ - png_size_t remaining = png_ptr->buffer_size; - png_ptr->buffer_size = 0; - - /* So subtract the saved buffer size, unless all the data - * is actually 'saved', in which case we just return 0 - */ - if (png_ptr->save_buffer_size < remaining) - return remaining - png_ptr->save_buffer_size; - } - } - - return 0; -} - -png_uint_32 PNGAPI -png_process_data_skip(png_structrp png_ptr) -{ - png_uint_32 remaining = 0; - - if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE && - png_ptr->skip_length > 0) - { - /* At the end of png_process_data the buffer size must be 0 (see the loop - * above) so we can detect a broken call here: - */ - if (png_ptr->buffer_size != 0) - png_error(png_ptr, - "png_process_data_skip called inside png_process_data"); - - /* If is impossible for there to be a saved buffer at this point - - * otherwise we could not be in SKIP mode. This will also happen if - * png_process_skip is called inside png_process_data (but only very - * rarely.) - */ - if (png_ptr->save_buffer_size != 0) - png_error(png_ptr, "png_process_data_skip called with saved data"); - - remaining = png_ptr->skip_length; - png_ptr->skip_length = 0; - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - - return remaining; -} - /* What we do with the incoming data depends on what we were previously * doing before we ran out of data... */ void /* PRIVATE */ -png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) +png_process_some_data(png_structp png_ptr, png_infop info_ptr) { - if (png_ptr == NULL) - return; - switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: @@ -115,25 +49,42 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) png_push_read_sig(png_ptr, info_ptr); break; } - case PNG_READ_CHUNK_MODE: { png_push_read_chunk(png_ptr, info_ptr); break; } - case PNG_READ_IDAT_MODE: { png_push_read_IDAT(png_ptr); break; } - +#if defined(PNG_READ_tEXt_SUPPORTED) + case PNG_READ_tEXt_MODE: + { + png_push_read_tEXt(png_ptr, info_ptr); + break; + } +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + case PNG_READ_zTXt_MODE: + { + png_push_read_zTXt(png_ptr, info_ptr); + break; + } +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + case PNG_READ_iTXt_MODE: + { + png_push_read_iTXt(png_ptr, info_ptr); + break; + } +#endif case PNG_SKIP_MODE: { png_push_crc_finish(png_ptr); break; } - default: { png_ptr->buffer_size = 0; @@ -149,7 +100,7 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) * routine. */ void /* PRIVATE */ -png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) +png_push_read_sig(png_structp png_ptr, png_infop info_ptr) { png_size_t num_checked = png_ptr->sig_bytes, num_to_check = 8 - num_checked; @@ -160,15 +111,14 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) } png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); + num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { if (num_checked < 4 && png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) png_error(png_ptr, "Not a PNG file"); - else png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } @@ -182,13 +132,65 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) } void /* PRIVATE */ -png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) +png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) { - png_uint_32 chunk_name; -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; /* unknown handling method */ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; #endif - +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_USE_LOCAL_ARRAYS */ /* First we make sure we have enough data for the 4 byte chunk name * and the 4 byte chunk length before proceeding with decoding the * chunk data. To fully decode each of these chunks, we also make @@ -198,7 +200,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; - png_byte chunk_tag[4]; if (png_ptr->buffer_size < 8) { @@ -207,87 +208,57 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); - png_crc_read(png_ptr, chunk_tag, 4); - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); - png_check_chunk_name(png_ptr, png_ptr->chunk_name); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } - chunk_name = png_ptr->chunk_name; - - if (chunk_name == png_IDAT) + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) { - if (png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->mode |= PNG_HAVE_IDAT; - - if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_benign_error(png_ptr, "Too many IDATs found"); - } - - if (chunk_name == png_IHDR) - { - if (png_ptr->push_length != 13) - png_error(png_ptr, "Invalid IHDR length"); - if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); } - - else if (chunk_name == png_IEND) + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_ptr->process_mode = PNG_READ_DONE_MODE; png_push_have_end(png_ptr, info_ptr); } - #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep); - - if (chunk_name == png_PLTE) + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + } } - #endif - else if (chunk_name == png_PLTE) + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -296,239 +267,221 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) } png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); } - - else if (chunk_name == png_IDAT) + else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) { + /* If we reach an IDAT chunk, this means we have read all of the + * header chunks, and we can start reading the image (or if this + * is called after the image has been read - we have an error). + */ + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + { + if (png_ptr->push_length == 0) + return; + + if (png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); + } + png_ptr->idat_size = png_ptr->push_length; + png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->process_mode = PNG_READ_IDAT_MODE; png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = - (uInt) PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.next_out = png_ptr->row_buf; return; } - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (png_ptr->chunk_name == png_gAMA) +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_sBIT_SUPPORTED - else if (png_ptr->chunk_name == png_sBIT) +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_cHRM_SUPPORTED - else if (png_ptr->chunk_name == png_cHRM) +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_iCCP_SUPPORTED - else if (png_ptr->chunk_name == png_iCCP) +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); } #endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - - png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); + png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - - png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); + png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } - #endif -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - - png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); + png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); } - #endif else { @@ -537,64 +490,50 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) png_push_save_buffer(png_ptr); return; } - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; } void /* PRIVATE */ -png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip) +png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) { png_ptr->process_mode = PNG_SKIP_MODE; png_ptr->skip_length = skip; } void /* PRIVATE */ -png_push_crc_finish(png_structrp png_ptr) +png_push_crc_finish(png_structp png_ptr) { if (png_ptr->skip_length && png_ptr->save_buffer_size) { - png_size_t save_size = png_ptr->save_buffer_size; - png_uint_32 skip_length = png_ptr->skip_length; - - /* We want the smaller of 'skip_length' and 'save_buffer_size', but - * they are of different types and we don't know which variable has the - * fewest bits. Carefully select the smaller and cast it to the type of - * the larger - this cannot overflow. Do not cast in the following test - * - it will break on either 16 or 64 bit platforms. - */ - if (skip_length < save_size) - save_size = (png_size_t)skip_length; + png_size_t save_size; + if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) + save_size = (png_size_t)png_ptr->skip_length; else - skip_length = (png_uint_32)save_size; + save_size = png_ptr->save_buffer_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->skip_length -= skip_length; + png_ptr->skip_length -= save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } if (png_ptr->skip_length && png_ptr->current_buffer_size) { - png_size_t save_size = png_ptr->current_buffer_size; - png_uint_32 skip_length = png_ptr->skip_length; - - /* We want the smaller of 'skip_length' and 'current_buffer_size', here, - * the same problem exists as above and the same solution. - */ - if (skip_length < save_size) - save_size = (png_size_t)skip_length; + png_size_t save_size; + if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) + save_size = (png_size_t)png_ptr->skip_length; else - skip_length = (png_uint_32)save_size; + save_size = png_ptr->current_buffer_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->skip_length -= skip_length; + png_ptr->skip_length -= save_size; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -612,14 +551,11 @@ png_push_crc_finish(png_structrp png_ptr) } } -void PNGCBAPI +void PNGAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; - if (png_ptr == NULL) - return; - ptr = buffer; if (png_ptr->save_buffer_size) { @@ -627,11 +563,10 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) if (length < png_ptr->save_buffer_size) save_size = length; - else save_size = png_ptr->save_buffer_size; - memcpy(ptr, png_ptr->save_buffer_ptr, save_size); + png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); length -= save_size; ptr += save_size; png_ptr->buffer_size -= save_size; @@ -644,11 +579,10 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) if (length < png_ptr->current_buffer_size) save_size = length; - else save_size = png_ptr->current_buffer_size; - memcpy(ptr, png_ptr->current_buffer_ptr, save_size); + png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -656,54 +590,46 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) } void /* PRIVATE */ -png_push_save_buffer(png_structrp png_ptr) +png_push_save_buffer(png_structp png_ptr) { if (png_ptr->save_buffer_size) { if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) { - png_size_t i, istop; + png_size_t i,istop; png_bytep sp; png_bytep dp; istop = png_ptr->save_buffer_size; for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) + i < istop; i++, sp++, dp++) { *dp = *sp; } } } if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) + png_ptr->save_buffer_max) { png_size_t new_max; png_bytep old_buffer; - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) + if (png_ptr->save_buffer_size > PNG_SIZE_MAX - + (png_ptr->current_buffer_size + 256)) { - png_error(png_ptr, "Potential overflow of save_buffer"); + png_error(png_ptr, "Potential overflow of save_buffer"); } - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, - (png_size_t)new_max); - - if (png_ptr->save_buffer == NULL) - { - png_free(png_ptr, old_buffer); - png_error(png_ptr, "Insufficient memory for save_buffer"); - } - - memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, + (png_uint_32)new_max); + png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } if (png_ptr->current_buffer_size) { - memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, + png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); png_ptr->save_buffer_size += png_ptr->current_buffer_size; png_ptr->current_buffer_size = 0; @@ -713,7 +639,7 @@ png_push_save_buffer(png_structrp png_ptr) } void /* PRIVATE */ -png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, +png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length) { png_ptr->current_buffer = buffer; @@ -723,14 +649,15 @@ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, } void /* PRIVATE */ -png_push_read_IDAT(png_structrp png_ptr) +png_push_read_IDAT(png_structp png_ptr) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; - png_byte chunk_tag[4]; - /* TODO: this code can be commoned up with the same code in push_read */ if (png_ptr->buffer_size < 8) { png_push_save_buffer(png_ptr); @@ -738,73 +665,62 @@ png_push_read_IDAT(png_structrp png_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); - png_crc_read(png_ptr, chunk_tag, 4); - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - if (png_ptr->chunk_name != png_IDAT) + if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) { png_ptr->process_mode = PNG_READ_CHUNK_MODE; - - if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) png_error(png_ptr, "Not enough compressed data"); - return; } png_ptr->idat_size = png_ptr->push_length; } - if (png_ptr->idat_size && png_ptr->save_buffer_size) { - png_size_t save_size = png_ptr->save_buffer_size; - png_uint_32 idat_size = png_ptr->idat_size; - - /* We want the smaller of 'idat_size' and 'current_buffer_size', but they - * are of different types and we don't know which variable has the fewest - * bits. Carefully select the smaller and cast it to the type of the - * larger - this cannot overflow. Do not cast in the following test - it - * will break on either 16 or 64 bit platforms. - */ - if (idat_size < save_size) - save_size = (png_size_t)idat_size; + png_size_t save_size; + if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) + { + save_size = (png_size_t)png_ptr->idat_size; + /* check for overflow */ + if((png_uint_32)save_size != png_ptr->idat_size) + png_error(png_ptr, "save_size overflowed in pngpread"); + } else - idat_size = (png_uint_32)save_size; + save_size = png_ptr->save_buffer_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->idat_size -= idat_size; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); + png_ptr->idat_size -= save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } - if (png_ptr->idat_size && png_ptr->current_buffer_size) { - png_size_t save_size = png_ptr->current_buffer_size; - png_uint_32 idat_size = png_ptr->idat_size; - - /* We want the smaller of 'idat_size' and 'current_buffer_size', but they - * are of different types and we don't know which variable has the fewest - * bits. Carefully select the smaller and cast it to the type of the - * larger - this cannot overflow. - */ - if (idat_size < save_size) - save_size = (png_size_t)idat_size; + png_size_t save_size; + if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) + { + save_size = (png_size_t)png_ptr->idat_size; + /* check for overflow */ + if((png_uint_32)save_size != png_ptr->idat_size) + png_error(png_ptr, "save_size overflowed in pngpread"); + } else - idat_size = (png_uint_32)save_size; + save_size = png_ptr->current_buffer_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= idat_size; + png_ptr->idat_size -= save_size; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -820,170 +736,98 @@ png_push_read_IDAT(png_structrp png_ptr) png_crc_finish(png_ptr, 0); png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->zowner = 0; } } void /* PRIVATE */ -png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, +png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length) { - /* The caller checks for a non-zero buffer length. */ - if (!(buffer_length > 0) || buffer == NULL) - png_error(png_ptr, "No IDAT data (internal error)"); + int ret; + + if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) + png_error(png_ptr, "Extra compression data"); - /* This routine must process all the data it has been given - * before returning, calling the row callback as required to - * handle the uncompressed results. - */ png_ptr->zstream.next_in = buffer; - /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ png_ptr->zstream.avail_in = (uInt)buffer_length; - - /* Keep going until the decompressed data is all processed - * or the stream marked as finished. - */ - while (png_ptr->zstream.avail_in > 0 && - !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + for(;;) { - int ret; - - /* We have data for zlib, but we must check that zlib - * has someplace to put the results. It doesn't matter - * if we don't expect any results -- it may be the input - * data is just the LZ end code. - */ - if (!(png_ptr->zstream.avail_out > 0)) + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK) { - /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ - png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1); + if (ret == Z_STREAM_END) + { + if (png_ptr->zstream.avail_in) + png_error(png_ptr, "Extra compressed data"); + if (!(png_ptr->zstream.avail_out)) + { + png_push_process_row(png_ptr); + } + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + else if (ret == Z_BUF_ERROR) + break; + else + png_error(png_ptr, "Decompression Error"); + } + if (!(png_ptr->zstream.avail_out)) + { + if (( +#if defined(PNG_READ_INTERLACING_SUPPORTED) + png_ptr->interlaced && png_ptr->pass > 6) || + (!png_ptr->interlaced && +#endif + png_ptr->row_number == png_ptr->num_rows)) + { + if (png_ptr->zstream.avail_in) + png_warning(png_ptr, "Too much data in IDAT chunks"); + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + png_push_process_row(png_ptr); + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.next_out = png_ptr->row_buf; } - - /* Using Z_SYNC_FLUSH here means that an unterminated - * LZ stream (a stream with a missing end code) can still - * be handled, otherwise (Z_NO_FLUSH) a future zlib - * implementation might defer output and therefore - * change the current behavior (see comments in inflate.c - * for why this doesn't happen at present with zlib 1.2.5). - */ - ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH); - - /* Check for any failure before proceeding. */ - if (ret != Z_OK && ret != Z_STREAM_END) - { - /* Terminate the decompression. */ - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - png_ptr->zowner = 0; - - /* This may be a truncated stream (missing or - * damaged end code). Treat that as a warning. - */ - if (png_ptr->row_number >= png_ptr->num_rows || - png_ptr->pass > 6) - png_warning(png_ptr, "Truncated compressed data in IDAT"); - - else - png_error(png_ptr, "Decompression error in IDAT"); - - /* Skip the check on unprocessed input */ - return; - } - - /* Did inflate output any data? */ - if (png_ptr->zstream.next_out != png_ptr->row_buf) - { - /* Is this unexpected data after the last row? - * If it is, artificially terminate the LZ output - * here. - */ - if (png_ptr->row_number >= png_ptr->num_rows || - png_ptr->pass > 6) - { - /* Extra data. */ - png_warning(png_ptr, "Extra compressed data in IDAT"); - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - png_ptr->zowner = 0; - - /* Do no more processing; skip the unprocessed - * input check below. - */ - return; - } - - /* Do we have a complete row? */ - if (png_ptr->zstream.avail_out == 0) - png_push_process_row(png_ptr); - } - - /* And check for the end of the stream. */ - if (ret == Z_STREAM_END) - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + else + break; } - - /* All the data should have been processed, if anything - * is left at this point we have bytes of IDAT data - * after the zlib end code. - */ - if (png_ptr->zstream.avail_in > 0) - png_warning(png_ptr, "Extra compression data in IDAT"); } void /* PRIVATE */ -png_push_process_row(png_structrp png_ptr) +png_push_process_row(png_structp png_ptr) { - /* 1.5.6: row_info moved out of png_struct to a local here. */ - png_row_info row_info; + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ - row_info.color_type = png_ptr->color_type; - row_info.bit_depth = png_ptr->bit_depth; - row_info.channels = png_ptr->channels; - row_info.pixel_depth = png_ptr->pixel_depth; - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); - if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) - { - if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) - png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); - else - png_error(png_ptr, "bad adaptive filter value"); - } + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); - /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before - * 1.5.6, while the buffer really is this big in current versions of libpng - * it may not be in the future, so this was changed just to copy the - * interlaced row count: - */ - memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); -#ifdef PNG_READ_TRANSFORMS_SUPPORTED if (png_ptr->transformations) - png_do_read_transformations(png_ptr, &row_info); -#endif + png_do_read_transformations(png_ptr); - /* The transformed pixel depth should match the depth now in row_info. */ - if (png_ptr->transformed_pixel_depth == 0) - { - png_ptr->transformed_pixel_depth = row_info.pixel_depth; - if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) - png_error(png_ptr, "progressive row overflow"); - } - - else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) - png_error(png_ptr, "internal progressive row size calculation error"); - - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Blow up interlaced rows to full size */ +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) - png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); switch (png_ptr->pass) { @@ -993,36 +837,31 @@ png_push_process_row(png_structrp png_ptr) for (i = 0; i < 8 && png_ptr->pass == 0; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ + png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ } - - if (png_ptr->pass == 2) /* Pass 1 might be empty */ + if (png_ptr->pass == 2) /* pass 1 might be empty */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } - if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } - if (png_ptr->pass == 6 && png_ptr->height <= 4) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - break; } - case 1: { int i; @@ -1031,123 +870,99 @@ png_push_process_row(png_structrp png_ptr) png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - - if (png_ptr->pass == 2) /* Skip top 4 generated rows */ + if (png_ptr->pass == 2) /* skip top 4 generated rows */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } - break; } - case 2: { int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - - if (png_ptr->pass == 4) /* Pass 3 might be empty */ + if (png_ptr->pass == 4) /* pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } - break; } - case 3: { int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - - if (png_ptr->pass == 4) /* Skip top two generated rows */ + if (png_ptr->pass == 4) /* skip top two generated rows */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } - break; } - case 4: { int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - - if (png_ptr->pass == 6) /* Pass 5 might be empty */ + if (png_ptr->pass == 6) /* pass 5 might be empty */ { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - break; } - case 5: { int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - - if (png_ptr->pass == 6) /* Skip top generated row */ + if (png_ptr->pass == 6) /* skip top generated row */ { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - break; } - - default: case 6: { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) break; - - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -1161,26 +976,31 @@ png_push_process_row(png_structrp png_ptr) } void /* PRIVATE */ -png_read_push_finish_row(png_structrp png_ptr) +png_read_push_finish_row(png_structp png_ptr) { -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + /* start of interlace block in the y direction */ + const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + /* offset to next interlace block in the y direction */ + const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + + /* Width of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h + const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; + */ /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h - static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; + const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ #endif @@ -1188,91 +1008,556 @@ png_read_push_finish_row(png_structrp png_ptr) if (png_ptr->row_number < png_ptr->num_rows) return; -#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - + png_memset_check(png_ptr, png_ptr->prev_row, 0, + png_ptr->rowbytes + 1); do { png_ptr->pass++; if ((png_ptr->pass == 1 && png_ptr->width < 5) || (png_ptr->pass == 3 && png_ptr->width < 3) || (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; + png_ptr->pass++; if (png_ptr->pass > 7) png_ptr->pass--; - if (png_ptr->pass >= 7) break; png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; if (png_ptr->transformations & PNG_INTERLACE) break; png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } -#endif /* PNG_READ_INTERLACING_SUPPORTED */ +} + +#if defined(PNG_READ_tEXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place tEXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + png_ptr->skip_length = 0; /* This may not be necessary */ + + if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + { + png_warning(png_ptr, "tEXt chunk too large to fit in memory"); + png_ptr->skip_length = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_tEXt_MODE; } void /* PRIVATE */ -png_push_have_info(png_structrp png_ptr, png_inforp info_ptr) +png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp text; + png_charp key; + int ret; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + +#if defined(PNG_MAX_MALLOC_64K) + if (png_ptr->skip_length) + return; +#endif + + key = png_ptr->current_text; + + for (text = key; *text; text++) + /* empty loop */ ; + + if (text != key + png_ptr->current_text_size) + text++; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; +#endif + text_ptr->text = text; + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + png_ptr->current_text = NULL; + + if (ret) + png_warning(png_ptr, "Insufficient memory to store text chunk."); + } +} +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place zTXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + /* We can't handle zTXt chunks > 64K, since we don't have enough space + * to be able to store the uncompressed data. Actually, the threshold + * is probably around 32K, but it isn't as definite as 64K is. + */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "zTXt chunk too large to fit in memory"); + png_push_crc_skip(png_ptr, length); + return; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_zTXt_MODE; +} + +void /* PRIVATE */ +png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp text; + png_charp key; + int ret; + png_size_t text_size, key_size; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + + key = png_ptr->current_text; + + for (text = key; *text; text++) + /* empty loop */ ; + + /* zTXt can't have zero text */ + if (text == key + png_ptr->current_text_size) + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + return; + } + + text++; + + if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + return; + } + + text++; + + png_ptr->zstream.next_in = (png_bytep )text; + png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - + (text - key)); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + key_size = text - key; + text_size = 0; + text = NULL; + ret = Z_STREAM_END; + + while (png_ptr->zstream.avail_in) + { + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK && ret != Z_STREAM_END) + { + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + png_ptr->current_text = NULL; + png_free(png_ptr, key); + png_free(png_ptr, text); + return; + } + if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) + { + if (text == NULL) + { + text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + + key_size + 1)); + png_memcpy(text + key_size, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_memcpy(text, key, key_size); + text_size = key_size + png_ptr->zbuf_size - + png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; + } + else + { + png_charp tmp; + + tmp = text; + text = (png_charp)png_malloc(png_ptr, text_size + + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + + 1)); + png_memcpy(text, tmp, text_size); + png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; + } + if (ret != Z_STREAM_END) + { + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + else + { + break; + } + + if (ret == Z_STREAM_END) + break; + } + + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + if (ret != Z_STREAM_END) + { + png_ptr->current_text = NULL; + png_free(png_ptr, key); + png_free(png_ptr, text); + return; + } + + png_ptr->current_text = NULL; + png_free(png_ptr, key); + key = text; + text += key_size; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; +#endif + text_ptr->text = text; + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + + if (ret) + png_warning(png_ptr, "Insufficient memory to store text chunk."); + } +} +#endif + +#if defined(PNG_READ_iTXt_SUPPORTED) +void /* PRIVATE */ +png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) + { + png_error(png_ptr, "Out of place iTXt"); + /* to quiet some compiler warnings */ + if(info_ptr == NULL) return; + } + +#ifdef PNG_MAX_MALLOC_64K + png_ptr->skip_length = 0; /* This may not be necessary */ + + if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + { + png_warning(png_ptr, "iTXt chunk too large to fit in memory"); + png_ptr->skip_length = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_ptr->current_text = (png_charp)png_malloc(png_ptr, + (png_uint_32)(length+1)); + png_ptr->current_text[length] = '\0'; + png_ptr->current_text_ptr = png_ptr->current_text; + png_ptr->current_text_size = (png_size_t)length; + png_ptr->current_text_left = (png_size_t)length; + png_ptr->process_mode = PNG_READ_iTXt_MODE; +} + +void /* PRIVATE */ +png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) +{ + + if (png_ptr->buffer_size && png_ptr->current_text_left) + { + png_size_t text_size; + + if (png_ptr->buffer_size < png_ptr->current_text_left) + text_size = png_ptr->buffer_size; + else + text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); + png_ptr->current_text_left -= text_size; + png_ptr->current_text_ptr += text_size; + } + if (!(png_ptr->current_text_left)) + { + png_textp text_ptr; + png_charp key; + int comp_flag; + png_charp lang; + png_charp lang_key; + png_charp text; + int ret; + + if (png_ptr->buffer_size < 4) + { + png_push_save_buffer(png_ptr); + return; + } + + png_push_crc_finish(png_ptr); + +#if defined(PNG_MAX_MALLOC_64K) + if (png_ptr->skip_length) + return; +#endif + + key = png_ptr->current_text; + + for (lang = key; *lang; lang++) + /* empty loop */ ; + + if (lang != key + png_ptr->current_text_size) + lang++; + + comp_flag = *lang++; + lang++; /* skip comp_type, always zero */ + + for (lang_key = lang; *lang_key; lang_key++) + /* empty loop */ ; + lang_key++; /* skip NUL separator */ + + for (text = lang_key; *text; text++) + /* empty loop */ ; + + if (text != key + png_ptr->current_text_size) + text++; + + text_ptr = (png_textp)png_malloc(png_ptr, + (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = comp_flag + 2; + text_ptr->key = key; + text_ptr->lang = lang; + text_ptr->lang_key = lang_key; + text_ptr->text = text; + text_ptr->text_length = 0; + text_ptr->itxt_length = png_strlen(text); + + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_ptr->current_text = NULL; + + png_free(png_ptr, text_ptr); + if (ret) + png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); + } +} +#endif + +/* This function is called when we haven't found a handler for this + * chunk. If there isn't a problem with the chunk itself (ie a bad chunk + * name or a critical chunk), the chunk is (currently) silently ignored. + */ +void /* PRIVATE */ +png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 + length) +{ + png_uint_32 skip=0; + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + if (!(png_ptr->chunk_name[0] & 0x20)) + { +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + && png_ptr->read_user_chunk_fn == NULL +#endif + ) +#endif + png_chunk_error(png_ptr, "unknown critical chunk"); + + /* to quiet compiler warnings about unused info_ptr */ + if (info_ptr == NULL) + return; + } + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) + { + png_unknown_chunk chunk; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "unknown chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + chunk.data = (png_bytep)png_malloc(png_ptr, length); + png_crc_read(png_ptr, chunk.data, length); + chunk.size = length; +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if(png_ptr->read_user_chunk_fn != NULL) + { + /* callback to user unknown chunk handler */ + if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) + { + if (!(png_ptr->chunk_name[0] & 0x20)) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS) + png_chunk_error(png_ptr, "unknown critical chunk"); + } + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + } + else +#endif + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + png_free(png_ptr, chunk.data); + } + else +#endif + skip=length; + png_push_crc_skip(png_ptr, skip); +} + +void /* PRIVATE */ +png_push_have_info(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->info_fn != NULL) (*(png_ptr->info_fn))(png_ptr, info_ptr); } void /* PRIVATE */ -png_push_have_end(png_structrp png_ptr, png_inforp info_ptr) +png_push_have_end(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->end_fn != NULL) (*(png_ptr->end_fn))(png_ptr, info_ptr); } void /* PRIVATE */ -png_push_have_row(png_structrp png_ptr, png_bytep row) +png_push_have_row(png_structp png_ptr, png_bytep row) { if (png_ptr->row_fn != NULL) (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, (int)png_ptr->pass); } -#ifdef PNG_READ_INTERLACING_SUPPORTED void PNGAPI -png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, - png_const_bytep new_row) +png_progressive_combine_row (png_structp png_ptr, + png_bytep old_row, png_bytep new_row) { - if (png_ptr == NULL) - return; - - /* new_row is a flag here - if it is NULL then the app callback was called - * from an empty row (see the calls to png_struct::row_fn below), otherwise - * it must be png_ptr->row_buf+1 - */ - if (new_row != NULL) - png_combine_row(png_ptr, old_row, 1/*display*/); +#ifdef PNG_USE_LOCAL_ARRAYS + const int FARDATA png_pass_dsp_mask[7] = + {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; +#endif + if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ + png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); } -#endif /* PNG_READ_INTERLACING_SUPPORTED */ void PNGAPI -png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) +png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn) { - if (png_ptr == NULL) - return; - png_ptr->info_fn = info_fn; png_ptr->row_fn = row_fn; png_ptr->end_fn = end_fn; @@ -1281,11 +1566,8 @@ png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr, } png_voidp PNGAPI -png_get_progressive_ptr(png_const_structrp png_ptr) +png_get_progressive_ptr(png_structp png_ptr) { - if (png_ptr == NULL) - return (NULL); - return png_ptr->io_ptr; } #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngprefix.h b/Source/3rd Party/wx/src/png/pngprefix.h deleted file mode 100644 index 89cbb31ee..000000000 --- a/Source/3rd Party/wx/src/png/pngprefix.h +++ /dev/null @@ -1,188 +0,0 @@ -#define png_sRGB_table wx_png_sRGB_table -#define png_sRGB_base wx_png_sRGB_base -#define png_sRGB_delta wx_png_sRGB_delta -#define png_zstream_error wx_png_zstream_error -#define png_free_buffer_list wx_png_free_buffer_list -#define png_fixed wx_png_fixed -#define png_user_version_check wx_png_user_version_check -#define png_malloc_base wx_png_malloc_base -#define png_malloc_array wx_png_malloc_array -#define png_realloc_array wx_png_realloc_array -#define png_create_png_struct wx_png_create_png_struct -#define png_destroy_png_struct wx_png_destroy_png_struct -#define png_free_jmpbuf wx_png_free_jmpbuf -#define png_zalloc wx_png_zalloc -#define png_zfree wx_png_zfree -#define png_default_read_data wx_png_default_read_data -#define png_push_fill_buffer wx_png_push_fill_buffer -#define png_default_write_data wx_png_default_write_data -#define png_default_flush wx_png_default_flush -#define png_reset_crc wx_png_reset_crc -#define png_write_data wx_png_write_data -#define png_read_sig wx_png_read_sig -#define png_read_chunk_header wx_png_read_chunk_header -#define png_read_data wx_png_read_data -#define png_crc_read wx_png_crc_read -#define png_crc_finish wx_png_crc_finish -#define png_crc_error wx_png_crc_error -#define png_calculate_crc wx_png_calculate_crc -#define png_flush wx_png_flush -#define png_write_IHDR wx_png_write_IHDR -#define png_write_PLTE wx_png_write_PLTE -#define png_compress_IDAT wx_png_compress_IDAT -#define png_write_IEND wx_png_write_IEND -#define png_write_gAMA_fixed wx_png_write_gAMA_fixed -#define png_write_sBIT wx_png_write_sBIT -#define png_write_cHRM_fixed wx_png_write_cHRM_fixed -#define png_write_sRGB wx_png_write_sRGB -#define png_write_iCCP wx_png_write_iCCP -#define png_write_sPLT wx_png_write_sPLT -#define png_write_tRNS wx_png_write_tRNS -#define png_write_bKGD wx_png_write_bKGD -#define png_write_hIST wx_png_write_hIST -#define png_write_tEXt wx_png_write_tEXt -#define png_write_zTXt wx_png_write_zTXt -#define png_write_iTXt wx_png_write_iTXt -#define png_set_text_2 wx_png_set_text_2 -#define png_write_oFFs wx_png_write_oFFs -#define png_write_pCAL wx_png_write_pCAL -#define png_write_pHYs wx_png_write_pHYs -#define png_write_tIME wx_png_write_tIME -#define png_write_sCAL_s wx_png_write_sCAL_s -#define png_write_finish_row wx_png_write_finish_row -#define png_write_start_row wx_png_write_start_row -#define png_combine_row wx_png_combine_row -#define png_do_read_interlace wx_png_do_read_interlace -#define png_do_write_interlace wx_png_do_write_interlace -#define png_read_filter_row wx_png_read_filter_row -#define png_read_filter_row_up_neon wx_png_read_filter_row_up_neon -#define png_read_filter_row_sub3_neon wx_png_read_filter_row_sub3_neon -#define png_read_filter_row_sub4_neon wx_png_read_filter_row_sub4_neon -#define png_read_filter_row_avg3_neon wx_png_read_filter_row_avg3_neon -#define png_read_filter_row_avg4_neon wx_png_read_filter_row_avg4_neon -#define png_read_filter_row_paeth3_neon wx_png_read_filter_row_paeth3_neon -#define png_read_filter_row_paeth4_neon wx_png_read_filter_row_paeth4_neon -#define png_write_find_filter wx_png_write_find_filter -#define png_read_IDAT_data wx_png_read_IDAT_data -#define png_read_finish_IDAT wx_png_read_finish_IDAT -#define png_read_finish_row wx_png_read_finish_row -#define png_read_start_row wx_png_read_start_row -#define png_read_transform_info wx_png_read_transform_info -#define png_do_read_filler wx_png_do_read_filler -#define png_do_read_swap_alpha wx_png_do_read_swap_alpha -#define png_do_write_swap_alpha wx_png_do_write_swap_alpha -#define png_do_read_invert_alpha wx_png_do_read_invert_alpha -#define png_do_write_invert_alpha wx_png_do_write_invert_alpha -#define png_do_strip_channel wx_png_do_strip_channel -#define png_do_swap wx_png_do_swap -#define png_do_packswap wx_png_do_packswap -#define png_do_rgb_to_gray wx_png_do_rgb_to_gray -#define png_do_gray_to_rgb wx_png_do_gray_to_rgb -#define png_do_unpack wx_png_do_unpack -#define png_do_unshift wx_png_do_unshift -#define png_do_invert wx_png_do_invert -#define png_do_scale_16_to_8 wx_png_do_scale_16_to_8 -#define png_do_chop wx_png_do_chop -#define png_do_quantize wx_png_do_quantize -#define png_do_bgr wx_png_do_bgr -#define png_do_pack wx_png_do_pack -#define png_do_shift wx_png_do_shift -#define png_do_compose wx_png_do_compose -#define png_do_gamma wx_png_do_gamma -#define png_do_encode_alpha wx_png_do_encode_alpha -#define png_do_expand_palette wx_png_do_expand_palette -#define png_do_expand wx_png_do_expand -#define png_do_expand_16 wx_png_do_expand_16 -#define png_handle_IHDR wx_png_handle_IHDR -#define png_handle_PLTE wx_png_handle_PLTE -#define png_handle_IEND wx_png_handle_IEND -#define png_handle_bKGD wx_png_handle_bKGD -#define png_handle_cHRM wx_png_handle_cHRM -#define png_handle_gAMA wx_png_handle_gAMA -#define png_handle_hIST wx_png_handle_hIST -#define png_handle_iCCP wx_png_handle_iCCP -#define png_handle_iTXt wx_png_handle_iTXt -#define png_handle_oFFs wx_png_handle_oFFs -#define png_handle_pCAL wx_png_handle_pCAL -#define png_handle_pHYs wx_png_handle_pHYs -#define png_handle_sBIT wx_png_handle_sBIT -#define png_handle_sCAL wx_png_handle_sCAL -#define png_handle_sPLT wx_png_handle_sPLT -#define png_handle_sRGB wx_png_handle_sRGB -#define png_handle_tEXt wx_png_handle_tEXt -#define png_handle_tIME wx_png_handle_tIME -#define png_handle_tRNS wx_png_handle_tRNS -#define png_handle_zTXt wx_png_handle_zTXt -#define png_check_chunk_name wx_png_check_chunk_name -#define png_handle_unknown wx_png_handle_unknown -#define png_chunk_unknown_handling wx_png_chunk_unknown_handling -#define png_do_read_transformations wx_png_do_read_transformations -#define png_do_write_transformations wx_png_do_write_transformations -#define png_init_read_transformations wx_png_init_read_transformations -#define png_push_read_chunk wx_png_push_read_chunk -#define png_push_read_sig wx_png_push_read_sig -#define png_push_check_crc wx_png_push_check_crc -#define png_push_crc_skip wx_png_push_crc_skip -#define png_push_crc_finish wx_png_push_crc_finish -#define png_push_save_buffer wx_png_push_save_buffer -#define png_push_restore_buffer wx_png_push_restore_buffer -#define png_push_read_IDAT wx_png_push_read_IDAT -#define png_process_IDAT_data wx_png_process_IDAT_data -#define png_push_process_row wx_png_push_process_row -#define png_push_handle_unknown wx_png_push_handle_unknown -#define png_push_have_info wx_png_push_have_info -#define png_push_have_end wx_png_push_have_end -#define png_push_have_row wx_png_push_have_row -#define png_push_read_end wx_png_push_read_end -#define png_process_some_data wx_png_process_some_data -#define png_read_push_finish_row wx_png_read_push_finish_row -#define png_push_handle_tEXt wx_png_push_handle_tEXt -#define png_push_read_tEXt wx_png_push_read_tEXt -#define png_push_handle_zTXt wx_png_push_handle_zTXt -#define png_push_read_zTXt wx_png_push_read_zTXt -#define png_push_handle_iTXt wx_png_push_handle_iTXt -#define png_push_read_iTXt wx_png_push_read_iTXt -#define png_do_read_intrapixel wx_png_do_read_intrapixel -#define png_do_write_intrapixel wx_png_do_write_intrapixel -#define png_colorspace_set_gamma wx_png_colorspace_set_gamma -#define png_colorspace_sync_info wx_png_colorspace_sync_info -#define png_colorspace_sync wx_png_colorspace_sync -#define png_colorspace_set_chromaticities wx_png_colorspace_set_chromaticities -#define png_colorspace_set_endpoints wx_png_colorspace_set_endpoints -#define png_colorspace_set_sRGB wx_png_colorspace_set_sRGB -#define png_colorspace_set_ICC wx_png_colorspace_set_ICC -#define png_icc_check_length wx_png_icc_check_length -#define png_icc_check_header wx_png_icc_check_header -#define png_icc_check_tag_table wx_png_icc_check_tag_table -#define png_icc_set_sRGB wx_png_icc_set_sRGB -#define png_colorspace_set_rgb_coefficients wx_png_colorspace_set_rgb_coefficients -#define png_check_IHDR wx_png_check_IHDR -#define png_do_check_palette_indexes wx_png_do_check_palette_indexes -#define png_fixed_error wx_png_fixed_error -#define png_safecat wx_png_safecat -#define png_format_number wx_png_format_number -#define png_warning_parameter wx_png_warning_parameter -#define png_warning_parameter_unsigned wx_png_warning_parameter_unsigned -#define png_warning_parameter_signed wx_png_warning_parameter_signed -#define png_formatted_warning wx_png_formatted_warning -#define png_app_warning wx_png_app_warning -#define png_app_error wx_png_app_error -#define png_chunk_report wx_png_chunk_report -#define png_ascii_from_fp wx_png_ascii_from_fp -#define png_ascii_from_fixed wx_png_ascii_from_fixed -#define png_check_fp_number wx_png_check_fp_number -#define png_check_fp_string wx_png_check_fp_string -#define png_muldiv wx_png_muldiv -#define png_muldiv_warn wx_png_muldiv_warn -#define png_reciprocal wx_png_reciprocal -#define png_reciprocal2 wx_png_reciprocal2 -#define png_gamma_significant wx_png_gamma_significant -#define png_gamma_correct wx_png_gamma_correct -#define png_gamma_16bit_correct wx_png_gamma_16bit_correct -#define png_gamma_8bit_correct wx_png_gamma_8bit_correct -#define png_destroy_gamma_table wx_png_destroy_gamma_table -#define png_build_gamma_table wx_png_build_gamma_table -#define png_safe_error wx_png_safe_error -#define png_safe_warning wx_png_safe_warning -#define png_safe_execute wx_png_safe_execute -#define png_image_error wx_png_image_error diff --git a/Source/3rd Party/wx/src/png/pngpriv.h b/Source/3rd Party/wx/src/png/pngpriv.h deleted file mode 100644 index 1813e5a15..000000000 --- a/Source/3rd Party/wx/src/png/pngpriv.h +++ /dev/null @@ -1,1912 +0,0 @@ -/* pngpriv.h - private declarations for use inside libpng - * - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2013 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Last changed in libpng 1.6.2 [April 25, 2013] - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* The symbols declared in this file (including the functions declared - * as extern) are PRIVATE. They are not part of the libpng public - * interface, and are not recommended for use by regular applications. - * Some of them may become public in the future; others may stay private, - * change in an incompatible way, or even disappear. - * Although the libpng users are not forbidden to include this header, - * they should be well aware of the issues that may arise from doing so. - */ - -#ifndef PNGPRIV_H -#define PNGPRIV_H - -/* Feature Test Macros. The following are defined here to ensure that correctly - * implemented libraries reveal the APIs libpng needs to build and hide those - * that are not needed and potentially damaging to the compilation. - * - * Feature Test Macros must be defined before any system header is included (see - * POSIX 1003.1 2.8.2 "POSIX Symbols." - * - * These macros only have an effect if the operating system supports either - * POSIX 1003.1 or C99, or both. On other operating systems (particularly - * Windows/Visual Studio) there is no effect; the OS specific tests below are - * still required (as of 2011-05-02.) - */ -#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ - -#ifndef PNG_VERSION_INFO_ONLY -/* Standard library headers not required by png.h: */ -# include -# include -#endif - -#define PNGLIB_BUILD /*libpng is being built, not used*/ - -/* If HAVE_CONFIG_H is defined during the build then the build system must - * provide an appropriate "config.h" file on the include path. The header file - * must provide definitions as required below (search for "HAVE_CONFIG_H"); - * see configure.ac for more details of the requirements. The macro - * "PNG_NO_CONFIG_H" is provided for maintainers to test for dependencies on - * 'configure'; define this macro to prevent the configure build including the - * configure generated config.h. Libpng is expected to compile without *any* - * special build system support on a reasonably ANSI-C compliant system. - */ -#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) -# include - - /* Pick up the definition of 'restrict' from config.h if it was read: */ -# define PNG_RESTRICT restrict -#endif - -/* To support symbol prefixing it is necessary to know *before* including png.h - * whether the fixed point (and maybe other) APIs are exported, because if they - * are not internal definitions may be required. This is handled below just - * before png.h is included, but load the configuration now if it is available. - */ -#ifndef PNGLCONF_H -# include "pnglibconf.h" -#endif - -/* Local renames may change non-exported API functions from png.h */ -#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H) -# include "pngprefix.h" -#endif - -#ifdef PNG_USER_CONFIG -# include "pngusr.h" - /* These should have been defined in pngusr.h */ -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD "Custom libpng build" -# endif -# ifndef PNG_USER_DLLFNAME_POSTFIX -# define PNG_USER_DLLFNAME_POSTFIX "Cb" -# endif -#endif - -/* Is this a build of a DLL where compilation of the object modules requires - * different preprocessor settings to those required for a simple library? If - * so PNG_BUILD_DLL must be set. - * - * If libpng is used inside a DLL but that DLL does not export the libpng APIs - * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a - * static library of libpng then link the DLL against that. - */ -#ifndef PNG_BUILD_DLL -# ifdef DLL_EXPORT - /* This is set by libtool when files are compiled for a DLL; libtool - * always compiles twice, even on systems where it isn't necessary. Set - * PNG_BUILD_DLL in case it is necessary: - */ -# define PNG_BUILD_DLL -# else -# ifdef _WINDLL - /* This is set by the Microsoft Visual Studio IDE in projects that - * build a DLL. It can't easily be removed from those projects (it - * isn't visible in the Visual Studio UI) so it is a fairly reliable - * indication that PNG_IMPEXP needs to be set to the DLL export - * attributes. - */ -# define PNG_BUILD_DLL -# else -# ifdef __DLL__ - /* This is set by the Borland C system when compiling for a DLL - * (as above.) - */ -# define PNG_BUILD_DLL -# else - /* Add additional compiler cases here. */ -# endif -# endif -# endif -#endif /* Setting PNG_BUILD_DLL if required */ - -/* See pngconf.h for more details: the builder of the library may set this on - * the command line to the right thing for the specific compilation system or it - * may be automagically set above (at present we know of no system where it does - * need to be set on the command line.) - * - * PNG_IMPEXP must be set here when building the library to prevent pngconf.h - * setting it to the "import" setting for a DLL build. - */ -#ifndef PNG_IMPEXP -# ifdef PNG_BUILD_DLL -# define PNG_IMPEXP PNG_DLL_EXPORT -# else - /* Not building a DLL, or the DLL doesn't require specific export - * definitions. - */ -# define PNG_IMPEXP -# endif -#endif - -/* No warnings for private or deprecated functions in the build: */ -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE -#endif - -/* Symbol preprocessing support. - * - * To enable listing global, but internal, symbols the following macros should - * always be used to declare an extern data or function object in this file. - */ -#ifndef PNG_INTERNAL_DATA -# define PNG_INTERNAL_DATA(type, name, array) extern type name array -#endif - -#ifndef PNG_INTERNAL_FUNCTION -# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ - extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes) -#endif - -/* If floating or fixed point APIs are disabled they may still be compiled - * internally. To handle this make sure they are declared as the appropriate - * internal extern function (otherwise the symbol prefixing stuff won't work and - * the functions will be used without definitions.) - * - * NOTE: although all the API functions are declared here they are not all - * actually built! Because the declarations are still made it is necessary to - * fake out types that they depend on. - */ -#ifndef PNG_FP_EXPORT -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); -# ifndef PNG_VERSION_INFO_ONLY - typedef struct png_incomplete png_double; - typedef png_double* png_doublep; - typedef const png_double* png_const_doublep; - typedef png_double** png_doublepp; -# endif -# endif -#endif -#ifndef PNG_FIXED_EXPORT -# ifndef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); -# endif -#endif - -#include "png.h" - -/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ -#ifndef PNG_DLL_EXPORT -# define PNG_DLL_EXPORT -#endif - -/* SECURITY and SAFETY: - * - * By default libpng is built without any internal limits on image size, - * individual heap (png_malloc) allocations or the total amount of memory used. - * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used - * (unless individually overridden). These limits are believed to be fairly - * safe, but builders of secure systems should verify the values against the - * real system capabilities. - */ -#ifdef PNG_SAFE_LIMITS_SUPPORTED - /* 'safe' limits */ -# ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000 -# endif -# ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000 -# endif -# ifndef PNG_USER_CHUNK_CACHE_MAX -# define PNG_USER_CHUNK_CACHE_MAX 128 -# endif -# ifndef PNG_USER_CHUNK_MALLOC_MAX -# define PNG_USER_CHUNK_MALLOC_MAX 8000000 -# endif -#else - /* values for no limits */ -# ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 0x7fffffff -# endif -# ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 0x7fffffff -# endif -# ifndef PNG_USER_CHUNK_CACHE_MAX -# define PNG_USER_CHUNK_CACHE_MAX 0 -# endif -# ifndef PNG_USER_CHUNK_MALLOC_MAX -# define PNG_USER_CHUNK_MALLOC_MAX 0 -# endif -#endif - -/* Moved to pngpriv.h at libpng-1.5.0 */ -/* NOTE: some of these may have been used in external applications as - * these definitions were exposed in pngconf.h prior to 1.5. - */ - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. - * - * zlib provides 'MAXSEG_64K' which, if defined, indicates the - * same limit and pngconf.h (already included) sets the limit - * if certain operating systems are detected. - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -#ifndef PNG_UNUSED -/* Unused formal parameter warnings are silenced using the following macro - * which is expected to have no bad effects on performance (optimizing - * compilers will probably remove it entirely). Note that if you replace - * it with something other than whitespace, you must include the terminating - * semicolon. - */ -# define PNG_UNUSED(param) (void)param; -#endif - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -/* If warnings or errors are turned off the code is disabled or redirected here. - * From 1.5.4 functions have been added to allow very limited formatting of - * error and warning messages - this code will also be disabled here. - */ -#ifdef PNG_WARNINGS_SUPPORTED -# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p; -#else -# define png_warning(s1,s2) ((void)(s1)) -# define png_chunk_warning(s1,s2) ((void)(s1)) -# define png_warning_parameter(p,number,string) ((void)0) -# define png_warning_parameter_unsigned(p,number,format,value) ((void)0) -# define png_warning_parameter_signed(p,number,format,value) ((void)0) -# define png_formatted_warning(pp,p,message) ((void)(pp)) -# define PNG_WARNING_PARAMETERS(p) -#endif -#ifndef PNG_ERROR_TEXT_SUPPORTED -# define png_error(s1,s2) png_err(s1) -# define png_chunk_error(s1,s2) png_err(s1) -# define png_fixed_error(s1,s2) png_err(s1) -#endif - -/* C allows up-casts from (void*) to any pointer and (const void*) to any - * pointer to a const object. C++ regards this as a type error and requires an - * explicit, static, cast and provides the static_cast<> rune to ensure that - * const is not cast away. - */ -#ifdef __cplusplus -# define png_voidcast(type, value) static_cast(value) -# define png_constcast(type, value) const_cast(value) -# define png_aligncast(type, value) \ - static_cast(static_cast(value)) -# define png_aligncastconst(type, value) \ - static_cast(static_cast(value)) -#else -# define png_voidcast(type, value) (value) -# define png_constcast(type, value) ((type)(value)) -# define png_aligncast(type, value) ((void*)(value)) -# define png_aligncastconst(type, value) ((const void*)(value)) -#endif /* __cplusplus */ - -/* Some fixed point APIs are still required even if not exported because - * they get used by the corresponding floating point APIs. This magic - * deals with this: - */ -#ifdef PNG_FIXED_POINT_SUPPORTED -# define PNGFAPI PNGAPI -#else -# define PNGFAPI /* PRIVATE */ -#endif - -#ifndef PNG_VERSION_INFO_ONLY -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) - /* png.c requires the following ANSI-C constants if the conversion of - * floating point to ASCII is implemented therein: - * - * DBL_DIG Maximum number of decimal digits (can be set to any constant) - * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) - * DBL_MAX Maximum floating point number (can be set to an arbitrary value) - */ -# include - -# if ( ( (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(TARGET_OS_MAC) ) && !wxOSX_USE_IPHONE ) || defined(__SC__) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include -# include -#endif - -#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ - defined(_WIN32) || defined(__WIN32__) -# include /* defines _WINDOWS_ macro */ -#endif -#endif /* PNG_VERSION_INFO_ONLY */ - -/* Moved here around 1.5.0beta36 from pngconf.h */ -/* Users may want to use these so they are not private. Any library - * functions that are passed far data must be model-independent. - */ - -/* Memory model/platform independent fns */ -#ifndef PNG_ABORT -# ifdef _WINDOWS_ -# define PNG_ABORT() ExitProcess(0) -# else -# define PNG_ABORT() abort() -# endif -#endif - -/* These macros may need to be architecture dependent. */ -#define PNG_ALIGN_NONE 0 /* do not use data alignment */ -#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ -#ifdef offsetof -# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ -#else -# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ -#endif -#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ - -#ifndef PNG_ALIGN_TYPE - /* Default to using aligned access optimizations and requiring alignment to a - * multiple of the data type size. Override in a compiler specific fashion - * if necessary by inserting tests here: - */ -# define PNG_ALIGN_TYPE PNG_ALIGN_SIZE -#endif - -#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE - /* This is used because in some compiler implementations non-aligned - * structure members are supported, so the offsetof approach below fails. - * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access - * is good for performance. Do not do this unless you have tested the result - * and understand it. - */ -# define png_alignof(type) (sizeof (type)) -#else -# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET -# define png_alignof(type) offsetof(struct{char c; type t;}, t) -# else -# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS -# define png_alignof(type) (1) -# endif - /* Else leave png_alignof undefined to prevent use thereof */ -# endif -#endif - -/* This implicitly assumes alignment is always to a power of 2. */ -#ifdef png_alignof -# define png_isaligned(ptr, type)\ - ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0) -#else -# define png_isaligned(ptr, type) 0 -#endif - -/* End of memory model/platform independent support */ -/* End of 1.5.0beta36 move from pngconf.h */ - -/* CONSTANTS and UTILITY MACROS - * These are used internally by libpng and not exposed in the API - */ - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. Three of these - * are defined in png.h because they need to be visible to applications - * that call png_set_unknown_chunk(). - */ -/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */ -/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */ -#define PNG_HAVE_IDAT 0x04 -/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */ -#define PNG_HAVE_IEND 0x10 - /* 0x20 (unused) */ - /* 0x40 (unused) */ - /* 0x80 (unused) */ -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - /* 0x4000 (unused) */ -#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */ - -/* Flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_QUANTIZE 0x0040 -#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */ -#define PNG_BACKGROUND_EXPAND 0x0100 -#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */ -#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */ -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000 -#define PNG_PACKSWAP 0x10000 -#define PNG_SWAP_ALPHA 0x20000 -#define PNG_STRIP_ALPHA 0x40000 -#define PNG_INVERT_ALPHA 0x80000 -#define PNG_USER_TRANSFORM 0x100000 -#define PNG_RGB_TO_GRAY_ERR 0x200000 -#define PNG_RGB_TO_GRAY_WARN 0x400000 -#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ -#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */ -#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ -#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ -/* Flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* Flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */ - /* 0x0004 unused */ -#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */ - /* 0x0010 unused */ - /* 0x0020 unused */ -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */ -/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */ -/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */ -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000 -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000 -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000 -#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */ -#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */ -#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */ - /* 0x800000 unused */ - /* 0x1000000 unused */ - /* 0x2000000 unused */ - /* 0x4000000 unused */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* Save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255 - * by dividing by 257 *with rounding*. This macro is exact for the given range. - * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the - * macro were established by experiment (modifying the added value). The macro - * has a second variant that takes a value already scaled by 255 and divides by - * 65535 - this has a maximum error of .502. Over the range 0..65535*65535 it - * only gives off-by-one errors and only for 0.5% (1 in 200) of the values. - */ -#define PNG_DIV65535(v24) (((v24) + 32895) >> 16) -#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ - (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - * ideal-delta..ideal+delta. Each argument is evaluated twice. - * "ideal" and "delta" should be constants, normally simple - * integers, "value" a variable. Added to libpng-1.2.6 JB - */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* Conversions between fixed and floating point, only defined if - * required (to make sure the code doesn't accidentally use float - * when it is supposedly disabled.) - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -/* The floating point conversion can't overflow, though it can and - * does lose accuracy relative to the original fixed point value. - * In practice this doesn't matter because png_fixed_point only - * stores numbers with very low precision. The png_ptr and s - * arguments are unused by default but are there in case error - * checking becomes a requirement. - */ -#define png_float(png_ptr, fixed, s) (.00001 * (fixed)) - -/* The fixed point conversion performs range checking and evaluates - * its argument multiple times, so must be used with care. The - * range checking uses the PNG specification values for a signed - * 32 bit fixed point value except that the values are deliberately - * rounded-to-zero to an integral value - 21474 (21474.83 is roughly - * (2^31-1) * 100000). 's' is a string that describes the value being - * converted. - * - * NOTE: this macro will raise a png_error if the range check fails, - * therefore it is normally only appropriate to use this on values - * that come from API calls or other sources where an out of range - * error indicates a programming error, not a data error! - * - * NOTE: by default this is off - the macro is not used - because the - * function call saves a lot of code. - */ -#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED -#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ - ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) -#endif -/* else the corresponding function is defined below, inside the scope of the - * cplusplus test. - */ -#endif - -/* Constants for known chunk types. If you need to add a chunk, define the name - * here. For historical reasons these constants have the form png_; i.e. - * the prefix is lower case. Please use decimal values as the parameters to - * match the ISO PNG specification and to avoid relying on the C locale - * interpretation of character values. - * - * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values - * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string - * to be generated if required. - * - * PNG_32b correctly produces a value shifted by up to 24 bits, even on - * architectures where (int) is only 16 bits. - */ -#define PNG_32b(b,s) ((png_uint_32)(b) << (s)) -#define PNG_CHUNK(b1,b2,b3,b4) \ - (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0)) - -#define png_IHDR PNG_CHUNK( 73, 72, 68, 82) -#define png_IDAT PNG_CHUNK( 73, 68, 65, 84) -#define png_IEND PNG_CHUNK( 73, 69, 78, 68) -#define png_PLTE PNG_CHUNK( 80, 76, 84, 69) -#define png_bKGD PNG_CHUNK( 98, 75, 71, 68) -#define png_cHRM PNG_CHUNK( 99, 72, 82, 77) -#define png_gAMA PNG_CHUNK(103, 65, 77, 65) -#define png_hIST PNG_CHUNK(104, 73, 83, 84) -#define png_iCCP PNG_CHUNK(105, 67, 67, 80) -#define png_iTXt PNG_CHUNK(105, 84, 88, 116) -#define png_oFFs PNG_CHUNK(111, 70, 70, 115) -#define png_pCAL PNG_CHUNK(112, 67, 65, 76) -#define png_sCAL PNG_CHUNK(115, 67, 65, 76) -#define png_pHYs PNG_CHUNK(112, 72, 89, 115) -#define png_sBIT PNG_CHUNK(115, 66, 73, 84) -#define png_sPLT PNG_CHUNK(115, 80, 76, 84) -#define png_sRGB PNG_CHUNK(115, 82, 71, 66) -#define png_sTER PNG_CHUNK(115, 84, 69, 82) -#define png_tEXt PNG_CHUNK(116, 69, 88, 116) -#define png_tIME PNG_CHUNK(116, 73, 77, 69) -#define png_tRNS PNG_CHUNK(116, 82, 78, 83) -#define png_zTXt PNG_CHUNK(122, 84, 88, 116) - -/* The following will work on (signed char*) strings, whereas the get_uint_32 - * macro will fail on top-bit-set values because of the sign extension. - */ -#define PNG_CHUNK_FROM_STRING(s)\ - PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3]) - -/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is - * signed and the argument is a (char[]) This macro will fail miserably on - * systems where (char) is more than 8 bits. - */ -#define PNG_STRING_FROM_CHUNK(s,c)\ - (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\ - ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c))) - -/* Do the same but terminate with a null character. */ -#define PNG_CSTRING_FROM_CHUNK(s,c)\ - (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0) - -/* Test on flag values as defined in the spec (section 5.4): */ -#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29)) -#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c)) -#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) -#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) -#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) - -/* Gamma values (new at libpng-1.5.4): */ -#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */ -#define PNG_GAMMA_MAC_INVERSE 65909 -#define PNG_GAMMA_sRGB_INVERSE 45455 - -/* Almost everything below is C specific; the #defines above can be used in - * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot. - */ -#ifndef PNG_VERSION_INFO_ONLY - -#include "pngstruct.h" -#include "pnginfo.h" - -/* This is used for 16 bit gamma tables -- only the top level pointers are - * const; this could be changed: - */ -typedef const png_uint_16p * png_const_uint_16pp; - -/* Added to libpng-1.5.7: sRGB conversion tables */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); - /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, - * 0..65535. This table gives the closest 16-bit answers (no errors). - */ -#endif - -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); -PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); - -#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\ - ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)) - /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB - * encoded value with maximum error 0.646365. Note that the input is not a - * 16-bit value; it has been multiplied by 255! */ -#endif /* PNG_SIMPLIFIED_READ/WRITE */ - - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Internal functions; these are not exported from a DLL however because they - * are used within several of the C source files they have to be C extern. - * - * All of these functions must be declared with PNG_INTERNAL_FUNCTION. - */ - -/* Zlib support */ -#define PNG_UNEXPECTED_ZLIB_RETURN (-7) -PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret), - PNG_EMPTY); - /* Used by the zlib handling functions to ensure that z_stream::msg is always - * set before they return. - */ - -#ifdef PNG_WRITE_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr, - png_compression_bufferp *list),PNG_EMPTY); - /* Free the buffer list used by the compressed write code. */ -#endif - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ - (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ - defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ - (defined(PNG_sCAL_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) -PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr, - double fp, png_const_charp text),PNG_EMPTY); -#endif - -/* Check the user version string for compatibility, returns false if the version - * numbers aren't compatible. - */ -PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr, - png_const_charp user_png_ver),PNG_EMPTY); - -/* Internal base allocator - no messages, NULL on failure to allocate. This - * does, however, call the application provided allocator and that could call - * png_error (although that would be a bug in the application implementation.) - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr, - png_alloc_size_t size),PNG_ALLOCATED); - -#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ - defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) -/* Internal array allocator, outputs no error or warning messages on failure, - * just returns NULL. - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr, - int nelements, size_t element_size),PNG_ALLOCATED); - -/* The same but an existing array is extended by add_elements. This function - * also memsets the new elements to 0 and copies the old elements. The old - * array is not freed or altered. - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr, - png_const_voidp array, int old_elements, int add_elements, - size_t element_size),PNG_ALLOCATED); -#endif /* text, sPLT or unknown chunks */ - -/* Magic to create a struct when there is no struct to call the user supplied - * memory allocators. Because error handling has not been set up the memory - * handlers can't safely call png_error, but this is an obscure and undocumented - * restriction so libpng has to assume that the 'free' handler, at least, might - * call png_error. - */ -PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, - png_free_ptr free_fn),PNG_ALLOCATED); - -/* Free memory from internal libpng struct */ -PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr), - PNG_EMPTY); - -/* Free an allocated jmp_buf (always succeeds) */ -PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY); - -/* Function to allocate memory for zlib. PNGAPI is disallowed. */ -PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size), - PNG_ALLOCATED); - -/* Function to free memory for zlib. PNGAPI is disallowed. */ -PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY); - -/* Next four functions are used internally as callbacks. PNGCBAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to - * PNGCBAPI at 1.5.0 - */ - -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr, - png_bytep data, png_size_t length),PNG_EMPTY); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr, - png_bytep buffer, png_size_t length),PNG_EMPTY); -#endif - -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr, - png_bytep data, png_size_t length),PNG_EMPTY); - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_STDIO_SUPPORTED -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr), - PNG_EMPTY); -# endif -#endif - -/* Reset the CRC variable */ -PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY); - -/* Write the "data" buffer to whatever output you are using */ -PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr, - png_const_bytep data, png_size_t length),PNG_EMPTY); - -/* Read and check the PNG file signature */ -PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); - -/* Read the chunk header (length + type name) */ -PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), - PNG_EMPTY); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data, - png_size_t length),PNG_EMPTY); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf, - png_uint_32 length),PNG_EMPTY); - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr, - png_uint_32 skip),PNG_EMPTY); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr, - png_const_bytep ptr, png_size_t length),PNG_EMPTY); - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY); -#endif - -/* Write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, - int compression_method, int filter_method, int interlace_method),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr, - png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr, - png_const_bytep row_data, png_alloc_size_t row_data_length, int flush), - PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY); - -#ifdef PNG_WRITE_gAMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr, - png_fixed_point file_gamma),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_sBIT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, - png_const_color_8p sbit, int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_cHRM_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, - const png_xy *xy), PNG_EMPTY); - /* The xy value must have been previously validated */ -#endif - -#ifdef PNG_WRITE_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, - int intent),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr, - png_const_charp name, png_const_bytep profile), PNG_EMPTY); - /* The profile must have been previously validated for correctness, the - * length comes from the first four bytes. Only the base, deflate, - * compression is supported. - */ -#endif - -#ifdef PNG_WRITE_sPLT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr, - png_const_sPLT_tp palette),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_tRNS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr, - png_const_bytep trans, png_const_color_16p values, int number, - int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_bKGD_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr, - png_const_color_16p values, int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_hIST_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr, - png_const_uint_16p hist, int num_hist),PNG_EMPTY); -#endif - -/* Chunks that have keywords */ -#ifdef PNG_WRITE_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr, - png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp - key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr, - int compression, png_const_charp key, png_const_charp lang, - png_const_charp lang_key, png_const_charp text),PNG_EMPTY); -#endif - -#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */ -PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_oFFs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_pCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_const_charp units, png_charpp params),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_pHYs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_tIME_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr, - png_const_timep mod_time),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_sCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr, - int unit, png_const_charp width, png_const_charp height),PNG_EMPTY); -#endif - -/* Called when finished processing a row of data */ -PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr), - PNG_EMPTY); - -/* Internal use only. Called before first row of data */ -PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr), - PNG_EMPTY); - -/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an - * array of png_ptr->width pixels. If the image is not interlaced or this - * is the final pass this just does a memcpy, otherwise the "display" flag - * is used to determine whether to copy pixels that are not in the current pass. - * - * Because 'png_do_read_interlace' (below) replicates pixels this allows this - * function to achieve the documented 'blocky' appearance during interlaced read - * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row' - * are not changed if they are not in the current pass, when display is 0. - * - * 'display' must be 0 or 1, otherwise the memcpy will be done regardless. - * - * The API always reads from the png_struct row buffer and always assumes that - * it is full width (png_do_read_interlace has already been called.) - * - * This function is only ever used to write to row buffers provided by the - * caller of the relevant libpng API and the row must have already been - * transformed by the read transformations. - * - * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed - * bitmasks for use within the code, otherwise runtime generated masks are used. - * The default is compile time masks. - */ -#ifndef PNG_USE_COMPILE_TIME_MASKS -# define PNG_USE_COMPILE_TIME_MASKS 1 -#endif -PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr, - png_bytep row, int display),PNG_EMPTY); - -#ifdef PNG_READ_INTERLACING_SUPPORTED -/* Expand an interlaced row: the 'row_info' describes the pass data that has - * been read in and must correspond to the pixels in 'row', the pixels are - * expanded (moved apart) in 'row' to match the final layout, when doing this - * the pixels are *replicated* to the intervening space. This is essential for - * the correct operation of png_combine_row, above. - */ -PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED -/* Grab pixels out of a row for an interlaced pass */ -PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, - png_bytep row, int pass),PNG_EMPTY); -#endif - -/* Unfilter a row: check the filter value before calling this, there is no point - * calling it for PNG_FILTER_VALUE_NONE. - */ -PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop - row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); - -/* Choose the best filter to use and filter the row data */ -PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, - png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); - /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer - * is NULL the function checks, instead, for the end of the stream. In this - * case a benign error will be issued if the stream end is not found or if - * extra data has to be consumed. - */ -PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr), - PNG_EMPTY); - /* This cleans up when the IDAT LZ stream does not end when the last image - * byte is read; there is still some pending input. - */ - -PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), - PNG_EMPTY); - /* Finish a row while reading, dealing with interlacing passes, etc. */ -#endif - -/* Initialize the row buffers, etc. */ -PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -/* Optional call to update the users info structure */ -PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -#endif - -/* These are the functions that do the transformations */ -#ifdef PNG_READ_FILLER_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_filler,(png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags),PNG_EMPTY); -#endif - -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_swap_alpha,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_write_swap_alpha,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_invert_alpha,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_write_invert_alpha,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info, - png_bytep row, int at_start),PNG_EMPTY); -#endif - -#ifdef PNG_16BIT_SUPPORTED -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_do_rgb_to_gray,(png_structrp png_ptr, - png_row_infop row_info, png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_gray_to_rgb,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_PACK_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_unpack,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_SHIFT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_unshift,(png_row_infop row_info, - png_bytep row, png_const_color_8p sig_bits),PNG_EMPTY); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_scale_16_to_8,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_chop,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_quantize,(png_row_infop row_info, - png_bytep row, png_const_bytep palette_lookup, - png_const_bytep quantize_lookup),PNG_EMPTY); - -# ifdef PNG_CORRECT_PALETTE_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_correct_palette,(png_structrp png_ptr, - png_colorp palette, int num_palette),PNG_EMPTY); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_PACK_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_pack,(png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_SHIFT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_shift,(png_row_infop row_info, - png_bytep row, png_const_color_8p bit_depth),PNG_EMPTY); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_compose,(png_row_infop row_info, - png_bytep row, png_structrp png_ptr),PNG_EMPTY); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_gamma,(png_row_infop row_info, - png_bytep row, png_structrp png_ptr),PNG_EMPTY); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_encode_alpha,(png_row_infop row_info, - png_bytep row, png_structrp png_ptr),PNG_EMPTY); -#endif - -#ifdef PNG_READ_EXPAND_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_expand_palette,(png_row_infop row_info, - png_bytep row, png_const_colorp palette, png_const_bytep trans, - int num_trans),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_do_expand,(png_row_infop row_info, - png_bytep row, png_const_color_16p trans_color),PNG_EMPTY); -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_expand_16,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* Decode the IHDR chunk */ -PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); - -#ifdef PNG_READ_bKGD_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_cHRM_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_gAMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_hIST_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#ifdef PNG_READ_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_oFFs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_pHYs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sBIT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sPLT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#ifdef PNG_READ_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tIME_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tRNS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr, - png_uint_32 chunk_name),PNG_EMPTY); - -#ifdef PNG_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); - /* This is the function that gets called for unknown chunks. The 'keep' - * argument is either non-zero for a known chunk that has been set to be - * handled as unknown or zero for an unknown chunk. By default the function - * just skips the chunk or errors out if it is critical. - */ - -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling, - (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY); - /* Exactly as the API png_handle_as_unknown() except that the argument is a - * 32-bit chunk name, not a string. - */ -#endif -#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ - -/* Handle the transformations for reading and writing */ -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); -#endif -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr), - PNG_EMPTY); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr, - png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr, - png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr, - png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, - png_bytep row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr), - PNG_EMPTY); -# ifdef PNG_READ_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif -# ifdef PNG_READ_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif -# ifdef PNG_READ_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_intrapixel,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_do_write_intrapixel,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -/* Added at libpng version 1.6.0 */ -#ifdef PNG_GAMMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY); - /* Set the colorspace gamma with a value provided by the application or by - * the gAMA chunk on read. The value will override anything set by an ICC - * profile. - */ - -PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, - png_inforp info_ptr), PNG_EMPTY); - /* Synchronize the info 'valid' flags with the colorspace */ - -PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, - png_inforp info_ptr), PNG_EMPTY); - /* Copy the png_struct colorspace to the info_struct and call the above to - * synchronize the flags. Checks for NULL info_ptr and does nothing. - */ -#endif - -/* Added at libpng version 1.4.0 */ -#ifdef PNG_COLORSPACE_SUPPORTED -/* These internal functions are for maintaining the colorspace structure within - * a png_info or png_struct (or, indeed, both). - */ -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities, - (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, - int preferred), PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints, - (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ, - int preferred), PNG_EMPTY); - -#ifdef PNG_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr, - png_colorspacerp colorspace, int intent), PNG_EMPTY); - /* This does set the colorspace gAMA and cHRM values too, but doesn't set the - * flags to write them, if it returns false there was a problem and an error - * message has already been output (but the colorspace may still need to be - * synced to record the invalid flag). - */ -#endif /* sRGB */ - -#ifdef PNG_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, png_const_bytep profile, int color_type), - PNG_EMPTY); - /* The 'name' is used for information only */ - -/* Routines for checking parts of an ICC profile. */ -PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length), PNG_EMPTY); -PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, - png_const_bytep profile /* first 132 bytes only */, int color_type), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY); -#ifdef PNG_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,( - png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_bytep profile, uLong adler), PNG_EMPTY); - /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may - * be zero to indicate that it is not available. It is used, if provided, - * as a fast check on the profile when checking to see if it is sRGB. - */ -#endif -#endif /* iCCP */ - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients, - (png_structrp png_ptr), PNG_EMPTY); - /* Set the rgb_to_gray coefficients from the colorspace Y values */ -#endif /* READ_RGB_TO_GRAY */ -#endif /* COLORSPACE */ - -/* Added at libpng version 1.4.0 */ -PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type),PNG_EMPTY); - -/* Added at libpng version 1.5.10 */ -#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ - defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes, - (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY); -#endif - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr, - png_const_charp name),PNG_NORETURN); -#endif - -/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite - * the end. Always leaves the buffer nul terminated. Never errors out (and - * there is no error code.) - */ -PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize, - size_t pos, png_const_charp string),PNG_EMPTY); - -/* Various internal functions to handle formatted warning messages, currently - * only implemented for warnings. - */ -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) -/* Utility to dump an unsigned value into a buffer, given a start pointer and - * and end pointer (which should point just *beyond* the end of the buffer!) - * Returns the pointer to the start of the formatted string. This utility only - * does unsigned values. - */ -PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start, - png_charp end, int format, png_alloc_size_t number),PNG_EMPTY); - -/* Convenience macro that takes an array: */ -#define PNG_FORMAT_NUMBER(buffer,format,number) \ - png_format_number(buffer, buffer + (sizeof buffer), format, number) - -/* Suggested size for a number buffer (enough for 64 bits and a sign!) */ -#define PNG_NUMBER_BUFFER_SIZE 24 - -/* These are the integer formats currently supported, the name is formed from - * the standard printf(3) format string. - */ -#define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */ -#define PNG_NUMBER_FORMAT_02u 2 -#define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */ -#define PNG_NUMBER_FORMAT_02d 2 -#define PNG_NUMBER_FORMAT_x 3 -#define PNG_NUMBER_FORMAT_02x 4 -#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */ -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* New defines and members adding in libpng-1.5.4 */ -# define PNG_WARNING_PARAMETER_SIZE 32 -# define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */ - -/* An l-value of this type has to be passed to the APIs below to cache the - * values of the parameters to a formatted warning message. - */ -typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][ - PNG_WARNING_PARAMETER_SIZE]; - -PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p, - int number, png_const_charp string),PNG_EMPTY); - /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters, - * including the trailing '\0'. - */ -PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned, - (png_warning_parameters p, int number, int format, png_alloc_size_t value), - PNG_EMPTY); - /* Use png_alloc_size_t because it is an unsigned type as big as any we - * need to output. Use the following for a signed value. - */ -PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed, - (png_warning_parameters p, int number, int format, png_int_32 value), - PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr, - png_warning_parameters p, png_const_charp message),PNG_EMPTY); - /* 'message' follows the X/Open approach of using @1, @2 to insert - * parameters previously supplied using the above functions. Errors in - * specifying the parameters will simply result in garbage substitutions. - */ -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Application errors (new in 1.6); use these functions (declared below) for - * errors in the parameters or order of API function calls on read. The - * 'warning' should be used for an error that can be handled completely; the - * 'error' for one which can be handled safely but which may lose application - * information or settings. - * - * By default these both result in a png_error call prior to release, while in a - * released version the 'warning' is just a warning. However if the application - * explicitly disables benign errors (explicitly permitting the code to lose - * information) they both turn into warnings. - * - * If benign errors aren't supported they end up as the corresponding base call - * (png_warning or png_error.) - */ -PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr, - png_const_charp message),PNG_EMPTY); - /* The application provided invalid parameters to an API function or called - * an API function at the wrong time, libpng can completely recover. - */ - -PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr, - png_const_charp message),PNG_EMPTY); - /* As above but libpng will ignore the call, or attempt some other partial - * recovery from the error. - */ -#else -# define png_app_warning(pp,s) png_warning(pp,s) -# define png_app_error(pp,s) png_error(pp,s) -#endif - -PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr, - png_const_charp message, int error),PNG_EMPTY); - /* Report a recoverable issue in chunk data. On read this is used to report - * a problem found while reading a particular chunk and the - * png_chunk_benign_error or png_chunk_warning function is used as - * appropriate. On write this is used to report an error that comes from - * data set via an application call to a png_set_ API and png_app_error or - * png_app_warning is used as appropriate. - * - * The 'error' parameter must have one of the following values: - */ -#define PNG_CHUNK_WARNING 0 /* never an error */ -#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */ -#define PNG_CHUNK_ERROR 2 /* always an error */ - -/* ASCII to FP interfaces, currently only implemented if sCAL - * support is required. - */ -#if defined(PNG_sCAL_SUPPORTED) -/* MAX_DIGITS is actually the maximum number of characters in an sCAL - * width or height, derived from the precision (number of significant - * digits - a build time settable option) and assumptions about the - * maximum ridiculous exponent. - */ -#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) - -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr, - png_charp ascii, png_size_t size, double fp, unsigned int precision), - PNG_EMPTY); -#endif /* FLOATING_POINT */ - -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, - png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY); -#endif /* FIXED_POINT */ -#endif /* sCAL */ - -#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) -/* An internal API to validate the format of a floating point number. - * The result is the index of the next character. If the number is - * not valid it will be the index of a character in the supposed number. - * - * The format of a number is defined in the PNG extensions specification - * and this API is strictly conformant to that spec, not anyone elses! - * - * The format as a regular expression is: - * - * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? - * - * or: - * - * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? - * - * The complexity is that either integer or fraction must be present and the - * fraction is permitted to have no digits only if the integer is present. - * - * NOTE: The dangling E problem. - * There is a PNG valid floating point number in the following: - * - * PNG floating point numbers are not greedy. - * - * Working this out requires *TWO* character lookahead (because of the - * sign), the parser does not do this - it will fail at the 'r' - this - * doesn't matter for PNG sCAL chunk values, but it requires more care - * if the value were ever to be embedded in something more complex. Use - * ANSI-C strtod if you need the lookahead. - */ -/* State table for the parser. */ -#define PNG_FP_INTEGER 0 /* before or in integer */ -#define PNG_FP_FRACTION 1 /* before or in fraction */ -#define PNG_FP_EXPONENT 2 /* before or in exponent */ -#define PNG_FP_STATE 3 /* mask for the above */ -#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */ -#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */ -#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */ -#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */ -#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */ - -/* These three values don't affect the parser. They are set but not used. - */ -#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */ -#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */ -#define PNG_FP_NONZERO 256 /* A non-zero value */ -#define PNG_FP_STICKY 448 /* The above three flags */ - -/* This is available for the caller to store in 'state' if required. Do not - * call the parser after setting it (the parser sometimes clears it.) - */ -#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ - -/* Result codes for the parser (boolean - true meants ok, false means - * not ok yet.) - */ -#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ -#define PNG_FP_OK 1 /* The number is valid */ - -/* Tests on the sticky non-zero and negative flags. To pass these checks - * the state must also indicate that the whole number is valid - this is - * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this - * is equivalent to PNG_FP_OK above.) - */ -#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO) - /* NZ_MASK: the string is valid and a non-zero negative value */ -#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO) - /* Z MASK: the string is valid and a non-zero value. */ - /* PNG_FP_SAW_DIGIT: the string is valid. */ -#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT) -#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK) -#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK) - -/* The actual parser. This can be called repeatedly. It updates - * the index into the string and the state variable (which must - * be initialized to 0). It returns a result code, as above. There - * is no point calling the parser any more if it fails to advance to - * the end of the string - it is stuck on an invalid character (or - * terminated by '\0'). - * - * Note that the pointer will consume an E or even an E+ and then leave - * a 'maybe' state even though a preceding integer.fraction is valid. - * The PNG_FP_WAS_VALID flag indicates that a preceding substring was - * a valid number. It's possible to recover from this by calling - * the parser again (from the start, with state 0) but with a string - * that omits the last character (i.e. set the size to the index of - * the problem character.) This has not been tested within libpng. - */ -PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, - png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); - -/* This is the same but it checks a complete string and returns true - * only if it just contains a floating point number. As of 1.5.4 this - * function also returns the state at the end of parsing the number if - * it was valid (otherwise it returns 0.) This can be used for testing - * for negative or zero values using the sticky flag. - */ -PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string, - png_size_t size),PNG_EMPTY); -#endif /* pCAL || sCAL */ - -#if defined(PNG_READ_GAMMA_SUPPORTED) ||\ - defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) -/* Added at libpng version 1.5.0 */ -/* This is a utility to provide a*times/div (rounded) and indicate - * if there is an overflow. The result is a boolean - false (0) - * for overflow, true (1) if no overflow, in which case *res - * holds the result. - */ -PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a, - png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) -/* Same deal, but issue a warning on overflow and return 0. */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn, - (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by, - png_int_32 divided_by),PNG_EMPTY); -#endif - -#ifdef PNG_GAMMA_SUPPORTED -/* Calculate a reciprocal - used for gamma values. This returns - * 0 if the argument is 0 in order to maintain an undefined value; - * there are no warnings. - */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a), - PNG_EMPTY); - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The same but gives a reciprocal of the product of two fixed point - * values. Accuracy is suitable for gamma calculations but this is - * not exact - use png_muldiv for that. Only required at present on read. - */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a, - png_fixed_point b),PNG_EMPTY); -#endif - -/* Return true if the gamma value is significantly different from 1.0 */ -PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value), - PNG_EMPTY); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* Internal fixed point gamma correction. These APIs are called as - * required to convert single values - they don't need to be fast, - * they are not used when processing image pixel values. - * - * While the input is an 'unsigned' value it must actually be the - * correct bit value - 0..255 or 0..65535 as required. - */ -PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr, - unsigned int value, png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value, - png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value, - png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr, - int bit_depth),PNG_EMPTY); -#endif - -/* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -/* The internal structure that png_image::opaque points to. */ -typedef struct png_control -{ - png_structp png_ptr; - png_infop info_ptr; - png_voidp error_buf; /* Always a jmp_buf at present. */ - - png_const_bytep memory; /* Memory buffer. */ - png_size_t size; /* Size of the memory buffer. */ - - unsigned int for_write :1; /* Otherwise it is a read structure */ - unsigned int owned_file :1; /* We own the file in io_ptr */ -} png_control; - -/* Return the pointer to the jmp_buf from a png_control: necessary because C - * does not reveal the type of the elements of jmp_buf. - */ -#ifdef __cplusplus -# define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0]) -#else -# define png_control_jmp_buf(pc) ((pc)->error_buf) -#endif - -/* Utility to safely execute a piece of libpng code catching and logging any - * errors that might occur. Returns true on success, false on failure (either - * of the function or as a result of a png_error.) - */ -PNG_INTERNAL_FUNCTION(void,png_safe_error,(png_structp png_ptr, - png_const_charp error_message),PNG_NORETURN); - -#ifdef PNG_WARNINGS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_safe_warning,(png_structp png_ptr, - png_const_charp warning_message),PNG_EMPTY); -#else -# define png_safe_warning 0/*dummy argument*/ -#endif - -PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image, - int (*function)(png_voidp), png_voidp arg),PNG_EMPTY); - -/* Utility to log an error; this also cleans up the png_image; the function - * always returns 0 (false). - */ -PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image, - png_const_charp error_message),PNG_EMPTY); - -#ifndef PNG_SIMPLIFIED_READ_SUPPORTED -/* png_image_free is used by the write code but not exported */ -PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY); -#endif /* !SIMPLIFIED_READ */ - -#endif /* SIMPLIFIED READ/WRITE */ - -#ifdef PNG_FILTER_OPTIMIZATIONS -PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, - unsigned int bpp), PNG_EMPTY); - /* This is the initialization function for hardware specific optimizations, - * one implementation (for ARM NEON machines) is contained in - * arm/filter_neon.c. It need not be defined - the generic code will be used - * if not. - */ -#endif - -/* Maintainer: Put new private prototypes here ^ */ - -#include "pngdebug.h" - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -#endif /* PNGPRIV_H */ diff --git a/Source/3rd Party/wx/src/png/pngread.c b/Source/3rd Party/wx/src/png/pngread.c index e32f31d54..22240227d 100644 --- a/Source/3rd Party/wx/src/png/pngread.c +++ b/Source/3rd Party/wx/src/png/pngread.c @@ -1,85 +1,307 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.1 [March 28, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file contains routines that an application calls directly to * read a PNG file or stream. */ -#include "pngpriv.h" -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) -# include -#endif - -#ifdef PNG_READ_SUPPORTED +#define PNG_INTERNAL +#include "png.h" /* Create a PNG structure for reading, and allocate any memory needed. */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) +png_structp PNGAPI +png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn) { -#ifndef PNG_USER_MEM_SUPPORTED - png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); -#else - return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); } -/* Alternate create PNG structure for reading, and allocate any memory - * needed. - */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) +/* Alternate create PNG structure for reading, and allocate any memory needed. */ +png_structp PNGAPI +png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr != NULL) + png_structp png_ptr; + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + + int i; + + png_debug(1, "in png_create_read_struct\n"); +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, + (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); +#else + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); +#endif + if (png_ptr == NULL) + return (NULL); + +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif /* PNG_1_0_X */ + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_ptr->jmpbuf)) +#endif { - png_ptr->mode = PNG_IS_READ_STRUCT; + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf=NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + return (NULL); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#endif +#endif - /* Added in libpng-1.6.0; this can be used to detect a read structure if - * required (it will be zero in a write structure.) - */ -# ifdef PNG_SEQUENTIAL_READ_SUPPORTED - png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE; -# endif +#ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); +#endif -# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; + png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - /* In stable builds only warn if an application error can be completely - * handled. - */ -# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC - png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; -# endif -# endif + i=0; + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); - /* TODO: delay this, it can be done in png_init_io (if the app doesn't - * do it itself) avoiding setting the default function if it is not - * required. - */ - png_set_read_fn(png_ptr, NULL, NULL); + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first digit. + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[80]; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); +#endif +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "Incompatible libpng version in application and library"); + } } - return png_ptr; + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); + +#ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then encounter + a png_error() will longjmp here. Since the jmpbuf is then meaningless we + abort instead of returning. */ +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) + PNG_ABORT(); + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#else + if (setjmp(png_ptr->jmpbuf)) + PNG_ABORT(); +#endif +#endif + return (png_ptr); } +/* Initialize PNG structure for reading, and allocate any memory needed. + This interface is deprecated in favour of the png_create_read_struct(), + and it will eventually disappear. */ +#undef png_read_init +void PNGAPI +png_read_init(png_structp png_ptr) +{ + /* We only come here via pre-1.0.7-compiled applications */ + png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); +} -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +void PNGAPI +png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size, png_size_t png_info_size) +{ + /* We only come here via pre-1.0.12-compiled applications */ +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + if(png_sizeof(png_struct) > png_struct_size || + png_sizeof(png_info) > png_info_size) + { + char msg[80]; + png_ptr->warning_fn=NULL; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); + } +#endif + if(png_sizeof(png_struct) > png_struct_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The png struct allocated by the application for reading is too small."); + } + if(png_sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The info struct allocated by application for reading is too small."); + } + png_read_init_3(&png_ptr, user_png_ver, png_struct_size); +} + +void PNGAPI +png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* to save current jump buffer */ +#endif + + int i=0; + + png_structp png_ptr=*ptr_ptr; + + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + { +#ifdef PNG_LEGACY_SUPPORTED + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; +#else + png_ptr->warning_fn=NULL; + png_warning(png_ptr, + "Application uses deprecated png_read_init() and should be recompiled."); + break; +#endif + } + } while (png_libpng_ver[i++]); + + png_debug(1, "in png_read_init_3\n"); + +#ifdef PNG_SETJMP_SUPPORTED + /* save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + if(png_sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + png_ptr = *ptr_ptr; + } + + /* reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof (png_struct)); + +#ifdef PNG_SETJMP_SUPPORTED + /* restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); +} + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. This has been * changed in v0.90 to allow reading a file that already has the magic * bytes read from the stream. You can tell libpng how many bytes have @@ -89,294 +311,292 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, * read if it is determined that this isn't a valid PNG file. */ void PNGAPI -png_read_info(png_structrp png_ptr, png_inforp info_ptr) +png_read_info(png_structp png_ptr, png_infop info_ptr) { -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; -#endif - - png_debug(1, "in png_read_info"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Read and check the PNG file signature. */ - png_read_sig(png_ptr, info_ptr); - - for (;;) + png_debug(1, "in png_read_info\n"); + /* If we haven't checked all of the PNG signature bytes, do so now. */ + if (png_ptr->sig_bytes < 8) { - png_uint_32 length = png_read_chunk_header(png_ptr); - png_uint_32 chunk_name = png_ptr->chunk_name; + png_size_t num_checked = png_ptr->sig_bytes, + num_to_check = 8 - num_checked; - /* IDAT logic needs to happen here to simplify getting the two flags - * right. - */ - if (chunk_name == png_IDAT) + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); + png_ptr->sig_bytes = 8; + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "Missing IHDR before IDAT"); - - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_chunk_error(png_ptr, "Missing PLTE before IDAT"); - - else if (png_ptr->mode & PNG_AFTER_IDAT) - png_chunk_benign_error(png_ptr, "Too many IDATs found"); - - png_ptr->mode |= PNG_HAVE_IDAT; + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } + if (num_checked < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; + } - else if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; + for(;;) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_GLOBAL_ARRAYS */ + png_byte chunk_length[4]; + png_uint_32 length; + + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, + length); /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. */ - if (chunk_name == png_IHDR) + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - - else if (chunk_name == png_IEND) + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); - #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { - png_handle_unknown(png_ptr, info_ptr, length, keep); - - if (chunk_name == png_PLTE) + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; - - else if (chunk_name == png_IDAT) + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { - png_ptr->idat_size = 0; /* It has been consumed */ + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); break; } } #endif - else if (chunk_name == png_PLTE) + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); - - else if (chunk_name == png_IDAT) + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + png_ptr->idat_size = length; + png_ptr->mode |= PNG_HAVE_IDAT; break; } - -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_cHRM_SUPPORTED - else if (chunk_name == png_cHRM) +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (chunk_name == png_gAMA) +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sBIT_SUPPORTED - else if (chunk_name == png_sBIT) +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_iCCP_SUPPORTED - else if (chunk_name == png_iCCP) +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif - else - png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + png_handle_unknown(png_ptr, info_ptr, length); } } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -/* Optional call to update the users info_ptr structure */ +/* optional call to update the users info_ptr structure */ void PNGAPI -png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) +png_read_update_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_update_info"); - - if (png_ptr != NULL) - { - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - { - png_read_start_row(png_ptr); - -# ifdef PNG_READ_TRANSFORMS_SUPPORTED - png_read_transform_info(png_ptr, info_ptr); -# else - PNG_UNUSED(info_ptr) -# endif - } - - /* New in 1.6.0 this avoids the bug of doing the initializations twice */ - else - png_app_error(png_ptr, - "png_read_update_info/png_start_read_image: duplicate call"); - } + png_debug(1, "in png_read_update_info\n"); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); + else + png_warning(png_ptr, + "Ignoring extra png_read_update_info() call; row buffer not reallocated"); + png_read_transform_info(png_ptr, info_ptr); } -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Initialize palette, background, etc, after transformations * are set, but before any reading takes place. This allows * the user to obtain a gamma-corrected palette, for example. * If the user doesn't call this, we will do it ourselves. */ void PNGAPI -png_start_read_image(png_structrp png_ptr) +png_start_read_image(png_structp png_ptr) { - png_debug(1, "in png_start_read_image"); - - if (png_ptr != NULL) - { - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - png_read_start_row(png_ptr); - - /* New in 1.6.0 this avoids the bug of doing the initializations twice */ - else - png_app_error(png_ptr, - "png_start_read_image/png_read_update_info: duplicate call"); - } -} -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -void PNGAPI -png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) -{ - png_row_info row_info; - - if (png_ptr == NULL) - return; - - png_debug2(1, "in png_read_row (row %lu, pass %d)", - (unsigned long)png_ptr->row_number, png_ptr->pass); - - /* png_read_start_row sets the information (in particular iwidth) for this - * interlace pass. - */ + png_debug(1, "in png_start_read_image\n"); if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); +} +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - /* 1.5.6: row_info moved out of png_struct to a local here. */ - row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ - row_info.color_type = png_ptr->color_type; - row_info.bit_depth = png_ptr->bit_depth; - row_info.channels = png_ptr->channels; - row_info.pixel_depth = png_ptr->pixel_depth; - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +void PNGAPI +png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; + const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; +#endif + int ret; + png_debug2(1, "in png_read_row (row %lu, pass %d)\n", + png_ptr->row_number, png_ptr->pass); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* Check for transforms that have been set but were defined out */ + /* check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); #endif - #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); #endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ - !defined(PNG_READ_PACKSWAP_SUPPORTED) +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); #endif - #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); #endif - #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); #endif - #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); #endif - #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); #endif } -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* If interlaced and we do not need a new row, combine row and return. - * Notice that the pixels we have from previous rows have been transformed - * already; we can only combine like with like (transformed or - * untransformed) and, because of the libpng API for interlaced images, this - * means we must transform before de-interlacing. - */ +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* if interlaced and we do not need a new row, combine row and return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -385,68 +605,62 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) if (png_ptr->row_number & 0x07) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - case 1: if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - case 2: if ((png_ptr->row_number & 0x07) != 4) { if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - case 3: if ((png_ptr->row_number & 3) || png_ptr->width < 3) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - case 4: if ((png_ptr->row_number & 3) != 2) { if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - case 5: if ((png_ptr->row_number & 1) || png_ptr->width < 2) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; - - default: case 6: if (!(png_ptr->row_number & 1)) { @@ -461,85 +675,113 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "Invalid attempt to read row data"); - /* Fill the row with IDAT data: */ - png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); - - if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) + png_ptr->zstream.next_out = png_ptr->row_buf; + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + do { - if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) - png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); - else - png_error(png_ptr, "bad adaptive filter value"); - } + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; - /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before - * 1.5.6, while the buffer really is this big in current versions of libpng - * it may not be in the future, so this was changed just to copy the - * interlaced count: - */ - memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); + png_crc_finish(png_ptr, 0); -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, + (png_size_t)png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_error(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression error"); + + } while (png_ptr->zstream.avail_out); + + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + if(png_ptr->row_buf[0]) + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ - png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1); + png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); } #endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED if (png_ptr->transformations) - png_do_read_transformations(png_ptr, &row_info); -#endif + png_do_read_transformations(png_ptr); - /* The transformed pixel depth should match the depth now in row_info. */ - if (png_ptr->transformed_pixel_depth == 0) - { - png_ptr->transformed_pixel_depth = row_info.pixel_depth; - if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) - png_error(png_ptr, "sequential row overflow"); - } - - else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) - png_error(png_ptr, "internal sequential row size calculation error"); - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Blow up interlaced rows to full size */ +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) - png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); if (row != NULL) - png_combine_row(png_ptr, row, 0/*row*/); + png_combine_row(png_ptr, row, + png_pass_mask[png_ptr->pass]); } - else #endif { if (row != NULL) - png_combine_row(png_ptr, row, -1/*ignored*/); - + png_combine_row(png_ptr, row, 0xff); if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, -1/*ignored*/); + png_combine_row(png_ptr, dsp_row, 0xff); } png_read_finish_row(png_ptr); if (png_ptr->read_row_fn != NULL) (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); - } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. If the image is interlaced, * and png_set_interlace_handling() has been called, the rows need to * contain the contents of the rows from the previous pass. If the @@ -561,22 +803,18 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) * not called png_set_interlace_handling(), the display_row buffer will * be ignored, so pass NULL to it. * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7 */ void PNGAPI -png_read_rows(png_structrp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) +png_read_rows(png_structp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows) { png_uint_32 i; png_bytepp rp; png_bytepp dp; - png_debug(1, "in png_read_rows"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_read_rows\n"); rp = row; dp = display_row; if (rp != NULL && dp != NULL) @@ -587,26 +825,24 @@ png_read_rows(png_structrp png_ptr, png_bytepp row, png_read_row(png_ptr, rptr, dptr); } - - else if (rp != NULL) + else if(rp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, NULL); + png_read_row(png_ptr, rptr, png_bytep_NULL); rp++; } - - else if (dp != NULL) + else if(dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; - png_read_row(png_ptr, NULL, dptr); + png_read_row(png_ptr, png_bytep_NULL, dptr); dp++; } } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the entire image. If the image has an alpha channel or a tRNS * chunk, and you have called png_handle_alpha()[*], you will need to * initialize the image to the current image that PNG will be overlaying. @@ -617,366 +853,488 @@ png_read_rows(png_structrp png_ptr, png_bytepp row, * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7 */ void PNGAPI -png_read_image(png_structrp png_ptr, png_bytepp image) +png_read_image(png_structp png_ptr, png_bytepp image) { - png_uint_32 i, image_height; + png_uint_32 i,image_height; int pass, j; png_bytepp rp; - png_debug(1, "in png_read_image"); - - if (png_ptr == NULL) - return; + png_debug(1, "in png_read_image\n"); #ifdef PNG_READ_INTERLACING_SUPPORTED - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - { - pass = png_set_interlace_handling(png_ptr); - /* And make sure transforms are initialized. */ - png_start_read_image(png_ptr); - } - else - { - if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE)) - { - /* Caller called png_start_read_image or png_read_update_info without - * first turning on the PNG_INTERLACE transform. We can fix this here, - * but the caller should do it! - */ - png_warning(png_ptr, "Interlace handling should be turned on when " - "using png_read_image"); - /* Make sure this is set correctly */ - png_ptr->num_rows = png_ptr->height; - } - - /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in - * the above error case. - */ - pass = png_set_interlace_handling(png_ptr); - } + pass = png_set_interlace_handling(png_ptr); #else if (png_ptr->interlaced) png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled"); - + "Cannot read interlaced image -- interlace handler disabled."); pass = 1; #endif + image_height=png_ptr->height; + png_ptr->num_rows = image_height; /* Make sure this is set correctly */ for (j = 0; j < pass; j++) { rp = image; for (i = 0; i < image_height; i++) { - png_read_row(png_ptr, *rp, NULL); + png_read_row(png_ptr, *rp, png_bytep_NULL); rp++; } } } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. Will not read past the end of the * file, will verify the end is accurate, and will read any comments * or time information at the end of the file, if info is not NULL. */ void PNGAPI -png_read_end(png_structrp png_ptr, png_inforp info_ptr) +png_read_end(png_structp png_ptr, png_infop info_ptr) { -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; -#endif + png_byte chunk_length[4]; + png_uint_32 length; - png_debug(1, "in png_read_end"); - - if (png_ptr == NULL) - return; - - /* If png_read_end is called in the middle of reading the rows there may - * still be pending IDAT data and an owned zstream. Deal with this here. - */ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - if (!png_chunk_unknown_handling(png_ptr, png_IDAT)) -#endif - png_read_finish_IDAT(png_ptr); - -#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Report invalid palette index; added at libng-1.5.10 */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Read palette index exceeding num_palette"); -#endif + png_debug(1, "in png_read_end\n"); + png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do { - png_uint_32 length = png_read_chunk_header(png_ptr); - png_uint_32 chunk_name = png_ptr->chunk_name; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_GLOBAL_ARRAYS */ - if (chunk_name == png_IHDR) + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_31(png_ptr,chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); + + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - - else if (chunk_name == png_IEND) + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); - #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { - if (chunk_name == png_IDAT) + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_benign_error(png_ptr, "Too many IDATs found"); + if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); } - png_handle_unknown(png_ptr, info_ptr, length, keep); - if (chunk_name == png_PLTE) + else + png_ptr->mode |= PNG_AFTER_IDAT; + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; } #endif - - else if (chunk_name == png_IDAT) + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. */ - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_benign_error(png_ptr, "Too many IDATs found"); - + if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); png_crc_finish(png_ptr, length); } - else if (chunk_name == png_PLTE) + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); - -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_cHRM_SUPPORTED - else if (chunk_name == png_cHRM) +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (chunk_name == png_gAMA) +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sBIT_SUPPORTED - else if (chunk_name == png_sBIT) +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_iCCP_SUPPORTED - else if (chunk_name == png_iCCP) +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif - -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif - else - png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + png_handle_unknown(png_ptr, info_ptr, length); } while (!(png_ptr->mode & PNG_HAVE_IEND)); } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -/* Free all memory used in the read struct */ -static void -png_read_destroy(png_structrp png_ptr) +/* free all memory used by the read */ +void PNGAPI +png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, + png_infopp end_info_ptr_ptr) { - png_debug(1, "in png_read_destroy"); - -#ifdef PNG_READ_GAMMA_SUPPORTED - png_destroy_gamma_table(png_ptr); + png_structp png_ptr = NULL; + png_infop info_ptr = NULL, end_info_ptr = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; + png_voidp mem_ptr; #endif + png_debug(1, "in png_destroy_read_struct\n"); + if (png_ptr_ptr != NULL) + png_ptr = *png_ptr_ptr; + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (end_info_ptr_ptr != NULL) + end_info_ptr = *end_info_ptr_ptr; + +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; +#endif + + png_read_destroy(png_ptr, info_ptr, end_info_ptr); + + if (info_ptr != NULL) + { +#if defined(PNG_TEXT_SUPPORTED) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } + + if (end_info_ptr != NULL) + { +#if defined(PNG_READ_TEXT_SUPPORTED) + png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); +#endif +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)end_info_ptr); +#endif + *end_info_ptr_ptr = NULL; + } + + if (png_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + *png_ptr_ptr = NULL; + } +} + +/* free all memory used by the read (old method) */ +void /* PRIVATE */ +png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; +#endif + png_error_ptr error_fn; + png_error_ptr warning_fn; + png_voidp error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; +#endif + + png_debug(1, "in png_read_destroy\n"); + if (info_ptr != NULL) + png_info_destroy(png_ptr, info_ptr); + + if (end_info_ptr != NULL) + png_info_destroy(png_ptr, end_info_ptr); + + png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->big_prev_row); - png_free(png_ptr, png_ptr->read_buffer); - -#ifdef PNG_READ_QUANTIZE_SUPPORTED + png_free(png_ptr, png_ptr->prev_row); +#if defined(PNG_READ_DITHER_SUPPORTED) png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->quantize_index); + png_free(png_ptr, png_ptr->dither_index); #endif - +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_table); +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_from_1); + png_free(png_ptr, png_ptr->gamma_to_1); +#endif +#ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_PLTE) png_zfree(png_ptr, png_ptr->palette); png_ptr->free_me &= ~PNG_FREE_PLTE; - +#else + if (png_ptr->flags & PNG_FLAG_FREE_PLTE) + png_zfree(png_ptr, png_ptr->palette); + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif #if defined(PNG_tRNS_SUPPORTED) || \ defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans_alpha); + png_free(png_ptr, png_ptr->trans); png_ptr->free_me &= ~PNG_FREE_TRNS; +#else + if (png_ptr->flags & PNG_FLAG_FREE_TRNS) + png_free(png_ptr, png_ptr->trans); + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif +#endif +#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->free_me &= ~PNG_FREE_HIST; +#else + if (png_ptr->flags & PNG_FLAG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->gamma_16_table != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_table[i]); + } + png_free(png_ptr, png_ptr->gamma_16_table); + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_from_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_from_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_from_1); + } + if (png_ptr->gamma_16_to_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_to_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_to_1); + } +#endif +#endif +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_free(png_ptr, png_ptr->time_buffer); #endif inflateEnd(&png_ptr->zstream); - #ifdef PNG_PROGRESSIVE_READ_SUPPORTED png_free(png_ptr, png_ptr->save_buffer); #endif -#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free(png_ptr, png_ptr->unknown_chunk.data); +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +#ifdef PNG_TEXT_SUPPORTED + png_free(png_ptr, png_ptr->current_text); +#endif /* PNG_TEXT_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + + /* Save the important info out of the png_struct, in case it is + * being used again. + */ +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); #endif -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - png_free(png_ptr, png_ptr->chunk_list); + error_fn = png_ptr->error_fn; + warning_fn = png_ptr->warning_fn; + error_ptr = png_ptr->error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; #endif - /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error - * callbacks are still set at this point. They are required to complete the - * destruction of the png_struct itself. - */ -} + png_memset(png_ptr, 0, png_sizeof (png_struct)); -/* Free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structrp png_ptr = NULL; + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; + png_ptr->error_ptr = error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr->free_fn = free_fn; +#endif - png_debug(1, "in png_destroy_read_struct"); +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (png_ptr == NULL) - return; - - /* libpng 1.6.0: use the API to destroy info structs to ensure consistent - * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API. - * The extra was, apparently, unnecessary yet this hides memory leak bugs. - */ - png_destroy_info_struct(png_ptr, end_info_ptr_ptr); - png_destroy_info_struct(png_ptr, info_ptr_ptr); - - *png_ptr_ptr = NULL; - png_read_destroy(png_ptr); - png_destroy_png_struct(png_ptr); } void PNGAPI -png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) +png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) { - if (png_ptr == NULL) - return; - png_ptr->read_row_fn = read_row_fn; } -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -#ifdef PNG_INFO_IMAGE_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI -png_read_png(png_structrp png_ptr, png_inforp info_ptr, +png_read_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params) { int row; - if (png_ptr == NULL || info_ptr == NULL) - return; +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel from opacity to transparency + */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif /* png_read_info() gives us all of the information from the * PNG file before the first IDAT (image data chunk). */ png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep))) - png_error(png_ptr, "Image is too high to process with png_read_png()"); + if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error(png_ptr,"Image is too high to process with png_read_png()"); /* -------------- image transformations start here ------------------- */ -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - /* Tell libpng to strip 16-bit/color files down to 8 bits per color. - */ - if (transforms & PNG_TRANSFORM_SCALE_16) - { - /* Added at libpng-1.5.4. "strip_16" produces the same result that it - * did in earlier versions, while "scale_16" is now more accurate. - */ - png_set_scale_16(png_ptr); - } -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - /* If both SCALE and STRIP are required pngrtran will effectively cancel the - * latter by doing SCALE first. This is ok and allows apps not to check for - * which is supported to get the right answer. +#if defined(PNG_READ_16_TO_8_SUPPORTED) + /* tell libpng to strip 16 bit/color files down to 8 bits per color */ if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); + png_set_strip_16(png_ptr); #endif -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) /* Strip alpha bytes from the input data without combining with * the background (not recommended). */ if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); + png_set_strip_alpha(png_ptr); #endif #if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) @@ -984,41 +1342,41 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, * byte into separate bytes (useful for paletted and grayscale images). */ if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); + png_set_packing(png_ptr); #endif -#ifdef PNG_READ_PACKSWAP_SUPPORTED +#if defined(PNG_READ_PACKSWAP_SUPPORTED) /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); + png_set_packswap(png_ptr); #endif -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand paletted colors into true RGB triplets * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel * Expand paletted or RGB images with transparency to full alpha * channels so the data will be available as RGBA quartets. */ if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) + if ((png_ptr->bit_depth < 8) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) png_set_expand(png_ptr); #endif - /* We don't handle background color or gamma transformation or quantizing. + /* We don't handle background color or gamma transformation or dithering. */ -#ifdef PNG_READ_INVERT_SUPPORTED - /* Invert monochrome files to have 0 as white and 1 as black +#if defined(PNG_READ_INVERT_SUPPORTED) + /* invert monochrome files to have 0 as white and 1 as black */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif -#ifdef PNG_READ_SHIFT_SUPPORTED +#if defined(PNG_READ_SHIFT_SUPPORTED) /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: @@ -1033,51 +1391,29 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, } #endif -#ifdef PNG_READ_BGR_SUPPORTED - /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ +#if defined(PNG_READ_BGR_SUPPORTED) + /* flip the RGB pixels to BGR (or RGBA to BGRA) + */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED - /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) + */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); + png_set_swap_alpha(png_ptr); #endif -#ifdef PNG_READ_SWAP_SUPPORTED - /* Swap bytes of 16-bit files to least significant byte first */ +#if defined(PNG_READ_SWAP_SUPPORTED) + /* swap bytes of 16 bit files to least significant byte first + */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -/* Added at libpng-1.2.41 */ -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - /* Invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - -/* Added at libpng-1.2.41 */ -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* Expand grayscale image to RGB */ - if (transforms & PNG_TRANSFORM_GRAY_TO_RGB) - png_set_gray_to_rgb(png_ptr); -#endif - -/* Added at libpng-1.5.4 */ -#ifdef PNG_READ_EXPAND_16_SUPPORTED - if (transforms & PNG_TRANSFORM_EXPAND_16) - png_set_expand_16(png_ptr); + png_set_swap(png_ptr); #endif /* We don't handle adding filler bytes */ - /* We use png_read_image and rely on that for interlace handling, but we also - * call png_read_update_info therefore must turn on interlace handling now: - */ - (void)png_set_interlace_handling(png_ptr); - /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to * update the palette for you (i.e., you selected such a transform above). @@ -1086,2915 +1422,32 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* -------------- image transformations end here ------------------- */ +#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - if (info_ptr->row_pointers == NULL) +#endif + if(info_ptr->row_pointers == NULL) { - png_uint_32 iptr; - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * (sizeof (png_bytep))); - for (iptr=0; iptrheight; iptr++) - info_ptr->row_pointers[iptr] = NULL; - + info_ptr->height * png_sizeof(png_bytep)); +#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; - +#endif for (row = 0; row < (int)info_ptr->height; row++) + { info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + } } png_read_image(png_ptr, info_ptr->row_pointers); info_ptr->valid |= PNG_INFO_IDAT; - /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); - PNG_UNUSED(transforms) /* Quiet compiler warnings */ - PNG_UNUSED(params) + if(transforms == 0 || params == NULL) + /* quiet compiler warnings */ return; } -#endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* SIMPLIFIED READ - * - * This code currently relies on the sequential reader, though it could easily - * be made to work with the progressive one. - */ -/* Arguments to png_image_finish_read: */ - -/* Encoding of PNG data (used by the color-map code) */ -/* TODO: change these, dang, ANSI-C reserves the 'E' namespace. */ -# define E_NOTSET 0 /* File encoding not yet known */ -# define E_sRGB 1 /* 8-bit encoded to sRGB gamma */ -# define E_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */ -# define E_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */ -# define E_LINEAR8 4 /* 8-bit linear: only from a file value */ - -/* Color-map processing: after libpng has run on the PNG image further - * processing may be needed to conver the data to color-map indicies. - */ -#define PNG_CMAP_NONE 0 -#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */ -#define PNG_CMAP_TRANS 2 /* Process GA data to a background index */ -#define PNG_CMAP_RGB 3 /* Process RGB data */ -#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */ - -/* The following document where the background is for each processing case. */ -#define PNG_CMAP_NONE_BACKGROUND 256 -#define PNG_CMAP_GA_BACKGROUND 231 -#define PNG_CMAP_TRANS_BACKGROUND 254 -#define PNG_CMAP_RGB_BACKGROUND 256 -#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216 - -typedef struct -{ - /* Arguments: */ - png_imagep image; - png_voidp buffer; - png_int_32 row_stride; - png_voidp colormap; - png_const_colorp background; - /* Local variables: */ - png_voidp local_row; - png_voidp first_row; - ptrdiff_t row_bytes; /* step between rows */ - int file_encoding; /* E_ values above */ - png_fixed_point gamma_to_linear; /* For E_FILE, reciprocal of gamma */ - int colormap_processing; /* PNG_CMAP_ values above */ -} png_image_read_control; - -/* Do all the *safe* initialization - 'safe' means that png_error won't be - * called, so setting up the jmp_buf is not required. This means that anything - * called from here must *not* call png_malloc - it has to call png_malloc_warn - * instead so that control is returned safely back to this routine. - */ -static int -png_image_read_init(png_imagep image) -{ - if (image->opaque == NULL) - { - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image, - png_safe_error, png_safe_warning); - - /* And set the rest of the structure to NULL to ensure that the various - * fields are consistent. - */ - memset(image, 0, (sizeof *image)); - image->version = PNG_IMAGE_VERSION; - - if (png_ptr != NULL) - { - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (info_ptr != NULL) - { - png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); - - if (control != NULL) - { - memset(control, 0, (sizeof *control)); - - control->png_ptr = png_ptr; - control->info_ptr = info_ptr; - control->for_write = 0; - - image->opaque = control; - return 1; - } - - /* Error clean up */ - png_destroy_info_struct(png_ptr, &info_ptr); - } - - png_destroy_read_struct(&png_ptr, NULL, NULL); - } - - return png_image_error(image, "png_image_read: out of memory"); - } - - return png_image_error(image, "png_image_read: opaque pointer not NULL"); -} - -/* Utility to find the base format of a PNG file from a png_struct. */ -static png_uint_32 -png_image_format(png_structrp png_ptr) -{ - png_uint_32 format = 0; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - format |= PNG_FORMAT_FLAG_COLOR; - - if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) - format |= PNG_FORMAT_FLAG_ALPHA; - - /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS - * sets the png_struct fields; that's all we are interested in here. The - * precise interaction with an app call to png_set_tRNS and PNG file reading - * is unclear. - */ - else if (png_ptr->num_trans > 0) - format |= PNG_FORMAT_FLAG_ALPHA; - - if (png_ptr->bit_depth == 16) - format |= PNG_FORMAT_FLAG_LINEAR; - - if (png_ptr->color_type & PNG_COLOR_MASK_PALETTE) - format |= PNG_FORMAT_FLAG_COLORMAP; - - return format; -} - -/* Is the given gamma significantly different from sRGB? The test is the same - * one used in pngrtran.c when deciding whether to do gamma correction. The - * arithmetic optimizes the division by using the fact that the inverse of the - * file sRGB gamma is 2.2 - */ -static int -png_gamma_not_sRGB(png_fixed_point g) -{ - if (g < PNG_FP_1) - { - /* An uninitialized gamma is assumed to be sRGB for the simplified API. */ - if (g == 0) - return 0; - - return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */); - } - - return 1; -} - -/* Do the main body of a 'png_image_begin_read' function; read the PNG file - * header and fill in all the information. This is executed in a safe context, - * unlike the init routine above. - */ -static int -png_image_read_header(png_voidp argument) -{ - png_imagep image = png_voidcast(png_imagep, argument); - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - - png_set_benign_errors(png_ptr, 1/*warn*/); - png_read_info(png_ptr, info_ptr); - - /* Do this the fast way; just read directly out of png_struct. */ - image->width = png_ptr->width; - image->height = png_ptr->height; - - { - png_uint_32 format = png_image_format(png_ptr); - - image->format = format; - -#ifdef PNG_COLORSPACE_SUPPORTED - /* Does the colorspace match sRGB? If there is no color endpoint - * (colorant) information assume yes, otherwise require the - * 'ENDPOINTS_MATCHE_sRGB' colorspace flag to have been set. If the - * colorspace has been determined to be invalid ignore it. - */ - if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags - & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB| - PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS)) - image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB; #endif - } - - /* We need the maximum number of entries regardless of the format the - * application sets here. - */ - { - png_uint_32 cmap_entries; - - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - cmap_entries = 1U << png_ptr->bit_depth; - break; - - case PNG_COLOR_TYPE_PALETTE: - cmap_entries = png_ptr->num_palette; - break; - - default: - cmap_entries = 256; - break; - } - - if (cmap_entries > 256) - cmap_entries = 256; - - image->colormap_entries = cmap_entries; - } - - return 1; -} - -#ifdef PNG_STDIO_SUPPORTED -int PNGAPI -png_image_begin_read_from_stdio(png_imagep image, FILE* file) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file != NULL) - { - if (png_image_read_init(image)) - { - /* This is slightly evil, but png_init_io doesn't do anything other - * than this and we haven't changed the standard IO functions so - * this saves a 'safe' function. - */ - image->opaque->png_ptr->io_ptr = file; - return png_safe_execute(image, png_image_read_header, image); - } - } - - else - return png_image_error(image, - "png_image_begin_read_from_stdio: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); - - return 0; -} - -int PNGAPI -png_image_begin_read_from_file(png_imagep image, const char *file_name) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file_name != NULL) - { - FILE *fp = fopen(file_name, "rb"); - - if (fp != NULL) - { - if (png_image_read_init(image)) - { - image->opaque->png_ptr->io_ptr = fp; - image->opaque->owned_file = 1; - return png_safe_execute(image, png_image_read_header, image); - } - - /* Clean up: just the opened file. */ - (void)fclose(fp); - } - - else - return png_image_error(image, strerror(errno)); - } - - else - return png_image_error(image, - "png_image_begin_read_from_file: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); - - return 0; -} -#endif /* PNG_STDIO_SUPPORTED */ - -static void PNGCBAPI -png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) -{ - if (png_ptr != NULL) - { - png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr); - if (image != NULL) - { - png_controlp cp = image->opaque; - if (cp != NULL) - { - png_const_bytep memory = cp->memory; - png_size_t size = cp->size; - - if (memory != NULL && size >= need) - { - memcpy(out, memory, need); - cp->memory = memory + need; - cp->size = size - need; - return; - } - - png_error(png_ptr, "read beyond end of data"); - } - } - - png_error(png_ptr, "invalid memory read"); - } -} - -int PNGAPI png_image_begin_read_from_memory(png_imagep image, - png_const_voidp memory, png_size_t size) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (memory != NULL && size > 0) - { - if (png_image_read_init(image)) - { - /* Now set the IO functions to read from the memory buffer and - * store it into io_ptr. Again do this in-place to avoid calling a - * libpng function that requires error handling. - */ - image->opaque->memory = png_voidcast(png_const_bytep, memory); - image->opaque->size = size; - image->opaque->png_ptr->io_ptr = image; - image->opaque->png_ptr->read_data_fn = png_image_memory_read; - - return png_safe_execute(image, png_image_read_header, image); - } - } - - else - return png_image_error(image, - "png_image_begin_read_from_memory: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); - - return 0; -} - -/* Utility function to skip chunks that are not used by the simplified image - * read functions and an appropriate macro to call it. - */ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -static void -png_image_skip_unused_chunks(png_structrp png_ptr) -{ - /* Prepare the reader to ignore all recognized chunks whose data will not - * be used, i.e., all chunks recognized by libpng except for those - * involved in basic image reading: - * - * IHDR, PLTE, IDAT, IEND - * - * Or image data handling: - * - * tRNS, bKGD, gAMA, cHRM, sRGB, iCCP and sBIT. - * - * This provides a small performance improvement and eliminates any - * potential vulnerability to security problems in the unused chunks. - */ - { - static PNG_CONST png_byte chunks_to_process[] = { - 98, 75, 71, 68, '\0', /* bKGD */ - 99, 72, 82, 77, '\0', /* cHRM */ - 103, 65, 77, 65, '\0', /* gAMA */ - 105, 67, 67, 80, '\0', /* iCCP */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 82, 71, 66, '\0', /* sRGB */ - }; - - /* Ignore unknown chunks and all other chunks except for the - * IHDR, PLTE, tRNS, IDAT, and IEND chunks. - */ - png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, - NULL, -1); - - /* But do not ignore image data handling chunks */ - png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, - chunks_to_process, (sizeof chunks_to_process)/5); - } -} - -# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) -#else -# define PNG_SKIP_CHUNKS(p) ((void)0) -#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */ - -/* The following macro gives the exact rounded answer for all values in the - * range 0..255 (it actually divides by 51.2, but the rounding still generates - * the correct numbers 0..5 - */ -#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8) - -/* Utility functions to make particular color-maps */ -static void -set_file_encoding(png_image_read_control *display) -{ - png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma; - if (png_gamma_significant(g)) - { - if (png_gamma_not_sRGB(g)) - { - display->file_encoding = E_FILE; - display->gamma_to_linear = png_reciprocal(g); - } - - else - display->file_encoding = E_sRGB; - } - - else - display->file_encoding = E_LINEAR8; -} - -static unsigned int -decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) -{ - if (encoding == E_FILE) /* double check */ - encoding = display->file_encoding; - - if (encoding == E_NOTSET) /* must be the file encoding */ - { - set_file_encoding(display); - encoding = display->file_encoding; - } - - switch (encoding) - { - case E_FILE: - value = png_gamma_16bit_correct(value*257, display->gamma_to_linear); - break; - - case E_sRGB: - value = png_sRGB_table[value]; - break; - - case E_LINEAR: - break; - - case E_LINEAR8: - value *= 257; - break; - - default: - png_error(display->image->opaque->png_ptr, - "unexpected encoding (internal error)"); - break; - } - - return value; -} - -static png_uint_32 -png_colormap_compose(png_image_read_control *display, - png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, - png_uint_32 background, int encoding) -{ - /* The file value is composed on the background, the background has the given - * encoding and so does the result, the file is encoded with E_FILE and the - * file and alpha are 8-bit values. The (output) encoding will always be - * E_LINEAR or E_sRGB. - */ - png_uint_32 f = decode_gamma(display, foreground, foreground_encoding); - png_uint_32 b = decode_gamma(display, background, encoding); - - /* The alpha is always an 8-bit value (it comes from the palette), the value - * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires. - */ - f = f * alpha + b * (255-alpha); - - if (encoding == E_LINEAR) - { - /* Scale to 65535; divide by 255, approximately (in fact this is extremely - * accurate, it divides by 255.00000005937181414556, with no overflow.) - */ - f *= 257; /* Now scaled by 65535 */ - f += f >> 16; - f = (f+32768) >> 16; - } - - else /* E_sRGB */ - f = PNG_sRGB_FROM_LINEAR(f); - - return f; -} - -/* NOTE: E_LINEAR values to this routine must be 16-bit, but E_FILE values must - * be 8-bit. - */ -static void -png_create_colormap_entry(png_image_read_control *display, - png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, - png_uint_32 alpha, int encoding) -{ - png_imagep image = display->image; - const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ? - E_LINEAR : E_sRGB; - const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && - (red != green || green != blue); - - if (ip > 255) - png_error(image->opaque->png_ptr, "color-map index out of range"); - - /* Update the cache with whether the file gamma is significantly different - * from sRGB. - */ - if (encoding == E_FILE) - { - if (display->file_encoding == E_NOTSET) - set_file_encoding(display); - - /* Note that the cached value may be E_FILE too, but if it is then the - * gamma_to_linear member has been set. - */ - encoding = display->file_encoding; - } - - if (encoding == E_FILE) - { - png_fixed_point g = display->gamma_to_linear; - - red = png_gamma_16bit_correct(red*257, g); - green = png_gamma_16bit_correct(green*257, g); - blue = png_gamma_16bit_correct(blue*257, g); - - if (convert_to_Y || output_encoding == E_LINEAR) - { - alpha *= 257; - encoding = E_LINEAR; - } - - else - { - red = PNG_sRGB_FROM_LINEAR(red * 255); - green = PNG_sRGB_FROM_LINEAR(green * 255); - blue = PNG_sRGB_FROM_LINEAR(blue * 255); - encoding = E_sRGB; - } - } - - else if (encoding == E_LINEAR8) - { - /* This encoding occurs quite frequently in test cases because PngSuite - * includes a gAMA 1.0 chunk with most images. - */ - red *= 257; - green *= 257; - blue *= 257; - alpha *= 257; - encoding = E_LINEAR; - } - - else if (encoding == E_sRGB && (convert_to_Y || output_encoding == E_LINEAR)) - { - /* The values are 8-bit sRGB values, but must be converted to 16-bit - * linear. - */ - red = png_sRGB_table[red]; - green = png_sRGB_table[green]; - blue = png_sRGB_table[blue]; - alpha *= 257; - encoding = E_LINEAR; - } - - /* This is set if the color isn't gray but the output is. */ - if (encoding == E_LINEAR) - { - if (convert_to_Y) - { - /* NOTE: these values are copied from png_do_rgb_to_gray */ - png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green + - (png_uint_32)2366 * blue; - - if (output_encoding == E_LINEAR) - y = (y + 16384) >> 15; - - else - { - /* y is scaled by 32768, we need it scaled by 255: */ - y = (y + 128) >> 8; - y *= 255; - y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); - encoding = E_sRGB; - } - - blue = red = green = y; - } - - else if (output_encoding == E_sRGB) - { - red = PNG_sRGB_FROM_LINEAR(red * 255); - green = PNG_sRGB_FROM_LINEAR(green * 255); - blue = PNG_sRGB_FROM_LINEAR(blue * 255); - alpha = PNG_DIV257(alpha); - encoding = E_sRGB; - } - } - - if (encoding != output_encoding) - png_error(image->opaque->png_ptr, "bad encoding (internal error)"); - - /* Store the value. */ - { -# ifdef PNG_FORMAT_BGR_SUPPORTED - const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && - (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; -# else -# define afirst 0 -# endif -# ifdef PNG_FORMAT_BGR_SUPPORTED - const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; -# else -# define bgr 0 -# endif - - if (output_encoding == E_LINEAR) - { - png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap); - - entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); - - /* The linear 16-bit values must be pre-multiplied by the alpha channel - * value, if less than 65535 (this is, effectively, composite on black - * if the alpha channel is removed.) - */ - switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) - { - case 4: - entry[afirst ? 0 : 3] = (png_uint_16)alpha; - /* FALL THROUGH */ - - case 3: - if (alpha < 65535) - { - if (alpha > 0) - { - blue = (blue * alpha + 32767U)/65535U; - green = (green * alpha + 32767U)/65535U; - red = (red * alpha + 32767U)/65535U; - } - - else - red = green = blue = 0; - } - entry[afirst + (2 ^ bgr)] = (png_uint_16)blue; - entry[afirst + 1] = (png_uint_16)green; - entry[afirst + bgr] = (png_uint_16)red; - break; - - case 2: - entry[1 ^ afirst] = (png_uint_16)alpha; - /* FALL THROUGH */ - - case 1: - if (alpha < 65535) - { - if (alpha > 0) - green = (green * alpha + 32767U)/65535U; - - else - green = 0; - } - entry[afirst] = (png_uint_16)green; - break; - - default: - break; - } - } - - else /* output encoding is E_sRGB */ - { - png_bytep entry = png_voidcast(png_bytep, display->colormap); - - entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); - - switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) - { - case 4: - entry[afirst ? 0 : 3] = (png_byte)alpha; - case 3: - entry[afirst + (2 ^ bgr)] = (png_byte)blue; - entry[afirst + 1] = (png_byte)green; - entry[afirst + bgr] = (png_byte)red; - break; - - case 2: - entry[1 ^ afirst] = (png_byte)alpha; - case 1: - entry[afirst] = (png_byte)green; - break; - - default: - break; - } - } - -# ifdef afirst -# undef afirst -# endif -# ifdef bgr -# undef bgr -# endif - } -} - -static int -make_gray_file_colormap(png_image_read_control *display) -{ - unsigned int i; - - for (i=0; i<256; ++i) - png_create_colormap_entry(display, i, i, i, i, 255, E_FILE); - - return i; -} - -static int -make_gray_colormap(png_image_read_control *display) -{ - unsigned int i; - - for (i=0; i<256; ++i) - png_create_colormap_entry(display, i, i, i, i, 255, E_sRGB); - - return i; -} -#define PNG_GRAY_COLORMAP_ENTRIES 256 - -static int -make_ga_colormap(png_image_read_control *display) -{ - unsigned int i, a; - - /* Alpha is retained, the output will be a color-map with entries - * selected by six levels of alpha. One transparent entry, 6 gray - * levels for all the intermediate alpha values, leaving 230 entries - * for the opaque grays. The color-map entries are the six values - * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the - * relevant entry. - * - * if (alpha > 229) // opaque - * { - * // The 231 entries are selected to make the math below work: - * base = 0; - * entry = (231 * gray + 128) >> 8; - * } - * else if (alpha < 26) // transparent - * { - * base = 231; - * entry = 0; - * } - * else // partially opaque - * { - * base = 226 + 6 * PNG_DIV51(alpha); - * entry = PNG_DIV51(gray); - * } - */ - i = 0; - while (i < 231) - { - unsigned int gray = (i * 256 + 115) / 231; - png_create_colormap_entry(display, i++, gray, gray, gray, 255, E_sRGB); - } - - /* 255 is used here for the component values for consistency with the code - * that undoes premultiplication in pngwrite.c. - */ - png_create_colormap_entry(display, i++, 255, 255, 255, 0, E_sRGB); - - for (a=1; a<5; ++a) - { - unsigned int g; - - for (g=0; g<6; ++g) - png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, - E_sRGB); - } - - return i; -} - -#define PNG_GA_COLORMAP_ENTRIES 256 - -static int -make_rgb_colormap(png_image_read_control *display) -{ - unsigned int i, r; - - /* Build a 6x6x6 opaque RGB cube */ - for (i=r=0; r<6; ++r) - { - unsigned int g; - - for (g=0; g<6; ++g) - { - unsigned int b; - - for (b=0; b<6; ++b) - png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, - E_sRGB); - } - } - - return i; -} - -#define PNG_RGB_COLORMAP_ENTRIES 216 - -/* Return a palette index to the above palette given three 8-bit sRGB values. */ -#define PNG_RGB_INDEX(r,g,b) \ - ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))) - -static int -png_image_read_colormap(png_voidp argument) -{ - png_image_read_control *display = - png_voidcast(png_image_read_control*, argument); - const png_imagep image = display->image; - - const png_structrp png_ptr = image->opaque->png_ptr; - const png_uint_32 output_format = image->format; - const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ? - E_LINEAR : E_sRGB; - - unsigned int cmap_entries; - unsigned int output_processing; /* Output processing option */ - unsigned int data_encoding = E_NOTSET; /* Encoding libpng must produce */ - - /* Background information; the background color and the index of this color - * in the color-map if it exists (else 256). - */ - unsigned int background_index = 256; - png_uint_32 back_r, back_g, back_b; - - /* Flags to accumulate things that need to be done to the input. */ - int expand_tRNS = 0; - - /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is - * very difficult to do, the results look awful, and it is difficult to see - * what possible use it is because the application can't control the - * color-map. - */ - if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 || - png_ptr->num_trans > 0) /* alpha in input */ && - ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */) - { - if (output_encoding == E_LINEAR) /* compose on black */ - back_b = back_g = back_r = 0; - - else if (display->background == NULL /* no way to remove it */) - png_error(png_ptr, - "a background color must be supplied to remove alpha/transparency"); - - /* Get a copy of the background color (this avoids repeating the checks - * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the - * output format. - */ - else - { - back_g = display->background->green; - if (output_format & PNG_FORMAT_FLAG_COLOR) - { - back_r = display->background->red; - back_b = display->background->blue; - } - else - back_b = back_r = back_g; - } - } - - else if (output_encoding == E_LINEAR) - back_b = back_r = back_g = 65535; - - else - back_b = back_r = back_g = 255; - - /* Default the input file gamma if required - this is necessary because - * libpng assumes that if no gamma information is present the data is in the - * output format, but the simplified API deduces the gamma from the input - * format. - */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) - { - /* Do this directly, not using the png_colorspace functions, to ensure - * that it happens even if the colorspace is invalid (though probably if - * it is the setting will be ignored) Note that the same thing can be - * achieved at the application interface with png_set_gAMA. - */ - if (png_ptr->bit_depth == 16 && - (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) - png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; - - else - png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; - - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - } - - /* Decide what to do based on the PNG color type of the input data. The - * utility function png_create_colormap_entry deals with most aspects of the - * output transformations; this code works out how to produce bytes of - * color-map entries from the original format. - */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - if (png_ptr->bit_depth <= 8) - { - /* There at most 256 colors in the output, regardless of - * transparency. - */ - unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0; - - cmap_entries = 1U << png_ptr->bit_depth; - if (cmap_entries > image->colormap_entries) - png_error(png_ptr, "gray[8] color-map: too few entries"); - - step = 255 / (cmap_entries - 1); - output_processing = PNG_CMAP_NONE; - - /* If there is a tRNS chunk then this either selects a transparent - * value or, if the output has no alpha, the background color. - */ - if (png_ptr->num_trans > 0) - { - trans = png_ptr->trans_color.gray; - - if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) - back_alpha = output_encoding == E_LINEAR ? 65535 : 255; - } - - /* png_create_colormap_entry just takes an RGBA and writes the - * corresponding color-map entry using the format from 'image', - * including the required conversion to sRGB or linear as - * appropriate. The input values are always either sRGB (if the - * gamma correction flag is 0) or 0..255 scaled file encoded values - * (if the function must gamma correct them). - */ - for (i=val=0; ibit_depth < 8) - png_set_packing(png_ptr); - } - - else /* bit depth is 16 */ - { - /* The 16-bit input values can be converted directly to 8-bit gamma - * encoded values; however, if a tRNS chunk is present 257 color-map - * entries are required. This means that the extra entry requires - * special processing; add an alpha channel, sacrifice gray level - * 254 and convert transparent (alpha==0) entries to that. - * - * Use libpng to chop the data to 8 bits. Convert it to sRGB at the - * same time to minimize quality loss. If a tRNS chunk is present - * this means libpng must handle it too; otherwise it is impossible - * to do the exact match on the 16-bit value. - * - * If the output has no alpha channel *and* the background color is - * gray then it is possible to let libpng handle the substitution by - * ensuring that the corresponding gray level matches the background - * color exactly. - */ - data_encoding = E_sRGB; - - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray[16] color-map: too few entries"); - - cmap_entries = make_gray_colormap(display); - - if (png_ptr->num_trans > 0) - { - unsigned int back_alpha; - - if (output_format & PNG_FORMAT_FLAG_ALPHA) - back_alpha = 0; - - else - { - if (back_r == back_g && back_g == back_b) - { - /* Background is gray; no special processing will be - * required. - */ - png_color_16 c; - png_uint_32 gray = back_g; - - if (output_encoding == E_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry - * matches. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, E_LINEAR); - } - - /* The background passed to libpng, however, must be the - * sRGB value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - /* NOTE: does this work without expanding tRNS to alpha? - * It should be the color->gray case below apparently - * doesn't. - */ - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_NONE; - break; - } - - back_alpha = output_encoding == E_LINEAR ? 65535 : 255; - } - - /* output_processing means that the libpng-processed row will be - * 8-bit GA and it has to be processing to single byte color-map - * values. Entry 254 is replaced by either a completely - * transparent entry or by the background color at full - * precision (and the background color is not a simple gray leve - * in this case.) - */ - expand_tRNS = 1; - output_processing = PNG_CMAP_TRANS; - background_index = 254; - - /* And set (overwrite) color-map entry 254 to the actual - * background color at full precision. - */ - png_create_colormap_entry(display, 254, back_r, back_g, back_b, - back_alpha, output_encoding); - } - - else - output_processing = PNG_CMAP_NONE; - } - break; - - case PNG_COLOR_TYPE_GRAY_ALPHA: - /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum - * of 65536 combinations. If, however, the alpha channel is to be - * removed there are only 256 possibilities if the background is gray. - * (Otherwise there is a subset of the 65536 possibilities defined by - * the triangle between black, white and the background color.) - * - * Reduce 16-bit files to 8-bit and sRGB encode the result. No need to - * worry about tRNS matching - tRNS is ignored if there is an alpha - * channel. - */ - data_encoding = E_sRGB; - - if (output_format & PNG_FORMAT_FLAG_ALPHA) - { - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray+alpha color-map: too few entries"); - - cmap_entries = make_ga_colormap(display); - - background_index = PNG_CMAP_GA_BACKGROUND; - output_processing = PNG_CMAP_GA; - } - - else /* alpha is removed */ - { - /* Alpha must be removed as the PNG data is processed when the - * background is a color because the G and A channels are - * independent and the vector addition (non-parallel vectors) is a - * 2-D problem. - * - * This can be reduced to the same algorithm as above by making a - * colormap containing gray levels (for the opaque grays), a - * background entry (for a transparent pixel) and a set of four six - * level color values, one set for each intermediate alpha value. - * See the comments in make_ga_colormap for how this works in the - * per-pixel processing. - * - * If the background is gray, however, we only need a 256 entry gray - * level color map. It is sufficient to make the entry generated - * for the background color be exactly the color specified. - */ - if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 || - (back_r == back_g && back_g == back_b)) - { - /* Background is gray; no special processing will be required. */ - png_color_16 c; - png_uint_32 gray = back_g; - - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray-alpha color-map: too few entries"); - - cmap_entries = make_gray_colormap(display); - - if (output_encoding == E_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry matches. */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, E_LINEAR); - } - - /* The background passed to libpng, however, must be the sRGB - * value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_NONE; - } - - else - { - png_uint_32 i, a; - - /* This is the same as png_make_ga_colormap, above, except that - * the entries are all opaque. - */ - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "ga-alpha color-map: too few entries"); - - i = 0; - while (i < 231) - { - png_uint_32 gray = (i * 256 + 115) / 231; - png_create_colormap_entry(display, i++, gray, gray, gray, - 255, E_sRGB); - } - - /* NOTE: this preserves the full precision of the application - * background color. - */ - background_index = i; - png_create_colormap_entry(display, i++, back_r, back_g, back_b, - output_encoding == E_LINEAR ? 65535U : 255U, output_encoding); - - /* For non-opaque input composite on the sRGB background - this - * requires inverting the encoding for each component. The input - * is still converted to the sRGB encoding because this is a - * reasonable approximate to the logarithmic curve of human - * visual sensitivity, at least over the narrow range which PNG - * represents. Consequently 'G' is always sRGB encoded, while - * 'A' is linear. We need the linear background colors. - */ - if (output_encoding == E_sRGB) /* else already linear */ - { - /* This may produce a value not exactly matching the - * background, but that's ok because these numbers are only - * used when alpha != 0 - */ - back_r = png_sRGB_table[back_r]; - back_g = png_sRGB_table[back_g]; - back_b = png_sRGB_table[back_b]; - } - - for (a=1; a<5; ++a) - { - unsigned int g; - - /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled - * by an 8-bit alpha value (0..255). - */ - png_uint_32 alpha = 51 * a; - png_uint_32 back_rx = (255-alpha) * back_r; - png_uint_32 back_gx = (255-alpha) * back_g; - png_uint_32 back_bx = (255-alpha) * back_b; - - for (g=0; g<6; ++g) - { - png_uint_32 gray = png_sRGB_table[g*51] * alpha; - - png_create_colormap_entry(display, i++, - PNG_sRGB_FROM_LINEAR(gray + back_rx), - PNG_sRGB_FROM_LINEAR(gray + back_gx), - PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, E_sRGB); - } - } - - cmap_entries = i; - output_processing = PNG_CMAP_GA; - } - } - break; - - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - /* Exclude the case where the output is gray; we can always handle this - * with the cases above. - */ - if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0) - { - /* The color-map will be grayscale, so we may as well convert the - * input RGB values to a simple grayscale and use the grayscale - * code above. - * - * NOTE: calling this apparently damages the recognition of the - * transparent color in background color handling; call - * png_set_tRNS_to_alpha before png_set_background_fixed. - */ - png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, - -1); - data_encoding = E_sRGB; - - /* The output will now be one or two 8-bit gray or gray+alpha - * channels. The more complex case arises when the input has alpha. - */ - if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) && - (output_format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - /* Both input and output have an alpha channel, so no background - * processing is required; just map the GA bytes to the right - * color-map entry. - */ - expand_tRNS = 1; - - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb[ga] color-map: too few entries"); - - cmap_entries = make_ga_colormap(display); - background_index = PNG_CMAP_GA_BACKGROUND; - output_processing = PNG_CMAP_GA; - } - - else - { - /* Either the input or the output has no alpha channel, so there - * will be no non-opaque pixels in the color-map; it will just be - * grayscale. - */ - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb[gray] color-map: too few entries"); - - /* Ideally this code would use libpng to do the gamma correction, - * but if an input alpha channel is to be removed we will hit the - * libpng bug in gamma+compose+rgb-to-gray (the double gamma - * correction bug). Fix this by dropping the gamma correction in - * this case and doing it in the palette; this will result in - * duplicate palette entries, but that's better than the - * alternative of double gamma correction. - */ - if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) && - png_gamma_not_sRGB(png_ptr->colorspace.gamma)) - { - cmap_entries = make_gray_file_colormap(display); - data_encoding = E_FILE; - } - - else - cmap_entries = make_gray_colormap(display); - - /* But if the input has alpha or transparency it must be removed - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) - { - png_color_16 c; - png_uint_32 gray = back_g; - - /* We need to ensure that the application background exists in - * the colormap and that completely transparent pixels map to - * it. Achieve this simply by ensuring that the entry - * selected for the background really is the background color. - */ - if (data_encoding == E_FILE) /* from the fixup above */ - { - /* The app supplied a gray which is in output_encoding, we - * need to convert it to a value of the input (E_FILE) - * encoding then set this palette entry to the required - * output encoding. - */ - if (output_encoding == E_sRGB) - gray = png_sRGB_table[gray]; /* now E_LINEAR */ - - gray = PNG_DIV257(png_gamma_16bit_correct(gray, - png_ptr->colorspace.gamma)); /* now E_FILE */ - - /* And make sure the corresponding palette entry contains - * exactly the required sRGB value. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, output_encoding); - } - - else if (output_encoding == E_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry matches. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, E_LINEAR); - } - - /* The background passed to libpng, however, must be the - * output (normally sRGB) value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - /* NOTE: the following is apparently a bug in libpng. Without - * it the transparent color recognition in - * png_set_background_fixed seems to go wrong. - */ - expand_tRNS = 1; - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - } - - output_processing = PNG_CMAP_NONE; - } - } - - else /* output is color */ - { - /* We could use png_quantize here so long as there is no transparent - * color or alpha; png_quantize ignores alpha. Easier overall just - * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube. - * Consequently we always want libpng to produce sRGB data. - */ - data_encoding = E_sRGB; - - /* Is there any transparency or alpha? */ - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) - { - /* Is there alpha in the output too? If so all four channels are - * processed into a special RGB cube with alpha support. - */ - if (output_format & PNG_FORMAT_FLAG_ALPHA) - { - png_uint_32 r; - - if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) - png_error(png_ptr, "rgb+alpha color-map: too few entries"); - - cmap_entries = make_rgb_colormap(display); - - /* Add a transparent entry. */ - png_create_colormap_entry(display, cmap_entries, 255, 255, - 255, 0, E_sRGB); - - /* This is stored as the background index for the processing - * algorithm. - */ - background_index = cmap_entries++; - - /* Add 27 r,g,b entries each with alpha 0.5. */ - for (r=0; r<256; r = (r << 1) | 0x7f) - { - png_uint_32 g; - - for (g=0; g<256; g = (g << 1) | 0x7f) - { - png_uint_32 b; - - /* This generates components with the values 0, 127 and - * 255 - */ - for (b=0; b<256; b = (b << 1) | 0x7f) - png_create_colormap_entry(display, cmap_entries++, - r, g, b, 128, E_sRGB); - } - } - - expand_tRNS = 1; - output_processing = PNG_CMAP_RGB_ALPHA; - } - - else - { - /* Alpha/transparency must be removed. The background must - * exist in the color map (achieved by setting adding it after - * the 666 color-map). If the standard processing code will - * pick up this entry automatically that's all that is - * required; libpng can be called to do the background - * processing. - */ - unsigned int sample_size = - PNG_IMAGE_SAMPLE_SIZE(output_format); - png_uint_32 r, g, b; /* sRGB background */ - - if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) - png_error(png_ptr, "rgb-alpha color-map: too few entries"); - - cmap_entries = make_rgb_colormap(display); - - png_create_colormap_entry(display, cmap_entries, back_r, - back_g, back_b, 0/*unused*/, output_encoding); - - if (output_encoding == E_LINEAR) - { - r = PNG_sRGB_FROM_LINEAR(back_r * 255); - g = PNG_sRGB_FROM_LINEAR(back_g * 255); - b = PNG_sRGB_FROM_LINEAR(back_b * 255); - } - - else - { - r = back_r; - g = back_g; - b = back_g; - } - - /* Compare the newly-created color-map entry with the one the - * PNG_CMAP_RGB algorithm will use. If the two entries don't - * match, add the new one and set this as the background - * index. - */ - if (memcmp((png_const_bytep)display->colormap + - sample_size * cmap_entries, - (png_const_bytep)display->colormap + - sample_size * PNG_RGB_INDEX(r,g,b), - sample_size) != 0) - { - /* The background color must be added. */ - background_index = cmap_entries++; - - /* Add 27 r,g,b entries each with created by composing with - * the background at alpha 0.5. - */ - for (r=0; r<256; r = (r << 1) | 0x7f) - { - for (g=0; g<256; g = (g << 1) | 0x7f) - { - /* This generates components with the values 0, 127 - * and 255 - */ - for (b=0; b<256; b = (b << 1) | 0x7f) - png_create_colormap_entry(display, cmap_entries++, - png_colormap_compose(display, r, E_sRGB, 128, - back_r, output_encoding), - png_colormap_compose(display, g, E_sRGB, 128, - back_g, output_encoding), - png_colormap_compose(display, b, E_sRGB, 128, - back_b, output_encoding), - 0/*unused*/, output_encoding); - } - } - - expand_tRNS = 1; - output_processing = PNG_CMAP_RGB_ALPHA; - } - - else /* background color is in the standard color-map */ - { - png_color_16 c; - - c.index = 0; /*unused*/ - c.red = (png_uint_16)back_r; - c.gray = c.green = (png_uint_16)back_g; - c.blue = (png_uint_16)back_b; - - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_RGB; - } - } - } - - else /* no alpha or transparency in the input */ - { - /* Alpha in the output is irrelevant, simply map the opaque input - * pixels to the 6x6x6 color-map. - */ - if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb color-map: too few entries"); - - cmap_entries = make_rgb_colormap(display); - output_processing = PNG_CMAP_RGB; - } - } - break; - - case PNG_COLOR_TYPE_PALETTE: - /* It's already got a color-map. It may be necessary to eliminate the - * tRNS entries though. - */ - { - unsigned int num_trans = png_ptr->num_trans; - png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; - png_const_colorp colormap = png_ptr->palette; - const int do_background = trans != NULL && - (output_format & PNG_FORMAT_FLAG_ALPHA) == 0; - unsigned int i; - - /* Just in case: */ - if (trans == NULL) - num_trans = 0; - - output_processing = PNG_CMAP_NONE; - data_encoding = E_FILE; /* Don't change from color-map indicies */ - cmap_entries = png_ptr->num_palette; - if (cmap_entries > 256) - cmap_entries = 256; - - if (cmap_entries > image->colormap_entries) - png_error(png_ptr, "palette color-map: too few entries"); - - for (i=0; i < cmap_entries; ++i) - { - if (do_background && i < num_trans && trans[i] < 255) - { - if (trans[i] == 0) - png_create_colormap_entry(display, i, back_r, back_g, - back_b, 0, output_encoding); - - else - { - /* Must compose the PNG file color in the color-map entry - * on the sRGB color in 'back'. - */ - png_create_colormap_entry(display, i, - png_colormap_compose(display, colormap[i].red, E_FILE, - trans[i], back_r, output_encoding), - png_colormap_compose(display, colormap[i].green, E_FILE, - trans[i], back_g, output_encoding), - png_colormap_compose(display, colormap[i].blue, E_FILE, - trans[i], back_b, output_encoding), - output_encoding == E_LINEAR ? trans[i] * 257U : - trans[i], - output_encoding); - } - } - - else - png_create_colormap_entry(display, i, colormap[i].red, - colormap[i].green, colormap[i].blue, - i < num_trans ? trans[i] : 255U, E_FILE/*8-bit*/); - } - - /* The PNG data may have indicies packed in fewer than 8 bits, it - * must be expanded if so. - */ - if (png_ptr->bit_depth < 8) - png_set_packing(png_ptr); - } - break; - - default: - png_error(png_ptr, "invalid PNG color type"); - /*NOT REACHED*/ - break; - } - - /* Now deal with the output processing */ - if (expand_tRNS && png_ptr->num_trans > 0 && - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0) - png_set_tRNS_to_alpha(png_ptr); - - switch (data_encoding) - { - default: - png_error(png_ptr, "bad data option (internal error)"); - break; - - case E_sRGB: - /* Change to 8-bit sRGB */ - png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); - /* FALL THROUGH */ - - case E_FILE: - if (png_ptr->bit_depth > 8) - png_set_scale_16(png_ptr); - break; - } - - if (cmap_entries > 256 || cmap_entries > image->colormap_entries) - png_error(png_ptr, "color map overflow (BAD internal error)"); - - image->colormap_entries = cmap_entries; - - /* Double check using the recorded background index */ - switch (output_processing) - { - case PNG_CMAP_NONE: - if (background_index != PNG_CMAP_NONE_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_GA: - if (background_index != PNG_CMAP_GA_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_TRANS: - if (background_index >= cmap_entries || - background_index != PNG_CMAP_TRANS_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_RGB: - if (background_index != PNG_CMAP_RGB_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_RGB_ALPHA: - if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND) - goto bad_background; - break; - - default: - png_error(png_ptr, "bad processing option (internal error)"); - - bad_background: - png_error(png_ptr, "bad background index (internal error)"); - } - - display->colormap_processing = output_processing; - - return 1/*ok*/; -} - -/* The final part of the color-map read called from png_image_finish_read. */ -static int -png_image_read_and_map(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - int passes; - - /* Called when the libpng data must be transformed into the color-mapped - * form. There is a local row buffer in display->local and this routine must - * do the interlace handling. - */ - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - passes = 0; - png_error(png_ptr, "unknown interlace type"); - } - - { - png_uint_32 height = image->height; - png_uint_32 width = image->width; - int proc = display->colormap_processing; - png_bytep first_row = png_voidcast(png_bytep, display->first_row); - ptrdiff_t step_row = display->row_bytes; - int pass; - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass); - stepx = PNG_PASS_COL_OFFSET(pass); - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = stepy = 1; - } - - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read read the libpng data into the temporary buffer. */ - png_read_row(png_ptr, inrow, NULL); - - /* Now process the row according to the processing option, note - * that the caller verifies that the format of the libpng output - * data is as required. - */ - outrow += startx; - switch (proc) - { - case PNG_CMAP_GA: - for (; outrow < end_row; outrow += stepx) - { - /* The data is always in the PNG order */ - unsigned int gray = *inrow++; - unsigned int alpha = *inrow++; - unsigned int entry; - - /* NOTE: this code is copied as a comment in - * make_ga_colormap above. Please update the - * comment if you change this code! - */ - if (alpha > 229) /* opaque */ - { - entry = (231 * gray + 128) >> 8; - } - else if (alpha < 26) /* transparent */ - { - entry = 231; - } - else /* partially opaque */ - { - entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray); - } - - *outrow = (png_byte)entry; - } - break; - - case PNG_CMAP_TRANS: - for (; outrow < end_row; outrow += stepx) - { - png_byte gray = *inrow++; - png_byte alpha = *inrow++; - - if (alpha == 0) - *outrow = PNG_CMAP_TRANS_BACKGROUND; - - else if (gray != PNG_CMAP_TRANS_BACKGROUND) - *outrow = gray; - - else - *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1); - } - break; - - case PNG_CMAP_RGB: - for (; outrow < end_row; outrow += stepx) - { - *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]); - inrow += 3; - } - break; - - case PNG_CMAP_RGB_ALPHA: - for (; outrow < end_row; outrow += stepx) - { - unsigned int alpha = inrow[3]; - - /* Because the alpha entries only hold alpha==0.5 values - * split the processing at alpha==0.25 (64) and 0.75 - * (196). - */ - - if (alpha >= 196) - *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], - inrow[2]); - - else if (alpha < 64) - *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; - - else - { - /* Likewise there are three entries for each of r, g - * and b. We could select the entry by popcount on - * the top two bits on those architectures that - * support it, this is what the code below does, - * crudely. - */ - unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1; - - /* Here are how the values map: - * - * 0x00 .. 0x3f -> 0 - * 0x40 .. 0xbf -> 1 - * 0xc0 .. 0xff -> 2 - * - * So, as above with the explicit alpha checks, the - * breakpoints are at 64 and 196. - */ - if (inrow[0] & 0x80) back_i += 9; /* red */ - if (inrow[0] & 0x40) back_i += 9; - if (inrow[0] & 0x80) back_i += 3; /* green */ - if (inrow[0] & 0x40) back_i += 3; - if (inrow[0] & 0x80) back_i += 1; /* blue */ - if (inrow[0] & 0x40) back_i += 1; - - *outrow = (png_byte)back_i; - } - - inrow += 4; - } - break; - - default: - break; - } - } - } - } - - return 1; -} - -static int -png_image_read_colormapped(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_controlp control = image->opaque; - png_structrp png_ptr = control->png_ptr; - png_inforp info_ptr = control->info_ptr; - - int passes = 0; /* As a flag */ - - PNG_SKIP_CHUNKS(png_ptr); - - /* Update the 'info' structure and make sure the result is as required; first - * make sure to turn on the interlace handling if it will be required - * (because it can't be turned on *after* the call to png_read_update_info!) - */ - if (display->colormap_processing == PNG_CMAP_NONE) - passes = png_set_interlace_handling(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - - /* The expected output can be deduced from the colormap_processing option. */ - switch (display->colormap_processing) - { - case PNG_CMAP_NONE: - /* Output must be one channel and one byte per pixel, the output - * encoding can be anything. - */ - if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - info_ptr->color_type == PNG_COLOR_TYPE_GRAY) && - info_ptr->bit_depth == 8) - break; - - goto bad_output; - - case PNG_CMAP_TRANS: - case PNG_CMAP_GA: - /* Output must be two channels and the 'G' one must be sRGB, the latter - * can be checked with an exact number because it should have been set - * to this number above! - */ - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 256) - break; - - goto bad_output; - - case PNG_CMAP_RGB: - /* Output must be 8-bit sRGB encoded RGB */ - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 216) - break; - - goto bad_output; - - case PNG_CMAP_RGB_ALPHA: - /* Output must be 8-bit sRGB encoded RGBA */ - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 244 /* 216 + 1 + 27 */) - break; - - /* goto bad_output; */ - /* FALL THROUGH */ - - default: - bad_output: - png_error(png_ptr, "bad color-map processing (internal error)"); - } - - /* Now read the rows. Do this here if it is possible to read directly into - * the output buffer, otherwise allocate a local row buffer of the maximum - * size libpng requires and call the relevant processing routine safely. - */ - { - png_voidp first_row = display->buffer; - ptrdiff_t row_bytes = display->row_stride; - - /* The following expression is designed to work correctly whether it gives - * a signed or an unsigned result. - */ - if (row_bytes < 0) - { - char *ptr = png_voidcast(char*, first_row); - ptr += (image->height-1) * (-row_bytes); - first_row = png_voidcast(png_voidp, ptr); - } - - display->first_row = first_row; - display->row_bytes = row_bytes; - } - - if (passes == 0) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_and_map, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else - { - png_alloc_size_t row_bytes = display->row_bytes; - - while (--passes >= 0) - { - png_uint_32 y = image->height; - png_bytep row = png_voidcast(png_bytep, display->first_row); - - while (y-- > 0) - { - png_read_row(png_ptr, row, NULL); - row += row_bytes; - } - } - - return 1; - } -} - -/* Just the row reading part of png_image_read. */ -static int -png_image_read_composite(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - int passes; - - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - passes = 0; - png_error(png_ptr, "unknown interlace type"); - } - - { - png_uint_32 height = image->height; - png_uint_32 width = image->width; - ptrdiff_t step_row = display->row_bytes; - unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; - int pass; - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass) * channels; - stepx = PNG_PASS_COL_OFFSET(pass) * channels; - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = channels; - stepy = 1; - } - - for (; ylocal_row); - png_bytep outrow; - png_const_bytep end_row; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - outrow = png_voidcast(png_bytep, display->first_row); - outrow += y * step_row; - end_row = outrow + width * channels; - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[channels]; - - if (alpha > 0) /* else no change to the output */ - { - unsigned int c; - - for (c=0; cimage; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - png_uint_32 height = image->height; - png_uint_32 width = image->width; - int pass, passes; - - /* Double check the convoluted logic below. We expect to get here with - * libpng doing rgb to gray and gamma correction but background processing - * left to the png_image_read_background function. The rows libpng produce - * might be 8 or 16-bit but should always have two channels; gray plus alpha. - */ - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) - png_error(png_ptr, "lost rgb to gray"); - - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - png_error(png_ptr, "unexpected compose"); - - if (png_get_channels(png_ptr, info_ptr) != 2) - png_error(png_ptr, "lost/gained channels"); - - /* Expect the 8-bit case to always remove the alpha channel */ - if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 && - (image->format & PNG_FORMAT_FLAG_ALPHA) != 0) - png_error(png_ptr, "unexpected 8-bit transformation"); - - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - passes = 0; - png_error(png_ptr, "unknown interlace type"); - } - - switch (png_get_bit_depth(png_ptr, info_ptr)) - { - default: - png_error(png_ptr, "unexpected bit depth"); - break; - - case 8: - /* 8-bit sRGB gray values with an alpha channel; the alpha channel is - * to be removed by composing on a backgroundi: either the row if - * display->background is NULL or display->background->green if not. - * Unlike the code above ALPHA_OPTIMIZED has *not* been done. - */ - { - png_bytep first_row = png_voidcast(png_bytep, display->first_row); - ptrdiff_t step_row = display->row_bytes; - - for (pass = 0; pass < passes; ++pass) - { - png_bytep row = png_voidcast(png_bytep, - display->first_row); - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass); - stepx = PNG_PASS_COL_OFFSET(pass); - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = stepy = 1; - } - - if (display->background == NULL) - { - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[1]; - - if (alpha > 0) /* else no change to the output */ - { - png_uint_32 component = inrow[0]; - - if (alpha < 255) /* else just use component */ - { - /* Since PNG_OPTIMIZED_ALPHA was not set it is - * necessary to invert the sRGB transfer - * function and multiply the alpha out. - */ - component = png_sRGB_table[component] * alpha; - component += png_sRGB_table[outrow[0]] * - (255-alpha); - component = PNG_sRGB_FROM_LINEAR(component); - } - - outrow[0] = (png_byte)component; - } - - inrow += 2; /* gray and alpha channel */ - } - } - } - - else /* constant background value */ - { - png_byte background8 = display->background->green; - png_uint_16 background = png_sRGB_table[background8]; - - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[1]; - - if (alpha > 0) /* else use background */ - { - png_uint_32 component = inrow[0]; - - if (alpha < 255) /* else just use component */ - { - component = png_sRGB_table[component] * alpha; - component += background * (255-alpha); - component = PNG_sRGB_FROM_LINEAR(component); - } - - outrow[0] = (png_byte)component; - } - - else - outrow[0] = background8; - - inrow += 2; /* gray and alpha channel */ - } - - row += display->row_bytes; - } - } - } - } - break; - - case 16: - /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must - * still be done and, maybe, the alpha channel removed. This code also - * handles the alpha-first option. - */ - { - png_uint_16p first_row = png_voidcast(png_uint_16p, - display->first_row); - /* The division by two is safe because the caller passed in a - * stride which was multiplied by 2 (below) to get row_bytes. - */ - ptrdiff_t step_row = display->row_bytes / 2; - int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; - unsigned int outchannels = 1+preserve_alpha; - int swap_alpha = 0; - - if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST)) - swap_alpha = 1; - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - /* The 'x' start and step are adjusted to output components here. - */ - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass) * outchannels; - stepx = PNG_PASS_COL_OFFSET(pass) * outchannels; - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = outchannels; - stepy = 1; - } - - for (; ylocal_row), NULL); - inrow = png_voidcast(png_const_uint_16p, display->local_row); - - /* Now do the pre-multiplication on each pixel in this row. - */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_uint_32 component = inrow[0]; - png_uint_16 alpha = inrow[1]; - - if (alpha > 0) /* else 0 */ - { - if (alpha < 65535) /* else just use component */ - { - component *= alpha; - component += 32767; - component /= 65535; - } - } - - else - component = 0; - - outrow[swap_alpha] = (png_uint_16)component; - if (preserve_alpha) - outrow[1 ^ swap_alpha] = alpha; - - inrow += 2; /* components and alpha channel */ - } - } - } - } - break; - } - - return 1; -} - -/* The guts of png_image_finish_read as a png_safe_execute callback. */ -static int -png_image_read_direct(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - - png_uint_32 format = image->format; - int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0; - int do_local_compose = 0; - int do_local_background = 0; /* to avoid double gamma correction bug */ - int passes = 0; - - /* Add transforms to ensure the correct output format is produced then check - * that the required implementation support is there. Always expand; always - * need 8 bits minimum, no palette and expanded tRNS. - */ - png_set_expand(png_ptr); - - /* Now check the format to see if it was modified. */ - { - png_uint_32 base_format = png_image_format(png_ptr) & - ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */; - png_uint_32 change = format ^ base_format; - png_fixed_point output_gamma; - int mode; /* alpha mode */ - - /* Do this first so that we have a record if rgb to gray is happening. */ - if (change & PNG_FORMAT_FLAG_COLOR) - { - /* gray<->color transformation required. */ - if (format & PNG_FORMAT_FLAG_COLOR) - png_set_gray_to_rgb(png_ptr); - - else - { - /* libpng can't do both rgb to gray and - * background/pre-multiplication if there is also significant gamma - * correction, because both operations require linear colors and - * the code only supports one transform doing the gamma correction. - * Handle this by doing the pre-multiplication or background - * operation in this code, if necessary. - * - * TODO: fix this by rewriting pngrtran.c (!) - * - * For the moment (given that fixing this in pngrtran.c is an - * enormous change) 'do_local_background' is used to indicate that - * the problem exists. - */ - if (base_format & PNG_FORMAT_FLAG_ALPHA) - do_local_background = 1/*maybe*/; - - png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, - PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); - } - - change &= ~PNG_FORMAT_FLAG_COLOR; - } - - /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise. - */ - { - png_fixed_point input_gamma_default; - - if ((base_format & PNG_FORMAT_FLAG_LINEAR) && - (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) - input_gamma_default = PNG_GAMMA_LINEAR; - else - input_gamma_default = PNG_DEFAULT_sRGB; - - /* Call png_set_alpha_mode to set the default for the input gamma; the - * output gamma is set by a second call below. - */ - png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default); - } - - if (linear) - { - /* If there *is* an alpha channel in the input it must be multiplied - * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG. - */ - if (base_format & PNG_FORMAT_FLAG_ALPHA) - mode = PNG_ALPHA_STANDARD; /* associated alpha */ - - else - mode = PNG_ALPHA_PNG; - - output_gamma = PNG_GAMMA_LINEAR; - } - - else - { - mode = PNG_ALPHA_PNG; - output_gamma = PNG_DEFAULT_sRGB; - } - - /* If 'do_local_background' is set check for the presence of gamma - * correction; this is part of the work-round for the libpng bug - * described above. - * - * TODO: fix libpng and remove this. - */ - if (do_local_background) - { - png_fixed_point gtest; - - /* This is 'png_gamma_threshold' from pngrtran.c; the test used for - * gamma correction, the screen gamma hasn't been set on png_struct - * yet; it's set below. png_struct::gamma, however, is set to the - * final value. - */ - if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, - PNG_FP_1) && !png_gamma_significant(gtest)) - do_local_background = 0; - - else if (mode == PNG_ALPHA_STANDARD) - { - do_local_background = 2/*required*/; - mode = PNG_ALPHA_PNG; /* prevent libpng doing it */ - } - - /* else leave as 1 for the checks below */ - } - - /* If the bit-depth changes then handle that here. */ - if (change & PNG_FORMAT_FLAG_LINEAR) - { - if (linear /*16-bit output*/) - png_set_expand_16(png_ptr); - - else /* 8-bit output */ - png_set_scale_16(png_ptr); - - change &= ~PNG_FORMAT_FLAG_LINEAR; - } - - /* Now the background/alpha channel changes. */ - if (change & PNG_FORMAT_FLAG_ALPHA) - { - /* Removing an alpha channel requires composition for the 8-bit - * formats; for the 16-bit it is already done, above, by the - * pre-multiplication and the channel just needs to be stripped. - */ - if (base_format & PNG_FORMAT_FLAG_ALPHA) - { - /* If RGB->gray is happening the alpha channel must be left and the - * operation completed locally. - * - * TODO: fix libpng and remove this. - */ - if (do_local_background) - do_local_background = 2/*required*/; - - /* 16-bit output: just remove the channel */ - else if (linear) /* compose on black (well, pre-multiply) */ - png_set_strip_alpha(png_ptr); - - /* 8-bit output: do an appropriate compose */ - else if (display->background != NULL) - { - png_color_16 c; - - c.index = 0; /*unused*/ - c.red = display->background->red; - c.green = display->background->green; - c.blue = display->background->blue; - c.gray = display->background->green; - - /* This is always an 8-bit sRGB value, using the 'green' channel - * for gray is much better than calculating the luminance here; - * we can get off-by-one errors in that calculation relative to - * the app expectations and that will show up in transparent - * pixels. - */ - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - } - - else /* compose on row: implemented below. */ - { - do_local_compose = 1; - /* This leaves the alpha channel in the output, so it has to be - * removed by the code below. Set the encoding to the 'OPTIMIZE' - * one so the code only has to hack on the pixels that require - * composition. - */ - mode = PNG_ALPHA_OPTIMIZED; - } - } - - else /* output needs an alpha channel */ - { - /* This is tricky because it happens before the swap operation has - * been accomplished; however, the swap does *not* swap the added - * alpha channel (weird API), so it must be added in the correct - * place. - */ - png_uint_32 filler; /* opaque filler */ - int where; - - if (linear) - filler = 65535; - - else - filler = 255; - -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - if (format & PNG_FORMAT_FLAG_AFIRST) - { - where = PNG_FILLER_BEFORE; - change &= ~PNG_FORMAT_FLAG_AFIRST; - } - - else -# endif - where = PNG_FILLER_AFTER; - - png_set_add_alpha(png_ptr, filler, where); - } - - /* This stops the (irrelevant) call to swap_alpha below. */ - change &= ~PNG_FORMAT_FLAG_ALPHA; - } - - /* Now set the alpha mode correctly; this is always done, even if there is - * no alpha channel in either the input or the output because it correctly - * sets the output gamma. - */ - png_set_alpha_mode_fixed(png_ptr, mode, output_gamma); - -# ifdef PNG_FORMAT_BGR_SUPPORTED - if (change & PNG_FORMAT_FLAG_BGR) - { - /* Check only the output format; PNG is never BGR; don't do this if - * the output is gray, but fix up the 'format' value in that case. - */ - if (format & PNG_FORMAT_FLAG_COLOR) - png_set_bgr(png_ptr); - - else - format &= ~PNG_FORMAT_FLAG_BGR; - - change &= ~PNG_FORMAT_FLAG_BGR; - } -# endif - -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - if (change & PNG_FORMAT_FLAG_AFIRST) - { - /* Only relevant if there is an alpha channel - it's particularly - * important to handle this correctly because do_local_compose may - * be set above and then libpng will keep the alpha channel for this - * code to remove. - */ - if (format & PNG_FORMAT_FLAG_ALPHA) - { - /* Disable this if doing a local background, - * TODO: remove this when local background is no longer required. - */ - if (do_local_background != 2) - png_set_swap_alpha(png_ptr); - } - - else - format &= ~PNG_FORMAT_FLAG_AFIRST; - - change &= ~PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* If the *output* is 16-bit then we need to check for a byte-swap on this - * architecture. - */ - if (linear) - { - PNG_CONST png_uint_16 le = 0x0001; - - if (*(png_const_bytep)&le) - png_set_swap(png_ptr); - } - - /* If change is not now 0 some transformation is missing - error out. */ - if (change) - png_error(png_ptr, "png_read_image: unsupported transformation"); - } - - PNG_SKIP_CHUNKS(png_ptr); - - /* Update the 'info' structure and make sure the result is as required; first - * make sure to turn on the interlace handling if it will be required - * (because it can't be turned on *after* the call to png_read_update_info!) - * - * TODO: remove the do_local_background fixup below. - */ - if (!do_local_compose && do_local_background != 2) - passes = png_set_interlace_handling(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - - { - png_uint_32 info_format = 0; - - if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_format |= PNG_FORMAT_FLAG_COLOR; - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - { - /* do_local_compose removes this channel below. */ - if (!do_local_compose) - { - /* do_local_background does the same if required. */ - if (do_local_background != 2 || - (format & PNG_FORMAT_FLAG_ALPHA) != 0) - info_format |= PNG_FORMAT_FLAG_ALPHA; - } - } - - else if (do_local_compose) /* internal error */ - png_error(png_ptr, "png_image_read: alpha channel lost"); - - if (info_ptr->bit_depth == 16) - info_format |= PNG_FORMAT_FLAG_LINEAR; - -# ifdef PNG_FORMAT_BGR_SUPPORTED - if (png_ptr->transformations & PNG_BGR) - info_format |= PNG_FORMAT_FLAG_BGR; -# endif - -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - if (do_local_background == 2) - { - if (format & PNG_FORMAT_FLAG_AFIRST) - info_format |= PNG_FORMAT_FLAG_AFIRST; - } - - if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 || - ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 && - (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0)) - { - if (do_local_background == 2) - png_error(png_ptr, "unexpected alpha swap transformation"); - - info_format |= PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* This is actually an internal error. */ - if (info_format != format) - png_error(png_ptr, "png_read_image: invalid transformations"); - } - - /* Now read the rows. If do_local_compose is set then it is necessary to use - * a local row buffer. The output will be GA, RGBA or BGRA and must be - * converted to G, RGB or BGR as appropriate. The 'local_row' member of the - * display acts as a flag. - */ - { - png_voidp first_row = display->buffer; - ptrdiff_t row_bytes = display->row_stride; - - if (linear) - row_bytes *= 2; - - /* The following expression is designed to work correctly whether it gives - * a signed or an unsigned result. - */ - if (row_bytes < 0) - { - char *ptr = png_voidcast(char*, first_row); - ptr += (image->height-1) * (-row_bytes); - first_row = png_voidcast(png_voidp, ptr); - } - - display->first_row = first_row; - display->row_bytes = row_bytes; - } - - if (do_local_compose) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_composite, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else if (do_local_background == 2) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_background, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else - { - png_alloc_size_t row_bytes = display->row_bytes; - - while (--passes >= 0) - { - png_uint_32 y = image->height; - png_bytep row = png_voidcast(png_bytep, display->first_row); - - while (y-- > 0) - { - png_read_row(png_ptr, row, NULL); - row += row_bytes; - } - } - - return 1; - } -} - -int PNGAPI -png_image_finish_read(png_imagep image, png_const_colorp background, - void *buffer, png_int_32 row_stride, void *colormap) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - png_uint_32 check; - - if (row_stride == 0) - row_stride = PNG_IMAGE_ROW_STRIDE(*image); - - if (row_stride < 0) - check = -row_stride; - - else - check = row_stride; - - if (image->opaque != NULL && buffer != NULL && - check >= PNG_IMAGE_ROW_STRIDE(*image)) - { - if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || - (image->colormap_entries > 0 && colormap != NULL)) - { - int result; - png_image_read_control display; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.background = background; - display.local_row = NULL; - - /* Choose the correct 'end' routine; for the color-map case all the - * setup has already been done. - */ - if (image->format & PNG_FORMAT_FLAG_COLORMAP) - result = - png_safe_execute(image, png_image_read_colormap, &display) && - png_safe_execute(image, png_image_read_colormapped, &display); - - else - result = - png_safe_execute(image, png_image_read_direct, &display); - - png_image_free(image); - return result; - } - - else - return png_image_error(image, - "png_image_finish_read[color-map]: no color-map"); - } - - else - return png_image_error(image, - "png_image_finish_read: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_finish_read: damaged PNG_IMAGE_VERSION"); - - return 0; -} - -#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngrio.c b/Source/3rd Party/wx/src/png/pngrio.c index d7864407b..806f79198 100644 --- a/Source/3rd Party/wx/src/png/pngrio.c +++ b/Source/3rd Party/wx/src/png/pngrio.c @@ -1,15 +1,12 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file provides a location for all input. Users who need * special handling are expected to write a function that has the same * arguments as this and performs a similar function, but that possibly @@ -18,84 +15,130 @@ * libpng use it at run time with png_set_read_fn(...). */ -#include "pngpriv.h" - -#ifdef PNG_READ_SUPPORTED +#define PNG_INTERNAL +#include "png.h" /* Read the data from whatever input you are using. The default routine - * reads from a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered reads. This should never be asked - * to read more then 64K on a 16 bit machine. - */ + reads from a file pointer. Note that this routine sometimes gets called + with very small lengths, so you should implement some kind of simple + buffering if you are using unbuffered reads. This should never be asked + to read more then 64K on a 16 bit machine. */ void /* PRIVATE */ -png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) +png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_debug1(4, "reading %d bytes", (int)length); - + png_debug1(4,"reading %d bytes\n", (int)length); if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); - else png_error(png_ptr, "Call to NULL read function"); } -#ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) /* This is the function that does the actual reading of data. If you are - * not reading from a standard C stream, you should create a replacement - * read_data function and use it at run time with png_set_read_fn(), rather - * than changing the library. - */ -void PNGCBAPI + not reading from a standard C stream, you should create a replacement + read_data function and use it at run time with png_set_read_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; - if (png_ptr == NULL) - return; - /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ - check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else + check = (png_size_t)fread(data, (png_size_t)1, length, + (png_FILE_p)png_ptr->io_ptr); +#endif if (check != length) png_error(png_ptr, "Read Error"); } +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void /* PRIVATE */ +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + int check; + png_byte *n_data; + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + n_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)n_data == data) + { +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else + check = fread(n_data, 1, length, io_ptr); +#endif + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t read, remaining, err; + check = 0; + remaining = length; + do + { + read = MIN(NEAR_BUF_SIZE, remaining); +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) + err = 0; +#else + err = fread(buf, (png_size_t)1, read, io_ptr); +#endif + png_memcpy(data, buf, read); /* copy far buffer to near buffer */ + if(err != read) + break; + else + check += err; + data += read; + remaining -= read; + } + while (remaining != 0); + } + if ((png_uint_32)check != (png_uint_32)length) + png_error(png_ptr, "read Error"); +} +#endif #endif /* This function allows the application to supply a new input function - * for libpng if standard C streams aren't being used. - * - * This function takes as its arguments: - * - * png_ptr - pointer to a png input data structure - * - * io_ptr - pointer to user supplied structure containing info about - * the input functions. May be NULL. - * - * read_data_fn - pointer to a new input function that takes as its - * arguments a pointer to a png_struct, a pointer to - * a location where input data can be stored, and a 32-bit - * unsigned int that is the number of bytes to be read. - * To exit and output any fatal error messages the new write - * function should call png_error(png_ptr, "Error msg"). - * May be NULL, in which case libpng's default function will - * be used. - */ + for libpng if standard C streams aren't being used. + + This function takes as its arguments: + png_ptr - pointer to a png input data structure + io_ptr - pointer to user supplied structure containing info about + the input functions. May be NULL. + read_data_fn - pointer to a new input function that takes as its + arguments a pointer to a png_struct, a pointer to + a location where input data can be stored, and a 32-bit + unsigned int that is the number of bytes to be read. + To exit and output any fatal error messages the new write + function should call png_error(png_ptr, "Error msg"). */ void PNGAPI -png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, +png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { - if (png_ptr == NULL) - return; - png_ptr->io_ptr = io_ptr; -#ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) if (read_data_fn != NULL) png_ptr->read_data_fn = read_data_fn; - else png_ptr->read_data_fn = png_default_read_data; #else @@ -107,12 +150,12 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, { png_ptr->write_data_fn = NULL; png_warning(png_ptr, - "Can't set both read_data_fn and write_data_fn in the" - " same structure"); + "It's an error to set both read_data_fn and write_data_fn in the "); + png_warning(png_ptr, + "same structure. Resetting write_data_fn to NULL."); } -#ifdef PNG_WRITE_FLUSH_SUPPORTED +#if defined(PNG_WRITE_FLUSH_SUPPORTED) png_ptr->output_flush_fn = NULL; #endif } -#endif /* PNG_READ_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngrtran.c b/Source/3rd Party/wx/src/png/pngrtran.c index e378ceba4..b914d0e65 100644 --- a/Source/3rd Party/wx/src/png/pngrtran.c +++ b/Source/3rd Party/wx/src/png/pngrtran.c @@ -1,86 +1,67 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file contains functions optionally called by an application * in order to tell libpng how to handle data when reading a PNG. * Transformations that are used in both reading and writing are * in pngtrans.c. */ -#include "pngpriv.h" - -#ifdef PNG_READ_SUPPORTED +#define PNG_INTERNAL +#include "png.h" /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI -png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) +png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) { - png_debug(1, "in png_set_crc_action"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_crc_action\n"); /* Tell libpng how we react to CRC errors in critical chunks */ switch (crit_action) { - case PNG_CRC_NO_CHANGE: /* Leave setting as is */ + case PNG_CRC_NO_CHANGE: /* leave setting as is */ break; - - case PNG_CRC_WARN_USE: /* Warn/use data */ + case PNG_CRC_WARN_USE: /* warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; break; - - case PNG_CRC_QUIET_USE: /* Quiet/use data */ + case PNG_CRC_QUIET_USE: /* quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; - - case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ - png_warning(png_ptr, - "Can't discard critical data on CRC error"); - case PNG_CRC_ERROR_QUIT: /* Error/quit */ - + case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ + png_warning(png_ptr, "Can't discard critical data on CRC error."); + case PNG_CRC_ERROR_QUIT: /* error/quit */ case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; break; } - /* Tell libpng how we react to CRC errors in ancillary chunks */ switch (ancil_action) { - case PNG_CRC_NO_CHANGE: /* Leave setting as is */ + case PNG_CRC_NO_CHANGE: /* leave setting as is */ break; - - case PNG_CRC_WARN_USE: /* Warn/use data */ + case PNG_CRC_WARN_USE: /* warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; break; - - case PNG_CRC_QUIET_USE: /* Quiet/use data */ + case PNG_CRC_QUIET_USE: /* quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - - case PNG_CRC_ERROR_QUIT: /* Error/quit */ + case PNG_CRC_ERROR_QUIT: /* error/quit */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - - case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ - + case PNG_CRC_WARN_DISCARD: /* warn/discard data */ case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; @@ -88,346 +69,95 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) } } -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -/* Is it OK to set a transformation now? Only if png_start_read_image or - * png_read_update_info have not been called. It is not necessary for the IHDR - * to have been read in all cases, the parameter allows for this check too. - */ -static int -png_rtran_ok(png_structrp png_ptr, int need_IHDR) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +/* handle alpha and tRNS via a background color */ +void PNGAPI +png_set_background(png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) { - if (png_ptr != NULL) - { - if (png_ptr->flags & PNG_FLAG_ROW_INIT) - png_app_error(png_ptr, - "invalid after png_start_read_image or png_read_update_info"); - - else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_app_error(png_ptr, "invalid before the PNG header has been read"); - - else - { - /* Turn on failure to initialize correctly for all transforms. */ - png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; - - return 1; /* Ok */ - } - } - - return 0; /* no png_error possible! */ -} -#endif - -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS via a background color */ -void PNGFAPI -png_set_background_fixed(png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma) -{ - png_debug(1, "in png_set_background_fixed"); - - if (!png_rtran_ok(png_ptr, 0) || background_color == NULL) - return; - + png_debug(1, "in png_set_background\n"); if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); return; } - png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - png_ptr->background = *background_color; - png_ptr->background_gamma = background_gamma; + png_ptr->transformations |= PNG_BACKGROUND; + png_memcpy(&(png_ptr->background), background_color, + png_sizeof(png_color_16)); + png_ptr->background_gamma = (float)background_gamma; png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - if (need_expand) - png_ptr->transformations |= PNG_BACKGROUND_EXPAND; - else - png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; -} + png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_background(png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_set_background_fixed(png_ptr, background_color, background_gamma_code, - need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); -} -# endif /* FLOATING_POINT */ -#endif /* READ_BACKGROUND */ - -/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the - * one that pngrtran does first (scale) happens. This is necessary to allow the - * TRANSFORM and API behavior to be somewhat consistent, and it's simpler. - */ -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -void PNGAPI -png_set_scale_16(png_structrp png_ptr) -{ - png_debug(1, "in png_set_scale_16"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= PNG_SCALE_16_TO_8; + /* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA + * (in which case need_expand is superfluous anyway), the background color + * might actually be gray yet not be flagged as such. This is not a problem + * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to + * decide when to do the png_do_gray_to_rgb() transformation. + */ + if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) || + (!need_expand && background_color->red == background_color->green && + background_color->red == background_color->blue)) + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; } #endif -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -/* Chop 16-bit depth files to 8-bit depth */ +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip 16 bit depth files to 8 bit depth */ void PNGAPI -png_set_strip_16(png_structrp png_ptr) +png_set_strip_16(png_structp png_ptr) { - png_debug(1, "in png_set_strip_16"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - + png_debug(1, "in png_set_strip_16\n"); png_ptr->transformations |= PNG_16_TO_8; } #endif -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) void PNGAPI -png_set_strip_alpha(png_structrp png_ptr) +png_set_strip_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_strip_alpha"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - + png_debug(1, "in png_set_strip_alpha\n"); png_ptr->transformations |= PNG_STRIP_ALPHA; } #endif -#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) -static png_fixed_point -translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, - int is_screen) -{ - /* Check for flag values. The main reason for having the old Mac value as a - * flag is that it is pretty near impossible to work out what the correct - * value is from Apple documentation - a working Mac system is needed to - * discover the value! - */ - if (output_gamma == PNG_DEFAULT_sRGB || - output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB) - { - /* If there is no sRGB support this just sets the gamma to the standard - * sRGB value. (This is a side effect of using this function!) - */ -# ifdef PNG_READ_sRGB_SUPPORTED - png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; -# else - PNG_UNUSED(png_ptr) -# endif - if (is_screen) - output_gamma = PNG_GAMMA_sRGB; - else - output_gamma = PNG_GAMMA_sRGB_INVERSE; - } - - else if (output_gamma == PNG_GAMMA_MAC_18 || - output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18) - { - if (is_screen) - output_gamma = PNG_GAMMA_MAC_OLD; - else - output_gamma = PNG_GAMMA_MAC_INVERSE; - } - - return output_gamma; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -static png_fixed_point -convert_gamma_value(png_structrp png_ptr, double output_gamma) -{ - /* The following silently ignores cases where fixed point (times 100,000) - * gamma values are passed to the floating point API. This is safe and it - * means the fixed point constants work just fine with the floating point - * API. The alternative would just lead to undetected errors and spurious - * bug reports. Negative values fail inside the _fixed API unless they - * correspond to the flag values. - */ - if (output_gamma > 0 && output_gamma < 128) - output_gamma *= PNG_FP_1; - - /* This preserves -1 and -2 exactly: */ - output_gamma = floor(output_gamma + .5); - - if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN) - png_fixed_error(png_ptr, "gamma value"); - - return (png_fixed_point)output_gamma; -} -# endif -#endif /* READ_ALPHA_MODE || READ_GAMMA */ - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -void PNGFAPI -png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, - png_fixed_point output_gamma) -{ - int compose = 0; - png_fixed_point file_gamma; - - png_debug(1, "in png_set_alpha_mode"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); - - /* Validate the value to ensure it is in a reasonable range. The value - * is expected to be 1 or greater, but this range test allows for some - * viewing correction values. The intent is to weed out users of this API - * who use the inverse of the gamma value accidentally! Since some of these - * values are reasonable this may have to be changed. - */ - if (output_gamma < 70000 || output_gamma > 300000) - png_error(png_ptr, "output gamma out of expected range"); - - /* The default file gamma is the inverse of the output gamma; the output - * gamma may be changed below so get the file value first: - */ - file_gamma = png_reciprocal(output_gamma); - - /* There are really 8 possibilities here, composed of any combination - * of: - * - * premultiply the color channels - * do not encode non-opaque pixels - * encode the alpha as well as the color channels - * - * The differences disappear if the input/output ('screen') gamma is 1.0, - * because then the encoding is a no-op and there is only the choice of - * premultiplying the color channels or not. - * - * png_set_alpha_mode and png_set_background interact because both use - * png_compose to do the work. Calling both is only useful when - * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along - * with a default gamma value. Otherwise PNG_COMPOSE must not be set. - */ - switch (mode) - { - case PNG_ALPHA_PNG: /* default: png standard */ - /* No compose, but it may be set by png_set_background! */ - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - break; - - case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */ - compose = 1; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - /* The output is linear: */ - output_gamma = PNG_FP_1; - break; - - case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */ - compose = 1; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; - /* output_gamma records the encoding of opaque pixels! */ - break; - - case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */ - compose = 1; - png_ptr->transformations |= PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - break; - - default: - png_error(png_ptr, "invalid alpha mode"); - } - - /* Only set the default gamma if the file gamma has not been set (this has - * the side effect that the gamma in a second call to png_set_alpha_mode will - * be ignored.) - */ - if (png_ptr->colorspace.gamma == 0) - { - png_ptr->colorspace.gamma = file_gamma; - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - } - - /* But always set the output gamma: */ - png_ptr->screen_gamma = output_gamma; - - /* Finally, if pre-multiplying, set the background fields to achieve the - * desired result. - */ - if (compose) - { - /* And obtain alpha pre-multiplication by composing on black: */ - memset(&png_ptr->background, 0, (sizeof png_ptr->background)); - png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */ - png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; - png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; - - if (png_ptr->transformations & PNG_COMPOSE) - png_error(png_ptr, - "conflicting calls to set alpha mode and background"); - - png_ptr->transformations |= PNG_COMPOSE; - } -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) -{ - png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, - output_gamma)); -} -# endif -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Dither file to 8-bit. Supply a palette, the current number +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Dither file to 8 bit. Supply a palette, the current number * of elements in the palette, the maximum number of elements * allowed, and a histogram if possible. If the current number * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_quantize" indicates - * whether we need a quantizing cube set up for RGB images, or if we + * modified to fit in the maximum number. "full_dither" indicates + * whether we need a dithering cube set up for RGB images, or if we * simply are reducing the number of colors in a paletted image. */ typedef struct png_dsort_struct { - struct png_dsort_struct * next; + struct png_dsort_struct FAR * next; png_byte left; png_byte right; } png_dsort; -typedef png_dsort * png_dsortp; -typedef png_dsort * * png_dsortpp; +typedef png_dsort FAR * png_dsortp; +typedef png_dsort FAR * FAR * png_dsortpp; void PNGAPI -png_set_quantize(png_structrp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_const_uint_16p histogram, - int full_quantize) +png_set_dither(png_structp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_uint_16p histogram, + int full_dither) { - png_debug(1, "in png_set_quantize"); + png_debug(1, "in png_set_dither\n"); + png_ptr->transformations |= PNG_DITHER; - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= PNG_QUANTIZE; - - if (!full_quantize) + if (!full_dither) { int i; - png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); for (i = 0; i < num_palette; i++) - png_ptr->quantize_index[i] = (png_byte)i; + png_ptr->dither_index[i] = (png_byte)i; } if (num_palette > maximum_colors) @@ -435,66 +165,61 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, if (histogram != NULL) { /* This is easy enough, just throw out the least used colors. - * Perhaps not the best solution, but good enough. - */ + Perhaps not the best solution, but good enough. */ int i; - /* Initialize an array to sort colors */ - png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + /* initialize an array to sort colors */ + png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * png_sizeof (png_byte))); - /* Initialize the quantize_sort array */ + /* initialize the dither_sort array */ for (i = 0; i < num_palette; i++) - png_ptr->quantize_sort[i] = (png_byte)i; + png_ptr->dither_sort[i] = (png_byte)i; /* Find the least used palette entries by starting a - * bubble sort, and running it until we have sorted - * out enough colors. Note that we don't care about - * sorting all the colors, just finding which are - * least used. - */ + bubble sort, and running it until we have sorted + out enough colors. Note that we don't care about + sorting all the colors, just finding which are + least used. */ for (i = num_palette - 1; i >= maximum_colors; i--) { - int done; /* To stop early if the list is pre-sorted */ + int done; /* to stop early if the list is pre-sorted */ int j; done = 1; for (j = 0; j < i; j++) { - if (histogram[png_ptr->quantize_sort[j]] - < histogram[png_ptr->quantize_sort[j + 1]]) + if (histogram[png_ptr->dither_sort[j]] + < histogram[png_ptr->dither_sort[j + 1]]) { png_byte t; - t = png_ptr->quantize_sort[j]; - png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; - png_ptr->quantize_sort[j + 1] = t; + t = png_ptr->dither_sort[j]; + png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; + png_ptr->dither_sort[j + 1] = t; done = 0; } } - if (done) break; } - /* Swap the palette around, and set up a table, if necessary */ - if (full_quantize) + /* swap the palette around, and set up a table, if necessary */ + if (full_dither) { int j = num_palette; - /* Put all the useful colors within the max, but don't - * move the others. - */ + /* put all the useful colors within the max, but don't + move the others */ for (i = 0; i < maximum_colors; i++) { - if ((int)png_ptr->quantize_sort[i] >= maximum_colors) + if ((int)png_ptr->dither_sort[i] >= maximum_colors) { do j--; - while ((int)png_ptr->quantize_sort[j] >= maximum_colors); - + while ((int)png_ptr->dither_sort[j] >= maximum_colors); palette[i] = palette[j]; } } @@ -503,38 +228,37 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, { int j = num_palette; - /* Move all the used colors inside the max limit, and - * develop a translation table. - */ + /* move all the used colors inside the max limit, and + develop a translation table */ for (i = 0; i < maximum_colors; i++) { - /* Only move the colors we need to */ - if ((int)png_ptr->quantize_sort[i] >= maximum_colors) + /* only move the colors we need to */ + if ((int)png_ptr->dither_sort[i] >= maximum_colors) { png_color tmp_color; do j--; - while ((int)png_ptr->quantize_sort[j] >= maximum_colors); + while ((int)png_ptr->dither_sort[j] >= maximum_colors); tmp_color = palette[j]; palette[j] = palette[i]; palette[i] = tmp_color; - /* Indicate where the color went */ - png_ptr->quantize_index[j] = (png_byte)i; - png_ptr->quantize_index[i] = (png_byte)j; + /* indicate where the color went */ + png_ptr->dither_index[j] = (png_byte)i; + png_ptr->dither_index[i] = (png_byte)j; } } - /* Find closest color for those colors we are not using */ + /* find closest color for those colors we are not using */ for (i = 0; i < num_palette; i++) { - if ((int)png_ptr->quantize_index[i] >= maximum_colors) + if ((int)png_ptr->dither_index[i] >= maximum_colors) { int min_d, k, min_k, d_index; - /* Find the closest color to one we threw out */ - d_index = png_ptr->quantize_index[i]; + /* find the closest color to one we threw out */ + d_index = png_ptr->dither_index[i]; min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); for (k = 1, min_k = 0; k < maximum_colors; k++) { @@ -548,58 +272,61 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, min_k = k; } } - /* Point to closest color */ - png_ptr->quantize_index[i] = (png_byte)min_k; + /* point to closest color */ + png_ptr->dither_index[i] = (png_byte)min_k; } } } - png_free(png_ptr, png_ptr->quantize_sort); - png_ptr->quantize_sort = NULL; + png_free(png_ptr, png_ptr->dither_sort); + png_ptr->dither_sort=NULL; } else { /* This is much harder to do simply (and quickly). Perhaps - * we need to go through a median cut routine, but those - * don't always behave themselves with only a few colors - * as input. So we will just find the closest two colors, - * and throw out one of them (chosen somewhat randomly). - * [We don't understand this at all, so if someone wants to - * work on improving it, be our guest - AED, GRP] - */ + we need to go through a median cut routine, but those + don't always behave themselves with only a few colors + as input. So we will just find the closest two colors, + and throw out one of them (chosen somewhat randomly). + [We don't understand this at all, so if someone wants to + work on improving it, be our guest - AED, GRP] + */ int i; int max_d; int num_new_palette; png_dsortp t; png_dsortpp hash; - t = NULL; + t=NULL; - /* Initialize palette index arrays */ + /* initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)(num_palette * png_sizeof (png_byte))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)(num_palette * png_sizeof (png_byte))); - /* Initialize the sort array */ + /* initialize the sort array */ for (i = 0; i < num_palette; i++) { png_ptr->index_to_palette[i] = (png_byte)i; png_ptr->palette_to_index[i] = (png_byte)i; } - hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * - (sizeof (png_dsortp)))); + hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * + png_sizeof (png_dsortp))); + for (i = 0; i < 769; i++) + hash[i] = NULL; +/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ num_new_palette = num_palette; - /* Initial wild guess at how far apart the farthest pixel - * pair we will be eliminating will be. Larger - * numbers mean more areas will be allocated, Smaller - * numbers run the risk of not saving enough data, and - * having to do this all over again. - * - * I have not done extensive checking on this number. - */ + /* initial wild guess at how far apart the farthest pixel + pair we will be eliminating will be. Larger + numbers mean more areas will be allocated, Smaller + numbers run the risk of not saving enough data, and + having to do this all over again. + + I have not done extensive checking on this number. + */ max_d = 96; while (num_new_palette > maximum_colors) @@ -618,11 +345,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, { t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(sizeof (png_dsort))); - + (png_uint_32)(png_sizeof(png_dsort))); if (t == NULL) break; - t->next = hash[d]; t->left = (png_byte)i; t->right = (png_byte)j; @@ -643,9 +368,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, for (p = hash[i]; p; p = p->next) { if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) + < num_new_palette && + (int)png_ptr->index_to_palette[p->right] + < num_new_palette) { int j, next_j; @@ -662,36 +387,31 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, num_new_palette--; palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_quantize) + = palette[num_new_palette]; + if (!full_dither) { int k; for (k = 0; k < num_palette; k++) { - if (png_ptr->quantize_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->quantize_index[k] = - png_ptr->index_to_palette[next_j]; - - if ((int)png_ptr->quantize_index[k] == - num_new_palette) - png_ptr->quantize_index[k] = - png_ptr->index_to_palette[j]; + if (png_ptr->dither_index[k] == + png_ptr->index_to_palette[j]) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[next_j]; + if ((int)png_ptr->dither_index[k] == + num_new_palette) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[j]; } } png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - + [num_new_palette]] = png_ptr->index_to_palette[j]; png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; + = png_ptr->palette_to_index[num_new_palette]; - png_ptr->index_to_palette[j] = - (png_byte)num_new_palette; - - png_ptr->palette_to_index[num_new_palette] = - (png_byte)j; + png_ptr->index_to_palette[j] = (png_byte)num_new_palette; + png_ptr->palette_to_index[num_new_palette] = (png_byte)j; } if (num_new_palette <= maximum_colors) break; @@ -720,8 +440,8 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, png_free(png_ptr, hash); png_free(png_ptr, png_ptr->palette_to_index); png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index = NULL; - png_ptr->index_to_palette = NULL; + png_ptr->palette_to_index=NULL; + png_ptr->index_to_palette=NULL; } num_palette = maximum_colors; } @@ -731,38 +451,40 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, } png_ptr->num_palette = (png_uint_16)num_palette; - if (full_quantize) + if (full_dither) { int i; png_bytep distance; - int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS + - PNG_QUANTIZE_BLUE_BITS; - int num_red = (1 << PNG_QUANTIZE_RED_BITS); - int num_green = (1 << PNG_QUANTIZE_GREEN_BITS); - int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS); + int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + + PNG_DITHER_BLUE_BITS; + int num_red = (1 << PNG_DITHER_RED_BITS); + int num_green = (1 << PNG_DITHER_GREEN_BITS); + int num_blue = (1 << PNG_DITHER_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); - png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, - (png_uint_32)(num_entries * (sizeof (png_byte)))); + png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, + (png_uint_32)(num_entries * png_sizeof (png_byte))); + + png_memset(png_ptr->palette_lookup, 0, num_entries * + png_sizeof (png_byte)); distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - (sizeof (png_byte)))); + png_sizeof(png_byte))); - memset(distance, 0xff, num_entries * (sizeof (png_byte))); + png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); for (i = 0; i < num_palette; i++) { int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS)); + int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); + int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); + int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); for (ir = 0; ir < num_red; ir++) { /* int dr = abs(ir - r); */ int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS + - PNG_QUANTIZE_GREEN_BITS)); + int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); for (ig = 0; ig < num_green; ig++) { @@ -770,7 +492,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, int dg = ((ig > g) ? ig - g : g - ig); int dt = dr + dg; int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS); + int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); for (ib = 0; ib < num_blue; ib++) { @@ -793,72 +515,41 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, png_free(png_ptr, distance); } } -#endif /* PNG_READ_QUANTIZE_SUPPORTED */ +#endif -#ifdef PNG_READ_GAMMA_SUPPORTED -void PNGFAPI -png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, - png_fixed_point file_gamma) -{ - png_debug(1, "in png_set_gamma_fixed"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - /* New in libpng-1.5.4 - reserve particular negative values as flags. */ - scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); - file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); - - /* Checking the gamma values for being >0 was added in 1.5.4 along with the - * premultiplied alpha support; this actually hides an undocumented feature - * of the previous implementation which allowed gamma processing to be - * disabled in background handling. There is no evidence (so far) that this - * was being used; however, png_set_background itself accepted and must still - * accept '0' for the gamma value it takes, because it isn't always used. - * - * Since this is an API change (albeit a very minor one that removes an - * undocumented API feature) the following checks were only enabled in - * libpng-1.6.0. - */ - if (file_gamma <= 0) - png_error(png_ptr, "invalid file gamma in png_set_gamma"); - - if (scrn_gamma <= 0) - png_error(png_ptr, "invalid screen gamma in png_set_gamma"); - - /* Set the gamma values unconditionally - this overrides the value in the PNG - * file if a gAMA chunk was present. png_set_alpha_mode provides a - * different, easier, way to default the file gamma. - */ - png_ptr->colorspace.gamma = file_gamma; - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - png_ptr->screen_gamma = scrn_gamma; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) +/* Transform the image from the file_gamma to the screen_gamma. We + * only do transformations on images where the file_gamma and screen_gamma + * are not close reciprocals, otherwise it slows things down slightly, and + * also needlessly introduces small errors. + * + * We will turn off gamma transformation later if no semitransparent entries + * are present in the tRNS array for palette images. We can't do it here + * because we don't necessarily have the tRNS chunk yet. + */ void PNGAPI -png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) +png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) { - png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), - convert_gamma_value(png_ptr, file_gamma)); + png_debug(1, "in png_set_gamma\n"); + if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + png_ptr->transformations |= PNG_GAMMA; + png_ptr->gamma = (float)file_gamma; + png_ptr->screen_gamma = (float)scrn_gamma; } -# endif /* FLOATING_POINT_SUPPORTED */ -#endif /* READ_GAMMA */ +#endif -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand paletted images to RGB, expand grayscale images of * less than 8-bit depth to 8-bit depth, and expand tRNS chunks * to alpha channels. */ void PNGAPI -png_set_expand(png_structrp png_ptr) +png_set_expand(png_structp png_ptr) { - png_debug(1, "in png_set_expand"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; } /* GRR 19990627: the following three functions currently are identical @@ -873,723 +564,238 @@ png_set_expand(png_structrp png_ptr) * * More to the point, these functions make it obvious what libpng will be * doing, whereas "expand" can (and does) mean any number of things. - * - * GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha - * and its name was changed to png_set_expand_gray_1_2_4_to_8(). */ /* Expand paletted images to RGB. */ void PNGAPI -png_set_palette_to_rgb(png_structrp png_ptr) +png_set_palette_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_palette_to_rgb"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; } /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) +png_set_gray_1_2_4_to_8(png_structp png_ptr) { - png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - + png_debug(1, "in png_set_expand\n"); png_ptr->transformations |= PNG_EXPAND; } /* Expand tRNS chunks to alpha channels. */ void PNGAPI -png_set_tRNS_to_alpha(png_structrp png_ptr) +png_set_tRNS_to_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_tRNS_to_alpha"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; } #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise - * it may not work correctly.) - */ +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) void PNGAPI -png_set_expand_16(png_structrp png_ptr) +png_set_gray_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_expand_16"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -void PNGAPI -png_set_gray_to_rgb(png_structrp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb"); - - if (!png_rtran_ok(png_ptr, 0)) - return; - - /* Because rgb must be 8 bits or more: */ - png_set_expand_gray_1_2_4_to_8(png_ptr); + png_debug(1, "in png_set_gray_to_rgb\n"); png_ptr->transformations |= PNG_GRAY_TO_RGB; } #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -void PNGFAPI -png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray"); - - /* Need the IHDR here because of the check on color_type below. */ - /* TODO: fix this */ - if (!png_rtran_ok(png_ptr, 1)) - return; - - switch(error_action) - { - case PNG_ERROR_ACTION_NONE: - png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - - case PNG_ERROR_ACTION_WARN: - png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - - case PNG_ERROR_ACTION_ERROR: - png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - break; - - default: - png_error(png_ptr, "invalid error action to rgb_to_gray"); - break; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#ifdef PNG_READ_EXPAND_SUPPORTED - png_ptr->transformations |= PNG_EXPAND; -#else - { - /* Make this an error in 1.6 because otherwise the application may assume - * that it just worked and get a memory overwrite. - */ - png_error(png_ptr, - "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); - - /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ - } -#endif - { - if (red >= 0 && green >= 0 && red + green <= PNG_FP_1) - { - png_uint_16 red_int, green_int; - - /* NOTE: this calculation does not round, but this behavior is retained - * for consistency, the inaccuracy is very small. The code here always - * overwrites the coefficients, regardless of whether they have been - * defaulted or set already. - */ - red_int = (png_uint_16)(((png_uint_32)red*32768)/100000); - green_int = (png_uint_16)(((png_uint_32)green*32768)/100000); - - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_coefficients_set = 1; - } - - else - { - if (red >= 0 && green >= 0) - png_app_warning(png_ptr, - "ignoring out of range rgb_to_gray coefficients"); - - /* Use the defaults, from the cHRM chunk if set, else the historical - * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See - * png_do_rgb_to_gray for more discussion of the values. In this case - * the coefficients are not marked as 'set' and are not overwritten if - * something has already provided a default. - */ - if (png_ptr->rgb_to_gray_red_coeff == 0 && - png_ptr->rgb_to_gray_green_coeff == 0) - { - png_ptr->rgb_to_gray_red_coeff = 6968; - png_ptr->rgb_to_gray_green_coeff = 23434; - /* png_ptr->rgb_to_gray_blue_coeff = 2366; */ - } - } - } -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) /* Convert a RGB image to a grayscale of the same width. This allows us, * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. */ void PNGAPI -png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, +png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, double green) { - png_set_rgb_to_gray_fixed(png_ptr, error_action, - png_fixed(png_ptr, red, "rgb to gray red coefficient"), - png_fixed(png_ptr, green, "rgb to gray green coefficient")); + int red_fixed = (int)((float)red*100000.0 + 0.5); + int green_fixed = (int)((float)green*100000.0 + 0.5); + png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); } -#endif /* FLOATING POINT */ +#endif -#endif /* RGB_TO_GRAY */ +void PNGAPI +png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) +{ + png_debug(1, "in png_set_rgb_to_gray\n"); + switch(error_action) + { + case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; + break; + case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + break; + case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#if defined(PNG_READ_EXPAND_SUPPORTED) + png_ptr->transformations |= PNG_EXPAND; +#else + { + png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + png_ptr->transformations &= ~PNG_RGB_TO_GRAY; + } +#endif + { + png_uint_16 red_int, green_int; + if(red < 0 || green < 0) + { + red_int = 6968; /* .212671 * 32768 + .5 */ + green_int = 23434; /* .715160 * 32768 + .5 */ + } + else if(red + green < 100000L) + { + red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); + green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + } + else + { + png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); + red_int = 6968; + green_int = 23434; + } + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); + } +} +#endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) void PNGAPI -png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr - read_user_transform_fn) +png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + read_user_transform_fn) { - png_debug(1, "in png_set_read_user_transform_fn"); - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_debug(1, "in png_set_read_user_transform_fn\n"); +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif -} +#ifdef PNG_LEGACY_SUPPORTED + if(read_user_transform_fn) + png_warning(png_ptr, + "This version of libpng does not support user transforms"); #endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -#ifdef PNG_READ_GAMMA_SUPPORTED -/* In the case of gamma transformations only do transformations on images where - * the [file] gamma and screen_gamma are not close reciprocals, otherwise it - * slows things down slightly, and also needlessly introduces small errors. - */ -static int /* PRIVATE */ -png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma) -{ - /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma - * correction as a difference of the overall transform from 1.0 - * - * We want to compare the threshold with s*f - 1, if we get - * overflow here it is because of wacky gamma values so we - * turn on processing anyway. - */ - png_fixed_point gtest; - return !png_muldiv(>est, screen_gamma, file_gamma, PNG_FP_1) || - png_gamma_significant(gtest); } #endif /* Initialize everything needed for the read. This includes modifying * the palette. */ - -/*For the moment 'png_init_palette_transformations' and - * 'png_init_rgb_transformations' only do some flag canceling optimizations. - * The intent is that these two routines should have palette or rgb operations - * extracted from 'png_init_read_transformations'. - */ -static void /* PRIVATE */ -png_init_palette_transformations(png_structrp png_ptr) +void /* PRIVATE */ +png_init_read_transformations(png_structp png_ptr) { - /* Called to handle the (input) palette case. In png_do_read_transformations - * the first step is to expand the palette if requested, so this code must - * take care to only make changes that are invariant with respect to the - * palette expansion, or only do them if there is no expansion. - * - * STRIP_ALPHA has already been handled in the caller (by setting num_trans - * to 0.) - */ - int input_has_alpha = 0; - int input_has_transparency = 0; - - if (png_ptr->num_trans > 0) - { - int i; - - /* Ignore if all the entries are opaque (unlikely!) */ - for (i=0; inum_trans; ++i) - if (png_ptr->trans_alpha[i] == 255) - continue; - else if (png_ptr->trans_alpha[i] == 0) - input_has_transparency = 1; - else - input_has_alpha = 1; - } - - /* If no alpha we can optimize. */ - if (!input_has_alpha) - { - /* Any alpha means background and associative alpha processing is - * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA - * and ENCODE_ALPHA are irrelevant. - */ - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - if (!input_has_transparency) - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); - } + png_debug(1, "in png_init_read_transformations\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if(png_ptr != NULL) +#endif + { +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ + || defined(PNG_READ_GAMMA_SUPPORTED) + int color_type = png_ptr->color_type; +#endif #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* png_set_background handling - deals with the complexity of whether the - * background color is in the file format or the screen format in the case - * where an 'expand' will happen. - */ - - /* The following code cannot be entered in the alpha pre-multiplication case - * because PNG_BACKGROUND_EXPAND is cancelled below. - */ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && (png_ptr->transformations & PNG_EXPAND)) { + if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - /* Invert the alpha channel (in tRNS) unless the pixels are - * going to be expanded, in which case leave it for later - */ - int i, istop = png_ptr->num_trans; - - for (i=0; itrans_alpha[i] = (png_byte)(255 - - png_ptr->trans_alpha[i]); - } - } -#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ - } - } /* background expand and (therefore) no alpha association. */ -#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ -} - -static void /* PRIVATE */ -png_init_rgb_transformations(png_structrp png_ptr) -{ - /* Added to libpng-1.5.4: check the color type to determine whether there - * is any alpha or transparency in the image and simply cancel the - * background and alpha mode stuff if there isn't. - */ - int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; - int input_has_transparency = png_ptr->num_trans > 0; - - /* If no alpha we can optimize. */ - if (!input_has_alpha) - { - /* Any alpha means background and associative alpha processing is - * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA - * and ENCODE_ALPHA are irrelevant. - */ -# ifdef PNG_READ_ALPHA_MODE_SUPPORTED - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; -# endif - - if (!input_has_transparency) - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); - } - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* png_set_background handling - deals with the complexity of whether the - * background color is in the file format or the screen format in the case - * where an 'expand' will happen. - */ - - /* The following code cannot be entered in the alpha pre-multiplication case - * because PNG_BACKGROUND_EXPAND is cancelled below. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND) && - !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) - /* i.e., GRAY or GRAY_ALPHA */ - { - { - /* Expand background and tRNS chunks */ - int gray = png_ptr->background.gray; - int trans_gray = png_ptr->trans_color.gray; - + /* expand background chunk. */ switch (png_ptr->bit_depth) { case 1: - gray *= 0xff; - trans_gray *= 0xff; + png_ptr->background.gray *= (png_uint_16)0xff; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; break; - case 2: - gray *= 0x55; - trans_gray *= 0x55; + png_ptr->background.gray *= (png_uint_16)0x55; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; break; - case 4: - gray *= 0x11; - trans_gray *= 0x11; + png_ptr->background.gray *= (png_uint_16)0x11; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; break; - - default: - case 8: - /* FALL THROUGH (Already 8 bits) */ - case 16: - /* Already a full 16 bits */ + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; break; } - - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = (png_uint_16)gray; - - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_color.red = png_ptr->trans_color.green = - png_ptr->trans_color.blue = (png_uint_16)trans_gray; - } } - } /* background expand and (therefore) no alpha association. */ -#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ -} - -void /* PRIVATE */ -png_init_read_transformations(png_structrp png_ptr) -{ - png_debug(1, "in png_init_read_transformations"); - - /* This internal function is called from png_read_start_row in pngrutil.c - * and it is called before the 'rowbytes' calculation is done, so the code - * in here can change or update the transformations flags. - * - * First do updates that do not depend on the details of the PNG image data - * being processed. - */ - -#ifdef PNG_READ_GAMMA_SUPPORTED - /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds - * png_set_alpha_mode and this is another source for a default file gamma so - * the test needs to be performed later - here. In addition prior to 1.5.4 - * the tests were repeated for the PALETTE color type here - this is no - * longer necessary (and doesn't seem to have been necessary before.) - */ - { - /* The following temporary indicates if overall gamma correction is - * required. - */ - int gamma_correction = 0; - - if (png_ptr->colorspace.gamma != 0) /* has been set */ + else if (color_type == PNG_COLOR_TYPE_PALETTE) { - if (png_ptr->screen_gamma != 0) /* screen set too */ - gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->background.red = + png_ptr->palette[png_ptr->background.index].red; + png_ptr->background.green = + png_ptr->palette[png_ptr->background.index].green; + png_ptr->background.blue = + png_ptr->palette[png_ptr->background.index].blue; - else - /* Assume the output matches the input; a long time default behavior - * of libpng, although the standard has nothing to say about this. - */ - png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma); - } - - else if (png_ptr->screen_gamma != 0) - /* The converse - assume the file matches the screen, note that this - * perhaps undesireable default can (from 1.5.4) be changed by calling - * png_set_alpha_mode (even if the alpha handling mode isn't required - * or isn't changed from the default.) - */ - png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma); - - else /* neither are set */ - /* Just in case the following prevents any processing - file and screen - * are both assumed to be linear and there is no way to introduce a - * third gamma value other than png_set_background with 'UNIQUE', and, - * prior to 1.5.4 - */ - png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1; - - /* We have a gamma value now. */ - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - - /* Now turn the gamma transformation on or off as appropriate. Notice - * that PNG_GAMMA just refers to the file->screen correction. Alpha - * composition may independently cause gamma correction because it needs - * linear data (e.g. if the file has a gAMA chunk but the screen gamma - * hasn't been specified.) In any case this flag may get turned off in - * the code immediately below if the transform can be handled outside the - * row loop. - */ - if (gamma_correction) - png_ptr->transformations |= PNG_GAMMA; - - else - png_ptr->transformations &= ~PNG_GAMMA; - } +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + { +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (!(png_ptr->transformations & PNG_EXPAND)) +#endif + { + /* invert the alpha channel (in tRNS) unless the pixels are + going to be expanded, in which case leave it for later */ + int i,istop; + istop=(int)png_ptr->num_trans; + for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); + } + } #endif - /* Certain transformations have the effect of preventing other - * transformations that happen afterward in png_do_read_transformations, - * resolve the interdependencies here. From the code of - * png_do_read_transformations the order is: - * - * 1) PNG_EXPAND (including PNG_EXPAND_tRNS) - * 2) PNG_STRIP_ALPHA (if no compose) - * 3) PNG_RGB_TO_GRAY - * 4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY - * 5) PNG_COMPOSE - * 6) PNG_GAMMA - * 7) PNG_STRIP_ALPHA (if compose) - * 8) PNG_ENCODE_ALPHA - * 9) PNG_SCALE_16_TO_8 - * 10) PNG_16_TO_8 - * 11) PNG_QUANTIZE (converts to palette) - * 12) PNG_EXPAND_16 - * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY - * 14) PNG_INVERT_MONO - * 15) PNG_SHIFT - * 16) PNG_PACK - * 17) PNG_BGR - * 18) PNG_PACKSWAP - * 19) PNG_FILLER (includes PNG_ADD_ALPHA) - * 20) PNG_INVERT_ALPHA - * 21) PNG_SWAP_ALPHA - * 22) PNG_SWAP_BYTES - * 23) PNG_USER_TRANSFORM [must be last] - */ -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) && - !(png_ptr->transformations & PNG_COMPOSE)) - { - /* Stripping the alpha channel happens immediately after the 'expand' - * transformations, before all other transformation, so it cancels out - * the alpha handling. It has the side effect negating the effect of - * PNG_EXPAND_tRNS too: - */ - png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | - PNG_EXPAND_tRNS); - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - /* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen - * so transparency information would remain just so long as it wasn't - * expanded. This produces unexpected API changes if the set of things - * that do PNG_EXPAND_tRNS changes (perfectly possible given the - * documentation - which says ask for what you want, accept what you - * get.) This makes the behavior consistent from 1.5.4: - */ - png_ptr->num_trans = 0; - } -#endif /* STRIP_ALPHA supported, no COMPOSE */ - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED - /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA - * settings will have no effect. - */ - if (!png_gamma_significant(png_ptr->screen_gamma)) - { - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - } -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* Make sure the coefficients for the rgb to gray conversion are set - * appropriately. - */ - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - png_colorspace_set_rgb_coefficients(png_ptr); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* Detect gray background and attempt to enable optimization for - * gray --> RGB case. - * - * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. - * - * TODO: this code needs to be revised to avoid the complexity and - * interdependencies. The color type of the background should be recorded in - * png_set_background, along with the bit depth, then the code has a record - * of exactly what color space the background is currently in. - */ - if (png_ptr->transformations & PNG_BACKGROUND_EXPAND) - { - /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if - * the file was grayscale the background value is gray. - */ - if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } - - else if (png_ptr->transformations & PNG_COMPOSE) - { - /* PNG_COMPOSE: png_set_background was called with need_expand false, - * so the color is in the color space of the output or png_set_alpha_mode - * was called and the color is black. Ignore RGB_TO_GRAY because that - * happens before GRAY_TO_RGB. - */ - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if (png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; - } } } -#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ -#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */ - - /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations - * can be performed directly on the palette, and some (such as rgb to gray) - * can be optimized inside the palette. This is particularly true of the - * composite (background and alpha) stuff, which can be pretty much all done - * in the palette even if the result is expanded to RGB or gray afterward. - * - * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and - * earlier and the palette stuff is actually handled on the first row. This - * leads to the reported bug that the palette returned by png_get_PLTE is not - * updated. - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_init_palette_transformations(png_ptr); - - else - png_init_rgb_transformations(png_ptr); - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_EXPAND_16_SUPPORTED) - if ((png_ptr->transformations & PNG_EXPAND_16) && - (png_ptr->transformations & PNG_COMPOSE) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - png_ptr->bit_depth != 16) - { - /* TODO: fix this. Because the expand_16 operation is after the compose - * handling the background color must be 8, not 16, bits deep, but the - * application will supply a 16-bit value so reduce it here. - * - * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at - * present, so that case is ok (until do_expand_16 is moved.) - * - * NOTE: this discards the low 16 bits of the user supplied background - * color, but until expand_16 works properly there is no choice! - */ -# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x)) - CHOP(png_ptr->background.red); - CHOP(png_ptr->background.green); - CHOP(png_ptr->background.blue); - CHOP(png_ptr->background.gray); -# undef CHOP - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */ - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \ - defined(PNG_READ_STRIP_16_TO_8_SUPPORTED)) - if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) && - (png_ptr->transformations & PNG_COMPOSE) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - png_ptr->bit_depth == 16) - { - /* On the other hand, if a 16-bit file is to be reduced to 8-bits per - * component this will also happen after PNG_COMPOSE and so the background - * color must be pre-expanded here. - * - * TODO: fix this too. - */ - png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); - png_ptr->background.green = - (png_uint_16)(png_ptr->background.green * 257); - png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); - png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); - } #endif - /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the - * background support (see the comments in scripts/pnglibconf.dfa), this - * allows pre-multiplication of the alpha channel to be implemented as - * compositing on black. This is probably sub-optimal and has been done in - * 1.5.4 betas simply to enable external critique and testing (i.e. to - * implement the new API quickly, without lots of internal changes.) - */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + png_ptr->background_1 = png_ptr->background; +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -#ifdef PNG_READ_GAMMA_SUPPORTED -# ifdef PNG_READ_BACKGROUND_SUPPORTED - /* Includes ALPHA_MODE */ - png_ptr->background_1 = png_ptr->background; -# endif - - /* This needs to change - in the palette image case a whole set of tables are - * built when it would be quicker to just calculate the correct value for - * each palette entry directly. Also, the test is too tricky - why check - * PNG_RGB_TO_GRAY if PNG_GAMMA is not set? The answer seems to be that - * PNG_GAMMA is cancelled even if the gamma is known? The test excludes the - * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction - * the gamma tables will not be built even if composition is required on a - * gamma encoded value. - * - * In 1.5.4 this is addressed below by an additional check on the individual - * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the - * tables. - */ - if ((png_ptr->transformations & PNG_GAMMA) - || ((png_ptr->transformations & PNG_RGB_TO_GRAY) - && (png_gamma_significant(png_ptr->colorspace.gamma) || - png_gamma_significant(png_ptr->screen_gamma))) - || ((png_ptr->transformations & PNG_COMPOSE) - && (png_gamma_significant(png_ptr->colorspace.gamma) - || png_gamma_significant(png_ptr->screen_gamma) -# ifdef PNG_READ_BACKGROUND_SUPPORTED - || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE - && png_gamma_significant(png_ptr->background_gamma)) -# endif - )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) - && png_gamma_significant(png_ptr->screen_gamma)) - ) + if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) + && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) + < PNG_GAMMA_THRESHOLD)) { - png_build_gamma_table(png_ptr, png_ptr->bit_depth); + int i,k; + k=0; + for (i=0; inum_trans; i++) + { + if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) + k=1; /* partial transparency is present */ + } + if (k == 0) + png_ptr->transformations &= (~PNG_GAMMA); + } -#ifdef PNG_READ_BACKGROUND_SUPPORTED - if (png_ptr->transformations & PNG_COMPOSE) + if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) + { + png_build_gamma_table(png_ptr); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) { - /* Issue a warning about this combination: because RGB_TO_GRAY is - * optimized to do the gamma transform if present yet do_background has - * to do the same thing if both options are set a - * double-gamma-correction happens. This is true in all versions of - * libpng to date. - */ - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - png_warning(png_ptr, - "libpng does not support gamma+background+rgb_to_gray"); - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + if (color_type == PNG_COLOR_TYPE_PALETTE) { - /* We don't get to here unless there is a tRNS chunk with non-opaque - * entries - see the checking code at the start of this function. - */ + /* could skip if no transparency and + */ png_color back, back_1; png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) { - back.red = png_ptr->gamma_table[png_ptr->background.red]; back.green = png_ptr->gamma_table[png_ptr->background.green]; back.blue = png_ptr->gamma_table[png_ptr->background.blue]; @@ -1600,90 +806,73 @@ png_init_read_transformations(png_structrp png_ptr) } else { - png_fixed_point g, gs; + double g, gs; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: g = (png_ptr->screen_gamma); - gs = PNG_FP_1; + gs = 1.0; break; - case PNG_BACKGROUND_GAMMA_FILE: - g = png_reciprocal(png_ptr->colorspace.gamma); - gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = png_reciprocal(png_ptr->background_gamma); - gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * + png_ptr->screen_gamma); break; default: - g = PNG_FP_1; /* back_1 */ - gs = PNG_FP_1; /* back */ - break; + g = 1.0; /* back_1 */ + gs = 1.0; /* back */ } - if (png_gamma_significant(gs)) - { - back.red = png_gamma_8bit_correct(png_ptr->background.red, - gs); - back.green = png_gamma_8bit_correct(png_ptr->background.green, - gs); - back.blue = png_gamma_8bit_correct(png_ptr->background.blue, - gs); - } - - else + if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) { back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; } - - if (png_gamma_significant(g)) - { - back_1.red = png_gamma_8bit_correct(png_ptr->background.red, - g); - back_1.green = png_gamma_8bit_correct( - png_ptr->background.green, g); - back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, - g); - } - else { - back_1.red = (png_byte)png_ptr->background.red; - back_1.green = (png_byte)png_ptr->background.green; - back_1.blue = (png_byte)png_ptr->background.blue; + back.red = (png_byte)(pow( + (double)png_ptr->background.red/255, gs) * 255.0 + .5); + back.green = (png_byte)(pow( + (double)png_ptr->background.green/255, gs) * 255.0 + .5); + back.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, gs) * 255.0 + .5); } - } + back_1.red = (png_byte)(pow( + (double)png_ptr->background.red/255, g) * 255.0 + .5); + back_1.green = (png_byte)(pow( + (double)png_ptr->background.green/255, g) * 255.0 + .5); + back_1.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, g) * 255.0 + .5); + } for (i = 0; i < num_palette; i++) { - if (i < (int)png_ptr->num_trans && - png_ptr->trans_alpha[i] != 0xff) + if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) { - if (png_ptr->trans_alpha[i] == 0) + if (png_ptr->trans[i] == 0) { palette[i] = back; } - else /* if (png_ptr->trans_alpha[i] != 0xff) */ + else /* if (png_ptr->trans[i] != 0xff) */ { png_byte v, w; v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); + png_composite(w, v, png_ptr->trans[i], back_1.red); palette[i].red = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); + png_composite(w, v, png_ptr->trans[i], back_1.green); palette[i].green = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); + png_composite(w, v, png_ptr->trans[i], back_1.blue); palette[i].blue = png_ptr->gamma_from_1[w]; } } @@ -1694,140 +883,90 @@ png_init_read_transformations(png_structrp png_ptr) palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } - - /* Prevent the transformations being done again. - * - * NOTE: this is highly dubious; it removes the transformations in - * place. This seems inconsistent with the general treatment of the - * transformations elsewhere. - */ - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); - } /* color_type == PNG_COLOR_TYPE_PALETTE */ - + } /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else /* color_type != PNG_COLOR_TYPE_PALETTE */ + else + /* color_type != PNG_COLOR_TYPE_PALETTE */ { - int gs_sig, g_sig; - png_fixed_point g = PNG_FP_1; /* Correction to linear */ - png_fixed_point gs = PNG_FP_1; /* Correction to screen */ + double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); + double g = 1.0; + double gs = 1.0; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: - g = png_ptr->screen_gamma; - /* gs = PNG_FP_1; */ + g = (png_ptr->screen_gamma); + gs = 1.0; break; - case PNG_BACKGROUND_GAMMA_FILE: - g = png_reciprocal(png_ptr->colorspace.gamma); - gs = png_reciprocal2(png_ptr->colorspace.gamma, + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); break; - - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = png_reciprocal(png_ptr->background_gamma); - gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); - break; - - default: - png_error(png_ptr, "invalid background gamma type"); } - g_sig = png_gamma_significant(g); - gs_sig = png_gamma_significant(gs); - - if (g_sig) - png_ptr->background_1.gray = png_gamma_correct(png_ptr, - png_ptr->background.gray, g); - - if (gs_sig) - png_ptr->background.gray = png_gamma_correct(png_ptr, - png_ptr->background.gray, gs); + png_ptr->background_1.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, g) * m + .5); + png_ptr->background.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, gs) * m + .5); if ((png_ptr->background.red != png_ptr->background.green) || (png_ptr->background.red != png_ptr->background.blue) || (png_ptr->background.red != png_ptr->background.gray)) { /* RGB or RGBA with color background */ - if (g_sig) - { - png_ptr->background_1.red = png_gamma_correct(png_ptr, - png_ptr->background.red, g); - - png_ptr->background_1.green = png_gamma_correct(png_ptr, - png_ptr->background.green, g); - - png_ptr->background_1.blue = png_gamma_correct(png_ptr, - png_ptr->background.blue, g); - } - - if (gs_sig) - { - png_ptr->background.red = png_gamma_correct(png_ptr, - png_ptr->background.red, gs); - - png_ptr->background.green = png_gamma_correct(png_ptr, - png_ptr->background.green, gs); - - png_ptr->background.blue = png_gamma_correct(png_ptr, - png_ptr->background.blue, gs); - } + png_ptr->background_1.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, g) * m + .5); + png_ptr->background_1.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, g) * m + .5); + png_ptr->background_1.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, g) * m + .5); + png_ptr->background.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, gs) * m + .5); + png_ptr->background.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, gs) * m + .5); + png_ptr->background.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, gs) * m + .5); } - else { /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - + = png_ptr->background_1.blue = png_ptr->background_1.gray; png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; + = png_ptr->background.blue = png_ptr->background.gray; } - - /* The background is now in screen gamma: */ - png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; - } /* color_type != PNG_COLOR_TYPE_PALETTE */ - }/* png_ptr->transformations & PNG_BACKGROUND */ - + } + } else - /* Transformation does not include PNG_BACKGROUND */ + /* transformation does not include PNG_BACKGROUND */ #endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* RGB_TO_GRAY needs to have non-gamma-corrected values! */ - && ((png_ptr->transformations & PNG_EXPAND) == 0 || - (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) -#endif - ) + if (color_type == PNG_COLOR_TYPE_PALETTE) { png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; - /* NOTE: there are other transformations that should probably be in - * here too. - */ for (i = 0; i < num_palette; i++) { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } - - /* Done the gamma correction. */ - png_ptr->transformations &= ~PNG_GAMMA; - } /* color_type == PALETTE && !PNG_BACKGROUND transformation */ + } } -#ifdef PNG_READ_BACKGROUND_SUPPORTED +#if defined(PNG_READ_BACKGROUND_SUPPORTED) else #endif -#endif /* PNG_READ_GAMMA_SUPPORTED */ - -#ifdef PNG_READ_BACKGROUND_SUPPORTED - /* No GAMMA transformation (see the hanging else 4 lines above) */ - if ((png_ptr->transformations & PNG_COMPOSE) && - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) +#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + /* No GAMMA transformation */ + if ((png_ptr->transformations & PNG_BACKGROUND) && + (color_type == PNG_COLOR_TYPE_PALETTE)) { int i; int istop = (int)png_ptr->num_trans; @@ -1840,71 +979,54 @@ png_init_read_transformations(png_structrp png_ptr) for (i = 0; i < istop; i++) { - if (png_ptr->trans_alpha[i] == 0) + if (png_ptr->trans[i] == 0) { palette[i] = back; } - - else if (png_ptr->trans_alpha[i] != 0xff) + else if (png_ptr->trans[i] != 0xff) { /* The png_composite() macro is defined in png.h */ png_composite(palette[i].red, palette[i].red, - png_ptr->trans_alpha[i], back.red); - + png_ptr->trans[i], back.red); png_composite(palette[i].green, palette[i].green, - png_ptr->trans_alpha[i], back.green); - + png_ptr->trans[i], back.green); png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans_alpha[i], back.blue); + png_ptr->trans[i], back.blue); } } - - png_ptr->transformations &= ~PNG_COMPOSE; } #endif /* PNG_READ_BACKGROUND_SUPPORTED */ -#ifdef PNG_READ_SHIFT_SUPPORTED +#if defined(PNG_READ_SHIFT_SUPPORTED) if ((png_ptr->transformations & PNG_SHIFT) && - !(png_ptr->transformations & PNG_EXPAND) && - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + (color_type == PNG_COLOR_TYPE_PALETTE)) { - int i; - int istop = png_ptr->num_palette; - int shift = 8 - png_ptr->sig_bit.red; + png_uint_16 i; + png_uint_16 istop = png_ptr->num_palette; + int sr = 8 - png_ptr->sig_bit.red; + int sg = 8 - png_ptr->sig_bit.green; + int sb = 8 - png_ptr->sig_bit.blue; - png_ptr->transformations &= ~PNG_SHIFT; - - /* significant bits can be in the range 1 to 7 for a meaninful result, if - * the number of significant bits is 0 then no shift is done (this is an - * error condition which is silently ignored.) - */ - if (shift > 0 && shift < 8) for (i=0; i 8) + sr = 0; + if (sg < 0 || sg > 8) + sg = 0; + if (sb < 0 || sb > 8) + sb = 0; + for (i = 0; i < istop; i++) { - int component = png_ptr->palette[i].red; - - component >>= shift; - png_ptr->palette[i].red = (png_byte)component; - } - - shift = 8 - png_ptr->sig_bit.green; - if (shift > 0 && shift < 8) for (i=0; ipalette[i].green; - - component >>= shift; - png_ptr->palette[i].green = (png_byte)component; - } - - shift = 8 - png_ptr->sig_bit.blue; - if (shift > 0 && shift < 8) for (i=0; ipalette[i].blue; - - component >>= shift; - png_ptr->palette[i].blue = (png_byte)component; + png_ptr->palette[i].red >>= sr; + png_ptr->palette[i].green >>= sg; + png_ptr->palette[i].blue >>= sb; } } #endif /* PNG_READ_SHIFT_SUPPORTED */ + } +#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ + && !defined(PNG_READ_BACKGROUND_SUPPORTED) + if(png_ptr) + return; +#endif } /* Modify the info structure to reflect the transformations. The @@ -1912,201 +1034,133 @@ png_init_read_transformations(png_structrp png_ptr) * assuming the transformations result in valid PNG data. */ void /* PRIVATE */ -png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) +png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_transform_info"); - -#ifdef PNG_READ_EXPAND_SUPPORTED + png_debug(1, "in png_read_transform_info\n"); +#if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - /* This check must match what actually happens in - * png_do_expand_palette; if it ever checks the tRNS chunk to see if - * it is all opaque we must do the same (at present it does not.) - */ - if (png_ptr->num_trans > 0) + if (png_ptr->num_trans) info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; info_ptr->num_trans = 0; } else { if (png_ptr->num_trans) - { - if (png_ptr->transformations & PNG_EXPAND_tRNS) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - } + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; if (info_ptr->bit_depth < 8) info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; } } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - /* The following is almost certainly wrong unless the background value is in - * the screen space! - */ - if (png_ptr->transformations & PNG_COMPOSE) - info_ptr->background = png_ptr->background; -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED - /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4), - * however it seems that the code in png_init_read_transformations, which has - * been called before this from png_read_update_info->png_read_start_row - * sometimes does the gamma transform and cancels the flag. - * - * TODO: this looks wrong; the info_ptr should end up with a gamma equal to - * the screen_gamma value. The following probably results in weirdness if - * the info_ptr is used by the app after the rows have been read. - */ - info_ptr->colorspace.gamma = png_ptr->colorspace.gamma; -#endif - - if (info_ptr->bit_depth == 16) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) { -# ifdef PNG_READ_16BIT_SUPPORTED -# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - if (png_ptr->transformations & PNG_SCALE_16_TO_8) - info_ptr->bit_depth = 8; -# endif - -# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - if (png_ptr->transformations & PNG_16_TO_8) - info_ptr->bit_depth = 8; -# endif - -# else - /* No 16 bit support: force chopping 16-bit input down to 8, in this case - * the app program can chose if both APIs are available by setting the - * correct scaling to use. - */ -# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - /* For compatibility with previous versions use the strip method by - * default. This code works because if PNG_SCALE_16_TO_8 is already - * set the code below will do that in preference to the chop. - */ - png_ptr->transformations |= PNG_16_TO_8; - info_ptr->bit_depth = 8; -# else - -# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - png_ptr->transformations |= PNG_SCALE_16_TO_8; - info_ptr->bit_depth = 8; -# else - - CONFIGURATION ERROR: you must enable at least one 16 to 8 method -# endif -# endif -#endif /* !READ_16BIT_SUPPORTED */ + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; + info_ptr->num_trans = 0; + info_ptr->background = png_ptr->background; } - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type = (png_byte)(info_ptr->color_type | - PNG_COLOR_MASK_COLOR); #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type = (png_byte)(info_ptr->color_type & - ~PNG_COLOR_MASK_COLOR); +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = png_ptr->gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = png_ptr->int_gamma; +#endif + } #endif -#ifdef PNG_READ_QUANTIZE_SUPPORTED - if (png_ptr->transformations & PNG_QUANTIZE) +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) + info_ptr->bit_depth = 8; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) { if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup && info_ptr->bit_depth == 8) { info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; } } #endif -#ifdef PNG_READ_EXPAND_16_SUPPORTED - if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 && - info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - info_ptr->bit_depth = 16; - } -#endif - -#ifdef PNG_READ_PACK_SUPPORTED +#if defined(PNG_READ_PACK_SUPPORTED) if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) info_ptr->bit_depth = 8; #endif +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + info_ptr->color_type |= PNG_COLOR_MASK_COLOR; +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; +#endif + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; - else info_ptr->channels = 1; -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_STRIP_ALPHA) - { - info_ptr->color_type = (png_byte)(info_ptr->color_type & - ~PNG_COLOR_MASK_ALPHA); - info_ptr->num_trans = 0; - } + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; #endif if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; -#ifdef PNG_READ_FILLER_SUPPORTED +#if defined(PNG_READ_FILLER_SUPPORTED) /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ if ((png_ptr->transformations & PNG_FILLER) && ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; - /* If adding a true alpha channel not just filler */ + /* if adding a true alpha channel not just filler */ +#if !defined(PNG_1_0_X) if (png_ptr->transformations & PNG_ADD_ALPHA) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; +#endif } #endif #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if (info_ptr->bit_depth < png_ptr->user_transform_depth) + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + if(info_ptr->bit_depth < png_ptr->user_transform_depth) info_ptr->bit_depth = png_ptr->user_transform_depth; - - if (info_ptr->channels < png_ptr->user_transform_channels) + if(info_ptr->channels < png_ptr->user_transform_channels) info_ptr->channels = png_ptr->user_transform_channels; - } + } #endif info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); + info_ptr->bit_depth); - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); - /* Adding in 1.5.4: cache the above value in png_struct so that we can later - * check in png_rowbytes that the user buffer won't get overwritten. Note - * that the field is not always set - if png_read_update_info isn't called - * the application has to either not do any transforms or get the calculation - * right itself. - */ - png_ptr->info_rowbytes = info_ptr->rowbytes; - -#ifndef PNG_READ_EXPAND_SUPPORTED - if (png_ptr) +#if !defined(PNG_READ_EXPAND_SUPPORTED) + if(png_ptr) return; #endif } @@ -2116,299 +1170,232 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) * decide how it fits in with the other transformations here. */ void /* PRIVATE */ -png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) +png_do_read_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_read_transformations"); - + png_debug(1, "in png_do_read_transformations\n"); +#if !defined(PNG_USELESS_TESTS_SUPPORTED) if (png_ptr->row_buf == NULL) { - /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this - * error is incredibly rare and incredibly easy to debug without this - * information. - */ +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[50]; + + sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, + png_ptr->pass); + png_error(png_ptr, msg); +#else png_error(png_ptr, "NULL row buffer"); +#endif } +#endif - /* The following is debugging; prior to 1.5.4 the code was never compiled in; - * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro - * PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for - * all transformations, however in practice the ROW_INIT always gets done on - * demand, if necessary. - */ - if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && - !(png_ptr->flags & PNG_FLAG_ROW_INIT)) - { - /* Application has failed to call either png_read_start_image() or - * png_read_update_info() after setting transforms that expand pixels. - * This check added to libpng-1.2.19 (but not enabled until 1.5.4). - */ - png_error(png_ptr, "Uninitialized row"); - } - -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) + if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) { - png_do_expand_palette(row_info, png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); + png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette, png_ptr->trans, png_ptr->num_trans); } - else { - if (png_ptr->num_trans && - (png_ptr->transformations & PNG_EXPAND_tRNS)) - png_do_expand(row_info, png_ptr->row_buf + 1, - &(png_ptr->trans_color)); - + if (png_ptr->num_trans) + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values)); else - png_do_expand(row_info, png_ptr->row_buf + 1, - NULL); + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + NULL); } } #endif -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) && - !(png_ptr->transformations & PNG_COMPOSE) && - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_STRIP_ALPHA) + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + PNG_FLAG_FILLER_AFTER); #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & PNG_RGB_TO_GRAY) { int rgb_error = - png_do_rgb_to_gray(png_ptr, row_info, - png_ptr->row_buf + 1); - - if (rgb_error) + png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); + if(rgb_error) { png_ptr->rgb_to_gray_status=1; - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == - PNG_RGB_TO_GRAY_WARN) + if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == - PNG_RGB_TO_GRAY_ERR) + if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); } } #endif -/* From Andreas Dilger e-mail to png-implement, 26 March 1998: - * - * In most cases, the "simple transparency" should be done prior to doing - * gray-to-RGB, or you will have to test 3x as many bytes to check if a - * pixel is transparent. You would also need to make sure that the - * transparency information is upgraded to RGB. - * - * To summarize, the current flow is: - * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - * with background "in place" if transparent, - * convert to RGB if necessary - * - Gray + alpha -> composite with gray background and remove alpha bytes, - * convert to RGB if necessary - * - * To support RGB backgrounds for gray images we need: - * - Gray + simple transparency -> convert to RGB + simple transparency, - * compare 3 or 6 bytes and composite with - * background "in place" if transparent - * (3x compare/pixel compared to doing - * composite with gray bkgrnd) - * - Gray + alpha -> convert to RGB + alpha, composite with background and - * remove alpha bytes (3x float - * operations/pixel compared with composite - * on gray background) - * - * Greg's change will do this. The reason it wasn't done before is for - * performance, as this increases the per-pixel operations. If we would check - * in advance if the background was gray or RGB, and position the gray-to-RGB - * transform appropriately, then it would save a lot of work/time. +/* +From Andreas Dilger e-mail to png-implement, 26 March 1998: + + In most cases, the "simple transparency" should be done prior to doing + gray-to-RGB, or you will have to test 3x as many bytes to check if a + pixel is transparent. You would also need to make sure that the + transparency information is upgraded to RGB. + + To summarize, the current flow is: + - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + with background "in place" if transparent, + convert to RGB if necessary + - Gray + alpha -> composite with gray background and remove alpha bytes, + convert to RGB if necessary + + To support RGB backgrounds for gray images we need: + - Gray + simple transparency -> convert to RGB + simple transparency, compare + 3 or 6 bytes and composite with background + "in place" if transparent (3x compare/pixel + compared to doing composite with gray bkgrnd) + - Gray + alpha -> convert to RGB + alpha, composite with background and + remove alpha bytes (3x float operations/pixel + compared with composite on gray background) + + Greg's change will do this. The reason it wasn't done before is for + performance, as this increases the per-pixel operations. If we would check + in advance if the background was gray or RGB, and position the gray-to-RGB + transform appropriately, then it would save a lot of work/time. */ -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* If gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons - */ +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - if (png_ptr->transformations & PNG_COMPOSE) - png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if ((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0 ) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) + png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values), &(png_ptr->background) +#if defined(PNG_READ_GAMMA_SUPPORTED) + , &(png_ptr->background_1), + png_ptr->gamma_table, png_ptr->gamma_from_1, + png_ptr->gamma_to_1, png_ptr->gamma_16_table, + png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, + png_ptr->gamma_shift +#endif +); #endif -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if ((png_ptr->transformations & PNG_GAMMA) && -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* Because RGB_TO_GRAY does the gamma transform. */ - !(png_ptr->transformations & PNG_RGB_TO_GRAY) && +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + !((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - /* Because PNG_COMPOSE does the gamma transform if there is something to - * do (if there is an alpha channel or transparency.) - */ - !((png_ptr->transformations & PNG_COMPOSE) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - /* Because png_init_read_transformations transforms the palette, unless - * RGB_TO_GRAY will do the transform. - */ - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->gamma_table, png_ptr->gamma_16_table, + png_ptr->gamma_shift); #endif -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) && - (png_ptr->transformations & PNG_COMPOSE) && - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED - if ((png_ptr->transformations & PNG_ENCODE_ALPHA) && - (row_info->color_type & PNG_COLOR_MASK_ALPHA)) - png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - if (png_ptr->transformations & PNG_SCALE_16_TO_8) - png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - /* There is no harm in doing both of these because only one has any effect, - * by putting the 'scale' option first if the app asks for scale (either by - * calling the API or in a TRANSFORM flag) this is what happens. - */ +#if defined(PNG_READ_16_TO_8_SUPPORTED) if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(row_info, png_ptr->row_buf + 1); + png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_QUANTIZE_SUPPORTED - if (png_ptr->transformations & PNG_QUANTIZE) +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) { - png_do_quantize(row_info, png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->quantize_index); - - if (row_info->rowbytes == 0) - png_error(png_ptr, "png_do_quantize returned rowbytes=0"); + png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette_lookup, png_ptr->dither_index); + if(png_ptr->row_info.rowbytes == (png_uint_32)0) + png_error(png_ptr, "png_do_dither returned rowbytes=0"); } -#endif /* PNG_READ_QUANTIZE_SUPPORTED */ - -#ifdef PNG_READ_EXPAND_16_SUPPORTED - /* Do the expansion now, after all the arithmetic has been done. Notice - * that previous transformations can handle the PNG_EXPAND_16 flag if this - * is efficient (particularly true in the case of gamma correction, where - * better accuracy results faster!) - */ - if (png_ptr->transformations & PNG_EXPAND_16) - png_do_expand_16(row_info, png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* NOTE: moved here in 1.5.4 (from much later in this list.) */ +#if defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if we did not do so above */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_INVERT_SUPPORTED - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_SHIFT_SUPPORTED - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#ifdef PNG_READ_PACK_SUPPORTED - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Added at libpng-1.5.10 */ - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max >= 0) - png_do_check_palette_indexes(png_ptr, row_info); -#endif - -#ifdef PNG_READ_BGR_SUPPORTED - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_PACKSWAP_SUPPORTED - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_FILLER_SUPPORTED +#if defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(row_info, png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); + png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->filler, png_ptr->flags); #endif -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); + png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); + png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_16BIT_SUPPORTED -#ifdef PNG_READ_SWAP_SUPPORTED +#if defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(row_info, png_ptr->row_buf + 1); -#endif + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) if (png_ptr->transformations & PNG_USER_TRANSFORM) { - if (png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* User read transform function */ - (png_ptr, /* png_ptr */ - row_info, /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_size_t rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED - if (png_ptr->user_transform_depth) - row_info->bit_depth = png_ptr->user_transform_depth; - - if (png_ptr->user_transform_channels) - row_info->channels = png_ptr->user_transform_channels; + if(png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* user read transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if(png_ptr->user_transform_depth) + png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; + if(png_ptr->user_transform_channels) + png_ptr->row_info.channels = png_ptr->user_transform_channels; #endif - row_info->pixel_depth = (png_byte)(row_info->bit_depth * - row_info->channels); - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width); + png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * + png_ptr->row_info.channels); + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); } #endif + } -#ifdef PNG_READ_PACK_SUPPORTED +#if defined(PNG_READ_PACK_SUPPORTED) /* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, * without changing the actual values. Thus, if you had a row with * a bit depth of 1, you would end up with bytes that only contained @@ -2418,9 +1405,12 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_unpack"); - + png_debug(1, "in png_do_unpack\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth < 8) +#else if (row_info->bit_depth < 8) +#endif { png_uint_32 i; png_uint_32 row_width=row_info->width; @@ -2435,13 +1425,11 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) { shift = 0; sp--; } - else shift++; @@ -2449,7 +1437,6 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } - case 2: { @@ -2459,13 +1446,11 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) { shift = 0; sp--; } - else shift += 2; @@ -2473,7 +1458,6 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } - case 4: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); @@ -2482,13 +1466,11 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) { shift = 0; sp--; } - else shift = 4; @@ -2496,9 +1478,6 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } - - default: - break; } row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); @@ -2507,229 +1486,164 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } #endif -#ifdef PNG_READ_SHIFT_SUPPORTED +#if defined(PNG_READ_SHIFT_SUPPORTED) /* Reverse the effects of png_do_shift. This routine merely shifts the * pixels back to their significant bits values. Thus, if you have * a row of bit depth 8, but only 5 are significant, this will shift * the values back to 0 through 31. */ void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, - png_const_color_8p sig_bits) +png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { - int color_type; - - png_debug(1, "in png_do_unshift"); - - /* The palette case has already been handled in the _init routine. */ - color_type = row_info->color_type; - - if (color_type != PNG_COLOR_TYPE_PALETTE) + png_debug(1, "in png_do_unshift\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && sig_bits != NULL && +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift[4]; int channels = 0; - int bit_depth = row_info->bit_depth; + int c; + png_uint_16 value = 0; + png_uint_32 row_width = row_info->width; - if (color_type & PNG_COLOR_MASK_COLOR) + if (row_info->color_type & PNG_COLOR_MASK_COLOR) { - shift[channels++] = bit_depth - sig_bits->red; - shift[channels++] = bit_depth - sig_bits->green; - shift[channels++] = bit_depth - sig_bits->blue; + shift[channels++] = row_info->bit_depth - sig_bits->red; + shift[channels++] = row_info->bit_depth - sig_bits->green; + shift[channels++] = row_info->bit_depth - sig_bits->blue; } - else { - shift[channels++] = bit_depth - sig_bits->gray; + shift[channels++] = row_info->bit_depth - sig_bits->gray; + } + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + shift[channels++] = row_info->bit_depth - sig_bits->alpha; } - if (color_type & PNG_COLOR_MASK_ALPHA) + for (c = 0; c < channels; c++) { - shift[channels++] = bit_depth - sig_bits->alpha; + if (shift[c] <= 0) + shift[c] = 0; + else + value = 1; } + if (!value) + return; + + switch (row_info->bit_depth) { - int c, have_shift; - - for (c = have_shift = 0; c < channels; ++c) - { - /* A shift of more than the bit depth is an error condition but it - * gets ignored here. - */ - if (shift[c] <= 0 || shift[c] >= bit_depth) - shift[c] = 0; - - else - have_shift = 1; - } - - if (!have_shift) - return; - } - - switch (bit_depth) - { - default: - /* Must be 1bpp gray: should not be here! */ - /* NOTREACHED */ - break; - case 2: - /* Must be 2bpp gray */ - /* assert(channels == 1 && shift[0] == 1) */ { - png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; + png_bytep bp; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; - while (bp < bp_end) + for (bp = row, i = 0; i < istop; i++) { - int b = (*bp >> 1) & 0x55; - *bp++ = (png_byte)b; + *bp >>= 1; + *bp++ &= 0x55; } break; } - case 4: - /* Must be 4bpp gray */ - /* assert(channels == 1) */ { png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int gray_shift = shift[0]; - int mask = 0xf >> gray_shift; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | + (png_byte)((int)0xf >> shift[0])); - mask |= mask << 4; - - while (bp < bp_end) + for (i = 0; i < istop; i++) { - int b = (*bp >> gray_shift) & mask; - *bp++ = (png_byte)b; + *bp >>= shift[0]; + *bp++ &= mask; } break; } - case 8: - /* Single byte components, G, GA, RGB, RGBA */ { png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int channel = 0; + png_uint_32 i; + png_uint_32 istop = row_width * channels; - while (bp < bp_end) + for (i = 0; i < istop; i++) { - int b = *bp >> shift[channel]; - if (++channel >= channels) - channel = 0; - *bp++ = (png_byte)b; + *bp++ >>= shift[i%channels]; } break; } - -#ifdef PNG_READ_16BIT_SUPPORTED case 16: - /* Double byte components, G, GA, RGB, RGBA */ { png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int channel = 0; + png_uint_32 i; + png_uint_32 istop = channels * row_width; - while (bp < bp_end) + for (i = 0; i < istop; i++) { - int value = (bp[0] << 8) + bp[1]; - - value >>= shift[channel]; - if (++channel >= channels) - channel = 0; + value = (png_uint_16)((*bp << 8) + *(bp + 1)); + value >>= shift[i%channels]; *bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)(value & 0xff); } break; } -#endif } } } #endif -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale rows of bit depth 16 down to 8 accurately */ +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ -png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_scale_16_to_8"); - - if (row_info->bit_depth == 16) - { - png_bytep sp = row; /* source */ - png_bytep dp = row; /* destination */ - png_bytep ep = sp + row_info->rowbytes; /* end+1 */ - - while (sp < ep) - { - /* The input is an array of 16 bit components, these must be scaled to - * 8 bits each. For a 16 bit value V the required value (from the PNG - * specification) is: - * - * (V * 255) / 65535 - * - * This reduces to round(V / 257), or floor((V + 128.5)/257) - * - * Represent V as the two byte value vhi.vlo. Make a guess that the - * result is the top byte of V, vhi, then the correction to this value - * is: - * - * error = floor(((V-vhi.vhi) + 128.5) / 257) - * = floor(((vlo-vhi) + 128.5) / 257) - * - * This can be approximated using integer arithmetic (and a signed - * shift): - * - * error = (vlo-vhi+128) >> 8; - * - * The approximate differs from the exact answer only when (vlo-vhi) is - * 128; it then gives a correction of +1 when the exact correction is - * 0. This gives 128 errors. The exact answer (correct for all 16 bit - * input values) is: - * - * error = (vlo-vhi+128)*65535 >> 24; - * - * An alternative arithmetic calculation which also gives no errors is: - * - * (V * 255 + 32895) >> 16 - */ - - png_int_32 tmp = *sp++; /* must be signed! */ - tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; - *dp++ = (png_byte)tmp; - } - - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -void /* PRIVATE */ -/* Simply discard the low byte. This was the default behavior prior - * to libpng-1.5.4. - */ png_do_chop(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_chop"); - + png_debug(1, "in png_do_chop\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth == 16) +#else if (row_info->bit_depth == 16) +#endif { - png_bytep sp = row; /* source */ - png_bytep dp = row; /* destination */ - png_bytep ep = sp + row_info->rowbytes; /* end+1 */ + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + png_uint_32 istop = row_info->width * row_info->channels; - while (sp < ep) + for (i = 0; i> 8)) >> 8; + * + * Approximate calculation with shift/add instead of multiply/divide: + * *dp = ((((png_uint_32)(*sp) << 8) | + * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; + * + * What we actually do to avoid extra shifting and conversion: + */ + *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); +#else + /* Simply discard the low order byte */ + *dp = *sp; +#endif + } row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); row_info->rowbytes = row_info->width * row_info->channels; @@ -2737,12 +1651,14 @@ png_do_chop(png_row_infop row_info, png_bytep row) } #endif -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_swap_alpha"); - + png_debug(1, "in png_do_read_swap_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) @@ -2764,8 +1680,6 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save; } } - -#ifdef PNG_READ_16BIT_SUPPORTED /* This converts from RRGGBBAA to AARRGGBB */ else { @@ -2788,9 +1702,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save[1]; } } -#endif } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { /* This converts from GA to AG */ @@ -2808,8 +1720,6 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save; } } - -#ifdef PNG_READ_16BIT_SUPPORTED /* This converts from GGAA to AAGG */ else { @@ -2828,137 +1738,133 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save[1]; } } -#endif } } } #endif -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { - png_uint_32 row_width; - png_debug(1, "in png_do_read_invert_alpha"); - - row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_debug(1, "in png_do_read_invert_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { - if (row_info->bit_depth == 8) + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { /* This inverts the alpha channel in RGBA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) + if (row_info->bit_depth == 8) { - *(--dp) = (png_byte)(255 - *(--sp)); + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: */ - sp-=3; - dp=sp; + sp-=3; + dp=sp; + } + } + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=6; + dp=sp; + } } } - -#ifdef PNG_READ_16BIT_SUPPORTED - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } -#endif - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { /* This inverts the alpha channel in GA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) + if (row_info->bit_depth == 8) { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; -#ifdef PNG_READ_16BIT_SUPPORTED - else - { + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = *(--sp); + } + } /* This inverts the alpha channel in GGAA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) + else { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); /* - *(--dp) = *(--sp); - *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); */ - sp-=2; - dp=sp; + sp-=2; + dp=sp; + } } } -#endif } } #endif -#ifdef PNG_READ_FILLER_SUPPORTED +#if defined(PNG_READ_FILLER_SUPPORTED) /* Add filler channel if we have RGB color */ void /* PRIVATE */ png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) + png_uint_32 filler, png_uint_32 flags) { png_uint_32 i; png_uint_32 row_width = row_info->width; -#ifdef PNG_READ_16BIT_SUPPORTED png_byte hi_filler = (png_byte)((filler>>8) & 0xff); -#endif png_byte lo_filler = (png_byte)(filler & 0xff); - png_debug(1, "in png_do_read_filler"); - + png_debug(1, "in png_do_read_filler\n"); if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { - if (row_info->bit_depth == 8) + if(row_info->bit_depth == 8) { + /* This changes the data from G to GX */ if (flags & PNG_FLAG_FILLER_AFTER) { - /* This changes the data from G to GX */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) @@ -2971,10 +1877,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } - + /* This changes the data from G to XG */ else { - /* This changes the data from G to XG */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) @@ -2987,13 +1892,11 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 2; } } - -#ifdef PNG_READ_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) + else if(row_info->bit_depth == 16) { + /* This changes the data from GG to GGXX */ if (flags & PNG_FLAG_FILLER_AFTER) { - /* This changes the data from GG to GGXX */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) @@ -3009,10 +1912,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - + /* This changes the data from GG to XXGG */ else { - /* This changes the data from GG to XXGG */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -3027,15 +1929,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 4; } } -#endif } /* COLOR_TYPE == GRAY */ else if (row_info->color_type == PNG_COLOR_TYPE_RGB) { - if (row_info->bit_depth == 8) + if(row_info->bit_depth == 8) { + /* This changes the data from RGB to RGBX */ if (flags & PNG_FLAG_FILLER_AFTER) { - /* This changes the data from RGB to RGBX */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) @@ -3050,10 +1951,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - + /* This changes the data from RGB to XRGB */ else { - /* This changes the data from RGB to XRGB */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) @@ -3068,13 +1968,11 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 4; } } - -#ifdef PNG_READ_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) + else if(row_info->bit_depth == 16) { + /* This changes the data from RRGGBB to RRGGBBXX */ if (flags & PNG_FLAG_FILLER_AFTER) { - /* This changes the data from RRGGBB to RRGGBBXX */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) @@ -3094,10 +1992,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } - + /* This changes the data from RRGGBB to XXRRGGBB */ else { - /* This changes the data from RRGGBB to XXRRGGBB */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -3111,35 +2008,34 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, *(--dp) = hi_filler; *(--dp) = lo_filler; } - row_info->channels = 4; row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } } -#endif } /* COLOR_TYPE == RGB */ } #endif -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -/* Expand grayscale files to RGB, with or without alpha */ +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* expand grayscale files to RGB, with or without alpha */ void /* PRIVATE */ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) { png_uint_32 i; png_uint_32 row_width = row_info->width; - png_debug(1, "in png_do_gray_to_rgb"); - + png_debug(1, "in png_do_gray_to_rgb\n"); if (row_info->bit_depth >= 8 && - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + !(row_info->color_type & PNG_COLOR_MASK_COLOR)) { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { - /* This changes G to RGB */ png_bytep sp = row + (png_size_t)row_width - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -3149,10 +2045,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) *(dp--) = *(sp--); } } - else { - /* This changes GG to RRGGBB */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) @@ -3166,12 +2060,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) } } } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (row_info->bit_depth == 8) { - /* This changes GA to RGBA */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -3182,10 +2074,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) *(dp--) = *(sp--); } } - else { - /* This changes GGAA to RRGGBBAA */ png_bytep sp = row + (png_size_t)row_width * 4 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) @@ -3201,269 +2091,273 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) } } } - row_info->channels = (png_byte)(row_info->channels + 2); + row_info->channels += (png_byte)2; row_info->color_type |= PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } #endif -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -/* Reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ of 1998-01-04 at - * (THIS LINK IS DEAD June 2008 but - * versions dated 1998 through November 2002 have been archived at - * http://web.archive.org/web/20000816232553/http://www.inforamp.net/ - * ~poynton/notes/colour_and_gamma/ColorFAQ.txt ) - * Charles Poynton poynton at poynton.com +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* reduce RGB files to grayscale, with or without alpha + * using the equation given in Poynton's ColorFAQ at + * + * Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net * * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B * + * We approximate this with + * + * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + * * which can be expressed with integers as * * Y = (6969 * R + 23434 * G + 2365 * B)/32768 * - * Poynton's current link (as of January 2003 through July 2011): - * - * has changed the numbers slightly: + * The calculation is to be done in a linear colorspace. * - * Y = 0.2126*R + 0.7152*G + 0.0722*B - * - * which can be expressed with integers as - * - * Y = (6966 * R + 23436 * G + 2366 * B)/32768 - * - * Historically, however, libpng uses numbers derived from the ITU-R Rec 709 - * end point chromaticities and the D65 white point. Depending on the - * precision used for the D65 white point this produces a variety of different - * numbers, however if the four decimal place value used in ITU-R Rec 709 is - * used (0.3127,0.3290) the Y calculation would be: - * - * Y = (6968 * R + 23435 * G + 2366 * B)/32768 - * - * While this is correct the rounding results in an overflow for white, because - * the sum of the rounded coefficients is 32769, not 32768. Consequently - * libpng uses, instead, the closest non-overflowing approximation: - * - * Y = (6968 * R + 23434 * G + 2366 * B)/32768 - * - * Starting with libpng-1.5.5, if the image being converted has a cHRM chunk - * (including an sRGB chunk) then the chromaticities are used to calculate the - * coefficients. See the chunk handling in pngrutil.c for more information. - * - * In all cases the calculation is to be done in a linear colorspace. If no - * gamma information is available to correct the encoding of the original RGB - * values this results in an implicit assumption that the original PNG RGB - * values were linear. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). Because - * the API takes just red and green coefficients the blue coefficient is - * calculated to make the sum 32768. This will result in different rounding - * to that used above. + * Other integer coefficents can be used via png_set_rgb_to_gray(). */ int /* PRIVATE */ -png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) +png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) { + png_uint_32 i; + + png_uint_32 row_width = row_info->width; int rgb_error = 0; - png_debug(1, "in png_do_rgb_to_gray"); - - if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) && - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_rgb_to_gray\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) { - PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - PNG_CONST png_uint_32 bc = 32768 - rc - gc; - PNG_CONST png_uint_32 row_width = row_info->width; - PNG_CONST int have_alpha = - (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; + png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - if (row_info->bit_depth == 8) + if (row_info->color_type == PNG_COLOR_TYPE_RGB) { -#ifdef PNG_READ_GAMMA_SUPPORTED - /* Notice that gamma to/from 1 are not necessarily inverses (if - * there is an overall gamma correction). Prior to 1.5.5 this code - * checked the linearized values for equality; this doesn't match - * the documentation, the original values must be checked. - */ - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + if (row_info->bit_depth == 8) { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); + png_bytep sp = row; + png_bytep dp = row; - if (red != green || red != blue) + for (i = 0; i < row_width; i++) { - red = png_ptr->gamma_to_1[red]; - green = png_ptr->gamma_to_1[green]; - blue = png_ptr->gamma_to_1[blue]; - - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red + gc*green + bc*blue + 16384)>>15]; - } - - else - { - /* If there is no overall correction the table will not be - * set. - */ - if (png_ptr->gamma_table != NULL) - red = png_ptr->gamma_table[red]; - - *(dp++) = red; - } - - if (have_alpha) - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - - if (red != green || red != blue) - { - rgb_error |= 1; - /* NOTE: this is the historical approach which simply - * truncates the results. - */ - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - } - - else - *(dp++) = red; - - if (have_alpha) - *(dp++) = *(sp++); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - - if (red == green && red == blue) - { - if (png_ptr->gamma_16_table != NULL) - w = png_ptr->gamma_16_table[(red&0xff) - >> png_ptr->gamma_shift][red>>8]; - + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1[ + (rc*red+gc*green+bc*blue)>>15]; + } else - w = red; + *(dp++) = *(sp-1); } - - else + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) - >> png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = - png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) - >> png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1 + 16384)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - - if (have_alpha) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); + } + else + *(dp++) = *(sp-1); } } } - else -#endif + + else /* RGB bit_depth == 16 */ { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - - if (red != green || red != blue) - rgb_error |= 1; - - /* From 1.5.5 in the 16 bit case do the accurate conversion even - * in the 'fast' case - this is because this is where the code - * ends up when handling linear 16 bit data. - */ - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >> - 15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - - if (have_alpha) + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + + bc*blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + } + } + } + } + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1 + [(rc*red + gc*green + bc*blue)>>15]; + *(dp++) = *(sp++); /* alpha */ + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = *(sp++); /* alpha */ + } + } + } + else /* RGBA bit_depth == 16 */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc * red_1 + + gc * green_1 + bc * blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + *(dp++) = *(sp++); /* alpha */ *(dp++) = *(sp++); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + *(dp++) = *(sp++); /* alpha */ *(dp++) = *(sp++); } } } } - - row_info->channels = (png_byte)(row_info->channels - 2); - row_info->color_type = (png_byte)(row_info->color_type & - ~PNG_COLOR_MASK_COLOR); + row_info->channels -= (png_byte)2; + row_info->color_type &= ~PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } return rgb_error; } #endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED /* Build a grayscale palette. Palette is assumed to be 1 << bit_depth * large of png_color. This lets grayscale images be treated as * paletted. Most useful for gamma correction and simplification - * of code. This API is not used internally. + * of code. */ void PNGAPI png_build_grayscale_palette(int bit_depth, png_colorp palette) @@ -3473,8 +2367,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) int i; int v; - png_debug(1, "in png_do_build_grayscale_palette"); - + png_debug(1, "in png_do_build_grayscale_palette\n"); if (palette == NULL) return; @@ -3484,22 +2377,18 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) num_palette = 2; color_inc = 0xff; break; - case 2: num_palette = 4; color_inc = 0x55; break; - case 4: num_palette = 16; color_inc = 0x11; break; - case 8: num_palette = 256; color_inc = 1; break; - default: num_palette = 0; color_inc = 0; @@ -3513,37 +2402,217 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) palette[i].blue = (png_byte)v; } } + +/* This function is currently unused. Do we really need it? */ +#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) +void /* PRIVATE */ +png_correct_palette(png_structp png_ptr, png_colorp palette, + int num_palette) +{ + png_debug(1, "in png_correct_palette\n"); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) + { + png_color back, back_1; + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + double g; + + g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || + fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) + { + back.red = png_ptr->background.red; + back.green = png_ptr->background.green; + back.blue = png_ptr->background.blue; + } + else + { + back.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + g = 1.0 / png_ptr->background_gamma; + + back_1.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back_1.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back_1.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_uint_32 i; + + for (i = 0; i < (png_uint_32)num_palette; i++) + { + if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) + { + png_byte v, w; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; + png_composite(w, v, png_ptr->trans[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; + png_composite(w, v, png_ptr->trans[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; + png_composite(w, v, png_ptr->trans[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + else + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (palette[i].red == (png_byte)png_ptr->trans_values.gray) + { + palette[i] = back; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + } + else +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { + int i; + + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + else +#endif +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_color back; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < (int)png_ptr->num_trans; i++) + { + if (png_ptr->trans[i] == 0) + { + palette[i].red = back.red; + palette[i].green = back.green; + palette[i].blue = back.blue; + } + else if (png_ptr->trans[i] != 0xff) + { + png_composite(palette[i].red, png_ptr->palette[i].red, + png_ptr->trans[i], back.red); + png_composite(palette[i].green, png_ptr->palette[i].green, + png_ptr->trans[i], back.green); + png_composite(palette[i].blue, png_ptr->palette[i].blue, + png_ptr->trans[i], back.blue); + } + } + } + else /* assume grayscale palette (what else could it be?) */ + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (i == (png_byte)png_ptr->trans_values.gray) + { + palette[i].red = (png_byte)png_ptr->background.red; + palette[i].green = (png_byte)png_ptr->background.green; + palette[i].blue = (png_byte)png_ptr->background.blue; + } + } + } + } +#endif +} #endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. */ void /* PRIVATE */ -png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) -{ -#ifdef PNG_READ_GAMMA_SUPPORTED - png_const_bytep gamma_table = png_ptr->gamma_table; - png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; - png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; - png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; - png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; - png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; - int gamma_shift = png_ptr->gamma_shift; - int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; +png_do_background(png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background +#if defined(PNG_READ_GAMMA_SUPPORTED) + , png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift #endif - - png_bytep sp; + ) +{ + png_bytep sp, dp; png_uint_32 i; - png_uint_32 row_width = row_info->width; + png_uint_32 row_width=row_info->width; int shift; - png_debug(1, "in png_do_compose"); - + png_debug(1, "in png_do_background\n"); + if (background != NULL && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || + (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) { switch (row_info->color_type) { @@ -3558,28 +2627,24 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x01) - == png_ptr->trans_color.gray) + == trans_values->gray) { - unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); - tmp |= png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); + *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); } - if (!shift) { shift = 7; sp++; } - else shift--; } break; } - case 2: { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; @@ -3587,34 +2652,28 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == png_ptr->trans_color.gray) + == trans_values->gray) { - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); } - else { - unsigned int p = (*sp >> shift) & 0x03; - unsigned int g = (gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03; - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= g << shift; - *sp = (png_byte)(tmp & 0xff); + png_byte p = (png_byte)((*sp >> shift) & 0x03); + png_byte g = (png_byte)((gamma_table [p | (p << 2) | + (p << 4) | (p << 6)] >> 6) & 0x03); + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); } - if (!shift) { shift = 6; sp++; } - else shift -= 2; } } - else #endif { @@ -3623,29 +2682,25 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == png_ptr->trans_color.gray) + == trans_values->gray) { - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); } - if (!shift) { shift = 6; sp++; } - else shift -= 2; } } break; } - case 4: { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; @@ -3653,34 +2708,28 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == png_ptr->trans_color.gray) + == trans_values->gray) { - unsigned int tmp = *sp & (0xf0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); } - else { - unsigned int p = (*sp >> shift) & 0x0f; - unsigned int g = (gamma_table[p | (p << 4)] >> 4) & - 0x0f; - unsigned int tmp = *sp & (0xf0f >> (4 - shift)); - tmp |= g << shift; - *sp = (png_byte)(tmp & 0xff); + png_byte p = (png_byte)((*sp >> shift) & 0x0f); + png_byte g = (png_byte)((gamma_table[p | + (p << 4)] >> 4) & 0x0f); + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); } - if (!shift) { shift = 4; sp++; } - else shift -= 4; } } - else #endif { @@ -3689,39 +2738,38 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == png_ptr->trans_color.gray) + == trans_values->gray) { - unsigned int tmp = *sp & (0xf0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); } - if (!shift) { shift = 4; sp++; } - else shift -= 4; } } break; } - case 8: { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == png_ptr->trans_color.gray) - *sp = (png_byte)png_ptr->background.gray; - + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } else + { *sp = gamma_table[*sp]; + } } } else @@ -3730,16 +2778,17 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == png_ptr->trans_color.gray) - *sp = (png_byte)png_ptr->background.gray; + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } } } break; } - case 16: { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL) { sp = row; @@ -3748,16 +2797,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - if (v == png_ptr->trans_color.gray) + if (v == trans_values->gray) { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray - & 0xff); + /* background is already in screen gamma */ + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); } - else { v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; @@ -3775,44 +2820,36 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - if (v == png_ptr->trans_color.gray) + if (v == trans_values->gray) { - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray - & 0xff); + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); } } } break; } - - default: - break; } break; } - case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == png_ptr->trans_color.red && - *(sp + 1) == png_ptr->trans_color.green && - *(sp + 2) == png_ptr->trans_color.blue) + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; } - else { *sp = gamma_table[*sp]; @@ -3827,131 +2864,108 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == png_ptr->trans_color.red && - *(sp + 1) == png_ptr->trans_color.green && - *(sp + 2) == png_ptr->trans_color.blue) + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; } } } } else /* if (row_info->bit_depth == 16) */ { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 6) { png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - if (r == png_ptr->trans_color.red && - g == png_ptr->trans_color.green && - b == png_ptr->trans_color.blue) + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + /* background is already in screen gamma */ + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); } - else { png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; *(sp + 2) = (png_byte)((v >> 8) & 0xff); *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; *(sp + 4) = (png_byte)((v >> 8) & 0xff); *(sp + 5) = (png_byte)(v & 0xff); } } } - else #endif { sp = row; for (i = 0; i < row_width; i++, sp += 6) { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - if (r == png_ptr->trans_color.red && - g == png_ptr->trans_color.green && - b == png_ptr->trans_color.blue) + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) { - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); } } } } break; } - case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; - for (i = 0; i < row_width; i++, sp += 2) + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) { png_uint_16 a = *(sp + 1); if (a == 0xff) - *sp = gamma_table[*sp]; - + { + *dp = gamma_table[*sp]; + } else if (a == 0) { - /* Background is already in screen gamma */ - *sp = (png_byte)png_ptr->background.gray; + /* background is already in screen gamma */ + *dp = (png_byte)background->gray; } - else { png_byte v, w; v = gamma_to_1[*sp]; - png_composite(w, v, a, png_ptr->background_1.gray); - if (!optimize) - w = gamma_from_1[w]; - *sp = w; + png_composite(w, v, a, background_1->gray); + *dp = gamma_from_1[w]; } } } @@ -3959,139 +2973,151 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) #endif { sp = row; - for (i = 0; i < row_width; i++, sp += 2) + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) { png_byte a = *(sp + 1); - if (a == 0) - *sp = (png_byte)png_ptr->background.gray; - - else if (a < 0xff) - png_composite(*sp, *sp, a, png_ptr->background.gray); + if (a == 0xff) + { + *dp = *sp; + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) + { + *dp = (png_byte)background->gray; + } + else + { + png_composite(*dp, *sp, a, background_1->gray); + } +#else + *dp = (png_byte)background->gray; +#endif } } } else /* if (png_ptr->bit_depth == 16) */ { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; - for (i = 0; i < row_width; i++, sp += 4) + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) { - png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); } - +#if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) +#else + else +#endif { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + /* background is already in screen gamma */ + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); } - +#if defined(PNG_READ_GAMMA_SUPPORTED) else { png_uint_16 g, v, w; g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, png_ptr->background_1.gray); - if (optimize) - w = v; - else - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *sp = (png_byte)((w >> 8) & 0xff); - *(sp + 1) = (png_byte)(w & 0xff); + png_composite_16(v, g, a, background_1->gray); + w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; + *dp = (png_byte)((w >> 8) & 0xff); + *(dp + 1) = (png_byte)(w & 0xff); } +#endif } } else #endif { sp = row; - for (i = 0; i < row_width; i++, sp += 4) + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) { - png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - if (a == 0) + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + if (a == (png_uint_16)0xffff) { - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + png_memcpy(dp, sp, 2); } - - else if (a < 0xffff) +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) +#else + else +#endif + { + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else { png_uint_16 g, v; g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, png_ptr->background.gray); - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); + png_composite_16(v, g, a, background_1->gray); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); } +#endif } } } break; } - case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; - for (i = 0; i < row_width; i++, sp += 4) + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) { png_byte a = *(sp + 3); if (a == 0xff) { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; + *dp = gamma_table[*sp]; + *(dp + 1) = gamma_table[*(sp + 1)]; + *(dp + 2) = gamma_table[*(sp + 2)]; } - else if (a == 0) { - /* Background is already in screen gamma */ - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; + /* background is already in screen gamma */ + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; } - else { png_byte v, w; v = gamma_to_1[*sp]; - png_composite(w, v, a, png_ptr->background_1.red); - if (!optimize) w = gamma_from_1[w]; - *sp = w; - + png_composite(w, v, a, background_1->red); + *dp = gamma_from_1[w]; v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, png_ptr->background_1.green); - if (!optimize) w = gamma_from_1[w]; - *(sp + 1) = w; - + png_composite(w, v, a, background_1->green); + *(dp + 1) = gamma_from_1[w]; v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, png_ptr->background_1.blue); - if (!optimize) w = gamma_from_1[w]; - *(sp + 2) = w; + png_composite(w, v, a, background_1->blue); + *(dp + 2) = gamma_from_1[w]; } } } @@ -4099,129 +3125,115 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) #endif { sp = row; - for (i = 0; i < row_width; i++, sp += 4) + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) { png_byte a = *(sp + 3); - if (a == 0) + if (a == 0xff) { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; + *dp = *sp; + *(dp + 1) = *(sp + 1); + *(dp + 2) = *(sp + 2); } - - else if (a < 0xff) + else if (a == 0) { - png_composite(*sp, *sp, a, png_ptr->background.red); - - png_composite(*(sp + 1), *(sp + 1), a, - png_ptr->background.green); - - png_composite(*(sp + 2), *(sp + 2), a, - png_ptr->background.blue); + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; + } + else + { + png_composite(*dp, *sp, a, background->red); + png_composite(*(dp + 1), *(sp + 1), a, + background->green); + png_composite(*(dp + 2), *(sp + 2), a, + background->blue); } } } } else /* if (row_info->bit_depth == 16) */ { -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; - for (i = 0; i < row_width; i++, sp += 8) + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); } - else if (a == 0) { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + /* background is already in screen gamma */ + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); } - else { - png_uint_16 v, w; + png_uint_16 v, w, x; v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, png_ptr->background_1.red); - if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> - 8]; - *sp = (png_byte)((w >> 8) & 0xff); - *(sp + 1) = (png_byte)(w & 0xff); - + png_composite_16(w, v, a, background_1->red); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *dp = (png_byte)((x >> 8) & 0xff); + *(dp + 1) = (png_byte)(x & 0xff); v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, png_ptr->background_1.green); - if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> - 8]; - - *(sp + 2) = (png_byte)((w >> 8) & 0xff); - *(sp + 3) = (png_byte)(w & 0xff); - + png_composite_16(w, v, a, background_1->green); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *(dp + 2) = (png_byte)((x >> 8) & 0xff); + *(dp + 3) = (png_byte)(x & 0xff); v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, png_ptr->background_1.blue); - if (!optimize) - w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> - 8]; - - *(sp + 4) = (png_byte)((w >> 8) & 0xff); - *(sp + 5) = (png_byte)(w & 0xff); + png_composite_16(w, v, a, background_1->blue); + x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; + *(dp + 4) = (png_byte)((x >> 8) & 0xff); + *(dp + 5) = (png_byte)(x & 0xff); } } } - else #endif { sp = row; - for (i = 0; i < row_width; i++, sp += 8) + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - - if (a == 0) + << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) { - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + png_memcpy(dp, sp, 6); } - - else if (a < 0xffff) + else if (a == 0) + { + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); + } + else { png_uint_16 v; @@ -4231,32 +3243,36 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + *(sp + 5)); - png_composite_16(v, r, a, png_ptr->background.red); - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - - png_composite_16(v, g, a, png_ptr->background.green); - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - - png_composite_16(v, b, a, png_ptr->background.blue); - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); + png_composite_16(v, r, a, background->red); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + png_composite_16(v, g, a, background->green); + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); + png_composite_16(v, b, a, background->blue); + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); } } } } break; } + } - default: - break; + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + row_info->channels--; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */ +#endif -#ifdef PNG_READ_GAMMA_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) /* Gamma correct the image, avoiding the alpha channel. Make sure * you do this after you deal with the transparency issue on grayscale * or RGB images. If your bit depth is 8, use gamma_table, if it @@ -4264,20 +3280,21 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) * build_gamma_table(). */ void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) +png_do_gamma(png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift) { - png_const_bytep gamma_table = png_ptr->gamma_table; - png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; - int gamma_shift = png_ptr->gamma_shift; - png_bytep sp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_gamma"); - - if (((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) + png_debug(1, "in png_do_gamma\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + ((row_info->bit_depth <= 8 && gamma_table != NULL) || + (row_info->bit_depth == 16 && gamma_16_table != NULL))) { switch (row_info->color_type) { @@ -4296,7 +3313,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) sp++; } } - else /* if (row_info->bit_depth == 16) */ { sp = row; @@ -4308,12 +3324,10 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); @@ -4322,7 +3336,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) } break; } - case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) @@ -4332,17 +3345,13 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) { *sp = gamma_table[*sp]; sp++; - *sp = gamma_table[*sp]; sp++; - *sp = gamma_table[*sp]; sp++; - sp++; } } - else /* if (row_info->bit_depth == 16) */ { sp = row; @@ -4352,12 +3361,10 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); @@ -4366,7 +3373,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) } break; } - case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) @@ -4378,7 +3384,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) sp += 2; } } - else /* if (row_info->bit_depth == 16) */ { sp = row; @@ -4392,7 +3397,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) } break; } - case PNG_COLOR_TYPE_GRAY: { if (row_info->bit_depth == 2) @@ -4406,14 +3410,13 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) int d = *sp & 0x03; *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); + ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| + ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| + ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); sp++; } } - if (row_info->bit_depth == 4) { sp = row; @@ -4423,11 +3426,10 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) int lsb = *sp & 0x0f; *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); + | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); sp++; } } - else if (row_info->bit_depth == 8) { sp = row; @@ -4437,7 +3439,6 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) sp++; } } - else if (row_info->bit_depth == 16) { sp = row; @@ -4451,97 +3452,30 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) } break; } - - default: - break; } } } #endif -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* Encode the alpha channel to the output gamma (the input channel is always - * linear.) Called only with color types that have an alpha channel. Needs the - * from_1 tables. - */ -void /* PRIVATE */ -png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) -{ - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_encode_alpha"); - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - if (row_info->bit_depth == 8) - { - PNG_CONST png_bytep table = png_ptr->gamma_from_1; - - if (table != NULL) - { - PNG_CONST int step = - (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; - - /* The alpha channel is the last component: */ - row += step - 1; - - for (; row_width > 0; --row_width, row += step) - *row = table[*row]; - - return; - } - } - - else if (row_info->bit_depth == 16) - { - PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; - PNG_CONST int gamma_shift = png_ptr->gamma_shift; - - if (table != NULL) - { - PNG_CONST int step = - (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; - - /* The alpha channel is the last component: */ - row += step - 2; - - for (; row_width > 0; --row_width, row += step) - { - png_uint_16 v; - - v = table[*(row + 1) >> gamma_shift][*row]; - *row = (png_byte)((v >> 8) & 0xff); - *(row + 1) = (png_byte)(v & 0xff); - } - - return; - } - } - } - - /* Only get to here if called with a weird row_info; no harm has been done, - * so just issue a warning. - */ - png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); -} -#endif - -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) /* Expands a palette row to an RGB or RGBA row depending * upon whether you supply trans and num_trans. */ void /* PRIVATE */ png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) + png_colorp palette, png_bytep trans, int num_trans) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand_palette"); - - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) + png_debug(1, "in png_do_expand_palette\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->color_type == PNG_COLOR_TYPE_PALETTE) { if (row_info->bit_depth < 8) { @@ -4556,16 +3490,13 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, { if ((*sp >> shift) & 0x01) *dp = 1; - else *dp = 0; - if (shift == 7) { shift = 0; sp--; } - else shift++; @@ -4573,7 +3504,6 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } - case 2: { sp = row + (png_size_t)((row_width - 1) >> 2); @@ -4588,7 +3518,6 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, shift = 0; sp--; } - else shift += 2; @@ -4596,7 +3525,6 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } - case 4: { sp = row + (png_size_t)((row_width - 1) >> 1); @@ -4611,7 +3539,6 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, shift = 0; sp--; } - else shift += 4; @@ -4619,19 +3546,16 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } - - default: - break; } row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } - - if (row_info->bit_depth == 8) + switch (row_info->bit_depth) { + case 8: { - if (num_trans > 0) + if (trans != NULL) { sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 2) - 1; @@ -4640,10 +3564,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, { if ((int)(*sp) >= num_trans) *dp-- = 0xff; - else - *dp-- = trans_alpha[*sp]; - + *dp-- = trans[*sp]; *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; *dp-- = palette[*sp].red; @@ -4655,7 +3577,6 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, row_info->color_type = 6; row_info->channels = 4; } - else { sp = row + (png_size_t)row_width - 1; @@ -4668,36 +3589,38 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, *dp-- = palette[*sp].red; sp--; } - row_info->bit_depth = 8; row_info->pixel_depth = 24; row_info->rowbytes = row_width * 3; row_info->color_type = 2; row_info->channels = 3; } + break; } } } } -/* If the bit depth < 8, it is expanded to 8. Also, if the already - * expanded transparency value is supplied, an alpha channel is built. +/* If the bit depth < 8, it is expanded to 8. Also, if the + * transparency value is supplied, an alpha channel is built. */ void /* PRIVATE */ png_do_expand(png_row_infop row_info, png_bytep row, - png_const_color_16p trans_color) + png_color_16p trans_value) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand"); - + png_debug(1, "in png_do_expand\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { - unsigned int gray = trans_color ? trans_color->gray : 0; + png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); if (row_info->bit_depth < 8) { @@ -4705,7 +3628,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, { case 1: { - gray = (gray & 0x01) * 0xff; + gray = (png_uint_16)(gray*0xff); sp = row + (png_size_t)((row_width - 1) >> 3); dp = row + (png_size_t)row_width - 1; shift = 7 - (int)((row_width + 7) & 0x07); @@ -4713,16 +3636,13 @@ png_do_expand(png_row_infop row_info, png_bytep row, { if ((*sp >> shift) & 0x01) *dp = 0xff; - else *dp = 0; - if (shift == 7) { shift = 0; sp--; } - else shift++; @@ -4730,10 +3650,9 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } - case 2: { - gray = (gray & 0x03) * 0x55; + gray = (png_uint_16)(gray*0x55); sp = row + (png_size_t)((row_width - 1) >> 2); dp = row + (png_size_t)row_width - 1; shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); @@ -4747,7 +3666,6 @@ png_do_expand(png_row_infop row_info, png_bytep row, shift = 0; sp--; } - else shift += 2; @@ -4755,10 +3673,9 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } - case 4: { - gray = (gray & 0x0f) * 0x11; + gray = (png_uint_16)(gray*0x11); sp = row + (png_size_t)((row_width - 1) >> 1); dp = row + (png_size_t)row_width - 1; shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); @@ -4771,7 +3688,6 @@ png_do_expand(png_row_infop row_info, png_bytep row, shift = 0; sp--; } - else shift = 4; @@ -4779,61 +3695,48 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } - - default: - break; } - row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } - if (trans_color != NULL) + if (trans_value != NULL) { if (row_info->bit_depth == 8) { - gray = gray & 0xff; sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) { if (*sp == gray) *dp-- = 0; - else *dp-- = 0xff; - *dp-- = *sp--; } } - else if (row_info->bit_depth == 16) { - unsigned int gray_high = (gray >> 8) & 0xff; - unsigned int gray_low = gray & 0xff; sp = row + row_info->rowbytes - 1; dp = row + (row_info->rowbytes << 1) - 1; for (i = 0; i < row_width; i++) { - if (*(sp - 1) == gray_high && *(sp) == gray_low) + if (((png_uint_16)*(sp) | + ((png_uint_16)*(sp - 1) << 8)) == gray) { *dp-- = 0; *dp-- = 0; } - else { *dp-- = 0xff; *dp-- = 0xff; } - *dp-- = *sp--; *dp-- = *sp--; } } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); @@ -4841,23 +3744,20 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_width); } } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color) + else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) { if (row_info->bit_depth == 8) { - png_byte red = (png_byte)(trans_color->red & 0xff); - png_byte green = (png_byte)(trans_color->green & 0xff); - png_byte blue = (png_byte)(trans_color->blue & 0xff); sp = row + (png_size_t)row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 2) - 1; for (i = 0; i < row_width; i++) { - if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue) + if (*(sp - 2) == trans_value->red && + *(sp - 1) == trans_value->green && + *(sp - 0) == trans_value->blue) *dp-- = 0; - else *dp-- = 0xff; - *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; @@ -4865,33 +3765,25 @@ png_do_expand(png_row_infop row_info, png_bytep row, } else if (row_info->bit_depth == 16) { - png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff); - png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff); - png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff); - png_byte red_low = (png_byte)(trans_color->red & 0xff); - png_byte green_low = (png_byte)(trans_color->green & 0xff); - png_byte blue_low = (png_byte)(trans_color->blue & 0xff); sp = row + row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 3) - 1; for (i = 0; i < row_width; i++) { - if (*(sp - 5) == red_high && - *(sp - 4) == red_low && - *(sp - 3) == green_high && - *(sp - 2) == green_low && - *(sp - 1) == blue_high && - *(sp ) == blue_low) + if ((((png_uint_16)*(sp - 4) | + ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && + (((png_uint_16)*(sp - 2) | + ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && + (((png_uint_16)*(sp - 0) | + ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) { *dp-- = 0; *dp-- = 0; } - else { *dp-- = 0xff; *dp-- = 0xff; } - *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; @@ -4903,57 +3795,28 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; row_info->channels = 4; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } } #endif -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* If the bit depth is 8 and the color type is not a palette type expand the - * whole row to 16 bits. Has no effect otherwise. - */ +#if defined(PNG_READ_DITHER_SUPPORTED) void /* PRIVATE */ -png_do_expand_16(png_row_infop row_info, png_bytep row) -{ - if (row_info->bit_depth == 8 && - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - /* The row have a sequence of bytes containing [0..255] and we need - * to turn it into another row containing [0..65535], to do this we - * calculate: - * - * (input / 255) * 65535 - * - * Which happens to be exactly input * 257 and this can be achieved - * simply by byte replication in place (copying backwards). - */ - png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */ - png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ - while (dp > sp) - dp[-2] = dp[-1] = *--sp, dp -= 2; - - row_info->rowbytes *= 2; - row_info->bit_depth = 16; - row_info->pixel_depth = (png_byte)(row_info->channels * 16); - } -} -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -void /* PRIVATE */ -png_do_quantize(png_row_infop row_info, png_bytep row, - png_const_bytep palette_lookup, png_const_bytep quantize_lookup) +png_do_dither(png_row_infop row_info, png_bytep row, + png_bytep palette_lookup, png_bytep dither_lookup) { png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_quantize"); - - if (row_info->bit_depth == 8) + png_debug(1, "in png_do_dither\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup) + if (row_info->color_type == PNG_COLOR_TYPE_RGB && + palette_lookup && row_info->bit_depth == 8) { int r, g, b, p; sp = row; @@ -4964,33 +3827,31 @@ png_do_quantize(png_row_infop row_info, png_bytep row, g = *sp++; b = *sp++; - /* This looks real messy, but the compiler will reduce - * it down to a reasonable formula. For example, with - * 5 bits per color, we get: - * p = (((r >> 3) & 0x1f) << 10) | - * (((g >> 3) & 0x1f) << 5) | - * ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & - ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << - (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | - (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & - ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << - (PNG_QUANTIZE_BLUE_BITS)) | - ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & - ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); + /* this looks real messy, but the compiler will reduce + it down to a reasonable formula. For example, with + 5 bits per color, we get: + p = (((r >> 3) & 0x1f) << 10) | + (((g >> 3) & 0x1f) << 5) | + ((b >> 3) & 0x1f); + */ + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL) + palette_lookup != NULL && row_info->bit_depth == 8) { int r, g, b, p; sp = row; @@ -5002,52 +3863,272 @@ png_do_quantize(png_row_infop row_info, png_bytep row, b = *sp++; sp++; - p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & - ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << - (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | - (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & - ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << - (PNG_QUANTIZE_BLUE_BITS)) | - ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & - ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - quantize_lookup) + dither_lookup && row_info->bit_depth == 8) { sp = row; - for (i = 0; i < row_width; i++, sp++) { - *sp = quantize_lookup[*sp]; + *sp = dither_lookup[*sp]; } } } } -#endif /* PNG_READ_QUANTIZE_SUPPORTED */ -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ +#endif -#ifdef PNG_MNG_FEATURES_SUPPORTED -/* Undoes intrapixel differencing */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) +static int png_gamma_shift[] = + {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0}; + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structp png_ptr) +{ + png_debug(1, "in png_build_gamma_table\n"); + if(png_ptr->gamma != 0.0) + { + if (png_ptr->bit_depth <= 8) + { + int i; + double g; + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + + + png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + else + { + double g; + int i, j, shift, num; + int sig_bit; + png_uint_32 ig; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit = (int)png_ptr->sig_bit.red; + if ((int)png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + if ((int)png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + { + sig_bit = (int)png_ptr->sig_bit.gray; + } + + if (sig_bit > 0) + shift = 16 - sig_bit; + else + shift = 0; + + if (png_ptr->transformations & PNG_16_TO_8) + { + if (shift < (16 - PNG_MAX_GAMMA_8)) + shift = (16 - PNG_MAX_GAMMA_8); + } + + if (shift > 8) + shift = 8; + if (shift < 0) + shift = 0; + + png_ptr->gamma_shift = (png_byte)shift; + + num = (1 << (8 - shift)); + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p))); + + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) + { + double fin, fout; + png_uint_32 last, max; + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + } + + g = 1.0 / g; + last = 0; + for (i = 0; i < 256; i++) + { + fout = ((double)i + 0.5) / 256.0; + fin = pow(fout, g); + max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); + while (last <= max) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)( + (png_uint_16)i | ((png_uint_16)i << 8)); + last++; + } + } + while (last < ((png_uint_32)num << 8)) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)65535L; + last++; + } + } + else + { + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_table[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p ))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_to_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * png_sizeof (png_uint_16p))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_from_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + } +} +#endif +/* To do: install integer version of png_build_gamma_table here */ +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_intrapixel"); - + png_debug(1, "in png_do_read_intrapixel\n"); if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) { png_bytep rp; @@ -5055,17 +4136,15 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff); - *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff); + *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); + *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); } } else if (row_info->bit_depth == 16) @@ -5075,27 +4154,24 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); - png_uint_32 red = (s0 + s1 + 65536) & 0xffff; - png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp + 1) = (png_byte)(red & 0xff); - *(rp + 4) = (png_byte)((blue >> 8) & 0xff); - *(rp + 5) = (png_byte)(blue & 0xff); + png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); + png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); + png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); + png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp+1) = (png_byte)(red & 0xff); + *(rp+4) = (png_byte)((blue >> 8) & 0xff); + *(rp+5) = (png_byte)(blue & 0xff); } } } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngrutil.c b/Source/3rd Party/wx/src/png/pngrutil.c index 01c3679df..b61664aa6 100644 --- a/Source/3rd Party/wx/src/png/pngrutil.c +++ b/Source/3rd Party/wx/src/png/pngrutil.c @@ -1,239 +1,130 @@ - /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ -#include "pngpriv.h" +#define PNG_INTERNAL +#include "png.h" -#ifdef PNG_READ_SUPPORTED - -#define png_strtod(p,a,b) strtod(a,b) - -png_uint_32 PNGAPI -png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) +#if defined(_WIN32_WCE) +/* strtod() function is not supported on WindowsCE */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +__inline double strtod(const char *nptr, char **endptr) { - png_uint_32 uval = png_get_uint_32(buf); + double result = 0; + int len; + wchar_t *str, *end; - if (uval > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range"); - - return (uval); -} - -#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) -/* The following is a variation on the above for use with the fixed - * point values used for gAMA and cHRM. Instead of png_error it - * issues a warning and returns (-1) - an invalid value because both - * gAMA and cHRM use *unsigned* integers for fixed point values. - */ -#define PNG_FIXED_ERROR (-1) - -static png_fixed_point /* PRIVATE */ -png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf) -{ - png_uint_32 uval = png_get_uint_32(buf); - - if (uval <= PNG_UINT_31_MAX) - return (png_fixed_point)uval; /* known to be in range */ - - /* The caller can turn off the warning by passing NULL. */ - if (png_ptr != NULL) - png_warning(png_ptr, "PNG fixed point integer out of range"); - - return PNG_FIXED_ERROR; + len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); + str = (wchar_t *)malloc(len * sizeof(wchar_t)); + if ( NULL != str ) + { + MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); + result = wcstod(str, &end); + len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); + *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); + free(str); + } + return result; } +# endif #endif -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -/* NOTE: the read macros will obscure these definitions, so that if - * PNG_USE_READ_MACROS is set the library will not use them internally, - * but the APIs will still be available externally. - * - * The parentheses around "PNGAPI function_name" in the following three - * functions are necessary because they allow the macros to co-exist with - * these (unused but exported) functions. - */ - +png_uint_32 /* PRIVATE */ +png_get_uint_31(png_structp png_ptr, png_bytep buf) +{ + png_uint_32 i = png_get_uint_32(buf); + if (i > PNG_UINT_31_MAX) + png_error(png_ptr, "PNG unsigned integer out of range.\n"); + return (i); +} +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 (PNGAPI -png_get_uint_32)(png_const_bytep buf) +png_uint_32 /* PRIVATE */ +png_get_uint_32(png_bytep buf) { - png_uint_32 uval = - ((png_uint_32)(*(buf )) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - ((png_uint_32)(*(buf + 3)) ) ; + png_uint_32 i = ((png_uint_32)(*buf) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + (png_uint_32)(*(buf + 3)); - return uval; + return (i); } +#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) /* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format and there - * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore - * the following code does a two's complement to native conversion. - */ -png_int_32 (PNGAPI -png_get_int_32)(png_const_bytep buf) + * data is stored in the PNG file in two's complement format, and it is + * assumed that the machine format for signed integers is the same. */ +png_int_32 /* PRIVATE */ +png_get_int_32(png_bytep buf) { - png_uint_32 uval = png_get_uint_32(buf); - if ((uval & 0x80000000) == 0) /* non-negative */ - return uval; + png_int_32 i = ((png_int_32)(*buf) << 24) + + ((png_int_32)(*(buf + 1)) << 16) + + ((png_int_32)(*(buf + 2)) << 8) + + (png_int_32)(*(buf + 3)); - uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ - return -(png_int_32)uval; + return (i); } +#endif /* PNG_READ_pCAL_SUPPORTED */ /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 (PNGAPI -png_get_uint_16)(png_const_bytep buf) +png_uint_16 /* PRIVATE */ +png_get_uint_16(png_bytep buf) { - /* ANSI-C requires an int value to accomodate at least 16 bits so this - * works and allows the compiler not to worry about possible narrowing - * on 32 bit systems. (Pre-ANSI systems did not make integers smaller - * than 16 bits either.) - */ - unsigned int val = - ((unsigned int)(*buf) << 8) + - ((unsigned int)(*(buf + 1))); + png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + + (png_uint_16)(*(buf + 1))); - return (png_uint_16)val; -} - -#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */ - -/* Read and check the PNG file signature */ -void /* PRIVATE */ -png_read_sig(png_structrp png_ptr, png_inforp info_ptr) -{ - png_size_t num_checked, num_to_check; - - /* Exit if the user application does not expect a signature. */ - if (png_ptr->sig_bytes >= 8) - return; - - num_checked = png_ptr->sig_bytes; - num_to_check = 8 - num_checked; - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE; -#endif - - /* The signature must be serialized in a single I/O call. */ - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -/* Read the chunk header (length + type name). - * Put the type name into png_ptr->chunk_name, and return the length. - */ -png_uint_32 /* PRIVATE */ -png_read_chunk_header(png_structrp png_ptr) -{ - png_byte buf[8]; - png_uint_32 length; - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR; -#endif - - /* Read the length and the chunk name. - * This must be performed in a single I/O call. - */ - png_read_data(png_ptr, buf, 8); - length = png_get_uint_31(png_ptr, buf); - - /* Put the chunk name into png_ptr->chunk_name. */ - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4); - - png_debug2(0, "Reading %lx chunk, length = %lu", - (unsigned long)png_ptr->chunk_name, (unsigned long)length); - - /* Reset the crc and run it over the chunk name. */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, buf + 4, 4); - - /* Check to see if chunk name is valid. */ - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; -#endif - - return length; + return (i); } +#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ -png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length) +png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) { - if (png_ptr == NULL) - return; - png_read_data(png_ptr, buf, length); png_calculate_crc(png_ptr, buf, length); } /* Optionally skip data and then check the CRC. Depending on whether we - * are reading an ancillary or critical chunk, and how the program has set - * things up, we may calculate the CRC on the data and print a message. - * Returns '1' if there was a CRC error, '0' otherwise. - */ + are reading a ancillary or critical chunk, and how the program has set + things up, we may calculate the CRC on the data and print a message. + Returns '1' if there was a CRC error, '0' otherwise. */ int /* PRIVATE */ -png_crc_finish(png_structrp png_ptr, png_uint_32 skip) +png_crc_finish(png_structp png_ptr, png_uint_32 skip) { - /* The size of the local buffer for inflate is a good guess as to a - * reasonable size to use for buffering reads from the application. - */ - while (skip > 0) + png_size_t i; + png_size_t istop = png_ptr->zbuf_size; + + for (i = (png_size_t)skip; i > istop; i -= istop) { - png_uint_32 len; - png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; - - len = (sizeof tmpbuf); - if (len > skip) - len = skip; - skip -= len; - - png_crc_read(png_ptr, tmpbuf, len); + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + } + if (i) + { + png_crc_read(png_ptr, png_ptr->zbuf, i); } if (png_crc_error(png_ptr)) { - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ? - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) : - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)) + if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ + !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || + (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) { png_chunk_warning(png_ptr, "CRC error"); } - else { - png_chunk_benign_error(png_ptr, "CRC error"); - return (0); + png_chunk_error(png_ptr, "CRC error"); } - return (1); } @@ -241,33 +132,26 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip) } /* Compare the CRC stored in the PNG file with that calculated by libpng from - * the data it has read thus far. - */ + the data it has read thus far. */ int /* PRIVATE */ -png_crc_error(png_structrp png_ptr) +png_crc_error(png_structp png_ptr) { png_byte crc_bytes[4]; png_uint_32 crc; int need_crc = 1; - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)) + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } - - else /* critical */ + else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC; -#endif - - /* The chunk CRC must be serialized in a single I/O call. */ png_read_data(png_ptr, crc_bytes, 4); if (need_crc) @@ -275,527 +159,195 @@ png_crc_error(png_structrp png_ptr) crc = png_get_uint_32(crc_bytes); return ((int)(crc != png_ptr->crc)); } - else return (0); } -/* Manage the read buffer; this simply reallocates the buffer if it is not small - * enough (or if it is not allocated). The routine returns a pointer to the - * buffer; if an error occurs and 'warn' is set the routine returns NULL, else - * it will call png_error (via png_malloc) on failure. (warn == 2 means - * 'silent'). - */ -static png_bytep -png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) -{ - png_bytep buffer = png_ptr->read_buffer; - - if (buffer != NULL && new_size > png_ptr->read_buffer_size) - { - png_ptr->read_buffer = NULL; - png_ptr->read_buffer = NULL; - png_ptr->read_buffer_size = 0; - png_free(png_ptr, buffer); - buffer = NULL; - } - - if (buffer == NULL) - { - buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size)); - - if (buffer != NULL) - { - png_ptr->read_buffer = buffer; - png_ptr->read_buffer_size = new_size; - } - - else if (warn < 2) /* else silent */ - { -#ifdef PNG_WARNINGS_SUPPORTED - if (warn) - png_chunk_warning(png_ptr, "insufficient memory to read chunk"); - else -#endif - { -#ifdef PNG_ERROR_TEXT_SUPPORTED - png_chunk_error(png_ptr, "insufficient memory to read chunk"); -#endif - } - } - } - - return buffer; -} - -/* png_inflate_claim: claim the zstream for some nefarious purpose that involves - * decompression. Returns Z_OK on success, else a zlib error code. It checks - * the owner but, in final release builds, just issues a warning if some other - * chunk apparently owns the stream. Prior to release it does a png_error. - */ -static int -png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits) -{ - if (png_ptr->zowner != 0) - { - char msg[64]; - - PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); - /* So the message that results is " using zstream"; this is an - * internal error, but is very useful for debugging. i18n requirements - * are minimal. - */ - (void)png_safecat(msg, (sizeof msg), 4, " using zstream"); -# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC - png_chunk_warning(png_ptr, msg); - png_ptr->zowner = 0; -# else - png_chunk_error(png_ptr, msg); -# endif - } - - /* Implementation note: unlike 'png_deflate_claim' this internal function - * does not take the size of the data as an argument. Some efficiency could - * be gained by using this when it is known *if* the zlib stream itself does - * not record the number; however, this is an illusion: the original writer - * of the PNG may have selected a lower window size, and we really must - * follow that because, for systems with with limited capabilities, we - * would otherwise reject the application's attempts to use a smaller window - * size (zlib doesn't have an interface to say "this or lower"!). - * - * inflateReset2 was added to zlib 1.2.4; before this the window could not be - * reset, therefore it is necessary to always allocate the maximum window - * size with earlier zlibs just in case later compressed chunks need it. - */ - { - int ret; /* zlib return code */ - - /* Set this for safety, just in case the previous owner left pointers to - * memory allocations. - */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->zstream.avail_out = 0; - - if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) - { -# if ZLIB_VERNUM < 0x1240 - PNG_UNUSED(window_bits) - ret = inflateReset(&png_ptr->zstream); -# else - ret = inflateReset2(&png_ptr->zstream, window_bits); -# endif - } - - else - { -# if ZLIB_VERNUM < 0x1240 - ret = inflateInit(&png_ptr->zstream); -# else - ret = inflateInit2(&png_ptr->zstream, window_bits); -# endif - - if (ret == Z_OK) - png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; - } - - if (ret == Z_OK) - png_ptr->zowner = owner; - - else - png_zstream_error(png_ptr, ret); - - return ret; - } -} - -#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED -/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to - * allow the caller to do multiple calls if required. If the 'finish' flag is - * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must - * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and - * Z_OK or Z_STREAM_END will be returned on success. - * - * The input and output sizes are updated to the actual amounts of data consumed - * or written, not the amount available (as in a z_stream). The data pointers - * are not changed, so the next input is (data+input_size) and the next - * available output is (output+output_size). - */ -static int -png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, - /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr, - /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr) -{ - if (png_ptr->zowner == owner) /* Else not claimed */ - { - int ret; - png_alloc_size_t avail_out = *output_size_ptr; - png_uint_32 avail_in = *input_size_ptr; - - /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it - * can't even necessarily handle 65536 bytes) because the type uInt is - * "16 bits or more". Consequently it is necessary to chunk the input to - * zlib. This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the - * maximum value that can be stored in a uInt.) It is possible to set - * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have - * a performance advantage, because it reduces the amount of data accessed - * at each step and that may give the OS more time to page it in. - */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); - /* avail_in and avail_out are set below from 'size' */ - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.avail_out = 0; - - /* Read directly into the output if it is available (this is set to - * a local buffer below if output is NULL). - */ - if (output != NULL) - png_ptr->zstream.next_out = output; - - do - { - uInt avail; - Byte local_buffer[PNG_INFLATE_BUF_SIZE]; - - /* zlib INPUT BUFFER */ - /* The setting of 'avail_in' used to be outside the loop; by setting it - * inside it is possible to chunk the input to zlib and simply rely on - * zlib to advance the 'next_in' pointer. This allows arbitrary - * amounts of data to be passed through zlib at the unavoidable cost of - * requiring a window save (memcpy of up to 32768 output bytes) - * every ZLIB_IO_MAX input bytes. - */ - avail_in += png_ptr->zstream.avail_in; /* not consumed last time */ - - avail = ZLIB_IO_MAX; - - if (avail_in < avail) - avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */ - - avail_in -= avail; - png_ptr->zstream.avail_in = avail; - - /* zlib OUTPUT BUFFER */ - avail_out += png_ptr->zstream.avail_out; /* not written last time */ - - avail = ZLIB_IO_MAX; /* maximum zlib can process */ - - if (output == NULL) - { - /* Reset the output buffer each time round if output is NULL and - * make available the full buffer, up to 'remaining_space' - */ - png_ptr->zstream.next_out = local_buffer; - if ((sizeof local_buffer) < avail) - avail = (sizeof local_buffer); - } - - if (avail_out < avail) - avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */ - - png_ptr->zstream.avail_out = avail; - avail_out -= avail; - - /* zlib inflate call */ - /* In fact 'avail_out' may be 0 at this point, that happens at the end - * of the read when the final LZ end code was not passed at the end of - * the previous chunk of input data. Tell zlib if we have reached the - * end of the output buffer. - */ - ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH : - (finish ? Z_FINISH : Z_SYNC_FLUSH)); - } while (ret == Z_OK); - - /* For safety kill the local buffer pointer now */ - if (output == NULL) - png_ptr->zstream.next_out = NULL; - - /* Claw back the 'size' and 'remaining_space' byte counts. */ - avail_in += png_ptr->zstream.avail_in; - avail_out += png_ptr->zstream.avail_out; - - /* Update the input and output sizes; the updated values are the amount - * consumed or written, effectively the inverse of what zlib uses. - */ - if (avail_out > 0) - *output_size_ptr -= avail_out; - - if (avail_in > 0) - *input_size_ptr -= avail_in; - - /* Ensure png_ptr->zstream.msg is set (even in the success case!) */ - png_zstream_error(png_ptr, ret); - return ret; - } - - else - { - /* This is a bad internal error. The recovery assigns to the zstream msg - * pointer, which is not owned by the caller, but this is safe; it's only - * used on errors! - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); - return Z_STREAM_ERROR; - } -} - +#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ + defined(PNG_READ_iCCP_SUPPORTED) /* - * Decompress trailing data in a chunk. The assumption is that read_buffer + * Decompress trailing data in a chunk. The assumption is that chunkdata * points at an allocated area holding the contents of a chunk with a * trailing compressed part. What we get back is an allocated area * holding the original prefix part and an uncompressed version of the * trailing part (the malloc area passed in is freed). */ -static int -png_decompress_chunk(png_structrp png_ptr, - png_uint_32 chunklength, png_uint_32 prefix_size, - png_alloc_size_t *newlength /* must be initialized to the maximum! */, - int terminate /*add a '\0' to the end of the uncompressed data*/) +png_charp /* PRIVATE */ +png_decompress_chunk(png_structp png_ptr, int comp_type, + png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_size, png_size_t *newlength) { - /* TODO: implement different limits for different types of chunk. - * - * The caller supplies *newlength set to the maximum length of the - * uncompressed data, but this routine allocates space for the prefix and - * maybe a '\0' terminator too. We have to assume that 'prefix_size' is - * limited only by the maximum chunk size. - */ - png_alloc_size_t limit = PNG_SIZE_MAX; + static char msg[] = "Error decoding compressed text"; + png_charp text; + png_size_t text_size; -# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; -# endif - - if (limit >= prefix_size + (terminate != 0)) + if (comp_type == PNG_COMPRESSION_TYPE_BASE) { - int ret; + int ret = Z_OK; + png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); + png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - limit -= prefix_size + (terminate != 0); + text_size = 0; + text = NULL; - if (limit < *newlength) - *newlength = limit; - - /* Now try to claim the stream; the 'warn' setting causes zlib to be told - * to use the maximum window size during inflate; this hides errors in the - * deflate header window bits value which is used if '0' is passed. In - * fact this only has an effect with zlib versions 1.2.4 and later - see - * the comments in png_inflate_claim above. - */ - ret = png_inflate_claim(png_ptr, png_ptr->chunk_name, - png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0); - - if (ret == Z_OK) + while (png_ptr->zstream.avail_in) { - png_uint_32 lzsize = chunklength - prefix_size; - - ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, - /* output: */ NULL, newlength); - - if (ret == Z_STREAM_END) + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK && ret != Z_STREAM_END) { - /* Use 'inflateReset' here, not 'inflateReset2' because this - * preserves the previously decided window size (otherwise it would - * be necessary to store the previous window size.) In practice - * this doesn't matter anyway, because png_inflate will call inflate - * with Z_FINISH in almost all cases, so the window will not be - * maintained. - */ - if (inflateReset(&png_ptr->zstream) == Z_OK) + if (png_ptr->zstream.msg != NULL) + png_warning(png_ptr, png_ptr->zstream.msg); + else + png_warning(png_ptr, msg); + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + if (text == NULL) { - /* Because of the limit checks above we know that the new, - * expanded, size will fit in a size_t (let alone an - * png_alloc_size_t). Use png_malloc_base here to avoid an - * extra OOM message. - */ - png_alloc_size_t new_size = *newlength; - png_alloc_size_t buffer_size = prefix_size + new_size + - (terminate != 0); - png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, - buffer_size)); - - if (text != NULL) - { - ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - png_ptr->read_buffer + prefix_size, &lzsize, - text + prefix_size, newlength); - - if (ret == Z_STREAM_END) - { - if (new_size == *newlength) - { - if (terminate) - text[prefix_size + *newlength] = 0; - - if (prefix_size > 0) - memcpy(text, png_ptr->read_buffer, prefix_size); - - { - png_bytep old_ptr = png_ptr->read_buffer; - - png_ptr->read_buffer = text; - png_ptr->read_buffer_size = buffer_size; - text = old_ptr; /* freed below */ - } - } - - else - { - /* The size changed on the second read, there can be no - * guarantee that anything is correct at this point. - * The 'msg' pointer has been set to "unexpected end of - * LZ stream", which is fine, but return an error code - * that the caller won't accept. - */ - ret = PNG_UNEXPECTED_ZLIB_RETURN; - } - } - - else if (ret == Z_OK) - ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */ - - /* Free the text pointer (this is the old read_buffer on - * success) - */ - png_free(png_ptr, text); - - /* This really is very benign, but it's still an error because - * the extra space may otherwise be used as a Trojan Horse. - */ - if (ret == Z_STREAM_END && - chunklength - prefix_size != lzsize) - png_chunk_benign_error(png_ptr, "extra compressed data"); - } - - else - { - /* Out of memory allocating the buffer */ - ret = Z_MEM_ERROR; - png_zstream_error(png_ptr, Z_MEM_ERROR); - } + text_size = prefix_size + png_sizeof(msg) + 1; + text = (png_charp)png_malloc_warn(png_ptr, text_size); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk"); + } + png_memcpy(text, chunkdata, prefix_size); } + text[text_size - 1] = 0x00; + + /* Copy what we can of the error message into the text chunk */ + text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); + text_size = png_sizeof(msg) > text_size ? text_size : + png_sizeof(msg); + png_memcpy(text + prefix_size, msg, text_size + 1); + break; + } + if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) + { + if (text == NULL) + { + text_size = prefix_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out; + text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk."); + } + png_memcpy(text + prefix_size, png_ptr->zbuf, + text_size - prefix_size); + png_memcpy(text, chunkdata, prefix_size); + *(text + text_size) = 0x00; + } else { - /* inflateReset failed, store the error message */ - png_zstream_error(png_ptr, ret); + png_charp tmp; - if (ret == Z_STREAM_END) - ret = PNG_UNEXPECTED_ZLIB_RETURN; + tmp = text; + text = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(text_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); + if (text == NULL) + { + png_free(png_ptr, tmp); + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk.."); + } + png_memcpy(text, tmp, text_size); + png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, + (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = 0x00; + } + if (ret == Z_STREAM_END) + break; + else + { + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } } - - else if (ret == Z_OK) - ret = PNG_UNEXPECTED_ZLIB_RETURN; - - /* Release the claimed stream */ - png_ptr->zowner = 0; } - - else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */ - ret = PNG_UNEXPECTED_ZLIB_RETURN; - - return ret; - } - - else - { - /* Application/configuration limits exceeded */ - png_zstream_error(png_ptr, Z_MEM_ERROR); - return Z_MEM_ERROR; - } -} -#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */ - -#ifdef PNG_READ_iCCP_SUPPORTED -/* Perform a partial read and decompress, producing 'avail_out' bytes and - * reading from the current chunk as required. - */ -static int -png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, - png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, - int finish) -{ - if (png_ptr->zowner == png_ptr->chunk_name) - { - int ret; - - /* next_in and avail_in must have been initialized by the caller. */ - png_ptr->zstream.next_out = next_out; - png_ptr->zstream.avail_out = 0; /* set in the loop */ - - do + if (ret != Z_STREAM_END) { - if (png_ptr->zstream.avail_in == 0) +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[50]; + + if (ret == Z_BUF_ERROR) + sprintf(umsg,"Buffer error in compressed datastream in %s chunk", + (char *)png_ptr->chunk_name); + else if (ret == Z_DATA_ERROR) + sprintf(umsg,"Data error in compressed datastream in %s chunk", + (char *)png_ptr->chunk_name); + else + sprintf(umsg,"Incomplete compressed datastream in %s chunk", + (char *)png_ptr->chunk_name); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, + "Incomplete compressed datastream in chunk other than IDAT"); +#endif + text_size=prefix_size; + if (text == NULL) { - if (read_size > *chunk_bytes) - read_size = (uInt)*chunk_bytes; - *chunk_bytes -= read_size; - - if (read_size > 0) - png_crc_read(png_ptr, read_buffer, read_size); - - png_ptr->zstream.next_in = read_buffer; - png_ptr->zstream.avail_in = read_size; + text = (png_charp)png_malloc_warn(png_ptr, text_size+1); + if (text == NULL) + { + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory for text."); + } + png_memcpy(text, chunkdata, prefix_size); } - - if (png_ptr->zstream.avail_out == 0) - { - uInt avail = ZLIB_IO_MAX; - if (avail > *out_size) - avail = (uInt)*out_size; - *out_size -= avail; - - png_ptr->zstream.avail_out = avail; - } - - /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all - * the available output is produced; this allows reading of truncated - * streams. - */ - ret = inflate(&png_ptr->zstream, - *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); + *(text + text_size) = 0x00; } - while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); - *out_size += png_ptr->zstream.avail_out; - png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */ + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; - /* Ensure the error message pointer is always set: */ - png_zstream_error(png_ptr, ret); - return ret; + png_free(png_ptr, chunkdata); + chunkdata = text; + *newlength=text_size; } - - else + else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ { - png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); - return Z_STREAM_ERROR; +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[50]; + + sprintf(umsg, "Unknown zTXt compression type %d", comp_type); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, "Unknown zTXt compression type"); +#endif + + *(chunkdata + prefix_size) = 0x00; + *newlength=prefix_size; } + + return chunkdata; } #endif -/* Read and check the IDHR chunk */ +/* read and check the IDHR chunk */ void /* PRIVATE */ -png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[13]; png_uint_32 width, height; int bit_depth, color_type, compression_type, filter_type; int interlace_type; - png_debug(1, "in png_handle_IHDR"); + png_debug(1, "in png_handle_IHDR\n"); if (png_ptr->mode & PNG_HAVE_IHDR) - png_chunk_error(png_ptr, "out of place"); + png_error(png_ptr, "Out of place IHDR"); - /* Check the length */ + /* check the length */ if (length != 13) - png_chunk_error(png_ptr, "invalid"); + png_error(png_ptr, "Invalid IHDR chunk"); png_ptr->mode |= PNG_HAVE_IHDR; @@ -810,93 +362,79 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) filter_type = buf[11]; interlace_type = buf[12]; - /* Set internal variables */ + /* set internal variables */ png_ptr->width = width; png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; png_ptr->color_type = (png_byte)color_type; -#ifdef PNG_MNG_FEATURES_SUPPORTED +#if defined(PNG_MNG_FEATURES_SUPPORTED) png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; - /* Find number of channels */ + /* find number of channels */ switch (png_ptr->color_type) { - default: /* invalid, png_set_IHDR calls png_error */ case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_PALETTE: png_ptr->channels = 1; break; - case PNG_COLOR_TYPE_RGB: png_ptr->channels = 3; break; - case PNG_COLOR_TYPE_GRAY_ALPHA: png_ptr->channels = 2; break; - case PNG_COLOR_TYPE_RGB_ALPHA: png_ptr->channels = 4; break; } - /* Set up other useful info */ + /* set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); - png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); - png_debug1(3, "channels = %d", png_ptr->channels); - png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); + png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); + png_debug1(3,"channels = %d\n", png_ptr->channels); + png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); + color_type, interlace_type, compression_type, filter_type); } -/* Read and check the palette */ +/* read and check the palette */ void /* PRIVATE */ -png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_color palette[PNG_MAX_PALETTE_LENGTH]; int num, i; -#ifdef PNG_POINTER_INDEXING_SUPPORTED +#ifndef PNG_NO_POINTER_INDEXING png_colorp pal_ptr; #endif - png_debug(1, "in png_handle_PLTE"); + png_debug(1, "in png_handle_PLTE\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - /* Moved to before the 'after IDAT' check below because otherwise duplicate - * PLTE chunks are potentially ignored (the spec says there shall not be more - * than one PLTE, the error is not treated as benign, so this check trumps - * the requirement that PLTE appears before IDAT.) - */ - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_chunk_error(png_ptr, "duplicate"); - + png_error(png_ptr, "Missing IHDR before PLTE"); else if (png_ptr->mode & PNG_HAVE_IDAT) { - /* This is benign because the non-benign error happened before, when an - * IDAT was encountered in a color-mapped image with no PLTE. - */ + png_warning(png_ptr, "Invalid PLTE after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (png_ptr->mode & PNG_HAVE_PLTE) + png_error(png_ptr, "Duplicate PLTE chunk"); png_ptr->mode |= PNG_HAVE_PLTE; - if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) + if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) { + png_warning(png_ptr, + "Ignoring PLTE chunk in grayscale PNG"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "ignored in grayscale PNG"); return; } - -#ifndef PNG_READ_OPT_PLTE_SUPPORTED +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { png_crc_finish(png_ptr, length); @@ -906,21 +444,21 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) { - png_crc_finish(png_ptr, length); - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - png_chunk_benign_error(png_ptr, "invalid"); - + { + png_warning(png_ptr, "Invalid palette chunk"); + png_crc_finish(png_ptr, length); + return; + } else - png_chunk_error(png_ptr, "invalid"); - - return; + { + png_error(png_ptr, "Invalid palette chunk"); + } } - /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */ num = (int)length / 3; -#ifdef PNG_POINTER_INDEXING_SUPPORTED +#ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) { png_byte buf[3]; @@ -936,51 +474,42 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_byte buf[3]; png_crc_read(png_ptr, buf, 3); - /* Don't depend upon png_color being any order */ + /* don't depend upon png_color being any order */ palette[i].red = buf[0]; palette[i].green = buf[1]; palette[i].blue = buf[2]; } #endif - /* If we actually need the PLTE chunk (ie for a paletted image), we do - * whatever the normal CRC configuration tells us. However, if we - * have an RGB image, the PLTE can be considered ancillary, so - * we will act as though it is. - */ -#ifndef PNG_READ_OPT_PLTE_SUPPORTED + /* If we actually NEED the PLTE chunk (ie for a paletted image), we do + whatever the normal CRC configuration tells us. However, if we + have an RGB image, the PLTE can be considered ancillary, so + we will act as though it is. */ +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { png_crc_finish(png_ptr, 0); } - -#ifndef PNG_READ_OPT_PLTE_SUPPORTED +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ { /* If we don't want to use the data from an ancillary chunk, - * we have two options: an error abort, or a warning and we - * ignore the data in this chunk (which should be OK, since - * it's considered ancillary for a RGB or RGBA image). - * - * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the - * chunk type to determine whether to check the ancillary or the critical - * flags. - */ + we have two options: an error abort, or a warning and we + ignore the data in this chunk (which should be OK, since + it's considered ancillary for a RGB or RGBA image). */ if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) { - png_chunk_benign_error(png_ptr, "CRC error"); + png_chunk_error(png_ptr, "CRC error"); } - else { png_chunk_warning(png_ptr, "CRC error"); return; } } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) { @@ -989,152 +518,176 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif - /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its - * own copy of the palette. This has the side effect that when png_start_row - * is called (this happens after any call to png_read_update_info) the - * info_ptr palette gets changed. This is extremely unexpected and - * confusing. - * - * Fix this by not sharing the palette in this way. - */ png_set_PLTE(png_ptr, info_ptr, palette, num); - /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before - * IDAT. Prior to 1.6.0 this was not checked; instead the code merely - * checked the apparent validity of a tRNS chunk inserted before PLTE on a - * palette PNG. 1.6.0 attempts to rigorously follow the standard and - * therefore does a benign error if the erroneous condition is detected *and* - * cancels the tRNS if the benign error returns. The alternative is to - * amend the standard since it would be rather hypocritical of the standards - * maintainers to ignore it. - */ -#ifdef PNG_READ_tRNS_SUPPORTED - if (png_ptr->num_trans > 0 || - (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) +#if defined(PNG_READ_tRNS_SUPPORTED) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - /* Cancel this because otherwise it would be used if the transforms - * require it. Don't cancel the 'valid' flag because this would prevent - * detection of duplicate chunks. - */ - png_ptr->num_trans = 0; - - if (info_ptr != NULL) - info_ptr->num_trans = 0; - - png_chunk_benign_error(png_ptr, "tRNS must be after"); + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + if (png_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); + png_ptr->num_trans = (png_uint_16)num; + } + if (info_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); + info_ptr->num_trans = (png_uint_16)num; + } + } } #endif -#ifdef PNG_READ_hIST_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) - png_chunk_benign_error(png_ptr, "hIST must be after"); -#endif - -#ifdef PNG_READ_bKGD_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) - png_chunk_benign_error(png_ptr, "bKGD must be after"); -#endif } void /* PRIVATE */ -png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_debug(1, "in png_handle_IEND"); + png_debug(1, "in png_handle_IEND\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - png_chunk_error(png_ptr, "out of place"); + { + png_error(png_ptr, "No image in file"); + } png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); + if (length != 0) + { + png_warning(png_ptr, "Incorrect IEND chunk length"); + } png_crc_finish(png_ptr, length); - if (length != 0) - png_chunk_benign_error(png_ptr, "invalid"); - - PNG_UNUSED(info_ptr) + if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ + return; } -#ifdef PNG_READ_gAMA_SUPPORTED +#if defined(PNG_READ_gAMA_SUPPORTED) void /* PRIVATE */ -png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_fixed_point igamma; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif png_byte buf[4]; - png_debug(1, "in png_handle_gAMA"); + png_debug(1, "in png_handle_gAMA\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing IHDR before gAMA"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid gAMA after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place gAMA chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate gAMA chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 4) { + png_warning(png_ptr, "Incorrect gAMA chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) return; - igamma = png_get_fixed_point(NULL, buf); + igamma = (png_fixed_point)png_get_uint_32(buf); + /* check for zero gamma */ + if (igamma == 0) + { + png_warning(png_ptr, + "Ignoring gAMA chunk with gamma=0"); + return; + } - png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma); - png_colorspace_sync(png_ptr, info_ptr); +#if defined(PNG_READ_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO + fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); +#endif + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float)igamma / (float)100000.0; +# ifdef PNG_READ_GAMMA_SUPPORTED + png_ptr->gamma = file_gamma; +# endif + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_gAMA_fixed(png_ptr, info_ptr, igamma); +#endif } #endif -#ifdef PNG_READ_sBIT_SUPPORTED +#if defined(PNG_READ_sBIT_SUPPORTED) void /* PRIVATE */ -png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - unsigned int truelen; + png_size_t truelen; png_byte buf[4]; - png_debug(1, "in png_handle_sBIT"); + png_debug(1, "in png_handle_sBIT\n"); buf[0] = buf[1] = buf[2] = buf[3] = 0; if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing IHDR before sBIT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid sBIT after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - + else if (png_ptr->mode & PNG_HAVE_PLTE) + { + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sBIT chunk"); + } if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) { + png_warning(png_ptr, "Duplicate sBIT chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 3; - else - truelen = png_ptr->channels; + truelen = (png_size_t)png_ptr->channels; if (length != truelen || length > 4) { - png_chunk_benign_error(png_ptr, "invalid"); + png_warning(png_ptr, "Incorrect sBIT chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) return; @@ -1145,7 +698,6 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->sig_bit.blue = buf[2]; png_ptr->sig_bit.alpha = buf[3]; } - else { png_ptr->sig_bit.gray = buf[0]; @@ -1154,606 +706,549 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->sig_bit.blue = buf[0]; png_ptr->sig_bit.alpha = buf[1]; } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); } #endif -#ifdef PNG_READ_cHRM_SUPPORTED +#if defined(PNG_READ_cHRM_SUPPORTED) void /* PRIVATE */ -png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_byte buf[32]; - png_xy xy; + png_byte buf[4]; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif + png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue; - png_debug(1, "in png_handle_cHRM"); + png_uint_32 uint_x, uint_y; + + png_debug(1, "in png_handle_cHRM\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing IHDR before cHRM"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid cHRM after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Missing PLTE before cHRM"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate cHRM chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 32) { + png_warning(png_ptr, "Incorrect cHRM chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, buf, 32); + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM white point"); + png_crc_finish(png_ptr, 24); + return; + } + int_x_white = (png_fixed_point)uint_x; + int_y_white = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM red point"); + png_crc_finish(png_ptr, 16); + return; + } + int_x_red = (png_fixed_point)uint_x; + int_y_red = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM green point"); + png_crc_finish(png_ptr, 8); + return; + } + int_x_green = (png_fixed_point)uint_x; + int_y_green = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM blue point"); + png_crc_finish(png_ptr, 0); + return; + } + int_x_blue = (png_fixed_point)uint_x; + int_y_blue = (png_fixed_point)uint_y; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float)int_x_white / (float)100000.0; + white_y = (float)int_y_white / (float)100000.0; + red_x = (float)int_x_red / (float)100000.0; + red_y = (float)int_y_red / (float)100000.0; + green_x = (float)int_x_green / (float)100000.0; + green_y = (float)int_y_green / (float)100000.0; + blue_x = (float)int_x_blue / (float)100000.0; + blue_y = (float)int_y_blue / (float)100000.0; +#endif + +#if defined(PNG_READ_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + { + if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) + { + + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", + white_x, white_y, red_x, red_y); + fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", + green_x, green_y, blue_x, blue_y); +#else + fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", + int_x_white, int_y_white, int_x_red, int_y_red); + fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", + int_x_green, int_y_green, int_x_blue, int_y_blue); +#endif +#endif /* PNG_NO_CONSOLE_IO */ + } + png_crc_finish(png_ptr, 0); + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_cHRM_fixed(png_ptr, info_ptr, + int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue); +#endif if (png_crc_finish(png_ptr, 0)) return; - - xy.whitex = png_get_fixed_point(NULL, buf); - xy.whitey = png_get_fixed_point(NULL, buf + 4); - xy.redx = png_get_fixed_point(NULL, buf + 8); - xy.redy = png_get_fixed_point(NULL, buf + 12); - xy.greenx = png_get_fixed_point(NULL, buf + 16); - xy.greeny = png_get_fixed_point(NULL, buf + 20); - xy.bluex = png_get_fixed_point(NULL, buf + 24); - xy.bluey = png_get_fixed_point(NULL, buf + 28); - - if (xy.whitex == PNG_FIXED_ERROR || - xy.whitey == PNG_FIXED_ERROR || - xy.redx == PNG_FIXED_ERROR || - xy.redy == PNG_FIXED_ERROR || - xy.greenx == PNG_FIXED_ERROR || - xy.greeny == PNG_FIXED_ERROR || - xy.bluex == PNG_FIXED_ERROR || - xy.bluey == PNG_FIXED_ERROR) - { - png_chunk_benign_error(png_ptr, "invalid values"); - return; - } - - /* If a colorspace error has already been output skip this chunk */ - if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) - return; - - if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) - { - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, - 1/*prefer cHRM values*/); - png_colorspace_sync(png_ptr, info_ptr); } #endif -#ifdef PNG_READ_sRGB_SUPPORTED +#if defined(PNG_READ_sRGB_SUPPORTED) void /* PRIVATE */ -png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_byte intent; + int intent; + png_byte buf[1]; - png_debug(1, "in png_handle_sRGB"); + png_debug(1, "in png_handle_sRGB\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing IHDR before sRGB"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid sRGB after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sRGB chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + { + png_warning(png_ptr, "Duplicate sRGB chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 1) { + png_warning(png_ptr, "Incorrect sRGB chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, &intent, 1); - + png_crc_read(png_ptr, buf, 1); if (png_crc_finish(png_ptr, 0)) return; - /* If a colorspace error has already been output skip this chunk */ - if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) - return; - - /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect - * this. - */ - if (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) + intent = buf[0]; + /* check for bad intent */ + if (intent >= PNG_sRGB_INTENT_LAST) { - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - png_chunk_benign_error(png_ptr, "too many profiles"); + png_warning(png_ptr, "Unknown sRGB intent"); return; } - (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent); - png_colorspace_sync(png_ptr, info_ptr); +#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + if ((info_ptr->valid & PNG_INFO_gAMA)) + { + png_fixed_point igamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + igamma=info_ptr->int_gamma; +#else +# ifdef PNG_FLOATING_POINT_SUPPORTED + igamma=(png_fixed_point)(info_ptr->gamma * 100000.); +# endif +#endif + if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +# ifdef PNG_FIXED_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); +# else +# ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); +# endif +# endif +#endif + } + } +#endif /* PNG_READ_gAMA_SUPPORTED */ + +#ifdef PNG_READ_cHRM_SUPPORTED +#ifdef PNG_FIXED_POINT_SUPPORTED + if (info_ptr->valid & PNG_INFO_cHRM) + if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) + { + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); + } +#endif /* PNG_FIXED_POINT_SUPPORTED */ +#endif /* PNG_READ_cHRM_SUPPORTED */ + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); } #endif /* PNG_READ_sRGB_SUPPORTED */ -#ifdef PNG_READ_iCCP_SUPPORTED +#if defined(PNG_READ_iCCP_SUPPORTED) void /* PRIVATE */ -png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -/* Note: this does not properly handle profiles that are > 64K under DOS */ -{ - png_const_charp errmsg = NULL; /* error message output, or no error */ - int finished = 0; /* crc checked */ - - png_debug(1, "in png_handle_iCCP"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - /* Consistent with all the above colorspace handling an obviously *invalid* - * chunk is just ignored, so does not invalidate the color space. An - * alternative is to set the 'invalid' flags at the start of this routine - * and only clear them in they were not set before and all the tests pass. - * The minimum 'deflate' stream is assumed to be just the 2 byte header and 4 - * byte checksum. The keyword must be one character and there is a - * terminator (0) byte and the compression method. - */ - if (length < 9) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too short"); - return; - } - - /* If a colorspace error has already been output skip this chunk */ - if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) - { - png_crc_finish(png_ptr, length); - return; - } - - /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect - * this. - */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0) - { - uInt read_length, keyword_length; - char keyword[81]; - - /* Find the keyword; the keyword plus separator and compression method - * bytes can be at most 81 characters long. - */ - read_length = 81; /* maximum */ - if (read_length > length) - read_length = (uInt)length; - - png_crc_read(png_ptr, (png_bytep)keyword, read_length); - length -= read_length; - - keyword_length = 0; - while (keyword_length < 80 && keyword_length < read_length && - keyword[keyword_length] != 0) - ++keyword_length; - - /* TODO: make the keyword checking common */ - if (keyword_length >= 1 && keyword_length <= 79) - { - /* We only understand '0' compression - deflate - so if we get a - * different value we can't safely decode the chunk. - */ - if (keyword_length+1 < read_length && - keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE) - { - read_length -= keyword_length+2; - - if (png_inflate_claim(png_ptr, png_iCCP, - png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0) == Z_OK) - { - Byte profile_header[132]; - Byte local_buffer[PNG_INFLATE_BUF_SIZE]; - png_alloc_size_t size = (sizeof profile_header); - - png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); - png_ptr->zstream.avail_in = read_length; - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, profile_header, &size, - 0/*finish: don't, because the output is too small*/); - - if (size == 0) - { - /* We have the ICC profile header; do the basic header checks. - */ - const png_uint_32 profile_length = - png_get_uint_32(profile_header); - - if (png_icc_check_length(png_ptr, &png_ptr->colorspace, - keyword, profile_length)) - { - /* The length is apparently ok, so we can check the 132 - * byte header. - */ - if (png_icc_check_header(png_ptr, &png_ptr->colorspace, - keyword, profile_length, profile_header, - png_ptr->color_type)) - { - /* Now read the tag table; a variable size buffer is - * needed at this point, allocate one for the whole - * profile. The header check has already validated - * that none of these stuff will overflow. - */ - const png_uint_32 tag_count = png_get_uint_32( - profile_header+128); - png_bytep profile = png_read_buffer(png_ptr, - profile_length, 2/*silent*/); - - if (profile != NULL) - { - memcpy(profile, profile_header, - (sizeof profile_header)); - - size = 12 * tag_count; - - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header), &size, 0); - - /* Still expect a a buffer error because we expect - * there to be some tag data! - */ - if (size == 0) - { - if (png_icc_check_tag_table(png_ptr, - &png_ptr->colorspace, keyword, profile_length, - profile)) - { - /* The profile has been validated for basic - * security issues, so read the whole thing in. - */ - size = profile_length - (sizeof profile_header) - - 12 * tag_count; - - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header) + - 12 * tag_count, &size, 1/*finish*/); - - if (length > 0 && !(png_ptr->flags & - PNG_FLAG_BENIGN_ERRORS_WARN)) - errmsg = "extra compressed data"; - - /* But otherwise allow extra data: */ - else if (size == 0) - { - if (length > 0) - { - /* This can be handled completely, so - * keep going. - */ - png_chunk_warning(png_ptr, - "extra compressed data"); - } - - png_crc_finish(png_ptr, length); - finished = 1; - -# ifdef PNG_sRGB_SUPPORTED - /* Check for a match against sRGB */ - png_icc_set_sRGB(png_ptr, - &png_ptr->colorspace, profile, - png_ptr->zstream.adler); -# endif - - /* Steal the profile for info_ptr. */ - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, - PNG_FREE_ICCP, 0); - - info_ptr->iccp_name = png_voidcast(char*, - png_malloc_base(png_ptr, - keyword_length+1)); - if (info_ptr->iccp_name != NULL) - { - memcpy(info_ptr->iccp_name, keyword, - keyword_length+1); - info_ptr->iccp_proflen = - profile_length; - info_ptr->iccp_profile = profile; - png_ptr->read_buffer = NULL; /*steal*/ - info_ptr->free_me |= PNG_FREE_ICCP; - info_ptr->valid |= PNG_INFO_iCCP; - } - - else - { - png_ptr->colorspace.flags |= - PNG_COLORSPACE_INVALID; - errmsg = "out of memory"; - } - } - - /* else the profile remains in the read - * buffer which gets reused for subsequent - * chunks. - */ - - if (info_ptr != NULL) - png_colorspace_sync(png_ptr, info_ptr); - - if (errmsg == NULL) - { - png_ptr->zowner = 0; - return; - } - } - - else if (size > 0) - errmsg = "truncated"; - - else - errmsg = png_ptr->zstream.msg; - } - - /* else png_icc_check_tag_table output an error */ - } - - else /* profile truncated */ - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "out of memory"; - } - - /* else png_icc_check_header output an error */ - } - - /* else png_icc_check_length output an error */ - } - - else /* profile truncated */ - errmsg = png_ptr->zstream.msg; - - /* Release the stream */ - png_ptr->zowner = 0; - } - - else /* png_inflate_claim failed */ - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "bad compression method"; /* or missing */ - } - - else - errmsg = "bad keyword"; - } - - else - errmsg = "too many profiles"; - - /* Failure: the reason is in 'errmsg' */ - if (!finished) - png_crc_finish(png_ptr, length); - - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - if (errmsg != NULL) /* else already output */ - png_chunk_benign_error(png_ptr, errmsg); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#ifdef PNG_READ_sPLT_SUPPORTED -void /* PRIVATE */ -png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_bytep entry_start, buffer; - png_sPLT_t new_palette; - png_sPLT_entryp pp; - png_uint_32 data_length; - int entry_size, i; + png_charp chunkdata; + png_byte compression_type; + png_bytep pC; + png_charp profile; png_uint_32 skip = 0; - png_uint_32 dl; - png_size_t max_dl; + png_uint_32 profile_size, profile_length; + png_size_t slength, prefix_length, data_length; - png_debug(1, "in png_handle_sPLT"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_warning(png_ptr, "No space in chunk cache for sPLT"); - png_crc_finish(png_ptr, length); - return; - } - } -#endif + png_debug(1, "in png_handle_iCCP\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before iCCP"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid iCCP after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place iCCP chunk"); + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) + { + png_warning(png_ptr, "Duplicate iCCP chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } #ifdef PNG_MAX_MALLOC_64K - if (length > 65535U) + if (length > (png_uint_32)65535L) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too large to fit in memory"); - return; + png_warning(png_ptr, "iCCP chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; } #endif - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - if (buffer == NULL) + chunkdata = (png_charp)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + if (png_crc_finish(png_ptr, skip)) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); + png_free(png_ptr, chunkdata); return; } + chunkdata[slength] = 0x00; - /* WARNING: this may break if size_t is less than 32 bits; it is assumed - * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a - * potential breakage point if the types in pngconf.h aren't exactly right. - */ - png_crc_read(png_ptr, buffer, length); + for (profile = chunkdata; *profile; profile++) + /* empty loop to find end of name */ ; + + ++profile; + + /* there should be at least one zero (the compression type byte) + following the separator, and we should be on it */ + if ( profile >= chunkdata + slength) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Malformed iCCP chunk"); + return; + } + + /* compression_type should always be zero */ + compression_type = *profile++; + if (compression_type) + { + png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); + compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 + wrote nonzero) */ + } + + prefix_length = profile - chunkdata; + chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, + slength, prefix_length, &data_length); + + profile_length = data_length - prefix_length; + + if ( prefix_length > data_length || profile_length < 4) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Profile size field missing from iCCP chunk"); + return; + } + + /* Check the profile_size recorded in the first 32 bits of the ICC profile */ + pC = (png_bytep)(chunkdata+prefix_length); + profile_size = ((*(pC ))<<24) | + ((*(pC+1))<<16) | + ((*(pC+2))<< 8) | + ((*(pC+3)) ); + + if(profile_size < profile_length) + profile_length = profile_size; + + if(profile_size > profile_length) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); + return; + } + + png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, + chunkdata + prefix_length, profile_length); + png_free(png_ptr, chunkdata); +} +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_sPLT_SUPPORTED) +void /* PRIVATE */ +png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_bytep chunkdata; + png_bytep entry_start; + png_sPLT_t new_palette; +#ifdef PNG_NO_POINTER_INDEXING + png_sPLT_entryp pp; +#endif + int data_length, entry_size, i; + png_uint_32 skip = 0; + png_size_t slength; + + png_debug(1, "in png_handle_sPLT\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sPLT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sPLT after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "sPLT chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, chunkdata); return; + } - buffer[length] = 0; - - for (entry_start = buffer; *entry_start; entry_start++) - /* Empty loop to find end of name */ ; + chunkdata[slength] = 0x00; + for (entry_start = chunkdata; *entry_start; entry_start++) + /* empty loop to find end of name */ ; ++entry_start; - /* A sample depth should follow the separator, and we should be on it */ - if (entry_start > buffer + length - 2) + /* a sample depth should follow the separator, and we should be on it */ + if (entry_start > chunkdata + slength) { + png_free(png_ptr, chunkdata); png_warning(png_ptr, "malformed sPLT chunk"); return; } new_palette.depth = *entry_start++; entry_size = (new_palette.depth == 8 ? 6 : 10); - /* This must fit in a png_uint_32 because it is derived from the original - * chunk data length. - */ - data_length = length - (png_uint_32)(entry_start - buffer); + data_length = (slength - (entry_start - chunkdata)); - /* Integrity-check the data length */ + /* integrity-check the data length */ if (data_length % entry_size) { + png_free(png_ptr, chunkdata); png_warning(png_ptr, "sPLT chunk has bad length"); return; } - dl = (png_int_32)(data_length / entry_size); - max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); - - if (dl > max_dl) + new_palette.nentries = (png_uint_32) (data_length / entry_size); + if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / + png_sizeof(png_sPLT_entry))) { png_warning(png_ptr, "sPLT chunk too long"); return; } - - new_palette.nentries = (png_int_32)(data_length / entry_size); - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry))); - + png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); if (new_palette.entries == NULL) { png_warning(png_ptr, "sPLT chunk requires too much memory"); return; } -#ifdef PNG_POINTER_INDEXING_SUPPORTED +#ifndef PNG_NO_POINTER_INDEXING for (i = 0; i < new_palette.nentries; i++) { - pp = new_palette.entries + i; + png_sPLT_entryp pp = new_palette.entries + i; if (new_palette.depth == 8) { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; + pp->red = *entry_start++; + pp->green = *entry_start++; + pp->blue = *entry_start++; + pp->alpha = *entry_start++; } - else { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; + pp->red = png_get_uint_16(entry_start); entry_start += 2; + pp->green = png_get_uint_16(entry_start); entry_start += 2; + pp->blue = png_get_uint_16(entry_start); entry_start += 2; + pp->alpha = png_get_uint_16(entry_start); entry_start += 2; } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; } #else pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) { if (new_palette.depth == 8) { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; + pp[i].red = *entry_start++; + pp[i].green = *entry_start++; + pp[i].blue = *entry_start++; + pp[i].alpha = *entry_start++; } - else { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; + pp[i].red = png_get_uint_16(entry_start); entry_start += 2; + pp[i].green = png_get_uint_16(entry_start); entry_start += 2; + pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; + pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; } - - pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2; + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; } #endif - /* Discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)buffer; + /* discard all chunk data except the name and stash that */ + new_palette.name = (png_charp)chunkdata; png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); + png_free(png_ptr, chunkdata); png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ -#ifdef PNG_READ_tRNS_SUPPORTED +#if defined(PNG_READ_tRNS_SUPPORTED) void /* PRIVATE */ -png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_tRNS"); + png_debug(1, "in png_handle_tRNS\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before tRNS"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid tRNS after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { + png_warning(png_ptr, "Duplicate tRNS chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } @@ -1763,210 +1258,194 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (length != 2) { + png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 2); png_ptr->num_trans = 1; - png_ptr->trans_color.gray = png_get_uint_16(buf); + png_ptr->trans_values.gray = png_get_uint_16(buf); } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { png_byte buf[6]; if (length != 6) { + png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } - - png_crc_read(png_ptr, buf, length); + png_crc_read(png_ptr, buf, (png_size_t)length); png_ptr->num_trans = 1; - png_ptr->trans_color.red = png_get_uint_16(buf); - png_ptr->trans_color.green = png_get_uint_16(buf + 2); - png_ptr->trans_color.blue = png_get_uint_16(buf + 4); + png_ptr->trans_values.red = png_get_uint_16(buf); + png_ptr->trans_values.green = png_get_uint_16(buf + 2); + png_ptr->trans_values.blue = png_get_uint_16(buf + 4); } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (!(png_ptr->mode & PNG_HAVE_PLTE)) { - /* TODO: is this actually an error in the ISO spec? */ - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; + /* Should be an error, but we can cope with it. */ + png_warning(png_ptr, "Missing PLTE before tRNS"); } - - if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH || - length == 0) + if (length > (png_uint_32)png_ptr->num_palette || + length > PNG_MAX_PALETTE_LENGTH) { + png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } - - png_crc_read(png_ptr, readbuf, length); + if (length == 0) + { + png_warning(png_ptr, "Zero length tRNS chunk"); + png_crc_finish(png_ptr, length); + return; + } + png_crc_read(png_ptr, readbuf, (png_size_t)length); png_ptr->num_trans = (png_uint_16)length; } - else { + png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid with alpha channel"); return; } if (png_crc_finish(png_ptr, 0)) - { - png_ptr->num_trans = 0; return; - } - /* TODO: this is a horrible side effect in the palette case because the - * png_struct ends up with a pointer to the tRNS buffer owned by the - * png_info. Fix this. - */ png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_color)); + &(png_ptr->trans_values)); } #endif -#ifdef PNG_READ_bKGD_SUPPORTED +#if defined(PNG_READ_bKGD_SUPPORTED) void /* PRIVATE */ -png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - unsigned int truelen; + png_size_t truelen; png_byte buf[6]; - png_color_16 background; - png_debug(1, "in png_handle_bKGD"); + png_debug(1, "in png_handle_bKGD\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE))) + png_error(png_ptr, "Missing IHDR before bKGD"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid bKGD after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before bKGD"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) { + png_warning(png_ptr, "Duplicate bKGD chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) truelen = 6; - else truelen = 2; if (length != truelen) { + png_warning(png_ptr, "Incorrect bKGD chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) return; /* We convert the index value into RGB components so that we can allow * arbitrary RGB values for background when we have transparency, and * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. - */ + * from the info_ptr struct. */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - background.index = buf[0]; - - if (info_ptr && info_ptr->num_palette) + png_ptr->background.index = buf[0]; + if(info_ptr->num_palette) { - if (buf[0] >= info_ptr->num_palette) - { - png_chunk_benign_error(png_ptr, "invalid index"); - return; - } - - background.red = (png_uint_16)png_ptr->palette[buf[0]].red; - background.green = (png_uint_16)png_ptr->palette[buf[0]].green; - background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue; + if(buf[0] > info_ptr->num_palette) + { + png_warning(png_ptr, "Incorrect bKGD chunk index value"); + return; + } + png_ptr->background.red = + (png_uint_16)png_ptr->palette[buf[0]].red; + png_ptr->background.green = + (png_uint_16)png_ptr->palette[buf[0]].green; + png_ptr->background.blue = + (png_uint_16)png_ptr->palette[buf[0]].blue; } - - else - background.red = background.green = background.blue = 0; - - background.gray = 0; } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ { - background.index = 0; - background.red = - background.green = - background.blue = - background.gray = png_get_uint_16(buf); + png_ptr->background.red = + png_ptr->background.green = + png_ptr->background.blue = + png_ptr->background.gray = png_get_uint_16(buf); } - else { - background.index = 0; - background.red = png_get_uint_16(buf); - background.green = png_get_uint_16(buf + 2); - background.blue = png_get_uint_16(buf + 4); - background.gray = 0; + png_ptr->background.red = png_get_uint_16(buf); + png_ptr->background.green = png_get_uint_16(buf + 2); + png_ptr->background.blue = png_get_uint_16(buf + 4); } - png_set_bKGD(png_ptr, info_ptr, &background); + png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); } #endif -#ifdef PNG_READ_hIST_SUPPORTED +#if defined(PNG_READ_hIST_SUPPORTED) void /* PRIVATE */ -png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { unsigned int num, i; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_hIST"); + png_debug(1, "in png_handle_hIST\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) || !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing IHDR before hIST"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid hIST after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (!(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before hIST"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) { + png_warning(png_ptr, "Duplicate hIST chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } num = length / 2 ; - - if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH) + if (num != (unsigned int) png_ptr->num_palette || num > + (unsigned int) PNG_MAX_PALETTE_LENGTH) { + png_warning(png_ptr, "Incorrect hIST chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } @@ -1985,42 +1464,39 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif -#ifdef PNG_READ_pHYs_SUPPORTED +#if defined(PNG_READ_pHYs_SUPPORTED) void /* PRIVATE */ -png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; png_uint_32 res_x, res_y; int unit_type; - png_debug(1, "in png_handle_pHYs"); + png_debug(1, "in png_handle_pHYs\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before pHYs"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid pHYs after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { + png_warning(png_ptr, "Duplicate pHYs chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } if (length != 9) { + png_warning(png_ptr, "Incorrect pHYs chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) return; @@ -2031,42 +1507,39 @@ png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif -#ifdef PNG_READ_oFFs_SUPPORTED +#if defined(PNG_READ_oFFs_SUPPORTED) void /* PRIVATE */ -png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; png_int_32 offset_x, offset_y; int unit_type; - png_debug(1, "in png_handle_oFFs"); + png_debug(1, "in png_handle_oFFs\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before oFFs"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid oFFs after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { + png_warning(png_ptr, "Duplicate oFFs chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } if (length != 9) { + png_warning(png_ptr, "Incorrect oFFs chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) return; @@ -2077,245 +1550,277 @@ png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif -#ifdef PNG_READ_pCAL_SUPPORTED -/* Read the pCAL chunk (described in the PNG Extensions document) */ +#if defined(PNG_READ_pCAL_SUPPORTED) +/* read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ -png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { + png_charp purpose; png_int_32 X0, X1; png_byte type, nparams; - png_bytep buffer, buf, units, endptr; + png_charp buf, units, endptr; png_charpp params; + png_size_t slength; int i; - png_debug(1, "in png_handle_pCAL"); + png_debug(1, "in png_handle_pCAL\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before pCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid pCAL after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) { + png_warning(png_ptr, "Duplicate pCAL chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } - png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)", - length + 1); - - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - - if (buffer == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - png_crc_read(png_ptr, buffer, length); + png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", + length + 1); + purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (purpose == NULL) + { + png_warning(png_ptr, "No memory for pCAL purpose."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)purpose, slength); if (png_crc_finish(png_ptr, 0)) - return; - - buffer[length] = 0; /* Null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string"); - for (buf = buffer; *buf; buf++) - /* Empty loop */ ; - - endptr = buffer + length; - - /* We need to have at least 12 bytes after the purpose string - * in order to get the parameter information. - */ - if (endptr <= buf + 12) { - png_chunk_benign_error(png_ptr, "invalid"); + png_free(png_ptr, purpose); return; } - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); + purpose[slength] = 0x00; /* null terminate the last string */ + + png_debug(3, "Finding end of pCAL purpose string\n"); + for (buf = purpose; *buf; buf++) + /* empty loop */ ; + + endptr = purpose + slength; + + /* We need to have at least 12 bytes after the purpose string + in order to get the parameter information. */ + if (endptr <= buf + 12) + { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); + return; + } + + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); X0 = png_get_int_32((png_bytep)buf+1); X1 = png_get_int_32((png_bytep)buf+5); type = buf[9]; nparams = buf[10]; units = buf + 11; - png_debug(3, "Checking pCAL equation type and number of parameters"); + png_debug(3, "Checking pCAL equation type and number of parameters\n"); /* Check that we have the right number of parameters for known - * equation types. - */ + equation types. */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || (type == PNG_EQUATION_BASE_E && nparams != 3) || (type == PNG_EQUATION_ARBITRARY && nparams != 3) || (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) { - png_chunk_benign_error(png_ptr, "invalid parameter count"); + png_warning(png_ptr, "Invalid pCAL parameters for equation type"); + png_free(png_ptr, purpose); return; } - else if (type >= PNG_EQUATION_LAST) { - png_chunk_benign_error(png_ptr, "unrecognized equation type"); + png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); } for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; - png_debug(3, "Allocating pCAL parameters array"); - - params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - nparams * (sizeof (png_charp)))); - + png_debug(3, "Allocating pCAL parameters array\n"); + params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams + *png_sizeof(png_charp))) ; if (params == NULL) - { - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } + { + png_free(png_ptr, purpose); + png_warning(png_ptr, "No memory for pCAL params."); + return; + } /* Get pointers to the start of each parameter string. */ - for (i = 0; i < nparams; i++) + for (i = 0; i < (int)nparams; i++) { buf++; /* Skip the null string terminator from previous parameter. */ - png_debug1(3, "Reading pCAL parameter %d", i); - - for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++) + png_debug1(3, "Reading pCAL parameter %d\n", i); + for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) /* Empty loop to move past each parameter string */ ; /* Make sure we haven't run out of data yet */ if (buf > endptr) { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); png_free(png_ptr, params); - png_chunk_benign_error(png_ptr, "invalid data"); return; } } - png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, - (png_charp)units, params); + png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, + units, params); + png_free(png_ptr, purpose); png_free(png_ptr, params); } #endif -#ifdef PNG_READ_sCAL_SUPPORTED -/* Read the sCAL chunk */ +#if defined(PNG_READ_sCAL_SUPPORTED) +/* read the sCAL chunk */ void /* PRIVATE */ -png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_bytep buffer; - png_size_t i; - int state; + png_charp buffer, ep; +#ifdef PNG_FLOATING_POINT_SUPPORTED + double width, height; + png_charp vp; +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp swidth, sheight; +#endif +#endif + png_size_t slength; - png_debug(1, "in png_handle_sCAL"); + png_debug(1, "in png_handle_sCAL\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Missing IHDR before sCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) { + png_warning(png_ptr, "Invalid sCAL after IDAT"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { + png_warning(png_ptr, "Duplicate sCAL chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } - /* Need unit type, width, \0, height: minimum 4 bytes */ - else if (length < 4) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", + png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", length + 1); - - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - + buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); if (buffer == NULL) - { - png_chunk_benign_error(png_ptr, "out of memory"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buffer, length); - buffer[length] = 0; /* Null terminate the last string */ + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk"); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)buffer, slength); if (png_crc_finish(png_ptr, 0)) - return; - - /* Validate the unit. */ - if (buffer[0] != 1 && buffer[0] != 2) { - png_chunk_benign_error(png_ptr, "invalid unit"); + png_free(png_ptr, buffer); return; } - /* Validate the ASCII numbers, need two ASCII numbers separated by - * a '\0' and they need to fit exactly in the chunk data. - */ - i = 1; - state = 0; + buffer[slength] = 0x00; /* null terminate the last string */ - if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) || - i >= length || buffer[i++] != 0) - png_chunk_benign_error(png_ptr, "bad width format"); + ep = buffer + 1; /* skip unit byte */ - else if (!PNG_FP_IS_POSITIVE(state)) - png_chunk_benign_error(png_ptr, "non-positive width"); - - else +#ifdef PNG_FLOATING_POINT_SUPPORTED + width = strtod(ep, &vp); + if (*vp) { - png_size_t heighti = i; - - state = 0; - if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) || - i != length) - png_chunk_benign_error(png_ptr, "bad height format"); - - else if (!PNG_FP_IS_POSITIVE(state)) - png_chunk_benign_error(png_ptr, "non-positive height"); - - else - /* This is the (only) success case. */ - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], - (png_charp)buffer+1, (png_charp)buffer+heighti); + png_warning(png_ptr, "malformed width string in sCAL chunk"); + return; } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); + return; + } + png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + for (ep = buffer; *ep; ep++) + /* empty loop */ ; + ep++; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + height = strtod(ep, &vp); + if (*vp) + { + png_warning(png_ptr, "malformed height string in sCAL chunk"); + return; + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); + return; + } + png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + if (buffer + slength < ep +#ifdef PNG_FLOATING_POINT_SUPPORTED + || width <= 0. || height <= 0. +#endif + ) + { + png_warning(png_ptr, "Invalid sCAL data"); + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif + return; + } + + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); +#endif +#endif + + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif } #endif -#ifdef PNG_READ_tIME_SUPPORTED +#if defined(PNG_READ_tIME_SUPPORTED) void /* PRIVATE */ -png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[7]; png_time mod_time; - png_debug(1, "in png_handle_tIME"); + png_debug(1, "in png_handle_tIME\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); - + png_error(png_ptr, "Out of place tIME chunk"); else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) { + png_warning(png_ptr, "Duplicate tIME chunk"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); return; } @@ -2324,13 +1829,12 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (length != 7) { + png_warning(png_ptr, "Incorrect tIME chunk length"); png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) return; @@ -2345,1136 +1849,628 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif -#ifdef PNG_READ_tEXt_SUPPORTED +#if defined(PNG_READ_tEXt_SUPPORTED) /* Note: this does not properly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_text text_info; - png_bytep buffer; + png_textp text_ptr; png_charp key; png_charp text; png_uint_32 skip = 0; + png_size_t slength; + int ret; - png_debug(1, "in png_handle_tEXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif + png_debug(1, "in png_handle_tEXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); + png_error(png_ptr, "Missing IHDR before tEXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K - if (length > 65535U) + if (length > (png_uint_32)65535L) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too large to fit in memory"); - return; + png_warning(png_ptr, "tEXt chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; } #endif - buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); - - if (buffer == NULL) + key = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (key == NULL) { - png_chunk_benign_error(png_ptr, "out of memory"); + png_warning(png_ptr, "No memory to process text chunk."); return; } - - png_crc_read(png_ptr, buffer, length); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)key, slength); if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, key); return; + } - key = (png_charp)buffer; - key[length] = 0; + key[slength] = 0x00; for (text = key; *text; text++) - /* Empty loop to find end of key */ ; + /* empty loop to find end of key */ ; - if (text != key + length) + if (text != key + slength) text++; - text_info.compression = PNG_TEXT_COMPRESSION_NONE; - text_info.key = key; - text_info.lang = NULL; - text_info.lang_key = NULL; - text_info.itxt_length = 0; - text_info.text = text; - text_info.text_length = strlen(text); + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr, "Not enough memory to process text chunk."); + png_free(png_ptr, key); + return; + } + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = text; + text_ptr->text_length = png_strlen(text); - if (png_set_text_2(png_ptr, info_ptr, &text_info, 1)) - png_warning(png_ptr, "Insufficient memory to process text chunk"); + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + if (ret) + png_warning(png_ptr, "Insufficient memory to process text chunk."); } #endif -#ifdef PNG_READ_zTXt_SUPPORTED -/* Note: this does not correctly handle chunks that are > 64K under DOS */ +#if defined(PNG_READ_zTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_const_charp errmsg = NULL; - png_bytep buffer; - png_uint_32 keyword_length; - - png_debug(1, "in png_handle_zTXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif + png_textp text_ptr; + png_charp chunkdata; + png_charp text; + int comp_type; + int ret; + png_size_t slength, prefix_len, data_len; + png_debug(1, "in png_handle_zTXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); + png_error(png_ptr, "Missing IHDR before zTXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; - buffer = png_read_buffer(png_ptr, length, 2/*silent*/); - - if (buffer == NULL) +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); + png_warning(png_ptr,"zTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; + } +#endif + + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr,"Out of memory processing zTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, chunkdata); return; } - png_crc_read(png_ptr, buffer, length); + chunkdata[slength] = 0x00; - if (png_crc_finish(png_ptr, 0)) - return; - - /* TODO: also check that the keyword contents match the spec! */ - for (keyword_length = 0; - keyword_length < length && buffer[keyword_length] != 0; - ++keyword_length) - /* Empty loop to find end of name */ ; - - if (keyword_length > 79 || keyword_length < 1) - errmsg = "bad keyword"; - - /* zTXt must have some LZ data after the keyword, although it may expand to - * zero bytes; we need a '\0' at the end of the keyword, the compression type - * then the LZ data: - */ - else if (keyword_length + 3 > length) - errmsg = "truncated"; - - else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE) - errmsg = "unknown compression type"; + for (text = chunkdata; *text; text++) + /* empty loop */ ; + /* zTXt must have some text after the chunkdataword */ + if (text == chunkdata + slength) + { + comp_type = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length zTXt chunk"); + } else { - png_alloc_size_t uncompressed_length = PNG_SIZE_MAX; - - /* TODO: at present png_decompress_chunk imposes a single application - * level memory limit, this should be split to different values for iCCP - * and text chunks. - */ - if (png_decompress_chunk(png_ptr, length, keyword_length+2, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) - { - png_text text; - - /* It worked; png_ptr->read_buffer now looks like a tEXt chunk except - * for the extra compression type byte and the fact that it isn't - * necessarily '\0' terminated. - */ - buffer = png_ptr->read_buffer; - buffer[uncompressed_length+(keyword_length+2)] = 0; - - text.compression = PNG_TEXT_COMPRESSION_zTXt; - text.key = (png_charp)buffer; - text.text = (png_charp)(buffer + keyword_length+2); - text.text_length = uncompressed_length; - text.itxt_length = 0; - text.lang = NULL; - text.lang_key = NULL; - - if (png_set_text_2(png_ptr, info_ptr, &text, 1)) - errmsg = "insufficient memory"; - } - - else - errmsg = png_ptr->zstream.msg; + comp_type = *(++text); + if (comp_type != PNG_TEXT_COMPRESSION_zTXt) + { + png_warning(png_ptr, "Unknown compression type in zTXt chunk"); + comp_type = PNG_TEXT_COMPRESSION_zTXt; + } + text++; /* skip the compression_method byte */ } + prefix_len = text - chunkdata; - if (errmsg != NULL) - png_chunk_benign_error(png_ptr, errmsg); + chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, + (png_size_t)length, prefix_len, &data_len); + + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process zTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = comp_type; + text_ptr->key = chunkdata; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = chunkdata + prefix_len; + text_ptr->text_length = data_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store zTXt chunk."); } #endif -#ifdef PNG_READ_iTXt_SUPPORTED -/* Note: this does not correctly handle chunks that are > 64K under DOS */ +#if defined(PNG_READ_iTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_const_charp errmsg = NULL; - png_bytep buffer; - png_uint_32 prefix_length; + png_textp text_ptr; + png_charp chunkdata; + png_charp key, lang, text, lang_key; + int comp_flag; + int comp_type = 0; + int ret; + png_size_t slength, prefix_len, data_len; - png_debug(1, "in png_handle_iTXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif + png_debug(1, "in png_handle_iTXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_chunk_error(png_ptr, "missing IHDR"); + png_error(png_ptr, "Missing IHDR before iTXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; - buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); - - if (buffer == NULL) +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; + png_warning(png_ptr,"iTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; } +#endif - png_crc_read(png_ptr, buffer, length); - + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr, "No memory to process iTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, 0)) - return; - - /* First the keyword. */ - for (prefix_length=0; - prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* Perform a basic check on the keyword length here. */ - if (prefix_length > 79 || prefix_length < 1) - errmsg = "bad keyword"; - - /* Expect keyword, compression flag, compression type, language, translated - * keyword (both may be empty but are 0 terminated) then the text, which may - * be empty. - */ - else if (prefix_length + 5 > length) - errmsg = "truncated"; - - else if (buffer[prefix_length+1] == 0 || - (buffer[prefix_length+1] == 1 && - buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) { - int compressed = buffer[prefix_length+1] != 0; - png_uint_32 language_offset, translated_keyword_offset; - png_alloc_size_t uncompressed_length = 0; - - /* Now the language tag */ - prefix_length += 3; - language_offset = prefix_length; - - for (; prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* WARNING: the length may be invalid here, this is checked below. */ - translated_keyword_offset = ++prefix_length; - - for (; prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* prefix_length should now be at the trailing '\0' of the translated - * keyword, but it may already be over the end. None of this arithmetic - * can overflow because chunks are at most 2^31 bytes long, but on 16-bit - * systems the available allocaton may overflow. - */ - ++prefix_length; - - if (!compressed && prefix_length <= length) - uncompressed_length = length - prefix_length; - - else if (compressed && prefix_length < length) - { - uncompressed_length = PNG_SIZE_MAX; - - /* TODO: at present png_decompress_chunk imposes a single application - * level memory limit, this should be split to different values for - * iCCP and text chunks. - */ - if (png_decompress_chunk(png_ptr, length, prefix_length, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) - buffer = png_ptr->read_buffer; - - else - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "truncated"; - - if (errmsg == NULL) - { - png_text text; - - buffer[uncompressed_length+prefix_length] = 0; - - if (compressed) - text.compression = PNG_ITXT_COMPRESSION_NONE; - - else - text.compression = PNG_ITXT_COMPRESSION_zTXt; - - text.key = (png_charp)buffer; - text.lang = (png_charp)buffer + language_offset; - text.lang_key = (png_charp)buffer + translated_keyword_offset; - text.text = (png_charp)buffer + prefix_length; - text.text_length = 0; - text.itxt_length = uncompressed_length; - - if (png_set_text_2(png_ptr, info_ptr, &text, 1)) - errmsg = "insufficient memory"; - } + png_free(png_ptr, chunkdata); + return; } - else - errmsg = "bad compression info"; + chunkdata[slength] = 0x00; - if (errmsg != NULL) - png_chunk_benign_error(png_ptr, errmsg); + for (lang = chunkdata; *lang; lang++) + /* empty loop */ ; + lang++; /* skip NUL separator */ + + /* iTXt must have a language tag (possibly empty), two compression bytes, + translated keyword (possibly empty), and possibly some text after the + keyword */ + + if (lang >= chunkdata + slength) + { + comp_flag = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length iTXt chunk"); + } + else + { + comp_flag = *lang++; + comp_type = *lang++; + } + + for (lang_key = lang; *lang_key; lang_key++) + /* empty loop */ ; + lang_key++; /* skip NUL separator */ + + for (text = lang_key; *text; text++) + /* empty loop */ ; + text++; /* skip NUL separator */ + + prefix_len = text - chunkdata; + + key=chunkdata; + if (comp_flag) + chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, + (size_t)length, prefix_len, &data_len); + else + data_len=png_strlen(chunkdata + prefix_len); + text_ptr = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)png_sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process iTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = (int)comp_flag + 1; + text_ptr->lang_key = chunkdata+(lang_key-key); + text_ptr->lang = chunkdata+(lang-key); + text_ptr->itxt_length = data_len; + text_ptr->text_length = 0; + text_ptr->key = chunkdata; + text_ptr->text = chunkdata + prefix_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store iTXt chunk."); } #endif -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ -static int -png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) -{ - png_alloc_size_t limit = PNG_SIZE_MAX; - - if (png_ptr->unknown_chunk.data != NULL) - { - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - -# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; - -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; -# endif - - if (length <= limit) - { - PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name); - /* The following is safe because of the PNG_SIZE_MAX init above */ - png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/; - /* 'mode' is a flag array, only the bottom four bits matter here */ - png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/; - - if (length == 0) - png_ptr->unknown_chunk.data = NULL; - - else - { - /* Do a 'warn' here - it is handled below. */ - png_ptr->unknown_chunk.data = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, length)); - } - } - - if (png_ptr->unknown_chunk.data == NULL && length > 0) - { - /* This is benign because we clean up correctly */ - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "unknown chunk exceeds memory limits"); - return 0; - } - - else - { - if (length > 0) - png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length); - png_crc_finish(png_ptr, 0); - return 1; - } -} -#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ - -/* Handle an unknown, or known but disabled, chunk */ +/* This function is called when we haven't found a handler for a + chunk. If there isn't a problem with the chunk itself (ie bad + chunk name, CRC, or a critical chunk), the chunk is silently ignored + -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which + case it will be saved away to be written out later. */ void /* PRIVATE */ -png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 length, int keep) +png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - int handled = 0; /* the chunk was handled */ + png_uint_32 skip = 0; - png_debug(1, "in png_handle_unknown"); + png_debug(1, "in png_handle_unknown\n"); -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing - * the bug which meant that setting a non-default behavior for a specific - * chunk would be ignored (the default was always used unless a user - * callback was installed). - * - * 'keep' is the value from the png_chunk_unknown_handling, the setting for - * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it - * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here. - * This is just an optimization to avoid multiple calls to the lookup - * function. - */ -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name); -# endif -# endif + if (png_ptr->mode & PNG_HAVE_IDAT) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ + png_ptr->mode |= PNG_AFTER_IDAT; + } - /* One of the following methods will read the chunk or skip it (at least one - * of these is always defined because this is the only way to switch on - * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - */ -# ifdef PNG_READ_USER_CHUNKS_SUPPORTED - /* The user callback takes precedence over the chunk keep value, but the - * keep value is still required to validate a save of a critical chunk. - */ - if (png_ptr->read_user_chunk_fn != NULL) - { - if (png_cache_unknown_chunk(png_ptr, length)) - { - /* Callback to user unknown chunk handler */ - int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, - &png_ptr->unknown_chunk); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); - /* ret is: - * negative: An error occured, png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be discarded - * unless png_set_keep_unknown_chunks has been used to set - * a 'keep' behavior for this particular chunk, in which - * case that will be used. A critical chunk will cause an - * error at this point unless it is to be saved. - * positive: The chunk was handled, libpng will ignore/discard it. - */ - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); + if (!(png_ptr->chunk_name[0] & 0x20)) + { +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + && png_ptr->read_user_chunk_fn == NULL +#endif + ) +#endif + png_chunk_error(png_ptr, "unknown critical chunk"); + } - else if (ret == 0) - { - /* If the keep value is 'default' or 'never' override it, but - * still error out on critical chunks unless the keep value is - * 'always' While this is weird it is the behavior in 1.4.12. - * A possible improvement would be to obey the value set for the - * chunk, but this would be an API change that would probably - * damage some applications. - * - * The png_app_warning below catches the case that matters, where - * the application has not set specific save or ignore for this - * chunk or global save or ignore. - */ - if (keep < PNG_HANDLE_CHUNK_IF_SAFE) - { -# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) - { - png_chunk_warning(png_ptr, "Saving unknown chunk:"); - png_app_warning(png_ptr, - "forcing save of an unhandled chunk;" - " please call png_set_keep_unknown_chunks"); - /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ - } -# endif - keep = PNG_HANDLE_CHUNK_IF_SAFE; - } - } +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) + { + png_unknown_chunk chunk; - else /* chunk was handled */ - { - handled = 1; - /* Critical chunks can be safely discarded at this point. */ - keep = PNG_HANDLE_CHUNK_NEVER; - } - } +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "unknown chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + chunk.data = (png_bytep)png_malloc(png_ptr, length); + chunk.size = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunk.data, length); +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if(png_ptr->read_user_chunk_fn != NULL) + { + /* callback to user unknown chunk handler */ + if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) + { + if (!(png_ptr->chunk_name[0] & 0x20)) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS) + { + png_free(png_ptr, chunk.data); + png_chunk_error(png_ptr, "unknown critical chunk"); + } + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + } + } + else +#endif + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + png_free(png_ptr, chunk.data); + } + else +#endif + skip = length; - else - keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ - } + png_crc_finish(png_ptr, skip); - else - /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ -# endif /* PNG_READ_USER_CHUNKS_SUPPORTED */ - -# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED - { - /* keep is currently just the per-chunk setting, if there was no - * setting change it to the global default now (not that this may - * still be AS_DEFAULT) then obtain the cache of the chunk if required, - * if not simply skip the chunk. - */ - if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) - keep = png_ptr->unknown_default; - - if (keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_IF_SAFE && - PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) - { - if (!png_cache_unknown_chunk(png_ptr, length)) - keep = PNG_HANDLE_CHUNK_NEVER; - } - - else - png_crc_finish(png_ptr, length); - } -# else -# ifndef PNG_READ_USER_CHUNKS_SUPPORTED -# error no method to support READ_UNKNOWN_CHUNKS -# endif - - { - /* If here there is no read callback pointer set and no support is - * compiled in to just save the unknown chunks, so simply skip this - * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then - * the app has erroneously asked for unknown chunk saving when there - * is no support. - */ - if (keep > PNG_HANDLE_CHUNK_NEVER) - png_app_error(png_ptr, "no unknown chunk support available"); - - png_crc_finish(png_ptr, length); - } -# endif - -# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - /* Now store the chunk in the chunk list if appropriate, and if the limits - * permit it. - */ - if (keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_IF_SAFE && - PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) - { -# ifdef PNG_USER_LIMITS_SUPPORTED - switch (png_ptr->user_chunk_cache_max) - { - case 2: - png_ptr->user_chunk_cache_max = 1; - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - /* FALL THROUGH */ - case 1: - /* NOTE: prior to 1.6.0 this case resulted in an unknown critical - * chunk being skipped, now there will be a hard error below. - */ - break; - - default: /* not at limit */ - --(png_ptr->user_chunk_cache_max); - /* FALL THROUGH */ - case 0: /* no limit */ -# endif /* PNG_USER_LIMITS_SUPPORTED */ - /* Here when the limit isn't reached or when limits are compiled - * out; store the chunk. - */ - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - handled = 1; -# ifdef PNG_USER_LIMITS_SUPPORTED - break; - } -# endif - } -# else /* no store support! */ - PNG_UNUSED(info_ptr) -# error untested code (reading unknown chunks with no store support) -# endif - - /* Regardless of the error handling below the cached data (if any) can be - * freed now. Notice that the data is not freed if there is a png_error, but - * it will be freed by destroy_read_struct. - */ - if (png_ptr->unknown_chunk.data != NULL) - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - -#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ - /* There is no support to read an unknown chunk, so just skip it. */ - png_crc_finish(png_ptr, length); - PNG_UNUSED(info_ptr) - PNG_UNUSED(keep) -#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ - - /* Check for unhandled critical chunks */ - if (!handled && PNG_CHUNK_CRITICAL(png_ptr->chunk_name)) - png_chunk_error(png_ptr, "unhandled critical chunk"); +#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ + return; +#endif } /* This function is called to verify that a chunk name is valid. - * This function can't have the "critical chunk check" incorporated - * into it, since in the future we will need to be able to call user - * functions to handle unknown critical chunks after we check that - * the chunk name itself is valid. - */ + This function can't have the "critical chunk check" incorporated + into it, since in the future we will need to be able to call user + functions to handle unknown critical chunks after we check that + the chunk name itself is valid. */ -/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is: - * - * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) - */ +#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) void /* PRIVATE */ -png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name) +png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) { - int i; - - png_debug(1, "in png_check_chunk_name"); - - for (i=1; i<=4; ++i) + png_debug(1, "in png_check_chunk_name\n"); + if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || + isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) { - int c = chunk_name & 0xff; - - if (c < 65 || c > 122 || (c > 90 && c < 97)) - png_chunk_error(png_ptr, "invalid chunk type"); - - chunk_name >>= 8; + png_chunk_error(png_ptr, "invalid chunk type"); } } -/* Combines the row recently read in with the existing pixels in the row. This - * routine takes care of alpha and transparency if requested. This routine also - * handles the two methods of progressive display of interlaced images, - * depending on the 'display' value; if 'display' is true then the whole row - * (dp) is filled from the start by replicating the available pixels. If - * 'display' is false only those pixels present in the pass are filled in. - */ +/* Combines the row recently read in with the existing pixels in the + row. This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined, + a zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ +#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW void /* PRIVATE */ -png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) +png_combine_row(png_structp png_ptr, png_bytep row, int mask) { - unsigned int pixel_depth = png_ptr->transformed_pixel_depth; - png_const_bytep sp = png_ptr->row_buf + 1; - png_uint_32 row_width = png_ptr->width; - unsigned int pass = png_ptr->pass; - png_bytep end_ptr = 0; - png_byte end_byte = 0; - unsigned int end_mask; - - png_debug(1, "in png_combine_row"); - - /* Added in 1.5.6: it should not be possible to enter this routine until at - * least one row has been read from the PNG data and transformed. - */ - if (pixel_depth == 0) - png_error(png_ptr, "internal row logic error"); - - /* Added in 1.5.4: the pixel depth should match the information returned by - * any call to png_read_update_info at this point. Do not continue if we got - * this wrong. - */ - if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes != - PNG_ROWBYTES(pixel_depth, row_width)) - png_error(png_ptr, "internal row size calculation error"); - - /* Don't expect this to ever happen: */ - if (row_width == 0) - png_error(png_ptr, "internal row width error"); - - /* Preserve the last byte in cases where only part of it will be overwritten, - * the multiply below may overflow, we don't care because ANSI-C guarantees - * we get the low bits. - */ - end_mask = (pixel_depth * row_width) & 7; - if (end_mask != 0) + png_debug(1,"in png_combine_row\n"); + if (mask == 0xff) { - /* end_ptr == NULL is a flag to say do nothing */ - end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1; - end_byte = *end_ptr; -# ifdef PNG_READ_PACKSWAP_SUPPORTED - if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */ - end_mask = 0xff << end_mask; - - else /* big-endian byte */ -# endif - end_mask = 0xff >> end_mask; - /* end_mask is now the bits to *keep* from the destination row */ - } - - /* For non-interlaced images this reduces to a memcpy(). A memcpy() - * will also happen if interlacing isn't supported or if the application - * does not call png_set_interlace_handling(). In the latter cases the - * caller just gets a sequence of the unexpanded rows from each interlace - * pass. - */ -#ifdef PNG_READ_INTERLACING_SUPPORTED - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) && - pass < 6 && (display == 0 || - /* The following copies everything for 'display' on passes 0, 2 and 4. */ - (display == 1 && (pass & 1) != 0))) - { - /* Narrow images may have no bits in a pass; the caller should handle - * this, but this test is cheap: - */ - if (row_width <= PNG_PASS_START_COL(pass)) - return; - - if (pixel_depth < 8) - { - /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit - * into 32 bits, then a single loop over the bytes using the four byte - * values in the 32-bit mask can be used. For the 'display' option the - * expanded mask may also not require any masking within a byte. To - * make this work the PACKSWAP option must be taken into account - it - * simply requires the pixels to be reversed in each byte. - * - * The 'regular' case requires a mask for each of the first 6 passes, - * the 'display' case does a copy for the even passes in the range - * 0..6. This has already been handled in the test above. - * - * The masks are arranged as four bytes with the first byte to use in - * the lowest bits (little-endian) regardless of the order (PACKSWAP or - * not) of the pixels in each byte. - * - * NOTE: the whole of this logic depends on the caller of this function - * only calling it on rows appropriate to the pass. This function only - * understands the 'x' logic; the 'y' logic is handled by the caller. - * - * The following defines allow generation of compile time constant bit - * masks for each pixel depth and each possibility of swapped or not - * swapped bytes. Pass 'p' is in the range 0..6; 'x', a pixel index, - * is in the range 0..7; and the result is 1 if the pixel is to be - * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B' - * for the block method. - * - * With some compilers a compile time expression of the general form: - * - * (shift >= 32) ? (a >> (shift-32)) : (b >> shift) - * - * Produces warnings with values of 'shift' in the range 33 to 63 - * because the right hand side of the ?: expression is evaluated by - * the compiler even though it isn't used. Microsoft Visual C (various - * versions) and the Intel C compiler are known to do this. To avoid - * this the following macros are used in 1.5.6. This is a temporary - * solution to avoid destabilizing the code during the release process. - */ -# if PNG_USE_COMPILE_TIME_MASKS -# define PNG_LSR(x,s) ((x)>>((s) & 0x1f)) -# define PNG_LSL(x,s) ((x)<<((s) & 0x1f)) -# else -# define PNG_LSR(x,s) ((x)>>(s)) -# define PNG_LSL(x,s) ((x)<<(s)) -# endif -# define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\ - PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1) -# define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\ - PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1) - - /* Return a mask for pass 'p' pixel 'x' at depth 'd'. The mask is - * little endian - the first pixel is at bit 0 - however the extra - * parameter 's' can be set to cause the mask position to be swapped - * within each byte, to match the PNG format. This is done by XOR of - * the shift with 7, 6 or 4 for bit depths 1, 2 and 4. - */ -# define PIXEL_MASK(p,x,d,s) \ - (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) - - /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask. - */ -# define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) -# define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) - - /* Combine 8 of these to get the full mask. For the 1-bpp and 2-bpp - * cases the result needs replicating, for the 4-bpp case the above - * generates a full 32 bits. - */ -# define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) - -# define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\ - S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\ - S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d) - -# define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\ - B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\ - B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d) - -#if PNG_USE_COMPILE_TIME_MASKS - /* Utility macros to construct all the masks for a depth/swap - * combination. The 's' parameter says whether the format is PNG - * (big endian bytes) or not. Only the three odd-numbered passes are - * required for the display/block algorithm. - */ -# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\ - S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) } - -# define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) } - -# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2)) - - /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and - * then pass: - */ - static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = - { - /* Little-endian byte masks for PACKSWAP */ - { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, - /* Normal (big-endian byte) masks - PNG format */ - { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) } - }; - - /* display_mask has only three entries for the odd passes, so index by - * pass>>1. - */ - static PNG_CONST png_uint_32 display_mask[2][3][3] = - { - /* Little-endian byte masks for PACKSWAP */ - { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, - /* Normal (big-endian byte) masks - PNG format */ - { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) } - }; - -# define MASK(pass,depth,display,png)\ - ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\ - row_mask[png][DEPTH_INDEX(depth)][pass]) - -#else /* !PNG_USE_COMPILE_TIME_MASKS */ - /* This is the runtime alternative: it seems unlikely that this will - * ever be either smaller or faster than the compile time approach. - */ -# define MASK(pass,depth,display,png)\ - ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png)) -#endif /* !PNG_USE_COMPILE_TIME_MASKS */ - - /* Use the appropriate mask to copy the required bits. In some cases - * the byte mask will be 0 or 0xff, optimize these cases. row_width is - * the number of pixels, but the code copies bytes, so it is necessary - * to special case the end. - */ - png_uint_32 pixels_per_byte = 8 / pixel_depth; - png_uint_32 mask; - -# ifdef PNG_READ_PACKSWAP_SUPPORTED - if (png_ptr->transformations & PNG_PACKSWAP) - mask = MASK(pass, pixel_depth, display, 0); - - else -# endif - mask = MASK(pass, pixel_depth, display, 1); - - for (;;) - { - png_uint_32 m; - - /* It doesn't matter in the following if png_uint_32 has more than - * 32 bits because the high bits always match those in m<<24; it is, - * however, essential to use OR here, not +, because of this. - */ - m = mask; - mask = (m >> 8) | (m << 24); /* rotate right to good compilers */ - m &= 0xff; - - if (m != 0) /* something to copy */ - { - if (m != 0xff) - *dp = (png_byte)((*dp & ~m) | (*sp & m)); - else - *dp = *sp; - } - - /* NOTE: this may overwrite the last byte with garbage if the image - * is not an exact number of bytes wide; libpng has always done - * this. - */ - if (row_width <= pixels_per_byte) - break; /* May need to restore part of the last byte */ - - row_width -= pixels_per_byte; - ++dp; - ++sp; - } - } - - else /* pixel_depth >= 8 */ - { - unsigned int bytes_to_copy, bytes_to_jump; - - /* Validate the depth - it must be a multiple of 8 */ - if (pixel_depth & 7) - png_error(png_ptr, "invalid user transform pixel depth"); - - pixel_depth >>= 3; /* now in bytes */ - row_width *= pixel_depth; - - /* Regardless of pass number the Adam 7 interlace always results in a - * fixed number of pixels to copy then to skip. There may be a - * different number of pixels to skip at the start though. - */ - { - unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth; - - row_width -= offset; - dp += offset; - sp += offset; - } - - /* Work out the bytes to copy. */ - if (display) - { - /* When doing the 'block' algorithm the pixel in the pass gets - * replicated to adjacent pixels. This is why the even (0,2,4,6) - * passes are skipped above - the entire expanded row is copied. - */ - bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth; - - /* But don't allow this number to exceed the actual row width. */ - if (bytes_to_copy > row_width) - bytes_to_copy = row_width; - } - - else /* normal row; Adam7 only ever gives us one pixel to copy. */ - bytes_to_copy = pixel_depth; - - /* In Adam7 there is a constant offset between where the pixels go. */ - bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth; - - /* And simply copy these bytes. Some optimization is possible here, - * depending on the value of 'bytes_to_copy'. Special case the low - * byte counts, which we know to be frequent. - * - * Notice that these cases all 'return' rather than 'break' - this - * avoids an unnecessary test on whether to restore the last byte - * below. - */ - switch (bytes_to_copy) - { - case 1: - for (;;) - { - *dp = *sp; - - if (row_width <= bytes_to_jump) - return; - - dp += bytes_to_jump; - sp += bytes_to_jump; - row_width -= bytes_to_jump; - } - - case 2: - /* There is a possibility of a partial copy at the end here; this - * slows the code down somewhat. - */ - do - { - dp[0] = sp[0], dp[1] = sp[1]; - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - } - while (row_width > 1); - - /* And there can only be one byte left at this point: */ - *dp = *sp; - return; - - case 3: - /* This can only be the RGB case, so each copy is exactly one - * pixel and it is not necessary to check for a partial copy. - */ - for(;;) - { - dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2]; - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - } - - default: -#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE - /* Check for double byte alignment and, if possible, use a - * 16-bit copy. Don't attempt this for narrow images - ones that - * are less than an interlace panel wide. Don't attempt it for - * wide bytes_to_copy either - use the memcpy there. - */ - if (bytes_to_copy < 16 /*else use memcpy*/ && - png_isaligned(dp, png_uint_16) && - png_isaligned(sp, png_uint_16) && - bytes_to_copy % (sizeof (png_uint_16)) == 0 && - bytes_to_jump % (sizeof (png_uint_16)) == 0) - { - /* Everything is aligned for png_uint_16 copies, but try for - * png_uint_32 first. - */ - if (png_isaligned(dp, png_uint_32) && - png_isaligned(sp, png_uint_32) && - bytes_to_copy % (sizeof (png_uint_32)) == 0 && - bytes_to_jump % (sizeof (png_uint_32)) == 0) - { - png_uint_32p dp32 = png_aligncast(png_uint_32p,dp); - png_const_uint_32p sp32 = png_aligncastconst( - png_const_uint_32p, sp); - size_t skip = (bytes_to_jump-bytes_to_copy) / - (sizeof (png_uint_32)); - - do - { - size_t c = bytes_to_copy; - do - { - *dp32++ = *sp32++; - c -= (sizeof (png_uint_32)); - } - while (c > 0); - - if (row_width <= bytes_to_jump) - return; - - dp32 += skip; - sp32 += skip; - row_width -= bytes_to_jump; - } - while (bytes_to_copy <= row_width); - - /* Get to here when the row_width truncates the final copy. - * There will be 1-3 bytes left to copy, so don't try the - * 16-bit loop below. - */ - dp = (png_bytep)dp32; - sp = (png_const_bytep)sp32; - do - *dp++ = *sp++; - while (--row_width > 0); - return; - } - - /* Else do it in 16-bit quantities, but only if the size is - * not too large. - */ - else - { - png_uint_16p dp16 = png_aligncast(png_uint_16p, dp); - png_const_uint_16p sp16 = png_aligncastconst( - png_const_uint_16p, sp); - size_t skip = (bytes_to_jump-bytes_to_copy) / - (sizeof (png_uint_16)); - - do - { - size_t c = bytes_to_copy; - do - { - *dp16++ = *sp16++; - c -= (sizeof (png_uint_16)); - } - while (c > 0); - - if (row_width <= bytes_to_jump) - return; - - dp16 += skip; - sp16 += skip; - row_width -= bytes_to_jump; - } - while (bytes_to_copy <= row_width); - - /* End of row - 1 byte left, bytes_to_copy > row_width: */ - dp = (png_bytep)dp16; - sp = (png_const_bytep)sp16; - do - *dp++ = *sp++; - while (--row_width > 0); - return; - } - } -#endif /* PNG_ALIGN_ code */ - - /* The true default - use a memcpy: */ - for (;;) - { - memcpy(dp, sp, bytes_to_copy); - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - if (bytes_to_copy > row_width) - bytes_to_copy = row_width; - } - } - - /* NOT REACHED*/ - } /* pixel_depth >= 8 */ - - /* Here if pixel_depth < 8 to check 'end_ptr' below. */ + png_memcpy(row, png_ptr->row_buf + 1, + PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); } else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_inc, s_start, s_end; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else #endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } - /* If here then the switch above wasn't used so just memcpy the whole row - * from the temporary row buffer (notice that this overwrites the end of the - * destination row if it is a partial byte.) - */ - memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width)); + shift = s_start; - /* Restore the overwritten bits from the last byte if necessary. */ - if (end_ptr != NULL) - *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask)); + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x01; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 2: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x03; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 4: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + default: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + png_byte m = 0x80; + + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + png_memcpy(dp, sp, pixel_bytes); + } + + sp += pixel_bytes; + dp += pixel_bytes; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + } + } } +#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */ #ifdef PNG_READ_INTERLACING_SUPPORTED +#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ +/* OLD pre-1.0.9 interface: +void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations) + */ void /* PRIVATE */ -png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations /* Because these may affect the byte layout */) +png_do_read_interlace(png_structp png_ptr) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Offset to next interlace block */ - static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; + png_uint_32 transformations = png_ptr->transformations; +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif - png_debug(1, "in png_do_read_interlace"); + png_debug(1,"in png_do_read_interlace (stock C version)\n"); if (row != NULL && row_info != NULL) { png_uint_32 final_width; @@ -3494,7 +2490,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 i; int j; -#ifdef PNG_READ_PACKSWAP_SUPPORTED +#if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)((row_info->width + 7) & 0x07); @@ -3503,7 +2499,6 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, s_end = 0; s_inc = -1; } - else #endif { @@ -3519,32 +2514,26 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, v = (png_byte)((*sp >> sshift) & 0x01); for (j = 0; j < jstop; j++) { - unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); - tmp |= v << dshift; - *dp = (png_byte)(tmp & 0xff); - + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } - else dshift += s_inc; } - if (sshift == s_end) { sshift = s_start; sp--; } - else sshift += s_inc; } break; } - case 2: { png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); @@ -3554,7 +2543,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, int jstop = png_pass_inc[pass]; png_uint_32 i; -#ifdef PNG_READ_PACKSWAP_SUPPORTED +#if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 3) & 0x03) << 1); @@ -3563,7 +2552,6 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, s_end = 0; s_inc = -2; } - else #endif { @@ -3582,32 +2570,26 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, v = (png_byte)((*sp >> sshift) & 0x03); for (j = 0; j < jstop; j++) { - unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); - tmp |= v << dshift; - *dp = (png_byte)(tmp & 0xff); - + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } - else dshift += s_inc; } - if (sshift == s_end) { sshift = s_start; sp--; } - else sshift += s_inc; } break; } - case 4: { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); @@ -3617,7 +2599,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 i; int jstop = png_pass_inc[pass]; -#ifdef PNG_READ_PACKSWAP_SUPPORTED +#if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 1) & 0x01) << 2); @@ -3626,7 +2608,6 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, s_end = 0; s_inc = -4; } - else #endif { @@ -3639,44 +2620,35 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (i = 0; i < row_info->width; i++) { - png_byte v = (png_byte)((*sp >> sshift) & 0x0f); + png_byte v = (png_byte)((*sp >> sshift) & 0xf); int j; for (j = 0; j < jstop; j++) { - unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); - tmp |= v << dshift; - *dp = (png_byte)(tmp & 0xff); - + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } - else dshift += s_inc; } - if (sshift == s_end) { sshift = s_start; sp--; } - else sshift += s_inc; } break; } - default: { png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - - png_bytep sp = row + (png_size_t)(row_info->width - 1) - * pixel_bytes; - + png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; int jstop = png_pass_inc[pass]; @@ -3687,572 +2659,354 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_byte v[8]; int j; - memcpy(v, sp, pixel_bytes); - + png_memcpy(v, sp, pixel_bytes); for (j = 0; j < jstop; j++) { - memcpy(dp, v, pixel_bytes); + png_memcpy(dp, v, pixel_bytes); dp -= pixel_bytes; } - sp -= pixel_bytes; } break; } } - row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); } -#ifndef PNG_READ_PACKSWAP_SUPPORTED - PNG_UNUSED(transformations) /* Silence compiler warning */ +#if !defined(PNG_READ_PACKSWAP_SUPPORTED) + if (&transformations == NULL) /* silence compiler warning */ + return; #endif } +#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ #endif /* PNG_READ_INTERLACING_SUPPORTED */ -static void -png_read_filter_row_sub(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - png_size_t i; - png_size_t istop = row_info->rowbytes; - unsigned int bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - - PNG_UNUSED(prev_row) - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); - rp++; - } -} - -static void -png_read_filter_row_up(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - png_size_t i; - png_size_t istop = row_info->rowbytes; - png_bytep rp = row; - png_const_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } -} - -static void -png_read_filter_row_avg(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - png_size_t i; - png_bytep rp = row; - png_const_bytep pp = prev_row; - unsigned int bpp = (row_info->pixel_depth + 7) >> 3; - png_size_t istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); - - rp++; - } -} - -static void -png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - png_bytep rp_end = row + row_info->rowbytes; - int a, c; - - /* First pixel/byte */ - c = *prev_row++; - a = *row + c; - *row++ = (png_byte)a; - - /* Remainder */ - while (row < rp_end) - { - int b, pa, pb, pc, p; - - a &= 0xff; /* From previous iteration or start */ - b = *prev_row++; - - p = b - c; - pc = a - c; - -# ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -# else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -# endif - - /* Find the best predictor, the least of pa, pb, pc favoring the earlier - * ones in the case of a tie. - */ - if (pb < pa) pa = pb, a = b; - if (pc < pa) a = c; - - /* Calculate the current pixel in a, and move the previous row pixel to c - * for the next time round the loop - */ - c = b; - a += *row; - *row++ = (png_byte)a; - } -} - -static void -png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - int bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp_end = row + bpp; - - /* Process the first pixel in the row completely (this is the same as 'up' - * because there is only one candidate predictor for the first row). - */ - while (row < rp_end) - { - int a = *row + *prev_row++; - *row++ = (png_byte)a; - } - - /* Remainder */ - rp_end += row_info->rowbytes - bpp; - - while (row < rp_end) - { - int a, b, c, pa, pb, pc, p; - - c = *(prev_row - bpp); - a = *(row - bpp); - b = *prev_row++; - - p = b - c; - pc = a - c; - -# ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -# else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -# endif - - if (pb < pa) pa = pb, a = b; - if (pc < pa) a = c; - - c = b; - a += *row; - *row++ = (png_byte)a; - } -} - -static void -png_init_filter_functions(png_structrp pp) - /* This function is called once for every PNG image to set the - * implementations required to reverse the filtering of PNG rows. Reversing - * the filter is the first transformation performed on the row data. It is - * performed in place, therefore an implementation can be selected based on - * the image pixel format. If the implementation depends on image width then - * take care to ensure that it works correctly if the image is interlaced - - * interlacing causes the actual row width to vary. - */ -{ - unsigned int bpp = (pp->pixel_depth + 7) >> 3; - - pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub; - pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up; - pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg; - if (bpp == 1) - pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = - png_read_filter_row_paeth_1byte_pixel; - else - pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = - png_read_filter_row_paeth_multibyte_pixel; - -#ifdef PNG_FILTER_OPTIMIZATIONS - /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to - * call to install hardware optimizations for the above functions; simply - * replace whatever elements of the pp->read_filter[] array with a hardware - * specific (or, for that matter, generic) optimization. - * - * To see an example of this examine what configure.ac does when - * --enable-arm-neon is specified on the command line. - */ - PNG_FILTER_OPTIMIZATIONS(pp, bpp); -#endif -} - +#ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW void /* PRIVATE */ -png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, - png_const_bytep prev_row, int filter) +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, + png_bytep prev_row, int filter) { - /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define - * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic - * implementations. See png_init_filter_functions above. - */ - if (pp->read_filter[0] == NULL) - png_init_filter_functions(pp); - if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) - pp->read_filter[filter-1](row_info, row, prev_row); -} - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -void /* PRIVATE */ -png_read_IDAT_data(png_structrp png_ptr, png_bytep output, - png_alloc_size_t avail_out) -{ - /* Loop reading IDATs and decompressing the result into output[avail_out] */ - png_ptr->zstream.next_out = output; - png_ptr->zstream.avail_out = 0; /* safety: set below */ - - if (output == NULL) - avail_out = 0; - - do + png_debug(1, "in png_read_filter_row\n"); + png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); + switch (filter) { - int ret; - png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; - - if (png_ptr->zstream.avail_in == 0) + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: { - uInt avail_in; - png_bytep buffer; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; - while (png_ptr->idat_size == 0) + for (i = bpp; i < istop; i++) { - png_crc_finish(png_ptr, 0); - - png_ptr->idat_size = png_read_chunk_header(png_ptr); - /* This is an error even in the 'check' case because the code just - * consumed a non-IDAT header. - */ - if (png_ptr->chunk_name != png_IDAT) - png_error(png_ptr, "Not enough image data"); + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; } - - avail_in = png_ptr->IDAT_read_size; - - if (avail_in > png_ptr->idat_size) - avail_in = (uInt)png_ptr->idat_size; - - /* A PNG with a gradually increasing IDAT size will defeat this attempt - * to minimize memory usage by causing lots of re-allocs, but - * realistically doing IDAT_read_size re-allocs is not likely to be a - * big problem. - */ - buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/); - - png_crc_read(png_ptr, buffer, avail_in); - png_ptr->idat_size -= avail_in; - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = avail_in; - } - - /* And set up the output side. */ - if (output != NULL) /* standard read */ - { - uInt out = ZLIB_IO_MAX; - - if (out > avail_out) - out = (uInt)avail_out; - - avail_out -= out; - png_ptr->zstream.avail_out = out; - } - - else /* after last row, checking for end */ - { - png_ptr->zstream.next_out = tmpbuf; - png_ptr->zstream.avail_out = (sizeof tmpbuf); - } - - /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the - * process. If the LZ stream is truncated the sequential reader will - * terminally damage the stream, above, by reading the chunk header of the - * following chunk (it then exits with png_error). - * - * TODO: deal more elegantly with truncated IDAT lists. - */ - ret = inflate(&png_ptr->zstream, Z_NO_FLUSH); - - /* Take the unconsumed output back. */ - if (output != NULL) - avail_out += png_ptr->zstream.avail_out; - - else /* avail_out counts the extra bytes */ - avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out; - - png_ptr->zstream.avail_out = 0; - - if (ret == Z_STREAM_END) - { - /* Do this for safety; we won't read any more into this row. */ - png_ptr->zstream.next_out = NULL; - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - - if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) - png_chunk_benign_error(png_ptr, "Extra compressed data"); break; } - - if (ret != Z_OK) + case PNG_FILTER_VALUE_UP: { - png_zstream_error(png_ptr, ret); + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; - if (output != NULL) - png_chunk_error(png_ptr, png_ptr->zstream.msg); - - else /* checking */ + for (i = 0; i < istop; i++) { - png_chunk_benign_error(png_ptr, png_ptr->zstream.msg); - return; + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; } + break; } - } while (avail_out > 0); - - if (avail_out > 0) - { - /* The stream ended before the image; this is the same as too few IDATs so - * should be handled the same way. - */ - if (output != NULL) - png_error(png_ptr, "Not enough image data"); - - else /* the deflate stream contained extra data */ - png_chunk_benign_error(png_ptr, "Too much image data"); - } -} - -void /* PRIVATE */ -png_read_finish_IDAT(png_structrp png_ptr) -{ - /* We don't need any more data and the stream should have ended, however the - * LZ end code may actually not have been processed. In this case we must - * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk - * may still remain to be consumed. - */ - if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) - { - /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in - * the compressed stream, but the stream may be damaged too, so even after - * this call we may need to terminate the zstream ownership. - */ - png_read_IDAT_data(png_ptr, NULL, 0); - png_ptr->zstream.next_out = NULL; /* safety */ - - /* Now clear everything out for safety; the following may not have been - * done. - */ - if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + case PNG_FILTER_VALUE_AVG: { - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *lp++) / 2 ) & 0xff); + rp++; + } + break; } - } + case PNG_FILTER_VALUE_PAETH: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; - /* If the zstream has not been released do it now *and* terminate the reading - * of the final IDAT chunk. - */ - if (png_ptr->zowner == png_IDAT) - { - /* Always do this; the pointers otherwise point into the read buffer. */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } - /* Now we no longer own the zstream. */ - png_ptr->zowner = 0; + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; - /* The slightly weird semantics of the sequential IDAT reading is that we - * are always in or at the end of an IDAT chunk, so we always need to do a - * crc_finish here. If idat_size is non-zero we also need to read the - * spurious bytes at the end of the chunk now. - */ - (void)png_crc_finish(png_ptr, png_ptr->idat_size); + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + break; + } + default: + png_warning(png_ptr, "Ignoring bad adaptive filter type"); + *row=0; + break; } } +#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ void /* PRIVATE */ -png_read_finish_row(png_structrp png_ptr) +png_read_finish_row(png_structp png_ptr) { -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif /* PNG_READ_INTERLACING_SUPPORTED */ + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif - png_debug(1, "in png_read_finish_row"); + png_debug(1, "in png_read_finish_row\n"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; -#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - - /* TO DO: don't do this if prev_row isn't needed (requires - * read-ahead of the next row's filter byte. - */ - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { png_ptr->pass++; - if (png_ptr->pass >= 7) break; - png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + if (!(png_ptr->num_rows)) + continue; } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; /* libpng deinterlacing sees every row */ - - } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0); + break; + } while (png_ptr->iwidth == 0); if (png_ptr->pass < 7) return; } -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - /* Here after at the end of the last row of the last pass. */ - png_read_finish_IDAT(png_ptr); + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + char extra; + int ret; + + png_ptr->zstream.next_out = (Byte *)&extra; + png_ptr->zstream.avail_out = (uInt)1; + for(;;) + { + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; + + png_crc_finish(png_ptr, 0); + + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_warning(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression Error"); + + if (!(png_ptr->zstream.avail_out)) + { + png_warning(png_ptr, "Extra compressed data."); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + + } + png_ptr->zstream.avail_out = 0; + } + + if (png_ptr->idat_size || png_ptr->zstream.avail_in) + png_warning(png_ptr, "Extra compression data"); + + inflateReset(&png_ptr->zstream); + + png_ptr->mode |= PNG_AFTER_IDAT; } -#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ void /* PRIVATE */ -png_read_start_row(png_structrp png_ptr) +png_read_start_row(png_structp png_ptr) { -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif int max_pixel_depth; - png_size_t row_bytes; + png_uint_32 row_bytes; - png_debug(1, "in png_read_start_row"); - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED + png_debug(1, "in png_read_start_row\n"); + png_ptr->zstream.avail_in = 0; png_init_read_transformations(png_ptr); -#endif -#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - + png_pass_ystart[0]) / png_pass_yinc[0]; else png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - } + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; + + png_ptr->irowbytes = (png_size_t)row_bytes; + if((png_uint_32)png_ptr->irowbytes != row_bytes) + png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + } else -#endif /* PNG_READ_INTERLACING_SUPPORTED */ { png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = png_ptr->width; + png_ptr->irowbytes = png_ptr->rowbytes + 1; } - max_pixel_depth = png_ptr->pixel_depth; - /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of - * calculations to calculate the final pixel depth, then - * png_do_read_transforms actually does the transforms. This means that the - * code which effectively calculates this value is actually repeated in three - * separate places. They must all match. Innocent changes to the order of - * transformations can and will break libpng in a way that causes memory - * overwrites. - * - * TODO: fix this. - */ -#ifdef PNG_READ_PACK_SUPPORTED +#if defined(PNG_READ_PACK_SUPPORTED) if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) max_pixel_depth = 8; #endif -#ifdef PNG_READ_EXPAND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (png_ptr->num_trans) max_pixel_depth = 32; - else max_pixel_depth = 24; } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth < 8) max_pixel_depth = 8; - if (png_ptr->num_trans) max_pixel_depth *= 2; } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { if (png_ptr->num_trans) @@ -4264,81 +3018,56 @@ png_read_start_row(png_structrp png_ptr) } #endif -#ifdef PNG_READ_EXPAND_16_SUPPORTED - if (png_ptr->transformations & PNG_EXPAND_16) - { -# ifdef PNG_READ_EXPAND_SUPPORTED - /* In fact it is an error if it isn't supported, but checking is - * the safe way. - */ - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->bit_depth < 16) - max_pixel_depth *= 2; - } - else -# endif - png_ptr->transformations &= ~PNG_EXPAND_16; - } -#endif - -#ifdef PNG_READ_FILLER_SUPPORTED +#if defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & (PNG_FILLER)) { - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + max_pixel_depth = 32; + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth <= 8) max_pixel_depth = 16; - else max_pixel_depth = 32; } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB || - png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { if (max_pixel_depth <= 32) max_pixel_depth = 32; - else max_pixel_depth = 64; } } #endif -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) if (png_ptr->transformations & PNG_GRAY_TO_RGB) { if ( -#ifdef PNG_READ_EXPAND_SUPPORTED - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || +#if defined(PNG_READ_EXPAND_SUPPORTED) + (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || #endif -#ifdef PNG_READ_FILLER_SUPPORTED - (png_ptr->transformations & (PNG_FILLER)) || +#if defined(PNG_READ_FILLER_SUPPORTED) + (png_ptr->transformations & (PNG_FILLER)) || #endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (max_pixel_depth <= 16) max_pixel_depth = 32; - else max_pixel_depth = 64; } - else { if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 32; - - else + else max_pixel_depth = 24; - } - + } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 64; - else max_pixel_depth = 48; } @@ -4347,116 +3076,49 @@ png_read_start_row(png_structrp png_ptr) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth = png_ptr->user_transform_depth * + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + int user_pixel_depth=png_ptr->user_transform_depth* png_ptr->user_transform_channels; - - if (user_pixel_depth > max_pixel_depth) - max_pixel_depth = user_pixel_depth; - } + if(user_pixel_depth > max_pixel_depth) + max_pixel_depth=user_pixel_depth; + } #endif - /* This value is stored in png_struct and double checked in the row read - * code. - */ - png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth; - png_ptr->transformed_pixel_depth = 0; /* calculated on demand */ - - /* Align the width on the next larger 8 pixels. Mainly used - * for interlacing - */ + /* align the width on the next larger 8 pixels. Mainly used + for interlacing */ row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* Calculate the maximum bytes needed, adding a byte and a pixel - * for safety's sake - */ - row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); - + /* calculate the maximum bytes needed, adding a byte and a pixel + for safety's sake */ + row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + + 1 + ((max_pixel_depth + 7) >> 3); #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif - - if (row_bytes + 48 > png_ptr->old_big_row_buf_size) - { - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->big_prev_row); - - if (png_ptr->interlaced) - png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, - row_bytes + 48); - - else - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - - png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - -#ifdef PNG_ALIGNED_MEMORY_SUPPORTED - /* Use 16-byte aligned memory for row_buf with at least 16 bytes - * of padding before and after row_buf; treat prev_row similarly. - * NOTE: the alignment is to the start of the pixels, one beyond the start - * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this - * was incorrect; the filter byte was aligned, which had the exact - * opposite effect of that intended. - */ - { - png_bytep temp = png_ptr->big_row_buf + 32; - int extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->row_buf = temp - extra - 1/*filter byte*/; - - temp = png_ptr->big_prev_row + 32; - extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->prev_row = temp - extra - 1/*filter byte*/; - } - -#else - /* Use 31 bytes of padding before and 17 bytes after row_buf. */ - png_ptr->row_buf = png_ptr->big_row_buf + 31; - png_ptr->prev_row = png_ptr->big_prev_row + 31; + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); + png_ptr->row_buf = png_ptr->big_row_buf+32; +#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) + png_ptr->row_buf_size = row_bytes; #endif - png_ptr->old_big_row_buf_size = row_bytes + 48; - } #ifdef PNG_MAX_MALLOC_64K - if (png_ptr->rowbytes > 65535) + if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); - #endif - if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory"); + if ((png_uint_32)png_ptr->rowbytes + 1 > PNG_SIZE_MAX) + png_error(png_ptr, "Row has too many bytes to allocate in memory."); + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( + png_ptr->rowbytes + 1)); - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - png_debug1(3, "width = %u,", png_ptr->width); - png_debug1(3, "height = %u,", png_ptr->height); - png_debug1(3, "iwidth = %u,", png_ptr->iwidth); - png_debug1(3, "num_rows = %u,", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu", - (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); - - /* The sequential reader needs a buffer for IDAT, but the progressive reader - * does not, so free the read buffer now regardless; the sequential reader - * reallocates it on demand. - */ - if (png_ptr->read_buffer) - { - png_bytep buffer = png_ptr->read_buffer; - - png_ptr->read_buffer_size = 0; - png_ptr->read_buffer = NULL; - png_free(png_ptr, buffer); - } - - /* Finally claim the zstream for the inflate of the IDAT data, use the bits - * value from the stream (note that this will result in a fatal error if the - * IDAT stream has a bogus deflate header window_bits value, but this should - * not be happening any longer!) - */ - if (png_inflate_claim(png_ptr, png_IDAT, 0) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); + png_debug1(3, "width = %lu,\n", png_ptr->width); + png_debug1(3, "height = %lu,\n", png_ptr->height); + png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); + png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); png_ptr->flags |= PNG_FLAG_ROW_INIT; } -#endif /* PNG_READ_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngset.c b/Source/3rd Party/wx/src/png/pngset.c index fcb077913..b9677a12d 100644 --- a/Source/3rd Party/wx/src/png/pngset.c +++ b/Source/3rd Party/wx/src/png/pngset.c @@ -1,262 +1,360 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * The functions here are used during reads to store data from the file * into the info struct, and during writes to store application data * into the info struct for writing into the file. This abstracts the * info struct and allows us to change the structure in the future. */ -#include "pngpriv.h" +#define PNG_INTERNAL +#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#ifdef PNG_bKGD_SUPPORTED +#if defined(PNG_bKGD_SUPPORTED) void PNGAPI -png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_color_16p background) +png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) { - png_debug1(1, "in %s storage function", "bKGD"); - - if (png_ptr == NULL || info_ptr == NULL || background == NULL) + png_debug1(1, "in %s storage function\n", "bKGD"); + if (png_ptr == NULL || info_ptr == NULL) return; - info_ptr->background = *background; + png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); info_ptr->valid |= PNG_INFO_bKGD; } #endif -#ifdef PNG_cHRM_SUPPORTED -void PNGFAPI -png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_cHRM(png_structp png_ptr, png_infop info_ptr, + double white_x, double white_y, double red_x, double red_y, + double green_x, double green_y, double blue_x, double blue_y) { - png_xy xy; - - png_debug1(1, "in %s storage function", "cHRM fixed"); - + png_debug1(1, "in %s storage function\n", "cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; - xy.redx = red_x; - xy.redy = red_y; - xy.greenx = green_x; - xy.greeny = green_y; - xy.bluex = blue_x; - xy.bluey = blue_y; - xy.whitex = white_x; - xy.whitey = white_y; + if (white_x < 0.0 || white_y < 0.0 || + red_x < 0.0 || red_y < 0.0 || + green_x < 0.0 || green_y < 0.0 || + blue_x < 0.0 || blue_y < 0.0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + return; + } + if (white_x > 21474.83 || white_y > 21474.83 || + red_x > 21474.83 || red_y > 21474.83 || + green_x > 21474.83 || green_y > 21474.83 || + blue_x > 21474.83 || blue_y > 21474.83) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } - if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy, - 2/* override with app values*/)) - info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - - png_colorspace_sync_info(png_ptr, info_ptr); + info_ptr->x_white = (float)white_x; + info_ptr->y_white = (float)white_y; + info_ptr->x_red = (float)red_x; + info_ptr->y_red = (float)red_y; + info_ptr->x_green = (float)green_x; + info_ptr->y_green = (float)green_y; + info_ptr->x_blue = (float)blue_x; + info_ptr->y_blue = (float)blue_y; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); + info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); + info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); + info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); + info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); + info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); + info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); + info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); +#endif + info_ptr->valid |= PNG_INFO_cHRM; } - -void PNGFAPI -png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z) +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) { - png_XYZ XYZ; - - png_debug1(1, "in %s storage function", "cHRM XYZ fixed"); - + png_debug1(1, "in %s storage function\n", "cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; - XYZ.red_X = int_red_X; - XYZ.red_Y = int_red_Y; - XYZ.red_Z = int_red_Z; - XYZ.green_X = int_green_X; - XYZ.green_Y = int_green_Y; - XYZ.green_Z = int_green_Z; - XYZ.blue_X = int_blue_X; - XYZ.blue_Y = int_blue_Y; - XYZ.blue_Z = int_blue_Z; - - if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2)) - info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - - png_colorspace_sync_info(png_ptr, info_ptr); -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_set_cHRM_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, white_x, "cHRM White X"), - png_fixed(png_ptr, white_y, "cHRM White Y"), - png_fixed(png_ptr, red_x, "cHRM Red X"), - png_fixed(png_ptr, red_y, "cHRM Red Y"), - png_fixed(png_ptr, green_x, "cHRM Green X"), - png_fixed(png_ptr, green_y, "cHRM Green Y"), - png_fixed(png_ptr, blue_x, "cHRM Blue X"), - png_fixed(png_ptr, blue_y, "cHRM Blue Y")); -} - -void PNGAPI -png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, - double red_Y, double red_Z, double green_X, double green_Y, double green_Z, - double blue_X, double blue_Y, double blue_Z) -{ - png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, red_X, "cHRM Red X"), - png_fixed(png_ptr, red_Y, "cHRM Red Y"), - png_fixed(png_ptr, red_Z, "cHRM Red Z"), - png_fixed(png_ptr, green_X, "cHRM Red X"), - png_fixed(png_ptr, green_Y, "cHRM Red Y"), - png_fixed(png_ptr, green_Z, "cHRM Red Z"), - png_fixed(png_ptr, blue_X, "cHRM Red X"), - png_fixed(png_ptr, blue_Y, "cHRM Red Y"), - png_fixed(png_ptr, blue_Z, "cHRM Red Z")); -} -# endif /* PNG_FLOATING_POINT_SUPPORTED */ - -#endif /* PNG_cHRM_SUPPORTED */ - -#ifdef PNG_gAMA_SUPPORTED -void PNGFAPI -png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point file_gamma) -{ - png_debug1(1, "in %s storage function", "gAMA"); - - if (png_ptr == NULL || info_ptr == NULL) + if (white_x < 0 || white_y < 0 || + red_x < 0 || red_y < 0 || + green_x < 0 || green_y < 0 || + blue_x < 0 || blue_y < 0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); return; - - png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma); - png_colorspace_sync_info(png_ptr, info_ptr); + } + if (white_x > (double) PNG_UINT_31_MAX || + white_y > (double) PNG_UINT_31_MAX || + red_x > (double) PNG_UINT_31_MAX || + red_y > (double) PNG_UINT_31_MAX || + green_x > (double) PNG_UINT_31_MAX || + green_y > (double) PNG_UINT_31_MAX || + blue_x > (double) PNG_UINT_31_MAX || + blue_y > (double) PNG_UINT_31_MAX) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } + info_ptr->int_x_white = white_x; + info_ptr->int_y_white = white_y; + info_ptr->int_x_red = red_x; + info_ptr->int_y_red = red_y; + info_ptr->int_x_green = green_x; + info_ptr->int_y_green = green_y; + info_ptr->int_x_blue = blue_x; + info_ptr->int_y_blue = blue_y; +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->x_white = (float)(white_x/100000.); + info_ptr->y_white = (float)(white_y/100000.); + info_ptr->x_red = (float)( red_x/100000.); + info_ptr->y_red = (float)( red_y/100000.); + info_ptr->x_green = (float)(green_x/100000.); + info_ptr->y_green = (float)(green_y/100000.); + info_ptr->x_blue = (float)( blue_x/100000.); + info_ptr->y_blue = (float)( blue_y/100000.); +#endif + info_ptr->valid |= PNG_INFO_cHRM; } - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma) -{ - png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, - "png_set_gAMA")); -} -# endif +#endif #endif -#ifdef PNG_hIST_SUPPORTED +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_uint_16p hist) +png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +{ + double gamma; + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Check for overflow */ + if (file_gamma > 21474.83) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + gamma=21474.83; + } + else + gamma=file_gamma; + info_ptr->gamma = (float)gamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = (int)(gamma*100000.+.5); +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(gamma == 0.0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif +void PNGAPI +png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point + int_gamma) +{ + png_fixed_point gamma; + + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + gamma=PNG_UINT_31_MAX; + } + else + { + if (int_gamma < 0) + { + png_warning(png_ptr, "Setting negative gamma to zero"); + gamma=0; + } + else + gamma=int_gamma; + } +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = (float)(gamma/100000.); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = gamma; +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(gamma == 0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +void PNGAPI +png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) { int i; - png_debug1(1, "in %s storage function", "hIST"); - + png_debug1(1, "in %s storage function\n", "hIST"); if (png_ptr == NULL || info_ptr == NULL) return; - - if (info_ptr->num_palette == 0 || info_ptr->num_palette - > PNG_MAX_PALETTE_LENGTH) + if (info_ptr->num_palette == 0) { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped"); - - return; + png_warning(png_ptr, + "Palette size 0, hIST allocation skipped."); + return; } +#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); - - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in - * version 1.2.1 - */ - info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr, - PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16)))); - - if (info_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data"); - return; - } - - info_ptr->free_me |= PNG_FREE_HIST; +#endif + /* Changed from info->num_palette to 256 in version 1.2.1 */ + png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, + (png_uint_32)(256 * png_sizeof (png_uint_16))); + if (png_ptr->hist == NULL) + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data."); + return; + } for (i = 0; i < info_ptr->num_palette; i++) - info_ptr->hist[i] = hist[i]; - + png_ptr->hist[i] = hist[i]; + info_ptr->hist = png_ptr->hist; info_ptr->valid |= PNG_INFO_hIST; + +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_HIST; +#else + png_ptr->flags |= PNG_FLAG_FREE_HIST; +#endif } #endif void PNGAPI -png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) +png_set_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) { - png_debug1(1, "in %s storage function", "IHDR"); - + png_debug1(1, "in %s storage function\n", "IHDR"); if (png_ptr == NULL || info_ptr == NULL) return; + /* check for width and height valid values */ + if (width == 0 || height == 0) + png_error(png_ptr, "Image width or height is zero in IHDR"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) + png_error(png_ptr, "image size exceeds user limits in IHDR"); +#else + if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) + png_error(png_ptr, "image size exceeds user limits in IHDR"); +#endif + if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) + png_error(png_ptr, "Invalid image size in IHDR"); + if ( width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + png_warning(png_ptr, "Width is too large for libpng to process pixels"); + + /* check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth in IHDR"); + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + png_error(png_ptr, "Invalid color type in IHDR"); + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); + + if (interlace_type >= PNG_INTERLACE_LAST) + png_error(png_ptr, "Unknown interlace method in IHDR"); + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_error(png_ptr, "Unknown compression method in IHDR"); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); + if(filter_type != PNG_FILTER_TYPE_BASE) + { + if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + png_error(png_ptr, "Unknown filter method in IHDR"); + if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) + png_warning(png_ptr, "Invalid filter method in IHDR"); + } +#else + if(filter_type != PNG_FILTER_TYPE_BASE) + png_error(png_ptr, "Unknown filter method in IHDR"); +#endif + info_ptr->width = width; info_ptr->height = height; info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type = (png_byte)color_type; + info_ptr->color_type =(png_byte) color_type; info_ptr->compression_type = (png_byte)compression_type; info_ptr->filter_type = (png_byte)filter_type; info_ptr->interlace_type = (png_byte)interlace_type; - - png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, - info_ptr->compression_type, info_ptr->filter_type); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; - else info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - /* Check for potential overflow */ - if (width > - (PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */ - - 48 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = 0; + /* check for potential overflow */ + if ( width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + info_ptr->rowbytes = (png_size_t)0; else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); } -#ifdef PNG_oFFs_SUPPORTED +#if defined(PNG_oFFs_SUPPORTED) void PNGAPI -png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) +png_set_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type) { - png_debug1(1, "in %s storage function", "oFFs"); - + png_debug1(1, "in %s storage function\n", "oFFs"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -267,236 +365,139 @@ png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, } #endif -#ifdef PNG_pCAL_SUPPORTED +#if defined(PNG_pCAL_SUPPORTED) void PNGAPI -png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, - int nparams, png_const_charp units, png_charpp params) +png_set_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params) { - png_size_t length; + png_uint_32 length; int i; - png_debug1(1, "in %s storage function", "pCAL"); - - if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL - || (nparams > 0 && params == NULL)) + png_debug1(1, "in %s storage function\n", "pCAL"); + if (png_ptr == NULL || info_ptr == NULL) return; - length = strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)", - (unsigned long)length); - - /* TODO: validate format of calibration name and unit name */ - - /* Check that the type matches the specification. */ - if (type < 0 || type > 3) - png_error(png_ptr, "Invalid pCAL equation type"); - - if (nparams < 0 || nparams > 255) - png_error(png_ptr, "Invalid pCAL parameter count"); - - /* Validate params[nparams] */ - for (i=0; ipcal_purpose = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); - + length = png_strlen(purpose) + 1; + png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); + info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose"); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL purpose."); + return; + } + png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - memcpy(info_ptr->pcal_purpose, purpose, length); - - png_debug(3, "storing X0, X1, type, and nparams in info"); + png_debug(3, "storing X0, X1, type, and nparams in info\n"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; - length = strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)", - (unsigned long)length); - - info_ptr->pcal_units = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); - + length = png_strlen(units) + 1; + png_debug1(3, "allocating units for info (%lu bytes)\n", length); + info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units"); - return; - } - - memcpy(info_ptr->pcal_units, units, length); - - info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - (png_size_t)((nparams + 1) * (sizeof (png_charp))))); + { + png_warning(png_ptr, "Insufficient memory for pCAL units."); + return; + } + png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); + info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params"); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL params."); + return; + } - memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp))); + info_ptr->pcal_params[nparams] = NULL; for (i = 0; i < nparams; i++) { - length = strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, - (unsigned long)length); - + length = png_strlen(params[i]) + 1; + png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter"); - return; - } - - memcpy(info_ptr->pcal_params[i], params[i], length); + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter."); + return; + } + png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); } info_ptr->valid |= PNG_INFO_pCAL; +#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PCAL; +#endif } #endif -#ifdef PNG_sCAL_SUPPORTED +#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, - int unit, png_const_charp swidth, png_const_charp sheight) +png_set_sCAL(png_structp png_ptr, png_infop info_ptr, + int unit, double width, double height) { - png_size_t lengthw = 0, lengthh = 0; - - png_debug1(1, "in %s storage function", "sCAL"); - + png_debug1(1, "in %s storage function\n", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; - /* Double check the unit (should never get here with an invalid - * unit unless this is an API call.) - */ - if (unit != 1 && unit != 2) - png_error(png_ptr, "Invalid sCAL unit"); + info_ptr->scal_unit = (png_byte)unit; + info_ptr->scal_pixel_width = width; + info_ptr->scal_pixel_height = height; - if (swidth == NULL || (lengthw = strlen(swidth)) == 0 || - swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) - png_error(png_ptr, "Invalid sCAL width"); + info_ptr->valid |= PNG_INFO_sCAL; +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int unit, png_charp swidth, png_charp sheight) +{ + png_uint_32 length; - if (sheight == NULL || (lengthh = strlen(sheight)) == 0 || - sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) - png_error(png_ptr, "Invalid sCAL height"); + png_debug1(1, "in %s storage function\n", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; info_ptr->scal_unit = (png_byte)unit; - ++lengthw; - - png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); - - info_ptr->scal_s_width = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthw)); - + length = png_strlen(swidth) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { - png_warning(png_ptr, "Memory allocation failed while processing sCAL"); - return; + png_warning(png_ptr, "Memory allocation failed while processing sCAL."); } + png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - memcpy(info_ptr->scal_s_width, swidth, lengthw); - - ++lengthh; - - png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); - - info_ptr->scal_s_height = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthh)); - + length = png_strlen(sheight) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_height == NULL) { png_free (png_ptr, info_ptr->scal_s_width); - info_ptr->scal_s_width = NULL; - - png_warning(png_ptr, "Memory allocation failed while processing sCAL"); - return; + png_warning(png_ptr, "Memory allocation failed while processing sCAL."); } - - memcpy(info_ptr->scal_s_height, sheight, lengthh); + png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); info_ptr->valid |= PNG_INFO_sCAL; +#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SCAL; +#endif } - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, - double width, double height) -{ - png_debug1(1, "in %s storage function", "sCAL"); - - /* Check the arguments. */ - if (width <= 0) - png_warning(png_ptr, "Invalid sCAL width ignored"); - - else if (height <= 0) - png_warning(png_ptr, "Invalid sCAL height ignored"); - - else - { - /* Convert 'width' and 'height' to ASCII. */ - char swidth[PNG_sCAL_MAX_DIGITS+1]; - char sheight[PNG_sCAL_MAX_DIGITS+1]; - - png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, - PNG_sCAL_PRECISION); - png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, - PNG_sCAL_PRECISION); - - png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); - } -} -# endif - -# ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit, - png_fixed_point width, png_fixed_point height) -{ - png_debug1(1, "in %s storage function", "sCAL"); - - /* Check the arguments. */ - if (width <= 0) - png_warning(png_ptr, "Invalid sCAL width ignored"); - - else if (height <= 0) - png_warning(png_ptr, "Invalid sCAL height ignored"); - - else - { - /* Convert 'width' and 'height' to ASCII. */ - char swidth[PNG_sCAL_MAX_DIGITS+1]; - char sheight[PNG_sCAL_MAX_DIGITS+1]; - - png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width); - png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height); - - png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); - } -} -# endif +#endif +#endif #endif -#ifdef PNG_pHYs_SUPPORTED +#if defined(PNG_pHYs_SUPPORTED) void PNGAPI -png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) +png_set_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type) { - png_debug1(1, "in %s storage function", "pHYs"); - + png_debug1(1, "in %s storage function\n", "pHYs"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -508,1099 +509,711 @@ png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, #endif void PNGAPI -png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, - png_const_colorp palette, int num_palette) +png_set_PLTE(png_structp png_ptr, png_infop info_ptr, + png_colorp palette, int num_palette) { - png_debug1(1, "in %s storage function", "PLTE"); - + png_debug1(1, "in %s storage function\n", "PLTE"); if (png_ptr == NULL || info_ptr == NULL) return; - if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Invalid palette length"); - - else - { - png_warning(png_ptr, "Invalid palette length"); - return; - } - } - - if ((num_palette > 0 && palette == NULL) || - (num_palette == 0 -# ifdef PNG_MNG_FEATURES_SUPPORTED - && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 -# endif - )) - { - png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR); - return; - } - - /* It may not actually be necessary to set png_ptr->palette here; + /* + * It may not actually be necessary to set png_ptr->palette here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. - * - * 1.6.0: the above statement appears to be incorrect; something has to set - * the palette inside png_struct on read. */ +#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); +#endif - /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - * of num_palette entries, in case of an invalid PNG file that has - * too-large sample values. - */ - png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); - - if (num_palette > 0) - memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); + /* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries, + in case of an invalid PNG file that has too-large sample values. */ + png_ptr->palette = (png_colorp)png_malloc(png_ptr, + 256 * png_sizeof(png_color)); + png_memset(png_ptr->palette, 0, 256 * png_sizeof(png_color)); + png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; +#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PLTE; +#else + png_ptr->flags |= PNG_FLAG_FREE_PLTE; +#endif info_ptr->valid |= PNG_INFO_PLTE; } -#ifdef PNG_sBIT_SUPPORTED +#if defined(PNG_sBIT_SUPPORTED) void PNGAPI -png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_color_8p sig_bit) +png_set_sBIT(png_structp png_ptr, png_infop info_ptr, + png_color_8p sig_bit) { - png_debug1(1, "in %s storage function", "sBIT"); - - if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL) + png_debug1(1, "in %s storage function\n", "sBIT"); + if (png_ptr == NULL || info_ptr == NULL) return; - info_ptr->sig_bit = *sig_bit; + png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); info_ptr->valid |= PNG_INFO_sBIT; } #endif -#ifdef PNG_sRGB_SUPPORTED +#if defined(PNG_sRGB_SUPPORTED) void PNGAPI -png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) +png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) { - png_debug1(1, "in %s storage function", "sRGB"); - + png_debug1(1, "in %s storage function\n", "sRGB"); if (png_ptr == NULL || info_ptr == NULL) return; - (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent); - png_colorspace_sync_info(png_ptr, info_ptr); + info_ptr->srgb_intent = (png_byte)intent; + info_ptr->valid |= PNG_INFO_sRGB; } void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, - int srgb_intent) +png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, + int intent) { - png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); - +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_file_gamma; +#endif +#endif +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y; +#endif +#endif + png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; - if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent)) - { - /* This causes the gAMA and cHRM to be written too */ - info_ptr->colorspace.flags |= - PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; - } + png_set_sRGB(png_ptr, info_ptr, intent); - png_colorspace_sync_info(png_ptr, info_ptr); +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float).45455; + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + int_file_gamma = 45455L; + png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FIXED_POINT_SUPPORTED + int_white_x = 31270L; + int_white_y = 32900L; + int_red_x = 64000L; + int_red_y = 33000L; + int_green_x = 30000L; + int_green_y = 60000L; + int_blue_x = 15000L; + int_blue_y = 6000L; + + png_set_cHRM_fixed(png_ptr, info_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, + int_blue_x, int_blue_y); +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float).3127; + white_y = (float).3290; + red_x = (float).64; + red_y = (float).33; + green_x = (float).30; + green_y = (float).60; + blue_x = (float).15; + blue_y = (float).06; + + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#endif } -#endif /* sRGB */ +#endif -#ifdef PNG_iCCP_SUPPORTED +#if defined(PNG_iCCP_SUPPORTED) void PNGAPI -png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_charp name, int compression_type, - png_const_bytep profile, png_uint_32 proflen) +png_set_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen) { png_charp new_iccp_name; - png_bytep new_iccp_profile; - png_size_t length; - - png_debug1(1, "in %s storage function", "iCCP"); + png_charp new_iccp_profile; + png_debug1(1, "in %s storage function\n", "iCCP"); if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_app_error(png_ptr, "Invalid iCCP compression method"); - - /* Set the colorspace first because this validates the profile; do not - * override previously set app cHRM or gAMA here (because likely as not the - * application knows better than libpng what the correct values are.) Pass - * the info_ptr color_type field to png_colorspace_set_ICC because in the - * write case it has not yet been stored in png_ptr. - */ - { - int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, - proflen, profile, info_ptr->color_type); - - png_colorspace_sync_info(png_ptr, info_ptr); - - /* Don't do any of the copying if the profile was bad, or inconsistent. */ - if (!result) - return; - - /* But do write the gAMA and cHRM chunks from the profile. */ - info_ptr->colorspace.flags |= - PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; - } - - length = strlen(name)+1; - new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); - + new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); if (new_iccp_name == NULL) { - png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk"); + png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); return; } - - memcpy(new_iccp_name, name, length); - new_iccp_profile = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, proflen)); - + png_strcpy(new_iccp_name, name); + new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); if (new_iccp_profile == NULL) { - png_free(png_ptr, new_iccp_name); - png_benign_error(png_ptr, - "Insufficient memory to process iCCP profile"); + png_free (png_ptr, new_iccp_name); + png_warning(png_ptr, "Insufficient memory to process iCCP profile."); return; } - - memcpy(new_iccp_profile, profile, proflen); + png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); info_ptr->iccp_proflen = proflen; info_ptr->iccp_name = new_iccp_name; info_ptr->iccp_profile = new_iccp_profile; + /* Compression is always zero but is here so the API and info structure + * does not have to change if we introduce multiple compression types */ + info_ptr->iccp_compression = (png_byte)compression_type; +#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ICCP; +#endif info_ptr->valid |= PNG_INFO_iCCP; } #endif -#ifdef PNG_TEXT_SUPPORTED +#if defined(PNG_TEXT_SUPPORTED) void PNGAPI -png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_textp text_ptr, int num_text) +png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) { int ret; - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); if (ret) - png_error(png_ptr, "Insufficient memory to store text"); + png_error(png_ptr, "Insufficient memory to store text"); } int /* PRIVATE */ -png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_textp text_ptr, int num_text) +png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) { int i; - png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" : - (unsigned long)png_ptr->chunk_name); + png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? + "text" : (png_const_charp)png_ptr->chunk_name)); - if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL) + if (png_ptr == NULL || info_ptr == NULL || num_text == 0) return(0); /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. This compare can't overflow - * because max_text >= num_text (anyway, subtract of two positive integers - * can't overflow in any case.) + * to hold all of the incoming text_ptr objects. */ - if (num_text > info_ptr->max_text - info_ptr->num_text) + if (info_ptr->num_text + num_text > info_ptr->max_text) { - int old_num_text = info_ptr->num_text; - int max_text; - png_textp new_text = NULL; - - /* Calculate an appropriate max_text, checking for overflow. */ - max_text = old_num_text; - if (num_text <= INT_MAX - max_text) + if (info_ptr->text != NULL) { - max_text += num_text; + png_textp old_text; + int old_max; - /* Round up to a multiple of 8 */ - if (max_text < INT_MAX-8) - max_text = (max_text + 8) & ~0x7; - - else - max_text = INT_MAX; - - /* Now allocate a new array and copy the old members in, this does all - * the overflow checks. - */ - new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, - info_ptr->text, old_num_text, max_text-old_num_text, - sizeof *new_text)); + old_max = info_ptr->max_text; + info_ptr->max_text = info_ptr->num_text + num_text + 8; + old_text = info_ptr->text; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + if (info_ptr->text == NULL) + { + png_free(png_ptr, old_text); + return(1); + } + png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * + png_sizeof(png_text))); + png_free(png_ptr, old_text); } - - if (new_text == NULL) + else { - png_chunk_report(png_ptr, "too many text chunks", - PNG_CHUNK_WRITE_ERROR); - return 1; + info_ptr->max_text = num_text + 8; + info_ptr->num_text = 0; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + if (info_ptr->text == NULL) + return(1); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TEXT; +#endif } - - png_free(png_ptr, info_ptr->text); - - info_ptr->text = new_text; - info_ptr->free_me |= PNG_FREE_TEXT; - info_ptr->max_text = max_text; - /* num_text is adjusted below as the entries are copied in */ - - png_debug1(3, "allocated %d entries for info_ptr->text", max_text); + png_debug1(3, "allocated %d entries for info_ptr->text\n", + info_ptr->max_text); } - for (i = 0; i < num_text; i++) { - size_t text_length, key_len; - size_t lang_len, lang_key_len; + png_size_t text_length,key_len; + png_size_t lang_len,lang_key_len; png_textp textp = &(info_ptr->text[info_ptr->num_text]); if (text_ptr[i].key == NULL) continue; - if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE || - text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) + key_len = png_strlen(text_ptr[i].key); + + if(text_ptr[i].compression <= 0) { - png_chunk_report(png_ptr, "text compression mode is out of range", - PNG_CHUNK_WRITE_ERROR); - continue; + lang_len = 0; + lang_key_len = 0; } - - key_len = strlen(text_ptr[i].key); - - if (text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -# ifdef PNG_iTXt_SUPPORTED +#ifdef PNG_iTXt_SUPPORTED { - /* Set iTXt data */ - - if (text_ptr[i].lang != NULL) - lang_len = strlen(text_ptr[i].lang); - - else - lang_len = 0; - - if (text_ptr[i].lang_key != NULL) - lang_key_len = strlen(text_ptr[i].lang_key); - - else - lang_key_len = 0; + /* set iTXt data */ + if (text_ptr[i].lang != NULL) + lang_len = png_strlen(text_ptr[i].lang); + else + lang_len = 0; + if (text_ptr[i].lang_key != NULL) + lang_key_len = png_strlen(text_ptr[i].lang_key); + else + lang_key_len = 0; } -# else /* PNG_iTXt_SUPPORTED */ +#else { - png_chunk_report(png_ptr, "iTXt chunk not supported", - PNG_CHUNK_WRITE_ERROR); - continue; + png_warning(png_ptr, "iTXt chunk not supported."); + continue; } -# endif +#endif if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') { text_length = 0; -# ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) +#ifdef PNG_iTXt_SUPPORTED + if(text_ptr[i].compression > 0) textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -# endif +#endif textp->compression = PNG_TEXT_COMPRESSION_NONE; } - else { - text_length = strlen(text_ptr[i].text); + text_length = png_strlen(text_ptr[i].text); textp->compression = text_ptr[i].compression; } - textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr, - key_len + text_length + lang_len + lang_key_len + 4)); - + textp->key = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) - { - png_chunk_report(png_ptr, "text chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); - return 1; - } - - png_debug2(2, "Allocated %lu bytes at %p in png_set_text", - (unsigned long)(png_uint_32) - (key_len + lang_len + lang_key_len + text_length + 4), - textp->key); - - memcpy(textp->key, text_ptr[i].key, key_len); - *(textp->key + key_len) = '\0'; + return(1); + png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", + (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), + (int)textp->key); + png_memcpy(textp->key, text_ptr[i].key, + (png_size_t)(key_len)); + *(textp->key+key_len) = '\0'; +#ifdef PNG_iTXt_SUPPORTED if (text_ptr[i].compression > 0) { - textp->lang = textp->key + key_len + 1; - memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang + lang_len) = '\0'; - textp->lang_key = textp->lang + lang_len + 1; - memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key + lang_key_len) = '\0'; - textp->text = textp->lang_key + lang_key_len + 1; + textp->lang=textp->key + key_len + 1; + png_memcpy(textp->lang, text_ptr[i].lang, lang_len); + *(textp->lang+lang_len) = '\0'; + textp->lang_key=textp->lang + lang_len + 1; + png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); + *(textp->lang_key+lang_key_len) = '\0'; + textp->text=textp->lang_key + lang_key_len + 1; } - else +#endif { +#ifdef PNG_iTXt_SUPPORTED textp->lang=NULL; textp->lang_key=NULL; - textp->text = textp->key + key_len + 1; +#endif + textp->text=textp->key + key_len + 1; } + if(text_length) + png_memcpy(textp->text, text_ptr[i].text, + (png_size_t)(text_length)); + *(textp->text+text_length) = '\0'; - if (text_length) - memcpy(textp->text, text_ptr[i].text, text_length); - - *(textp->text + text_length) = '\0'; - -# ifdef PNG_iTXt_SUPPORTED - if (textp->compression > 0) +#ifdef PNG_iTXt_SUPPORTED + if(textp->compression > 0) { textp->text_length = 0; textp->itxt_length = text_length; } - else -# endif +#endif { textp->text_length = text_length; +#ifdef PNG_iTXt_SUPPORTED textp->itxt_length = 0; +#endif } - + info_ptr->text[info_ptr->num_text]= *textp; info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d", info_ptr->num_text); + png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); } - return(0); } #endif -#ifdef PNG_tIME_SUPPORTED +#if defined(PNG_tIME_SUPPORTED) void PNGAPI -png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_timep mod_time) +png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) { - png_debug1(1, "in %s storage function", "tIME"); - - if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL || + png_debug1(1, "in %s storage function\n", "tIME"); + if (png_ptr == NULL || info_ptr == NULL || (png_ptr->mode & PNG_WROTE_tIME)) return; - if (mod_time->month == 0 || mod_time->month > 12 || - mod_time->day == 0 || mod_time->day > 31 || - mod_time->hour > 23 || mod_time->minute > 59 || - mod_time->second > 60) - { - png_warning(png_ptr, "Ignoring invalid time value"); - return; - } - - info_ptr->mod_time = *mod_time; + png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); info_ptr->valid |= PNG_INFO_tIME; } #endif -#ifdef PNG_tRNS_SUPPORTED +#if defined(PNG_tRNS_SUPPORTED) void PNGAPI -png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, - png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) +png_set_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep trans, int num_trans, png_color_16p trans_values) { - png_debug1(1, "in %s storage function", "tRNS"); - + png_debug1(1, "in %s storage function\n", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) return; - if (trans_alpha != NULL) + if (trans != NULL) { - /* It may not actually be necessary to set png_ptr->trans_alpha here; + /* + * It may not actually be necessary to set png_ptr->trans here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. - * - * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively - * relies on png_set_tRNS storing the information in png_struct - * (otherwise it won't be there for the code in pngrtran.c). */ - +#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); - - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, - png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); - - if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) - memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); +#endif + /* Changed from num_trans to 256 in version 1.2.1 */ + png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TRNS; +#else + png_ptr->flags |= PNG_FLAG_FREE_TRNS; +#endif } - if (trans_color != NULL) + if (trans_values != NULL) { - int sample_max = (1 << info_ptr->bit_depth); - - if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - trans_color->gray > sample_max) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - (trans_color->red > sample_max || - trans_color->green > sample_max || - trans_color->blue > sample_max))) - png_warning(png_ptr, - "tRNS chunk has out-of-range samples for bit_depth"); - - info_ptr->trans_color = *trans_color; - + png_memcpy(&(info_ptr->trans_values), trans_values, + png_sizeof(png_color_16)); if (num_trans == 0) - num_trans = 1; + num_trans = 1; } - info_ptr->num_trans = (png_uint_16)num_trans; - - if (num_trans != 0) - { - info_ptr->valid |= PNG_INFO_tRNS; - info_ptr->free_me |= PNG_FREE_TRNS; - } + info_ptr->valid |= PNG_INFO_tRNS; } #endif -#ifdef PNG_sPLT_SUPPORTED +#if defined(PNG_sPLT_SUPPORTED) void PNGAPI -png_set_sPLT(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_sPLT_tp entries, int nentries) -/* - * entries - array of png_sPLT_t structures - * to be added to the list of palettes - * in the info structure. - * - * nentries - number of palette structures to be - * added. - */ +png_set_sPLT(png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries) { - png_sPLT_tp np; + png_sPLT_tp np; + int i; - if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL) + np = (png_sPLT_tp)png_malloc_warn(png_ptr, + (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); + if (np == NULL) + { + png_warning(png_ptr, "No memory for sPLT palettes."); return; + } - /* Use the internal realloc function, which checks for all the possible - * overflows. Notice that the parameters are (int) and (size_t) - */ - np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, - info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, - sizeof *np)); + png_memcpy(np, info_ptr->splt_palettes, + info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes=NULL; - if (np == NULL) - { - /* Out of memory or too many chunks */ - png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR); - return; - } + for (i = 0; i < nentries; i++) + { + png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; + png_sPLT_tp from = entries + i; - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = np; - info_ptr->free_me |= PNG_FREE_SPLT; + to->name = (png_charp)png_malloc(png_ptr, + png_strlen(from->name) + 1); + /* TODO: use png_malloc_warn */ + png_strcpy(to->name, from->name); + to->entries = (png_sPLT_entryp)png_malloc(png_ptr, + from->nentries * png_sizeof(png_sPLT_t)); + /* TODO: use png_malloc_warn */ + png_memcpy(to->entries, from->entries, + from->nentries * png_sizeof(png_sPLT_t)); + to->nentries = from->nentries; + to->depth = from->depth; + } - np += info_ptr->splt_palettes_num; - - do - { - png_size_t length; - - /* Skip invalid input entries */ - if (entries->name == NULL || entries->entries == NULL) - { - /* png_handle_sPLT doesn't do this, so this is an app error */ - png_app_error(png_ptr, "png_set_sPLT: invalid sPLT"); - /* Just skip the invalid entry */ - continue; - } - - np->depth = entries->depth; - - /* In the even of out-of-memory just return - there's no point keeping on - * trying to add sPLT chunks. - */ - length = strlen(entries->name) + 1; - np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length)); - - if (np->name == NULL) - break; - - memcpy(np->name, entries->name, length); - - /* IMPORTANT: we have memory now that won't get freed if something else - * goes wrong, this code must free it. png_malloc_array produces no - * warnings, use a png_chunk_report (below) if there is an error. - */ - np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr, - entries->nentries, sizeof (png_sPLT_entry))); - - if (np->entries == NULL) - { - png_free(png_ptr, np->name); - break; - } - - np->nentries = entries->nentries; - /* This multiply can't overflow because png_malloc_array has already - * checked it when doing the allocation. - */ - memcpy(np->entries, entries->entries, - entries->nentries * sizeof (png_sPLT_entry)); - - /* Note that 'continue' skips the advance of the out pointer and out - * count, so an invalid entry is not added. - */ - info_ptr->valid |= PNG_INFO_sPLT; - ++(info_ptr->splt_palettes_num); - ++np; - } - while (++entries, --nentries); - - if (nentries > 0) - png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR); + info_ptr->splt_palettes = np; + info_ptr->splt_palettes_num += nentries; + info_ptr->valid |= PNG_INFO_sPLT; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_SPLT; +#endif } #endif /* PNG_sPLT_SUPPORTED */ -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -static png_byte -check_location(png_const_structrp png_ptr, int location) -{ - location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT); - - /* New in 1.6.0; copy the location and check it. This is an API - * change, previously the app had to use the - * png_set_unknown_chunk_location API below for each chunk. - */ - if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT)) - { - /* Write struct, so unknown chunks come from the app */ - png_app_warning(png_ptr, - "png_set_unknown_chunks now expects a valid location"); - /* Use the old behavior */ - location = (png_byte)(png_ptr->mode & - (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); - } - - /* This need not be an internal error - if the app calls - * png_set_unknown_chunks on a read pointer it must get the location right. - */ - if (location == 0) - png_error(png_ptr, "invalid location in png_set_unknown_chunks"); - - /* Now reduce the location to the top-most set bit by removing each least - * significant bit in turn. - */ - while (location != (location & -location)) - location &= ~(location & -location); - - /* The cast is safe because 'location' is a bit mask and only the low four - * bits are significant. - */ - return (png_byte)location; -} - +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) void PNGAPI -png_set_unknown_chunks(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) +png_set_unknown_chunks(png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) { - png_unknown_chunkp np; + png_unknown_chunkp np; + int i; - if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 || - unknowns == NULL) - return; - - /* Check for the failure cases where support has been disabled at compile - * time. This code is hardly ever compiled - it's here because - * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this - * code) but may be meaningless if the read or write handling of unknown - * chunks is not compiled in. - */ -# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ - defined(PNG_READ_SUPPORTED) - if (png_ptr->mode & PNG_IS_READ_STRUCT) - { - png_app_error(png_ptr, "no unknown chunk support on read"); - return; - } -# endif -# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ - defined(PNG_WRITE_SUPPORTED) - if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) - { - png_app_error(png_ptr, "no unknown chunk support on write"); - return; - } -# endif - - /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that - * unknown critical chunks could be lost with just a warning resulting in - * undefined behavior. Now png_chunk_report is used to provide behavior - * appropriate to read or write. - */ - np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, - info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, - sizeof *np)); - - if (np == NULL) - { - png_chunk_report(png_ptr, "too many unknown chunks", - PNG_CHUNK_WRITE_ERROR); - return; - } - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = np; /* safe because it is initialized */ - info_ptr->free_me |= PNG_FREE_UNKN; - - np += info_ptr->unknown_chunks_num; - - /* Increment unknown_chunks_num each time round the loop to protect the - * just-allocated chunk data. - */ - for (; num_unknowns > 0; --num_unknowns, ++unknowns) - { - memcpy(np->name, unknowns->name, (sizeof np->name)); - np->name[(sizeof np->name)-1] = '\0'; - np->location = check_location(png_ptr, unknowns->location); - - if (unknowns->size == 0) - { - np->data = NULL; - np->size = 0; - } - - else - { - np->data = png_voidcast(png_bytep, - png_malloc_base(png_ptr, unknowns->size)); - - if (np->data == NULL) - { - png_chunk_report(png_ptr, "unknown chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); - /* But just skip storing the unknown chunk */ - continue; - } - - memcpy(np->data, unknowns->data, unknowns->size); - np->size = unknowns->size; - } - - /* These increments are skipped on out-of-memory for the data - the - * unknown chunk entry gets overwritten if the png_chunk_report returns. - * This is correct in the read case (the chunk is just dropped.) - */ - ++np; - ++(info_ptr->unknown_chunks_num); - } -} - -void PNGAPI -png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, - int chunk, int location) -{ - /* This API is pretty pointless in 1.6.0 because the location can be set - * before the call to png_set_unknown_chunks. - * - * TODO: add a png_app_warning in 1.7 - */ - if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && - chunk < info_ptr->unknown_chunks_num) - { - if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0) - { - png_app_error(png_ptr, "invalid unknown chunk location"); - /* Fake out the pre 1.6.0 behavior: */ - if ((location & PNG_HAVE_IDAT)) /* undocumented! */ - location = PNG_AFTER_IDAT; - - else - location = PNG_HAVE_IHDR; /* also undocumented */ - } - - info_ptr->unknown_chunks[chunk].location = - check_location(png_ptr, location); - } -} -#endif - - -#ifdef PNG_MNG_FEATURES_SUPPORTED -png_uint_32 PNGAPI -png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features"); - - if (png_ptr == NULL) - return 0; - - png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES; - - return png_ptr->mng_features_permitted; -} -#endif - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -static unsigned int -add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) -{ - unsigned int i; - - /* Utility function: update the 'keep' state of a chunk if it is already in - * the list, otherwise add it to the list. - */ - for (i=0; i= PNG_HANDLE_CHUNK_LAST) - { - png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep"); - return; - } - - if (num_chunks_in <= 0) - { - png_ptr->unknown_default = keep; - - /* '0' means just set the flags, so stop here */ - if (num_chunks_in == 0) + if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) return; - } - if (num_chunks_in < 0) - { - /* Ignore all unknown chunks and all chunks recognized by - * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND - */ - static PNG_CONST png_byte chunks_to_ignore[] = { - 98, 75, 71, 68, '\0', /* bKGD */ - 99, 72, 82, 77, '\0', /* cHRM */ - 103, 65, 77, 65, '\0', /* gAMA */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 67, 65, 76, '\0', /* sCAL */ - 115, 80, 76, 84, '\0', /* sPLT */ - 115, 84, 69, 82, '\0', /* sTER */ - 115, 82, 71, 66, '\0', /* sRGB */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0' /* zTXt */ - }; + np = (png_unknown_chunkp)png_malloc_warn(png_ptr, + (info_ptr->unknown_chunks_num + num_unknowns) * + png_sizeof(png_unknown_chunk)); + if (np == NULL) + { + png_warning(png_ptr, "Out of memory while processing unknown chunk."); + return; + } - chunk_list = chunks_to_ignore; - num_chunks = (sizeof chunks_to_ignore)/5; - } + png_memcpy(np, info_ptr->unknown_chunks, + info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks=NULL; - else /* num_chunks_in > 0 */ - { - if (chunk_list == NULL) - { - /* Prior to 1.6.0 this was silently ignored, now it is an app_error - * which can be switched off. - */ - png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list"); - return; - } + for (i = 0; i < num_unknowns; i++) + { + png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; + png_unknown_chunkp from = unknowns + i; - num_chunks = num_chunks_in; - } + png_strncpy((png_charp)to->name, (png_charp)from->name, 5); + to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); + if (to->data == NULL) + { + png_warning(png_ptr, "Out of memory processing unknown chunk."); + } + else + { + png_memcpy(to->data, from->data, from->size); + to->size = from->size; - old_num_chunks = png_ptr->num_chunk_list; - if (png_ptr->chunk_list == NULL) - old_num_chunks = 0; + /* note our location in the read or write sequence */ + to->location = (png_byte)(png_ptr->mode & 0xff); + } + } - /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow. - */ - if (num_chunks + old_num_chunks > UINT_MAX/5) - { - png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks"); - return; - } - - /* If these chunks are being reset to the default then no more memory is - * required because add_one_chunk above doesn't extend the list if the 'keep' - * parameter is the default. - */ - if (keep) - { - new_list = png_voidcast(png_bytep, png_malloc(png_ptr, - 5 * (num_chunks + old_num_chunks))); - - if (old_num_chunks > 0) - memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); - } - - else if (old_num_chunks > 0) - new_list = png_ptr->chunk_list; - - else - new_list = NULL; - - /* Add the new chunks together with each one's handling code. If the chunk - * already exists the code is updated, otherwise the chunk is added to the - * end. (In libpng 1.6.0 order no longer matters because this code enforces - * the earlier convention that the last setting is the one that is used.) - */ - if (new_list != NULL) - { - png_const_bytep inlist; - png_bytep outlist; - unsigned int i; - - for (i=0; ichunk_list != new_list) - png_free(png_ptr, new_list); - - new_list = NULL; - } - } - - else - num_chunks = 0; - - png_ptr->num_chunk_list = num_chunks; - - if (png_ptr->chunk_list != new_list) - { - if (png_ptr->chunk_list != NULL) - png_free(png_ptr, png_ptr->chunk_list); - - png_ptr->chunk_list = new_list; - } + info_ptr->unknown_chunks = np; + info_ptr->unknown_chunks_num += num_unknowns; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_UNKN; +#endif +} +void PNGAPI +png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, + int chunk, int location) +{ + if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < + (int)info_ptr->unknown_chunks_num) + info_ptr->unknown_chunks[chunk].location = (png_byte)location; } #endif -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) void PNGAPI -png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) +png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) { - png_debug(1, "in png_set_read_user_chunk_fn"); - + /* This function is deprecated in favor of png_permit_mng_features() + and will be removed from libpng-2.0.0 */ + png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); if (png_ptr == NULL) return; + png_ptr->mng_features_permitted = (png_byte) + ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | + ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); +} +#endif +#if defined(PNG_MNG_FEATURES_SUPPORTED) +png_uint_32 PNGAPI +png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) +{ + png_debug(1, "in png_permit_mng_features\n"); + if (png_ptr == NULL) + return (png_uint_32)0; + png_ptr->mng_features_permitted = + (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); + return (png_uint_32)png_ptr->mng_features_permitted; +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +void PNGAPI +png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep + chunk_list, int num_chunks) +{ + png_bytep new_list, p; + int i, old_num_chunks; + if (num_chunks == 0) + { + if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) + png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + + if(keep == PNG_HANDLE_CHUNK_ALWAYS) + png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; + return; + } + if (chunk_list == NULL) + return; + old_num_chunks=png_ptr->num_chunk_list; + new_list=(png_bytep)png_malloc(png_ptr, + (png_uint_32)(5*(num_chunks+old_num_chunks))); + if(png_ptr->chunk_list != NULL) + { + png_memcpy(new_list, png_ptr->chunk_list, + (png_size_t)(5*old_num_chunks)); + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + } + png_memcpy(new_list+5*old_num_chunks, chunk_list, + (png_size_t)(5*num_chunks)); + for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; + png_ptr->chunk_list=new_list; +#ifdef PNG_FREE_ME_SUPPORTED + png_ptr->free_me |= PNG_FREE_LIST; +#endif +} +#endif + +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +void PNGAPI +png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, + png_user_chunk_ptr read_user_chunk_fn) +{ + png_debug(1, "in png_set_read_user_chunk_fn\n"); png_ptr->read_user_chunk_fn = read_user_chunk_fn; png_ptr->user_chunk_ptr = user_chunk_ptr; } #endif -#ifdef PNG_INFO_IMAGE_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI -png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytepp row_pointers) +png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) { - png_debug1(1, "in %s storage function", "rows"); + png_debug1(1, "in %s storage function\n", "rows"); if (png_ptr == NULL || info_ptr == NULL) return; - if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) + if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - - if (row_pointers) + if(row_pointers) info_ptr->valid |= PNG_INFO_IDAT; } #endif +#ifdef PNG_WRITE_SUPPORTED void PNGAPI -png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) +png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) { - if (png_ptr == NULL) - return; - - if (size == 0 || size > PNG_UINT_31_MAX) - png_error(png_ptr, "invalid compression buffer size"); - -# ifdef PNG_SEQUENTIAL_READ_SUPPORTED - if (png_ptr->mode & PNG_IS_READ_STRUCT) - { - png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ - return; - } -# endif - -# ifdef PNG_WRITE_SUPPORTED - if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) - { - if (png_ptr->zowner != 0) - { - png_warning(png_ptr, - "Compression buffer size cannot be changed because it is in use"); - return; - } - - if (size > ZLIB_IO_MAX) - { - png_warning(png_ptr, - "Compression buffer size limited to system maximum"); - size = ZLIB_IO_MAX; /* must fit */ - } - - else if (size < 6) - { - /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH - * if this is permitted. - */ - png_warning(png_ptr, - "Compression buffer size cannot be reduced below 6"); - return; - } - - if (png_ptr->zbuffer_size != size) - { - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); - png_ptr->zbuffer_size = (uInt)size; - } - } -# endif + if(png_ptr->zbuf) + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf_size = (png_size_t)size; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } +#endif void PNGAPI -png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) +png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) { if (png_ptr && info_ptr) - info_ptr->valid &= ~mask; + info_ptr->valid &= ~(mask); } +#ifndef PNG_1_0_X +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 and should always exist by default */ +void PNGAPI +png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) +{ + png_uint_32 settable_asm_flags; + png_uint_32 settable_mmx_flags; + + settable_mmx_flags = +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + PNG_ASM_FLAG_MMX_READ_INTERLACE | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | +#endif + 0; + + /* could be some non-MMX ones in the future, but not currently: */ + settable_asm_flags = settable_mmx_flags; + + if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || + !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) + { + /* clear all MMX flags if MMX isn't supported */ + settable_asm_flags &= ~settable_mmx_flags; + png_ptr->asm_flags &= ~settable_mmx_flags; + } + + /* we're replacing the settable bits with those passed in by the user, + * so first zero them out of the master copy, then logical-OR in the + * allowed subset that was requested */ + + png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ + png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 */ +void PNGAPI +png_set_mmx_thresholds (png_structp png_ptr, + png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold) +{ + png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; + png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + #ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* This function was added to libpng 1.2.6 */ +/* this function was added to libpng 1.2.6 */ void PNGAPI -png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, +png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max) { - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if (png_ptr == NULL) - return; - - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; -} - -/* This function was added to libpng 1.4.0 */ -void PNGAPI -png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) -{ - if (png_ptr) - png_ptr->user_chunk_cache_max = user_chunk_cache_max; -} - -/* This function was added to libpng 1.4.1 */ -void PNGAPI -png_set_chunk_malloc_max (png_structrp png_ptr, - png_alloc_size_t user_chunk_malloc_max) -{ - if (png_ptr) - png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; + /* Images with dimensions larger than these limits will be + * rejected by png_set_IHDR(). To accept any PNG datastream + * regardless of dimensions, set both limits to 0x7ffffffL. + */ + png_ptr->user_width_max = user_width_max; + png_ptr->user_height_max = user_height_max; } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_set_benign_errors(png_structrp png_ptr, int allowed) -{ - png_debug(1, "in png_set_benign_errors"); - - /* If allowed is 1, png_benign_error() is treated as a warning. - * - * If allowed is 0, png_benign_error() is treated as an error (which - * is the default behavior if png_set_benign_errors() is not called). - */ - - if (allowed) - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN | - PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN; - - else - png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN | - PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN); -} -#endif /* PNG_BENIGN_ERRORS_SUPPORTED */ - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Whether to report invalid palette index; added at libng-1.5.10. - * It is possible for an indexed (color-type==3) PNG file to contain - * pixels with invalid (out-of-range) indexes if the PLTE chunk has - * fewer entries than the image's bit-depth would allow. We recover - * from this gracefully by filling any incomplete palette with zeroes - * (opaque black). By default, when this occurs libpng will issue - * a benign error. This API can be used to override that behavior. - */ -void PNGAPI -png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) -{ - png_debug(1, "in png_set_check_for_invalid_index"); - - if (allowed > 0) - png_ptr->num_palette_max = 0; - - else - png_ptr->num_palette_max = -1; -} -#endif -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ +#endif /* ?PNG_1_0_X */ diff --git a/Source/3rd Party/wx/src/png/pngstruct.h b/Source/3rd Party/wx/src/png/pngstruct.h deleted file mode 100644 index d58c02884..000000000 --- a/Source/3rd Party/wx/src/png/pngstruct.h +++ /dev/null @@ -1,489 +0,0 @@ - -/* pngstruct.h - header file for PNG reference library - * - * Copyright (c) 1998-2013 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Last changed in libpng 1.6.1 [March 28, 2013] - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application. - */ - -#ifndef PNGSTRUCT_H -#define PNGSTRUCT_H -/* zlib.h defines the structure z_stream, an instance of which is included - * in this structure and is required for decompressing the LZ compressed - * data in PNG files. - */ -#ifndef ZLIB_CONST - /* We must ensure that zlib uses 'const' in declarations. */ -# define ZLIB_CONST -#endif -#include "zlib.h" -#ifdef const - /* zlib.h sometimes #defines const to nothing, undo this. */ -# undef const -#endif - -/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility - * with older builds. - */ -#if ZLIB_VERNUM < 0x1260 -# define PNGZ_MSG_CAST(s) png_constcast(char*,s) -# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b) -#else -# define PNGZ_MSG_CAST(s) (s) -# define PNGZ_INPUT_CAST(b) (b) -#endif - -/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib - * can handle at once. This type need be no larger than 16 bits (so maximum of - * 65535), this define allows us to discover how big it is, but limited by the - * maximuum for png_size_t. The value can be overriden in a library build - * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably - * lower value (e.g. 255 works). A lower value may help memory usage (slightly) - * and may even improve performance on some systems (and degrade it on others.) - */ -#ifndef ZLIB_IO_MAX -# define ZLIB_IO_MAX ((uInt)-1) -#endif - -#ifdef PNG_WRITE_SUPPORTED -/* The type of a compression buffer list used by the write code. */ -typedef struct png_compression_buffer -{ - struct png_compression_buffer *next; - png_byte output[1]; /* actually zbuf_size */ -} png_compression_buffer, *png_compression_bufferp; - -#define PNG_COMPRESSION_BUFFER_SIZE(pp)\ - (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size) -#endif - -/* Colorspace support; structures used in png_struct, png_info and in internal - * functions to hold and communicate information about the color space. - * - * PNG_COLORSPACE_SUPPORTED is only required if the application will perform - * colorspace corrections, otherwise all the colorspace information can be - * skipped and the size of libpng can be reduced (significantly) by compiling - * out the colorspace support. - */ -#ifdef PNG_COLORSPACE_SUPPORTED -/* The chromaticities of the red, green and blue colorants and the chromaticity - * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)). - */ -typedef struct png_xy -{ - png_fixed_point redx, redy; - png_fixed_point greenx, greeny; - png_fixed_point bluex, bluey; - png_fixed_point whitex, whitey; -} png_xy; - -/* The same data as above but encoded as CIE XYZ values. When this data comes - * from chromaticities the sum of the Y values is assumed to be 1.0 - */ -typedef struct png_XYZ -{ - png_fixed_point red_X, red_Y, red_Z; - png_fixed_point green_X, green_Y, green_Z; - png_fixed_point blue_X, blue_Y, blue_Z; -} png_XYZ; -#endif /* COLORSPACE */ - -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) -/* A colorspace is all the above plus, potentially, profile information, - * however at present libpng does not use the profile internally so it is only - * stored in the png_info struct (if iCCP is supported.) The rendering intent - * is retained here and is checked. - * - * The file gamma encoding information is also stored here and gamma correction - * is done by libpng, whereas color correction must currently be done by the - * application. - */ -typedef struct png_colorspace -{ -#ifdef PNG_GAMMA_SUPPORTED - png_fixed_point gamma; /* File gamma */ -#endif - -#ifdef PNG_COLORSPACE_SUPPORTED - png_xy end_points_xy; /* End points as chromaticities */ - png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */ - png_uint_16 rendering_intent; /* Rendering intent of a profile */ -#endif - - /* Flags are always defined to simplify the code. */ - png_uint_16 flags; /* As defined below */ -} png_colorspace, * PNG_RESTRICT png_colorspacerp; - -typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp; - -/* General flags for the 'flags' field */ -#define PNG_COLORSPACE_HAVE_GAMMA 0x0001 -#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002 -#define PNG_COLORSPACE_HAVE_INTENT 0x0004 -#define PNG_COLORSPACE_FROM_gAMA 0x0008 -#define PNG_COLORSPACE_FROM_cHRM 0x0010 -#define PNG_COLORSPACE_FROM_sRGB 0x0020 -#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040 -#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */ -#define PNG_COLORSPACE_INVALID 0x8000 -#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags)) -#endif /* COLORSPACE || GAMMA */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */ - png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ - jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */ - size_t jmp_buf_size; /* size of the above, if allocated */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ -#ifdef PNG_WARNINGS_SUPPORTED - png_error_ptr warning_fn; /* function for printing warnings */ -#endif - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */ - z_stream zstream; /* decompression structure */ - -#ifdef PNG_WRITE_SUPPORTED - png_compression_bufferp zbuffer_list; /* Created on demand during write */ - uInt zbuffer_size; /* size of the actual buffer */ - - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ -#endif -/* Added at libpng 1.5.4 */ -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED - int zlib_text_level; /* holds zlib compression level */ - int zlib_text_method; /* holds zlib compression method */ - int zlib_text_window_bits; /* holds zlib compression window bits */ - int zlib_text_mem_level; /* holds zlib compression memory level */ - int zlib_text_strategy; /* holds zlib compression strategy */ -#endif -/* End of material added at libpng 1.5.4 */ -/* Added at libpng 1.6.0 */ -#ifdef PNG_WRITE_SUPPORTED - int zlib_set_level; /* Actual values set into the zstream on write */ - int zlib_set_method; - int zlib_set_window_bits; - int zlib_set_mem_level; - int zlib_set_strategy; -#endif - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_size_t rowbytes; /* size of row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row. - * This is a pointer into big_prev_row - */ - png_bytep row_buf; /* buffer to save current (unfiltered) row. - * This is a pointer into big_row_buf - */ -#ifdef PNG_WRITE_SUPPORTED - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ -#endif - png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - -/* Added at libpng-1.5.10 */ -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED - int num_palette_max; /* maximum palette index found in IDAT */ -#endif - - png_uint_16 num_trans; /* number of transparency values */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row: write only */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ -#ifdef PNG_WRITE_SUPPORTED - png_byte usr_channels; /* channels at start of write: write only */ -#endif - png_byte sig_bytes; /* magic bytes read/written from start of file */ - png_byte maximum_pixel_depth; - /* pixel depth used for the row buffers */ - png_byte transformed_pixel_depth; - /* pixel depth after read/write transforms */ -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - png_byte background_gamma_type; - png_fixed_point background_gamma; - png_color_16 background; /* background color in screen gamma space */ -#ifdef PNG_READ_GAMMA_SUPPORTED - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#ifdef PNG_WRITE_FLUSH_SUPPORTED - png_flush_ptr output_flush_fn; /* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED - int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ - png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ - - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans_alpha; /* alpha values for paletted files */ - png_color_16 trans_color; /* transparent color for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* For the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - png_bytep palette_lookup; /* lookup table for quantizing */ - png_bytep quantize_index; /* index translation for palette files */ -#endif - -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - - /* Options */ -#ifdef PNG_SET_OPTION_SUPPORTED - png_byte options; /* On/off state (up to 4 options) */ -#endif - -#if PNG_LIBPNG_VER < 10700 -/* To do: remove this from libpng-1.7 */ -#ifdef PNG_TIME_RFC1123_SUPPORTED - char time_buffer[29]; /* String to hold RFC 1123 time text */ -#endif -#endif - -/* New members added in libpng-1.0.6 */ - - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ - -#ifdef PNG_USER_CHUNKS_SUPPORTED - png_voidp user_chunk_ptr; -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - int unknown_default; /* As PNG_HANDLE_* */ - unsigned int num_chunk_list; /* Number of entries in the list */ - png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name - * followed by a PNG_HANDLE_* byte */ -#endif - -/* New members added in libpng-1.0.3 */ -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - png_byte rgb_to_gray_status; - /* Added in libpng 1.5.5 to record setting of coefficients: */ - png_byte rgb_to_gray_coefficients_set; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* Changed from png_byte to png_uint_32 at version 1.2.0 */ - png_uint_32 mng_features_permitted; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#ifdef PNG_MNG_FEATURES_SUPPORTED - png_byte filter_type; -#endif - -/* New members added in libpng-1.2.0 */ - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep quantize_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is - in the palette */ - png_bytep palette_to_index; /* which original index points to this - palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; - - /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown - * chunks that can be stored (0 means unlimited). - */ - png_uint_32 user_chunk_cache_max; - - /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk - * can occupy when decompressed. 0 means unlimited. - */ - png_alloc_size_t user_chunk_malloc_max; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - /* Temporary storage for unknown chunk that the library doesn't recognize, - * used while reading the chunk. - */ - png_unknown_chunk unknown_chunk; -#endif - -/* New member added in libpng-1.2.26 */ - png_size_t old_big_row_buf_size; - -#ifdef PNG_READ_SUPPORTED -/* New member added in libpng-1.2.30 */ - png_bytep read_buffer; /* buffer for reading chunk data */ - png_alloc_size_t read_buffer_size; /* current size of the buffer */ -#endif -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED - uInt IDAT_read_size; /* limit on read buffer size for IDAT */ -#endif - -#ifdef PNG_IO_STATE_SUPPORTED -/* New member added in libpng-1.4.0 */ - png_uint_32 io_state; -#endif - -/* New member added in libpng-1.5.6 */ - png_bytep big_prev_row; - -/* New member added in libpng-1.5.7 */ - void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row); - -#ifdef PNG_READ_SUPPORTED -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) - png_colorspace colorspace; -#endif -#endif -}; -#endif /* PNGSTRUCT_H */ diff --git a/Source/3rd Party/wx/src/png/pngtest.c b/Source/3rd Party/wx/src/png/pngtest.c index 144f2db35..431c85dd3 100644 --- a/Source/3rd Party/wx/src/png/pngtest.c +++ b/Source/3rd Party/wx/src/png/pngtest.c @@ -1,15 +1,12 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This program reads in a PNG image, writes it out again, and then * compares the two files. If the files are identical, this shows that * the basic chunk handling, filtering, and (de)compression code is working @@ -31,70 +28,52 @@ * of files at once by typing "pngtest -m file1.png file2.png ..." */ -#define _POSIX_SOURCE 1 - -#include -#include -#include - -/* Defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* For DOS */ - #include "png.h" -/* Known chunks that exist in pngtest.png must be supported or pngtest will fail - * simply as a result of re-ordering them. This may be fixed in 1.7 - */ -#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\ - defined PNG_READ_bKGD_SUPPORTED &&\ - defined PNG_READ_cHRM_SUPPORTED &&\ - defined PNG_READ_gAMA_SUPPORTED &&\ - defined PNG_READ_oFFs_SUPPORTED &&\ - defined PNG_READ_pCAL_SUPPORTED &&\ - defined PNG_READ_pHYs_SUPPORTED &&\ - defined PNG_READ_sBIT_SUPPORTED &&\ - defined PNG_READ_sCAL_SUPPORTED &&\ - defined PNG_READ_sRGB_SUPPORTED &&\ - defined PNG_READ_tEXt_SUPPORTED &&\ - defined PNG_READ_tIME_SUPPORTED &&\ - defined PNG_READ_zTXt_SUPPORTED - -#include "zlib.h" -/* Copied from pngpriv.h but only used in error messages below. */ -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif -#define FCLOSE(file) fclose(file) - -#ifndef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; +#if defined(_WIN32_WCE) +# if _WIN32_WCE < 211 + __error__ (f|w)printf functions are not supported on old WindowsCE.; +# endif +# include +# include +# define READFILE(file, data, length, check) \ + if (ReadFile(file, data, length, &check,NULL)) check = 0 +# define WRITEFILE(file, data, length, check)) \ + if (WriteFile(file, data, length, &check, NULL)) check = 0 +# define FCLOSE(file) CloseHandle(file) +#else +# include +# include +# include +# define READFILE(file, data, length, check) \ + check=(png_size_t)fread(data,(png_size_t)1,length,file) +# define WRITEFILE(file, data, length, check) \ + check=(png_size_t)fwrite(data,(png_size_t)1, length, file) +# define FCLOSE(file) fclose(file) #endif -/* Makes pngtest verbose so we can find problems. */ +#if defined(PNG_NO_STDIO) +# if defined(_WIN32_WCE) + typedef HANDLE png_FILE_p; +# else + typedef FILE * png_FILE_p; +# endif +#endif + +/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ #ifndef PNG_DEBUG # define PNG_DEBUG 0 #endif -#if PNG_DEBUG > 1 -# define pngtest_debug(m) ((void)fprintf(stderr, m "\n")) -# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1)) -# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2)) -#else -# define pngtest_debug(m) ((void)0) -# define pngtest_debug1(m,p1) ((void)0) -# define pngtest_debug2(m,p1,p2) ((void)0) -#endif - #if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */ +# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ #endif /* Turn on CPU timing #define PNGTEST_TIMING */ -#ifndef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_NO_FLOATING_POINT_SUPPORTED #undef PNGTEST_TIMING #endif @@ -103,109 +82,125 @@ static float t_start, t_stop, t_decode, t_encode, t_misc; #include #endif -#ifdef PNG_TIME_RFC1123_SUPPORTED -#define PNG_tIME_STRING_LENGTH 29 -static int tIME_chunk_present = 0; -static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; -#endif - -static int verbose = 0; -static int strict = 0; -static int relaxed = 0; -static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */ -static int error_count = 0; /* count calls to png_error */ -static int warning_count = 0; /* count calls to png_warning */ - -#ifdef __TURBOC__ -#include -#endif - /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ #ifndef png_jmpbuf # define png_jmpbuf(png_ptr) png_ptr->jmpbuf #endif -/* Defines for unknown chunk handling if required. */ -#ifndef PNG_HANDLE_CHUNK_ALWAYS -# define PNG_HANDLE_CHUNK_ALWAYS 3 +#ifdef PNGTEST_TIMING +static float t_start, t_stop, t_decode, t_encode, t_misc; +#if !defined(PNG_tIME_SUPPORTED) +#include #endif -#ifndef PNG_HANDLE_CHUNK_IF_SAFE -# define PNG_HANDLE_CHUNK_IF_SAFE 2 #endif -/* Utility to save typing/errors, the argument must be a name */ -#define MEMZERO(var) ((void)memset(&var, 0, sizeof var)) +#if defined(PNG_TIME_RFC1123_SUPPORTED) +static int tIME_chunk_present=0; +static char tIME_string[30] = "no tIME chunk present in file"; +#endif -/* Example of using row callbacks to make a simple progress meter */ -static int status_pass = 1; -static int status_dots_requested = 0; -static int status_dots = 1; +static int verbose = 0; -static void PNGCBAPI +int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); + +#ifdef __TURBOC__ +#include +#endif + +/* defined so I can write to a file on gui/windowing platforms */ +/* #define STDERR stderr */ +#define STDERR stdout /* for DOS */ + +/* example of using row callbacks to make a simple progress meter */ +static int status_pass=1; +static int status_dots_requested=0; +static int status_dots=1; + +void +#ifdef PNG_1_0_X +PNGAPI +#endif +read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void +#ifdef PNG_1_0_X +PNGAPI +#endif read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) - return; - - if (status_pass != pass) - { - fprintf(stdout, "\n Pass %d: ", pass); - status_pass = pass; - status_dots = 31; - } - - status_dots--; - - if (status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - - fprintf(stdout, "r"); + if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; + if(status_pass != pass) + { + fprintf(stdout,"\n Pass %d: ",pass); + status_pass = pass; + status_dots = 31; + } + status_dots--; + if(status_dots == 0) + { + fprintf(stdout, "\n "); + status_dots=30; + } + fprintf(stdout, "r"); } -#ifdef PNG_WRITE_SUPPORTED -static void PNGCBAPI +void +#ifdef PNG_1_0_X +PNGAPI +#endif +write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void +#ifdef PNG_1_0_X +PNGAPI +#endif write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) - return; - - fprintf(stdout, "w"); + if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; + fprintf(stdout, "w"); } -#endif -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) /* Example of using user transform callback (we don't transform anything, - * but merely examine the row filters. We set this to 256 rather than - * 5 in case illegal filter values are present.) - */ + but merely examine the row filters. We set this to 256 rather than + 5 in case illegal filter values are present.) */ static png_uint_32 filters_used[256]; -static void PNGCBAPI +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); +void +#ifdef PNG_1_0_X +PNGAPI +#endif count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) { - if (png_ptr != NULL && row_info != NULL) - ++filters_used[*(data - 1)]; + if(png_ptr != NULL && row_info != NULL) + ++filters_used[*(data-1)]; } #endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -/* Example of using user transform callback (we don't transform anything, - * but merely count the zero samples) - */ +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +/* example of using user transform callback (we don't transform anything, + but merely count the zero samples) */ static png_uint_32 zero_samples; -static void PNGCBAPI +void +#ifdef PNG_1_0_X +PNGAPI +#endif +count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); +void +#ifdef PNG_1_0_X +PNGAPI +#endif count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) { png_bytep dp = data; - if (png_ptr == NULL) - return; + if(png_ptr == NULL)return; - /* Contents of row_info: + /* contents of row_info: * png_uint_32 width width of row * png_uint_32 rowbytes number of bytes in row * png_byte color_type color type of pixels @@ -214,228 +209,248 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) * png_byte pixel_depth bits per pixel (depth*channels) */ - /* Counts the number of zero samples (or zero pixels if color_type is 3 */ - if (row_info->color_type == 0 || row_info->color_type == 3) + /* counts the number of zero samples (or zero pixels if color_type is 3 */ + + if(row_info->color_type == 0 || row_info->color_type == 3) { - int pos = 0; + int pos=0; png_uint_32 n, nstop; - - for (n = 0, nstop=row_info->width; nwidth; nbit_depth == 1) + if(row_info->bit_depth == 1) { - if (((*dp << pos++ ) & 0x80) == 0) - zero_samples++; - - if (pos == 8) + if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; + if(pos == 8) { pos = 0; dp++; } } - - if (row_info->bit_depth == 2) + if(row_info->bit_depth == 2) { - if (((*dp << (pos+=2)) & 0xc0) == 0) - zero_samples++; - - if (pos == 8) + if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; + if(pos == 8) { pos = 0; dp++; } } - - if (row_info->bit_depth == 4) + if(row_info->bit_depth == 4) { - if (((*dp << (pos+=4)) & 0xf0) == 0) - zero_samples++; - - if (pos == 8) + if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; + if(pos == 8) { pos = 0; dp++; } } - - if (row_info->bit_depth == 8) - if (*dp++ == 0) - zero_samples++; - - if (row_info->bit_depth == 16) + if(row_info->bit_depth == 8) + if(*dp++ == 0) zero_samples++; + if(row_info->bit_depth == 16) { - if ((*dp | *(dp+1)) == 0) - zero_samples++; + if((*dp | *(dp+1)) == 0) zero_samples++; dp+=2; } } } - else /* Other color types */ + else /* other color types */ { png_uint_32 n, nstop; int channel; int color_channels = row_info->channels; - if (row_info->color_type > 3)color_channels--; + if(row_info->color_type > 3)color_channels--; - for (n = 0, nstop=row_info->width; nwidth; nbit_depth == 8) - if (*dp++ == 0) - zero_samples++; - - if (row_info->bit_depth == 16) + if(row_info->bit_depth == 8) + if(*dp++ == 0) zero_samples++; + if(row_info->bit_depth == 16) { - if ((*dp | *(dp+1)) == 0) - zero_samples++; - + if((*dp | *(dp+1)) == 0) zero_samples++; dp+=2; } } - if (row_info->color_type > 3) + if(row_info->color_type > 3) { dp++; - if (row_info->bit_depth == 16) - dp++; + if(row_info->bit_depth == 16)dp++; } } } } #endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ -#ifndef PNG_STDIO_SUPPORTED +static int wrote_question = 0; + +#if defined(PNG_NO_STDIO) /* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and - * pngwio.c. They allow "don't include stdio" testing of the library. - * This is the function that does the actual reading of data. If you are - * not reading from a standard C stream, you should create a replacement - * read_data function and use it at run time with png_set_read_fn(), rather - * than changing the library. - */ +/* These copies of the default read/write functions come from pngrio.c and */ +/* pngwio.c. They allow "don't include stdio" testing of the library. */ +/* This is the function that does the actual reading of data. If you are + not reading from a standard C stream, you should create a replacement + read_data function and use it at run time with png_set_read_fn(), rather + than changing the library. */ -#ifdef PNG_IO_STATE_SUPPORTED -void -pngtest_check_io_state(png_structp png_ptr, png_size_t data_length, - png_uint_32 io_op); -void -pngtest_check_io_state(png_structp png_ptr, png_size_t data_length, - png_uint_32 io_op) -{ - png_uint_32 io_state = png_get_io_state(png_ptr); - int err = 0; - - /* Check if the current operation (reading / writing) is as expected. */ - if ((io_state & PNG_IO_MASK_OP) != io_op) - png_error(png_ptr, "Incorrect operation in I/O state"); - - /* Check if the buffer size specific to the current location - * (file signature / header / data / crc) is as expected. - */ - switch (io_state & PNG_IO_MASK_LOC) - { - case PNG_IO_SIGNATURE: - if (data_length > 8) - err = 1; - break; - case PNG_IO_CHUNK_HDR: - if (data_length != 8) - err = 1; - break; - case PNG_IO_CHUNK_DATA: - break; /* no restrictions here */ - case PNG_IO_CHUNK_CRC: - if (data_length != 4) - err = 1; - break; - default: - err = 1; /* uninitialized */ - } - if (err) - png_error(png_ptr, "Bad I/O state or buffer size"); -} -#endif - -static void PNGCBAPI +#ifndef USE_FAR_KEYWORD +static void pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check = 0; - png_voidp io_ptr; + png_size_t check; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ - io_ptr = png_get_io_ptr(png_ptr); - if (io_ptr != NULL) - { - check = fread(data, 1, length, (png_FILE_p)io_ptr); - } + READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); if (check != length) { - png_error(png_ptr, "Read Error"); + png_error(png_ptr, "Read Error!"); } - -#ifdef PNG_IO_STATE_SUPPORTED - pngtest_check_io_state(png_ptr, length, PNG_IO_READING); -#endif } +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ -#ifdef PNG_WRITE_FLUSH_SUPPORTED -static void PNGCBAPI +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void +pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + int check; + png_byte *n_data; + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + n_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)n_data == data) + { + READFILE(io_ptr, n_data, length, check); + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t read, remaining, err; + check = 0; + remaining = length; + do + { + read = MIN(NEAR_BUF_SIZE, remaining); + READFILE(io_ptr, buf, 1, err); + png_memcpy(data, buf, read); /* copy far buffer to near buffer */ + if(err != read) + break; + else + check += err; + data += read; + remaining -= read; + } + while (remaining != 0); + } + if (check != length) + { + png_error(png_ptr, "read Error"); + } +} +#endif /* USE_FAR_KEYWORD */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +static void pngtest_flush(png_structp png_ptr) { - /* Do nothing; fflush() is said to be just a waste of energy. */ - PNG_UNUSED(png_ptr) /* Stifle compiler warning */ +#if !defined(_WIN32_WCE) + png_FILE_p io_ptr; + io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); + if (io_ptr != NULL) + fflush(io_ptr); +#endif } #endif /* This is the function that does the actual writing of data. If you are - * not writing to a standard C stream, you should create a replacement - * write_data function and use it at run time with png_set_write_fn(), rather - * than changing the library. - */ -static void PNGCBAPI + not writing to a standard C stream, you should create a replacement + write_data function and use it at run time with png_set_write_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +static void pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check; - - check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr)); + png_uint_32 check; + WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); if (check != length) { png_error(png_ptr, "Write Error"); } - -#ifdef PNG_IO_STATE_SUPPORTED - pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING); -#endif } -#endif /* !PNG_STDIO_SUPPORTED */ +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void +pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + near_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)near_data == data) + { + WRITEFILE(io_ptr, near_data, length, check); + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t written, remaining, err; + check = 0; + remaining = length; + do + { + written = MIN(NEAR_BUF_SIZE, remaining); + png_memcpy(buf, data, written); /* copy far buffer to near buffer */ + WRITEFILE(io_ptr, buf, written, err); + if (err != written) + break; + else + check += err; + data += written; + remaining -= written; + } + while (remaining != 0); + } + if (check != length) + { + png_error(png_ptr, "Write Error"); + } +} + +#endif /* USE_FAR_KEYWORD */ /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything * here if you don't want to. In the default configuration, png_ptr is * not used, but it is passed in case it may be useful. */ -typedef struct -{ - PNG_CONST char *file_name; -} pngtest_error_parameters; - -static void PNGCBAPI +static void pngtest_warning(png_structp png_ptr, png_const_charp message) { PNG_CONST char *name = "UNKNOWN (ERROR!)"; - pngtest_error_parameters *test = - (pngtest_error_parameters*)png_get_error_ptr(png_ptr); - - ++warning_count; - - if (test != NULL && test->file_name != NULL) - name = test->file_name; - + if (png_ptr != NULL && png_ptr->error_ptr != NULL) + name = png_ptr->error_ptr; fprintf(STDERR, "%s: libpng warning: %s\n", name, message); } @@ -444,38 +459,34 @@ pngtest_warning(png_structp png_ptr, png_const_charp message) * function is used by default, or if the program supplies NULL for the * error function pointer in png_set_error_fn(). */ -static void PNGCBAPI +static void pngtest_error(png_structp png_ptr, png_const_charp message) { - ++error_count; - pngtest_warning(png_ptr, message); /* We can return because png_error calls the default handler, which is - * actually OK in this case. - */ + * actually OK in this case. */ } - +#endif /* PNG_NO_STDIO */ /* END of code to validate stdio-free compilation */ /* START of code to validate memory allocation and deallocation */ #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG /* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * This piece of code can be compiled to validate max 64K allocations - * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. - */ + 64K. However, zlib may allocate more then 64K if you don't tell + it not to. See zconf.h and png.h for more information. zlib does + need to allocate exactly 64K, so whatever you call here must + have the ability to do that. + + This piece of code can be compiled to validate max 64K allocations + by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ typedef struct memory_information { - png_alloc_size_t size; + png_uint_32 size; png_voidp pointer; - struct memory_information *next; + struct memory_information FAR *next; } memory_information; -typedef memory_information *memory_infop; +typedef memory_information FAR *memory_infop; static memory_infop pinformation = NULL; static int current_allocation = 0; @@ -483,17 +494,15 @@ static int maximum_allocation = 0; static int total_allocation = 0; static int num_allocations = 0; -png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, - png_alloc_size_t size)); -void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); +png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); +void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); png_voidp -PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) +png_debug_malloc(png_structp png_ptr, png_uint_32 size) { /* png_malloc has already tested for NULL; png_create_struct calls - * png_debug_malloc directly, with png_ptr == NULL which is OK - */ + png_debug_malloc directly, with png_ptr == NULL which is OK */ if (size == 0) return (NULL); @@ -505,49 +514,41 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) memory_infop pinfo; png_set_mem_fn(png_ptr, NULL, NULL, NULL); pinfo = (memory_infop)png_malloc(png_ptr, - (sizeof *pinfo)); + (png_uint_32)png_sizeof (*pinfo)); pinfo->size = size; current_allocation += size; total_allocation += size; num_allocations ++; - if (current_allocation > maximum_allocation) maximum_allocation = current_allocation; - - pinfo->pointer = png_malloc(png_ptr, size); + pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); /* Restore malloc_fn and free_fn */ - - png_set_mem_fn(png_ptr, - NULL, png_debug_malloc, png_debug_free); - + png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, + (png_free_ptr)png_debug_free); if (size != 0 && pinfo->pointer == NULL) { current_allocation -= size; total_allocation -= size; png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc"); + "out of memory in pngtest->png_debug_malloc."); } - pinfo->next = pinformation; pinformation = pinfo; /* Make sure the caller isn't assuming zeroed memory. */ - memset(pinfo->pointer, 0xdd, pinfo->size); - - if (verbose) - printf("png_malloc %lu bytes at %p\n", (unsigned long)size, - pinfo->pointer); - + png_memset(pinfo->pointer, 0xdd, pinfo->size); + if(verbose) + printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer); + assert(pinfo->size != 12345678); return (png_voidp)(pinfo->pointer); } } /* Free a pointer. It is removed from the list at the same time. */ -void PNGCBAPI +void png_debug_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL) fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) { #if 0 /* This happens all the time. */ @@ -558,12 +559,10 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) /* Unlink the element from the list. */ { - memory_infop *ppinfo = &pinformation; - + memory_infop FAR *ppinfo = &pinformation; for (;;) { memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) { *ppinfo = pinfo->next; @@ -572,256 +571,35 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) fprintf(STDERR, "Duplicate free of memory\n"); /* We must free the list element too, but first kill the memory that is to be freed. */ - memset(ptr, 0x55, pinfo->size); + png_memset(ptr, 0x55, pinfo->size); png_free_default(png_ptr, pinfo); - pinfo = NULL; + pinfo=NULL; break; } - if (pinfo->next == NULL) { fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); break; } - ppinfo = &pinfo->next; } } /* Finally free the data. */ - if (verbose) - printf("Freeing %p\n", ptr); - + if(verbose) + printf("Freeing %x\n",ptr); png_free_default(png_ptr, ptr); - ptr = NULL; + ptr=NULL; } #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ /* END of code to test memory allocation/deallocation */ - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* Demonstration of user chunk support of the sTER and vpAg chunks */ - -/* (sTER is a public chunk not yet known by libpng. vpAg is a private -chunk used in ImageMagick to store "virtual page" size). */ - -static struct user_chunk_data -{ - png_const_infop info_ptr; - png_uint_32 vpAg_width, vpAg_height; - png_byte vpAg_units; - png_byte sTER_mode; - int location[2]; -} -user_chunk_data; - -/* Used for location and order; zero means nothing. */ -#define have_sTER 0x01 -#define have_vpAg 0x02 -#define before_PLTE 0x10 -#define before_IDAT 0x20 -#define after_IDAT 0x40 - -static void -init_callback_info(png_const_infop info_ptr) -{ - MEMZERO(user_chunk_data); - user_chunk_data.info_ptr = info_ptr; -} - -static int -set_location(png_structp png_ptr, struct user_chunk_data *data, int what) -{ - int location; - - if ((data->location[0] & what) || (data->location[1] & what)) - return 0; /* already have one of these */ - - /* Find where we are (the code below zeros info_ptr to indicate that the - * chunks before the first IDAT have been read.) - */ - if (data->info_ptr == NULL) /* after IDAT */ - location = what | after_IDAT; - - else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE)) - location = what | before_IDAT; - - else - location = what | before_PLTE; - - if (data->location[0] == 0) - data->location[0] = location; - - else - data->location[1] = location; - - return 1; /* handled */ -} - -static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr, - png_unknown_chunkp chunk) -{ - struct user_chunk_data *my_user_chunk_data = - (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr); - - if (my_user_chunk_data == NULL) - png_error(png_ptr, "lost user chunk pointer"); - - /* Return one of the following: - * return (-n); chunk had an error - * return (0); did not recognize - * return (n); success - * - * The unknown chunk structure contains the chunk data: - * png_byte name[5]; - * png_byte *data; - * png_size_t size; - * - * Note that libpng has already taken care of the CRC handling. - */ - - if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */ - chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */ - { - /* Found sTER chunk */ - if (chunk->size != 1) - return (-1); /* Error return */ - - if (chunk->data[0] != 0 && chunk->data[0] != 1) - return (-1); /* Invalid mode */ - - if (set_location(png_ptr, my_user_chunk_data, have_sTER)) - { - my_user_chunk_data->sTER_mode=chunk->data[0]; - return (1); - } - - else - return (0); /* duplicate sTER - give it to libpng */ - } - - if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ - chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ - return (0); /* Did not recognize */ - - /* Found ImageMagick vpAg chunk */ - - if (chunk->size != 9) - return (-1); /* Error return */ - - if (!set_location(png_ptr, my_user_chunk_data, have_vpAg)) - return (0); /* duplicate vpAg */ - - my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data); - my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4); - my_user_chunk_data->vpAg_units = chunk->data[8]; - - return (1); -} - -#ifdef PNG_WRITE_SUPPORTED -static void -write_sTER_chunk(png_structp write_ptr) -{ - png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}; - - if (verbose) - fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode); - - png_write_chunk(write_ptr, png_sTER, &user_chunk_data.sTER_mode, 1); -} - -static void -write_vpAg_chunk(png_structp write_ptr) -{ - png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'}; - - png_byte vpag_chunk_data[9]; - - if (verbose) - fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n", - (unsigned long)user_chunk_data.vpAg_width, - (unsigned long)user_chunk_data.vpAg_height, - user_chunk_data.vpAg_units); - - png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width); - png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height); - vpag_chunk_data[8] = user_chunk_data.vpAg_units; - png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9); -} - -static void -write_chunks(png_structp write_ptr, int location) -{ - int i; - - /* Notice that this preserves the original chunk order, however chunks - * intercepted by the callback will be written *after* chunks passed to - * libpng. This will actually reverse a pair of sTER chunks or a pair of - * vpAg chunks, resulting in an error later. This is not worth worrying - * about - the chunks should not be duplicated! - */ - for (i=0; i<2; ++i) - { - if (user_chunk_data.location[i] == (location | have_sTER)) - write_sTER_chunk(write_ptr); - - else if (user_chunk_data.location[i] == (location | have_vpAg)) - write_vpAg_chunk(write_ptr); - } -} -#endif /* PNG_WRITE_SUPPORTED */ -#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */ -# define write_chunks(pp,loc) ((void)0) -#endif -/* END of code to demonstrate user chunk support */ - -/* START of code to check that libpng has the required text support; this only - * checks for the write support because if read support is missing the chunk - * will simply not be reported back to pngtest. - */ -#ifdef PNG_TEXT_SUPPORTED -static void -pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr, - int num_text) -{ - while (num_text > 0) - { - switch (text_ptr[--num_text].compression) - { - case PNG_TEXT_COMPRESSION_NONE: - break; - - case PNG_TEXT_COMPRESSION_zTXt: -# ifndef PNG_WRITE_zTXt_SUPPORTED - ++unsupported_chunks; -# endif - break; - - case PNG_ITXT_COMPRESSION_NONE: - case PNG_ITXT_COMPRESSION_zTXt: -# ifndef PNG_WRITE_iTXt_SUPPORTED - ++unsupported_chunks; -# endif - break; - - default: - /* This is an error */ - png_error(png_ptr, "invalid text chunk compression field"); - break; - } - } -} -#endif -/* END of code to check that libpng has the required text support */ - /* Test one file */ -static int +int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { static png_FILE_p fpin; static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - pngtest_error_parameters error_parameters; png_structp read_ptr; png_infop read_info_ptr, end_info_ptr; #ifdef PNG_WRITE_SUPPORTED @@ -838,48 +616,70 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_uint_32 width, height; int num_pass, pass; int bit_depth, color_type; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + +#if defined(_WIN32_WCE) + TCHAR path[MAX_PATH]; +#endif + char inbuf[256], outbuf[256]; row_buf = NULL; - error_parameters.file_name = inname; +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); + if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else if ((fpin = fopen(inname, "rb")) == NULL) +#endif { fprintf(STDERR, "Could not find input file %s\n", inname); return (1); } +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); + if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) +#else if ((fpout = fopen(outname, "wb")) == NULL) +#endif { fprintf(STDERR, "Could not open output file %s\n", outname); FCLOSE(fpin); return (1); } - pngtest_debug("Allocating read and write structures"); + png_debug(0, "Allocating read and write structures\n"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = - png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL, - NULL, NULL, NULL, png_debug_malloc, png_debug_free); + read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, + (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - read_ptr = - png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL); +#endif +#if defined(PNG_NO_STDIO) + png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, + pngtest_warning); #endif - png_set_error_fn(read_ptr, &error_parameters, pngtest_error, - pngtest_warning); - #ifdef PNG_WRITE_SUPPORTED #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = - png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, - NULL, NULL, NULL, png_debug_malloc, png_debug_free); + write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, + (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - write_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + png_error_ptr_NULL, png_error_ptr_NULL); #endif - png_set_error_fn(write_ptr, &error_parameters, pngtest_error, - pngtest_warning); +#if defined(PNG_NO_STDIO) + png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, + pngtest_warning); #endif - pngtest_debug("Allocating read_info, write_info and end_info structures"); +#endif + png_debug(0, "Allocating read_info, write_info and end_info structures\n"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); #ifdef PNG_WRITE_SUPPORTED @@ -887,19 +687,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) write_end_info_ptr = png_create_info_struct(write_ptr); #endif -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - init_callback_info(read_info_ptr); - png_set_read_user_chunk_fn(read_ptr, &user_chunk_data, - read_user_chunk_callback); -#endif - #ifdef PNG_SETJMP_SUPPORTED - pngtest_debug("Setting jmpbuf for read struct"); + png_debug(0, "Setting jmpbuf for read struct\n"); +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else if (setjmp(png_jmpbuf(read_ptr))) +#endif { fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - png_free(read_ptr, row_buf); - row_buf = NULL; + if (row_buf) + png_free(read_ptr, row_buf); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED png_destroy_info_struct(write_ptr, &write_end_info_ptr); @@ -909,11 +707,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) FCLOSE(fpout); return (1); } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); +#endif #ifdef PNG_WRITE_SUPPORTED - pngtest_debug("Setting jmpbuf for write struct"); - + png_debug(0, "Setting jmpbuf for write struct\n"); +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else if (setjmp(png_jmpbuf(write_ptr))) +#endif { fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); @@ -925,37 +729,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) FCLOSE(fpout); return (1); } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); +#endif #endif #endif - if (strict) - { - /* Treat png_benign_error() as errors on read */ - png_set_benign_errors(read_ptr, 0); - -#ifdef PNG_WRITE_SUPPORTED - /* Treat them as errors on write */ - png_set_benign_errors(write_ptr, 0); -#endif - - /* if strict is not set, then app warnings and errors are treated as - * warnings in release builds, but not in unstable builds; this can be - * changed with '--relaxed'. - */ - } - - else if (relaxed) - { - /* Allow application (pngtest) errors and warnings to pass */ - png_set_benign_errors(read_ptr, 1); - -#ifdef PNG_WRITE_SUPPORTED - png_set_benign_errors(write_ptr, 1); -#endif - } - - pngtest_debug("Initializing input and output streams"); -#ifdef PNG_STDIO_SUPPORTED + png_debug(0, "Initializing input and output streams\n"); +#if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); # ifdef PNG_WRITE_SUPPORTED png_init_io(write_ptr, fpout); @@ -964,77 +745,60 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); # ifdef PNG_WRITE_SUPPORTED png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# ifdef PNG_WRITE_FLUSH_SUPPORTED +# if defined(PNG_WRITE_FLUSH_SUPPORTED) pngtest_flush); # else NULL); # endif # endif #endif - - if (status_dots_requested == 1) + if(status_dots_requested == 1) { #ifdef PNG_WRITE_SUPPORTED png_set_write_status_fn(write_ptr, write_row_callback); #endif png_set_read_status_fn(read_ptr, read_row_callback); } - else { #ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, NULL); + png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); #endif - png_set_read_status_fn(read_ptr, NULL); + png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); } -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) { - int i; - - for (i = 0; i<256; i++) - filters_used[i] = 0; - - png_set_read_user_transform_fn(read_ptr, count_filters); + int i; + for(i=0; i<256; i++) + filters_used[i]=0; + png_set_read_user_transform_fn(read_ptr, count_filters); } #endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - zero_samples = 0; +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + zero_samples=0; png_set_write_user_transform_fn(write_ptr, count_zero_samples); #endif -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - /* Preserve all the unknown chunks, if possible. If this is disabled then, - * even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use - * libpng to *save* the unknown chunks on read (because we can't switch the - * save option on!) - * - * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all - * unknown chunks and write will write them all. - */ -#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# ifndef PNG_HANDLE_CHUNK_ALWAYS +# define PNG_HANDLE_CHUNK_ALWAYS 3 +# endif png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - NULL, 0); -#endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, - NULL, 0); + png_bytep_NULL, 0); #endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +# ifndef PNG_HANDLE_CHUNK_IF_SAFE +# define PNG_HANDLE_CHUNK_IF_SAFE 2 +# endif + png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, + png_bytep_NULL, 0); #endif - pngtest_debug("Reading info struct"); + png_debug(0, "Reading info struct\n"); png_read_info(read_ptr, read_info_ptr); -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - /* This is a bit of a hack; there is no obvious way in the callback function - * to determine that the chunks before the first IDAT have been read, so - * remove the info_ptr (which is only used to determine position relative to - * PLTE) here to indicate that we are after the IDAT. - */ - user_chunk_data.info_ptr = NULL; -#endif - - pngtest_debug("Transferring info struct"); + png_debug(0, "Transferring info struct\n"); { int interlace_type, compression_type, filter_type; @@ -1042,42 +806,42 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) &color_type, &interlace_type, &compression_type, &filter_type)) { png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#ifdef PNG_WRITE_INTERLACING_SUPPORTED +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) color_type, interlace_type, compression_type, filter_type); #else color_type, PNG_INTERLACE_NONE, compression_type, filter_type); #endif } } -#ifdef PNG_FIXED_POINT_SUPPORTED -#ifdef PNG_cHRM_SUPPORTED +#if defined(PNG_FIXED_POINT_SUPPORTED) +#if defined(PNG_cHRM_SUPPORTED) { png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; - - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, - &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y)) + if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y)) { png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); } } #endif -#ifdef PNG_gAMA_SUPPORTED +#if defined(PNG_gAMA_SUPPORTED) { png_fixed_point gamma; if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) + { png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); + } } #endif #else /* Use floating point versions */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -#ifdef PNG_cHRM_SUPPORTED +#if defined(PNG_FLOATING_POINT_SUPPORTED) +#if defined(PNG_cHRM_SUPPORTED) { double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y)) { @@ -1086,20 +850,22 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } } #endif -#ifdef PNG_gAMA_SUPPORTED +#if defined(PNG_gAMA_SUPPORTED) { double gamma; if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) + { png_set_gAMA(write_ptr, write_info_ptr, gamma); + } } #endif -#endif /* Floating point */ -#endif /* Fixed point */ -#ifdef PNG_iCCP_SUPPORTED +#endif /* floating point */ +#endif /* fixed point */ +#if defined(PNG_iCCP_SUPPORTED) { png_charp name; - png_bytep profile; + png_charp profile; png_uint_32 proflen; int compression_type; @@ -1111,12 +877,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } } #endif -#ifdef PNG_sRGB_SUPPORTED +#if defined(PNG_sRGB_SUPPORTED) { int intent; if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) + { png_set_sRGB(write_ptr, write_info_ptr, intent); + } } #endif { @@ -1124,9 +892,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int num_palette; if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) + { png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); + } } -#ifdef PNG_bKGD_SUPPORTED +#if defined(PNG_bKGD_SUPPORTED) { png_color_16p background; @@ -1136,27 +906,28 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } } #endif -#ifdef PNG_hIST_SUPPORTED +#if defined(PNG_hIST_SUPPORTED) { png_uint_16p hist; if (png_get_hIST(read_ptr, read_info_ptr, &hist)) + { png_set_hIST(write_ptr, write_info_ptr, hist); + } } #endif -#ifdef PNG_oFFs_SUPPORTED +#if defined(PNG_oFFs_SUPPORTED) { png_int_32 offset_x, offset_y; int unit_type; - if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, - &unit_type)) + if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) { png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); } } #endif -#ifdef PNG_pCAL_SUPPORTED +#if defined(PNG_pCAL_SUPPORTED) { png_charp purpose, units; png_charpp params; @@ -1171,26 +942,29 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } } #endif -#ifdef PNG_pHYs_SUPPORTED +#if defined(PNG_pHYs_SUPPORTED) { png_uint_32 res_x, res_y; int unit_type; if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) + { png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); + } } #endif -#ifdef PNG_sBIT_SUPPORTED +#if defined(PNG_sBIT_SUPPORTED) { png_color_8p sig_bit; if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) + { png_set_sBIT(write_ptr, write_info_ptr, sig_bit); + } } #endif -#ifdef PNG_sCAL_SUPPORTED -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED { int unit; double scal_width, scal_height; @@ -1210,133 +984,91 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, &scal_height)) { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, - scal_height); + png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); } } #endif #endif #endif -#ifdef PNG_TEXT_SUPPORTED +#if defined(PNG_TEXT_SUPPORTED) { png_textp text_ptr; int num_text; if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) { - pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); - - pngtest_check_text_support(read_ptr, text_ptr, num_text); - - if (verbose) - { - int i; - - printf("\n"); - for (i=0; i 0) { - pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); - - pngtest_check_text_support(read_ptr, text_ptr, num_text); - - if (verbose) - { - int i; - - printf("\n"); - for (i=0; i 0) - { - /* We don't really expect to get here because of the setjmp handling - * above, but this is safe. - */ - fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)", - inname, error_count, warning_count); - - if (strict != 0) - return (1); - } - -# ifdef PNG_WRITE_SUPPORTED - /* If there we no write support nothing was written! */ - else if (unsupported_chunks > 0) - { - fprintf(STDERR, "\n %s: unsupported chunks (%d)%s", - inname, unsupported_chunks, strict ? ": IGNORED --strict!" : ""); - } -# endif - - else if (warning_count > 0) - { - fprintf(STDERR, "\n %s: %d libpng warnings found", - inname, warning_count); - - if (strict != 0) - return (1); - } - - pngtest_debug("Opening files for comparison"); + png_debug(0, "Opening files for comparison\n"); +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); + if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else if ((fpin = fopen(inname, "rb")) == NULL) +#endif { fprintf(STDERR, "Could not find file %s\n", inname); return (1); } +#if defined(_WIN32_WCE) + MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); + if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) +#else if ((fpout = fopen(outname, "rb")) == NULL) +#endif { fprintf(STDERR, "Could not find file %s\n", outname); FCLOSE(fpin); return (1); } -#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */ + for(;;) { - int wrote_question = 0; + png_size_t num_in, num_out; - for (;;) + READFILE(fpin, inbuf, 1, num_in); + READFILE(fpout, outbuf, 1, num_out); + + if (num_in != num_out) { - png_size_t num_in, num_out; - char inbuf[256], outbuf[256]; - - - num_in = fread(inbuf, 1, sizeof inbuf, fpin); - num_out = fread(outbuf, 1, sizeof outbuf, fpout); - - if (num_in != num_out) + fprintf(STDERR, "\nFiles %s and %s are of a different size\n", + inname, outname); + if(wrote_question == 0) { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - - if (wrote_question == 0 && unsupported_chunks == 0) - { - fprintf(STDERR, + fprintf(STDERR, " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname, PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question = 1; - } - - FCLOSE(fpin); - FCLOSE(fpout); - - if (strict != 0 && unsupported_chunks == 0) - return (1); - - else - return (0); + inname,PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question=1; } + FCLOSE(fpin); + FCLOSE(fpout); + return (0); + } - if (!num_in) - break; + if (!num_in) + break; - if (memcmp(inbuf, outbuf, num_in)) + if (png_memcmp(inbuf, outbuf, num_in)) + { + fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); + if(wrote_question == 0) { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, - outname); - - if (wrote_question == 0 && unsupported_chunks == 0) - { - fprintf(STDERR, + fprintf(STDERR, " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname, PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question = 1; - } - - FCLOSE(fpin); - FCLOSE(fpout); - - /* NOTE: the unsupported_chunks escape is permitted here because - * unsupported text chunk compression will result in the compression - * mode being changed (to NONE) yet, in the test case, the result - * can be exactly the same size! - */ - if (strict != 0 && unsupported_chunks == 0) - return (1); - - else - return (0); + inname,PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question=1; } + FCLOSE(fpin); + FCLOSE(fpout); + return (0); } } -#endif /* PNG_WRITE_SUPPORTED */ FCLOSE(fpin); FCLOSE(fpout); @@ -1660,7 +1295,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (0); } -/* Input and output filenames */ +/* input and output filenames */ #ifdef RISCOS static PNG_CONST char *inname = "pngtest/png"; static PNG_CONST char *outname = "pngout/png"; @@ -1675,23 +1310,22 @@ main(int argc, char *argv[]) int multiple = 0; int ierror = 0; - fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR, "%s", png_get_copyright(NULL)); + fprintf(STDERR,"%s",png_get_copyright(NULL)); /* Show the version of libpng used in building the library */ - fprintf(STDERR, " library (%lu):%s", - (unsigned long)png_access_version_number(), + fprintf(STDERR," library (%lu):%s", png_access_version_number(), png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, + fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, PNG_HEADER_VERSION_STRING); + fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", + (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); /* Do some consistency checking on the memory allocation settings, I'm - * not sure this matters, but it is nice to know, the first of these - * tests should be impossible because of the way the macros are set - * in pngconf.h - */ + not sure this matters, but it is nice to know, the first of these + tests should be impossible because of the way the macros are set + in pngconf.h */ #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); #endif @@ -1716,7 +1350,6 @@ main(int argc, char *argv[]) multiple = 1; status_dots_requested = 0; } - else if (strcmp(argv[1], "-mv") == 0 || strcmp(argv[1], "-vm") == 0 ) { @@ -1724,32 +1357,12 @@ main(int argc, char *argv[]) verbose = 1; status_dots_requested = 1; } - else if (strcmp(argv[1], "-v") == 0) { verbose = 1; status_dots_requested = 1; inname = argv[2]; } - - else if (strcmp(argv[1], "--strict") == 0) - { - status_dots_requested = 0; - verbose = 1; - inname = argv[2]; - strict++; - relaxed = 0; - } - - else if (strcmp(argv[1], "--relaxed") == 0) - { - status_dots_requested = 0; - verbose = 1; - inname = argv[2]; - strict = 0; - relaxed++; - } - else { inname = argv[1]; @@ -1757,10 +1370,10 @@ main(int argc, char *argv[]) } } - if (!multiple && argc == 3 + verbose) - outname = argv[2 + verbose]; + if (!multiple && argc == 3+verbose) + outname = argv[2+verbose]; - if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2)) + if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) { fprintf(STDERR, "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", @@ -1780,34 +1393,31 @@ main(int argc, char *argv[]) #endif for (i=2; isize, - (unsigned int)pinfo->pointer); + fprintf(STDERR, " %lu bytes at %x\n", pinfo->size, + (unsigned int) pinfo->pointer); pinfo = pinfo->next; } } @@ -1846,77 +1453,65 @@ main(int argc, char *argv[]) num_allocations); #endif } - else { int i; - for (i = 0; i<3; ++i) + for (i=0; i<3; ++i) { int kerror; #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG int allocation_now = current_allocation; #endif - if (i == 1) - status_dots_requested = 1; - - else if (verbose == 0) - status_dots_requested = 0; - + if (i == 1) status_dots_requested = 1; + else if(verbose == 0)status_dots_requested = 0; if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "\n Testing %s:", inname); - + fprintf(STDERR, "Testing %s:",inname); kerror = test_one_file(inname, outname); - - if (kerror == 0) + if(kerror == 0) { - if (verbose == 1 || i == 2) + if(verbose == 1 || i == 2) { -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) int k; #endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples); #else fprintf(STDERR, " PASS\n"); #endif -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - for (k = 0; k<256; k++) - if (filters_used[k]) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + for (k=0; k<256; k++) + if(filters_used[k]) fprintf(STDERR, " Filter %d was used %lu times\n", - k, (unsigned long)filters_used[k]); + k,filters_used[k]); #endif -#ifdef PNG_TIME_RFC1123_SUPPORTED - if (tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n", tIME_string); +#if defined(PNG_TIME_RFC1123_SUPPORTED) + if(tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n",tIME_string); #endif /* PNG_TIME_RFC1123_SUPPORTED */ } } - else { - if (verbose == 0 && i != 2) - fprintf(STDERR, "\n Testing %s:", inname); - + if(verbose == 0 && i != 2) + fprintf(STDERR, "Testing %s:",inname); fprintf(STDERR, " FAIL\n"); ierror += kerror; } #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG if (allocation_now != current_allocation) fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation - allocation_now); - + current_allocation-allocation_now); if (current_allocation != 0) { memory_infop pinfo = pinformation; fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", current_allocation); - while (pinfo != NULL) { - fprintf(STDERR, " %lu bytes at %x\n", - (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); + fprintf(STDERR," %lu bytes at %x\n", + pinfo->size, (unsigned int)pinfo->pointer); pinfo = pinfo->next; } } @@ -1938,34 +1533,22 @@ main(int argc, char *argv[]) t_stop = (float)clock(); t_misc += (t_stop - t_start); t_start = t_stop; - fprintf(STDERR, " CPU time used = %.3f seconds", + fprintf(STDERR," CPU time used = %.3f seconds", (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " (decoding %.3f,\n", + fprintf(STDERR," (decoding %.3f,\n", t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " encoding %.3f ,", + fprintf(STDERR," encoding %.3f ,", t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " other %.3f seconds)\n\n", + fprintf(STDERR," other %.3f seconds)\n\n", t_misc/(float)CLOCKS_PER_SEC); #endif if (ierror == 0) - fprintf(STDERR, " libpng passes test\n"); - + fprintf(STDERR, "libpng passes test\n"); else - fprintf(STDERR, " libpng FAILS test\n"); - + fprintf(STDERR, "libpng FAILS test\n"); return (int)(ierror != 0); } -#else -int -main(void) -{ - fprintf(STDERR, - " test ignored because libpng was not built with read support\n"); - /* And skip this test */ - return 77; -} -#endif /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_2 Your_png_h_is_not_version_1_6_2; +typedef version_1_2_7 your_png_h_is_not_version_1_2_7; diff --git a/Source/3rd Party/wx/src/png/pngtrans.c b/Source/3rd Party/wx/src/png/pngtrans.c index 8f8bc5d9e..f279f9e79 100644 --- a/Source/3rd Party/wx/src/png/pngtrans.c +++ b/Source/3rd Party/wx/src/png/pngtrans.c @@ -1,59 +1,43 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#define PNG_INTERNAL +#include "png.h" #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Turn on BGR-to-RGB mapping */ +/* turn on BGR-to-RGB mapping */ void PNGAPI -png_set_bgr(png_structrp png_ptr) +png_set_bgr(png_structp png_ptr) { - png_debug(1, "in png_set_bgr"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_bgr\n"); png_ptr->transformations |= PNG_BGR; } #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Turn on 16 bit byte swapping */ +/* turn on 16 bit byte swapping */ void PNGAPI -png_set_swap(png_structrp png_ptr) +png_set_swap(png_structp png_ptr) { - png_debug(1, "in png_set_swap"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_swap\n"); if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Turn on pixel packing */ +/* turn on pixel packing */ void PNGAPI -png_set_packing(png_structrp png_ptr) +png_set_packing(png_structp png_ptr) { - png_debug(1, "in png_set_packing"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_packing\n"); if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; @@ -63,15 +47,11 @@ png_set_packing(png_structrp png_ptr) #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Turn on packed pixel swapping */ +/* turn on packed pixel swapping */ void PNGAPI -png_set_packswap(png_structrp png_ptr) +png_set_packswap(png_structp png_ptr) { - png_debug(1, "in png_set_packswap"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_packswap\n"); if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } @@ -79,13 +59,9 @@ png_set_packswap(png_structrp png_ptr) #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) void PNGAPI -png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits) +png_set_shift(png_structp png_ptr, png_color_8p true_bits) { - png_debug(1, "in png_set_shift"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_shift\n"); png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } @@ -94,11 +70,10 @@ png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits) #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) int PNGAPI -png_set_interlace_handling(png_structrp png_ptr) +png_set_interlace_handling(png_structp png_ptr) { - png_debug(1, "in png_set_interlace handling"); - - if (png_ptr && png_ptr->interlaced) + png_debug(1, "in png_set_interlace handling\n"); + if (png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; return (7); @@ -115,115 +90,54 @@ png_set_interlace_handling(png_structrp png_ptr) * that don't like bytes as parameters. */ void PNGAPI -png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) +png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_filler"); - - if (png_ptr == NULL) - return; - - /* In libpng 1.6 it is possible to determine whether this is a read or write - * operation and therefore to do more checking here for a valid call. - */ - if (png_ptr->mode & PNG_IS_READ_STRUCT) - { -# ifdef PNG_READ_FILLER_SUPPORTED - /* On read png_set_filler is always valid, regardless of the base PNG - * format, because other transformations can give a format where the - * filler code can execute (basically an 8 or 16-bit component RGB or G - * format.) - * - * NOTE: usr_channels is not used by the read code! (This has led to - * confusion in the past.) The filler is only used in the read code. - */ - png_ptr->filler = (png_uint_16)filler; -# else - png_app_error(png_ptr, "png_set_filler not supported on read"); - PNG_UNUSED(filler) /* not used in the write case */ - return; -# endif - } - - else /* write */ - { -# ifdef PNG_WRITE_FILLER_SUPPORTED - /* On write the usr_channels parameter must be set correctly at the - * start to record the number of channels in the app-supplied data. - */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_RGB: - png_ptr->usr_channels = 4; - break; - - case PNG_COLOR_TYPE_GRAY: - if (png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - break; - } - - else - { - /* There simply isn't any code in libpng to strip out bits - * from bytes when the components are less than a byte in - * size! - */ - png_app_error(png_ptr, - "png_set_filler is invalid for low bit depth gray output"); - return; - } - - default: - png_app_error(png_ptr, - "png_set_filler: inappropriate color type"); - return; - } -# else - png_app_error(png_ptr, "png_set_filler not supported on write"); - return; -# endif - } - - /* Here on success - libpng supports the operation, set the transformation - * and the flag to say where the filler channel is. - */ + png_debug(1, "in png_set_filler\n"); png_ptr->transformations |= PNG_FILLER; - + png_ptr->filler = (png_byte)filler; if (filler_loc == PNG_FILLER_AFTER) png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; + + /* This should probably go in the "do_read_filler" routine. + * I attempted to do that in libpng-1.0.1a but that caused problems + * so I restored it in libpng-1.0.2a + */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_ptr->usr_channels = 4; + } + + /* Also I added this in libpng-1.0.2a (what happens when we expand + * a less-than-8-bit grayscale to GA? */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) + { + png_ptr->usr_channels = 2; + } } +#if !defined(PNG_1_0_X) /* Added to libpng-1.2.7 */ void PNGAPI -png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc) +png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_add_alpha"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_add_alpha\n"); png_set_filler(png_ptr, filler, filler_loc); - /* The above may fail to do anything. */ - if (png_ptr->transformations & PNG_FILLER) - png_ptr->transformations |= PNG_ADD_ALPHA; + png_ptr->transformations |= PNG_ADD_ALPHA; } +#endif #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void PNGAPI -png_set_swap_alpha(png_structrp png_ptr) +png_set_swap_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_swap_alpha"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_swap_alpha\n"); png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif @@ -231,43 +145,38 @@ png_set_swap_alpha(png_structrp png_ptr) #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void PNGAPI -png_set_invert_alpha(png_structrp png_ptr) +png_set_invert_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_invert_alpha"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_invert_alpha\n"); png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) void PNGAPI -png_set_invert_mono(png_structrp png_ptr) +png_set_invert_mono(png_structp png_ptr) { - png_debug(1, "in png_set_invert_mono"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_invert_mono\n"); png_ptr->transformations |= PNG_INVERT_MONO; } -/* Invert monochrome grayscale data */ +/* invert monochrome grayscale data */ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_invert"); - + png_debug(1, "in png_do_invert\n"); /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row == NULL || row_info == NULL) + return; +#endif if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_bytep rp = row; - png_size_t i; - png_size_t istop = row_info->rowbytes; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; for (i = 0; i < istop; i++) { @@ -275,49 +184,47 @@ png_do_invert(png_row_infop row_info, png_bytep row) rp++; } } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 8) { png_bytep rp = row; - png_size_t i; - png_size_t istop = row_info->rowbytes; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; - for (i = 0; i < istop; i += 2) + for (i = 0; i < istop; i+=2) { *rp = (png_byte)(~(*rp)); - rp += 2; + rp+=2; } } - -#ifdef PNG_16BIT_SUPPORTED else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 16) { png_bytep rp = row; - png_size_t i; - png_size_t istop = row_info->rowbytes; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; - for (i = 0; i < istop; i += 4) + for (i = 0; i < istop; i+=4) { *rp = (png_byte)(~(*rp)); - *(rp + 1) = (png_byte)(~(*(rp + 1))); - rp += 4; + *(rp+1) = (png_byte)(~(*(rp+1))); + rp+=4; } } -#endif } #endif -#ifdef PNG_16BIT_SUPPORTED #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swaps byte order on 16 bit depth images */ +/* swaps byte order on 16 bit depth images */ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_swap"); - - if (row_info->bit_depth == 16) + png_debug(1, "in png_do_swap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; @@ -332,10 +239,9 @@ png_do_swap(png_row_infop row_info, png_bytep row) } } #endif -#endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static PNG_CONST png_byte onebppswaptable[256] = { +static png_byte onebppswaptable[256] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, @@ -370,7 +276,7 @@ static PNG_CONST png_byte onebppswaptable[256] = { 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; -static PNG_CONST png_byte twobppswaptable[256] = { +static png_byte twobppswaptable[256] = { 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, @@ -405,7 +311,7 @@ static PNG_CONST png_byte twobppswaptable[256] = { 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF }; -static PNG_CONST png_byte fourbppswaptable[256] = { +static png_byte fourbppswaptable[256] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, @@ -440,28 +346,27 @@ static PNG_CONST png_byte fourbppswaptable[256] = { 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF }; -/* Swaps pixel packing order within bytes */ +/* swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_packswap"); - - if (row_info->bit_depth < 8) + png_debug(1, "in png_do_packswap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth < 8) { - png_bytep rp; - png_const_bytep end, table; + png_bytep rp, end, table; end = row + row_info->rowbytes; if (row_info->bit_depth == 1) table = onebppswaptable; - else if (row_info->bit_depth == 2) table = twobppswaptable; - else if (row_info->bit_depth == 4) table = fourbppswaptable; - else return; @@ -473,130 +378,168 @@ png_do_packswap(png_row_infop row_info, png_bytep row) #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* Remove a channel - this used to be 'png_do_strip_filler' but it used a - * somewhat weird combination of flags to determine what to do. All the calls - * to png_do_strip_filler are changed in 1.5.2 to call this instead with the - * correct arguments. - * - * The routine isn't general - the channel must be the channel at the start or - * end (not in the middle) of each pixel. - */ +/* remove filler or alpha byte(s) */ void /* PRIVATE */ -png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) +png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { - png_bytep sp = row; /* source pointer */ - png_bytep dp = row; /* destination pointer */ - png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */ - - /* At the start sp will point to the first byte to copy and dp to where - * it is copied to. ep always points just beyond the end of the row, so - * the loop simply copies (channels-1) channels until sp reaches ep. - * - * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. - * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc. - */ - - /* GA, GX, XG cases */ - if (row_info->channels == 2) + png_debug(1, "in png_do_strip_filler\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { - if (row_info->bit_depth == 8) + png_bytep sp=row; + png_bytep dp=row; + png_uint_32 row_width=row_info->width; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB && + row_info->channels == 4) { - if (at_start) /* Skip initial filler */ - ++sp; - else /* Skip initial channel and, for sp, the filler */ - sp += 2, ++dp; - - /* For a 1 pixel wide image there is nothing to do */ - while (sp < ep) - *dp++ = *sp, sp += 2; - - row_info->pixel_depth = 8; - } - - else if (row_info->bit_depth == 16) - { - if (at_start) /* Skip initial filler */ - sp += 2; - else /* Skip initial channel and, for sp, the filler */ - sp += 4, dp += 2; - - while (sp < ep) - *dp++ = *sp++, *dp++ = *sp, sp += 3; - - row_info->pixel_depth = 16; - } - - else - return; /* bad bit depth */ - - row_info->channels = 1; - - /* Finally fix the color type if it records an alpha channel */ - if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - row_info->color_type = PNG_COLOR_TYPE_GRAY; - } - - /* RGBA, RGBX, XRGB cases */ - else if (row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - if (at_start) /* Skip initial filler */ - ++sp; - else /* Skip initial channels and, for sp, the filler */ - sp += 4, dp += 3; - - /* Note that the loop adds 3 to dp and 4 to sp each time. */ - while (sp < ep) - *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2; - - row_info->pixel_depth = 24; - } - - else if (row_info->bit_depth == 16) - { - if (at_start) /* Skip initial filler */ - sp += 2; - else /* Skip initial channels and, for sp, the filler */ - sp += 8, dp += 6; - - while (sp < ep) + if (row_info->bit_depth == 8) { - /* Copy 6 bytes, skip 2 */ - *dp++ = *sp++, *dp++ = *sp++; - *dp++ = *sp++, *dp++ = *sp++; - *dp++ = *sp++, *dp++ = *sp, sp += 3; + /* This converts from RGBX or RGBA to RGB */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + dp+=3; sp+=4; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp++; + } + } + /* This converts from XRGB or ARGB to RGB */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ + sp += 8; dp += 6; + for (i = 1; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ - row_info->pixel_depth = 48; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ + for (i = 0; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ + + sp+=2; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 48; + row_info->rowbytes = row_width * 6; + } + row_info->channels = 3; + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY && + row_info->channels == 2) + { + if (row_info->bit_depth == 8) + { + /* This converts from GX or GA to G */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + for (i = 0; i < row_width; i++) + { + *dp++ = *sp++; + sp++; + } + } + /* This converts from XG or AG to G */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from GGXX or GGAA to GG */ + sp += 4; dp += 2; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXGG or AAGG to GG */ + for (i = 0; i < row_width; i++) + { + sp += 2; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + row_info->channels = 1; } - - else - return; /* bad bit depth */ - - row_info->channels = 3; - - /* Finally fix the color type if it records an alpha channel */ - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - row_info->color_type = PNG_COLOR_TYPE_RGB; } - - else - return; /* The filler channel has gone already */ - - /* Fix the rowbytes value. */ - row_info->rowbytes = dp-row; } #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Swaps red and blue bytes within a pixel */ +/* swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_bgr"); - - if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_bgr\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) @@ -613,7 +556,6 @@ png_do_bgr(png_row_infop row_info, png_bytep row) *(rp + 2) = save; } } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; @@ -627,8 +569,6 @@ png_do_bgr(png_row_infop row_info, png_bytep row) } } } - -#ifdef PNG_16BIT_SUPPORTED else if (row_info->bit_depth == 16) { if (row_info->color_type == PNG_COLOR_TYPE_RGB) @@ -646,7 +586,6 @@ png_do_bgr(png_row_infop row_info, png_bytep row) *(rp + 5) = save; } } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; @@ -663,139 +602,27 @@ png_do_bgr(png_row_infop row_info, png_bytep row) } } } -#endif } } #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ -#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ - defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) -/* Added at libpng-1.5.10 */ -void /* PRIVATE */ -png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) -{ - if (png_ptr->num_palette < (1 << row_info->bit_depth) && - png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ - { - /* Calculations moved outside switch in an attempt to stop different - * compiler warnings. 'padding' is in *bits* within the last byte, it is - * an 'int' because pixel_depth becomes an 'int' in the expression below, - * and this calculation is used because it avoids warnings that other - * forms produced on either GCC or MSVC. - */ - int padding = (-row_info->pixel_depth * row_info->width) & 7; - png_bytep rp = png_ptr->row_buf + row_info->rowbytes; - - switch (row_info->bit_depth) - { - case 1: - { - /* in this case, all bytes must be 0 so we don't need - * to unpack the pixels except for the rightmost one. - */ - for (; rp > png_ptr->row_buf; rp--) - { - if (*rp >> padding != 0) - png_ptr->num_palette_max = 1; - padding = 0; - } - - break; - } - - case 2: - { - for (; rp > png_ptr->row_buf; rp--) - { - int i = ((*rp >> padding) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 2) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 4) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 6) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - padding = 0; - } - - break; - } - - case 4: - { - for (; rp > png_ptr->row_buf; rp--) - { - int i = ((*rp >> padding) & 0x0f); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 4) & 0x0f); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - padding = 0; - } - - break; - } - - case 8: - { - for (; rp > png_ptr->row_buf; rp--) - { - if (*rp > png_ptr->num_palette_max) - png_ptr->num_palette_max = (int) *rp; - } - - break; - } - - default: - break; - } - } -} -#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */ - #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) void PNGAPI -png_set_user_transform_info(png_structrp png_ptr, png_voidp +png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { - png_debug(1, "in png_set_user_transform_info"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) - { - png_app_error(png_ptr, - "info change after png_start_read_image or png_read_update_info"); - return; - } -#endif - + png_debug(1, "in png_set_user_transform_info\n"); +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; +#else + if(user_transform_ptr || user_transform_depth || user_transform_channels) + png_warning(png_ptr, + "This version of libpng does not support user transform info"); +#endif } #endif @@ -804,38 +631,14 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp * associated with this pointer before png_write_destroy and png_read_destroy * are called. */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED png_voidp PNGAPI -png_get_user_transform_ptr(png_const_structrp png_ptr) +png_get_user_transform_ptr(png_structp png_ptr) { - if (png_ptr == NULL) - return (NULL); - - return png_ptr->user_transform_ptr; -} +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + return ((png_voidp)png_ptr->user_transform_ptr); +#else + if(png_ptr) + return (NULL); + return (NULL); #endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -png_uint_32 PNGAPI -png_get_current_row_number(png_const_structrp png_ptr) -{ - /* See the comments in png.h - this is the sub-image row when reading and - * interlaced image. - */ - if (png_ptr != NULL) - return png_ptr->row_number; - - return PNG_UINT_32_MAX; /* help the app not to fail silently */ } - -png_byte PNGAPI -png_get_current_pass_number(png_const_structrp png_ptr) -{ - if (png_ptr != NULL) - return png_ptr->pass; - return 8; /* invalid */ -} -#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */ -#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED || - PNG_WRITE_USER_TRANSFORM_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngvcrd.c b/Source/3rd Party/wx/src/png/pngvcrd.c new file mode 100644 index 000000000..b6fea2e35 --- /dev/null +++ b/Source/3rd Party/wx/src/png/pngvcrd.c @@ -0,0 +1,3903 @@ +/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file + * + * For Intel x86 CPU and Microsoft Visual C++ compiler + * + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson + * Copyright (c) 1998, Intel Corporation + * + * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 + * Interface to libpng contributed by Gilles Vollant, 1999 + * + * + * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, + * a sign error in the post-MMX cleanup code for each pixel_depth resulted + * in bad pixels at the beginning of some rows of some images, and also + * (due to out-of-range memory reads and writes) caused heap corruption + * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. + * + * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] + * + * [runtime MMX configuration, GRR 20010102] + * + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) + +static int mmx_supported=2; + + +int PNGAPI +png_mmx_support(void) +{ + int mmx_supported_local = 0; + _asm { + push ebx /*CPUID will trash these */ + push ecx + push edx + + pushfd /*Save Eflag to stack */ + pop eax /*Get Eflag from stack into eax */ + mov ecx, eax /*Make another copy of Eflag in ecx */ + xor eax, 0x200000 /*Toggle ID bit in Eflag [i.e. bit(21)] */ + push eax /*Save modified Eflag back to stack */ + + popfd /*Restored modified value back to Eflag reg */ + pushfd /*Save Eflag to stack */ + pop eax /*Get Eflag from stack */ + push ecx /* save original Eflag to stack */ + popfd /* restore original Eflag */ + xor eax, ecx /*Compare the new Eflag with the original Eflag */ + jz NOT_SUPPORTED /*If the same, CPUID instruction is not supported, */ + /*skip following instructions and jump to */ + /*NOT_SUPPORTED label */ + + xor eax, eax /*Set eax to zero */ + + _asm _emit 0x0f /*CPUID instruction (two bytes opcode) */ + _asm _emit 0xa2 + + cmp eax, 1 /*make sure eax return non-zero value */ + jl NOT_SUPPORTED /*If eax is zero, mmx not supported */ + + xor eax, eax /*set eax to zero */ + inc eax /*Now increment eax to 1. This instruction is */ + /*faster than the instruction "mov eax, 1" */ + + _asm _emit 0x0f /*CPUID instruction */ + _asm _emit 0xa2 + + and edx, 0x00800000 /*mask out all bits but mmx bit(24) */ + cmp edx, 0 /* 0 = mmx not supported */ + jz NOT_SUPPORTED /* non-zero = Yes, mmx IS supported */ + + mov mmx_supported_local, 1 /*set return value to 1 */ + +NOT_SUPPORTED: + mov eax, mmx_supported_local /*move return value to eax */ + pop edx /*CPUID trashed these */ + pop ecx + pop ebx + } + + /*mmx_supported_local=0; // test code for force don't support MMX */ + /*printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); */ + + mmx_supported = mmx_supported_local; + return mmx_supported_local; +} + +/* Combines the row recently read in with the previous row. + This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined; a + zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ + +/* Use this routine for x86 platform - uses faster MMX routine if machine + supports MMX */ + +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_combine_row_asm\n"); + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + + if (mask == 0xff) + { + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->width)); + } + /* GRR: add "else if (mask == 0)" case? + * or does png_combine_row() not even get called in that case? */ + else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp; + png_bytep dp; + int s_inc, s_start, s_end; + int m; + int shift; + png_uint_32 i; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x1; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 2: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x3; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 4: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 8: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int m; + int diff, unmask; + + __int64 mask0=0x0102040810204080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + m = 0x80; + unmask = ~mask; + len = png_ptr->width &~7; /*reduce to multiple of 8 */ + diff = png_ptr->width & 7; /*amount lost */ + + _asm + { + movd mm7, unmask /*load bit pattern */ + psubb mm6,mm6 /*zero mm6 */ + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 /*fill register with 8 masks */ + + movq mm0,mask0 + + pand mm0,mm7 /*nonzero if keep byte */ + pcmpeqb mm0,mm6 /*zeros->1s, v versa */ + + mov ecx,len /*load length of line (pixels) */ + mov esi,srcptr /*load source */ + mov ebx,dstptr /*load dest */ + cmp ecx,0 /*lcr */ + je mainloop8end + +mainloop8: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm4,mm6 + movq [ebx],mm4 + + add esi,8 /*inc by 8 bytes processed */ + add ebx,8 + sub ecx,8 /*dec by 8 pixels processed */ + + ja mainloop8 +mainloop8end: + + mov ecx,diff + cmp ecx,0 + jz end8 + + mov edx,mask + sal edx,24 /*make low byte the high byte */ + +secondloop8: + sal edx,1 /*move high bit to CF */ + jnc skip8 /*if CF = 0 */ + mov al,[esi] + mov [ebx],al +skip8: + inc esi + inc ebx + + dec ecx + jnz secondloop8 +end8: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } /* end 8 bpp */ + + case 16: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + __int64 mask1=0x0101020204040808, + mask0=0x1010202040408080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask /*load bit pattern */ + psubb mm6,mm6 /*zero mm6 */ + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 /*fill register with 8 masks */ + + movq mm0,mask0 + movq mm1,mask1 + + pand mm0,mm7 + pand mm1,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + + mov ecx,len /*load length of line */ + mov esi,srcptr /*load source */ + mov ebx,dstptr /*load dest */ + cmp ecx,0 /*lcr */ + jz mainloop16end + +mainloop16: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + add esi,16 /*inc by 16 bytes processed */ + add ebx,16 + sub ecx,8 /*dec by 8 pixels processed */ + + ja mainloop16 + +mainloop16end: + mov ecx,diff + cmp ecx,0 + jz end16 + + mov edx,mask + sal edx,24 /*make low byte the high byte */ +secondloop16: + sal edx,1 /*move high bit to CF */ + jnc skip16 /*if CF = 0 */ + mov ax,[esi] + mov [ebx],ax +skip16: + add esi,2 + add ebx,2 + + dec ecx + jnz secondloop16 +end16: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } /* end 16 bpp */ + + case 24: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask2=0x0101010202020404, /*24bpp */ + mask1=0x0408080810101020, + mask0=0x2020404040808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + _asm + { + movd mm7, unmask /*load bit pattern */ + psubb mm6,mm6 /*zero mm6 */ + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 /*fill register with 8 masks */ + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + + mov ecx,len /*load length of line */ + mov esi,srcptr /*load source */ + mov ebx,dstptr /*load dest */ + cmp ecx,0 + jz mainloop24end + +mainloop24: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + add esi,24 /*inc by 24 bytes processed */ + add ebx,24 + sub ecx,8 /*dec by 8 pixels processed */ + + ja mainloop24 + +mainloop24end: + mov ecx,diff + cmp ecx,0 + jz end24 + + mov edx,mask + sal edx,24 /*make low byte the high byte */ +secondloop24: + sal edx,1 /*move high bit to CF */ + jnc skip24 /*if CF = 0 */ + mov ax,[esi] + mov [ebx],ax + xor eax,eax + mov al,[esi+2] + mov [ebx+2],al +skip24: + add esi,3 + add ebx,3 + + dec ecx + jnz secondloop24 + +end24: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } /* end 24 bpp */ + + case 32: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask3=0x0101010102020202, /*32bpp */ + mask2=0x0404040408080808, + mask1=0x1010101020202020, + mask0=0x4040404080808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + _asm + { + movd mm7, unmask /*load bit pattern */ + psubb mm6,mm6 /*zero mm6 */ + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 /*fill register with 8 masks */ + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + + mov ecx,len /*load length of line */ + mov esi,srcptr /*load source */ + mov ebx,dstptr /*load dest */ + + cmp ecx,0 /*lcr */ + jz mainloop32end + +mainloop32: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm5,mm3 + movq mm4,[ebx+24] + pandn mm5,mm4 + por mm7,mm5 + movq [ebx+24],mm7 + + add esi,32 /*inc by 32 bytes processed */ + add ebx,32 + sub ecx,8 /*dec by 8 pixels processed */ + + ja mainloop32 + +mainloop32end: + mov ecx,diff + cmp ecx,0 + jz end32 + + mov edx,mask + sal edx,24 /*make low byte the high byte */ +secondloop32: + sal edx,1 /*move high bit to CF */ + jnc skip32 /*if CF = 0 */ + mov eax,[esi] + mov [ebx],eax +skip32: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop32 + +end32: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } /* end 32 bpp */ + + case 48: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask5=0x0101010101010202, + mask4=0x0202020204040404, + mask3=0x0404080808080808, + mask2=0x1010101010102020, + mask1=0x2020202040404040, + mask0=0x4040808080808080; + +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask /*load bit pattern */ + psubb mm6,mm6 /*zero mm6 */ + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 /*fill register with 8 masks */ + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + movq mm4,mask4 + movq mm5,mask5 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + pand mm4,mm7 + pand mm5,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + pcmpeqb mm4,mm6 + pcmpeqb mm5,mm6 + + mov ecx,len /*load length of line */ + mov esi,srcptr /*load source */ + mov ebx,dstptr /*load dest */ + + cmp ecx,0 + jz mainloop48end + +mainloop48: + movq mm7,[esi] + pand mm7,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm7,mm6 + movq [ebx],mm7 + + movq mm6,[esi+8] + pand mm6,mm1 + movq mm7,mm1 + pandn mm7,[ebx+8] + por mm6,mm7 + movq [ebx+8],mm6 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm7,mm2 + pandn mm7,[ebx+16] + por mm6,mm7 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm6,mm3 + pandn mm6,[ebx+24] + por mm7,mm6 + movq [ebx+24],mm7 + + movq mm6,[esi+32] + pand mm6,mm4 + movq mm7,mm4 + pandn mm7,[ebx+32] + por mm6,mm7 + movq [ebx+32],mm6 + + movq mm7,[esi+40] + pand mm7,mm5 + movq mm6,mm5 + pandn mm6,[ebx+40] + por mm7,mm6 + movq [ebx+40],mm7 + + add esi,48 /*inc by 32 bytes processed */ + add ebx,48 + sub ecx,8 /*dec by 8 pixels processed */ + + ja mainloop48 +mainloop48end: + + mov ecx,diff + cmp ecx,0 + jz end48 + + mov edx,mask + sal edx,24 /*make low byte the high byte */ + +secondloop48: + sal edx,1 /*move high bit to CF */ + jnc skip48 /*if CF = 0 */ + mov eax,[esi] + mov [ebx],eax +skip48: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop48 + +end48: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } /* end 48 bpp */ + + default: + { + png_bytep sptr; + png_bytep dp; + png_size_t pixel_bytes; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + unsigned int i; + register int disp = png_pass_inc[png_ptr->pass]; /* get the offset */ + register unsigned int incr1, initial_val, final_val; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dp = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dp, sptr, pixel_bytes); + sptr += incr1; + dp += incr1; + } + break; + } + } /* end switch (png_ptr->row_info.pixel_depth) */ + } /* end if (non-trivial mask) */ + +} /* end png_combine_row() */ + + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; + png_uint_32 transformations = png_ptr->transformations; +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_do_read_interlace\n"); + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_byte v; + png_uint_32 i; + int j; + + sp = row + (png_size_t)((row_info->width - 1) >> 3); + dp = row + (png_size_t)((final_width - 1) >> 3); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 7); + dshift = (int)((final_width + 7) & 7); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 7); + dshift = 7 - (int)((final_width + 7) & 7); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = row_info->width; i; i--) + { + v = (png_byte)((*sp >> sshift) & 0x1); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 2: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 2); + dp = row + (png_size_t)((final_width - 1) >> 2); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); + dshift = (png_size_t)(((final_width + 3) & 3) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 4: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 1); + dp = row + (png_size_t)((final_width - 1) >> 1); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); + dshift = (png_size_t)(((final_width + 1) & 1) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0xf); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + default: /* This is the place where the routine is modified */ + { + __int64 const4 = 0x0000000000FFFFFF; + /* __int64 const5 = 0x000000FFFFFF0000; // unused... */ + __int64 const6 = 0x00000000000000FF; + png_bytep sptr, dp; + png_uint_32 i; + png_size_t pixel_bytes; + int width = row_info->width; + + pixel_bytes = (row_info->pixel_depth >> 3); + + sptr = row + (width - 1) * pixel_bytes; + dp = row + (final_width - 1) * pixel_bytes; + /* New code by Nirav Chhatrapati - Intel Corporation */ + /* sign fix by GRR */ + /* NOTE: there is NO MMX code for 48-bit and 64-bit images */ + + // use MMX routine if machine supports it +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && mmx_supported */ ) +#else + if (mmx_supported) +#endif + { + if (pixel_bytes == 3) + { + if (((pass == 0) || (pass == 1)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 21 /* (png_pass_inc[pass] - 1)*pixel_bytes */ +loop_pass0: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 + psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 + movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 + punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 + movq [edi+16] , mm4 + psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 + movq [edi+8] , mm3 + punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 + sub esi, 3 + movq [edi], mm0 + sub edi, 24 + /*sub esi, 3 */ + dec ecx + jnz loop_pass0 + EMMS + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 9 /* (png_pass_inc[pass] - 1)*pixel_bytes */ +loop_pass2: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq [edi+4], mm0 ; move to memory + psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 + movd [edi], mm0 ; move to memory + sub esi, 3 + sub edi, 12 + dec ecx + jnz loop_pass2 + EMMS + } + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 1) << 1) - 8; + if (width_mmx < 0) + width_mmx = 0; + width -= width_mmx; /* 8 or 9 pix, 24 or 27 bytes */ + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 3 + sub edi, 9 +loop_pass4: + movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 + movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 + movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 + psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 + pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 + psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 + por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 + movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 + psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 + movq [edi], mm0 ; move quad to memory + psrlq mm5, 16 ; 0 0 0 0 0 X X v2 + pand mm5, const6 ; 0 0 0 0 0 0 0 v2 + por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 + movd [edi+8], mm6 ; move double to memory + sub esi, 6 + sub edi, 12 + sub ecx, 2 + jnz loop_pass4 + EMMS + } + } + + sptr -= width_mmx*3; + dp -= width_mmx*6; + for (i = width; i; i--) + { + png_byte v[8]; + int j; + + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + } /* end of pixel_bytes == 3 */ + + else if (pixel_bytes == 1) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 31 + sub esi, 3 +loop1_pass0: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + movq mm1, mm0 ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 + punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 + movq [edi], mm0 ; move to memory v3 + punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi+8], mm3 ; move to memory v2 + movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 + punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 + movq [edi+16], mm2 ; move to memory v1 + movq [edi+24], mm4 ; move to memory v0 + sub esi, 4 + sub edi, 32 + sub ecx, 4 + jnz loop1_pass0 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*8; + for (i = width; i; i--) + { + int j; + + /* I simplified this part in version 1.0.4e + * here and in several other instances where + * pixel_bytes == 1 -- GR-P + * + * Original code: + * + * png_byte v[8]; + * png_memcpy(v, sptr, pixel_bytes); + * for (j = 0; j < png_pass_inc[pass]; j++) + * { + * png_memcpy(dp, v, pixel_bytes); + * dp -= pixel_bytes; + * } + * sptr -= pixel_bytes; + * + * Replacement code is in the next three lines: + */ + + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 3 +loop1_pass2: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi], mm0 ; move to memory v2 and v3 + sub esi, 4 + movq [edi+8], mm1 ; move to memory v1 and v0 + sub edi, 16 + sub ecx, 4 + jnz loop1_pass2 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*4; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + else if (width) /* && ((pass == 4) || (pass == 5))) */ + { + int width_mmx = ((width >> 3) << 3); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 7 +loop1_pass4: + movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 + movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 + punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 + /*movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 */ + punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 + movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 + sub esi, 8 + movq [edi], mm0 ; move to memory v4 v5 v6 and v7 + /*sub esi, 4 */ + sub edi, 16 + sub ecx, 8 + jnz loop1_pass4 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*2; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + } /* end of pixel_bytes == 1 */ + + else if (pixel_bytes == 2) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 30 +loop2_pass0: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm1 + movq [edi + 24], mm1 + sub esi, 4 + sub edi, 32 + sub ecx, 2 + jnz loop2_pass0 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*16 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 14 +loop2_pass2: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + sub esi, 4 + movq [edi + 8], mm1 + /*sub esi, 4 */ + sub edi, 16 + sub ecx, 2 + jnz loop2_pass2 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*8 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (width) /* pass == 4 or 5 */ + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 6 +loop2_pass4: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + sub esi, 4 + movq [edi], mm0 + sub edi, 8 + sub ecx, 2 + jnz loop2_pass4 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); /* sign fixed */ + dp -= (width_mmx*4 - 2); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + } /* end of pixel_bytes == 2 */ + + else if (pixel_bytes == 4) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 60 +loop4_pass0: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm0 + movq [edi + 24], mm0 + movq [edi+32], mm1 + movq [edi + 40], mm1 + movq [edi+ 48], mm1 + sub esi, 8 + movq [edi + 56], mm1 + sub edi, 64 + sub ecx, 2 + jnz loop4_pass0 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*32 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 28 +loop4_pass2: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi+16], mm1 + movq [edi + 24], mm1 + sub esi, 8 + sub edi, 32 + sub ecx, 2 + jnz loop4_pass2 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*16 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (width) /* pass == 4 or 5 */ + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 12 +loop4_pass4: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + sub esi, 8 + movq [edi + 8], mm1 + sub edi, 16 + sub ecx, 2 + jnz loop4_pass4 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); /* sign fixed */ + dp -= (width_mmx*8 - 4); /* sign fixed */ + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + + } /* end of pixel_bytes == 4 */ + + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } /* end of pixel_bytes == 6 */ + + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr-= pixel_bytes; + } + } + } /* end of mmx_supported */ + + else /* MMX not supported: use modified C code - takes advantage + * of inlining of memcpy for a constant */ + { + if (pixel_bytes == 1) + { + for (i = width; i; i--) + { + int j; + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (pixel_bytes == 3) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 2) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 4) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + + } /* end of MMX not supported */ + break; + } + } /* end switch (row_info->pixel_depth) */ + + row_info->width = final_width; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + } + +} + +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + +/* These variables are utilized in the functions below. They are declared */ +/* globally here to ensure alignment on 8-byte boundaries. */ + +union uAll { + __int64 use; + double align; +} LBCarryMask = {0x0101010101010101}, + HBClearMask = {0x7f7f7f7f7f7f7f7f}, + ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; + + +/* Optimized code for PNG Average filter decoder */ +void /* PRIVATE */ +png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row + , png_bytep prev_row) +{ + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + /*png_uint_32 len; */ + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; /* Get # bytes per pixel */ + FullLength = row_info->rowbytes; /* # of bytes to filter */ + _asm { + /* Init address pointers and offset */ + mov edi, row /* edi ==> Avg(x) */ + xor ebx, ebx /* ebx ==> x */ + mov edx, edi + mov esi, prev_row /* esi ==> Prior(x) */ + sub edx, bpp /* edx ==> Raw(x-bpp) */ + + xor eax, eax + /* Compute the Raw value for the first bpp bytes */ + /* Raw(x) = Avg(x) + (Prior(x)/2) */ +davgrlp: + mov al, [esi + ebx] /* Load al with Prior(x) */ + inc ebx + shr al, 1 /* divide by 2 */ + add al, [edi+ebx-1] /* Add Avg(x); -1 to offset inc ebx */ + cmp ebx, bpp + mov [edi+ebx-1], al /* Write back Raw(x); */ + /* mov does not affect flags; -1 to offset inc ebx */ + jb davgrlp + /* get # of bytes to alignment */ + mov diff, edi /* take start of row */ + add diff, ebx /* add bpp */ + add diff, 0xf /* add 7 + 8 to incr past alignment boundary */ + and diff, 0xfffffff8 /* mask to alignment boundary */ + sub diff, edi /* subtract from start ==> value ebx at alignment */ + jz davggo + /* fix alignment */ + /* Compute the Raw value for the bytes upto the alignment boundary */ + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + xor ecx, ecx +davglp1: + xor eax, eax + mov cl, [esi + ebx] /* load cl with Prior(x) */ + mov al, [edx + ebx] /* load al with Raw(x-bpp) */ + add ax, cx + inc ebx + shr ax, 1 /* divide by 2 */ + add al, [edi+ebx-1] /* Add Avg(x); -1 to offset inc ebx */ + cmp ebx, diff /* Check if at alignment boundary */ + mov [edi+ebx-1], al /* Write back Raw(x); */ + /* mov does not affect flags; -1 to offset inc ebx */ + jb davglp1 /* Repeat until at alignment boundary */ +davggo: + mov eax, FullLength + mov ecx, eax + sub eax, ebx /* subtract alignment fix */ + and eax, 0x00000007 /* calc bytes over mult of 8 */ + sub ecx, eax /* drop over bytes from original length */ + mov MMXLength, ecx + } /* end _asm block */ + /* Now do the math for the rest of the row */ + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ShiftBpp.use = 24; /* == 3 * 8 */ + ShiftRem.use = 40; /* == 64 - 24 */ + _asm { + /* Re-init address pointers and offset */ + movq mm7, ActiveMask + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + movq mm5, LBCarryMask + mov edi, row /* edi ==> Avg(x) */ + movq mm4, HBClearMask + mov esi, prev_row /* esi ==> Prior(x) */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm2, [edi + ebx - 8] /* Load previous aligned 8 bytes */ + /* (we correct position in loop below) */ +davg3lp: + movq mm0, [edi + ebx] /* Load mm0 with Avg(x) */ + /* Add (Prev_row/2) to Average */ + movq mm3, mm5 + psrlq mm2, ShiftRem /* Correct position Raw(x-bpp) data */ + movq mm1, [esi + ebx] /* Load mm1 with Prior(x) */ + movq mm6, mm7 + pand mm3, mm1 /* get lsb for each prev_row byte */ + psrlq mm1, 1 /* divide prev_row bytes by 2 */ + pand mm1, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm1 /* add (Prev_row/2) to Avg for each byte */ + /* Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 1 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active */ + /* byte */ + /* Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry */ + psllq mm6, ShiftBpp /* shift the mm6 mask to cover bytes 3-5 */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active */ + /* byte */ + + /* Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry */ + psllq mm6, ShiftBpp /* shift the mm6 mask to cover the last two */ + /* bytes */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + /* Data only needs to be shifted once here to */ + /* get the correct x-bpp offset. */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + add ebx, 8 + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active */ + /* byte */ + + /* Now ready to write back to memory */ + movq [edi + ebx - 8], mm0 + /* Move updated Raw(x) to use as Raw(x-bpp) for next loop */ + cmp ebx, MMXLength + movq mm2, mm0 /* mov updated Raw(x) to mm2 */ + jb davg3lp + } /* end _asm block */ + } + break; + + case 6: + case 4: + case 7: + case 5: + { + ActiveMask.use = 0xffffffffffffffff; /* use shift below to clear */ + /* appropriate inactive bytes */ + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + movq mm4, HBClearMask + /* Re-init address pointers and offset */ + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + /* Load ActiveMask and clear all bytes except for 1st active group */ + movq mm7, ActiveMask + mov edi, row /* edi ==> Avg(x) */ + psrlq mm7, ShiftRem + mov esi, prev_row /* esi ==> Prior(x) */ + movq mm6, mm7 + movq mm5, LBCarryMask + psllq mm6, ShiftBpp /* Create mask for 2nd active group */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm2, [edi + ebx - 8] /* Load previous aligned 8 bytes */ + /* (we correct position in loop below) */ +davg4lp: + movq mm0, [edi + ebx] + psrlq mm2, ShiftRem /* shift data to position correctly */ + movq mm1, [esi + ebx] + /* Add (Prev_row/2) to Average */ + movq mm3, mm5 + pand mm3, mm1 /* get lsb for each prev_row byte */ + psrlq mm1, 1 /* divide prev_row bytes by 2 */ + pand mm1, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm1 /* add (Prev_row/2) to Avg for each byte */ + /* Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm7 /* Leave only Active Group 1 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active */ + /* byte */ + /* Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + add ebx, 8 + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active */ + /* byte */ + cmp ebx, MMXLength + /* Now ready to write back to memory */ + movq [edi + ebx - 8], mm0 + /* Prep Raw(x-bpp) for next loop */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + jb davg4lp + } /* end _asm block */ + } + break; + case 2: + { + ActiveMask.use = 0x000000000000ffff; + ShiftBpp.use = 16; /* == 2 * 8 [BUGFIX] */ + ShiftRem.use = 48; /* == 64 - 16 [BUGFIX] */ + _asm { + /* Load ActiveMask */ + movq mm7, ActiveMask + /* Re-init address pointers and offset */ + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + movq mm5, LBCarryMask + mov edi, row /* edi ==> Avg(x) */ + movq mm4, HBClearMask + mov esi, prev_row /* esi ==> Prior(x) */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm2, [edi + ebx - 8] /* Load previous aligned 8 bytes */ + /* (we correct position in loop below) */ +davg2lp: + movq mm0, [edi + ebx] + psrlq mm2, ShiftRem /* shift data to position correctly [BUGFIX] */ + movq mm1, [esi + ebx] + /* Add (Prev_row/2) to Average */ + movq mm3, mm5 + pand mm3, mm1 /* get lsb for each prev_row byte */ + psrlq mm1, 1 /* divide prev_row bytes by 2 */ + pand mm1, mm4 /* clear invalid bit 7 of each byte */ + movq mm6, mm7 + paddb mm0, mm1 /* add (Prev_row/2) to Avg for each byte */ + /* Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 1 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active byte */ + /* Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry */ + psllq mm6, ShiftBpp /* shift the mm6 mask to cover bytes 2 & 3 */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active byte */ + + /* Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry */ + psllq mm6, ShiftBpp /* shift the mm6 mask to cover bytes 4 & 5 */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + /* Data only needs to be shifted once here to */ + /* get the correct x-bpp offset. */ + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active byte */ + + /* Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry */ + psllq mm6, ShiftBpp /* shift the mm6 mask to cover bytes 6 & 7 */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + psllq mm2, ShiftBpp /* shift data to position correctly */ + /* Data only needs to be shifted once here to */ + /* get the correct x-bpp offset. */ + add ebx, 8 + movq mm1, mm3 /* now use mm1 for getting LBCarrys */ + pand mm1, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 (Only valid for active group) */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm2, mm1 /* add LBCarrys to (Raw(x-bpp)/2) for each byte */ + pand mm2, mm6 /* Leave only Active Group 2 bytes to add to Avg */ + paddb mm0, mm2 /* add (Raw/2) + LBCarrys to Avg for each Active byte */ + + cmp ebx, MMXLength + /* Now ready to write back to memory */ + movq [edi + ebx - 8], mm0 + /* Prep Raw(x-bpp) for next loop */ + movq mm2, mm0 /* mov updated Raws to mm2 */ + jb davg2lp + } /* end _asm block */ + } + break; + + case 1: /* bpp == 1 */ + { + _asm { + /* Re-init address pointers and offset */ + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + mov edi, row /* edi ==> Avg(x) */ + cmp ebx, FullLength /* Test if offset at end of array */ + jnb davg1end + /* Do Paeth decode for remaining bytes */ + mov esi, prev_row /* esi ==> Prior(x) */ + mov edx, edi + xor ecx, ecx /* zero ecx before using cl & cx in loop below */ + sub edx, bpp /* edx ==> Raw(x-bpp) */ +davg1lp: + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + xor eax, eax + mov cl, [esi + ebx] /* load cl with Prior(x) */ + mov al, [edx + ebx] /* load al with Raw(x-bpp) */ + add ax, cx + inc ebx + shr ax, 1 /* divide by 2 */ + add al, [edi+ebx-1] /* Add Avg(x); -1 to offset inc ebx */ + cmp ebx, FullLength /* Check if at end of array */ + mov [edi+ebx-1], al /* Write back Raw(x); */ + /* mov does not affect flags; -1 to offset inc ebx */ + jb davg1lp +davg1end: + } /* end _asm block */ + } + return; + + case 8: /* bpp == 8 */ + { + _asm { + /* Re-init address pointers and offset */ + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + movq mm5, LBCarryMask + mov edi, row /* edi ==> Avg(x) */ + movq mm4, HBClearMask + mov esi, prev_row /* esi ==> Prior(x) */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm2, [edi + ebx - 8] /* Load previous aligned 8 bytes */ + /* (NO NEED to correct position in loop below) */ +davg8lp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + add ebx, 8 + pand mm3, mm1 /* get lsb for each prev_row byte */ + psrlq mm1, 1 /* divide prev_row bytes by 2 */ + pand mm3, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm1, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm3 /* add LBCarrys to Avg for each byte */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm1 /* add (Prev_row/2) to Avg for each byte */ + paddb mm0, mm2 /* add (Raw/2) to Avg for each byte */ + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + movq mm2, mm0 /* reuse as Raw(x-bpp) */ + jb davg8lp + } /* end _asm block */ + } + break; + default: /* bpp greater than 8 */ + { + _asm { + movq mm5, LBCarryMask + /* Re-init address pointers and offset */ + mov ebx, diff /* ebx ==> x = offset to alignment boundary */ + mov edi, row /* edi ==> Avg(x) */ + movq mm4, HBClearMask + mov edx, edi + mov esi, prev_row /* esi ==> Prior(x) */ + sub edx, bpp /* edx ==> Raw(x-bpp) */ +davgAlp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + pand mm3, mm1 /* get lsb for each prev_row byte */ + movq mm2, [edx + ebx] + psrlq mm1, 1 /* divide prev_row bytes by 2 */ + pand mm3, mm2 /* get LBCarrys for each byte where both */ + /* lsb's were == 1 */ + psrlq mm2, 1 /* divide raw bytes by 2 */ + pand mm1, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm3 /* add LBCarrys to Avg for each byte */ + pand mm2, mm4 /* clear invalid bit 7 of each byte */ + paddb mm0, mm1 /* add (Prev_row/2) to Avg for each byte */ + add ebx, 8 + paddb mm0, mm2 /* add (Raw/2) to Avg for each byte */ + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + jb davgAlp + } /* end _asm block */ + } + break; + } /* end switch ( bpp ) */ + + _asm { + /* MMX acceleration complete now do clean-up */ + /* Check if any remaining bytes left to decode */ + mov ebx, MMXLength /* ebx ==> x = offset bytes remaining after MMX */ + mov edi, row /* edi ==> Avg(x) */ + cmp ebx, FullLength /* Test if offset at end of array */ + jnb davgend + /* Do Paeth decode for remaining bytes */ + mov esi, prev_row /* esi ==> Prior(x) */ + mov edx, edi + xor ecx, ecx /* zero ecx before using cl & cx in loop below */ + sub edx, bpp /* edx ==> Raw(x-bpp) */ +davglp2: + /* Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) */ + xor eax, eax + mov cl, [esi + ebx] /* load cl with Prior(x) */ + mov al, [edx + ebx] /* load al with Raw(x-bpp) */ + add ax, cx + inc ebx + shr ax, 1 /* divide by 2 */ + add al, [edi+ebx-1] /* Add Avg(x); -1 to offset inc ebx */ + cmp ebx, FullLength /* Check if at end of array */ + mov [edi+ebx-1], al /* Write back Raw(x); */ + /* mov does not affect flags; -1 to offset inc ebx */ + jb davglp2 +davgend: + emms /* End MMX instructions; prep for possible FP instrs. */ + } /* end _asm block */ +} + +/* Optimized code for PNG Paeth filter decoder */ +void /* PRIVATE */ +png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 FullLength; + png_uint_32 MMXLength; + /*png_uint_32 len; */ + int bpp; + int diff; + /*int ptemp; */ + int patemp, pbtemp, pctemp; + + bpp = (row_info->pixel_depth + 7) >> 3; /* Get # bytes per pixel */ + FullLength = row_info->rowbytes; /* # of bytes to filter */ + _asm + { + xor ebx, ebx /* ebx ==> x offset */ + mov edi, row + xor edx, edx /* edx ==> x-bpp offset */ + mov esi, prev_row + xor eax, eax + + /* Compute the Raw value for the first bpp bytes */ + /* Note: the formula works out to be always */ + /* Paeth(x) = Raw(x) + Prior(x) where x < bpp */ +dpthrlp: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, bpp + mov [edi + ebx - 1], al + jb dpthrlp + /* get # of bytes to alignment */ + mov diff, edi /* take start of row */ + add diff, ebx /* add bpp */ + xor ecx, ecx + add diff, 0xf /* add 7 + 8 to incr past alignment boundary */ + and diff, 0xfffffff8 /* mask to alignment boundary */ + sub diff, edi /* subtract from start ==> value ebx at alignment */ + jz dpthgo + /* fix alignment */ +dpthlp1: + xor eax, eax + /* pav = p - a = (a + b - c) - a = b - c */ + mov al, [esi + ebx] /* load Prior(x) into al */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov patemp, eax /* Save pav for later use */ + xor eax, eax + /* pbv = p - b = (a + b - c) - b = a - c */ + mov al, [edi + edx] /* load Raw(x-bpp) into al */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov ecx, eax + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + add eax, patemp /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + test eax, 0x80000000 + jz dpthpca + neg eax /* reverse sign of neg values */ +dpthpca: + mov pctemp, eax /* save pc for later use */ + /* pb = abs(pbv) */ + test ecx, 0x80000000 + jz dpthpba + neg ecx /* reverse sign of neg values */ +dpthpba: + mov pbtemp, ecx /* save pb for later use */ + /* pa = abs(pav) */ + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa + neg eax /* reverse sign of neg values */ +dpthpaa: + mov patemp, eax /* save pa for later use */ + /* test if pa <= pb */ + cmp eax, ecx + jna dpthabb + /* pa > pb; now test if pb <= pc */ + cmp ecx, pctemp + jna dpthbbc + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthpaeth +dpthbbc: + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + mov cl, [esi + ebx] /* load Prior(x) into cl */ + jmp dpthpaeth +dpthabb: + /* pa <= pb; now test if pa <= pc */ + cmp eax, pctemp + jna dpthabc + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthpaeth +dpthabc: + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + mov cl, [edi + edx] /* load Raw(x-bpp) into cl */ +dpthpaeth: + inc ebx + inc edx + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + add [edi + ebx - 1], cl + cmp ebx, diff + jb dpthlp1 +dpthgo: + mov ecx, FullLength + mov eax, ecx + sub eax, ebx /* subtract alignment fix */ + and eax, 0x00000007 /* calc bytes over mult of 8 */ + sub ecx, eax /* drop over bytes from original length */ + mov MMXLength, ecx + } /* end _asm block */ + /* Now do the math for the rest of the row */ + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ActiveMaskEnd.use = 0xffff000000000000; + ShiftBpp.use = 24; /* == bpp(3) * 8 */ + ShiftRem.use = 40; /* == 64 - 24 */ + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] +dpth3lp: + psrlq mm1, ShiftRem /* shift last 3 bytes to 1st 3 bytes */ + movq mm2, [esi + ebx] /* load b=Prior(x) */ + punpcklbw mm1, mm0 /* Unpack High bytes of a */ + movq mm3, [esi+ebx-8] /* Prep c=Prior(x-bpp) bytes */ + punpcklbw mm2, mm0 /* Unpack High bytes of b */ + psrlq mm3, ShiftRem /* shift last 3 bytes to 1st 3 bytes */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + punpcklbw mm3, mm0 /* Unpack High bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] /* load c=Prior(x-bpp) */ + pand mm7, ActiveMask + movq mm2, mm3 /* load b=Prior(x) step 1 */ + paddb mm7, [edi + ebx] /* add Paeth predictor with Raw(x) */ + punpcklbw mm3, mm0 /* Unpack High bytes of c */ + movq [edi + ebx], mm7 /* write back updated value */ + movq mm1, mm7 /* Now mm1 will be used as Raw(x-bpp) */ + /* Now do Paeth for 2nd set of bytes (3-5) */ + psrlq mm2, ShiftBpp /* load b=Prior(x) step 2 */ + punpcklbw mm1, mm0 /* Unpack High bytes of a */ + pxor mm7, mm7 + punpcklbw mm2, mm0 /* Unpack High bytes of b */ + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + psubw mm5, mm3 + psubw mm4, mm3 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = */ + /* pav + pbv = pbv + pav */ + movq mm6, mm5 + paddw mm6, mm4 + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm5 /* Create mask pbv bytes < 0 */ + pcmpgtw mm7, mm4 /* Create mask pav bytes < 0 */ + pand mm0, mm5 /* Only pbv bytes < 0 in mm0 */ + pand mm7, mm4 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm0 + psubw mm4, mm7 + psubw mm5, mm0 + psubw mm4, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + movq mm2, [esi + ebx] /* load b=Prior(x) */ + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, mm2 /* load c=Prior(x-bpp) step 1 */ + pand mm7, ActiveMask + punpckhbw mm2, mm0 /* Unpack High bytes of b */ + psllq mm7, ShiftBpp /* Shift bytes to 2nd group of 3 bytes */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + paddb mm7, [edi + ebx] /* add Paeth predictor with Raw(x) */ + psllq mm3, ShiftBpp /* load c=Prior(x-bpp) step 2 */ + movq [edi + ebx], mm7 /* write back updated value */ + movq mm1, mm7 + punpckhbw mm3, mm0 /* Unpack High bytes of c */ + psllq mm1, ShiftBpp /* Shift bytes */ + /* Now mm1 will be used as Raw(x-bpp) */ + /* Now do Paeth for 3rd, and final, set of bytes (6-7) */ + pxor mm7, mm7 + punpckhbw mm1, mm0 /* Unpack High bytes of a */ + psubw mm4, mm3 + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + pxor mm0, mm0 + paddw mm6, mm5 + + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + pandn mm0, mm1 + pandn mm7, mm4 + paddw mm0, mm2 + paddw mm7, mm5 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm1, mm1 + packuswb mm1, mm7 + /* Step ebx to next set of 8 bytes and repeat loop til done */ + add ebx, 8 + pand mm1, ActiveMaskEnd + paddb mm1, [edi + ebx - 8] /* add Paeth predictor with Raw(x) */ + + cmp ebx, MMXLength + pxor mm0, mm0 /* pxor does not affect flags */ + movq [edi + ebx - 8], mm1 /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + /* mm3 ready to be used as Prior(x-bpp) next loop */ + jb dpth3lp + } /* end _asm block */ + } + break; + + case 6: + case 7: + case 5: + { + ActiveMask.use = 0x00000000ffffffff; + ActiveMask2.use = 0xffffffff00000000; + ShiftBpp.use = bpp << 3; /* == bpp * 8 */ + ShiftRem.use = 64 - ShiftBpp.use; + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] + pxor mm0, mm0 +dpth6lp: + /* Must shift to position Raw(x-bpp) data */ + psrlq mm1, ShiftRem + /* Do first set of 4 bytes */ + movq mm3, [esi+ebx-8] /* read c=Prior(x-bpp) bytes */ + punpcklbw mm1, mm0 /* Unpack Low bytes of a */ + movq mm2, [esi + ebx] /* load b=Prior(x) */ + punpcklbw mm2, mm0 /* Unpack Low bytes of b */ + /* Must shift to position Prior(x-bpp) data */ + psrlq mm3, ShiftRem + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + punpcklbw mm3, mm0 /* Unpack Low bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx - 8] /* load c=Prior(x-bpp) */ + pand mm7, ActiveMask + psrlq mm3, ShiftRem + movq mm2, [esi + ebx] /* load b=Prior(x) step 1 */ + paddb mm7, [edi + ebx] /* add Paeth predictor with Raw(x) */ + movq mm6, mm2 + movq [edi + ebx], mm7 /* write back updated value */ + movq mm1, [edi+ebx-8] + psllq mm6, ShiftBpp + movq mm5, mm7 + psrlq mm1, ShiftRem + por mm3, mm6 + psllq mm5, ShiftBpp + punpckhbw mm3, mm0 /* Unpack High bytes of c */ + por mm1, mm5 + /* Do second set of 4 bytes */ + punpckhbw mm2, mm0 /* Unpack High bytes of b */ + punpckhbw mm1, mm0 /* Unpack High bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + /* Step ex to next set of 8 bytes and repeat loop til done */ + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] /* add Paeth predictor with Raw(x) */ + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + jb dpth6lp + } /* end _asm block */ + } + break; + + case 4: + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] /* Only time should need to read */ + /* a=Raw(x-bpp) bytes */ +dpth4lp: + /* Do first set of 4 bytes */ + movq mm3, [esi+ebx-8] /* read c=Prior(x-bpp) bytes */ + punpckhbw mm1, mm0 /* Unpack Low bytes of a */ + movq mm2, [esi + ebx] /* load b=Prior(x) */ + punpcklbw mm2, mm0 /* Unpack High bytes of b */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + punpckhbw mm3, mm0 /* Unpack High bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] /* load c=Prior(x-bpp) */ + pand mm7, ActiveMask + movq mm2, mm3 /* load b=Prior(x) step 1 */ + paddb mm7, [edi + ebx] /* add Paeth predictor with Raw(x) */ + punpcklbw mm3, mm0 /* Unpack High bytes of c */ + movq [edi + ebx], mm7 /* write back updated value */ + movq mm1, mm7 /* Now mm1 will be used as Raw(x-bpp) */ + /* Do second set of 4 bytes */ + punpckhbw mm2, mm0 /* Unpack Low bytes of b */ + punpcklbw mm1, mm0 /* Unpack Low bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + /* Step ex to next set of 8 bytes and repeat loop til done */ + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] /* add Paeth predictor with Raw(x) */ + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + jb dpth4lp + } /* end _asm block */ + } + break; + case 8: /* bpp == 8 */ + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] /* Only time should need to read */ + /* a=Raw(x-bpp) bytes */ +dpth8lp: + /* Do first set of 4 bytes */ + movq mm3, [esi+ebx-8] /* read c=Prior(x-bpp) bytes */ + punpcklbw mm1, mm0 /* Unpack Low bytes of a */ + movq mm2, [esi + ebx] /* load b=Prior(x) */ + punpcklbw mm2, mm0 /* Unpack Low bytes of b */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + punpcklbw mm3, mm0 /* Unpack Low bytes of c */ + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi+ebx-8] /* read c=Prior(x-bpp) bytes */ + pand mm7, ActiveMask + movq mm2, [esi + ebx] /* load b=Prior(x) */ + paddb mm7, [edi + ebx] /* add Paeth predictor with Raw(x) */ + punpckhbw mm3, mm0 /* Unpack High bytes of c */ + movq [edi + ebx], mm7 /* write back updated value */ + movq mm1, [edi+ebx-8] /* read a=Raw(x-bpp) bytes */ + + /* Do second set of 4 bytes */ + punpckhbw mm2, mm0 /* Unpack High bytes of b */ + punpckhbw mm1, mm0 /* Unpack High bytes of a */ + /* pav = p - a = (a + b - c) - a = b - c */ + movq mm4, mm2 + /* pbv = p - b = (a + b - c) - b = a - c */ + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + movq mm6, mm4 + psubw mm5, mm3 + /* pa = abs(p-a) = abs(pav) */ + /* pb = abs(p-b) = abs(pbv) */ + /* pc = abs(p-c) = abs(pcv) */ + pcmpgtw mm0, mm4 /* Create mask pav bytes < 0 */ + paddw mm6, mm5 + pand mm0, mm4 /* Only pav bytes < 0 in mm7 */ + pcmpgtw mm7, mm5 /* Create mask pbv bytes < 0 */ + psubw mm4, mm0 + pand mm7, mm5 /* Only pbv bytes < 0 in mm0 */ + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 /* Create mask pcv bytes < 0 */ + pand mm0, mm6 /* Only pav bytes < 0 in mm7 */ + psubw mm5, mm7 + psubw mm6, mm0 + /* test pa <= pb */ + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 /* pa > pb? */ + movq mm0, mm7 + /* use mm7 mask to merge pa & pb */ + pand mm5, mm7 + /* use mm0 mask copy to merge a & b */ + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + /* test ((pa <= pb)? pa:pb) <= pc */ + pcmpgtw mm7, mm6 /* pab > pc? */ + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + /* Step ex to next set of 8 bytes and repeat loop til done */ + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] /* add Paeth predictor with Raw(x) */ + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 /* write back updated value */ + /* mm1 will be used as Raw(x-bpp) next loop */ + jb dpth8lp + } /* end _asm block */ + } + break; + + case 1: /* bpp = 1 */ + case 2: /* bpp = 2 */ + default: /* bpp > 8 */ + { + _asm { + mov ebx, diff + cmp ebx, FullLength + jnb dpthdend + mov edi, row + mov esi, prev_row + /* Do Paeth decode for remaining bytes */ + mov edx, ebx + xor ecx, ecx /* zero ecx before using cl & cx in loop below */ + sub edx, bpp /* Set edx = ebx - bpp */ +dpthdlp: + xor eax, eax + /* pav = p - a = (a + b - c) - a = b - c */ + mov al, [esi + ebx] /* load Prior(x) into al */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov patemp, eax /* Save pav for later use */ + xor eax, eax + /* pbv = p - b = (a + b - c) - b = a - c */ + mov al, [edi + edx] /* load Raw(x-bpp) into al */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov ecx, eax + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + add eax, patemp /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + test eax, 0x80000000 + jz dpthdpca + neg eax /* reverse sign of neg values */ +dpthdpca: + mov pctemp, eax /* save pc for later use */ + /* pb = abs(pbv) */ + test ecx, 0x80000000 + jz dpthdpba + neg ecx /* reverse sign of neg values */ +dpthdpba: + mov pbtemp, ecx /* save pb for later use */ + /* pa = abs(pav) */ + mov eax, patemp + test eax, 0x80000000 + jz dpthdpaa + neg eax /* reverse sign of neg values */ +dpthdpaa: + mov patemp, eax /* save pa for later use */ + /* test if pa <= pb */ + cmp eax, ecx + jna dpthdabb + /* pa > pb; now test if pb <= pc */ + cmp ecx, pctemp + jna dpthdbbc + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthdpaeth +dpthdbbc: + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + mov cl, [esi + ebx] /* load Prior(x) into cl */ + jmp dpthdpaeth +dpthdabb: + /* pa <= pb; now test if pa <= pc */ + cmp eax, pctemp + jna dpthdabc + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthdpaeth +dpthdabc: + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + mov cl, [edi + edx] /* load Raw(x-bpp) into cl */ +dpthdpaeth: + inc ebx + inc edx + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthdlp +dpthdend: + } /* end _asm block */ + } + return; /* No need to go further with this one */ + } /* end switch ( bpp ) */ + _asm + { + /* MMX acceleration complete now do clean-up */ + /* Check if any remaining bytes left to decode */ + mov ebx, MMXLength + cmp ebx, FullLength + jnb dpthend + mov edi, row + mov esi, prev_row + /* Do Paeth decode for remaining bytes */ + mov edx, ebx + xor ecx, ecx /* zero ecx before using cl & cx in loop below */ + sub edx, bpp /* Set edx = ebx - bpp */ +dpthlp2: + xor eax, eax + /* pav = p - a = (a + b - c) - a = b - c */ + mov al, [esi + ebx] /* load Prior(x) into al */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov patemp, eax /* Save pav for later use */ + xor eax, eax + /* pbv = p - b = (a + b - c) - b = a - c */ + mov al, [edi + edx] /* load Raw(x-bpp) into al */ + sub eax, ecx /* subtract Prior(x-bpp) */ + mov ecx, eax + /* pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv */ + add eax, patemp /* pcv = pav + pbv */ + /* pc = abs(pcv) */ + test eax, 0x80000000 + jz dpthpca2 + neg eax /* reverse sign of neg values */ +dpthpca2: + mov pctemp, eax /* save pc for later use */ + /* pb = abs(pbv) */ + test ecx, 0x80000000 + jz dpthpba2 + neg ecx /* reverse sign of neg values */ +dpthpba2: + mov pbtemp, ecx /* save pb for later use */ + /* pa = abs(pav) */ + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa2 + neg eax /* reverse sign of neg values */ +dpthpaa2: + mov patemp, eax /* save pa for later use */ + /* test if pa <= pb */ + cmp eax, ecx + jna dpthabb2 + /* pa > pb; now test if pb <= pc */ + cmp ecx, pctemp + jna dpthbbc2 + /* pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthpaeth2 +dpthbbc2: + /* pb <= pc; Raw(x) = Paeth(x) + Prior(x) */ + mov cl, [esi + ebx] /* load Prior(x) into cl */ + jmp dpthpaeth2 +dpthabb2: + /* pa <= pb; now test if pa <= pc */ + cmp eax, pctemp + jna dpthabc2 + /* pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) */ + mov cl, [esi + edx] /* load Prior(x-bpp) into cl */ + jmp dpthpaeth2 +dpthabc2: + /* pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) */ + mov cl, [edi + edx] /* load Raw(x-bpp) into cl */ +dpthpaeth2: + inc ebx + inc edx + /* Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 */ + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthlp2 +dpthend: + emms /* End MMX instructions; prep for possible FP instrs. */ + } /* end _asm block */ +} + +/* Optimized code for PNG Sub filter decoder */ +void /* PRIVATE */ +png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) +{ + /*int test; */ + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; /* Get # bytes per pixel */ + FullLength = row_info->rowbytes - bpp; /* # of bytes to filter */ + _asm { + mov edi, row + mov esi, edi /* lp = row */ + add edi, bpp /* rp = row + bpp */ + xor eax, eax + /* get # of bytes to alignment */ + mov diff, edi /* take start of row */ + add diff, 0xf /* add 7 + 8 to incr past */ + /* alignment boundary */ + xor ebx, ebx + and diff, 0xfffffff8 /* mask to alignment boundary */ + sub diff, edi /* subtract from start ==> value */ + /* ebx at alignment */ + jz dsubgo + /* fix alignment */ +dsublp1: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, diff + jb dsublp1 +dsubgo: + mov ecx, FullLength + mov edx, ecx + sub edx, ebx /* subtract alignment fix */ + and edx, 0x00000007 /* calc bytes over mult of 8 */ + sub ecx, edx /* drop over bytes from length */ + mov MMXLength, ecx + } /* end _asm block */ + + /* Now do the math for the rest of the row */ + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000ffffff000000; + ShiftBpp.use = 24; /* == 3 * 8 */ + ShiftRem.use = 40; /* == 64 - 24 */ + _asm { + mov edi, row + movq mm7, ActiveMask /* Load ActiveMask for 2nd active byte group */ + mov esi, edi /* lp = row */ + add edi, bpp /* rp = row + bpp */ + movq mm6, mm7 + mov ebx, diff + psllq mm6, ShiftBpp /* Move mask in mm6 to cover 3rd active */ + /* byte group */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] +dsub3lp: + psrlq mm1, ShiftRem /* Shift data for adding 1st bpp bytes */ + /* no need for mask; shift clears inactive bytes */ + /* Add 1st active group */ + movq mm0, [edi+ebx] + paddb mm0, mm1 + /* Add 2nd active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + pand mm1, mm7 /* mask to use only 2nd active group */ + paddb mm0, mm1 + /* Add 3rd active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + pand mm1, mm6 /* mask to use only 3rd active group */ + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 /* Write updated Raws back to array */ + /* Prep for doing 1st add at top of loop */ + movq mm1, mm0 + jb dsub3lp + } /* end _asm block */ + } + break; + + case 1: + { + /* Placed here just in case this is a duplicate of the */ + /* non-MMX code for the SUB filter in png_read_filter_row below */ + // + /* png_bytep rp; */ + /* png_bytep lp; */ + /* png_uint_32 i; */ + /* bpp = (row_info->pixel_depth + 7) >> 3; */ + /* for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; */ + /* i < row_info->rowbytes; i++, rp++, lp++) */ + /* { */ + /* *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); */ + /* } */ + _asm { + mov ebx, diff + mov edi, row + cmp ebx, FullLength + jnb dsub1end + mov esi, edi /* lp = row */ + xor eax, eax + add edi, bpp /* rp = row + bpp */ +dsub1lp: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsub1lp +dsub1end: + } /* end _asm block */ + } + return; + + case 6: + case 7: + case 4: + case 5: + { + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + mov edi, row + mov ebx, diff + mov esi, edi /* lp = row */ + add edi, bpp /* rp = row + bpp */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] +dsub4lp: + psrlq mm1, ShiftRem /* Shift data for adding 1st bpp bytes */ + /* no need for mask; shift clears inactive bytes */ + movq mm0, [edi+ebx] + paddb mm0, mm1 + /* Add 2nd active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + /* there is no need for any mask */ + /* since shift clears inactive bits/bytes */ + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 + movq mm1, mm0 /* Prep for doing 1st add at top of loop */ + jb dsub4lp + } /* end _asm block */ + } + break; + + case 2: + { + ActiveMask.use = 0x00000000ffff0000; + ShiftBpp.use = 16; /* == 2 * 8 */ + ShiftRem.use = 48; /* == 64 - 16 */ + _asm { + movq mm7, ActiveMask /* Load ActiveMask for 2nd active byte group */ + mov ebx, diff + movq mm6, mm7 + mov edi, row + psllq mm6, ShiftBpp /* Move mask in mm6 to cover 3rd active */ + /* byte group */ + mov esi, edi /* lp = row */ + movq mm5, mm6 + add edi, bpp /* rp = row + bpp */ + psllq mm5, ShiftBpp /* Move mask in mm5 to cover 4th active */ + /* byte group */ + /* PRIME the pump (load the first Raw(x-bpp) data set */ + movq mm1, [edi+ebx-8] +dsub2lp: + /* Add 1st active group */ + psrlq mm1, ShiftRem /* Shift data for adding 1st bpp bytes */ + /* no need for mask; shift clears inactive */ + /* bytes */ + movq mm0, [edi+ebx] + paddb mm0, mm1 + /* Add 2nd active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + pand mm1, mm7 /* mask to use only 2nd active group */ + paddb mm0, mm1 + /* Add 3rd active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + pand mm1, mm6 /* mask to use only 3rd active group */ + paddb mm0, mm1 + /* Add 4th active group */ + movq mm1, mm0 /* mov updated Raws to mm1 */ + psllq mm1, ShiftBpp /* shift data to position correctly */ + pand mm1, mm5 /* mask to use only 4th active group */ + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 /* Write updated Raws back to array */ + movq mm1, mm0 /* Prep for doing 1st add at top of loop */ + jb dsub2lp + } /* end _asm block */ + } + break; + case 8: + { + _asm { + mov edi, row + mov ebx, diff + mov esi, edi /* lp = row */ + add edi, bpp /* rp = row + bpp */ + mov ecx, MMXLength + movq mm7, [edi+ebx-8] /* PRIME the pump (load the first */ + /* Raw(x-bpp) data set */ + and ecx, 0x0000003f /* calc bytes over mult of 64 */ +dsub8lp: + movq mm0, [edi+ebx] /* Load Sub(x) for 1st 8 bytes */ + paddb mm0, mm7 + movq mm1, [edi+ebx+8] /* Load Sub(x) for 2nd 8 bytes */ + movq [edi+ebx], mm0 /* Write Raw(x) for 1st 8 bytes */ + /* Now mm0 will be used as Raw(x-bpp) for */ + /* the 2nd group of 8 bytes. This will be */ + /* repeated for each group of 8 bytes with */ + /* the 8th group being used as the Raw(x-bpp) */ + /* for the 1st group of the next loop. */ + paddb mm1, mm0 + movq mm2, [edi+ebx+16] /* Load Sub(x) for 3rd 8 bytes */ + movq [edi+ebx+8], mm1 /* Write Raw(x) for 2nd 8 bytes */ + paddb mm2, mm1 + movq mm3, [edi+ebx+24] /* Load Sub(x) for 4th 8 bytes */ + movq [edi+ebx+16], mm2 /* Write Raw(x) for 3rd 8 bytes */ + paddb mm3, mm2 + movq mm4, [edi+ebx+32] /* Load Sub(x) for 5th 8 bytes */ + movq [edi+ebx+24], mm3 /* Write Raw(x) for 4th 8 bytes */ + paddb mm4, mm3 + movq mm5, [edi+ebx+40] /* Load Sub(x) for 6th 8 bytes */ + movq [edi+ebx+32], mm4 /* Write Raw(x) for 5th 8 bytes */ + paddb mm5, mm4 + movq mm6, [edi+ebx+48] /* Load Sub(x) for 7th 8 bytes */ + movq [edi+ebx+40], mm5 /* Write Raw(x) for 6th 8 bytes */ + paddb mm6, mm5 + movq mm7, [edi+ebx+56] /* Load Sub(x) for 8th 8 bytes */ + movq [edi+ebx+48], mm6 /* Write Raw(x) for 7th 8 bytes */ + add ebx, 64 + paddb mm7, mm6 + cmp ebx, ecx + movq [edi+ebx-8], mm7 /* Write Raw(x) for 8th 8 bytes */ + jb dsub8lp + cmp ebx, MMXLength + jnb dsub8lt8 +dsub8lpA: + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm7 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 /* use -8 to offset early add to ebx */ + movq mm7, mm0 /* Move calculated Raw(x) data to mm1 to */ + /* be the new Raw(x-bpp) for the next loop */ + jb dsub8lpA +dsub8lt8: + } /* end _asm block */ + } + break; + + default: /* bpp greater than 8 bytes */ + { + _asm { + mov ebx, diff + mov edi, row + mov esi, edi /* lp = row */ + add edi, bpp /* rp = row + bpp */ +dsubAlp: + movq mm0, [edi+ebx] + movq mm1, [esi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 /* mov does not affect flags; -8 to offset */ + /* add ebx */ + jb dsubAlp + } /* end _asm block */ + } + break; + + } /* end switch ( bpp ) */ + + _asm { + mov ebx, MMXLength + mov edi, row + cmp ebx, FullLength + jnb dsubend + mov esi, edi /* lp = row */ + xor eax, eax + add edi, bpp /* rp = row + bpp */ +dsublp2: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsublp2 +dsubend: + emms /* End MMX instructions; prep for possible FP instrs. */ + } /* end _asm block */ +} + +/* Optimized code for PNG Up filter decoder */ +void /* PRIVATE */ +png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 len; + len = row_info->rowbytes; /* # of bytes to filter */ + _asm { + mov edi, row + /* get # of bytes to alignment */ + mov ecx, edi + xor ebx, ebx + add ecx, 0x7 + xor eax, eax + and ecx, 0xfffffff8 + mov esi, prev_row + sub ecx, edi + jz dupgo + /* fix alignment */ +duplp1: + mov al, [edi+ebx] + add al, [esi+ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al /* mov does not affect flags; -1 to offset inc ebx */ + jb duplp1 +dupgo: + mov ecx, len + mov edx, ecx + sub edx, ebx /* subtract alignment fix */ + and edx, 0x0000003f /* calc bytes over mult of 64 */ + sub ecx, edx /* drop over bytes from length */ + /* Unrolled loop - use all MMX registers and interleave to reduce */ + /* number of branch instructions (loops) and reduce partial stalls */ +duploop: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + movq mm3, [esi+ebx+8] + paddb mm0, mm1 + movq mm2, [edi+ebx+8] + movq [edi+ebx], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+16] + movq [edi+ebx+8], mm2 + movq mm4, [edi+ebx+16] + movq mm7, [esi+ebx+24] + paddb mm4, mm5 + movq mm6, [edi+ebx+24] + movq [edi+ebx+16], mm4 + paddb mm6, mm7 + movq mm1, [esi+ebx+32] + movq [edi+ebx+24], mm6 + movq mm0, [edi+ebx+32] + movq mm3, [esi+ebx+40] + paddb mm0, mm1 + movq mm2, [edi+ebx+40] + movq [edi+ebx+32], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+48] + movq [edi+ebx+40], mm2 + movq mm4, [edi+ebx+48] + movq mm7, [esi+ebx+56] + paddb mm4, mm5 + movq mm6, [edi+ebx+56] + movq [edi+ebx+48], mm4 + add ebx, 64 + paddb mm6, mm7 + cmp ebx, ecx + movq [edi+ebx-8], mm6 /* (+56)movq does not affect flags; */ + /* -8 to offset add ebx */ + jb duploop + + cmp edx, 0 /* Test for bytes over mult of 64 */ + jz dupend + + + /* 2 lines added by lcreeve@netins.net */ + /* (mail 11 Jul 98 in png-implement list) */ + cmp edx, 8 /*test for less than 8 bytes */ + jb duplt8 + + + add ecx, edx + and edx, 0x00000007 /* calc bytes over mult of 8 */ + sub ecx, edx /* drop over bytes from length */ + jz duplt8 + /* Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously */ +duplpA: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, ecx + movq [edi+ebx-8], mm0 /* movq does not affect flags; -8 to offset add ebx */ + jb duplpA + cmp edx, 0 /* Test for bytes over mult of 8 */ + jz dupend +duplt8: + xor eax, eax + add ecx, edx /* move over byte count into counter */ + /* Loop using x86 registers to update remaining bytes */ +duplp2: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al /* mov does not affect flags; -1 to offset inc ebx */ + jb duplp2 +dupend: + /* Conversion of filtered row completed */ + emms /* End MMX instructions; prep for possible FP instrs. */ + } /* end _asm block */ +} + + +/* Optimized png_read_filter_row routines */ +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep + row, png_bytep prev_row, int filter) +{ +#ifdef PNG_DEBUG + char filnm[10]; +#endif + + if (mmx_supported == 2) { +#if !defined(PNG_1_0_X) + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); +#endif + png_mmx_support(); + } + +#ifdef PNG_DEBUG + png_debug(1, "in png_read_filter_row\n"); + switch (filter) + { + case 0: sprintf(filnm, "none"); + break; +#if !defined(PNG_1_0_X) + case 1: sprintf(filnm, "sub-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); + break; + case 2: sprintf(filnm, "up-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); + break; + case 3: sprintf(filnm, "avg-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); + break; + case 4: sprintf(filnm, "Paeth-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); + break; +#else + case 1: sprintf(filnm, "sub"); + break; + case 2: sprintf(filnm, "up"); + break; + case 3: sprintf(filnm, "avg"); + break; + case 4: sprintf(filnm, "Paeth"); + break; +#endif + default: sprintf(filnm, "unknw"); + break; + } + png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); + png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, + (int)((row_info->pixel_depth + 7) >> 3)); + png_debug1(0,"len=%8d, ", row_info->rowbytes); +#endif /* PNG_DEBUG */ + + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + + case PNG_FILTER_VALUE_SUB: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_sub(row_info, row); + } + else + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_UP: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_up(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; ++i) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_AVG: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_avg(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) >> 1)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++ + *lp++) >> 1)) & 0xff); + rp++; + } + } + break; + } + + case PNG_FILTER_VALUE_PAETH: + { +#if !defined(PNG_1_0_X) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) +#else + if (mmx_supported) +#endif + { + png_read_filter_row_mmx_paeth(row_info, row, prev_row); + } + else + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + } + break; + } + + default: + png_warning(png_ptr, "Ignoring bad row filter type"); + *row=0; + break; + } +} + +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/Source/3rd Party/wx/src/png/pngwio.c b/Source/3rd Party/wx/src/png/pngwio.c index e3289dfe4..adc57b309 100644 --- a/Source/3rd Party/wx/src/png/pngwio.c +++ b/Source/3rd Party/wx/src/png/pngwio.c @@ -1,15 +1,12 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * * This file provides a location for all output. Users who need * special handling are expected to write functions that have the same * arguments as these and perform similar functions, but that possibly @@ -18,147 +15,214 @@ * them at run time with png_set_write_fn(...). */ -#include "pngpriv.h" - +#define PNG_INTERNAL +#include "png.h" #ifdef PNG_WRITE_SUPPORTED /* Write the data to whatever output you are using. The default routine - * writes to a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered writes. This should never be asked - * to write more than 64K on a 16 bit machine. - */ + writes to a file pointer. Note that this routine sometimes gets called + with very small lengths, so you should implement some kind of simple + buffering if you are using unbuffered writes. This should never be asked + to write more than 64K on a 16 bit machine. */ void /* PRIVATE */ -png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) +png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - /* NOTE: write_data_fn must not change the buffer! */ if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), - length); - + (*(png_ptr->write_data_fn))(png_ptr, data, length); else png_error(png_ptr, "Call to NULL write function"); } -#ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) /* This is the function that does the actual writing of data. If you are - * not writing to a standard C stream, you should create a replacement - * write_data function and use it at run time with png_set_write_fn(), rather - * than changing the library. - */ -void PNGCBAPI + not writing to a standard C stream, you should create a replacement + write_data function and use it at run time with png_set_write_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +void PNGAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check; - - if (png_ptr == NULL) - return; + png_uint_32 check; +#if defined(_WIN32_WCE) + if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); - +#endif if (check != length) png_error(png_ptr, "Write Error"); } +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +void PNGAPI +png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_uint_32 check; + png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + near_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)near_data == data) + { +#if defined(_WIN32_WCE) + if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) + check = 0; +#else + check = fwrite(near_data, 1, length, io_ptr); +#endif + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t written, remaining, err; + check = 0; + remaining = length; + do + { + written = MIN(NEAR_BUF_SIZE, remaining); + png_memcpy(buf, data, written); /* copy far buffer to near buffer */ +#if defined(_WIN32_WCE) + if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) + err = 0; +#else + err = fwrite(buf, 1, written, io_ptr); +#endif + if (err != written) + break; + else + check += err; + data += written; + remaining -= written; + } + while (remaining != 0); + } + if (check != length) + png_error(png_ptr, "Write Error"); +} + +#endif #endif /* This function is called to output any data pending writing (normally - * to disk). After png_flush is called, there should be no data pending - * writing in any buffers. - */ -#ifdef PNG_WRITE_FLUSH_SUPPORTED + to disk). After png_flush is called, there should be no data pending + writing in any buffers. */ +#if defined(PNG_WRITE_FLUSH_SUPPORTED) void /* PRIVATE */ -png_flush(png_structrp png_ptr) +png_flush(png_structp png_ptr) { if (png_ptr->output_flush_fn != NULL) (*(png_ptr->output_flush_fn))(png_ptr); } -# ifdef PNG_STDIO_SUPPORTED -void PNGCBAPI +#if !defined(PNG_NO_STDIO) +void PNGAPI png_default_flush(png_structp png_ptr) { +#if !defined(_WIN32_WCE) png_FILE_p io_ptr; - - if (png_ptr == NULL) - return; - - io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr)); - fflush(io_ptr); + io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); + if (io_ptr != NULL) + fflush(io_ptr); +#endif } -# endif +#endif #endif /* This function allows the application to supply new output functions for - * libpng if standard C streams aren't being used. - * - * This function takes as its arguments: - * png_ptr - pointer to a png output data structure - * io_ptr - pointer to user supplied structure containing info about - * the output functions. May be NULL. - * write_data_fn - pointer to a new output function that takes as its - * arguments a pointer to a png_struct, a pointer to - * data to be written, and a 32-bit unsigned int that is - * the number of bytes to be written. The new write - * function should call png_error(png_ptr, "Error msg") - * to exit and output any fatal error messages. May be - * NULL, in which case libpng's default function will - * be used. - * flush_data_fn - pointer to a new flush function that takes as its - * arguments a pointer to a png_struct. After a call to - * the flush function, there should be no data in any buffers - * or pending transmission. If the output method doesn't do - * any buffering of output, a function prototype must still be - * supplied although it doesn't have to do anything. If - * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - * time, output_flush_fn will be ignored, although it must be - * supplied for compatibility. May be NULL, in which case - * libpng's default function will be used, if - * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not - * a good idea if io_ptr does not point to a standard - * *FILE structure. - */ -void PNGAPI -png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - if (png_ptr == NULL) - return; + libpng if standard C streams aren't being used. + This function takes as its arguments: + png_ptr - pointer to a png output data structure + io_ptr - pointer to user supplied structure containing info about + the output functions. May be NULL. + write_data_fn - pointer to a new output function that takes as its + arguments a pointer to a png_struct, a pointer to + data to be written, and a 32-bit unsigned int that is + the number of bytes to be written. The new write + function should call png_error(png_ptr, "Error msg") + to exit and output any fatal error messages. + flush_data_fn - pointer to a new flush function that takes as its + arguments a pointer to a png_struct. After a call to + the flush function, there should be no data in any buffers + or pending transmission. If the output method doesn't do + any buffering of ouput, a function prototype must still be + supplied although it doesn't have to do anything. If + PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile + time, output_flush_fn will be ignored, although it must be + supplied for compatibility. */ +void PNGAPI +png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) +{ png_ptr->io_ptr = io_ptr; -#ifdef PNG_STDIO_SUPPORTED +#if !defined(PNG_NO_STDIO) if (write_data_fn != NULL) png_ptr->write_data_fn = write_data_fn; - else png_ptr->write_data_fn = png_default_write_data; #else png_ptr->write_data_fn = write_data_fn; #endif -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_STDIO_SUPPORTED - +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) if (output_flush_fn != NULL) png_ptr->output_flush_fn = output_flush_fn; - else png_ptr->output_flush_fn = png_default_flush; - -# else +#else png_ptr->output_flush_fn = output_flush_fn; -# endif +#endif #endif /* PNG_WRITE_FLUSH_SUPPORTED */ /* It is an error to read while writing a png file */ if (png_ptr->read_data_fn != NULL) { png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Can't set both read_data_fn and write_data_fn in the" - " same structure"); + "Attempted to set both read_data_fn and write_data_fn in"); + png_warning(png_ptr, + "the same structure. Resetting read_data_fn to NULL."); } } + +#if defined(USE_FAR_KEYWORD) +#if defined(_MSC_VER) +void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +{ + void *near_ptr; + void FAR *far_ptr; + FP_OFF(near_ptr) = FP_OFF(ptr); + far_ptr = (void FAR *)near_ptr; + if(check != 0) + if(FP_SEG(ptr) != FP_SEG(far_ptr)) + png_error(png_ptr,"segment lost in conversion"); + return(near_ptr); +} +# else +void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +{ + void *near_ptr; + void FAR *far_ptr; + near_ptr = (void FAR *)ptr; + far_ptr = (void FAR *)near_ptr; + if(check != 0) + if(far_ptr != ptr) + png_error(png_ptr,"segment lost in conversion"); + return(near_ptr); +} +# endif +# endif #endif /* PNG_WRITE_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngwrite.c b/Source/3rd Party/wx/src/png/pngwrite.c index 33924aac0..f422173bf 100644 --- a/Source/3rd Party/wx/src/png/pngwrite.c +++ b/Source/3rd Party/wx/src/png/pngwrite.c @@ -1,76 +1,18 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" -#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) -# include -#endif - +/* get internal access to png.h */ +#define PNG_INTERNAL +#include "png.h" #ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -/* Write out all the unknown chunks for the current given location */ -static void -write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, - unsigned int where) -{ - if (info_ptr->unknown_chunks_num) - { - png_const_unknown_chunkp up; - - png_debug(5, "writing extra chunks"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - ++up) - if (up->location & where) - { - /* If per-chunk unknown chunk handling is enabled use it, otherwise - * just write the chunks the application has set. - */ -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - int keep = png_handle_as_unknown(png_ptr, up->name); - - /* NOTE: this code is radically different from the read side in the - * matter of handling an ancillary unknown chunk. In the read side - * the default behavior is to discard it, in the code below the default - * behavior is to write it. Critical chunks are, however, only - * written if explicitly listed or if the default is set to write all - * unknown chunks. - * - * The default handling is also slightly weird - it is not possible to - * stop the writing of all unsafe-to-copy chunks! - * - * TODO: REVIEW: this would seem to be a bug. - */ - if (keep != PNG_HANDLE_CHUNK_NEVER && - ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ || - keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_AS_DEFAULT && - png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS))) -#endif - { - /* TODO: review, what is wrong with a zero length unknown chunk? */ - if (up->size == 0) - png_warning(png_ptr, "Writing zero-length unknown chunk"); - - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -} -#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */ - /* Writes all the PNG information. This is the suggested way to use the * library. If you have a new chunk to add, make a function to write it, * and put it in the correct location here. If you want the chunk written @@ -81,258 +23,261 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, * them in png_write_end(), and compressing them. */ void PNGAPI -png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) +png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_info_before_PLTE"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - + png_debug(1, "in png_write_info_before_PLTE\n"); if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) { - /* Write PNG signature */ - png_write_sig(png_ptr); - -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \ - (png_ptr->mng_features_permitted)) + png_write_sig(png_ptr); /* write PNG signature */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) { - png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted = 0; + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); + png_ptr->mng_features_permitted=0; } #endif - - /* Write IHDR information. */ + /* write IHDR information. */ png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - info_ptr->interlace_type + info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, + info_ptr->filter_type, +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + info_ptr->interlace_type); #else - 0 + 0); #endif - ); - - /* The rest of these check to see if the valid field has the appropriate - * flag set, and if it does, writes the chunk. - * - * 1.6.0: COLORSPACE support controls the writing of these chunks too, and - * the chunks will be written if the WRITE routine is there and information - * is available in the COLORSPACE. (See png_colorspace_sync_info in png.c - * for where the valid flags get set.) - * - * Under certain circumstances the colorspace can be invalidated without - * syncing the info_struct 'valid' flags; this happens if libpng detects and - * error and calls png_error while the color space is being set, yet the - * application continues writing the PNG. So check the 'invalid' flag here - * too. - */ -#ifdef PNG_GAMMA_SUPPORTED -# ifdef PNG_WRITE_gAMA_SUPPORTED - if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && - (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) && - (info_ptr->valid & PNG_INFO_gAMA)) - png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); + /* the rest of these check to see if the valid field has the appropriate + flag set, and if it does, writes the chunk. */ +#if defined(PNG_WRITE_gAMA_SUPPORTED) + if (info_ptr->valid & PNG_INFO_gAMA) + { +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_write_gAMA(png_ptr, info_ptr->gamma); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); # endif #endif - -#ifdef PNG_COLORSPACE_SUPPORTED - /* Write only one of sRGB or an ICC profile. If a profile was supplied - * and it matches one of the known sRGB ones issue a warning. - */ -# ifdef PNG_WRITE_iCCP_SUPPORTED - if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && - (info_ptr->valid & PNG_INFO_iCCP)) - { -# ifdef PNG_WRITE_sRGB_SUPPORTED - if (info_ptr->valid & PNG_INFO_sRGB) - png_app_warning(png_ptr, - "profile matches sRGB but writing iCCP instead"); -# endif - - png_write_iCCP(png_ptr, info_ptr->iccp_name, - info_ptr->iccp_profile); - } -# ifdef PNG_WRITE_sRGB_SUPPORTED - else -# endif -# endif - -# ifdef PNG_WRITE_sRGB_SUPPORTED - if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && - (info_ptr->valid & PNG_INFO_sRGB)) - png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); -# endif /* WRITE_sRGB */ -#endif /* COLORSPACE */ - -#ifdef PNG_WRITE_sBIT_SUPPORTED + } +#endif +#if defined(PNG_WRITE_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); +#endif +#if defined(PNG_WRITE_iCCP_SUPPORTED) + if (info_ptr->valid & PNG_INFO_iCCP) + png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, + info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); +#endif +#if defined(PNG_WRITE_sBIT_SUPPORTED) if (info_ptr->valid & PNG_INFO_sBIT) png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); #endif - -#ifdef PNG_COLORSPACE_SUPPORTED -# ifdef PNG_WRITE_cHRM_SUPPORTED - if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && - (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) && - (info_ptr->valid & PNG_INFO_cHRM)) - png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy); +#if defined(PNG_WRITE_cHRM_SUPPORTED) + if (info_ptr->valid & PNG_INFO_cHRM) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_write_cHRM(png_ptr, + info_ptr->x_white, info_ptr->y_white, + info_ptr->x_red, info_ptr->y_red, + info_ptr->x_green, info_ptr->y_green, + info_ptr->x_blue, info_ptr->y_blue); +#else +# ifdef PNG_FIXED_POINT_SUPPORTED + png_write_cHRM_fixed(png_ptr, + info_ptr->int_x_white, info_ptr->int_y_white, + info_ptr->int_x_red, info_ptr->int_y_red, + info_ptr->int_x_green, info_ptr->int_y_green, + info_ptr->int_x_blue, info_ptr->int_y_blue); # endif #endif - -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); + } #endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && !(up->location & PNG_HAVE_PLTE) && + !(up->location & PNG_HAVE_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +#endif png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; } } void PNGAPI -png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) +png_write_info(png_structp png_ptr, png_infop info_ptr) { #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) int i; #endif - png_debug(1, "in png_write_info"); - - if (png_ptr == NULL || info_ptr == NULL) - return; + png_debug(1, "in png_write_info\n"); png_write_info_before_PLTE(png_ptr, info_ptr); if (info_ptr->valid & PNG_INFO_PLTE) png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - + (png_uint_32)info_ptr->num_palette); else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images"); + png_error(png_ptr, "Valid palette required for paletted images\n"); -#ifdef PNG_WRITE_tRNS_SUPPORTED +#if defined(PNG_WRITE_tRNS_SUPPORTED) if (info_ptr->valid & PNG_INFO_tRNS) - { -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED - /* Invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - int j; - for (j = 0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans_alpha[j] = - (png_byte)(255 - info_ptr->trans_alpha[j]); +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel (in tRNS) */ + if ((png_ptr->transformations & PNG_INVERT_ALPHA) && + info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + int j; + for (j=0; j<(int)info_ptr->num_trans; j++) + info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); + } +#endif + png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), + info_ptr->num_trans, info_ptr->color_type); } #endif - png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#ifdef PNG_WRITE_bKGD_SUPPORTED +#if defined(PNG_WRITE_bKGD_SUPPORTED) if (info_ptr->valid & PNG_INFO_bKGD) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif - -#ifdef PNG_WRITE_hIST_SUPPORTED +#if defined(PNG_WRITE_hIST_SUPPORTED) if (info_ptr->valid & PNG_INFO_hIST) png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); #endif - -#ifdef PNG_WRITE_oFFs_SUPPORTED +#if defined(PNG_WRITE_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); + info_ptr->offset_unit_type); #endif - -#ifdef PNG_WRITE_pCAL_SUPPORTED +#if defined(PNG_WRITE_pCAL_SUPPORTED) if (info_ptr->valid & PNG_INFO_pCAL) png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); + info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, + info_ptr->pcal_units, info_ptr->pcal_params); #endif - -#ifdef PNG_WRITE_sCAL_SUPPORTED +#if defined(PNG_WRITE_sCAL_SUPPORTED) if (info_ptr->valid & PNG_INFO_sCAL) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) + png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, + info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_s_width, info_ptr->scal_s_height); -#endif /* sCAL */ - -#ifdef PNG_WRITE_pHYs_SUPPORTED +#else + png_warning(png_ptr, + "png_write_sCAL not supported; sCAL chunk not written.\n"); +#endif +#endif +#endif +#if defined(PNG_WRITE_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif /* pHYs */ - -#ifdef PNG_WRITE_tIME_SUPPORTED + info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); +#endif +#if defined(PNG_WRITE_tIME_SUPPORTED) if (info_ptr->valid & PNG_INFO_tIME) { png_write_tIME(png_ptr, &(info_ptr->mod_time)); png_ptr->mode |= PNG_WROTE_tIME; } -#endif /* tIME */ - -#ifdef PNG_WRITE_sPLT_SUPPORTED +#endif +#if defined(PNG_WRITE_sPLT_SUPPORTED) if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif /* sPLT */ - -#ifdef PNG_WRITE_TEXT_SUPPORTED + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); +#endif +#if defined(PNG_WRITE_TEXT_SUPPORTED) /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing header text chunk %d, type %d", i, - info_ptr->text[i].compression); - /* An internationalized chunk? */ + png_debug2(2, "Writing header text chunk %d, type %d\n", i, + info_ptr->text[i].compression); + /* an internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#ifdef PNG_WRITE_iTXt_SUPPORTED - /* Write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); +#if defined(PNG_WRITE_iTXt_SUPPORTED) + /* write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); #else - png_warning(png_ptr, "Unable to write international text"); + png_warning(png_ptr, "Unable to write international text\n"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } - /* If we want a compressed text chunk */ else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) { -#ifdef PNG_WRITE_zTXt_SUPPORTED - /* Write compressed chunk */ +#if defined(PNG_WRITE_zTXt_SUPPORTED) + /* write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); #else - png_warning(png_ptr, "Unable to write compressed text"); + png_warning(png_ptr, "Unable to write compressed text\n"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#ifdef PNG_WRITE_tEXt_SUPPORTED - /* Write uncompressed chunk */ +#if defined(PNG_WRITE_tEXt_SUPPORTED) + /* write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); + info_ptr->text[i].text, + 0); +#else + png_warning(png_ptr, "Unable to write uncompressed text\n"); +#endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; -#else - /* Can't get here */ - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif } } -#endif /* tEXt */ +#endif +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE); + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && (up->location & PNG_HAVE_PLTE) && + !(up->location & PNG_HAVE_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } #endif } @@ -342,80 +287,68 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) * comments, I suggest writing them here, and compressing them. */ void PNGAPI -png_write_end(png_structrp png_ptr, png_inforp info_ptr) +png_write_end(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_end"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_write_end\n"); if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "No IDATs written into file"); -#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED - if (png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); -#endif - - /* See if user wants us to write information chunks */ + /* see if user wants us to write information chunks */ if (info_ptr != NULL) { -#ifdef PNG_WRITE_TEXT_SUPPORTED +#if defined(PNG_WRITE_TEXT_SUPPORTED) int i; /* local index variable */ #endif -#ifdef PNG_WRITE_tIME_SUPPORTED - /* Check to see if user has supplied a time chunk */ +#if defined(PNG_WRITE_tIME_SUPPORTED) + /* check to see if user has supplied a time chunk */ if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) + !(png_ptr->mode & PNG_WROTE_tIME)) png_write_tIME(png_ptr, &(info_ptr->mod_time)); - #endif -#ifdef PNG_WRITE_TEXT_SUPPORTED - /* Loop through comment chunks */ +#if defined(PNG_WRITE_TEXT_SUPPORTED) + /* loop through comment chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing trailer text chunk %d, type %d", i, + png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, info_ptr->text[i].compression); - /* An internationalized chunk? */ + /* an internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#ifdef PNG_WRITE_iTXt_SUPPORTED - /* Write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); +#if defined(PNG_WRITE_iTXt_SUPPORTED) + /* write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); #else - png_warning(png_ptr, "Unable to write international text"); + png_warning(png_ptr, "Unable to write international text\n"); #endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) { -#ifdef PNG_WRITE_zTXt_SUPPORTED - /* Write compressed chunk */ +#if defined(PNG_WRITE_zTXt_SUPPORTED) + /* write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); #else - png_warning(png_ptr, "Unable to write compressed text"); + png_warning(png_ptr, "Unable to write compressed text\n"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#ifdef PNG_WRITE_tEXt_SUPPORTED - /* Write uncompressed chunk */ +#if defined(PNG_WRITE_tEXt_SUPPORTED) + /* write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); + info_ptr->text[i].text, 0); #else - png_warning(png_ptr, "Unable to write uncompressed text"); + png_warning(png_ptr, "Unable to write uncompressed text\n"); #endif /* Mark this chunk as written */ @@ -423,35 +356,48 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) } } #endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT); +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) + if (info_ptr->unknown_chunks_num) + { + png_unknown_chunk *up; + + png_debug(5, "writing extra chunks\n"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { + int keep=png_handle_as_unknown(png_ptr, up->name); + if (keep != PNG_HANDLE_CHUNK_NEVER && + up->location && (up->location & PNG_AFTER_IDAT) && + ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || + (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) + { + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } #endif } png_ptr->mode |= PNG_AFTER_IDAT; - /* Write end of PNG file */ + /* write end of PNG file */ png_write_IEND(png_ptr); - /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, - * and restored again in libpng-1.2.30, may cause some applications that - * do not set png_ptr->output_flush_fn to crash. If your application - * experiences a problem, please try building libpng with - * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to - * png-mng-implement at lists.sf.net . - */ -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED +#if 0 +/* This flush, added in libpng-1.0.8, causes some applications to crash + because they do not set png_ptr->output_flush_fn */ png_flush(png_ptr); -# endif #endif } -#ifdef PNG_CONVERT_tIME_SUPPORTED +#if defined(PNG_WRITE_tIME_SUPPORTED) +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ void PNGAPI -png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime) +png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) { - png_debug(1, "in png_convert_from_struct_tm"); - + png_debug(1, "in png_convert_from_struct_tm\n"); ptime->year = (png_uint_16)(1900 + ttime->tm_year); ptime->month = (png_byte)(ttime->tm_mon + 1); ptime->day = (png_byte)ttime->tm_mday; @@ -465,90 +411,272 @@ png_convert_from_time_t(png_timep ptime, time_t ttime) { struct tm *tbuf; - png_debug(1, "in png_convert_from_time_t"); - + png_debug(1, "in png_convert_from_time_t\n"); tbuf = gmtime(&ttime); png_convert_from_struct_tm(ptime, tbuf); } #endif +#endif /* Initialize png_ptr structure, and allocate any memory needed */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) +png_structp PNGAPI +png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn) { -#ifndef PNG_USER_MEM_SUPPORTED - png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); -#else - return png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); } /* Alternate initialize png_ptr structure, and allocate any memory needed */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) +png_structp PNGAPI +png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* PNG_USER_MEM_SUPPORTED */ + png_structp png_ptr; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + int i; + png_debug(1, "in png_create_write_struct\n"); +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, + (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); +#else + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); +#endif /* PNG_USER_MEM_SUPPORTED */ + if (png_ptr == NULL) + return (NULL); - /* Set the zlib control values to defaults; they can be overridden by the - * application after the struct has been created. - */ - png_ptr->zbuffer_size = PNG_ZBUF_SIZE; +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif /* PNG_1_0_X */ - /* The 'zlib_strategy' setting is irrelevant because png_default_claim in - * pngwutil.c defaults it according to whether or not filters will be used, - * and ignores this setting. - */ - png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY; - png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION; - png_ptr->zlib_mem_level = 8; - png_ptr->zlib_window_bits = 15; - png_ptr->zlib_method = 8; + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif -#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED - png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY; - png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION; - png_ptr->zlib_text_mem_level = 8; - png_ptr->zlib_text_window_bits = 15; - png_ptr->zlib_text_method = 8; -#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */ - - /* This is a highly dubious configuration option; by default it is off, but - * it may be appropriate for private builds that are testing extensions not - * conformant to the current specification, or of applications that must not - * fail to write at all costs! - */ -# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; - /* In stable builds only warn if an application error can be completely - * handled. - */ -# endif - - /* App warnings are warnings in release (or release candidate) builds but - * are errors during development. - */ -# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC - png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; -# endif - - if (png_ptr != NULL) +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_ptr->jmpbuf)) +#endif { - /* TODO: delay this, it can be done in png_init_io() (if the app doesn't - * do it itself) avoiding setting the default function if it is not - * required. - */ - png_set_write_fn(png_ptr, NULL, NULL, NULL); + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf=NULL; + png_destroy_struct(png_ptr); + return (NULL); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#endif +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); +#endif /* PNG_USER_MEM_SUPPORTED */ + png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); + + i=0; + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); + + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first digit. + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[80]; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); +#endif +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "Incompatible libpng version in application and library"); + } } - return png_ptr; + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, + 1, png_doublep_NULL, png_doublep_NULL); +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then encounter + a png_error() will longjmp here. Since the jmpbuf is then meaningless we + abort instead of returning. */ +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) + PNG_ABORT(); + png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); +#else + if (setjmp(png_ptr->jmpbuf)) + PNG_ABORT(); +#endif +#endif + return (png_ptr); } +/* Initialize png_ptr structure, and allocate any memory needed */ +#undef png_write_init +void PNGAPI +png_write_init(png_structp png_ptr) +{ + /* We only come here via pre-1.0.7-compiled applications */ + png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); +} + +void PNGAPI +png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size, png_size_t png_info_size) +{ + /* We only come here via pre-1.0.12-compiled applications */ +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + if(png_sizeof(png_struct) > png_struct_size || + png_sizeof(png_info) > png_info_size) + { + char msg[80]; + png_ptr->warning_fn=NULL; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); + } +#endif + if(png_sizeof(png_struct) > png_struct_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The png struct allocated by the application for writing is too small."); + } + if(png_sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The info struct allocated by the application for writing is too small."); + } + png_write_init_3(&png_ptr, user_png_ver, png_struct_size); +} + + +void PNGAPI +png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size) +{ + png_structp png_ptr=*ptr_ptr; +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* to save current jump buffer */ +#endif + int i = 0; + do + { + if (user_png_ver[i] != png_libpng_ver[i]) + { +#ifdef PNG_LEGACY_SUPPORTED + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; +#else + png_ptr->warning_fn=NULL; + png_warning(png_ptr, + "Application uses deprecated png_write_init() and should be recompiled."); + break; +#endif + } + } while (png_libpng_ver[i++]); + + png_debug(1, "in png_write_init_3\n"); + +#ifdef PNG_SETJMP_SUPPORTED + /* save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#endif + + if (png_sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + *ptr_ptr = png_ptr; + } + + /* reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof (png_struct)); + + /* added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_ptr->user_width_max=PNG_USER_WIDTH_MAX; + png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; +#endif + +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif /* PNG_1_0_X */ + +#ifdef PNG_SETJMP_SUPPORTED + /* restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif + + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, + 1, png_doublep_NULL, png_doublep_NULL); +#endif +} /* Write a few rows of image data. If the image is interlaced, * either you will have to write the 7 sub images, or, if you @@ -556,18 +684,14 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, * "write" the image seven times. */ void PNGAPI -png_write_rows(png_structrp png_ptr, png_bytepp row, - png_uint_32 num_rows) +png_write_rows(png_structp png_ptr, png_bytepp row, + png_uint_32 num_rows) { png_uint_32 i; /* row counter */ png_bytepp rp; /* row pointer */ - png_debug(1, "in png_write_rows"); - - if (png_ptr == NULL) - return; - - /* Loop through the rows */ + png_debug(1, "in png_write_rows\n"); + /* loop through the rows */ for (i = 0, rp = row; i < num_rows; i++, rp++) { png_write_row(png_ptr, *rp); @@ -578,29 +702,24 @@ png_write_rows(png_structrp png_ptr, png_bytepp row, * if you are writing an interlaced image. */ void PNGAPI -png_write_image(png_structrp png_ptr, png_bytepp image) +png_write_image(png_structp png_ptr, png_bytepp image) { png_uint_32 i; /* row index */ int pass, num_pass; /* pass variables */ png_bytepp rp; /* points to current row */ - if (png_ptr == NULL) - return; - - png_debug(1, "in png_write_image"); - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Initialize interlace handling. If image is not interlaced, - * this will set pass to 1 - */ + png_debug(1, "in png_write_image\n"); +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* intialize interlace handling. If image is not interlaced, + this will set pass to 1 */ num_pass = png_set_interlace_handling(png_ptr); #else num_pass = 1; #endif - /* Loop through passes */ + /* loop through passes */ for (pass = 0; pass < num_pass; pass++) { - /* Loop through image */ + /* loop through image */ for (i = 0, rp = image; i < png_ptr->height; i++, rp++) { png_write_row(png_ptr, *rp); @@ -608,69 +727,55 @@ png_write_image(png_structrp png_ptr, png_bytepp image) } } -/* Called by user to write a row of image data */ +/* called by user to write a row of image data */ void PNGAPI -png_write_row(png_structrp png_ptr, png_const_bytep row) +png_write_row(png_structp png_ptr, png_bytep row) { - /* 1.5.6: moved from png_struct to be a local structure: */ - png_row_info row_info; - - if (png_ptr == NULL) - return; - - png_debug2(1, "in png_write_row (row %u, pass %d)", + png_debug2(1, "in png_write_row (row %ld, pass %d)\n", png_ptr->row_number, png_ptr->pass); - - /* Initialize transformations and other stuff if first time */ + /* initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* Make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row"); + /* make sure we wrote the header info */ + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + png_error(png_ptr, + "png_write_info was never called before png_write_row."); - /* Check for transforms that have been set but were defined out */ + /* check for transforms that have been set but were defined out */ #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); #endif - #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); #endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ - defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, - "PNG_WRITE_PACKSWAP_SUPPORTED is not defined"); +#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); #endif - #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); #endif - #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); #endif - #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); #endif - #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined"); + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); #endif png_write_start_row(png_ptr); } -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced and not interested in row, return */ +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* if interlaced and not interested in row, return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -682,7 +787,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 1: if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) { @@ -690,7 +794,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 2: if ((png_ptr->row_number & 0x07) != 4) { @@ -698,7 +801,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 3: if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) { @@ -706,7 +808,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 4: if ((png_ptr->row_number & 0x03) != 2) { @@ -714,7 +815,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 5: if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) { @@ -722,7 +822,6 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - case 6: if (!(png_ptr->row_number & 0x01)) { @@ -730,39 +829,41 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; } break; - - default: /* error: ignore it */ - break; } } #endif - /* Set up row info for transformations */ - row_info.color_type = png_ptr->color_type; - row_info.width = png_ptr->usr_width; - row_info.channels = png_ptr->usr_channels; - row_info.bit_depth = png_ptr->usr_bit_depth; - row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels); - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + /* set up row info for transformations */ + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->usr_width; + png_ptr->row_info.channels = png_ptr->usr_channels; + png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; + png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * + png_ptr->row_info.channels); - png_debug1(3, "row_info->color_type = %d", row_info.color_type); - png_debug1(3, "row_info->width = %u", row_info.width); - png_debug1(3, "row_info->channels = %d", row_info.channels); - png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes); + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); + png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); + png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); + png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ - memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes); + png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, + png_ptr->row_info.rowbytes); -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Handle interlacing */ +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* handle interlacing */ if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) + (png_ptr->transformations & PNG_INTERLACE)) { - png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass); - /* This should always get caught above, but still ... */ - if (!(row_info.width)) + png_do_write_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass); + /* this should always get caught above, but still ... */ + if (!(png_ptr->row_info.width)) { png_write_finish_row(png_ptr); return; @@ -770,20 +871,11 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) } #endif -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED - /* Handle other transformations */ + /* handle other transformations */ if (png_ptr->transformations) - png_do_write_transformations(png_ptr, &row_info); -#endif + png_do_write_transformations(png_ptr); - /* At this point the row_info pixel depth must match the 'transformed' depth, - * which is also the output depth. - */ - if (row_info.pixel_depth != png_ptr->pixel_depth || - row_info.pixel_depth != png_ptr->transformed_pixel_depth) - png_error(png_ptr, "internal write transform logic error"); - -#ifdef PNG_MNG_FEATURES_SUPPORTED +#if defined(PNG_MNG_FEATURES_SUPPORTED) /* Write filter_method 64 (intrapixel differencing) only if * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and * 2. Libpng did not write a PNG signature (this filter_method is only @@ -793,177 +885,231 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ - png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1); + png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); } #endif -/* Added at libpng-1.5.10 */ -#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Check for out-of-range palette index */ - if (row_info.color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max >= 0) - png_do_check_palette_indexes(png_ptr, &row_info); -#endif - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &row_info); + png_write_find_filter(png_ptr, &(png_ptr->row_info)); if (png_ptr->write_row_fn != NULL) (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } -#ifdef PNG_WRITE_FLUSH_SUPPORTED +#if defined(PNG_WRITE_FLUSH_SUPPORTED) /* Set the automatic flush interval or 0 to turn flushing off */ void PNGAPI -png_set_flush(png_structrp png_ptr, int nrows) +png_set_flush(png_structp png_ptr, int nrows) { - png_debug(1, "in png_set_flush"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_flush\n"); png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); } -/* Flush the current output buffers now */ +/* flush the current output buffers now */ void PNGAPI -png_write_flush(png_structrp png_ptr) +png_write_flush(png_structp png_ptr) { - png_debug(1, "in png_write_flush"); - - if (png_ptr == NULL) - return; + int wrote_IDAT; + png_debug(1, "in png_write_flush\n"); /* We have already written out all of the data */ if (png_ptr->row_number >= png_ptr->num_rows) - return; + return; - png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH); + do + { + int ret; + + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); + wrote_IDAT = 0; + + /* check for compression errors */ + if (ret != Z_OK) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + + if (!(png_ptr->zstream.avail_out)) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + wrote_IDAT = 1; + } + } while(wrote_IDAT == 1); + + /* If there is any data left to be output, write it into a new IDAT */ + if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } png_ptr->flush_rows = 0; png_flush(png_ptr); } #endif /* PNG_WRITE_FLUSH_SUPPORTED */ -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */ +/* free all memory used by the write */ +void PNGAPI +png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn = NULL; + png_voidp mem_ptr = NULL; #endif -/* Free any memory used in png_ptr struct without freeing the struct itself. */ -static void -png_write_destroy(png_structrp png_ptr) + png_debug(1, "in png_destroy_write_struct\n"); + if (png_ptr_ptr != NULL) + { + png_ptr = *png_ptr_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; +#endif + } + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (info_ptr != NULL) + { + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } + + if (png_ptr != NULL) + { + png_write_destroy(png_ptr); +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + *png_ptr_ptr = NULL; + } +} + + +/* Free any memory used in png_ptr struct (old method) */ +void /* PRIVATE */ +png_write_destroy(png_structp png_ptr) { - png_debug(1, "in png_write_destroy"); +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* save jump buffer */ +#endif + png_error_ptr error_fn; + png_error_ptr warning_fn; + png_voidp error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; +#endif - /* Free any memory zlib uses */ - if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) - deflateEnd(&png_ptr->zstream); + png_debug(1, "in png_write_destroy\n"); + /* free any memory zlib uses */ + deflateEnd(&png_ptr->zstream); - /* Free our memory. png_free checks NULL for us. */ - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + /* free our memory. png_free checks NULL for us. */ + png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->row_buf); -#ifdef PNG_WRITE_FILTER_SUPPORTED png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->sub_row); png_free(png_ptr, png_ptr->up_row); png_free(png_ptr, png_ptr->avg_row); png_free(png_ptr, png_ptr->paeth_row); + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_free(png_ptr, png_ptr->time_buffer); #endif -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - /* Use this to save a little code space, it doesn't free the filter_costs */ - png_reset_filter_heuristics(png_ptr); +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_free(png_ptr, png_ptr->prev_filters); + png_free(png_ptr, png_ptr->filter_weights); + png_free(png_ptr, png_ptr->inv_filter_weights); png_free(png_ptr, png_ptr->filter_costs); png_free(png_ptr, png_ptr->inv_filter_costs); #endif -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - png_free(png_ptr, png_ptr->chunk_list); +#ifdef PNG_SETJMP_SUPPORTED + /* reset structure */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); #endif - /* The error handling and memory handling information is left intact at this - * point: the jmp_buf may still have to be freed. See png_destroy_png_struct - * for how this happens. - */ -} + error_fn = png_ptr->error_fn; + warning_fn = png_ptr->warning_fn; + error_ptr = png_ptr->error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; +#endif -/* Free all memory used by the write. - * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for - * *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free - * the passed in info_structs but it would quietly fail to free any of the data - * inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it - * has no png_ptr.) - */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_debug(1, "in png_destroy_write_struct"); + png_memset(png_ptr, 0, png_sizeof (png_struct)); - if (png_ptr_ptr != NULL) - { - png_structrp png_ptr = *png_ptr_ptr; + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; + png_ptr->error_ptr = error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr->free_fn = free_fn; +#endif - if (png_ptr != NULL) /* added in libpng 1.6.0 */ - { - png_destroy_info_struct(png_ptr, info_ptr_ptr); - - *png_ptr_ptr = NULL; - png_write_destroy(png_ptr); - png_destroy_png_struct(png_ptr); - } - } +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); +#endif } /* Allow the application to select one or more row filters to use. */ void PNGAPI -png_set_filter(png_structrp png_ptr, int method, int filters) +png_set_filter(png_structp png_ptr, int method, int filters) { - png_debug(1, "in png_set_filter"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; - + png_debug(1, "in png_set_filter\n"); +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (method == PNG_INTRAPIXEL_DIFFERENCING)) + method = PNG_FILTER_TYPE_BASE; #endif if (method == PNG_FILTER_TYPE_BASE) { switch (filters & (PNG_ALL_FILTERS | 0x07)) { -#ifdef PNG_WRITE_FILTER_SUPPORTED case 5: case 6: - case 7: png_app_error(png_ptr, "Unknown row filter for method 0"); - /* FALL THROUGH */ -#endif /* PNG_WRITE_FILTER_SUPPORTED */ - case PNG_FILTER_VALUE_NONE: - png_ptr->do_filter = PNG_FILTER_NONE; break; - -#ifdef PNG_WRITE_FILTER_SUPPORTED - case PNG_FILTER_VALUE_SUB: - png_ptr->do_filter = PNG_FILTER_SUB; break; - - case PNG_FILTER_VALUE_UP: - png_ptr->do_filter = PNG_FILTER_UP; break; - - case PNG_FILTER_VALUE_AVG: - png_ptr->do_filter = PNG_FILTER_AVG; break; - - case PNG_FILTER_VALUE_PAETH: - png_ptr->do_filter = PNG_FILTER_PAETH; break; - - default: - png_ptr->do_filter = (png_byte)filters; break; -#else - default: - png_app_error(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_WRITE_FILTER_SUPPORTED */ + case 7: png_warning(png_ptr, "Unknown row filter for method 0"); + case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; + case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; + case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; + case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; + case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; + default: png_ptr->do_filter = (png_byte)filters; break; } /* If we have allocated the row_buf, this means we have already started @@ -977,11 +1123,10 @@ png_set_filter(png_structrp png_ptr, int method, int filters) */ if (png_ptr->row_buf != NULL) { -#ifdef PNG_WRITE_FILTER_SUPPORTED if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) { png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } @@ -990,14 +1135,12 @@ png_set_filter(png_structrp png_ptr, int method, int filters) if (png_ptr->prev_row == NULL) { png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter = (png_byte)(png_ptr->do_filter & - ~PNG_FILTER_UP); + png_ptr->do_filter &= ~PNG_FILTER_UP; } - else { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } } @@ -1007,14 +1150,12 @@ png_set_filter(png_structrp png_ptr, int method, int filters) if (png_ptr->prev_row == NULL) { png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter = (png_byte)(png_ptr->do_filter & - ~PNG_FILTER_AVG); + png_ptr->do_filter &= ~PNG_FILTER_AVG; } - else { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } } @@ -1027,17 +1168,15 @@ png_set_filter(png_structrp png_ptr, int method, int filters) png_warning(png_ptr, "Can't add Paeth filter after starting"); png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); } - else { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } } if (png_ptr->do_filter == PNG_NO_FILTERS) -#endif /* PNG_WRITE_FILTER_SUPPORTED */ png_ptr->do_filter = PNG_FILTER_NONE; } } @@ -1052,1280 +1191,274 @@ png_set_filter(png_structrp png_ptr, int method, int filters) * filtered data going to zlib more consistent, hopefully resulting in * better compression. */ -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */ -/* Convenience reset API. */ -static void -png_reset_filter_heuristics(png_structrp png_ptr) +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ +void PNGAPI +png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, + int num_weights, png_doublep filter_weights, + png_doublep filter_costs) { - /* Clear out any old values in the 'weights' - this must be done because if - * the app calls set_filter_heuristics multiple times with different - * 'num_weights' values we would otherwise potentially have wrong sized - * arrays. - */ - png_ptr->num_prev_filters = 0; - png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - if (png_ptr->prev_filters != NULL) + int i; + + png_debug(1, "in png_set_filter_heuristics\n"); + if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) { - png_bytep old = png_ptr->prev_filters; - png_ptr->prev_filters = NULL; - png_free(png_ptr, old); - } - if (png_ptr->filter_weights != NULL) - { - png_uint_16p old = png_ptr->filter_weights; - png_ptr->filter_weights = NULL; - png_free(png_ptr, old); + png_warning(png_ptr, "Unknown filter heuristic method"); + return; } - if (png_ptr->inv_filter_weights != NULL) + if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) { - png_uint_16p old = png_ptr->inv_filter_weights; - png_ptr->inv_filter_weights = NULL; - png_free(png_ptr, old); + heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; } - /* Leave the filter_costs - this array is fixed size. */ -} - -static int -png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method, - int num_weights) -{ - if (png_ptr == NULL) - return 0; - - /* Clear out the arrays */ - png_reset_filter_heuristics(png_ptr); - - /* Check arguments; the 'reset' function makes the correct settings for the - * unweighted case, but we must handle the weight case by initializing the - * arrays for the caller. - */ - if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + if (num_weights < 0 || filter_weights == NULL || + heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) { - int i; + num_weights = 0; + } - if (num_weights > 0) + png_ptr->num_prev_filters = (png_byte)num_weights; + png_ptr->heuristic_method = (png_byte)heuristic_method; + + if (num_weights > 0) + { + if (png_ptr->prev_filters == NULL) { png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)((sizeof (png_byte)) * num_weights)); + (png_uint_32)(png_sizeof(png_byte) * num_weights)); /* To make sure that the weighting starts out fairly */ for (i = 0; i < num_weights; i++) { png_ptr->prev_filters[i] = 255; } + } + if (png_ptr->filter_weights == NULL) + { png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)((sizeof (png_uint_16)) * num_weights)); + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)((sizeof (png_uint_16)) * num_weights)); - + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); for (i = 0; i < num_weights; i++) { png_ptr->inv_filter_weights[i] = png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; } - - /* Safe to set this now */ - png_ptr->num_prev_filters = (png_byte)num_weights; } - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) + for (i = 0; i < num_weights; i++) { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); + if (filter_weights[i] < 0.0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } + else + { + png_ptr->inv_filter_weights[i] = + (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); + png_ptr->filter_weights[i] = + (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); + } } + } + + /* If, in the future, there are other filter methods, this would + * need to be based on png_ptr->filter. + */ + if (png_ptr->filter_costs == NULL) + { + png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + + png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) { png_ptr->inv_filter_costs[i] = png_ptr->filter_costs[i] = PNG_COST_FACTOR; } - - /* All the arrays are inited, safe to set this: */ - png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED; - - /* Return the 'ok' code. */ - return 1; } - else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - return 1; - } - else - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return 0; - } -} -/* Provide floating and fixed point APIs */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method, - int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs) -{ - png_debug(1, "in png_set_filter_heuristics"); - - /* The internal API allocates all the arrays and ensures that the elements of - * those arrays are set to the default value. + /* Here is where we set the relative costs of the different filters. We + * should take the desired compression level into account when setting + * the costs, so that Paeth, for instance, has a high relative cost at low + * compression levels, while it has a lower relative cost at higher + * compression settings. The filter types are in order of increasing + * relative cost, so it would be possible to do this with an algorithm. */ - if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) - return; - - /* If using the weighted method copy in the weights. */ - if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) { - int i; - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] <= 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); - - png_ptr->filter_weights[i] = - (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0) + if (filter_costs == NULL || filter_costs[i] < 0.0) { png_ptr->inv_filter_costs[i] = - (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); - + png_ptr->filter_costs[i] = PNG_COST_FACTOR; + } + else if (filter_costs[i] >= 1.0) + { + png_ptr->inv_filter_costs[i] = + (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); png_ptr->filter_costs[i] = - (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); + (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); } } } -#endif /* FLOATING_POINT */ - -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, - int num_weights, png_const_fixed_point_p filter_weights, - png_const_fixed_point_p filter_costs) -{ - png_debug(1, "in png_set_filter_heuristics_fixed"); - - /* The internal API allocates all the arrays and ensures that the elements of - * those arrays are set to the default value. - */ - if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) - return; - - /* If using the weighted method copy in the weights. */ - if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int i; - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] <= 0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - - else - { - png_ptr->inv_filter_weights[i] = (png_uint_16) - ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); - - png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* - PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - if (filter_costs[i] >= PNG_FP_1) - { - png_uint_32 tmp; - - /* Use a 32 bit unsigned temporary here because otherwise the - * intermediate value will be a 32 bit *signed* integer (ANSI rules) - * and this will get the wrong answer on division. - */ - tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2); - tmp /= filter_costs[i]; - - png_ptr->inv_filter_costs[i] = (png_uint_16)tmp; - - tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF; - tmp /= PNG_FP_1; - - png_ptr->filter_costs[i] = (png_uint_16)tmp; - } - } -} -#endif /* FIXED_POINT */ #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ void PNGAPI -png_set_compression_level(png_structrp png_ptr, int level) +png_set_compression_level(png_structp png_ptr, int level) { - png_debug(1, "in png_set_compression_level"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_compression_level\n"); + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; png_ptr->zlib_level = level; } void PNGAPI -png_set_compression_mem_level(png_structrp png_ptr, int mem_level) +png_set_compression_mem_level(png_structp png_ptr, int mem_level) { - png_debug(1, "in png_set_compression_mem_level"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_compression_mem_level\n"); + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; png_ptr->zlib_mem_level = mem_level; } void PNGAPI -png_set_compression_strategy(png_structrp png_ptr, int strategy) +png_set_compression_strategy(png_structp png_ptr, int strategy) { - png_debug(1, "in png_set_compression_strategy"); - - if (png_ptr == NULL) - return; - - /* The flag setting here prevents the libpng dynamic selection of strategy. - */ + png_debug(1, "in png_set_compression_strategy\n"); png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; png_ptr->zlib_strategy = strategy; } -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ void PNGAPI -png_set_compression_window_bits(png_structrp png_ptr, int window_bits) +png_set_compression_window_bits(png_structp png_ptr, int window_bits) { - if (png_ptr == NULL) - return; - - /* Prior to 1.6.0 this would warn but then set the window_bits value, this - * meant that negative window bits values could be selected which would cause - * libpng to write a non-standard PNG file with raw deflate or gzip - * compressed IDAT or ancillary chunks. Such files can be read and there is - * no warning on read, so this seems like a very bad idea. - */ if (window_bits > 15) - { png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - window_bits = 15; - } - else if (window_bits < 8) - { png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); - window_bits = 8; - } - +#ifndef WBITS_8_OK + /* avoid libpng bug with 256-byte windows */ + if (window_bits == 8) + { + png_warning(png_ptr, "Compression window is being reset to 512"); + window_bits=9; + } +#endif + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; png_ptr->zlib_window_bits = window_bits; } void PNGAPI -png_set_compression_method(png_structrp png_ptr, int method) +png_set_compression_method(png_structp png_ptr, int method) { - png_debug(1, "in png_set_compression_method"); - - if (png_ptr == NULL) - return; - - /* This would produce an invalid PNG file if it worked, but it doesn't and - * deflate will fault it, so it is harmless to just warn here. - */ + png_debug(1, "in png_set_compression_method\n"); if (method != 8) png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; png_ptr->zlib_method = method; } -/* The following were added to libpng-1.5.4 */ -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED void PNGAPI -png_set_text_compression_level(png_structrp png_ptr, int level) +png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) { - png_debug(1, "in png_set_text_compression_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_level = level; -} - -void PNGAPI -png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_text_compression_mem_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_mem_level = mem_level; -} - -void PNGAPI -png_set_text_compression_strategy(png_structrp png_ptr, int strategy) -{ - png_debug(1, "in png_set_text_compression_strategy"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_strategy = strategy; -} - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -void PNGAPI -png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - - if (window_bits > 15) - { - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - window_bits = 15; - } - - else if (window_bits < 8) - { - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); - window_bits = 8; - } - - png_ptr->zlib_text_window_bits = window_bits; -} - -void PNGAPI -png_set_text_compression_method(png_structrp png_ptr, int method) -{ - png_debug(1, "in png_set_text_compression_method"); - - if (png_ptr == NULL) - return; - - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - - png_ptr->zlib_text_method = method; -} -#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ -/* end of API added to libpng-1.5.4 */ - -void PNGAPI -png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->write_row_fn = write_row_fn; } -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) void PNGAPI -png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr - write_user_transform_fn) +png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + write_user_transform_fn) { - png_debug(1, "in png_set_write_user_transform_fn"); - - if (png_ptr == NULL) - return; - + png_debug(1, "in png_set_write_user_transform_fn\n"); png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->write_user_transform_fn = write_user_transform_fn; } #endif -#ifdef PNG_INFO_IMAGE_SUPPORTED +#if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI -png_write_png(png_structrp png_ptr, png_inforp info_ptr, - int transforms, voidp params) +png_write_png(png_structp png_ptr, png_infop info_ptr, + int transforms, voidp params) { - if (png_ptr == NULL || info_ptr == NULL) - return; +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel from opacity to transparency */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif /* Write the file header information. */ png_write_info(png_ptr, info_ptr); /* ------ these transformations don't touch the info structure ------- */ -#ifdef PNG_WRITE_INVERT_SUPPORTED - /* Invert monochrome pixels */ +#if defined(PNG_WRITE_INVERT_SUPPORTED) + /* invert monochrome pixels */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif -#ifdef PNG_WRITE_SHIFT_SUPPORTED +#if defined(PNG_WRITE_SHIFT_SUPPORTED) /* Shift the pixels up to a legal bit depth and fill in * as appropriate to correctly scale the image. */ if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); + && (info_ptr->valid & PNG_INFO_sBIT)) + png_set_shift(png_ptr, &info_ptr->sig_bit); #endif -#ifdef PNG_WRITE_PACK_SUPPORTED - /* Pack pixels into bytes */ +#if defined(PNG_WRITE_PACK_SUPPORTED) + /* pack pixels into bytes */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED - /* Swap location of alpha bytes from ARGB to RGBA */ +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + /* swap location of alpha bytes from ARGB to RGBA */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); + png_set_swap_alpha(png_ptr); #endif -#ifdef PNG_WRITE_FILLER_SUPPORTED - /* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) - png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); - - else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); +#if defined(PNG_WRITE_FILLER_SUPPORTED) + /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into + * RGB (4 channels -> 3 channels). The second parameter is not used. + */ + if (transforms & PNG_TRANSFORM_STRIP_FILLER) + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); #endif -#ifdef PNG_WRITE_BGR_SUPPORTED - /* Flip BGR pixels to RGB */ +#if defined(PNG_WRITE_BGR_SUPPORTED) + /* flip BGR pixels to RGB */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif -#ifdef PNG_WRITE_SWAP_SUPPORTED - /* Swap bytes of 16-bit files to most significant byte first */ +#if defined(PNG_WRITE_SWAP_SUPPORTED) + /* swap bytes of 16-bit files to most significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); + png_set_swap(png_ptr); #endif -#ifdef PNG_WRITE_PACKSWAP_SUPPORTED - /* Swap bits of 1, 2, 4 bit packed pixel formats */ +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) + /* swap bits of 1, 2, 4 bit packed pixel formats */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED - /* Invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); + png_set_packswap(png_ptr); #endif /* ----------------------- end of transformations ------------------- */ - /* Write the bits */ + /* write the bits */ if (info_ptr->valid & PNG_INFO_IDAT) png_write_image(png_ptr, info_ptr->row_pointers); /* It is REQUIRED to call this to finish writing the rest of the file */ png_write_end(png_ptr, info_ptr); - PNG_UNUSED(transforms) /* Quiet compiler warnings */ - PNG_UNUSED(params) + if(transforms == 0 || params == NULL) + /* quiet compiler warnings */ return; } #endif - - -#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -#ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */ -/* Initialize the write structure - general purpose utility. */ -static int -png_image_write_init(png_imagep image) -{ - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image, - png_safe_error, png_safe_warning); - - if (png_ptr != NULL) - { - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (info_ptr != NULL) - { - png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); - - if (control != NULL) - { - memset(control, 0, (sizeof *control)); - - control->png_ptr = png_ptr; - control->info_ptr = info_ptr; - control->for_write = 1; - - image->opaque = control; - return 1; - } - - /* Error clean up */ - png_destroy_info_struct(png_ptr, &info_ptr); - } - - png_destroy_write_struct(&png_ptr, NULL); - } - - return png_image_error(image, "png_image_write_: out of memory"); -} - -/* Arguments to png_image_write_main: */ -typedef struct -{ - /* Arguments: */ - png_imagep image; - png_const_voidp buffer; - png_int_32 row_stride; - png_const_voidp colormap; - int convert_to_8bit; - /* Local variables: */ - png_const_voidp first_row; - ptrdiff_t row_bytes; - png_voidp local_row; -} png_image_write_control; - -/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to - * do any necessary byte swapping. The component order is defined by the - * png_image format value. - */ -static int -png_write_image_16bit(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - - png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, - display->first_row); - png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); - png_uint_16p row_end; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; - int aindex = 0; - png_uint_32 y = image->height; - - if (image->format & PNG_FORMAT_FLAG_ALPHA) - { - if (image->format & PNG_FORMAT_FLAG_AFIRST) - { - aindex = -1; - ++input_row; /* To point to the first component */ - ++output_row; - } - - else - aindex = channels; - } - - else - png_error(png_ptr, "png_write_image: internal call error"); - - /* Work out the output row end and count over this, note that the increment - * above to 'row' means that row_end can actually be beyond the end of the - * row; this is correct. - */ - row_end = output_row + image->width * (channels+1); - - while (y-- > 0) - { - png_const_uint_16p in_ptr = input_row; - png_uint_16p out_ptr = output_row; - - while (out_ptr < row_end) - { - const png_uint_16 alpha = in_ptr[aindex]; - png_uint_32 reciprocal = 0; - int c; - - out_ptr[aindex] = alpha; - - /* Calculate a reciprocal. The correct calculation is simply - * component/alpha*65535 << 15. (I.e. 15 bits of precision); this - * allows correct rounding by adding .5 before the shift. 'reciprocal' - * is only initialized when required. - */ - if (alpha > 0 && alpha < 65535) - reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; - - c = channels; - do /* always at least one channel */ - { - png_uint_16 component = *in_ptr++; - - /* The following gives 65535 for an alpha of 0, which is fine, - * otherwise if 0/0 is represented as some other value there is more - * likely to be a discontinuity which will probably damage - * compression when moving from a fully transparent area to a - * nearly transparent one. (The assumption here is that opaque - * areas tend not to be 0 intensity.) - */ - if (component >= alpha) - component = 65535; - - /* component 0 && alpha < 65535) - { - png_uint_32 calc = component * reciprocal; - calc += 16384; /* round to nearest */ - component = (png_uint_16)(calc >> 15); - } - - *out_ptr++ = component; - } - while (--c > 0); - - /* Skip to next component (skip the intervening alpha channel) */ - ++in_ptr; - ++out_ptr; - } - - png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); - } - - return 1; -} - -/* Given 16-bit input (1 to 4 channels) write 8-bit output. If an alpha channel - * is present it must be removed from the components, the components are then - * written in sRGB encoding. No components are added or removed. - * - * Calculate an alpha reciprocal to reverse pre-multiplication. As above the - * calculation can be done to 15 bits of accuracy; however, the output needs to - * be scaled in the range 0..255*65535, so include that scaling here. - */ -#define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha) - -static png_byte -png_unpremultiply(png_uint_32 component, png_uint_32 alpha, - png_uint_32 reciprocal/*from the above macro*/) -{ - /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 - * is represented as some other value there is more likely to be a - * discontinuity which will probably damage compression when moving from a - * fully transparent area to a nearly transparent one. (The assumption here - * is that opaque areas tend not to be 0 intensity.) - * - * There is a rounding problem here; if alpha is less than 128 it will end up - * as 0 when scaled to 8 bits. To avoid introducing spurious colors into the - * output change for this too. - */ - if (component >= alpha || alpha < 128) - return 255; - - /* component 0) - { - /* The test is that alpha/257 (rounded) is less than 255, the first value - * that becomes 255 is 65407. - * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore, - * be exact!) [Could also test reciprocal != 0] - */ - if (alpha < 65407) - { - component *= reciprocal; - component += 64; /* round to nearest */ - component >>= 7; - } - - else - component *= 255; - - /* Convert the component to sRGB. */ - return (png_byte)PNG_sRGB_FROM_LINEAR(component); - } - - else - return 0; -} - -static int -png_write_image_8bit(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - - png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, - display->first_row); - png_bytep output_row = png_voidcast(png_bytep, display->local_row); - png_uint_32 y = image->height; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; - - if (image->format & PNG_FORMAT_FLAG_ALPHA) - { - png_bytep row_end; - int aindex; - - if (image->format & PNG_FORMAT_FLAG_AFIRST) - { - aindex = -1; - ++input_row; /* To point to the first component */ - ++output_row; - } - - else - aindex = channels; - - /* Use row_end in place of a loop counter: */ - row_end = output_row + image->width * (channels+1); - - while (y-- > 0) - { - png_const_uint_16p in_ptr = input_row; - png_bytep out_ptr = output_row; - - while (out_ptr < row_end) - { - png_uint_16 alpha = in_ptr[aindex]; - png_byte alphabyte = (png_byte)PNG_DIV257(alpha); - png_uint_32 reciprocal = 0; - int c; - - /* Scale and write the alpha channel. */ - out_ptr[aindex] = alphabyte; - - if (alphabyte > 0 && alphabyte < 255) - reciprocal = UNP_RECIPROCAL(alpha); - - c = channels; - do /* always at least one channel */ - *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); - while (--c > 0); - - /* Skip to next component (skip the intervening alpha channel) */ - ++in_ptr; - ++out_ptr; - } /* while out_ptr < row_end */ - - png_write_row(png_ptr, png_voidcast(png_const_bytep, - display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); - } /* while y */ - } - - else - { - /* No alpha channel, so the row_end really is the end of the row and it - * is sufficient to loop over the components one by one. - */ - png_bytep row_end = output_row + image->width * channels; - - while (y-- > 0) - { - png_const_uint_16p in_ptr = input_row; - png_bytep out_ptr = output_row; - - while (out_ptr < row_end) - { - png_uint_32 component = *in_ptr++; - - component *= 255; - *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component); - } - - png_write_row(png_ptr, output_row); - input_row += display->row_bytes/(sizeof (png_uint_16)); - } - } - - return 1; -} - -static void -png_image_set_PLTE(png_image_write_control *display) -{ - const png_imagep image = display->image; - const void *cmap = display->colormap; - const int entries = image->colormap_entries > 256 ? 256 : - (int)image->colormap_entries; - - /* NOTE: the caller must check for cmap != NULL and entries != 0 */ - const png_uint_32 format = image->format; - const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); - -# ifdef PNG_FORMAT_BGR_SUPPORTED - const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && - (format & PNG_FORMAT_FLAG_ALPHA) != 0; -# else -# define afirst 0 -# endif - -# ifdef PNG_FORMAT_BGR_SUPPORTED - const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; -# else -# define bgr 0 -# endif - - int i, num_trans; - png_color palette[256]; - png_byte tRNS[256]; - - memset(tRNS, 255, (sizeof tRNS)); - memset(palette, 0, (sizeof palette)); - - for (i=num_trans=0; i= 3) /* RGB */ - { - palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[(2 ^ bgr)]); - palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[1]); - palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[bgr]); - } - - else /* Gray */ - palette[i].blue = palette[i].red = palette[i].green = - (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry); - } - - else /* alpha */ - { - png_uint_16 alpha = entry[afirst ? 0 : channels-1]; - png_byte alphabyte = (png_byte)PNG_DIV257(alpha); - png_uint_32 reciprocal = 0; - - /* Calculate a reciprocal, as in the png_write_image_8bit code above - * this is designed to produce a value scaled to 255*65535 when - * divided by 128 (i.e. asr 7). - */ - if (alphabyte > 0 && alphabyte < 255) - reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha; - - tRNS[i] = alphabyte; - if (alphabyte < 255) - num_trans = i+1; - - if (channels >= 3) /* RGB */ - { - palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], - alpha, reciprocal); - palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, - reciprocal); - palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, - reciprocal); - } - - else /* gray */ - palette[i].blue = palette[i].red = palette[i].green = - png_unpremultiply(entry[afirst], alpha, reciprocal); - } - } - - else /* Color-map has sRGB values */ - { - png_const_bytep entry = png_voidcast(png_const_bytep, cmap); - - entry += i * channels; - - switch (channels) - { - case 4: - tRNS[i] = entry[afirst ? 0 : 3]; - if (tRNS[i] < 255) - num_trans = i+1; - /* FALL THROUGH */ - case 3: - palette[i].blue = entry[afirst + (2 ^ bgr)]; - palette[i].green = entry[afirst + 1]; - palette[i].red = entry[afirst + bgr]; - break; - - case 2: - tRNS[i] = entry[1 ^ afirst]; - if (tRNS[i] < 255) - num_trans = i+1; - /* FALL THROUGH */ - case 1: - palette[i].blue = palette[i].red = palette[i].green = - entry[afirst]; - break; - - default: - break; - } - } - } - -# ifdef afirst -# undef afirst -# endif -# ifdef bgr -# undef bgr -# endif - - png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, - entries); - - if (num_trans > 0) - png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, - num_trans, NULL); - - image->colormap_entries = entries; -} - -static int -png_image_write_main(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - png_uint_32 format = image->format; - - int colormap = (format & PNG_FORMAT_FLAG_COLORMAP) != 0; - int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR) != 0; /* input */ - int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0; - int write_16bit = linear && !colormap && !display->convert_to_8bit; - -# ifdef PNG_BENIGN_ERRORS_SUPPORTED - /* Make sure we error out on any bad situation */ - png_set_benign_errors(png_ptr, 0/*error*/); -# endif - - /* Default the 'row_stride' parameter if required. */ - if (display->row_stride == 0) - display->row_stride = PNG_IMAGE_ROW_STRIDE(*image); - - /* Set the required transforms then write the rows in the correct order. */ - if (format & PNG_FORMAT_FLAG_COLORMAP) - { - if (display->colormap != NULL && image->colormap_entries > 0) - { - png_uint_32 entries = image->colormap_entries; - - png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), - PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_image_set_PLTE(display); - } - - else - png_error(image->opaque->png_ptr, - "no color-map for color-mapped image"); - } - - else - png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - write_16bit ? 16 : 8, - ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + - ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* Counter-intuitively the data transformations must be called *after* - * png_write_info, not before as in the read code, but the 'set' functions - * must still be called before. Just set the color space information, never - * write an interlaced image. - */ - - if (write_16bit) - { - /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */ - png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR); - - if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) - png_set_cHRM_fixed(png_ptr, info_ptr, - /* color x y */ - /* white */ 31270, 32900, - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000 - ); - } - - else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) - png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); - - /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit - * space must still be gamma encoded. - */ - else - png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); - - /* Write the file header. */ - png_write_info(png_ptr, info_ptr); - - /* Now set up the data transformations (*after* the header is written), - * remove the handled transformations from the 'format' flags for checking. - * - * First check for a little endian system if writing 16 bit files. - */ - if (write_16bit) - { - PNG_CONST png_uint_16 le = 0x0001; - - if (*(png_const_bytep)&le) - png_set_swap(png_ptr); - } - -# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED - if (format & PNG_FORMAT_FLAG_BGR) - { - if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0) - png_set_bgr(png_ptr); - format &= ~PNG_FORMAT_FLAG_BGR; - } -# endif - -# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED - if (format & PNG_FORMAT_FLAG_AFIRST) - { - if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0) - png_set_swap_alpha(png_ptr); - format &= ~PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* If there are 16 or fewer color-map entries we wrote a lower bit depth - * above, but the application data is still byte packed. - */ - if (colormap && image->colormap_entries <= 16) - png_set_packing(png_ptr); - - /* That should have handled all (both) the transforms. */ - if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR | - PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0) - png_error(png_ptr, "png_write_image: unsupported transformation"); - - { - png_const_bytep row = png_voidcast(png_const_bytep, display->buffer); - ptrdiff_t row_bytes = display->row_stride; - - if (linear) - row_bytes *= (sizeof (png_uint_16)); - - if (row_bytes < 0) - row += (image->height-1) * (-row_bytes); - - display->first_row = row; - display->row_bytes = row_bytes; - } - - /* Apply 'fast' options if the flag is set. */ - if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0) - { - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS); - /* NOTE: determined by experiment using pngstest, this reflects some - * balance between the time to write the image once and the time to read - * it about 50 times. The speed-up in pngstest was about 10-20% of the - * total (user) time on a heavily loaded system. - */ - png_set_compression_level(png_ptr, 3); - } - - /* Check for the cases that currently require a pre-transform on the row - * before it is written. This only applies when the input is 16-bit and - * either there is an alpha channel or it is converted to 8-bit. - */ - if ((linear && alpha) || (!colormap && display->convert_to_8bit)) - { - png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr))); - int result; - - display->local_row = row; - if (write_16bit) - result = png_safe_execute(image, png_write_image_16bit, display); - else - result = png_safe_execute(image, png_write_image_8bit, display); - display->local_row = NULL; - - png_free(png_ptr, row); - - /* Skip the 'write_end' on error: */ - if (!result) - return 0; - } - - /* Otherwise this is the case where the input is in a format currently - * supported by the rest of the libpng write code; call it directly. - */ - else - { - png_const_bytep row = png_voidcast(png_const_bytep, display->first_row); - ptrdiff_t row_bytes = display->row_bytes; - png_uint_32 y = image->height; - - while (y-- > 0) - { - png_write_row(png_ptr, row); - row += row_bytes; - } - } - - png_write_end(png_ptr, info_ptr); - return 1; -} - -int PNGAPI -png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) -{ - /* Write the image to the given (FILE*). */ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file != NULL) - { - if (png_image_write_init(image)) - { - png_image_write_control display; - int result; - - /* This is slightly evil, but png_init_io doesn't do anything other - * than this and we haven't changed the standard IO functions so - * this saves a 'safe' function. - */ - image->opaque->png_ptr->io_ptr = file; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.convert_to_8bit = convert_to_8bit; - - result = png_safe_execute(image, png_image_write_main, &display); - png_image_free(image); - return result; - } - - else - return 0; - } - - else - return png_image_error(image, - "png_image_write_to_stdio: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); - - else - return 0; -} - -int PNGAPI -png_image_write_to_file(png_imagep image, const char *file_name, - int convert_to_8bit, const void *buffer, png_int_32 row_stride, - const void *colormap) -{ - /* Write the image to the named file. */ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file_name != NULL) - { - FILE *fp = fopen(file_name, "wb"); - - if (fp != NULL) - { - if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, - row_stride, colormap)) - { - int error; /* from fflush/fclose */ - - /* Make sure the file is flushed correctly. */ - if (fflush(fp) == 0 && ferror(fp) == 0) - { - if (fclose(fp) == 0) - return 1; - - error = errno; /* from fclose */ - } - - else - { - error = errno; /* from fflush or ferror */ - (void)fclose(fp); - } - - (void)remove(file_name); - /* The image has already been cleaned up; this is just used to - * set the error (because the original write succeeded). - */ - return png_image_error(image, strerror(error)); - } - - else - { - /* Clean up: just the opened file. */ - (void)fclose(fp); - (void)remove(file_name); - return 0; - } - } - - else - return png_image_error(image, strerror(errno)); - } - - else - return png_image_error(image, - "png_image_write_to_file: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); - - else - return 0; -} -#endif /* PNG_STDIO_SUPPORTED */ -#endif /* SIMPLIFIED_WRITE */ #endif /* PNG_WRITE_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngwtran.c b/Source/3rd Party/wx/src/png/pngwtran.c index 98703f8c8..94d8ecc1c 100644 --- a/Source/3rd Party/wx/src/png/pngwtran.c +++ b/Source/3rd Party/wx/src/png/pngwtran.c @@ -1,98 +1,84 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" - +#define PNG_INTERNAL +#include "png.h" #ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED /* Transform the data according to the user's wishes. The order of * transformations is significant. */ void /* PRIVATE */ -png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) +png_do_write_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_write_transformations"); + png_debug(1, "in png_do_write_transformations\n"); if (png_ptr == NULL) return; -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) if (png_ptr->transformations & PNG_USER_TRANSFORM) - if (png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* User write transform - function */ - (png_ptr, /* png_ptr */ - row_info, /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_size_t rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ + if(png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* user write transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ #endif - -#ifdef PNG_WRITE_FILLER_SUPPORTED +#if defined(PNG_WRITE_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->flags); #endif - -#ifdef PNG_WRITE_PACKSWAP_SUPPORTED +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(row_info, png_ptr->row_buf + 1); + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - -#ifdef PNG_WRITE_PACK_SUPPORTED +#if defined(PNG_WRITE_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) - png_do_pack(row_info, png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); + png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->bit_depth); #endif - -#ifdef PNG_WRITE_SWAP_SUPPORTED +#if defined(PNG_WRITE_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(row_info, png_ptr->row_buf + 1); + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - -#ifdef PNG_WRITE_SHIFT_SUPPORTED +#if defined(PNG_WRITE_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); + png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); #endif - -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1); + png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - -#ifdef PNG_WRITE_BGR_SUPPORTED +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_ALPHA) + png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif +#if defined(PNG_WRITE_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) - png_do_bgr(row_info, png_ptr->row_buf + 1); + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - -#ifdef PNG_WRITE_INVERT_SUPPORTED +#if defined(PNG_WRITE_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(row_info, png_ptr->row_buf + 1); + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif } -#ifdef PNG_WRITE_PACK_SUPPORTED +#if defined(PNG_WRITE_PACK_SUPPORTED) /* Pack pixels into bytes. Pass the true bit depth in bit_depth. The * row_info bit depth should be 8 (one pixel per byte). The channels * should be 1 (this only happens on grayscale and paletted images). @@ -100,9 +86,11 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) void /* PRIVATE */ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { - png_debug(1, "in png_do_pack"); - + png_debug(1, "in png_do_pack\n"); if (row_info->bit_depth == 8 && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif row_info->channels == 1) { switch ((int)bit_depth) @@ -123,12 +111,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { if (*sp != 0) v |= mask; - sp++; - if (mask > 1) mask >>= 1; - else { mask = 0x80; @@ -137,13 +122,10 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) v = 0; } } - if (mask != 0x80) *dp = (png_byte)v; - break; } - case 2: { png_bytep sp, dp; @@ -155,14 +137,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 6; v = 0; - for (i = 0; i < row_width; i++) { png_byte value; value = (png_byte)(*sp & 0x03); v |= (value << shift); - if (shift == 0) { shift = 6; @@ -170,19 +150,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } - else shift -= 2; - sp++; } - if (shift != 6) *dp = (png_byte)v; - break; } - case 4: { png_bytep sp, dp; @@ -194,7 +169,6 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 4; v = 0; - for (i = 0; i < row_width; i++) { png_byte value; @@ -209,32 +183,25 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } - else shift -= 4; sp++; } - if (shift != 4) *dp = (png_byte)v; - break; } - - default: - break; } - row_info->bit_depth = (png_byte)bit_depth; row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); + row_info->width); } } #endif -#ifdef PNG_WRITE_SHIFT_SUPPORTED +#if defined(PNG_WRITE_SHIFT_SUPPORTED) /* Shift pixel values to take advantage of whole range. Pass the * true number of bits in bit_depth. The row should be packed * according to row_info->bit_depth. Thus, if you had a row of @@ -243,12 +210,15 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) * data to 0 to 15. */ void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, - png_const_color_8p bit_depth) +png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { - png_debug(1, "in png_do_shift"); - - if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) + png_debug(1, "in png_do_shift\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && +#else + if ( +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; int channels = 0; @@ -258,23 +228,19 @@ png_do_shift(png_row_infop row_info, png_bytep row, shift_start[channels] = row_info->bit_depth - bit_depth->red; shift_dec[channels] = bit_depth->red; channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; shift_dec[channels] = bit_depth->green; channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; shift_dec[channels] = bit_depth->blue; channels++; } - else { shift_start[channels] = row_info->bit_depth - bit_depth->gray; shift_dec[channels] = bit_depth->gray; channels++; } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) { shift_start[channels] = row_info->bit_depth - bit_depth->alpha; @@ -282,44 +248,37 @@ png_do_shift(png_row_infop row_info, png_bytep row, channels++; } - /* With low row depths, could only be grayscale, so one channel */ + /* with low row depths, could only be grayscale, so one channel */ if (row_info->bit_depth < 8) { png_bytep bp = row; - png_size_t i; - unsigned int mask; - png_size_t row_bytes = row_info->rowbytes; + png_uint_32 i; + png_byte mask; + png_uint_32 row_bytes = row_info->rowbytes; if (bit_depth->gray == 1 && row_info->bit_depth == 2) mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) mask = 0x11; - else mask = 0xff; for (i = 0; i < row_bytes; i++, bp++) { + png_uint_16 v; int j; - unsigned int v, out; v = *bp; - out = 0; - + *bp = 0; for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) { if (j > 0) - out |= v << j; - + *bp |= (png_byte)((v << j) & 0xff); else - out |= (v >> (-j)) & mask; + *bp |= (png_byte)((v >> (-j)) & mask); } - - *bp = (png_byte)(out & 0xff); } } - else if (row_info->bit_depth == 8) { png_bytep bp = row; @@ -329,26 +288,21 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (i = 0; i < istop; i++, bp++) { - const unsigned int c = i%channels; + png_uint_16 v; int j; - unsigned int v, out; + int c = (int)(i%channels); v = *bp; - out = 0; - + *bp = 0; for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - out |= v << j; - + *bp |= (png_byte)((v << j) & 0xff); else - out |= v >> (-j); + *bp |= (png_byte)((v >> (-j)) & 0xff); } - - *bp = (png_byte)(out & 0xff); } } - else { png_bytep bp; @@ -357,22 +311,20 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (bp = row, i = 0; i < istop; i++) { - const unsigned int c = i%channels; + int c = (int)(i%channels); + png_uint_16 value, v; int j; - unsigned int value, v; - v = png_get_uint_16(bp); + v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - value |= v << j; - + value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); else - value |= v >> (-j); + value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); } - *bp++ = (png_byte)((value >> 8) & 0xff); + *bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)(value & 0xff); } } @@ -380,22 +332,23 @@ png_do_shift(png_row_infop row_info, png_bytep row, } #endif -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_swap_alpha"); - + png_debug(1, "in png_do_write_swap_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + /* This converts from ARGB to RGBA */ if (row_info->bit_depth == 8) { - /* This converts from ARGB to RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) { png_byte save = *(sp++); @@ -405,11 +358,9 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This converts from AARRGGBB to RRGGBBAA */ else { - /* This converts from AARRGGBB to RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -429,14 +380,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + /* This converts from AG to GA */ if (row_info->bit_depth == 8) { - /* This converts from AG to GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -448,11 +397,9 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This converts from AAGG to GGAA */ else { - /* This converts from AAGG to GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -468,71 +415,61 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } #endif -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_invert_alpha"); - + png_debug(1, "in png_do_write_invert_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { - /* This inverts the alpha channel in RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) { - /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); - */ - sp+=3; dp = sp; *(dp++) = (png_byte)(255 - *(sp++)); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This inverts the alpha channel in RRGGBBAA */ else { - /* This inverts the alpha channel in RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; for (i = 0, sp = dp = row; i < row_width; i++) { - /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); - */ - sp+=6; dp = sp; *(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++)); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { - /* This inverts the alpha channel in GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -543,41 +480,37 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This inverts the alpha channel in GGAA */ else { - /* This inverts the alpha channel in GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; for (i = 0, sp = dp = row; i < row_width; i++) { - /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); - */ - sp+=2; dp = sp; *(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++)); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } #endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ -#ifdef PNG_MNG_FEATURES_SUPPORTED -/* Undoes intrapixel differencing */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* undoes intrapixel differencing */ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_intrapixel"); - - if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_write_intrapixel\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; @@ -588,21 +521,17 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - *(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff); - *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff); + *(rp) = (png_byte)((*rp - *(rp+1))&0xff); + *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED else if (row_info->bit_depth == 16) { png_bytep rp; @@ -610,27 +539,24 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); - png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp + 1) = (png_byte)(red & 0xff); - *(rp + 4) = (png_byte)((blue >> 8) & 0xff); - *(rp + 5) = (png_byte)(blue & 0xff); + png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); + png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); + png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); + png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp+1) = (png_byte)(red & 0xff); + *(rp+4) = (png_byte)((blue >> 8) & 0xff); + *(rp+5) = (png_byte)(blue & 0xff); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ diff --git a/Source/3rd Party/wx/src/png/pngwutil.c b/Source/3rd Party/wx/src/png/pngwutil.c index 49e6a2d21..17938d227 100644 --- a/Source/3rd Party/wx/src/png/pngwutil.c +++ b/Source/3rd Party/wx/src/png/pngwutil.c @@ -1,26 +1,22 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.6.2 [April 25, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * libpng version 1.2.7 - September 12, 2004 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2004 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h */ -#include "pngpriv.h" - +#define PNG_INTERNAL +#include "png.h" #ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED /* Place a 32-bit number into a buffer in PNG byte order. We work * with unsigned numbers for convenience, although one supported * ancillary chunk uses signed (two's complement) numbers. */ -void PNGAPI +void /* PRIVATE */ png_save_uint_32(png_bytep buf, png_uint_32 i) { buf[0] = (png_byte)((i >> 24) & 0xff); @@ -29,139 +25,31 @@ png_save_uint_32(png_bytep buf, png_uint_32 i) buf[3] = (png_byte)(i & 0xff); } +#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) +/* The png_save_int_32 function assumes integers are stored in two's + * complement format. If this isn't the case, then this routine needs to + * be modified to write data in two's complement format. + */ +void /* PRIVATE */ +png_save_int_32(png_bytep buf, png_int_32 i) +{ + buf[0] = (png_byte)((i >> 24) & 0xff); + buf[1] = (png_byte)((i >> 16) & 0xff); + buf[2] = (png_byte)((i >> 8) & 0xff); + buf[3] = (png_byte)(i & 0xff); +} +#endif + /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ -void PNGAPI +void /* PRIVATE */ png_save_uint_16(png_bytep buf, unsigned int i) { buf[0] = (png_byte)((i >> 8) & 0xff); buf[1] = (png_byte)(i & 0xff); } -#endif - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void PNGAPI -png_write_sig(png_structrp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the signature is being written */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; -#endif - - /* Write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)(8 - png_ptr->sig_bytes)); - - if (png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -static void -png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, - png_uint_32 length) -{ - png_byte buf[8]; - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) - PNG_CSTRING_FROM_CHUNK(buf, chunk_name); - png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); -#endif - - if (png_ptr == NULL) - return; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the chunk header is being written. - * PNG_IO_CHUNK_HDR requires a single I/O call. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; -#endif - - /* Write the length and the chunk name */ - png_save_uint_32(buf, length); - png_save_uint_32(buf + 4, chunk_name); - png_write_data(png_ptr, buf, 8); - - /* Put the chunk name into png_ptr->chunk_name */ - png_ptr->chunk_name = chunk_name; - - /* Reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - - png_calculate_crc(png_ptr, buf + 4, 4); - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that chunk data will (possibly) be written. - * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; -#endif -} - -void PNGAPI -png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string, - png_uint_32 length) -{ - png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length); -} - -/* Write the data of a PNG chunk started with png_write_chunk_header(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_header(). - */ -void PNGAPI -png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, - png_size_t length) -{ - /* Write the data, and run the CRC over it */ - if (png_ptr == NULL) - return; - - if (data != NULL && length > 0) - { - png_write_data(png_ptr, data, length); - - /* Update the CRC after writing the data, - * in case that the user I/O routine alters it. - */ - png_calculate_crc(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_header(). */ -void PNGAPI -png_write_chunk_end(png_structrp png_ptr) -{ - png_byte buf[4]; - - if (png_ptr == NULL) return; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the chunk CRC is being written. - * PNG_IO_CHUNK_CRC requires a single I/O function call. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; -#endif - - /* Write the crc in a single operation */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} /* Write a PNG chunk all at once. The type is an array of ASCII characters * representing the chunk name. The array must be at least 4 bytes in @@ -172,577 +60,306 @@ png_write_chunk_end(png_structrp png_ptr) * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() * functions instead. */ -static void -png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, - png_const_bytep data, png_size_t length) +void PNGAPI +png_write_chunk(png_structp png_ptr, png_bytep chunk_name, + png_bytep data, png_size_t length) { - if (png_ptr == NULL) - return; - - /* On 64 bit architectures 'length' may not fit in a png_uint_32. */ - if (length > PNG_UINT_31_MAX) - png_error(png_ptr, "length exceeds PNG maxima"); - - png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); + png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); png_write_chunk_data(png_ptr, data, length); png_write_chunk_end(png_ptr); } -/* This is the API that calls the internal function above. */ -void PNGAPI -png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, - png_const_bytep data, png_size_t length) -{ - png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, - length); -} - -/* This is used below to find the size of an image to pass to png_deflate_claim, - * so it only needs to be accurate if the size is less than 16384 bytes (the - * point at which a lower LZ window size can be used.) +/* Write the start of a PNG chunk. The type is the chunk type. + * The total_length is the sum of the lengths of all the data you will be + * passing in png_write_chunk_data(). */ -static png_alloc_size_t -png_image_size(png_structrp png_ptr) +void PNGAPI +png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, + png_uint_32 length) { - /* Only return sizes up to the maximum of a png_uint_32, do this by limiting - * the width and height used to 15 bits. - */ - png_uint_32 h = png_ptr->height; + png_byte buf[4]; + png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if (png_ptr->rowbytes < 32768 && h < 32768) - { - if (png_ptr->interlaced) - { - /* Interlacing makes the image larger because of the replication of - * both the filter byte and the padding to a byte boundary. - */ - png_uint_32 w = png_ptr->width; - unsigned int pd = png_ptr->pixel_depth; - png_alloc_size_t cb_base; - int pass; + /* write the length */ + png_save_uint_32(buf, length); + png_write_data(png_ptr, buf, (png_size_t)4); - for (cb_base=0, pass=0; pass<=6; ++pass) - { - png_uint_32 pw = PNG_PASS_COLS(w, pass); - - if (pw > 0) - cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass); - } - - return cb_base; - } - - else - return (png_ptr->rowbytes+1) * h; - } - - else - return 0xffffffffU; + /* write the chunk name */ + png_write_data(png_ptr, chunk_name, (png_size_t)4); + /* reset the crc and run it over the chunk name */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); } -#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - /* This is the code to hack the first two bytes of the deflate stream (the - * deflate header) to correct the windowBits value to match the actual data - * size. Note that the second argument is the *uncompressed* size but the - * first argument is the *compressed* data (and it must be deflate - * compressed.) - */ -static void -optimize_cmf(png_bytep data, png_alloc_size_t data_size) +/* Write the data of a PNG chunk started with png_write_chunk_start(). + * Note that multiple calls to this function are allowed, and that the + * sum of the lengths from these calls *must* add up to the total_length + * given to png_write_chunk_start(). + */ +void PNGAPI +png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) { - /* Optimize the CMF field in the zlib stream. The resultant zlib stream is - * still compliant to the stream specification. - */ - if (data_size <= 16384) /* else windowBits must be 15 */ + /* write the data, and run the CRC over it */ + if (data != NULL && length > 0) { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) - { - unsigned int z_cinfo; - unsigned int half_z_window_size; - - z_cinfo = z_cmf >> 4; - half_z_window_size = 1U << (z_cinfo + 7); - - if (data_size <= half_z_window_size) /* else no change */ - { - unsigned int tmp; - - do - { - half_z_window_size >>= 1; - --z_cinfo; - } - while (z_cinfo > 0 && data_size <= half_z_window_size); - - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - - data[0] = (png_byte)z_cmf; - tmp = data[1] & 0xe0; - tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f; - data[1] = (png_byte)tmp; - } - } - } -} -#else -# define optimize_cmf(dp,dl) ((void)0) -#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */ - -/* Initialize the compressor for the appropriate type of compression. */ -static int -png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, - png_alloc_size_t data_size) -{ - if (png_ptr->zowner != 0) - { - char msg[64]; - - PNG_STRING_FROM_CHUNK(msg, owner); - msg[4] = ':'; - msg[5] = ' '; - PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner); - /* So the message that results is " using zstream"; this is an - * internal error, but is very useful for debugging. i18n requirements - * are minimal. - */ - (void)png_safecat(msg, (sizeof msg), 10, " using zstream"); -# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC - png_warning(png_ptr, msg); - - /* Attempt sane error recovery */ - if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */ - { - png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT"); - return Z_STREAM_ERROR; - } - - png_ptr->zowner = 0; -# else - png_error(png_ptr, msg); -# endif - } - - { - int level = png_ptr->zlib_level; - int method = png_ptr->zlib_method; - int windowBits = png_ptr->zlib_window_bits; - int memLevel = png_ptr->zlib_mem_level; - int strategy; /* set below */ - int ret; /* zlib return code */ - - if (owner == png_IDAT) - { - if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) - strategy = png_ptr->zlib_strategy; - - else if (png_ptr->do_filter != PNG_FILTER_NONE) - strategy = PNG_Z_DEFAULT_STRATEGY; - - else - strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY; - } - - else - { -# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED - level = png_ptr->zlib_text_level; - method = png_ptr->zlib_text_method; - windowBits = png_ptr->zlib_text_window_bits; - memLevel = png_ptr->zlib_text_mem_level; - strategy = png_ptr->zlib_text_strategy; -# else - /* If customization is not supported the values all come from the - * IDAT values except for the strategy, which is fixed to the - * default. (This is the pre-1.6.0 behavior too, although it was - * implemented in a very different way.) - */ - strategy = Z_DEFAULT_STRATEGY; -# endif - } - - /* Adjust 'windowBits' down if larger than 'data_size'; to stop this - * happening just pass 32768 as the data_size parameter. Notice that zlib - * requires an extra 262 bytes in the window in addition to the data to be - * able to see the whole of the data, so if data_size+262 takes us to the - * next windowBits size we need to fix up the value later. (Because even - * though deflate needs the extra window, inflate does not!) - */ - if (data_size <= 16384) - { - /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to - * work round a Microsoft Visual C misbehavior which, contrary to C-90, - * widens the result of the following shift to 64-bits if (and, - * apparently, only if) it is used in a test. - */ - unsigned int half_window_size = 1U << (windowBits-1); - - while (data_size + 262 <= half_window_size) - { - half_window_size >>= 1; - --windowBits; - } - } - - /* Check against the previous initialized values, if any. */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) && - (png_ptr->zlib_set_level != level || - png_ptr->zlib_set_method != method || - png_ptr->zlib_set_window_bits != windowBits || - png_ptr->zlib_set_mem_level != memLevel || - png_ptr->zlib_set_strategy != strategy)) - { - if (deflateEnd(&png_ptr->zstream) != Z_OK) - png_warning(png_ptr, "deflateEnd failed (ignored)"); - - png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED; - } - - /* For safety clear out the input and output pointers (currently zlib - * doesn't use them on Init, but it might in the future). - */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->zstream.avail_out = 0; - - /* Now initialize if required, setting the new parameters, otherwise just - * to a simple reset to the previous parameters. - */ - if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) - ret = deflateReset(&png_ptr->zstream); - - else - { - ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, - memLevel, strategy); - - if (ret == Z_OK) - png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; - } - - /* The return code is from either deflateReset or deflateInit2; they have - * pretty much the same set of error codes. - */ - if (ret == Z_OK) - png_ptr->zowner = owner; - - else - png_zstream_error(png_ptr, ret); - - return ret; + png_calculate_crc(png_ptr, data, length); + png_write_data(png_ptr, data, length); } } -/* Clean up (or trim) a linked list of compression buffers. */ +/* Finish a chunk started with png_write_chunk_start(). */ +void PNGAPI +png_write_chunk_end(png_structp png_ptr) +{ + png_byte buf[4]; + + /* write the crc */ + png_save_uint_32(buf, png_ptr->crc); + + png_write_data(png_ptr, buf, (png_size_t)4); +} + +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. + */ void /* PRIVATE */ -png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp) +png_write_sig(png_structp png_ptr) { - png_compression_bufferp list = *listp; - - if (list != NULL) - { - *listp = NULL; - - do - { - png_compression_bufferp next = list->next; - - png_free(png_ptr, list); - list = next; - } - while (list != NULL); - } + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + /* write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)8 - png_ptr->sig_bytes); + if(png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; } -#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -/* This pair of functions encapsulates the operation of (a) compressing a +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) +/* + * This pair of functions encapsulates the operation of (a) compressing a * text string, and (b) issuing it later as a series of chunk data writes. * The compression_state structure is shared context for these functions - * set up by the caller to allow access to the relevant local variables. - * - * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size - * temporary buffers. From 1.6.0 it is retained in png_struct so that it will - * be correctly freed in the event of a write error (previous implementations - * just leaked memory.) + * set up by the caller in order to make the whole mess thread-safe. */ + typedef struct { - png_const_bytep input; /* The uncompressed input data */ - png_alloc_size_t input_len; /* Its length */ - png_uint_32 output_len; /* Final compressed length */ - png_byte output[1024]; /* First block of output */ + char *input; /* the uncompressed input data */ + int input_len; /* its length */ + int num_output_ptr; /* number of output pointers used */ + int max_output_ptr; /* size of output_ptr */ + png_charpp output_ptr; /* array of pointers to output */ } compression_state; -static void -png_text_compress_init(compression_state *comp, png_const_bytep input, - png_alloc_size_t input_len) -{ - comp->input = input; - comp->input_len = input_len; - comp->output_len = 0; -} - -/* Compress the data in the compression state input */ -static int -png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, - compression_state *comp, png_uint_32 prefix_len) +/* compress given text into storage in the png_ptr structure */ +static int /* PRIVATE */ +png_text_compress(png_structp png_ptr, + png_charp text, png_size_t text_len, int compression, + compression_state *comp) { int ret; - /* To find the length of the output it is necessary to first compress the - * input, the result is buffered rather than using the two-pass algorithm - * that is used on the inflate side; deflate is assumed to be slower and a - * PNG writer is assumed to have more memory available than a PNG reader. - * - * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an - * upper limit on the output size, but it is always bigger than the input - * size so it is likely to be more efficient to use this linked-list - * approach. - */ - ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len); + comp->num_output_ptr = comp->max_output_ptr = 0; + comp->output_ptr = NULL; + comp->input = NULL; - if (ret != Z_OK) - return ret; - - /* Set up the compression buffers, we need a loop here to avoid overflowing a - * uInt. Use ZLIB_IO_MAX to limit the input. The output is always limited - * by the output buffer size, so there is no need to check that. Since this - * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits - * in size. - */ + /* we may just want to pass the text right through */ + if (compression == PNG_TEXT_COMPRESSION_NONE) { - png_compression_bufferp *end = &png_ptr->zbuffer_list; - png_alloc_size_t input_len = comp->input_len; /* may be zero! */ - png_uint_32 output_len; + comp->input = text; + comp->input_len = text_len; + return((int)text_len); + } - /* zlib updates these for us: */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input); - png_ptr->zstream.avail_in = 0; /* Set below */ - png_ptr->zstream.next_out = comp->output; - png_ptr->zstream.avail_out = (sizeof comp->output); + if (compression >= PNG_TEXT_COMPRESSION_LAST) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[50]; + sprintf(msg, "Unknown compression type %d", compression); + png_warning(png_ptr, msg); +#else + png_warning(png_ptr, "Unknown compression type"); +#endif + } - output_len = png_ptr->zstream.avail_out; + /* We can't write the chunk until we find out how much data we have, + * which means we need to run the compressor first and save the + * output. This shouldn't be a problem, as the vast majority of + * comments should be reasonable, but we will set up an array of + * malloc'd pointers to be sure. + * + * If we knew the application was well behaved, we could simplify this + * greatly by assuming we can always malloc an output buffer large + * enough to hold the compressed text ((1001 * text_len / 1000) + 12) + * and malloc this directly. The only time this would be a bad idea is + * if we can't malloc more than 64K and we have 64K of random input + * data, or if the input string is incredibly large (although this + * wouldn't cause a failure, just a slowdown due to swapping). + */ - do + /* set up the compression buffers */ + png_ptr->zstream.avail_in = (uInt)text_len; + png_ptr->zstream.next_in = (Bytef *)text; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; + + /* this is the same compression loop as in png_write_row() */ + do + { + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); + if (ret != Z_OK) { - uInt avail_in = ZLIB_IO_MAX; - - if (avail_in > input_len) - avail_in = (uInt)input_len; - - input_len -= avail_in; - - png_ptr->zstream.avail_in = avail_in; - - if (png_ptr->zstream.avail_out == 0) + /* error */ + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + /* check to see if we need more room */ + if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in) + { + /* make sure the output array has room */ + if (comp->num_output_ptr >= comp->max_output_ptr) { - png_compression_buffer *next; + int old_max; - /* Chunk data is limited to 2^31 bytes in length, so the prefix - * length must be counted here. - */ - if (output_len + prefix_len > PNG_UINT_31_MAX) + old_max = comp->max_output_ptr; + comp->max_output_ptr = comp->num_output_ptr + 4; + if (comp->output_ptr != NULL) { - ret = Z_MEM_ERROR; - break; + png_charpp old_ptr; + + old_ptr = comp->output_ptr; + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charpp))); + png_memcpy(comp->output_ptr, old_ptr, old_max + * png_sizeof (png_charp)); + png_free(png_ptr, old_ptr); } - - /* Need a new (malloc'ed) buffer, but there may be one present - * already. - */ - next = *end; - if (next == NULL) - { - next = png_voidcast(png_compression_bufferp, png_malloc_base - (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); - - if (next == NULL) - { - ret = Z_MEM_ERROR; - break; - } - - /* Link in this buffer (so that it will be freed later) */ - next->next = NULL; - *end = next; - } - - png_ptr->zstream.next_out = next->output; - png_ptr->zstream.avail_out = png_ptr->zbuffer_size; - output_len += png_ptr->zstream.avail_out; - - /* Move 'end' to the next buffer pointer. */ - end = &next->next; + else + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charp))); } - /* Compress the data */ - ret = deflate(&png_ptr->zstream, - input_len > 0 ? Z_NO_FLUSH : Z_FINISH); + /* save the data */ + comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, + png_ptr->zbuf_size); + comp->num_output_ptr++; - /* Claw back input data that was not consumed (because avail_in is - * reset above every time round the loop). - */ - input_len += png_ptr->zstream.avail_in; - png_ptr->zstream.avail_in = 0; /* safety */ + /* and reset the buffer */ + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; } - while (ret == Z_OK); + /* continue until we don't have any more to compress */ + } while (png_ptr->zstream.avail_in); - /* There may be some space left in the last output buffer, this needs to - * be subtracted from output_len. - */ - output_len -= png_ptr->zstream.avail_out; - png_ptr->zstream.avail_out = 0; /* safety */ - comp->output_len = output_len; + /* finish the compression */ + do + { + /* tell zlib we are finished */ + ret = deflate(&png_ptr->zstream, Z_FINISH); - /* Now double check the output length, put in a custom message if it is - * too long. Otherwise ensure the z_stream::msg pointer is set to - * something. - */ - if (output_len + prefix_len >= PNG_UINT_31_MAX) + if (ret == Z_OK) { - png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long"); - ret = Z_MEM_ERROR; + /* check to see if we need more room */ + if (!(png_ptr->zstream.avail_out)) + { + /* check to make sure our output array has room */ + if (comp->num_output_ptr >= comp->max_output_ptr) + { + int old_max; + + old_max = comp->max_output_ptr; + comp->max_output_ptr = comp->num_output_ptr + 4; + if (comp->output_ptr != NULL) + { + png_charpp old_ptr; + + old_ptr = comp->output_ptr; + /* This could be optimized to realloc() */ + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charpp))); + png_memcpy(comp->output_ptr, old_ptr, + old_max * png_sizeof (png_charp)); + png_free(png_ptr, old_ptr); + } + else + comp->output_ptr = (png_charpp)png_malloc(png_ptr, + (png_uint_32)(comp->max_output_ptr * + png_sizeof (png_charp))); + } + + /* save off the data */ + comp->output_ptr[comp->num_output_ptr] = + (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); + png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, + png_ptr->zbuf_size); + comp->num_output_ptr++; + + /* and reset the buffer pointers */ + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; + } } - - else - png_zstream_error(png_ptr, ret); - - /* Reset zlib for another zTXt/iTXt or image data */ - png_ptr->zowner = 0; - - /* The only success case is Z_STREAM_END, input_len must be 0, if not this - * is an internal error. - */ - if (ret == Z_STREAM_END && input_len == 0) + else if (ret != Z_STREAM_END) { - /* Fix up the deflate header, if required */ - optimize_cmf(comp->output, comp->input_len); - - /* But Z_OK is returned, not Z_STREAM_END; this allows the claim - * function above to return Z_STREAM_END on an error (though it never - * does in the current versions of zlib.) - */ - return Z_OK; + /* we got an error */ + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); } + } while (ret != Z_STREAM_END); - else - return ret; - } + /* text length is number of buffers plus last buffer */ + text_len = png_ptr->zbuf_size * comp->num_output_ptr; + if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) + text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; + + return((int)text_len); } -/* Ship the compressed text out via chunk writes */ -static void -png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) +/* ship the compressed text out via chunk writes */ +static void /* PRIVATE */ +png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) { - png_uint_32 output_len = comp->output_len; - png_const_bytep output = comp->output; - png_uint_32 avail = (sizeof comp->output); - png_compression_buffer *next = png_ptr->zbuffer_list; + int i; - for (;;) + /* handle the no-compression case */ + if (comp->input) { - if (avail > output_len) - avail = output_len; - - png_write_chunk_data(png_ptr, output, avail); - - output_len -= avail; - - if (output_len == 0 || next == NULL) - break; - - avail = png_ptr->zbuffer_size; - output = next->output; - next = next->next; + png_write_chunk_data(png_ptr, (png_bytep)comp->input, + (png_size_t)comp->input_len); + return; } - /* This is an internal error; 'next' must have been NULL! */ - if (output_len > 0) - png_error(png_ptr, "error writing ancillary chunked compressed data"); -} -#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */ - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The 'new_key' buffer must be 80 characters in size (for the keyword plus a - * trailing '\0'). If this routine returns 0 then there was no keyword, or a - * valid one could not be generated, and the caller must png_error. - */ -static png_uint_32 -png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) -{ - png_const_charp orig_key = key; - png_uint_32 key_len = 0; - int bad_character = 0; - int space = 1; - - png_debug(1, "in png_check_keyword"); - - if (key == NULL) + /* write saved output buffers, if any */ + for (i = 0; i < comp->num_output_ptr; i++) { - *new_key = 0; - return 0; + png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], + png_ptr->zbuf_size); + png_free(png_ptr, comp->output_ptr[i]); + comp->output_ptr[i]=NULL; } + if (comp->max_output_ptr != 0) + png_free(png_ptr, comp->output_ptr); + comp->output_ptr=NULL; + /* write anything left in zbuf */ + if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) + png_write_chunk_data(png_ptr, png_ptr->zbuf, + png_ptr->zbuf_size - png_ptr->zstream.avail_out); - while (*key && key_len < 79) - { - png_byte ch = (png_byte)(0xff & *key++); + /* reset zlib for another zTXt/iTXt or the image data */ + deflateReset(&png_ptr->zstream); - if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) - *new_key++ = ch, ++key_len, space = 0; - - else if (!space) - { - /* A space or an invalid character when one wasn't seen immediately - * before; output just a space. - */ - *new_key++ = 32, ++key_len, space = 1; - - /* If the character was not a space then it is invalid. */ - if (ch != 32) - bad_character = ch; - } - - else if (!bad_character) - bad_character = ch; /* just skip it, record the first error */ - } - - if (key_len > 0 && space) /* trailing space */ - { - --key_len, --new_key; - if (!bad_character) - bad_character = 32; - } - - /* Terminate the keyword */ - *new_key = 0; - - if (key_len == 0) - return 0; - - /* Try to only output one warning per keyword: */ - if (*key) /* keyword too long */ - png_warning(png_ptr, "keyword truncated"); - - else if (bad_character) - { - PNG_WARNING_PARAMETERS(p) - - png_warning_parameter(p, 1, orig_key); - png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); - - png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); - } - - return key_len; } #endif @@ -751,14 +368,16 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) * information being correct. */ void /* PRIVATE */ -png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) +png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, + int bit_depth, int color_type, int compression_type, int filter_type, + int interlace_type) { - png_byte buf[13]; /* Buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR"); +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; +#endif + png_byte buf[13]; /* buffer to store the IHDR info */ + png_debug(1, "in png_write_IHDR\n"); /* Check that we have valid input data from the application info */ switch (color_type) { @@ -769,61 +388,35 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, case 2: case 4: case 8: -#ifdef PNG_WRITE_16BIT_SUPPORTED - case 16: -#endif - png_ptr->channels = 1; break; - - default: - png_error(png_ptr, - "Invalid bit depth for grayscale image"); + case 16: png_ptr->channels = 1; break; + default: png_error(png_ptr,"Invalid bit depth for grayscale image"); } break; - case PNG_COLOR_TYPE_RGB: -#ifdef PNG_WRITE_16BIT_SUPPORTED if (bit_depth != 8 && bit_depth != 16) -#else - if (bit_depth != 8) -#endif png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; break; - case PNG_COLOR_TYPE_PALETTE: switch (bit_depth) { case 1: case 2: case 4: - case 8: - png_ptr->channels = 1; - break; - - default: - png_error(png_ptr, "Invalid bit depth for paletted image"); + case 8: png_ptr->channels = 1; break; + default: png_error(png_ptr, "Invalid bit depth for paletted image"); } break; - case PNG_COLOR_TYPE_GRAY_ALPHA: if (bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; break; - case PNG_COLOR_TYPE_RGB_ALPHA: -#ifdef PNG_WRITE_16BIT_SUPPORTED if (bit_depth != 8 && bit_depth != 16) -#else - if (bit_depth != 8) -#endif png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; break; - default: png_error(png_ptr, "Invalid image color type specified"); } @@ -844,14 +437,14 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, * 5. The color_type is RGB or RGBA */ if ( -#ifdef PNG_MNG_FEATURES_SUPPORTED - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && +#if defined(PNG_MNG_FEATURES_SUPPORTED) + !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && #endif - filter_type != PNG_FILTER_TYPE_BASE) + filter_type != PNG_FILTER_TYPE_BASE) { png_warning(png_ptr, "Invalid filter type specified"); filter_type = PNG_FILTER_TYPE_BASE; @@ -859,7 +452,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, #ifdef PNG_WRITE_INTERLACING_SUPPORTED if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) + interlace_type != PNG_INTERLACE_ADAM7) { png_warning(png_ptr, "Invalid interlace type specified"); interlace_type = PNG_INTERLACE_ADAM7; @@ -868,11 +461,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, interlace_type=PNG_INTERLACE_NONE; #endif - /* Save the relevent information */ + /* save off the relevent information */ png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; -#ifdef PNG_MNG_FEATURES_SUPPORTED +#if defined(PNG_MNG_FEATURES_SUPPORTED) png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; @@ -881,12 +474,12 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* Set the usr info, so any transformations can modify it */ + /* set the usr info, so any transformations can modify it */ png_ptr->usr_width = png_ptr->width; png_ptr->usr_bit_depth = png_ptr->bit_depth; png_ptr->usr_channels = png_ptr->channels; - /* Pack the header information into the buffer */ + /* pack the header information into the buffer */ png_save_uint_32(buf, width); png_save_uint_32(buf + 4, height); buf[8] = (png_byte)bit_depth; @@ -895,68 +488,89 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; - /* Write the chunk */ - png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); + /* write the chunk */ + png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); + /* initialize zlib with PNG info */ + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; if (!(png_ptr->do_filter)) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) + png_ptr->bit_depth < 8) png_ptr->do_filter = PNG_FILTER_NONE; - else png_ptr->do_filter = PNG_ALL_FILTERS; } + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) + { + if (png_ptr->do_filter != PNG_FILTER_NONE) + png_ptr->zlib_strategy = Z_FILTERED; + else + png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; + } + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) + png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) + png_ptr->zlib_mem_level = 8; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) + png_ptr->zlib_window_bits = 15; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) + png_ptr->zlib_method = 8; + deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, + png_ptr->zlib_method, png_ptr->zlib_window_bits, + png_ptr->zlib_mem_level, png_ptr->zlib_strategy); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */ + png_ptr->mode = PNG_HAVE_IHDR; } -/* Write the palette. We are careful not to trust png_color to be in the +/* write the palette. We are careful not to trust png_color to be in the * correct order for PNG, so people can redefine it to any convenient * structure. */ void /* PRIVATE */ -png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, - png_uint_32 num_pal) +png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_PLTE; +#endif png_uint_32 i; - png_const_colorp pal_ptr; + png_colorp pal_ptr; png_byte buf[3]; - png_debug(1, "in png_write_PLTE"); - + png_debug(1, "in png_write_PLTE\n"); if (( -#ifdef PNG_MNG_FEATURES_SUPPORTED - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && +#if defined(PNG_MNG_FEATURES_SUPPORTED) + !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && #endif - num_pal == 0) || num_pal > 256) + num_pal == 0) || num_pal > 256) { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, "Invalid number of colors in palette"); + } + else + { + png_warning(png_ptr, "Invalid number of colors in palette"); + return; + } } if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) { png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - + "Ignoring request to write a PLTE chunk in grayscale PNG"); return; } png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d", png_ptr->num_palette); - - png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); -#ifdef PNG_POINTER_INDEXING_SUPPORTED + png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); + png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); +#ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) { buf[0] = pal_ptr->red; @@ -964,13 +578,9 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, buf[2] = pal_ptr->blue; png_write_chunk_data(png_ptr, buf, (png_size_t)3); } - #else - /* This is a little slower but some buggy compilers need to do this - * instead - */ + /* This is a little slower but some buggy compilers need to do this instead */ pal_ptr=palette; - for (i = 0; i < num_pal; i++) { buf[0] = pal_ptr[i].red; @@ -978,374 +588,278 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, buf[2] = pal_ptr[i].blue; png_write_chunk_data(png_ptr, buf, (png_size_t)3); } - #endif png_write_chunk_end(png_ptr); png_ptr->mode |= PNG_HAVE_PLTE; } -/* This is similar to png_text_compress, above, except that it does not require - * all of the data at once and, instead of buffering the compressed result, - * writes it as IDAT chunks. Unlike png_text_compress it *can* png_error out - * because it calls the write interface. As a result it does its own error - * reporting and does not return an error code. In the event of error it will - * just call png_error. The input data length may exceed 32-bits. The 'flush' - * parameter is exactly the same as that to deflate, with the following - * meanings: - * - * Z_NO_FLUSH: normal incremental output of compressed data - * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush - * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up - * - * The routine manages the acquire and release of the png_ptr->zstream by - * checking and (at the end) clearing png_ptr->zowner, it does some sanity - * checks on the 'mode' flags while doing this. - */ +/* write an IDAT chunk */ void /* PRIVATE */ -png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, - png_alloc_size_t input_len, int flush) +png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) { - if (png_ptr->zowner != png_IDAT) +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + png_debug(1, "in png_write_IDAT\n"); + + /* Optimize the CMF field in the zlib stream. */ + /* This hack of the zlib stream is compliant to the stream specification. */ + if (!(png_ptr->mode & PNG_HAVE_IDAT) && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) { - /* First time. Ensure we have a temporary buffer for compression and - * trim the buffer list if it has more than one entry to free memory. - * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been - * created at this point, but the check here is quick and safe. - */ - if (png_ptr->zbuffer_list == NULL) + unsigned int z_cmf = data[0]; /* zlib compression method and flags */ + if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) { - png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, - png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); - png_ptr->zbuffer_list->next = NULL; - } - - else - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next); - - /* It is a terminal error if we can't claim the zstream. */ - if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - /* The output state is maintained in png_ptr->zstream, so it must be - * initialized here after the claim. - */ - png_ptr->zstream.next_out = png_ptr->zbuffer_list->output; - png_ptr->zstream.avail_out = png_ptr->zbuffer_size; - } - - /* Now loop reading and writing until all the input is consumed or an error - * terminates the operation. The _out values are maintained across calls to - * this function, but the input must be reset each time. - */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); - png_ptr->zstream.avail_in = 0; /* set below */ - for (;;) - { - int ret; - - /* INPUT: from the row data */ - uInt avail = ZLIB_IO_MAX; - - if (avail > input_len) - avail = (uInt)input_len; /* safe because of the check */ - - png_ptr->zstream.avail_in = avail; - input_len -= avail; - - ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush); - - /* Include as-yet unconsumed input */ - input_len += png_ptr->zstream.avail_in; - png_ptr->zstream.avail_in = 0; - - /* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note - * that these two zstream fields are preserved across the calls, therefore - * there is no need to set these up on entry to the loop. - */ - if (png_ptr->zstream.avail_out == 0) - { - png_bytep data = png_ptr->zbuffer_list->output; - uInt size = png_ptr->zbuffer_size; - - /* Write an IDAT containing the data then reset the buffer. The - * first IDAT may need deflate header optimization. - */ -# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - optimize_cmf(data, png_image_size(png_ptr)); -# endif - - png_write_complete_chunk(png_ptr, png_IDAT, data, size); - png_ptr->mode |= PNG_HAVE_IDAT; - - png_ptr->zstream.next_out = data; - png_ptr->zstream.avail_out = size; - - /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with - * the same flush parameter until it has finished output, for NO_FLUSH - * it doesn't matter. - */ - if (ret == Z_OK && flush != Z_NO_FLUSH) - continue; - } - - /* The order of these checks doesn't matter much; it just effect which - * possible error might be detected if multiple things go wrong at once. - */ - if (ret == Z_OK) /* most likely return code! */ - { - /* If all the input has been consumed then just return. If Z_FINISH - * was used as the flush parameter something has gone wrong if we get - * here. - */ - if (input_len == 0) + /* Avoid memory underflows and multiplication overflows. */ + /* The conditions below are practically always satisfied; + however, they still must be checked. */ + if (length >= 2 && + png_ptr->height < 16384 && png_ptr->width < 16384) { - if (flush == Z_FINISH) - png_error(png_ptr, "Z_OK on Z_FINISH with output space"); - - return; + png_uint_32 uncompressed_idat_size = png_ptr->height * + ((png_ptr->width * + png_ptr->channels * png_ptr->bit_depth + 15) >> 3); + unsigned int z_cinfo = z_cmf >> 4; + unsigned int half_z_window_size = 1 << (z_cinfo + 7); + while (uncompressed_idat_size <= half_z_window_size && + half_z_window_size >= 256) + { + z_cinfo--; + half_z_window_size >>= 1; + } + z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); + if (data[0] != (png_byte)z_cmf) + { + data[0] = (png_byte)z_cmf; + data[1] &= 0xe0; + data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); + } } } - - else if (ret == Z_STREAM_END && flush == Z_FINISH) - { - /* This is the end of the IDAT data; any pending output must be - * flushed. For small PNG files we may still be at the beginning. - */ - png_bytep data = png_ptr->zbuffer_list->output; - uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out; - -# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - optimize_cmf(data, png_image_size(png_ptr)); -# endif - - png_write_complete_chunk(png_ptr, png_IDAT, data, size); - png_ptr->zstream.avail_out = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; - - png_ptr->zowner = 0; /* Release the stream */ - return; - } - else - { - /* This is an error condition. */ - png_zstream_error(png_ptr, ret); - png_error(png_ptr, png_ptr->zstream.msg); - } + png_error(png_ptr, + "Invalid zlib compression method or flags in IDAT"); } + + png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); + png_ptr->mode |= PNG_HAVE_IDAT; } -/* Write an IEND chunk */ +/* write an IEND chunk */ void /* PRIVATE */ -png_write_IEND(png_structrp png_ptr) +png_write_IEND(png_structp png_ptr) { - png_debug(1, "in png_write_IEND"); - - png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0); +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IEND; +#endif + png_debug(1, "in png_write_IEND\n"); + png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, + (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } -#ifdef PNG_WRITE_gAMA_SUPPORTED -/* Write a gAMA chunk */ +#if defined(PNG_WRITE_gAMA_SUPPORTED) +/* write a gAMA chunk */ +#ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ -png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma) +png_write_gAMA(png_structp png_ptr, double file_gamma) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_gAMA; +#endif + png_uint_32 igamma; png_byte buf[4]; - png_debug(1, "in png_write_gAMA"); + png_debug(1, "in png_write_gAMA\n"); + /* file_gamma is saved in 1/100,000ths */ + igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); + png_save_uint_32(buf, igamma); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_gAMA; +#endif + png_byte buf[4]; + png_debug(1, "in png_write_gAMA\n"); /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } #endif +#endif -#ifdef PNG_WRITE_sRGB_SUPPORTED -/* Write a sRGB chunk */ +#if defined(PNG_WRITE_sRGB_SUPPORTED) +/* write a sRGB chunk */ void /* PRIVATE */ -png_write_sRGB(png_structrp png_ptr, int srgb_intent) +png_write_sRGB(png_structp png_ptr, int srgb_intent) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sRGB; +#endif png_byte buf[1]; - png_debug(1, "in png_write_sRGB"); - - if (srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - + png_debug(1, "in png_write_sRGB\n"); + if(srgb_intent >= PNG_sRGB_INTENT_LAST) + png_warning(png_ptr, + "Invalid sRGB rendering intent specified"); buf[0]=(png_byte)srgb_intent; - png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); } #endif -#ifdef PNG_WRITE_iCCP_SUPPORTED -/* Write an iCCP chunk */ +#if defined(PNG_WRITE_iCCP_SUPPORTED) +/* write an iCCP chunk */ void /* PRIVATE */ -png_write_iCCP(png_structrp png_ptr, png_const_charp name, - png_const_bytep profile) +png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, + png_charp profile, int profile_len) { - png_uint_32 name_len; - png_uint_32 profile_len; - png_byte new_name[81]; /* 1 byte for the compression byte */ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_iCCP; +#endif + png_size_t name_len; + png_charp new_name; compression_state comp; - png_debug(1, "in png_write_iCCP"); - - /* These are all internal problems: the profile should have been checked - * before when it was stored. - */ - if (profile == NULL) - png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */ - - profile_len = png_get_uint_32(profile); - - if (profile_len < 132) - png_error(png_ptr, "ICC profile too short"); - - if (profile_len & 0x03) - png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)"); - + png_debug(1, "in png_write_iCCP\n"); + if (name == NULL || (name_len = png_check_keyword(png_ptr, name, + &new_name)) == 0) { - png_uint_32 embedded_profile_len = png_get_uint_32(profile); - - if (profile_len != embedded_profile_len) - png_error(png_ptr, "Profile length does not match profile"); + png_warning(png_ptr, "Empty keyword in iCCP chunk"); + return; } - name_len = png_check_keyword(png_ptr, name, new_name); + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - if (name_len == 0) - png_error(png_ptr, "iCCP: invalid keyword"); + if (profile == NULL) + profile_len = 0; - new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE; + if (profile_len) + profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, + PNG_COMPRESSION_TYPE_BASE, &comp); - /* Make sure we include the NULL after the name and the compression type */ - ++name_len; + /* make sure we include the NULL after the name and the compression type */ + png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, + (png_uint_32)name_len+profile_len+2); + new_name[name_len+1]=0x00; + png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - png_text_compress_init(&comp, profile, profile_len); - - /* Allow for keyword terminator and compression byte */ - if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len); - - png_write_chunk_data(png_ptr, new_name, name_len); - - png_write_compressed_data_out(png_ptr, &comp); + if (profile_len) + png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); + png_free(png_ptr, new_name); } #endif -#ifdef PNG_WRITE_sPLT_SUPPORTED -/* Write a sPLT chunk */ +#if defined(PNG_WRITE_sPLT_SUPPORTED) +/* write a sPLT chunk */ void /* PRIVATE */ -png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) +png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) { - png_uint_32 name_len; - png_byte new_name[80]; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sPLT; +#endif + png_size_t name_len; + png_charp new_name; png_byte entrybuf[10]; - png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); - png_size_t palette_size = entry_size * spalette->nentries; + int entry_size = (spalette->depth == 8 ? 6 : 10); + int palette_size = entry_size * spalette->nentries; png_sPLT_entryp ep; -#ifndef PNG_POINTER_INDEXING_SUPPORTED +#ifdef PNG_NO_POINTER_INDEXING int i; #endif - png_debug(1, "in png_write_sPLT"); - - name_len = png_check_keyword(png_ptr, spalette->name, new_name); - - if (name_len == 0) - png_error(png_ptr, "sPLT: invalid keyword"); - - /* Make sure we include the NULL after the name */ - png_write_chunk_header(png_ptr, png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - - png_write_chunk_data(png_ptr, (png_bytep)new_name, - (png_size_t)(name_len + 1)); - - png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1); - - /* Loop through each palette entry, writing appropriately */ -#ifdef PNG_POINTER_INDEXING_SUPPORTED - for (ep = spalette->entries; epentries + spalette->nentries; ep++) + png_debug(1, "in png_write_sPLT\n"); + if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, + spalette->name, &new_name))==0) { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } + png_warning(png_ptr, "Empty keyword in sPLT chunk"); + return; + } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } + /* make sure we include the NULL after the name */ + png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, + (png_uint_32)(name_len + 2 + palette_size)); + png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - png_write_chunk_data(png_ptr, entrybuf, entry_size); + /* loop through each palette entry, writing appropriately */ +#ifndef PNG_NO_POINTER_INDEXING + for (ep = spalette->entries; epentries+spalette->nentries; ep++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep->red; + entrybuf[1] = (png_byte)ep->green; + entrybuf[2] = (png_byte)ep->blue; + entrybuf[3] = (png_byte)ep->alpha; + png_save_uint_16(entrybuf + 4, ep->frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep->red); + png_save_uint_16(entrybuf + 2, ep->green); + png_save_uint_16(entrybuf + 4, ep->blue); + png_save_uint_16(entrybuf + 6, ep->alpha); + png_save_uint_16(entrybuf + 8, ep->frequency); + } + png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); } #else ep=spalette->entries; - for (i = 0; i>spalette->nentries; i++) + for (i=0; i>spalette->nentries; i++) { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - - png_write_chunk_data(png_ptr, entrybuf, entry_size); + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep[i].red; + entrybuf[1] = (png_byte)ep[i].green; + entrybuf[2] = (png_byte)ep[i].blue; + entrybuf[3] = (png_byte)ep[i].alpha; + png_save_uint_16(entrybuf + 4, ep[i].frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep[i].red); + png_save_uint_16(entrybuf + 2, ep[i].green); + png_save_uint_16(entrybuf + 4, ep[i].blue); + png_save_uint_16(entrybuf + 6, ep[i].alpha); + png_save_uint_16(entrybuf + 8, ep[i].frequency); + } + png_write_chunk_data(png_ptr, entrybuf, entry_size); } #endif png_write_chunk_end(png_ptr); + png_free(png_ptr, new_name); } #endif -#ifdef PNG_WRITE_sBIT_SUPPORTED -/* Write the sBIT chunk */ +#if defined(PNG_WRITE_sBIT_SUPPORTED) +/* write the sBIT chunk */ void /* PRIVATE */ -png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) +png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sBIT; +#endif png_byte buf[4]; png_size_t size; - png_debug(1, "in png_write_sBIT"); - - /* Make sure we don't depend upon the order of PNG_COLOR_8 */ + png_debug(1, "in png_write_sBIT\n"); + /* make sure we don't depend upon the order of PNG_COLOR_8 */ if (color_type & PNG_COLOR_MASK_COLOR) { png_byte maxbits; maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - + png_ptr->usr_bit_depth); if (sbit->red == 0 || sbit->red > maxbits || sbit->green == 0 || sbit->green > maxbits || sbit->blue == 0 || sbit->blue > maxbits) @@ -1353,13 +867,11 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } - buf[0] = sbit->red; buf[1] = sbit->green; buf[2] = sbit->blue; size = 3; } - else { if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) @@ -1367,7 +879,6 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } - buf[0] = sbit->gray; size = 1; } @@ -1379,404 +890,590 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } - buf[size++] = sbit->alpha; } - png_write_complete_chunk(png_ptr, png_sBIT, buf, size); + png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); } #endif -#ifdef PNG_WRITE_cHRM_SUPPORTED -/* Write the cHRM chunk */ +#if defined(PNG_WRITE_cHRM_SUPPORTED) +/* write the cHRM chunk */ +#ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ -png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy) +png_write_cHRM(png_structp png_ptr, double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_cHRM; +#endif + png_byte buf[32]; + png_uint_32 itemp; + + png_debug(1, "in png_write_cHRM\n"); + /* each value is saved in 1/100,000ths */ + if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || + white_x + white_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM white point specified"); +#if !defined(PNG_NO_CONSOLE_IO) + fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); +#endif + return; + } + itemp = (png_uint_32)(white_x * 100000.0 + 0.5); + png_save_uint_32(buf, itemp); + itemp = (png_uint_32)(white_y * 100000.0 + 0.5); + png_save_uint_32(buf + 4, itemp); + + if (red_x < 0 || red_x > 0.8 || red_y < 0 || red_y > 0.8 || + red_x + red_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM red point specified"); + return; + } + itemp = (png_uint_32)(red_x * 100000.0 + 0.5); + png_save_uint_32(buf + 8, itemp); + itemp = (png_uint_32)(red_y * 100000.0 + 0.5); + png_save_uint_32(buf + 12, itemp); + + if (green_x < 0 || green_x > 0.8 || green_y < 0 || green_y > 0.8 || + green_x + green_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM green point specified"); + return; + } + itemp = (png_uint_32)(green_x * 100000.0 + 0.5); + png_save_uint_32(buf + 16, itemp); + itemp = (png_uint_32)(green_y * 100000.0 + 0.5); + png_save_uint_32(buf + 20, itemp); + + if (blue_x < 0 || blue_x > 0.8 || blue_y < 0 || blue_y > 0.8 || + blue_x + blue_y > 1.0) + { + png_warning(png_ptr, "Invalid cHRM blue point specified"); + return; + } + itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); + png_save_uint_32(buf + 24, itemp); + itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); + png_save_uint_32(buf + 28, itemp); + + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, + png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, + png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, + png_fixed_point blue_y) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_cHRM; +#endif png_byte buf[32]; - png_debug(1, "in png_write_cHRM"); + png_debug(1, "in png_write_cHRM\n"); + /* each value is saved in 1/100,000ths */ + if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM white point specified"); +#if !defined(PNG_NO_CONSOLE_IO) + fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); +#endif + return; + } + png_save_uint_32(buf, (png_uint_32)white_x); + png_save_uint_32(buf + 4, (png_uint_32)white_y); - /* Each value is saved in 1/100,000ths */ - png_save_int_32(buf, xy->whitex); - png_save_int_32(buf + 4, xy->whitey); + if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM fixed red point specified"); + return; + } + png_save_uint_32(buf + 8, (png_uint_32)red_x); + png_save_uint_32(buf + 12, (png_uint_32)red_y); - png_save_int_32(buf + 8, xy->redx); - png_save_int_32(buf + 12, xy->redy); + if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM green point specified"); + return; + } + png_save_uint_32(buf + 16, (png_uint_32)green_x); + png_save_uint_32(buf + 20, (png_uint_32)green_y); - png_save_int_32(buf + 16, xy->greenx); - png_save_int_32(buf + 20, xy->greeny); + if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L) + { + png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); + return; + } + png_save_uint_32(buf + 24, (png_uint_32)blue_x); + png_save_uint_32(buf + 28, (png_uint_32)blue_y); - png_save_int_32(buf + 24, xy->bluex); - png_save_int_32(buf + 28, xy->bluey); - - png_write_complete_chunk(png_ptr, png_cHRM, buf, 32); + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); } #endif +#endif -#ifdef PNG_WRITE_tRNS_SUPPORTED -/* Write the tRNS chunk */ +#if defined(PNG_WRITE_tRNS_SUPPORTED) +/* write the tRNS chunk */ void /* PRIVATE */ -png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, - png_const_color_16p tran, int num_trans, int color_type) +png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, + int num_trans, int color_type) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tRNS; +#endif png_byte buf[6]; - png_debug(1, "in png_write_tRNS"); - + png_debug(1, "in png_write_tRNS\n"); if (color_type == PNG_COLOR_TYPE_PALETTE) { if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) { - png_app_warning(png_ptr, - "Invalid number of transparent colors specified"); + png_warning(png_ptr,"Invalid number of transparent colors specified"); return; } - - /* Write the chunk out as it is */ - png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, - (png_size_t)num_trans); + /* write the chunk out as it is */ + png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); } - else if (color_type == PNG_COLOR_TYPE_GRAY) { - /* One 16 bit value */ - if (tran->gray >= (1 << png_ptr->bit_depth)) + /* one 16 bit value */ + if(tran->gray >= (1 << png_ptr->bit_depth)) { - png_app_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - + png_warning(png_ptr, + "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); return; } - png_save_uint_16(buf, tran->gray); - png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); } - else if (color_type == PNG_COLOR_TYPE_RGB) { - /* Three 16 bit values */ + /* three 16 bit values */ png_save_uint_16(buf, tran->red); png_save_uint_16(buf + 2, tran->green); png_save_uint_16(buf + 4, tran->blue); -#ifdef PNG_WRITE_16BIT_SUPPORTED - if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) -#else - if (buf[0] | buf[2] | buf[4]) -#endif - { - png_app_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - - png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); + if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); } - else { - png_app_warning(png_ptr, "Can't write tRNS with an alpha channel"); + png_warning(png_ptr, "Can't write tRNS with an alpha channel"); } } #endif -#ifdef PNG_WRITE_bKGD_SUPPORTED -/* Write the background chunk */ +#if defined(PNG_WRITE_bKGD_SUPPORTED) +/* write the background chunk */ void /* PRIVATE */ -png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) +png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_bKGD; +#endif png_byte buf[6]; - png_debug(1, "in png_write_bKGD"); - + png_debug(1, "in png_write_bKGD\n"); if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( -#ifdef PNG_MNG_FEATURES_SUPPORTED +#if defined(PNG_MNG_FEATURES_SUPPORTED) (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif - back->index >= png_ptr->num_palette) + back->index > png_ptr->num_palette) { png_warning(png_ptr, "Invalid background palette index"); return; } - buf[0] = back->index; - png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); } - else if (color_type & PNG_COLOR_MASK_COLOR) { png_save_uint_16(buf, back->red); png_save_uint_16(buf + 2, back->green); png_save_uint_16(buf + 4, back->blue); -#ifdef PNG_WRITE_16BIT_SUPPORTED - if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) -#else - if (buf[0] | buf[2] | buf[4]) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - - return; - } - - png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); + if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); } - else { - if (back->gray >= (1 << png_ptr->bit_depth)) + if(back->gray >= (1 << png_ptr->bit_depth)) { png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - + "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); return; } - png_save_uint_16(buf, back->gray); - png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); } } #endif -#ifdef PNG_WRITE_hIST_SUPPORTED -/* Write the histogram */ +#if defined(PNG_WRITE_hIST_SUPPORTED) +/* write the histogram */ void /* PRIVATE */ -png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist) +png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_hIST; +#endif int i; png_byte buf[3]; - png_debug(1, "in png_write_hIST"); - + png_debug(1, "in png_write_hIST\n"); if (num_hist > (int)png_ptr->num_palette) { - png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, - png_ptr->num_palette); - + png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, + png_ptr->num_palette); png_warning(png_ptr, "Invalid number of histogram entries specified"); return; } - png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); - + png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); for (i = 0; i < num_hist; i++) { png_save_uint_16(buf, hist[i]); png_write_chunk_data(png_ptr, buf, (png_size_t)2); } - png_write_chunk_end(png_ptr); } #endif -#ifdef PNG_WRITE_tEXt_SUPPORTED -/* Write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, - png_size_t text_len) +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, + * and if invalid, correct the keyword rather than discarding the entire + * chunk. The PNG 1.0 specification requires keywords 1-79 characters in + * length, forbids leading or trailing whitespace, multiple internal spaces, + * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. + * + * The new_key is allocated to hold the corrected keyword and must be freed + * by the calling routine. This avoids problems with trying to write to + * static keywords without having to have duplicate copies of the strings. + */ +png_size_t /* PRIVATE */ +png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) { - png_uint_32 key_len; - png_byte new_key[80]; + png_size_t key_len; + png_charp kp, dp; + int kflag; + int kwarn=0; - png_debug(1, "in png_write_tEXt"); + png_debug(1, "in png_check_keyword\n"); + *new_key = NULL; - key_len = png_check_keyword(png_ptr, key, new_key); + if (key == NULL || (key_len = png_strlen(key)) == 0) + { + png_warning(png_ptr, "zero length keyword"); + return ((png_size_t)0); + } + + png_debug1(2, "Keyword to be checked is '%s'\n", key); + + *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); + if (*new_key == NULL) + { + png_warning(png_ptr, "Out of memory while procesing keyword"); + return ((png_size_t)0); + } + + /* Replace non-printing characters with a blank and print a warning */ + for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) + { + if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[40]; + + sprintf(msg, "invalid keyword character 0x%02X", *kp); + png_warning(png_ptr, msg); +#else + png_warning(png_ptr, "invalid character in keyword"); +#endif + *dp = ' '; + } + else + { + *dp = *kp; + } + } + *dp = '\0'; + + /* Remove any trailing white space. */ + kp = *new_key + key_len - 1; + if (*kp == ' ') + { + png_warning(png_ptr, "trailing spaces removed from keyword"); + + while (*kp == ' ') + { + *(kp--) = '\0'; + key_len--; + } + } + + /* Remove any leading white space. */ + kp = *new_key; + if (*kp == ' ') + { + png_warning(png_ptr, "leading spaces removed from keyword"); + + while (*kp == ' ') + { + kp++; + key_len--; + } + } + + png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); + + /* Remove multiple internal spaces. */ + for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) + { + if (*kp == ' ' && kflag == 0) + { + *(dp++) = *kp; + kflag = 1; + } + else if (*kp == ' ') + { + key_len--; + kwarn=1; + } + else + { + *(dp++) = *kp; + kflag = 0; + } + } + *dp = '\0'; + if(kwarn) + png_warning(png_ptr, "extra interior spaces removed from keyword"); if (key_len == 0) - png_error(png_ptr, "tEXt: invalid keyword"); + { + png_free(png_ptr, *new_key); + *new_key=NULL; + png_warning(png_ptr, "Zero length keyword"); + } + + if (key_len > 79) + { + png_warning(png_ptr, "keyword length must be 1 - 79 characters"); + new_key[79] = '\0'; + key_len = 79; + } + + return (key_len); +} +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +/* write a tEXt chunk */ +void /* PRIVATE */ +png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, + png_size_t text_len) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tEXt; +#endif + png_size_t key_len; + png_charp new_key; + + png_debug(1, "in png_write_tEXt\n"); + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + { + png_warning(png_ptr, "Empty keyword in tEXt chunk"); + return; + } if (text == NULL || *text == '\0') text_len = 0; - else - text_len = strlen(text); + text_len = png_strlen(text); - if (text_len > PNG_UINT_31_MAX - (key_len+1)) - png_error(png_ptr, "tEXt: text too long"); - - /* Make sure we include the 0 after the key */ - png_write_chunk_header(png_ptr, png_tEXt, - (png_uint_32)/*checked above*/(key_len + text_len + 1)); + /* make sure we include the 0 after the key */ + png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); /* * We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, new_key, key_len + 1); - + png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); if (text_len) - png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len); + png_write_chunk_data(png_ptr, (png_bytep)text, text_len); png_write_chunk_end(png_ptr); + png_free(png_ptr, new_key); } #endif -#ifdef PNG_WRITE_zTXt_SUPPORTED -/* Write a compressed text chunk */ +#if defined(PNG_WRITE_zTXt_SUPPORTED) +/* write a compressed text chunk */ void /* PRIVATE */ -png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, - png_size_t text_len, int compression) +png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, + png_size_t text_len, int compression) { - png_uint_32 key_len; - png_byte new_key[81]; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_zTXt; +#endif + png_size_t key_len; + char buf[1]; + png_charp new_key; compression_state comp; - png_debug(1, "in png_write_zTXt"); - PNG_UNUSED(text_len) /* Always use strlen */ + png_debug(1, "in png_write_zTXt\n"); - if (compression == PNG_TEXT_COMPRESSION_NONE) + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) { - png_write_tEXt(png_ptr, key, text, 0); + png_warning(png_ptr, "Empty keyword in zTXt chunk"); return; } - if (compression != PNG_TEXT_COMPRESSION_zTXt) - png_error(png_ptr, "zTXt: invalid compression type"); + if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) + { + png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); + png_free(png_ptr, new_key); + return; + } - key_len = png_check_keyword(png_ptr, key, new_key); + text_len = png_strlen(text); - if (key_len == 0) - png_error(png_ptr, "zTXt: invalid keyword"); + png_free(png_ptr, new_key); - /* Add the compression method and 1 for the keyword separator. */ - new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; - ++key_len; + /* compute the compressed data; do it now for the length */ + text_len = png_text_compress(png_ptr, text, text_len, compression, + &comp); - /* Compute the compressed data; do it now for the length */ - png_text_compress_init(&comp, (png_const_bytep)text, - text == NULL ? 0 : strlen(text)); - - if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - /* Write start of chunk */ - png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len); - - /* Write key */ - png_write_chunk_data(png_ptr, new_key, key_len); - - /* Write the compressed data */ + /* write start of chunk */ + png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) + (key_len+text_len+2)); + /* write key */ + png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); + buf[0] = (png_byte)compression; + /* write compression */ + png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); + /* write the compressed data */ png_write_compressed_data_out(png_ptr, &comp); - /* Close the chunk */ + /* close the chunk */ png_write_chunk_end(png_ptr); } #endif -#ifdef PNG_WRITE_iTXt_SUPPORTED -/* Write an iTXt chunk */ +#if defined(PNG_WRITE_iTXt_SUPPORTED) +/* write an iTXt chunk */ void /* PRIVATE */ -png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, - png_const_charp lang, png_const_charp lang_key, png_const_charp text) +png_write_iTXt(png_structp png_ptr, int compression, png_charp key, + png_charp lang, png_charp lang_key, png_charp text) { - png_uint_32 key_len, prefix_len; - png_size_t lang_len, lang_key_len; - png_byte new_key[82]; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_iTXt; +#endif + png_size_t lang_len, key_len, lang_key_len, text_len; + png_charp new_lang, new_key; + png_byte cbuf[2]; compression_state comp; - png_debug(1, "in png_write_iTXt"); + png_debug(1, "in png_write_iTXt\n"); - key_len = png_check_keyword(png_ptr, key, new_key); - - if (key_len == 0) - png_error(png_ptr, "iTXt: invalid keyword"); - - /* Set the compression flag */ - switch (compression) + if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) { - case PNG_ITXT_COMPRESSION_NONE: - case PNG_TEXT_COMPRESSION_NONE: - compression = new_key[++key_len] = 0; /* no compression */ - break; - - case PNG_TEXT_COMPRESSION_zTXt: - case PNG_ITXT_COMPRESSION_zTXt: - compression = new_key[++key_len] = 1; /* compressed */ - break; - - default: - png_error(png_ptr, "iTXt: invalid compression"); + png_warning(png_ptr, "Empty keyword in iTXt chunk"); + return; + } + if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) + { + png_warning(png_ptr, "Empty language field in iTXt chunk"); + new_lang = NULL; + lang_len = 0; } - new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; - ++key_len; /* for the keywod separator */ + if (lang_key == NULL) + lang_key_len = 0; + else + lang_key_len = png_strlen(lang_key); - /* We leave it to the application to meet PNG-1.0 requirements on the + if (text == NULL) + text_len = 0; + else + text_len = png_strlen(text); + + /* compute the compressed data; do it now for the length */ + text_len = png_text_compress(png_ptr, text, text_len, compression-2, + &comp); + + + /* make sure we include the compression flag, the compression byte, + * and the NULs after the key, lang, and lang_key parts */ + + png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, + (png_uint_32)( + 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ + + key_len + + lang_len + + lang_key_len + + text_len)); + + /* + * We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG, however, - * specifies that the text is UTF-8 and this really doesn't require any - * checking. - * + * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - * - * TODO: validate the language tag correctly (see the spec.) */ - if (lang == NULL) lang = ""; /* empty language is valid */ - lang_len = strlen(lang)+1; - if (lang_key == NULL) lang_key = ""; /* may be empty */ - lang_key_len = strlen(lang_key)+1; - if (text == NULL) text = ""; /* may be empty */ + png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - prefix_len = key_len; - if (lang_len > PNG_UINT_31_MAX-prefix_len) - prefix_len = PNG_UINT_31_MAX; - else - prefix_len = (png_uint_32)(prefix_len + lang_len); + /* set the compression flag */ + if (compression == PNG_ITXT_COMPRESSION_NONE || \ + compression == PNG_TEXT_COMPRESSION_NONE) + cbuf[0] = 0; + else /* compression == PNG_ITXT_COMPRESSION_zTXt */ + cbuf[0] = 1; + /* set the compression method */ + cbuf[1] = 0; + png_write_chunk_data(png_ptr, cbuf, 2); - if (lang_key_len > PNG_UINT_31_MAX-prefix_len) - prefix_len = PNG_UINT_31_MAX; - else - prefix_len = (png_uint_32)(prefix_len + lang_key_len); - - png_text_compress_init(&comp, (png_const_bytep)text, strlen(text)); - - if (compression) - { - if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - } - - else - { - if (comp.input_len > PNG_UINT_31_MAX-prefix_len) - png_error(png_ptr, "iTXt: uncompressed text too long"); - - /* So the string will fit in a chunk: */ - comp.output_len = (png_uint_32)/*SAFE*/comp.input_len; - } - - png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len); - - png_write_chunk_data(png_ptr, new_key, key_len); - - png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len); - - png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len); - - if (compression) - png_write_compressed_data_out(png_ptr, &comp); - - else - png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len); + cbuf[0] = 0; + png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); + png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); + png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); + png_free(png_ptr, new_key); + if (new_lang) + png_free(png_ptr, new_lang); } #endif -#ifdef PNG_WRITE_oFFs_SUPPORTED -/* Write the oFFs chunk */ +#if defined(PNG_WRITE_oFFs_SUPPORTED) +/* write the oFFs chunk */ void /* PRIVATE */ -png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) +png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, + int unit_type) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_oFFs; +#endif png_byte buf[9]; - png_debug(1, "in png_write_oFFs"); - + png_debug(1, "in png_write_oFFs\n"); if (unit_type >= PNG_OFFSET_LAST) png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); @@ -1784,67 +1481,63 @@ png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, png_save_int_32(buf + 4, y_offset); buf[8] = (png_byte)unit_type; - png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); } #endif -#ifdef PNG_WRITE_pCAL_SUPPORTED -/* Write the pCAL chunk (described in the PNG extensions document) */ + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +/* write the pCAL chunk (described in the PNG extensions document) */ void /* PRIVATE */ -png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_const_charp units, - png_charpp params) +png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, + png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) { - png_uint_32 purpose_len; - png_size_t units_len, total_len; - png_size_tp params_len; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_pCAL; +#endif + png_size_t purpose_len, units_len, total_len; + png_uint_32p params_len; png_byte buf[10]; - png_byte new_purpose[80]; + png_charp new_purpose; int i; - png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); - + png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); if (type >= PNG_EQUATION_LAST) - png_error(png_ptr, "Unrecognized equation type for pCAL chunk"); + png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - purpose_len = png_check_keyword(png_ptr, purpose, new_purpose); - - if (purpose_len == 0) - png_error(png_ptr, "pCAL: invalid keyword"); - - ++purpose_len; /* terminator */ - - png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); - units_len = strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d", (int)units_len); + purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; + png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); + units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); + png_debug1(3, "pCAL units length = %d\n", (int)units_len); total_len = purpose_len + units_len + 10; - params_len = (png_size_tp)png_malloc(png_ptr, - (png_alloc_size_t)(nparams * (sizeof (png_size_t)))); + params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams + *png_sizeof(png_uint_32))); /* Find the length of each parameter, making sure we don't count the - * null terminator for the last parameter. - */ + null terminator for the last parameter. */ for (i = 0; i < nparams; i++) { - params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu", i, - (unsigned long)params_len[i]); - total_len += params_len[i]; + params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); + png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); + total_len += (png_size_t)params_len[i]; } - png_debug1(3, "pCAL total length = %d", (int)total_len); - png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, new_purpose, purpose_len); + png_debug1(3, "pCAL total length = %d\n", (int)total_len); + png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf + 4, X1); buf[8] = (png_byte)type; buf[9] = (png_byte)nparams; png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len); + png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); + + png_free(png_ptr, new_purpose); for (i = 0; i < nparams; i++) { - png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]); + png_write_chunk_data(png_ptr, (png_bytep)params[i], + (png_size_t)params_len[i]); } png_free(png_ptr, params_len); @@ -1852,47 +1545,88 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, } #endif -#ifdef PNG_WRITE_sCAL_SUPPORTED -/* Write the sCAL chunk */ +#if defined(PNG_WRITE_sCAL_SUPPORTED) +/* write the sCAL chunk */ +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) void /* PRIVATE */ -png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, - png_const_charp height) +png_write_sCAL(png_structp png_ptr, int unit, double width,double height) { - png_byte buf[64]; - png_size_t wlen, hlen, total_len; +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sCAL; +#endif + png_size_t total_len; + char wbuf[32], hbuf[32]; + png_byte bunit = unit; - png_debug(1, "in png_write_sCAL_s"); + png_debug(1, "in png_write_sCAL\n"); - wlen = strlen(width); - hlen = strlen(height); - total_len = wlen + hlen + 2; - - if (total_len > 64) +#if defined(_WIN32_WCE) +/* sprintf() function is not supported on WindowsCE */ { - png_warning(png_ptr, "Can't write sCAL (buffer too small)"); - return; + wchar_t wc_buf[32]; + swprintf(wc_buf, TEXT("%12.12e"), width); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL); + swprintf(wc_buf, TEXT("%12.12e"), height); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL); } +#else + sprintf(wbuf, "%12.12e", width); + sprintf(hbuf, "%12.12e", height); +#endif + total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - buf[0] = (png_byte)unit; - memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ - memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ + png_debug1(3, "sCAL total length = %d\n", (int)total_len); + png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1); + png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); + png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); - png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len); + png_write_chunk_end(png_ptr); +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +void /* PRIVATE */ +png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, + png_charp height) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_sCAL; +#endif + png_size_t total_len; + char wbuf[32], hbuf[32]; + png_byte bunit = unit; + + png_debug(1, "in png_write_sCAL_s\n"); + + png_strcpy(wbuf,(const char *)width); + png_strcpy(hbuf,(const char *)height); + total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); + + png_debug1(3, "sCAL total length = %d\n", total_len); + png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1); + png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); + png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); + + png_write_chunk_end(png_ptr); } #endif +#endif +#endif -#ifdef PNG_WRITE_pHYs_SUPPORTED -/* Write the pHYs chunk */ +#if defined(PNG_WRITE_pHYs_SUPPORTED) +/* write the pHYs chunk */ void /* PRIVATE */ -png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) +png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, + png_uint_32 y_pixels_per_unit, + int unit_type) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_pHYs; +#endif png_byte buf[9]; - png_debug(1, "in png_write_pHYs"); - + png_debug(1, "in png_write_pHYs\n"); if (unit_type >= PNG_RESOLUTION_LAST) png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); @@ -1900,21 +1634,23 @@ png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, png_save_uint_32(buf + 4, y_pixels_per_unit); buf[8] = (png_byte)unit_type; - png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); } #endif -#ifdef PNG_WRITE_tIME_SUPPORTED +#if defined(PNG_WRITE_tIME_SUPPORTED) /* Write the tIME chunk. Use either png_convert_from_struct_tm() * or png_convert_from_time_t(), or fill in the structure yourself. */ void /* PRIVATE */ -png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) +png_write_tIME(png_structp png_ptr, png_timep mod_time) { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_tIME; +#endif png_byte buf[7]; - png_debug(1, "in png_write_tIME"); - + png_debug(1, "in png_write_tIME\n"); if (mod_time->month > 12 || mod_time->month < 1 || mod_time->day > 31 || mod_time->day < 1 || mod_time->hour > 23 || mod_time->second > 60) @@ -1930,147 +1666,136 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) buf[5] = mod_time->minute; buf[6] = mod_time->second; - png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7); + png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); } #endif -/* Initializes the row writing capability of libpng */ +/* initializes the row writing capability of libpng */ void /* PRIVATE */ -png_write_start_row(png_structrp png_ptr) +png_write_start_row(png_structp png_ptr) { -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* start of interlace block in the y direction */ + int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + /* offset to next interlace block in the y direction */ + int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif - png_alloc_size_t buf_size; - int usr_pixel_depth; + png_size_t buf_size; - png_debug(1, "in png_write_start_row"); - - usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth; - buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; - - /* 1.5.6: added to allow checking in the row write code. */ - png_ptr->transformed_pixel_depth = png_ptr->pixel_depth; - png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; - - /* Set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size); + png_debug(1, "in png_write_start_row\n"); + buf_size = (png_size_t)(PNG_ROWBYTES( + png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); + /* set up row buffer */ + png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; -#ifdef PNG_WRITE_FILTER_SUPPORTED - /* Set up filtering buffer, if using this filter */ + /* set up filtering buffer, if using this filter */ if (png_ptr->do_filter & PNG_FILTER_SUB) { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1); - + png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } /* We only need to keep the previous row if we are using one of these. */ if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { - /* Set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size); + /* set up previous row buffer */ + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + png_memset(png_ptr->prev_row, 0, buf_size); if (png_ptr->do_filter & PNG_FILTER_UP) { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - png_ptr->rowbytes + 1); - + png_ptr->up_row = (png_bytep )png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } if (png_ptr->do_filter & PNG_FILTER_AVG) { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - png_ptr->rowbytes + 1); - + (png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } if (png_ptr->do_filter & PNG_FILTER_PAETH) { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - png_ptr->rowbytes + 1); - + png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, + (png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } } -#endif /* PNG_WRITE_FILTER_SUPPORTED */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced, we need to set up width and height of pass */ + /* if interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - + png_pass_ystart[0]) / png_pass_yinc[0]; png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; + png_pass_start[0]) / png_pass_inc[0]; } - else { png_ptr->num_rows = png_ptr->height; png_ptr->usr_width = png_ptr->width; } } - else #endif { png_ptr->num_rows = png_ptr->height; png_ptr->usr_width = png_ptr->width; } + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_out = png_ptr->zbuf; } /* Internal use only. Called when finished processing a row of data. */ void /* PRIVATE */ -png_write_finish_row(png_structrp png_ptr) +png_write_finish_row(png_structp png_ptr) { -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* start of interlace block in the y direction */ + int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + /* offset to next interlace block in the y direction */ + int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif - png_debug(1, "in png_write_finish_row"); + int ret; - /* Next row */ + png_debug(1, "in png_write_finish_row\n"); + /* next row */ png_ptr->row_number++; - /* See if we are done */ + /* see if we are done */ if (png_ptr->row_number < png_ptr->num_rows) return; #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced, go to next pass */ + /* if interlaced, go to next pass */ if (png_ptr->interlaced) { png_ptr->row_number = 0; @@ -2078,53 +1803,77 @@ png_write_finish_row(png_structrp png_ptr) { png_ptr->pass++; } - else { - /* Loop until we find a non-zero width or height pass */ + /* loop until we find a non-zero width or height pass */ do { png_ptr->pass++; - if (png_ptr->pass >= 7) break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; if (png_ptr->transformations & PNG_INTERLACE) break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); } - /* Reset the row above the image for the next pass */ + /* reset the row above the image for the next pass */ if (png_ptr->pass < 7) { if (png_ptr->prev_row != NULL) - memset(png_ptr->prev_row, 0, - (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth, png_ptr->width)) + 1); - + png_memset(png_ptr->prev_row, 0, + (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* + png_ptr->usr_bit_depth,png_ptr->width))+1); return; } } #endif - /* If we get here, we've just written the last row, so we need + /* if we get here, we've just written the last row, so we need to flush the compressor */ - png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH); + do + { + /* tell the compressor we are done */ + ret = deflate(&png_ptr->zstream, Z_FINISH); + /* check for an error */ + if (ret == Z_OK) + { + /* check to see if we need more room */ + if (!(png_ptr->zstream.avail_out)) + { + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + else if (ret != Z_STREAM_END) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } + } while (ret != Z_STREAM_END); + + /* write any extra space */ + if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) + { + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - + png_ptr->zstream.avail_out); + } + + deflateReset(&png_ptr->zstream); } -#ifdef PNG_WRITE_INTERLACING_SUPPORTED +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Pick out the correct pixels for the interlace pass. * The basic idea here is to go through the row with a source * pointer and a destination pointer (sp and dp), and copy the @@ -2135,20 +1884,25 @@ png_write_finish_row(png_structrp png_ptr) void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* start of interlace block */ + int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* offset to next interlace block */ + int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif - png_debug(1, "in png_do_write_interlace"); - - /* We don't have to do anything on the last pass (6) */ + png_debug(1, "in png_do_write_interlace\n"); + /* we don't have to do anything on the last pass (6) */ +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && pass < 6) +#else if (pass < 6) +#endif { - /* Each pixel depth is handled separately */ + /* each pixel depth is handled separately */ switch (row_info->pixel_depth) { case 1: @@ -2164,7 +1918,6 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) dp = row; d = 0; shift = 7; - for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { @@ -2178,17 +1931,14 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } - else shift--; } if (shift != 7) *dp = (png_byte)d; - break; } - case 2: { png_bytep sp; @@ -2202,7 +1952,6 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) dp = row; shift = 6; d = 0; - for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { @@ -2216,16 +1965,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } - else shift -= 2; } if (shift != 6) - *dp = (png_byte)d; - + *dp = (png_byte)d; break; } - case 4: { png_bytep sp; @@ -2240,7 +1986,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) shift = 4; d = 0; for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) + i += png_pass_inc[pass]) { sp = row + (png_size_t)(i >> 1); value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; @@ -2252,16 +1998,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } - else shift -= 4; } if (shift != 4) *dp = (png_byte)d; - break; } - default: { png_bytep sp; @@ -2270,37 +2013,33 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) png_uint_32 row_width = row_info->width; png_size_t pixel_bytes; - /* Start at the beginning */ + /* start at the beginning */ dp = row; - - /* Find out how many bytes each pixel takes up */ + /* find out how many bytes each pixel takes up */ pixel_bytes = (row_info->pixel_depth >> 3); - - /* Loop through the row, only looking at the pixels that matter */ + /* loop through the row, only looking at the pixels that + matter */ for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { - /* Find out where the original pixel is */ + /* find out where the original pixel is */ sp = row + (png_size_t)i * pixel_bytes; - - /* Move the pixel */ + /* move the pixel */ if (dp != sp) - memcpy(dp, sp, pixel_bytes); - - /* Next pixel */ + png_memcpy(dp, sp, pixel_bytes); + /* next pixel */ dp += pixel_bytes; } break; } } - /* Set new row width */ + /* set new row width */ row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); + png_pass_inc[pass] - 1 - + png_pass_start[pass]) / + png_pass_inc[pass]; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); } } #endif @@ -2309,44 +2048,27 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) * been specified by the application, and then writes the row out with the * chosen filter. */ -static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t row_bytes); - -#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) +#define PNG_MAXSUM (~((png_uint_32)0) >> 1) #define PNG_HISHIFT 10 #define PNG_LOMASK ((png_uint_32)0xffffL) #define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) void /* PRIVATE */ -png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) +png_write_find_filter(png_structp png_ptr, png_row_infop row_info) { - png_bytep best_row; -#ifdef PNG_WRITE_FILTER_SUPPORTED - png_bytep prev_row, row_buf; + png_bytep prev_row, best_row, row_buf; png_uint_32 mins, bpp; png_byte filter_to_do = png_ptr->do_filter; - png_size_t row_bytes = row_info->rowbytes; -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - int num_p_filters = png_ptr->num_prev_filters; + png_uint_32 row_bytes = row_info->rowbytes; +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + int num_p_filters = (int)png_ptr->num_prev_filters; #endif - png_debug(1, "in png_write_find_filter"); - -#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS) - { - /* These will never be selected so we need not test them. */ - filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH); - } -#endif - - /* Find out how many bytes offset each pixel is */ + png_debug(1, "in png_write_find_filter\n"); + /* find out how many bytes offset each pixel is */ bpp = (row_info->pixel_depth + 7) >> 3; prev_row = png_ptr->prev_row; -#endif - best_row = png_ptr->row_buf; -#ifdef PNG_WRITE_FILTER_SUPPORTED - row_buf = best_row; + best_row = row_buf = png_ptr->row_buf; mins = PNG_MAXSUM; /* The prediction method we use is to find which method provides the @@ -2361,14 +2083,11 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) * computationally expensive). * * GRR 980525: consider also - * * (1) minimum sum of absolute differences from running average (i.e., * keep running sum of non-absolute differences & count of bytes) * [track dispersion, too? restart average if dispersion too large?] - * * (1b) minimum sum of absolute differences from sliding average, probably * with window size <= deflate window (usually 32K) - * * (2) minimum sum of squared differences from zero or running average * (i.e., ~ root-mean-square approach) */ @@ -2377,11 +2096,12 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* We don't need to test the 'no filter' case if this is the only filter * that has been chosen, as it doesn't actually do anything to the data. */ - if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE) + if ((filter_to_do & PNG_FILTER_NONE) && + filter_to_do != PNG_FILTER_NONE) { png_bytep rp; png_uint_32 sum = 0; - png_size_t i; + png_uint_32 i; int v; for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) @@ -2390,7 +2110,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { png_uint_32 sumhi, sumlo; @@ -2404,10 +2124,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } @@ -2416,14 +2135,12 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) * it has the minimum possible computational cost - none). */ sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; - else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2431,25 +2148,22 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) mins = sum; } - /* Sub filter */ + /* sub filter */ if (filter_to_do == PNG_FILTER_SUB) - /* It's the only filter so no testing is needed */ + /* it's the only filter so no testing is needed */ { png_bytep rp, lp, dp; - png_size_t i; - + png_uint_32 i; for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; i++, rp++, dp++) { *dp = *rp; } - for (lp = row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); } - best_row = png_ptr->sub_row; } @@ -2457,10 +2171,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) { png_bytep rp, dp, lp; png_uint_32 sum = 0, lmins = mins; - png_size_t i; + png_uint_32 i; int v; -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* We temporarily increase the "minimum sum" by the factor we * would reduce the sum of this filter, so that we can do the * early exit comparison without scaling the sum each time. @@ -2477,22 +2191,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; - else lmins = (lmhi << PNG_HISHIFT) + lmlo; } @@ -2505,7 +2216,6 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } - for (lp = row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { @@ -2517,7 +2227,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) break; } -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2530,22 +2240,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) { sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; - else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2558,19 +2265,18 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) } } - /* Up filter */ + /* up filter */ if (filter_to_do == PNG_FILTER_UP) { png_bytep rp, dp, pp; - png_size_t i; + png_uint_32 i; for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) + pp = prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) { *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); } - best_row = png_ptr->up_row; } @@ -2578,11 +2284,11 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp; png_uint_32 sum = 0, lmins = mins; - png_size_t i; + png_uint_32 i; int v; -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2595,29 +2301,26 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; - else lmins = (lmhi << PNG_HISHIFT) + lmlo; } #endif for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) + pp = prev_row + 1; i < row_bytes; i++) { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); @@ -2627,7 +2330,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) break; } -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2640,22 +2343,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; - else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2668,18 +2368,16 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) } } - /* Avg filter */ + /* avg filter */ if (filter_to_do == PNG_FILTER_AVG) { png_bytep rp, dp, pp, lp; png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, pp = prev_row + 1; i < bpp; i++) { *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); } - for (lp = row_buf + 1; i < row_bytes; i++) { *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) @@ -2692,10 +2390,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp, lp; png_uint_32 sum = 0, lmins = mins; - png_size_t i; + png_uint_32 i; int v; -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2708,22 +2406,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; - else lmins = (lmhi << PNG_HISHIFT) + lmlo; } @@ -2736,11 +2431,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } - for (lp = row_buf + 1; i < row_bytes; i++) { v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); + (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); sum += (v < 128) ? v : 256 - v; @@ -2748,7 +2442,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) break; } -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2761,22 +2455,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; - else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2793,10 +2484,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_PAETH) { png_bytep rp, dp, pp, cp, lp; - png_size_t i; - + png_uint_32 i; for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) + pp = prev_row + 1; i < bpp; i++) { *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); } @@ -2833,10 +2523,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp, cp, lp; png_uint_32 sum = 0, lmins = mins; - png_size_t i; + png_uint_32 i; int v; -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2849,29 +2539,26 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; - else lmins = (lmhi << PNG_HISHIFT) + lmlo; } #endif for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) + pp = prev_row + 1; i < bpp; i++) { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); @@ -2904,13 +2591,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) pa = abs(p - a); pb = abs(p - b); pc = abs(p - c); - if (pa <= pb && pa <= pc) p = a; - else if (pb <= pc) p = b; - else p = c; #endif /* PNG_SLOW_PAETH */ @@ -2923,7 +2607,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) break; } -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2936,22 +2620,19 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - + PNG_WEIGHT_SHIFT; sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - + PNG_COST_SHIFT; sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; - else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2962,42 +2643,64 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->paeth_row; } } -#endif /* PNG_WRITE_FILTER_SUPPORTED */ /* Do the actual writing of the filtered row data from the chosen filter. */ - png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); -#ifdef PNG_WRITE_FILTER_SUPPORTED -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + png_write_filtered_row(png_ptr, best_row); + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* Save the type of filter we picked this time for future calculations */ if (png_ptr->num_prev_filters > 0) { int j; - for (j = 1; j < num_p_filters; j++) { png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; } - png_ptr->prev_filters[j] = best_row[0]; } #endif -#endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* Do the actual writing of a previously filtered row. */ -static void -png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t full_row_length/*includes filter byte*/) +void /* PRIVATE */ +png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) { - png_debug(1, "in png_write_filtered_row"); + png_debug(1, "in png_write_filtered_row\n"); + png_debug1(2, "filter = %d\n", filtered_row[0]); + /* set up the zlib input buffer */ - png_debug1(2, "filter = %d", filtered_row[0]); + png_ptr->zstream.next_in = filtered_row; + png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; + /* repeat until we have compressed all the data */ + do + { + int ret; /* return of zlib */ - png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); + /* compress the data */ + ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); + /* check for compression errors */ + if (ret != Z_OK) + { + if (png_ptr->zstream.msg != NULL) + png_error(png_ptr, png_ptr->zstream.msg); + else + png_error(png_ptr, "zlib error"); + } - /* Swap the current and previous rows */ + /* see if it is time to write another IDAT */ + if (!(png_ptr->zstream.avail_out)) + { + /* write the IDAT and reset the zlib output buffer */ + png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + /* repeat until all data has been compressed */ + } while (png_ptr->zstream.avail_in); + + /* swap the current and previous rows */ if (png_ptr->prev_row != NULL) { png_bytep tptr; @@ -3007,10 +2710,10 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, png_ptr->row_buf = tptr; } - /* Finish row - updates counters and flushes zlib if last row */ + /* finish row - updates counters and flushes zlib if last row */ png_write_finish_row(png_ptr); -#ifdef PNG_WRITE_FLUSH_SUPPORTED +#if defined(PNG_WRITE_FLUSH_SUPPORTED) png_ptr->flush_rows++; if (png_ptr->flush_dist > 0 && diff --git a/Source/3rd Party/wx/src/tiff/libtiff/tiff.h b/Source/3rd Party/wx/src/tiff/libtiff/tiff.h index 31e177bce..8656f7194 100644 --- a/Source/3rd Party/wx/src/tiff/libtiff/tiff.h +++ b/Source/3rd Party/wx/src/tiff/libtiff/tiff.h @@ -1,3 +1,4 @@ +/* $Id$ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -42,75 +43,87 @@ * Suite 200 * Seattle, WA 98104 * 206-622-5500 - * + * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * - * For BigTIFF design notes see the following links - * http://www.remotesensing.org/libtiff/bigtiffdesign.html - * http://www.awaresystems.be/imaging/tiff/bigtiff.html + * For Big TIFF design notes see the following link + * http://gdal.maptools.org/twiki/bin/view/libtiff/BigTIFFDesign */ +#define TIFF_VERSION 42 +#define TIFF_BIGTIFF_VERSION 43 -#define TIFF_VERSION_CLASSIC 42 -#define TIFF_VERSION_BIG 43 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 - +#define TIFF_BIGENDIAN 0x4d4d +#define TIFF_LITTLEENDIAN 0x4949 +#define MDI_LITTLEENDIAN 0x5045 +#define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * 64-bit quantities int64/uint64 - * strings unsigned char* + * 8-bit quantities int8/uint8 + * 16-bit quantities int16/uint16 + * 32-bit quantities int32/uint32 + * strings unsigned char* */ -typedef TIFF_INT8_T int8; -typedef TIFF_UINT8_T uint8; +#ifndef HAVE_INT8 +typedef signed char int8; /* NB: non-ANSI compilers may not grok */ +#endif +typedef unsigned char uint8; +#ifndef HAVE_INT16 +typedef short int16; +#endif +typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ +#if SIZEOF_INT == 4 +#ifndef HAVE_INT32 +typedef int int32; +#endif +typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ +#elif SIZEOF_LONG == 4 +#ifndef HAVE_INT32 +typedef long int32; +#endif +typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ +#endif -typedef TIFF_INT16_T int16; -typedef TIFF_UINT16_T uint16; - -typedef TIFF_INT32_T int32; -typedef TIFF_UINT32_T uint32; - -typedef TIFF_INT64_T int64; -typedef TIFF_UINT64_T uint64; - -/* - * Some types as promoted in a variable argument list - * We use uint16_vap rather then directly using int, because this way - * we document the type we actually want to pass through, conceptually, - * rather then confusing the issue by merely stating the type it gets - * promoted to - */ - -typedef int uint16_vap; +/* For TIFFReassignTagToIgnore */ +enum TIFFIgnoreSense /* IGNORE tag table */ +{ + TIS_STORE, + TIS_EXTRACT, + TIS_EMPTY +}; /* * TIFF header. */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ -} TIFFHeaderCommon; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderClassic; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint16 tiff_offsetsize; /* size of offsets, should be 8 */ - uint16 tiff_unused; /* unused word, should be 0 */ - uint64 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderBig; +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ +#define TIFF_MAGIC_SIZE 2 + uint16 tiff_version; /* TIFF version number */ +#define TIFF_VERSION_SIZE 2 + uint32 tiff_diroff; /* byte offset to first directory */ +#define TIFF_DIROFFSET_SIZE 4 +} TIFFHeader; +/* + * TIFF Image File Directories are comprised of a table of field + * descriptors of the form shown below. The table is sorted in + * ascending order by tag. The values associated with each entry are + * disjoint and may appear anywhere in the file (so long as they are + * placed on a word boundary). + * + * If the value is 4 bytes or less, then it is placed in the offset + * field to save space. If the value is less than 4 bytes, it is + * left-justified in the offset field. + */ +typedef struct { + uint16 tdir_tag; /* see below */ + uint16 tdir_type; /* data type; see below */ + uint32 tdir_count; /* number of items; length in spec */ + uint32 tdir_offset; /* byte offset to field data */ +} TIFFDirEntry; + /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, @@ -125,24 +138,21 @@ typedef struct { * * Note: RATIONALs are the ratio of two 32-bit integer values. */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ - TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ - TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ - TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ + TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */ } TIFFDataType; /* @@ -169,8 +179,6 @@ typedef enum { #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ -#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ @@ -192,7 +200,6 @@ typedef enum { #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ @@ -324,30 +331,6 @@ typedef enum { [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ -/* Tags 400-435 are from the TIFF/FX spec */ -#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ -#define TIFFTAG_PROFILETYPE 401 /* ! */ -#define PROFILETYPE_UNSPECIFIED 0 /* ! */ -#define PROFILETYPE_G3_FAX 1 /* ! */ -#define TIFFTAG_FAXPROFILE 402 /* ! */ -#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ -#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ -#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ -#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ -#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ -#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ -#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ -#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ -#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ -#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ -#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ -#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ -#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ -#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ -#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ -#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ -#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ -#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. @@ -369,7 +352,6 @@ typedef enum { #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ @@ -436,7 +418,6 @@ typedef enum { #define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */ /* tag 34750 is a private tag registered to Adobe? */ #define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ -#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */ /* tag 34750 is a private tag registered to Pixel Magic */ #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ @@ -599,10 +580,6 @@ typedef enum { #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ -#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ -#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ -#define PERSAMPLE_MERGED 0 /* present as a single value */ -#define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags @@ -672,10 +649,3 @@ typedef enum { #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/Source/3rd Party/wx/src/tiff/libtiff/tiffconf.h b/Source/3rd Party/wx/src/tiff/libtiff/tiffconf.h index a24efc83b..f5b16cb0c 100644 --- a/Source/3rd Party/wx/src/tiff/libtiff/tiffconf.h +++ b/Source/3rd Party/wx/src/tiff/libtiff/tiffconf.h @@ -1,3 +1,4 @@ +/* libtiff/tiffconf.h. Generated by configure. */ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions @@ -7,10 +8,6 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ -#ifdef __MINGW32__ -#include -#endif - /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ @@ -23,58 +20,8 @@ /* The size of a `int', as computed by sizeof. */ #define SIZEOF_INT 4 -/* Signed 8-bit type */ -#define TIFF_INT8_T signed char - -/* Unsigned 8-bit type */ -#define TIFF_UINT8_T unsigned char - -/* Signed 16-bit type */ -#define TIFF_INT16_T signed short - -/* Unsigned 16-bit type */ -#define TIFF_UINT16_T unsigned short - -/* Signed 32-bit type formatter */ -#define TIFF_INT32_FORMAT "%d" - -/* Signed 32-bit type */ -#define TIFF_INT32_T signed int - -/* Unsigned 32-bit type formatter */ -#define TIFF_UINT32_FORMAT "%u" - -/* Unsigned 32-bit type */ -#define TIFF_UINT32_T unsigned int - -/* Signed 64-bit type formatter */ -#define TIFF_INT64_FORMAT "%I64d" - -/* Signed 64-bit type */ -#define TIFF_INT64_T signed __int64 - -/* Unsigned 64-bit type formatter */ -#define TIFF_UINT64_FORMAT "%I64u" - -/* Unsigned 64-bit type */ -#define TIFF_UINT64_T unsigned __int64 - -/* Signed size type */ -#if defined(_WIN64) -#define TIFF_SSIZE_T signed __int64 -#else -#define TIFF_SSIZE_T signed int -#endif - -/* Signed size type formatter */ -#if defined(_WIN64) -#define TIFF_SSIZE_FORMAT "%I64d" -#else -#define TIFF_SSIZE_FORMAT "%ld" -#endif - -/* Pointer difference type */ -#define TIFF_PTRDIFF_T long +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 /* Compatibility stuff. */ @@ -152,10 +99,3 @@ #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/Source/3rd Party/wx/src/tiff/libtiff/tiffio.h b/Source/3rd Party/wx/src/tiff/libtiff/tiffio.h index 662e1701a..249fe9ed3 100644 --- a/Source/3rd Party/wx/src/tiff/libtiff/tiffio.h +++ b/Source/3rd Party/wx/src/tiff/libtiff/tiffio.h @@ -1,20 +1,21 @@ +/* $Id$ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, @@ -36,7 +37,7 @@ * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ -typedef struct tiff TIFF; +typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of @@ -54,27 +55,17 @@ typedef struct tiff TIFF; * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets, and BigTIFF maxes out at 64-bit - * offsets being the most important, and to ensure use of - * a consistently unsigned type across architectures. - * Prior to libtiff 4.0, this was an unsigned 32 bit type. + * 32-bit file offsets being the most important, and to ensure + * that it is unsigned, rather than signed. */ -/* - * this is the machine addressing size type, only it's signed, so make it - * int32 on 32bit machines, int64 on 64bit machines - */ -typedef TIFF_SSIZE_T tmsize_t; -typedef uint64 toff_t; /* file offset */ -/* the following are deprecated and should be replaced by their defining - counterparts */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrile_t; /* strip or tile number */ -typedef tstrile_t tstrip_t; /* strip number */ -typedef tstrile_t ttile_t; /* tile number */ -typedef tmsize_t tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ +typedef uint32 ttag_t; /* directory tag */ +typedef uint16 tdir_t; /* directory index */ +typedef uint16 tsample_t; /* sample number */ +typedef uint32 tstrip_t; /* strip number */ +typedef uint32 ttile_t; /* tile number */ +typedef int32 tsize_t; /* i/o size in bytes */ +typedef void* tdata_t; /* image data ref */ +typedef uint32 toff_t; /* file offset */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ @@ -97,27 +88,31 @@ typedef void* tdata_t; /* image data ref */ # define VC_EXTRALEAN # include # ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else -typedef HFILE thandle_t; /* client data handle */ +typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else -typedef void* thandle_t; /* client data handle */ +typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ +#ifndef NULL +# define NULL (void *)0 +#endif + /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff @@ -134,42 +129,42 @@ typedef void* thandle_t; /* client data handle */ /* Structure for holding information about a display device. */ -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ +typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ + uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ + float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ + float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; +typedef struct { /* YCbCr->RGB support */ + TIFFRGBValue* clamptab; /* range clamping table */ + int* Cr_r_tab; + int* Cb_b_tab; + int32* Cr_g_tab; + int32* Cb_g_tab; + int32* Y_tab; } TIFFYCbCrToRGB; -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ +typedef struct { /* CIE Lab 1976->RGB support */ + int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ + float rstep, gstep, bstep; + float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ + float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ + float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ + float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* @@ -196,49 +191,45 @@ typedef void (*tileSeparateRoutine) * RGBA-reader state. */ struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - /* put decoded strip/tile */ + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 req_orientation; /* requested orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap pallete */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); union { void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ + tileContigRoutine contig; + tileSeparateRoutine separate; + } put; /* put decoded strip/tile */ + TIFFRGBValue* Map; /* sample mapping array */ + uint32** BWmap; /* black&white map */ + uint32** PALmap; /* palette image map */ + TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ + TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ - uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ - - int row_offset; - int col_offset; + int row_offset; + int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) +#define TIFFGetR(abgr) ((abgr) & 0xff) +#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) +#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) +#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, @@ -247,11 +238,11 @@ struct _TIFFRGBAImage { * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ -typedef int (*TIFFInitMethod)(TIFF*, int); +typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; + char* name; + uint16 scheme; + TIFFInitMethod init; } TIFFCodec; #include @@ -259,274 +250,54 @@ typedef struct { /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if !defined(__GNUC__) && !defined(__attribute__) -# define __attribute__(x) /*nothing*/ +#define LOGLUV_PUBLIC 1 #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); -typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); -typedef void (*TIFFExtendProc)(TIFF*); +typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); +typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); +typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); +typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); +typedef int (*TIFFCloseProc)(thandle_t); +typedef toff_t (*TIFFSizeProc)(thandle_t); +typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); +typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); +typedef void (*TIFFExtendProc)(TIFF*); -extern const char* TIFFGetVersion(void); +extern const char* TIFFGetVersion(void); -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); -extern TIFFCodec* TIFFGetConfiguredCODECs(void); +extern const TIFFCodec* TIFFFindCODEC(uint16); +extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern void TIFFUnRegisterCODEC(TIFFCodec*); +extern int TIFFIsCODECConfigured(uint16); +extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ -extern void* _TIFFmalloc(tmsize_t s); -extern void* _TIFFrealloc(void* p, tmsize_t s); -extern void _TIFFmemset(void* p, int v, tmsize_t c); -extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); -extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); -extern void _TIFFfree(void* p); +extern tdata_t _TIFFmalloc(tsize_t); +extern tdata_t _TIFFrealloc(tdata_t, tsize_t); +extern void _TIFFmemset(tdata_t, int, tsize_t); +extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); +extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); +extern void _TIFFfree(tdata_t); /* ** Stuff, related to tag handling and creating custom tags. */ -extern int TIFFGetTagListCount( TIFF * ); -extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); +extern int TIFFGetTagListCount( TIFF * ); +extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index ); -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ +#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ +#define TIFF_VARIABLE -1 /* marker for variable length tags */ +#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ -#define FIELD_CUSTOM 65 +#define FIELD_CUSTOM 65 -typedef struct _TIFFField TIFFField; -typedef struct _TIFFFieldArray TIFFFieldArray; - -extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); -extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); -extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); - -extern uint32 TIFFFieldTag(const TIFFField*); -extern const char* TIFFFieldName(const TIFFField*); -extern TIFFDataType TIFFFieldDataType(const TIFFField*); -extern int TIFFFieldPassCount(const TIFFField*); -extern int TIFFFieldReadCount(const TIFFField*); -extern int TIFFFieldWriteCount(const TIFFField*); - -typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); -extern void *TIFFGetClientInfo(TIFF *, const char *); -extern void TIFFSetClientInfo(TIFF *, void *, const char *); - -extern void TIFFCleanup(TIFF* tif); -extern void TIFFClose(TIFF* tif); -extern int TIFFFlush(TIFF* tif); -extern int TIFFFlushData(TIFF* tif); -extern int TIFFGetField(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFReadDirectory(TIFF* tif); -extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); -extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); -extern uint64 TIFFScanlineSize64(TIFF* tif); -extern tmsize_t TIFFScanlineSize(TIFF* tif); -extern uint64 TIFFRasterScanlineSize64(TIFF* tif); -extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); -extern uint64 TIFFStripSize64(TIFF* tif); -extern tmsize_t TIFFStripSize(TIFF* tif); -extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); -extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); -extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); -extern uint64 TIFFTileRowSize64(TIFF* tif); -extern tmsize_t TIFFTileRowSize(TIFF* tif); -extern uint64 TIFFTileSize64(TIFF* tif); -extern tmsize_t TIFFTileSize(TIFF* tif); -extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); -extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFSetFileno(TIFF*, int); -extern thandle_t TIFFClientdata(TIFF*); -extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); -extern int TIFFGetMode(TIFF*); -extern int TIFFSetMode(TIFF*, int); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern int TIFFIsBigEndian(TIFF*); -extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); -extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -extern TIFFSeekProc TIFFGetSeekProc(TIFF*); -extern TIFFCloseProc TIFFGetCloseProc(TIFF*); -extern TIFFSizeProc TIFFGetSizeProc(TIFF*); -extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern uint16 TIFFCurrentDirectory(TIFF*); -extern uint16 TIFFNumberOfDirectories(TIFF*); -extern uint64 TIFFCurrentDirOffset(TIFF*); -extern uint32 TIFFCurrentStrip(TIFF*); -extern uint32 TIFFCurrentTile(TIFF* tif); -extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFSetupStrips(TIFF *); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); -extern int TIFFCreateEXIFDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, uint16); -extern int TIFFSetSubDirectory(TIFF*, uint64); -extern int TIFFUnlinkDirectory(TIFF*, uint16); -extern int TIFFSetField(TIFF*, uint32, ...); -extern int TIFFVSetField(TIFF*, uint32, va_list); -extern int TIFFUnsetField(TIFF*, uint32); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); -extern int TIFFCheckpointDirectory(TIFF *); -extern int TIFFRewriteDirectory(TIFF *); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -extern TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFNumberOfTiles(TIFF*); -extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); -extern uint32 TIFFNumberOfStrips(TIFF*); -extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabLong8(uint64*); -extern void TIFFSwabFloat(float*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); -extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); -extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); -extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); -extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); -extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); -extern void TIFFReverseBits(uint8* cp, tmsize_t n); -extern const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -extern double LogL16toY(int); -extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); -extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -extern int LogL16fromY(double, int); -extern int LogL10fromY(double, int); -extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -/**************************************************************************** - * O B S O L E T E D I N T E R F A C E S - * - * Don't use this stuff in your applications, it may be removed in the future - * libtiff versions. - ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ @@ -538,8 +309,203 @@ typedef struct { char *field_name; /* ASCII name */ } TIFFFieldInfo; -extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); +typedef struct _TIFFTagValue { + const TIFFFieldInfo *info; + int count; + void *value; +} TIFFTagValue; + +extern void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); +extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); +extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *, + TIFFDataType); +extern const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t); +extern const TIFFFieldInfo* TIFFFieldWithName(TIFF*, const char *); + +typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); +typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); + +typedef struct { + TIFFVSetMethod vsetfield; /* tag set routine */ + TIFFVGetMethod vgetfield; /* tag get routine */ + TIFFPrintMethod printdir; /* directory print routine */ +} TIFFTagMethods; +extern TIFFTagMethods *TIFFAccessTagMethods( TIFF * ); +extern void *TIFFGetClientInfo( TIFF *, const char * ); +extern void TIFFSetClientInfo( TIFF *, void *, const char * ); + +extern void TIFFCleanup(TIFF*); +extern void TIFFClose(TIFF*); +extern int TIFFFlush(TIFF*); +extern int TIFFFlushData(TIFF*); +extern int TIFFGetField(TIFF*, ttag_t, ...); +extern int TIFFVGetField(TIFF*, ttag_t, va_list); +extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); +extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); +extern int TIFFReadDirectory(TIFF*); +extern int TIFFReadCustomDirectory(TIFF*, toff_t, const TIFFFieldInfo[], + size_t); +extern int TIFFReadEXIFDirectory(TIFF*, toff_t); +extern tsize_t TIFFScanlineSize(TIFF*); +extern tsize_t TIFFRasterScanlineSize(TIFF*); +extern tsize_t TIFFStripSize(TIFF*); +extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t); +extern tsize_t TIFFVStripSize(TIFF*, uint32); +extern tsize_t TIFFTileRowSize(TIFF*); +extern tsize_t TIFFTileSize(TIFF*); +extern tsize_t TIFFVTileSize(TIFF*, uint32); +extern uint32 TIFFDefaultStripSize(TIFF*, uint32); +extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); +extern int TIFFFileno(TIFF*); +extern int TIFFSetFileno(TIFF*, int); +extern thandle_t TIFFClientdata(TIFF*); +extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); +extern int TIFFGetMode(TIFF*); +extern int TIFFSetMode(TIFF*, int); +extern int TIFFIsTiled(TIFF*); +extern int TIFFIsByteSwapped(TIFF*); +extern int TIFFIsUpSampled(TIFF*); +extern int TIFFIsMSB2LSB(TIFF*); +extern int TIFFIsBigEndian(TIFF*); +extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); +extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); +extern TIFFSeekProc TIFFGetSeekProc(TIFF*); +extern TIFFCloseProc TIFFGetCloseProc(TIFF*); +extern TIFFSizeProc TIFFGetSizeProc(TIFF*); +extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); +extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); +extern uint32 TIFFCurrentRow(TIFF*); +extern tdir_t TIFFCurrentDirectory(TIFF*); +extern tdir_t TIFFNumberOfDirectories(TIFF*); +extern uint32 TIFFCurrentDirOffset(TIFF*); +extern tstrip_t TIFFCurrentStrip(TIFF*); +extern ttile_t TIFFCurrentTile(TIFF*); +extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); +extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); +extern int TIFFSetupStrips(TIFF *); +extern int TIFFWriteCheck(TIFF*, int, const char *); +extern void TIFFFreeDirectory(TIFF*); +extern int TIFFCreateDirectory(TIFF*); +extern int TIFFLastDirectory(TIFF*); +extern int TIFFSetDirectory(TIFF*, tdir_t); +extern int TIFFSetSubDirectory(TIFF*, uint32); +extern int TIFFUnlinkDirectory(TIFF*, tdir_t); +extern int TIFFSetField(TIFF*, ttag_t, ...); +extern int TIFFVSetField(TIFF*, ttag_t, va_list); +extern int TIFFWriteDirectory(TIFF *); +extern int TIFFCheckpointDirectory(TIFF *); +extern int TIFFRewriteDirectory(TIFF *); +extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); + +#if defined(c_plusplus) || defined(__cplusplus) +extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); +extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); +extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, + int = ORIENTATION_BOTLEFT, int = 0); +#else +extern void TIFFPrintDirectory(TIFF*, FILE*, long); +extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); +extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); +#endif + +extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); +extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); +extern int TIFFRGBAImageOK(TIFF*, char [1024]); +extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern void TIFFRGBAImageEnd(TIFFRGBAImage*); +extern TIFF* TIFFOpen(const char*, const char*); +# ifdef __WIN32__ +extern TIFF* TIFFOpenW(const wchar_t*, const char*); +# endif /* __WIN32__ */ +extern TIFF* TIFFFdOpen(int, const char*, const char*); +extern TIFF* TIFFClientOpen(const char*, const char*, + thandle_t, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, + TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc); +extern const char* TIFFFileName(TIFF*); +extern const char* TIFFSetFileName(TIFF*, const char *); +extern void TIFFError(const char*, const char*, ...); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...); +extern void TIFFWarning(const char*, const char*, ...); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); +extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); +extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); +extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); +extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); +extern ttile_t TIFFNumberOfTiles(TIFF*); +extern tsize_t TIFFReadTile(TIFF*, + tdata_t, uint32, uint32, uint32, tsample_t); +extern tsize_t TIFFWriteTile(TIFF*, + tdata_t, uint32, uint32, uint32, tsample_t); +extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); +extern tstrip_t TIFFNumberOfStrips(TIFF*); +extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ +extern void TIFFSetWriteOffset(TIFF*, toff_t); +extern void TIFFSwabShort(uint16*); +extern void TIFFSwabLong(uint32*); +extern void TIFFSwabDouble(double*); +extern void TIFFSwabArrayOfShort(uint16*, unsigned long); +extern void TIFFSwabArrayOfTriples(uint8*, unsigned long); +extern void TIFFSwabArrayOfLong(uint32*, unsigned long); +extern void TIFFSwabArrayOfDouble(double*, unsigned long); +extern void TIFFReverseBits(unsigned char *, unsigned long); +extern const unsigned char* TIFFGetBitRevTable(int); + +#ifdef LOGLUV_PUBLIC +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +extern double LogL16toY(int); +extern double LogL10toY(int); +extern void XYZtoRGB24(float*, uint8*); +extern int uv_decode(double*, double*, int); +extern void LogLuv24toXYZ(uint32, float*); +extern void LogLuv32toXYZ(uint32, float*); +#if defined(c_plusplus) || defined(__cplusplus) +extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); +extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); +extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); +#else +extern int LogL16fromY(double, int); +extern int LogL10fromY(double, int); +extern int uv_encode(double, double, int); +extern uint32 LogLuv24fromXYZ(float*, int); +extern uint32 LogLuv32fromXYZ(float*, int); +#endif +#endif /* LOGLUV_PUBLIC */ + +extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, + float *, float *, float *); +extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, + uint32 *, uint32 *, uint32 *); + +extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, + uint32 *, uint32 *, uint32 *); + #if defined(c_plusplus) || defined(__cplusplus) } #endif @@ -547,10 +513,3 @@ extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/Source/3rd Party/wx/src/tiff/libtiff/tiffvers.h b/Source/3rd Party/wx/src/tiff/libtiff/tiffvers.h index 5e0ff317c..deb6d97c1 100644 --- a/Source/3rd Party/wx/src/tiff/libtiff/tiffvers.h +++ b/Source/3rd Party/wx/src/tiff/libtiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20120922 +#define TIFFLIB_VERSION 20060323 diff --git a/Source/3rd Party/wx/src/xrc/descrip.mms b/Source/3rd Party/wx/src/xrc/descrip.mms deleted file mode 100644 index b1c10c2e4..000000000 --- a/Source/3rd Party/wx/src/xrc/descrip.mms +++ /dev/null @@ -1,164 +0,0 @@ -#***************************************************************************** -# * -# Make file for VMS * -# Author : J.Jansen (joukj@hrem.nano.tudelft.nl) * -# Date : 6 November 2012 * -# * -#***************************************************************************** -.first - define wx [--.include.wx] - -.ifdef __WXMOTIF__ -CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\ - /assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short) -.else -.ifdef __WXGTK__ -CXX_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm\ - /assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm -.else -.ifdef __WXGTK2__ -CXX_DEFINE = /define=(__WXGTK__=1,VMS_GTK2=1)/float=ieee/name=(as_is,short)/ieee=denorm\ - /assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXGTK__=1,VMS_GTK2=1)/float=ieee/name=(as_is,short)/ieee=denorm -.else -.ifdef __WXX11__ -CXX_DEFINE = /define=(__WXX11__=1,__WXUNIVERSAL__==1)/float=ieee\ - /name=(as_is,short)/assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXX11__=1,__WXUNIVERSAL__==1)/float=ieee\ - /name=(as_is,short) -.else -CXX_DEFINE = -CC_DEFINE = -.endif -.endif -.endif -.endif - -.suffixes : .cpp - -.cpp.obj : - cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp -.c.obj : - cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c - -OBJECTS=xh_bmp.obj,xh_bmpbt.obj,xh_bttn.obj,xh_cald.obj,xh_chckb.obj,\ - xh_chckl.obj,xh_choic.obj,xh_combo.obj,xh_dlg.obj,xh_frame.obj,\ - xh_gauge.obj,xh_gdctl.obj,xh_html.obj,xh_listb.obj,xh_listc.obj,\ - xh_menu.obj,xh_notbk.obj,xh_panel.obj,xh_radbt.obj,xh_radbx.obj,\ - xh_scrol.obj,xh_scwin.obj,xh_sizer.obj,xh_slidr.obj,xh_spin.obj,\ - xh_split.obj,xh_statbar.obj,xh_stbmp.obj,xh_stbox.obj,xh_stlin.obj,\ - xh_sttxt.obj,xh_text.obj,xh_tglbtn.obj,xh_toolb.obj,xh_tree.obj,\ - xh_unkwn.obj,xh_wizrd.obj,xmlres.obj,xmlrsall.obj,xh_listbk.obj,\ - xh_choicbk.obj,xh_dirpicker.obj,xh_hyperlink.obj,xh_filepicker.obj,\ - xh_fontpicker.obj,xh_clrpicker.obj,xh_odcombo.obj,xh_mdi.obj,\ - xh_grid.obj,xh_datectrl.obj,xh_treebk.obj,xh_bmpcbox.obj,\ - xh_animatctrl.obj,xh_htmllbox.obj,xh_collpane.obj,xh_srchctrl.obj,\ - xh_propdlg.obj,xh_comboctrl.obj,xmladv.obj,xh_editlbox.obj,\ - xh_filectrl.obj,xh_cmdlinkbn.obj,xh_toolbk.obj,xh_bannerwindow.obj,\ - xh_timectrl.obj,xmlreshandler.obj,xh_ribbon.obj - -SOURCES =xh_bmp.cpp,xh_bmpbt.cpp,xh_bttn.cpp,xh_cald.cpp,xh_chckb.cpp,\ - xh_chckl.cpp,xh_choic.cpp,xh_combo.cpp,xh_dlg.cpp,xh_frame.cpp,\ - xh_gauge.cpp,xh_gdctl.cpp,xh_html.cpp,xh_listb.cpp,xh_listc.cpp,\ - xh_menu.cpp,xh_notbk.cpp,xh_panel.cpp,xh_radbt.cpp,xh_radbx.cpp,\ - xh_scrol.cpp,xh_scwin.cpp,xh_sizer.cpp,xh_slidr.cpp,xh_spin.cpp,\ - xh_split.cpp,xh_statbar.cpp,xh_stbmp.cpp,xh_stbox.cpp,xh_stlin.cpp,\ - xh_sttxt.cpp,xh_text.cpp,xh_tglbtn.cpp,xh_toolb.cpp,xh_tree.cpp,\ - xh_unkwn.cpp,xh_wizrd.cpp,xmlres.cpp,xmlrsall.cpp,xh_listbk.cpp,\ - xh_choicbk.cpp,xh_dirpicker.cpp,xh_hyperlink.cpp,xh_filepicker.cpp,\ - xh_fontpicker.cpp,xh_clrpicker.cpp,xh_odcombo.cpp,xh_mdi.cpp,\ - xh_grid.cpp,xh_datectrl.cpp,xh_treebk.cpp,xh_bmpcbox.cpp,\ - xh_animatctrl.cpp,xh_htmllbox.cpp,xh_collpane.cpp,xh_srchctrl.cpp,\ - xh_propdlg.cpp,xh_comboctrl.cpp,xmladv.cpp,xh_editlbox.cpp,\ - xh_filectrl.cpp,xh_cmdlinkbn.cpp,xh_toolbk.cpp,xh_bannerwindow.cpp,\ - xh_timectrl.cpp,xmlreshandler.cpp,xh_ribbon.cpp - -all : $(SOURCES) - $(MMS)$(MMSQUALIFIERS) $(OBJECTS) -.ifdef __WXMOTIF__ - library [--.lib]libwx_motif.olb $(OBJECTS) -.else -.ifdef __WXGTK__ - library [--.lib]libwx_gtk.olb $(OBJECTS) -.else -.ifdef __WXGTK2__ - library [--.lib]libwx_gtk2.olb $(OBJECTS) -.else -.ifdef __WXX11__ - library [--.lib]libwx_x11_univ.olb $(OBJECTS) -.endif -.endif -.endif -.endif - -$(OBJECTS) : [--.include.wx]setup.h - -xh_bmp.obj : xh_bmp.cpp -xh_bmpbt.obj : xh_bmpbt.cpp -xh_bttn.obj : xh_bttn.cpp -xh_cald.obj : xh_cald.cpp -xh_chckb.obj : xh_chckb.cpp -xh_chckl.obj : xh_chckl.cpp -xh_choic.obj : xh_choic.cpp -xh_combo.obj : xh_combo.cpp -xh_comboctrl.obj : xh_comboctrl.cpp -xh_dlg.obj : xh_dlg.cpp -xh_frame.obj : xh_frame.cpp -xh_gauge.obj : xh_gauge.cpp -xh_gdctl.obj : xh_gdctl.cpp -xh_html.obj : xh_html.cpp -xh_listb.obj : xh_listb.cpp -xh_listc.obj : xh_listc.cpp -xh_menu.obj : xh_menu.cpp -xh_notbk.obj : xh_notbk.cpp -xh_panel.obj : xh_panel.cpp -xh_radbt.obj : xh_radbt.cpp -xh_radbx.obj : xh_radbx.cpp -xh_scrol.obj : xh_scrol.cpp -xh_scwin.obj : xh_scwin.cpp -xh_sizer.obj : xh_sizer.cpp -xh_slidr.obj : xh_slidr.cpp -xh_spin.obj : xh_spin.cpp -xh_split.obj : xh_split.cpp -xh_statbar.obj : xh_statbar.cpp -xh_stbmp.obj : xh_stbmp.cpp -xh_stbox.obj : xh_stbox.cpp -xh_stlin.obj : xh_stlin.cpp -xh_sttxt.obj : xh_sttxt.cpp -xh_text.obj : xh_text.cpp -xh_tglbtn.obj : xh_tglbtn.cpp -xh_toolb.obj : xh_toolb.cpp -xh_tree.obj : xh_tree.cpp -xh_unkwn.obj : xh_unkwn.cpp -xh_wizrd.obj : xh_wizrd.cpp -xmlres.obj : xmlres.cpp -xmlrsall.obj : xmlrsall.cpp -xh_listbk.obj : xh_listbk.cpp -xh_choicbk.obj : xh_choicbk.cpp -xh_dirpicker.obj : xh_dirpicker.cpp -xh_hyperlink.obj : xh_hyperlink.cpp -xh_filepicker.obj : xh_filepicker.cpp -xh_fontpicker.obj : xh_fontpicker.cpp -xh_clrpicker.obj : xh_clrpicker.cpp -xh_odcombo.obj : xh_odcombo.cpp -xh_mdi.obj : xh_mdi.cpp -xh_grid.obj : xh_grid.cpp -xh_datectrl.obj : xh_datectrl.cpp -xh_treebk.obj : xh_treebk.cpp -xh_bmpcbox.obj : xh_bmpcbox.cpp -xh_animatctrl.obj : xh_animatctrl.cpp -xh_htmllbox.obj : xh_htmllbox.cpp -xh_collpane.obj : xh_collpane.cpp -xh_srchctrl.obj : xh_srchctrl.cpp -xh_propdlg.obj : xh_propdlg.cpp -xmladv.obj : xmladv.cpp -xh_editlbox.obj : xh_editlbox.cpp -xh_filectrl.obj : xh_filectrl.cpp -xh_cmdlinkbn.obj : xh_cmdlinkbn.cpp -xh_toolbk.obj : xh_toolbk.cpp -xh_bannerwindow.obj : xh_bannerwindow.cpp -xh_timectrl.obj : xh_timectrl.cpp -xmlreshandler.obj : xmlreshandler.cpp -xh_ribbon.obj : xh_ribbon.cpp diff --git a/Source/3rd Party/wx/src/xrc/xh_animatctrl.cpp b/Source/3rd Party/wx/src/xrc/xh_animatctrl.cpp deleted file mode 100644 index aabcb53a7..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_animatctrl.cpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_animatctrl.cpp -// Purpose: XML resource handler for wxAnimationCtrl -// Author: Francesco Montorsi -// Created: 2006-10-15 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_ANIMATIONCTRL - -#include "wx/xrc/xh_animatctrl.h" -#include "wx/animate.h" -#include "wx/scopedptr.h" - -IMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler) - -wxAnimationCtrlXmlHandler::wxAnimationCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxAC_NO_AUTORESIZE); - XRC_ADD_STYLE(wxAC_DEFAULT_STYLE); - AddWindowStyles(); -} - -wxObject *wxAnimationCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(ctrl, wxAnimationCtrl) - - wxScopedPtr animation(GetAnimation(wxT("animation"))); - - ctrl->Create(m_parentAsWindow, - GetID(), - animation ? *animation : wxNullAnimation, - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxAC_DEFAULT_STYLE), - GetName()); - - // if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap - // which just tells wxAnimationCtrl to use the default for inactive status - ctrl->SetInactiveBitmap(GetBitmap(wxT("inactive-bitmap"))); - - SetupWindow(ctrl); - - return ctrl; -} - -bool wxAnimationCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxAnimationCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_auinotbk.cpp b/Source/3rd Party/wx/src/xrc/xh_auinotbk.cpp deleted file mode 100644 index 203578729..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_auinotbk.cpp +++ /dev/null @@ -1,118 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_auinotbk.cpp -// Purpose: XML resource handler for wxAuiNotebook -// Author: Steve Lamerton -// Created: 2009-06-12 -// Copyright: (c) 2009 Steve Lamerton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_AUI - -#include "wx/xrc/xh_auinotbk.h" -#include "wx/aui/auibook.h" - -wxIMPLEMENT_DYNAMIC_CLASS(wxAuiNotebookXmlHandler, wxXmlResourceHandler); - -wxAuiNotebookXmlHandler::wxAuiNotebookXmlHandler() - : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxAUI_NB_DEFAULT_STYLE); - XRC_ADD_STYLE(wxAUI_NB_TAB_SPLIT); - XRC_ADD_STYLE(wxAUI_NB_TAB_MOVE); - XRC_ADD_STYLE(wxAUI_NB_TAB_EXTERNAL_MOVE); - XRC_ADD_STYLE(wxAUI_NB_TAB_FIXED_WIDTH); - XRC_ADD_STYLE(wxAUI_NB_SCROLL_BUTTONS); - XRC_ADD_STYLE(wxAUI_NB_WINDOWLIST_BUTTON); - XRC_ADD_STYLE(wxAUI_NB_CLOSE_BUTTON); - XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ACTIVE_TAB); - XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ALL_TABS); - XRC_ADD_STYLE(wxAUI_NB_TOP); - XRC_ADD_STYLE(wxAUI_NB_BOTTOM); - - AddWindowStyles(); -} - -wxObject *wxAuiNotebookXmlHandler::DoCreateResource() -{ - if (m_class == wxT("notebookpage")) - { - wxXmlNode *anb = GetParamNode(wxT("object")); - - if (!anb) - anb = GetParamNode(wxT("object_ref")); - - if (anb) - { - bool old_ins = m_isInside; - m_isInside = false; - wxObject *item = CreateResFromNode(anb, m_notebook, NULL); - m_isInside = old_ins; - wxWindow *wnd = wxDynamicCast(item, wxWindow); - - if (wnd) - { - if ( HasParam(wxT("bitmap")) ) - { - m_notebook->AddPage(wnd, - GetText(wxT("label")), - GetBool(wxT("selected")), - GetBitmap(wxT("bitmap"), wxART_OTHER)); - } - else - { - m_notebook->AddPage(wnd, - GetText(wxT("label")), - GetBool(wxT("selected"))); - } - } - else - { - ReportError(anb, "notebookpage child must be a window"); - } - return wnd; - } - else - { - ReportError("notebookpage must have a window child"); - return NULL; - } - } - else - { - XRC_MAKE_INSTANCE(anb, wxAuiNotebook) - - anb->Create(m_parentAsWindow, - GetID(), - GetPosition(), - GetSize(), - GetStyle(wxT("style"))); - - SetupWindow(anb); - - wxAuiNotebook *old_par = m_notebook; - m_notebook = anb; - bool old_ins = m_isInside; - m_isInside = true; - CreateChildren(m_notebook, true/*only this handler*/); - m_isInside = old_ins; - m_notebook = old_par; - - return anb; - } -} - -bool wxAuiNotebookXmlHandler::CanHandle(wxXmlNode *node) -{ - return ((!m_isInside && IsOfClass(node, wxT("wxAuiNotebook"))) || - (m_isInside && IsOfClass(node, wxT("notebookpage")))); -} - -#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_bannerwindow.cpp b/Source/3rd Party/wx/src/xrc/xh_bannerwindow.cpp deleted file mode 100644 index acba8dd83..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_bannerwindow.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: srx/xrc/xh_bannerwindow.h -// Purpose: Implementation of wxBannerWindow XRC handler. -// Author: Vadim Zeitlin -// Created: 2011-08-16 -// Copyright: (c) 2011 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_BANNERWINDOW - -#include "wx/xrc/xh_bannerwindow.h" -#include "wx/bannerwindow.h" - -wxIMPLEMENT_DYNAMIC_CLASS(wxBannerWindowXmlHandler, wxXmlResourceHandler) - -wxBannerWindowXmlHandler::wxBannerWindowXmlHandler() - : wxXmlResourceHandler() -{ - AddWindowStyles(); -} - -wxObject *wxBannerWindowXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(banner, wxBannerWindow) - - banner->Create(m_parentAsWindow, - GetID(), - GetDirection(wxS("direction")), - GetPosition(), - GetSize(), - GetStyle(wxS("style")), - GetName()); - - SetupWindow(banner); - - const wxColour colStart = GetColour(wxS("gradient-start")); - const wxColour colEnd = GetColour(wxS("gradient-end")); - if ( colStart.IsOk() || colEnd.IsOk() ) - { - if ( !colStart.IsOk() || !colEnd.IsOk() ) - { - ReportError - ( - "Both start and end gradient colours must be " - "specified if either one is." - ); - } - else - { - banner->SetGradient(colStart, colEnd); - } - } - - wxBitmap bitmap = GetBitmap(); - if ( bitmap.IsOk() ) - { - if ( colStart.IsOk() || colEnd.IsOk() ) - { - ReportError - ( - "Gradient colours are ignored by wxBannerWindow " - "if the background bitmap is specified." - ); - } - - banner->SetBitmap(bitmap); - } - - banner->SetText(GetText(wxS("title")), GetText(wxS("message"))); - - return banner; -} - -bool wxBannerWindowXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxS("wxBannerWindow")); -} - -#endif // wxUSE_XRC && wxUSE_BANNERWINDOW diff --git a/Source/3rd Party/wx/src/xrc/xh_bmp.cpp b/Source/3rd Party/wx/src/xrc/xh_bmp.cpp deleted file mode 100644 index 788f50f22..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_bmp.cpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_bmp.cpp -// Purpose: XRC resource for wxBitmap and wxIcon -// Author: Vaclav Slavik -// Created: 2000/09/09 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC - -#include "wx/xrc/xh_bmp.h" - -#ifndef WX_PRECOMP - #include "wx/bitmap.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler) - -wxBitmapXmlHandler::wxBitmapXmlHandler() - :wxXmlResourceHandler() -{ -} - -wxObject *wxBitmapXmlHandler::DoCreateResource() -{ - return new wxBitmap(GetBitmap(m_node)); -} - -bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxBitmap")); -} - -IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler) - -wxIconXmlHandler::wxIconXmlHandler() -: wxXmlResourceHandler() -{ -} - -wxObject *wxIconXmlHandler::DoCreateResource() -{ - return new wxIcon(GetIcon(m_node)); -} - -bool wxIconXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxIcon")); -} - -#endif // wxUSE_XRC diff --git a/Source/3rd Party/wx/src/xrc/xh_bmpbt.cpp b/Source/3rd Party/wx/src/xrc/xh_bmpbt.cpp deleted file mode 100644 index d5ae4ec9d..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_bmpbt.cpp +++ /dev/null @@ -1,71 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_bmpbt.cpp -// Purpose: XRC resource for bitmap buttons -// Author: Brian Gavin -// Created: 2000/09/09 -// Copyright: (c) 2000 Brian Gavin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_BMPBUTTON - -#include "wx/xrc/xh_bmpbt.h" - -#ifndef WX_PRECOMP - #include "wx/bmpbuttn.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler) - -wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxBU_AUTODRAW); - XRC_ADD_STYLE(wxBU_LEFT); - XRC_ADD_STYLE(wxBU_RIGHT); - XRC_ADD_STYLE(wxBU_TOP); - XRC_ADD_STYLE(wxBU_BOTTOM); - XRC_ADD_STYLE(wxBU_EXACTFIT); - AddWindowStyles(); -} - -wxObject *wxBitmapButtonXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(button, wxBitmapButton) - - button->Create(m_parentAsWindow, - GetID(), - GetBitmap(wxT("bitmap"), wxART_BUTTON), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxBU_AUTODRAW), - wxDefaultValidator, - GetName()); - if (GetBool(wxT("default"), 0)) - button->SetDefault(); - SetupWindow(button); - - if (GetParamNode(wxT("selected"))) - button->SetBitmapSelected(GetBitmap(wxT("selected"))); - if (GetParamNode(wxT("focus"))) - button->SetBitmapFocus(GetBitmap(wxT("focus"))); - if (GetParamNode(wxT("disabled"))) - button->SetBitmapDisabled(GetBitmap(wxT("disabled"))); - if (GetParamNode(wxT("hover"))) - button->SetBitmapHover(GetBitmap(wxT("hover"))); - - return button; -} - -bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxBitmapButton")); -} - -#endif // wxUSE_XRC && wxUSE_BMPBUTTON diff --git a/Source/3rd Party/wx/src/xrc/xh_bmpcbox.cpp b/Source/3rd Party/wx/src/xrc/xh_bmpcbox.cpp deleted file mode 100644 index 533f52fd8..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_bmpcbox.cpp +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_bmpcbox.cpp -// Purpose: XRC resource for wxBitmapComboBox -// Author: Jaakko Salli -// Created: Sep-10-2006 -// Copyright: (c) 2006 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_BITMAPCOMBOBOX - -#include "wx/xrc/xh_bmpcbox.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" -#endif - -#include "wx/bmpcbox.h" - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler) - -wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler() - :wxXmlResourceHandler() - ,m_combobox(NULL) - ,m_isInside(false) -{ - XRC_ADD_STYLE(wxCB_SORT); - XRC_ADD_STYLE(wxCB_READONLY); - AddWindowStyles(); -} - -wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource() -{ - if (m_class == wxT("ownerdrawnitem")) - { - if ( !m_combobox ) - { - ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox"); - return NULL; - } - - m_combobox->Append(GetText(wxT("text")), - GetBitmap(wxT("bitmap"))); - - return m_combobox; - } - else /*if( m_class == wxT("wxBitmapComboBox"))*/ - { - // find the selection - long selection = GetLong( wxT("selection"), -1 ); - - XRC_MAKE_INSTANCE(control, wxBitmapComboBox) - - control->Create(m_parentAsWindow, - GetID(), - GetText(wxT("value")), - GetPosition(), GetSize(), - 0, - NULL, - GetStyle(), - wxDefaultValidator, - GetName()); - - m_isInside = true; - m_combobox = control; - - wxXmlNode *children_node = GetParamNode(wxT("object")); - - wxXmlNode *n = children_node; - - while (n) - { - if ((n->GetType() == wxXML_ELEMENT_NODE) && - (n->GetName() == wxT("object"))) - { - CreateResFromNode(n, control, NULL); - } - n = n->GetNext(); - } - - m_isInside = false; - m_combobox = NULL; - - if (selection != -1) - control->SetSelection(selection); - - SetupWindow(control); - - return control; - } -} - -bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) || - (m_isInside && IsOfClass(node, wxT("ownerdrawnitem")))); -} - -#endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_bttn.cpp b/Source/3rd Party/wx/src/xrc/xh_bttn.cpp deleted file mode 100644 index fea736044..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_bttn.cpp +++ /dev/null @@ -1,69 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_bttn.cpp -// Purpose: XRC resource for buttons -// Author: Vaclav Slavik -// Created: 2000/03/05 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_BUTTON - -#include "wx/xrc/xh_bttn.h" - -#ifndef WX_PRECOMP - #include "wx/button.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler) - -wxButtonXmlHandler::wxButtonXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxBU_LEFT); - XRC_ADD_STYLE(wxBU_RIGHT); - XRC_ADD_STYLE(wxBU_TOP); - XRC_ADD_STYLE(wxBU_BOTTOM); - XRC_ADD_STYLE(wxBU_EXACTFIT); - AddWindowStyles(); -} - -wxObject *wxButtonXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(button, wxButton) - - button->Create(m_parentAsWindow, - GetID(), - GetText(wxT("label")), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - if (GetBool(wxT("default"), 0)) - button->SetDefault(); - - if ( GetParamNode("bitmap") ) - { - button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON), - GetDirection("bitmapposition")); - } - - SetupWindow(button); - - return button; -} - -bool wxButtonXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxButton")); -} - -#endif // wxUSE_XRC && wxUSE_BUTTON diff --git a/Source/3rd Party/wx/src/xrc/xh_cald.cpp b/Source/3rd Party/wx/src/xrc/xh_cald.cpp deleted file mode 100644 index 28c60ecad..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_cald.cpp +++ /dev/null @@ -1,66 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_cald.cpp -// Purpose: XRC resource for wxCalendarCtrl -// Author: Brian Gavin -// Created: 2000/09/09 -// Copyright: (c) 2000 Brian Gavin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_CALENDARCTRL - -#include "wx/xrc/xh_cald.h" - -#ifndef WX_PRECOMP - #include "wx/event.h" -#endif //WX_PRECOMP - -#include "wx/calctrl.h" - -IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler) - -wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST); - XRC_ADD_STYLE(wxCAL_MONDAY_FIRST); - XRC_ADD_STYLE(wxCAL_SHOW_HOLIDAYS); - XRC_ADD_STYLE(wxCAL_NO_YEAR_CHANGE); - XRC_ADD_STYLE(wxCAL_NO_MONTH_CHANGE); - XRC_ADD_STYLE(wxCAL_SEQUENTIAL_MONTH_SELECTION); - XRC_ADD_STYLE(wxCAL_SHOW_SURROUNDING_WEEKS); - - AddWindowStyles(); -} - - -wxObject *wxCalendarCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl); - - calendar->Create(m_parentAsWindow, - GetID(), - wxDefaultDateTime, - /*TODO: take it from resource*/ - GetPosition(), GetSize(), - GetStyle(), - GetName()); - - SetupWindow(calendar); - - return calendar; -} - -bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxCalendarCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_CALENDARCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_chckb.cpp b/Source/3rd Party/wx/src/xrc/xh_chckb.cpp deleted file mode 100644 index 9499c652f..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_chckb.cpp +++ /dev/null @@ -1,60 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_chckb.cpp -// Purpose: XRC resource for wxCheckBox -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_CHECKBOX - -#include "wx/xrc/xh_chckb.h" - -#ifndef WX_PRECOMP - #include "wx/checkbox.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler) - -wxCheckBoxXmlHandler::wxCheckBoxXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxCHK_2STATE); - XRC_ADD_STYLE(wxCHK_3STATE); - XRC_ADD_STYLE(wxCHK_ALLOW_3RD_STATE_FOR_USER); - XRC_ADD_STYLE(wxALIGN_RIGHT); - AddWindowStyles(); -} - -wxObject *wxCheckBoxXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(control, wxCheckBox) - - control->Create(m_parentAsWindow, - GetID(), - GetText(wxT("label")), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - control->SetValue(GetBool( wxT("checked"))); - SetupWindow(control); - - return control; -} - -bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxCheckBox")); -} - -#endif // wxUSE_XRC && wxUSE_CHECKBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_chckl.cpp b/Source/3rd Party/wx/src/xrc/xh_chckl.cpp deleted file mode 100644 index 843571597..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_chckl.cpp +++ /dev/null @@ -1,111 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_chckl.cpp -// Purpose: XRC resource for wxCheckListBox -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_CHECKLISTBOX - -#include "wx/xrc/xh_chckl.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/checklst.h" -#endif - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler) - -wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler() -: wxXmlResourceHandler(), m_insideBox(false) -{ - // wxListBox styles: - XRC_ADD_STYLE(wxLB_SINGLE); - XRC_ADD_STYLE(wxLB_MULTIPLE); - XRC_ADD_STYLE(wxLB_EXTENDED); - XRC_ADD_STYLE(wxLB_HSCROLL); - XRC_ADD_STYLE(wxLB_ALWAYS_SB); - XRC_ADD_STYLE(wxLB_NEEDED_SB); - XRC_ADD_STYLE(wxLB_SORT); - - AddWindowStyles(); -} - -wxObject *wxCheckListBoxXmlHandler::DoCreateResource() -{ - if (m_class == wxT("wxCheckListBox")) - { - // need to build the list of strings from children - m_insideBox = true; - CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); - - XRC_MAKE_INSTANCE(control, wxCheckListBox) - - control->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - strList, - GetStyle(), - wxDefaultValidator, - GetName()); - - // step through children myself (again.) - wxXmlNode *n = GetParamNode(wxT("content")); - if (n) - n = n->GetChildren(); - int i = 0; - while (n) - { - if (n->GetType() != wxXML_ELEMENT_NODE || - n->GetName() != wxT("item")) - { n = n->GetNext(); continue; } - - // checking boolean is a bit ugly here (see GetBool() ) - wxString v = n->GetAttribute(wxT("checked"), wxEmptyString); - v.MakeLower(); - if (v == wxT("1")) - control->Check( i, true ); - - i++; - n = n->GetNext(); - } - - SetupWindow(control); - - strList.Clear(); // dump the strings - - return control; - } - else - { - // on the inside now. - // handle Label - - // add to the list - wxString str = GetNodeContent(m_node); - if (m_resource->GetFlags() & wxXRC_USE_LOCALE) - str = wxGetTranslation(str, m_resource->GetDomain()); - strList.Add(str); - return NULL; - } -} - -bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxCheckListBox")) || - (m_insideBox && node->GetName() == wxT("item"))); -} - -#endif // wxUSE_XRC && wxUSE_CHECKLISTBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_choic.cpp b/Source/3rd Party/wx/src/xrc/xh_choic.cpp deleted file mode 100644 index fb9b7f224..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_choic.cpp +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_choic.cpp -// Purpose: XRC resource for wxChoice -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_CHOICE - -#include "wx/xrc/xh_choic.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/choice.h" -#endif - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler) - -wxChoiceXmlHandler::wxChoiceXmlHandler() -: wxXmlResourceHandler() , m_insideBox(false) -{ - XRC_ADD_STYLE(wxCB_SORT); - AddWindowStyles(); -} - -wxObject *wxChoiceXmlHandler::DoCreateResource() -{ - if( m_class == wxT("wxChoice")) - { - // find the selection - long selection = GetLong(wxT("selection"), -1); - - // need to build the list of strings from children - m_insideBox = true; - CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); - - XRC_MAKE_INSTANCE(control, wxChoice) - - control->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - strList, - GetStyle(), - wxDefaultValidator, - GetName()); - - if (selection != -1) - control->SetSelection(selection); - - SetupWindow(control); - - strList.Clear(); // dump the strings - - return control; - } - else - { - // on the inside now. - // handle Label - - // add to the list - wxString str = GetNodeContent(m_node); - if (m_resource->GetFlags() & wxXRC_USE_LOCALE) - str = wxGetTranslation(str, m_resource->GetDomain()); - strList.Add(str); - - return NULL; - } -} - -bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxChoice")) || - (m_insideBox && node->GetName() == wxT("item"))); -} - -#endif // wxUSE_XRC && wxUSE_CHOICE diff --git a/Source/3rd Party/wx/src/xrc/xh_choicbk.cpp b/Source/3rd Party/wx/src/xrc/xh_choicbk.cpp deleted file mode 100644 index e70bd60ae..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_choicbk.cpp +++ /dev/null @@ -1,143 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_choicbk.cpp -// Purpose: XRC resource for wxChoicebook -// Author: Vaclav Slavik -// Created: 2000/03/21 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_CHOICEBOOK - -#include "wx/xrc/xh_choicbk.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/sizer.h" -#endif - -#include "wx/choicebk.h" -#include "wx/imaglist.h" - -IMPLEMENT_DYNAMIC_CLASS(wxChoicebookXmlHandler, wxXmlResourceHandler) - -wxChoicebookXmlHandler::wxChoicebookXmlHandler() - :wxXmlResourceHandler(), - m_isInside(false), - m_choicebook(NULL) -{ - XRC_ADD_STYLE(wxBK_DEFAULT); - XRC_ADD_STYLE(wxBK_LEFT); - XRC_ADD_STYLE(wxBK_RIGHT); - XRC_ADD_STYLE(wxBK_TOP); - XRC_ADD_STYLE(wxBK_BOTTOM); - - XRC_ADD_STYLE(wxCHB_DEFAULT); - XRC_ADD_STYLE(wxCHB_LEFT); - XRC_ADD_STYLE(wxCHB_RIGHT); - XRC_ADD_STYLE(wxCHB_TOP); - XRC_ADD_STYLE(wxCHB_BOTTOM); - - AddWindowStyles(); -} - -wxObject *wxChoicebookXmlHandler::DoCreateResource() -{ - if (m_class == wxT("choicebookpage")) - { - wxXmlNode *n = GetParamNode(wxT("object")); - - if ( !n ) - n = GetParamNode(wxT("object_ref")); - - if (n) - { - bool old_ins = m_isInside; - m_isInside = false; - wxObject *item = CreateResFromNode(n, m_choicebook, NULL); - m_isInside = old_ins; - wxWindow *wnd = wxDynamicCast(item, wxWindow); - - if (wnd) - { - m_choicebook->AddPage(wnd, GetText(wxT("label")), - GetBool(wxT("selected"))); - if ( HasParam(wxT("bitmap")) ) - { - wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); - wxImageList *imgList = m_choicebook->GetImageList(); - if ( imgList == NULL ) - { - imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); - m_choicebook->AssignImageList( imgList ); - } - int imgIndex = imgList->Add(bmp); - m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex ); - } - else if ( HasParam(wxT("image")) ) - { - if ( m_choicebook->GetImageList() ) - { - m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, - GetLong(wxT("image")) ); - } - else // image without image list? - { - ReportError(n, "image can only be used in conjunction " - "with imagelist"); - } - } - } - else - { - ReportError(n, "choicebookpage child must be a window"); - } - return wnd; - } - else - { - ReportError("choicebookpage must have a window child"); - return NULL; - } - } - - else - { - XRC_MAKE_INSTANCE(nb, wxChoicebook) - - nb->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - GetStyle(wxT("style")), - GetName()); - - wxImageList *imagelist = GetImageList(); - if ( imagelist ) - nb->AssignImageList(imagelist); - - wxChoicebook *old_par = m_choicebook; - m_choicebook = nb; - bool old_ins = m_isInside; - m_isInside = true; - CreateChildren(m_choicebook, true/*only this handler*/); - m_isInside = old_ins; - m_choicebook = old_par; - - return nb; - } -} - -bool wxChoicebookXmlHandler::CanHandle(wxXmlNode *node) -{ - return ((!m_isInside && IsOfClass(node, wxT("wxChoicebook"))) || - (m_isInside && IsOfClass(node, wxT("choicebookpage")))); -} - -#endif // wxUSE_XRC && wxUSE_CHOICEBOOK diff --git a/Source/3rd Party/wx/src/xrc/xh_clrpicker.cpp b/Source/3rd Party/wx/src/xrc/xh_clrpicker.cpp deleted file mode 100644 index 690275e67..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_clrpicker.cpp +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_clrpicker.cpp -// Purpose: XML resource handler for wxColourPickerCtrl -// Author: Francesco Montorsi -// Created: 2006-04-17 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_COLOURPICKERCTRL - -#include "wx/xrc/xh_clrpicker.h" -#include "wx/clrpicker.h" - -IMPLEMENT_DYNAMIC_CLASS(wxColourPickerCtrlXmlHandler, wxXmlResourceHandler) - -wxColourPickerCtrlXmlHandler::wxColourPickerCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxCLRP_USE_TEXTCTRL); - XRC_ADD_STYLE(wxCLRP_SHOW_LABEL); - XRC_ADD_STYLE(wxCLRP_DEFAULT_STYLE); - AddWindowStyles(); -} - -wxObject *wxColourPickerCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(picker, wxColourPickerCtrl) - - picker->Create(m_parentAsWindow, - GetID(), - GetColour(wxT("value"), *wxBLACK), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxCLRP_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - SetupWindow(picker); - - return picker; -} - -bool wxColourPickerCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxColourPickerCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_COLOURPICKERCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_cmdlinkbn.cpp b/Source/3rd Party/wx/src/xrc/xh_cmdlinkbn.cpp deleted file mode 100644 index 396827a01..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_cmdlinkbn.cpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_cmdlinkbn.cpp -// Purpose: XRC resource for command link buttons -// Author: Kinaou Herve -// Created: 2010/10/20 -// Copyright: -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_COMMANDLINKBUTTON - -#include "wx/xrc/xh_cmdlinkbn.h" - -#include "wx/commandlinkbutton.h" - -IMPLEMENT_DYNAMIC_CLASS(wxCommandLinkButtonXmlHandler, wxXmlResourceHandler) - -wxCommandLinkButtonXmlHandler::wxCommandLinkButtonXmlHandler() - : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxBU_LEFT); - XRC_ADD_STYLE(wxBU_RIGHT); - XRC_ADD_STYLE(wxBU_TOP); - XRC_ADD_STYLE(wxBU_BOTTOM); - XRC_ADD_STYLE(wxBU_EXACTFIT); - AddWindowStyles(); -} - -wxObject *wxCommandLinkButtonXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(button, wxCommandLinkButton) - - button->Create(m_parentAsWindow, - GetID(), - GetText(wxS("label")), - GetText(wxS("note")), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - SetupWindow(button); - - return button; -} - -bool wxCommandLinkButtonXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxS("wxCommandLinkButton")); -} - -#endif // wxUSE_XRC && wxUSE_COMMANDLINKBUTTON diff --git a/Source/3rd Party/wx/src/xrc/xh_collpane.cpp b/Source/3rd Party/wx/src/xrc/xh_collpane.cpp deleted file mode 100644 index ae4857615..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_collpane.cpp +++ /dev/null @@ -1,100 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_collpane.cpp -// Purpose: XML resource handler for wxCollapsiblePane -// Author: Francesco Montorsi -// Created: 2006-10-27 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_COLLPANE - -#ifndef WX_PRECOMP - #include "wx/log.h" -#endif - -#include "wx/collpane.h" -#include "wx/xrc/xh_collpane.h" - -IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneXmlHandler, wxXmlResourceHandler) - -wxCollapsiblePaneXmlHandler::wxCollapsiblePaneXmlHandler() -: wxXmlResourceHandler(), m_isInside(false) -{ - XRC_ADD_STYLE(wxCP_NO_TLW_RESIZE); - XRC_ADD_STYLE(wxCP_DEFAULT_STYLE); - AddWindowStyles(); -} - -wxObject *wxCollapsiblePaneXmlHandler::DoCreateResource() -{ - if (m_class == wxT("panewindow")) // read the XRC for the pane window - { - wxXmlNode *n = GetParamNode(wxT("object")); - - if ( !n ) - n = GetParamNode(wxT("object_ref")); - - if (n) - { - bool old_ins = m_isInside; - m_isInside = false; - wxObject *item = CreateResFromNode(n, m_collpane->GetPane(), NULL); - m_isInside = old_ins; - - return item; - } - else - { - ReportError("no control within panewindow"); - return NULL; - } - } - else - { - XRC_MAKE_INSTANCE(ctrl, wxCollapsiblePane) - - wxString label = GetParamValue(wxT("label")); - if (label.empty()) - { - ReportParamError("label", "label cannot be empty"); - return NULL; - } - - ctrl->Create(m_parentAsWindow, - GetID(), - label, - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxCP_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - ctrl->Collapse(GetBool(wxT("collapsed"))); - SetupWindow(ctrl); - - wxCollapsiblePane *old_par = m_collpane; - m_collpane = ctrl; - bool old_ins = m_isInside; - m_isInside = true; - CreateChildren(m_collpane, true/*only this handler*/); - m_isInside = old_ins; - m_collpane = old_par; - - return ctrl; - } -} - -bool wxCollapsiblePaneXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxCollapsiblePane")) || - (m_isInside && IsOfClass(node, wxT("panewindow"))); -} - -#endif // wxUSE_XRC && wxUSE_COLLPANE diff --git a/Source/3rd Party/wx/src/xrc/xh_combo.cpp b/Source/3rd Party/wx/src/xrc/xh_combo.cpp deleted file mode 100644 index 8691c4161..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_combo.cpp +++ /dev/null @@ -1,95 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_combo.cpp -// Purpose: XRC resource for wxComboBox -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_COMBOBOX - -#include "wx/xrc/xh_combo.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/combobox.h" - #include "wx/textctrl.h" // for wxTE_PROCESS_ENTER -#endif - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler) - -wxComboBoxXmlHandler::wxComboBoxXmlHandler() - :wxXmlResourceHandler() - ,m_insideBox(false) -{ - XRC_ADD_STYLE(wxCB_SIMPLE); - XRC_ADD_STYLE(wxCB_SORT); - XRC_ADD_STYLE(wxCB_READONLY); - XRC_ADD_STYLE(wxCB_DROPDOWN); - XRC_ADD_STYLE(wxTE_PROCESS_ENTER); - AddWindowStyles(); -} - -wxObject *wxComboBoxXmlHandler::DoCreateResource() -{ - if( m_class == wxT("wxComboBox")) - { - // find the selection - long selection = GetLong( wxT("selection"), -1 ); - - // need to build the list of strings from children - m_insideBox = true; - CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); - - XRC_MAKE_INSTANCE(control, wxComboBox) - - control->Create(m_parentAsWindow, - GetID(), - GetText(wxT("value")), - GetPosition(), GetSize(), - strList, - GetStyle(), - wxDefaultValidator, - GetName()); - - if (selection != -1) - control->SetSelection(selection); - - SetupWindow(control); - - strList.Clear(); // dump the strings - - return control; - } - else - { - // on the inside now. - // handle Label - - // add to the list - wxString str = GetNodeContent(m_node); - if (m_resource->GetFlags() & wxXRC_USE_LOCALE) - str = wxGetTranslation(str, m_resource->GetDomain()); - strList.Add(str); - - return NULL; - } -} - -bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxComboBox")) || - (m_insideBox && node->GetName() == wxT("item"))); -} - -#endif // wxUSE_XRC && wxUSE_COMBOBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_comboctrl.cpp b/Source/3rd Party/wx/src/xrc/xh_comboctrl.cpp deleted file mode 100644 index 9becbbbe3..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_comboctrl.cpp +++ /dev/null @@ -1,68 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_comboctrl.cpp -// Purpose: XRC resource for wxComboCtrl -// Author: Jaakko Salli -// Created: 2009/01/25 -// Copyright: (c) 2009 Jaakko Salli -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_COMBOCTRL - -#include "wx/xrc/xh_comboctrl.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/textctrl.h" // for wxTE_PROCESS_ENTER -#endif - -#include "wx/combo.h" - - -IMPLEMENT_DYNAMIC_CLASS(wxComboCtrlXmlHandler, wxXmlResourceHandler) - -wxComboCtrlXmlHandler::wxComboCtrlXmlHandler() - : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxCB_SORT); - XRC_ADD_STYLE(wxCB_READONLY); - XRC_ADD_STYLE(wxTE_PROCESS_ENTER); - XRC_ADD_STYLE(wxCC_SPECIAL_DCLICK); - XRC_ADD_STYLE(wxCC_STD_BUTTON); - AddWindowStyles(); -} - -wxObject *wxComboCtrlXmlHandler::DoCreateResource() -{ - if( m_class == wxT("wxComboCtrl")) - { - XRC_MAKE_INSTANCE(control, wxComboCtrl) - - control->Create(m_parentAsWindow, - GetID(), - GetText(wxT("value")), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - SetupWindow(control); - - return control; - } - return NULL; -} - -bool wxComboCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxComboCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_COMBOBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_datectrl.cpp b/Source/3rd Party/wx/src/xrc/xh_datectrl.cpp deleted file mode 100644 index 634bb9e84..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_datectrl.cpp +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_datectrl.cpp -// Purpose: XML resource handler for wxDatePickerCtrl -// Author: Vaclav Slavik -// Created: 2005-02-07 -// Copyright: (c) 2005 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_DATEPICKCTRL - -#include "wx/xrc/xh_datectrl.h" -#include "wx/datectrl.h" - -IMPLEMENT_DYNAMIC_CLASS(wxDateCtrlXmlHandler, wxXmlResourceHandler) - -wxDateCtrlXmlHandler::wxDateCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxDP_DEFAULT); - XRC_ADD_STYLE(wxDP_SPIN); - XRC_ADD_STYLE(wxDP_DROPDOWN); - XRC_ADD_STYLE(wxDP_ALLOWNONE); - XRC_ADD_STYLE(wxDP_SHOWCENTURY); - AddWindowStyles(); -} - -wxObject *wxDateCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(picker, wxDatePickerCtrl) - - picker->Create(m_parentAsWindow, - GetID(), - wxDefaultDateTime, - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxDP_DEFAULT | wxDP_SHOWCENTURY), - wxDefaultValidator, - GetName()); - - SetupWindow(picker); - - return picker; -} - -bool wxDateCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxDatePickerCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_DATEPICKCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_dirpicker.cpp b/Source/3rd Party/wx/src/xrc/xh_dirpicker.cpp deleted file mode 100644 index 8fab3a7fc..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_dirpicker.cpp +++ /dev/null @@ -1,57 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_dirpicker.cpp -// Purpose: XML resource handler for wxDirPickerCtrl -// Author: Francesco Montorsi -// Created: 2006-04-17 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_DIRPICKERCTRL - -#include "wx/xrc/xh_dirpicker.h" -#include "wx/filepicker.h" - -IMPLEMENT_DYNAMIC_CLASS(wxDirPickerCtrlXmlHandler, wxXmlResourceHandler) - -wxDirPickerCtrlXmlHandler::wxDirPickerCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxDIRP_USE_TEXTCTRL); - XRC_ADD_STYLE(wxDIRP_DIR_MUST_EXIST); - XRC_ADD_STYLE(wxDIRP_CHANGE_DIR); - XRC_ADD_STYLE(wxDIRP_SMALL); - XRC_ADD_STYLE(wxDIRP_DEFAULT_STYLE); - AddWindowStyles(); -} - -wxObject *wxDirPickerCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(picker, wxDirPickerCtrl) - - picker->Create(m_parentAsWindow, - GetID(), - GetParamValue(wxT("value")), - GetText(wxT("message")), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxDIRP_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - SetupWindow(picker); - - return picker; -} - -bool wxDirPickerCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxDirPickerCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_DIRPICKERCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_dlg.cpp b/Source/3rd Party/wx/src/xrc/xh_dlg.cpp deleted file mode 100644 index 3edffae5e..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_dlg.cpp +++ /dev/null @@ -1,92 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_dlg.cpp -// Purpose: XRC resource for dialogs -// Author: Vaclav Slavik -// Created: 2000/03/05 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC - -#include "wx/xrc/xh_dlg.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/frame.h" - #include "wx/dialog.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxDialogXmlHandler, wxXmlResourceHandler) - -wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxSTAY_ON_TOP); - XRC_ADD_STYLE(wxCAPTION); - XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE); - XRC_ADD_STYLE(wxSYSTEM_MENU); - XRC_ADD_STYLE(wxRESIZE_BORDER); - XRC_ADD_STYLE(wxCLOSE_BOX); - XRC_ADD_STYLE(wxDIALOG_NO_PARENT); - - XRC_ADD_STYLE(wxTAB_TRAVERSAL); - XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); - XRC_ADD_STYLE(wxDIALOG_EX_METAL); - XRC_ADD_STYLE(wxMAXIMIZE_BOX); - XRC_ADD_STYLE(wxMINIMIZE_BOX); - XRC_ADD_STYLE(wxFRAME_SHAPED); - XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP); - -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxDIALOG_MODAL); - XRC_ADD_STYLE(wxTHICK_FRAME); - XRC_ADD_STYLE(wxRESIZE_BOX); - XRC_ADD_STYLE(wxDIALOG_MODELESS); - XRC_ADD_STYLE(wxNO_3D); -#endif // WXWIN_COMPATIBILITY_2_6 - - AddWindowStyles(); -} - -wxObject *wxDialogXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(dlg, wxDialog); - - dlg->Create(m_parentAsWindow, - GetID(), - GetText(wxT("title")), - wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE), - GetName()); - - if (HasParam(wxT("size"))) - dlg->SetClientSize(GetSize(wxT("size"), dlg)); - if (HasParam(wxT("pos"))) - dlg->Move(GetPosition()); - if (HasParam(wxT("icon"))) - dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); - - SetupWindow(dlg); - - CreateChildren(dlg); - - if (GetBool(wxT("centered"), false)) - dlg->Centre(); - - return dlg; -} - -bool wxDialogXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxDialog")); -} - -#endif // wxUSE_XRC diff --git a/Source/3rd Party/wx/src/xrc/xh_editlbox.cpp b/Source/3rd Party/wx/src/xrc/xh_editlbox.cpp deleted file mode 100644 index 87031b005..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_editlbox.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_editlbox.cpp -// Purpose: implementation of wxEditableListBox XRC handler -// Author: Vadim Zeitlin -// Created: 2009-06-04 -// Copyright: (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// for compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_EDITABLELISTBOX - -#ifndef WX_PRECOMP - #include "wx/intl.h" -#endif // WX_PRECOMP - -#include "wx/editlbox.h" -#include "wx/xrc/xh_editlbox.h" - -#include "wx/xml/xml.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -namespace -{ - -const char * const EDITLBOX_CLASS_NAME = "wxEditableListBox"; -const char * const EDITLBOX_ITEM_NAME = "item"; - -} // anonymous namespace - -// ============================================================================ -// implementation -// ============================================================================ - -IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler, wxXmlResourceHandler) - -wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler() -{ - m_insideBox = false; - - XRC_ADD_STYLE(wxEL_ALLOW_NEW); - XRC_ADD_STYLE(wxEL_ALLOW_EDIT); - XRC_ADD_STYLE(wxEL_ALLOW_DELETE); - XRC_ADD_STYLE(wxEL_NO_REORDER); - - AddWindowStyles(); -} - -wxObject *wxEditableListBoxXmlHandler::DoCreateResource() -{ - if ( m_class == EDITLBOX_CLASS_NAME ) - { - // create the control itself - XRC_MAKE_INSTANCE(control, wxEditableListBox) - - control->Create - ( - m_parentAsWindow, - GetID(), - GetText("label"), - GetPosition(), - GetSize(), - GetStyle(), - GetName() - ); - - SetupWindow(control); - - // if any items are given, add them to the control - wxXmlNode * const contents = GetParamNode("content"); - if ( contents ) - { - m_insideBox = true; - CreateChildrenPrivately(NULL, contents); - m_insideBox = false; - - control->SetStrings(m_items); - m_items.clear(); - } - - return control; - } - else if ( m_insideBox && m_node->GetName() == EDITLBOX_ITEM_NAME ) - { - wxString str = GetNodeContent(m_node); - if ( m_resource->GetFlags() & wxXRC_USE_LOCALE ) - str = wxGetTranslation(str, m_resource->GetDomain()); - m_items.push_back(str); - - return NULL; - } - else - { - ReportError("Unexpected node inside wxEditableListBox"); - return NULL; - } -} - -bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, EDITLBOX_CLASS_NAME) || - (m_insideBox && node->GetName() == EDITLBOX_ITEM_NAME); -} - - -#endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_filectrl.cpp b/Source/3rd Party/wx/src/xrc/xh_filectrl.cpp deleted file mode 100644 index da4fc940f..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_filectrl.cpp +++ /dev/null @@ -1,58 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_filectrl.cpp -// Purpose: XML resource handler for wxFileCtrl -// Author: Kinaou Hervé -// Created: 2009-05-11 -// Copyright: (c) 2009 wxWidgets development team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_FILECTRL - -#include "wx/xrc/xh_filectrl.h" -#include "wx/filectrl.h" - -IMPLEMENT_DYNAMIC_CLASS(wxFileCtrlXmlHandler, wxXmlResourceHandler) - -wxFileCtrlXmlHandler::wxFileCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxFC_DEFAULT_STYLE); - XRC_ADD_STYLE(wxFC_OPEN); - XRC_ADD_STYLE(wxFC_SAVE); - XRC_ADD_STYLE(wxFC_MULTIPLE); - XRC_ADD_STYLE(wxFC_NOSHOWHIDDEN); - - AddWindowStyles(); -} - -wxObject *wxFileCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(filectrl, wxFileCtrl) - - filectrl->Create(m_parentAsWindow, - GetID(), - GetText(wxT("defaultdirectory")), - GetText(wxT("defaultfilename")), - GetParamValue(wxT("wildcard")), - GetStyle(wxT("style"), wxFC_DEFAULT_STYLE), - GetPosition(), - GetSize(), - GetName()); - - SetupWindow(filectrl); - return filectrl; -} - -bool wxFileCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxFileCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_FILECTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_filepicker.cpp b/Source/3rd Party/wx/src/xrc/xh_filepicker.cpp deleted file mode 100644 index 21d8e51d5..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_filepicker.cpp +++ /dev/null @@ -1,60 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_filepicker.cpp -// Purpose: XML resource handler for wxFilePickerCtrl -// Author: Francesco Montorsi -// Created: 2006-04-17 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_FILEPICKERCTRL - -#include "wx/xrc/xh_filepicker.h" -#include "wx/filepicker.h" - -IMPLEMENT_DYNAMIC_CLASS(wxFilePickerCtrlXmlHandler, wxXmlResourceHandler) - -wxFilePickerCtrlXmlHandler::wxFilePickerCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxFLP_OPEN); - XRC_ADD_STYLE(wxFLP_SAVE); - XRC_ADD_STYLE(wxFLP_OVERWRITE_PROMPT); - XRC_ADD_STYLE(wxFLP_FILE_MUST_EXIST); - XRC_ADD_STYLE(wxFLP_CHANGE_DIR); - XRC_ADD_STYLE(wxFLP_SMALL); - XRC_ADD_STYLE(wxFLP_DEFAULT_STYLE); - XRC_ADD_STYLE(wxFLP_USE_TEXTCTRL); - AddWindowStyles(); -} - -wxObject *wxFilePickerCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(picker, wxFilePickerCtrl) - - picker->Create(m_parentAsWindow, - GetID(), - GetParamValue(wxT("value")), - GetText(wxT("message")), - GetParamValue(wxT("wildcard")), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxFLP_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - SetupWindow(picker); - return picker; -} - -bool wxFilePickerCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxFilePickerCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_FILEPICKERCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_fontpicker.cpp b/Source/3rd Party/wx/src/xrc/xh_fontpicker.cpp deleted file mode 100644 index 7d7674047..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_fontpicker.cpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_fontpicker.cpp -// Purpose: XML resource handler for wxFontPickerCtrl -// Author: Francesco Montorsi -// Created: 2006-04-17 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_FONTPICKERCTRL - -#include "wx/xrc/xh_fontpicker.h" -#include "wx/fontpicker.h" - -IMPLEMENT_DYNAMIC_CLASS(wxFontPickerCtrlXmlHandler, wxXmlResourceHandler) - -wxFontPickerCtrlXmlHandler::wxFontPickerCtrlXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxFNTP_USE_TEXTCTRL); - XRC_ADD_STYLE(wxFNTP_FONTDESC_AS_LABEL); - XRC_ADD_STYLE(wxFNTP_USEFONT_FOR_LABEL); - XRC_ADD_STYLE(wxFNTP_DEFAULT_STYLE); - AddWindowStyles(); -} - -wxObject *wxFontPickerCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(picker, wxFontPickerCtrl) - - wxFont f = *wxNORMAL_FONT; - if (HasParam(wxT("value"))) - f = GetFont(wxT("value")); - - picker->Create(m_parentAsWindow, - GetID(), - f, - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxFNTP_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - SetupWindow(picker); - - return picker; -} - -bool wxFontPickerCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxFontPickerCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_FONTPICKERCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_frame.cpp b/Source/3rd Party/wx/src/xrc/xh_frame.cpp deleted file mode 100644 index 5ad0e1ee8..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_frame.cpp +++ /dev/null @@ -1,98 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_frame.cpp -// Purpose: XRC resource for dialogs -// Author: Vaclav Slavik & Aleks. -// Created: 2000/03/05 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC - -#include "wx/xrc/xh_frame.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/frame.h" - #include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxFrameXmlHandler, wxXmlResourceHandler) - -wxFrameXmlHandler::wxFrameXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxSTAY_ON_TOP); - XRC_ADD_STYLE(wxCAPTION); - XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE); - XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE); -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxTHICK_FRAME); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxSYSTEM_MENU); - XRC_ADD_STYLE(wxRESIZE_BORDER); -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxRESIZE_BOX); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxCLOSE_BOX); - - XRC_ADD_STYLE(wxFRAME_NO_TASKBAR); - XRC_ADD_STYLE(wxFRAME_SHAPED); - XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW); - XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT); - XRC_ADD_STYLE(wxMAXIMIZE_BOX); - XRC_ADD_STYLE(wxMINIMIZE_BOX); - XRC_ADD_STYLE(wxSTAY_ON_TOP); - -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxNO_3D); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxTAB_TRAVERSAL); - XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); - XRC_ADD_STYLE(wxFRAME_EX_METAL); - XRC_ADD_STYLE(wxFRAME_EX_CONTEXTHELP); - - AddWindowStyles(); -} - -wxObject *wxFrameXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(frame, wxFrame); - - frame->Create(m_parentAsWindow, - GetID(), - GetText(wxT("title")), - wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE), - GetName()); - - if (HasParam(wxT("size"))) - frame->SetClientSize(GetSize(wxT("size"), frame)); - if (HasParam(wxT("pos"))) - frame->Move(GetPosition()); - if (HasParam(wxT("icon"))) - frame->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); - - SetupWindow(frame); - - CreateChildren(frame); - - if (GetBool(wxT("centered"), false)) - frame->Centre(); - - return frame; -} - -bool wxFrameXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxFrame")); -} - -#endif // wxUSE_XRC diff --git a/Source/3rd Party/wx/src/xrc/xh_gauge.cpp b/Source/3rd Party/wx/src/xrc/xh_gauge.cpp deleted file mode 100644 index b30741065..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_gauge.cpp +++ /dev/null @@ -1,76 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_gauge.cpp -// Purpose: XRC resource for wxGauge -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_GAUGE - -#include "wx/xrc/xh_gauge.h" - -#ifndef WX_PRECOMP - #include "wx/gauge.h" -#endif - -static const long DEFAULT_RANGE = 100; - -IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler) - -wxGaugeXmlHandler::wxGaugeXmlHandler() - :wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxGA_HORIZONTAL); - XRC_ADD_STYLE(wxGA_VERTICAL); -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxGA_PROGRESSBAR); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxGA_SMOOTH); // windows only - AddWindowStyles(); -} - -wxObject *wxGaugeXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(control, wxGauge) - - control->Create(m_parentAsWindow, - GetID(), - GetLong(wxT("range"), DEFAULT_RANGE), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - if( HasParam(wxT("value"))) - { - control->SetValue(GetLong(wxT("value"))); - } - if( HasParam(wxT("shadow"))) - { - control->SetShadowWidth(GetDimension(wxT("shadow"))); - } - if( HasParam(wxT("bezel"))) - { - control->SetBezelFace(GetDimension(wxT("bezel"))); - } - - SetupWindow(control); - - return control; -} - -bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxGauge")); -} - -#endif // wxUSE_XRC && wxUSE_GAUGE diff --git a/Source/3rd Party/wx/src/xrc/xh_gdctl.cpp b/Source/3rd Party/wx/src/xrc/xh_gdctl.cpp deleted file mode 100644 index 76ad6ba45..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_gdctl.cpp +++ /dev/null @@ -1,64 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_gdctl.cpp -// Purpose: XRC resource for wxGenericDirCtrl -// Author: Markus Greither -// Created: 2002/01/20 -// Copyright: (c) 2002 Markus Greither -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_DIRDLG - -#include "wx/xrc/xh_gdctl.h" - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" -#endif - -#include "wx/dirctrl.h" - -IMPLEMENT_DYNAMIC_CLASS(wxGenericDirCtrlXmlHandler, wxXmlResourceHandler) - -wxGenericDirCtrlXmlHandler::wxGenericDirCtrlXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxDIRCTRL_DIR_ONLY); - XRC_ADD_STYLE(wxDIRCTRL_3D_INTERNAL); - XRC_ADD_STYLE(wxDIRCTRL_SELECT_FIRST); - XRC_ADD_STYLE(wxDIRCTRL_SHOW_FILTERS); - XRC_ADD_STYLE(wxDIRCTRL_EDIT_LABELS); - XRC_ADD_STYLE(wxDIRCTRL_MULTIPLE); - AddWindowStyles(); -} - -wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl) - - ctrl->Create(m_parentAsWindow, - GetID(), - GetText(wxT("defaultfolder")), - GetPosition(), GetSize(), - GetStyle(), - GetText(wxT("filter")), - (int)GetLong(wxT("defaultfilter")), - GetName()); - - SetupWindow(ctrl); - - return ctrl; -} - -bool wxGenericDirCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxGenericDirCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_DIRDLG diff --git a/Source/3rd Party/wx/src/xrc/xh_grid.cpp b/Source/3rd Party/wx/src/xrc/xh_grid.cpp deleted file mode 100644 index 74ccf19bc..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_grid.cpp +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_grid.cpp -// Purpose: XML resource handler for the grid control -// Author: Agron Selimaj -// Created: 2005/08/11 -// Copyright: (c) 2005 Agron Selimaj, Freepour Controls Inc. -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_GRID - -#include "wx/xrc/xh_grid.h" -#include "wx/grid.h" - -IMPLEMENT_DYNAMIC_CLASS(wxGridXmlHandler, wxXmlResourceHandler) - -wxGridXmlHandler::wxGridXmlHandler() - : wxXmlResourceHandler() -{ - AddWindowStyles(); -} - -wxObject *wxGridXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(grid, wxGrid) - - grid->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - GetStyle(wxT("style")), - GetName()); - - SetupWindow( grid); - - return grid; -} - -bool wxGridXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxGrid")); -} - -#endif // wxUSE_XRC && wxUSE_GRID diff --git a/Source/3rd Party/wx/src/xrc/xh_html.cpp b/Source/3rd Party/wx/src/xrc/xh_html.cpp deleted file mode 100644 index 929c1f061..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_html.cpp +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_html.cpp -// Purpose: XRC resource for wxHtmlWindow -// Author: Bob Mitchell -// Created: 2000/03/21 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_HTML - -#include "wx/xrc/xh_html.h" - -#include "wx/html/htmlwin.h" -#include "wx/filesys.h" - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler) - -wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() -: wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER); - XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO); - XRC_ADD_STYLE(wxHW_NO_SELECTION); - AddWindowStyles(); -} - -wxObject *wxHtmlWindowXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(control, wxHtmlWindow) - - control->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO), - GetName()); - - if (HasParam(wxT("borders"))) - { - control->SetBorders(GetDimension(wxT("borders"))); - } - - if (HasParam(wxT("url"))) - { - wxString url = GetParamValue(wxT("url")); - wxFileSystem& fsys = GetCurFileSystem(); - - wxFSFile *f = fsys.OpenFile(url); - if (f) - { - control->LoadPage(f->GetLocation()); - delete f; - } - else - control->LoadPage(url); - } - - else if (HasParam(wxT("htmlcode"))) - { - control->SetPage(GetText(wxT("htmlcode"))); - } - - SetupWindow(control); - - return control; -} - -bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxHtmlWindow")); -} - -#endif // wxUSE_XRC && wxUSE_HTML diff --git a/Source/3rd Party/wx/src/xrc/xh_htmllbox.cpp b/Source/3rd Party/wx/src/xrc/xh_htmllbox.cpp deleted file mode 100644 index f2af2a89c..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_htmllbox.cpp +++ /dev/null @@ -1,87 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_simplehtmllbox.cpp -// Purpose: XML resource handler for wxSimpleHtmlListBox -// Author: Francesco Montorsi -// Created: 2006/10/21 -// Copyright: (c) 2006 Francesco Montorsi -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_HTML - -#include "wx/xrc/xh_htmllbox.h" - -#include "wx/htmllbox.h" -#include "wx/filesys.h" - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler, wxXmlResourceHandler) - -wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler() -: wxXmlResourceHandler(), m_insideBox(false) -{ - XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE); - XRC_ADD_STYLE(wxHLB_MULTIPLE); - AddWindowStyles(); -} - -wxObject *wxSimpleHtmlListBoxXmlHandler::DoCreateResource() -{ - if ( m_class == wxT("wxSimpleHtmlListBox")) - { - // find the selection - long selection = GetLong(wxT("selection"), -1); - - // need to build the list of strings from children - m_insideBox = true; - CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); - m_insideBox = false; - - XRC_MAKE_INSTANCE(control, wxSimpleHtmlListBox) - - control->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - strList, - GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE), - wxDefaultValidator, - GetName()); - - if (selection != -1) - control->SetSelection(selection); - - SetupWindow(control); - strList.Clear(); // dump the strings - - return control; - } - else - { - // on the inside now. - // handle Label - - // add to the list - wxString str = GetNodeContent(m_node); - if (m_resource->GetFlags() & wxXRC_USE_LOCALE) - str = wxGetTranslation(str, m_resource->GetDomain()); - strList.Add(str); - - return NULL; - } -} - -bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxSimpleHtmlListBox")) || - (m_insideBox && node->GetName() == wxT("item"))); -} - -#endif // wxUSE_XRC && wxUSE_HTML diff --git a/Source/3rd Party/wx/src/xrc/xh_hyperlink.cpp b/Source/3rd Party/wx/src/xrc/xh_hyperlink.cpp deleted file mode 100644 index 870b7b470..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_hyperlink.cpp +++ /dev/null @@ -1,87 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_hyperlink.cpp -// Purpose: Hyperlink control -// Author: David Norris -// Modified by: Ryan Norton, Francesco Montorsi -// Created: 04/02/2005 -// Copyright: (c) 2005 David Norris -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -//=========================================================================== -// Declarations -//=========================================================================== - -//--------------------------------------------------------------------------- -// Pre-compiled header stuff -//--------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_HYPERLINKCTRL - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- - -#include "wx/xrc/xh_hyperlink.h" - -#ifndef WX_PRECOMP -#endif - -#include "wx/hyperlink.h" -#include "wx/xrc/xmlres.h" - -//=========================================================================== -// Implementation -//=========================================================================== - -//--------------------------------------------------------------------------- -// wxHyperlinkCtrlXmlHandler -//--------------------------------------------------------------------------- - -// Register with wxWindows' dynamic class subsystem. -IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkCtrlXmlHandler, wxXmlResourceHandler) - -wxHyperlinkCtrlXmlHandler::wxHyperlinkCtrlXmlHandler() -{ - XRC_ADD_STYLE(wxHL_CONTEXTMENU); - XRC_ADD_STYLE(wxHL_ALIGN_LEFT); - XRC_ADD_STYLE(wxHL_ALIGN_RIGHT); - XRC_ADD_STYLE(wxHL_ALIGN_CENTRE); - XRC_ADD_STYLE(wxHL_DEFAULT_STYLE); - - AddWindowStyles(); -} - -wxObject *wxHyperlinkCtrlXmlHandler::DoCreateResource() -{ - XRC_MAKE_INSTANCE(control, wxHyperlinkCtrl) - - control->Create - ( - m_parentAsWindow, - GetID(), - GetText(wxT("label")), - GetParamValue(wxT("url")), - GetPosition(), GetSize(), - GetStyle(wxT("style"), wxHL_DEFAULT_STYLE), - GetName() - ); - - SetupWindow(control); - - return control; -} - -bool wxHyperlinkCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxHyperlinkCtrl")); -} - -#endif // wxUSE_XRC && wxUSE_HYPERLINKCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_listb.cpp b/Source/3rd Party/wx/src/xrc/xh_listb.cpp deleted file mode 100644 index cde163372..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_listb.cpp +++ /dev/null @@ -1,95 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_listb.cpp -// Purpose: XRC resource for wxListBox -// Author: Bob Mitchell & Vaclav Slavik -// Created: 2000/07/29 -// Copyright: (c) 2000 Bob Mitchell and Verant Interactive -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_LISTBOX - -#include "wx/xrc/xh_listb.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/listbox.h" -#endif - -#include "wx/xml/xml.h" - -IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler) - -wxListBoxXmlHandler::wxListBoxXmlHandler() - : wxXmlResourceHandler(), - m_insideBox(false) -{ - XRC_ADD_STYLE(wxLB_SINGLE); - XRC_ADD_STYLE(wxLB_MULTIPLE); - XRC_ADD_STYLE(wxLB_EXTENDED); - XRC_ADD_STYLE(wxLB_HSCROLL); - XRC_ADD_STYLE(wxLB_ALWAYS_SB); - XRC_ADD_STYLE(wxLB_NEEDED_SB); - XRC_ADD_STYLE(wxLB_SORT); - AddWindowStyles(); -} - -wxObject *wxListBoxXmlHandler::DoCreateResource() -{ - if ( m_class == wxT("wxListBox")) - { - // find the selection - long selection = GetLong(wxT("selection"), -1); - - // need to build the list of strings from children - m_insideBox = true; - CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); - m_insideBox = false; - - XRC_MAKE_INSTANCE(control, wxListBox) - - control->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - strList, - GetStyle(), - wxDefaultValidator, - GetName()); - - if (selection != -1) - control->SetSelection(selection); - - SetupWindow(control); - strList.Clear(); // dump the strings - - return control; - } - else - { - // on the inside now. - // handle Label - - // add to the list - wxString str = GetNodeContent(m_node); - if (m_resource->GetFlags() & wxXRC_USE_LOCALE) - str = wxGetTranslation(str, m_resource->GetDomain()); - strList.Add(str); - - return NULL; - } -} - -bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxListBox")) || - (m_insideBox && node->GetName() == wxT("item"))); -} - -#endif // wxUSE_XRC && wxUSE_LISTBOX diff --git a/Source/3rd Party/wx/src/xrc/xh_listbk.cpp b/Source/3rd Party/wx/src/xrc/xh_listbk.cpp deleted file mode 100644 index f7bf2c58b..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_listbk.cpp +++ /dev/null @@ -1,143 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_listbk.cpp -// Purpose: XRC resource for wxListbook -// Author: Vaclav Slavik -// Created: 2000/03/21 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_LISTBOOK - -#include "wx/xrc/xh_listbk.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/sizer.h" -#endif - -#include "wx/listbook.h" -#include "wx/imaglist.h" - -IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler, wxXmlResourceHandler) - -wxListbookXmlHandler::wxListbookXmlHandler() - :wxXmlResourceHandler(), - m_isInside(false), - m_listbook(NULL) -{ - XRC_ADD_STYLE(wxBK_DEFAULT); - XRC_ADD_STYLE(wxBK_LEFT); - XRC_ADD_STYLE(wxBK_RIGHT); - XRC_ADD_STYLE(wxBK_TOP); - XRC_ADD_STYLE(wxBK_BOTTOM); - - XRC_ADD_STYLE(wxLB_DEFAULT); - XRC_ADD_STYLE(wxLB_LEFT); - XRC_ADD_STYLE(wxLB_RIGHT); - XRC_ADD_STYLE(wxLB_TOP); - XRC_ADD_STYLE(wxLB_BOTTOM); - - AddWindowStyles(); -} - -wxObject *wxListbookXmlHandler::DoCreateResource() -{ - if (m_class == wxT("listbookpage")) - { - wxXmlNode *n = GetParamNode(wxT("object")); - - if ( !n ) - n = GetParamNode(wxT("object_ref")); - - if (n) - { - bool old_ins = m_isInside; - m_isInside = false; - wxObject *item = CreateResFromNode(n, m_listbook, NULL); - m_isInside = old_ins; - wxWindow *wnd = wxDynamicCast(item, wxWindow); - - if (wnd) - { - m_listbook->AddPage(wnd, GetText(wxT("label")), - GetBool(wxT("selected"))); - if ( HasParam(wxT("bitmap")) ) - { - wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); - wxImageList *imgList = m_listbook->GetImageList(); - if ( imgList == NULL ) - { - imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); - m_listbook->AssignImageList( imgList ); - } - int imgIndex = imgList->Add(bmp); - m_listbook->SetPageImage(m_listbook->GetPageCount()-1, imgIndex ); - } - else if ( HasParam(wxT("image")) ) - { - if ( m_listbook->GetImageList() ) - { - m_listbook->SetPageImage(m_listbook->GetPageCount()-1, - GetLong(wxT("image")) ); - } - else // image without image list? - { - ReportError(n, "image can only be used in conjunction " - "with imagelist"); - } - } - } - else - { - ReportError(n, "listbookpage child must be a window"); - } - return wnd; - } - else - { - ReportError("listbookpage must have a window child"); - return NULL; - } - } - - else - { - XRC_MAKE_INSTANCE(nb, wxListbook) - - nb->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - GetStyle(wxT("style")), - GetName()); - - wxImageList *imagelist = GetImageList(); - if ( imagelist ) - nb->AssignImageList(imagelist); - - wxListbook *old_par = m_listbook; - m_listbook = nb; - bool old_ins = m_isInside; - m_isInside = true; - CreateChildren(m_listbook, true/*only this handler*/); - m_isInside = old_ins; - m_listbook = old_par; - - return nb; - } -} - -bool wxListbookXmlHandler::CanHandle(wxXmlNode *node) -{ - return ((!m_isInside && IsOfClass(node, wxT("wxListbook"))) || - (m_isInside && IsOfClass(node, wxT("listbookpage")))); -} - -#endif // wxUSE_XRC && wxUSE_LISTBOOK diff --git a/Source/3rd Party/wx/src/xrc/xh_listc.cpp b/Source/3rd Party/wx/src/xrc/xh_listc.cpp deleted file mode 100644 index c4fb4e446..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_listc.cpp +++ /dev/null @@ -1,265 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_listc.cpp -// Purpose: XRC resource for wxListCtrl -// Author: Brian Gavin, Kinaou Hervé, Vadim Zeitlin -// Created: 2000/09/09 -// Copyright: (c) 2000 Brian Gavin -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_LISTCTRL - -#include "wx/xrc/xh_listc.h" - -#ifndef WX_PRECOMP - #include "wx/textctrl.h" -#endif - -#include "wx/listctrl.h" -#include "wx/imaglist.h" - -namespace -{ - -const char *LISTCTRL_CLASS_NAME = "wxListCtrl"; -const char *LISTITEM_CLASS_NAME = "listitem"; -const char *LISTCOL_CLASS_NAME = "listcol"; - -} // anonymous namespace - - -IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler) - -wxListCtrlXmlHandler::wxListCtrlXmlHandler() - : wxXmlResourceHandler() -{ - // wxListItem styles - XRC_ADD_STYLE(wxLIST_FORMAT_LEFT); - XRC_ADD_STYLE(wxLIST_FORMAT_RIGHT); - XRC_ADD_STYLE(wxLIST_FORMAT_CENTRE); - XRC_ADD_STYLE(wxLIST_MASK_STATE); - XRC_ADD_STYLE(wxLIST_MASK_TEXT); - XRC_ADD_STYLE(wxLIST_MASK_IMAGE); - XRC_ADD_STYLE(wxLIST_MASK_DATA); - XRC_ADD_STYLE(wxLIST_MASK_WIDTH); - XRC_ADD_STYLE(wxLIST_MASK_FORMAT); - XRC_ADD_STYLE(wxLIST_STATE_FOCUSED); - XRC_ADD_STYLE(wxLIST_STATE_SELECTED); - - // wxListCtrl styles - XRC_ADD_STYLE(wxLC_LIST); - XRC_ADD_STYLE(wxLC_REPORT); - XRC_ADD_STYLE(wxLC_ICON); - XRC_ADD_STYLE(wxLC_SMALL_ICON); - XRC_ADD_STYLE(wxLC_ALIGN_TOP); - XRC_ADD_STYLE(wxLC_ALIGN_LEFT); - XRC_ADD_STYLE(wxLC_AUTOARRANGE); - XRC_ADD_STYLE(wxLC_USER_TEXT); - XRC_ADD_STYLE(wxLC_EDIT_LABELS); - XRC_ADD_STYLE(wxLC_NO_HEADER); - XRC_ADD_STYLE(wxLC_SINGLE_SEL); - XRC_ADD_STYLE(wxLC_SORT_ASCENDING); - XRC_ADD_STYLE(wxLC_SORT_DESCENDING); - XRC_ADD_STYLE(wxLC_VIRTUAL); - XRC_ADD_STYLE(wxLC_HRULES); - XRC_ADD_STYLE(wxLC_VRULES); - XRC_ADD_STYLE(wxLC_NO_SORT_HEADER); - AddWindowStyles(); -} - -wxObject *wxListCtrlXmlHandler::DoCreateResource() -{ - if ( m_class == LISTITEM_CLASS_NAME ) - { - HandleListItem(); - } - else if ( m_class == LISTCOL_CLASS_NAME ) - { - HandleListCol(); - } - else - { - wxASSERT_MSG( m_class == LISTCTRL_CLASS_NAME, - "can't handle unknown node" ); - - return HandleListCtrl(); - } - - return m_parentAsWindow; -} - -bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, LISTCTRL_CLASS_NAME) || - IsOfClass(node, LISTITEM_CLASS_NAME) || - IsOfClass(node, LISTCOL_CLASS_NAME); -} - -void wxListCtrlXmlHandler::HandleCommonItemAttrs(wxListItem& item) -{ - if (HasParam(wxT("align"))) - item.SetAlign((wxListColumnFormat)GetStyle(wxT("align"))); - if (HasParam(wxT("text"))) - item.SetText(GetText(wxT("text"))); -} - -void wxListCtrlXmlHandler::HandleListCol() -{ - wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl); - wxCHECK_RET( list, "must have wxListCtrl parent" ); - - if ( !list->HasFlag(wxLC_REPORT) ) - { - ReportError("Only report mode list controls can have columns."); - return; - } - - wxListItem item; - - HandleCommonItemAttrs(item); - if (HasParam(wxT("width"))) - item.SetWidth((int)GetLong(wxT("width"))); - if (HasParam(wxT("image"))) - item.SetImage((int)GetLong(wxT("image"))); - - list->InsertColumn(list->GetColumnCount(), item); -} - -void wxListCtrlXmlHandler::HandleListItem() -{ - wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl); - wxCHECK_RET( list, "must have wxListCtrl parent" ); - - wxListItem item; - - HandleCommonItemAttrs(item); - - if (HasParam(wxT("bg"))) - item.SetBackgroundColour(GetColour(wxT("bg"))); - if (HasParam(wxT("col"))) - item.SetColumn((int)GetLong(wxT("col"))); - if (HasParam(wxT("data"))) - item.SetData(GetLong(wxT("data"))); - if (HasParam(wxT("font"))) - item.SetFont(GetFont(wxT("font"), list)); - if (HasParam(wxT("state"))) - item.SetState(GetStyle(wxT("state"))); - if (HasParam(wxT("textcolour"))) - item.SetTextColour(GetColour(wxT("textcolour"))); - if (HasParam(wxT("textcolor"))) - item.SetTextColour(GetColour(wxT("textcolor"))); - - // the list control icon style, may be 0 - int image; - if ( list->HasFlag(wxLC_ICON) ) - image = GetImageIndex(list, wxIMAGE_LIST_NORMAL); - else if ( list->HasFlag(wxLC_SMALL_ICON) || list->HasFlag(wxLC_REPORT) || list->HasFlag(wxLC_LIST) ) - image = GetImageIndex(list, wxIMAGE_LIST_SMALL); - else - image = wxNOT_FOUND; - - if ( image != wxNOT_FOUND ) - item.SetImage(image); - - // append the list item to the control - item.SetId(list->GetItemCount()); - - list->InsertItem(item); -} - -wxListCtrl *wxListCtrlXmlHandler::HandleListCtrl() -{ - XRC_MAKE_INSTANCE(list, wxListCtrl) - - list->Create(m_parentAsWindow, - GetID(), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); - - // we can optionally have normal and/or small image lists - wxImageList *imagelist; - imagelist = GetImageList(wxT("imagelist")); - if ( imagelist ) - list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL); - imagelist = GetImageList(wxT("imagelist-small")); - if ( imagelist ) - list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL); - - CreateChildrenPrivately(list); - SetupWindow(list); - - return list; -} - -long wxListCtrlXmlHandler::GetImageIndex(wxListCtrl *listctrl, int which) -{ - // use different tag names depending on whether we need a normal or small - // image - wxString - bmpParam("bitmap"), - imgParam("image"); - switch ( which ) - { - case wxIMAGE_LIST_SMALL: - bmpParam += "-small"; - imgParam += "-small"; - break; - - case wxIMAGE_LIST_NORMAL: - // nothing to do - break; - - default: - wxFAIL_MSG( "unsupported image list kind" ); - return wxNOT_FOUND; - } - - // look for either bitmap or image tags - int imgIndex = wxNOT_FOUND; - if ( HasParam(bmpParam) ) - { - // we implicitly construct an image list containing the specified - // bitmaps - wxBitmap bmp = GetBitmap(bmpParam, wxART_OTHER); - - // create the image list on demand for the first bitmap - wxImageList *imgList = listctrl->GetImageList(which); - if ( !imgList ) - { - imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); - listctrl->AssignImageList( imgList, which ); - } - - imgIndex = imgList->Add(bmp); - } - - if ( HasParam(imgParam) ) - { - if ( imgIndex != wxNOT_FOUND ) - { - // TODO: we should really check that only bitmap or only image tags - // are used across all items of the control, not just in this - // one - ReportError(wxString::Format( - "listitem %s attribute ignored because %s is also specified", - bmpParam, imgParam)); - } - - // just use the specified index directly - imgIndex = GetLong(imgParam); - } - - return imgIndex; -} - -#endif // wxUSE_XRC && wxUSE_LISTCTRL diff --git a/Source/3rd Party/wx/src/xrc/xh_mdi.cpp b/Source/3rd Party/wx/src/xrc/xh_mdi.cpp deleted file mode 100644 index 021934231..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_mdi.cpp +++ /dev/null @@ -1,138 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_mdi.cpp -// Purpose: XRC resource for wxMDI -// Author: David M. Falkinder & Vaclav Slavik -// Created: 14/02/2005 -// Copyright: (c) 2005 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_MDI - -#include "wx/xrc/xh_mdi.h" -#include "wx/mdi.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" - #include "wx/log.h" - #include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler) - -wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxSTAY_ON_TOP); - XRC_ADD_STYLE(wxCAPTION); - XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE); - XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE); -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxTHICK_FRAME); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxSYSTEM_MENU); - XRC_ADD_STYLE(wxRESIZE_BORDER); -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxRESIZE_BOX); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxCLOSE_BOX); - - XRC_ADD_STYLE(wxFRAME_NO_TASKBAR); - XRC_ADD_STYLE(wxFRAME_SHAPED); - XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW); - XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT); - XRC_ADD_STYLE(wxMAXIMIZE_BOX); - XRC_ADD_STYLE(wxMINIMIZE_BOX); - XRC_ADD_STYLE(wxSTAY_ON_TOP); - -#if WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxNO_3D); -#endif // WXWIN_COMPATIBILITY_2_6 - XRC_ADD_STYLE(wxTAB_TRAVERSAL); - XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); - XRC_ADD_STYLE(wxFRAME_EX_METAL); - - XRC_ADD_STYLE(wxHSCROLL); - XRC_ADD_STYLE(wxVSCROLL); - XRC_ADD_STYLE(wxMAXIMIZE); - XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU); - - AddWindowStyles(); -} - -wxWindow *wxMdiXmlHandler::CreateFrame() -{ - if (m_class == wxT("wxMDIParentFrame")) - { - XRC_MAKE_INSTANCE(frame, wxMDIParentFrame); - - frame->Create(m_parentAsWindow, - GetID(), - GetText(wxT("title")), - wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), - wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL), - GetName()); - return frame; - } - else // wxMDIChildFrame - { - wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame); - - if ( !mdiParent ) - { - ReportError("parent of wxMDIChildFrame must be wxMDIParentFrame"); - return NULL; - } - - XRC_MAKE_INSTANCE(frame, wxMDIChildFrame); - - frame->Create(mdiParent, - GetID(), - GetText(wxT("title")), - wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE), - GetName()); - - return frame; - } -} - -wxObject *wxMdiXmlHandler::DoCreateResource() -{ - wxWindow *frame = CreateFrame(); - - if (HasParam(wxT("size"))) - frame->SetClientSize(GetSize()); - if (HasParam(wxT("pos"))) - frame->Move(GetPosition()); - if (HasParam(wxT("icon"))) - { - wxFrame* f = wxDynamicCast(frame, wxFrame); - if (f) - f->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); - } - - SetupWindow(frame); - - CreateChildren(frame); - - if (GetBool(wxT("centered"), false)) - frame->Centre(); - - return frame; -} - -bool wxMdiXmlHandler::CanHandle(wxXmlNode *node) -{ - return (IsOfClass(node, wxT("wxMDIParentFrame")) || - IsOfClass(node, wxT("wxMDIChildFrame"))); -} - -#endif // wxUSE_XRC && wxUSE_MDI diff --git a/Source/3rd Party/wx/src/xrc/xh_menu.cpp b/Source/3rd Party/wx/src/xrc/xh_menu.cpp deleted file mode 100644 index 0865063dc..000000000 --- a/Source/3rd Party/wx/src/xrc/xh_menu.cpp +++ /dev/null @@ -1,180 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/xrc/xh_menu.cpp -// Purpose: XRC resource for menus and menubars -// Author: Vaclav Slavik -// Created: 2000/03/05 -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_XRC && wxUSE_MENUS - -#include "wx/xrc/xh_menu.h" - -#ifndef WX_PRECOMP - #include "wx/frame.h" - #include "wx/log.h" - #include "wx/menu.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler) - -wxMenuXmlHandler::wxMenuXmlHandler() : - wxXmlResourceHandler(), m_insideMenu(false) -{ - XRC_ADD_STYLE(wxMENU_TEAROFF); -} - -wxObject *wxMenuXmlHandler::DoCreateResource() -{ - if (m_class == wxT("wxMenu")) - { - wxMenu *menu = m_instance ? wxStaticCast(m_instance, wxMenu) - : new wxMenu(GetStyle()); - - wxString title = GetText(wxT("label")); - wxString help = GetText(wxT("help")); - - bool oldins = m_insideMenu; - m_insideMenu = true; - CreateChildren(menu, true/*only this handler*/); - m_insideMenu = oldins; - - wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar); - if (p_bar) - { - p_bar->Append(menu, title); - } - else - { - wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); - if (p_menu) - { - p_menu->Append(GetID(), title, menu, help); - if (HasParam(wxT("enabled"))) - p_menu->Enable(GetID(), GetBool(wxT("enabled"))); - } - } - - return menu; - } - - else - { - wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); - - if (m_class == wxT("separator")) - p_menu->AppendSeparator(); - else if (m_class == wxT("break")) - p_menu->Break(); - else /*wxMenuItem*/ - { - int id = GetID(); - wxString label = GetText(wxT("label")); - wxString accel = GetText(wxT("accel"), false); - wxString fullLabel = label; - if (!accel.empty()) - fullLabel << wxT("\t") << accel; - - wxItemKind kind = wxITEM_NORMAL; - if (GetBool(wxT("radio"))) - kind = wxITEM_RADIO; - if (GetBool(wxT("checkable"))) - { - if ( kind != wxITEM_NORMAL ) - { - ReportParamError - ( - "checkable", - "menu item can't have both and properties" - ); - } - - kind = wxITEM_CHECK; - } - - wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel, - GetText(wxT("help")), kind); - -#if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN - if (HasParam(wxT("bitmap"))) - { - // currently only wxMSW has support for using different checked - // and unchecked bitmaps for menu items -#ifdef __WXMSW__ - if (HasParam(wxT("bitmap2"))) - mitem->SetBitmaps(GetBitmap(wxT("bitmap2"), wxART_MENU), - GetBitmap(wxT("bitmap"), wxART_MENU)); - else -#endif // __WXMSW__ - mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU)); - } -#endif - p_menu->Append(mitem); - mitem->Enable(GetBool(wxT("enabled"), true)); - if (kind == wxITEM_CHECK) - mitem->Check(GetBool(wxT("checked"))); - } - return NULL; - } -} - - - -bool wxMenuXmlHandler::CanHandle(wxXmlNode *node) -{ - return IsOfClass(node, wxT("wxMenu")) || - (m_insideMenu && - (IsOfClass(node, wxT("wxMenuItem")) || - IsOfClass(node, wxT("break")) || - IsOfClass(node, wxT("separator"))) - ); -} - -IMPLEMENT_DYNAMIC_CLASS(wxMenuBarXmlHandler, wxXmlResourceHandler) - -wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler() -{ - XRC_ADD_STYLE(wxMB_DOCKABLE); -} - -wxObject *wxMenuBarXmlHandler::DoCreateResource() -{ - wxMenuBar *menubar = NULL; - - const int style = GetStyle(); - wxASSERT_MSG(!style || !m_instance, - "cannot use